From b83f43371409b15da635177a7e9db7ffbca38ae5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingy=20d=C3=B6t=20Net?= Date: Wed, 10 Apr 2013 23:57:08 -0700 Subject: [PATCH] tasks a-s --- Conf/task.yaml | 154 ++++- Lang/0815/Binary-digits | 1 + Lang/0815/Reverse-a-string | 1 + Lang/4DOS-Batch/Repeat-a-string | 1 + Lang/6502-Assembly/Rot-13 | 1 + Lang/6800-Assembly/Loops-Infinite | 1 + Lang/ABAP/Copy-a-string | 1 + Lang/ABAP/Permutations | 1 + Lang/ABAP/Prime-decomposition | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/ACL2/Binary-digits | 1 + Lang/ACL2/Non-decimal-radices-Convert | 1 + Lang/ACL2/One-dimensional-cellular-automata | 1 + Lang/ACL2/Palindrome-detection | 1 + Lang/ACL2/Pangram-checker | 1 + Lang/ACL2/Pick-random-element | 1 + Lang/ACL2/Playing-cards | 1 + Lang/ACL2/Primality-by-trial-division | 1 + Lang/ACL2/Prime-decomposition | 1 + Lang/ACL2/Queue-Definition | 1 + Lang/ACL2/Real-constants-and-functions | 1 + Lang/ACL2/Remove-duplicate-elements | 1 + Lang/ACL2/Return-multiple-values | 1 + Lang/ACL2/Reverse-a-string | 1 + Lang/ACL2/Rot-13 | 1 + Lang/ALGOL-68/Binary-digits | 1 + Lang/ALGOL-68/Calendar---for-real-programmers | 1 + Lang/ALGOL-68/Calendar-for-real-programmers | 1 - Lang/ALGOL-68/Copy-a-string | 1 + Lang/ALGOL-68/Dragon-curve | 1 + Lang/ALGOL-68/Environment-variables | 1 + Lang/ALGOL-68/N-queens-problem | 1 + Lang/ALGOL-68/Named-parameters | 1 + Lang/ALGOL-68/Non-continuous-subsequences | 1 + Lang/ALGOL-68/Non-decimal-radices-Convert | 1 + Lang/ALGOL-68/Non-decimal-radices-Input | 1 + Lang/ALGOL-68/Non-decimal-radices-Output | 1 + Lang/ALGOL-68/Nth-root | 1 + Lang/ALGOL-68/Null-object | 1 + Lang/ALGOL-68/Number-names | 1 + Lang/ALGOL-68/Numerical-integration | 1 + Lang/ALGOL-68/Object-serialization | 1 + .../One-dimensional-cellular-automata | 1 + Lang/ALGOL-68/Palindrome-detection | 1 + Lang/ALGOL-68/Pangram-checker | 1 + Lang/ALGOL-68/Partial-function-application | 1 + Lang/ALGOL-68/Pascals-triangle | 1 + Lang/ALGOL-68/Pascals-triangle-Puzzle | 1 + Lang/ALGOL-68/Perfect-numbers | 1 + Lang/ALGOL-68/Permutations | 1 + Lang/ALGOL-68/Playing-cards | 1 + Lang/ALGOL-68/Plot-coordinate-pairs | 1 + Lang/ALGOL-68/Pointers-and-references | 1 + Lang/ALGOL-68/Polynomial-regression | 1 + Lang/ALGOL-68/Power-set | 1 + Lang/ALGOL-68/Pragmatic-directives | 1 + Lang/ALGOL-68/Price-fraction | 1 + Lang/ALGOL-68/Primality-by-trial-division | 1 + Lang/ALGOL-68/Prime-decomposition | 1 + Lang/ALGOL-68/Probabilistic-choice | 1 + Lang/ALGOL-68/Program-termination | 1 + Lang/ALGOL-68/Quaternion-type | 1 + .../Random-number-generator--included- | 1 + Lang/ALGOL-68/Random-numbers | 1 + Lang/ALGOL-68/Range-expansion | 1 + Lang/ALGOL-68/Range-extraction | 1 + Lang/ALGOL-68/Read-a-file-line-by-line | 1 + Lang/ALGOL-68/Read-entire-file | 1 + Lang/ALGOL-68/Real-constants-and-functions | 1 + Lang/ALGOL-68/Reduced-row-echelon-form | 1 + Lang/ALGOL-68/Regular-expressions | 1 + Lang/ALGOL-68/Rename-a-file | 1 + Lang/ALGOL-68/Repeat-a-string | 1 + Lang/ALGOL-68/Reverse-a-string | 1 + Lang/ALGOL-68/Roman-numerals-Decode | 1 + Lang/ALGOL-68/Roman-numerals-Encode | 1 + Lang/ALGOL-68/Roots-of-a-function | 1 + Lang/ALGOL-68/Roots-of-a-quadratic-function | 1 + Lang/ALGOL-68/Roots-of-unity | 1 + .../Rosetta-Code-Rank-languages-by-popularity | 1 + Lang/ALGOL-68/Rot-13 | 1 + Lang/ALGOL-68/Run-length-encoding | 1 + Lang/ALGOL-68/Runtime-evaluation | 1 + .../Runtime-evaluation-In-an-environment | 1 + Lang/ALGOL-68/SEDOLs | 1 + Lang/ALGOL-68/Sequence-of-non-squares | 1 + Lang/ALGOL-W/Roman-numerals-Encode | 1 + Lang/ANTLR/Parsing-RPN-calculator-algorithm | 1 + Lang/ANTLR/Roman-numerals-Decode | 1 + Lang/APL/Pangram-checker | 1 + Lang/APL/Pascals-triangle | 1 + Lang/APL/Run-length-encoding | 1 + Lang/ATS/Return-multiple-values | 1 + Lang/AWK/Binary-digits | 1 + Lang/AWK/Catalan-numbers | 1 + Lang/AWK/Copy-a-string | 1 + Lang/AWK/Environment-variables | 1 + Lang/AWK/Non-decimal-radices-Convert | 1 + Lang/AWK/Non-decimal-radices-Output | 1 + Lang/AWK/Nth-root | 1 + Lang/AWK/Number-names | 1 + Lang/AWK/Number-reversal-game | 1 + Lang/AWK/One-dimensional-cellular-automata | 1 + Lang/AWK/Palindrome-detection | 1 + Lang/AWK/Pangram-checker | 1 + Lang/AWK/Parsing-RPN-to-infix-conversion | 1 + Lang/AWK/Pascals-triangle | 1 + Lang/AWK/Perfect-numbers | 1 + Lang/AWK/Price-fraction | 1 + Lang/AWK/Primality-by-trial-division | 1 + Lang/AWK/Prime-decomposition | 1 + Lang/AWK/Probabilistic-choice | 1 + Lang/AWK/Program-termination | 1 + Lang/AWK/Queue-Definition | 1 + Lang/AWK/Random-numbers | 1 + Lang/AWK/Range-extraction | 1 + Lang/AWK/Read-a-file-line-by-line | 1 + Lang/AWK/Read-a-specific-line-from-a-file | 1 + Lang/AWK/Read-entire-file | 1 + Lang/AWK/Real-constants-and-functions | 1 + Lang/AWK/Regular-expressions | 1 + Lang/AWK/Remove-duplicate-elements | 1 + Lang/AWK/Remove-lines-from-a-file | 1 + Lang/AWK/Rename-a-file | 1 + Lang/AWK/Repeat-a-string | 1 + Lang/AWK/Reverse-a-string | 1 + Lang/AWK/Roman-numerals-Decode | 1 + Lang/AWK/Roman-numerals-Encode | 1 + .../Rosetta-Code-Rank-languages-by-popularity | 1 + Lang/AWK/Rot-13 | 1 + Lang/AWK/Run-length-encoding | 1 + Lang/AWK/SEDOLs | 1 + Lang/AWK/Scope-Function-names-and-labels | 1 + Lang/AWK/Self-describing-numbers | 1 + Lang/AWK/Semordnilap | 1 + Lang/AWK/Sequence-of-non-squares | 1 + Lang/ActionScript/Copy-a-string | 1 + Lang/ActionScript/Null-object | 1 + Lang/ActionScript/Numerical-integration | 1 + Lang/ActionScript/Palindrome-detection | 1 + Lang/ActionScript/Pangram-checker | 1 + Lang/ActionScript/Polymorphism | 1 + Lang/ActionScript/Primality-by-trial-division | 1 + .../ActionScript/Real-constants-and-functions | 1 + Lang/ActionScript/Reduced-row-echelon-form | 1 + Lang/ActionScript/Repeat-a-string | 1 + Lang/ActionScript/Reverse-a-string | 1 + Lang/ActionScript/Roman-numerals-Encode | 1 + Lang/ActionScript/SEDOLs | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Ada/Arbitrary-precision-integers-included | 1 - Lang/Ada/Binary-digits | 1 + Lang/Ada/Calendar---for-real-programmers | 1 + Lang/Ada/Calendar-for-real-programmers | 1 - Lang/Ada/Catalan-numbers | 1 + Lang/Ada/Copy-a-string | 1 + Lang/Ada/Environment-variables | 1 + Lang/Ada/Execute-a-Markov-algorithm | 1 + .../Guess-the-number-With-feedback--player- | 1 + .../Ada/Guess-the-number-With-feedback-player | 1 - Lang/Ada/N-queens-problem | 1 + Lang/Ada/Named-parameters | 1 + Lang/Ada/Non-continuous-subsequences | 1 + Lang/Ada/Non-decimal-radices-Convert | 1 + Lang/Ada/Non-decimal-radices-Input | 1 + Lang/Ada/Non-decimal-radices-Output | 1 + Lang/Ada/Nth-root | 1 + Lang/Ada/Null-object | 1 + Lang/Ada/Number-names | 1 + Lang/Ada/Number-reversal-game | 1 + Lang/Ada/Numeric-error-propagation | 1 + Lang/Ada/Numerical-integration | 1 + Lang/Ada/Object-serialization | 1 + Lang/Ada/One-dimensional-cellular-automata | 1 + Lang/Ada/One-of-n-lines-in-a-file | 1 + Lang/Ada/OpenGL | 1 + Lang/Ada/Optional-parameters | 1 + Lang/Ada/Order-two-numerical-lists | 1 + Lang/Ada/Ordered-Partitions | 1 + Lang/Ada/Palindrome-detection | 1 + Lang/Ada/Pangram-checker | 1 + Lang/Ada/Parallel-calculations | 1 + Lang/Ada/Parametric-polymorphism | 1 + Lang/Ada/Parametrized-SQL-statement | 1 + Lang/Ada/Parsing-RPN-calculator-algorithm | 1 + Lang/Ada/Parsing-RPN-to-infix-conversion | 1 + Lang/Ada/Partial-function-application | 1 + Lang/Ada/Pascals-triangle | 1 + Lang/Ada/Pascals-triangle-Puzzle | 1 + Lang/Ada/Percentage-difference-between-images | 1 + Lang/Ada/Perfect-numbers | 1 + Lang/Ada/Permutation-test | 1 + Lang/Ada/Permutations | 1 + Lang/Ada/Permutations-Derangements | 1 + Lang/Ada/Pick-random-element | 1 + Lang/Ada/Pig-the-dice-game | 1 + Lang/Ada/Pig-the-dice-game-Player | 1 + Lang/Ada/Plot-coordinate-pairs | 1 + Lang/Ada/Pointers-and-references | 1 + Lang/Ada/Polymorphic-copy | 1 + Lang/Ada/Polymorphism | 1 + Lang/Ada/Polynomial-long-division | 1 + Lang/Ada/Polynomial-regression | 1 + Lang/Ada/Power-set | 1 + Lang/Ada/Price-fraction | 1 + Lang/Ada/Primality-by-trial-division | 1 + Lang/Ada/Prime-decomposition | 1 + Lang/Ada/Priority-queue | 1 + Lang/Ada/Probabilistic-choice | 1 + Lang/Ada/Problem-of-Apollonius | 1 + Lang/Ada/Program-name | 1 + Lang/Ada/Program-termination | 1 + Lang/Ada/Pythagorean-triples | 1 + Lang/Ada/QR-decomposition | 1 + Lang/Ada/Quaternion-type | 1 + Lang/Ada/Queue-Definition | 1 + Lang/Ada/Queue-Usage | 1 + Lang/Ada/Random-number-generator--device- | 1 + Lang/Ada/Random-numbers | 1 + Lang/Ada/Range-expansion | 1 + Lang/Ada/Range-extraction | 1 + Lang/Ada/Rate-counter | 1 + Lang/Ada/Ray-casting-algorithm | 1 + Lang/Ada/Read-a-configuration-file | 1 + Lang/Ada/Read-a-file-line-by-line | 1 + Lang/Ada/Read-a-specific-line-from-a-file | 1 + Lang/Ada/Read-entire-file | 1 + Lang/Ada/Real-constants-and-functions | 1 + Lang/Ada/Reduced-row-echelon-form | 1 + Lang/Ada/Regular-expressions | 1 + Lang/Ada/Remove-duplicate-elements | 1 + Lang/Ada/Remove-lines-from-a-file | 1 + Lang/Ada/Rename-a-file | 1 + Lang/Ada/Rendezvous | 1 + Lang/Ada/Repeat-a-string | 1 + Lang/Ada/Resistor-mesh | 1 + Lang/Ada/Return-multiple-values | 1 + Lang/Ada/Reverse-a-string | 1 + Lang/Ada/Rock-paper-scissors | 1 + Lang/Ada/Roman-numerals-Decode | 1 + Lang/Ada/Roman-numerals-Encode | 1 + Lang/Ada/Roots-of-a-function | 1 + Lang/Ada/Roots-of-a-quadratic-function | 1 + Lang/Ada/Roots-of-unity | 1 + Lang/Ada/Rosetta-Code-Count-examples | 1 + .../Ada/Rosetta-Code-Find-unimplemented-tasks | 1 + .../Rosetta-Code-Rank-languages-by-popularity | 1 + Lang/Ada/Rot-13 | 1 + Lang/Ada/Run-length-encoding | 1 + Lang/Ada/S-Expressions | 1 + Lang/Ada/SEDOLs | 1 + Lang/Ada/Safe-addition | 1 + Lang/Ada/Same-Fringe | 1 + Lang/Ada/Scope-modifiers | 1 + Lang/Ada/Secure-temporary-file | 1 + Lang/Ada/Self-describing-numbers | 1 + Lang/Ada/Self-referential-sequence | 1 + Lang/Ada/Semordnilap | 1 + Lang/Ada/Send-email | 1 + Lang/Ada/Sequence-of-non-squares | 1 + Lang/Ada/Set | 1 + Lang/Ada/Set-consolidation | 1 + Lang/Agda2/Reverse-a-string | 1 + Lang/Aikido/Polymorphic-copy | 1 + Lang/Aikido/Polymorphism | 1 + Lang/Aime/Pick-random-element | 1 + Lang/Aime/Range-extraction | 1 + Lang/Aime/Read-a-file-line-by-line | 1 + Lang/Aime/Read-a-specific-line-from-a-file | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/AmigaE/Null-object | 1 + Lang/AppleScript/Named-parameters | 1 + Lang/AppleScript/Null-object | 1 + Lang/AppleScript/Optional-parameters | 1 + Lang/AppleScript/Program-termination | 1 + Lang/AppleScript/Queue-Usage | 1 + Lang/AppleScript/Regular-expressions | 1 + Lang/AppleScript/Remove-duplicate-elements | 1 + Lang/AppleScript/Repeat-a-string | 1 + Lang/AppleScript/Reverse-a-string | 1 + Lang/AppleScript/Rot-13 | 1 + Lang/Argile/Regular-expressions | 1 + Lang/AutoHotkey/Binary-digits | 1 + Lang/AutoHotkey/Brownian-tree | 1 + Lang/AutoHotkey/Catalan-numbers | 1 + Lang/AutoHotkey/Copy-a-string | 1 + Lang/AutoHotkey/Environment-variables | 1 + Lang/AutoHotkey/Execute-a-Markov-algorithm | 1 + .../Guess-the-number-With-feedback--player- | 1 + .../Guess-the-number-With-feedback-player | 1 - Lang/AutoHotkey/N-queens-problem | 1 + Lang/AutoHotkey/Named-parameters | 1 + Lang/AutoHotkey/Non-continuous-subsequences | 1 + Lang/AutoHotkey/Non-decimal-radices-Convert | 1 + Lang/AutoHotkey/Non-decimal-radices-Output | 1 + Lang/AutoHotkey/Nth-root | 1 + Lang/AutoHotkey/Null-object | 1 + Lang/AutoHotkey/Number-names | 1 + Lang/AutoHotkey/Number-reversal-game | 1 + Lang/AutoHotkey/Numerical-integration | 1 + Lang/AutoHotkey/OLE-Automation | 1 + .../One-dimensional-cellular-automata | 1 + Lang/AutoHotkey/One-of-n-lines-in-a-file | 1 + Lang/AutoHotkey/OpenGL | 1 + Lang/AutoHotkey/Optional-parameters | 1 + Lang/AutoHotkey/Order-two-numerical-lists | 1 + Lang/AutoHotkey/Palindrome-detection | 1 + Lang/AutoHotkey/Pangram-checker | 1 + .../Parsing-RPN-calculator-algorithm | 1 + .../Parsing-RPN-to-infix-conversion | 1 + .../Parsing-Shunting-yard-algorithm | 1 + Lang/AutoHotkey/Pascals-triangle | 1 + Lang/AutoHotkey/Pascals-triangle-Puzzle | 1 + .../Percentage-difference-between-images | 1 + Lang/AutoHotkey/Perfect-numbers | 1 + Lang/AutoHotkey/Permutations | 1 + Lang/AutoHotkey/Permutations-Derangements | 1 + Lang/AutoHotkey/Pick-random-element | 1 + Lang/AutoHotkey/Pinstripe-Display | 1 + Lang/AutoHotkey/Play-recorded-sounds | 1 + Lang/AutoHotkey/Playing-cards | 1 + Lang/AutoHotkey/Pointers-and-references | 1 + Lang/AutoHotkey/Power-set | 1 + Lang/AutoHotkey/Price-fraction | 1 + Lang/AutoHotkey/Primality-by-trial-division | 1 + Lang/AutoHotkey/Prime-decomposition | 1 + Lang/AutoHotkey/Probabilistic-choice | 1 + Lang/AutoHotkey/Program-name | 1 + Lang/AutoHotkey/Program-termination | 1 + Lang/AutoHotkey/Queue-Definition | 1 + Lang/AutoHotkey/Queue-Usage | 1 + Lang/AutoHotkey/Random-numbers | 1 + Lang/AutoHotkey/Range-expansion | 1 + Lang/AutoHotkey/Range-extraction | 1 + Lang/AutoHotkey/Ray-casting-algorithm | 1 + Lang/AutoHotkey/Read-a-configuration-file | 1 + Lang/AutoHotkey/Read-a-file-line-by-line | 1 + .../Read-a-specific-line-from-a-file | 1 + Lang/AutoHotkey/Read-entire-file | 1 + Lang/AutoHotkey/Real-constants-and-functions | 1 + Lang/AutoHotkey/Regular-expressions | 1 + Lang/AutoHotkey/Remove-duplicate-elements | 1 + Lang/AutoHotkey/Remove-lines-from-a-file | 1 + Lang/AutoHotkey/Rename-a-file | 1 + Lang/AutoHotkey/Rendezvous | 1 + Lang/AutoHotkey/Repeat-a-string | 1 + Lang/AutoHotkey/Return-multiple-values | 1 + Lang/AutoHotkey/Reverse-a-string | 1 + Lang/AutoHotkey/Rock-paper-scissors | 1 + Lang/AutoHotkey/Roman-numerals-Decode | 1 + Lang/AutoHotkey/Roman-numerals-Encode | 1 + Lang/AutoHotkey/Roots-of-a-function | 1 + Lang/AutoHotkey/Roots-of-a-quadratic-function | 1 + Lang/AutoHotkey/Roots-of-unity | 1 + Lang/AutoHotkey/Rosetta-Code-Count-examples | 1 + .../Rosetta-Code-Find-unimplemented-tasks | 1 + Lang/AutoHotkey/Rosetta-Code-Fix-code-tags | 1 + .../Rosetta-Code-Rank-languages-by-popularity | 1 + Lang/AutoHotkey/Rot-13 | 1 + Lang/AutoHotkey/Run-length-encoding | 1 + Lang/AutoHotkey/Runtime-evaluation | 1 + .../Runtime-evaluation-In-an-environment | 1 + Lang/AutoHotkey/SEDOLs | 1 + Lang/AutoHotkey/Scope-modifiers | 1 + Lang/AutoHotkey/Self-describing-numbers | 1 + Lang/AutoHotkey/Self-referential-sequence | 1 + Lang/AutoHotkey/Send-an-unknown-method-call | 1 + Lang/AutoHotkey/Send-email | 1 + Lang/AutoHotkey/Sequence-of-non-squares | 1 + Lang/AutoIt/Binary-digits | 1 + Lang/AutoIt/Copy-a-string | 1 + Lang/AutoIt/Nth-root | 1 + Lang/AutoIt/Palindrome-detection | 1 + Lang/AutoIt/Pangram-checker | 1 + Lang/AutoIt/Program-termination | 1 + Lang/AutoIt/Reduced-row-echelon-form | 1 + Lang/AutoIt/Return-multiple-values | 1 + Lang/AutoIt/Reverse-a-string | 1 + Lang/AutoIt/Rock-paper-scissors | 1 + Lang/Axiom/Perfect-numbers | 1 + Lang/Axiom/Priority-queue | 1 + Lang/Axiom/QR-decomposition | 1 + Lang/Axiom/Roots-of-a-function | 1 + Lang/BASIC/Catalan-numbers | 1 + Lang/BASIC/Dragon-curve | 1 + Lang/BASIC/Environment-variables | 1 + Lang/BASIC/Nth-root | 1 + Lang/BASIC/Number-names | 1 + Lang/BASIC/Number-reversal-game | 1 + Lang/BASIC/Numerical-integration | 1 + Lang/BASIC/One-dimensional-cellular-automata | 1 + Lang/BASIC/One-of-n-lines-in-a-file | 1 + Lang/BASIC/Palindrome-detection | 1 + Lang/BASIC/Pangram-checker | 1 + Lang/BASIC/Pascals-triangle | 1 + Lang/BASIC/Perfect-numbers | 1 + Lang/BASIC/Pick-random-element | 1 + Lang/BASIC/Playing-cards | 1 + Lang/BASIC/Pragmatic-directives | 1 + Lang/BASIC/Price-fraction | 1 + Lang/BASIC/Primality-by-trial-division | 1 + Lang/BASIC/Program-name | 1 + Lang/BASIC/Program-termination | 1 + Lang/BASIC/Read-a-file-line-by-line | 1 + Lang/BASIC/Read-entire-file | 1 + Lang/BASIC/Real-constants-and-functions | 1 + Lang/BASIC/Rename-a-file | 1 + Lang/BASIC/Reverse-a-string | 1 + Lang/BASIC/Rock-paper-scissors | 1 + Lang/BASIC/Roman-numerals-Encode | 1 + Lang/BASIC/Roots-of-unity | 1 + Lang/BASIC/Rot-13 | 1 + Lang/BASIC/Run-length-encoding | 1 + Lang/BASIC/Runtime-evaluation | 1 + Lang/BASIC/SEDOLs | 1 + Lang/BASIC/Scope-Function-names-and-labels | 1 + Lang/BASIC/Self-describing-numbers | 1 + Lang/BASIC/Sequence-of-non-squares | 1 + Lang/BASIC256/Dragon-curve | 1 + Lang/BASIC256/Roman-numerals-Encode | 1 + Lang/BBC-BASIC/Binary-digits | 1 + Lang/BBC-BASIC/Brownian-tree | 1 + .../BBC-BASIC/Calendar---for-real-programmers | 1 + Lang/BBC-BASIC/Calendar-for-real-programmers | 1 - Lang/BBC-BASIC/Catalan-numbers | 1 + Lang/BBC-BASIC/Copy-a-string | 1 + Lang/BBC-BASIC/Dragon-curve | 1 + Lang/BBC-BASIC/Environment-variables | 1 + Lang/BBC-BASIC/Execute-a-Markov-algorithm | 1 + .../Guess-the-number-With-feedback--player- | 1 + .../Guess-the-number-With-feedback-player | 1 - Lang/BBC-BASIC/N-queens-problem | 1 + Lang/BBC-BASIC/Non-continuous-subsequences | 1 + Lang/BBC-BASIC/Non-decimal-radices-Convert | 1 + Lang/BBC-BASIC/Non-decimal-radices-Input | 1 + Lang/BBC-BASIC/Non-decimal-radices-Output | 1 + Lang/BBC-BASIC/Nth-root | 1 + Lang/BBC-BASIC/Null-object | 1 + Lang/BBC-BASIC/Number-names | 1 + Lang/BBC-BASIC/Number-reversal-game | 1 + Lang/BBC-BASIC/Numerical-integration | 1 + .../One-dimensional-cellular-automata | 1 + Lang/BBC-BASIC/One-of-n-lines-in-a-file | 1 + Lang/BBC-BASIC/OpenGL | 1 + Lang/BBC-BASIC/Optional-parameters | 1 + Lang/BBC-BASIC/Order-two-numerical-lists | 1 + Lang/BBC-BASIC/Ordered-Partitions | 1 + Lang/BBC-BASIC/Palindrome-detection | 1 + Lang/BBC-BASIC/Pangram-checker | 1 + .../Parsing-RPN-calculator-algorithm | 1 + Lang/BBC-BASIC/Partial-function-application | 1 + Lang/BBC-BASIC/Pascals-triangle | 1 + Lang/BBC-BASIC/Pascals-triangle-Puzzle | 1 + .../Percentage-difference-between-images | 1 + Lang/BBC-BASIC/Perfect-numbers | 1 + Lang/BBC-BASIC/Permutation-test | 1 + Lang/BBC-BASIC/Permutations | 1 + Lang/BBC-BASIC/Permutations-Derangements | 1 + Lang/BBC-BASIC/Permutations-by-swapping | 1 + Lang/BBC-BASIC/Pick-random-element | 1 + Lang/BBC-BASIC/Pinstripe-Display | 1 + Lang/BBC-BASIC/Pinstripe-Printer | 1 + Lang/BBC-BASIC/Play-recorded-sounds | 1 + Lang/BBC-BASIC/Playing-cards | 1 + Lang/BBC-BASIC/Plot-coordinate-pairs | 1 + Lang/BBC-BASIC/Pointers-and-references | 1 + Lang/BBC-BASIC/Polymorphic-copy | 1 + Lang/BBC-BASIC/Polymorphism | 1 + Lang/BBC-BASIC/Polynomial-long-division | 1 + Lang/BBC-BASIC/Polynomial-regression | 1 + Lang/BBC-BASIC/Power-set | 1 + Lang/BBC-BASIC/Price-fraction | 1 + Lang/BBC-BASIC/Primality-by-trial-division | 1 + Lang/BBC-BASIC/Probabilistic-choice | 1 + Lang/BBC-BASIC/Problem-of-Apollonius | 1 + Lang/BBC-BASIC/Program-name | 1 + Lang/BBC-BASIC/Program-termination | 1 + Lang/BBC-BASIC/Pythagorean-triples | 1 + Lang/BBC-BASIC/QR-decomposition | 1 + Lang/BBC-BASIC/Quaternion-type | 1 + Lang/BBC-BASIC/Queue-Definition | 1 + Lang/BBC-BASIC/Queue-Usage | 1 + .../Random-number-generator--device- | 1 + Lang/BBC-BASIC/Random-numbers | 1 + Lang/BBC-BASIC/Range-expansion | 1 + Lang/BBC-BASIC/Range-extraction | 1 + Lang/BBC-BASIC/Rate-counter | 1 + Lang/BBC-BASIC/Read-a-configuration-file | 1 + Lang/BBC-BASIC/Read-a-file-line-by-line | 1 + .../Read-a-specific-line-from-a-file | 1 + Lang/BBC-BASIC/Read-entire-file | 1 + Lang/BBC-BASIC/Real-constants-and-functions | 1 + Lang/BBC-BASIC/Record-sound | 1 + Lang/BBC-BASIC/Reduced-row-echelon-form | 1 + Lang/BBC-BASIC/Regular-expressions | 1 + Lang/BBC-BASIC/Remove-duplicate-elements | 1 + Lang/BBC-BASIC/Rename-a-file | 1 + Lang/BBC-BASIC/Repeat-a-string | 1 + Lang/BBC-BASIC/Resistor-mesh | 1 + Lang/BBC-BASIC/Return-multiple-values | 1 + Lang/BBC-BASIC/Reverse-a-string | 1 + Lang/BBC-BASIC/Rock-paper-scissors | 1 + Lang/BBC-BASIC/Roman-numerals-Decode | 1 + Lang/BBC-BASIC/Roman-numerals-Encode | 1 + Lang/BBC-BASIC/Roots-of-a-function | 1 + Lang/BBC-BASIC/Roots-of-a-quadratic-function | 1 + Lang/BBC-BASIC/Roots-of-unity | 1 + Lang/BBC-BASIC/Rosetta-Code-Count-examples | 1 + .../Rosetta-Code-Rank-languages-by-popularity | 1 + Lang/BBC-BASIC/Rot-13 | 1 + Lang/BBC-BASIC/Run-length-encoding | 1 + Lang/BBC-BASIC/Runtime-evaluation | 1 + .../Runtime-evaluation-In-an-environment | 1 + Lang/BBC-BASIC/SEDOLs | 1 + Lang/BBC-BASIC/Scope-modifiers | 1 + Lang/BBC-BASIC/Secure-temporary-file | 1 + Lang/BBC-BASIC/Self-describing-numbers | 1 + Lang/BBC-BASIC/Self-referential-sequence | 1 + Lang/BBC-BASIC/Semordnilap | 1 + Lang/BBC-BASIC/Send-email | 1 + Lang/BBC-BASIC/Sequence-of-non-squares | 1 + Lang/BBC-BASIC/Set | 1 + Lang/BCPL/N-queens-problem | 1 + Lang/Babel/Null-object | 1 + Lang/Babel/Repeat-a-string | 1 + Lang/Babel/Reverse-a-string | 1 + Lang/Batch-File/Binary-digits | 1 + Lang/Batch-File/Copy-a-string | 1 + Lang/Batch-File/Environment-variables | 1 + Lang/Batch-File/Program-termination | 1 + Lang/Batch-File/Queue-Definition | 1 + Lang/Batch-File/Rename-a-file | 1 + Lang/Batch-File/Repeat-a-string | 1 + Lang/Batch-File/Reverse-a-string | 1 + Lang/Bc/Sequence-of-non-squares | 1 + .../Befunge/One-dimensional-cellular-automata | 1 + Lang/Befunge/Palindrome-detection | 1 + Lang/Befunge/Prime-decomposition | 1 + Lang/Befunge/Reverse-a-string | 1 + Lang/Befunge/Rot-13 | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Bracmat/Catalan-numbers | 1 + Lang/Bracmat/Copy-a-string | 1 + Lang/Bracmat/Non-continuous-subsequences | 1 + Lang/Bracmat/Non-decimal-radices-Convert | 1 + .../Bracmat/One-dimensional-cellular-automata | 1 + Lang/Bracmat/Order-two-numerical-lists | 1 + Lang/Bracmat/Pangram-checker | 1 + Lang/Bracmat/Pascals-triangle | 1 + Lang/Bracmat/Pattern-matching | 1 + Lang/Bracmat/Perfect-numbers | 1 + Lang/Bracmat/Permutations | 1 + Lang/Bracmat/Price-fraction | 1 + Lang/Bracmat/Primality-by-trial-division | 1 + Lang/Bracmat/Pythagorean-triples | 1 + Lang/Bracmat/Range-expansion | 1 + Lang/Bracmat/Range-extraction | 1 + Lang/Bracmat/Regular-expressions | 1 + Lang/Bracmat/Remove-duplicate-elements | 1 + Lang/Bracmat/Rename-a-file | 1 + Lang/Bracmat/Repeat-a-string | 1 + Lang/Bracmat/Return-multiple-values | 1 + Lang/Bracmat/Reverse-a-string | 1 + Lang/Bracmat/Roman-numerals-Decode | 1 + Lang/Bracmat/Roman-numerals-Encode | 1 + Lang/Bracmat/Run-length-encoding | 1 + Lang/Bracmat/Self-referential-sequence | 1 + Lang/Bracmat/Set-consolidation | 1 + Lang/Brainf---/Binary-digits | 1 + Lang/Brainf---/Read-entire-file | 1 + Lang/Brainf---/Repeat-a-string | 1 + Lang/Brainf---/Reverse-a-string | 1 + Lang/Brat/Catalan-numbers | 1 + Lang/Brat/Number-reversal-game | 1 + Lang/Brat/Pangram-checker | 1 + Lang/Brat/Read-a-file-line-by-line | 1 + Lang/Brat/Read-entire-file | 1 + Lang/Brat/Remove-duplicate-elements | 1 + Lang/Brat/Repeat-a-string | 1 + Lang/Brat/Respond-to-an-unknown-method-call | 1 + Lang/Brat/Reverse-a-string | 1 + Lang/Burlesque/Binary-digits | 1 + Lang/Burlesque/Palindrome-detection | 1 + Lang/Burlesque/Pascals-triangle | 1 + Lang/Burlesque/Pick-random-element | 1 + Lang/Burlesque/Power-set | 1 + Lang/Burlesque/Primality-by-trial-division | 1 + Lang/Burlesque/Prime-decomposition | 1 + Lang/Burlesque/Repeat-a-string | 1 + Lang/Burlesque/Reverse-a-string | 1 + Lang/Burlesque/Rot-13 | 1 + Lang/Burlesque/Run-length-encoding | 1 + Lang/Burlesque/Runtime-evaluation | 1 + Lang/Burlesque/Sequence-of-non-squares | 1 + Lang/C++/Binary-digits | 1 + Lang/C++/Catalan-numbers | 1 + ...rithmetic-G-matrix-NG,-Contined-Fraction-N | 1 - ...ithmetic-G-matrix-NG,-Contined-Fraction-N- | 1 + ...Contined-Fraction-N1,-Contined-Fraction-N2 | 1 - ...ontined-Fraction-N1,-Contined-Fraction-N2- | 1 + Lang/C++/Copy-a-string | 1 + Lang/C++/Environment-variables | 1 + Lang/C++/Execute-a-Markov-algorithm | 1 + .../Guess-the-number-With-feedback--player- | 1 + .../C++/Guess-the-number-With-feedback-player | 1 - Lang/C++/Named-parameters | 1 + Lang/C++/Non-decimal-radices-Convert | 1 + Lang/C++/Non-decimal-radices-Input | 1 + Lang/C++/Non-decimal-radices-Output | 1 + Lang/C++/Nth-root | 1 + Lang/C++/Null-object | 1 + Lang/C++/Number-names | 1 + Lang/C++/Number-reversal-game | 1 + Lang/C++/Numerical-integration | 1 + Lang/C++/Object-serialization | 1 + Lang/C++/One-dimensional-cellular-automata | 1 + Lang/C++/One-of-n-lines-in-a-file | 1 + Lang/C++/Optional-parameters | 1 + Lang/C++/Order-two-numerical-lists | 1 + Lang/C++/Palindrome-detection | 1 + Lang/C++/Pangram-checker | 1 + Lang/C++/Parallel-calculations | 1 + Lang/C++/Parametric-polymorphism | 1 + Lang/C++/Parsing-RPN-calculator-algorithm | 1 + Lang/C++/Partial-function-application | 1 + Lang/C++/Pascals-triangle | 1 + Lang/C++/Percentage-difference-between-images | 1 + Lang/C++/Perfect-numbers | 1 + Lang/C++/Permutations | 1 + Lang/C++/Playing-cards | 1 + Lang/C++/Polymorphic-copy | 1 + Lang/C++/Polymorphism | 1 + Lang/C++/Polynomial-long-division | 1 + Lang/C++/Power-set | 1 + Lang/C++/Price-fraction | 1 + Lang/C++/Primality-by-trial-division | 1 + Lang/C++/Prime-decomposition | 1 + Lang/C++/Priority-queue | 1 + Lang/C++/Probabilistic-choice | 1 + Lang/C++/Program-name | 1 + Lang/C++/Program-termination | 1 + Lang/C++/Quaternion-type | 1 + Lang/C++/Queue-Definition | 1 + Lang/C++/Queue-Usage | 1 + Lang/C++/Random-numbers | 1 + Lang/C++/Range-expansion | 1 + Lang/C++/Range-extraction | 1 + Lang/C++/Rate-counter | 1 + Lang/C++/Read-a-configuration-file | 1 + Lang/C++/Read-a-file-line-by-line | 1 + Lang/C++/Read-entire-file | 1 + Lang/C++/Real-constants-and-functions | 1 + Lang/C++/Reduced-row-echelon-form | 1 + Lang/C++/Regular-expressions | 1 + Lang/C++/Remove-duplicate-elements | 1 + Lang/C++/Remove-lines-from-a-file | 1 + Lang/C++/Rename-a-file | 1 + Lang/C++/Repeat-a-string | 1 + Lang/C++/Respond-to-an-unknown-method-call | 1 + Lang/C++/Return-multiple-values | 1 + Lang/C++/Reverse-a-string | 1 + Lang/C++/Rock-paper-scissors | 1 + Lang/C++/Roman-numerals-Decode | 1 + Lang/C++/Roman-numerals-Encode | 1 + Lang/C++/Roots-of-a-function | 1 + Lang/C++/Roots-of-a-quadratic-function | 1 + Lang/C++/Roots-of-unity | 1 + .../Rosetta-Code-Rank-languages-by-popularity | 1 + Lang/C++/Rot-13 | 1 + Lang/C++/Run-length-encoding | 1 + Lang/C++/SEDOLs | 1 + Lang/C++/Semordnilap | 1 + Lang/C++/Send-email | 1 + Lang/C++/Sequence-of-non-squares | 1 + Lang/C++/Set | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - .../C-sharp/One-dimensional-cellular-automata | 1 + Lang/C-sharp/Partial-function-application | 1 + Lang/C-sharp/Polynomial-regression | 1 + Lang/C-sharp/Quaternion-type | 1 + Lang/C-sharp/Queue-Definition | 1 + Lang/C-sharp/Queue-Usage | 1 + Lang/C-sharp/Random-number-generator--device- | 1 + Lang/C-sharp/Random-numbers | 1 + Lang/C-sharp/Range-extraction | 1 + Lang/C-sharp/Read-a-file-line-by-line | 1 + Lang/C-sharp/Read-a-specific-line-from-a-file | 1 + Lang/C-sharp/Read-entire-file | 1 + Lang/C-sharp/Real-constants-and-functions | 1 + Lang/C-sharp/Regular-expressions | 1 + Lang/C-sharp/Remove-duplicate-elements | 1 + Lang/C-sharp/Rename-a-file | 1 + Lang/C-sharp/Repeat-a-string | 1 + Lang/C-sharp/Set-of-real-numbers | 1 + .../C/Arbitrary-precision-integers--included- | 1 + Lang/C/Arbitrary-precision-integers-included | 1 - Lang/C/Binary-digits | 1 + Lang/C/Brownian-tree | 1 + Lang/C/Catalan-numbers | 1 + Lang/C/Copy-a-string | 1 + Lang/C/Dragon-curve | 1 + Lang/C/Environment-variables | 1 + Lang/C/Execute-a-Markov-algorithm | 1 + .../C/Guess-the-number-With-feedback--player- | 1 + Lang/C/Guess-the-number-With-feedback-player | 1 - Lang/C/N-queens-problem | 1 + Lang/C/Named-parameters | 1 + Lang/C/Non-continuous-subsequences | 1 + Lang/C/Non-decimal-radices-Convert | 1 + Lang/C/Non-decimal-radices-Input | 1 + Lang/C/Non-decimal-radices-Output | 1 + Lang/C/Nth-root | 1 + Lang/C/Null-object | 1 + Lang/C/Number-names | 1 + Lang/C/Number-reversal-game | 1 + Lang/C/Numeric-error-propagation | 1 + Lang/C/Numerical-integration | 1 + ...ical-integration-Gauss-Legendre-Quadrature | 1 + Lang/C/One-dimensional-cellular-automata | 1 + Lang/C/One-of-n-lines-in-a-file | 1 + Lang/C/OpenGL | 1 + Lang/C/Optional-parameters | 1 + Lang/C/Order-two-numerical-lists | 1 + Lang/C/Ordered-Partitions | 1 + Lang/C/Palindrome-detection | 1 + Lang/C/Pangram-checker | 1 + Lang/C/Parallel-calculations | 1 + Lang/C/Parametric-polymorphism | 1 + Lang/C/Parsing-RPN-calculator-algorithm | 1 + Lang/C/Parsing-Shunting-yard-algorithm | 1 + Lang/C/Partial-function-application | 1 + Lang/C/Pascals-triangle | 1 + Lang/C/Pascals-triangle-Puzzle | 1 + Lang/C/Percentage-difference-between-images | 1 + Lang/C/Perfect-numbers | 1 + Lang/C/Permutation-test | 1 + Lang/C/Permutations | 1 + Lang/C/Permutations-Derangements | 1 + Lang/C/Pick-random-element | 1 + Lang/C/Playing-cards | 1 + Lang/C/Plot-coordinate-pairs | 1 + Lang/C/Polymorphic-copy | 1 + Lang/C/Polynomial-long-division | 1 + Lang/C/Polynomial-regression | 1 + Lang/C/Power-set | 1 + Lang/C/Price-fraction | 1 + Lang/C/Primality-by-trial-division | 1 + Lang/C/Prime-decomposition | 1 + Lang/C/Priority-queue | 1 + Lang/C/Probabilistic-choice | 1 + Lang/C/Problem-of-Apollonius | 1 + Lang/C/Program-name | 1 + Lang/C/Program-termination | 1 + Lang/C/Pythagorean-triples | 1 + Lang/C/QR-decomposition | 1 + Lang/C/Quaternion-type | 1 + Lang/C/Queue-Definition | 1 + Lang/C/Queue-Usage | 1 + Lang/C/Random-number-generator--device- | 1 + Lang/C/Random-number-generator--included- | 1 + Lang/C/Random-numbers | 1 + Lang/C/Range-expansion | 1 + Lang/C/Range-extraction | 1 + Lang/C/Rate-counter | 1 + Lang/C/Ray-casting-algorithm | 1 + Lang/C/Read-a-file-line-by-line | 1 + Lang/C/Read-a-specific-line-from-a-file | 1 + Lang/C/Read-entire-file | 1 + Lang/C/Real-constants-and-functions | 1 + Lang/C/Record-sound | 1 + Lang/C/Reduced-row-echelon-form | 1 + Lang/C/Regular-expressions | 1 + Lang/C/Remove-duplicate-elements | 1 + Lang/C/Remove-lines-from-a-file | 1 + Lang/C/Rename-a-file | 1 + Lang/C/Rendezvous | 1 + Lang/C/Repeat-a-string | 1 + Lang/C/Resistor-mesh | 1 + Lang/C/Return-multiple-values | 1 + Lang/C/Reverse-a-string | 1 + Lang/C/Rock-paper-scissors | 1 + Lang/C/Roman-numerals-Decode | 1 + Lang/C/Roman-numerals-Encode | 1 + Lang/C/Roots-of-a-function | 1 + Lang/C/Roots-of-a-quadratic-function | 1 + Lang/C/Roots-of-unity | 1 + .../Rosetta-Code-Rank-languages-by-popularity | 1 + Lang/C/Rot-13 | 1 + Lang/C/Run-length-encoding | 1 + Lang/C/S-Expressions | 1 + Lang/C/SEDOLs | 1 + Lang/C/Safe-addition | 1 + Lang/C/Same-Fringe | 1 + Lang/C/Scope-modifiers | 1 + Lang/C/Secure-temporary-file | 1 + Lang/C/Self-describing-numbers | 1 + Lang/C/Self-referential-sequence | 1 + Lang/C/Semordnilap | 1 + Lang/C/Sequence-of-non-squares | 1 + Lang/C/Set | 1 + Lang/C/Set-consolidation | 1 + Lang/CMake/Primality-by-trial-division | 1 + Lang/CMake/Random-number-generator--included- | 1 + Lang/CMake/Read-entire-file | 1 + Lang/CMake/Return-multiple-values | 1 + Lang/COBOL/Binary-digits | 1 + Lang/COBOL/One-dimensional-cellular-automata | 1 + Lang/COBOL/Primality-by-trial-division | 1 + Lang/COBOL/Reverse-a-string | 1 + .../Non-decimal-radices-Convert | 1 + .../Rosetta-Code-Rank-languages-by-popularity | 1 + Lang/Clean/Parametric-polymorphism | 1 + Lang/Clipper/Price-fraction | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Clojure/Binary-digits | 1 + Lang/Clojure/Catalan-numbers | 1 + Lang/Clojure/Copy-a-string | 1 + Lang/Clojure/Environment-variables | 1 + .../Guess-the-number-With-feedback--player- | 1 + .../Guess-the-number-With-feedback-player | 1 - Lang/Clojure/N-queens-problem | 1 + Lang/Clojure/Named-parameters | 1 + Lang/Clojure/Non-continuous-subsequences | 1 + Lang/Clojure/Non-decimal-radices-Output | 1 + Lang/Clojure/Null-object | 1 + Lang/Clojure/Number-names | 1 + Lang/Clojure/Number-reversal-game | 1 + .../Clojure/One-dimensional-cellular-automata | 1 + Lang/Clojure/OpenGL | 1 + Lang/Clojure/Optional-parameters | 1 + Lang/Clojure/Palindrome-detection | 1 + Lang/Clojure/Pangram-checker | 1 + Lang/Clojure/Parallel-calculations | 1 + Lang/Clojure/Parsing-RPN-calculator-algorithm | 1 + Lang/Clojure/Partial-function-application | 1 + Lang/Clojure/Pascals-triangle | 1 + Lang/Clojure/Pascals-triangle-Puzzle | 1 + Lang/Clojure/Perfect-numbers | 1 + Lang/Clojure/Permutations | 1 + Lang/Clojure/Pick-random-element | 1 + Lang/Clojure/Playing-cards | 1 + Lang/Clojure/Polymorphism | 1 + Lang/Clojure/Power-set | 1 + Lang/Clojure/Primality-by-trial-division | 1 + Lang/Clojure/Prime-decomposition | 1 + Lang/Clojure/Probabilistic-choice | 1 + Lang/Clojure/Program-name | 1 + Lang/Clojure/Program-termination | 1 + Lang/Clojure/Queue-Definition | 1 + Lang/Clojure/Queue-Usage | 1 + Lang/Clojure/Random-numbers | 1 + Lang/Clojure/Range-expansion | 1 + Lang/Clojure/Read-a-file-line-by-line | 1 + Lang/Clojure/Read-entire-file | 1 + Lang/Clojure/Real-constants-and-functions | 1 + Lang/Clojure/Regular-expressions | 1 + Lang/Clojure/Remove-duplicate-elements | 1 + Lang/Clojure/Rename-a-file | 1 + Lang/Clojure/Repeat-a-string | 1 + Lang/Clojure/Return-multiple-values | 1 + Lang/Clojure/Reverse-a-string | 1 + Lang/Clojure/Roman-numerals-Decode | 1 + Lang/Clojure/Roman-numerals-Encode | 1 + Lang/Clojure/Roots-of-a-function | 1 + Lang/Clojure/Rosetta-Code-Count-examples | 1 + Lang/Clojure/Rot-13 | 1 + Lang/Clojure/Run-length-encoding | 1 + Lang/Clojure/Secure-temporary-file | 1 + Lang/Clojure/Sequence-of-non-squares | 1 + Lang/Clojure/Set | 1 + Lang/CoffeeScript/Binary-digits | 1 + Lang/CoffeeScript/Environment-variables | 1 + Lang/CoffeeScript/N-queens-problem | 1 + Lang/CoffeeScript/Non-continuous-subsequences | 1 + Lang/CoffeeScript/Nth-root | 1 + Lang/CoffeeScript/Number-names | 1 + Lang/CoffeeScript/Numerical-integration | 1 + .../One-dimensional-cellular-automata | 1 + Lang/CoffeeScript/Palindrome-detection | 1 + Lang/CoffeeScript/Pangram-checker | 1 + .../CoffeeScript/Partial-function-application | 1 + Lang/CoffeeScript/Pascals-triangle | 1 + Lang/CoffeeScript/Perfect-numbers | 1 + Lang/CoffeeScript/Permutations | 1 + Lang/CoffeeScript/Pick-random-element | 1 + Lang/CoffeeScript/Power-set | 1 + Lang/CoffeeScript/Primality-by-trial-division | 1 + Lang/CoffeeScript/Priority-queue | 1 + Lang/CoffeeScript/Problem-of-Apollonius | 1 + Lang/CoffeeScript/Pythagorean-triples | 1 + Lang/CoffeeScript/Queue-Definition | 1 + Lang/CoffeeScript/Queue-Usage | 1 + Lang/CoffeeScript/Ray-casting-algorithm | 1 + Lang/CoffeeScript/Read-a-file-line-by-line | 1 + Lang/CoffeeScript/Reverse-a-string | 1 + Lang/CoffeeScript/Roman-numerals-Decode | 1 + Lang/CoffeeScript/Roman-numerals-Encode | 1 + Lang/CoffeeScript/Roots-of-a-function | 1 + Lang/CoffeeScript/Roots-of-unity | 1 + Lang/CoffeeScript/Run-length-encoding | 1 + Lang/CoffeeScript/S-Expressions | 1 + Lang/CoffeeScript/Self-referential-sequence | 1 + Lang/CoffeeScript/Sequence-of-non-squares | 1 + Lang/CoffeeScript/Set | 1 + Lang/ColdFusion/Copy-a-string | 1 + Lang/ColdFusion/Power-set | 1 + Lang/ColdFusion/Reverse-a-string | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Common-Lisp/Binary-digits | 1 + Lang/Common-Lisp/Catalan-numbers | 1 + Lang/Common-Lisp/Copy-a-string | 1 + Lang/Common-Lisp/Dragon-curve | 1 + Lang/Common-Lisp/Environment-variables | 1 + Lang/Common-Lisp/N-queens-problem | 1 + Lang/Common-Lisp/Named-parameters | 1 + Lang/Common-Lisp/Non-continuous-subsequences | 1 + Lang/Common-Lisp/Non-decimal-radices-Convert | 1 + Lang/Common-Lisp/Non-decimal-radices-Input | 1 + Lang/Common-Lisp/Non-decimal-radices-Output | 1 + Lang/Common-Lisp/Nth-root | 1 + Lang/Common-Lisp/Null-object | 1 + Lang/Common-Lisp/Number-names | 1 + Lang/Common-Lisp/Number-reversal-game | 1 + Lang/Common-Lisp/Numerical-integration | 1 + ...ical-integration-Gauss-Legendre-Quadrature | 1 + Lang/Common-Lisp/Object-serialization | 1 + .../One-dimensional-cellular-automata | 1 + Lang/Common-Lisp/Optional-parameters | 1 + Lang/Common-Lisp/Order-two-numerical-lists | 1 + Lang/Common-Lisp/Ordered-Partitions | 1 + Lang/Common-Lisp/Palindrome-detection | 1 + Lang/Common-Lisp/Pangram-checker | 1 + Lang/Common-Lisp/Parametric-polymorphism | 1 + Lang/Common-Lisp/Partial-function-application | 1 + Lang/Common-Lisp/Pascals-triangle | 1 + Lang/Common-Lisp/Pattern-matching | 1 + .../Percentage-difference-between-images | 1 + Lang/Common-Lisp/Perfect-numbers | 1 + Lang/Common-Lisp/Permutation-test | 1 + Lang/Common-Lisp/Permutations | 1 + Lang/Common-Lisp/Pig-the-dice-game | 1 + Lang/Common-Lisp/Playing-cards | 1 + Lang/Common-Lisp/Polymorphic-copy | 1 + Lang/Common-Lisp/Polymorphism | 1 + Lang/Common-Lisp/Polynomial-long-division | 1 + Lang/Common-Lisp/Polynomial-regression | 1 + Lang/Common-Lisp/Power-set | 1 + Lang/Common-Lisp/Primality-by-trial-division | 1 + Lang/Common-Lisp/Prime-decomposition | 1 + Lang/Common-Lisp/Probabilistic-choice | 1 + Lang/Common-Lisp/Program-name | 1 + Lang/Common-Lisp/Program-termination | 1 + Lang/Common-Lisp/Pythagorean-triples | 1 + Lang/Common-Lisp/QR-decomposition | 1 + Lang/Common-Lisp/Queue-Definition | 1 + Lang/Common-Lisp/Queue-Usage | 1 + Lang/Common-Lisp/Random-numbers | 1 + Lang/Common-Lisp/Range-expansion | 1 + Lang/Common-Lisp/Range-extraction | 1 + Lang/Common-Lisp/Rate-counter | 1 + Lang/Common-Lisp/Ray-casting-algorithm | 1 + Lang/Common-Lisp/Read-a-file-line-by-line | 1 + .../Read-a-specific-line-from-a-file | 1 + Lang/Common-Lisp/Read-entire-file | 1 + Lang/Common-Lisp/Real-constants-and-functions | 1 + Lang/Common-Lisp/Reduced-row-echelon-form | 1 + Lang/Common-Lisp/Regular-expressions | 1 + Lang/Common-Lisp/Remove-duplicate-elements | 1 + Lang/Common-Lisp/Remove-lines-from-a-file | 1 + Lang/Common-Lisp/Rename-a-file | 1 + Lang/Common-Lisp/Repeat-a-string | 1 + .../Respond-to-an-unknown-method-call | 1 + Lang/Common-Lisp/Return-multiple-values | 1 + Lang/Common-Lisp/Reverse-a-string | 1 + Lang/Common-Lisp/Roman-numerals-Decode | 1 + Lang/Common-Lisp/Roman-numerals-Encode | 1 + Lang/Common-Lisp/Roots-of-a-function | 1 + .../Common-Lisp/Roots-of-a-quadratic-function | 1 + Lang/Common-Lisp/Roots-of-unity | 1 + Lang/Common-Lisp/Rot-13 | 1 + Lang/Common-Lisp/Run-length-encoding | 1 + Lang/Common-Lisp/Runtime-evaluation | 1 + .../Runtime-evaluation-In-an-environment | 1 + Lang/Common-Lisp/S-Expressions | 1 + Lang/Common-Lisp/SEDOLs | 1 + Lang/Common-Lisp/Scope-modifiers | 1 + Lang/Common-Lisp/Self-referential-sequence | 1 + Lang/Common-Lisp/Sequence-of-non-squares | 1 + Lang/Common-Lisp/Set | 1 + Lang/Component-Pascal/Null-object | 1 + Lang/Curry/N-queens-problem | 1 + .../D/Arbitrary-precision-integers--included- | 1 + Lang/D/Arbitrary-precision-integers-included | 1 - Lang/D/Binary-digits | 1 + Lang/D/Brownian-tree | 1 + Lang/D/Catalan-numbers | 1 + Lang/D/Copy-a-string | 1 + Lang/D/Dragon-curve | 1 + Lang/D/Environment-variables | 1 + Lang/D/Execute-a-Markov-algorithm | 1 + .../D/Guess-the-number-With-feedback--player- | 1 + Lang/D/Guess-the-number-With-feedback-player | 1 - Lang/D/N-queens-problem | 1 + Lang/D/Nautical-bell | 1 + Lang/D/Non-continuous-subsequences | 1 + Lang/D/Non-decimal-radices-Convert | 1 + Lang/D/Non-decimal-radices-Input | 1 + Lang/D/Non-decimal-radices-Output | 1 + Lang/D/Nth-root | 1 + Lang/D/Null-object | 1 + Lang/D/Number-names | 1 + Lang/D/Number-reversal-game | 1 + Lang/D/Numeric-error-propagation | 1 + Lang/D/Numerical-integration | 1 + ...ical-integration-Gauss-Legendre-Quadrature | 1 + Lang/D/Object-serialization | 1 + Lang/D/One-dimensional-cellular-automata | 1 + Lang/D/One-of-n-lines-in-a-file | 1 + Lang/D/OpenGL | 1 + Lang/D/Optional-parameters | 1 + Lang/D/Order-two-numerical-lists | 1 + Lang/D/Ordered-Partitions | 1 + Lang/D/Palindrome-detection | 1 + Lang/D/Pangram-checker | 1 + Lang/D/Parallel-calculations | 1 + Lang/D/Parametric-polymorphism | 1 + Lang/D/Parsing-RPN-calculator-algorithm | 1 + Lang/D/Parsing-RPN-to-infix-conversion | 1 + Lang/D/Partial-function-application | 1 + Lang/D/Pascals-triangle | 1 + Lang/D/Pascals-triangle-Puzzle | 1 + Lang/D/Percentage-difference-between-images | 1 + Lang/D/Perfect-numbers | 1 + Lang/D/Permutation-test | 1 + Lang/D/Permutations | 1 + Lang/D/Permutations-Derangements | 1 + Lang/D/Permutations-by-swapping | 1 + Lang/D/Pick-random-element | 1 + Lang/D/Pig-the-dice-game | 1 + Lang/D/Playing-cards | 1 + Lang/D/Pointers-and-references | 1 + Lang/D/Polymorphic-copy | 1 + Lang/D/Polymorphism | 1 + Lang/D/Polynomial-long-division | 1 + Lang/D/Power-set | 1 + Lang/D/Price-fraction | 1 + Lang/D/Primality-by-trial-division | 1 + Lang/D/Prime-decomposition | 1 + Lang/D/Priority-queue | 1 + Lang/D/Probabilistic-choice | 1 + Lang/D/Problem-of-Apollonius | 1 + Lang/D/Program-name | 1 + Lang/D/Pythagorean-triples | 1 + Lang/D/QR-decomposition | 1 + Lang/D/Quaternion-type | 1 + Lang/D/Queue-Usage | 1 + Lang/D/RIPEMD-160 | 1 + Lang/D/Random-numbers | 1 + Lang/D/Range-expansion | 1 + Lang/D/Range-extraction | 1 + Lang/D/Ray-casting-algorithm | 1 + Lang/D/Read-a-configuration-file | 1 + Lang/D/Read-a-file-line-by-line | 1 + Lang/D/Read-a-specific-line-from-a-file | 1 + Lang/D/Read-entire-file | 1 + Lang/D/Real-constants-and-functions | 1 + Lang/D/Reduced-row-echelon-form | 1 + Lang/D/Regular-expressions | 1 + Lang/D/Remove-duplicate-elements | 1 + Lang/D/Remove-lines-from-a-file | 1 + Lang/D/Rename-a-file | 1 + Lang/D/Repeat-a-string | 1 + Lang/D/Resistor-mesh | 1 + Lang/D/Respond-to-an-unknown-method-call | 1 + Lang/D/Return-multiple-values | 1 + Lang/D/Reverse-a-string | 1 + Lang/D/Rock-paper-scissors | 1 + Lang/D/Roman-numerals-Decode | 1 + Lang/D/Roman-numerals-Encode | 1 + Lang/D/Roots-of-a-function | 1 + Lang/D/Roots-of-a-quadratic-function | 1 + Lang/D/Roots-of-unity | 1 + Lang/D/Rosetta-Code-Count-examples | 1 + .../Rosetta-Code-Rank-languages-by-popularity | 1 + Lang/D/Rot-13 | 1 + Lang/D/Run-length-encoding | 1 + Lang/D/S-Expressions | 1 + Lang/D/SEDOLs | 1 + Lang/D/Same-Fringe | 1 + Lang/D/Secure-temporary-file | 1 + Lang/D/Self-describing-numbers | 1 + Lang/D/Self-referential-sequence | 1 + Lang/D/Semordnilap | 1 + Lang/D/Send-email | 1 + Lang/D/Sequence-of-non-squares | 1 + Lang/D/Set | 1 + Lang/D/Set-consolidation | 1 + Lang/D/Set-of-real-numbers | 1 + Lang/DCL/Rename-a-file | 1 + .../One-dimensional-cellular-automata | 1 + Lang/DWScript/Pascals-triangle | 1 + Lang/DWScript/Random-numbers | 1 + Lang/DWScript/Range-extraction | 1 + Lang/DWScript/Repeat-a-string | 1 + Lang/DWScript/Roman-numerals-Encode | 1 + Lang/DWScript/Roots-of-a-function | 1 + Lang/Dart/Binary-digits | 1 + Lang/Dart/N-queens-problem | 1 + Lang/Dart/Program-name | 1 + Lang/Dart/Reverse-a-string | 1 + Lang/Deja-Vu/Pick-random-element | 1 + .../Random-number-generator--included- | 1 + Lang/Delphi/Binary-digits | 1 + Lang/Delphi/Brownian-tree | 1 + Lang/Delphi/Copy-a-string | 1 + Lang/Delphi/Environment-variables | 1 + Lang/Delphi/Nth-root | 1 + Lang/Delphi/Null-object | 1 + Lang/Delphi/Palindrome-detection | 1 + Lang/Delphi/Pangram-checker | 1 + Lang/Delphi/Permutations | 1 + Lang/Delphi/Play-recorded-sounds | 1 + Lang/Delphi/Playing-cards | 1 + Lang/Delphi/Polymorphism | 1 + Lang/Delphi/Primality-by-trial-division | 1 + Lang/Delphi/Program-name | 1 + Lang/Delphi/Program-termination | 1 + Lang/Delphi/Quaternion-type | 1 + Lang/Delphi/Queue-Usage | 1 + Lang/Delphi/Random-numbers | 1 + Lang/Delphi/Read-a-file-line-by-line | 1 + Lang/Delphi/Read-entire-file | 1 + Lang/Delphi/Real-constants-and-functions | 1 + Lang/Delphi/Remove-duplicate-elements | 1 + Lang/Delphi/Rename-a-file | 1 + Lang/Delphi/Repeat-a-string | 1 + Lang/Delphi/Return-multiple-values | 1 + Lang/Delphi/Reverse-a-string | 1 + Lang/Delphi/Roman-numerals-Decode | 1 + Lang/Delphi/Roman-numerals-Encode | 1 + Lang/Delphi/Scope-modifiers | 1 + Lang/Delphi/Send-email | 1 + .../E/Arbitrary-precision-integers--included- | 1 + Lang/E/Arbitrary-precision-integers-included | 1 - Lang/E/Environment-variables | 1 + Lang/E/Named-parameters | 1 + Lang/E/Non-decimal-radices-Convert | 1 + Lang/E/Non-decimal-radices-Input | 1 + Lang/E/Non-decimal-radices-Output | 1 + Lang/E/Nth-root | 1 + Lang/E/Null-object | 1 + Lang/E/Numerical-integration | 1 + Lang/E/Object-serialization | 1 + Lang/E/One-dimensional-cellular-automata | 1 + Lang/E/Optional-parameters | 1 + Lang/E/Palindrome-detection | 1 + Lang/E/Pangram-checker | 1 + Lang/E/Parametric-polymorphism | 1 + Lang/E/Partial-function-application | 1 + Lang/E/Pascals-triangle | 1 + Lang/E/Percentage-difference-between-images | 1 + Lang/E/Perfect-numbers | 1 + Lang/E/Polymorphic-copy | 1 + Lang/E/Polymorphism | 1 + Lang/E/Polynomial-long-division | 1 + Lang/E/Power-set | 1 + Lang/E/Primality-by-trial-division | 1 + Lang/E/Prime-decomposition | 1 + Lang/E/Probabilistic-choice | 1 + Lang/E/Program-termination | 1 + Lang/E/Quaternion-type | 1 + Lang/E/Queue-Definition | 1 + Lang/E/Queue-Usage | 1 + Lang/E/Random-numbers | 1 + Lang/E/Range-extraction | 1 + Lang/E/Rate-counter | 1 + Lang/E/Read-entire-file | 1 + Lang/E/Real-constants-and-functions | 1 + Lang/E/Remove-duplicate-elements | 1 + Lang/E/Rename-a-file | 1 + Lang/E/Repeat-a-string | 1 + Lang/E/Respond-to-an-unknown-method-call | 1 + Lang/E/Reverse-a-string | 1 + Lang/E/Rot-13 | 1 + Lang/E/Run-length-encoding | 1 + Lang/E/Runtime-evaluation | 1 + Lang/E/Runtime-evaluation-In-an-environment | 1 + Lang/E/SEDOLs | 1 + Lang/E/Safe-addition | 1 + Lang/E/Send-an-unknown-method-call | 1 + Lang/EGL/Reverse-a-string | 1 + Lang/EGL/Rosetta-Code-Count-examples | 1 + Lang/Eiffel/Environment-variables | 1 + Lang/Eiffel/Polymorphism | 1 + Lang/Eiffel/Random-numbers | 1 + Lang/Eiffel/Reverse-a-string | 1 + Lang/Ela/Order-two-numerical-lists | 1 + Lang/Ela/Palindrome-detection | 1 + Lang/Ela/Parsing-RPN-calculator-algorithm | 1 + Lang/Ela/Polymorphism | 1 + Lang/Ela/Scope-modifiers | 1 + Lang/Ela/Set-consolidation | 1 + Lang/Elena/Binary-digits | 1 + Lang/Elisa/Queue-Definition | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Emacs-Lisp/Dragon-curve | 1 + Lang/Emacs-Lisp/Environment-variables | 1 + Lang/Emacs-Lisp/Program-name | 1 + Lang/Emacs-Lisp/Reverse-a-string | 1 + Lang/Emacs-Lisp/Roman-numerals-Decode | 1 + Lang/Emacs-Lisp/Roman-numerals-Encode | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Erlang/Binary-digits | 1 + Lang/Erlang/Catalan-numbers | 1 + Lang/Erlang/Copy-a-string | 1 + Lang/Erlang/Nth-root | 1 + Lang/Erlang/One-dimensional-cellular-automata | 1 + Lang/Erlang/Palindrome-detection | 1 + Lang/Erlang/Pangram-checker | 1 + Lang/Erlang/Pascals-triangle | 1 + Lang/Erlang/Perfect-numbers | 1 + Lang/Erlang/Permutations | 1 + Lang/Erlang/Power-set | 1 + Lang/Erlang/Price-fraction | 1 + Lang/Erlang/Primality-by-trial-division | 1 + Lang/Erlang/Prime-decomposition | 1 + Lang/Erlang/Program-name | 1 + Lang/Erlang/Pythagorean-triples | 1 + Lang/Erlang/Queue-Definition | 1 + Lang/Erlang/Queue-Usage | 1 + .../Erlang/Random-number-generator--included- | 1 + Lang/Erlang/Random-numbers | 1 + Lang/Erlang/Read-entire-file | 1 + Lang/Erlang/Regular-expressions | 1 + Lang/Erlang/Remove-duplicate-elements | 1 + Lang/Erlang/Rename-a-file | 1 + Lang/Erlang/Repeat-a-string | 1 + Lang/Erlang/Reverse-a-string | 1 + Lang/Erlang/Rock-paper-scissors | 1 + Lang/Erlang/Roman-numerals-Encode | 1 + Lang/Erlang/Rosetta-Code-Count-examples | 1 + Lang/Erlang/Rot-13 | 1 + Lang/Erlang/Run-length-encoding | 1 + Lang/Erlang/Runtime-evaluation | 1 + Lang/Erlang/Self-describing-numbers | 1 + Lang/Euler-Math-Toolbox/Random-numbers | 1 + Lang/Euler-Math-Toolbox/Resistor-mesh | 1 + Lang/Euler-Math-Toolbox/Reverse-a-string | 1 + Lang/Euphoria/Binary-digits | 1 + Lang/Euphoria/Catalan-numbers | 1 + Lang/Euphoria/Copy-a-string | 1 + Lang/Euphoria/Environment-variables | 1 + .../Guess-the-number-With-feedback--player- | 1 + .../Guess-the-number-With-feedback-player | 1 - Lang/Euphoria/Non-decimal-radices-Convert | 1 + Lang/Euphoria/Non-decimal-radices-Output | 1 + Lang/Euphoria/Number-names | 1 + Lang/Euphoria/Number-reversal-game | 1 + Lang/Euphoria/Numerical-integration | 1 + .../One-dimensional-cellular-automata | 1 + Lang/Euphoria/One-of-n-lines-in-a-file | 1 + Lang/Euphoria/Palindrome-detection | 1 + Lang/Euphoria/Pascals-triangle | 1 + Lang/Euphoria/Permutations | 1 + Lang/Euphoria/Pick-random-element | 1 + Lang/Euphoria/Price-fraction | 1 + Lang/Euphoria/Primality-by-trial-division | 1 + Lang/Euphoria/Probabilistic-choice | 1 + Lang/Euphoria/Program-name | 1 + Lang/Euphoria/Pythagorean-triples | 1 + Lang/Euphoria/Quaternion-type | 1 + Lang/Euphoria/Random-numbers | 1 + Lang/Euphoria/Range-extraction | 1 + Lang/Euphoria/Read-a-file-line-by-line | 1 + Lang/Euphoria/Read-entire-file | 1 + Lang/Euphoria/Reduced-row-echelon-form | 1 + Lang/Euphoria/Remove-duplicate-elements | 1 + Lang/Euphoria/Repeat-a-string | 1 + Lang/Euphoria/Return-multiple-values | 1 + Lang/Euphoria/Reverse-a-string | 1 + Lang/Euphoria/Rock-paper-scissors | 1 + Lang/Euphoria/Roman-numerals-Decode | 1 + Lang/Euphoria/Roman-numerals-Encode | 1 + Lang/Euphoria/Rot-13 | 1 + Lang/Euphoria/Run-length-encoding | 1 + Lang/Euphoria/Sequence-of-non-squares | 1 + Lang/FALSE/Perfect-numbers | 1 + Lang/FALSE/Primality-by-trial-division | 1 + Lang/FALSE/Prime-decomposition | 1 + Lang/FALSE/Return-multiple-values | 1 + Lang/FALSE/Roman-numerals-Encode | 1 + Lang/FALSE/Rot-13 | 1 + Lang/FALSE/Run-length-encoding | 1 + Lang/FBSL/Reverse-a-string | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Factor/Binary-digits | 1 + Lang/Factor/Catalan-numbers | 1 + Lang/Factor/Copy-a-string | 1 + Lang/Factor/Dragon-curve | 1 + Lang/Factor/Environment-variables | 1 + Lang/Factor/N-queens-problem | 1 + Lang/Factor/Non-decimal-radices-Convert | 1 + Lang/Factor/Non-decimal-radices-Input | 1 + Lang/Factor/Non-decimal-radices-Output | 1 + Lang/Factor/Null-object | 1 + Lang/Factor/Number-reversal-game | 1 + Lang/Factor/One-dimensional-cellular-automata | 1 + Lang/Factor/One-of-n-lines-in-a-file | 1 + Lang/Factor/OpenGL | 1 + Lang/Factor/Palindrome-detection | 1 + Lang/Factor/Pangram-checker | 1 + Lang/Factor/Pascals-triangle | 1 + Lang/Factor/Perfect-numbers | 1 + Lang/Factor/Pick-random-element | 1 + Lang/Factor/Polymorphic-copy | 1 + Lang/Factor/Polymorphism | 1 + Lang/Factor/Power-set | 1 + Lang/Factor/Primality-by-trial-division | 1 + Lang/Factor/Prime-decomposition | 1 + Lang/Factor/Priority-queue | 1 + Lang/Factor/Probabilistic-choice | 1 + Lang/Factor/Program-name | 1 + Lang/Factor/Pythagorean-triples | 1 + Lang/Factor/Random-numbers | 1 + Lang/Factor/Ray-casting-algorithm | 1 + Lang/Factor/Read-a-file-line-by-line | 1 + Lang/Factor/Read-entire-file | 1 + Lang/Factor/Real-constants-and-functions | 1 + Lang/Factor/Remove-duplicate-elements | 1 + Lang/Factor/Rename-a-file | 1 + Lang/Factor/Repeat-a-string | 1 + Lang/Factor/Return-multiple-values | 1 + Lang/Factor/Reverse-a-string | 1 + Lang/Factor/Roman-numerals-Encode | 1 + Lang/Factor/Roots-of-a-quadratic-function | 1 + Lang/Factor/Rot-13 | 1 + Lang/Factor/Send-email | 1 + Lang/Factor/Set | 1 + Lang/Fan/Roman-numerals-Encode | 1 + Lang/Fan/Run-length-encoding | 1 + Lang/Fancy/Respond-to-an-unknown-method-call | 1 + Lang/Fancy/Reverse-a-string | 1 + Lang/Fantom/Brownian-tree | 1 + Lang/Fantom/Catalan-numbers | 1 + .../Guess-the-number-With-feedback--player- | 1 + .../Guess-the-number-With-feedback-player | 1 - Lang/Fantom/Null-object | 1 + Lang/Fantom/One-dimensional-cellular-automata | 1 + Lang/Fantom/Palindrome-detection | 1 + Lang/Fantom/Pascals-triangle | 1 + Lang/Fantom/Playing-cards | 1 + Lang/Fantom/Price-fraction | 1 + Lang/Fantom/Queue-Definition | 1 + Lang/Fantom/Queue-Usage | 1 + Lang/Fantom/Random-numbers | 1 + Lang/Fantom/Read-a-configuration-file | 1 + Lang/Fantom/Read-a-file-line-by-line | 1 + Lang/Fantom/Read-entire-file | 1 + Lang/Fantom/Real-constants-and-functions | 1 + Lang/Fantom/Rename-a-file | 1 + Lang/Fantom/Respond-to-an-unknown-method-call | 1 + Lang/Fantom/Rot-13 | 1 + Lang/Fantom/Send-email | 1 + Lang/Fantom/Sequence-of-non-squares | 1 + Lang/Forth/Binary-digits | 1 + Lang/Forth/Catalan-numbers | 1 + Lang/Forth/Copy-a-string | 1 + Lang/Forth/Dragon-curve | 1 + Lang/Forth/Environment-variables | 1 + Lang/Forth/N-queens-problem | 1 + Lang/Forth/Non-decimal-radices-Convert | 1 + Lang/Forth/Non-decimal-radices-Input | 1 + Lang/Forth/Non-decimal-radices-Output | 1 + Lang/Forth/Nth-root | 1 + Lang/Forth/Number-reversal-game | 1 + Lang/Forth/Numerical-integration | 1 + Lang/Forth/One-dimensional-cellular-automata | 1 + Lang/Forth/OpenGL | 1 + Lang/Forth/Palindrome-detection | 1 + Lang/Forth/Pangram-checker | 1 + Lang/Forth/Pascals-triangle | 1 + .../Percentage-difference-between-images | 1 + Lang/Forth/Perfect-numbers | 1 + Lang/Forth/Pig-the-dice-game | 1 + Lang/Forth/Playing-cards | 1 + Lang/Forth/Polymorphic-copy | 1 + Lang/Forth/Polymorphism | 1 + Lang/Forth/Power-set | 1 + Lang/Forth/Price-fraction | 1 + Lang/Forth/Primality-by-trial-division | 1 + Lang/Forth/Prime-decomposition | 1 + Lang/Forth/Probabilistic-choice | 1 + Lang/Forth/Program-name | 1 + Lang/Forth/Program-termination | 1 + Lang/Forth/Pythagorean-triples | 1 + Lang/Forth/Quaternion-type | 1 + Lang/Forth/Queue-Definition | 1 + Lang/Forth/Random-number-generator--device- | 1 + Lang/Forth/Random-numbers | 1 + Lang/Forth/Range-extraction | 1 + Lang/Forth/Read-a-file-line-by-line | 1 + Lang/Forth/Read-entire-file | 1 + Lang/Forth/Real-constants-and-functions | 1 + Lang/Forth/Regular-expressions | 1 + Lang/Forth/Remove-duplicate-elements | 1 + Lang/Forth/Rename-a-file | 1 + Lang/Forth/Repeat-a-string | 1 + Lang/Forth/Return-multiple-values | 1 + Lang/Forth/Reverse-a-string | 1 + Lang/Forth/Roman-numerals-Decode | 1 + Lang/Forth/Roman-numerals-Encode | 1 + Lang/Forth/Roots-of-a-quadratic-function | 1 + Lang/Forth/Roots-of-unity | 1 + Lang/Forth/Rot-13 | 1 + Lang/Forth/Run-length-encoding | 1 + Lang/Forth/Runtime-evaluation | 1 + .../Runtime-evaluation-In-an-environment | 1 + Lang/Forth/SEDOLs | 1 + Lang/Forth/Self-describing-numbers | 1 + Lang/Forth/Sequence-of-non-squares | 1 + Lang/Fortran/Brownian-tree | 1 + Lang/Fortran/Catalan-numbers | 1 + Lang/Fortran/Copy-a-string | 1 + Lang/Fortran/Environment-variables | 1 + .../Guess-the-number-With-feedback--player- | 1 + .../Guess-the-number-With-feedback-player | 1 - Lang/Fortran/N-queens-problem | 1 + Lang/Fortran/Named-parameters | 1 + Lang/Fortran/Non-decimal-radices-Convert | 1 + Lang/Fortran/Non-decimal-radices-Input | 1 + Lang/Fortran/Non-decimal-radices-Output | 1 + Lang/Fortran/Nth-root | 1 + Lang/Fortran/Number-names | 1 + Lang/Fortran/Number-reversal-game | 1 + Lang/Fortran/Numerical-integration | 1 + .../Fortran/One-dimensional-cellular-automata | 1 + Lang/Fortran/Optional-parameters | 1 + Lang/Fortran/Palindrome-detection | 1 + Lang/Fortran/Pangram-checker | 1 + Lang/Fortran/Pascals-triangle | 1 + .../Percentage-difference-between-images | 1 + Lang/Fortran/Perfect-numbers | 1 + Lang/Fortran/Permutations | 1 + Lang/Fortran/Playing-cards | 1 + Lang/Fortran/Pointers-and-references | 1 + Lang/Fortran/Polymorphism | 1 + Lang/Fortran/Polynomial-long-division | 1 + Lang/Fortran/Polynomial-regression | 1 + Lang/Fortran/Price-fraction | 1 + Lang/Fortran/Primality-by-trial-division | 1 + Lang/Fortran/Prime-decomposition | 1 + Lang/Fortran/Probabilistic-choice | 1 + Lang/Fortran/Problem-of-Apollonius | 1 + Lang/Fortran/Program-termination | 1 + Lang/Fortran/Pythagorean-triples | 1 + Lang/Fortran/Quaternion-type | 1 + Lang/Fortran/Queue-Definition | 1 + Lang/Fortran/Queue-Usage | 1 + Lang/Fortran/Random-numbers | 1 + Lang/Fortran/Ray-casting-algorithm | 1 + Lang/Fortran/Real-constants-and-functions | 1 + Lang/Fortran/Reduced-row-echelon-form | 1 + Lang/Fortran/Remove-duplicate-elements | 1 + Lang/Fortran/Rename-a-file | 1 + Lang/Fortran/Repeat-a-string | 1 + Lang/Fortran/Reverse-a-string | 1 + Lang/Fortran/Roman-numerals-Decode | 1 + Lang/Fortran/Roman-numerals-Encode | 1 + Lang/Fortran/Roots-of-a-function | 1 + Lang/Fortran/Roots-of-a-quadratic-function | 1 + Lang/Fortran/Roots-of-unity | 1 + Lang/Fortran/Rot-13 | 1 + Lang/Fortran/Run-length-encoding | 1 + Lang/Fortran/SEDOLs | 1 + Lang/Fortran/Sequence-of-non-squares | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Frink/Catalan-numbers | 1 + Lang/Frink/Power-set | 1 + Lang/Frink/Prime-decomposition | 1 + Lang/Frink/Read-a-file-line-by-line | 1 + Lang/Frink/Read-entire-file | 1 + Lang/Frink/Regular-expressions | 1 + Lang/Frink/Repeat-a-string | 1 + Lang/Frink/Reverse-a-string | 1 + .../Arbitrary-precision-integers--included- | 1 + .../GAP/Arbitrary-precision-integers-included | 1 - Lang/GAP/Catalan-numbers | 1 + Lang/GAP/Copy-a-string | 1 + Lang/GAP/Ordered-Partitions | 1 + Lang/GAP/Palindrome-detection | 1 + Lang/GAP/Pascals-triangle | 1 + Lang/GAP/Perfect-numbers | 1 + Lang/GAP/Permutation-test | 1 + Lang/GAP/Permutations | 1 + Lang/GAP/Permutations-Derangements | 1 + Lang/GAP/Polynomial-long-division | 1 + Lang/GAP/Polynomial-regression | 1 + Lang/GAP/Power-set | 1 + Lang/GAP/Primality-by-trial-division | 1 + Lang/GAP/Prime-decomposition | 1 + Lang/GAP/Quaternion-type | 1 + Lang/GAP/Queue-Definition | 1 + Lang/GAP/Random-number-generator--included- | 1 + Lang/GAP/Read-a-file-line-by-line | 1 + Lang/GAP/Read-entire-file | 1 + Lang/GAP/Remove-duplicate-elements | 1 + Lang/GAP/Repeat-a-string | 1 + Lang/GAP/Reverse-a-string | 1 + Lang/GAP/Roots-of-a-quadratic-function | 1 + Lang/GAP/Roots-of-unity | 1 + Lang/GAP/Rot-13 | 1 + Lang/GAP/Sequence-of-non-squares | 1 + Lang/GML/Copy-a-string | 1 + Lang/GML/Palindrome-detection | 1 + Lang/GML/Rot-13 | 1 + Lang/GUISS/Calendar---for-real-programmers | 1 + Lang/GUISS/Calendar-for-real-programmers | 1 - Lang/GUISS/Copy-a-string | 1 + Lang/GUISS/Play-recorded-sounds | 1 + Lang/GUISS/Read-entire-file | 1 + Lang/GUISS/Record-sound | 1 + Lang/GW-BASIC/Pascals-triangle | 1 + Lang/GW-BASIC/Program-termination | 1 + Lang/GW-BASIC/Rot-13 | 1 + Lang/GW-BASIC/Runtime-evaluation | 1 + Lang/Gambas/Copy-a-string | 1 + Lang/Gema/Non-decimal-radices-Output | 1 + Lang/Gema/Program-termination | 1 + Lang/Gema/Reverse-a-string | 1 + Lang/Gema/Rot-13 | 1 + .../Runtime-evaluation-In-an-environment | 1 + .../Arbitrary-precision-integers--included- | 1 + Lang/Go/Arbitrary-precision-integers-included | 1 - Lang/Go/Binary-digits | 1 + Lang/Go/Brownian-tree | 1 + Lang/Go/Catalan-numbers | 1 + Lang/Go/Copy-a-string | 1 + Lang/Go/Dragon-curve | 1 + Lang/Go/Environment-variables | 1 + Lang/Go/Execute-a-Markov-algorithm | 1 + .../Guess-the-number-With-feedback--player- | 1 + Lang/Go/Guess-the-number-With-feedback-player | 1 - Lang/Go/N-queens-problem | 1 + Lang/Go/Non-continuous-subsequences | 1 + Lang/Go/Non-decimal-radices-Convert | 1 + Lang/Go/Non-decimal-radices-Input | 1 + Lang/Go/Non-decimal-radices-Output | 1 + Lang/Go/Nth-root | 1 + Lang/Go/Null-object | 1 + Lang/Go/Number-names | 1 + Lang/Go/Number-reversal-game | 1 + Lang/Go/Numeric-error-propagation | 1 + Lang/Go/Numerical-integration | 1 + ...ical-integration-Gauss-Legendre-Quadrature | 1 + Lang/Go/Object-serialization | 1 + Lang/Go/One-dimensional-cellular-automata | 1 + Lang/Go/One-of-n-lines-in-a-file | 1 + Lang/Go/Optional-parameters | 1 + Lang/Go/Order-two-numerical-lists | 1 + Lang/Go/Ordered-Partitions | 1 + Lang/Go/Palindrome-detection | 1 + Lang/Go/Pangram-checker | 1 + Lang/Go/Parallel-calculations | 1 + Lang/Go/Parametric-polymorphism | 1 + Lang/Go/Parsing-RPN-calculator-algorithm | 1 + Lang/Go/Parsing-RPN-to-infix-conversion | 1 + Lang/Go/Parsing-Shunting-yard-algorithm | 1 + Lang/Go/Pascals-triangle | 1 + Lang/Go/Pascals-triangle-Puzzle | 1 + Lang/Go/Percentage-difference-between-images | 1 + Lang/Go/Perfect-numbers | 1 + Lang/Go/Permutation-test | 1 + Lang/Go/Permutations | 1 + Lang/Go/Permutations-Derangements | 1 + Lang/Go/Pick-random-element | 1 + Lang/Go/Pig-the-dice-game-Player | 1 + Lang/Go/Playing-cards | 1 + Lang/Go/Pointers-and-references | 1 + Lang/Go/Polymorphic-copy | 1 + Lang/Go/Polymorphism | 1 + Lang/Go/Polynomial-long-division | 1 + Lang/Go/Polynomial-regression | 1 + Lang/Go/Power-set | 1 + Lang/Go/Pragmatic-directives | 1 + Lang/Go/Price-fraction | 1 + Lang/Go/Primality-by-trial-division | 1 + Lang/Go/Prime-decomposition | 1 + Lang/Go/Priority-queue | 1 + Lang/Go/Probabilistic-choice | 1 + Lang/Go/Problem-of-Apollonius | 1 + Lang/Go/Program-name | 1 + Lang/Go/Program-termination | 1 + Lang/Go/Pythagorean-triples | 1 + Lang/Go/QR-decomposition | 1 + Lang/Go/Quaternion-type | 1 + Lang/Go/Queue-Definition | 1 + Lang/Go/Queue-Usage | 1 + Lang/Go/RIPEMD-160 | 1 + Lang/Go/Random-number-generator--device- | 1 + Lang/Go/Random-numbers | 1 + Lang/Go/Range-expansion | 1 + Lang/Go/Range-extraction | 1 + Lang/Go/Rate-counter | 1 + Lang/Go/Ray-casting-algorithm | 1 + Lang/Go/Read-a-configuration-file | 1 + Lang/Go/Read-a-file-line-by-line | 1 + Lang/Go/Read-a-specific-line-from-a-file | 1 + Lang/Go/Read-entire-file | 1 + Lang/Go/Real-constants-and-functions | 1 + Lang/Go/Reduced-row-echelon-form | 1 + Lang/Go/Regular-expressions | 1 + Lang/Go/Remove-duplicate-elements | 1 + Lang/Go/Remove-lines-from-a-file | 1 + Lang/Go/Rename-a-file | 1 + Lang/Go/Rendezvous | 1 + Lang/Go/Repeat-a-string | 1 + Lang/Go/Respond-to-an-unknown-method-call | 1 + Lang/Go/Return-multiple-values | 1 + Lang/Go/Reverse-a-string | 1 + Lang/Go/Rock-paper-scissors | 1 + Lang/Go/Roman-numerals-Decode | 1 + Lang/Go/Roman-numerals-Encode | 1 + Lang/Go/Roots-of-a-function | 1 + Lang/Go/Roots-of-a-quadratic-function | 1 + Lang/Go/Roots-of-unity | 1 + Lang/Go/Rosetta-Code-Count-examples | 1 + Lang/Go/Rosetta-Code-Find-unimplemented-tasks | 1 + Lang/Go/Rosetta-Code-Fix-code-tags | 1 + .../Rosetta-Code-Rank-languages-by-popularity | 1 + Lang/Go/Rot-13 | 1 + Lang/Go/Run-length-encoding | 1 + Lang/Go/Runtime-evaluation | 1 + Lang/Go/Runtime-evaluation-In-an-environment | 1 + Lang/Go/S-Expressions | 1 + Lang/Go/SEDOLs | 1 + Lang/Go/Safe-addition | 1 + Lang/Go/Same-Fringe | 1 + Lang/Go/Secure-temporary-file | 1 + Lang/Go/Self-describing-numbers | 1 + Lang/Go/Self-referential-sequence | 1 + Lang/Go/Semordnilap | 1 + Lang/Go/Send-an-unknown-method-call | 1 + Lang/Go/Send-email | 1 + Lang/Go/Sequence-of-non-squares | 1 + Lang/Go/Set | 1 + Lang/Go/Set-consolidation | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Groovy/Binary-digits | 1 + Lang/Groovy/Copy-a-string | 1 + Lang/Groovy/Environment-variables | 1 + Lang/Groovy/Execute-a-Markov-algorithm | 1 + Lang/Groovy/N-queens-problem | 1 + Lang/Groovy/Non-decimal-radices-Convert | 1 + Lang/Groovy/Nth-root | 1 + Lang/Groovy/Number-names | 1 + Lang/Groovy/Number-reversal-game | 1 + Lang/Groovy/Numerical-integration | 1 + Lang/Groovy/Object-serialization | 1 + Lang/Groovy/One-dimensional-cellular-automata | 1 + Lang/Groovy/Order-two-numerical-lists | 1 + Lang/Groovy/Ordered-Partitions | 1 + Lang/Groovy/Palindrome-detection | 1 + Lang/Groovy/Parsing-RPN-calculator-algorithm | 1 + Lang/Groovy/Pascals-triangle | 1 + Lang/Groovy/Perfect-numbers | 1 + Lang/Groovy/Permutations | 1 + Lang/Groovy/Permutations-Derangements | 1 + Lang/Groovy/Pick-random-element | 1 + Lang/Groovy/Pig-the-dice-game | 1 + Lang/Groovy/Playing-cards | 1 + Lang/Groovy/Plot-coordinate-pairs | 1 + Lang/Groovy/Power-set | 1 + Lang/Groovy/Price-fraction | 1 + Lang/Groovy/Primality-by-trial-division | 1 + Lang/Groovy/Prime-decomposition | 1 + Lang/Groovy/Program-name | 1 + Lang/Groovy/Program-termination | 1 + Lang/Groovy/Queue-Definition | 1 + Lang/Groovy/Queue-Usage | 1 + Lang/Groovy/Random-number-generator--device- | 1 + Lang/Groovy/Random-numbers | 1 + Lang/Groovy/Range-expansion | 1 + Lang/Groovy/Range-extraction | 1 + Lang/Groovy/Read-a-file-line-by-line | 1 + Lang/Groovy/Read-a-specific-line-from-a-file | 1 + Lang/Groovy/Read-entire-file | 1 + Lang/Groovy/Real-constants-and-functions | 1 + Lang/Groovy/Reduced-row-echelon-form | 1 + Lang/Groovy/Regular-expressions | 1 + Lang/Groovy/Remove-duplicate-elements | 1 + Lang/Groovy/Rename-a-file | 1 + Lang/Groovy/Repeat-a-string | 1 + Lang/Groovy/Return-multiple-values | 1 + Lang/Groovy/Reverse-a-string | 1 + Lang/Groovy/Roman-numerals-Decode | 1 + Lang/Groovy/Roman-numerals-Encode | 1 + Lang/Groovy/Roots-of-unity | 1 + Lang/Groovy/Rot-13 | 1 + Lang/Groovy/Run-length-encoding | 1 + Lang/Groovy/Runtime-evaluation | 1 + .../Runtime-evaluation-In-an-environment | 1 + Lang/Groovy/SEDOLs | 1 + Lang/Groovy/Secure-temporary-file | 1 + Lang/Groovy/Semordnilap | 1 + Lang/Groovy/Sequence-of-non-squares | 1 + Lang/Groovy/Set | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Haskell/Binary-digits | 1 + Lang/Haskell/Brownian-tree | 1 + Lang/Haskell/Catalan-numbers | 1 + Lang/Haskell/Dragon-curve | 1 + Lang/Haskell/Environment-variables | 1 + Lang/Haskell/Execute-a-Markov-algorithm | 1 + Lang/Haskell/N-queens-problem | 1 + Lang/Haskell/Named-parameters | 1 + Lang/Haskell/Non-continuous-subsequences | 1 + Lang/Haskell/Non-decimal-radices-Convert | 1 + Lang/Haskell/Non-decimal-radices-Input | 1 + Lang/Haskell/Non-decimal-radices-Output | 1 + Lang/Haskell/Nth-root | 1 + Lang/Haskell/Null-object | 1 + Lang/Haskell/Number-names | 1 + Lang/Haskell/Number-reversal-game | 1 + Lang/Haskell/Numeric-error-propagation | 1 + Lang/Haskell/Numerical-integration | 1 + .../Haskell/One-dimensional-cellular-automata | 1 + Lang/Haskell/One-of-n-lines-in-a-file | 1 + Lang/Haskell/OpenGL | 1 + Lang/Haskell/Order-two-numerical-lists | 1 + Lang/Haskell/Ordered-Partitions | 1 + Lang/Haskell/Palindrome-detection | 1 + Lang/Haskell/Pangram-checker | 1 + Lang/Haskell/Parametric-polymorphism | 1 + Lang/Haskell/Parsing-RPN-calculator-algorithm | 1 + Lang/Haskell/Parsing-Shunting-yard-algorithm | 1 + Lang/Haskell/Partial-function-application | 1 + Lang/Haskell/Pascals-triangle | 1 + Lang/Haskell/Pascals-triangle-Puzzle | 1 + Lang/Haskell/Pattern-matching | 1 + Lang/Haskell/Perfect-numbers | 1 + Lang/Haskell/Permutation-test | 1 + Lang/Haskell/Permutations | 1 + Lang/Haskell/Permutations-Derangements | 1 + Lang/Haskell/Permutations-by-swapping | 1 + Lang/Haskell/Pick-random-element | 1 + Lang/Haskell/Playing-cards | 1 + Lang/Haskell/Plot-coordinate-pairs | 1 + Lang/Haskell/Pointers-and-references | 1 + Lang/Haskell/Polymorphism | 1 + Lang/Haskell/Polynomial-long-division | 1 + Lang/Haskell/Polynomial-regression | 1 + Lang/Haskell/Power-set | 1 + Lang/Haskell/Price-fraction | 1 + Lang/Haskell/Primality-by-trial-division | 1 + Lang/Haskell/Prime-decomposition | 1 + Lang/Haskell/Priority-queue | 1 + Lang/Haskell/Probabilistic-choice | 1 + Lang/Haskell/Problem-of-Apollonius | 1 + Lang/Haskell/Program-name | 1 + Lang/Haskell/Program-termination | 1 + Lang/Haskell/Pythagorean-triples | 1 + Lang/Haskell/Quaternion-type | 1 + Lang/Haskell/Queue-Definition | 1 + Lang/Haskell/Queue-Usage | 1 + Lang/Haskell/Random-number-generator--device- | 1 + Lang/Haskell/Random-numbers | 1 + Lang/Haskell/Range-expansion | 1 + Lang/Haskell/Range-extraction | 1 + Lang/Haskell/Ray-casting-algorithm | 1 + Lang/Haskell/Read-a-configuration-file | 1 + Lang/Haskell/Read-a-specific-line-from-a-file | 1 + Lang/Haskell/Read-entire-file | 1 + Lang/Haskell/Real-constants-and-functions | 1 + Lang/Haskell/Reduced-row-echelon-form | 1 + Lang/Haskell/Regular-expressions | 1 + Lang/Haskell/Remove-duplicate-elements | 1 + Lang/Haskell/Remove-lines-from-a-file | 1 + Lang/Haskell/Rename-a-file | 1 + Lang/Haskell/Repeat-a-string | 1 + Lang/Haskell/Return-multiple-values | 1 + Lang/Haskell/Reverse-a-string | 1 + Lang/Haskell/Rock-paper-scissors | 1 + Lang/Haskell/Roman-numerals-Decode | 1 + Lang/Haskell/Roman-numerals-Encode | 1 + Lang/Haskell/Roots-of-a-function | 1 + Lang/Haskell/Roots-of-a-quadratic-function | 1 + Lang/Haskell/Roots-of-unity | 1 + Lang/Haskell/Rosetta-Code-Count-examples | 1 + .../Rosetta-Code-Find-unimplemented-tasks | 1 + .../Rosetta-Code-Rank-languages-by-popularity | 1 + Lang/Haskell/Rot-13 | 1 + Lang/Haskell/Run-length-encoding | 1 + Lang/Haskell/S-Expressions | 1 + Lang/Haskell/SEDOLs | 1 + Lang/Haskell/Same-Fringe | 1 + Lang/Haskell/Secure-temporary-file | 1 + Lang/Haskell/Self-describing-numbers | 1 + Lang/Haskell/Self-referential-sequence | 1 + Lang/Haskell/Semordnilap | 1 + Lang/Haskell/Sequence-of-non-squares | 1 + Lang/Haskell/Set | 1 + Lang/Haskell/Set-consolidation | 1 + Lang/Heron/N-queens-problem | 1 + Lang/HicEst/Copy-a-string | 1 + Lang/HicEst/Dragon-curve | 1 + Lang/HicEst/Environment-variables | 1 + Lang/HicEst/Non-decimal-radices-Convert | 1 + Lang/HicEst/Non-decimal-radices-Input | 1 + Lang/HicEst/Non-decimal-radices-Output | 1 + Lang/HicEst/Nth-root | 1 + Lang/HicEst/Number-names | 1 + Lang/HicEst/Number-reversal-game | 1 + Lang/HicEst/Palindrome-detection | 1 + Lang/HicEst/Pangram-checker | 1 + Lang/HicEst/Pascals-triangle | 1 + Lang/HicEst/Perfect-numbers | 1 + Lang/HicEst/Plot-coordinate-pairs | 1 + Lang/HicEst/Polynomial-regression | 1 + Lang/HicEst/Price-fraction | 1 + Lang/HicEst/Primality-by-trial-division | 1 + Lang/HicEst/Probabilistic-choice | 1 + Lang/HicEst/Program-termination | 1 + Lang/HicEst/Random-numbers | 1 + Lang/HicEst/Rate-counter | 1 + Lang/HicEst/Real-constants-and-functions | 1 + Lang/HicEst/Regular-expressions | 1 + Lang/HicEst/Remove-duplicate-elements | 1 + Lang/HicEst/Rename-a-file | 1 + Lang/HicEst/Repeat-a-string | 1 + Lang/HicEst/Reverse-a-string | 1 + Lang/HicEst/Roman-numerals-Encode | 1 + Lang/HicEst/Roots-of-a-function | 1 + .../Rosetta-Code-Rank-languages-by-popularity | 1 + Lang/HicEst/Rot-13 | 1 + Lang/HicEst/Runtime-evaluation | 1 + Lang/HicEst/Secure-temporary-file | 1 + Lang/HicEst/Sequence-of-non-squares | 1 + Lang/IDL/Pascals-triangle | 1 + Lang/IDL/Random-numbers | 1 + Lang/IDL/Remove-duplicate-elements | 1 + Lang/IDL/Roots-of-a-quadratic-function | 1 + Lang/IDL/Roots-of-unity | 1 + Lang/IDL/Sequence-of-non-squares | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Icon/Binary-digits | 1 + Lang/Icon/Brownian-tree | 1 + Lang/Icon/Calendar---for-real-programmers | 1 + Lang/Icon/Calendar-for-real-programmers | 1 - Lang/Icon/Catalan-numbers | 1 + Lang/Icon/Copy-a-string | 1 + Lang/Icon/Dragon-curve | 1 + Lang/Icon/Environment-variables | 1 + Lang/Icon/Execute-a-Markov-algorithm | 1 + .../Guess-the-number-With-feedback--player- | 1 + .../Guess-the-number-With-feedback-player | 1 - Lang/Icon/N-queens-problem | 1 + Lang/Icon/Named-parameters | 1 + Lang/Icon/Non-decimal-radices-Convert | 1 + Lang/Icon/Non-decimal-radices-Input | 1 + Lang/Icon/Non-decimal-radices-Output | 1 + Lang/Icon/Nth-root | 1 + Lang/Icon/Null-object | 1 + Lang/Icon/Number-reversal-game | 1 + Lang/Icon/One-dimensional-cellular-automata | 1 + Lang/Icon/One-of-n-lines-in-a-file | 1 + Lang/Icon/Optional-parameters | 1 + Lang/Icon/Order-two-numerical-lists | 1 + Lang/Icon/Palindrome-detection | 1 + Lang/Icon/Pangram-checker | 1 + Lang/Icon/Parsing-RPN-calculator-algorithm | 1 + Lang/Icon/Parsing-RPN-to-infix-conversion | 1 + Lang/Icon/Parsing-Shunting-yard-algorithm | 1 + Lang/Icon/Partial-function-application | 1 + Lang/Icon/Pascals-triangle | 1 + .../Icon/Percentage-difference-between-images | 1 + Lang/Icon/Perfect-numbers | 1 + Lang/Icon/Permutations | 1 + Lang/Icon/Pick-random-element | 1 + Lang/Icon/Pinstripe-Display | 1 + Lang/Icon/Playing-cards | 1 + Lang/Icon/Plot-coordinate-pairs | 1 + Lang/Icon/Power-set | 1 + Lang/Icon/Pragmatic-directives | 1 + Lang/Icon/Price-fraction | 1 + Lang/Icon/Primality-by-trial-division | 1 + Lang/Icon/Prime-decomposition | 1 + Lang/Icon/Priority-queue | 1 + Lang/Icon/Probabilistic-choice | 1 + Lang/Icon/Problem-of-Apollonius | 1 + Lang/Icon/Program-name | 1 + Lang/Icon/Program-termination | 1 + Lang/Icon/Pythagorean-triples | 1 + Lang/Icon/Queue-Usage | 1 + Lang/Icon/Random-numbers | 1 + Lang/Icon/Range-expansion | 1 + Lang/Icon/Range-extraction | 1 + Lang/Icon/Read-a-specific-line-from-a-file | 1 + Lang/Icon/Read-entire-file | 1 + Lang/Icon/Regular-expressions | 1 + Lang/Icon/Remove-duplicate-elements | 1 + Lang/Icon/Remove-lines-from-a-file | 1 + Lang/Icon/Rename-a-file | 1 + Lang/Icon/Repeat-a-string | 1 + Lang/Icon/Return-multiple-values | 1 + Lang/Icon/Reverse-a-string | 1 + Lang/Icon/Rock-paper-scissors | 1 + Lang/Icon/Roman-numerals-Decode | 1 + Lang/Icon/Roman-numerals-Encode | 1 + Lang/Icon/Roots-of-unity | 1 + Lang/Icon/Rot-13 | 1 + Lang/Icon/Run-length-encoding | 1 + Lang/Icon/S-Expressions | 1 + Lang/Icon/SEDOLs | 1 + Lang/Icon/Scope-modifiers | 1 + Lang/Icon/Self-describing-numbers | 1 + Lang/Icon/Self-referential-sequence | 1 + Lang/Icon/Sequence-of-non-squares | 1 + Lang/Icon/Set | 1 + Lang/Inform-7/Number-names | 1 + Lang/Inform-7/Number-reversal-game | 1 + Lang/Inform-7/Parametric-polymorphism | 1 + Lang/Inform-7/Polymorphism | 1 + Lang/Inform-7/Price-fraction | 1 + Lang/Inform-7/Read-entire-file | 1 + Lang/Inform-7/Regular-expressions | 1 + Lang/Inform-7/Remove-duplicate-elements | 1 + Lang/Inform-7/Repeat-a-string | 1 + Lang/Io/Null-object | 1 + Lang/Io/Number-reversal-game | 1 + Lang/Io/Program-name | 1 + Lang/Io/Rename-a-file | 1 + Lang/Io/Reverse-a-string | 1 + Lang/Io/Roman-numerals-Encode | 1 + Lang/Ioke/Palindrome-detection | 1 + Lang/Ioke/Pangram-checker | 1 + .../J/Arbitrary-precision-integers--included- | 1 + Lang/J/Arbitrary-precision-integers-included | 1 - Lang/J/Binary-digits | 1 + Lang/J/Brownian-tree | 1 + Lang/J/Calendar---for-real-programmers | 1 + Lang/J/Calendar-for-real-programmers | 1 - Lang/J/Catalan-numbers | 1 + Lang/J/Copy-a-string | 1 + Lang/J/Dragon-curve | 1 + Lang/J/Environment-variables | 1 + Lang/J/Execute-a-Markov-algorithm | 1 + .../J/Guess-the-number-With-feedback--player- | 1 + Lang/J/Guess-the-number-With-feedback-player | 1 - Lang/J/N-queens-problem | 1 + Lang/J/Named-parameters | 1 + Lang/J/Non-continuous-subsequences | 1 + Lang/J/Non-decimal-radices-Convert | 1 + Lang/J/Non-decimal-radices-Input | 1 + Lang/J/Non-decimal-radices-Output | 1 + Lang/J/Nth-root | 1 + Lang/J/Null-object | 1 + Lang/J/Number-reversal-game | 1 + Lang/J/Numeric-error-propagation | 1 + Lang/J/Numerical-integration | 1 + ...ical-integration-Gauss-Legendre-Quadrature | 1 + Lang/J/Object-serialization | 1 + Lang/J/One-dimensional-cellular-automata | 1 + Lang/J/One-of-n-lines-in-a-file | 1 + Lang/J/OpenGL | 1 + Lang/J/Optional-parameters | 1 + Lang/J/Order-two-numerical-lists | 1 + Lang/J/Ordered-Partitions | 1 + Lang/J/Palindrome-detection | 1 + Lang/J/Pangram-checker | 1 + Lang/J/Parallel-calculations | 1 + Lang/J/Parsing-RPN-calculator-algorithm | 1 + Lang/J/Parsing-RPN-to-infix-conversion | 1 + Lang/J/Parsing-Shunting-yard-algorithm | 1 + Lang/J/Partial-function-application | 1 + Lang/J/Pascals-triangle | 1 + Lang/J/Pascals-triangle-Puzzle | 1 + Lang/J/Pattern-matching | 1 + Lang/J/Percentage-difference-between-images | 1 + Lang/J/Perfect-numbers | 1 + Lang/J/Permutation-test | 1 + Lang/J/Permutations | 1 + Lang/J/Permutations-Derangements | 1 + Lang/J/Permutations-by-swapping | 1 + Lang/J/Pick-random-element | 1 + Lang/J/Pig-the-dice-game | 1 + Lang/J/Pig-the-dice-game-Player | 1 + Lang/J/Pinstripe-Display | 1 + Lang/J/Playing-cards | 1 + Lang/J/Plot-coordinate-pairs | 1 + Lang/J/Polymorphism | 1 + Lang/J/Polynomial-long-division | 1 + Lang/J/Polynomial-regression | 1 + Lang/J/Power-set | 1 + Lang/J/Pragmatic-directives | 1 + Lang/J/Price-fraction | 1 + Lang/J/Primality-by-trial-division | 1 + Lang/J/Prime-decomposition | 1 + Lang/J/Priority-queue | 1 + Lang/J/Probabilistic-choice | 1 + Lang/J/Problem-of-Apollonius | 1 + Lang/J/Program-name | 1 + Lang/J/Program-termination | 1 + Lang/J/Pythagorean-triples | 1 + Lang/J/QR-decomposition | 1 + Lang/J/Quaternion-type | 1 + Lang/J/Queue-Definition | 1 + Lang/J/Queue-Usage | 1 + Lang/J/Random-number-generator--device- | 1 + Lang/J/Random-numbers | 1 + Lang/J/Range-expansion | 1 + Lang/J/Range-extraction | 1 + Lang/J/Rate-counter | 1 + Lang/J/Ray-casting-algorithm | 1 + Lang/J/Read-a-configuration-file | 1 + Lang/J/Read-a-file-line-by-line | 1 + Lang/J/Read-a-specific-line-from-a-file | 1 + Lang/J/Read-entire-file | 1 + Lang/J/Real-constants-and-functions | 1 + Lang/J/Reduced-row-echelon-form | 1 + Lang/J/Regular-expressions | 1 + Lang/J/Remove-duplicate-elements | 1 + Lang/J/Remove-lines-from-a-file | 1 + Lang/J/Rename-a-file | 1 + Lang/J/Repeat-a-string | 1 + Lang/J/Resistor-mesh | 1 + Lang/J/Respond-to-an-unknown-method-call | 1 + Lang/J/Return-multiple-values | 1 + Lang/J/Reverse-a-string | 1 + Lang/J/Rock-paper-scissors | 1 + Lang/J/Roman-numerals-Decode | 1 + Lang/J/Roman-numerals-Encode | 1 + Lang/J/Roots-of-a-function | 1 + Lang/J/Roots-of-a-quadratic-function | 1 + Lang/J/Roots-of-unity | 1 + Lang/J/Rosetta-Code-Count-examples | 1 + Lang/J/Rosetta-Code-Find-unimplemented-tasks | 1 + Lang/J/Rosetta-Code-Fix-code-tags | 1 + Lang/J/Rot-13 | 1 + Lang/J/Run-length-encoding | 1 + Lang/J/Runtime-evaluation | 1 + Lang/J/Runtime-evaluation-In-an-environment | 1 + Lang/J/S-Expressions | 1 + Lang/J/SEDOLs | 1 + Lang/J/Safe-addition | 1 + Lang/J/Same-Fringe | 1 + Lang/J/Scope-modifiers | 1 + Lang/J/Self-describing-numbers | 1 + Lang/J/Self-referential-sequence | 1 + Lang/J/Semordnilap | 1 + Lang/J/Sequence-of-non-squares | 1 + Lang/J/Set | 1 + Lang/J/Set-consolidation | 1 + Lang/J/Set-of-real-numbers | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Java/Binary-digits | 1 + Lang/Java/Brownian-tree | 1 + Lang/Java/Catalan-numbers | 1 + Lang/Java/Copy-a-string | 1 + Lang/Java/Dragon-curve | 1 + Lang/Java/Environment-variables | 1 + .../Guess-the-number-With-feedback--player- | 1 + .../Guess-the-number-With-feedback-player | 1 - Lang/Java/N-queens-problem | 1 + Lang/Java/Named-parameters | 1 + Lang/Java/Non-decimal-radices-Convert | 1 + Lang/Java/Non-decimal-radices-Input | 1 + Lang/Java/Non-decimal-radices-Output | 1 + Lang/Java/Nth-root | 1 + Lang/Java/Null-object | 1 + Lang/Java/Number-names | 1 + Lang/Java/Number-reversal-game | 1 + Lang/Java/Numerical-integration | 1 + Lang/Java/Object-serialization | 1 + Lang/Java/One-dimensional-cellular-automata | 1 + Lang/Java/One-of-n-lines-in-a-file | 1 + Lang/Java/OpenGL | 1 + Lang/Java/Optional-parameters | 1 + Lang/Java/Order-two-numerical-lists | 1 + Lang/Java/Palindrome-detection | 1 + Lang/Java/Pangram-checker | 1 + Lang/Java/Parametric-polymorphism | 1 + Lang/Java/Parametrized-SQL-statement | 1 + Lang/Java/Parsing-RPN-calculator-algorithm | 1 + Lang/Java/Partial-function-application | 1 + Lang/Java/Pascals-triangle | 1 + .../Java/Percentage-difference-between-images | 1 + Lang/Java/Perfect-numbers | 1 + Lang/Java/Permutations | 1 + Lang/Java/Permutations-Derangements | 1 + Lang/Java/Pick-random-element | 1 + Lang/Java/Pig-the-dice-game | 1 + Lang/Java/Playing-cards | 1 + Lang/Java/Plot-coordinate-pairs | 1 + Lang/Java/Pointers-and-references | 1 + Lang/Java/Polymorphic-copy | 1 + Lang/Java/Polymorphism | 1 + Lang/Java/Power-set | 1 + Lang/Java/Price-fraction | 1 + Lang/Java/Primality-by-trial-division | 1 + Lang/Java/Prime-decomposition | 1 + Lang/Java/Priority-queue | 1 + Lang/Java/Probabilistic-choice | 1 + Lang/Java/Problem-of-Apollonius | 1 + Lang/Java/Program-name | 1 + Lang/Java/Program-termination | 1 + Lang/Java/Pythagorean-triples | 1 + Lang/Java/Quaternion-type | 1 + Lang/Java/Queue-Definition | 1 + Lang/Java/Queue-Usage | 1 + Lang/Java/RIPEMD-160 | 1 + Lang/Java/Random-number-generator--device- | 1 + Lang/Java/Random-numbers | 1 + Lang/Java/Range-expansion | 1 + Lang/Java/Range-extraction | 1 + Lang/Java/Read-a-file-line-by-line | 1 + Lang/Java/Read-a-specific-line-from-a-file | 1 + Lang/Java/Read-entire-file | 1 + Lang/Java/Real-constants-and-functions | 1 + Lang/Java/Reduced-row-echelon-form | 1 + Lang/Java/Regular-expressions | 1 + Lang/Java/Remove-duplicate-elements | 1 + Lang/Java/Rename-a-file | 1 + Lang/Java/Repeat-a-string | 1 + Lang/Java/Return-multiple-values | 1 + Lang/Java/Reverse-a-string | 1 + Lang/Java/Rock-paper-scissors | 1 + Lang/Java/Roman-numerals-Decode | 1 + Lang/Java/Roman-numerals-Encode | 1 + Lang/Java/Roots-of-a-function | 1 + Lang/Java/Roots-of-a-quadratic-function | 1 + Lang/Java/Roots-of-unity | 1 + Lang/Java/Rosetta-Code-Count-examples | 1 + Lang/Java/Rot-13 | 1 + Lang/Java/Run-length-encoding | 1 + .../Java/Runtime-evaluation-In-an-environment | 1 + Lang/Java/S-Expressions | 1 + Lang/Java/SEDOLs | 1 + Lang/Java/Same-Fringe | 1 + Lang/Java/Scope-modifiers | 1 + Lang/Java/Secure-temporary-file | 1 + Lang/Java/Self-describing-numbers | 1 + Lang/Java/Semordnilap | 1 + Lang/Java/Send-an-unknown-method-call | 1 + Lang/Java/Send-email | 1 + Lang/Java/Sequence-of-non-squares | 1 + Lang/Java/Set | 1 + Lang/Java/Set-consolidation | 1 + Lang/JavaScript/Binary-digits | 1 + Lang/JavaScript/Brownian-tree | 1 + Lang/JavaScript/Catalan-numbers | 1 + Lang/JavaScript/Copy-a-string | 1 + Lang/JavaScript/Dragon-curve | 1 + Lang/JavaScript/Environment-variables | 1 + .../Guess-the-number-With-feedback--player- | 1 + .../Guess-the-number-With-feedback-player | 1 - Lang/JavaScript/Named-parameters | 1 + Lang/JavaScript/Non-continuous-subsequences | 1 + Lang/JavaScript/Non-decimal-radices-Convert | 1 + Lang/JavaScript/Non-decimal-radices-Input | 1 + Lang/JavaScript/Non-decimal-radices-Output | 1 + Lang/JavaScript/Nth-root | 1 + Lang/JavaScript/Null-object | 1 + Lang/JavaScript/Number-reversal-game | 1 + .../One-dimensional-cellular-automata | 1 + Lang/JavaScript/OpenGL | 1 + Lang/JavaScript/Optional-parameters | 1 + Lang/JavaScript/Palindrome-detection | 1 + Lang/JavaScript/Pangram-checker | 1 + Lang/JavaScript/Parallel-calculations | 1 + Lang/JavaScript/Pascals-triangle | 1 + Lang/JavaScript/Perfect-numbers | 1 + Lang/JavaScript/Permutations | 1 + Lang/JavaScript/Pick-random-element | 1 + Lang/JavaScript/Playing-cards | 1 + Lang/JavaScript/Polymorphic-copy | 1 + Lang/JavaScript/Polymorphism | 1 + Lang/JavaScript/Power-set | 1 + Lang/JavaScript/Price-fraction | 1 + Lang/JavaScript/Primality-by-trial-division | 1 + Lang/JavaScript/Prime-decomposition | 1 + Lang/JavaScript/Probabilistic-choice | 1 + Lang/JavaScript/Program-name | 1 + Lang/JavaScript/Program-termination | 1 + Lang/JavaScript/Queue-Definition | 1 + Lang/JavaScript/Queue-Usage | 1 + Lang/JavaScript/Random-numbers | 1 + Lang/JavaScript/Range-expansion | 1 + Lang/JavaScript/Range-extraction | 1 + Lang/JavaScript/Rate-counter | 1 + Lang/JavaScript/Read-entire-file | 1 + Lang/JavaScript/Real-constants-and-functions | 1 + Lang/JavaScript/Reduced-row-echelon-form | 1 + Lang/JavaScript/Regular-expressions | 1 + Lang/JavaScript/Remove-duplicate-elements | 1 + Lang/JavaScript/Rename-a-file | 1 + Lang/JavaScript/Repeat-a-string | 1 + .../Respond-to-an-unknown-method-call | 1 + Lang/JavaScript/Reverse-a-string | 1 + Lang/JavaScript/Roman-numerals-Decode | 1 + Lang/JavaScript/Roman-numerals-Encode | 1 + Lang/JavaScript/Rosetta-Code-Fix-code-tags | 1 + Lang/JavaScript/Rot-13 | 1 + Lang/JavaScript/Run-length-encoding | 1 + Lang/JavaScript/Runtime-evaluation | 1 + .../Runtime-evaluation-In-an-environment | 1 + Lang/JavaScript/SEDOLs | 1 + Lang/JavaScript/Self-describing-numbers | 1 + Lang/JavaScript/Send-an-unknown-method-call | 1 + Lang/Joy/Binary-digits | 1 + Lang/Joy/Copy-a-string | 1 + Lang/Joy/Environment-variables | 1 + Lang/Joy/Number-names | 1 + Lang/Joy/Order-two-numerical-lists | 1 + Lang/Joy/Primality-by-trial-division | 1 + Lang/Joy/Rename-a-file | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Julia/Catalan-numbers | 1 + Lang/Julia/Perfect-numbers | 1 + Lang/Julia/Read-a-file-line-by-line | 1 + Lang/Julia/Read-entire-file | 1 + Lang/Julia/Regular-expressions | 1 + Lang/Julia/Remove-duplicate-elements | 1 + Lang/Julia/Repeat-a-string | 1 + Lang/Julia/Return-multiple-values | 1 + Lang/Julia/Reverse-a-string | 1 + Lang/Julia/Rock-paper-scissors | 1 + Lang/Julia/Self-describing-numbers | 1 + Lang/Julia/Semordnilap | 1 + Lang/K/Binary-digits | 1 + Lang/K/Catalan-numbers | 1 + Lang/K/Environment-variables | 1 + Lang/K/Null-object | 1 + Lang/K/One-dimensional-cellular-automata | 1 + Lang/K/Pangram-checker | 1 + Lang/K/Pascals-triangle | 1 + Lang/K/Perfect-numbers | 1 + Lang/K/Permutations | 1 + Lang/K/Pick-random-element | 1 + Lang/K/Playing-cards | 1 + Lang/K/Power-set | 1 + Lang/K/Price-fraction | 1 + Lang/K/Primality-by-trial-division | 1 + Lang/K/Range-expansion | 1 + Lang/K/Range-extraction | 1 + Lang/K/Remove-duplicate-elements | 1 + Lang/K/Repeat-a-string | 1 + Lang/K/Roman-numerals-Decode | 1 + Lang/K/Rot-13 | 1 + Lang/K/Run-length-encoding | 1 + Lang/K/Self-describing-numbers | 1 + Lang/KonsolScript/Copy-a-string | 1 + Lang/LLVM/Program-name | 1 + Lang/LOLCODE/Binary-digits | 1 + Lang/LSE64/Primality-by-trial-division | 1 + Lang/LSL/Environment-variables | 1 + Lang/LaTeX/Roman-numerals-Encode | 1 + Lang/Lang5/Binary-digits | 1 + Lang/Lang5/Copy-a-string | 1 + Lang/Lang5/Read-entire-file | 1 + Lang/Lang5/Remove-duplicate-elements | 1 + Lang/Lang5/Reverse-a-string | 1 + Lang/Lhogho/Order-two-numerical-lists | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Liberty-BASIC/Binary-digits | 1 + Lang/Liberty-BASIC/Brownian-tree | 1 + Lang/Liberty-BASIC/Catalan-numbers | 1 + Lang/Liberty-BASIC/Copy-a-string | 1 + Lang/Liberty-BASIC/Dragon-curve | 1 + Lang/Liberty-BASIC/Environment-variables | 1 + .../Guess-the-number-With-feedback--player- | 1 + .../Guess-the-number-With-feedback-player | 1 - .../Liberty-BASIC/Non-decimal-radices-Convert | 1 + Lang/Liberty-BASIC/Nth-root | 1 + Lang/Liberty-BASIC/Numerical-integration | 1 + .../One-dimensional-cellular-automata | 1 + Lang/Liberty-BASIC/OpenGL | 1 + Lang/Liberty-BASIC/Palindrome-detection | 1 + Lang/Liberty-BASIC/Pangram-checker | 1 + Lang/Liberty-BASIC/Pascals-triangle | 1 + .../Percentage-difference-between-images | 1 + Lang/Liberty-BASIC/Perfect-numbers | 1 + Lang/Liberty-BASIC/Pick-random-element | 1 + Lang/Liberty-BASIC/Pinstripe-Printer | 1 + Lang/Liberty-BASIC/Play-recorded-sounds | 1 + Lang/Liberty-BASIC/Playing-cards | 1 + Lang/Liberty-BASIC/Plot-coordinate-pairs | 1 + Lang/Liberty-BASIC/Price-fraction | 1 + .../Liberty-BASIC/Primality-by-trial-division | 1 + Lang/Liberty-BASIC/Probabilistic-choice | 1 + Lang/Liberty-BASIC/Problem-of-Apollonius | 1 + Lang/Liberty-BASIC/Program-termination | 1 + Lang/Liberty-BASIC/Pythagorean-triples | 1 + Lang/Liberty-BASIC/Quaternion-type | 1 + Lang/Liberty-BASIC/Random-numbers | 1 + Lang/Liberty-BASIC/Range-expansion | 1 + Lang/Liberty-BASIC/Range-extraction | 1 + Lang/Liberty-BASIC/Rate-counter | 1 + Lang/Liberty-BASIC/Ray-casting-algorithm | 1 + Lang/Liberty-BASIC/Read-a-configuration-file | 1 + Lang/Liberty-BASIC/Read-a-file-line-by-line | 1 + .../Read-a-specific-line-from-a-file | 1 + Lang/Liberty-BASIC/Read-entire-file | 1 + .../Real-constants-and-functions | 1 + Lang/Liberty-BASIC/Record-sound | 1 + Lang/Liberty-BASIC/Remove-duplicate-elements | 1 + Lang/Liberty-BASIC/Remove-lines-from-a-file | 1 + Lang/Liberty-BASIC/Rename-a-file | 1 + Lang/Liberty-BASIC/Repeat-a-string | 1 + Lang/Liberty-BASIC/Return-multiple-values | 1 + Lang/Liberty-BASIC/Reverse-a-string | 1 + Lang/Liberty-BASIC/Rock-paper-scissors | 1 + Lang/Liberty-BASIC/Roman-numerals-Decode | 1 + Lang/Liberty-BASIC/Roman-numerals-Encode | 1 + Lang/Liberty-BASIC/Roots-of-a-function | 1 + .../Roots-of-a-quadratic-function | 1 + Lang/Liberty-BASIC/Roots-of-unity | 1 + Lang/Liberty-BASIC/Rot-13 | 1 + Lang/Liberty-BASIC/Run-length-encoding | 1 + Lang/Liberty-BASIC/Runtime-evaluation | 1 + .../Runtime-evaluation-In-an-environment | 1 + Lang/Liberty-BASIC/SEDOLs | 1 + Lang/Liberty-BASIC/Self-describing-numbers | 1 + Lang/Liberty-BASIC/Semordnilap | 1 + Lang/Liberty-BASIC/Send-email | 1 + Lang/Liberty-BASIC/Sequence-of-non-squares | 1 + Lang/Liberty-BASIC/Set | 1 + Lang/Lisaac/Copy-a-string | 1 + Lang/Locomotive-Basic/Binary-digits | 1 + Lang/Locomotive-Basic/N-queens-problem | 1 + .../Non-decimal-radices-Output | 1 + .../One-dimensional-cellular-automata | 1 + Lang/Locomotive-Basic/Pascals-triangle | 1 + Lang/Locomotive-Basic/Pinstripe-Display | 1 + Lang/Locomotive-Basic/Rename-a-file | 1 + Lang/Locomotive-Basic/Rock-paper-scissors | 1 + Lang/Locomotive-Basic/Rot-13 | 1 + Lang/Logo/Copy-a-string | 1 + Lang/Logo/Dragon-curve | 1 + Lang/Logo/N-queens-problem | 1 + Lang/Logo/Nth-root | 1 + Lang/Logo/Null-object | 1 + Lang/Logo/Number-names | 1 + Lang/Logo/Numerical-integration | 1 + Lang/Logo/One-dimensional-cellular-automata | 1 + Lang/Logo/Optional-parameters | 1 + Lang/Logo/Palindrome-detection | 1 + Lang/Logo/Pangram-checker | 1 + Lang/Logo/Pascals-triangle | 1 + Lang/Logo/Perfect-numbers | 1 + Lang/Logo/Pick-random-element | 1 + Lang/Logo/Playing-cards | 1 + Lang/Logo/Power-set | 1 + Lang/Logo/Primality-by-trial-division | 1 + Lang/Logo/Prime-decomposition | 1 + Lang/Logo/Program-termination | 1 + Lang/Logo/Queue-Usage | 1 + Lang/Logo/Random-numbers | 1 + Lang/Logo/Read-a-file-line-by-line | 1 + Lang/Logo/Real-constants-and-functions | 1 + Lang/Logo/Remove-duplicate-elements | 1 + Lang/Logo/Repeat-a-string | 1 + Lang/Logo/Reverse-a-string | 1 + Lang/Logo/Roman-numerals-Decode | 1 + Lang/Logo/Roman-numerals-Encode | 1 + Lang/Logo/Roots-of-a-quadratic-function | 1 + Lang/Logo/Rot-13 | 1 + Lang/Logo/Run-length-encoding | 1 + Lang/Logo/Scope-modifiers | 1 + Lang/Logo/Self-describing-numbers | 1 + Lang/Logo/Sequence-of-non-squares | 1 + Lang/Logtalk/Permutations | 1 + Lang/Logtalk/Power-set | 1 + Lang/LotusScript/Roman-numerals-Encode | 1 + Lang/LotusScript/Send-email | 1 + Lang/Lua/Brownian-tree | 1 + Lang/Lua/Catalan-numbers | 1 + Lang/Lua/Copy-a-string | 1 + Lang/Lua/Dragon-curve | 1 + Lang/Lua/Environment-variables | 1 + Lang/Lua/N-queens-problem | 1 + Lang/Lua/Named-parameters | 1 + Lang/Lua/Non-decimal-radices-Input | 1 + Lang/Lua/Non-decimal-radices-Output | 1 + Lang/Lua/Nth-root | 1 + Lang/Lua/Null-object | 1 + Lang/Lua/Number-names | 1 + Lang/Lua/Numerical-integration | 1 + Lang/Lua/One-dimensional-cellular-automata | 1 + Lang/Lua/OpenGL | 1 + Lang/Lua/Ordered-Partitions | 1 + Lang/Lua/Palindrome-detection | 1 + Lang/Lua/Pangram-checker | 1 + Lang/Lua/Pascals-triangle | 1 + Lang/Lua/Perfect-numbers | 1 + Lang/Lua/Permutations | 1 + Lang/Lua/Pick-random-element | 1 + Lang/Lua/Playing-cards | 1 + Lang/Lua/Polymorphism | 1 + Lang/Lua/Power-set | 1 + Lang/Lua/Primality-by-trial-division | 1 + Lang/Lua/Prime-decomposition | 1 + Lang/Lua/Probabilistic-choice | 1 + Lang/Lua/Program-name | 1 + Lang/Lua/Program-termination | 1 + Lang/Lua/Quaternion-type | 1 + Lang/Lua/Queue-Definition | 1 + Lang/Lua/Queue-Usage | 1 + Lang/Lua/Read-a-configuration-file | 1 + Lang/Lua/Read-a-file-line-by-line | 1 + Lang/Lua/Read-entire-file | 1 + Lang/Lua/Real-constants-and-functions | 1 + Lang/Lua/Reduced-row-echelon-form | 1 + Lang/Lua/Regular-expressions | 1 + Lang/Lua/Remove-duplicate-elements | 1 + Lang/Lua/Remove-lines-from-a-file | 1 + Lang/Lua/Rename-a-file | 1 + Lang/Lua/Repeat-a-string | 1 + Lang/Lua/Respond-to-an-unknown-method-call | 1 + Lang/Lua/Return-multiple-values | 1 + Lang/Lua/Reverse-a-string | 1 + Lang/Lua/Roman-numerals-Decode | 1 + Lang/Lua/Roman-numerals-Encode | 1 + Lang/Lua/Roots-of-a-quadratic-function | 1 + Lang/Lua/Roots-of-unity | 1 + Lang/Lua/Rosetta-Code-Fix-code-tags | 1 + Lang/Lua/Rot-13 | 1 + Lang/Lua/Run-length-encoding | 1 + Lang/Lua/Runtime-evaluation | 1 + Lang/Lua/Runtime-evaluation-In-an-environment | 1 + Lang/Lua/Secure-temporary-file | 1 + Lang/Lua/Self-describing-numbers | 1 + Lang/Lua/Send-email | 1 + Lang/Lua/Sequence-of-non-squares | 1 + Lang/M4/Non-decimal-radices-Convert | 1 + Lang/M4/One-dimensional-cellular-automata | 1 + Lang/M4/Palindrome-detection | 1 + Lang/M4/Perfect-numbers | 1 + Lang/M4/Playing-cards | 1 + Lang/M4/Power-set | 1 + Lang/M4/Primality-by-trial-division | 1 + Lang/M4/Program-termination | 1 + Lang/M4/Regular-expressions | 1 + Lang/M4/Reverse-a-string | 1 + Lang/M4/Roman-numerals-Encode | 1 + Lang/M4/SEDOLs | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/MATLAB/Binary-digits | 1 + Lang/MATLAB/Catalan-numbers | 1 + Lang/MATLAB/Copy-a-string | 1 + Lang/MATLAB/Environment-variables | 1 + Lang/MATLAB/Named-parameters | 1 + Lang/MATLAB/Nth-root | 1 + Lang/MATLAB/Numerical-integration | 1 + Lang/MATLAB/Palindrome-detection | 1 + Lang/MATLAB/Pangram-checker | 1 + Lang/MATLAB/Pascals-triangle | 1 + Lang/MATLAB/Pick-random-element | 1 + Lang/MATLAB/Plot-coordinate-pairs | 1 + Lang/MATLAB/Polynomial-regression | 1 + Lang/MATLAB/Power-set | 1 + Lang/MATLAB/Price-fraction | 1 + Lang/MATLAB/Primality-by-trial-division | 1 + Lang/MATLAB/Prime-decomposition | 1 + Lang/MATLAB/Program-termination | 1 + Lang/MATLAB/Pythagorean-triples | 1 + Lang/MATLAB/QR-decomposition | 1 + Lang/MATLAB/Queue-Definition | 1 + Lang/MATLAB/Random-numbers | 1 + Lang/MATLAB/Read-a-configuration-file | 1 + Lang/MATLAB/Read-a-file-line-by-line | 1 + Lang/MATLAB/Read-a-specific-line-from-a-file | 1 + Lang/MATLAB/Read-entire-file | 1 + Lang/MATLAB/Reduced-row-echelon-form | 1 + Lang/MATLAB/Remove-duplicate-elements | 1 + Lang/MATLAB/Rename-a-file | 1 + Lang/MATLAB/Repeat-a-string | 1 + Lang/MATLAB/Return-multiple-values | 1 + Lang/MATLAB/Reverse-a-string | 1 + Lang/MATLAB/Roots-of-a-quadratic-function | 1 + Lang/MATLAB/Roots-of-unity | 1 + Lang/MATLAB/Rosetta-Code-Count-examples | 1 + Lang/MATLAB/Rot-13 | 1 + Lang/MATLAB/Self-describing-numbers | 1 + Lang/MATLAB/Send-an-unknown-method-call | 1 + Lang/MATLAB/Sequence-of-non-squares | 1 + Lang/MATLAB/Set | 1 + Lang/MAXScript/Copy-a-string | 1 + Lang/MAXScript/Null-object | 1 + Lang/MAXScript/Number-names | 1 + Lang/MAXScript/OpenGL | 1 + Lang/MAXScript/Palindrome-detection | 1 + .../Percentage-difference-between-images | 1 + Lang/MAXScript/Perfect-numbers | 1 + Lang/MAXScript/Primality-by-trial-division | 1 + Lang/MAXScript/Random-numbers | 1 + Lang/MAXScript/Real-constants-and-functions | 1 + Lang/MAXScript/Remove-duplicate-elements | 1 + Lang/MAXScript/Rename-a-file | 1 + Lang/MAXScript/Reverse-a-string | 1 + .../Regular-expressions | 1 + Lang/MMIX/Palindrome-detection | 1 + Lang/MMIX/Rot-13 | 1 + Lang/MMIX/Run-length-encoding | 1 + Lang/MMIX/Sequence-of-non-squares | 1 + Lang/MUMPS/Copy-a-string | 1 + Lang/MUMPS/Environment-variables | 1 + Lang/MUMPS/N-queens-problem | 1 + Lang/MUMPS/Null-object | 1 + Lang/MUMPS/Price-fraction | 1 + Lang/MUMPS/Primality-by-trial-division | 1 + Lang/MUMPS/Prime-decomposition | 1 + Lang/MUMPS/Problem-of-Apollonius | 1 + Lang/MUMPS/Range-expansion | 1 + Lang/MUMPS/Range-extraction | 1 + Lang/MUMPS/Regular-expressions | 1 + Lang/MUMPS/Remove-duplicate-elements | 1 + Lang/MUMPS/Rename-a-file | 1 + Lang/MUMPS/Repeat-a-string | 1 + Lang/MUMPS/Reverse-a-string | 1 + Lang/MUMPS/Roman-numerals-Encode | 1 + Lang/MUMPS/Rot-13 | 1 + Lang/MUMPS/SEDOLs | 1 + Lang/MUMPS/Scope-modifiers | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Maple/Binary-digits | 1 + Lang/Maple/Copy-a-string | 1 + Lang/Maple/Permutations | 1 + Lang/Maple/Polynomial-long-division | 1 + Lang/Maple/Primality-by-trial-division | 1 + Lang/Maple/Range-expansion | 1 + Lang/Maple/Read-entire-file | 1 + Lang/Maple/Real-constants-and-functions | 1 + Lang/Maple/Remove-duplicate-elements | 1 + Lang/Maple/Rename-a-file | 1 + Lang/Maple/Repeat-a-string | 1 + Lang/Maple/Return-multiple-values | 1 + Lang/Maple/Reverse-a-string | 1 + Lang/Maple/Roots-of-a-function | 1 + Lang/Maple/Rot-13 | 1 + Lang/Maple/Set | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Mathematica/Binary-digits | 1 + Lang/Mathematica/Brownian-tree | 1 + Lang/Mathematica/Catalan-numbers | 1 + Lang/Mathematica/Copy-a-string | 1 + Lang/Mathematica/Dragon-curve | 1 + Lang/Mathematica/Environment-variables | 1 + Lang/Mathematica/Execute-a-Markov-algorithm | 1 + .../Guess-the-number-With-feedback--player- | 1 + .../Guess-the-number-With-feedback-player | 1 - Lang/Mathematica/N-queens-problem | 1 + Lang/Mathematica/Named-parameters | 1 + Lang/Mathematica/Non-continuous-subsequences | 1 + Lang/Mathematica/Non-decimal-radices-Convert | 1 + Lang/Mathematica/Non-decimal-radices-Input | 1 + Lang/Mathematica/Non-decimal-radices-Output | 1 + Lang/Mathematica/Nth-root | 1 + Lang/Mathematica/Null-object | 1 + Lang/Mathematica/Number-names | 1 + Lang/Mathematica/Number-reversal-game | 1 + Lang/Mathematica/Numeric-error-propagation | 1 + Lang/Mathematica/Numerical-integration | 1 + ...ical-integration-Gauss-Legendre-Quadrature | 1 + .../One-dimensional-cellular-automata | 1 + Lang/Mathematica/Optional-parameters | 1 + Lang/Mathematica/Order-two-numerical-lists | 1 + Lang/Mathematica/Ordered-Partitions | 1 + Lang/Mathematica/Palindrome-detection | 1 + Lang/Mathematica/Pangram-checker | 1 + Lang/Mathematica/Parallel-calculations | 1 + Lang/Mathematica/Parametrized-SQL-statement | 1 + Lang/Mathematica/Partial-function-application | 1 + Lang/Mathematica/Pascals-triangle | 1 + Lang/Mathematica/Pascals-triangle-Puzzle | 1 + .../Percentage-difference-between-images | 1 + Lang/Mathematica/Perfect-numbers | 1 + Lang/Mathematica/Permutation-test | 1 + Lang/Mathematica/Permutations | 1 + Lang/Mathematica/Permutations-Derangements | 1 + Lang/Mathematica/Permutations-by-swapping | 1 + Lang/Mathematica/Pick-random-element | 1 + Lang/Mathematica/Pig-the-dice-game | 1 + Lang/Mathematica/Play-recorded-sounds | 1 + Lang/Mathematica/Playing-cards | 1 + Lang/Mathematica/Plot-coordinate-pairs | 1 + Lang/Mathematica/Polynomial-long-division | 1 + Lang/Mathematica/Polynomial-regression | 1 + Lang/Mathematica/Power-set | 1 + Lang/Mathematica/Price-fraction | 1 + Lang/Mathematica/Primality-by-trial-division | 1 + Lang/Mathematica/Prime-decomposition | 1 + Lang/Mathematica/Priority-queue | 1 + Lang/Mathematica/Probabilistic-choice | 1 + Lang/Mathematica/Problem-of-Apollonius | 1 + Lang/Mathematica/Program-name | 1 + Lang/Mathematica/Program-termination | 1 + Lang/Mathematica/Pythagorean-triples | 1 + Lang/Mathematica/QR-decomposition | 1 + Lang/Mathematica/Quaternion-type | 1 + Lang/Mathematica/Queue-Definition | 1 + Lang/Mathematica/Queue-Usage | 1 + Lang/Mathematica/Random-numbers | 1 + Lang/Mathematica/Range-expansion | 1 + Lang/Mathematica/Range-extraction | 1 + Lang/Mathematica/Read-a-file-line-by-line | 1 + .../Read-a-specific-line-from-a-file | 1 + Lang/Mathematica/Read-entire-file | 1 + Lang/Mathematica/Real-constants-and-functions | 1 + Lang/Mathematica/Record-sound | 1 + Lang/Mathematica/Reduced-row-echelon-form | 1 + Lang/Mathematica/Regular-expressions | 1 + Lang/Mathematica/Remove-duplicate-elements | 1 + Lang/Mathematica/Rename-a-file | 1 + Lang/Mathematica/Repeat-a-string | 1 + Lang/Mathematica/Resistor-mesh | 1 + Lang/Mathematica/Return-multiple-values | 1 + Lang/Mathematica/Reverse-a-string | 1 + Lang/Mathematica/Rock-paper-scissors | 1 + Lang/Mathematica/Roman-numerals-Decode | 1 + Lang/Mathematica/Roman-numerals-Encode | 1 + Lang/Mathematica/Roots-of-a-function | 1 + .../Mathematica/Roots-of-a-quadratic-function | 1 + Lang/Mathematica/Roots-of-unity | 1 + Lang/Mathematica/Rosetta-Code-Count-examples | 1 + Lang/Mathematica/Rosetta-Code-Fix-code-tags | 1 + .../Rosetta-Code-Rank-languages-by-popularity | 1 + Lang/Mathematica/Rot-13 | 1 + Lang/Mathematica/Run-length-encoding | 1 + .../Runtime-evaluation-In-an-environment | 1 + Lang/Mathematica/SEDOLs | 1 + Lang/Mathematica/Scope-modifiers | 1 + Lang/Mathematica/Secure-temporary-file | 1 + Lang/Mathematica/Self-describing-numbers | 1 + Lang/Mathematica/Self-referential-sequence | 1 + Lang/Mathematica/Semordnilap | 1 + Lang/Mathematica/Send-email | 1 + Lang/Mathematica/Sequence-of-non-squares | 1 + Lang/Mathematica/Set | 1 + Lang/Mathematica/Set-consolidation | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Maxima/Binary-digits | 1 + Lang/Maxima/Catalan-numbers | 1 + Lang/Maxima/Copy-a-string | 1 + Lang/Maxima/N-queens-problem | 1 + Lang/Maxima/Nth-root | 1 + Lang/Maxima/Numerical-integration | 1 + ...ical-integration-Gauss-Legendre-Quadrature | 1 + Lang/Maxima/Order-two-numerical-lists | 1 + Lang/Maxima/Palindrome-detection | 1 + Lang/Maxima/Pascals-triangle | 1 + Lang/Maxima/Perfect-numbers | 1 + Lang/Maxima/Permutations | 1 + Lang/Maxima/Plot-coordinate-pairs | 1 + Lang/Maxima/Power-set | 1 + Lang/Maxima/Prime-decomposition | 1 + Lang/Maxima/Priority-queue | 1 + Lang/Maxima/Program-termination | 1 + Lang/Maxima/QR-decomposition | 1 + Lang/Maxima/Queue-Definition | 1 + Lang/Maxima/Random-numbers | 1 + Lang/Maxima/Read-a-file-line-by-line | 1 + Lang/Maxima/Reduced-row-echelon-form | 1 + Lang/Maxima/Remove-duplicate-elements | 1 + Lang/Maxima/Repeat-a-string | 1 + Lang/Maxima/Resistor-mesh | 1 + Lang/Maxima/Return-multiple-values | 1 + Lang/Maxima/Reverse-a-string | 1 + Lang/Maxima/Roots-of-a-function | 1 + Lang/Maxima/Roots-of-a-quadratic-function | 1 + Lang/Maxima/Roots-of-unity | 1 + Lang/Maxima/Rot-13 | 1 + Lang/Maxima/Run-length-encoding | 1 + Lang/Maxima/Runtime-evaluation | 1 + Lang/Maxima/Sequence-of-non-squares | 1 + Lang/Maxima/Set | 1 + Lang/Mercury/Binary-digits | 1 + Lang/Mercury/Environment-variables | 1 + Lang/Mercury/OpenGL | 1 + Lang/Mercury/Order-two-numerical-lists | 1 + Lang/Mercury/Partial-function-application | 1 + Lang/Mercury/Price-fraction | 1 + Lang/Mercury/Real-constants-and-functions | 1 + Lang/Mercury/Repeat-a-string | 1 + Lang/Mercury/Return-multiple-values | 1 + Lang/Mercury/SEDOLs | 1 + Lang/Metafont/Copy-a-string | 1 + Lang/Metafont/Dragon-curve | 1 + Lang/Metafont/Nth-root | 1 + Lang/Metafont/Pascals-triangle | 1 + Lang/Metafont/Random-numbers | 1 + Lang/Metafont/Real-constants-and-functions | 1 + .../Runtime-evaluation-In-an-environment | 1 + Lang/Mirah/Copy-a-string | 1 + Lang/Mirah/Palindrome-detection | 1 + Lang/Mirah/Random-numbers | 1 + Lang/Mirah/Repeat-a-string | 1 + Lang/Mirah/Reverse-a-string | 1 + Lang/Mirah/Rot-13 | 1 + .../Guess-the-number-With-feedback--player- | 1 + .../Guess-the-number-With-feedback-player | 1 - Lang/Modula-3/Binary-digits | 1 + Lang/Modula-3/Copy-a-string | 1 + Lang/Modula-3/Named-parameters | 1 + Lang/Modula-3/Non-decimal-radices-Output | 1 + Lang/Modula-3/Null-object | 1 + .../One-dimensional-cellular-automata | 1 + Lang/Modula-3/Palindrome-detection | 1 + Lang/Modula-3/Pointers-and-references | 1 + Lang/Modula-3/Pythagorean-triples | 1 + Lang/Modula-3/Random-numbers | 1 + Lang/Modula-3/Real-constants-and-functions | 1 + Lang/Modula-3/Reverse-a-string | 1 + Lang/Modula-3/Roots-of-a-quadratic-function | 1 + Lang/Modula-3/Rot-13 | 1 + Lang/Modula-3/SEDOLs | 1 + Lang/Modula-3/Sequence-of-non-squares | 1 + Lang/NSIS/Environment-variables | 1 + Lang/Nemerle/Copy-a-string | 1 + Lang/Nemerle/Named-parameters | 1 + Lang/Nemerle/Optional-parameters | 1 + Lang/Nemerle/Palindrome-detection | 1 + Lang/Nemerle/Partial-function-application | 1 + Lang/Nemerle/Remove-duplicate-elements | 1 + Lang/Nemerle/Reverse-a-string | 1 + Lang/NetLogo/Pick-random-element | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/NetRexx/Binary-digits | 1 + Lang/NetRexx/Copy-a-string | 1 + Lang/NetRexx/Environment-variables | 1 + Lang/NetRexx/Non-decimal-radices-Convert | 1 + Lang/NetRexx/Non-decimal-radices-Output | 1 + Lang/NetRexx/Nth-root | 1 + Lang/NetRexx/Null-object | 1 + Lang/NetRexx/Palindrome-detection | 1 + Lang/NetRexx/Pangram-checker | 1 + Lang/NetRexx/Parametrized-SQL-statement | 1 + Lang/NetRexx/Parsing-RPN-calculator-algorithm | 1 + Lang/NetRexx/Pick-random-element | 1 + Lang/NetRexx/Polymorphic-copy | 1 + Lang/NetRexx/Polymorphism | 1 + Lang/NetRexx/Pragmatic-directives | 1 + Lang/NetRexx/Primality-by-trial-division | 1 + Lang/NetRexx/Program-name | 1 + Lang/NetRexx/Program-termination | 1 + Lang/NetRexx/Queue-Definition | 1 + Lang/NetRexx/Queue-Usage | 1 + Lang/NetRexx/Random-number-generator--device- | 1 + Lang/NetRexx/Random-numbers | 1 + Lang/NetRexx/Range-expansion | 1 + Lang/NetRexx/Range-extraction | 1 + Lang/NetRexx/Read-a-file-line-by-line | 1 + Lang/NetRexx/Read-a-specific-line-from-a-file | 1 + Lang/NetRexx/Read-entire-file | 1 + Lang/NetRexx/Real-constants-and-functions | 1 + Lang/NetRexx/Regular-expressions | 1 + Lang/NetRexx/Remove-duplicate-elements | 1 + Lang/NetRexx/Repeat-a-string | 1 + Lang/NetRexx/Return-multiple-values | 1 + Lang/NetRexx/Reverse-a-string | 1 + Lang/NetRexx/Roman-numerals-Decode | 1 + Lang/NetRexx/Rot-13 | 1 + Lang/NetRexx/Semordnilap | 1 + Lang/NewLISP/Copy-a-string | 1 + Lang/NewLISP/Environment-variables | 1 + Lang/NewLISP/Random-numbers | 1 + Lang/NewLISP/Read-a-file-line-by-line | 1 + Lang/NewLISP/Read-entire-file | 1 + Lang/NewLISP/Remove-duplicate-elements | 1 + Lang/NewLISP/Rename-a-file | 1 + Lang/NewLISP/Repeat-a-string | 1 + Lang/NewLISP/Reverse-a-string | 1 + Lang/NewLISP/Send-email | 1 + Lang/Nial/One-dimensional-cellular-automata | 1 + Lang/Nial/Pascals-triangle | 1 + Lang/Nial/Remove-duplicate-elements | 1 + Lang/Nial/Reverse-a-string | 1 + Lang/Nimrod/One-dimensional-cellular-automata | 1 + Lang/Nimrod/Program-termination | 1 + Lang/Nimrod/Read-entire-file | 1 + Lang/Nimrod/Reverse-a-string | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/OCaml/Binary-digits | 1 + Lang/OCaml/Brownian-tree | 1 + Lang/OCaml/Copy-a-string | 1 + Lang/OCaml/Dragon-curve | 1 + Lang/OCaml/Environment-variables | 1 + Lang/OCaml/N-queens-problem | 1 + Lang/OCaml/Named-parameters | 1 + Lang/OCaml/Non-continuous-subsequences | 1 + Lang/OCaml/Non-decimal-radices-Convert | 1 + Lang/OCaml/Non-decimal-radices-Input | 1 + Lang/OCaml/Non-decimal-radices-Output | 1 + Lang/OCaml/Nth-root | 1 + Lang/OCaml/Null-object | 1 + Lang/OCaml/Number-names | 1 + Lang/OCaml/Number-reversal-game | 1 + Lang/OCaml/Numerical-integration | 1 + ...ical-integration-Gauss-Legendre-Quadrature | 1 + Lang/OCaml/Object-serialization | 1 + Lang/OCaml/One-dimensional-cellular-automata | 1 + Lang/OCaml/One-of-n-lines-in-a-file | 1 + Lang/OCaml/OpenGL | 1 + Lang/OCaml/Optional-parameters | 1 + Lang/OCaml/Order-two-numerical-lists | 1 + Lang/OCaml/Palindrome-detection | 1 + Lang/OCaml/Pangram-checker | 1 + Lang/OCaml/Parametric-polymorphism | 1 + Lang/OCaml/Partial-function-application | 1 + Lang/OCaml/Pascals-triangle | 1 + Lang/OCaml/Pattern-matching | 1 + .../Percentage-difference-between-images | 1 + Lang/OCaml/Perfect-numbers | 1 + Lang/OCaml/Permutations | 1 + Lang/OCaml/Pick-random-element | 1 + Lang/OCaml/Playing-cards | 1 + Lang/OCaml/Plot-coordinate-pairs | 1 + Lang/OCaml/Pointers-and-references | 1 + Lang/OCaml/Polymorphic-copy | 1 + Lang/OCaml/Polymorphism | 1 + Lang/OCaml/Polynomial-long-division | 1 + Lang/OCaml/Power-set | 1 + Lang/OCaml/Price-fraction | 1 + Lang/OCaml/Primality-by-trial-division | 1 + Lang/OCaml/Prime-decomposition | 1 + Lang/OCaml/Priority-queue | 1 + Lang/OCaml/Probabilistic-choice | 1 + Lang/OCaml/Problem-of-Apollonius | 1 + Lang/OCaml/Program-name | 1 + Lang/OCaml/Program-termination | 1 + Lang/OCaml/Pythagorean-triples | 1 + Lang/OCaml/Quaternion-type | 1 + Lang/OCaml/Queue-Definition | 1 + Lang/OCaml/Queue-Usage | 1 + Lang/OCaml/Random-number-generator--device- | 1 + Lang/OCaml/Random-numbers | 1 + Lang/OCaml/Range-expansion | 1 + Lang/OCaml/Range-extraction | 1 + Lang/OCaml/Ray-casting-algorithm | 1 + Lang/OCaml/Read-a-configuration-file | 1 + Lang/OCaml/Read-a-file-line-by-line | 1 + Lang/OCaml/Read-a-specific-line-from-a-file | 1 + Lang/OCaml/Read-entire-file | 1 + Lang/OCaml/Real-constants-and-functions | 1 + Lang/OCaml/Record-sound | 1 + Lang/OCaml/Reduced-row-echelon-form | 1 + Lang/OCaml/Regular-expressions | 1 + Lang/OCaml/Remove-duplicate-elements | 1 + Lang/OCaml/Remove-lines-from-a-file | 1 + Lang/OCaml/Rename-a-file | 1 + Lang/OCaml/Repeat-a-string | 1 + Lang/OCaml/Return-multiple-values | 1 + Lang/OCaml/Reverse-a-string | 1 + Lang/OCaml/Rock-paper-scissors | 1 + Lang/OCaml/Roman-numerals-Decode | 1 + Lang/OCaml/Roman-numerals-Encode | 1 + Lang/OCaml/Roots-of-a-function | 1 + Lang/OCaml/Roots-of-a-quadratic-function | 1 + Lang/OCaml/Roots-of-unity | 1 + Lang/OCaml/Rosetta-Code-Count-examples | 1 + Lang/OCaml/Rosetta-Code-Fix-code-tags | 1 + Lang/OCaml/Rot-13 | 1 + Lang/OCaml/Run-length-encoding | 1 + Lang/OCaml/S-Expressions | 1 + Lang/OCaml/SEDOLs | 1 + Lang/OCaml/Same-Fringe | 1 + Lang/OCaml/Secure-temporary-file | 1 + Lang/OCaml/Semordnilap | 1 + Lang/OCaml/Send-email | 1 + Lang/OCaml/Sequence-of-non-squares | 1 + Lang/OCaml/Set | 1 + Lang/OCaml/Set-consolidation | 1 + Lang/Oberon-2/Copy-a-string | 1 + Lang/Oberon-2/Range-expansion | 1 + Lang/Oberon-2/Range-extraction | 1 + Lang/Objeck/Binary-digits | 1 + Lang/Objeck/Copy-a-string | 1 + Lang/Objeck/N-queens-problem | 1 + Lang/Objeck/Null-object | 1 + Lang/Objeck/Number-names | 1 + Lang/Objeck/Object-serialization | 1 + Lang/Objeck/Palindrome-detection | 1 + Lang/Objeck/Pangram-checker | 1 + Lang/Objeck/Parametrized-SQL-statement | 1 + Lang/Objeck/Parsing-RPN-calculator-algorithm | 1 + Lang/Objeck/Perfect-numbers | 1 + Lang/Objeck/Pick-random-element | 1 + Lang/Objeck/Polymorphism | 1 + Lang/Objeck/Primality-by-trial-division | 1 + Lang/Objeck/Program-termination | 1 + Lang/Objeck/Queue-Usage | 1 + Lang/Objeck/RIPEMD-160 | 1 + Lang/Objeck/Random-numbers | 1 + Lang/Objeck/Read-a-file-line-by-line | 1 + Lang/Objeck/Read-entire-file | 1 + Lang/Objeck/Real-constants-and-functions | 1 + Lang/Objeck/Reduced-row-echelon-form | 1 + Lang/Objeck/Regular-expressions | 1 + Lang/Objeck/Remove-duplicate-elements | 1 + Lang/Objeck/Rename-a-file | 1 + Lang/Objeck/Repeat-a-string | 1 + Lang/Objeck/Reverse-a-string | 1 + Lang/Objeck/Roman-numerals-Encode | 1 + Lang/Objeck/Roots-of-a-function | 1 + Lang/Objeck/Rot-13 | 1 + Lang/Objective-C/Copy-a-string | 1 + Lang/Objective-C/Environment-variables | 1 + .../Guess-the-number-With-feedback--player- | 1 + .../Guess-the-number-With-feedback-player | 1 - Lang/Objective-C/Named-parameters | 1 + Lang/Objective-C/Null-object | 1 + Lang/Objective-C/Object-serialization | 1 + Lang/Objective-C/Optional-parameters | 1 + Lang/Objective-C/Polymorphic-copy | 1 + Lang/Objective-C/Polymorphism | 1 + Lang/Objective-C/Power-set | 1 + Lang/Objective-C/Priority-queue | 1 + Lang/Objective-C/Program-name | 1 + Lang/Objective-C/Read-a-file-line-by-line | 1 + Lang/Objective-C/Read-entire-file | 1 + Lang/Objective-C/Regular-expressions | 1 + Lang/Objective-C/Remove-duplicate-elements | 1 + Lang/Objective-C/Rename-a-file | 1 + Lang/Objective-C/Repeat-a-string | 1 + .../Respond-to-an-unknown-method-call | 1 + Lang/Objective-C/Reverse-a-string | 1 + Lang/Objective-C/Send-an-unknown-method-call | 1 + Lang/Objective-C/Set | 1 + Lang/Octave/Brownian-tree | 1 + Lang/Octave/Copy-a-string | 1 + Lang/Octave/Nth-root | 1 + Lang/Octave/Palindrome-detection | 1 + Lang/Octave/Pascals-triangle | 1 + Lang/Octave/Plot-coordinate-pairs | 1 + Lang/Octave/Polynomial-long-division | 1 + Lang/Octave/Polynomial-regression | 1 + Lang/Octave/Primality-by-trial-division | 1 + Lang/Octave/Prime-decomposition | 1 + Lang/Octave/Program-name | 1 + Lang/Octave/Random-numbers | 1 + Lang/Octave/Real-constants-and-functions | 1 + Lang/Octave/Reduced-row-echelon-form | 1 + Lang/Octave/Remove-duplicate-elements | 1 + Lang/Octave/Rename-a-file | 1 + Lang/Octave/Reverse-a-string | 1 + Lang/Octave/Roots-of-a-function | 1 + Lang/Octave/Roots-of-unity | 1 + .../Runtime-evaluation-In-an-environment | 1 + Lang/Octave/Secure-temporary-file | 1 + Lang/OpenEdge-Progress/Repeat-a-string | 1 + Lang/OpenEdge-Progress/Reverse-a-string | 1 + Lang/OpenEdge-Progress/Roman-numerals-Encode | 1 + Lang/Order/Partial-function-application | 1 + Lang/Order/Program-name | 1 + Lang/OxygenBasic/Binary-digits | 1 + Lang/OxygenBasic/Copy-a-string | 1 + Lang/OxygenBasic/OpenGL | 1 + Lang/OxygenBasic/Parallel-calculations | 1 + Lang/OxygenBasic/Polymorphic-copy | 1 + Lang/OxygenBasic/Polymorphism | 1 + Lang/OxygenBasic/Queue-Definition | 1 + Lang/OxygenBasic/Range-extraction | 1 + Lang/OxygenBasic/Rate-counter | 1 + Lang/OxygenBasic/Read-a-file-line-by-line | 1 + Lang/OxygenBasic/Repeat-a-string | 1 + Lang/OxygenBasic/Return-multiple-values | 1 + Lang/OxygenBasic/Reverse-a-string | 1 + Lang/OxygenBasic/Runtime-evaluation | 1 + Lang/Oxygene/Regular-expressions | 1 + .../Arbitrary-precision-integers--included- | 1 + Lang/Oz/Arbitrary-precision-integers-included | 1 - Lang/Oz/Environment-variables | 1 + Lang/Oz/N-queens-problem | 1 + Lang/Oz/Named-parameters | 1 + Lang/Oz/Non-continuous-subsequences | 1 + Lang/Oz/Non-decimal-radices-Input | 1 + Lang/Oz/Nth-root | 1 + Lang/Oz/Null-object | 1 + Lang/Oz/Number-reversal-game | 1 + Lang/Oz/One-dimensional-cellular-automata | 1 + Lang/Oz/Optional-parameters | 1 + Lang/Oz/Palindrome-detection | 1 + Lang/Oz/Pangram-checker | 1 + Lang/Oz/Pascals-triangle | 1 + Lang/Oz/Pascals-triangle-Puzzle | 1 + Lang/Oz/Pattern-matching | 1 + Lang/Oz/Perfect-numbers | 1 + Lang/Oz/Polymorphic-copy | 1 + Lang/Oz/Polymorphism | 1 + Lang/Oz/Power-set | 1 + Lang/Oz/Price-fraction | 1 + Lang/Oz/Program-termination | 1 + Lang/Oz/Queue-Definition | 1 + Lang/Oz/Queue-Usage | 1 + Lang/Oz/Range-expansion | 1 + Lang/Oz/Range-extraction | 1 + Lang/Oz/Read-entire-file | 1 + Lang/Oz/Real-constants-and-functions | 1 + Lang/Oz/Regular-expressions | 1 + Lang/Oz/Remove-duplicate-elements | 1 + Lang/Oz/Rendezvous | 1 + Lang/Oz/Repeat-a-string | 1 + Lang/Oz/Respond-to-an-unknown-method-call | 1 + Lang/Oz/Reverse-a-string | 1 + Lang/Oz/Roman-numerals-Encode | 1 + Lang/Oz/Rosetta-Code-Count-examples | 1 + Lang/Oz/Rosetta-Code-Find-unimplemented-tasks | 1 + .../Rosetta-Code-Rank-languages-by-popularity | 1 + Lang/Oz/Rot-13 | 1 + Lang/Oz/Run-length-encoding | 1 + Lang/Oz/Runtime-evaluation | 1 + Lang/Oz/Runtime-evaluation-In-an-environment | 1 + Lang/Oz/Sequence-of-non-squares | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/PARI-GP/Binary-digits | 1 + Lang/PARI-GP/Catalan-numbers | 1 + Lang/PARI-GP/Copy-a-string | 1 + Lang/PARI-GP/Environment-variables | 1 + .../Guess-the-number-With-feedback--player- | 1 + .../Guess-the-number-With-feedback-player | 1 - Lang/PARI-GP/Non-decimal-radices-Convert | 1 + Lang/PARI-GP/Non-decimal-radices-Input | 1 + Lang/PARI-GP/Non-decimal-radices-Output | 1 + Lang/PARI-GP/Nth-root | 1 + Lang/PARI-GP/Null-object | 1 + Lang/PARI-GP/Number-names | 1 + Lang/PARI-GP/Number-reversal-game | 1 + Lang/PARI-GP/Numerical-integration | 1 + ...ical-integration-Gauss-Legendre-Quadrature | 1 + .../PARI-GP/One-dimensional-cellular-automata | 1 + Lang/PARI-GP/Optional-parameters | 1 + Lang/PARI-GP/Order-two-numerical-lists | 1 + Lang/PARI-GP/Palindrome-detection | 1 + Lang/PARI-GP/Pangram-checker | 1 + Lang/PARI-GP/Parallel-calculations | 1 + Lang/PARI-GP/Pascals-triangle | 1 + Lang/PARI-GP/Pascals-triangle-Puzzle | 1 + Lang/PARI-GP/Perfect-numbers | 1 + Lang/PARI-GP/Permutations | 1 + Lang/PARI-GP/Permutations-Derangements | 1 + Lang/PARI-GP/Pick-random-element | 1 + Lang/PARI-GP/Playing-cards | 1 + Lang/PARI-GP/Plot-coordinate-pairs | 1 + Lang/PARI-GP/Pointers-and-references | 1 + Lang/PARI-GP/Polynomial-long-division | 1 + Lang/PARI-GP/Polynomial-regression | 1 + Lang/PARI-GP/Power-set | 1 + Lang/PARI-GP/Price-fraction | 1 + Lang/PARI-GP/Primality-by-trial-division | 1 + Lang/PARI-GP/Prime-decomposition | 1 + Lang/PARI-GP/Probabilistic-choice | 1 + Lang/PARI-GP/Program-termination | 1 + Lang/PARI-GP/Pythagorean-triples | 1 + Lang/PARI-GP/QR-decomposition | 1 + Lang/PARI-GP/Quaternion-type | 1 + .../Random-number-generator--included- | 1 + Lang/PARI-GP/Random-numbers | 1 + Lang/PARI-GP/Rate-counter | 1 + Lang/PARI-GP/Read-a-file-line-by-line | 1 + Lang/PARI-GP/Read-entire-file | 1 + Lang/PARI-GP/Real-constants-and-functions | 1 + Lang/PARI-GP/Reduced-row-echelon-form | 1 + Lang/PARI-GP/Remove-duplicate-elements | 1 + Lang/PARI-GP/Rename-a-file | 1 + Lang/PARI-GP/Repeat-a-string | 1 + Lang/PARI-GP/Return-multiple-values | 1 + Lang/PARI-GP/Reverse-a-string | 1 + Lang/PARI-GP/Rock-paper-scissors | 1 + Lang/PARI-GP/Roman-numerals-Decode | 1 + Lang/PARI-GP/Roman-numerals-Encode | 1 + Lang/PARI-GP/Roots-of-a-function | 1 + Lang/PARI-GP/Roots-of-a-quadratic-function | 1 + Lang/PARI-GP/Roots-of-unity | 1 + Lang/PARI-GP/Rot-13 | 1 + Lang/PARI-GP/Run-length-encoding | 1 + .../Runtime-evaluation-In-an-environment | 1 + Lang/PARI-GP/Self-describing-numbers | 1 + Lang/PARI-GP/Send-an-unknown-method-call | 1 + Lang/PARI-GP/Sequence-of-non-squares | 1 + Lang/PARI-GP/Set | 1 + Lang/PARI-GP/Set-consolidation | 1 + .../Arbitrary-precision-integers--included- | 1 + .../PHP/Arbitrary-precision-integers-included | 1 - Lang/PHP/Binary-digits | 1 + Lang/PHP/Calendar---for-real-programmers | 1 + Lang/PHP/Calendar-for-real-programmers | 1 - Lang/PHP/Catalan-numbers | 1 + Lang/PHP/Copy-a-string | 1 + Lang/PHP/Environment-variables | 1 + Lang/PHP/N-queens-problem | 1 + Lang/PHP/Non-decimal-radices-Convert | 1 + Lang/PHP/Non-decimal-radices-Input | 1 + Lang/PHP/Non-decimal-radices-Output | 1 + Lang/PHP/Nth-root | 1 + Lang/PHP/Null-object | 1 + Lang/PHP/Number-names | 1 + Lang/PHP/Object-serialization | 1 + Lang/PHP/Palindrome-detection | 1 + Lang/PHP/Pangram-checker | 1 + Lang/PHP/Parametrized-SQL-statement | 1 + Lang/PHP/Parsing-RPN-calculator-algorithm | 1 + Lang/PHP/Pascals-triangle | 1 + Lang/PHP/Perfect-numbers | 1 + Lang/PHP/Pick-random-element | 1 + Lang/PHP/Pig-the-dice-game | 1 + Lang/PHP/Playing-cards | 1 + Lang/PHP/Pointers-and-references | 1 + Lang/PHP/Polymorphic-copy | 1 + Lang/PHP/Polymorphism | 1 + Lang/PHP/Power-set | 1 + Lang/PHP/Primality-by-trial-division | 1 + Lang/PHP/Priority-queue | 1 + Lang/PHP/Program-name | 1 + Lang/PHP/Program-termination | 1 + Lang/PHP/Queue-Definition | 1 + Lang/PHP/Queue-Usage | 1 + Lang/PHP/Random-numbers | 1 + Lang/PHP/Range-expansion | 1 + Lang/PHP/Read-a-file-line-by-line | 1 + Lang/PHP/Read-entire-file | 1 + Lang/PHP/Real-constants-and-functions | 1 + Lang/PHP/Reduced-row-echelon-form | 1 + Lang/PHP/Regular-expressions | 1 + Lang/PHP/Remove-duplicate-elements | 1 + Lang/PHP/Rename-a-file | 1 + Lang/PHP/Repeat-a-string | 1 + Lang/PHP/Respond-to-an-unknown-method-call | 1 + Lang/PHP/Return-multiple-values | 1 + Lang/PHP/Reverse-a-string | 1 + Lang/PHP/Roman-numerals-Decode | 1 + Lang/PHP/Roman-numerals-Encode | 1 + Lang/PHP/Rot-13 | 1 + Lang/PHP/Run-length-encoding | 1 + Lang/PHP/Runtime-evaluation | 1 + Lang/PHP/Runtime-evaluation-In-an-environment | 1 + Lang/PHP/SEDOLs | 1 + Lang/PHP/Secure-temporary-file | 1 + Lang/PHP/Semordnilap | 1 + Lang/PHP/Send-an-unknown-method-call | 1 + Lang/PHP/Send-email | 1 + Lang/PL-I/Binary-digits | 1 + Lang/PL-I/Catalan-numbers | 1 + Lang/PL-I/Copy-a-string | 1 + Lang/PL-I/Non-decimal-radices-Convert | 1 + Lang/PL-I/Non-decimal-radices-Input | 1 + Lang/PL-I/Non-decimal-radices-Output | 1 + Lang/PL-I/Nth-root | 1 + Lang/PL-I/Null-object | 1 + Lang/PL-I/Number-names | 1 + Lang/PL-I/Number-reversal-game | 1 + Lang/PL-I/Numerical-integration | 1 + Lang/PL-I/Palindrome-detection | 1 + Lang/PL-I/Pangram-checker | 1 + Lang/PL-I/Parsing-RPN-calculator-algorithm | 1 + Lang/PL-I/Parsing-RPN-to-infix-conversion | 1 + Lang/PL-I/Parsing-Shunting-yard-algorithm | 1 + Lang/PL-I/Pascals-triangle | 1 + Lang/PL-I/Perfect-numbers | 1 + Lang/PL-I/Pick-random-element | 1 + Lang/PL-I/Price-fraction | 1 + Lang/PL-I/Primality-by-trial-division | 1 + Lang/PL-I/Prime-decomposition | 1 + Lang/PL-I/Program-termination | 1 + Lang/PL-I/Queue-Definition | 1 + Lang/PL-I/Queue-Usage | 1 + Lang/PL-I/Random-number-generator--included- | 1 + Lang/PL-I/Random-numbers | 1 + Lang/PL-I/Range-expansion | 1 + Lang/PL-I/Range-extraction | 1 + Lang/PL-I/Read-a-configuration-file | 1 + Lang/PL-I/Read-a-file-line-by-line | 1 + Lang/PL-I/Read-a-specific-line-from-a-file | 1 + Lang/PL-I/Read-entire-file | 1 + Lang/PL-I/Real-constants-and-functions | 1 + Lang/PL-I/Remove-duplicate-elements | 1 + Lang/PL-I/Repeat-a-string | 1 + Lang/PL-I/Return-multiple-values | 1 + Lang/PL-I/Reverse-a-string | 1 + Lang/PL-I/Roman-numerals-Decode | 1 + Lang/PL-I/Roman-numerals-Encode | 1 + Lang/PL-I/Roots-of-a-function | 1 + Lang/PL-I/Roots-of-a-quadratic-function | 1 + Lang/PL-I/Roots-of-unity | 1 + Lang/PL-I/Rot-13 | 1 + Lang/PL-I/Run-length-encoding | 1 + Lang/PL-I/SEDOLs | 1 + Lang/PL-I/Semordnilap | 1 + Lang/PL-I/Sequence-of-non-squares | 1 + .../PL-SQL/Random-number-generator--included- | 1 + Lang/PL-SQL/Random-numbers | 1 + Lang/PL-SQL/Roman-numerals-Decode | 1 + Lang/PL-SQL/Roman-numerals-Encode | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Pascal/Catalan-numbers | 1 + Lang/Pascal/Copy-a-string | 1 + Lang/Pascal/Dragon-curve | 1 + .../Guess-the-number-With-feedback--player- | 1 + .../Guess-the-number-With-feedback-player | 1 - Lang/Pascal/N-queens-problem | 1 + Lang/Pascal/Non-decimal-radices-Convert | 1 + Lang/Pascal/Number-names | 1 + Lang/Pascal/Numerical-integration | 1 + Lang/Pascal/One-of-n-lines-in-a-file | 1 + Lang/Pascal/OpenGL | 1 + Lang/Pascal/Palindrome-detection | 1 + Lang/Pascal/Pascals-triangle | 1 + Lang/Pascal/Perfect-numbers | 1 + Lang/Pascal/Permutations | 1 + Lang/Pascal/Pick-random-element | 1 + Lang/Pascal/Price-fraction | 1 + Lang/Pascal/Primality-by-trial-division | 1 + Lang/Pascal/Prime-decomposition | 1 + Lang/Pascal/Program-name | 1 + Lang/Pascal/Pythagorean-triples | 1 + Lang/Pascal/Queue-Definition | 1 + Lang/Pascal/Random-number-generator--device- | 1 + Lang/Pascal/Read-a-configuration-file | 1 + Lang/Pascal/Read-a-specific-line-from-a-file | 1 + Lang/Pascal/Regular-expressions | 1 + Lang/Pascal/Remove-duplicate-elements | 1 + Lang/Pascal/Rename-a-file | 1 + Lang/Pascal/Reverse-a-string | 1 + Lang/Pascal/Roots-of-a-function | 1 + Lang/Pascal/Roots-of-a-quadratic-function | 1 + Lang/Pascal/Roots-of-unity | 1 + Lang/Pascal/Rot-13 | 1 + Lang/Pascal/Run-length-encoding | 1 + Lang/Pascal/SEDOLs | 1 + Lang/Pascal/Secure-temporary-file | 1 + Lang/Pascal/Self-describing-numbers | 1 + Lang/Pascal/Sequence-of-non-squares | 1 + Lang/Pascal/Set | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Perl-6/Binary-digits | 1 + Lang/Perl-6/Calendar---for-real-programmers | 1 + Lang/Perl-6/Calendar-for-real-programmers | 1 - Lang/Perl-6/Catalan-numbers | 1 + Lang/Perl-6/Copy-a-string | 1 + Lang/Perl-6/Dragon-curve | 1 + Lang/Perl-6/Environment-variables | 1 + .../Guess-the-number-With-feedback--player- | 1 + .../Guess-the-number-With-feedback-player | 1 - Lang/Perl-6/N-queens-problem | 1 + Lang/Perl-6/Named-parameters | 1 + Lang/Perl-6/Nautical-bell | 1 + Lang/Perl-6/Non-continuous-subsequences | 1 + Lang/Perl-6/Non-decimal-radices-Convert | 1 + Lang/Perl-6/Non-decimal-radices-Input | 1 + Lang/Perl-6/Non-decimal-radices-Output | 1 + Lang/Perl-6/Nth-root | 1 + Lang/Perl-6/Null-object | 1 + Lang/Perl-6/Number-names | 1 + Lang/Perl-6/Number-reversal-game | 1 + Lang/Perl-6/Numeric-error-propagation | 1 + Lang/Perl-6/Numerical-integration | 1 + ...ical-integration-Gauss-Legendre-Quadrature | 1 + Lang/Perl-6/One-dimensional-cellular-automata | 1 + Lang/Perl-6/One-of-n-lines-in-a-file | 1 + Lang/Perl-6/Optional-parameters | 1 + Lang/Perl-6/Order-two-numerical-lists | 1 + Lang/Perl-6/Ordered-Partitions | 1 + Lang/Perl-6/Palindrome-detection | 1 + Lang/Perl-6/Pangram-checker | 1 + Lang/Perl-6/Parallel-calculations | 1 + Lang/Perl-6/Parametric-polymorphism | 1 + Lang/Perl-6/Parsing-RPN-calculator-algorithm | 1 + Lang/Perl-6/Parsing-RPN-to-infix-conversion | 1 + Lang/Perl-6/Partial-function-application | 1 + Lang/Perl-6/Pascals-triangle | 1 + Lang/Perl-6/Pattern-matching | 1 + Lang/Perl-6/Perfect-numbers | 1 + Lang/Perl-6/Permutations | 1 + Lang/Perl-6/Permutations-Derangements | 1 + Lang/Perl-6/Permutations-by-swapping | 1 + Lang/Perl-6/Pick-random-element | 1 + Lang/Perl-6/Pig-the-dice-game | 1 + Lang/Perl-6/Playing-cards | 1 + Lang/Perl-6/Plot-coordinate-pairs | 1 + Lang/Perl-6/Pointers-and-references | 1 + Lang/Perl-6/Polymorphic-copy | 1 + Lang/Perl-6/Polymorphism | 1 + Lang/Perl-6/Polynomial-long-division | 1 + Lang/Perl-6/Power-set | 1 + Lang/Perl-6/Pragmatic-directives | 1 + Lang/Perl-6/Price-fraction | 1 + Lang/Perl-6/Primality-by-trial-division | 1 + Lang/Perl-6/Prime-decomposition | 1 + Lang/Perl-6/Priority-queue | 1 + Lang/Perl-6/Probabilistic-choice | 1 + Lang/Perl-6/Problem-of-Apollonius | 1 + Lang/Perl-6/Program-name | 1 + Lang/Perl-6/Program-termination | 1 + Lang/Perl-6/Pythagorean-triples | 1 + Lang/Perl-6/Quaternion-type | 1 + Lang/Perl-6/Queue-Definition | 1 + Lang/Perl-6/Queue-Usage | 1 + Lang/Perl-6/RIPEMD-160 | 1 + Lang/Perl-6/Random-number-generator--device- | 1 + Lang/Perl-6/Random-numbers | 1 + Lang/Perl-6/Range-expansion | 1 + Lang/Perl-6/Range-extraction | 1 + Lang/Perl-6/Rate-counter | 1 + Lang/Perl-6/Ray-casting-algorithm | 1 + Lang/Perl-6/Read-a-configuration-file | 1 + Lang/Perl-6/Read-a-file-line-by-line | 1 + Lang/Perl-6/Read-a-specific-line-from-a-file | 1 + Lang/Perl-6/Read-entire-file | 1 + Lang/Perl-6/Real-constants-and-functions | 1 + Lang/Perl-6/Reduced-row-echelon-form | 1 + Lang/Perl-6/Regular-expressions | 1 + Lang/Perl-6/Remove-duplicate-elements | 1 + Lang/Perl-6/Remove-lines-from-a-file | 1 + Lang/Perl-6/Rename-a-file | 1 + Lang/Perl-6/Repeat-a-string | 1 + Lang/Perl-6/Resistor-mesh | 1 + Lang/Perl-6/Respond-to-an-unknown-method-call | 1 + Lang/Perl-6/Return-multiple-values | 1 + Lang/Perl-6/Reverse-a-string | 1 + Lang/Perl-6/Rock-paper-scissors | 1 + Lang/Perl-6/Roman-numerals-Decode | 1 + Lang/Perl-6/Roman-numerals-Encode | 1 + Lang/Perl-6/Roots-of-a-function | 1 + Lang/Perl-6/Roots-of-a-quadratic-function | 1 + Lang/Perl-6/Roots-of-unity | 1 + .../Rosetta-Code-Rank-languages-by-popularity | 1 + Lang/Perl-6/Rot-13 | 1 + Lang/Perl-6/Run-length-encoding | 1 + Lang/Perl-6/Runtime-evaluation | 1 + .../Runtime-evaluation-In-an-environment | 1 + Lang/Perl-6/S-Expressions | 1 + Lang/Perl-6/SEDOLs | 1 + Lang/Perl-6/Same-Fringe | 1 + Lang/Perl-6/Scope-Function-names-and-labels | 1 + Lang/Perl-6/Scope-modifiers | 1 + Lang/Perl-6/Self-describing-numbers | 1 + Lang/Perl-6/Self-referential-sequence | 1 + Lang/Perl-6/Semordnilap | 1 + Lang/Perl-6/Send-an-unknown-method-call | 1 + Lang/Perl-6/Sequence-of-non-squares | 1 + Lang/Perl-6/Set | 1 + Lang/Perl-6/Set-consolidation | 1 + Lang/Perl-6/Set-of-real-numbers | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Perl/Binary-digits | 1 + Lang/Perl/Brownian-tree | 1 + Lang/Perl/Calendar---for-real-programmers | 1 + Lang/Perl/Calendar-for-real-programmers | 1 - Lang/Perl/Catalan-numbers | 1 + Lang/Perl/Copy-a-string | 1 + Lang/Perl/Environment-variables | 1 + Lang/Perl/Execute-a-Markov-algorithm | 1 + .../Guess-the-number-With-feedback--player- | 1 + .../Guess-the-number-With-feedback-player | 1 - Lang/Perl/N-queens-problem | 1 + Lang/Perl/Named-parameters | 1 + Lang/Perl/Non-continuous-subsequences | 1 + Lang/Perl/Non-decimal-radices-Convert | 1 + Lang/Perl/Non-decimal-radices-Input | 1 + Lang/Perl/Non-decimal-radices-Output | 1 + Lang/Perl/Nth-root | 1 + Lang/Perl/Null-object | 1 + Lang/Perl/Number-names | 1 + Lang/Perl/Number-reversal-game | 1 + Lang/Perl/Numeric-error-propagation | 1 + Lang/Perl/Object-serialization | 1 + Lang/Perl/One-dimensional-cellular-automata | 1 + Lang/Perl/OpenGL | 1 + Lang/Perl/Optional-parameters | 1 + Lang/Perl/Order-two-numerical-lists | 1 + Lang/Perl/Ordered-Partitions | 1 + Lang/Perl/Palindrome-detection | 1 + Lang/Perl/Pangram-checker | 1 + Lang/Perl/Parametrized-SQL-statement | 1 + Lang/Perl/Parsing-RPN-calculator-algorithm | 1 + Lang/Perl/Parsing-RPN-to-infix-conversion | 1 + Lang/Perl/Partial-function-application | 1 + Lang/Perl/Pascals-triangle | 1 + Lang/Perl/Perfect-numbers | 1 + Lang/Perl/Permutations | 1 + Lang/Perl/Permutations-Derangements | 1 + Lang/Perl/Pick-random-element | 1 + Lang/Perl/Playing-cards | 1 + Lang/Perl/Plot-coordinate-pairs | 1 + Lang/Perl/Pointers-and-references | 1 + Lang/Perl/Polymorphic-copy | 1 + Lang/Perl/Polymorphism | 1 + Lang/Perl/Polynomial-long-division | 1 + Lang/Perl/Power-set | 1 + Lang/Perl/Pragmatic-directives | 1 + Lang/Perl/Price-fraction | 1 + Lang/Perl/Primality-by-trial-division | 1 + Lang/Perl/Prime-decomposition | 1 + Lang/Perl/Priority-queue | 1 + Lang/Perl/Probabilistic-choice | 1 + Lang/Perl/Program-name | 1 + Lang/Perl/Program-termination | 1 + Lang/Perl/Quaternion-type | 1 + Lang/Perl/Queue-Definition | 1 + Lang/Perl/Queue-Usage | 1 + Lang/Perl/Random-number-generator--device- | 1 + Lang/Perl/Random-numbers | 1 + Lang/Perl/Range-expansion | 1 + Lang/Perl/Range-extraction | 1 + Lang/Perl/Rate-counter | 1 + Lang/Perl/Ray-casting-algorithm | 1 + Lang/Perl/Read-a-configuration-file | 1 + Lang/Perl/Read-a-file-line-by-line | 1 + Lang/Perl/Read-a-specific-line-from-a-file | 1 + Lang/Perl/Read-entire-file | 1 + Lang/Perl/Real-constants-and-functions | 1 + Lang/Perl/Reduced-row-echelon-form | 1 + Lang/Perl/Regular-expressions | 1 + Lang/Perl/Remove-duplicate-elements | 1 + Lang/Perl/Remove-lines-from-a-file | 1 + Lang/Perl/Rename-a-file | 1 + Lang/Perl/Repeat-a-string | 1 + Lang/Perl/Resistor-mesh | 1 + Lang/Perl/Respond-to-an-unknown-method-call | 1 + Lang/Perl/Return-multiple-values | 1 + Lang/Perl/Reverse-a-string | 1 + Lang/Perl/Roman-numerals-Decode | 1 + Lang/Perl/Roman-numerals-Encode | 1 + Lang/Perl/Roots-of-a-function | 1 + Lang/Perl/Roots-of-a-quadratic-function | 1 + Lang/Perl/Roots-of-unity | 1 + Lang/Perl/Rosetta-Code-Count-examples | 1 + .../Rosetta-Code-Find-unimplemented-tasks | 1 + Lang/Perl/Rosetta-Code-Fix-code-tags | 1 + .../Rosetta-Code-Rank-languages-by-popularity | 1 + Lang/Perl/Rot-13 | 1 + Lang/Perl/Run-length-encoding | 1 + Lang/Perl/Runtime-evaluation | 1 + .../Perl/Runtime-evaluation-In-an-environment | 1 + Lang/Perl/S-Expressions | 1 + Lang/Perl/SEDOLs | 1 + Lang/Perl/Scope-modifiers | 1 + Lang/Perl/Secure-temporary-file | 1 + Lang/Perl/Self-describing-numbers | 1 + Lang/Perl/Self-referential-sequence | 1 + Lang/Perl/Semordnilap | 1 + Lang/Perl/Send-an-unknown-method-call | 1 + Lang/Perl/Send-email | 1 + Lang/Perl/Sequence-of-non-squares | 1 + Lang/Perl/Set | 1 + Lang/Perl/Set-of-real-numbers | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/PicoLisp/Binary-digits | 1 + Lang/PicoLisp/Brownian-tree | 1 + Lang/PicoLisp/Calendar---for-real-programmers | 1 + Lang/PicoLisp/Calendar-for-real-programmers | 1 - Lang/PicoLisp/Catalan-numbers | 1 + Lang/PicoLisp/Copy-a-string | 1 + Lang/PicoLisp/Dragon-curve | 1 + Lang/PicoLisp/Environment-variables | 1 + Lang/PicoLisp/Execute-a-Markov-algorithm | 1 + .../Guess-the-number-With-feedback--player- | 1 + .../Guess-the-number-With-feedback-player | 1 - Lang/PicoLisp/N-queens-problem | 1 + Lang/PicoLisp/Named-parameters | 1 + Lang/PicoLisp/Non-continuous-subsequences | 1 + Lang/PicoLisp/Non-decimal-radices-Convert | 1 + Lang/PicoLisp/Non-decimal-radices-Input | 1 + Lang/PicoLisp/Non-decimal-radices-Output | 1 + Lang/PicoLisp/Nth-root | 1 + Lang/PicoLisp/Null-object | 1 + Lang/PicoLisp/Number-names | 1 + Lang/PicoLisp/Number-reversal-game | 1 + Lang/PicoLisp/Numeric-error-propagation | 1 + Lang/PicoLisp/Numerical-integration | 1 + Lang/PicoLisp/Object-serialization | 1 + .../One-dimensional-cellular-automata | 1 + Lang/PicoLisp/One-of-n-lines-in-a-file | 1 + Lang/PicoLisp/OpenGL | 1 + Lang/PicoLisp/Optional-parameters | 1 + Lang/PicoLisp/Order-two-numerical-lists | 1 + Lang/PicoLisp/Ordered-Partitions | 1 + Lang/PicoLisp/Palindrome-detection | 1 + Lang/PicoLisp/Pangram-checker | 1 + Lang/PicoLisp/Parallel-calculations | 1 + Lang/PicoLisp/Parametric-polymorphism | 1 + Lang/PicoLisp/Parametrized-SQL-statement | 1 + .../PicoLisp/Parsing-RPN-calculator-algorithm | 1 + Lang/PicoLisp/Parsing-RPN-to-infix-conversion | 1 + Lang/PicoLisp/Parsing-Shunting-yard-algorithm | 1 + Lang/PicoLisp/Partial-function-application | 1 + Lang/PicoLisp/Pascals-triangle | 1 + Lang/PicoLisp/Pascals-triangle-Puzzle | 1 + Lang/PicoLisp/Pattern-matching | 1 + .../Percentage-difference-between-images | 1 + Lang/PicoLisp/Perfect-numbers | 1 + Lang/PicoLisp/Permutation-test | 1 + Lang/PicoLisp/Permutations | 1 + Lang/PicoLisp/Permutations-Derangements | 1 + Lang/PicoLisp/Pick-random-element | 1 + Lang/PicoLisp/Pinstripe-Display | 1 + Lang/PicoLisp/Pinstripe-Printer | 1 + Lang/PicoLisp/Play-recorded-sounds | 1 + Lang/PicoLisp/Playing-cards | 1 + Lang/PicoLisp/Plot-coordinate-pairs | 1 + Lang/PicoLisp/Pointers-and-references | 1 + Lang/PicoLisp/Polymorphic-copy | 1 + Lang/PicoLisp/Polymorphism | 1 + Lang/PicoLisp/Polynomial-long-division | 1 + Lang/PicoLisp/Power-set | 1 + Lang/PicoLisp/Price-fraction | 1 + Lang/PicoLisp/Primality-by-trial-division | 1 + Lang/PicoLisp/Prime-decomposition | 1 + Lang/PicoLisp/Priority-queue | 1 + Lang/PicoLisp/Probabilistic-choice | 1 + Lang/PicoLisp/Program-name | 1 + Lang/PicoLisp/Program-termination | 1 + Lang/PicoLisp/Pythagorean-triples | 1 + Lang/PicoLisp/Quaternion-type | 1 + Lang/PicoLisp/Queue-Definition | 1 + Lang/PicoLisp/Queue-Usage | 1 + .../PicoLisp/Random-number-generator--device- | 1 + Lang/PicoLisp/Random-numbers | 1 + Lang/PicoLisp/Range-expansion | 1 + Lang/PicoLisp/Range-extraction | 1 + Lang/PicoLisp/Rate-counter | 1 + Lang/PicoLisp/Ray-casting-algorithm | 1 + Lang/PicoLisp/Read-a-configuration-file | 1 + Lang/PicoLisp/Read-a-file-line-by-line | 1 + .../PicoLisp/Read-a-specific-line-from-a-file | 1 + Lang/PicoLisp/Read-entire-file | 1 + Lang/PicoLisp/Real-constants-and-functions | 1 + Lang/PicoLisp/Record-sound | 1 + Lang/PicoLisp/Reduced-row-echelon-form | 1 + Lang/PicoLisp/Regular-expressions | 1 + Lang/PicoLisp/Remove-duplicate-elements | 1 + Lang/PicoLisp/Remove-lines-from-a-file | 1 + Lang/PicoLisp/Rename-a-file | 1 + Lang/PicoLisp/Rendezvous | 1 + Lang/PicoLisp/Repeat-a-string | 1 + .../Respond-to-an-unknown-method-call | 1 + Lang/PicoLisp/Return-multiple-values | 1 + Lang/PicoLisp/Reverse-a-string | 1 + Lang/PicoLisp/Rock-paper-scissors | 1 + Lang/PicoLisp/Roman-numerals-Decode | 1 + Lang/PicoLisp/Roman-numerals-Encode | 1 + Lang/PicoLisp/Roots-of-a-function | 1 + Lang/PicoLisp/Roots-of-a-quadratic-function | 1 + Lang/PicoLisp/Roots-of-unity | 1 + Lang/PicoLisp/Rosetta-Code-Count-examples | 1 + .../Rosetta-Code-Find-unimplemented-tasks | 1 + Lang/PicoLisp/Rosetta-Code-Fix-code-tags | 1 + .../Rosetta-Code-Rank-languages-by-popularity | 1 + Lang/PicoLisp/Rot-13 | 1 + Lang/PicoLisp/Run-length-encoding | 1 + .../Runtime-evaluation-In-an-environment | 1 + Lang/PicoLisp/S-Expressions | 1 + Lang/PicoLisp/SEDOLs | 1 + Lang/PicoLisp/Same-Fringe | 1 + Lang/PicoLisp/Secure-temporary-file | 1 + Lang/PicoLisp/Self-describing-numbers | 1 + Lang/PicoLisp/Self-referential-sequence | 1 + Lang/PicoLisp/Send-an-unknown-method-call | 1 + Lang/PicoLisp/Send-email | 1 + Lang/PicoLisp/Sequence-of-non-squares | 1 + Lang/PicoLisp/Set | 1 + Lang/PicoLisp/Set-consolidation | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Pike/Copy-a-string | 1 + Lang/Pike/Null-object | 1 + Lang/Pike/OpenGL | 1 + Lang/Pike/Order-two-numerical-lists | 1 + Lang/Pike/Palindrome-detection | 1 + Lang/Pike/Read-entire-file | 1 + Lang/Pike/Rename-a-file | 1 + Lang/Pike/Repeat-a-string | 1 + Lang/Pike/Respond-to-an-unknown-method-call | 1 + Lang/Pike/Return-multiple-values | 1 + Lang/Pike/Roman-numerals-Encode | 1 + Lang/Pike/Rot-13 | 1 + Lang/Pike/Runtime-evaluation | 1 + .../Pike/Runtime-evaluation-In-an-environment | 1 + Lang/Pike/S-Expressions | 1 + Lang/Pike/Send-an-unknown-method-call | 1 + Lang/Pike/Send-email | 1 + Lang/PlainTeX/Catalan-numbers | 1 + Lang/Pop11/Copy-a-string | 1 + Lang/Pop11/Non-continuous-subsequences | 1 + Lang/Pop11/Non-decimal-radices-Convert | 1 + Lang/Pop11/Polymorphism | 1 + Lang/Pop11/Program-termination | 1 + Lang/Pop11/Random-numbers | 1 + Lang/Pop11/Real-constants-and-functions | 1 + Lang/Pop11/Remove-duplicate-elements | 1 + Lang/Pop11/Rename-a-file | 1 + Lang/Pop11/Reverse-a-string | 1 + Lang/Pop11/Rot-13 | 1 + Lang/PostScript/Copy-a-string | 1 + Lang/PostScript/Dragon-curve | 1 + Lang/PostScript/Plot-coordinate-pairs | 1 + Lang/PostScript/Program-termination | 1 + Lang/PostScript/Queue-Definition | 1 + Lang/PostScript/Queue-Usage | 1 + Lang/PostScript/Remove-duplicate-elements | 1 + Lang/PostScript/Repeat-a-string | 1 + Lang/PostScript/Reverse-a-string | 1 + Lang/PostScript/Rot-13 | 1 + Lang/PostScript/Sequence-of-non-squares | 1 + Lang/PowerBASIC/N-queens-problem | 1 + Lang/PowerBASIC/Number-names | 1 + Lang/PowerBASIC/Palindrome-detection | 1 + Lang/PowerBASIC/Permutations | 1 + Lang/PowerBASIC/Program-name | 1 + Lang/PowerBASIC/Remove-lines-from-a-file | 1 + Lang/PowerBASIC/Repeat-a-string | 1 + Lang/PowerBASIC/Roman-numerals-Encode | 1 + Lang/PowerBASIC/Run-length-encoding | 1 + Lang/PowerShell/Binary-digits | 1 + Lang/PowerShell/Copy-a-string | 1 + Lang/PowerShell/Environment-variables | 1 + Lang/PowerShell/Named-parameters | 1 + Lang/PowerShell/Non-continuous-subsequences | 1 + Lang/PowerShell/Non-decimal-radices-Output | 1 + Lang/PowerShell/Null-object | 1 + Lang/PowerShell/Pascals-triangle | 1 + Lang/PowerShell/Perfect-numbers | 1 + Lang/PowerShell/Primality-by-trial-division | 1 + Lang/PowerShell/Program-termination | 1 + Lang/PowerShell/Read-entire-file | 1 + Lang/PowerShell/Real-constants-and-functions | 1 + Lang/PowerShell/Regular-expressions | 1 + Lang/PowerShell/Remove-duplicate-elements | 1 + Lang/PowerShell/Rename-a-file | 1 + Lang/PowerShell/Repeat-a-string | 1 + Lang/PowerShell/Reverse-a-string | 1 + Lang/PowerShell/Rot-13 | 1 + Lang/PowerShell/Run-length-encoding | 1 + Lang/PowerShell/Scope-modifiers | 1 + Lang/PowerShell/Sequence-of-non-squares | 1 + Lang/ProDOS/Copy-a-string | 1 + Lang/ProDOS/Random-number-generator--device- | 1 + Lang/ProDOS/Rename-a-file | 1 + Lang/Prolog/Catalan-numbers | 1 + Lang/Prolog/Dragon-curve | 1 + Lang/Prolog/N-queens-problem | 1 + Lang/Prolog/Non-continuous-subsequences | 1 + Lang/Prolog/One-dimensional-cellular-automata | 1 + Lang/Prolog/Palindrome-detection | 1 + Lang/Prolog/Pangram-checker | 1 + Lang/Prolog/Parallel-calculations | 1 + Lang/Prolog/Parsing-RPN-calculator-algorithm | 1 + Lang/Prolog/Partial-function-application | 1 + Lang/Prolog/Pascals-triangle | 1 + Lang/Prolog/Pascals-triangle-Puzzle | 1 + Lang/Prolog/Perfect-numbers | 1 + Lang/Prolog/Permutations | 1 + Lang/Prolog/Playing-cards | 1 + Lang/Prolog/Power-set | 1 + Lang/Prolog/Primality-by-trial-division | 1 + Lang/Prolog/Prime-decomposition | 1 + Lang/Prolog/Priority-queue | 1 + Lang/Prolog/Program-termination | 1 + Lang/Prolog/Queue-Definition | 1 + Lang/Prolog/Queue-Usage | 1 + Lang/Prolog/Range-expansion | 1 + Lang/Prolog/Range-extraction | 1 + Lang/Prolog/Remove-duplicate-elements | 1 + Lang/Prolog/Repeat-a-string | 1 + Lang/Prolog/Reverse-a-string | 1 + Lang/Prolog/Roman-numerals-Decode | 1 + Lang/Prolog/Roman-numerals-Encode | 1 + Lang/Prolog/Rot-13 | 1 + Lang/Prolog/Run-length-encoding | 1 + Lang/Prolog/Self-describing-numbers | 1 + Lang/Prolog/Set | 1 + Lang/Protium/Read-a-configuration-file | 1 + Lang/Protium/Reverse-a-string | 1 + Lang/Protium/Roman-numerals-Encode | 1 + Lang/Pure/Prime-decomposition | 1 + Lang/Pure/Repeat-a-string | 1 + Lang/Pure/Run-length-encoding | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/PureBasic/Binary-digits | 1 + Lang/PureBasic/Brownian-tree | 1 + Lang/PureBasic/Catalan-numbers | 1 + Lang/PureBasic/Copy-a-string | 1 + Lang/PureBasic/Dragon-curve | 1 + Lang/PureBasic/Environment-variables | 1 + Lang/PureBasic/Execute-a-Markov-algorithm | 1 + .../Guess-the-number-With-feedback--player- | 1 + .../Guess-the-number-With-feedback-player | 1 - Lang/PureBasic/N-queens-problem | 1 + Lang/PureBasic/Non-decimal-radices-Convert | 1 + Lang/PureBasic/Non-decimal-radices-Input | 1 + Lang/PureBasic/Non-decimal-radices-Output | 1 + Lang/PureBasic/Nth-root | 1 + Lang/PureBasic/Null-object | 1 + Lang/PureBasic/Number-names | 1 + Lang/PureBasic/Number-reversal-game | 1 + Lang/PureBasic/Numerical-integration | 1 + .../One-dimensional-cellular-automata | 1 + Lang/PureBasic/One-of-n-lines-in-a-file | 1 + Lang/PureBasic/OpenGL | 1 + Lang/PureBasic/Order-two-numerical-lists | 1 + Lang/PureBasic/Palindrome-detection | 1 + Lang/PureBasic/Pangram-checker | 1 + Lang/PureBasic/Parallel-calculations | 1 + Lang/PureBasic/Parametrized-SQL-statement | 1 + Lang/PureBasic/Pascals-triangle | 1 + Lang/PureBasic/Pascals-triangle-Puzzle | 1 + .../Percentage-difference-between-images | 1 + Lang/PureBasic/Perfect-numbers | 1 + Lang/PureBasic/Permutation-test | 1 + Lang/PureBasic/Permutations | 1 + Lang/PureBasic/Permutations-Derangements | 1 + Lang/PureBasic/Pick-random-element | 1 + Lang/PureBasic/Pinstripe-Display | 1 + Lang/PureBasic/Play-recorded-sounds | 1 + Lang/PureBasic/Playing-cards | 1 + Lang/PureBasic/Plot-coordinate-pairs | 1 + Lang/PureBasic/Pointers-and-references | 1 + Lang/PureBasic/Polymorphism | 1 + Lang/PureBasic/Power-set | 1 + Lang/PureBasic/Price-fraction | 1 + Lang/PureBasic/Primality-by-trial-division | 1 + Lang/PureBasic/Prime-decomposition | 1 + Lang/PureBasic/Priority-queue | 1 + Lang/PureBasic/Probabilistic-choice | 1 + Lang/PureBasic/Problem-of-Apollonius | 1 + Lang/PureBasic/Program-name | 1 + Lang/PureBasic/Program-termination | 1 + Lang/PureBasic/Pythagorean-triples | 1 + Lang/PureBasic/Quaternion-type | 1 + Lang/PureBasic/Queue-Definition | 1 + Lang/PureBasic/Queue-Usage | 1 + .../Random-number-generator--device- | 1 + Lang/PureBasic/Random-numbers | 1 + Lang/PureBasic/Range-expansion | 1 + Lang/PureBasic/Range-extraction | 1 + Lang/PureBasic/Rate-counter | 1 + Lang/PureBasic/Ray-casting-algorithm | 1 + Lang/PureBasic/Read-a-file-line-by-line | 1 + .../Read-a-specific-line-from-a-file | 1 + Lang/PureBasic/Read-entire-file | 1 + Lang/PureBasic/Real-constants-and-functions | 1 + Lang/PureBasic/Regular-expressions | 1 + Lang/PureBasic/Remove-duplicate-elements | 1 + Lang/PureBasic/Rename-a-file | 1 + Lang/PureBasic/Repeat-a-string | 1 + Lang/PureBasic/Return-multiple-values | 1 + Lang/PureBasic/Reverse-a-string | 1 + Lang/PureBasic/Rock-paper-scissors | 1 + Lang/PureBasic/Roman-numerals-Decode | 1 + Lang/PureBasic/Roman-numerals-Encode | 1 + Lang/PureBasic/Roots-of-a-function | 1 + Lang/PureBasic/Roots-of-unity | 1 + Lang/PureBasic/Rosetta-Code-Count-examples | 1 + Lang/PureBasic/Rosetta-Code-Fix-code-tags | 1 + .../Rosetta-Code-Rank-languages-by-popularity | 1 + Lang/PureBasic/Rot-13 | 1 + Lang/PureBasic/Run-length-encoding | 1 + Lang/PureBasic/SEDOLs | 1 + Lang/PureBasic/Scope-modifiers | 1 + Lang/PureBasic/Secure-temporary-file | 1 + Lang/PureBasic/Self-describing-numbers | 1 + Lang/PureBasic/Send-email | 1 + Lang/PureBasic/Sequence-of-non-squares | 1 + Lang/PureBasic/Set | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Python/Binary-digits | 1 + Lang/Python/Brownian-tree | 1 + Lang/Python/Catalan-numbers | 1 + Lang/Python/Copy-a-string | 1 + Lang/Python/Dragon-curve | 1 + Lang/Python/Environment-variables | 1 + Lang/Python/Execute-a-Markov-algorithm | 1 + .../Guess-the-number-With-feedback--player- | 1 + .../Guess-the-number-With-feedback-player | 1 - Lang/Python/N-queens-problem | 1 + Lang/Python/Named-parameters | 1 + Lang/Python/Nautical-bell | 1 + Lang/Python/Non-continuous-subsequences | 1 + Lang/Python/Non-decimal-radices-Convert | 1 + Lang/Python/Non-decimal-radices-Input | 1 + Lang/Python/Non-decimal-radices-Output | 1 + Lang/Python/Nth-root | 1 + Lang/Python/Null-object | 1 + Lang/Python/Number-reversal-game | 1 + Lang/Python/Numeric-error-propagation | 1 + Lang/Python/Numerical-integration | 1 + ...ical-integration-Gauss-Legendre-Quadrature | 1 + Lang/Python/OLE-Automation | 1 + Lang/Python/Object-serialization | 1 + Lang/Python/One-dimensional-cellular-automata | 1 + Lang/Python/One-of-n-lines-in-a-file | 1 + Lang/Python/OpenGL | 1 + Lang/Python/Optional-parameters | 1 + Lang/Python/Order-two-numerical-lists | 1 + Lang/Python/Ordered-Partitions | 1 + Lang/Python/Palindrome-detection | 1 + Lang/Python/Pangram-checker | 1 + Lang/Python/Parallel-calculations | 1 + Lang/Python/Parametrized-SQL-statement | 1 + Lang/Python/Parsing-RPN-calculator-algorithm | 1 + Lang/Python/Parsing-RPN-to-infix-conversion | 1 + Lang/Python/Parsing-Shunting-yard-algorithm | 1 + Lang/Python/Partial-function-application | 1 + Lang/Python/Pascals-triangle | 1 + Lang/Python/Pascals-triangle-Puzzle | 1 + .../Percentage-difference-between-images | 1 + Lang/Python/Perfect-numbers | 1 + Lang/Python/Permutation-test | 1 + Lang/Python/Permutations | 1 + Lang/Python/Permutations-Derangements | 1 + Lang/Python/Permutations-by-swapping | 1 + Lang/Python/Pick-random-element | 1 + Lang/Python/Pig-the-dice-game | 1 + Lang/Python/Pig-the-dice-game-Player | 1 + Lang/Python/Play-recorded-sounds | 1 + Lang/Python/Playing-cards | 1 + Lang/Python/Plot-coordinate-pairs | 1 + Lang/Python/Pointers-and-references | 1 + Lang/Python/Polymorphic-copy | 1 + Lang/Python/Polymorphism | 1 + Lang/Python/Polynomial-long-division | 1 + Lang/Python/Polynomial-regression | 1 + Lang/Python/Power-set | 1 + Lang/Python/Pragmatic-directives | 1 + Lang/Python/Price-fraction | 1 + Lang/Python/Primality-by-trial-division | 1 + Lang/Python/Prime-decomposition | 1 + Lang/Python/Priority-queue | 1 + Lang/Python/Probabilistic-choice | 1 + Lang/Python/Problem-of-Apollonius | 1 + Lang/Python/Program-name | 1 + Lang/Python/Program-termination | 1 + Lang/Python/Pythagorean-triples | 1 + Lang/Python/Quaternion-type | 1 + Lang/Python/Queue-Definition | 1 + Lang/Python/Queue-Usage | 1 + Lang/Python/RIPEMD-160 | 1 + Lang/Python/Random-number-generator--device- | 1 + Lang/Python/Random-numbers | 1 + Lang/Python/Range-expansion | 1 + Lang/Python/Range-extraction | 1 + Lang/Python/Rate-counter | 1 + Lang/Python/Ray-casting-algorithm | 1 + Lang/Python/Read-a-configuration-file | 1 + Lang/Python/Read-a-file-line-by-line | 1 + Lang/Python/Read-a-specific-line-from-a-file | 1 + Lang/Python/Read-entire-file | 1 + Lang/Python/Real-constants-and-functions | 1 + Lang/Python/Record-sound | 1 + Lang/Python/Reduced-row-echelon-form | 1 + Lang/Python/Regular-expressions | 1 + Lang/Python/Remove-duplicate-elements | 1 + Lang/Python/Remove-lines-from-a-file | 1 + Lang/Python/Rename-a-file | 1 + Lang/Python/Repeat-a-string | 1 + Lang/Python/Resistor-mesh | 1 + Lang/Python/Respond-to-an-unknown-method-call | 1 + Lang/Python/Return-multiple-values | 1 + Lang/Python/Reverse-a-string | 1 + Lang/Python/Rock-paper-scissors | 1 + Lang/Python/Roman-numerals-Decode | 1 + Lang/Python/Roman-numerals-Encode | 1 + Lang/Python/Roots-of-a-function | 1 + Lang/Python/Roots-of-a-quadratic-function | 1 + Lang/Python/Roots-of-unity | 1 + Lang/Python/Rosetta-Code-Count-examples | 1 + Lang/Python/Rosetta-Code-Fix-code-tags | 1 + .../Rosetta-Code-Rank-languages-by-popularity | 1 + Lang/Python/Rot-13 | 1 + Lang/Python/Run-length-encoding | 1 + Lang/Python/Runtime-evaluation | 1 + .../Runtime-evaluation-In-an-environment | 1 + Lang/Python/S-Expressions | 1 + Lang/Python/SEDOLs | 1 + Lang/Python/Safe-addition | 1 + Lang/Python/Same-Fringe | 1 + Lang/Python/Scope-modifiers | 1 + Lang/Python/Secure-temporary-file | 1 + Lang/Python/Self-describing-numbers | 1 + Lang/Python/Self-referential-sequence | 1 + Lang/Python/Semordnilap | 1 + Lang/Python/Send-an-unknown-method-call | 1 + Lang/Python/Send-email | 1 + Lang/Python/Sequence-of-non-squares | 1 + Lang/Python/Set | 1 + Lang/Python/Set-consolidation | 1 + Lang/Python/Set-of-real-numbers | 1 + Lang/Qi/Pascals-triangle | 1 + Lang/Qi/Permutations | 1 + Lang/Qi/Power-set | 1 + Lang/Qi/Primality-by-trial-division | 1 + Lang/Qi/Range-extraction | 1 + Lang/Qi/Remove-duplicate-elements | 1 + Lang/Qi/Reverse-a-string | 1 + Lang/Qi/Send-an-unknown-method-call | 1 + .../R/Arbitrary-precision-integers--included- | 1 + Lang/R/Arbitrary-precision-integers-included | 1 - Lang/R/Catalan-numbers | 1 + Lang/R/Copy-a-string | 1 + Lang/R/Environment-variables | 1 + Lang/R/N-queens-problem | 1 + Lang/R/Named-parameters | 1 + Lang/R/Non-continuous-subsequences | 1 + Lang/R/Non-decimal-radices-Input | 1 + Lang/R/Non-decimal-radices-Output | 1 + Lang/R/Nth-root | 1 + Lang/R/Null-object | 1 + Lang/R/Number-reversal-game | 1 + Lang/R/Numerical-integration | 1 + Lang/R/One-dimensional-cellular-automata | 1 + Lang/R/OpenGL | 1 + Lang/R/Optional-parameters | 1 + Lang/R/Palindrome-detection | 1 + Lang/R/Pangram-checker | 1 + Lang/R/Partial-function-application | 1 + Lang/R/Pascals-triangle | 1 + Lang/R/Perfect-numbers | 1 + Lang/R/Permutation-test | 1 + Lang/R/Permutations | 1 + Lang/R/Pick-random-element | 1 + Lang/R/Play-recorded-sounds | 1 + Lang/R/Playing-cards | 1 + Lang/R/Plot-coordinate-pairs | 1 + Lang/R/Polymorphism | 1 + Lang/R/Polynomial-long-division | 1 + Lang/R/Polynomial-regression | 1 + Lang/R/Power-set | 1 + Lang/R/Price-fraction | 1 + Lang/R/Primality-by-trial-division | 1 + Lang/R/Prime-decomposition | 1 + Lang/R/Priority-queue | 1 + Lang/R/Probabilistic-choice | 1 + Lang/R/Program-name | 1 + Lang/R/Program-termination | 1 + Lang/R/QR-decomposition | 1 + Lang/R/Quaternion-type | 1 + Lang/R/Queue-Definition | 1 + Lang/R/Random-number-generator--included- | 1 + Lang/R/Random-numbers | 1 + Lang/R/Range-expansion | 1 + Lang/R/Ray-casting-algorithm | 1 + Lang/R/Read-a-file-line-by-line | 1 + Lang/R/Read-a-specific-line-from-a-file | 1 + Lang/R/Read-entire-file | 1 + Lang/R/Real-constants-and-functions | 1 + Lang/R/Reduced-row-echelon-form | 1 + Lang/R/Regular-expressions | 1 + Lang/R/Rename-a-file | 1 + Lang/R/Repeat-a-string | 1 + Lang/R/Return-multiple-values | 1 + Lang/R/Reverse-a-string | 1 + Lang/R/Roman-numerals-Encode | 1 + Lang/R/Roots-of-a-function | 1 + Lang/R/Roots-of-a-quadratic-function | 1 + Lang/R/Roots-of-unity | 1 + Lang/R/Rosetta-Code-Count-examples | 1 + Lang/R/Rosetta-Code-Find-unimplemented-tasks | 1 + Lang/R/Rosetta-Code-Fix-code-tags | 1 + .../Rosetta-Code-Rank-languages-by-popularity | 1 + Lang/R/Rot-13 | 1 + Lang/R/Run-length-encoding | 1 + Lang/R/Runtime-evaluation | 1 + Lang/R/Runtime-evaluation-In-an-environment | 1 + Lang/R/SEDOLs | 1 + Lang/R/Scope-modifiers | 1 + Lang/R/Sequence-of-non-squares | 1 + Lang/REALbasic/Read-entire-file | 1 + Lang/REALbasic/Rename-a-file | 1 + Lang/REALbasic/Repeat-a-string | 1 + Lang/REBOL/Copy-a-string | 1 + Lang/REBOL/Environment-variables | 1 + Lang/REBOL/Null-object | 1 + Lang/REBOL/Palindrome-detection | 1 + .../Percentage-difference-between-images | 1 + Lang/REBOL/Perfect-numbers | 1 + Lang/REBOL/Primality-by-trial-division | 1 + Lang/REBOL/Program-termination | 1 + Lang/REBOL/Queue-Definition | 1 + Lang/REBOL/Queue-Usage | 1 + Lang/REBOL/Read-entire-file | 1 + Lang/REBOL/Regular-expressions | 1 + Lang/REBOL/Remove-duplicate-elements | 1 + Lang/REBOL/Rename-a-file | 1 + Lang/REBOL/Repeat-a-string | 1 + Lang/REBOL/Reverse-a-string | 1 + Lang/REBOL/Rot-13 | 1 + .../Runtime-evaluation-In-an-environment | 1 + Lang/REBOL/Send-email | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/REXX/Binary-digits | 1 + Lang/REXX/Brownian-tree | 1 + Lang/REXX/Calendar---for-real-programmers | 1 + Lang/REXX/Calendar-for-real-programmers | 1 - Lang/REXX/Catalan-numbers | 1 + Lang/REXX/Copy-a-string | 1 + Lang/REXX/Dragon-curve | 1 + Lang/REXX/Environment-variables | 1 + Lang/REXX/Execute-a-Markov-algorithm | 1 + .../Guess-the-number-With-feedback--player- | 1 + .../Guess-the-number-With-feedback-player | 1 - Lang/REXX/N-queens-problem | 1 + Lang/REXX/Named-parameters | 1 + Lang/REXX/Nautical-bell | 1 + Lang/REXX/Non-continuous-subsequences | 1 + Lang/REXX/Non-decimal-radices-Convert | 1 + Lang/REXX/Non-decimal-radices-Input | 1 + Lang/REXX/Non-decimal-radices-Output | 1 + Lang/REXX/Nth-root | 1 + Lang/REXX/Null-object | 1 + Lang/REXX/Number-reversal-game | 1 + Lang/REXX/Numerical-integration | 1 + Lang/REXX/One-of-n-lines-in-a-file | 1 + Lang/REXX/Operator-precedence | 1 + Lang/REXX/Palindrome-detection | 1 + Lang/REXX/Pangram-checker | 1 + Lang/REXX/Parsing-RPN-calculator-algorithm | 1 + Lang/REXX/Parsing-RPN-to-infix-conversion | 1 + Lang/REXX/Parsing-Shunting-yard-algorithm | 1 + Lang/REXX/Pascals-triangle | 1 + Lang/REXX/Pascals-triangle-Puzzle | 1 + Lang/REXX/Perfect-numbers | 1 + Lang/REXX/Permutation-test | 1 + Lang/REXX/Permutations | 1 + Lang/REXX/Permutations-Derangements | 1 + Lang/REXX/Pick-random-element | 1 + Lang/REXX/Pig-the-dice-game | 1 + Lang/REXX/Pig-the-dice-game-Player | 1 + Lang/REXX/Playing-cards | 1 + Lang/REXX/Power-set | 1 + Lang/REXX/Price-fraction | 1 + Lang/REXX/Primality-by-trial-division | 1 + Lang/REXX/Prime-decomposition | 1 + Lang/REXX/Probabilistic-choice | 1 + Lang/REXX/Problem-of-Apollonius | 1 + Lang/REXX/Program-name | 1 + Lang/REXX/Program-termination | 1 + Lang/REXX/Pythagorean-triples | 1 + Lang/REXX/Quaternion-type | 1 + Lang/REXX/Queue-Definition | 1 + Lang/REXX/Queue-Usage | 1 + Lang/REXX/Random-number-generator--device- | 1 + Lang/REXX/Random-numbers | 1 + Lang/REXX/Range-expansion | 1 + Lang/REXX/Range-extraction | 1 + Lang/REXX/Rate-counter | 1 + Lang/REXX/Ray-casting-algorithm | 1 + Lang/REXX/Read-a-configuration-file | 1 + Lang/REXX/Read-a-file-line-by-line | 1 + Lang/REXX/Read-a-specific-line-from-a-file | 1 + Lang/REXX/Read-entire-file | 1 + Lang/REXX/Real-constants-and-functions | 1 + Lang/REXX/Reduced-row-echelon-form | 1 + Lang/REXX/Regular-expressions | 1 + Lang/REXX/Remove-duplicate-elements | 1 + Lang/REXX/Remove-lines-from-a-file | 1 + Lang/REXX/Rename-a-file | 1 + Lang/REXX/Repeat-a-string | 1 + Lang/REXX/Resistor-mesh | 1 + Lang/REXX/Return-multiple-values | 1 + Lang/REXX/Reverse-a-string | 1 + Lang/REXX/Roman-numerals-Decode | 1 + Lang/REXX/Roman-numerals-Encode | 1 + Lang/REXX/Roots-of-a-function | 1 + Lang/REXX/Roots-of-a-quadratic-function | 1 + Lang/REXX/Roots-of-unity | 1 + Lang/REXX/Rosetta-Code-Fix-code-tags | 1 + .../Rosetta-Code-Rank-languages-by-popularity | 1 + Lang/REXX/Rot-13 | 1 + Lang/REXX/Run-length-encoding | 1 + Lang/REXX/Runtime-evaluation | 1 + .../REXX/Runtime-evaluation-In-an-environment | 1 + Lang/REXX/S-Expressions | 1 + Lang/REXX/SEDOLs | 1 + Lang/REXX/Safe-addition | 1 + Lang/REXX/Same-Fringe | 1 + Lang/REXX/Scope-Function-names-and-labels | 1 + Lang/REXX/Scope-modifiers | 1 + Lang/REXX/Self-describing-numbers | 1 + Lang/REXX/Self-referential-sequence | 1 + Lang/REXX/Semordnilap | 1 + Lang/REXX/Sequence-of-non-squares | 1 + Lang/REXX/Set | 1 + Lang/REXX/Set-consolidation | 1 + Lang/REXX/Set-of-real-numbers | 1 + Lang/RLaB/Copy-a-string | 1 + Lang/RLaB/Real-constants-and-functions | 1 + Lang/RLaB/Reverse-a-string | 1 + Lang/RLaB/Roots-of-a-function | 1 + Lang/RLaB/Roots-of-unity | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Racket/Binary-digits | 1 + Lang/Racket/Catalan-numbers | 1 + Lang/Racket/Dragon-curve | 1 + Lang/Racket/Environment-variables | 1 + Lang/Racket/Named-parameters | 1 + Lang/Racket/OpenGL | 1 + Lang/Racket/Optional-parameters | 1 + Lang/Racket/Palindrome-detection | 1 + Lang/Racket/Parametric-polymorphism | 1 + Lang/Racket/Partial-function-application | 1 + Lang/Racket/Pascals-triangle | 1 + Lang/Racket/Pattern-matching | 1 + Lang/Racket/Playing-cards | 1 + Lang/Racket/Power-set | 1 + Lang/Racket/Program-name | 1 + Lang/Racket/Range-expansion | 1 + Lang/Racket/Ray-casting-algorithm | 1 + Lang/Racket/Read-a-file-line-by-line | 1 + Lang/Racket/Read-entire-file | 1 + Lang/Racket/Real-constants-and-functions | 1 + Lang/Racket/Reduced-row-echelon-form | 1 + Lang/Racket/Regular-expressions | 1 + Lang/Racket/Rename-a-file | 1 + Lang/Racket/Repeat-a-string | 1 + Lang/Racket/Reverse-a-string | 1 + Lang/Racket/Roots-of-unity | 1 + .../Rosetta-Code-Rank-languages-by-popularity | 1 + Lang/Racket/Rot-13 | 1 + Lang/Racket/S-Expressions | 1 + Lang/Racket/SEDOLs | 1 + Lang/Racket/Same-Fringe | 1 + Lang/Racket/Secure-temporary-file | 1 + Lang/Racket/Send-email | 1 + Lang/Racket/Sequence-of-non-squares | 1 + Lang/Racket/Set | 1 + Lang/RapidQ/Dragon-curve | 1 + Lang/RapidQ/Pascals-triangle | 1 + Lang/Rascal/N-queens-problem | 1 + Lang/Rascal/Number-reversal-game | 1 + Lang/Rascal/Order-two-numerical-lists | 1 + Lang/Rascal/Palindrome-detection | 1 + Lang/Rascal/Pattern-matching | 1 + Lang/Rascal/Power-set | 1 + Lang/Rascal/QR-decomposition | 1 + .../Rascal/Random-number-generator--included- | 1 + Lang/Rascal/Reverse-a-string | 1 + Lang/Rascal/Rock-paper-scissors | 1 + Lang/Raven/Copy-a-string | 1 + Lang/Raven/Regular-expressions | 1 + Lang/Raven/Remove-duplicate-elements | 1 + Lang/Retro/Binary-digits | 1 + Lang/Retro/Copy-a-string | 1 + Lang/Retro/Environment-variables | 1 + Lang/Retro/One-dimensional-cellular-automata | 1 + Lang/Retro/Palindrome-detection | 1 + Lang/Retro/Pangram-checker | 1 + Lang/Retro/Pascals-triangle | 1 + Lang/Retro/Program-termination | 1 + Lang/Retro/Read-entire-file | 1 + Lang/Retro/Repeat-a-string | 1 + Lang/Retro/Return-multiple-values | 1 + Lang/Retro/Reverse-a-string | 1 + Lang/Retro/Roman-numerals-Encode | 1 + Lang/Retro/Rot-13 | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Ruby/Binary-digits | 1 + Lang/Ruby/Brownian-tree | 1 + Lang/Ruby/Calendar---for-real-programmers | 1 + Lang/Ruby/Calendar-for-real-programmers | 1 - Lang/Ruby/Catalan-numbers | 1 + ...rithmetic-G-matrix-NG,-Contined-Fraction-N | 1 - ...ithmetic-G-matrix-NG,-Contined-Fraction-N- | 1 + Lang/Ruby/Copy-a-string | 1 + Lang/Ruby/Dragon-curve | 1 + Lang/Ruby/Environment-variables | 1 + Lang/Ruby/Execute-a-Markov-algorithm | 1 + .../Guess-the-number-With-feedback--player- | 1 + .../Guess-the-number-With-feedback-player | 1 - Lang/Ruby/N-queens-problem | 1 + Lang/Ruby/Named-parameters | 1 + Lang/Ruby/Non-continuous-subsequences | 1 + Lang/Ruby/Non-decimal-radices-Convert | 1 + Lang/Ruby/Non-decimal-radices-Input | 1 + Lang/Ruby/Non-decimal-radices-Output | 1 + Lang/Ruby/Nth-root | 1 + Lang/Ruby/Null-object | 1 + Lang/Ruby/Number-names | 1 + Lang/Ruby/Number-reversal-game | 1 + Lang/Ruby/Numeric-error-propagation | 1 + Lang/Ruby/Numerical-integration | 1 + Lang/Ruby/Object-serialization | 1 + Lang/Ruby/One-dimensional-cellular-automata | 1 + Lang/Ruby/One-of-n-lines-in-a-file | 1 + Lang/Ruby/OpenGL | 1 + Lang/Ruby/Optional-parameters | 1 + Lang/Ruby/Order-two-numerical-lists | 1 + Lang/Ruby/Palindrome-detection | 1 + Lang/Ruby/Pangram-checker | 1 + Lang/Ruby/Parametrized-SQL-statement | 1 + Lang/Ruby/Parsing-RPN-calculator-algorithm | 1 + Lang/Ruby/Parsing-RPN-to-infix-conversion | 1 + Lang/Ruby/Parsing-Shunting-yard-algorithm | 1 + Lang/Ruby/Partial-function-application | 1 + Lang/Ruby/Pascals-triangle | 1 + Lang/Ruby/Pascals-triangle-Puzzle | 1 + .../Ruby/Percentage-difference-between-images | 1 + Lang/Ruby/Perfect-numbers | 1 + Lang/Ruby/Permutations | 1 + Lang/Ruby/Permutations-Derangements | 1 + Lang/Ruby/Pick-random-element | 1 + Lang/Ruby/Pig-the-dice-game | 1 + Lang/Ruby/Play-recorded-sounds | 1 + Lang/Ruby/Playing-cards | 1 + Lang/Ruby/Plot-coordinate-pairs | 1 + Lang/Ruby/Polymorphic-copy | 1 + Lang/Ruby/Polymorphism | 1 + Lang/Ruby/Polynomial-long-division | 1 + Lang/Ruby/Polynomial-regression | 1 + Lang/Ruby/Power-set | 1 + Lang/Ruby/Price-fraction | 1 + Lang/Ruby/Primality-by-trial-division | 1 + Lang/Ruby/Prime-decomposition | 1 + Lang/Ruby/Priority-queue | 1 + Lang/Ruby/Probabilistic-choice | 1 + Lang/Ruby/Problem-of-Apollonius | 1 + Lang/Ruby/Program-name | 1 + Lang/Ruby/Program-termination | 1 + Lang/Ruby/Pythagorean-triples | 1 + Lang/Ruby/Quaternion-type | 1 + Lang/Ruby/Queue-Definition | 1 + Lang/Ruby/RIPEMD-160 | 1 + Lang/Ruby/Random-number-generator--device- | 1 + Lang/Ruby/Random-numbers | 1 + Lang/Ruby/Range-expansion | 1 + Lang/Ruby/Range-extraction | 1 + Lang/Ruby/Read-a-configuration-file | 1 + Lang/Ruby/Read-a-file-line-by-line | 1 + Lang/Ruby/Read-a-specific-line-from-a-file | 1 + Lang/Ruby/Read-entire-file | 1 + Lang/Ruby/Real-constants-and-functions | 1 + Lang/Ruby/Reduced-row-echelon-form | 1 + Lang/Ruby/Regular-expressions | 1 + Lang/Ruby/Remove-duplicate-elements | 1 + Lang/Ruby/Remove-lines-from-a-file | 1 + Lang/Ruby/Rename-a-file | 1 + Lang/Ruby/Repeat-a-string | 1 + Lang/Ruby/Respond-to-an-unknown-method-call | 1 + Lang/Ruby/Return-multiple-values | 1 + Lang/Ruby/Reverse-a-string | 1 + Lang/Ruby/Rock-paper-scissors | 1 + Lang/Ruby/Roman-numerals-Decode | 1 + Lang/Ruby/Roman-numerals-Encode | 1 + Lang/Ruby/Roots-of-a-function | 1 + Lang/Ruby/Roots-of-a-quadratic-function | 1 + Lang/Ruby/Roots-of-unity | 1 + Lang/Ruby/Rosetta-Code-Count-examples | 1 + .../Rosetta-Code-Find-unimplemented-tasks | 1 + Lang/Ruby/Rosetta-Code-Fix-code-tags | 1 + .../Rosetta-Code-Rank-languages-by-popularity | 1 + Lang/Ruby/Rot-13 | 1 + Lang/Ruby/Run-length-encoding | 1 + Lang/Ruby/Runtime-evaluation | 1 + .../Ruby/Runtime-evaluation-In-an-environment | 1 + Lang/Ruby/S-Expressions | 1 + Lang/Ruby/SEDOLs | 1 + Lang/Ruby/Safe-addition | 1 + Lang/Ruby/Secure-temporary-file | 1 + Lang/Ruby/Self-describing-numbers | 1 + Lang/Ruby/Self-referential-sequence | 1 + Lang/Ruby/Semordnilap | 1 + Lang/Ruby/Send-an-unknown-method-call | 1 + Lang/Ruby/Send-email | 1 + Lang/Ruby/Sequence-of-non-squares | 1 + Lang/Ruby/Set | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Run-BASIC/Binary-digits | 1 + Lang/Run-BASIC/Brownian-tree | 1 + Lang/Run-BASIC/Catalan-numbers | 1 + Lang/Run-BASIC/Copy-a-string | 1 + Lang/Run-BASIC/Dragon-curve | 1 + Lang/Run-BASIC/Environment-variables | 1 + Lang/Run-BASIC/Non-decimal-radices-Convert | 1 + Lang/Run-BASIC/Nth-root | 1 + Lang/Run-BASIC/Number-reversal-game | 1 + Lang/Run-BASIC/One-of-n-lines-in-a-file | 1 + Lang/Run-BASIC/Palindrome-detection | 1 + Lang/Run-BASIC/Pangram-checker | 1 + .../Parsing-RPN-calculator-algorithm | 1 + Lang/Run-BASIC/Pascals-triangle | 1 + Lang/Run-BASIC/Perfect-numbers | 1 + Lang/Run-BASIC/Permutations | 1 + Lang/Run-BASIC/Pick-random-element | 1 + Lang/Run-BASIC/Pig-the-dice-game | 1 + Lang/Run-BASIC/Playing-cards | 1 + Lang/Run-BASIC/Price-fraction | 1 + Lang/Run-BASIC/Primality-by-trial-division | 1 + Lang/Run-BASIC/Priority-queue | 1 + .../Random-number-generator--included- | 1 + Lang/Run-BASIC/Random-numbers | 1 + Lang/Run-BASIC/Range-expansion | 1 + Lang/Run-BASIC/Rate-counter | 1 + Lang/Run-BASIC/Read-a-file-line-by-line | 1 + .../Read-a-specific-line-from-a-file | 1 + Lang/Run-BASIC/Real-constants-and-functions | 1 + Lang/Run-BASIC/Regular-expressions | 1 + Lang/Run-BASIC/Remove-lines-from-a-file | 1 + Lang/Run-BASIC/Rename-a-file | 1 + Lang/Run-BASIC/Repeat-a-string | 1 + Lang/Run-BASIC/Return-multiple-values | 1 + Lang/Run-BASIC/Reverse-a-string | 1 + Lang/Run-BASIC/Rock-paper-scissors | 1 + Lang/Run-BASIC/Roman-numerals-Decode | 1 + Lang/Run-BASIC/Roman-numerals-Encode | 1 + Lang/Run-BASIC/Roots-of-a-quadratic-function | 1 + Lang/Run-BASIC/Rosetta-Code-Count-examples | 1 + .../Rosetta-Code-Find-unimplemented-tasks | 1 + .../Rosetta-Code-Rank-languages-by-popularity | 1 + Lang/Run-BASIC/Rot-13 | 1 + Lang/Run-BASIC/Run-length-encoding | 1 + Lang/Run-BASIC/Self-describing-numbers | 1 + Lang/Rust/Program-name | 1 + Lang/SAS/N-queens-problem | 1 + Lang/SAS/Permutations | 1 + Lang/SAS/Pointers-and-references | 1 + Lang/SAS/Primality-by-trial-division | 1 + Lang/SAS/QR-decomposition | 1 + Lang/SAS/Reverse-a-string | 1 + Lang/SAS/Send-email | 1 + Lang/SETL/Remove-duplicate-elements | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/SIMPOL/Polymorphism | 1 + Lang/SNOBOL4/Copy-a-string | 1 + Lang/SNOBOL4/Environment-variables | 1 + Lang/SNOBOL4/N-queens-problem | 1 + Lang/SNOBOL4/Palindrome-detection | 1 + Lang/SNOBOL4/Pangram-checker | 1 + Lang/SNOBOL4/Primality-by-trial-division | 1 + Lang/SNOBOL4/Program-termination | 1 + Lang/SNOBOL4/Range-expansion | 1 + Lang/SNOBOL4/Range-extraction | 1 + Lang/SNOBOL4/Read-a-file-line-by-line | 1 + Lang/SNOBOL4/Read-entire-file | 1 + Lang/SNOBOL4/Regular-expressions | 1 + Lang/SNOBOL4/Repeat-a-string | 1 + Lang/SNOBOL4/Reverse-a-string | 1 + Lang/SNOBOL4/Roman-numerals-Decode | 1 + Lang/SNOBOL4/Roman-numerals-Encode | 1 + Lang/SNOBOL4/Rot-13 | 1 + Lang/SNOBOL4/Run-length-encoding | 1 + Lang/SNOBOL4/Runtime-evaluation | 1 + .../Runtime-evaluation-In-an-environment | 1 + Lang/SQL/Repeat-a-string | 1 + Lang/SQL/Roman-numerals-Encode | 1 + Lang/Sage/Reduced-row-echelon-form | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Sather/Copy-a-string | 1 + Lang/Sather/Nth-root | 1 + Lang/Sather/Random-numbers | 1 + Lang/Sather/Regular-expressions | 1 + Lang/Sather/Reverse-a-string | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Scala/Binary-digits | 1 + Lang/Scala/Catalan-numbers | 1 + Lang/Scala/Copy-a-string | 1 + Lang/Scala/Execute-a-Markov-algorithm | 1 + Lang/Scala/N-queens-problem | 1 + Lang/Scala/Named-parameters | 1 + Lang/Scala/Nth-root | 1 + Lang/Scala/Null-object | 1 + Lang/Scala/Numerical-integration | 1 + Lang/Scala/One-dimensional-cellular-automata | 1 + Lang/Scala/Optional-parameters | 1 + Lang/Scala/Palindrome-detection | 1 + Lang/Scala/Pangram-checker | 1 + Lang/Scala/Parametric-polymorphism | 1 + Lang/Scala/Partial-function-application | 1 + Lang/Scala/Pascals-triangle | 1 + Lang/Scala/Pattern-matching | 1 + Lang/Scala/Perfect-numbers | 1 + Lang/Scala/Permutations | 1 + Lang/Scala/Plot-coordinate-pairs | 1 + Lang/Scala/Power-set | 1 + Lang/Scala/Price-fraction | 1 + Lang/Scala/Primality-by-trial-division | 1 + Lang/Scala/Prime-decomposition | 1 + Lang/Scala/Priority-queue | 1 + Lang/Scala/Problem-of-Apollonius | 1 + Lang/Scala/Program-name | 1 + Lang/Scala/Quaternion-type | 1 + Lang/Scala/Queue-Definition | 1 + Lang/Scala/Queue-Usage | 1 + Lang/Scala/Random-numbers | 1 + Lang/Scala/Range-expansion | 1 + Lang/Scala/Range-extraction | 1 + Lang/Scala/Rate-counter | 1 + Lang/Scala/Read-a-file-line-by-line | 1 + Lang/Scala/Read-a-specific-line-from-a-file | 1 + Lang/Scala/Regular-expressions | 1 + Lang/Scala/Remove-duplicate-elements | 1 + Lang/Scala/Rename-a-file | 1 + Lang/Scala/Repeat-a-string | 1 + Lang/Scala/Respond-to-an-unknown-method-call | 1 + Lang/Scala/Return-multiple-values | 1 + Lang/Scala/Reverse-a-string | 1 + Lang/Scala/Roman-numerals-Decode | 1 + Lang/Scala/Roman-numerals-Encode | 1 + Lang/Scala/Roots-of-a-quadratic-function | 1 + Lang/Scala/Roots-of-unity | 1 + Lang/Scala/Rosetta-Code-Count-examples | 1 + .../Rosetta-Code-Rank-languages-by-popularity | 1 + Lang/Scala/Rot-13 | 1 + Lang/Scala/Run-length-encoding | 1 + Lang/Scala/SEDOLs | 1 + Lang/Scala/Secure-temporary-file | 1 + Lang/Scala/Sequence-of-non-squares | 1 + Lang/Scala/Set | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Scheme/Binary-digits | 1 + Lang/Scheme/Brownian-tree | 1 + Lang/Scheme/Catalan-numbers | 1 + Lang/Scheme/Copy-a-string | 1 + Lang/Scheme/Execute-a-Markov-algorithm | 1 + .../Guess-the-number-With-feedback--player- | 1 + .../Guess-the-number-With-feedback-player | 1 - Lang/Scheme/Named-parameters | 1 + Lang/Scheme/Non-continuous-subsequences | 1 + Lang/Scheme/Non-decimal-radices-Input | 1 + Lang/Scheme/Non-decimal-radices-Output | 1 + Lang/Scheme/Nth-root | 1 + Lang/Scheme/Null-object | 1 + Lang/Scheme/Numerical-integration | 1 + Lang/Scheme/One-dimensional-cellular-automata | 1 + Lang/Scheme/Order-two-numerical-lists | 1 + Lang/Scheme/Palindrome-detection | 1 + Lang/Scheme/Pascals-triangle | 1 + Lang/Scheme/Perfect-numbers | 1 + Lang/Scheme/Permutations | 1 + Lang/Scheme/Playing-cards | 1 + Lang/Scheme/Power-set | 1 + Lang/Scheme/Primality-by-trial-division | 1 + Lang/Scheme/Prime-decomposition | 1 + Lang/Scheme/Program-name | 1 + Lang/Scheme/Program-termination | 1 + Lang/Scheme/Queue-Definition | 1 + Lang/Scheme/Random-numbers | 1 + Lang/Scheme/Range-expansion | 1 + Lang/Scheme/Range-extraction | 1 + Lang/Scheme/Read-a-file-line-by-line | 1 + Lang/Scheme/Real-constants-and-functions | 1 + Lang/Scheme/Reduced-row-echelon-form | 1 + Lang/Scheme/Remove-duplicate-elements | 1 + Lang/Scheme/Rename-a-file | 1 + Lang/Scheme/Repeat-a-string | 1 + Lang/Scheme/Return-multiple-values | 1 + Lang/Scheme/Reverse-a-string | 1 + Lang/Scheme/Roman-numerals-Encode | 1 + Lang/Scheme/Roots-of-a-quadratic-function | 1 + Lang/Scheme/Roots-of-unity | 1 + Lang/Scheme/Rot-13 | 1 + Lang/Scheme/Run-length-encoding | 1 + Lang/Scheme/Runtime-evaluation | 1 + .../Runtime-evaluation-In-an-environment | 1 + Lang/Scheme/S-Expressions | 1 + Lang/Scheme/Sequence-of-non-squares | 1 + Lang/Scheme/Set | 1 + Lang/Sed/Read-a-file-line-by-line | 1 + Lang/Sed/Reverse-a-string | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Seed7/Binary-digits | 1 + Lang/Seed7/Brownian-tree | 1 + Lang/Seed7/Copy-a-string | 1 + Lang/Seed7/Dragon-curve | 1 + Lang/Seed7/Environment-variables | 1 + Lang/Seed7/Non-decimal-radices-Output | 1 + Lang/Seed7/Nth-root | 1 + Lang/Seed7/Number-names | 1 + Lang/Seed7/One-dimensional-cellular-automata | 1 + Lang/Seed7/One-of-n-lines-in-a-file | 1 + Lang/Seed7/Palindrome-detection | 1 + Lang/Seed7/Pangram-checker | 1 + Lang/Seed7/Parametric-polymorphism | 1 + Lang/Seed7/Pascals-triangle | 1 + Lang/Seed7/Perfect-numbers | 1 + Lang/Seed7/Permutations | 1 + Lang/Seed7/Pick-random-element | 1 + Lang/Seed7/Power-set | 1 + Lang/Seed7/Price-fraction | 1 + Lang/Seed7/Primality-by-trial-division | 1 + Lang/Seed7/Prime-decomposition | 1 + Lang/Seed7/Probabilistic-choice | 1 + Lang/Seed7/Program-name | 1 + Lang/Seed7/Program-termination | 1 + Lang/Seed7/Pythagorean-triples | 1 + Lang/Seed7/Random-numbers | 1 + Lang/Seed7/Range-expansion | 1 + Lang/Seed7/Range-extraction | 1 + Lang/Seed7/Read-a-configuration-file | 1 + Lang/Seed7/Read-a-file-line-by-line | 1 + Lang/Seed7/Read-a-specific-line-from-a-file | 1 + Lang/Seed7/Reduced-row-echelon-form | 1 + Lang/Seed7/Remove-duplicate-elements | 1 + Lang/Seed7/Remove-lines-from-a-file | 1 + Lang/Seed7/Rename-a-file | 1 + Lang/Seed7/Repeat-a-string | 1 + Lang/Seed7/Return-multiple-values | 1 + Lang/Seed7/Reverse-a-string | 1 + Lang/Seed7/Roman-numerals-Decode | 1 + Lang/Seed7/Roman-numerals-Encode | 1 + Lang/Seed7/Roots-of-a-quadratic-function | 1 + Lang/Seed7/Roots-of-unity | 1 + Lang/Seed7/Rot-13 | 1 + Lang/Seed7/Run-length-encoding | 1 + Lang/Seed7/SEDOLs | 1 + Lang/Seed7/Self-describing-numbers | 1 + Lang/Seed7/Sequence-of-non-squares | 1 + Lang/Seed7/Set | 1 + Lang/Shiny/Copy-a-string | 1 + Lang/Shiny/Regular-expressions | 1 + Lang/Slate/Copy-a-string | 1 + Lang/Slate/Environment-variables | 1 + Lang/Slate/Non-decimal-radices-Convert | 1 + Lang/Slate/Null-object | 1 + Lang/Slate/Optional-parameters | 1 + Lang/Slate/Palindrome-detection | 1 + Lang/Slate/Perfect-numbers | 1 + Lang/Slate/Polymorphic-copy | 1 + Lang/Slate/Polynomial-long-division | 1 + Lang/Slate/Prime-decomposition | 1 + Lang/Slate/Program-termination | 1 + Lang/Slate/Queue-Definition | 1 + Lang/Slate/Real-constants-and-functions | 1 + Lang/Slate/Regular-expressions | 1 + Lang/Slate/Remove-duplicate-elements | 1 + Lang/Slate/Rename-a-file | 1 + Lang/Slate/Respond-to-an-unknown-method-call | 1 + Lang/Slate/Reverse-a-string | 1 + Lang/Slate/Rot-13 | 1 + Lang/Slate/Runtime-evaluation | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Smalltalk/Binary-digits | 1 + Lang/Smalltalk/Copy-a-string | 1 + .../Guess-the-number-With-feedback--player- | 1 + .../Guess-the-number-With-feedback-player | 1 - Lang/Smalltalk/Named-parameters | 1 + Lang/Smalltalk/Non-decimal-radices-Output | 1 + Lang/Smalltalk/Nth-root | 1 + Lang/Smalltalk/Null-object | 1 + Lang/Smalltalk/Palindrome-detection | 1 + Lang/Smalltalk/Pangram-checker | 1 + Lang/Smalltalk/Partial-function-application | 1 + Lang/Smalltalk/Perfect-numbers | 1 + Lang/Smalltalk/Permutations | 1 + Lang/Smalltalk/Pick-random-element | 1 + Lang/Smalltalk/Playing-cards | 1 + Lang/Smalltalk/Polymorphism | 1 + Lang/Smalltalk/Polynomial-long-division | 1 + Lang/Smalltalk/Power-set | 1 + Lang/Smalltalk/Price-fraction | 1 + Lang/Smalltalk/Prime-decomposition | 1 + Lang/Smalltalk/Program-name | 1 + Lang/Smalltalk/Queue-Definition | 1 + Lang/Smalltalk/Rate-counter | 1 + Lang/Smalltalk/Ray-casting-algorithm | 1 + Lang/Smalltalk/Read-a-configuration-file | 1 + Lang/Smalltalk/Read-a-file-line-by-line | 1 + Lang/Smalltalk/Read-entire-file | 1 + Lang/Smalltalk/Real-constants-and-functions | 1 + Lang/Smalltalk/Regular-expressions | 1 + Lang/Smalltalk/Remove-duplicate-elements | 1 + Lang/Smalltalk/Rename-a-file | 1 + Lang/Smalltalk/Repeat-a-string | 1 + .../Respond-to-an-unknown-method-call | 1 + Lang/Smalltalk/Reverse-a-string | 1 + Lang/Smalltalk/Roman-numerals-Encode | 1 + Lang/Smalltalk/Rot-13 | 1 + Lang/Smalltalk/Runtime-evaluation | 1 + Lang/Smalltalk/SEDOLs | 1 + Lang/Smalltalk/Send-an-unknown-method-call | 1 + Lang/Smalltalk/Set | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Standard-ML/Binary-digits | 1 + Lang/Standard-ML/Catalan-numbers | 1 + Lang/Standard-ML/Copy-a-string | 1 + Lang/Standard-ML/Environment-variables | 1 + Lang/Standard-ML/N-queens-problem | 1 + Lang/Standard-ML/Non-continuous-subsequences | 1 + Lang/Standard-ML/Non-decimal-radices-Convert | 1 + Lang/Standard-ML/Non-decimal-radices-Input | 1 + Lang/Standard-ML/Non-decimal-radices-Output | 1 + Lang/Standard-ML/Null-object | 1 + Lang/Standard-ML/Numerical-integration | 1 + Lang/Standard-ML/Order-two-numerical-lists | 1 + Lang/Standard-ML/Parametric-polymorphism | 1 + Lang/Standard-ML/Pattern-matching | 1 + Lang/Standard-ML/Pointers-and-references | 1 + Lang/Standard-ML/Power-set | 1 + Lang/Standard-ML/Primality-by-trial-division | 1 + Lang/Standard-ML/Priority-queue | 1 + Lang/Standard-ML/Program-name | 1 + Lang/Standard-ML/Program-termination | 1 + Lang/Standard-ML/Queue-Definition | 1 + Lang/Standard-ML/Queue-Usage | 1 + Lang/Standard-ML/Random-numbers | 1 + Lang/Standard-ML/Real-constants-and-functions | 1 + Lang/Standard-ML/Regular-expressions | 1 + Lang/Standard-ML/Rename-a-file | 1 + Lang/Standard-ML/Repeat-a-string | 1 + Lang/Standard-ML/Return-multiple-values | 1 + Lang/Standard-ML/Reverse-a-string | 1 + Lang/Standard-ML/Rot-13 | 1 + Lang/Standard-ML/Run-length-encoding | 1 + Lang/Standard-ML/SEDOLs | 1 + Lang/Standard-ML/Secure-temporary-file | 1 + Lang/Standard-ML/Sequence-of-non-squares | 1 + Lang/Suneido/Named-parameters | 1 + Lang/Suneido/Repeat-a-string | 1 + Lang/SystemVerilog/N-queens-problem | 1 + Lang/SystemVerilog/Pascals-triangle-Puzzle | 1 + Lang/TI-83-BASIC/Binary-digits | 1 + Lang/TI-83-BASIC/Brownian-tree | 1 + Lang/TI-83-BASIC/Catalan-numbers | 1 + Lang/TI-83-BASIC/Copy-a-string | 1 + Lang/TI-83-BASIC/Program-termination | 1 + Lang/TI-83-BASIC/Reverse-a-string | 1 + Lang/TI-83-BASIC/Rock-paper-scissors | 1 + Lang/TI-83-BASIC/Roman-numerals-Decode | 1 + Lang/TI-83-BASIC/Roman-numerals-Encode | 1 + Lang/TI-83-BASIC/Rot-13 | 1 + Lang/TI-89-BASIC/Copy-a-string | 1 + Lang/TI-89-BASIC/Dragon-curve | 1 + Lang/TI-89-BASIC/Non-decimal-radices-Output | 1 + Lang/TI-89-BASIC/Plot-coordinate-pairs | 1 + Lang/TI-89-BASIC/Polynomial-regression | 1 + Lang/TI-89-BASIC/Program-termination | 1 + Lang/TI-89-BASIC/Reduced-row-echelon-form | 1 + Lang/TI-89-BASIC/Roots-of-unity | 1 + .../Runtime-evaluation-In-an-environment | 1 + Lang/TI-89-BASIC/Scope-modifiers | 1 + Lang/TI-89-BASIC/Sequence-of-non-squares | 1 + Lang/TIScript/Optional-parameters | 1 + Lang/TUSCRIPT/Copy-a-string | 1 + Lang/TUSCRIPT/Number-reversal-game | 1 + Lang/TUSCRIPT/Order-two-numerical-lists | 1 + Lang/TUSCRIPT/Palindrome-detection | 1 + Lang/TUSCRIPT/Pangram-checker | 1 + Lang/TUSCRIPT/Pick-random-element | 1 + Lang/TUSCRIPT/Play-recorded-sounds | 1 + Lang/TUSCRIPT/Program-termination | 1 + Lang/TUSCRIPT/Range-expansion | 1 + Lang/TUSCRIPT/Range-extraction | 1 + Lang/TUSCRIPT/Read-a-file-line-by-line | 1 + .../TUSCRIPT/Read-a-specific-line-from-a-file | 1 + Lang/TUSCRIPT/Read-entire-file | 1 + Lang/TUSCRIPT/Remove-duplicate-elements | 1 + Lang/TUSCRIPT/Remove-lines-from-a-file | 1 + Lang/TUSCRIPT/Rename-a-file | 1 + Lang/TUSCRIPT/Repeat-a-string | 1 + Lang/TUSCRIPT/Reverse-a-string | 1 + Lang/TUSCRIPT/Roman-numerals-Decode | 1 + Lang/TUSCRIPT/Roman-numerals-Encode | 1 + Lang/TUSCRIPT/Rosetta-Code-Count-examples | 1 + .../Rosetta-Code-Rank-languages-by-popularity | 1 + Lang/TUSCRIPT/Run-length-encoding | 1 + Lang/TUSCRIPT/SEDOLs | 1 + Lang/TUSCRIPT/Secure-temporary-file | 1 + Lang/TUSCRIPT/Semordnilap | 1 + Lang/TUSCRIPT/Send-email | 1 + .../Arbitrary-precision-integers--included- | 1 + .../TXR/Arbitrary-precision-integers-included | 1 - Lang/TXR/Environment-variables | 1 + Lang/TXR/Pangram-checker | 1 + Lang/TXR/Pick-random-element | 1 + Lang/TXR/Power-set | 1 + Lang/TXR/Prime-decomposition | 1 + Lang/TXR/Read-a-configuration-file | 1 + Lang/TXR/Read-a-specific-line-from-a-file | 1 + Lang/TXR/Read-entire-file | 1 + Lang/TXR/Regular-expressions | 1 + Lang/TXR/Return-multiple-values | 1 + Lang/TXR/Rot-13 | 1 + Lang/TXR/Scope-modifiers | 1 + Lang/TXR/Send-email | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Tcl/Arbitrary-precision-integers-included | 1 - Lang/Tcl/Binary-digits | 1 + Lang/Tcl/Brownian-tree | 1 + Lang/Tcl/Calendar---for-real-programmers | 1 + Lang/Tcl/Calendar-for-real-programmers | 1 - Lang/Tcl/Catalan-numbers | 1 + ...rithmetic-G-matrix-NG,-Contined-Fraction-N | 1 - ...ithmetic-G-matrix-NG,-Contined-Fraction-N- | 1 + ...Contined-Fraction-N1,-Contined-Fraction-N2 | 1 - ...ontined-Fraction-N1,-Contined-Fraction-N2- | 1 + Lang/Tcl/Copy-a-string | 1 + Lang/Tcl/Dragon-curve | 1 + Lang/Tcl/Environment-variables | 1 + Lang/Tcl/Execute-a-Markov-algorithm | 1 + .../Guess-the-number-With-feedback--player- | 1 + .../Tcl/Guess-the-number-With-feedback-player | 1 - Lang/Tcl/N-queens-problem | 1 + Lang/Tcl/Named-parameters | 1 + Lang/Tcl/Nautical-bell | 1 + Lang/Tcl/Non-continuous-subsequences | 1 + Lang/Tcl/Non-decimal-radices-Convert | 1 + Lang/Tcl/Non-decimal-radices-Input | 1 + Lang/Tcl/Non-decimal-radices-Output | 1 + Lang/Tcl/Nth-root | 1 + Lang/Tcl/Null-object | 1 + Lang/Tcl/Number-names | 1 + Lang/Tcl/Number-reversal-game | 1 + Lang/Tcl/Numeric-error-propagation | 1 + Lang/Tcl/Numerical-integration | 1 + ...ical-integration-Gauss-Legendre-Quadrature | 1 + Lang/Tcl/Object-serialization | 1 + Lang/Tcl/One-dimensional-cellular-automata | 1 + Lang/Tcl/One-of-n-lines-in-a-file | 1 + Lang/Tcl/OpenGL | 1 + Lang/Tcl/Optional-parameters | 1 + Lang/Tcl/Order-two-numerical-lists | 1 + Lang/Tcl/Ordered-Partitions | 1 + Lang/Tcl/Palindrome-detection | 1 + Lang/Tcl/Pangram-checker | 1 + Lang/Tcl/Parallel-calculations | 1 + Lang/Tcl/Parametrized-SQL-statement | 1 + Lang/Tcl/Parsing-RPN-calculator-algorithm | 1 + Lang/Tcl/Parsing-RPN-to-infix-conversion | 1 + Lang/Tcl/Parsing-Shunting-yard-algorithm | 1 + Lang/Tcl/Partial-function-application | 1 + Lang/Tcl/Pascals-triangle | 1 + Lang/Tcl/Pascals-triangle-Puzzle | 1 + Lang/Tcl/Pattern-matching | 1 + Lang/Tcl/Percentage-difference-between-images | 1 + Lang/Tcl/Perfect-numbers | 1 + Lang/Tcl/Permutation-test | 1 + Lang/Tcl/Permutations | 1 + Lang/Tcl/Permutations-Derangements | 1 + Lang/Tcl/Permutations-by-swapping | 1 + Lang/Tcl/Pick-random-element | 1 + Lang/Tcl/Pig-the-dice-game | 1 + Lang/Tcl/Pig-the-dice-game-Player | 1 + Lang/Tcl/Pinstripe-Display | 1 + Lang/Tcl/Pinstripe-Printer | 1 + Lang/Tcl/Play-recorded-sounds | 1 + Lang/Tcl/Playing-cards | 1 + Lang/Tcl/Plot-coordinate-pairs | 1 + Lang/Tcl/Pointers-and-references | 1 + Lang/Tcl/Polymorphic-copy | 1 + Lang/Tcl/Polymorphism | 1 + Lang/Tcl/Polynomial-long-division | 1 + Lang/Tcl/Polynomial-regression | 1 + Lang/Tcl/Power-set | 1 + Lang/Tcl/Price-fraction | 1 + Lang/Tcl/Primality-by-trial-division | 1 + Lang/Tcl/Prime-decomposition | 1 + Lang/Tcl/Priority-queue | 1 + Lang/Tcl/Probabilistic-choice | 1 + Lang/Tcl/Problem-of-Apollonius | 1 + Lang/Tcl/Program-name | 1 + Lang/Tcl/Program-termination | 1 + Lang/Tcl/Pythagorean-triples | 1 + Lang/Tcl/QR-decomposition | 1 + Lang/Tcl/Quaternion-type | 1 + Lang/Tcl/Queue-Definition | 1 + Lang/Tcl/Queue-Usage | 1 + Lang/Tcl/RIPEMD-160 | 1 + Lang/Tcl/Random-number-generator--device- | 1 + Lang/Tcl/Random-numbers | 1 + Lang/Tcl/Range-expansion | 1 + Lang/Tcl/Range-extraction | 1 + Lang/Tcl/Rate-counter | 1 + Lang/Tcl/Ray-casting-algorithm | 1 + Lang/Tcl/Read-a-configuration-file | 1 + Lang/Tcl/Read-a-file-line-by-line | 1 + Lang/Tcl/Read-a-specific-line-from-a-file | 1 + Lang/Tcl/Read-entire-file | 1 + Lang/Tcl/Real-constants-and-functions | 1 + Lang/Tcl/Record-sound | 1 + Lang/Tcl/Reduced-row-echelon-form | 1 + Lang/Tcl/Regular-expressions | 1 + Lang/Tcl/Remove-duplicate-elements | 1 + Lang/Tcl/Remove-lines-from-a-file | 1 + Lang/Tcl/Rename-a-file | 1 + Lang/Tcl/Rendezvous | 1 + Lang/Tcl/Repeat-a-string | 1 + Lang/Tcl/Resistor-mesh | 1 + Lang/Tcl/Respond-to-an-unknown-method-call | 1 + Lang/Tcl/Return-multiple-values | 1 + Lang/Tcl/Reverse-a-string | 1 + Lang/Tcl/Rock-paper-scissors | 1 + Lang/Tcl/Roman-numerals-Decode | 1 + Lang/Tcl/Roman-numerals-Encode | 1 + Lang/Tcl/Roots-of-a-function | 1 + Lang/Tcl/Roots-of-a-quadratic-function | 1 + Lang/Tcl/Roots-of-unity | 1 + Lang/Tcl/Rosetta-Code-Count-examples | 1 + .../Tcl/Rosetta-Code-Find-unimplemented-tasks | 1 + Lang/Tcl/Rosetta-Code-Fix-code-tags | 1 + .../Rosetta-Code-Rank-languages-by-popularity | 1 + Lang/Tcl/Rot-13 | 1 + Lang/Tcl/Run-length-encoding | 1 + Lang/Tcl/Runtime-evaluation | 1 + Lang/Tcl/Runtime-evaluation-In-an-environment | 1 + Lang/Tcl/S-Expressions | 1 + Lang/Tcl/SEDOLs | 1 + Lang/Tcl/Safe-addition | 1 + Lang/Tcl/Same-Fringe | 1 + Lang/Tcl/Scope-Function-names-and-labels | 1 + Lang/Tcl/Scope-modifiers | 1 + Lang/Tcl/Secure-temporary-file | 1 + Lang/Tcl/Self-describing-numbers | 1 + Lang/Tcl/Self-referential-sequence | 1 + Lang/Tcl/Semordnilap | 1 + Lang/Tcl/Send-an-unknown-method-call | 1 + Lang/Tcl/Send-email | 1 + Lang/Tcl/Sequence-of-non-squares | 1 + Lang/Tcl/Set | 1 + Lang/Tcl/Set-consolidation | 1 + Lang/Tcl/Set-of-real-numbers | 1 + Lang/Toka/Copy-a-string | 1 + Lang/Toka/Regular-expressions | 1 + Lang/Toka/Rename-a-file | 1 + Lang/TorqueScript/Read-a-file-line-by-line | 1 + Lang/TorqueScript/Rename-a-file | 1 + Lang/TorqueScript/Repeat-a-string | 1 + Lang/TorqueScript/Rock-paper-scissors | 1 + Lang/TorqueScript/Rot-13 | 1 + Lang/Trith/Copy-a-string | 1 + Lang/Turing/Pascals-triangle | 1 + Lang/Turing/Reverse-a-string | 1 + Lang/UNIX-Shell/Binary-digits | 1 + Lang/UNIX-Shell/Copy-a-string | 1 + Lang/UNIX-Shell/Environment-variables | 1 + Lang/UNIX-Shell/Number-reversal-game | 1 + Lang/UNIX-Shell/Pangram-checker | 1 + Lang/UNIX-Shell/Play-recorded-sounds | 1 + Lang/UNIX-Shell/Power-set | 1 + Lang/UNIX-Shell/Pragmatic-directives | 1 + Lang/UNIX-Shell/Primality-by-trial-division | 1 + Lang/UNIX-Shell/Program-name | 1 + Lang/UNIX-Shell/Program-termination | 1 + .../Random-number-generator--included- | 1 + Lang/UNIX-Shell/Rate-counter | 1 + Lang/UNIX-Shell/Read-a-file-line-by-line | 1 + Lang/UNIX-Shell/Read-entire-file | 1 + Lang/UNIX-Shell/Remove-lines-from-a-file | 1 + Lang/UNIX-Shell/Rename-a-file | 1 + Lang/UNIX-Shell/Repeat-a-string | 1 + .../Respond-to-an-unknown-method-call | 1 + Lang/UNIX-Shell/Return-multiple-values | 1 + Lang/UNIX-Shell/Rot-13 | 1 + .../Runtime-evaluation-In-an-environment | 1 + .../Scope-Function-names-and-labels | 1 + Lang/UNIX-Shell/Secure-temporary-file | 1 + Lang/UnixPipes/Power-set | 1 + Lang/UnixPipes/Queue-Definition | 1 + Lang/UnixPipes/Remove-duplicate-elements | 1 + .../Rosetta-Code-Rank-languages-by-popularity | 1 + Lang/Unlambda/Program-termination | 1 + Lang/Unlambda/Reverse-a-string | 1 + Lang/Unlambda/Rot-13 | 1 + .../Arbitrary-precision-integers--included- | 1 + .../Arbitrary-precision-integers-included | 1 - Lang/Ursala/Catalan-numbers | 1 + Lang/Ursala/Environment-variables | 1 + Lang/Ursala/N-queens-problem | 1 + Lang/Ursala/Non-continuous-subsequences | 1 + Lang/Ursala/Non-decimal-radices-Convert | 1 + Lang/Ursala/Nth-root | 1 + Lang/Ursala/Numerical-integration | 1 + ...ical-integration-Gauss-Legendre-Quadrature | 1 + Lang/Ursala/One-dimensional-cellular-automata | 1 + Lang/Ursala/Optional-parameters | 1 + Lang/Ursala/Ordered-Partitions | 1 + Lang/Ursala/Palindrome-detection | 1 + Lang/Ursala/Pangram-checker | 1 + Lang/Ursala/Parametric-polymorphism | 1 + Lang/Ursala/Pascals-triangle | 1 + Lang/Ursala/Perfect-numbers | 1 + Lang/Ursala/Permutation-test | 1 + Lang/Ursala/Permutations | 1 + Lang/Ursala/Plot-coordinate-pairs | 1 + Lang/Ursala/Polynomial-long-division | 1 + Lang/Ursala/Polynomial-regression | 1 + Lang/Ursala/Power-set | 1 + Lang/Ursala/Price-fraction | 1 + Lang/Ursala/Primality-by-trial-division | 1 + Lang/Ursala/Probabilistic-choice | 1 + Lang/Ursala/Random-numbers | 1 + Lang/Ursala/Range-expansion | 1 + Lang/Ursala/Range-extraction | 1 + Lang/Ursala/Ray-casting-algorithm | 1 + Lang/Ursala/Reduced-row-echelon-form | 1 + Lang/Ursala/Remove-duplicate-elements | 1 + Lang/Ursala/Repeat-a-string | 1 + Lang/Ursala/Reverse-a-string | 1 + Lang/Ursala/Roman-numerals-Encode | 1 + Lang/Ursala/Roots-of-unity | 1 + Lang/Ursala/Rot-13 | 1 + Lang/Ursala/Run-length-encoding | 1 + Lang/Ursala/SEDOLs | 1 + Lang/Ursala/Scope-modifiers | 1 + Lang/Ursala/Sequence-of-non-squares | 1 + Lang/V/Copy-a-string | 1 + Lang/V/Power-set | 1 + Lang/V/Primality-by-trial-division | 1 + Lang/V/Prime-decomposition | 1 + Lang/V/Queue-Definition | 1 + Lang/VBA/Catalan-numbers | 1 + Lang/VBA/Palindrome-detection | 1 + Lang/VBA/Pangram-checker | 1 + Lang/VBA/Permutations | 1 + Lang/VBA/Play-recorded-sounds | 1 + Lang/VBA/Program-name | 1 + Lang/VBA/Range-expansion | 1 + Lang/VBA/Range-extraction | 1 + Lang/VBA/Repeat-a-string | 1 + Lang/VBA/Reverse-a-string | 1 + Lang/VBScript/Execute-a-Markov-algorithm | 1 + Lang/VBScript/Palindrome-detection | 1 + Lang/VBScript/Pangram-checker | 1 + Lang/VBScript/Playing-cards | 1 + Lang/VBScript/Program-termination | 1 + Lang/VBScript/Read-entire-file | 1 + Lang/Vala/Program-name | 1 + Lang/Vala/Read-a-file-line-by-line | 1 + Lang/Vala/Read-entire-file | 1 + Lang/Vala/Regular-expressions | 1 + Lang/Vala/Repeat-a-string | 1 + Lang/Vedit-macro-language/Binary-digits | 1 + .../Calendar---for-real-programmers | 1 + .../Calendar-for-real-programmers | 1 - Lang/Vedit-macro-language/Dragon-curve | 1 + .../Environment-variables | 1 + .../One-dimensional-cellular-automata | 1 + .../Vedit-macro-language/Palindrome-detection | 1 + Lang/Vedit-macro-language/Pascals-triangle | 1 + .../Percentage-difference-between-images | 1 + Lang/Vedit-macro-language/Playing-cards | 1 + Lang/Vedit-macro-language/Program-termination | 1 + .../Read-a-configuration-file | 1 + .../Read-a-file-line-by-line | 1 + .../Read-a-specific-line-from-a-file | 1 + Lang/Vedit-macro-language/Read-entire-file | 1 + Lang/Vedit-macro-language/Regular-expressions | 1 + .../Remove-duplicate-elements | 1 + Lang/Vedit-macro-language/Rename-a-file | 1 + Lang/Vedit-macro-language/Repeat-a-string | 1 + Lang/Vedit-macro-language/Reverse-a-string | 1 + .../Roman-numerals-Decode | 1 + .../Roman-numerals-Encode | 1 + Lang/Vedit-macro-language/Rot-13 | 1 + Lang/Vedit-macro-language/Run-length-encoding | 1 + Lang/Visual-Basic-.NET/Binary-digits | 1 + Lang/Visual-Basic-.NET/Brownian-tree | 1 + Lang/Visual-Basic-.NET/Copy-a-string | 1 + Lang/Visual-Basic-.NET/Number-names | 1 + .../One-dimensional-cellular-automata | 1 + .../Read-a-file-line-by-line | 1 + Lang/Visual-Basic-.NET/Read-entire-file | 1 + Lang/Visual-Basic-.NET/Rename-a-file | 1 + Lang/Visual-Basic-.NET/Repeat-a-string | 1 + Lang/Visual-Basic-.NET/Reverse-a-string | 1 + Lang/Visual-Basic-.NET/Rot-13 | 1 + Lang/Visual-Basic/Named-parameters | 1 + Lang/Visual-Basic/Number-names | 1 + Lang/Visual-Basic/Program-name | 1 + Lang/Visual-Basic/Program-termination | 1 + Lang/Visual-Basic/Read-a-configuration-file | 1 + Lang/Visual-Basic/Read-a-file-line-by-line | 1 + Lang/Visual-Basic/Roman-numerals-Encode | 1 + Lang/Whitespace/Binary-digits | 1 + Lang/X86-Assembly/Binary-digits | 1 + .../Calendar---for-real-programmers | 1 + .../Calendar-for-real-programmers | 1 - Lang/X86-Assembly/Dragon-curve | 1 + Lang/X86-Assembly/Rot-13 | 1 + Lang/XPL0/Binary-digits | 1 + Lang/XPL0/Brownian-tree | 1 + Lang/XPL0/Catalan-numbers | 1 + Lang/XPL0/Copy-a-string | 1 + Lang/XPL0/Dragon-curve | 1 + Lang/XPL0/Environment-variables | 1 + .../Guess-the-number-With-feedback--player- | 1 + .../Guess-the-number-With-feedback-player | 1 - Lang/XPL0/N-queens-problem | 1 + Lang/XPL0/Non-decimal-radices-Convert | 1 + Lang/XPL0/Non-decimal-radices-Input | 1 + Lang/XPL0/Non-decimal-radices-Output | 1 + Lang/XPL0/Nth-root | 1 + Lang/XPL0/Number-names | 1 + Lang/XPL0/Number-reversal-game | 1 + Lang/XPL0/Numerical-integration | 1 + Lang/XPL0/One-dimensional-cellular-automata | 1 + Lang/XPL0/Palindrome-detection | 1 + Lang/XPL0/Pangram-checker | 1 + Lang/XPL0/Pascals-triangle | 1 + Lang/XPL0/Permutations | 1 + Lang/XPL0/Permutations-by-swapping | 1 + Lang/XPL0/Pick-random-element | 1 + Lang/XPL0/Pig-the-dice-game | 1 + Lang/XPL0/Pinstripe-Display | 1 + Lang/XPL0/Plot-coordinate-pairs | 1 + Lang/XPL0/Pointers-and-references | 1 + Lang/XPL0/Price-fraction | 1 + Lang/XPL0/Primality-by-trial-division | 1 + Lang/XPL0/Probabilistic-choice | 1 + Lang/XPL0/Program-termination | 1 + Lang/XPL0/Queue-Definition | 1 + Lang/XPL0/Queue-Usage | 1 + Lang/XPL0/Random-number-generator--device- | 1 + Lang/XPL0/Random-number-generator--included- | 1 + Lang/XPL0/Range-expansion | 1 + Lang/XPL0/Rate-counter | 1 + Lang/XPL0/Read-a-specific-line-from-a-file | 1 + Lang/XPL0/Read-entire-file | 1 + Lang/XPL0/Real-constants-and-functions | 1 + Lang/XPL0/Remove-duplicate-elements | 1 + Lang/XPL0/Repeat-a-string | 1 + Lang/XPL0/Resistor-mesh | 1 + Lang/XPL0/Return-multiple-values | 1 + Lang/XPL0/Reverse-a-string | 1 + Lang/XPL0/Roman-numerals-Decode | 1 + Lang/XPL0/Rot-13 | 1 + Lang/XPL0/Run-length-encoding | 1 + Lang/XPL0/Self-describing-numbers | 1 + Lang/XPL0/Semordnilap | 1 + Lang/XPL0/Sequence-of-non-squares | 1 + Lang/XSLT/N-queens-problem | 1 + Lang/XSLT/Named-parameters | 1 + Lang/XSLT/Optional-parameters | 1 + Lang/XSLT/Prime-decomposition | 1 + Lang/XSLT/Roman-numerals-Encode | 1 + Lang/XSLT/Rot-13 | 1 + Lang/Xanadu/N-queens-problem | 1 + Lang/Yorick/Palindrome-detection | 1 + Lang/Yorick/Plot-coordinate-pairs | 1 + Lang/Yorick/Random-numbers | 1 + Lang/Yorick/Read-entire-file | 1 + Lang/Yorick/Rename-a-file | 1 + Lang/Yorick/Repeat-a-string | 1 + Lang/Yorick/Reverse-a-string | 1 + Lang/ZX-Spectrum-Basic/Binary-digits | 1 + Lang/ZX-Spectrum-Basic/Copy-a-string | 1 + Lang/ZX-Spectrum-Basic/Random-numbers | 1 + Lang/ZX-Spectrum-Basic/Rot-13 | 1 + .../Scope-Function-names-and-labels | 1 + Meta/Task.yaml | 542 +++++++++++++++++- .../0DESCRIPTION | 0 .../1META.yaml | 0 ...itrary-precision-integers--included-.acl2} | 0 ...bitrary-precision-integers--included-.ada} | 0 ...trary-precision-integers--included-.alore} | 0 ...ary-precision-integers--included-.bracmat} | 0 ...rbitrary-precision-integers--included-.cs} | 0 ...bitrary-precision-integers--included--1.c} | 0 ...bitrary-precision-integers--included--2.c} | 0 ...trary-precision-integers--included--1.clj} | 0 ...trary-precision-integers--included--2.clj} | 0 ...itrary-precision-integers--included-.lisp} | 0 ...arbitrary-precision-integers--included-.d} | 0 ...arbitrary-precision-integers--included-.e} | 0 ...arbitrary-precision-integers--included-.l} | 0 ...bitrary-precision-integers--included-.erl} | 0 ...rary-precision-integers--included-.factor} | 0 ...trary-precision-integers--included-.frink} | 0 ...bitrary-precision-integers--included-.gap} | 0 ...rbitrary-precision-integers--included-.go} | 0 ...-precision-integers--included-.golfscript} | 0 ...ry-precision-integers--included--1.groovy} | 0 ...ry-precision-integers--included--2.groovy} | 0 ...rbitrary-precision-integers--included-.hs} | 0 ...itrary-precision-integers--included-.icon} | 0 ...arbitrary-precision-integers--included-.j} | 0 ...itrary-precision-integers--included-.java} | 0 ...trary-precision-integers--included-.julia} | 0 ...ary-precision-integers--included-.liberty} | 0 ...arbitrary-precision-integers--included-.m} | 0 ...ary-precision-integers--included--1.maple} | 0 ...ary-precision-integers--included--2.maple} | 0 ...itrary-precision-integers--included-.math} | 0 ...rary-precision-integers--included-.maxima} | 0 ...y-precision-integers--included--1.netrexx} | 0 ...y-precision-integers--included--2.netrexx} | 0 ...y-precision-integers--included--3.netrexx} | 0 ...ary-precision-integers--included--1.ocaml} | 0 ...ary-precision-integers--included--2.ocaml} | 0 ...rbitrary-precision-integers--included-.oz} | 0 ...itrary-precision-integers--included-.pari} | 0 ...bitrary-precision-integers--included-.php} | 0 ...rary-precision-integers--included-.pascal} | 0 ...bitrary-precision-integers--included-.pl6} | 0 ...itrary-precision-integers--included--1.pl} | 0 ...itrary-precision-integers--included--2.pl} | 0 ...itrary-precision-integers--included--3.pl} | 0 ...arbitrary-precision-integers--included-.l} | 0 ...itrary-precision-integers--included-.pike} | 0 ...y-precision-integers--included-.purebasic} | 0 ...rbitrary-precision-integers--included-.py} | 0 ...arbitrary-precision-integers--included-.r} | 0 ...rary-precision-integers--included--1.rexx} | 0 ...rary-precision-integers--included--2.rexx} | 0 ...bitrary-precision-integers--included-.rkt} | 0 ...rbitrary-precision-integers--included-.rb} | 0 ...bitrary-precision-integers--included-.run} | 0 ...rary-precision-integers--included-.simpol} | 0 ...rbitrary-precision-integers--included-.sa} | 0 ...trary-precision-integers--included-.scala} | 0 ...rbitrary-precision-integers--included-.ss} | 0 ...trary-precision-integers--included-.seed7} | 0 ...itrary-precision-integers--included--1.st} | 0 ...itrary-precision-integers--included--2.st} | 0 ...rbitrary-precision-integers--included-.ml} | 0 ...bitrary-precision-integers--included-.txr} | 0 ...bitrary-precision-integers--included-.tcl} | 0 ...rary-precision-integers--included-.ursala} | 0 Task/Binary-digits/0815/binary-digits-1.0815 | 12 + Task/Binary-digits/0815/binary-digits-2.0815 | 4 + Task/Binary-digits/0DESCRIPTION | 7 + Task/Binary-digits/1META.yaml | 4 + Task/Binary-digits/ACL2/binary-digits.acl2 | 15 + Task/Binary-digits/ALGOL-68/binary-digits.alg | 14 + Task/Binary-digits/AWK/binary-digits.awk | 23 + Task/Binary-digits/Ada/binary-digits.ada | 28 + .../AutoHotkey/binary-digits.ahk | 10 + .../Binary-digits/AutoIt/binary-digits.autoit | 15 + .../BBC-BASIC/binary-digits-1.bbc | 16 + .../BBC-BASIC/binary-digits-2.bbc | 12 + .../Batch-File/binary-digits.bat | 14 + Task/Binary-digits/Brainf---/binary-digits.bf | 17 + .../Binary-digits/Burlesque/binary-digits.blq | 4 + Task/Binary-digits/C++/binary-digits.cpp | 25 + Task/Binary-digits/C/binary-digits-1.c | 20 + Task/Binary-digits/C/binary-digits-2.c | 30 + Task/Binary-digits/COBOL/binary-digits.cobol | 26 + Task/Binary-digits/Clojure/binary-digits.clj | 3 + .../CoffeeScript/binary-digits.coffeescript | 4 + .../Common-Lisp/binary-digits.lisp | 1 + Task/Binary-digits/D/binary-digits.d | 6 + Task/Binary-digits/Dart/binary-digits.dart | 25 + .../Binary-digits/Delphi/binary-digits.delphi | 18 + Task/Binary-digits/Elena/binary-digits.elena | 11 + Task/Binary-digits/Erlang/binary-digits.erl | 1 + .../Euphoria/binary-digits.euphoria | 13 + .../Binary-digits/Factor/binary-digits.factor | 5 + Task/Binary-digits/Forth/binary-digits.fth | 4 + Task/Binary-digits/Go/binary-digits.go | 11 + .../Binary-digits/Groovy/binary-digits.groovy | 7 + Task/Binary-digits/Haskell/binary-digits.hs | 16 + Task/Binary-digits/Icon/binary-digits.icon | 23 + Task/Binary-digits/J/binary-digits.j | 7 + Task/Binary-digits/Java/binary-digits.java | 7 + .../Binary-digits/JavaScript/binary-digits.js | 7 + Task/Binary-digits/Joy/binary-digits-1.joy | 5 + Task/Binary-digits/Joy/binary-digits-2.joy | 5 + Task/Binary-digits/K/binary-digits.k | 5 + Task/Binary-digits/LOLCODE/binary-digits.lol | 19 + Task/Binary-digits/Lang5/binary-digits.lang5 | 2 + .../Liberty-BASIC/binary-digits.liberty | 15 + .../Locomotive-Basic/binary-digits.locomotive | 3 + Task/Binary-digits/MATLAB/binary-digits.m | 3 + Task/Binary-digits/Maple/binary-digits.maple | 4 + .../Mathematica/binary-digits.math | 1 + .../Binary-digits/Maxima/binary-digits.maxima | 15 + .../Mercury/binary-digits.mercury | 17 + .../Binary-digits/Modula-3/binary-digits.mod3 | 11 + .../NetRexx/binary-digits.netrexx | 12 + Task/Binary-digits/OCaml/binary-digits.ocaml | 12 + .../Binary-digits/Objeck/binary-digits.objeck | 9 + .../OxygenBasic/binary-digits.oxy | 42 ++ Task/Binary-digits/PARI-GP/binary-digits.pari | 1 + Task/Binary-digits/PHP/binary-digits.php | 4 + Task/Binary-digits/PL-I/binary-digits-1.pli | 1 + Task/Binary-digits/PL-I/binary-digits-2.pli | 7 + Task/Binary-digits/Perl-6/binary-digits.pl6 | 1 + Task/Binary-digits/Perl/binary-digits.pl | 3 + Task/Binary-digits/PicoLisp/binary-digits.l | 8 + .../PowerShell/binary-digits.psh | 1 + .../PureBasic/binary-digits.purebasic | 8 + Task/Binary-digits/Python/binary-digits-1.py | 18 + Task/Binary-digits/Python/binary-digits-2.py | 18 + Task/Binary-digits/Python/binary-digits-3.py | 20 + Task/Binary-digits/REXX/binary-digits-1.rexx | 13 + Task/Binary-digits/REXX/binary-digits-2.rexx | 13 + Task/Binary-digits/REXX/binary-digits-3.rexx | 11 + Task/Binary-digits/Racket/binary-digits.rkt | 3 + Task/Binary-digits/Retro/binary-digits.retro | 1 + Task/Binary-digits/Ruby/binary-digits-1.rb | 3 + Task/Binary-digits/Ruby/binary-digits-2.rb | 3 + Task/Binary-digits/Ruby/binary-digits.rb | 4 + .../Binary-digits/Run-BASIC/binary-digits.run | 14 + Task/Binary-digits/Scala/binary-digits.scala | 3 + Task/Binary-digits/Scheme/binary-digits.ss | 3 + Task/Binary-digits/Seed7/binary-digits.seed7 | 10 + .../Smalltalk/binary-digits-1.st | 3 + .../Smalltalk/binary-digits-2.st | 1 + .../Standard-ML/binary-digits.ml | 3 + .../TI-83-BASIC/binary-digits-1.ti-83 | 19 + .../TI-83-BASIC/binary-digits-2.ti-83 | 9 + .../TI-83-BASIC/binary-digits-3.ti-83 | 5 + Task/Binary-digits/Tcl/binary-digits-1.tcl | 6 + Task/Binary-digits/Tcl/binary-digits-2.tcl | 7 + .../Binary-digits/UNIX-Shell/binary-digits.sh | 9 + .../Vedit-macro-language/binary-digits.vedit | 17 + .../Visual-Basic-.NET/binary-digits.visual | 5 + .../Whitespace/binary-digits-1.ws | 1 + .../Whitespace/binary-digits-2.ws | 33 ++ .../X86-Assembly/binary-digits.x86 | 29 + Task/Binary-digits/XPL0/binary-digits.xpl0 | 17 + .../ZX-Spectrum-Basic/binary-digits.zx | 14 + Task/Brownian-tree/0DESCRIPTION | 9 + Task/Brownian-tree/1META.yaml | 4 + .../AutoHotkey/brownian-tree.ahk | 53 ++ .../Brownian-tree/BBC-BASIC/brownian-tree.bbc | 27 + Task/Brownian-tree/C/brownian-tree-1.c | 65 +++ Task/Brownian-tree/C/brownian-tree-2.c | 43 ++ Task/Brownian-tree/D/brownian-tree.d | 38 ++ .../Brownian-tree/Delphi/brownian-tree.delphi | 54 ++ .../Brownian-tree/Fantom/brownian-tree.fantom | 101 ++++ Task/Brownian-tree/Fortran/brownian-tree.f | 106 ++++ Task/Brownian-tree/Go/brownian-tree-1.go | 85 +++ Task/Brownian-tree/Go/brownian-tree-2.go | 79 +++ Task/Brownian-tree/Haskell/brownian-tree.hs | 46 ++ Task/Brownian-tree/Icon/brownian-tree.icon | 66 +++ Task/Brownian-tree/J/brownian-tree-1.j | 19 + Task/Brownian-tree/J/brownian-tree-2.j | 2 + Task/Brownian-tree/Java/brownian-tree.java | 72 +++ .../JavaScript/brownian-tree-1.js | 128 +++++ .../JavaScript/brownian-tree-2.js | 9 + .../Liberty-BASIC/brownian-tree.liberty | 83 +++ Task/Brownian-tree/Lua/brownian-tree.lua | 67 +++ .../Mathematica/brownian-tree.math | 26 + Task/Brownian-tree/OCaml/brownian-tree.ocaml | 48 ++ .../Brownian-tree/Octave/brownian-tree.octave | 27 + Task/Brownian-tree/Perl/brownian-tree.pl | 158 +++++ Task/Brownian-tree/PicoLisp/brownian-tree.l | 19 + .../PureBasic/brownian-tree.purebasic | 39 ++ Task/Brownian-tree/Python/brownian-tree.py | 101 ++++ Task/Brownian-tree/REXX/brownian-tree.rexx | 108 ++++ Task/Brownian-tree/Ruby/brownian-tree.rb | 56 ++ .../Brownian-tree/Run-BASIC/brownian-tree.run | 26 + Task/Brownian-tree/Scheme/brownian-tree.ss | 108 ++++ Task/Brownian-tree/Seed7/brownian-tree.seed7 | 53 ++ .../TI-83-BASIC/brownian-tree.ti-83 | 27 + Task/Brownian-tree/Tcl/brownian-tree.tcl | 52 ++ .../Visual-Basic-.NET/brownian-tree.visual | 129 +++++ Task/Brownian-tree/XPL0/brownian-tree.xpl0 | 18 + .../0DESCRIPTION | 0 .../1META.yaml | 0 .../calendar---for-real-programmers.alg} | 0 .../Ada/calendar---for-real-programmers.ada} | 0 .../calendar---for-real-programmers.bbc} | 0 .../calendar---for-real-programmers.guiss} | 0 .../calendar---for-real-programmers-1.icon} | 0 .../calendar---for-real-programmers-2.icon} | 0 .../J/calendar---for-real-programmers-1.j} | 0 .../J/calendar---for-real-programmers-2.j} | 0 .../PHP/calendar---for-real-programmers.php} | 0 .../calendar---for-real-programmers.pl6} | 0 .../calendar---for-real-programmers-1.pl} | 0 .../calendar---for-real-programmers-2.pl} | 0 .../calendar---for-real-programmers.l} | 0 .../calendar---for-real-programmers.rexx} | 0 .../calendar---for-real-programmers-1.rb} | 0 .../calendar---for-real-programmers-2.rb} | 0 .../Tcl/calendar---for-real-programmers.tcl} | 0 .../calendar---for-real-programmers.vedit} | 0 .../calendar---for-real-programmers.x86} | 0 Task/Catalan-numbers/0DESCRIPTION | 13 + Task/Catalan-numbers/1META.yaml | 2 + Task/Catalan-numbers/AWK/catalan-numbers.awk | 16 + Task/Catalan-numbers/Ada/catalan-numbers.ada | 16 + .../AutoHotkey/catalan-numbers.ahk | 20 + .../BASIC/catalan-numbers.basic | 18 + .../BBC-BASIC/catalan-numbers.bbc | 8 + .../Bracmat/catalan-numbers-1.bracmat | 55 ++ .../Bracmat/catalan-numbers-2.bracmat | 51 ++ .../Catalan-numbers/Brat/catalan-numbers.brat | 9 + .../Catalan-numbers/C++/catalan-numbers-1.cpp | 60 ++ .../Catalan-numbers/C++/catalan-numbers-2.cpp | 101 ++++ .../Catalan-numbers/C++/catalan-numbers-3.cpp | 26 + .../Catalan-numbers/C++/catalan-numbers-4.cpp | 12 + .../Catalan-numbers/C++/catalan-numbers-5.cpp | 16 + Task/Catalan-numbers/C/catalan-numbers-1.c | 46 ++ Task/Catalan-numbers/C/catalan-numbers-2.c | 114 ++++ .../Clojure/catalan-numbers.clj | 17 + .../Common-Lisp/catalan-numbers.lisp | 28 + Task/Catalan-numbers/D/catalan-numbers.d | 29 + .../Erlang/catalan-numbers.erl | 30 + .../Euphoria/catalan-numbers.euphoria | 23 + .../Factor/catalan-numbers.factor | 23 + .../Fantom/catalan-numbers.fantom | 52 ++ .../Catalan-numbers/Forth/catalan-numbers.fth | 1 + .../Catalan-numbers/Fortran/catalan-numbers.f | 44 ++ .../Frink/catalan-numbers.frink | 3 + Task/Catalan-numbers/GAP/catalan-numbers.gap | 34 ++ Task/Catalan-numbers/Go/catalan-numbers.go | 13 + .../Haskell/catalan-numbers.hs | 10 + .../Catalan-numbers/Icon/catalan-numbers.icon | 11 + Task/Catalan-numbers/J/catalan-numbers.j | 2 + .../Catalan-numbers/Java/catalan-numbers.java | 65 +++ .../JavaScript/catalan-numbers-1.js | 29 + .../JavaScript/catalan-numbers-2.js | 17 + .../Julia/catalan-numbers.julia | 3 + Task/Catalan-numbers/K/catalan-numbers.k | 3 + .../Liberty-BASIC/catalan-numbers.liberty | 53 ++ Task/Catalan-numbers/Lua/catalan-numbers.lua | 13 + .../MATLAB/catalan-numbers-1.m | 5 + .../MATLAB/catalan-numbers-2.m | 3 + .../MATLAB/catalan-numbers-3.m | 28 + .../Mathematica/catalan-numbers-1.math | 1 + .../Mathematica/catalan-numbers-2.math | 18 + .../Maxima/catalan-numbers.maxima | 11 + .../PARI-GP/catalan-numbers-1.pari | 1 + .../PARI-GP/catalan-numbers-2.pari | 1 + .../PARI-GP/catalan-numbers-3.pari | 1 + .../PARI-GP/catalan-numbers-4.pari | 6 + .../PARI-GP/catalan-numbers-5.pari | 1 + Task/Catalan-numbers/PHP/catalan-numbers.php | 33 ++ Task/Catalan-numbers/PL-I/catalan-numbers.pli | 19 + .../Pascal/catalan-numbers.pascal | 19 + .../Perl-6/catalan-numbers.pl6 | 3 + .../Catalan-numbers/Perl/catalan-numbers-1.pl | 4 + .../Catalan-numbers/Perl/catalan-numbers-2.pl | 8 + .../PicoLisp/catalan-numbers.l | 33 ++ .../PlainTeX/catalan-numbers.tex | 22 + .../Prolog/catalan-numbers.pro | 17 + .../PureBasic/catalan-numbers.purebasic | 23 + .../Catalan-numbers/Python/catalan-numbers.py | 44 ++ Task/Catalan-numbers/R/catalan-numbers.r | 4 + .../Catalan-numbers/REXX/catalan-numbers.rexx | 47 ++ .../Racket/catalan-numbers.rkt | 12 + Task/Catalan-numbers/Ruby/catalan-numbers.rb | 42 ++ .../Run-BASIC/catalan-numbers.run | 11 + .../Scala/catalan-numbers.scala | 10 + .../Catalan-numbers/Scheme/catalan-numbers.ss | 8 + .../Standard-ML/catalan-numbers.ml | 32 ++ .../TI-83-BASIC/catalan-numbers.ti-83 | 3 + .../Catalan-numbers/Tcl/catalan-numbers-1.tcl | 19 + .../Catalan-numbers/Tcl/catalan-numbers-2.tcl | 3 + .../Ursala/catalan-numbers.ursala | 8 + Task/Catalan-numbers/VBA/catalan-numbers.vba | 34 ++ .../Catalan-numbers/XPL0/catalan-numbers.xpl0 | 9 + .../0DESCRIPTION | 0 ...c-g-matrix-ng,-contined-fraction-n--1.cpp} | 0 ...c-g-matrix-ng,-contined-fraction-n--2.cpp} | 0 ...c-g-matrix-ng,-contined-fraction-n--3.cpp} | 0 ...c-g-matrix-ng,-contined-fraction-n--4.cpp} | 0 ...c-g-matrix-ng,-contined-fraction-n--5.cpp} | 0 ...c-g-matrix-ng,-contined-fraction-n--6.cpp} | 0 ...c-g-matrix-ng,-contined-fraction-n--7.cpp} | 0 ...ic-g-matrix-ng,-contined-fraction-n--1.rb} | 0 ...ic-g-matrix-ng,-contined-fraction-n--2.rb} | 0 ...ic-g-matrix-ng,-contined-fraction-n--3.rb} | 0 ...ic-g-matrix-ng,-contined-fraction-n--4.rb} | 0 ...c-g-matrix-ng,-contined-fraction-n--1.tcl} | 0 ...c-g-matrix-ng,-contined-fraction-n--2.tcl} | 0 .../0DESCRIPTION | 0 .../1META.yaml | 0 ...-fraction-n1,-contined-fraction-n2--1.cpp} | 0 ...-fraction-n1,-contined-fraction-n2--2.cpp} | 0 ...-fraction-n1,-contined-fraction-n2--3.cpp} | 0 ...-fraction-n1,-contined-fraction-n2--4.cpp} | 0 ...-fraction-n1,-contined-fraction-n2--5.cpp} | 0 ...-fraction-n1,-contined-fraction-n2--6.cpp} | 0 ...-fraction-n1,-contined-fraction-n2--1.tcl} | 0 ...-fraction-n1,-contined-fraction-n2--2.tcl} | 0 Task/Copy-a-string/0DESCRIPTION | 1 + Task/Copy-a-string/1META.yaml | 4 + Task/Copy-a-string/ABAP/copy-a-string.abap | 3 + Task/Copy-a-string/ALGOL-68/copy-a-string.alg | 4 + Task/Copy-a-string/AWK/copy-a-string.awk | 6 + .../ActionScript/copy-a-string.as | 2 + Task/Copy-a-string/Ada/copy-a-string-1.ada | 2 + Task/Copy-a-string/Ada/copy-a-string-2.ada | 3 + Task/Copy-a-string/Ada/copy-a-string-3.ada | 6 + Task/Copy-a-string/Ada/copy-a-string-4.ada | 3 + .../AutoHotkey/copy-a-string.ahk | 2 + .../Copy-a-string/AutoIt/copy-a-string.autoit | 2 + .../Copy-a-string/BBC-BASIC/copy-a-string.bbc | 11 + .../Batch-File/copy-a-string.bat | 2 + .../Bracmat/copy-a-string.bracmat | 8 + Task/Copy-a-string/C++/copy-a-string.cpp | 13 + Task/Copy-a-string/C/copy-a-string-1.c | 60 ++ Task/Copy-a-string/C/copy-a-string-2.c | 22 + Task/Copy-a-string/Clojure/copy-a-string.clj | 3 + .../ColdFusion/copy-a-string.cfm | 2 + .../Common-Lisp/copy-a-string.lisp | 10 + Task/Copy-a-string/D/copy-a-string.d | 12 + .../Copy-a-string/Delphi/copy-a-string.delphi | 15 + Task/Copy-a-string/Erlang/copy-a-string.erl | 2 + .../Euphoria/copy-a-string.euphoria | 2 + .../Factor/copy-a-string-1.factor | 4 + .../Factor/copy-a-string-2.factor | 2 + .../Factor/copy-a-string-3.factor | 2 + Task/Copy-a-string/Forth/copy-a-string.fth | 9 + Task/Copy-a-string/Fortran/copy-a-string.f | 1 + Task/Copy-a-string/GAP/copy-a-string.gap | 13 + Task/Copy-a-string/GML/copy-a-string.gml | 2 + Task/Copy-a-string/GUISS/copy-a-string.guiss | 3 + .../Copy-a-string/Gambas/copy-a-string.gambas | 4 + Task/Copy-a-string/Go/copy-a-string.go | 2 + .../Groovy/copy-a-string-1.groovy | 3 + .../Groovy/copy-a-string-2.groovy | 4 + .../Copy-a-string/HicEst/copy-a-string.hicest | 2 + Task/Copy-a-string/Icon/copy-a-string.icon | 6 + Task/Copy-a-string/J/copy-a-string.j | 2 + Task/Copy-a-string/Java/copy-a-string-1.java | 7 + Task/Copy-a-string/Java/copy-a-string-2.java | 1 + .../JavaScript/copy-a-string-1.js | 4 + .../JavaScript/copy-a-string-2.js | 4 + Task/Copy-a-string/Joy/copy-a-string.joy | 1 + .../KonsolScript/copy-a-string.konsolscript | 2 + Task/Copy-a-string/Lang5/copy-a-string.lang5 | 1 + .../Liberty-BASIC/copy-a-string.liberty | 4 + .../Copy-a-string/Lisaac/copy-a-string.lisaac | 9 + Task/Copy-a-string/Logo/copy-a-string.logo | 10 + Task/Copy-a-string/Lua/copy-a-string.lua | 4 + Task/Copy-a-string/MATLAB/copy-a-string.m | 2 + .../MAXScript/copy-a-string.maxscript | 2 + Task/Copy-a-string/MUMPS/copy-a-string.mumps | 2 + Task/Copy-a-string/Maple/copy-a-string.maple | 13 + .../Mathematica/copy-a-string.math | 2 + .../Copy-a-string/Maxima/copy-a-string.maxima | 19 + .../Metafont/copy-a-string.metafont | 7 + Task/Copy-a-string/Mirah/copy-a-string.mirah | 8 + .../Copy-a-string/Modula-3/copy-a-string.mod3 | 2 + .../Nemerle/copy-a-string.nemerle | 18 + .../NetRexx/copy-a-string.netrexx | 10 + .../NewLISP/copy-a-string.newlisp | 6 + Task/Copy-a-string/OCaml/copy-a-string.ocaml | 1 + .../Oberon-2/copy-a-string.oberon-2 | 10 + .../Copy-a-string/Objeck/copy-a-string.objeck | 2 + .../Objective-C/copy-a-string-1.m | 4 + .../Objective-C/copy-a-string-2.m | 4 + .../Objective-C/copy-a-string-3.m | 2 + .../Objective-C/copy-a-string-4.m | 2 + .../Copy-a-string/Octave/copy-a-string.octave | 1 + .../OxygenBasic/copy-a-string.oxy | 2 + .../PARI-GP/copy-a-string-1.pari | 1 + .../PARI-GP/copy-a-string-2.pari | 2 + Task/Copy-a-string/PHP/copy-a-string.php | 2 + Task/Copy-a-string/PL-I/copy-a-string.pli | 3 + .../Copy-a-string/Pascal/copy-a-string.pascal | 28 + Task/Copy-a-string/Perl-6/copy-a-string-1.pl6 | 6 + Task/Copy-a-string/Perl-6/copy-a-string-2.pl6 | 6 + Task/Copy-a-string/Perl-6/copy-a-string-3.pl6 | 12 + Task/Copy-a-string/Perl/copy-a-string-1.pl | 4 + Task/Copy-a-string/Perl/copy-a-string-2.pl | 4 + Task/Copy-a-string/Perl/copy-a-string-3.pl | 5 + Task/Copy-a-string/Perl/copy-a-string-4.pl | 6 + Task/Copy-a-string/PicoLisp/copy-a-string.l | 3 + Task/Copy-a-string/Pike/copy-a-string.pike | 4 + .../Copy-a-string/Pop11/copy-a-string-1.pop11 | 3 + .../Copy-a-string/Pop11/copy-a-string-2.pop11 | 2 + .../Copy-a-string/PostScript/copy-a-string.ps | 1 + .../PowerShell/copy-a-string-1.psh | 2 + .../PowerShell/copy-a-string-2.psh | 1 + Task/Copy-a-string/ProDOS/copy-a-string.dos | 4 + .../PureBasic/copy-a-string.purebasic | 2 + Task/Copy-a-string/Python/copy-a-string-1.py | 8 + Task/Copy-a-string/Python/copy-a-string-2.py | 6 + Task/Copy-a-string/R/copy-a-string.r | 2 + Task/Copy-a-string/REBOL/copy-a-string.rebol | 23 + Task/Copy-a-string/REXX/copy-a-string.rexx | 2 + Task/Copy-a-string/RLaB/copy-a-string.rlab | 4 + .../Copy-a-string/Raven/copy-a-string-1.raven | 2 + .../Copy-a-string/Raven/copy-a-string-2.raven | 2 + Task/Copy-a-string/Retro/copy-a-string.retro | 1 + Task/Copy-a-string/Ruby/copy-a-string.rb | 4 + .../Copy-a-string/Run-BASIC/copy-a-string.run | 2 + Task/Copy-a-string/SNOBOL4/copy-a-string.sno | 8 + Task/Copy-a-string/Sather/copy-a-string.sa | 7 + Task/Copy-a-string/Scala/copy-a-string.scala | 2 + Task/Copy-a-string/Scheme/copy-a-string.ss | 1 + Task/Copy-a-string/Seed7/copy-a-string.seed7 | 3 + Task/Copy-a-string/Shiny/copy-a-string.shiny | 2 + Task/Copy-a-string/Slate/copy-a-string.slate | 1 + Task/Copy-a-string/Smalltalk/copy-a-string.st | 7 + .../Standard-ML/copy-a-string-1.ml | 4 + .../Standard-ML/copy-a-string-2.ml | 2 + .../TI-83-BASIC/copy-a-string.ti-83 | 2 + .../TI-89-BASIC/copy-a-string.ti-89 | 2 + .../TUSCRIPT/copy-a-string.tuscript | 3 + Task/Copy-a-string/Tcl/copy-a-string.tcl | 2 + Task/Copy-a-string/Toka/copy-a-string.toka | 2 + Task/Copy-a-string/Trith/copy-a-string.trith | 1 + .../Copy-a-string/UNIX-Shell/copy-a-string.sh | 2 + Task/Copy-a-string/V/copy-a-string.v | 1 + .../Visual-Basic-.NET/copy-a-string-1.visual | 9 + .../Visual-Basic-.NET/copy-a-string-2.visual | 2 + Task/Copy-a-string/XPL0/copy-a-string.xpl0 | 13 + .../ZX-Spectrum-Basic/copy-a-string.zx | 2 + Task/Dragon-curve/0DESCRIPTION | 1 + Task/Dragon-curve/1META.yaml | 4 + Task/Dragon-curve/ALGOL-68/dragon-curve.alg | 101 ++++ Task/Dragon-curve/BASIC/dragon-curve.basic | 29 + .../BASIC256/dragon-curve.basic256 | 50 ++ Task/Dragon-curve/BBC-BASIC/dragon-curve.bbc | 18 + Task/Dragon-curve/C/dragon-curve.c | 129 +++++ .../Common-Lisp/dragon-curve.lisp | 19 + Task/Dragon-curve/D/dragon-curve-1.d | 106 ++++ Task/Dragon-curve/D/dragon-curve-2.d | 19 + Task/Dragon-curve/Emacs-Lisp/dragon-curve.l | 92 +++ Task/Dragon-curve/Factor/dragon-curve.factor | 53 ++ Task/Dragon-curve/Forth/dragon-curve-1.fth | 14 + Task/Dragon-curve/Forth/dragon-curve-2.fth | 20 + Task/Dragon-curve/Go/dragon-curve-1.go | 76 +++ Task/Dragon-curve/Go/dragon-curve-2.go | 43 ++ Task/Dragon-curve/Haskell/dragon-curve-1.hs | 18 + Task/Dragon-curve/Haskell/dragon-curve-2.hs | 11 + Task/Dragon-curve/HicEst/dragon-curve.hicest | 30 + Task/Dragon-curve/Icon/dragon-curve.icon | 20 + Task/Dragon-curve/J/dragon-curve-1.j | 4 + Task/Dragon-curve/J/dragon-curve-2.j | 1 + Task/Dragon-curve/J/dragon-curve-3.j | 4 + Task/Dragon-curve/Java/dragon-curve.java | 56 ++ .../Dragon-curve/JavaScript/dragon-curve-1.js | 97 ++++ .../Dragon-curve/JavaScript/dragon-curve-2.js | 10 + .../Liberty-BASIC/dragon-curve.liberty | 56 ++ Task/Dragon-curve/Logo/dragon-curve-1.logo | 13 + Task/Dragon-curve/Logo/dragon-curve-2.logo | 11 + Task/Dragon-curve/Logo/dragon-curve-3.logo | 15 + Task/Dragon-curve/Logo/dragon-curve-4.logo | 24 + Task/Dragon-curve/Logo/dragon-curve-5.logo | 20 + Task/Dragon-curve/Lua/dragon-curve.lua | 93 +++ .../Mathematica/dragon-curve.math | 4 + .../Metafont/dragon-curve.metafont | 20 + Task/Dragon-curve/OCaml/dragon-curve-1.ocaml | 78 +++ Task/Dragon-curve/OCaml/dragon-curve-2.ocaml | 15 + .../Dragon-curve/Pascal/dragon-curve-1.pascal | 43 ++ .../Dragon-curve/Pascal/dragon-curve-2.pascal | 8 + Task/Dragon-curve/Perl-6/dragon-curve.pl6 | 25 + Task/Dragon-curve/PicoLisp/dragon-curve.l | 40 ++ .../Dragon-curve/PostScript/dragon-curve-1.ps | 44 ++ .../Dragon-curve/PostScript/dragon-curve-2.ps | 22 + Task/Dragon-curve/Prolog/dragon-curve.pro | 60 ++ .../PureBasic/dragon-curve.purebasic | 39 ++ Task/Dragon-curve/Python/dragon-curve-1.py | 37 ++ Task/Dragon-curve/Python/dragon-curve-2.py | 18 + Task/Dragon-curve/Python/dragon-curve-3.py | 16 + Task/Dragon-curve/REXX/dragon-curve.rexx | 36 ++ Task/Dragon-curve/Racket/dragon-curve.rkt | 38 ++ Task/Dragon-curve/RapidQ/dragon-curve.rapidq | 44 ++ Task/Dragon-curve/Ruby/dragon-curve.rb | 32 ++ Task/Dragon-curve/Run-BASIC/dragon-curve.run | 30 + Task/Dragon-curve/Seed7/dragon-curve.seed7 | 48 ++ .../TI-89-BASIC/dragon-curve.ti-89 | 17 + Task/Dragon-curve/Tcl/dragon-curve.tcl | 42 ++ .../Vedit-macro-language/dragon-curve.vedit | 100 ++++ .../X86-Assembly/dragon-curve.x86 | 62 ++ Task/Dragon-curve/XPL0/dragon-curve.xpl0 | 26 + Task/Environment-variables/0DESCRIPTION | 1 + Task/Environment-variables/1META.yaml | 5 + .../ALGOL-68/environment-variables.alg | 1 + .../AWK/environment-variables-1.awk | 2 + .../AWK/environment-variables-2.awk | 2 + .../Ada/environment-variables-1.ada | 7 + .../Ada/environment-variables-2.ada | 11 + .../Ada/environment-variables-3.ada | 15 + .../AutoHotkey/environment-variables.ahk | 2 + .../BASIC/environment-variables-1.basic | 2 + .../BASIC/environment-variables-2.basic | 3 + .../BBC-BASIC/environment-variables.bbc | 10 + .../Batch-File/environment-variables-1.bat | 1 + .../Batch-File/environment-variables-2.bat | 2 + .../C++/environment-variables.cpp | 8 + .../C/environment-variables.c | 7 + .../Clojure/environment-variables.clj | 1 + .../environment-variables.coffeescript | 2 + .../Common-Lisp/environment-variables-1.lisp | 1 + .../Common-Lisp/environment-variables-2.lisp | 1 + .../Common-Lisp/environment-variables-3.lisp | 1 + .../Common-Lisp/environment-variables-4.lisp | 1 + .../D/environment-variables-1.d | 5 + .../D/environment-variables-2.d | 5 + .../Delphi/environment-variables.delphi | 9 + .../E/environment-variables.e | 1 + .../Eiffel/environment-variables.e | 13 + .../Emacs-Lisp/environment-variables.l | 1 + .../Euphoria/environment-variables.euphoria | 1 + .../Factor/environment-variables.factor | 1 + .../Forth/environment-variables.fth | 1 + .../Fortran/environment-variables.f | 15 + .../Go/environment-variables-1.go | 10 + .../Go/environment-variables-2.go | 19 + .../Groovy/environment-variables.groovy | 1 + .../Haskell/environment-variables.hs | 3 + .../HicEst/environment-variables.hicest | 4 + .../Icon/environment-variables.icon | 7 + .../J/environment-variables.j | 1 + .../Java/environment-variables.java | 2 + .../JavaScript/environment-variables.js | 3 + .../Joy/environment-variables.joy | 1 + .../K/environment-variables.k | 1 + .../LSL/environment-variables.lsl | 8 + .../environment-variables-1.liberty | 2 + .../environment-variables-2.liberty | 29 + .../Lua/environment-variables.lua | 1 + .../MATLAB/environment-variables.m | 3 + .../MUMPS/environment-variables.mumps | 2 + .../Mathematica/environment-variables.math | 1 + .../Mercury/environment-variables.mercury | 18 + .../NSIS/environment-variables.nsis | 3 + .../NetRexx/environment-variables.netrexx | 60 ++ .../NewLISP/environment-variables.newlisp | 4 + .../OCaml/environment-variables.ocaml | 1 + .../Objective-C/environment-variables.m | 1 + .../Oz/environment-variables.oz | 1 + .../PARI-GP/environment-variables-1.pari | 1 + .../PARI-GP/environment-variables-2.pari | 1 + .../PARI-GP/environment-variables-3.pari | 1 + .../PARI-GP/environment-variables-4.pari | 1 + .../PARI-GP/environment-variables-5.pari | 1 + .../PHP/environment-variables.php | 1 + .../Perl-6/environment-variables.pl6 | 1 + .../Perl/environment-variables.pl | 1 + .../PicoLisp/environment-variables.l | 5 + .../PowerShell/environment-variables-1.psh | 1 + .../PowerShell/environment-variables-2.psh | 1 + .../environment-variables-1.purebasic | 1 + .../environment-variables-2.purebasic | 8 + .../Python/environment-variables.py | 2 + .../R/environment-variables.r | 1 + .../REBOL/environment-variables.rebol | 1 + .../REXX/environment-variables-1.rexx | 3 + .../REXX/environment-variables-2.rexx | 3 + .../REXX/environment-variables-3.rexx | 1 + .../Racket/environment-variables.rkt | 2 + .../Retro/environment-variables.retro | 2 + .../Ruby/environment-variables.rb | 1 + .../Run-BASIC/environment-variables.run | 20 + .../SNOBOL4/environment-variables.sno | 2 + .../Seed7/environment-variables.seed7 | 6 + .../Slate/environment-variables.slate | 2 + .../Standard-ML/environment-variables.ml | 1 + .../TXR/environment-variables-1.txr | 4 + .../TXR/environment-variables-2.txr | 6 + .../TXR/environment-variables-3.txr | 7 + .../Tcl/environment-variables.tcl | 1 + .../UNIX-Shell/environment-variables-1.sh | 1 + .../UNIX-Shell/environment-variables-2.sh | 1 + .../Ursala/environment-variables.ursala | 5 + .../environment-variables-1.vedit | 2 + .../environment-variables-2.vedit | 1 + .../XPL0/environment-variables.xpl0 | 28 + Task/Execute-SNUSP/0DESCRIPTION | 3 + Task/Execute-SNUSP/1META.yaml | 3 + Task/Execute-a-Markov-algorithm/0DESCRIPTION | 127 ++++ Task/Execute-a-Markov-algorithm/1META.yaml | 2 + .../Ada/execute-a-markov-algorithm-1.ada | 26 + .../Ada/execute-a-markov-algorithm-2.ada | 81 +++ .../Ada/execute-a-markov-algorithm-3.ada | 48 ++ .../AutoHotkey/execute-a-markov-algorithm.ahk | 354 ++++++++++++ .../BBC-BASIC/execute-a-markov-algorithm.bbc | 35 ++ .../C++/execute-a-markov-algorithm.cpp | 113 ++++ .../C/execute-a-markov-algorithm-1.c | 203 +++++++ .../C/execute-a-markov-algorithm-2.c | 19 + .../D/execute-a-markov-algorithm.d | 32 ++ .../Go/execute-a-markov-algorithm-1.go | 91 +++ .../Go/execute-a-markov-algorithm-2.go | 20 + .../execute-a-markov-algorithm-1.groovy | 25 + .../execute-a-markov-algorithm-2.groovy | 33 ++ .../Haskell/execute-a-markov-algorithm.hs | 43 ++ .../Icon/execute-a-markov-algorithm.icon | 22 + .../J/execute-a-markov-algorithm-1.j | 30 + .../J/execute-a-markov-algorithm-2.j | 13 + .../execute-a-markov-algorithm-1.math | 12 + .../execute-a-markov-algorithm-2.math | 18 + .../Perl/execute-a-markov-algorithm.pl | 18 + .../PicoLisp/execute-a-markov-algorithm.l | 19 + .../execute-a-markov-algorithm.purebasic | 113 ++++ .../Python/execute-a-markov-algorithm.py | 134 +++++ .../REXX/execute-a-markov-algorithm.rexx | 41 ++ .../Ruby/execute-a-markov-algorithm.rb | 20 + .../Scala/execute-a-markov-algorithm-1.scala | 30 + .../Scala/execute-a-markov-algorithm-2.scala | 16 + .../Scheme/execute-a-markov-algorithm.ss | 47 ++ .../Tcl/execute-a-markov-algorithm-1.tcl | 41 ++ .../Tcl/execute-a-markov-algorithm-2.tcl | 28 + .../execute-a-markov-algorithm-1.vbscript | 73 +++ .../execute-a-markov-algorithm-2.vbscript | 60 ++ .../execute-a-markov-algorithm-3.vbscript | 5 + .../0DESCRIPTION | 0 .../1META.yaml | 0 ...ess-the-number-with-feedback--player-.ada} | 0 ...ess-the-number-with-feedback--player-.ahk} | 0 ...ess-the-number-with-feedback--player-.bbc} | 0 ...ess-the-number-with-feedback--player-.cpp} | 0 ...guess-the-number-with-feedback--player-.c} | 0 ...ess-the-number-with-feedback--player-.clj} | 0 ...guess-the-number-with-feedback--player-.d} | 0 ...he-number-with-feedback--player-.euphoria} | 0 ...-the-number-with-feedback--player-.fantom} | 0 ...guess-the-number-with-feedback--player-.f} | 0 ...ss-the-number-with-feedback--player--1.go} | 0 ...ss-the-number-with-feedback--player--2.go} | 0 ...ss-the-number-with-feedback--player-.icon} | 0 ...ess-the-number-with-feedback--player--1.j} | 0 ...ess-the-number-with-feedback--player--2.j} | 0 ...ss-the-number-with-feedback--player-.java} | 0 ...uess-the-number-with-feedback--player-.js} | 0 ...the-number-with-feedback--player-.liberty} | 0 ...ss-the-number-with-feedback--player-.math} | 0 ...ss-the-number-with-feedback--player-.mod2} | 0 ...guess-the-number-with-feedback--player-.m} | 0 ...ss-the-number-with-feedback--player-.pari} | 0 ...-the-number-with-feedback--player-.pascal} | 0 ...ess-the-number-with-feedback--player-.pl6} | 0 ...uess-the-number-with-feedback--player-.pl} | 0 ...guess-the-number-with-feedback--player-.l} | 0 ...e-number-with-feedback--player-.purebasic} | 0 ...ss-the-number-with-feedback--player--1.py} | 0 ...ss-the-number-with-feedback--player--2.py} | 0 ...-the-number-with-feedback--player--1.rexx} | 0 ...-the-number-with-feedback--player--2.rexx} | 0 ...uess-the-number-with-feedback--player-.rb} | 0 ...uess-the-number-with-feedback--player-.ss} | 0 ...ss-the-number-with-feedback--player--1.st} | 0 ...ss-the-number-with-feedback--player--2.st} | 0 ...ss-the-number-with-feedback--player--3.st} | 0 ...ss-the-number-with-feedback--player--4.st} | 0 ...ess-the-number-with-feedback--player-.tcl} | 0 ...ss-the-number-with-feedback--player-.xpl0} | 0 .../largest-int-from-concatenated-ints-2.rb | 2 +- .../6800-Assembly/loops-infinite.6800 | 31 + Task/N-queens-problem/0DESCRIPTION | 4 + .../ALGOL-68/n-queens-problem.alg | 51 ++ .../N-queens-problem/Ada/n-queens-problem.ada | 50 ++ .../AutoHotkey/n-queens-problem-1.ahk | 80 +++ .../AutoHotkey/n-queens-problem-2.ahk | 90 +++ .../BBC-BASIC/n-queens-problem.bbc | 61 ++ .../BCPL/n-queens-problem-1.bcpl | 30 + .../BCPL/n-queens-problem-2.bcpl | 134 +++++ Task/N-queens-problem/C/n-queens-problem-1.c | 31 + Task/N-queens-problem/C/n-queens-problem-2.c | 38 ++ Task/N-queens-problem/C/n-queens-problem-3.c | 91 +++ .../Clojure/n-queens-problem.clj | 23 + .../n-queens-problem.coffeescript | 111 ++++ .../Common-Lisp/n-queens-problem.lisp | 22 + .../Curry/n-queens-problem-1.curry | 58 ++ .../Curry/n-queens-problem-2.curry | 34 ++ .../Curry/n-queens-problem-3.curry | 59 ++ Task/N-queens-problem/D/n-queens-problem-1.d | 44 ++ Task/N-queens-problem/D/n-queens-problem-2.d | 90 +++ .../Dart/n-queens-problem.dart | 65 +++ .../Factor/n-queens-problem.factor | 27 + .../Forth/n-queens-problem.fth | 29 + .../Fortran/n-queens-problem-1.f | 101 ++++ .../Fortran/n-queens-problem-2.f | 72 +++ .../Fortran/n-queens-problem-3.f | 106 ++++ Task/N-queens-problem/Go/n-queens-problem.go | 61 ++ .../Groovy/n-queens-problem-1.groovy | 24 + .../Groovy/n-queens-problem-2.groovy | 51 ++ .../Groovy/n-queens-problem-3.groovy | 8 + .../Haskell/n-queens-problem.hs | 31 + .../Heron/n-queens-problem.heron | 95 +++ .../Icon/n-queens-problem-1.icon | 16 + .../Icon/n-queens-problem-2.icon | 3 + .../Icon/n-queens-problem-3.icon | 35 ++ Task/N-queens-problem/J/n-queens-problem.j | 4 + .../Java/n-queens-problem.java | 48 ++ .../n-queens-problem.locomotive | 52 ++ .../Logo/n-queens-problem.logo | 17 + .../N-queens-problem/Lua/n-queens-problem.lua | 46 ++ .../MUMPS/n-queens-problem.mumps | 268 +++++++++ .../Mathematica/n-queens-problem-1.math | 9 + .../Mathematica/n-queens-problem-2.math | 5 + .../Maxima/n-queens-problem.maxima | 18 + .../OCaml/n-queens-problem-1.ocaml | 59 ++ .../OCaml/n-queens-problem-2.ocaml | 32 ++ .../Objeck/n-queens-problem.objeck | 57 ++ Task/N-queens-problem/Oz/n-queens-problem.oz | 68 +++ .../N-queens-problem/PHP/n-queens-problem.php | 175 ++++++ .../Pascal/n-queens-problem.pascal | 81 +++ .../Perl-6/n-queens-problem.pl6 | 30 + .../N-queens-problem/Perl/n-queens-problem.pl | 41 ++ .../PicoLisp/n-queens-problem-1.l | 11 + .../PicoLisp/n-queens-problem-2.l | 16 + .../PowerBASIC/n-queens-problem.powerbasic | 40 ++ .../Prolog/n-queens-problem-1.pro | 21 + .../Prolog/n-queens-problem-2.pro | 28 + .../Prolog/n-queens-problem-3.pro | 20 + .../PureBasic/n-queens-problem.purebasic | 80 +++ .../Python/n-queens-problem-1.py | 8 + .../Python/n-queens-problem-2.py | 2 + .../Python/n-queens-problem-3.py | 17 + .../Python/n-queens-problem-4.py | 19 + Task/N-queens-problem/R/n-queens-problem.r | 28 + .../REXX/n-queens-problem.rexx | 64 +++ .../Rascal/n-queens-problem.rascal | 10 + .../N-queens-problem/Ruby/n-queens-problem.rb | 59 ++ .../N-queens-problem/SAS/n-queens-problem.sas | 58 ++ .../SNOBOL4/n-queens-problem.sno | 23 + .../Scala/n-queens-problem.scala | 20 + .../Standard-ML/n-queens-problem.ml | 39 ++ .../SystemVerilog/n-queens-problem.v | 37 ++ .../N-queens-problem/Tcl/n-queens-problem.tcl | 47 ++ .../Ursala/n-queens-problem.ursala | 18 + .../XPL0/n-queens-problem.xpl0 | 57 ++ .../XSLT/n-queens-problem-1.xslt | 5 + .../XSLT/n-queens-problem-2.xslt | 126 ++++ .../Xanadu/n-queens-problem.xanadu | 69 +++ Task/Named-parameters/0DESCRIPTION | 13 + Task/Named-parameters/1META.yaml | 2 + .../ALGOL-68/named-parameters.alg | 28 + .../Ada/named-parameters-1.ada | 1 + .../Ada/named-parameters-2.ada | 4 + .../named-parameters-1.applescript | 9 + .../named-parameters-2.applescript | 4 + .../AutoHotkey/named-parameters.ahk | 12 + .../C++/named-parameters-1.cpp | 27 + .../C++/named-parameters-2.cpp | 1 + .../C++/named-parameters-3.cpp | 1 + .../C++/named-parameters-4.cpp | 26 + .../C++/named-parameters-5.cpp | 5 + Task/Named-parameters/C/named-parameters.c | 48 ++ .../Clojure/named-parameters-1.clj | 4 + .../Clojure/named-parameters-2.clj | 2 + .../Clojure/named-parameters-3.clj | 3 + .../Common-Lisp/named-parameters-1.lisp | 6 + .../Common-Lisp/named-parameters-2.lisp | 8 + Task/Named-parameters/E/named-parameters-1.e | 11 + Task/Named-parameters/E/named-parameters-2.e | 8 + .../Fortran/named-parameters-1.f | 5 + .../Fortran/named-parameters-2.f | 4 + .../Fortran/named-parameters-3.f | 5 + .../Fortran/named-parameters-4.f | 4 + .../Haskell/named-parameters-1.hs | 8 + .../Haskell/named-parameters-2.hs | 6 + .../Icon/named-parameters.icon | 20 + Task/Named-parameters/J/named-parameters.j | 26 + .../Java/named-parameters.java | 1 + .../JavaScript/named-parameters.js | 12 + .../Named-parameters/Lua/named-parameters.lua | 8 + .../MATLAB/named-parameters.m | 15 + .../Mathematica/named-parameters.math | 7 + .../Modula-3/named-parameters-1.mod3 | 1 + .../Modula-3/named-parameters-2.mod3 | 4 + .../Nemerle/named-parameters.nemerle | 4 + .../OCaml/named-parameters.ocaml | 6 + .../Objective-C/named-parameters-1.m | 8 + .../Objective-C/named-parameters-2.m | 10 + .../Objective-C/named-parameters-3.m | 2 + .../Named-parameters/Oz/named-parameters-1.oz | 15 + .../Named-parameters/Oz/named-parameters-2.oz | 10 + .../Perl-6/named-parameters-1.pl6 | 3 + .../Perl-6/named-parameters-2.pl6 | 5 + .../Perl-6/named-parameters-3.pl6 | 3 + .../Perl/named-parameters-1.pl | 12 + .../Perl/named-parameters-2.pl | 3 + .../PicoLisp/named-parameters-1.l | 6 + .../PicoLisp/named-parameters-2.l | 7 + .../PowerShell/named-parameters-1.psh | 3 + .../PowerShell/named-parameters-2.psh | 5 + .../PowerShell/named-parameters-3.psh | 3 + .../PowerShell/named-parameters-4.psh | 3 + .../Python/named-parameters-1.py | 5 + .../Python/named-parameters-2.py | 107 ++++ Task/Named-parameters/R/named-parameters.r | 10 + .../REXX/named-parameters.rexx | 76 +++ .../Racket/named-parameters.rkt | 12 + .../Ruby/named-parameters-1.rb | 6 + .../Ruby/named-parameters-2.rb | 11 + .../Ruby/named-parameters-3.rb | 8 + .../Scala/named-parameters-1.scala | 1 + .../Scala/named-parameters-2.scala | 5 + .../Scheme/named-parameters-1.ss | 21 + .../Scheme/named-parameters-2.ss | 8 + .../Smalltalk/named-parameters.st | 9 + .../Suneido/named-parameters-1.suneido | 6 + .../Suneido/named-parameters-2.suneido | 1 + .../Tcl/named-parameters-1.tcl | 11 + .../Tcl/named-parameters-2.tcl | 18 + .../Visual-Basic/named-parameters.vb | 8 + .../XSLT/named-parameters.xslt | 4 + Task/Nautical-bell/0DESCRIPTION | 4 + Task/Nautical-bell/1META.yaml | 3 + Task/Nautical-bell/D/nautical-bell.d | 50 ++ Task/Nautical-bell/Perl-6/nautical-bell.pl6 | 41 ++ Task/Nautical-bell/Python/nautical-bell.py | 63 ++ Task/Nautical-bell/REXX/nautical-bell.rexx | 24 + Task/Nautical-bell/Tcl/nautical-bell.tcl | 75 +++ Task/Non-continuous-subsequences/0DESCRIPTION | 11 + Task/Non-continuous-subsequences/1META.yaml | 2 + .../non-continuous-subsequences-1.alg | 35 ++ .../non-continuous-subsequences-2.alg | 47 ++ .../Ada/non-continuous-subsequences.ada | 37 ++ .../non-continuous-subsequences.ahk | 20 + .../BBC-BASIC/non-continuous-subsequences.bbc | 32 ++ .../non-continuous-subsequences.bracmat | 20 + .../C/non-continuous-subsequences-1.c | 20 + .../C/non-continuous-subsequences-2.c | 25 + .../C/non-continuous-subsequences-3.c | 51 ++ .../Clojure/non-continuous-subsequences.clj | 16 + ...non-continuous-subsequences-1.coffeescript | 57 ++ ...non-continuous-subsequences-2.coffeescript | 16 + .../non-continuous-subsequences-1.lisp | 21 + .../non-continuous-subsequences-2.lisp | 16 + .../D/non-continuous-subsequences-1.d | 18 + .../D/non-continuous-subsequences-2.d | 43 ++ .../Go/non-continuous-subsequences.go | 39 ++ .../Haskell/non-continuous-subsequences-1.hs | 9 + .../Haskell/non-continuous-subsequences-2.hs | 4 + .../Haskell/non-continuous-subsequences-3.hs | 10 + .../Haskell/non-continuous-subsequences-4.hs | 8 + .../Haskell/non-continuous-subsequences-5.hs | 15 + .../J/non-continuous-subsequences-1.j | 4 + .../J/non-continuous-subsequences-2.j | 10 + .../J/non-continuous-subsequences-3.j | 2 + .../JavaScript/non-continuous-subsequences.js | 24 + .../non-continuous-subsequences-1.math | 3 + .../non-continuous-subsequences-2.math | 1 + .../OCaml/non-continuous-subsequences.ocaml | 22 + .../Oz/non-continuous-subsequences.oz | 25 + .../Perl-6/non-continuous-subsequences.pl6 | 11 + .../Perl/non-continuous-subsequences.pl | 17 + .../PicoLisp/non-continuous-subsequences.l | 15 + .../Pop11/non-continuous-subsequences-1.pop11 | 24 + .../Pop11/non-continuous-subsequences-2.pop11 | 2 + .../non-continuous-subsequences.psh | 69 +++ .../Prolog/non-continuous-subsequences-1.pro | 25 + .../Prolog/non-continuous-subsequences-2.pro | 2 + .../Python/non-continuous-subsequences-1.py | 9 + .../Python/non-continuous-subsequences-2.py | 40 ++ .../R/non-continuous-subsequences.r | 17 + .../REXX/non-continuous-subsequences.rexx | 33 ++ .../Ruby/non-continuous-subsequences.rb | 21 + .../Scheme/non-continuous-subsequences.ss | 18 + .../non-continuous-subsequences.ml | 21 + .../Tcl/non-continuous-subsequences.tcl | 23 + .../Ursala/non-continuous-subsequences.ursala | 7 + Task/Non-decimal-radices-Convert/0DESCRIPTION | 7 + Task/Non-decimal-radices-Convert/1META.yaml | 2 + .../ACL2/non-decimal-radices-convert.acl2 | 35 ++ .../non-decimal-radices-convert-1.alg | 14 + .../non-decimal-radices-convert-2.alg | 36 ++ .../AWK/non-decimal-radices-convert.awk | 28 + .../Ada/non-decimal-radices-convert.ada | 54 ++ .../non-decimal-radices-convert-1.ahk | 25 + .../non-decimal-radices-convert-2.ahk | 13 + .../BBC-BASIC/non-decimal-radices-convert.bbc | 28 + .../non-decimal-radices-convert.bracmat | 23 + .../C++/non-decimal-radices-convert.cpp | 29 + .../C/non-decimal-radices-convert.c | 48 ++ .../non-decimal-radices-convert.cos | 67 +++ .../non-decimal-radices-convert.lisp | 2 + .../D/non-decimal-radices-convert-1.d | 8 + .../D/non-decimal-radices-convert-2.d | 62 ++ .../E/non-decimal-radices-convert-1.e | 4 + .../E/non-decimal-radices-convert-2.e | 5 + .../non-decimal-radices-convert.euphoria | 35 ++ .../Factor/non-decimal-radices-convert.factor | 4 + .../Forth/non-decimal-radices-convert-1.fth | 6 + .../Forth/non-decimal-radices-convert-2.fth | 1 + .../Fortran/non-decimal-radices-convert.f | 46 ++ .../Go/non-decimal-radices-convert.go | 21 + .../non-decimal-radices-convert-1.groovy | 2 + .../non-decimal-radices-convert-2.groovy | 11 + .../Haskell/non-decimal-radices-convert-1.hs | 4 + .../Haskell/non-decimal-radices-convert-2.hs | 21 + .../Haskell/non-decimal-radices-convert-3.hs | 4 + .../non-decimal-radices-convert-1.hicest | 28 + .../non-decimal-radices-convert-2.hicest | 1 + .../Icon/non-decimal-radices-convert.icon | 26 + .../J/non-decimal-radices-convert-1.j | 2 + .../J/non-decimal-radices-convert-2.j | 3 + .../J/non-decimal-radices-convert-3.j | 7 + .../J/non-decimal-radices-convert-4.j | 6 + .../Java/non-decimal-radices-convert-1.java | 7 + .../Java/non-decimal-radices-convert-2.java | 7 + .../JavaScript/non-decimal-radices-convert.js | 5 + .../non-decimal-radices-convert.liberty | 32 ++ .../M4/non-decimal-radices-convert.m4 | 3 + .../non-decimal-radices-convert.math | 2 + .../non-decimal-radices-convert.netrexx | 39 ++ .../OCaml/non-decimal-radices-convert-1.ocaml | 12 + .../OCaml/non-decimal-radices-convert-2.ocaml | 32 ++ .../PARI-GP/non-decimal-radices-convert.pari | 17 + .../PHP/non-decimal-radices-convert-1.php | 1 + .../PHP/non-decimal-radices-convert-2.php | 1 + .../PHP/non-decimal-radices-convert-3.php | 1 + .../PHP/non-decimal-radices-convert-4.php | 12 + .../PL-I/non-decimal-radices-convert.pli | 12 + .../Pascal/non-decimal-radices-convert.pascal | 45 ++ .../Perl-6/non-decimal-radices-convert.pl6 | 7 + .../Perl/non-decimal-radices-convert-1.pl | 5 + .../Perl/non-decimal-radices-convert-2.pl | 14 + .../PicoLisp/non-decimal-radices-convert.l | 22 + .../Pop11/non-decimal-radices-convert-1.pop11 | 3 + .../Pop11/non-decimal-radices-convert-2.pop11 | 3 + .../non-decimal-radices-convert.purebasic | 36 ++ .../Python/non-decimal-radices-convert-1.py | 1 + .../Python/non-decimal-radices-convert-2.py | 17 + .../REXX/non-decimal-radices-convert.rexx | 46 ++ .../Ruby/non-decimal-radices-convert-1.rb | 2 + .../Ruby/non-decimal-radices-convert-2.rb | 1 + .../Ruby/non-decimal-radices-convert-3.rb | 32 ++ .../Run-BASIC/non-decimal-radices-convert.run | 28 + .../Slate/non-decimal-radices-convert.slate | 2 + .../non-decimal-radices-convert.ml | 25 + .../Tcl/non-decimal-radices-convert.tcl | 28 + .../non-decimal-radices-convert-1.ursala | 6 + .../non-decimal-radices-convert-2.ursala | 11 + .../XPL0/non-decimal-radices-convert.xpl0 | 31 + Task/Non-decimal-radices-Input/0DESCRIPTION | 9 + Task/Non-decimal-radices-Input/1META.yaml | 2 + .../ALGOL-68/non-decimal-radices-input.alg | 25 + .../Ada/non-decimal-radices-input.ada | 14 + .../BBC-BASIC/non-decimal-radices-input.bbc | 10 + .../C++/non-decimal-radices-input.cpp | 23 + .../C/non-decimal-radices-input-1.c | 19 + .../C/non-decimal-radices-input-2.c | 25 + .../non-decimal-radices-input.lisp | 1 + .../D/non-decimal-radices-input.d | 8 + .../E/non-decimal-radices-input.e | 5 + .../Factor/non-decimal-radices-input.factor | 2 + .../Forth/non-decimal-radices-input.fth | 6 + .../Fortran/non-decimal-radices-input.f | 23 + .../Go/non-decimal-radices-input.go | 55 ++ .../Haskell/non-decimal-radices-input.hs | 6 + .../HicEst/non-decimal-radices-input.hicest | 4 + .../Icon/non-decimal-radices-input.icon | 12 + .../J/non-decimal-radices-input-1.j | 1 + .../J/non-decimal-radices-input-2.j | 1 + .../J/non-decimal-radices-input-3.j | 6 + .../J/non-decimal-radices-input-4.j | 2 + .../J/non-decimal-radices-input-5.j | 2 + .../J/non-decimal-radices-input-6.j | 2 + .../Java/non-decimal-radices-input-1.java | 3 + .../Java/non-decimal-radices-input-2.java | 1 + .../Java/non-decimal-radices-input-3.java | 3 + .../JavaScript/non-decimal-radices-input-1.js | 6 + .../JavaScript/non-decimal-radices-input-2.js | 12 + .../JavaScript/non-decimal-radices-input-3.js | 2 + .../JavaScript/non-decimal-radices-input-4.js | 10 + .../JavaScript/non-decimal-radices-input-5.js | 1 + .../JavaScript/non-decimal-radices-input-6.js | 2 + .../Lua/non-decimal-radices-input.lua | 4 + .../non-decimal-radices-input.math | 5 + .../OCaml/non-decimal-radices-input-1.ocaml | 8 + .../OCaml/non-decimal-radices-input-2.ocaml | 6 + .../Oz/non-decimal-radices-input.oz | 4 + .../PARI-GP/non-decimal-radices-input.pari | 16 + .../PHP/non-decimal-radices-input-1.php | 7 + .../PHP/non-decimal-radices-input-2.php | 5 + .../PHP/non-decimal-radices-input-3.php | 5 + .../PL-I/non-decimal-radices-input.pli | 6 + .../Perl-6/non-decimal-radices-input-1.pl6 | 4 + .../Perl-6/non-decimal-radices-input-2.pl6 | 37 ++ .../Perl/non-decimal-radices-input.pl | 15 + .../PicoLisp/non-decimal-radices-input.l | 9 + .../non-decimal-radices-input.purebasic | 5 + .../Python/non-decimal-radices-input.py | 25 + .../R/non-decimal-radices-input.r | 8 + .../REXX/non-decimal-radices-input.rexx | 85 +++ .../Ruby/non-decimal-radices-input-1.rb | 9 + .../Ruby/non-decimal-radices-input-2.rb | 5 + .../Ruby/non-decimal-radices-input-3.rb | 5 + .../Ruby/non-decimal-radices-input-4.rb | 5 + .../Scheme/non-decimal-radices-input.ss | 8 + .../Standard-ML/non-decimal-radices-input.ml | 10 + .../Tcl/non-decimal-radices-input-1.tcl | 16 + .../Tcl/non-decimal-radices-input-2.tcl | 10 + .../XPL0/non-decimal-radices-input.xpl0 | 12 + Task/Non-decimal-radices-Output/0DESCRIPTION | 5 + Task/Non-decimal-radices-Output/1META.yaml | 2 + .../ALGOL-68/non-decimal-radices-output.alg | 5 + .../AWK/non-decimal-radices-output.awk | 7 + .../Ada/non-decimal-radices-output.ada | 12 + .../AutoHotkey/non-decimal-radices-output.ahk | 7 + .../BBC-BASIC/non-decimal-radices-output.bbc | 8 + .../C++/non-decimal-radices-output.cpp | 12 + .../C/non-decimal-radices-output.c | 11 + .../Clojure/non-decimal-radices-output.clj | 6 + .../non-decimal-radices-output.lisp | 2 + .../D/non-decimal-radices-output-1.d | 8 + .../D/non-decimal-radices-output-2.d | 2 + .../E/non-decimal-radices-output.e | 7 + .../non-decimal-radices-output.euphoria | 3 + .../Factor/non-decimal-radices-output.factor | 1 + .../Forth/non-decimal-radices-output-1.fth | 5 + .../Forth/non-decimal-radices-output-2.fth | 3 + .../Fortran/non-decimal-radices-output.f | 3 + .../Gema/non-decimal-radices-output.gema | 3 + .../Go/non-decimal-radices-output.go | 28 + .../Haskell/non-decimal-radices-output-1.hs | 6 + .../Haskell/non-decimal-radices-output-2.hs | 6 + .../HicEst/non-decimal-radices-output.hicest | 3 + .../Icon/non-decimal-radices-output.icon | 10 + .../J/non-decimal-radices-output-1.j | 6 + .../J/non-decimal-radices-output-2.j | 4 + .../J/non-decimal-radices-output-3.j | 3 + .../Java/non-decimal-radices-output.java | 11 + .../JavaScript/non-decimal-radices-output.js | 7 + .../non-decimal-radices-output.locomotive | 3 + .../Lua/non-decimal-radices-output.lua | 3 + .../non-decimal-radices-output.math | 2 + .../Modula-3/non-decimal-radices-output.mod3 | 12 + .../non-decimal-radices-output.netrexx | 38 ++ .../OCaml/non-decimal-radices-output.ocaml | 3 + .../PARI-GP/non-decimal-radices-output.pari | 7 + .../PHP/non-decimal-radices-output-1.php | 5 + .../PHP/non-decimal-radices-output-2.php | 5 + .../PL-I/non-decimal-radices-output.pli | 3 + .../Perl-6/non-decimal-radices-output.pl6 | 3 + .../Perl/non-decimal-radices-output.pl | 3 + .../PicoLisp/non-decimal-radices-output.l | 11 + .../PowerShell/non-decimal-radices-output.psh | 9 + .../non-decimal-radices-output.purebasic | 6 + .../Python/non-decimal-radices-output-1.py | 42 ++ .../Python/non-decimal-radices-output-2.py | 2 + .../Python/non-decimal-radices-output-3.py | 8 + .../R/non-decimal-radices-output.r | 8 + .../REXX/non-decimal-radices-output-1.rexx | 10 + .../REXX/non-decimal-radices-output-2.rexx | 11 + .../Ruby/non-decimal-radices-output.rb | 38 ++ .../Scheme/non-decimal-radices-output.ss | 10 + .../Seed7/non-decimal-radices-output.seed7 | 12 + .../Smalltalk/non-decimal-radices-output.st | 4 + .../Standard-ML/non-decimal-radices-output.ml | 12 + .../non-decimal-radices-output-1.ti-89 | 9 + .../non-decimal-radices-output-2.ti-89 | 3 + .../Tcl/non-decimal-radices-output-1.tcl | 3 + .../Tcl/non-decimal-radices-output-2.tcl | 10 + .../XPL0/non-decimal-radices-output.xpl0 | 8 + Task/Nth-root/0DESCRIPTION | 1 + Task/Nth-root/1META.yaml | 2 + Task/Nth-root/ALGOL-68/nth-root.alg | 25 + Task/Nth-root/AWK/nth-root.awk | 22 + Task/Nth-root/Ada/nth-root.ada | 27 + Task/Nth-root/AutoHotkey/nth-root.ahk | 19 + Task/Nth-root/AutoIt/nth-root.autoit | 26 + Task/Nth-root/BASIC/nth-root-1.basic | 11 + Task/Nth-root/BASIC/nth-root-2.basic | 1 + Task/Nth-root/BASIC/nth-root-3.basic | 1 + Task/Nth-root/BBC-BASIC/nth-root.bbc | 13 + Task/Nth-root/C++/nth-root-1.cpp | 12 + Task/Nth-root/C++/nth-root-2.cpp | 4 + Task/Nth-root/C/nth-root.c | 31 + .../CoffeeScript/nth-root-1.coffeescript | 26 + .../CoffeeScript/nth-root-2.coffeescript | 12 + Task/Nth-root/Common-Lisp/nth-root-1.lisp | 9 + Task/Nth-root/Common-Lisp/nth-root-2.lisp | 4 + Task/Nth-root/D/nth-root.d | 13 + Task/Nth-root/Delphi/nth-root.delphi | 15 + Task/Nth-root/E/nth-root.e | 12 + Task/Nth-root/Erlang/nth-root-1.erl | 6 + Task/Nth-root/Erlang/nth-root-2.erl | 4 + Task/Nth-root/Forth/nth-root.fth | 11 + Task/Nth-root/Fortran/nth-root.f | 42 ++ Task/Nth-root/Go/nth-root.go | 19 + Task/Nth-root/Groovy/nth-root-1.groovy | 13 + Task/Nth-root/Groovy/nth-root-2.groovy | 21 + Task/Nth-root/Haskell/nth-root.hs | 1 + Task/Nth-root/HicEst/nth-root.hicest | 19 + Task/Nth-root/Icon/nth-root.icon | 23 + Task/Nth-root/J/nth-root.j | 5 + Task/Nth-root/Java/nth-root-1.java | 18 + Task/Nth-root/Java/nth-root-2.java | 15 + Task/Nth-root/JavaScript/nth-root.js | 11 + Task/Nth-root/Liberty-BASIC/nth-root.liberty | 21 + Task/Nth-root/Logo/nth-root.logo | 11 + Task/Nth-root/Lua/nth-root.lua | 3 + Task/Nth-root/MATLAB/nth-root-1.m | 13 + Task/Nth-root/MATLAB/nth-root-2.m | 5 + Task/Nth-root/Mathematica/nth-root.math | 1 + Task/Nth-root/Maxima/nth-root.maxima | 13 + Task/Nth-root/Metafont/nth-root.metafont | 17 + Task/Nth-root/NetRexx/nth-root.netrexx | 78 +++ Task/Nth-root/OCaml/nth-root.ocaml | 12 + Task/Nth-root/Octave/nth-root-1.octave | 1 + Task/Nth-root/Octave/nth-root-2.octave | 12 + Task/Nth-root/Octave/nth-root-3.octave | 8 + Task/Nth-root/Octave/nth-root-4.octave | 6 + Task/Nth-root/Oz/nth-root.oz | 19 + Task/Nth-root/PARI-GP/nth-root.pari | 1 + Task/Nth-root/PHP/nth-root.php | 11 + Task/Nth-root/PL-I/nth-root.pli | 13 + Task/Nth-root/Perl-6/nth-root.pl6 | 11 + Task/Nth-root/Perl/nth-root-1.pl | 14 + Task/Nth-root/Perl/nth-root-2.pl | 3 + Task/Nth-root/PicoLisp/nth-root.l | 17 + Task/Nth-root/PureBasic/nth-root.purebasic | 19 + Task/Nth-root/Python/nth-root-1.py | 13 + Task/Nth-root/Python/nth-root-2.py | 3 + Task/Nth-root/R/nth-root.r | 12 + Task/Nth-root/REXX/nth-root.rexx | 39 ++ Task/Nth-root/Ruby/nth-root.rb | 10 + Task/Nth-root/Run-BASIC/nth-root.run | 21 + Task/Nth-root/Sather/nth-root-1.sa | 16 + Task/Nth-root/Sather/nth-root-2.sa | 6 + Task/Nth-root/Scala/nth-root.scala | 16 + Task/Nth-root/Scheme/nth-root.ss | 18 + Task/Nth-root/Seed7/nth-root.seed7 | 13 + Task/Nth-root/Smalltalk/nth-root-1.st | 13 + Task/Nth-root/Smalltalk/nth-root-2.st | 3 + Task/Nth-root/Tcl/nth-root-1.tcl | 3 + Task/Nth-root/Tcl/nth-root-2.tcl | 11 + Task/Nth-root/Tcl/nth-root-3.tcl | 5 + Task/Nth-root/Ursala/nth-root-1.ursala | 8 + Task/Nth-root/Ursala/nth-root-2.ursala | 9 + Task/Nth-root/XPL0/nth-root.xpl0 | 21 + Task/Null-object/0DESCRIPTION | 5 + Task/Null-object/1META.yaml | 2 + Task/Null-object/ALGOL-68/null-object.alg | 19 + Task/Null-object/ActionScript/null-object.as | 2 + Task/Null-object/Ada/null-object.ada | 5 + Task/Null-object/AmigaE/null-object.amiga | 5 + .../AppleScript/null-object.applescript | 7 + Task/Null-object/AutoHotkey/null-object.ahk | 2 + Task/Null-object/BBC-BASIC/null-object.bbc | 13 + Task/Null-object/Babel/null-object.pb | 1 + Task/Null-object/C++/null-object-1.cpp | 5 + Task/Null-object/C++/null-object-2.cpp | 12 + Task/Null-object/C/null-object.c | 11 + Task/Null-object/Clojure/null-object-1.clj | 2 + Task/Null-object/Clojure/null-object-2.clj | 1 + Task/Null-object/Clojure/null-object-3.clj | 1 + .../Common-Lisp/null-object-1.lisp | 1 + .../Common-Lisp/null-object-2.lisp | 5 + .../Common-Lisp/null-object-3.lisp | 2 + .../Component-Pascal/null-object.component | 17 + Task/Null-object/D/null-object.d | 12 + Task/Null-object/Delphi/null-object.delphi | 6 + Task/Null-object/E/null-object.e | 1 + Task/Null-object/Factor/null-object.factor | 1 + Task/Null-object/Fantom/null-object.fantom | 7 + Task/Null-object/Go/null-object.go | 21 + Task/Null-object/Haskell/null-object-1.hs | 3 + Task/Null-object/Haskell/null-object-2.hs | 1 + Task/Null-object/Haskell/null-object-3.hs | 3 + Task/Null-object/Icon/null-object.icon | 10 + Task/Null-object/Io/null-object.io | 1 + Task/Null-object/J/null-object-1.j | 1 + Task/Null-object/J/null-object-2.j | 5 + Task/Null-object/J/null-object-3.j | 10 + Task/Null-object/Java/null-object.java | 4 + Task/Null-object/JavaScript/null-object.js | 6 + Task/Null-object/K/null-object.k | 6 + Task/Null-object/Logo/null-object.logo | 6 + Task/Null-object/Lua/null-object.lua | 2 + .../MAXScript/null-object.maxscript | 1 + Task/Null-object/MUMPS/null-object.mumps | 18 + .../Mathematica/null-object-1.math | 1 + .../Mathematica/null-object-2.math | 3 + .../Mathematica/null-object-3.math | 1 + .../Mathematica/null-object-4.math | 1 + .../Mathematica/null-object-5.math | 4 + .../Mathematica/null-object-6.math | 2 + Task/Null-object/Modula-3/null-object-1.mod3 | 1 + Task/Null-object/Modula-3/null-object-2.mod3 | 1 + Task/Null-object/Modula-3/null-object-3.mod3 | 3 + Task/Null-object/NetRexx/null-object.netrexx | 6 + Task/Null-object/OCaml/null-object-1.ocaml | 1 + Task/Null-object/OCaml/null-object-2.ocaml | 3 + Task/Null-object/Objeck/null-object.objeck | 4 + Task/Null-object/Objective-C/null-object-1.m | 4 + Task/Null-object/Objective-C/null-object-2.m | 1 + Task/Null-object/Oz/null-object-1.oz | 4 + Task/Null-object/Oz/null-object-2.oz | 4 + Task/Null-object/Oz/null-object-3.oz | 6 + Task/Null-object/PARI-GP/null-object.pari | 1 + Task/Null-object/PHP/null-object.php | 3 + Task/Null-object/PL-I/null-object.pli | 7 + Task/Null-object/Perl-6/null-object-1.pl6 | 8 + Task/Null-object/Perl-6/null-object-2.pl6 | 4 + Task/Null-object/Perl-6/null-object-3.pl6 | 5 + Task/Null-object/Perl/null-object-1.pl | 1 + Task/Null-object/Perl/null-object-2.pl | 1 + Task/Null-object/PicoLisp/null-object-1.l | 2 + Task/Null-object/PicoLisp/null-object-2.l | 2 + Task/Null-object/Pike/null-object.pike | 12 + Task/Null-object/PowerShell/null-object.psh | 3 + .../PureBasic/null-object.purebasic | 3 + Task/Null-object/Python/null-object.py | 5 + Task/Null-object/R/null-object.r | 6 + Task/Null-object/REBOL/null-object.rebol | 3 + Task/Null-object/REXX/null-object.rexx | 13 + Task/Null-object/Ruby/null-object.rb | 1 + Task/Null-object/Scala/null-object.scala | 22 + Task/Null-object/Scheme/null-object.ss | 1 + Task/Null-object/Slate/null-object.slate | 1 + Task/Null-object/Smalltalk/null-object-1.st | 6 + Task/Null-object/Smalltalk/null-object-2.st | 6 + Task/Null-object/Standard-ML/null-object-1.ml | 1 + Task/Null-object/Standard-ML/null-object-2.ml | 2 + Task/Null-object/Tcl/null-object-1.tcl | 1 + Task/Null-object/Tcl/null-object-2.tcl | 3 + Task/Number-names/0DESCRIPTION | 1 + Task/Number-names/1META.yaml | 2 + Task/Number-names/ALGOL-68/number-names-1.alg | 38 ++ Task/Number-names/ALGOL-68/number-names-2.alg | 89 +++ Task/Number-names/AWK/number-names.awk | 50 ++ Task/Number-names/Ada/number-names.ada | 132 +++++ Task/Number-names/AutoHotkey/number-names.ahk | 40 ++ Task/Number-names/BASIC/number-names.basic | 73 +++ Task/Number-names/BBC-BASIC/number-names.bbc | 40 ++ Task/Number-names/C++/number-names.cpp | 69 +++ Task/Number-names/C/number-names.c | 137 +++++ Task/Number-names/Clojure/number-names.clj | 2 + .../CoffeeScript/number-names-1.coffeescript | 57 ++ .../CoffeeScript/number-names-2.coffeescript | 5 + .../Common-Lisp/number-names.lisp | 2 + Task/Number-names/D/number-names.d | 60 ++ .../Euphoria/number-names.euphoria | 72 +++ Task/Number-names/Fortran/number-names.f | 67 +++ Task/Number-names/Go/number-names.go | 54 ++ Task/Number-names/Groovy/number-names.groovy | 75 +++ Task/Number-names/Haskell/number-names.hs | 36 ++ .../Number-names/HicEst/number-names-1.hicest | 70 +++ .../Number-names/HicEst/number-names-2.hicest | 7 + .../Number-names/HicEst/number-names-3.hicest | 6 + .../Number-names/HicEst/number-names-4.hicest | 37 ++ Task/Number-names/Inform-7/number-names-1.inf | 1 + Task/Number-names/Inform-7/number-names-2.inf | 1 + Task/Number-names/Inform-7/number-names-3.inf | 24 + Task/Number-names/Java/number-names-1.java | 64 +++ Task/Number-names/Java/number-names-2.java | 18 + Task/Number-names/Joy/number-names.joy | 43 ++ Task/Number-names/Logo/number-names.logo | 28 + Task/Number-names/Lua/number-names.lua | 37 ++ .../MAXScript/number-names-1.maxscript | 55 ++ .../MAXScript/number-names-2.maxscript | 1 + .../Mathematica/number-names.math | 24 + Task/Number-names/OCaml/number-names.ocaml | 57 ++ Task/Number-names/Objeck/number-names.objeck | 93 +++ Task/Number-names/PARI-GP/number-names.pari | 34 ++ Task/Number-names/PHP/number-names-1.php | 57 ++ Task/Number-names/PHP/number-names-2.php | 6 + Task/Number-names/PL-I/number-names.pli | 54 ++ Task/Number-names/Pascal/number-names.pascal | 82 +++ Task/Number-names/Perl-6/number-names.pl6 | 34 ++ Task/Number-names/Perl/number-names.pl | 3 + Task/Number-names/PicoLisp/number-names.l | 22 + .../PowerBASIC/number-names.powerbasic | 68 +++ .../PureBasic/number-names-1.purebasic | 120 ++++ .../PureBasic/number-names-2.purebasic | 48 ++ Task/Number-names/Ruby/number-names.rb | 59 ++ Task/Number-names/Seed7/number-names.seed7 | 12 + Task/Number-names/Tcl/number-names.tcl | 72 +++ .../Visual-Basic-.NET/number-names.visual | 28 + .../Number-names/Visual-Basic/number-names.vb | 60 ++ Task/Number-names/XPL0/number-names.xpl0 | 53 ++ Task/Number-reversal-game/0DESCRIPTION | 12 + Task/Number-reversal-game/1META.yaml | 2 + .../AWK/number-reversal-game.awk | 79 +++ .../Ada/number-reversal-game.ada | 75 +++ .../AutoHotkey/number-reversal-game.ahk | 34 ++ .../BASIC/number-reversal-game.basic | 55 ++ .../BBC-BASIC/number-reversal-game.bbc | 32 ++ .../Brat/number-reversal-game.brat | 19 + .../C++/number-reversal-game-1.cpp | 34 ++ .../C++/number-reversal-game-2.cpp | 50 ++ .../C/number-reversal-game-1.c | 32 ++ .../C/number-reversal-game-2.c | 44 ++ .../Clojure/number-reversal-game.clj | 16 + .../Common-Lisp/number-reversal-game.lisp | 32 ++ .../D/number-reversal-game.d | 15 + .../Euphoria/number-reversal-game.euphoria | 55 ++ .../Factor/number-reversal-game.factor | 30 + .../Forth/number-reversal-game.fth | 49 ++ .../Fortran/number-reversal-game.f | 54 ++ .../Go/number-reversal-game.go | 43 ++ .../Groovy/number-reversal-game.groovy | 15 + .../Haskell/number-reversal-game.hs | 35 ++ .../HicEst/number-reversal-game.hicest | 23 + .../Icon/number-reversal-game.icon | 68 +++ .../Inform-7/number-reversal-game.inf | 40 ++ .../Io/number-reversal-game.io | 19 + .../J/number-reversal-game-1.j | 22 + .../J/number-reversal-game-2.j | 17 + .../Java/number-reversal-game.java | 73 +++ .../JavaScript/number-reversal-game-1.js | 10 + .../JavaScript/number-reversal-game-2.js | 68 +++ .../JavaScript/number-reversal-game-3.js | 3 + .../Mathematica/number-reversal-game.math | 6 + .../OCaml/number-reversal-game-1.ocaml | 48 ++ .../OCaml/number-reversal-game-2.ocaml | 49 ++ .../Oz/number-reversal-game.oz | 59 ++ .../PARI-GP/number-reversal-game.pari | 14 + .../PL-I/number-reversal-game.pli | 33 ++ .../Perl-6/number-reversal-game.pl6 | 15 + .../Perl/number-reversal-game.pl | 20 + .../PicoLisp/number-reversal-game.l | 12 + .../PureBasic/number-reversal-game.purebasic | 47 ++ .../Python/number-reversal-game.py | 22 + .../R/number-reversal-game-1.r | 24 + .../R/number-reversal-game-2.r | 10 + .../REXX/number-reversal-game.rexx | 22 + .../Rascal/number-reversal-game.rascal | 37 ++ .../Ruby/number-reversal-game.rb | 11 + .../Run-BASIC/number-reversal-game.run | 40 ++ .../TUSCRIPT/number-reversal-game.tuscript | 37 ++ .../Tcl/number-reversal-game.tcl | 43 ++ .../UNIX-Shell/number-reversal-game.sh | 100 ++++ .../XPL0/number-reversal-game.xpl0 | 24 + Task/Numeric-error-propagation/0DESCRIPTION | 27 + .../Ada/numeric-error-propagation-1.ada | 48 ++ .../Ada/numeric-error-propagation-2.ada | 119 ++++ .../Ada/numeric-error-propagation-3.ada | 17 + .../C/numeric-error-propagation.c | 52 ++ .../D/numeric-error-propagation.d | 103 ++++ .../Go/numeric-error-propagation.go | 101 ++++ .../Haskell/numeric-error-propagation.hs | 20 + .../J/numeric-error-propagation-1.j | 3 + .../J/numeric-error-propagation-2.j | 5 + .../J/numeric-error-propagation-3.j | 4 + .../J/numeric-error-propagation-4.j | 4 + .../J/numeric-error-propagation-5.j | 2 + .../J/numeric-error-propagation-6.j | 5 + .../J/numeric-error-propagation-7.j | 2 + .../numeric-error-propagation-1.math | 5 + .../numeric-error-propagation-2.math | 5 + .../Perl-6/numeric-error-propagation.pl6 | 100 ++++ .../Perl/numeric-error-propagation-1.pl | 186 ++++++ .../Perl/numeric-error-propagation-2.pl | 3 + .../PicoLisp/numeric-error-propagation-1.l | 94 +++ .../PicoLisp/numeric-error-propagation-2.l | 12 + .../Python/numeric-error-propagation.py | 93 +++ .../Ruby/numeric-error-propagation.rb | 64 +++ .../Tcl/numeric-error-propagation-1.tcl | 54 ++ .../Tcl/numeric-error-propagation-2.tcl | 51 ++ .../Tcl/numeric-error-propagation-3.tcl | 9 + .../0DESCRIPTION | 42 ++ .../1META.yaml | 5 + ...al-integration-gauss-legendre-quadrature.c | 84 +++ ...tegration-gauss-legendre-quadrature-1.lisp | 63 ++ ...tegration-gauss-legendre-quadrature-2.lisp | 8 + ...tegration-gauss-legendre-quadrature-3.lisp | 11 + ...al-integration-gauss-legendre-quadrature.d | 75 +++ ...l-integration-gauss-legendre-quadrature.go | 96 ++++ ...-integration-gauss-legendre-quadrature-1.j | 16 + ...-integration-gauss-legendre-quadrature-2.j | 2 + ...integration-gauss-legendre-quadrature.math | 7 + ...tegration-gauss-legendre-quadrature.maxima | 31 + ...egration-gauss-legendre-quadrature-1.ocaml | 36 ++ ...egration-gauss-legendre-quadrature-2.ocaml | 9 + ...egration-gauss-legendre-quadrature-3.ocaml | 2 + ...integration-gauss-legendre-quadrature.pari | 6 + ...-integration-gauss-legendre-quadrature.pl6 | 55 ++ ...l-integration-gauss-legendre-quadrature.py | 97 ++++ ...ntegration-gauss-legendre-quadrature-1.tcl | 63 ++ ...ntegration-gauss-legendre-quadrature-2.tcl | 4 + ...gration-gauss-legendre-quadrature-1.ursala | 34 ++ ...gration-gauss-legendre-quadrature-2.ursala | 7 + Task/Numerical-integration/0DESCRIPTION | 24 + Task/Numerical-integration/1META.yaml | 2 + .../ALGOL-68/numerical-integration.alg | 85 +++ .../ActionScript/numerical-integration-1.as | 51 ++ .../ActionScript/numerical-integration-2.as | 8 + .../Ada/numerical-integration-1.ada | 10 + .../Ada/numerical-integration-2.ada | 61 ++ .../Ada/numerical-integration-3.ada | 104 ++++ .../AutoHotkey/numerical-integration.ahk | 35 ++ .../BASIC/numerical-integration.basic | 51 ++ .../BBC-BASIC/numerical-integration.bbc | 71 +++ .../C++/numerical-integration.cpp | 63 ++ .../C/numerical-integration-1.c | 58 ++ .../C/numerical-integration-2.c | 71 +++ .../numerical-integration-1.coffeescript | 33 ++ .../numerical-integration-2.coffeescript | 25 + .../Common-Lisp/numerical-integration.lisp | 27 + .../D/numerical-integration-1.d | 63 ++ .../D/numerical-integration-2.d | 71 +++ .../E/numerical-integration-1.e | 26 + .../E/numerical-integration-2.e | 5 + .../Euphoria/numerical-integration.euphoria | 79 +++ .../Forth/numerical-integration.fth | 40 ++ .../Fortran/numerical-integration-1.f | 4 + .../Fortran/numerical-integration-2.f | 75 +++ .../Fortran/numerical-integration-3.f | 12 + .../Fortran/numerical-integration-4.f | 13 + .../Go/numerical-integration.go | 172 ++++++ .../Groovy/numerical-integration-1.groovy | 44 ++ .../Groovy/numerical-integration-2.groovy | 40 ++ .../Groovy/numerical-integration-3.groovy | 31 + .../Haskell/numerical-integration-1.hs | 1 + .../Haskell/numerical-integration-2.hs | 7 + .../Haskell/numerical-integration-3.hs | 14 + .../Haskell/numerical-integration-4.hs | 5 + .../Haskell/numerical-integration-5.hs | 3 + .../Haskell/numerical-integration-6.hs | 70 +++ .../J/numerical-integration-1.j | 11 + .../J/numerical-integration-2.j | 28 + .../J/numerical-integration-3.j | 6 + .../J/numerical-integration-4.j | 7 + .../J/numerical-integration-5.j | 4 + .../J/numerical-integration-6.j | 2 + .../J/numerical-integration-7.j | 2 + .../Java/numerical-integration.java | 123 ++++ .../numerical-integration.liberty | 117 ++++ .../Logo/numerical-integration.logo | 36 ++ .../Lua/numerical-integration.lua | 73 +++ .../MATLAB/numerical-integration-1.m | 8 + .../MATLAB/numerical-integration-2.m | 8 + .../MATLAB/numerical-integration-3.m | 8 + .../MATLAB/numerical-integration-4.m | 7 + .../MATLAB/numerical-integration-5.m | 1 + .../MATLAB/numerical-integration-6.m | 5 + .../MATLAB/numerical-integration-7.m | 5 + .../MATLAB/numerical-integration-8.m | 4 + .../MATLAB/numerical-integration-9.m | 5 + .../Mathematica/numerical-integration.math | 26 + .../Maxima/numerical-integration.maxima | 27 + .../OCaml/numerical-integration-1.ocaml | 7 + .../OCaml/numerical-integration-2.ocaml | 7 + .../OCaml/numerical-integration-3.ocaml | 6 + .../OCaml/numerical-integration-4.ocaml | 7 + .../PARI-GP/numerical-integration.pari | 29 + .../PL-I/numerical-integration.pli | 43 ++ .../Pascal/numerical-integration.pascal | 41 ++ .../Perl-6/numerical-integration-1.pl6 | 51 ++ .../Perl-6/numerical-integration-2.pl6 | 35 ++ .../PicoLisp/numerical-integration.l | 32 ++ .../PureBasic/numerical-integration.purebasic | 102 ++++ .../Python/numerical-integration-1.py | 55 ++ .../Python/numerical-integration-2.py | 23 + .../Python/numerical-integration-3.py | 6 + .../R/numerical-integration.r | 36 ++ .../REXX/numerical-integration.rexx | 60 ++ .../Ruby/numerical-integration.rb | 58 ++ .../Scala/numerical-integration.scala | 35 ++ .../Scheme/numerical-integration.ss | 21 + .../Standard-ML/numerical-integration.ml | 23 + .../Tcl/numerical-integration.tcl | 54 ++ .../Ursala/numerical-integration-1.ursala | 7 + .../Ursala/numerical-integration-2.ursala | 3 + .../Ursala/numerical-integration-3.ursala | 5 + .../Ursala/numerical-integration-4.ursala | 3 + .../XPL0/numerical-integration.xpl0 | 47 ++ Task/OLE-Automation/0DESCRIPTION | 4 + Task/OLE-Automation/1META.yaml | 2 + .../AutoHotkey/ole-automation-1.ahk | 5 + .../AutoHotkey/ole-automation-2.ahk | 56 ++ .../OLE-Automation/Python/ole-automation-1.py | 56 ++ .../OLE-Automation/Python/ole-automation-2.py | 3 + Task/Object-serialization/0DESCRIPTION | 1 + Task/Object-serialization/1META.yaml | 2 + .../ALGOL-68/object-serialization.alg | 29 + .../Ada/object-serialization-1.ada | 25 + .../Ada/object-serialization-2.ada | 68 +++ .../Ada/object-serialization-3.ada | 40 ++ .../C++/object-serialization.cpp | 118 ++++ .../Common-Lisp/object-serialization-1.lisp | 12 + .../Common-Lisp/object-serialization-2.lisp | 35 ++ .../D/object-serialization.d | 35 ++ .../E/object-serialization-1.e | 21 + .../E/object-serialization-2.e | 3 + .../E/object-serialization-3.e | 6 + .../Go/object-serialization.go | 154 +++++ .../Groovy/object-serialization-1.groovy | 11 + .../Groovy/object-serialization-2.groovy | 19 + .../Groovy/object-serialization-3.groovy | 8 + .../J/object-serialization-1.j | 41 ++ .../J/object-serialization-2.j | 17 + .../Java/object-serialization.java | 60 ++ .../OCaml/object-serialization.ocaml | 23 + .../Objeck/object-serialization.objeck | 50 ++ .../Objective-C/object-serialization.m | 185 ++++++ .../PHP/object-serialization.php | 2 + .../Perl/object-serialization-1.pl | 35 ++ .../Perl/object-serialization-2.pl | 25 + .../PicoLisp/object-serialization-1.l | 30 + .../PicoLisp/object-serialization-2.l | 6 + .../Python/object-serialization.py | 37 ++ .../Ruby/object-serialization.rb | 70 +++ .../Tcl/object-serialization.tcl | 52 ++ .../0DESCRIPTION | 13 + .../1META.yaml | 4 + .../one-dimensional-cellular-automata.acl2 | 33 ++ .../one-dimensional-cellular-automata-1.alg | 43 ++ .../one-dimensional-cellular-automata-2.alg | 36 ++ .../AWK/one-dimensional-cellular-automata.awk | 69 +++ .../Ada/one-dimensional-cellular-automata.ada | 42 ++ .../one-dimensional-cellular-automata.ahk | 23 + .../one-dimensional-cellular-automata.basic | 53 ++ .../one-dimensional-cellular-automata.bbc | 13 + .../one-dimensional-cellular-automata.bf | 16 + .../one-dimensional-cellular-automata.bracmat | 30 + .../C++/one-dimensional-cellular-automata.cpp | 29 + .../one-dimensional-cellular-automata.cs | 39 ++ .../C/one-dimensional-cellular-automata-1.c | 28 + .../C/one-dimensional-cellular-automata-2.c | 27 + .../one-dimensional-cellular-automata.cobol | 90 +++ .../one-dimensional-cellular-automata-1.clj | 15 + .../one-dimensional-cellular-automata-2.clj | 12 + ...mensional-cellular-automata-1.coffeescript | 32 ++ ...mensional-cellular-automata-2.coffeescript | 11 + .../one-dimensional-cellular-automata-1.lisp | 28 + .../one-dimensional-cellular-automata-2.lisp | 13 + .../D/one-dimensional-cellular-automata.d | 19 + ...one-dimensional-cellular-automata.dwscript | 20 + .../E/one-dimensional-cellular-automata-1.e | 18 + .../E/one-dimensional-cellular-automata-2.e | 23 + .../one-dimensional-cellular-automata-1.erl | 48 ++ .../one-dimensional-cellular-automata-2.erl | 11 + ...one-dimensional-cellular-automata.euphoria | 46 ++ .../one-dimensional-cellular-automata.factor | 21 + .../one-dimensional-cellular-automata.fantom | 30 + .../one-dimensional-cellular-automata.fth | 25 + .../one-dimensional-cellular-automata.f | 50 ++ .../Go/one-dimensional-cellular-automata.go | 26 + ...one-dimensional-cellular-automata-1.groovy | 5 + ...one-dimensional-cellular-automata-2.groovy | 6 + .../one-dimensional-cellular-automata-1.hs | 24 + .../one-dimensional-cellular-automata-2.hs | 19 + .../one-dimensional-cellular-automata-1.icon | 36 ++ .../one-dimensional-cellular-automata-2.icon | 16 + .../J/one-dimensional-cellular-automata-1.j | 1 + .../J/one-dimensional-cellular-automata-2.j | 10 + .../J/one-dimensional-cellular-automata-3.j | 3 + .../J/one-dimensional-cellular-automata-4.j | 10 + .../one-dimensional-cellular-automata-1.java | 42 ++ .../one-dimensional-cellular-automata-2.java | 31 + .../one-dimensional-cellular-automata-1.js | 13 + .../one-dimensional-cellular-automata-2.js | 1 + .../K/one-dimensional-cellular-automata-1.k | 1 + .../K/one-dimensional-cellular-automata-2.k | 10 + .../one-dimensional-cellular-automata.liberty | 26 + ...e-dimensional-cellular-automata.locomotive | 9 + .../one-dimensional-cellular-automata.logo | 38 ++ .../Lua/one-dimensional-cellular-automata.lua | 32 ++ .../M4/one-dimensional-cellular-automata.m4 | 36 ++ .../one-dimensional-cellular-automata-1.math | 2 + .../one-dimensional-cellular-automata-2.math | 13 + .../one-dimensional-cellular-automata.mod3 | 43 ++ .../one-dimensional-cellular-automata-1.nial | 10 + .../one-dimensional-cellular-automata-2.nial | 3 + .../one-dimensional-cellular-automata.nimrod | 61 ++ .../one-dimensional-cellular-automata.ocaml | 29 + .../Oz/one-dimensional-cellular-automata.oz | 36 ++ .../one-dimensional-cellular-automata.pari | 1 + .../one-dimensional-cellular-automata.pl6 | 7 + .../one-dimensional-cellular-automata-1.pl | 7 + .../one-dimensional-cellular-automata-2.pl | 6 + .../one-dimensional-cellular-automata.l | 15 + .../one-dimensional-cellular-automata.pro | 52 ++ ...ne-dimensional-cellular-automata.purebasic | 31 + .../one-dimensional-cellular-automata-1.py | 25 + .../one-dimensional-cellular-automata-2.py | 16 + .../R/one-dimensional-cellular-automata.r | 33 ++ .../one-dimensional-cellular-automata.retro | 33 ++ .../Ruby/one-dimensional-cellular-automata.rb | 21 + .../one-dimensional-cellular-automata.scala | 11 + .../one-dimensional-cellular-automata.ss | 21 + .../one-dimensional-cellular-automata.seed7 | 26 + .../Tcl/one-dimensional-cellular-automata.tcl | 36 ++ .../one-dimensional-cellular-automata.ursala | 12 + .../one-dimensional-cellular-automata-1.vedit | 18 + .../one-dimensional-cellular-automata-2.vedit | 10 + .../one-dimensional-cellular-automata.visual | 105 ++++ .../one-dimensional-cellular-automata.xpl0 | 12 + Task/One-of-n-lines-in-a-file/0DESCRIPTION | 19 + .../Ada/one-of-n-lines-in-a-file.ada | 34 ++ .../AutoHotkey/one-of-n-lines-in-a-file.ahk | 22 + .../BASIC/one-of-n-lines-in-a-file.basic | 24 + .../BBC-BASIC/one-of-n-lines-in-a-file.bbc | 17 + .../C++/one-of-n-lines-in-a-file.cpp | 27 + .../C/one-of-n-lines-in-a-file.c | 27 + .../D/one-of-n-lines-in-a-file.d | 19 + .../one-of-n-lines-in-a-file.euphoria | 27 + .../Factor/one-of-n-lines-in-a-file-1.factor | 11 + .../Factor/one-of-n-lines-in-a-file-2.factor | 31 + .../Go/one-of-n-lines-in-a-file.go | 82 +++ .../Haskell/one-of-n-lines-in-a-file.hs | 33 ++ .../Icon/one-of-n-lines-in-a-file.icon | 17 + .../J/one-of-n-lines-in-a-file-1.j | 20 + .../J/one-of-n-lines-in-a-file-2.j | 24 + .../Java/one-of-n-lines-in-a-file.java | 31 + .../OCaml/one-of-n-lines-in-a-file.ocaml | 21 + .../Pascal/one-of-n-lines-in-a-file.pascal | 39 ++ .../Perl-6/one-of-n-lines-in-a-file.pl6 | 13 + .../PicoLisp/one-of-n-lines-in-a-file.l | 11 + .../one-of-n-lines-in-a-file.purebasic | 33 ++ .../Python/one-of-n-lines-in-a-file.py | 20 + .../REXX/one-of-n-lines-in-a-file.rexx | 15 + .../Ruby/one-of-n-lines-in-a-file.rb | 29 + .../Run-BASIC/one-of-n-lines-in-a-file.run | 15 + .../Seed7/one-of-n-lines-in-a-file.seed7 | 28 + .../Tcl/one-of-n-lines-in-a-file.tcl | 14 + Task/OpenGL/0DESCRIPTION | 3 + Task/OpenGL/1META.yaml | 7 + Task/OpenGL/Ada/opengl.ada | 121 ++++ Task/OpenGL/AutoHotkey/opengl.ahk | 61 ++ Task/OpenGL/BBC-BASIC/opengl.bbc | 82 +++ Task/OpenGL/C/opengl.c | 48 ++ Task/OpenGL/Clojure/opengl.clj | 22 + Task/OpenGL/D/opengl.d | 32 ++ Task/OpenGL/Factor/opengl.factor | 33 ++ Task/OpenGL/Forth/opengl-1.fth | 2 + Task/OpenGL/Forth/opengl-2.fth | 54 ++ Task/OpenGL/Haskell/opengl.hs | 25 + Task/OpenGL/J/opengl.j | 31 + Task/OpenGL/Java/opengl.java | 57 ++ Task/OpenGL/JavaScript/opengl.js | 116 ++++ Task/OpenGL/Liberty-BASIC/opengl.liberty | 51 ++ Task/OpenGL/Lua/opengl.lua | 42 ++ Task/OpenGL/MAXScript/opengl.maxscript | 11 + Task/OpenGL/Mercury/opengl.mercury | 46 ++ Task/OpenGL/OCaml/opengl.ocaml | 42 ++ Task/OpenGL/OxygenBasic/opengl.oxy | 41 ++ Task/OpenGL/Pascal/opengl.pascal | 49 ++ Task/OpenGL/Perl/opengl-1.pl | 24 + Task/OpenGL/Perl/opengl-2.pl | 29 + Task/OpenGL/PicoLisp/opengl.l | 34 ++ Task/OpenGL/Pike/opengl.pike | 37 ++ Task/OpenGL/PureBasic/opengl.purebasic | 41 ++ Task/OpenGL/Python/opengl.py | 41 ++ Task/OpenGL/R/opengl.r | 7 + Task/OpenGL/Racket/opengl.rkt | 49 ++ Task/OpenGL/Ruby/opengl.rb | 44 ++ Task/OpenGL/Tcl/opengl.tcl | 30 + Task/Operator-precedence/0DESCRIPTION | 4 + .../REXX/operator-precedence.rexx | 90 +++ Task/Optional-parameters/0DESCRIPTION | 19 + Task/Optional-parameters/1META.yaml | 2 + .../Ada/optional-parameters-1.ada | 14 + .../Ada/optional-parameters-2.ada | 10 + .../optional-parameters-1.applescript | 20 + .../optional-parameters-2.applescript | 15 + .../AutoHotkey/optional-parameters.ahk | 33 ++ .../BBC-BASIC/optional-parameters.bbc | 10 + .../C++/optional-parameters.cpp | 91 +++ .../C/optional-parameters.c | 167 ++++++ .../Clojure/optional-parameters.clj | 6 + .../Common-Lisp/optional-parameters-1.lisp | 7 + .../Common-Lisp/optional-parameters-2.lisp | 17 + .../D/optional-parameters.d | 28 + .../E/optional-parameters.e | 22 + .../Fortran/optional-parameters-1.f | 69 +++ .../Fortran/optional-parameters-2.f | 36 ++ .../Go/optional-parameters-1.go | 5 + .../Go/optional-parameters-2.go | 1 + .../Go/optional-parameters-3.go | 93 +++ .../Icon/optional-parameters.icon | 20 + .../J/optional-parameters-1.j | 6 + .../J/optional-parameters-2.j | 40 ++ .../Java/optional-parameters.java | 73 +++ .../JavaScript/optional-parameters.js | 10 + .../Logo/optional-parameters-1.logo | 3 + .../Logo/optional-parameters-2.logo | 3 + .../Mathematica/optional-parameters.math | 10 + .../Nemerle/optional-parameters.nemerle | 4 + .../OCaml/optional-parameters-1.ocaml | 3 + .../OCaml/optional-parameters-2.ocaml | 18 + .../Objective-C/optional-parameters.m | 25 + .../Oz/optional-parameters.oz | 30 + .../PARI-GP/optional-parameters-1.pari | 1 + .../PARI-GP/optional-parameters-2.pari | 10 + .../Perl-6/optional-parameters.pl6 | 4 + .../Perl/optional-parameters-1.pl | 10 + .../Perl/optional-parameters-2.pl | 5 + .../PicoLisp/optional-parameters.l | 8 + .../Python/optional-parameters.py | 35 ++ .../R/optional-parameters.r | 7 + .../Racket/optional-parameters.rkt | 10 + .../Ruby/optional-parameters-1.rb | 2 + .../Ruby/optional-parameters-2.rb | 16 + .../Ruby/optional-parameters-3.rb | 12 + .../Scala/optional-parameters-1.scala | 5 + .../Scala/optional-parameters-2.scala | 11 + .../Slate/optional-parameters.slate | 8 + .../TIScript/optional-parameters.tiscript | 5 + .../Tcl/optional-parameters-1.tcl | 15 + .../Tcl/optional-parameters-2.tcl | 18 + .../Ursala/optional-parameters-1.ursala | 10 + .../Ursala/optional-parameters-2.ursala | 17 + .../XSLT/optional-parameters.xslt | 7 + Task/Order-two-numerical-lists/0DESCRIPTION | 4 + Task/Order-two-numerical-lists/1META.yaml | 2 + .../Ada/order-two-numerical-lists.ada | 22 + .../AutoHotkey/order-two-numerical-lists.ahk | 7 + .../BBC-BASIC/order-two-numerical-lists.bbc | 19 + .../Bracmat/order-two-numerical-lists.bracmat | 24 + .../C++/order-two-numerical-lists.cpp | 23 + .../C/order-two-numerical-lists-1.c | 11 + .../C/order-two-numerical-lists-2.c | 1 + .../order-two-numerical-lists-1.lisp | 6 + .../order-two-numerical-lists-2.lisp | 3 + .../D/order-two-numerical-lists.d | 3 + .../Ela/order-two-numerical-lists.ela | 6 + .../Go/order-two-numerical-lists.go | 73 +++ .../Groovy/order-two-numerical-lists-1.groovy | 10 + .../Groovy/order-two-numerical-lists-2.groovy | 9 + .../Haskell/order-two-numerical-lists.hs | 2 + .../Icon/order-two-numerical-lists.icon | 11 + .../J/order-two-numerical-lists-1.j | 1 + .../J/order-two-numerical-lists-2.j | 49 ++ .../Java/order-two-numerical-lists.java | 34 ++ .../Joy/order-two-numerical-lists.joy | 4 + .../Lhogho/order-two-numerical-lists-1.lhogho | 8 + .../Lhogho/order-two-numerical-lists-2.lhogho | 5 + .../order-two-numerical-lists.math | 8 + .../Maxima/order-two-numerical-lists.maxima | 13 + .../order-two-numerical-lists-1.mercury | 3 + .../order-two-numerical-lists-2.mercury | 3 + .../order-two-numerical-lists-3.mercury | 27 + .../order-two-numerical-lists-4.mercury | 6 + .../OCaml/order-two-numerical-lists-1.ocaml | 2 + .../OCaml/order-two-numerical-lists-2.ocaml | 8 + .../OCaml/order-two-numerical-lists-3.ocaml | 20 + .../OCaml/order-two-numerical-lists-4.ocaml | 1 + .../PARI-GP/order-two-numerical-lists.pari | 1 + .../Perl-6/order-two-numerical-lists.pl6 | 17 + .../Perl/order-two-numerical-lists.pl | 36 ++ .../PicoLisp/order-two-numerical-lists.l | 2 + .../Pike/order-two-numerical-lists-1.pike | 8 + .../Pike/order-two-numerical-lists-2.pike | 1 + .../order-two-numerical-lists.purebasic | 70 +++ .../Python/order-two-numerical-lists.py | 2 + .../Rascal/order-two-numerical-lists.rascal | 2 + .../Ruby/order-two-numerical-lists.rb | 2 + .../Scheme/order-two-numerical-lists.ss | 5 + .../Standard-ML/order-two-numerical-lists.ml | 2 + .../order-two-numerical-lists.tuscript | 24 + .../Tcl/order-two-numerical-lists.tcl | 10 + Task/Ordered-Partitions/0DESCRIPTION | 38 ++ Task/Ordered-Partitions/1META.yaml | 2 + .../Ada/ordered-partitions-1.ada | 13 + .../Ada/ordered-partitions-2.ada | 148 +++++ .../Ada/ordered-partitions-3.ada | 61 ++ .../BBC-BASIC/ordered-partitions.bbc | 52 ++ .../C/ordered-partitions-1.c | 51 ++ .../C/ordered-partitions-2.c | 51 ++ .../Common-Lisp/ordered-partitions.lisp | 46 ++ .../Ordered-Partitions/D/ordered-partitions.d | 34 ++ .../GAP/ordered-partitions.gap | 28 + .../Go/ordered-partitions.go | 60 ++ .../Groovy/ordered-partitions-1.groovy | 13 + .../Groovy/ordered-partitions-2.groovy | 3 + .../Haskell/ordered-partitions-1.hs | 13 + .../Haskell/ordered-partitions-2.hs | 12 + .../Haskell/ordered-partitions-3.hs | 15 + .../J/ordered-partitions-1.j | 2 + .../J/ordered-partitions-2.j | 39 ++ .../Lua/ordered-partitions.lua | 89 +++ .../Mathematica/ordered-partitions-1.math | 4 + .../Mathematica/ordered-partitions-2.math | 3 + .../Perl-6/ordered-partitions.pl6 | 10 + .../Perl/ordered-partitions-1.pl | 43 ++ .../Perl/ordered-partitions-2.pl | 48 ++ .../PicoLisp/ordered-partitions.l | 11 + .../Python/ordered-partitions-1.py | 15 + .../Python/ordered-partitions-2.py | 10 + .../Tcl/ordered-partitions-1.tcl | 52 ++ .../Tcl/ordered-partitions-2.tcl | 4 + .../Ursala/ordered-partitions-1.ursala | 8 + .../Ursala/ordered-partitions-2.ursala | 3 + Task/Palindrome-detection/0DESCRIPTION | 30 + Task/Palindrome-detection/1META.yaml | 5 + .../ACL2/palindrome-detection.acl2 | 17 + .../ALGOL-68/palindrome-detection.alg | 26 + .../AWK/palindrome-detection-1.awk | 5 + .../AWK/palindrome-detection-2.awk | 6 + .../AWK/palindrome-detection-3.awk | 5 + .../ActionScript/palindrome-detection.as | 6 + .../Ada/palindrome-detection.ada | 9 + .../AutoHotkey/palindrome-detection.ahk | 7 + .../AutoIt/palindrome-detection.autoit | 52 ++ .../BASIC/palindrome-detection.basic | 32 ++ .../BBC-BASIC/palindrome-detection.bbc | 27 + .../Befunge/palindrome-detection-1.bf | 4 + .../Befunge/palindrome-detection-2.bf | 18 + .../Burlesque/palindrome-detection.blq | 1 + .../C++/palindrome-detection-1.cpp | 7 + .../C++/palindrome-detection-2.cpp | 7 + .../C/palindrome-detection-1.c | 12 + .../C/palindrome-detection-2.c | 10 + .../C/palindrome-detection-3.c | 6 + .../C/palindrome-detection-4.c | 15 + .../Clojure/palindrome-detection-1.clj | 2 + .../Clojure/palindrome-detection-2.clj | 7 + .../palindrome-detection-1.coffeescript | 3 + .../palindrome-detection-2.coffeescript | 7 + .../Common-Lisp/palindrome-detection.lisp | 2 + .../D/palindrome-detection-1.d | 22 + .../D/palindrome-detection-2.d | 26 + .../D/palindrome-detection-3.d | 39 ++ .../D/palindrome-detection-4.d | 23 + .../Delphi/palindrome-detection.delphi | 7 + .../E/palindrome-detection.e | 8 + .../Ela/palindrome-detection-1.ela | 4 + .../Ela/palindrome-detection-2.ela | 4 + .../Erlang/palindrome-detection.erl | 2 + .../Euphoria/palindrome-detection.euphoria | 8 + .../Factor/palindrome-detection.factor | 2 + .../Fantom/palindrome-detection.fantom | 20 + .../Forth/palindrome-detection.fth | 8 + .../Fortran/palindrome-detection-1.f | 14 + .../Fortran/palindrome-detection-2.f | 26 + .../Fortran/palindrome-detection-3.f | 9 + .../Fortran/palindrome-detection-4.f | 1 + .../GAP/palindrome-detection.gap | 27 + .../GML/palindrome-detection.gml | 13 + .../Go/palindrome-detection.go | 12 + .../Groovy/palindrome-detection-1.groovy | 3 + .../Groovy/palindrome-detection-2.groovy | 5 + .../Groovy/palindrome-detection-3.groovy | 4 + .../Groovy/palindrome-detection-4.groovy | 5 + .../Haskell/palindrome-detection-1.hs | 1 + .../Haskell/palindrome-detection-2.hs | 3 + .../HicEst/palindrome-detection.hicest | 17 + .../Icon/palindrome-detection-1.icon | 3 + .../Icon/palindrome-detection-2.icon | 3 + .../Icon/palindrome-detection-3.icon | 5 + .../Ioke/palindrome-detection.ioke | 1 + .../J/palindrome-detection-1.j | 1 + .../J/palindrome-detection-2.j | 4 + .../J/palindrome-detection-3.j | 6 + .../J/palindrome-detection-4.j | 12 + .../Java/palindrome-detection-1.java | 4 + .../Java/palindrome-detection-2.java | 9 + .../Java/palindrome-detection-3.java | 3 + .../JavaScript/palindrome-detection-1.js | 5 + .../JavaScript/palindrome-detection-2.js | 15 + .../palindrome-detection.liberty | 22 + .../Logo/palindrome-detection.logo | 3 + .../Lua/palindrome-detection.lua | 1 + .../M4/palindrome-detection-1.m4 | 3 + .../M4/palindrome-detection-2.m4 | 7 + .../MATLAB/palindrome-detection-1.m | 15 + .../MATLAB/palindrome-detection-2.m | 5 + .../palindrome-detection-1.maxscript | 6 + .../palindrome-detection-2.maxscript | 15 + .../palindrome-detection-3.maxscript | 3 + .../MMIX/palindrome-detection.mmix | 68 +++ .../Mathematica/palindrome-detection.math | 1 + .../Maxima/palindrome-detection.maxima | 3 + .../Mirah/palindrome-detection.mirah | 12 + .../Modula-3/palindrome-detection.mod3 | 15 + .../Nemerle/palindrome-detection-1.nemerle | 16 + .../Nemerle/palindrome-detection-2.nemerle | 5 + .../NetRexx/palindrome-detection.netrexx | 16 + .../OCaml/palindrome-detection-1.ocaml | 10 + .../OCaml/palindrome-detection-2.ocaml | 14 + .../Objeck/palindrome-detection.objeck | 20 + .../Octave/palindrome-detection-1.octave | 14 + .../Octave/palindrome-detection-2.octave | 3 + .../Octave/palindrome-detection-3.octave | 2 + .../Oz/palindrome-detection.oz | 3 + .../PARI-GP/palindrome-detection.pari | 7 + .../PHP/palindrome-detection-1.php | 5 + .../PHP/palindrome-detection-2.php | 5 + .../PL-I/palindrome-detection.pli | 18 + .../Pascal/palindrome-detection-1.pascal | 23 + .../Pascal/palindrome-detection-2.pascal | 19 + .../Perl-6/palindrome-detection.pl6 | 16 + .../Perl/palindrome-detection-1.pl | 37 ++ .../Perl/palindrome-detection-2.pl | 23 + .../PicoLisp/palindrome-detection.l | 2 + .../Pike/palindrome-detection.pike | 16 + .../palindrome-detection.powerbasic | 32 ++ .../Prolog/palindrome-detection-1.pro | 1 + .../Prolog/palindrome-detection-2.pro | 2 + .../Prolog/palindrome-detection-3.pro | 2 + .../PureBasic/palindrome-detection.purebasic | 7 + .../Python/palindrome-detection-1.py | 2 + .../Python/palindrome-detection-2.py | 7 + .../Python/palindrome-detection-3.py | 2 + .../Python/palindrome-detection-4.py | 9 + .../R/palindrome-detection-1.r | 13 + .../R/palindrome-detection-2.r | 7 + .../R/palindrome-detection-3.r | 8 + .../REBOL/palindrome-detection.rebol | 31 + .../REXX/palindrome-detection.rexx | 17 + .../Racket/palindrome-detection.rkt | 14 + .../Rascal/palindrome-detection-1.rascal | 3 + .../Rascal/palindrome-detection-2.rascal | 6 + .../Rascal/palindrome-detection-3.rascal | 2 + .../Retro/palindrome-detection.retro | 4 + .../Ruby/palindrome-detection-1.rb | 3 + .../Ruby/palindrome-detection-2.rb | 9 + .../Ruby/palindrome-detection-3.rb | 9 + .../Run-BASIC/palindrome-detection.run | 13 + .../SNOBOL4/palindrome-detection.sno | 17 + .../Scala/palindrome-detection-1.scala | 1 + .../Scala/palindrome-detection-2.scala | 8 + .../Scala/palindrome-detection-3.scala | 1 + .../Scala/palindrome-detection-4.scala | 2 + .../Scala/palindrome-detection-5.scala | 4 + .../Scheme/palindrome-detection-1.ss | 3 + .../Scheme/palindrome-detection-2.ss | 20 + .../Seed7/palindrome-detection-1.seed7 | 14 + .../Seed7/palindrome-detection-2.seed7 | 1 + .../Slate/palindrome-detection-1.slate | 4 + .../Slate/palindrome-detection-2.slate | 6 + .../Slate/palindrome-detection-3.slate | 2 + .../Smalltalk/palindrome-detection-1.st | 4 + .../Smalltalk/palindrome-detection-2.st | 14 + .../Smalltalk/palindrome-detection-3.st | 4 + .../Smalltalk/palindrome-detection-4.st | 2 + .../TUSCRIPT/palindrome-detection.tuscript | 9 + .../Tcl/palindrome-detection-1.tcl | 4 + .../Tcl/palindrome-detection-2.tcl | 9 + .../Tcl/palindrome-detection-3.tcl | 3 + .../Ursala/palindrome-detection-1.ursala | 3 + .../Ursala/palindrome-detection-2.ursala | 3 + .../VBA/palindrome-detection.vba | 5 + .../VBScript/palindrome-detection-1.vbscript | 18 + .../VBScript/palindrome-detection-2.vbscript | 4 + .../VBScript/palindrome-detection-3.vbscript | 4 + .../palindrome-detection-1.vedit | 7 + .../palindrome-detection-2.vedit | 7 + .../XPL0/palindrome-detection.xpl0 | 26 + .../Yorick/palindrome-detection.yorick | 10 + Task/Pangram-checker/0DESCRIPTION | 3 + .../Pangram-checker/ACL2/pangram-checker.acl2 | 9 + .../ALGOL-68/pangram-checker.alg | 36 ++ Task/Pangram-checker/APL/pangram-checker.apl | 8 + Task/Pangram-checker/AWK/pangram-checker.awk | 17 + .../ActionScript/pangram-checker.as | 16 + Task/Pangram-checker/Ada/pangram-checker.ada | 20 + .../AutoHotkey/pangram-checker.ahk | 19 + .../AutoIt/pangram-checker.autoit | 9 + .../BASIC/pangram-checker.basic | 42 ++ .../BBC-BASIC/pangram-checker.bbc | 29 + .../Bracmat/pangram-checker.bracmat | 11 + .../Brat/pangram-checker-1.brat | 15 + .../Brat/pangram-checker-2.brat | 3 + Task/Pangram-checker/C++/pangram-checker.cpp | 16 + Task/Pangram-checker/C/pangram-checker-1.c | 36 ++ Task/Pangram-checker/C/pangram-checker-2.c | 23 + .../Clojure/pangram-checker.clj | 3 + .../CoffeeScript/pangram-checker.coffeescript | 34 ++ .../Common-Lisp/pangram-checker.lisp | 4 + Task/Pangram-checker/D/pangram-checker-1.d | 19 + Task/Pangram-checker/D/pangram-checker-2.d | 22 + .../Delphi/pangram-checker.delphi | 21 + Task/Pangram-checker/E/pangram-checker.e | 3 + .../Erlang/pangram-checker.erl | 5 + .../Factor/pangram-checker.factor | 4 + .../Pangram-checker/Forth/pangram-checker.fth | 10 + .../Fortran/pangram-checker-1.f | 48 ++ .../Fortran/pangram-checker-2.f | 15 + Task/Pangram-checker/Go/pangram-checker.go | 43 ++ .../Haskell/pangram-checker.hs | 7 + .../HicEst/pangram-checker.hicest | 8 + .../Icon/pangram-checker-1.icon | 3 + .../Icon/pangram-checker-2.icon | 11 + .../Ioke/pangram-checker-1.ioke | 5 + .../Ioke/pangram-checker-2.ioke | 7 + Task/Pangram-checker/J/pangram-checker-1.j | 2 + Task/Pangram-checker/J/pangram-checker-2.j | 4 + .../Pangram-checker/Java/pangram-checker.java | 18 + .../JavaScript/pangram-checker.js | 12 + Task/Pangram-checker/K/pangram-checker-1.k | 4 + Task/Pangram-checker/K/pangram-checker-2.k | 4 + .../Liberty-BASIC/pangram-checker.liberty | 12 + .../Pangram-checker/Logo/pangram-checker.logo | 10 + Task/Pangram-checker/Lua/pangram-checker.lua | 9 + .../MATLAB/pangram-checker-1.m | 12 + .../MATLAB/pangram-checker-2.m | 5 + Task/Pangram-checker/MATLAB/pangram-checker.m | 5 + .../Mathematica/pangram-checker.math | 1 + .../NetRexx/pangram-checker.netrexx | 29 + .../OCaml/pangram-checker-1.ocaml | 7 + .../OCaml/pangram-checker-2.ocaml | 7 + .../Objeck/pangram-checker.objeck | 23 + Task/Pangram-checker/Oz/pangram-checker.oz | 8 + .../PARI-GP/pangram-checker.pari | 12 + Task/Pangram-checker/PHP/pangram-checker.php | 20 + Task/Pangram-checker/PL-I/pangram-checker.pli | 28 + .../Perl-6/pangram-checker.pl6 | 13 + Task/Pangram-checker/Perl/pangram-checker.pl | 5 + .../PicoLisp/pangram-checker.l | 5 + .../Prolog/pangram-checker.pro | 12 + .../PureBasic/pangram-checker.purebasic | 31 + .../Pangram-checker/Python/pangram-checker.py | 9 + Task/Pangram-checker/R/pangram-checker.r | 10 + .../Pangram-checker/REXX/pangram-checker.rexx | 16 + .../Retro/pangram-checker.retro | 5 + Task/Pangram-checker/Ruby/pangram-checker.rb | 7 + .../Run-BASIC/pangram-checker.run | 13 + .../SNOBOL4/pangram-checker.sno | 18 + .../Scala/pangram-checker-1.scala | 1 + .../Scala/pangram-checker-2.scala | 5 + .../Seed7/pangram-checker.seed7 | 24 + .../Smalltalk/pangram-checker-1.st | 3 + .../Smalltalk/pangram-checker-2.st | 1 + .../TUSCRIPT/pangram-checker.tuscript | 13 + Task/Pangram-checker/TXR/pangram-checker.txr | 7 + Task/Pangram-checker/Tcl/pangram-checker.tcl | 9 + .../UNIX-Shell/pangram-checker.sh | 11 + .../Ursala/pangram-checker-1.ursala | 3 + .../Ursala/pangram-checker-2.ursala | 7 + Task/Pangram-checker/VBA/pangram-checker.vba | 14 + .../VBScript/pangram-checker-1.vbscript | 29 + .../VBScript/pangram-checker-2.vbscript | 2 + .../Pangram-checker/XPL0/pangram-checker.xpl0 | 31 + Task/Parallel-calculations/0DESCRIPTION | 18 + Task/Parallel-calculations/1META.yaml | 2 + .../Ada/parallel-calculations-1.ada | 22 + .../Ada/parallel-calculations-2.ada | 50 ++ .../Ada/parallel-calculations-3.ada | 54 ++ .../C++/parallel-calculations.cpp | 57 ++ .../C/parallel-calculations.c | 33 ++ .../Clojure/parallel-calculations.clj | 14 + .../D/parallel-calculations-1.d | 16 + .../D/parallel-calculations-2.d | 83 +++ .../Go/parallel-calculations.go | 96 ++++ .../J/parallel-calculations.j | 7 + .../JavaScript/parallel-calculations-1.js | 16 + .../JavaScript/parallel-calculations-2.js | 38 ++ .../Mathematica/parallel-calculations.math | 1 + .../OxygenBasic/parallel-calculations.oxy | 181 ++++++ .../PARI-GP/parallel-calculations.pari | 2 + .../Perl-6/parallel-calculations.pl6 | 5 + .../PicoLisp/parallel-calculations.l | 20 + .../Prolog/parallel-calculations.pro | 31 + .../PureBasic/parallel-calculations.purebasic | 87 +++ .../Python/parallel-calculations.py | 45 ++ .../Tcl/parallel-calculations-1.tcl | 42 ++ .../Tcl/parallel-calculations-2.tcl | 67 +++ .../Tcl/parallel-calculations-3.tcl | 15 + Task/Parametric-polymorphism/0DESCRIPTION | 5 + Task/Parametric-polymorphism/1META.yaml | 4 + .../Ada/parametric-polymorphism-1.ada | 14 + .../Ada/parametric-polymorphism-2.ada | 12 + .../C++/parametric-polymorphism-1.cpp | 9 + .../C++/parametric-polymorphism-2.cpp | 7 + .../C/parametric-polymorphism.c | 47 ++ .../Clean/parametric-polymorphism-1.clean | 5 + .../Clean/parametric-polymorphism-2.clean | 3 + .../Clean/parametric-polymorphism-3.clean | 2 + .../Common-Lisp/parametric-polymorphism.lisp | 2 + .../D/parametric-polymorphism.d | 46 ++ .../E/parametric-polymorphism-1.e | 31 + .../E/parametric-polymorphism-2.e | 11 + .../Go/parametric-polymorphism.go | 53 ++ .../Haskell/parametric-polymorphism-1.hs | 5 + .../Haskell/parametric-polymorphism-2.hs | 3 + .../Haskell/parametric-polymorphism-3.hs | 2 + .../Inform-7/parametric-polymorphism-1.inf | 13 + .../Inform-7/parametric-polymorphism-2.inf | 8 + .../Java/parametric-polymorphism.java | 13 + .../OCaml/parametric-polymorphism.ocaml | 6 + .../Perl-6/parametric-polymorphism.pl6 | 20 + .../PicoLisp/parametric-polymorphism.l | 4 + .../Racket/parametric-polymorphism.rkt | 20 + .../Scala/parametric-polymorphism-1.scala | 4 + .../Scala/parametric-polymorphism-2.scala | 5 + .../Scala/parametric-polymorphism-3.scala | 2 + .../Scala/parametric-polymorphism-4.scala | 1 + .../Scala/parametric-polymorphism-5.scala | 6 + .../Scala/parametric-polymorphism-6.scala | 2 + .../Scala/parametric-polymorphism-7.scala | 4 + .../Seed7/parametric-polymorphism.seed7 | 37 ++ .../Standard-ML/parametric-polymorphism.ml | 5 + .../Ursala/parametric-polymorphism-1.ursala | 1 + .../Ursala/parametric-polymorphism-2.ursala | 5 + .../Ursala/parametric-polymorphism-3.ursala | 1 + .../Ursala/parametric-polymorphism-4.ursala | 1 + .../Ursala/parametric-polymorphism-5.ursala | 1 + .../Ursala/parametric-polymorphism-6.ursala | 7 + Task/Parametrized-SQL-statement/0DESCRIPTION | 7 + Task/Parametrized-SQL-statement/1META.yaml | 2 + .../Ada/parametrized-sql-statement.ada | 38 ++ .../Java/parametrized-sql-statement.java | 28 + .../parametrized-sql-statement.math | 4 + .../parametrized-sql-statement.netrexx | 139 +++++ .../Objeck/parametrized-sql-statement.objeck | 19 + .../PHP/parametrized-sql-statement.php | 16 + .../Perl/parametrized-sql-statement.pl | 7 + .../PicoLisp/parametrized-sql-statement.l | 4 + .../parametrized-sql-statement.purebasic | 19 + .../Python/parametrized-sql-statement.py | 25 + .../Ruby/parametrized-sql-statement.rb | 33 ++ .../Tcl/parametrized-sql-statement.tcl | 22 + .../0DESCRIPTION | 14 + .../parsing-rpn-calculator-algorithm.antlr | 19 + .../Ada/parsing-rpn-calculator-algorithm.ada | 68 +++ .../parsing-rpn-calculator-algorithm.ahk | 35 ++ .../parsing-rpn-calculator-algorithm.bbc | 38 ++ .../C++/parsing-rpn-calculator-algorithm.cpp | 53 ++ .../C/parsing-rpn-calculator-algorithm-1.c | 62 ++ .../C/parsing-rpn-calculator-algorithm-2.c | 53 ++ .../parsing-rpn-calculator-algorithm.clj | 29 + .../D/parsing-rpn-calculator-algorithm.d | 26 + .../Ela/parsing-rpn-calculator-algorithm.ela | 21 + .../Go/parsing-rpn-calculator-algorithm.go | 43 ++ .../parsing-rpn-calculator-algorithm-1.groovy | 19 + .../parsing-rpn-calculator-algorithm-2.groovy | 1 + .../parsing-rpn-calculator-algorithm.hs | 15 + .../parsing-rpn-calculator-algorithm.icon | 33 ++ .../J/parsing-rpn-calculator-algorithm-1.j | 4 + .../J/parsing-rpn-calculator-algorithm-2.j | 32 ++ .../parsing-rpn-calculator-algorithm.java | 59 ++ .../parsing-rpn-calculator-algorithm.netrexx | 88 +++ .../parsing-rpn-calculator-algorithm.objeck | 63 ++ .../PHP/parsing-rpn-calculator-algorithm.php | 24 + .../PL-I/parsing-rpn-calculator-algorithm.pli | 32 ++ .../parsing-rpn-calculator-algorithm.pl6 | 22 + .../Perl/parsing-rpn-calculator-algorithm.pl | 17 + .../parsing-rpn-calculator-algorithm-1.l | 12 + .../parsing-rpn-calculator-algorithm-2.l | 17 + .../parsing-rpn-calculator-algorithm.pro | 47 ++ .../parsing-rpn-calculator-algorithm.py | 59 ++ .../parsing-rpn-calculator-algorithm-1.rexx | 53 ++ .../parsing-rpn-calculator-algorithm-2.rexx | 27 + .../parsing-rpn-calculator-algorithm-3.rexx | 42 ++ .../Ruby/parsing-rpn-calculator-algorithm.rb | 2 + .../parsing-rpn-calculator-algorithm.run | 34 ++ .../Tcl/parsing-rpn-calculator-algorithm.tcl | 49 ++ .../0DESCRIPTION | 37 ++ .../AWK/parsing-rpn-to-infix-conversion.awk | 102 ++++ .../Ada/parsing-rpn-to-infix-conversion-1.ada | 82 +++ .../Ada/parsing-rpn-to-infix-conversion-2.ada | 12 + .../parsing-rpn-to-infix-conversion.ahk | 46 ++ .../D/parsing-rpn-to-infix-conversion.d | 43 ++ .../Go/parsing-rpn-to-infix-conversion.go | 63 ++ .../Icon/parsing-rpn-to-infix-conversion.icon | 58 ++ .../J/parsing-rpn-to-infix-conversion-1.j | 36 ++ .../J/parsing-rpn-to-infix-conversion-2.j | 102 ++++ .../PL-I/parsing-rpn-to-infix-conversion.pli | 54 ++ .../parsing-rpn-to-infix-conversion.pl6 | 23 + .../Perl/parsing-rpn-to-infix-conversion.pl | 14 + .../parsing-rpn-to-infix-conversion-1.l | 33 ++ .../parsing-rpn-to-infix-conversion-2.l | 31 + .../Python/parsing-rpn-to-infix-conversion.py | 223 +++++++ .../REXX/parsing-rpn-to-infix-conversion.rexx | 36 ++ .../Ruby/parsing-rpn-to-infix-conversion.rb | 3 + .../Tcl/parsing-rpn-to-infix-conversion.tcl | 39 ++ .../0DESCRIPTION | 32 ++ .../parsing-shunting-yard-algorithm.ahk | 70 +++ .../C/parsing-shunting-yard-algorithm.c | 181 ++++++ .../Go/parsing-shunting-yard-algorithm.go | 72 +++ .../parsing-shunting-yard-algorithm.hs | 53 ++ .../Icon/parsing-shunting-yard-algorithm.icon | 64 +++ .../J/parsing-shunting-yard-algorithm-1.j | 144 +++++ .../J/parsing-shunting-yard-algorithm-2.j | 55 ++ .../parsing-shunting-yard-algorithm-1.pli | 82 +++ .../parsing-shunting-yard-algorithm-2.pli | 32 ++ .../parsing-shunting-yard-algorithm-1.l | 41 ++ .../parsing-shunting-yard-algorithm-2.l | 22 + .../Python/parsing-shunting-yard-algorithm.py | 103 ++++ .../parsing-shunting-yard-algorithm-1.rexx | 48 ++ .../parsing-shunting-yard-algorithm-2.rexx | 57 ++ .../Ruby/parsing-shunting-yard-algorithm.rb | 1 + .../Tcl/parsing-shunting-yard-algorithm.tcl | 58 ++ .../Partial-function-application/0DESCRIPTION | 27 + Task/Partial-function-application/1META.yaml | 2 + .../ALGOL-68/partial-function-application.alg | 27 + .../Ada/partial-function-application.ada | 50 ++ .../partial-function-application.bbc | 39 ++ .../C++/partial-function-application.cpp | 71 +++ .../C-sharp/partial-function-application.cs | 28 + .../C/partial-function-application-1.c | 58 ++ .../C/partial-function-application-2.c | 10 + .../Clojure/partial-function-application.clj | 10 + ...artial-function-application-1.coffeescript | 13 + ...artial-function-application-2.coffeescript | 5 + .../partial-function-application.lisp | 12 + .../D/partial-function-application.d | 19 + .../E/partial-function-application.e | 26 + .../Haskell/partial-function-application.hs | 13 + .../Icon/partial-function-application.icon | 39 ++ .../J/partial-function-application-1.j | 5 + .../J/partial-function-application-2.j | 8 + .../J/partial-function-application-3.j | 8 + .../J/partial-function-application-4.j | 9 + .../J/partial-function-application-5.j | 6 + .../Java/partial-function-application-1.java | 63 ++ .../Java/partial-function-application-2.java | 43 ++ .../partial-function-application.math | 5 + .../partial-function-application.mercury | 36 ++ .../partial-function-application.nemerle | 45 ++ .../OCaml/partial-function-application.ocaml | 22 + .../Order/partial-function-application.order | 16 + .../Perl-6/partial-function-application.pl6 | 11 + .../Perl/partial-function-application.pl | 18 + .../PicoLisp/partial-function-application.l | 14 + .../Prolog/partial-function-application.pro | 25 + .../Python/partial-function-application-1.py | 18 + .../Python/partial-function-application-2.py | 13 + .../R/partial-function-application.r | 18 + .../Racket/partial-function-application.rkt | 13 + .../Ruby/partial-function-application.rb | 10 + .../Scala/partial-function-application.scala | 11 + .../Smalltalk/partial-function-application.st | 19 + .../Tcl/partial-function-application-1.tcl | 9 + .../Tcl/partial-function-application-2.tcl | 15 + Task/Pascals-triangle-Puzzle/0DESCRIPTION | 12 + .../ALGOL-68/pascals-triangle-puzzle.alg | 96 ++++ .../Ada/pascals-triangle-puzzle.ada | 69 +++ .../AutoHotkey/pascals-triangle-puzzle-1.ahk | 4 + .../AutoHotkey/pascals-triangle-puzzle-2.ahk | 274 +++++++++ .../BBC-BASIC/pascals-triangle-puzzle.bbc | 39 ++ .../C/pascals-triangle-puzzle-1.c | 39 ++ .../C/pascals-triangle-puzzle-2.c | 73 +++ .../C/pascals-triangle-puzzle-3.c | 13 + .../Clojure/pascals-triangle-puzzle-1.clj | 9 + .../Clojure/pascals-triangle-puzzle-2.clj | 5 + .../Clojure/pascals-triangle-puzzle-3.clj | 11 + .../Clojure/pascals-triangle-puzzle-4.clj | 5 + .../D/pascals-triangle-puzzle.d | 69 +++ .../Go/pascals-triangle-puzzle.go | 134 +++++ .../Haskell/pascals-triangle-puzzle-1.hs | 1 + .../Haskell/pascals-triangle-puzzle-2.hs | 29 + .../Haskell/pascals-triangle-puzzle-3.hs | 10 + .../Haskell/pascals-triangle-puzzle-4.hs | 4 + .../J/pascals-triangle-puzzle-1.j | 1 + .../J/pascals-triangle-puzzle-2.j | 1 + .../J/pascals-triangle-puzzle-3.j | 1 + .../J/pascals-triangle-puzzle-4.j | 1 + .../J/pascals-triangle-puzzle-5.j | 1 + .../J/pascals-triangle-puzzle-6.j | 1 + .../pascals-triangle-puzzle-1.math | 11 + .../pascals-triangle-puzzle-2.math | 4 + .../pascals-triangle-puzzle-3.math | 3 + .../pascals-triangle-puzzle-4.math | 1 + .../pascals-triangle-puzzle-5.math | 5 + .../Oz/pascals-triangle-puzzle.oz | 69 +++ .../PARI-GP/pascals-triangle-puzzle.pari | 5 + .../PicoLisp/pascals-triangle-puzzle.l | 43 ++ .../Prolog/pascals-triangle-puzzle.pro | 19 + .../pascals-triangle-puzzle.purebasic | 31 + .../Python/pascals-triangle-puzzle-1.py | 122 ++++ .../Python/pascals-triangle-puzzle-2.py | 19 + .../Python/pascals-triangle-puzzle-3.py | 1 + .../REXX/pascals-triangle-puzzle.rexx | 33 ++ .../Ruby/pascals-triangle-puzzle.rb | 59 ++ .../SystemVerilog/pascals-triangle-puzzle.v | 38 ++ .../Tcl/pascals-triangle-puzzle.tcl | 68 +++ Task/Pascals-triangle/0DESCRIPTION | 8 + Task/Pascals-triangle/1META.yaml | 2 + .../ALGOL-68/pascals-triangle.alg | 19 + .../APL/pascals-triangle-1.apl | 1 + .../APL/pascals-triangle-2.apl | 1 + .../Pascals-triangle/AWK/pascals-triangle.awk | 7 + .../Pascals-triangle/Ada/pascals-triangle.ada | 34 ++ .../AutoHotkey/pascals-triangle.ahk | 22 + .../BASIC/pascals-triangle.basic | 16 + .../BBC-BASIC/pascals-triangle.bbc | 13 + .../Bracmat/pascals-triangle.bracmat | 18 + .../Burlesque/pascals-triangle.blq | 18 + .../Pascals-triangle/C++/pascals-triangle.cpp | 26 + Task/Pascals-triangle/C/pascals-triangle-1.c | 22 + Task/Pascals-triangle/C/pascals-triangle-2.c | 18 + Task/Pascals-triangle/C/pascals-triangle-3.c | 16 + .../Clojure/pascals-triangle-1.clj | 12 + .../Clojure/pascals-triangle-2.clj | 8 + .../Clojure/pascals-triangle-3.clj | 7 + .../pascals-triangle.coffeescript | 28 + .../Common-Lisp/pascals-triangle.lisp | 12 + Task/Pascals-triangle/D/pascals-triangle-1.d | 25 + Task/Pascals-triangle/D/pascals-triangle-2.d | 12 + Task/Pascals-triangle/D/pascals-triangle-3.d | 42 ++ .../DWScript/pascals-triangle.dwscript | 15 + Task/Pascals-triangle/E/pascals-triangle-1.e | 20 + Task/Pascals-triangle/E/pascals-triangle-2.e | 7 + .../Erlang/pascals-triangle.erl | 8 + .../Euphoria/pascals-triangle.euphoria | 10 + .../Factor/pascals-triangle-1.factor | 7 + .../Factor/pascals-triangle-2.factor | 2 + .../Fantom/pascals-triangle.fantom | 29 + .../Forth/pascals-triangle-1.fth | 11 + .../Forth/pascals-triangle-2.fth | 8 + .../Fortran/pascals-triangle.f | 26 + .../Pascals-triangle/GAP/pascals-triangle.gap | 19 + .../GW-BASIC/pascals-triangle.gw-basic | 9 + Task/Pascals-triangle/Go/pascals-triangle.go | 42 ++ .../Groovy/pascals-triangle-1.groovy | 1 + .../Groovy/pascals-triangle-2.groovy | 4 + .../Haskell/pascals-triangle-1.hs | 4 + .../Haskell/pascals-triangle-2.hs | 2 + .../Haskell/pascals-triangle-3.hs | 1 + .../Haskell/pascals-triangle-4.hs | 2 + .../Haskell/pascals-triangle-5.hs | 5 + .../Haskell/pascals-triangle-6.hs | 5 + .../Haskell/pascals-triangle-7.hs | 11 + .../HicEst/pascals-triangle.hicest | 15 + .../Pascals-triangle/IDL/pascals-triangle.idl | 17 + .../Icon/pascals-triangle.icon | 20 + Task/Pascals-triangle/J/pascals-triangle-1.j | 6 + Task/Pascals-triangle/J/pascals-triangle-2.j | 6 + Task/Pascals-triangle/J/pascals-triangle-3.j | 6 + .../Java/pascals-triangle-1.java | 21 + .../Java/pascals-triangle-2.java | 27 + .../Java/pascals-triangle-3.java | 19 + .../JavaScript/pascals-triangle.js | 71 +++ Task/Pascals-triangle/K/pascals-triangle.k | 9 + .../Liberty-BASIC/pascals-triangle.liberty | 19 + .../pascals-triangle.locomotive | 12 + .../Logo/pascals-triangle.logo | 7 + .../Pascals-triangle/Lua/pascals-triangle.lua | 14 + .../MATLAB/pascals-triangle-1.m | 1 + .../MATLAB/pascals-triangle-2.m | 1 + .../Mathematica/pascals-triangle.math | 2 + .../Maxima/pascals-triangle.maxima | 12 + .../Metafont/pascals-triangle.metafont | 18 + .../Nial/pascals-triangle-1.nial | 5 + .../Nial/pascals-triangle-2.nial | 2 + .../OCaml/pascals-triangle.ocaml | 10 + .../Octave/pascals-triangle.octave | 13 + Task/Pascals-triangle/Oz/pascals-triangle.oz | 31 + .../PARI-GP/pascals-triangle.pari | 15 + .../Pascals-triangle/PHP/pascals-triangle.php | 23 + .../PL-I/pascals-triangle-1.pli | 15 + .../PL-I/pascals-triangle-2.pli | 11 + .../Pascal/pascals-triangle.pascal | 21 + .../Perl-6/pascals-triangle-1.pl6 | 7 + .../Perl-6/pascals-triangle-2.pl6 | 8 + .../Perl-6/pascals-triangle-3.pl6 | 3 + .../Perl-6/pascals-triangle-4.pl6 | 3 + .../Perl/pascals-triangle-1.pl | 13 + .../Perl/pascals-triangle-2.pl | 3 + .../PicoLisp/pascals-triangle.l | 8 + .../PowerShell/pascals-triangle.psh | 64 +++ .../Prolog/pascals-triangle-1.pro | 36 ++ .../Prolog/pascals-triangle-2.pro | 18 + .../PureBasic/pascals-triangle.purebasic | 17 + .../Python/pascals-triangle-1.py | 9 + .../Python/pascals-triangle-2.py | 17 + Task/Pascals-triangle/Qi/pascals-triangle.qi | 9 + Task/Pascals-triangle/R/pascals-triangle-1.r | 10 + Task/Pascals-triangle/R/pascals-triangle-2.r | 3 + .../REXX/pascals-triangle.rexx | 28 + .../Racket/pascals-triangle.rkt | 14 + .../RapidQ/pascals-triangle-1.rapidq | 12 + .../RapidQ/pascals-triangle-2.rapidq | 10 + .../Retro/pascals-triangle.retro | 6 + .../Ruby/pascals-triangle-1.rb | 27 + .../Ruby/pascals-triangle-2.rb | 3 + .../Run-BASIC/pascals-triangle.run | 10 + .../Scala/pascals-triangle-1.scala | 5 + .../Scala/pascals-triangle-2.scala | 2 + .../Scheme/pascals-triangle-1.ss | 9 + .../Scheme/pascals-triangle-2.ss | 1 + .../Seed7/pascals-triangle.seed7 | 22 + .../Tcl/pascals-triangle-1.tcl | 18 + .../Tcl/pascals-triangle-2.tcl | 15 + .../Tcl/pascals-triangle-3.tcl | 35 ++ .../Tcl/pascals-triangle-4.tcl | 5 + .../Turing/pascals-triangle.turing | 13 + .../Ursala/pascals-triangle-1.ursala | 4 + .../Ursala/pascals-triangle-2.ursala | 4 + .../Ursala/pascals-triangle-3.ursala | 3 + .../pascals-triangle-1.vedit | 13 + .../pascals-triangle-2.vedit | 10 + .../XPL0/pascals-triangle.xpl0 | 22 + Task/Pattern-matching/0DESCRIPTION | 5 + Task/Pattern-matching/1META.yaml | 2 + .../Bracmat/pattern-matching-1.bracmat | 47 ++ .../Bracmat/pattern-matching-2.bracmat | 8 + .../Bracmat/pattern-matching-3.bracmat | 20 + .../Common-Lisp/pattern-matching.lisp | 39 ++ .../Haskell/pattern-matching.hs | 18 + Task/Pattern-matching/J/pattern-matching-1.j | 196 +++++++ Task/Pattern-matching/J/pattern-matching-2.j | 11 + .../OCaml/pattern-matching.ocaml | 24 + Task/Pattern-matching/Oz/pattern-matching.oz | 24 + .../Perl-6/pattern-matching.pl6 | 25 + .../PicoLisp/pattern-matching-1.l | 35 ++ .../PicoLisp/pattern-matching-2.l | 3 + .../Racket/pattern-matching.rkt | 28 + .../Rascal/pattern-matching-1.rascal | 65 +++ .../Rascal/pattern-matching-2.rascal | 8 + .../Rascal/pattern-matching-3.rascal | 40 ++ .../Rascal/pattern-matching-4.rascal | 4 + .../Scala/pattern-matching.scala | 33 ++ .../Standard-ML/pattern-matching.ml | 24 + .../Tcl/pattern-matching-1.tcl | 70 +++ .../Tcl/pattern-matching-2.tcl | 30 + .../0DESCRIPTION | 19 + .../1META.yaml | 2 + ...percentage-difference-between-images-1.ada | 1 + ...percentage-difference-between-images-2.ada | 8 + ...percentage-difference-between-images-3.ada | 4 + ...percentage-difference-between-images-4.ada | 15 + ...percentage-difference-between-images-5.ada | 7 + .../percentage-difference-between-images.ahk | 85 +++ .../percentage-difference-between-images.bbc | 48 ++ .../percentage-difference-between-images.cpp | 43 ++ .../C/percentage-difference-between-images.c | 45 ++ .../percentage-difference-between-images.lisp | 14 + .../D/percentage-difference-between-images.d | 17 + .../E/percentage-difference-between-images.e | 29 + .../percentage-difference-between-images.fth | 17 + .../percentage-difference-between-images.f | 32 ++ .../percentage-difference-between-images-1.go | 65 +++ .../percentage-difference-between-images-2.go | 72 +++ .../percentage-difference-between-images-3.go | 26 + .../percentage-difference-between-images.icon | 34 ++ .../J/percentage-difference-between-images.j | 3 + .../percentage-difference-between-images.java | 48 ++ ...rcentage-difference-between-images.liberty | 81 +++ ...entage-difference-between-images.maxscript | 19 + .../percentage-difference-between-images.math | 5 + ...percentage-difference-between-images.ocaml | 36 ++ .../percentage-difference-between-images.l | 14 + ...entage-difference-between-images.purebasic | 52 ++ .../percentage-difference-between-images.py | 17 + ...percentage-difference-between-images.rebol | 52 ++ .../percentage-difference-between-images.rb | 27 + .../percentage-difference-between-images.tcl | 26 + ...percentage-difference-between-images.vedit | 30 + Task/Perfect-numbers/0DESCRIPTION | 9 + Task/Perfect-numbers/1META.yaml | 2 + .../ALGOL-68/perfect-numbers.alg | 21 + Task/Perfect-numbers/AWK/perfect-numbers.awk | 6 + Task/Perfect-numbers/Ada/perfect-numbers.ada | 10 + .../AutoHotkey/perfect-numbers.ahk | 22 + .../Axiom/perfect-numbers-1.axiom | 1 + .../Axiom/perfect-numbers-2.axiom | 7 + .../Axiom/perfect-numbers-3.axiom | 3 + .../Axiom/perfect-numbers-4.axiom | 3 + .../BASIC/perfect-numbers.basic | 13 + .../BBC-BASIC/perfect-numbers-1.bbc | 13 + .../BBC-BASIC/perfect-numbers-2.bbc | 10 + .../Bracmat/perfect-numbers.bracmat | 18 + Task/Perfect-numbers/C++/perfect-numbers.cpp | 21 + Task/Perfect-numbers/C/perfect-numbers-1.c | 27 + Task/Perfect-numbers/C/perfect-numbers-2.c | 15 + .../Clojure/perfect-numbers-1.clj | 8 + .../Clojure/perfect-numbers-2.clj | 2 + .../CoffeeScript/perfect-numbers.coffeescript | 49 ++ .../Common-Lisp/perfect-numbers.lisp | 2 + Task/Perfect-numbers/D/perfect-numbers-1.d | 21 + Task/Perfect-numbers/D/perfect-numbers-2.d | 9 + Task/Perfect-numbers/E/perfect-numbers.e | 9 + .../Erlang/perfect-numbers.erl | 2 + .../FALSE/perfect-numbers.false | 2 + .../Factor/perfect-numbers.factor | 4 + .../Perfect-numbers/Forth/perfect-numbers.fth | 6 + .../Perfect-numbers/Fortran/perfect-numbers.f | 12 + Task/Perfect-numbers/GAP/perfect-numbers.gap | 2 + Task/Perfect-numbers/Go/perfect-numbers.go | 36 ++ .../Groovy/perfect-numbers-1.groovy | 3 + .../Groovy/perfect-numbers-2.groovy | 1 + .../Haskell/perfect-numbers-1.hs | 1 + .../Haskell/perfect-numbers-2.hs | 15 + .../HicEst/perfect-numbers.hicest | 12 + .../Perfect-numbers/Icon/perfect-numbers.icon | 15 + Task/Perfect-numbers/J/perfect-numbers-1.j | 1 + Task/Perfect-numbers/J/perfect-numbers-2.j | 14 + .../Java/perfect-numbers-1.java | 9 + .../Java/perfect-numbers-2.java | 12 + .../JavaScript/perfect-numbers.js | 21 + .../Julia/perfect-numbers.julia | 20 + Task/Perfect-numbers/K/perfect-numbers.k | 16 + .../Liberty-BASIC/perfect-numbers.liberty | 19 + .../Perfect-numbers/Logo/perfect-numbers.logo | 3 + Task/Perfect-numbers/Lua/perfect-numbers.lua | 7 + Task/Perfect-numbers/M4/perfect-numbers.m4 | 19 + .../MAXScript/perfect-numbers.maxscript | 12 + .../Mathematica/perfect-numbers-1.math | 1 + .../Mathematica/perfect-numbers-2.math | 3 + .../Mathematica/perfect-numbers-3.math | 3 + .../Maxima/perfect-numbers.maxima | 7 + .../OCaml/perfect-numbers-1.ocaml | 7 + .../OCaml/perfect-numbers-2.ocaml | 8 + .../Objeck/perfect-numbers.objeck | 23 + Task/Perfect-numbers/Oz/perfect-numbers.oz | 12 + .../PARI-GP/perfect-numbers-1.pari | 1 + .../PARI-GP/perfect-numbers-2.pari | 3 + .../PARI-GP/perfect-numbers-3.pari | 9 + Task/Perfect-numbers/PHP/perfect-numbers.php | 17 + Task/Perfect-numbers/PL-I/perfect-numbers.pli | 11 + .../Pascal/perfect-numbers.pascal | 23 + .../Perl-6/perfect-numbers.pl6 | 1 + .../Perfect-numbers/Perl/perfect-numbers-1.pl | 10 + .../Perfect-numbers/Perl/perfect-numbers-2.pl | 6 + .../PicoLisp/perfect-numbers.l | 5 + .../PowerShell/perfect-numbers.psh | 14 + .../Prolog/perfect-numbers-1.pro | 14 + .../Prolog/perfect-numbers-2.pro | 37 ++ .../PureBasic/perfect-numbers.purebasic | 13 + .../Python/perfect-numbers-1.py | 6 + .../Python/perfect-numbers-2.py | 1 + Task/Perfect-numbers/R/perfect-numbers.r | 11 + .../REBOL/perfect-numbers.rebol | 9 + .../REXX/perfect-numbers-1.rexx | 22 + .../REXX/perfect-numbers-2.rexx | 33 ++ .../Perfect-numbers/Ruby/perfect-numbers-1.rb | 9 + .../Perfect-numbers/Ruby/perfect-numbers-2.rb | 3 + .../Run-BASIC/perfect-numbers.run | 10 + .../Scala/perfect-numbers.scala | 1 + .../Perfect-numbers/Scheme/perfect-numbers.ss | 9 + .../Seed7/perfect-numbers.seed7 | 32 ++ .../Slate/perfect-numbers.slate | 5 + .../Smalltalk/perfect-numbers-1.st | 21 + .../Smalltalk/perfect-numbers-2.st | 1 + Task/Perfect-numbers/Tcl/perfect-numbers.tcl | 7 + .../Ursala/perfect-numbers-1.ursala | 4 + .../Ursala/perfect-numbers-2.ursala | 3 + Task/Permutation-test/0DESCRIPTION | 49 ++ Task/Permutation-test/1META.yaml | 2 + .../Ada/permutation-test-1.ada | 62 ++ .../Ada/permutation-test-2.ada | 16 + .../Ada/permutation-test-3.ada | 34 ++ .../BBC-BASIC/permutation-test.bbc | 38 ++ Task/Permutation-test/C/permutation-test-1.c | 29 + Task/Permutation-test/C/permutation-test-2.c | 2 + .../Common-Lisp/permutation-test-1.lisp | 24 + .../Common-Lisp/permutation-test-2.lisp | 2 + Task/Permutation-test/D/permutation-test.d | 32 ++ .../Permutation-test/GAP/permutation-test.gap | 51 ++ Task/Permutation-test/Go/permutation-test.go | 72 +++ .../Haskell/permutation-test-1.hs | 21 + .../Haskell/permutation-test-2.hs | 19 + .../Haskell/permutation-test-3.hs | 26 + Task/Permutation-test/J/permutation-test-1.j | 8 + Task/Permutation-test/J/permutation-test-2.j | 2 + .../Mathematica/permutation-test.math | 6 + .../PicoLisp/permutation-test.l | 32 ++ .../PureBasic/permutation-test.purebasic | 90 +++ .../Python/permutation-test-1.py | 20 + .../Python/permutation-test-2.py | 15 + Task/Permutation-test/R/permutation-test-1.r | 8 + Task/Permutation-test/R/permutation-test-2.r | 4 + .../REXX/permutation-test.rexx | 30 + .../Tcl/permutation-test-1.tcl | 47 ++ .../Tcl/permutation-test-2.tcl | 4 + .../Ursala/permutation-test.ursala | 16 + Task/Permutations-Derangements/0DESCRIPTION | 19 + .../Ada/permutations-derangements.ada | 54 ++ .../AutoHotkey/permutations-derangements.ahk | 96 ++++ .../BBC-BASIC/permutations-derangements-1.bbc | 75 +++ .../BBC-BASIC/permutations-derangements-2.bbc | 26 + .../C/permutations-derangements.c | 57 ++ .../D/permutations-derangements-1.d | 65 +++ .../D/permutations-derangements-2.d | 47 ++ .../GAP/permutations-derangements.gap | 35 ++ .../Go/permutations-derangements.go | 71 +++ .../Groovy/permutations-derangements-1.groovy | 9 + .../Groovy/permutations-derangements-2.groovy | 16 + .../Haskell/permutations-derangements-1.hs | 25 + .../Haskell/permutations-derangements-2.hs | 3 + .../J/permutations-derangements-1.j | 2 + .../J/permutations-derangements-2.j | 25 + .../Java/permutations-derangements.java | 95 +++ .../permutations-derangements.math | 5 + .../PARI-GP/permutations-derangements.pari | 19 + .../Perl-6/permutations-derangements.pl6 | 32 ++ .../Perl/permutations-derangements.pl | 66 +++ .../PicoLisp/permutations-derangements.l | 13 + .../permutations-derangements-1.purebasic | 123 ++++ .../permutations-derangements-2.purebasic | 57 ++ .../Python/permutations-derangements.py | 41 ++ .../REXX/permutations-derangements.rexx | 43 ++ .../Ruby/permutations-derangements.rb | 25 + .../Tcl/permutations-derangements-1.tcl | 37 ++ .../Tcl/permutations-derangements-2.tcl | 11 + Task/Permutations-by-swapping/0DESCRIPTION | 12 + .../BBC-BASIC/permutations-by-swapping.bbc | 35 ++ .../D/permutations-by-swapping-1.d | 91 +++ .../D/permutations-by-swapping-2.d | 34 ++ .../Haskell/permutations-by-swapping.hs | 18 + .../J/permutations-by-swapping-1.j | 4 + .../J/permutations-by-swapping-2.j | 16 + .../J/permutations-by-swapping-3.j | 7 + .../J/permutations-by-swapping-4.j | 7 + .../J/permutations-by-swapping-5.j | 5 + .../J/permutations-by-swapping-6.j | 7 + .../permutations-by-swapping-1.math | 5 + .../permutations-by-swapping-2.math | 1 + .../Perl-6/permutations-by-swapping.pl6 | 12 + .../Python/permutations-by-swapping-1.py | 60 ++ .../Python/permutations-by-swapping-2.py | 19 + .../Python/permutations-by-swapping-3.py | 17 + .../Tcl/permutations-by-swapping-1.tcl | 50 ++ .../Tcl/permutations-by-swapping-2.tcl | 3 + .../XPL0/permutations-by-swapping.xpl0 | 36 ++ Task/Permutations/0DESCRIPTION | 4 + Task/Permutations/1META.yaml | 2 + Task/Permutations/ABAP/permutations.abap | 100 ++++ Task/Permutations/ALGOL-68/permutations-1.alg | 61 ++ Task/Permutations/ALGOL-68/permutations-2.alg | 23 + Task/Permutations/Ada/permutations.ada | 113 ++++ Task/Permutations/AutoHotkey/permutations.ahk | 49 ++ Task/Permutations/BBC-BASIC/permutations.bbc | 38 ++ .../Permutations/Bracmat/permutations.bracmat | 13 + Task/Permutations/C++/permutations.cpp | 40 ++ Task/Permutations/C/permutations.c | 100 ++++ Task/Permutations/Clojure/permutations.clj | 4 + .../CoffeeScript/permutations-1.coffeescript | 18 + .../CoffeeScript/permutations-2.coffeescript | 7 + .../Common-Lisp/permutations-1.lisp | 9 + .../Common-Lisp/permutations-2.lisp | 18 + Task/Permutations/D/permutations-1.d | 21 + Task/Permutations/D/permutations-2.d | 86 +++ Task/Permutations/D/permutations-3.d | 8 + Task/Permutations/Delphi/permutations.delphi | 58 ++ Task/Permutations/Erlang/permutations-1.erl | 5 + Task/Permutations/Erlang/permutations-2.erl | 1 + Task/Permutations/Erlang/permutations-3.erl | 18 + Task/Permutations/Erlang/permutations-4.erl | 1 + .../Euphoria/permutations.euphoria | 48 ++ Task/Permutations/Fortran/permutations-1.f | 33 ++ Task/Permutations/Fortran/permutations-2.f | 41 ++ Task/Permutations/GAP/permutations-1.gap | 6 + Task/Permutations/GAP/permutations-2.gap | 4 + Task/Permutations/GAP/permutations-3.gap | 44 ++ Task/Permutations/Go/permutations.go | 52 ++ .../Permutations/Groovy/permutations-1.groovy | 1 + .../Permutations/Groovy/permutations-2.groovy | 4 + Task/Permutations/Haskell/permutations-1.hs | 3 + Task/Permutations/Haskell/permutations-2.hs | 5 + Task/Permutations/Haskell/permutations-3.hs | 5 + Task/Permutations/Haskell/permutations-4.hs | 5 + Task/Permutations/Icon/permutations.icon | 8 + Task/Permutations/J/permutations-1.j | 1 + Task/Permutations/J/permutations-2.j | 10 + Task/Permutations/Java/permutations-1.java | 83 +++ Task/Permutations/Java/permutations-2.java | 5 + Task/Permutations/JavaScript/permutations.js | 23 + Task/Permutations/K/permutations.k | 12 + .../Logtalk/permutations-1.logtalk | 22 + .../Logtalk/permutations-2.logtalk | 9 + Task/Permutations/Lua/permutations.lua | 17 + Task/Permutations/Maple/permutations.maple | 5 + .../Mathematica/permutations.math | 1 + .../Permutations/Maxima/permutations-1.maxima | 24 + .../Permutations/Maxima/permutations-2.maxima | 2 + Task/Permutations/OCaml/permutations-1.ocaml | 45 ++ Task/Permutations/OCaml/permutations-2.ocaml | 15 + Task/Permutations/OCaml/permutations-3.ocaml | 17 + Task/Permutations/PARI-GP/permutations.pari | 1 + Task/Permutations/Pascal/permutations.pascal | 71 +++ Task/Permutations/Perl-6/permutations-1.pl6 | 8 + Task/Permutations/Perl-6/permutations-2.pl6 | 16 + Task/Permutations/Perl/permutations.pl | 8 + Task/Permutations/PicoLisp/permutations.l | 3 + .../PowerBASIC/permutations.powerbasic | 26 + Task/Permutations/Prolog/permutations-1.pro | 7 + Task/Permutations/Prolog/permutations-2.pro | 8 + Task/Permutations/Prolog/permutations-3.pro | 7 + Task/Permutations/Prolog/permutations-4.pro | 8 + .../PureBasic/permutations.purebasic | 57 ++ Task/Permutations/Python/permutations.py | 3 + Task/Permutations/Qi/permutations.qi | 19 + Task/Permutations/R/permutations.r | 48 ++ Task/Permutations/REXX/permutations-1.rexx | 34 ++ Task/Permutations/REXX/permutations-2.rexx | 22 + Task/Permutations/Ruby/permutations-1.rb | 1 + Task/Permutations/Ruby/permutations-2.rb | 37 ++ Task/Permutations/Run-BASIC/permutations.run | 25 + Task/Permutations/SAS/permutations.sas | 42 ++ Task/Permutations/Scala/permutations.scala | 1 + Task/Permutations/Scheme/permutations-1.ss | 19 + Task/Permutations/Scheme/permutations-2.ss | 61 ++ Task/Permutations/Scheme/permutations-3.ss | 11 + Task/Permutations/Seed7/permutations.seed7 | 37 ++ Task/Permutations/Smalltalk/permutations.st | 2 + Task/Permutations/Tcl/permutations.tcl | 10 + .../Permutations/Ursala/permutations-1.ursala | 9 + .../Permutations/Ursala/permutations-2.ursala | 3 + Task/Permutations/VBA/permutations.vba | 64 +++ Task/Permutations/XPL0/permutations.xpl0 | 25 + Task/Pick-random-element/0DESCRIPTION | 1 + Task/Pick-random-element/1META.yaml | 2 + .../ACL2/pick-random-element.acl2 | 6 + .../Ada/pick-random-element.ada | 30 + .../Aime/pick-random-element.aime | 11 + .../AutoHotkey/pick-random-element-1.ahk | 3 + .../AutoHotkey/pick-random-element-2.ahk | 4 + .../BASIC/pick-random-element.basic | 13 + .../BBC-BASIC/pick-random-element.bbc | 4 + .../Burlesque/pick-random-element.blq | 2 + .../C/pick-random-element.c | 13 + .../Clojure/pick-random-element-1.clj | 1 + .../Clojure/pick-random-element-2.clj | 1 + .../pick-random-element.coffeescript | 2 + .../D/pick-random-element.d | 7 + .../Deja-Vu/pick-random-element.djv | 1 + .../Euphoria/pick-random-element.euphoria | 2 + .../Factor/pick-random-element.factor | 2 + .../Go/pick-random-element.go | 14 + .../Groovy/pick-random-element.groovy | 7 + .../Haskell/pick-random-element-1.hs | 6 + .../Haskell/pick-random-element-2.hs | 5 + .../Icon/pick-random-element.icon | 4 + .../J/pick-random-element.j | 2 + .../Java/pick-random-element.java | 4 + .../JavaScript/pick-random-element.js | 2 + .../K/pick-random-element.k | 2 + .../Liberty-BASIC/pick-random-element.liberty | 3 + .../Logo/pick-random-element.logo | 1 + .../Lua/pick-random-element.lua | 3 + .../MATLAB/pick-random-element-1.m | 2 + .../MATLAB/pick-random-element-2.m | 2 + .../Mathematica/pick-random-element.math | 2 + .../NetLogo/pick-random-element.netlogo | 4 + .../NetRexx/pick-random-element.netrexx | 13 + .../OCaml/pick-random-element-1.ocaml | 3 + .../OCaml/pick-random-element-2.ocaml | 3 + .../Objeck/pick-random-element.objeck | 2 + .../PARI-GP/pick-random-element.pari | 1 + .../PHP/pick-random-element.php | 2 + .../PL-I/pick-random-element.pli | 3 + .../Pascal/pick-random-element.pascal | 9 + .../Perl-6/pick-random-element-1.pl6 | 3 + .../Perl-6/pick-random-element-2.pl6 | 5 + .../Perl-6/pick-random-element-3.pl6 | 1 + .../Perl-6/pick-random-element-4.pl6 | 1 + .../Perl/pick-random-element.pl | 2 + .../PicoLisp/pick-random-element.l | 1 + .../PureBasic/pick-random-element.purebasic | 40 ++ .../Python/pick-random-element.py | 3 + .../R/pick-random-element.r | 12 + .../REXX/pick-random-element-1.rexx | 21 + .../REXX/pick-random-element-2.rexx | 9 + .../Ruby/pick-random-element-1.rb | 4 + .../Ruby/pick-random-element-2.rb | 2 + .../Run-BASIC/pick-random-element.run | 3 + .../Seed7/pick-random-element.seed7 | 6 + .../Smalltalk/pick-random-element.st | 1 + .../TUSCRIPT/pick-random-element.tuscript | 6 + .../TXR/pick-random-element.txr | 3 + .../Tcl/pick-random-element.tcl | 4 + .../XPL0/pick-random-element.xpl0 | 5 + Task/Pig-the-dice-game-Player/0DESCRIPTION | 18 + .../Ada/pig-the-dice-game-player.ada | 37 ++ .../Go/pig-the-dice-game-player.go | 191 ++++++ .../J/pig-the-dice-game-player-1.j | 3 + .../J/pig-the-dice-game-player-2.j | 2 + .../J/pig-the-dice-game-player-3.j | 6 + .../J/pig-the-dice-game-player-4.j | 3 + .../Python/pig-the-dice-game-player.py | 127 ++++ .../REXX/pig-the-dice-game-player.rexx | 89 +++ .../Tcl/pig-the-dice-game-player-1.tcl | 107 ++++ .../Tcl/pig-the-dice-game-player-2.tcl | 61 ++ .../Tcl/pig-the-dice-game-player-3.tcl | 1 + Task/Pig-the-dice-game/0DESCRIPTION | 12 + .../Ada/pig-the-dice-game-1.ada | 23 + .../Ada/pig-the-dice-game-2.ada | 51 ++ .../Ada/pig-the-dice-game-3.ada | 32 ++ .../Common-Lisp/pig-the-dice-game.lisp | 32 ++ Task/Pig-the-dice-game/D/pig-the-dice-game.d | 38 ++ .../Forth/pig-the-dice-game.fth | 21 + .../Groovy/pig-the-dice-game.groovy | 94 +++ .../Pig-the-dice-game/J/pig-the-dice-game-1.j | 41 ++ .../Pig-the-dice-game/J/pig-the-dice-game-2.j | 62 ++ .../Java/pig-the-dice-game.java | 42 ++ .../Mathematica/pig-the-dice-game.math | 18 + .../PHP/pig-the-dice-game.php | 32 ++ .../Perl-6/pig-the-dice-game.pl6 | 32 ++ .../Python/pig-the-dice-game.py | 37 ++ .../REXX/pig-the-dice-game.rexx | 89 +++ .../Ruby/pig-the-dice-game.rb | 36 ++ .../Run-BASIC/pig-the-dice-game.run | 26 + .../Tcl/pig-the-dice-game-1.tcl | 79 +++ .../Tcl/pig-the-dice-game-2.tcl | 32 ++ .../XPL0/pig-the-dice-game.xpl0 | 25 + Task/Pinstripe-Display/0DESCRIPTION | 6 + Task/Pinstripe-Display/1META.yaml | 2 + .../AutoHotkey/pinstripe-display.ahk | 40 ++ .../BBC-BASIC/pinstripe-display.bbc | 25 + .../Icon/pinstripe-display.icon | 23 + Task/Pinstripe-Display/J/pinstripe-display.j | 4 + .../pinstripe-display.locomotive | 20 + .../PicoLisp/pinstripe-display.l | 14 + .../PureBasic/pinstripe-display.purebasic | 30 + .../Tcl/pinstripe-display.tcl | 17 + .../XPL0/pinstripe-display.xpl0 | 14 + Task/Pinstripe-Printer/0DESCRIPTION | 7 + Task/Pinstripe-Printer/1META.yaml | 4 + .../BBC-BASIC/pinstripe-printer.bbc | 37 ++ .../Liberty-BASIC/pinstripe-printer.liberty | 49 ++ .../PicoLisp/pinstripe-printer.l | 9 + .../Tcl/pinstripe-printer.tcl | 14 + Task/Play-recorded-sounds/0DESCRIPTION | 15 + Task/Play-recorded-sounds/1META.yaml | 6 + .../AutoHotkey/play-recorded-sounds.ahk | 11 + .../BBC-BASIC/play-recorded-sounds.bbc | 41 ++ .../Delphi/play-recorded-sounds.delphi | 9 + .../GUISS/play-recorded-sounds.guiss | 2 + .../play-recorded-sounds.liberty | 41 ++ .../Mathematica/play-recorded-sounds.math | 11 + .../PicoLisp/play-recorded-sounds.l | 5 + .../PureBasic/play-recorded-sounds.purebasic | 36 ++ .../Python/play-recorded-sounds-1.py | 28 + .../Python/play-recorded-sounds-2.py | 12 + .../R/play-recorded-sounds.r | 29 + .../Ruby/play-recorded-sounds.rb | 43 ++ .../TUSCRIPT/play-recorded-sounds.tuscript | 4 + .../Tcl/play-recorded-sounds.tcl | 20 + .../UNIX-Shell/play-recorded-sounds.sh | 8 + .../VBA/play-recorded-sounds.vba | 6 + Task/Playing-cards/0DESCRIPTION | 1 + Task/Playing-cards/1META.yaml | 2 + Task/Playing-cards/ACL2/playing-cards.acl2 | 52 ++ Task/Playing-cards/ALGOL-68/playing-cards.alg | 75 +++ .../AutoHotkey/playing-cards.ahk | 30 + Task/Playing-cards/BASIC/playing-cards.basic | 64 +++ .../Playing-cards/BBC-BASIC/playing-cards.bbc | 47 ++ Task/Playing-cards/C++/playing-cards.cpp | 93 +++ Task/Playing-cards/C/playing-cards.c | 94 +++ Task/Playing-cards/Clojure/playing-cards.clj | 21 + .../Common-Lisp/playing-cards.lisp | 22 + Task/Playing-cards/D/playing-cards-1.d | 43 ++ Task/Playing-cards/D/playing-cards-2.d | 111 ++++ .../Playing-cards/Delphi/playing-cards.delphi | 125 ++++ .../Playing-cards/Fantom/playing-cards.fantom | 66 +++ Task/Playing-cards/Forth/playing-cards.fth | 32 ++ Task/Playing-cards/Fortran/playing-cards-1.f | 66 +++ Task/Playing-cards/Fortran/playing-cards-2.f | 11 + Task/Playing-cards/Go/playing-cards.go | 125 ++++ .../Groovy/playing-cards-1.groovy | 37 ++ .../Groovy/playing-cards-2.groovy | 3 + Task/Playing-cards/Haskell/playing-cards.hs | 27 + Task/Playing-cards/Icon/playing-cards.icon | 53 ++ Task/Playing-cards/J/playing-cards-1.j | 42 ++ Task/Playing-cards/J/playing-cards-2.j | 23 + Task/Playing-cards/Java/playing-cards-1.java | 2 + Task/Playing-cards/Java/playing-cards-2.java | 1 + Task/Playing-cards/Java/playing-cards-3.java | 13 + Task/Playing-cards/Java/playing-cards-4.java | 24 + .../Playing-cards/JavaScript/playing-cards.js | 31 + Task/Playing-cards/K/playing-cards-1.k | 6 + Task/Playing-cards/K/playing-cards-2.k | 4 + Task/Playing-cards/K/playing-cards-3.k | 4 + Task/Playing-cards/K/playing-cards-4.k | 12 + Task/Playing-cards/K/playing-cards-5.k | 16 + Task/Playing-cards/K/playing-cards-6.k | 4 + .../Liberty-BASIC/playing-cards.liberty | 92 +++ Task/Playing-cards/Logo/playing-cards.logo | 33 ++ Task/Playing-cards/Lua/playing-cards.lua | 64 +++ Task/Playing-cards/M4/playing-cards.m4 | 40 ++ .../Mathematica/playing-cards.math | 3 + Task/Playing-cards/OCaml/playing-cards.ocaml | 21 + Task/Playing-cards/PARI-GP/playing-cards.pari | 20 + Task/Playing-cards/PHP/playing-cards-1.php | 276 +++++++++ Task/Playing-cards/PHP/playing-cards-2.php | 57 ++ Task/Playing-cards/Perl-6/playing-cards.pl6 | 30 + Task/Playing-cards/Perl/playing-cards-1.pl | 42 ++ Task/Playing-cards/Perl/playing-cards-2.pl | 5 + Task/Playing-cards/PicoLisp/playing-cards.l | 13 + Task/Playing-cards/Prolog/playing-cards.pro | 38 ++ .../PureBasic/playing-cards.purebasic | 134 +++++ Task/Playing-cards/Python/playing-cards.py | 26 + Task/Playing-cards/R/playing-cards.r | 25 + Task/Playing-cards/REXX/playing-cards-1.rexx | 50 ++ Task/Playing-cards/REXX/playing-cards-2.rexx | 36 ++ Task/Playing-cards/Racket/playing-cards.rkt | 34 ++ Task/Playing-cards/Ruby/playing-cards.rb | 56 ++ .../Playing-cards/Run-BASIC/playing-cards.run | 25 + Task/Playing-cards/Scheme/playing-cards-1.ss | 28 + Task/Playing-cards/Scheme/playing-cards-2.ss | 14 + Task/Playing-cards/Smalltalk/playing-cards.st | 103 ++++ Task/Playing-cards/Tcl/playing-cards.tcl | 66 +++ .../VBScript/playing-cards-1.vbscript | 66 +++ .../VBScript/playing-cards-2.vbscript | 17 + .../Vedit-macro-language/playing-cards.vedit | 83 +++ Task/Plot-coordinate-pairs/0DESCRIPTION | 7 + .../ALGOL-68/plot-coordinate-pairs.alg | 37 ++ .../Ada/plot-coordinate-pairs.ada | 46 ++ .../BBC-BASIC/plot-coordinate-pairs.bbc | 29 + .../C/plot-coordinate-pairs-1.c | 117 ++++ .../C/plot-coordinate-pairs-2.c | 131 +++++ .../Groovy/plot-coordinate-pairs.groovy | 28 + .../Haskell/plot-coordinate-pairs.hs | 6 + .../HicEst/plot-coordinate-pairs.hicest | 8 + .../Icon/plot-coordinate-pairs.icon | 86 +++ .../J/plot-coordinate-pairs.j | 4 + .../Java/plot-coordinate-pairs.java | 89 +++ .../plot-coordinate-pairs-1.liberty | 34 ++ .../plot-coordinate-pairs-2.liberty | 63 ++ .../MATLAB/plot-coordinate-pairs.m | 3 + .../Mathematica/plot-coordinate-pairs.math | 3 + .../Maxima/plot-coordinate-pairs.maxima | 3 + .../OCaml/plot-coordinate-pairs-1.ocaml | 20 + .../OCaml/plot-coordinate-pairs-2.ocaml | 10 + .../Octave/plot-coordinate-pairs.octave | 4 + .../PARI-GP/plot-coordinate-pairs.pari | 1 + .../Perl-6/plot-coordinate-pairs.pl6 | 16 + .../Perl/plot-coordinate-pairs-1.pl | 15 + .../Perl/plot-coordinate-pairs-2.pl | 28 + .../PicoLisp/plot-coordinate-pairs.l | 35 ++ .../PostScript/plot-coordinate-pairs.ps | 11 + .../PureBasic/plot-coordinate-pairs.purebasic | 89 +++ .../Python/plot-coordinate-pairs.py | 6 + .../R/plot-coordinate-pairs-1.r | 2 + .../R/plot-coordinate-pairs-2.r | 1 + .../R/plot-coordinate-pairs-3.r | 2 + .../R/plot-coordinate-pairs-4.r | 2 + .../Ruby/plot-coordinate-pairs.rb | 12 + .../Scala/plot-coordinate-pairs.scala | 94 +++ .../TI-89-BASIC/plot-coordinate-pairs.ti-89 | 4 + .../Tcl/plot-coordinate-pairs.tcl | 56 ++ .../Ursala/plot-coordinate-pairs-1.ursala | 11 + .../Ursala/plot-coordinate-pairs-2.ursala | 17 + .../XPL0/plot-coordinate-pairs.xpl0 | 34 ++ .../Yorick/plot-coordinate-pairs.yorick | 6 + Task/Pointers-and-references/0DESCRIPTION | 1 + Task/Pointers-and-references/1META.yaml | 2 + .../ALGOL-68/pointers-and-references-1.alg | 2 + .../ALGOL-68/pointers-and-references-10.alg | 3 + .../ALGOL-68/pointers-and-references-11.alg | 4 + .../ALGOL-68/pointers-and-references-2.alg | 2 + .../ALGOL-68/pointers-and-references-3.alg | 2 + .../ALGOL-68/pointers-and-references-4.alg | 1 + .../ALGOL-68/pointers-and-references-5.alg | 2 + .../ALGOL-68/pointers-and-references-6.alg | 1 + .../ALGOL-68/pointers-and-references-7.alg | 2 + .../ALGOL-68/pointers-and-references-8.alg | 1 + .../ALGOL-68/pointers-and-references-9.alg | 2 + .../Ada/pointers-and-references-1.ada | 2 + .../Ada/pointers-and-references-2.ada | 1 + .../Ada/pointers-and-references-3.ada | 7 + .../Ada/pointers-and-references-4.ada | 1 + .../Ada/pointers-and-references-5.ada | 2 + .../Ada/pointers-and-references-6.ada | 5 + .../Ada/pointers-and-references-7.ada | 8 + .../Ada/pointers-and-references-8.ada | 4 + .../AutoHotkey/pointers-and-references.ahk | 5 + .../BBC-BASIC/pointers-and-references.bbc | 26 + .../D/pointers-and-references-1.d | 2 + .../D/pointers-and-references-2.d | 9 + .../Fortran/pointers-and-references-1.f | 1 + .../Fortran/pointers-and-references-10.f | 6 + .../Fortran/pointers-and-references-2.f | 1 + .../Fortran/pointers-and-references-3.f | 1 + .../Fortran/pointers-and-references-4.f | 2 + .../Fortran/pointers-and-references-5.f | 1 + .../Fortran/pointers-and-references-6.f | 2 + .../Fortran/pointers-and-references-7.f | 4 + .../Fortran/pointers-and-references-8.f | 8 + .../Fortran/pointers-and-references-9.f | 4 + .../Go/pointers-and-references-1.go | 2 + .../Go/pointers-and-references-2.go | 1 + .../Go/pointers-and-references-3.go | 1 + .../Go/pointers-and-references-4.go | 4 + .../Go/pointers-and-references-5.go | 4 + .../Go/pointers-and-references-6.go | 5 + .../Haskell/pointers-and-references.hs | 7 + .../Java/pointers-and-references.java | 9 + .../Modula-3/pointers-and-references-1.mod3 | 5 + .../Modula-3/pointers-and-references-2.mod3 | 2 + .../Modula-3/pointers-and-references-3.mod3 | 13 + .../OCaml/pointers-and-references.ocaml | 3 + .../PARI-GP/pointers-and-references.pari | 3 + .../PHP/pointers-and-references.php | 28 + .../Perl-6/pointers-and-references.pl6 | 13 + .../Perl/pointers-and-references-1.pl | 9 + .../Perl/pointers-and-references-2.pl | 9 + .../Perl/pointers-and-references-3.pl | 3 + .../PicoLisp/pointers-and-references.l | 11 + .../pointers-and-references-1.purebasic | 4 + .../pointers-and-references-2.purebasic | 2 + .../pointers-and-references-3.purebasic | 1 + .../pointers-and-references-4.purebasic | 6 + .../pointers-and-references-5.purebasic | 2 + .../pointers-and-references-6.purebasic | 10 + .../pointers-and-references-7.purebasic | 2 + .../pointers-and-references-8.purebasic | 20 + .../Python/pointers-and-references.py | 32 ++ .../SAS/pointers-and-references.sas | 13 + .../Standard-ML/pointers-and-references.ml | 3 + .../Tcl/pointers-and-references-1.tcl | 5 + .../Tcl/pointers-and-references-2.tcl | 9 + .../XPL0/pointers-and-references.xpl0 | 32 ++ Task/Polymorphic-copy/0DESCRIPTION | 8 + Task/Polymorphic-copy/1META.yaml | 2 + .../Polymorphic-copy/Ada/polymorphic-copy.ada | 42 ++ .../Aikido/polymorphic-copy.aikido | 23 + .../BBC-BASIC/polymorphic-copy.bbc | 28 + .../Polymorphic-copy/C++/polymorphic-copy.cpp | 50 ++ Task/Polymorphic-copy/C/polymorphic-copy.c | 202 +++++++ .../Common-Lisp/polymorphic-copy-1.lisp | 12 + .../Common-Lisp/polymorphic-copy-2.lisp | 5 + Task/Polymorphic-copy/D/polymorphic-copy-1.d | 19 + Task/Polymorphic-copy/D/polymorphic-copy-2.d | 46 ++ Task/Polymorphic-copy/E/polymorphic-copy-1.e | 5 + Task/Polymorphic-copy/E/polymorphic-copy-2.e | 12 + .../Factor/polymorphic-copy.factor | 8 + .../Forth/polymorphic-copy.fth | 36 ++ Task/Polymorphic-copy/Go/polymorphic-copy.go | 84 +++ .../Java/polymorphic-copy.java | 24 + .../JavaScript/polymorphic-copy.js | 9 + .../NetRexx/polymorphic-copy.netrexx | 38 ++ .../OCaml/polymorphic-copy.ocaml | 13 + .../Objective-C/polymorphic-copy.m | 39 ++ .../OxygenBasic/polymorphic-copy.oxy | 37 ++ Task/Polymorphic-copy/Oz/polymorphic-copy.oz | 41 ++ .../Polymorphic-copy/PHP/polymorphic-copy.php | 16 + .../Perl-6/polymorphic-copy.pl6 | 3 + .../Polymorphic-copy/Perl/polymorphic-copy.pl | 53 ++ .../PicoLisp/polymorphic-copy-1.l | 10 + .../PicoLisp/polymorphic-copy-2.l | 1 + .../PicoLisp/polymorphic-copy-3.l | 7 + .../Python/polymorphic-copy-1.py | 54 ++ .../Python/polymorphic-copy-2.py | 7 + .../Python/polymorphic-copy-3.py | 8 + .../Polymorphic-copy/Ruby/polymorphic-copy.rb | 16 + .../Slate/polymorphic-copy.slate | 9 + .../Tcl/polymorphic-copy-1.tcl | 1 + .../Tcl/polymorphic-copy-2.tcl | 42 ++ Task/Polymorphism/0DESCRIPTION | 1 + Task/Polymorphism/1META.yaml | 4 + .../ActionScript/polymorphism-1.as | 39 ++ .../ActionScript/polymorphism-2.as | 27 + Task/Polymorphism/Ada/polymorphism-1.ada | 17 + Task/Polymorphism/Ada/polymorphism-2.ada | 77 +++ Task/Polymorphism/Ada/polymorphism-3.ada | 18 + Task/Polymorphism/Ada/polymorphism-4.ada | 106 ++++ Task/Polymorphism/Ada/polymorphism-5.ada | 10 + Task/Polymorphism/Aikido/polymorphism.aikido | 25 + Task/Polymorphism/BBC-BASIC/polymorphism.bbc | 38 ++ Task/Polymorphism/C++/polymorphism-1.cpp | 55 ++ Task/Polymorphism/C++/polymorphism-2.cpp | 67 +++ Task/Polymorphism/Clojure/polymorphism.clj | 18 + .../Common-Lisp/polymorphism.lisp | 23 + Task/Polymorphism/D/polymorphism.d | 36 ++ .../Polymorphism/Delphi/polymorphism-1.delphi | 107 ++++ .../Polymorphism/Delphi/polymorphism-2.delphi | 17 + Task/Polymorphism/E/polymorphism-1.e | 23 + Task/Polymorphism/E/polymorphism-2.e | 4 + Task/Polymorphism/Eiffel/polymorphism-1.e | 64 +++ Task/Polymorphism/Eiffel/polymorphism-2.e | 81 +++ Task/Polymorphism/Eiffel/polymorphism-3.e | 34 ++ Task/Polymorphism/Eiffel/polymorphism-4.e | 6 + Task/Polymorphism/Ela/polymorphism-1.ela | 45 ++ Task/Polymorphism/Ela/polymorphism-2.ela | 2 + Task/Polymorphism/Factor/polymorphism.factor | 13 + Task/Polymorphism/Forth/polymorphism.fth | 89 +++ Task/Polymorphism/Fortran/polymorphism.f | 81 +++ Task/Polymorphism/Go/polymorphism.go | 81 +++ Task/Polymorphism/Haskell/polymorphism-1.hs | 31 + Task/Polymorphism/Haskell/polymorphism-2.hs | 63 ++ Task/Polymorphism/Inform-7/polymorphism.inf | 19 + Task/Polymorphism/J/polymorphism-1.j | 12 + Task/Polymorphism/J/polymorphism-2.j | 10 + Task/Polymorphism/Java/polymorphism.java | 33 ++ Task/Polymorphism/JavaScript/polymorphism.js | 63 ++ Task/Polymorphism/Lua/polymorphism.lua | 29 + .../Polymorphism/NetRexx/polymorphism.netrexx | 104 ++++ Task/Polymorphism/OCaml/polymorphism.ocaml | 33 ++ Task/Polymorphism/Objeck/polymorphism.objeck | 82 +++ Task/Polymorphism/Objective-C/polymorphism.m | 73 +++ .../Polymorphism/OxygenBasic/polymorphism.oxy | 56 ++ Task/Polymorphism/Oz/polymorphism.oz | 38 ++ Task/Polymorphism/PHP/polymorphism-1.php | 71 +++ Task/Polymorphism/PHP/polymorphism-2.php | 63 ++ Task/Polymorphism/PHP/polymorphism-3.php | 12 + Task/Polymorphism/Perl-6/polymorphism-1.pl6 | 18 + Task/Polymorphism/Perl-6/polymorphism-2.pl6 | 2 + Task/Polymorphism/Perl/polymorphism.pl | 86 +++ Task/Polymorphism/PicoLisp/polymorphism-1.l | 19 + Task/Polymorphism/PicoLisp/polymorphism-2.l | 6 + Task/Polymorphism/Pop11/polymorphism-1.pop11 | 19 + Task/Polymorphism/Pop11/polymorphism-2.pop11 | 6 + .../PureBasic/polymorphism-1.purebasic | 59 ++ .../PureBasic/polymorphism-2.purebasic | 9 + Task/Polymorphism/Python/polymorphism-1.py | 14 + Task/Polymorphism/Python/polymorphism-2.py | 14 + Task/Polymorphism/Python/polymorphism-3.py | 24 + Task/Polymorphism/Python/polymorphism-4.py | 7 + Task/Polymorphism/R/polymorphism.r | 39 ++ Task/Polymorphism/Ruby/polymorphism.rb | 22 + Task/Polymorphism/SIMPOL/polymorphism.simpol | 73 +++ Task/Polymorphism/Smalltalk/polymorphism.st | 75 +++ Task/Polymorphism/Tcl/polymorphism.tcl | 53 ++ Task/Polynomial-long-division/0DESCRIPTION | 93 +++ Task/Polynomial-long-division/1META.yaml | 2 + .../Ada/polynomial-long-division.ada | 110 ++++ .../BBC-BASIC/polynomial-long-division.bbc | 44 ++ .../C++/polynomial-long-division-1.cpp | 16 + .../C++/polynomial-long-division-2.cpp | 106 ++++ .../C/polynomial-long-division-1.c | 107 ++++ .../C/polynomial-long-division-2.c | 23 + .../C/polynomial-long-division-3.c | 104 ++++ .../polynomial-long-division-1.lisp | 41 ++ .../polynomial-long-division-2.lisp | 4 + .../D/polynomial-long-division.d | 38 ++ .../E/polynomial-long-division.e | 7 + .../Fortran/polynomial-long-division-1.f | 80 +++ .../Fortran/polynomial-long-division-2.f | 18 + .../GAP/polynomial-long-division.gap | 5 + .../Go/polynomial-long-division.go | 46 ++ .../Haskell/polynomial-long-division-1.hs | 22 + .../Haskell/polynomial-long-division-2.hs | 11 + .../J/polynomial-long-division-1.j | 1 + .../J/polynomial-long-division-2.j | 1 + .../Maple/polynomial-long-division.maple | 19 + .../Mathematica/polynomial-long-division.math | 1 + .../OCaml/polynomial-long-division-1.ocaml | 8 + .../OCaml/polynomial-long-division-2.ocaml | 10 + .../OCaml/polynomial-long-division-3.ocaml | 12 + .../OCaml/polynomial-long-division-4.ocaml | 6 + .../Octave/polynomial-long-division.octave | 37 ++ .../PARI-GP/polynomial-long-division-1.pari | 5 + .../PARI-GP/polynomial-long-division-2.pari | 1 + .../Perl-6/polynomial-long-division.pl6 | 24 + .../Perl/polynomial-long-division-1.pl | 22 + .../Perl/polynomial-long-division-2.pl | 10 + .../Perl/polynomial-long-division-3.pl | 18 + .../PicoLisp/polynomial-long-division.l | 18 + .../Python/polynomial-long-division.py | 34 ++ .../R/polynomial-long-division.r | 34 ++ .../Ruby/polynomial-long-division-1.rb | 46 ++ .../Ruby/polynomial-long-division-2.rb | 68 +++ .../Ruby/polynomial-long-division-3.rb | 30 + .../Slate/polynomial-long-division.slate | 62 ++ .../Smalltalk/polynomial-long-division-1.st | 68 +++ .../Smalltalk/polynomial-long-division-2.st | 11 + .../Tcl/polynomial-long-division.tcl | 40 ++ .../Ursala/polynomial-long-division-1.ursala | 9 + .../Ursala/polynomial-long-division-2.ursala | 3 + Task/Polynomial-regression/0DESCRIPTION | 11 + Task/Polynomial-regression/1META.yaml | 2 + .../ALGOL-68/polynomial-regression.alg | 114 ++++ .../Ada/polynomial-regression-1.ada | 12 + .../Ada/polynomial-regression-2.ada | 15 + .../BBC-BASIC/polynomial-regression.bbc | 49 ++ .../C-sharp/polynomial-regression-1.cs | 15 + .../C-sharp/polynomial-regression-2.cs | 12 + .../C/polynomial-regression-1.c | 8 + .../C/polynomial-regression-2.c | 42 ++ .../C/polynomial-regression-3.c | 21 + .../Common-Lisp/polynomial-regression-1.lisp | 9 + .../Common-Lisp/polynomial-regression-2.lisp | 5 + .../Fortran/polynomial-regression-1.f | 64 +++ .../Fortran/polynomial-regression-2.f | 19 + .../GAP/polynomial-regression.gap | 12 + .../Go/polynomial-regression.go | 40 ++ .../Haskell/polynomial-regression-1.hs | 11 + .../Haskell/polynomial-regression-2.hs | 2 + .../HicEst/polynomial-regression-1.hicest | 15 + .../HicEst/polynomial-regression-2.hicest | 2 + .../J/polynomial-regression-1.j | 3 + .../J/polynomial-regression-2.j | 2 + .../MATLAB/polynomial-regression.m | 7 + .../Mathematica/polynomial-regression.math | 2 + .../Octave/polynomial-regression.octave | 3 + .../PARI-GP/polynomial-regression-1.pari | 1 + .../PARI-GP/polynomial-regression-2.pari | 2 + .../Python/polynomial-regression-1.py | 5 + .../Python/polynomial-regression-2.py | 3 + .../Python/polynomial-regression-3.py | 2 + .../Python/polynomial-regression-4.py | 2 + .../Python/polynomial-regression-5.py | 4 + .../R/polynomial-regression-1.r | 3 + .../R/polynomial-regression-2.r | 2 + .../Ruby/polynomial-regression-1.rb | 10 + .../Ruby/polynomial-regression-2.rb | 5 + .../TI-89-BASIC/polynomial-regression.ti-89 | 5 + .../Tcl/polynomial-regression.tcl | 49 ++ .../Ursala/polynomial-regression-1.ursala | 5 + .../Ursala/polynomial-regression-2.ursala | 6 + Task/Power-set/0DESCRIPTION | 6 + Task/Power-set/1META.yaml | 2 + Task/Power-set/ALGOL-68/power-set.alg | 27 + Task/Power-set/Ada/power-set.ada | 84 +++ Task/Power-set/AutoHotkey/power-set.ahk | 11 + Task/Power-set/BBC-BASIC/power-set.bbc | 17 + Task/Power-set/Burlesque/power-set.blq | 2 + Task/Power-set/C++/power-set-1.cpp | 78 +++ Task/Power-set/C++/power-set-2.cpp | 25 + Task/Power-set/C/power-set-1.c | 28 + Task/Power-set/C/power-set-2.c | 17 + Task/Power-set/Clojure/power-set.clj | 6 + .../CoffeeScript/power-set-1.coffeescript | 28 + .../CoffeeScript/power-set-2.coffeescript | 29 + Task/Power-set/ColdFusion/power-set.cfm | 18 + Task/Power-set/Common-Lisp/power-set-1.lisp | 8 + Task/Power-set/Common-Lisp/power-set-2.lisp | 6 + Task/Power-set/Common-Lisp/power-set-3.lisp | 3 + Task/Power-set/D/power-set.d | 16 + Task/Power-set/E/power-set.e | 9 + Task/Power-set/Erlang/power-set-1.erl | 5 + Task/Power-set/Erlang/power-set-2.erl | 3 + Task/Power-set/Erlang/power-set-3.erl | 6 + Task/Power-set/Factor/power-set-1.factor | 5 + Task/Power-set/Factor/power-set-2.factor | 19 + Task/Power-set/Forth/power-set.fth | 8 + Task/Power-set/Frink/power-set.frink | 2 + Task/Power-set/GAP/power-set.gap | 8 + Task/Power-set/Go/power-set.go | 106 ++++ Task/Power-set/Groovy/power-set-1.groovy | 14 + Task/Power-set/Groovy/power-set-2.groovy | 3 + Task/Power-set/Haskell/power-set-1.hs | 8 + Task/Power-set/Haskell/power-set-2.hs | 2 + Task/Power-set/Haskell/power-set-3.hs | 1 + Task/Power-set/Haskell/power-set-4.hs | 15 + Task/Power-set/Haskell/power-set-5.hs | 2 + Task/Power-set/Icon/power-set-1.icon | 14 + Task/Power-set/Icon/power-set-2.icon | 7 + Task/Power-set/Icon/power-set-3.icon | 19 + Task/Power-set/J/power-set-1.j | 1 + Task/Power-set/J/power-set-2.j | 9 + Task/Power-set/J/power-set-3.j | 6 + Task/Power-set/Java/power-set-1.java | 25 + Task/Power-set/Java/power-set-2.java | 23 + Task/Power-set/Java/power-set-3.java | 16 + Task/Power-set/JavaScript/power-set.js | 14 + Task/Power-set/K/power-set-1.k | 1 + Task/Power-set/K/power-set-2.k | 9 + Task/Power-set/Logo/power-set.logo | 8 + Task/Power-set/Logtalk/power-set-1.logtalk | 25 + Task/Power-set/Logtalk/power-set-2.logtalk | 4 + Task/Power-set/Lua/power-set.lua | 33 ++ Task/Power-set/M4/power-set.m4 | 22 + Task/Power-set/MATLAB/power-set-1.m | 18 + Task/Power-set/MATLAB/power-set-2.m | 5 + Task/Power-set/MATLAB/power-set-3.m | 5 + Task/Power-set/Mathematica/power-set-1.math | 1 + Task/Power-set/Mathematica/power-set-2.math | 1 + Task/Power-set/Maxima/power-set.maxima | 3 + Task/Power-set/OCaml/power-set-1.ocaml | 17 + Task/Power-set/OCaml/power-set-2.ocaml | 1 + Task/Power-set/Objective-C/power-set.m | 17 + Task/Power-set/Oz/power-set-1.oz | 16 + Task/Power-set/Oz/power-set-2.oz | 8 + Task/Power-set/PARI-GP/power-set.pari | 1 + Task/Power-set/PHP/power-set-1.php | 59 ++ Task/Power-set/PHP/power-set-2.php | 21 + Task/Power-set/Perl-6/power-set.pl6 | 3 + Task/Power-set/Perl/power-set-1.pl | 1 + Task/Power-set/Perl/power-set-2.pl | 4 + Task/Power-set/PicoLisp/power-set.l | 7 + Task/Power-set/Prolog/power-set-1.pro | 9 + Task/Power-set/Prolog/power-set-2.pro | 18 + Task/Power-set/PureBasic/power-set.purebasic | 25 + Task/Power-set/Python/power-set-1.py | 20 + Task/Power-set/Python/power-set-2.py | 9 + Task/Power-set/Python/power-set-3.py | 25 + Task/Power-set/Python/power-set-4.py | 3 + Task/Power-set/Qi/power-set.qi | 4 + Task/Power-set/R/power-set-1.r | 1 + Task/Power-set/R/power-set-2.r | 3 + Task/Power-set/R/power-set-3.r | 3 + Task/Power-set/REXX/power-set.rexx | 29 + Task/Power-set/Racket/power-set.rkt | 8 + Task/Power-set/Rascal/power-set-1.rascal | 3 + Task/Power-set/Rascal/power-set-2.rascal | 19 + Task/Power-set/Ruby/power-set.rb | 48 ++ Task/Power-set/Scala/power-set.scala | 1 + Task/Power-set/Scheme/power-set-1.ss | 13 + Task/Power-set/Scheme/power-set-2.ss | 23 + Task/Power-set/Scheme/power-set-3.ss | 7 + Task/Power-set/Seed7/power-set.seed7 | 29 + Task/Power-set/Smalltalk/power-set-1.st | 7 + Task/Power-set/Smalltalk/power-set-2.st | 5 + Task/Power-set/Standard-ML/power-set.ml | 1 + Task/Power-set/TXR/power-set.txr | 14 + Task/Power-set/Tcl/power-set-1.tcl | 8 + Task/Power-set/Tcl/power-set-2.tcl | 12 + Task/Power-set/UNIX-Shell/power-set-1.sh | 1 + Task/Power-set/UNIX-Shell/power-set-2.sh | 5 + Task/Power-set/UnixPipes/power-set.unixpipes | 22 + Task/Power-set/Ursala/power-set-1.ursala | 1 + Task/Power-set/Ursala/power-set-2.ursala | 3 + Task/Power-set/V/power-set-1.v | 2 + Task/Power-set/V/power-set-2.v | 6 + Task/Pragmatic-directives/0DESCRIPTION | 3 + Task/Pragmatic-directives/1META.yaml | 3 + .../ALGOL-68/pragmatic-directives.alg | 12 + .../BASIC/pragmatic-directives.basic | 2 + .../Go/pragmatic-directives-1.go | 1 + .../Go/pragmatic-directives-2.go | 1 + .../Go/pragmatic-directives-3.go | 1 + .../Go/pragmatic-directives-4.go | 1 + .../Icon/pragmatic-directives.icon | 2 + .../J/pragmatic-directives-1.j | 1 + .../J/pragmatic-directives-2.j | 2 + .../J/pragmatic-directives-3.j | 2 + .../J/pragmatic-directives-4.j | 7 + .../NetRexx/pragmatic-directives-1.netrexx | 1 + .../NetRexx/pragmatic-directives-2.netrexx | 3 + .../NetRexx/pragmatic-directives-3.netrexx | 2 + .../NetRexx/pragmatic-directives-4.netrexx | 2 + .../Perl-6/pragmatic-directives.pl6 | 4 + .../Perl/pragmatic-directives-1.pl | 2 + .../Perl/pragmatic-directives-2.pl | 2 + .../Python/pragmatic-directives-1.py | 6 + .../Python/pragmatic-directives-2.py | 6 + .../UNIX-Shell/pragmatic-directives.sh | 2 + Task/Price-fraction/0DESCRIPTION | 24 + Task/Price-fraction/1META.yaml | 2 + .../ALGOL-68/price-fraction.alg | 30 + Task/Price-fraction/AWK/price-fraction.awk | 21 + Task/Price-fraction/Ada/price-fraction-1.ada | 31 + Task/Price-fraction/Ada/price-fraction-2.ada | 11 + .../AutoHotkey/price-fraction.ahk | 34 ++ .../Price-fraction/BASIC/price-fraction.basic | 56 ++ .../BBC-BASIC/price-fraction.bbc | 24 + .../Bracmat/price-fraction.bracmat | 37 ++ Task/Price-fraction/C++/price-fraction.cpp | 30 + Task/Price-fraction/C/price-fraction.c | 28 + .../Clipper/price-fraction-1.clipper | 33 ++ .../Clipper/price-fraction-2.clipper | 44 ++ Task/Price-fraction/D/price-fraction.d | 20 + Task/Price-fraction/Erlang/price-fraction.erl | 22 + .../Euphoria/price-fraction.euphoria | 20 + .../Fantom/price-fraction.fantom | 69 +++ Task/Price-fraction/Forth/price-fraction.fth | 12 + .../Price-fraction/Fortran/price-fraction-1.f | 19 + .../Price-fraction/Fortran/price-fraction-2.f | 10 + Task/Price-fraction/Go/price-fraction.go | 24 + .../Groovy/price-fraction.groovy | 17 + .../Haskell/price-fraction-1.hs | 22 + .../Haskell/price-fraction-2.hs | 10 + .../HicEst/price-fraction.hicest | 10 + Task/Price-fraction/Icon/price-fraction.icon | 39 ++ .../Inform-7/price-fraction.inf | 37 ++ Task/Price-fraction/J/price-fraction-1.j | 4 + Task/Price-fraction/J/price-fraction-2.j | 2 + Task/Price-fraction/Java/price-fraction.java | 35 ++ .../JavaScript/price-fraction.js | 8 + Task/Price-fraction/K/price-fraction-1.k | 4 + Task/Price-fraction/K/price-fraction-2.k | 2 + .../Liberty-BASIC/price-fraction.liberty | 23 + Task/Price-fraction/MATLAB/price-fraction.m | 13 + .../Price-fraction/MUMPS/price-fraction.mumps | 11 + .../Mathematica/price-fraction.math | 5 + .../Mercury/price-fraction-1.mercury | 44 ++ .../Mercury/price-fraction-2.mercury | 1 + .../OCaml/price-fraction-1.ocaml | 15 + .../OCaml/price-fraction-2.ocaml | 18 + Task/Price-fraction/Oz/price-fraction.oz | 15 + .../PARI-GP/price-fraction.pari | 9 + Task/Price-fraction/PL-I/price-fraction.pli | 14 + .../Pascal/price-fraction.pascal | 25 + .../Perl-6/price-fraction-1.pl6 | 35 ++ .../Perl-6/price-fraction-2.pl6 | 26 + .../Perl-6/price-fraction-3.pl6 | 28 + Task/Price-fraction/Perl/price-fraction.pl | 36 ++ Task/Price-fraction/PicoLisp/price-fraction.l | 31 + .../PureBasic/price-fraction.purebasic | 63 ++ .../Price-fraction/Python/price-fraction-1.py | 5 + .../Price-fraction/Python/price-fraction-2.py | 5 + .../Price-fraction/Python/price-fraction-3.py | 20 + Task/Price-fraction/R/price-fraction-1.r | 11 + Task/Price-fraction/R/price-fraction-2.r | 23 + Task/Price-fraction/REXX/price-fraction.rexx | 32 ++ Task/Price-fraction/Ruby/price-fraction-1.rb | 24 + Task/Price-fraction/Ruby/price-fraction-2.rb | 48 ++ Task/Price-fraction/Ruby/price-fraction-3.rb | 27 + .../Run-BASIC/price-fraction.run | 20 + .../Price-fraction/Scala/price-fraction.scala | 10 + .../Seed7/price-fraction-1.seed7 | 28 + .../Seed7/price-fraction-2.seed7 | 21 + .../Smalltalk/price-fraction.st | 49 ++ Task/Price-fraction/Tcl/price-fraction-1.tcl | 23 + Task/Price-fraction/Tcl/price-fraction-2.tcl | 29 + .../Ursala/price-fraction-1.ursala | 6 + .../Ursala/price-fraction-2.ursala | 3 + Task/Price-fraction/XPL0/price-fraction.xpl0 | 33 ++ Task/Primality-by-trial-division/0DESCRIPTION | 5 + Task/Primality-by-trial-division/1META.yaml | 2 + .../ACL2/primality-by-trial-division.acl2 | 10 + .../ALGOL-68/primality-by-trial-division.alg | 10 + .../AWK/primality-by-trial-division.awk | 8 + .../primality-by-trial-division.as | 9 + .../Ada/primality-by-trial-division.ada | 18 + .../primality-by-trial-division.ahk | 8 + .../BASIC/primality-by-trial-division-1.basic | 22 + .../BASIC/primality-by-trial-division-2.basic | 16 + .../BBC-BASIC/primality-by-trial-division.bbc | 14 + .../primality-by-trial-division.bracmat | 22 + .../primality-by-trial-division-1.blq | 1 + .../primality-by-trial-division-2.blq | 6 + .../C++/primality-by-trial-division.cpp | 13 + .../C/primality-by-trial-division.c | 10 + .../CMake/primality-by-trial-division-1.cmake | 31 + .../CMake/primality-by-trial-division-2.cmake | 9 + .../COBOL/primality-by-trial-division-1.cobol | 44 ++ .../COBOL/primality-by-trial-division-2.cobol | 22 + .../COBOL/primality-by-trial-division-3.cobol | 27 + .../Clojure/primality-by-trial-division.clj | 6 + .../primality-by-trial-division.coffeescript | 12 + .../primality-by-trial-division-1.lisp | 7 + .../primality-by-trial-division-2.lisp | 6 + .../D/primality-by-trial-division-1.d | 15 + .../D/primality-by-trial-division-2.d | 27 + .../D/primality-by-trial-division-3.d | 15 + .../primality-by-trial-division-1.delphi | 18 + .../primality-by-trial-division-2.delphi | 15 + .../E/primality-by-trial-division.e | 16 + .../Erlang/primality-by-trial-division.erl | 7 + .../primality-by-trial-division.euphoria | 12 + .../FALSE/primality-by-trial-division.false | 3 + .../Factor/primality-by-trial-division.factor | 8 + .../Forth/primality-by-trial-division.fth | 11 + .../Fortran/primality-by-trial-division.f | 19 + .../GAP/primality-by-trial-division.gap | 21 + .../Go/primality-by-trial-division.go | 9 + .../Groovy/primality-by-trial-division.groovy | 7 + .../Haskell/primality-by-trial-division-1.hs | 1 + .../Haskell/primality-by-trial-division-2.hs | 6 + .../Haskell/primality-by-trial-division-3.hs | 1 + .../Haskell/primality-by-trial-division-4.hs | 2 + .../Haskell/primality-by-trial-division-5.hs | 3 + .../Haskell/primality-by-trial-division-6.hs | 3 + .../Haskell/primality-by-trial-division-7.hs | 4 + .../HicEst/primality-by-trial-division.hicest | 18 + .../Icon/primality-by-trial-division.icon | 5 + .../J/primality-by-trial-division.j | 1 + .../Java/primality-by-trial-division-1.java | 12 + .../Java/primality-by-trial-division-2.java | 3 + .../JavaScript/primality-by-trial-division.js | 13 + .../Joy/primality-by-trial-division.joy | 6 + .../K/primality-by-trial-division.k | 3 + .../LSE64/primality-by-trial-division.lse64 | 15 + .../primality-by-trial-division.liberty | 22 + .../Logo/primality-by-trial-division.logo | 7 + .../Lua/primality-by-trial-division.lua | 13 + .../M4/primality-by-trial-division.m4 | 15 + .../MATLAB/primality-by-trial-division-1.m | 19 + .../MATLAB/primality-by-trial-division-2.m | 5 + .../primality-by-trial-division.maxscript | 17 + .../MUMPS/primality-by-trial-division.mumps | 7 + .../Maple/primality-by-trial-division-1.maple | 16 + .../Maple/primality-by-trial-division-2.maple | 2 + .../Maple/primality-by-trial-division-3.maple | 2 + .../primality-by-trial-division.math | 9 + .../primality-by-trial-division-1.netrexx | 66 +++ .../primality-by-trial-division-2.netrexx | 32 ++ .../OCaml/primality-by-trial-division.ocaml | 9 + .../Objeck/primality-by-trial-division.objeck | 13 + .../Octave/primality-by-trial-division.octave | 25 + .../PARI-GP/primality-by-trial-division.pari | 7 + .../PHP/primality-by-trial-division-1.php | 15 + .../PHP/primality-by-trial-division-2.php | 5 + .../PL-I/primality-by-trial-division.pli | 13 + .../Pascal/primality-by-trial-division.pascal | 29 + .../Perl-6/primality-by-trial-division-1.pl6 | 3 + .../Perl-6/primality-by-trial-division-2.pl6 | 3 + .../Perl-6/primality-by-trial-division-3.pl6 | 1 + .../Perl/primality-by-trial-division-1.pl | 6 + .../Perl/primality-by-trial-division-2.pl | 6 + .../PicoLisp/primality-by-trial-division.l | 9 + .../primality-by-trial-division.psh | 7 + .../Prolog/primality-by-trial-division.pro | 16 + .../primality-by-trial-division.purebasic | 19 + .../Python/primality-by-trial-division-1.py | 2 + .../Python/primality-by-trial-division-2.py | 4 + .../Python/primality-by-trial-division-3.py | 13 + .../Python/primality-by-trial-division-4.py | 7 + .../Qi/primality-by-trial-division.qi | 10 + .../R/primality-by-trial-division-1.r | 8 + .../R/primality-by-trial-division-2.r | 1 + .../REBOL/primality-by-trial-division-1.rebol | 12 + .../REBOL/primality-by-trial-division-2.rebol | 1 + .../REXX/primality-by-trial-division-1.rexx | 24 + .../REXX/primality-by-trial-division-2.rexx | 26 + .../REXX/primality-by-trial-division-3.rexx | 56 ++ .../Ruby/primality-by-trial-division-1.rb | 11 + .../Ruby/primality-by-trial-division-2.rb | 8 + .../Ruby/primality-by-trial-division-3.rb | 10 + .../Ruby/primality-by-trial-division-4.rb | 3 + .../Run-BASIC/primality-by-trial-division.run | 15 + .../SAS/primality-by-trial-division.sas | 21 + .../SNOBOL4/primality-by-trial-division-1.sno | 9 + .../SNOBOL4/primality-by-trial-division-2.sno | 12 + .../Scala/primality-by-trial-division.scala | 1 + .../Scheme/primality-by-trial-division-1.ss | 7 + .../Scheme/primality-by-trial-division-2.ss | 8 + .../Seed7/primality-by-trial-division.seed7 | 19 + .../primality-by-trial-division.ml | 10 + .../Tcl/primality-by-trial-division.tcl | 9 + .../primality-by-trial-division-1.sh | 15 + .../primality-by-trial-division-2.sh | 15 + .../primality-by-trial-division-1.ursala | 4 + .../primality-by-trial-division-2.ursala | 3 + .../V/primality-by-trial-division-1.v | 6 + .../V/primality-by-trial-division-2.v | 4 + .../XPL0/primality-by-trial-division.xpl0 | 16 + Task/Prime-decomposition/0DESCRIPTION | 7 + Task/Prime-decomposition/1META.yaml | 4 + .../ABAP/prime-decomposition.abap | 53 ++ .../ACL2/prime-decomposition.acl2 | 13 + .../ALGOL-68/prime-decomposition.alg | 103 ++++ .../AWK/prime-decomposition.awk | 14 + .../Ada/prime-decomposition.ada | 60 ++ .../AutoHotkey/prime-decomposition.ahk | 18 + .../Befunge/prime-decomposition.bf | 4 + .../Burlesque/prime-decomposition.blq | 2 + .../C++/prime-decomposition.cpp | 85 +++ .../C/prime-decomposition-1.c | 171 ++++++ .../C/prime-decomposition-2.c | 107 ++++ .../C/prime-decomposition-3.c | 73 +++ .../Clojure/prime-decomposition.clj | 11 + .../Common-Lisp/prime-decomposition.lisp | 8 + .../D/prime-decomposition.d | 37 ++ .../E/prime-decomposition.e | 29 + .../Erlang/prime-decomposition.erl | 10 + .../FALSE/prime-decomposition.false | 2 + .../Factor/prime-decomposition.factor | 5 + .../Forth/prime-decomposition.fth | 9 + .../Fortran/prime-decomposition-1.f | 31 + .../Fortran/prime-decomposition-2.f | 17 + .../Frink/prime-decomposition.frink | 1 + .../GAP/prime-decomposition-1.gap | 2 + .../GAP/prime-decomposition-2.gap | 2 + .../Go/prime-decomposition.go | 39 ++ .../Groovy/prime-decomposition-1.groovy | 29 + .../Groovy/prime-decomposition-2.groovy | 1 + .../Groovy/prime-decomposition-3.groovy | 2 + .../Haskell/prime-decomposition-1.hs | 3 + .../Haskell/prime-decomposition-2.hs | 8 + .../Icon/prime-decomposition.icon | 18 + .../J/prime-decomposition-1.j | 1 + .../J/prime-decomposition-2.j | 9 + .../Java/prime-decomposition-1.java | 1 + .../Java/prime-decomposition-2.java | 12 + .../Java/prime-decomposition-3.java | 32 ++ .../Java/prime-decomposition-4.java | 11 + .../JavaScript/prime-decomposition-1.js | 39 ++ .../JavaScript/prime-decomposition-2.js | 41 ++ .../Logo/prime-decomposition.logo | 5 + .../Lua/prime-decomposition.lua | 22 + .../MATLAB/prime-decomposition.m | 2 + .../MUMPS/prime-decomposition.mumps | 22 + .../Mathematica/prime-decomposition-1.math | 1 + .../Mathematica/prime-decomposition-2.math | 2 + .../Mathematica/prime-decomposition-3.math | 1 + .../Mathematica/prime-decomposition-4.math | 1 + .../Mathematica/prime-decomposition-5.math | 1 + .../Mathematica/prime-decomposition-6.math | 22 + .../Maxima/prime-decomposition-1.maxima | 3 + .../Maxima/prime-decomposition-2.maxima | 7 + .../OCaml/prime-decomposition.ocaml | 12 + .../Octave/prime-decomposition.octave | 1 + .../PARI-GP/prime-decomposition.pari | 9 + .../PL-I/prime-decomposition.pli | 41 ++ .../Pascal/prime-decomposition.pascal | 38 ++ .../Perl-6/prime-decomposition.pl6 | 22 + .../Perl/prime-decomposition.pl | 9 + .../PicoLisp/prime-decomposition.l | 10 + .../Prolog/prime-decomposition-1.pro | 37 ++ .../Prolog/prime-decomposition-2.pro | 11 + .../Pure/prime-decomposition.pure | 6 + .../PureBasic/prime-decomposition.purebasic | 34 ++ .../Python/prime-decomposition-1.py | 47 ++ .../Python/prime-decomposition-2.py | 18 + .../Python/prime-decomposition-3.py | 21 + .../R/prime-decomposition.r | 15 + .../REXX/prime-decomposition.rexx | 32 ++ .../Ruby/prime-decomposition-1.rb | 4 + .../Ruby/prime-decomposition-2.rb | 4 + .../Ruby/prime-decomposition-3.rb | 13 + .../Ruby/prime-decomposition-4.rb | 32 ++ .../Ruby/prime-decomposition-5.rb | 10 + .../Scala/prime-decomposition-1.scala | 33 ++ .../Scala/prime-decomposition-2.scala | 25 + .../Scala/prime-decomposition-3.scala | 18 + .../Scala/prime-decomposition-4.scala | 11 + .../Scheme/prime-decomposition.ss | 11 + .../Seed7/prime-decomposition.seed7 | 18 + .../Slate/prime-decomposition.slate | 15 + .../Smalltalk/prime-decomposition.st | 14 + .../TXR/prime-decomposition.txr | 16 + .../Tcl/prime-decomposition-1.tcl | 93 +++ .../Tcl/prime-decomposition-2.tcl | 8 + .../V/prime-decomposition-1.v | 10 + .../V/prime-decomposition-2.v | 10 + .../V/prime-decomposition-3.v | 1 + .../XSLT/prime-decomposition-1.xslt | 73 +++ .../XSLT/prime-decomposition-2.xslt | 8 + .../XSLT/prime-decomposition-3.xslt | 43 ++ Task/Priority-queue/0DESCRIPTION | 17 + Task/Priority-queue/Ada/priority-queue.ada | 42 ++ .../Axiom/priority-queue-1.axiom | 27 + .../Axiom/priority-queue-2.axiom | 7 + .../Axiom/priority-queue-3.axiom | 3 + Task/Priority-queue/C++/priority-queue-1.cpp | 20 + Task/Priority-queue/C++/priority-queue-2.cpp | 30 + Task/Priority-queue/C/priority-queue-1.c | 131 +++++ Task/Priority-queue/C/priority-queue-2.c | 9 + .../priority-queue-1.coffeescript | 78 +++ .../priority-queue-2.coffeescript | 8 + Task/Priority-queue/D/priority-queue.d | 15 + .../Factor/priority-queue-1.factor | 10 + .../Factor/priority-queue-2.factor | 5 + Task/Priority-queue/Go/priority-queue.go | 43 ++ .../Haskell/priority-queue-1.hs | 3 + .../Haskell/priority-queue-2.hs | 44 ++ Task/Priority-queue/Icon/priority-queue.icon | 13 + Task/Priority-queue/J/priority-queue-1.j | 23 + Task/Priority-queue/J/priority-queue-2.j | 9 + Task/Priority-queue/Java/priority-queue.java | 31 + .../Mathematica/priority-queue-1.math | 10 + .../Mathematica/priority-queue-2.math | 11 + .../Maxima/priority-queue.maxima | 82 +++ .../OCaml/priority-queue-1.ocaml | 17 + .../OCaml/priority-queue-2.ocaml | 22 + .../Objective-C/priority-queue.m | 68 +++ Task/Priority-queue/PHP/priority-queue-1.php | 17 + Task/Priority-queue/PHP/priority-queue-2.php | 13 + Task/Priority-queue/Perl-6/priority-queue.pl6 | 29 + Task/Priority-queue/Perl/priority-queue-1.pl | 14 + Task/Priority-queue/Perl/priority-queue-2.pl | 5 + .../PicoLisp/priority-queue-1.l | 18 + .../PicoLisp/priority-queue-2.l | 18 + Task/Priority-queue/Prolog/priority-queue.pro | 28 + .../PureBasic/priority-queue.purebasic | 119 ++++ .../Priority-queue/Python/priority-queue-1.py | 16 + .../Priority-queue/Python/priority-queue-2.py | 107 ++++ .../Priority-queue/Python/priority-queue-3.py | 13 + .../Priority-queue/Python/priority-queue-4.py | 89 +++ Task/Priority-queue/R/priority-queue-1.r | 27 + Task/Priority-queue/R/priority-queue-2.r | 5 + Task/Priority-queue/R/priority-queue-3.r | 18 + Task/Priority-queue/R/priority-queue-4.r | 1 + Task/Priority-queue/Ruby/priority-queue.rb | 51 ++ .../Run-BASIC/priority-queue.run | 45 ++ .../Scala/priority-queue-1.scala | 9 + .../Scala/priority-queue-2.scala | 4 + .../Standard-ML/priority-queue.ml | 29 + Task/Priority-queue/Tcl/priority-queue.tcl | 18 + Task/Probabilistic-choice/0DESCRIPTION | 13 + Task/Probabilistic-choice/1META.yaml | 2 + .../ALGOL-68/probabilistic-choice.alg | 72 +++ .../AWK/probabilistic-choice.awk | 72 +++ .../Ada/probabilistic-choice.ada | 34 ++ .../AutoHotkey/probabilistic-choice.ahk | 39 ++ .../BBC-BASIC/probabilistic-choice.bbc | 19 + .../C++/probabilistic-choice.cpp | 52 ++ .../C/probabilistic-choice-1.c | 34 ++ .../C/probabilistic-choice-2.c | 9 + .../Clojure/probabilistic-choice.clj | 22 + .../Common-Lisp/probabilistic-choice.lisp | 46 ++ .../D/probabilistic-choice-1.d | 15 + .../D/probabilistic-choice-2.d | 24 + .../E/probabilistic-choice-1.e | 1 + .../E/probabilistic-choice-2.e | 55 ++ .../E/probabilistic-choice-3.e | 22 + .../Euphoria/probabilistic-choice.euphoria | 33 ++ .../Factor/probabilistic-choice-1.factor | 37 ++ .../Factor/probabilistic-choice-2.factor | 2 + .../Factor/probabilistic-choice-3.factor | 9 + .../Forth/probabilistic-choice.fth | 44 ++ .../Fortran/probabilistic-choice.f | 33 ++ .../Go/probabilistic-choice.go | 63 ++ .../Haskell/probabilistic-choice.hs | 20 + .../HicEst/probabilistic-choice.hicest | 17 + .../Icon/probabilistic-choice.icon | 50 ++ .../J/probabilistic-choice-1.j | 17 + .../J/probabilistic-choice-2.j | 10 + .../J/probabilistic-choice-3.j | 5 + .../Java/probabilistic-choice-1.java | 67 +++ .../Java/probabilistic-choice-2.java | 52 ++ .../JavaScript/probabilistic-choice.js | 32 ++ .../probabilistic-choice.liberty | 24 + .../Lua/probabilistic-choice.lua | 34 ++ .../Mathematica/probabilistic-choice-1.math | 2 + .../Mathematica/probabilistic-choice-2.math | 1 + .../OCaml/probabilistic-choice.ocaml | 30 + .../PARI-GP/probabilistic-choice.pari | 14 + .../Perl-6/probabilistic-choice.pl6 | 27 + .../Perl/probabilistic-choice.pl | 38 ++ .../PicoLisp/probabilistic-choice.l | 17 + .../PureBasic/probabilistic-choice.purebasic | 42 ++ .../Python/probabilistic-choice.py | 64 +++ .../R/probabilistic-choice-1.r | 8 + .../R/probabilistic-choice-2.r | 2 + .../REXX/probabilistic-choice.rexx | 32 ++ .../Ruby/probabilistic-choice.rb | 35 ++ .../Seed7/probabilistic-choice.seed7 | 45 ++ .../Tcl/probabilistic-choice.tcl | 37 ++ .../Ursala/probabilistic-choice.ursala | 18 + .../XPL0/probabilistic-choice.xpl0 | 27 + Task/Problem-of-Apollonius/0DESCRIPTION | 3 + Task/Problem-of-Apollonius/1META.yaml | 2 + .../Ada/problem-of-apollonius-1.ada | 17 + .../Ada/problem-of-apollonius-2.ada | 86 +++ .../Ada/problem-of-apollonius-3.ada | 25 + .../BBC-BASIC/problem-of-apollonius.bbc | 37 ++ .../C/problem-of-apollonius.c | 110 ++++ .../problem-of-apollonius-1.coffeescript | 51 ++ .../problem-of-apollonius-2.coffeescript | 6 + .../D/problem-of-apollonius.d | 80 +++ .../Fortran/problem-of-apollonius.f | 72 +++ .../Go/problem-of-apollonius.go | 64 +++ .../Haskell/problem-of-apollonius.hs | 75 +++ .../Icon/problem-of-apollonius.icon | 68 +++ .../J/problem-of-apollonius-1.j | 19 + .../J/problem-of-apollonius-2.j | 7 + .../Java/problem-of-apollonius.java | 93 +++ .../problem-of-apollonius.liberty | 54 ++ .../MUMPS/problem-of-apollonius.mumps | 42 ++ .../Mathematica/problem-of-apollonius.math | 27 + .../OCaml/problem-of-apollonius.ocaml | 76 +++ .../Perl-6/problem-of-apollonius.pl6 | 53 ++ .../PureBasic/problem-of-apollonius.purebasic | 74 +++ .../Python/problem-of-apollonius.py | 56 ++ .../REXX/problem-of-apollonius.rexx | 44 ++ .../Ruby/problem-of-apollonius.rb | 54 ++ .../Scala/problem-of-apollonius.scala | 81 +++ .../Tcl/problem-of-apollonius-1.tcl | 56 ++ .../Tcl/problem-of-apollonius-2.tcl | 7 + Task/Program-name/0DESCRIPTION | 7 + Task/Program-name/1META.yaml | 4 + Task/Program-name/Ada/program-name.ada | 6 + Task/Program-name/AutoHotkey/program-name.ahk | 1 + Task/Program-name/BASIC/program-name-1.basic | 1 + Task/Program-name/BASIC/program-name-2.basic | 1 + Task/Program-name/BBC-BASIC/program-name.bbc | 2 + Task/Program-name/C++/program-name.cpp | 10 + Task/Program-name/C/program-name-1.c | 7 + Task/Program-name/C/program-name-2.c | 8 + Task/Program-name/C/program-name-3.c | 37 ++ Task/Program-name/C/program-name-4.c | 57 ++ Task/Program-name/Clojure/program-name.clj | 12 + .../Common-Lisp/program-name-1.lisp | 6 + .../Common-Lisp/program-name-2.lisp | 30 + Task/Program-name/D/program-name-1.d | 7 + Task/Program-name/D/program-name-2.d | 3 + Task/Program-name/D/program-name-3.d | 2 + Task/Program-name/Dart/program-name.dart | 6 + Task/Program-name/Delphi/program-name.delphi | 8 + Task/Program-name/Emacs-Lisp/program-name.l | 8 + Task/Program-name/Erlang/program-name.erl | 5 + .../Euphoria/program-name.euphoria | 2 + Task/Program-name/Factor/program-name.factor | 8 + Task/Program-name/Forth/program-name.fth | 2 + Task/Program-name/Go/program-name.go | 10 + .../Program-name/Groovy/program-name-1.groovy | 5 + .../Program-name/Groovy/program-name-2.groovy | 1 + Task/Program-name/Haskell/program-name.hs | 4 + Task/Program-name/Icon/program-name.icon | 3 + Task/Program-name/Io/program-name.io | 9 + Task/Program-name/J/program-name.j | 13 + Task/Program-name/Java/program-name-1.java | 6 + Task/Program-name/Java/program-name-2.java | 6 + Task/Program-name/Java/program-name-3.java | 6 + Task/Program-name/Java/program-name-4.java | 6 + .../Program-name/JavaScript/program-name-1.js | 3 + .../Program-name/JavaScript/program-name-2.js | 1 + .../Program-name/JavaScript/program-name-3.js | 9 + Task/Program-name/LLVM/program-name-1.llvm | 6 + Task/Program-name/LLVM/program-name-2.llvm | 10 + Task/Program-name/LLVM/program-name-3.llvm | 10 + Task/Program-name/Lua/program-name.lua | 12 + .../Mathematica/program-name.math | 12 + .../Program-name/NetRexx/program-name.netrexx | 8 + Task/Program-name/OCaml/program-name.ocaml | 3 + .../Program-name/Objective-C/program-name-1.m | 16 + .../Program-name/Objective-C/program-name-2.m | 3 + Task/Program-name/Octave/program-name.octave | 6 + Task/Program-name/Order/program-name.order | 1 + Task/Program-name/PHP/program-name.php | 4 + Task/Program-name/Pascal/program-name.pascal | 8 + Task/Program-name/Perl-6/program-name.pl6 | 1 + Task/Program-name/Perl/program-name.pl | 11 + Task/Program-name/PicoLisp/program-name.l | 2 + .../PowerBASIC/program-name-1.powerbasic | 9 + .../PowerBASIC/program-name-2.powerbasic | 1 + .../PureBasic/program-name.purebasic | 6 + Task/Program-name/Python/program-name-1.py | 10 + Task/Program-name/Python/program-name-2.py | 10 + Task/Program-name/R/program-name.r | 12 + Task/Program-name/REXX/program-name-1.rexx | 4 + Task/Program-name/REXX/program-name-2.rexx | 2 + Task/Program-name/REXX/program-name-3.rexx | 1 + Task/Program-name/REXX/program-name-4.rexx | 5 + Task/Program-name/REXX/program-name-5.rexx | 15 + Task/Program-name/Racket/program-name.rkt | 6 + Task/Program-name/Ruby/program-name.rb | 4 + Task/Program-name/Rust/program-name-1.rust | 3 + Task/Program-name/Rust/program-name-2.rust | 3 + Task/Program-name/Scala/program-name-1.scala | 19 + Task/Program-name/Scala/program-name-2.scala | 18 + Task/Program-name/Scheme/program-name.ss | 25 + Task/Program-name/Seed7/program-name.seed7 | 10 + Task/Program-name/Smalltalk/program-name-1.st | 8 + Task/Program-name/Smalltalk/program-name-2.st | 4 + Task/Program-name/Standard-ML/program-name.ml | 7 + Task/Program-name/Tcl/program-name.tcl | 10 + Task/Program-name/UNIX-Shell/program-name.sh | 3 + Task/Program-name/VBA/program-name.vba | 1 + Task/Program-name/Vala/program-name.vala | 5 + .../Visual-Basic/program-name-1.vb | 1 + .../Visual-Basic/program-name-2.vb | 9 + Task/Program-termination/0DESCRIPTION | 3 + Task/Program-termination/1META.yaml | 2 + .../ALGOL-68/program-termination.alg | 3 + .../AWK/program-termination.awk | 1 + .../Ada/program-termination-1.ada | 10 + .../Ada/program-termination-2.ada | 11 + .../Ada/program-termination-3.ada | 14 + .../Ada/program-termination-4.ada | 10 + .../program-termination-1.applescript | 3 + .../program-termination-2.applescript | 8 + .../AutoHotkey/program-termination.ahk | 2 + .../AutoIt/program-termination.autoit | 3 + .../BASIC/program-termination-1.basic | 3 + .../BASIC/program-termination-2.basic | 1 + .../BASIC/program-termination-3.basic | 1 + .../BASIC/program-termination-4.basic | 3 + .../BBC-BASIC/program-termination.bbc | 1 + .../Batch-File/program-termination.bat | 1 + .../C++/program-termination-1.cpp | 6 + .../C++/program-termination-2.cpp | 6 + .../C++/program-termination-3.cpp | 6 + .../C/program-termination-1.c | 18 + .../C/program-termination-2.c | 5 + .../C/program-termination-3.c | 1 + .../Clojure/program-termination-1.clj | 6 + .../Clojure/program-termination-2.clj | 4 + .../Common-Lisp/program-termination.lisp | 8 + .../Delphi/program-termination-1.delphi | 1 + .../Delphi/program-termination-2.delphi | 1 + .../E/program-termination-1.e | 3 + .../E/program-termination-2.e | 3 + .../Forth/program-termination.fth | 4 + .../Fortran/program-termination.f | 3 + .../GW-BASIC/program-termination.gw-basic | 1 + .../Gema/program-termination.gema | 1 + .../Go/program-termination-1.go | 5 + .../Go/program-termination-2.go | 46 ++ .../Go/program-termination-3.go | 13 + .../Go/program-termination-4.go | 17 + .../Groovy/program-termination-1.groovy | 1 + .../Groovy/program-termination-2.groovy | 1 + .../Haskell/program-termination.hs | 8 + .../HicEst/program-termination.hicest | 1 + .../Icon/program-termination.icon | 3 + .../J/program-termination-1.j | 1 + .../J/program-termination-2.j | 1 + .../Java/program-termination-1.java | 6 + .../Java/program-termination-2.java | 5 + .../JavaScript/program-termination.js | 2 + .../Liberty-BASIC/program-termination.liberty | 1 + .../Logo/program-termination.logo | 6 + .../Lua/program-termination.lua | 3 + .../M4/program-termination.m4 | 4 + .../MATLAB/program-termination-1.m | 3 + .../MATLAB/program-termination-2.m | 3 + .../Mathematica/program-termination.math | 1 + .../Maxima/program-termination.maxima | 6 + .../NetRexx/program-termination.netrexx | 9 + .../Nimrod/program-termination.nimrod | 2 + .../OCaml/program-termination.ocaml | 4 + .../Objeck/program-termination.objeck | 3 + .../Oz/program-termination.oz | 1 + .../PARI-GP/program-termination.pari | 1 + .../PHP/program-termination.php | 2 + .../PL-I/program-termination-1.pli | 2 + .../PL-I/program-termination-2.pli | 1 + .../PL-I/program-termination-3.pli | 3 + .../Perl-6/program-termination.pl6 | 1 + .../Perl/program-termination.pl | 6 + .../PicoLisp/program-termination.l | 2 + .../Pop11/program-termination.pop11 | 3 + .../PostScript/program-termination-1.ps | 1 + .../PostScript/program-termination-2.ps | 1 + .../PowerShell/program-termination.psh | 3 + .../Prolog/program-termination-1.pro | 1 + .../Prolog/program-termination-2.pro | 1 + .../PureBasic/program-termination.purebasic | 3 + .../Python/program-termination-1.py | 3 + .../Python/program-termination-2.py | 3 + .../R/program-termination.r | 1 + .../REBOL/program-termination-1.rebol | 1 + .../REBOL/program-termination-2.rebol | 1 + .../REBOL/program-termination-3.rebol | 1 + .../REBOL/program-termination-4.rebol | 1 + .../REXX/program-termination.rexx | 29 + .../Retro/program-termination.retro | 1 + .../Ruby/program-termination-1.rb | 3 + .../Ruby/program-termination-2.rb | 3 + .../SNOBOL4/program-termination.sno | 1 + .../Scheme/program-termination-1.ss | 2 + .../Scheme/program-termination-2.ss | 2 + .../Scheme/program-termination-3.ss | 2 + .../Seed7/program-termination.seed7 | 9 + .../Slate/program-termination.slate | 1 + .../Standard-ML/program-termination.ml | 5 + .../TI-83-BASIC/program-termination.ti-83 | 1 + .../TI-89-BASIC/program-termination.ti-89 | 5 + .../TUSCRIPT/program-termination.tuscript | 4 + .../Tcl/program-termination-1.tcl | 6 + .../Tcl/program-termination-2.tcl | 3 + .../UNIX-Shell/program-termination.sh | 8 + .../Unlambda/program-termination.unlambda | 1 + .../VBScript/program-termination.vbscript | 11 + .../program-termination.vedit | 6 + .../Visual-Basic/program-termination.vb | 10 + .../XPL0/program-termination.xpl0 | 1 + Task/Pythagorean-triples/0DESCRIPTION | 12 + .../Ada/pythagorean-triples.ada | 33 ++ .../BBC-BASIC/pythagorean-triples.bbc | 27 + .../Bracmat/pythagorean-triples-1.bracmat | 53 ++ .../Bracmat/pythagorean-triples-2.bracmat | 54 ++ .../C/pythagorean-triples-1.c | 46 ++ .../C/pythagorean-triples-2.c | 1 + .../C/pythagorean-triples-3.c | 48 ++ .../C/pythagorean-triples-4.c | 8 + .../C/pythagorean-triples-5.c | 51 ++ .../pythagorean-triples.coffeescript | 33 ++ .../Common-Lisp/pythagorean-triples-1.lisp | 19 + .../Common-Lisp/pythagorean-triples-2.lisp | 7 + .../D/pythagorean-triples-1.d | 17 + .../D/pythagorean-triples-2.d | 40 ++ .../Erlang/pythagorean-triples.erl | 45 ++ .../Euphoria/pythagorean-triples.euphoria | 21 + .../Factor/pythagorean-triples.factor | 43 ++ .../Forth/pythagorean-triples.fth | 169 ++++++ .../Fortran/pythagorean-triples.f | 46 ++ .../Go/pythagorean-triples.go | 25 + .../Haskell/pythagorean-triples-1.hs | 5 + .../Haskell/pythagorean-triples-2.hs | 15 + .../Icon/pythagorean-triples.icon | 38 ++ .../J/pythagorean-triples-1.j | 14 + .../J/pythagorean-triples-2.j | 26 + .../J/pythagorean-triples-3.j | 5 + .../J/pythagorean-triples-4.j | 14 + .../J/pythagorean-triples-5.j | 4 + .../J/pythagorean-triples-6.j | 2 + .../Java/pythagorean-triples-1.java | 51 ++ .../Java/pythagorean-triples-2.java | 38 ++ .../Liberty-BASIC/pythagorean-triples.liberty | 44 ++ .../MATLAB/pythagorean-triples.m | 16 + .../Mathematica/pythagorean-triples.math | 3 + .../Modula-3/pythagorean-triples.mod3 | 31 + .../OCaml/pythagorean-triples.ocaml | 33 ++ .../PARI-GP/pythagorean-triples.pari | 15 + .../Pascal/pythagorean-triples.pascal | 31 + .../Perl-6/pythagorean-triples-1.pl6 | 18 + .../Perl-6/pythagorean-triples-2.pl6 | 20 + .../Perl-6/pythagorean-triples-3.pl6 | 23 + .../PicoLisp/pythagorean-triples.l | 15 + .../PureBasic/pythagorean-triples.purebasic | 67 +++ .../Python/pythagorean-triples-1.py | 56 ++ .../Python/pythagorean-triples-2.py | 14 + .../Python/pythagorean-triples-3.py | 7 + .../REXX/pythagorean-triples-1.rexx | 28 + .../REXX/pythagorean-triples-2.rexx | 35 ++ .../Ruby/pythagorean-triples.rb | 29 + .../Seed7/pythagorean-triples.seed7 | 31 + .../Tcl/pythagorean-triples.tcl | 25 + Task/QR-decomposition/0DESCRIPTION | 95 +++ Task/QR-decomposition/1META.yaml | 4 + .../QR-decomposition/Ada/qr-decomposition.ada | 94 +++ .../Axiom/qr-decomposition-1.axiom | 55 ++ .../Axiom/qr-decomposition-2.axiom | 5 + .../Axiom/qr-decomposition-3.axiom | 20 + .../BBC-BASIC/qr-decomposition.bbc | 97 ++++ Task/QR-decomposition/C/qr-decomposition.c | 192 +++++++ .../Common-Lisp/qr-decomposition-1.lisp | 54 ++ .../Common-Lisp/qr-decomposition-2.lisp | 34 ++ .../Common-Lisp/qr-decomposition-3.lisp | 9 + .../Common-Lisp/qr-decomposition-4.lisp | 29 + .../Common-Lisp/qr-decomposition-5.lisp | 6 + Task/QR-decomposition/D/qr-decomposition.d | 205 +++++++ Task/QR-decomposition/Go/qr-decomposition.go | 106 ++++ Task/QR-decomposition/J/qr-decomposition-1.j | 16 + Task/QR-decomposition/J/qr-decomposition-2.j | 6 + Task/QR-decomposition/J/qr-decomposition-3.j | 4 + .../MATLAB/qr-decomposition.m | 4 + .../Mathematica/qr-decomposition.math | 11 + .../Maxima/qr-decomposition-1.maxima | 12 + .../Maxima/qr-decomposition-2.maxima | 44 ++ .../Maxima/qr-decomposition-3.maxima | 29 + .../PARI-GP/qr-decomposition.pari | 1 + Task/QR-decomposition/R/qr-decomposition.r | 23 + .../Rascal/qr-decomposition.rascal | 93 +++ .../QR-decomposition/SAS/qr-decomposition.sas | 32 ++ .../Tcl/qr-decomposition-1.tcl | 58 ++ .../Tcl/qr-decomposition-2.tcl | 5 + Task/Quaternion-type/0DESCRIPTION | 29 + .../ALGOL-68/quaternion-type.alg | 220 +++++++ .../Quaternion-type/Ada/quaternion-type-1.ada | 16 + .../Quaternion-type/Ada/quaternion-type-2.ada | 59 ++ .../Quaternion-type/Ada/quaternion-type-3.ada | 26 + .../BBC-BASIC/quaternion-type.bbc | 42 ++ .../Quaternion-type/C++/quaternion-type-1.cpp | 116 ++++ .../Quaternion-type/C++/quaternion-type-2.cpp | 40 ++ .../C-sharp/quaternion-type-1.cs | 90 +++ .../C-sharp/quaternion-type-2.cs | 34 ++ Task/Quaternion-type/C/quaternion-type-1.c | 131 +++++ Task/Quaternion-type/C/quaternion-type-2.c | 58 ++ Task/Quaternion-type/D/quaternion-type.d | 216 +++++++ .../Delphi/quaternion-type-1.delphi | 129 +++++ .../Delphi/quaternion-type-2.delphi | 32 ++ Task/Quaternion-type/E/quaternion-type-1.e | 61 ++ Task/Quaternion-type/E/quaternion-type-2.e | 17 + .../Euphoria/quaternion-type.euphoria | 48 ++ .../Quaternion-type/Forth/quaternion-type.fth | 77 +++ .../Quaternion-type/Fortran/quaternion-type.f | 161 ++++++ Task/Quaternion-type/GAP/quaternion-type.gap | 39 ++ Task/Quaternion-type/Go/quaternion-type.go | 79 +++ .../Haskell/quaternion-type-1.hs | 35 ++ .../Haskell/quaternion-type-2.hs | 4 + .../Haskell/quaternion-type-3.hs | 43 ++ .../Haskell/quaternion-type-4.hs | 16 + Task/Quaternion-type/J/quaternion-type-1.j | 11 + Task/Quaternion-type/J/quaternion-type-2.j | 21 + .../Quaternion-type/Java/quaternion-type.java | 103 ++++ .../Liberty-BASIC/quaternion-type.liberty | 111 ++++ .../Quaternion-type/Lua/quaternion-type-1.lua | 63 ++ .../Quaternion-type/Lua/quaternion-type-2.lua | 23 + .../Mathematica/quaternion-type.math | 26 + .../OCaml/quaternion-type-1.ocaml | 49 ++ .../OCaml/quaternion-type-2.ocaml | 18 + .../PARI-GP/quaternion-type-1.pari | 35 ++ .../PARI-GP/quaternion-type-2.pari | 10 + .../Perl-6/quaternion-type.pl6 | 43 ++ Task/Quaternion-type/Perl/quaternion-type.pl | 70 +++ .../PicoLisp/quaternion-type-1.l | 33 ++ .../PicoLisp/quaternion-type-2.l | 22 + .../PureBasic/quaternion-type-1.purebasic | 85 +++ .../PureBasic/quaternion-type-2.purebasic | 29 + .../Python/quaternion-type-1.py | 82 +++ .../Python/quaternion-type-2.py | 56 ++ Task/Quaternion-type/R/quaternion-type.r | 33 ++ .../Quaternion-type/REXX/quaternion-type.rexx | 48 ++ .../Quaternion-type/Ruby/quaternion-type-1.rb | 58 ++ .../Quaternion-type/Ruby/quaternion-type-2.rb | 38 ++ .../Scala/quaternion-type-1.scala | 36 ++ .../Scala/quaternion-type-2.scala | 35 ++ .../Quaternion-type/Tcl/quaternion-type-1.tcl | 99 ++++ .../Quaternion-type/Tcl/quaternion-type-2.tcl | 22 + Task/Queue-Definition/0DESCRIPTION | 13 + Task/Queue-Definition/1META.yaml | 2 + .../ACL2/queue-definition.acl2 | 14 + .../Queue-Definition/AWK/queue-definition.awk | 32 ++ .../Ada/queue-definition-1.ada | 20 + .../Ada/queue-definition-10.ada | 11 + .../Ada/queue-definition-11.ada | 30 + .../Ada/queue-definition-12.ada | 48 ++ .../Ada/queue-definition-2.ada | 49 ++ .../Ada/queue-definition-3.ada | 17 + .../Ada/queue-definition-4.ada | 13 + .../Ada/queue-definition-5.ada | 25 + .../Ada/queue-definition-6.ada | 17 + .../Ada/queue-definition-7.ada | 11 + .../Ada/queue-definition-8.ada | 31 + .../Ada/queue-definition-9.ada | 56 ++ .../AutoHotkey/queue-definition.ahk | 31 + .../BBC-BASIC/queue-definition.bbc | 31 + .../Batch-File/queue-definition.bat | 69 +++ .../Queue-Definition/C++/queue-definition.cpp | 67 +++ .../C-sharp/queue-definition.cs | 38 ++ Task/Queue-Definition/C/queue-definition-1.c | 50 ++ Task/Queue-Definition/C/queue-definition-2.c | 43 ++ Task/Queue-Definition/C/queue-definition-3.c | 22 + Task/Queue-Definition/C/queue-definition-4.c | 47 ++ .../Clojure/queue-definition.clj | 15 + .../queue-definition-1.coffeescript | 38 ++ .../queue-definition-2.coffeescript | 7 + .../Common-Lisp/queue-definition.lisp | 26 + Task/Queue-Definition/E/queue-definition.e | 27 + .../Elisa/queue-definition-1.elisa | 23 + .../Elisa/queue-definition-2.elisa | 29 + .../Erlang/queue-definition.erl | 13 + .../Fantom/queue-definition.fantom | 24 + .../Forth/queue-definition.fth | 22 + .../Fortran/queue-definition.f | 69 +++ .../Queue-Definition/GAP/queue-definition.gap | 35 ++ Task/Queue-Definition/Go/queue-definition.go | 55 ++ .../Groovy/queue-definition-1.groovy | 22 + .../Groovy/queue-definition-2.groovy | 27 + .../Haskell/queue-definition-1.hs | 16 + .../Haskell/queue-definition-2.hs | 34 ++ .../Haskell/queue-definition-3.hs | 30 + Task/Queue-Definition/J/queue-definition-1.j | 16 + Task/Queue-Definition/J/queue-definition-2.j | 10 + .../Java/queue-definition.java | 40 ++ .../JavaScript/queue-definition-1.js | 5 + .../JavaScript/queue-definition-2.js | 10 + .../Queue-Definition/Lua/queue-definition.lua | 25 + .../MATLAB/queue-definition-1.m | 10 + .../MATLAB/queue-definition-2.m | 82 +++ .../MATLAB/queue-definition-3.m | 22 + .../Mathematica/queue-definition.math | 3 + .../Maxima/queue-definition.maxima | 18 + .../NetRexx/queue-definition.netrexx | 35 ++ .../OCaml/queue-definition-1.ocaml | 20 + .../OCaml/queue-definition-2.ocaml | 28 + .../OxygenBasic/queue-definition.oxy | 65 +++ Task/Queue-Definition/Oz/queue-definition.oz | 34 ++ .../PHP/queue-definition-1.php | 21 + .../PHP/queue-definition-2.php | 9 + .../PL-I/queue-definition.pli | 28 + .../Pascal/queue-definition.pascal | 101 ++++ .../Perl-6/queue-definition-1.pl6 | 13 + .../Perl-6/queue-definition-2.pl6 | 15 + .../Perl/queue-definition-1.pl | 4 + .../Perl/queue-definition-2.pl | 5 + .../PicoLisp/queue-definition.l | 6 + .../PostScript/queue-definition.ps | 3 + .../Prolog/queue-definition.pro | 11 + .../PureBasic/queue-definition.purebasic | 38 ++ .../Python/queue-definition-1.py | 45 ++ .../Python/queue-definition-2.py | 15 + .../Python/queue-definition-3.py | 6 + Task/Queue-Definition/R/queue-definition-1.r | 48 ++ Task/Queue-Definition/R/queue-definition-2.r | 39 ++ Task/Queue-Definition/R/queue-definition-3.r | 30 + .../REBOL/queue-definition.rebol | 33 ++ .../REXX/queue-definition.rexx | 20 + .../Ruby/queue-definition-1.rb | 57 ++ .../Ruby/queue-definition-2.rb | 16 + .../Scala/queue-definition-1.scala | 34 ++ .../Scala/queue-definition-2.scala | 11 + .../Scheme/queue-definition-1.ss | 15 + .../Scheme/queue-definition-2.ss | 25 + .../Slate/queue-definition.slate | 7 + .../Smalltalk/queue-definition.st | 20 + .../Standard-ML/queue-definition-1.ml | 12 + .../Standard-ML/queue-definition-2.ml | 16 + .../Tcl/queue-definition-1.tcl | 31 + .../Tcl/queue-definition-2.tcl | 10 + .../UnixPipes/queue-definition-1.unixpipes | 4 + .../UnixPipes/queue-definition-2.unixpipes | 6 + Task/Queue-Definition/V/queue-definition-1.v | 4 + Task/Queue-Definition/V/queue-definition-2.v | 8 + .../XPL0/queue-definition.xpl0 | 48 ++ Task/Queue-Usage/0DESCRIPTION | 8 + Task/Queue-Usage/1META.yaml | 2 + Task/Queue-Usage/Ada/queue-usage.ada | 21 + .../AppleScript/queue-usage.applescript | 29 + Task/Queue-Usage/AutoHotkey/queue-usage.ahk | 31 + Task/Queue-Usage/BBC-BASIC/queue-usage.bbc | 31 + Task/Queue-Usage/C++/queue-usage-1.cpp | 46 ++ Task/Queue-Usage/C++/queue-usage-2.cpp | 1 + Task/Queue-Usage/C-sharp/queue-usage.cs | 37 ++ Task/Queue-Usage/C/queue-usage.c | 31 + Task/Queue-Usage/Clojure/queue-usage-1.clj | 11 + Task/Queue-Usage/Clojure/queue-usage-2.clj | 11 + .../CoffeeScript/queue-usage-1.coffeescript | 32 ++ .../CoffeeScript/queue-usage-2.coffeescript | 4 + Task/Queue-Usage/Common-Lisp/queue-usage.lisp | 7 + Task/Queue-Usage/D/queue-usage-1.d | 44 ++ Task/Queue-Usage/D/queue-usage-2.d | 64 +++ Task/Queue-Usage/Delphi/queue-usage.delphi | 25 + Task/Queue-Usage/E/queue-usage.e | 9 + Task/Queue-Usage/Erlang/queue-usage.erl | 17 + Task/Queue-Usage/Fantom/queue-usage.fantom | 14 + Task/Queue-Usage/Fortran/queue-usage.f | 33 ++ Task/Queue-Usage/Go/queue-usage-1.go | 39 ++ Task/Queue-Usage/Go/queue-usage-2.go | 36 ++ Task/Queue-Usage/Go/queue-usage-3.go | 39 ++ Task/Queue-Usage/Groovy/queue-usage-1.groovy | 1 + Task/Queue-Usage/Groovy/queue-usage-2.groovy | 46 ++ Task/Queue-Usage/Haskell/queue-usage.hs | 25 + Task/Queue-Usage/Icon/queue-usage.icon | 18 + Task/Queue-Usage/J/queue-usage-1.j | 19 + Task/Queue-Usage/J/queue-usage-2.j | 17 + Task/Queue-Usage/Java/queue-usage-1.java | 13 + Task/Queue-Usage/Java/queue-usage-2.java | 11 + Task/Queue-Usage/JavaScript/queue-usage.js | 10 + Task/Queue-Usage/Logo/queue-usage.logo | 9 + Task/Queue-Usage/Lua/queue-usage.lua | 7 + Task/Queue-Usage/Mathematica/queue-usage.math | 16 + Task/Queue-Usage/NetRexx/queue-usage.netrexx | 65 +++ Task/Queue-Usage/OCaml/queue-usage.ocaml | 37 ++ Task/Queue-Usage/Objeck/queue-usage.objeck | 14 + Task/Queue-Usage/Oz/queue-usage.oz | 12 + Task/Queue-Usage/PHP/queue-usage.php | 10 + Task/Queue-Usage/PL-I/queue-usage-1.pli | 40 ++ Task/Queue-Usage/PL-I/queue-usage-2.pli | 21 + Task/Queue-Usage/Perl-6/queue-usage-1.pl6 | 3 + Task/Queue-Usage/Perl-6/queue-usage-2.pl6 | 12 + Task/Queue-Usage/Perl/queue-usage-1.pl | 11 + Task/Queue-Usage/Perl/queue-usage-2.pl | 3 + Task/Queue-Usage/PicoLisp/queue-usage.l | 5 + Task/Queue-Usage/PostScript/queue-usage.ps | 6 + Task/Queue-Usage/Prolog/queue-usage.pro | 48 ++ .../PureBasic/queue-usage.purebasic | 36 ++ Task/Queue-Usage/Python/queue-usage.py | 8 + Task/Queue-Usage/REBOL/queue-usage.rebol | 15 + Task/Queue-Usage/REXX/queue-usage.rexx | 20 + Task/Queue-Usage/Scala/queue-usage.scala | 11 + Task/Queue-Usage/Standard-ML/queue-usage-1.ml | 48 ++ Task/Queue-Usage/Standard-ML/queue-usage-2.ml | 55 ++ Task/Queue-Usage/Tcl/queue-usage.tcl | 8 + Task/Queue-Usage/XPL0/queue-usage.xpl0 | 48 ++ Task/RCRPG/0DESCRIPTION | 10 + Task/RCRPG/1META.yaml | 2 + Task/RIPEMD-160/0DESCRIPTION | 5 + Task/RIPEMD-160/1META.yaml | 3 + Task/RIPEMD-160/D/ripemd-160.d | 6 + Task/RIPEMD-160/Go/ripemd-160.go | 12 + Task/RIPEMD-160/Java/ripemd-160.java | 16 + Task/RIPEMD-160/Objeck/ripemd-160.objeck | 7 + Task/RIPEMD-160/Perl-6/ripemd-160.pl6 | 83 +++ Task/RIPEMD-160/Python/ripemd-160.py | 8 + Task/RIPEMD-160/Ruby/ripemd-160-1.rb | 2 + Task/RIPEMD-160/Ruby/ripemd-160-2.rb | 2 + Task/RIPEMD-160/Ruby/ripemd-160-3.rb | 118 ++++ Task/RIPEMD-160/Tcl/ripemd-160.tcl | 3 + .../0DESCRIPTION | 1 + .../1META.yaml | 3 + .../Ada/random-number-generator--device-.ada | 13 + .../random-number-generator--device-.bbc | 2 + .../random-number-generator--device-.cs | 14 + .../C/random-number-generator--device--1.c | 25 + .../C/random-number-generator--device--2.c | 10 + .../C/random-number-generator--device--3.c | 18 + .../C/random-number-generator--device--4.c | 23 + .../random-number-generator--device-.fth | 9 + .../Go/random-number-generator--device-.go | 34 ++ .../random-number-generator--device--1.groovy | 1 + .../random-number-generator--device--2.groovy | 1 + .../random-number-generator--device-.hs | 9 + .../J/random-number-generator--device--1.j | 1 + .../J/random-number-generator--device--2.j | 1 + .../random-number-generator--device-.java | 10 + .../random-number-generator--device-.netrexx | 32 ++ .../random-number-generator--device--1.ocaml | 13 + .../random-number-generator--device--2.ocaml | 16 + .../random-number-generator--device-.pascal | 11 + .../random-number-generator--device-.pl6 | 4 + .../Perl/random-number-generator--device-.pl | 10 + .../random-number-generator--device-.l | 2 + .../random-number-generator--device-.dos | 1 + ...random-number-generator--device-.purebasic | 4 + .../random-number-generator--device-.py | 3 + .../random-number-generator--device-.rexx | 9 + .../Ruby/random-number-generator--device-.rb | 2 + .../random-number-generator--device--1.tcl | 9 + .../random-number-generator--device--2.tcl | 2 + .../random-number-generator--device-.xpl0 | 3 + .../0DESCRIPTION | 9 + .../random-number-generator--included--1.alg | 12 + .../random-number-generator--included--2.alg | 3 + .../C/random-number-generator--included-.c | 13 + .../random-number-generator--included-.cmake | 4 + .../random-number-generator--included-.djv | 1 + .../random-number-generator--included--1.erl | 1 + .../random-number-generator--included--2.erl | 6 + .../random-number-generator--included--3.erl | 1 + .../random-number-generator--included--4.erl | 1 + .../random-number-generator--included--1.gap | 8 + .../random-number-generator--included--2.gap | 7 + .../random-number-generator--included-.pari | 4 + .../random-number-generator--included-.pli | 2 + .../random-number-generator--included--1.sql | 2 + .../random-number-generator--included--2.sql | 3 + .../R/random-number-generator--included-.r | 2 + ...andom-number-generator--included--1.rascal | 5 + ...andom-number-generator--included--2.rascal | 4 + .../random-number-generator--included-.run | 1 + .../random-number-generator--included-.sh | 1 + .../random-number-generator--included-.xpl0 | 6 + Task/Random-numbers/0DESCRIPTION | 3 + Task/Random-numbers/1META.yaml | 4 + .../ALGOL-68/random-numbers.alg | 13 + Task/Random-numbers/AWK/random-numbers.awk | 1 + Task/Random-numbers/Ada/random-numbers.ada | 23 + .../AutoHotkey/random-numbers.ahk | 15 + .../BBC-BASIC/random-numbers.bbc | 11 + Task/Random-numbers/C++/random-numbers-1.cpp | 27 + Task/Random-numbers/C++/random-numbers-2.cpp | 20 + Task/Random-numbers/C++/random-numbers-3.cpp | 17 + .../C-sharp/random-numbers-1.cs | 4 + .../C-sharp/random-numbers-2.cs | 27 + Task/Random-numbers/C/random-numbers.c | 22 + .../Random-numbers/Clojure/random-numbers.clj | 4 + .../Common-Lisp/random-numbers.lisp | 2 + Task/Random-numbers/D/random-numbers-1.d | 24 + Task/Random-numbers/D/random-numbers-2.d | 10 + .../DWScript/random-numbers.dwscript | 5 + .../Delphi/random-numbers.delphi | 19 + Task/Random-numbers/E/random-numbers.e | 1 + Task/Random-numbers/Eiffel/random-numbers.e | 95 +++ Task/Random-numbers/Erlang/random-numbers.erl | 31 + .../Euler-Math-Toolbox/random-numbers.euler | 4 + .../Euphoria/random-numbers.euphoria | 15 + .../Factor/random-numbers.factor | 1 + .../Fantom/random-numbers-1.fantom | 17 + .../Fantom/random-numbers-2.fantom | 20 + Task/Random-numbers/Forth/random-numbers.fth | 16 + Task/Random-numbers/Fortran/random-numbers.f | 24 + Task/Random-numbers/Go/random-numbers.go | 17 + .../Groovy/random-numbers.groovy | 2 + Task/Random-numbers/Haskell/random-numbers.hs | 14 + .../HicEst/random-numbers.hicest | 4 + Task/Random-numbers/IDL/random-numbers.idl | 1 + Task/Random-numbers/Icon/random-numbers.icon | 7 + Task/Random-numbers/J/random-numbers-1.j | 4 + Task/Random-numbers/J/random-numbers-2.j | 3 + Task/Random-numbers/Java/random-numbers.java | 6 + .../JavaScript/random-numbers.js | 8 + .../Liberty-BASIC/random-numbers.liberty | 6 + Task/Random-numbers/Logo/random-numbers.logo | 10 + Task/Random-numbers/MATLAB/random-numbers-1.m | 2 + Task/Random-numbers/MATLAB/random-numbers-2.m | 1 + Task/Random-numbers/MATLAB/random-numbers-3.m | 15 + Task/Random-numbers/MATLAB/random-numbers-4.m | 5 + .../MAXScript/random-numbers.maxscript | 8 + .../Mathematica/random-numbers.math | 1 + .../Maxima/random-numbers.maxima | 3 + .../Metafont/random-numbers.metafont | 19 + .../Random-numbers/Mirah/random-numbers.mirah | 9 + .../Modula-3/random-numbers.mod3 | 21 + .../NetRexx/random-numbers.netrexx | 55 ++ .../NewLISP/random-numbers.newlisp | 1 + .../Random-numbers/OCaml/random-numbers.ocaml | 4 + .../Objeck/random-numbers.objeck | 18 + .../Octave/random-numbers.octave | 3 + .../PARI-GP/random-numbers.pari | 6 + Task/Random-numbers/PHP/random-numbers.php | 11 + Task/Random-numbers/PL-I/random-numbers.pli | 21 + Task/Random-numbers/PL-SQL/random-numbers.sql | 24 + Task/Random-numbers/Perl-6/random-numbers.pl6 | 5 + Task/Random-numbers/Perl/random-numbers.pl | 5 + Task/Random-numbers/PicoLisp/random-numbers.l | 16 + .../Random-numbers/Pop11/random-numbers.pop11 | 15 + .../PureBasic/random-numbers.purebasic | 18 + .../Random-numbers/Python/random-numbers-1.py | 3 + .../Random-numbers/Python/random-numbers-2.py | 4 + Task/Random-numbers/R/random-numbers.r | 1 + Task/Random-numbers/REXX/random-numbers.rexx | 41 ++ Task/Random-numbers/Ruby/random-numbers.rb | 1 + .../Run-BASIC/random-numbers.run | 5 + Task/Random-numbers/Sather/random-numbers.sa | 19 + .../Random-numbers/Scala/random-numbers.scala | 1 + Task/Random-numbers/Scheme/random-numbers.ss | 47 ++ .../Random-numbers/Seed7/random-numbers.seed7 | 25 + .../Standard-ML/random-numbers-1.ml | 5 + .../Standard-ML/random-numbers-2.ml | 5 + Task/Random-numbers/Tcl/random-numbers.tcl | 11 + .../Ursala/random-numbers.ursala | 14 + .../Yorick/random-numbers.yorick | 3 + .../ZX-Spectrum-Basic/random-numbers.zx | 6 + Task/Range-expansion/0DESCRIPTION | 8 + .../ALGOL-68/range-expansion.alg | 39 ++ Task/Range-expansion/Ada/range-expansion.ada | 66 +++ .../AutoHotkey/range-expansion.ahk | 9 + .../BBC-BASIC/range-expansion.bbc | 23 + .../Bracmat/range-expansion.bracmat | 15 + Task/Range-expansion/C++/range-expansion.cpp | 74 +++ Task/Range-expansion/C/range-expansion.c | 78 +++ .../Clojure/range-expansion.clj | 24 + .../Common-Lisp/range-expansion.lisp | 23 + Task/Range-expansion/D/range-expansion.d | 16 + Task/Range-expansion/Go/range-expansion.go | 64 +++ .../Groovy/range-expansion-1.groovy | 3 + .../Groovy/range-expansion-2.groovy | 2 + .../Haskell/range-expansion-1.hs | 2 + .../Haskell/range-expansion-2.hs | 10 + .../Haskell/range-expansion-3.hs | 16 + .../Range-expansion/Icon/range-expansion.icon | 25 + Task/Range-expansion/J/range-expansion-1.j | 6 + Task/Range-expansion/J/range-expansion-2.j | 2 + .../Range-expansion/Java/range-expansion.java | 66 +++ .../JavaScript/range-expansion.js | 34 ++ Task/Range-expansion/K/range-expansion-1.k | 5 + Task/Range-expansion/K/range-expansion-2.k | 2 + .../Liberty-BASIC/range-expansion.liberty | 23 + .../MUMPS/range-expansion.mumps | 10 + .../Maple/range-expansion-1.maple | 37 ++ .../Maple/range-expansion-2.maple | 3 + .../Maple/range-expansion-3.maple | 3 + .../Mathematica/range-expansion.math | 3 + .../NetRexx/range-expansion.netrexx | 30 + .../OCaml/range-expansion.ocaml | 23 + .../Oberon-2/range-expansion.oberon-2 | 235 ++++++++ Task/Range-expansion/Oz/range-expansion-1.oz | 30 + Task/Range-expansion/Oz/range-expansion-2.oz | 1 + Task/Range-expansion/PHP/range-expansion.php | 12 + Task/Range-expansion/PL-I/range-expansion.pli | 51 ++ .../Perl-6/range-expansion.pl6 | 7 + .../Range-expansion/Perl/range-expansion-1.pl | 6 + .../Range-expansion/Perl/range-expansion-2.pl | 4 + .../PicoLisp/range-expansion.l | 9 + .../Prolog/range-expansion.pro | 81 +++ .../PureBasic/range-expansion.purebasic | 46 ++ .../Python/range-expansion-1.py | 11 + .../Python/range-expansion-2.py | 11 + Task/Range-expansion/R/range-expansion-1.r | 9 + Task/Range-expansion/R/range-expansion-2.r | 2 + .../REXX/range-expansion-1.rexx | 18 + .../REXX/range-expansion-2.rexx | 25 + .../Racket/range-expansion-1.rkt | 13 + .../Racket/range-expansion-2.rkt | 26 + Task/Range-expansion/Ruby/range-expansion.rb | 11 + .../Run-BASIC/range-expansion.run | 25 + .../SNOBOL4/range-expansion.sno | 15 + .../Scala/range-expansion.scala | 6 + .../Range-expansion/Scheme/range-expansion.ss | 35 ++ .../Seed7/range-expansion.seed7 | 35 ++ .../TUSCRIPT/range-expansion.tuscript | 22 + Task/Range-expansion/Tcl/range-expansion.tcl | 14 + .../Ursala/range-expansion.ursala | 8 + Task/Range-expansion/VBA/range-expansion.vba | 46 ++ .../Range-expansion/XPL0/range-expansion.xpl0 | 42 ++ Task/Range-extraction/0DESCRIPTION | 12 + .../ALGOL-68/range-extraction-1.alg | 54 ++ .../ALGOL-68/range-extraction-2.alg | 60 ++ .../ALGOL-68/range-extraction-3.alg | 44 ++ .../ALGOL-68/range-extraction-4.alg | 83 +++ .../Range-extraction/AWK/range-extraction.awk | 54 ++ .../Ada/range-extraction-1.ada | 46 ++ .../Ada/range-extraction-2.ada | 45 ++ .../Aime/range-extraction.aime | 54 ++ .../AutoHotkey/range-extraction.ahk | 11 + .../BBC-BASIC/range-extraction.bbc | 26 + .../Bracmat/range-extraction.bracmat | 51 ++ .../Range-extraction/C++/range-extraction.cpp | 53 ++ .../C-sharp/range-extraction.cs | 58 ++ Task/Range-extraction/C/range-extraction-1.c | 36 ++ Task/Range-extraction/C/range-extraction-2.c | 1 + .../Common-Lisp/range-extraction.lisp | 26 + Task/Range-extraction/D/range-extraction.d | 34 ++ .../DWScript/range-extraction.dwscript | 25 + Task/Range-extraction/E/range-extraction-1.e | 17 + Task/Range-extraction/E/range-extraction-2.e | 6 + .../Euphoria/range-extraction.euphoria | 32 ++ .../Forth/range-extraction.fth | 27 + Task/Range-extraction/Go/range-extraction.go | 55 ++ .../Groovy/range-extraction-1.groovy | 12 + .../Groovy/range-extraction-2.groovy | 7 + .../Haskell/range-extraction-1.hs | 13 + .../Haskell/range-extraction-2.hs | 2 + .../Icon/range-extraction.icon | 33 ++ Task/Range-extraction/J/range-extraction-1.j | 4 + Task/Range-extraction/J/range-extraction-2.j | 2 + .../Java/range-extraction.java | 41 ++ .../JavaScript/range-extraction.js | 35 ++ Task/Range-extraction/K/range-extraction-1.k | 3 + Task/Range-extraction/K/range-extraction-2.k | 2 + .../Liberty-BASIC/range-extraction.liberty | 33 ++ .../MUMPS/range-extraction.mumps | 17 + .../Mathematica/range-extraction.math | 5 + .../NetRexx/range-extraction.netrexx | 37 ++ .../OCaml/range-extraction.ocaml | 21 + .../Oberon-2/range-extraction.oberon-2 | 92 +++ .../OxygenBasic/range-extraction.oxy | 38 ++ .../Range-extraction/Oz/range-extraction-1.oz | 47 ++ .../Range-extraction/Oz/range-extraction-2.oz | 1 + .../PL-I/range-extraction-1.pli | 48 ++ .../PL-I/range-extraction-2.pli | 1 + .../PL-I/range-extraction-3.pli | 1 + .../Perl-6/range-extraction.pl6 | 24 + .../Range-extraction/Perl/range-extraction.pl | 15 + .../PicoLisp/range-extraction.l | 11 + .../Prolog/range-extraction.pro | 89 +++ .../PureBasic/range-extraction.purebasic | 70 +++ .../Python/range-extraction-1.py | 19 + .../Python/range-extraction-2.py | 26 + Task/Range-extraction/Qi/range-extraction.qi | 17 + .../REXX/range-extraction-1.rexx | 30 + .../REXX/range-extraction-2.rexx | 31 + .../Range-extraction/Ruby/range-extraction.rb | 27 + .../SNOBOL4/range-extraction.sno | 22 + .../Scala/range-extraction.scala | 25 + .../Scheme/range-extraction.ss | 28 + .../Seed7/range-extraction.seed7 | 32 ++ .../TUSCRIPT/range-extraction-1.tuscript | 13 + .../TUSCRIPT/range-extraction-2.tuscript | 31 + .../Range-extraction/Tcl/range-extraction.tcl | 29 + .../Ursala/range-extraction.ursala | 10 + .../Range-extraction/VBA/range-extraction.vba | 70 +++ Task/Rate-counter/0DESCRIPTION | 12 + Task/Rate-counter/Ada/rate-counter.ada | 71 +++ Task/Rate-counter/BBC-BASIC/rate-counter.bbc | 26 + Task/Rate-counter/C++/rate-counter.cpp | 78 +++ Task/Rate-counter/C/rate-counter.c | 74 +++ .../Common-Lisp/rate-counter-1.lisp | 1 + .../Common-Lisp/rate-counter-2.lisp | 10 + .../Common-Lisp/rate-counter-3.lisp | 1 + .../Common-Lisp/rate-counter-4.lisp | 1 + Task/Rate-counter/E/rate-counter-1.e | 24 + Task/Rate-counter/E/rate-counter-2.e | 34 ++ Task/Rate-counter/Go/rate-counter.go | 52 ++ Task/Rate-counter/HicEst/rate-counter.hicest | 20 + Task/Rate-counter/J/rate-counter-1.j | 1 + Task/Rate-counter/J/rate-counter-2.j | 4 + Task/Rate-counter/J/rate-counter-3.j | 2 + Task/Rate-counter/JavaScript/rate-counter.js | 14 + .../Liberty-BASIC/rate-counter.liberty | 56 ++ .../Rate-counter/OxygenBasic/rate-counter.oxy | 118 ++++ Task/Rate-counter/PARI-GP/rate-counter.pari | 10 + Task/Rate-counter/Perl-6/rate-counter.pl6 | 20 + Task/Rate-counter/Perl/rate-counter.pl | 12 + Task/Rate-counter/PicoLisp/rate-counter-1.l | 8 + Task/Rate-counter/PicoLisp/rate-counter-2.l | 1 + .../PureBasic/rate-counter-1.purebasic | 35 ++ .../PureBasic/rate-counter-2.purebasic | 13 + Task/Rate-counter/Python/rate-counter.py | 58 ++ Task/Rate-counter/REXX/rate-counter.rexx | 36 ++ Task/Rate-counter/Run-BASIC/rate-counter.run | 45 ++ Task/Rate-counter/Scala/rate-counter-1.scala | 11 + Task/Rate-counter/Scala/rate-counter-2.scala | 15 + Task/Rate-counter/Smalltalk/rate-counter.st | 5 + Task/Rate-counter/Tcl/rate-counter-1.tcl | 16 + Task/Rate-counter/Tcl/rate-counter-2.tcl | 1 + .../Rate-counter/UNIX-Shell/rate-counter-1.sh | 5 + .../Rate-counter/UNIX-Shell/rate-counter-2.sh | 15 + Task/Rate-counter/XPL0/rate-counter.xpl0 | 13 + Task/Ray-casting-algorithm/0DESCRIPTION | 71 +++ Task/Ray-casting-algorithm/1META.yaml | 2 + .../Ada/ray-casting-algorithm-1.ada | 14 + .../Ada/ray-casting-algorithm-2.ada | 87 +++ .../Ada/ray-casting-algorithm-3.ada | 91 +++ .../AutoHotkey/ray-casting-algorithm.ahk | 11 + .../C/ray-casting-algorithm.c | 141 +++++ .../ray-casting-algorithm.coffeescript | 28 + .../Common-Lisp/ray-casting-algorithm-1.lisp | 30 + .../Common-Lisp/ray-casting-algorithm-2.lisp | 35 ++ .../D/ray-casting-algorithm.d | 66 +++ .../Factor/ray-casting-algorithm-1.factor | 19 + .../Factor/ray-casting-algorithm-2.factor | 7 + .../Fortran/ray-casting-algorithm-1.f | 35 ++ .../Fortran/ray-casting-algorithm-2.f | 77 +++ .../Fortran/ray-casting-algorithm-3.f | 40 ++ .../Go/ray-casting-algorithm-1.go | 97 ++++ .../Go/ray-casting-algorithm-2.go | 76 +++ .../Haskell/ray-casting-algorithm.hs | 49 ++ .../J/ray-casting-algorithm-1.j | 9 + .../J/ray-casting-algorithm-2.j | 11 + .../J/ray-casting-algorithm-3.j | 5 + .../ray-casting-algorithm.liberty | 76 +++ .../OCaml/ray-casting-algorithm.ocaml | 97 ++++ .../Perl-6/ray-casting-algorithm.pl6 | 72 +++ .../Perl/ray-casting-algorithm-1.pl | 38 ++ .../Perl/ray-casting-algorithm-2.pl | 37 ++ .../PicoLisp/ray-casting-algorithm.l | 27 + .../PureBasic/ray-casting-algorithm.purebasic | 83 +++ .../Python/ray-casting-algorithm-1.py | 102 ++++ .../Python/ray-casting-algorithm-2.py | 27 + .../R/ray-casting-algorithm-1.r | 44 ++ .../R/ray-casting-algorithm-2.r | 13 + .../R/ray-casting-algorithm-3.r | 26 + .../REXX/ray-casting-algorithm.rexx | 49 ++ .../Racket/ray-casting-algorithm-1.rkt | 75 +++ .../Racket/ray-casting-algorithm-2.rkt | 17 + .../Smalltalk/ray-casting-algorithm-1.st | 77 +++ .../Smalltalk/ray-casting-algorithm-2.st | 42 ++ .../Tcl/ray-casting-algorithm.tcl | 58 ++ .../Ursala/ray-casting-algorithm-1.ursala | 7 + .../Ursala/ray-casting-algorithm-2.ursala | 7 + Task/Read-a-configuration-file/0DESCRIPTION | 42 ++ Task/Read-a-configuration-file/1META.yaml | 2 + .../Ada/read-a-configuration-file-1.ada | 39 ++ .../Ada/read-a-configuration-file-2.ada | 24 + .../AutoHotkey/read-a-configuration-file.ahk | 37 ++ .../BBC-BASIC/read-a-configuration-file.bbc | 61 ++ .../C++/read-a-configuration-file-1.cpp | 105 ++++ .../C++/read-a-configuration-file-2.cpp | 75 +++ .../D/read-a-configuration-file.d | 38 ++ .../Fantom/read-a-configuration-file.fantom | 60 ++ .../Go/read-a-configuration-file-1.go | 160 ++++++ .../Go/read-a-configuration-file-2.go | 63 ++ .../Haskell/read-a-configuration-file-1.hs | 33 ++ .../Haskell/read-a-configuration-file-2.hs | 8 + .../J/read-a-configuration-file-1.j | 22 + .../J/read-a-configuration-file-2.j | 6 + .../read-a-configuration-file.liberty | 69 +++ .../Lua/read-a-configuration-file.lua | 40 ++ .../MATLAB/read-a-configuration-file.m | 38 ++ .../OCaml/read-a-configuration-file.ocaml | 25 + .../PL-I/read-a-configuration-file.pli | 58 ++ .../Pascal/read-a-configuration-file.pascal | 100 ++++ .../Perl-6/read-a-configuration-file.pl6 | 52 ++ .../Perl/read-a-configuration-file.pl | 77 +++ .../PicoLisp/read-a-configuration-file-1.l | 4 + .../PicoLisp/read-a-configuration-file-2.l | 2 + .../Protium/read-a-configuration-file.protium | 27 + .../Python/read-a-configuration-file.py | 34 ++ .../REXX/read-a-configuration-file-1.rexx | 47 ++ .../REXX/read-a-configuration-file-2.rexx | 161 ++++++ .../Ruby/read-a-configuration-file.rb | 19 + .../Seed7/read-a-configuration-file.seed7 | 49 ++ .../Smalltalk/read-a-configuration-file-1.st | 19 + .../Smalltalk/read-a-configuration-file-2.st | 5 + .../Smalltalk/read-a-configuration-file-3.st | 5 + .../TXR/read-a-configuration-file.txr | 24 + .../Tcl/read-a-configuration-file.tcl | 46 ++ .../read-a-configuration-file.vedit | 35 ++ .../Visual-Basic/read-a-configuration-file.vb | 205 +++++++ Task/Read-a-file-line-by-line/0DESCRIPTION | 5 + Task/Read-a-file-line-by-line/1META.yaml | 2 + .../ALGOL-68/read-a-file-line-by-line.alg | 21 + .../AWK/read-a-file-line-by-line.awk | 1 + .../Ada/read-a-file-line-by-line.ada | 19 + .../Aime/read-a-file-line-by-line.aime | 9 + .../AutoHotkey/read-a-file-line-by-line.ahk | 21 + .../BASIC/read-a-file-line-by-line-1.basic | 5 + .../BASIC/read-a-file-line-by-line-2.basic | 7 + .../BBC-BASIC/read-a-file-line-by-line-1.bbc | 6 + .../BBC-BASIC/read-a-file-line-by-line-2.bbc | 7 + .../Brat/read-a-file-line-by-line.brat | 5 + .../C++/read-a-file-line-by-line-1.cpp | 17 + .../C++/read-a-file-line-by-line-2.cpp | 10 + .../C-sharp/read-a-file-line-by-line-1.cs | 2 + .../C-sharp/read-a-file-line-by-line-2.cs | 34 ++ .../C/read-a-file-line-by-line-1.c | 35 ++ .../C/read-a-file-line-by-line-2.c | 123 ++++ .../C/read-a-file-line-by-line-3.c | 75 +++ .../Clojure/read-a-file-line-by-line.clj | 3 + .../read-a-file-line-by-line.coffeescript | 80 +++ .../Common-Lisp/read-a-file-line-by-line.lisp | 3 + .../D/read-a-file-line-by-line.d | 6 + .../Delphi/read-a-file-line-by-line-1.delphi | 11 + .../Delphi/read-a-file-line-by-line-2.delphi | 10 + .../read-a-file-line-by-line.euphoria | 15 + .../Factor/read-a-file-line-by-line.factor | 1 + .../Fantom/read-a-file-line-by-line.fantom | 10 + .../Forth/read-a-file-line-by-line.fth | 10 + .../Frink/read-a-file-line-by-line.frink | 2 + .../GAP/read-a-file-line-by-line.gap | 18 + .../Go/read-a-file-line-by-line-1.go | 63 ++ .../Go/read-a-file-line-by-line-2.go | 32 ++ .../Groovy/read-a-file-line-by-line-1.groovy | 3 + .../Groovy/read-a-file-line-by-line-2.groovy | 3 + .../Groovy/read-a-file-line-by-line-3.groovy | 5 + .../J/read-a-file-line-by-line-1.j | 34 ++ .../J/read-a-file-line-by-line-2.j | 5 + .../Java/read-a-file-line-by-line-1.java | 39 ++ .../Java/read-a-file-line-by-line-2.java | 12 + .../Java/read-a-file-line-by-line-3.java | 11 + .../Julia/read-a-file-line-by-line.julia | 5 + .../read-a-file-line-by-line-1.liberty | 8 + .../read-a-file-line-by-line-2.liberty | 8 + .../read-a-file-line-by-line-3.liberty | 8 + .../Logo/read-a-file-line-by-line.logo | 1 + .../Lua/read-a-file-line-by-line.lua | 8 + .../MATLAB/read-a-file-line-by-line.m | 10 + .../Mathematica/read-a-file-line-by-line.math | 7 + .../Maxima/read-a-file-line-by-line.maxima | 8 + .../read-a-file-line-by-line-1.netrexx | 31 + .../read-a-file-line-by-line-2.netrexx | 46 ++ .../NewLISP/read-a-file-line-by-line.newlisp | 4 + .../OCaml/read-a-file-line-by-line.ocaml | 9 + .../Objeck/read-a-file-line-by-line.objeck | 15 + .../Objective-C/read-a-file-line-by-line-1.m | 4 + .../Objective-C/read-a-file-line-by-line-2.m | 1 + .../OxygenBasic/read-a-file-line-by-line.oxy | 32 ++ .../PARI-GP/read-a-file-line-by-line.pari | 7 + .../PHP/read-a-file-line-by-line.php | 6 + .../PL-I/read-a-file-line-by-line.pli | 9 + .../Perl-6/read-a-file-line-by-line-1.pl6 | 4 + .../Perl-6/read-a-file-line-by-line-2.pl6 | 4 + .../Perl/read-a-file-line-by-line-1.pl | 6 + .../Perl/read-a-file-line-by-line-2.pl | 6 + .../Perl/read-a-file-line-by-line-3.pl | 4 + .../PicoLisp/read-a-file-line-by-line.l | 3 + .../read-a-file-line-by-line.purebasic | 9 + .../Python/read-a-file-line-by-line-1.py | 3 + .../Python/read-a-file-line-by-line-2.py | 3 + .../R/read-a-file-line-by-line.r | 4 + .../REXX/read-a-file-line-by-line.rexx | 17 + .../Racket/read-a-file-line-by-line.rkt | 7 + .../Ruby/read-a-file-line-by-line-1.rb | 4 + .../Ruby/read-a-file-line-by-line-2.rb | 2 + .../Ruby/read-a-file-line-by-line-3.rb | 4 + .../Ruby/read-a-file-line-by-line-4.rb | 4 + .../Run-BASIC/read-a-file-line-by-line.run | 6 + .../SNOBOL4/read-a-file-line-by-line.sno | 3 + .../Scala/read-a-file-line-by-line.scala | 2 + .../Scheme/read-a-file-line-by-line.ss | 7 + .../Sed/read-a-file-line-by-line-1.sed | 2 + .../Sed/read-a-file-line-by-line-2.sed | 1 + .../Seed7/read-a-file-line-by-line.seed7 | 13 + .../Smalltalk/read-a-file-line-by-line-1.st | 1 + .../Smalltalk/read-a-file-line-by-line-2.st | 6 + .../Smalltalk/read-a-file-line-by-line-3.st | 1 + .../read-a-file-line-by-line-1.tuscript | 11 + .../read-a-file-line-by-line-2.tuscript | 3 + .../Tcl/read-a-file-line-by-line.tcl | 6 + .../read-a-file-line-by-line.torquescript | 22 + .../UNIX-Shell/read-a-file-line-by-line-1.sh | 7 + .../UNIX-Shell/read-a-file-line-by-line-2.sh | 7 + .../UNIX-Shell/read-a-file-line-by-line-3.sh | 10 + .../Vala/read-a-file-line-by-line.vala | 9 + .../read-a-file-line-by-line.vedit | 15 + .../read-a-file-line-by-line.visual | 17 + .../Visual-Basic/read-a-file-line-by-line.vb | 133 +++++ .../0DESCRIPTION | 2 + .../AWK/read-a-specific-line-from-a-file.awk | 4 + .../Ada/read-a-specific-line-from-a-file.ada | 54 ++ .../read-a-specific-line-from-a-file.aime | 30 + .../read-a-specific-line-from-a-file.ahk | 3 + .../read-a-specific-line-from-a-file.bbc | 13 + .../read-a-specific-line-from-a-file.cs | 44 ++ .../C/read-a-specific-line-from-a-file.c | 66 +++ .../read-a-specific-line-from-a-file.lisp | 11 + .../D/read-a-specific-line-from-a-file.d | 22 + .../Go/read-a-specific-line-from-a-file.go | 69 +++ .../read-a-specific-line-from-a-file.groovy | 7 + .../read-a-specific-line-from-a-file.hs | 6 + .../read-a-specific-line-from-a-file.icon | 10 + .../J/read-a-specific-line-from-a-file-1.j | 3 + .../J/read-a-specific-line-from-a-file-2.j | 1 + .../J/read-a-specific-line-from-a-file-3.j | 2 + .../J/read-a-specific-line-from-a-file-4.j | 2 + .../read-a-specific-line-from-a-file.java | 33 ++ .../read-a-specific-line-from-a-file.liberty | 11 + .../MATLAB/read-a-specific-line-from-a-file.m | 18 + .../read-a-specific-line-from-a-file.math | 1 + .../read-a-specific-line-from-a-file.netrexx | 52 ++ .../read-a-specific-line-from-a-file.ocaml | 21 + .../PL-I/read-a-specific-line-from-a-file.pli | 12 + .../read-a-specific-line-from-a-file.pascal | 38 ++ .../read-a-specific-line-from-a-file.pl6 | 1 + .../Perl/read-a-specific-line-from-a-file.pl | 4 + .../read-a-specific-line-from-a-file.l | 3 + ...read-a-specific-line-from-a-file.purebasic | 32 ++ .../read-a-specific-line-from-a-file.py | 6 + .../R/read-a-specific-line-from-a-file.r | 4 + .../read-a-specific-line-from-a-file.rexx | 26 + .../Ruby/read-a-specific-line-from-a-file.rb | 15 + .../read-a-specific-line-from-a-file.run | 10 + .../read-a-specific-line-from-a-file-1.scala | 2 + .../read-a-specific-line-from-a-file-2.scala | 13 + .../read-a-specific-line-from-a-file-3.scala | 6 + .../read-a-specific-line-from-a-file.seed7 | 32 ++ .../read-a-specific-line-from-a-file.tuscript | 17 + .../read-a-specific-line-from-a-file-1.txr | 2 + .../read-a-specific-line-from-a-file-2.txr | 4 + .../Tcl/read-a-specific-line-from-a-file.tcl | 13 + .../read-a-specific-line-from-a-file.vedit | 11 + .../read-a-specific-line-from-a-file.xpl0 | 26 + Task/Read-entire-file/0DESCRIPTION | 5 + Task/Read-entire-file/1META.yaml | 2 + .../ALGOL-68/read-entire-file-1.alg | 7 + .../ALGOL-68/read-entire-file-2.alg | 2 + .../Read-entire-file/AWK/read-entire-file.awk | 13 + .../Ada/read-entire-file-1.ada | 23 + .../Ada/read-entire-file-2.ada | 35 ++ .../AutoHotkey/read-entire-file.ahk | 1 + .../BASIC/read-entire-file.basic | 5 + .../BBC-BASIC/read-entire-file-1.bbc | 6 + .../BBC-BASIC/read-entire-file-2.bbc | 4 + .../Brainf---/read-entire-file.bf | 4 + .../Brat/read-entire-file.brat | 3 + .../Read-entire-file/C++/read-entire-file.cpp | 18 + .../C-sharp/read-entire-file.cs | 9 + Task/Read-entire-file/C/read-entire-file-1.c | 28 + Task/Read-entire-file/C/read-entire-file-2.c | 29 + .../CMake/read-entire-file-1.cmake | 1 + .../CMake/read-entire-file-2.cmake | 1 + .../Clojure/read-entire-file.clj | 2 + .../Common-Lisp/read-entire-file.lisp | 5 + Task/Read-entire-file/D/read-entire-file.d | 9 + .../Delphi/read-entire-file-1.delphi | 22 + .../Delphi/read-entire-file-2.delphi | 14 + Task/Read-entire-file/E/read-entire-file.e | 1 + .../Erlang/read-entire-file.erl | 1 + .../Euphoria/read-entire-file.euphoria | 16 + .../Factor/read-entire-file.factor | 7 + .../Fantom/read-entire-file.fantom | 8 + .../Forth/read-entire-file.fth | 1 + .../Frink/read-entire-file.frink | 2 + .../Read-entire-file/GAP/read-entire-file.gap | 3 + .../GUISS/read-entire-file.guiss | 1 + .../Read-entire-file/Go/read-entire-file-1.go | 4 + .../Read-entire-file/Go/read-entire-file-2.go | 25 + .../Groovy/read-entire-file.groovy | 1 + .../Haskell/read-entire-file-1.hs | 2 + .../Haskell/read-entire-file-2.hs | 4 + .../Icon/read-entire-file-1.icon | 1 + .../Icon/read-entire-file-2.icon | 3 + .../Inform-7/read-entire-file.inf | 7 + Task/Read-entire-file/J/read-entire-file-1.j | 1 + Task/Read-entire-file/J/read-entire-file-2.j | 2 + .../Java/read-entire-file-1.java | 21 + .../Java/read-entire-file-2.java | 20 + .../Java/read-entire-file-3.java | 1 + .../Java/read-entire-file-4.java | 15 + .../JavaScript/read-entire-file-1.js | 5 + .../JavaScript/read-entire-file-2.js | 14 + .../Julia/read-entire-file.julia | 4 + .../Lang5/read-entire-file.lang5 | 1 + .../Liberty-BASIC/read-entire-file.liberty | 7 + .../Read-entire-file/Lua/read-entire-file.lua | 21 + .../MATLAB/read-entire-file.m | 3 + .../Maple/read-entire-file-1.maple | 1 + .../Maple/read-entire-file-2.maple | 1 + .../Mathematica/read-entire-file.math | 1 + .../NetRexx/read-entire-file.netrexx | 43 ++ .../NewLISP/read-entire-file.newlisp | 1 + .../Nimrod/read-entire-file.nimrod | 1 + .../OCaml/read-entire-file-1.ocaml | 7 + .../OCaml/read-entire-file-2.ocaml | 2 + .../OCaml/read-entire-file-3.ocaml | 9 + .../OCaml/read-entire-file-4.ocaml | 7 + .../Objeck/read-entire-file.objeck | 1 + .../Objective-C/read-entire-file.m | 32 ++ Task/Read-entire-file/Oz/read-entire-file.oz | 6 + .../PARI-GP/read-entire-file.pari | 1 + .../Read-entire-file/PHP/read-entire-file.php | 1 + .../PL-I/read-entire-file.pli | 1 + .../Perl-6/read-entire-file.pl6 | 1 + .../Perl/read-entire-file-1.pl | 3 + .../Perl/read-entire-file-2.pl | 3 + .../Perl/read-entire-file-3.pl | 2 + .../Perl/read-entire-file-4.pl | 6 + .../Perl/read-entire-file-5.pl | 1 + .../PicoLisp/read-entire-file-1.l | 1 + .../PicoLisp/read-entire-file-2.l | 1 + .../PicoLisp/read-entire-file-3.l | 1 + .../Pike/read-entire-file.pike | 1 + .../PowerShell/read-entire-file-1.psh | 1 + .../PowerShell/read-entire-file-2.psh | 1 + .../PowerShell/read-entire-file-3.psh | 1 + .../PureBasic/read-entire-file-1.purebasic | 10 + .../PureBasic/read-entire-file-2.purebasic | 4 + .../PureBasic/read-entire-file-3.purebasic | 14 + .../Python/read-entire-file-1.py | 1 + .../Python/read-entire-file-2.py | 1 + Task/Read-entire-file/R/read-entire-file.r | 5 + .../REALbasic/read-entire-file.realbasic | 11 + .../REBOL/read-entire-file.rebol | 2 + .../REXX/read-entire-file.rexx | 9 + .../Racket/read-entire-file.rkt | 1 + .../Retro/read-entire-file.retro | 2 + .../Ruby/read-entire-file-1.rb | 5 + .../Ruby/read-entire-file-2.rb | 2 + .../Ruby/read-entire-file-3.rb | 2 + .../Ruby/read-entire-file-4.rb | 5 + .../SNOBOL4/read-entire-file.sno | 6 + .../Smalltalk/read-entire-file-1.st | 1 + .../Smalltalk/read-entire-file-2.st | 1 + .../TUSCRIPT/read-entire-file.tuscript | 3 + .../Read-entire-file/TXR/read-entire-file.txr | 3 + .../Tcl/read-entire-file-1.tcl | 3 + .../Tcl/read-entire-file-2.tcl | 3 + .../UNIX-Shell/read-entire-file-1.sh | 2 + .../UNIX-Shell/read-entire-file-2.sh | 2 + .../UNIX-Shell/read-entire-file-3.sh | 2 + .../UNIX-Shell/read-entire-file-4.sh | 2 + .../UNIX-Shell/read-entire-file-5.sh | 2 + .../VBScript/read-entire-file-1.vbscript | 3 + .../VBScript/read-entire-file-2.vbscript | 1 + .../Vala/read-entire-file.vala | 2 + .../read-entire-file-1.vedit | 1 + .../read-entire-file-2.vedit | 1 + .../Visual-Basic-.NET/read-entire-file.visual | 16 + .../XPL0/read-entire-file.xpl0 | 13 + .../Yorick/read-entire-file-1.yorick | 1 + .../Yorick/read-entire-file-2.yorick | 5 + .../Real-constants-and-functions/0DESCRIPTION | 12 + Task/Real-constants-and-functions/1META.yaml | 4 + .../ACL2/real-constants-and-functions.acl2 | 11 + .../ALGOL-68/real-constants-and-functions.alg | 13 + .../AWK/real-constants-and-functions-1.awk | 7 + .../AWK/real-constants-and-functions-2.awk | 27 + .../real-constants-and-functions-1.as | 9 + .../real-constants-and-functions-2.as | 6 + .../Ada/real-constants-and-functions.ada | 9 + .../real-constants-and-functions-1.ahk | 7 + .../real-constants-and-functions-2.ahk | 4 + .../real-constants-and-functions-3.ahk | 6 + .../BASIC/real-constants-and-functions.basic | 6 + .../real-constants-and-functions.bbc | 13 + .../C++/real-constants-and-functions.cpp | 28 + .../C-sharp/real-constants-and-functions.cs | 16 + .../C/real-constants-and-functions.c | 12 + .../real-constants-and-functions-1.clj | 9 + .../real-constants-and-functions-2.clj | 6 + .../real-constants-and-functions-3.clj | 8 + .../real-constants-and-functions.lisp | 10 + .../D/real-constants-and-functions.d | 12 + .../real-constants-and-functions.delphi | 12 + .../E/real-constants-and-functions.e | 26 + .../real-constants-and-functions.factor | 11 + .../real-constants-and-functions.fantom | 11 + .../Forth/real-constants-and-functions.fth | 9 + .../Fortran/real-constants-and-functions.f | 10 + .../Go/real-constants-and-functions.go | 18 + .../real-constants-and-functions-1.groovy | 1 + .../real-constants-and-functions-2.groovy | 1 + .../real-constants-and-functions-3.groovy | 1 + .../Haskell/real-constants-and-functions.hs | 11 + .../real-constants-and-functions-1.hicest | 11 + .../real-constants-and-functions-2.hicest | 15 + .../J/real-constants-and-functions.j | 14 + .../Java/real-constants-and-functions.java | 9 + .../real-constants-and-functions.js | 9 + .../real-constants-and-functions.liberty | 32 ++ .../Logo/real-constants-and-functions.logo | 7 + .../Lua/real-constants-and-functions.lua | 10 + .../real-constants-and-functions.maxscript | 9 + .../Maple/real-constants-and-functions.maple | 2 + .../real-constants-and-functions-1.math | 10 + .../real-constants-and-functions-2.math | 16 + .../real-constants-and-functions.mercury | 12 + .../real-constants-and-functions.metafont | 15 + .../real-constants-and-functions.mod3 | 9 + .../real-constants-and-functions.netrexx | 49 ++ .../OCaml/real-constants-and-functions.ocaml | 9 + .../real-constants-and-functions.objeck | 9 + .../real-constants-and-functions.octave | 9 + .../Oz/real-constants-and-functions.oz | 12 + .../PARI-GP/real-constants-and-functions.pari | 1 + .../PHP/real-constants-and-functions.php | 9 + .../PL-I/real-constants-and-functions.pli | 16 + .../Perl-6/real-constants-and-functions.pl6 | 9 + .../Perl/real-constants-and-functions.pl | 11 + .../PicoLisp/real-constants-and-functions.l | 16 + .../Pop11/real-constants-and-functions.pop11 | 6 + .../real-constants-and-functions.psh | 9 + .../real-constants-and-functions.purebasic | 8 + .../Python/real-constants-and-functions.py | 16 + .../R/real-constants-and-functions.r | 11 + .../REXX/real-constants-and-functions-1.rexx | 3 + .../REXX/real-constants-and-functions-2.rexx | 1 + .../REXX/real-constants-and-functions-3.rexx | 1 + .../REXX/real-constants-and-functions-4.rexx | 63 ++ .../REXX/real-constants-and-functions-5.rexx | 16 + .../REXX/real-constants-and-functions-6.rexx | 27 + .../RLaB/real-constants-and-functions-1.rlab | 5 + .../RLaB/real-constants-and-functions-2.rlab | 24 + .../RLaB/real-constants-and-functions-3.rlab | 17 + .../Racket/real-constants-and-functions.rkt | 9 + .../Ruby/real-constants-and-functions.rb | 10 + .../real-constants-and-functions.run | 9 + .../Scheme/real-constants-and-functions.ss | 7 + .../Slate/real-constants-and-functions.slate | 11 + .../Smalltalk/real-constants-and-functions.st | 10 + .../real-constants-and-functions.ml | 10 + .../Tcl/real-constants-and-functions-1.tcl | 9 + .../Tcl/real-constants-and-functions-2.tcl | 3 + .../XPL0/real-constants-and-functions.xpl0 | 26 + Task/Record-sound/0DESCRIPTION | 3 + Task/Record-sound/BBC-BASIC/record-sound.bbc | 36 ++ Task/Record-sound/C/record-sound.c | 30 + Task/Record-sound/GUISS/record-sound.guiss | 1 + .../Liberty-BASIC/record-sound-1.liberty | 1 + .../Liberty-BASIC/record-sound-2.liberty | 34 ++ .../Mathematica/record-sound.math | 1 + Task/Record-sound/OCaml/record-sound.ocaml | 21 + Task/Record-sound/PicoLisp/record-sound.l | 4 + Task/Record-sound/Python/record-sound.py | 17 + Task/Record-sound/Tcl/record-sound.tcl | 19 + Task/Reduced-row-echelon-form/0DESCRIPTION | 39 ++ Task/Reduced-row-echelon-form/1META.yaml | 2 + .../ALGOL-68/reduced-row-echelon-form.alg | 54 ++ .../ActionScript/reduced-row-echelon-form.as | 37 ++ .../Ada/reduced-row-echelon-form-1.ada | 11 + .../Ada/reduced-row-echelon-form-2.ada | 71 +++ .../Ada/reduced-row-echelon-form-3.ada | 28 + .../AutoIt/reduced-row-echelon-form.autoit | 56 ++ .../BBC-BASIC/reduced-row-echelon-form.bbc | 42 ++ .../C++/reduced-row-echelon-form.cpp | 186 ++++++ .../C/reduced-row-echelon-form.c | 156 +++++ .../Common-Lisp/reduced-row-echelon-form.lisp | 44 ++ .../D/reduced-row-echelon-form.d | 40 ++ .../reduced-row-echelon-form.euphoria | 39 ++ .../Fortran/reduced-row-echelon-form-1.f | 39 ++ .../Fortran/reduced-row-echelon-form-2.f | 23 + .../Go/reduced-row-echelon-form-1.go | 59 ++ .../Go/reduced-row-echelon-form-2.go | 83 +++ .../Groovy/reduced-row-echelon-form-1.groovy | 32 ++ .../Groovy/reduced-row-echelon-form-2.groovy | 46 ++ .../Haskell/reduced-row-echelon-form.hs | 32 ++ .../J/reduced-row-echelon-form-1.j | 10 + .../J/reduced-row-echelon-form-2.j | 16 + .../Java/reduced-row-echelon-form.java | 260 +++++++++ .../JavaScript/reduced-row-echelon-form.js | 54 ++ .../Lua/reduced-row-echelon-form.lua | 46 ++ .../MATLAB/reduced-row-echelon-form.m | 1 + .../reduced-row-echelon-form-1.math | 1 + .../reduced-row-echelon-form-2.math | 1 + .../Maxima/reduced-row-echelon-form.maxima | 10 + .../OCaml/reduced-row-echelon-form-1.ocaml | 51 ++ .../OCaml/reduced-row-echelon-form-2.ocaml | 28 + .../Objeck/reduced-row-echelon-form.objeck | 68 +++ .../Octave/reduced-row-echelon-form.octave | 3 + .../PARI-GP/reduced-row-echelon-form-1.pari | 5 + .../PARI-GP/reduced-row-echelon-form-2.pari | 1 + .../PHP/reduced-row-echelon-form.php | 47 ++ .../Perl-6/reduced-row-echelon-form-1.pl6 | 83 +++ .../Perl-6/reduced-row-echelon-form-2.pl6 | 32 ++ .../Perl-6/reduced-row-echelon-form-3.pl6 | 43 ++ .../Perl/reduced-row-echelon-form.pl | 25 + .../PicoLisp/reduced-row-echelon-form.l | 23 + .../Python/reduced-row-echelon-form.py | 35 ++ .../R/reduced-row-echelon-form.r | 33 ++ .../REXX/reduced-row-echelon-form.rexx | 66 +++ .../Racket/reduced-row-echelon-form.rkt | 9 + .../Ruby/reduced-row-echelon-form.rb | 76 +++ .../Sage/reduced-row-echelon-form.sage | 5 + .../Scheme/reduced-row-echelon-form-1.ss | 48 ++ .../Scheme/reduced-row-echelon-form-2.ss | 5 + .../Scheme/reduced-row-echelon-form-3.ss | 1 + .../Seed7/reduced-row-echelon-form.seed7 | 54 ++ .../reduced-row-echelon-form.ti-89 | 1 + .../Tcl/reduced-row-echelon-form.tcl | 49 ++ .../Ursala/reduced-row-echelon-form-1.ursala | 17 + .../Ursala/reduced-row-echelon-form-2.ursala | 3 + Task/Regular-expressions/0DESCRIPTION | 3 + Task/Regular-expressions/1META.yaml | 2 + .../ALGOL-68/regular-expressions-1.alg | 13 + .../ALGOL-68/regular-expressions-2.alg | 12 + .../AWK/regular-expressions-1.awk | 4 + .../AWK/regular-expressions-2.awk | 4 + .../AWK/regular-expressions-3.awk | 6 + .../AWK/regular-expressions-4.awk | 3 + .../Ada/regular-expressions.ada | 43 ++ .../regular-expressions.applescript | 11 + .../Argile/regular-expressions.argile | 22 + .../AutoHotkey/regular-expressions.ahk | 2 + .../BBC-BASIC/regular-expressions.bbc | 40 ++ .../Bracmat/regular-expressions.bracmat | 1 + .../C++/regular-expressions.cpp | 39 ++ .../C-sharp/regular-expressions.cs | 15 + .../C/regular-expressions.c | 43 ++ .../Clojure/regular-expressions.clj | 10 + .../Common-Lisp/regular-expressions-1.lisp | 5 + .../Common-Lisp/regular-expressions-2.lisp | 3 + .../Common-Lisp/regular-expressions-3.lisp | 5 + .../Common-Lisp/regular-expressions-4.lisp | 2 + .../Common-Lisp/regular-expressions-5.lisp | 6 + .../D/regular-expressions.d | 12 + .../Erlang/regular-expressions.erl | 11 + .../Forth/regular-expressions.fth | 19 + .../Frink/regular-expressions-1.frink | 7 + .../Frink/regular-expressions-2.frink | 1 + .../Go/regular-expressions.go | 16 + .../Groovy/regular-expressions-1.groovy | 54 ++ .../Groovy/regular-expressions-2.groovy | 1 + .../Groovy/regular-expressions-3.groovy | 11 + .../Haskell/regular-expressions-1.hs | 7 + .../Haskell/regular-expressions-2.hs | 5 + .../HicEst/regular-expressions.hicest | 7 + .../Icon/regular-expressions.icon | 12 + .../Inform-7/regular-expressions.inf | 4 + .../J/regular-expressions-1.j | 2 + .../J/regular-expressions-2.j | 2 + .../J/regular-expressions-3.j | 2 + .../J/regular-expressions-4.j | 1 + .../Java/regular-expressions-1.java | 4 + .../Java/regular-expressions-2.java | 6 + .../Java/regular-expressions-3.java | 3 + .../JavaScript/regular-expressions-1.js | 15 + .../JavaScript/regular-expressions-2.js | 5 + .../Julia/regular-expressions-1.julia | 5 + .../Julia/regular-expressions-2.julia | 41 ++ .../Lua/regular-expressions.lua | 5 + .../M4/regular-expressions.m4 | 2 + .../regular-expressions.mirc | 13 + .../MUMPS/regular-expressions.mumps | 13 + .../Mathematica/regular-expressions.math | 2 + .../NetRexx/regular-expressions.netrexx | 37 ++ .../OCaml/regular-expressions-1.ocaml | 7 + .../OCaml/regular-expressions-2.ocaml | 4 + .../OCaml/regular-expressions-3.ocaml | 10 + .../Objeck/regular-expressions.objeck | 17 + .../Objective-C/regular-expressions-1.m | 9 + .../Objective-C/regular-expressions-2.m | 4 + .../Objective-C/regular-expressions-3.m | 6 + .../Objective-C/regular-expressions-4.m | 10 + .../Objective-C/regular-expressions-5.m | 7 + .../Objective-C/regular-expressions-6.m | 9 + .../Oxygene/regular-expressions.oxy | 30 + .../Oz/regular-expressions.oz | 8 + .../PHP/regular-expressions.php | 9 + .../Pascal/regular-expressions.pascal | 25 + .../Perl-6/regular-expressions.pl6 | 12 + .../Perl/regular-expressions-1.pl | 8 + .../Perl/regular-expressions-2.pl | 3 + .../Perl/regular-expressions-3.pl | 3 + .../Perl/regular-expressions-4.pl | 4 + .../Perl/regular-expressions-5.pl | 7 + .../Perl/regular-expressions-6.pl | 4 + .../PicoLisp/regular-expressions-1.l | 5 + .../PicoLisp/regular-expressions-2.l | 6 + .../PowerShell/regular-expressions.psh | 2 + .../PureBasic/regular-expressions.purebasic | 9 + .../Python/regular-expressions.py | 9 + .../R/regular-expressions-1.r | 3 + .../R/regular-expressions-2.r | 1 + .../R/regular-expressions-3.r | 1 + .../R/regular-expressions-4.r | 1 + .../REBOL/regular-expressions.rebol | 42 ++ .../REXX/regular-expressions-1.rexx | 15 + .../REXX/regular-expressions-2.rexx | 10 + .../REXX/regular-expressions-3.rexx | 11 + .../REXX/regular-expressions-4.rexx | 14 + .../Racket/regular-expressions.rkt | 11 + .../Raven/regular-expressions-1.raven | 1 + .../Raven/regular-expressions-2.raven | 2 + .../Raven/regular-expressions-3.raven | 1 + .../Ruby/regular-expressions-1.rb | 3 + .../Ruby/regular-expressions-2.rb | 4 + .../Ruby/regular-expressions-3.rb | 1 + .../Run-BASIC/regular-expressions.run | 5 + .../SNOBOL4/regular-expressions-1.sno | 1 + .../SNOBOL4/regular-expressions-2.sno | 2 + .../SNOBOL4/regular-expressions-3.sno | 5 + .../Sather/regular-expressions.sa | 22 + .../Scala/regular-expressions-1.scala | 4 + .../Scala/regular-expressions-2.scala | 3 + .../Scala/regular-expressions-3.scala | 7 + .../Scala/regular-expressions-4.scala | 13 + .../Scala/regular-expressions-5.scala | 2 + .../Shiny/regular-expressions-1.shiny | 1 + .../Shiny/regular-expressions-2.shiny | 3 + .../Shiny/regular-expressions-3.shiny | 1 + .../Slate/regular-expressions.slate | 3 + .../Smalltalk/regular-expressions.st | 18 + .../Standard-ML/regular-expressions.ml | 14 + .../TXR/regular-expressions-1.txr | 6 + .../TXR/regular-expressions-2.txr | 5 + .../Tcl/regular-expressions-1.tcl | 8 + .../Tcl/regular-expressions-2.tcl | 4 + .../Tcl/regular-expressions-3.tcl | 2 + .../Toka/regular-expressions.toka | 19 + .../Vala/regular-expressions.vala | 13 + .../regular-expressions-1.vedit | 3 + .../regular-expressions-2.vedit | 3 + .../regular-expressions-3.vedit | 1 + Task/Remove-duplicate-elements/0DESCRIPTION | 6 + .../ACL2/remove-duplicate-elements.acl2 | 1 + .../AWK/remove-duplicate-elements.awk | 2 + .../Ada/remove-duplicate-elements-1.ada | 21 + .../Ada/remove-duplicate-elements-2.ada | 2 + .../Ada/remove-duplicate-elements-3.ada | 3 + .../remove-duplicate-elements.applescript | 9 + .../AutoHotkey/remove-duplicate-elements.ahk | 3 + .../BBC-BASIC/remove-duplicate-elements.bbc | 21 + .../Bracmat/remove-duplicate-elements.bracmat | 63 ++ .../Brat/remove-duplicate-elements.brat | 3 + .../C++/remove-duplicate-elements-1.cpp | 15 + .../C++/remove-duplicate-elements-2.cpp | 15 + .../C++/remove-duplicate-elements-3.cpp | 15 + .../C++/remove-duplicate-elements-4.cpp | 15 + .../C-sharp/remove-duplicate-elements-1.cs | 5 + .../C-sharp/remove-duplicate-elements-2.cs | 2 + .../C/remove-duplicate-elements-1.c | 33 ++ .../C/remove-duplicate-elements-2.c | 59 ++ .../C/remove-duplicate-elements-3.c | 29 + .../Clojure/remove-duplicate-elements.clj | 3 + .../remove-duplicate-elements-1.lisp | 2 + .../remove-duplicate-elements-2.lisp | 2 + .../D/remove-duplicate-elements-1.d | 7 + .../D/remove-duplicate-elements-2.d | 10 + .../Delphi/remove-duplicate-elements.delphi | 24 + .../E/remove-duplicate-elements.e | 1 + .../Erlang/remove-duplicate-elements.erl | 2 + .../remove-duplicate-elements.euphoria | 17 + .../Factor/remove-duplicate-elements.factor | 4 + .../Forth/remove-duplicate-elements-1.fth | 19 + .../Forth/remove-duplicate-elements-2.fth | 12 + .../Forth/remove-duplicate-elements-3.fth | 5 + .../Forth/remove-duplicate-elements-4.fth | 1 + .../Fortran/remove-duplicate-elements.f | 24 + .../GAP/remove-duplicate-elements.gap | 9 + .../Go/remove-duplicate-elements-1.go | 20 + .../Go/remove-duplicate-elements-2.go | 23 + .../Go/remove-duplicate-elements-3.go | 35 ++ .../Groovy/remove-duplicate-elements.groovy | 21 + .../Haskell/remove-duplicate-elements.hs | 2 + .../HicEst/remove-duplicate-elements.hicest | 9 + .../IDL/remove-duplicate-elements.idl | 1 + .../Icon/remove-duplicate-elements.icon | 15 + .../Inform-7/remove-duplicate-elements.inf | 5 + .../J/remove-duplicate-elements-1.j | 4 + .../J/remove-duplicate-elements-2.j | 10 + .../Java/remove-duplicate-elements.java | 7 + .../JavaScript/remove-duplicate-elements-1.js | 16 + .../JavaScript/remove-duplicate-elements-2.js | 11 + .../Julia/remove-duplicate-elements.julia | 2 + .../K/remove-duplicate-elements.k | 31 + .../Lang5/remove-duplicate-elements-1.lang5 | 8 + .../Lang5/remove-duplicate-elements-2.lang5 | 2 + .../remove-duplicate-elements.liberty | 18 + .../Logo/remove-duplicate-elements.logo | 1 + .../Lua/remove-duplicate-elements.lua | 10 + .../MATLAB/remove-duplicate-elements.m | 5 + .../remove-duplicate-elements.maxscript | 6 + .../MUMPS/remove-duplicate-elements.mumps | 11 + .../Maple/remove-duplicate-elements-1.maple | 5 + .../Maple/remove-duplicate-elements-2.maple | 2 + .../Maple/remove-duplicate-elements-3.maple | 3 + .../remove-duplicate-elements-1.math | 1 + .../remove-duplicate-elements-2.math | 1 + .../remove-duplicate-elements-3.math | 2 + .../remove-duplicate-elements-4.math | 1 + .../Maxima/remove-duplicate-elements.maxima | 2 + .../Nemerle/remove-duplicate-elements.nemerle | 12 + .../NetRexx/remove-duplicate-elements.netrexx | 47 ++ .../NewLISP/remove-duplicate-elements.newlisp | 1 + .../Nial/remove-duplicate-elements-1.nial | 5 + .../Nial/remove-duplicate-elements-2.nial | 2 + .../OCaml/remove-duplicate-elements.ocaml | 7 + .../Objeck/remove-duplicate-elements.objeck | 21 + .../Objective-C/remove-duplicate-elements.m | 3 + .../Octave/remove-duplicate-elements.octave | 2 + .../Oz/remove-duplicate-elements.oz | 12 + .../PARI-GP/remove-duplicate-elements.pari | 3 + .../PHP/remove-duplicate-elements.php | 2 + .../PL-I/remove-duplicate-elements.pli | 18 + .../Pascal/remove-duplicate-elements.pascal | 33 ++ .../Perl-6/remove-duplicate-elements-1.pl6 | 7 + .../Perl-6/remove-duplicate-elements-2.pl6 | 1 + .../Perl/remove-duplicate-elements-1.pl | 3 + .../Perl/remove-duplicate-elements-2.pl | 2 + .../Perl/remove-duplicate-elements-3.pl | 2 + .../Perl/remove-duplicate-elements-4.pl | 3 + .../PicoLisp/remove-duplicate-elements.l | 1 + .../Pop11/remove-duplicate-elements.pop11 | 13 + .../PostScript/remove-duplicate-elements.ps | 1 + .../remove-duplicate-elements-1.psh | 1 + .../remove-duplicate-elements-2.psh | 5 + .../remove-duplicate-elements-3.psh | 1 + .../remove-duplicate-elements-4.psh | 1 + .../Prolog/remove-duplicate-elements-1.pro | 1 + .../Prolog/remove-duplicate-elements-2.pro | 2 + .../Prolog/remove-duplicate-elements-3.pro | 6 + .../Prolog/remove-duplicate-elements-4.pro | 2 + .../remove-duplicate-elements.purebasic | 11 + .../Python/remove-duplicate-elements-1.py | 2 + .../Python/remove-duplicate-elements-2.py | 3 + .../Python/remove-duplicate-elements-3.py | 5 + .../Qi/remove-duplicate-elements.qi | 6 + .../REBOL/remove-duplicate-elements.rebol | 1 + .../REXX/remove-duplicate-elements-1.rexx | 12 + .../REXX/remove-duplicate-elements-2.rexx | 13 + .../REXX/remove-duplicate-elements-3.rexx | 28 + .../Raven/remove-duplicate-elements.raven | 12 + .../Ruby/remove-duplicate-elements.rb | 3 + .../SETL/remove-duplicate-elements-1.setl | 2 + .../SETL/remove-duplicate-elements-2.setl | 3 + .../SETL/remove-duplicate-elements-3.setl | 4 + .../Scala/remove-duplicate-elements.scala | 7 + .../Scheme/remove-duplicate-elements-1.ss | 9 + .../Scheme/remove-duplicate-elements-2.ss | 1 + .../Scheme/remove-duplicate-elements-3.ss | 6 + .../Scheme/remove-duplicate-elements-4.ss | 1 + .../Seed7/remove-duplicate-elements.seed7 | 13 + .../Slate/remove-duplicate-elements.slate | 3 + .../Smalltalk/remove-duplicate-elements-1.st | 4 + .../Smalltalk/remove-duplicate-elements-2.st | 3 + .../remove-duplicate-elements-1.tuscript | 6 + .../remove-duplicate-elements-2.tuscript | 11 + .../Tcl/remove-duplicate-elements.tcl | 1 + .../remove-duplicate-elements-1.unixpipes | 15 + .../remove-duplicate-elements-2.unixpipes | 7 + .../Ursala/remove-duplicate-elements.ursala | 3 + .../remove-duplicate-elements.vedit | 2 + .../XPL0/remove-duplicate-elements.xpl0 | 24 + Task/Remove-lines-from-a-file/0DESCRIPTION | 3 + Task/Remove-lines-from-a-file/1META.yaml | 3 + .../AWK/remove-lines-from-a-file.awk | 43 ++ .../Ada/remove-lines-from-a-file.ada | 41 ++ .../AutoHotkey/remove-lines-from-a-file.ahk | 11 + .../C++/remove-lines-from-a-file.cpp | 58 ++ .../C/remove-lines-from-a-file.c | 61 ++ .../Common-Lisp/remove-lines-from-a-file.lisp | 25 + .../D/remove-lines-from-a-file.d | 25 + .../Go/remove-lines-from-a-file.go | 72 +++ .../Haskell/remove-lines-from-a-file.hs | 8 + .../Icon/remove-lines-from-a-file.icon | 18 + .../J/remove-lines-from-a-file-1.j | 6 + .../J/remove-lines-from-a-file-2.j | 10 + .../J/remove-lines-from-a-file-3.j | 1 + .../J/remove-lines-from-a-file-4.j | 7 + .../remove-lines-from-a-file.liberty | 20 + .../Lua/remove-lines-from-a-file.lua | 26 + .../OCaml/remove-lines-from-a-file.ocaml | 33 ++ .../Perl-6/remove-lines-from-a-file.pl6 | 6 + .../Perl/remove-lines-from-a-file-1.pl | 2 + .../Perl/remove-lines-from-a-file-2.pl | 27 + .../PicoLisp/remove-lines-from-a-file.l | 7 + .../remove-lines-from-a-file.powerbasic | 37 ++ .../Python/remove-lines-from-a-file.py | 13 + .../REXX/remove-lines-from-a-file.rexx | 24 + .../Ruby/remove-lines-from-a-file-1.rb | 18 + .../Ruby/remove-lines-from-a-file-2.rb | 19 + .../Run-BASIC/remove-lines-from-a-file.run | 14 + .../Seed7/remove-lines-from-a-file.seed7 | 31 + .../remove-lines-from-a-file.tuscript | 26 + .../Tcl/remove-lines-from-a-file.tcl | 13 + .../UNIX-Shell/remove-lines-from-a-file-1.sh | 15 + .../UNIX-Shell/remove-lines-from-a-file-2.sh | 1 + Task/Rename-a-file/0DESCRIPTION | 1 + Task/Rename-a-file/1META.yaml | 2 + Task/Rename-a-file/ALGOL-68/rename-a-file.alg | 22 + Task/Rename-a-file/AWK/rename-a-file.awk | 4 + Task/Rename-a-file/Ada/rename-a-file.ada | 6 + .../AutoHotkey/rename-a-file.ahk | 1 + .../Rename-a-file/BASIC/rename-a-file-1.basic | 4 + .../Rename-a-file/BASIC/rename-a-file-2.basic | 1 + .../Rename-a-file/BASIC/rename-a-file-3.basic | 1 + .../Rename-a-file/BASIC/rename-a-file-4.basic | 5 + .../BBC-BASIC/rename-a-file-1.bbc | 4 + .../BBC-BASIC/rename-a-file-2.bbc | 4 + .../Batch-File/rename-a-file.bat | 4 + .../Bracmat/rename-a-file.bracmat | 4 + Task/Rename-a-file/C++/rename-a-file-1.cpp | 10 + Task/Rename-a-file/C++/rename-a-file-2.cpp | 18 + Task/Rename-a-file/C-sharp/rename-a-file.cs | 12 + Task/Rename-a-file/C/rename-a-file.c | 10 + Task/Rename-a-file/Clojure/rename-a-file.clj | 11 + .../Common-Lisp/rename-a-file.lisp | 4 + Task/Rename-a-file/D/rename-a-file.d | 4 + Task/Rename-a-file/DCL/rename-a-file.dcl | 4 + .../Rename-a-file/Delphi/rename-a-file.delphi | 14 + Task/Rename-a-file/E/rename-a-file.e | 4 + Task/Rename-a-file/Erlang/rename-a-file.erl | 1 + .../Rename-a-file/Factor/rename-a-file.factor | 3 + .../Rename-a-file/Fantom/rename-a-file.fantom | 12 + Task/Rename-a-file/Forth/rename-a-file.fth | 2 + Task/Rename-a-file/Fortran/rename-a-file.f | 6 + Task/Rename-a-file/Go/rename-a-file.go | 9 + .../Groovy/rename-a-file-1.groovy | 5 + .../Groovy/rename-a-file-2.groovy | 5 + Task/Rename-a-file/Haskell/rename-a-file.hs | 8 + .../Rename-a-file/HicEst/rename-a-file.hicest | 7 + Task/Rename-a-file/Icon/rename-a-file.icon | 4 + Task/Rename-a-file/Io/rename-a-file.io | 15 + Task/Rename-a-file/J/rename-a-file-1.j | 9 + Task/Rename-a-file/J/rename-a-file-2.j | 4 + Task/Rename-a-file/Java/rename-a-file.java | 26 + .../Rename-a-file/JavaScript/rename-a-file.js | 5 + Task/Rename-a-file/Joy/rename-a-file.joy | 4 + .../Liberty-BASIC/rename-a-file.liberty | 10 + .../Locomotive-Basic/rename-a-file.locomotive | 1 + Task/Rename-a-file/Lua/rename-a-file.lua | 4 + Task/Rename-a-file/MATLAB/rename-a-file.m | 1 + .../MAXScript/rename-a-file.maxscript | 4 + Task/Rename-a-file/MUMPS/rename-a-file.mumps | 6 + Task/Rename-a-file/Maple/rename-a-file.maple | 6 + .../Mathematica/rename-a-file.math | 6 + .../NewLISP/rename-a-file.newlisp | 4 + Task/Rename-a-file/OCaml/rename-a-file.ocaml | 4 + .../Rename-a-file/Objeck/rename-a-file.objeck | 11 + .../Rename-a-file/Objective-C/rename-a-file.m | 9 + .../Rename-a-file/Octave/rename-a-file.octave | 3 + Task/Rename-a-file/PARI-GP/rename-a-file.pari | 4 + Task/Rename-a-file/PHP/rename-a-file.php | 6 + .../Rename-a-file/Pascal/rename-a-file.pascal | 22 + Task/Rename-a-file/Perl-6/rename-a-file.pl6 | 4 + Task/Rename-a-file/Perl/rename-a-file.pl | 8 + Task/Rename-a-file/PicoLisp/rename-a-file.l | 4 + Task/Rename-a-file/Pike/rename-a-file.pike | 6 + Task/Rename-a-file/Pop11/rename-a-file.pop11 | 4 + .../PowerShell/rename-a-file.psh | 4 + Task/Rename-a-file/ProDOS/rename-a-file.dos | 2 + .../PureBasic/rename-a-file.purebasic | 5 + Task/Rename-a-file/Python/rename-a-file-1.py | 7 + Task/Rename-a-file/Python/rename-a-file-2.py | 7 + Task/Rename-a-file/R/rename-a-file.r | 4 + .../REALbasic/rename-a-file.realbasic | 29 + Task/Rename-a-file/REBOL/rename-a-file.rebol | 19 + Task/Rename-a-file/REXX/rename-a-file-1.rexx | 5 + Task/Rename-a-file/REXX/rename-a-file-2.rexx | 5 + Task/Rename-a-file/Racket/rename-a-file.rkt | 12 + Task/Rename-a-file/Ruby/rename-a-file-1.rb | 4 + Task/Rename-a-file/Ruby/rename-a-file-2.rb | 3 + .../Rename-a-file/Run-BASIC/rename-a-file.run | 4 + Task/Rename-a-file/Scala/rename-a-file.scala | 9 + Task/Rename-a-file/Scheme/rename-a-file.ss | 4 + Task/Rename-a-file/Seed7/rename-a-file.seed7 | 10 + Task/Rename-a-file/Slate/rename-a-file.slate | 4 + .../Smalltalk/rename-a-file-1.st | 6 + .../Smalltalk/rename-a-file-2.st | 4 + .../Standard-ML/rename-a-file.ml | 4 + .../TUSCRIPT/rename-a-file.tuscript | 5 + Task/Rename-a-file/Tcl/rename-a-file-1.tcl | 5 + Task/Rename-a-file/Tcl/rename-a-file-2.tcl | 5 + Task/Rename-a-file/Toka/rename-a-file.toka | 6 + .../TorqueScript/rename-a-file.torquescript | 8 + .../Rename-a-file/UNIX-Shell/rename-a-file.sh | 4 + .../Vedit-macro-language/rename-a-file.vedit | 7 + .../Visual-Basic-.NET/rename-a-file.visual | 13 + .../Rename-a-file/Yorick/rename-a-file.yorick | 4 + Task/Rendezvous/0DESCRIPTION | 29 + Task/Rendezvous/1META.yaml | 6 + Task/Rendezvous/Ada/rendezvous-1.ada | 6 + Task/Rendezvous/Ada/rendezvous-2.ada | 8 + Task/Rendezvous/Ada/rendezvous-3.ada | 77 +++ Task/Rendezvous/AutoHotkey/rendezvous.ahk | 77 +++ Task/Rendezvous/C/rendezvous.c | 72 +++ Task/Rendezvous/Go/rendezvous.go | 145 +++++ Task/Rendezvous/Oz/rendezvous-1.oz | 28 + Task/Rendezvous/Oz/rendezvous-2.oz | 21 + Task/Rendezvous/Oz/rendezvous-3.oz | 30 + Task/Rendezvous/PicoLisp/rendezvous-1.l | 6 + Task/Rendezvous/PicoLisp/rendezvous-2.l | 56 ++ Task/Rendezvous/Tcl/rendezvous.tcl | 157 +++++ Task/Repeat-a-string/0DESCRIPTION | 3 + Task/Repeat-a-string/1META.yaml | 2 + .../4DOS-Batch/repeat-a-string.4dos | 10 + .../ALGOL-68/repeat-a-string.alg | 1 + Task/Repeat-a-string/AWK/repeat-a-string.awk | 10 + .../ActionScript/repeat-a-string-1.as | 7 + .../ActionScript/repeat-a-string-2.as | 7 + .../ActionScript/repeat-a-string-3.as | 2 + Task/Repeat-a-string/Ada/repeat-a-string.ada | 7 + .../AppleScript/repeat-a-string.applescript | 5 + .../AutoHotkey/repeat-a-string.ahk | 8 + .../BBC-BASIC/repeat-a-string.bbc | 1 + .../Babel/repeat-a-string-1.pb | 3 + .../Babel/repeat-a-string-2.pb | 1 + .../Batch-File/repeat-a-string-1.bat | 8 + .../Batch-File/repeat-a-string-2.bat | 10 + .../Batch-File/repeat-a-string-3.bat | 13 + .../Bracmat/repeat-a-string.bracmat | 8 + .../Brainf---/repeat-a-string.bf | 9 + .../Repeat-a-string/Brat/repeat-a-string.brat | 1 + .../Burlesque/repeat-a-string.blq | 4 + .../Repeat-a-string/C++/repeat-a-string-1.cpp | 15 + .../Repeat-a-string/C++/repeat-a-string-2.cpp | 7 + .../C-sharp/repeat-a-string-1.cs | 1 + .../C-sharp/repeat-a-string-2.cs | 1 + .../C-sharp/repeat-a-string-3.cs | 1 + .../C-sharp/repeat-a-string-4.cs | 1 + .../C-sharp/repeat-a-string-5.cs | 1 + .../C-sharp/repeat-a-string-6.cs | 1 + Task/Repeat-a-string/C/repeat-a-string-1.c | 22 + Task/Repeat-a-string/C/repeat-a-string-2.c | 13 + Task/Repeat-a-string/C/repeat-a-string-3.c | 17 + .../Clojure/repeat-a-string.clj | 1 + .../Common-Lisp/repeat-a-string-1.lisp | 5 + .../Common-Lisp/repeat-a-string-2.lisp | 1 + Task/Repeat-a-string/D/repeat-a-string-1.d | 5 + Task/Repeat-a-string/D/repeat-a-string-2.d | 8 + .../DWScript/repeat-a-string-1.dwscript | 1 + .../DWScript/repeat-a-string-2.dwscript | 1 + .../Delphi/repeat-a-string-1.delphi | 9 + .../Delphi/repeat-a-string-2.delphi | 1 + .../Delphi/repeat-a-string-3.delphi | 1 + Task/Repeat-a-string/E/repeat-a-string.e | 1 + .../Erlang/repeat-a-string.erl | 2 + .../Euphoria/repeat-a-string-1.euphoria | 16 + .../Euphoria/repeat-a-string-2.euphoria | 4 + .../Factor/repeat-a-string.factor | 3 + .../Forth/repeat-a-string-1.fth | 6 + .../Forth/repeat-a-string-2.fth | 7 + .../Forth/repeat-a-string-3.fth | 2 + .../Repeat-a-string/Fortran/repeat-a-string.f | 5 + .../Frink/repeat-a-string.frink | 1 + Task/Repeat-a-string/GAP/repeat-a-string.gap | 2 + Task/Repeat-a-string/Go/repeat-a-string-1.go | 1 + Task/Repeat-a-string/Go/repeat-a-string-2.go | 1 + .../Groovy/repeat-a-string.groovy | 1 + .../Haskell/repeat-a-string-1.hs | 1 + .../Haskell/repeat-a-string-2.hs | 1 + .../Haskell/repeat-a-string-3.hs | 1 + .../Haskell/repeat-a-string-4.hs | 1 + .../HicEst/repeat-a-string.hicest | 3 + .../Icon/repeat-a-string-1.icon | 3 + .../Icon/repeat-a-string-2.icon | 4 + .../Inform-7/repeat-a-string.inf | 11 + Task/Repeat-a-string/J/repeat-a-string.j | 8 + .../Java/repeat-a-string-1.java | 9 + .../Java/repeat-a-string-2.java | 3 + .../JavaScript/repeat-a-string.js | 5 + .../Julia/repeat-a-string.julia | 2 + Task/Repeat-a-string/K/repeat-a-string.k | 5 + .../Liberty-BASIC/repeat-a-string.liberty | 12 + .../Logo/repeat-a-string-1.logo | 4 + .../Logo/repeat-a-string-2.logo | 1 + .../Logo/repeat-a-string-3.logo | 6 + .../Repeat-a-string/Lua/repeat-a-string-1.lua | 1 + .../Repeat-a-string/Lua/repeat-a-string-2.lua | 1 + Task/Repeat-a-string/MATLAB/repeat-a-string.m | 3 + .../MUMPS/repeat-a-string-1.mumps | 9 + .../MUMPS/repeat-a-string-2.mumps | 3 + .../Maple/repeat-a-string-1.maple | 7 + .../Maple/repeat-a-string-2.maple | 5 + .../Maple/repeat-a-string-3.maple | 3 + .../Mathematica/repeat-a-string.math | 8 + .../Maxima/repeat-a-string.maxima | 5 + .../Mercury/repeat-a-string.mercury | 26 + .../Mirah/repeat-a-string.mirah | 7 + .../NetRexx/repeat-a-string-1.netrexx | 3 + .../NetRexx/repeat-a-string-2.netrexx | 12 + .../NewLISP/repeat-a-string.newlisp | 1 + .../OCaml/repeat-a-string-1.ocaml | 8 + .../OCaml/repeat-a-string-2.ocaml | 2 + .../OCaml/repeat-a-string-3.ocaml | 3 + .../OCaml/repeat-a-string-4.ocaml | 3 + .../OCaml/repeat-a-string-5.ocaml | 1 + .../Objeck/repeat-a-string.objeck | 16 + .../Objective-C/repeat-a-string-1.m | 9 + .../Objective-C/repeat-a-string-2.m | 6 + .../repeat-a-string.openedge | 1 + .../OxygenBasic/repeat-a-string.oxy | 18 + Task/Repeat-a-string/Oz/repeat-a-string.oz | 10 + .../PARI-GP/repeat-a-string.pari | 3 + Task/Repeat-a-string/PHP/repeat-a-string.php | 1 + Task/Repeat-a-string/PL-I/repeat-a-string.pli | 5 + .../Perl-6/repeat-a-string.pl6 | 1 + Task/Repeat-a-string/Perl/repeat-a-string.pl | 1 + .../PicoLisp/repeat-a-string-1.l | 2 + .../PicoLisp/repeat-a-string-2.l | 2 + .../Repeat-a-string/Pike/repeat-a-string.pike | 1 + .../PostScript/repeat-a-string.ps | 19 + .../PowerBASIC/repeat-a-string.powerbasic | 1 + .../PowerShell/repeat-a-string.psh | 1 + .../Prolog/repeat-a-string.pro | 6 + .../Repeat-a-string/Pure/repeat-a-string.pure | 5 + .../PureBasic/repeat-a-string.purebasic | 10 + .../Python/repeat-a-string-1.py | 1 + .../Python/repeat-a-string-2.py | 1 + Task/Repeat-a-string/R/repeat-a-string.r | 1 + .../REALbasic/repeat-a-string.realbasic | 7 + .../REBOL/repeat-a-string.rebol | 1 + .../Repeat-a-string/REXX/repeat-a-string.rexx | 118 ++++ .../Racket/repeat-a-string-1.rkt | 4 + .../Racket/repeat-a-string-2.rkt | 7 + .../Racket/repeat-a-string-3.rkt | 1 + .../Retro/repeat-a-string.retro | 5 + .../Repeat-a-string/Ruby/repeat-a-string-1.rb | 1 + .../Repeat-a-string/Ruby/repeat-a-string-2.rb | 1 + .../Run-BASIC/repeat-a-string.run | 6 + .../SNOBOL4/repeat-a-string.sno | 2 + Task/Repeat-a-string/SQL/repeat-a-string.sql | 1 + .../Scala/repeat-a-string.scala | 1 + .../Scheme/repeat-a-string-1.ss | 2 + .../Scheme/repeat-a-string-2.ss | 3 + .../Scheme/repeat-a-string-3.ss | 1 + .../Seed7/repeat-a-string.seed7 | 6 + .../Smalltalk/repeat-a-string-1.st | 2 + .../Smalltalk/repeat-a-string-2.st | 1 + .../Smalltalk/repeat-a-string-3.st | 1 + .../Smalltalk/repeat-a-string-4.st | 3 + .../Smalltalk/repeat-a-string-5.st | 1 + .../Smalltalk/repeat-a-string-6.st | 1 + .../Standard-ML/repeat-a-string-1.ml | 3 + .../Standard-ML/repeat-a-string-2.ml | 2 + .../Standard-ML/repeat-a-string-3.ml | 3 + .../Suneido/repeat-a-string.suneido | 2 + .../TUSCRIPT/repeat-a-string.tuscript | 2 + Task/Repeat-a-string/Tcl/repeat-a-string.tcl | 1 + .../TorqueScript/repeat-a-string.torquescript | 9 + .../UNIX-Shell/repeat-a-string-1.sh | 1 + .../UNIX-Shell/repeat-a-string-2.sh | 2 + .../UNIX-Shell/repeat-a-string-3.sh | 2 + .../UNIX-Shell/repeat-a-string-4.sh | 5 + .../UNIX-Shell/repeat-a-string-5.sh | 2 + .../Ursala/repeat-a-string.ursala | 7 + Task/Repeat-a-string/VBA/repeat-a-string.vba | 11 + .../Vala/repeat-a-string-1.vala | 4 + .../Vala/repeat-a-string-2.vala | 1 + .../repeat-a-string.vedit | 1 + .../Visual-Basic-.NET/repeat-a-string.visual | 6 + .../Repeat-a-string/XPL0/repeat-a-string.xpl0 | 1 + .../Yorick/repeat-a-string.yorick | 1 + Task/Resistor-mesh/0DESCRIPTION | 5 + Task/Resistor-mesh/Ada/resistor-mesh.ada | 69 +++ .../Resistor-mesh/BBC-BASIC/resistor-mesh.bbc | 31 + Task/Resistor-mesh/C/resistor-mesh.c | 65 +++ Task/Resistor-mesh/D/resistor-mesh.d | 76 +++ .../Euler-Math-Toolbox/resistor-mesh-1.euler | 3 + .../Euler-Math-Toolbox/resistor-mesh-2.euler | 44 ++ .../Euler-Math-Toolbox/resistor-mesh-3.euler | 39 ++ Task/Resistor-mesh/J/resistor-mesh-1.j | 10 + Task/Resistor-mesh/J/resistor-mesh-2.j | 2 + Task/Resistor-mesh/J/resistor-mesh-3.j | 2 + .../Mathematica/resistor-mesh-1.math | 12 + .../Mathematica/resistor-mesh-2.math | 7 + .../Resistor-mesh/Maxima/resistor-mesh.maxima | 62 ++ Task/Resistor-mesh/Perl-6/resistor-mesh.pl6 | 58 ++ Task/Resistor-mesh/Perl/resistor-mesh.pl | 60 ++ Task/Resistor-mesh/Python/resistor-mesh.py | 64 +++ Task/Resistor-mesh/REXX/resistor-mesh.rexx | 40 ++ Task/Resistor-mesh/Tcl/resistor-mesh-1.tcl | 95 +++ Task/Resistor-mesh/Tcl/resistor-mesh-2.tcl | 6 + Task/Resistor-mesh/XPL0/resistor-mesh.xpl0 | 49 ++ .../0DESCRIPTION | 5 + .../1META.yaml | 2 + .../respond-to-an-unknown-method-call.brat | 7 + .../C++/respond-to-an-unknown-method-call.cpp | 17 + .../respond-to-an-unknown-method-call-1.lisp | 8 + .../respond-to-an-unknown-method-call-2.lisp | 1 + .../respond-to-an-unknown-method-call-3.lisp | 2 + .../D/respond-to-an-unknown-method-call.d | 25 + .../E/respond-to-an-unknown-method-call.e | 10 + .../respond-to-an-unknown-method-call.fancy | 20 + .../respond-to-an-unknown-method-call.fantom | 32 ++ .../Go/respond-to-an-unknown-method-call-1.go | 29 + .../Go/respond-to-an-unknown-method-call-2.go | 16 + .../Go/respond-to-an-unknown-method-call-3.go | 31 + .../J/respond-to-an-unknown-method-call-1.j | 7 + .../J/respond-to-an-unknown-method-call-2.j | 4 + .../respond-to-an-unknown-method-call.js | 18 + .../Lua/respond-to-an-unknown-method-call.lua | 4 + .../respond-to-an-unknown-method-call.m | 59 ++ .../Oz/respond-to-an-unknown-method-call.oz | 23 + .../PHP/respond-to-an-unknown-method-call.php | 23 + .../respond-to-an-unknown-method-call.pl6 | 10 + .../Perl/respond-to-an-unknown-method-call.pl | 30 + .../respond-to-an-unknown-method-call-1.l | 12 + .../respond-to-an-unknown-method-call-2.l | 6 + .../respond-to-an-unknown-method-call.pike | 12 + .../respond-to-an-unknown-method-call.py | 19 + .../Ruby/respond-to-an-unknown-method-call.rb | 22 + .../respond-to-an-unknown-method-call.scala | 20 + .../respond-to-an-unknown-method-call-1.slate | 24 + .../respond-to-an-unknown-method-call-2.slate | 5 + .../respond-to-an-unknown-method-call-1.st | 18 + .../respond-to-an-unknown-method-call-2.st | 6 + .../respond-to-an-unknown-method-call-3.st | 11 + .../respond-to-an-unknown-method-call-4.st | 1 + .../Tcl/respond-to-an-unknown-method-call.tcl | 28 + .../respond-to-an-unknown-method-call.sh | 17 + Task/Return-multiple-values/0DESCRIPTION | 1 + Task/Return-multiple-values/1META.yaml | 4 + .../ACL2/return-multiple-values.acl2 | 8 + .../ATS/return-multiple-values.ats | 9 + .../Ada/return-multiple-values.ada | 14 + .../AutoHotkey/return-multiple-values.ahk | 3 + .../AutoIt/return-multiple-values.autoit | 6 + .../BBC-BASIC/return-multiple-values.bbc | 9 + .../Bracmat/return-multiple-values-1.bracmat | 1 + .../Bracmat/return-multiple-values-2.bracmat | 4 + .../C++/return-multiple-values.cpp | 19 + .../C/return-multiple-values.c | 39 ++ .../CMake/return-multiple-values.cmake | 17 + .../Clojure/return-multiple-values-1.clj | 6 + .../Clojure/return-multiple-values-2.clj | 8 + .../Common-Lisp/return-multiple-values-1.lisp | 2 + .../return-multiple-values-10.lisp | 2 + .../return-multiple-values-11.lisp | 1 + .../Common-Lisp/return-multiple-values-2.lisp | 2 + .../Common-Lisp/return-multiple-values-3.lisp | 12 + .../Common-Lisp/return-multiple-values-4.lisp | 1 + .../Common-Lisp/return-multiple-values-5.lisp | 1 + .../Common-Lisp/return-multiple-values-6.lisp | 3 + .../Common-Lisp/return-multiple-values-7.lisp | 3 + .../Common-Lisp/return-multiple-values-8.lisp | 1 + .../Common-Lisp/return-multiple-values-9.lisp | 2 + .../D/return-multiple-values.d | 10 + .../Delphi/return-multiple-values.delphi | 17 + .../Euphoria/return-multiple-values.euphoria | 14 + .../FALSE/return-multiple-values.false | 2 + .../Factor/return-multiple-values.factor | 10 + .../Forth/return-multiple-values.fth | 2 + .../Go/return-multiple-values-1.go | 3 + .../Go/return-multiple-values-2.go | 5 + .../Go/return-multiple-values-3.go | 3 + .../Groovy/return-multiple-values-1.groovy | 6 + .../Groovy/return-multiple-values-2.groovy | 3 + .../Haskell/return-multiple-values-1.hs | 2 + .../Haskell/return-multiple-values-2.hs | 4 + .../Icon/return-multiple-values.icon | 26 + .../J/return-multiple-values.j | 2 + .../Java/return-multiple-values.java | 100 ++++ .../Julia/return-multiple-values.julia | 3 + .../return-multiple-values.liberty | 21 + .../Lua/return-multiple-values.lua | 6 + .../MATLAB/return-multiple-values-1.m | 6 + .../MATLAB/return-multiple-values-2.m | 4 + .../Maple/return-multiple-values-1.maple | 6 + .../Maple/return-multiple-values-2.maple | 1 + .../Mathematica/return-multiple-values.math | 2 + .../Maxima/return-multiple-values.maxima | 4 + .../Mercury/return-multiple-values.mercury | 26 + .../NetRexx/return-multiple-values.netrexx | 102 ++++ .../OCaml/return-multiple-values-1.ocaml | 2 + .../OCaml/return-multiple-values-2.ocaml | 3 + .../OCaml/return-multiple-values-3.ocaml | 13 + .../OCaml/return-multiple-values-4.ocaml | 2 + .../OCaml/return-multiple-values-5.ocaml | 15 + .../OxygenBasic/return-multiple-values.oxy | 42 ++ .../PARI-GP/return-multiple-values.pari | 3 + .../PHP/return-multiple-values-1.php | 3 + .../PHP/return-multiple-values-2.php | 3 + .../PL-I/return-multiple-values-1.pli | 12 + .../PL-I/return-multiple-values-2.pli | 15 + .../PL-I/return-multiple-values-3.pli | 5 + .../Perl-6/return-multiple-values.pl6 | 5 + .../Perl/return-multiple-values.pl | 4 + .../PicoLisp/return-multiple-values-1.l | 2 + .../PicoLisp/return-multiple-values-2.l | 8 + .../Pike/return-multiple-values.pike | 6 + .../return-multiple-values.purebasic | 33 ++ .../Python/return-multiple-values-1.py | 2 + .../Python/return-multiple-values-2.py | 3 + .../R/return-multiple-values.r | 1 + .../REXX/return-multiple-values.rexx | 32 ++ .../Retro/return-multiple-values.retro | 2 + .../Ruby/return-multiple-values-1.rb | 3 + .../Ruby/return-multiple-values-2.rb | 3 + .../Ruby/return-multiple-values-3.rb | 3 + .../Run-BASIC/return-multiple-values.run | 11 + .../Scala/return-multiple-values-1.scala | 1 + .../Scala/return-multiple-values-2.scala | 1 + .../Scheme/return-multiple-values-1.ss | 2 + .../Scheme/return-multiple-values-2.ss | 5 + .../Scheme/return-multiple-values-3.ss | 4 + .../Scheme/return-multiple-values-4.ss | 4 + .../Seed7/return-multiple-values.seed7 | 17 + .../Standard-ML/return-multiple-values-1.ml | 2 + .../Standard-ML/return-multiple-values-2.ml | 6 + .../TXR/return-multiple-values-1.txr | 4 + .../TXR/return-multiple-values-2.txr | 1 + .../TXR/return-multiple-values-3.txr | 1 + .../TXR/return-multiple-values-4.txr | 1 + .../Tcl/return-multiple-values-1.tcl | 3 + .../Tcl/return-multiple-values-2.tcl | 2 + .../UNIX-Shell/return-multiple-values.sh | 14 + .../XPL0/return-multiple-values.xpl0 | 14 + .../0815/reverse-a-string-1.0815 | 10 + .../0815/reverse-a-string-2.0815 | 3 + Task/Reverse-a-string/0DESCRIPTION | 3 + Task/Reverse-a-string/1META.yaml | 2 + .../ACL2/reverse-a-string.acl2 | 1 + .../ALGOL-68/reverse-a-string-1.alg | 13 + .../ALGOL-68/reverse-a-string-2.alg | 2 + .../AWK/reverse-a-string-1.awk | 10 + .../AWK/reverse-a-string-2.awk | 9 + .../ActionScript/reverse-a-string.as | 12 + .../Reverse-a-string/Ada/reverse-a-string.ada | 14 + .../Agda2/reverse-a-string.agda2 | 7 + .../AppleScript/reverse-a-string.applescript | 12 + .../AutoHotkey/reverse-a-string-1.ahk | 8 + .../AutoHotkey/reverse-a-string-2.ahk | 19 + .../AutoIt/reverse-a-string.autoit | 12 + .../BASIC/reverse-a-string.basic | 7 + .../BBC-BASIC/reverse-a-string.bbc | 9 + .../Babel/reverse-a-string.pb | 1 + .../Batch-File/reverse-a-string.bat | 17 + .../Befunge/reverse-a-string.bf | 14 + .../Bracmat/reverse-a-string.bracmat | 15 + .../Brainf---/reverse-a-string-1.bf | 1 + .../Brainf---/reverse-a-string-2.bf | 5 + .../Brat/reverse-a-string.brat | 1 + .../Burlesque/reverse-a-string.blq | 1 + .../Reverse-a-string/C++/reverse-a-string.cpp | 12 + Task/Reverse-a-string/C/reverse-a-string-1.c | 67 +++ Task/Reverse-a-string/C/reverse-a-string-2.c | 13 + .../COBOL/reverse-a-string.cobol | 1 + .../Clojure/reverse-a-string-1.clj | 1 + .../Clojure/reverse-a-string-2.clj | 1 + .../Clojure/reverse-a-string-3.clj | 21 + .../reverse-a-string.coffeescript | 1 + .../ColdFusion/reverse-a-string.cfm | 2 + .../Common-Lisp/reverse-a-string.lisp | 1 + Task/Reverse-a-string/D/reverse-a-string.d | 15 + .../Dart/reverse-a-string.dart | 11 + .../Delphi/reverse-a-string-1.delphi | 7 + .../Delphi/reverse-a-string-2.delphi | 1 + Task/Reverse-a-string/E/reverse-a-string.e | 4 + .../Reverse-a-string/EGL/reverse-a-string.egl | 7 + .../Eiffel/reverse-a-string.e | 15 + .../Emacs-Lisp/reverse-a-string.l | 1 + .../Erlang/reverse-a-string-1.erl | 2 + .../Erlang/reverse-a-string-2.erl | 4 + .../Euler-Math-Toolbox/reverse-a-string.euler | 3 + .../Euphoria/reverse-a-string.euphoria | 2 + .../FBSL/reverse-a-string-1.fbsl | 8 + .../FBSL/reverse-a-string-2.fbsl | 8 + .../FBSL/reverse-a-string-3.fbsl | 7 + .../FBSL/reverse-a-string-4.fbsl | 20 + .../Factor/reverse-a-string-1.factor | 1 + .../Factor/reverse-a-string-2.factor | 1 + .../Fancy/reverse-a-string.fancy | 1 + .../Forth/reverse-a-string.fth | 9 + .../Fortran/reverse-a-string-1.f | 16 + .../Fortran/reverse-a-string-2.f | 25 + .../Frink/reverse-a-string.frink | 1 + .../Reverse-a-string/GAP/reverse-a-string.gap | 2 + .../Gema/reverse-a-string-1.gema | 1 + .../Gema/reverse-a-string-2.gema | 1 + Task/Reverse-a-string/Go/reverse-a-string.go | 76 +++ .../Groovy/reverse-a-string.groovy | 1 + .../Haskell/reverse-a-string-1.hs | 1 + .../Haskell/reverse-a-string-2.hs | 3 + .../HicEst/reverse-a-string.hicest | 10 + .../Icon/reverse-a-string.icon | 4 + Task/Reverse-a-string/Io/reverse-a-string.io | 1 + Task/Reverse-a-string/J/reverse-a-string-1.j | 2 + Task/Reverse-a-string/J/reverse-a-string-2.j | 2 + Task/Reverse-a-string/J/reverse-a-string-3.j | 1 + Task/Reverse-a-string/J/reverse-a-string-4.j | 2 + .../Java/reverse-a-string-1.java | 3 + .../Java/reverse-a-string-2.java | 3 + .../JavaScript/reverse-a-string.js | 3 + .../Julia/reverse-a-string.julia | 2 + .../Lang5/reverse-a-string.lang5 | 2 + .../Liberty-BASIC/reverse-a-string.liberty | 11 + .../Logo/reverse-a-string.logo | 1 + .../Reverse-a-string/Lua/reverse-a-string.lua | 1 + Task/Reverse-a-string/M4/reverse-a-string.m4 | 1 + .../MATLAB/reverse-a-string.m | 6 + .../MAXScript/reverse-a-string.maxscript | 6 + .../MUMPS/reverse-a-string.mumps | 6 + .../Maple/reverse-a-string.maple | 2 + .../Mathematica/reverse-a-string.math | 1 + .../Maxima/reverse-a-string.maxima | 3 + .../Mirah/reverse-a-string.mirah | 5 + .../Modula-3/reverse-a-string.mod3 | 16 + .../Nemerle/reverse-a-string-1.nemerle | 23 + .../Nemerle/reverse-a-string-2.nemerle | 7 + .../NetRexx/reverse-a-string.netrexx | 11 + .../NewLISP/reverse-a-string.newlisp | 1 + .../Nial/reverse-a-string.nial | 2 + .../Nimrod/reverse-a-string.nimrod | 9 + .../OCaml/reverse-a-string-1.ocaml | 9 + .../OCaml/reverse-a-string-2.ocaml | 8 + .../OCaml/reverse-a-string-3.ocaml | 4 + .../Objeck/reverse-a-string.objeck | 1 + .../Objective-C/reverse-a-string-1.m | 20 + .../Objective-C/reverse-a-string-2.m | 11 + .../Objective-C/reverse-a-string-3.m | 20 + .../Objective-C/reverse-a-string-4.m | 11 + .../Octave/reverse-a-string.octave | 2 + .../reverse-a-string.openedge | 15 + .../OxygenBasic/reverse-a-string-1.oxy | 32 ++ .../OxygenBasic/reverse-a-string-2.oxy | 19 + .../Reverse-a-string/Oz/reverse-a-string-1.oz | 1 + .../Reverse-a-string/Oz/reverse-a-string-2.oz | 9 + .../PARI-GP/reverse-a-string.pari | 1 + .../PHP/reverse-a-string-1.php | 1 + .../PHP/reverse-a-string-2.php | 2 + .../PL-I/reverse-a-string.pli | 1 + .../Pascal/reverse-a-string-1.pascal | 9 + .../Pascal/reverse-a-string-2.pascal | 10 + .../Pascal/reverse-a-string-3.pascal | 12 + .../Perl-6/reverse-a-string.pl6 | 4 + .../Perl/reverse-a-string-1.pl | 2 + .../Perl/reverse-a-string-2.pl | 2 + .../PicoLisp/reverse-a-string.l | 1 + .../Pop11/reverse-a-string.pop11 | 7 + .../PostScript/reverse-a-string-1.ps | 12 + .../PostScript/reverse-a-string-2.ps | 5 + .../PowerShell/reverse-a-string-1.psh | 1 + .../PowerShell/reverse-a-string-2.psh | 1 + .../PowerShell/reverse-a-string-3.psh | 1 + .../PowerShell/reverse-a-string-4.psh | 1 + .../PowerShell/reverse-a-string-5.psh | 3 + .../PowerShell/reverse-a-string-6.psh | 3 + .../Prolog/reverse-a-string-1.pro | 1 + .../Prolog/reverse-a-string-2.pro | 3 + .../Prolog/reverse-a-string-3.pro | 4 + .../Protium/reverse-a-string-1.protium | 1 + .../Protium/reverse-a-string-2.protium | 1 + .../Protium/reverse-a-string-3.protium | 1 + .../PureBasic/reverse-a-string.purebasic | 1 + .../Python/reverse-a-string-1.py | 1 + .../Python/reverse-a-string-2.py | 1 + .../Python/reverse-a-string-3.py | 36 ++ Task/Reverse-a-string/Qi/reverse-a-string.qi | 1 + Task/Reverse-a-string/R/reverse-a-string-1.r | 7 + Task/Reverse-a-string/R/reverse-a-string-2.r | 1 + Task/Reverse-a-string/R/reverse-a-string-3.r | 4 + .../REBOL/reverse-a-string-1.rebol | 1 + .../REBOL/reverse-a-string-2.rebol | 3 + .../REXX/reverse-a-string-1.rexx | 8 + .../REXX/reverse-a-string-2.rexx | 10 + .../REXX/reverse-a-string-3.rexx | 3 + .../REXX/reverse-a-string-4.rexx | 10 + .../RLaB/reverse-a-string.rlab | 12 + .../Racket/reverse-a-string.rkt | 6 + .../Rascal/reverse-a-string.rascal | 2 + .../Retro/reverse-a-string.retro | 2 + .../Ruby/reverse-a-string-1.rb | 2 + .../Ruby/reverse-a-string-2.rb | 2 + .../Run-BASIC/reverse-a-string.run | 4 + .../Reverse-a-string/SAS/reverse-a-string.sas | 7 + .../SNOBOL4/reverse-a-string.sno | 2 + .../Sather/reverse-a-string.sa | 7 + .../Scala/reverse-a-string-1.scala | 1 + .../Scala/reverse-a-string-2.scala | 1 + .../Scala/reverse-a-string-3.scala | 30 + .../Scheme/reverse-a-string.ss | 2 + .../Reverse-a-string/Sed/reverse-a-string.sed | 18 + .../Seed7/reverse-a-string.seed7 | 17 + .../Slate/reverse-a-string-1.slate | 1 + .../Slate/reverse-a-string-2.slate | 1 + .../Smalltalk/reverse-a-string-1.st | 1 + .../Smalltalk/reverse-a-string-2.st | 1 + .../Standard-ML/reverse-a-string.ml | 3 + .../TI-83-BASIC/reverse-a-string.ti-83 | 8 + .../TUSCRIPT/reverse-a-string.tuscript | 5 + .../Reverse-a-string/Tcl/reverse-a-string.tcl | 2 + .../Turing/reverse-a-string.turing | 16 + .../Unlambda/reverse-a-string.unlambda | 1 + .../Ursala/reverse-a-string.ursala | 7 + .../VBA/reverse-a-string-1.vba | 12 + .../VBA/reverse-a-string-2.vba | 14 + .../reverse-a-string-1.vedit | 4 + .../reverse-a-string-2.vedit | 4 + .../Visual-Basic-.NET/reverse-a-string.visual | 5 + .../XPL0/reverse-a-string.xpl0 | 23 + .../Yorick/reverse-a-string.yorick | 1 + Task/Rock-paper-scissors/0DESCRIPTION | 11 + Task/Rock-paper-scissors/1META.yaml | 2 + .../Ada/rock-paper-scissors.ada | 107 ++++ .../AutoHotkey/rock-paper-scissors.ahk | 46 ++ .../AutoIt/rock-paper-scissors.autoit | 92 +++ .../BASIC/rock-paper-scissors-1.basic | 62 ++ .../BASIC/rock-paper-scissors-2.basic | 16 + .../BBC-BASIC/rock-paper-scissors.bbc | 46 ++ .../C++/rock-paper-scissors.cpp | 179 ++++++ .../C/rock-paper-scissors-1.c | 54 ++ .../C/rock-paper-scissors-2.c | 28 + .../D/rock-paper-scissors.d | 55 ++ .../Erlang/rock-paper-scissors.erl | 46 ++ .../Euphoria/rock-paper-scissors.euphoria | 50 ++ .../Go/rock-paper-scissors.go | 69 +++ .../Haskell/rock-paper-scissors.hs | 36 ++ .../Icon/rock-paper-scissors.icon | 41 ++ .../J/rock-paper-scissors-1.j | 19 + .../J/rock-paper-scissors-2.j | 20 + .../Java/rock-paper-scissors.java | 79 +++ .../Julia/rock-paper-scissors.julia | 23 + .../Liberty-BASIC/rock-paper-scissors.liberty | 88 +++ .../rock-paper-scissors.locomotive | 23 + .../Mathematica/rock-paper-scissors.math | 12 + .../OCaml/rock-paper-scissors.ocaml | 52 ++ .../PARI-GP/rock-paper-scissors.pari | 35 ++ .../Perl-6/rock-paper-scissors-1.pl6 | 40 ++ .../Perl-6/rock-paper-scissors-2.pl6 | 38 ++ .../PicoLisp/rock-paper-scissors.l | 20 + .../PureBasic/rock-paper-scissors.purebasic | 84 +++ .../Python/rock-paper-scissors.py | 66 +++ .../Rascal/rock-paper-scissors-1.rascal | 20 + .../Rascal/rock-paper-scissors-2.rascal | 29 + .../Ruby/rock-paper-scissors.rb | 73 +++ .../Run-BASIC/rock-paper-scissors.run | 30 + .../TI-83-BASIC/rock-paper-scissors.ti-83 | 64 +++ .../Tcl/rock-paper-scissors.tcl | 64 +++ .../rock-paper-scissors-1.torquescript | 140 +++++ .../rock-paper-scissors-2.torquescript | 1 + .../rock-paper-scissors-3.torquescript | 1 + Task/Roman-numerals-Decode/0DESCRIPTION | 3 + .../ALGOL-68/roman-numerals-decode.alg | 48 ++ .../ANTLR/roman-numerals-decode.antlr | 39 ++ .../AWK/roman-numerals-decode.awk | 23 + .../Ada/roman-numerals-decode.ada | 46 ++ .../AutoHotkey/roman-numerals-decode.ahk | 16 + .../BBC-BASIC/roman-numerals-decode.bbc | 16 + .../Bracmat/roman-numerals-decode.bracmat | 40 ++ .../C++/roman-numerals-decode.cpp | 48 ++ .../C/roman-numerals-decode.c | 47 ++ .../Clojure/roman-numerals-decode.clj | 6 + .../roman-numerals-decode.coffeescript | 36 ++ .../Common-Lisp/roman-numerals-decode.lisp | 9 + .../D/roman-numerals-decode-1.d | 19 + .../D/roman-numerals-decode-2.d | 20 + .../Delphi/roman-numerals-decode.delphi | 44 ++ .../Emacs-Lisp/roman-numerals-decode.l | 16 + .../Euphoria/roman-numerals-decode.euphoria | 25 + .../Forth/roman-numerals-decode.fth | 26 + .../Fortran/roman-numerals-decode.f | 41 ++ .../Go/roman-numerals-decode-1.go | 84 +++ .../Go/roman-numerals-decode-2.go | 38 ++ .../Groovy/roman-numerals-decode-1.groovy | 20 + .../Groovy/roman-numerals-decode-2.groovy | 12 + .../Haskell/roman-numerals-decode.hs | 9 + .../Icon/roman-numerals-decode-1.icon | 6 + .../Icon/roman-numerals-decode-2.icon | 20 + .../J/roman-numerals-decode-1.j | 1 + .../J/roman-numerals-decode-2.j | 6 + .../Java/roman-numerals-decode.java | 37 ++ .../JavaScript/roman-numerals-decode.js | 27 + .../K/roman-numerals-decode-1.k | 1 + .../K/roman-numerals-decode-2.k | 2 + .../roman-numerals-decode.liberty | 43 ++ .../Logo/roman-numerals-decode.logo | 35 ++ .../Lua/roman-numerals-decode.lua | 25 + .../Mathematica/roman-numerals-decode.math | 1 + .../NetRexx/roman-numerals-decode.netrexx | 49 ++ .../OCaml/roman-numerals-decode.ocaml | 27 + .../PARI-GP/roman-numerals-decode.pari | 17 + .../PHP/roman-numerals-decode.php | 86 +++ .../PL-I/roman-numerals-decode.pli | 46 ++ .../PL-SQL/roman-numerals-decode.sql | 83 +++ .../Perl-6/roman-numerals-decode-1.pl6 | 23 + .../Perl-6/roman-numerals-decode-2.pl6 | 15 + .../Perl/roman-numerals-decode.pl | 25 + .../PicoLisp/roman-numerals-decode.l | 3 + .../Prolog/roman-numerals-decode.pro | 32 ++ .../PureBasic/roman-numerals-decode.purebasic | 43 ++ .../Python/roman-numerals-decode-1.py | 12 + .../Python/roman-numerals-decode-2.py | 20 + .../REXX/roman-numerals-decode-1.rexx | 63 ++ .../REXX/roman-numerals-decode-2.rexx | 30 + .../REXX/roman-numerals-decode-3.rexx | 22 + .../Ruby/roman-numerals-decode.rb | 28 + .../Run-BASIC/roman-numerals-decode.run | 24 + .../SNOBOL4/roman-numerals-decode-1.sno | 17 + .../SNOBOL4/roman-numerals-decode-2.sno | 15 + .../SNOBOL4/roman-numerals-decode-3.sno | 13 + .../Scala/roman-numerals-decode.scala | 18 + .../Seed7/roman-numerals-decode.seed7 | 36 ++ .../TI-83-BASIC/roman-numerals-decode-1.ti-83 | 3 + .../TI-83-BASIC/roman-numerals-decode-2.ti-83 | 20 + .../TUSCRIPT/roman-numerals-decode.tuscript | 5 + .../Tcl/roman-numerals-decode-1.tcl | 4 + .../Tcl/roman-numerals-decode-2.tcl | 3 + .../roman-numerals-decode.vedit | 38 ++ .../XPL0/roman-numerals-decode.xpl0 | 27 + Task/Roman-numerals-Encode/0DESCRIPTION | 3 + .../ALGOL-68/roman-numerals-encode.alg | 29 + .../ALGOL-W/roman-numerals-encode.alg | 51 ++ .../AWK/roman-numerals-encode.awk | 26 + .../ActionScript/roman-numerals-encode-1.as | 14 + .../ActionScript/roman-numerals-encode-2.as | 13 + .../Ada/roman-numerals-encode.ada | 33 ++ .../AutoHotkey/roman-numerals-encode.ahk | 28 + .../BASIC/roman-numerals-encode-1.basic | 20 + .../BASIC/roman-numerals-encode-2.basic | 17 + .../BASIC256/roman-numerals-encode.basic256 | 16 + .../BBC-BASIC/roman-numerals-encode.bbc | 18 + .../Bracmat/roman-numerals-encode.bracmat | 49 ++ .../C++/roman-numerals-encode.cpp | 41 ++ .../C/roman-numerals-encode-1.c | 59 ++ .../C/roman-numerals-encode-2.c | 38 ++ .../C/roman-numerals-encode-3.c | 40 ++ .../Clojure/roman-numerals-encode-1.clj | 7 + .../Clojure/roman-numerals-encode-2.clj | 31 + .../Clojure/roman-numerals-encode-3.clj | 17 + .../Clojure/roman-numerals-encode-4.clj | 5 + .../roman-numerals-encode.coffeescript | 46 ++ .../Common-Lisp/roman-numerals-encode.lisp | 2 + .../D/roman-numerals-encode.d | 26 + .../DWScript/roman-numerals-encode.dwscript | 20 + .../Delphi/roman-numerals-encode.delphi | 28 + .../Emacs-Lisp/roman-numerals-encode.l | 17 + .../Erlang/roman-numerals-encode.erl | 20 + .../Euphoria/roman-numerals-encode.euphoria | 18 + .../FALSE/roman-numerals-encode.false | 14 + .../Factor/roman-numerals-encode-1.factor | 3 + .../Factor/roman-numerals-encode-2.factor | 16 + .../Fan/roman-numerals-encode.fan | 38 ++ .../Forth/roman-numerals-encode-1.fth | 18 + .../Forth/roman-numerals-encode-2.fth | 19 + .../Fortran/roman-numerals-encode.f | 35 ++ .../Go/roman-numerals-encode.go | 39 ++ .../Groovy/roman-numerals-encode.groovy | 28 + .../Haskell/roman-numerals-encode-1.hs | 13 + .../Haskell/roman-numerals-encode-2.hs | 2 + .../HicEst/roman-numerals-encode.hicest | 22 + .../Icon/roman-numerals-encode-1.icon | 6 + .../Icon/roman-numerals-encode-2.icon | 12 + .../Io/roman-numerals-encode.io | 18 + .../J/roman-numerals-encode-1.j | 7 + .../J/roman-numerals-encode-2.j | 6 + .../Java/roman-numerals-encode.java | 41 ++ .../JavaScript/roman-numerals-encode.js | 18 + .../LaTeX/roman-numerals-encode.tex | 5 + .../roman-numerals-encode.liberty | 31 + .../Logo/roman-numerals-encode-1.logo | 12 + .../Logo/roman-numerals-encode-2.logo | 18 + .../roman-numerals-encode.lotusscript | 43 ++ .../Lua/roman-numerals-encode.lua | 15 + .../M4/roman-numerals-encode.m4 | 15 + .../MUMPS/roman-numerals-encode.mumps | 14 + .../Mathematica/roman-numerals-encode-1.math | 10 + .../Mathematica/roman-numerals-encode-2.math | 5 + .../Mathematica/roman-numerals-encode-3.math | 5 + .../Mathematica/roman-numerals-encode-4.math | 52 ++ .../Mathematica/roman-numerals-encode-5.math | 48 ++ .../OCaml/roman-numerals-encode.ocaml | 23 + .../Objeck/roman-numerals-encode.objeck | 32 ++ .../roman-numerals-encode.openedge | 36 ++ .../Oz/roman-numerals-encode.oz | 17 + .../PARI-GP/roman-numerals-encode-1.pari | 55 ++ .../PARI-GP/roman-numerals-encode-2.pari | 55 ++ .../PHP/roman-numerals-encode.php | 60 ++ .../PL-I/roman-numerals-encode.pli | 19 + .../PL-SQL/roman-numerals-encode.sql | 24 + .../Perl-6/roman-numerals-encode-1.pl6 | 16 + .../Perl-6/roman-numerals-encode-2.pl6 | 3 + .../Perl/roman-numerals-encode-1.pl | 3 + .../Perl/roman-numerals-encode-2.pl | 25 + .../Perl/roman-numerals-encode-3.pl | 1 + .../PicoLisp/roman-numerals-encode.l | 10 + .../Pike/roman-numerals-encode.pike | 6 + .../roman-numerals-encode.powerbasic | 24 + .../Prolog/roman-numerals-encode.pro | 102 ++++ .../Protium/roman-numerals-encode-1.protium | 5 + .../Protium/roman-numerals-encode-2.protium | 5 + .../PureBasic/roman-numerals-encode.purebasic | 56 ++ .../Python/roman-numerals-encode-1.py | 24 + .../Python/roman-numerals-encode-2.py | 16 + .../Python/roman-numerals-encode-3.py | 18 + .../R/roman-numerals-encode-1.r | 1 + .../R/roman-numerals-encode-2.r | 1 + .../REXX/roman-numerals-encode-1.rexx | 17 + .../REXX/roman-numerals-encode-2.rexx | 64 +++ .../Retro/roman-numerals-encode.retro | 24 + .../Ruby/roman-numerals-encode.rb | 10 + .../Run-BASIC/roman-numerals-encode.run | 20 + .../SNOBOL4/roman-numerals-encode-1.sno | 31 + .../SNOBOL4/roman-numerals-encode-2.sno | 29 + .../SQL/roman-numerals-encode.sql | 16 + .../Scala/roman-numerals-encode-1.scala | 13 + .../Scala/roman-numerals-encode-2.scala | 14 + .../Scheme/roman-numerals-encode.ss | 2 + .../Seed7/roman-numerals-encode.seed7 | 12 + .../Smalltalk/roman-numerals-encode-1.st | 1 + .../Smalltalk/roman-numerals-encode-2.st | 53 ++ .../TI-83-BASIC/roman-numerals-encode.ti-83 | 84 +++ .../TUSCRIPT/roman-numerals-encode.tuscript | 5 + .../Tcl/roman-numerals-encode.tcl | 10 + .../Ursala/roman-numerals-encode-1.ursala | 7 + .../Ursala/roman-numerals-encode-2.ursala | 3 + .../roman-numerals-encode.vedit | 32 ++ .../Visual-Basic/roman-numerals-encode.vb | 22 + .../XSLT/roman-numerals-encode.xslt | 50 ++ Task/Roots-of-a-function/0DESCRIPTION | 3 + Task/Roots-of-a-function/1META.yaml | 2 + .../ALGOL-68/roots-of-a-function.alg | 70 +++ .../Ada/roots-of-a-function.ada | 39 ++ .../AutoHotkey/roots-of-a-function.ahk | 36 ++ .../Axiom/roots-of-a-function-1.axiom | 2 + .../Axiom/roots-of-a-function-2.axiom | 2 + .../Axiom/roots-of-a-function-3.axiom | 15 + .../Axiom/roots-of-a-function-4.axiom | 1 + .../BBC-BASIC/roots-of-a-function.bbc | 27 + .../C++/roots-of-a-function.cpp | 36 ++ .../C/roots-of-a-function.c | 60 ++ .../Clojure/roots-of-a-function.clj | 2 + .../roots-of-a-function-1.coffeescript | 35 ++ .../roots-of-a-function-2.coffeescript | 13 + .../Common-Lisp/roots-of-a-function.lisp | 17 + .../D/roots-of-a-function.d | 71 +++ .../DWScript/roots-of-a-function.dwscript | 51 ++ .../Fortran/roots-of-a-function-1.f | 26 + .../Fortran/roots-of-a-function-2.f | 22 + .../Go/roots-of-a-function.go | 44 ++ .../Haskell/roots-of-a-function-1.hs | 4 + .../Haskell/roots-of-a-function-2.hs | 2 + .../Haskell/roots-of-a-function-3.hs | 7 + .../Haskell/roots-of-a-function-4.hs | 4 + .../HicEst/roots-of-a-function-1.hicest | 10 + .../HicEst/roots-of-a-function-2.hicest | 9 + .../J/roots-of-a-function-1.j | 2 + .../J/roots-of-a-function-2.j | 2 + .../J/roots-of-a-function-3.j | 5 + .../Java/roots-of-a-function.java | 38 ++ .../Liberty-BASIC/roots-of-a-function.liberty | 46 ++ .../Maple/roots-of-a-function-1.maple | 2 + .../Maple/roots-of-a-function-2.maple | 1 + .../Mathematica/roots-of-a-function-1.math | 1 + .../Mathematica/roots-of-a-function-2.math | 1 + .../Mathematica/roots-of-a-function-3.math | 1 + .../Mathematica/roots-of-a-function-4.math | 1 + .../Mathematica/roots-of-a-function-5.math | 1 + .../Mathematica/roots-of-a-function-6.math | 1 + .../Maxima/roots-of-a-function.maxima | 54 ++ .../OCaml/roots-of-a-function.ocaml | 33 ++ .../Objeck/roots-of-a-function.objeck | 34 ++ .../Octave/roots-of-a-function-1.octave | 11 + .../Octave/roots-of-a-function-2.octave | 21 + .../PARI-GP/roots-of-a-function-1.pari | 1 + .../PARI-GP/roots-of-a-function-2.pari | 1 + .../PARI-GP/roots-of-a-function-3.pari | 3 + .../PARI-GP/roots-of-a-function-4.pari | 19 + .../PARI-GP/roots-of-a-function-5.pari | 46 ++ .../PL-I/roots-of-a-function.pli | 41 ++ .../Pascal/roots-of-a-function.pascal | 64 +++ .../Perl-6/roots-of-a-function.pl6 | 19 + .../Perl/roots-of-a-function.pl | 37 ++ .../PicoLisp/roots-of-a-function.l | 11 + .../PureBasic/roots-of-a-function.purebasic | 28 + .../Python/roots-of-a-function.py | 23 + .../R/roots-of-a-function.r | 18 + .../REXX/roots-of-a-function-1.rexx | 16 + .../REXX/roots-of-a-function-2.rexx | 2 + .../RLaB/roots-of-a-function.rlab | 8 + .../Ruby/roots-of-a-function-1.rb | 22 + .../Ruby/roots-of-a-function-2.rb | 19 + .../Tcl/roots-of-a-function-1.tcl | 15 + .../Tcl/roots-of-a-function-2.tcl | 29 + .../0DESCRIPTION | 29 + Task/Roots-of-a-quadratic-function/1META.yaml | 2 + .../roots-of-a-quadratic-function.alg | 55 ++ .../Ada/roots-of-a-quadratic-function.ada | 22 + .../roots-of-a-quadratic-function.ahk | 23 + .../roots-of-a-quadratic-function.bbc | 28 + .../C++/roots-of-a-quadratic-function.cpp | 28 + .../C/roots-of-a-quadratic-function-1.c | 61 ++ .../C/roots-of-a-quadratic-function-2.c | 2 + .../C/roots-of-a-quadratic-function-3.c | 12 + .../C/roots-of-a-quadratic-function-4.c | 15 + .../C/roots-of-a-quadratic-function-5.c | 15 + .../roots-of-a-quadratic-function.lisp | 7 + .../D/roots-of-a-quadratic-function.d | 47 ++ .../roots-of-a-quadratic-function-1.factor | 6 + .../roots-of-a-quadratic-function-2.factor | 4 + .../roots-of-a-quadratic-function-3.factor | 4 + .../roots-of-a-quadratic-function-4.factor | 4 + .../Forth/roots-of-a-quadratic-function-1.fth | 13 + .../Forth/roots-of-a-quadratic-function-2.fth | 10 + .../Fortran/roots-of-a-quadratic-function.f | 34 ++ .../GAP/roots-of-a-quadratic-function.gap | 10 + .../Go/roots-of-a-quadratic-function.go | 57 ++ .../Haskell/roots-of-a-quadratic-function.hs | 10 + .../IDL/roots-of-a-quadratic-function.idl | 17 + .../J/roots-of-a-quadratic-function-1.j | 6 + .../J/roots-of-a-quadratic-function-2.j | 6 + .../J/roots-of-a-quadratic-function-3.j | 10 + .../J/roots-of-a-quadratic-function-4.j | 2 + .../J/roots-of-a-quadratic-function-5.j | 9 + .../Java/roots-of-a-quadratic-function.java | 74 +++ .../roots-of-a-quadratic-function.liberty | 14 + .../Logo/roots-of-a-quadratic-function.logo | 5 + .../Lua/roots-of-a-quadratic-function.lua | 9 + .../MATLAB/roots-of-a-quadratic-function.m | 1 + .../roots-of-a-quadratic-function.math | 9 + .../roots-of-a-quadratic-function.maxima | 16 + .../roots-of-a-quadratic-function.mod3 | 25 + .../roots-of-a-quadratic-function-1.ocaml | 20 + .../roots-of-a-quadratic-function-2.ocaml | 10 + .../roots-of-a-quadratic-function.pari | 11 + .../PL-I/roots-of-a-quadratic-function.pli | 16 + .../roots-of-a-quadratic-function.pascal | 28 + .../Perl-6/roots-of-a-quadratic-function.pl6 | 23 + .../Perl/roots-of-a-quadratic-function.pl | 12 + .../PicoLisp/roots-of-a-quadratic-function.l | 15 + .../Python/roots-of-a-quadratic-function.py | 25 + .../R/roots-of-a-quadratic-function.r | 18 + .../REXX/roots-of-a-quadratic-function.rexx | 36 ++ .../Ruby/roots-of-a-quadratic-function.rb | 15 + .../roots-of-a-quadratic-function.run | 12 + .../roots-of-a-quadratic-function-1.scala | 17 + .../roots-of-a-quadratic-function-2.scala | 17 + .../Scheme/roots-of-a-quadratic-function.ss | 40 ++ .../Seed7/roots-of-a-quadratic-function.seed7 | 35 ++ .../Tcl/roots-of-a-quadratic-function.tcl | 37 ++ Task/Roots-of-unity/0DESCRIPTION | 1 + Task/Roots-of-unity/1META.yaml | 2 + .../ALGOL-68/roots-of-unity.alg | 8 + Task/Roots-of-unity/Ada/roots-of-unity.ada | 34 ++ .../AutoHotkey/roots-of-unity.ahk | 4 + .../Roots-of-unity/BASIC/roots-of-unity.basic | 13 + .../BBC-BASIC/roots-of-unity.bbc | 11 + Task/Roots-of-unity/C++/roots-of-unity.cpp | 16 + Task/Roots-of-unity/C/roots-of-unity.c | 24 + .../CoffeeScript/roots-of-unity.coffeescript | 28 + .../Common-Lisp/roots-of-unity.lisp | 3 + Task/Roots-of-unity/D/roots-of-unity.d | 10 + Task/Roots-of-unity/Forth/roots-of-unity.fth | 10 + .../Roots-of-unity/Fortran/roots-of-unity-1.f | 19 + .../Roots-of-unity/Fortran/roots-of-unity-2.f | 15 + Task/Roots-of-unity/GAP/roots-of-unity.gap | 7 + Task/Roots-of-unity/Go/roots-of-unity.go | 24 + .../Groovy/roots-of-unity-1.groovy | 7 + .../Groovy/roots-of-unity-2.groovy | 14 + .../Haskell/roots-of-unity-1.hs | 3 + .../Haskell/roots-of-unity-2.hs | 4 + Task/Roots-of-unity/IDL/roots-of-unity-1.idl | 2 + Task/Roots-of-unity/IDL/roots-of-unity-2.idl | 1 + Task/Roots-of-unity/Icon/roots-of-unity.icon | 12 + Task/Roots-of-unity/J/roots-of-unity-1.j | 7 + Task/Roots-of-unity/J/roots-of-unity-2.j | 8 + Task/Roots-of-unity/Java/roots-of-unity.java | 10 + .../Liberty-BASIC/roots-of-unity.liberty | 54 ++ Task/Roots-of-unity/Lua/roots-of-unity.lua | 29 + Task/Roots-of-unity/MATLAB/roots-of-unity-1.m | 6 + Task/Roots-of-unity/MATLAB/roots-of-unity-2.m | 7 + .../Mathematica/roots-of-unity.math | 1 + .../Maxima/roots-of-unity-1.maxima | 1 + .../Maxima/roots-of-unity-2.maxima | 1 + .../Maxima/roots-of-unity-3.maxima | 5 + .../Roots-of-unity/OCaml/roots-of-unity.ocaml | 13 + .../Octave/roots-of-unity.octave | 7 + .../PARI-GP/roots-of-unity.pari | 1 + Task/Roots-of-unity/PL-I/roots-of-unity.pli | 22 + .../Pascal/roots-of-unity.pascal | 25 + Task/Roots-of-unity/Perl-6/roots-of-unity.pl6 | 5 + Task/Roots-of-unity/Perl/roots-of-unity.pl | 11 + Task/Roots-of-unity/PicoLisp/roots-of-unity.l | 15 + .../PureBasic/roots-of-unity.purebasic | 12 + Task/Roots-of-unity/Python/roots-of-unity.py | 20 + Task/Roots-of-unity/R/roots-of-unity.r | 7 + Task/Roots-of-unity/REXX/roots-of-unity.rexx | 48 ++ Task/Roots-of-unity/RLaB/roots-of-unity.rlab | 16 + Task/Roots-of-unity/Racket/roots-of-unity.rkt | 5 + Task/Roots-of-unity/Ruby/roots-of-unity.rb | 6 + .../Roots-of-unity/Scala/roots-of-unity.scala | 1 + Task/Roots-of-unity/Scheme/roots-of-unity.ss | 10 + .../Seed7/roots-of-unity-1.seed7 | 17 + .../Seed7/roots-of-unity-2.seed7 | 9 + .../TI-89-BASIC/roots-of-unity-1.ti-89 | 1 + .../TI-89-BASIC/roots-of-unity-2.ti-89 | 1 + Task/Roots-of-unity/Tcl/roots-of-unity.tcl | 13 + .../Ursala/roots-of-unity.ursala | 9 + Task/Rosetta-Code-Count-examples/0DESCRIPTION | 11 + Task/Rosetta-Code-Count-examples/1META.yaml | 2 + .../Ada/rosetta-code-count-examples.ada | 101 ++++ .../rosetta-code-count-examples.ahk | 20 + .../BBC-BASIC/rosetta-code-count-examples.bbc | 84 +++ .../Clojure/rosetta-code-count-examples-1.clj | 39 ++ .../Clojure/rosetta-code-count-examples-2.clj | 16 + .../D/rosetta-code-count-examples.d | 48 ++ .../EGL/rosetta-code-count-examples-1.egl | 76 +++ .../EGL/rosetta-code-count-examples-2.egl | 37 ++ .../Erlang/rosetta-code-count-examples.erl | 62 ++ .../Go/rosetta-code-count-examples.go | 75 +++ .../Haskell/rosetta-code-count-examples-1.hs | 37 ++ .../Haskell/rosetta-code-count-examples-2.hs | 10 + .../Haskell/rosetta-code-count-examples-3.hs | 65 +++ .../J/rosetta-code-count-examples-1.j | 20 + .../J/rosetta-code-count-examples-2.j | 6 + .../Java/rosetta-code-count-examples.java | 69 +++ .../MATLAB/rosetta-code-count-examples.m | 18 + .../rosetta-code-count-examples.math | 7 + .../OCaml/rosetta-code-count-examples.ocaml | 62 ++ .../Oz/rosetta-code-count-examples.oz | 85 +++ .../Perl/rosetta-code-count-examples-1.pl | 10 + .../Perl/rosetta-code-count-examples-2.pl | 12 + .../PicoLisp/rosetta-code-count-examples.l | 12 + .../rosetta-code-count-examples.purebasic | 25 + .../Python/rosetta-code-count-examples.py | 12 + .../R/rosetta-code-count-examples.r | 14 + .../Ruby/rosetta-code-count-examples-1.rb | 51 ++ .../Ruby/rosetta-code-count-examples-2.rb | 13 + .../Run-BASIC/rosetta-code-count-examples.run | 32 ++ .../Scala/rosetta-code-count-examples.scala | 14 + .../rosetta-code-count-examples.tuscript | 39 ++ .../Tcl/rosetta-code-count-examples.tcl | 65 +++ .../0DESCRIPTION | 5 + .../1META.yaml | 2 + .../rosetta-code-find-unimplemented-tasks.ada | 123 ++++ .../rosetta-code-find-unimplemented-tasks.ahk | 184 ++++++ .../rosetta-code-find-unimplemented-tasks.go | 74 +++ .../rosetta-code-find-unimplemented-tasks.hs | 27 + .../rosetta-code-find-unimplemented-tasks-1.j | 25 + .../rosetta-code-find-unimplemented-tasks-2.j | 4 + .../rosetta-code-find-unimplemented-tasks.oz | 127 ++++ .../rosetta-code-find-unimplemented-tasks.pl | 24 + .../rosetta-code-find-unimplemented-tasks-1.l | 24 + .../rosetta-code-find-unimplemented-tasks-2.l | 26 + .../R/rosetta-code-find-unimplemented-tasks.r | 16 + .../rosetta-code-find-unimplemented-tasks.rb | 46 ++ .../rosetta-code-find-unimplemented-tasks.run | 43 ++ .../rosetta-code-find-unimplemented-tasks.tcl | 97 ++++ Task/Rosetta-Code-Fix-code-tags/0DESCRIPTION | 10 + Task/Rosetta-Code-Fix-code-tags/1META.yaml | 4 + .../AutoHotkey/rosetta-code-fix-code-tags.ahk | 15 + .../Go/rosetta-code-fix-code-tags.go | 88 +++ .../J/rosetta-code-fix-code-tags-1.j | 6 + .../J/rosetta-code-fix-code-tags-2.j | 2 + .../J/rosetta-code-fix-code-tags-3.j | 2 + .../J/rosetta-code-fix-code-tags-4.j | 1 + .../J/rosetta-code-fix-code-tags-5.j | 1 + .../J/rosetta-code-fix-code-tags-6.j | 1 + .../J/rosetta-code-fix-code-tags-7.j | 1 + .../J/rosetta-code-fix-code-tags-8.j | 1 + .../J/rosetta-code-fix-code-tags-9.j | 1 + .../JavaScript/rosetta-code-fix-code-tags.js | 11 + .../Lua/rosetta-code-fix-code-tags.lua | 29 + .../rosetta-code-fix-code-tags-1.math | 5 + .../rosetta-code-fix-code-tags-2.math | 1 + .../rosetta-code-fix-code-tags-3.math | 1 + .../rosetta-code-fix-code-tags-4.math | 1 + .../rosetta-code-fix-code-tags-5.math | 1 + .../OCaml/rosetta-code-fix-code-tags-1.ocaml | 59 ++ .../OCaml/rosetta-code-fix-code-tags-2.ocaml | 1 + .../OCaml/rosetta-code-fix-code-tags-3.ocaml | 1 + .../Perl/rosetta-code-fix-code-tags.pl | 26 + .../PicoLisp/rosetta-code-fix-code-tags.l | 14 + .../rosetta-code-fix-code-tags.purebasic | 40 ++ .../Python/rosetta-code-fix-code-tags.py | 36 ++ .../R/rosetta-code-fix-code-tags.r | 14 + .../REXX/rosetta-code-fix-code-tags-1.rexx | 21 + .../REXX/rosetta-code-fix-code-tags-2.rexx | 26 + .../Ruby/rosetta-code-fix-code-tags-1.rb | 21 + .../Ruby/rosetta-code-fix-code-tags-2.rb | 1 + .../Ruby/rosetta-code-fix-code-tags-3.rb | 1 + .../Ruby/rosetta-code-fix-code-tags-4.rb | 1 + .../Ruby/rosetta-code-fix-code-tags-5.rb | 1 + .../Tcl/rosetta-code-fix-code-tags-1.tcl | 20 + .../Tcl/rosetta-code-fix-code-tags-2.tcl | 2 + .../Tcl/rosetta-code-fix-code-tags-3.tcl | 7 + .../0DESCRIPTION | 50 ++ .../1META.yaml | 6 + ...etta-code-rank-languages-by-popularity.alg | 124 ++++ ...etta-code-rank-languages-by-popularity.awk | 93 +++ ...etta-code-rank-languages-by-popularity.ada | 89 +++ ...etta-code-rank-languages-by-popularity.ahk | 71 +++ ...etta-code-rank-languages-by-popularity.bbc | 90 +++ ...etta-code-rank-languages-by-popularity.cpp | 78 +++ ...osetta-code-rank-languages-by-popularity.c | 77 +++ ...etta-code-rank-languages-by-popularity.cos | 108 ++++ ...osetta-code-rank-languages-by-popularity.d | 24 + ...setta-code-rank-languages-by-popularity.go | 114 ++++ ...setta-code-rank-languages-by-popularity.hs | 35 ++ ...code-rank-languages-by-popularity-1.hicest | 33 ++ ...code-rank-languages-by-popularity-2.hicest | 12 + ...code-rank-languages-by-popularity-3.hicest | 18 + ...code-rank-languages-by-popularity-4.hicest | 11 + ...tta-code-rank-languages-by-popularity.math | 5 + ...setta-code-rank-languages-by-popularity.oz | 40 ++ ...etta-code-rank-languages-by-popularity.pl6 | 25 + ...setta-code-rank-languages-by-popularity.pl | 17 + ...osetta-code-rank-languages-by-popularity.l | 14 + ...ode-rank-languages-by-popularity.purebasic | 40 ++ ...setta-code-rank-languages-by-popularity.py | 14 + ...osetta-code-rank-languages-by-popularity.r | 15 + ...tta-code-rank-languages-by-popularity.rexx | 101 ++++ ...etta-code-rank-languages-by-popularity.rkt | 29 + ...setta-code-rank-languages-by-popularity.rb | 30 + ...etta-code-rank-languages-by-popularity.run | 28 + ...ta-code-rank-languages-by-popularity.scala | 46 ++ ...code-rank-languages-by-popularity.tuscript | 49 ++ ...ta-code-rank-languages-by-popularity-1.tcl | 36 ++ ...ta-code-rank-languages-by-popularity-2.tcl | 86 +++ ...ode-rank-languages-by-popularity.unixpipes | 3 + Task/Rot-13/0DESCRIPTION | 5 + Task/Rot-13/1META.yaml | 2 + Task/Rot-13/6502-Assembly/rot-13.6502 | 31 + Task/Rot-13/ACL2/rot-13.acl2 | 20 + Task/Rot-13/ALGOL-68/rot-13.alg | 14 + Task/Rot-13/AWK/rot-13.awk | 22 + Task/Rot-13/Ada/rot-13.ada | 40 ++ Task/Rot-13/AppleScript/rot-13-1.applescript | 3 + Task/Rot-13/AppleScript/rot-13-2.applescript | 13 + Task/Rot-13/AppleScript/rot-13-3.applescript | 1 + Task/Rot-13/AutoHotkey/rot-13.ahk | 28 + Task/Rot-13/BASIC/rot-13.basic | 17 + Task/Rot-13/BBC-BASIC/rot-13.bbc | 22 + Task/Rot-13/Befunge/rot-13.bf | 4 + Task/Rot-13/Burlesque/rot-13.blq | 4 + Task/Rot-13/C++/rot-13-1.cpp | 77 +++ Task/Rot-13/C++/rot-13-2.cpp | 41 ++ Task/Rot-13/C/rot-13.c | 44 ++ Task/Rot-13/Clojure/rot-13-1.clj | 12 + Task/Rot-13/Clojure/rot-13-2.clj | 7 + Task/Rot-13/Common-Lisp/rot-13-1.lisp | 13 + Task/Rot-13/Common-Lisp/rot-13-2.lisp | 12 + Task/Rot-13/D/rot-13-1.d | 12 + Task/Rot-13/D/rot-13-2.d | 21 + Task/Rot-13/E/rot-13.e | 12 + Task/Rot-13/Erlang/rot-13.erl | 6 + Task/Rot-13/Euphoria/rot-13.euphoria | 39 ++ Task/Rot-13/FALSE/rot-13.false | 1 + Task/Rot-13/Factor/rot-13.factor | 24 + Task/Rot-13/Fantom/rot-13.fantom | 35 ++ Task/Rot-13/Forth/rot-13-1.fth | 5 + Task/Rot-13/Forth/rot-13-2.fth | 21 + Task/Rot-13/Fortran/rot-13-1.f | 58 ++ Task/Rot-13/Fortran/rot-13-2.f | 12 + Task/Rot-13/GAP/rot-13.gap | 27 + Task/Rot-13/GML/rot-13-1.gml | 16 + Task/Rot-13/GML/rot-13-2.gml | 1 + Task/Rot-13/GW-BASIC/rot-13.gw-basic | 14 + Task/Rot-13/Gema/rot-13.gema | 2 + Task/Rot-13/Go/rot-13.go | 23 + Task/Rot-13/Groovy/rot-13-1.groovy | 12 + Task/Rot-13/Groovy/rot-13-2.groovy | 1 + Task/Rot-13/Haskell/rot-13-1.hs | 7 + Task/Rot-13/Haskell/rot-13-2.hs | 23 + Task/Rot-13/Haskell/rot-13-3.hs | 3 + Task/Rot-13/HicEst/rot-13.hicest | 16 + Task/Rot-13/Icon/rot-13.icon | 14 + Task/Rot-13/J/rot-13.j | 1 + Task/Rot-13/Java/rot-13.java | 49 ++ Task/Rot-13/JavaScript/rot-13.js | 6 + Task/Rot-13/K/rot-13.k | 4 + Task/Rot-13/Liberty-BASIC/rot-13-1.liberty | 29 + Task/Rot-13/Liberty-BASIC/rot-13-2.liberty | 12 + .../Rot-13/Locomotive-Basic/rot-13.locomotive | 14 + Task/Rot-13/Logo/rot-13.logo | 9 + Task/Rot-13/Lua/rot-13.lua | 5 + Task/Rot-13/MATLAB/rot-13-1.m | 19 + Task/Rot-13/MATLAB/rot-13-2.m | 5 + Task/Rot-13/MATLAB/rot-13-3.m | 13 + Task/Rot-13/MATLAB/rot-13-4.m | 11 + Task/Rot-13/MMIX/rot-13.mmix | 35 ++ Task/Rot-13/MUMPS/rot-13.mumps | 9 + Task/Rot-13/Maple/rot-13.maple | 2 + Task/Rot-13/Mathematica/rot-13.math | 6 + Task/Rot-13/Maxima/rot-13.maxima | 19 + Task/Rot-13/Mirah/rot-13.mirah | 18 + Task/Rot-13/Modula-3/rot-13.mod3 | 19 + Task/Rot-13/NetRexx/rot-13.netrexx | 94 +++ Task/Rot-13/OCaml/rot-13-1.ocaml | 4 + Task/Rot-13/OCaml/rot-13-2.ocaml | 11 + Task/Rot-13/OCaml/rot-13-3.ocaml | 5 + Task/Rot-13/Objeck/rot-13.objeck | 25 + Task/Rot-13/Oz/rot-13.oz | 14 + Task/Rot-13/PARI-GP/rot-13.pari | 7 + Task/Rot-13/PHP/rot-13-1.php | 1 + Task/Rot-13/PHP/rot-13-2.php | 8 + Task/Rot-13/PL-I/rot-13.pli | 17 + Task/Rot-13/Pascal/rot-13.pascal | 29 + Task/Rot-13/Perl-6/rot-13.pl6 | 4 + Task/Rot-13/Perl/rot-13-1.pl | 7 + Task/Rot-13/Perl/rot-13-2.pl | 1 + Task/Rot-13/PicoLisp/rot-13-1.l | 7 + Task/Rot-13/PicoLisp/rot-13-2.l | 7 + Task/Rot-13/PicoLisp/rot-13-3.l | 3 + Task/Rot-13/Pike/rot-13.pike | 6 + Task/Rot-13/Pop11/rot-13.pop11 | 14 + Task/Rot-13/PostScript/rot-13.ps | 10 + Task/Rot-13/PowerShell/rot-13.psh | 10 + Task/Rot-13/Prolog/rot-13-1.pro | 7 + Task/Rot-13/Prolog/rot-13-2.pro | 2 + Task/Rot-13/PureBasic/rot-13.purebasic | 29 + Task/Rot-13/Python/rot-13-1.py | 21 + Task/Rot-13/Python/rot-13-2.py | 21 + Task/Rot-13/R/rot-13.r | 10 + Task/Rot-13/REBOL/rot-13.rebol | 84 +++ Task/Rot-13/REXX/rot-13.rexx | 30 + Task/Rot-13/Racket/rot-13.rkt | 17 + Task/Rot-13/Retro/rot-13.retro | 11 + Task/Rot-13/Ruby/rot-13.rb | 9 + Task/Rot-13/Run-BASIC/rot-13.run | 14 + Task/Rot-13/SNOBOL4/rot-13.sno | 21 + Task/Rot-13/Scala/rot-13.scala | 12 + Task/Rot-13/Scheme/rot-13.ss | 14 + Task/Rot-13/Seed7/rot-13.seed7 | 17 + Task/Rot-13/Slate/rot-13-1.slate | 23 + Task/Rot-13/Slate/rot-13-2.slate | 22 + Task/Rot-13/Smalltalk/rot-13.st | 74 +++ Task/Rot-13/Standard-ML/rot-13.ml | 9 + Task/Rot-13/TI-83-BASIC/rot-13.ti-83 | 13 + Task/Rot-13/TXR/rot-13.txr | 15 + Task/Rot-13/Tcl/rot-13-1.tcl | 8 + Task/Rot-13/Tcl/rot-13-2.tcl | 4 + Task/Rot-13/TorqueScript/rot-13.torquescript | 22 + Task/Rot-13/UNIX-Shell/rot-13.sh | 6 + Task/Rot-13/Unlambda/rot-13.unlambda | 10 + Task/Rot-13/Ursala/rot-13.ursala | 5 + Task/Rot-13/Vedit-macro-language/rot-13.vedit | 2 + Task/Rot-13/Visual-Basic-.NET/rot-13.visual | 23 + Task/Rot-13/X86-Assembly/rot-13.x86 | 54 ++ Task/Rot-13/XPL0/rot-13.xpl0 | 7 + Task/Rot-13/XSLT/rot-13.xslt | 11 + Task/Rot-13/ZX-Spectrum-Basic/rot-13.zx | 18 + Task/Run-length-encoding/0DESCRIPTION | 8 + Task/Run-length-encoding/1META.yaml | 2 + .../ALGOL-68/run-length-encoding.alg | 72 +++ .../APL/run-length-encoding.apl | 4 + .../AWK/run-length-encoding-1.awk | 16 + .../AWK/run-length-encoding-2.awk | 13 + .../Ada/run-length-encoding.ada | 48 ++ .../AutoHotkey/run-length-encoding.ahk | 35 ++ .../BASIC/run-length-encoding.basic | 55 ++ .../BBC-BASIC/run-length-encoding.bbc | 36 ++ .../Bracmat/run-length-encoding.bracmat | 21 + .../Burlesque/run-length-encoding.blq | 2 + .../C++/run-length-encoding.cpp | 53 ++ .../C/run-length-encoding.c | 147 +++++ .../Clojure/run-length-encoding.clj | 7 + .../run-length-encoding-1.coffeescript | 11 + .../run-length-encoding-2.coffeescript | 8 + .../Common-Lisp/run-length-encoding.lisp | 23 + .../D/run-length-encoding-1.d | 13 + .../D/run-length-encoding-2.d | 53 ++ .../D/run-length-encoding-3.d | 79 +++ .../D/run-length-encoding-4.d | 32 ++ .../E/run-length-encoding-1.e | 28 + .../E/run-length-encoding-2.e | 5 + .../Erlang/run-length-encoding.erl | 46 ++ .../Euphoria/run-length-encoding.euphoria | 38 ++ .../FALSE/run-length-encoding-1.false | 1 + .../FALSE/run-length-encoding-2.false | 2 + .../Fan/run-length-encoding.fan | 47 ++ .../Forth/run-length-encoding-1.fth | 15 + .../Forth/run-length-encoding-2.fth | 3 + .../Fortran/run-length-encoding.f | 73 +++ .../Go/run-length-encoding.go | 71 +++ .../Groovy/run-length-encoding-1.groovy | 15 + .../Groovy/run-length-encoding-2.groovy | 7 + .../Haskell/run-length-encoding.hs | 24 + .../Icon/run-length-encoding.icon | 27 + .../J/run-length-encoding-1.j | 2 + .../J/run-length-encoding-2.j | 5 + .../Java/run-length-encoding-1.java | 38 ++ .../Java/run-length-encoding-2.java | 32 ++ .../JavaScript/run-length-encoding-1.js | 15 + .../JavaScript/run-length-encoding-2.js | 5 + .../JavaScript/run-length-encoding-3.js | 5 + .../K/run-length-encoding-1.k | 1 + .../K/run-length-encoding-2.k | 1 + .../K/run-length-encoding-3.k | 4 + .../Liberty-BASIC/run-length-encoding.liberty | 48 ++ .../Logo/run-length-encoding.logo | 18 + .../Lua/run-length-encoding.lua | 31 + .../MMIX/run-length-encoding.mmix | 110 ++++ .../Mathematica/run-length-encoding-1.math | 2 + .../Mathematica/run-length-encoding-2.math | 4 + .../Mathematica/run-length-encoding-3.math | 3 + .../Mathematica/run-length-encoding-4.math | 8 + .../Maxima/run-length-encoding.maxima | 9 + .../OCaml/run-length-encoding-1.ocaml | 23 + .../OCaml/run-length-encoding-2.ocaml | 7 + .../OCaml/run-length-encoding-3.ocaml | 17 + .../Oz/run-length-encoding.oz | 37 ++ .../PARI-GP/run-length-encoding.pari | 31 + .../PHP/run-length-encoding.php | 12 + .../PL-I/run-length-encoding.pli | 38 ++ .../Pascal/run-length-encoding.pascal | 51 ++ .../Perl-6/run-length-encoding.pl6 | 7 + .../Perl/run-length-encoding-1.pl | 13 + .../Perl/run-length-encoding-2.pl | 14 + .../PicoLisp/run-length-encoding.l | 23 + .../PowerBASIC/run-length-encoding.powerbasic | 52 ++ .../PowerShell/run-length-encoding.psh | 18 + .../Prolog/run-length-encoding.pro | 108 ++++ .../Pure/run-length-encoding.pure | 15 + .../PureBasic/run-length-encoding.purebasic | 66 +++ .../Python/run-length-encoding-1.py | 29 + .../Python/run-length-encoding-2.py | 9 + .../Python/run-length-encoding-3.py | 22 + .../R/run-length-encoding-1.r | 9 + .../R/run-length-encoding-2.r | 11 + .../REXX/run-length-encoding-1.rexx | 23 + .../REXX/run-length-encoding-2.rexx | 24 + .../Ruby/run-length-encoding-1.rb | 14 + .../Ruby/run-length-encoding-2.rb | 15 + .../Ruby/run-length-encoding-3.rb | 10 + .../Run-BASIC/run-length-encoding.run | 26 + .../SNOBOL4/run-length-encoding.sno | 19 + .../Scala/run-length-encoding-1.scala | 13 + .../Scala/run-length-encoding-2.scala | 4 + .../Scheme/run-length-encoding.ss | 15 + .../Seed7/run-length-encoding.seed7 | 36 ++ .../Standard-ML/run-length-encoding.ml | 17 + .../TUSCRIPT/run-length-encoding.tuscript | 9 + .../Tcl/run-length-encoding-1.tcl | 15 + .../Tcl/run-length-encoding-2.tcl | 6 + .../Ursala/run-length-encoding.ursala | 16 + .../run-length-encoding.vedit | 31 + .../XPL0/run-length-encoding.xpl0 | 41 ++ .../0DESCRIPTION | 11 + .../runtime-evaluation-in-an-environment.alg | 3 + .../runtime-evaluation-in-an-environment.ahk | 32 ++ .../runtime-evaluation-in-an-environment.bbc | 8 + ...untime-evaluation-in-an-environment-1.lisp | 4 + ...untime-evaluation-in-an-environment-2.lisp | 2 + ...untime-evaluation-in-an-environment-3.lisp | 5 + .../runtime-evaluation-in-an-environment-1.e | 15 + .../runtime-evaluation-in-an-environment-2.e | 2 + ...runtime-evaluation-in-an-environment-1.fth | 7 + ...runtime-evaluation-in-an-environment-2.fth | 15 + ...ime-evaluation-in-an-environment-1.genyris | 7 + ...ime-evaluation-in-an-environment-2.genyris | 8 + ...ime-evaluation-in-an-environment-3.genyris | 4 + .../runtime-evaluation-in-an-environment.go | 67 +++ ...time-evaluation-in-an-environment-1.groovy | 3 + ...time-evaluation-in-an-environment-2.groovy | 5 + .../runtime-evaluation-in-an-environment-1.j | 7 + .../runtime-evaluation-in-an-environment-2.j | 2 + .../runtime-evaluation-in-an-environment-3.j | 3 + .../runtime-evaluation-in-an-environment-4.j | 2 + .../runtime-evaluation-in-an-environment-5.j | 4 + .../runtime-evaluation-in-an-environment-6.j | 4 + .../runtime-evaluation-in-an-environment.java | 2 + .../runtime-evaluation-in-an-environment-1.js | 7 + .../runtime-evaluation-in-an-environment-2.js | 1 + ...ntime-evaluation-in-an-environment.liberty | 7 + .../runtime-evaluation-in-an-environment.lua | 4 + .../runtime-evaluation-in-an-environment.math | 3 + ...time-evaluation-in-an-environment.metafont | 7 + ...untime-evaluation-in-an-environment.octave | 10 + .../runtime-evaluation-in-an-environment.oz | 8 + .../runtime-evaluation-in-an-environment.pari | 2 + .../runtime-evaluation-in-an-environment.php | 11 + .../runtime-evaluation-in-an-environment.pl6 | 9 + .../runtime-evaluation-in-an-environment.pl | 8 + .../runtime-evaluation-in-an-environment.l | 12 + ...untime-evaluation-in-an-environment-1.pike | 11 + ...untime-evaluation-in-an-environment-2.pike | 8 + .../runtime-evaluation-in-an-environment-1.py | 5 + .../runtime-evaluation-in-an-environment-2.py | 9 + .../R/runtime-evaluation-in-an-environment.r | 15 + ...runtime-evaluation-in-an-environment.rebol | 5 + .../runtime-evaluation-in-an-environment.rexx | 9 + .../runtime-evaluation-in-an-environment.rb | 9 + ...runtime-evaluation-in-an-environment-1.sno | 6 + ...runtime-evaluation-in-an-environment-2.sno | 6 + .../runtime-evaluation-in-an-environment.ss | 4 + ...runtime-evaluation-in-an-environment.ti-89 | 12 + ...runtime-evaluation-in-an-environment-1.tcl | 9 + ...runtime-evaluation-in-an-environment-2.tcl | 4 + .../runtime-evaluation-in-an-environment.sh | 15 + Task/Runtime-evaluation/0DESCRIPTION | 5 + .../ALGOL-68/runtime-evaluation.alg | 1 + .../AutoHotkey/runtime-evaluation.ahk | 32 ++ .../BASIC/runtime-evaluation.basic | 2 + .../BBC-BASIC/runtime-evaluation-1.bbc | 2 + .../BBC-BASIC/runtime-evaluation-2.bbc | 16 + .../Burlesque/runtime-evaluation-1.blq | 2 + .../Burlesque/runtime-evaluation-2.blq | 4 + .../Burlesque/runtime-evaluation-3.blq | 2 + .../Burlesque/runtime-evaluation-4.blq | 2 + .../Burlesque/runtime-evaluation-5.blq | 2 + .../Burlesque/runtime-evaluation-6.blq | 8 + .../Common-Lisp/runtime-evaluation-1.lisp | 1 + .../Common-Lisp/runtime-evaluation-2.lisp | 2 + .../Common-Lisp/runtime-evaluation-3.lisp | 2 + .../Common-Lisp/runtime-evaluation-4.lisp | 1 + .../Common-Lisp/runtime-evaluation-5.lisp | 3 + .../Common-Lisp/runtime-evaluation-6.lisp | 2 + .../Common-Lisp/runtime-evaluation-7.lisp | 1 + .../Common-Lisp/runtime-evaluation-8.lisp | 1 + .../E/runtime-evaluation-1.e | 2 + .../E/runtime-evaluation-2.e | 5 + .../E/runtime-evaluation-3.e | 5 + .../Erlang/runtime-evaluation.erl | 8 + .../Forth/runtime-evaluation-1.fth | 4 + .../Forth/runtime-evaluation-2.fth | 10 + .../GW-BASIC/runtime-evaluation.gw-basic | 10 + .../Go/runtime-evaluation.go | 25 + .../Groovy/runtime-evaluation-1.groovy | 7 + .../Groovy/runtime-evaluation-2.groovy | 9 + .../Groovy/runtime-evaluation-3.groovy | 8 + .../Groovy/runtime-evaluation-4.groovy | 7 + .../Groovy/runtime-evaluation-5.groovy | 8 + .../Groovy/runtime-evaluation-6.groovy | 7 + .../HicEst/runtime-evaluation.hicest | 8 + .../J/runtime-evaluation-1.j | 1 + .../J/runtime-evaluation-2.j | 1 + .../JavaScript/runtime-evaluation.js | 5 + .../runtime-evaluation-1.liberty | 20 + .../runtime-evaluation-2.liberty | 14 + .../Lua/runtime-evaluation.lua | 5 + .../Maxima/runtime-evaluation.maxima | 17 + .../OxygenBasic/runtime-evaluation.oxy | 50 ++ .../Oz/runtime-evaluation.oz | 17 + .../PHP/runtime-evaluation.php | 5 + .../Perl-6/runtime-evaluation.pl6 | 2 + .../Perl/runtime-evaluation.pl | 2 + .../Pike/runtime-evaluation.pike | 9 + .../Python/runtime-evaluation-1.py | 5 + .../Python/runtime-evaluation-2.py | 5 + .../R/runtime-evaluation-1.r | 3 + .../R/runtime-evaluation-2.r | 3 + .../R/runtime-evaluation-3.r | 11 + .../REXX/runtime-evaluation.rexx | 22 + .../Ruby/runtime-evaluation-1.rb | 2 + .../Ruby/runtime-evaluation-2.rb | 18 + .../SNOBOL4/runtime-evaluation-1.sno | 4 + .../SNOBOL4/runtime-evaluation-2.sno | 2 + .../Scheme/runtime-evaluation.ss | 12 + .../Slate/runtime-evaluation-1.slate | 2 + .../Slate/runtime-evaluation-2.slate | 1 + .../Slate/runtime-evaluation-3.slate | 2 + .../Slate/runtime-evaluation-4.slate | 2 + .../Slate/runtime-evaluation-5.slate | 2 + .../Smalltalk/runtime-evaluation-1.st | 1 + .../Smalltalk/runtime-evaluation-2.st | 2 + .../Smalltalk/runtime-evaluation-3.st | 2 + .../Tcl/runtime-evaluation-1.tcl | 4 + .../Tcl/runtime-evaluation-2.tcl | 21 + .../Tcl/runtime-evaluation-3.tcl | 8 + Task/S-Expressions/0DESCRIPTION | 21 + Task/S-Expressions/1META.yaml | 2 + Task/S-Expressions/Ada/s-expressions-1.ada | 55 ++ Task/S-Expressions/Ada/s-expressions-2.ada | 55 ++ Task/S-Expressions/Ada/s-expressions-3.ada | 7 + Task/S-Expressions/Ada/s-expressions-4.ada | 110 ++++ Task/S-Expressions/Ada/s-expressions-5.ada | 23 + Task/S-Expressions/C/s-expressions-1.c | 226 ++++++++ Task/S-Expressions/C/s-expressions-2.c | 24 + .../CoffeeScript/s-expressions-1.coffeescript | 130 +++++ .../CoffeeScript/s-expressions-2.coffeescript | 29 + .../Common-Lisp/s-expressions-1.lisp | 5 + .../Common-Lisp/s-expressions-2.lisp | 16 + .../Common-Lisp/s-expressions-3.lisp | 24 + .../Common-Lisp/s-expressions-4.lisp | 7 + Task/S-Expressions/D/s-expressions.d | 90 +++ Task/S-Expressions/Go/s-expressions.go | 174 ++++++ Task/S-Expressions/Haskell/s-expressions.hs | 49 ++ Task/S-Expressions/Icon/s-expressions.icon | 60 ++ Task/S-Expressions/J/s-expressions-1.j | 52 ++ Task/S-Expressions/J/s-expressions-2.j | 12 + Task/S-Expressions/Java/s-expressions-1.java | 111 ++++ Task/S-Expressions/Java/s-expressions-2.java | 29 + Task/S-Expressions/Java/s-expressions-3.java | 17 + Task/S-Expressions/Java/s-expressions-4.java | 20 + Task/S-Expressions/Java/s-expressions-5.java | 71 +++ Task/S-Expressions/Java/s-expressions-6.java | 47 ++ Task/S-Expressions/Java/s-expressions-7.java | 26 + .../S-Expressions/OCaml/s-expressions-1.ocaml | 29 + .../S-Expressions/OCaml/s-expressions-2.ocaml | 178 ++++++ Task/S-Expressions/Perl-6/s-expressions.pl6 | 43 ++ Task/S-Expressions/Perl/s-expressions-1.pl | 34 ++ Task/S-Expressions/Perl/s-expressions-2.pl | 13 + Task/S-Expressions/PicoLisp/s-expressions-1.l | 21 + Task/S-Expressions/PicoLisp/s-expressions-2.l | 26 + Task/S-Expressions/PicoLisp/s-expressions-3.l | 2 + Task/S-Expressions/PicoLisp/s-expressions-4.l | 2 + Task/S-Expressions/PicoLisp/s-expressions-5.l | 14 + Task/S-Expressions/PicoLisp/s-expressions-6.l | 4 + Task/S-Expressions/PicoLisp/s-expressions-7.l | 6 + Task/S-Expressions/Pike/s-expressions.pike | 106 ++++ Task/S-Expressions/Python/s-expressions-1.py | 60 ++ Task/S-Expressions/Python/s-expressions-2.py | 23 + Task/S-Expressions/REXX/s-expressions.rexx | 75 +++ Task/S-Expressions/Racket/s-expressions.rkt | 9 + Task/S-Expressions/Ruby/s-expressions.rb | 124 ++++ Task/S-Expressions/Scheme/s-expressions.ss | 9 + Task/S-Expressions/Tcl/s-expressions-1.tcl | 49 ++ Task/S-Expressions/Tcl/s-expressions-2.tcl | 6 + Task/SEDOLs/0DESCRIPTION | 28 + Task/SEDOLs/1META.yaml | 2 + Task/SEDOLs/ALGOL-68/sedols.alg | 58 ++ Task/SEDOLs/AWK/sedols.awk | 49 ++ Task/SEDOLs/ActionScript/sedols.as | 50 ++ Task/SEDOLs/Ada/sedols.ada | 40 ++ Task/SEDOLs/AutoHotkey/sedols.ahk | 17 + Task/SEDOLs/BASIC/sedols.basic | 31 + Task/SEDOLs/BBC-BASIC/sedols.bbc | 21 + Task/SEDOLs/C++/sedols.cpp | 52 ++ Task/SEDOLs/C/sedols.c | 48 ++ Task/SEDOLs/Common-Lisp/sedols.lisp | 12 + Task/SEDOLs/D/sedols-1.d | 20 + Task/SEDOLs/D/sedols-2.d | 35 ++ Task/SEDOLs/D/sedols-3.d | 12 + Task/SEDOLs/E/sedols.e | 37 ++ Task/SEDOLs/Forth/sedols.fth | 28 + Task/SEDOLs/Fortran/sedols.f | 43 ++ Task/SEDOLs/Go/sedols.go | 62 ++ Task/SEDOLs/Groovy/sedols-1.groovy | 10 + Task/SEDOLs/Groovy/sedols-2.groovy | 6 + Task/SEDOLs/Haskell/sedols.hs | 22 + Task/SEDOLs/Icon/sedols.icon | 19 + Task/SEDOLs/J/sedols-1.j | 2 + Task/SEDOLs/J/sedols-2.j | 1 + Task/SEDOLs/J/sedols-3.j | 1 + Task/SEDOLs/J/sedols-4.j | 1 + Task/SEDOLs/Java/sedols.java | 31 + Task/SEDOLs/JavaScript/sedols.js | 41 ++ Task/SEDOLs/Liberty-BASIC/sedols.liberty | 31 + Task/SEDOLs/M4/sedols.m4 | 17 + Task/SEDOLs/MUMPS/sedols.mumps | 21 + Task/SEDOLs/Mathematica/sedols.math | 19 + Task/SEDOLs/Mercury/sedols.mercury | 53 ++ Task/SEDOLs/Modula-3/sedols.mod3 | 44 ++ Task/SEDOLs/OCaml/sedols.ocaml | 29 + Task/SEDOLs/PHP/sedols.php | 26 + Task/SEDOLs/PL-I/sedols.pli | 23 + Task/SEDOLs/Pascal/sedols.pascal | 45 ++ Task/SEDOLs/Perl-6/sedols.pl6 | 26 + Task/SEDOLs/Perl/sedols.pl | 26 + Task/SEDOLs/PicoLisp/sedols.l | 21 + Task/SEDOLs/PureBasic/sedols.purebasic | 40 ++ Task/SEDOLs/Python/sedols.py | 25 + Task/SEDOLs/R/sedols.r | 37 ++ Task/SEDOLs/REXX/sedols.rexx | 53 ++ Task/SEDOLs/Racket/sedols.rkt | 63 ++ Task/SEDOLs/Ruby/sedols.rb | 28 + Task/SEDOLs/Scala/sedols.scala | 7 + Task/SEDOLs/Seed7/sedols.seed7 | 35 ++ Task/SEDOLs/Smalltalk/sedols-1.st | 6 + Task/SEDOLs/Smalltalk/sedols-2.st | 43 ++ Task/SEDOLs/Smalltalk/sedols-3.st | 12 + Task/SEDOLs/Standard-ML/sedols.ml | 26 + Task/SEDOLs/TUSCRIPT/sedols.tuscript | 20 + Task/SEDOLs/Tcl/sedols.tcl | 38 ++ Task/SEDOLs/Ursala/sedols-1.ursala | 8 + Task/SEDOLs/Ursala/sedols-2.ursala | 2 + Task/SEDOLs/Ursala/sedols-3.ursala | 2 + Task/SEDOLs/Ursala/sedols-4.ursala | 2 + Task/SEDOLs/Ursala/sedols-5.ursala | 15 + Task/Safe-addition/0DESCRIPTION | 8 + Task/Safe-addition/1META.yaml | 2 + Task/Safe-addition/Ada/safe-addition-1.ada | 4 + Task/Safe-addition/Ada/safe-addition-2.ada | 19 + Task/Safe-addition/Ada/safe-addition-3.ada | 10 + Task/Safe-addition/C/safe-addition-1.c | 50 ++ Task/Safe-addition/C/safe-addition-2.c | 49 ++ Task/Safe-addition/C/safe-addition-3.c | 49 ++ Task/Safe-addition/E/safe-addition-1.e | 17 + Task/Safe-addition/E/safe-addition-2.e | 2 + Task/Safe-addition/Go/safe-addition.go | 30 + Task/Safe-addition/J/safe-addition.j | 4 + Task/Safe-addition/Python/safe-addition.py | 5 + Task/Safe-addition/REXX/safe-addition.rexx | 5 + Task/Safe-addition/Ruby/safe-addition.rb | 23 + Task/Safe-addition/Tcl/safe-addition-1.tcl | 12 + Task/Safe-addition/Tcl/safe-addition-2.tcl | 5 + Task/Same-Fringe/0DESCRIPTION | 5 + Task/Same-Fringe/Ada/same-fringe-1.ada | 26 + Task/Same-Fringe/Ada/same-fringe-2.ada | 52 ++ Task/Same-Fringe/Ada/same-fringe-3.ada | 11 + Task/Same-Fringe/Ada/same-fringe-4.ada | 23 + Task/Same-Fringe/Ada/same-fringe-5.ada | 162 ++++++ Task/Same-Fringe/C/same-fringe.c | 121 ++++ Task/Same-Fringe/D/same-fringe-1.d | 22 + Task/Same-Fringe/D/same-fringe-2.d | 194 +++++++ Task/Same-Fringe/Go/same-fringe.go | 71 +++ Task/Same-Fringe/Haskell/same-fringe.hs | 24 + Task/Same-Fringe/J/same-fringe-1.j | 1 + Task/Same-Fringe/J/same-fringe-2.j | 1 + Task/Same-Fringe/J/same-fringe-3.j | 2 + Task/Same-Fringe/J/same-fringe-4.j | 4 + Task/Same-Fringe/Java/same-fringe.java | 121 ++++ Task/Same-Fringe/OCaml/same-fringe.ocaml | 23 + Task/Same-Fringe/Perl-6/same-fringe-1.pl6 | 8 + Task/Same-Fringe/Perl-6/same-fringe-2.pl6 | 15 + Task/Same-Fringe/PicoLisp/same-fringe-1.l | 19 + Task/Same-Fringe/PicoLisp/same-fringe-2.l | 27 + Task/Same-Fringe/Python/same-fringe.py | 35 ++ Task/Same-Fringe/REXX/same-fringe-1.rexx | 176 ++++++ Task/Same-Fringe/REXX/same-fringe-2.rexx | 139 +++++ Task/Same-Fringe/REXX/same-fringe-3.rexx | 87 +++ Task/Same-Fringe/Racket/same-fringe.rkt | 30 + Task/Same-Fringe/Tcl/same-fringe-1.tcl | 33 ++ Task/Same-Fringe/Tcl/same-fringe-2.tcl | 20 + .../0DESCRIPTION | 5 + .../1META.yaml | 4 + .../AWK/scope-function-names-and-labels.awk | 9 + .../scope-function-names-and-labels-1.basic | 1 + .../scope-function-names-and-labels-2.basic | 8 + .../scope-function-names-and-labels.pl6 | 53 ++ .../REXX/scope-function-names-and-labels.rexx | 13 + .../Tcl/scope-function-names-and-labels.tcl | 6 + .../scope-function-names-and-labels.sh | 10 + .../scope-function-names-and-labels.zx | 5 + Task/Scope-modifiers/0DESCRIPTION | 3 + Task/Scope-modifiers/1META.yaml | 2 + .../Scope-modifiers/Ada/scope-modifiers-1.ada | 5 + .../Scope-modifiers/Ada/scope-modifiers-2.ada | 11 + .../Scope-modifiers/Ada/scope-modifiers-3.ada | 4 + .../Scope-modifiers/Ada/scope-modifiers-4.ada | 5 + .../AutoHotkey/scope-modifiers.ahk | 25 + .../BBC-BASIC/scope-modifiers.bbc | 33 ++ Task/Scope-modifiers/C/scope-modifiers-1.c | 24 + Task/Scope-modifiers/C/scope-modifiers-2.c | 8 + .../Common-Lisp/scope-modifiers.lisp | 12 + .../Delphi/scope-modifiers-1.delphi | 1 + .../Delphi/scope-modifiers-2.delphi | 1 + .../Delphi/scope-modifiers-3.delphi | 1 + .../Delphi/scope-modifiers-4.delphi | 1 + .../Delphi/scope-modifiers-5.delphi | 1 + .../Delphi/scope-modifiers-6.delphi | 2 + Task/Scope-modifiers/Ela/scope-modifiers.ela | 5 + .../Scope-modifiers/Icon/scope-modifiers.icon | 6 + Task/Scope-modifiers/J/scope-modifiers.j | 17 + .../Scope-modifiers/Java/scope-modifiers.java | 35 ++ .../Scope-modifiers/Logo/scope-modifiers.logo | 15 + .../MUMPS/scope-modifiers.mumps | 15 + .../Mathematica/scope-modifiers.math | 19 + .../Perl-6/scope-modifiers-1.pl6 | 4 + .../Perl-6/scope-modifiers-2.pl6 | 13 + .../Scope-modifiers/Perl/scope-modifiers-1.pl | 9 + .../Scope-modifiers/Perl/scope-modifiers-2.pl | 13 + .../Scope-modifiers/Perl/scope-modifiers-3.pl | 10 + .../Scope-modifiers/Perl/scope-modifiers-4.pl | 17 + .../PowerShell/scope-modifiers.psh | 6 + .../PureBasic/scope-modifiers.purebasic | 32 ++ .../Scope-modifiers/Python/scope-modifiers.py | 30 + Task/Scope-modifiers/R/scope-modifiers-1.r | 7 + Task/Scope-modifiers/R/scope-modifiers-2.r | 5 + Task/Scope-modifiers/R/scope-modifiers-3.r | 37 ++ Task/Scope-modifiers/R/scope-modifiers-4.r | 11 + Task/Scope-modifiers/R/scope-modifiers-5.r | 12 + .../Scope-modifiers/REXX/scope-modifiers.rexx | 23 + .../TI-89-BASIC/scope-modifiers.ti-89 | 3 + .../Scope-modifiers/TXR/scope-modifiers-1.txr | 6 + .../Scope-modifiers/TXR/scope-modifiers-2.txr | 6 + .../Scope-modifiers/Tcl/scope-modifiers-1.tcl | 18 + .../Scope-modifiers/Tcl/scope-modifiers-2.tcl | 11 + .../Scope-modifiers/Tcl/scope-modifiers-3.tcl | 4 + .../Scope-modifiers/Tcl/scope-modifiers-4.tcl | 3 + .../Scope-modifiers/Tcl/scope-modifiers-5.tcl | 15 + .../Ursala/scope-modifiers-1.ursala | 11 + .../Ursala/scope-modifiers-2.ursala | 10 + .../Ursala/scope-modifiers-3.ursala | 13 + .../Ursala/scope-modifiers-4.ursala | 4 + Task/Secure-temporary-file/0DESCRIPTION | 1 + Task/Secure-temporary-file/1META.yaml | 2 + .../Ada/secure-temporary-file.ada | 14 + .../BBC-BASIC/secure-temporary-file.bbc | 27 + .../C/secure-temporary-file-1.c | 14 + .../C/secure-temporary-file-2.c | 12 + .../Clojure/secure-temporary-file.clj | 2 + .../D/secure-temporary-file.d | 15 + .../Go/secure-temporary-file.go | 3 + .../Groovy/secure-temporary-file.groovy | 3 + .../Haskell/secure-temporary-file.hs | 5 + .../HicEst/secure-temporary-file.hicest | 12 + .../Java/secure-temporary-file.java | 13 + .../Lua/secure-temporary-file.lua | 5 + .../Mathematica/secure-temporary-file.math | 2 + .../OCaml/secure-temporary-file.ocaml | 2 + .../Octave/secure-temporary-file.octave | 3 + .../PHP/secure-temporary-file.php | 9 + .../Pascal/secure-temporary-file.pascal | 14 + .../Perl/secure-temporary-file-1.pl | 6 + .../Perl/secure-temporary-file-2.pl | 4 + .../PicoLisp/secure-temporary-file.l | 11 + .../PureBasic/secure-temporary-file.purebasic | 25 + .../Python/secure-temporary-file-1.py | 9 + .../Python/secure-temporary-file-2.py | 5 + .../Racket/secure-temporary-file.rkt | 2 + .../Ruby/secure-temporary-file.rb | 8 + .../Scala/secure-temporary-file.scala | 14 + .../Standard-ML/secure-temporary-file.ml | 1 + .../TUSCRIPT/secure-temporary-file.tuscript | 6 + .../Tcl/secure-temporary-file.tcl | 1 + .../UNIX-Shell/secure-temporary-file.sh | 13 + Task/Self-describing-numbers/0DESCRIPTION | 14 + .../AWK/self-describing-numbers.awk | 17 + .../Ada/self-describing-numbers.ada | 25 + .../AutoHotkey/self-describing-numbers.ahk | 23 + .../BASIC/self-describing-numbers.basic | 24 + .../BBC-BASIC/self-describing-numbers.bbc | 16 + .../C/self-describing-numbers-1.c | 45 ++ .../C/self-describing-numbers-2.c | 15 + .../C/self-describing-numbers-3.c | 26 + .../C/self-describing-numbers-4.c | 5 + .../D/self-describing-numbers-1.d | 10 + .../D/self-describing-numbers-2.d | 42 ++ .../Erlang/self-describing-numbers.erl | 2 + .../Forth/self-describing-numbers.fth | 16 + .../Go/self-describing-numbers.go | 30 + .../Haskell/self-describing-numbers-1.hs | 16 + .../Haskell/self-describing-numbers-2.hs | 21 + .../Icon/self-describing-numbers-1.icon | 28 + .../Icon/self-describing-numbers-2.icon | 11 + .../J/self-describing-numbers-1.j | 3 + .../J/self-describing-numbers-2.j | 2 + .../J/self-describing-numbers-3.j | 2 + .../Java/self-describing-numbers.java | 27 + .../JavaScript/self-describing-numbers.js | 28 + .../Julia/self-describing-numbers.julia | 11 + .../K/self-describing-numbers.k | 6 + .../self-describing-numbers.liberty | 19 + .../Logo/self-describing-numbers.logo | 26 + .../Lua/self-describing-numbers.lua | 21 + .../MATLAB/self-describing-numbers-1.m | 5 + .../MATLAB/self-describing-numbers-2.m | 5 + .../Mathematica/self-describing-numbers.math | 1 + .../PARI-GP/self-describing-numbers.pari | 2 + .../Pascal/self-describing-numbers.pascal | 43 ++ .../Perl-6/self-describing-numbers.pl6 | 18 + .../Perl/self-describing-numbers.pl | 12 + .../PicoLisp/self-describing-numbers.l | 5 + .../Prolog/self-describing-numbers.pro | 107 ++++ .../self-describing-numbers.purebasic | 73 +++ .../Python/self-describing-numbers-1.py | 8 + .../Python/self-describing-numbers-2.py | 11 + .../REXX/self-describing-numbers-1.rexx | 39 ++ .../REXX/self-describing-numbers-2.rexx | 21 + .../REXX/self-describing-numbers-3.rexx | 23 + .../Ruby/self-describing-numbers.rb | 14 + .../Run-BASIC/self-describing-numbers.run | 17 + .../Seed7/self-describing-numbers.seed7 | 66 +++ .../Tcl/self-describing-numbers.tcl | 16 + .../XPL0/self-describing-numbers.xpl0 | 35 ++ Task/Self-referential-sequence/0DESCRIPTION | 48 ++ .../Ada/self-referential-sequence.ada | 62 ++ .../AutoHotkey/self-referential-sequence.ahk | 33 ++ .../BBC-BASIC/self-referential-sequence.bbc | 41 ++ .../Bracmat/self-referential-sequence.bracmat | 72 +++ .../C/self-referential-sequence.c | 123 ++++ .../self-referential-sequence.coffeescript | 42 ++ .../self-referential-sequence-1.lisp | 29 + .../self-referential-sequence-2.lisp | 22 + .../D/self-referential-sequence-1.d | 37 ++ .../D/self-referential-sequence-2.d | 176 ++++++ .../D/self-referential-sequence-3.d | 139 +++++ .../Go/self-referential-sequence.go | 75 +++ .../Haskell/self-referential-sequence.hs | 25 + .../Icon/self-referential-sequence-1.icon | 38 ++ .../Icon/self-referential-sequence-2.icon | 29 + .../J/self-referential-sequence-1.j | 6 + .../J/self-referential-sequence-2.j | 26 + .../J/self-referential-sequence-3.j | 4 + .../J/self-referential-sequence-4.j | 2 + .../self-referential-sequence.math | 6 + .../Perl-6/self-referential-sequence.pl6 | 47 ++ .../Perl/self-referential-sequence.pl | 39 ++ .../PicoLisp/self-referential-sequence.l | 16 + .../Python/self-referential-sequence.py | 65 +++ .../REXX/self-referential-sequence.rexx | 35 ++ .../Ruby/self-referential-sequence.rb | 37 ++ .../Tcl/self-referential-sequence.tcl | 49 ++ Task/Semordnilap/0DESCRIPTION | 8 + Task/Semordnilap/1META.yaml | 2 + Task/Semordnilap/AWK/semordnilap.awk | 20 + Task/Semordnilap/Ada/semordnilap-1.ada | 19 + Task/Semordnilap/Ada/semordnilap-2.ada | 35 ++ Task/Semordnilap/Ada/semordnilap-3.ada | 30 + Task/Semordnilap/BBC-BASIC/semordnilap.bbc | 50 ++ Task/Semordnilap/C++/semordnilap.cpp | 29 + Task/Semordnilap/C/semordnilap.c | 66 +++ Task/Semordnilap/D/semordnilap.d | 17 + Task/Semordnilap/Go/semordnilap.go | 58 ++ Task/Semordnilap/Groovy/semordnilap-1.groovy | 9 + Task/Semordnilap/Groovy/semordnilap-2.groovy | 3 + Task/Semordnilap/Haskell/semordnilap.hs | 10 + Task/Semordnilap/J/semordnilap-1.j | 4 + Task/Semordnilap/J/semordnilap-2.j | 12 + Task/Semordnilap/Java/semordnilap.java | 30 + Task/Semordnilap/Julia/semordnilap.julia | 4 + .../Liberty-BASIC/semordnilap.liberty | 44 ++ Task/Semordnilap/Mathematica/semordnilap.math | 3 + Task/Semordnilap/NetRexx/semordnilap.netrexx | 29 + Task/Semordnilap/OCaml/semordnilap.ocaml | 34 ++ Task/Semordnilap/PHP/semordnilap.php | 15 + Task/Semordnilap/PL-I/semordnilap.pli | 41 ++ Task/Semordnilap/Perl-6/semordnilap.pl6 | 8 + Task/Semordnilap/Perl/semordnilap.pl | 7 + Task/Semordnilap/Python/semordnilap-1.py | 11 + Task/Semordnilap/Python/semordnilap-2.py | 16 + Task/Semordnilap/REXX/semordnilap-1.rexx | 19 + Task/Semordnilap/REXX/semordnilap-2.rexx | 15 + Task/Semordnilap/Ruby/semordnilap.rb | 9 + .../Semordnilap/TUSCRIPT/semordnilap.tuscript | 23 + Task/Semordnilap/Tcl/semordnilap.tcl | 30 + Task/Semordnilap/XPL0/semordnilap.xpl0 | 60 ++ Task/Send-an-unknown-method-call/0DESCRIPTION | 5 + Task/Send-an-unknown-method-call/1META.yaml | 2 + .../send-an-unknown-method-call.ahk | 13 + .../E/send-an-unknown-method-call.e | 3 + .../Go/send-an-unknown-method-call-1.go | 24 + .../Go/send-an-unknown-method-call-2.go | 12 + .../Java/send-an-unknown-method-call.java | 18 + .../JavaScript/send-an-unknown-method-call.js | 7 + .../MATLAB/send-an-unknown-method-call.m | 5 + .../Objective-C/send-an-unknown-method-call.m | 23 + .../PARI-GP/send-an-unknown-method-call.pari | 2 + .../PHP/send-an-unknown-method-call.php | 15 + .../Perl-6/send-an-unknown-method-call.pl6 | 3 + .../Perl/send-an-unknown-method-call.pl | 12 + .../PicoLisp/send-an-unknown-method-call.l | 1 + .../Pike/send-an-unknown-method-call.pike | 3 + .../Python/send-an-unknown-method-call.py | 6 + .../Qi/send-an-unknown-method-call.qi | 6 + .../Ruby/send-an-unknown-method-call-1.rb | 14 + .../Ruby/send-an-unknown-method-call-2.rb | 11 + .../Smalltalk/send-an-unknown-method-call.st | 9 + .../Tcl/send-an-unknown-method-call.tcl | 14 + Task/Send-email/0DESCRIPTION | 6 + Task/Send-email/1META.yaml | 2 + Task/Send-email/Ada/send-email.ada | 27 + Task/Send-email/AutoHotkey/send-email.ahk | 37 ++ Task/Send-email/BBC-BASIC/send-email.bbc | 84 +++ Task/Send-email/C++/send-email.cpp | 46 ++ Task/Send-email/D/send-email.d | 10 + Task/Send-email/Delphi/send-email.delphi | 33 ++ Task/Send-email/Factor/send-email.factor | 14 + Task/Send-email/Fantom/send-email.fantom | 32 ++ Task/Send-email/Go/send-email.go | 161 ++++++ Task/Send-email/Java/send-email.java | 56 ++ .../Liberty-BASIC/send-email.liberty | 25 + .../LotusScript/send-email.lotusscript | 9 + Task/Send-email/Lua/send-email.lua | 31 + Task/Send-email/Mathematica/send-email-1.math | 3 + Task/Send-email/Mathematica/send-email-2.math | 15 + Task/Send-email/NewLISP/send-email.newlisp | 2 + Task/Send-email/OCaml/send-email.ocaml | 11 + Task/Send-email/PHP/send-email.php | 1 + Task/Send-email/Perl/send-email-1.pl | 33 ++ Task/Send-email/Perl/send-email-2.pl | 9 + Task/Send-email/Perl/send-email-3.pl | 3 + Task/Send-email/PicoLisp/send-email.l | 1 + Task/Send-email/Pike/send-email.pike | 8 + .../Send-email/PureBasic/send-email.purebasic | 15 + Task/Send-email/Python/send-email-1.py | 18 + Task/Send-email/Python/send-email-2.py | 7 + Task/Send-email/REBOL/send-email.rebol | 1 + Task/Send-email/Racket/send-email.rkt | 14 + Task/Send-email/Ruby/send-email.rb | 77 +++ Task/Send-email/SAS/send-email.sas | 10 + Task/Send-email/TUSCRIPT/send-email.tuscript | 14 + Task/Send-email/TXR/send-email.txr | 23 + Task/Send-email/Tcl/send-email.tcl | 23 + Task/Sequence-of-non-squares/0DESCRIPTION | 5 + Task/Sequence-of-non-squares/1META.yaml | 2 + .../ALGOL-68/sequence-of-non-squares.alg | 19 + .../AWK/sequence-of-non-squares.awk | 26 + .../Ada/sequence-of-non-squares.ada | 24 + .../AutoHotkey/sequence-of-non-squares.ahk | 8 + .../BASIC/sequence-of-non-squares.basic | 25 + .../BBC-BASIC/sequence-of-non-squares.bbc | 12 + .../Bc/sequence-of-non-squares.bc | 46 ++ .../Burlesque/sequence-of-non-squares.blq | 1 + .../C++/sequence-of-non-squares.cpp | 34 ++ .../C/sequence-of-non-squares.c | 24 + .../Clojure/sequence-of-non-squares.clj | 13 + .../sequence-of-non-squares-1.coffeescript | 19 + .../sequence-of-non-squares-2.coffeescript | 3 + .../Common-Lisp/sequence-of-non-squares.lisp | 16 + .../D/sequence-of-non-squares.d | 14 + .../Euphoria/sequence-of-non-squares.euphoria | 24 + .../Fantom/sequence-of-non-squares.fantom | 21 + .../Forth/sequence-of-non-squares.fth | 10 + .../Fortran/sequence-of-non-squares.f | 20 + .../GAP/sequence-of-non-squares.gap | 45 ++ .../Go/sequence-of-non-squares.go | 37 ++ .../Groovy/sequence-of-non-squares-1.groovy | 1 + .../Groovy/sequence-of-non-squares-2.groovy | 2 + .../Haskell/sequence-of-non-squares.hs | 2 + .../HicEst/sequence-of-non-squares.hicest | 13 + .../IDL/sequence-of-non-squares.idl | 4 + .../Icon/sequence-of-non-squares.icon | 15 + .../J/sequence-of-non-squares.j | 7 + .../Java/sequence-of-non-squares.java | 18 + .../sequence-of-non-squares.liberty | 21 + .../Logo/sequence-of-non-squares.logo | 1 + .../Lua/sequence-of-non-squares.lua | 1 + .../MATLAB/sequence-of-non-squares-1.m | 19 + .../MATLAB/sequence-of-non-squares-2.m | 3 + .../MMIX/sequence-of-non-squares.mmix | 87 +++ .../Mathematica/sequence-of-non-squares.math | 5 + .../Maxima/sequence-of-non-squares.maxima | 10 + .../Modula-3/sequence-of-non-squares.mod3 | 23 + .../OCaml/sequence-of-non-squares.ocaml | 15 + .../Oz/sequence-of-non-squares.oz | 17 + .../PARI-GP/sequence-of-non-squares.pari | 1 + .../PL-I/sequence-of-non-squares-1.pli | 2 + .../PL-I/sequence-of-non-squares-2.pli | 21 + .../PL-I/sequence-of-non-squares-3.pli | 17 + .../Pascal/sequence-of-non-squares.pascal | 24 + .../Perl-6/sequence-of-non-squares.pl6 | 7 + .../Perl/sequence-of-non-squares.pl | 6 + .../PicoLisp/sequence-of-non-squares.l | 10 + .../PostScript/sequence-of-non-squares.ps | 10 + .../PowerShell/sequence-of-non-squares-1.psh | 3 + .../PowerShell/sequence-of-non-squares-2.psh | 1 + .../PowerShell/sequence-of-non-squares-3.psh | 6 + .../sequence-of-non-squares.purebasic | 27 + .../Python/sequence-of-non-squares.py | 14 + .../R/sequence-of-non-squares-1.r | 2 + .../R/sequence-of-non-squares-2.r | 7 + .../REXX/sequence-of-non-squares.rexx | 35 ++ .../Racket/sequence-of-non-squares.rkt | 11 + .../Ruby/sequence-of-non-squares.rb | 9 + .../Scala/sequence-of-non-squares.scala | 9 + .../Scheme/sequence-of-non-squares.ss | 31 + .../Seed7/sequence-of-non-squares.seed7 | 26 + .../Standard-ML/sequence-of-non-squares.ml | 12 + .../sequence-of-non-squares-1.ti-89 | 4 + .../sequence-of-non-squares-2.ti-89 | 11 + .../Tcl/sequence-of-non-squares.tcl | 17 + .../Ursala/sequence-of-non-squares.ursala | 10 + .../XPL0/sequence-of-non-squares.xpl0 | 23 + Task/Set-consolidation/0DESCRIPTION | 20 + .../Ada/set-consolidation-1.ada | 27 + .../Ada/set-consolidation-2.ada | 77 +++ .../Ada/set-consolidation-3.ada | 40 ++ .../Bracmat/set-consolidation.bracmat | 28 + .../Set-consolidation/C/set-consolidation-1.c | 37 ++ .../Set-consolidation/C/set-consolidation-2.c | 102 ++++ .../Set-consolidation/D/set-consolidation-1.d | 29 + .../Set-consolidation/D/set-consolidation-2.d | 32 ++ .../Ela/set-consolidation-1.ela | 11 + .../Ela/set-consolidation-2.ela | 4 + .../Set-consolidation/Go/set-consolidation.go | 56 ++ .../Haskell/set-consolidation.hs | 8 + .../Set-consolidation/J/set-consolidation-1.j | 4 + .../Set-consolidation/J/set-consolidation-2.j | 16 + .../Java/set-consolidation.java | 63 ++ .../Mathematica/set-consolidation.math | 10 + .../OCaml/set-consolidation.ocaml | 40 ++ .../PARI-GP/set-consolidation.pari | 12 + .../Perl-6/set-consolidation.pl6 | 17 + .../PicoLisp/set-consolidation-1.l | 8 + .../PicoLisp/set-consolidation-2.l | 8 + .../Python/set-consolidation-1.py | 42 ++ .../Python/set-consolidation-2.py | 8 + .../REXX/set-consolidation.rexx | 53 ++ .../Tcl/set-consolidation-1.tcl | 18 + .../Tcl/set-consolidation-2.tcl | 4 + Task/Set-of-real-numbers/0DESCRIPTION | 33 ++ .../C-sharp/set-of-real-numbers-1.cs | 33 ++ .../C-sharp/set-of-real-numbers-2.cs | 49 ++ .../D/set-of-real-numbers.d | 61 ++ .../J/set-of-real-numbers-1.j | 18 + .../J/set-of-real-numbers-10.j | 2 + .../J/set-of-real-numbers-11.j | 4 + .../J/set-of-real-numbers-12.j | 2 + .../J/set-of-real-numbers-2.j | 10 + .../J/set-of-real-numbers-3.j | 2 + .../J/set-of-real-numbers-4.j | 23 + .../J/set-of-real-numbers-5.j | 10 + .../J/set-of-real-numbers-6.j | 2 + .../J/set-of-real-numbers-7.j | 4 + .../J/set-of-real-numbers-8.j | 1 + .../J/set-of-real-numbers-9.j | 11 + .../Perl-6/set-of-real-numbers.pl6 | 149 +++++ .../Perl/set-of-real-numbers-1.pl | 179 ++++++ .../Perl/set-of-real-numbers-2.pl | 13 + .../Python/set-of-real-numbers.py | 47 ++ .../REXX/set-of-real-numbers-1.rexx | 40 ++ .../REXX/set-of-real-numbers-2.rexx | 53 ++ .../Tcl/set-of-real-numbers-1.tcl | 146 +++++ .../Tcl/set-of-real-numbers-2.tcl | 19 + .../Tcl/set-of-real-numbers-3.tcl | 19 + Task/Set/0DESCRIPTION | 16 + Task/Set/1META.yaml | 2 + Task/Set/Ada/set.ada | 54 ++ Task/Set/BBC-BASIC/set.bbc | 43 ++ Task/Set/C++/set.cpp | 79 +++ Task/Set/C/set.c | 45 ++ Task/Set/Clojure/set.clj | 15 + Task/Set/CoffeeScript/set.coffeescript | 85 +++ Task/Set/Common-Lisp/set.lisp | 22 + Task/Set/D/set.d | 18 + Task/Set/Factor/set.factor | 15 + Task/Set/Go/set.go | 124 ++++ Task/Set/Groovy/set.groovy | 19 + Task/Set/Haskell/set-1.hs | 35 ++ Task/Set/Haskell/set-2.hs | 15 + Task/Set/Icon/set-1.icon | 61 ++ Task/Set/Icon/set-2.icon | 39 ++ Task/Set/J/set-1.j | 5 + Task/Set/J/set-2.j | 12 + Task/Set/J/set-3.j | 12 + Task/Set/J/set-4.j | 1 + Task/Set/Java/set.java | 62 ++ Task/Set/Liberty-BASIC/set.liberty | 148 +++++ Task/Set/MATLAB/set.m | 16 + Task/Set/Maple/set.maple | 41 ++ Task/Set/Mathematica/set.math | 8 + Task/Set/Maxima/set.maxima | 78 +++ Task/Set/OCaml/set.ocaml | 68 +++ Task/Set/Objective-C/set.m | 57 ++ Task/Set/PARI-GP/set.pari | 14 + Task/Set/Pascal/set.pascal | 94 +++ Task/Set/Perl-6/set.pl6 | 19 + Task/Set/Perl/set.pl | 113 ++++ Task/Set/PicoLisp/set-1.l | 46 ++ Task/Set/PicoLisp/set-2.l | 57 ++ Task/Set/Prolog/set.pro | 49 ++ Task/Set/PureBasic/set.purebasic | 170 ++++++ Task/Set/Python/set.py | 49 ++ Task/Set/REXX/set.rexx | 56 ++ Task/Set/Racket/set.rkt | 12 + Task/Set/Ruby/set.rb | 43 ++ Task/Set/Scala/set.scala | 10 + Task/Set/Scheme/set.ss | 43 ++ Task/Set/Seed7/set.seed7 | 26 + Task/Set/Smalltalk/set.st | 20 + Task/Set/Tcl/set.tcl | 21 + 12433 files changed, 156208 insertions(+), 123 deletions(-) create mode 120000 Lang/0815/Binary-digits create mode 120000 Lang/0815/Reverse-a-string create mode 120000 Lang/4DOS-Batch/Repeat-a-string create mode 120000 Lang/6502-Assembly/Rot-13 create mode 120000 Lang/6800-Assembly/Loops-Infinite create mode 120000 Lang/ABAP/Copy-a-string create mode 120000 Lang/ABAP/Permutations create mode 120000 Lang/ABAP/Prime-decomposition create mode 120000 Lang/ACL2/Arbitrary-precision-integers--included- delete mode 120000 Lang/ACL2/Arbitrary-precision-integers-included create mode 120000 Lang/ACL2/Binary-digits create mode 120000 Lang/ACL2/Non-decimal-radices-Convert create mode 120000 Lang/ACL2/One-dimensional-cellular-automata create mode 120000 Lang/ACL2/Palindrome-detection create mode 120000 Lang/ACL2/Pangram-checker create mode 120000 Lang/ACL2/Pick-random-element create mode 120000 Lang/ACL2/Playing-cards create mode 120000 Lang/ACL2/Primality-by-trial-division create mode 120000 Lang/ACL2/Prime-decomposition create mode 120000 Lang/ACL2/Queue-Definition create mode 120000 Lang/ACL2/Real-constants-and-functions create mode 120000 Lang/ACL2/Remove-duplicate-elements create mode 120000 Lang/ACL2/Return-multiple-values create mode 120000 Lang/ACL2/Reverse-a-string create mode 120000 Lang/ACL2/Rot-13 create mode 120000 Lang/ALGOL-68/Binary-digits create mode 120000 Lang/ALGOL-68/Calendar---for-real-programmers delete mode 120000 Lang/ALGOL-68/Calendar-for-real-programmers create mode 120000 Lang/ALGOL-68/Copy-a-string create mode 120000 Lang/ALGOL-68/Dragon-curve create mode 120000 Lang/ALGOL-68/Environment-variables create mode 120000 Lang/ALGOL-68/N-queens-problem create mode 120000 Lang/ALGOL-68/Named-parameters create mode 120000 Lang/ALGOL-68/Non-continuous-subsequences create mode 120000 Lang/ALGOL-68/Non-decimal-radices-Convert create mode 120000 Lang/ALGOL-68/Non-decimal-radices-Input create mode 120000 Lang/ALGOL-68/Non-decimal-radices-Output create mode 120000 Lang/ALGOL-68/Nth-root create mode 120000 Lang/ALGOL-68/Null-object create mode 120000 Lang/ALGOL-68/Number-names create mode 120000 Lang/ALGOL-68/Numerical-integration create mode 120000 Lang/ALGOL-68/Object-serialization create mode 120000 Lang/ALGOL-68/One-dimensional-cellular-automata create mode 120000 Lang/ALGOL-68/Palindrome-detection create mode 120000 Lang/ALGOL-68/Pangram-checker create mode 120000 Lang/ALGOL-68/Partial-function-application create mode 120000 Lang/ALGOL-68/Pascals-triangle create mode 120000 Lang/ALGOL-68/Pascals-triangle-Puzzle create mode 120000 Lang/ALGOL-68/Perfect-numbers create mode 120000 Lang/ALGOL-68/Permutations create mode 120000 Lang/ALGOL-68/Playing-cards create mode 120000 Lang/ALGOL-68/Plot-coordinate-pairs create mode 120000 Lang/ALGOL-68/Pointers-and-references create mode 120000 Lang/ALGOL-68/Polynomial-regression create mode 120000 Lang/ALGOL-68/Power-set create mode 120000 Lang/ALGOL-68/Pragmatic-directives create mode 120000 Lang/ALGOL-68/Price-fraction create mode 120000 Lang/ALGOL-68/Primality-by-trial-division create mode 120000 Lang/ALGOL-68/Prime-decomposition create mode 120000 Lang/ALGOL-68/Probabilistic-choice create mode 120000 Lang/ALGOL-68/Program-termination create mode 120000 Lang/ALGOL-68/Quaternion-type create mode 120000 Lang/ALGOL-68/Random-number-generator--included- create mode 120000 Lang/ALGOL-68/Random-numbers create mode 120000 Lang/ALGOL-68/Range-expansion create mode 120000 Lang/ALGOL-68/Range-extraction create mode 120000 Lang/ALGOL-68/Read-a-file-line-by-line create mode 120000 Lang/ALGOL-68/Read-entire-file create mode 120000 Lang/ALGOL-68/Real-constants-and-functions create mode 120000 Lang/ALGOL-68/Reduced-row-echelon-form create mode 120000 Lang/ALGOL-68/Regular-expressions create mode 120000 Lang/ALGOL-68/Rename-a-file create mode 120000 Lang/ALGOL-68/Repeat-a-string create mode 120000 Lang/ALGOL-68/Reverse-a-string create mode 120000 Lang/ALGOL-68/Roman-numerals-Decode create mode 120000 Lang/ALGOL-68/Roman-numerals-Encode create mode 120000 Lang/ALGOL-68/Roots-of-a-function create mode 120000 Lang/ALGOL-68/Roots-of-a-quadratic-function create mode 120000 Lang/ALGOL-68/Roots-of-unity create mode 120000 Lang/ALGOL-68/Rosetta-Code-Rank-languages-by-popularity create mode 120000 Lang/ALGOL-68/Rot-13 create mode 120000 Lang/ALGOL-68/Run-length-encoding create mode 120000 Lang/ALGOL-68/Runtime-evaluation create mode 120000 Lang/ALGOL-68/Runtime-evaluation-In-an-environment create mode 120000 Lang/ALGOL-68/SEDOLs create mode 120000 Lang/ALGOL-68/Sequence-of-non-squares create mode 120000 Lang/ALGOL-W/Roman-numerals-Encode create mode 120000 Lang/ANTLR/Parsing-RPN-calculator-algorithm create mode 120000 Lang/ANTLR/Roman-numerals-Decode create mode 120000 Lang/APL/Pangram-checker create mode 120000 Lang/APL/Pascals-triangle create mode 120000 Lang/APL/Run-length-encoding create mode 120000 Lang/ATS/Return-multiple-values create mode 120000 Lang/AWK/Binary-digits create mode 120000 Lang/AWK/Catalan-numbers create mode 120000 Lang/AWK/Copy-a-string create mode 120000 Lang/AWK/Environment-variables create mode 120000 Lang/AWK/Non-decimal-radices-Convert create mode 120000 Lang/AWK/Non-decimal-radices-Output create mode 120000 Lang/AWK/Nth-root create mode 120000 Lang/AWK/Number-names create mode 120000 Lang/AWK/Number-reversal-game create mode 120000 Lang/AWK/One-dimensional-cellular-automata create mode 120000 Lang/AWK/Palindrome-detection create mode 120000 Lang/AWK/Pangram-checker create mode 120000 Lang/AWK/Parsing-RPN-to-infix-conversion create mode 120000 Lang/AWK/Pascals-triangle create mode 120000 Lang/AWK/Perfect-numbers create mode 120000 Lang/AWK/Price-fraction create mode 120000 Lang/AWK/Primality-by-trial-division create mode 120000 Lang/AWK/Prime-decomposition create mode 120000 Lang/AWK/Probabilistic-choice create mode 120000 Lang/AWK/Program-termination create mode 120000 Lang/AWK/Queue-Definition create mode 120000 Lang/AWK/Random-numbers create mode 120000 Lang/AWK/Range-extraction create mode 120000 Lang/AWK/Read-a-file-line-by-line create mode 120000 Lang/AWK/Read-a-specific-line-from-a-file create mode 120000 Lang/AWK/Read-entire-file create mode 120000 Lang/AWK/Real-constants-and-functions create mode 120000 Lang/AWK/Regular-expressions create mode 120000 Lang/AWK/Remove-duplicate-elements create mode 120000 Lang/AWK/Remove-lines-from-a-file create mode 120000 Lang/AWK/Rename-a-file create mode 120000 Lang/AWK/Repeat-a-string create mode 120000 Lang/AWK/Reverse-a-string create mode 120000 Lang/AWK/Roman-numerals-Decode create mode 120000 Lang/AWK/Roman-numerals-Encode create mode 120000 Lang/AWK/Rosetta-Code-Rank-languages-by-popularity create mode 120000 Lang/AWK/Rot-13 create mode 120000 Lang/AWK/Run-length-encoding create mode 120000 Lang/AWK/SEDOLs create mode 120000 Lang/AWK/Scope-Function-names-and-labels create mode 120000 Lang/AWK/Self-describing-numbers create mode 120000 Lang/AWK/Semordnilap create mode 120000 Lang/AWK/Sequence-of-non-squares create mode 120000 Lang/ActionScript/Copy-a-string create mode 120000 Lang/ActionScript/Null-object create mode 120000 Lang/ActionScript/Numerical-integration create mode 120000 Lang/ActionScript/Palindrome-detection create mode 120000 Lang/ActionScript/Pangram-checker create mode 120000 Lang/ActionScript/Polymorphism create mode 120000 Lang/ActionScript/Primality-by-trial-division create mode 120000 Lang/ActionScript/Real-constants-and-functions create mode 120000 Lang/ActionScript/Reduced-row-echelon-form create mode 120000 Lang/ActionScript/Repeat-a-string create mode 120000 Lang/ActionScript/Reverse-a-string create mode 120000 Lang/ActionScript/Roman-numerals-Encode create mode 120000 Lang/ActionScript/SEDOLs create mode 120000 Lang/Ada/Arbitrary-precision-integers--included- delete mode 120000 Lang/Ada/Arbitrary-precision-integers-included create mode 120000 Lang/Ada/Binary-digits create mode 120000 Lang/Ada/Calendar---for-real-programmers delete mode 120000 Lang/Ada/Calendar-for-real-programmers create mode 120000 Lang/Ada/Catalan-numbers create mode 120000 Lang/Ada/Copy-a-string create mode 120000 Lang/Ada/Environment-variables create mode 120000 Lang/Ada/Execute-a-Markov-algorithm create mode 120000 Lang/Ada/Guess-the-number-With-feedback--player- delete mode 120000 Lang/Ada/Guess-the-number-With-feedback-player create mode 120000 Lang/Ada/N-queens-problem create mode 120000 Lang/Ada/Named-parameters create mode 120000 Lang/Ada/Non-continuous-subsequences create mode 120000 Lang/Ada/Non-decimal-radices-Convert create mode 120000 Lang/Ada/Non-decimal-radices-Input create mode 120000 Lang/Ada/Non-decimal-radices-Output create mode 120000 Lang/Ada/Nth-root create mode 120000 Lang/Ada/Null-object create mode 120000 Lang/Ada/Number-names create mode 120000 Lang/Ada/Number-reversal-game create mode 120000 Lang/Ada/Numeric-error-propagation create mode 120000 Lang/Ada/Numerical-integration create mode 120000 Lang/Ada/Object-serialization create mode 120000 Lang/Ada/One-dimensional-cellular-automata create mode 120000 Lang/Ada/One-of-n-lines-in-a-file create mode 120000 Lang/Ada/OpenGL create mode 120000 Lang/Ada/Optional-parameters create mode 120000 Lang/Ada/Order-two-numerical-lists create mode 120000 Lang/Ada/Ordered-Partitions create mode 120000 Lang/Ada/Palindrome-detection create mode 120000 Lang/Ada/Pangram-checker create mode 120000 Lang/Ada/Parallel-calculations create mode 120000 Lang/Ada/Parametric-polymorphism create mode 120000 Lang/Ada/Parametrized-SQL-statement create mode 120000 Lang/Ada/Parsing-RPN-calculator-algorithm create mode 120000 Lang/Ada/Parsing-RPN-to-infix-conversion create mode 120000 Lang/Ada/Partial-function-application create mode 120000 Lang/Ada/Pascals-triangle create mode 120000 Lang/Ada/Pascals-triangle-Puzzle create mode 120000 Lang/Ada/Percentage-difference-between-images create mode 120000 Lang/Ada/Perfect-numbers create mode 120000 Lang/Ada/Permutation-test create mode 120000 Lang/Ada/Permutations create mode 120000 Lang/Ada/Permutations-Derangements create mode 120000 Lang/Ada/Pick-random-element create mode 120000 Lang/Ada/Pig-the-dice-game create mode 120000 Lang/Ada/Pig-the-dice-game-Player create mode 120000 Lang/Ada/Plot-coordinate-pairs create mode 120000 Lang/Ada/Pointers-and-references create mode 120000 Lang/Ada/Polymorphic-copy create mode 120000 Lang/Ada/Polymorphism create mode 120000 Lang/Ada/Polynomial-long-division create mode 120000 Lang/Ada/Polynomial-regression create mode 120000 Lang/Ada/Power-set create mode 120000 Lang/Ada/Price-fraction create mode 120000 Lang/Ada/Primality-by-trial-division create mode 120000 Lang/Ada/Prime-decomposition create mode 120000 Lang/Ada/Priority-queue create mode 120000 Lang/Ada/Probabilistic-choice create mode 120000 Lang/Ada/Problem-of-Apollonius create mode 120000 Lang/Ada/Program-name create mode 120000 Lang/Ada/Program-termination create mode 120000 Lang/Ada/Pythagorean-triples create mode 120000 Lang/Ada/QR-decomposition create mode 120000 Lang/Ada/Quaternion-type create mode 120000 Lang/Ada/Queue-Definition create mode 120000 Lang/Ada/Queue-Usage create mode 120000 Lang/Ada/Random-number-generator--device- create mode 120000 Lang/Ada/Random-numbers create mode 120000 Lang/Ada/Range-expansion create mode 120000 Lang/Ada/Range-extraction create mode 120000 Lang/Ada/Rate-counter create mode 120000 Lang/Ada/Ray-casting-algorithm create mode 120000 Lang/Ada/Read-a-configuration-file create mode 120000 Lang/Ada/Read-a-file-line-by-line create mode 120000 Lang/Ada/Read-a-specific-line-from-a-file create mode 120000 Lang/Ada/Read-entire-file create mode 120000 Lang/Ada/Real-constants-and-functions create mode 120000 Lang/Ada/Reduced-row-echelon-form create mode 120000 Lang/Ada/Regular-expressions create mode 120000 Lang/Ada/Remove-duplicate-elements create mode 120000 Lang/Ada/Remove-lines-from-a-file create mode 120000 Lang/Ada/Rename-a-file create mode 120000 Lang/Ada/Rendezvous create mode 120000 Lang/Ada/Repeat-a-string create mode 120000 Lang/Ada/Resistor-mesh create mode 120000 Lang/Ada/Return-multiple-values create mode 120000 Lang/Ada/Reverse-a-string create mode 120000 Lang/Ada/Rock-paper-scissors create mode 120000 Lang/Ada/Roman-numerals-Decode create mode 120000 Lang/Ada/Roman-numerals-Encode create mode 120000 Lang/Ada/Roots-of-a-function create mode 120000 Lang/Ada/Roots-of-a-quadratic-function create mode 120000 Lang/Ada/Roots-of-unity create mode 120000 Lang/Ada/Rosetta-Code-Count-examples create mode 120000 Lang/Ada/Rosetta-Code-Find-unimplemented-tasks create mode 120000 Lang/Ada/Rosetta-Code-Rank-languages-by-popularity create mode 120000 Lang/Ada/Rot-13 create mode 120000 Lang/Ada/Run-length-encoding create mode 120000 Lang/Ada/S-Expressions create mode 120000 Lang/Ada/SEDOLs create mode 120000 Lang/Ada/Safe-addition create mode 120000 Lang/Ada/Same-Fringe create mode 120000 Lang/Ada/Scope-modifiers create mode 120000 Lang/Ada/Secure-temporary-file create mode 120000 Lang/Ada/Self-describing-numbers create mode 120000 Lang/Ada/Self-referential-sequence create mode 120000 Lang/Ada/Semordnilap create mode 120000 Lang/Ada/Send-email create mode 120000 Lang/Ada/Sequence-of-non-squares create mode 120000 Lang/Ada/Set create mode 120000 Lang/Ada/Set-consolidation create mode 120000 Lang/Agda2/Reverse-a-string create mode 120000 Lang/Aikido/Polymorphic-copy create mode 120000 Lang/Aikido/Polymorphism create mode 120000 Lang/Aime/Pick-random-element create mode 120000 Lang/Aime/Range-extraction create mode 120000 Lang/Aime/Read-a-file-line-by-line create mode 120000 Lang/Aime/Read-a-specific-line-from-a-file create mode 120000 Lang/Alore/Arbitrary-precision-integers--included- delete mode 120000 Lang/Alore/Arbitrary-precision-integers-included create mode 120000 Lang/AmigaE/Null-object create mode 120000 Lang/AppleScript/Named-parameters create mode 120000 Lang/AppleScript/Null-object create mode 120000 Lang/AppleScript/Optional-parameters create mode 120000 Lang/AppleScript/Program-termination create mode 120000 Lang/AppleScript/Queue-Usage create mode 120000 Lang/AppleScript/Regular-expressions create mode 120000 Lang/AppleScript/Remove-duplicate-elements create mode 120000 Lang/AppleScript/Repeat-a-string create mode 120000 Lang/AppleScript/Reverse-a-string create mode 120000 Lang/AppleScript/Rot-13 create mode 120000 Lang/Argile/Regular-expressions create mode 120000 Lang/AutoHotkey/Binary-digits create mode 120000 Lang/AutoHotkey/Brownian-tree create mode 120000 Lang/AutoHotkey/Catalan-numbers create mode 120000 Lang/AutoHotkey/Copy-a-string create mode 120000 Lang/AutoHotkey/Environment-variables create mode 120000 Lang/AutoHotkey/Execute-a-Markov-algorithm create mode 120000 Lang/AutoHotkey/Guess-the-number-With-feedback--player- delete mode 120000 Lang/AutoHotkey/Guess-the-number-With-feedback-player create mode 120000 Lang/AutoHotkey/N-queens-problem create mode 120000 Lang/AutoHotkey/Named-parameters create mode 120000 Lang/AutoHotkey/Non-continuous-subsequences create mode 120000 Lang/AutoHotkey/Non-decimal-radices-Convert create mode 120000 Lang/AutoHotkey/Non-decimal-radices-Output create mode 120000 Lang/AutoHotkey/Nth-root create mode 120000 Lang/AutoHotkey/Null-object create mode 120000 Lang/AutoHotkey/Number-names create mode 120000 Lang/AutoHotkey/Number-reversal-game create mode 120000 Lang/AutoHotkey/Numerical-integration create mode 120000 Lang/AutoHotkey/OLE-Automation create mode 120000 Lang/AutoHotkey/One-dimensional-cellular-automata create mode 120000 Lang/AutoHotkey/One-of-n-lines-in-a-file create mode 120000 Lang/AutoHotkey/OpenGL create mode 120000 Lang/AutoHotkey/Optional-parameters create mode 120000 Lang/AutoHotkey/Order-two-numerical-lists create mode 120000 Lang/AutoHotkey/Palindrome-detection create mode 120000 Lang/AutoHotkey/Pangram-checker create mode 120000 Lang/AutoHotkey/Parsing-RPN-calculator-algorithm create mode 120000 Lang/AutoHotkey/Parsing-RPN-to-infix-conversion create mode 120000 Lang/AutoHotkey/Parsing-Shunting-yard-algorithm create mode 120000 Lang/AutoHotkey/Pascals-triangle create mode 120000 Lang/AutoHotkey/Pascals-triangle-Puzzle create mode 120000 Lang/AutoHotkey/Percentage-difference-between-images create mode 120000 Lang/AutoHotkey/Perfect-numbers create mode 120000 Lang/AutoHotkey/Permutations create mode 120000 Lang/AutoHotkey/Permutations-Derangements create mode 120000 Lang/AutoHotkey/Pick-random-element create mode 120000 Lang/AutoHotkey/Pinstripe-Display create mode 120000 Lang/AutoHotkey/Play-recorded-sounds create mode 120000 Lang/AutoHotkey/Playing-cards create mode 120000 Lang/AutoHotkey/Pointers-and-references create mode 120000 Lang/AutoHotkey/Power-set create mode 120000 Lang/AutoHotkey/Price-fraction create mode 120000 Lang/AutoHotkey/Primality-by-trial-division create mode 120000 Lang/AutoHotkey/Prime-decomposition create mode 120000 Lang/AutoHotkey/Probabilistic-choice create mode 120000 Lang/AutoHotkey/Program-name create mode 120000 Lang/AutoHotkey/Program-termination create mode 120000 Lang/AutoHotkey/Queue-Definition create mode 120000 Lang/AutoHotkey/Queue-Usage create mode 120000 Lang/AutoHotkey/Random-numbers create mode 120000 Lang/AutoHotkey/Range-expansion create mode 120000 Lang/AutoHotkey/Range-extraction create mode 120000 Lang/AutoHotkey/Ray-casting-algorithm create mode 120000 Lang/AutoHotkey/Read-a-configuration-file create mode 120000 Lang/AutoHotkey/Read-a-file-line-by-line create mode 120000 Lang/AutoHotkey/Read-a-specific-line-from-a-file create mode 120000 Lang/AutoHotkey/Read-entire-file create mode 120000 Lang/AutoHotkey/Real-constants-and-functions create mode 120000 Lang/AutoHotkey/Regular-expressions create mode 120000 Lang/AutoHotkey/Remove-duplicate-elements create mode 120000 Lang/AutoHotkey/Remove-lines-from-a-file create mode 120000 Lang/AutoHotkey/Rename-a-file create mode 120000 Lang/AutoHotkey/Rendezvous create mode 120000 Lang/AutoHotkey/Repeat-a-string create mode 120000 Lang/AutoHotkey/Return-multiple-values create mode 120000 Lang/AutoHotkey/Reverse-a-string create mode 120000 Lang/AutoHotkey/Rock-paper-scissors create mode 120000 Lang/AutoHotkey/Roman-numerals-Decode create mode 120000 Lang/AutoHotkey/Roman-numerals-Encode create mode 120000 Lang/AutoHotkey/Roots-of-a-function create mode 120000 Lang/AutoHotkey/Roots-of-a-quadratic-function create mode 120000 Lang/AutoHotkey/Roots-of-unity create mode 120000 Lang/AutoHotkey/Rosetta-Code-Count-examples create mode 120000 Lang/AutoHotkey/Rosetta-Code-Find-unimplemented-tasks create mode 120000 Lang/AutoHotkey/Rosetta-Code-Fix-code-tags create mode 120000 Lang/AutoHotkey/Rosetta-Code-Rank-languages-by-popularity create mode 120000 Lang/AutoHotkey/Rot-13 create mode 120000 Lang/AutoHotkey/Run-length-encoding create mode 120000 Lang/AutoHotkey/Runtime-evaluation create mode 120000 Lang/AutoHotkey/Runtime-evaluation-In-an-environment create mode 120000 Lang/AutoHotkey/SEDOLs create mode 120000 Lang/AutoHotkey/Scope-modifiers create mode 120000 Lang/AutoHotkey/Self-describing-numbers create mode 120000 Lang/AutoHotkey/Self-referential-sequence create mode 120000 Lang/AutoHotkey/Send-an-unknown-method-call create mode 120000 Lang/AutoHotkey/Send-email create mode 120000 Lang/AutoHotkey/Sequence-of-non-squares create mode 120000 Lang/AutoIt/Binary-digits create mode 120000 Lang/AutoIt/Copy-a-string create mode 120000 Lang/AutoIt/Nth-root create mode 120000 Lang/AutoIt/Palindrome-detection create mode 120000 Lang/AutoIt/Pangram-checker create mode 120000 Lang/AutoIt/Program-termination create mode 120000 Lang/AutoIt/Reduced-row-echelon-form create mode 120000 Lang/AutoIt/Return-multiple-values create mode 120000 Lang/AutoIt/Reverse-a-string create mode 120000 Lang/AutoIt/Rock-paper-scissors create mode 120000 Lang/Axiom/Perfect-numbers create mode 120000 Lang/Axiom/Priority-queue create mode 120000 Lang/Axiom/QR-decomposition create mode 120000 Lang/Axiom/Roots-of-a-function create mode 120000 Lang/BASIC/Catalan-numbers create mode 120000 Lang/BASIC/Dragon-curve create mode 120000 Lang/BASIC/Environment-variables create mode 120000 Lang/BASIC/Nth-root create mode 120000 Lang/BASIC/Number-names create mode 120000 Lang/BASIC/Number-reversal-game create mode 120000 Lang/BASIC/Numerical-integration create mode 120000 Lang/BASIC/One-dimensional-cellular-automata create mode 120000 Lang/BASIC/One-of-n-lines-in-a-file create mode 120000 Lang/BASIC/Palindrome-detection create mode 120000 Lang/BASIC/Pangram-checker create mode 120000 Lang/BASIC/Pascals-triangle create mode 120000 Lang/BASIC/Perfect-numbers create mode 120000 Lang/BASIC/Pick-random-element create mode 120000 Lang/BASIC/Playing-cards create mode 120000 Lang/BASIC/Pragmatic-directives create mode 120000 Lang/BASIC/Price-fraction create mode 120000 Lang/BASIC/Primality-by-trial-division create mode 120000 Lang/BASIC/Program-name create mode 120000 Lang/BASIC/Program-termination create mode 120000 Lang/BASIC/Read-a-file-line-by-line create mode 120000 Lang/BASIC/Read-entire-file create mode 120000 Lang/BASIC/Real-constants-and-functions create mode 120000 Lang/BASIC/Rename-a-file create mode 120000 Lang/BASIC/Reverse-a-string create mode 120000 Lang/BASIC/Rock-paper-scissors create mode 120000 Lang/BASIC/Roman-numerals-Encode create mode 120000 Lang/BASIC/Roots-of-unity create mode 120000 Lang/BASIC/Rot-13 create mode 120000 Lang/BASIC/Run-length-encoding create mode 120000 Lang/BASIC/Runtime-evaluation create mode 120000 Lang/BASIC/SEDOLs create mode 120000 Lang/BASIC/Scope-Function-names-and-labels create mode 120000 Lang/BASIC/Self-describing-numbers create mode 120000 Lang/BASIC/Sequence-of-non-squares create mode 120000 Lang/BASIC256/Dragon-curve create mode 120000 Lang/BASIC256/Roman-numerals-Encode create mode 120000 Lang/BBC-BASIC/Binary-digits create mode 120000 Lang/BBC-BASIC/Brownian-tree create mode 120000 Lang/BBC-BASIC/Calendar---for-real-programmers delete mode 120000 Lang/BBC-BASIC/Calendar-for-real-programmers create mode 120000 Lang/BBC-BASIC/Catalan-numbers create mode 120000 Lang/BBC-BASIC/Copy-a-string create mode 120000 Lang/BBC-BASIC/Dragon-curve create mode 120000 Lang/BBC-BASIC/Environment-variables create mode 120000 Lang/BBC-BASIC/Execute-a-Markov-algorithm create mode 120000 Lang/BBC-BASIC/Guess-the-number-With-feedback--player- delete mode 120000 Lang/BBC-BASIC/Guess-the-number-With-feedback-player create mode 120000 Lang/BBC-BASIC/N-queens-problem create mode 120000 Lang/BBC-BASIC/Non-continuous-subsequences create mode 120000 Lang/BBC-BASIC/Non-decimal-radices-Convert create mode 120000 Lang/BBC-BASIC/Non-decimal-radices-Input create mode 120000 Lang/BBC-BASIC/Non-decimal-radices-Output create mode 120000 Lang/BBC-BASIC/Nth-root create mode 120000 Lang/BBC-BASIC/Null-object create mode 120000 Lang/BBC-BASIC/Number-names create mode 120000 Lang/BBC-BASIC/Number-reversal-game create mode 120000 Lang/BBC-BASIC/Numerical-integration create mode 120000 Lang/BBC-BASIC/One-dimensional-cellular-automata create mode 120000 Lang/BBC-BASIC/One-of-n-lines-in-a-file create mode 120000 Lang/BBC-BASIC/OpenGL create mode 120000 Lang/BBC-BASIC/Optional-parameters create mode 120000 Lang/BBC-BASIC/Order-two-numerical-lists create mode 120000 Lang/BBC-BASIC/Ordered-Partitions create mode 120000 Lang/BBC-BASIC/Palindrome-detection create mode 120000 Lang/BBC-BASIC/Pangram-checker create mode 120000 Lang/BBC-BASIC/Parsing-RPN-calculator-algorithm create mode 120000 Lang/BBC-BASIC/Partial-function-application create mode 120000 Lang/BBC-BASIC/Pascals-triangle create mode 120000 Lang/BBC-BASIC/Pascals-triangle-Puzzle create mode 120000 Lang/BBC-BASIC/Percentage-difference-between-images create mode 120000 Lang/BBC-BASIC/Perfect-numbers create mode 120000 Lang/BBC-BASIC/Permutation-test create mode 120000 Lang/BBC-BASIC/Permutations create mode 120000 Lang/BBC-BASIC/Permutations-Derangements create mode 120000 Lang/BBC-BASIC/Permutations-by-swapping create mode 120000 Lang/BBC-BASIC/Pick-random-element create mode 120000 Lang/BBC-BASIC/Pinstripe-Display create mode 120000 Lang/BBC-BASIC/Pinstripe-Printer create mode 120000 Lang/BBC-BASIC/Play-recorded-sounds create mode 120000 Lang/BBC-BASIC/Playing-cards create mode 120000 Lang/BBC-BASIC/Plot-coordinate-pairs create mode 120000 Lang/BBC-BASIC/Pointers-and-references create mode 120000 Lang/BBC-BASIC/Polymorphic-copy create mode 120000 Lang/BBC-BASIC/Polymorphism create mode 120000 Lang/BBC-BASIC/Polynomial-long-division create mode 120000 Lang/BBC-BASIC/Polynomial-regression create mode 120000 Lang/BBC-BASIC/Power-set create mode 120000 Lang/BBC-BASIC/Price-fraction create mode 120000 Lang/BBC-BASIC/Primality-by-trial-division create mode 120000 Lang/BBC-BASIC/Probabilistic-choice create mode 120000 Lang/BBC-BASIC/Problem-of-Apollonius create mode 120000 Lang/BBC-BASIC/Program-name create mode 120000 Lang/BBC-BASIC/Program-termination create mode 120000 Lang/BBC-BASIC/Pythagorean-triples create mode 120000 Lang/BBC-BASIC/QR-decomposition create mode 120000 Lang/BBC-BASIC/Quaternion-type create mode 120000 Lang/BBC-BASIC/Queue-Definition create mode 120000 Lang/BBC-BASIC/Queue-Usage create mode 120000 Lang/BBC-BASIC/Random-number-generator--device- create mode 120000 Lang/BBC-BASIC/Random-numbers create mode 120000 Lang/BBC-BASIC/Range-expansion create mode 120000 Lang/BBC-BASIC/Range-extraction create mode 120000 Lang/BBC-BASIC/Rate-counter create mode 120000 Lang/BBC-BASIC/Read-a-configuration-file create mode 120000 Lang/BBC-BASIC/Read-a-file-line-by-line create mode 120000 Lang/BBC-BASIC/Read-a-specific-line-from-a-file create mode 120000 Lang/BBC-BASIC/Read-entire-file create mode 120000 Lang/BBC-BASIC/Real-constants-and-functions create mode 120000 Lang/BBC-BASIC/Record-sound create mode 120000 Lang/BBC-BASIC/Reduced-row-echelon-form create mode 120000 Lang/BBC-BASIC/Regular-expressions create mode 120000 Lang/BBC-BASIC/Remove-duplicate-elements create mode 120000 Lang/BBC-BASIC/Rename-a-file create mode 120000 Lang/BBC-BASIC/Repeat-a-string create mode 120000 Lang/BBC-BASIC/Resistor-mesh create mode 120000 Lang/BBC-BASIC/Return-multiple-values create mode 120000 Lang/BBC-BASIC/Reverse-a-string create mode 120000 Lang/BBC-BASIC/Rock-paper-scissors create mode 120000 Lang/BBC-BASIC/Roman-numerals-Decode create mode 120000 Lang/BBC-BASIC/Roman-numerals-Encode create mode 120000 Lang/BBC-BASIC/Roots-of-a-function create mode 120000 Lang/BBC-BASIC/Roots-of-a-quadratic-function create mode 120000 Lang/BBC-BASIC/Roots-of-unity create mode 120000 Lang/BBC-BASIC/Rosetta-Code-Count-examples create mode 120000 Lang/BBC-BASIC/Rosetta-Code-Rank-languages-by-popularity create mode 120000 Lang/BBC-BASIC/Rot-13 create mode 120000 Lang/BBC-BASIC/Run-length-encoding create mode 120000 Lang/BBC-BASIC/Runtime-evaluation create mode 120000 Lang/BBC-BASIC/Runtime-evaluation-In-an-environment create mode 120000 Lang/BBC-BASIC/SEDOLs create mode 120000 Lang/BBC-BASIC/Scope-modifiers create mode 120000 Lang/BBC-BASIC/Secure-temporary-file create mode 120000 Lang/BBC-BASIC/Self-describing-numbers create mode 120000 Lang/BBC-BASIC/Self-referential-sequence create mode 120000 Lang/BBC-BASIC/Semordnilap create mode 120000 Lang/BBC-BASIC/Send-email create mode 120000 Lang/BBC-BASIC/Sequence-of-non-squares create mode 120000 Lang/BBC-BASIC/Set create mode 120000 Lang/BCPL/N-queens-problem create mode 120000 Lang/Babel/Null-object create mode 120000 Lang/Babel/Repeat-a-string create mode 120000 Lang/Babel/Reverse-a-string create mode 120000 Lang/Batch-File/Binary-digits create mode 120000 Lang/Batch-File/Copy-a-string create mode 120000 Lang/Batch-File/Environment-variables create mode 120000 Lang/Batch-File/Program-termination create mode 120000 Lang/Batch-File/Queue-Definition create mode 120000 Lang/Batch-File/Rename-a-file create mode 120000 Lang/Batch-File/Repeat-a-string create mode 120000 Lang/Batch-File/Reverse-a-string create mode 120000 Lang/Bc/Sequence-of-non-squares create mode 120000 Lang/Befunge/One-dimensional-cellular-automata create mode 120000 Lang/Befunge/Palindrome-detection create mode 120000 Lang/Befunge/Prime-decomposition create mode 120000 Lang/Befunge/Reverse-a-string create mode 120000 Lang/Befunge/Rot-13 create mode 120000 Lang/Bracmat/Arbitrary-precision-integers--included- delete mode 120000 Lang/Bracmat/Arbitrary-precision-integers-included create mode 120000 Lang/Bracmat/Catalan-numbers create mode 120000 Lang/Bracmat/Copy-a-string create mode 120000 Lang/Bracmat/Non-continuous-subsequences create mode 120000 Lang/Bracmat/Non-decimal-radices-Convert create mode 120000 Lang/Bracmat/One-dimensional-cellular-automata create mode 120000 Lang/Bracmat/Order-two-numerical-lists create mode 120000 Lang/Bracmat/Pangram-checker create mode 120000 Lang/Bracmat/Pascals-triangle create mode 120000 Lang/Bracmat/Pattern-matching create mode 120000 Lang/Bracmat/Perfect-numbers create mode 120000 Lang/Bracmat/Permutations create mode 120000 Lang/Bracmat/Price-fraction create mode 120000 Lang/Bracmat/Primality-by-trial-division create mode 120000 Lang/Bracmat/Pythagorean-triples create mode 120000 Lang/Bracmat/Range-expansion create mode 120000 Lang/Bracmat/Range-extraction create mode 120000 Lang/Bracmat/Regular-expressions create mode 120000 Lang/Bracmat/Remove-duplicate-elements create mode 120000 Lang/Bracmat/Rename-a-file create mode 120000 Lang/Bracmat/Repeat-a-string create mode 120000 Lang/Bracmat/Return-multiple-values create mode 120000 Lang/Bracmat/Reverse-a-string create mode 120000 Lang/Bracmat/Roman-numerals-Decode create mode 120000 Lang/Bracmat/Roman-numerals-Encode create mode 120000 Lang/Bracmat/Run-length-encoding create mode 120000 Lang/Bracmat/Self-referential-sequence create mode 120000 Lang/Bracmat/Set-consolidation create mode 120000 Lang/Brainf---/Binary-digits create mode 120000 Lang/Brainf---/Read-entire-file create mode 120000 Lang/Brainf---/Repeat-a-string create mode 120000 Lang/Brainf---/Reverse-a-string create mode 120000 Lang/Brat/Catalan-numbers create mode 120000 Lang/Brat/Number-reversal-game create mode 120000 Lang/Brat/Pangram-checker create mode 120000 Lang/Brat/Read-a-file-line-by-line create mode 120000 Lang/Brat/Read-entire-file create mode 120000 Lang/Brat/Remove-duplicate-elements create mode 120000 Lang/Brat/Repeat-a-string create mode 120000 Lang/Brat/Respond-to-an-unknown-method-call create mode 120000 Lang/Brat/Reverse-a-string create mode 120000 Lang/Burlesque/Binary-digits create mode 120000 Lang/Burlesque/Palindrome-detection create mode 120000 Lang/Burlesque/Pascals-triangle create mode 120000 Lang/Burlesque/Pick-random-element create mode 120000 Lang/Burlesque/Power-set create mode 120000 Lang/Burlesque/Primality-by-trial-division create mode 120000 Lang/Burlesque/Prime-decomposition create mode 120000 Lang/Burlesque/Repeat-a-string create mode 120000 Lang/Burlesque/Reverse-a-string create mode 120000 Lang/Burlesque/Rot-13 create mode 120000 Lang/Burlesque/Run-length-encoding create mode 120000 Lang/Burlesque/Runtime-evaluation create mode 120000 Lang/Burlesque/Sequence-of-non-squares create mode 120000 Lang/C++/Binary-digits create mode 120000 Lang/C++/Catalan-numbers delete 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-N- delete mode 120000 Lang/C++/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2 create mode 120000 Lang/C++/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2- create mode 120000 Lang/C++/Copy-a-string create mode 120000 Lang/C++/Environment-variables create mode 120000 Lang/C++/Execute-a-Markov-algorithm create mode 120000 Lang/C++/Guess-the-number-With-feedback--player- delete mode 120000 Lang/C++/Guess-the-number-With-feedback-player create mode 120000 Lang/C++/Named-parameters create mode 120000 Lang/C++/Non-decimal-radices-Convert create mode 120000 Lang/C++/Non-decimal-radices-Input create mode 120000 Lang/C++/Non-decimal-radices-Output create mode 120000 Lang/C++/Nth-root create mode 120000 Lang/C++/Null-object create mode 120000 Lang/C++/Number-names create mode 120000 Lang/C++/Number-reversal-game create mode 120000 Lang/C++/Numerical-integration create mode 120000 Lang/C++/Object-serialization create mode 120000 Lang/C++/One-dimensional-cellular-automata create mode 120000 Lang/C++/One-of-n-lines-in-a-file create mode 120000 Lang/C++/Optional-parameters create mode 120000 Lang/C++/Order-two-numerical-lists create mode 120000 Lang/C++/Palindrome-detection create mode 120000 Lang/C++/Pangram-checker create mode 120000 Lang/C++/Parallel-calculations create mode 120000 Lang/C++/Parametric-polymorphism create mode 120000 Lang/C++/Parsing-RPN-calculator-algorithm create mode 120000 Lang/C++/Partial-function-application create mode 120000 Lang/C++/Pascals-triangle create mode 120000 Lang/C++/Percentage-difference-between-images create mode 120000 Lang/C++/Perfect-numbers create mode 120000 Lang/C++/Permutations create mode 120000 Lang/C++/Playing-cards create mode 120000 Lang/C++/Polymorphic-copy create mode 120000 Lang/C++/Polymorphism create mode 120000 Lang/C++/Polynomial-long-division create mode 120000 Lang/C++/Power-set create mode 120000 Lang/C++/Price-fraction create mode 120000 Lang/C++/Primality-by-trial-division create mode 120000 Lang/C++/Prime-decomposition create mode 120000 Lang/C++/Priority-queue create mode 120000 Lang/C++/Probabilistic-choice create mode 120000 Lang/C++/Program-name create mode 120000 Lang/C++/Program-termination create mode 120000 Lang/C++/Quaternion-type create mode 120000 Lang/C++/Queue-Definition create mode 120000 Lang/C++/Queue-Usage create mode 120000 Lang/C++/Random-numbers create mode 120000 Lang/C++/Range-expansion create mode 120000 Lang/C++/Range-extraction create mode 120000 Lang/C++/Rate-counter create mode 120000 Lang/C++/Read-a-configuration-file create mode 120000 Lang/C++/Read-a-file-line-by-line create mode 120000 Lang/C++/Read-entire-file create mode 120000 Lang/C++/Real-constants-and-functions create mode 120000 Lang/C++/Reduced-row-echelon-form create mode 120000 Lang/C++/Regular-expressions create mode 120000 Lang/C++/Remove-duplicate-elements create mode 120000 Lang/C++/Remove-lines-from-a-file create mode 120000 Lang/C++/Rename-a-file create mode 120000 Lang/C++/Repeat-a-string create mode 120000 Lang/C++/Respond-to-an-unknown-method-call create mode 120000 Lang/C++/Return-multiple-values create mode 120000 Lang/C++/Reverse-a-string create mode 120000 Lang/C++/Rock-paper-scissors create mode 120000 Lang/C++/Roman-numerals-Decode create mode 120000 Lang/C++/Roman-numerals-Encode create mode 120000 Lang/C++/Roots-of-a-function create mode 120000 Lang/C++/Roots-of-a-quadratic-function create mode 120000 Lang/C++/Roots-of-unity create mode 120000 Lang/C++/Rosetta-Code-Rank-languages-by-popularity create mode 120000 Lang/C++/Rot-13 create mode 120000 Lang/C++/Run-length-encoding create mode 120000 Lang/C++/SEDOLs create mode 120000 Lang/C++/Semordnilap create mode 120000 Lang/C++/Send-email create mode 120000 Lang/C++/Sequence-of-non-squares create mode 120000 Lang/C++/Set create mode 120000 Lang/C-sharp/Arbitrary-precision-integers--included- delete mode 120000 Lang/C-sharp/Arbitrary-precision-integers-included create mode 120000 Lang/C-sharp/One-dimensional-cellular-automata create mode 120000 Lang/C-sharp/Partial-function-application create mode 120000 Lang/C-sharp/Polynomial-regression create mode 120000 Lang/C-sharp/Quaternion-type create mode 120000 Lang/C-sharp/Queue-Definition create mode 120000 Lang/C-sharp/Queue-Usage create mode 120000 Lang/C-sharp/Random-number-generator--device- create mode 120000 Lang/C-sharp/Random-numbers create mode 120000 Lang/C-sharp/Range-extraction create mode 120000 Lang/C-sharp/Read-a-file-line-by-line create mode 120000 Lang/C-sharp/Read-a-specific-line-from-a-file create mode 120000 Lang/C-sharp/Read-entire-file create mode 120000 Lang/C-sharp/Real-constants-and-functions create mode 120000 Lang/C-sharp/Regular-expressions create mode 120000 Lang/C-sharp/Remove-duplicate-elements create mode 120000 Lang/C-sharp/Rename-a-file create mode 120000 Lang/C-sharp/Repeat-a-string create mode 120000 Lang/C-sharp/Set-of-real-numbers create mode 120000 Lang/C/Arbitrary-precision-integers--included- delete mode 120000 Lang/C/Arbitrary-precision-integers-included create mode 120000 Lang/C/Binary-digits create mode 120000 Lang/C/Brownian-tree create mode 120000 Lang/C/Catalan-numbers create mode 120000 Lang/C/Copy-a-string create mode 120000 Lang/C/Dragon-curve create mode 120000 Lang/C/Environment-variables create mode 120000 Lang/C/Execute-a-Markov-algorithm create mode 120000 Lang/C/Guess-the-number-With-feedback--player- delete mode 120000 Lang/C/Guess-the-number-With-feedback-player create mode 120000 Lang/C/N-queens-problem create mode 120000 Lang/C/Named-parameters create mode 120000 Lang/C/Non-continuous-subsequences create mode 120000 Lang/C/Non-decimal-radices-Convert create mode 120000 Lang/C/Non-decimal-radices-Input create mode 120000 Lang/C/Non-decimal-radices-Output create mode 120000 Lang/C/Nth-root create mode 120000 Lang/C/Null-object create mode 120000 Lang/C/Number-names create mode 120000 Lang/C/Number-reversal-game create mode 120000 Lang/C/Numeric-error-propagation create mode 120000 Lang/C/Numerical-integration create mode 120000 Lang/C/Numerical-integration-Gauss-Legendre-Quadrature create mode 120000 Lang/C/One-dimensional-cellular-automata create mode 120000 Lang/C/One-of-n-lines-in-a-file create mode 120000 Lang/C/OpenGL create mode 120000 Lang/C/Optional-parameters create mode 120000 Lang/C/Order-two-numerical-lists create mode 120000 Lang/C/Ordered-Partitions create mode 120000 Lang/C/Palindrome-detection create mode 120000 Lang/C/Pangram-checker create mode 120000 Lang/C/Parallel-calculations create mode 120000 Lang/C/Parametric-polymorphism create mode 120000 Lang/C/Parsing-RPN-calculator-algorithm create mode 120000 Lang/C/Parsing-Shunting-yard-algorithm create mode 120000 Lang/C/Partial-function-application create mode 120000 Lang/C/Pascals-triangle create mode 120000 Lang/C/Pascals-triangle-Puzzle create mode 120000 Lang/C/Percentage-difference-between-images create mode 120000 Lang/C/Perfect-numbers create mode 120000 Lang/C/Permutation-test create mode 120000 Lang/C/Permutations create mode 120000 Lang/C/Permutations-Derangements create mode 120000 Lang/C/Pick-random-element create mode 120000 Lang/C/Playing-cards create mode 120000 Lang/C/Plot-coordinate-pairs create mode 120000 Lang/C/Polymorphic-copy create mode 120000 Lang/C/Polynomial-long-division create mode 120000 Lang/C/Polynomial-regression create mode 120000 Lang/C/Power-set create mode 120000 Lang/C/Price-fraction create mode 120000 Lang/C/Primality-by-trial-division create mode 120000 Lang/C/Prime-decomposition create mode 120000 Lang/C/Priority-queue create mode 120000 Lang/C/Probabilistic-choice create mode 120000 Lang/C/Problem-of-Apollonius create mode 120000 Lang/C/Program-name create mode 120000 Lang/C/Program-termination create mode 120000 Lang/C/Pythagorean-triples create mode 120000 Lang/C/QR-decomposition create mode 120000 Lang/C/Quaternion-type create mode 120000 Lang/C/Queue-Definition create mode 120000 Lang/C/Queue-Usage create mode 120000 Lang/C/Random-number-generator--device- create mode 120000 Lang/C/Random-number-generator--included- create mode 120000 Lang/C/Random-numbers create mode 120000 Lang/C/Range-expansion create mode 120000 Lang/C/Range-extraction create mode 120000 Lang/C/Rate-counter create mode 120000 Lang/C/Ray-casting-algorithm create mode 120000 Lang/C/Read-a-file-line-by-line create mode 120000 Lang/C/Read-a-specific-line-from-a-file create mode 120000 Lang/C/Read-entire-file create mode 120000 Lang/C/Real-constants-and-functions create mode 120000 Lang/C/Record-sound create mode 120000 Lang/C/Reduced-row-echelon-form create mode 120000 Lang/C/Regular-expressions create mode 120000 Lang/C/Remove-duplicate-elements create mode 120000 Lang/C/Remove-lines-from-a-file create mode 120000 Lang/C/Rename-a-file create mode 120000 Lang/C/Rendezvous create mode 120000 Lang/C/Repeat-a-string create mode 120000 Lang/C/Resistor-mesh create mode 120000 Lang/C/Return-multiple-values create mode 120000 Lang/C/Reverse-a-string create mode 120000 Lang/C/Rock-paper-scissors create mode 120000 Lang/C/Roman-numerals-Decode create mode 120000 Lang/C/Roman-numerals-Encode create mode 120000 Lang/C/Roots-of-a-function create mode 120000 Lang/C/Roots-of-a-quadratic-function create mode 120000 Lang/C/Roots-of-unity create mode 120000 Lang/C/Rosetta-Code-Rank-languages-by-popularity create mode 120000 Lang/C/Rot-13 create mode 120000 Lang/C/Run-length-encoding create mode 120000 Lang/C/S-Expressions create mode 120000 Lang/C/SEDOLs create mode 120000 Lang/C/Safe-addition create mode 120000 Lang/C/Same-Fringe create mode 120000 Lang/C/Scope-modifiers create mode 120000 Lang/C/Secure-temporary-file create mode 120000 Lang/C/Self-describing-numbers create mode 120000 Lang/C/Self-referential-sequence create mode 120000 Lang/C/Semordnilap create mode 120000 Lang/C/Sequence-of-non-squares create mode 120000 Lang/C/Set create mode 120000 Lang/C/Set-consolidation create mode 120000 Lang/CMake/Primality-by-trial-division create mode 120000 Lang/CMake/Random-number-generator--included- create mode 120000 Lang/CMake/Read-entire-file create mode 120000 Lang/CMake/Return-multiple-values create mode 120000 Lang/COBOL/Binary-digits create mode 120000 Lang/COBOL/One-dimensional-cellular-automata create mode 120000 Lang/COBOL/Primality-by-trial-division create mode 120000 Lang/COBOL/Reverse-a-string create mode 120000 Lang/Cache-ObjectScript/Non-decimal-radices-Convert create mode 120000 Lang/Cache-ObjectScript/Rosetta-Code-Rank-languages-by-popularity create mode 120000 Lang/Clean/Parametric-polymorphism create mode 120000 Lang/Clipper/Price-fraction create mode 120000 Lang/Clojure/Arbitrary-precision-integers--included- delete mode 120000 Lang/Clojure/Arbitrary-precision-integers-included create mode 120000 Lang/Clojure/Binary-digits create mode 120000 Lang/Clojure/Catalan-numbers create mode 120000 Lang/Clojure/Copy-a-string create mode 120000 Lang/Clojure/Environment-variables create mode 120000 Lang/Clojure/Guess-the-number-With-feedback--player- delete mode 120000 Lang/Clojure/Guess-the-number-With-feedback-player create mode 120000 Lang/Clojure/N-queens-problem create mode 120000 Lang/Clojure/Named-parameters create mode 120000 Lang/Clojure/Non-continuous-subsequences create mode 120000 Lang/Clojure/Non-decimal-radices-Output create mode 120000 Lang/Clojure/Null-object create mode 120000 Lang/Clojure/Number-names create mode 120000 Lang/Clojure/Number-reversal-game create mode 120000 Lang/Clojure/One-dimensional-cellular-automata create mode 120000 Lang/Clojure/OpenGL create mode 120000 Lang/Clojure/Optional-parameters create mode 120000 Lang/Clojure/Palindrome-detection create mode 120000 Lang/Clojure/Pangram-checker create mode 120000 Lang/Clojure/Parallel-calculations create mode 120000 Lang/Clojure/Parsing-RPN-calculator-algorithm create mode 120000 Lang/Clojure/Partial-function-application create mode 120000 Lang/Clojure/Pascals-triangle create mode 120000 Lang/Clojure/Pascals-triangle-Puzzle create mode 120000 Lang/Clojure/Perfect-numbers create mode 120000 Lang/Clojure/Permutations create mode 120000 Lang/Clojure/Pick-random-element create mode 120000 Lang/Clojure/Playing-cards create mode 120000 Lang/Clojure/Polymorphism create mode 120000 Lang/Clojure/Power-set create mode 120000 Lang/Clojure/Primality-by-trial-division create mode 120000 Lang/Clojure/Prime-decomposition create mode 120000 Lang/Clojure/Probabilistic-choice create mode 120000 Lang/Clojure/Program-name create mode 120000 Lang/Clojure/Program-termination create mode 120000 Lang/Clojure/Queue-Definition create mode 120000 Lang/Clojure/Queue-Usage create mode 120000 Lang/Clojure/Random-numbers create mode 120000 Lang/Clojure/Range-expansion create mode 120000 Lang/Clojure/Read-a-file-line-by-line create mode 120000 Lang/Clojure/Read-entire-file create mode 120000 Lang/Clojure/Real-constants-and-functions create mode 120000 Lang/Clojure/Regular-expressions create mode 120000 Lang/Clojure/Remove-duplicate-elements create mode 120000 Lang/Clojure/Rename-a-file create mode 120000 Lang/Clojure/Repeat-a-string create mode 120000 Lang/Clojure/Return-multiple-values create mode 120000 Lang/Clojure/Reverse-a-string create mode 120000 Lang/Clojure/Roman-numerals-Decode create mode 120000 Lang/Clojure/Roman-numerals-Encode create mode 120000 Lang/Clojure/Roots-of-a-function create mode 120000 Lang/Clojure/Rosetta-Code-Count-examples create mode 120000 Lang/Clojure/Rot-13 create mode 120000 Lang/Clojure/Run-length-encoding create mode 120000 Lang/Clojure/Secure-temporary-file create mode 120000 Lang/Clojure/Sequence-of-non-squares create mode 120000 Lang/Clojure/Set create mode 120000 Lang/CoffeeScript/Binary-digits create mode 120000 Lang/CoffeeScript/Environment-variables create mode 120000 Lang/CoffeeScript/N-queens-problem create mode 120000 Lang/CoffeeScript/Non-continuous-subsequences create mode 120000 Lang/CoffeeScript/Nth-root create mode 120000 Lang/CoffeeScript/Number-names create mode 120000 Lang/CoffeeScript/Numerical-integration create mode 120000 Lang/CoffeeScript/One-dimensional-cellular-automata create mode 120000 Lang/CoffeeScript/Palindrome-detection create mode 120000 Lang/CoffeeScript/Pangram-checker create mode 120000 Lang/CoffeeScript/Partial-function-application create mode 120000 Lang/CoffeeScript/Pascals-triangle create mode 120000 Lang/CoffeeScript/Perfect-numbers create mode 120000 Lang/CoffeeScript/Permutations create mode 120000 Lang/CoffeeScript/Pick-random-element create mode 120000 Lang/CoffeeScript/Power-set create mode 120000 Lang/CoffeeScript/Primality-by-trial-division create mode 120000 Lang/CoffeeScript/Priority-queue create mode 120000 Lang/CoffeeScript/Problem-of-Apollonius create mode 120000 Lang/CoffeeScript/Pythagorean-triples create mode 120000 Lang/CoffeeScript/Queue-Definition create mode 120000 Lang/CoffeeScript/Queue-Usage create mode 120000 Lang/CoffeeScript/Ray-casting-algorithm create mode 120000 Lang/CoffeeScript/Read-a-file-line-by-line create mode 120000 Lang/CoffeeScript/Reverse-a-string create mode 120000 Lang/CoffeeScript/Roman-numerals-Decode create mode 120000 Lang/CoffeeScript/Roman-numerals-Encode create mode 120000 Lang/CoffeeScript/Roots-of-a-function create mode 120000 Lang/CoffeeScript/Roots-of-unity create mode 120000 Lang/CoffeeScript/Run-length-encoding create mode 120000 Lang/CoffeeScript/S-Expressions create mode 120000 Lang/CoffeeScript/Self-referential-sequence create mode 120000 Lang/CoffeeScript/Sequence-of-non-squares create mode 120000 Lang/CoffeeScript/Set create mode 120000 Lang/ColdFusion/Copy-a-string create mode 120000 Lang/ColdFusion/Power-set create mode 120000 Lang/ColdFusion/Reverse-a-string create mode 120000 Lang/Common-Lisp/Arbitrary-precision-integers--included- delete mode 120000 Lang/Common-Lisp/Arbitrary-precision-integers-included create mode 120000 Lang/Common-Lisp/Binary-digits create mode 120000 Lang/Common-Lisp/Catalan-numbers create mode 120000 Lang/Common-Lisp/Copy-a-string create mode 120000 Lang/Common-Lisp/Dragon-curve create mode 120000 Lang/Common-Lisp/Environment-variables create mode 120000 Lang/Common-Lisp/N-queens-problem create mode 120000 Lang/Common-Lisp/Named-parameters create mode 120000 Lang/Common-Lisp/Non-continuous-subsequences create mode 120000 Lang/Common-Lisp/Non-decimal-radices-Convert create mode 120000 Lang/Common-Lisp/Non-decimal-radices-Input create mode 120000 Lang/Common-Lisp/Non-decimal-radices-Output create mode 120000 Lang/Common-Lisp/Nth-root create mode 120000 Lang/Common-Lisp/Null-object create mode 120000 Lang/Common-Lisp/Number-names create mode 120000 Lang/Common-Lisp/Number-reversal-game create mode 120000 Lang/Common-Lisp/Numerical-integration create mode 120000 Lang/Common-Lisp/Numerical-integration-Gauss-Legendre-Quadrature create mode 120000 Lang/Common-Lisp/Object-serialization create mode 120000 Lang/Common-Lisp/One-dimensional-cellular-automata create mode 120000 Lang/Common-Lisp/Optional-parameters create mode 120000 Lang/Common-Lisp/Order-two-numerical-lists create mode 120000 Lang/Common-Lisp/Ordered-Partitions create mode 120000 Lang/Common-Lisp/Palindrome-detection create mode 120000 Lang/Common-Lisp/Pangram-checker create mode 120000 Lang/Common-Lisp/Parametric-polymorphism create mode 120000 Lang/Common-Lisp/Partial-function-application create mode 120000 Lang/Common-Lisp/Pascals-triangle create mode 120000 Lang/Common-Lisp/Pattern-matching create mode 120000 Lang/Common-Lisp/Percentage-difference-between-images create mode 120000 Lang/Common-Lisp/Perfect-numbers create mode 120000 Lang/Common-Lisp/Permutation-test create mode 120000 Lang/Common-Lisp/Permutations create mode 120000 Lang/Common-Lisp/Pig-the-dice-game create mode 120000 Lang/Common-Lisp/Playing-cards create mode 120000 Lang/Common-Lisp/Polymorphic-copy create mode 120000 Lang/Common-Lisp/Polymorphism create mode 120000 Lang/Common-Lisp/Polynomial-long-division create mode 120000 Lang/Common-Lisp/Polynomial-regression create mode 120000 Lang/Common-Lisp/Power-set create mode 120000 Lang/Common-Lisp/Primality-by-trial-division create mode 120000 Lang/Common-Lisp/Prime-decomposition create mode 120000 Lang/Common-Lisp/Probabilistic-choice create mode 120000 Lang/Common-Lisp/Program-name create mode 120000 Lang/Common-Lisp/Program-termination create mode 120000 Lang/Common-Lisp/Pythagorean-triples create mode 120000 Lang/Common-Lisp/QR-decomposition create mode 120000 Lang/Common-Lisp/Queue-Definition create mode 120000 Lang/Common-Lisp/Queue-Usage create mode 120000 Lang/Common-Lisp/Random-numbers create mode 120000 Lang/Common-Lisp/Range-expansion create mode 120000 Lang/Common-Lisp/Range-extraction create mode 120000 Lang/Common-Lisp/Rate-counter create mode 120000 Lang/Common-Lisp/Ray-casting-algorithm create mode 120000 Lang/Common-Lisp/Read-a-file-line-by-line create mode 120000 Lang/Common-Lisp/Read-a-specific-line-from-a-file create mode 120000 Lang/Common-Lisp/Read-entire-file create mode 120000 Lang/Common-Lisp/Real-constants-and-functions create mode 120000 Lang/Common-Lisp/Reduced-row-echelon-form create mode 120000 Lang/Common-Lisp/Regular-expressions create mode 120000 Lang/Common-Lisp/Remove-duplicate-elements create mode 120000 Lang/Common-Lisp/Remove-lines-from-a-file create mode 120000 Lang/Common-Lisp/Rename-a-file create mode 120000 Lang/Common-Lisp/Repeat-a-string create mode 120000 Lang/Common-Lisp/Respond-to-an-unknown-method-call create mode 120000 Lang/Common-Lisp/Return-multiple-values create mode 120000 Lang/Common-Lisp/Reverse-a-string create mode 120000 Lang/Common-Lisp/Roman-numerals-Decode create mode 120000 Lang/Common-Lisp/Roman-numerals-Encode create mode 120000 Lang/Common-Lisp/Roots-of-a-function create mode 120000 Lang/Common-Lisp/Roots-of-a-quadratic-function create mode 120000 Lang/Common-Lisp/Roots-of-unity create mode 120000 Lang/Common-Lisp/Rot-13 create mode 120000 Lang/Common-Lisp/Run-length-encoding create mode 120000 Lang/Common-Lisp/Runtime-evaluation create mode 120000 Lang/Common-Lisp/Runtime-evaluation-In-an-environment create mode 120000 Lang/Common-Lisp/S-Expressions create mode 120000 Lang/Common-Lisp/SEDOLs create mode 120000 Lang/Common-Lisp/Scope-modifiers create mode 120000 Lang/Common-Lisp/Self-referential-sequence create mode 120000 Lang/Common-Lisp/Sequence-of-non-squares create mode 120000 Lang/Common-Lisp/Set create mode 120000 Lang/Component-Pascal/Null-object create mode 120000 Lang/Curry/N-queens-problem create mode 120000 Lang/D/Arbitrary-precision-integers--included- delete mode 120000 Lang/D/Arbitrary-precision-integers-included create mode 120000 Lang/D/Binary-digits create mode 120000 Lang/D/Brownian-tree create mode 120000 Lang/D/Catalan-numbers create mode 120000 Lang/D/Copy-a-string create mode 120000 Lang/D/Dragon-curve create mode 120000 Lang/D/Environment-variables create mode 120000 Lang/D/Execute-a-Markov-algorithm create mode 120000 Lang/D/Guess-the-number-With-feedback--player- delete mode 120000 Lang/D/Guess-the-number-With-feedback-player create mode 120000 Lang/D/N-queens-problem create mode 120000 Lang/D/Nautical-bell create mode 120000 Lang/D/Non-continuous-subsequences create mode 120000 Lang/D/Non-decimal-radices-Convert create mode 120000 Lang/D/Non-decimal-radices-Input create mode 120000 Lang/D/Non-decimal-radices-Output create mode 120000 Lang/D/Nth-root create mode 120000 Lang/D/Null-object create mode 120000 Lang/D/Number-names create mode 120000 Lang/D/Number-reversal-game create mode 120000 Lang/D/Numeric-error-propagation create mode 120000 Lang/D/Numerical-integration create mode 120000 Lang/D/Numerical-integration-Gauss-Legendre-Quadrature create mode 120000 Lang/D/Object-serialization create mode 120000 Lang/D/One-dimensional-cellular-automata create mode 120000 Lang/D/One-of-n-lines-in-a-file create mode 120000 Lang/D/OpenGL create mode 120000 Lang/D/Optional-parameters create mode 120000 Lang/D/Order-two-numerical-lists create mode 120000 Lang/D/Ordered-Partitions create mode 120000 Lang/D/Palindrome-detection create mode 120000 Lang/D/Pangram-checker create mode 120000 Lang/D/Parallel-calculations create mode 120000 Lang/D/Parametric-polymorphism create mode 120000 Lang/D/Parsing-RPN-calculator-algorithm create mode 120000 Lang/D/Parsing-RPN-to-infix-conversion create mode 120000 Lang/D/Partial-function-application create mode 120000 Lang/D/Pascals-triangle create mode 120000 Lang/D/Pascals-triangle-Puzzle create mode 120000 Lang/D/Percentage-difference-between-images create mode 120000 Lang/D/Perfect-numbers create mode 120000 Lang/D/Permutation-test create mode 120000 Lang/D/Permutations create mode 120000 Lang/D/Permutations-Derangements create mode 120000 Lang/D/Permutations-by-swapping create mode 120000 Lang/D/Pick-random-element create mode 120000 Lang/D/Pig-the-dice-game create mode 120000 Lang/D/Playing-cards create mode 120000 Lang/D/Pointers-and-references create mode 120000 Lang/D/Polymorphic-copy create mode 120000 Lang/D/Polymorphism create mode 120000 Lang/D/Polynomial-long-division create mode 120000 Lang/D/Power-set create mode 120000 Lang/D/Price-fraction create mode 120000 Lang/D/Primality-by-trial-division create mode 120000 Lang/D/Prime-decomposition create mode 120000 Lang/D/Priority-queue create mode 120000 Lang/D/Probabilistic-choice create mode 120000 Lang/D/Problem-of-Apollonius create mode 120000 Lang/D/Program-name create mode 120000 Lang/D/Pythagorean-triples create mode 120000 Lang/D/QR-decomposition create mode 120000 Lang/D/Quaternion-type create mode 120000 Lang/D/Queue-Usage create mode 120000 Lang/D/RIPEMD-160 create mode 120000 Lang/D/Random-numbers create mode 120000 Lang/D/Range-expansion create mode 120000 Lang/D/Range-extraction create mode 120000 Lang/D/Ray-casting-algorithm create mode 120000 Lang/D/Read-a-configuration-file create mode 120000 Lang/D/Read-a-file-line-by-line create mode 120000 Lang/D/Read-a-specific-line-from-a-file create mode 120000 Lang/D/Read-entire-file create mode 120000 Lang/D/Real-constants-and-functions create mode 120000 Lang/D/Reduced-row-echelon-form create mode 120000 Lang/D/Regular-expressions create mode 120000 Lang/D/Remove-duplicate-elements create mode 120000 Lang/D/Remove-lines-from-a-file create mode 120000 Lang/D/Rename-a-file create mode 120000 Lang/D/Repeat-a-string create mode 120000 Lang/D/Resistor-mesh create mode 120000 Lang/D/Respond-to-an-unknown-method-call create mode 120000 Lang/D/Return-multiple-values create mode 120000 Lang/D/Reverse-a-string create mode 120000 Lang/D/Rock-paper-scissors create mode 120000 Lang/D/Roman-numerals-Decode create mode 120000 Lang/D/Roman-numerals-Encode create mode 120000 Lang/D/Roots-of-a-function create mode 120000 Lang/D/Roots-of-a-quadratic-function create mode 120000 Lang/D/Roots-of-unity create mode 120000 Lang/D/Rosetta-Code-Count-examples create mode 120000 Lang/D/Rosetta-Code-Rank-languages-by-popularity create mode 120000 Lang/D/Rot-13 create mode 120000 Lang/D/Run-length-encoding create mode 120000 Lang/D/S-Expressions create mode 120000 Lang/D/SEDOLs create mode 120000 Lang/D/Same-Fringe create mode 120000 Lang/D/Secure-temporary-file create mode 120000 Lang/D/Self-describing-numbers create mode 120000 Lang/D/Self-referential-sequence create mode 120000 Lang/D/Semordnilap create mode 120000 Lang/D/Send-email create mode 120000 Lang/D/Sequence-of-non-squares create mode 120000 Lang/D/Set create mode 120000 Lang/D/Set-consolidation create mode 120000 Lang/D/Set-of-real-numbers create mode 120000 Lang/DCL/Rename-a-file create mode 120000 Lang/DWScript/One-dimensional-cellular-automata create mode 120000 Lang/DWScript/Pascals-triangle create mode 120000 Lang/DWScript/Random-numbers create mode 120000 Lang/DWScript/Range-extraction create mode 120000 Lang/DWScript/Repeat-a-string create mode 120000 Lang/DWScript/Roman-numerals-Encode create mode 120000 Lang/DWScript/Roots-of-a-function create mode 120000 Lang/Dart/Binary-digits create mode 120000 Lang/Dart/N-queens-problem create mode 120000 Lang/Dart/Program-name create mode 120000 Lang/Dart/Reverse-a-string create mode 120000 Lang/Deja-Vu/Pick-random-element create mode 120000 Lang/Deja-Vu/Random-number-generator--included- create mode 120000 Lang/Delphi/Binary-digits create mode 120000 Lang/Delphi/Brownian-tree create mode 120000 Lang/Delphi/Copy-a-string create mode 120000 Lang/Delphi/Environment-variables create mode 120000 Lang/Delphi/Nth-root create mode 120000 Lang/Delphi/Null-object create mode 120000 Lang/Delphi/Palindrome-detection create mode 120000 Lang/Delphi/Pangram-checker create mode 120000 Lang/Delphi/Permutations create mode 120000 Lang/Delphi/Play-recorded-sounds create mode 120000 Lang/Delphi/Playing-cards create mode 120000 Lang/Delphi/Polymorphism create mode 120000 Lang/Delphi/Primality-by-trial-division create mode 120000 Lang/Delphi/Program-name create mode 120000 Lang/Delphi/Program-termination create mode 120000 Lang/Delphi/Quaternion-type create mode 120000 Lang/Delphi/Queue-Usage create mode 120000 Lang/Delphi/Random-numbers create mode 120000 Lang/Delphi/Read-a-file-line-by-line create mode 120000 Lang/Delphi/Read-entire-file create mode 120000 Lang/Delphi/Real-constants-and-functions create mode 120000 Lang/Delphi/Remove-duplicate-elements create mode 120000 Lang/Delphi/Rename-a-file create mode 120000 Lang/Delphi/Repeat-a-string create mode 120000 Lang/Delphi/Return-multiple-values create mode 120000 Lang/Delphi/Reverse-a-string create mode 120000 Lang/Delphi/Roman-numerals-Decode create mode 120000 Lang/Delphi/Roman-numerals-Encode create mode 120000 Lang/Delphi/Scope-modifiers create mode 120000 Lang/Delphi/Send-email create mode 120000 Lang/E/Arbitrary-precision-integers--included- delete mode 120000 Lang/E/Arbitrary-precision-integers-included create mode 120000 Lang/E/Environment-variables create mode 120000 Lang/E/Named-parameters create mode 120000 Lang/E/Non-decimal-radices-Convert create mode 120000 Lang/E/Non-decimal-radices-Input create mode 120000 Lang/E/Non-decimal-radices-Output create mode 120000 Lang/E/Nth-root create mode 120000 Lang/E/Null-object create mode 120000 Lang/E/Numerical-integration create mode 120000 Lang/E/Object-serialization create mode 120000 Lang/E/One-dimensional-cellular-automata create mode 120000 Lang/E/Optional-parameters create mode 120000 Lang/E/Palindrome-detection create mode 120000 Lang/E/Pangram-checker create mode 120000 Lang/E/Parametric-polymorphism create mode 120000 Lang/E/Partial-function-application create mode 120000 Lang/E/Pascals-triangle create mode 120000 Lang/E/Percentage-difference-between-images create mode 120000 Lang/E/Perfect-numbers create mode 120000 Lang/E/Polymorphic-copy create mode 120000 Lang/E/Polymorphism create mode 120000 Lang/E/Polynomial-long-division create mode 120000 Lang/E/Power-set create mode 120000 Lang/E/Primality-by-trial-division create mode 120000 Lang/E/Prime-decomposition create mode 120000 Lang/E/Probabilistic-choice create mode 120000 Lang/E/Program-termination create mode 120000 Lang/E/Quaternion-type create mode 120000 Lang/E/Queue-Definition create mode 120000 Lang/E/Queue-Usage create mode 120000 Lang/E/Random-numbers create mode 120000 Lang/E/Range-extraction create mode 120000 Lang/E/Rate-counter create mode 120000 Lang/E/Read-entire-file create mode 120000 Lang/E/Real-constants-and-functions create mode 120000 Lang/E/Remove-duplicate-elements create mode 120000 Lang/E/Rename-a-file create mode 120000 Lang/E/Repeat-a-string create mode 120000 Lang/E/Respond-to-an-unknown-method-call create mode 120000 Lang/E/Reverse-a-string create mode 120000 Lang/E/Rot-13 create mode 120000 Lang/E/Run-length-encoding create mode 120000 Lang/E/Runtime-evaluation create mode 120000 Lang/E/Runtime-evaluation-In-an-environment create mode 120000 Lang/E/SEDOLs create mode 120000 Lang/E/Safe-addition create mode 120000 Lang/E/Send-an-unknown-method-call create mode 120000 Lang/EGL/Reverse-a-string create mode 120000 Lang/EGL/Rosetta-Code-Count-examples create mode 120000 Lang/Eiffel/Environment-variables create mode 120000 Lang/Eiffel/Polymorphism create mode 120000 Lang/Eiffel/Random-numbers create mode 120000 Lang/Eiffel/Reverse-a-string create mode 120000 Lang/Ela/Order-two-numerical-lists create mode 120000 Lang/Ela/Palindrome-detection create mode 120000 Lang/Ela/Parsing-RPN-calculator-algorithm create mode 120000 Lang/Ela/Polymorphism create mode 120000 Lang/Ela/Scope-modifiers create mode 120000 Lang/Ela/Set-consolidation create mode 120000 Lang/Elena/Binary-digits create mode 120000 Lang/Elisa/Queue-Definition create mode 120000 Lang/Emacs-Lisp/Arbitrary-precision-integers--included- delete mode 120000 Lang/Emacs-Lisp/Arbitrary-precision-integers-included create mode 120000 Lang/Emacs-Lisp/Dragon-curve create mode 120000 Lang/Emacs-Lisp/Environment-variables create mode 120000 Lang/Emacs-Lisp/Program-name create mode 120000 Lang/Emacs-Lisp/Reverse-a-string create mode 120000 Lang/Emacs-Lisp/Roman-numerals-Decode create mode 120000 Lang/Emacs-Lisp/Roman-numerals-Encode create mode 120000 Lang/Erlang/Arbitrary-precision-integers--included- delete mode 120000 Lang/Erlang/Arbitrary-precision-integers-included create mode 120000 Lang/Erlang/Binary-digits create mode 120000 Lang/Erlang/Catalan-numbers create mode 120000 Lang/Erlang/Copy-a-string create mode 120000 Lang/Erlang/Nth-root create mode 120000 Lang/Erlang/One-dimensional-cellular-automata create mode 120000 Lang/Erlang/Palindrome-detection create mode 120000 Lang/Erlang/Pangram-checker create mode 120000 Lang/Erlang/Pascals-triangle create mode 120000 Lang/Erlang/Perfect-numbers create mode 120000 Lang/Erlang/Permutations create mode 120000 Lang/Erlang/Power-set create mode 120000 Lang/Erlang/Price-fraction create mode 120000 Lang/Erlang/Primality-by-trial-division create mode 120000 Lang/Erlang/Prime-decomposition create mode 120000 Lang/Erlang/Program-name create mode 120000 Lang/Erlang/Pythagorean-triples create mode 120000 Lang/Erlang/Queue-Definition create mode 120000 Lang/Erlang/Queue-Usage create mode 120000 Lang/Erlang/Random-number-generator--included- create mode 120000 Lang/Erlang/Random-numbers create mode 120000 Lang/Erlang/Read-entire-file create mode 120000 Lang/Erlang/Regular-expressions create mode 120000 Lang/Erlang/Remove-duplicate-elements create mode 120000 Lang/Erlang/Rename-a-file create mode 120000 Lang/Erlang/Repeat-a-string create mode 120000 Lang/Erlang/Reverse-a-string create mode 120000 Lang/Erlang/Rock-paper-scissors create mode 120000 Lang/Erlang/Roman-numerals-Encode create mode 120000 Lang/Erlang/Rosetta-Code-Count-examples create mode 120000 Lang/Erlang/Rot-13 create mode 120000 Lang/Erlang/Run-length-encoding create mode 120000 Lang/Erlang/Runtime-evaluation create mode 120000 Lang/Erlang/Self-describing-numbers create mode 120000 Lang/Euler-Math-Toolbox/Random-numbers create mode 120000 Lang/Euler-Math-Toolbox/Resistor-mesh create mode 120000 Lang/Euler-Math-Toolbox/Reverse-a-string create mode 120000 Lang/Euphoria/Binary-digits create mode 120000 Lang/Euphoria/Catalan-numbers create mode 120000 Lang/Euphoria/Copy-a-string create mode 120000 Lang/Euphoria/Environment-variables create mode 120000 Lang/Euphoria/Guess-the-number-With-feedback--player- delete mode 120000 Lang/Euphoria/Guess-the-number-With-feedback-player create mode 120000 Lang/Euphoria/Non-decimal-radices-Convert create mode 120000 Lang/Euphoria/Non-decimal-radices-Output create mode 120000 Lang/Euphoria/Number-names create mode 120000 Lang/Euphoria/Number-reversal-game create mode 120000 Lang/Euphoria/Numerical-integration create mode 120000 Lang/Euphoria/One-dimensional-cellular-automata create mode 120000 Lang/Euphoria/One-of-n-lines-in-a-file create mode 120000 Lang/Euphoria/Palindrome-detection create mode 120000 Lang/Euphoria/Pascals-triangle create mode 120000 Lang/Euphoria/Permutations create mode 120000 Lang/Euphoria/Pick-random-element create mode 120000 Lang/Euphoria/Price-fraction create mode 120000 Lang/Euphoria/Primality-by-trial-division create mode 120000 Lang/Euphoria/Probabilistic-choice create mode 120000 Lang/Euphoria/Program-name create mode 120000 Lang/Euphoria/Pythagorean-triples create mode 120000 Lang/Euphoria/Quaternion-type create mode 120000 Lang/Euphoria/Random-numbers create mode 120000 Lang/Euphoria/Range-extraction create mode 120000 Lang/Euphoria/Read-a-file-line-by-line create mode 120000 Lang/Euphoria/Read-entire-file create mode 120000 Lang/Euphoria/Reduced-row-echelon-form create mode 120000 Lang/Euphoria/Remove-duplicate-elements create mode 120000 Lang/Euphoria/Repeat-a-string create mode 120000 Lang/Euphoria/Return-multiple-values create mode 120000 Lang/Euphoria/Reverse-a-string create mode 120000 Lang/Euphoria/Rock-paper-scissors create mode 120000 Lang/Euphoria/Roman-numerals-Decode create mode 120000 Lang/Euphoria/Roman-numerals-Encode create mode 120000 Lang/Euphoria/Rot-13 create mode 120000 Lang/Euphoria/Run-length-encoding create mode 120000 Lang/Euphoria/Sequence-of-non-squares create mode 120000 Lang/FALSE/Perfect-numbers create mode 120000 Lang/FALSE/Primality-by-trial-division create mode 120000 Lang/FALSE/Prime-decomposition create mode 120000 Lang/FALSE/Return-multiple-values create mode 120000 Lang/FALSE/Roman-numerals-Encode create mode 120000 Lang/FALSE/Rot-13 create mode 120000 Lang/FALSE/Run-length-encoding create mode 120000 Lang/FBSL/Reverse-a-string create mode 120000 Lang/Factor/Arbitrary-precision-integers--included- delete mode 120000 Lang/Factor/Arbitrary-precision-integers-included create mode 120000 Lang/Factor/Binary-digits create mode 120000 Lang/Factor/Catalan-numbers create mode 120000 Lang/Factor/Copy-a-string create mode 120000 Lang/Factor/Dragon-curve create mode 120000 Lang/Factor/Environment-variables create mode 120000 Lang/Factor/N-queens-problem create mode 120000 Lang/Factor/Non-decimal-radices-Convert create mode 120000 Lang/Factor/Non-decimal-radices-Input create mode 120000 Lang/Factor/Non-decimal-radices-Output create mode 120000 Lang/Factor/Null-object create mode 120000 Lang/Factor/Number-reversal-game create mode 120000 Lang/Factor/One-dimensional-cellular-automata create mode 120000 Lang/Factor/One-of-n-lines-in-a-file create mode 120000 Lang/Factor/OpenGL create mode 120000 Lang/Factor/Palindrome-detection create mode 120000 Lang/Factor/Pangram-checker create mode 120000 Lang/Factor/Pascals-triangle create mode 120000 Lang/Factor/Perfect-numbers create mode 120000 Lang/Factor/Pick-random-element create mode 120000 Lang/Factor/Polymorphic-copy create mode 120000 Lang/Factor/Polymorphism create mode 120000 Lang/Factor/Power-set create mode 120000 Lang/Factor/Primality-by-trial-division create mode 120000 Lang/Factor/Prime-decomposition create mode 120000 Lang/Factor/Priority-queue create mode 120000 Lang/Factor/Probabilistic-choice create mode 120000 Lang/Factor/Program-name create mode 120000 Lang/Factor/Pythagorean-triples create mode 120000 Lang/Factor/Random-numbers create mode 120000 Lang/Factor/Ray-casting-algorithm create mode 120000 Lang/Factor/Read-a-file-line-by-line create mode 120000 Lang/Factor/Read-entire-file create mode 120000 Lang/Factor/Real-constants-and-functions create mode 120000 Lang/Factor/Remove-duplicate-elements create mode 120000 Lang/Factor/Rename-a-file create mode 120000 Lang/Factor/Repeat-a-string create mode 120000 Lang/Factor/Return-multiple-values create mode 120000 Lang/Factor/Reverse-a-string create mode 120000 Lang/Factor/Roman-numerals-Encode create mode 120000 Lang/Factor/Roots-of-a-quadratic-function create mode 120000 Lang/Factor/Rot-13 create mode 120000 Lang/Factor/Send-email create mode 120000 Lang/Factor/Set create mode 120000 Lang/Fan/Roman-numerals-Encode create mode 120000 Lang/Fan/Run-length-encoding create mode 120000 Lang/Fancy/Respond-to-an-unknown-method-call create mode 120000 Lang/Fancy/Reverse-a-string create mode 120000 Lang/Fantom/Brownian-tree create mode 120000 Lang/Fantom/Catalan-numbers create mode 120000 Lang/Fantom/Guess-the-number-With-feedback--player- delete mode 120000 Lang/Fantom/Guess-the-number-With-feedback-player create mode 120000 Lang/Fantom/Null-object create mode 120000 Lang/Fantom/One-dimensional-cellular-automata create mode 120000 Lang/Fantom/Palindrome-detection create mode 120000 Lang/Fantom/Pascals-triangle create mode 120000 Lang/Fantom/Playing-cards create mode 120000 Lang/Fantom/Price-fraction create mode 120000 Lang/Fantom/Queue-Definition create mode 120000 Lang/Fantom/Queue-Usage create mode 120000 Lang/Fantom/Random-numbers create mode 120000 Lang/Fantom/Read-a-configuration-file create mode 120000 Lang/Fantom/Read-a-file-line-by-line create mode 120000 Lang/Fantom/Read-entire-file create mode 120000 Lang/Fantom/Real-constants-and-functions create mode 120000 Lang/Fantom/Rename-a-file create mode 120000 Lang/Fantom/Respond-to-an-unknown-method-call create mode 120000 Lang/Fantom/Rot-13 create mode 120000 Lang/Fantom/Send-email create mode 120000 Lang/Fantom/Sequence-of-non-squares create mode 120000 Lang/Forth/Binary-digits create mode 120000 Lang/Forth/Catalan-numbers create mode 120000 Lang/Forth/Copy-a-string create mode 120000 Lang/Forth/Dragon-curve create mode 120000 Lang/Forth/Environment-variables create mode 120000 Lang/Forth/N-queens-problem create mode 120000 Lang/Forth/Non-decimal-radices-Convert create mode 120000 Lang/Forth/Non-decimal-radices-Input create mode 120000 Lang/Forth/Non-decimal-radices-Output create mode 120000 Lang/Forth/Nth-root create mode 120000 Lang/Forth/Number-reversal-game create mode 120000 Lang/Forth/Numerical-integration create mode 120000 Lang/Forth/One-dimensional-cellular-automata create mode 120000 Lang/Forth/OpenGL create mode 120000 Lang/Forth/Palindrome-detection create mode 120000 Lang/Forth/Pangram-checker create mode 120000 Lang/Forth/Pascals-triangle create mode 120000 Lang/Forth/Percentage-difference-between-images create mode 120000 Lang/Forth/Perfect-numbers create mode 120000 Lang/Forth/Pig-the-dice-game create mode 120000 Lang/Forth/Playing-cards create mode 120000 Lang/Forth/Polymorphic-copy create mode 120000 Lang/Forth/Polymorphism create mode 120000 Lang/Forth/Power-set create mode 120000 Lang/Forth/Price-fraction create mode 120000 Lang/Forth/Primality-by-trial-division create mode 120000 Lang/Forth/Prime-decomposition create mode 120000 Lang/Forth/Probabilistic-choice create mode 120000 Lang/Forth/Program-name create mode 120000 Lang/Forth/Program-termination create mode 120000 Lang/Forth/Pythagorean-triples create mode 120000 Lang/Forth/Quaternion-type create mode 120000 Lang/Forth/Queue-Definition create mode 120000 Lang/Forth/Random-number-generator--device- create mode 120000 Lang/Forth/Random-numbers create mode 120000 Lang/Forth/Range-extraction create mode 120000 Lang/Forth/Read-a-file-line-by-line create mode 120000 Lang/Forth/Read-entire-file create mode 120000 Lang/Forth/Real-constants-and-functions create mode 120000 Lang/Forth/Regular-expressions create mode 120000 Lang/Forth/Remove-duplicate-elements create mode 120000 Lang/Forth/Rename-a-file create mode 120000 Lang/Forth/Repeat-a-string create mode 120000 Lang/Forth/Return-multiple-values create mode 120000 Lang/Forth/Reverse-a-string create mode 120000 Lang/Forth/Roman-numerals-Decode create mode 120000 Lang/Forth/Roman-numerals-Encode create mode 120000 Lang/Forth/Roots-of-a-quadratic-function create mode 120000 Lang/Forth/Roots-of-unity create mode 120000 Lang/Forth/Rot-13 create mode 120000 Lang/Forth/Run-length-encoding create mode 120000 Lang/Forth/Runtime-evaluation create mode 120000 Lang/Forth/Runtime-evaluation-In-an-environment create mode 120000 Lang/Forth/SEDOLs create mode 120000 Lang/Forth/Self-describing-numbers create mode 120000 Lang/Forth/Sequence-of-non-squares create mode 120000 Lang/Fortran/Brownian-tree create mode 120000 Lang/Fortran/Catalan-numbers create mode 120000 Lang/Fortran/Copy-a-string create mode 120000 Lang/Fortran/Environment-variables create mode 120000 Lang/Fortran/Guess-the-number-With-feedback--player- delete mode 120000 Lang/Fortran/Guess-the-number-With-feedback-player create mode 120000 Lang/Fortran/N-queens-problem create mode 120000 Lang/Fortran/Named-parameters create mode 120000 Lang/Fortran/Non-decimal-radices-Convert create mode 120000 Lang/Fortran/Non-decimal-radices-Input create mode 120000 Lang/Fortran/Non-decimal-radices-Output create mode 120000 Lang/Fortran/Nth-root create mode 120000 Lang/Fortran/Number-names create mode 120000 Lang/Fortran/Number-reversal-game create mode 120000 Lang/Fortran/Numerical-integration create mode 120000 Lang/Fortran/One-dimensional-cellular-automata create mode 120000 Lang/Fortran/Optional-parameters create mode 120000 Lang/Fortran/Palindrome-detection create mode 120000 Lang/Fortran/Pangram-checker create mode 120000 Lang/Fortran/Pascals-triangle create mode 120000 Lang/Fortran/Percentage-difference-between-images create mode 120000 Lang/Fortran/Perfect-numbers create mode 120000 Lang/Fortran/Permutations create mode 120000 Lang/Fortran/Playing-cards create mode 120000 Lang/Fortran/Pointers-and-references create mode 120000 Lang/Fortran/Polymorphism create mode 120000 Lang/Fortran/Polynomial-long-division create mode 120000 Lang/Fortran/Polynomial-regression create mode 120000 Lang/Fortran/Price-fraction create mode 120000 Lang/Fortran/Primality-by-trial-division create mode 120000 Lang/Fortran/Prime-decomposition create mode 120000 Lang/Fortran/Probabilistic-choice create mode 120000 Lang/Fortran/Problem-of-Apollonius create mode 120000 Lang/Fortran/Program-termination create mode 120000 Lang/Fortran/Pythagorean-triples create mode 120000 Lang/Fortran/Quaternion-type create mode 120000 Lang/Fortran/Queue-Definition create mode 120000 Lang/Fortran/Queue-Usage create mode 120000 Lang/Fortran/Random-numbers create mode 120000 Lang/Fortran/Ray-casting-algorithm create mode 120000 Lang/Fortran/Real-constants-and-functions create mode 120000 Lang/Fortran/Reduced-row-echelon-form create mode 120000 Lang/Fortran/Remove-duplicate-elements create mode 120000 Lang/Fortran/Rename-a-file create mode 120000 Lang/Fortran/Repeat-a-string create mode 120000 Lang/Fortran/Reverse-a-string create mode 120000 Lang/Fortran/Roman-numerals-Decode create mode 120000 Lang/Fortran/Roman-numerals-Encode create mode 120000 Lang/Fortran/Roots-of-a-function create mode 120000 Lang/Fortran/Roots-of-a-quadratic-function create mode 120000 Lang/Fortran/Roots-of-unity create mode 120000 Lang/Fortran/Rot-13 create mode 120000 Lang/Fortran/Run-length-encoding create mode 120000 Lang/Fortran/SEDOLs create mode 120000 Lang/Fortran/Sequence-of-non-squares create mode 120000 Lang/Frink/Arbitrary-precision-integers--included- delete mode 120000 Lang/Frink/Arbitrary-precision-integers-included create mode 120000 Lang/Frink/Catalan-numbers create mode 120000 Lang/Frink/Power-set create mode 120000 Lang/Frink/Prime-decomposition create mode 120000 Lang/Frink/Read-a-file-line-by-line create mode 120000 Lang/Frink/Read-entire-file create mode 120000 Lang/Frink/Regular-expressions create mode 120000 Lang/Frink/Repeat-a-string create mode 120000 Lang/Frink/Reverse-a-string create mode 120000 Lang/GAP/Arbitrary-precision-integers--included- delete mode 120000 Lang/GAP/Arbitrary-precision-integers-included create mode 120000 Lang/GAP/Catalan-numbers create mode 120000 Lang/GAP/Copy-a-string create mode 120000 Lang/GAP/Ordered-Partitions create mode 120000 Lang/GAP/Palindrome-detection create mode 120000 Lang/GAP/Pascals-triangle create mode 120000 Lang/GAP/Perfect-numbers create mode 120000 Lang/GAP/Permutation-test create mode 120000 Lang/GAP/Permutations create mode 120000 Lang/GAP/Permutations-Derangements create mode 120000 Lang/GAP/Polynomial-long-division create mode 120000 Lang/GAP/Polynomial-regression create mode 120000 Lang/GAP/Power-set create mode 120000 Lang/GAP/Primality-by-trial-division create mode 120000 Lang/GAP/Prime-decomposition create mode 120000 Lang/GAP/Quaternion-type create mode 120000 Lang/GAP/Queue-Definition create mode 120000 Lang/GAP/Random-number-generator--included- create mode 120000 Lang/GAP/Read-a-file-line-by-line create mode 120000 Lang/GAP/Read-entire-file create mode 120000 Lang/GAP/Remove-duplicate-elements create mode 120000 Lang/GAP/Repeat-a-string create mode 120000 Lang/GAP/Reverse-a-string create mode 120000 Lang/GAP/Roots-of-a-quadratic-function create mode 120000 Lang/GAP/Roots-of-unity create mode 120000 Lang/GAP/Rot-13 create mode 120000 Lang/GAP/Sequence-of-non-squares create mode 120000 Lang/GML/Copy-a-string create mode 120000 Lang/GML/Palindrome-detection create mode 120000 Lang/GML/Rot-13 create mode 120000 Lang/GUISS/Calendar---for-real-programmers delete mode 120000 Lang/GUISS/Calendar-for-real-programmers create mode 120000 Lang/GUISS/Copy-a-string create mode 120000 Lang/GUISS/Play-recorded-sounds create mode 120000 Lang/GUISS/Read-entire-file create mode 120000 Lang/GUISS/Record-sound create mode 120000 Lang/GW-BASIC/Pascals-triangle create mode 120000 Lang/GW-BASIC/Program-termination create mode 120000 Lang/GW-BASIC/Rot-13 create mode 120000 Lang/GW-BASIC/Runtime-evaluation create mode 120000 Lang/Gambas/Copy-a-string create mode 120000 Lang/Gema/Non-decimal-radices-Output create mode 120000 Lang/Gema/Program-termination create mode 120000 Lang/Gema/Reverse-a-string create mode 120000 Lang/Gema/Rot-13 create mode 120000 Lang/Genyris/Runtime-evaluation-In-an-environment create mode 120000 Lang/Go/Arbitrary-precision-integers--included- delete mode 120000 Lang/Go/Arbitrary-precision-integers-included create mode 120000 Lang/Go/Binary-digits create mode 120000 Lang/Go/Brownian-tree create mode 120000 Lang/Go/Catalan-numbers create mode 120000 Lang/Go/Copy-a-string create mode 120000 Lang/Go/Dragon-curve create mode 120000 Lang/Go/Environment-variables create mode 120000 Lang/Go/Execute-a-Markov-algorithm create mode 120000 Lang/Go/Guess-the-number-With-feedback--player- delete mode 120000 Lang/Go/Guess-the-number-With-feedback-player create mode 120000 Lang/Go/N-queens-problem create mode 120000 Lang/Go/Non-continuous-subsequences create mode 120000 Lang/Go/Non-decimal-radices-Convert create mode 120000 Lang/Go/Non-decimal-radices-Input create mode 120000 Lang/Go/Non-decimal-radices-Output create mode 120000 Lang/Go/Nth-root create mode 120000 Lang/Go/Null-object create mode 120000 Lang/Go/Number-names create mode 120000 Lang/Go/Number-reversal-game create mode 120000 Lang/Go/Numeric-error-propagation create mode 120000 Lang/Go/Numerical-integration create mode 120000 Lang/Go/Numerical-integration-Gauss-Legendre-Quadrature create mode 120000 Lang/Go/Object-serialization create mode 120000 Lang/Go/One-dimensional-cellular-automata create mode 120000 Lang/Go/One-of-n-lines-in-a-file create mode 120000 Lang/Go/Optional-parameters create mode 120000 Lang/Go/Order-two-numerical-lists create mode 120000 Lang/Go/Ordered-Partitions create mode 120000 Lang/Go/Palindrome-detection create mode 120000 Lang/Go/Pangram-checker create mode 120000 Lang/Go/Parallel-calculations create mode 120000 Lang/Go/Parametric-polymorphism create mode 120000 Lang/Go/Parsing-RPN-calculator-algorithm create mode 120000 Lang/Go/Parsing-RPN-to-infix-conversion create mode 120000 Lang/Go/Parsing-Shunting-yard-algorithm create mode 120000 Lang/Go/Pascals-triangle create mode 120000 Lang/Go/Pascals-triangle-Puzzle create mode 120000 Lang/Go/Percentage-difference-between-images create mode 120000 Lang/Go/Perfect-numbers create mode 120000 Lang/Go/Permutation-test create mode 120000 Lang/Go/Permutations create mode 120000 Lang/Go/Permutations-Derangements create mode 120000 Lang/Go/Pick-random-element create mode 120000 Lang/Go/Pig-the-dice-game-Player create mode 120000 Lang/Go/Playing-cards create mode 120000 Lang/Go/Pointers-and-references create mode 120000 Lang/Go/Polymorphic-copy create mode 120000 Lang/Go/Polymorphism create mode 120000 Lang/Go/Polynomial-long-division create mode 120000 Lang/Go/Polynomial-regression create mode 120000 Lang/Go/Power-set create mode 120000 Lang/Go/Pragmatic-directives create mode 120000 Lang/Go/Price-fraction create mode 120000 Lang/Go/Primality-by-trial-division create mode 120000 Lang/Go/Prime-decomposition create mode 120000 Lang/Go/Priority-queue create mode 120000 Lang/Go/Probabilistic-choice create mode 120000 Lang/Go/Problem-of-Apollonius create mode 120000 Lang/Go/Program-name create mode 120000 Lang/Go/Program-termination create mode 120000 Lang/Go/Pythagorean-triples create mode 120000 Lang/Go/QR-decomposition create mode 120000 Lang/Go/Quaternion-type create mode 120000 Lang/Go/Queue-Definition create mode 120000 Lang/Go/Queue-Usage create mode 120000 Lang/Go/RIPEMD-160 create mode 120000 Lang/Go/Random-number-generator--device- create mode 120000 Lang/Go/Random-numbers create mode 120000 Lang/Go/Range-expansion create mode 120000 Lang/Go/Range-extraction create mode 120000 Lang/Go/Rate-counter create mode 120000 Lang/Go/Ray-casting-algorithm create mode 120000 Lang/Go/Read-a-configuration-file create mode 120000 Lang/Go/Read-a-file-line-by-line create mode 120000 Lang/Go/Read-a-specific-line-from-a-file create mode 120000 Lang/Go/Read-entire-file create mode 120000 Lang/Go/Real-constants-and-functions create mode 120000 Lang/Go/Reduced-row-echelon-form create mode 120000 Lang/Go/Regular-expressions create mode 120000 Lang/Go/Remove-duplicate-elements create mode 120000 Lang/Go/Remove-lines-from-a-file create mode 120000 Lang/Go/Rename-a-file create mode 120000 Lang/Go/Rendezvous create mode 120000 Lang/Go/Repeat-a-string create mode 120000 Lang/Go/Respond-to-an-unknown-method-call create mode 120000 Lang/Go/Return-multiple-values create mode 120000 Lang/Go/Reverse-a-string create mode 120000 Lang/Go/Rock-paper-scissors create mode 120000 Lang/Go/Roman-numerals-Decode create mode 120000 Lang/Go/Roman-numerals-Encode create mode 120000 Lang/Go/Roots-of-a-function create mode 120000 Lang/Go/Roots-of-a-quadratic-function create mode 120000 Lang/Go/Roots-of-unity create mode 120000 Lang/Go/Rosetta-Code-Count-examples create mode 120000 Lang/Go/Rosetta-Code-Find-unimplemented-tasks create mode 120000 Lang/Go/Rosetta-Code-Fix-code-tags create mode 120000 Lang/Go/Rosetta-Code-Rank-languages-by-popularity create mode 120000 Lang/Go/Rot-13 create mode 120000 Lang/Go/Run-length-encoding create mode 120000 Lang/Go/Runtime-evaluation create mode 120000 Lang/Go/Runtime-evaluation-In-an-environment create mode 120000 Lang/Go/S-Expressions create mode 120000 Lang/Go/SEDOLs create mode 120000 Lang/Go/Safe-addition create mode 120000 Lang/Go/Same-Fringe create mode 120000 Lang/Go/Secure-temporary-file create mode 120000 Lang/Go/Self-describing-numbers create mode 120000 Lang/Go/Self-referential-sequence create mode 120000 Lang/Go/Semordnilap create mode 120000 Lang/Go/Send-an-unknown-method-call create mode 120000 Lang/Go/Send-email create mode 120000 Lang/Go/Sequence-of-non-squares create mode 120000 Lang/Go/Set create mode 120000 Lang/Go/Set-consolidation create mode 120000 Lang/Golfscript/Arbitrary-precision-integers--included- delete mode 120000 Lang/Golfscript/Arbitrary-precision-integers-included create mode 120000 Lang/Groovy/Arbitrary-precision-integers--included- delete mode 120000 Lang/Groovy/Arbitrary-precision-integers-included create mode 120000 Lang/Groovy/Binary-digits create mode 120000 Lang/Groovy/Copy-a-string create mode 120000 Lang/Groovy/Environment-variables create mode 120000 Lang/Groovy/Execute-a-Markov-algorithm create mode 120000 Lang/Groovy/N-queens-problem create mode 120000 Lang/Groovy/Non-decimal-radices-Convert create mode 120000 Lang/Groovy/Nth-root create mode 120000 Lang/Groovy/Number-names create mode 120000 Lang/Groovy/Number-reversal-game create mode 120000 Lang/Groovy/Numerical-integration create mode 120000 Lang/Groovy/Object-serialization create mode 120000 Lang/Groovy/One-dimensional-cellular-automata create mode 120000 Lang/Groovy/Order-two-numerical-lists create mode 120000 Lang/Groovy/Ordered-Partitions create mode 120000 Lang/Groovy/Palindrome-detection create mode 120000 Lang/Groovy/Parsing-RPN-calculator-algorithm create mode 120000 Lang/Groovy/Pascals-triangle create mode 120000 Lang/Groovy/Perfect-numbers create mode 120000 Lang/Groovy/Permutations create mode 120000 Lang/Groovy/Permutations-Derangements create mode 120000 Lang/Groovy/Pick-random-element create mode 120000 Lang/Groovy/Pig-the-dice-game create mode 120000 Lang/Groovy/Playing-cards create mode 120000 Lang/Groovy/Plot-coordinate-pairs create mode 120000 Lang/Groovy/Power-set create mode 120000 Lang/Groovy/Price-fraction create mode 120000 Lang/Groovy/Primality-by-trial-division create mode 120000 Lang/Groovy/Prime-decomposition create mode 120000 Lang/Groovy/Program-name create mode 120000 Lang/Groovy/Program-termination create mode 120000 Lang/Groovy/Queue-Definition create mode 120000 Lang/Groovy/Queue-Usage create mode 120000 Lang/Groovy/Random-number-generator--device- create mode 120000 Lang/Groovy/Random-numbers create mode 120000 Lang/Groovy/Range-expansion create mode 120000 Lang/Groovy/Range-extraction create mode 120000 Lang/Groovy/Read-a-file-line-by-line create mode 120000 Lang/Groovy/Read-a-specific-line-from-a-file create mode 120000 Lang/Groovy/Read-entire-file create mode 120000 Lang/Groovy/Real-constants-and-functions create mode 120000 Lang/Groovy/Reduced-row-echelon-form create mode 120000 Lang/Groovy/Regular-expressions create mode 120000 Lang/Groovy/Remove-duplicate-elements create mode 120000 Lang/Groovy/Rename-a-file create mode 120000 Lang/Groovy/Repeat-a-string create mode 120000 Lang/Groovy/Return-multiple-values create mode 120000 Lang/Groovy/Reverse-a-string create mode 120000 Lang/Groovy/Roman-numerals-Decode create mode 120000 Lang/Groovy/Roman-numerals-Encode create mode 120000 Lang/Groovy/Roots-of-unity create mode 120000 Lang/Groovy/Rot-13 create mode 120000 Lang/Groovy/Run-length-encoding create mode 120000 Lang/Groovy/Runtime-evaluation create mode 120000 Lang/Groovy/Runtime-evaluation-In-an-environment create mode 120000 Lang/Groovy/SEDOLs create mode 120000 Lang/Groovy/Secure-temporary-file create mode 120000 Lang/Groovy/Semordnilap create mode 120000 Lang/Groovy/Sequence-of-non-squares create mode 120000 Lang/Groovy/Set create mode 120000 Lang/Haskell/Arbitrary-precision-integers--included- delete mode 120000 Lang/Haskell/Arbitrary-precision-integers-included create mode 120000 Lang/Haskell/Binary-digits create mode 120000 Lang/Haskell/Brownian-tree create mode 120000 Lang/Haskell/Catalan-numbers create mode 120000 Lang/Haskell/Dragon-curve create mode 120000 Lang/Haskell/Environment-variables create mode 120000 Lang/Haskell/Execute-a-Markov-algorithm create mode 120000 Lang/Haskell/N-queens-problem create mode 120000 Lang/Haskell/Named-parameters create mode 120000 Lang/Haskell/Non-continuous-subsequences create mode 120000 Lang/Haskell/Non-decimal-radices-Convert create mode 120000 Lang/Haskell/Non-decimal-radices-Input create mode 120000 Lang/Haskell/Non-decimal-radices-Output create mode 120000 Lang/Haskell/Nth-root create mode 120000 Lang/Haskell/Null-object create mode 120000 Lang/Haskell/Number-names create mode 120000 Lang/Haskell/Number-reversal-game create mode 120000 Lang/Haskell/Numeric-error-propagation create mode 120000 Lang/Haskell/Numerical-integration create mode 120000 Lang/Haskell/One-dimensional-cellular-automata create mode 120000 Lang/Haskell/One-of-n-lines-in-a-file create mode 120000 Lang/Haskell/OpenGL create mode 120000 Lang/Haskell/Order-two-numerical-lists create mode 120000 Lang/Haskell/Ordered-Partitions create mode 120000 Lang/Haskell/Palindrome-detection create mode 120000 Lang/Haskell/Pangram-checker create mode 120000 Lang/Haskell/Parametric-polymorphism create mode 120000 Lang/Haskell/Parsing-RPN-calculator-algorithm create mode 120000 Lang/Haskell/Parsing-Shunting-yard-algorithm create mode 120000 Lang/Haskell/Partial-function-application create mode 120000 Lang/Haskell/Pascals-triangle create mode 120000 Lang/Haskell/Pascals-triangle-Puzzle create mode 120000 Lang/Haskell/Pattern-matching create mode 120000 Lang/Haskell/Perfect-numbers create mode 120000 Lang/Haskell/Permutation-test create mode 120000 Lang/Haskell/Permutations create mode 120000 Lang/Haskell/Permutations-Derangements create mode 120000 Lang/Haskell/Permutations-by-swapping create mode 120000 Lang/Haskell/Pick-random-element create mode 120000 Lang/Haskell/Playing-cards create mode 120000 Lang/Haskell/Plot-coordinate-pairs create mode 120000 Lang/Haskell/Pointers-and-references create mode 120000 Lang/Haskell/Polymorphism create mode 120000 Lang/Haskell/Polynomial-long-division create mode 120000 Lang/Haskell/Polynomial-regression create mode 120000 Lang/Haskell/Power-set create mode 120000 Lang/Haskell/Price-fraction create mode 120000 Lang/Haskell/Primality-by-trial-division create mode 120000 Lang/Haskell/Prime-decomposition create mode 120000 Lang/Haskell/Priority-queue create mode 120000 Lang/Haskell/Probabilistic-choice create mode 120000 Lang/Haskell/Problem-of-Apollonius create mode 120000 Lang/Haskell/Program-name create mode 120000 Lang/Haskell/Program-termination create mode 120000 Lang/Haskell/Pythagorean-triples create mode 120000 Lang/Haskell/Quaternion-type create mode 120000 Lang/Haskell/Queue-Definition create mode 120000 Lang/Haskell/Queue-Usage create mode 120000 Lang/Haskell/Random-number-generator--device- create mode 120000 Lang/Haskell/Random-numbers create mode 120000 Lang/Haskell/Range-expansion create mode 120000 Lang/Haskell/Range-extraction create mode 120000 Lang/Haskell/Ray-casting-algorithm create mode 120000 Lang/Haskell/Read-a-configuration-file create mode 120000 Lang/Haskell/Read-a-specific-line-from-a-file create mode 120000 Lang/Haskell/Read-entire-file create mode 120000 Lang/Haskell/Real-constants-and-functions create mode 120000 Lang/Haskell/Reduced-row-echelon-form create mode 120000 Lang/Haskell/Regular-expressions create mode 120000 Lang/Haskell/Remove-duplicate-elements create mode 120000 Lang/Haskell/Remove-lines-from-a-file create mode 120000 Lang/Haskell/Rename-a-file create mode 120000 Lang/Haskell/Repeat-a-string create mode 120000 Lang/Haskell/Return-multiple-values create mode 120000 Lang/Haskell/Reverse-a-string create mode 120000 Lang/Haskell/Rock-paper-scissors create mode 120000 Lang/Haskell/Roman-numerals-Decode create mode 120000 Lang/Haskell/Roman-numerals-Encode create mode 120000 Lang/Haskell/Roots-of-a-function create mode 120000 Lang/Haskell/Roots-of-a-quadratic-function create mode 120000 Lang/Haskell/Roots-of-unity create mode 120000 Lang/Haskell/Rosetta-Code-Count-examples create mode 120000 Lang/Haskell/Rosetta-Code-Find-unimplemented-tasks create mode 120000 Lang/Haskell/Rosetta-Code-Rank-languages-by-popularity create mode 120000 Lang/Haskell/Rot-13 create mode 120000 Lang/Haskell/Run-length-encoding create mode 120000 Lang/Haskell/S-Expressions create mode 120000 Lang/Haskell/SEDOLs create mode 120000 Lang/Haskell/Same-Fringe create mode 120000 Lang/Haskell/Secure-temporary-file create mode 120000 Lang/Haskell/Self-describing-numbers create mode 120000 Lang/Haskell/Self-referential-sequence create mode 120000 Lang/Haskell/Semordnilap create mode 120000 Lang/Haskell/Sequence-of-non-squares create mode 120000 Lang/Haskell/Set create mode 120000 Lang/Haskell/Set-consolidation create mode 120000 Lang/Heron/N-queens-problem create mode 120000 Lang/HicEst/Copy-a-string create mode 120000 Lang/HicEst/Dragon-curve create mode 120000 Lang/HicEst/Environment-variables create mode 120000 Lang/HicEst/Non-decimal-radices-Convert create mode 120000 Lang/HicEst/Non-decimal-radices-Input create mode 120000 Lang/HicEst/Non-decimal-radices-Output create mode 120000 Lang/HicEst/Nth-root create mode 120000 Lang/HicEst/Number-names create mode 120000 Lang/HicEst/Number-reversal-game create mode 120000 Lang/HicEst/Palindrome-detection create mode 120000 Lang/HicEst/Pangram-checker create mode 120000 Lang/HicEst/Pascals-triangle create mode 120000 Lang/HicEst/Perfect-numbers create mode 120000 Lang/HicEst/Plot-coordinate-pairs create mode 120000 Lang/HicEst/Polynomial-regression create mode 120000 Lang/HicEst/Price-fraction create mode 120000 Lang/HicEst/Primality-by-trial-division create mode 120000 Lang/HicEst/Probabilistic-choice create mode 120000 Lang/HicEst/Program-termination create mode 120000 Lang/HicEst/Random-numbers create mode 120000 Lang/HicEst/Rate-counter create mode 120000 Lang/HicEst/Real-constants-and-functions create mode 120000 Lang/HicEst/Regular-expressions create mode 120000 Lang/HicEst/Remove-duplicate-elements create mode 120000 Lang/HicEst/Rename-a-file create mode 120000 Lang/HicEst/Repeat-a-string create mode 120000 Lang/HicEst/Reverse-a-string create mode 120000 Lang/HicEst/Roman-numerals-Encode create mode 120000 Lang/HicEst/Roots-of-a-function create mode 120000 Lang/HicEst/Rosetta-Code-Rank-languages-by-popularity create mode 120000 Lang/HicEst/Rot-13 create mode 120000 Lang/HicEst/Runtime-evaluation create mode 120000 Lang/HicEst/Secure-temporary-file create mode 120000 Lang/HicEst/Sequence-of-non-squares create mode 120000 Lang/IDL/Pascals-triangle create mode 120000 Lang/IDL/Random-numbers create mode 120000 Lang/IDL/Remove-duplicate-elements create mode 120000 Lang/IDL/Roots-of-a-quadratic-function create mode 120000 Lang/IDL/Roots-of-unity create mode 120000 Lang/IDL/Sequence-of-non-squares create mode 120000 Lang/Icon/Arbitrary-precision-integers--included- delete mode 120000 Lang/Icon/Arbitrary-precision-integers-included create mode 120000 Lang/Icon/Binary-digits create mode 120000 Lang/Icon/Brownian-tree create mode 120000 Lang/Icon/Calendar---for-real-programmers delete mode 120000 Lang/Icon/Calendar-for-real-programmers create mode 120000 Lang/Icon/Catalan-numbers create mode 120000 Lang/Icon/Copy-a-string create mode 120000 Lang/Icon/Dragon-curve create mode 120000 Lang/Icon/Environment-variables create mode 120000 Lang/Icon/Execute-a-Markov-algorithm create mode 120000 Lang/Icon/Guess-the-number-With-feedback--player- delete mode 120000 Lang/Icon/Guess-the-number-With-feedback-player create mode 120000 Lang/Icon/N-queens-problem create mode 120000 Lang/Icon/Named-parameters create mode 120000 Lang/Icon/Non-decimal-radices-Convert create mode 120000 Lang/Icon/Non-decimal-radices-Input create mode 120000 Lang/Icon/Non-decimal-radices-Output create mode 120000 Lang/Icon/Nth-root create mode 120000 Lang/Icon/Null-object create mode 120000 Lang/Icon/Number-reversal-game create mode 120000 Lang/Icon/One-dimensional-cellular-automata create mode 120000 Lang/Icon/One-of-n-lines-in-a-file create mode 120000 Lang/Icon/Optional-parameters create mode 120000 Lang/Icon/Order-two-numerical-lists create mode 120000 Lang/Icon/Palindrome-detection create mode 120000 Lang/Icon/Pangram-checker create mode 120000 Lang/Icon/Parsing-RPN-calculator-algorithm create mode 120000 Lang/Icon/Parsing-RPN-to-infix-conversion create mode 120000 Lang/Icon/Parsing-Shunting-yard-algorithm create mode 120000 Lang/Icon/Partial-function-application create mode 120000 Lang/Icon/Pascals-triangle create mode 120000 Lang/Icon/Percentage-difference-between-images create mode 120000 Lang/Icon/Perfect-numbers create mode 120000 Lang/Icon/Permutations create mode 120000 Lang/Icon/Pick-random-element create mode 120000 Lang/Icon/Pinstripe-Display create mode 120000 Lang/Icon/Playing-cards create mode 120000 Lang/Icon/Plot-coordinate-pairs create mode 120000 Lang/Icon/Power-set create mode 120000 Lang/Icon/Pragmatic-directives create mode 120000 Lang/Icon/Price-fraction create mode 120000 Lang/Icon/Primality-by-trial-division create mode 120000 Lang/Icon/Prime-decomposition create mode 120000 Lang/Icon/Priority-queue create mode 120000 Lang/Icon/Probabilistic-choice create mode 120000 Lang/Icon/Problem-of-Apollonius create mode 120000 Lang/Icon/Program-name create mode 120000 Lang/Icon/Program-termination create mode 120000 Lang/Icon/Pythagorean-triples create mode 120000 Lang/Icon/Queue-Usage create mode 120000 Lang/Icon/Random-numbers create mode 120000 Lang/Icon/Range-expansion create mode 120000 Lang/Icon/Range-extraction create mode 120000 Lang/Icon/Read-a-specific-line-from-a-file create mode 120000 Lang/Icon/Read-entire-file create mode 120000 Lang/Icon/Regular-expressions create mode 120000 Lang/Icon/Remove-duplicate-elements create mode 120000 Lang/Icon/Remove-lines-from-a-file create mode 120000 Lang/Icon/Rename-a-file create mode 120000 Lang/Icon/Repeat-a-string create mode 120000 Lang/Icon/Return-multiple-values create mode 120000 Lang/Icon/Reverse-a-string create mode 120000 Lang/Icon/Rock-paper-scissors create mode 120000 Lang/Icon/Roman-numerals-Decode create mode 120000 Lang/Icon/Roman-numerals-Encode create mode 120000 Lang/Icon/Roots-of-unity create mode 120000 Lang/Icon/Rot-13 create mode 120000 Lang/Icon/Run-length-encoding create mode 120000 Lang/Icon/S-Expressions create mode 120000 Lang/Icon/SEDOLs create mode 120000 Lang/Icon/Scope-modifiers create mode 120000 Lang/Icon/Self-describing-numbers create mode 120000 Lang/Icon/Self-referential-sequence create mode 120000 Lang/Icon/Sequence-of-non-squares create mode 120000 Lang/Icon/Set create mode 120000 Lang/Inform-7/Number-names create mode 120000 Lang/Inform-7/Number-reversal-game create mode 120000 Lang/Inform-7/Parametric-polymorphism create mode 120000 Lang/Inform-7/Polymorphism create mode 120000 Lang/Inform-7/Price-fraction create mode 120000 Lang/Inform-7/Read-entire-file create mode 120000 Lang/Inform-7/Regular-expressions create mode 120000 Lang/Inform-7/Remove-duplicate-elements create mode 120000 Lang/Inform-7/Repeat-a-string create mode 120000 Lang/Io/Null-object create mode 120000 Lang/Io/Number-reversal-game create mode 120000 Lang/Io/Program-name create mode 120000 Lang/Io/Rename-a-file create mode 120000 Lang/Io/Reverse-a-string create mode 120000 Lang/Io/Roman-numerals-Encode create mode 120000 Lang/Ioke/Palindrome-detection create mode 120000 Lang/Ioke/Pangram-checker create mode 120000 Lang/J/Arbitrary-precision-integers--included- delete mode 120000 Lang/J/Arbitrary-precision-integers-included create mode 120000 Lang/J/Binary-digits create mode 120000 Lang/J/Brownian-tree create mode 120000 Lang/J/Calendar---for-real-programmers delete mode 120000 Lang/J/Calendar-for-real-programmers create mode 120000 Lang/J/Catalan-numbers create mode 120000 Lang/J/Copy-a-string create mode 120000 Lang/J/Dragon-curve create mode 120000 Lang/J/Environment-variables create mode 120000 Lang/J/Execute-a-Markov-algorithm create mode 120000 Lang/J/Guess-the-number-With-feedback--player- delete mode 120000 Lang/J/Guess-the-number-With-feedback-player create mode 120000 Lang/J/N-queens-problem create mode 120000 Lang/J/Named-parameters create mode 120000 Lang/J/Non-continuous-subsequences create mode 120000 Lang/J/Non-decimal-radices-Convert create mode 120000 Lang/J/Non-decimal-radices-Input create mode 120000 Lang/J/Non-decimal-radices-Output create mode 120000 Lang/J/Nth-root create mode 120000 Lang/J/Null-object create mode 120000 Lang/J/Number-reversal-game create mode 120000 Lang/J/Numeric-error-propagation create mode 120000 Lang/J/Numerical-integration create mode 120000 Lang/J/Numerical-integration-Gauss-Legendre-Quadrature create mode 120000 Lang/J/Object-serialization create mode 120000 Lang/J/One-dimensional-cellular-automata create mode 120000 Lang/J/One-of-n-lines-in-a-file create mode 120000 Lang/J/OpenGL create mode 120000 Lang/J/Optional-parameters create mode 120000 Lang/J/Order-two-numerical-lists create mode 120000 Lang/J/Ordered-Partitions create mode 120000 Lang/J/Palindrome-detection create mode 120000 Lang/J/Pangram-checker create mode 120000 Lang/J/Parallel-calculations create mode 120000 Lang/J/Parsing-RPN-calculator-algorithm create mode 120000 Lang/J/Parsing-RPN-to-infix-conversion create mode 120000 Lang/J/Parsing-Shunting-yard-algorithm create mode 120000 Lang/J/Partial-function-application create mode 120000 Lang/J/Pascals-triangle create mode 120000 Lang/J/Pascals-triangle-Puzzle create mode 120000 Lang/J/Pattern-matching create mode 120000 Lang/J/Percentage-difference-between-images create mode 120000 Lang/J/Perfect-numbers create mode 120000 Lang/J/Permutation-test create mode 120000 Lang/J/Permutations create mode 120000 Lang/J/Permutations-Derangements create mode 120000 Lang/J/Permutations-by-swapping create mode 120000 Lang/J/Pick-random-element create mode 120000 Lang/J/Pig-the-dice-game create mode 120000 Lang/J/Pig-the-dice-game-Player create mode 120000 Lang/J/Pinstripe-Display create mode 120000 Lang/J/Playing-cards create mode 120000 Lang/J/Plot-coordinate-pairs create mode 120000 Lang/J/Polymorphism create mode 120000 Lang/J/Polynomial-long-division create mode 120000 Lang/J/Polynomial-regression create mode 120000 Lang/J/Power-set create mode 120000 Lang/J/Pragmatic-directives create mode 120000 Lang/J/Price-fraction create mode 120000 Lang/J/Primality-by-trial-division create mode 120000 Lang/J/Prime-decomposition create mode 120000 Lang/J/Priority-queue create mode 120000 Lang/J/Probabilistic-choice create mode 120000 Lang/J/Problem-of-Apollonius create mode 120000 Lang/J/Program-name create mode 120000 Lang/J/Program-termination create mode 120000 Lang/J/Pythagorean-triples create mode 120000 Lang/J/QR-decomposition create mode 120000 Lang/J/Quaternion-type create mode 120000 Lang/J/Queue-Definition create mode 120000 Lang/J/Queue-Usage create mode 120000 Lang/J/Random-number-generator--device- create mode 120000 Lang/J/Random-numbers create mode 120000 Lang/J/Range-expansion create mode 120000 Lang/J/Range-extraction create mode 120000 Lang/J/Rate-counter create mode 120000 Lang/J/Ray-casting-algorithm create mode 120000 Lang/J/Read-a-configuration-file create mode 120000 Lang/J/Read-a-file-line-by-line create mode 120000 Lang/J/Read-a-specific-line-from-a-file create mode 120000 Lang/J/Read-entire-file create mode 120000 Lang/J/Real-constants-and-functions create mode 120000 Lang/J/Reduced-row-echelon-form create mode 120000 Lang/J/Regular-expressions create mode 120000 Lang/J/Remove-duplicate-elements create mode 120000 Lang/J/Remove-lines-from-a-file create mode 120000 Lang/J/Rename-a-file create mode 120000 Lang/J/Repeat-a-string create mode 120000 Lang/J/Resistor-mesh create mode 120000 Lang/J/Respond-to-an-unknown-method-call create mode 120000 Lang/J/Return-multiple-values create mode 120000 Lang/J/Reverse-a-string create mode 120000 Lang/J/Rock-paper-scissors create mode 120000 Lang/J/Roman-numerals-Decode create mode 120000 Lang/J/Roman-numerals-Encode create mode 120000 Lang/J/Roots-of-a-function create mode 120000 Lang/J/Roots-of-a-quadratic-function create mode 120000 Lang/J/Roots-of-unity create mode 120000 Lang/J/Rosetta-Code-Count-examples create mode 120000 Lang/J/Rosetta-Code-Find-unimplemented-tasks create mode 120000 Lang/J/Rosetta-Code-Fix-code-tags create mode 120000 Lang/J/Rot-13 create mode 120000 Lang/J/Run-length-encoding create mode 120000 Lang/J/Runtime-evaluation create mode 120000 Lang/J/Runtime-evaluation-In-an-environment create mode 120000 Lang/J/S-Expressions create mode 120000 Lang/J/SEDOLs create mode 120000 Lang/J/Safe-addition create mode 120000 Lang/J/Same-Fringe create mode 120000 Lang/J/Scope-modifiers create mode 120000 Lang/J/Self-describing-numbers create mode 120000 Lang/J/Self-referential-sequence create mode 120000 Lang/J/Semordnilap create mode 120000 Lang/J/Sequence-of-non-squares create mode 120000 Lang/J/Set create mode 120000 Lang/J/Set-consolidation create mode 120000 Lang/J/Set-of-real-numbers create mode 120000 Lang/Java/Arbitrary-precision-integers--included- delete mode 120000 Lang/Java/Arbitrary-precision-integers-included create mode 120000 Lang/Java/Binary-digits create mode 120000 Lang/Java/Brownian-tree create mode 120000 Lang/Java/Catalan-numbers create mode 120000 Lang/Java/Copy-a-string create mode 120000 Lang/Java/Dragon-curve create mode 120000 Lang/Java/Environment-variables create mode 120000 Lang/Java/Guess-the-number-With-feedback--player- delete mode 120000 Lang/Java/Guess-the-number-With-feedback-player create mode 120000 Lang/Java/N-queens-problem create mode 120000 Lang/Java/Named-parameters create mode 120000 Lang/Java/Non-decimal-radices-Convert create mode 120000 Lang/Java/Non-decimal-radices-Input create mode 120000 Lang/Java/Non-decimal-radices-Output create mode 120000 Lang/Java/Nth-root create mode 120000 Lang/Java/Null-object create mode 120000 Lang/Java/Number-names create mode 120000 Lang/Java/Number-reversal-game create mode 120000 Lang/Java/Numerical-integration create mode 120000 Lang/Java/Object-serialization create mode 120000 Lang/Java/One-dimensional-cellular-automata create mode 120000 Lang/Java/One-of-n-lines-in-a-file create mode 120000 Lang/Java/OpenGL create mode 120000 Lang/Java/Optional-parameters create mode 120000 Lang/Java/Order-two-numerical-lists create mode 120000 Lang/Java/Palindrome-detection create mode 120000 Lang/Java/Pangram-checker create mode 120000 Lang/Java/Parametric-polymorphism create mode 120000 Lang/Java/Parametrized-SQL-statement create mode 120000 Lang/Java/Parsing-RPN-calculator-algorithm create mode 120000 Lang/Java/Partial-function-application create mode 120000 Lang/Java/Pascals-triangle create mode 120000 Lang/Java/Percentage-difference-between-images create mode 120000 Lang/Java/Perfect-numbers create mode 120000 Lang/Java/Permutations create mode 120000 Lang/Java/Permutations-Derangements create mode 120000 Lang/Java/Pick-random-element create mode 120000 Lang/Java/Pig-the-dice-game create mode 120000 Lang/Java/Playing-cards create mode 120000 Lang/Java/Plot-coordinate-pairs create mode 120000 Lang/Java/Pointers-and-references create mode 120000 Lang/Java/Polymorphic-copy create mode 120000 Lang/Java/Polymorphism create mode 120000 Lang/Java/Power-set create mode 120000 Lang/Java/Price-fraction create mode 120000 Lang/Java/Primality-by-trial-division create mode 120000 Lang/Java/Prime-decomposition create mode 120000 Lang/Java/Priority-queue create mode 120000 Lang/Java/Probabilistic-choice create mode 120000 Lang/Java/Problem-of-Apollonius create mode 120000 Lang/Java/Program-name create mode 120000 Lang/Java/Program-termination create mode 120000 Lang/Java/Pythagorean-triples create mode 120000 Lang/Java/Quaternion-type create mode 120000 Lang/Java/Queue-Definition create mode 120000 Lang/Java/Queue-Usage create mode 120000 Lang/Java/RIPEMD-160 create mode 120000 Lang/Java/Random-number-generator--device- create mode 120000 Lang/Java/Random-numbers create mode 120000 Lang/Java/Range-expansion create mode 120000 Lang/Java/Range-extraction create mode 120000 Lang/Java/Read-a-file-line-by-line create mode 120000 Lang/Java/Read-a-specific-line-from-a-file create mode 120000 Lang/Java/Read-entire-file create mode 120000 Lang/Java/Real-constants-and-functions create mode 120000 Lang/Java/Reduced-row-echelon-form create mode 120000 Lang/Java/Regular-expressions create mode 120000 Lang/Java/Remove-duplicate-elements create mode 120000 Lang/Java/Rename-a-file create mode 120000 Lang/Java/Repeat-a-string create mode 120000 Lang/Java/Return-multiple-values create mode 120000 Lang/Java/Reverse-a-string create mode 120000 Lang/Java/Rock-paper-scissors create mode 120000 Lang/Java/Roman-numerals-Decode create mode 120000 Lang/Java/Roman-numerals-Encode create mode 120000 Lang/Java/Roots-of-a-function create mode 120000 Lang/Java/Roots-of-a-quadratic-function create mode 120000 Lang/Java/Roots-of-unity create mode 120000 Lang/Java/Rosetta-Code-Count-examples create mode 120000 Lang/Java/Rot-13 create mode 120000 Lang/Java/Run-length-encoding create mode 120000 Lang/Java/Runtime-evaluation-In-an-environment create mode 120000 Lang/Java/S-Expressions create mode 120000 Lang/Java/SEDOLs create mode 120000 Lang/Java/Same-Fringe create mode 120000 Lang/Java/Scope-modifiers create mode 120000 Lang/Java/Secure-temporary-file create mode 120000 Lang/Java/Self-describing-numbers create mode 120000 Lang/Java/Semordnilap create mode 120000 Lang/Java/Send-an-unknown-method-call create mode 120000 Lang/Java/Send-email create mode 120000 Lang/Java/Sequence-of-non-squares create mode 120000 Lang/Java/Set create mode 120000 Lang/Java/Set-consolidation create mode 120000 Lang/JavaScript/Binary-digits create mode 120000 Lang/JavaScript/Brownian-tree create mode 120000 Lang/JavaScript/Catalan-numbers create mode 120000 Lang/JavaScript/Copy-a-string create mode 120000 Lang/JavaScript/Dragon-curve create mode 120000 Lang/JavaScript/Environment-variables create mode 120000 Lang/JavaScript/Guess-the-number-With-feedback--player- delete mode 120000 Lang/JavaScript/Guess-the-number-With-feedback-player create mode 120000 Lang/JavaScript/Named-parameters create mode 120000 Lang/JavaScript/Non-continuous-subsequences create mode 120000 Lang/JavaScript/Non-decimal-radices-Convert create mode 120000 Lang/JavaScript/Non-decimal-radices-Input create mode 120000 Lang/JavaScript/Non-decimal-radices-Output create mode 120000 Lang/JavaScript/Nth-root create mode 120000 Lang/JavaScript/Null-object create mode 120000 Lang/JavaScript/Number-reversal-game create mode 120000 Lang/JavaScript/One-dimensional-cellular-automata create mode 120000 Lang/JavaScript/OpenGL create mode 120000 Lang/JavaScript/Optional-parameters create mode 120000 Lang/JavaScript/Palindrome-detection create mode 120000 Lang/JavaScript/Pangram-checker create mode 120000 Lang/JavaScript/Parallel-calculations create mode 120000 Lang/JavaScript/Pascals-triangle create mode 120000 Lang/JavaScript/Perfect-numbers create mode 120000 Lang/JavaScript/Permutations create mode 120000 Lang/JavaScript/Pick-random-element create mode 120000 Lang/JavaScript/Playing-cards create mode 120000 Lang/JavaScript/Polymorphic-copy create mode 120000 Lang/JavaScript/Polymorphism create mode 120000 Lang/JavaScript/Power-set create mode 120000 Lang/JavaScript/Price-fraction create mode 120000 Lang/JavaScript/Primality-by-trial-division create mode 120000 Lang/JavaScript/Prime-decomposition create mode 120000 Lang/JavaScript/Probabilistic-choice create mode 120000 Lang/JavaScript/Program-name create mode 120000 Lang/JavaScript/Program-termination create mode 120000 Lang/JavaScript/Queue-Definition create mode 120000 Lang/JavaScript/Queue-Usage create mode 120000 Lang/JavaScript/Random-numbers create mode 120000 Lang/JavaScript/Range-expansion create mode 120000 Lang/JavaScript/Range-extraction create mode 120000 Lang/JavaScript/Rate-counter create mode 120000 Lang/JavaScript/Read-entire-file create mode 120000 Lang/JavaScript/Real-constants-and-functions create mode 120000 Lang/JavaScript/Reduced-row-echelon-form create mode 120000 Lang/JavaScript/Regular-expressions create mode 120000 Lang/JavaScript/Remove-duplicate-elements create mode 120000 Lang/JavaScript/Rename-a-file create mode 120000 Lang/JavaScript/Repeat-a-string create mode 120000 Lang/JavaScript/Respond-to-an-unknown-method-call create mode 120000 Lang/JavaScript/Reverse-a-string create mode 120000 Lang/JavaScript/Roman-numerals-Decode create mode 120000 Lang/JavaScript/Roman-numerals-Encode create mode 120000 Lang/JavaScript/Rosetta-Code-Fix-code-tags create mode 120000 Lang/JavaScript/Rot-13 create mode 120000 Lang/JavaScript/Run-length-encoding create mode 120000 Lang/JavaScript/Runtime-evaluation create mode 120000 Lang/JavaScript/Runtime-evaluation-In-an-environment create mode 120000 Lang/JavaScript/SEDOLs create mode 120000 Lang/JavaScript/Self-describing-numbers create mode 120000 Lang/JavaScript/Send-an-unknown-method-call create mode 120000 Lang/Joy/Binary-digits create mode 120000 Lang/Joy/Copy-a-string create mode 120000 Lang/Joy/Environment-variables create mode 120000 Lang/Joy/Number-names create mode 120000 Lang/Joy/Order-two-numerical-lists create mode 120000 Lang/Joy/Primality-by-trial-division create mode 120000 Lang/Joy/Rename-a-file create mode 120000 Lang/Julia/Arbitrary-precision-integers--included- delete mode 120000 Lang/Julia/Arbitrary-precision-integers-included create mode 120000 Lang/Julia/Catalan-numbers create mode 120000 Lang/Julia/Perfect-numbers create mode 120000 Lang/Julia/Read-a-file-line-by-line create mode 120000 Lang/Julia/Read-entire-file create mode 120000 Lang/Julia/Regular-expressions create mode 120000 Lang/Julia/Remove-duplicate-elements create mode 120000 Lang/Julia/Repeat-a-string create mode 120000 Lang/Julia/Return-multiple-values create mode 120000 Lang/Julia/Reverse-a-string create mode 120000 Lang/Julia/Rock-paper-scissors create mode 120000 Lang/Julia/Self-describing-numbers create mode 120000 Lang/Julia/Semordnilap create mode 120000 Lang/K/Binary-digits create mode 120000 Lang/K/Catalan-numbers create mode 120000 Lang/K/Environment-variables create mode 120000 Lang/K/Null-object create mode 120000 Lang/K/One-dimensional-cellular-automata create mode 120000 Lang/K/Pangram-checker create mode 120000 Lang/K/Pascals-triangle create mode 120000 Lang/K/Perfect-numbers create mode 120000 Lang/K/Permutations create mode 120000 Lang/K/Pick-random-element create mode 120000 Lang/K/Playing-cards create mode 120000 Lang/K/Power-set create mode 120000 Lang/K/Price-fraction create mode 120000 Lang/K/Primality-by-trial-division create mode 120000 Lang/K/Range-expansion create mode 120000 Lang/K/Range-extraction create mode 120000 Lang/K/Remove-duplicate-elements create mode 120000 Lang/K/Repeat-a-string create mode 120000 Lang/K/Roman-numerals-Decode create mode 120000 Lang/K/Rot-13 create mode 120000 Lang/K/Run-length-encoding create mode 120000 Lang/K/Self-describing-numbers create mode 120000 Lang/KonsolScript/Copy-a-string create mode 120000 Lang/LLVM/Program-name create mode 120000 Lang/LOLCODE/Binary-digits create mode 120000 Lang/LSE64/Primality-by-trial-division create mode 120000 Lang/LSL/Environment-variables create mode 120000 Lang/LaTeX/Roman-numerals-Encode create mode 120000 Lang/Lang5/Binary-digits create mode 120000 Lang/Lang5/Copy-a-string create mode 120000 Lang/Lang5/Read-entire-file create mode 120000 Lang/Lang5/Remove-duplicate-elements create mode 120000 Lang/Lang5/Reverse-a-string create mode 120000 Lang/Lhogho/Order-two-numerical-lists create mode 120000 Lang/Liberty-BASIC/Arbitrary-precision-integers--included- delete mode 120000 Lang/Liberty-BASIC/Arbitrary-precision-integers-included create mode 120000 Lang/Liberty-BASIC/Binary-digits create mode 120000 Lang/Liberty-BASIC/Brownian-tree create mode 120000 Lang/Liberty-BASIC/Catalan-numbers create mode 120000 Lang/Liberty-BASIC/Copy-a-string create mode 120000 Lang/Liberty-BASIC/Dragon-curve create mode 120000 Lang/Liberty-BASIC/Environment-variables create mode 120000 Lang/Liberty-BASIC/Guess-the-number-With-feedback--player- delete mode 120000 Lang/Liberty-BASIC/Guess-the-number-With-feedback-player create mode 120000 Lang/Liberty-BASIC/Non-decimal-radices-Convert create mode 120000 Lang/Liberty-BASIC/Nth-root create mode 120000 Lang/Liberty-BASIC/Numerical-integration create mode 120000 Lang/Liberty-BASIC/One-dimensional-cellular-automata create mode 120000 Lang/Liberty-BASIC/OpenGL create mode 120000 Lang/Liberty-BASIC/Palindrome-detection create mode 120000 Lang/Liberty-BASIC/Pangram-checker create mode 120000 Lang/Liberty-BASIC/Pascals-triangle create mode 120000 Lang/Liberty-BASIC/Percentage-difference-between-images create mode 120000 Lang/Liberty-BASIC/Perfect-numbers create mode 120000 Lang/Liberty-BASIC/Pick-random-element create mode 120000 Lang/Liberty-BASIC/Pinstripe-Printer create mode 120000 Lang/Liberty-BASIC/Play-recorded-sounds create mode 120000 Lang/Liberty-BASIC/Playing-cards create mode 120000 Lang/Liberty-BASIC/Plot-coordinate-pairs create mode 120000 Lang/Liberty-BASIC/Price-fraction create mode 120000 Lang/Liberty-BASIC/Primality-by-trial-division create mode 120000 Lang/Liberty-BASIC/Probabilistic-choice create mode 120000 Lang/Liberty-BASIC/Problem-of-Apollonius create mode 120000 Lang/Liberty-BASIC/Program-termination create mode 120000 Lang/Liberty-BASIC/Pythagorean-triples create mode 120000 Lang/Liberty-BASIC/Quaternion-type create mode 120000 Lang/Liberty-BASIC/Random-numbers create mode 120000 Lang/Liberty-BASIC/Range-expansion create mode 120000 Lang/Liberty-BASIC/Range-extraction create mode 120000 Lang/Liberty-BASIC/Rate-counter create mode 120000 Lang/Liberty-BASIC/Ray-casting-algorithm create mode 120000 Lang/Liberty-BASIC/Read-a-configuration-file create mode 120000 Lang/Liberty-BASIC/Read-a-file-line-by-line create mode 120000 Lang/Liberty-BASIC/Read-a-specific-line-from-a-file create mode 120000 Lang/Liberty-BASIC/Read-entire-file create mode 120000 Lang/Liberty-BASIC/Real-constants-and-functions create mode 120000 Lang/Liberty-BASIC/Record-sound create mode 120000 Lang/Liberty-BASIC/Remove-duplicate-elements create mode 120000 Lang/Liberty-BASIC/Remove-lines-from-a-file create mode 120000 Lang/Liberty-BASIC/Rename-a-file create mode 120000 Lang/Liberty-BASIC/Repeat-a-string create mode 120000 Lang/Liberty-BASIC/Return-multiple-values create mode 120000 Lang/Liberty-BASIC/Reverse-a-string create mode 120000 Lang/Liberty-BASIC/Rock-paper-scissors create mode 120000 Lang/Liberty-BASIC/Roman-numerals-Decode create mode 120000 Lang/Liberty-BASIC/Roman-numerals-Encode create mode 120000 Lang/Liberty-BASIC/Roots-of-a-function create mode 120000 Lang/Liberty-BASIC/Roots-of-a-quadratic-function create mode 120000 Lang/Liberty-BASIC/Roots-of-unity create mode 120000 Lang/Liberty-BASIC/Rot-13 create mode 120000 Lang/Liberty-BASIC/Run-length-encoding create mode 120000 Lang/Liberty-BASIC/Runtime-evaluation create mode 120000 Lang/Liberty-BASIC/Runtime-evaluation-In-an-environment create mode 120000 Lang/Liberty-BASIC/SEDOLs create mode 120000 Lang/Liberty-BASIC/Self-describing-numbers create mode 120000 Lang/Liberty-BASIC/Semordnilap create mode 120000 Lang/Liberty-BASIC/Send-email create mode 120000 Lang/Liberty-BASIC/Sequence-of-non-squares create mode 120000 Lang/Liberty-BASIC/Set create mode 120000 Lang/Lisaac/Copy-a-string create mode 120000 Lang/Locomotive-Basic/Binary-digits create mode 120000 Lang/Locomotive-Basic/N-queens-problem create mode 120000 Lang/Locomotive-Basic/Non-decimal-radices-Output create mode 120000 Lang/Locomotive-Basic/One-dimensional-cellular-automata create mode 120000 Lang/Locomotive-Basic/Pascals-triangle create mode 120000 Lang/Locomotive-Basic/Pinstripe-Display create mode 120000 Lang/Locomotive-Basic/Rename-a-file create mode 120000 Lang/Locomotive-Basic/Rock-paper-scissors create mode 120000 Lang/Locomotive-Basic/Rot-13 create mode 120000 Lang/Logo/Copy-a-string create mode 120000 Lang/Logo/Dragon-curve create mode 120000 Lang/Logo/N-queens-problem create mode 120000 Lang/Logo/Nth-root create mode 120000 Lang/Logo/Null-object create mode 120000 Lang/Logo/Number-names create mode 120000 Lang/Logo/Numerical-integration create mode 120000 Lang/Logo/One-dimensional-cellular-automata create mode 120000 Lang/Logo/Optional-parameters create mode 120000 Lang/Logo/Palindrome-detection create mode 120000 Lang/Logo/Pangram-checker create mode 120000 Lang/Logo/Pascals-triangle create mode 120000 Lang/Logo/Perfect-numbers create mode 120000 Lang/Logo/Pick-random-element create mode 120000 Lang/Logo/Playing-cards create mode 120000 Lang/Logo/Power-set create mode 120000 Lang/Logo/Primality-by-trial-division create mode 120000 Lang/Logo/Prime-decomposition create mode 120000 Lang/Logo/Program-termination create mode 120000 Lang/Logo/Queue-Usage create mode 120000 Lang/Logo/Random-numbers create mode 120000 Lang/Logo/Read-a-file-line-by-line create mode 120000 Lang/Logo/Real-constants-and-functions create mode 120000 Lang/Logo/Remove-duplicate-elements create mode 120000 Lang/Logo/Repeat-a-string create mode 120000 Lang/Logo/Reverse-a-string create mode 120000 Lang/Logo/Roman-numerals-Decode create mode 120000 Lang/Logo/Roman-numerals-Encode create mode 120000 Lang/Logo/Roots-of-a-quadratic-function create mode 120000 Lang/Logo/Rot-13 create mode 120000 Lang/Logo/Run-length-encoding create mode 120000 Lang/Logo/Scope-modifiers create mode 120000 Lang/Logo/Self-describing-numbers create mode 120000 Lang/Logo/Sequence-of-non-squares create mode 120000 Lang/Logtalk/Permutations create mode 120000 Lang/Logtalk/Power-set create mode 120000 Lang/LotusScript/Roman-numerals-Encode create mode 120000 Lang/LotusScript/Send-email create mode 120000 Lang/Lua/Brownian-tree create mode 120000 Lang/Lua/Catalan-numbers create mode 120000 Lang/Lua/Copy-a-string create mode 120000 Lang/Lua/Dragon-curve create mode 120000 Lang/Lua/Environment-variables create mode 120000 Lang/Lua/N-queens-problem create mode 120000 Lang/Lua/Named-parameters create mode 120000 Lang/Lua/Non-decimal-radices-Input create mode 120000 Lang/Lua/Non-decimal-radices-Output create mode 120000 Lang/Lua/Nth-root create mode 120000 Lang/Lua/Null-object create mode 120000 Lang/Lua/Number-names create mode 120000 Lang/Lua/Numerical-integration create mode 120000 Lang/Lua/One-dimensional-cellular-automata create mode 120000 Lang/Lua/OpenGL create mode 120000 Lang/Lua/Ordered-Partitions create mode 120000 Lang/Lua/Palindrome-detection create mode 120000 Lang/Lua/Pangram-checker create mode 120000 Lang/Lua/Pascals-triangle create mode 120000 Lang/Lua/Perfect-numbers create mode 120000 Lang/Lua/Permutations create mode 120000 Lang/Lua/Pick-random-element create mode 120000 Lang/Lua/Playing-cards create mode 120000 Lang/Lua/Polymorphism create mode 120000 Lang/Lua/Power-set create mode 120000 Lang/Lua/Primality-by-trial-division create mode 120000 Lang/Lua/Prime-decomposition create mode 120000 Lang/Lua/Probabilistic-choice create mode 120000 Lang/Lua/Program-name create mode 120000 Lang/Lua/Program-termination create mode 120000 Lang/Lua/Quaternion-type create mode 120000 Lang/Lua/Queue-Definition create mode 120000 Lang/Lua/Queue-Usage create mode 120000 Lang/Lua/Read-a-configuration-file create mode 120000 Lang/Lua/Read-a-file-line-by-line create mode 120000 Lang/Lua/Read-entire-file create mode 120000 Lang/Lua/Real-constants-and-functions create mode 120000 Lang/Lua/Reduced-row-echelon-form create mode 120000 Lang/Lua/Regular-expressions create mode 120000 Lang/Lua/Remove-duplicate-elements create mode 120000 Lang/Lua/Remove-lines-from-a-file create mode 120000 Lang/Lua/Rename-a-file create mode 120000 Lang/Lua/Repeat-a-string create mode 120000 Lang/Lua/Respond-to-an-unknown-method-call create mode 120000 Lang/Lua/Return-multiple-values create mode 120000 Lang/Lua/Reverse-a-string create mode 120000 Lang/Lua/Roman-numerals-Decode create mode 120000 Lang/Lua/Roman-numerals-Encode create mode 120000 Lang/Lua/Roots-of-a-quadratic-function create mode 120000 Lang/Lua/Roots-of-unity create mode 120000 Lang/Lua/Rosetta-Code-Fix-code-tags create mode 120000 Lang/Lua/Rot-13 create mode 120000 Lang/Lua/Run-length-encoding create mode 120000 Lang/Lua/Runtime-evaluation create mode 120000 Lang/Lua/Runtime-evaluation-In-an-environment create mode 120000 Lang/Lua/Secure-temporary-file create mode 120000 Lang/Lua/Self-describing-numbers create mode 120000 Lang/Lua/Send-email create mode 120000 Lang/Lua/Sequence-of-non-squares create mode 120000 Lang/M4/Non-decimal-radices-Convert create mode 120000 Lang/M4/One-dimensional-cellular-automata create mode 120000 Lang/M4/Palindrome-detection create mode 120000 Lang/M4/Perfect-numbers create mode 120000 Lang/M4/Playing-cards create mode 120000 Lang/M4/Power-set create mode 120000 Lang/M4/Primality-by-trial-division create mode 120000 Lang/M4/Program-termination create mode 120000 Lang/M4/Regular-expressions create mode 120000 Lang/M4/Reverse-a-string create mode 120000 Lang/M4/Roman-numerals-Encode create mode 120000 Lang/M4/SEDOLs create mode 120000 Lang/MATLAB/Arbitrary-precision-integers--included- delete mode 120000 Lang/MATLAB/Arbitrary-precision-integers-included create mode 120000 Lang/MATLAB/Binary-digits create mode 120000 Lang/MATLAB/Catalan-numbers create mode 120000 Lang/MATLAB/Copy-a-string create mode 120000 Lang/MATLAB/Environment-variables create mode 120000 Lang/MATLAB/Named-parameters create mode 120000 Lang/MATLAB/Nth-root create mode 120000 Lang/MATLAB/Numerical-integration create mode 120000 Lang/MATLAB/Palindrome-detection create mode 120000 Lang/MATLAB/Pangram-checker create mode 120000 Lang/MATLAB/Pascals-triangle create mode 120000 Lang/MATLAB/Pick-random-element create mode 120000 Lang/MATLAB/Plot-coordinate-pairs create mode 120000 Lang/MATLAB/Polynomial-regression create mode 120000 Lang/MATLAB/Power-set create mode 120000 Lang/MATLAB/Price-fraction create mode 120000 Lang/MATLAB/Primality-by-trial-division create mode 120000 Lang/MATLAB/Prime-decomposition create mode 120000 Lang/MATLAB/Program-termination create mode 120000 Lang/MATLAB/Pythagorean-triples create mode 120000 Lang/MATLAB/QR-decomposition create mode 120000 Lang/MATLAB/Queue-Definition create mode 120000 Lang/MATLAB/Random-numbers create mode 120000 Lang/MATLAB/Read-a-configuration-file create mode 120000 Lang/MATLAB/Read-a-file-line-by-line create mode 120000 Lang/MATLAB/Read-a-specific-line-from-a-file create mode 120000 Lang/MATLAB/Read-entire-file create mode 120000 Lang/MATLAB/Reduced-row-echelon-form create mode 120000 Lang/MATLAB/Remove-duplicate-elements create mode 120000 Lang/MATLAB/Rename-a-file create mode 120000 Lang/MATLAB/Repeat-a-string create mode 120000 Lang/MATLAB/Return-multiple-values create mode 120000 Lang/MATLAB/Reverse-a-string create mode 120000 Lang/MATLAB/Roots-of-a-quadratic-function create mode 120000 Lang/MATLAB/Roots-of-unity create mode 120000 Lang/MATLAB/Rosetta-Code-Count-examples create mode 120000 Lang/MATLAB/Rot-13 create mode 120000 Lang/MATLAB/Self-describing-numbers create mode 120000 Lang/MATLAB/Send-an-unknown-method-call create mode 120000 Lang/MATLAB/Sequence-of-non-squares create mode 120000 Lang/MATLAB/Set create mode 120000 Lang/MAXScript/Copy-a-string create mode 120000 Lang/MAXScript/Null-object create mode 120000 Lang/MAXScript/Number-names create mode 120000 Lang/MAXScript/OpenGL create mode 120000 Lang/MAXScript/Palindrome-detection create mode 120000 Lang/MAXScript/Percentage-difference-between-images create mode 120000 Lang/MAXScript/Perfect-numbers create mode 120000 Lang/MAXScript/Primality-by-trial-division create mode 120000 Lang/MAXScript/Random-numbers create mode 120000 Lang/MAXScript/Real-constants-and-functions create mode 120000 Lang/MAXScript/Remove-duplicate-elements create mode 120000 Lang/MAXScript/Rename-a-file create mode 120000 Lang/MAXScript/Reverse-a-string create mode 120000 Lang/MIRC-Scripting-Language/Regular-expressions create mode 120000 Lang/MMIX/Palindrome-detection create mode 120000 Lang/MMIX/Rot-13 create mode 120000 Lang/MMIX/Run-length-encoding create mode 120000 Lang/MMIX/Sequence-of-non-squares create mode 120000 Lang/MUMPS/Copy-a-string create mode 120000 Lang/MUMPS/Environment-variables create mode 120000 Lang/MUMPS/N-queens-problem create mode 120000 Lang/MUMPS/Null-object create mode 120000 Lang/MUMPS/Price-fraction create mode 120000 Lang/MUMPS/Primality-by-trial-division create mode 120000 Lang/MUMPS/Prime-decomposition create mode 120000 Lang/MUMPS/Problem-of-Apollonius create mode 120000 Lang/MUMPS/Range-expansion create mode 120000 Lang/MUMPS/Range-extraction create mode 120000 Lang/MUMPS/Regular-expressions create mode 120000 Lang/MUMPS/Remove-duplicate-elements create mode 120000 Lang/MUMPS/Rename-a-file create mode 120000 Lang/MUMPS/Repeat-a-string create mode 120000 Lang/MUMPS/Reverse-a-string create mode 120000 Lang/MUMPS/Roman-numerals-Encode create mode 120000 Lang/MUMPS/Rot-13 create mode 120000 Lang/MUMPS/SEDOLs create mode 120000 Lang/MUMPS/Scope-modifiers create mode 120000 Lang/Maple/Arbitrary-precision-integers--included- delete mode 120000 Lang/Maple/Arbitrary-precision-integers-included create mode 120000 Lang/Maple/Binary-digits create mode 120000 Lang/Maple/Copy-a-string create mode 120000 Lang/Maple/Permutations create mode 120000 Lang/Maple/Polynomial-long-division create mode 120000 Lang/Maple/Primality-by-trial-division create mode 120000 Lang/Maple/Range-expansion create mode 120000 Lang/Maple/Read-entire-file create mode 120000 Lang/Maple/Real-constants-and-functions create mode 120000 Lang/Maple/Remove-duplicate-elements create mode 120000 Lang/Maple/Rename-a-file create mode 120000 Lang/Maple/Repeat-a-string create mode 120000 Lang/Maple/Return-multiple-values create mode 120000 Lang/Maple/Reverse-a-string create mode 120000 Lang/Maple/Roots-of-a-function create mode 120000 Lang/Maple/Rot-13 create mode 120000 Lang/Maple/Set create mode 120000 Lang/Mathematica/Arbitrary-precision-integers--included- delete mode 120000 Lang/Mathematica/Arbitrary-precision-integers-included create mode 120000 Lang/Mathematica/Binary-digits create mode 120000 Lang/Mathematica/Brownian-tree create mode 120000 Lang/Mathematica/Catalan-numbers create mode 120000 Lang/Mathematica/Copy-a-string create mode 120000 Lang/Mathematica/Dragon-curve create mode 120000 Lang/Mathematica/Environment-variables create mode 120000 Lang/Mathematica/Execute-a-Markov-algorithm create mode 120000 Lang/Mathematica/Guess-the-number-With-feedback--player- delete mode 120000 Lang/Mathematica/Guess-the-number-With-feedback-player create mode 120000 Lang/Mathematica/N-queens-problem create mode 120000 Lang/Mathematica/Named-parameters create mode 120000 Lang/Mathematica/Non-continuous-subsequences create mode 120000 Lang/Mathematica/Non-decimal-radices-Convert create mode 120000 Lang/Mathematica/Non-decimal-radices-Input create mode 120000 Lang/Mathematica/Non-decimal-radices-Output create mode 120000 Lang/Mathematica/Nth-root create mode 120000 Lang/Mathematica/Null-object create mode 120000 Lang/Mathematica/Number-names create mode 120000 Lang/Mathematica/Number-reversal-game create mode 120000 Lang/Mathematica/Numeric-error-propagation create mode 120000 Lang/Mathematica/Numerical-integration create mode 120000 Lang/Mathematica/Numerical-integration-Gauss-Legendre-Quadrature create mode 120000 Lang/Mathematica/One-dimensional-cellular-automata create mode 120000 Lang/Mathematica/Optional-parameters create mode 120000 Lang/Mathematica/Order-two-numerical-lists create mode 120000 Lang/Mathematica/Ordered-Partitions create mode 120000 Lang/Mathematica/Palindrome-detection create mode 120000 Lang/Mathematica/Pangram-checker create mode 120000 Lang/Mathematica/Parallel-calculations create mode 120000 Lang/Mathematica/Parametrized-SQL-statement create mode 120000 Lang/Mathematica/Partial-function-application create mode 120000 Lang/Mathematica/Pascals-triangle create mode 120000 Lang/Mathematica/Pascals-triangle-Puzzle create mode 120000 Lang/Mathematica/Percentage-difference-between-images create mode 120000 Lang/Mathematica/Perfect-numbers create mode 120000 Lang/Mathematica/Permutation-test create mode 120000 Lang/Mathematica/Permutations create mode 120000 Lang/Mathematica/Permutations-Derangements create mode 120000 Lang/Mathematica/Permutations-by-swapping create mode 120000 Lang/Mathematica/Pick-random-element create mode 120000 Lang/Mathematica/Pig-the-dice-game create mode 120000 Lang/Mathematica/Play-recorded-sounds create mode 120000 Lang/Mathematica/Playing-cards create mode 120000 Lang/Mathematica/Plot-coordinate-pairs create mode 120000 Lang/Mathematica/Polynomial-long-division create mode 120000 Lang/Mathematica/Polynomial-regression create mode 120000 Lang/Mathematica/Power-set create mode 120000 Lang/Mathematica/Price-fraction create mode 120000 Lang/Mathematica/Primality-by-trial-division create mode 120000 Lang/Mathematica/Prime-decomposition create mode 120000 Lang/Mathematica/Priority-queue create mode 120000 Lang/Mathematica/Probabilistic-choice create mode 120000 Lang/Mathematica/Problem-of-Apollonius create mode 120000 Lang/Mathematica/Program-name create mode 120000 Lang/Mathematica/Program-termination create mode 120000 Lang/Mathematica/Pythagorean-triples create mode 120000 Lang/Mathematica/QR-decomposition create mode 120000 Lang/Mathematica/Quaternion-type create mode 120000 Lang/Mathematica/Queue-Definition create mode 120000 Lang/Mathematica/Queue-Usage create mode 120000 Lang/Mathematica/Random-numbers create mode 120000 Lang/Mathematica/Range-expansion create mode 120000 Lang/Mathematica/Range-extraction create mode 120000 Lang/Mathematica/Read-a-file-line-by-line create mode 120000 Lang/Mathematica/Read-a-specific-line-from-a-file create mode 120000 Lang/Mathematica/Read-entire-file create mode 120000 Lang/Mathematica/Real-constants-and-functions create mode 120000 Lang/Mathematica/Record-sound create mode 120000 Lang/Mathematica/Reduced-row-echelon-form create mode 120000 Lang/Mathematica/Regular-expressions create mode 120000 Lang/Mathematica/Remove-duplicate-elements create mode 120000 Lang/Mathematica/Rename-a-file create mode 120000 Lang/Mathematica/Repeat-a-string create mode 120000 Lang/Mathematica/Resistor-mesh create mode 120000 Lang/Mathematica/Return-multiple-values create mode 120000 Lang/Mathematica/Reverse-a-string create mode 120000 Lang/Mathematica/Rock-paper-scissors create mode 120000 Lang/Mathematica/Roman-numerals-Decode create mode 120000 Lang/Mathematica/Roman-numerals-Encode create mode 120000 Lang/Mathematica/Roots-of-a-function create mode 120000 Lang/Mathematica/Roots-of-a-quadratic-function create mode 120000 Lang/Mathematica/Roots-of-unity create mode 120000 Lang/Mathematica/Rosetta-Code-Count-examples create mode 120000 Lang/Mathematica/Rosetta-Code-Fix-code-tags create mode 120000 Lang/Mathematica/Rosetta-Code-Rank-languages-by-popularity create mode 120000 Lang/Mathematica/Rot-13 create mode 120000 Lang/Mathematica/Run-length-encoding create mode 120000 Lang/Mathematica/Runtime-evaluation-In-an-environment create mode 120000 Lang/Mathematica/SEDOLs create mode 120000 Lang/Mathematica/Scope-modifiers create mode 120000 Lang/Mathematica/Secure-temporary-file create mode 120000 Lang/Mathematica/Self-describing-numbers create mode 120000 Lang/Mathematica/Self-referential-sequence create mode 120000 Lang/Mathematica/Semordnilap create mode 120000 Lang/Mathematica/Send-email create mode 120000 Lang/Mathematica/Sequence-of-non-squares create mode 120000 Lang/Mathematica/Set create mode 120000 Lang/Mathematica/Set-consolidation create mode 120000 Lang/Maxima/Arbitrary-precision-integers--included- delete mode 120000 Lang/Maxima/Arbitrary-precision-integers-included create mode 120000 Lang/Maxima/Binary-digits create mode 120000 Lang/Maxima/Catalan-numbers create mode 120000 Lang/Maxima/Copy-a-string create mode 120000 Lang/Maxima/N-queens-problem create mode 120000 Lang/Maxima/Nth-root create mode 120000 Lang/Maxima/Numerical-integration create mode 120000 Lang/Maxima/Numerical-integration-Gauss-Legendre-Quadrature create mode 120000 Lang/Maxima/Order-two-numerical-lists create mode 120000 Lang/Maxima/Palindrome-detection create mode 120000 Lang/Maxima/Pascals-triangle create mode 120000 Lang/Maxima/Perfect-numbers create mode 120000 Lang/Maxima/Permutations create mode 120000 Lang/Maxima/Plot-coordinate-pairs create mode 120000 Lang/Maxima/Power-set create mode 120000 Lang/Maxima/Prime-decomposition create mode 120000 Lang/Maxima/Priority-queue create mode 120000 Lang/Maxima/Program-termination create mode 120000 Lang/Maxima/QR-decomposition create mode 120000 Lang/Maxima/Queue-Definition create mode 120000 Lang/Maxima/Random-numbers create mode 120000 Lang/Maxima/Read-a-file-line-by-line create mode 120000 Lang/Maxima/Reduced-row-echelon-form create mode 120000 Lang/Maxima/Remove-duplicate-elements create mode 120000 Lang/Maxima/Repeat-a-string create mode 120000 Lang/Maxima/Resistor-mesh create mode 120000 Lang/Maxima/Return-multiple-values create mode 120000 Lang/Maxima/Reverse-a-string create mode 120000 Lang/Maxima/Roots-of-a-function create mode 120000 Lang/Maxima/Roots-of-a-quadratic-function create mode 120000 Lang/Maxima/Roots-of-unity create mode 120000 Lang/Maxima/Rot-13 create mode 120000 Lang/Maxima/Run-length-encoding create mode 120000 Lang/Maxima/Runtime-evaluation create mode 120000 Lang/Maxima/Sequence-of-non-squares create mode 120000 Lang/Maxima/Set create mode 120000 Lang/Mercury/Binary-digits create mode 120000 Lang/Mercury/Environment-variables create mode 120000 Lang/Mercury/OpenGL create mode 120000 Lang/Mercury/Order-two-numerical-lists create mode 120000 Lang/Mercury/Partial-function-application create mode 120000 Lang/Mercury/Price-fraction create mode 120000 Lang/Mercury/Real-constants-and-functions create mode 120000 Lang/Mercury/Repeat-a-string create mode 120000 Lang/Mercury/Return-multiple-values create mode 120000 Lang/Mercury/SEDOLs create mode 120000 Lang/Metafont/Copy-a-string create mode 120000 Lang/Metafont/Dragon-curve create mode 120000 Lang/Metafont/Nth-root create mode 120000 Lang/Metafont/Pascals-triangle create mode 120000 Lang/Metafont/Random-numbers create mode 120000 Lang/Metafont/Real-constants-and-functions create mode 120000 Lang/Metafont/Runtime-evaluation-In-an-environment create mode 120000 Lang/Mirah/Copy-a-string create mode 120000 Lang/Mirah/Palindrome-detection create mode 120000 Lang/Mirah/Random-numbers create mode 120000 Lang/Mirah/Repeat-a-string create mode 120000 Lang/Mirah/Reverse-a-string create mode 120000 Lang/Mirah/Rot-13 create mode 120000 Lang/Modula-2/Guess-the-number-With-feedback--player- delete mode 120000 Lang/Modula-2/Guess-the-number-With-feedback-player create mode 120000 Lang/Modula-3/Binary-digits create mode 120000 Lang/Modula-3/Copy-a-string create mode 120000 Lang/Modula-3/Named-parameters create mode 120000 Lang/Modula-3/Non-decimal-radices-Output create mode 120000 Lang/Modula-3/Null-object create mode 120000 Lang/Modula-3/One-dimensional-cellular-automata create mode 120000 Lang/Modula-3/Palindrome-detection create mode 120000 Lang/Modula-3/Pointers-and-references create mode 120000 Lang/Modula-3/Pythagorean-triples create mode 120000 Lang/Modula-3/Random-numbers create mode 120000 Lang/Modula-3/Real-constants-and-functions create mode 120000 Lang/Modula-3/Reverse-a-string create mode 120000 Lang/Modula-3/Roots-of-a-quadratic-function create mode 120000 Lang/Modula-3/Rot-13 create mode 120000 Lang/Modula-3/SEDOLs create mode 120000 Lang/Modula-3/Sequence-of-non-squares create mode 120000 Lang/NSIS/Environment-variables create mode 120000 Lang/Nemerle/Copy-a-string create mode 120000 Lang/Nemerle/Named-parameters create mode 120000 Lang/Nemerle/Optional-parameters create mode 120000 Lang/Nemerle/Palindrome-detection create mode 120000 Lang/Nemerle/Partial-function-application create mode 120000 Lang/Nemerle/Remove-duplicate-elements create mode 120000 Lang/Nemerle/Reverse-a-string create mode 120000 Lang/NetLogo/Pick-random-element create mode 120000 Lang/NetRexx/Arbitrary-precision-integers--included- delete mode 120000 Lang/NetRexx/Arbitrary-precision-integers-included create mode 120000 Lang/NetRexx/Binary-digits create mode 120000 Lang/NetRexx/Copy-a-string create mode 120000 Lang/NetRexx/Environment-variables create mode 120000 Lang/NetRexx/Non-decimal-radices-Convert create mode 120000 Lang/NetRexx/Non-decimal-radices-Output create mode 120000 Lang/NetRexx/Nth-root create mode 120000 Lang/NetRexx/Null-object create mode 120000 Lang/NetRexx/Palindrome-detection create mode 120000 Lang/NetRexx/Pangram-checker create mode 120000 Lang/NetRexx/Parametrized-SQL-statement create mode 120000 Lang/NetRexx/Parsing-RPN-calculator-algorithm create mode 120000 Lang/NetRexx/Pick-random-element create mode 120000 Lang/NetRexx/Polymorphic-copy create mode 120000 Lang/NetRexx/Polymorphism create mode 120000 Lang/NetRexx/Pragmatic-directives create mode 120000 Lang/NetRexx/Primality-by-trial-division create mode 120000 Lang/NetRexx/Program-name create mode 120000 Lang/NetRexx/Program-termination create mode 120000 Lang/NetRexx/Queue-Definition create mode 120000 Lang/NetRexx/Queue-Usage create mode 120000 Lang/NetRexx/Random-number-generator--device- create mode 120000 Lang/NetRexx/Random-numbers create mode 120000 Lang/NetRexx/Range-expansion create mode 120000 Lang/NetRexx/Range-extraction create mode 120000 Lang/NetRexx/Read-a-file-line-by-line create mode 120000 Lang/NetRexx/Read-a-specific-line-from-a-file create mode 120000 Lang/NetRexx/Read-entire-file create mode 120000 Lang/NetRexx/Real-constants-and-functions create mode 120000 Lang/NetRexx/Regular-expressions create mode 120000 Lang/NetRexx/Remove-duplicate-elements create mode 120000 Lang/NetRexx/Repeat-a-string create mode 120000 Lang/NetRexx/Return-multiple-values create mode 120000 Lang/NetRexx/Reverse-a-string create mode 120000 Lang/NetRexx/Roman-numerals-Decode create mode 120000 Lang/NetRexx/Rot-13 create mode 120000 Lang/NetRexx/Semordnilap create mode 120000 Lang/NewLISP/Copy-a-string create mode 120000 Lang/NewLISP/Environment-variables create mode 120000 Lang/NewLISP/Random-numbers create mode 120000 Lang/NewLISP/Read-a-file-line-by-line create mode 120000 Lang/NewLISP/Read-entire-file create mode 120000 Lang/NewLISP/Remove-duplicate-elements create mode 120000 Lang/NewLISP/Rename-a-file create mode 120000 Lang/NewLISP/Repeat-a-string create mode 120000 Lang/NewLISP/Reverse-a-string create mode 120000 Lang/NewLISP/Send-email create mode 120000 Lang/Nial/One-dimensional-cellular-automata create mode 120000 Lang/Nial/Pascals-triangle create mode 120000 Lang/Nial/Remove-duplicate-elements create mode 120000 Lang/Nial/Reverse-a-string create mode 120000 Lang/Nimrod/One-dimensional-cellular-automata create mode 120000 Lang/Nimrod/Program-termination create mode 120000 Lang/Nimrod/Read-entire-file create mode 120000 Lang/Nimrod/Reverse-a-string create mode 120000 Lang/OCaml/Arbitrary-precision-integers--included- delete mode 120000 Lang/OCaml/Arbitrary-precision-integers-included create mode 120000 Lang/OCaml/Binary-digits create mode 120000 Lang/OCaml/Brownian-tree create mode 120000 Lang/OCaml/Copy-a-string create mode 120000 Lang/OCaml/Dragon-curve create mode 120000 Lang/OCaml/Environment-variables create mode 120000 Lang/OCaml/N-queens-problem create mode 120000 Lang/OCaml/Named-parameters create mode 120000 Lang/OCaml/Non-continuous-subsequences create mode 120000 Lang/OCaml/Non-decimal-radices-Convert create mode 120000 Lang/OCaml/Non-decimal-radices-Input create mode 120000 Lang/OCaml/Non-decimal-radices-Output create mode 120000 Lang/OCaml/Nth-root create mode 120000 Lang/OCaml/Null-object create mode 120000 Lang/OCaml/Number-names create mode 120000 Lang/OCaml/Number-reversal-game create mode 120000 Lang/OCaml/Numerical-integration create mode 120000 Lang/OCaml/Numerical-integration-Gauss-Legendre-Quadrature create mode 120000 Lang/OCaml/Object-serialization create mode 120000 Lang/OCaml/One-dimensional-cellular-automata create mode 120000 Lang/OCaml/One-of-n-lines-in-a-file create mode 120000 Lang/OCaml/OpenGL create mode 120000 Lang/OCaml/Optional-parameters create mode 120000 Lang/OCaml/Order-two-numerical-lists create mode 120000 Lang/OCaml/Palindrome-detection create mode 120000 Lang/OCaml/Pangram-checker create mode 120000 Lang/OCaml/Parametric-polymorphism create mode 120000 Lang/OCaml/Partial-function-application create mode 120000 Lang/OCaml/Pascals-triangle create mode 120000 Lang/OCaml/Pattern-matching create mode 120000 Lang/OCaml/Percentage-difference-between-images create mode 120000 Lang/OCaml/Perfect-numbers create mode 120000 Lang/OCaml/Permutations create mode 120000 Lang/OCaml/Pick-random-element create mode 120000 Lang/OCaml/Playing-cards create mode 120000 Lang/OCaml/Plot-coordinate-pairs create mode 120000 Lang/OCaml/Pointers-and-references create mode 120000 Lang/OCaml/Polymorphic-copy create mode 120000 Lang/OCaml/Polymorphism create mode 120000 Lang/OCaml/Polynomial-long-division create mode 120000 Lang/OCaml/Power-set create mode 120000 Lang/OCaml/Price-fraction create mode 120000 Lang/OCaml/Primality-by-trial-division create mode 120000 Lang/OCaml/Prime-decomposition create mode 120000 Lang/OCaml/Priority-queue create mode 120000 Lang/OCaml/Probabilistic-choice create mode 120000 Lang/OCaml/Problem-of-Apollonius create mode 120000 Lang/OCaml/Program-name create mode 120000 Lang/OCaml/Program-termination create mode 120000 Lang/OCaml/Pythagorean-triples create mode 120000 Lang/OCaml/Quaternion-type create mode 120000 Lang/OCaml/Queue-Definition create mode 120000 Lang/OCaml/Queue-Usage create mode 120000 Lang/OCaml/Random-number-generator--device- create mode 120000 Lang/OCaml/Random-numbers create mode 120000 Lang/OCaml/Range-expansion create mode 120000 Lang/OCaml/Range-extraction create mode 120000 Lang/OCaml/Ray-casting-algorithm create mode 120000 Lang/OCaml/Read-a-configuration-file create mode 120000 Lang/OCaml/Read-a-file-line-by-line create mode 120000 Lang/OCaml/Read-a-specific-line-from-a-file create mode 120000 Lang/OCaml/Read-entire-file create mode 120000 Lang/OCaml/Real-constants-and-functions create mode 120000 Lang/OCaml/Record-sound create mode 120000 Lang/OCaml/Reduced-row-echelon-form create mode 120000 Lang/OCaml/Regular-expressions create mode 120000 Lang/OCaml/Remove-duplicate-elements create mode 120000 Lang/OCaml/Remove-lines-from-a-file create mode 120000 Lang/OCaml/Rename-a-file create mode 120000 Lang/OCaml/Repeat-a-string create mode 120000 Lang/OCaml/Return-multiple-values create mode 120000 Lang/OCaml/Reverse-a-string create mode 120000 Lang/OCaml/Rock-paper-scissors create mode 120000 Lang/OCaml/Roman-numerals-Decode create mode 120000 Lang/OCaml/Roman-numerals-Encode create mode 120000 Lang/OCaml/Roots-of-a-function create mode 120000 Lang/OCaml/Roots-of-a-quadratic-function create mode 120000 Lang/OCaml/Roots-of-unity create mode 120000 Lang/OCaml/Rosetta-Code-Count-examples create mode 120000 Lang/OCaml/Rosetta-Code-Fix-code-tags create mode 120000 Lang/OCaml/Rot-13 create mode 120000 Lang/OCaml/Run-length-encoding create mode 120000 Lang/OCaml/S-Expressions create mode 120000 Lang/OCaml/SEDOLs create mode 120000 Lang/OCaml/Same-Fringe create mode 120000 Lang/OCaml/Secure-temporary-file create mode 120000 Lang/OCaml/Semordnilap create mode 120000 Lang/OCaml/Send-email create mode 120000 Lang/OCaml/Sequence-of-non-squares create mode 120000 Lang/OCaml/Set create mode 120000 Lang/OCaml/Set-consolidation create mode 120000 Lang/Oberon-2/Copy-a-string create mode 120000 Lang/Oberon-2/Range-expansion create mode 120000 Lang/Oberon-2/Range-extraction create mode 120000 Lang/Objeck/Binary-digits create mode 120000 Lang/Objeck/Copy-a-string create mode 120000 Lang/Objeck/N-queens-problem create mode 120000 Lang/Objeck/Null-object create mode 120000 Lang/Objeck/Number-names create mode 120000 Lang/Objeck/Object-serialization create mode 120000 Lang/Objeck/Palindrome-detection create mode 120000 Lang/Objeck/Pangram-checker create mode 120000 Lang/Objeck/Parametrized-SQL-statement create mode 120000 Lang/Objeck/Parsing-RPN-calculator-algorithm create mode 120000 Lang/Objeck/Perfect-numbers create mode 120000 Lang/Objeck/Pick-random-element create mode 120000 Lang/Objeck/Polymorphism create mode 120000 Lang/Objeck/Primality-by-trial-division create mode 120000 Lang/Objeck/Program-termination create mode 120000 Lang/Objeck/Queue-Usage create mode 120000 Lang/Objeck/RIPEMD-160 create mode 120000 Lang/Objeck/Random-numbers create mode 120000 Lang/Objeck/Read-a-file-line-by-line create mode 120000 Lang/Objeck/Read-entire-file create mode 120000 Lang/Objeck/Real-constants-and-functions create mode 120000 Lang/Objeck/Reduced-row-echelon-form create mode 120000 Lang/Objeck/Regular-expressions create mode 120000 Lang/Objeck/Remove-duplicate-elements create mode 120000 Lang/Objeck/Rename-a-file create mode 120000 Lang/Objeck/Repeat-a-string create mode 120000 Lang/Objeck/Reverse-a-string create mode 120000 Lang/Objeck/Roman-numerals-Encode create mode 120000 Lang/Objeck/Roots-of-a-function create mode 120000 Lang/Objeck/Rot-13 create mode 120000 Lang/Objective-C/Copy-a-string create mode 120000 Lang/Objective-C/Environment-variables create mode 120000 Lang/Objective-C/Guess-the-number-With-feedback--player- delete mode 120000 Lang/Objective-C/Guess-the-number-With-feedback-player create mode 120000 Lang/Objective-C/Named-parameters create mode 120000 Lang/Objective-C/Null-object create mode 120000 Lang/Objective-C/Object-serialization create mode 120000 Lang/Objective-C/Optional-parameters create mode 120000 Lang/Objective-C/Polymorphic-copy create mode 120000 Lang/Objective-C/Polymorphism create mode 120000 Lang/Objective-C/Power-set create mode 120000 Lang/Objective-C/Priority-queue create mode 120000 Lang/Objective-C/Program-name create mode 120000 Lang/Objective-C/Read-a-file-line-by-line create mode 120000 Lang/Objective-C/Read-entire-file create mode 120000 Lang/Objective-C/Regular-expressions create mode 120000 Lang/Objective-C/Remove-duplicate-elements create mode 120000 Lang/Objective-C/Rename-a-file create mode 120000 Lang/Objective-C/Repeat-a-string create mode 120000 Lang/Objective-C/Respond-to-an-unknown-method-call create mode 120000 Lang/Objective-C/Reverse-a-string create mode 120000 Lang/Objective-C/Send-an-unknown-method-call create mode 120000 Lang/Objective-C/Set create mode 120000 Lang/Octave/Brownian-tree create mode 120000 Lang/Octave/Copy-a-string create mode 120000 Lang/Octave/Nth-root create mode 120000 Lang/Octave/Palindrome-detection create mode 120000 Lang/Octave/Pascals-triangle create mode 120000 Lang/Octave/Plot-coordinate-pairs create mode 120000 Lang/Octave/Polynomial-long-division create mode 120000 Lang/Octave/Polynomial-regression create mode 120000 Lang/Octave/Primality-by-trial-division create mode 120000 Lang/Octave/Prime-decomposition create mode 120000 Lang/Octave/Program-name create mode 120000 Lang/Octave/Random-numbers create mode 120000 Lang/Octave/Real-constants-and-functions create mode 120000 Lang/Octave/Reduced-row-echelon-form create mode 120000 Lang/Octave/Remove-duplicate-elements create mode 120000 Lang/Octave/Rename-a-file create mode 120000 Lang/Octave/Reverse-a-string create mode 120000 Lang/Octave/Roots-of-a-function create mode 120000 Lang/Octave/Roots-of-unity create mode 120000 Lang/Octave/Runtime-evaluation-In-an-environment create mode 120000 Lang/Octave/Secure-temporary-file create mode 120000 Lang/OpenEdge-Progress/Repeat-a-string create mode 120000 Lang/OpenEdge-Progress/Reverse-a-string create mode 120000 Lang/OpenEdge-Progress/Roman-numerals-Encode create mode 120000 Lang/Order/Partial-function-application create mode 120000 Lang/Order/Program-name create mode 120000 Lang/OxygenBasic/Binary-digits create mode 120000 Lang/OxygenBasic/Copy-a-string create mode 120000 Lang/OxygenBasic/OpenGL create mode 120000 Lang/OxygenBasic/Parallel-calculations create mode 120000 Lang/OxygenBasic/Polymorphic-copy create mode 120000 Lang/OxygenBasic/Polymorphism create mode 120000 Lang/OxygenBasic/Queue-Definition create mode 120000 Lang/OxygenBasic/Range-extraction create mode 120000 Lang/OxygenBasic/Rate-counter create mode 120000 Lang/OxygenBasic/Read-a-file-line-by-line create mode 120000 Lang/OxygenBasic/Repeat-a-string create mode 120000 Lang/OxygenBasic/Return-multiple-values create mode 120000 Lang/OxygenBasic/Reverse-a-string create mode 120000 Lang/OxygenBasic/Runtime-evaluation create mode 120000 Lang/Oxygene/Regular-expressions create mode 120000 Lang/Oz/Arbitrary-precision-integers--included- delete mode 120000 Lang/Oz/Arbitrary-precision-integers-included create mode 120000 Lang/Oz/Environment-variables create mode 120000 Lang/Oz/N-queens-problem create mode 120000 Lang/Oz/Named-parameters create mode 120000 Lang/Oz/Non-continuous-subsequences create mode 120000 Lang/Oz/Non-decimal-radices-Input create mode 120000 Lang/Oz/Nth-root create mode 120000 Lang/Oz/Null-object create mode 120000 Lang/Oz/Number-reversal-game create mode 120000 Lang/Oz/One-dimensional-cellular-automata create mode 120000 Lang/Oz/Optional-parameters create mode 120000 Lang/Oz/Palindrome-detection create mode 120000 Lang/Oz/Pangram-checker create mode 120000 Lang/Oz/Pascals-triangle create mode 120000 Lang/Oz/Pascals-triangle-Puzzle create mode 120000 Lang/Oz/Pattern-matching create mode 120000 Lang/Oz/Perfect-numbers create mode 120000 Lang/Oz/Polymorphic-copy create mode 120000 Lang/Oz/Polymorphism create mode 120000 Lang/Oz/Power-set create mode 120000 Lang/Oz/Price-fraction create mode 120000 Lang/Oz/Program-termination create mode 120000 Lang/Oz/Queue-Definition create mode 120000 Lang/Oz/Queue-Usage create mode 120000 Lang/Oz/Range-expansion create mode 120000 Lang/Oz/Range-extraction create mode 120000 Lang/Oz/Read-entire-file create mode 120000 Lang/Oz/Real-constants-and-functions create mode 120000 Lang/Oz/Regular-expressions create mode 120000 Lang/Oz/Remove-duplicate-elements create mode 120000 Lang/Oz/Rendezvous create mode 120000 Lang/Oz/Repeat-a-string create mode 120000 Lang/Oz/Respond-to-an-unknown-method-call create mode 120000 Lang/Oz/Reverse-a-string create mode 120000 Lang/Oz/Roman-numerals-Encode create mode 120000 Lang/Oz/Rosetta-Code-Count-examples create mode 120000 Lang/Oz/Rosetta-Code-Find-unimplemented-tasks create mode 120000 Lang/Oz/Rosetta-Code-Rank-languages-by-popularity create mode 120000 Lang/Oz/Rot-13 create mode 120000 Lang/Oz/Run-length-encoding create mode 120000 Lang/Oz/Runtime-evaluation create mode 120000 Lang/Oz/Runtime-evaluation-In-an-environment create mode 120000 Lang/Oz/Sequence-of-non-squares create mode 120000 Lang/PARI-GP/Arbitrary-precision-integers--included- delete mode 120000 Lang/PARI-GP/Arbitrary-precision-integers-included create mode 120000 Lang/PARI-GP/Binary-digits create mode 120000 Lang/PARI-GP/Catalan-numbers create mode 120000 Lang/PARI-GP/Copy-a-string create mode 120000 Lang/PARI-GP/Environment-variables create mode 120000 Lang/PARI-GP/Guess-the-number-With-feedback--player- delete mode 120000 Lang/PARI-GP/Guess-the-number-With-feedback-player create mode 120000 Lang/PARI-GP/Non-decimal-radices-Convert create mode 120000 Lang/PARI-GP/Non-decimal-radices-Input create mode 120000 Lang/PARI-GP/Non-decimal-radices-Output create mode 120000 Lang/PARI-GP/Nth-root create mode 120000 Lang/PARI-GP/Null-object create mode 120000 Lang/PARI-GP/Number-names create mode 120000 Lang/PARI-GP/Number-reversal-game create mode 120000 Lang/PARI-GP/Numerical-integration create mode 120000 Lang/PARI-GP/Numerical-integration-Gauss-Legendre-Quadrature create mode 120000 Lang/PARI-GP/One-dimensional-cellular-automata create mode 120000 Lang/PARI-GP/Optional-parameters create mode 120000 Lang/PARI-GP/Order-two-numerical-lists create mode 120000 Lang/PARI-GP/Palindrome-detection create mode 120000 Lang/PARI-GP/Pangram-checker create mode 120000 Lang/PARI-GP/Parallel-calculations create mode 120000 Lang/PARI-GP/Pascals-triangle create mode 120000 Lang/PARI-GP/Pascals-triangle-Puzzle create mode 120000 Lang/PARI-GP/Perfect-numbers create mode 120000 Lang/PARI-GP/Permutations create mode 120000 Lang/PARI-GP/Permutations-Derangements create mode 120000 Lang/PARI-GP/Pick-random-element create mode 120000 Lang/PARI-GP/Playing-cards create mode 120000 Lang/PARI-GP/Plot-coordinate-pairs create mode 120000 Lang/PARI-GP/Pointers-and-references create mode 120000 Lang/PARI-GP/Polynomial-long-division create mode 120000 Lang/PARI-GP/Polynomial-regression create mode 120000 Lang/PARI-GP/Power-set create mode 120000 Lang/PARI-GP/Price-fraction create mode 120000 Lang/PARI-GP/Primality-by-trial-division create mode 120000 Lang/PARI-GP/Prime-decomposition create mode 120000 Lang/PARI-GP/Probabilistic-choice create mode 120000 Lang/PARI-GP/Program-termination create mode 120000 Lang/PARI-GP/Pythagorean-triples create mode 120000 Lang/PARI-GP/QR-decomposition create mode 120000 Lang/PARI-GP/Quaternion-type create mode 120000 Lang/PARI-GP/Random-number-generator--included- create mode 120000 Lang/PARI-GP/Random-numbers create mode 120000 Lang/PARI-GP/Rate-counter create mode 120000 Lang/PARI-GP/Read-a-file-line-by-line create mode 120000 Lang/PARI-GP/Read-entire-file create mode 120000 Lang/PARI-GP/Real-constants-and-functions create mode 120000 Lang/PARI-GP/Reduced-row-echelon-form create mode 120000 Lang/PARI-GP/Remove-duplicate-elements create mode 120000 Lang/PARI-GP/Rename-a-file create mode 120000 Lang/PARI-GP/Repeat-a-string create mode 120000 Lang/PARI-GP/Return-multiple-values create mode 120000 Lang/PARI-GP/Reverse-a-string create mode 120000 Lang/PARI-GP/Rock-paper-scissors create mode 120000 Lang/PARI-GP/Roman-numerals-Decode create mode 120000 Lang/PARI-GP/Roman-numerals-Encode create mode 120000 Lang/PARI-GP/Roots-of-a-function create mode 120000 Lang/PARI-GP/Roots-of-a-quadratic-function create mode 120000 Lang/PARI-GP/Roots-of-unity create mode 120000 Lang/PARI-GP/Rot-13 create mode 120000 Lang/PARI-GP/Run-length-encoding create mode 120000 Lang/PARI-GP/Runtime-evaluation-In-an-environment create mode 120000 Lang/PARI-GP/Self-describing-numbers create mode 120000 Lang/PARI-GP/Send-an-unknown-method-call create mode 120000 Lang/PARI-GP/Sequence-of-non-squares create mode 120000 Lang/PARI-GP/Set create mode 120000 Lang/PARI-GP/Set-consolidation create mode 120000 Lang/PHP/Arbitrary-precision-integers--included- delete mode 120000 Lang/PHP/Arbitrary-precision-integers-included create mode 120000 Lang/PHP/Binary-digits create mode 120000 Lang/PHP/Calendar---for-real-programmers delete mode 120000 Lang/PHP/Calendar-for-real-programmers create mode 120000 Lang/PHP/Catalan-numbers create mode 120000 Lang/PHP/Copy-a-string create mode 120000 Lang/PHP/Environment-variables create mode 120000 Lang/PHP/N-queens-problem create mode 120000 Lang/PHP/Non-decimal-radices-Convert create mode 120000 Lang/PHP/Non-decimal-radices-Input create mode 120000 Lang/PHP/Non-decimal-radices-Output create mode 120000 Lang/PHP/Nth-root create mode 120000 Lang/PHP/Null-object create mode 120000 Lang/PHP/Number-names create mode 120000 Lang/PHP/Object-serialization create mode 120000 Lang/PHP/Palindrome-detection create mode 120000 Lang/PHP/Pangram-checker create mode 120000 Lang/PHP/Parametrized-SQL-statement create mode 120000 Lang/PHP/Parsing-RPN-calculator-algorithm create mode 120000 Lang/PHP/Pascals-triangle create mode 120000 Lang/PHP/Perfect-numbers create mode 120000 Lang/PHP/Pick-random-element create mode 120000 Lang/PHP/Pig-the-dice-game create mode 120000 Lang/PHP/Playing-cards create mode 120000 Lang/PHP/Pointers-and-references create mode 120000 Lang/PHP/Polymorphic-copy create mode 120000 Lang/PHP/Polymorphism create mode 120000 Lang/PHP/Power-set create mode 120000 Lang/PHP/Primality-by-trial-division create mode 120000 Lang/PHP/Priority-queue create mode 120000 Lang/PHP/Program-name create mode 120000 Lang/PHP/Program-termination create mode 120000 Lang/PHP/Queue-Definition create mode 120000 Lang/PHP/Queue-Usage create mode 120000 Lang/PHP/Random-numbers create mode 120000 Lang/PHP/Range-expansion create mode 120000 Lang/PHP/Read-a-file-line-by-line create mode 120000 Lang/PHP/Read-entire-file create mode 120000 Lang/PHP/Real-constants-and-functions create mode 120000 Lang/PHP/Reduced-row-echelon-form create mode 120000 Lang/PHP/Regular-expressions create mode 120000 Lang/PHP/Remove-duplicate-elements create mode 120000 Lang/PHP/Rename-a-file create mode 120000 Lang/PHP/Repeat-a-string create mode 120000 Lang/PHP/Respond-to-an-unknown-method-call create mode 120000 Lang/PHP/Return-multiple-values create mode 120000 Lang/PHP/Reverse-a-string create mode 120000 Lang/PHP/Roman-numerals-Decode create mode 120000 Lang/PHP/Roman-numerals-Encode create mode 120000 Lang/PHP/Rot-13 create mode 120000 Lang/PHP/Run-length-encoding create mode 120000 Lang/PHP/Runtime-evaluation create mode 120000 Lang/PHP/Runtime-evaluation-In-an-environment create mode 120000 Lang/PHP/SEDOLs create mode 120000 Lang/PHP/Secure-temporary-file create mode 120000 Lang/PHP/Semordnilap create mode 120000 Lang/PHP/Send-an-unknown-method-call create mode 120000 Lang/PHP/Send-email create mode 120000 Lang/PL-I/Binary-digits create mode 120000 Lang/PL-I/Catalan-numbers create mode 120000 Lang/PL-I/Copy-a-string create mode 120000 Lang/PL-I/Non-decimal-radices-Convert create mode 120000 Lang/PL-I/Non-decimal-radices-Input create mode 120000 Lang/PL-I/Non-decimal-radices-Output create mode 120000 Lang/PL-I/Nth-root create mode 120000 Lang/PL-I/Null-object create mode 120000 Lang/PL-I/Number-names create mode 120000 Lang/PL-I/Number-reversal-game create mode 120000 Lang/PL-I/Numerical-integration create mode 120000 Lang/PL-I/Palindrome-detection create mode 120000 Lang/PL-I/Pangram-checker create mode 120000 Lang/PL-I/Parsing-RPN-calculator-algorithm create mode 120000 Lang/PL-I/Parsing-RPN-to-infix-conversion create mode 120000 Lang/PL-I/Parsing-Shunting-yard-algorithm create mode 120000 Lang/PL-I/Pascals-triangle create mode 120000 Lang/PL-I/Perfect-numbers create mode 120000 Lang/PL-I/Pick-random-element create mode 120000 Lang/PL-I/Price-fraction create mode 120000 Lang/PL-I/Primality-by-trial-division create mode 120000 Lang/PL-I/Prime-decomposition create mode 120000 Lang/PL-I/Program-termination create mode 120000 Lang/PL-I/Queue-Definition create mode 120000 Lang/PL-I/Queue-Usage create mode 120000 Lang/PL-I/Random-number-generator--included- create mode 120000 Lang/PL-I/Random-numbers create mode 120000 Lang/PL-I/Range-expansion create mode 120000 Lang/PL-I/Range-extraction create mode 120000 Lang/PL-I/Read-a-configuration-file create mode 120000 Lang/PL-I/Read-a-file-line-by-line create mode 120000 Lang/PL-I/Read-a-specific-line-from-a-file create mode 120000 Lang/PL-I/Read-entire-file create mode 120000 Lang/PL-I/Real-constants-and-functions create mode 120000 Lang/PL-I/Remove-duplicate-elements create mode 120000 Lang/PL-I/Repeat-a-string create mode 120000 Lang/PL-I/Return-multiple-values create mode 120000 Lang/PL-I/Reverse-a-string create mode 120000 Lang/PL-I/Roman-numerals-Decode create mode 120000 Lang/PL-I/Roman-numerals-Encode create mode 120000 Lang/PL-I/Roots-of-a-function create mode 120000 Lang/PL-I/Roots-of-a-quadratic-function create mode 120000 Lang/PL-I/Roots-of-unity create mode 120000 Lang/PL-I/Rot-13 create mode 120000 Lang/PL-I/Run-length-encoding create mode 120000 Lang/PL-I/SEDOLs create mode 120000 Lang/PL-I/Semordnilap create mode 120000 Lang/PL-I/Sequence-of-non-squares create mode 120000 Lang/PL-SQL/Random-number-generator--included- create mode 120000 Lang/PL-SQL/Random-numbers create mode 120000 Lang/PL-SQL/Roman-numerals-Decode create mode 120000 Lang/PL-SQL/Roman-numerals-Encode create mode 120000 Lang/Pascal/Arbitrary-precision-integers--included- delete mode 120000 Lang/Pascal/Arbitrary-precision-integers-included create mode 120000 Lang/Pascal/Catalan-numbers create mode 120000 Lang/Pascal/Copy-a-string create mode 120000 Lang/Pascal/Dragon-curve create mode 120000 Lang/Pascal/Guess-the-number-With-feedback--player- delete mode 120000 Lang/Pascal/Guess-the-number-With-feedback-player create mode 120000 Lang/Pascal/N-queens-problem create mode 120000 Lang/Pascal/Non-decimal-radices-Convert create mode 120000 Lang/Pascal/Number-names create mode 120000 Lang/Pascal/Numerical-integration create mode 120000 Lang/Pascal/One-of-n-lines-in-a-file create mode 120000 Lang/Pascal/OpenGL create mode 120000 Lang/Pascal/Palindrome-detection create mode 120000 Lang/Pascal/Pascals-triangle create mode 120000 Lang/Pascal/Perfect-numbers create mode 120000 Lang/Pascal/Permutations create mode 120000 Lang/Pascal/Pick-random-element create mode 120000 Lang/Pascal/Price-fraction create mode 120000 Lang/Pascal/Primality-by-trial-division create mode 120000 Lang/Pascal/Prime-decomposition create mode 120000 Lang/Pascal/Program-name create mode 120000 Lang/Pascal/Pythagorean-triples create mode 120000 Lang/Pascal/Queue-Definition create mode 120000 Lang/Pascal/Random-number-generator--device- create mode 120000 Lang/Pascal/Read-a-configuration-file create mode 120000 Lang/Pascal/Read-a-specific-line-from-a-file create mode 120000 Lang/Pascal/Regular-expressions create mode 120000 Lang/Pascal/Remove-duplicate-elements create mode 120000 Lang/Pascal/Rename-a-file create mode 120000 Lang/Pascal/Reverse-a-string create mode 120000 Lang/Pascal/Roots-of-a-function create mode 120000 Lang/Pascal/Roots-of-a-quadratic-function create mode 120000 Lang/Pascal/Roots-of-unity create mode 120000 Lang/Pascal/Rot-13 create mode 120000 Lang/Pascal/Run-length-encoding create mode 120000 Lang/Pascal/SEDOLs create mode 120000 Lang/Pascal/Secure-temporary-file create mode 120000 Lang/Pascal/Self-describing-numbers create mode 120000 Lang/Pascal/Sequence-of-non-squares create mode 120000 Lang/Pascal/Set create mode 120000 Lang/Perl-6/Arbitrary-precision-integers--included- delete mode 120000 Lang/Perl-6/Arbitrary-precision-integers-included create mode 120000 Lang/Perl-6/Binary-digits create mode 120000 Lang/Perl-6/Calendar---for-real-programmers delete mode 120000 Lang/Perl-6/Calendar-for-real-programmers create mode 120000 Lang/Perl-6/Catalan-numbers create mode 120000 Lang/Perl-6/Copy-a-string create mode 120000 Lang/Perl-6/Dragon-curve create mode 120000 Lang/Perl-6/Environment-variables create mode 120000 Lang/Perl-6/Guess-the-number-With-feedback--player- delete mode 120000 Lang/Perl-6/Guess-the-number-With-feedback-player create mode 120000 Lang/Perl-6/N-queens-problem create mode 120000 Lang/Perl-6/Named-parameters create mode 120000 Lang/Perl-6/Nautical-bell create mode 120000 Lang/Perl-6/Non-continuous-subsequences create mode 120000 Lang/Perl-6/Non-decimal-radices-Convert create mode 120000 Lang/Perl-6/Non-decimal-radices-Input create mode 120000 Lang/Perl-6/Non-decimal-radices-Output create mode 120000 Lang/Perl-6/Nth-root create mode 120000 Lang/Perl-6/Null-object create mode 120000 Lang/Perl-6/Number-names create mode 120000 Lang/Perl-6/Number-reversal-game create mode 120000 Lang/Perl-6/Numeric-error-propagation create mode 120000 Lang/Perl-6/Numerical-integration create mode 120000 Lang/Perl-6/Numerical-integration-Gauss-Legendre-Quadrature create mode 120000 Lang/Perl-6/One-dimensional-cellular-automata create mode 120000 Lang/Perl-6/One-of-n-lines-in-a-file create mode 120000 Lang/Perl-6/Optional-parameters create mode 120000 Lang/Perl-6/Order-two-numerical-lists create mode 120000 Lang/Perl-6/Ordered-Partitions create mode 120000 Lang/Perl-6/Palindrome-detection create mode 120000 Lang/Perl-6/Pangram-checker create mode 120000 Lang/Perl-6/Parallel-calculations create mode 120000 Lang/Perl-6/Parametric-polymorphism create mode 120000 Lang/Perl-6/Parsing-RPN-calculator-algorithm create mode 120000 Lang/Perl-6/Parsing-RPN-to-infix-conversion create mode 120000 Lang/Perl-6/Partial-function-application create mode 120000 Lang/Perl-6/Pascals-triangle create mode 120000 Lang/Perl-6/Pattern-matching create mode 120000 Lang/Perl-6/Perfect-numbers create mode 120000 Lang/Perl-6/Permutations create mode 120000 Lang/Perl-6/Permutations-Derangements create mode 120000 Lang/Perl-6/Permutations-by-swapping create mode 120000 Lang/Perl-6/Pick-random-element create mode 120000 Lang/Perl-6/Pig-the-dice-game create mode 120000 Lang/Perl-6/Playing-cards create mode 120000 Lang/Perl-6/Plot-coordinate-pairs create mode 120000 Lang/Perl-6/Pointers-and-references create mode 120000 Lang/Perl-6/Polymorphic-copy create mode 120000 Lang/Perl-6/Polymorphism create mode 120000 Lang/Perl-6/Polynomial-long-division create mode 120000 Lang/Perl-6/Power-set create mode 120000 Lang/Perl-6/Pragmatic-directives create mode 120000 Lang/Perl-6/Price-fraction create mode 120000 Lang/Perl-6/Primality-by-trial-division create mode 120000 Lang/Perl-6/Prime-decomposition create mode 120000 Lang/Perl-6/Priority-queue create mode 120000 Lang/Perl-6/Probabilistic-choice create mode 120000 Lang/Perl-6/Problem-of-Apollonius create mode 120000 Lang/Perl-6/Program-name create mode 120000 Lang/Perl-6/Program-termination create mode 120000 Lang/Perl-6/Pythagorean-triples create mode 120000 Lang/Perl-6/Quaternion-type create mode 120000 Lang/Perl-6/Queue-Definition create mode 120000 Lang/Perl-6/Queue-Usage create mode 120000 Lang/Perl-6/RIPEMD-160 create mode 120000 Lang/Perl-6/Random-number-generator--device- create mode 120000 Lang/Perl-6/Random-numbers create mode 120000 Lang/Perl-6/Range-expansion create mode 120000 Lang/Perl-6/Range-extraction create mode 120000 Lang/Perl-6/Rate-counter create mode 120000 Lang/Perl-6/Ray-casting-algorithm create mode 120000 Lang/Perl-6/Read-a-configuration-file create mode 120000 Lang/Perl-6/Read-a-file-line-by-line create mode 120000 Lang/Perl-6/Read-a-specific-line-from-a-file create mode 120000 Lang/Perl-6/Read-entire-file create mode 120000 Lang/Perl-6/Real-constants-and-functions create mode 120000 Lang/Perl-6/Reduced-row-echelon-form create mode 120000 Lang/Perl-6/Regular-expressions create mode 120000 Lang/Perl-6/Remove-duplicate-elements create mode 120000 Lang/Perl-6/Remove-lines-from-a-file create mode 120000 Lang/Perl-6/Rename-a-file create mode 120000 Lang/Perl-6/Repeat-a-string create mode 120000 Lang/Perl-6/Resistor-mesh create mode 120000 Lang/Perl-6/Respond-to-an-unknown-method-call create mode 120000 Lang/Perl-6/Return-multiple-values create mode 120000 Lang/Perl-6/Reverse-a-string create mode 120000 Lang/Perl-6/Rock-paper-scissors create mode 120000 Lang/Perl-6/Roman-numerals-Decode create mode 120000 Lang/Perl-6/Roman-numerals-Encode create mode 120000 Lang/Perl-6/Roots-of-a-function create mode 120000 Lang/Perl-6/Roots-of-a-quadratic-function create mode 120000 Lang/Perl-6/Roots-of-unity create mode 120000 Lang/Perl-6/Rosetta-Code-Rank-languages-by-popularity create mode 120000 Lang/Perl-6/Rot-13 create mode 120000 Lang/Perl-6/Run-length-encoding create mode 120000 Lang/Perl-6/Runtime-evaluation create mode 120000 Lang/Perl-6/Runtime-evaluation-In-an-environment create mode 120000 Lang/Perl-6/S-Expressions create mode 120000 Lang/Perl-6/SEDOLs create mode 120000 Lang/Perl-6/Same-Fringe create mode 120000 Lang/Perl-6/Scope-Function-names-and-labels create mode 120000 Lang/Perl-6/Scope-modifiers create mode 120000 Lang/Perl-6/Self-describing-numbers create mode 120000 Lang/Perl-6/Self-referential-sequence create mode 120000 Lang/Perl-6/Semordnilap create mode 120000 Lang/Perl-6/Send-an-unknown-method-call create mode 120000 Lang/Perl-6/Sequence-of-non-squares create mode 120000 Lang/Perl-6/Set create mode 120000 Lang/Perl-6/Set-consolidation create mode 120000 Lang/Perl-6/Set-of-real-numbers create mode 120000 Lang/Perl/Arbitrary-precision-integers--included- delete mode 120000 Lang/Perl/Arbitrary-precision-integers-included create mode 120000 Lang/Perl/Binary-digits create mode 120000 Lang/Perl/Brownian-tree create mode 120000 Lang/Perl/Calendar---for-real-programmers delete mode 120000 Lang/Perl/Calendar-for-real-programmers create mode 120000 Lang/Perl/Catalan-numbers create mode 120000 Lang/Perl/Copy-a-string create mode 120000 Lang/Perl/Environment-variables create mode 120000 Lang/Perl/Execute-a-Markov-algorithm create mode 120000 Lang/Perl/Guess-the-number-With-feedback--player- delete mode 120000 Lang/Perl/Guess-the-number-With-feedback-player create mode 120000 Lang/Perl/N-queens-problem create mode 120000 Lang/Perl/Named-parameters create mode 120000 Lang/Perl/Non-continuous-subsequences create mode 120000 Lang/Perl/Non-decimal-radices-Convert create mode 120000 Lang/Perl/Non-decimal-radices-Input create mode 120000 Lang/Perl/Non-decimal-radices-Output create mode 120000 Lang/Perl/Nth-root create mode 120000 Lang/Perl/Null-object create mode 120000 Lang/Perl/Number-names create mode 120000 Lang/Perl/Number-reversal-game create mode 120000 Lang/Perl/Numeric-error-propagation create mode 120000 Lang/Perl/Object-serialization create mode 120000 Lang/Perl/One-dimensional-cellular-automata create mode 120000 Lang/Perl/OpenGL create mode 120000 Lang/Perl/Optional-parameters create mode 120000 Lang/Perl/Order-two-numerical-lists create mode 120000 Lang/Perl/Ordered-Partitions create mode 120000 Lang/Perl/Palindrome-detection create mode 120000 Lang/Perl/Pangram-checker create mode 120000 Lang/Perl/Parametrized-SQL-statement create mode 120000 Lang/Perl/Parsing-RPN-calculator-algorithm create mode 120000 Lang/Perl/Parsing-RPN-to-infix-conversion create mode 120000 Lang/Perl/Partial-function-application create mode 120000 Lang/Perl/Pascals-triangle create mode 120000 Lang/Perl/Perfect-numbers create mode 120000 Lang/Perl/Permutations create mode 120000 Lang/Perl/Permutations-Derangements create mode 120000 Lang/Perl/Pick-random-element create mode 120000 Lang/Perl/Playing-cards create mode 120000 Lang/Perl/Plot-coordinate-pairs create mode 120000 Lang/Perl/Pointers-and-references create mode 120000 Lang/Perl/Polymorphic-copy create mode 120000 Lang/Perl/Polymorphism create mode 120000 Lang/Perl/Polynomial-long-division create mode 120000 Lang/Perl/Power-set create mode 120000 Lang/Perl/Pragmatic-directives create mode 120000 Lang/Perl/Price-fraction create mode 120000 Lang/Perl/Primality-by-trial-division create mode 120000 Lang/Perl/Prime-decomposition create mode 120000 Lang/Perl/Priority-queue create mode 120000 Lang/Perl/Probabilistic-choice create mode 120000 Lang/Perl/Program-name create mode 120000 Lang/Perl/Program-termination create mode 120000 Lang/Perl/Quaternion-type create mode 120000 Lang/Perl/Queue-Definition create mode 120000 Lang/Perl/Queue-Usage create mode 120000 Lang/Perl/Random-number-generator--device- create mode 120000 Lang/Perl/Random-numbers create mode 120000 Lang/Perl/Range-expansion create mode 120000 Lang/Perl/Range-extraction create mode 120000 Lang/Perl/Rate-counter create mode 120000 Lang/Perl/Ray-casting-algorithm create mode 120000 Lang/Perl/Read-a-configuration-file create mode 120000 Lang/Perl/Read-a-file-line-by-line create mode 120000 Lang/Perl/Read-a-specific-line-from-a-file create mode 120000 Lang/Perl/Read-entire-file create mode 120000 Lang/Perl/Real-constants-and-functions create mode 120000 Lang/Perl/Reduced-row-echelon-form create mode 120000 Lang/Perl/Regular-expressions create mode 120000 Lang/Perl/Remove-duplicate-elements create mode 120000 Lang/Perl/Remove-lines-from-a-file create mode 120000 Lang/Perl/Rename-a-file create mode 120000 Lang/Perl/Repeat-a-string create mode 120000 Lang/Perl/Resistor-mesh create mode 120000 Lang/Perl/Respond-to-an-unknown-method-call create mode 120000 Lang/Perl/Return-multiple-values create mode 120000 Lang/Perl/Reverse-a-string create mode 120000 Lang/Perl/Roman-numerals-Decode create mode 120000 Lang/Perl/Roman-numerals-Encode create mode 120000 Lang/Perl/Roots-of-a-function create mode 120000 Lang/Perl/Roots-of-a-quadratic-function create mode 120000 Lang/Perl/Roots-of-unity create mode 120000 Lang/Perl/Rosetta-Code-Count-examples create mode 120000 Lang/Perl/Rosetta-Code-Find-unimplemented-tasks create mode 120000 Lang/Perl/Rosetta-Code-Fix-code-tags create mode 120000 Lang/Perl/Rosetta-Code-Rank-languages-by-popularity create mode 120000 Lang/Perl/Rot-13 create mode 120000 Lang/Perl/Run-length-encoding create mode 120000 Lang/Perl/Runtime-evaluation create mode 120000 Lang/Perl/Runtime-evaluation-In-an-environment create mode 120000 Lang/Perl/S-Expressions create mode 120000 Lang/Perl/SEDOLs create mode 120000 Lang/Perl/Scope-modifiers create mode 120000 Lang/Perl/Secure-temporary-file create mode 120000 Lang/Perl/Self-describing-numbers create mode 120000 Lang/Perl/Self-referential-sequence create mode 120000 Lang/Perl/Semordnilap create mode 120000 Lang/Perl/Send-an-unknown-method-call create mode 120000 Lang/Perl/Send-email create mode 120000 Lang/Perl/Sequence-of-non-squares create mode 120000 Lang/Perl/Set create mode 120000 Lang/Perl/Set-of-real-numbers create mode 120000 Lang/PicoLisp/Arbitrary-precision-integers--included- delete mode 120000 Lang/PicoLisp/Arbitrary-precision-integers-included create mode 120000 Lang/PicoLisp/Binary-digits create mode 120000 Lang/PicoLisp/Brownian-tree create mode 120000 Lang/PicoLisp/Calendar---for-real-programmers delete mode 120000 Lang/PicoLisp/Calendar-for-real-programmers create mode 120000 Lang/PicoLisp/Catalan-numbers create mode 120000 Lang/PicoLisp/Copy-a-string create mode 120000 Lang/PicoLisp/Dragon-curve create mode 120000 Lang/PicoLisp/Environment-variables create mode 120000 Lang/PicoLisp/Execute-a-Markov-algorithm create mode 120000 Lang/PicoLisp/Guess-the-number-With-feedback--player- delete mode 120000 Lang/PicoLisp/Guess-the-number-With-feedback-player create mode 120000 Lang/PicoLisp/N-queens-problem create mode 120000 Lang/PicoLisp/Named-parameters create mode 120000 Lang/PicoLisp/Non-continuous-subsequences create mode 120000 Lang/PicoLisp/Non-decimal-radices-Convert create mode 120000 Lang/PicoLisp/Non-decimal-radices-Input create mode 120000 Lang/PicoLisp/Non-decimal-radices-Output create mode 120000 Lang/PicoLisp/Nth-root create mode 120000 Lang/PicoLisp/Null-object create mode 120000 Lang/PicoLisp/Number-names create mode 120000 Lang/PicoLisp/Number-reversal-game create mode 120000 Lang/PicoLisp/Numeric-error-propagation create mode 120000 Lang/PicoLisp/Numerical-integration create mode 120000 Lang/PicoLisp/Object-serialization create mode 120000 Lang/PicoLisp/One-dimensional-cellular-automata create mode 120000 Lang/PicoLisp/One-of-n-lines-in-a-file create mode 120000 Lang/PicoLisp/OpenGL create mode 120000 Lang/PicoLisp/Optional-parameters create mode 120000 Lang/PicoLisp/Order-two-numerical-lists create mode 120000 Lang/PicoLisp/Ordered-Partitions create mode 120000 Lang/PicoLisp/Palindrome-detection create mode 120000 Lang/PicoLisp/Pangram-checker create mode 120000 Lang/PicoLisp/Parallel-calculations create mode 120000 Lang/PicoLisp/Parametric-polymorphism create mode 120000 Lang/PicoLisp/Parametrized-SQL-statement create mode 120000 Lang/PicoLisp/Parsing-RPN-calculator-algorithm create mode 120000 Lang/PicoLisp/Parsing-RPN-to-infix-conversion create mode 120000 Lang/PicoLisp/Parsing-Shunting-yard-algorithm create mode 120000 Lang/PicoLisp/Partial-function-application create mode 120000 Lang/PicoLisp/Pascals-triangle create mode 120000 Lang/PicoLisp/Pascals-triangle-Puzzle create mode 120000 Lang/PicoLisp/Pattern-matching create mode 120000 Lang/PicoLisp/Percentage-difference-between-images create mode 120000 Lang/PicoLisp/Perfect-numbers create mode 120000 Lang/PicoLisp/Permutation-test create mode 120000 Lang/PicoLisp/Permutations create mode 120000 Lang/PicoLisp/Permutations-Derangements create mode 120000 Lang/PicoLisp/Pick-random-element create mode 120000 Lang/PicoLisp/Pinstripe-Display create mode 120000 Lang/PicoLisp/Pinstripe-Printer create mode 120000 Lang/PicoLisp/Play-recorded-sounds create mode 120000 Lang/PicoLisp/Playing-cards create mode 120000 Lang/PicoLisp/Plot-coordinate-pairs create mode 120000 Lang/PicoLisp/Pointers-and-references create mode 120000 Lang/PicoLisp/Polymorphic-copy create mode 120000 Lang/PicoLisp/Polymorphism create mode 120000 Lang/PicoLisp/Polynomial-long-division create mode 120000 Lang/PicoLisp/Power-set create mode 120000 Lang/PicoLisp/Price-fraction create mode 120000 Lang/PicoLisp/Primality-by-trial-division create mode 120000 Lang/PicoLisp/Prime-decomposition create mode 120000 Lang/PicoLisp/Priority-queue create mode 120000 Lang/PicoLisp/Probabilistic-choice create mode 120000 Lang/PicoLisp/Program-name create mode 120000 Lang/PicoLisp/Program-termination create mode 120000 Lang/PicoLisp/Pythagorean-triples create mode 120000 Lang/PicoLisp/Quaternion-type create mode 120000 Lang/PicoLisp/Queue-Definition create mode 120000 Lang/PicoLisp/Queue-Usage create mode 120000 Lang/PicoLisp/Random-number-generator--device- create mode 120000 Lang/PicoLisp/Random-numbers create mode 120000 Lang/PicoLisp/Range-expansion create mode 120000 Lang/PicoLisp/Range-extraction create mode 120000 Lang/PicoLisp/Rate-counter create mode 120000 Lang/PicoLisp/Ray-casting-algorithm create mode 120000 Lang/PicoLisp/Read-a-configuration-file create mode 120000 Lang/PicoLisp/Read-a-file-line-by-line create mode 120000 Lang/PicoLisp/Read-a-specific-line-from-a-file create mode 120000 Lang/PicoLisp/Read-entire-file create mode 120000 Lang/PicoLisp/Real-constants-and-functions create mode 120000 Lang/PicoLisp/Record-sound create mode 120000 Lang/PicoLisp/Reduced-row-echelon-form create mode 120000 Lang/PicoLisp/Regular-expressions create mode 120000 Lang/PicoLisp/Remove-duplicate-elements create mode 120000 Lang/PicoLisp/Remove-lines-from-a-file create mode 120000 Lang/PicoLisp/Rename-a-file create mode 120000 Lang/PicoLisp/Rendezvous create mode 120000 Lang/PicoLisp/Repeat-a-string create mode 120000 Lang/PicoLisp/Respond-to-an-unknown-method-call create mode 120000 Lang/PicoLisp/Return-multiple-values create mode 120000 Lang/PicoLisp/Reverse-a-string create mode 120000 Lang/PicoLisp/Rock-paper-scissors create mode 120000 Lang/PicoLisp/Roman-numerals-Decode create mode 120000 Lang/PicoLisp/Roman-numerals-Encode create mode 120000 Lang/PicoLisp/Roots-of-a-function create mode 120000 Lang/PicoLisp/Roots-of-a-quadratic-function create mode 120000 Lang/PicoLisp/Roots-of-unity create mode 120000 Lang/PicoLisp/Rosetta-Code-Count-examples create mode 120000 Lang/PicoLisp/Rosetta-Code-Find-unimplemented-tasks create mode 120000 Lang/PicoLisp/Rosetta-Code-Fix-code-tags create mode 120000 Lang/PicoLisp/Rosetta-Code-Rank-languages-by-popularity create mode 120000 Lang/PicoLisp/Rot-13 create mode 120000 Lang/PicoLisp/Run-length-encoding create mode 120000 Lang/PicoLisp/Runtime-evaluation-In-an-environment create mode 120000 Lang/PicoLisp/S-Expressions create mode 120000 Lang/PicoLisp/SEDOLs create mode 120000 Lang/PicoLisp/Same-Fringe create mode 120000 Lang/PicoLisp/Secure-temporary-file create mode 120000 Lang/PicoLisp/Self-describing-numbers create mode 120000 Lang/PicoLisp/Self-referential-sequence create mode 120000 Lang/PicoLisp/Send-an-unknown-method-call create mode 120000 Lang/PicoLisp/Send-email create mode 120000 Lang/PicoLisp/Sequence-of-non-squares create mode 120000 Lang/PicoLisp/Set create mode 120000 Lang/PicoLisp/Set-consolidation create mode 120000 Lang/Pike/Arbitrary-precision-integers--included- delete mode 120000 Lang/Pike/Arbitrary-precision-integers-included create mode 120000 Lang/Pike/Copy-a-string create mode 120000 Lang/Pike/Null-object create mode 120000 Lang/Pike/OpenGL create mode 120000 Lang/Pike/Order-two-numerical-lists create mode 120000 Lang/Pike/Palindrome-detection create mode 120000 Lang/Pike/Read-entire-file create mode 120000 Lang/Pike/Rename-a-file create mode 120000 Lang/Pike/Repeat-a-string create mode 120000 Lang/Pike/Respond-to-an-unknown-method-call create mode 120000 Lang/Pike/Return-multiple-values create mode 120000 Lang/Pike/Roman-numerals-Encode create mode 120000 Lang/Pike/Rot-13 create mode 120000 Lang/Pike/Runtime-evaluation create mode 120000 Lang/Pike/Runtime-evaluation-In-an-environment create mode 120000 Lang/Pike/S-Expressions create mode 120000 Lang/Pike/Send-an-unknown-method-call create mode 120000 Lang/Pike/Send-email create mode 120000 Lang/PlainTeX/Catalan-numbers create mode 120000 Lang/Pop11/Copy-a-string create mode 120000 Lang/Pop11/Non-continuous-subsequences create mode 120000 Lang/Pop11/Non-decimal-radices-Convert create mode 120000 Lang/Pop11/Polymorphism create mode 120000 Lang/Pop11/Program-termination create mode 120000 Lang/Pop11/Random-numbers create mode 120000 Lang/Pop11/Real-constants-and-functions create mode 120000 Lang/Pop11/Remove-duplicate-elements create mode 120000 Lang/Pop11/Rename-a-file create mode 120000 Lang/Pop11/Reverse-a-string create mode 120000 Lang/Pop11/Rot-13 create mode 120000 Lang/PostScript/Copy-a-string create mode 120000 Lang/PostScript/Dragon-curve create mode 120000 Lang/PostScript/Plot-coordinate-pairs create mode 120000 Lang/PostScript/Program-termination create mode 120000 Lang/PostScript/Queue-Definition create mode 120000 Lang/PostScript/Queue-Usage create mode 120000 Lang/PostScript/Remove-duplicate-elements create mode 120000 Lang/PostScript/Repeat-a-string create mode 120000 Lang/PostScript/Reverse-a-string create mode 120000 Lang/PostScript/Rot-13 create mode 120000 Lang/PostScript/Sequence-of-non-squares create mode 120000 Lang/PowerBASIC/N-queens-problem create mode 120000 Lang/PowerBASIC/Number-names create mode 120000 Lang/PowerBASIC/Palindrome-detection create mode 120000 Lang/PowerBASIC/Permutations create mode 120000 Lang/PowerBASIC/Program-name create mode 120000 Lang/PowerBASIC/Remove-lines-from-a-file create mode 120000 Lang/PowerBASIC/Repeat-a-string create mode 120000 Lang/PowerBASIC/Roman-numerals-Encode create mode 120000 Lang/PowerBASIC/Run-length-encoding create mode 120000 Lang/PowerShell/Binary-digits create mode 120000 Lang/PowerShell/Copy-a-string create mode 120000 Lang/PowerShell/Environment-variables create mode 120000 Lang/PowerShell/Named-parameters create mode 120000 Lang/PowerShell/Non-continuous-subsequences create mode 120000 Lang/PowerShell/Non-decimal-radices-Output create mode 120000 Lang/PowerShell/Null-object create mode 120000 Lang/PowerShell/Pascals-triangle create mode 120000 Lang/PowerShell/Perfect-numbers create mode 120000 Lang/PowerShell/Primality-by-trial-division create mode 120000 Lang/PowerShell/Program-termination create mode 120000 Lang/PowerShell/Read-entire-file create mode 120000 Lang/PowerShell/Real-constants-and-functions create mode 120000 Lang/PowerShell/Regular-expressions create mode 120000 Lang/PowerShell/Remove-duplicate-elements create mode 120000 Lang/PowerShell/Rename-a-file create mode 120000 Lang/PowerShell/Repeat-a-string create mode 120000 Lang/PowerShell/Reverse-a-string create mode 120000 Lang/PowerShell/Rot-13 create mode 120000 Lang/PowerShell/Run-length-encoding create mode 120000 Lang/PowerShell/Scope-modifiers create mode 120000 Lang/PowerShell/Sequence-of-non-squares create mode 120000 Lang/ProDOS/Copy-a-string create mode 120000 Lang/ProDOS/Random-number-generator--device- create mode 120000 Lang/ProDOS/Rename-a-file create mode 120000 Lang/Prolog/Catalan-numbers create mode 120000 Lang/Prolog/Dragon-curve create mode 120000 Lang/Prolog/N-queens-problem create mode 120000 Lang/Prolog/Non-continuous-subsequences create mode 120000 Lang/Prolog/One-dimensional-cellular-automata create mode 120000 Lang/Prolog/Palindrome-detection create mode 120000 Lang/Prolog/Pangram-checker create mode 120000 Lang/Prolog/Parallel-calculations create mode 120000 Lang/Prolog/Parsing-RPN-calculator-algorithm create mode 120000 Lang/Prolog/Partial-function-application create mode 120000 Lang/Prolog/Pascals-triangle create mode 120000 Lang/Prolog/Pascals-triangle-Puzzle create mode 120000 Lang/Prolog/Perfect-numbers create mode 120000 Lang/Prolog/Permutations create mode 120000 Lang/Prolog/Playing-cards create mode 120000 Lang/Prolog/Power-set create mode 120000 Lang/Prolog/Primality-by-trial-division create mode 120000 Lang/Prolog/Prime-decomposition create mode 120000 Lang/Prolog/Priority-queue create mode 120000 Lang/Prolog/Program-termination create mode 120000 Lang/Prolog/Queue-Definition create mode 120000 Lang/Prolog/Queue-Usage create mode 120000 Lang/Prolog/Range-expansion create mode 120000 Lang/Prolog/Range-extraction create mode 120000 Lang/Prolog/Remove-duplicate-elements create mode 120000 Lang/Prolog/Repeat-a-string create mode 120000 Lang/Prolog/Reverse-a-string create mode 120000 Lang/Prolog/Roman-numerals-Decode create mode 120000 Lang/Prolog/Roman-numerals-Encode create mode 120000 Lang/Prolog/Rot-13 create mode 120000 Lang/Prolog/Run-length-encoding create mode 120000 Lang/Prolog/Self-describing-numbers create mode 120000 Lang/Prolog/Set create mode 120000 Lang/Protium/Read-a-configuration-file create mode 120000 Lang/Protium/Reverse-a-string create mode 120000 Lang/Protium/Roman-numerals-Encode create mode 120000 Lang/Pure/Prime-decomposition create mode 120000 Lang/Pure/Repeat-a-string create mode 120000 Lang/Pure/Run-length-encoding create mode 120000 Lang/PureBasic/Arbitrary-precision-integers--included- delete mode 120000 Lang/PureBasic/Arbitrary-precision-integers-included create mode 120000 Lang/PureBasic/Binary-digits create mode 120000 Lang/PureBasic/Brownian-tree create mode 120000 Lang/PureBasic/Catalan-numbers create mode 120000 Lang/PureBasic/Copy-a-string create mode 120000 Lang/PureBasic/Dragon-curve create mode 120000 Lang/PureBasic/Environment-variables create mode 120000 Lang/PureBasic/Execute-a-Markov-algorithm create mode 120000 Lang/PureBasic/Guess-the-number-With-feedback--player- delete mode 120000 Lang/PureBasic/Guess-the-number-With-feedback-player create mode 120000 Lang/PureBasic/N-queens-problem create mode 120000 Lang/PureBasic/Non-decimal-radices-Convert create mode 120000 Lang/PureBasic/Non-decimal-radices-Input create mode 120000 Lang/PureBasic/Non-decimal-radices-Output create mode 120000 Lang/PureBasic/Nth-root create mode 120000 Lang/PureBasic/Null-object create mode 120000 Lang/PureBasic/Number-names create mode 120000 Lang/PureBasic/Number-reversal-game create mode 120000 Lang/PureBasic/Numerical-integration create mode 120000 Lang/PureBasic/One-dimensional-cellular-automata create mode 120000 Lang/PureBasic/One-of-n-lines-in-a-file create mode 120000 Lang/PureBasic/OpenGL create mode 120000 Lang/PureBasic/Order-two-numerical-lists create mode 120000 Lang/PureBasic/Palindrome-detection create mode 120000 Lang/PureBasic/Pangram-checker create mode 120000 Lang/PureBasic/Parallel-calculations create mode 120000 Lang/PureBasic/Parametrized-SQL-statement create mode 120000 Lang/PureBasic/Pascals-triangle create mode 120000 Lang/PureBasic/Pascals-triangle-Puzzle create mode 120000 Lang/PureBasic/Percentage-difference-between-images create mode 120000 Lang/PureBasic/Perfect-numbers create mode 120000 Lang/PureBasic/Permutation-test create mode 120000 Lang/PureBasic/Permutations create mode 120000 Lang/PureBasic/Permutations-Derangements create mode 120000 Lang/PureBasic/Pick-random-element create mode 120000 Lang/PureBasic/Pinstripe-Display create mode 120000 Lang/PureBasic/Play-recorded-sounds create mode 120000 Lang/PureBasic/Playing-cards create mode 120000 Lang/PureBasic/Plot-coordinate-pairs create mode 120000 Lang/PureBasic/Pointers-and-references create mode 120000 Lang/PureBasic/Polymorphism create mode 120000 Lang/PureBasic/Power-set create mode 120000 Lang/PureBasic/Price-fraction create mode 120000 Lang/PureBasic/Primality-by-trial-division create mode 120000 Lang/PureBasic/Prime-decomposition create mode 120000 Lang/PureBasic/Priority-queue create mode 120000 Lang/PureBasic/Probabilistic-choice create mode 120000 Lang/PureBasic/Problem-of-Apollonius create mode 120000 Lang/PureBasic/Program-name create mode 120000 Lang/PureBasic/Program-termination create mode 120000 Lang/PureBasic/Pythagorean-triples create mode 120000 Lang/PureBasic/Quaternion-type create mode 120000 Lang/PureBasic/Queue-Definition create mode 120000 Lang/PureBasic/Queue-Usage create mode 120000 Lang/PureBasic/Random-number-generator--device- create mode 120000 Lang/PureBasic/Random-numbers create mode 120000 Lang/PureBasic/Range-expansion create mode 120000 Lang/PureBasic/Range-extraction create mode 120000 Lang/PureBasic/Rate-counter create mode 120000 Lang/PureBasic/Ray-casting-algorithm create mode 120000 Lang/PureBasic/Read-a-file-line-by-line create mode 120000 Lang/PureBasic/Read-a-specific-line-from-a-file create mode 120000 Lang/PureBasic/Read-entire-file create mode 120000 Lang/PureBasic/Real-constants-and-functions create mode 120000 Lang/PureBasic/Regular-expressions create mode 120000 Lang/PureBasic/Remove-duplicate-elements create mode 120000 Lang/PureBasic/Rename-a-file create mode 120000 Lang/PureBasic/Repeat-a-string create mode 120000 Lang/PureBasic/Return-multiple-values create mode 120000 Lang/PureBasic/Reverse-a-string create mode 120000 Lang/PureBasic/Rock-paper-scissors create mode 120000 Lang/PureBasic/Roman-numerals-Decode create mode 120000 Lang/PureBasic/Roman-numerals-Encode create mode 120000 Lang/PureBasic/Roots-of-a-function create mode 120000 Lang/PureBasic/Roots-of-unity create mode 120000 Lang/PureBasic/Rosetta-Code-Count-examples create mode 120000 Lang/PureBasic/Rosetta-Code-Fix-code-tags create mode 120000 Lang/PureBasic/Rosetta-Code-Rank-languages-by-popularity create mode 120000 Lang/PureBasic/Rot-13 create mode 120000 Lang/PureBasic/Run-length-encoding create mode 120000 Lang/PureBasic/SEDOLs create mode 120000 Lang/PureBasic/Scope-modifiers create mode 120000 Lang/PureBasic/Secure-temporary-file create mode 120000 Lang/PureBasic/Self-describing-numbers create mode 120000 Lang/PureBasic/Send-email create mode 120000 Lang/PureBasic/Sequence-of-non-squares create mode 120000 Lang/PureBasic/Set create mode 120000 Lang/Python/Arbitrary-precision-integers--included- delete mode 120000 Lang/Python/Arbitrary-precision-integers-included create mode 120000 Lang/Python/Binary-digits create mode 120000 Lang/Python/Brownian-tree create mode 120000 Lang/Python/Catalan-numbers create mode 120000 Lang/Python/Copy-a-string create mode 120000 Lang/Python/Dragon-curve create mode 120000 Lang/Python/Environment-variables create mode 120000 Lang/Python/Execute-a-Markov-algorithm create mode 120000 Lang/Python/Guess-the-number-With-feedback--player- delete mode 120000 Lang/Python/Guess-the-number-With-feedback-player create mode 120000 Lang/Python/N-queens-problem create mode 120000 Lang/Python/Named-parameters create mode 120000 Lang/Python/Nautical-bell create mode 120000 Lang/Python/Non-continuous-subsequences create mode 120000 Lang/Python/Non-decimal-radices-Convert create mode 120000 Lang/Python/Non-decimal-radices-Input create mode 120000 Lang/Python/Non-decimal-radices-Output create mode 120000 Lang/Python/Nth-root create mode 120000 Lang/Python/Null-object create mode 120000 Lang/Python/Number-reversal-game create mode 120000 Lang/Python/Numeric-error-propagation create mode 120000 Lang/Python/Numerical-integration create mode 120000 Lang/Python/Numerical-integration-Gauss-Legendre-Quadrature create mode 120000 Lang/Python/OLE-Automation create mode 120000 Lang/Python/Object-serialization create mode 120000 Lang/Python/One-dimensional-cellular-automata create mode 120000 Lang/Python/One-of-n-lines-in-a-file create mode 120000 Lang/Python/OpenGL create mode 120000 Lang/Python/Optional-parameters create mode 120000 Lang/Python/Order-two-numerical-lists create mode 120000 Lang/Python/Ordered-Partitions create mode 120000 Lang/Python/Palindrome-detection create mode 120000 Lang/Python/Pangram-checker create mode 120000 Lang/Python/Parallel-calculations create mode 120000 Lang/Python/Parametrized-SQL-statement create mode 120000 Lang/Python/Parsing-RPN-calculator-algorithm create mode 120000 Lang/Python/Parsing-RPN-to-infix-conversion create mode 120000 Lang/Python/Parsing-Shunting-yard-algorithm create mode 120000 Lang/Python/Partial-function-application create mode 120000 Lang/Python/Pascals-triangle create mode 120000 Lang/Python/Pascals-triangle-Puzzle create mode 120000 Lang/Python/Percentage-difference-between-images create mode 120000 Lang/Python/Perfect-numbers create mode 120000 Lang/Python/Permutation-test create mode 120000 Lang/Python/Permutations create mode 120000 Lang/Python/Permutations-Derangements create mode 120000 Lang/Python/Permutations-by-swapping create mode 120000 Lang/Python/Pick-random-element create mode 120000 Lang/Python/Pig-the-dice-game create mode 120000 Lang/Python/Pig-the-dice-game-Player create mode 120000 Lang/Python/Play-recorded-sounds create mode 120000 Lang/Python/Playing-cards create mode 120000 Lang/Python/Plot-coordinate-pairs create mode 120000 Lang/Python/Pointers-and-references create mode 120000 Lang/Python/Polymorphic-copy create mode 120000 Lang/Python/Polymorphism create mode 120000 Lang/Python/Polynomial-long-division create mode 120000 Lang/Python/Polynomial-regression create mode 120000 Lang/Python/Power-set create mode 120000 Lang/Python/Pragmatic-directives create mode 120000 Lang/Python/Price-fraction create mode 120000 Lang/Python/Primality-by-trial-division create mode 120000 Lang/Python/Prime-decomposition create mode 120000 Lang/Python/Priority-queue create mode 120000 Lang/Python/Probabilistic-choice create mode 120000 Lang/Python/Problem-of-Apollonius create mode 120000 Lang/Python/Program-name create mode 120000 Lang/Python/Program-termination create mode 120000 Lang/Python/Pythagorean-triples create mode 120000 Lang/Python/Quaternion-type create mode 120000 Lang/Python/Queue-Definition create mode 120000 Lang/Python/Queue-Usage create mode 120000 Lang/Python/RIPEMD-160 create mode 120000 Lang/Python/Random-number-generator--device- create mode 120000 Lang/Python/Random-numbers create mode 120000 Lang/Python/Range-expansion create mode 120000 Lang/Python/Range-extraction create mode 120000 Lang/Python/Rate-counter create mode 120000 Lang/Python/Ray-casting-algorithm create mode 120000 Lang/Python/Read-a-configuration-file create mode 120000 Lang/Python/Read-a-file-line-by-line create mode 120000 Lang/Python/Read-a-specific-line-from-a-file create mode 120000 Lang/Python/Read-entire-file create mode 120000 Lang/Python/Real-constants-and-functions create mode 120000 Lang/Python/Record-sound create mode 120000 Lang/Python/Reduced-row-echelon-form create mode 120000 Lang/Python/Regular-expressions create mode 120000 Lang/Python/Remove-duplicate-elements create mode 120000 Lang/Python/Remove-lines-from-a-file create mode 120000 Lang/Python/Rename-a-file create mode 120000 Lang/Python/Repeat-a-string create mode 120000 Lang/Python/Resistor-mesh create mode 120000 Lang/Python/Respond-to-an-unknown-method-call create mode 120000 Lang/Python/Return-multiple-values create mode 120000 Lang/Python/Reverse-a-string create mode 120000 Lang/Python/Rock-paper-scissors create mode 120000 Lang/Python/Roman-numerals-Decode create mode 120000 Lang/Python/Roman-numerals-Encode create mode 120000 Lang/Python/Roots-of-a-function create mode 120000 Lang/Python/Roots-of-a-quadratic-function create mode 120000 Lang/Python/Roots-of-unity create mode 120000 Lang/Python/Rosetta-Code-Count-examples create mode 120000 Lang/Python/Rosetta-Code-Fix-code-tags create mode 120000 Lang/Python/Rosetta-Code-Rank-languages-by-popularity create mode 120000 Lang/Python/Rot-13 create mode 120000 Lang/Python/Run-length-encoding create mode 120000 Lang/Python/Runtime-evaluation create mode 120000 Lang/Python/Runtime-evaluation-In-an-environment create mode 120000 Lang/Python/S-Expressions create mode 120000 Lang/Python/SEDOLs create mode 120000 Lang/Python/Safe-addition create mode 120000 Lang/Python/Same-Fringe create mode 120000 Lang/Python/Scope-modifiers create mode 120000 Lang/Python/Secure-temporary-file create mode 120000 Lang/Python/Self-describing-numbers create mode 120000 Lang/Python/Self-referential-sequence create mode 120000 Lang/Python/Semordnilap create mode 120000 Lang/Python/Send-an-unknown-method-call create mode 120000 Lang/Python/Send-email create mode 120000 Lang/Python/Sequence-of-non-squares create mode 120000 Lang/Python/Set create mode 120000 Lang/Python/Set-consolidation create mode 120000 Lang/Python/Set-of-real-numbers create mode 120000 Lang/Qi/Pascals-triangle create mode 120000 Lang/Qi/Permutations create mode 120000 Lang/Qi/Power-set create mode 120000 Lang/Qi/Primality-by-trial-division create mode 120000 Lang/Qi/Range-extraction create mode 120000 Lang/Qi/Remove-duplicate-elements create mode 120000 Lang/Qi/Reverse-a-string create mode 120000 Lang/Qi/Send-an-unknown-method-call create mode 120000 Lang/R/Arbitrary-precision-integers--included- delete mode 120000 Lang/R/Arbitrary-precision-integers-included create mode 120000 Lang/R/Catalan-numbers create mode 120000 Lang/R/Copy-a-string create mode 120000 Lang/R/Environment-variables create mode 120000 Lang/R/N-queens-problem create mode 120000 Lang/R/Named-parameters create mode 120000 Lang/R/Non-continuous-subsequences create mode 120000 Lang/R/Non-decimal-radices-Input create mode 120000 Lang/R/Non-decimal-radices-Output create mode 120000 Lang/R/Nth-root create mode 120000 Lang/R/Null-object create mode 120000 Lang/R/Number-reversal-game create mode 120000 Lang/R/Numerical-integration create mode 120000 Lang/R/One-dimensional-cellular-automata create mode 120000 Lang/R/OpenGL create mode 120000 Lang/R/Optional-parameters create mode 120000 Lang/R/Palindrome-detection create mode 120000 Lang/R/Pangram-checker create mode 120000 Lang/R/Partial-function-application create mode 120000 Lang/R/Pascals-triangle create mode 120000 Lang/R/Perfect-numbers create mode 120000 Lang/R/Permutation-test create mode 120000 Lang/R/Permutations create mode 120000 Lang/R/Pick-random-element create mode 120000 Lang/R/Play-recorded-sounds create mode 120000 Lang/R/Playing-cards create mode 120000 Lang/R/Plot-coordinate-pairs create mode 120000 Lang/R/Polymorphism create mode 120000 Lang/R/Polynomial-long-division create mode 120000 Lang/R/Polynomial-regression create mode 120000 Lang/R/Power-set create mode 120000 Lang/R/Price-fraction create mode 120000 Lang/R/Primality-by-trial-division create mode 120000 Lang/R/Prime-decomposition create mode 120000 Lang/R/Priority-queue create mode 120000 Lang/R/Probabilistic-choice create mode 120000 Lang/R/Program-name create mode 120000 Lang/R/Program-termination create mode 120000 Lang/R/QR-decomposition create mode 120000 Lang/R/Quaternion-type create mode 120000 Lang/R/Queue-Definition create mode 120000 Lang/R/Random-number-generator--included- create mode 120000 Lang/R/Random-numbers create mode 120000 Lang/R/Range-expansion create mode 120000 Lang/R/Ray-casting-algorithm create mode 120000 Lang/R/Read-a-file-line-by-line create mode 120000 Lang/R/Read-a-specific-line-from-a-file create mode 120000 Lang/R/Read-entire-file create mode 120000 Lang/R/Real-constants-and-functions create mode 120000 Lang/R/Reduced-row-echelon-form create mode 120000 Lang/R/Regular-expressions create mode 120000 Lang/R/Rename-a-file create mode 120000 Lang/R/Repeat-a-string create mode 120000 Lang/R/Return-multiple-values create mode 120000 Lang/R/Reverse-a-string create mode 120000 Lang/R/Roman-numerals-Encode create mode 120000 Lang/R/Roots-of-a-function create mode 120000 Lang/R/Roots-of-a-quadratic-function create mode 120000 Lang/R/Roots-of-unity create mode 120000 Lang/R/Rosetta-Code-Count-examples create mode 120000 Lang/R/Rosetta-Code-Find-unimplemented-tasks create mode 120000 Lang/R/Rosetta-Code-Fix-code-tags create mode 120000 Lang/R/Rosetta-Code-Rank-languages-by-popularity create mode 120000 Lang/R/Rot-13 create mode 120000 Lang/R/Run-length-encoding create mode 120000 Lang/R/Runtime-evaluation create mode 120000 Lang/R/Runtime-evaluation-In-an-environment create mode 120000 Lang/R/SEDOLs create mode 120000 Lang/R/Scope-modifiers create mode 120000 Lang/R/Sequence-of-non-squares create mode 120000 Lang/REALbasic/Read-entire-file create mode 120000 Lang/REALbasic/Rename-a-file create mode 120000 Lang/REALbasic/Repeat-a-string create mode 120000 Lang/REBOL/Copy-a-string create mode 120000 Lang/REBOL/Environment-variables create mode 120000 Lang/REBOL/Null-object create mode 120000 Lang/REBOL/Palindrome-detection create mode 120000 Lang/REBOL/Percentage-difference-between-images create mode 120000 Lang/REBOL/Perfect-numbers create mode 120000 Lang/REBOL/Primality-by-trial-division create mode 120000 Lang/REBOL/Program-termination create mode 120000 Lang/REBOL/Queue-Definition create mode 120000 Lang/REBOL/Queue-Usage create mode 120000 Lang/REBOL/Read-entire-file create mode 120000 Lang/REBOL/Regular-expressions create mode 120000 Lang/REBOL/Remove-duplicate-elements create mode 120000 Lang/REBOL/Rename-a-file create mode 120000 Lang/REBOL/Repeat-a-string create mode 120000 Lang/REBOL/Reverse-a-string create mode 120000 Lang/REBOL/Rot-13 create mode 120000 Lang/REBOL/Runtime-evaluation-In-an-environment create mode 120000 Lang/REBOL/Send-email create mode 120000 Lang/REXX/Arbitrary-precision-integers--included- delete mode 120000 Lang/REXX/Arbitrary-precision-integers-included create mode 120000 Lang/REXX/Binary-digits create mode 120000 Lang/REXX/Brownian-tree create mode 120000 Lang/REXX/Calendar---for-real-programmers delete mode 120000 Lang/REXX/Calendar-for-real-programmers create mode 120000 Lang/REXX/Catalan-numbers create mode 120000 Lang/REXX/Copy-a-string create mode 120000 Lang/REXX/Dragon-curve create mode 120000 Lang/REXX/Environment-variables create mode 120000 Lang/REXX/Execute-a-Markov-algorithm create mode 120000 Lang/REXX/Guess-the-number-With-feedback--player- delete mode 120000 Lang/REXX/Guess-the-number-With-feedback-player create mode 120000 Lang/REXX/N-queens-problem create mode 120000 Lang/REXX/Named-parameters create mode 120000 Lang/REXX/Nautical-bell create mode 120000 Lang/REXX/Non-continuous-subsequences create mode 120000 Lang/REXX/Non-decimal-radices-Convert create mode 120000 Lang/REXX/Non-decimal-radices-Input create mode 120000 Lang/REXX/Non-decimal-radices-Output create mode 120000 Lang/REXX/Nth-root create mode 120000 Lang/REXX/Null-object create mode 120000 Lang/REXX/Number-reversal-game create mode 120000 Lang/REXX/Numerical-integration create mode 120000 Lang/REXX/One-of-n-lines-in-a-file create mode 120000 Lang/REXX/Operator-precedence create mode 120000 Lang/REXX/Palindrome-detection create mode 120000 Lang/REXX/Pangram-checker create mode 120000 Lang/REXX/Parsing-RPN-calculator-algorithm create mode 120000 Lang/REXX/Parsing-RPN-to-infix-conversion create mode 120000 Lang/REXX/Parsing-Shunting-yard-algorithm create mode 120000 Lang/REXX/Pascals-triangle create mode 120000 Lang/REXX/Pascals-triangle-Puzzle create mode 120000 Lang/REXX/Perfect-numbers create mode 120000 Lang/REXX/Permutation-test create mode 120000 Lang/REXX/Permutations create mode 120000 Lang/REXX/Permutations-Derangements create mode 120000 Lang/REXX/Pick-random-element create mode 120000 Lang/REXX/Pig-the-dice-game create mode 120000 Lang/REXX/Pig-the-dice-game-Player create mode 120000 Lang/REXX/Playing-cards create mode 120000 Lang/REXX/Power-set create mode 120000 Lang/REXX/Price-fraction create mode 120000 Lang/REXX/Primality-by-trial-division create mode 120000 Lang/REXX/Prime-decomposition create mode 120000 Lang/REXX/Probabilistic-choice create mode 120000 Lang/REXX/Problem-of-Apollonius create mode 120000 Lang/REXX/Program-name create mode 120000 Lang/REXX/Program-termination create mode 120000 Lang/REXX/Pythagorean-triples create mode 120000 Lang/REXX/Quaternion-type create mode 120000 Lang/REXX/Queue-Definition create mode 120000 Lang/REXX/Queue-Usage create mode 120000 Lang/REXX/Random-number-generator--device- create mode 120000 Lang/REXX/Random-numbers create mode 120000 Lang/REXX/Range-expansion create mode 120000 Lang/REXX/Range-extraction create mode 120000 Lang/REXX/Rate-counter create mode 120000 Lang/REXX/Ray-casting-algorithm create mode 120000 Lang/REXX/Read-a-configuration-file create mode 120000 Lang/REXX/Read-a-file-line-by-line create mode 120000 Lang/REXX/Read-a-specific-line-from-a-file create mode 120000 Lang/REXX/Read-entire-file create mode 120000 Lang/REXX/Real-constants-and-functions create mode 120000 Lang/REXX/Reduced-row-echelon-form create mode 120000 Lang/REXX/Regular-expressions create mode 120000 Lang/REXX/Remove-duplicate-elements create mode 120000 Lang/REXX/Remove-lines-from-a-file create mode 120000 Lang/REXX/Rename-a-file create mode 120000 Lang/REXX/Repeat-a-string create mode 120000 Lang/REXX/Resistor-mesh create mode 120000 Lang/REXX/Return-multiple-values create mode 120000 Lang/REXX/Reverse-a-string create mode 120000 Lang/REXX/Roman-numerals-Decode create mode 120000 Lang/REXX/Roman-numerals-Encode create mode 120000 Lang/REXX/Roots-of-a-function create mode 120000 Lang/REXX/Roots-of-a-quadratic-function create mode 120000 Lang/REXX/Roots-of-unity create mode 120000 Lang/REXX/Rosetta-Code-Fix-code-tags create mode 120000 Lang/REXX/Rosetta-Code-Rank-languages-by-popularity create mode 120000 Lang/REXX/Rot-13 create mode 120000 Lang/REXX/Run-length-encoding create mode 120000 Lang/REXX/Runtime-evaluation create mode 120000 Lang/REXX/Runtime-evaluation-In-an-environment create mode 120000 Lang/REXX/S-Expressions create mode 120000 Lang/REXX/SEDOLs create mode 120000 Lang/REXX/Safe-addition create mode 120000 Lang/REXX/Same-Fringe create mode 120000 Lang/REXX/Scope-Function-names-and-labels create mode 120000 Lang/REXX/Scope-modifiers create mode 120000 Lang/REXX/Self-describing-numbers create mode 120000 Lang/REXX/Self-referential-sequence create mode 120000 Lang/REXX/Semordnilap create mode 120000 Lang/REXX/Sequence-of-non-squares create mode 120000 Lang/REXX/Set create mode 120000 Lang/REXX/Set-consolidation create mode 120000 Lang/REXX/Set-of-real-numbers create mode 120000 Lang/RLaB/Copy-a-string create mode 120000 Lang/RLaB/Real-constants-and-functions create mode 120000 Lang/RLaB/Reverse-a-string create mode 120000 Lang/RLaB/Roots-of-a-function create mode 120000 Lang/RLaB/Roots-of-unity create mode 120000 Lang/Racket/Arbitrary-precision-integers--included- delete mode 120000 Lang/Racket/Arbitrary-precision-integers-included create mode 120000 Lang/Racket/Binary-digits create mode 120000 Lang/Racket/Catalan-numbers create mode 120000 Lang/Racket/Dragon-curve create mode 120000 Lang/Racket/Environment-variables create mode 120000 Lang/Racket/Named-parameters create mode 120000 Lang/Racket/OpenGL create mode 120000 Lang/Racket/Optional-parameters create mode 120000 Lang/Racket/Palindrome-detection create mode 120000 Lang/Racket/Parametric-polymorphism create mode 120000 Lang/Racket/Partial-function-application create mode 120000 Lang/Racket/Pascals-triangle create mode 120000 Lang/Racket/Pattern-matching create mode 120000 Lang/Racket/Playing-cards create mode 120000 Lang/Racket/Power-set create mode 120000 Lang/Racket/Program-name create mode 120000 Lang/Racket/Range-expansion create mode 120000 Lang/Racket/Ray-casting-algorithm create mode 120000 Lang/Racket/Read-a-file-line-by-line create mode 120000 Lang/Racket/Read-entire-file create mode 120000 Lang/Racket/Real-constants-and-functions create mode 120000 Lang/Racket/Reduced-row-echelon-form create mode 120000 Lang/Racket/Regular-expressions create mode 120000 Lang/Racket/Rename-a-file create mode 120000 Lang/Racket/Repeat-a-string create mode 120000 Lang/Racket/Reverse-a-string create mode 120000 Lang/Racket/Roots-of-unity create mode 120000 Lang/Racket/Rosetta-Code-Rank-languages-by-popularity create mode 120000 Lang/Racket/Rot-13 create mode 120000 Lang/Racket/S-Expressions create mode 120000 Lang/Racket/SEDOLs create mode 120000 Lang/Racket/Same-Fringe create mode 120000 Lang/Racket/Secure-temporary-file create mode 120000 Lang/Racket/Send-email create mode 120000 Lang/Racket/Sequence-of-non-squares create mode 120000 Lang/Racket/Set create mode 120000 Lang/RapidQ/Dragon-curve create mode 120000 Lang/RapidQ/Pascals-triangle create mode 120000 Lang/Rascal/N-queens-problem create mode 120000 Lang/Rascal/Number-reversal-game create mode 120000 Lang/Rascal/Order-two-numerical-lists create mode 120000 Lang/Rascal/Palindrome-detection create mode 120000 Lang/Rascal/Pattern-matching create mode 120000 Lang/Rascal/Power-set create mode 120000 Lang/Rascal/QR-decomposition create mode 120000 Lang/Rascal/Random-number-generator--included- create mode 120000 Lang/Rascal/Reverse-a-string create mode 120000 Lang/Rascal/Rock-paper-scissors create mode 120000 Lang/Raven/Copy-a-string create mode 120000 Lang/Raven/Regular-expressions create mode 120000 Lang/Raven/Remove-duplicate-elements create mode 120000 Lang/Retro/Binary-digits create mode 120000 Lang/Retro/Copy-a-string create mode 120000 Lang/Retro/Environment-variables create mode 120000 Lang/Retro/One-dimensional-cellular-automata create mode 120000 Lang/Retro/Palindrome-detection create mode 120000 Lang/Retro/Pangram-checker create mode 120000 Lang/Retro/Pascals-triangle create mode 120000 Lang/Retro/Program-termination create mode 120000 Lang/Retro/Read-entire-file create mode 120000 Lang/Retro/Repeat-a-string create mode 120000 Lang/Retro/Return-multiple-values create mode 120000 Lang/Retro/Reverse-a-string create mode 120000 Lang/Retro/Roman-numerals-Encode create mode 120000 Lang/Retro/Rot-13 create mode 120000 Lang/Ruby/Arbitrary-precision-integers--included- delete mode 120000 Lang/Ruby/Arbitrary-precision-integers-included create mode 120000 Lang/Ruby/Binary-digits create mode 120000 Lang/Ruby/Brownian-tree create mode 120000 Lang/Ruby/Calendar---for-real-programmers delete mode 120000 Lang/Ruby/Calendar-for-real-programmers create mode 120000 Lang/Ruby/Catalan-numbers delete mode 120000 Lang/Ruby/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N create mode 120000 Lang/Ruby/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N- create mode 120000 Lang/Ruby/Copy-a-string create mode 120000 Lang/Ruby/Dragon-curve create mode 120000 Lang/Ruby/Environment-variables create mode 120000 Lang/Ruby/Execute-a-Markov-algorithm create mode 120000 Lang/Ruby/Guess-the-number-With-feedback--player- delete mode 120000 Lang/Ruby/Guess-the-number-With-feedback-player create mode 120000 Lang/Ruby/N-queens-problem create mode 120000 Lang/Ruby/Named-parameters create mode 120000 Lang/Ruby/Non-continuous-subsequences create mode 120000 Lang/Ruby/Non-decimal-radices-Convert create mode 120000 Lang/Ruby/Non-decimal-radices-Input create mode 120000 Lang/Ruby/Non-decimal-radices-Output create mode 120000 Lang/Ruby/Nth-root create mode 120000 Lang/Ruby/Null-object create mode 120000 Lang/Ruby/Number-names create mode 120000 Lang/Ruby/Number-reversal-game create mode 120000 Lang/Ruby/Numeric-error-propagation create mode 120000 Lang/Ruby/Numerical-integration create mode 120000 Lang/Ruby/Object-serialization create mode 120000 Lang/Ruby/One-dimensional-cellular-automata create mode 120000 Lang/Ruby/One-of-n-lines-in-a-file create mode 120000 Lang/Ruby/OpenGL create mode 120000 Lang/Ruby/Optional-parameters create mode 120000 Lang/Ruby/Order-two-numerical-lists create mode 120000 Lang/Ruby/Palindrome-detection create mode 120000 Lang/Ruby/Pangram-checker create mode 120000 Lang/Ruby/Parametrized-SQL-statement create mode 120000 Lang/Ruby/Parsing-RPN-calculator-algorithm create mode 120000 Lang/Ruby/Parsing-RPN-to-infix-conversion create mode 120000 Lang/Ruby/Parsing-Shunting-yard-algorithm create mode 120000 Lang/Ruby/Partial-function-application create mode 120000 Lang/Ruby/Pascals-triangle create mode 120000 Lang/Ruby/Pascals-triangle-Puzzle create mode 120000 Lang/Ruby/Percentage-difference-between-images create mode 120000 Lang/Ruby/Perfect-numbers create mode 120000 Lang/Ruby/Permutations create mode 120000 Lang/Ruby/Permutations-Derangements create mode 120000 Lang/Ruby/Pick-random-element create mode 120000 Lang/Ruby/Pig-the-dice-game create mode 120000 Lang/Ruby/Play-recorded-sounds create mode 120000 Lang/Ruby/Playing-cards create mode 120000 Lang/Ruby/Plot-coordinate-pairs create mode 120000 Lang/Ruby/Polymorphic-copy create mode 120000 Lang/Ruby/Polymorphism create mode 120000 Lang/Ruby/Polynomial-long-division create mode 120000 Lang/Ruby/Polynomial-regression create mode 120000 Lang/Ruby/Power-set create mode 120000 Lang/Ruby/Price-fraction create mode 120000 Lang/Ruby/Primality-by-trial-division create mode 120000 Lang/Ruby/Prime-decomposition create mode 120000 Lang/Ruby/Priority-queue create mode 120000 Lang/Ruby/Probabilistic-choice create mode 120000 Lang/Ruby/Problem-of-Apollonius create mode 120000 Lang/Ruby/Program-name create mode 120000 Lang/Ruby/Program-termination create mode 120000 Lang/Ruby/Pythagorean-triples create mode 120000 Lang/Ruby/Quaternion-type create mode 120000 Lang/Ruby/Queue-Definition create mode 120000 Lang/Ruby/RIPEMD-160 create mode 120000 Lang/Ruby/Random-number-generator--device- create mode 120000 Lang/Ruby/Random-numbers create mode 120000 Lang/Ruby/Range-expansion create mode 120000 Lang/Ruby/Range-extraction create mode 120000 Lang/Ruby/Read-a-configuration-file create mode 120000 Lang/Ruby/Read-a-file-line-by-line create mode 120000 Lang/Ruby/Read-a-specific-line-from-a-file create mode 120000 Lang/Ruby/Read-entire-file create mode 120000 Lang/Ruby/Real-constants-and-functions create mode 120000 Lang/Ruby/Reduced-row-echelon-form create mode 120000 Lang/Ruby/Regular-expressions create mode 120000 Lang/Ruby/Remove-duplicate-elements create mode 120000 Lang/Ruby/Remove-lines-from-a-file create mode 120000 Lang/Ruby/Rename-a-file create mode 120000 Lang/Ruby/Repeat-a-string create mode 120000 Lang/Ruby/Respond-to-an-unknown-method-call create mode 120000 Lang/Ruby/Return-multiple-values create mode 120000 Lang/Ruby/Reverse-a-string create mode 120000 Lang/Ruby/Rock-paper-scissors create mode 120000 Lang/Ruby/Roman-numerals-Decode create mode 120000 Lang/Ruby/Roman-numerals-Encode create mode 120000 Lang/Ruby/Roots-of-a-function create mode 120000 Lang/Ruby/Roots-of-a-quadratic-function create mode 120000 Lang/Ruby/Roots-of-unity create mode 120000 Lang/Ruby/Rosetta-Code-Count-examples create mode 120000 Lang/Ruby/Rosetta-Code-Find-unimplemented-tasks create mode 120000 Lang/Ruby/Rosetta-Code-Fix-code-tags create mode 120000 Lang/Ruby/Rosetta-Code-Rank-languages-by-popularity create mode 120000 Lang/Ruby/Rot-13 create mode 120000 Lang/Ruby/Run-length-encoding create mode 120000 Lang/Ruby/Runtime-evaluation create mode 120000 Lang/Ruby/Runtime-evaluation-In-an-environment create mode 120000 Lang/Ruby/S-Expressions create mode 120000 Lang/Ruby/SEDOLs create mode 120000 Lang/Ruby/Safe-addition create mode 120000 Lang/Ruby/Secure-temporary-file create mode 120000 Lang/Ruby/Self-describing-numbers create mode 120000 Lang/Ruby/Self-referential-sequence create mode 120000 Lang/Ruby/Semordnilap create mode 120000 Lang/Ruby/Send-an-unknown-method-call create mode 120000 Lang/Ruby/Send-email create mode 120000 Lang/Ruby/Sequence-of-non-squares create mode 120000 Lang/Ruby/Set create mode 120000 Lang/Run-BASIC/Arbitrary-precision-integers--included- delete mode 120000 Lang/Run-BASIC/Arbitrary-precision-integers-included create mode 120000 Lang/Run-BASIC/Binary-digits create mode 120000 Lang/Run-BASIC/Brownian-tree create mode 120000 Lang/Run-BASIC/Catalan-numbers create mode 120000 Lang/Run-BASIC/Copy-a-string create mode 120000 Lang/Run-BASIC/Dragon-curve create mode 120000 Lang/Run-BASIC/Environment-variables create mode 120000 Lang/Run-BASIC/Non-decimal-radices-Convert create mode 120000 Lang/Run-BASIC/Nth-root create mode 120000 Lang/Run-BASIC/Number-reversal-game create mode 120000 Lang/Run-BASIC/One-of-n-lines-in-a-file create mode 120000 Lang/Run-BASIC/Palindrome-detection create mode 120000 Lang/Run-BASIC/Pangram-checker create mode 120000 Lang/Run-BASIC/Parsing-RPN-calculator-algorithm create mode 120000 Lang/Run-BASIC/Pascals-triangle create mode 120000 Lang/Run-BASIC/Perfect-numbers create mode 120000 Lang/Run-BASIC/Permutations create mode 120000 Lang/Run-BASIC/Pick-random-element create mode 120000 Lang/Run-BASIC/Pig-the-dice-game create mode 120000 Lang/Run-BASIC/Playing-cards create mode 120000 Lang/Run-BASIC/Price-fraction create mode 120000 Lang/Run-BASIC/Primality-by-trial-division create mode 120000 Lang/Run-BASIC/Priority-queue create mode 120000 Lang/Run-BASIC/Random-number-generator--included- create mode 120000 Lang/Run-BASIC/Random-numbers create mode 120000 Lang/Run-BASIC/Range-expansion create mode 120000 Lang/Run-BASIC/Rate-counter create mode 120000 Lang/Run-BASIC/Read-a-file-line-by-line create mode 120000 Lang/Run-BASIC/Read-a-specific-line-from-a-file create mode 120000 Lang/Run-BASIC/Real-constants-and-functions create mode 120000 Lang/Run-BASIC/Regular-expressions create mode 120000 Lang/Run-BASIC/Remove-lines-from-a-file create mode 120000 Lang/Run-BASIC/Rename-a-file create mode 120000 Lang/Run-BASIC/Repeat-a-string create mode 120000 Lang/Run-BASIC/Return-multiple-values create mode 120000 Lang/Run-BASIC/Reverse-a-string create mode 120000 Lang/Run-BASIC/Rock-paper-scissors create mode 120000 Lang/Run-BASIC/Roman-numerals-Decode create mode 120000 Lang/Run-BASIC/Roman-numerals-Encode create mode 120000 Lang/Run-BASIC/Roots-of-a-quadratic-function create mode 120000 Lang/Run-BASIC/Rosetta-Code-Count-examples create mode 120000 Lang/Run-BASIC/Rosetta-Code-Find-unimplemented-tasks create mode 120000 Lang/Run-BASIC/Rosetta-Code-Rank-languages-by-popularity create mode 120000 Lang/Run-BASIC/Rot-13 create mode 120000 Lang/Run-BASIC/Run-length-encoding create mode 120000 Lang/Run-BASIC/Self-describing-numbers create mode 120000 Lang/Rust/Program-name create mode 120000 Lang/SAS/N-queens-problem create mode 120000 Lang/SAS/Permutations create mode 120000 Lang/SAS/Pointers-and-references create mode 120000 Lang/SAS/Primality-by-trial-division create mode 120000 Lang/SAS/QR-decomposition create mode 120000 Lang/SAS/Reverse-a-string create mode 120000 Lang/SAS/Send-email create mode 120000 Lang/SETL/Remove-duplicate-elements create mode 120000 Lang/SIMPOL/Arbitrary-precision-integers--included- delete mode 120000 Lang/SIMPOL/Arbitrary-precision-integers-included create mode 120000 Lang/SIMPOL/Polymorphism create mode 120000 Lang/SNOBOL4/Copy-a-string create mode 120000 Lang/SNOBOL4/Environment-variables create mode 120000 Lang/SNOBOL4/N-queens-problem create mode 120000 Lang/SNOBOL4/Palindrome-detection create mode 120000 Lang/SNOBOL4/Pangram-checker create mode 120000 Lang/SNOBOL4/Primality-by-trial-division create mode 120000 Lang/SNOBOL4/Program-termination create mode 120000 Lang/SNOBOL4/Range-expansion create mode 120000 Lang/SNOBOL4/Range-extraction create mode 120000 Lang/SNOBOL4/Read-a-file-line-by-line create mode 120000 Lang/SNOBOL4/Read-entire-file create mode 120000 Lang/SNOBOL4/Regular-expressions create mode 120000 Lang/SNOBOL4/Repeat-a-string create mode 120000 Lang/SNOBOL4/Reverse-a-string create mode 120000 Lang/SNOBOL4/Roman-numerals-Decode create mode 120000 Lang/SNOBOL4/Roman-numerals-Encode create mode 120000 Lang/SNOBOL4/Rot-13 create mode 120000 Lang/SNOBOL4/Run-length-encoding create mode 120000 Lang/SNOBOL4/Runtime-evaluation create mode 120000 Lang/SNOBOL4/Runtime-evaluation-In-an-environment create mode 120000 Lang/SQL/Repeat-a-string create mode 120000 Lang/SQL/Roman-numerals-Encode create mode 120000 Lang/Sage/Reduced-row-echelon-form create mode 120000 Lang/Sather/Arbitrary-precision-integers--included- delete mode 120000 Lang/Sather/Arbitrary-precision-integers-included create mode 120000 Lang/Sather/Copy-a-string create mode 120000 Lang/Sather/Nth-root create mode 120000 Lang/Sather/Random-numbers create mode 120000 Lang/Sather/Regular-expressions create mode 120000 Lang/Sather/Reverse-a-string create mode 120000 Lang/Scala/Arbitrary-precision-integers--included- delete mode 120000 Lang/Scala/Arbitrary-precision-integers-included create mode 120000 Lang/Scala/Binary-digits create mode 120000 Lang/Scala/Catalan-numbers create mode 120000 Lang/Scala/Copy-a-string create mode 120000 Lang/Scala/Execute-a-Markov-algorithm create mode 120000 Lang/Scala/N-queens-problem create mode 120000 Lang/Scala/Named-parameters create mode 120000 Lang/Scala/Nth-root create mode 120000 Lang/Scala/Null-object create mode 120000 Lang/Scala/Numerical-integration create mode 120000 Lang/Scala/One-dimensional-cellular-automata create mode 120000 Lang/Scala/Optional-parameters create mode 120000 Lang/Scala/Palindrome-detection create mode 120000 Lang/Scala/Pangram-checker create mode 120000 Lang/Scala/Parametric-polymorphism create mode 120000 Lang/Scala/Partial-function-application create mode 120000 Lang/Scala/Pascals-triangle create mode 120000 Lang/Scala/Pattern-matching create mode 120000 Lang/Scala/Perfect-numbers create mode 120000 Lang/Scala/Permutations create mode 120000 Lang/Scala/Plot-coordinate-pairs create mode 120000 Lang/Scala/Power-set create mode 120000 Lang/Scala/Price-fraction create mode 120000 Lang/Scala/Primality-by-trial-division create mode 120000 Lang/Scala/Prime-decomposition create mode 120000 Lang/Scala/Priority-queue create mode 120000 Lang/Scala/Problem-of-Apollonius create mode 120000 Lang/Scala/Program-name create mode 120000 Lang/Scala/Quaternion-type create mode 120000 Lang/Scala/Queue-Definition create mode 120000 Lang/Scala/Queue-Usage create mode 120000 Lang/Scala/Random-numbers create mode 120000 Lang/Scala/Range-expansion create mode 120000 Lang/Scala/Range-extraction create mode 120000 Lang/Scala/Rate-counter create mode 120000 Lang/Scala/Read-a-file-line-by-line create mode 120000 Lang/Scala/Read-a-specific-line-from-a-file create mode 120000 Lang/Scala/Regular-expressions create mode 120000 Lang/Scala/Remove-duplicate-elements create mode 120000 Lang/Scala/Rename-a-file create mode 120000 Lang/Scala/Repeat-a-string create mode 120000 Lang/Scala/Respond-to-an-unknown-method-call create mode 120000 Lang/Scala/Return-multiple-values create mode 120000 Lang/Scala/Reverse-a-string create mode 120000 Lang/Scala/Roman-numerals-Decode create mode 120000 Lang/Scala/Roman-numerals-Encode create mode 120000 Lang/Scala/Roots-of-a-quadratic-function create mode 120000 Lang/Scala/Roots-of-unity create mode 120000 Lang/Scala/Rosetta-Code-Count-examples create mode 120000 Lang/Scala/Rosetta-Code-Rank-languages-by-popularity create mode 120000 Lang/Scala/Rot-13 create mode 120000 Lang/Scala/Run-length-encoding create mode 120000 Lang/Scala/SEDOLs create mode 120000 Lang/Scala/Secure-temporary-file create mode 120000 Lang/Scala/Sequence-of-non-squares create mode 120000 Lang/Scala/Set create mode 120000 Lang/Scheme/Arbitrary-precision-integers--included- delete mode 120000 Lang/Scheme/Arbitrary-precision-integers-included create mode 120000 Lang/Scheme/Binary-digits create mode 120000 Lang/Scheme/Brownian-tree create mode 120000 Lang/Scheme/Catalan-numbers create mode 120000 Lang/Scheme/Copy-a-string create mode 120000 Lang/Scheme/Execute-a-Markov-algorithm create mode 120000 Lang/Scheme/Guess-the-number-With-feedback--player- delete mode 120000 Lang/Scheme/Guess-the-number-With-feedback-player create mode 120000 Lang/Scheme/Named-parameters create mode 120000 Lang/Scheme/Non-continuous-subsequences create mode 120000 Lang/Scheme/Non-decimal-radices-Input create mode 120000 Lang/Scheme/Non-decimal-radices-Output create mode 120000 Lang/Scheme/Nth-root create mode 120000 Lang/Scheme/Null-object create mode 120000 Lang/Scheme/Numerical-integration create mode 120000 Lang/Scheme/One-dimensional-cellular-automata create mode 120000 Lang/Scheme/Order-two-numerical-lists create mode 120000 Lang/Scheme/Palindrome-detection create mode 120000 Lang/Scheme/Pascals-triangle create mode 120000 Lang/Scheme/Perfect-numbers create mode 120000 Lang/Scheme/Permutations create mode 120000 Lang/Scheme/Playing-cards create mode 120000 Lang/Scheme/Power-set create mode 120000 Lang/Scheme/Primality-by-trial-division create mode 120000 Lang/Scheme/Prime-decomposition create mode 120000 Lang/Scheme/Program-name create mode 120000 Lang/Scheme/Program-termination create mode 120000 Lang/Scheme/Queue-Definition create mode 120000 Lang/Scheme/Random-numbers create mode 120000 Lang/Scheme/Range-expansion create mode 120000 Lang/Scheme/Range-extraction create mode 120000 Lang/Scheme/Read-a-file-line-by-line create mode 120000 Lang/Scheme/Real-constants-and-functions create mode 120000 Lang/Scheme/Reduced-row-echelon-form create mode 120000 Lang/Scheme/Remove-duplicate-elements create mode 120000 Lang/Scheme/Rename-a-file create mode 120000 Lang/Scheme/Repeat-a-string create mode 120000 Lang/Scheme/Return-multiple-values create mode 120000 Lang/Scheme/Reverse-a-string create mode 120000 Lang/Scheme/Roman-numerals-Encode create mode 120000 Lang/Scheme/Roots-of-a-quadratic-function create mode 120000 Lang/Scheme/Roots-of-unity create mode 120000 Lang/Scheme/Rot-13 create mode 120000 Lang/Scheme/Run-length-encoding create mode 120000 Lang/Scheme/Runtime-evaluation create mode 120000 Lang/Scheme/Runtime-evaluation-In-an-environment create mode 120000 Lang/Scheme/S-Expressions create mode 120000 Lang/Scheme/Sequence-of-non-squares create mode 120000 Lang/Scheme/Set create mode 120000 Lang/Sed/Read-a-file-line-by-line create mode 120000 Lang/Sed/Reverse-a-string create mode 120000 Lang/Seed7/Arbitrary-precision-integers--included- delete mode 120000 Lang/Seed7/Arbitrary-precision-integers-included create mode 120000 Lang/Seed7/Binary-digits create mode 120000 Lang/Seed7/Brownian-tree create mode 120000 Lang/Seed7/Copy-a-string create mode 120000 Lang/Seed7/Dragon-curve create mode 120000 Lang/Seed7/Environment-variables create mode 120000 Lang/Seed7/Non-decimal-radices-Output create mode 120000 Lang/Seed7/Nth-root create mode 120000 Lang/Seed7/Number-names create mode 120000 Lang/Seed7/One-dimensional-cellular-automata create mode 120000 Lang/Seed7/One-of-n-lines-in-a-file create mode 120000 Lang/Seed7/Palindrome-detection create mode 120000 Lang/Seed7/Pangram-checker create mode 120000 Lang/Seed7/Parametric-polymorphism create mode 120000 Lang/Seed7/Pascals-triangle create mode 120000 Lang/Seed7/Perfect-numbers create mode 120000 Lang/Seed7/Permutations create mode 120000 Lang/Seed7/Pick-random-element create mode 120000 Lang/Seed7/Power-set create mode 120000 Lang/Seed7/Price-fraction create mode 120000 Lang/Seed7/Primality-by-trial-division create mode 120000 Lang/Seed7/Prime-decomposition create mode 120000 Lang/Seed7/Probabilistic-choice create mode 120000 Lang/Seed7/Program-name create mode 120000 Lang/Seed7/Program-termination create mode 120000 Lang/Seed7/Pythagorean-triples create mode 120000 Lang/Seed7/Random-numbers create mode 120000 Lang/Seed7/Range-expansion create mode 120000 Lang/Seed7/Range-extraction create mode 120000 Lang/Seed7/Read-a-configuration-file create mode 120000 Lang/Seed7/Read-a-file-line-by-line create mode 120000 Lang/Seed7/Read-a-specific-line-from-a-file create mode 120000 Lang/Seed7/Reduced-row-echelon-form create mode 120000 Lang/Seed7/Remove-duplicate-elements create mode 120000 Lang/Seed7/Remove-lines-from-a-file create mode 120000 Lang/Seed7/Rename-a-file create mode 120000 Lang/Seed7/Repeat-a-string create mode 120000 Lang/Seed7/Return-multiple-values create mode 120000 Lang/Seed7/Reverse-a-string create mode 120000 Lang/Seed7/Roman-numerals-Decode create mode 120000 Lang/Seed7/Roman-numerals-Encode create mode 120000 Lang/Seed7/Roots-of-a-quadratic-function create mode 120000 Lang/Seed7/Roots-of-unity create mode 120000 Lang/Seed7/Rot-13 create mode 120000 Lang/Seed7/Run-length-encoding create mode 120000 Lang/Seed7/SEDOLs create mode 120000 Lang/Seed7/Self-describing-numbers create mode 120000 Lang/Seed7/Sequence-of-non-squares create mode 120000 Lang/Seed7/Set create mode 120000 Lang/Shiny/Copy-a-string create mode 120000 Lang/Shiny/Regular-expressions create mode 120000 Lang/Slate/Copy-a-string create mode 120000 Lang/Slate/Environment-variables create mode 120000 Lang/Slate/Non-decimal-radices-Convert create mode 120000 Lang/Slate/Null-object create mode 120000 Lang/Slate/Optional-parameters create mode 120000 Lang/Slate/Palindrome-detection create mode 120000 Lang/Slate/Perfect-numbers create mode 120000 Lang/Slate/Polymorphic-copy create mode 120000 Lang/Slate/Polynomial-long-division create mode 120000 Lang/Slate/Prime-decomposition create mode 120000 Lang/Slate/Program-termination create mode 120000 Lang/Slate/Queue-Definition create mode 120000 Lang/Slate/Real-constants-and-functions create mode 120000 Lang/Slate/Regular-expressions create mode 120000 Lang/Slate/Remove-duplicate-elements create mode 120000 Lang/Slate/Rename-a-file create mode 120000 Lang/Slate/Respond-to-an-unknown-method-call create mode 120000 Lang/Slate/Reverse-a-string create mode 120000 Lang/Slate/Rot-13 create mode 120000 Lang/Slate/Runtime-evaluation create mode 120000 Lang/Smalltalk/Arbitrary-precision-integers--included- delete mode 120000 Lang/Smalltalk/Arbitrary-precision-integers-included create mode 120000 Lang/Smalltalk/Binary-digits create mode 120000 Lang/Smalltalk/Copy-a-string create mode 120000 Lang/Smalltalk/Guess-the-number-With-feedback--player- delete mode 120000 Lang/Smalltalk/Guess-the-number-With-feedback-player create mode 120000 Lang/Smalltalk/Named-parameters create mode 120000 Lang/Smalltalk/Non-decimal-radices-Output create mode 120000 Lang/Smalltalk/Nth-root create mode 120000 Lang/Smalltalk/Null-object create mode 120000 Lang/Smalltalk/Palindrome-detection create mode 120000 Lang/Smalltalk/Pangram-checker create mode 120000 Lang/Smalltalk/Partial-function-application create mode 120000 Lang/Smalltalk/Perfect-numbers create mode 120000 Lang/Smalltalk/Permutations create mode 120000 Lang/Smalltalk/Pick-random-element create mode 120000 Lang/Smalltalk/Playing-cards create mode 120000 Lang/Smalltalk/Polymorphism create mode 120000 Lang/Smalltalk/Polynomial-long-division create mode 120000 Lang/Smalltalk/Power-set create mode 120000 Lang/Smalltalk/Price-fraction create mode 120000 Lang/Smalltalk/Prime-decomposition create mode 120000 Lang/Smalltalk/Program-name create mode 120000 Lang/Smalltalk/Queue-Definition create mode 120000 Lang/Smalltalk/Rate-counter create mode 120000 Lang/Smalltalk/Ray-casting-algorithm create mode 120000 Lang/Smalltalk/Read-a-configuration-file create mode 120000 Lang/Smalltalk/Read-a-file-line-by-line create mode 120000 Lang/Smalltalk/Read-entire-file create mode 120000 Lang/Smalltalk/Real-constants-and-functions create mode 120000 Lang/Smalltalk/Regular-expressions create mode 120000 Lang/Smalltalk/Remove-duplicate-elements create mode 120000 Lang/Smalltalk/Rename-a-file create mode 120000 Lang/Smalltalk/Repeat-a-string create mode 120000 Lang/Smalltalk/Respond-to-an-unknown-method-call create mode 120000 Lang/Smalltalk/Reverse-a-string create mode 120000 Lang/Smalltalk/Roman-numerals-Encode create mode 120000 Lang/Smalltalk/Rot-13 create mode 120000 Lang/Smalltalk/Runtime-evaluation create mode 120000 Lang/Smalltalk/SEDOLs create mode 120000 Lang/Smalltalk/Send-an-unknown-method-call create mode 120000 Lang/Smalltalk/Set create mode 120000 Lang/Standard-ML/Arbitrary-precision-integers--included- delete mode 120000 Lang/Standard-ML/Arbitrary-precision-integers-included create mode 120000 Lang/Standard-ML/Binary-digits create mode 120000 Lang/Standard-ML/Catalan-numbers create mode 120000 Lang/Standard-ML/Copy-a-string create mode 120000 Lang/Standard-ML/Environment-variables create mode 120000 Lang/Standard-ML/N-queens-problem create mode 120000 Lang/Standard-ML/Non-continuous-subsequences create mode 120000 Lang/Standard-ML/Non-decimal-radices-Convert create mode 120000 Lang/Standard-ML/Non-decimal-radices-Input create mode 120000 Lang/Standard-ML/Non-decimal-radices-Output create mode 120000 Lang/Standard-ML/Null-object create mode 120000 Lang/Standard-ML/Numerical-integration create mode 120000 Lang/Standard-ML/Order-two-numerical-lists create mode 120000 Lang/Standard-ML/Parametric-polymorphism create mode 120000 Lang/Standard-ML/Pattern-matching create mode 120000 Lang/Standard-ML/Pointers-and-references create mode 120000 Lang/Standard-ML/Power-set create mode 120000 Lang/Standard-ML/Primality-by-trial-division create mode 120000 Lang/Standard-ML/Priority-queue create mode 120000 Lang/Standard-ML/Program-name create mode 120000 Lang/Standard-ML/Program-termination create mode 120000 Lang/Standard-ML/Queue-Definition create mode 120000 Lang/Standard-ML/Queue-Usage create mode 120000 Lang/Standard-ML/Random-numbers create mode 120000 Lang/Standard-ML/Real-constants-and-functions create mode 120000 Lang/Standard-ML/Regular-expressions create mode 120000 Lang/Standard-ML/Rename-a-file create mode 120000 Lang/Standard-ML/Repeat-a-string create mode 120000 Lang/Standard-ML/Return-multiple-values create mode 120000 Lang/Standard-ML/Reverse-a-string create mode 120000 Lang/Standard-ML/Rot-13 create mode 120000 Lang/Standard-ML/Run-length-encoding create mode 120000 Lang/Standard-ML/SEDOLs create mode 120000 Lang/Standard-ML/Secure-temporary-file create mode 120000 Lang/Standard-ML/Sequence-of-non-squares create mode 120000 Lang/Suneido/Named-parameters create mode 120000 Lang/Suneido/Repeat-a-string create mode 120000 Lang/SystemVerilog/N-queens-problem create mode 120000 Lang/SystemVerilog/Pascals-triangle-Puzzle create mode 120000 Lang/TI-83-BASIC/Binary-digits create mode 120000 Lang/TI-83-BASIC/Brownian-tree create mode 120000 Lang/TI-83-BASIC/Catalan-numbers create mode 120000 Lang/TI-83-BASIC/Copy-a-string create mode 120000 Lang/TI-83-BASIC/Program-termination create mode 120000 Lang/TI-83-BASIC/Reverse-a-string create mode 120000 Lang/TI-83-BASIC/Rock-paper-scissors create mode 120000 Lang/TI-83-BASIC/Roman-numerals-Decode create mode 120000 Lang/TI-83-BASIC/Roman-numerals-Encode create mode 120000 Lang/TI-83-BASIC/Rot-13 create mode 120000 Lang/TI-89-BASIC/Copy-a-string create mode 120000 Lang/TI-89-BASIC/Dragon-curve create mode 120000 Lang/TI-89-BASIC/Non-decimal-radices-Output create mode 120000 Lang/TI-89-BASIC/Plot-coordinate-pairs create mode 120000 Lang/TI-89-BASIC/Polynomial-regression create mode 120000 Lang/TI-89-BASIC/Program-termination create mode 120000 Lang/TI-89-BASIC/Reduced-row-echelon-form create mode 120000 Lang/TI-89-BASIC/Roots-of-unity create mode 120000 Lang/TI-89-BASIC/Runtime-evaluation-In-an-environment create mode 120000 Lang/TI-89-BASIC/Scope-modifiers create mode 120000 Lang/TI-89-BASIC/Sequence-of-non-squares create mode 120000 Lang/TIScript/Optional-parameters create mode 120000 Lang/TUSCRIPT/Copy-a-string create mode 120000 Lang/TUSCRIPT/Number-reversal-game create mode 120000 Lang/TUSCRIPT/Order-two-numerical-lists create mode 120000 Lang/TUSCRIPT/Palindrome-detection create mode 120000 Lang/TUSCRIPT/Pangram-checker create mode 120000 Lang/TUSCRIPT/Pick-random-element create mode 120000 Lang/TUSCRIPT/Play-recorded-sounds create mode 120000 Lang/TUSCRIPT/Program-termination create mode 120000 Lang/TUSCRIPT/Range-expansion create mode 120000 Lang/TUSCRIPT/Range-extraction create mode 120000 Lang/TUSCRIPT/Read-a-file-line-by-line create mode 120000 Lang/TUSCRIPT/Read-a-specific-line-from-a-file create mode 120000 Lang/TUSCRIPT/Read-entire-file create mode 120000 Lang/TUSCRIPT/Remove-duplicate-elements create mode 120000 Lang/TUSCRIPT/Remove-lines-from-a-file create mode 120000 Lang/TUSCRIPT/Rename-a-file create mode 120000 Lang/TUSCRIPT/Repeat-a-string create mode 120000 Lang/TUSCRIPT/Reverse-a-string create mode 120000 Lang/TUSCRIPT/Roman-numerals-Decode create mode 120000 Lang/TUSCRIPT/Roman-numerals-Encode create mode 120000 Lang/TUSCRIPT/Rosetta-Code-Count-examples create mode 120000 Lang/TUSCRIPT/Rosetta-Code-Rank-languages-by-popularity create mode 120000 Lang/TUSCRIPT/Run-length-encoding create mode 120000 Lang/TUSCRIPT/SEDOLs create mode 120000 Lang/TUSCRIPT/Secure-temporary-file create mode 120000 Lang/TUSCRIPT/Semordnilap create mode 120000 Lang/TUSCRIPT/Send-email create mode 120000 Lang/TXR/Arbitrary-precision-integers--included- delete mode 120000 Lang/TXR/Arbitrary-precision-integers-included create mode 120000 Lang/TXR/Environment-variables create mode 120000 Lang/TXR/Pangram-checker create mode 120000 Lang/TXR/Pick-random-element create mode 120000 Lang/TXR/Power-set create mode 120000 Lang/TXR/Prime-decomposition create mode 120000 Lang/TXR/Read-a-configuration-file create mode 120000 Lang/TXR/Read-a-specific-line-from-a-file create mode 120000 Lang/TXR/Read-entire-file create mode 120000 Lang/TXR/Regular-expressions create mode 120000 Lang/TXR/Return-multiple-values create mode 120000 Lang/TXR/Rot-13 create mode 120000 Lang/TXR/Scope-modifiers create mode 120000 Lang/TXR/Send-email create mode 120000 Lang/Tcl/Arbitrary-precision-integers--included- delete mode 120000 Lang/Tcl/Arbitrary-precision-integers-included create mode 120000 Lang/Tcl/Binary-digits create mode 120000 Lang/Tcl/Brownian-tree create mode 120000 Lang/Tcl/Calendar---for-real-programmers delete mode 120000 Lang/Tcl/Calendar-for-real-programmers create mode 120000 Lang/Tcl/Catalan-numbers delete 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-N- delete mode 120000 Lang/Tcl/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2 create mode 120000 Lang/Tcl/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2- create mode 120000 Lang/Tcl/Copy-a-string create mode 120000 Lang/Tcl/Dragon-curve create mode 120000 Lang/Tcl/Environment-variables create mode 120000 Lang/Tcl/Execute-a-Markov-algorithm create mode 120000 Lang/Tcl/Guess-the-number-With-feedback--player- delete mode 120000 Lang/Tcl/Guess-the-number-With-feedback-player create mode 120000 Lang/Tcl/N-queens-problem create mode 120000 Lang/Tcl/Named-parameters create mode 120000 Lang/Tcl/Nautical-bell create mode 120000 Lang/Tcl/Non-continuous-subsequences create mode 120000 Lang/Tcl/Non-decimal-radices-Convert create mode 120000 Lang/Tcl/Non-decimal-radices-Input create mode 120000 Lang/Tcl/Non-decimal-radices-Output create mode 120000 Lang/Tcl/Nth-root create mode 120000 Lang/Tcl/Null-object create mode 120000 Lang/Tcl/Number-names create mode 120000 Lang/Tcl/Number-reversal-game create mode 120000 Lang/Tcl/Numeric-error-propagation create mode 120000 Lang/Tcl/Numerical-integration create mode 120000 Lang/Tcl/Numerical-integration-Gauss-Legendre-Quadrature create mode 120000 Lang/Tcl/Object-serialization create mode 120000 Lang/Tcl/One-dimensional-cellular-automata create mode 120000 Lang/Tcl/One-of-n-lines-in-a-file create mode 120000 Lang/Tcl/OpenGL create mode 120000 Lang/Tcl/Optional-parameters create mode 120000 Lang/Tcl/Order-two-numerical-lists create mode 120000 Lang/Tcl/Ordered-Partitions create mode 120000 Lang/Tcl/Palindrome-detection create mode 120000 Lang/Tcl/Pangram-checker create mode 120000 Lang/Tcl/Parallel-calculations create mode 120000 Lang/Tcl/Parametrized-SQL-statement create mode 120000 Lang/Tcl/Parsing-RPN-calculator-algorithm create mode 120000 Lang/Tcl/Parsing-RPN-to-infix-conversion create mode 120000 Lang/Tcl/Parsing-Shunting-yard-algorithm create mode 120000 Lang/Tcl/Partial-function-application create mode 120000 Lang/Tcl/Pascals-triangle create mode 120000 Lang/Tcl/Pascals-triangle-Puzzle create mode 120000 Lang/Tcl/Pattern-matching create mode 120000 Lang/Tcl/Percentage-difference-between-images create mode 120000 Lang/Tcl/Perfect-numbers create mode 120000 Lang/Tcl/Permutation-test create mode 120000 Lang/Tcl/Permutations create mode 120000 Lang/Tcl/Permutations-Derangements create mode 120000 Lang/Tcl/Permutations-by-swapping create mode 120000 Lang/Tcl/Pick-random-element create mode 120000 Lang/Tcl/Pig-the-dice-game create mode 120000 Lang/Tcl/Pig-the-dice-game-Player create mode 120000 Lang/Tcl/Pinstripe-Display create mode 120000 Lang/Tcl/Pinstripe-Printer create mode 120000 Lang/Tcl/Play-recorded-sounds create mode 120000 Lang/Tcl/Playing-cards create mode 120000 Lang/Tcl/Plot-coordinate-pairs create mode 120000 Lang/Tcl/Pointers-and-references create mode 120000 Lang/Tcl/Polymorphic-copy create mode 120000 Lang/Tcl/Polymorphism create mode 120000 Lang/Tcl/Polynomial-long-division create mode 120000 Lang/Tcl/Polynomial-regression create mode 120000 Lang/Tcl/Power-set create mode 120000 Lang/Tcl/Price-fraction create mode 120000 Lang/Tcl/Primality-by-trial-division create mode 120000 Lang/Tcl/Prime-decomposition create mode 120000 Lang/Tcl/Priority-queue create mode 120000 Lang/Tcl/Probabilistic-choice create mode 120000 Lang/Tcl/Problem-of-Apollonius create mode 120000 Lang/Tcl/Program-name create mode 120000 Lang/Tcl/Program-termination create mode 120000 Lang/Tcl/Pythagorean-triples create mode 120000 Lang/Tcl/QR-decomposition create mode 120000 Lang/Tcl/Quaternion-type create mode 120000 Lang/Tcl/Queue-Definition create mode 120000 Lang/Tcl/Queue-Usage create mode 120000 Lang/Tcl/RIPEMD-160 create mode 120000 Lang/Tcl/Random-number-generator--device- create mode 120000 Lang/Tcl/Random-numbers create mode 120000 Lang/Tcl/Range-expansion create mode 120000 Lang/Tcl/Range-extraction create mode 120000 Lang/Tcl/Rate-counter create mode 120000 Lang/Tcl/Ray-casting-algorithm create mode 120000 Lang/Tcl/Read-a-configuration-file create mode 120000 Lang/Tcl/Read-a-file-line-by-line create mode 120000 Lang/Tcl/Read-a-specific-line-from-a-file create mode 120000 Lang/Tcl/Read-entire-file create mode 120000 Lang/Tcl/Real-constants-and-functions create mode 120000 Lang/Tcl/Record-sound create mode 120000 Lang/Tcl/Reduced-row-echelon-form create mode 120000 Lang/Tcl/Regular-expressions create mode 120000 Lang/Tcl/Remove-duplicate-elements create mode 120000 Lang/Tcl/Remove-lines-from-a-file create mode 120000 Lang/Tcl/Rename-a-file create mode 120000 Lang/Tcl/Rendezvous create mode 120000 Lang/Tcl/Repeat-a-string create mode 120000 Lang/Tcl/Resistor-mesh create mode 120000 Lang/Tcl/Respond-to-an-unknown-method-call create mode 120000 Lang/Tcl/Return-multiple-values create mode 120000 Lang/Tcl/Reverse-a-string create mode 120000 Lang/Tcl/Rock-paper-scissors create mode 120000 Lang/Tcl/Roman-numerals-Decode create mode 120000 Lang/Tcl/Roman-numerals-Encode create mode 120000 Lang/Tcl/Roots-of-a-function create mode 120000 Lang/Tcl/Roots-of-a-quadratic-function create mode 120000 Lang/Tcl/Roots-of-unity create mode 120000 Lang/Tcl/Rosetta-Code-Count-examples create mode 120000 Lang/Tcl/Rosetta-Code-Find-unimplemented-tasks create mode 120000 Lang/Tcl/Rosetta-Code-Fix-code-tags create mode 120000 Lang/Tcl/Rosetta-Code-Rank-languages-by-popularity create mode 120000 Lang/Tcl/Rot-13 create mode 120000 Lang/Tcl/Run-length-encoding create mode 120000 Lang/Tcl/Runtime-evaluation create mode 120000 Lang/Tcl/Runtime-evaluation-In-an-environment create mode 120000 Lang/Tcl/S-Expressions create mode 120000 Lang/Tcl/SEDOLs create mode 120000 Lang/Tcl/Safe-addition create mode 120000 Lang/Tcl/Same-Fringe create mode 120000 Lang/Tcl/Scope-Function-names-and-labels create mode 120000 Lang/Tcl/Scope-modifiers create mode 120000 Lang/Tcl/Secure-temporary-file create mode 120000 Lang/Tcl/Self-describing-numbers create mode 120000 Lang/Tcl/Self-referential-sequence create mode 120000 Lang/Tcl/Semordnilap create mode 120000 Lang/Tcl/Send-an-unknown-method-call create mode 120000 Lang/Tcl/Send-email create mode 120000 Lang/Tcl/Sequence-of-non-squares create mode 120000 Lang/Tcl/Set create mode 120000 Lang/Tcl/Set-consolidation create mode 120000 Lang/Tcl/Set-of-real-numbers create mode 120000 Lang/Toka/Copy-a-string create mode 120000 Lang/Toka/Regular-expressions create mode 120000 Lang/Toka/Rename-a-file create mode 120000 Lang/TorqueScript/Read-a-file-line-by-line create mode 120000 Lang/TorqueScript/Rename-a-file create mode 120000 Lang/TorqueScript/Repeat-a-string create mode 120000 Lang/TorqueScript/Rock-paper-scissors create mode 120000 Lang/TorqueScript/Rot-13 create mode 120000 Lang/Trith/Copy-a-string create mode 120000 Lang/Turing/Pascals-triangle create mode 120000 Lang/Turing/Reverse-a-string create mode 120000 Lang/UNIX-Shell/Binary-digits create mode 120000 Lang/UNIX-Shell/Copy-a-string create mode 120000 Lang/UNIX-Shell/Environment-variables create mode 120000 Lang/UNIX-Shell/Number-reversal-game create mode 120000 Lang/UNIX-Shell/Pangram-checker create mode 120000 Lang/UNIX-Shell/Play-recorded-sounds create mode 120000 Lang/UNIX-Shell/Power-set create mode 120000 Lang/UNIX-Shell/Pragmatic-directives create mode 120000 Lang/UNIX-Shell/Primality-by-trial-division create mode 120000 Lang/UNIX-Shell/Program-name create mode 120000 Lang/UNIX-Shell/Program-termination create mode 120000 Lang/UNIX-Shell/Random-number-generator--included- create mode 120000 Lang/UNIX-Shell/Rate-counter create mode 120000 Lang/UNIX-Shell/Read-a-file-line-by-line create mode 120000 Lang/UNIX-Shell/Read-entire-file create mode 120000 Lang/UNIX-Shell/Remove-lines-from-a-file create mode 120000 Lang/UNIX-Shell/Rename-a-file create mode 120000 Lang/UNIX-Shell/Repeat-a-string create mode 120000 Lang/UNIX-Shell/Respond-to-an-unknown-method-call create mode 120000 Lang/UNIX-Shell/Return-multiple-values create mode 120000 Lang/UNIX-Shell/Rot-13 create mode 120000 Lang/UNIX-Shell/Runtime-evaluation-In-an-environment create mode 120000 Lang/UNIX-Shell/Scope-Function-names-and-labels create mode 120000 Lang/UNIX-Shell/Secure-temporary-file create mode 120000 Lang/UnixPipes/Power-set create mode 120000 Lang/UnixPipes/Queue-Definition create mode 120000 Lang/UnixPipes/Remove-duplicate-elements create mode 120000 Lang/UnixPipes/Rosetta-Code-Rank-languages-by-popularity create mode 120000 Lang/Unlambda/Program-termination create mode 120000 Lang/Unlambda/Reverse-a-string create mode 120000 Lang/Unlambda/Rot-13 create mode 120000 Lang/Ursala/Arbitrary-precision-integers--included- delete mode 120000 Lang/Ursala/Arbitrary-precision-integers-included create mode 120000 Lang/Ursala/Catalan-numbers create mode 120000 Lang/Ursala/Environment-variables create mode 120000 Lang/Ursala/N-queens-problem create mode 120000 Lang/Ursala/Non-continuous-subsequences create mode 120000 Lang/Ursala/Non-decimal-radices-Convert create mode 120000 Lang/Ursala/Nth-root create mode 120000 Lang/Ursala/Numerical-integration create mode 120000 Lang/Ursala/Numerical-integration-Gauss-Legendre-Quadrature create mode 120000 Lang/Ursala/One-dimensional-cellular-automata create mode 120000 Lang/Ursala/Optional-parameters create mode 120000 Lang/Ursala/Ordered-Partitions create mode 120000 Lang/Ursala/Palindrome-detection create mode 120000 Lang/Ursala/Pangram-checker create mode 120000 Lang/Ursala/Parametric-polymorphism create mode 120000 Lang/Ursala/Pascals-triangle create mode 120000 Lang/Ursala/Perfect-numbers create mode 120000 Lang/Ursala/Permutation-test create mode 120000 Lang/Ursala/Permutations create mode 120000 Lang/Ursala/Plot-coordinate-pairs create mode 120000 Lang/Ursala/Polynomial-long-division create mode 120000 Lang/Ursala/Polynomial-regression create mode 120000 Lang/Ursala/Power-set create mode 120000 Lang/Ursala/Price-fraction create mode 120000 Lang/Ursala/Primality-by-trial-division create mode 120000 Lang/Ursala/Probabilistic-choice create mode 120000 Lang/Ursala/Random-numbers create mode 120000 Lang/Ursala/Range-expansion create mode 120000 Lang/Ursala/Range-extraction create mode 120000 Lang/Ursala/Ray-casting-algorithm create mode 120000 Lang/Ursala/Reduced-row-echelon-form create mode 120000 Lang/Ursala/Remove-duplicate-elements create mode 120000 Lang/Ursala/Repeat-a-string create mode 120000 Lang/Ursala/Reverse-a-string create mode 120000 Lang/Ursala/Roman-numerals-Encode create mode 120000 Lang/Ursala/Roots-of-unity create mode 120000 Lang/Ursala/Rot-13 create mode 120000 Lang/Ursala/Run-length-encoding create mode 120000 Lang/Ursala/SEDOLs create mode 120000 Lang/Ursala/Scope-modifiers create mode 120000 Lang/Ursala/Sequence-of-non-squares create mode 120000 Lang/V/Copy-a-string create mode 120000 Lang/V/Power-set create mode 120000 Lang/V/Primality-by-trial-division create mode 120000 Lang/V/Prime-decomposition create mode 120000 Lang/V/Queue-Definition create mode 120000 Lang/VBA/Catalan-numbers create mode 120000 Lang/VBA/Palindrome-detection create mode 120000 Lang/VBA/Pangram-checker create mode 120000 Lang/VBA/Permutations create mode 120000 Lang/VBA/Play-recorded-sounds create mode 120000 Lang/VBA/Program-name create mode 120000 Lang/VBA/Range-expansion create mode 120000 Lang/VBA/Range-extraction create mode 120000 Lang/VBA/Repeat-a-string create mode 120000 Lang/VBA/Reverse-a-string create mode 120000 Lang/VBScript/Execute-a-Markov-algorithm create mode 120000 Lang/VBScript/Palindrome-detection create mode 120000 Lang/VBScript/Pangram-checker create mode 120000 Lang/VBScript/Playing-cards create mode 120000 Lang/VBScript/Program-termination create mode 120000 Lang/VBScript/Read-entire-file create mode 120000 Lang/Vala/Program-name create mode 120000 Lang/Vala/Read-a-file-line-by-line create mode 120000 Lang/Vala/Read-entire-file create mode 120000 Lang/Vala/Regular-expressions create mode 120000 Lang/Vala/Repeat-a-string create mode 120000 Lang/Vedit-macro-language/Binary-digits create mode 120000 Lang/Vedit-macro-language/Calendar---for-real-programmers delete mode 120000 Lang/Vedit-macro-language/Calendar-for-real-programmers create mode 120000 Lang/Vedit-macro-language/Dragon-curve create mode 120000 Lang/Vedit-macro-language/Environment-variables create mode 120000 Lang/Vedit-macro-language/One-dimensional-cellular-automata create mode 120000 Lang/Vedit-macro-language/Palindrome-detection create mode 120000 Lang/Vedit-macro-language/Pascals-triangle create mode 120000 Lang/Vedit-macro-language/Percentage-difference-between-images create mode 120000 Lang/Vedit-macro-language/Playing-cards create mode 120000 Lang/Vedit-macro-language/Program-termination create mode 120000 Lang/Vedit-macro-language/Read-a-configuration-file create mode 120000 Lang/Vedit-macro-language/Read-a-file-line-by-line create mode 120000 Lang/Vedit-macro-language/Read-a-specific-line-from-a-file create mode 120000 Lang/Vedit-macro-language/Read-entire-file create mode 120000 Lang/Vedit-macro-language/Regular-expressions create mode 120000 Lang/Vedit-macro-language/Remove-duplicate-elements create mode 120000 Lang/Vedit-macro-language/Rename-a-file create mode 120000 Lang/Vedit-macro-language/Repeat-a-string create mode 120000 Lang/Vedit-macro-language/Reverse-a-string create mode 120000 Lang/Vedit-macro-language/Roman-numerals-Decode create mode 120000 Lang/Vedit-macro-language/Roman-numerals-Encode create mode 120000 Lang/Vedit-macro-language/Rot-13 create mode 120000 Lang/Vedit-macro-language/Run-length-encoding create mode 120000 Lang/Visual-Basic-.NET/Binary-digits create mode 120000 Lang/Visual-Basic-.NET/Brownian-tree create mode 120000 Lang/Visual-Basic-.NET/Copy-a-string create mode 120000 Lang/Visual-Basic-.NET/Number-names create mode 120000 Lang/Visual-Basic-.NET/One-dimensional-cellular-automata create mode 120000 Lang/Visual-Basic-.NET/Read-a-file-line-by-line create mode 120000 Lang/Visual-Basic-.NET/Read-entire-file create mode 120000 Lang/Visual-Basic-.NET/Rename-a-file create mode 120000 Lang/Visual-Basic-.NET/Repeat-a-string create mode 120000 Lang/Visual-Basic-.NET/Reverse-a-string create mode 120000 Lang/Visual-Basic-.NET/Rot-13 create mode 120000 Lang/Visual-Basic/Named-parameters create mode 120000 Lang/Visual-Basic/Number-names create mode 120000 Lang/Visual-Basic/Program-name create mode 120000 Lang/Visual-Basic/Program-termination create mode 120000 Lang/Visual-Basic/Read-a-configuration-file create mode 120000 Lang/Visual-Basic/Read-a-file-line-by-line create mode 120000 Lang/Visual-Basic/Roman-numerals-Encode create mode 120000 Lang/Whitespace/Binary-digits create mode 120000 Lang/X86-Assembly/Binary-digits create mode 120000 Lang/X86-Assembly/Calendar---for-real-programmers delete mode 120000 Lang/X86-Assembly/Calendar-for-real-programmers create mode 120000 Lang/X86-Assembly/Dragon-curve create mode 120000 Lang/X86-Assembly/Rot-13 create mode 120000 Lang/XPL0/Binary-digits create mode 120000 Lang/XPL0/Brownian-tree create mode 120000 Lang/XPL0/Catalan-numbers create mode 120000 Lang/XPL0/Copy-a-string create mode 120000 Lang/XPL0/Dragon-curve create mode 120000 Lang/XPL0/Environment-variables create mode 120000 Lang/XPL0/Guess-the-number-With-feedback--player- delete mode 120000 Lang/XPL0/Guess-the-number-With-feedback-player create mode 120000 Lang/XPL0/N-queens-problem create mode 120000 Lang/XPL0/Non-decimal-radices-Convert create mode 120000 Lang/XPL0/Non-decimal-radices-Input create mode 120000 Lang/XPL0/Non-decimal-radices-Output create mode 120000 Lang/XPL0/Nth-root create mode 120000 Lang/XPL0/Number-names create mode 120000 Lang/XPL0/Number-reversal-game create mode 120000 Lang/XPL0/Numerical-integration create mode 120000 Lang/XPL0/One-dimensional-cellular-automata create mode 120000 Lang/XPL0/Palindrome-detection create mode 120000 Lang/XPL0/Pangram-checker create mode 120000 Lang/XPL0/Pascals-triangle create mode 120000 Lang/XPL0/Permutations create mode 120000 Lang/XPL0/Permutations-by-swapping create mode 120000 Lang/XPL0/Pick-random-element create mode 120000 Lang/XPL0/Pig-the-dice-game create mode 120000 Lang/XPL0/Pinstripe-Display create mode 120000 Lang/XPL0/Plot-coordinate-pairs create mode 120000 Lang/XPL0/Pointers-and-references create mode 120000 Lang/XPL0/Price-fraction create mode 120000 Lang/XPL0/Primality-by-trial-division create mode 120000 Lang/XPL0/Probabilistic-choice create mode 120000 Lang/XPL0/Program-termination create mode 120000 Lang/XPL0/Queue-Definition create mode 120000 Lang/XPL0/Queue-Usage create mode 120000 Lang/XPL0/Random-number-generator--device- create mode 120000 Lang/XPL0/Random-number-generator--included- create mode 120000 Lang/XPL0/Range-expansion create mode 120000 Lang/XPL0/Rate-counter create mode 120000 Lang/XPL0/Read-a-specific-line-from-a-file create mode 120000 Lang/XPL0/Read-entire-file create mode 120000 Lang/XPL0/Real-constants-and-functions create mode 120000 Lang/XPL0/Remove-duplicate-elements create mode 120000 Lang/XPL0/Repeat-a-string create mode 120000 Lang/XPL0/Resistor-mesh create mode 120000 Lang/XPL0/Return-multiple-values create mode 120000 Lang/XPL0/Reverse-a-string create mode 120000 Lang/XPL0/Roman-numerals-Decode create mode 120000 Lang/XPL0/Rot-13 create mode 120000 Lang/XPL0/Run-length-encoding create mode 120000 Lang/XPL0/Self-describing-numbers create mode 120000 Lang/XPL0/Semordnilap create mode 120000 Lang/XPL0/Sequence-of-non-squares create mode 120000 Lang/XSLT/N-queens-problem create mode 120000 Lang/XSLT/Named-parameters create mode 120000 Lang/XSLT/Optional-parameters create mode 120000 Lang/XSLT/Prime-decomposition create mode 120000 Lang/XSLT/Roman-numerals-Encode create mode 120000 Lang/XSLT/Rot-13 create mode 120000 Lang/Xanadu/N-queens-problem create mode 120000 Lang/Yorick/Palindrome-detection create mode 120000 Lang/Yorick/Plot-coordinate-pairs create mode 120000 Lang/Yorick/Random-numbers create mode 120000 Lang/Yorick/Read-entire-file create mode 120000 Lang/Yorick/Rename-a-file create mode 120000 Lang/Yorick/Repeat-a-string create mode 120000 Lang/Yorick/Reverse-a-string create mode 120000 Lang/ZX-Spectrum-Basic/Binary-digits create mode 120000 Lang/ZX-Spectrum-Basic/Copy-a-string create mode 120000 Lang/ZX-Spectrum-Basic/Random-numbers create mode 120000 Lang/ZX-Spectrum-Basic/Rot-13 create mode 120000 Lang/ZX-Spectrum-Basic/Scope-Function-names-and-labels rename Task/{Arbitrary-precision-integers-included => Arbitrary-precision-integers--included-}/0DESCRIPTION (100%) rename Task/{Arbitrary-precision-integers-included => Arbitrary-precision-integers--included-}/1META.yaml (100%) rename Task/{Arbitrary-precision-integers-included/ACL2/arbitrary-precision-integers-included.acl2 => Arbitrary-precision-integers--included-/ACL2/arbitrary-precision-integers--included-.acl2} (100%) rename Task/{Arbitrary-precision-integers-included/Ada/arbitrary-precision-integers-included.ada => Arbitrary-precision-integers--included-/Ada/arbitrary-precision-integers--included-.ada} (100%) rename Task/{Arbitrary-precision-integers-included/Alore/arbitrary-precision-integers-included.alore => Arbitrary-precision-integers--included-/Alore/arbitrary-precision-integers--included-.alore} (100%) rename Task/{Arbitrary-precision-integers-included/Bracmat/arbitrary-precision-integers-included.bracmat => Arbitrary-precision-integers--included-/Bracmat/arbitrary-precision-integers--included-.bracmat} (100%) rename Task/{Arbitrary-precision-integers-included/C-sharp/arbitrary-precision-integers-included.cs => Arbitrary-precision-integers--included-/C-sharp/arbitrary-precision-integers--included-.cs} (100%) rename Task/{Arbitrary-precision-integers-included/C/arbitrary-precision-integers-included-1.c => Arbitrary-precision-integers--included-/C/arbitrary-precision-integers--included--1.c} (100%) rename Task/{Arbitrary-precision-integers-included/C/arbitrary-precision-integers-included-2.c => Arbitrary-precision-integers--included-/C/arbitrary-precision-integers--included--2.c} (100%) rename Task/{Arbitrary-precision-integers-included/Clojure/arbitrary-precision-integers-included-1.clj => Arbitrary-precision-integers--included-/Clojure/arbitrary-precision-integers--included--1.clj} (100%) rename Task/{Arbitrary-precision-integers-included/Clojure/arbitrary-precision-integers-included-2.clj => Arbitrary-precision-integers--included-/Clojure/arbitrary-precision-integers--included--2.clj} (100%) rename Task/{Arbitrary-precision-integers-included/Common-Lisp/arbitrary-precision-integers-included.lisp => Arbitrary-precision-integers--included-/Common-Lisp/arbitrary-precision-integers--included-.lisp} (100%) rename Task/{Arbitrary-precision-integers-included/D/arbitrary-precision-integers-included.d => Arbitrary-precision-integers--included-/D/arbitrary-precision-integers--included-.d} (100%) rename Task/{Arbitrary-precision-integers-included/E/arbitrary-precision-integers-included.e => Arbitrary-precision-integers--included-/E/arbitrary-precision-integers--included-.e} (100%) rename Task/{Arbitrary-precision-integers-included/Emacs-Lisp/arbitrary-precision-integers-included.l => Arbitrary-precision-integers--included-/Emacs-Lisp/arbitrary-precision-integers--included-.l} (100%) rename Task/{Arbitrary-precision-integers-included/Erlang/arbitrary-precision-integers-included.erl => Arbitrary-precision-integers--included-/Erlang/arbitrary-precision-integers--included-.erl} (100%) rename Task/{Arbitrary-precision-integers-included/Factor/arbitrary-precision-integers-included.factor => Arbitrary-precision-integers--included-/Factor/arbitrary-precision-integers--included-.factor} (100%) rename Task/{Arbitrary-precision-integers-included/Frink/arbitrary-precision-integers-included.frink => Arbitrary-precision-integers--included-/Frink/arbitrary-precision-integers--included-.frink} (100%) rename Task/{Arbitrary-precision-integers-included/GAP/arbitrary-precision-integers-included.gap => Arbitrary-precision-integers--included-/GAP/arbitrary-precision-integers--included-.gap} (100%) rename Task/{Arbitrary-precision-integers-included/Go/arbitrary-precision-integers-included.go => Arbitrary-precision-integers--included-/Go/arbitrary-precision-integers--included-.go} (100%) rename Task/{Arbitrary-precision-integers-included/Golfscript/arbitrary-precision-integers-included.golfscript => Arbitrary-precision-integers--included-/Golfscript/arbitrary-precision-integers--included-.golfscript} (100%) rename Task/{Arbitrary-precision-integers-included/Groovy/arbitrary-precision-integers-included-1.groovy => Arbitrary-precision-integers--included-/Groovy/arbitrary-precision-integers--included--1.groovy} (100%) rename Task/{Arbitrary-precision-integers-included/Groovy/arbitrary-precision-integers-included-2.groovy => Arbitrary-precision-integers--included-/Groovy/arbitrary-precision-integers--included--2.groovy} (100%) rename Task/{Arbitrary-precision-integers-included/Haskell/arbitrary-precision-integers-included.hs => Arbitrary-precision-integers--included-/Haskell/arbitrary-precision-integers--included-.hs} (100%) rename Task/{Arbitrary-precision-integers-included/Icon/arbitrary-precision-integers-included.icon => Arbitrary-precision-integers--included-/Icon/arbitrary-precision-integers--included-.icon} (100%) rename Task/{Arbitrary-precision-integers-included/J/arbitrary-precision-integers-included.j => Arbitrary-precision-integers--included-/J/arbitrary-precision-integers--included-.j} (100%) rename Task/{Arbitrary-precision-integers-included/Java/arbitrary-precision-integers-included.java => Arbitrary-precision-integers--included-/Java/arbitrary-precision-integers--included-.java} (100%) rename Task/{Arbitrary-precision-integers-included/Julia/arbitrary-precision-integers-included.julia => Arbitrary-precision-integers--included-/Julia/arbitrary-precision-integers--included-.julia} (100%) rename Task/{Arbitrary-precision-integers-included/Liberty-BASIC/arbitrary-precision-integers-included.liberty => Arbitrary-precision-integers--included-/Liberty-BASIC/arbitrary-precision-integers--included-.liberty} (100%) rename Task/{Arbitrary-precision-integers-included/MATLAB/arbitrary-precision-integers-included.m => Arbitrary-precision-integers--included-/MATLAB/arbitrary-precision-integers--included-.m} (100%) rename Task/{Arbitrary-precision-integers-included/Maple/arbitrary-precision-integers-included-1.maple => Arbitrary-precision-integers--included-/Maple/arbitrary-precision-integers--included--1.maple} (100%) rename Task/{Arbitrary-precision-integers-included/Maple/arbitrary-precision-integers-included-2.maple => Arbitrary-precision-integers--included-/Maple/arbitrary-precision-integers--included--2.maple} (100%) rename Task/{Arbitrary-precision-integers-included/Mathematica/arbitrary-precision-integers-included.math => Arbitrary-precision-integers--included-/Mathematica/arbitrary-precision-integers--included-.math} (100%) rename Task/{Arbitrary-precision-integers-included/Maxima/arbitrary-precision-integers-included.maxima => Arbitrary-precision-integers--included-/Maxima/arbitrary-precision-integers--included-.maxima} (100%) rename Task/{Arbitrary-precision-integers-included/NetRexx/arbitrary-precision-integers-included-1.netrexx => Arbitrary-precision-integers--included-/NetRexx/arbitrary-precision-integers--included--1.netrexx} (100%) rename Task/{Arbitrary-precision-integers-included/NetRexx/arbitrary-precision-integers-included-2.netrexx => Arbitrary-precision-integers--included-/NetRexx/arbitrary-precision-integers--included--2.netrexx} (100%) rename Task/{Arbitrary-precision-integers-included/NetRexx/arbitrary-precision-integers-included-3.netrexx => Arbitrary-precision-integers--included-/NetRexx/arbitrary-precision-integers--included--3.netrexx} (100%) rename Task/{Arbitrary-precision-integers-included/OCaml/arbitrary-precision-integers-included-1.ocaml => Arbitrary-precision-integers--included-/OCaml/arbitrary-precision-integers--included--1.ocaml} (100%) rename Task/{Arbitrary-precision-integers-included/OCaml/arbitrary-precision-integers-included-2.ocaml => Arbitrary-precision-integers--included-/OCaml/arbitrary-precision-integers--included--2.ocaml} (100%) rename Task/{Arbitrary-precision-integers-included/Oz/arbitrary-precision-integers-included.oz => Arbitrary-precision-integers--included-/Oz/arbitrary-precision-integers--included-.oz} (100%) rename Task/{Arbitrary-precision-integers-included/PARI-GP/arbitrary-precision-integers-included.pari => Arbitrary-precision-integers--included-/PARI-GP/arbitrary-precision-integers--included-.pari} (100%) rename Task/{Arbitrary-precision-integers-included/PHP/arbitrary-precision-integers-included.php => Arbitrary-precision-integers--included-/PHP/arbitrary-precision-integers--included-.php} (100%) rename Task/{Arbitrary-precision-integers-included/Pascal/arbitrary-precision-integers-included.pascal => Arbitrary-precision-integers--included-/Pascal/arbitrary-precision-integers--included-.pascal} (100%) rename Task/{Arbitrary-precision-integers-included/Perl-6/arbitrary-precision-integers-included.pl6 => Arbitrary-precision-integers--included-/Perl-6/arbitrary-precision-integers--included-.pl6} (100%) rename Task/{Arbitrary-precision-integers-included/Perl/arbitrary-precision-integers-included-1.pl => Arbitrary-precision-integers--included-/Perl/arbitrary-precision-integers--included--1.pl} (100%) rename Task/{Arbitrary-precision-integers-included/Perl/arbitrary-precision-integers-included-2.pl => Arbitrary-precision-integers--included-/Perl/arbitrary-precision-integers--included--2.pl} (100%) rename Task/{Arbitrary-precision-integers-included/Perl/arbitrary-precision-integers-included-3.pl => Arbitrary-precision-integers--included-/Perl/arbitrary-precision-integers--included--3.pl} (100%) rename Task/{Arbitrary-precision-integers-included/PicoLisp/arbitrary-precision-integers-included.l => Arbitrary-precision-integers--included-/PicoLisp/arbitrary-precision-integers--included-.l} (100%) rename Task/{Arbitrary-precision-integers-included/Pike/arbitrary-precision-integers-included.pike => Arbitrary-precision-integers--included-/Pike/arbitrary-precision-integers--included-.pike} (100%) rename Task/{Arbitrary-precision-integers-included/PureBasic/arbitrary-precision-integers-included.purebasic => Arbitrary-precision-integers--included-/PureBasic/arbitrary-precision-integers--included-.purebasic} (100%) rename Task/{Arbitrary-precision-integers-included/Python/arbitrary-precision-integers-included.py => Arbitrary-precision-integers--included-/Python/arbitrary-precision-integers--included-.py} (100%) rename Task/{Arbitrary-precision-integers-included/R/arbitrary-precision-integers-included.r => Arbitrary-precision-integers--included-/R/arbitrary-precision-integers--included-.r} (100%) rename Task/{Arbitrary-precision-integers-included/REXX/arbitrary-precision-integers-included-1.rexx => Arbitrary-precision-integers--included-/REXX/arbitrary-precision-integers--included--1.rexx} (100%) rename Task/{Arbitrary-precision-integers-included/REXX/arbitrary-precision-integers-included-2.rexx => Arbitrary-precision-integers--included-/REXX/arbitrary-precision-integers--included--2.rexx} (100%) rename Task/{Arbitrary-precision-integers-included/Racket/arbitrary-precision-integers-included.rkt => Arbitrary-precision-integers--included-/Racket/arbitrary-precision-integers--included-.rkt} (100%) rename Task/{Arbitrary-precision-integers-included/Ruby/arbitrary-precision-integers-included.rb => Arbitrary-precision-integers--included-/Ruby/arbitrary-precision-integers--included-.rb} (100%) rename Task/{Arbitrary-precision-integers-included/Run-BASIC/arbitrary-precision-integers-included.run => Arbitrary-precision-integers--included-/Run-BASIC/arbitrary-precision-integers--included-.run} (100%) rename Task/{Arbitrary-precision-integers-included/SIMPOL/arbitrary-precision-integers-included.simpol => Arbitrary-precision-integers--included-/SIMPOL/arbitrary-precision-integers--included-.simpol} (100%) rename Task/{Arbitrary-precision-integers-included/Sather/arbitrary-precision-integers-included.sa => Arbitrary-precision-integers--included-/Sather/arbitrary-precision-integers--included-.sa} (100%) rename Task/{Arbitrary-precision-integers-included/Scala/arbitrary-precision-integers-included.scala => Arbitrary-precision-integers--included-/Scala/arbitrary-precision-integers--included-.scala} (100%) rename Task/{Arbitrary-precision-integers-included/Scheme/arbitrary-precision-integers-included.ss => Arbitrary-precision-integers--included-/Scheme/arbitrary-precision-integers--included-.ss} (100%) rename Task/{Arbitrary-precision-integers-included/Seed7/arbitrary-precision-integers-included.seed7 => Arbitrary-precision-integers--included-/Seed7/arbitrary-precision-integers--included-.seed7} (100%) rename Task/{Arbitrary-precision-integers-included/Smalltalk/arbitrary-precision-integers-included-1.st => Arbitrary-precision-integers--included-/Smalltalk/arbitrary-precision-integers--included--1.st} (100%) rename Task/{Arbitrary-precision-integers-included/Smalltalk/arbitrary-precision-integers-included-2.st => Arbitrary-precision-integers--included-/Smalltalk/arbitrary-precision-integers--included--2.st} (100%) rename Task/{Arbitrary-precision-integers-included/Standard-ML/arbitrary-precision-integers-included.ml => Arbitrary-precision-integers--included-/Standard-ML/arbitrary-precision-integers--included-.ml} (100%) rename Task/{Arbitrary-precision-integers-included/TXR/arbitrary-precision-integers-included.txr => Arbitrary-precision-integers--included-/TXR/arbitrary-precision-integers--included-.txr} (100%) rename Task/{Arbitrary-precision-integers-included/Tcl/arbitrary-precision-integers-included.tcl => Arbitrary-precision-integers--included-/Tcl/arbitrary-precision-integers--included-.tcl} (100%) rename Task/{Arbitrary-precision-integers-included/Ursala/arbitrary-precision-integers-included.ursala => Arbitrary-precision-integers--included-/Ursala/arbitrary-precision-integers--included-.ursala} (100%) create mode 100644 Task/Binary-digits/0815/binary-digits-1.0815 create mode 100644 Task/Binary-digits/0815/binary-digits-2.0815 create mode 100644 Task/Binary-digits/0DESCRIPTION create mode 100644 Task/Binary-digits/1META.yaml create mode 100644 Task/Binary-digits/ACL2/binary-digits.acl2 create mode 100644 Task/Binary-digits/ALGOL-68/binary-digits.alg create mode 100644 Task/Binary-digits/AWK/binary-digits.awk create mode 100644 Task/Binary-digits/Ada/binary-digits.ada create mode 100644 Task/Binary-digits/AutoHotkey/binary-digits.ahk create mode 100644 Task/Binary-digits/AutoIt/binary-digits.autoit create mode 100644 Task/Binary-digits/BBC-BASIC/binary-digits-1.bbc create mode 100644 Task/Binary-digits/BBC-BASIC/binary-digits-2.bbc create mode 100644 Task/Binary-digits/Batch-File/binary-digits.bat create mode 100644 Task/Binary-digits/Brainf---/binary-digits.bf create mode 100644 Task/Binary-digits/Burlesque/binary-digits.blq create mode 100644 Task/Binary-digits/C++/binary-digits.cpp create mode 100644 Task/Binary-digits/C/binary-digits-1.c create mode 100644 Task/Binary-digits/C/binary-digits-2.c create mode 100644 Task/Binary-digits/COBOL/binary-digits.cobol create mode 100644 Task/Binary-digits/Clojure/binary-digits.clj create mode 100644 Task/Binary-digits/CoffeeScript/binary-digits.coffeescript create mode 100644 Task/Binary-digits/Common-Lisp/binary-digits.lisp create mode 100644 Task/Binary-digits/D/binary-digits.d create mode 100644 Task/Binary-digits/Dart/binary-digits.dart create mode 100644 Task/Binary-digits/Delphi/binary-digits.delphi create mode 100644 Task/Binary-digits/Elena/binary-digits.elena create mode 100644 Task/Binary-digits/Erlang/binary-digits.erl create mode 100644 Task/Binary-digits/Euphoria/binary-digits.euphoria create mode 100644 Task/Binary-digits/Factor/binary-digits.factor create mode 100644 Task/Binary-digits/Forth/binary-digits.fth create mode 100644 Task/Binary-digits/Go/binary-digits.go create mode 100644 Task/Binary-digits/Groovy/binary-digits.groovy create mode 100644 Task/Binary-digits/Haskell/binary-digits.hs create mode 100644 Task/Binary-digits/Icon/binary-digits.icon create mode 100644 Task/Binary-digits/J/binary-digits.j create mode 100644 Task/Binary-digits/Java/binary-digits.java create mode 100644 Task/Binary-digits/JavaScript/binary-digits.js create mode 100644 Task/Binary-digits/Joy/binary-digits-1.joy create mode 100644 Task/Binary-digits/Joy/binary-digits-2.joy create mode 100644 Task/Binary-digits/K/binary-digits.k create mode 100644 Task/Binary-digits/LOLCODE/binary-digits.lol create mode 100644 Task/Binary-digits/Lang5/binary-digits.lang5 create mode 100644 Task/Binary-digits/Liberty-BASIC/binary-digits.liberty create mode 100644 Task/Binary-digits/Locomotive-Basic/binary-digits.locomotive create mode 100644 Task/Binary-digits/MATLAB/binary-digits.m create mode 100644 Task/Binary-digits/Maple/binary-digits.maple create mode 100644 Task/Binary-digits/Mathematica/binary-digits.math create mode 100644 Task/Binary-digits/Maxima/binary-digits.maxima create mode 100644 Task/Binary-digits/Mercury/binary-digits.mercury create mode 100644 Task/Binary-digits/Modula-3/binary-digits.mod3 create mode 100644 Task/Binary-digits/NetRexx/binary-digits.netrexx create mode 100644 Task/Binary-digits/OCaml/binary-digits.ocaml create mode 100644 Task/Binary-digits/Objeck/binary-digits.objeck create mode 100644 Task/Binary-digits/OxygenBasic/binary-digits.oxy create mode 100644 Task/Binary-digits/PARI-GP/binary-digits.pari create mode 100644 Task/Binary-digits/PHP/binary-digits.php create mode 100644 Task/Binary-digits/PL-I/binary-digits-1.pli create mode 100644 Task/Binary-digits/PL-I/binary-digits-2.pli create mode 100644 Task/Binary-digits/Perl-6/binary-digits.pl6 create mode 100644 Task/Binary-digits/Perl/binary-digits.pl create mode 100644 Task/Binary-digits/PicoLisp/binary-digits.l create mode 100644 Task/Binary-digits/PowerShell/binary-digits.psh create mode 100644 Task/Binary-digits/PureBasic/binary-digits.purebasic create mode 100644 Task/Binary-digits/Python/binary-digits-1.py create mode 100644 Task/Binary-digits/Python/binary-digits-2.py create mode 100644 Task/Binary-digits/Python/binary-digits-3.py create mode 100644 Task/Binary-digits/REXX/binary-digits-1.rexx create mode 100644 Task/Binary-digits/REXX/binary-digits-2.rexx create mode 100644 Task/Binary-digits/REXX/binary-digits-3.rexx create mode 100644 Task/Binary-digits/Racket/binary-digits.rkt create mode 100644 Task/Binary-digits/Retro/binary-digits.retro create mode 100644 Task/Binary-digits/Ruby/binary-digits-1.rb create mode 100644 Task/Binary-digits/Ruby/binary-digits-2.rb create mode 100644 Task/Binary-digits/Ruby/binary-digits.rb create mode 100644 Task/Binary-digits/Run-BASIC/binary-digits.run create mode 100644 Task/Binary-digits/Scala/binary-digits.scala create mode 100644 Task/Binary-digits/Scheme/binary-digits.ss create mode 100644 Task/Binary-digits/Seed7/binary-digits.seed7 create mode 100644 Task/Binary-digits/Smalltalk/binary-digits-1.st create mode 100644 Task/Binary-digits/Smalltalk/binary-digits-2.st create mode 100644 Task/Binary-digits/Standard-ML/binary-digits.ml create mode 100644 Task/Binary-digits/TI-83-BASIC/binary-digits-1.ti-83 create mode 100644 Task/Binary-digits/TI-83-BASIC/binary-digits-2.ti-83 create mode 100644 Task/Binary-digits/TI-83-BASIC/binary-digits-3.ti-83 create mode 100644 Task/Binary-digits/Tcl/binary-digits-1.tcl create mode 100644 Task/Binary-digits/Tcl/binary-digits-2.tcl create mode 100644 Task/Binary-digits/UNIX-Shell/binary-digits.sh create mode 100644 Task/Binary-digits/Vedit-macro-language/binary-digits.vedit create mode 100644 Task/Binary-digits/Visual-Basic-.NET/binary-digits.visual create mode 100644 Task/Binary-digits/Whitespace/binary-digits-1.ws create mode 100644 Task/Binary-digits/Whitespace/binary-digits-2.ws create mode 100644 Task/Binary-digits/X86-Assembly/binary-digits.x86 create mode 100644 Task/Binary-digits/XPL0/binary-digits.xpl0 create mode 100644 Task/Binary-digits/ZX-Spectrum-Basic/binary-digits.zx create mode 100644 Task/Brownian-tree/0DESCRIPTION create mode 100644 Task/Brownian-tree/1META.yaml create mode 100644 Task/Brownian-tree/AutoHotkey/brownian-tree.ahk create mode 100644 Task/Brownian-tree/BBC-BASIC/brownian-tree.bbc create mode 100644 Task/Brownian-tree/C/brownian-tree-1.c create mode 100644 Task/Brownian-tree/C/brownian-tree-2.c create mode 100644 Task/Brownian-tree/D/brownian-tree.d create mode 100644 Task/Brownian-tree/Delphi/brownian-tree.delphi create mode 100644 Task/Brownian-tree/Fantom/brownian-tree.fantom create mode 100644 Task/Brownian-tree/Fortran/brownian-tree.f create mode 100644 Task/Brownian-tree/Go/brownian-tree-1.go create mode 100644 Task/Brownian-tree/Go/brownian-tree-2.go create mode 100644 Task/Brownian-tree/Haskell/brownian-tree.hs create mode 100644 Task/Brownian-tree/Icon/brownian-tree.icon create mode 100644 Task/Brownian-tree/J/brownian-tree-1.j create mode 100644 Task/Brownian-tree/J/brownian-tree-2.j create mode 100644 Task/Brownian-tree/Java/brownian-tree.java create mode 100644 Task/Brownian-tree/JavaScript/brownian-tree-1.js create mode 100644 Task/Brownian-tree/JavaScript/brownian-tree-2.js create mode 100644 Task/Brownian-tree/Liberty-BASIC/brownian-tree.liberty create mode 100644 Task/Brownian-tree/Lua/brownian-tree.lua create mode 100644 Task/Brownian-tree/Mathematica/brownian-tree.math create mode 100644 Task/Brownian-tree/OCaml/brownian-tree.ocaml create mode 100644 Task/Brownian-tree/Octave/brownian-tree.octave create mode 100644 Task/Brownian-tree/Perl/brownian-tree.pl create mode 100644 Task/Brownian-tree/PicoLisp/brownian-tree.l create mode 100644 Task/Brownian-tree/PureBasic/brownian-tree.purebasic create mode 100644 Task/Brownian-tree/Python/brownian-tree.py create mode 100644 Task/Brownian-tree/REXX/brownian-tree.rexx create mode 100644 Task/Brownian-tree/Ruby/brownian-tree.rb create mode 100644 Task/Brownian-tree/Run-BASIC/brownian-tree.run create mode 100644 Task/Brownian-tree/Scheme/brownian-tree.ss create mode 100644 Task/Brownian-tree/Seed7/brownian-tree.seed7 create mode 100644 Task/Brownian-tree/TI-83-BASIC/brownian-tree.ti-83 create mode 100644 Task/Brownian-tree/Tcl/brownian-tree.tcl create mode 100644 Task/Brownian-tree/Visual-Basic-.NET/brownian-tree.visual create mode 100644 Task/Brownian-tree/XPL0/brownian-tree.xpl0 rename Task/{Calendar-for-real-programmers => Calendar---for-real-programmers}/0DESCRIPTION (100%) rename Task/{Calendar-for-real-programmers => Calendar---for-real-programmers}/1META.yaml (100%) rename Task/{Calendar-for-real-programmers/ALGOL-68/calendar-for-real-programmers.alg => Calendar---for-real-programmers/ALGOL-68/calendar---for-real-programmers.alg} (100%) rename Task/{Calendar-for-real-programmers/Ada/calendar-for-real-programmers.ada => Calendar---for-real-programmers/Ada/calendar---for-real-programmers.ada} (100%) rename Task/{Calendar-for-real-programmers/BBC-BASIC/calendar-for-real-programmers.bbc => Calendar---for-real-programmers/BBC-BASIC/calendar---for-real-programmers.bbc} (100%) rename Task/{Calendar-for-real-programmers/GUISS/calendar-for-real-programmers.guiss => Calendar---for-real-programmers/GUISS/calendar---for-real-programmers.guiss} (100%) rename Task/{Calendar-for-real-programmers/Icon/calendar-for-real-programmers-1.icon => Calendar---for-real-programmers/Icon/calendar---for-real-programmers-1.icon} (100%) rename Task/{Calendar-for-real-programmers/Icon/calendar-for-real-programmers-2.icon => Calendar---for-real-programmers/Icon/calendar---for-real-programmers-2.icon} (100%) rename Task/{Calendar-for-real-programmers/J/calendar-for-real-programmers-1.j => Calendar---for-real-programmers/J/calendar---for-real-programmers-1.j} (100%) rename Task/{Calendar-for-real-programmers/J/calendar-for-real-programmers-2.j => Calendar---for-real-programmers/J/calendar---for-real-programmers-2.j} (100%) rename Task/{Calendar-for-real-programmers/PHP/calendar-for-real-programmers.php => Calendar---for-real-programmers/PHP/calendar---for-real-programmers.php} (100%) rename Task/{Calendar-for-real-programmers/Perl-6/calendar-for-real-programmers.pl6 => Calendar---for-real-programmers/Perl-6/calendar---for-real-programmers.pl6} (100%) rename Task/{Calendar-for-real-programmers/Perl/calendar-for-real-programmers-1.pl => Calendar---for-real-programmers/Perl/calendar---for-real-programmers-1.pl} (100%) rename Task/{Calendar-for-real-programmers/Perl/calendar-for-real-programmers-2.pl => Calendar---for-real-programmers/Perl/calendar---for-real-programmers-2.pl} (100%) rename Task/{Calendar-for-real-programmers/PicoLisp/calendar-for-real-programmers.l => Calendar---for-real-programmers/PicoLisp/calendar---for-real-programmers.l} (100%) rename Task/{Calendar-for-real-programmers/REXX/calendar-for-real-programmers.rexx => Calendar---for-real-programmers/REXX/calendar---for-real-programmers.rexx} (100%) rename Task/{Calendar-for-real-programmers/Ruby/calendar-for-real-programmers-1.rb => Calendar---for-real-programmers/Ruby/calendar---for-real-programmers-1.rb} (100%) rename Task/{Calendar-for-real-programmers/Ruby/calendar-for-real-programmers-2.rb => Calendar---for-real-programmers/Ruby/calendar---for-real-programmers-2.rb} (100%) rename Task/{Calendar-for-real-programmers/Tcl/calendar-for-real-programmers.tcl => Calendar---for-real-programmers/Tcl/calendar---for-real-programmers.tcl} (100%) rename Task/{Calendar-for-real-programmers/Vedit-macro-language/calendar-for-real-programmers.vedit => Calendar---for-real-programmers/Vedit-macro-language/calendar---for-real-programmers.vedit} (100%) rename Task/{Calendar-for-real-programmers/X86-Assembly/calendar-for-real-programmers.x86 => Calendar---for-real-programmers/X86-Assembly/calendar---for-real-programmers.x86} (100%) create mode 100644 Task/Catalan-numbers/0DESCRIPTION create mode 100644 Task/Catalan-numbers/1META.yaml create mode 100644 Task/Catalan-numbers/AWK/catalan-numbers.awk create mode 100644 Task/Catalan-numbers/Ada/catalan-numbers.ada create mode 100644 Task/Catalan-numbers/AutoHotkey/catalan-numbers.ahk create mode 100644 Task/Catalan-numbers/BASIC/catalan-numbers.basic create mode 100644 Task/Catalan-numbers/BBC-BASIC/catalan-numbers.bbc create mode 100644 Task/Catalan-numbers/Bracmat/catalan-numbers-1.bracmat create mode 100644 Task/Catalan-numbers/Bracmat/catalan-numbers-2.bracmat create mode 100644 Task/Catalan-numbers/Brat/catalan-numbers.brat create mode 100644 Task/Catalan-numbers/C++/catalan-numbers-1.cpp create mode 100644 Task/Catalan-numbers/C++/catalan-numbers-2.cpp create mode 100644 Task/Catalan-numbers/C++/catalan-numbers-3.cpp create mode 100644 Task/Catalan-numbers/C++/catalan-numbers-4.cpp create mode 100644 Task/Catalan-numbers/C++/catalan-numbers-5.cpp create mode 100644 Task/Catalan-numbers/C/catalan-numbers-1.c create mode 100644 Task/Catalan-numbers/C/catalan-numbers-2.c create mode 100644 Task/Catalan-numbers/Clojure/catalan-numbers.clj create mode 100644 Task/Catalan-numbers/Common-Lisp/catalan-numbers.lisp create mode 100644 Task/Catalan-numbers/D/catalan-numbers.d create mode 100644 Task/Catalan-numbers/Erlang/catalan-numbers.erl create mode 100644 Task/Catalan-numbers/Euphoria/catalan-numbers.euphoria create mode 100644 Task/Catalan-numbers/Factor/catalan-numbers.factor create mode 100644 Task/Catalan-numbers/Fantom/catalan-numbers.fantom create mode 100644 Task/Catalan-numbers/Forth/catalan-numbers.fth create mode 100644 Task/Catalan-numbers/Fortran/catalan-numbers.f create mode 100644 Task/Catalan-numbers/Frink/catalan-numbers.frink create mode 100644 Task/Catalan-numbers/GAP/catalan-numbers.gap create mode 100644 Task/Catalan-numbers/Go/catalan-numbers.go create mode 100644 Task/Catalan-numbers/Haskell/catalan-numbers.hs create mode 100644 Task/Catalan-numbers/Icon/catalan-numbers.icon create mode 100644 Task/Catalan-numbers/J/catalan-numbers.j create mode 100644 Task/Catalan-numbers/Java/catalan-numbers.java create mode 100644 Task/Catalan-numbers/JavaScript/catalan-numbers-1.js create mode 100644 Task/Catalan-numbers/JavaScript/catalan-numbers-2.js create mode 100644 Task/Catalan-numbers/Julia/catalan-numbers.julia create mode 100644 Task/Catalan-numbers/K/catalan-numbers.k create mode 100644 Task/Catalan-numbers/Liberty-BASIC/catalan-numbers.liberty create mode 100644 Task/Catalan-numbers/Lua/catalan-numbers.lua create mode 100644 Task/Catalan-numbers/MATLAB/catalan-numbers-1.m create mode 100644 Task/Catalan-numbers/MATLAB/catalan-numbers-2.m create mode 100644 Task/Catalan-numbers/MATLAB/catalan-numbers-3.m create mode 100644 Task/Catalan-numbers/Mathematica/catalan-numbers-1.math create mode 100644 Task/Catalan-numbers/Mathematica/catalan-numbers-2.math create mode 100644 Task/Catalan-numbers/Maxima/catalan-numbers.maxima create mode 100644 Task/Catalan-numbers/PARI-GP/catalan-numbers-1.pari create mode 100644 Task/Catalan-numbers/PARI-GP/catalan-numbers-2.pari create mode 100644 Task/Catalan-numbers/PARI-GP/catalan-numbers-3.pari create mode 100644 Task/Catalan-numbers/PARI-GP/catalan-numbers-4.pari create mode 100644 Task/Catalan-numbers/PARI-GP/catalan-numbers-5.pari create mode 100644 Task/Catalan-numbers/PHP/catalan-numbers.php create mode 100644 Task/Catalan-numbers/PL-I/catalan-numbers.pli create mode 100644 Task/Catalan-numbers/Pascal/catalan-numbers.pascal create mode 100644 Task/Catalan-numbers/Perl-6/catalan-numbers.pl6 create mode 100644 Task/Catalan-numbers/Perl/catalan-numbers-1.pl create mode 100644 Task/Catalan-numbers/Perl/catalan-numbers-2.pl create mode 100644 Task/Catalan-numbers/PicoLisp/catalan-numbers.l create mode 100644 Task/Catalan-numbers/PlainTeX/catalan-numbers.tex create mode 100644 Task/Catalan-numbers/Prolog/catalan-numbers.pro create mode 100644 Task/Catalan-numbers/PureBasic/catalan-numbers.purebasic create mode 100644 Task/Catalan-numbers/Python/catalan-numbers.py create mode 100644 Task/Catalan-numbers/R/catalan-numbers.r create mode 100644 Task/Catalan-numbers/REXX/catalan-numbers.rexx create mode 100644 Task/Catalan-numbers/Racket/catalan-numbers.rkt create mode 100644 Task/Catalan-numbers/Ruby/catalan-numbers.rb create mode 100644 Task/Catalan-numbers/Run-BASIC/catalan-numbers.run create mode 100644 Task/Catalan-numbers/Scala/catalan-numbers.scala create mode 100644 Task/Catalan-numbers/Scheme/catalan-numbers.ss create mode 100644 Task/Catalan-numbers/Standard-ML/catalan-numbers.ml create mode 100644 Task/Catalan-numbers/TI-83-BASIC/catalan-numbers.ti-83 create mode 100644 Task/Catalan-numbers/Tcl/catalan-numbers-1.tcl create mode 100644 Task/Catalan-numbers/Tcl/catalan-numbers-2.tcl create mode 100644 Task/Catalan-numbers/Ursala/catalan-numbers.ursala create mode 100644 Task/Catalan-numbers/VBA/catalan-numbers.vba create mode 100644 Task/Catalan-numbers/XPL0/catalan-numbers.xpl0 rename Task/{Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N => Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N-}/0DESCRIPTION (100%) rename Task/{Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-1.cpp => Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N-/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n--1.cpp} (100%) rename Task/{Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-2.cpp => Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N-/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n--2.cpp} (100%) rename Task/{Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-3.cpp => Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N-/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n--3.cpp} (100%) rename Task/{Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-4.cpp => Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N-/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n--4.cpp} (100%) rename Task/{Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-5.cpp => Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N-/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n--5.cpp} (100%) rename Task/{Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-6.cpp => Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N-/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n--6.cpp} (100%) rename Task/{Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-7.cpp => Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N-/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n--7.cpp} (100%) rename Task/{Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Ruby/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-1.rb => Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N-/Ruby/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n--1.rb} (100%) rename Task/{Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Ruby/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-2.rb => Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N-/Ruby/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n--2.rb} (100%) rename Task/{Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Ruby/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-3.rb => Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N-/Ruby/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n--3.rb} (100%) rename Task/{Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Ruby/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-4.rb => Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N-/Ruby/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n--4.rb} (100%) rename Task/{Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Tcl/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-1.tcl => Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N-/Tcl/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n--1.tcl} (100%) rename Task/{Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Tcl/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-2.tcl => Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N-/Tcl/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n--2.tcl} (100%) rename Task/{Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2 => Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2-}/0DESCRIPTION (100%) rename Task/{Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2 => Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2-}/1META.yaml (100%) rename 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 => 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} (100%) rename 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 => 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} (100%) rename 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 => 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} (100%) rename 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 => 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} (100%) rename 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 => 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} (100%) rename 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 => 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} (100%) rename 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 => 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} (100%) rename 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 => 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} (100%) create mode 100644 Task/Copy-a-string/0DESCRIPTION create mode 100644 Task/Copy-a-string/1META.yaml create mode 100644 Task/Copy-a-string/ABAP/copy-a-string.abap create mode 100644 Task/Copy-a-string/ALGOL-68/copy-a-string.alg create mode 100644 Task/Copy-a-string/AWK/copy-a-string.awk create mode 100644 Task/Copy-a-string/ActionScript/copy-a-string.as create mode 100644 Task/Copy-a-string/Ada/copy-a-string-1.ada create mode 100644 Task/Copy-a-string/Ada/copy-a-string-2.ada create mode 100644 Task/Copy-a-string/Ada/copy-a-string-3.ada create mode 100644 Task/Copy-a-string/Ada/copy-a-string-4.ada create mode 100644 Task/Copy-a-string/AutoHotkey/copy-a-string.ahk create mode 100644 Task/Copy-a-string/AutoIt/copy-a-string.autoit create mode 100644 Task/Copy-a-string/BBC-BASIC/copy-a-string.bbc create mode 100644 Task/Copy-a-string/Batch-File/copy-a-string.bat create mode 100644 Task/Copy-a-string/Bracmat/copy-a-string.bracmat create mode 100644 Task/Copy-a-string/C++/copy-a-string.cpp create mode 100644 Task/Copy-a-string/C/copy-a-string-1.c create mode 100644 Task/Copy-a-string/C/copy-a-string-2.c create mode 100644 Task/Copy-a-string/Clojure/copy-a-string.clj create mode 100644 Task/Copy-a-string/ColdFusion/copy-a-string.cfm create mode 100644 Task/Copy-a-string/Common-Lisp/copy-a-string.lisp create mode 100644 Task/Copy-a-string/D/copy-a-string.d create mode 100644 Task/Copy-a-string/Delphi/copy-a-string.delphi create mode 100644 Task/Copy-a-string/Erlang/copy-a-string.erl create mode 100644 Task/Copy-a-string/Euphoria/copy-a-string.euphoria create mode 100644 Task/Copy-a-string/Factor/copy-a-string-1.factor create mode 100644 Task/Copy-a-string/Factor/copy-a-string-2.factor create mode 100644 Task/Copy-a-string/Factor/copy-a-string-3.factor create mode 100644 Task/Copy-a-string/Forth/copy-a-string.fth create mode 100644 Task/Copy-a-string/Fortran/copy-a-string.f create mode 100644 Task/Copy-a-string/GAP/copy-a-string.gap create mode 100644 Task/Copy-a-string/GML/copy-a-string.gml create mode 100644 Task/Copy-a-string/GUISS/copy-a-string.guiss create mode 100644 Task/Copy-a-string/Gambas/copy-a-string.gambas create mode 100644 Task/Copy-a-string/Go/copy-a-string.go create mode 100644 Task/Copy-a-string/Groovy/copy-a-string-1.groovy create mode 100644 Task/Copy-a-string/Groovy/copy-a-string-2.groovy create mode 100644 Task/Copy-a-string/HicEst/copy-a-string.hicest create mode 100644 Task/Copy-a-string/Icon/copy-a-string.icon create mode 100644 Task/Copy-a-string/J/copy-a-string.j create mode 100644 Task/Copy-a-string/Java/copy-a-string-1.java create mode 100644 Task/Copy-a-string/Java/copy-a-string-2.java create mode 100644 Task/Copy-a-string/JavaScript/copy-a-string-1.js create mode 100644 Task/Copy-a-string/JavaScript/copy-a-string-2.js create mode 100644 Task/Copy-a-string/Joy/copy-a-string.joy create mode 100644 Task/Copy-a-string/KonsolScript/copy-a-string.konsolscript create mode 100644 Task/Copy-a-string/Lang5/copy-a-string.lang5 create mode 100644 Task/Copy-a-string/Liberty-BASIC/copy-a-string.liberty create mode 100644 Task/Copy-a-string/Lisaac/copy-a-string.lisaac create mode 100644 Task/Copy-a-string/Logo/copy-a-string.logo create mode 100644 Task/Copy-a-string/Lua/copy-a-string.lua create mode 100644 Task/Copy-a-string/MATLAB/copy-a-string.m create mode 100644 Task/Copy-a-string/MAXScript/copy-a-string.maxscript create mode 100644 Task/Copy-a-string/MUMPS/copy-a-string.mumps create mode 100644 Task/Copy-a-string/Maple/copy-a-string.maple create mode 100644 Task/Copy-a-string/Mathematica/copy-a-string.math create mode 100644 Task/Copy-a-string/Maxima/copy-a-string.maxima create mode 100644 Task/Copy-a-string/Metafont/copy-a-string.metafont create mode 100644 Task/Copy-a-string/Mirah/copy-a-string.mirah create mode 100644 Task/Copy-a-string/Modula-3/copy-a-string.mod3 create mode 100644 Task/Copy-a-string/Nemerle/copy-a-string.nemerle create mode 100644 Task/Copy-a-string/NetRexx/copy-a-string.netrexx create mode 100644 Task/Copy-a-string/NewLISP/copy-a-string.newlisp create mode 100644 Task/Copy-a-string/OCaml/copy-a-string.ocaml create mode 100644 Task/Copy-a-string/Oberon-2/copy-a-string.oberon-2 create mode 100644 Task/Copy-a-string/Objeck/copy-a-string.objeck create mode 100644 Task/Copy-a-string/Objective-C/copy-a-string-1.m create mode 100644 Task/Copy-a-string/Objective-C/copy-a-string-2.m create mode 100644 Task/Copy-a-string/Objective-C/copy-a-string-3.m create mode 100644 Task/Copy-a-string/Objective-C/copy-a-string-4.m create mode 100644 Task/Copy-a-string/Octave/copy-a-string.octave create mode 100644 Task/Copy-a-string/OxygenBasic/copy-a-string.oxy create mode 100644 Task/Copy-a-string/PARI-GP/copy-a-string-1.pari create mode 100644 Task/Copy-a-string/PARI-GP/copy-a-string-2.pari create mode 100644 Task/Copy-a-string/PHP/copy-a-string.php create mode 100644 Task/Copy-a-string/PL-I/copy-a-string.pli create mode 100644 Task/Copy-a-string/Pascal/copy-a-string.pascal create mode 100644 Task/Copy-a-string/Perl-6/copy-a-string-1.pl6 create mode 100644 Task/Copy-a-string/Perl-6/copy-a-string-2.pl6 create mode 100644 Task/Copy-a-string/Perl-6/copy-a-string-3.pl6 create mode 100644 Task/Copy-a-string/Perl/copy-a-string-1.pl create mode 100644 Task/Copy-a-string/Perl/copy-a-string-2.pl create mode 100644 Task/Copy-a-string/Perl/copy-a-string-3.pl create mode 100644 Task/Copy-a-string/Perl/copy-a-string-4.pl create mode 100644 Task/Copy-a-string/PicoLisp/copy-a-string.l create mode 100644 Task/Copy-a-string/Pike/copy-a-string.pike create mode 100644 Task/Copy-a-string/Pop11/copy-a-string-1.pop11 create mode 100644 Task/Copy-a-string/Pop11/copy-a-string-2.pop11 create mode 100644 Task/Copy-a-string/PostScript/copy-a-string.ps create mode 100644 Task/Copy-a-string/PowerShell/copy-a-string-1.psh create mode 100644 Task/Copy-a-string/PowerShell/copy-a-string-2.psh create mode 100644 Task/Copy-a-string/ProDOS/copy-a-string.dos create mode 100644 Task/Copy-a-string/PureBasic/copy-a-string.purebasic create mode 100644 Task/Copy-a-string/Python/copy-a-string-1.py create mode 100644 Task/Copy-a-string/Python/copy-a-string-2.py create mode 100644 Task/Copy-a-string/R/copy-a-string.r create mode 100644 Task/Copy-a-string/REBOL/copy-a-string.rebol create mode 100644 Task/Copy-a-string/REXX/copy-a-string.rexx create mode 100644 Task/Copy-a-string/RLaB/copy-a-string.rlab create mode 100644 Task/Copy-a-string/Raven/copy-a-string-1.raven create mode 100644 Task/Copy-a-string/Raven/copy-a-string-2.raven create mode 100644 Task/Copy-a-string/Retro/copy-a-string.retro create mode 100644 Task/Copy-a-string/Ruby/copy-a-string.rb create mode 100644 Task/Copy-a-string/Run-BASIC/copy-a-string.run create mode 100644 Task/Copy-a-string/SNOBOL4/copy-a-string.sno create mode 100644 Task/Copy-a-string/Sather/copy-a-string.sa create mode 100644 Task/Copy-a-string/Scala/copy-a-string.scala create mode 100644 Task/Copy-a-string/Scheme/copy-a-string.ss create mode 100644 Task/Copy-a-string/Seed7/copy-a-string.seed7 create mode 100644 Task/Copy-a-string/Shiny/copy-a-string.shiny create mode 100644 Task/Copy-a-string/Slate/copy-a-string.slate create mode 100644 Task/Copy-a-string/Smalltalk/copy-a-string.st create mode 100644 Task/Copy-a-string/Standard-ML/copy-a-string-1.ml create mode 100644 Task/Copy-a-string/Standard-ML/copy-a-string-2.ml create mode 100644 Task/Copy-a-string/TI-83-BASIC/copy-a-string.ti-83 create mode 100644 Task/Copy-a-string/TI-89-BASIC/copy-a-string.ti-89 create mode 100644 Task/Copy-a-string/TUSCRIPT/copy-a-string.tuscript create mode 100644 Task/Copy-a-string/Tcl/copy-a-string.tcl create mode 100644 Task/Copy-a-string/Toka/copy-a-string.toka create mode 100644 Task/Copy-a-string/Trith/copy-a-string.trith create mode 100644 Task/Copy-a-string/UNIX-Shell/copy-a-string.sh create mode 100644 Task/Copy-a-string/V/copy-a-string.v create mode 100644 Task/Copy-a-string/Visual-Basic-.NET/copy-a-string-1.visual create mode 100644 Task/Copy-a-string/Visual-Basic-.NET/copy-a-string-2.visual create mode 100644 Task/Copy-a-string/XPL0/copy-a-string.xpl0 create mode 100644 Task/Copy-a-string/ZX-Spectrum-Basic/copy-a-string.zx create mode 100644 Task/Dragon-curve/0DESCRIPTION create mode 100644 Task/Dragon-curve/1META.yaml create mode 100644 Task/Dragon-curve/ALGOL-68/dragon-curve.alg create mode 100644 Task/Dragon-curve/BASIC/dragon-curve.basic create mode 100644 Task/Dragon-curve/BASIC256/dragon-curve.basic256 create mode 100644 Task/Dragon-curve/BBC-BASIC/dragon-curve.bbc create mode 100644 Task/Dragon-curve/C/dragon-curve.c create mode 100644 Task/Dragon-curve/Common-Lisp/dragon-curve.lisp create mode 100644 Task/Dragon-curve/D/dragon-curve-1.d create mode 100644 Task/Dragon-curve/D/dragon-curve-2.d create mode 100644 Task/Dragon-curve/Emacs-Lisp/dragon-curve.l create mode 100644 Task/Dragon-curve/Factor/dragon-curve.factor create mode 100644 Task/Dragon-curve/Forth/dragon-curve-1.fth create mode 100644 Task/Dragon-curve/Forth/dragon-curve-2.fth create mode 100644 Task/Dragon-curve/Go/dragon-curve-1.go create mode 100644 Task/Dragon-curve/Go/dragon-curve-2.go create mode 100644 Task/Dragon-curve/Haskell/dragon-curve-1.hs create mode 100644 Task/Dragon-curve/Haskell/dragon-curve-2.hs create mode 100644 Task/Dragon-curve/HicEst/dragon-curve.hicest create mode 100644 Task/Dragon-curve/Icon/dragon-curve.icon create mode 100644 Task/Dragon-curve/J/dragon-curve-1.j create mode 100644 Task/Dragon-curve/J/dragon-curve-2.j create mode 100644 Task/Dragon-curve/J/dragon-curve-3.j create mode 100644 Task/Dragon-curve/Java/dragon-curve.java create mode 100644 Task/Dragon-curve/JavaScript/dragon-curve-1.js create mode 100644 Task/Dragon-curve/JavaScript/dragon-curve-2.js create mode 100644 Task/Dragon-curve/Liberty-BASIC/dragon-curve.liberty create mode 100644 Task/Dragon-curve/Logo/dragon-curve-1.logo create mode 100644 Task/Dragon-curve/Logo/dragon-curve-2.logo create mode 100644 Task/Dragon-curve/Logo/dragon-curve-3.logo create mode 100644 Task/Dragon-curve/Logo/dragon-curve-4.logo create mode 100644 Task/Dragon-curve/Logo/dragon-curve-5.logo create mode 100644 Task/Dragon-curve/Lua/dragon-curve.lua create mode 100644 Task/Dragon-curve/Mathematica/dragon-curve.math create mode 100644 Task/Dragon-curve/Metafont/dragon-curve.metafont create mode 100644 Task/Dragon-curve/OCaml/dragon-curve-1.ocaml create mode 100644 Task/Dragon-curve/OCaml/dragon-curve-2.ocaml create mode 100644 Task/Dragon-curve/Pascal/dragon-curve-1.pascal create mode 100644 Task/Dragon-curve/Pascal/dragon-curve-2.pascal create mode 100644 Task/Dragon-curve/Perl-6/dragon-curve.pl6 create mode 100644 Task/Dragon-curve/PicoLisp/dragon-curve.l create mode 100644 Task/Dragon-curve/PostScript/dragon-curve-1.ps create mode 100644 Task/Dragon-curve/PostScript/dragon-curve-2.ps create mode 100644 Task/Dragon-curve/Prolog/dragon-curve.pro create mode 100644 Task/Dragon-curve/PureBasic/dragon-curve.purebasic create mode 100644 Task/Dragon-curve/Python/dragon-curve-1.py create mode 100644 Task/Dragon-curve/Python/dragon-curve-2.py create mode 100644 Task/Dragon-curve/Python/dragon-curve-3.py create mode 100644 Task/Dragon-curve/REXX/dragon-curve.rexx create mode 100644 Task/Dragon-curve/Racket/dragon-curve.rkt create mode 100644 Task/Dragon-curve/RapidQ/dragon-curve.rapidq create mode 100644 Task/Dragon-curve/Ruby/dragon-curve.rb create mode 100644 Task/Dragon-curve/Run-BASIC/dragon-curve.run create mode 100644 Task/Dragon-curve/Seed7/dragon-curve.seed7 create mode 100644 Task/Dragon-curve/TI-89-BASIC/dragon-curve.ti-89 create mode 100644 Task/Dragon-curve/Tcl/dragon-curve.tcl create mode 100644 Task/Dragon-curve/Vedit-macro-language/dragon-curve.vedit create mode 100644 Task/Dragon-curve/X86-Assembly/dragon-curve.x86 create mode 100644 Task/Dragon-curve/XPL0/dragon-curve.xpl0 create mode 100644 Task/Environment-variables/0DESCRIPTION create mode 100644 Task/Environment-variables/1META.yaml create mode 100644 Task/Environment-variables/ALGOL-68/environment-variables.alg create mode 100644 Task/Environment-variables/AWK/environment-variables-1.awk create mode 100644 Task/Environment-variables/AWK/environment-variables-2.awk create mode 100644 Task/Environment-variables/Ada/environment-variables-1.ada create mode 100644 Task/Environment-variables/Ada/environment-variables-2.ada create mode 100644 Task/Environment-variables/Ada/environment-variables-3.ada create mode 100644 Task/Environment-variables/AutoHotkey/environment-variables.ahk create mode 100644 Task/Environment-variables/BASIC/environment-variables-1.basic create mode 100644 Task/Environment-variables/BASIC/environment-variables-2.basic create mode 100644 Task/Environment-variables/BBC-BASIC/environment-variables.bbc create mode 100644 Task/Environment-variables/Batch-File/environment-variables-1.bat create mode 100644 Task/Environment-variables/Batch-File/environment-variables-2.bat create mode 100644 Task/Environment-variables/C++/environment-variables.cpp create mode 100644 Task/Environment-variables/C/environment-variables.c create mode 100644 Task/Environment-variables/Clojure/environment-variables.clj create mode 100644 Task/Environment-variables/CoffeeScript/environment-variables.coffeescript create mode 100644 Task/Environment-variables/Common-Lisp/environment-variables-1.lisp create mode 100644 Task/Environment-variables/Common-Lisp/environment-variables-2.lisp create mode 100644 Task/Environment-variables/Common-Lisp/environment-variables-3.lisp create mode 100644 Task/Environment-variables/Common-Lisp/environment-variables-4.lisp create mode 100644 Task/Environment-variables/D/environment-variables-1.d create mode 100644 Task/Environment-variables/D/environment-variables-2.d create mode 100644 Task/Environment-variables/Delphi/environment-variables.delphi create mode 100644 Task/Environment-variables/E/environment-variables.e create mode 100644 Task/Environment-variables/Eiffel/environment-variables.e create mode 100644 Task/Environment-variables/Emacs-Lisp/environment-variables.l create mode 100644 Task/Environment-variables/Euphoria/environment-variables.euphoria create mode 100644 Task/Environment-variables/Factor/environment-variables.factor create mode 100644 Task/Environment-variables/Forth/environment-variables.fth create mode 100644 Task/Environment-variables/Fortran/environment-variables.f create mode 100644 Task/Environment-variables/Go/environment-variables-1.go create mode 100644 Task/Environment-variables/Go/environment-variables-2.go create mode 100644 Task/Environment-variables/Groovy/environment-variables.groovy create mode 100644 Task/Environment-variables/Haskell/environment-variables.hs create mode 100644 Task/Environment-variables/HicEst/environment-variables.hicest create mode 100644 Task/Environment-variables/Icon/environment-variables.icon create mode 100644 Task/Environment-variables/J/environment-variables.j create mode 100644 Task/Environment-variables/Java/environment-variables.java create mode 100644 Task/Environment-variables/JavaScript/environment-variables.js create mode 100644 Task/Environment-variables/Joy/environment-variables.joy create mode 100644 Task/Environment-variables/K/environment-variables.k create mode 100644 Task/Environment-variables/LSL/environment-variables.lsl create mode 100644 Task/Environment-variables/Liberty-BASIC/environment-variables-1.liberty create mode 100644 Task/Environment-variables/Liberty-BASIC/environment-variables-2.liberty create mode 100644 Task/Environment-variables/Lua/environment-variables.lua create mode 100644 Task/Environment-variables/MATLAB/environment-variables.m create mode 100644 Task/Environment-variables/MUMPS/environment-variables.mumps create mode 100644 Task/Environment-variables/Mathematica/environment-variables.math create mode 100644 Task/Environment-variables/Mercury/environment-variables.mercury create mode 100644 Task/Environment-variables/NSIS/environment-variables.nsis create mode 100644 Task/Environment-variables/NetRexx/environment-variables.netrexx create mode 100644 Task/Environment-variables/NewLISP/environment-variables.newlisp create mode 100644 Task/Environment-variables/OCaml/environment-variables.ocaml create mode 100644 Task/Environment-variables/Objective-C/environment-variables.m create mode 100644 Task/Environment-variables/Oz/environment-variables.oz create mode 100644 Task/Environment-variables/PARI-GP/environment-variables-1.pari create mode 100644 Task/Environment-variables/PARI-GP/environment-variables-2.pari create mode 100644 Task/Environment-variables/PARI-GP/environment-variables-3.pari create mode 100644 Task/Environment-variables/PARI-GP/environment-variables-4.pari create mode 100644 Task/Environment-variables/PARI-GP/environment-variables-5.pari create mode 100644 Task/Environment-variables/PHP/environment-variables.php create mode 100644 Task/Environment-variables/Perl-6/environment-variables.pl6 create mode 100644 Task/Environment-variables/Perl/environment-variables.pl create mode 100644 Task/Environment-variables/PicoLisp/environment-variables.l create mode 100644 Task/Environment-variables/PowerShell/environment-variables-1.psh create mode 100644 Task/Environment-variables/PowerShell/environment-variables-2.psh create mode 100644 Task/Environment-variables/PureBasic/environment-variables-1.purebasic create mode 100644 Task/Environment-variables/PureBasic/environment-variables-2.purebasic create mode 100644 Task/Environment-variables/Python/environment-variables.py create mode 100644 Task/Environment-variables/R/environment-variables.r create mode 100644 Task/Environment-variables/REBOL/environment-variables.rebol create mode 100644 Task/Environment-variables/REXX/environment-variables-1.rexx create mode 100644 Task/Environment-variables/REXX/environment-variables-2.rexx create mode 100644 Task/Environment-variables/REXX/environment-variables-3.rexx create mode 100644 Task/Environment-variables/Racket/environment-variables.rkt create mode 100644 Task/Environment-variables/Retro/environment-variables.retro create mode 100644 Task/Environment-variables/Ruby/environment-variables.rb create mode 100644 Task/Environment-variables/Run-BASIC/environment-variables.run create mode 100644 Task/Environment-variables/SNOBOL4/environment-variables.sno create mode 100644 Task/Environment-variables/Seed7/environment-variables.seed7 create mode 100644 Task/Environment-variables/Slate/environment-variables.slate create mode 100644 Task/Environment-variables/Standard-ML/environment-variables.ml create mode 100644 Task/Environment-variables/TXR/environment-variables-1.txr create mode 100644 Task/Environment-variables/TXR/environment-variables-2.txr create mode 100644 Task/Environment-variables/TXR/environment-variables-3.txr create mode 100644 Task/Environment-variables/Tcl/environment-variables.tcl create mode 100644 Task/Environment-variables/UNIX-Shell/environment-variables-1.sh create mode 100644 Task/Environment-variables/UNIX-Shell/environment-variables-2.sh create mode 100644 Task/Environment-variables/Ursala/environment-variables.ursala create mode 100644 Task/Environment-variables/Vedit-macro-language/environment-variables-1.vedit create mode 100644 Task/Environment-variables/Vedit-macro-language/environment-variables-2.vedit create mode 100644 Task/Environment-variables/XPL0/environment-variables.xpl0 create mode 100644 Task/Execute-SNUSP/0DESCRIPTION create mode 100644 Task/Execute-SNUSP/1META.yaml create mode 100644 Task/Execute-a-Markov-algorithm/0DESCRIPTION create mode 100644 Task/Execute-a-Markov-algorithm/1META.yaml create mode 100644 Task/Execute-a-Markov-algorithm/Ada/execute-a-markov-algorithm-1.ada create mode 100644 Task/Execute-a-Markov-algorithm/Ada/execute-a-markov-algorithm-2.ada create mode 100644 Task/Execute-a-Markov-algorithm/Ada/execute-a-markov-algorithm-3.ada create mode 100644 Task/Execute-a-Markov-algorithm/AutoHotkey/execute-a-markov-algorithm.ahk create mode 100644 Task/Execute-a-Markov-algorithm/BBC-BASIC/execute-a-markov-algorithm.bbc create mode 100644 Task/Execute-a-Markov-algorithm/C++/execute-a-markov-algorithm.cpp create mode 100644 Task/Execute-a-Markov-algorithm/C/execute-a-markov-algorithm-1.c create mode 100644 Task/Execute-a-Markov-algorithm/C/execute-a-markov-algorithm-2.c create mode 100644 Task/Execute-a-Markov-algorithm/D/execute-a-markov-algorithm.d create mode 100644 Task/Execute-a-Markov-algorithm/Go/execute-a-markov-algorithm-1.go create mode 100644 Task/Execute-a-Markov-algorithm/Go/execute-a-markov-algorithm-2.go create mode 100644 Task/Execute-a-Markov-algorithm/Groovy/execute-a-markov-algorithm-1.groovy create mode 100644 Task/Execute-a-Markov-algorithm/Groovy/execute-a-markov-algorithm-2.groovy create mode 100644 Task/Execute-a-Markov-algorithm/Haskell/execute-a-markov-algorithm.hs create mode 100644 Task/Execute-a-Markov-algorithm/Icon/execute-a-markov-algorithm.icon create mode 100644 Task/Execute-a-Markov-algorithm/J/execute-a-markov-algorithm-1.j create mode 100644 Task/Execute-a-Markov-algorithm/J/execute-a-markov-algorithm-2.j create mode 100644 Task/Execute-a-Markov-algorithm/Mathematica/execute-a-markov-algorithm-1.math create mode 100644 Task/Execute-a-Markov-algorithm/Mathematica/execute-a-markov-algorithm-2.math create mode 100644 Task/Execute-a-Markov-algorithm/Perl/execute-a-markov-algorithm.pl create mode 100644 Task/Execute-a-Markov-algorithm/PicoLisp/execute-a-markov-algorithm.l create mode 100644 Task/Execute-a-Markov-algorithm/PureBasic/execute-a-markov-algorithm.purebasic create mode 100644 Task/Execute-a-Markov-algorithm/Python/execute-a-markov-algorithm.py create mode 100644 Task/Execute-a-Markov-algorithm/REXX/execute-a-markov-algorithm.rexx create mode 100644 Task/Execute-a-Markov-algorithm/Ruby/execute-a-markov-algorithm.rb create mode 100644 Task/Execute-a-Markov-algorithm/Scala/execute-a-markov-algorithm-1.scala create mode 100644 Task/Execute-a-Markov-algorithm/Scala/execute-a-markov-algorithm-2.scala create mode 100644 Task/Execute-a-Markov-algorithm/Scheme/execute-a-markov-algorithm.ss create mode 100644 Task/Execute-a-Markov-algorithm/Tcl/execute-a-markov-algorithm-1.tcl create mode 100644 Task/Execute-a-Markov-algorithm/Tcl/execute-a-markov-algorithm-2.tcl create mode 100644 Task/Execute-a-Markov-algorithm/VBScript/execute-a-markov-algorithm-1.vbscript create mode 100644 Task/Execute-a-Markov-algorithm/VBScript/execute-a-markov-algorithm-2.vbscript create mode 100644 Task/Execute-a-Markov-algorithm/VBScript/execute-a-markov-algorithm-3.vbscript rename Task/{Guess-the-number-With-feedback-player => Guess-the-number-With-feedback--player-}/0DESCRIPTION (100%) rename Task/{Guess-the-number-With-feedback-player => Guess-the-number-With-feedback--player-}/1META.yaml (100%) rename Task/{Guess-the-number-With-feedback-player/Ada/guess-the-number-with-feedback-player.ada => Guess-the-number-With-feedback--player-/Ada/guess-the-number-with-feedback--player-.ada} (100%) rename Task/{Guess-the-number-With-feedback-player/AutoHotkey/guess-the-number-with-feedback-player.ahk => Guess-the-number-With-feedback--player-/AutoHotkey/guess-the-number-with-feedback--player-.ahk} (100%) rename Task/{Guess-the-number-With-feedback-player/BBC-BASIC/guess-the-number-with-feedback-player.bbc => Guess-the-number-With-feedback--player-/BBC-BASIC/guess-the-number-with-feedback--player-.bbc} (100%) rename Task/{Guess-the-number-With-feedback-player/C++/guess-the-number-with-feedback-player.cpp => Guess-the-number-With-feedback--player-/C++/guess-the-number-with-feedback--player-.cpp} (100%) rename Task/{Guess-the-number-With-feedback-player/C/guess-the-number-with-feedback-player.c => Guess-the-number-With-feedback--player-/C/guess-the-number-with-feedback--player-.c} (100%) rename Task/{Guess-the-number-With-feedback-player/Clojure/guess-the-number-with-feedback-player.clj => Guess-the-number-With-feedback--player-/Clojure/guess-the-number-with-feedback--player-.clj} (100%) rename Task/{Guess-the-number-With-feedback-player/D/guess-the-number-with-feedback-player.d => Guess-the-number-With-feedback--player-/D/guess-the-number-with-feedback--player-.d} (100%) rename Task/{Guess-the-number-With-feedback-player/Euphoria/guess-the-number-with-feedback-player.euphoria => Guess-the-number-With-feedback--player-/Euphoria/guess-the-number-with-feedback--player-.euphoria} (100%) rename Task/{Guess-the-number-With-feedback-player/Fantom/guess-the-number-with-feedback-player.fantom => Guess-the-number-With-feedback--player-/Fantom/guess-the-number-with-feedback--player-.fantom} (100%) rename Task/{Guess-the-number-With-feedback-player/Fortran/guess-the-number-with-feedback-player.f => Guess-the-number-With-feedback--player-/Fortran/guess-the-number-with-feedback--player-.f} (100%) rename Task/{Guess-the-number-With-feedback-player/Go/guess-the-number-with-feedback-player-1.go => Guess-the-number-With-feedback--player-/Go/guess-the-number-with-feedback--player--1.go} (100%) rename Task/{Guess-the-number-With-feedback-player/Go/guess-the-number-with-feedback-player-2.go => Guess-the-number-With-feedback--player-/Go/guess-the-number-with-feedback--player--2.go} (100%) rename Task/{Guess-the-number-With-feedback-player/Icon/guess-the-number-with-feedback-player.icon => Guess-the-number-With-feedback--player-/Icon/guess-the-number-with-feedback--player-.icon} (100%) rename Task/{Guess-the-number-With-feedback-player/J/guess-the-number-with-feedback-player-1.j => Guess-the-number-With-feedback--player-/J/guess-the-number-with-feedback--player--1.j} (100%) rename Task/{Guess-the-number-With-feedback-player/J/guess-the-number-with-feedback-player-2.j => Guess-the-number-With-feedback--player-/J/guess-the-number-with-feedback--player--2.j} (100%) rename Task/{Guess-the-number-With-feedback-player/Java/guess-the-number-with-feedback-player.java => Guess-the-number-With-feedback--player-/Java/guess-the-number-with-feedback--player-.java} (100%) rename Task/{Guess-the-number-With-feedback-player/JavaScript/guess-the-number-with-feedback-player.js => Guess-the-number-With-feedback--player-/JavaScript/guess-the-number-with-feedback--player-.js} (100%) rename Task/{Guess-the-number-With-feedback-player/Liberty-BASIC/guess-the-number-with-feedback-player.liberty => Guess-the-number-With-feedback--player-/Liberty-BASIC/guess-the-number-with-feedback--player-.liberty} (100%) rename Task/{Guess-the-number-With-feedback-player/Mathematica/guess-the-number-with-feedback-player.math => Guess-the-number-With-feedback--player-/Mathematica/guess-the-number-with-feedback--player-.math} (100%) rename Task/{Guess-the-number-With-feedback-player/Modula-2/guess-the-number-with-feedback-player.mod2 => Guess-the-number-With-feedback--player-/Modula-2/guess-the-number-with-feedback--player-.mod2} (100%) rename Task/{Guess-the-number-With-feedback-player/Objective-C/guess-the-number-with-feedback-player.m => Guess-the-number-With-feedback--player-/Objective-C/guess-the-number-with-feedback--player-.m} (100%) rename Task/{Guess-the-number-With-feedback-player/PARI-GP/guess-the-number-with-feedback-player.pari => Guess-the-number-With-feedback--player-/PARI-GP/guess-the-number-with-feedback--player-.pari} (100%) rename Task/{Guess-the-number-With-feedback-player/Pascal/guess-the-number-with-feedback-player.pascal => Guess-the-number-With-feedback--player-/Pascal/guess-the-number-with-feedback--player-.pascal} (100%) rename Task/{Guess-the-number-With-feedback-player/Perl-6/guess-the-number-with-feedback-player.pl6 => Guess-the-number-With-feedback--player-/Perl-6/guess-the-number-with-feedback--player-.pl6} (100%) rename Task/{Guess-the-number-With-feedback-player/Perl/guess-the-number-with-feedback-player.pl => Guess-the-number-With-feedback--player-/Perl/guess-the-number-with-feedback--player-.pl} (100%) rename Task/{Guess-the-number-With-feedback-player/PicoLisp/guess-the-number-with-feedback-player.l => Guess-the-number-With-feedback--player-/PicoLisp/guess-the-number-with-feedback--player-.l} (100%) rename Task/{Guess-the-number-With-feedback-player/PureBasic/guess-the-number-with-feedback-player.purebasic => Guess-the-number-With-feedback--player-/PureBasic/guess-the-number-with-feedback--player-.purebasic} (100%) rename Task/{Guess-the-number-With-feedback-player/Python/guess-the-number-with-feedback-player-1.py => Guess-the-number-With-feedback--player-/Python/guess-the-number-with-feedback--player--1.py} (100%) rename Task/{Guess-the-number-With-feedback-player/Python/guess-the-number-with-feedback-player-2.py => Guess-the-number-With-feedback--player-/Python/guess-the-number-with-feedback--player--2.py} (100%) rename Task/{Guess-the-number-With-feedback-player/REXX/guess-the-number-with-feedback-player-1.rexx => Guess-the-number-With-feedback--player-/REXX/guess-the-number-with-feedback--player--1.rexx} (100%) rename Task/{Guess-the-number-With-feedback-player/REXX/guess-the-number-with-feedback-player-2.rexx => Guess-the-number-With-feedback--player-/REXX/guess-the-number-with-feedback--player--2.rexx} (100%) rename Task/{Guess-the-number-With-feedback-player/Ruby/guess-the-number-with-feedback-player.rb => Guess-the-number-With-feedback--player-/Ruby/guess-the-number-with-feedback--player-.rb} (100%) rename Task/{Guess-the-number-With-feedback-player/Scheme/guess-the-number-with-feedback-player.ss => Guess-the-number-With-feedback--player-/Scheme/guess-the-number-with-feedback--player-.ss} (100%) rename Task/{Guess-the-number-With-feedback-player/Smalltalk/guess-the-number-with-feedback-player-1.st => Guess-the-number-With-feedback--player-/Smalltalk/guess-the-number-with-feedback--player--1.st} (100%) rename Task/{Guess-the-number-With-feedback-player/Smalltalk/guess-the-number-with-feedback-player-2.st => Guess-the-number-With-feedback--player-/Smalltalk/guess-the-number-with-feedback--player--2.st} (100%) rename Task/{Guess-the-number-With-feedback-player/Smalltalk/guess-the-number-with-feedback-player-3.st => Guess-the-number-With-feedback--player-/Smalltalk/guess-the-number-with-feedback--player--3.st} (100%) rename Task/{Guess-the-number-With-feedback-player/Smalltalk/guess-the-number-with-feedback-player-4.st => Guess-the-number-With-feedback--player-/Smalltalk/guess-the-number-with-feedback--player--4.st} (100%) rename Task/{Guess-the-number-With-feedback-player/Tcl/guess-the-number-with-feedback-player.tcl => Guess-the-number-With-feedback--player-/Tcl/guess-the-number-with-feedback--player-.tcl} (100%) rename Task/{Guess-the-number-With-feedback-player/XPL0/guess-the-number-with-feedback-player.xpl0 => Guess-the-number-With-feedback--player-/XPL0/guess-the-number-with-feedback--player-.xpl0} (100%) create mode 100644 Task/Loops-Infinite/6800-Assembly/loops-infinite.6800 create mode 100644 Task/N-queens-problem/0DESCRIPTION create mode 100644 Task/N-queens-problem/ALGOL-68/n-queens-problem.alg create mode 100644 Task/N-queens-problem/Ada/n-queens-problem.ada create mode 100644 Task/N-queens-problem/AutoHotkey/n-queens-problem-1.ahk create mode 100644 Task/N-queens-problem/AutoHotkey/n-queens-problem-2.ahk create mode 100644 Task/N-queens-problem/BBC-BASIC/n-queens-problem.bbc create mode 100644 Task/N-queens-problem/BCPL/n-queens-problem-1.bcpl create mode 100644 Task/N-queens-problem/BCPL/n-queens-problem-2.bcpl create mode 100644 Task/N-queens-problem/C/n-queens-problem-1.c create mode 100644 Task/N-queens-problem/C/n-queens-problem-2.c create mode 100644 Task/N-queens-problem/C/n-queens-problem-3.c create mode 100644 Task/N-queens-problem/Clojure/n-queens-problem.clj create mode 100644 Task/N-queens-problem/CoffeeScript/n-queens-problem.coffeescript create mode 100644 Task/N-queens-problem/Common-Lisp/n-queens-problem.lisp create mode 100644 Task/N-queens-problem/Curry/n-queens-problem-1.curry create mode 100644 Task/N-queens-problem/Curry/n-queens-problem-2.curry create mode 100644 Task/N-queens-problem/Curry/n-queens-problem-3.curry create mode 100644 Task/N-queens-problem/D/n-queens-problem-1.d create mode 100644 Task/N-queens-problem/D/n-queens-problem-2.d create mode 100644 Task/N-queens-problem/Dart/n-queens-problem.dart create mode 100644 Task/N-queens-problem/Factor/n-queens-problem.factor create mode 100644 Task/N-queens-problem/Forth/n-queens-problem.fth create mode 100644 Task/N-queens-problem/Fortran/n-queens-problem-1.f create mode 100644 Task/N-queens-problem/Fortran/n-queens-problem-2.f create mode 100644 Task/N-queens-problem/Fortran/n-queens-problem-3.f create mode 100644 Task/N-queens-problem/Go/n-queens-problem.go create mode 100644 Task/N-queens-problem/Groovy/n-queens-problem-1.groovy create mode 100644 Task/N-queens-problem/Groovy/n-queens-problem-2.groovy create mode 100644 Task/N-queens-problem/Groovy/n-queens-problem-3.groovy create mode 100644 Task/N-queens-problem/Haskell/n-queens-problem.hs create mode 100644 Task/N-queens-problem/Heron/n-queens-problem.heron create mode 100644 Task/N-queens-problem/Icon/n-queens-problem-1.icon create mode 100644 Task/N-queens-problem/Icon/n-queens-problem-2.icon create mode 100644 Task/N-queens-problem/Icon/n-queens-problem-3.icon create mode 100644 Task/N-queens-problem/J/n-queens-problem.j create mode 100644 Task/N-queens-problem/Java/n-queens-problem.java create mode 100644 Task/N-queens-problem/Locomotive-Basic/n-queens-problem.locomotive create mode 100644 Task/N-queens-problem/Logo/n-queens-problem.logo create mode 100644 Task/N-queens-problem/Lua/n-queens-problem.lua create mode 100644 Task/N-queens-problem/MUMPS/n-queens-problem.mumps create mode 100644 Task/N-queens-problem/Mathematica/n-queens-problem-1.math create mode 100644 Task/N-queens-problem/Mathematica/n-queens-problem-2.math create mode 100644 Task/N-queens-problem/Maxima/n-queens-problem.maxima create mode 100644 Task/N-queens-problem/OCaml/n-queens-problem-1.ocaml create mode 100644 Task/N-queens-problem/OCaml/n-queens-problem-2.ocaml create mode 100644 Task/N-queens-problem/Objeck/n-queens-problem.objeck create mode 100644 Task/N-queens-problem/Oz/n-queens-problem.oz create mode 100644 Task/N-queens-problem/PHP/n-queens-problem.php create mode 100644 Task/N-queens-problem/Pascal/n-queens-problem.pascal create mode 100644 Task/N-queens-problem/Perl-6/n-queens-problem.pl6 create mode 100644 Task/N-queens-problem/Perl/n-queens-problem.pl create mode 100644 Task/N-queens-problem/PicoLisp/n-queens-problem-1.l create mode 100644 Task/N-queens-problem/PicoLisp/n-queens-problem-2.l create mode 100644 Task/N-queens-problem/PowerBASIC/n-queens-problem.powerbasic create mode 100644 Task/N-queens-problem/Prolog/n-queens-problem-1.pro create mode 100644 Task/N-queens-problem/Prolog/n-queens-problem-2.pro create mode 100644 Task/N-queens-problem/Prolog/n-queens-problem-3.pro create mode 100644 Task/N-queens-problem/PureBasic/n-queens-problem.purebasic create mode 100644 Task/N-queens-problem/Python/n-queens-problem-1.py create mode 100644 Task/N-queens-problem/Python/n-queens-problem-2.py create mode 100644 Task/N-queens-problem/Python/n-queens-problem-3.py create mode 100644 Task/N-queens-problem/Python/n-queens-problem-4.py create mode 100644 Task/N-queens-problem/R/n-queens-problem.r create mode 100644 Task/N-queens-problem/REXX/n-queens-problem.rexx create mode 100644 Task/N-queens-problem/Rascal/n-queens-problem.rascal create mode 100644 Task/N-queens-problem/Ruby/n-queens-problem.rb create mode 100644 Task/N-queens-problem/SAS/n-queens-problem.sas create mode 100644 Task/N-queens-problem/SNOBOL4/n-queens-problem.sno create mode 100644 Task/N-queens-problem/Scala/n-queens-problem.scala create mode 100644 Task/N-queens-problem/Standard-ML/n-queens-problem.ml create mode 100644 Task/N-queens-problem/SystemVerilog/n-queens-problem.v create mode 100644 Task/N-queens-problem/Tcl/n-queens-problem.tcl create mode 100644 Task/N-queens-problem/Ursala/n-queens-problem.ursala create mode 100644 Task/N-queens-problem/XPL0/n-queens-problem.xpl0 create mode 100644 Task/N-queens-problem/XSLT/n-queens-problem-1.xslt create mode 100644 Task/N-queens-problem/XSLT/n-queens-problem-2.xslt create mode 100644 Task/N-queens-problem/Xanadu/n-queens-problem.xanadu create mode 100644 Task/Named-parameters/0DESCRIPTION create mode 100644 Task/Named-parameters/1META.yaml create mode 100644 Task/Named-parameters/ALGOL-68/named-parameters.alg create mode 100644 Task/Named-parameters/Ada/named-parameters-1.ada create mode 100644 Task/Named-parameters/Ada/named-parameters-2.ada create mode 100644 Task/Named-parameters/AppleScript/named-parameters-1.applescript create mode 100644 Task/Named-parameters/AppleScript/named-parameters-2.applescript create mode 100644 Task/Named-parameters/AutoHotkey/named-parameters.ahk create mode 100644 Task/Named-parameters/C++/named-parameters-1.cpp create mode 100644 Task/Named-parameters/C++/named-parameters-2.cpp create mode 100644 Task/Named-parameters/C++/named-parameters-3.cpp create mode 100644 Task/Named-parameters/C++/named-parameters-4.cpp create mode 100644 Task/Named-parameters/C++/named-parameters-5.cpp create mode 100644 Task/Named-parameters/C/named-parameters.c create mode 100644 Task/Named-parameters/Clojure/named-parameters-1.clj create mode 100644 Task/Named-parameters/Clojure/named-parameters-2.clj create mode 100644 Task/Named-parameters/Clojure/named-parameters-3.clj create mode 100644 Task/Named-parameters/Common-Lisp/named-parameters-1.lisp create mode 100644 Task/Named-parameters/Common-Lisp/named-parameters-2.lisp create mode 100644 Task/Named-parameters/E/named-parameters-1.e create mode 100644 Task/Named-parameters/E/named-parameters-2.e create mode 100644 Task/Named-parameters/Fortran/named-parameters-1.f create mode 100644 Task/Named-parameters/Fortran/named-parameters-2.f create mode 100644 Task/Named-parameters/Fortran/named-parameters-3.f create mode 100644 Task/Named-parameters/Fortran/named-parameters-4.f create mode 100644 Task/Named-parameters/Haskell/named-parameters-1.hs create mode 100644 Task/Named-parameters/Haskell/named-parameters-2.hs create mode 100644 Task/Named-parameters/Icon/named-parameters.icon create mode 100644 Task/Named-parameters/J/named-parameters.j create mode 100644 Task/Named-parameters/Java/named-parameters.java create mode 100644 Task/Named-parameters/JavaScript/named-parameters.js create mode 100644 Task/Named-parameters/Lua/named-parameters.lua create mode 100644 Task/Named-parameters/MATLAB/named-parameters.m create mode 100644 Task/Named-parameters/Mathematica/named-parameters.math create mode 100644 Task/Named-parameters/Modula-3/named-parameters-1.mod3 create mode 100644 Task/Named-parameters/Modula-3/named-parameters-2.mod3 create mode 100644 Task/Named-parameters/Nemerle/named-parameters.nemerle create mode 100644 Task/Named-parameters/OCaml/named-parameters.ocaml create mode 100644 Task/Named-parameters/Objective-C/named-parameters-1.m create mode 100644 Task/Named-parameters/Objective-C/named-parameters-2.m create mode 100644 Task/Named-parameters/Objective-C/named-parameters-3.m create mode 100644 Task/Named-parameters/Oz/named-parameters-1.oz create mode 100644 Task/Named-parameters/Oz/named-parameters-2.oz create mode 100644 Task/Named-parameters/Perl-6/named-parameters-1.pl6 create mode 100644 Task/Named-parameters/Perl-6/named-parameters-2.pl6 create mode 100644 Task/Named-parameters/Perl-6/named-parameters-3.pl6 create mode 100644 Task/Named-parameters/Perl/named-parameters-1.pl create mode 100644 Task/Named-parameters/Perl/named-parameters-2.pl create mode 100644 Task/Named-parameters/PicoLisp/named-parameters-1.l create mode 100644 Task/Named-parameters/PicoLisp/named-parameters-2.l create mode 100644 Task/Named-parameters/PowerShell/named-parameters-1.psh create mode 100644 Task/Named-parameters/PowerShell/named-parameters-2.psh create mode 100644 Task/Named-parameters/PowerShell/named-parameters-3.psh create mode 100644 Task/Named-parameters/PowerShell/named-parameters-4.psh create mode 100644 Task/Named-parameters/Python/named-parameters-1.py create mode 100644 Task/Named-parameters/Python/named-parameters-2.py create mode 100644 Task/Named-parameters/R/named-parameters.r create mode 100644 Task/Named-parameters/REXX/named-parameters.rexx create mode 100644 Task/Named-parameters/Racket/named-parameters.rkt create mode 100644 Task/Named-parameters/Ruby/named-parameters-1.rb create mode 100644 Task/Named-parameters/Ruby/named-parameters-2.rb create mode 100644 Task/Named-parameters/Ruby/named-parameters-3.rb create mode 100644 Task/Named-parameters/Scala/named-parameters-1.scala create mode 100644 Task/Named-parameters/Scala/named-parameters-2.scala create mode 100644 Task/Named-parameters/Scheme/named-parameters-1.ss create mode 100644 Task/Named-parameters/Scheme/named-parameters-2.ss create mode 100644 Task/Named-parameters/Smalltalk/named-parameters.st create mode 100644 Task/Named-parameters/Suneido/named-parameters-1.suneido create mode 100644 Task/Named-parameters/Suneido/named-parameters-2.suneido create mode 100644 Task/Named-parameters/Tcl/named-parameters-1.tcl create mode 100644 Task/Named-parameters/Tcl/named-parameters-2.tcl create mode 100644 Task/Named-parameters/Visual-Basic/named-parameters.vb create mode 100644 Task/Named-parameters/XSLT/named-parameters.xslt create mode 100644 Task/Nautical-bell/0DESCRIPTION create mode 100644 Task/Nautical-bell/1META.yaml create mode 100644 Task/Nautical-bell/D/nautical-bell.d create mode 100644 Task/Nautical-bell/Perl-6/nautical-bell.pl6 create mode 100644 Task/Nautical-bell/Python/nautical-bell.py create mode 100644 Task/Nautical-bell/REXX/nautical-bell.rexx create mode 100644 Task/Nautical-bell/Tcl/nautical-bell.tcl create mode 100644 Task/Non-continuous-subsequences/0DESCRIPTION create mode 100644 Task/Non-continuous-subsequences/1META.yaml create mode 100644 Task/Non-continuous-subsequences/ALGOL-68/non-continuous-subsequences-1.alg create mode 100644 Task/Non-continuous-subsequences/ALGOL-68/non-continuous-subsequences-2.alg create mode 100644 Task/Non-continuous-subsequences/Ada/non-continuous-subsequences.ada create mode 100644 Task/Non-continuous-subsequences/AutoHotkey/non-continuous-subsequences.ahk create mode 100644 Task/Non-continuous-subsequences/BBC-BASIC/non-continuous-subsequences.bbc create mode 100644 Task/Non-continuous-subsequences/Bracmat/non-continuous-subsequences.bracmat create mode 100644 Task/Non-continuous-subsequences/C/non-continuous-subsequences-1.c create mode 100644 Task/Non-continuous-subsequences/C/non-continuous-subsequences-2.c create mode 100644 Task/Non-continuous-subsequences/C/non-continuous-subsequences-3.c create mode 100644 Task/Non-continuous-subsequences/Clojure/non-continuous-subsequences.clj create mode 100644 Task/Non-continuous-subsequences/CoffeeScript/non-continuous-subsequences-1.coffeescript create mode 100644 Task/Non-continuous-subsequences/CoffeeScript/non-continuous-subsequences-2.coffeescript create mode 100644 Task/Non-continuous-subsequences/Common-Lisp/non-continuous-subsequences-1.lisp create mode 100644 Task/Non-continuous-subsequences/Common-Lisp/non-continuous-subsequences-2.lisp create mode 100644 Task/Non-continuous-subsequences/D/non-continuous-subsequences-1.d create mode 100644 Task/Non-continuous-subsequences/D/non-continuous-subsequences-2.d create mode 100644 Task/Non-continuous-subsequences/Go/non-continuous-subsequences.go create mode 100644 Task/Non-continuous-subsequences/Haskell/non-continuous-subsequences-1.hs create mode 100644 Task/Non-continuous-subsequences/Haskell/non-continuous-subsequences-2.hs create mode 100644 Task/Non-continuous-subsequences/Haskell/non-continuous-subsequences-3.hs create mode 100644 Task/Non-continuous-subsequences/Haskell/non-continuous-subsequences-4.hs create mode 100644 Task/Non-continuous-subsequences/Haskell/non-continuous-subsequences-5.hs create mode 100644 Task/Non-continuous-subsequences/J/non-continuous-subsequences-1.j create mode 100644 Task/Non-continuous-subsequences/J/non-continuous-subsequences-2.j create mode 100644 Task/Non-continuous-subsequences/J/non-continuous-subsequences-3.j create mode 100644 Task/Non-continuous-subsequences/JavaScript/non-continuous-subsequences.js create mode 100644 Task/Non-continuous-subsequences/Mathematica/non-continuous-subsequences-1.math create mode 100644 Task/Non-continuous-subsequences/Mathematica/non-continuous-subsequences-2.math create mode 100644 Task/Non-continuous-subsequences/OCaml/non-continuous-subsequences.ocaml create mode 100644 Task/Non-continuous-subsequences/Oz/non-continuous-subsequences.oz create mode 100644 Task/Non-continuous-subsequences/Perl-6/non-continuous-subsequences.pl6 create mode 100644 Task/Non-continuous-subsequences/Perl/non-continuous-subsequences.pl create mode 100644 Task/Non-continuous-subsequences/PicoLisp/non-continuous-subsequences.l create mode 100644 Task/Non-continuous-subsequences/Pop11/non-continuous-subsequences-1.pop11 create mode 100644 Task/Non-continuous-subsequences/Pop11/non-continuous-subsequences-2.pop11 create mode 100644 Task/Non-continuous-subsequences/PowerShell/non-continuous-subsequences.psh create mode 100644 Task/Non-continuous-subsequences/Prolog/non-continuous-subsequences-1.pro create mode 100644 Task/Non-continuous-subsequences/Prolog/non-continuous-subsequences-2.pro create mode 100644 Task/Non-continuous-subsequences/Python/non-continuous-subsequences-1.py create mode 100644 Task/Non-continuous-subsequences/Python/non-continuous-subsequences-2.py create mode 100644 Task/Non-continuous-subsequences/R/non-continuous-subsequences.r create mode 100644 Task/Non-continuous-subsequences/REXX/non-continuous-subsequences.rexx create mode 100644 Task/Non-continuous-subsequences/Ruby/non-continuous-subsequences.rb create mode 100644 Task/Non-continuous-subsequences/Scheme/non-continuous-subsequences.ss create mode 100644 Task/Non-continuous-subsequences/Standard-ML/non-continuous-subsequences.ml create mode 100644 Task/Non-continuous-subsequences/Tcl/non-continuous-subsequences.tcl create mode 100644 Task/Non-continuous-subsequences/Ursala/non-continuous-subsequences.ursala create mode 100644 Task/Non-decimal-radices-Convert/0DESCRIPTION create mode 100644 Task/Non-decimal-radices-Convert/1META.yaml create mode 100644 Task/Non-decimal-radices-Convert/ACL2/non-decimal-radices-convert.acl2 create mode 100644 Task/Non-decimal-radices-Convert/ALGOL-68/non-decimal-radices-convert-1.alg create mode 100644 Task/Non-decimal-radices-Convert/ALGOL-68/non-decimal-radices-convert-2.alg create mode 100644 Task/Non-decimal-radices-Convert/AWK/non-decimal-radices-convert.awk create mode 100644 Task/Non-decimal-radices-Convert/Ada/non-decimal-radices-convert.ada create mode 100644 Task/Non-decimal-radices-Convert/AutoHotkey/non-decimal-radices-convert-1.ahk create mode 100644 Task/Non-decimal-radices-Convert/AutoHotkey/non-decimal-radices-convert-2.ahk create mode 100644 Task/Non-decimal-radices-Convert/BBC-BASIC/non-decimal-radices-convert.bbc create mode 100644 Task/Non-decimal-radices-Convert/Bracmat/non-decimal-radices-convert.bracmat create mode 100644 Task/Non-decimal-radices-Convert/C++/non-decimal-radices-convert.cpp create mode 100644 Task/Non-decimal-radices-Convert/C/non-decimal-radices-convert.c create mode 100644 Task/Non-decimal-radices-Convert/Cache-ObjectScript/non-decimal-radices-convert.cos create mode 100644 Task/Non-decimal-radices-Convert/Common-Lisp/non-decimal-radices-convert.lisp create mode 100644 Task/Non-decimal-radices-Convert/D/non-decimal-radices-convert-1.d create mode 100644 Task/Non-decimal-radices-Convert/D/non-decimal-radices-convert-2.d create mode 100644 Task/Non-decimal-radices-Convert/E/non-decimal-radices-convert-1.e create mode 100644 Task/Non-decimal-radices-Convert/E/non-decimal-radices-convert-2.e create mode 100644 Task/Non-decimal-radices-Convert/Euphoria/non-decimal-radices-convert.euphoria create mode 100644 Task/Non-decimal-radices-Convert/Factor/non-decimal-radices-convert.factor create mode 100644 Task/Non-decimal-radices-Convert/Forth/non-decimal-radices-convert-1.fth create mode 100644 Task/Non-decimal-radices-Convert/Forth/non-decimal-radices-convert-2.fth create mode 100644 Task/Non-decimal-radices-Convert/Fortran/non-decimal-radices-convert.f create mode 100644 Task/Non-decimal-radices-Convert/Go/non-decimal-radices-convert.go create mode 100644 Task/Non-decimal-radices-Convert/Groovy/non-decimal-radices-convert-1.groovy create mode 100644 Task/Non-decimal-radices-Convert/Groovy/non-decimal-radices-convert-2.groovy create mode 100644 Task/Non-decimal-radices-Convert/Haskell/non-decimal-radices-convert-1.hs create mode 100644 Task/Non-decimal-radices-Convert/Haskell/non-decimal-radices-convert-2.hs create mode 100644 Task/Non-decimal-radices-Convert/Haskell/non-decimal-radices-convert-3.hs create mode 100644 Task/Non-decimal-radices-Convert/HicEst/non-decimal-radices-convert-1.hicest create mode 100644 Task/Non-decimal-radices-Convert/HicEst/non-decimal-radices-convert-2.hicest create mode 100644 Task/Non-decimal-radices-Convert/Icon/non-decimal-radices-convert.icon create mode 100644 Task/Non-decimal-radices-Convert/J/non-decimal-radices-convert-1.j create mode 100644 Task/Non-decimal-radices-Convert/J/non-decimal-radices-convert-2.j create mode 100644 Task/Non-decimal-radices-Convert/J/non-decimal-radices-convert-3.j create mode 100644 Task/Non-decimal-radices-Convert/J/non-decimal-radices-convert-4.j create mode 100644 Task/Non-decimal-radices-Convert/Java/non-decimal-radices-convert-1.java create mode 100644 Task/Non-decimal-radices-Convert/Java/non-decimal-radices-convert-2.java create mode 100644 Task/Non-decimal-radices-Convert/JavaScript/non-decimal-radices-convert.js create mode 100644 Task/Non-decimal-radices-Convert/Liberty-BASIC/non-decimal-radices-convert.liberty create mode 100644 Task/Non-decimal-radices-Convert/M4/non-decimal-radices-convert.m4 create mode 100644 Task/Non-decimal-radices-Convert/Mathematica/non-decimal-radices-convert.math create mode 100644 Task/Non-decimal-radices-Convert/NetRexx/non-decimal-radices-convert.netrexx create mode 100644 Task/Non-decimal-radices-Convert/OCaml/non-decimal-radices-convert-1.ocaml create mode 100644 Task/Non-decimal-radices-Convert/OCaml/non-decimal-radices-convert-2.ocaml create mode 100644 Task/Non-decimal-radices-Convert/PARI-GP/non-decimal-radices-convert.pari create mode 100644 Task/Non-decimal-radices-Convert/PHP/non-decimal-radices-convert-1.php create mode 100644 Task/Non-decimal-radices-Convert/PHP/non-decimal-radices-convert-2.php create mode 100644 Task/Non-decimal-radices-Convert/PHP/non-decimal-radices-convert-3.php create mode 100644 Task/Non-decimal-radices-Convert/PHP/non-decimal-radices-convert-4.php create mode 100644 Task/Non-decimal-radices-Convert/PL-I/non-decimal-radices-convert.pli create mode 100644 Task/Non-decimal-radices-Convert/Pascal/non-decimal-radices-convert.pascal create mode 100644 Task/Non-decimal-radices-Convert/Perl-6/non-decimal-radices-convert.pl6 create mode 100644 Task/Non-decimal-radices-Convert/Perl/non-decimal-radices-convert-1.pl create mode 100644 Task/Non-decimal-radices-Convert/Perl/non-decimal-radices-convert-2.pl create mode 100644 Task/Non-decimal-radices-Convert/PicoLisp/non-decimal-radices-convert.l create mode 100644 Task/Non-decimal-radices-Convert/Pop11/non-decimal-radices-convert-1.pop11 create mode 100644 Task/Non-decimal-radices-Convert/Pop11/non-decimal-radices-convert-2.pop11 create mode 100644 Task/Non-decimal-radices-Convert/PureBasic/non-decimal-radices-convert.purebasic create mode 100644 Task/Non-decimal-radices-Convert/Python/non-decimal-radices-convert-1.py create mode 100644 Task/Non-decimal-radices-Convert/Python/non-decimal-radices-convert-2.py create mode 100644 Task/Non-decimal-radices-Convert/REXX/non-decimal-radices-convert.rexx create mode 100644 Task/Non-decimal-radices-Convert/Ruby/non-decimal-radices-convert-1.rb create mode 100644 Task/Non-decimal-radices-Convert/Ruby/non-decimal-radices-convert-2.rb create mode 100644 Task/Non-decimal-radices-Convert/Ruby/non-decimal-radices-convert-3.rb create mode 100644 Task/Non-decimal-radices-Convert/Run-BASIC/non-decimal-radices-convert.run create mode 100644 Task/Non-decimal-radices-Convert/Slate/non-decimal-radices-convert.slate create mode 100644 Task/Non-decimal-radices-Convert/Standard-ML/non-decimal-radices-convert.ml create mode 100644 Task/Non-decimal-radices-Convert/Tcl/non-decimal-radices-convert.tcl create mode 100644 Task/Non-decimal-radices-Convert/Ursala/non-decimal-radices-convert-1.ursala create mode 100644 Task/Non-decimal-radices-Convert/Ursala/non-decimal-radices-convert-2.ursala create mode 100644 Task/Non-decimal-radices-Convert/XPL0/non-decimal-radices-convert.xpl0 create mode 100644 Task/Non-decimal-radices-Input/0DESCRIPTION create mode 100644 Task/Non-decimal-radices-Input/1META.yaml create mode 100644 Task/Non-decimal-radices-Input/ALGOL-68/non-decimal-radices-input.alg create mode 100644 Task/Non-decimal-radices-Input/Ada/non-decimal-radices-input.ada create mode 100644 Task/Non-decimal-radices-Input/BBC-BASIC/non-decimal-radices-input.bbc create mode 100644 Task/Non-decimal-radices-Input/C++/non-decimal-radices-input.cpp create mode 100644 Task/Non-decimal-radices-Input/C/non-decimal-radices-input-1.c create mode 100644 Task/Non-decimal-radices-Input/C/non-decimal-radices-input-2.c create mode 100644 Task/Non-decimal-radices-Input/Common-Lisp/non-decimal-radices-input.lisp create mode 100644 Task/Non-decimal-radices-Input/D/non-decimal-radices-input.d create mode 100644 Task/Non-decimal-radices-Input/E/non-decimal-radices-input.e create mode 100644 Task/Non-decimal-radices-Input/Factor/non-decimal-radices-input.factor create mode 100644 Task/Non-decimal-radices-Input/Forth/non-decimal-radices-input.fth create mode 100644 Task/Non-decimal-radices-Input/Fortran/non-decimal-radices-input.f create mode 100644 Task/Non-decimal-radices-Input/Go/non-decimal-radices-input.go create mode 100644 Task/Non-decimal-radices-Input/Haskell/non-decimal-radices-input.hs create mode 100644 Task/Non-decimal-radices-Input/HicEst/non-decimal-radices-input.hicest create mode 100644 Task/Non-decimal-radices-Input/Icon/non-decimal-radices-input.icon create mode 100644 Task/Non-decimal-radices-Input/J/non-decimal-radices-input-1.j create mode 100644 Task/Non-decimal-radices-Input/J/non-decimal-radices-input-2.j create mode 100644 Task/Non-decimal-radices-Input/J/non-decimal-radices-input-3.j create mode 100644 Task/Non-decimal-radices-Input/J/non-decimal-radices-input-4.j create mode 100644 Task/Non-decimal-radices-Input/J/non-decimal-radices-input-5.j create mode 100644 Task/Non-decimal-radices-Input/J/non-decimal-radices-input-6.j create mode 100644 Task/Non-decimal-radices-Input/Java/non-decimal-radices-input-1.java create mode 100644 Task/Non-decimal-radices-Input/Java/non-decimal-radices-input-2.java create mode 100644 Task/Non-decimal-radices-Input/Java/non-decimal-radices-input-3.java create mode 100644 Task/Non-decimal-radices-Input/JavaScript/non-decimal-radices-input-1.js create mode 100644 Task/Non-decimal-radices-Input/JavaScript/non-decimal-radices-input-2.js create mode 100644 Task/Non-decimal-radices-Input/JavaScript/non-decimal-radices-input-3.js create mode 100644 Task/Non-decimal-radices-Input/JavaScript/non-decimal-radices-input-4.js create mode 100644 Task/Non-decimal-radices-Input/JavaScript/non-decimal-radices-input-5.js create mode 100644 Task/Non-decimal-radices-Input/JavaScript/non-decimal-radices-input-6.js create mode 100644 Task/Non-decimal-radices-Input/Lua/non-decimal-radices-input.lua create mode 100644 Task/Non-decimal-radices-Input/Mathematica/non-decimal-radices-input.math create mode 100644 Task/Non-decimal-radices-Input/OCaml/non-decimal-radices-input-1.ocaml create mode 100644 Task/Non-decimal-radices-Input/OCaml/non-decimal-radices-input-2.ocaml create mode 100644 Task/Non-decimal-radices-Input/Oz/non-decimal-radices-input.oz create mode 100644 Task/Non-decimal-radices-Input/PARI-GP/non-decimal-radices-input.pari create mode 100644 Task/Non-decimal-radices-Input/PHP/non-decimal-radices-input-1.php create mode 100644 Task/Non-decimal-radices-Input/PHP/non-decimal-radices-input-2.php create mode 100644 Task/Non-decimal-radices-Input/PHP/non-decimal-radices-input-3.php create mode 100644 Task/Non-decimal-radices-Input/PL-I/non-decimal-radices-input.pli create mode 100644 Task/Non-decimal-radices-Input/Perl-6/non-decimal-radices-input-1.pl6 create mode 100644 Task/Non-decimal-radices-Input/Perl-6/non-decimal-radices-input-2.pl6 create mode 100644 Task/Non-decimal-radices-Input/Perl/non-decimal-radices-input.pl create mode 100644 Task/Non-decimal-radices-Input/PicoLisp/non-decimal-radices-input.l create mode 100644 Task/Non-decimal-radices-Input/PureBasic/non-decimal-radices-input.purebasic create mode 100644 Task/Non-decimal-radices-Input/Python/non-decimal-radices-input.py create mode 100644 Task/Non-decimal-radices-Input/R/non-decimal-radices-input.r create mode 100644 Task/Non-decimal-radices-Input/REXX/non-decimal-radices-input.rexx create mode 100644 Task/Non-decimal-radices-Input/Ruby/non-decimal-radices-input-1.rb create mode 100644 Task/Non-decimal-radices-Input/Ruby/non-decimal-radices-input-2.rb create mode 100644 Task/Non-decimal-radices-Input/Ruby/non-decimal-radices-input-3.rb create mode 100644 Task/Non-decimal-radices-Input/Ruby/non-decimal-radices-input-4.rb create mode 100644 Task/Non-decimal-radices-Input/Scheme/non-decimal-radices-input.ss create mode 100644 Task/Non-decimal-radices-Input/Standard-ML/non-decimal-radices-input.ml create mode 100644 Task/Non-decimal-radices-Input/Tcl/non-decimal-radices-input-1.tcl create mode 100644 Task/Non-decimal-radices-Input/Tcl/non-decimal-radices-input-2.tcl create mode 100644 Task/Non-decimal-radices-Input/XPL0/non-decimal-radices-input.xpl0 create mode 100644 Task/Non-decimal-radices-Output/0DESCRIPTION create mode 100644 Task/Non-decimal-radices-Output/1META.yaml create mode 100644 Task/Non-decimal-radices-Output/ALGOL-68/non-decimal-radices-output.alg create mode 100644 Task/Non-decimal-radices-Output/AWK/non-decimal-radices-output.awk create mode 100644 Task/Non-decimal-radices-Output/Ada/non-decimal-radices-output.ada create mode 100644 Task/Non-decimal-radices-Output/AutoHotkey/non-decimal-radices-output.ahk create mode 100644 Task/Non-decimal-radices-Output/BBC-BASIC/non-decimal-radices-output.bbc create mode 100644 Task/Non-decimal-radices-Output/C++/non-decimal-radices-output.cpp create mode 100644 Task/Non-decimal-radices-Output/C/non-decimal-radices-output.c create mode 100644 Task/Non-decimal-radices-Output/Clojure/non-decimal-radices-output.clj create mode 100644 Task/Non-decimal-radices-Output/Common-Lisp/non-decimal-radices-output.lisp create mode 100644 Task/Non-decimal-radices-Output/D/non-decimal-radices-output-1.d create mode 100644 Task/Non-decimal-radices-Output/D/non-decimal-radices-output-2.d create mode 100644 Task/Non-decimal-radices-Output/E/non-decimal-radices-output.e create mode 100644 Task/Non-decimal-radices-Output/Euphoria/non-decimal-radices-output.euphoria create mode 100644 Task/Non-decimal-radices-Output/Factor/non-decimal-radices-output.factor create mode 100644 Task/Non-decimal-radices-Output/Forth/non-decimal-radices-output-1.fth create mode 100644 Task/Non-decimal-radices-Output/Forth/non-decimal-radices-output-2.fth create mode 100644 Task/Non-decimal-radices-Output/Fortran/non-decimal-radices-output.f create mode 100644 Task/Non-decimal-radices-Output/Gema/non-decimal-radices-output.gema create mode 100644 Task/Non-decimal-radices-Output/Go/non-decimal-radices-output.go create mode 100644 Task/Non-decimal-radices-Output/Haskell/non-decimal-radices-output-1.hs create mode 100644 Task/Non-decimal-radices-Output/Haskell/non-decimal-radices-output-2.hs create mode 100644 Task/Non-decimal-radices-Output/HicEst/non-decimal-radices-output.hicest create mode 100644 Task/Non-decimal-radices-Output/Icon/non-decimal-radices-output.icon create mode 100644 Task/Non-decimal-radices-Output/J/non-decimal-radices-output-1.j create mode 100644 Task/Non-decimal-radices-Output/J/non-decimal-radices-output-2.j create mode 100644 Task/Non-decimal-radices-Output/J/non-decimal-radices-output-3.j create mode 100644 Task/Non-decimal-radices-Output/Java/non-decimal-radices-output.java create mode 100644 Task/Non-decimal-radices-Output/JavaScript/non-decimal-radices-output.js create mode 100644 Task/Non-decimal-radices-Output/Locomotive-Basic/non-decimal-radices-output.locomotive create mode 100644 Task/Non-decimal-radices-Output/Lua/non-decimal-radices-output.lua create mode 100644 Task/Non-decimal-radices-Output/Mathematica/non-decimal-radices-output.math create mode 100644 Task/Non-decimal-radices-Output/Modula-3/non-decimal-radices-output.mod3 create mode 100644 Task/Non-decimal-radices-Output/NetRexx/non-decimal-radices-output.netrexx create mode 100644 Task/Non-decimal-radices-Output/OCaml/non-decimal-radices-output.ocaml create mode 100644 Task/Non-decimal-radices-Output/PARI-GP/non-decimal-radices-output.pari create mode 100644 Task/Non-decimal-radices-Output/PHP/non-decimal-radices-output-1.php create mode 100644 Task/Non-decimal-radices-Output/PHP/non-decimal-radices-output-2.php create mode 100644 Task/Non-decimal-radices-Output/PL-I/non-decimal-radices-output.pli create mode 100644 Task/Non-decimal-radices-Output/Perl-6/non-decimal-radices-output.pl6 create mode 100644 Task/Non-decimal-radices-Output/Perl/non-decimal-radices-output.pl create mode 100644 Task/Non-decimal-radices-Output/PicoLisp/non-decimal-radices-output.l create mode 100644 Task/Non-decimal-radices-Output/PowerShell/non-decimal-radices-output.psh create mode 100644 Task/Non-decimal-radices-Output/PureBasic/non-decimal-radices-output.purebasic create mode 100644 Task/Non-decimal-radices-Output/Python/non-decimal-radices-output-1.py create mode 100644 Task/Non-decimal-radices-Output/Python/non-decimal-radices-output-2.py create mode 100644 Task/Non-decimal-radices-Output/Python/non-decimal-radices-output-3.py create mode 100644 Task/Non-decimal-radices-Output/R/non-decimal-radices-output.r create mode 100644 Task/Non-decimal-radices-Output/REXX/non-decimal-radices-output-1.rexx create mode 100644 Task/Non-decimal-radices-Output/REXX/non-decimal-radices-output-2.rexx create mode 100644 Task/Non-decimal-radices-Output/Ruby/non-decimal-radices-output.rb create mode 100644 Task/Non-decimal-radices-Output/Scheme/non-decimal-radices-output.ss create mode 100644 Task/Non-decimal-radices-Output/Seed7/non-decimal-radices-output.seed7 create mode 100644 Task/Non-decimal-radices-Output/Smalltalk/non-decimal-radices-output.st create mode 100644 Task/Non-decimal-radices-Output/Standard-ML/non-decimal-radices-output.ml create mode 100644 Task/Non-decimal-radices-Output/TI-89-BASIC/non-decimal-radices-output-1.ti-89 create mode 100644 Task/Non-decimal-radices-Output/TI-89-BASIC/non-decimal-radices-output-2.ti-89 create mode 100644 Task/Non-decimal-radices-Output/Tcl/non-decimal-radices-output-1.tcl create mode 100644 Task/Non-decimal-radices-Output/Tcl/non-decimal-radices-output-2.tcl create mode 100644 Task/Non-decimal-radices-Output/XPL0/non-decimal-radices-output.xpl0 create mode 100644 Task/Nth-root/0DESCRIPTION create mode 100644 Task/Nth-root/1META.yaml create mode 100644 Task/Nth-root/ALGOL-68/nth-root.alg create mode 100644 Task/Nth-root/AWK/nth-root.awk create mode 100644 Task/Nth-root/Ada/nth-root.ada create mode 100644 Task/Nth-root/AutoHotkey/nth-root.ahk create mode 100644 Task/Nth-root/AutoIt/nth-root.autoit create mode 100644 Task/Nth-root/BASIC/nth-root-1.basic create mode 100644 Task/Nth-root/BASIC/nth-root-2.basic create mode 100644 Task/Nth-root/BASIC/nth-root-3.basic create mode 100644 Task/Nth-root/BBC-BASIC/nth-root.bbc create mode 100644 Task/Nth-root/C++/nth-root-1.cpp create mode 100644 Task/Nth-root/C++/nth-root-2.cpp create mode 100644 Task/Nth-root/C/nth-root.c create mode 100644 Task/Nth-root/CoffeeScript/nth-root-1.coffeescript create mode 100644 Task/Nth-root/CoffeeScript/nth-root-2.coffeescript create mode 100644 Task/Nth-root/Common-Lisp/nth-root-1.lisp create mode 100644 Task/Nth-root/Common-Lisp/nth-root-2.lisp create mode 100644 Task/Nth-root/D/nth-root.d create mode 100644 Task/Nth-root/Delphi/nth-root.delphi create mode 100644 Task/Nth-root/E/nth-root.e create mode 100644 Task/Nth-root/Erlang/nth-root-1.erl create mode 100644 Task/Nth-root/Erlang/nth-root-2.erl create mode 100644 Task/Nth-root/Forth/nth-root.fth create mode 100644 Task/Nth-root/Fortran/nth-root.f create mode 100644 Task/Nth-root/Go/nth-root.go create mode 100644 Task/Nth-root/Groovy/nth-root-1.groovy create mode 100644 Task/Nth-root/Groovy/nth-root-2.groovy create mode 100644 Task/Nth-root/Haskell/nth-root.hs create mode 100644 Task/Nth-root/HicEst/nth-root.hicest create mode 100644 Task/Nth-root/Icon/nth-root.icon create mode 100644 Task/Nth-root/J/nth-root.j create mode 100644 Task/Nth-root/Java/nth-root-1.java create mode 100644 Task/Nth-root/Java/nth-root-2.java create mode 100644 Task/Nth-root/JavaScript/nth-root.js create mode 100644 Task/Nth-root/Liberty-BASIC/nth-root.liberty create mode 100644 Task/Nth-root/Logo/nth-root.logo create mode 100644 Task/Nth-root/Lua/nth-root.lua create mode 100644 Task/Nth-root/MATLAB/nth-root-1.m create mode 100644 Task/Nth-root/MATLAB/nth-root-2.m create mode 100644 Task/Nth-root/Mathematica/nth-root.math create mode 100644 Task/Nth-root/Maxima/nth-root.maxima create mode 100644 Task/Nth-root/Metafont/nth-root.metafont create mode 100644 Task/Nth-root/NetRexx/nth-root.netrexx create mode 100644 Task/Nth-root/OCaml/nth-root.ocaml create mode 100644 Task/Nth-root/Octave/nth-root-1.octave create mode 100644 Task/Nth-root/Octave/nth-root-2.octave create mode 100644 Task/Nth-root/Octave/nth-root-3.octave create mode 100644 Task/Nth-root/Octave/nth-root-4.octave create mode 100644 Task/Nth-root/Oz/nth-root.oz create mode 100644 Task/Nth-root/PARI-GP/nth-root.pari create mode 100644 Task/Nth-root/PHP/nth-root.php create mode 100644 Task/Nth-root/PL-I/nth-root.pli create mode 100644 Task/Nth-root/Perl-6/nth-root.pl6 create mode 100644 Task/Nth-root/Perl/nth-root-1.pl create mode 100644 Task/Nth-root/Perl/nth-root-2.pl create mode 100644 Task/Nth-root/PicoLisp/nth-root.l create mode 100644 Task/Nth-root/PureBasic/nth-root.purebasic create mode 100644 Task/Nth-root/Python/nth-root-1.py create mode 100644 Task/Nth-root/Python/nth-root-2.py create mode 100644 Task/Nth-root/R/nth-root.r create mode 100644 Task/Nth-root/REXX/nth-root.rexx create mode 100644 Task/Nth-root/Ruby/nth-root.rb create mode 100644 Task/Nth-root/Run-BASIC/nth-root.run create mode 100644 Task/Nth-root/Sather/nth-root-1.sa create mode 100644 Task/Nth-root/Sather/nth-root-2.sa create mode 100644 Task/Nth-root/Scala/nth-root.scala create mode 100644 Task/Nth-root/Scheme/nth-root.ss create mode 100644 Task/Nth-root/Seed7/nth-root.seed7 create mode 100644 Task/Nth-root/Smalltalk/nth-root-1.st create mode 100644 Task/Nth-root/Smalltalk/nth-root-2.st create mode 100644 Task/Nth-root/Tcl/nth-root-1.tcl create mode 100644 Task/Nth-root/Tcl/nth-root-2.tcl create mode 100644 Task/Nth-root/Tcl/nth-root-3.tcl create mode 100644 Task/Nth-root/Ursala/nth-root-1.ursala create mode 100644 Task/Nth-root/Ursala/nth-root-2.ursala create mode 100644 Task/Nth-root/XPL0/nth-root.xpl0 create mode 100644 Task/Null-object/0DESCRIPTION create mode 100644 Task/Null-object/1META.yaml create mode 100644 Task/Null-object/ALGOL-68/null-object.alg create mode 100644 Task/Null-object/ActionScript/null-object.as create mode 100644 Task/Null-object/Ada/null-object.ada create mode 100644 Task/Null-object/AmigaE/null-object.amiga create mode 100644 Task/Null-object/AppleScript/null-object.applescript create mode 100644 Task/Null-object/AutoHotkey/null-object.ahk create mode 100644 Task/Null-object/BBC-BASIC/null-object.bbc create mode 100644 Task/Null-object/Babel/null-object.pb create mode 100644 Task/Null-object/C++/null-object-1.cpp create mode 100644 Task/Null-object/C++/null-object-2.cpp create mode 100644 Task/Null-object/C/null-object.c create mode 100644 Task/Null-object/Clojure/null-object-1.clj create mode 100644 Task/Null-object/Clojure/null-object-2.clj create mode 100644 Task/Null-object/Clojure/null-object-3.clj create mode 100644 Task/Null-object/Common-Lisp/null-object-1.lisp create mode 100644 Task/Null-object/Common-Lisp/null-object-2.lisp create mode 100644 Task/Null-object/Common-Lisp/null-object-3.lisp create mode 100644 Task/Null-object/Component-Pascal/null-object.component create mode 100644 Task/Null-object/D/null-object.d create mode 100644 Task/Null-object/Delphi/null-object.delphi create mode 100644 Task/Null-object/E/null-object.e create mode 100644 Task/Null-object/Factor/null-object.factor create mode 100644 Task/Null-object/Fantom/null-object.fantom create mode 100644 Task/Null-object/Go/null-object.go create mode 100644 Task/Null-object/Haskell/null-object-1.hs create mode 100644 Task/Null-object/Haskell/null-object-2.hs create mode 100644 Task/Null-object/Haskell/null-object-3.hs create mode 100644 Task/Null-object/Icon/null-object.icon create mode 100644 Task/Null-object/Io/null-object.io create mode 100644 Task/Null-object/J/null-object-1.j create mode 100644 Task/Null-object/J/null-object-2.j create mode 100644 Task/Null-object/J/null-object-3.j create mode 100644 Task/Null-object/Java/null-object.java create mode 100644 Task/Null-object/JavaScript/null-object.js create mode 100644 Task/Null-object/K/null-object.k create mode 100644 Task/Null-object/Logo/null-object.logo create mode 100644 Task/Null-object/Lua/null-object.lua create mode 100644 Task/Null-object/MAXScript/null-object.maxscript create mode 100644 Task/Null-object/MUMPS/null-object.mumps create mode 100644 Task/Null-object/Mathematica/null-object-1.math create mode 100644 Task/Null-object/Mathematica/null-object-2.math create mode 100644 Task/Null-object/Mathematica/null-object-3.math create mode 100644 Task/Null-object/Mathematica/null-object-4.math create mode 100644 Task/Null-object/Mathematica/null-object-5.math create mode 100644 Task/Null-object/Mathematica/null-object-6.math create mode 100644 Task/Null-object/Modula-3/null-object-1.mod3 create mode 100644 Task/Null-object/Modula-3/null-object-2.mod3 create mode 100644 Task/Null-object/Modula-3/null-object-3.mod3 create mode 100644 Task/Null-object/NetRexx/null-object.netrexx create mode 100644 Task/Null-object/OCaml/null-object-1.ocaml create mode 100644 Task/Null-object/OCaml/null-object-2.ocaml create mode 100644 Task/Null-object/Objeck/null-object.objeck create mode 100644 Task/Null-object/Objective-C/null-object-1.m create mode 100644 Task/Null-object/Objective-C/null-object-2.m create mode 100644 Task/Null-object/Oz/null-object-1.oz create mode 100644 Task/Null-object/Oz/null-object-2.oz create mode 100644 Task/Null-object/Oz/null-object-3.oz create mode 100644 Task/Null-object/PARI-GP/null-object.pari create mode 100644 Task/Null-object/PHP/null-object.php create mode 100644 Task/Null-object/PL-I/null-object.pli create mode 100644 Task/Null-object/Perl-6/null-object-1.pl6 create mode 100644 Task/Null-object/Perl-6/null-object-2.pl6 create mode 100644 Task/Null-object/Perl-6/null-object-3.pl6 create mode 100644 Task/Null-object/Perl/null-object-1.pl create mode 100644 Task/Null-object/Perl/null-object-2.pl create mode 100644 Task/Null-object/PicoLisp/null-object-1.l create mode 100644 Task/Null-object/PicoLisp/null-object-2.l create mode 100644 Task/Null-object/Pike/null-object.pike create mode 100644 Task/Null-object/PowerShell/null-object.psh create mode 100644 Task/Null-object/PureBasic/null-object.purebasic create mode 100644 Task/Null-object/Python/null-object.py create mode 100644 Task/Null-object/R/null-object.r create mode 100644 Task/Null-object/REBOL/null-object.rebol create mode 100644 Task/Null-object/REXX/null-object.rexx create mode 100644 Task/Null-object/Ruby/null-object.rb create mode 100644 Task/Null-object/Scala/null-object.scala create mode 100644 Task/Null-object/Scheme/null-object.ss create mode 100644 Task/Null-object/Slate/null-object.slate create mode 100644 Task/Null-object/Smalltalk/null-object-1.st create mode 100644 Task/Null-object/Smalltalk/null-object-2.st create mode 100644 Task/Null-object/Standard-ML/null-object-1.ml create mode 100644 Task/Null-object/Standard-ML/null-object-2.ml create mode 100644 Task/Null-object/Tcl/null-object-1.tcl create mode 100644 Task/Null-object/Tcl/null-object-2.tcl create mode 100644 Task/Number-names/0DESCRIPTION create mode 100644 Task/Number-names/1META.yaml create mode 100644 Task/Number-names/ALGOL-68/number-names-1.alg create mode 100644 Task/Number-names/ALGOL-68/number-names-2.alg create mode 100644 Task/Number-names/AWK/number-names.awk create mode 100644 Task/Number-names/Ada/number-names.ada create mode 100644 Task/Number-names/AutoHotkey/number-names.ahk create mode 100644 Task/Number-names/BASIC/number-names.basic create mode 100644 Task/Number-names/BBC-BASIC/number-names.bbc create mode 100644 Task/Number-names/C++/number-names.cpp create mode 100644 Task/Number-names/C/number-names.c create mode 100644 Task/Number-names/Clojure/number-names.clj create mode 100644 Task/Number-names/CoffeeScript/number-names-1.coffeescript create mode 100644 Task/Number-names/CoffeeScript/number-names-2.coffeescript create mode 100644 Task/Number-names/Common-Lisp/number-names.lisp create mode 100644 Task/Number-names/D/number-names.d create mode 100644 Task/Number-names/Euphoria/number-names.euphoria create mode 100644 Task/Number-names/Fortran/number-names.f create mode 100644 Task/Number-names/Go/number-names.go create mode 100644 Task/Number-names/Groovy/number-names.groovy create mode 100644 Task/Number-names/Haskell/number-names.hs create mode 100644 Task/Number-names/HicEst/number-names-1.hicest create mode 100644 Task/Number-names/HicEst/number-names-2.hicest create mode 100644 Task/Number-names/HicEst/number-names-3.hicest create mode 100644 Task/Number-names/HicEst/number-names-4.hicest create mode 100644 Task/Number-names/Inform-7/number-names-1.inf create mode 100644 Task/Number-names/Inform-7/number-names-2.inf create mode 100644 Task/Number-names/Inform-7/number-names-3.inf create mode 100644 Task/Number-names/Java/number-names-1.java create mode 100644 Task/Number-names/Java/number-names-2.java create mode 100644 Task/Number-names/Joy/number-names.joy create mode 100644 Task/Number-names/Logo/number-names.logo create mode 100644 Task/Number-names/Lua/number-names.lua create mode 100644 Task/Number-names/MAXScript/number-names-1.maxscript create mode 100644 Task/Number-names/MAXScript/number-names-2.maxscript create mode 100644 Task/Number-names/Mathematica/number-names.math create mode 100644 Task/Number-names/OCaml/number-names.ocaml create mode 100644 Task/Number-names/Objeck/number-names.objeck create mode 100644 Task/Number-names/PARI-GP/number-names.pari create mode 100644 Task/Number-names/PHP/number-names-1.php create mode 100644 Task/Number-names/PHP/number-names-2.php create mode 100644 Task/Number-names/PL-I/number-names.pli create mode 100644 Task/Number-names/Pascal/number-names.pascal create mode 100644 Task/Number-names/Perl-6/number-names.pl6 create mode 100644 Task/Number-names/Perl/number-names.pl create mode 100644 Task/Number-names/PicoLisp/number-names.l create mode 100644 Task/Number-names/PowerBASIC/number-names.powerbasic create mode 100644 Task/Number-names/PureBasic/number-names-1.purebasic create mode 100644 Task/Number-names/PureBasic/number-names-2.purebasic create mode 100644 Task/Number-names/Ruby/number-names.rb create mode 100644 Task/Number-names/Seed7/number-names.seed7 create mode 100644 Task/Number-names/Tcl/number-names.tcl create mode 100644 Task/Number-names/Visual-Basic-.NET/number-names.visual create mode 100644 Task/Number-names/Visual-Basic/number-names.vb create mode 100644 Task/Number-names/XPL0/number-names.xpl0 create mode 100644 Task/Number-reversal-game/0DESCRIPTION create mode 100644 Task/Number-reversal-game/1META.yaml create mode 100644 Task/Number-reversal-game/AWK/number-reversal-game.awk create mode 100644 Task/Number-reversal-game/Ada/number-reversal-game.ada create mode 100644 Task/Number-reversal-game/AutoHotkey/number-reversal-game.ahk create mode 100644 Task/Number-reversal-game/BASIC/number-reversal-game.basic create mode 100644 Task/Number-reversal-game/BBC-BASIC/number-reversal-game.bbc create mode 100644 Task/Number-reversal-game/Brat/number-reversal-game.brat create mode 100644 Task/Number-reversal-game/C++/number-reversal-game-1.cpp create mode 100644 Task/Number-reversal-game/C++/number-reversal-game-2.cpp create mode 100644 Task/Number-reversal-game/C/number-reversal-game-1.c create mode 100644 Task/Number-reversal-game/C/number-reversal-game-2.c create mode 100644 Task/Number-reversal-game/Clojure/number-reversal-game.clj create mode 100644 Task/Number-reversal-game/Common-Lisp/number-reversal-game.lisp create mode 100644 Task/Number-reversal-game/D/number-reversal-game.d create mode 100644 Task/Number-reversal-game/Euphoria/number-reversal-game.euphoria create mode 100644 Task/Number-reversal-game/Factor/number-reversal-game.factor create mode 100644 Task/Number-reversal-game/Forth/number-reversal-game.fth create mode 100644 Task/Number-reversal-game/Fortran/number-reversal-game.f create mode 100644 Task/Number-reversal-game/Go/number-reversal-game.go create mode 100644 Task/Number-reversal-game/Groovy/number-reversal-game.groovy create mode 100644 Task/Number-reversal-game/Haskell/number-reversal-game.hs create mode 100644 Task/Number-reversal-game/HicEst/number-reversal-game.hicest create mode 100644 Task/Number-reversal-game/Icon/number-reversal-game.icon create mode 100644 Task/Number-reversal-game/Inform-7/number-reversal-game.inf create mode 100644 Task/Number-reversal-game/Io/number-reversal-game.io create mode 100644 Task/Number-reversal-game/J/number-reversal-game-1.j create mode 100644 Task/Number-reversal-game/J/number-reversal-game-2.j create mode 100644 Task/Number-reversal-game/Java/number-reversal-game.java create mode 100644 Task/Number-reversal-game/JavaScript/number-reversal-game-1.js create mode 100644 Task/Number-reversal-game/JavaScript/number-reversal-game-2.js create mode 100644 Task/Number-reversal-game/JavaScript/number-reversal-game-3.js create mode 100644 Task/Number-reversal-game/Mathematica/number-reversal-game.math create mode 100644 Task/Number-reversal-game/OCaml/number-reversal-game-1.ocaml create mode 100644 Task/Number-reversal-game/OCaml/number-reversal-game-2.ocaml create mode 100644 Task/Number-reversal-game/Oz/number-reversal-game.oz create mode 100644 Task/Number-reversal-game/PARI-GP/number-reversal-game.pari create mode 100644 Task/Number-reversal-game/PL-I/number-reversal-game.pli create mode 100644 Task/Number-reversal-game/Perl-6/number-reversal-game.pl6 create mode 100644 Task/Number-reversal-game/Perl/number-reversal-game.pl create mode 100644 Task/Number-reversal-game/PicoLisp/number-reversal-game.l create mode 100644 Task/Number-reversal-game/PureBasic/number-reversal-game.purebasic create mode 100644 Task/Number-reversal-game/Python/number-reversal-game.py create mode 100644 Task/Number-reversal-game/R/number-reversal-game-1.r create mode 100644 Task/Number-reversal-game/R/number-reversal-game-2.r create mode 100644 Task/Number-reversal-game/REXX/number-reversal-game.rexx create mode 100644 Task/Number-reversal-game/Rascal/number-reversal-game.rascal create mode 100644 Task/Number-reversal-game/Ruby/number-reversal-game.rb create mode 100644 Task/Number-reversal-game/Run-BASIC/number-reversal-game.run create mode 100644 Task/Number-reversal-game/TUSCRIPT/number-reversal-game.tuscript create mode 100644 Task/Number-reversal-game/Tcl/number-reversal-game.tcl create mode 100644 Task/Number-reversal-game/UNIX-Shell/number-reversal-game.sh create mode 100644 Task/Number-reversal-game/XPL0/number-reversal-game.xpl0 create mode 100644 Task/Numeric-error-propagation/0DESCRIPTION create mode 100644 Task/Numeric-error-propagation/Ada/numeric-error-propagation-1.ada create mode 100644 Task/Numeric-error-propagation/Ada/numeric-error-propagation-2.ada create mode 100644 Task/Numeric-error-propagation/Ada/numeric-error-propagation-3.ada create mode 100644 Task/Numeric-error-propagation/C/numeric-error-propagation.c create mode 100644 Task/Numeric-error-propagation/D/numeric-error-propagation.d create mode 100644 Task/Numeric-error-propagation/Go/numeric-error-propagation.go create mode 100644 Task/Numeric-error-propagation/Haskell/numeric-error-propagation.hs create mode 100644 Task/Numeric-error-propagation/J/numeric-error-propagation-1.j create mode 100644 Task/Numeric-error-propagation/J/numeric-error-propagation-2.j create mode 100644 Task/Numeric-error-propagation/J/numeric-error-propagation-3.j create mode 100644 Task/Numeric-error-propagation/J/numeric-error-propagation-4.j create mode 100644 Task/Numeric-error-propagation/J/numeric-error-propagation-5.j create mode 100644 Task/Numeric-error-propagation/J/numeric-error-propagation-6.j create mode 100644 Task/Numeric-error-propagation/J/numeric-error-propagation-7.j create mode 100644 Task/Numeric-error-propagation/Mathematica/numeric-error-propagation-1.math create mode 100644 Task/Numeric-error-propagation/Mathematica/numeric-error-propagation-2.math create mode 100644 Task/Numeric-error-propagation/Perl-6/numeric-error-propagation.pl6 create mode 100644 Task/Numeric-error-propagation/Perl/numeric-error-propagation-1.pl create mode 100644 Task/Numeric-error-propagation/Perl/numeric-error-propagation-2.pl create mode 100644 Task/Numeric-error-propagation/PicoLisp/numeric-error-propagation-1.l create mode 100644 Task/Numeric-error-propagation/PicoLisp/numeric-error-propagation-2.l create mode 100644 Task/Numeric-error-propagation/Python/numeric-error-propagation.py create mode 100644 Task/Numeric-error-propagation/Ruby/numeric-error-propagation.rb create mode 100644 Task/Numeric-error-propagation/Tcl/numeric-error-propagation-1.tcl create mode 100644 Task/Numeric-error-propagation/Tcl/numeric-error-propagation-2.tcl create mode 100644 Task/Numeric-error-propagation/Tcl/numeric-error-propagation-3.tcl create mode 100644 Task/Numerical-integration-Gauss-Legendre-Quadrature/0DESCRIPTION create mode 100644 Task/Numerical-integration-Gauss-Legendre-Quadrature/1META.yaml create mode 100644 Task/Numerical-integration-Gauss-Legendre-Quadrature/C/numerical-integration-gauss-legendre-quadrature.c create mode 100644 Task/Numerical-integration-Gauss-Legendre-Quadrature/Common-Lisp/numerical-integration-gauss-legendre-quadrature-1.lisp create mode 100644 Task/Numerical-integration-Gauss-Legendre-Quadrature/Common-Lisp/numerical-integration-gauss-legendre-quadrature-2.lisp create mode 100644 Task/Numerical-integration-Gauss-Legendre-Quadrature/Common-Lisp/numerical-integration-gauss-legendre-quadrature-3.lisp create mode 100644 Task/Numerical-integration-Gauss-Legendre-Quadrature/D/numerical-integration-gauss-legendre-quadrature.d create mode 100644 Task/Numerical-integration-Gauss-Legendre-Quadrature/Go/numerical-integration-gauss-legendre-quadrature.go create mode 100644 Task/Numerical-integration-Gauss-Legendre-Quadrature/J/numerical-integration-gauss-legendre-quadrature-1.j create mode 100644 Task/Numerical-integration-Gauss-Legendre-Quadrature/J/numerical-integration-gauss-legendre-quadrature-2.j create mode 100644 Task/Numerical-integration-Gauss-Legendre-Quadrature/Mathematica/numerical-integration-gauss-legendre-quadrature.math create mode 100644 Task/Numerical-integration-Gauss-Legendre-Quadrature/Maxima/numerical-integration-gauss-legendre-quadrature.maxima create mode 100644 Task/Numerical-integration-Gauss-Legendre-Quadrature/OCaml/numerical-integration-gauss-legendre-quadrature-1.ocaml create mode 100644 Task/Numerical-integration-Gauss-Legendre-Quadrature/OCaml/numerical-integration-gauss-legendre-quadrature-2.ocaml create mode 100644 Task/Numerical-integration-Gauss-Legendre-Quadrature/OCaml/numerical-integration-gauss-legendre-quadrature-3.ocaml create mode 100644 Task/Numerical-integration-Gauss-Legendre-Quadrature/PARI-GP/numerical-integration-gauss-legendre-quadrature.pari create mode 100644 Task/Numerical-integration-Gauss-Legendre-Quadrature/Perl-6/numerical-integration-gauss-legendre-quadrature.pl6 create mode 100644 Task/Numerical-integration-Gauss-Legendre-Quadrature/Python/numerical-integration-gauss-legendre-quadrature.py create mode 100644 Task/Numerical-integration-Gauss-Legendre-Quadrature/Tcl/numerical-integration-gauss-legendre-quadrature-1.tcl create mode 100644 Task/Numerical-integration-Gauss-Legendre-Quadrature/Tcl/numerical-integration-gauss-legendre-quadrature-2.tcl create mode 100644 Task/Numerical-integration-Gauss-Legendre-Quadrature/Ursala/numerical-integration-gauss-legendre-quadrature-1.ursala create mode 100644 Task/Numerical-integration-Gauss-Legendre-Quadrature/Ursala/numerical-integration-gauss-legendre-quadrature-2.ursala create mode 100644 Task/Numerical-integration/0DESCRIPTION create mode 100644 Task/Numerical-integration/1META.yaml create mode 100644 Task/Numerical-integration/ALGOL-68/numerical-integration.alg create mode 100644 Task/Numerical-integration/ActionScript/numerical-integration-1.as create mode 100644 Task/Numerical-integration/ActionScript/numerical-integration-2.as create mode 100644 Task/Numerical-integration/Ada/numerical-integration-1.ada create mode 100644 Task/Numerical-integration/Ada/numerical-integration-2.ada create mode 100644 Task/Numerical-integration/Ada/numerical-integration-3.ada create mode 100644 Task/Numerical-integration/AutoHotkey/numerical-integration.ahk create mode 100644 Task/Numerical-integration/BASIC/numerical-integration.basic create mode 100644 Task/Numerical-integration/BBC-BASIC/numerical-integration.bbc create mode 100644 Task/Numerical-integration/C++/numerical-integration.cpp create mode 100644 Task/Numerical-integration/C/numerical-integration-1.c create mode 100644 Task/Numerical-integration/C/numerical-integration-2.c create mode 100644 Task/Numerical-integration/CoffeeScript/numerical-integration-1.coffeescript create mode 100644 Task/Numerical-integration/CoffeeScript/numerical-integration-2.coffeescript create mode 100644 Task/Numerical-integration/Common-Lisp/numerical-integration.lisp create mode 100644 Task/Numerical-integration/D/numerical-integration-1.d create mode 100644 Task/Numerical-integration/D/numerical-integration-2.d create mode 100644 Task/Numerical-integration/E/numerical-integration-1.e create mode 100644 Task/Numerical-integration/E/numerical-integration-2.e create mode 100644 Task/Numerical-integration/Euphoria/numerical-integration.euphoria create mode 100644 Task/Numerical-integration/Forth/numerical-integration.fth create mode 100644 Task/Numerical-integration/Fortran/numerical-integration-1.f create mode 100644 Task/Numerical-integration/Fortran/numerical-integration-2.f create mode 100644 Task/Numerical-integration/Fortran/numerical-integration-3.f create mode 100644 Task/Numerical-integration/Fortran/numerical-integration-4.f create mode 100644 Task/Numerical-integration/Go/numerical-integration.go create mode 100644 Task/Numerical-integration/Groovy/numerical-integration-1.groovy create mode 100644 Task/Numerical-integration/Groovy/numerical-integration-2.groovy create mode 100644 Task/Numerical-integration/Groovy/numerical-integration-3.groovy create mode 100644 Task/Numerical-integration/Haskell/numerical-integration-1.hs create mode 100644 Task/Numerical-integration/Haskell/numerical-integration-2.hs create mode 100644 Task/Numerical-integration/Haskell/numerical-integration-3.hs create mode 100644 Task/Numerical-integration/Haskell/numerical-integration-4.hs create mode 100644 Task/Numerical-integration/Haskell/numerical-integration-5.hs create mode 100644 Task/Numerical-integration/Haskell/numerical-integration-6.hs create mode 100644 Task/Numerical-integration/J/numerical-integration-1.j create mode 100644 Task/Numerical-integration/J/numerical-integration-2.j create mode 100644 Task/Numerical-integration/J/numerical-integration-3.j create mode 100644 Task/Numerical-integration/J/numerical-integration-4.j create mode 100644 Task/Numerical-integration/J/numerical-integration-5.j create mode 100644 Task/Numerical-integration/J/numerical-integration-6.j create mode 100644 Task/Numerical-integration/J/numerical-integration-7.j create mode 100644 Task/Numerical-integration/Java/numerical-integration.java create mode 100644 Task/Numerical-integration/Liberty-BASIC/numerical-integration.liberty create mode 100644 Task/Numerical-integration/Logo/numerical-integration.logo create mode 100644 Task/Numerical-integration/Lua/numerical-integration.lua create mode 100644 Task/Numerical-integration/MATLAB/numerical-integration-1.m create mode 100644 Task/Numerical-integration/MATLAB/numerical-integration-2.m create mode 100644 Task/Numerical-integration/MATLAB/numerical-integration-3.m create mode 100644 Task/Numerical-integration/MATLAB/numerical-integration-4.m create mode 100644 Task/Numerical-integration/MATLAB/numerical-integration-5.m create mode 100644 Task/Numerical-integration/MATLAB/numerical-integration-6.m create mode 100644 Task/Numerical-integration/MATLAB/numerical-integration-7.m create mode 100644 Task/Numerical-integration/MATLAB/numerical-integration-8.m create mode 100644 Task/Numerical-integration/MATLAB/numerical-integration-9.m create mode 100644 Task/Numerical-integration/Mathematica/numerical-integration.math create mode 100644 Task/Numerical-integration/Maxima/numerical-integration.maxima create mode 100644 Task/Numerical-integration/OCaml/numerical-integration-1.ocaml create mode 100644 Task/Numerical-integration/OCaml/numerical-integration-2.ocaml create mode 100644 Task/Numerical-integration/OCaml/numerical-integration-3.ocaml create mode 100644 Task/Numerical-integration/OCaml/numerical-integration-4.ocaml create mode 100644 Task/Numerical-integration/PARI-GP/numerical-integration.pari create mode 100644 Task/Numerical-integration/PL-I/numerical-integration.pli create mode 100644 Task/Numerical-integration/Pascal/numerical-integration.pascal create mode 100644 Task/Numerical-integration/Perl-6/numerical-integration-1.pl6 create mode 100644 Task/Numerical-integration/Perl-6/numerical-integration-2.pl6 create mode 100644 Task/Numerical-integration/PicoLisp/numerical-integration.l create mode 100644 Task/Numerical-integration/PureBasic/numerical-integration.purebasic create mode 100644 Task/Numerical-integration/Python/numerical-integration-1.py create mode 100644 Task/Numerical-integration/Python/numerical-integration-2.py create mode 100644 Task/Numerical-integration/Python/numerical-integration-3.py create mode 100644 Task/Numerical-integration/R/numerical-integration.r create mode 100644 Task/Numerical-integration/REXX/numerical-integration.rexx create mode 100644 Task/Numerical-integration/Ruby/numerical-integration.rb create mode 100644 Task/Numerical-integration/Scala/numerical-integration.scala create mode 100644 Task/Numerical-integration/Scheme/numerical-integration.ss create mode 100644 Task/Numerical-integration/Standard-ML/numerical-integration.ml create mode 100644 Task/Numerical-integration/Tcl/numerical-integration.tcl create mode 100644 Task/Numerical-integration/Ursala/numerical-integration-1.ursala create mode 100644 Task/Numerical-integration/Ursala/numerical-integration-2.ursala create mode 100644 Task/Numerical-integration/Ursala/numerical-integration-3.ursala create mode 100644 Task/Numerical-integration/Ursala/numerical-integration-4.ursala create mode 100644 Task/Numerical-integration/XPL0/numerical-integration.xpl0 create mode 100644 Task/OLE-Automation/0DESCRIPTION create mode 100644 Task/OLE-Automation/1META.yaml create mode 100644 Task/OLE-Automation/AutoHotkey/ole-automation-1.ahk create mode 100644 Task/OLE-Automation/AutoHotkey/ole-automation-2.ahk create mode 100644 Task/OLE-Automation/Python/ole-automation-1.py create mode 100644 Task/OLE-Automation/Python/ole-automation-2.py create mode 100644 Task/Object-serialization/0DESCRIPTION create mode 100644 Task/Object-serialization/1META.yaml create mode 100644 Task/Object-serialization/ALGOL-68/object-serialization.alg create mode 100644 Task/Object-serialization/Ada/object-serialization-1.ada create mode 100644 Task/Object-serialization/Ada/object-serialization-2.ada create mode 100644 Task/Object-serialization/Ada/object-serialization-3.ada create mode 100644 Task/Object-serialization/C++/object-serialization.cpp create mode 100644 Task/Object-serialization/Common-Lisp/object-serialization-1.lisp create mode 100644 Task/Object-serialization/Common-Lisp/object-serialization-2.lisp create mode 100644 Task/Object-serialization/D/object-serialization.d create mode 100644 Task/Object-serialization/E/object-serialization-1.e create mode 100644 Task/Object-serialization/E/object-serialization-2.e create mode 100644 Task/Object-serialization/E/object-serialization-3.e create mode 100644 Task/Object-serialization/Go/object-serialization.go create mode 100644 Task/Object-serialization/Groovy/object-serialization-1.groovy create mode 100644 Task/Object-serialization/Groovy/object-serialization-2.groovy create mode 100644 Task/Object-serialization/Groovy/object-serialization-3.groovy create mode 100644 Task/Object-serialization/J/object-serialization-1.j create mode 100644 Task/Object-serialization/J/object-serialization-2.j create mode 100644 Task/Object-serialization/Java/object-serialization.java create mode 100644 Task/Object-serialization/OCaml/object-serialization.ocaml create mode 100644 Task/Object-serialization/Objeck/object-serialization.objeck create mode 100644 Task/Object-serialization/Objective-C/object-serialization.m create mode 100644 Task/Object-serialization/PHP/object-serialization.php create mode 100644 Task/Object-serialization/Perl/object-serialization-1.pl create mode 100644 Task/Object-serialization/Perl/object-serialization-2.pl create mode 100644 Task/Object-serialization/PicoLisp/object-serialization-1.l create mode 100644 Task/Object-serialization/PicoLisp/object-serialization-2.l create mode 100644 Task/Object-serialization/Python/object-serialization.py create mode 100644 Task/Object-serialization/Ruby/object-serialization.rb create mode 100644 Task/Object-serialization/Tcl/object-serialization.tcl create mode 100644 Task/One-dimensional-cellular-automata/0DESCRIPTION create mode 100644 Task/One-dimensional-cellular-automata/1META.yaml create mode 100644 Task/One-dimensional-cellular-automata/ACL2/one-dimensional-cellular-automata.acl2 create mode 100644 Task/One-dimensional-cellular-automata/ALGOL-68/one-dimensional-cellular-automata-1.alg create mode 100644 Task/One-dimensional-cellular-automata/ALGOL-68/one-dimensional-cellular-automata-2.alg create mode 100644 Task/One-dimensional-cellular-automata/AWK/one-dimensional-cellular-automata.awk create mode 100644 Task/One-dimensional-cellular-automata/Ada/one-dimensional-cellular-automata.ada create mode 100644 Task/One-dimensional-cellular-automata/AutoHotkey/one-dimensional-cellular-automata.ahk create mode 100644 Task/One-dimensional-cellular-automata/BASIC/one-dimensional-cellular-automata.basic create mode 100644 Task/One-dimensional-cellular-automata/BBC-BASIC/one-dimensional-cellular-automata.bbc create mode 100644 Task/One-dimensional-cellular-automata/Befunge/one-dimensional-cellular-automata.bf create mode 100644 Task/One-dimensional-cellular-automata/Bracmat/one-dimensional-cellular-automata.bracmat create mode 100644 Task/One-dimensional-cellular-automata/C++/one-dimensional-cellular-automata.cpp create mode 100644 Task/One-dimensional-cellular-automata/C-sharp/one-dimensional-cellular-automata.cs create mode 100644 Task/One-dimensional-cellular-automata/C/one-dimensional-cellular-automata-1.c create mode 100644 Task/One-dimensional-cellular-automata/C/one-dimensional-cellular-automata-2.c create mode 100644 Task/One-dimensional-cellular-automata/COBOL/one-dimensional-cellular-automata.cobol create mode 100644 Task/One-dimensional-cellular-automata/Clojure/one-dimensional-cellular-automata-1.clj create mode 100644 Task/One-dimensional-cellular-automata/Clojure/one-dimensional-cellular-automata-2.clj create mode 100644 Task/One-dimensional-cellular-automata/CoffeeScript/one-dimensional-cellular-automata-1.coffeescript create mode 100644 Task/One-dimensional-cellular-automata/CoffeeScript/one-dimensional-cellular-automata-2.coffeescript create mode 100644 Task/One-dimensional-cellular-automata/Common-Lisp/one-dimensional-cellular-automata-1.lisp create mode 100644 Task/One-dimensional-cellular-automata/Common-Lisp/one-dimensional-cellular-automata-2.lisp create mode 100644 Task/One-dimensional-cellular-automata/D/one-dimensional-cellular-automata.d create mode 100644 Task/One-dimensional-cellular-automata/DWScript/one-dimensional-cellular-automata.dwscript create mode 100644 Task/One-dimensional-cellular-automata/E/one-dimensional-cellular-automata-1.e create mode 100644 Task/One-dimensional-cellular-automata/E/one-dimensional-cellular-automata-2.e create mode 100644 Task/One-dimensional-cellular-automata/Erlang/one-dimensional-cellular-automata-1.erl create mode 100644 Task/One-dimensional-cellular-automata/Erlang/one-dimensional-cellular-automata-2.erl create mode 100644 Task/One-dimensional-cellular-automata/Euphoria/one-dimensional-cellular-automata.euphoria create mode 100644 Task/One-dimensional-cellular-automata/Factor/one-dimensional-cellular-automata.factor create mode 100644 Task/One-dimensional-cellular-automata/Fantom/one-dimensional-cellular-automata.fantom create mode 100644 Task/One-dimensional-cellular-automata/Forth/one-dimensional-cellular-automata.fth create mode 100644 Task/One-dimensional-cellular-automata/Fortran/one-dimensional-cellular-automata.f create mode 100644 Task/One-dimensional-cellular-automata/Go/one-dimensional-cellular-automata.go create mode 100644 Task/One-dimensional-cellular-automata/Groovy/one-dimensional-cellular-automata-1.groovy create mode 100644 Task/One-dimensional-cellular-automata/Groovy/one-dimensional-cellular-automata-2.groovy create mode 100644 Task/One-dimensional-cellular-automata/Haskell/one-dimensional-cellular-automata-1.hs create mode 100644 Task/One-dimensional-cellular-automata/Haskell/one-dimensional-cellular-automata-2.hs create mode 100644 Task/One-dimensional-cellular-automata/Icon/one-dimensional-cellular-automata-1.icon create mode 100644 Task/One-dimensional-cellular-automata/Icon/one-dimensional-cellular-automata-2.icon create mode 100644 Task/One-dimensional-cellular-automata/J/one-dimensional-cellular-automata-1.j create mode 100644 Task/One-dimensional-cellular-automata/J/one-dimensional-cellular-automata-2.j create mode 100644 Task/One-dimensional-cellular-automata/J/one-dimensional-cellular-automata-3.j create mode 100644 Task/One-dimensional-cellular-automata/J/one-dimensional-cellular-automata-4.j create mode 100644 Task/One-dimensional-cellular-automata/Java/one-dimensional-cellular-automata-1.java create mode 100644 Task/One-dimensional-cellular-automata/Java/one-dimensional-cellular-automata-2.java create mode 100644 Task/One-dimensional-cellular-automata/JavaScript/one-dimensional-cellular-automata-1.js create mode 100644 Task/One-dimensional-cellular-automata/JavaScript/one-dimensional-cellular-automata-2.js create mode 100644 Task/One-dimensional-cellular-automata/K/one-dimensional-cellular-automata-1.k create mode 100644 Task/One-dimensional-cellular-automata/K/one-dimensional-cellular-automata-2.k create mode 100644 Task/One-dimensional-cellular-automata/Liberty-BASIC/one-dimensional-cellular-automata.liberty create mode 100644 Task/One-dimensional-cellular-automata/Locomotive-Basic/one-dimensional-cellular-automata.locomotive create mode 100644 Task/One-dimensional-cellular-automata/Logo/one-dimensional-cellular-automata.logo create mode 100644 Task/One-dimensional-cellular-automata/Lua/one-dimensional-cellular-automata.lua create mode 100644 Task/One-dimensional-cellular-automata/M4/one-dimensional-cellular-automata.m4 create mode 100644 Task/One-dimensional-cellular-automata/Mathematica/one-dimensional-cellular-automata-1.math create mode 100644 Task/One-dimensional-cellular-automata/Mathematica/one-dimensional-cellular-automata-2.math create mode 100644 Task/One-dimensional-cellular-automata/Modula-3/one-dimensional-cellular-automata.mod3 create mode 100644 Task/One-dimensional-cellular-automata/Nial/one-dimensional-cellular-automata-1.nial create mode 100644 Task/One-dimensional-cellular-automata/Nial/one-dimensional-cellular-automata-2.nial create mode 100644 Task/One-dimensional-cellular-automata/Nimrod/one-dimensional-cellular-automata.nimrod create mode 100644 Task/One-dimensional-cellular-automata/OCaml/one-dimensional-cellular-automata.ocaml create mode 100644 Task/One-dimensional-cellular-automata/Oz/one-dimensional-cellular-automata.oz create mode 100644 Task/One-dimensional-cellular-automata/PARI-GP/one-dimensional-cellular-automata.pari create mode 100644 Task/One-dimensional-cellular-automata/Perl-6/one-dimensional-cellular-automata.pl6 create mode 100644 Task/One-dimensional-cellular-automata/Perl/one-dimensional-cellular-automata-1.pl create mode 100644 Task/One-dimensional-cellular-automata/Perl/one-dimensional-cellular-automata-2.pl create mode 100644 Task/One-dimensional-cellular-automata/PicoLisp/one-dimensional-cellular-automata.l create mode 100644 Task/One-dimensional-cellular-automata/Prolog/one-dimensional-cellular-automata.pro create mode 100644 Task/One-dimensional-cellular-automata/PureBasic/one-dimensional-cellular-automata.purebasic create mode 100644 Task/One-dimensional-cellular-automata/Python/one-dimensional-cellular-automata-1.py create mode 100644 Task/One-dimensional-cellular-automata/Python/one-dimensional-cellular-automata-2.py create mode 100644 Task/One-dimensional-cellular-automata/R/one-dimensional-cellular-automata.r create mode 100644 Task/One-dimensional-cellular-automata/Retro/one-dimensional-cellular-automata.retro create mode 100644 Task/One-dimensional-cellular-automata/Ruby/one-dimensional-cellular-automata.rb create mode 100644 Task/One-dimensional-cellular-automata/Scala/one-dimensional-cellular-automata.scala create mode 100644 Task/One-dimensional-cellular-automata/Scheme/one-dimensional-cellular-automata.ss create mode 100644 Task/One-dimensional-cellular-automata/Seed7/one-dimensional-cellular-automata.seed7 create mode 100644 Task/One-dimensional-cellular-automata/Tcl/one-dimensional-cellular-automata.tcl create mode 100644 Task/One-dimensional-cellular-automata/Ursala/one-dimensional-cellular-automata.ursala create mode 100644 Task/One-dimensional-cellular-automata/Vedit-macro-language/one-dimensional-cellular-automata-1.vedit create mode 100644 Task/One-dimensional-cellular-automata/Vedit-macro-language/one-dimensional-cellular-automata-2.vedit create mode 100644 Task/One-dimensional-cellular-automata/Visual-Basic-.NET/one-dimensional-cellular-automata.visual create mode 100644 Task/One-dimensional-cellular-automata/XPL0/one-dimensional-cellular-automata.xpl0 create mode 100644 Task/One-of-n-lines-in-a-file/0DESCRIPTION create mode 100644 Task/One-of-n-lines-in-a-file/Ada/one-of-n-lines-in-a-file.ada create mode 100644 Task/One-of-n-lines-in-a-file/AutoHotkey/one-of-n-lines-in-a-file.ahk create mode 100644 Task/One-of-n-lines-in-a-file/BASIC/one-of-n-lines-in-a-file.basic create mode 100644 Task/One-of-n-lines-in-a-file/BBC-BASIC/one-of-n-lines-in-a-file.bbc create mode 100644 Task/One-of-n-lines-in-a-file/C++/one-of-n-lines-in-a-file.cpp create mode 100644 Task/One-of-n-lines-in-a-file/C/one-of-n-lines-in-a-file.c create mode 100644 Task/One-of-n-lines-in-a-file/D/one-of-n-lines-in-a-file.d create mode 100644 Task/One-of-n-lines-in-a-file/Euphoria/one-of-n-lines-in-a-file.euphoria create mode 100644 Task/One-of-n-lines-in-a-file/Factor/one-of-n-lines-in-a-file-1.factor create mode 100644 Task/One-of-n-lines-in-a-file/Factor/one-of-n-lines-in-a-file-2.factor create mode 100644 Task/One-of-n-lines-in-a-file/Go/one-of-n-lines-in-a-file.go create mode 100644 Task/One-of-n-lines-in-a-file/Haskell/one-of-n-lines-in-a-file.hs create mode 100644 Task/One-of-n-lines-in-a-file/Icon/one-of-n-lines-in-a-file.icon create mode 100644 Task/One-of-n-lines-in-a-file/J/one-of-n-lines-in-a-file-1.j create mode 100644 Task/One-of-n-lines-in-a-file/J/one-of-n-lines-in-a-file-2.j create mode 100644 Task/One-of-n-lines-in-a-file/Java/one-of-n-lines-in-a-file.java create mode 100644 Task/One-of-n-lines-in-a-file/OCaml/one-of-n-lines-in-a-file.ocaml create mode 100644 Task/One-of-n-lines-in-a-file/Pascal/one-of-n-lines-in-a-file.pascal create mode 100644 Task/One-of-n-lines-in-a-file/Perl-6/one-of-n-lines-in-a-file.pl6 create mode 100644 Task/One-of-n-lines-in-a-file/PicoLisp/one-of-n-lines-in-a-file.l create mode 100644 Task/One-of-n-lines-in-a-file/PureBasic/one-of-n-lines-in-a-file.purebasic create mode 100644 Task/One-of-n-lines-in-a-file/Python/one-of-n-lines-in-a-file.py create mode 100644 Task/One-of-n-lines-in-a-file/REXX/one-of-n-lines-in-a-file.rexx create mode 100644 Task/One-of-n-lines-in-a-file/Ruby/one-of-n-lines-in-a-file.rb create mode 100644 Task/One-of-n-lines-in-a-file/Run-BASIC/one-of-n-lines-in-a-file.run create mode 100644 Task/One-of-n-lines-in-a-file/Seed7/one-of-n-lines-in-a-file.seed7 create mode 100644 Task/One-of-n-lines-in-a-file/Tcl/one-of-n-lines-in-a-file.tcl create mode 100644 Task/OpenGL/0DESCRIPTION create mode 100644 Task/OpenGL/1META.yaml create mode 100644 Task/OpenGL/Ada/opengl.ada create mode 100644 Task/OpenGL/AutoHotkey/opengl.ahk create mode 100644 Task/OpenGL/BBC-BASIC/opengl.bbc create mode 100644 Task/OpenGL/C/opengl.c create mode 100644 Task/OpenGL/Clojure/opengl.clj create mode 100644 Task/OpenGL/D/opengl.d create mode 100644 Task/OpenGL/Factor/opengl.factor create mode 100644 Task/OpenGL/Forth/opengl-1.fth create mode 100644 Task/OpenGL/Forth/opengl-2.fth create mode 100644 Task/OpenGL/Haskell/opengl.hs create mode 100644 Task/OpenGL/J/opengl.j create mode 100644 Task/OpenGL/Java/opengl.java create mode 100644 Task/OpenGL/JavaScript/opengl.js create mode 100644 Task/OpenGL/Liberty-BASIC/opengl.liberty create mode 100644 Task/OpenGL/Lua/opengl.lua create mode 100644 Task/OpenGL/MAXScript/opengl.maxscript create mode 100644 Task/OpenGL/Mercury/opengl.mercury create mode 100644 Task/OpenGL/OCaml/opengl.ocaml create mode 100644 Task/OpenGL/OxygenBasic/opengl.oxy create mode 100644 Task/OpenGL/Pascal/opengl.pascal create mode 100644 Task/OpenGL/Perl/opengl-1.pl create mode 100644 Task/OpenGL/Perl/opengl-2.pl create mode 100644 Task/OpenGL/PicoLisp/opengl.l create mode 100644 Task/OpenGL/Pike/opengl.pike create mode 100644 Task/OpenGL/PureBasic/opengl.purebasic create mode 100644 Task/OpenGL/Python/opengl.py create mode 100644 Task/OpenGL/R/opengl.r create mode 100644 Task/OpenGL/Racket/opengl.rkt create mode 100644 Task/OpenGL/Ruby/opengl.rb create mode 100644 Task/OpenGL/Tcl/opengl.tcl create mode 100644 Task/Operator-precedence/0DESCRIPTION create mode 100644 Task/Operator-precedence/REXX/operator-precedence.rexx create mode 100644 Task/Optional-parameters/0DESCRIPTION create mode 100644 Task/Optional-parameters/1META.yaml create mode 100644 Task/Optional-parameters/Ada/optional-parameters-1.ada create mode 100644 Task/Optional-parameters/Ada/optional-parameters-2.ada create mode 100644 Task/Optional-parameters/AppleScript/optional-parameters-1.applescript create mode 100644 Task/Optional-parameters/AppleScript/optional-parameters-2.applescript create mode 100644 Task/Optional-parameters/AutoHotkey/optional-parameters.ahk create mode 100644 Task/Optional-parameters/BBC-BASIC/optional-parameters.bbc create mode 100644 Task/Optional-parameters/C++/optional-parameters.cpp create mode 100644 Task/Optional-parameters/C/optional-parameters.c create mode 100644 Task/Optional-parameters/Clojure/optional-parameters.clj create mode 100644 Task/Optional-parameters/Common-Lisp/optional-parameters-1.lisp create mode 100644 Task/Optional-parameters/Common-Lisp/optional-parameters-2.lisp create mode 100644 Task/Optional-parameters/D/optional-parameters.d create mode 100644 Task/Optional-parameters/E/optional-parameters.e create mode 100644 Task/Optional-parameters/Fortran/optional-parameters-1.f create mode 100644 Task/Optional-parameters/Fortran/optional-parameters-2.f create mode 100644 Task/Optional-parameters/Go/optional-parameters-1.go create mode 100644 Task/Optional-parameters/Go/optional-parameters-2.go create mode 100644 Task/Optional-parameters/Go/optional-parameters-3.go create mode 100644 Task/Optional-parameters/Icon/optional-parameters.icon create mode 100644 Task/Optional-parameters/J/optional-parameters-1.j create mode 100644 Task/Optional-parameters/J/optional-parameters-2.j create mode 100644 Task/Optional-parameters/Java/optional-parameters.java create mode 100644 Task/Optional-parameters/JavaScript/optional-parameters.js create mode 100644 Task/Optional-parameters/Logo/optional-parameters-1.logo create mode 100644 Task/Optional-parameters/Logo/optional-parameters-2.logo create mode 100644 Task/Optional-parameters/Mathematica/optional-parameters.math create mode 100644 Task/Optional-parameters/Nemerle/optional-parameters.nemerle create mode 100644 Task/Optional-parameters/OCaml/optional-parameters-1.ocaml create mode 100644 Task/Optional-parameters/OCaml/optional-parameters-2.ocaml create mode 100644 Task/Optional-parameters/Objective-C/optional-parameters.m create mode 100644 Task/Optional-parameters/Oz/optional-parameters.oz create mode 100644 Task/Optional-parameters/PARI-GP/optional-parameters-1.pari create mode 100644 Task/Optional-parameters/PARI-GP/optional-parameters-2.pari create mode 100644 Task/Optional-parameters/Perl-6/optional-parameters.pl6 create mode 100644 Task/Optional-parameters/Perl/optional-parameters-1.pl create mode 100644 Task/Optional-parameters/Perl/optional-parameters-2.pl create mode 100644 Task/Optional-parameters/PicoLisp/optional-parameters.l create mode 100644 Task/Optional-parameters/Python/optional-parameters.py create mode 100644 Task/Optional-parameters/R/optional-parameters.r create mode 100644 Task/Optional-parameters/Racket/optional-parameters.rkt create mode 100644 Task/Optional-parameters/Ruby/optional-parameters-1.rb create mode 100644 Task/Optional-parameters/Ruby/optional-parameters-2.rb create mode 100644 Task/Optional-parameters/Ruby/optional-parameters-3.rb create mode 100644 Task/Optional-parameters/Scala/optional-parameters-1.scala create mode 100644 Task/Optional-parameters/Scala/optional-parameters-2.scala create mode 100644 Task/Optional-parameters/Slate/optional-parameters.slate create mode 100644 Task/Optional-parameters/TIScript/optional-parameters.tiscript create mode 100644 Task/Optional-parameters/Tcl/optional-parameters-1.tcl create mode 100644 Task/Optional-parameters/Tcl/optional-parameters-2.tcl create mode 100644 Task/Optional-parameters/Ursala/optional-parameters-1.ursala create mode 100644 Task/Optional-parameters/Ursala/optional-parameters-2.ursala create mode 100644 Task/Optional-parameters/XSLT/optional-parameters.xslt create mode 100644 Task/Order-two-numerical-lists/0DESCRIPTION create mode 100644 Task/Order-two-numerical-lists/1META.yaml create mode 100644 Task/Order-two-numerical-lists/Ada/order-two-numerical-lists.ada create mode 100644 Task/Order-two-numerical-lists/AutoHotkey/order-two-numerical-lists.ahk create mode 100644 Task/Order-two-numerical-lists/BBC-BASIC/order-two-numerical-lists.bbc create mode 100644 Task/Order-two-numerical-lists/Bracmat/order-two-numerical-lists.bracmat create mode 100644 Task/Order-two-numerical-lists/C++/order-two-numerical-lists.cpp create mode 100644 Task/Order-two-numerical-lists/C/order-two-numerical-lists-1.c create mode 100644 Task/Order-two-numerical-lists/C/order-two-numerical-lists-2.c create mode 100644 Task/Order-two-numerical-lists/Common-Lisp/order-two-numerical-lists-1.lisp create mode 100644 Task/Order-two-numerical-lists/Common-Lisp/order-two-numerical-lists-2.lisp create mode 100644 Task/Order-two-numerical-lists/D/order-two-numerical-lists.d create mode 100644 Task/Order-two-numerical-lists/Ela/order-two-numerical-lists.ela create mode 100644 Task/Order-two-numerical-lists/Go/order-two-numerical-lists.go create mode 100644 Task/Order-two-numerical-lists/Groovy/order-two-numerical-lists-1.groovy create mode 100644 Task/Order-two-numerical-lists/Groovy/order-two-numerical-lists-2.groovy create mode 100644 Task/Order-two-numerical-lists/Haskell/order-two-numerical-lists.hs create mode 100644 Task/Order-two-numerical-lists/Icon/order-two-numerical-lists.icon create mode 100644 Task/Order-two-numerical-lists/J/order-two-numerical-lists-1.j create mode 100644 Task/Order-two-numerical-lists/J/order-two-numerical-lists-2.j create mode 100644 Task/Order-two-numerical-lists/Java/order-two-numerical-lists.java create mode 100644 Task/Order-two-numerical-lists/Joy/order-two-numerical-lists.joy create mode 100644 Task/Order-two-numerical-lists/Lhogho/order-two-numerical-lists-1.lhogho create mode 100644 Task/Order-two-numerical-lists/Lhogho/order-two-numerical-lists-2.lhogho create mode 100644 Task/Order-two-numerical-lists/Mathematica/order-two-numerical-lists.math create mode 100644 Task/Order-two-numerical-lists/Maxima/order-two-numerical-lists.maxima create mode 100644 Task/Order-two-numerical-lists/Mercury/order-two-numerical-lists-1.mercury create mode 100644 Task/Order-two-numerical-lists/Mercury/order-two-numerical-lists-2.mercury create mode 100644 Task/Order-two-numerical-lists/Mercury/order-two-numerical-lists-3.mercury create mode 100644 Task/Order-two-numerical-lists/Mercury/order-two-numerical-lists-4.mercury create mode 100644 Task/Order-two-numerical-lists/OCaml/order-two-numerical-lists-1.ocaml create mode 100644 Task/Order-two-numerical-lists/OCaml/order-two-numerical-lists-2.ocaml create mode 100644 Task/Order-two-numerical-lists/OCaml/order-two-numerical-lists-3.ocaml create mode 100644 Task/Order-two-numerical-lists/OCaml/order-two-numerical-lists-4.ocaml create mode 100644 Task/Order-two-numerical-lists/PARI-GP/order-two-numerical-lists.pari create mode 100644 Task/Order-two-numerical-lists/Perl-6/order-two-numerical-lists.pl6 create mode 100644 Task/Order-two-numerical-lists/Perl/order-two-numerical-lists.pl create mode 100644 Task/Order-two-numerical-lists/PicoLisp/order-two-numerical-lists.l create mode 100644 Task/Order-two-numerical-lists/Pike/order-two-numerical-lists-1.pike create mode 100644 Task/Order-two-numerical-lists/Pike/order-two-numerical-lists-2.pike create mode 100644 Task/Order-two-numerical-lists/PureBasic/order-two-numerical-lists.purebasic create mode 100644 Task/Order-two-numerical-lists/Python/order-two-numerical-lists.py create mode 100644 Task/Order-two-numerical-lists/Rascal/order-two-numerical-lists.rascal create mode 100644 Task/Order-two-numerical-lists/Ruby/order-two-numerical-lists.rb create mode 100644 Task/Order-two-numerical-lists/Scheme/order-two-numerical-lists.ss create mode 100644 Task/Order-two-numerical-lists/Standard-ML/order-two-numerical-lists.ml create mode 100644 Task/Order-two-numerical-lists/TUSCRIPT/order-two-numerical-lists.tuscript create mode 100644 Task/Order-two-numerical-lists/Tcl/order-two-numerical-lists.tcl create mode 100644 Task/Ordered-Partitions/0DESCRIPTION create mode 100644 Task/Ordered-Partitions/1META.yaml create mode 100644 Task/Ordered-Partitions/Ada/ordered-partitions-1.ada create mode 100644 Task/Ordered-Partitions/Ada/ordered-partitions-2.ada create mode 100644 Task/Ordered-Partitions/Ada/ordered-partitions-3.ada create mode 100644 Task/Ordered-Partitions/BBC-BASIC/ordered-partitions.bbc create mode 100644 Task/Ordered-Partitions/C/ordered-partitions-1.c create mode 100644 Task/Ordered-Partitions/C/ordered-partitions-2.c create mode 100644 Task/Ordered-Partitions/Common-Lisp/ordered-partitions.lisp create mode 100644 Task/Ordered-Partitions/D/ordered-partitions.d create mode 100644 Task/Ordered-Partitions/GAP/ordered-partitions.gap create mode 100644 Task/Ordered-Partitions/Go/ordered-partitions.go create mode 100644 Task/Ordered-Partitions/Groovy/ordered-partitions-1.groovy create mode 100644 Task/Ordered-Partitions/Groovy/ordered-partitions-2.groovy create mode 100644 Task/Ordered-Partitions/Haskell/ordered-partitions-1.hs create mode 100644 Task/Ordered-Partitions/Haskell/ordered-partitions-2.hs create mode 100644 Task/Ordered-Partitions/Haskell/ordered-partitions-3.hs create mode 100644 Task/Ordered-Partitions/J/ordered-partitions-1.j create mode 100644 Task/Ordered-Partitions/J/ordered-partitions-2.j create mode 100644 Task/Ordered-Partitions/Lua/ordered-partitions.lua create mode 100644 Task/Ordered-Partitions/Mathematica/ordered-partitions-1.math create mode 100644 Task/Ordered-Partitions/Mathematica/ordered-partitions-2.math create mode 100644 Task/Ordered-Partitions/Perl-6/ordered-partitions.pl6 create mode 100644 Task/Ordered-Partitions/Perl/ordered-partitions-1.pl create mode 100644 Task/Ordered-Partitions/Perl/ordered-partitions-2.pl create mode 100644 Task/Ordered-Partitions/PicoLisp/ordered-partitions.l create mode 100644 Task/Ordered-Partitions/Python/ordered-partitions-1.py create mode 100644 Task/Ordered-Partitions/Python/ordered-partitions-2.py create mode 100644 Task/Ordered-Partitions/Tcl/ordered-partitions-1.tcl create mode 100644 Task/Ordered-Partitions/Tcl/ordered-partitions-2.tcl create mode 100644 Task/Ordered-Partitions/Ursala/ordered-partitions-1.ursala create mode 100644 Task/Ordered-Partitions/Ursala/ordered-partitions-2.ursala create mode 100644 Task/Palindrome-detection/0DESCRIPTION create mode 100644 Task/Palindrome-detection/1META.yaml create mode 100644 Task/Palindrome-detection/ACL2/palindrome-detection.acl2 create mode 100644 Task/Palindrome-detection/ALGOL-68/palindrome-detection.alg create mode 100644 Task/Palindrome-detection/AWK/palindrome-detection-1.awk create mode 100644 Task/Palindrome-detection/AWK/palindrome-detection-2.awk create mode 100644 Task/Palindrome-detection/AWK/palindrome-detection-3.awk create mode 100644 Task/Palindrome-detection/ActionScript/palindrome-detection.as create mode 100644 Task/Palindrome-detection/Ada/palindrome-detection.ada create mode 100644 Task/Palindrome-detection/AutoHotkey/palindrome-detection.ahk create mode 100644 Task/Palindrome-detection/AutoIt/palindrome-detection.autoit create mode 100644 Task/Palindrome-detection/BASIC/palindrome-detection.basic create mode 100644 Task/Palindrome-detection/BBC-BASIC/palindrome-detection.bbc create mode 100644 Task/Palindrome-detection/Befunge/palindrome-detection-1.bf create mode 100644 Task/Palindrome-detection/Befunge/palindrome-detection-2.bf create mode 100644 Task/Palindrome-detection/Burlesque/palindrome-detection.blq create mode 100644 Task/Palindrome-detection/C++/palindrome-detection-1.cpp create mode 100644 Task/Palindrome-detection/C++/palindrome-detection-2.cpp create mode 100644 Task/Palindrome-detection/C/palindrome-detection-1.c create mode 100644 Task/Palindrome-detection/C/palindrome-detection-2.c create mode 100644 Task/Palindrome-detection/C/palindrome-detection-3.c create mode 100644 Task/Palindrome-detection/C/palindrome-detection-4.c create mode 100644 Task/Palindrome-detection/Clojure/palindrome-detection-1.clj create mode 100644 Task/Palindrome-detection/Clojure/palindrome-detection-2.clj create mode 100644 Task/Palindrome-detection/CoffeeScript/palindrome-detection-1.coffeescript create mode 100644 Task/Palindrome-detection/CoffeeScript/palindrome-detection-2.coffeescript create mode 100644 Task/Palindrome-detection/Common-Lisp/palindrome-detection.lisp create mode 100644 Task/Palindrome-detection/D/palindrome-detection-1.d create mode 100644 Task/Palindrome-detection/D/palindrome-detection-2.d create mode 100644 Task/Palindrome-detection/D/palindrome-detection-3.d create mode 100644 Task/Palindrome-detection/D/palindrome-detection-4.d create mode 100644 Task/Palindrome-detection/Delphi/palindrome-detection.delphi create mode 100644 Task/Palindrome-detection/E/palindrome-detection.e create mode 100644 Task/Palindrome-detection/Ela/palindrome-detection-1.ela create mode 100644 Task/Palindrome-detection/Ela/palindrome-detection-2.ela create mode 100644 Task/Palindrome-detection/Erlang/palindrome-detection.erl create mode 100644 Task/Palindrome-detection/Euphoria/palindrome-detection.euphoria create mode 100644 Task/Palindrome-detection/Factor/palindrome-detection.factor create mode 100644 Task/Palindrome-detection/Fantom/palindrome-detection.fantom create mode 100644 Task/Palindrome-detection/Forth/palindrome-detection.fth create mode 100644 Task/Palindrome-detection/Fortran/palindrome-detection-1.f create mode 100644 Task/Palindrome-detection/Fortran/palindrome-detection-2.f create mode 100644 Task/Palindrome-detection/Fortran/palindrome-detection-3.f create mode 100644 Task/Palindrome-detection/Fortran/palindrome-detection-4.f create mode 100644 Task/Palindrome-detection/GAP/palindrome-detection.gap create mode 100644 Task/Palindrome-detection/GML/palindrome-detection.gml create mode 100644 Task/Palindrome-detection/Go/palindrome-detection.go create mode 100644 Task/Palindrome-detection/Groovy/palindrome-detection-1.groovy create mode 100644 Task/Palindrome-detection/Groovy/palindrome-detection-2.groovy create mode 100644 Task/Palindrome-detection/Groovy/palindrome-detection-3.groovy create mode 100644 Task/Palindrome-detection/Groovy/palindrome-detection-4.groovy create mode 100644 Task/Palindrome-detection/Haskell/palindrome-detection-1.hs create mode 100644 Task/Palindrome-detection/Haskell/palindrome-detection-2.hs create mode 100644 Task/Palindrome-detection/HicEst/palindrome-detection.hicest create mode 100644 Task/Palindrome-detection/Icon/palindrome-detection-1.icon create mode 100644 Task/Palindrome-detection/Icon/palindrome-detection-2.icon create mode 100644 Task/Palindrome-detection/Icon/palindrome-detection-3.icon create mode 100644 Task/Palindrome-detection/Ioke/palindrome-detection.ioke create mode 100644 Task/Palindrome-detection/J/palindrome-detection-1.j create mode 100644 Task/Palindrome-detection/J/palindrome-detection-2.j create mode 100644 Task/Palindrome-detection/J/palindrome-detection-3.j create mode 100644 Task/Palindrome-detection/J/palindrome-detection-4.j create mode 100644 Task/Palindrome-detection/Java/palindrome-detection-1.java create mode 100644 Task/Palindrome-detection/Java/palindrome-detection-2.java create mode 100644 Task/Palindrome-detection/Java/palindrome-detection-3.java create mode 100644 Task/Palindrome-detection/JavaScript/palindrome-detection-1.js create mode 100644 Task/Palindrome-detection/JavaScript/palindrome-detection-2.js create mode 100644 Task/Palindrome-detection/Liberty-BASIC/palindrome-detection.liberty create mode 100644 Task/Palindrome-detection/Logo/palindrome-detection.logo create mode 100644 Task/Palindrome-detection/Lua/palindrome-detection.lua create mode 100644 Task/Palindrome-detection/M4/palindrome-detection-1.m4 create mode 100644 Task/Palindrome-detection/M4/palindrome-detection-2.m4 create mode 100644 Task/Palindrome-detection/MATLAB/palindrome-detection-1.m create mode 100644 Task/Palindrome-detection/MATLAB/palindrome-detection-2.m create mode 100644 Task/Palindrome-detection/MAXScript/palindrome-detection-1.maxscript create mode 100644 Task/Palindrome-detection/MAXScript/palindrome-detection-2.maxscript create mode 100644 Task/Palindrome-detection/MAXScript/palindrome-detection-3.maxscript create mode 100644 Task/Palindrome-detection/MMIX/palindrome-detection.mmix create mode 100644 Task/Palindrome-detection/Mathematica/palindrome-detection.math create mode 100644 Task/Palindrome-detection/Maxima/palindrome-detection.maxima create mode 100644 Task/Palindrome-detection/Mirah/palindrome-detection.mirah create mode 100644 Task/Palindrome-detection/Modula-3/palindrome-detection.mod3 create mode 100644 Task/Palindrome-detection/Nemerle/palindrome-detection-1.nemerle create mode 100644 Task/Palindrome-detection/Nemerle/palindrome-detection-2.nemerle create mode 100644 Task/Palindrome-detection/NetRexx/palindrome-detection.netrexx create mode 100644 Task/Palindrome-detection/OCaml/palindrome-detection-1.ocaml create mode 100644 Task/Palindrome-detection/OCaml/palindrome-detection-2.ocaml create mode 100644 Task/Palindrome-detection/Objeck/palindrome-detection.objeck create mode 100644 Task/Palindrome-detection/Octave/palindrome-detection-1.octave create mode 100644 Task/Palindrome-detection/Octave/palindrome-detection-2.octave create mode 100644 Task/Palindrome-detection/Octave/palindrome-detection-3.octave create mode 100644 Task/Palindrome-detection/Oz/palindrome-detection.oz create mode 100644 Task/Palindrome-detection/PARI-GP/palindrome-detection.pari create mode 100644 Task/Palindrome-detection/PHP/palindrome-detection-1.php create mode 100644 Task/Palindrome-detection/PHP/palindrome-detection-2.php create mode 100644 Task/Palindrome-detection/PL-I/palindrome-detection.pli create mode 100644 Task/Palindrome-detection/Pascal/palindrome-detection-1.pascal create mode 100644 Task/Palindrome-detection/Pascal/palindrome-detection-2.pascal create mode 100644 Task/Palindrome-detection/Perl-6/palindrome-detection.pl6 create mode 100644 Task/Palindrome-detection/Perl/palindrome-detection-1.pl create mode 100644 Task/Palindrome-detection/Perl/palindrome-detection-2.pl create mode 100644 Task/Palindrome-detection/PicoLisp/palindrome-detection.l create mode 100644 Task/Palindrome-detection/Pike/palindrome-detection.pike create mode 100644 Task/Palindrome-detection/PowerBASIC/palindrome-detection.powerbasic create mode 100644 Task/Palindrome-detection/Prolog/palindrome-detection-1.pro create mode 100644 Task/Palindrome-detection/Prolog/palindrome-detection-2.pro create mode 100644 Task/Palindrome-detection/Prolog/palindrome-detection-3.pro create mode 100644 Task/Palindrome-detection/PureBasic/palindrome-detection.purebasic create mode 100644 Task/Palindrome-detection/Python/palindrome-detection-1.py create mode 100644 Task/Palindrome-detection/Python/palindrome-detection-2.py create mode 100644 Task/Palindrome-detection/Python/palindrome-detection-3.py create mode 100644 Task/Palindrome-detection/Python/palindrome-detection-4.py create mode 100644 Task/Palindrome-detection/R/palindrome-detection-1.r create mode 100644 Task/Palindrome-detection/R/palindrome-detection-2.r create mode 100644 Task/Palindrome-detection/R/palindrome-detection-3.r create mode 100644 Task/Palindrome-detection/REBOL/palindrome-detection.rebol create mode 100644 Task/Palindrome-detection/REXX/palindrome-detection.rexx create mode 100644 Task/Palindrome-detection/Racket/palindrome-detection.rkt create mode 100644 Task/Palindrome-detection/Rascal/palindrome-detection-1.rascal create mode 100644 Task/Palindrome-detection/Rascal/palindrome-detection-2.rascal create mode 100644 Task/Palindrome-detection/Rascal/palindrome-detection-3.rascal create mode 100644 Task/Palindrome-detection/Retro/palindrome-detection.retro create mode 100644 Task/Palindrome-detection/Ruby/palindrome-detection-1.rb create mode 100644 Task/Palindrome-detection/Ruby/palindrome-detection-2.rb create mode 100644 Task/Palindrome-detection/Ruby/palindrome-detection-3.rb create mode 100644 Task/Palindrome-detection/Run-BASIC/palindrome-detection.run create mode 100644 Task/Palindrome-detection/SNOBOL4/palindrome-detection.sno create mode 100644 Task/Palindrome-detection/Scala/palindrome-detection-1.scala create mode 100644 Task/Palindrome-detection/Scala/palindrome-detection-2.scala create mode 100644 Task/Palindrome-detection/Scala/palindrome-detection-3.scala create mode 100644 Task/Palindrome-detection/Scala/palindrome-detection-4.scala create mode 100644 Task/Palindrome-detection/Scala/palindrome-detection-5.scala create mode 100644 Task/Palindrome-detection/Scheme/palindrome-detection-1.ss create mode 100644 Task/Palindrome-detection/Scheme/palindrome-detection-2.ss create mode 100644 Task/Palindrome-detection/Seed7/palindrome-detection-1.seed7 create mode 100644 Task/Palindrome-detection/Seed7/palindrome-detection-2.seed7 create mode 100644 Task/Palindrome-detection/Slate/palindrome-detection-1.slate create mode 100644 Task/Palindrome-detection/Slate/palindrome-detection-2.slate create mode 100644 Task/Palindrome-detection/Slate/palindrome-detection-3.slate create mode 100644 Task/Palindrome-detection/Smalltalk/palindrome-detection-1.st create mode 100644 Task/Palindrome-detection/Smalltalk/palindrome-detection-2.st create mode 100644 Task/Palindrome-detection/Smalltalk/palindrome-detection-3.st create mode 100644 Task/Palindrome-detection/Smalltalk/palindrome-detection-4.st create mode 100644 Task/Palindrome-detection/TUSCRIPT/palindrome-detection.tuscript create mode 100644 Task/Palindrome-detection/Tcl/palindrome-detection-1.tcl create mode 100644 Task/Palindrome-detection/Tcl/palindrome-detection-2.tcl create mode 100644 Task/Palindrome-detection/Tcl/palindrome-detection-3.tcl create mode 100644 Task/Palindrome-detection/Ursala/palindrome-detection-1.ursala create mode 100644 Task/Palindrome-detection/Ursala/palindrome-detection-2.ursala create mode 100644 Task/Palindrome-detection/VBA/palindrome-detection.vba create mode 100644 Task/Palindrome-detection/VBScript/palindrome-detection-1.vbscript create mode 100644 Task/Palindrome-detection/VBScript/palindrome-detection-2.vbscript create mode 100644 Task/Palindrome-detection/VBScript/palindrome-detection-3.vbscript create mode 100644 Task/Palindrome-detection/Vedit-macro-language/palindrome-detection-1.vedit create mode 100644 Task/Palindrome-detection/Vedit-macro-language/palindrome-detection-2.vedit create mode 100644 Task/Palindrome-detection/XPL0/palindrome-detection.xpl0 create mode 100644 Task/Palindrome-detection/Yorick/palindrome-detection.yorick create mode 100644 Task/Pangram-checker/0DESCRIPTION create mode 100644 Task/Pangram-checker/ACL2/pangram-checker.acl2 create mode 100644 Task/Pangram-checker/ALGOL-68/pangram-checker.alg create mode 100644 Task/Pangram-checker/APL/pangram-checker.apl create mode 100644 Task/Pangram-checker/AWK/pangram-checker.awk create mode 100644 Task/Pangram-checker/ActionScript/pangram-checker.as create mode 100644 Task/Pangram-checker/Ada/pangram-checker.ada create mode 100644 Task/Pangram-checker/AutoHotkey/pangram-checker.ahk create mode 100644 Task/Pangram-checker/AutoIt/pangram-checker.autoit create mode 100644 Task/Pangram-checker/BASIC/pangram-checker.basic create mode 100644 Task/Pangram-checker/BBC-BASIC/pangram-checker.bbc create mode 100644 Task/Pangram-checker/Bracmat/pangram-checker.bracmat create mode 100644 Task/Pangram-checker/Brat/pangram-checker-1.brat create mode 100644 Task/Pangram-checker/Brat/pangram-checker-2.brat create mode 100644 Task/Pangram-checker/C++/pangram-checker.cpp create mode 100644 Task/Pangram-checker/C/pangram-checker-1.c create mode 100644 Task/Pangram-checker/C/pangram-checker-2.c create mode 100644 Task/Pangram-checker/Clojure/pangram-checker.clj create mode 100644 Task/Pangram-checker/CoffeeScript/pangram-checker.coffeescript create mode 100644 Task/Pangram-checker/Common-Lisp/pangram-checker.lisp create mode 100644 Task/Pangram-checker/D/pangram-checker-1.d create mode 100644 Task/Pangram-checker/D/pangram-checker-2.d create mode 100644 Task/Pangram-checker/Delphi/pangram-checker.delphi create mode 100644 Task/Pangram-checker/E/pangram-checker.e create mode 100644 Task/Pangram-checker/Erlang/pangram-checker.erl create mode 100644 Task/Pangram-checker/Factor/pangram-checker.factor create mode 100644 Task/Pangram-checker/Forth/pangram-checker.fth create mode 100644 Task/Pangram-checker/Fortran/pangram-checker-1.f create mode 100644 Task/Pangram-checker/Fortran/pangram-checker-2.f create mode 100644 Task/Pangram-checker/Go/pangram-checker.go create mode 100644 Task/Pangram-checker/Haskell/pangram-checker.hs create mode 100644 Task/Pangram-checker/HicEst/pangram-checker.hicest create mode 100644 Task/Pangram-checker/Icon/pangram-checker-1.icon create mode 100644 Task/Pangram-checker/Icon/pangram-checker-2.icon create mode 100644 Task/Pangram-checker/Ioke/pangram-checker-1.ioke create mode 100644 Task/Pangram-checker/Ioke/pangram-checker-2.ioke create mode 100644 Task/Pangram-checker/J/pangram-checker-1.j create mode 100644 Task/Pangram-checker/J/pangram-checker-2.j create mode 100644 Task/Pangram-checker/Java/pangram-checker.java create mode 100644 Task/Pangram-checker/JavaScript/pangram-checker.js create mode 100644 Task/Pangram-checker/K/pangram-checker-1.k create mode 100644 Task/Pangram-checker/K/pangram-checker-2.k create mode 100644 Task/Pangram-checker/Liberty-BASIC/pangram-checker.liberty create mode 100644 Task/Pangram-checker/Logo/pangram-checker.logo create mode 100644 Task/Pangram-checker/Lua/pangram-checker.lua create mode 100644 Task/Pangram-checker/MATLAB/pangram-checker-1.m create mode 100644 Task/Pangram-checker/MATLAB/pangram-checker-2.m create mode 100644 Task/Pangram-checker/MATLAB/pangram-checker.m create mode 100644 Task/Pangram-checker/Mathematica/pangram-checker.math create mode 100644 Task/Pangram-checker/NetRexx/pangram-checker.netrexx create mode 100644 Task/Pangram-checker/OCaml/pangram-checker-1.ocaml create mode 100644 Task/Pangram-checker/OCaml/pangram-checker-2.ocaml create mode 100644 Task/Pangram-checker/Objeck/pangram-checker.objeck create mode 100644 Task/Pangram-checker/Oz/pangram-checker.oz create mode 100644 Task/Pangram-checker/PARI-GP/pangram-checker.pari create mode 100644 Task/Pangram-checker/PHP/pangram-checker.php create mode 100644 Task/Pangram-checker/PL-I/pangram-checker.pli create mode 100644 Task/Pangram-checker/Perl-6/pangram-checker.pl6 create mode 100644 Task/Pangram-checker/Perl/pangram-checker.pl create mode 100644 Task/Pangram-checker/PicoLisp/pangram-checker.l create mode 100644 Task/Pangram-checker/Prolog/pangram-checker.pro create mode 100644 Task/Pangram-checker/PureBasic/pangram-checker.purebasic create mode 100644 Task/Pangram-checker/Python/pangram-checker.py create mode 100644 Task/Pangram-checker/R/pangram-checker.r create mode 100644 Task/Pangram-checker/REXX/pangram-checker.rexx create mode 100644 Task/Pangram-checker/Retro/pangram-checker.retro create mode 100644 Task/Pangram-checker/Ruby/pangram-checker.rb create mode 100644 Task/Pangram-checker/Run-BASIC/pangram-checker.run create mode 100644 Task/Pangram-checker/SNOBOL4/pangram-checker.sno create mode 100644 Task/Pangram-checker/Scala/pangram-checker-1.scala create mode 100644 Task/Pangram-checker/Scala/pangram-checker-2.scala create mode 100644 Task/Pangram-checker/Seed7/pangram-checker.seed7 create mode 100644 Task/Pangram-checker/Smalltalk/pangram-checker-1.st create mode 100644 Task/Pangram-checker/Smalltalk/pangram-checker-2.st create mode 100644 Task/Pangram-checker/TUSCRIPT/pangram-checker.tuscript create mode 100644 Task/Pangram-checker/TXR/pangram-checker.txr create mode 100644 Task/Pangram-checker/Tcl/pangram-checker.tcl create mode 100644 Task/Pangram-checker/UNIX-Shell/pangram-checker.sh create mode 100644 Task/Pangram-checker/Ursala/pangram-checker-1.ursala create mode 100644 Task/Pangram-checker/Ursala/pangram-checker-2.ursala create mode 100644 Task/Pangram-checker/VBA/pangram-checker.vba create mode 100644 Task/Pangram-checker/VBScript/pangram-checker-1.vbscript create mode 100644 Task/Pangram-checker/VBScript/pangram-checker-2.vbscript create mode 100644 Task/Pangram-checker/XPL0/pangram-checker.xpl0 create mode 100644 Task/Parallel-calculations/0DESCRIPTION create mode 100644 Task/Parallel-calculations/1META.yaml create mode 100644 Task/Parallel-calculations/Ada/parallel-calculations-1.ada create mode 100644 Task/Parallel-calculations/Ada/parallel-calculations-2.ada create mode 100644 Task/Parallel-calculations/Ada/parallel-calculations-3.ada create mode 100644 Task/Parallel-calculations/C++/parallel-calculations.cpp create mode 100644 Task/Parallel-calculations/C/parallel-calculations.c create mode 100644 Task/Parallel-calculations/Clojure/parallel-calculations.clj create mode 100644 Task/Parallel-calculations/D/parallel-calculations-1.d create mode 100644 Task/Parallel-calculations/D/parallel-calculations-2.d create mode 100644 Task/Parallel-calculations/Go/parallel-calculations.go create mode 100644 Task/Parallel-calculations/J/parallel-calculations.j create mode 100644 Task/Parallel-calculations/JavaScript/parallel-calculations-1.js create mode 100644 Task/Parallel-calculations/JavaScript/parallel-calculations-2.js create mode 100644 Task/Parallel-calculations/Mathematica/parallel-calculations.math create mode 100644 Task/Parallel-calculations/OxygenBasic/parallel-calculations.oxy create mode 100644 Task/Parallel-calculations/PARI-GP/parallel-calculations.pari create mode 100644 Task/Parallel-calculations/Perl-6/parallel-calculations.pl6 create mode 100644 Task/Parallel-calculations/PicoLisp/parallel-calculations.l create mode 100644 Task/Parallel-calculations/Prolog/parallel-calculations.pro create mode 100644 Task/Parallel-calculations/PureBasic/parallel-calculations.purebasic create mode 100644 Task/Parallel-calculations/Python/parallel-calculations.py create mode 100644 Task/Parallel-calculations/Tcl/parallel-calculations-1.tcl create mode 100644 Task/Parallel-calculations/Tcl/parallel-calculations-2.tcl create mode 100644 Task/Parallel-calculations/Tcl/parallel-calculations-3.tcl create mode 100644 Task/Parametric-polymorphism/0DESCRIPTION create mode 100644 Task/Parametric-polymorphism/1META.yaml create mode 100644 Task/Parametric-polymorphism/Ada/parametric-polymorphism-1.ada create mode 100644 Task/Parametric-polymorphism/Ada/parametric-polymorphism-2.ada create mode 100644 Task/Parametric-polymorphism/C++/parametric-polymorphism-1.cpp create mode 100644 Task/Parametric-polymorphism/C++/parametric-polymorphism-2.cpp create mode 100644 Task/Parametric-polymorphism/C/parametric-polymorphism.c create mode 100644 Task/Parametric-polymorphism/Clean/parametric-polymorphism-1.clean create mode 100644 Task/Parametric-polymorphism/Clean/parametric-polymorphism-2.clean create mode 100644 Task/Parametric-polymorphism/Clean/parametric-polymorphism-3.clean create mode 100644 Task/Parametric-polymorphism/Common-Lisp/parametric-polymorphism.lisp create mode 100644 Task/Parametric-polymorphism/D/parametric-polymorphism.d create mode 100644 Task/Parametric-polymorphism/E/parametric-polymorphism-1.e create mode 100644 Task/Parametric-polymorphism/E/parametric-polymorphism-2.e create mode 100644 Task/Parametric-polymorphism/Go/parametric-polymorphism.go create mode 100644 Task/Parametric-polymorphism/Haskell/parametric-polymorphism-1.hs create mode 100644 Task/Parametric-polymorphism/Haskell/parametric-polymorphism-2.hs create mode 100644 Task/Parametric-polymorphism/Haskell/parametric-polymorphism-3.hs create mode 100644 Task/Parametric-polymorphism/Inform-7/parametric-polymorphism-1.inf create mode 100644 Task/Parametric-polymorphism/Inform-7/parametric-polymorphism-2.inf create mode 100644 Task/Parametric-polymorphism/Java/parametric-polymorphism.java create mode 100644 Task/Parametric-polymorphism/OCaml/parametric-polymorphism.ocaml create mode 100644 Task/Parametric-polymorphism/Perl-6/parametric-polymorphism.pl6 create mode 100644 Task/Parametric-polymorphism/PicoLisp/parametric-polymorphism.l create mode 100644 Task/Parametric-polymorphism/Racket/parametric-polymorphism.rkt create mode 100644 Task/Parametric-polymorphism/Scala/parametric-polymorphism-1.scala create mode 100644 Task/Parametric-polymorphism/Scala/parametric-polymorphism-2.scala create mode 100644 Task/Parametric-polymorphism/Scala/parametric-polymorphism-3.scala create mode 100644 Task/Parametric-polymorphism/Scala/parametric-polymorphism-4.scala create mode 100644 Task/Parametric-polymorphism/Scala/parametric-polymorphism-5.scala create mode 100644 Task/Parametric-polymorphism/Scala/parametric-polymorphism-6.scala create mode 100644 Task/Parametric-polymorphism/Scala/parametric-polymorphism-7.scala create mode 100644 Task/Parametric-polymorphism/Seed7/parametric-polymorphism.seed7 create mode 100644 Task/Parametric-polymorphism/Standard-ML/parametric-polymorphism.ml create mode 100644 Task/Parametric-polymorphism/Ursala/parametric-polymorphism-1.ursala create mode 100644 Task/Parametric-polymorphism/Ursala/parametric-polymorphism-2.ursala create mode 100644 Task/Parametric-polymorphism/Ursala/parametric-polymorphism-3.ursala create mode 100644 Task/Parametric-polymorphism/Ursala/parametric-polymorphism-4.ursala create mode 100644 Task/Parametric-polymorphism/Ursala/parametric-polymorphism-5.ursala create mode 100644 Task/Parametric-polymorphism/Ursala/parametric-polymorphism-6.ursala create mode 100644 Task/Parametrized-SQL-statement/0DESCRIPTION create mode 100644 Task/Parametrized-SQL-statement/1META.yaml create mode 100644 Task/Parametrized-SQL-statement/Ada/parametrized-sql-statement.ada create mode 100644 Task/Parametrized-SQL-statement/Java/parametrized-sql-statement.java create mode 100644 Task/Parametrized-SQL-statement/Mathematica/parametrized-sql-statement.math create mode 100644 Task/Parametrized-SQL-statement/NetRexx/parametrized-sql-statement.netrexx create mode 100644 Task/Parametrized-SQL-statement/Objeck/parametrized-sql-statement.objeck create mode 100644 Task/Parametrized-SQL-statement/PHP/parametrized-sql-statement.php create mode 100644 Task/Parametrized-SQL-statement/Perl/parametrized-sql-statement.pl create mode 100644 Task/Parametrized-SQL-statement/PicoLisp/parametrized-sql-statement.l create mode 100644 Task/Parametrized-SQL-statement/PureBasic/parametrized-sql-statement.purebasic create mode 100644 Task/Parametrized-SQL-statement/Python/parametrized-sql-statement.py create mode 100644 Task/Parametrized-SQL-statement/Ruby/parametrized-sql-statement.rb create mode 100644 Task/Parametrized-SQL-statement/Tcl/parametrized-sql-statement.tcl create mode 100644 Task/Parsing-RPN-calculator-algorithm/0DESCRIPTION create mode 100644 Task/Parsing-RPN-calculator-algorithm/ANTLR/parsing-rpn-calculator-algorithm.antlr create mode 100644 Task/Parsing-RPN-calculator-algorithm/Ada/parsing-rpn-calculator-algorithm.ada create mode 100644 Task/Parsing-RPN-calculator-algorithm/AutoHotkey/parsing-rpn-calculator-algorithm.ahk create mode 100644 Task/Parsing-RPN-calculator-algorithm/BBC-BASIC/parsing-rpn-calculator-algorithm.bbc create mode 100644 Task/Parsing-RPN-calculator-algorithm/C++/parsing-rpn-calculator-algorithm.cpp create mode 100644 Task/Parsing-RPN-calculator-algorithm/C/parsing-rpn-calculator-algorithm-1.c create mode 100644 Task/Parsing-RPN-calculator-algorithm/C/parsing-rpn-calculator-algorithm-2.c create mode 100644 Task/Parsing-RPN-calculator-algorithm/Clojure/parsing-rpn-calculator-algorithm.clj create mode 100644 Task/Parsing-RPN-calculator-algorithm/D/parsing-rpn-calculator-algorithm.d create mode 100644 Task/Parsing-RPN-calculator-algorithm/Ela/parsing-rpn-calculator-algorithm.ela create mode 100644 Task/Parsing-RPN-calculator-algorithm/Go/parsing-rpn-calculator-algorithm.go create mode 100644 Task/Parsing-RPN-calculator-algorithm/Groovy/parsing-rpn-calculator-algorithm-1.groovy create mode 100644 Task/Parsing-RPN-calculator-algorithm/Groovy/parsing-rpn-calculator-algorithm-2.groovy create mode 100644 Task/Parsing-RPN-calculator-algorithm/Haskell/parsing-rpn-calculator-algorithm.hs create mode 100644 Task/Parsing-RPN-calculator-algorithm/Icon/parsing-rpn-calculator-algorithm.icon create mode 100644 Task/Parsing-RPN-calculator-algorithm/J/parsing-rpn-calculator-algorithm-1.j create mode 100644 Task/Parsing-RPN-calculator-algorithm/J/parsing-rpn-calculator-algorithm-2.j create mode 100644 Task/Parsing-RPN-calculator-algorithm/Java/parsing-rpn-calculator-algorithm.java create mode 100644 Task/Parsing-RPN-calculator-algorithm/NetRexx/parsing-rpn-calculator-algorithm.netrexx create mode 100644 Task/Parsing-RPN-calculator-algorithm/Objeck/parsing-rpn-calculator-algorithm.objeck create mode 100644 Task/Parsing-RPN-calculator-algorithm/PHP/parsing-rpn-calculator-algorithm.php create mode 100644 Task/Parsing-RPN-calculator-algorithm/PL-I/parsing-rpn-calculator-algorithm.pli create mode 100644 Task/Parsing-RPN-calculator-algorithm/Perl-6/parsing-rpn-calculator-algorithm.pl6 create mode 100644 Task/Parsing-RPN-calculator-algorithm/Perl/parsing-rpn-calculator-algorithm.pl create mode 100644 Task/Parsing-RPN-calculator-algorithm/PicoLisp/parsing-rpn-calculator-algorithm-1.l create mode 100644 Task/Parsing-RPN-calculator-algorithm/PicoLisp/parsing-rpn-calculator-algorithm-2.l create mode 100644 Task/Parsing-RPN-calculator-algorithm/Prolog/parsing-rpn-calculator-algorithm.pro create mode 100644 Task/Parsing-RPN-calculator-algorithm/Python/parsing-rpn-calculator-algorithm.py create mode 100644 Task/Parsing-RPN-calculator-algorithm/REXX/parsing-rpn-calculator-algorithm-1.rexx create mode 100644 Task/Parsing-RPN-calculator-algorithm/REXX/parsing-rpn-calculator-algorithm-2.rexx create mode 100644 Task/Parsing-RPN-calculator-algorithm/REXX/parsing-rpn-calculator-algorithm-3.rexx create mode 100644 Task/Parsing-RPN-calculator-algorithm/Ruby/parsing-rpn-calculator-algorithm.rb create mode 100644 Task/Parsing-RPN-calculator-algorithm/Run-BASIC/parsing-rpn-calculator-algorithm.run create mode 100644 Task/Parsing-RPN-calculator-algorithm/Tcl/parsing-rpn-calculator-algorithm.tcl create mode 100644 Task/Parsing-RPN-to-infix-conversion/0DESCRIPTION create mode 100644 Task/Parsing-RPN-to-infix-conversion/AWK/parsing-rpn-to-infix-conversion.awk create mode 100644 Task/Parsing-RPN-to-infix-conversion/Ada/parsing-rpn-to-infix-conversion-1.ada create mode 100644 Task/Parsing-RPN-to-infix-conversion/Ada/parsing-rpn-to-infix-conversion-2.ada create mode 100644 Task/Parsing-RPN-to-infix-conversion/AutoHotkey/parsing-rpn-to-infix-conversion.ahk create mode 100644 Task/Parsing-RPN-to-infix-conversion/D/parsing-rpn-to-infix-conversion.d create mode 100644 Task/Parsing-RPN-to-infix-conversion/Go/parsing-rpn-to-infix-conversion.go create mode 100644 Task/Parsing-RPN-to-infix-conversion/Icon/parsing-rpn-to-infix-conversion.icon create mode 100644 Task/Parsing-RPN-to-infix-conversion/J/parsing-rpn-to-infix-conversion-1.j create mode 100644 Task/Parsing-RPN-to-infix-conversion/J/parsing-rpn-to-infix-conversion-2.j create mode 100644 Task/Parsing-RPN-to-infix-conversion/PL-I/parsing-rpn-to-infix-conversion.pli create mode 100644 Task/Parsing-RPN-to-infix-conversion/Perl-6/parsing-rpn-to-infix-conversion.pl6 create mode 100644 Task/Parsing-RPN-to-infix-conversion/Perl/parsing-rpn-to-infix-conversion.pl create mode 100644 Task/Parsing-RPN-to-infix-conversion/PicoLisp/parsing-rpn-to-infix-conversion-1.l create mode 100644 Task/Parsing-RPN-to-infix-conversion/PicoLisp/parsing-rpn-to-infix-conversion-2.l create mode 100644 Task/Parsing-RPN-to-infix-conversion/Python/parsing-rpn-to-infix-conversion.py create mode 100644 Task/Parsing-RPN-to-infix-conversion/REXX/parsing-rpn-to-infix-conversion.rexx create mode 100644 Task/Parsing-RPN-to-infix-conversion/Ruby/parsing-rpn-to-infix-conversion.rb create mode 100644 Task/Parsing-RPN-to-infix-conversion/Tcl/parsing-rpn-to-infix-conversion.tcl create mode 100644 Task/Parsing-Shunting-yard-algorithm/0DESCRIPTION create mode 100644 Task/Parsing-Shunting-yard-algorithm/AutoHotkey/parsing-shunting-yard-algorithm.ahk create mode 100644 Task/Parsing-Shunting-yard-algorithm/C/parsing-shunting-yard-algorithm.c create mode 100644 Task/Parsing-Shunting-yard-algorithm/Go/parsing-shunting-yard-algorithm.go create mode 100644 Task/Parsing-Shunting-yard-algorithm/Haskell/parsing-shunting-yard-algorithm.hs create mode 100644 Task/Parsing-Shunting-yard-algorithm/Icon/parsing-shunting-yard-algorithm.icon create mode 100644 Task/Parsing-Shunting-yard-algorithm/J/parsing-shunting-yard-algorithm-1.j create mode 100644 Task/Parsing-Shunting-yard-algorithm/J/parsing-shunting-yard-algorithm-2.j create mode 100644 Task/Parsing-Shunting-yard-algorithm/PL-I/parsing-shunting-yard-algorithm-1.pli create mode 100644 Task/Parsing-Shunting-yard-algorithm/PL-I/parsing-shunting-yard-algorithm-2.pli create mode 100644 Task/Parsing-Shunting-yard-algorithm/PicoLisp/parsing-shunting-yard-algorithm-1.l create mode 100644 Task/Parsing-Shunting-yard-algorithm/PicoLisp/parsing-shunting-yard-algorithm-2.l create mode 100644 Task/Parsing-Shunting-yard-algorithm/Python/parsing-shunting-yard-algorithm.py create mode 100644 Task/Parsing-Shunting-yard-algorithm/REXX/parsing-shunting-yard-algorithm-1.rexx create mode 100644 Task/Parsing-Shunting-yard-algorithm/REXX/parsing-shunting-yard-algorithm-2.rexx create mode 100644 Task/Parsing-Shunting-yard-algorithm/Ruby/parsing-shunting-yard-algorithm.rb create mode 100644 Task/Parsing-Shunting-yard-algorithm/Tcl/parsing-shunting-yard-algorithm.tcl create mode 100644 Task/Partial-function-application/0DESCRIPTION create mode 100644 Task/Partial-function-application/1META.yaml create mode 100644 Task/Partial-function-application/ALGOL-68/partial-function-application.alg create mode 100644 Task/Partial-function-application/Ada/partial-function-application.ada create mode 100644 Task/Partial-function-application/BBC-BASIC/partial-function-application.bbc create mode 100644 Task/Partial-function-application/C++/partial-function-application.cpp create mode 100644 Task/Partial-function-application/C-sharp/partial-function-application.cs create mode 100644 Task/Partial-function-application/C/partial-function-application-1.c create mode 100644 Task/Partial-function-application/C/partial-function-application-2.c create mode 100644 Task/Partial-function-application/Clojure/partial-function-application.clj create mode 100644 Task/Partial-function-application/CoffeeScript/partial-function-application-1.coffeescript create mode 100644 Task/Partial-function-application/CoffeeScript/partial-function-application-2.coffeescript create mode 100644 Task/Partial-function-application/Common-Lisp/partial-function-application.lisp create mode 100644 Task/Partial-function-application/D/partial-function-application.d create mode 100644 Task/Partial-function-application/E/partial-function-application.e create mode 100644 Task/Partial-function-application/Haskell/partial-function-application.hs create mode 100644 Task/Partial-function-application/Icon/partial-function-application.icon create mode 100644 Task/Partial-function-application/J/partial-function-application-1.j create mode 100644 Task/Partial-function-application/J/partial-function-application-2.j create mode 100644 Task/Partial-function-application/J/partial-function-application-3.j create mode 100644 Task/Partial-function-application/J/partial-function-application-4.j create mode 100644 Task/Partial-function-application/J/partial-function-application-5.j create mode 100644 Task/Partial-function-application/Java/partial-function-application-1.java create mode 100644 Task/Partial-function-application/Java/partial-function-application-2.java create mode 100644 Task/Partial-function-application/Mathematica/partial-function-application.math create mode 100644 Task/Partial-function-application/Mercury/partial-function-application.mercury create mode 100644 Task/Partial-function-application/Nemerle/partial-function-application.nemerle create mode 100644 Task/Partial-function-application/OCaml/partial-function-application.ocaml create mode 100644 Task/Partial-function-application/Order/partial-function-application.order create mode 100644 Task/Partial-function-application/Perl-6/partial-function-application.pl6 create mode 100644 Task/Partial-function-application/Perl/partial-function-application.pl create mode 100644 Task/Partial-function-application/PicoLisp/partial-function-application.l create mode 100644 Task/Partial-function-application/Prolog/partial-function-application.pro create mode 100644 Task/Partial-function-application/Python/partial-function-application-1.py create mode 100644 Task/Partial-function-application/Python/partial-function-application-2.py create mode 100644 Task/Partial-function-application/R/partial-function-application.r create mode 100644 Task/Partial-function-application/Racket/partial-function-application.rkt create mode 100644 Task/Partial-function-application/Ruby/partial-function-application.rb create mode 100644 Task/Partial-function-application/Scala/partial-function-application.scala create mode 100644 Task/Partial-function-application/Smalltalk/partial-function-application.st create mode 100644 Task/Partial-function-application/Tcl/partial-function-application-1.tcl create mode 100644 Task/Partial-function-application/Tcl/partial-function-application-2.tcl create mode 100644 Task/Pascals-triangle-Puzzle/0DESCRIPTION create mode 100644 Task/Pascals-triangle-Puzzle/ALGOL-68/pascals-triangle-puzzle.alg create mode 100644 Task/Pascals-triangle-Puzzle/Ada/pascals-triangle-puzzle.ada create mode 100644 Task/Pascals-triangle-Puzzle/AutoHotkey/pascals-triangle-puzzle-1.ahk create mode 100644 Task/Pascals-triangle-Puzzle/AutoHotkey/pascals-triangle-puzzle-2.ahk create mode 100644 Task/Pascals-triangle-Puzzle/BBC-BASIC/pascals-triangle-puzzle.bbc create mode 100644 Task/Pascals-triangle-Puzzle/C/pascals-triangle-puzzle-1.c create mode 100644 Task/Pascals-triangle-Puzzle/C/pascals-triangle-puzzle-2.c create mode 100644 Task/Pascals-triangle-Puzzle/C/pascals-triangle-puzzle-3.c create mode 100644 Task/Pascals-triangle-Puzzle/Clojure/pascals-triangle-puzzle-1.clj create mode 100644 Task/Pascals-triangle-Puzzle/Clojure/pascals-triangle-puzzle-2.clj create mode 100644 Task/Pascals-triangle-Puzzle/Clojure/pascals-triangle-puzzle-3.clj create mode 100644 Task/Pascals-triangle-Puzzle/Clojure/pascals-triangle-puzzle-4.clj create mode 100644 Task/Pascals-triangle-Puzzle/D/pascals-triangle-puzzle.d create mode 100644 Task/Pascals-triangle-Puzzle/Go/pascals-triangle-puzzle.go create mode 100644 Task/Pascals-triangle-Puzzle/Haskell/pascals-triangle-puzzle-1.hs create mode 100644 Task/Pascals-triangle-Puzzle/Haskell/pascals-triangle-puzzle-2.hs create mode 100644 Task/Pascals-triangle-Puzzle/Haskell/pascals-triangle-puzzle-3.hs create mode 100644 Task/Pascals-triangle-Puzzle/Haskell/pascals-triangle-puzzle-4.hs create mode 100644 Task/Pascals-triangle-Puzzle/J/pascals-triangle-puzzle-1.j create mode 100644 Task/Pascals-triangle-Puzzle/J/pascals-triangle-puzzle-2.j create mode 100644 Task/Pascals-triangle-Puzzle/J/pascals-triangle-puzzle-3.j create mode 100644 Task/Pascals-triangle-Puzzle/J/pascals-triangle-puzzle-4.j create mode 100644 Task/Pascals-triangle-Puzzle/J/pascals-triangle-puzzle-5.j create mode 100644 Task/Pascals-triangle-Puzzle/J/pascals-triangle-puzzle-6.j create mode 100644 Task/Pascals-triangle-Puzzle/Mathematica/pascals-triangle-puzzle-1.math create mode 100644 Task/Pascals-triangle-Puzzle/Mathematica/pascals-triangle-puzzle-2.math create mode 100644 Task/Pascals-triangle-Puzzle/Mathematica/pascals-triangle-puzzle-3.math create mode 100644 Task/Pascals-triangle-Puzzle/Mathematica/pascals-triangle-puzzle-4.math create mode 100644 Task/Pascals-triangle-Puzzle/Mathematica/pascals-triangle-puzzle-5.math create mode 100644 Task/Pascals-triangle-Puzzle/Oz/pascals-triangle-puzzle.oz create mode 100644 Task/Pascals-triangle-Puzzle/PARI-GP/pascals-triangle-puzzle.pari create mode 100644 Task/Pascals-triangle-Puzzle/PicoLisp/pascals-triangle-puzzle.l create mode 100644 Task/Pascals-triangle-Puzzle/Prolog/pascals-triangle-puzzle.pro create mode 100644 Task/Pascals-triangle-Puzzle/PureBasic/pascals-triangle-puzzle.purebasic create mode 100644 Task/Pascals-triangle-Puzzle/Python/pascals-triangle-puzzle-1.py create mode 100644 Task/Pascals-triangle-Puzzle/Python/pascals-triangle-puzzle-2.py create mode 100644 Task/Pascals-triangle-Puzzle/Python/pascals-triangle-puzzle-3.py create mode 100644 Task/Pascals-triangle-Puzzle/REXX/pascals-triangle-puzzle.rexx create mode 100644 Task/Pascals-triangle-Puzzle/Ruby/pascals-triangle-puzzle.rb create mode 100644 Task/Pascals-triangle-Puzzle/SystemVerilog/pascals-triangle-puzzle.v create mode 100644 Task/Pascals-triangle-Puzzle/Tcl/pascals-triangle-puzzle.tcl create mode 100644 Task/Pascals-triangle/0DESCRIPTION create mode 100644 Task/Pascals-triangle/1META.yaml create mode 100644 Task/Pascals-triangle/ALGOL-68/pascals-triangle.alg create mode 100644 Task/Pascals-triangle/APL/pascals-triangle-1.apl create mode 100644 Task/Pascals-triangle/APL/pascals-triangle-2.apl create mode 100644 Task/Pascals-triangle/AWK/pascals-triangle.awk create mode 100644 Task/Pascals-triangle/Ada/pascals-triangle.ada create mode 100644 Task/Pascals-triangle/AutoHotkey/pascals-triangle.ahk create mode 100644 Task/Pascals-triangle/BASIC/pascals-triangle.basic create mode 100644 Task/Pascals-triangle/BBC-BASIC/pascals-triangle.bbc create mode 100644 Task/Pascals-triangle/Bracmat/pascals-triangle.bracmat create mode 100644 Task/Pascals-triangle/Burlesque/pascals-triangle.blq create mode 100644 Task/Pascals-triangle/C++/pascals-triangle.cpp create mode 100644 Task/Pascals-triangle/C/pascals-triangle-1.c create mode 100644 Task/Pascals-triangle/C/pascals-triangle-2.c create mode 100644 Task/Pascals-triangle/C/pascals-triangle-3.c create mode 100644 Task/Pascals-triangle/Clojure/pascals-triangle-1.clj create mode 100644 Task/Pascals-triangle/Clojure/pascals-triangle-2.clj create mode 100644 Task/Pascals-triangle/Clojure/pascals-triangle-3.clj create mode 100644 Task/Pascals-triangle/CoffeeScript/pascals-triangle.coffeescript create mode 100644 Task/Pascals-triangle/Common-Lisp/pascals-triangle.lisp create mode 100644 Task/Pascals-triangle/D/pascals-triangle-1.d create mode 100644 Task/Pascals-triangle/D/pascals-triangle-2.d create mode 100644 Task/Pascals-triangle/D/pascals-triangle-3.d create mode 100644 Task/Pascals-triangle/DWScript/pascals-triangle.dwscript create mode 100644 Task/Pascals-triangle/E/pascals-triangle-1.e create mode 100644 Task/Pascals-triangle/E/pascals-triangle-2.e create mode 100644 Task/Pascals-triangle/Erlang/pascals-triangle.erl create mode 100644 Task/Pascals-triangle/Euphoria/pascals-triangle.euphoria create mode 100644 Task/Pascals-triangle/Factor/pascals-triangle-1.factor create mode 100644 Task/Pascals-triangle/Factor/pascals-triangle-2.factor create mode 100644 Task/Pascals-triangle/Fantom/pascals-triangle.fantom create mode 100644 Task/Pascals-triangle/Forth/pascals-triangle-1.fth create mode 100644 Task/Pascals-triangle/Forth/pascals-triangle-2.fth create mode 100644 Task/Pascals-triangle/Fortran/pascals-triangle.f create mode 100644 Task/Pascals-triangle/GAP/pascals-triangle.gap create mode 100644 Task/Pascals-triangle/GW-BASIC/pascals-triangle.gw-basic create mode 100644 Task/Pascals-triangle/Go/pascals-triangle.go create mode 100644 Task/Pascals-triangle/Groovy/pascals-triangle-1.groovy create mode 100644 Task/Pascals-triangle/Groovy/pascals-triangle-2.groovy create mode 100644 Task/Pascals-triangle/Haskell/pascals-triangle-1.hs create mode 100644 Task/Pascals-triangle/Haskell/pascals-triangle-2.hs create mode 100644 Task/Pascals-triangle/Haskell/pascals-triangle-3.hs create mode 100644 Task/Pascals-triangle/Haskell/pascals-triangle-4.hs create mode 100644 Task/Pascals-triangle/Haskell/pascals-triangle-5.hs create mode 100644 Task/Pascals-triangle/Haskell/pascals-triangle-6.hs create mode 100644 Task/Pascals-triangle/Haskell/pascals-triangle-7.hs create mode 100644 Task/Pascals-triangle/HicEst/pascals-triangle.hicest create mode 100644 Task/Pascals-triangle/IDL/pascals-triangle.idl create mode 100644 Task/Pascals-triangle/Icon/pascals-triangle.icon create mode 100644 Task/Pascals-triangle/J/pascals-triangle-1.j create mode 100644 Task/Pascals-triangle/J/pascals-triangle-2.j create mode 100644 Task/Pascals-triangle/J/pascals-triangle-3.j create mode 100644 Task/Pascals-triangle/Java/pascals-triangle-1.java create mode 100644 Task/Pascals-triangle/Java/pascals-triangle-2.java create mode 100644 Task/Pascals-triangle/Java/pascals-triangle-3.java create mode 100644 Task/Pascals-triangle/JavaScript/pascals-triangle.js create mode 100644 Task/Pascals-triangle/K/pascals-triangle.k create mode 100644 Task/Pascals-triangle/Liberty-BASIC/pascals-triangle.liberty create mode 100644 Task/Pascals-triangle/Locomotive-Basic/pascals-triangle.locomotive create mode 100644 Task/Pascals-triangle/Logo/pascals-triangle.logo create mode 100644 Task/Pascals-triangle/Lua/pascals-triangle.lua create mode 100644 Task/Pascals-triangle/MATLAB/pascals-triangle-1.m create mode 100644 Task/Pascals-triangle/MATLAB/pascals-triangle-2.m create mode 100644 Task/Pascals-triangle/Mathematica/pascals-triangle.math create mode 100644 Task/Pascals-triangle/Maxima/pascals-triangle.maxima create mode 100644 Task/Pascals-triangle/Metafont/pascals-triangle.metafont create mode 100644 Task/Pascals-triangle/Nial/pascals-triangle-1.nial create mode 100644 Task/Pascals-triangle/Nial/pascals-triangle-2.nial create mode 100644 Task/Pascals-triangle/OCaml/pascals-triangle.ocaml create mode 100644 Task/Pascals-triangle/Octave/pascals-triangle.octave create mode 100644 Task/Pascals-triangle/Oz/pascals-triangle.oz create mode 100644 Task/Pascals-triangle/PARI-GP/pascals-triangle.pari create mode 100644 Task/Pascals-triangle/PHP/pascals-triangle.php create mode 100644 Task/Pascals-triangle/PL-I/pascals-triangle-1.pli create mode 100644 Task/Pascals-triangle/PL-I/pascals-triangle-2.pli create mode 100644 Task/Pascals-triangle/Pascal/pascals-triangle.pascal create mode 100644 Task/Pascals-triangle/Perl-6/pascals-triangle-1.pl6 create mode 100644 Task/Pascals-triangle/Perl-6/pascals-triangle-2.pl6 create mode 100644 Task/Pascals-triangle/Perl-6/pascals-triangle-3.pl6 create mode 100644 Task/Pascals-triangle/Perl-6/pascals-triangle-4.pl6 create mode 100644 Task/Pascals-triangle/Perl/pascals-triangle-1.pl create mode 100644 Task/Pascals-triangle/Perl/pascals-triangle-2.pl create mode 100644 Task/Pascals-triangle/PicoLisp/pascals-triangle.l create mode 100644 Task/Pascals-triangle/PowerShell/pascals-triangle.psh create mode 100644 Task/Pascals-triangle/Prolog/pascals-triangle-1.pro create mode 100644 Task/Pascals-triangle/Prolog/pascals-triangle-2.pro create mode 100644 Task/Pascals-triangle/PureBasic/pascals-triangle.purebasic create mode 100644 Task/Pascals-triangle/Python/pascals-triangle-1.py create mode 100644 Task/Pascals-triangle/Python/pascals-triangle-2.py create mode 100644 Task/Pascals-triangle/Qi/pascals-triangle.qi create mode 100644 Task/Pascals-triangle/R/pascals-triangle-1.r create mode 100644 Task/Pascals-triangle/R/pascals-triangle-2.r create mode 100644 Task/Pascals-triangle/REXX/pascals-triangle.rexx create mode 100644 Task/Pascals-triangle/Racket/pascals-triangle.rkt create mode 100644 Task/Pascals-triangle/RapidQ/pascals-triangle-1.rapidq create mode 100644 Task/Pascals-triangle/RapidQ/pascals-triangle-2.rapidq create mode 100644 Task/Pascals-triangle/Retro/pascals-triangle.retro create mode 100644 Task/Pascals-triangle/Ruby/pascals-triangle-1.rb create mode 100644 Task/Pascals-triangle/Ruby/pascals-triangle-2.rb create mode 100644 Task/Pascals-triangle/Run-BASIC/pascals-triangle.run create mode 100644 Task/Pascals-triangle/Scala/pascals-triangle-1.scala create mode 100644 Task/Pascals-triangle/Scala/pascals-triangle-2.scala create mode 100644 Task/Pascals-triangle/Scheme/pascals-triangle-1.ss create mode 100644 Task/Pascals-triangle/Scheme/pascals-triangle-2.ss create mode 100644 Task/Pascals-triangle/Seed7/pascals-triangle.seed7 create mode 100644 Task/Pascals-triangle/Tcl/pascals-triangle-1.tcl create mode 100644 Task/Pascals-triangle/Tcl/pascals-triangle-2.tcl create mode 100644 Task/Pascals-triangle/Tcl/pascals-triangle-3.tcl create mode 100644 Task/Pascals-triangle/Tcl/pascals-triangle-4.tcl create mode 100644 Task/Pascals-triangle/Turing/pascals-triangle.turing create mode 100644 Task/Pascals-triangle/Ursala/pascals-triangle-1.ursala create mode 100644 Task/Pascals-triangle/Ursala/pascals-triangle-2.ursala create mode 100644 Task/Pascals-triangle/Ursala/pascals-triangle-3.ursala create mode 100644 Task/Pascals-triangle/Vedit-macro-language/pascals-triangle-1.vedit create mode 100644 Task/Pascals-triangle/Vedit-macro-language/pascals-triangle-2.vedit create mode 100644 Task/Pascals-triangle/XPL0/pascals-triangle.xpl0 create mode 100644 Task/Pattern-matching/0DESCRIPTION create mode 100644 Task/Pattern-matching/1META.yaml create mode 100644 Task/Pattern-matching/Bracmat/pattern-matching-1.bracmat create mode 100644 Task/Pattern-matching/Bracmat/pattern-matching-2.bracmat create mode 100644 Task/Pattern-matching/Bracmat/pattern-matching-3.bracmat create mode 100644 Task/Pattern-matching/Common-Lisp/pattern-matching.lisp create mode 100644 Task/Pattern-matching/Haskell/pattern-matching.hs create mode 100644 Task/Pattern-matching/J/pattern-matching-1.j create mode 100644 Task/Pattern-matching/J/pattern-matching-2.j create mode 100644 Task/Pattern-matching/OCaml/pattern-matching.ocaml create mode 100644 Task/Pattern-matching/Oz/pattern-matching.oz create mode 100644 Task/Pattern-matching/Perl-6/pattern-matching.pl6 create mode 100644 Task/Pattern-matching/PicoLisp/pattern-matching-1.l create mode 100644 Task/Pattern-matching/PicoLisp/pattern-matching-2.l create mode 100644 Task/Pattern-matching/Racket/pattern-matching.rkt create mode 100644 Task/Pattern-matching/Rascal/pattern-matching-1.rascal create mode 100644 Task/Pattern-matching/Rascal/pattern-matching-2.rascal create mode 100644 Task/Pattern-matching/Rascal/pattern-matching-3.rascal create mode 100644 Task/Pattern-matching/Rascal/pattern-matching-4.rascal create mode 100644 Task/Pattern-matching/Scala/pattern-matching.scala create mode 100644 Task/Pattern-matching/Standard-ML/pattern-matching.ml create mode 100644 Task/Pattern-matching/Tcl/pattern-matching-1.tcl create mode 100644 Task/Pattern-matching/Tcl/pattern-matching-2.tcl create mode 100644 Task/Percentage-difference-between-images/0DESCRIPTION create mode 100644 Task/Percentage-difference-between-images/1META.yaml create mode 100644 Task/Percentage-difference-between-images/Ada/percentage-difference-between-images-1.ada create mode 100644 Task/Percentage-difference-between-images/Ada/percentage-difference-between-images-2.ada create mode 100644 Task/Percentage-difference-between-images/Ada/percentage-difference-between-images-3.ada create mode 100644 Task/Percentage-difference-between-images/Ada/percentage-difference-between-images-4.ada create mode 100644 Task/Percentage-difference-between-images/Ada/percentage-difference-between-images-5.ada create mode 100644 Task/Percentage-difference-between-images/AutoHotkey/percentage-difference-between-images.ahk create mode 100644 Task/Percentage-difference-between-images/BBC-BASIC/percentage-difference-between-images.bbc create mode 100644 Task/Percentage-difference-between-images/C++/percentage-difference-between-images.cpp create mode 100644 Task/Percentage-difference-between-images/C/percentage-difference-between-images.c create mode 100644 Task/Percentage-difference-between-images/Common-Lisp/percentage-difference-between-images.lisp create mode 100644 Task/Percentage-difference-between-images/D/percentage-difference-between-images.d create mode 100644 Task/Percentage-difference-between-images/E/percentage-difference-between-images.e create mode 100644 Task/Percentage-difference-between-images/Forth/percentage-difference-between-images.fth create mode 100644 Task/Percentage-difference-between-images/Fortran/percentage-difference-between-images.f create mode 100644 Task/Percentage-difference-between-images/Go/percentage-difference-between-images-1.go create mode 100644 Task/Percentage-difference-between-images/Go/percentage-difference-between-images-2.go create mode 100644 Task/Percentage-difference-between-images/Go/percentage-difference-between-images-3.go create mode 100644 Task/Percentage-difference-between-images/Icon/percentage-difference-between-images.icon create mode 100644 Task/Percentage-difference-between-images/J/percentage-difference-between-images.j create mode 100644 Task/Percentage-difference-between-images/Java/percentage-difference-between-images.java create mode 100644 Task/Percentage-difference-between-images/Liberty-BASIC/percentage-difference-between-images.liberty create mode 100644 Task/Percentage-difference-between-images/MAXScript/percentage-difference-between-images.maxscript create mode 100644 Task/Percentage-difference-between-images/Mathematica/percentage-difference-between-images.math create mode 100644 Task/Percentage-difference-between-images/OCaml/percentage-difference-between-images.ocaml create mode 100644 Task/Percentage-difference-between-images/PicoLisp/percentage-difference-between-images.l create mode 100644 Task/Percentage-difference-between-images/PureBasic/percentage-difference-between-images.purebasic create mode 100644 Task/Percentage-difference-between-images/Python/percentage-difference-between-images.py create mode 100644 Task/Percentage-difference-between-images/REBOL/percentage-difference-between-images.rebol create mode 100644 Task/Percentage-difference-between-images/Ruby/percentage-difference-between-images.rb create mode 100644 Task/Percentage-difference-between-images/Tcl/percentage-difference-between-images.tcl create mode 100644 Task/Percentage-difference-between-images/Vedit-macro-language/percentage-difference-between-images.vedit create mode 100644 Task/Perfect-numbers/0DESCRIPTION create mode 100644 Task/Perfect-numbers/1META.yaml create mode 100644 Task/Perfect-numbers/ALGOL-68/perfect-numbers.alg create mode 100644 Task/Perfect-numbers/AWK/perfect-numbers.awk create mode 100644 Task/Perfect-numbers/Ada/perfect-numbers.ada create mode 100644 Task/Perfect-numbers/AutoHotkey/perfect-numbers.ahk create mode 100644 Task/Perfect-numbers/Axiom/perfect-numbers-1.axiom create mode 100644 Task/Perfect-numbers/Axiom/perfect-numbers-2.axiom create mode 100644 Task/Perfect-numbers/Axiom/perfect-numbers-3.axiom create mode 100644 Task/Perfect-numbers/Axiom/perfect-numbers-4.axiom create mode 100644 Task/Perfect-numbers/BASIC/perfect-numbers.basic create mode 100644 Task/Perfect-numbers/BBC-BASIC/perfect-numbers-1.bbc create mode 100644 Task/Perfect-numbers/BBC-BASIC/perfect-numbers-2.bbc create mode 100644 Task/Perfect-numbers/Bracmat/perfect-numbers.bracmat create mode 100644 Task/Perfect-numbers/C++/perfect-numbers.cpp create mode 100644 Task/Perfect-numbers/C/perfect-numbers-1.c create mode 100644 Task/Perfect-numbers/C/perfect-numbers-2.c create mode 100644 Task/Perfect-numbers/Clojure/perfect-numbers-1.clj create mode 100644 Task/Perfect-numbers/Clojure/perfect-numbers-2.clj create mode 100644 Task/Perfect-numbers/CoffeeScript/perfect-numbers.coffeescript create mode 100644 Task/Perfect-numbers/Common-Lisp/perfect-numbers.lisp create mode 100644 Task/Perfect-numbers/D/perfect-numbers-1.d create mode 100644 Task/Perfect-numbers/D/perfect-numbers-2.d create mode 100644 Task/Perfect-numbers/E/perfect-numbers.e create mode 100644 Task/Perfect-numbers/Erlang/perfect-numbers.erl create mode 100644 Task/Perfect-numbers/FALSE/perfect-numbers.false create mode 100644 Task/Perfect-numbers/Factor/perfect-numbers.factor create mode 100644 Task/Perfect-numbers/Forth/perfect-numbers.fth create mode 100644 Task/Perfect-numbers/Fortran/perfect-numbers.f create mode 100644 Task/Perfect-numbers/GAP/perfect-numbers.gap create mode 100644 Task/Perfect-numbers/Go/perfect-numbers.go create mode 100644 Task/Perfect-numbers/Groovy/perfect-numbers-1.groovy create mode 100644 Task/Perfect-numbers/Groovy/perfect-numbers-2.groovy create mode 100644 Task/Perfect-numbers/Haskell/perfect-numbers-1.hs create mode 100644 Task/Perfect-numbers/Haskell/perfect-numbers-2.hs create mode 100644 Task/Perfect-numbers/HicEst/perfect-numbers.hicest create mode 100644 Task/Perfect-numbers/Icon/perfect-numbers.icon create mode 100644 Task/Perfect-numbers/J/perfect-numbers-1.j create mode 100644 Task/Perfect-numbers/J/perfect-numbers-2.j create mode 100644 Task/Perfect-numbers/Java/perfect-numbers-1.java create mode 100644 Task/Perfect-numbers/Java/perfect-numbers-2.java create mode 100644 Task/Perfect-numbers/JavaScript/perfect-numbers.js create mode 100644 Task/Perfect-numbers/Julia/perfect-numbers.julia create mode 100644 Task/Perfect-numbers/K/perfect-numbers.k create mode 100644 Task/Perfect-numbers/Liberty-BASIC/perfect-numbers.liberty create mode 100644 Task/Perfect-numbers/Logo/perfect-numbers.logo create mode 100644 Task/Perfect-numbers/Lua/perfect-numbers.lua create mode 100644 Task/Perfect-numbers/M4/perfect-numbers.m4 create mode 100644 Task/Perfect-numbers/MAXScript/perfect-numbers.maxscript create mode 100644 Task/Perfect-numbers/Mathematica/perfect-numbers-1.math create mode 100644 Task/Perfect-numbers/Mathematica/perfect-numbers-2.math create mode 100644 Task/Perfect-numbers/Mathematica/perfect-numbers-3.math create mode 100644 Task/Perfect-numbers/Maxima/perfect-numbers.maxima create mode 100644 Task/Perfect-numbers/OCaml/perfect-numbers-1.ocaml create mode 100644 Task/Perfect-numbers/OCaml/perfect-numbers-2.ocaml create mode 100644 Task/Perfect-numbers/Objeck/perfect-numbers.objeck create mode 100644 Task/Perfect-numbers/Oz/perfect-numbers.oz create mode 100644 Task/Perfect-numbers/PARI-GP/perfect-numbers-1.pari create mode 100644 Task/Perfect-numbers/PARI-GP/perfect-numbers-2.pari create mode 100644 Task/Perfect-numbers/PARI-GP/perfect-numbers-3.pari create mode 100644 Task/Perfect-numbers/PHP/perfect-numbers.php create mode 100644 Task/Perfect-numbers/PL-I/perfect-numbers.pli create mode 100644 Task/Perfect-numbers/Pascal/perfect-numbers.pascal create mode 100644 Task/Perfect-numbers/Perl-6/perfect-numbers.pl6 create mode 100644 Task/Perfect-numbers/Perl/perfect-numbers-1.pl create mode 100644 Task/Perfect-numbers/Perl/perfect-numbers-2.pl create mode 100644 Task/Perfect-numbers/PicoLisp/perfect-numbers.l create mode 100644 Task/Perfect-numbers/PowerShell/perfect-numbers.psh create mode 100644 Task/Perfect-numbers/Prolog/perfect-numbers-1.pro create mode 100644 Task/Perfect-numbers/Prolog/perfect-numbers-2.pro create mode 100644 Task/Perfect-numbers/PureBasic/perfect-numbers.purebasic create mode 100644 Task/Perfect-numbers/Python/perfect-numbers-1.py create mode 100644 Task/Perfect-numbers/Python/perfect-numbers-2.py create mode 100644 Task/Perfect-numbers/R/perfect-numbers.r create mode 100644 Task/Perfect-numbers/REBOL/perfect-numbers.rebol create mode 100644 Task/Perfect-numbers/REXX/perfect-numbers-1.rexx create mode 100644 Task/Perfect-numbers/REXX/perfect-numbers-2.rexx create mode 100644 Task/Perfect-numbers/Ruby/perfect-numbers-1.rb create mode 100644 Task/Perfect-numbers/Ruby/perfect-numbers-2.rb create mode 100644 Task/Perfect-numbers/Run-BASIC/perfect-numbers.run create mode 100644 Task/Perfect-numbers/Scala/perfect-numbers.scala create mode 100644 Task/Perfect-numbers/Scheme/perfect-numbers.ss create mode 100644 Task/Perfect-numbers/Seed7/perfect-numbers.seed7 create mode 100644 Task/Perfect-numbers/Slate/perfect-numbers.slate create mode 100644 Task/Perfect-numbers/Smalltalk/perfect-numbers-1.st create mode 100644 Task/Perfect-numbers/Smalltalk/perfect-numbers-2.st create mode 100644 Task/Perfect-numbers/Tcl/perfect-numbers.tcl create mode 100644 Task/Perfect-numbers/Ursala/perfect-numbers-1.ursala create mode 100644 Task/Perfect-numbers/Ursala/perfect-numbers-2.ursala create mode 100644 Task/Permutation-test/0DESCRIPTION create mode 100644 Task/Permutation-test/1META.yaml create mode 100644 Task/Permutation-test/Ada/permutation-test-1.ada create mode 100644 Task/Permutation-test/Ada/permutation-test-2.ada create mode 100644 Task/Permutation-test/Ada/permutation-test-3.ada create mode 100644 Task/Permutation-test/BBC-BASIC/permutation-test.bbc create mode 100644 Task/Permutation-test/C/permutation-test-1.c create mode 100644 Task/Permutation-test/C/permutation-test-2.c create mode 100644 Task/Permutation-test/Common-Lisp/permutation-test-1.lisp create mode 100644 Task/Permutation-test/Common-Lisp/permutation-test-2.lisp create mode 100644 Task/Permutation-test/D/permutation-test.d create mode 100644 Task/Permutation-test/GAP/permutation-test.gap create mode 100644 Task/Permutation-test/Go/permutation-test.go create mode 100644 Task/Permutation-test/Haskell/permutation-test-1.hs create mode 100644 Task/Permutation-test/Haskell/permutation-test-2.hs create mode 100644 Task/Permutation-test/Haskell/permutation-test-3.hs create mode 100644 Task/Permutation-test/J/permutation-test-1.j create mode 100644 Task/Permutation-test/J/permutation-test-2.j create mode 100644 Task/Permutation-test/Mathematica/permutation-test.math create mode 100644 Task/Permutation-test/PicoLisp/permutation-test.l create mode 100644 Task/Permutation-test/PureBasic/permutation-test.purebasic create mode 100644 Task/Permutation-test/Python/permutation-test-1.py create mode 100644 Task/Permutation-test/Python/permutation-test-2.py create mode 100644 Task/Permutation-test/R/permutation-test-1.r create mode 100644 Task/Permutation-test/R/permutation-test-2.r create mode 100644 Task/Permutation-test/REXX/permutation-test.rexx create mode 100644 Task/Permutation-test/Tcl/permutation-test-1.tcl create mode 100644 Task/Permutation-test/Tcl/permutation-test-2.tcl create mode 100644 Task/Permutation-test/Ursala/permutation-test.ursala create mode 100644 Task/Permutations-Derangements/0DESCRIPTION create mode 100644 Task/Permutations-Derangements/Ada/permutations-derangements.ada create mode 100644 Task/Permutations-Derangements/AutoHotkey/permutations-derangements.ahk create mode 100644 Task/Permutations-Derangements/BBC-BASIC/permutations-derangements-1.bbc create mode 100644 Task/Permutations-Derangements/BBC-BASIC/permutations-derangements-2.bbc create mode 100644 Task/Permutations-Derangements/C/permutations-derangements.c create mode 100644 Task/Permutations-Derangements/D/permutations-derangements-1.d create mode 100644 Task/Permutations-Derangements/D/permutations-derangements-2.d create mode 100644 Task/Permutations-Derangements/GAP/permutations-derangements.gap create mode 100644 Task/Permutations-Derangements/Go/permutations-derangements.go create mode 100644 Task/Permutations-Derangements/Groovy/permutations-derangements-1.groovy create mode 100644 Task/Permutations-Derangements/Groovy/permutations-derangements-2.groovy create mode 100644 Task/Permutations-Derangements/Haskell/permutations-derangements-1.hs create mode 100644 Task/Permutations-Derangements/Haskell/permutations-derangements-2.hs create mode 100644 Task/Permutations-Derangements/J/permutations-derangements-1.j create mode 100644 Task/Permutations-Derangements/J/permutations-derangements-2.j create mode 100644 Task/Permutations-Derangements/Java/permutations-derangements.java create mode 100644 Task/Permutations-Derangements/Mathematica/permutations-derangements.math create mode 100644 Task/Permutations-Derangements/PARI-GP/permutations-derangements.pari create mode 100644 Task/Permutations-Derangements/Perl-6/permutations-derangements.pl6 create mode 100644 Task/Permutations-Derangements/Perl/permutations-derangements.pl create mode 100644 Task/Permutations-Derangements/PicoLisp/permutations-derangements.l create mode 100644 Task/Permutations-Derangements/PureBasic/permutations-derangements-1.purebasic create mode 100644 Task/Permutations-Derangements/PureBasic/permutations-derangements-2.purebasic create mode 100644 Task/Permutations-Derangements/Python/permutations-derangements.py create mode 100644 Task/Permutations-Derangements/REXX/permutations-derangements.rexx create mode 100644 Task/Permutations-Derangements/Ruby/permutations-derangements.rb create mode 100644 Task/Permutations-Derangements/Tcl/permutations-derangements-1.tcl create mode 100644 Task/Permutations-Derangements/Tcl/permutations-derangements-2.tcl create mode 100644 Task/Permutations-by-swapping/0DESCRIPTION create mode 100644 Task/Permutations-by-swapping/BBC-BASIC/permutations-by-swapping.bbc create mode 100644 Task/Permutations-by-swapping/D/permutations-by-swapping-1.d create mode 100644 Task/Permutations-by-swapping/D/permutations-by-swapping-2.d create mode 100644 Task/Permutations-by-swapping/Haskell/permutations-by-swapping.hs create mode 100644 Task/Permutations-by-swapping/J/permutations-by-swapping-1.j create mode 100644 Task/Permutations-by-swapping/J/permutations-by-swapping-2.j create mode 100644 Task/Permutations-by-swapping/J/permutations-by-swapping-3.j create mode 100644 Task/Permutations-by-swapping/J/permutations-by-swapping-4.j create mode 100644 Task/Permutations-by-swapping/J/permutations-by-swapping-5.j create mode 100644 Task/Permutations-by-swapping/J/permutations-by-swapping-6.j create mode 100644 Task/Permutations-by-swapping/Mathematica/permutations-by-swapping-1.math create mode 100644 Task/Permutations-by-swapping/Mathematica/permutations-by-swapping-2.math create mode 100644 Task/Permutations-by-swapping/Perl-6/permutations-by-swapping.pl6 create mode 100644 Task/Permutations-by-swapping/Python/permutations-by-swapping-1.py create mode 100644 Task/Permutations-by-swapping/Python/permutations-by-swapping-2.py create mode 100644 Task/Permutations-by-swapping/Python/permutations-by-swapping-3.py create mode 100644 Task/Permutations-by-swapping/Tcl/permutations-by-swapping-1.tcl create mode 100644 Task/Permutations-by-swapping/Tcl/permutations-by-swapping-2.tcl create mode 100644 Task/Permutations-by-swapping/XPL0/permutations-by-swapping.xpl0 create mode 100644 Task/Permutations/0DESCRIPTION create mode 100644 Task/Permutations/1META.yaml create mode 100644 Task/Permutations/ABAP/permutations.abap create mode 100644 Task/Permutations/ALGOL-68/permutations-1.alg create mode 100644 Task/Permutations/ALGOL-68/permutations-2.alg create mode 100644 Task/Permutations/Ada/permutations.ada create mode 100644 Task/Permutations/AutoHotkey/permutations.ahk create mode 100644 Task/Permutations/BBC-BASIC/permutations.bbc create mode 100644 Task/Permutations/Bracmat/permutations.bracmat create mode 100644 Task/Permutations/C++/permutations.cpp create mode 100644 Task/Permutations/C/permutations.c create mode 100644 Task/Permutations/Clojure/permutations.clj create mode 100644 Task/Permutations/CoffeeScript/permutations-1.coffeescript create mode 100644 Task/Permutations/CoffeeScript/permutations-2.coffeescript create mode 100644 Task/Permutations/Common-Lisp/permutations-1.lisp create mode 100644 Task/Permutations/Common-Lisp/permutations-2.lisp create mode 100644 Task/Permutations/D/permutations-1.d create mode 100644 Task/Permutations/D/permutations-2.d create mode 100644 Task/Permutations/D/permutations-3.d create mode 100644 Task/Permutations/Delphi/permutations.delphi create mode 100644 Task/Permutations/Erlang/permutations-1.erl create mode 100644 Task/Permutations/Erlang/permutations-2.erl create mode 100644 Task/Permutations/Erlang/permutations-3.erl create mode 100644 Task/Permutations/Erlang/permutations-4.erl create mode 100644 Task/Permutations/Euphoria/permutations.euphoria create mode 100644 Task/Permutations/Fortran/permutations-1.f create mode 100644 Task/Permutations/Fortran/permutations-2.f create mode 100644 Task/Permutations/GAP/permutations-1.gap create mode 100644 Task/Permutations/GAP/permutations-2.gap create mode 100644 Task/Permutations/GAP/permutations-3.gap create mode 100644 Task/Permutations/Go/permutations.go create mode 100644 Task/Permutations/Groovy/permutations-1.groovy create mode 100644 Task/Permutations/Groovy/permutations-2.groovy create mode 100644 Task/Permutations/Haskell/permutations-1.hs create mode 100644 Task/Permutations/Haskell/permutations-2.hs create mode 100644 Task/Permutations/Haskell/permutations-3.hs create mode 100644 Task/Permutations/Haskell/permutations-4.hs create mode 100644 Task/Permutations/Icon/permutations.icon create mode 100644 Task/Permutations/J/permutations-1.j create mode 100644 Task/Permutations/J/permutations-2.j create mode 100644 Task/Permutations/Java/permutations-1.java create mode 100644 Task/Permutations/Java/permutations-2.java create mode 100644 Task/Permutations/JavaScript/permutations.js create mode 100644 Task/Permutations/K/permutations.k create mode 100644 Task/Permutations/Logtalk/permutations-1.logtalk create mode 100644 Task/Permutations/Logtalk/permutations-2.logtalk create mode 100644 Task/Permutations/Lua/permutations.lua create mode 100644 Task/Permutations/Maple/permutations.maple create mode 100644 Task/Permutations/Mathematica/permutations.math create mode 100644 Task/Permutations/Maxima/permutations-1.maxima create mode 100644 Task/Permutations/Maxima/permutations-2.maxima create mode 100644 Task/Permutations/OCaml/permutations-1.ocaml create mode 100644 Task/Permutations/OCaml/permutations-2.ocaml create mode 100644 Task/Permutations/OCaml/permutations-3.ocaml create mode 100644 Task/Permutations/PARI-GP/permutations.pari create mode 100644 Task/Permutations/Pascal/permutations.pascal create mode 100644 Task/Permutations/Perl-6/permutations-1.pl6 create mode 100644 Task/Permutations/Perl-6/permutations-2.pl6 create mode 100644 Task/Permutations/Perl/permutations.pl create mode 100644 Task/Permutations/PicoLisp/permutations.l create mode 100644 Task/Permutations/PowerBASIC/permutations.powerbasic create mode 100644 Task/Permutations/Prolog/permutations-1.pro create mode 100644 Task/Permutations/Prolog/permutations-2.pro create mode 100644 Task/Permutations/Prolog/permutations-3.pro create mode 100644 Task/Permutations/Prolog/permutations-4.pro create mode 100644 Task/Permutations/PureBasic/permutations.purebasic create mode 100644 Task/Permutations/Python/permutations.py create mode 100644 Task/Permutations/Qi/permutations.qi create mode 100644 Task/Permutations/R/permutations.r create mode 100644 Task/Permutations/REXX/permutations-1.rexx create mode 100644 Task/Permutations/REXX/permutations-2.rexx create mode 100644 Task/Permutations/Ruby/permutations-1.rb create mode 100644 Task/Permutations/Ruby/permutations-2.rb create mode 100644 Task/Permutations/Run-BASIC/permutations.run create mode 100644 Task/Permutations/SAS/permutations.sas create mode 100644 Task/Permutations/Scala/permutations.scala create mode 100644 Task/Permutations/Scheme/permutations-1.ss create mode 100644 Task/Permutations/Scheme/permutations-2.ss create mode 100644 Task/Permutations/Scheme/permutations-3.ss create mode 100644 Task/Permutations/Seed7/permutations.seed7 create mode 100644 Task/Permutations/Smalltalk/permutations.st create mode 100644 Task/Permutations/Tcl/permutations.tcl create mode 100644 Task/Permutations/Ursala/permutations-1.ursala create mode 100644 Task/Permutations/Ursala/permutations-2.ursala create mode 100644 Task/Permutations/VBA/permutations.vba create mode 100644 Task/Permutations/XPL0/permutations.xpl0 create mode 100644 Task/Pick-random-element/0DESCRIPTION create mode 100644 Task/Pick-random-element/1META.yaml create mode 100644 Task/Pick-random-element/ACL2/pick-random-element.acl2 create mode 100644 Task/Pick-random-element/Ada/pick-random-element.ada create mode 100644 Task/Pick-random-element/Aime/pick-random-element.aime create mode 100644 Task/Pick-random-element/AutoHotkey/pick-random-element-1.ahk create mode 100644 Task/Pick-random-element/AutoHotkey/pick-random-element-2.ahk create mode 100644 Task/Pick-random-element/BASIC/pick-random-element.basic create mode 100644 Task/Pick-random-element/BBC-BASIC/pick-random-element.bbc create mode 100644 Task/Pick-random-element/Burlesque/pick-random-element.blq create mode 100644 Task/Pick-random-element/C/pick-random-element.c create mode 100644 Task/Pick-random-element/Clojure/pick-random-element-1.clj create mode 100644 Task/Pick-random-element/Clojure/pick-random-element-2.clj create mode 100644 Task/Pick-random-element/CoffeeScript/pick-random-element.coffeescript create mode 100644 Task/Pick-random-element/D/pick-random-element.d create mode 100644 Task/Pick-random-element/Deja-Vu/pick-random-element.djv create mode 100644 Task/Pick-random-element/Euphoria/pick-random-element.euphoria create mode 100644 Task/Pick-random-element/Factor/pick-random-element.factor create mode 100644 Task/Pick-random-element/Go/pick-random-element.go create mode 100644 Task/Pick-random-element/Groovy/pick-random-element.groovy create mode 100644 Task/Pick-random-element/Haskell/pick-random-element-1.hs create mode 100644 Task/Pick-random-element/Haskell/pick-random-element-2.hs create mode 100644 Task/Pick-random-element/Icon/pick-random-element.icon create mode 100644 Task/Pick-random-element/J/pick-random-element.j create mode 100644 Task/Pick-random-element/Java/pick-random-element.java create mode 100644 Task/Pick-random-element/JavaScript/pick-random-element.js create mode 100644 Task/Pick-random-element/K/pick-random-element.k create mode 100644 Task/Pick-random-element/Liberty-BASIC/pick-random-element.liberty create mode 100644 Task/Pick-random-element/Logo/pick-random-element.logo create mode 100644 Task/Pick-random-element/Lua/pick-random-element.lua create mode 100644 Task/Pick-random-element/MATLAB/pick-random-element-1.m create mode 100644 Task/Pick-random-element/MATLAB/pick-random-element-2.m create mode 100644 Task/Pick-random-element/Mathematica/pick-random-element.math create mode 100644 Task/Pick-random-element/NetLogo/pick-random-element.netlogo create mode 100644 Task/Pick-random-element/NetRexx/pick-random-element.netrexx create mode 100644 Task/Pick-random-element/OCaml/pick-random-element-1.ocaml create mode 100644 Task/Pick-random-element/OCaml/pick-random-element-2.ocaml create mode 100644 Task/Pick-random-element/Objeck/pick-random-element.objeck create mode 100644 Task/Pick-random-element/PARI-GP/pick-random-element.pari create mode 100644 Task/Pick-random-element/PHP/pick-random-element.php create mode 100644 Task/Pick-random-element/PL-I/pick-random-element.pli create mode 100644 Task/Pick-random-element/Pascal/pick-random-element.pascal create mode 100644 Task/Pick-random-element/Perl-6/pick-random-element-1.pl6 create mode 100644 Task/Pick-random-element/Perl-6/pick-random-element-2.pl6 create mode 100644 Task/Pick-random-element/Perl-6/pick-random-element-3.pl6 create mode 100644 Task/Pick-random-element/Perl-6/pick-random-element-4.pl6 create mode 100644 Task/Pick-random-element/Perl/pick-random-element.pl create mode 100644 Task/Pick-random-element/PicoLisp/pick-random-element.l create mode 100644 Task/Pick-random-element/PureBasic/pick-random-element.purebasic create mode 100644 Task/Pick-random-element/Python/pick-random-element.py create mode 100644 Task/Pick-random-element/R/pick-random-element.r create mode 100644 Task/Pick-random-element/REXX/pick-random-element-1.rexx create mode 100644 Task/Pick-random-element/REXX/pick-random-element-2.rexx create mode 100644 Task/Pick-random-element/Ruby/pick-random-element-1.rb create mode 100644 Task/Pick-random-element/Ruby/pick-random-element-2.rb create mode 100644 Task/Pick-random-element/Run-BASIC/pick-random-element.run create mode 100644 Task/Pick-random-element/Seed7/pick-random-element.seed7 create mode 100644 Task/Pick-random-element/Smalltalk/pick-random-element.st create mode 100644 Task/Pick-random-element/TUSCRIPT/pick-random-element.tuscript create mode 100644 Task/Pick-random-element/TXR/pick-random-element.txr create mode 100644 Task/Pick-random-element/Tcl/pick-random-element.tcl create mode 100644 Task/Pick-random-element/XPL0/pick-random-element.xpl0 create mode 100644 Task/Pig-the-dice-game-Player/0DESCRIPTION create mode 100644 Task/Pig-the-dice-game-Player/Ada/pig-the-dice-game-player.ada create mode 100644 Task/Pig-the-dice-game-Player/Go/pig-the-dice-game-player.go create mode 100644 Task/Pig-the-dice-game-Player/J/pig-the-dice-game-player-1.j create mode 100644 Task/Pig-the-dice-game-Player/J/pig-the-dice-game-player-2.j create mode 100644 Task/Pig-the-dice-game-Player/J/pig-the-dice-game-player-3.j create mode 100644 Task/Pig-the-dice-game-Player/J/pig-the-dice-game-player-4.j create mode 100644 Task/Pig-the-dice-game-Player/Python/pig-the-dice-game-player.py create mode 100644 Task/Pig-the-dice-game-Player/REXX/pig-the-dice-game-player.rexx create mode 100644 Task/Pig-the-dice-game-Player/Tcl/pig-the-dice-game-player-1.tcl create mode 100644 Task/Pig-the-dice-game-Player/Tcl/pig-the-dice-game-player-2.tcl create mode 100644 Task/Pig-the-dice-game-Player/Tcl/pig-the-dice-game-player-3.tcl create mode 100644 Task/Pig-the-dice-game/0DESCRIPTION create mode 100644 Task/Pig-the-dice-game/Ada/pig-the-dice-game-1.ada create mode 100644 Task/Pig-the-dice-game/Ada/pig-the-dice-game-2.ada create mode 100644 Task/Pig-the-dice-game/Ada/pig-the-dice-game-3.ada create mode 100644 Task/Pig-the-dice-game/Common-Lisp/pig-the-dice-game.lisp create mode 100644 Task/Pig-the-dice-game/D/pig-the-dice-game.d create mode 100644 Task/Pig-the-dice-game/Forth/pig-the-dice-game.fth create mode 100644 Task/Pig-the-dice-game/Groovy/pig-the-dice-game.groovy create mode 100644 Task/Pig-the-dice-game/J/pig-the-dice-game-1.j create mode 100644 Task/Pig-the-dice-game/J/pig-the-dice-game-2.j create mode 100644 Task/Pig-the-dice-game/Java/pig-the-dice-game.java create mode 100644 Task/Pig-the-dice-game/Mathematica/pig-the-dice-game.math create mode 100644 Task/Pig-the-dice-game/PHP/pig-the-dice-game.php create mode 100644 Task/Pig-the-dice-game/Perl-6/pig-the-dice-game.pl6 create mode 100644 Task/Pig-the-dice-game/Python/pig-the-dice-game.py create mode 100644 Task/Pig-the-dice-game/REXX/pig-the-dice-game.rexx create mode 100644 Task/Pig-the-dice-game/Ruby/pig-the-dice-game.rb create mode 100644 Task/Pig-the-dice-game/Run-BASIC/pig-the-dice-game.run create mode 100644 Task/Pig-the-dice-game/Tcl/pig-the-dice-game-1.tcl create mode 100644 Task/Pig-the-dice-game/Tcl/pig-the-dice-game-2.tcl create mode 100644 Task/Pig-the-dice-game/XPL0/pig-the-dice-game.xpl0 create mode 100644 Task/Pinstripe-Display/0DESCRIPTION create mode 100644 Task/Pinstripe-Display/1META.yaml create mode 100644 Task/Pinstripe-Display/AutoHotkey/pinstripe-display.ahk create mode 100644 Task/Pinstripe-Display/BBC-BASIC/pinstripe-display.bbc create mode 100644 Task/Pinstripe-Display/Icon/pinstripe-display.icon create mode 100644 Task/Pinstripe-Display/J/pinstripe-display.j create mode 100644 Task/Pinstripe-Display/Locomotive-Basic/pinstripe-display.locomotive create mode 100644 Task/Pinstripe-Display/PicoLisp/pinstripe-display.l create mode 100644 Task/Pinstripe-Display/PureBasic/pinstripe-display.purebasic create mode 100644 Task/Pinstripe-Display/Tcl/pinstripe-display.tcl create mode 100644 Task/Pinstripe-Display/XPL0/pinstripe-display.xpl0 create mode 100644 Task/Pinstripe-Printer/0DESCRIPTION create mode 100644 Task/Pinstripe-Printer/1META.yaml create mode 100644 Task/Pinstripe-Printer/BBC-BASIC/pinstripe-printer.bbc create mode 100644 Task/Pinstripe-Printer/Liberty-BASIC/pinstripe-printer.liberty create mode 100644 Task/Pinstripe-Printer/PicoLisp/pinstripe-printer.l create mode 100644 Task/Pinstripe-Printer/Tcl/pinstripe-printer.tcl create mode 100644 Task/Play-recorded-sounds/0DESCRIPTION create mode 100644 Task/Play-recorded-sounds/1META.yaml create mode 100644 Task/Play-recorded-sounds/AutoHotkey/play-recorded-sounds.ahk create mode 100644 Task/Play-recorded-sounds/BBC-BASIC/play-recorded-sounds.bbc create mode 100644 Task/Play-recorded-sounds/Delphi/play-recorded-sounds.delphi create mode 100644 Task/Play-recorded-sounds/GUISS/play-recorded-sounds.guiss create mode 100644 Task/Play-recorded-sounds/Liberty-BASIC/play-recorded-sounds.liberty create mode 100644 Task/Play-recorded-sounds/Mathematica/play-recorded-sounds.math create mode 100644 Task/Play-recorded-sounds/PicoLisp/play-recorded-sounds.l create mode 100644 Task/Play-recorded-sounds/PureBasic/play-recorded-sounds.purebasic create mode 100644 Task/Play-recorded-sounds/Python/play-recorded-sounds-1.py create mode 100644 Task/Play-recorded-sounds/Python/play-recorded-sounds-2.py create mode 100644 Task/Play-recorded-sounds/R/play-recorded-sounds.r create mode 100644 Task/Play-recorded-sounds/Ruby/play-recorded-sounds.rb create mode 100644 Task/Play-recorded-sounds/TUSCRIPT/play-recorded-sounds.tuscript create mode 100644 Task/Play-recorded-sounds/Tcl/play-recorded-sounds.tcl create mode 100644 Task/Play-recorded-sounds/UNIX-Shell/play-recorded-sounds.sh create mode 100644 Task/Play-recorded-sounds/VBA/play-recorded-sounds.vba create mode 100644 Task/Playing-cards/0DESCRIPTION create mode 100644 Task/Playing-cards/1META.yaml create mode 100644 Task/Playing-cards/ACL2/playing-cards.acl2 create mode 100644 Task/Playing-cards/ALGOL-68/playing-cards.alg create mode 100644 Task/Playing-cards/AutoHotkey/playing-cards.ahk create mode 100644 Task/Playing-cards/BASIC/playing-cards.basic create mode 100644 Task/Playing-cards/BBC-BASIC/playing-cards.bbc create mode 100644 Task/Playing-cards/C++/playing-cards.cpp create mode 100644 Task/Playing-cards/C/playing-cards.c create mode 100644 Task/Playing-cards/Clojure/playing-cards.clj create mode 100644 Task/Playing-cards/Common-Lisp/playing-cards.lisp create mode 100644 Task/Playing-cards/D/playing-cards-1.d create mode 100644 Task/Playing-cards/D/playing-cards-2.d create mode 100644 Task/Playing-cards/Delphi/playing-cards.delphi create mode 100644 Task/Playing-cards/Fantom/playing-cards.fantom create mode 100644 Task/Playing-cards/Forth/playing-cards.fth create mode 100644 Task/Playing-cards/Fortran/playing-cards-1.f create mode 100644 Task/Playing-cards/Fortran/playing-cards-2.f create mode 100644 Task/Playing-cards/Go/playing-cards.go create mode 100644 Task/Playing-cards/Groovy/playing-cards-1.groovy create mode 100644 Task/Playing-cards/Groovy/playing-cards-2.groovy create mode 100644 Task/Playing-cards/Haskell/playing-cards.hs create mode 100644 Task/Playing-cards/Icon/playing-cards.icon create mode 100644 Task/Playing-cards/J/playing-cards-1.j create mode 100644 Task/Playing-cards/J/playing-cards-2.j create mode 100644 Task/Playing-cards/Java/playing-cards-1.java create mode 100644 Task/Playing-cards/Java/playing-cards-2.java create mode 100644 Task/Playing-cards/Java/playing-cards-3.java create mode 100644 Task/Playing-cards/Java/playing-cards-4.java create mode 100644 Task/Playing-cards/JavaScript/playing-cards.js create mode 100644 Task/Playing-cards/K/playing-cards-1.k create mode 100644 Task/Playing-cards/K/playing-cards-2.k create mode 100644 Task/Playing-cards/K/playing-cards-3.k create mode 100644 Task/Playing-cards/K/playing-cards-4.k create mode 100644 Task/Playing-cards/K/playing-cards-5.k create mode 100644 Task/Playing-cards/K/playing-cards-6.k create mode 100644 Task/Playing-cards/Liberty-BASIC/playing-cards.liberty create mode 100644 Task/Playing-cards/Logo/playing-cards.logo create mode 100644 Task/Playing-cards/Lua/playing-cards.lua create mode 100644 Task/Playing-cards/M4/playing-cards.m4 create mode 100644 Task/Playing-cards/Mathematica/playing-cards.math create mode 100644 Task/Playing-cards/OCaml/playing-cards.ocaml create mode 100644 Task/Playing-cards/PARI-GP/playing-cards.pari create mode 100644 Task/Playing-cards/PHP/playing-cards-1.php create mode 100644 Task/Playing-cards/PHP/playing-cards-2.php create mode 100644 Task/Playing-cards/Perl-6/playing-cards.pl6 create mode 100644 Task/Playing-cards/Perl/playing-cards-1.pl create mode 100644 Task/Playing-cards/Perl/playing-cards-2.pl create mode 100644 Task/Playing-cards/PicoLisp/playing-cards.l create mode 100644 Task/Playing-cards/Prolog/playing-cards.pro create mode 100644 Task/Playing-cards/PureBasic/playing-cards.purebasic create mode 100644 Task/Playing-cards/Python/playing-cards.py create mode 100644 Task/Playing-cards/R/playing-cards.r create mode 100644 Task/Playing-cards/REXX/playing-cards-1.rexx create mode 100644 Task/Playing-cards/REXX/playing-cards-2.rexx create mode 100644 Task/Playing-cards/Racket/playing-cards.rkt create mode 100644 Task/Playing-cards/Ruby/playing-cards.rb create mode 100644 Task/Playing-cards/Run-BASIC/playing-cards.run create mode 100644 Task/Playing-cards/Scheme/playing-cards-1.ss create mode 100644 Task/Playing-cards/Scheme/playing-cards-2.ss create mode 100644 Task/Playing-cards/Smalltalk/playing-cards.st create mode 100644 Task/Playing-cards/Tcl/playing-cards.tcl create mode 100644 Task/Playing-cards/VBScript/playing-cards-1.vbscript create mode 100644 Task/Playing-cards/VBScript/playing-cards-2.vbscript create mode 100644 Task/Playing-cards/Vedit-macro-language/playing-cards.vedit create mode 100644 Task/Plot-coordinate-pairs/0DESCRIPTION create mode 100644 Task/Plot-coordinate-pairs/ALGOL-68/plot-coordinate-pairs.alg create mode 100644 Task/Plot-coordinate-pairs/Ada/plot-coordinate-pairs.ada create mode 100644 Task/Plot-coordinate-pairs/BBC-BASIC/plot-coordinate-pairs.bbc create mode 100644 Task/Plot-coordinate-pairs/C/plot-coordinate-pairs-1.c create mode 100644 Task/Plot-coordinate-pairs/C/plot-coordinate-pairs-2.c create mode 100644 Task/Plot-coordinate-pairs/Groovy/plot-coordinate-pairs.groovy create mode 100644 Task/Plot-coordinate-pairs/Haskell/plot-coordinate-pairs.hs create mode 100644 Task/Plot-coordinate-pairs/HicEst/plot-coordinate-pairs.hicest create mode 100644 Task/Plot-coordinate-pairs/Icon/plot-coordinate-pairs.icon create mode 100644 Task/Plot-coordinate-pairs/J/plot-coordinate-pairs.j create mode 100644 Task/Plot-coordinate-pairs/Java/plot-coordinate-pairs.java create mode 100644 Task/Plot-coordinate-pairs/Liberty-BASIC/plot-coordinate-pairs-1.liberty create mode 100644 Task/Plot-coordinate-pairs/Liberty-BASIC/plot-coordinate-pairs-2.liberty create mode 100644 Task/Plot-coordinate-pairs/MATLAB/plot-coordinate-pairs.m create mode 100644 Task/Plot-coordinate-pairs/Mathematica/plot-coordinate-pairs.math create mode 100644 Task/Plot-coordinate-pairs/Maxima/plot-coordinate-pairs.maxima create mode 100644 Task/Plot-coordinate-pairs/OCaml/plot-coordinate-pairs-1.ocaml create mode 100644 Task/Plot-coordinate-pairs/OCaml/plot-coordinate-pairs-2.ocaml create mode 100644 Task/Plot-coordinate-pairs/Octave/plot-coordinate-pairs.octave create mode 100644 Task/Plot-coordinate-pairs/PARI-GP/plot-coordinate-pairs.pari create mode 100644 Task/Plot-coordinate-pairs/Perl-6/plot-coordinate-pairs.pl6 create mode 100644 Task/Plot-coordinate-pairs/Perl/plot-coordinate-pairs-1.pl create mode 100644 Task/Plot-coordinate-pairs/Perl/plot-coordinate-pairs-2.pl create mode 100644 Task/Plot-coordinate-pairs/PicoLisp/plot-coordinate-pairs.l create mode 100644 Task/Plot-coordinate-pairs/PostScript/plot-coordinate-pairs.ps create mode 100644 Task/Plot-coordinate-pairs/PureBasic/plot-coordinate-pairs.purebasic create mode 100644 Task/Plot-coordinate-pairs/Python/plot-coordinate-pairs.py create mode 100644 Task/Plot-coordinate-pairs/R/plot-coordinate-pairs-1.r create mode 100644 Task/Plot-coordinate-pairs/R/plot-coordinate-pairs-2.r create mode 100644 Task/Plot-coordinate-pairs/R/plot-coordinate-pairs-3.r create mode 100644 Task/Plot-coordinate-pairs/R/plot-coordinate-pairs-4.r create mode 100644 Task/Plot-coordinate-pairs/Ruby/plot-coordinate-pairs.rb create mode 100644 Task/Plot-coordinate-pairs/Scala/plot-coordinate-pairs.scala create mode 100644 Task/Plot-coordinate-pairs/TI-89-BASIC/plot-coordinate-pairs.ti-89 create mode 100644 Task/Plot-coordinate-pairs/Tcl/plot-coordinate-pairs.tcl create mode 100644 Task/Plot-coordinate-pairs/Ursala/plot-coordinate-pairs-1.ursala create mode 100644 Task/Plot-coordinate-pairs/Ursala/plot-coordinate-pairs-2.ursala create mode 100644 Task/Plot-coordinate-pairs/XPL0/plot-coordinate-pairs.xpl0 create mode 100644 Task/Plot-coordinate-pairs/Yorick/plot-coordinate-pairs.yorick create mode 100644 Task/Pointers-and-references/0DESCRIPTION create mode 100644 Task/Pointers-and-references/1META.yaml create mode 100644 Task/Pointers-and-references/ALGOL-68/pointers-and-references-1.alg create mode 100644 Task/Pointers-and-references/ALGOL-68/pointers-and-references-10.alg create mode 100644 Task/Pointers-and-references/ALGOL-68/pointers-and-references-11.alg create mode 100644 Task/Pointers-and-references/ALGOL-68/pointers-and-references-2.alg create mode 100644 Task/Pointers-and-references/ALGOL-68/pointers-and-references-3.alg create mode 100644 Task/Pointers-and-references/ALGOL-68/pointers-and-references-4.alg create mode 100644 Task/Pointers-and-references/ALGOL-68/pointers-and-references-5.alg create mode 100644 Task/Pointers-and-references/ALGOL-68/pointers-and-references-6.alg create mode 100644 Task/Pointers-and-references/ALGOL-68/pointers-and-references-7.alg create mode 100644 Task/Pointers-and-references/ALGOL-68/pointers-and-references-8.alg create mode 100644 Task/Pointers-and-references/ALGOL-68/pointers-and-references-9.alg create mode 100644 Task/Pointers-and-references/Ada/pointers-and-references-1.ada create mode 100644 Task/Pointers-and-references/Ada/pointers-and-references-2.ada create mode 100644 Task/Pointers-and-references/Ada/pointers-and-references-3.ada create mode 100644 Task/Pointers-and-references/Ada/pointers-and-references-4.ada create mode 100644 Task/Pointers-and-references/Ada/pointers-and-references-5.ada create mode 100644 Task/Pointers-and-references/Ada/pointers-and-references-6.ada create mode 100644 Task/Pointers-and-references/Ada/pointers-and-references-7.ada create mode 100644 Task/Pointers-and-references/Ada/pointers-and-references-8.ada create mode 100644 Task/Pointers-and-references/AutoHotkey/pointers-and-references.ahk create mode 100644 Task/Pointers-and-references/BBC-BASIC/pointers-and-references.bbc create mode 100644 Task/Pointers-and-references/D/pointers-and-references-1.d create mode 100644 Task/Pointers-and-references/D/pointers-and-references-2.d create mode 100644 Task/Pointers-and-references/Fortran/pointers-and-references-1.f create mode 100644 Task/Pointers-and-references/Fortran/pointers-and-references-10.f create mode 100644 Task/Pointers-and-references/Fortran/pointers-and-references-2.f create mode 100644 Task/Pointers-and-references/Fortran/pointers-and-references-3.f create mode 100644 Task/Pointers-and-references/Fortran/pointers-and-references-4.f create mode 100644 Task/Pointers-and-references/Fortran/pointers-and-references-5.f create mode 100644 Task/Pointers-and-references/Fortran/pointers-and-references-6.f create mode 100644 Task/Pointers-and-references/Fortran/pointers-and-references-7.f create mode 100644 Task/Pointers-and-references/Fortran/pointers-and-references-8.f create mode 100644 Task/Pointers-and-references/Fortran/pointers-and-references-9.f create mode 100644 Task/Pointers-and-references/Go/pointers-and-references-1.go create mode 100644 Task/Pointers-and-references/Go/pointers-and-references-2.go create mode 100644 Task/Pointers-and-references/Go/pointers-and-references-3.go create mode 100644 Task/Pointers-and-references/Go/pointers-and-references-4.go create mode 100644 Task/Pointers-and-references/Go/pointers-and-references-5.go create mode 100644 Task/Pointers-and-references/Go/pointers-and-references-6.go create mode 100644 Task/Pointers-and-references/Haskell/pointers-and-references.hs create mode 100644 Task/Pointers-and-references/Java/pointers-and-references.java create mode 100644 Task/Pointers-and-references/Modula-3/pointers-and-references-1.mod3 create mode 100644 Task/Pointers-and-references/Modula-3/pointers-and-references-2.mod3 create mode 100644 Task/Pointers-and-references/Modula-3/pointers-and-references-3.mod3 create mode 100644 Task/Pointers-and-references/OCaml/pointers-and-references.ocaml create mode 100644 Task/Pointers-and-references/PARI-GP/pointers-and-references.pari create mode 100644 Task/Pointers-and-references/PHP/pointers-and-references.php create mode 100644 Task/Pointers-and-references/Perl-6/pointers-and-references.pl6 create mode 100644 Task/Pointers-and-references/Perl/pointers-and-references-1.pl create mode 100644 Task/Pointers-and-references/Perl/pointers-and-references-2.pl create mode 100644 Task/Pointers-and-references/Perl/pointers-and-references-3.pl create mode 100644 Task/Pointers-and-references/PicoLisp/pointers-and-references.l create mode 100644 Task/Pointers-and-references/PureBasic/pointers-and-references-1.purebasic create mode 100644 Task/Pointers-and-references/PureBasic/pointers-and-references-2.purebasic create mode 100644 Task/Pointers-and-references/PureBasic/pointers-and-references-3.purebasic create mode 100644 Task/Pointers-and-references/PureBasic/pointers-and-references-4.purebasic create mode 100644 Task/Pointers-and-references/PureBasic/pointers-and-references-5.purebasic create mode 100644 Task/Pointers-and-references/PureBasic/pointers-and-references-6.purebasic create mode 100644 Task/Pointers-and-references/PureBasic/pointers-and-references-7.purebasic create mode 100644 Task/Pointers-and-references/PureBasic/pointers-and-references-8.purebasic create mode 100644 Task/Pointers-and-references/Python/pointers-and-references.py create mode 100644 Task/Pointers-and-references/SAS/pointers-and-references.sas create mode 100644 Task/Pointers-and-references/Standard-ML/pointers-and-references.ml create mode 100644 Task/Pointers-and-references/Tcl/pointers-and-references-1.tcl create mode 100644 Task/Pointers-and-references/Tcl/pointers-and-references-2.tcl create mode 100644 Task/Pointers-and-references/XPL0/pointers-and-references.xpl0 create mode 100644 Task/Polymorphic-copy/0DESCRIPTION create mode 100644 Task/Polymorphic-copy/1META.yaml create mode 100644 Task/Polymorphic-copy/Ada/polymorphic-copy.ada create mode 100644 Task/Polymorphic-copy/Aikido/polymorphic-copy.aikido create mode 100644 Task/Polymorphic-copy/BBC-BASIC/polymorphic-copy.bbc create mode 100644 Task/Polymorphic-copy/C++/polymorphic-copy.cpp create mode 100644 Task/Polymorphic-copy/C/polymorphic-copy.c create mode 100644 Task/Polymorphic-copy/Common-Lisp/polymorphic-copy-1.lisp create mode 100644 Task/Polymorphic-copy/Common-Lisp/polymorphic-copy-2.lisp create mode 100644 Task/Polymorphic-copy/D/polymorphic-copy-1.d create mode 100644 Task/Polymorphic-copy/D/polymorphic-copy-2.d create mode 100644 Task/Polymorphic-copy/E/polymorphic-copy-1.e create mode 100644 Task/Polymorphic-copy/E/polymorphic-copy-2.e create mode 100644 Task/Polymorphic-copy/Factor/polymorphic-copy.factor create mode 100644 Task/Polymorphic-copy/Forth/polymorphic-copy.fth create mode 100644 Task/Polymorphic-copy/Go/polymorphic-copy.go create mode 100644 Task/Polymorphic-copy/Java/polymorphic-copy.java create mode 100644 Task/Polymorphic-copy/JavaScript/polymorphic-copy.js create mode 100644 Task/Polymorphic-copy/NetRexx/polymorphic-copy.netrexx create mode 100644 Task/Polymorphic-copy/OCaml/polymorphic-copy.ocaml create mode 100644 Task/Polymorphic-copy/Objective-C/polymorphic-copy.m create mode 100644 Task/Polymorphic-copy/OxygenBasic/polymorphic-copy.oxy create mode 100644 Task/Polymorphic-copy/Oz/polymorphic-copy.oz create mode 100644 Task/Polymorphic-copy/PHP/polymorphic-copy.php create mode 100644 Task/Polymorphic-copy/Perl-6/polymorphic-copy.pl6 create mode 100644 Task/Polymorphic-copy/Perl/polymorphic-copy.pl create mode 100644 Task/Polymorphic-copy/PicoLisp/polymorphic-copy-1.l create mode 100644 Task/Polymorphic-copy/PicoLisp/polymorphic-copy-2.l create mode 100644 Task/Polymorphic-copy/PicoLisp/polymorphic-copy-3.l create mode 100644 Task/Polymorphic-copy/Python/polymorphic-copy-1.py create mode 100644 Task/Polymorphic-copy/Python/polymorphic-copy-2.py create mode 100644 Task/Polymorphic-copy/Python/polymorphic-copy-3.py create mode 100644 Task/Polymorphic-copy/Ruby/polymorphic-copy.rb create mode 100644 Task/Polymorphic-copy/Slate/polymorphic-copy.slate create mode 100644 Task/Polymorphic-copy/Tcl/polymorphic-copy-1.tcl create mode 100644 Task/Polymorphic-copy/Tcl/polymorphic-copy-2.tcl create mode 100644 Task/Polymorphism/0DESCRIPTION create mode 100644 Task/Polymorphism/1META.yaml create mode 100644 Task/Polymorphism/ActionScript/polymorphism-1.as create mode 100644 Task/Polymorphism/ActionScript/polymorphism-2.as create mode 100644 Task/Polymorphism/Ada/polymorphism-1.ada create mode 100644 Task/Polymorphism/Ada/polymorphism-2.ada create mode 100644 Task/Polymorphism/Ada/polymorphism-3.ada create mode 100644 Task/Polymorphism/Ada/polymorphism-4.ada create mode 100644 Task/Polymorphism/Ada/polymorphism-5.ada create mode 100644 Task/Polymorphism/Aikido/polymorphism.aikido create mode 100644 Task/Polymorphism/BBC-BASIC/polymorphism.bbc create mode 100644 Task/Polymorphism/C++/polymorphism-1.cpp create mode 100644 Task/Polymorphism/C++/polymorphism-2.cpp create mode 100644 Task/Polymorphism/Clojure/polymorphism.clj create mode 100644 Task/Polymorphism/Common-Lisp/polymorphism.lisp create mode 100644 Task/Polymorphism/D/polymorphism.d create mode 100644 Task/Polymorphism/Delphi/polymorphism-1.delphi create mode 100644 Task/Polymorphism/Delphi/polymorphism-2.delphi create mode 100644 Task/Polymorphism/E/polymorphism-1.e create mode 100644 Task/Polymorphism/E/polymorphism-2.e create mode 100644 Task/Polymorphism/Eiffel/polymorphism-1.e create mode 100644 Task/Polymorphism/Eiffel/polymorphism-2.e create mode 100644 Task/Polymorphism/Eiffel/polymorphism-3.e create mode 100644 Task/Polymorphism/Eiffel/polymorphism-4.e create mode 100644 Task/Polymorphism/Ela/polymorphism-1.ela create mode 100644 Task/Polymorphism/Ela/polymorphism-2.ela create mode 100644 Task/Polymorphism/Factor/polymorphism.factor create mode 100644 Task/Polymorphism/Forth/polymorphism.fth create mode 100644 Task/Polymorphism/Fortran/polymorphism.f create mode 100644 Task/Polymorphism/Go/polymorphism.go create mode 100644 Task/Polymorphism/Haskell/polymorphism-1.hs create mode 100644 Task/Polymorphism/Haskell/polymorphism-2.hs create mode 100644 Task/Polymorphism/Inform-7/polymorphism.inf create mode 100644 Task/Polymorphism/J/polymorphism-1.j create mode 100644 Task/Polymorphism/J/polymorphism-2.j create mode 100644 Task/Polymorphism/Java/polymorphism.java create mode 100644 Task/Polymorphism/JavaScript/polymorphism.js create mode 100644 Task/Polymorphism/Lua/polymorphism.lua create mode 100644 Task/Polymorphism/NetRexx/polymorphism.netrexx create mode 100644 Task/Polymorphism/OCaml/polymorphism.ocaml create mode 100644 Task/Polymorphism/Objeck/polymorphism.objeck create mode 100644 Task/Polymorphism/Objective-C/polymorphism.m create mode 100644 Task/Polymorphism/OxygenBasic/polymorphism.oxy create mode 100644 Task/Polymorphism/Oz/polymorphism.oz create mode 100644 Task/Polymorphism/PHP/polymorphism-1.php create mode 100644 Task/Polymorphism/PHP/polymorphism-2.php create mode 100644 Task/Polymorphism/PHP/polymorphism-3.php create mode 100644 Task/Polymorphism/Perl-6/polymorphism-1.pl6 create mode 100644 Task/Polymorphism/Perl-6/polymorphism-2.pl6 create mode 100644 Task/Polymorphism/Perl/polymorphism.pl create mode 100644 Task/Polymorphism/PicoLisp/polymorphism-1.l create mode 100644 Task/Polymorphism/PicoLisp/polymorphism-2.l create mode 100644 Task/Polymorphism/Pop11/polymorphism-1.pop11 create mode 100644 Task/Polymorphism/Pop11/polymorphism-2.pop11 create mode 100644 Task/Polymorphism/PureBasic/polymorphism-1.purebasic create mode 100644 Task/Polymorphism/PureBasic/polymorphism-2.purebasic create mode 100644 Task/Polymorphism/Python/polymorphism-1.py create mode 100644 Task/Polymorphism/Python/polymorphism-2.py create mode 100644 Task/Polymorphism/Python/polymorphism-3.py create mode 100644 Task/Polymorphism/Python/polymorphism-4.py create mode 100644 Task/Polymorphism/R/polymorphism.r create mode 100644 Task/Polymorphism/Ruby/polymorphism.rb create mode 100644 Task/Polymorphism/SIMPOL/polymorphism.simpol create mode 100644 Task/Polymorphism/Smalltalk/polymorphism.st create mode 100644 Task/Polymorphism/Tcl/polymorphism.tcl create mode 100644 Task/Polynomial-long-division/0DESCRIPTION create mode 100644 Task/Polynomial-long-division/1META.yaml create mode 100644 Task/Polynomial-long-division/Ada/polynomial-long-division.ada create mode 100644 Task/Polynomial-long-division/BBC-BASIC/polynomial-long-division.bbc create mode 100644 Task/Polynomial-long-division/C++/polynomial-long-division-1.cpp create mode 100644 Task/Polynomial-long-division/C++/polynomial-long-division-2.cpp create mode 100644 Task/Polynomial-long-division/C/polynomial-long-division-1.c create mode 100644 Task/Polynomial-long-division/C/polynomial-long-division-2.c create mode 100644 Task/Polynomial-long-division/C/polynomial-long-division-3.c create mode 100644 Task/Polynomial-long-division/Common-Lisp/polynomial-long-division-1.lisp create mode 100644 Task/Polynomial-long-division/Common-Lisp/polynomial-long-division-2.lisp create mode 100644 Task/Polynomial-long-division/D/polynomial-long-division.d create mode 100644 Task/Polynomial-long-division/E/polynomial-long-division.e create mode 100644 Task/Polynomial-long-division/Fortran/polynomial-long-division-1.f create mode 100644 Task/Polynomial-long-division/Fortran/polynomial-long-division-2.f create mode 100644 Task/Polynomial-long-division/GAP/polynomial-long-division.gap create mode 100644 Task/Polynomial-long-division/Go/polynomial-long-division.go create mode 100644 Task/Polynomial-long-division/Haskell/polynomial-long-division-1.hs create mode 100644 Task/Polynomial-long-division/Haskell/polynomial-long-division-2.hs create mode 100644 Task/Polynomial-long-division/J/polynomial-long-division-1.j create mode 100644 Task/Polynomial-long-division/J/polynomial-long-division-2.j create mode 100644 Task/Polynomial-long-division/Maple/polynomial-long-division.maple create mode 100644 Task/Polynomial-long-division/Mathematica/polynomial-long-division.math create mode 100644 Task/Polynomial-long-division/OCaml/polynomial-long-division-1.ocaml create mode 100644 Task/Polynomial-long-division/OCaml/polynomial-long-division-2.ocaml create mode 100644 Task/Polynomial-long-division/OCaml/polynomial-long-division-3.ocaml create mode 100644 Task/Polynomial-long-division/OCaml/polynomial-long-division-4.ocaml create mode 100644 Task/Polynomial-long-division/Octave/polynomial-long-division.octave create mode 100644 Task/Polynomial-long-division/PARI-GP/polynomial-long-division-1.pari create mode 100644 Task/Polynomial-long-division/PARI-GP/polynomial-long-division-2.pari create mode 100644 Task/Polynomial-long-division/Perl-6/polynomial-long-division.pl6 create mode 100644 Task/Polynomial-long-division/Perl/polynomial-long-division-1.pl create mode 100644 Task/Polynomial-long-division/Perl/polynomial-long-division-2.pl create mode 100644 Task/Polynomial-long-division/Perl/polynomial-long-division-3.pl create mode 100644 Task/Polynomial-long-division/PicoLisp/polynomial-long-division.l create mode 100644 Task/Polynomial-long-division/Python/polynomial-long-division.py create mode 100644 Task/Polynomial-long-division/R/polynomial-long-division.r create mode 100644 Task/Polynomial-long-division/Ruby/polynomial-long-division-1.rb create mode 100644 Task/Polynomial-long-division/Ruby/polynomial-long-division-2.rb create mode 100644 Task/Polynomial-long-division/Ruby/polynomial-long-division-3.rb create mode 100644 Task/Polynomial-long-division/Slate/polynomial-long-division.slate create mode 100644 Task/Polynomial-long-division/Smalltalk/polynomial-long-division-1.st create mode 100644 Task/Polynomial-long-division/Smalltalk/polynomial-long-division-2.st create mode 100644 Task/Polynomial-long-division/Tcl/polynomial-long-division.tcl create mode 100644 Task/Polynomial-long-division/Ursala/polynomial-long-division-1.ursala create mode 100644 Task/Polynomial-long-division/Ursala/polynomial-long-division-2.ursala create mode 100644 Task/Polynomial-regression/0DESCRIPTION create mode 100644 Task/Polynomial-regression/1META.yaml create mode 100644 Task/Polynomial-regression/ALGOL-68/polynomial-regression.alg create mode 100644 Task/Polynomial-regression/Ada/polynomial-regression-1.ada create mode 100644 Task/Polynomial-regression/Ada/polynomial-regression-2.ada create mode 100644 Task/Polynomial-regression/BBC-BASIC/polynomial-regression.bbc create mode 100644 Task/Polynomial-regression/C-sharp/polynomial-regression-1.cs create mode 100644 Task/Polynomial-regression/C-sharp/polynomial-regression-2.cs create mode 100644 Task/Polynomial-regression/C/polynomial-regression-1.c create mode 100644 Task/Polynomial-regression/C/polynomial-regression-2.c create mode 100644 Task/Polynomial-regression/C/polynomial-regression-3.c create mode 100644 Task/Polynomial-regression/Common-Lisp/polynomial-regression-1.lisp create mode 100644 Task/Polynomial-regression/Common-Lisp/polynomial-regression-2.lisp create mode 100644 Task/Polynomial-regression/Fortran/polynomial-regression-1.f create mode 100644 Task/Polynomial-regression/Fortran/polynomial-regression-2.f create mode 100644 Task/Polynomial-regression/GAP/polynomial-regression.gap create mode 100644 Task/Polynomial-regression/Go/polynomial-regression.go create mode 100644 Task/Polynomial-regression/Haskell/polynomial-regression-1.hs create mode 100644 Task/Polynomial-regression/Haskell/polynomial-regression-2.hs create mode 100644 Task/Polynomial-regression/HicEst/polynomial-regression-1.hicest create mode 100644 Task/Polynomial-regression/HicEst/polynomial-regression-2.hicest create mode 100644 Task/Polynomial-regression/J/polynomial-regression-1.j create mode 100644 Task/Polynomial-regression/J/polynomial-regression-2.j create mode 100644 Task/Polynomial-regression/MATLAB/polynomial-regression.m create mode 100644 Task/Polynomial-regression/Mathematica/polynomial-regression.math create mode 100644 Task/Polynomial-regression/Octave/polynomial-regression.octave create mode 100644 Task/Polynomial-regression/PARI-GP/polynomial-regression-1.pari create mode 100644 Task/Polynomial-regression/PARI-GP/polynomial-regression-2.pari create mode 100644 Task/Polynomial-regression/Python/polynomial-regression-1.py create mode 100644 Task/Polynomial-regression/Python/polynomial-regression-2.py create mode 100644 Task/Polynomial-regression/Python/polynomial-regression-3.py create mode 100644 Task/Polynomial-regression/Python/polynomial-regression-4.py create mode 100644 Task/Polynomial-regression/Python/polynomial-regression-5.py create mode 100644 Task/Polynomial-regression/R/polynomial-regression-1.r create mode 100644 Task/Polynomial-regression/R/polynomial-regression-2.r create mode 100644 Task/Polynomial-regression/Ruby/polynomial-regression-1.rb create mode 100644 Task/Polynomial-regression/Ruby/polynomial-regression-2.rb create mode 100644 Task/Polynomial-regression/TI-89-BASIC/polynomial-regression.ti-89 create mode 100644 Task/Polynomial-regression/Tcl/polynomial-regression.tcl create mode 100644 Task/Polynomial-regression/Ursala/polynomial-regression-1.ursala create mode 100644 Task/Polynomial-regression/Ursala/polynomial-regression-2.ursala create mode 100644 Task/Power-set/0DESCRIPTION create mode 100644 Task/Power-set/1META.yaml create mode 100644 Task/Power-set/ALGOL-68/power-set.alg create mode 100644 Task/Power-set/Ada/power-set.ada create mode 100644 Task/Power-set/AutoHotkey/power-set.ahk create mode 100644 Task/Power-set/BBC-BASIC/power-set.bbc create mode 100644 Task/Power-set/Burlesque/power-set.blq create mode 100644 Task/Power-set/C++/power-set-1.cpp create mode 100644 Task/Power-set/C++/power-set-2.cpp create mode 100644 Task/Power-set/C/power-set-1.c create mode 100644 Task/Power-set/C/power-set-2.c create mode 100644 Task/Power-set/Clojure/power-set.clj create mode 100644 Task/Power-set/CoffeeScript/power-set-1.coffeescript create mode 100644 Task/Power-set/CoffeeScript/power-set-2.coffeescript create mode 100644 Task/Power-set/ColdFusion/power-set.cfm create mode 100644 Task/Power-set/Common-Lisp/power-set-1.lisp create mode 100644 Task/Power-set/Common-Lisp/power-set-2.lisp create mode 100644 Task/Power-set/Common-Lisp/power-set-3.lisp create mode 100644 Task/Power-set/D/power-set.d create mode 100644 Task/Power-set/E/power-set.e create mode 100644 Task/Power-set/Erlang/power-set-1.erl create mode 100644 Task/Power-set/Erlang/power-set-2.erl create mode 100644 Task/Power-set/Erlang/power-set-3.erl create mode 100644 Task/Power-set/Factor/power-set-1.factor create mode 100644 Task/Power-set/Factor/power-set-2.factor create mode 100644 Task/Power-set/Forth/power-set.fth create mode 100644 Task/Power-set/Frink/power-set.frink create mode 100644 Task/Power-set/GAP/power-set.gap create mode 100644 Task/Power-set/Go/power-set.go create mode 100644 Task/Power-set/Groovy/power-set-1.groovy create mode 100644 Task/Power-set/Groovy/power-set-2.groovy create mode 100644 Task/Power-set/Haskell/power-set-1.hs create mode 100644 Task/Power-set/Haskell/power-set-2.hs create mode 100644 Task/Power-set/Haskell/power-set-3.hs create mode 100644 Task/Power-set/Haskell/power-set-4.hs create mode 100644 Task/Power-set/Haskell/power-set-5.hs create mode 100644 Task/Power-set/Icon/power-set-1.icon create mode 100644 Task/Power-set/Icon/power-set-2.icon create mode 100644 Task/Power-set/Icon/power-set-3.icon create mode 100644 Task/Power-set/J/power-set-1.j create mode 100644 Task/Power-set/J/power-set-2.j create mode 100644 Task/Power-set/J/power-set-3.j create mode 100644 Task/Power-set/Java/power-set-1.java create mode 100644 Task/Power-set/Java/power-set-2.java create mode 100644 Task/Power-set/Java/power-set-3.java create mode 100644 Task/Power-set/JavaScript/power-set.js create mode 100644 Task/Power-set/K/power-set-1.k create mode 100644 Task/Power-set/K/power-set-2.k create mode 100644 Task/Power-set/Logo/power-set.logo create mode 100644 Task/Power-set/Logtalk/power-set-1.logtalk create mode 100644 Task/Power-set/Logtalk/power-set-2.logtalk create mode 100644 Task/Power-set/Lua/power-set.lua create mode 100644 Task/Power-set/M4/power-set.m4 create mode 100644 Task/Power-set/MATLAB/power-set-1.m create mode 100644 Task/Power-set/MATLAB/power-set-2.m create mode 100644 Task/Power-set/MATLAB/power-set-3.m create mode 100644 Task/Power-set/Mathematica/power-set-1.math create mode 100644 Task/Power-set/Mathematica/power-set-2.math create mode 100644 Task/Power-set/Maxima/power-set.maxima create mode 100644 Task/Power-set/OCaml/power-set-1.ocaml create mode 100644 Task/Power-set/OCaml/power-set-2.ocaml create mode 100644 Task/Power-set/Objective-C/power-set.m create mode 100644 Task/Power-set/Oz/power-set-1.oz create mode 100644 Task/Power-set/Oz/power-set-2.oz create mode 100644 Task/Power-set/PARI-GP/power-set.pari create mode 100644 Task/Power-set/PHP/power-set-1.php create mode 100644 Task/Power-set/PHP/power-set-2.php create mode 100644 Task/Power-set/Perl-6/power-set.pl6 create mode 100644 Task/Power-set/Perl/power-set-1.pl create mode 100644 Task/Power-set/Perl/power-set-2.pl create mode 100644 Task/Power-set/PicoLisp/power-set.l create mode 100644 Task/Power-set/Prolog/power-set-1.pro create mode 100644 Task/Power-set/Prolog/power-set-2.pro create mode 100644 Task/Power-set/PureBasic/power-set.purebasic create mode 100644 Task/Power-set/Python/power-set-1.py create mode 100644 Task/Power-set/Python/power-set-2.py create mode 100644 Task/Power-set/Python/power-set-3.py create mode 100644 Task/Power-set/Python/power-set-4.py create mode 100644 Task/Power-set/Qi/power-set.qi create mode 100644 Task/Power-set/R/power-set-1.r create mode 100644 Task/Power-set/R/power-set-2.r create mode 100644 Task/Power-set/R/power-set-3.r create mode 100644 Task/Power-set/REXX/power-set.rexx create mode 100644 Task/Power-set/Racket/power-set.rkt create mode 100644 Task/Power-set/Rascal/power-set-1.rascal create mode 100644 Task/Power-set/Rascal/power-set-2.rascal create mode 100644 Task/Power-set/Ruby/power-set.rb create mode 100644 Task/Power-set/Scala/power-set.scala create mode 100644 Task/Power-set/Scheme/power-set-1.ss create mode 100644 Task/Power-set/Scheme/power-set-2.ss create mode 100644 Task/Power-set/Scheme/power-set-3.ss create mode 100644 Task/Power-set/Seed7/power-set.seed7 create mode 100644 Task/Power-set/Smalltalk/power-set-1.st create mode 100644 Task/Power-set/Smalltalk/power-set-2.st create mode 100644 Task/Power-set/Standard-ML/power-set.ml create mode 100644 Task/Power-set/TXR/power-set.txr create mode 100644 Task/Power-set/Tcl/power-set-1.tcl create mode 100644 Task/Power-set/Tcl/power-set-2.tcl create mode 100644 Task/Power-set/UNIX-Shell/power-set-1.sh create mode 100644 Task/Power-set/UNIX-Shell/power-set-2.sh create mode 100644 Task/Power-set/UnixPipes/power-set.unixpipes create mode 100644 Task/Power-set/Ursala/power-set-1.ursala create mode 100644 Task/Power-set/Ursala/power-set-2.ursala create mode 100644 Task/Power-set/V/power-set-1.v create mode 100644 Task/Power-set/V/power-set-2.v create mode 100644 Task/Pragmatic-directives/0DESCRIPTION create mode 100644 Task/Pragmatic-directives/1META.yaml create mode 100644 Task/Pragmatic-directives/ALGOL-68/pragmatic-directives.alg create mode 100644 Task/Pragmatic-directives/BASIC/pragmatic-directives.basic create mode 100644 Task/Pragmatic-directives/Go/pragmatic-directives-1.go create mode 100644 Task/Pragmatic-directives/Go/pragmatic-directives-2.go create mode 100644 Task/Pragmatic-directives/Go/pragmatic-directives-3.go create mode 100644 Task/Pragmatic-directives/Go/pragmatic-directives-4.go create mode 100644 Task/Pragmatic-directives/Icon/pragmatic-directives.icon create mode 100644 Task/Pragmatic-directives/J/pragmatic-directives-1.j create mode 100644 Task/Pragmatic-directives/J/pragmatic-directives-2.j create mode 100644 Task/Pragmatic-directives/J/pragmatic-directives-3.j create mode 100644 Task/Pragmatic-directives/J/pragmatic-directives-4.j create mode 100644 Task/Pragmatic-directives/NetRexx/pragmatic-directives-1.netrexx create mode 100644 Task/Pragmatic-directives/NetRexx/pragmatic-directives-2.netrexx create mode 100644 Task/Pragmatic-directives/NetRexx/pragmatic-directives-3.netrexx create mode 100644 Task/Pragmatic-directives/NetRexx/pragmatic-directives-4.netrexx create mode 100644 Task/Pragmatic-directives/Perl-6/pragmatic-directives.pl6 create mode 100644 Task/Pragmatic-directives/Perl/pragmatic-directives-1.pl create mode 100644 Task/Pragmatic-directives/Perl/pragmatic-directives-2.pl create mode 100644 Task/Pragmatic-directives/Python/pragmatic-directives-1.py create mode 100644 Task/Pragmatic-directives/Python/pragmatic-directives-2.py create mode 100644 Task/Pragmatic-directives/UNIX-Shell/pragmatic-directives.sh create mode 100644 Task/Price-fraction/0DESCRIPTION create mode 100644 Task/Price-fraction/1META.yaml create mode 100644 Task/Price-fraction/ALGOL-68/price-fraction.alg create mode 100644 Task/Price-fraction/AWK/price-fraction.awk create mode 100644 Task/Price-fraction/Ada/price-fraction-1.ada create mode 100644 Task/Price-fraction/Ada/price-fraction-2.ada create mode 100644 Task/Price-fraction/AutoHotkey/price-fraction.ahk create mode 100644 Task/Price-fraction/BASIC/price-fraction.basic create mode 100644 Task/Price-fraction/BBC-BASIC/price-fraction.bbc create mode 100644 Task/Price-fraction/Bracmat/price-fraction.bracmat create mode 100644 Task/Price-fraction/C++/price-fraction.cpp create mode 100644 Task/Price-fraction/C/price-fraction.c create mode 100644 Task/Price-fraction/Clipper/price-fraction-1.clipper create mode 100644 Task/Price-fraction/Clipper/price-fraction-2.clipper create mode 100644 Task/Price-fraction/D/price-fraction.d create mode 100644 Task/Price-fraction/Erlang/price-fraction.erl create mode 100644 Task/Price-fraction/Euphoria/price-fraction.euphoria create mode 100644 Task/Price-fraction/Fantom/price-fraction.fantom create mode 100644 Task/Price-fraction/Forth/price-fraction.fth create mode 100644 Task/Price-fraction/Fortran/price-fraction-1.f create mode 100644 Task/Price-fraction/Fortran/price-fraction-2.f create mode 100644 Task/Price-fraction/Go/price-fraction.go create mode 100644 Task/Price-fraction/Groovy/price-fraction.groovy create mode 100644 Task/Price-fraction/Haskell/price-fraction-1.hs create mode 100644 Task/Price-fraction/Haskell/price-fraction-2.hs create mode 100644 Task/Price-fraction/HicEst/price-fraction.hicest create mode 100644 Task/Price-fraction/Icon/price-fraction.icon create mode 100644 Task/Price-fraction/Inform-7/price-fraction.inf create mode 100644 Task/Price-fraction/J/price-fraction-1.j create mode 100644 Task/Price-fraction/J/price-fraction-2.j create mode 100644 Task/Price-fraction/Java/price-fraction.java create mode 100644 Task/Price-fraction/JavaScript/price-fraction.js create mode 100644 Task/Price-fraction/K/price-fraction-1.k create mode 100644 Task/Price-fraction/K/price-fraction-2.k create mode 100644 Task/Price-fraction/Liberty-BASIC/price-fraction.liberty create mode 100644 Task/Price-fraction/MATLAB/price-fraction.m create mode 100644 Task/Price-fraction/MUMPS/price-fraction.mumps create mode 100644 Task/Price-fraction/Mathematica/price-fraction.math create mode 100644 Task/Price-fraction/Mercury/price-fraction-1.mercury create mode 100644 Task/Price-fraction/Mercury/price-fraction-2.mercury create mode 100644 Task/Price-fraction/OCaml/price-fraction-1.ocaml create mode 100644 Task/Price-fraction/OCaml/price-fraction-2.ocaml create mode 100644 Task/Price-fraction/Oz/price-fraction.oz create mode 100644 Task/Price-fraction/PARI-GP/price-fraction.pari create mode 100644 Task/Price-fraction/PL-I/price-fraction.pli create mode 100644 Task/Price-fraction/Pascal/price-fraction.pascal create mode 100644 Task/Price-fraction/Perl-6/price-fraction-1.pl6 create mode 100644 Task/Price-fraction/Perl-6/price-fraction-2.pl6 create mode 100644 Task/Price-fraction/Perl-6/price-fraction-3.pl6 create mode 100644 Task/Price-fraction/Perl/price-fraction.pl create mode 100644 Task/Price-fraction/PicoLisp/price-fraction.l create mode 100644 Task/Price-fraction/PureBasic/price-fraction.purebasic create mode 100644 Task/Price-fraction/Python/price-fraction-1.py create mode 100644 Task/Price-fraction/Python/price-fraction-2.py create mode 100644 Task/Price-fraction/Python/price-fraction-3.py create mode 100644 Task/Price-fraction/R/price-fraction-1.r create mode 100644 Task/Price-fraction/R/price-fraction-2.r create mode 100644 Task/Price-fraction/REXX/price-fraction.rexx create mode 100644 Task/Price-fraction/Ruby/price-fraction-1.rb create mode 100644 Task/Price-fraction/Ruby/price-fraction-2.rb create mode 100644 Task/Price-fraction/Ruby/price-fraction-3.rb create mode 100644 Task/Price-fraction/Run-BASIC/price-fraction.run create mode 100644 Task/Price-fraction/Scala/price-fraction.scala create mode 100644 Task/Price-fraction/Seed7/price-fraction-1.seed7 create mode 100644 Task/Price-fraction/Seed7/price-fraction-2.seed7 create mode 100644 Task/Price-fraction/Smalltalk/price-fraction.st create mode 100644 Task/Price-fraction/Tcl/price-fraction-1.tcl create mode 100644 Task/Price-fraction/Tcl/price-fraction-2.tcl create mode 100644 Task/Price-fraction/Ursala/price-fraction-1.ursala create mode 100644 Task/Price-fraction/Ursala/price-fraction-2.ursala create mode 100644 Task/Price-fraction/XPL0/price-fraction.xpl0 create mode 100644 Task/Primality-by-trial-division/0DESCRIPTION create mode 100644 Task/Primality-by-trial-division/1META.yaml create mode 100644 Task/Primality-by-trial-division/ACL2/primality-by-trial-division.acl2 create mode 100644 Task/Primality-by-trial-division/ALGOL-68/primality-by-trial-division.alg create mode 100644 Task/Primality-by-trial-division/AWK/primality-by-trial-division.awk create mode 100644 Task/Primality-by-trial-division/ActionScript/primality-by-trial-division.as create mode 100644 Task/Primality-by-trial-division/Ada/primality-by-trial-division.ada create mode 100644 Task/Primality-by-trial-division/AutoHotkey/primality-by-trial-division.ahk create mode 100644 Task/Primality-by-trial-division/BASIC/primality-by-trial-division-1.basic create mode 100644 Task/Primality-by-trial-division/BASIC/primality-by-trial-division-2.basic create mode 100644 Task/Primality-by-trial-division/BBC-BASIC/primality-by-trial-division.bbc create mode 100644 Task/Primality-by-trial-division/Bracmat/primality-by-trial-division.bracmat create mode 100644 Task/Primality-by-trial-division/Burlesque/primality-by-trial-division-1.blq create mode 100644 Task/Primality-by-trial-division/Burlesque/primality-by-trial-division-2.blq create mode 100644 Task/Primality-by-trial-division/C++/primality-by-trial-division.cpp create mode 100644 Task/Primality-by-trial-division/C/primality-by-trial-division.c create mode 100644 Task/Primality-by-trial-division/CMake/primality-by-trial-division-1.cmake create mode 100644 Task/Primality-by-trial-division/CMake/primality-by-trial-division-2.cmake create mode 100644 Task/Primality-by-trial-division/COBOL/primality-by-trial-division-1.cobol create mode 100644 Task/Primality-by-trial-division/COBOL/primality-by-trial-division-2.cobol create mode 100644 Task/Primality-by-trial-division/COBOL/primality-by-trial-division-3.cobol create mode 100644 Task/Primality-by-trial-division/Clojure/primality-by-trial-division.clj create mode 100644 Task/Primality-by-trial-division/CoffeeScript/primality-by-trial-division.coffeescript create mode 100644 Task/Primality-by-trial-division/Common-Lisp/primality-by-trial-division-1.lisp create mode 100644 Task/Primality-by-trial-division/Common-Lisp/primality-by-trial-division-2.lisp create mode 100644 Task/Primality-by-trial-division/D/primality-by-trial-division-1.d create mode 100644 Task/Primality-by-trial-division/D/primality-by-trial-division-2.d create mode 100644 Task/Primality-by-trial-division/D/primality-by-trial-division-3.d create mode 100644 Task/Primality-by-trial-division/Delphi/primality-by-trial-division-1.delphi create mode 100644 Task/Primality-by-trial-division/Delphi/primality-by-trial-division-2.delphi create mode 100644 Task/Primality-by-trial-division/E/primality-by-trial-division.e create mode 100644 Task/Primality-by-trial-division/Erlang/primality-by-trial-division.erl create mode 100644 Task/Primality-by-trial-division/Euphoria/primality-by-trial-division.euphoria create mode 100644 Task/Primality-by-trial-division/FALSE/primality-by-trial-division.false create mode 100644 Task/Primality-by-trial-division/Factor/primality-by-trial-division.factor create mode 100644 Task/Primality-by-trial-division/Forth/primality-by-trial-division.fth create mode 100644 Task/Primality-by-trial-division/Fortran/primality-by-trial-division.f create mode 100644 Task/Primality-by-trial-division/GAP/primality-by-trial-division.gap create mode 100644 Task/Primality-by-trial-division/Go/primality-by-trial-division.go create mode 100644 Task/Primality-by-trial-division/Groovy/primality-by-trial-division.groovy create mode 100644 Task/Primality-by-trial-division/Haskell/primality-by-trial-division-1.hs create mode 100644 Task/Primality-by-trial-division/Haskell/primality-by-trial-division-2.hs create mode 100644 Task/Primality-by-trial-division/Haskell/primality-by-trial-division-3.hs create mode 100644 Task/Primality-by-trial-division/Haskell/primality-by-trial-division-4.hs create mode 100644 Task/Primality-by-trial-division/Haskell/primality-by-trial-division-5.hs create mode 100644 Task/Primality-by-trial-division/Haskell/primality-by-trial-division-6.hs create mode 100644 Task/Primality-by-trial-division/Haskell/primality-by-trial-division-7.hs create mode 100644 Task/Primality-by-trial-division/HicEst/primality-by-trial-division.hicest create mode 100644 Task/Primality-by-trial-division/Icon/primality-by-trial-division.icon create mode 100644 Task/Primality-by-trial-division/J/primality-by-trial-division.j create mode 100644 Task/Primality-by-trial-division/Java/primality-by-trial-division-1.java create mode 100644 Task/Primality-by-trial-division/Java/primality-by-trial-division-2.java create mode 100644 Task/Primality-by-trial-division/JavaScript/primality-by-trial-division.js create mode 100644 Task/Primality-by-trial-division/Joy/primality-by-trial-division.joy create mode 100644 Task/Primality-by-trial-division/K/primality-by-trial-division.k create mode 100644 Task/Primality-by-trial-division/LSE64/primality-by-trial-division.lse64 create mode 100644 Task/Primality-by-trial-division/Liberty-BASIC/primality-by-trial-division.liberty create mode 100644 Task/Primality-by-trial-division/Logo/primality-by-trial-division.logo create mode 100644 Task/Primality-by-trial-division/Lua/primality-by-trial-division.lua create mode 100644 Task/Primality-by-trial-division/M4/primality-by-trial-division.m4 create mode 100644 Task/Primality-by-trial-division/MATLAB/primality-by-trial-division-1.m create mode 100644 Task/Primality-by-trial-division/MATLAB/primality-by-trial-division-2.m create mode 100644 Task/Primality-by-trial-division/MAXScript/primality-by-trial-division.maxscript create mode 100644 Task/Primality-by-trial-division/MUMPS/primality-by-trial-division.mumps create mode 100644 Task/Primality-by-trial-division/Maple/primality-by-trial-division-1.maple create mode 100644 Task/Primality-by-trial-division/Maple/primality-by-trial-division-2.maple create mode 100644 Task/Primality-by-trial-division/Maple/primality-by-trial-division-3.maple create mode 100644 Task/Primality-by-trial-division/Mathematica/primality-by-trial-division.math create mode 100644 Task/Primality-by-trial-division/NetRexx/primality-by-trial-division-1.netrexx create mode 100644 Task/Primality-by-trial-division/NetRexx/primality-by-trial-division-2.netrexx create mode 100644 Task/Primality-by-trial-division/OCaml/primality-by-trial-division.ocaml create mode 100644 Task/Primality-by-trial-division/Objeck/primality-by-trial-division.objeck create mode 100644 Task/Primality-by-trial-division/Octave/primality-by-trial-division.octave create mode 100644 Task/Primality-by-trial-division/PARI-GP/primality-by-trial-division.pari create mode 100644 Task/Primality-by-trial-division/PHP/primality-by-trial-division-1.php create mode 100644 Task/Primality-by-trial-division/PHP/primality-by-trial-division-2.php create mode 100644 Task/Primality-by-trial-division/PL-I/primality-by-trial-division.pli create mode 100644 Task/Primality-by-trial-division/Pascal/primality-by-trial-division.pascal create mode 100644 Task/Primality-by-trial-division/Perl-6/primality-by-trial-division-1.pl6 create mode 100644 Task/Primality-by-trial-division/Perl-6/primality-by-trial-division-2.pl6 create mode 100644 Task/Primality-by-trial-division/Perl-6/primality-by-trial-division-3.pl6 create mode 100644 Task/Primality-by-trial-division/Perl/primality-by-trial-division-1.pl create mode 100644 Task/Primality-by-trial-division/Perl/primality-by-trial-division-2.pl create mode 100644 Task/Primality-by-trial-division/PicoLisp/primality-by-trial-division.l create mode 100644 Task/Primality-by-trial-division/PowerShell/primality-by-trial-division.psh create mode 100644 Task/Primality-by-trial-division/Prolog/primality-by-trial-division.pro create mode 100644 Task/Primality-by-trial-division/PureBasic/primality-by-trial-division.purebasic create mode 100644 Task/Primality-by-trial-division/Python/primality-by-trial-division-1.py create mode 100644 Task/Primality-by-trial-division/Python/primality-by-trial-division-2.py create mode 100644 Task/Primality-by-trial-division/Python/primality-by-trial-division-3.py create mode 100644 Task/Primality-by-trial-division/Python/primality-by-trial-division-4.py create mode 100644 Task/Primality-by-trial-division/Qi/primality-by-trial-division.qi create mode 100644 Task/Primality-by-trial-division/R/primality-by-trial-division-1.r create mode 100644 Task/Primality-by-trial-division/R/primality-by-trial-division-2.r create mode 100644 Task/Primality-by-trial-division/REBOL/primality-by-trial-division-1.rebol create mode 100644 Task/Primality-by-trial-division/REBOL/primality-by-trial-division-2.rebol create mode 100644 Task/Primality-by-trial-division/REXX/primality-by-trial-division-1.rexx create mode 100644 Task/Primality-by-trial-division/REXX/primality-by-trial-division-2.rexx create mode 100644 Task/Primality-by-trial-division/REXX/primality-by-trial-division-3.rexx create mode 100644 Task/Primality-by-trial-division/Ruby/primality-by-trial-division-1.rb create mode 100644 Task/Primality-by-trial-division/Ruby/primality-by-trial-division-2.rb create mode 100644 Task/Primality-by-trial-division/Ruby/primality-by-trial-division-3.rb create mode 100644 Task/Primality-by-trial-division/Ruby/primality-by-trial-division-4.rb create mode 100644 Task/Primality-by-trial-division/Run-BASIC/primality-by-trial-division.run create mode 100644 Task/Primality-by-trial-division/SAS/primality-by-trial-division.sas create mode 100644 Task/Primality-by-trial-division/SNOBOL4/primality-by-trial-division-1.sno create mode 100644 Task/Primality-by-trial-division/SNOBOL4/primality-by-trial-division-2.sno create mode 100644 Task/Primality-by-trial-division/Scala/primality-by-trial-division.scala create mode 100644 Task/Primality-by-trial-division/Scheme/primality-by-trial-division-1.ss create mode 100644 Task/Primality-by-trial-division/Scheme/primality-by-trial-division-2.ss create mode 100644 Task/Primality-by-trial-division/Seed7/primality-by-trial-division.seed7 create mode 100644 Task/Primality-by-trial-division/Standard-ML/primality-by-trial-division.ml create mode 100644 Task/Primality-by-trial-division/Tcl/primality-by-trial-division.tcl create mode 100644 Task/Primality-by-trial-division/UNIX-Shell/primality-by-trial-division-1.sh create mode 100644 Task/Primality-by-trial-division/UNIX-Shell/primality-by-trial-division-2.sh create mode 100644 Task/Primality-by-trial-division/Ursala/primality-by-trial-division-1.ursala create mode 100644 Task/Primality-by-trial-division/Ursala/primality-by-trial-division-2.ursala create mode 100644 Task/Primality-by-trial-division/V/primality-by-trial-division-1.v create mode 100644 Task/Primality-by-trial-division/V/primality-by-trial-division-2.v create mode 100644 Task/Primality-by-trial-division/XPL0/primality-by-trial-division.xpl0 create mode 100644 Task/Prime-decomposition/0DESCRIPTION create mode 100644 Task/Prime-decomposition/1META.yaml create mode 100644 Task/Prime-decomposition/ABAP/prime-decomposition.abap create mode 100644 Task/Prime-decomposition/ACL2/prime-decomposition.acl2 create mode 100644 Task/Prime-decomposition/ALGOL-68/prime-decomposition.alg create mode 100644 Task/Prime-decomposition/AWK/prime-decomposition.awk create mode 100644 Task/Prime-decomposition/Ada/prime-decomposition.ada create mode 100644 Task/Prime-decomposition/AutoHotkey/prime-decomposition.ahk create mode 100644 Task/Prime-decomposition/Befunge/prime-decomposition.bf create mode 100644 Task/Prime-decomposition/Burlesque/prime-decomposition.blq create mode 100644 Task/Prime-decomposition/C++/prime-decomposition.cpp create mode 100644 Task/Prime-decomposition/C/prime-decomposition-1.c create mode 100644 Task/Prime-decomposition/C/prime-decomposition-2.c create mode 100644 Task/Prime-decomposition/C/prime-decomposition-3.c create mode 100644 Task/Prime-decomposition/Clojure/prime-decomposition.clj create mode 100644 Task/Prime-decomposition/Common-Lisp/prime-decomposition.lisp create mode 100644 Task/Prime-decomposition/D/prime-decomposition.d create mode 100644 Task/Prime-decomposition/E/prime-decomposition.e create mode 100644 Task/Prime-decomposition/Erlang/prime-decomposition.erl create mode 100644 Task/Prime-decomposition/FALSE/prime-decomposition.false create mode 100644 Task/Prime-decomposition/Factor/prime-decomposition.factor create mode 100644 Task/Prime-decomposition/Forth/prime-decomposition.fth create mode 100644 Task/Prime-decomposition/Fortran/prime-decomposition-1.f create mode 100644 Task/Prime-decomposition/Fortran/prime-decomposition-2.f create mode 100644 Task/Prime-decomposition/Frink/prime-decomposition.frink create mode 100644 Task/Prime-decomposition/GAP/prime-decomposition-1.gap create mode 100644 Task/Prime-decomposition/GAP/prime-decomposition-2.gap create mode 100644 Task/Prime-decomposition/Go/prime-decomposition.go create mode 100644 Task/Prime-decomposition/Groovy/prime-decomposition-1.groovy create mode 100644 Task/Prime-decomposition/Groovy/prime-decomposition-2.groovy create mode 100644 Task/Prime-decomposition/Groovy/prime-decomposition-3.groovy create mode 100644 Task/Prime-decomposition/Haskell/prime-decomposition-1.hs create mode 100644 Task/Prime-decomposition/Haskell/prime-decomposition-2.hs create mode 100644 Task/Prime-decomposition/Icon/prime-decomposition.icon create mode 100644 Task/Prime-decomposition/J/prime-decomposition-1.j create mode 100644 Task/Prime-decomposition/J/prime-decomposition-2.j create mode 100644 Task/Prime-decomposition/Java/prime-decomposition-1.java create mode 100644 Task/Prime-decomposition/Java/prime-decomposition-2.java create mode 100644 Task/Prime-decomposition/Java/prime-decomposition-3.java create mode 100644 Task/Prime-decomposition/Java/prime-decomposition-4.java create mode 100644 Task/Prime-decomposition/JavaScript/prime-decomposition-1.js create mode 100644 Task/Prime-decomposition/JavaScript/prime-decomposition-2.js create mode 100644 Task/Prime-decomposition/Logo/prime-decomposition.logo create mode 100644 Task/Prime-decomposition/Lua/prime-decomposition.lua create mode 100644 Task/Prime-decomposition/MATLAB/prime-decomposition.m create mode 100644 Task/Prime-decomposition/MUMPS/prime-decomposition.mumps create mode 100644 Task/Prime-decomposition/Mathematica/prime-decomposition-1.math create mode 100644 Task/Prime-decomposition/Mathematica/prime-decomposition-2.math create mode 100644 Task/Prime-decomposition/Mathematica/prime-decomposition-3.math create mode 100644 Task/Prime-decomposition/Mathematica/prime-decomposition-4.math create mode 100644 Task/Prime-decomposition/Mathematica/prime-decomposition-5.math create mode 100644 Task/Prime-decomposition/Mathematica/prime-decomposition-6.math create mode 100644 Task/Prime-decomposition/Maxima/prime-decomposition-1.maxima create mode 100644 Task/Prime-decomposition/Maxima/prime-decomposition-2.maxima create mode 100644 Task/Prime-decomposition/OCaml/prime-decomposition.ocaml create mode 100644 Task/Prime-decomposition/Octave/prime-decomposition.octave create mode 100644 Task/Prime-decomposition/PARI-GP/prime-decomposition.pari create mode 100644 Task/Prime-decomposition/PL-I/prime-decomposition.pli create mode 100644 Task/Prime-decomposition/Pascal/prime-decomposition.pascal create mode 100644 Task/Prime-decomposition/Perl-6/prime-decomposition.pl6 create mode 100644 Task/Prime-decomposition/Perl/prime-decomposition.pl create mode 100644 Task/Prime-decomposition/PicoLisp/prime-decomposition.l create mode 100644 Task/Prime-decomposition/Prolog/prime-decomposition-1.pro create mode 100644 Task/Prime-decomposition/Prolog/prime-decomposition-2.pro create mode 100644 Task/Prime-decomposition/Pure/prime-decomposition.pure create mode 100644 Task/Prime-decomposition/PureBasic/prime-decomposition.purebasic create mode 100644 Task/Prime-decomposition/Python/prime-decomposition-1.py create mode 100644 Task/Prime-decomposition/Python/prime-decomposition-2.py create mode 100644 Task/Prime-decomposition/Python/prime-decomposition-3.py create mode 100644 Task/Prime-decomposition/R/prime-decomposition.r create mode 100644 Task/Prime-decomposition/REXX/prime-decomposition.rexx create mode 100644 Task/Prime-decomposition/Ruby/prime-decomposition-1.rb create mode 100644 Task/Prime-decomposition/Ruby/prime-decomposition-2.rb create mode 100644 Task/Prime-decomposition/Ruby/prime-decomposition-3.rb create mode 100644 Task/Prime-decomposition/Ruby/prime-decomposition-4.rb create mode 100644 Task/Prime-decomposition/Ruby/prime-decomposition-5.rb create mode 100644 Task/Prime-decomposition/Scala/prime-decomposition-1.scala create mode 100644 Task/Prime-decomposition/Scala/prime-decomposition-2.scala create mode 100644 Task/Prime-decomposition/Scala/prime-decomposition-3.scala create mode 100644 Task/Prime-decomposition/Scala/prime-decomposition-4.scala create mode 100644 Task/Prime-decomposition/Scheme/prime-decomposition.ss create mode 100644 Task/Prime-decomposition/Seed7/prime-decomposition.seed7 create mode 100644 Task/Prime-decomposition/Slate/prime-decomposition.slate create mode 100644 Task/Prime-decomposition/Smalltalk/prime-decomposition.st create mode 100644 Task/Prime-decomposition/TXR/prime-decomposition.txr create mode 100644 Task/Prime-decomposition/Tcl/prime-decomposition-1.tcl create mode 100644 Task/Prime-decomposition/Tcl/prime-decomposition-2.tcl create mode 100644 Task/Prime-decomposition/V/prime-decomposition-1.v create mode 100644 Task/Prime-decomposition/V/prime-decomposition-2.v create mode 100644 Task/Prime-decomposition/V/prime-decomposition-3.v create mode 100644 Task/Prime-decomposition/XSLT/prime-decomposition-1.xslt create mode 100644 Task/Prime-decomposition/XSLT/prime-decomposition-2.xslt create mode 100644 Task/Prime-decomposition/XSLT/prime-decomposition-3.xslt create mode 100644 Task/Priority-queue/0DESCRIPTION create mode 100644 Task/Priority-queue/Ada/priority-queue.ada create mode 100644 Task/Priority-queue/Axiom/priority-queue-1.axiom create mode 100644 Task/Priority-queue/Axiom/priority-queue-2.axiom create mode 100644 Task/Priority-queue/Axiom/priority-queue-3.axiom create mode 100644 Task/Priority-queue/C++/priority-queue-1.cpp create mode 100644 Task/Priority-queue/C++/priority-queue-2.cpp create mode 100644 Task/Priority-queue/C/priority-queue-1.c create mode 100644 Task/Priority-queue/C/priority-queue-2.c create mode 100644 Task/Priority-queue/CoffeeScript/priority-queue-1.coffeescript create mode 100644 Task/Priority-queue/CoffeeScript/priority-queue-2.coffeescript create mode 100644 Task/Priority-queue/D/priority-queue.d create mode 100644 Task/Priority-queue/Factor/priority-queue-1.factor create mode 100644 Task/Priority-queue/Factor/priority-queue-2.factor create mode 100644 Task/Priority-queue/Go/priority-queue.go create mode 100644 Task/Priority-queue/Haskell/priority-queue-1.hs create mode 100644 Task/Priority-queue/Haskell/priority-queue-2.hs create mode 100644 Task/Priority-queue/Icon/priority-queue.icon create mode 100644 Task/Priority-queue/J/priority-queue-1.j create mode 100644 Task/Priority-queue/J/priority-queue-2.j create mode 100644 Task/Priority-queue/Java/priority-queue.java create mode 100644 Task/Priority-queue/Mathematica/priority-queue-1.math create mode 100644 Task/Priority-queue/Mathematica/priority-queue-2.math create mode 100644 Task/Priority-queue/Maxima/priority-queue.maxima create mode 100644 Task/Priority-queue/OCaml/priority-queue-1.ocaml create mode 100644 Task/Priority-queue/OCaml/priority-queue-2.ocaml create mode 100644 Task/Priority-queue/Objective-C/priority-queue.m create mode 100644 Task/Priority-queue/PHP/priority-queue-1.php create mode 100644 Task/Priority-queue/PHP/priority-queue-2.php create mode 100644 Task/Priority-queue/Perl-6/priority-queue.pl6 create mode 100644 Task/Priority-queue/Perl/priority-queue-1.pl create mode 100644 Task/Priority-queue/Perl/priority-queue-2.pl create mode 100644 Task/Priority-queue/PicoLisp/priority-queue-1.l create mode 100644 Task/Priority-queue/PicoLisp/priority-queue-2.l create mode 100644 Task/Priority-queue/Prolog/priority-queue.pro create mode 100644 Task/Priority-queue/PureBasic/priority-queue.purebasic create mode 100644 Task/Priority-queue/Python/priority-queue-1.py create mode 100644 Task/Priority-queue/Python/priority-queue-2.py create mode 100644 Task/Priority-queue/Python/priority-queue-3.py create mode 100644 Task/Priority-queue/Python/priority-queue-4.py create mode 100644 Task/Priority-queue/R/priority-queue-1.r create mode 100644 Task/Priority-queue/R/priority-queue-2.r create mode 100644 Task/Priority-queue/R/priority-queue-3.r create mode 100644 Task/Priority-queue/R/priority-queue-4.r create mode 100644 Task/Priority-queue/Ruby/priority-queue.rb create mode 100644 Task/Priority-queue/Run-BASIC/priority-queue.run create mode 100644 Task/Priority-queue/Scala/priority-queue-1.scala create mode 100644 Task/Priority-queue/Scala/priority-queue-2.scala create mode 100644 Task/Priority-queue/Standard-ML/priority-queue.ml create mode 100644 Task/Priority-queue/Tcl/priority-queue.tcl create mode 100644 Task/Probabilistic-choice/0DESCRIPTION create mode 100644 Task/Probabilistic-choice/1META.yaml create mode 100644 Task/Probabilistic-choice/ALGOL-68/probabilistic-choice.alg create mode 100644 Task/Probabilistic-choice/AWK/probabilistic-choice.awk create mode 100644 Task/Probabilistic-choice/Ada/probabilistic-choice.ada create mode 100644 Task/Probabilistic-choice/AutoHotkey/probabilistic-choice.ahk create mode 100644 Task/Probabilistic-choice/BBC-BASIC/probabilistic-choice.bbc create mode 100644 Task/Probabilistic-choice/C++/probabilistic-choice.cpp create mode 100644 Task/Probabilistic-choice/C/probabilistic-choice-1.c create mode 100644 Task/Probabilistic-choice/C/probabilistic-choice-2.c create mode 100644 Task/Probabilistic-choice/Clojure/probabilistic-choice.clj create mode 100644 Task/Probabilistic-choice/Common-Lisp/probabilistic-choice.lisp create mode 100644 Task/Probabilistic-choice/D/probabilistic-choice-1.d create mode 100644 Task/Probabilistic-choice/D/probabilistic-choice-2.d create mode 100644 Task/Probabilistic-choice/E/probabilistic-choice-1.e create mode 100644 Task/Probabilistic-choice/E/probabilistic-choice-2.e create mode 100644 Task/Probabilistic-choice/E/probabilistic-choice-3.e create mode 100644 Task/Probabilistic-choice/Euphoria/probabilistic-choice.euphoria create mode 100644 Task/Probabilistic-choice/Factor/probabilistic-choice-1.factor create mode 100644 Task/Probabilistic-choice/Factor/probabilistic-choice-2.factor create mode 100644 Task/Probabilistic-choice/Factor/probabilistic-choice-3.factor create mode 100644 Task/Probabilistic-choice/Forth/probabilistic-choice.fth create mode 100644 Task/Probabilistic-choice/Fortran/probabilistic-choice.f create mode 100644 Task/Probabilistic-choice/Go/probabilistic-choice.go create mode 100644 Task/Probabilistic-choice/Haskell/probabilistic-choice.hs create mode 100644 Task/Probabilistic-choice/HicEst/probabilistic-choice.hicest create mode 100644 Task/Probabilistic-choice/Icon/probabilistic-choice.icon create mode 100644 Task/Probabilistic-choice/J/probabilistic-choice-1.j create mode 100644 Task/Probabilistic-choice/J/probabilistic-choice-2.j create mode 100644 Task/Probabilistic-choice/J/probabilistic-choice-3.j create mode 100644 Task/Probabilistic-choice/Java/probabilistic-choice-1.java create mode 100644 Task/Probabilistic-choice/Java/probabilistic-choice-2.java create mode 100644 Task/Probabilistic-choice/JavaScript/probabilistic-choice.js create mode 100644 Task/Probabilistic-choice/Liberty-BASIC/probabilistic-choice.liberty create mode 100644 Task/Probabilistic-choice/Lua/probabilistic-choice.lua create mode 100644 Task/Probabilistic-choice/Mathematica/probabilistic-choice-1.math create mode 100644 Task/Probabilistic-choice/Mathematica/probabilistic-choice-2.math create mode 100644 Task/Probabilistic-choice/OCaml/probabilistic-choice.ocaml create mode 100644 Task/Probabilistic-choice/PARI-GP/probabilistic-choice.pari create mode 100644 Task/Probabilistic-choice/Perl-6/probabilistic-choice.pl6 create mode 100644 Task/Probabilistic-choice/Perl/probabilistic-choice.pl create mode 100644 Task/Probabilistic-choice/PicoLisp/probabilistic-choice.l create mode 100644 Task/Probabilistic-choice/PureBasic/probabilistic-choice.purebasic create mode 100644 Task/Probabilistic-choice/Python/probabilistic-choice.py create mode 100644 Task/Probabilistic-choice/R/probabilistic-choice-1.r create mode 100644 Task/Probabilistic-choice/R/probabilistic-choice-2.r create mode 100644 Task/Probabilistic-choice/REXX/probabilistic-choice.rexx create mode 100644 Task/Probabilistic-choice/Ruby/probabilistic-choice.rb create mode 100644 Task/Probabilistic-choice/Seed7/probabilistic-choice.seed7 create mode 100644 Task/Probabilistic-choice/Tcl/probabilistic-choice.tcl create mode 100644 Task/Probabilistic-choice/Ursala/probabilistic-choice.ursala create mode 100644 Task/Probabilistic-choice/XPL0/probabilistic-choice.xpl0 create mode 100644 Task/Problem-of-Apollonius/0DESCRIPTION create mode 100644 Task/Problem-of-Apollonius/1META.yaml create mode 100644 Task/Problem-of-Apollonius/Ada/problem-of-apollonius-1.ada create mode 100644 Task/Problem-of-Apollonius/Ada/problem-of-apollonius-2.ada create mode 100644 Task/Problem-of-Apollonius/Ada/problem-of-apollonius-3.ada create mode 100644 Task/Problem-of-Apollonius/BBC-BASIC/problem-of-apollonius.bbc create mode 100644 Task/Problem-of-Apollonius/C/problem-of-apollonius.c create mode 100644 Task/Problem-of-Apollonius/CoffeeScript/problem-of-apollonius-1.coffeescript create mode 100644 Task/Problem-of-Apollonius/CoffeeScript/problem-of-apollonius-2.coffeescript create mode 100644 Task/Problem-of-Apollonius/D/problem-of-apollonius.d create mode 100644 Task/Problem-of-Apollonius/Fortran/problem-of-apollonius.f create mode 100644 Task/Problem-of-Apollonius/Go/problem-of-apollonius.go create mode 100644 Task/Problem-of-Apollonius/Haskell/problem-of-apollonius.hs create mode 100644 Task/Problem-of-Apollonius/Icon/problem-of-apollonius.icon create mode 100644 Task/Problem-of-Apollonius/J/problem-of-apollonius-1.j create mode 100644 Task/Problem-of-Apollonius/J/problem-of-apollonius-2.j create mode 100644 Task/Problem-of-Apollonius/Java/problem-of-apollonius.java create mode 100644 Task/Problem-of-Apollonius/Liberty-BASIC/problem-of-apollonius.liberty create mode 100644 Task/Problem-of-Apollonius/MUMPS/problem-of-apollonius.mumps create mode 100644 Task/Problem-of-Apollonius/Mathematica/problem-of-apollonius.math create mode 100644 Task/Problem-of-Apollonius/OCaml/problem-of-apollonius.ocaml create mode 100644 Task/Problem-of-Apollonius/Perl-6/problem-of-apollonius.pl6 create mode 100644 Task/Problem-of-Apollonius/PureBasic/problem-of-apollonius.purebasic create mode 100644 Task/Problem-of-Apollonius/Python/problem-of-apollonius.py create mode 100644 Task/Problem-of-Apollonius/REXX/problem-of-apollonius.rexx create mode 100644 Task/Problem-of-Apollonius/Ruby/problem-of-apollonius.rb create mode 100644 Task/Problem-of-Apollonius/Scala/problem-of-apollonius.scala create mode 100644 Task/Problem-of-Apollonius/Tcl/problem-of-apollonius-1.tcl create mode 100644 Task/Problem-of-Apollonius/Tcl/problem-of-apollonius-2.tcl create mode 100644 Task/Program-name/0DESCRIPTION create mode 100644 Task/Program-name/1META.yaml create mode 100644 Task/Program-name/Ada/program-name.ada create mode 100644 Task/Program-name/AutoHotkey/program-name.ahk create mode 100644 Task/Program-name/BASIC/program-name-1.basic create mode 100644 Task/Program-name/BASIC/program-name-2.basic create mode 100644 Task/Program-name/BBC-BASIC/program-name.bbc create mode 100644 Task/Program-name/C++/program-name.cpp create mode 100644 Task/Program-name/C/program-name-1.c create mode 100644 Task/Program-name/C/program-name-2.c create mode 100644 Task/Program-name/C/program-name-3.c create mode 100644 Task/Program-name/C/program-name-4.c create mode 100644 Task/Program-name/Clojure/program-name.clj create mode 100644 Task/Program-name/Common-Lisp/program-name-1.lisp create mode 100644 Task/Program-name/Common-Lisp/program-name-2.lisp create mode 100644 Task/Program-name/D/program-name-1.d create mode 100644 Task/Program-name/D/program-name-2.d create mode 100644 Task/Program-name/D/program-name-3.d create mode 100644 Task/Program-name/Dart/program-name.dart create mode 100644 Task/Program-name/Delphi/program-name.delphi create mode 100644 Task/Program-name/Emacs-Lisp/program-name.l create mode 100644 Task/Program-name/Erlang/program-name.erl create mode 100644 Task/Program-name/Euphoria/program-name.euphoria create mode 100644 Task/Program-name/Factor/program-name.factor create mode 100644 Task/Program-name/Forth/program-name.fth create mode 100644 Task/Program-name/Go/program-name.go create mode 100644 Task/Program-name/Groovy/program-name-1.groovy create mode 100644 Task/Program-name/Groovy/program-name-2.groovy create mode 100644 Task/Program-name/Haskell/program-name.hs create mode 100644 Task/Program-name/Icon/program-name.icon create mode 100644 Task/Program-name/Io/program-name.io create mode 100644 Task/Program-name/J/program-name.j create mode 100644 Task/Program-name/Java/program-name-1.java create mode 100644 Task/Program-name/Java/program-name-2.java create mode 100644 Task/Program-name/Java/program-name-3.java create mode 100644 Task/Program-name/Java/program-name-4.java create mode 100644 Task/Program-name/JavaScript/program-name-1.js create mode 100644 Task/Program-name/JavaScript/program-name-2.js create mode 100644 Task/Program-name/JavaScript/program-name-3.js create mode 100644 Task/Program-name/LLVM/program-name-1.llvm create mode 100644 Task/Program-name/LLVM/program-name-2.llvm create mode 100644 Task/Program-name/LLVM/program-name-3.llvm create mode 100644 Task/Program-name/Lua/program-name.lua create mode 100644 Task/Program-name/Mathematica/program-name.math create mode 100644 Task/Program-name/NetRexx/program-name.netrexx create mode 100644 Task/Program-name/OCaml/program-name.ocaml create mode 100644 Task/Program-name/Objective-C/program-name-1.m create mode 100644 Task/Program-name/Objective-C/program-name-2.m create mode 100644 Task/Program-name/Octave/program-name.octave create mode 100644 Task/Program-name/Order/program-name.order create mode 100644 Task/Program-name/PHP/program-name.php create mode 100644 Task/Program-name/Pascal/program-name.pascal create mode 100644 Task/Program-name/Perl-6/program-name.pl6 create mode 100644 Task/Program-name/Perl/program-name.pl create mode 100644 Task/Program-name/PicoLisp/program-name.l create mode 100644 Task/Program-name/PowerBASIC/program-name-1.powerbasic create mode 100644 Task/Program-name/PowerBASIC/program-name-2.powerbasic create mode 100644 Task/Program-name/PureBasic/program-name.purebasic create mode 100644 Task/Program-name/Python/program-name-1.py create mode 100644 Task/Program-name/Python/program-name-2.py create mode 100644 Task/Program-name/R/program-name.r create mode 100644 Task/Program-name/REXX/program-name-1.rexx create mode 100644 Task/Program-name/REXX/program-name-2.rexx create mode 100644 Task/Program-name/REXX/program-name-3.rexx create mode 100644 Task/Program-name/REXX/program-name-4.rexx create mode 100644 Task/Program-name/REXX/program-name-5.rexx create mode 100644 Task/Program-name/Racket/program-name.rkt create mode 100644 Task/Program-name/Ruby/program-name.rb create mode 100644 Task/Program-name/Rust/program-name-1.rust create mode 100644 Task/Program-name/Rust/program-name-2.rust create mode 100644 Task/Program-name/Scala/program-name-1.scala create mode 100644 Task/Program-name/Scala/program-name-2.scala create mode 100644 Task/Program-name/Scheme/program-name.ss create mode 100644 Task/Program-name/Seed7/program-name.seed7 create mode 100644 Task/Program-name/Smalltalk/program-name-1.st create mode 100644 Task/Program-name/Smalltalk/program-name-2.st create mode 100644 Task/Program-name/Standard-ML/program-name.ml create mode 100644 Task/Program-name/Tcl/program-name.tcl create mode 100644 Task/Program-name/UNIX-Shell/program-name.sh create mode 100644 Task/Program-name/VBA/program-name.vba create mode 100644 Task/Program-name/Vala/program-name.vala create mode 100644 Task/Program-name/Visual-Basic/program-name-1.vb create mode 100644 Task/Program-name/Visual-Basic/program-name-2.vb create mode 100644 Task/Program-termination/0DESCRIPTION create mode 100644 Task/Program-termination/1META.yaml create mode 100644 Task/Program-termination/ALGOL-68/program-termination.alg create mode 100644 Task/Program-termination/AWK/program-termination.awk create mode 100644 Task/Program-termination/Ada/program-termination-1.ada create mode 100644 Task/Program-termination/Ada/program-termination-2.ada create mode 100644 Task/Program-termination/Ada/program-termination-3.ada create mode 100644 Task/Program-termination/Ada/program-termination-4.ada create mode 100644 Task/Program-termination/AppleScript/program-termination-1.applescript create mode 100644 Task/Program-termination/AppleScript/program-termination-2.applescript create mode 100644 Task/Program-termination/AutoHotkey/program-termination.ahk create mode 100644 Task/Program-termination/AutoIt/program-termination.autoit create mode 100644 Task/Program-termination/BASIC/program-termination-1.basic create mode 100644 Task/Program-termination/BASIC/program-termination-2.basic create mode 100644 Task/Program-termination/BASIC/program-termination-3.basic create mode 100644 Task/Program-termination/BASIC/program-termination-4.basic create mode 100644 Task/Program-termination/BBC-BASIC/program-termination.bbc create mode 100644 Task/Program-termination/Batch-File/program-termination.bat create mode 100644 Task/Program-termination/C++/program-termination-1.cpp create mode 100644 Task/Program-termination/C++/program-termination-2.cpp create mode 100644 Task/Program-termination/C++/program-termination-3.cpp create mode 100644 Task/Program-termination/C/program-termination-1.c create mode 100644 Task/Program-termination/C/program-termination-2.c create mode 100644 Task/Program-termination/C/program-termination-3.c create mode 100644 Task/Program-termination/Clojure/program-termination-1.clj create mode 100644 Task/Program-termination/Clojure/program-termination-2.clj create mode 100644 Task/Program-termination/Common-Lisp/program-termination.lisp create mode 100644 Task/Program-termination/Delphi/program-termination-1.delphi create mode 100644 Task/Program-termination/Delphi/program-termination-2.delphi create mode 100644 Task/Program-termination/E/program-termination-1.e create mode 100644 Task/Program-termination/E/program-termination-2.e create mode 100644 Task/Program-termination/Forth/program-termination.fth create mode 100644 Task/Program-termination/Fortran/program-termination.f create mode 100644 Task/Program-termination/GW-BASIC/program-termination.gw-basic create mode 100644 Task/Program-termination/Gema/program-termination.gema create mode 100644 Task/Program-termination/Go/program-termination-1.go create mode 100644 Task/Program-termination/Go/program-termination-2.go create mode 100644 Task/Program-termination/Go/program-termination-3.go create mode 100644 Task/Program-termination/Go/program-termination-4.go create mode 100644 Task/Program-termination/Groovy/program-termination-1.groovy create mode 100644 Task/Program-termination/Groovy/program-termination-2.groovy create mode 100644 Task/Program-termination/Haskell/program-termination.hs create mode 100644 Task/Program-termination/HicEst/program-termination.hicest create mode 100644 Task/Program-termination/Icon/program-termination.icon create mode 100644 Task/Program-termination/J/program-termination-1.j create mode 100644 Task/Program-termination/J/program-termination-2.j create mode 100644 Task/Program-termination/Java/program-termination-1.java create mode 100644 Task/Program-termination/Java/program-termination-2.java create mode 100644 Task/Program-termination/JavaScript/program-termination.js create mode 100644 Task/Program-termination/Liberty-BASIC/program-termination.liberty create mode 100644 Task/Program-termination/Logo/program-termination.logo create mode 100644 Task/Program-termination/Lua/program-termination.lua create mode 100644 Task/Program-termination/M4/program-termination.m4 create mode 100644 Task/Program-termination/MATLAB/program-termination-1.m create mode 100644 Task/Program-termination/MATLAB/program-termination-2.m create mode 100644 Task/Program-termination/Mathematica/program-termination.math create mode 100644 Task/Program-termination/Maxima/program-termination.maxima create mode 100644 Task/Program-termination/NetRexx/program-termination.netrexx create mode 100644 Task/Program-termination/Nimrod/program-termination.nimrod create mode 100644 Task/Program-termination/OCaml/program-termination.ocaml create mode 100644 Task/Program-termination/Objeck/program-termination.objeck create mode 100644 Task/Program-termination/Oz/program-termination.oz create mode 100644 Task/Program-termination/PARI-GP/program-termination.pari create mode 100644 Task/Program-termination/PHP/program-termination.php create mode 100644 Task/Program-termination/PL-I/program-termination-1.pli create mode 100644 Task/Program-termination/PL-I/program-termination-2.pli create mode 100644 Task/Program-termination/PL-I/program-termination-3.pli create mode 100644 Task/Program-termination/Perl-6/program-termination.pl6 create mode 100644 Task/Program-termination/Perl/program-termination.pl create mode 100644 Task/Program-termination/PicoLisp/program-termination.l create mode 100644 Task/Program-termination/Pop11/program-termination.pop11 create mode 100644 Task/Program-termination/PostScript/program-termination-1.ps create mode 100644 Task/Program-termination/PostScript/program-termination-2.ps create mode 100644 Task/Program-termination/PowerShell/program-termination.psh create mode 100644 Task/Program-termination/Prolog/program-termination-1.pro create mode 100644 Task/Program-termination/Prolog/program-termination-2.pro create mode 100644 Task/Program-termination/PureBasic/program-termination.purebasic create mode 100644 Task/Program-termination/Python/program-termination-1.py create mode 100644 Task/Program-termination/Python/program-termination-2.py create mode 100644 Task/Program-termination/R/program-termination.r create mode 100644 Task/Program-termination/REBOL/program-termination-1.rebol create mode 100644 Task/Program-termination/REBOL/program-termination-2.rebol create mode 100644 Task/Program-termination/REBOL/program-termination-3.rebol create mode 100644 Task/Program-termination/REBOL/program-termination-4.rebol create mode 100644 Task/Program-termination/REXX/program-termination.rexx create mode 100644 Task/Program-termination/Retro/program-termination.retro create mode 100644 Task/Program-termination/Ruby/program-termination-1.rb create mode 100644 Task/Program-termination/Ruby/program-termination-2.rb create mode 100644 Task/Program-termination/SNOBOL4/program-termination.sno create mode 100644 Task/Program-termination/Scheme/program-termination-1.ss create mode 100644 Task/Program-termination/Scheme/program-termination-2.ss create mode 100644 Task/Program-termination/Scheme/program-termination-3.ss create mode 100644 Task/Program-termination/Seed7/program-termination.seed7 create mode 100644 Task/Program-termination/Slate/program-termination.slate create mode 100644 Task/Program-termination/Standard-ML/program-termination.ml create mode 100644 Task/Program-termination/TI-83-BASIC/program-termination.ti-83 create mode 100644 Task/Program-termination/TI-89-BASIC/program-termination.ti-89 create mode 100644 Task/Program-termination/TUSCRIPT/program-termination.tuscript create mode 100644 Task/Program-termination/Tcl/program-termination-1.tcl create mode 100644 Task/Program-termination/Tcl/program-termination-2.tcl create mode 100644 Task/Program-termination/UNIX-Shell/program-termination.sh create mode 100644 Task/Program-termination/Unlambda/program-termination.unlambda create mode 100644 Task/Program-termination/VBScript/program-termination.vbscript create mode 100644 Task/Program-termination/Vedit-macro-language/program-termination.vedit create mode 100644 Task/Program-termination/Visual-Basic/program-termination.vb create mode 100644 Task/Program-termination/XPL0/program-termination.xpl0 create mode 100644 Task/Pythagorean-triples/0DESCRIPTION create mode 100644 Task/Pythagorean-triples/Ada/pythagorean-triples.ada create mode 100644 Task/Pythagorean-triples/BBC-BASIC/pythagorean-triples.bbc create mode 100644 Task/Pythagorean-triples/Bracmat/pythagorean-triples-1.bracmat create mode 100644 Task/Pythagorean-triples/Bracmat/pythagorean-triples-2.bracmat create mode 100644 Task/Pythagorean-triples/C/pythagorean-triples-1.c create mode 100644 Task/Pythagorean-triples/C/pythagorean-triples-2.c create mode 100644 Task/Pythagorean-triples/C/pythagorean-triples-3.c create mode 100644 Task/Pythagorean-triples/C/pythagorean-triples-4.c create mode 100644 Task/Pythagorean-triples/C/pythagorean-triples-5.c create mode 100644 Task/Pythagorean-triples/CoffeeScript/pythagorean-triples.coffeescript create mode 100644 Task/Pythagorean-triples/Common-Lisp/pythagorean-triples-1.lisp create mode 100644 Task/Pythagorean-triples/Common-Lisp/pythagorean-triples-2.lisp create mode 100644 Task/Pythagorean-triples/D/pythagorean-triples-1.d create mode 100644 Task/Pythagorean-triples/D/pythagorean-triples-2.d create mode 100644 Task/Pythagorean-triples/Erlang/pythagorean-triples.erl create mode 100644 Task/Pythagorean-triples/Euphoria/pythagorean-triples.euphoria create mode 100644 Task/Pythagorean-triples/Factor/pythagorean-triples.factor create mode 100644 Task/Pythagorean-triples/Forth/pythagorean-triples.fth create mode 100644 Task/Pythagorean-triples/Fortran/pythagorean-triples.f create mode 100644 Task/Pythagorean-triples/Go/pythagorean-triples.go create mode 100644 Task/Pythagorean-triples/Haskell/pythagorean-triples-1.hs create mode 100644 Task/Pythagorean-triples/Haskell/pythagorean-triples-2.hs create mode 100644 Task/Pythagorean-triples/Icon/pythagorean-triples.icon create mode 100644 Task/Pythagorean-triples/J/pythagorean-triples-1.j create mode 100644 Task/Pythagorean-triples/J/pythagorean-triples-2.j create mode 100644 Task/Pythagorean-triples/J/pythagorean-triples-3.j create mode 100644 Task/Pythagorean-triples/J/pythagorean-triples-4.j create mode 100644 Task/Pythagorean-triples/J/pythagorean-triples-5.j create mode 100644 Task/Pythagorean-triples/J/pythagorean-triples-6.j create mode 100644 Task/Pythagorean-triples/Java/pythagorean-triples-1.java create mode 100644 Task/Pythagorean-triples/Java/pythagorean-triples-2.java create mode 100644 Task/Pythagorean-triples/Liberty-BASIC/pythagorean-triples.liberty create mode 100644 Task/Pythagorean-triples/MATLAB/pythagorean-triples.m create mode 100644 Task/Pythagorean-triples/Mathematica/pythagorean-triples.math create mode 100644 Task/Pythagorean-triples/Modula-3/pythagorean-triples.mod3 create mode 100644 Task/Pythagorean-triples/OCaml/pythagorean-triples.ocaml create mode 100644 Task/Pythagorean-triples/PARI-GP/pythagorean-triples.pari create mode 100644 Task/Pythagorean-triples/Pascal/pythagorean-triples.pascal create mode 100644 Task/Pythagorean-triples/Perl-6/pythagorean-triples-1.pl6 create mode 100644 Task/Pythagorean-triples/Perl-6/pythagorean-triples-2.pl6 create mode 100644 Task/Pythagorean-triples/Perl-6/pythagorean-triples-3.pl6 create mode 100644 Task/Pythagorean-triples/PicoLisp/pythagorean-triples.l create mode 100644 Task/Pythagorean-triples/PureBasic/pythagorean-triples.purebasic create mode 100644 Task/Pythagorean-triples/Python/pythagorean-triples-1.py create mode 100644 Task/Pythagorean-triples/Python/pythagorean-triples-2.py create mode 100644 Task/Pythagorean-triples/Python/pythagorean-triples-3.py create mode 100644 Task/Pythagorean-triples/REXX/pythagorean-triples-1.rexx create mode 100644 Task/Pythagorean-triples/REXX/pythagorean-triples-2.rexx create mode 100644 Task/Pythagorean-triples/Ruby/pythagorean-triples.rb create mode 100644 Task/Pythagorean-triples/Seed7/pythagorean-triples.seed7 create mode 100644 Task/Pythagorean-triples/Tcl/pythagorean-triples.tcl create mode 100644 Task/QR-decomposition/0DESCRIPTION create mode 100644 Task/QR-decomposition/1META.yaml create mode 100644 Task/QR-decomposition/Ada/qr-decomposition.ada create mode 100644 Task/QR-decomposition/Axiom/qr-decomposition-1.axiom create mode 100644 Task/QR-decomposition/Axiom/qr-decomposition-2.axiom create mode 100644 Task/QR-decomposition/Axiom/qr-decomposition-3.axiom create mode 100644 Task/QR-decomposition/BBC-BASIC/qr-decomposition.bbc create mode 100644 Task/QR-decomposition/C/qr-decomposition.c create mode 100644 Task/QR-decomposition/Common-Lisp/qr-decomposition-1.lisp create mode 100644 Task/QR-decomposition/Common-Lisp/qr-decomposition-2.lisp create mode 100644 Task/QR-decomposition/Common-Lisp/qr-decomposition-3.lisp create mode 100644 Task/QR-decomposition/Common-Lisp/qr-decomposition-4.lisp create mode 100644 Task/QR-decomposition/Common-Lisp/qr-decomposition-5.lisp create mode 100644 Task/QR-decomposition/D/qr-decomposition.d create mode 100644 Task/QR-decomposition/Go/qr-decomposition.go create mode 100644 Task/QR-decomposition/J/qr-decomposition-1.j create mode 100644 Task/QR-decomposition/J/qr-decomposition-2.j create mode 100644 Task/QR-decomposition/J/qr-decomposition-3.j create mode 100644 Task/QR-decomposition/MATLAB/qr-decomposition.m create mode 100644 Task/QR-decomposition/Mathematica/qr-decomposition.math create mode 100644 Task/QR-decomposition/Maxima/qr-decomposition-1.maxima create mode 100644 Task/QR-decomposition/Maxima/qr-decomposition-2.maxima create mode 100644 Task/QR-decomposition/Maxima/qr-decomposition-3.maxima create mode 100644 Task/QR-decomposition/PARI-GP/qr-decomposition.pari create mode 100644 Task/QR-decomposition/R/qr-decomposition.r create mode 100644 Task/QR-decomposition/Rascal/qr-decomposition.rascal create mode 100644 Task/QR-decomposition/SAS/qr-decomposition.sas create mode 100644 Task/QR-decomposition/Tcl/qr-decomposition-1.tcl create mode 100644 Task/QR-decomposition/Tcl/qr-decomposition-2.tcl create mode 100644 Task/Quaternion-type/0DESCRIPTION create mode 100644 Task/Quaternion-type/ALGOL-68/quaternion-type.alg create mode 100644 Task/Quaternion-type/Ada/quaternion-type-1.ada create mode 100644 Task/Quaternion-type/Ada/quaternion-type-2.ada create mode 100644 Task/Quaternion-type/Ada/quaternion-type-3.ada create mode 100644 Task/Quaternion-type/BBC-BASIC/quaternion-type.bbc create mode 100644 Task/Quaternion-type/C++/quaternion-type-1.cpp create mode 100644 Task/Quaternion-type/C++/quaternion-type-2.cpp create mode 100644 Task/Quaternion-type/C-sharp/quaternion-type-1.cs create mode 100644 Task/Quaternion-type/C-sharp/quaternion-type-2.cs create mode 100644 Task/Quaternion-type/C/quaternion-type-1.c create mode 100644 Task/Quaternion-type/C/quaternion-type-2.c create mode 100644 Task/Quaternion-type/D/quaternion-type.d create mode 100644 Task/Quaternion-type/Delphi/quaternion-type-1.delphi create mode 100644 Task/Quaternion-type/Delphi/quaternion-type-2.delphi create mode 100644 Task/Quaternion-type/E/quaternion-type-1.e create mode 100644 Task/Quaternion-type/E/quaternion-type-2.e create mode 100644 Task/Quaternion-type/Euphoria/quaternion-type.euphoria create mode 100644 Task/Quaternion-type/Forth/quaternion-type.fth create mode 100644 Task/Quaternion-type/Fortran/quaternion-type.f create mode 100644 Task/Quaternion-type/GAP/quaternion-type.gap create mode 100644 Task/Quaternion-type/Go/quaternion-type.go create mode 100644 Task/Quaternion-type/Haskell/quaternion-type-1.hs create mode 100644 Task/Quaternion-type/Haskell/quaternion-type-2.hs create mode 100644 Task/Quaternion-type/Haskell/quaternion-type-3.hs create mode 100644 Task/Quaternion-type/Haskell/quaternion-type-4.hs create mode 100644 Task/Quaternion-type/J/quaternion-type-1.j create mode 100644 Task/Quaternion-type/J/quaternion-type-2.j create mode 100644 Task/Quaternion-type/Java/quaternion-type.java create mode 100644 Task/Quaternion-type/Liberty-BASIC/quaternion-type.liberty create mode 100644 Task/Quaternion-type/Lua/quaternion-type-1.lua create mode 100644 Task/Quaternion-type/Lua/quaternion-type-2.lua create mode 100644 Task/Quaternion-type/Mathematica/quaternion-type.math create mode 100644 Task/Quaternion-type/OCaml/quaternion-type-1.ocaml create mode 100644 Task/Quaternion-type/OCaml/quaternion-type-2.ocaml create mode 100644 Task/Quaternion-type/PARI-GP/quaternion-type-1.pari create mode 100644 Task/Quaternion-type/PARI-GP/quaternion-type-2.pari create mode 100644 Task/Quaternion-type/Perl-6/quaternion-type.pl6 create mode 100644 Task/Quaternion-type/Perl/quaternion-type.pl create mode 100644 Task/Quaternion-type/PicoLisp/quaternion-type-1.l create mode 100644 Task/Quaternion-type/PicoLisp/quaternion-type-2.l create mode 100644 Task/Quaternion-type/PureBasic/quaternion-type-1.purebasic create mode 100644 Task/Quaternion-type/PureBasic/quaternion-type-2.purebasic create mode 100644 Task/Quaternion-type/Python/quaternion-type-1.py create mode 100644 Task/Quaternion-type/Python/quaternion-type-2.py create mode 100644 Task/Quaternion-type/R/quaternion-type.r create mode 100644 Task/Quaternion-type/REXX/quaternion-type.rexx create mode 100644 Task/Quaternion-type/Ruby/quaternion-type-1.rb create mode 100644 Task/Quaternion-type/Ruby/quaternion-type-2.rb create mode 100644 Task/Quaternion-type/Scala/quaternion-type-1.scala create mode 100644 Task/Quaternion-type/Scala/quaternion-type-2.scala create mode 100644 Task/Quaternion-type/Tcl/quaternion-type-1.tcl create mode 100644 Task/Quaternion-type/Tcl/quaternion-type-2.tcl create mode 100644 Task/Queue-Definition/0DESCRIPTION create mode 100644 Task/Queue-Definition/1META.yaml create mode 100644 Task/Queue-Definition/ACL2/queue-definition.acl2 create mode 100644 Task/Queue-Definition/AWK/queue-definition.awk create mode 100644 Task/Queue-Definition/Ada/queue-definition-1.ada create mode 100644 Task/Queue-Definition/Ada/queue-definition-10.ada create mode 100644 Task/Queue-Definition/Ada/queue-definition-11.ada create mode 100644 Task/Queue-Definition/Ada/queue-definition-12.ada create mode 100644 Task/Queue-Definition/Ada/queue-definition-2.ada create mode 100644 Task/Queue-Definition/Ada/queue-definition-3.ada create mode 100644 Task/Queue-Definition/Ada/queue-definition-4.ada create mode 100644 Task/Queue-Definition/Ada/queue-definition-5.ada create mode 100644 Task/Queue-Definition/Ada/queue-definition-6.ada create mode 100644 Task/Queue-Definition/Ada/queue-definition-7.ada create mode 100644 Task/Queue-Definition/Ada/queue-definition-8.ada create mode 100644 Task/Queue-Definition/Ada/queue-definition-9.ada create mode 100644 Task/Queue-Definition/AutoHotkey/queue-definition.ahk create mode 100644 Task/Queue-Definition/BBC-BASIC/queue-definition.bbc create mode 100644 Task/Queue-Definition/Batch-File/queue-definition.bat create mode 100644 Task/Queue-Definition/C++/queue-definition.cpp create mode 100644 Task/Queue-Definition/C-sharp/queue-definition.cs create mode 100644 Task/Queue-Definition/C/queue-definition-1.c create mode 100644 Task/Queue-Definition/C/queue-definition-2.c create mode 100644 Task/Queue-Definition/C/queue-definition-3.c create mode 100644 Task/Queue-Definition/C/queue-definition-4.c create mode 100644 Task/Queue-Definition/Clojure/queue-definition.clj create mode 100644 Task/Queue-Definition/CoffeeScript/queue-definition-1.coffeescript create mode 100644 Task/Queue-Definition/CoffeeScript/queue-definition-2.coffeescript create mode 100644 Task/Queue-Definition/Common-Lisp/queue-definition.lisp create mode 100644 Task/Queue-Definition/E/queue-definition.e create mode 100644 Task/Queue-Definition/Elisa/queue-definition-1.elisa create mode 100644 Task/Queue-Definition/Elisa/queue-definition-2.elisa create mode 100644 Task/Queue-Definition/Erlang/queue-definition.erl create mode 100644 Task/Queue-Definition/Fantom/queue-definition.fantom create mode 100644 Task/Queue-Definition/Forth/queue-definition.fth create mode 100644 Task/Queue-Definition/Fortran/queue-definition.f create mode 100644 Task/Queue-Definition/GAP/queue-definition.gap create mode 100644 Task/Queue-Definition/Go/queue-definition.go create mode 100644 Task/Queue-Definition/Groovy/queue-definition-1.groovy create mode 100644 Task/Queue-Definition/Groovy/queue-definition-2.groovy create mode 100644 Task/Queue-Definition/Haskell/queue-definition-1.hs create mode 100644 Task/Queue-Definition/Haskell/queue-definition-2.hs create mode 100644 Task/Queue-Definition/Haskell/queue-definition-3.hs create mode 100644 Task/Queue-Definition/J/queue-definition-1.j create mode 100644 Task/Queue-Definition/J/queue-definition-2.j create mode 100644 Task/Queue-Definition/Java/queue-definition.java create mode 100644 Task/Queue-Definition/JavaScript/queue-definition-1.js create mode 100644 Task/Queue-Definition/JavaScript/queue-definition-2.js create mode 100644 Task/Queue-Definition/Lua/queue-definition.lua create mode 100644 Task/Queue-Definition/MATLAB/queue-definition-1.m create mode 100644 Task/Queue-Definition/MATLAB/queue-definition-2.m create mode 100644 Task/Queue-Definition/MATLAB/queue-definition-3.m create mode 100644 Task/Queue-Definition/Mathematica/queue-definition.math create mode 100644 Task/Queue-Definition/Maxima/queue-definition.maxima create mode 100644 Task/Queue-Definition/NetRexx/queue-definition.netrexx create mode 100644 Task/Queue-Definition/OCaml/queue-definition-1.ocaml create mode 100644 Task/Queue-Definition/OCaml/queue-definition-2.ocaml create mode 100644 Task/Queue-Definition/OxygenBasic/queue-definition.oxy create mode 100644 Task/Queue-Definition/Oz/queue-definition.oz create mode 100644 Task/Queue-Definition/PHP/queue-definition-1.php create mode 100644 Task/Queue-Definition/PHP/queue-definition-2.php create mode 100644 Task/Queue-Definition/PL-I/queue-definition.pli create mode 100644 Task/Queue-Definition/Pascal/queue-definition.pascal create mode 100644 Task/Queue-Definition/Perl-6/queue-definition-1.pl6 create mode 100644 Task/Queue-Definition/Perl-6/queue-definition-2.pl6 create mode 100644 Task/Queue-Definition/Perl/queue-definition-1.pl create mode 100644 Task/Queue-Definition/Perl/queue-definition-2.pl create mode 100644 Task/Queue-Definition/PicoLisp/queue-definition.l create mode 100644 Task/Queue-Definition/PostScript/queue-definition.ps create mode 100644 Task/Queue-Definition/Prolog/queue-definition.pro create mode 100644 Task/Queue-Definition/PureBasic/queue-definition.purebasic create mode 100644 Task/Queue-Definition/Python/queue-definition-1.py create mode 100644 Task/Queue-Definition/Python/queue-definition-2.py create mode 100644 Task/Queue-Definition/Python/queue-definition-3.py create mode 100644 Task/Queue-Definition/R/queue-definition-1.r create mode 100644 Task/Queue-Definition/R/queue-definition-2.r create mode 100644 Task/Queue-Definition/R/queue-definition-3.r create mode 100644 Task/Queue-Definition/REBOL/queue-definition.rebol create mode 100644 Task/Queue-Definition/REXX/queue-definition.rexx create mode 100644 Task/Queue-Definition/Ruby/queue-definition-1.rb create mode 100644 Task/Queue-Definition/Ruby/queue-definition-2.rb create mode 100644 Task/Queue-Definition/Scala/queue-definition-1.scala create mode 100644 Task/Queue-Definition/Scala/queue-definition-2.scala create mode 100644 Task/Queue-Definition/Scheme/queue-definition-1.ss create mode 100644 Task/Queue-Definition/Scheme/queue-definition-2.ss create mode 100644 Task/Queue-Definition/Slate/queue-definition.slate create mode 100644 Task/Queue-Definition/Smalltalk/queue-definition.st create mode 100644 Task/Queue-Definition/Standard-ML/queue-definition-1.ml create mode 100644 Task/Queue-Definition/Standard-ML/queue-definition-2.ml create mode 100644 Task/Queue-Definition/Tcl/queue-definition-1.tcl create mode 100644 Task/Queue-Definition/Tcl/queue-definition-2.tcl create mode 100644 Task/Queue-Definition/UnixPipes/queue-definition-1.unixpipes create mode 100644 Task/Queue-Definition/UnixPipes/queue-definition-2.unixpipes create mode 100644 Task/Queue-Definition/V/queue-definition-1.v create mode 100644 Task/Queue-Definition/V/queue-definition-2.v create mode 100644 Task/Queue-Definition/XPL0/queue-definition.xpl0 create mode 100644 Task/Queue-Usage/0DESCRIPTION create mode 100644 Task/Queue-Usage/1META.yaml create mode 100644 Task/Queue-Usage/Ada/queue-usage.ada create mode 100644 Task/Queue-Usage/AppleScript/queue-usage.applescript create mode 100644 Task/Queue-Usage/AutoHotkey/queue-usage.ahk create mode 100644 Task/Queue-Usage/BBC-BASIC/queue-usage.bbc create mode 100644 Task/Queue-Usage/C++/queue-usage-1.cpp create mode 100644 Task/Queue-Usage/C++/queue-usage-2.cpp create mode 100644 Task/Queue-Usage/C-sharp/queue-usage.cs create mode 100644 Task/Queue-Usage/C/queue-usage.c create mode 100644 Task/Queue-Usage/Clojure/queue-usage-1.clj create mode 100644 Task/Queue-Usage/Clojure/queue-usage-2.clj create mode 100644 Task/Queue-Usage/CoffeeScript/queue-usage-1.coffeescript create mode 100644 Task/Queue-Usage/CoffeeScript/queue-usage-2.coffeescript create mode 100644 Task/Queue-Usage/Common-Lisp/queue-usage.lisp create mode 100644 Task/Queue-Usage/D/queue-usage-1.d create mode 100644 Task/Queue-Usage/D/queue-usage-2.d create mode 100644 Task/Queue-Usage/Delphi/queue-usage.delphi create mode 100644 Task/Queue-Usage/E/queue-usage.e create mode 100644 Task/Queue-Usage/Erlang/queue-usage.erl create mode 100644 Task/Queue-Usage/Fantom/queue-usage.fantom create mode 100644 Task/Queue-Usage/Fortran/queue-usage.f create mode 100644 Task/Queue-Usage/Go/queue-usage-1.go create mode 100644 Task/Queue-Usage/Go/queue-usage-2.go create mode 100644 Task/Queue-Usage/Go/queue-usage-3.go create mode 100644 Task/Queue-Usage/Groovy/queue-usage-1.groovy create mode 100644 Task/Queue-Usage/Groovy/queue-usage-2.groovy create mode 100644 Task/Queue-Usage/Haskell/queue-usage.hs create mode 100644 Task/Queue-Usage/Icon/queue-usage.icon create mode 100644 Task/Queue-Usage/J/queue-usage-1.j create mode 100644 Task/Queue-Usage/J/queue-usage-2.j create mode 100644 Task/Queue-Usage/Java/queue-usage-1.java create mode 100644 Task/Queue-Usage/Java/queue-usage-2.java create mode 100644 Task/Queue-Usage/JavaScript/queue-usage.js create mode 100644 Task/Queue-Usage/Logo/queue-usage.logo create mode 100644 Task/Queue-Usage/Lua/queue-usage.lua create mode 100644 Task/Queue-Usage/Mathematica/queue-usage.math create mode 100644 Task/Queue-Usage/NetRexx/queue-usage.netrexx create mode 100644 Task/Queue-Usage/OCaml/queue-usage.ocaml create mode 100644 Task/Queue-Usage/Objeck/queue-usage.objeck create mode 100644 Task/Queue-Usage/Oz/queue-usage.oz create mode 100644 Task/Queue-Usage/PHP/queue-usage.php create mode 100644 Task/Queue-Usage/PL-I/queue-usage-1.pli create mode 100644 Task/Queue-Usage/PL-I/queue-usage-2.pli create mode 100644 Task/Queue-Usage/Perl-6/queue-usage-1.pl6 create mode 100644 Task/Queue-Usage/Perl-6/queue-usage-2.pl6 create mode 100644 Task/Queue-Usage/Perl/queue-usage-1.pl create mode 100644 Task/Queue-Usage/Perl/queue-usage-2.pl create mode 100644 Task/Queue-Usage/PicoLisp/queue-usage.l create mode 100644 Task/Queue-Usage/PostScript/queue-usage.ps create mode 100644 Task/Queue-Usage/Prolog/queue-usage.pro create mode 100644 Task/Queue-Usage/PureBasic/queue-usage.purebasic create mode 100644 Task/Queue-Usage/Python/queue-usage.py create mode 100644 Task/Queue-Usage/REBOL/queue-usage.rebol create mode 100644 Task/Queue-Usage/REXX/queue-usage.rexx create mode 100644 Task/Queue-Usage/Scala/queue-usage.scala create mode 100644 Task/Queue-Usage/Standard-ML/queue-usage-1.ml create mode 100644 Task/Queue-Usage/Standard-ML/queue-usage-2.ml create mode 100644 Task/Queue-Usage/Tcl/queue-usage.tcl create mode 100644 Task/Queue-Usage/XPL0/queue-usage.xpl0 create mode 100644 Task/RCRPG/0DESCRIPTION create mode 100644 Task/RCRPG/1META.yaml create mode 100644 Task/RIPEMD-160/0DESCRIPTION create mode 100644 Task/RIPEMD-160/1META.yaml create mode 100644 Task/RIPEMD-160/D/ripemd-160.d create mode 100644 Task/RIPEMD-160/Go/ripemd-160.go create mode 100644 Task/RIPEMD-160/Java/ripemd-160.java create mode 100644 Task/RIPEMD-160/Objeck/ripemd-160.objeck create mode 100644 Task/RIPEMD-160/Perl-6/ripemd-160.pl6 create mode 100644 Task/RIPEMD-160/Python/ripemd-160.py create mode 100644 Task/RIPEMD-160/Ruby/ripemd-160-1.rb create mode 100644 Task/RIPEMD-160/Ruby/ripemd-160-2.rb create mode 100644 Task/RIPEMD-160/Ruby/ripemd-160-3.rb create mode 100644 Task/RIPEMD-160/Tcl/ripemd-160.tcl create mode 100644 Task/Random-number-generator--device-/0DESCRIPTION create mode 100644 Task/Random-number-generator--device-/1META.yaml create mode 100644 Task/Random-number-generator--device-/Ada/random-number-generator--device-.ada create mode 100644 Task/Random-number-generator--device-/BBC-BASIC/random-number-generator--device-.bbc create mode 100644 Task/Random-number-generator--device-/C-sharp/random-number-generator--device-.cs create mode 100644 Task/Random-number-generator--device-/C/random-number-generator--device--1.c create mode 100644 Task/Random-number-generator--device-/C/random-number-generator--device--2.c create mode 100644 Task/Random-number-generator--device-/C/random-number-generator--device--3.c create mode 100644 Task/Random-number-generator--device-/C/random-number-generator--device--4.c create mode 100644 Task/Random-number-generator--device-/Forth/random-number-generator--device-.fth create mode 100644 Task/Random-number-generator--device-/Go/random-number-generator--device-.go create mode 100644 Task/Random-number-generator--device-/Groovy/random-number-generator--device--1.groovy create mode 100644 Task/Random-number-generator--device-/Groovy/random-number-generator--device--2.groovy create mode 100644 Task/Random-number-generator--device-/Haskell/random-number-generator--device-.hs create mode 100644 Task/Random-number-generator--device-/J/random-number-generator--device--1.j create mode 100644 Task/Random-number-generator--device-/J/random-number-generator--device--2.j create mode 100644 Task/Random-number-generator--device-/Java/random-number-generator--device-.java create mode 100644 Task/Random-number-generator--device-/NetRexx/random-number-generator--device-.netrexx create mode 100644 Task/Random-number-generator--device-/OCaml/random-number-generator--device--1.ocaml create mode 100644 Task/Random-number-generator--device-/OCaml/random-number-generator--device--2.ocaml create mode 100644 Task/Random-number-generator--device-/Pascal/random-number-generator--device-.pascal create mode 100644 Task/Random-number-generator--device-/Perl-6/random-number-generator--device-.pl6 create mode 100644 Task/Random-number-generator--device-/Perl/random-number-generator--device-.pl create mode 100644 Task/Random-number-generator--device-/PicoLisp/random-number-generator--device-.l create mode 100644 Task/Random-number-generator--device-/ProDOS/random-number-generator--device-.dos create mode 100644 Task/Random-number-generator--device-/PureBasic/random-number-generator--device-.purebasic create mode 100644 Task/Random-number-generator--device-/Python/random-number-generator--device-.py create mode 100644 Task/Random-number-generator--device-/REXX/random-number-generator--device-.rexx create mode 100644 Task/Random-number-generator--device-/Ruby/random-number-generator--device-.rb create mode 100644 Task/Random-number-generator--device-/Tcl/random-number-generator--device--1.tcl create mode 100644 Task/Random-number-generator--device-/Tcl/random-number-generator--device--2.tcl create mode 100644 Task/Random-number-generator--device-/XPL0/random-number-generator--device-.xpl0 create mode 100644 Task/Random-number-generator--included-/0DESCRIPTION create mode 100644 Task/Random-number-generator--included-/ALGOL-68/random-number-generator--included--1.alg create mode 100644 Task/Random-number-generator--included-/ALGOL-68/random-number-generator--included--2.alg create mode 100644 Task/Random-number-generator--included-/C/random-number-generator--included-.c create mode 100644 Task/Random-number-generator--included-/CMake/random-number-generator--included-.cmake create mode 100644 Task/Random-number-generator--included-/Deja-Vu/random-number-generator--included-.djv create mode 100644 Task/Random-number-generator--included-/Erlang/random-number-generator--included--1.erl create mode 100644 Task/Random-number-generator--included-/Erlang/random-number-generator--included--2.erl create mode 100644 Task/Random-number-generator--included-/Erlang/random-number-generator--included--3.erl create mode 100644 Task/Random-number-generator--included-/Erlang/random-number-generator--included--4.erl create mode 100644 Task/Random-number-generator--included-/GAP/random-number-generator--included--1.gap create mode 100644 Task/Random-number-generator--included-/GAP/random-number-generator--included--2.gap create mode 100644 Task/Random-number-generator--included-/PARI-GP/random-number-generator--included-.pari create mode 100644 Task/Random-number-generator--included-/PL-I/random-number-generator--included-.pli create mode 100644 Task/Random-number-generator--included-/PL-SQL/random-number-generator--included--1.sql create mode 100644 Task/Random-number-generator--included-/PL-SQL/random-number-generator--included--2.sql create mode 100644 Task/Random-number-generator--included-/R/random-number-generator--included-.r create mode 100644 Task/Random-number-generator--included-/Rascal/random-number-generator--included--1.rascal create mode 100644 Task/Random-number-generator--included-/Rascal/random-number-generator--included--2.rascal create mode 100644 Task/Random-number-generator--included-/Run-BASIC/random-number-generator--included-.run create mode 100644 Task/Random-number-generator--included-/UNIX-Shell/random-number-generator--included-.sh create mode 100644 Task/Random-number-generator--included-/XPL0/random-number-generator--included-.xpl0 create mode 100644 Task/Random-numbers/0DESCRIPTION create mode 100644 Task/Random-numbers/1META.yaml create mode 100644 Task/Random-numbers/ALGOL-68/random-numbers.alg create mode 100644 Task/Random-numbers/AWK/random-numbers.awk create mode 100644 Task/Random-numbers/Ada/random-numbers.ada create mode 100644 Task/Random-numbers/AutoHotkey/random-numbers.ahk create mode 100644 Task/Random-numbers/BBC-BASIC/random-numbers.bbc create mode 100644 Task/Random-numbers/C++/random-numbers-1.cpp create mode 100644 Task/Random-numbers/C++/random-numbers-2.cpp create mode 100644 Task/Random-numbers/C++/random-numbers-3.cpp create mode 100644 Task/Random-numbers/C-sharp/random-numbers-1.cs create mode 100644 Task/Random-numbers/C-sharp/random-numbers-2.cs create mode 100644 Task/Random-numbers/C/random-numbers.c create mode 100644 Task/Random-numbers/Clojure/random-numbers.clj create mode 100644 Task/Random-numbers/Common-Lisp/random-numbers.lisp create mode 100644 Task/Random-numbers/D/random-numbers-1.d create mode 100644 Task/Random-numbers/D/random-numbers-2.d create mode 100644 Task/Random-numbers/DWScript/random-numbers.dwscript create mode 100644 Task/Random-numbers/Delphi/random-numbers.delphi create mode 100644 Task/Random-numbers/E/random-numbers.e create mode 100644 Task/Random-numbers/Eiffel/random-numbers.e create mode 100644 Task/Random-numbers/Erlang/random-numbers.erl create mode 100644 Task/Random-numbers/Euler-Math-Toolbox/random-numbers.euler create mode 100644 Task/Random-numbers/Euphoria/random-numbers.euphoria create mode 100644 Task/Random-numbers/Factor/random-numbers.factor create mode 100644 Task/Random-numbers/Fantom/random-numbers-1.fantom create mode 100644 Task/Random-numbers/Fantom/random-numbers-2.fantom create mode 100644 Task/Random-numbers/Forth/random-numbers.fth create mode 100644 Task/Random-numbers/Fortran/random-numbers.f create mode 100644 Task/Random-numbers/Go/random-numbers.go create mode 100644 Task/Random-numbers/Groovy/random-numbers.groovy create mode 100644 Task/Random-numbers/Haskell/random-numbers.hs create mode 100644 Task/Random-numbers/HicEst/random-numbers.hicest create mode 100644 Task/Random-numbers/IDL/random-numbers.idl create mode 100644 Task/Random-numbers/Icon/random-numbers.icon create mode 100644 Task/Random-numbers/J/random-numbers-1.j create mode 100644 Task/Random-numbers/J/random-numbers-2.j create mode 100644 Task/Random-numbers/Java/random-numbers.java create mode 100644 Task/Random-numbers/JavaScript/random-numbers.js create mode 100644 Task/Random-numbers/Liberty-BASIC/random-numbers.liberty create mode 100644 Task/Random-numbers/Logo/random-numbers.logo create mode 100644 Task/Random-numbers/MATLAB/random-numbers-1.m create mode 100644 Task/Random-numbers/MATLAB/random-numbers-2.m create mode 100644 Task/Random-numbers/MATLAB/random-numbers-3.m create mode 100644 Task/Random-numbers/MATLAB/random-numbers-4.m create mode 100644 Task/Random-numbers/MAXScript/random-numbers.maxscript create mode 100644 Task/Random-numbers/Mathematica/random-numbers.math create mode 100644 Task/Random-numbers/Maxima/random-numbers.maxima create mode 100644 Task/Random-numbers/Metafont/random-numbers.metafont create mode 100644 Task/Random-numbers/Mirah/random-numbers.mirah create mode 100644 Task/Random-numbers/Modula-3/random-numbers.mod3 create mode 100644 Task/Random-numbers/NetRexx/random-numbers.netrexx create mode 100644 Task/Random-numbers/NewLISP/random-numbers.newlisp create mode 100644 Task/Random-numbers/OCaml/random-numbers.ocaml create mode 100644 Task/Random-numbers/Objeck/random-numbers.objeck create mode 100644 Task/Random-numbers/Octave/random-numbers.octave create mode 100644 Task/Random-numbers/PARI-GP/random-numbers.pari create mode 100644 Task/Random-numbers/PHP/random-numbers.php create mode 100644 Task/Random-numbers/PL-I/random-numbers.pli create mode 100644 Task/Random-numbers/PL-SQL/random-numbers.sql create mode 100644 Task/Random-numbers/Perl-6/random-numbers.pl6 create mode 100644 Task/Random-numbers/Perl/random-numbers.pl create mode 100644 Task/Random-numbers/PicoLisp/random-numbers.l create mode 100644 Task/Random-numbers/Pop11/random-numbers.pop11 create mode 100644 Task/Random-numbers/PureBasic/random-numbers.purebasic create mode 100644 Task/Random-numbers/Python/random-numbers-1.py create mode 100644 Task/Random-numbers/Python/random-numbers-2.py create mode 100644 Task/Random-numbers/R/random-numbers.r create mode 100644 Task/Random-numbers/REXX/random-numbers.rexx create mode 100644 Task/Random-numbers/Ruby/random-numbers.rb create mode 100644 Task/Random-numbers/Run-BASIC/random-numbers.run create mode 100644 Task/Random-numbers/Sather/random-numbers.sa create mode 100644 Task/Random-numbers/Scala/random-numbers.scala create mode 100644 Task/Random-numbers/Scheme/random-numbers.ss create mode 100644 Task/Random-numbers/Seed7/random-numbers.seed7 create mode 100644 Task/Random-numbers/Standard-ML/random-numbers-1.ml create mode 100644 Task/Random-numbers/Standard-ML/random-numbers-2.ml create mode 100644 Task/Random-numbers/Tcl/random-numbers.tcl create mode 100644 Task/Random-numbers/Ursala/random-numbers.ursala create mode 100644 Task/Random-numbers/Yorick/random-numbers.yorick create mode 100644 Task/Random-numbers/ZX-Spectrum-Basic/random-numbers.zx create mode 100644 Task/Range-expansion/0DESCRIPTION create mode 100644 Task/Range-expansion/ALGOL-68/range-expansion.alg create mode 100644 Task/Range-expansion/Ada/range-expansion.ada create mode 100644 Task/Range-expansion/AutoHotkey/range-expansion.ahk create mode 100644 Task/Range-expansion/BBC-BASIC/range-expansion.bbc create mode 100644 Task/Range-expansion/Bracmat/range-expansion.bracmat create mode 100644 Task/Range-expansion/C++/range-expansion.cpp create mode 100644 Task/Range-expansion/C/range-expansion.c create mode 100644 Task/Range-expansion/Clojure/range-expansion.clj create mode 100644 Task/Range-expansion/Common-Lisp/range-expansion.lisp create mode 100644 Task/Range-expansion/D/range-expansion.d create mode 100644 Task/Range-expansion/Go/range-expansion.go create mode 100644 Task/Range-expansion/Groovy/range-expansion-1.groovy create mode 100644 Task/Range-expansion/Groovy/range-expansion-2.groovy create mode 100644 Task/Range-expansion/Haskell/range-expansion-1.hs create mode 100644 Task/Range-expansion/Haskell/range-expansion-2.hs create mode 100644 Task/Range-expansion/Haskell/range-expansion-3.hs create mode 100644 Task/Range-expansion/Icon/range-expansion.icon create mode 100644 Task/Range-expansion/J/range-expansion-1.j create mode 100644 Task/Range-expansion/J/range-expansion-2.j create mode 100644 Task/Range-expansion/Java/range-expansion.java create mode 100644 Task/Range-expansion/JavaScript/range-expansion.js create mode 100644 Task/Range-expansion/K/range-expansion-1.k create mode 100644 Task/Range-expansion/K/range-expansion-2.k create mode 100644 Task/Range-expansion/Liberty-BASIC/range-expansion.liberty create mode 100644 Task/Range-expansion/MUMPS/range-expansion.mumps create mode 100644 Task/Range-expansion/Maple/range-expansion-1.maple create mode 100644 Task/Range-expansion/Maple/range-expansion-2.maple create mode 100644 Task/Range-expansion/Maple/range-expansion-3.maple create mode 100644 Task/Range-expansion/Mathematica/range-expansion.math create mode 100644 Task/Range-expansion/NetRexx/range-expansion.netrexx create mode 100644 Task/Range-expansion/OCaml/range-expansion.ocaml create mode 100644 Task/Range-expansion/Oberon-2/range-expansion.oberon-2 create mode 100644 Task/Range-expansion/Oz/range-expansion-1.oz create mode 100644 Task/Range-expansion/Oz/range-expansion-2.oz create mode 100644 Task/Range-expansion/PHP/range-expansion.php create mode 100644 Task/Range-expansion/PL-I/range-expansion.pli create mode 100644 Task/Range-expansion/Perl-6/range-expansion.pl6 create mode 100644 Task/Range-expansion/Perl/range-expansion-1.pl create mode 100644 Task/Range-expansion/Perl/range-expansion-2.pl create mode 100644 Task/Range-expansion/PicoLisp/range-expansion.l create mode 100644 Task/Range-expansion/Prolog/range-expansion.pro create mode 100644 Task/Range-expansion/PureBasic/range-expansion.purebasic create mode 100644 Task/Range-expansion/Python/range-expansion-1.py create mode 100644 Task/Range-expansion/Python/range-expansion-2.py create mode 100644 Task/Range-expansion/R/range-expansion-1.r create mode 100644 Task/Range-expansion/R/range-expansion-2.r create mode 100644 Task/Range-expansion/REXX/range-expansion-1.rexx create mode 100644 Task/Range-expansion/REXX/range-expansion-2.rexx create mode 100644 Task/Range-expansion/Racket/range-expansion-1.rkt create mode 100644 Task/Range-expansion/Racket/range-expansion-2.rkt create mode 100644 Task/Range-expansion/Ruby/range-expansion.rb create mode 100644 Task/Range-expansion/Run-BASIC/range-expansion.run create mode 100644 Task/Range-expansion/SNOBOL4/range-expansion.sno create mode 100644 Task/Range-expansion/Scala/range-expansion.scala create mode 100644 Task/Range-expansion/Scheme/range-expansion.ss create mode 100644 Task/Range-expansion/Seed7/range-expansion.seed7 create mode 100644 Task/Range-expansion/TUSCRIPT/range-expansion.tuscript create mode 100644 Task/Range-expansion/Tcl/range-expansion.tcl create mode 100644 Task/Range-expansion/Ursala/range-expansion.ursala create mode 100644 Task/Range-expansion/VBA/range-expansion.vba create mode 100644 Task/Range-expansion/XPL0/range-expansion.xpl0 create mode 100644 Task/Range-extraction/0DESCRIPTION create mode 100644 Task/Range-extraction/ALGOL-68/range-extraction-1.alg create mode 100644 Task/Range-extraction/ALGOL-68/range-extraction-2.alg create mode 100644 Task/Range-extraction/ALGOL-68/range-extraction-3.alg create mode 100644 Task/Range-extraction/ALGOL-68/range-extraction-4.alg create mode 100644 Task/Range-extraction/AWK/range-extraction.awk create mode 100644 Task/Range-extraction/Ada/range-extraction-1.ada create mode 100644 Task/Range-extraction/Ada/range-extraction-2.ada create mode 100644 Task/Range-extraction/Aime/range-extraction.aime create mode 100644 Task/Range-extraction/AutoHotkey/range-extraction.ahk create mode 100644 Task/Range-extraction/BBC-BASIC/range-extraction.bbc create mode 100644 Task/Range-extraction/Bracmat/range-extraction.bracmat create mode 100644 Task/Range-extraction/C++/range-extraction.cpp create mode 100644 Task/Range-extraction/C-sharp/range-extraction.cs create mode 100644 Task/Range-extraction/C/range-extraction-1.c create mode 100644 Task/Range-extraction/C/range-extraction-2.c create mode 100644 Task/Range-extraction/Common-Lisp/range-extraction.lisp create mode 100644 Task/Range-extraction/D/range-extraction.d create mode 100644 Task/Range-extraction/DWScript/range-extraction.dwscript create mode 100644 Task/Range-extraction/E/range-extraction-1.e create mode 100644 Task/Range-extraction/E/range-extraction-2.e create mode 100644 Task/Range-extraction/Euphoria/range-extraction.euphoria create mode 100644 Task/Range-extraction/Forth/range-extraction.fth create mode 100644 Task/Range-extraction/Go/range-extraction.go create mode 100644 Task/Range-extraction/Groovy/range-extraction-1.groovy create mode 100644 Task/Range-extraction/Groovy/range-extraction-2.groovy create mode 100644 Task/Range-extraction/Haskell/range-extraction-1.hs create mode 100644 Task/Range-extraction/Haskell/range-extraction-2.hs create mode 100644 Task/Range-extraction/Icon/range-extraction.icon create mode 100644 Task/Range-extraction/J/range-extraction-1.j create mode 100644 Task/Range-extraction/J/range-extraction-2.j create mode 100644 Task/Range-extraction/Java/range-extraction.java create mode 100644 Task/Range-extraction/JavaScript/range-extraction.js create mode 100644 Task/Range-extraction/K/range-extraction-1.k create mode 100644 Task/Range-extraction/K/range-extraction-2.k create mode 100644 Task/Range-extraction/Liberty-BASIC/range-extraction.liberty create mode 100644 Task/Range-extraction/MUMPS/range-extraction.mumps create mode 100644 Task/Range-extraction/Mathematica/range-extraction.math create mode 100644 Task/Range-extraction/NetRexx/range-extraction.netrexx create mode 100644 Task/Range-extraction/OCaml/range-extraction.ocaml create mode 100644 Task/Range-extraction/Oberon-2/range-extraction.oberon-2 create mode 100644 Task/Range-extraction/OxygenBasic/range-extraction.oxy create mode 100644 Task/Range-extraction/Oz/range-extraction-1.oz create mode 100644 Task/Range-extraction/Oz/range-extraction-2.oz create mode 100644 Task/Range-extraction/PL-I/range-extraction-1.pli create mode 100644 Task/Range-extraction/PL-I/range-extraction-2.pli create mode 100644 Task/Range-extraction/PL-I/range-extraction-3.pli create mode 100644 Task/Range-extraction/Perl-6/range-extraction.pl6 create mode 100644 Task/Range-extraction/Perl/range-extraction.pl create mode 100644 Task/Range-extraction/PicoLisp/range-extraction.l create mode 100644 Task/Range-extraction/Prolog/range-extraction.pro create mode 100644 Task/Range-extraction/PureBasic/range-extraction.purebasic create mode 100644 Task/Range-extraction/Python/range-extraction-1.py create mode 100644 Task/Range-extraction/Python/range-extraction-2.py create mode 100644 Task/Range-extraction/Qi/range-extraction.qi create mode 100644 Task/Range-extraction/REXX/range-extraction-1.rexx create mode 100644 Task/Range-extraction/REXX/range-extraction-2.rexx create mode 100644 Task/Range-extraction/Ruby/range-extraction.rb create mode 100644 Task/Range-extraction/SNOBOL4/range-extraction.sno create mode 100644 Task/Range-extraction/Scala/range-extraction.scala create mode 100644 Task/Range-extraction/Scheme/range-extraction.ss create mode 100644 Task/Range-extraction/Seed7/range-extraction.seed7 create mode 100644 Task/Range-extraction/TUSCRIPT/range-extraction-1.tuscript create mode 100644 Task/Range-extraction/TUSCRIPT/range-extraction-2.tuscript create mode 100644 Task/Range-extraction/Tcl/range-extraction.tcl create mode 100644 Task/Range-extraction/Ursala/range-extraction.ursala create mode 100644 Task/Range-extraction/VBA/range-extraction.vba create mode 100644 Task/Rate-counter/0DESCRIPTION create mode 100644 Task/Rate-counter/Ada/rate-counter.ada create mode 100644 Task/Rate-counter/BBC-BASIC/rate-counter.bbc create mode 100644 Task/Rate-counter/C++/rate-counter.cpp create mode 100644 Task/Rate-counter/C/rate-counter.c create mode 100644 Task/Rate-counter/Common-Lisp/rate-counter-1.lisp create mode 100644 Task/Rate-counter/Common-Lisp/rate-counter-2.lisp create mode 100644 Task/Rate-counter/Common-Lisp/rate-counter-3.lisp create mode 100644 Task/Rate-counter/Common-Lisp/rate-counter-4.lisp create mode 100644 Task/Rate-counter/E/rate-counter-1.e create mode 100644 Task/Rate-counter/E/rate-counter-2.e create mode 100644 Task/Rate-counter/Go/rate-counter.go create mode 100644 Task/Rate-counter/HicEst/rate-counter.hicest create mode 100644 Task/Rate-counter/J/rate-counter-1.j create mode 100644 Task/Rate-counter/J/rate-counter-2.j create mode 100644 Task/Rate-counter/J/rate-counter-3.j create mode 100644 Task/Rate-counter/JavaScript/rate-counter.js create mode 100644 Task/Rate-counter/Liberty-BASIC/rate-counter.liberty create mode 100644 Task/Rate-counter/OxygenBasic/rate-counter.oxy create mode 100644 Task/Rate-counter/PARI-GP/rate-counter.pari create mode 100644 Task/Rate-counter/Perl-6/rate-counter.pl6 create mode 100644 Task/Rate-counter/Perl/rate-counter.pl create mode 100644 Task/Rate-counter/PicoLisp/rate-counter-1.l create mode 100644 Task/Rate-counter/PicoLisp/rate-counter-2.l create mode 100644 Task/Rate-counter/PureBasic/rate-counter-1.purebasic create mode 100644 Task/Rate-counter/PureBasic/rate-counter-2.purebasic create mode 100644 Task/Rate-counter/Python/rate-counter.py create mode 100644 Task/Rate-counter/REXX/rate-counter.rexx create mode 100644 Task/Rate-counter/Run-BASIC/rate-counter.run create mode 100644 Task/Rate-counter/Scala/rate-counter-1.scala create mode 100644 Task/Rate-counter/Scala/rate-counter-2.scala create mode 100644 Task/Rate-counter/Smalltalk/rate-counter.st create mode 100644 Task/Rate-counter/Tcl/rate-counter-1.tcl create mode 100644 Task/Rate-counter/Tcl/rate-counter-2.tcl create mode 100644 Task/Rate-counter/UNIX-Shell/rate-counter-1.sh create mode 100644 Task/Rate-counter/UNIX-Shell/rate-counter-2.sh create mode 100644 Task/Rate-counter/XPL0/rate-counter.xpl0 create mode 100644 Task/Ray-casting-algorithm/0DESCRIPTION create mode 100644 Task/Ray-casting-algorithm/1META.yaml create mode 100644 Task/Ray-casting-algorithm/Ada/ray-casting-algorithm-1.ada create mode 100644 Task/Ray-casting-algorithm/Ada/ray-casting-algorithm-2.ada create mode 100644 Task/Ray-casting-algorithm/Ada/ray-casting-algorithm-3.ada create mode 100644 Task/Ray-casting-algorithm/AutoHotkey/ray-casting-algorithm.ahk create mode 100644 Task/Ray-casting-algorithm/C/ray-casting-algorithm.c create mode 100644 Task/Ray-casting-algorithm/CoffeeScript/ray-casting-algorithm.coffeescript create mode 100644 Task/Ray-casting-algorithm/Common-Lisp/ray-casting-algorithm-1.lisp create mode 100644 Task/Ray-casting-algorithm/Common-Lisp/ray-casting-algorithm-2.lisp create mode 100644 Task/Ray-casting-algorithm/D/ray-casting-algorithm.d create mode 100644 Task/Ray-casting-algorithm/Factor/ray-casting-algorithm-1.factor create mode 100644 Task/Ray-casting-algorithm/Factor/ray-casting-algorithm-2.factor create mode 100644 Task/Ray-casting-algorithm/Fortran/ray-casting-algorithm-1.f create mode 100644 Task/Ray-casting-algorithm/Fortran/ray-casting-algorithm-2.f create mode 100644 Task/Ray-casting-algorithm/Fortran/ray-casting-algorithm-3.f create mode 100644 Task/Ray-casting-algorithm/Go/ray-casting-algorithm-1.go create mode 100644 Task/Ray-casting-algorithm/Go/ray-casting-algorithm-2.go create mode 100644 Task/Ray-casting-algorithm/Haskell/ray-casting-algorithm.hs create mode 100644 Task/Ray-casting-algorithm/J/ray-casting-algorithm-1.j create mode 100644 Task/Ray-casting-algorithm/J/ray-casting-algorithm-2.j create mode 100644 Task/Ray-casting-algorithm/J/ray-casting-algorithm-3.j create mode 100644 Task/Ray-casting-algorithm/Liberty-BASIC/ray-casting-algorithm.liberty create mode 100644 Task/Ray-casting-algorithm/OCaml/ray-casting-algorithm.ocaml create mode 100644 Task/Ray-casting-algorithm/Perl-6/ray-casting-algorithm.pl6 create mode 100644 Task/Ray-casting-algorithm/Perl/ray-casting-algorithm-1.pl create mode 100644 Task/Ray-casting-algorithm/Perl/ray-casting-algorithm-2.pl create mode 100644 Task/Ray-casting-algorithm/PicoLisp/ray-casting-algorithm.l create mode 100644 Task/Ray-casting-algorithm/PureBasic/ray-casting-algorithm.purebasic create mode 100644 Task/Ray-casting-algorithm/Python/ray-casting-algorithm-1.py create mode 100644 Task/Ray-casting-algorithm/Python/ray-casting-algorithm-2.py create mode 100644 Task/Ray-casting-algorithm/R/ray-casting-algorithm-1.r create mode 100644 Task/Ray-casting-algorithm/R/ray-casting-algorithm-2.r create mode 100644 Task/Ray-casting-algorithm/R/ray-casting-algorithm-3.r create mode 100644 Task/Ray-casting-algorithm/REXX/ray-casting-algorithm.rexx create mode 100644 Task/Ray-casting-algorithm/Racket/ray-casting-algorithm-1.rkt create mode 100644 Task/Ray-casting-algorithm/Racket/ray-casting-algorithm-2.rkt create mode 100644 Task/Ray-casting-algorithm/Smalltalk/ray-casting-algorithm-1.st create mode 100644 Task/Ray-casting-algorithm/Smalltalk/ray-casting-algorithm-2.st create mode 100644 Task/Ray-casting-algorithm/Tcl/ray-casting-algorithm.tcl create mode 100644 Task/Ray-casting-algorithm/Ursala/ray-casting-algorithm-1.ursala create mode 100644 Task/Ray-casting-algorithm/Ursala/ray-casting-algorithm-2.ursala create mode 100644 Task/Read-a-configuration-file/0DESCRIPTION create mode 100644 Task/Read-a-configuration-file/1META.yaml create mode 100644 Task/Read-a-configuration-file/Ada/read-a-configuration-file-1.ada create mode 100644 Task/Read-a-configuration-file/Ada/read-a-configuration-file-2.ada create mode 100644 Task/Read-a-configuration-file/AutoHotkey/read-a-configuration-file.ahk create mode 100644 Task/Read-a-configuration-file/BBC-BASIC/read-a-configuration-file.bbc create mode 100644 Task/Read-a-configuration-file/C++/read-a-configuration-file-1.cpp create mode 100644 Task/Read-a-configuration-file/C++/read-a-configuration-file-2.cpp create mode 100644 Task/Read-a-configuration-file/D/read-a-configuration-file.d create mode 100644 Task/Read-a-configuration-file/Fantom/read-a-configuration-file.fantom create mode 100644 Task/Read-a-configuration-file/Go/read-a-configuration-file-1.go create mode 100644 Task/Read-a-configuration-file/Go/read-a-configuration-file-2.go create mode 100644 Task/Read-a-configuration-file/Haskell/read-a-configuration-file-1.hs create mode 100644 Task/Read-a-configuration-file/Haskell/read-a-configuration-file-2.hs create mode 100644 Task/Read-a-configuration-file/J/read-a-configuration-file-1.j create mode 100644 Task/Read-a-configuration-file/J/read-a-configuration-file-2.j create mode 100644 Task/Read-a-configuration-file/Liberty-BASIC/read-a-configuration-file.liberty create mode 100644 Task/Read-a-configuration-file/Lua/read-a-configuration-file.lua create mode 100644 Task/Read-a-configuration-file/MATLAB/read-a-configuration-file.m create mode 100644 Task/Read-a-configuration-file/OCaml/read-a-configuration-file.ocaml create mode 100644 Task/Read-a-configuration-file/PL-I/read-a-configuration-file.pli create mode 100644 Task/Read-a-configuration-file/Pascal/read-a-configuration-file.pascal create mode 100644 Task/Read-a-configuration-file/Perl-6/read-a-configuration-file.pl6 create mode 100644 Task/Read-a-configuration-file/Perl/read-a-configuration-file.pl create mode 100644 Task/Read-a-configuration-file/PicoLisp/read-a-configuration-file-1.l create mode 100644 Task/Read-a-configuration-file/PicoLisp/read-a-configuration-file-2.l create mode 100644 Task/Read-a-configuration-file/Protium/read-a-configuration-file.protium create mode 100644 Task/Read-a-configuration-file/Python/read-a-configuration-file.py create mode 100644 Task/Read-a-configuration-file/REXX/read-a-configuration-file-1.rexx create mode 100644 Task/Read-a-configuration-file/REXX/read-a-configuration-file-2.rexx create mode 100644 Task/Read-a-configuration-file/Ruby/read-a-configuration-file.rb create mode 100644 Task/Read-a-configuration-file/Seed7/read-a-configuration-file.seed7 create mode 100644 Task/Read-a-configuration-file/Smalltalk/read-a-configuration-file-1.st create mode 100644 Task/Read-a-configuration-file/Smalltalk/read-a-configuration-file-2.st create mode 100644 Task/Read-a-configuration-file/Smalltalk/read-a-configuration-file-3.st create mode 100644 Task/Read-a-configuration-file/TXR/read-a-configuration-file.txr create mode 100644 Task/Read-a-configuration-file/Tcl/read-a-configuration-file.tcl create mode 100644 Task/Read-a-configuration-file/Vedit-macro-language/read-a-configuration-file.vedit create mode 100644 Task/Read-a-configuration-file/Visual-Basic/read-a-configuration-file.vb create mode 100644 Task/Read-a-file-line-by-line/0DESCRIPTION create mode 100644 Task/Read-a-file-line-by-line/1META.yaml create mode 100644 Task/Read-a-file-line-by-line/ALGOL-68/read-a-file-line-by-line.alg create mode 100644 Task/Read-a-file-line-by-line/AWK/read-a-file-line-by-line.awk create mode 100644 Task/Read-a-file-line-by-line/Ada/read-a-file-line-by-line.ada create mode 100644 Task/Read-a-file-line-by-line/Aime/read-a-file-line-by-line.aime create mode 100644 Task/Read-a-file-line-by-line/AutoHotkey/read-a-file-line-by-line.ahk create mode 100644 Task/Read-a-file-line-by-line/BASIC/read-a-file-line-by-line-1.basic create mode 100644 Task/Read-a-file-line-by-line/BASIC/read-a-file-line-by-line-2.basic create mode 100644 Task/Read-a-file-line-by-line/BBC-BASIC/read-a-file-line-by-line-1.bbc create mode 100644 Task/Read-a-file-line-by-line/BBC-BASIC/read-a-file-line-by-line-2.bbc create mode 100644 Task/Read-a-file-line-by-line/Brat/read-a-file-line-by-line.brat create mode 100644 Task/Read-a-file-line-by-line/C++/read-a-file-line-by-line-1.cpp create mode 100644 Task/Read-a-file-line-by-line/C++/read-a-file-line-by-line-2.cpp create mode 100644 Task/Read-a-file-line-by-line/C-sharp/read-a-file-line-by-line-1.cs create mode 100644 Task/Read-a-file-line-by-line/C-sharp/read-a-file-line-by-line-2.cs create mode 100644 Task/Read-a-file-line-by-line/C/read-a-file-line-by-line-1.c create mode 100644 Task/Read-a-file-line-by-line/C/read-a-file-line-by-line-2.c create mode 100644 Task/Read-a-file-line-by-line/C/read-a-file-line-by-line-3.c create mode 100644 Task/Read-a-file-line-by-line/Clojure/read-a-file-line-by-line.clj create mode 100644 Task/Read-a-file-line-by-line/CoffeeScript/read-a-file-line-by-line.coffeescript create mode 100644 Task/Read-a-file-line-by-line/Common-Lisp/read-a-file-line-by-line.lisp create mode 100644 Task/Read-a-file-line-by-line/D/read-a-file-line-by-line.d create mode 100644 Task/Read-a-file-line-by-line/Delphi/read-a-file-line-by-line-1.delphi create mode 100644 Task/Read-a-file-line-by-line/Delphi/read-a-file-line-by-line-2.delphi create mode 100644 Task/Read-a-file-line-by-line/Euphoria/read-a-file-line-by-line.euphoria create mode 100644 Task/Read-a-file-line-by-line/Factor/read-a-file-line-by-line.factor create mode 100644 Task/Read-a-file-line-by-line/Fantom/read-a-file-line-by-line.fantom create mode 100644 Task/Read-a-file-line-by-line/Forth/read-a-file-line-by-line.fth create mode 100644 Task/Read-a-file-line-by-line/Frink/read-a-file-line-by-line.frink create mode 100644 Task/Read-a-file-line-by-line/GAP/read-a-file-line-by-line.gap create mode 100644 Task/Read-a-file-line-by-line/Go/read-a-file-line-by-line-1.go create mode 100644 Task/Read-a-file-line-by-line/Go/read-a-file-line-by-line-2.go create mode 100644 Task/Read-a-file-line-by-line/Groovy/read-a-file-line-by-line-1.groovy create mode 100644 Task/Read-a-file-line-by-line/Groovy/read-a-file-line-by-line-2.groovy create mode 100644 Task/Read-a-file-line-by-line/Groovy/read-a-file-line-by-line-3.groovy create mode 100644 Task/Read-a-file-line-by-line/J/read-a-file-line-by-line-1.j create mode 100644 Task/Read-a-file-line-by-line/J/read-a-file-line-by-line-2.j create mode 100644 Task/Read-a-file-line-by-line/Java/read-a-file-line-by-line-1.java create mode 100644 Task/Read-a-file-line-by-line/Java/read-a-file-line-by-line-2.java create mode 100644 Task/Read-a-file-line-by-line/Java/read-a-file-line-by-line-3.java create mode 100644 Task/Read-a-file-line-by-line/Julia/read-a-file-line-by-line.julia create mode 100644 Task/Read-a-file-line-by-line/Liberty-BASIC/read-a-file-line-by-line-1.liberty create mode 100644 Task/Read-a-file-line-by-line/Liberty-BASIC/read-a-file-line-by-line-2.liberty create mode 100644 Task/Read-a-file-line-by-line/Liberty-BASIC/read-a-file-line-by-line-3.liberty create mode 100644 Task/Read-a-file-line-by-line/Logo/read-a-file-line-by-line.logo create mode 100644 Task/Read-a-file-line-by-line/Lua/read-a-file-line-by-line.lua create mode 100644 Task/Read-a-file-line-by-line/MATLAB/read-a-file-line-by-line.m create mode 100644 Task/Read-a-file-line-by-line/Mathematica/read-a-file-line-by-line.math create mode 100644 Task/Read-a-file-line-by-line/Maxima/read-a-file-line-by-line.maxima create mode 100644 Task/Read-a-file-line-by-line/NetRexx/read-a-file-line-by-line-1.netrexx create mode 100644 Task/Read-a-file-line-by-line/NetRexx/read-a-file-line-by-line-2.netrexx create mode 100644 Task/Read-a-file-line-by-line/NewLISP/read-a-file-line-by-line.newlisp create mode 100644 Task/Read-a-file-line-by-line/OCaml/read-a-file-line-by-line.ocaml create mode 100644 Task/Read-a-file-line-by-line/Objeck/read-a-file-line-by-line.objeck create mode 100644 Task/Read-a-file-line-by-line/Objective-C/read-a-file-line-by-line-1.m create mode 100644 Task/Read-a-file-line-by-line/Objective-C/read-a-file-line-by-line-2.m create mode 100644 Task/Read-a-file-line-by-line/OxygenBasic/read-a-file-line-by-line.oxy create mode 100644 Task/Read-a-file-line-by-line/PARI-GP/read-a-file-line-by-line.pari create mode 100644 Task/Read-a-file-line-by-line/PHP/read-a-file-line-by-line.php create mode 100644 Task/Read-a-file-line-by-line/PL-I/read-a-file-line-by-line.pli create mode 100644 Task/Read-a-file-line-by-line/Perl-6/read-a-file-line-by-line-1.pl6 create mode 100644 Task/Read-a-file-line-by-line/Perl-6/read-a-file-line-by-line-2.pl6 create mode 100644 Task/Read-a-file-line-by-line/Perl/read-a-file-line-by-line-1.pl create mode 100644 Task/Read-a-file-line-by-line/Perl/read-a-file-line-by-line-2.pl create mode 100644 Task/Read-a-file-line-by-line/Perl/read-a-file-line-by-line-3.pl create mode 100644 Task/Read-a-file-line-by-line/PicoLisp/read-a-file-line-by-line.l create mode 100644 Task/Read-a-file-line-by-line/PureBasic/read-a-file-line-by-line.purebasic create mode 100644 Task/Read-a-file-line-by-line/Python/read-a-file-line-by-line-1.py create mode 100644 Task/Read-a-file-line-by-line/Python/read-a-file-line-by-line-2.py create mode 100644 Task/Read-a-file-line-by-line/R/read-a-file-line-by-line.r create mode 100644 Task/Read-a-file-line-by-line/REXX/read-a-file-line-by-line.rexx create mode 100644 Task/Read-a-file-line-by-line/Racket/read-a-file-line-by-line.rkt create mode 100644 Task/Read-a-file-line-by-line/Ruby/read-a-file-line-by-line-1.rb create mode 100644 Task/Read-a-file-line-by-line/Ruby/read-a-file-line-by-line-2.rb create mode 100644 Task/Read-a-file-line-by-line/Ruby/read-a-file-line-by-line-3.rb create mode 100644 Task/Read-a-file-line-by-line/Ruby/read-a-file-line-by-line-4.rb create mode 100644 Task/Read-a-file-line-by-line/Run-BASIC/read-a-file-line-by-line.run create mode 100644 Task/Read-a-file-line-by-line/SNOBOL4/read-a-file-line-by-line.sno create mode 100644 Task/Read-a-file-line-by-line/Scala/read-a-file-line-by-line.scala create mode 100644 Task/Read-a-file-line-by-line/Scheme/read-a-file-line-by-line.ss create mode 100644 Task/Read-a-file-line-by-line/Sed/read-a-file-line-by-line-1.sed create mode 100644 Task/Read-a-file-line-by-line/Sed/read-a-file-line-by-line-2.sed create mode 100644 Task/Read-a-file-line-by-line/Seed7/read-a-file-line-by-line.seed7 create mode 100644 Task/Read-a-file-line-by-line/Smalltalk/read-a-file-line-by-line-1.st create mode 100644 Task/Read-a-file-line-by-line/Smalltalk/read-a-file-line-by-line-2.st create mode 100644 Task/Read-a-file-line-by-line/Smalltalk/read-a-file-line-by-line-3.st create mode 100644 Task/Read-a-file-line-by-line/TUSCRIPT/read-a-file-line-by-line-1.tuscript create mode 100644 Task/Read-a-file-line-by-line/TUSCRIPT/read-a-file-line-by-line-2.tuscript create mode 100644 Task/Read-a-file-line-by-line/Tcl/read-a-file-line-by-line.tcl create mode 100644 Task/Read-a-file-line-by-line/TorqueScript/read-a-file-line-by-line.torquescript create mode 100644 Task/Read-a-file-line-by-line/UNIX-Shell/read-a-file-line-by-line-1.sh create mode 100644 Task/Read-a-file-line-by-line/UNIX-Shell/read-a-file-line-by-line-2.sh create mode 100644 Task/Read-a-file-line-by-line/UNIX-Shell/read-a-file-line-by-line-3.sh create mode 100644 Task/Read-a-file-line-by-line/Vala/read-a-file-line-by-line.vala create mode 100644 Task/Read-a-file-line-by-line/Vedit-macro-language/read-a-file-line-by-line.vedit create mode 100644 Task/Read-a-file-line-by-line/Visual-Basic-.NET/read-a-file-line-by-line.visual create mode 100644 Task/Read-a-file-line-by-line/Visual-Basic/read-a-file-line-by-line.vb create mode 100644 Task/Read-a-specific-line-from-a-file/0DESCRIPTION create mode 100644 Task/Read-a-specific-line-from-a-file/AWK/read-a-specific-line-from-a-file.awk create mode 100644 Task/Read-a-specific-line-from-a-file/Ada/read-a-specific-line-from-a-file.ada create mode 100644 Task/Read-a-specific-line-from-a-file/Aime/read-a-specific-line-from-a-file.aime create mode 100644 Task/Read-a-specific-line-from-a-file/AutoHotkey/read-a-specific-line-from-a-file.ahk create mode 100644 Task/Read-a-specific-line-from-a-file/BBC-BASIC/read-a-specific-line-from-a-file.bbc create mode 100644 Task/Read-a-specific-line-from-a-file/C-sharp/read-a-specific-line-from-a-file.cs create mode 100644 Task/Read-a-specific-line-from-a-file/C/read-a-specific-line-from-a-file.c create mode 100644 Task/Read-a-specific-line-from-a-file/Common-Lisp/read-a-specific-line-from-a-file.lisp create mode 100644 Task/Read-a-specific-line-from-a-file/D/read-a-specific-line-from-a-file.d create mode 100644 Task/Read-a-specific-line-from-a-file/Go/read-a-specific-line-from-a-file.go create mode 100644 Task/Read-a-specific-line-from-a-file/Groovy/read-a-specific-line-from-a-file.groovy create mode 100644 Task/Read-a-specific-line-from-a-file/Haskell/read-a-specific-line-from-a-file.hs create mode 100644 Task/Read-a-specific-line-from-a-file/Icon/read-a-specific-line-from-a-file.icon create mode 100644 Task/Read-a-specific-line-from-a-file/J/read-a-specific-line-from-a-file-1.j create mode 100644 Task/Read-a-specific-line-from-a-file/J/read-a-specific-line-from-a-file-2.j create mode 100644 Task/Read-a-specific-line-from-a-file/J/read-a-specific-line-from-a-file-3.j create mode 100644 Task/Read-a-specific-line-from-a-file/J/read-a-specific-line-from-a-file-4.j create mode 100644 Task/Read-a-specific-line-from-a-file/Java/read-a-specific-line-from-a-file.java create mode 100644 Task/Read-a-specific-line-from-a-file/Liberty-BASIC/read-a-specific-line-from-a-file.liberty create mode 100644 Task/Read-a-specific-line-from-a-file/MATLAB/read-a-specific-line-from-a-file.m create mode 100644 Task/Read-a-specific-line-from-a-file/Mathematica/read-a-specific-line-from-a-file.math create mode 100644 Task/Read-a-specific-line-from-a-file/NetRexx/read-a-specific-line-from-a-file.netrexx create mode 100644 Task/Read-a-specific-line-from-a-file/OCaml/read-a-specific-line-from-a-file.ocaml create mode 100644 Task/Read-a-specific-line-from-a-file/PL-I/read-a-specific-line-from-a-file.pli create mode 100644 Task/Read-a-specific-line-from-a-file/Pascal/read-a-specific-line-from-a-file.pascal create mode 100644 Task/Read-a-specific-line-from-a-file/Perl-6/read-a-specific-line-from-a-file.pl6 create mode 100644 Task/Read-a-specific-line-from-a-file/Perl/read-a-specific-line-from-a-file.pl create mode 100644 Task/Read-a-specific-line-from-a-file/PicoLisp/read-a-specific-line-from-a-file.l create mode 100644 Task/Read-a-specific-line-from-a-file/PureBasic/read-a-specific-line-from-a-file.purebasic create mode 100644 Task/Read-a-specific-line-from-a-file/Python/read-a-specific-line-from-a-file.py create mode 100644 Task/Read-a-specific-line-from-a-file/R/read-a-specific-line-from-a-file.r create mode 100644 Task/Read-a-specific-line-from-a-file/REXX/read-a-specific-line-from-a-file.rexx create mode 100644 Task/Read-a-specific-line-from-a-file/Ruby/read-a-specific-line-from-a-file.rb create mode 100644 Task/Read-a-specific-line-from-a-file/Run-BASIC/read-a-specific-line-from-a-file.run create mode 100644 Task/Read-a-specific-line-from-a-file/Scala/read-a-specific-line-from-a-file-1.scala create mode 100644 Task/Read-a-specific-line-from-a-file/Scala/read-a-specific-line-from-a-file-2.scala create mode 100644 Task/Read-a-specific-line-from-a-file/Scala/read-a-specific-line-from-a-file-3.scala create mode 100644 Task/Read-a-specific-line-from-a-file/Seed7/read-a-specific-line-from-a-file.seed7 create mode 100644 Task/Read-a-specific-line-from-a-file/TUSCRIPT/read-a-specific-line-from-a-file.tuscript create mode 100644 Task/Read-a-specific-line-from-a-file/TXR/read-a-specific-line-from-a-file-1.txr create mode 100644 Task/Read-a-specific-line-from-a-file/TXR/read-a-specific-line-from-a-file-2.txr create mode 100644 Task/Read-a-specific-line-from-a-file/Tcl/read-a-specific-line-from-a-file.tcl create mode 100644 Task/Read-a-specific-line-from-a-file/Vedit-macro-language/read-a-specific-line-from-a-file.vedit create mode 100644 Task/Read-a-specific-line-from-a-file/XPL0/read-a-specific-line-from-a-file.xpl0 create mode 100644 Task/Read-entire-file/0DESCRIPTION create mode 100644 Task/Read-entire-file/1META.yaml create mode 100644 Task/Read-entire-file/ALGOL-68/read-entire-file-1.alg create mode 100644 Task/Read-entire-file/ALGOL-68/read-entire-file-2.alg create mode 100644 Task/Read-entire-file/AWK/read-entire-file.awk create mode 100644 Task/Read-entire-file/Ada/read-entire-file-1.ada create mode 100644 Task/Read-entire-file/Ada/read-entire-file-2.ada create mode 100644 Task/Read-entire-file/AutoHotkey/read-entire-file.ahk create mode 100644 Task/Read-entire-file/BASIC/read-entire-file.basic create mode 100644 Task/Read-entire-file/BBC-BASIC/read-entire-file-1.bbc create mode 100644 Task/Read-entire-file/BBC-BASIC/read-entire-file-2.bbc create mode 100644 Task/Read-entire-file/Brainf---/read-entire-file.bf create mode 100644 Task/Read-entire-file/Brat/read-entire-file.brat create mode 100644 Task/Read-entire-file/C++/read-entire-file.cpp create mode 100644 Task/Read-entire-file/C-sharp/read-entire-file.cs create mode 100644 Task/Read-entire-file/C/read-entire-file-1.c create mode 100644 Task/Read-entire-file/C/read-entire-file-2.c create mode 100644 Task/Read-entire-file/CMake/read-entire-file-1.cmake create mode 100644 Task/Read-entire-file/CMake/read-entire-file-2.cmake create mode 100644 Task/Read-entire-file/Clojure/read-entire-file.clj create mode 100644 Task/Read-entire-file/Common-Lisp/read-entire-file.lisp create mode 100644 Task/Read-entire-file/D/read-entire-file.d create mode 100644 Task/Read-entire-file/Delphi/read-entire-file-1.delphi create mode 100644 Task/Read-entire-file/Delphi/read-entire-file-2.delphi create mode 100644 Task/Read-entire-file/E/read-entire-file.e create mode 100644 Task/Read-entire-file/Erlang/read-entire-file.erl create mode 100644 Task/Read-entire-file/Euphoria/read-entire-file.euphoria create mode 100644 Task/Read-entire-file/Factor/read-entire-file.factor create mode 100644 Task/Read-entire-file/Fantom/read-entire-file.fantom create mode 100644 Task/Read-entire-file/Forth/read-entire-file.fth create mode 100644 Task/Read-entire-file/Frink/read-entire-file.frink create mode 100644 Task/Read-entire-file/GAP/read-entire-file.gap create mode 100644 Task/Read-entire-file/GUISS/read-entire-file.guiss create mode 100644 Task/Read-entire-file/Go/read-entire-file-1.go create mode 100644 Task/Read-entire-file/Go/read-entire-file-2.go create mode 100644 Task/Read-entire-file/Groovy/read-entire-file.groovy create mode 100644 Task/Read-entire-file/Haskell/read-entire-file-1.hs create mode 100644 Task/Read-entire-file/Haskell/read-entire-file-2.hs create mode 100644 Task/Read-entire-file/Icon/read-entire-file-1.icon create mode 100644 Task/Read-entire-file/Icon/read-entire-file-2.icon create mode 100644 Task/Read-entire-file/Inform-7/read-entire-file.inf create mode 100644 Task/Read-entire-file/J/read-entire-file-1.j create mode 100644 Task/Read-entire-file/J/read-entire-file-2.j create mode 100644 Task/Read-entire-file/Java/read-entire-file-1.java create mode 100644 Task/Read-entire-file/Java/read-entire-file-2.java create mode 100644 Task/Read-entire-file/Java/read-entire-file-3.java create mode 100644 Task/Read-entire-file/Java/read-entire-file-4.java create mode 100644 Task/Read-entire-file/JavaScript/read-entire-file-1.js create mode 100644 Task/Read-entire-file/JavaScript/read-entire-file-2.js create mode 100644 Task/Read-entire-file/Julia/read-entire-file.julia create mode 100644 Task/Read-entire-file/Lang5/read-entire-file.lang5 create mode 100644 Task/Read-entire-file/Liberty-BASIC/read-entire-file.liberty create mode 100644 Task/Read-entire-file/Lua/read-entire-file.lua create mode 100644 Task/Read-entire-file/MATLAB/read-entire-file.m create mode 100644 Task/Read-entire-file/Maple/read-entire-file-1.maple create mode 100644 Task/Read-entire-file/Maple/read-entire-file-2.maple create mode 100644 Task/Read-entire-file/Mathematica/read-entire-file.math create mode 100644 Task/Read-entire-file/NetRexx/read-entire-file.netrexx create mode 100644 Task/Read-entire-file/NewLISP/read-entire-file.newlisp create mode 100644 Task/Read-entire-file/Nimrod/read-entire-file.nimrod create mode 100644 Task/Read-entire-file/OCaml/read-entire-file-1.ocaml create mode 100644 Task/Read-entire-file/OCaml/read-entire-file-2.ocaml create mode 100644 Task/Read-entire-file/OCaml/read-entire-file-3.ocaml create mode 100644 Task/Read-entire-file/OCaml/read-entire-file-4.ocaml create mode 100644 Task/Read-entire-file/Objeck/read-entire-file.objeck create mode 100644 Task/Read-entire-file/Objective-C/read-entire-file.m create mode 100644 Task/Read-entire-file/Oz/read-entire-file.oz create mode 100644 Task/Read-entire-file/PARI-GP/read-entire-file.pari create mode 100644 Task/Read-entire-file/PHP/read-entire-file.php create mode 100644 Task/Read-entire-file/PL-I/read-entire-file.pli create mode 100644 Task/Read-entire-file/Perl-6/read-entire-file.pl6 create mode 100644 Task/Read-entire-file/Perl/read-entire-file-1.pl create mode 100644 Task/Read-entire-file/Perl/read-entire-file-2.pl create mode 100644 Task/Read-entire-file/Perl/read-entire-file-3.pl create mode 100644 Task/Read-entire-file/Perl/read-entire-file-4.pl create mode 100644 Task/Read-entire-file/Perl/read-entire-file-5.pl create mode 100644 Task/Read-entire-file/PicoLisp/read-entire-file-1.l create mode 100644 Task/Read-entire-file/PicoLisp/read-entire-file-2.l create mode 100644 Task/Read-entire-file/PicoLisp/read-entire-file-3.l create mode 100644 Task/Read-entire-file/Pike/read-entire-file.pike create mode 100644 Task/Read-entire-file/PowerShell/read-entire-file-1.psh create mode 100644 Task/Read-entire-file/PowerShell/read-entire-file-2.psh create mode 100644 Task/Read-entire-file/PowerShell/read-entire-file-3.psh create mode 100644 Task/Read-entire-file/PureBasic/read-entire-file-1.purebasic create mode 100644 Task/Read-entire-file/PureBasic/read-entire-file-2.purebasic create mode 100644 Task/Read-entire-file/PureBasic/read-entire-file-3.purebasic create mode 100644 Task/Read-entire-file/Python/read-entire-file-1.py create mode 100644 Task/Read-entire-file/Python/read-entire-file-2.py create mode 100644 Task/Read-entire-file/R/read-entire-file.r create mode 100644 Task/Read-entire-file/REALbasic/read-entire-file.realbasic create mode 100644 Task/Read-entire-file/REBOL/read-entire-file.rebol create mode 100644 Task/Read-entire-file/REXX/read-entire-file.rexx create mode 100644 Task/Read-entire-file/Racket/read-entire-file.rkt create mode 100644 Task/Read-entire-file/Retro/read-entire-file.retro create mode 100644 Task/Read-entire-file/Ruby/read-entire-file-1.rb create mode 100644 Task/Read-entire-file/Ruby/read-entire-file-2.rb create mode 100644 Task/Read-entire-file/Ruby/read-entire-file-3.rb create mode 100644 Task/Read-entire-file/Ruby/read-entire-file-4.rb create mode 100644 Task/Read-entire-file/SNOBOL4/read-entire-file.sno create mode 100644 Task/Read-entire-file/Smalltalk/read-entire-file-1.st create mode 100644 Task/Read-entire-file/Smalltalk/read-entire-file-2.st create mode 100644 Task/Read-entire-file/TUSCRIPT/read-entire-file.tuscript create mode 100644 Task/Read-entire-file/TXR/read-entire-file.txr create mode 100644 Task/Read-entire-file/Tcl/read-entire-file-1.tcl create mode 100644 Task/Read-entire-file/Tcl/read-entire-file-2.tcl create mode 100644 Task/Read-entire-file/UNIX-Shell/read-entire-file-1.sh create mode 100644 Task/Read-entire-file/UNIX-Shell/read-entire-file-2.sh create mode 100644 Task/Read-entire-file/UNIX-Shell/read-entire-file-3.sh create mode 100644 Task/Read-entire-file/UNIX-Shell/read-entire-file-4.sh create mode 100644 Task/Read-entire-file/UNIX-Shell/read-entire-file-5.sh create mode 100644 Task/Read-entire-file/VBScript/read-entire-file-1.vbscript create mode 100644 Task/Read-entire-file/VBScript/read-entire-file-2.vbscript create mode 100644 Task/Read-entire-file/Vala/read-entire-file.vala create mode 100644 Task/Read-entire-file/Vedit-macro-language/read-entire-file-1.vedit create mode 100644 Task/Read-entire-file/Vedit-macro-language/read-entire-file-2.vedit create mode 100644 Task/Read-entire-file/Visual-Basic-.NET/read-entire-file.visual create mode 100644 Task/Read-entire-file/XPL0/read-entire-file.xpl0 create mode 100644 Task/Read-entire-file/Yorick/read-entire-file-1.yorick create mode 100644 Task/Read-entire-file/Yorick/read-entire-file-2.yorick create mode 100644 Task/Real-constants-and-functions/0DESCRIPTION create mode 100644 Task/Real-constants-and-functions/1META.yaml create mode 100644 Task/Real-constants-and-functions/ACL2/real-constants-and-functions.acl2 create mode 100644 Task/Real-constants-and-functions/ALGOL-68/real-constants-and-functions.alg create mode 100644 Task/Real-constants-and-functions/AWK/real-constants-and-functions-1.awk create mode 100644 Task/Real-constants-and-functions/AWK/real-constants-and-functions-2.awk create mode 100644 Task/Real-constants-and-functions/ActionScript/real-constants-and-functions-1.as create mode 100644 Task/Real-constants-and-functions/ActionScript/real-constants-and-functions-2.as create mode 100644 Task/Real-constants-and-functions/Ada/real-constants-and-functions.ada create mode 100644 Task/Real-constants-and-functions/AutoHotkey/real-constants-and-functions-1.ahk create mode 100644 Task/Real-constants-and-functions/AutoHotkey/real-constants-and-functions-2.ahk create mode 100644 Task/Real-constants-and-functions/AutoHotkey/real-constants-and-functions-3.ahk create mode 100644 Task/Real-constants-and-functions/BASIC/real-constants-and-functions.basic create mode 100644 Task/Real-constants-and-functions/BBC-BASIC/real-constants-and-functions.bbc create mode 100644 Task/Real-constants-and-functions/C++/real-constants-and-functions.cpp create mode 100644 Task/Real-constants-and-functions/C-sharp/real-constants-and-functions.cs create mode 100644 Task/Real-constants-and-functions/C/real-constants-and-functions.c create mode 100644 Task/Real-constants-and-functions/Clojure/real-constants-and-functions-1.clj create mode 100644 Task/Real-constants-and-functions/Clojure/real-constants-and-functions-2.clj create mode 100644 Task/Real-constants-and-functions/Clojure/real-constants-and-functions-3.clj create mode 100644 Task/Real-constants-and-functions/Common-Lisp/real-constants-and-functions.lisp create mode 100644 Task/Real-constants-and-functions/D/real-constants-and-functions.d create mode 100644 Task/Real-constants-and-functions/Delphi/real-constants-and-functions.delphi create mode 100644 Task/Real-constants-and-functions/E/real-constants-and-functions.e create mode 100644 Task/Real-constants-and-functions/Factor/real-constants-and-functions.factor create mode 100644 Task/Real-constants-and-functions/Fantom/real-constants-and-functions.fantom create mode 100644 Task/Real-constants-and-functions/Forth/real-constants-and-functions.fth create mode 100644 Task/Real-constants-and-functions/Fortran/real-constants-and-functions.f create mode 100644 Task/Real-constants-and-functions/Go/real-constants-and-functions.go create mode 100644 Task/Real-constants-and-functions/Groovy/real-constants-and-functions-1.groovy create mode 100644 Task/Real-constants-and-functions/Groovy/real-constants-and-functions-2.groovy create mode 100644 Task/Real-constants-and-functions/Groovy/real-constants-and-functions-3.groovy create mode 100644 Task/Real-constants-and-functions/Haskell/real-constants-and-functions.hs create mode 100644 Task/Real-constants-and-functions/HicEst/real-constants-and-functions-1.hicest create mode 100644 Task/Real-constants-and-functions/HicEst/real-constants-and-functions-2.hicest create mode 100644 Task/Real-constants-and-functions/J/real-constants-and-functions.j create mode 100644 Task/Real-constants-and-functions/Java/real-constants-and-functions.java create mode 100644 Task/Real-constants-and-functions/JavaScript/real-constants-and-functions.js create mode 100644 Task/Real-constants-and-functions/Liberty-BASIC/real-constants-and-functions.liberty create mode 100644 Task/Real-constants-and-functions/Logo/real-constants-and-functions.logo create mode 100644 Task/Real-constants-and-functions/Lua/real-constants-and-functions.lua create mode 100644 Task/Real-constants-and-functions/MAXScript/real-constants-and-functions.maxscript create mode 100644 Task/Real-constants-and-functions/Maple/real-constants-and-functions.maple create mode 100644 Task/Real-constants-and-functions/Mathematica/real-constants-and-functions-1.math create mode 100644 Task/Real-constants-and-functions/Mathematica/real-constants-and-functions-2.math create mode 100644 Task/Real-constants-and-functions/Mercury/real-constants-and-functions.mercury create mode 100644 Task/Real-constants-and-functions/Metafont/real-constants-and-functions.metafont create mode 100644 Task/Real-constants-and-functions/Modula-3/real-constants-and-functions.mod3 create mode 100644 Task/Real-constants-and-functions/NetRexx/real-constants-and-functions.netrexx create mode 100644 Task/Real-constants-and-functions/OCaml/real-constants-and-functions.ocaml create mode 100644 Task/Real-constants-and-functions/Objeck/real-constants-and-functions.objeck create mode 100644 Task/Real-constants-and-functions/Octave/real-constants-and-functions.octave create mode 100644 Task/Real-constants-and-functions/Oz/real-constants-and-functions.oz create mode 100644 Task/Real-constants-and-functions/PARI-GP/real-constants-and-functions.pari create mode 100644 Task/Real-constants-and-functions/PHP/real-constants-and-functions.php create mode 100644 Task/Real-constants-and-functions/PL-I/real-constants-and-functions.pli create mode 100644 Task/Real-constants-and-functions/Perl-6/real-constants-and-functions.pl6 create mode 100644 Task/Real-constants-and-functions/Perl/real-constants-and-functions.pl create mode 100644 Task/Real-constants-and-functions/PicoLisp/real-constants-and-functions.l create mode 100644 Task/Real-constants-and-functions/Pop11/real-constants-and-functions.pop11 create mode 100644 Task/Real-constants-and-functions/PowerShell/real-constants-and-functions.psh create mode 100644 Task/Real-constants-and-functions/PureBasic/real-constants-and-functions.purebasic create mode 100644 Task/Real-constants-and-functions/Python/real-constants-and-functions.py create mode 100644 Task/Real-constants-and-functions/R/real-constants-and-functions.r create mode 100644 Task/Real-constants-and-functions/REXX/real-constants-and-functions-1.rexx create mode 100644 Task/Real-constants-and-functions/REXX/real-constants-and-functions-2.rexx create mode 100644 Task/Real-constants-and-functions/REXX/real-constants-and-functions-3.rexx create mode 100644 Task/Real-constants-and-functions/REXX/real-constants-and-functions-4.rexx create mode 100644 Task/Real-constants-and-functions/REXX/real-constants-and-functions-5.rexx create mode 100644 Task/Real-constants-and-functions/REXX/real-constants-and-functions-6.rexx create mode 100644 Task/Real-constants-and-functions/RLaB/real-constants-and-functions-1.rlab create mode 100644 Task/Real-constants-and-functions/RLaB/real-constants-and-functions-2.rlab create mode 100644 Task/Real-constants-and-functions/RLaB/real-constants-and-functions-3.rlab create mode 100644 Task/Real-constants-and-functions/Racket/real-constants-and-functions.rkt create mode 100644 Task/Real-constants-and-functions/Ruby/real-constants-and-functions.rb create mode 100644 Task/Real-constants-and-functions/Run-BASIC/real-constants-and-functions.run create mode 100644 Task/Real-constants-and-functions/Scheme/real-constants-and-functions.ss create mode 100644 Task/Real-constants-and-functions/Slate/real-constants-and-functions.slate create mode 100644 Task/Real-constants-and-functions/Smalltalk/real-constants-and-functions.st create mode 100644 Task/Real-constants-and-functions/Standard-ML/real-constants-and-functions.ml create mode 100644 Task/Real-constants-and-functions/Tcl/real-constants-and-functions-1.tcl create mode 100644 Task/Real-constants-and-functions/Tcl/real-constants-and-functions-2.tcl create mode 100644 Task/Real-constants-and-functions/XPL0/real-constants-and-functions.xpl0 create mode 100644 Task/Record-sound/0DESCRIPTION create mode 100644 Task/Record-sound/BBC-BASIC/record-sound.bbc create mode 100644 Task/Record-sound/C/record-sound.c create mode 100644 Task/Record-sound/GUISS/record-sound.guiss create mode 100644 Task/Record-sound/Liberty-BASIC/record-sound-1.liberty create mode 100644 Task/Record-sound/Liberty-BASIC/record-sound-2.liberty create mode 100644 Task/Record-sound/Mathematica/record-sound.math create mode 100644 Task/Record-sound/OCaml/record-sound.ocaml create mode 100644 Task/Record-sound/PicoLisp/record-sound.l create mode 100644 Task/Record-sound/Python/record-sound.py create mode 100644 Task/Record-sound/Tcl/record-sound.tcl create mode 100644 Task/Reduced-row-echelon-form/0DESCRIPTION create mode 100644 Task/Reduced-row-echelon-form/1META.yaml create mode 100644 Task/Reduced-row-echelon-form/ALGOL-68/reduced-row-echelon-form.alg create mode 100644 Task/Reduced-row-echelon-form/ActionScript/reduced-row-echelon-form.as create mode 100644 Task/Reduced-row-echelon-form/Ada/reduced-row-echelon-form-1.ada create mode 100644 Task/Reduced-row-echelon-form/Ada/reduced-row-echelon-form-2.ada create mode 100644 Task/Reduced-row-echelon-form/Ada/reduced-row-echelon-form-3.ada create mode 100644 Task/Reduced-row-echelon-form/AutoIt/reduced-row-echelon-form.autoit create mode 100644 Task/Reduced-row-echelon-form/BBC-BASIC/reduced-row-echelon-form.bbc create mode 100644 Task/Reduced-row-echelon-form/C++/reduced-row-echelon-form.cpp create mode 100644 Task/Reduced-row-echelon-form/C/reduced-row-echelon-form.c create mode 100644 Task/Reduced-row-echelon-form/Common-Lisp/reduced-row-echelon-form.lisp create mode 100644 Task/Reduced-row-echelon-form/D/reduced-row-echelon-form.d create mode 100644 Task/Reduced-row-echelon-form/Euphoria/reduced-row-echelon-form.euphoria create mode 100644 Task/Reduced-row-echelon-form/Fortran/reduced-row-echelon-form-1.f create mode 100644 Task/Reduced-row-echelon-form/Fortran/reduced-row-echelon-form-2.f create mode 100644 Task/Reduced-row-echelon-form/Go/reduced-row-echelon-form-1.go create mode 100644 Task/Reduced-row-echelon-form/Go/reduced-row-echelon-form-2.go create mode 100644 Task/Reduced-row-echelon-form/Groovy/reduced-row-echelon-form-1.groovy create mode 100644 Task/Reduced-row-echelon-form/Groovy/reduced-row-echelon-form-2.groovy create mode 100644 Task/Reduced-row-echelon-form/Haskell/reduced-row-echelon-form.hs create mode 100644 Task/Reduced-row-echelon-form/J/reduced-row-echelon-form-1.j create mode 100644 Task/Reduced-row-echelon-form/J/reduced-row-echelon-form-2.j create mode 100644 Task/Reduced-row-echelon-form/Java/reduced-row-echelon-form.java create mode 100644 Task/Reduced-row-echelon-form/JavaScript/reduced-row-echelon-form.js create mode 100644 Task/Reduced-row-echelon-form/Lua/reduced-row-echelon-form.lua create mode 100644 Task/Reduced-row-echelon-form/MATLAB/reduced-row-echelon-form.m create mode 100644 Task/Reduced-row-echelon-form/Mathematica/reduced-row-echelon-form-1.math create mode 100644 Task/Reduced-row-echelon-form/Mathematica/reduced-row-echelon-form-2.math create mode 100644 Task/Reduced-row-echelon-form/Maxima/reduced-row-echelon-form.maxima create mode 100644 Task/Reduced-row-echelon-form/OCaml/reduced-row-echelon-form-1.ocaml create mode 100644 Task/Reduced-row-echelon-form/OCaml/reduced-row-echelon-form-2.ocaml create mode 100644 Task/Reduced-row-echelon-form/Objeck/reduced-row-echelon-form.objeck create mode 100644 Task/Reduced-row-echelon-form/Octave/reduced-row-echelon-form.octave create mode 100644 Task/Reduced-row-echelon-form/PARI-GP/reduced-row-echelon-form-1.pari create mode 100644 Task/Reduced-row-echelon-form/PARI-GP/reduced-row-echelon-form-2.pari create mode 100644 Task/Reduced-row-echelon-form/PHP/reduced-row-echelon-form.php create mode 100644 Task/Reduced-row-echelon-form/Perl-6/reduced-row-echelon-form-1.pl6 create mode 100644 Task/Reduced-row-echelon-form/Perl-6/reduced-row-echelon-form-2.pl6 create mode 100644 Task/Reduced-row-echelon-form/Perl-6/reduced-row-echelon-form-3.pl6 create mode 100644 Task/Reduced-row-echelon-form/Perl/reduced-row-echelon-form.pl create mode 100644 Task/Reduced-row-echelon-form/PicoLisp/reduced-row-echelon-form.l create mode 100644 Task/Reduced-row-echelon-form/Python/reduced-row-echelon-form.py create mode 100644 Task/Reduced-row-echelon-form/R/reduced-row-echelon-form.r create mode 100644 Task/Reduced-row-echelon-form/REXX/reduced-row-echelon-form.rexx create mode 100644 Task/Reduced-row-echelon-form/Racket/reduced-row-echelon-form.rkt create mode 100644 Task/Reduced-row-echelon-form/Ruby/reduced-row-echelon-form.rb create mode 100644 Task/Reduced-row-echelon-form/Sage/reduced-row-echelon-form.sage create mode 100644 Task/Reduced-row-echelon-form/Scheme/reduced-row-echelon-form-1.ss create mode 100644 Task/Reduced-row-echelon-form/Scheme/reduced-row-echelon-form-2.ss create mode 100644 Task/Reduced-row-echelon-form/Scheme/reduced-row-echelon-form-3.ss create mode 100644 Task/Reduced-row-echelon-form/Seed7/reduced-row-echelon-form.seed7 create mode 100644 Task/Reduced-row-echelon-form/TI-89-BASIC/reduced-row-echelon-form.ti-89 create mode 100644 Task/Reduced-row-echelon-form/Tcl/reduced-row-echelon-form.tcl create mode 100644 Task/Reduced-row-echelon-form/Ursala/reduced-row-echelon-form-1.ursala create mode 100644 Task/Reduced-row-echelon-form/Ursala/reduced-row-echelon-form-2.ursala create mode 100644 Task/Regular-expressions/0DESCRIPTION create mode 100644 Task/Regular-expressions/1META.yaml create mode 100644 Task/Regular-expressions/ALGOL-68/regular-expressions-1.alg create mode 100644 Task/Regular-expressions/ALGOL-68/regular-expressions-2.alg create mode 100644 Task/Regular-expressions/AWK/regular-expressions-1.awk create mode 100644 Task/Regular-expressions/AWK/regular-expressions-2.awk create mode 100644 Task/Regular-expressions/AWK/regular-expressions-3.awk create mode 100644 Task/Regular-expressions/AWK/regular-expressions-4.awk create mode 100644 Task/Regular-expressions/Ada/regular-expressions.ada create mode 100644 Task/Regular-expressions/AppleScript/regular-expressions.applescript create mode 100644 Task/Regular-expressions/Argile/regular-expressions.argile create mode 100644 Task/Regular-expressions/AutoHotkey/regular-expressions.ahk create mode 100644 Task/Regular-expressions/BBC-BASIC/regular-expressions.bbc create mode 100644 Task/Regular-expressions/Bracmat/regular-expressions.bracmat create mode 100644 Task/Regular-expressions/C++/regular-expressions.cpp create mode 100644 Task/Regular-expressions/C-sharp/regular-expressions.cs create mode 100644 Task/Regular-expressions/C/regular-expressions.c create mode 100644 Task/Regular-expressions/Clojure/regular-expressions.clj create mode 100644 Task/Regular-expressions/Common-Lisp/regular-expressions-1.lisp create mode 100644 Task/Regular-expressions/Common-Lisp/regular-expressions-2.lisp create mode 100644 Task/Regular-expressions/Common-Lisp/regular-expressions-3.lisp create mode 100644 Task/Regular-expressions/Common-Lisp/regular-expressions-4.lisp create mode 100644 Task/Regular-expressions/Common-Lisp/regular-expressions-5.lisp create mode 100644 Task/Regular-expressions/D/regular-expressions.d create mode 100644 Task/Regular-expressions/Erlang/regular-expressions.erl create mode 100644 Task/Regular-expressions/Forth/regular-expressions.fth create mode 100644 Task/Regular-expressions/Frink/regular-expressions-1.frink create mode 100644 Task/Regular-expressions/Frink/regular-expressions-2.frink create mode 100644 Task/Regular-expressions/Go/regular-expressions.go create mode 100644 Task/Regular-expressions/Groovy/regular-expressions-1.groovy create mode 100644 Task/Regular-expressions/Groovy/regular-expressions-2.groovy create mode 100644 Task/Regular-expressions/Groovy/regular-expressions-3.groovy create mode 100644 Task/Regular-expressions/Haskell/regular-expressions-1.hs create mode 100644 Task/Regular-expressions/Haskell/regular-expressions-2.hs create mode 100644 Task/Regular-expressions/HicEst/regular-expressions.hicest create mode 100644 Task/Regular-expressions/Icon/regular-expressions.icon create mode 100644 Task/Regular-expressions/Inform-7/regular-expressions.inf create mode 100644 Task/Regular-expressions/J/regular-expressions-1.j create mode 100644 Task/Regular-expressions/J/regular-expressions-2.j create mode 100644 Task/Regular-expressions/J/regular-expressions-3.j create mode 100644 Task/Regular-expressions/J/regular-expressions-4.j create mode 100644 Task/Regular-expressions/Java/regular-expressions-1.java create mode 100644 Task/Regular-expressions/Java/regular-expressions-2.java create mode 100644 Task/Regular-expressions/Java/regular-expressions-3.java create mode 100644 Task/Regular-expressions/JavaScript/regular-expressions-1.js create mode 100644 Task/Regular-expressions/JavaScript/regular-expressions-2.js create mode 100644 Task/Regular-expressions/Julia/regular-expressions-1.julia create mode 100644 Task/Regular-expressions/Julia/regular-expressions-2.julia create mode 100644 Task/Regular-expressions/Lua/regular-expressions.lua create mode 100644 Task/Regular-expressions/M4/regular-expressions.m4 create mode 100644 Task/Regular-expressions/MIRC-Scripting-Language/regular-expressions.mirc create mode 100644 Task/Regular-expressions/MUMPS/regular-expressions.mumps create mode 100644 Task/Regular-expressions/Mathematica/regular-expressions.math create mode 100644 Task/Regular-expressions/NetRexx/regular-expressions.netrexx create mode 100644 Task/Regular-expressions/OCaml/regular-expressions-1.ocaml create mode 100644 Task/Regular-expressions/OCaml/regular-expressions-2.ocaml create mode 100644 Task/Regular-expressions/OCaml/regular-expressions-3.ocaml create mode 100644 Task/Regular-expressions/Objeck/regular-expressions.objeck create mode 100644 Task/Regular-expressions/Objective-C/regular-expressions-1.m create mode 100644 Task/Regular-expressions/Objective-C/regular-expressions-2.m create mode 100644 Task/Regular-expressions/Objective-C/regular-expressions-3.m create mode 100644 Task/Regular-expressions/Objective-C/regular-expressions-4.m create mode 100644 Task/Regular-expressions/Objective-C/regular-expressions-5.m create mode 100644 Task/Regular-expressions/Objective-C/regular-expressions-6.m create mode 100644 Task/Regular-expressions/Oxygene/regular-expressions.oxy create mode 100644 Task/Regular-expressions/Oz/regular-expressions.oz create mode 100644 Task/Regular-expressions/PHP/regular-expressions.php create mode 100644 Task/Regular-expressions/Pascal/regular-expressions.pascal create mode 100644 Task/Regular-expressions/Perl-6/regular-expressions.pl6 create mode 100644 Task/Regular-expressions/Perl/regular-expressions-1.pl create mode 100644 Task/Regular-expressions/Perl/regular-expressions-2.pl create mode 100644 Task/Regular-expressions/Perl/regular-expressions-3.pl create mode 100644 Task/Regular-expressions/Perl/regular-expressions-4.pl create mode 100644 Task/Regular-expressions/Perl/regular-expressions-5.pl create mode 100644 Task/Regular-expressions/Perl/regular-expressions-6.pl create mode 100644 Task/Regular-expressions/PicoLisp/regular-expressions-1.l create mode 100644 Task/Regular-expressions/PicoLisp/regular-expressions-2.l create mode 100644 Task/Regular-expressions/PowerShell/regular-expressions.psh create mode 100644 Task/Regular-expressions/PureBasic/regular-expressions.purebasic create mode 100644 Task/Regular-expressions/Python/regular-expressions.py create mode 100644 Task/Regular-expressions/R/regular-expressions-1.r create mode 100644 Task/Regular-expressions/R/regular-expressions-2.r create mode 100644 Task/Regular-expressions/R/regular-expressions-3.r create mode 100644 Task/Regular-expressions/R/regular-expressions-4.r create mode 100644 Task/Regular-expressions/REBOL/regular-expressions.rebol create mode 100644 Task/Regular-expressions/REXX/regular-expressions-1.rexx create mode 100644 Task/Regular-expressions/REXX/regular-expressions-2.rexx create mode 100644 Task/Regular-expressions/REXX/regular-expressions-3.rexx create mode 100644 Task/Regular-expressions/REXX/regular-expressions-4.rexx create mode 100644 Task/Regular-expressions/Racket/regular-expressions.rkt create mode 100644 Task/Regular-expressions/Raven/regular-expressions-1.raven create mode 100644 Task/Regular-expressions/Raven/regular-expressions-2.raven create mode 100644 Task/Regular-expressions/Raven/regular-expressions-3.raven create mode 100644 Task/Regular-expressions/Ruby/regular-expressions-1.rb create mode 100644 Task/Regular-expressions/Ruby/regular-expressions-2.rb create mode 100644 Task/Regular-expressions/Ruby/regular-expressions-3.rb create mode 100644 Task/Regular-expressions/Run-BASIC/regular-expressions.run create mode 100644 Task/Regular-expressions/SNOBOL4/regular-expressions-1.sno create mode 100644 Task/Regular-expressions/SNOBOL4/regular-expressions-2.sno create mode 100644 Task/Regular-expressions/SNOBOL4/regular-expressions-3.sno create mode 100644 Task/Regular-expressions/Sather/regular-expressions.sa create mode 100644 Task/Regular-expressions/Scala/regular-expressions-1.scala create mode 100644 Task/Regular-expressions/Scala/regular-expressions-2.scala create mode 100644 Task/Regular-expressions/Scala/regular-expressions-3.scala create mode 100644 Task/Regular-expressions/Scala/regular-expressions-4.scala create mode 100644 Task/Regular-expressions/Scala/regular-expressions-5.scala create mode 100644 Task/Regular-expressions/Shiny/regular-expressions-1.shiny create mode 100644 Task/Regular-expressions/Shiny/regular-expressions-2.shiny create mode 100644 Task/Regular-expressions/Shiny/regular-expressions-3.shiny create mode 100644 Task/Regular-expressions/Slate/regular-expressions.slate create mode 100644 Task/Regular-expressions/Smalltalk/regular-expressions.st create mode 100644 Task/Regular-expressions/Standard-ML/regular-expressions.ml create mode 100644 Task/Regular-expressions/TXR/regular-expressions-1.txr create mode 100644 Task/Regular-expressions/TXR/regular-expressions-2.txr create mode 100644 Task/Regular-expressions/Tcl/regular-expressions-1.tcl create mode 100644 Task/Regular-expressions/Tcl/regular-expressions-2.tcl create mode 100644 Task/Regular-expressions/Tcl/regular-expressions-3.tcl create mode 100644 Task/Regular-expressions/Toka/regular-expressions.toka create mode 100644 Task/Regular-expressions/Vala/regular-expressions.vala create mode 100644 Task/Regular-expressions/Vedit-macro-language/regular-expressions-1.vedit create mode 100644 Task/Regular-expressions/Vedit-macro-language/regular-expressions-2.vedit create mode 100644 Task/Regular-expressions/Vedit-macro-language/regular-expressions-3.vedit create mode 100644 Task/Remove-duplicate-elements/0DESCRIPTION create mode 100644 Task/Remove-duplicate-elements/ACL2/remove-duplicate-elements.acl2 create mode 100644 Task/Remove-duplicate-elements/AWK/remove-duplicate-elements.awk create mode 100644 Task/Remove-duplicate-elements/Ada/remove-duplicate-elements-1.ada create mode 100644 Task/Remove-duplicate-elements/Ada/remove-duplicate-elements-2.ada create mode 100644 Task/Remove-duplicate-elements/Ada/remove-duplicate-elements-3.ada create mode 100644 Task/Remove-duplicate-elements/AppleScript/remove-duplicate-elements.applescript create mode 100644 Task/Remove-duplicate-elements/AutoHotkey/remove-duplicate-elements.ahk create mode 100644 Task/Remove-duplicate-elements/BBC-BASIC/remove-duplicate-elements.bbc create mode 100644 Task/Remove-duplicate-elements/Bracmat/remove-duplicate-elements.bracmat create mode 100644 Task/Remove-duplicate-elements/Brat/remove-duplicate-elements.brat create mode 100644 Task/Remove-duplicate-elements/C++/remove-duplicate-elements-1.cpp create mode 100644 Task/Remove-duplicate-elements/C++/remove-duplicate-elements-2.cpp create mode 100644 Task/Remove-duplicate-elements/C++/remove-duplicate-elements-3.cpp create mode 100644 Task/Remove-duplicate-elements/C++/remove-duplicate-elements-4.cpp create mode 100644 Task/Remove-duplicate-elements/C-sharp/remove-duplicate-elements-1.cs create mode 100644 Task/Remove-duplicate-elements/C-sharp/remove-duplicate-elements-2.cs create mode 100644 Task/Remove-duplicate-elements/C/remove-duplicate-elements-1.c create mode 100644 Task/Remove-duplicate-elements/C/remove-duplicate-elements-2.c create mode 100644 Task/Remove-duplicate-elements/C/remove-duplicate-elements-3.c create mode 100644 Task/Remove-duplicate-elements/Clojure/remove-duplicate-elements.clj create mode 100644 Task/Remove-duplicate-elements/Common-Lisp/remove-duplicate-elements-1.lisp create mode 100644 Task/Remove-duplicate-elements/Common-Lisp/remove-duplicate-elements-2.lisp create mode 100644 Task/Remove-duplicate-elements/D/remove-duplicate-elements-1.d create mode 100644 Task/Remove-duplicate-elements/D/remove-duplicate-elements-2.d create mode 100644 Task/Remove-duplicate-elements/Delphi/remove-duplicate-elements.delphi create mode 100644 Task/Remove-duplicate-elements/E/remove-duplicate-elements.e create mode 100644 Task/Remove-duplicate-elements/Erlang/remove-duplicate-elements.erl create mode 100644 Task/Remove-duplicate-elements/Euphoria/remove-duplicate-elements.euphoria create mode 100644 Task/Remove-duplicate-elements/Factor/remove-duplicate-elements.factor create mode 100644 Task/Remove-duplicate-elements/Forth/remove-duplicate-elements-1.fth create mode 100644 Task/Remove-duplicate-elements/Forth/remove-duplicate-elements-2.fth create mode 100644 Task/Remove-duplicate-elements/Forth/remove-duplicate-elements-3.fth create mode 100644 Task/Remove-duplicate-elements/Forth/remove-duplicate-elements-4.fth create mode 100644 Task/Remove-duplicate-elements/Fortran/remove-duplicate-elements.f create mode 100644 Task/Remove-duplicate-elements/GAP/remove-duplicate-elements.gap create mode 100644 Task/Remove-duplicate-elements/Go/remove-duplicate-elements-1.go create mode 100644 Task/Remove-duplicate-elements/Go/remove-duplicate-elements-2.go create mode 100644 Task/Remove-duplicate-elements/Go/remove-duplicate-elements-3.go create mode 100644 Task/Remove-duplicate-elements/Groovy/remove-duplicate-elements.groovy create mode 100644 Task/Remove-duplicate-elements/Haskell/remove-duplicate-elements.hs create mode 100644 Task/Remove-duplicate-elements/HicEst/remove-duplicate-elements.hicest create mode 100644 Task/Remove-duplicate-elements/IDL/remove-duplicate-elements.idl create mode 100644 Task/Remove-duplicate-elements/Icon/remove-duplicate-elements.icon create mode 100644 Task/Remove-duplicate-elements/Inform-7/remove-duplicate-elements.inf create mode 100644 Task/Remove-duplicate-elements/J/remove-duplicate-elements-1.j create mode 100644 Task/Remove-duplicate-elements/J/remove-duplicate-elements-2.j create mode 100644 Task/Remove-duplicate-elements/Java/remove-duplicate-elements.java create mode 100644 Task/Remove-duplicate-elements/JavaScript/remove-duplicate-elements-1.js create mode 100644 Task/Remove-duplicate-elements/JavaScript/remove-duplicate-elements-2.js create mode 100644 Task/Remove-duplicate-elements/Julia/remove-duplicate-elements.julia create mode 100644 Task/Remove-duplicate-elements/K/remove-duplicate-elements.k create mode 100644 Task/Remove-duplicate-elements/Lang5/remove-duplicate-elements-1.lang5 create mode 100644 Task/Remove-duplicate-elements/Lang5/remove-duplicate-elements-2.lang5 create mode 100644 Task/Remove-duplicate-elements/Liberty-BASIC/remove-duplicate-elements.liberty create mode 100644 Task/Remove-duplicate-elements/Logo/remove-duplicate-elements.logo create mode 100644 Task/Remove-duplicate-elements/Lua/remove-duplicate-elements.lua create mode 100644 Task/Remove-duplicate-elements/MATLAB/remove-duplicate-elements.m create mode 100644 Task/Remove-duplicate-elements/MAXScript/remove-duplicate-elements.maxscript create mode 100644 Task/Remove-duplicate-elements/MUMPS/remove-duplicate-elements.mumps create mode 100644 Task/Remove-duplicate-elements/Maple/remove-duplicate-elements-1.maple create mode 100644 Task/Remove-duplicate-elements/Maple/remove-duplicate-elements-2.maple create mode 100644 Task/Remove-duplicate-elements/Maple/remove-duplicate-elements-3.maple create mode 100644 Task/Remove-duplicate-elements/Mathematica/remove-duplicate-elements-1.math create mode 100644 Task/Remove-duplicate-elements/Mathematica/remove-duplicate-elements-2.math create mode 100644 Task/Remove-duplicate-elements/Mathematica/remove-duplicate-elements-3.math create mode 100644 Task/Remove-duplicate-elements/Mathematica/remove-duplicate-elements-4.math create mode 100644 Task/Remove-duplicate-elements/Maxima/remove-duplicate-elements.maxima create mode 100644 Task/Remove-duplicate-elements/Nemerle/remove-duplicate-elements.nemerle create mode 100644 Task/Remove-duplicate-elements/NetRexx/remove-duplicate-elements.netrexx create mode 100644 Task/Remove-duplicate-elements/NewLISP/remove-duplicate-elements.newlisp create mode 100644 Task/Remove-duplicate-elements/Nial/remove-duplicate-elements-1.nial create mode 100644 Task/Remove-duplicate-elements/Nial/remove-duplicate-elements-2.nial create mode 100644 Task/Remove-duplicate-elements/OCaml/remove-duplicate-elements.ocaml create mode 100644 Task/Remove-duplicate-elements/Objeck/remove-duplicate-elements.objeck create mode 100644 Task/Remove-duplicate-elements/Objective-C/remove-duplicate-elements.m create mode 100644 Task/Remove-duplicate-elements/Octave/remove-duplicate-elements.octave create mode 100644 Task/Remove-duplicate-elements/Oz/remove-duplicate-elements.oz create mode 100644 Task/Remove-duplicate-elements/PARI-GP/remove-duplicate-elements.pari create mode 100644 Task/Remove-duplicate-elements/PHP/remove-duplicate-elements.php create mode 100644 Task/Remove-duplicate-elements/PL-I/remove-duplicate-elements.pli create mode 100644 Task/Remove-duplicate-elements/Pascal/remove-duplicate-elements.pascal create mode 100644 Task/Remove-duplicate-elements/Perl-6/remove-duplicate-elements-1.pl6 create mode 100644 Task/Remove-duplicate-elements/Perl-6/remove-duplicate-elements-2.pl6 create mode 100644 Task/Remove-duplicate-elements/Perl/remove-duplicate-elements-1.pl create mode 100644 Task/Remove-duplicate-elements/Perl/remove-duplicate-elements-2.pl create mode 100644 Task/Remove-duplicate-elements/Perl/remove-duplicate-elements-3.pl create mode 100644 Task/Remove-duplicate-elements/Perl/remove-duplicate-elements-4.pl create mode 100644 Task/Remove-duplicate-elements/PicoLisp/remove-duplicate-elements.l create mode 100644 Task/Remove-duplicate-elements/Pop11/remove-duplicate-elements.pop11 create mode 100644 Task/Remove-duplicate-elements/PostScript/remove-duplicate-elements.ps create mode 100644 Task/Remove-duplicate-elements/PowerShell/remove-duplicate-elements-1.psh create mode 100644 Task/Remove-duplicate-elements/PowerShell/remove-duplicate-elements-2.psh create mode 100644 Task/Remove-duplicate-elements/PowerShell/remove-duplicate-elements-3.psh create mode 100644 Task/Remove-duplicate-elements/PowerShell/remove-duplicate-elements-4.psh create mode 100644 Task/Remove-duplicate-elements/Prolog/remove-duplicate-elements-1.pro create mode 100644 Task/Remove-duplicate-elements/Prolog/remove-duplicate-elements-2.pro create mode 100644 Task/Remove-duplicate-elements/Prolog/remove-duplicate-elements-3.pro create mode 100644 Task/Remove-duplicate-elements/Prolog/remove-duplicate-elements-4.pro create mode 100644 Task/Remove-duplicate-elements/PureBasic/remove-duplicate-elements.purebasic create mode 100644 Task/Remove-duplicate-elements/Python/remove-duplicate-elements-1.py create mode 100644 Task/Remove-duplicate-elements/Python/remove-duplicate-elements-2.py create mode 100644 Task/Remove-duplicate-elements/Python/remove-duplicate-elements-3.py create mode 100644 Task/Remove-duplicate-elements/Qi/remove-duplicate-elements.qi create mode 100644 Task/Remove-duplicate-elements/REBOL/remove-duplicate-elements.rebol create mode 100644 Task/Remove-duplicate-elements/REXX/remove-duplicate-elements-1.rexx create mode 100644 Task/Remove-duplicate-elements/REXX/remove-duplicate-elements-2.rexx create mode 100644 Task/Remove-duplicate-elements/REXX/remove-duplicate-elements-3.rexx create mode 100644 Task/Remove-duplicate-elements/Raven/remove-duplicate-elements.raven create mode 100644 Task/Remove-duplicate-elements/Ruby/remove-duplicate-elements.rb create mode 100644 Task/Remove-duplicate-elements/SETL/remove-duplicate-elements-1.setl create mode 100644 Task/Remove-duplicate-elements/SETL/remove-duplicate-elements-2.setl create mode 100644 Task/Remove-duplicate-elements/SETL/remove-duplicate-elements-3.setl create mode 100644 Task/Remove-duplicate-elements/Scala/remove-duplicate-elements.scala create mode 100644 Task/Remove-duplicate-elements/Scheme/remove-duplicate-elements-1.ss create mode 100644 Task/Remove-duplicate-elements/Scheme/remove-duplicate-elements-2.ss create mode 100644 Task/Remove-duplicate-elements/Scheme/remove-duplicate-elements-3.ss create mode 100644 Task/Remove-duplicate-elements/Scheme/remove-duplicate-elements-4.ss create mode 100644 Task/Remove-duplicate-elements/Seed7/remove-duplicate-elements.seed7 create mode 100644 Task/Remove-duplicate-elements/Slate/remove-duplicate-elements.slate create mode 100644 Task/Remove-duplicate-elements/Smalltalk/remove-duplicate-elements-1.st create mode 100644 Task/Remove-duplicate-elements/Smalltalk/remove-duplicate-elements-2.st create mode 100644 Task/Remove-duplicate-elements/TUSCRIPT/remove-duplicate-elements-1.tuscript create mode 100644 Task/Remove-duplicate-elements/TUSCRIPT/remove-duplicate-elements-2.tuscript create mode 100644 Task/Remove-duplicate-elements/Tcl/remove-duplicate-elements.tcl create mode 100644 Task/Remove-duplicate-elements/UnixPipes/remove-duplicate-elements-1.unixpipes create mode 100644 Task/Remove-duplicate-elements/UnixPipes/remove-duplicate-elements-2.unixpipes create mode 100644 Task/Remove-duplicate-elements/Ursala/remove-duplicate-elements.ursala create mode 100644 Task/Remove-duplicate-elements/Vedit-macro-language/remove-duplicate-elements.vedit create mode 100644 Task/Remove-duplicate-elements/XPL0/remove-duplicate-elements.xpl0 create mode 100644 Task/Remove-lines-from-a-file/0DESCRIPTION create mode 100644 Task/Remove-lines-from-a-file/1META.yaml create mode 100644 Task/Remove-lines-from-a-file/AWK/remove-lines-from-a-file.awk create mode 100644 Task/Remove-lines-from-a-file/Ada/remove-lines-from-a-file.ada create mode 100644 Task/Remove-lines-from-a-file/AutoHotkey/remove-lines-from-a-file.ahk create mode 100644 Task/Remove-lines-from-a-file/C++/remove-lines-from-a-file.cpp create mode 100644 Task/Remove-lines-from-a-file/C/remove-lines-from-a-file.c create mode 100644 Task/Remove-lines-from-a-file/Common-Lisp/remove-lines-from-a-file.lisp create mode 100644 Task/Remove-lines-from-a-file/D/remove-lines-from-a-file.d create mode 100644 Task/Remove-lines-from-a-file/Go/remove-lines-from-a-file.go create mode 100644 Task/Remove-lines-from-a-file/Haskell/remove-lines-from-a-file.hs create mode 100644 Task/Remove-lines-from-a-file/Icon/remove-lines-from-a-file.icon create mode 100644 Task/Remove-lines-from-a-file/J/remove-lines-from-a-file-1.j create mode 100644 Task/Remove-lines-from-a-file/J/remove-lines-from-a-file-2.j create mode 100644 Task/Remove-lines-from-a-file/J/remove-lines-from-a-file-3.j create mode 100644 Task/Remove-lines-from-a-file/J/remove-lines-from-a-file-4.j create mode 100644 Task/Remove-lines-from-a-file/Liberty-BASIC/remove-lines-from-a-file.liberty create mode 100644 Task/Remove-lines-from-a-file/Lua/remove-lines-from-a-file.lua create mode 100644 Task/Remove-lines-from-a-file/OCaml/remove-lines-from-a-file.ocaml create mode 100644 Task/Remove-lines-from-a-file/Perl-6/remove-lines-from-a-file.pl6 create mode 100644 Task/Remove-lines-from-a-file/Perl/remove-lines-from-a-file-1.pl create mode 100644 Task/Remove-lines-from-a-file/Perl/remove-lines-from-a-file-2.pl create mode 100644 Task/Remove-lines-from-a-file/PicoLisp/remove-lines-from-a-file.l create mode 100644 Task/Remove-lines-from-a-file/PowerBASIC/remove-lines-from-a-file.powerbasic create mode 100644 Task/Remove-lines-from-a-file/Python/remove-lines-from-a-file.py create mode 100644 Task/Remove-lines-from-a-file/REXX/remove-lines-from-a-file.rexx create mode 100644 Task/Remove-lines-from-a-file/Ruby/remove-lines-from-a-file-1.rb create mode 100644 Task/Remove-lines-from-a-file/Ruby/remove-lines-from-a-file-2.rb create mode 100644 Task/Remove-lines-from-a-file/Run-BASIC/remove-lines-from-a-file.run create mode 100644 Task/Remove-lines-from-a-file/Seed7/remove-lines-from-a-file.seed7 create mode 100644 Task/Remove-lines-from-a-file/TUSCRIPT/remove-lines-from-a-file.tuscript create mode 100644 Task/Remove-lines-from-a-file/Tcl/remove-lines-from-a-file.tcl create mode 100644 Task/Remove-lines-from-a-file/UNIX-Shell/remove-lines-from-a-file-1.sh create mode 100644 Task/Remove-lines-from-a-file/UNIX-Shell/remove-lines-from-a-file-2.sh create mode 100644 Task/Rename-a-file/0DESCRIPTION create mode 100644 Task/Rename-a-file/1META.yaml create mode 100644 Task/Rename-a-file/ALGOL-68/rename-a-file.alg create mode 100644 Task/Rename-a-file/AWK/rename-a-file.awk create mode 100644 Task/Rename-a-file/Ada/rename-a-file.ada create mode 100644 Task/Rename-a-file/AutoHotkey/rename-a-file.ahk create mode 100644 Task/Rename-a-file/BASIC/rename-a-file-1.basic create mode 100644 Task/Rename-a-file/BASIC/rename-a-file-2.basic create mode 100644 Task/Rename-a-file/BASIC/rename-a-file-3.basic create mode 100644 Task/Rename-a-file/BASIC/rename-a-file-4.basic create mode 100644 Task/Rename-a-file/BBC-BASIC/rename-a-file-1.bbc create mode 100644 Task/Rename-a-file/BBC-BASIC/rename-a-file-2.bbc create mode 100644 Task/Rename-a-file/Batch-File/rename-a-file.bat create mode 100644 Task/Rename-a-file/Bracmat/rename-a-file.bracmat create mode 100644 Task/Rename-a-file/C++/rename-a-file-1.cpp create mode 100644 Task/Rename-a-file/C++/rename-a-file-2.cpp create mode 100644 Task/Rename-a-file/C-sharp/rename-a-file.cs create mode 100644 Task/Rename-a-file/C/rename-a-file.c create mode 100644 Task/Rename-a-file/Clojure/rename-a-file.clj create mode 100644 Task/Rename-a-file/Common-Lisp/rename-a-file.lisp create mode 100644 Task/Rename-a-file/D/rename-a-file.d create mode 100644 Task/Rename-a-file/DCL/rename-a-file.dcl create mode 100644 Task/Rename-a-file/Delphi/rename-a-file.delphi create mode 100644 Task/Rename-a-file/E/rename-a-file.e create mode 100644 Task/Rename-a-file/Erlang/rename-a-file.erl create mode 100644 Task/Rename-a-file/Factor/rename-a-file.factor create mode 100644 Task/Rename-a-file/Fantom/rename-a-file.fantom create mode 100644 Task/Rename-a-file/Forth/rename-a-file.fth create mode 100644 Task/Rename-a-file/Fortran/rename-a-file.f create mode 100644 Task/Rename-a-file/Go/rename-a-file.go create mode 100644 Task/Rename-a-file/Groovy/rename-a-file-1.groovy create mode 100644 Task/Rename-a-file/Groovy/rename-a-file-2.groovy create mode 100644 Task/Rename-a-file/Haskell/rename-a-file.hs create mode 100644 Task/Rename-a-file/HicEst/rename-a-file.hicest create mode 100644 Task/Rename-a-file/Icon/rename-a-file.icon create mode 100644 Task/Rename-a-file/Io/rename-a-file.io create mode 100644 Task/Rename-a-file/J/rename-a-file-1.j create mode 100644 Task/Rename-a-file/J/rename-a-file-2.j create mode 100644 Task/Rename-a-file/Java/rename-a-file.java create mode 100644 Task/Rename-a-file/JavaScript/rename-a-file.js create mode 100644 Task/Rename-a-file/Joy/rename-a-file.joy create mode 100644 Task/Rename-a-file/Liberty-BASIC/rename-a-file.liberty create mode 100644 Task/Rename-a-file/Locomotive-Basic/rename-a-file.locomotive create mode 100644 Task/Rename-a-file/Lua/rename-a-file.lua create mode 100644 Task/Rename-a-file/MATLAB/rename-a-file.m create mode 100644 Task/Rename-a-file/MAXScript/rename-a-file.maxscript create mode 100644 Task/Rename-a-file/MUMPS/rename-a-file.mumps create mode 100644 Task/Rename-a-file/Maple/rename-a-file.maple create mode 100644 Task/Rename-a-file/Mathematica/rename-a-file.math create mode 100644 Task/Rename-a-file/NewLISP/rename-a-file.newlisp create mode 100644 Task/Rename-a-file/OCaml/rename-a-file.ocaml create mode 100644 Task/Rename-a-file/Objeck/rename-a-file.objeck create mode 100644 Task/Rename-a-file/Objective-C/rename-a-file.m create mode 100644 Task/Rename-a-file/Octave/rename-a-file.octave create mode 100644 Task/Rename-a-file/PARI-GP/rename-a-file.pari create mode 100644 Task/Rename-a-file/PHP/rename-a-file.php create mode 100644 Task/Rename-a-file/Pascal/rename-a-file.pascal create mode 100644 Task/Rename-a-file/Perl-6/rename-a-file.pl6 create mode 100644 Task/Rename-a-file/Perl/rename-a-file.pl create mode 100644 Task/Rename-a-file/PicoLisp/rename-a-file.l create mode 100644 Task/Rename-a-file/Pike/rename-a-file.pike create mode 100644 Task/Rename-a-file/Pop11/rename-a-file.pop11 create mode 100644 Task/Rename-a-file/PowerShell/rename-a-file.psh create mode 100644 Task/Rename-a-file/ProDOS/rename-a-file.dos create mode 100644 Task/Rename-a-file/PureBasic/rename-a-file.purebasic create mode 100644 Task/Rename-a-file/Python/rename-a-file-1.py create mode 100644 Task/Rename-a-file/Python/rename-a-file-2.py create mode 100644 Task/Rename-a-file/R/rename-a-file.r create mode 100644 Task/Rename-a-file/REALbasic/rename-a-file.realbasic create mode 100644 Task/Rename-a-file/REBOL/rename-a-file.rebol create mode 100644 Task/Rename-a-file/REXX/rename-a-file-1.rexx create mode 100644 Task/Rename-a-file/REXX/rename-a-file-2.rexx create mode 100644 Task/Rename-a-file/Racket/rename-a-file.rkt create mode 100644 Task/Rename-a-file/Ruby/rename-a-file-1.rb create mode 100644 Task/Rename-a-file/Ruby/rename-a-file-2.rb create mode 100644 Task/Rename-a-file/Run-BASIC/rename-a-file.run create mode 100644 Task/Rename-a-file/Scala/rename-a-file.scala create mode 100644 Task/Rename-a-file/Scheme/rename-a-file.ss create mode 100644 Task/Rename-a-file/Seed7/rename-a-file.seed7 create mode 100644 Task/Rename-a-file/Slate/rename-a-file.slate create mode 100644 Task/Rename-a-file/Smalltalk/rename-a-file-1.st create mode 100644 Task/Rename-a-file/Smalltalk/rename-a-file-2.st create mode 100644 Task/Rename-a-file/Standard-ML/rename-a-file.ml create mode 100644 Task/Rename-a-file/TUSCRIPT/rename-a-file.tuscript create mode 100644 Task/Rename-a-file/Tcl/rename-a-file-1.tcl create mode 100644 Task/Rename-a-file/Tcl/rename-a-file-2.tcl create mode 100644 Task/Rename-a-file/Toka/rename-a-file.toka create mode 100644 Task/Rename-a-file/TorqueScript/rename-a-file.torquescript create mode 100644 Task/Rename-a-file/UNIX-Shell/rename-a-file.sh create mode 100644 Task/Rename-a-file/Vedit-macro-language/rename-a-file.vedit create mode 100644 Task/Rename-a-file/Visual-Basic-.NET/rename-a-file.visual create mode 100644 Task/Rename-a-file/Yorick/rename-a-file.yorick create mode 100644 Task/Rendezvous/0DESCRIPTION create mode 100644 Task/Rendezvous/1META.yaml create mode 100644 Task/Rendezvous/Ada/rendezvous-1.ada create mode 100644 Task/Rendezvous/Ada/rendezvous-2.ada create mode 100644 Task/Rendezvous/Ada/rendezvous-3.ada create mode 100644 Task/Rendezvous/AutoHotkey/rendezvous.ahk create mode 100644 Task/Rendezvous/C/rendezvous.c create mode 100644 Task/Rendezvous/Go/rendezvous.go create mode 100644 Task/Rendezvous/Oz/rendezvous-1.oz create mode 100644 Task/Rendezvous/Oz/rendezvous-2.oz create mode 100644 Task/Rendezvous/Oz/rendezvous-3.oz create mode 100644 Task/Rendezvous/PicoLisp/rendezvous-1.l create mode 100644 Task/Rendezvous/PicoLisp/rendezvous-2.l create mode 100644 Task/Rendezvous/Tcl/rendezvous.tcl create mode 100644 Task/Repeat-a-string/0DESCRIPTION create mode 100644 Task/Repeat-a-string/1META.yaml create mode 100644 Task/Repeat-a-string/4DOS-Batch/repeat-a-string.4dos create mode 100644 Task/Repeat-a-string/ALGOL-68/repeat-a-string.alg create mode 100644 Task/Repeat-a-string/AWK/repeat-a-string.awk create mode 100644 Task/Repeat-a-string/ActionScript/repeat-a-string-1.as create mode 100644 Task/Repeat-a-string/ActionScript/repeat-a-string-2.as create mode 100644 Task/Repeat-a-string/ActionScript/repeat-a-string-3.as create mode 100644 Task/Repeat-a-string/Ada/repeat-a-string.ada create mode 100644 Task/Repeat-a-string/AppleScript/repeat-a-string.applescript create mode 100644 Task/Repeat-a-string/AutoHotkey/repeat-a-string.ahk create mode 100644 Task/Repeat-a-string/BBC-BASIC/repeat-a-string.bbc create mode 100644 Task/Repeat-a-string/Babel/repeat-a-string-1.pb create mode 100644 Task/Repeat-a-string/Babel/repeat-a-string-2.pb create mode 100644 Task/Repeat-a-string/Batch-File/repeat-a-string-1.bat create mode 100644 Task/Repeat-a-string/Batch-File/repeat-a-string-2.bat create mode 100644 Task/Repeat-a-string/Batch-File/repeat-a-string-3.bat create mode 100644 Task/Repeat-a-string/Bracmat/repeat-a-string.bracmat create mode 100644 Task/Repeat-a-string/Brainf---/repeat-a-string.bf create mode 100644 Task/Repeat-a-string/Brat/repeat-a-string.brat create mode 100644 Task/Repeat-a-string/Burlesque/repeat-a-string.blq create mode 100644 Task/Repeat-a-string/C++/repeat-a-string-1.cpp create mode 100644 Task/Repeat-a-string/C++/repeat-a-string-2.cpp create mode 100644 Task/Repeat-a-string/C-sharp/repeat-a-string-1.cs create mode 100644 Task/Repeat-a-string/C-sharp/repeat-a-string-2.cs create mode 100644 Task/Repeat-a-string/C-sharp/repeat-a-string-3.cs create mode 100644 Task/Repeat-a-string/C-sharp/repeat-a-string-4.cs create mode 100644 Task/Repeat-a-string/C-sharp/repeat-a-string-5.cs create mode 100644 Task/Repeat-a-string/C-sharp/repeat-a-string-6.cs create mode 100644 Task/Repeat-a-string/C/repeat-a-string-1.c create mode 100644 Task/Repeat-a-string/C/repeat-a-string-2.c create mode 100644 Task/Repeat-a-string/C/repeat-a-string-3.c create mode 100644 Task/Repeat-a-string/Clojure/repeat-a-string.clj create mode 100644 Task/Repeat-a-string/Common-Lisp/repeat-a-string-1.lisp create mode 100644 Task/Repeat-a-string/Common-Lisp/repeat-a-string-2.lisp create mode 100644 Task/Repeat-a-string/D/repeat-a-string-1.d create mode 100644 Task/Repeat-a-string/D/repeat-a-string-2.d create mode 100644 Task/Repeat-a-string/DWScript/repeat-a-string-1.dwscript create mode 100644 Task/Repeat-a-string/DWScript/repeat-a-string-2.dwscript create mode 100644 Task/Repeat-a-string/Delphi/repeat-a-string-1.delphi create mode 100644 Task/Repeat-a-string/Delphi/repeat-a-string-2.delphi create mode 100644 Task/Repeat-a-string/Delphi/repeat-a-string-3.delphi create mode 100644 Task/Repeat-a-string/E/repeat-a-string.e create mode 100644 Task/Repeat-a-string/Erlang/repeat-a-string.erl create mode 100644 Task/Repeat-a-string/Euphoria/repeat-a-string-1.euphoria create mode 100644 Task/Repeat-a-string/Euphoria/repeat-a-string-2.euphoria create mode 100644 Task/Repeat-a-string/Factor/repeat-a-string.factor create mode 100644 Task/Repeat-a-string/Forth/repeat-a-string-1.fth create mode 100644 Task/Repeat-a-string/Forth/repeat-a-string-2.fth create mode 100644 Task/Repeat-a-string/Forth/repeat-a-string-3.fth create mode 100644 Task/Repeat-a-string/Fortran/repeat-a-string.f create mode 100644 Task/Repeat-a-string/Frink/repeat-a-string.frink create mode 100644 Task/Repeat-a-string/GAP/repeat-a-string.gap create mode 100644 Task/Repeat-a-string/Go/repeat-a-string-1.go create mode 100644 Task/Repeat-a-string/Go/repeat-a-string-2.go create mode 100644 Task/Repeat-a-string/Groovy/repeat-a-string.groovy create mode 100644 Task/Repeat-a-string/Haskell/repeat-a-string-1.hs create mode 100644 Task/Repeat-a-string/Haskell/repeat-a-string-2.hs create mode 100644 Task/Repeat-a-string/Haskell/repeat-a-string-3.hs create mode 100644 Task/Repeat-a-string/Haskell/repeat-a-string-4.hs create mode 100644 Task/Repeat-a-string/HicEst/repeat-a-string.hicest create mode 100644 Task/Repeat-a-string/Icon/repeat-a-string-1.icon create mode 100644 Task/Repeat-a-string/Icon/repeat-a-string-2.icon create mode 100644 Task/Repeat-a-string/Inform-7/repeat-a-string.inf create mode 100644 Task/Repeat-a-string/J/repeat-a-string.j create mode 100644 Task/Repeat-a-string/Java/repeat-a-string-1.java create mode 100644 Task/Repeat-a-string/Java/repeat-a-string-2.java create mode 100644 Task/Repeat-a-string/JavaScript/repeat-a-string.js create mode 100644 Task/Repeat-a-string/Julia/repeat-a-string.julia create mode 100644 Task/Repeat-a-string/K/repeat-a-string.k create mode 100644 Task/Repeat-a-string/Liberty-BASIC/repeat-a-string.liberty create mode 100644 Task/Repeat-a-string/Logo/repeat-a-string-1.logo create mode 100644 Task/Repeat-a-string/Logo/repeat-a-string-2.logo create mode 100644 Task/Repeat-a-string/Logo/repeat-a-string-3.logo create mode 100644 Task/Repeat-a-string/Lua/repeat-a-string-1.lua create mode 100644 Task/Repeat-a-string/Lua/repeat-a-string-2.lua create mode 100644 Task/Repeat-a-string/MATLAB/repeat-a-string.m create mode 100644 Task/Repeat-a-string/MUMPS/repeat-a-string-1.mumps create mode 100644 Task/Repeat-a-string/MUMPS/repeat-a-string-2.mumps create mode 100644 Task/Repeat-a-string/Maple/repeat-a-string-1.maple create mode 100644 Task/Repeat-a-string/Maple/repeat-a-string-2.maple create mode 100644 Task/Repeat-a-string/Maple/repeat-a-string-3.maple create mode 100644 Task/Repeat-a-string/Mathematica/repeat-a-string.math create mode 100644 Task/Repeat-a-string/Maxima/repeat-a-string.maxima create mode 100644 Task/Repeat-a-string/Mercury/repeat-a-string.mercury create mode 100644 Task/Repeat-a-string/Mirah/repeat-a-string.mirah create mode 100644 Task/Repeat-a-string/NetRexx/repeat-a-string-1.netrexx create mode 100644 Task/Repeat-a-string/NetRexx/repeat-a-string-2.netrexx create mode 100644 Task/Repeat-a-string/NewLISP/repeat-a-string.newlisp create mode 100644 Task/Repeat-a-string/OCaml/repeat-a-string-1.ocaml create mode 100644 Task/Repeat-a-string/OCaml/repeat-a-string-2.ocaml create mode 100644 Task/Repeat-a-string/OCaml/repeat-a-string-3.ocaml create mode 100644 Task/Repeat-a-string/OCaml/repeat-a-string-4.ocaml create mode 100644 Task/Repeat-a-string/OCaml/repeat-a-string-5.ocaml create mode 100644 Task/Repeat-a-string/Objeck/repeat-a-string.objeck create mode 100644 Task/Repeat-a-string/Objective-C/repeat-a-string-1.m create mode 100644 Task/Repeat-a-string/Objective-C/repeat-a-string-2.m create mode 100644 Task/Repeat-a-string/OpenEdge-Progress/repeat-a-string.openedge create mode 100644 Task/Repeat-a-string/OxygenBasic/repeat-a-string.oxy create mode 100644 Task/Repeat-a-string/Oz/repeat-a-string.oz create mode 100644 Task/Repeat-a-string/PARI-GP/repeat-a-string.pari create mode 100644 Task/Repeat-a-string/PHP/repeat-a-string.php create mode 100644 Task/Repeat-a-string/PL-I/repeat-a-string.pli create mode 100644 Task/Repeat-a-string/Perl-6/repeat-a-string.pl6 create mode 100644 Task/Repeat-a-string/Perl/repeat-a-string.pl create mode 100644 Task/Repeat-a-string/PicoLisp/repeat-a-string-1.l create mode 100644 Task/Repeat-a-string/PicoLisp/repeat-a-string-2.l create mode 100644 Task/Repeat-a-string/Pike/repeat-a-string.pike create mode 100644 Task/Repeat-a-string/PostScript/repeat-a-string.ps create mode 100644 Task/Repeat-a-string/PowerBASIC/repeat-a-string.powerbasic create mode 100644 Task/Repeat-a-string/PowerShell/repeat-a-string.psh create mode 100644 Task/Repeat-a-string/Prolog/repeat-a-string.pro create mode 100644 Task/Repeat-a-string/Pure/repeat-a-string.pure create mode 100644 Task/Repeat-a-string/PureBasic/repeat-a-string.purebasic create mode 100644 Task/Repeat-a-string/Python/repeat-a-string-1.py create mode 100644 Task/Repeat-a-string/Python/repeat-a-string-2.py create mode 100644 Task/Repeat-a-string/R/repeat-a-string.r create mode 100644 Task/Repeat-a-string/REALbasic/repeat-a-string.realbasic create mode 100644 Task/Repeat-a-string/REBOL/repeat-a-string.rebol create mode 100644 Task/Repeat-a-string/REXX/repeat-a-string.rexx create mode 100644 Task/Repeat-a-string/Racket/repeat-a-string-1.rkt create mode 100644 Task/Repeat-a-string/Racket/repeat-a-string-2.rkt create mode 100644 Task/Repeat-a-string/Racket/repeat-a-string-3.rkt create mode 100644 Task/Repeat-a-string/Retro/repeat-a-string.retro create mode 100644 Task/Repeat-a-string/Ruby/repeat-a-string-1.rb create mode 100644 Task/Repeat-a-string/Ruby/repeat-a-string-2.rb create mode 100644 Task/Repeat-a-string/Run-BASIC/repeat-a-string.run create mode 100644 Task/Repeat-a-string/SNOBOL4/repeat-a-string.sno create mode 100644 Task/Repeat-a-string/SQL/repeat-a-string.sql create mode 100644 Task/Repeat-a-string/Scala/repeat-a-string.scala create mode 100644 Task/Repeat-a-string/Scheme/repeat-a-string-1.ss create mode 100644 Task/Repeat-a-string/Scheme/repeat-a-string-2.ss create mode 100644 Task/Repeat-a-string/Scheme/repeat-a-string-3.ss create mode 100644 Task/Repeat-a-string/Seed7/repeat-a-string.seed7 create mode 100644 Task/Repeat-a-string/Smalltalk/repeat-a-string-1.st create mode 100644 Task/Repeat-a-string/Smalltalk/repeat-a-string-2.st create mode 100644 Task/Repeat-a-string/Smalltalk/repeat-a-string-3.st create mode 100644 Task/Repeat-a-string/Smalltalk/repeat-a-string-4.st create mode 100644 Task/Repeat-a-string/Smalltalk/repeat-a-string-5.st create mode 100644 Task/Repeat-a-string/Smalltalk/repeat-a-string-6.st create mode 100644 Task/Repeat-a-string/Standard-ML/repeat-a-string-1.ml create mode 100644 Task/Repeat-a-string/Standard-ML/repeat-a-string-2.ml create mode 100644 Task/Repeat-a-string/Standard-ML/repeat-a-string-3.ml create mode 100644 Task/Repeat-a-string/Suneido/repeat-a-string.suneido create mode 100644 Task/Repeat-a-string/TUSCRIPT/repeat-a-string.tuscript create mode 100644 Task/Repeat-a-string/Tcl/repeat-a-string.tcl create mode 100644 Task/Repeat-a-string/TorqueScript/repeat-a-string.torquescript create mode 100644 Task/Repeat-a-string/UNIX-Shell/repeat-a-string-1.sh create mode 100644 Task/Repeat-a-string/UNIX-Shell/repeat-a-string-2.sh create mode 100644 Task/Repeat-a-string/UNIX-Shell/repeat-a-string-3.sh create mode 100644 Task/Repeat-a-string/UNIX-Shell/repeat-a-string-4.sh create mode 100644 Task/Repeat-a-string/UNIX-Shell/repeat-a-string-5.sh create mode 100644 Task/Repeat-a-string/Ursala/repeat-a-string.ursala create mode 100644 Task/Repeat-a-string/VBA/repeat-a-string.vba create mode 100644 Task/Repeat-a-string/Vala/repeat-a-string-1.vala create mode 100644 Task/Repeat-a-string/Vala/repeat-a-string-2.vala create mode 100644 Task/Repeat-a-string/Vedit-macro-language/repeat-a-string.vedit create mode 100644 Task/Repeat-a-string/Visual-Basic-.NET/repeat-a-string.visual create mode 100644 Task/Repeat-a-string/XPL0/repeat-a-string.xpl0 create mode 100644 Task/Repeat-a-string/Yorick/repeat-a-string.yorick create mode 100644 Task/Resistor-mesh/0DESCRIPTION create mode 100644 Task/Resistor-mesh/Ada/resistor-mesh.ada create mode 100644 Task/Resistor-mesh/BBC-BASIC/resistor-mesh.bbc create mode 100644 Task/Resistor-mesh/C/resistor-mesh.c create mode 100644 Task/Resistor-mesh/D/resistor-mesh.d create mode 100644 Task/Resistor-mesh/Euler-Math-Toolbox/resistor-mesh-1.euler create mode 100644 Task/Resistor-mesh/Euler-Math-Toolbox/resistor-mesh-2.euler create mode 100644 Task/Resistor-mesh/Euler-Math-Toolbox/resistor-mesh-3.euler create mode 100644 Task/Resistor-mesh/J/resistor-mesh-1.j create mode 100644 Task/Resistor-mesh/J/resistor-mesh-2.j create mode 100644 Task/Resistor-mesh/J/resistor-mesh-3.j create mode 100644 Task/Resistor-mesh/Mathematica/resistor-mesh-1.math create mode 100644 Task/Resistor-mesh/Mathematica/resistor-mesh-2.math create mode 100644 Task/Resistor-mesh/Maxima/resistor-mesh.maxima create mode 100644 Task/Resistor-mesh/Perl-6/resistor-mesh.pl6 create mode 100644 Task/Resistor-mesh/Perl/resistor-mesh.pl create mode 100644 Task/Resistor-mesh/Python/resistor-mesh.py create mode 100644 Task/Resistor-mesh/REXX/resistor-mesh.rexx create mode 100644 Task/Resistor-mesh/Tcl/resistor-mesh-1.tcl create mode 100644 Task/Resistor-mesh/Tcl/resistor-mesh-2.tcl create mode 100644 Task/Resistor-mesh/XPL0/resistor-mesh.xpl0 create mode 100644 Task/Respond-to-an-unknown-method-call/0DESCRIPTION create mode 100644 Task/Respond-to-an-unknown-method-call/1META.yaml create mode 100644 Task/Respond-to-an-unknown-method-call/Brat/respond-to-an-unknown-method-call.brat create mode 100644 Task/Respond-to-an-unknown-method-call/C++/respond-to-an-unknown-method-call.cpp create mode 100644 Task/Respond-to-an-unknown-method-call/Common-Lisp/respond-to-an-unknown-method-call-1.lisp create mode 100644 Task/Respond-to-an-unknown-method-call/Common-Lisp/respond-to-an-unknown-method-call-2.lisp create mode 100644 Task/Respond-to-an-unknown-method-call/Common-Lisp/respond-to-an-unknown-method-call-3.lisp create mode 100644 Task/Respond-to-an-unknown-method-call/D/respond-to-an-unknown-method-call.d create mode 100644 Task/Respond-to-an-unknown-method-call/E/respond-to-an-unknown-method-call.e create mode 100644 Task/Respond-to-an-unknown-method-call/Fancy/respond-to-an-unknown-method-call.fancy create mode 100644 Task/Respond-to-an-unknown-method-call/Fantom/respond-to-an-unknown-method-call.fantom create mode 100644 Task/Respond-to-an-unknown-method-call/Go/respond-to-an-unknown-method-call-1.go create mode 100644 Task/Respond-to-an-unknown-method-call/Go/respond-to-an-unknown-method-call-2.go create mode 100644 Task/Respond-to-an-unknown-method-call/Go/respond-to-an-unknown-method-call-3.go create mode 100644 Task/Respond-to-an-unknown-method-call/J/respond-to-an-unknown-method-call-1.j create mode 100644 Task/Respond-to-an-unknown-method-call/J/respond-to-an-unknown-method-call-2.j create mode 100644 Task/Respond-to-an-unknown-method-call/JavaScript/respond-to-an-unknown-method-call.js create mode 100644 Task/Respond-to-an-unknown-method-call/Lua/respond-to-an-unknown-method-call.lua create mode 100644 Task/Respond-to-an-unknown-method-call/Objective-C/respond-to-an-unknown-method-call.m create mode 100644 Task/Respond-to-an-unknown-method-call/Oz/respond-to-an-unknown-method-call.oz create mode 100644 Task/Respond-to-an-unknown-method-call/PHP/respond-to-an-unknown-method-call.php create mode 100644 Task/Respond-to-an-unknown-method-call/Perl-6/respond-to-an-unknown-method-call.pl6 create mode 100644 Task/Respond-to-an-unknown-method-call/Perl/respond-to-an-unknown-method-call.pl create mode 100644 Task/Respond-to-an-unknown-method-call/PicoLisp/respond-to-an-unknown-method-call-1.l create mode 100644 Task/Respond-to-an-unknown-method-call/PicoLisp/respond-to-an-unknown-method-call-2.l create mode 100644 Task/Respond-to-an-unknown-method-call/Pike/respond-to-an-unknown-method-call.pike create mode 100644 Task/Respond-to-an-unknown-method-call/Python/respond-to-an-unknown-method-call.py create mode 100644 Task/Respond-to-an-unknown-method-call/Ruby/respond-to-an-unknown-method-call.rb create mode 100644 Task/Respond-to-an-unknown-method-call/Scala/respond-to-an-unknown-method-call.scala create mode 100644 Task/Respond-to-an-unknown-method-call/Slate/respond-to-an-unknown-method-call-1.slate create mode 100644 Task/Respond-to-an-unknown-method-call/Slate/respond-to-an-unknown-method-call-2.slate create mode 100644 Task/Respond-to-an-unknown-method-call/Smalltalk/respond-to-an-unknown-method-call-1.st create mode 100644 Task/Respond-to-an-unknown-method-call/Smalltalk/respond-to-an-unknown-method-call-2.st create mode 100644 Task/Respond-to-an-unknown-method-call/Smalltalk/respond-to-an-unknown-method-call-3.st create mode 100644 Task/Respond-to-an-unknown-method-call/Smalltalk/respond-to-an-unknown-method-call-4.st create mode 100644 Task/Respond-to-an-unknown-method-call/Tcl/respond-to-an-unknown-method-call.tcl create mode 100644 Task/Respond-to-an-unknown-method-call/UNIX-Shell/respond-to-an-unknown-method-call.sh create mode 100644 Task/Return-multiple-values/0DESCRIPTION create mode 100644 Task/Return-multiple-values/1META.yaml create mode 100644 Task/Return-multiple-values/ACL2/return-multiple-values.acl2 create mode 100644 Task/Return-multiple-values/ATS/return-multiple-values.ats create mode 100644 Task/Return-multiple-values/Ada/return-multiple-values.ada create mode 100644 Task/Return-multiple-values/AutoHotkey/return-multiple-values.ahk create mode 100644 Task/Return-multiple-values/AutoIt/return-multiple-values.autoit create mode 100644 Task/Return-multiple-values/BBC-BASIC/return-multiple-values.bbc create mode 100644 Task/Return-multiple-values/Bracmat/return-multiple-values-1.bracmat create mode 100644 Task/Return-multiple-values/Bracmat/return-multiple-values-2.bracmat create mode 100644 Task/Return-multiple-values/C++/return-multiple-values.cpp create mode 100644 Task/Return-multiple-values/C/return-multiple-values.c create mode 100644 Task/Return-multiple-values/CMake/return-multiple-values.cmake create mode 100644 Task/Return-multiple-values/Clojure/return-multiple-values-1.clj create mode 100644 Task/Return-multiple-values/Clojure/return-multiple-values-2.clj create mode 100644 Task/Return-multiple-values/Common-Lisp/return-multiple-values-1.lisp create mode 100644 Task/Return-multiple-values/Common-Lisp/return-multiple-values-10.lisp create mode 100644 Task/Return-multiple-values/Common-Lisp/return-multiple-values-11.lisp create mode 100644 Task/Return-multiple-values/Common-Lisp/return-multiple-values-2.lisp create mode 100644 Task/Return-multiple-values/Common-Lisp/return-multiple-values-3.lisp create mode 100644 Task/Return-multiple-values/Common-Lisp/return-multiple-values-4.lisp create mode 100644 Task/Return-multiple-values/Common-Lisp/return-multiple-values-5.lisp create mode 100644 Task/Return-multiple-values/Common-Lisp/return-multiple-values-6.lisp create mode 100644 Task/Return-multiple-values/Common-Lisp/return-multiple-values-7.lisp create mode 100644 Task/Return-multiple-values/Common-Lisp/return-multiple-values-8.lisp create mode 100644 Task/Return-multiple-values/Common-Lisp/return-multiple-values-9.lisp create mode 100644 Task/Return-multiple-values/D/return-multiple-values.d create mode 100644 Task/Return-multiple-values/Delphi/return-multiple-values.delphi create mode 100644 Task/Return-multiple-values/Euphoria/return-multiple-values.euphoria create mode 100644 Task/Return-multiple-values/FALSE/return-multiple-values.false create mode 100644 Task/Return-multiple-values/Factor/return-multiple-values.factor create mode 100644 Task/Return-multiple-values/Forth/return-multiple-values.fth create mode 100644 Task/Return-multiple-values/Go/return-multiple-values-1.go create mode 100644 Task/Return-multiple-values/Go/return-multiple-values-2.go create mode 100644 Task/Return-multiple-values/Go/return-multiple-values-3.go create mode 100644 Task/Return-multiple-values/Groovy/return-multiple-values-1.groovy create mode 100644 Task/Return-multiple-values/Groovy/return-multiple-values-2.groovy create mode 100644 Task/Return-multiple-values/Haskell/return-multiple-values-1.hs create mode 100644 Task/Return-multiple-values/Haskell/return-multiple-values-2.hs create mode 100644 Task/Return-multiple-values/Icon/return-multiple-values.icon create mode 100644 Task/Return-multiple-values/J/return-multiple-values.j create mode 100644 Task/Return-multiple-values/Java/return-multiple-values.java create mode 100644 Task/Return-multiple-values/Julia/return-multiple-values.julia create mode 100644 Task/Return-multiple-values/Liberty-BASIC/return-multiple-values.liberty create mode 100644 Task/Return-multiple-values/Lua/return-multiple-values.lua create mode 100644 Task/Return-multiple-values/MATLAB/return-multiple-values-1.m create mode 100644 Task/Return-multiple-values/MATLAB/return-multiple-values-2.m create mode 100644 Task/Return-multiple-values/Maple/return-multiple-values-1.maple create mode 100644 Task/Return-multiple-values/Maple/return-multiple-values-2.maple create mode 100644 Task/Return-multiple-values/Mathematica/return-multiple-values.math create mode 100644 Task/Return-multiple-values/Maxima/return-multiple-values.maxima create mode 100644 Task/Return-multiple-values/Mercury/return-multiple-values.mercury create mode 100644 Task/Return-multiple-values/NetRexx/return-multiple-values.netrexx create mode 100644 Task/Return-multiple-values/OCaml/return-multiple-values-1.ocaml create mode 100644 Task/Return-multiple-values/OCaml/return-multiple-values-2.ocaml create mode 100644 Task/Return-multiple-values/OCaml/return-multiple-values-3.ocaml create mode 100644 Task/Return-multiple-values/OCaml/return-multiple-values-4.ocaml create mode 100644 Task/Return-multiple-values/OCaml/return-multiple-values-5.ocaml create mode 100644 Task/Return-multiple-values/OxygenBasic/return-multiple-values.oxy create mode 100644 Task/Return-multiple-values/PARI-GP/return-multiple-values.pari create mode 100644 Task/Return-multiple-values/PHP/return-multiple-values-1.php create mode 100644 Task/Return-multiple-values/PHP/return-multiple-values-2.php create mode 100644 Task/Return-multiple-values/PL-I/return-multiple-values-1.pli create mode 100644 Task/Return-multiple-values/PL-I/return-multiple-values-2.pli create mode 100644 Task/Return-multiple-values/PL-I/return-multiple-values-3.pli create mode 100644 Task/Return-multiple-values/Perl-6/return-multiple-values.pl6 create mode 100644 Task/Return-multiple-values/Perl/return-multiple-values.pl create mode 100644 Task/Return-multiple-values/PicoLisp/return-multiple-values-1.l create mode 100644 Task/Return-multiple-values/PicoLisp/return-multiple-values-2.l create mode 100644 Task/Return-multiple-values/Pike/return-multiple-values.pike create mode 100644 Task/Return-multiple-values/PureBasic/return-multiple-values.purebasic create mode 100644 Task/Return-multiple-values/Python/return-multiple-values-1.py create mode 100644 Task/Return-multiple-values/Python/return-multiple-values-2.py create mode 100644 Task/Return-multiple-values/R/return-multiple-values.r create mode 100644 Task/Return-multiple-values/REXX/return-multiple-values.rexx create mode 100644 Task/Return-multiple-values/Retro/return-multiple-values.retro create mode 100644 Task/Return-multiple-values/Ruby/return-multiple-values-1.rb create mode 100644 Task/Return-multiple-values/Ruby/return-multiple-values-2.rb create mode 100644 Task/Return-multiple-values/Ruby/return-multiple-values-3.rb create mode 100644 Task/Return-multiple-values/Run-BASIC/return-multiple-values.run create mode 100644 Task/Return-multiple-values/Scala/return-multiple-values-1.scala create mode 100644 Task/Return-multiple-values/Scala/return-multiple-values-2.scala create mode 100644 Task/Return-multiple-values/Scheme/return-multiple-values-1.ss create mode 100644 Task/Return-multiple-values/Scheme/return-multiple-values-2.ss create mode 100644 Task/Return-multiple-values/Scheme/return-multiple-values-3.ss create mode 100644 Task/Return-multiple-values/Scheme/return-multiple-values-4.ss create mode 100644 Task/Return-multiple-values/Seed7/return-multiple-values.seed7 create mode 100644 Task/Return-multiple-values/Standard-ML/return-multiple-values-1.ml create mode 100644 Task/Return-multiple-values/Standard-ML/return-multiple-values-2.ml create mode 100644 Task/Return-multiple-values/TXR/return-multiple-values-1.txr create mode 100644 Task/Return-multiple-values/TXR/return-multiple-values-2.txr create mode 100644 Task/Return-multiple-values/TXR/return-multiple-values-3.txr create mode 100644 Task/Return-multiple-values/TXR/return-multiple-values-4.txr create mode 100644 Task/Return-multiple-values/Tcl/return-multiple-values-1.tcl create mode 100644 Task/Return-multiple-values/Tcl/return-multiple-values-2.tcl create mode 100644 Task/Return-multiple-values/UNIX-Shell/return-multiple-values.sh create mode 100644 Task/Return-multiple-values/XPL0/return-multiple-values.xpl0 create mode 100644 Task/Reverse-a-string/0815/reverse-a-string-1.0815 create mode 100644 Task/Reverse-a-string/0815/reverse-a-string-2.0815 create mode 100644 Task/Reverse-a-string/0DESCRIPTION create mode 100644 Task/Reverse-a-string/1META.yaml create mode 100644 Task/Reverse-a-string/ACL2/reverse-a-string.acl2 create mode 100644 Task/Reverse-a-string/ALGOL-68/reverse-a-string-1.alg create mode 100644 Task/Reverse-a-string/ALGOL-68/reverse-a-string-2.alg create mode 100644 Task/Reverse-a-string/AWK/reverse-a-string-1.awk create mode 100644 Task/Reverse-a-string/AWK/reverse-a-string-2.awk create mode 100644 Task/Reverse-a-string/ActionScript/reverse-a-string.as create mode 100644 Task/Reverse-a-string/Ada/reverse-a-string.ada create mode 100644 Task/Reverse-a-string/Agda2/reverse-a-string.agda2 create mode 100644 Task/Reverse-a-string/AppleScript/reverse-a-string.applescript create mode 100644 Task/Reverse-a-string/AutoHotkey/reverse-a-string-1.ahk create mode 100644 Task/Reverse-a-string/AutoHotkey/reverse-a-string-2.ahk create mode 100644 Task/Reverse-a-string/AutoIt/reverse-a-string.autoit create mode 100644 Task/Reverse-a-string/BASIC/reverse-a-string.basic create mode 100644 Task/Reverse-a-string/BBC-BASIC/reverse-a-string.bbc create mode 100644 Task/Reverse-a-string/Babel/reverse-a-string.pb create mode 100644 Task/Reverse-a-string/Batch-File/reverse-a-string.bat create mode 100644 Task/Reverse-a-string/Befunge/reverse-a-string.bf create mode 100644 Task/Reverse-a-string/Bracmat/reverse-a-string.bracmat create mode 100644 Task/Reverse-a-string/Brainf---/reverse-a-string-1.bf create mode 100644 Task/Reverse-a-string/Brainf---/reverse-a-string-2.bf create mode 100644 Task/Reverse-a-string/Brat/reverse-a-string.brat create mode 100644 Task/Reverse-a-string/Burlesque/reverse-a-string.blq create mode 100644 Task/Reverse-a-string/C++/reverse-a-string.cpp create mode 100644 Task/Reverse-a-string/C/reverse-a-string-1.c create mode 100644 Task/Reverse-a-string/C/reverse-a-string-2.c create mode 100644 Task/Reverse-a-string/COBOL/reverse-a-string.cobol create mode 100644 Task/Reverse-a-string/Clojure/reverse-a-string-1.clj create mode 100644 Task/Reverse-a-string/Clojure/reverse-a-string-2.clj create mode 100644 Task/Reverse-a-string/Clojure/reverse-a-string-3.clj create mode 100644 Task/Reverse-a-string/CoffeeScript/reverse-a-string.coffeescript create mode 100644 Task/Reverse-a-string/ColdFusion/reverse-a-string.cfm create mode 100644 Task/Reverse-a-string/Common-Lisp/reverse-a-string.lisp create mode 100644 Task/Reverse-a-string/D/reverse-a-string.d create mode 100644 Task/Reverse-a-string/Dart/reverse-a-string.dart create mode 100644 Task/Reverse-a-string/Delphi/reverse-a-string-1.delphi create mode 100644 Task/Reverse-a-string/Delphi/reverse-a-string-2.delphi create mode 100644 Task/Reverse-a-string/E/reverse-a-string.e create mode 100644 Task/Reverse-a-string/EGL/reverse-a-string.egl create mode 100644 Task/Reverse-a-string/Eiffel/reverse-a-string.e create mode 100644 Task/Reverse-a-string/Emacs-Lisp/reverse-a-string.l create mode 100644 Task/Reverse-a-string/Erlang/reverse-a-string-1.erl create mode 100644 Task/Reverse-a-string/Erlang/reverse-a-string-2.erl create mode 100644 Task/Reverse-a-string/Euler-Math-Toolbox/reverse-a-string.euler create mode 100644 Task/Reverse-a-string/Euphoria/reverse-a-string.euphoria create mode 100644 Task/Reverse-a-string/FBSL/reverse-a-string-1.fbsl create mode 100644 Task/Reverse-a-string/FBSL/reverse-a-string-2.fbsl create mode 100644 Task/Reverse-a-string/FBSL/reverse-a-string-3.fbsl create mode 100644 Task/Reverse-a-string/FBSL/reverse-a-string-4.fbsl create mode 100644 Task/Reverse-a-string/Factor/reverse-a-string-1.factor create mode 100644 Task/Reverse-a-string/Factor/reverse-a-string-2.factor create mode 100644 Task/Reverse-a-string/Fancy/reverse-a-string.fancy create mode 100644 Task/Reverse-a-string/Forth/reverse-a-string.fth create mode 100644 Task/Reverse-a-string/Fortran/reverse-a-string-1.f create mode 100644 Task/Reverse-a-string/Fortran/reverse-a-string-2.f create mode 100644 Task/Reverse-a-string/Frink/reverse-a-string.frink create mode 100644 Task/Reverse-a-string/GAP/reverse-a-string.gap create mode 100644 Task/Reverse-a-string/Gema/reverse-a-string-1.gema create mode 100644 Task/Reverse-a-string/Gema/reverse-a-string-2.gema create mode 100644 Task/Reverse-a-string/Go/reverse-a-string.go create mode 100644 Task/Reverse-a-string/Groovy/reverse-a-string.groovy create mode 100644 Task/Reverse-a-string/Haskell/reverse-a-string-1.hs create mode 100644 Task/Reverse-a-string/Haskell/reverse-a-string-2.hs create mode 100644 Task/Reverse-a-string/HicEst/reverse-a-string.hicest create mode 100644 Task/Reverse-a-string/Icon/reverse-a-string.icon create mode 100644 Task/Reverse-a-string/Io/reverse-a-string.io create mode 100644 Task/Reverse-a-string/J/reverse-a-string-1.j create mode 100644 Task/Reverse-a-string/J/reverse-a-string-2.j create mode 100644 Task/Reverse-a-string/J/reverse-a-string-3.j create mode 100644 Task/Reverse-a-string/J/reverse-a-string-4.j create mode 100644 Task/Reverse-a-string/Java/reverse-a-string-1.java create mode 100644 Task/Reverse-a-string/Java/reverse-a-string-2.java create mode 100644 Task/Reverse-a-string/JavaScript/reverse-a-string.js create mode 100644 Task/Reverse-a-string/Julia/reverse-a-string.julia create mode 100644 Task/Reverse-a-string/Lang5/reverse-a-string.lang5 create mode 100644 Task/Reverse-a-string/Liberty-BASIC/reverse-a-string.liberty create mode 100644 Task/Reverse-a-string/Logo/reverse-a-string.logo create mode 100644 Task/Reverse-a-string/Lua/reverse-a-string.lua create mode 100644 Task/Reverse-a-string/M4/reverse-a-string.m4 create mode 100644 Task/Reverse-a-string/MATLAB/reverse-a-string.m create mode 100644 Task/Reverse-a-string/MAXScript/reverse-a-string.maxscript create mode 100644 Task/Reverse-a-string/MUMPS/reverse-a-string.mumps create mode 100644 Task/Reverse-a-string/Maple/reverse-a-string.maple create mode 100644 Task/Reverse-a-string/Mathematica/reverse-a-string.math create mode 100644 Task/Reverse-a-string/Maxima/reverse-a-string.maxima create mode 100644 Task/Reverse-a-string/Mirah/reverse-a-string.mirah create mode 100644 Task/Reverse-a-string/Modula-3/reverse-a-string.mod3 create mode 100644 Task/Reverse-a-string/Nemerle/reverse-a-string-1.nemerle create mode 100644 Task/Reverse-a-string/Nemerle/reverse-a-string-2.nemerle create mode 100644 Task/Reverse-a-string/NetRexx/reverse-a-string.netrexx create mode 100644 Task/Reverse-a-string/NewLISP/reverse-a-string.newlisp create mode 100644 Task/Reverse-a-string/Nial/reverse-a-string.nial create mode 100644 Task/Reverse-a-string/Nimrod/reverse-a-string.nimrod create mode 100644 Task/Reverse-a-string/OCaml/reverse-a-string-1.ocaml create mode 100644 Task/Reverse-a-string/OCaml/reverse-a-string-2.ocaml create mode 100644 Task/Reverse-a-string/OCaml/reverse-a-string-3.ocaml create mode 100644 Task/Reverse-a-string/Objeck/reverse-a-string.objeck create mode 100644 Task/Reverse-a-string/Objective-C/reverse-a-string-1.m create mode 100644 Task/Reverse-a-string/Objective-C/reverse-a-string-2.m create mode 100644 Task/Reverse-a-string/Objective-C/reverse-a-string-3.m create mode 100644 Task/Reverse-a-string/Objective-C/reverse-a-string-4.m create mode 100644 Task/Reverse-a-string/Octave/reverse-a-string.octave create mode 100644 Task/Reverse-a-string/OpenEdge-Progress/reverse-a-string.openedge create mode 100644 Task/Reverse-a-string/OxygenBasic/reverse-a-string-1.oxy create mode 100644 Task/Reverse-a-string/OxygenBasic/reverse-a-string-2.oxy create mode 100644 Task/Reverse-a-string/Oz/reverse-a-string-1.oz create mode 100644 Task/Reverse-a-string/Oz/reverse-a-string-2.oz create mode 100644 Task/Reverse-a-string/PARI-GP/reverse-a-string.pari create mode 100644 Task/Reverse-a-string/PHP/reverse-a-string-1.php create mode 100644 Task/Reverse-a-string/PHP/reverse-a-string-2.php create mode 100644 Task/Reverse-a-string/PL-I/reverse-a-string.pli create mode 100644 Task/Reverse-a-string/Pascal/reverse-a-string-1.pascal create mode 100644 Task/Reverse-a-string/Pascal/reverse-a-string-2.pascal create mode 100644 Task/Reverse-a-string/Pascal/reverse-a-string-3.pascal create mode 100644 Task/Reverse-a-string/Perl-6/reverse-a-string.pl6 create mode 100644 Task/Reverse-a-string/Perl/reverse-a-string-1.pl create mode 100644 Task/Reverse-a-string/Perl/reverse-a-string-2.pl create mode 100644 Task/Reverse-a-string/PicoLisp/reverse-a-string.l create mode 100644 Task/Reverse-a-string/Pop11/reverse-a-string.pop11 create mode 100644 Task/Reverse-a-string/PostScript/reverse-a-string-1.ps create mode 100644 Task/Reverse-a-string/PostScript/reverse-a-string-2.ps create mode 100644 Task/Reverse-a-string/PowerShell/reverse-a-string-1.psh create mode 100644 Task/Reverse-a-string/PowerShell/reverse-a-string-2.psh create mode 100644 Task/Reverse-a-string/PowerShell/reverse-a-string-3.psh create mode 100644 Task/Reverse-a-string/PowerShell/reverse-a-string-4.psh create mode 100644 Task/Reverse-a-string/PowerShell/reverse-a-string-5.psh create mode 100644 Task/Reverse-a-string/PowerShell/reverse-a-string-6.psh create mode 100644 Task/Reverse-a-string/Prolog/reverse-a-string-1.pro create mode 100644 Task/Reverse-a-string/Prolog/reverse-a-string-2.pro create mode 100644 Task/Reverse-a-string/Prolog/reverse-a-string-3.pro create mode 100644 Task/Reverse-a-string/Protium/reverse-a-string-1.protium create mode 100644 Task/Reverse-a-string/Protium/reverse-a-string-2.protium create mode 100644 Task/Reverse-a-string/Protium/reverse-a-string-3.protium create mode 100644 Task/Reverse-a-string/PureBasic/reverse-a-string.purebasic create mode 100644 Task/Reverse-a-string/Python/reverse-a-string-1.py create mode 100644 Task/Reverse-a-string/Python/reverse-a-string-2.py create mode 100644 Task/Reverse-a-string/Python/reverse-a-string-3.py create mode 100644 Task/Reverse-a-string/Qi/reverse-a-string.qi create mode 100644 Task/Reverse-a-string/R/reverse-a-string-1.r create mode 100644 Task/Reverse-a-string/R/reverse-a-string-2.r create mode 100644 Task/Reverse-a-string/R/reverse-a-string-3.r create mode 100644 Task/Reverse-a-string/REBOL/reverse-a-string-1.rebol create mode 100644 Task/Reverse-a-string/REBOL/reverse-a-string-2.rebol create mode 100644 Task/Reverse-a-string/REXX/reverse-a-string-1.rexx create mode 100644 Task/Reverse-a-string/REXX/reverse-a-string-2.rexx create mode 100644 Task/Reverse-a-string/REXX/reverse-a-string-3.rexx create mode 100644 Task/Reverse-a-string/REXX/reverse-a-string-4.rexx create mode 100644 Task/Reverse-a-string/RLaB/reverse-a-string.rlab create mode 100644 Task/Reverse-a-string/Racket/reverse-a-string.rkt create mode 100644 Task/Reverse-a-string/Rascal/reverse-a-string.rascal create mode 100644 Task/Reverse-a-string/Retro/reverse-a-string.retro create mode 100644 Task/Reverse-a-string/Ruby/reverse-a-string-1.rb create mode 100644 Task/Reverse-a-string/Ruby/reverse-a-string-2.rb create mode 100644 Task/Reverse-a-string/Run-BASIC/reverse-a-string.run create mode 100644 Task/Reverse-a-string/SAS/reverse-a-string.sas create mode 100644 Task/Reverse-a-string/SNOBOL4/reverse-a-string.sno create mode 100644 Task/Reverse-a-string/Sather/reverse-a-string.sa create mode 100644 Task/Reverse-a-string/Scala/reverse-a-string-1.scala create mode 100644 Task/Reverse-a-string/Scala/reverse-a-string-2.scala create mode 100644 Task/Reverse-a-string/Scala/reverse-a-string-3.scala create mode 100644 Task/Reverse-a-string/Scheme/reverse-a-string.ss create mode 100644 Task/Reverse-a-string/Sed/reverse-a-string.sed create mode 100644 Task/Reverse-a-string/Seed7/reverse-a-string.seed7 create mode 100644 Task/Reverse-a-string/Slate/reverse-a-string-1.slate create mode 100644 Task/Reverse-a-string/Slate/reverse-a-string-2.slate create mode 100644 Task/Reverse-a-string/Smalltalk/reverse-a-string-1.st create mode 100644 Task/Reverse-a-string/Smalltalk/reverse-a-string-2.st create mode 100644 Task/Reverse-a-string/Standard-ML/reverse-a-string.ml create mode 100644 Task/Reverse-a-string/TI-83-BASIC/reverse-a-string.ti-83 create mode 100644 Task/Reverse-a-string/TUSCRIPT/reverse-a-string.tuscript create mode 100644 Task/Reverse-a-string/Tcl/reverse-a-string.tcl create mode 100644 Task/Reverse-a-string/Turing/reverse-a-string.turing create mode 100644 Task/Reverse-a-string/Unlambda/reverse-a-string.unlambda create mode 100644 Task/Reverse-a-string/Ursala/reverse-a-string.ursala create mode 100644 Task/Reverse-a-string/VBA/reverse-a-string-1.vba create mode 100644 Task/Reverse-a-string/VBA/reverse-a-string-2.vba create mode 100644 Task/Reverse-a-string/Vedit-macro-language/reverse-a-string-1.vedit create mode 100644 Task/Reverse-a-string/Vedit-macro-language/reverse-a-string-2.vedit create mode 100644 Task/Reverse-a-string/Visual-Basic-.NET/reverse-a-string.visual create mode 100644 Task/Reverse-a-string/XPL0/reverse-a-string.xpl0 create mode 100644 Task/Reverse-a-string/Yorick/reverse-a-string.yorick create mode 100644 Task/Rock-paper-scissors/0DESCRIPTION create mode 100644 Task/Rock-paper-scissors/1META.yaml create mode 100644 Task/Rock-paper-scissors/Ada/rock-paper-scissors.ada create mode 100644 Task/Rock-paper-scissors/AutoHotkey/rock-paper-scissors.ahk create mode 100644 Task/Rock-paper-scissors/AutoIt/rock-paper-scissors.autoit create mode 100644 Task/Rock-paper-scissors/BASIC/rock-paper-scissors-1.basic create mode 100644 Task/Rock-paper-scissors/BASIC/rock-paper-scissors-2.basic create mode 100644 Task/Rock-paper-scissors/BBC-BASIC/rock-paper-scissors.bbc create mode 100644 Task/Rock-paper-scissors/C++/rock-paper-scissors.cpp create mode 100644 Task/Rock-paper-scissors/C/rock-paper-scissors-1.c create mode 100644 Task/Rock-paper-scissors/C/rock-paper-scissors-2.c create mode 100644 Task/Rock-paper-scissors/D/rock-paper-scissors.d create mode 100644 Task/Rock-paper-scissors/Erlang/rock-paper-scissors.erl create mode 100644 Task/Rock-paper-scissors/Euphoria/rock-paper-scissors.euphoria create mode 100644 Task/Rock-paper-scissors/Go/rock-paper-scissors.go create mode 100644 Task/Rock-paper-scissors/Haskell/rock-paper-scissors.hs create mode 100644 Task/Rock-paper-scissors/Icon/rock-paper-scissors.icon create mode 100644 Task/Rock-paper-scissors/J/rock-paper-scissors-1.j create mode 100644 Task/Rock-paper-scissors/J/rock-paper-scissors-2.j create mode 100644 Task/Rock-paper-scissors/Java/rock-paper-scissors.java create mode 100644 Task/Rock-paper-scissors/Julia/rock-paper-scissors.julia create mode 100644 Task/Rock-paper-scissors/Liberty-BASIC/rock-paper-scissors.liberty create mode 100644 Task/Rock-paper-scissors/Locomotive-Basic/rock-paper-scissors.locomotive create mode 100644 Task/Rock-paper-scissors/Mathematica/rock-paper-scissors.math create mode 100644 Task/Rock-paper-scissors/OCaml/rock-paper-scissors.ocaml create mode 100644 Task/Rock-paper-scissors/PARI-GP/rock-paper-scissors.pari create mode 100644 Task/Rock-paper-scissors/Perl-6/rock-paper-scissors-1.pl6 create mode 100644 Task/Rock-paper-scissors/Perl-6/rock-paper-scissors-2.pl6 create mode 100644 Task/Rock-paper-scissors/PicoLisp/rock-paper-scissors.l create mode 100644 Task/Rock-paper-scissors/PureBasic/rock-paper-scissors.purebasic create mode 100644 Task/Rock-paper-scissors/Python/rock-paper-scissors.py create mode 100644 Task/Rock-paper-scissors/Rascal/rock-paper-scissors-1.rascal create mode 100644 Task/Rock-paper-scissors/Rascal/rock-paper-scissors-2.rascal create mode 100644 Task/Rock-paper-scissors/Ruby/rock-paper-scissors.rb create mode 100644 Task/Rock-paper-scissors/Run-BASIC/rock-paper-scissors.run create mode 100644 Task/Rock-paper-scissors/TI-83-BASIC/rock-paper-scissors.ti-83 create mode 100644 Task/Rock-paper-scissors/Tcl/rock-paper-scissors.tcl create mode 100644 Task/Rock-paper-scissors/TorqueScript/rock-paper-scissors-1.torquescript create mode 100644 Task/Rock-paper-scissors/TorqueScript/rock-paper-scissors-2.torquescript create mode 100644 Task/Rock-paper-scissors/TorqueScript/rock-paper-scissors-3.torquescript create mode 100644 Task/Roman-numerals-Decode/0DESCRIPTION create mode 100644 Task/Roman-numerals-Decode/ALGOL-68/roman-numerals-decode.alg create mode 100644 Task/Roman-numerals-Decode/ANTLR/roman-numerals-decode.antlr create mode 100644 Task/Roman-numerals-Decode/AWK/roman-numerals-decode.awk create mode 100644 Task/Roman-numerals-Decode/Ada/roman-numerals-decode.ada create mode 100644 Task/Roman-numerals-Decode/AutoHotkey/roman-numerals-decode.ahk create mode 100644 Task/Roman-numerals-Decode/BBC-BASIC/roman-numerals-decode.bbc create mode 100644 Task/Roman-numerals-Decode/Bracmat/roman-numerals-decode.bracmat create mode 100644 Task/Roman-numerals-Decode/C++/roman-numerals-decode.cpp create mode 100644 Task/Roman-numerals-Decode/C/roman-numerals-decode.c create mode 100644 Task/Roman-numerals-Decode/Clojure/roman-numerals-decode.clj create mode 100644 Task/Roman-numerals-Decode/CoffeeScript/roman-numerals-decode.coffeescript create mode 100644 Task/Roman-numerals-Decode/Common-Lisp/roman-numerals-decode.lisp create mode 100644 Task/Roman-numerals-Decode/D/roman-numerals-decode-1.d create mode 100644 Task/Roman-numerals-Decode/D/roman-numerals-decode-2.d create mode 100644 Task/Roman-numerals-Decode/Delphi/roman-numerals-decode.delphi create mode 100644 Task/Roman-numerals-Decode/Emacs-Lisp/roman-numerals-decode.l create mode 100644 Task/Roman-numerals-Decode/Euphoria/roman-numerals-decode.euphoria create mode 100644 Task/Roman-numerals-Decode/Forth/roman-numerals-decode.fth create mode 100644 Task/Roman-numerals-Decode/Fortran/roman-numerals-decode.f create mode 100644 Task/Roman-numerals-Decode/Go/roman-numerals-decode-1.go create mode 100644 Task/Roman-numerals-Decode/Go/roman-numerals-decode-2.go create mode 100644 Task/Roman-numerals-Decode/Groovy/roman-numerals-decode-1.groovy create mode 100644 Task/Roman-numerals-Decode/Groovy/roman-numerals-decode-2.groovy create mode 100644 Task/Roman-numerals-Decode/Haskell/roman-numerals-decode.hs create mode 100644 Task/Roman-numerals-Decode/Icon/roman-numerals-decode-1.icon create mode 100644 Task/Roman-numerals-Decode/Icon/roman-numerals-decode-2.icon create mode 100644 Task/Roman-numerals-Decode/J/roman-numerals-decode-1.j create mode 100644 Task/Roman-numerals-Decode/J/roman-numerals-decode-2.j create mode 100644 Task/Roman-numerals-Decode/Java/roman-numerals-decode.java create mode 100644 Task/Roman-numerals-Decode/JavaScript/roman-numerals-decode.js create mode 100644 Task/Roman-numerals-Decode/K/roman-numerals-decode-1.k create mode 100644 Task/Roman-numerals-Decode/K/roman-numerals-decode-2.k create mode 100644 Task/Roman-numerals-Decode/Liberty-BASIC/roman-numerals-decode.liberty create mode 100644 Task/Roman-numerals-Decode/Logo/roman-numerals-decode.logo create mode 100644 Task/Roman-numerals-Decode/Lua/roman-numerals-decode.lua create mode 100644 Task/Roman-numerals-Decode/Mathematica/roman-numerals-decode.math create mode 100644 Task/Roman-numerals-Decode/NetRexx/roman-numerals-decode.netrexx create mode 100644 Task/Roman-numerals-Decode/OCaml/roman-numerals-decode.ocaml create mode 100644 Task/Roman-numerals-Decode/PARI-GP/roman-numerals-decode.pari create mode 100644 Task/Roman-numerals-Decode/PHP/roman-numerals-decode.php create mode 100644 Task/Roman-numerals-Decode/PL-I/roman-numerals-decode.pli create mode 100644 Task/Roman-numerals-Decode/PL-SQL/roman-numerals-decode.sql create mode 100644 Task/Roman-numerals-Decode/Perl-6/roman-numerals-decode-1.pl6 create mode 100644 Task/Roman-numerals-Decode/Perl-6/roman-numerals-decode-2.pl6 create mode 100644 Task/Roman-numerals-Decode/Perl/roman-numerals-decode.pl create mode 100644 Task/Roman-numerals-Decode/PicoLisp/roman-numerals-decode.l create mode 100644 Task/Roman-numerals-Decode/Prolog/roman-numerals-decode.pro create mode 100644 Task/Roman-numerals-Decode/PureBasic/roman-numerals-decode.purebasic create mode 100644 Task/Roman-numerals-Decode/Python/roman-numerals-decode-1.py create mode 100644 Task/Roman-numerals-Decode/Python/roman-numerals-decode-2.py create mode 100644 Task/Roman-numerals-Decode/REXX/roman-numerals-decode-1.rexx create mode 100644 Task/Roman-numerals-Decode/REXX/roman-numerals-decode-2.rexx create mode 100644 Task/Roman-numerals-Decode/REXX/roman-numerals-decode-3.rexx create mode 100644 Task/Roman-numerals-Decode/Ruby/roman-numerals-decode.rb create mode 100644 Task/Roman-numerals-Decode/Run-BASIC/roman-numerals-decode.run create mode 100644 Task/Roman-numerals-Decode/SNOBOL4/roman-numerals-decode-1.sno create mode 100644 Task/Roman-numerals-Decode/SNOBOL4/roman-numerals-decode-2.sno create mode 100644 Task/Roman-numerals-Decode/SNOBOL4/roman-numerals-decode-3.sno create mode 100644 Task/Roman-numerals-Decode/Scala/roman-numerals-decode.scala create mode 100644 Task/Roman-numerals-Decode/Seed7/roman-numerals-decode.seed7 create mode 100644 Task/Roman-numerals-Decode/TI-83-BASIC/roman-numerals-decode-1.ti-83 create mode 100644 Task/Roman-numerals-Decode/TI-83-BASIC/roman-numerals-decode-2.ti-83 create mode 100644 Task/Roman-numerals-Decode/TUSCRIPT/roman-numerals-decode.tuscript create mode 100644 Task/Roman-numerals-Decode/Tcl/roman-numerals-decode-1.tcl create mode 100644 Task/Roman-numerals-Decode/Tcl/roman-numerals-decode-2.tcl create mode 100644 Task/Roman-numerals-Decode/Vedit-macro-language/roman-numerals-decode.vedit create mode 100644 Task/Roman-numerals-Decode/XPL0/roman-numerals-decode.xpl0 create mode 100644 Task/Roman-numerals-Encode/0DESCRIPTION create mode 100644 Task/Roman-numerals-Encode/ALGOL-68/roman-numerals-encode.alg create mode 100644 Task/Roman-numerals-Encode/ALGOL-W/roman-numerals-encode.alg create mode 100644 Task/Roman-numerals-Encode/AWK/roman-numerals-encode.awk create mode 100644 Task/Roman-numerals-Encode/ActionScript/roman-numerals-encode-1.as create mode 100644 Task/Roman-numerals-Encode/ActionScript/roman-numerals-encode-2.as create mode 100644 Task/Roman-numerals-Encode/Ada/roman-numerals-encode.ada create mode 100644 Task/Roman-numerals-Encode/AutoHotkey/roman-numerals-encode.ahk create mode 100644 Task/Roman-numerals-Encode/BASIC/roman-numerals-encode-1.basic create mode 100644 Task/Roman-numerals-Encode/BASIC/roman-numerals-encode-2.basic create mode 100644 Task/Roman-numerals-Encode/BASIC256/roman-numerals-encode.basic256 create mode 100644 Task/Roman-numerals-Encode/BBC-BASIC/roman-numerals-encode.bbc create mode 100644 Task/Roman-numerals-Encode/Bracmat/roman-numerals-encode.bracmat create mode 100644 Task/Roman-numerals-Encode/C++/roman-numerals-encode.cpp create mode 100644 Task/Roman-numerals-Encode/C/roman-numerals-encode-1.c create mode 100644 Task/Roman-numerals-Encode/C/roman-numerals-encode-2.c create mode 100644 Task/Roman-numerals-Encode/C/roman-numerals-encode-3.c create mode 100644 Task/Roman-numerals-Encode/Clojure/roman-numerals-encode-1.clj create mode 100644 Task/Roman-numerals-Encode/Clojure/roman-numerals-encode-2.clj create mode 100644 Task/Roman-numerals-Encode/Clojure/roman-numerals-encode-3.clj create mode 100644 Task/Roman-numerals-Encode/Clojure/roman-numerals-encode-4.clj create mode 100644 Task/Roman-numerals-Encode/CoffeeScript/roman-numerals-encode.coffeescript create mode 100644 Task/Roman-numerals-Encode/Common-Lisp/roman-numerals-encode.lisp create mode 100644 Task/Roman-numerals-Encode/D/roman-numerals-encode.d create mode 100644 Task/Roman-numerals-Encode/DWScript/roman-numerals-encode.dwscript create mode 100644 Task/Roman-numerals-Encode/Delphi/roman-numerals-encode.delphi create mode 100644 Task/Roman-numerals-Encode/Emacs-Lisp/roman-numerals-encode.l create mode 100644 Task/Roman-numerals-Encode/Erlang/roman-numerals-encode.erl create mode 100644 Task/Roman-numerals-Encode/Euphoria/roman-numerals-encode.euphoria create mode 100644 Task/Roman-numerals-Encode/FALSE/roman-numerals-encode.false create mode 100644 Task/Roman-numerals-Encode/Factor/roman-numerals-encode-1.factor create mode 100644 Task/Roman-numerals-Encode/Factor/roman-numerals-encode-2.factor create mode 100644 Task/Roman-numerals-Encode/Fan/roman-numerals-encode.fan create mode 100644 Task/Roman-numerals-Encode/Forth/roman-numerals-encode-1.fth create mode 100644 Task/Roman-numerals-Encode/Forth/roman-numerals-encode-2.fth create mode 100644 Task/Roman-numerals-Encode/Fortran/roman-numerals-encode.f create mode 100644 Task/Roman-numerals-Encode/Go/roman-numerals-encode.go create mode 100644 Task/Roman-numerals-Encode/Groovy/roman-numerals-encode.groovy create mode 100644 Task/Roman-numerals-Encode/Haskell/roman-numerals-encode-1.hs create mode 100644 Task/Roman-numerals-Encode/Haskell/roman-numerals-encode-2.hs create mode 100644 Task/Roman-numerals-Encode/HicEst/roman-numerals-encode.hicest create mode 100644 Task/Roman-numerals-Encode/Icon/roman-numerals-encode-1.icon create mode 100644 Task/Roman-numerals-Encode/Icon/roman-numerals-encode-2.icon create mode 100644 Task/Roman-numerals-Encode/Io/roman-numerals-encode.io create mode 100644 Task/Roman-numerals-Encode/J/roman-numerals-encode-1.j create mode 100644 Task/Roman-numerals-Encode/J/roman-numerals-encode-2.j create mode 100644 Task/Roman-numerals-Encode/Java/roman-numerals-encode.java create mode 100644 Task/Roman-numerals-Encode/JavaScript/roman-numerals-encode.js create mode 100644 Task/Roman-numerals-Encode/LaTeX/roman-numerals-encode.tex create mode 100644 Task/Roman-numerals-Encode/Liberty-BASIC/roman-numerals-encode.liberty create mode 100644 Task/Roman-numerals-Encode/Logo/roman-numerals-encode-1.logo create mode 100644 Task/Roman-numerals-Encode/Logo/roman-numerals-encode-2.logo create mode 100644 Task/Roman-numerals-Encode/LotusScript/roman-numerals-encode.lotusscript create mode 100644 Task/Roman-numerals-Encode/Lua/roman-numerals-encode.lua create mode 100644 Task/Roman-numerals-Encode/M4/roman-numerals-encode.m4 create mode 100644 Task/Roman-numerals-Encode/MUMPS/roman-numerals-encode.mumps create mode 100644 Task/Roman-numerals-Encode/Mathematica/roman-numerals-encode-1.math create mode 100644 Task/Roman-numerals-Encode/Mathematica/roman-numerals-encode-2.math create mode 100644 Task/Roman-numerals-Encode/Mathematica/roman-numerals-encode-3.math create mode 100644 Task/Roman-numerals-Encode/Mathematica/roman-numerals-encode-4.math create mode 100644 Task/Roman-numerals-Encode/Mathematica/roman-numerals-encode-5.math create mode 100644 Task/Roman-numerals-Encode/OCaml/roman-numerals-encode.ocaml create mode 100644 Task/Roman-numerals-Encode/Objeck/roman-numerals-encode.objeck create mode 100644 Task/Roman-numerals-Encode/OpenEdge-Progress/roman-numerals-encode.openedge create mode 100644 Task/Roman-numerals-Encode/Oz/roman-numerals-encode.oz create mode 100644 Task/Roman-numerals-Encode/PARI-GP/roman-numerals-encode-1.pari create mode 100644 Task/Roman-numerals-Encode/PARI-GP/roman-numerals-encode-2.pari create mode 100644 Task/Roman-numerals-Encode/PHP/roman-numerals-encode.php create mode 100644 Task/Roman-numerals-Encode/PL-I/roman-numerals-encode.pli create mode 100644 Task/Roman-numerals-Encode/PL-SQL/roman-numerals-encode.sql create mode 100644 Task/Roman-numerals-Encode/Perl-6/roman-numerals-encode-1.pl6 create mode 100644 Task/Roman-numerals-Encode/Perl-6/roman-numerals-encode-2.pl6 create mode 100644 Task/Roman-numerals-Encode/Perl/roman-numerals-encode-1.pl create mode 100644 Task/Roman-numerals-Encode/Perl/roman-numerals-encode-2.pl create mode 100644 Task/Roman-numerals-Encode/Perl/roman-numerals-encode-3.pl create mode 100644 Task/Roman-numerals-Encode/PicoLisp/roman-numerals-encode.l create mode 100644 Task/Roman-numerals-Encode/Pike/roman-numerals-encode.pike create mode 100644 Task/Roman-numerals-Encode/PowerBASIC/roman-numerals-encode.powerbasic create mode 100644 Task/Roman-numerals-Encode/Prolog/roman-numerals-encode.pro create mode 100644 Task/Roman-numerals-Encode/Protium/roman-numerals-encode-1.protium create mode 100644 Task/Roman-numerals-Encode/Protium/roman-numerals-encode-2.protium create mode 100644 Task/Roman-numerals-Encode/PureBasic/roman-numerals-encode.purebasic create mode 100644 Task/Roman-numerals-Encode/Python/roman-numerals-encode-1.py create mode 100644 Task/Roman-numerals-Encode/Python/roman-numerals-encode-2.py create mode 100644 Task/Roman-numerals-Encode/Python/roman-numerals-encode-3.py create mode 100644 Task/Roman-numerals-Encode/R/roman-numerals-encode-1.r create mode 100644 Task/Roman-numerals-Encode/R/roman-numerals-encode-2.r create mode 100644 Task/Roman-numerals-Encode/REXX/roman-numerals-encode-1.rexx create mode 100644 Task/Roman-numerals-Encode/REXX/roman-numerals-encode-2.rexx create mode 100644 Task/Roman-numerals-Encode/Retro/roman-numerals-encode.retro create mode 100644 Task/Roman-numerals-Encode/Ruby/roman-numerals-encode.rb create mode 100644 Task/Roman-numerals-Encode/Run-BASIC/roman-numerals-encode.run create mode 100644 Task/Roman-numerals-Encode/SNOBOL4/roman-numerals-encode-1.sno create mode 100644 Task/Roman-numerals-Encode/SNOBOL4/roman-numerals-encode-2.sno create mode 100644 Task/Roman-numerals-Encode/SQL/roman-numerals-encode.sql create mode 100644 Task/Roman-numerals-Encode/Scala/roman-numerals-encode-1.scala create mode 100644 Task/Roman-numerals-Encode/Scala/roman-numerals-encode-2.scala create mode 100644 Task/Roman-numerals-Encode/Scheme/roman-numerals-encode.ss create mode 100644 Task/Roman-numerals-Encode/Seed7/roman-numerals-encode.seed7 create mode 100644 Task/Roman-numerals-Encode/Smalltalk/roman-numerals-encode-1.st create mode 100644 Task/Roman-numerals-Encode/Smalltalk/roman-numerals-encode-2.st create mode 100644 Task/Roman-numerals-Encode/TI-83-BASIC/roman-numerals-encode.ti-83 create mode 100644 Task/Roman-numerals-Encode/TUSCRIPT/roman-numerals-encode.tuscript create mode 100644 Task/Roman-numerals-Encode/Tcl/roman-numerals-encode.tcl create mode 100644 Task/Roman-numerals-Encode/Ursala/roman-numerals-encode-1.ursala create mode 100644 Task/Roman-numerals-Encode/Ursala/roman-numerals-encode-2.ursala create mode 100644 Task/Roman-numerals-Encode/Vedit-macro-language/roman-numerals-encode.vedit create mode 100644 Task/Roman-numerals-Encode/Visual-Basic/roman-numerals-encode.vb create mode 100644 Task/Roman-numerals-Encode/XSLT/roman-numerals-encode.xslt create mode 100644 Task/Roots-of-a-function/0DESCRIPTION create mode 100644 Task/Roots-of-a-function/1META.yaml create mode 100644 Task/Roots-of-a-function/ALGOL-68/roots-of-a-function.alg create mode 100644 Task/Roots-of-a-function/Ada/roots-of-a-function.ada create mode 100644 Task/Roots-of-a-function/AutoHotkey/roots-of-a-function.ahk create mode 100644 Task/Roots-of-a-function/Axiom/roots-of-a-function-1.axiom create mode 100644 Task/Roots-of-a-function/Axiom/roots-of-a-function-2.axiom create mode 100644 Task/Roots-of-a-function/Axiom/roots-of-a-function-3.axiom create mode 100644 Task/Roots-of-a-function/Axiom/roots-of-a-function-4.axiom create mode 100644 Task/Roots-of-a-function/BBC-BASIC/roots-of-a-function.bbc create mode 100644 Task/Roots-of-a-function/C++/roots-of-a-function.cpp create mode 100644 Task/Roots-of-a-function/C/roots-of-a-function.c create mode 100644 Task/Roots-of-a-function/Clojure/roots-of-a-function.clj create mode 100644 Task/Roots-of-a-function/CoffeeScript/roots-of-a-function-1.coffeescript create mode 100644 Task/Roots-of-a-function/CoffeeScript/roots-of-a-function-2.coffeescript create mode 100644 Task/Roots-of-a-function/Common-Lisp/roots-of-a-function.lisp create mode 100644 Task/Roots-of-a-function/D/roots-of-a-function.d create mode 100644 Task/Roots-of-a-function/DWScript/roots-of-a-function.dwscript create mode 100644 Task/Roots-of-a-function/Fortran/roots-of-a-function-1.f create mode 100644 Task/Roots-of-a-function/Fortran/roots-of-a-function-2.f create mode 100644 Task/Roots-of-a-function/Go/roots-of-a-function.go create mode 100644 Task/Roots-of-a-function/Haskell/roots-of-a-function-1.hs create mode 100644 Task/Roots-of-a-function/Haskell/roots-of-a-function-2.hs create mode 100644 Task/Roots-of-a-function/Haskell/roots-of-a-function-3.hs create mode 100644 Task/Roots-of-a-function/Haskell/roots-of-a-function-4.hs create mode 100644 Task/Roots-of-a-function/HicEst/roots-of-a-function-1.hicest create mode 100644 Task/Roots-of-a-function/HicEst/roots-of-a-function-2.hicest create mode 100644 Task/Roots-of-a-function/J/roots-of-a-function-1.j create mode 100644 Task/Roots-of-a-function/J/roots-of-a-function-2.j create mode 100644 Task/Roots-of-a-function/J/roots-of-a-function-3.j create mode 100644 Task/Roots-of-a-function/Java/roots-of-a-function.java create mode 100644 Task/Roots-of-a-function/Liberty-BASIC/roots-of-a-function.liberty create mode 100644 Task/Roots-of-a-function/Maple/roots-of-a-function-1.maple create mode 100644 Task/Roots-of-a-function/Maple/roots-of-a-function-2.maple create mode 100644 Task/Roots-of-a-function/Mathematica/roots-of-a-function-1.math create mode 100644 Task/Roots-of-a-function/Mathematica/roots-of-a-function-2.math create mode 100644 Task/Roots-of-a-function/Mathematica/roots-of-a-function-3.math create mode 100644 Task/Roots-of-a-function/Mathematica/roots-of-a-function-4.math create mode 100644 Task/Roots-of-a-function/Mathematica/roots-of-a-function-5.math create mode 100644 Task/Roots-of-a-function/Mathematica/roots-of-a-function-6.math create mode 100644 Task/Roots-of-a-function/Maxima/roots-of-a-function.maxima create mode 100644 Task/Roots-of-a-function/OCaml/roots-of-a-function.ocaml create mode 100644 Task/Roots-of-a-function/Objeck/roots-of-a-function.objeck create mode 100644 Task/Roots-of-a-function/Octave/roots-of-a-function-1.octave create mode 100644 Task/Roots-of-a-function/Octave/roots-of-a-function-2.octave create mode 100644 Task/Roots-of-a-function/PARI-GP/roots-of-a-function-1.pari create mode 100644 Task/Roots-of-a-function/PARI-GP/roots-of-a-function-2.pari create mode 100644 Task/Roots-of-a-function/PARI-GP/roots-of-a-function-3.pari create mode 100644 Task/Roots-of-a-function/PARI-GP/roots-of-a-function-4.pari create mode 100644 Task/Roots-of-a-function/PARI-GP/roots-of-a-function-5.pari create mode 100644 Task/Roots-of-a-function/PL-I/roots-of-a-function.pli create mode 100644 Task/Roots-of-a-function/Pascal/roots-of-a-function.pascal create mode 100644 Task/Roots-of-a-function/Perl-6/roots-of-a-function.pl6 create mode 100644 Task/Roots-of-a-function/Perl/roots-of-a-function.pl create mode 100644 Task/Roots-of-a-function/PicoLisp/roots-of-a-function.l create mode 100644 Task/Roots-of-a-function/PureBasic/roots-of-a-function.purebasic create mode 100644 Task/Roots-of-a-function/Python/roots-of-a-function.py create mode 100644 Task/Roots-of-a-function/R/roots-of-a-function.r create mode 100644 Task/Roots-of-a-function/REXX/roots-of-a-function-1.rexx create mode 100644 Task/Roots-of-a-function/REXX/roots-of-a-function-2.rexx create mode 100644 Task/Roots-of-a-function/RLaB/roots-of-a-function.rlab create mode 100644 Task/Roots-of-a-function/Ruby/roots-of-a-function-1.rb create mode 100644 Task/Roots-of-a-function/Ruby/roots-of-a-function-2.rb create mode 100644 Task/Roots-of-a-function/Tcl/roots-of-a-function-1.tcl create mode 100644 Task/Roots-of-a-function/Tcl/roots-of-a-function-2.tcl create mode 100644 Task/Roots-of-a-quadratic-function/0DESCRIPTION create mode 100644 Task/Roots-of-a-quadratic-function/1META.yaml create mode 100644 Task/Roots-of-a-quadratic-function/ALGOL-68/roots-of-a-quadratic-function.alg create mode 100644 Task/Roots-of-a-quadratic-function/Ada/roots-of-a-quadratic-function.ada create mode 100644 Task/Roots-of-a-quadratic-function/AutoHotkey/roots-of-a-quadratic-function.ahk create mode 100644 Task/Roots-of-a-quadratic-function/BBC-BASIC/roots-of-a-quadratic-function.bbc create mode 100644 Task/Roots-of-a-quadratic-function/C++/roots-of-a-quadratic-function.cpp create mode 100644 Task/Roots-of-a-quadratic-function/C/roots-of-a-quadratic-function-1.c create mode 100644 Task/Roots-of-a-quadratic-function/C/roots-of-a-quadratic-function-2.c create mode 100644 Task/Roots-of-a-quadratic-function/C/roots-of-a-quadratic-function-3.c create mode 100644 Task/Roots-of-a-quadratic-function/C/roots-of-a-quadratic-function-4.c create mode 100644 Task/Roots-of-a-quadratic-function/C/roots-of-a-quadratic-function-5.c create mode 100644 Task/Roots-of-a-quadratic-function/Common-Lisp/roots-of-a-quadratic-function.lisp create mode 100644 Task/Roots-of-a-quadratic-function/D/roots-of-a-quadratic-function.d create mode 100644 Task/Roots-of-a-quadratic-function/Factor/roots-of-a-quadratic-function-1.factor create mode 100644 Task/Roots-of-a-quadratic-function/Factor/roots-of-a-quadratic-function-2.factor create mode 100644 Task/Roots-of-a-quadratic-function/Factor/roots-of-a-quadratic-function-3.factor create mode 100644 Task/Roots-of-a-quadratic-function/Factor/roots-of-a-quadratic-function-4.factor create mode 100644 Task/Roots-of-a-quadratic-function/Forth/roots-of-a-quadratic-function-1.fth create mode 100644 Task/Roots-of-a-quadratic-function/Forth/roots-of-a-quadratic-function-2.fth create mode 100644 Task/Roots-of-a-quadratic-function/Fortran/roots-of-a-quadratic-function.f create mode 100644 Task/Roots-of-a-quadratic-function/GAP/roots-of-a-quadratic-function.gap create mode 100644 Task/Roots-of-a-quadratic-function/Go/roots-of-a-quadratic-function.go create mode 100644 Task/Roots-of-a-quadratic-function/Haskell/roots-of-a-quadratic-function.hs create mode 100644 Task/Roots-of-a-quadratic-function/IDL/roots-of-a-quadratic-function.idl create mode 100644 Task/Roots-of-a-quadratic-function/J/roots-of-a-quadratic-function-1.j create mode 100644 Task/Roots-of-a-quadratic-function/J/roots-of-a-quadratic-function-2.j create mode 100644 Task/Roots-of-a-quadratic-function/J/roots-of-a-quadratic-function-3.j create mode 100644 Task/Roots-of-a-quadratic-function/J/roots-of-a-quadratic-function-4.j create mode 100644 Task/Roots-of-a-quadratic-function/J/roots-of-a-quadratic-function-5.j create mode 100644 Task/Roots-of-a-quadratic-function/Java/roots-of-a-quadratic-function.java create mode 100644 Task/Roots-of-a-quadratic-function/Liberty-BASIC/roots-of-a-quadratic-function.liberty create mode 100644 Task/Roots-of-a-quadratic-function/Logo/roots-of-a-quadratic-function.logo create mode 100644 Task/Roots-of-a-quadratic-function/Lua/roots-of-a-quadratic-function.lua create mode 100644 Task/Roots-of-a-quadratic-function/MATLAB/roots-of-a-quadratic-function.m create mode 100644 Task/Roots-of-a-quadratic-function/Mathematica/roots-of-a-quadratic-function.math create mode 100644 Task/Roots-of-a-quadratic-function/Maxima/roots-of-a-quadratic-function.maxima create mode 100644 Task/Roots-of-a-quadratic-function/Modula-3/roots-of-a-quadratic-function.mod3 create mode 100644 Task/Roots-of-a-quadratic-function/OCaml/roots-of-a-quadratic-function-1.ocaml create mode 100644 Task/Roots-of-a-quadratic-function/OCaml/roots-of-a-quadratic-function-2.ocaml create mode 100644 Task/Roots-of-a-quadratic-function/PARI-GP/roots-of-a-quadratic-function.pari create mode 100644 Task/Roots-of-a-quadratic-function/PL-I/roots-of-a-quadratic-function.pli create mode 100644 Task/Roots-of-a-quadratic-function/Pascal/roots-of-a-quadratic-function.pascal create mode 100644 Task/Roots-of-a-quadratic-function/Perl-6/roots-of-a-quadratic-function.pl6 create mode 100644 Task/Roots-of-a-quadratic-function/Perl/roots-of-a-quadratic-function.pl create mode 100644 Task/Roots-of-a-quadratic-function/PicoLisp/roots-of-a-quadratic-function.l create mode 100644 Task/Roots-of-a-quadratic-function/Python/roots-of-a-quadratic-function.py create mode 100644 Task/Roots-of-a-quadratic-function/R/roots-of-a-quadratic-function.r create mode 100644 Task/Roots-of-a-quadratic-function/REXX/roots-of-a-quadratic-function.rexx create mode 100644 Task/Roots-of-a-quadratic-function/Ruby/roots-of-a-quadratic-function.rb create mode 100644 Task/Roots-of-a-quadratic-function/Run-BASIC/roots-of-a-quadratic-function.run create mode 100644 Task/Roots-of-a-quadratic-function/Scala/roots-of-a-quadratic-function-1.scala create mode 100644 Task/Roots-of-a-quadratic-function/Scala/roots-of-a-quadratic-function-2.scala create mode 100644 Task/Roots-of-a-quadratic-function/Scheme/roots-of-a-quadratic-function.ss create mode 100644 Task/Roots-of-a-quadratic-function/Seed7/roots-of-a-quadratic-function.seed7 create mode 100644 Task/Roots-of-a-quadratic-function/Tcl/roots-of-a-quadratic-function.tcl create mode 100644 Task/Roots-of-unity/0DESCRIPTION create mode 100644 Task/Roots-of-unity/1META.yaml create mode 100644 Task/Roots-of-unity/ALGOL-68/roots-of-unity.alg create mode 100644 Task/Roots-of-unity/Ada/roots-of-unity.ada create mode 100644 Task/Roots-of-unity/AutoHotkey/roots-of-unity.ahk create mode 100644 Task/Roots-of-unity/BASIC/roots-of-unity.basic create mode 100644 Task/Roots-of-unity/BBC-BASIC/roots-of-unity.bbc create mode 100644 Task/Roots-of-unity/C++/roots-of-unity.cpp create mode 100644 Task/Roots-of-unity/C/roots-of-unity.c create mode 100644 Task/Roots-of-unity/CoffeeScript/roots-of-unity.coffeescript create mode 100644 Task/Roots-of-unity/Common-Lisp/roots-of-unity.lisp create mode 100644 Task/Roots-of-unity/D/roots-of-unity.d create mode 100644 Task/Roots-of-unity/Forth/roots-of-unity.fth create mode 100644 Task/Roots-of-unity/Fortran/roots-of-unity-1.f create mode 100644 Task/Roots-of-unity/Fortran/roots-of-unity-2.f create mode 100644 Task/Roots-of-unity/GAP/roots-of-unity.gap create mode 100644 Task/Roots-of-unity/Go/roots-of-unity.go create mode 100644 Task/Roots-of-unity/Groovy/roots-of-unity-1.groovy create mode 100644 Task/Roots-of-unity/Groovy/roots-of-unity-2.groovy create mode 100644 Task/Roots-of-unity/Haskell/roots-of-unity-1.hs create mode 100644 Task/Roots-of-unity/Haskell/roots-of-unity-2.hs create mode 100644 Task/Roots-of-unity/IDL/roots-of-unity-1.idl create mode 100644 Task/Roots-of-unity/IDL/roots-of-unity-2.idl create mode 100644 Task/Roots-of-unity/Icon/roots-of-unity.icon create mode 100644 Task/Roots-of-unity/J/roots-of-unity-1.j create mode 100644 Task/Roots-of-unity/J/roots-of-unity-2.j create mode 100644 Task/Roots-of-unity/Java/roots-of-unity.java create mode 100644 Task/Roots-of-unity/Liberty-BASIC/roots-of-unity.liberty create mode 100644 Task/Roots-of-unity/Lua/roots-of-unity.lua create mode 100644 Task/Roots-of-unity/MATLAB/roots-of-unity-1.m create mode 100644 Task/Roots-of-unity/MATLAB/roots-of-unity-2.m create mode 100644 Task/Roots-of-unity/Mathematica/roots-of-unity.math create mode 100644 Task/Roots-of-unity/Maxima/roots-of-unity-1.maxima create mode 100644 Task/Roots-of-unity/Maxima/roots-of-unity-2.maxima create mode 100644 Task/Roots-of-unity/Maxima/roots-of-unity-3.maxima create mode 100644 Task/Roots-of-unity/OCaml/roots-of-unity.ocaml create mode 100644 Task/Roots-of-unity/Octave/roots-of-unity.octave create mode 100644 Task/Roots-of-unity/PARI-GP/roots-of-unity.pari create mode 100644 Task/Roots-of-unity/PL-I/roots-of-unity.pli create mode 100644 Task/Roots-of-unity/Pascal/roots-of-unity.pascal create mode 100644 Task/Roots-of-unity/Perl-6/roots-of-unity.pl6 create mode 100644 Task/Roots-of-unity/Perl/roots-of-unity.pl create mode 100644 Task/Roots-of-unity/PicoLisp/roots-of-unity.l create mode 100644 Task/Roots-of-unity/PureBasic/roots-of-unity.purebasic create mode 100644 Task/Roots-of-unity/Python/roots-of-unity.py create mode 100644 Task/Roots-of-unity/R/roots-of-unity.r create mode 100644 Task/Roots-of-unity/REXX/roots-of-unity.rexx create mode 100644 Task/Roots-of-unity/RLaB/roots-of-unity.rlab create mode 100644 Task/Roots-of-unity/Racket/roots-of-unity.rkt create mode 100644 Task/Roots-of-unity/Ruby/roots-of-unity.rb create mode 100644 Task/Roots-of-unity/Scala/roots-of-unity.scala create mode 100644 Task/Roots-of-unity/Scheme/roots-of-unity.ss create mode 100644 Task/Roots-of-unity/Seed7/roots-of-unity-1.seed7 create mode 100644 Task/Roots-of-unity/Seed7/roots-of-unity-2.seed7 create mode 100644 Task/Roots-of-unity/TI-89-BASIC/roots-of-unity-1.ti-89 create mode 100644 Task/Roots-of-unity/TI-89-BASIC/roots-of-unity-2.ti-89 create mode 100644 Task/Roots-of-unity/Tcl/roots-of-unity.tcl create mode 100644 Task/Roots-of-unity/Ursala/roots-of-unity.ursala create mode 100644 Task/Rosetta-Code-Count-examples/0DESCRIPTION create mode 100644 Task/Rosetta-Code-Count-examples/1META.yaml create mode 100644 Task/Rosetta-Code-Count-examples/Ada/rosetta-code-count-examples.ada create mode 100644 Task/Rosetta-Code-Count-examples/AutoHotkey/rosetta-code-count-examples.ahk create mode 100644 Task/Rosetta-Code-Count-examples/BBC-BASIC/rosetta-code-count-examples.bbc create mode 100644 Task/Rosetta-Code-Count-examples/Clojure/rosetta-code-count-examples-1.clj create mode 100644 Task/Rosetta-Code-Count-examples/Clojure/rosetta-code-count-examples-2.clj create mode 100644 Task/Rosetta-Code-Count-examples/D/rosetta-code-count-examples.d create mode 100644 Task/Rosetta-Code-Count-examples/EGL/rosetta-code-count-examples-1.egl create mode 100644 Task/Rosetta-Code-Count-examples/EGL/rosetta-code-count-examples-2.egl create mode 100644 Task/Rosetta-Code-Count-examples/Erlang/rosetta-code-count-examples.erl create mode 100644 Task/Rosetta-Code-Count-examples/Go/rosetta-code-count-examples.go create mode 100644 Task/Rosetta-Code-Count-examples/Haskell/rosetta-code-count-examples-1.hs create mode 100644 Task/Rosetta-Code-Count-examples/Haskell/rosetta-code-count-examples-2.hs create mode 100644 Task/Rosetta-Code-Count-examples/Haskell/rosetta-code-count-examples-3.hs create mode 100644 Task/Rosetta-Code-Count-examples/J/rosetta-code-count-examples-1.j create mode 100644 Task/Rosetta-Code-Count-examples/J/rosetta-code-count-examples-2.j create mode 100644 Task/Rosetta-Code-Count-examples/Java/rosetta-code-count-examples.java create mode 100644 Task/Rosetta-Code-Count-examples/MATLAB/rosetta-code-count-examples.m create mode 100644 Task/Rosetta-Code-Count-examples/Mathematica/rosetta-code-count-examples.math create mode 100644 Task/Rosetta-Code-Count-examples/OCaml/rosetta-code-count-examples.ocaml create mode 100644 Task/Rosetta-Code-Count-examples/Oz/rosetta-code-count-examples.oz create mode 100644 Task/Rosetta-Code-Count-examples/Perl/rosetta-code-count-examples-1.pl create mode 100644 Task/Rosetta-Code-Count-examples/Perl/rosetta-code-count-examples-2.pl create mode 100644 Task/Rosetta-Code-Count-examples/PicoLisp/rosetta-code-count-examples.l create mode 100644 Task/Rosetta-Code-Count-examples/PureBasic/rosetta-code-count-examples.purebasic create mode 100644 Task/Rosetta-Code-Count-examples/Python/rosetta-code-count-examples.py create mode 100644 Task/Rosetta-Code-Count-examples/R/rosetta-code-count-examples.r create mode 100644 Task/Rosetta-Code-Count-examples/Ruby/rosetta-code-count-examples-1.rb create mode 100644 Task/Rosetta-Code-Count-examples/Ruby/rosetta-code-count-examples-2.rb create mode 100644 Task/Rosetta-Code-Count-examples/Run-BASIC/rosetta-code-count-examples.run create mode 100644 Task/Rosetta-Code-Count-examples/Scala/rosetta-code-count-examples.scala create mode 100644 Task/Rosetta-Code-Count-examples/TUSCRIPT/rosetta-code-count-examples.tuscript create mode 100644 Task/Rosetta-Code-Count-examples/Tcl/rosetta-code-count-examples.tcl create mode 100644 Task/Rosetta-Code-Find-unimplemented-tasks/0DESCRIPTION create mode 100644 Task/Rosetta-Code-Find-unimplemented-tasks/1META.yaml create mode 100644 Task/Rosetta-Code-Find-unimplemented-tasks/Ada/rosetta-code-find-unimplemented-tasks.ada create mode 100644 Task/Rosetta-Code-Find-unimplemented-tasks/AutoHotkey/rosetta-code-find-unimplemented-tasks.ahk create mode 100644 Task/Rosetta-Code-Find-unimplemented-tasks/Go/rosetta-code-find-unimplemented-tasks.go create mode 100644 Task/Rosetta-Code-Find-unimplemented-tasks/Haskell/rosetta-code-find-unimplemented-tasks.hs create mode 100644 Task/Rosetta-Code-Find-unimplemented-tasks/J/rosetta-code-find-unimplemented-tasks-1.j create mode 100644 Task/Rosetta-Code-Find-unimplemented-tasks/J/rosetta-code-find-unimplemented-tasks-2.j create mode 100644 Task/Rosetta-Code-Find-unimplemented-tasks/Oz/rosetta-code-find-unimplemented-tasks.oz create mode 100644 Task/Rosetta-Code-Find-unimplemented-tasks/Perl/rosetta-code-find-unimplemented-tasks.pl create mode 100644 Task/Rosetta-Code-Find-unimplemented-tasks/PicoLisp/rosetta-code-find-unimplemented-tasks-1.l create mode 100644 Task/Rosetta-Code-Find-unimplemented-tasks/PicoLisp/rosetta-code-find-unimplemented-tasks-2.l create mode 100644 Task/Rosetta-Code-Find-unimplemented-tasks/R/rosetta-code-find-unimplemented-tasks.r create mode 100644 Task/Rosetta-Code-Find-unimplemented-tasks/Ruby/rosetta-code-find-unimplemented-tasks.rb create mode 100644 Task/Rosetta-Code-Find-unimplemented-tasks/Run-BASIC/rosetta-code-find-unimplemented-tasks.run create mode 100644 Task/Rosetta-Code-Find-unimplemented-tasks/Tcl/rosetta-code-find-unimplemented-tasks.tcl create mode 100644 Task/Rosetta-Code-Fix-code-tags/0DESCRIPTION create mode 100644 Task/Rosetta-Code-Fix-code-tags/1META.yaml create mode 100644 Task/Rosetta-Code-Fix-code-tags/AutoHotkey/rosetta-code-fix-code-tags.ahk create mode 100644 Task/Rosetta-Code-Fix-code-tags/Go/rosetta-code-fix-code-tags.go create mode 100644 Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-1.j create mode 100644 Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-2.j create mode 100644 Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-3.j create mode 100644 Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-4.j create mode 100644 Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-5.j create mode 100644 Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-6.j create mode 100644 Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-7.j create mode 100644 Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-8.j create mode 100644 Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-9.j create mode 100644 Task/Rosetta-Code-Fix-code-tags/JavaScript/rosetta-code-fix-code-tags.js create mode 100644 Task/Rosetta-Code-Fix-code-tags/Lua/rosetta-code-fix-code-tags.lua create mode 100644 Task/Rosetta-Code-Fix-code-tags/Mathematica/rosetta-code-fix-code-tags-1.math create mode 100644 Task/Rosetta-Code-Fix-code-tags/Mathematica/rosetta-code-fix-code-tags-2.math create mode 100644 Task/Rosetta-Code-Fix-code-tags/Mathematica/rosetta-code-fix-code-tags-3.math create mode 100644 Task/Rosetta-Code-Fix-code-tags/Mathematica/rosetta-code-fix-code-tags-4.math create mode 100644 Task/Rosetta-Code-Fix-code-tags/Mathematica/rosetta-code-fix-code-tags-5.math create mode 100644 Task/Rosetta-Code-Fix-code-tags/OCaml/rosetta-code-fix-code-tags-1.ocaml create mode 100644 Task/Rosetta-Code-Fix-code-tags/OCaml/rosetta-code-fix-code-tags-2.ocaml create mode 100644 Task/Rosetta-Code-Fix-code-tags/OCaml/rosetta-code-fix-code-tags-3.ocaml create mode 100644 Task/Rosetta-Code-Fix-code-tags/Perl/rosetta-code-fix-code-tags.pl create mode 100644 Task/Rosetta-Code-Fix-code-tags/PicoLisp/rosetta-code-fix-code-tags.l create mode 100644 Task/Rosetta-Code-Fix-code-tags/PureBasic/rosetta-code-fix-code-tags.purebasic create mode 100644 Task/Rosetta-Code-Fix-code-tags/Python/rosetta-code-fix-code-tags.py create mode 100644 Task/Rosetta-Code-Fix-code-tags/R/rosetta-code-fix-code-tags.r create mode 100644 Task/Rosetta-Code-Fix-code-tags/REXX/rosetta-code-fix-code-tags-1.rexx create mode 100644 Task/Rosetta-Code-Fix-code-tags/REXX/rosetta-code-fix-code-tags-2.rexx create mode 100644 Task/Rosetta-Code-Fix-code-tags/Ruby/rosetta-code-fix-code-tags-1.rb create mode 100644 Task/Rosetta-Code-Fix-code-tags/Ruby/rosetta-code-fix-code-tags-2.rb create mode 100644 Task/Rosetta-Code-Fix-code-tags/Ruby/rosetta-code-fix-code-tags-3.rb create mode 100644 Task/Rosetta-Code-Fix-code-tags/Ruby/rosetta-code-fix-code-tags-4.rb create mode 100644 Task/Rosetta-Code-Fix-code-tags/Ruby/rosetta-code-fix-code-tags-5.rb create mode 100644 Task/Rosetta-Code-Fix-code-tags/Tcl/rosetta-code-fix-code-tags-1.tcl create mode 100644 Task/Rosetta-Code-Fix-code-tags/Tcl/rosetta-code-fix-code-tags-2.tcl create mode 100644 Task/Rosetta-Code-Fix-code-tags/Tcl/rosetta-code-fix-code-tags-3.tcl create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/0DESCRIPTION create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/1META.yaml create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/ALGOL-68/rosetta-code-rank-languages-by-popularity.alg create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/AWK/rosetta-code-rank-languages-by-popularity.awk create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/Ada/rosetta-code-rank-languages-by-popularity.ada create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/AutoHotkey/rosetta-code-rank-languages-by-popularity.ahk create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/BBC-BASIC/rosetta-code-rank-languages-by-popularity.bbc create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/C++/rosetta-code-rank-languages-by-popularity.cpp create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/C/rosetta-code-rank-languages-by-popularity.c create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/Cache-ObjectScript/rosetta-code-rank-languages-by-popularity.cos create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/D/rosetta-code-rank-languages-by-popularity.d create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/Go/rosetta-code-rank-languages-by-popularity.go create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/Haskell/rosetta-code-rank-languages-by-popularity.hs create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/HicEst/rosetta-code-rank-languages-by-popularity-1.hicest create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/HicEst/rosetta-code-rank-languages-by-popularity-2.hicest create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/HicEst/rosetta-code-rank-languages-by-popularity-3.hicest create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/HicEst/rosetta-code-rank-languages-by-popularity-4.hicest create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/Mathematica/rosetta-code-rank-languages-by-popularity.math create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/Oz/rosetta-code-rank-languages-by-popularity.oz create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/Perl-6/rosetta-code-rank-languages-by-popularity.pl6 create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/Perl/rosetta-code-rank-languages-by-popularity.pl create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/PicoLisp/rosetta-code-rank-languages-by-popularity.l create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/PureBasic/rosetta-code-rank-languages-by-popularity.purebasic create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/Python/rosetta-code-rank-languages-by-popularity.py create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/R/rosetta-code-rank-languages-by-popularity.r create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/REXX/rosetta-code-rank-languages-by-popularity.rexx create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/Racket/rosetta-code-rank-languages-by-popularity.rkt create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/Ruby/rosetta-code-rank-languages-by-popularity.rb create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/Run-BASIC/rosetta-code-rank-languages-by-popularity.run create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/Scala/rosetta-code-rank-languages-by-popularity.scala create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/TUSCRIPT/rosetta-code-rank-languages-by-popularity.tuscript create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/Tcl/rosetta-code-rank-languages-by-popularity-1.tcl create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/Tcl/rosetta-code-rank-languages-by-popularity-2.tcl create mode 100644 Task/Rosetta-Code-Rank-languages-by-popularity/UnixPipes/rosetta-code-rank-languages-by-popularity.unixpipes create mode 100644 Task/Rot-13/0DESCRIPTION create mode 100644 Task/Rot-13/1META.yaml create mode 100644 Task/Rot-13/6502-Assembly/rot-13.6502 create mode 100644 Task/Rot-13/ACL2/rot-13.acl2 create mode 100644 Task/Rot-13/ALGOL-68/rot-13.alg create mode 100644 Task/Rot-13/AWK/rot-13.awk create mode 100644 Task/Rot-13/Ada/rot-13.ada create mode 100644 Task/Rot-13/AppleScript/rot-13-1.applescript create mode 100644 Task/Rot-13/AppleScript/rot-13-2.applescript create mode 100644 Task/Rot-13/AppleScript/rot-13-3.applescript create mode 100644 Task/Rot-13/AutoHotkey/rot-13.ahk create mode 100644 Task/Rot-13/BASIC/rot-13.basic create mode 100644 Task/Rot-13/BBC-BASIC/rot-13.bbc create mode 100644 Task/Rot-13/Befunge/rot-13.bf create mode 100644 Task/Rot-13/Burlesque/rot-13.blq create mode 100644 Task/Rot-13/C++/rot-13-1.cpp create mode 100644 Task/Rot-13/C++/rot-13-2.cpp create mode 100644 Task/Rot-13/C/rot-13.c create mode 100644 Task/Rot-13/Clojure/rot-13-1.clj create mode 100644 Task/Rot-13/Clojure/rot-13-2.clj create mode 100644 Task/Rot-13/Common-Lisp/rot-13-1.lisp create mode 100644 Task/Rot-13/Common-Lisp/rot-13-2.lisp create mode 100644 Task/Rot-13/D/rot-13-1.d create mode 100644 Task/Rot-13/D/rot-13-2.d create mode 100644 Task/Rot-13/E/rot-13.e create mode 100644 Task/Rot-13/Erlang/rot-13.erl create mode 100644 Task/Rot-13/Euphoria/rot-13.euphoria create mode 100644 Task/Rot-13/FALSE/rot-13.false create mode 100644 Task/Rot-13/Factor/rot-13.factor create mode 100644 Task/Rot-13/Fantom/rot-13.fantom create mode 100644 Task/Rot-13/Forth/rot-13-1.fth create mode 100644 Task/Rot-13/Forth/rot-13-2.fth create mode 100644 Task/Rot-13/Fortran/rot-13-1.f create mode 100644 Task/Rot-13/Fortran/rot-13-2.f create mode 100644 Task/Rot-13/GAP/rot-13.gap create mode 100644 Task/Rot-13/GML/rot-13-1.gml create mode 100644 Task/Rot-13/GML/rot-13-2.gml create mode 100644 Task/Rot-13/GW-BASIC/rot-13.gw-basic create mode 100644 Task/Rot-13/Gema/rot-13.gema create mode 100644 Task/Rot-13/Go/rot-13.go create mode 100644 Task/Rot-13/Groovy/rot-13-1.groovy create mode 100644 Task/Rot-13/Groovy/rot-13-2.groovy create mode 100644 Task/Rot-13/Haskell/rot-13-1.hs create mode 100644 Task/Rot-13/Haskell/rot-13-2.hs create mode 100644 Task/Rot-13/Haskell/rot-13-3.hs create mode 100644 Task/Rot-13/HicEst/rot-13.hicest create mode 100644 Task/Rot-13/Icon/rot-13.icon create mode 100644 Task/Rot-13/J/rot-13.j create mode 100644 Task/Rot-13/Java/rot-13.java create mode 100644 Task/Rot-13/JavaScript/rot-13.js create mode 100644 Task/Rot-13/K/rot-13.k create mode 100644 Task/Rot-13/Liberty-BASIC/rot-13-1.liberty create mode 100644 Task/Rot-13/Liberty-BASIC/rot-13-2.liberty create mode 100644 Task/Rot-13/Locomotive-Basic/rot-13.locomotive create mode 100644 Task/Rot-13/Logo/rot-13.logo create mode 100644 Task/Rot-13/Lua/rot-13.lua create mode 100644 Task/Rot-13/MATLAB/rot-13-1.m create mode 100644 Task/Rot-13/MATLAB/rot-13-2.m create mode 100644 Task/Rot-13/MATLAB/rot-13-3.m create mode 100644 Task/Rot-13/MATLAB/rot-13-4.m create mode 100644 Task/Rot-13/MMIX/rot-13.mmix create mode 100644 Task/Rot-13/MUMPS/rot-13.mumps create mode 100644 Task/Rot-13/Maple/rot-13.maple create mode 100644 Task/Rot-13/Mathematica/rot-13.math create mode 100644 Task/Rot-13/Maxima/rot-13.maxima create mode 100644 Task/Rot-13/Mirah/rot-13.mirah create mode 100644 Task/Rot-13/Modula-3/rot-13.mod3 create mode 100644 Task/Rot-13/NetRexx/rot-13.netrexx create mode 100644 Task/Rot-13/OCaml/rot-13-1.ocaml create mode 100644 Task/Rot-13/OCaml/rot-13-2.ocaml create mode 100644 Task/Rot-13/OCaml/rot-13-3.ocaml create mode 100644 Task/Rot-13/Objeck/rot-13.objeck create mode 100644 Task/Rot-13/Oz/rot-13.oz create mode 100644 Task/Rot-13/PARI-GP/rot-13.pari create mode 100644 Task/Rot-13/PHP/rot-13-1.php create mode 100644 Task/Rot-13/PHP/rot-13-2.php create mode 100644 Task/Rot-13/PL-I/rot-13.pli create mode 100644 Task/Rot-13/Pascal/rot-13.pascal create mode 100644 Task/Rot-13/Perl-6/rot-13.pl6 create mode 100644 Task/Rot-13/Perl/rot-13-1.pl create mode 100644 Task/Rot-13/Perl/rot-13-2.pl create mode 100644 Task/Rot-13/PicoLisp/rot-13-1.l create mode 100644 Task/Rot-13/PicoLisp/rot-13-2.l create mode 100644 Task/Rot-13/PicoLisp/rot-13-3.l create mode 100644 Task/Rot-13/Pike/rot-13.pike create mode 100644 Task/Rot-13/Pop11/rot-13.pop11 create mode 100644 Task/Rot-13/PostScript/rot-13.ps create mode 100644 Task/Rot-13/PowerShell/rot-13.psh create mode 100644 Task/Rot-13/Prolog/rot-13-1.pro create mode 100644 Task/Rot-13/Prolog/rot-13-2.pro create mode 100644 Task/Rot-13/PureBasic/rot-13.purebasic create mode 100644 Task/Rot-13/Python/rot-13-1.py create mode 100644 Task/Rot-13/Python/rot-13-2.py create mode 100644 Task/Rot-13/R/rot-13.r create mode 100644 Task/Rot-13/REBOL/rot-13.rebol create mode 100644 Task/Rot-13/REXX/rot-13.rexx create mode 100644 Task/Rot-13/Racket/rot-13.rkt create mode 100644 Task/Rot-13/Retro/rot-13.retro create mode 100644 Task/Rot-13/Ruby/rot-13.rb create mode 100644 Task/Rot-13/Run-BASIC/rot-13.run create mode 100644 Task/Rot-13/SNOBOL4/rot-13.sno create mode 100644 Task/Rot-13/Scala/rot-13.scala create mode 100644 Task/Rot-13/Scheme/rot-13.ss create mode 100644 Task/Rot-13/Seed7/rot-13.seed7 create mode 100644 Task/Rot-13/Slate/rot-13-1.slate create mode 100644 Task/Rot-13/Slate/rot-13-2.slate create mode 100644 Task/Rot-13/Smalltalk/rot-13.st create mode 100644 Task/Rot-13/Standard-ML/rot-13.ml create mode 100644 Task/Rot-13/TI-83-BASIC/rot-13.ti-83 create mode 100644 Task/Rot-13/TXR/rot-13.txr create mode 100644 Task/Rot-13/Tcl/rot-13-1.tcl create mode 100644 Task/Rot-13/Tcl/rot-13-2.tcl create mode 100644 Task/Rot-13/TorqueScript/rot-13.torquescript create mode 100644 Task/Rot-13/UNIX-Shell/rot-13.sh create mode 100644 Task/Rot-13/Unlambda/rot-13.unlambda create mode 100644 Task/Rot-13/Ursala/rot-13.ursala create mode 100644 Task/Rot-13/Vedit-macro-language/rot-13.vedit create mode 100644 Task/Rot-13/Visual-Basic-.NET/rot-13.visual create mode 100644 Task/Rot-13/X86-Assembly/rot-13.x86 create mode 100644 Task/Rot-13/XPL0/rot-13.xpl0 create mode 100644 Task/Rot-13/XSLT/rot-13.xslt create mode 100644 Task/Rot-13/ZX-Spectrum-Basic/rot-13.zx create mode 100644 Task/Run-length-encoding/0DESCRIPTION create mode 100644 Task/Run-length-encoding/1META.yaml create mode 100644 Task/Run-length-encoding/ALGOL-68/run-length-encoding.alg create mode 100644 Task/Run-length-encoding/APL/run-length-encoding.apl create mode 100644 Task/Run-length-encoding/AWK/run-length-encoding-1.awk create mode 100644 Task/Run-length-encoding/AWK/run-length-encoding-2.awk create mode 100644 Task/Run-length-encoding/Ada/run-length-encoding.ada create mode 100644 Task/Run-length-encoding/AutoHotkey/run-length-encoding.ahk create mode 100644 Task/Run-length-encoding/BASIC/run-length-encoding.basic create mode 100644 Task/Run-length-encoding/BBC-BASIC/run-length-encoding.bbc create mode 100644 Task/Run-length-encoding/Bracmat/run-length-encoding.bracmat create mode 100644 Task/Run-length-encoding/Burlesque/run-length-encoding.blq create mode 100644 Task/Run-length-encoding/C++/run-length-encoding.cpp create mode 100644 Task/Run-length-encoding/C/run-length-encoding.c create mode 100644 Task/Run-length-encoding/Clojure/run-length-encoding.clj create mode 100644 Task/Run-length-encoding/CoffeeScript/run-length-encoding-1.coffeescript create mode 100644 Task/Run-length-encoding/CoffeeScript/run-length-encoding-2.coffeescript create mode 100644 Task/Run-length-encoding/Common-Lisp/run-length-encoding.lisp create mode 100644 Task/Run-length-encoding/D/run-length-encoding-1.d create mode 100644 Task/Run-length-encoding/D/run-length-encoding-2.d create mode 100644 Task/Run-length-encoding/D/run-length-encoding-3.d create mode 100644 Task/Run-length-encoding/D/run-length-encoding-4.d create mode 100644 Task/Run-length-encoding/E/run-length-encoding-1.e create mode 100644 Task/Run-length-encoding/E/run-length-encoding-2.e create mode 100644 Task/Run-length-encoding/Erlang/run-length-encoding.erl create mode 100644 Task/Run-length-encoding/Euphoria/run-length-encoding.euphoria create mode 100644 Task/Run-length-encoding/FALSE/run-length-encoding-1.false create mode 100644 Task/Run-length-encoding/FALSE/run-length-encoding-2.false create mode 100644 Task/Run-length-encoding/Fan/run-length-encoding.fan create mode 100644 Task/Run-length-encoding/Forth/run-length-encoding-1.fth create mode 100644 Task/Run-length-encoding/Forth/run-length-encoding-2.fth create mode 100644 Task/Run-length-encoding/Fortran/run-length-encoding.f create mode 100644 Task/Run-length-encoding/Go/run-length-encoding.go create mode 100644 Task/Run-length-encoding/Groovy/run-length-encoding-1.groovy create mode 100644 Task/Run-length-encoding/Groovy/run-length-encoding-2.groovy create mode 100644 Task/Run-length-encoding/Haskell/run-length-encoding.hs create mode 100644 Task/Run-length-encoding/Icon/run-length-encoding.icon create mode 100644 Task/Run-length-encoding/J/run-length-encoding-1.j create mode 100644 Task/Run-length-encoding/J/run-length-encoding-2.j create mode 100644 Task/Run-length-encoding/Java/run-length-encoding-1.java create mode 100644 Task/Run-length-encoding/Java/run-length-encoding-2.java create mode 100644 Task/Run-length-encoding/JavaScript/run-length-encoding-1.js create mode 100644 Task/Run-length-encoding/JavaScript/run-length-encoding-2.js create mode 100644 Task/Run-length-encoding/JavaScript/run-length-encoding-3.js create mode 100644 Task/Run-length-encoding/K/run-length-encoding-1.k create mode 100644 Task/Run-length-encoding/K/run-length-encoding-2.k create mode 100644 Task/Run-length-encoding/K/run-length-encoding-3.k create mode 100644 Task/Run-length-encoding/Liberty-BASIC/run-length-encoding.liberty create mode 100644 Task/Run-length-encoding/Logo/run-length-encoding.logo create mode 100644 Task/Run-length-encoding/Lua/run-length-encoding.lua create mode 100644 Task/Run-length-encoding/MMIX/run-length-encoding.mmix create mode 100644 Task/Run-length-encoding/Mathematica/run-length-encoding-1.math create mode 100644 Task/Run-length-encoding/Mathematica/run-length-encoding-2.math create mode 100644 Task/Run-length-encoding/Mathematica/run-length-encoding-3.math create mode 100644 Task/Run-length-encoding/Mathematica/run-length-encoding-4.math create mode 100644 Task/Run-length-encoding/Maxima/run-length-encoding.maxima create mode 100644 Task/Run-length-encoding/OCaml/run-length-encoding-1.ocaml create mode 100644 Task/Run-length-encoding/OCaml/run-length-encoding-2.ocaml create mode 100644 Task/Run-length-encoding/OCaml/run-length-encoding-3.ocaml create mode 100644 Task/Run-length-encoding/Oz/run-length-encoding.oz create mode 100644 Task/Run-length-encoding/PARI-GP/run-length-encoding.pari create mode 100644 Task/Run-length-encoding/PHP/run-length-encoding.php create mode 100644 Task/Run-length-encoding/PL-I/run-length-encoding.pli create mode 100644 Task/Run-length-encoding/Pascal/run-length-encoding.pascal create mode 100644 Task/Run-length-encoding/Perl-6/run-length-encoding.pl6 create mode 100644 Task/Run-length-encoding/Perl/run-length-encoding-1.pl create mode 100644 Task/Run-length-encoding/Perl/run-length-encoding-2.pl create mode 100644 Task/Run-length-encoding/PicoLisp/run-length-encoding.l create mode 100644 Task/Run-length-encoding/PowerBASIC/run-length-encoding.powerbasic create mode 100644 Task/Run-length-encoding/PowerShell/run-length-encoding.psh create mode 100644 Task/Run-length-encoding/Prolog/run-length-encoding.pro create mode 100644 Task/Run-length-encoding/Pure/run-length-encoding.pure create mode 100644 Task/Run-length-encoding/PureBasic/run-length-encoding.purebasic create mode 100644 Task/Run-length-encoding/Python/run-length-encoding-1.py create mode 100644 Task/Run-length-encoding/Python/run-length-encoding-2.py create mode 100644 Task/Run-length-encoding/Python/run-length-encoding-3.py create mode 100644 Task/Run-length-encoding/R/run-length-encoding-1.r create mode 100644 Task/Run-length-encoding/R/run-length-encoding-2.r create mode 100644 Task/Run-length-encoding/REXX/run-length-encoding-1.rexx create mode 100644 Task/Run-length-encoding/REXX/run-length-encoding-2.rexx create mode 100644 Task/Run-length-encoding/Ruby/run-length-encoding-1.rb create mode 100644 Task/Run-length-encoding/Ruby/run-length-encoding-2.rb create mode 100644 Task/Run-length-encoding/Ruby/run-length-encoding-3.rb create mode 100644 Task/Run-length-encoding/Run-BASIC/run-length-encoding.run create mode 100644 Task/Run-length-encoding/SNOBOL4/run-length-encoding.sno create mode 100644 Task/Run-length-encoding/Scala/run-length-encoding-1.scala create mode 100644 Task/Run-length-encoding/Scala/run-length-encoding-2.scala create mode 100644 Task/Run-length-encoding/Scheme/run-length-encoding.ss create mode 100644 Task/Run-length-encoding/Seed7/run-length-encoding.seed7 create mode 100644 Task/Run-length-encoding/Standard-ML/run-length-encoding.ml create mode 100644 Task/Run-length-encoding/TUSCRIPT/run-length-encoding.tuscript create mode 100644 Task/Run-length-encoding/Tcl/run-length-encoding-1.tcl create mode 100644 Task/Run-length-encoding/Tcl/run-length-encoding-2.tcl create mode 100644 Task/Run-length-encoding/Ursala/run-length-encoding.ursala create mode 100644 Task/Run-length-encoding/Vedit-macro-language/run-length-encoding.vedit create mode 100644 Task/Run-length-encoding/XPL0/run-length-encoding.xpl0 create mode 100644 Task/Runtime-evaluation-In-an-environment/0DESCRIPTION create mode 100644 Task/Runtime-evaluation-In-an-environment/ALGOL-68/runtime-evaluation-in-an-environment.alg create mode 100644 Task/Runtime-evaluation-In-an-environment/AutoHotkey/runtime-evaluation-in-an-environment.ahk create mode 100644 Task/Runtime-evaluation-In-an-environment/BBC-BASIC/runtime-evaluation-in-an-environment.bbc create mode 100644 Task/Runtime-evaluation-In-an-environment/Common-Lisp/runtime-evaluation-in-an-environment-1.lisp create mode 100644 Task/Runtime-evaluation-In-an-environment/Common-Lisp/runtime-evaluation-in-an-environment-2.lisp create mode 100644 Task/Runtime-evaluation-In-an-environment/Common-Lisp/runtime-evaluation-in-an-environment-3.lisp create mode 100644 Task/Runtime-evaluation-In-an-environment/E/runtime-evaluation-in-an-environment-1.e create mode 100644 Task/Runtime-evaluation-In-an-environment/E/runtime-evaluation-in-an-environment-2.e create mode 100644 Task/Runtime-evaluation-In-an-environment/Forth/runtime-evaluation-in-an-environment-1.fth create mode 100644 Task/Runtime-evaluation-In-an-environment/Forth/runtime-evaluation-in-an-environment-2.fth create mode 100644 Task/Runtime-evaluation-In-an-environment/Genyris/runtime-evaluation-in-an-environment-1.genyris create mode 100644 Task/Runtime-evaluation-In-an-environment/Genyris/runtime-evaluation-in-an-environment-2.genyris create mode 100644 Task/Runtime-evaluation-In-an-environment/Genyris/runtime-evaluation-in-an-environment-3.genyris create mode 100644 Task/Runtime-evaluation-In-an-environment/Go/runtime-evaluation-in-an-environment.go create mode 100644 Task/Runtime-evaluation-In-an-environment/Groovy/runtime-evaluation-in-an-environment-1.groovy create mode 100644 Task/Runtime-evaluation-In-an-environment/Groovy/runtime-evaluation-in-an-environment-2.groovy create mode 100644 Task/Runtime-evaluation-In-an-environment/J/runtime-evaluation-in-an-environment-1.j create mode 100644 Task/Runtime-evaluation-In-an-environment/J/runtime-evaluation-in-an-environment-2.j create mode 100644 Task/Runtime-evaluation-In-an-environment/J/runtime-evaluation-in-an-environment-3.j create mode 100644 Task/Runtime-evaluation-In-an-environment/J/runtime-evaluation-in-an-environment-4.j create mode 100644 Task/Runtime-evaluation-In-an-environment/J/runtime-evaluation-in-an-environment-5.j create mode 100644 Task/Runtime-evaluation-In-an-environment/J/runtime-evaluation-in-an-environment-6.j create mode 100644 Task/Runtime-evaluation-In-an-environment/Java/runtime-evaluation-in-an-environment.java create mode 100644 Task/Runtime-evaluation-In-an-environment/JavaScript/runtime-evaluation-in-an-environment-1.js create mode 100644 Task/Runtime-evaluation-In-an-environment/JavaScript/runtime-evaluation-in-an-environment-2.js create mode 100644 Task/Runtime-evaluation-In-an-environment/Liberty-BASIC/runtime-evaluation-in-an-environment.liberty create mode 100644 Task/Runtime-evaluation-In-an-environment/Lua/runtime-evaluation-in-an-environment.lua create mode 100644 Task/Runtime-evaluation-In-an-environment/Mathematica/runtime-evaluation-in-an-environment.math create mode 100644 Task/Runtime-evaluation-In-an-environment/Metafont/runtime-evaluation-in-an-environment.metafont create mode 100644 Task/Runtime-evaluation-In-an-environment/Octave/runtime-evaluation-in-an-environment.octave create mode 100644 Task/Runtime-evaluation-In-an-environment/Oz/runtime-evaluation-in-an-environment.oz create mode 100644 Task/Runtime-evaluation-In-an-environment/PARI-GP/runtime-evaluation-in-an-environment.pari create mode 100644 Task/Runtime-evaluation-In-an-environment/PHP/runtime-evaluation-in-an-environment.php create mode 100644 Task/Runtime-evaluation-In-an-environment/Perl-6/runtime-evaluation-in-an-environment.pl6 create mode 100644 Task/Runtime-evaluation-In-an-environment/Perl/runtime-evaluation-in-an-environment.pl create mode 100644 Task/Runtime-evaluation-In-an-environment/PicoLisp/runtime-evaluation-in-an-environment.l create mode 100644 Task/Runtime-evaluation-In-an-environment/Pike/runtime-evaluation-in-an-environment-1.pike create mode 100644 Task/Runtime-evaluation-In-an-environment/Pike/runtime-evaluation-in-an-environment-2.pike create mode 100644 Task/Runtime-evaluation-In-an-environment/Python/runtime-evaluation-in-an-environment-1.py create mode 100644 Task/Runtime-evaluation-In-an-environment/Python/runtime-evaluation-in-an-environment-2.py create mode 100644 Task/Runtime-evaluation-In-an-environment/R/runtime-evaluation-in-an-environment.r create mode 100644 Task/Runtime-evaluation-In-an-environment/REBOL/runtime-evaluation-in-an-environment.rebol create mode 100644 Task/Runtime-evaluation-In-an-environment/REXX/runtime-evaluation-in-an-environment.rexx create mode 100644 Task/Runtime-evaluation-In-an-environment/Ruby/runtime-evaluation-in-an-environment.rb create mode 100644 Task/Runtime-evaluation-In-an-environment/SNOBOL4/runtime-evaluation-in-an-environment-1.sno create mode 100644 Task/Runtime-evaluation-In-an-environment/SNOBOL4/runtime-evaluation-in-an-environment-2.sno create mode 100644 Task/Runtime-evaluation-In-an-environment/Scheme/runtime-evaluation-in-an-environment.ss create mode 100644 Task/Runtime-evaluation-In-an-environment/TI-89-BASIC/runtime-evaluation-in-an-environment.ti-89 create mode 100644 Task/Runtime-evaluation-In-an-environment/Tcl/runtime-evaluation-in-an-environment-1.tcl create mode 100644 Task/Runtime-evaluation-In-an-environment/Tcl/runtime-evaluation-in-an-environment-2.tcl create mode 100644 Task/Runtime-evaluation-In-an-environment/UNIX-Shell/runtime-evaluation-in-an-environment.sh create mode 100644 Task/Runtime-evaluation/0DESCRIPTION create mode 100644 Task/Runtime-evaluation/ALGOL-68/runtime-evaluation.alg create mode 100644 Task/Runtime-evaluation/AutoHotkey/runtime-evaluation.ahk create mode 100644 Task/Runtime-evaluation/BASIC/runtime-evaluation.basic create mode 100644 Task/Runtime-evaluation/BBC-BASIC/runtime-evaluation-1.bbc create mode 100644 Task/Runtime-evaluation/BBC-BASIC/runtime-evaluation-2.bbc create mode 100644 Task/Runtime-evaluation/Burlesque/runtime-evaluation-1.blq create mode 100644 Task/Runtime-evaluation/Burlesque/runtime-evaluation-2.blq create mode 100644 Task/Runtime-evaluation/Burlesque/runtime-evaluation-3.blq create mode 100644 Task/Runtime-evaluation/Burlesque/runtime-evaluation-4.blq create mode 100644 Task/Runtime-evaluation/Burlesque/runtime-evaluation-5.blq create mode 100644 Task/Runtime-evaluation/Burlesque/runtime-evaluation-6.blq create mode 100644 Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-1.lisp create mode 100644 Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-2.lisp create mode 100644 Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-3.lisp create mode 100644 Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-4.lisp create mode 100644 Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-5.lisp create mode 100644 Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-6.lisp create mode 100644 Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-7.lisp create mode 100644 Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-8.lisp create mode 100644 Task/Runtime-evaluation/E/runtime-evaluation-1.e create mode 100644 Task/Runtime-evaluation/E/runtime-evaluation-2.e create mode 100644 Task/Runtime-evaluation/E/runtime-evaluation-3.e create mode 100644 Task/Runtime-evaluation/Erlang/runtime-evaluation.erl create mode 100644 Task/Runtime-evaluation/Forth/runtime-evaluation-1.fth create mode 100644 Task/Runtime-evaluation/Forth/runtime-evaluation-2.fth create mode 100644 Task/Runtime-evaluation/GW-BASIC/runtime-evaluation.gw-basic create mode 100644 Task/Runtime-evaluation/Go/runtime-evaluation.go create mode 100644 Task/Runtime-evaluation/Groovy/runtime-evaluation-1.groovy create mode 100644 Task/Runtime-evaluation/Groovy/runtime-evaluation-2.groovy create mode 100644 Task/Runtime-evaluation/Groovy/runtime-evaluation-3.groovy create mode 100644 Task/Runtime-evaluation/Groovy/runtime-evaluation-4.groovy create mode 100644 Task/Runtime-evaluation/Groovy/runtime-evaluation-5.groovy create mode 100644 Task/Runtime-evaluation/Groovy/runtime-evaluation-6.groovy create mode 100644 Task/Runtime-evaluation/HicEst/runtime-evaluation.hicest create mode 100644 Task/Runtime-evaluation/J/runtime-evaluation-1.j create mode 100644 Task/Runtime-evaluation/J/runtime-evaluation-2.j create mode 100644 Task/Runtime-evaluation/JavaScript/runtime-evaluation.js create mode 100644 Task/Runtime-evaluation/Liberty-BASIC/runtime-evaluation-1.liberty create mode 100644 Task/Runtime-evaluation/Liberty-BASIC/runtime-evaluation-2.liberty create mode 100644 Task/Runtime-evaluation/Lua/runtime-evaluation.lua create mode 100644 Task/Runtime-evaluation/Maxima/runtime-evaluation.maxima create mode 100644 Task/Runtime-evaluation/OxygenBasic/runtime-evaluation.oxy create mode 100644 Task/Runtime-evaluation/Oz/runtime-evaluation.oz create mode 100644 Task/Runtime-evaluation/PHP/runtime-evaluation.php create mode 100644 Task/Runtime-evaluation/Perl-6/runtime-evaluation.pl6 create mode 100644 Task/Runtime-evaluation/Perl/runtime-evaluation.pl create mode 100644 Task/Runtime-evaluation/Pike/runtime-evaluation.pike create mode 100644 Task/Runtime-evaluation/Python/runtime-evaluation-1.py create mode 100644 Task/Runtime-evaluation/Python/runtime-evaluation-2.py create mode 100644 Task/Runtime-evaluation/R/runtime-evaluation-1.r create mode 100644 Task/Runtime-evaluation/R/runtime-evaluation-2.r create mode 100644 Task/Runtime-evaluation/R/runtime-evaluation-3.r create mode 100644 Task/Runtime-evaluation/REXX/runtime-evaluation.rexx create mode 100644 Task/Runtime-evaluation/Ruby/runtime-evaluation-1.rb create mode 100644 Task/Runtime-evaluation/Ruby/runtime-evaluation-2.rb create mode 100644 Task/Runtime-evaluation/SNOBOL4/runtime-evaluation-1.sno create mode 100644 Task/Runtime-evaluation/SNOBOL4/runtime-evaluation-2.sno create mode 100644 Task/Runtime-evaluation/Scheme/runtime-evaluation.ss create mode 100644 Task/Runtime-evaluation/Slate/runtime-evaluation-1.slate create mode 100644 Task/Runtime-evaluation/Slate/runtime-evaluation-2.slate create mode 100644 Task/Runtime-evaluation/Slate/runtime-evaluation-3.slate create mode 100644 Task/Runtime-evaluation/Slate/runtime-evaluation-4.slate create mode 100644 Task/Runtime-evaluation/Slate/runtime-evaluation-5.slate create mode 100644 Task/Runtime-evaluation/Smalltalk/runtime-evaluation-1.st create mode 100644 Task/Runtime-evaluation/Smalltalk/runtime-evaluation-2.st create mode 100644 Task/Runtime-evaluation/Smalltalk/runtime-evaluation-3.st create mode 100644 Task/Runtime-evaluation/Tcl/runtime-evaluation-1.tcl create mode 100644 Task/Runtime-evaluation/Tcl/runtime-evaluation-2.tcl create mode 100644 Task/Runtime-evaluation/Tcl/runtime-evaluation-3.tcl create mode 100644 Task/S-Expressions/0DESCRIPTION create mode 100644 Task/S-Expressions/1META.yaml create mode 100644 Task/S-Expressions/Ada/s-expressions-1.ada create mode 100644 Task/S-Expressions/Ada/s-expressions-2.ada create mode 100644 Task/S-Expressions/Ada/s-expressions-3.ada create mode 100644 Task/S-Expressions/Ada/s-expressions-4.ada create mode 100644 Task/S-Expressions/Ada/s-expressions-5.ada create mode 100644 Task/S-Expressions/C/s-expressions-1.c create mode 100644 Task/S-Expressions/C/s-expressions-2.c create mode 100644 Task/S-Expressions/CoffeeScript/s-expressions-1.coffeescript create mode 100644 Task/S-Expressions/CoffeeScript/s-expressions-2.coffeescript create mode 100644 Task/S-Expressions/Common-Lisp/s-expressions-1.lisp create mode 100644 Task/S-Expressions/Common-Lisp/s-expressions-2.lisp create mode 100644 Task/S-Expressions/Common-Lisp/s-expressions-3.lisp create mode 100644 Task/S-Expressions/Common-Lisp/s-expressions-4.lisp create mode 100644 Task/S-Expressions/D/s-expressions.d create mode 100644 Task/S-Expressions/Go/s-expressions.go create mode 100644 Task/S-Expressions/Haskell/s-expressions.hs create mode 100644 Task/S-Expressions/Icon/s-expressions.icon create mode 100644 Task/S-Expressions/J/s-expressions-1.j create mode 100644 Task/S-Expressions/J/s-expressions-2.j create mode 100644 Task/S-Expressions/Java/s-expressions-1.java create mode 100644 Task/S-Expressions/Java/s-expressions-2.java create mode 100644 Task/S-Expressions/Java/s-expressions-3.java create mode 100644 Task/S-Expressions/Java/s-expressions-4.java create mode 100644 Task/S-Expressions/Java/s-expressions-5.java create mode 100644 Task/S-Expressions/Java/s-expressions-6.java create mode 100644 Task/S-Expressions/Java/s-expressions-7.java create mode 100644 Task/S-Expressions/OCaml/s-expressions-1.ocaml create mode 100644 Task/S-Expressions/OCaml/s-expressions-2.ocaml create mode 100644 Task/S-Expressions/Perl-6/s-expressions.pl6 create mode 100644 Task/S-Expressions/Perl/s-expressions-1.pl create mode 100644 Task/S-Expressions/Perl/s-expressions-2.pl create mode 100644 Task/S-Expressions/PicoLisp/s-expressions-1.l create mode 100644 Task/S-Expressions/PicoLisp/s-expressions-2.l create mode 100644 Task/S-Expressions/PicoLisp/s-expressions-3.l create mode 100644 Task/S-Expressions/PicoLisp/s-expressions-4.l create mode 100644 Task/S-Expressions/PicoLisp/s-expressions-5.l create mode 100644 Task/S-Expressions/PicoLisp/s-expressions-6.l create mode 100644 Task/S-Expressions/PicoLisp/s-expressions-7.l create mode 100644 Task/S-Expressions/Pike/s-expressions.pike create mode 100644 Task/S-Expressions/Python/s-expressions-1.py create mode 100644 Task/S-Expressions/Python/s-expressions-2.py create mode 100644 Task/S-Expressions/REXX/s-expressions.rexx create mode 100644 Task/S-Expressions/Racket/s-expressions.rkt create mode 100644 Task/S-Expressions/Ruby/s-expressions.rb create mode 100644 Task/S-Expressions/Scheme/s-expressions.ss create mode 100644 Task/S-Expressions/Tcl/s-expressions-1.tcl create mode 100644 Task/S-Expressions/Tcl/s-expressions-2.tcl create mode 100644 Task/SEDOLs/0DESCRIPTION create mode 100644 Task/SEDOLs/1META.yaml create mode 100644 Task/SEDOLs/ALGOL-68/sedols.alg create mode 100644 Task/SEDOLs/AWK/sedols.awk create mode 100644 Task/SEDOLs/ActionScript/sedols.as create mode 100644 Task/SEDOLs/Ada/sedols.ada create mode 100644 Task/SEDOLs/AutoHotkey/sedols.ahk create mode 100644 Task/SEDOLs/BASIC/sedols.basic create mode 100644 Task/SEDOLs/BBC-BASIC/sedols.bbc create mode 100644 Task/SEDOLs/C++/sedols.cpp create mode 100644 Task/SEDOLs/C/sedols.c create mode 100644 Task/SEDOLs/Common-Lisp/sedols.lisp create mode 100644 Task/SEDOLs/D/sedols-1.d create mode 100644 Task/SEDOLs/D/sedols-2.d create mode 100644 Task/SEDOLs/D/sedols-3.d create mode 100644 Task/SEDOLs/E/sedols.e create mode 100644 Task/SEDOLs/Forth/sedols.fth create mode 100644 Task/SEDOLs/Fortran/sedols.f create mode 100644 Task/SEDOLs/Go/sedols.go create mode 100644 Task/SEDOLs/Groovy/sedols-1.groovy create mode 100644 Task/SEDOLs/Groovy/sedols-2.groovy create mode 100644 Task/SEDOLs/Haskell/sedols.hs create mode 100644 Task/SEDOLs/Icon/sedols.icon create mode 100644 Task/SEDOLs/J/sedols-1.j create mode 100644 Task/SEDOLs/J/sedols-2.j create mode 100644 Task/SEDOLs/J/sedols-3.j create mode 100644 Task/SEDOLs/J/sedols-4.j create mode 100644 Task/SEDOLs/Java/sedols.java create mode 100644 Task/SEDOLs/JavaScript/sedols.js create mode 100644 Task/SEDOLs/Liberty-BASIC/sedols.liberty create mode 100644 Task/SEDOLs/M4/sedols.m4 create mode 100644 Task/SEDOLs/MUMPS/sedols.mumps create mode 100644 Task/SEDOLs/Mathematica/sedols.math create mode 100644 Task/SEDOLs/Mercury/sedols.mercury create mode 100644 Task/SEDOLs/Modula-3/sedols.mod3 create mode 100644 Task/SEDOLs/OCaml/sedols.ocaml create mode 100644 Task/SEDOLs/PHP/sedols.php create mode 100644 Task/SEDOLs/PL-I/sedols.pli create mode 100644 Task/SEDOLs/Pascal/sedols.pascal create mode 100644 Task/SEDOLs/Perl-6/sedols.pl6 create mode 100644 Task/SEDOLs/Perl/sedols.pl create mode 100644 Task/SEDOLs/PicoLisp/sedols.l create mode 100644 Task/SEDOLs/PureBasic/sedols.purebasic create mode 100644 Task/SEDOLs/Python/sedols.py create mode 100644 Task/SEDOLs/R/sedols.r create mode 100644 Task/SEDOLs/REXX/sedols.rexx create mode 100644 Task/SEDOLs/Racket/sedols.rkt create mode 100644 Task/SEDOLs/Ruby/sedols.rb create mode 100644 Task/SEDOLs/Scala/sedols.scala create mode 100644 Task/SEDOLs/Seed7/sedols.seed7 create mode 100644 Task/SEDOLs/Smalltalk/sedols-1.st create mode 100644 Task/SEDOLs/Smalltalk/sedols-2.st create mode 100644 Task/SEDOLs/Smalltalk/sedols-3.st create mode 100644 Task/SEDOLs/Standard-ML/sedols.ml create mode 100644 Task/SEDOLs/TUSCRIPT/sedols.tuscript create mode 100644 Task/SEDOLs/Tcl/sedols.tcl create mode 100644 Task/SEDOLs/Ursala/sedols-1.ursala create mode 100644 Task/SEDOLs/Ursala/sedols-2.ursala create mode 100644 Task/SEDOLs/Ursala/sedols-3.ursala create mode 100644 Task/SEDOLs/Ursala/sedols-4.ursala create mode 100644 Task/SEDOLs/Ursala/sedols-5.ursala create mode 100644 Task/Safe-addition/0DESCRIPTION create mode 100644 Task/Safe-addition/1META.yaml create mode 100644 Task/Safe-addition/Ada/safe-addition-1.ada create mode 100644 Task/Safe-addition/Ada/safe-addition-2.ada create mode 100644 Task/Safe-addition/Ada/safe-addition-3.ada create mode 100644 Task/Safe-addition/C/safe-addition-1.c create mode 100644 Task/Safe-addition/C/safe-addition-2.c create mode 100644 Task/Safe-addition/C/safe-addition-3.c create mode 100644 Task/Safe-addition/E/safe-addition-1.e create mode 100644 Task/Safe-addition/E/safe-addition-2.e create mode 100644 Task/Safe-addition/Go/safe-addition.go create mode 100644 Task/Safe-addition/J/safe-addition.j create mode 100644 Task/Safe-addition/Python/safe-addition.py create mode 100644 Task/Safe-addition/REXX/safe-addition.rexx create mode 100644 Task/Safe-addition/Ruby/safe-addition.rb create mode 100644 Task/Safe-addition/Tcl/safe-addition-1.tcl create mode 100644 Task/Safe-addition/Tcl/safe-addition-2.tcl create mode 100644 Task/Same-Fringe/0DESCRIPTION create mode 100644 Task/Same-Fringe/Ada/same-fringe-1.ada create mode 100644 Task/Same-Fringe/Ada/same-fringe-2.ada create mode 100644 Task/Same-Fringe/Ada/same-fringe-3.ada create mode 100644 Task/Same-Fringe/Ada/same-fringe-4.ada create mode 100644 Task/Same-Fringe/Ada/same-fringe-5.ada create mode 100644 Task/Same-Fringe/C/same-fringe.c create mode 100644 Task/Same-Fringe/D/same-fringe-1.d create mode 100644 Task/Same-Fringe/D/same-fringe-2.d create mode 100644 Task/Same-Fringe/Go/same-fringe.go create mode 100644 Task/Same-Fringe/Haskell/same-fringe.hs create mode 100644 Task/Same-Fringe/J/same-fringe-1.j create mode 100644 Task/Same-Fringe/J/same-fringe-2.j create mode 100644 Task/Same-Fringe/J/same-fringe-3.j create mode 100644 Task/Same-Fringe/J/same-fringe-4.j create mode 100644 Task/Same-Fringe/Java/same-fringe.java create mode 100644 Task/Same-Fringe/OCaml/same-fringe.ocaml create mode 100644 Task/Same-Fringe/Perl-6/same-fringe-1.pl6 create mode 100644 Task/Same-Fringe/Perl-6/same-fringe-2.pl6 create mode 100644 Task/Same-Fringe/PicoLisp/same-fringe-1.l create mode 100644 Task/Same-Fringe/PicoLisp/same-fringe-2.l create mode 100644 Task/Same-Fringe/Python/same-fringe.py create mode 100644 Task/Same-Fringe/REXX/same-fringe-1.rexx create mode 100644 Task/Same-Fringe/REXX/same-fringe-2.rexx create mode 100644 Task/Same-Fringe/REXX/same-fringe-3.rexx create mode 100644 Task/Same-Fringe/Racket/same-fringe.rkt create mode 100644 Task/Same-Fringe/Tcl/same-fringe-1.tcl create mode 100644 Task/Same-Fringe/Tcl/same-fringe-2.tcl create mode 100644 Task/Scope-Function-names-and-labels/0DESCRIPTION create mode 100644 Task/Scope-Function-names-and-labels/1META.yaml create mode 100644 Task/Scope-Function-names-and-labels/AWK/scope-function-names-and-labels.awk create mode 100644 Task/Scope-Function-names-and-labels/BASIC/scope-function-names-and-labels-1.basic create mode 100644 Task/Scope-Function-names-and-labels/BASIC/scope-function-names-and-labels-2.basic create mode 100644 Task/Scope-Function-names-and-labels/Perl-6/scope-function-names-and-labels.pl6 create mode 100644 Task/Scope-Function-names-and-labels/REXX/scope-function-names-and-labels.rexx create mode 100644 Task/Scope-Function-names-and-labels/Tcl/scope-function-names-and-labels.tcl create mode 100644 Task/Scope-Function-names-and-labels/UNIX-Shell/scope-function-names-and-labels.sh create mode 100644 Task/Scope-Function-names-and-labels/ZX-Spectrum-Basic/scope-function-names-and-labels.zx create mode 100644 Task/Scope-modifiers/0DESCRIPTION create mode 100644 Task/Scope-modifiers/1META.yaml create mode 100644 Task/Scope-modifiers/Ada/scope-modifiers-1.ada create mode 100644 Task/Scope-modifiers/Ada/scope-modifiers-2.ada create mode 100644 Task/Scope-modifiers/Ada/scope-modifiers-3.ada create mode 100644 Task/Scope-modifiers/Ada/scope-modifiers-4.ada create mode 100644 Task/Scope-modifiers/AutoHotkey/scope-modifiers.ahk create mode 100644 Task/Scope-modifiers/BBC-BASIC/scope-modifiers.bbc create mode 100644 Task/Scope-modifiers/C/scope-modifiers-1.c create mode 100644 Task/Scope-modifiers/C/scope-modifiers-2.c create mode 100644 Task/Scope-modifiers/Common-Lisp/scope-modifiers.lisp create mode 100644 Task/Scope-modifiers/Delphi/scope-modifiers-1.delphi create mode 100644 Task/Scope-modifiers/Delphi/scope-modifiers-2.delphi create mode 100644 Task/Scope-modifiers/Delphi/scope-modifiers-3.delphi create mode 100644 Task/Scope-modifiers/Delphi/scope-modifiers-4.delphi create mode 100644 Task/Scope-modifiers/Delphi/scope-modifiers-5.delphi create mode 100644 Task/Scope-modifiers/Delphi/scope-modifiers-6.delphi create mode 100644 Task/Scope-modifiers/Ela/scope-modifiers.ela create mode 100644 Task/Scope-modifiers/Icon/scope-modifiers.icon create mode 100644 Task/Scope-modifiers/J/scope-modifiers.j create mode 100644 Task/Scope-modifiers/Java/scope-modifiers.java create mode 100644 Task/Scope-modifiers/Logo/scope-modifiers.logo create mode 100644 Task/Scope-modifiers/MUMPS/scope-modifiers.mumps create mode 100644 Task/Scope-modifiers/Mathematica/scope-modifiers.math create mode 100644 Task/Scope-modifiers/Perl-6/scope-modifiers-1.pl6 create mode 100644 Task/Scope-modifiers/Perl-6/scope-modifiers-2.pl6 create mode 100644 Task/Scope-modifiers/Perl/scope-modifiers-1.pl create mode 100644 Task/Scope-modifiers/Perl/scope-modifiers-2.pl create mode 100644 Task/Scope-modifiers/Perl/scope-modifiers-3.pl create mode 100644 Task/Scope-modifiers/Perl/scope-modifiers-4.pl create mode 100644 Task/Scope-modifiers/PowerShell/scope-modifiers.psh create mode 100644 Task/Scope-modifiers/PureBasic/scope-modifiers.purebasic create mode 100644 Task/Scope-modifiers/Python/scope-modifiers.py create mode 100644 Task/Scope-modifiers/R/scope-modifiers-1.r create mode 100644 Task/Scope-modifiers/R/scope-modifiers-2.r create mode 100644 Task/Scope-modifiers/R/scope-modifiers-3.r create mode 100644 Task/Scope-modifiers/R/scope-modifiers-4.r create mode 100644 Task/Scope-modifiers/R/scope-modifiers-5.r create mode 100644 Task/Scope-modifiers/REXX/scope-modifiers.rexx create mode 100644 Task/Scope-modifiers/TI-89-BASIC/scope-modifiers.ti-89 create mode 100644 Task/Scope-modifiers/TXR/scope-modifiers-1.txr create mode 100644 Task/Scope-modifiers/TXR/scope-modifiers-2.txr create mode 100644 Task/Scope-modifiers/Tcl/scope-modifiers-1.tcl create mode 100644 Task/Scope-modifiers/Tcl/scope-modifiers-2.tcl create mode 100644 Task/Scope-modifiers/Tcl/scope-modifiers-3.tcl create mode 100644 Task/Scope-modifiers/Tcl/scope-modifiers-4.tcl create mode 100644 Task/Scope-modifiers/Tcl/scope-modifiers-5.tcl create mode 100644 Task/Scope-modifiers/Ursala/scope-modifiers-1.ursala create mode 100644 Task/Scope-modifiers/Ursala/scope-modifiers-2.ursala create mode 100644 Task/Scope-modifiers/Ursala/scope-modifiers-3.ursala create mode 100644 Task/Scope-modifiers/Ursala/scope-modifiers-4.ursala create mode 100644 Task/Secure-temporary-file/0DESCRIPTION create mode 100644 Task/Secure-temporary-file/1META.yaml create mode 100644 Task/Secure-temporary-file/Ada/secure-temporary-file.ada create mode 100644 Task/Secure-temporary-file/BBC-BASIC/secure-temporary-file.bbc create mode 100644 Task/Secure-temporary-file/C/secure-temporary-file-1.c create mode 100644 Task/Secure-temporary-file/C/secure-temporary-file-2.c create mode 100644 Task/Secure-temporary-file/Clojure/secure-temporary-file.clj create mode 100644 Task/Secure-temporary-file/D/secure-temporary-file.d create mode 100644 Task/Secure-temporary-file/Go/secure-temporary-file.go create mode 100644 Task/Secure-temporary-file/Groovy/secure-temporary-file.groovy create mode 100644 Task/Secure-temporary-file/Haskell/secure-temporary-file.hs create mode 100644 Task/Secure-temporary-file/HicEst/secure-temporary-file.hicest create mode 100644 Task/Secure-temporary-file/Java/secure-temporary-file.java create mode 100644 Task/Secure-temporary-file/Lua/secure-temporary-file.lua create mode 100644 Task/Secure-temporary-file/Mathematica/secure-temporary-file.math create mode 100644 Task/Secure-temporary-file/OCaml/secure-temporary-file.ocaml create mode 100644 Task/Secure-temporary-file/Octave/secure-temporary-file.octave create mode 100644 Task/Secure-temporary-file/PHP/secure-temporary-file.php create mode 100644 Task/Secure-temporary-file/Pascal/secure-temporary-file.pascal create mode 100644 Task/Secure-temporary-file/Perl/secure-temporary-file-1.pl create mode 100644 Task/Secure-temporary-file/Perl/secure-temporary-file-2.pl create mode 100644 Task/Secure-temporary-file/PicoLisp/secure-temporary-file.l create mode 100644 Task/Secure-temporary-file/PureBasic/secure-temporary-file.purebasic create mode 100644 Task/Secure-temporary-file/Python/secure-temporary-file-1.py create mode 100644 Task/Secure-temporary-file/Python/secure-temporary-file-2.py create mode 100644 Task/Secure-temporary-file/Racket/secure-temporary-file.rkt create mode 100644 Task/Secure-temporary-file/Ruby/secure-temporary-file.rb create mode 100644 Task/Secure-temporary-file/Scala/secure-temporary-file.scala create mode 100644 Task/Secure-temporary-file/Standard-ML/secure-temporary-file.ml create mode 100644 Task/Secure-temporary-file/TUSCRIPT/secure-temporary-file.tuscript create mode 100644 Task/Secure-temporary-file/Tcl/secure-temporary-file.tcl create mode 100644 Task/Secure-temporary-file/UNIX-Shell/secure-temporary-file.sh create mode 100644 Task/Self-describing-numbers/0DESCRIPTION create mode 100644 Task/Self-describing-numbers/AWK/self-describing-numbers.awk create mode 100644 Task/Self-describing-numbers/Ada/self-describing-numbers.ada create mode 100644 Task/Self-describing-numbers/AutoHotkey/self-describing-numbers.ahk create mode 100644 Task/Self-describing-numbers/BASIC/self-describing-numbers.basic create mode 100644 Task/Self-describing-numbers/BBC-BASIC/self-describing-numbers.bbc create mode 100644 Task/Self-describing-numbers/C/self-describing-numbers-1.c create mode 100644 Task/Self-describing-numbers/C/self-describing-numbers-2.c create mode 100644 Task/Self-describing-numbers/C/self-describing-numbers-3.c create mode 100644 Task/Self-describing-numbers/C/self-describing-numbers-4.c create mode 100644 Task/Self-describing-numbers/D/self-describing-numbers-1.d create mode 100644 Task/Self-describing-numbers/D/self-describing-numbers-2.d create mode 100644 Task/Self-describing-numbers/Erlang/self-describing-numbers.erl create mode 100644 Task/Self-describing-numbers/Forth/self-describing-numbers.fth create mode 100644 Task/Self-describing-numbers/Go/self-describing-numbers.go create mode 100644 Task/Self-describing-numbers/Haskell/self-describing-numbers-1.hs create mode 100644 Task/Self-describing-numbers/Haskell/self-describing-numbers-2.hs create mode 100644 Task/Self-describing-numbers/Icon/self-describing-numbers-1.icon create mode 100644 Task/Self-describing-numbers/Icon/self-describing-numbers-2.icon create mode 100644 Task/Self-describing-numbers/J/self-describing-numbers-1.j create mode 100644 Task/Self-describing-numbers/J/self-describing-numbers-2.j create mode 100644 Task/Self-describing-numbers/J/self-describing-numbers-3.j create mode 100644 Task/Self-describing-numbers/Java/self-describing-numbers.java create mode 100644 Task/Self-describing-numbers/JavaScript/self-describing-numbers.js create mode 100644 Task/Self-describing-numbers/Julia/self-describing-numbers.julia create mode 100644 Task/Self-describing-numbers/K/self-describing-numbers.k create mode 100644 Task/Self-describing-numbers/Liberty-BASIC/self-describing-numbers.liberty create mode 100644 Task/Self-describing-numbers/Logo/self-describing-numbers.logo create mode 100644 Task/Self-describing-numbers/Lua/self-describing-numbers.lua create mode 100644 Task/Self-describing-numbers/MATLAB/self-describing-numbers-1.m create mode 100644 Task/Self-describing-numbers/MATLAB/self-describing-numbers-2.m create mode 100644 Task/Self-describing-numbers/Mathematica/self-describing-numbers.math create mode 100644 Task/Self-describing-numbers/PARI-GP/self-describing-numbers.pari create mode 100644 Task/Self-describing-numbers/Pascal/self-describing-numbers.pascal create mode 100644 Task/Self-describing-numbers/Perl-6/self-describing-numbers.pl6 create mode 100644 Task/Self-describing-numbers/Perl/self-describing-numbers.pl create mode 100644 Task/Self-describing-numbers/PicoLisp/self-describing-numbers.l create mode 100644 Task/Self-describing-numbers/Prolog/self-describing-numbers.pro create mode 100644 Task/Self-describing-numbers/PureBasic/self-describing-numbers.purebasic create mode 100644 Task/Self-describing-numbers/Python/self-describing-numbers-1.py create mode 100644 Task/Self-describing-numbers/Python/self-describing-numbers-2.py create mode 100644 Task/Self-describing-numbers/REXX/self-describing-numbers-1.rexx create mode 100644 Task/Self-describing-numbers/REXX/self-describing-numbers-2.rexx create mode 100644 Task/Self-describing-numbers/REXX/self-describing-numbers-3.rexx create mode 100644 Task/Self-describing-numbers/Ruby/self-describing-numbers.rb create mode 100644 Task/Self-describing-numbers/Run-BASIC/self-describing-numbers.run create mode 100644 Task/Self-describing-numbers/Seed7/self-describing-numbers.seed7 create mode 100644 Task/Self-describing-numbers/Tcl/self-describing-numbers.tcl create mode 100644 Task/Self-describing-numbers/XPL0/self-describing-numbers.xpl0 create mode 100644 Task/Self-referential-sequence/0DESCRIPTION create mode 100644 Task/Self-referential-sequence/Ada/self-referential-sequence.ada create mode 100644 Task/Self-referential-sequence/AutoHotkey/self-referential-sequence.ahk create mode 100644 Task/Self-referential-sequence/BBC-BASIC/self-referential-sequence.bbc create mode 100644 Task/Self-referential-sequence/Bracmat/self-referential-sequence.bracmat create mode 100644 Task/Self-referential-sequence/C/self-referential-sequence.c create mode 100644 Task/Self-referential-sequence/CoffeeScript/self-referential-sequence.coffeescript create mode 100644 Task/Self-referential-sequence/Common-Lisp/self-referential-sequence-1.lisp create mode 100644 Task/Self-referential-sequence/Common-Lisp/self-referential-sequence-2.lisp create mode 100644 Task/Self-referential-sequence/D/self-referential-sequence-1.d create mode 100644 Task/Self-referential-sequence/D/self-referential-sequence-2.d create mode 100644 Task/Self-referential-sequence/D/self-referential-sequence-3.d create mode 100644 Task/Self-referential-sequence/Go/self-referential-sequence.go create mode 100644 Task/Self-referential-sequence/Haskell/self-referential-sequence.hs create mode 100644 Task/Self-referential-sequence/Icon/self-referential-sequence-1.icon create mode 100644 Task/Self-referential-sequence/Icon/self-referential-sequence-2.icon create mode 100644 Task/Self-referential-sequence/J/self-referential-sequence-1.j create mode 100644 Task/Self-referential-sequence/J/self-referential-sequence-2.j create mode 100644 Task/Self-referential-sequence/J/self-referential-sequence-3.j create mode 100644 Task/Self-referential-sequence/J/self-referential-sequence-4.j create mode 100644 Task/Self-referential-sequence/Mathematica/self-referential-sequence.math create mode 100644 Task/Self-referential-sequence/Perl-6/self-referential-sequence.pl6 create mode 100644 Task/Self-referential-sequence/Perl/self-referential-sequence.pl create mode 100644 Task/Self-referential-sequence/PicoLisp/self-referential-sequence.l create mode 100644 Task/Self-referential-sequence/Python/self-referential-sequence.py create mode 100644 Task/Self-referential-sequence/REXX/self-referential-sequence.rexx create mode 100644 Task/Self-referential-sequence/Ruby/self-referential-sequence.rb create mode 100644 Task/Self-referential-sequence/Tcl/self-referential-sequence.tcl create mode 100644 Task/Semordnilap/0DESCRIPTION create mode 100644 Task/Semordnilap/1META.yaml create mode 100644 Task/Semordnilap/AWK/semordnilap.awk create mode 100644 Task/Semordnilap/Ada/semordnilap-1.ada create mode 100644 Task/Semordnilap/Ada/semordnilap-2.ada create mode 100644 Task/Semordnilap/Ada/semordnilap-3.ada create mode 100644 Task/Semordnilap/BBC-BASIC/semordnilap.bbc create mode 100644 Task/Semordnilap/C++/semordnilap.cpp create mode 100644 Task/Semordnilap/C/semordnilap.c create mode 100644 Task/Semordnilap/D/semordnilap.d create mode 100644 Task/Semordnilap/Go/semordnilap.go create mode 100644 Task/Semordnilap/Groovy/semordnilap-1.groovy create mode 100644 Task/Semordnilap/Groovy/semordnilap-2.groovy create mode 100644 Task/Semordnilap/Haskell/semordnilap.hs create mode 100644 Task/Semordnilap/J/semordnilap-1.j create mode 100644 Task/Semordnilap/J/semordnilap-2.j create mode 100644 Task/Semordnilap/Java/semordnilap.java create mode 100644 Task/Semordnilap/Julia/semordnilap.julia create mode 100644 Task/Semordnilap/Liberty-BASIC/semordnilap.liberty create mode 100644 Task/Semordnilap/Mathematica/semordnilap.math create mode 100644 Task/Semordnilap/NetRexx/semordnilap.netrexx create mode 100644 Task/Semordnilap/OCaml/semordnilap.ocaml create mode 100644 Task/Semordnilap/PHP/semordnilap.php create mode 100644 Task/Semordnilap/PL-I/semordnilap.pli create mode 100644 Task/Semordnilap/Perl-6/semordnilap.pl6 create mode 100644 Task/Semordnilap/Perl/semordnilap.pl create mode 100644 Task/Semordnilap/Python/semordnilap-1.py create mode 100644 Task/Semordnilap/Python/semordnilap-2.py create mode 100644 Task/Semordnilap/REXX/semordnilap-1.rexx create mode 100644 Task/Semordnilap/REXX/semordnilap-2.rexx create mode 100644 Task/Semordnilap/Ruby/semordnilap.rb create mode 100644 Task/Semordnilap/TUSCRIPT/semordnilap.tuscript create mode 100644 Task/Semordnilap/Tcl/semordnilap.tcl create mode 100644 Task/Semordnilap/XPL0/semordnilap.xpl0 create mode 100644 Task/Send-an-unknown-method-call/0DESCRIPTION create mode 100644 Task/Send-an-unknown-method-call/1META.yaml create mode 100644 Task/Send-an-unknown-method-call/AutoHotkey/send-an-unknown-method-call.ahk create mode 100644 Task/Send-an-unknown-method-call/E/send-an-unknown-method-call.e create mode 100644 Task/Send-an-unknown-method-call/Go/send-an-unknown-method-call-1.go create mode 100644 Task/Send-an-unknown-method-call/Go/send-an-unknown-method-call-2.go create mode 100644 Task/Send-an-unknown-method-call/Java/send-an-unknown-method-call.java create mode 100644 Task/Send-an-unknown-method-call/JavaScript/send-an-unknown-method-call.js create mode 100644 Task/Send-an-unknown-method-call/MATLAB/send-an-unknown-method-call.m create mode 100644 Task/Send-an-unknown-method-call/Objective-C/send-an-unknown-method-call.m create mode 100644 Task/Send-an-unknown-method-call/PARI-GP/send-an-unknown-method-call.pari create mode 100644 Task/Send-an-unknown-method-call/PHP/send-an-unknown-method-call.php create mode 100644 Task/Send-an-unknown-method-call/Perl-6/send-an-unknown-method-call.pl6 create mode 100644 Task/Send-an-unknown-method-call/Perl/send-an-unknown-method-call.pl create mode 100644 Task/Send-an-unknown-method-call/PicoLisp/send-an-unknown-method-call.l create mode 100644 Task/Send-an-unknown-method-call/Pike/send-an-unknown-method-call.pike create mode 100644 Task/Send-an-unknown-method-call/Python/send-an-unknown-method-call.py create mode 100644 Task/Send-an-unknown-method-call/Qi/send-an-unknown-method-call.qi create mode 100644 Task/Send-an-unknown-method-call/Ruby/send-an-unknown-method-call-1.rb create mode 100644 Task/Send-an-unknown-method-call/Ruby/send-an-unknown-method-call-2.rb create mode 100644 Task/Send-an-unknown-method-call/Smalltalk/send-an-unknown-method-call.st create mode 100644 Task/Send-an-unknown-method-call/Tcl/send-an-unknown-method-call.tcl create mode 100644 Task/Send-email/0DESCRIPTION create mode 100644 Task/Send-email/1META.yaml create mode 100644 Task/Send-email/Ada/send-email.ada create mode 100644 Task/Send-email/AutoHotkey/send-email.ahk create mode 100644 Task/Send-email/BBC-BASIC/send-email.bbc create mode 100644 Task/Send-email/C++/send-email.cpp create mode 100644 Task/Send-email/D/send-email.d create mode 100644 Task/Send-email/Delphi/send-email.delphi create mode 100644 Task/Send-email/Factor/send-email.factor create mode 100644 Task/Send-email/Fantom/send-email.fantom create mode 100644 Task/Send-email/Go/send-email.go create mode 100644 Task/Send-email/Java/send-email.java create mode 100644 Task/Send-email/Liberty-BASIC/send-email.liberty create mode 100644 Task/Send-email/LotusScript/send-email.lotusscript create mode 100644 Task/Send-email/Lua/send-email.lua create mode 100644 Task/Send-email/Mathematica/send-email-1.math create mode 100644 Task/Send-email/Mathematica/send-email-2.math create mode 100644 Task/Send-email/NewLISP/send-email.newlisp create mode 100644 Task/Send-email/OCaml/send-email.ocaml create mode 100644 Task/Send-email/PHP/send-email.php create mode 100644 Task/Send-email/Perl/send-email-1.pl create mode 100644 Task/Send-email/Perl/send-email-2.pl create mode 100644 Task/Send-email/Perl/send-email-3.pl create mode 100644 Task/Send-email/PicoLisp/send-email.l create mode 100644 Task/Send-email/Pike/send-email.pike create mode 100644 Task/Send-email/PureBasic/send-email.purebasic create mode 100644 Task/Send-email/Python/send-email-1.py create mode 100644 Task/Send-email/Python/send-email-2.py create mode 100644 Task/Send-email/REBOL/send-email.rebol create mode 100644 Task/Send-email/Racket/send-email.rkt create mode 100644 Task/Send-email/Ruby/send-email.rb create mode 100644 Task/Send-email/SAS/send-email.sas create mode 100644 Task/Send-email/TUSCRIPT/send-email.tuscript create mode 100644 Task/Send-email/TXR/send-email.txr create mode 100644 Task/Send-email/Tcl/send-email.tcl create mode 100644 Task/Sequence-of-non-squares/0DESCRIPTION create mode 100644 Task/Sequence-of-non-squares/1META.yaml create mode 100644 Task/Sequence-of-non-squares/ALGOL-68/sequence-of-non-squares.alg create mode 100644 Task/Sequence-of-non-squares/AWK/sequence-of-non-squares.awk create mode 100644 Task/Sequence-of-non-squares/Ada/sequence-of-non-squares.ada create mode 100644 Task/Sequence-of-non-squares/AutoHotkey/sequence-of-non-squares.ahk create mode 100644 Task/Sequence-of-non-squares/BASIC/sequence-of-non-squares.basic create mode 100644 Task/Sequence-of-non-squares/BBC-BASIC/sequence-of-non-squares.bbc create mode 100644 Task/Sequence-of-non-squares/Bc/sequence-of-non-squares.bc create mode 100644 Task/Sequence-of-non-squares/Burlesque/sequence-of-non-squares.blq create mode 100644 Task/Sequence-of-non-squares/C++/sequence-of-non-squares.cpp create mode 100644 Task/Sequence-of-non-squares/C/sequence-of-non-squares.c create mode 100644 Task/Sequence-of-non-squares/Clojure/sequence-of-non-squares.clj create mode 100644 Task/Sequence-of-non-squares/CoffeeScript/sequence-of-non-squares-1.coffeescript create mode 100644 Task/Sequence-of-non-squares/CoffeeScript/sequence-of-non-squares-2.coffeescript create mode 100644 Task/Sequence-of-non-squares/Common-Lisp/sequence-of-non-squares.lisp create mode 100644 Task/Sequence-of-non-squares/D/sequence-of-non-squares.d create mode 100644 Task/Sequence-of-non-squares/Euphoria/sequence-of-non-squares.euphoria create mode 100644 Task/Sequence-of-non-squares/Fantom/sequence-of-non-squares.fantom create mode 100644 Task/Sequence-of-non-squares/Forth/sequence-of-non-squares.fth create mode 100644 Task/Sequence-of-non-squares/Fortran/sequence-of-non-squares.f create mode 100644 Task/Sequence-of-non-squares/GAP/sequence-of-non-squares.gap create mode 100644 Task/Sequence-of-non-squares/Go/sequence-of-non-squares.go create mode 100644 Task/Sequence-of-non-squares/Groovy/sequence-of-non-squares-1.groovy create mode 100644 Task/Sequence-of-non-squares/Groovy/sequence-of-non-squares-2.groovy create mode 100644 Task/Sequence-of-non-squares/Haskell/sequence-of-non-squares.hs create mode 100644 Task/Sequence-of-non-squares/HicEst/sequence-of-non-squares.hicest create mode 100644 Task/Sequence-of-non-squares/IDL/sequence-of-non-squares.idl create mode 100644 Task/Sequence-of-non-squares/Icon/sequence-of-non-squares.icon create mode 100644 Task/Sequence-of-non-squares/J/sequence-of-non-squares.j create mode 100644 Task/Sequence-of-non-squares/Java/sequence-of-non-squares.java create mode 100644 Task/Sequence-of-non-squares/Liberty-BASIC/sequence-of-non-squares.liberty create mode 100644 Task/Sequence-of-non-squares/Logo/sequence-of-non-squares.logo create mode 100644 Task/Sequence-of-non-squares/Lua/sequence-of-non-squares.lua create mode 100644 Task/Sequence-of-non-squares/MATLAB/sequence-of-non-squares-1.m create mode 100644 Task/Sequence-of-non-squares/MATLAB/sequence-of-non-squares-2.m create mode 100644 Task/Sequence-of-non-squares/MMIX/sequence-of-non-squares.mmix create mode 100644 Task/Sequence-of-non-squares/Mathematica/sequence-of-non-squares.math create mode 100644 Task/Sequence-of-non-squares/Maxima/sequence-of-non-squares.maxima create mode 100644 Task/Sequence-of-non-squares/Modula-3/sequence-of-non-squares.mod3 create mode 100644 Task/Sequence-of-non-squares/OCaml/sequence-of-non-squares.ocaml create mode 100644 Task/Sequence-of-non-squares/Oz/sequence-of-non-squares.oz create mode 100644 Task/Sequence-of-non-squares/PARI-GP/sequence-of-non-squares.pari create mode 100644 Task/Sequence-of-non-squares/PL-I/sequence-of-non-squares-1.pli create mode 100644 Task/Sequence-of-non-squares/PL-I/sequence-of-non-squares-2.pli create mode 100644 Task/Sequence-of-non-squares/PL-I/sequence-of-non-squares-3.pli create mode 100644 Task/Sequence-of-non-squares/Pascal/sequence-of-non-squares.pascal create mode 100644 Task/Sequence-of-non-squares/Perl-6/sequence-of-non-squares.pl6 create mode 100644 Task/Sequence-of-non-squares/Perl/sequence-of-non-squares.pl create mode 100644 Task/Sequence-of-non-squares/PicoLisp/sequence-of-non-squares.l create mode 100644 Task/Sequence-of-non-squares/PostScript/sequence-of-non-squares.ps create mode 100644 Task/Sequence-of-non-squares/PowerShell/sequence-of-non-squares-1.psh create mode 100644 Task/Sequence-of-non-squares/PowerShell/sequence-of-non-squares-2.psh create mode 100644 Task/Sequence-of-non-squares/PowerShell/sequence-of-non-squares-3.psh create mode 100644 Task/Sequence-of-non-squares/PureBasic/sequence-of-non-squares.purebasic create mode 100644 Task/Sequence-of-non-squares/Python/sequence-of-non-squares.py create mode 100644 Task/Sequence-of-non-squares/R/sequence-of-non-squares-1.r create mode 100644 Task/Sequence-of-non-squares/R/sequence-of-non-squares-2.r create mode 100644 Task/Sequence-of-non-squares/REXX/sequence-of-non-squares.rexx create mode 100644 Task/Sequence-of-non-squares/Racket/sequence-of-non-squares.rkt create mode 100644 Task/Sequence-of-non-squares/Ruby/sequence-of-non-squares.rb create mode 100644 Task/Sequence-of-non-squares/Scala/sequence-of-non-squares.scala create mode 100644 Task/Sequence-of-non-squares/Scheme/sequence-of-non-squares.ss create mode 100644 Task/Sequence-of-non-squares/Seed7/sequence-of-non-squares.seed7 create mode 100644 Task/Sequence-of-non-squares/Standard-ML/sequence-of-non-squares.ml create mode 100644 Task/Sequence-of-non-squares/TI-89-BASIC/sequence-of-non-squares-1.ti-89 create mode 100644 Task/Sequence-of-non-squares/TI-89-BASIC/sequence-of-non-squares-2.ti-89 create mode 100644 Task/Sequence-of-non-squares/Tcl/sequence-of-non-squares.tcl create mode 100644 Task/Sequence-of-non-squares/Ursala/sequence-of-non-squares.ursala create mode 100644 Task/Sequence-of-non-squares/XPL0/sequence-of-non-squares.xpl0 create mode 100644 Task/Set-consolidation/0DESCRIPTION create mode 100644 Task/Set-consolidation/Ada/set-consolidation-1.ada create mode 100644 Task/Set-consolidation/Ada/set-consolidation-2.ada create mode 100644 Task/Set-consolidation/Ada/set-consolidation-3.ada create mode 100644 Task/Set-consolidation/Bracmat/set-consolidation.bracmat create mode 100644 Task/Set-consolidation/C/set-consolidation-1.c create mode 100644 Task/Set-consolidation/C/set-consolidation-2.c create mode 100644 Task/Set-consolidation/D/set-consolidation-1.d create mode 100644 Task/Set-consolidation/D/set-consolidation-2.d create mode 100644 Task/Set-consolidation/Ela/set-consolidation-1.ela create mode 100644 Task/Set-consolidation/Ela/set-consolidation-2.ela create mode 100644 Task/Set-consolidation/Go/set-consolidation.go create mode 100644 Task/Set-consolidation/Haskell/set-consolidation.hs create mode 100644 Task/Set-consolidation/J/set-consolidation-1.j create mode 100644 Task/Set-consolidation/J/set-consolidation-2.j create mode 100644 Task/Set-consolidation/Java/set-consolidation.java create mode 100644 Task/Set-consolidation/Mathematica/set-consolidation.math create mode 100644 Task/Set-consolidation/OCaml/set-consolidation.ocaml create mode 100644 Task/Set-consolidation/PARI-GP/set-consolidation.pari create mode 100644 Task/Set-consolidation/Perl-6/set-consolidation.pl6 create mode 100644 Task/Set-consolidation/PicoLisp/set-consolidation-1.l create mode 100644 Task/Set-consolidation/PicoLisp/set-consolidation-2.l create mode 100644 Task/Set-consolidation/Python/set-consolidation-1.py create mode 100644 Task/Set-consolidation/Python/set-consolidation-2.py create mode 100644 Task/Set-consolidation/REXX/set-consolidation.rexx create mode 100644 Task/Set-consolidation/Tcl/set-consolidation-1.tcl create mode 100644 Task/Set-consolidation/Tcl/set-consolidation-2.tcl create mode 100644 Task/Set-of-real-numbers/0DESCRIPTION create mode 100644 Task/Set-of-real-numbers/C-sharp/set-of-real-numbers-1.cs create mode 100644 Task/Set-of-real-numbers/C-sharp/set-of-real-numbers-2.cs create mode 100644 Task/Set-of-real-numbers/D/set-of-real-numbers.d create mode 100644 Task/Set-of-real-numbers/J/set-of-real-numbers-1.j create mode 100644 Task/Set-of-real-numbers/J/set-of-real-numbers-10.j create mode 100644 Task/Set-of-real-numbers/J/set-of-real-numbers-11.j create mode 100644 Task/Set-of-real-numbers/J/set-of-real-numbers-12.j create mode 100644 Task/Set-of-real-numbers/J/set-of-real-numbers-2.j create mode 100644 Task/Set-of-real-numbers/J/set-of-real-numbers-3.j create mode 100644 Task/Set-of-real-numbers/J/set-of-real-numbers-4.j create mode 100644 Task/Set-of-real-numbers/J/set-of-real-numbers-5.j create mode 100644 Task/Set-of-real-numbers/J/set-of-real-numbers-6.j create mode 100644 Task/Set-of-real-numbers/J/set-of-real-numbers-7.j create mode 100644 Task/Set-of-real-numbers/J/set-of-real-numbers-8.j create mode 100644 Task/Set-of-real-numbers/J/set-of-real-numbers-9.j create mode 100644 Task/Set-of-real-numbers/Perl-6/set-of-real-numbers.pl6 create mode 100644 Task/Set-of-real-numbers/Perl/set-of-real-numbers-1.pl create mode 100644 Task/Set-of-real-numbers/Perl/set-of-real-numbers-2.pl create mode 100644 Task/Set-of-real-numbers/Python/set-of-real-numbers.py create mode 100644 Task/Set-of-real-numbers/REXX/set-of-real-numbers-1.rexx create mode 100644 Task/Set-of-real-numbers/REXX/set-of-real-numbers-2.rexx create mode 100644 Task/Set-of-real-numbers/Tcl/set-of-real-numbers-1.tcl create mode 100644 Task/Set-of-real-numbers/Tcl/set-of-real-numbers-2.tcl create mode 100644 Task/Set-of-real-numbers/Tcl/set-of-real-numbers-3.tcl create mode 100644 Task/Set/0DESCRIPTION create mode 100644 Task/Set/1META.yaml create mode 100644 Task/Set/Ada/set.ada create mode 100644 Task/Set/BBC-BASIC/set.bbc create mode 100644 Task/Set/C++/set.cpp create mode 100644 Task/Set/C/set.c create mode 100644 Task/Set/Clojure/set.clj create mode 100644 Task/Set/CoffeeScript/set.coffeescript create mode 100644 Task/Set/Common-Lisp/set.lisp create mode 100644 Task/Set/D/set.d create mode 100644 Task/Set/Factor/set.factor create mode 100644 Task/Set/Go/set.go create mode 100644 Task/Set/Groovy/set.groovy create mode 100644 Task/Set/Haskell/set-1.hs create mode 100644 Task/Set/Haskell/set-2.hs create mode 100644 Task/Set/Icon/set-1.icon create mode 100644 Task/Set/Icon/set-2.icon create mode 100644 Task/Set/J/set-1.j create mode 100644 Task/Set/J/set-2.j create mode 100644 Task/Set/J/set-3.j create mode 100644 Task/Set/J/set-4.j create mode 100644 Task/Set/Java/set.java create mode 100644 Task/Set/Liberty-BASIC/set.liberty create mode 100644 Task/Set/MATLAB/set.m create mode 100644 Task/Set/Maple/set.maple create mode 100644 Task/Set/Mathematica/set.math create mode 100644 Task/Set/Maxima/set.maxima create mode 100644 Task/Set/OCaml/set.ocaml create mode 100644 Task/Set/Objective-C/set.m create mode 100644 Task/Set/PARI-GP/set.pari create mode 100644 Task/Set/Pascal/set.pascal create mode 100644 Task/Set/Perl-6/set.pl6 create mode 100644 Task/Set/Perl/set.pl create mode 100644 Task/Set/PicoLisp/set-1.l create mode 100644 Task/Set/PicoLisp/set-2.l create mode 100644 Task/Set/Prolog/set.pro create mode 100644 Task/Set/PureBasic/set.purebasic create mode 100644 Task/Set/Python/set.py create mode 100644 Task/Set/REXX/set.rexx create mode 100644 Task/Set/Racket/set.rkt create mode 100644 Task/Set/Ruby/set.rb create mode 100644 Task/Set/Scala/set.scala create mode 100644 Task/Set/Scheme/set.ss create mode 100644 Task/Set/Seed7/set.seed7 create mode 100644 Task/Set/Smalltalk/set.st create mode 100644 Task/Set/Tcl/set.tcl diff --git a/Conf/task.yaml b/Conf/task.yaml index 62cf250f0d..8f8eaceb54 100644 --- a/Conf/task.yaml +++ b/Conf/task.yaml @@ -45,7 +45,7 @@ Averages/Simple moving average: Balanced brackets: Balanced ternary: Best shuffle: -# Binary digits: +Binary digits: Binary search: Binary strings: Bitcoin/address validation: @@ -65,7 +65,7 @@ Bitwise operations: Boolean values: Box the compass: Break OO privacy: -# Brownian tree: +Brownian tree: Bulls and cows: Bulls and cows/Player: @@ -79,7 +79,7 @@ Call an object method: Canny edge detector: Carmichael 3 strong pseudoprimes: Case-sensitivity of identifiers: -# Catalan numbers: +Catalan numbers: Catmull–Clark subdivision surface: Character codes: Character matching: @@ -112,7 +112,7 @@ 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: +Copy a string: Count in factors: Count in octal: Count occurrences of a substring: @@ -152,7 +152,7 @@ Doubly-linked list/Definition: Doubly-linked list/Element definition: Doubly-linked list/Element insertion: Doubly-linked list/Traversal: -# Dragon curve: +Dragon curve: Draw a cuboid: Draw a sphere: Dutch national flag problem: @@ -166,7 +166,7 @@ Empty string: Enforced immutability: Entropy: Enumerations: -# Environment variables: +Environment variables: Equilibrium index: Ethiopian multiplication: Euler method: @@ -177,11 +177,11 @@ Evolutionary algorithm: Exceptions: Exceptions/Catch an exception thrown in a nested call: Executable library: -# Execute a Markov algorithm: +Execute a Markov algorithm: Execute a system command: -# Execute Brain****: +# Execute Brainf***: Execute HQ9+: -# Execute SNUSP: +Execute SNUSP: Exponentiation operator: Extend your language: Extreme floating point values: @@ -219,6 +219,7 @@ Function composition: Function definition: Function frequency: Function prototype: + Galton box animation: Gamma function: Generator/Exponential: @@ -237,6 +238,7 @@ Guess the number/With feedback (player): GUI component interaction: GUI enabling/disabling of controls: GUI/Maximum window dimensions: + Hailstone sequence: Hamming numbers: Handle a signal: @@ -268,6 +270,7 @@ HTTPS: HTTPS/Authenticated: HTTPS/Client-authenticated: Huffman coding: + I before E except after C: Identity matrix: Image convolution: @@ -284,11 +287,13 @@ Interactive programming: Introspection: Inverted index: Inverted syntax: + Jensen's Device: #' Josephus problem: Joystick position: JSON: Jump anywhere: + K-means++ clustering: Kaprekar numbers: Keyboard input/Flush the keyboard buffer: @@ -302,6 +307,7 @@ Knapsack problem/Unbounded: Knight's tour: #' Knuth shuffle: Knuth's algorithm S: #' + Langton's ant: #' Largest int from concatenated ints: Last Friday of each month: @@ -336,6 +342,7 @@ LU decomposition: Lucas-Lehmer test: Luhn test of credit card numbers: LZW compression: + Mad Libs: Main step of GOST 28147-89: Man or boy test: @@ -375,9 +382,136 @@ Multisplit: Mutex: Mutual recursion: +N-queens problem: +Named parameters: Narcissist: +Nautical bell: +Non-continuous subsequences: +Non-decimal radices/Convert: +Non-decimal radices/Input: +Non-decimal radices/Output: +Nth root: +Null object: +Number names: +Number reversal game: +Numeric error propagation: +Numerical integration: +Numerical integration/Gauss-Legendre Quadrature: + +Object serialization: +OLE Automation: +One of n lines in a file: +One-dimensional cellular automata: +OpenGL: +Operator precedence: +Optional parameters: +Order two numerical lists: +Ordered Partitions: Ordered words: + +Palindrome detection: +Pangram checker: +Parallel calculations: +Parametric polymorphism: +Parametrized SQL statement: +Parsing/RPN calculator algorithm: +Parsing/RPN to infix conversion: +Parsing/Shunting-yard algorithm: +Partial function application: +Pascal's triangle: #' +Pascal's triangle/Puzzle: #' +Pattern matching: +Percentage difference between images: +Perfect numbers: +Permutation test: +Permutations: +Permutations by swapping: +Permutations/Derangements: Pi: +Pick random element: +Pig the dice game: +Pig the dice game/Player: +Pinstripe/Display: +Pinstripe/Printer: +Play recorded sounds: +Playing cards: +Plot coordinate pairs: +Pointers and references: +Polymorphic copy: +Polymorphism: +Polynomial long division: +Polynomial regression: +Power set: +Pragmatic directives: +Price fraction: +Primality by trial division: +Prime decomposition: +Priority queue: +Probabilistic choice: +Problem of Apollonius: +Program name: +Program termination: +Pythagorean triples: +QR decomposition: +Quaternion type: +Queue/Definition: +Queue/Usage: Quine: -# ROT-13: + +Random number generator (device): +Random number generator (included): +Random numbers: +Range expansion: +Range extraction: +Rate counter: +Ray-casting algorithm: +RCRPG: +Read a configuration file: +Read a file line by line: +Read a specific line from a file: +Read entire file: +Real constants and functions: +Record sound: +Reduced row echelon form: +Regular expressions: +Remove duplicate elements: +Remove lines from a file: +Rename a file: +Rendezvous: +Repeat a string: +Resistor mesh: +Respond to an unknown method call: +Return multiple values: +Reverse a string: +RIPEMD-160: +Rock-paper-scissors: +Roman numerals/Decode: +Roman numerals/Encode: +Roots of a function: +Roots of a quadratic function: +Roots of unity: +Rosetta Code/Count examples: +Rosetta Code/Find unimplemented tasks: +Rosetta Code/Fix code tags: +Rosetta Code/Rank languages by popularity: +Rot-13: +Run-length encoding: +Runtime evaluation: +Runtime evaluation/In an environment: +S-Expressions: +Safe addition: +Same Fringe: +Scope modifiers: +Scope/Function names and labels: Search a list: +Secure temporary file: +SEDOLs: +Self-describing numbers: +Self-referential sequence: +Semordnilap: +Send an unknown method call: +Send email: +Sequence of non-squares: +Set: +Set consolidation: +Set of real numbers: diff --git a/Lang/0815/Binary-digits b/Lang/0815/Binary-digits new file mode 120000 index 0000000000..ee1bc56cd8 --- /dev/null +++ b/Lang/0815/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/0815 \ No newline at end of file diff --git a/Lang/0815/Reverse-a-string b/Lang/0815/Reverse-a-string new file mode 120000 index 0000000000..cb23149222 --- /dev/null +++ b/Lang/0815/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/0815 \ No newline at end of file diff --git a/Lang/4DOS-Batch/Repeat-a-string b/Lang/4DOS-Batch/Repeat-a-string new file mode 120000 index 0000000000..d139b535a6 --- /dev/null +++ b/Lang/4DOS-Batch/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/4DOS-Batch \ No newline at end of file diff --git a/Lang/6502-Assembly/Rot-13 b/Lang/6502-Assembly/Rot-13 new file mode 120000 index 0000000000..5079a0110e --- /dev/null +++ b/Lang/6502-Assembly/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/6502-Assembly \ No newline at end of file diff --git a/Lang/6800-Assembly/Loops-Infinite b/Lang/6800-Assembly/Loops-Infinite new file mode 120000 index 0000000000..6472f52bec --- /dev/null +++ b/Lang/6800-Assembly/Loops-Infinite @@ -0,0 +1 @@ +../../Task/Loops-Infinite/6800-Assembly \ No newline at end of file diff --git a/Lang/ABAP/Copy-a-string b/Lang/ABAP/Copy-a-string new file mode 120000 index 0000000000..51fdfcbf7e --- /dev/null +++ b/Lang/ABAP/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/ABAP \ No newline at end of file diff --git a/Lang/ABAP/Permutations b/Lang/ABAP/Permutations new file mode 120000 index 0000000000..57d6e0bfcc --- /dev/null +++ b/Lang/ABAP/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/ABAP \ No newline at end of file diff --git a/Lang/ABAP/Prime-decomposition b/Lang/ABAP/Prime-decomposition new file mode 120000 index 0000000000..9f2456b94c --- /dev/null +++ b/Lang/ABAP/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/ABAP \ No newline at end of file diff --git a/Lang/ACL2/Arbitrary-precision-integers--included- b/Lang/ACL2/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..588067f7e4 --- /dev/null +++ b/Lang/ACL2/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Arbitrary-precision-integers-included b/Lang/ACL2/Arbitrary-precision-integers-included deleted file mode 120000 index ef5de56eee..0000000000 --- a/Lang/ACL2/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Binary-digits b/Lang/ACL2/Binary-digits new file mode 120000 index 0000000000..721cfcd2d8 --- /dev/null +++ b/Lang/ACL2/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Non-decimal-radices-Convert b/Lang/ACL2/Non-decimal-radices-Convert new file mode 120000 index 0000000000..c74f90fe34 --- /dev/null +++ b/Lang/ACL2/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/One-dimensional-cellular-automata b/Lang/ACL2/One-dimensional-cellular-automata new file mode 120000 index 0000000000..382b92e7f4 --- /dev/null +++ b/Lang/ACL2/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Palindrome-detection b/Lang/ACL2/Palindrome-detection new file mode 120000 index 0000000000..f4901eec14 --- /dev/null +++ b/Lang/ACL2/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Pangram-checker b/Lang/ACL2/Pangram-checker new file mode 120000 index 0000000000..3df7f0e509 --- /dev/null +++ b/Lang/ACL2/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Pick-random-element b/Lang/ACL2/Pick-random-element new file mode 120000 index 0000000000..bd3f7b445f --- /dev/null +++ b/Lang/ACL2/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Playing-cards b/Lang/ACL2/Playing-cards new file mode 120000 index 0000000000..ddc300d72d --- /dev/null +++ b/Lang/ACL2/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Primality-by-trial-division b/Lang/ACL2/Primality-by-trial-division new file mode 120000 index 0000000000..59771e79a9 --- /dev/null +++ b/Lang/ACL2/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Prime-decomposition b/Lang/ACL2/Prime-decomposition new file mode 120000 index 0000000000..c8bdffa820 --- /dev/null +++ b/Lang/ACL2/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Queue-Definition b/Lang/ACL2/Queue-Definition new file mode 120000 index 0000000000..64fc118f23 --- /dev/null +++ b/Lang/ACL2/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Real-constants-and-functions b/Lang/ACL2/Real-constants-and-functions new file mode 120000 index 0000000000..63718ed6a5 --- /dev/null +++ b/Lang/ACL2/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Remove-duplicate-elements b/Lang/ACL2/Remove-duplicate-elements new file mode 120000 index 0000000000..2faa993053 --- /dev/null +++ b/Lang/ACL2/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Return-multiple-values b/Lang/ACL2/Return-multiple-values new file mode 120000 index 0000000000..c9d1cda416 --- /dev/null +++ b/Lang/ACL2/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Reverse-a-string b/Lang/ACL2/Reverse-a-string new file mode 120000 index 0000000000..9470bad754 --- /dev/null +++ b/Lang/ACL2/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/ACL2 \ No newline at end of file diff --git a/Lang/ACL2/Rot-13 b/Lang/ACL2/Rot-13 new file mode 120000 index 0000000000..f6198eed91 --- /dev/null +++ b/Lang/ACL2/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/ACL2 \ No newline at end of file diff --git a/Lang/ALGOL-68/Binary-digits b/Lang/ALGOL-68/Binary-digits new file mode 120000 index 0000000000..886e1a195a --- /dev/null +++ b/Lang/ALGOL-68/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/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..58b7604557 --- /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/Calendar-for-real-programmers b/Lang/ALGOL-68/Calendar-for-real-programmers deleted file mode 120000 index 4cf5bc4e24..0000000000 --- a/Lang/ALGOL-68/Calendar-for-real-programmers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Calendar-for-real-programmers/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Copy-a-string b/Lang/ALGOL-68/Copy-a-string new file mode 120000 index 0000000000..a2fc36bb1c --- /dev/null +++ b/Lang/ALGOL-68/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Dragon-curve b/Lang/ALGOL-68/Dragon-curve new file mode 120000 index 0000000000..71e4e4d832 --- /dev/null +++ b/Lang/ALGOL-68/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Environment-variables b/Lang/ALGOL-68/Environment-variables new file mode 120000 index 0000000000..b0c582f062 --- /dev/null +++ b/Lang/ALGOL-68/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/N-queens-problem b/Lang/ALGOL-68/N-queens-problem new file mode 120000 index 0000000000..37885ee4a5 --- /dev/null +++ b/Lang/ALGOL-68/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Named-parameters b/Lang/ALGOL-68/Named-parameters new file mode 120000 index 0000000000..126dc876c6 --- /dev/null +++ b/Lang/ALGOL-68/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Non-continuous-subsequences b/Lang/ALGOL-68/Non-continuous-subsequences new file mode 120000 index 0000000000..9fc6809c13 --- /dev/null +++ b/Lang/ALGOL-68/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Non-decimal-radices-Convert b/Lang/ALGOL-68/Non-decimal-radices-Convert new file mode 120000 index 0000000000..c578144e4e --- /dev/null +++ b/Lang/ALGOL-68/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Non-decimal-radices-Input b/Lang/ALGOL-68/Non-decimal-radices-Input new file mode 120000 index 0000000000..ee7fa65f16 --- /dev/null +++ b/Lang/ALGOL-68/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Non-decimal-radices-Output b/Lang/ALGOL-68/Non-decimal-radices-Output new file mode 120000 index 0000000000..f6111fa9fd --- /dev/null +++ b/Lang/ALGOL-68/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Nth-root b/Lang/ALGOL-68/Nth-root new file mode 120000 index 0000000000..21867b399d --- /dev/null +++ b/Lang/ALGOL-68/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Null-object b/Lang/ALGOL-68/Null-object new file mode 120000 index 0000000000..2df32d1b9c --- /dev/null +++ b/Lang/ALGOL-68/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Number-names b/Lang/ALGOL-68/Number-names new file mode 120000 index 0000000000..4df416b8bb --- /dev/null +++ b/Lang/ALGOL-68/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Numerical-integration b/Lang/ALGOL-68/Numerical-integration new file mode 120000 index 0000000000..a686210e29 --- /dev/null +++ b/Lang/ALGOL-68/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Object-serialization b/Lang/ALGOL-68/Object-serialization new file mode 120000 index 0000000000..aa5ea19023 --- /dev/null +++ b/Lang/ALGOL-68/Object-serialization @@ -0,0 +1 @@ +../../Task/Object-serialization/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/One-dimensional-cellular-automata b/Lang/ALGOL-68/One-dimensional-cellular-automata new file mode 120000 index 0000000000..ed6e05e6aa --- /dev/null +++ b/Lang/ALGOL-68/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Palindrome-detection b/Lang/ALGOL-68/Palindrome-detection new file mode 120000 index 0000000000..ed92040599 --- /dev/null +++ b/Lang/ALGOL-68/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Pangram-checker b/Lang/ALGOL-68/Pangram-checker new file mode 120000 index 0000000000..a6c10328ed --- /dev/null +++ b/Lang/ALGOL-68/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Partial-function-application b/Lang/ALGOL-68/Partial-function-application new file mode 120000 index 0000000000..a80c00a4ce --- /dev/null +++ b/Lang/ALGOL-68/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Pascals-triangle b/Lang/ALGOL-68/Pascals-triangle new file mode 120000 index 0000000000..241f3fe5e0 --- /dev/null +++ b/Lang/ALGOL-68/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Pascals-triangle-Puzzle b/Lang/ALGOL-68/Pascals-triangle-Puzzle new file mode 120000 index 0000000000..1f0605e194 --- /dev/null +++ b/Lang/ALGOL-68/Pascals-triangle-Puzzle @@ -0,0 +1 @@ +../../Task/Pascals-triangle-Puzzle/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Perfect-numbers b/Lang/ALGOL-68/Perfect-numbers new file mode 120000 index 0000000000..ab96e87e47 --- /dev/null +++ b/Lang/ALGOL-68/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Permutations b/Lang/ALGOL-68/Permutations new file mode 120000 index 0000000000..807ed65b6e --- /dev/null +++ b/Lang/ALGOL-68/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Playing-cards b/Lang/ALGOL-68/Playing-cards new file mode 120000 index 0000000000..d0c292a772 --- /dev/null +++ b/Lang/ALGOL-68/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Plot-coordinate-pairs b/Lang/ALGOL-68/Plot-coordinate-pairs new file mode 120000 index 0000000000..fb29e0a296 --- /dev/null +++ b/Lang/ALGOL-68/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Pointers-and-references b/Lang/ALGOL-68/Pointers-and-references new file mode 120000 index 0000000000..5eb347f314 --- /dev/null +++ b/Lang/ALGOL-68/Pointers-and-references @@ -0,0 +1 @@ +../../Task/Pointers-and-references/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Polynomial-regression b/Lang/ALGOL-68/Polynomial-regression new file mode 120000 index 0000000000..d45b7c656c --- /dev/null +++ b/Lang/ALGOL-68/Polynomial-regression @@ -0,0 +1 @@ +../../Task/Polynomial-regression/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Power-set b/Lang/ALGOL-68/Power-set new file mode 120000 index 0000000000..52a4d0fbd6 --- /dev/null +++ b/Lang/ALGOL-68/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Pragmatic-directives b/Lang/ALGOL-68/Pragmatic-directives new file mode 120000 index 0000000000..7ce8bff9f9 --- /dev/null +++ b/Lang/ALGOL-68/Pragmatic-directives @@ -0,0 +1 @@ +../../Task/Pragmatic-directives/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Price-fraction b/Lang/ALGOL-68/Price-fraction new file mode 120000 index 0000000000..b08625b69a --- /dev/null +++ b/Lang/ALGOL-68/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Primality-by-trial-division b/Lang/ALGOL-68/Primality-by-trial-division new file mode 120000 index 0000000000..c1766b1eab --- /dev/null +++ b/Lang/ALGOL-68/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Prime-decomposition b/Lang/ALGOL-68/Prime-decomposition new file mode 120000 index 0000000000..488051810c --- /dev/null +++ b/Lang/ALGOL-68/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Probabilistic-choice b/Lang/ALGOL-68/Probabilistic-choice new file mode 120000 index 0000000000..d8a5bc6506 --- /dev/null +++ b/Lang/ALGOL-68/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Program-termination b/Lang/ALGOL-68/Program-termination new file mode 120000 index 0000000000..dd87a29f57 --- /dev/null +++ b/Lang/ALGOL-68/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Quaternion-type b/Lang/ALGOL-68/Quaternion-type new file mode 120000 index 0000000000..9934ee409f --- /dev/null +++ b/Lang/ALGOL-68/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Random-number-generator--included- b/Lang/ALGOL-68/Random-number-generator--included- new file mode 120000 index 0000000000..e6483bc15e --- /dev/null +++ b/Lang/ALGOL-68/Random-number-generator--included- @@ -0,0 +1 @@ +../../Task/Random-number-generator--included-/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Random-numbers b/Lang/ALGOL-68/Random-numbers new file mode 120000 index 0000000000..8cf9e25de3 --- /dev/null +++ b/Lang/ALGOL-68/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Range-expansion b/Lang/ALGOL-68/Range-expansion new file mode 120000 index 0000000000..455967a550 --- /dev/null +++ b/Lang/ALGOL-68/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Range-extraction b/Lang/ALGOL-68/Range-extraction new file mode 120000 index 0000000000..2d7e949313 --- /dev/null +++ b/Lang/ALGOL-68/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Read-a-file-line-by-line b/Lang/ALGOL-68/Read-a-file-line-by-line new file mode 120000 index 0000000000..50d4e32164 --- /dev/null +++ b/Lang/ALGOL-68/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Read-entire-file b/Lang/ALGOL-68/Read-entire-file new file mode 120000 index 0000000000..121ce2c341 --- /dev/null +++ b/Lang/ALGOL-68/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Real-constants-and-functions b/Lang/ALGOL-68/Real-constants-and-functions new file mode 120000 index 0000000000..95f5636760 --- /dev/null +++ b/Lang/ALGOL-68/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Reduced-row-echelon-form b/Lang/ALGOL-68/Reduced-row-echelon-form new file mode 120000 index 0000000000..d4b8773c3c --- /dev/null +++ b/Lang/ALGOL-68/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Regular-expressions b/Lang/ALGOL-68/Regular-expressions new file mode 120000 index 0000000000..a1d7d37848 --- /dev/null +++ b/Lang/ALGOL-68/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Rename-a-file b/Lang/ALGOL-68/Rename-a-file new file mode 120000 index 0000000000..7172e98588 --- /dev/null +++ b/Lang/ALGOL-68/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Repeat-a-string b/Lang/ALGOL-68/Repeat-a-string new file mode 120000 index 0000000000..b7a0cf5099 --- /dev/null +++ b/Lang/ALGOL-68/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Reverse-a-string b/Lang/ALGOL-68/Reverse-a-string new file mode 120000 index 0000000000..b306fb2362 --- /dev/null +++ b/Lang/ALGOL-68/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Roman-numerals-Decode b/Lang/ALGOL-68/Roman-numerals-Decode new file mode 120000 index 0000000000..2c69475d77 --- /dev/null +++ b/Lang/ALGOL-68/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Roman-numerals-Encode b/Lang/ALGOL-68/Roman-numerals-Encode new file mode 120000 index 0000000000..82fb61c06e --- /dev/null +++ b/Lang/ALGOL-68/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Roots-of-a-function b/Lang/ALGOL-68/Roots-of-a-function new file mode 120000 index 0000000000..7742ce8527 --- /dev/null +++ b/Lang/ALGOL-68/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Roots-of-a-quadratic-function b/Lang/ALGOL-68/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..57df0bd40c --- /dev/null +++ b/Lang/ALGOL-68/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Roots-of-unity b/Lang/ALGOL-68/Roots-of-unity new file mode 120000 index 0000000000..78720d8df5 --- /dev/null +++ b/Lang/ALGOL-68/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Rosetta-Code-Rank-languages-by-popularity b/Lang/ALGOL-68/Rosetta-Code-Rank-languages-by-popularity new file mode 120000 index 0000000000..65acf74bf3 --- /dev/null +++ b/Lang/ALGOL-68/Rosetta-Code-Rank-languages-by-popularity @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-popularity/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Rot-13 b/Lang/ALGOL-68/Rot-13 new file mode 120000 index 0000000000..9e325bec18 --- /dev/null +++ b/Lang/ALGOL-68/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Run-length-encoding b/Lang/ALGOL-68/Run-length-encoding new file mode 120000 index 0000000000..c6d7b91c5b --- /dev/null +++ b/Lang/ALGOL-68/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Runtime-evaluation b/Lang/ALGOL-68/Runtime-evaluation new file mode 120000 index 0000000000..5cd647f4b4 --- /dev/null +++ b/Lang/ALGOL-68/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Runtime-evaluation-In-an-environment b/Lang/ALGOL-68/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..aac0a36bb9 --- /dev/null +++ b/Lang/ALGOL-68/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/SEDOLs b/Lang/ALGOL-68/SEDOLs new file mode 120000 index 0000000000..01cf86de6d --- /dev/null +++ b/Lang/ALGOL-68/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-68/Sequence-of-non-squares b/Lang/ALGOL-68/Sequence-of-non-squares new file mode 120000 index 0000000000..3e550fe839 --- /dev/null +++ b/Lang/ALGOL-68/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/ALGOL-68 \ No newline at end of file diff --git a/Lang/ALGOL-W/Roman-numerals-Encode b/Lang/ALGOL-W/Roman-numerals-Encode new file mode 120000 index 0000000000..d58d98a607 --- /dev/null +++ b/Lang/ALGOL-W/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/ALGOL-W \ No newline at end of file diff --git a/Lang/ANTLR/Parsing-RPN-calculator-algorithm b/Lang/ANTLR/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..eab07bd5c0 --- /dev/null +++ b/Lang/ANTLR/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/ANTLR \ No newline at end of file diff --git a/Lang/ANTLR/Roman-numerals-Decode b/Lang/ANTLR/Roman-numerals-Decode new file mode 120000 index 0000000000..436a478965 --- /dev/null +++ b/Lang/ANTLR/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/ANTLR \ No newline at end of file diff --git a/Lang/APL/Pangram-checker b/Lang/APL/Pangram-checker new file mode 120000 index 0000000000..cfe41fd966 --- /dev/null +++ b/Lang/APL/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/APL \ No newline at end of file diff --git a/Lang/APL/Pascals-triangle b/Lang/APL/Pascals-triangle new file mode 120000 index 0000000000..71bd4ebcce --- /dev/null +++ b/Lang/APL/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/APL \ No newline at end of file diff --git a/Lang/APL/Run-length-encoding b/Lang/APL/Run-length-encoding new file mode 120000 index 0000000000..daa7375650 --- /dev/null +++ b/Lang/APL/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/APL \ No newline at end of file diff --git a/Lang/ATS/Return-multiple-values b/Lang/ATS/Return-multiple-values new file mode 120000 index 0000000000..f1583eda6e --- /dev/null +++ b/Lang/ATS/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/ATS \ No newline at end of file diff --git a/Lang/AWK/Binary-digits b/Lang/AWK/Binary-digits new file mode 120000 index 0000000000..f73e73035b --- /dev/null +++ b/Lang/AWK/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/AWK \ No newline at end of file diff --git a/Lang/AWK/Catalan-numbers b/Lang/AWK/Catalan-numbers new file mode 120000 index 0000000000..9b2e9dc5d4 --- /dev/null +++ b/Lang/AWK/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/AWK \ No newline at end of file diff --git a/Lang/AWK/Copy-a-string b/Lang/AWK/Copy-a-string new file mode 120000 index 0000000000..d0772ffb60 --- /dev/null +++ b/Lang/AWK/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/AWK \ No newline at end of file diff --git a/Lang/AWK/Environment-variables b/Lang/AWK/Environment-variables new file mode 120000 index 0000000000..51f4f4853e --- /dev/null +++ b/Lang/AWK/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/AWK \ No newline at end of file diff --git a/Lang/AWK/Non-decimal-radices-Convert b/Lang/AWK/Non-decimal-radices-Convert new file mode 120000 index 0000000000..417df49352 --- /dev/null +++ b/Lang/AWK/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/AWK \ No newline at end of file diff --git a/Lang/AWK/Non-decimal-radices-Output b/Lang/AWK/Non-decimal-radices-Output new file mode 120000 index 0000000000..a58f26ac0e --- /dev/null +++ b/Lang/AWK/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/AWK \ No newline at end of file diff --git a/Lang/AWK/Nth-root b/Lang/AWK/Nth-root new file mode 120000 index 0000000000..ce462ded60 --- /dev/null +++ b/Lang/AWK/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/AWK \ No newline at end of file diff --git a/Lang/AWK/Number-names b/Lang/AWK/Number-names new file mode 120000 index 0000000000..80ddb739a8 --- /dev/null +++ b/Lang/AWK/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/AWK \ No newline at end of file diff --git a/Lang/AWK/Number-reversal-game b/Lang/AWK/Number-reversal-game new file mode 120000 index 0000000000..c0cf049887 --- /dev/null +++ b/Lang/AWK/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/AWK \ No newline at end of file diff --git a/Lang/AWK/One-dimensional-cellular-automata b/Lang/AWK/One-dimensional-cellular-automata new file mode 120000 index 0000000000..065a82d630 --- /dev/null +++ b/Lang/AWK/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/AWK \ No newline at end of file diff --git a/Lang/AWK/Palindrome-detection b/Lang/AWK/Palindrome-detection new file mode 120000 index 0000000000..27febd5f39 --- /dev/null +++ b/Lang/AWK/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/AWK \ No newline at end of file diff --git a/Lang/AWK/Pangram-checker b/Lang/AWK/Pangram-checker new file mode 120000 index 0000000000..ed25e3adaa --- /dev/null +++ b/Lang/AWK/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/AWK \ No newline at end of file diff --git a/Lang/AWK/Parsing-RPN-to-infix-conversion b/Lang/AWK/Parsing-RPN-to-infix-conversion new file mode 120000 index 0000000000..1736ee9ed2 --- /dev/null +++ b/Lang/AWK/Parsing-RPN-to-infix-conversion @@ -0,0 +1 @@ +../../Task/Parsing-RPN-to-infix-conversion/AWK \ No newline at end of file diff --git a/Lang/AWK/Pascals-triangle b/Lang/AWK/Pascals-triangle new file mode 120000 index 0000000000..4e9cdcda86 --- /dev/null +++ b/Lang/AWK/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/AWK \ No newline at end of file diff --git a/Lang/AWK/Perfect-numbers b/Lang/AWK/Perfect-numbers new file mode 120000 index 0000000000..be88f5b024 --- /dev/null +++ b/Lang/AWK/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/AWK \ No newline at end of file diff --git a/Lang/AWK/Price-fraction b/Lang/AWK/Price-fraction new file mode 120000 index 0000000000..606f5b6ed6 --- /dev/null +++ b/Lang/AWK/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/AWK \ No newline at end of file diff --git a/Lang/AWK/Primality-by-trial-division b/Lang/AWK/Primality-by-trial-division new file mode 120000 index 0000000000..3c46d98749 --- /dev/null +++ b/Lang/AWK/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/AWK \ No newline at end of file diff --git a/Lang/AWK/Prime-decomposition b/Lang/AWK/Prime-decomposition new file mode 120000 index 0000000000..41b36a56c4 --- /dev/null +++ b/Lang/AWK/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/AWK \ No newline at end of file diff --git a/Lang/AWK/Probabilistic-choice b/Lang/AWK/Probabilistic-choice new file mode 120000 index 0000000000..939cee9162 --- /dev/null +++ b/Lang/AWK/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/AWK \ No newline at end of file diff --git a/Lang/AWK/Program-termination b/Lang/AWK/Program-termination new file mode 120000 index 0000000000..07e9ff40a4 --- /dev/null +++ b/Lang/AWK/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/AWK \ No newline at end of file diff --git a/Lang/AWK/Queue-Definition b/Lang/AWK/Queue-Definition new file mode 120000 index 0000000000..e8d85677d6 --- /dev/null +++ b/Lang/AWK/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/AWK \ No newline at end of file diff --git a/Lang/AWK/Random-numbers b/Lang/AWK/Random-numbers new file mode 120000 index 0000000000..6eed7b3250 --- /dev/null +++ b/Lang/AWK/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/AWK \ No newline at end of file diff --git a/Lang/AWK/Range-extraction b/Lang/AWK/Range-extraction new file mode 120000 index 0000000000..7e13730e9f --- /dev/null +++ b/Lang/AWK/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/AWK \ No newline at end of file diff --git a/Lang/AWK/Read-a-file-line-by-line b/Lang/AWK/Read-a-file-line-by-line new file mode 120000 index 0000000000..27729a380f --- /dev/null +++ b/Lang/AWK/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/AWK \ No newline at end of file diff --git a/Lang/AWK/Read-a-specific-line-from-a-file b/Lang/AWK/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..0836cec516 --- /dev/null +++ b/Lang/AWK/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/AWK \ No newline at end of file diff --git a/Lang/AWK/Read-entire-file b/Lang/AWK/Read-entire-file new file mode 120000 index 0000000000..f0ebe7c559 --- /dev/null +++ b/Lang/AWK/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/AWK \ No newline at end of file diff --git a/Lang/AWK/Real-constants-and-functions b/Lang/AWK/Real-constants-and-functions new file mode 120000 index 0000000000..5ed8d7860e --- /dev/null +++ b/Lang/AWK/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/AWK \ No newline at end of file diff --git a/Lang/AWK/Regular-expressions b/Lang/AWK/Regular-expressions new file mode 120000 index 0000000000..8de084eec6 --- /dev/null +++ b/Lang/AWK/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/AWK \ No newline at end of file diff --git a/Lang/AWK/Remove-duplicate-elements b/Lang/AWK/Remove-duplicate-elements new file mode 120000 index 0000000000..ca47bc12dc --- /dev/null +++ b/Lang/AWK/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/AWK \ No newline at end of file diff --git a/Lang/AWK/Remove-lines-from-a-file b/Lang/AWK/Remove-lines-from-a-file new file mode 120000 index 0000000000..01ece2fc1d --- /dev/null +++ b/Lang/AWK/Remove-lines-from-a-file @@ -0,0 +1 @@ +../../Task/Remove-lines-from-a-file/AWK \ No newline at end of file diff --git a/Lang/AWK/Rename-a-file b/Lang/AWK/Rename-a-file new file mode 120000 index 0000000000..22238d75f7 --- /dev/null +++ b/Lang/AWK/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/AWK \ No newline at end of file diff --git a/Lang/AWK/Repeat-a-string b/Lang/AWK/Repeat-a-string new file mode 120000 index 0000000000..a27eb46675 --- /dev/null +++ b/Lang/AWK/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/AWK \ No newline at end of file diff --git a/Lang/AWK/Reverse-a-string b/Lang/AWK/Reverse-a-string new file mode 120000 index 0000000000..eb5ee88f74 --- /dev/null +++ b/Lang/AWK/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/AWK \ No newline at end of file diff --git a/Lang/AWK/Roman-numerals-Decode b/Lang/AWK/Roman-numerals-Decode new file mode 120000 index 0000000000..11eaa14e20 --- /dev/null +++ b/Lang/AWK/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/AWK \ No newline at end of file diff --git a/Lang/AWK/Roman-numerals-Encode b/Lang/AWK/Roman-numerals-Encode new file mode 120000 index 0000000000..2bcc60ee9a --- /dev/null +++ b/Lang/AWK/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/AWK \ No newline at end of file diff --git a/Lang/AWK/Rosetta-Code-Rank-languages-by-popularity b/Lang/AWK/Rosetta-Code-Rank-languages-by-popularity new file mode 120000 index 0000000000..c0bfd6a30c --- /dev/null +++ b/Lang/AWK/Rosetta-Code-Rank-languages-by-popularity @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-popularity/AWK \ No newline at end of file diff --git a/Lang/AWK/Rot-13 b/Lang/AWK/Rot-13 new file mode 120000 index 0000000000..1fe0465526 --- /dev/null +++ b/Lang/AWK/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/AWK \ No newline at end of file diff --git a/Lang/AWK/Run-length-encoding b/Lang/AWK/Run-length-encoding new file mode 120000 index 0000000000..805c870f7f --- /dev/null +++ b/Lang/AWK/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/AWK \ No newline at end of file diff --git a/Lang/AWK/SEDOLs b/Lang/AWK/SEDOLs new file mode 120000 index 0000000000..c3647e97ce --- /dev/null +++ b/Lang/AWK/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/AWK \ No newline at end of file diff --git a/Lang/AWK/Scope-Function-names-and-labels b/Lang/AWK/Scope-Function-names-and-labels new file mode 120000 index 0000000000..fc1411aba5 --- /dev/null +++ b/Lang/AWK/Scope-Function-names-and-labels @@ -0,0 +1 @@ +../../Task/Scope-Function-names-and-labels/AWK \ No newline at end of file diff --git a/Lang/AWK/Self-describing-numbers b/Lang/AWK/Self-describing-numbers new file mode 120000 index 0000000000..a73b22cf1f --- /dev/null +++ b/Lang/AWK/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/AWK \ No newline at end of file diff --git a/Lang/AWK/Semordnilap b/Lang/AWK/Semordnilap new file mode 120000 index 0000000000..fd5bdb62b4 --- /dev/null +++ b/Lang/AWK/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/AWK \ No newline at end of file diff --git a/Lang/AWK/Sequence-of-non-squares b/Lang/AWK/Sequence-of-non-squares new file mode 120000 index 0000000000..83bbb31d43 --- /dev/null +++ b/Lang/AWK/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/AWK \ No newline at end of file diff --git a/Lang/ActionScript/Copy-a-string b/Lang/ActionScript/Copy-a-string new file mode 120000 index 0000000000..1e5d522f1d --- /dev/null +++ b/Lang/ActionScript/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Null-object b/Lang/ActionScript/Null-object new file mode 120000 index 0000000000..0adb420195 --- /dev/null +++ b/Lang/ActionScript/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Numerical-integration b/Lang/ActionScript/Numerical-integration new file mode 120000 index 0000000000..bb4fe1f5f0 --- /dev/null +++ b/Lang/ActionScript/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Palindrome-detection b/Lang/ActionScript/Palindrome-detection new file mode 120000 index 0000000000..e1cf574cb6 --- /dev/null +++ b/Lang/ActionScript/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Pangram-checker b/Lang/ActionScript/Pangram-checker new file mode 120000 index 0000000000..e82c8c349d --- /dev/null +++ b/Lang/ActionScript/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Polymorphism b/Lang/ActionScript/Polymorphism new file mode 120000 index 0000000000..c09ce692d9 --- /dev/null +++ b/Lang/ActionScript/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Primality-by-trial-division b/Lang/ActionScript/Primality-by-trial-division new file mode 120000 index 0000000000..b8ecd14f74 --- /dev/null +++ b/Lang/ActionScript/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Real-constants-and-functions b/Lang/ActionScript/Real-constants-and-functions new file mode 120000 index 0000000000..6c1c9ead5b --- /dev/null +++ b/Lang/ActionScript/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Reduced-row-echelon-form b/Lang/ActionScript/Reduced-row-echelon-form new file mode 120000 index 0000000000..85000c2553 --- /dev/null +++ b/Lang/ActionScript/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Repeat-a-string b/Lang/ActionScript/Repeat-a-string new file mode 120000 index 0000000000..f7023af293 --- /dev/null +++ b/Lang/ActionScript/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Reverse-a-string b/Lang/ActionScript/Reverse-a-string new file mode 120000 index 0000000000..09754db4e9 --- /dev/null +++ b/Lang/ActionScript/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/Roman-numerals-Encode b/Lang/ActionScript/Roman-numerals-Encode new file mode 120000 index 0000000000..ebcfbad491 --- /dev/null +++ b/Lang/ActionScript/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/ActionScript \ No newline at end of file diff --git a/Lang/ActionScript/SEDOLs b/Lang/ActionScript/SEDOLs new file mode 120000 index 0000000000..1d622e636e --- /dev/null +++ b/Lang/ActionScript/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/ActionScript \ No newline at end of file diff --git a/Lang/Ada/Arbitrary-precision-integers--included- b/Lang/Ada/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..4969036683 --- /dev/null +++ b/Lang/Ada/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Ada \ No newline at end of file diff --git a/Lang/Ada/Arbitrary-precision-integers-included b/Lang/Ada/Arbitrary-precision-integers-included deleted file mode 120000 index eb30af14b8..0000000000 --- a/Lang/Ada/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Ada \ No newline at end of file diff --git a/Lang/Ada/Binary-digits b/Lang/Ada/Binary-digits new file mode 120000 index 0000000000..b66c883c51 --- /dev/null +++ b/Lang/Ada/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/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..61ff6f00d1 --- /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/Calendar-for-real-programmers b/Lang/Ada/Calendar-for-real-programmers deleted file mode 120000 index b080290260..0000000000 --- a/Lang/Ada/Calendar-for-real-programmers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Calendar-for-real-programmers/Ada \ No newline at end of file diff --git a/Lang/Ada/Catalan-numbers b/Lang/Ada/Catalan-numbers new file mode 120000 index 0000000000..7666ca32b8 --- /dev/null +++ b/Lang/Ada/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Ada \ No newline at end of file diff --git a/Lang/Ada/Copy-a-string b/Lang/Ada/Copy-a-string new file mode 120000 index 0000000000..80d578fb02 --- /dev/null +++ b/Lang/Ada/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Ada \ No newline at end of file diff --git a/Lang/Ada/Environment-variables b/Lang/Ada/Environment-variables new file mode 120000 index 0000000000..d00121f314 --- /dev/null +++ b/Lang/Ada/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Ada \ No newline at end of file diff --git a/Lang/Ada/Execute-a-Markov-algorithm b/Lang/Ada/Execute-a-Markov-algorithm new file mode 120000 index 0000000000..7595888790 --- /dev/null +++ b/Lang/Ada/Execute-a-Markov-algorithm @@ -0,0 +1 @@ +../../Task/Execute-a-Markov-algorithm/Ada \ No newline at end of file diff --git a/Lang/Ada/Guess-the-number-With-feedback--player- b/Lang/Ada/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..b8e9515770 --- /dev/null +++ b/Lang/Ada/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/Ada \ No newline at end of file diff --git a/Lang/Ada/Guess-the-number-With-feedback-player b/Lang/Ada/Guess-the-number-With-feedback-player deleted file mode 120000 index b0baf7b5c4..0000000000 --- a/Lang/Ada/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/Ada \ No newline at end of file diff --git a/Lang/Ada/N-queens-problem b/Lang/Ada/N-queens-problem new file mode 120000 index 0000000000..467af7baa8 --- /dev/null +++ b/Lang/Ada/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Ada \ No newline at end of file diff --git a/Lang/Ada/Named-parameters b/Lang/Ada/Named-parameters new file mode 120000 index 0000000000..f6009aa4c5 --- /dev/null +++ b/Lang/Ada/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/Ada \ No newline at end of file diff --git a/Lang/Ada/Non-continuous-subsequences b/Lang/Ada/Non-continuous-subsequences new file mode 120000 index 0000000000..d198f23b06 --- /dev/null +++ b/Lang/Ada/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/Ada \ No newline at end of file diff --git a/Lang/Ada/Non-decimal-radices-Convert b/Lang/Ada/Non-decimal-radices-Convert new file mode 120000 index 0000000000..dcbb360f24 --- /dev/null +++ b/Lang/Ada/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/Ada \ No newline at end of file diff --git a/Lang/Ada/Non-decimal-radices-Input b/Lang/Ada/Non-decimal-radices-Input new file mode 120000 index 0000000000..8cbacfc987 --- /dev/null +++ b/Lang/Ada/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/Ada \ No newline at end of file diff --git a/Lang/Ada/Non-decimal-radices-Output b/Lang/Ada/Non-decimal-radices-Output new file mode 120000 index 0000000000..81817ba28e --- /dev/null +++ b/Lang/Ada/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/Ada \ No newline at end of file diff --git a/Lang/Ada/Nth-root b/Lang/Ada/Nth-root new file mode 120000 index 0000000000..bc9b1980a6 --- /dev/null +++ b/Lang/Ada/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Ada \ No newline at end of file diff --git a/Lang/Ada/Null-object b/Lang/Ada/Null-object new file mode 120000 index 0000000000..223032d63f --- /dev/null +++ b/Lang/Ada/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Ada \ No newline at end of file diff --git a/Lang/Ada/Number-names b/Lang/Ada/Number-names new file mode 120000 index 0000000000..86430d03cf --- /dev/null +++ b/Lang/Ada/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/Ada \ No newline at end of file diff --git a/Lang/Ada/Number-reversal-game b/Lang/Ada/Number-reversal-game new file mode 120000 index 0000000000..6053a15210 --- /dev/null +++ b/Lang/Ada/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/Ada \ No newline at end of file diff --git a/Lang/Ada/Numeric-error-propagation b/Lang/Ada/Numeric-error-propagation new file mode 120000 index 0000000000..674d814f30 --- /dev/null +++ b/Lang/Ada/Numeric-error-propagation @@ -0,0 +1 @@ +../../Task/Numeric-error-propagation/Ada \ No newline at end of file diff --git a/Lang/Ada/Numerical-integration b/Lang/Ada/Numerical-integration new file mode 120000 index 0000000000..ef9144bb20 --- /dev/null +++ b/Lang/Ada/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/Ada \ No newline at end of file diff --git a/Lang/Ada/Object-serialization b/Lang/Ada/Object-serialization new file mode 120000 index 0000000000..7f9f463828 --- /dev/null +++ b/Lang/Ada/Object-serialization @@ -0,0 +1 @@ +../../Task/Object-serialization/Ada \ No newline at end of file diff --git a/Lang/Ada/One-dimensional-cellular-automata b/Lang/Ada/One-dimensional-cellular-automata new file mode 120000 index 0000000000..5fe5f2771c --- /dev/null +++ b/Lang/Ada/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Ada \ No newline at end of file diff --git a/Lang/Ada/One-of-n-lines-in-a-file b/Lang/Ada/One-of-n-lines-in-a-file new file mode 120000 index 0000000000..c1564e642b --- /dev/null +++ b/Lang/Ada/One-of-n-lines-in-a-file @@ -0,0 +1 @@ +../../Task/One-of-n-lines-in-a-file/Ada \ No newline at end of file diff --git a/Lang/Ada/OpenGL b/Lang/Ada/OpenGL new file mode 120000 index 0000000000..7536a5219f --- /dev/null +++ b/Lang/Ada/OpenGL @@ -0,0 +1 @@ +../../Task/OpenGL/Ada \ No newline at end of file diff --git a/Lang/Ada/Optional-parameters b/Lang/Ada/Optional-parameters new file mode 120000 index 0000000000..0d01830af6 --- /dev/null +++ b/Lang/Ada/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/Ada \ No newline at end of file diff --git a/Lang/Ada/Order-two-numerical-lists b/Lang/Ada/Order-two-numerical-lists new file mode 120000 index 0000000000..5e393657d4 --- /dev/null +++ b/Lang/Ada/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/Ada \ No newline at end of file diff --git a/Lang/Ada/Ordered-Partitions b/Lang/Ada/Ordered-Partitions new file mode 120000 index 0000000000..9537e83e37 --- /dev/null +++ b/Lang/Ada/Ordered-Partitions @@ -0,0 +1 @@ +../../Task/Ordered-Partitions/Ada \ No newline at end of file diff --git a/Lang/Ada/Palindrome-detection b/Lang/Ada/Palindrome-detection new file mode 120000 index 0000000000..f5174a2b8c --- /dev/null +++ b/Lang/Ada/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Ada \ No newline at end of file diff --git a/Lang/Ada/Pangram-checker b/Lang/Ada/Pangram-checker new file mode 120000 index 0000000000..5141d787d7 --- /dev/null +++ b/Lang/Ada/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Ada \ No newline at end of file diff --git a/Lang/Ada/Parallel-calculations b/Lang/Ada/Parallel-calculations new file mode 120000 index 0000000000..6c069eeb5c --- /dev/null +++ b/Lang/Ada/Parallel-calculations @@ -0,0 +1 @@ +../../Task/Parallel-calculations/Ada \ No newline at end of file diff --git a/Lang/Ada/Parametric-polymorphism b/Lang/Ada/Parametric-polymorphism new file mode 120000 index 0000000000..860bc3e1af --- /dev/null +++ b/Lang/Ada/Parametric-polymorphism @@ -0,0 +1 @@ +../../Task/Parametric-polymorphism/Ada \ No newline at end of file diff --git a/Lang/Ada/Parametrized-SQL-statement b/Lang/Ada/Parametrized-SQL-statement new file mode 120000 index 0000000000..d33077e909 --- /dev/null +++ b/Lang/Ada/Parametrized-SQL-statement @@ -0,0 +1 @@ +../../Task/Parametrized-SQL-statement/Ada \ No newline at end of file diff --git a/Lang/Ada/Parsing-RPN-calculator-algorithm b/Lang/Ada/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..09732747ee --- /dev/null +++ b/Lang/Ada/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/Ada \ No newline at end of file diff --git a/Lang/Ada/Parsing-RPN-to-infix-conversion b/Lang/Ada/Parsing-RPN-to-infix-conversion new file mode 120000 index 0000000000..3e3f3e02de --- /dev/null +++ b/Lang/Ada/Parsing-RPN-to-infix-conversion @@ -0,0 +1 @@ +../../Task/Parsing-RPN-to-infix-conversion/Ada \ No newline at end of file diff --git a/Lang/Ada/Partial-function-application b/Lang/Ada/Partial-function-application new file mode 120000 index 0000000000..1a1451052d --- /dev/null +++ b/Lang/Ada/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/Ada \ No newline at end of file diff --git a/Lang/Ada/Pascals-triangle b/Lang/Ada/Pascals-triangle new file mode 120000 index 0000000000..1e2016557e --- /dev/null +++ b/Lang/Ada/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Ada \ No newline at end of file diff --git a/Lang/Ada/Pascals-triangle-Puzzle b/Lang/Ada/Pascals-triangle-Puzzle new file mode 120000 index 0000000000..42f0f32476 --- /dev/null +++ b/Lang/Ada/Pascals-triangle-Puzzle @@ -0,0 +1 @@ +../../Task/Pascals-triangle-Puzzle/Ada \ No newline at end of file diff --git a/Lang/Ada/Percentage-difference-between-images b/Lang/Ada/Percentage-difference-between-images new file mode 120000 index 0000000000..ec82206d93 --- /dev/null +++ b/Lang/Ada/Percentage-difference-between-images @@ -0,0 +1 @@ +../../Task/Percentage-difference-between-images/Ada \ No newline at end of file diff --git a/Lang/Ada/Perfect-numbers b/Lang/Ada/Perfect-numbers new file mode 120000 index 0000000000..dea8f55219 --- /dev/null +++ b/Lang/Ada/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Ada \ No newline at end of file diff --git a/Lang/Ada/Permutation-test b/Lang/Ada/Permutation-test new file mode 120000 index 0000000000..90e09ccb88 --- /dev/null +++ b/Lang/Ada/Permutation-test @@ -0,0 +1 @@ +../../Task/Permutation-test/Ada \ No newline at end of file diff --git a/Lang/Ada/Permutations b/Lang/Ada/Permutations new file mode 120000 index 0000000000..56a6cc344c --- /dev/null +++ b/Lang/Ada/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Ada \ No newline at end of file diff --git a/Lang/Ada/Permutations-Derangements b/Lang/Ada/Permutations-Derangements new file mode 120000 index 0000000000..3d2089a14f --- /dev/null +++ b/Lang/Ada/Permutations-Derangements @@ -0,0 +1 @@ +../../Task/Permutations-Derangements/Ada \ No newline at end of file diff --git a/Lang/Ada/Pick-random-element b/Lang/Ada/Pick-random-element new file mode 120000 index 0000000000..6b82a9c9b3 --- /dev/null +++ b/Lang/Ada/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/Ada \ No newline at end of file diff --git a/Lang/Ada/Pig-the-dice-game b/Lang/Ada/Pig-the-dice-game new file mode 120000 index 0000000000..7bd09b8282 --- /dev/null +++ b/Lang/Ada/Pig-the-dice-game @@ -0,0 +1 @@ +../../Task/Pig-the-dice-game/Ada \ No newline at end of file diff --git a/Lang/Ada/Pig-the-dice-game-Player b/Lang/Ada/Pig-the-dice-game-Player new file mode 120000 index 0000000000..2bdf3af188 --- /dev/null +++ b/Lang/Ada/Pig-the-dice-game-Player @@ -0,0 +1 @@ +../../Task/Pig-the-dice-game-Player/Ada \ No newline at end of file diff --git a/Lang/Ada/Plot-coordinate-pairs b/Lang/Ada/Plot-coordinate-pairs new file mode 120000 index 0000000000..bdec79837f --- /dev/null +++ b/Lang/Ada/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/Ada \ No newline at end of file diff --git a/Lang/Ada/Pointers-and-references b/Lang/Ada/Pointers-and-references new file mode 120000 index 0000000000..4c2e870cd0 --- /dev/null +++ b/Lang/Ada/Pointers-and-references @@ -0,0 +1 @@ +../../Task/Pointers-and-references/Ada \ No newline at end of file diff --git a/Lang/Ada/Polymorphic-copy b/Lang/Ada/Polymorphic-copy new file mode 120000 index 0000000000..a081f5c9f1 --- /dev/null +++ b/Lang/Ada/Polymorphic-copy @@ -0,0 +1 @@ +../../Task/Polymorphic-copy/Ada \ No newline at end of file diff --git a/Lang/Ada/Polymorphism b/Lang/Ada/Polymorphism new file mode 120000 index 0000000000..028f1aa8d3 --- /dev/null +++ b/Lang/Ada/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/Ada \ No newline at end of file diff --git a/Lang/Ada/Polynomial-long-division b/Lang/Ada/Polynomial-long-division new file mode 120000 index 0000000000..b2d1e3ab4b --- /dev/null +++ b/Lang/Ada/Polynomial-long-division @@ -0,0 +1 @@ +../../Task/Polynomial-long-division/Ada \ No newline at end of file diff --git a/Lang/Ada/Polynomial-regression b/Lang/Ada/Polynomial-regression new file mode 120000 index 0000000000..2a28ff6762 --- /dev/null +++ b/Lang/Ada/Polynomial-regression @@ -0,0 +1 @@ +../../Task/Polynomial-regression/Ada \ No newline at end of file diff --git a/Lang/Ada/Power-set b/Lang/Ada/Power-set new file mode 120000 index 0000000000..4bdb725d64 --- /dev/null +++ b/Lang/Ada/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Ada \ No newline at end of file diff --git a/Lang/Ada/Price-fraction b/Lang/Ada/Price-fraction new file mode 120000 index 0000000000..9576eded0b --- /dev/null +++ b/Lang/Ada/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Ada \ No newline at end of file diff --git a/Lang/Ada/Primality-by-trial-division b/Lang/Ada/Primality-by-trial-division new file mode 120000 index 0000000000..a064480d90 --- /dev/null +++ b/Lang/Ada/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Ada \ No newline at end of file diff --git a/Lang/Ada/Prime-decomposition b/Lang/Ada/Prime-decomposition new file mode 120000 index 0000000000..793bd45fe5 --- /dev/null +++ b/Lang/Ada/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Ada \ No newline at end of file diff --git a/Lang/Ada/Priority-queue b/Lang/Ada/Priority-queue new file mode 120000 index 0000000000..b53d970b11 --- /dev/null +++ b/Lang/Ada/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/Ada \ No newline at end of file diff --git a/Lang/Ada/Probabilistic-choice b/Lang/Ada/Probabilistic-choice new file mode 120000 index 0000000000..b2d7e2a541 --- /dev/null +++ b/Lang/Ada/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/Ada \ No newline at end of file diff --git a/Lang/Ada/Problem-of-Apollonius b/Lang/Ada/Problem-of-Apollonius new file mode 120000 index 0000000000..f802966eb1 --- /dev/null +++ b/Lang/Ada/Problem-of-Apollonius @@ -0,0 +1 @@ +../../Task/Problem-of-Apollonius/Ada \ No newline at end of file diff --git a/Lang/Ada/Program-name b/Lang/Ada/Program-name new file mode 120000 index 0000000000..7ce8a4c4fa --- /dev/null +++ b/Lang/Ada/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Ada \ No newline at end of file diff --git a/Lang/Ada/Program-termination b/Lang/Ada/Program-termination new file mode 120000 index 0000000000..9e39fee49d --- /dev/null +++ b/Lang/Ada/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Ada \ No newline at end of file diff --git a/Lang/Ada/Pythagorean-triples b/Lang/Ada/Pythagorean-triples new file mode 120000 index 0000000000..0a0e6b12d6 --- /dev/null +++ b/Lang/Ada/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/Ada \ No newline at end of file diff --git a/Lang/Ada/QR-decomposition b/Lang/Ada/QR-decomposition new file mode 120000 index 0000000000..253a49731e --- /dev/null +++ b/Lang/Ada/QR-decomposition @@ -0,0 +1 @@ +../../Task/QR-decomposition/Ada \ No newline at end of file diff --git a/Lang/Ada/Quaternion-type b/Lang/Ada/Quaternion-type new file mode 120000 index 0000000000..9dc0eab94d --- /dev/null +++ b/Lang/Ada/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/Ada \ No newline at end of file diff --git a/Lang/Ada/Queue-Definition b/Lang/Ada/Queue-Definition new file mode 120000 index 0000000000..6d03f468c9 --- /dev/null +++ b/Lang/Ada/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/Ada \ No newline at end of file diff --git a/Lang/Ada/Queue-Usage b/Lang/Ada/Queue-Usage new file mode 120000 index 0000000000..1aa44fbc66 --- /dev/null +++ b/Lang/Ada/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/Ada \ No newline at end of file diff --git a/Lang/Ada/Random-number-generator--device- b/Lang/Ada/Random-number-generator--device- new file mode 120000 index 0000000000..5b4ecbfc50 --- /dev/null +++ b/Lang/Ada/Random-number-generator--device- @@ -0,0 +1 @@ +../../Task/Random-number-generator--device-/Ada \ No newline at end of file diff --git a/Lang/Ada/Random-numbers b/Lang/Ada/Random-numbers new file mode 120000 index 0000000000..c7e0926aa3 --- /dev/null +++ b/Lang/Ada/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Ada \ No newline at end of file diff --git a/Lang/Ada/Range-expansion b/Lang/Ada/Range-expansion new file mode 120000 index 0000000000..b9da586039 --- /dev/null +++ b/Lang/Ada/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/Ada \ No newline at end of file diff --git a/Lang/Ada/Range-extraction b/Lang/Ada/Range-extraction new file mode 120000 index 0000000000..4f54699fc6 --- /dev/null +++ b/Lang/Ada/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/Ada \ No newline at end of file diff --git a/Lang/Ada/Rate-counter b/Lang/Ada/Rate-counter new file mode 120000 index 0000000000..3665ff0b72 --- /dev/null +++ b/Lang/Ada/Rate-counter @@ -0,0 +1 @@ +../../Task/Rate-counter/Ada \ No newline at end of file diff --git a/Lang/Ada/Ray-casting-algorithm b/Lang/Ada/Ray-casting-algorithm new file mode 120000 index 0000000000..3869ab9db9 --- /dev/null +++ b/Lang/Ada/Ray-casting-algorithm @@ -0,0 +1 @@ +../../Task/Ray-casting-algorithm/Ada \ No newline at end of file diff --git a/Lang/Ada/Read-a-configuration-file b/Lang/Ada/Read-a-configuration-file new file mode 120000 index 0000000000..a9ec6e54c2 --- /dev/null +++ b/Lang/Ada/Read-a-configuration-file @@ -0,0 +1 @@ +../../Task/Read-a-configuration-file/Ada \ No newline at end of file diff --git a/Lang/Ada/Read-a-file-line-by-line b/Lang/Ada/Read-a-file-line-by-line new file mode 120000 index 0000000000..25db09890f --- /dev/null +++ b/Lang/Ada/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Ada \ No newline at end of file diff --git a/Lang/Ada/Read-a-specific-line-from-a-file b/Lang/Ada/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..5e85c1456d --- /dev/null +++ b/Lang/Ada/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/Ada \ No newline at end of file diff --git a/Lang/Ada/Read-entire-file b/Lang/Ada/Read-entire-file new file mode 120000 index 0000000000..0309797467 --- /dev/null +++ b/Lang/Ada/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Ada \ No newline at end of file diff --git a/Lang/Ada/Real-constants-and-functions b/Lang/Ada/Real-constants-and-functions new file mode 120000 index 0000000000..9d90ee66cf --- /dev/null +++ b/Lang/Ada/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Ada \ No newline at end of file diff --git a/Lang/Ada/Reduced-row-echelon-form b/Lang/Ada/Reduced-row-echelon-form new file mode 120000 index 0000000000..d9c5983b7c --- /dev/null +++ b/Lang/Ada/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/Ada \ No newline at end of file diff --git a/Lang/Ada/Regular-expressions b/Lang/Ada/Regular-expressions new file mode 120000 index 0000000000..6ccdf5025f --- /dev/null +++ b/Lang/Ada/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Ada \ No newline at end of file diff --git a/Lang/Ada/Remove-duplicate-elements b/Lang/Ada/Remove-duplicate-elements new file mode 120000 index 0000000000..8b18c4e27e --- /dev/null +++ b/Lang/Ada/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Ada \ No newline at end of file diff --git a/Lang/Ada/Remove-lines-from-a-file b/Lang/Ada/Remove-lines-from-a-file new file mode 120000 index 0000000000..1d1465a5d3 --- /dev/null +++ b/Lang/Ada/Remove-lines-from-a-file @@ -0,0 +1 @@ +../../Task/Remove-lines-from-a-file/Ada \ No newline at end of file diff --git a/Lang/Ada/Rename-a-file b/Lang/Ada/Rename-a-file new file mode 120000 index 0000000000..83071c4454 --- /dev/null +++ b/Lang/Ada/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Ada \ No newline at end of file diff --git a/Lang/Ada/Rendezvous b/Lang/Ada/Rendezvous new file mode 120000 index 0000000000..9a113ac3ce --- /dev/null +++ b/Lang/Ada/Rendezvous @@ -0,0 +1 @@ +../../Task/Rendezvous/Ada \ No newline at end of file diff --git a/Lang/Ada/Repeat-a-string b/Lang/Ada/Repeat-a-string new file mode 120000 index 0000000000..533831ea6a --- /dev/null +++ b/Lang/Ada/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Ada \ No newline at end of file diff --git a/Lang/Ada/Resistor-mesh b/Lang/Ada/Resistor-mesh new file mode 120000 index 0000000000..ba163b7f46 --- /dev/null +++ b/Lang/Ada/Resistor-mesh @@ -0,0 +1 @@ +../../Task/Resistor-mesh/Ada \ No newline at end of file diff --git a/Lang/Ada/Return-multiple-values b/Lang/Ada/Return-multiple-values new file mode 120000 index 0000000000..eb87094fa6 --- /dev/null +++ b/Lang/Ada/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Ada \ No newline at end of file diff --git a/Lang/Ada/Reverse-a-string b/Lang/Ada/Reverse-a-string new file mode 120000 index 0000000000..6aaf0b262c --- /dev/null +++ b/Lang/Ada/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Ada \ No newline at end of file diff --git a/Lang/Ada/Rock-paper-scissors b/Lang/Ada/Rock-paper-scissors new file mode 120000 index 0000000000..c797994415 --- /dev/null +++ b/Lang/Ada/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/Ada \ No newline at end of file diff --git a/Lang/Ada/Roman-numerals-Decode b/Lang/Ada/Roman-numerals-Decode new file mode 120000 index 0000000000..9cbbc51645 --- /dev/null +++ b/Lang/Ada/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/Ada \ No newline at end of file diff --git a/Lang/Ada/Roman-numerals-Encode b/Lang/Ada/Roman-numerals-Encode new file mode 120000 index 0000000000..011610ed64 --- /dev/null +++ b/Lang/Ada/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Ada \ No newline at end of file diff --git a/Lang/Ada/Roots-of-a-function b/Lang/Ada/Roots-of-a-function new file mode 120000 index 0000000000..e189b68118 --- /dev/null +++ b/Lang/Ada/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/Ada \ No newline at end of file diff --git a/Lang/Ada/Roots-of-a-quadratic-function b/Lang/Ada/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..e244932738 --- /dev/null +++ b/Lang/Ada/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/Ada \ No newline at end of file diff --git a/Lang/Ada/Roots-of-unity b/Lang/Ada/Roots-of-unity new file mode 120000 index 0000000000..677e9e06fb --- /dev/null +++ b/Lang/Ada/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/Ada \ No newline at end of file diff --git a/Lang/Ada/Rosetta-Code-Count-examples b/Lang/Ada/Rosetta-Code-Count-examples new file mode 120000 index 0000000000..a912071c5c --- /dev/null +++ b/Lang/Ada/Rosetta-Code-Count-examples @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Count-examples/Ada \ No newline at end of file diff --git a/Lang/Ada/Rosetta-Code-Find-unimplemented-tasks b/Lang/Ada/Rosetta-Code-Find-unimplemented-tasks new file mode 120000 index 0000000000..8441e9c78f --- /dev/null +++ b/Lang/Ada/Rosetta-Code-Find-unimplemented-tasks @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Find-unimplemented-tasks/Ada \ No newline at end of file diff --git a/Lang/Ada/Rosetta-Code-Rank-languages-by-popularity b/Lang/Ada/Rosetta-Code-Rank-languages-by-popularity new file mode 120000 index 0000000000..14bfc6c8b8 --- /dev/null +++ b/Lang/Ada/Rosetta-Code-Rank-languages-by-popularity @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-popularity/Ada \ No newline at end of file diff --git a/Lang/Ada/Rot-13 b/Lang/Ada/Rot-13 new file mode 120000 index 0000000000..9e00a778b8 --- /dev/null +++ b/Lang/Ada/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Ada \ No newline at end of file diff --git a/Lang/Ada/Run-length-encoding b/Lang/Ada/Run-length-encoding new file mode 120000 index 0000000000..3a61a6ea58 --- /dev/null +++ b/Lang/Ada/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Ada \ No newline at end of file diff --git a/Lang/Ada/S-Expressions b/Lang/Ada/S-Expressions new file mode 120000 index 0000000000..1ac2de7dbf --- /dev/null +++ b/Lang/Ada/S-Expressions @@ -0,0 +1 @@ +../../Task/S-Expressions/Ada \ No newline at end of file diff --git a/Lang/Ada/SEDOLs b/Lang/Ada/SEDOLs new file mode 120000 index 0000000000..b4c4706fad --- /dev/null +++ b/Lang/Ada/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/Ada \ No newline at end of file diff --git a/Lang/Ada/Safe-addition b/Lang/Ada/Safe-addition new file mode 120000 index 0000000000..ab92196079 --- /dev/null +++ b/Lang/Ada/Safe-addition @@ -0,0 +1 @@ +../../Task/Safe-addition/Ada \ No newline at end of file diff --git a/Lang/Ada/Same-Fringe b/Lang/Ada/Same-Fringe new file mode 120000 index 0000000000..7d0b781ab4 --- /dev/null +++ b/Lang/Ada/Same-Fringe @@ -0,0 +1 @@ +../../Task/Same-Fringe/Ada \ No newline at end of file diff --git a/Lang/Ada/Scope-modifiers b/Lang/Ada/Scope-modifiers new file mode 120000 index 0000000000..70fc3cd6ad --- /dev/null +++ b/Lang/Ada/Scope-modifiers @@ -0,0 +1 @@ +../../Task/Scope-modifiers/Ada \ No newline at end of file diff --git a/Lang/Ada/Secure-temporary-file b/Lang/Ada/Secure-temporary-file new file mode 120000 index 0000000000..7d339b379d --- /dev/null +++ b/Lang/Ada/Secure-temporary-file @@ -0,0 +1 @@ +../../Task/Secure-temporary-file/Ada \ No newline at end of file diff --git a/Lang/Ada/Self-describing-numbers b/Lang/Ada/Self-describing-numbers new file mode 120000 index 0000000000..d60d248551 --- /dev/null +++ b/Lang/Ada/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/Ada \ No newline at end of file diff --git a/Lang/Ada/Self-referential-sequence b/Lang/Ada/Self-referential-sequence new file mode 120000 index 0000000000..0309a4f24e --- /dev/null +++ b/Lang/Ada/Self-referential-sequence @@ -0,0 +1 @@ +../../Task/Self-referential-sequence/Ada \ No newline at end of file diff --git a/Lang/Ada/Semordnilap b/Lang/Ada/Semordnilap new file mode 120000 index 0000000000..260b1bd01a --- /dev/null +++ b/Lang/Ada/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/Ada \ No newline at end of file diff --git a/Lang/Ada/Send-email b/Lang/Ada/Send-email new file mode 120000 index 0000000000..aeb1607964 --- /dev/null +++ b/Lang/Ada/Send-email @@ -0,0 +1 @@ +../../Task/Send-email/Ada \ No newline at end of file diff --git a/Lang/Ada/Sequence-of-non-squares b/Lang/Ada/Sequence-of-non-squares new file mode 120000 index 0000000000..4bf9d09cc5 --- /dev/null +++ b/Lang/Ada/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Ada \ No newline at end of file diff --git a/Lang/Ada/Set b/Lang/Ada/Set new file mode 120000 index 0000000000..225fb8c4b4 --- /dev/null +++ b/Lang/Ada/Set @@ -0,0 +1 @@ +../../Task/Set/Ada \ No newline at end of file diff --git a/Lang/Ada/Set-consolidation b/Lang/Ada/Set-consolidation new file mode 120000 index 0000000000..b390fb5d77 --- /dev/null +++ b/Lang/Ada/Set-consolidation @@ -0,0 +1 @@ +../../Task/Set-consolidation/Ada \ No newline at end of file diff --git a/Lang/Agda2/Reverse-a-string b/Lang/Agda2/Reverse-a-string new file mode 120000 index 0000000000..07d789c153 --- /dev/null +++ b/Lang/Agda2/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Agda2 \ No newline at end of file diff --git a/Lang/Aikido/Polymorphic-copy b/Lang/Aikido/Polymorphic-copy new file mode 120000 index 0000000000..8fc3e18c73 --- /dev/null +++ b/Lang/Aikido/Polymorphic-copy @@ -0,0 +1 @@ +../../Task/Polymorphic-copy/Aikido \ No newline at end of file diff --git a/Lang/Aikido/Polymorphism b/Lang/Aikido/Polymorphism new file mode 120000 index 0000000000..a94c883944 --- /dev/null +++ b/Lang/Aikido/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/Aikido \ No newline at end of file diff --git a/Lang/Aime/Pick-random-element b/Lang/Aime/Pick-random-element new file mode 120000 index 0000000000..799fbabee7 --- /dev/null +++ b/Lang/Aime/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/Aime \ No newline at end of file diff --git a/Lang/Aime/Range-extraction b/Lang/Aime/Range-extraction new file mode 120000 index 0000000000..0e7a96a840 --- /dev/null +++ b/Lang/Aime/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/Aime \ No newline at end of file diff --git a/Lang/Aime/Read-a-file-line-by-line b/Lang/Aime/Read-a-file-line-by-line new file mode 120000 index 0000000000..cf67487f19 --- /dev/null +++ b/Lang/Aime/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Aime \ No newline at end of file diff --git a/Lang/Aime/Read-a-specific-line-from-a-file b/Lang/Aime/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..8a350fde5c --- /dev/null +++ b/Lang/Aime/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/Aime \ No newline at end of file diff --git a/Lang/Alore/Arbitrary-precision-integers--included- b/Lang/Alore/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..2c9c09033a --- /dev/null +++ b/Lang/Alore/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Alore \ No newline at end of file diff --git a/Lang/Alore/Arbitrary-precision-integers-included b/Lang/Alore/Arbitrary-precision-integers-included deleted file mode 120000 index bff88f0ead..0000000000 --- a/Lang/Alore/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Alore \ No newline at end of file diff --git a/Lang/AmigaE/Null-object b/Lang/AmigaE/Null-object new file mode 120000 index 0000000000..36729e8e82 --- /dev/null +++ b/Lang/AmigaE/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/AmigaE \ No newline at end of file diff --git a/Lang/AppleScript/Named-parameters b/Lang/AppleScript/Named-parameters new file mode 120000 index 0000000000..8008935b66 --- /dev/null +++ b/Lang/AppleScript/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Null-object b/Lang/AppleScript/Null-object new file mode 120000 index 0000000000..12d18e6f8c --- /dev/null +++ b/Lang/AppleScript/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Optional-parameters b/Lang/AppleScript/Optional-parameters new file mode 120000 index 0000000000..d150a6436a --- /dev/null +++ b/Lang/AppleScript/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Program-termination b/Lang/AppleScript/Program-termination new file mode 120000 index 0000000000..b110b48c95 --- /dev/null +++ b/Lang/AppleScript/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Queue-Usage b/Lang/AppleScript/Queue-Usage new file mode 120000 index 0000000000..e6d070c342 --- /dev/null +++ b/Lang/AppleScript/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Regular-expressions b/Lang/AppleScript/Regular-expressions new file mode 120000 index 0000000000..f5d0a9bb54 --- /dev/null +++ b/Lang/AppleScript/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Remove-duplicate-elements b/Lang/AppleScript/Remove-duplicate-elements new file mode 120000 index 0000000000..320d1e80ce --- /dev/null +++ b/Lang/AppleScript/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Repeat-a-string b/Lang/AppleScript/Repeat-a-string new file mode 120000 index 0000000000..9547499570 --- /dev/null +++ b/Lang/AppleScript/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Reverse-a-string b/Lang/AppleScript/Reverse-a-string new file mode 120000 index 0000000000..d5b5559d21 --- /dev/null +++ b/Lang/AppleScript/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/AppleScript \ No newline at end of file diff --git a/Lang/AppleScript/Rot-13 b/Lang/AppleScript/Rot-13 new file mode 120000 index 0000000000..5d7b9f65d1 --- /dev/null +++ b/Lang/AppleScript/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/AppleScript \ No newline at end of file diff --git a/Lang/Argile/Regular-expressions b/Lang/Argile/Regular-expressions new file mode 120000 index 0000000000..598eda2627 --- /dev/null +++ b/Lang/Argile/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Argile \ No newline at end of file diff --git a/Lang/AutoHotkey/Binary-digits b/Lang/AutoHotkey/Binary-digits new file mode 120000 index 0000000000..f82ac66730 --- /dev/null +++ b/Lang/AutoHotkey/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Brownian-tree b/Lang/AutoHotkey/Brownian-tree new file mode 120000 index 0000000000..65264efd19 --- /dev/null +++ b/Lang/AutoHotkey/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Catalan-numbers b/Lang/AutoHotkey/Catalan-numbers new file mode 120000 index 0000000000..210848c169 --- /dev/null +++ b/Lang/AutoHotkey/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Copy-a-string b/Lang/AutoHotkey/Copy-a-string new file mode 120000 index 0000000000..95f53586b8 --- /dev/null +++ b/Lang/AutoHotkey/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Environment-variables b/Lang/AutoHotkey/Environment-variables new file mode 120000 index 0000000000..8f3247f1a9 --- /dev/null +++ b/Lang/AutoHotkey/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Execute-a-Markov-algorithm b/Lang/AutoHotkey/Execute-a-Markov-algorithm new file mode 120000 index 0000000000..862ee10b83 --- /dev/null +++ b/Lang/AutoHotkey/Execute-a-Markov-algorithm @@ -0,0 +1 @@ +../../Task/Execute-a-Markov-algorithm/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Guess-the-number-With-feedback--player- b/Lang/AutoHotkey/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..c6e4c18c22 --- /dev/null +++ b/Lang/AutoHotkey/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Guess-the-number-With-feedback-player b/Lang/AutoHotkey/Guess-the-number-With-feedback-player deleted file mode 120000 index 092a1b33f7..0000000000 --- a/Lang/AutoHotkey/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/N-queens-problem b/Lang/AutoHotkey/N-queens-problem new file mode 120000 index 0000000000..987f80cfe5 --- /dev/null +++ b/Lang/AutoHotkey/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Named-parameters b/Lang/AutoHotkey/Named-parameters new file mode 120000 index 0000000000..faab81be63 --- /dev/null +++ b/Lang/AutoHotkey/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Non-continuous-subsequences b/Lang/AutoHotkey/Non-continuous-subsequences new file mode 120000 index 0000000000..373fe67834 --- /dev/null +++ b/Lang/AutoHotkey/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Non-decimal-radices-Convert b/Lang/AutoHotkey/Non-decimal-radices-Convert new file mode 120000 index 0000000000..61cdc9543d --- /dev/null +++ b/Lang/AutoHotkey/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Non-decimal-radices-Output b/Lang/AutoHotkey/Non-decimal-radices-Output new file mode 120000 index 0000000000..6177fabcab --- /dev/null +++ b/Lang/AutoHotkey/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Nth-root b/Lang/AutoHotkey/Nth-root new file mode 120000 index 0000000000..9c806b4396 --- /dev/null +++ b/Lang/AutoHotkey/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Null-object b/Lang/AutoHotkey/Null-object new file mode 120000 index 0000000000..9eb5dcd8bc --- /dev/null +++ b/Lang/AutoHotkey/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Number-names b/Lang/AutoHotkey/Number-names new file mode 120000 index 0000000000..93ee55e76a --- /dev/null +++ b/Lang/AutoHotkey/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Number-reversal-game b/Lang/AutoHotkey/Number-reversal-game new file mode 120000 index 0000000000..5ddef878c4 --- /dev/null +++ b/Lang/AutoHotkey/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Numerical-integration b/Lang/AutoHotkey/Numerical-integration new file mode 120000 index 0000000000..5978191ad1 --- /dev/null +++ b/Lang/AutoHotkey/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/OLE-Automation b/Lang/AutoHotkey/OLE-Automation new file mode 120000 index 0000000000..205ede6fdb --- /dev/null +++ b/Lang/AutoHotkey/OLE-Automation @@ -0,0 +1 @@ +../../Task/OLE-Automation/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/One-dimensional-cellular-automata b/Lang/AutoHotkey/One-dimensional-cellular-automata new file mode 120000 index 0000000000..db5da84b57 --- /dev/null +++ b/Lang/AutoHotkey/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/One-of-n-lines-in-a-file b/Lang/AutoHotkey/One-of-n-lines-in-a-file new file mode 120000 index 0000000000..1e87d6166c --- /dev/null +++ b/Lang/AutoHotkey/One-of-n-lines-in-a-file @@ -0,0 +1 @@ +../../Task/One-of-n-lines-in-a-file/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/OpenGL b/Lang/AutoHotkey/OpenGL new file mode 120000 index 0000000000..cdad2bf2f4 --- /dev/null +++ b/Lang/AutoHotkey/OpenGL @@ -0,0 +1 @@ +../../Task/OpenGL/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Optional-parameters b/Lang/AutoHotkey/Optional-parameters new file mode 120000 index 0000000000..d5a5458c88 --- /dev/null +++ b/Lang/AutoHotkey/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Order-two-numerical-lists b/Lang/AutoHotkey/Order-two-numerical-lists new file mode 120000 index 0000000000..c3a6ca6909 --- /dev/null +++ b/Lang/AutoHotkey/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Palindrome-detection b/Lang/AutoHotkey/Palindrome-detection new file mode 120000 index 0000000000..9f36378ff2 --- /dev/null +++ b/Lang/AutoHotkey/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Pangram-checker b/Lang/AutoHotkey/Pangram-checker new file mode 120000 index 0000000000..6e92353f9b --- /dev/null +++ b/Lang/AutoHotkey/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Parsing-RPN-calculator-algorithm b/Lang/AutoHotkey/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..9d5be1bb8b --- /dev/null +++ b/Lang/AutoHotkey/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Parsing-RPN-to-infix-conversion b/Lang/AutoHotkey/Parsing-RPN-to-infix-conversion new file mode 120000 index 0000000000..03fcff132b --- /dev/null +++ b/Lang/AutoHotkey/Parsing-RPN-to-infix-conversion @@ -0,0 +1 @@ +../../Task/Parsing-RPN-to-infix-conversion/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Parsing-Shunting-yard-algorithm b/Lang/AutoHotkey/Parsing-Shunting-yard-algorithm new file mode 120000 index 0000000000..77efba61eb --- /dev/null +++ b/Lang/AutoHotkey/Parsing-Shunting-yard-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-Shunting-yard-algorithm/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Pascals-triangle b/Lang/AutoHotkey/Pascals-triangle new file mode 120000 index 0000000000..be7dc04020 --- /dev/null +++ b/Lang/AutoHotkey/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Pascals-triangle-Puzzle b/Lang/AutoHotkey/Pascals-triangle-Puzzle new file mode 120000 index 0000000000..e36b666a91 --- /dev/null +++ b/Lang/AutoHotkey/Pascals-triangle-Puzzle @@ -0,0 +1 @@ +../../Task/Pascals-triangle-Puzzle/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Percentage-difference-between-images b/Lang/AutoHotkey/Percentage-difference-between-images new file mode 120000 index 0000000000..5538667d67 --- /dev/null +++ b/Lang/AutoHotkey/Percentage-difference-between-images @@ -0,0 +1 @@ +../../Task/Percentage-difference-between-images/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Perfect-numbers b/Lang/AutoHotkey/Perfect-numbers new file mode 120000 index 0000000000..7f48cc1e21 --- /dev/null +++ b/Lang/AutoHotkey/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Permutations b/Lang/AutoHotkey/Permutations new file mode 120000 index 0000000000..7c9eac16f7 --- /dev/null +++ b/Lang/AutoHotkey/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Permutations-Derangements b/Lang/AutoHotkey/Permutations-Derangements new file mode 120000 index 0000000000..a212df37a9 --- /dev/null +++ b/Lang/AutoHotkey/Permutations-Derangements @@ -0,0 +1 @@ +../../Task/Permutations-Derangements/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Pick-random-element b/Lang/AutoHotkey/Pick-random-element new file mode 120000 index 0000000000..7c8683b24e --- /dev/null +++ b/Lang/AutoHotkey/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Pinstripe-Display b/Lang/AutoHotkey/Pinstripe-Display new file mode 120000 index 0000000000..2476a2de2a --- /dev/null +++ b/Lang/AutoHotkey/Pinstripe-Display @@ -0,0 +1 @@ +../../Task/Pinstripe-Display/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Play-recorded-sounds b/Lang/AutoHotkey/Play-recorded-sounds new file mode 120000 index 0000000000..03085a9d27 --- /dev/null +++ b/Lang/AutoHotkey/Play-recorded-sounds @@ -0,0 +1 @@ +../../Task/Play-recorded-sounds/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Playing-cards b/Lang/AutoHotkey/Playing-cards new file mode 120000 index 0000000000..689d000895 --- /dev/null +++ b/Lang/AutoHotkey/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Pointers-and-references b/Lang/AutoHotkey/Pointers-and-references new file mode 120000 index 0000000000..2eae8ca8a3 --- /dev/null +++ b/Lang/AutoHotkey/Pointers-and-references @@ -0,0 +1 @@ +../../Task/Pointers-and-references/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Power-set b/Lang/AutoHotkey/Power-set new file mode 120000 index 0000000000..6fa8d1b498 --- /dev/null +++ b/Lang/AutoHotkey/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Price-fraction b/Lang/AutoHotkey/Price-fraction new file mode 120000 index 0000000000..1ffc1ea777 --- /dev/null +++ b/Lang/AutoHotkey/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Primality-by-trial-division b/Lang/AutoHotkey/Primality-by-trial-division new file mode 120000 index 0000000000..7372eff5ec --- /dev/null +++ b/Lang/AutoHotkey/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Prime-decomposition b/Lang/AutoHotkey/Prime-decomposition new file mode 120000 index 0000000000..1ef7b5a1c7 --- /dev/null +++ b/Lang/AutoHotkey/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Probabilistic-choice b/Lang/AutoHotkey/Probabilistic-choice new file mode 120000 index 0000000000..af5361e86c --- /dev/null +++ b/Lang/AutoHotkey/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Program-name b/Lang/AutoHotkey/Program-name new file mode 120000 index 0000000000..ed957e113d --- /dev/null +++ b/Lang/AutoHotkey/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Program-termination b/Lang/AutoHotkey/Program-termination new file mode 120000 index 0000000000..e0b34c344a --- /dev/null +++ b/Lang/AutoHotkey/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Queue-Definition b/Lang/AutoHotkey/Queue-Definition new file mode 120000 index 0000000000..a302e69826 --- /dev/null +++ b/Lang/AutoHotkey/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Queue-Usage b/Lang/AutoHotkey/Queue-Usage new file mode 120000 index 0000000000..7dde1ad2da --- /dev/null +++ b/Lang/AutoHotkey/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Random-numbers b/Lang/AutoHotkey/Random-numbers new file mode 120000 index 0000000000..2e085c5f29 --- /dev/null +++ b/Lang/AutoHotkey/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Range-expansion b/Lang/AutoHotkey/Range-expansion new file mode 120000 index 0000000000..d942361140 --- /dev/null +++ b/Lang/AutoHotkey/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Range-extraction b/Lang/AutoHotkey/Range-extraction new file mode 120000 index 0000000000..e07c8e01e4 --- /dev/null +++ b/Lang/AutoHotkey/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Ray-casting-algorithm b/Lang/AutoHotkey/Ray-casting-algorithm new file mode 120000 index 0000000000..587edacdfc --- /dev/null +++ b/Lang/AutoHotkey/Ray-casting-algorithm @@ -0,0 +1 @@ +../../Task/Ray-casting-algorithm/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Read-a-configuration-file b/Lang/AutoHotkey/Read-a-configuration-file new file mode 120000 index 0000000000..22aaa3d3a6 --- /dev/null +++ b/Lang/AutoHotkey/Read-a-configuration-file @@ -0,0 +1 @@ +../../Task/Read-a-configuration-file/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Read-a-file-line-by-line b/Lang/AutoHotkey/Read-a-file-line-by-line new file mode 120000 index 0000000000..4268c9ce21 --- /dev/null +++ b/Lang/AutoHotkey/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Read-a-specific-line-from-a-file b/Lang/AutoHotkey/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..e3088a5654 --- /dev/null +++ b/Lang/AutoHotkey/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Read-entire-file b/Lang/AutoHotkey/Read-entire-file new file mode 120000 index 0000000000..c5636a28e0 --- /dev/null +++ b/Lang/AutoHotkey/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Real-constants-and-functions b/Lang/AutoHotkey/Real-constants-and-functions new file mode 120000 index 0000000000..b3424771eb --- /dev/null +++ b/Lang/AutoHotkey/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Regular-expressions b/Lang/AutoHotkey/Regular-expressions new file mode 120000 index 0000000000..f18d0946f6 --- /dev/null +++ b/Lang/AutoHotkey/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Remove-duplicate-elements b/Lang/AutoHotkey/Remove-duplicate-elements new file mode 120000 index 0000000000..0440ba3e68 --- /dev/null +++ b/Lang/AutoHotkey/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Remove-lines-from-a-file b/Lang/AutoHotkey/Remove-lines-from-a-file new file mode 120000 index 0000000000..b65d7ad918 --- /dev/null +++ b/Lang/AutoHotkey/Remove-lines-from-a-file @@ -0,0 +1 @@ +../../Task/Remove-lines-from-a-file/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Rename-a-file b/Lang/AutoHotkey/Rename-a-file new file mode 120000 index 0000000000..e0c12f81ba --- /dev/null +++ b/Lang/AutoHotkey/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Rendezvous b/Lang/AutoHotkey/Rendezvous new file mode 120000 index 0000000000..4313c55941 --- /dev/null +++ b/Lang/AutoHotkey/Rendezvous @@ -0,0 +1 @@ +../../Task/Rendezvous/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Repeat-a-string b/Lang/AutoHotkey/Repeat-a-string new file mode 120000 index 0000000000..b07baf9f12 --- /dev/null +++ b/Lang/AutoHotkey/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Return-multiple-values b/Lang/AutoHotkey/Return-multiple-values new file mode 120000 index 0000000000..f7227e0bec --- /dev/null +++ b/Lang/AutoHotkey/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Reverse-a-string b/Lang/AutoHotkey/Reverse-a-string new file mode 120000 index 0000000000..9f4a2a3362 --- /dev/null +++ b/Lang/AutoHotkey/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Rock-paper-scissors b/Lang/AutoHotkey/Rock-paper-scissors new file mode 120000 index 0000000000..51f5814571 --- /dev/null +++ b/Lang/AutoHotkey/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Roman-numerals-Decode b/Lang/AutoHotkey/Roman-numerals-Decode new file mode 120000 index 0000000000..fa8da59936 --- /dev/null +++ b/Lang/AutoHotkey/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Roman-numerals-Encode b/Lang/AutoHotkey/Roman-numerals-Encode new file mode 120000 index 0000000000..04618afe0d --- /dev/null +++ b/Lang/AutoHotkey/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Roots-of-a-function b/Lang/AutoHotkey/Roots-of-a-function new file mode 120000 index 0000000000..62bf07667b --- /dev/null +++ b/Lang/AutoHotkey/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Roots-of-a-quadratic-function b/Lang/AutoHotkey/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..dfee0ebf14 --- /dev/null +++ b/Lang/AutoHotkey/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Roots-of-unity b/Lang/AutoHotkey/Roots-of-unity new file mode 120000 index 0000000000..2c8fd73566 --- /dev/null +++ b/Lang/AutoHotkey/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Rosetta-Code-Count-examples b/Lang/AutoHotkey/Rosetta-Code-Count-examples new file mode 120000 index 0000000000..0b1de8c223 --- /dev/null +++ b/Lang/AutoHotkey/Rosetta-Code-Count-examples @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Count-examples/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Rosetta-Code-Find-unimplemented-tasks b/Lang/AutoHotkey/Rosetta-Code-Find-unimplemented-tasks new file mode 120000 index 0000000000..2c382bcd56 --- /dev/null +++ b/Lang/AutoHotkey/Rosetta-Code-Find-unimplemented-tasks @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Find-unimplemented-tasks/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Rosetta-Code-Fix-code-tags b/Lang/AutoHotkey/Rosetta-Code-Fix-code-tags new file mode 120000 index 0000000000..f8b80906f9 --- /dev/null +++ b/Lang/AutoHotkey/Rosetta-Code-Fix-code-tags @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Fix-code-tags/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Rosetta-Code-Rank-languages-by-popularity b/Lang/AutoHotkey/Rosetta-Code-Rank-languages-by-popularity new file mode 120000 index 0000000000..d43899a9ae --- /dev/null +++ b/Lang/AutoHotkey/Rosetta-Code-Rank-languages-by-popularity @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-popularity/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Rot-13 b/Lang/AutoHotkey/Rot-13 new file mode 120000 index 0000000000..856daebd10 --- /dev/null +++ b/Lang/AutoHotkey/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Run-length-encoding b/Lang/AutoHotkey/Run-length-encoding new file mode 120000 index 0000000000..17ed7cb591 --- /dev/null +++ b/Lang/AutoHotkey/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Runtime-evaluation b/Lang/AutoHotkey/Runtime-evaluation new file mode 120000 index 0000000000..557fabe9e2 --- /dev/null +++ b/Lang/AutoHotkey/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Runtime-evaluation-In-an-environment b/Lang/AutoHotkey/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..7c25d1fae0 --- /dev/null +++ b/Lang/AutoHotkey/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/SEDOLs b/Lang/AutoHotkey/SEDOLs new file mode 120000 index 0000000000..0417cf6208 --- /dev/null +++ b/Lang/AutoHotkey/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Scope-modifiers b/Lang/AutoHotkey/Scope-modifiers new file mode 120000 index 0000000000..f741f4cd86 --- /dev/null +++ b/Lang/AutoHotkey/Scope-modifiers @@ -0,0 +1 @@ +../../Task/Scope-modifiers/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Self-describing-numbers b/Lang/AutoHotkey/Self-describing-numbers new file mode 120000 index 0000000000..5690ab287f --- /dev/null +++ b/Lang/AutoHotkey/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Self-referential-sequence b/Lang/AutoHotkey/Self-referential-sequence new file mode 120000 index 0000000000..2008a31bab --- /dev/null +++ b/Lang/AutoHotkey/Self-referential-sequence @@ -0,0 +1 @@ +../../Task/Self-referential-sequence/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Send-an-unknown-method-call b/Lang/AutoHotkey/Send-an-unknown-method-call new file mode 120000 index 0000000000..4eedd6f077 --- /dev/null +++ b/Lang/AutoHotkey/Send-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Send-an-unknown-method-call/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Send-email b/Lang/AutoHotkey/Send-email new file mode 120000 index 0000000000..312ded9491 --- /dev/null +++ b/Lang/AutoHotkey/Send-email @@ -0,0 +1 @@ +../../Task/Send-email/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoHotkey/Sequence-of-non-squares b/Lang/AutoHotkey/Sequence-of-non-squares new file mode 120000 index 0000000000..6cf31321a2 --- /dev/null +++ b/Lang/AutoHotkey/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/AutoHotkey \ No newline at end of file diff --git a/Lang/AutoIt/Binary-digits b/Lang/AutoIt/Binary-digits new file mode 120000 index 0000000000..4b4f4a7dea --- /dev/null +++ b/Lang/AutoIt/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Copy-a-string b/Lang/AutoIt/Copy-a-string new file mode 120000 index 0000000000..e4e98649cc --- /dev/null +++ b/Lang/AutoIt/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Nth-root b/Lang/AutoIt/Nth-root new file mode 120000 index 0000000000..08e148af4d --- /dev/null +++ b/Lang/AutoIt/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Palindrome-detection b/Lang/AutoIt/Palindrome-detection new file mode 120000 index 0000000000..1448389ff2 --- /dev/null +++ b/Lang/AutoIt/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Pangram-checker b/Lang/AutoIt/Pangram-checker new file mode 120000 index 0000000000..6dfc204833 --- /dev/null +++ b/Lang/AutoIt/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Program-termination b/Lang/AutoIt/Program-termination new file mode 120000 index 0000000000..f0c2f8acf7 --- /dev/null +++ b/Lang/AutoIt/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Reduced-row-echelon-form b/Lang/AutoIt/Reduced-row-echelon-form new file mode 120000 index 0000000000..33ba1d8e6b --- /dev/null +++ b/Lang/AutoIt/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Return-multiple-values b/Lang/AutoIt/Return-multiple-values new file mode 120000 index 0000000000..d675cf94b7 --- /dev/null +++ b/Lang/AutoIt/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Reverse-a-string b/Lang/AutoIt/Reverse-a-string new file mode 120000 index 0000000000..1ee04e545e --- /dev/null +++ b/Lang/AutoIt/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/AutoIt \ No newline at end of file diff --git a/Lang/AutoIt/Rock-paper-scissors b/Lang/AutoIt/Rock-paper-scissors new file mode 120000 index 0000000000..6815095866 --- /dev/null +++ b/Lang/AutoIt/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/AutoIt \ No newline at end of file diff --git a/Lang/Axiom/Perfect-numbers b/Lang/Axiom/Perfect-numbers new file mode 120000 index 0000000000..c1f54cf977 --- /dev/null +++ b/Lang/Axiom/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Axiom \ No newline at end of file diff --git a/Lang/Axiom/Priority-queue b/Lang/Axiom/Priority-queue new file mode 120000 index 0000000000..5d9f21b4a0 --- /dev/null +++ b/Lang/Axiom/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/Axiom \ No newline at end of file diff --git a/Lang/Axiom/QR-decomposition b/Lang/Axiom/QR-decomposition new file mode 120000 index 0000000000..77ea3c68f5 --- /dev/null +++ b/Lang/Axiom/QR-decomposition @@ -0,0 +1 @@ +../../Task/QR-decomposition/Axiom \ No newline at end of file diff --git a/Lang/Axiom/Roots-of-a-function b/Lang/Axiom/Roots-of-a-function new file mode 120000 index 0000000000..a630e654a4 --- /dev/null +++ b/Lang/Axiom/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/Axiom \ No newline at end of file diff --git a/Lang/BASIC/Catalan-numbers b/Lang/BASIC/Catalan-numbers new file mode 120000 index 0000000000..1e1e81b82d --- /dev/null +++ b/Lang/BASIC/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Dragon-curve b/Lang/BASIC/Dragon-curve new file mode 120000 index 0000000000..1191756bec --- /dev/null +++ b/Lang/BASIC/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Environment-variables b/Lang/BASIC/Environment-variables new file mode 120000 index 0000000000..d5f5eb8ae8 --- /dev/null +++ b/Lang/BASIC/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Nth-root b/Lang/BASIC/Nth-root new file mode 120000 index 0000000000..23ce85836b --- /dev/null +++ b/Lang/BASIC/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Number-names b/Lang/BASIC/Number-names new file mode 120000 index 0000000000..f0ccc76437 --- /dev/null +++ b/Lang/BASIC/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Number-reversal-game b/Lang/BASIC/Number-reversal-game new file mode 120000 index 0000000000..728ed8c834 --- /dev/null +++ b/Lang/BASIC/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Numerical-integration b/Lang/BASIC/Numerical-integration new file mode 120000 index 0000000000..a08768abea --- /dev/null +++ b/Lang/BASIC/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/BASIC \ No newline at end of file diff --git a/Lang/BASIC/One-dimensional-cellular-automata b/Lang/BASIC/One-dimensional-cellular-automata new file mode 120000 index 0000000000..91d5b5ff5e --- /dev/null +++ b/Lang/BASIC/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/BASIC \ No newline at end of file diff --git a/Lang/BASIC/One-of-n-lines-in-a-file b/Lang/BASIC/One-of-n-lines-in-a-file new file mode 120000 index 0000000000..43bd377078 --- /dev/null +++ b/Lang/BASIC/One-of-n-lines-in-a-file @@ -0,0 +1 @@ +../../Task/One-of-n-lines-in-a-file/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Palindrome-detection b/Lang/BASIC/Palindrome-detection new file mode 120000 index 0000000000..7de6221ded --- /dev/null +++ b/Lang/BASIC/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Pangram-checker b/Lang/BASIC/Pangram-checker new file mode 120000 index 0000000000..4e6c524734 --- /dev/null +++ b/Lang/BASIC/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Pascals-triangle b/Lang/BASIC/Pascals-triangle new file mode 120000 index 0000000000..e11fa2a0da --- /dev/null +++ b/Lang/BASIC/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Perfect-numbers b/Lang/BASIC/Perfect-numbers new file mode 120000 index 0000000000..424b901ed5 --- /dev/null +++ b/Lang/BASIC/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Pick-random-element b/Lang/BASIC/Pick-random-element new file mode 120000 index 0000000000..03127d5751 --- /dev/null +++ b/Lang/BASIC/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Playing-cards b/Lang/BASIC/Playing-cards new file mode 120000 index 0000000000..2f679dabf3 --- /dev/null +++ b/Lang/BASIC/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Pragmatic-directives b/Lang/BASIC/Pragmatic-directives new file mode 120000 index 0000000000..8603f1d11b --- /dev/null +++ b/Lang/BASIC/Pragmatic-directives @@ -0,0 +1 @@ +../../Task/Pragmatic-directives/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Price-fraction b/Lang/BASIC/Price-fraction new file mode 120000 index 0000000000..53b90426c7 --- /dev/null +++ b/Lang/BASIC/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Primality-by-trial-division b/Lang/BASIC/Primality-by-trial-division new file mode 120000 index 0000000000..25cccd2a41 --- /dev/null +++ b/Lang/BASIC/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Program-name b/Lang/BASIC/Program-name new file mode 120000 index 0000000000..2130a9a393 --- /dev/null +++ b/Lang/BASIC/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Program-termination b/Lang/BASIC/Program-termination new file mode 120000 index 0000000000..c80698fb7d --- /dev/null +++ b/Lang/BASIC/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Read-a-file-line-by-line b/Lang/BASIC/Read-a-file-line-by-line new file mode 120000 index 0000000000..09dc7bc7eb --- /dev/null +++ b/Lang/BASIC/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Read-entire-file b/Lang/BASIC/Read-entire-file new file mode 120000 index 0000000000..f642cce00d --- /dev/null +++ b/Lang/BASIC/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Real-constants-and-functions b/Lang/BASIC/Real-constants-and-functions new file mode 120000 index 0000000000..4a33788afd --- /dev/null +++ b/Lang/BASIC/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Rename-a-file b/Lang/BASIC/Rename-a-file new file mode 120000 index 0000000000..67cad936ab --- /dev/null +++ b/Lang/BASIC/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Reverse-a-string b/Lang/BASIC/Reverse-a-string new file mode 120000 index 0000000000..db5bd211b7 --- /dev/null +++ b/Lang/BASIC/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Rock-paper-scissors b/Lang/BASIC/Rock-paper-scissors new file mode 120000 index 0000000000..65db5ee962 --- /dev/null +++ b/Lang/BASIC/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Roman-numerals-Encode b/Lang/BASIC/Roman-numerals-Encode new file mode 120000 index 0000000000..03d174bfc9 --- /dev/null +++ b/Lang/BASIC/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Roots-of-unity b/Lang/BASIC/Roots-of-unity new file mode 120000 index 0000000000..86585e3d3b --- /dev/null +++ b/Lang/BASIC/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Rot-13 b/Lang/BASIC/Rot-13 new file mode 120000 index 0000000000..37a240fe69 --- /dev/null +++ b/Lang/BASIC/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Run-length-encoding b/Lang/BASIC/Run-length-encoding new file mode 120000 index 0000000000..94cdebf397 --- /dev/null +++ b/Lang/BASIC/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Runtime-evaluation b/Lang/BASIC/Runtime-evaluation new file mode 120000 index 0000000000..514e2c0c78 --- /dev/null +++ b/Lang/BASIC/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/BASIC \ No newline at end of file diff --git a/Lang/BASIC/SEDOLs b/Lang/BASIC/SEDOLs new file mode 120000 index 0000000000..935e26eb0f --- /dev/null +++ b/Lang/BASIC/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Scope-Function-names-and-labels b/Lang/BASIC/Scope-Function-names-and-labels new file mode 120000 index 0000000000..ed650b0fe8 --- /dev/null +++ b/Lang/BASIC/Scope-Function-names-and-labels @@ -0,0 +1 @@ +../../Task/Scope-Function-names-and-labels/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Self-describing-numbers b/Lang/BASIC/Self-describing-numbers new file mode 120000 index 0000000000..c99106ea5d --- /dev/null +++ b/Lang/BASIC/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/BASIC \ No newline at end of file diff --git a/Lang/BASIC/Sequence-of-non-squares b/Lang/BASIC/Sequence-of-non-squares new file mode 120000 index 0000000000..aec7603ce0 --- /dev/null +++ b/Lang/BASIC/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/BASIC \ No newline at end of file diff --git a/Lang/BASIC256/Dragon-curve b/Lang/BASIC256/Dragon-curve new file mode 120000 index 0000000000..d82766ccbf --- /dev/null +++ b/Lang/BASIC256/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/BASIC256 \ No newline at end of file diff --git a/Lang/BASIC256/Roman-numerals-Encode b/Lang/BASIC256/Roman-numerals-Encode new file mode 120000 index 0000000000..775bf55371 --- /dev/null +++ b/Lang/BASIC256/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/BASIC256 \ No newline at end of file diff --git a/Lang/BBC-BASIC/Binary-digits b/Lang/BBC-BASIC/Binary-digits new file mode 120000 index 0000000000..767a5ed929 --- /dev/null +++ b/Lang/BBC-BASIC/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Brownian-tree b/Lang/BBC-BASIC/Brownian-tree new file mode 120000 index 0000000000..16b91aeac6 --- /dev/null +++ b/Lang/BBC-BASIC/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/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..501af7834b --- /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/Calendar-for-real-programmers b/Lang/BBC-BASIC/Calendar-for-real-programmers deleted file mode 120000 index e970caf6e2..0000000000 --- a/Lang/BBC-BASIC/Calendar-for-real-programmers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Calendar-for-real-programmers/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Catalan-numbers b/Lang/BBC-BASIC/Catalan-numbers new file mode 120000 index 0000000000..eee6e61b43 --- /dev/null +++ b/Lang/BBC-BASIC/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Copy-a-string b/Lang/BBC-BASIC/Copy-a-string new file mode 120000 index 0000000000..8d37bd1027 --- /dev/null +++ b/Lang/BBC-BASIC/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Dragon-curve b/Lang/BBC-BASIC/Dragon-curve new file mode 120000 index 0000000000..c32fc448e1 --- /dev/null +++ b/Lang/BBC-BASIC/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Environment-variables b/Lang/BBC-BASIC/Environment-variables new file mode 120000 index 0000000000..4ccd386c44 --- /dev/null +++ b/Lang/BBC-BASIC/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Execute-a-Markov-algorithm b/Lang/BBC-BASIC/Execute-a-Markov-algorithm new file mode 120000 index 0000000000..c469a50283 --- /dev/null +++ b/Lang/BBC-BASIC/Execute-a-Markov-algorithm @@ -0,0 +1 @@ +../../Task/Execute-a-Markov-algorithm/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Guess-the-number-With-feedback--player- b/Lang/BBC-BASIC/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..9232b18ddb --- /dev/null +++ b/Lang/BBC-BASIC/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Guess-the-number-With-feedback-player b/Lang/BBC-BASIC/Guess-the-number-With-feedback-player deleted file mode 120000 index 58dd634194..0000000000 --- a/Lang/BBC-BASIC/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/N-queens-problem b/Lang/BBC-BASIC/N-queens-problem new file mode 120000 index 0000000000..ce108c0d65 --- /dev/null +++ b/Lang/BBC-BASIC/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Non-continuous-subsequences b/Lang/BBC-BASIC/Non-continuous-subsequences new file mode 120000 index 0000000000..4153eb48f1 --- /dev/null +++ b/Lang/BBC-BASIC/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Non-decimal-radices-Convert b/Lang/BBC-BASIC/Non-decimal-radices-Convert new file mode 120000 index 0000000000..3a2e0708e0 --- /dev/null +++ b/Lang/BBC-BASIC/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Non-decimal-radices-Input b/Lang/BBC-BASIC/Non-decimal-radices-Input new file mode 120000 index 0000000000..e4caeec6d8 --- /dev/null +++ b/Lang/BBC-BASIC/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Non-decimal-radices-Output b/Lang/BBC-BASIC/Non-decimal-radices-Output new file mode 120000 index 0000000000..beb6f64157 --- /dev/null +++ b/Lang/BBC-BASIC/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Nth-root b/Lang/BBC-BASIC/Nth-root new file mode 120000 index 0000000000..2e52f27c21 --- /dev/null +++ b/Lang/BBC-BASIC/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Null-object b/Lang/BBC-BASIC/Null-object new file mode 120000 index 0000000000..7327acb9d3 --- /dev/null +++ b/Lang/BBC-BASIC/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Number-names b/Lang/BBC-BASIC/Number-names new file mode 120000 index 0000000000..4acd6e6d6e --- /dev/null +++ b/Lang/BBC-BASIC/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Number-reversal-game b/Lang/BBC-BASIC/Number-reversal-game new file mode 120000 index 0000000000..e137d164f8 --- /dev/null +++ b/Lang/BBC-BASIC/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Numerical-integration b/Lang/BBC-BASIC/Numerical-integration new file mode 120000 index 0000000000..cbc1e5906a --- /dev/null +++ b/Lang/BBC-BASIC/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/One-dimensional-cellular-automata b/Lang/BBC-BASIC/One-dimensional-cellular-automata new file mode 120000 index 0000000000..3abbae033f --- /dev/null +++ b/Lang/BBC-BASIC/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/One-of-n-lines-in-a-file b/Lang/BBC-BASIC/One-of-n-lines-in-a-file new file mode 120000 index 0000000000..70e0298c3b --- /dev/null +++ b/Lang/BBC-BASIC/One-of-n-lines-in-a-file @@ -0,0 +1 @@ +../../Task/One-of-n-lines-in-a-file/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/OpenGL b/Lang/BBC-BASIC/OpenGL new file mode 120000 index 0000000000..4f619ab614 --- /dev/null +++ b/Lang/BBC-BASIC/OpenGL @@ -0,0 +1 @@ +../../Task/OpenGL/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Optional-parameters b/Lang/BBC-BASIC/Optional-parameters new file mode 120000 index 0000000000..41a38375a7 --- /dev/null +++ b/Lang/BBC-BASIC/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Order-two-numerical-lists b/Lang/BBC-BASIC/Order-two-numerical-lists new file mode 120000 index 0000000000..365b55927e --- /dev/null +++ b/Lang/BBC-BASIC/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Ordered-Partitions b/Lang/BBC-BASIC/Ordered-Partitions new file mode 120000 index 0000000000..50a8f7b8d5 --- /dev/null +++ b/Lang/BBC-BASIC/Ordered-Partitions @@ -0,0 +1 @@ +../../Task/Ordered-Partitions/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Palindrome-detection b/Lang/BBC-BASIC/Palindrome-detection new file mode 120000 index 0000000000..cf813cdb4f --- /dev/null +++ b/Lang/BBC-BASIC/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Pangram-checker b/Lang/BBC-BASIC/Pangram-checker new file mode 120000 index 0000000000..cb0ae12b2c --- /dev/null +++ b/Lang/BBC-BASIC/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Parsing-RPN-calculator-algorithm b/Lang/BBC-BASIC/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..3e6a10095a --- /dev/null +++ b/Lang/BBC-BASIC/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Partial-function-application b/Lang/BBC-BASIC/Partial-function-application new file mode 120000 index 0000000000..553e1bc175 --- /dev/null +++ b/Lang/BBC-BASIC/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Pascals-triangle b/Lang/BBC-BASIC/Pascals-triangle new file mode 120000 index 0000000000..e50c8153e8 --- /dev/null +++ b/Lang/BBC-BASIC/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Pascals-triangle-Puzzle b/Lang/BBC-BASIC/Pascals-triangle-Puzzle new file mode 120000 index 0000000000..cf208e492c --- /dev/null +++ b/Lang/BBC-BASIC/Pascals-triangle-Puzzle @@ -0,0 +1 @@ +../../Task/Pascals-triangle-Puzzle/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Percentage-difference-between-images b/Lang/BBC-BASIC/Percentage-difference-between-images new file mode 120000 index 0000000000..a85195d14f --- /dev/null +++ b/Lang/BBC-BASIC/Percentage-difference-between-images @@ -0,0 +1 @@ +../../Task/Percentage-difference-between-images/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Perfect-numbers b/Lang/BBC-BASIC/Perfect-numbers new file mode 120000 index 0000000000..5734f2c9fc --- /dev/null +++ b/Lang/BBC-BASIC/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Permutation-test b/Lang/BBC-BASIC/Permutation-test new file mode 120000 index 0000000000..861b7da89a --- /dev/null +++ b/Lang/BBC-BASIC/Permutation-test @@ -0,0 +1 @@ +../../Task/Permutation-test/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Permutations b/Lang/BBC-BASIC/Permutations new file mode 120000 index 0000000000..e13bc4060d --- /dev/null +++ b/Lang/BBC-BASIC/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Permutations-Derangements b/Lang/BBC-BASIC/Permutations-Derangements new file mode 120000 index 0000000000..62dee59161 --- /dev/null +++ b/Lang/BBC-BASIC/Permutations-Derangements @@ -0,0 +1 @@ +../../Task/Permutations-Derangements/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Permutations-by-swapping b/Lang/BBC-BASIC/Permutations-by-swapping new file mode 120000 index 0000000000..843298979d --- /dev/null +++ b/Lang/BBC-BASIC/Permutations-by-swapping @@ -0,0 +1 @@ +../../Task/Permutations-by-swapping/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Pick-random-element b/Lang/BBC-BASIC/Pick-random-element new file mode 120000 index 0000000000..b072feb170 --- /dev/null +++ b/Lang/BBC-BASIC/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Pinstripe-Display b/Lang/BBC-BASIC/Pinstripe-Display new file mode 120000 index 0000000000..12732b2f73 --- /dev/null +++ b/Lang/BBC-BASIC/Pinstripe-Display @@ -0,0 +1 @@ +../../Task/Pinstripe-Display/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Pinstripe-Printer b/Lang/BBC-BASIC/Pinstripe-Printer new file mode 120000 index 0000000000..d8f60cd2af --- /dev/null +++ b/Lang/BBC-BASIC/Pinstripe-Printer @@ -0,0 +1 @@ +../../Task/Pinstripe-Printer/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Play-recorded-sounds b/Lang/BBC-BASIC/Play-recorded-sounds new file mode 120000 index 0000000000..84047adba6 --- /dev/null +++ b/Lang/BBC-BASIC/Play-recorded-sounds @@ -0,0 +1 @@ +../../Task/Play-recorded-sounds/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Playing-cards b/Lang/BBC-BASIC/Playing-cards new file mode 120000 index 0000000000..d8390afffc --- /dev/null +++ b/Lang/BBC-BASIC/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Plot-coordinate-pairs b/Lang/BBC-BASIC/Plot-coordinate-pairs new file mode 120000 index 0000000000..d04aad36e2 --- /dev/null +++ b/Lang/BBC-BASIC/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Pointers-and-references b/Lang/BBC-BASIC/Pointers-and-references new file mode 120000 index 0000000000..1f9df88529 --- /dev/null +++ b/Lang/BBC-BASIC/Pointers-and-references @@ -0,0 +1 @@ +../../Task/Pointers-and-references/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Polymorphic-copy b/Lang/BBC-BASIC/Polymorphic-copy new file mode 120000 index 0000000000..81238ea3bb --- /dev/null +++ b/Lang/BBC-BASIC/Polymorphic-copy @@ -0,0 +1 @@ +../../Task/Polymorphic-copy/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Polymorphism b/Lang/BBC-BASIC/Polymorphism new file mode 120000 index 0000000000..78bbe38d66 --- /dev/null +++ b/Lang/BBC-BASIC/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Polynomial-long-division b/Lang/BBC-BASIC/Polynomial-long-division new file mode 120000 index 0000000000..22e595d634 --- /dev/null +++ b/Lang/BBC-BASIC/Polynomial-long-division @@ -0,0 +1 @@ +../../Task/Polynomial-long-division/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Polynomial-regression b/Lang/BBC-BASIC/Polynomial-regression new file mode 120000 index 0000000000..7eb885333b --- /dev/null +++ b/Lang/BBC-BASIC/Polynomial-regression @@ -0,0 +1 @@ +../../Task/Polynomial-regression/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Power-set b/Lang/BBC-BASIC/Power-set new file mode 120000 index 0000000000..19e1bd2f40 --- /dev/null +++ b/Lang/BBC-BASIC/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Price-fraction b/Lang/BBC-BASIC/Price-fraction new file mode 120000 index 0000000000..bf6d6bc67f --- /dev/null +++ b/Lang/BBC-BASIC/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Primality-by-trial-division b/Lang/BBC-BASIC/Primality-by-trial-division new file mode 120000 index 0000000000..62a45bd063 --- /dev/null +++ b/Lang/BBC-BASIC/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Probabilistic-choice b/Lang/BBC-BASIC/Probabilistic-choice new file mode 120000 index 0000000000..d92a29ba7f --- /dev/null +++ b/Lang/BBC-BASIC/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Problem-of-Apollonius b/Lang/BBC-BASIC/Problem-of-Apollonius new file mode 120000 index 0000000000..5df24cd34e --- /dev/null +++ b/Lang/BBC-BASIC/Problem-of-Apollonius @@ -0,0 +1 @@ +../../Task/Problem-of-Apollonius/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Program-name b/Lang/BBC-BASIC/Program-name new file mode 120000 index 0000000000..2b24ae8a78 --- /dev/null +++ b/Lang/BBC-BASIC/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Program-termination b/Lang/BBC-BASIC/Program-termination new file mode 120000 index 0000000000..345bcfc43b --- /dev/null +++ b/Lang/BBC-BASIC/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Pythagorean-triples b/Lang/BBC-BASIC/Pythagorean-triples new file mode 120000 index 0000000000..0422351ba9 --- /dev/null +++ b/Lang/BBC-BASIC/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/QR-decomposition b/Lang/BBC-BASIC/QR-decomposition new file mode 120000 index 0000000000..85d7fa286e --- /dev/null +++ b/Lang/BBC-BASIC/QR-decomposition @@ -0,0 +1 @@ +../../Task/QR-decomposition/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Quaternion-type b/Lang/BBC-BASIC/Quaternion-type new file mode 120000 index 0000000000..018816057d --- /dev/null +++ b/Lang/BBC-BASIC/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Queue-Definition b/Lang/BBC-BASIC/Queue-Definition new file mode 120000 index 0000000000..26ea9bf575 --- /dev/null +++ b/Lang/BBC-BASIC/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Queue-Usage b/Lang/BBC-BASIC/Queue-Usage new file mode 120000 index 0000000000..ece362aee6 --- /dev/null +++ b/Lang/BBC-BASIC/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Random-number-generator--device- b/Lang/BBC-BASIC/Random-number-generator--device- new file mode 120000 index 0000000000..445c8bb958 --- /dev/null +++ b/Lang/BBC-BASIC/Random-number-generator--device- @@ -0,0 +1 @@ +../../Task/Random-number-generator--device-/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Random-numbers b/Lang/BBC-BASIC/Random-numbers new file mode 120000 index 0000000000..d0b9a8ea62 --- /dev/null +++ b/Lang/BBC-BASIC/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Range-expansion b/Lang/BBC-BASIC/Range-expansion new file mode 120000 index 0000000000..923ea8638d --- /dev/null +++ b/Lang/BBC-BASIC/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Range-extraction b/Lang/BBC-BASIC/Range-extraction new file mode 120000 index 0000000000..b4afdc75fe --- /dev/null +++ b/Lang/BBC-BASIC/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Rate-counter b/Lang/BBC-BASIC/Rate-counter new file mode 120000 index 0000000000..bc08c62289 --- /dev/null +++ b/Lang/BBC-BASIC/Rate-counter @@ -0,0 +1 @@ +../../Task/Rate-counter/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Read-a-configuration-file b/Lang/BBC-BASIC/Read-a-configuration-file new file mode 120000 index 0000000000..36ad33a4c3 --- /dev/null +++ b/Lang/BBC-BASIC/Read-a-configuration-file @@ -0,0 +1 @@ +../../Task/Read-a-configuration-file/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Read-a-file-line-by-line b/Lang/BBC-BASIC/Read-a-file-line-by-line new file mode 120000 index 0000000000..6422dffa39 --- /dev/null +++ b/Lang/BBC-BASIC/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Read-a-specific-line-from-a-file b/Lang/BBC-BASIC/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..7207e39081 --- /dev/null +++ b/Lang/BBC-BASIC/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Read-entire-file b/Lang/BBC-BASIC/Read-entire-file new file mode 120000 index 0000000000..6e5865e802 --- /dev/null +++ b/Lang/BBC-BASIC/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Real-constants-and-functions b/Lang/BBC-BASIC/Real-constants-and-functions new file mode 120000 index 0000000000..cd8f1f7f86 --- /dev/null +++ b/Lang/BBC-BASIC/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Record-sound b/Lang/BBC-BASIC/Record-sound new file mode 120000 index 0000000000..b9c513198a --- /dev/null +++ b/Lang/BBC-BASIC/Record-sound @@ -0,0 +1 @@ +../../Task/Record-sound/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Reduced-row-echelon-form b/Lang/BBC-BASIC/Reduced-row-echelon-form new file mode 120000 index 0000000000..387c49ae78 --- /dev/null +++ b/Lang/BBC-BASIC/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Regular-expressions b/Lang/BBC-BASIC/Regular-expressions new file mode 120000 index 0000000000..9d2703847b --- /dev/null +++ b/Lang/BBC-BASIC/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Remove-duplicate-elements b/Lang/BBC-BASIC/Remove-duplicate-elements new file mode 120000 index 0000000000..72d6105297 --- /dev/null +++ b/Lang/BBC-BASIC/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Rename-a-file b/Lang/BBC-BASIC/Rename-a-file new file mode 120000 index 0000000000..86bff85733 --- /dev/null +++ b/Lang/BBC-BASIC/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Repeat-a-string b/Lang/BBC-BASIC/Repeat-a-string new file mode 120000 index 0000000000..6854a2c3fa --- /dev/null +++ b/Lang/BBC-BASIC/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Resistor-mesh b/Lang/BBC-BASIC/Resistor-mesh new file mode 120000 index 0000000000..a221ed2739 --- /dev/null +++ b/Lang/BBC-BASIC/Resistor-mesh @@ -0,0 +1 @@ +../../Task/Resistor-mesh/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Return-multiple-values b/Lang/BBC-BASIC/Return-multiple-values new file mode 120000 index 0000000000..44a723b0da --- /dev/null +++ b/Lang/BBC-BASIC/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Reverse-a-string b/Lang/BBC-BASIC/Reverse-a-string new file mode 120000 index 0000000000..dd5b697faf --- /dev/null +++ b/Lang/BBC-BASIC/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Rock-paper-scissors b/Lang/BBC-BASIC/Rock-paper-scissors new file mode 120000 index 0000000000..1e8e193ee3 --- /dev/null +++ b/Lang/BBC-BASIC/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Roman-numerals-Decode b/Lang/BBC-BASIC/Roman-numerals-Decode new file mode 120000 index 0000000000..d2063495e5 --- /dev/null +++ b/Lang/BBC-BASIC/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Roman-numerals-Encode b/Lang/BBC-BASIC/Roman-numerals-Encode new file mode 120000 index 0000000000..4067998660 --- /dev/null +++ b/Lang/BBC-BASIC/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Roots-of-a-function b/Lang/BBC-BASIC/Roots-of-a-function new file mode 120000 index 0000000000..7ba06fd923 --- /dev/null +++ b/Lang/BBC-BASIC/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Roots-of-a-quadratic-function b/Lang/BBC-BASIC/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..b514fd9b3d --- /dev/null +++ b/Lang/BBC-BASIC/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Roots-of-unity b/Lang/BBC-BASIC/Roots-of-unity new file mode 120000 index 0000000000..17e5cd8f9c --- /dev/null +++ b/Lang/BBC-BASIC/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Rosetta-Code-Count-examples b/Lang/BBC-BASIC/Rosetta-Code-Count-examples new file mode 120000 index 0000000000..db9da8adf4 --- /dev/null +++ b/Lang/BBC-BASIC/Rosetta-Code-Count-examples @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Count-examples/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Rosetta-Code-Rank-languages-by-popularity b/Lang/BBC-BASIC/Rosetta-Code-Rank-languages-by-popularity new file mode 120000 index 0000000000..fe97f2d5e6 --- /dev/null +++ b/Lang/BBC-BASIC/Rosetta-Code-Rank-languages-by-popularity @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-popularity/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Rot-13 b/Lang/BBC-BASIC/Rot-13 new file mode 120000 index 0000000000..2801656db0 --- /dev/null +++ b/Lang/BBC-BASIC/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Run-length-encoding b/Lang/BBC-BASIC/Run-length-encoding new file mode 120000 index 0000000000..c5bb019f8a --- /dev/null +++ b/Lang/BBC-BASIC/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Runtime-evaluation b/Lang/BBC-BASIC/Runtime-evaluation new file mode 120000 index 0000000000..8fd4b98879 --- /dev/null +++ b/Lang/BBC-BASIC/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Runtime-evaluation-In-an-environment b/Lang/BBC-BASIC/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..01736bac8d --- /dev/null +++ b/Lang/BBC-BASIC/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/SEDOLs b/Lang/BBC-BASIC/SEDOLs new file mode 120000 index 0000000000..727528b2c5 --- /dev/null +++ b/Lang/BBC-BASIC/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Scope-modifiers b/Lang/BBC-BASIC/Scope-modifiers new file mode 120000 index 0000000000..1147492904 --- /dev/null +++ b/Lang/BBC-BASIC/Scope-modifiers @@ -0,0 +1 @@ +../../Task/Scope-modifiers/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Secure-temporary-file b/Lang/BBC-BASIC/Secure-temporary-file new file mode 120000 index 0000000000..8abf444e7c --- /dev/null +++ b/Lang/BBC-BASIC/Secure-temporary-file @@ -0,0 +1 @@ +../../Task/Secure-temporary-file/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Self-describing-numbers b/Lang/BBC-BASIC/Self-describing-numbers new file mode 120000 index 0000000000..926be0d546 --- /dev/null +++ b/Lang/BBC-BASIC/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Self-referential-sequence b/Lang/BBC-BASIC/Self-referential-sequence new file mode 120000 index 0000000000..35afb7d294 --- /dev/null +++ b/Lang/BBC-BASIC/Self-referential-sequence @@ -0,0 +1 @@ +../../Task/Self-referential-sequence/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Semordnilap b/Lang/BBC-BASIC/Semordnilap new file mode 120000 index 0000000000..73a3e1d407 --- /dev/null +++ b/Lang/BBC-BASIC/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Send-email b/Lang/BBC-BASIC/Send-email new file mode 120000 index 0000000000..51b520e00d --- /dev/null +++ b/Lang/BBC-BASIC/Send-email @@ -0,0 +1 @@ +../../Task/Send-email/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Sequence-of-non-squares b/Lang/BBC-BASIC/Sequence-of-non-squares new file mode 120000 index 0000000000..edc4c24756 --- /dev/null +++ b/Lang/BBC-BASIC/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/BBC-BASIC \ No newline at end of file diff --git a/Lang/BBC-BASIC/Set b/Lang/BBC-BASIC/Set new file mode 120000 index 0000000000..5f5dd7044e --- /dev/null +++ b/Lang/BBC-BASIC/Set @@ -0,0 +1 @@ +../../Task/Set/BBC-BASIC \ No newline at end of file diff --git a/Lang/BCPL/N-queens-problem b/Lang/BCPL/N-queens-problem new file mode 120000 index 0000000000..f11d295e71 --- /dev/null +++ b/Lang/BCPL/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/BCPL \ No newline at end of file diff --git a/Lang/Babel/Null-object b/Lang/Babel/Null-object new file mode 120000 index 0000000000..1f85849de6 --- /dev/null +++ b/Lang/Babel/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Babel \ No newline at end of file diff --git a/Lang/Babel/Repeat-a-string b/Lang/Babel/Repeat-a-string new file mode 120000 index 0000000000..5a6c89fd41 --- /dev/null +++ b/Lang/Babel/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Babel \ No newline at end of file diff --git a/Lang/Babel/Reverse-a-string b/Lang/Babel/Reverse-a-string new file mode 120000 index 0000000000..0122853504 --- /dev/null +++ b/Lang/Babel/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Babel \ No newline at end of file diff --git a/Lang/Batch-File/Binary-digits b/Lang/Batch-File/Binary-digits new file mode 120000 index 0000000000..fa65fd272c --- /dev/null +++ b/Lang/Batch-File/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Copy-a-string b/Lang/Batch-File/Copy-a-string new file mode 120000 index 0000000000..2e446c5346 --- /dev/null +++ b/Lang/Batch-File/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Environment-variables b/Lang/Batch-File/Environment-variables new file mode 120000 index 0000000000..91da886a1d --- /dev/null +++ b/Lang/Batch-File/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Program-termination b/Lang/Batch-File/Program-termination new file mode 120000 index 0000000000..c5b6be8fc9 --- /dev/null +++ b/Lang/Batch-File/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Queue-Definition b/Lang/Batch-File/Queue-Definition new file mode 120000 index 0000000000..fa4a33da54 --- /dev/null +++ b/Lang/Batch-File/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Rename-a-file b/Lang/Batch-File/Rename-a-file new file mode 120000 index 0000000000..976a99af20 --- /dev/null +++ b/Lang/Batch-File/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Repeat-a-string b/Lang/Batch-File/Repeat-a-string new file mode 120000 index 0000000000..df5e29a5a2 --- /dev/null +++ b/Lang/Batch-File/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Batch-File \ No newline at end of file diff --git a/Lang/Batch-File/Reverse-a-string b/Lang/Batch-File/Reverse-a-string new file mode 120000 index 0000000000..914c556d27 --- /dev/null +++ b/Lang/Batch-File/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Batch-File \ No newline at end of file diff --git a/Lang/Bc/Sequence-of-non-squares b/Lang/Bc/Sequence-of-non-squares new file mode 120000 index 0000000000..1f7910be60 --- /dev/null +++ b/Lang/Bc/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Bc \ No newline at end of file diff --git a/Lang/Befunge/One-dimensional-cellular-automata b/Lang/Befunge/One-dimensional-cellular-automata new file mode 120000 index 0000000000..8c33d6e667 --- /dev/null +++ b/Lang/Befunge/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Befunge \ No newline at end of file diff --git a/Lang/Befunge/Palindrome-detection b/Lang/Befunge/Palindrome-detection new file mode 120000 index 0000000000..e8a3c3aaa6 --- /dev/null +++ b/Lang/Befunge/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Befunge \ No newline at end of file diff --git a/Lang/Befunge/Prime-decomposition b/Lang/Befunge/Prime-decomposition new file mode 120000 index 0000000000..b400ed2cc9 --- /dev/null +++ b/Lang/Befunge/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Befunge \ No newline at end of file diff --git a/Lang/Befunge/Reverse-a-string b/Lang/Befunge/Reverse-a-string new file mode 120000 index 0000000000..36b6da604c --- /dev/null +++ b/Lang/Befunge/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Befunge \ No newline at end of file diff --git a/Lang/Befunge/Rot-13 b/Lang/Befunge/Rot-13 new file mode 120000 index 0000000000..1f18a4d251 --- /dev/null +++ b/Lang/Befunge/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Befunge \ No newline at end of file diff --git a/Lang/Bracmat/Arbitrary-precision-integers--included- b/Lang/Bracmat/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..f14f76e169 --- /dev/null +++ b/Lang/Bracmat/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Arbitrary-precision-integers-included b/Lang/Bracmat/Arbitrary-precision-integers-included deleted file mode 120000 index 1f1f97afa1..0000000000 --- a/Lang/Bracmat/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Catalan-numbers b/Lang/Bracmat/Catalan-numbers new file mode 120000 index 0000000000..d1ee0fabc1 --- /dev/null +++ b/Lang/Bracmat/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Copy-a-string b/Lang/Bracmat/Copy-a-string new file mode 120000 index 0000000000..90ab4c7209 --- /dev/null +++ b/Lang/Bracmat/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Non-continuous-subsequences b/Lang/Bracmat/Non-continuous-subsequences new file mode 120000 index 0000000000..524e71ca8d --- /dev/null +++ b/Lang/Bracmat/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Non-decimal-radices-Convert b/Lang/Bracmat/Non-decimal-radices-Convert new file mode 120000 index 0000000000..d65f856d05 --- /dev/null +++ b/Lang/Bracmat/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/One-dimensional-cellular-automata b/Lang/Bracmat/One-dimensional-cellular-automata new file mode 120000 index 0000000000..68b20c9c4e --- /dev/null +++ b/Lang/Bracmat/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Order-two-numerical-lists b/Lang/Bracmat/Order-two-numerical-lists new file mode 120000 index 0000000000..6b003efed4 --- /dev/null +++ b/Lang/Bracmat/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Pangram-checker b/Lang/Bracmat/Pangram-checker new file mode 120000 index 0000000000..0cb819c8fb --- /dev/null +++ b/Lang/Bracmat/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Pascals-triangle b/Lang/Bracmat/Pascals-triangle new file mode 120000 index 0000000000..1cf05e0337 --- /dev/null +++ b/Lang/Bracmat/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Pattern-matching b/Lang/Bracmat/Pattern-matching new file mode 120000 index 0000000000..5fba24acd8 --- /dev/null +++ b/Lang/Bracmat/Pattern-matching @@ -0,0 +1 @@ +../../Task/Pattern-matching/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Perfect-numbers b/Lang/Bracmat/Perfect-numbers new file mode 120000 index 0000000000..7de3f646ab --- /dev/null +++ b/Lang/Bracmat/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Permutations b/Lang/Bracmat/Permutations new file mode 120000 index 0000000000..29a91c8382 --- /dev/null +++ b/Lang/Bracmat/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Price-fraction b/Lang/Bracmat/Price-fraction new file mode 120000 index 0000000000..e1d18e5b14 --- /dev/null +++ b/Lang/Bracmat/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Primality-by-trial-division b/Lang/Bracmat/Primality-by-trial-division new file mode 120000 index 0000000000..0e57da56c5 --- /dev/null +++ b/Lang/Bracmat/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Pythagorean-triples b/Lang/Bracmat/Pythagorean-triples new file mode 120000 index 0000000000..1aa971a8d2 --- /dev/null +++ b/Lang/Bracmat/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Range-expansion b/Lang/Bracmat/Range-expansion new file mode 120000 index 0000000000..e234cea43d --- /dev/null +++ b/Lang/Bracmat/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Range-extraction b/Lang/Bracmat/Range-extraction new file mode 120000 index 0000000000..0c5121636d --- /dev/null +++ b/Lang/Bracmat/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Regular-expressions b/Lang/Bracmat/Regular-expressions new file mode 120000 index 0000000000..9ba4537bbd --- /dev/null +++ b/Lang/Bracmat/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Remove-duplicate-elements b/Lang/Bracmat/Remove-duplicate-elements new file mode 120000 index 0000000000..80a9984e10 --- /dev/null +++ b/Lang/Bracmat/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Rename-a-file b/Lang/Bracmat/Rename-a-file new file mode 120000 index 0000000000..b87c760e8c --- /dev/null +++ b/Lang/Bracmat/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Repeat-a-string b/Lang/Bracmat/Repeat-a-string new file mode 120000 index 0000000000..2bc314783c --- /dev/null +++ b/Lang/Bracmat/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Return-multiple-values b/Lang/Bracmat/Return-multiple-values new file mode 120000 index 0000000000..5b2425413f --- /dev/null +++ b/Lang/Bracmat/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Reverse-a-string b/Lang/Bracmat/Reverse-a-string new file mode 120000 index 0000000000..cfb8a05385 --- /dev/null +++ b/Lang/Bracmat/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Roman-numerals-Decode b/Lang/Bracmat/Roman-numerals-Decode new file mode 120000 index 0000000000..fde9ba86c9 --- /dev/null +++ b/Lang/Bracmat/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Roman-numerals-Encode b/Lang/Bracmat/Roman-numerals-Encode new file mode 120000 index 0000000000..9ca079c100 --- /dev/null +++ b/Lang/Bracmat/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Run-length-encoding b/Lang/Bracmat/Run-length-encoding new file mode 120000 index 0000000000..4c2f5d32cf --- /dev/null +++ b/Lang/Bracmat/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Self-referential-sequence b/Lang/Bracmat/Self-referential-sequence new file mode 120000 index 0000000000..2bffa9ceba --- /dev/null +++ b/Lang/Bracmat/Self-referential-sequence @@ -0,0 +1 @@ +../../Task/Self-referential-sequence/Bracmat \ No newline at end of file diff --git a/Lang/Bracmat/Set-consolidation b/Lang/Bracmat/Set-consolidation new file mode 120000 index 0000000000..6809cdb82c --- /dev/null +++ b/Lang/Bracmat/Set-consolidation @@ -0,0 +1 @@ +../../Task/Set-consolidation/Bracmat \ No newline at end of file diff --git a/Lang/Brainf---/Binary-digits b/Lang/Brainf---/Binary-digits new file mode 120000 index 0000000000..96d66a9df1 --- /dev/null +++ b/Lang/Brainf---/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Brainf--- \ No newline at end of file diff --git a/Lang/Brainf---/Read-entire-file b/Lang/Brainf---/Read-entire-file new file mode 120000 index 0000000000..6f24320011 --- /dev/null +++ b/Lang/Brainf---/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Brainf--- \ No newline at end of file diff --git a/Lang/Brainf---/Repeat-a-string b/Lang/Brainf---/Repeat-a-string new file mode 120000 index 0000000000..8d52726f9e --- /dev/null +++ b/Lang/Brainf---/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Brainf--- \ No newline at end of file diff --git a/Lang/Brainf---/Reverse-a-string b/Lang/Brainf---/Reverse-a-string new file mode 120000 index 0000000000..765e21e4fd --- /dev/null +++ b/Lang/Brainf---/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Brainf--- \ No newline at end of file diff --git a/Lang/Brat/Catalan-numbers b/Lang/Brat/Catalan-numbers new file mode 120000 index 0000000000..09a2f098ae --- /dev/null +++ b/Lang/Brat/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Brat \ No newline at end of file diff --git a/Lang/Brat/Number-reversal-game b/Lang/Brat/Number-reversal-game new file mode 120000 index 0000000000..976634c646 --- /dev/null +++ b/Lang/Brat/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/Brat \ No newline at end of file diff --git a/Lang/Brat/Pangram-checker b/Lang/Brat/Pangram-checker new file mode 120000 index 0000000000..05d65939dc --- /dev/null +++ b/Lang/Brat/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Brat \ No newline at end of file diff --git a/Lang/Brat/Read-a-file-line-by-line b/Lang/Brat/Read-a-file-line-by-line new file mode 120000 index 0000000000..f4bd92b1a8 --- /dev/null +++ b/Lang/Brat/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Brat \ No newline at end of file diff --git a/Lang/Brat/Read-entire-file b/Lang/Brat/Read-entire-file new file mode 120000 index 0000000000..b2ddb6cb63 --- /dev/null +++ b/Lang/Brat/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Brat \ No newline at end of file diff --git a/Lang/Brat/Remove-duplicate-elements b/Lang/Brat/Remove-duplicate-elements new file mode 120000 index 0000000000..1781b72ad7 --- /dev/null +++ b/Lang/Brat/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Brat \ No newline at end of file diff --git a/Lang/Brat/Repeat-a-string b/Lang/Brat/Repeat-a-string new file mode 120000 index 0000000000..709dbd0c6b --- /dev/null +++ b/Lang/Brat/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Brat \ No newline at end of file diff --git a/Lang/Brat/Respond-to-an-unknown-method-call b/Lang/Brat/Respond-to-an-unknown-method-call new file mode 120000 index 0000000000..f97d973465 --- /dev/null +++ b/Lang/Brat/Respond-to-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Respond-to-an-unknown-method-call/Brat \ No newline at end of file diff --git a/Lang/Brat/Reverse-a-string b/Lang/Brat/Reverse-a-string new file mode 120000 index 0000000000..165996674c --- /dev/null +++ b/Lang/Brat/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Brat \ No newline at end of file diff --git a/Lang/Burlesque/Binary-digits b/Lang/Burlesque/Binary-digits new file mode 120000 index 0000000000..f00c734fb6 --- /dev/null +++ b/Lang/Burlesque/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Palindrome-detection b/Lang/Burlesque/Palindrome-detection new file mode 120000 index 0000000000..075b2cde4d --- /dev/null +++ b/Lang/Burlesque/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Pascals-triangle b/Lang/Burlesque/Pascals-triangle new file mode 120000 index 0000000000..f33b4fe418 --- /dev/null +++ b/Lang/Burlesque/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Pick-random-element b/Lang/Burlesque/Pick-random-element new file mode 120000 index 0000000000..d43072c2c2 --- /dev/null +++ b/Lang/Burlesque/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Power-set b/Lang/Burlesque/Power-set new file mode 120000 index 0000000000..9e2e943410 --- /dev/null +++ b/Lang/Burlesque/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Primality-by-trial-division b/Lang/Burlesque/Primality-by-trial-division new file mode 120000 index 0000000000..52b6b13400 --- /dev/null +++ b/Lang/Burlesque/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Prime-decomposition b/Lang/Burlesque/Prime-decomposition new file mode 120000 index 0000000000..8c469fa660 --- /dev/null +++ b/Lang/Burlesque/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Repeat-a-string b/Lang/Burlesque/Repeat-a-string new file mode 120000 index 0000000000..bc47b0fd0e --- /dev/null +++ b/Lang/Burlesque/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Reverse-a-string b/Lang/Burlesque/Reverse-a-string new file mode 120000 index 0000000000..73d7d78728 --- /dev/null +++ b/Lang/Burlesque/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Rot-13 b/Lang/Burlesque/Rot-13 new file mode 120000 index 0000000000..ec6ce4b7d1 --- /dev/null +++ b/Lang/Burlesque/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Run-length-encoding b/Lang/Burlesque/Run-length-encoding new file mode 120000 index 0000000000..fed06749aa --- /dev/null +++ b/Lang/Burlesque/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Runtime-evaluation b/Lang/Burlesque/Runtime-evaluation new file mode 120000 index 0000000000..21653fcf0e --- /dev/null +++ b/Lang/Burlesque/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/Burlesque \ No newline at end of file diff --git a/Lang/Burlesque/Sequence-of-non-squares b/Lang/Burlesque/Sequence-of-non-squares new file mode 120000 index 0000000000..f0e55cb1bd --- /dev/null +++ b/Lang/Burlesque/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Burlesque \ No newline at end of file diff --git a/Lang/C++/Binary-digits b/Lang/C++/Binary-digits new file mode 120000 index 0000000000..4c4efe1ef0 --- /dev/null +++ b/Lang/C++/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/C++ \ No newline at end of file diff --git a/Lang/C++/Catalan-numbers b/Lang/C++/Catalan-numbers new file mode 120000 index 0000000000..7133711e19 --- /dev/null +++ b/Lang/C++/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/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 deleted file mode 120000 index db20267163..0000000000 --- a/Lang/C++/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N +++ /dev/null @@ -1 +0,0 @@ -../../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-N- b/Lang/C++/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N- new file mode 120000 index 0000000000..880c338eb0 --- /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 deleted file mode 120000 index dcff703dc9..0000000000 --- a/Lang/C++/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2 +++ /dev/null @@ -1 +0,0 @@ -../../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++/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..5e07fbbb71 --- /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++/Copy-a-string b/Lang/C++/Copy-a-string new file mode 120000 index 0000000000..a190e3bfae --- /dev/null +++ b/Lang/C++/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/C++ \ No newline at end of file diff --git a/Lang/C++/Environment-variables b/Lang/C++/Environment-variables new file mode 120000 index 0000000000..b2ee939a9f --- /dev/null +++ b/Lang/C++/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/C++ \ No newline at end of file diff --git a/Lang/C++/Execute-a-Markov-algorithm b/Lang/C++/Execute-a-Markov-algorithm new file mode 120000 index 0000000000..116103d7b8 --- /dev/null +++ b/Lang/C++/Execute-a-Markov-algorithm @@ -0,0 +1 @@ +../../Task/Execute-a-Markov-algorithm/C++ \ No newline at end of file diff --git a/Lang/C++/Guess-the-number-With-feedback--player- b/Lang/C++/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..7017528b35 --- /dev/null +++ b/Lang/C++/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/C++ \ No newline at end of file diff --git a/Lang/C++/Guess-the-number-With-feedback-player b/Lang/C++/Guess-the-number-With-feedback-player deleted file mode 120000 index 7cfb075480..0000000000 --- a/Lang/C++/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/C++ \ No newline at end of file diff --git a/Lang/C++/Named-parameters b/Lang/C++/Named-parameters new file mode 120000 index 0000000000..8a704a4613 --- /dev/null +++ b/Lang/C++/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/C++ \ No newline at end of file diff --git a/Lang/C++/Non-decimal-radices-Convert b/Lang/C++/Non-decimal-radices-Convert new file mode 120000 index 0000000000..89e1bc8c21 --- /dev/null +++ b/Lang/C++/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/C++ \ No newline at end of file diff --git a/Lang/C++/Non-decimal-radices-Input b/Lang/C++/Non-decimal-radices-Input new file mode 120000 index 0000000000..86b5f543a9 --- /dev/null +++ b/Lang/C++/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/C++ \ No newline at end of file diff --git a/Lang/C++/Non-decimal-radices-Output b/Lang/C++/Non-decimal-radices-Output new file mode 120000 index 0000000000..975a713d40 --- /dev/null +++ b/Lang/C++/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/C++ \ No newline at end of file diff --git a/Lang/C++/Nth-root b/Lang/C++/Nth-root new file mode 120000 index 0000000000..2d00c0c7d9 --- /dev/null +++ b/Lang/C++/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/C++ \ No newline at end of file diff --git a/Lang/C++/Null-object b/Lang/C++/Null-object new file mode 120000 index 0000000000..71329df685 --- /dev/null +++ b/Lang/C++/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/C++ \ No newline at end of file diff --git a/Lang/C++/Number-names b/Lang/C++/Number-names new file mode 120000 index 0000000000..7ff92df008 --- /dev/null +++ b/Lang/C++/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/C++ \ No newline at end of file diff --git a/Lang/C++/Number-reversal-game b/Lang/C++/Number-reversal-game new file mode 120000 index 0000000000..6f16e0609d --- /dev/null +++ b/Lang/C++/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/C++ \ No newline at end of file diff --git a/Lang/C++/Numerical-integration b/Lang/C++/Numerical-integration new file mode 120000 index 0000000000..363e828dcb --- /dev/null +++ b/Lang/C++/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/C++ \ No newline at end of file diff --git a/Lang/C++/Object-serialization b/Lang/C++/Object-serialization new file mode 120000 index 0000000000..9c653956e4 --- /dev/null +++ b/Lang/C++/Object-serialization @@ -0,0 +1 @@ +../../Task/Object-serialization/C++ \ No newline at end of file diff --git a/Lang/C++/One-dimensional-cellular-automata b/Lang/C++/One-dimensional-cellular-automata new file mode 120000 index 0000000000..c5da9a9449 --- /dev/null +++ b/Lang/C++/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/C++ \ No newline at end of file diff --git a/Lang/C++/One-of-n-lines-in-a-file b/Lang/C++/One-of-n-lines-in-a-file new file mode 120000 index 0000000000..693f874f93 --- /dev/null +++ b/Lang/C++/One-of-n-lines-in-a-file @@ -0,0 +1 @@ +../../Task/One-of-n-lines-in-a-file/C++ \ No newline at end of file diff --git a/Lang/C++/Optional-parameters b/Lang/C++/Optional-parameters new file mode 120000 index 0000000000..e13f0fda77 --- /dev/null +++ b/Lang/C++/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/C++ \ No newline at end of file diff --git a/Lang/C++/Order-two-numerical-lists b/Lang/C++/Order-two-numerical-lists new file mode 120000 index 0000000000..a010c3f525 --- /dev/null +++ b/Lang/C++/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/C++ \ No newline at end of file diff --git a/Lang/C++/Palindrome-detection b/Lang/C++/Palindrome-detection new file mode 120000 index 0000000000..a29451113b --- /dev/null +++ b/Lang/C++/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/C++ \ No newline at end of file diff --git a/Lang/C++/Pangram-checker b/Lang/C++/Pangram-checker new file mode 120000 index 0000000000..9b07811025 --- /dev/null +++ b/Lang/C++/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/C++ \ No newline at end of file diff --git a/Lang/C++/Parallel-calculations b/Lang/C++/Parallel-calculations new file mode 120000 index 0000000000..62cffef510 --- /dev/null +++ b/Lang/C++/Parallel-calculations @@ -0,0 +1 @@ +../../Task/Parallel-calculations/C++ \ No newline at end of file diff --git a/Lang/C++/Parametric-polymorphism b/Lang/C++/Parametric-polymorphism new file mode 120000 index 0000000000..9a5567b356 --- /dev/null +++ b/Lang/C++/Parametric-polymorphism @@ -0,0 +1 @@ +../../Task/Parametric-polymorphism/C++ \ No newline at end of file diff --git a/Lang/C++/Parsing-RPN-calculator-algorithm b/Lang/C++/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..732f1a6a97 --- /dev/null +++ b/Lang/C++/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/C++ \ No newline at end of file diff --git a/Lang/C++/Partial-function-application b/Lang/C++/Partial-function-application new file mode 120000 index 0000000000..722dbd82e2 --- /dev/null +++ b/Lang/C++/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/C++ \ No newline at end of file diff --git a/Lang/C++/Pascals-triangle b/Lang/C++/Pascals-triangle new file mode 120000 index 0000000000..69e2c42758 --- /dev/null +++ b/Lang/C++/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/C++ \ No newline at end of file diff --git a/Lang/C++/Percentage-difference-between-images b/Lang/C++/Percentage-difference-between-images new file mode 120000 index 0000000000..2087e1f950 --- /dev/null +++ b/Lang/C++/Percentage-difference-between-images @@ -0,0 +1 @@ +../../Task/Percentage-difference-between-images/C++ \ No newline at end of file diff --git a/Lang/C++/Perfect-numbers b/Lang/C++/Perfect-numbers new file mode 120000 index 0000000000..2cebdbe96a --- /dev/null +++ b/Lang/C++/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/C++ \ No newline at end of file diff --git a/Lang/C++/Permutations b/Lang/C++/Permutations new file mode 120000 index 0000000000..55c1e367db --- /dev/null +++ b/Lang/C++/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/C++ \ No newline at end of file diff --git a/Lang/C++/Playing-cards b/Lang/C++/Playing-cards new file mode 120000 index 0000000000..aa2fb23471 --- /dev/null +++ b/Lang/C++/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/C++ \ No newline at end of file diff --git a/Lang/C++/Polymorphic-copy b/Lang/C++/Polymorphic-copy new file mode 120000 index 0000000000..987059721b --- /dev/null +++ b/Lang/C++/Polymorphic-copy @@ -0,0 +1 @@ +../../Task/Polymorphic-copy/C++ \ No newline at end of file diff --git a/Lang/C++/Polymorphism b/Lang/C++/Polymorphism new file mode 120000 index 0000000000..afea8b9eb3 --- /dev/null +++ b/Lang/C++/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/C++ \ No newline at end of file diff --git a/Lang/C++/Polynomial-long-division b/Lang/C++/Polynomial-long-division new file mode 120000 index 0000000000..aac66f1d55 --- /dev/null +++ b/Lang/C++/Polynomial-long-division @@ -0,0 +1 @@ +../../Task/Polynomial-long-division/C++ \ No newline at end of file diff --git a/Lang/C++/Power-set b/Lang/C++/Power-set new file mode 120000 index 0000000000..7555c2bbf9 --- /dev/null +++ b/Lang/C++/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/C++ \ No newline at end of file diff --git a/Lang/C++/Price-fraction b/Lang/C++/Price-fraction new file mode 120000 index 0000000000..1f7ad2b111 --- /dev/null +++ b/Lang/C++/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/C++ \ No newline at end of file diff --git a/Lang/C++/Primality-by-trial-division b/Lang/C++/Primality-by-trial-division new file mode 120000 index 0000000000..312a6a70db --- /dev/null +++ b/Lang/C++/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/C++ \ No newline at end of file diff --git a/Lang/C++/Prime-decomposition b/Lang/C++/Prime-decomposition new file mode 120000 index 0000000000..1b7df68c75 --- /dev/null +++ b/Lang/C++/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/C++ \ No newline at end of file diff --git a/Lang/C++/Priority-queue b/Lang/C++/Priority-queue new file mode 120000 index 0000000000..67da312b13 --- /dev/null +++ b/Lang/C++/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/C++ \ No newline at end of file diff --git a/Lang/C++/Probabilistic-choice b/Lang/C++/Probabilistic-choice new file mode 120000 index 0000000000..904e754918 --- /dev/null +++ b/Lang/C++/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/C++ \ No newline at end of file diff --git a/Lang/C++/Program-name b/Lang/C++/Program-name new file mode 120000 index 0000000000..b23c86f664 --- /dev/null +++ b/Lang/C++/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/C++ \ No newline at end of file diff --git a/Lang/C++/Program-termination b/Lang/C++/Program-termination new file mode 120000 index 0000000000..5e4b665e42 --- /dev/null +++ b/Lang/C++/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/C++ \ No newline at end of file diff --git a/Lang/C++/Quaternion-type b/Lang/C++/Quaternion-type new file mode 120000 index 0000000000..053fd1142a --- /dev/null +++ b/Lang/C++/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/C++ \ No newline at end of file diff --git a/Lang/C++/Queue-Definition b/Lang/C++/Queue-Definition new file mode 120000 index 0000000000..15f26b723e --- /dev/null +++ b/Lang/C++/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/C++ \ No newline at end of file diff --git a/Lang/C++/Queue-Usage b/Lang/C++/Queue-Usage new file mode 120000 index 0000000000..8b0f779a62 --- /dev/null +++ b/Lang/C++/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/C++ \ No newline at end of file diff --git a/Lang/C++/Random-numbers b/Lang/C++/Random-numbers new file mode 120000 index 0000000000..f61731c8c2 --- /dev/null +++ b/Lang/C++/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/C++ \ No newline at end of file diff --git a/Lang/C++/Range-expansion b/Lang/C++/Range-expansion new file mode 120000 index 0000000000..633a304f4e --- /dev/null +++ b/Lang/C++/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/C++ \ No newline at end of file diff --git a/Lang/C++/Range-extraction b/Lang/C++/Range-extraction new file mode 120000 index 0000000000..fde051eed7 --- /dev/null +++ b/Lang/C++/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/C++ \ No newline at end of file diff --git a/Lang/C++/Rate-counter b/Lang/C++/Rate-counter new file mode 120000 index 0000000000..8698f5f46b --- /dev/null +++ b/Lang/C++/Rate-counter @@ -0,0 +1 @@ +../../Task/Rate-counter/C++ \ No newline at end of file diff --git a/Lang/C++/Read-a-configuration-file b/Lang/C++/Read-a-configuration-file new file mode 120000 index 0000000000..fb4377b5fa --- /dev/null +++ b/Lang/C++/Read-a-configuration-file @@ -0,0 +1 @@ +../../Task/Read-a-configuration-file/C++ \ No newline at end of file diff --git a/Lang/C++/Read-a-file-line-by-line b/Lang/C++/Read-a-file-line-by-line new file mode 120000 index 0000000000..2ec24bfd11 --- /dev/null +++ b/Lang/C++/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/C++ \ No newline at end of file diff --git a/Lang/C++/Read-entire-file b/Lang/C++/Read-entire-file new file mode 120000 index 0000000000..697e252fe9 --- /dev/null +++ b/Lang/C++/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/C++ \ No newline at end of file diff --git a/Lang/C++/Real-constants-and-functions b/Lang/C++/Real-constants-and-functions new file mode 120000 index 0000000000..8d1aeb5ea2 --- /dev/null +++ b/Lang/C++/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/C++ \ No newline at end of file diff --git a/Lang/C++/Reduced-row-echelon-form b/Lang/C++/Reduced-row-echelon-form new file mode 120000 index 0000000000..2e42f1fcb1 --- /dev/null +++ b/Lang/C++/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/C++ \ No newline at end of file diff --git a/Lang/C++/Regular-expressions b/Lang/C++/Regular-expressions new file mode 120000 index 0000000000..b11606b2ef --- /dev/null +++ b/Lang/C++/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/C++ \ No newline at end of file diff --git a/Lang/C++/Remove-duplicate-elements b/Lang/C++/Remove-duplicate-elements new file mode 120000 index 0000000000..8f30683ab0 --- /dev/null +++ b/Lang/C++/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/C++ \ No newline at end of file diff --git a/Lang/C++/Remove-lines-from-a-file b/Lang/C++/Remove-lines-from-a-file new file mode 120000 index 0000000000..ed5228177c --- /dev/null +++ b/Lang/C++/Remove-lines-from-a-file @@ -0,0 +1 @@ +../../Task/Remove-lines-from-a-file/C++ \ No newline at end of file diff --git a/Lang/C++/Rename-a-file b/Lang/C++/Rename-a-file new file mode 120000 index 0000000000..67aa6cab9a --- /dev/null +++ b/Lang/C++/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/C++ \ No newline at end of file diff --git a/Lang/C++/Repeat-a-string b/Lang/C++/Repeat-a-string new file mode 120000 index 0000000000..1b443871db --- /dev/null +++ b/Lang/C++/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/C++ \ No newline at end of file diff --git a/Lang/C++/Respond-to-an-unknown-method-call b/Lang/C++/Respond-to-an-unknown-method-call new file mode 120000 index 0000000000..729ad39644 --- /dev/null +++ b/Lang/C++/Respond-to-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Respond-to-an-unknown-method-call/C++ \ No newline at end of file diff --git a/Lang/C++/Return-multiple-values b/Lang/C++/Return-multiple-values new file mode 120000 index 0000000000..721704ebb2 --- /dev/null +++ b/Lang/C++/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/C++ \ No newline at end of file diff --git a/Lang/C++/Reverse-a-string b/Lang/C++/Reverse-a-string new file mode 120000 index 0000000000..a9b89b0338 --- /dev/null +++ b/Lang/C++/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/C++ \ No newline at end of file diff --git a/Lang/C++/Rock-paper-scissors b/Lang/C++/Rock-paper-scissors new file mode 120000 index 0000000000..a951aba2f1 --- /dev/null +++ b/Lang/C++/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/C++ \ No newline at end of file diff --git a/Lang/C++/Roman-numerals-Decode b/Lang/C++/Roman-numerals-Decode new file mode 120000 index 0000000000..9b9287db7b --- /dev/null +++ b/Lang/C++/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/C++ \ No newline at end of file diff --git a/Lang/C++/Roman-numerals-Encode b/Lang/C++/Roman-numerals-Encode new file mode 120000 index 0000000000..46f0422e74 --- /dev/null +++ b/Lang/C++/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/C++ \ No newline at end of file diff --git a/Lang/C++/Roots-of-a-function b/Lang/C++/Roots-of-a-function new file mode 120000 index 0000000000..8e16377d49 --- /dev/null +++ b/Lang/C++/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/C++ \ No newline at end of file diff --git a/Lang/C++/Roots-of-a-quadratic-function b/Lang/C++/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..cd213a4bcd --- /dev/null +++ b/Lang/C++/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/C++ \ No newline at end of file diff --git a/Lang/C++/Roots-of-unity b/Lang/C++/Roots-of-unity new file mode 120000 index 0000000000..90ef7954e2 --- /dev/null +++ b/Lang/C++/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/C++ \ No newline at end of file diff --git a/Lang/C++/Rosetta-Code-Rank-languages-by-popularity b/Lang/C++/Rosetta-Code-Rank-languages-by-popularity new file mode 120000 index 0000000000..2989c4c31e --- /dev/null +++ b/Lang/C++/Rosetta-Code-Rank-languages-by-popularity @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-popularity/C++ \ No newline at end of file diff --git a/Lang/C++/Rot-13 b/Lang/C++/Rot-13 new file mode 120000 index 0000000000..a0426842ad --- /dev/null +++ b/Lang/C++/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/C++ \ No newline at end of file diff --git a/Lang/C++/Run-length-encoding b/Lang/C++/Run-length-encoding new file mode 120000 index 0000000000..71b286b493 --- /dev/null +++ b/Lang/C++/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/C++ \ No newline at end of file diff --git a/Lang/C++/SEDOLs b/Lang/C++/SEDOLs new file mode 120000 index 0000000000..bf8c9763e3 --- /dev/null +++ b/Lang/C++/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/C++ \ No newline at end of file diff --git a/Lang/C++/Semordnilap b/Lang/C++/Semordnilap new file mode 120000 index 0000000000..0655152d9a --- /dev/null +++ b/Lang/C++/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/C++ \ No newline at end of file diff --git a/Lang/C++/Send-email b/Lang/C++/Send-email new file mode 120000 index 0000000000..fb7a7cc0b0 --- /dev/null +++ b/Lang/C++/Send-email @@ -0,0 +1 @@ +../../Task/Send-email/C++ \ No newline at end of file diff --git a/Lang/C++/Sequence-of-non-squares b/Lang/C++/Sequence-of-non-squares new file mode 120000 index 0000000000..e4dddfdcb4 --- /dev/null +++ b/Lang/C++/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/C++ \ No newline at end of file diff --git a/Lang/C++/Set b/Lang/C++/Set new file mode 120000 index 0000000000..88b3cee7a7 --- /dev/null +++ b/Lang/C++/Set @@ -0,0 +1 @@ +../../Task/Set/C++ \ 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..e9bedb7cb7 --- /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/Arbitrary-precision-integers-included b/Lang/C-sharp/Arbitrary-precision-integers-included deleted file mode 120000 index 31bcb5946e..0000000000 --- a/Lang/C-sharp/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/One-dimensional-cellular-automata b/Lang/C-sharp/One-dimensional-cellular-automata new file mode 120000 index 0000000000..b4d7bf29d7 --- /dev/null +++ b/Lang/C-sharp/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Partial-function-application b/Lang/C-sharp/Partial-function-application new file mode 120000 index 0000000000..47eaba67ae --- /dev/null +++ b/Lang/C-sharp/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Polynomial-regression b/Lang/C-sharp/Polynomial-regression new file mode 120000 index 0000000000..e0fef468e4 --- /dev/null +++ b/Lang/C-sharp/Polynomial-regression @@ -0,0 +1 @@ +../../Task/Polynomial-regression/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Quaternion-type b/Lang/C-sharp/Quaternion-type new file mode 120000 index 0000000000..53c4bd6185 --- /dev/null +++ b/Lang/C-sharp/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Queue-Definition b/Lang/C-sharp/Queue-Definition new file mode 120000 index 0000000000..1052856d6c --- /dev/null +++ b/Lang/C-sharp/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Queue-Usage b/Lang/C-sharp/Queue-Usage new file mode 120000 index 0000000000..699aefe778 --- /dev/null +++ b/Lang/C-sharp/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Random-number-generator--device- b/Lang/C-sharp/Random-number-generator--device- new file mode 120000 index 0000000000..b95bc0959c --- /dev/null +++ b/Lang/C-sharp/Random-number-generator--device- @@ -0,0 +1 @@ +../../Task/Random-number-generator--device-/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Random-numbers b/Lang/C-sharp/Random-numbers new file mode 120000 index 0000000000..6adca58d67 --- /dev/null +++ b/Lang/C-sharp/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Range-extraction b/Lang/C-sharp/Range-extraction new file mode 120000 index 0000000000..cf2985c99c --- /dev/null +++ b/Lang/C-sharp/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Read-a-file-line-by-line b/Lang/C-sharp/Read-a-file-line-by-line new file mode 120000 index 0000000000..8a62edf17e --- /dev/null +++ b/Lang/C-sharp/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Read-a-specific-line-from-a-file b/Lang/C-sharp/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..25823f8132 --- /dev/null +++ b/Lang/C-sharp/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Read-entire-file b/Lang/C-sharp/Read-entire-file new file mode 120000 index 0000000000..d9c2b7d9fa --- /dev/null +++ b/Lang/C-sharp/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Real-constants-and-functions b/Lang/C-sharp/Real-constants-and-functions new file mode 120000 index 0000000000..a421c0a239 --- /dev/null +++ b/Lang/C-sharp/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Regular-expressions b/Lang/C-sharp/Regular-expressions new file mode 120000 index 0000000000..3746fb2dc9 --- /dev/null +++ b/Lang/C-sharp/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Remove-duplicate-elements b/Lang/C-sharp/Remove-duplicate-elements new file mode 120000 index 0000000000..b45a34c6af --- /dev/null +++ b/Lang/C-sharp/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Rename-a-file b/Lang/C-sharp/Rename-a-file new file mode 120000 index 0000000000..55f359fca7 --- /dev/null +++ b/Lang/C-sharp/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Repeat-a-string b/Lang/C-sharp/Repeat-a-string new file mode 120000 index 0000000000..d9e9dce863 --- /dev/null +++ b/Lang/C-sharp/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/C-sharp \ No newline at end of file diff --git a/Lang/C-sharp/Set-of-real-numbers b/Lang/C-sharp/Set-of-real-numbers new file mode 120000 index 0000000000..7071ac26f2 --- /dev/null +++ b/Lang/C-sharp/Set-of-real-numbers @@ -0,0 +1 @@ +../../Task/Set-of-real-numbers/C-sharp \ No newline at end of file diff --git a/Lang/C/Arbitrary-precision-integers--included- b/Lang/C/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..16e09813d0 --- /dev/null +++ b/Lang/C/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/C \ No newline at end of file diff --git a/Lang/C/Arbitrary-precision-integers-included b/Lang/C/Arbitrary-precision-integers-included deleted file mode 120000 index d8ca326673..0000000000 --- a/Lang/C/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/C \ No newline at end of file diff --git a/Lang/C/Binary-digits b/Lang/C/Binary-digits new file mode 120000 index 0000000000..c8cc102a41 --- /dev/null +++ b/Lang/C/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/C \ No newline at end of file diff --git a/Lang/C/Brownian-tree b/Lang/C/Brownian-tree new file mode 120000 index 0000000000..001c00ce81 --- /dev/null +++ b/Lang/C/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/C \ No newline at end of file diff --git a/Lang/C/Catalan-numbers b/Lang/C/Catalan-numbers new file mode 120000 index 0000000000..95f525bb6d --- /dev/null +++ b/Lang/C/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/C \ No newline at end of file diff --git a/Lang/C/Copy-a-string b/Lang/C/Copy-a-string new file mode 120000 index 0000000000..0dae64bfda --- /dev/null +++ b/Lang/C/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/C \ No newline at end of file diff --git a/Lang/C/Dragon-curve b/Lang/C/Dragon-curve new file mode 120000 index 0000000000..3edeb4f8d3 --- /dev/null +++ b/Lang/C/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/C \ No newline at end of file diff --git a/Lang/C/Environment-variables b/Lang/C/Environment-variables new file mode 120000 index 0000000000..25d9f46770 --- /dev/null +++ b/Lang/C/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/C \ No newline at end of file diff --git a/Lang/C/Execute-a-Markov-algorithm b/Lang/C/Execute-a-Markov-algorithm new file mode 120000 index 0000000000..9e820d01e7 --- /dev/null +++ b/Lang/C/Execute-a-Markov-algorithm @@ -0,0 +1 @@ +../../Task/Execute-a-Markov-algorithm/C \ No newline at end of file diff --git a/Lang/C/Guess-the-number-With-feedback--player- b/Lang/C/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..144725d1c8 --- /dev/null +++ b/Lang/C/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/C \ No newline at end of file diff --git a/Lang/C/Guess-the-number-With-feedback-player b/Lang/C/Guess-the-number-With-feedback-player deleted file mode 120000 index 9c42d1c8d0..0000000000 --- a/Lang/C/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/C \ No newline at end of file diff --git a/Lang/C/N-queens-problem b/Lang/C/N-queens-problem new file mode 120000 index 0000000000..694a64b2de --- /dev/null +++ b/Lang/C/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/C \ No newline at end of file diff --git a/Lang/C/Named-parameters b/Lang/C/Named-parameters new file mode 120000 index 0000000000..8f33c75a62 --- /dev/null +++ b/Lang/C/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/C \ No newline at end of file diff --git a/Lang/C/Non-continuous-subsequences b/Lang/C/Non-continuous-subsequences new file mode 120000 index 0000000000..cf8d47e7a6 --- /dev/null +++ b/Lang/C/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/C \ No newline at end of file diff --git a/Lang/C/Non-decimal-radices-Convert b/Lang/C/Non-decimal-radices-Convert new file mode 120000 index 0000000000..001852a43b --- /dev/null +++ b/Lang/C/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/C \ No newline at end of file diff --git a/Lang/C/Non-decimal-radices-Input b/Lang/C/Non-decimal-radices-Input new file mode 120000 index 0000000000..8d46245f41 --- /dev/null +++ b/Lang/C/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/C \ No newline at end of file diff --git a/Lang/C/Non-decimal-radices-Output b/Lang/C/Non-decimal-radices-Output new file mode 120000 index 0000000000..6bbdd92fdf --- /dev/null +++ b/Lang/C/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/C \ No newline at end of file diff --git a/Lang/C/Nth-root b/Lang/C/Nth-root new file mode 120000 index 0000000000..d2fccbd279 --- /dev/null +++ b/Lang/C/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/C \ No newline at end of file diff --git a/Lang/C/Null-object b/Lang/C/Null-object new file mode 120000 index 0000000000..5bd46a323e --- /dev/null +++ b/Lang/C/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/C \ No newline at end of file diff --git a/Lang/C/Number-names b/Lang/C/Number-names new file mode 120000 index 0000000000..49e267f21b --- /dev/null +++ b/Lang/C/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/C \ No newline at end of file diff --git a/Lang/C/Number-reversal-game b/Lang/C/Number-reversal-game new file mode 120000 index 0000000000..c80f6f34ea --- /dev/null +++ b/Lang/C/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/C \ No newline at end of file diff --git a/Lang/C/Numeric-error-propagation b/Lang/C/Numeric-error-propagation new file mode 120000 index 0000000000..a5fe522b57 --- /dev/null +++ b/Lang/C/Numeric-error-propagation @@ -0,0 +1 @@ +../../Task/Numeric-error-propagation/C \ No newline at end of file diff --git a/Lang/C/Numerical-integration b/Lang/C/Numerical-integration new file mode 120000 index 0000000000..fe8cc58cba --- /dev/null +++ b/Lang/C/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/C \ No newline at end of file diff --git a/Lang/C/Numerical-integration-Gauss-Legendre-Quadrature b/Lang/C/Numerical-integration-Gauss-Legendre-Quadrature new file mode 120000 index 0000000000..05bc4bbda7 --- /dev/null +++ b/Lang/C/Numerical-integration-Gauss-Legendre-Quadrature @@ -0,0 +1 @@ +../../Task/Numerical-integration-Gauss-Legendre-Quadrature/C \ No newline at end of file diff --git a/Lang/C/One-dimensional-cellular-automata b/Lang/C/One-dimensional-cellular-automata new file mode 120000 index 0000000000..013cd67fa4 --- /dev/null +++ b/Lang/C/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/C \ No newline at end of file diff --git a/Lang/C/One-of-n-lines-in-a-file b/Lang/C/One-of-n-lines-in-a-file new file mode 120000 index 0000000000..797335c774 --- /dev/null +++ b/Lang/C/One-of-n-lines-in-a-file @@ -0,0 +1 @@ +../../Task/One-of-n-lines-in-a-file/C \ No newline at end of file diff --git a/Lang/C/OpenGL b/Lang/C/OpenGL new file mode 120000 index 0000000000..b8ed83bbd9 --- /dev/null +++ b/Lang/C/OpenGL @@ -0,0 +1 @@ +../../Task/OpenGL/C \ No newline at end of file diff --git a/Lang/C/Optional-parameters b/Lang/C/Optional-parameters new file mode 120000 index 0000000000..985ab68c2c --- /dev/null +++ b/Lang/C/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/C \ No newline at end of file diff --git a/Lang/C/Order-two-numerical-lists b/Lang/C/Order-two-numerical-lists new file mode 120000 index 0000000000..8dfa9d7e66 --- /dev/null +++ b/Lang/C/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/C \ No newline at end of file diff --git a/Lang/C/Ordered-Partitions b/Lang/C/Ordered-Partitions new file mode 120000 index 0000000000..a86063403b --- /dev/null +++ b/Lang/C/Ordered-Partitions @@ -0,0 +1 @@ +../../Task/Ordered-Partitions/C \ No newline at end of file diff --git a/Lang/C/Palindrome-detection b/Lang/C/Palindrome-detection new file mode 120000 index 0000000000..f6828b7d70 --- /dev/null +++ b/Lang/C/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/C \ No newline at end of file diff --git a/Lang/C/Pangram-checker b/Lang/C/Pangram-checker new file mode 120000 index 0000000000..980fb1cf68 --- /dev/null +++ b/Lang/C/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/C \ No newline at end of file diff --git a/Lang/C/Parallel-calculations b/Lang/C/Parallel-calculations new file mode 120000 index 0000000000..72904889ae --- /dev/null +++ b/Lang/C/Parallel-calculations @@ -0,0 +1 @@ +../../Task/Parallel-calculations/C \ No newline at end of file diff --git a/Lang/C/Parametric-polymorphism b/Lang/C/Parametric-polymorphism new file mode 120000 index 0000000000..48ce1196a9 --- /dev/null +++ b/Lang/C/Parametric-polymorphism @@ -0,0 +1 @@ +../../Task/Parametric-polymorphism/C \ No newline at end of file diff --git a/Lang/C/Parsing-RPN-calculator-algorithm b/Lang/C/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..622dfa55d5 --- /dev/null +++ b/Lang/C/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/C \ No newline at end of file diff --git a/Lang/C/Parsing-Shunting-yard-algorithm b/Lang/C/Parsing-Shunting-yard-algorithm new file mode 120000 index 0000000000..1a67f3409a --- /dev/null +++ b/Lang/C/Parsing-Shunting-yard-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-Shunting-yard-algorithm/C \ No newline at end of file diff --git a/Lang/C/Partial-function-application b/Lang/C/Partial-function-application new file mode 120000 index 0000000000..b1ee36ecec --- /dev/null +++ b/Lang/C/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/C \ No newline at end of file diff --git a/Lang/C/Pascals-triangle b/Lang/C/Pascals-triangle new file mode 120000 index 0000000000..ba5aef532d --- /dev/null +++ b/Lang/C/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/C \ No newline at end of file diff --git a/Lang/C/Pascals-triangle-Puzzle b/Lang/C/Pascals-triangle-Puzzle new file mode 120000 index 0000000000..89c5126606 --- /dev/null +++ b/Lang/C/Pascals-triangle-Puzzle @@ -0,0 +1 @@ +../../Task/Pascals-triangle-Puzzle/C \ No newline at end of file diff --git a/Lang/C/Percentage-difference-between-images b/Lang/C/Percentage-difference-between-images new file mode 120000 index 0000000000..efe1a18565 --- /dev/null +++ b/Lang/C/Percentage-difference-between-images @@ -0,0 +1 @@ +../../Task/Percentage-difference-between-images/C \ No newline at end of file diff --git a/Lang/C/Perfect-numbers b/Lang/C/Perfect-numbers new file mode 120000 index 0000000000..67f4f421d1 --- /dev/null +++ b/Lang/C/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/C \ No newline at end of file diff --git a/Lang/C/Permutation-test b/Lang/C/Permutation-test new file mode 120000 index 0000000000..eacec90495 --- /dev/null +++ b/Lang/C/Permutation-test @@ -0,0 +1 @@ +../../Task/Permutation-test/C \ No newline at end of file diff --git a/Lang/C/Permutations b/Lang/C/Permutations new file mode 120000 index 0000000000..de95e22bef --- /dev/null +++ b/Lang/C/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/C \ No newline at end of file diff --git a/Lang/C/Permutations-Derangements b/Lang/C/Permutations-Derangements new file mode 120000 index 0000000000..3ff4785afa --- /dev/null +++ b/Lang/C/Permutations-Derangements @@ -0,0 +1 @@ +../../Task/Permutations-Derangements/C \ No newline at end of file diff --git a/Lang/C/Pick-random-element b/Lang/C/Pick-random-element new file mode 120000 index 0000000000..7a501c1a8d --- /dev/null +++ b/Lang/C/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/C \ No newline at end of file diff --git a/Lang/C/Playing-cards b/Lang/C/Playing-cards new file mode 120000 index 0000000000..159c808d37 --- /dev/null +++ b/Lang/C/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/C \ No newline at end of file diff --git a/Lang/C/Plot-coordinate-pairs b/Lang/C/Plot-coordinate-pairs new file mode 120000 index 0000000000..c649099132 --- /dev/null +++ b/Lang/C/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/C \ No newline at end of file diff --git a/Lang/C/Polymorphic-copy b/Lang/C/Polymorphic-copy new file mode 120000 index 0000000000..a9d90b2ccf --- /dev/null +++ b/Lang/C/Polymorphic-copy @@ -0,0 +1 @@ +../../Task/Polymorphic-copy/C \ No newline at end of file diff --git a/Lang/C/Polynomial-long-division b/Lang/C/Polynomial-long-division new file mode 120000 index 0000000000..8f35177d30 --- /dev/null +++ b/Lang/C/Polynomial-long-division @@ -0,0 +1 @@ +../../Task/Polynomial-long-division/C \ No newline at end of file diff --git a/Lang/C/Polynomial-regression b/Lang/C/Polynomial-regression new file mode 120000 index 0000000000..5ecf76f232 --- /dev/null +++ b/Lang/C/Polynomial-regression @@ -0,0 +1 @@ +../../Task/Polynomial-regression/C \ No newline at end of file diff --git a/Lang/C/Power-set b/Lang/C/Power-set new file mode 120000 index 0000000000..43cfb47ccc --- /dev/null +++ b/Lang/C/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/C \ No newline at end of file diff --git a/Lang/C/Price-fraction b/Lang/C/Price-fraction new file mode 120000 index 0000000000..3eae9550ae --- /dev/null +++ b/Lang/C/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/C \ No newline at end of file diff --git a/Lang/C/Primality-by-trial-division b/Lang/C/Primality-by-trial-division new file mode 120000 index 0000000000..cbb10072ab --- /dev/null +++ b/Lang/C/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/C \ No newline at end of file diff --git a/Lang/C/Prime-decomposition b/Lang/C/Prime-decomposition new file mode 120000 index 0000000000..a61d8294a6 --- /dev/null +++ b/Lang/C/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/C \ No newline at end of file diff --git a/Lang/C/Priority-queue b/Lang/C/Priority-queue new file mode 120000 index 0000000000..cc1cd4dfc7 --- /dev/null +++ b/Lang/C/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/C \ No newline at end of file diff --git a/Lang/C/Probabilistic-choice b/Lang/C/Probabilistic-choice new file mode 120000 index 0000000000..0fbe265148 --- /dev/null +++ b/Lang/C/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/C \ No newline at end of file diff --git a/Lang/C/Problem-of-Apollonius b/Lang/C/Problem-of-Apollonius new file mode 120000 index 0000000000..dc4f10e2a1 --- /dev/null +++ b/Lang/C/Problem-of-Apollonius @@ -0,0 +1 @@ +../../Task/Problem-of-Apollonius/C \ No newline at end of file diff --git a/Lang/C/Program-name b/Lang/C/Program-name new file mode 120000 index 0000000000..3000d69906 --- /dev/null +++ b/Lang/C/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/C \ No newline at end of file diff --git a/Lang/C/Program-termination b/Lang/C/Program-termination new file mode 120000 index 0000000000..6ac5f91b56 --- /dev/null +++ b/Lang/C/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/C \ No newline at end of file diff --git a/Lang/C/Pythagorean-triples b/Lang/C/Pythagorean-triples new file mode 120000 index 0000000000..d30392eb25 --- /dev/null +++ b/Lang/C/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/C \ No newline at end of file diff --git a/Lang/C/QR-decomposition b/Lang/C/QR-decomposition new file mode 120000 index 0000000000..d7306be816 --- /dev/null +++ b/Lang/C/QR-decomposition @@ -0,0 +1 @@ +../../Task/QR-decomposition/C \ No newline at end of file diff --git a/Lang/C/Quaternion-type b/Lang/C/Quaternion-type new file mode 120000 index 0000000000..25d9910755 --- /dev/null +++ b/Lang/C/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/C \ No newline at end of file diff --git a/Lang/C/Queue-Definition b/Lang/C/Queue-Definition new file mode 120000 index 0000000000..fab51c1a91 --- /dev/null +++ b/Lang/C/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/C \ No newline at end of file diff --git a/Lang/C/Queue-Usage b/Lang/C/Queue-Usage new file mode 120000 index 0000000000..d9ac2fbc76 --- /dev/null +++ b/Lang/C/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/C \ No newline at end of file diff --git a/Lang/C/Random-number-generator--device- b/Lang/C/Random-number-generator--device- new file mode 120000 index 0000000000..8bd3df339d --- /dev/null +++ b/Lang/C/Random-number-generator--device- @@ -0,0 +1 @@ +../../Task/Random-number-generator--device-/C \ No newline at end of file diff --git a/Lang/C/Random-number-generator--included- b/Lang/C/Random-number-generator--included- new file mode 120000 index 0000000000..bdbcca09ff --- /dev/null +++ b/Lang/C/Random-number-generator--included- @@ -0,0 +1 @@ +../../Task/Random-number-generator--included-/C \ No newline at end of file diff --git a/Lang/C/Random-numbers b/Lang/C/Random-numbers new file mode 120000 index 0000000000..adb1fd689f --- /dev/null +++ b/Lang/C/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/C \ No newline at end of file diff --git a/Lang/C/Range-expansion b/Lang/C/Range-expansion new file mode 120000 index 0000000000..1140d72f24 --- /dev/null +++ b/Lang/C/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/C \ No newline at end of file diff --git a/Lang/C/Range-extraction b/Lang/C/Range-extraction new file mode 120000 index 0000000000..b352b73e46 --- /dev/null +++ b/Lang/C/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/C \ No newline at end of file diff --git a/Lang/C/Rate-counter b/Lang/C/Rate-counter new file mode 120000 index 0000000000..f05a5eea54 --- /dev/null +++ b/Lang/C/Rate-counter @@ -0,0 +1 @@ +../../Task/Rate-counter/C \ No newline at end of file diff --git a/Lang/C/Ray-casting-algorithm b/Lang/C/Ray-casting-algorithm new file mode 120000 index 0000000000..5a359ab93c --- /dev/null +++ b/Lang/C/Ray-casting-algorithm @@ -0,0 +1 @@ +../../Task/Ray-casting-algorithm/C \ No newline at end of file diff --git a/Lang/C/Read-a-file-line-by-line b/Lang/C/Read-a-file-line-by-line new file mode 120000 index 0000000000..be1c0c246d --- /dev/null +++ b/Lang/C/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/C \ No newline at end of file diff --git a/Lang/C/Read-a-specific-line-from-a-file b/Lang/C/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..6b137ae5e4 --- /dev/null +++ b/Lang/C/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/C \ No newline at end of file diff --git a/Lang/C/Read-entire-file b/Lang/C/Read-entire-file new file mode 120000 index 0000000000..b337c72f3d --- /dev/null +++ b/Lang/C/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/C \ No newline at end of file diff --git a/Lang/C/Real-constants-and-functions b/Lang/C/Real-constants-and-functions new file mode 120000 index 0000000000..f58a6884a9 --- /dev/null +++ b/Lang/C/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/C \ No newline at end of file diff --git a/Lang/C/Record-sound b/Lang/C/Record-sound new file mode 120000 index 0000000000..0c81d8bdcc --- /dev/null +++ b/Lang/C/Record-sound @@ -0,0 +1 @@ +../../Task/Record-sound/C \ No newline at end of file diff --git a/Lang/C/Reduced-row-echelon-form b/Lang/C/Reduced-row-echelon-form new file mode 120000 index 0000000000..6ddd3a0741 --- /dev/null +++ b/Lang/C/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/C \ No newline at end of file diff --git a/Lang/C/Regular-expressions b/Lang/C/Regular-expressions new file mode 120000 index 0000000000..58a2b89042 --- /dev/null +++ b/Lang/C/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/C \ No newline at end of file diff --git a/Lang/C/Remove-duplicate-elements b/Lang/C/Remove-duplicate-elements new file mode 120000 index 0000000000..6a8bfd3c18 --- /dev/null +++ b/Lang/C/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/C \ No newline at end of file diff --git a/Lang/C/Remove-lines-from-a-file b/Lang/C/Remove-lines-from-a-file new file mode 120000 index 0000000000..ed3acb2aa7 --- /dev/null +++ b/Lang/C/Remove-lines-from-a-file @@ -0,0 +1 @@ +../../Task/Remove-lines-from-a-file/C \ No newline at end of file diff --git a/Lang/C/Rename-a-file b/Lang/C/Rename-a-file new file mode 120000 index 0000000000..beca9f058c --- /dev/null +++ b/Lang/C/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/C \ No newline at end of file diff --git a/Lang/C/Rendezvous b/Lang/C/Rendezvous new file mode 120000 index 0000000000..88860d357a --- /dev/null +++ b/Lang/C/Rendezvous @@ -0,0 +1 @@ +../../Task/Rendezvous/C \ No newline at end of file diff --git a/Lang/C/Repeat-a-string b/Lang/C/Repeat-a-string new file mode 120000 index 0000000000..f74b4942ea --- /dev/null +++ b/Lang/C/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/C \ No newline at end of file diff --git a/Lang/C/Resistor-mesh b/Lang/C/Resistor-mesh new file mode 120000 index 0000000000..0219d7c6ed --- /dev/null +++ b/Lang/C/Resistor-mesh @@ -0,0 +1 @@ +../../Task/Resistor-mesh/C \ No newline at end of file diff --git a/Lang/C/Return-multiple-values b/Lang/C/Return-multiple-values new file mode 120000 index 0000000000..599bccc39d --- /dev/null +++ b/Lang/C/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/C \ No newline at end of file diff --git a/Lang/C/Reverse-a-string b/Lang/C/Reverse-a-string new file mode 120000 index 0000000000..2c6847db9e --- /dev/null +++ b/Lang/C/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/C \ No newline at end of file diff --git a/Lang/C/Rock-paper-scissors b/Lang/C/Rock-paper-scissors new file mode 120000 index 0000000000..0719225ea9 --- /dev/null +++ b/Lang/C/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/C \ No newline at end of file diff --git a/Lang/C/Roman-numerals-Decode b/Lang/C/Roman-numerals-Decode new file mode 120000 index 0000000000..783df6549b --- /dev/null +++ b/Lang/C/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/C \ No newline at end of file diff --git a/Lang/C/Roman-numerals-Encode b/Lang/C/Roman-numerals-Encode new file mode 120000 index 0000000000..9fe23f6358 --- /dev/null +++ b/Lang/C/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/C \ No newline at end of file diff --git a/Lang/C/Roots-of-a-function b/Lang/C/Roots-of-a-function new file mode 120000 index 0000000000..c27d8accc4 --- /dev/null +++ b/Lang/C/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/C \ No newline at end of file diff --git a/Lang/C/Roots-of-a-quadratic-function b/Lang/C/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..bf0bfa2766 --- /dev/null +++ b/Lang/C/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/C \ No newline at end of file diff --git a/Lang/C/Roots-of-unity b/Lang/C/Roots-of-unity new file mode 120000 index 0000000000..e4cf222f32 --- /dev/null +++ b/Lang/C/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/C \ No newline at end of file diff --git a/Lang/C/Rosetta-Code-Rank-languages-by-popularity b/Lang/C/Rosetta-Code-Rank-languages-by-popularity new file mode 120000 index 0000000000..51e3f632cf --- /dev/null +++ b/Lang/C/Rosetta-Code-Rank-languages-by-popularity @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-popularity/C \ No newline at end of file diff --git a/Lang/C/Rot-13 b/Lang/C/Rot-13 new file mode 120000 index 0000000000..387bcc3945 --- /dev/null +++ b/Lang/C/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/C \ No newline at end of file diff --git a/Lang/C/Run-length-encoding b/Lang/C/Run-length-encoding new file mode 120000 index 0000000000..f434b52f0e --- /dev/null +++ b/Lang/C/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/C \ No newline at end of file diff --git a/Lang/C/S-Expressions b/Lang/C/S-Expressions new file mode 120000 index 0000000000..aba050c661 --- /dev/null +++ b/Lang/C/S-Expressions @@ -0,0 +1 @@ +../../Task/S-Expressions/C \ No newline at end of file diff --git a/Lang/C/SEDOLs b/Lang/C/SEDOLs new file mode 120000 index 0000000000..c44dbd8434 --- /dev/null +++ b/Lang/C/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/C \ No newline at end of file diff --git a/Lang/C/Safe-addition b/Lang/C/Safe-addition new file mode 120000 index 0000000000..0e41e2203e --- /dev/null +++ b/Lang/C/Safe-addition @@ -0,0 +1 @@ +../../Task/Safe-addition/C \ No newline at end of file diff --git a/Lang/C/Same-Fringe b/Lang/C/Same-Fringe new file mode 120000 index 0000000000..20876461a1 --- /dev/null +++ b/Lang/C/Same-Fringe @@ -0,0 +1 @@ +../../Task/Same-Fringe/C \ No newline at end of file diff --git a/Lang/C/Scope-modifiers b/Lang/C/Scope-modifiers new file mode 120000 index 0000000000..d9a541266d --- /dev/null +++ b/Lang/C/Scope-modifiers @@ -0,0 +1 @@ +../../Task/Scope-modifiers/C \ No newline at end of file diff --git a/Lang/C/Secure-temporary-file b/Lang/C/Secure-temporary-file new file mode 120000 index 0000000000..e77b0e7b47 --- /dev/null +++ b/Lang/C/Secure-temporary-file @@ -0,0 +1 @@ +../../Task/Secure-temporary-file/C \ No newline at end of file diff --git a/Lang/C/Self-describing-numbers b/Lang/C/Self-describing-numbers new file mode 120000 index 0000000000..96a8cb7a96 --- /dev/null +++ b/Lang/C/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/C \ No newline at end of file diff --git a/Lang/C/Self-referential-sequence b/Lang/C/Self-referential-sequence new file mode 120000 index 0000000000..c53e6eb6fb --- /dev/null +++ b/Lang/C/Self-referential-sequence @@ -0,0 +1 @@ +../../Task/Self-referential-sequence/C \ No newline at end of file diff --git a/Lang/C/Semordnilap b/Lang/C/Semordnilap new file mode 120000 index 0000000000..f3458d850c --- /dev/null +++ b/Lang/C/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/C \ No newline at end of file diff --git a/Lang/C/Sequence-of-non-squares b/Lang/C/Sequence-of-non-squares new file mode 120000 index 0000000000..17bda2b2df --- /dev/null +++ b/Lang/C/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/C \ No newline at end of file diff --git a/Lang/C/Set b/Lang/C/Set new file mode 120000 index 0000000000..d2c78f9f33 --- /dev/null +++ b/Lang/C/Set @@ -0,0 +1 @@ +../../Task/Set/C \ No newline at end of file diff --git a/Lang/C/Set-consolidation b/Lang/C/Set-consolidation new file mode 120000 index 0000000000..ee42aa01e5 --- /dev/null +++ b/Lang/C/Set-consolidation @@ -0,0 +1 @@ +../../Task/Set-consolidation/C \ No newline at end of file diff --git a/Lang/CMake/Primality-by-trial-division b/Lang/CMake/Primality-by-trial-division new file mode 120000 index 0000000000..e4b66aaa6e --- /dev/null +++ b/Lang/CMake/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/CMake \ No newline at end of file diff --git a/Lang/CMake/Random-number-generator--included- b/Lang/CMake/Random-number-generator--included- new file mode 120000 index 0000000000..81a5af9dd3 --- /dev/null +++ b/Lang/CMake/Random-number-generator--included- @@ -0,0 +1 @@ +../../Task/Random-number-generator--included-/CMake \ No newline at end of file diff --git a/Lang/CMake/Read-entire-file b/Lang/CMake/Read-entire-file new file mode 120000 index 0000000000..36899b43e1 --- /dev/null +++ b/Lang/CMake/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/CMake \ No newline at end of file diff --git a/Lang/CMake/Return-multiple-values b/Lang/CMake/Return-multiple-values new file mode 120000 index 0000000000..5b14768de1 --- /dev/null +++ b/Lang/CMake/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/CMake \ No newline at end of file diff --git a/Lang/COBOL/Binary-digits b/Lang/COBOL/Binary-digits new file mode 120000 index 0000000000..7cfec1d54d --- /dev/null +++ b/Lang/COBOL/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/COBOL \ No newline at end of file diff --git a/Lang/COBOL/One-dimensional-cellular-automata b/Lang/COBOL/One-dimensional-cellular-automata new file mode 120000 index 0000000000..a766c55613 --- /dev/null +++ b/Lang/COBOL/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Primality-by-trial-division b/Lang/COBOL/Primality-by-trial-division new file mode 120000 index 0000000000..3595516589 --- /dev/null +++ b/Lang/COBOL/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/COBOL \ No newline at end of file diff --git a/Lang/COBOL/Reverse-a-string b/Lang/COBOL/Reverse-a-string new file mode 120000 index 0000000000..9c676cdd46 --- /dev/null +++ b/Lang/COBOL/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/COBOL \ No newline at end of file diff --git a/Lang/Cache-ObjectScript/Non-decimal-radices-Convert b/Lang/Cache-ObjectScript/Non-decimal-radices-Convert new file mode 120000 index 0000000000..1074d9540e --- /dev/null +++ b/Lang/Cache-ObjectScript/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/Cache-ObjectScript \ No newline at end of file diff --git a/Lang/Cache-ObjectScript/Rosetta-Code-Rank-languages-by-popularity b/Lang/Cache-ObjectScript/Rosetta-Code-Rank-languages-by-popularity new file mode 120000 index 0000000000..06bfcd3121 --- /dev/null +++ b/Lang/Cache-ObjectScript/Rosetta-Code-Rank-languages-by-popularity @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-popularity/Cache-ObjectScript \ No newline at end of file diff --git a/Lang/Clean/Parametric-polymorphism b/Lang/Clean/Parametric-polymorphism new file mode 120000 index 0000000000..ba5346c564 --- /dev/null +++ b/Lang/Clean/Parametric-polymorphism @@ -0,0 +1 @@ +../../Task/Parametric-polymorphism/Clean \ No newline at end of file diff --git a/Lang/Clipper/Price-fraction b/Lang/Clipper/Price-fraction new file mode 120000 index 0000000000..150cf9cfb9 --- /dev/null +++ b/Lang/Clipper/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Clipper \ No newline at end of file diff --git a/Lang/Clojure/Arbitrary-precision-integers--included- b/Lang/Clojure/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..16490bf815 --- /dev/null +++ b/Lang/Clojure/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Arbitrary-precision-integers-included b/Lang/Clojure/Arbitrary-precision-integers-included deleted file mode 120000 index d219fdc615..0000000000 --- a/Lang/Clojure/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Binary-digits b/Lang/Clojure/Binary-digits new file mode 120000 index 0000000000..b8fd55cc03 --- /dev/null +++ b/Lang/Clojure/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Catalan-numbers b/Lang/Clojure/Catalan-numbers new file mode 120000 index 0000000000..02383d2687 --- /dev/null +++ b/Lang/Clojure/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Copy-a-string b/Lang/Clojure/Copy-a-string new file mode 120000 index 0000000000..ebbcf4db75 --- /dev/null +++ b/Lang/Clojure/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Environment-variables b/Lang/Clojure/Environment-variables new file mode 120000 index 0000000000..92e021637b --- /dev/null +++ b/Lang/Clojure/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Guess-the-number-With-feedback--player- b/Lang/Clojure/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..3ff7c33b9e --- /dev/null +++ b/Lang/Clojure/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Guess-the-number-With-feedback-player b/Lang/Clojure/Guess-the-number-With-feedback-player deleted file mode 120000 index 4336a484b4..0000000000 --- a/Lang/Clojure/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/Clojure \ No newline at end of file diff --git a/Lang/Clojure/N-queens-problem b/Lang/Clojure/N-queens-problem new file mode 120000 index 0000000000..d4ca32d1f6 --- /dev/null +++ b/Lang/Clojure/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Named-parameters b/Lang/Clojure/Named-parameters new file mode 120000 index 0000000000..ddcb9b17b0 --- /dev/null +++ b/Lang/Clojure/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Non-continuous-subsequences b/Lang/Clojure/Non-continuous-subsequences new file mode 120000 index 0000000000..0f77f8ba73 --- /dev/null +++ b/Lang/Clojure/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Non-decimal-radices-Output b/Lang/Clojure/Non-decimal-radices-Output new file mode 120000 index 0000000000..4b373d665b --- /dev/null +++ b/Lang/Clojure/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Null-object b/Lang/Clojure/Null-object new file mode 120000 index 0000000000..5450430f09 --- /dev/null +++ b/Lang/Clojure/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Number-names b/Lang/Clojure/Number-names new file mode 120000 index 0000000000..2db3f0de61 --- /dev/null +++ b/Lang/Clojure/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Number-reversal-game b/Lang/Clojure/Number-reversal-game new file mode 120000 index 0000000000..6c8134fc6e --- /dev/null +++ b/Lang/Clojure/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/Clojure \ No newline at end of file diff --git a/Lang/Clojure/One-dimensional-cellular-automata b/Lang/Clojure/One-dimensional-cellular-automata new file mode 120000 index 0000000000..38db04a93c --- /dev/null +++ b/Lang/Clojure/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Clojure \ No newline at end of file diff --git a/Lang/Clojure/OpenGL b/Lang/Clojure/OpenGL new file mode 120000 index 0000000000..cc70ea216e --- /dev/null +++ b/Lang/Clojure/OpenGL @@ -0,0 +1 @@ +../../Task/OpenGL/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Optional-parameters b/Lang/Clojure/Optional-parameters new file mode 120000 index 0000000000..f7ace168d2 --- /dev/null +++ b/Lang/Clojure/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Palindrome-detection b/Lang/Clojure/Palindrome-detection new file mode 120000 index 0000000000..be22b04019 --- /dev/null +++ b/Lang/Clojure/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Pangram-checker b/Lang/Clojure/Pangram-checker new file mode 120000 index 0000000000..a979eb7dfb --- /dev/null +++ b/Lang/Clojure/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Parallel-calculations b/Lang/Clojure/Parallel-calculations new file mode 120000 index 0000000000..06c9129583 --- /dev/null +++ b/Lang/Clojure/Parallel-calculations @@ -0,0 +1 @@ +../../Task/Parallel-calculations/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Parsing-RPN-calculator-algorithm b/Lang/Clojure/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..065ac59356 --- /dev/null +++ b/Lang/Clojure/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Partial-function-application b/Lang/Clojure/Partial-function-application new file mode 120000 index 0000000000..393699bf20 --- /dev/null +++ b/Lang/Clojure/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Pascals-triangle b/Lang/Clojure/Pascals-triangle new file mode 120000 index 0000000000..ac6a496c39 --- /dev/null +++ b/Lang/Clojure/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Pascals-triangle-Puzzle b/Lang/Clojure/Pascals-triangle-Puzzle new file mode 120000 index 0000000000..4277b0b2ce --- /dev/null +++ b/Lang/Clojure/Pascals-triangle-Puzzle @@ -0,0 +1 @@ +../../Task/Pascals-triangle-Puzzle/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Perfect-numbers b/Lang/Clojure/Perfect-numbers new file mode 120000 index 0000000000..9613cdc05d --- /dev/null +++ b/Lang/Clojure/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Permutations b/Lang/Clojure/Permutations new file mode 120000 index 0000000000..83788054e8 --- /dev/null +++ b/Lang/Clojure/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Pick-random-element b/Lang/Clojure/Pick-random-element new file mode 120000 index 0000000000..c091d536f7 --- /dev/null +++ b/Lang/Clojure/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Playing-cards b/Lang/Clojure/Playing-cards new file mode 120000 index 0000000000..1567e4a160 --- /dev/null +++ b/Lang/Clojure/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Polymorphism b/Lang/Clojure/Polymorphism new file mode 120000 index 0000000000..fb577f3af8 --- /dev/null +++ b/Lang/Clojure/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Power-set b/Lang/Clojure/Power-set new file mode 120000 index 0000000000..b98d4cde36 --- /dev/null +++ b/Lang/Clojure/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Primality-by-trial-division b/Lang/Clojure/Primality-by-trial-division new file mode 120000 index 0000000000..a18411b71e --- /dev/null +++ b/Lang/Clojure/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Prime-decomposition b/Lang/Clojure/Prime-decomposition new file mode 120000 index 0000000000..d21c05edf7 --- /dev/null +++ b/Lang/Clojure/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Probabilistic-choice b/Lang/Clojure/Probabilistic-choice new file mode 120000 index 0000000000..9705cad905 --- /dev/null +++ b/Lang/Clojure/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Program-name b/Lang/Clojure/Program-name new file mode 120000 index 0000000000..31f467c266 --- /dev/null +++ b/Lang/Clojure/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Program-termination b/Lang/Clojure/Program-termination new file mode 120000 index 0000000000..5cee44a422 --- /dev/null +++ b/Lang/Clojure/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Queue-Definition b/Lang/Clojure/Queue-Definition new file mode 120000 index 0000000000..da0bb87210 --- /dev/null +++ b/Lang/Clojure/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Queue-Usage b/Lang/Clojure/Queue-Usage new file mode 120000 index 0000000000..91cf77e13c --- /dev/null +++ b/Lang/Clojure/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Random-numbers b/Lang/Clojure/Random-numbers new file mode 120000 index 0000000000..c79b0a7c64 --- /dev/null +++ b/Lang/Clojure/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Range-expansion b/Lang/Clojure/Range-expansion new file mode 120000 index 0000000000..963438df98 --- /dev/null +++ b/Lang/Clojure/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Read-a-file-line-by-line b/Lang/Clojure/Read-a-file-line-by-line new file mode 120000 index 0000000000..47b5ce0510 --- /dev/null +++ b/Lang/Clojure/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Read-entire-file b/Lang/Clojure/Read-entire-file new file mode 120000 index 0000000000..f34fea0ddc --- /dev/null +++ b/Lang/Clojure/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Real-constants-and-functions b/Lang/Clojure/Real-constants-and-functions new file mode 120000 index 0000000000..bbccc69fcf --- /dev/null +++ b/Lang/Clojure/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Regular-expressions b/Lang/Clojure/Regular-expressions new file mode 120000 index 0000000000..86cd0759b8 --- /dev/null +++ b/Lang/Clojure/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Remove-duplicate-elements b/Lang/Clojure/Remove-duplicate-elements new file mode 120000 index 0000000000..6fa8b670e8 --- /dev/null +++ b/Lang/Clojure/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Rename-a-file b/Lang/Clojure/Rename-a-file new file mode 120000 index 0000000000..07aa410d9b --- /dev/null +++ b/Lang/Clojure/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Repeat-a-string b/Lang/Clojure/Repeat-a-string new file mode 120000 index 0000000000..00c000fa48 --- /dev/null +++ b/Lang/Clojure/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Return-multiple-values b/Lang/Clojure/Return-multiple-values new file mode 120000 index 0000000000..2c4be510fa --- /dev/null +++ b/Lang/Clojure/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Reverse-a-string b/Lang/Clojure/Reverse-a-string new file mode 120000 index 0000000000..d3f175bff4 --- /dev/null +++ b/Lang/Clojure/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Roman-numerals-Decode b/Lang/Clojure/Roman-numerals-Decode new file mode 120000 index 0000000000..2fb15c18cd --- /dev/null +++ b/Lang/Clojure/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Roman-numerals-Encode b/Lang/Clojure/Roman-numerals-Encode new file mode 120000 index 0000000000..4dd66bc048 --- /dev/null +++ b/Lang/Clojure/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Roots-of-a-function b/Lang/Clojure/Roots-of-a-function new file mode 120000 index 0000000000..17acd31c24 --- /dev/null +++ b/Lang/Clojure/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Rosetta-Code-Count-examples b/Lang/Clojure/Rosetta-Code-Count-examples new file mode 120000 index 0000000000..cad7ce809d --- /dev/null +++ b/Lang/Clojure/Rosetta-Code-Count-examples @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Count-examples/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Rot-13 b/Lang/Clojure/Rot-13 new file mode 120000 index 0000000000..1337355da3 --- /dev/null +++ b/Lang/Clojure/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Run-length-encoding b/Lang/Clojure/Run-length-encoding new file mode 120000 index 0000000000..77c3c3f377 --- /dev/null +++ b/Lang/Clojure/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Secure-temporary-file b/Lang/Clojure/Secure-temporary-file new file mode 120000 index 0000000000..2e274a4816 --- /dev/null +++ b/Lang/Clojure/Secure-temporary-file @@ -0,0 +1 @@ +../../Task/Secure-temporary-file/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Sequence-of-non-squares b/Lang/Clojure/Sequence-of-non-squares new file mode 120000 index 0000000000..e211f89c6a --- /dev/null +++ b/Lang/Clojure/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Clojure \ No newline at end of file diff --git a/Lang/Clojure/Set b/Lang/Clojure/Set new file mode 120000 index 0000000000..238f2d8a4b --- /dev/null +++ b/Lang/Clojure/Set @@ -0,0 +1 @@ +../../Task/Set/Clojure \ No newline at end of file diff --git a/Lang/CoffeeScript/Binary-digits b/Lang/CoffeeScript/Binary-digits new file mode 120000 index 0000000000..fb776816d4 --- /dev/null +++ b/Lang/CoffeeScript/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Environment-variables b/Lang/CoffeeScript/Environment-variables new file mode 120000 index 0000000000..118beab5c2 --- /dev/null +++ b/Lang/CoffeeScript/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/N-queens-problem b/Lang/CoffeeScript/N-queens-problem new file mode 120000 index 0000000000..722fe2c93d --- /dev/null +++ b/Lang/CoffeeScript/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Non-continuous-subsequences b/Lang/CoffeeScript/Non-continuous-subsequences new file mode 120000 index 0000000000..03c3850c14 --- /dev/null +++ b/Lang/CoffeeScript/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Nth-root b/Lang/CoffeeScript/Nth-root new file mode 120000 index 0000000000..e0eee7aa0c --- /dev/null +++ b/Lang/CoffeeScript/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Number-names b/Lang/CoffeeScript/Number-names new file mode 120000 index 0000000000..b0c9560175 --- /dev/null +++ b/Lang/CoffeeScript/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Numerical-integration b/Lang/CoffeeScript/Numerical-integration new file mode 120000 index 0000000000..aa928cee85 --- /dev/null +++ b/Lang/CoffeeScript/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/One-dimensional-cellular-automata b/Lang/CoffeeScript/One-dimensional-cellular-automata new file mode 120000 index 0000000000..87a40b2f39 --- /dev/null +++ b/Lang/CoffeeScript/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Palindrome-detection b/Lang/CoffeeScript/Palindrome-detection new file mode 120000 index 0000000000..0859ecbb36 --- /dev/null +++ b/Lang/CoffeeScript/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Pangram-checker b/Lang/CoffeeScript/Pangram-checker new file mode 120000 index 0000000000..5c1052a4cb --- /dev/null +++ b/Lang/CoffeeScript/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Partial-function-application b/Lang/CoffeeScript/Partial-function-application new file mode 120000 index 0000000000..700bcf9644 --- /dev/null +++ b/Lang/CoffeeScript/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Pascals-triangle b/Lang/CoffeeScript/Pascals-triangle new file mode 120000 index 0000000000..5e07e4d117 --- /dev/null +++ b/Lang/CoffeeScript/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Perfect-numbers b/Lang/CoffeeScript/Perfect-numbers new file mode 120000 index 0000000000..fe5feadc4b --- /dev/null +++ b/Lang/CoffeeScript/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Permutations b/Lang/CoffeeScript/Permutations new file mode 120000 index 0000000000..36768476fc --- /dev/null +++ b/Lang/CoffeeScript/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Pick-random-element b/Lang/CoffeeScript/Pick-random-element new file mode 120000 index 0000000000..952b3925e4 --- /dev/null +++ b/Lang/CoffeeScript/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Power-set b/Lang/CoffeeScript/Power-set new file mode 120000 index 0000000000..c53817daa6 --- /dev/null +++ b/Lang/CoffeeScript/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Primality-by-trial-division b/Lang/CoffeeScript/Primality-by-trial-division new file mode 120000 index 0000000000..d2f7c65868 --- /dev/null +++ b/Lang/CoffeeScript/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Priority-queue b/Lang/CoffeeScript/Priority-queue new file mode 120000 index 0000000000..8c71f97ac6 --- /dev/null +++ b/Lang/CoffeeScript/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Problem-of-Apollonius b/Lang/CoffeeScript/Problem-of-Apollonius new file mode 120000 index 0000000000..71f5fc82a0 --- /dev/null +++ b/Lang/CoffeeScript/Problem-of-Apollonius @@ -0,0 +1 @@ +../../Task/Problem-of-Apollonius/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Pythagorean-triples b/Lang/CoffeeScript/Pythagorean-triples new file mode 120000 index 0000000000..1367183c61 --- /dev/null +++ b/Lang/CoffeeScript/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Queue-Definition b/Lang/CoffeeScript/Queue-Definition new file mode 120000 index 0000000000..5579727178 --- /dev/null +++ b/Lang/CoffeeScript/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Queue-Usage b/Lang/CoffeeScript/Queue-Usage new file mode 120000 index 0000000000..85b38d76d0 --- /dev/null +++ b/Lang/CoffeeScript/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Ray-casting-algorithm b/Lang/CoffeeScript/Ray-casting-algorithm new file mode 120000 index 0000000000..bdc9116d2a --- /dev/null +++ b/Lang/CoffeeScript/Ray-casting-algorithm @@ -0,0 +1 @@ +../../Task/Ray-casting-algorithm/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Read-a-file-line-by-line b/Lang/CoffeeScript/Read-a-file-line-by-line new file mode 120000 index 0000000000..2a684e610f --- /dev/null +++ b/Lang/CoffeeScript/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Reverse-a-string b/Lang/CoffeeScript/Reverse-a-string new file mode 120000 index 0000000000..780e79389e --- /dev/null +++ b/Lang/CoffeeScript/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Roman-numerals-Decode b/Lang/CoffeeScript/Roman-numerals-Decode new file mode 120000 index 0000000000..23d08cd7b3 --- /dev/null +++ b/Lang/CoffeeScript/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Roman-numerals-Encode b/Lang/CoffeeScript/Roman-numerals-Encode new file mode 120000 index 0000000000..e841fdb71b --- /dev/null +++ b/Lang/CoffeeScript/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Roots-of-a-function b/Lang/CoffeeScript/Roots-of-a-function new file mode 120000 index 0000000000..44ba9a4d61 --- /dev/null +++ b/Lang/CoffeeScript/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Roots-of-unity b/Lang/CoffeeScript/Roots-of-unity new file mode 120000 index 0000000000..af66ab2bc6 --- /dev/null +++ b/Lang/CoffeeScript/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Run-length-encoding b/Lang/CoffeeScript/Run-length-encoding new file mode 120000 index 0000000000..365fd6b8b3 --- /dev/null +++ b/Lang/CoffeeScript/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/S-Expressions b/Lang/CoffeeScript/S-Expressions new file mode 120000 index 0000000000..fc67b06581 --- /dev/null +++ b/Lang/CoffeeScript/S-Expressions @@ -0,0 +1 @@ +../../Task/S-Expressions/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Self-referential-sequence b/Lang/CoffeeScript/Self-referential-sequence new file mode 120000 index 0000000000..479153c164 --- /dev/null +++ b/Lang/CoffeeScript/Self-referential-sequence @@ -0,0 +1 @@ +../../Task/Self-referential-sequence/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Sequence-of-non-squares b/Lang/CoffeeScript/Sequence-of-non-squares new file mode 120000 index 0000000000..843bd8f03d --- /dev/null +++ b/Lang/CoffeeScript/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/CoffeeScript \ No newline at end of file diff --git a/Lang/CoffeeScript/Set b/Lang/CoffeeScript/Set new file mode 120000 index 0000000000..687fc10cf1 --- /dev/null +++ b/Lang/CoffeeScript/Set @@ -0,0 +1 @@ +../../Task/Set/CoffeeScript \ No newline at end of file diff --git a/Lang/ColdFusion/Copy-a-string b/Lang/ColdFusion/Copy-a-string new file mode 120000 index 0000000000..458846b864 --- /dev/null +++ b/Lang/ColdFusion/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/ColdFusion \ No newline at end of file diff --git a/Lang/ColdFusion/Power-set b/Lang/ColdFusion/Power-set new file mode 120000 index 0000000000..d0f7a4e6c3 --- /dev/null +++ b/Lang/ColdFusion/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/ColdFusion \ No newline at end of file diff --git a/Lang/ColdFusion/Reverse-a-string b/Lang/ColdFusion/Reverse-a-string new file mode 120000 index 0000000000..a1b6065a2b --- /dev/null +++ b/Lang/ColdFusion/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/ColdFusion \ 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..237bfddfb7 --- /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/Arbitrary-precision-integers-included b/Lang/Common-Lisp/Arbitrary-precision-integers-included deleted file mode 120000 index c00b9cf409..0000000000 --- a/Lang/Common-Lisp/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Binary-digits b/Lang/Common-Lisp/Binary-digits new file mode 120000 index 0000000000..4eefc14eab --- /dev/null +++ b/Lang/Common-Lisp/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Catalan-numbers b/Lang/Common-Lisp/Catalan-numbers new file mode 120000 index 0000000000..7666c4a58a --- /dev/null +++ b/Lang/Common-Lisp/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Copy-a-string b/Lang/Common-Lisp/Copy-a-string new file mode 120000 index 0000000000..8de65345e4 --- /dev/null +++ b/Lang/Common-Lisp/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Dragon-curve b/Lang/Common-Lisp/Dragon-curve new file mode 120000 index 0000000000..2fdb37a591 --- /dev/null +++ b/Lang/Common-Lisp/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Environment-variables b/Lang/Common-Lisp/Environment-variables new file mode 120000 index 0000000000..24c22ac60c --- /dev/null +++ b/Lang/Common-Lisp/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/N-queens-problem b/Lang/Common-Lisp/N-queens-problem new file mode 120000 index 0000000000..7dfb2ae7e9 --- /dev/null +++ b/Lang/Common-Lisp/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Named-parameters b/Lang/Common-Lisp/Named-parameters new file mode 120000 index 0000000000..1a64ca17b8 --- /dev/null +++ b/Lang/Common-Lisp/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Non-continuous-subsequences b/Lang/Common-Lisp/Non-continuous-subsequences new file mode 120000 index 0000000000..bf6267c484 --- /dev/null +++ b/Lang/Common-Lisp/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Non-decimal-radices-Convert b/Lang/Common-Lisp/Non-decimal-radices-Convert new file mode 120000 index 0000000000..c8d6209f5d --- /dev/null +++ b/Lang/Common-Lisp/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Non-decimal-radices-Input b/Lang/Common-Lisp/Non-decimal-radices-Input new file mode 120000 index 0000000000..2705d80403 --- /dev/null +++ b/Lang/Common-Lisp/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Non-decimal-radices-Output b/Lang/Common-Lisp/Non-decimal-radices-Output new file mode 120000 index 0000000000..8aed6ea4c9 --- /dev/null +++ b/Lang/Common-Lisp/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Nth-root b/Lang/Common-Lisp/Nth-root new file mode 120000 index 0000000000..e795a292f9 --- /dev/null +++ b/Lang/Common-Lisp/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Null-object b/Lang/Common-Lisp/Null-object new file mode 120000 index 0000000000..f42db5bf4a --- /dev/null +++ b/Lang/Common-Lisp/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Number-names b/Lang/Common-Lisp/Number-names new file mode 120000 index 0000000000..8d89fd9688 --- /dev/null +++ b/Lang/Common-Lisp/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Number-reversal-game b/Lang/Common-Lisp/Number-reversal-game new file mode 120000 index 0000000000..9ea45a0d05 --- /dev/null +++ b/Lang/Common-Lisp/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Numerical-integration b/Lang/Common-Lisp/Numerical-integration new file mode 120000 index 0000000000..0b6ee48924 --- /dev/null +++ b/Lang/Common-Lisp/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Numerical-integration-Gauss-Legendre-Quadrature b/Lang/Common-Lisp/Numerical-integration-Gauss-Legendre-Quadrature new file mode 120000 index 0000000000..4cbe7fa8be --- /dev/null +++ b/Lang/Common-Lisp/Numerical-integration-Gauss-Legendre-Quadrature @@ -0,0 +1 @@ +../../Task/Numerical-integration-Gauss-Legendre-Quadrature/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Object-serialization b/Lang/Common-Lisp/Object-serialization new file mode 120000 index 0000000000..2fc8a03fd2 --- /dev/null +++ b/Lang/Common-Lisp/Object-serialization @@ -0,0 +1 @@ +../../Task/Object-serialization/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/One-dimensional-cellular-automata b/Lang/Common-Lisp/One-dimensional-cellular-automata new file mode 120000 index 0000000000..a69e5b2122 --- /dev/null +++ b/Lang/Common-Lisp/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Optional-parameters b/Lang/Common-Lisp/Optional-parameters new file mode 120000 index 0000000000..81f8ad199b --- /dev/null +++ b/Lang/Common-Lisp/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Order-two-numerical-lists b/Lang/Common-Lisp/Order-two-numerical-lists new file mode 120000 index 0000000000..fc69ccd155 --- /dev/null +++ b/Lang/Common-Lisp/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Ordered-Partitions b/Lang/Common-Lisp/Ordered-Partitions new file mode 120000 index 0000000000..5874b7bfb2 --- /dev/null +++ b/Lang/Common-Lisp/Ordered-Partitions @@ -0,0 +1 @@ +../../Task/Ordered-Partitions/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Palindrome-detection b/Lang/Common-Lisp/Palindrome-detection new file mode 120000 index 0000000000..1d5a95a197 --- /dev/null +++ b/Lang/Common-Lisp/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Pangram-checker b/Lang/Common-Lisp/Pangram-checker new file mode 120000 index 0000000000..611593193d --- /dev/null +++ b/Lang/Common-Lisp/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Parametric-polymorphism b/Lang/Common-Lisp/Parametric-polymorphism new file mode 120000 index 0000000000..5af9c5edc1 --- /dev/null +++ b/Lang/Common-Lisp/Parametric-polymorphism @@ -0,0 +1 @@ +../../Task/Parametric-polymorphism/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Partial-function-application b/Lang/Common-Lisp/Partial-function-application new file mode 120000 index 0000000000..2d72c82acf --- /dev/null +++ b/Lang/Common-Lisp/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Pascals-triangle b/Lang/Common-Lisp/Pascals-triangle new file mode 120000 index 0000000000..66efca307d --- /dev/null +++ b/Lang/Common-Lisp/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Pattern-matching b/Lang/Common-Lisp/Pattern-matching new file mode 120000 index 0000000000..676da6b380 --- /dev/null +++ b/Lang/Common-Lisp/Pattern-matching @@ -0,0 +1 @@ +../../Task/Pattern-matching/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Percentage-difference-between-images b/Lang/Common-Lisp/Percentage-difference-between-images new file mode 120000 index 0000000000..aff1b36528 --- /dev/null +++ b/Lang/Common-Lisp/Percentage-difference-between-images @@ -0,0 +1 @@ +../../Task/Percentage-difference-between-images/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Perfect-numbers b/Lang/Common-Lisp/Perfect-numbers new file mode 120000 index 0000000000..46d98f4577 --- /dev/null +++ b/Lang/Common-Lisp/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Permutation-test b/Lang/Common-Lisp/Permutation-test new file mode 120000 index 0000000000..aaa95d4a03 --- /dev/null +++ b/Lang/Common-Lisp/Permutation-test @@ -0,0 +1 @@ +../../Task/Permutation-test/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Permutations b/Lang/Common-Lisp/Permutations new file mode 120000 index 0000000000..2a60cd0b83 --- /dev/null +++ b/Lang/Common-Lisp/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Pig-the-dice-game b/Lang/Common-Lisp/Pig-the-dice-game new file mode 120000 index 0000000000..1536d34952 --- /dev/null +++ b/Lang/Common-Lisp/Pig-the-dice-game @@ -0,0 +1 @@ +../../Task/Pig-the-dice-game/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Playing-cards b/Lang/Common-Lisp/Playing-cards new file mode 120000 index 0000000000..9b93bf93e4 --- /dev/null +++ b/Lang/Common-Lisp/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Polymorphic-copy b/Lang/Common-Lisp/Polymorphic-copy new file mode 120000 index 0000000000..b19bf50774 --- /dev/null +++ b/Lang/Common-Lisp/Polymorphic-copy @@ -0,0 +1 @@ +../../Task/Polymorphic-copy/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Polymorphism b/Lang/Common-Lisp/Polymorphism new file mode 120000 index 0000000000..989989f612 --- /dev/null +++ b/Lang/Common-Lisp/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Polynomial-long-division b/Lang/Common-Lisp/Polynomial-long-division new file mode 120000 index 0000000000..e71d469861 --- /dev/null +++ b/Lang/Common-Lisp/Polynomial-long-division @@ -0,0 +1 @@ +../../Task/Polynomial-long-division/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Polynomial-regression b/Lang/Common-Lisp/Polynomial-regression new file mode 120000 index 0000000000..688a322ed2 --- /dev/null +++ b/Lang/Common-Lisp/Polynomial-regression @@ -0,0 +1 @@ +../../Task/Polynomial-regression/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Power-set b/Lang/Common-Lisp/Power-set new file mode 120000 index 0000000000..bc85ec1b54 --- /dev/null +++ b/Lang/Common-Lisp/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Primality-by-trial-division b/Lang/Common-Lisp/Primality-by-trial-division new file mode 120000 index 0000000000..070ad5fc17 --- /dev/null +++ b/Lang/Common-Lisp/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Prime-decomposition b/Lang/Common-Lisp/Prime-decomposition new file mode 120000 index 0000000000..64746725b7 --- /dev/null +++ b/Lang/Common-Lisp/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Probabilistic-choice b/Lang/Common-Lisp/Probabilistic-choice new file mode 120000 index 0000000000..d192e22abc --- /dev/null +++ b/Lang/Common-Lisp/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Program-name b/Lang/Common-Lisp/Program-name new file mode 120000 index 0000000000..ced983dfcc --- /dev/null +++ b/Lang/Common-Lisp/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Program-termination b/Lang/Common-Lisp/Program-termination new file mode 120000 index 0000000000..c7477bb58d --- /dev/null +++ b/Lang/Common-Lisp/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Pythagorean-triples b/Lang/Common-Lisp/Pythagorean-triples new file mode 120000 index 0000000000..0d60ca8a3d --- /dev/null +++ b/Lang/Common-Lisp/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/QR-decomposition b/Lang/Common-Lisp/QR-decomposition new file mode 120000 index 0000000000..c98abfb989 --- /dev/null +++ b/Lang/Common-Lisp/QR-decomposition @@ -0,0 +1 @@ +../../Task/QR-decomposition/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Queue-Definition b/Lang/Common-Lisp/Queue-Definition new file mode 120000 index 0000000000..1430a5146a --- /dev/null +++ b/Lang/Common-Lisp/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Queue-Usage b/Lang/Common-Lisp/Queue-Usage new file mode 120000 index 0000000000..163ad5e095 --- /dev/null +++ b/Lang/Common-Lisp/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Random-numbers b/Lang/Common-Lisp/Random-numbers new file mode 120000 index 0000000000..41ef49736c --- /dev/null +++ b/Lang/Common-Lisp/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Range-expansion b/Lang/Common-Lisp/Range-expansion new file mode 120000 index 0000000000..7515794887 --- /dev/null +++ b/Lang/Common-Lisp/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Range-extraction b/Lang/Common-Lisp/Range-extraction new file mode 120000 index 0000000000..7420286ff1 --- /dev/null +++ b/Lang/Common-Lisp/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Rate-counter b/Lang/Common-Lisp/Rate-counter new file mode 120000 index 0000000000..78750d933e --- /dev/null +++ b/Lang/Common-Lisp/Rate-counter @@ -0,0 +1 @@ +../../Task/Rate-counter/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Ray-casting-algorithm b/Lang/Common-Lisp/Ray-casting-algorithm new file mode 120000 index 0000000000..171fcbbd69 --- /dev/null +++ b/Lang/Common-Lisp/Ray-casting-algorithm @@ -0,0 +1 @@ +../../Task/Ray-casting-algorithm/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Read-a-file-line-by-line b/Lang/Common-Lisp/Read-a-file-line-by-line new file mode 120000 index 0000000000..d909b90caf --- /dev/null +++ b/Lang/Common-Lisp/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Read-a-specific-line-from-a-file b/Lang/Common-Lisp/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..87eeef2863 --- /dev/null +++ b/Lang/Common-Lisp/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Read-entire-file b/Lang/Common-Lisp/Read-entire-file new file mode 120000 index 0000000000..fe0e90ccce --- /dev/null +++ b/Lang/Common-Lisp/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Real-constants-and-functions b/Lang/Common-Lisp/Real-constants-and-functions new file mode 120000 index 0000000000..74e244ef11 --- /dev/null +++ b/Lang/Common-Lisp/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Reduced-row-echelon-form b/Lang/Common-Lisp/Reduced-row-echelon-form new file mode 120000 index 0000000000..88b82d89d4 --- /dev/null +++ b/Lang/Common-Lisp/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Regular-expressions b/Lang/Common-Lisp/Regular-expressions new file mode 120000 index 0000000000..04bda99cd0 --- /dev/null +++ b/Lang/Common-Lisp/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Remove-duplicate-elements b/Lang/Common-Lisp/Remove-duplicate-elements new file mode 120000 index 0000000000..a1d84195b8 --- /dev/null +++ b/Lang/Common-Lisp/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Remove-lines-from-a-file b/Lang/Common-Lisp/Remove-lines-from-a-file new file mode 120000 index 0000000000..bef85c8efc --- /dev/null +++ b/Lang/Common-Lisp/Remove-lines-from-a-file @@ -0,0 +1 @@ +../../Task/Remove-lines-from-a-file/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Rename-a-file b/Lang/Common-Lisp/Rename-a-file new file mode 120000 index 0000000000..b00a7ce2c6 --- /dev/null +++ b/Lang/Common-Lisp/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Repeat-a-string b/Lang/Common-Lisp/Repeat-a-string new file mode 120000 index 0000000000..7de10ce508 --- /dev/null +++ b/Lang/Common-Lisp/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Respond-to-an-unknown-method-call b/Lang/Common-Lisp/Respond-to-an-unknown-method-call new file mode 120000 index 0000000000..07eef7bbf6 --- /dev/null +++ b/Lang/Common-Lisp/Respond-to-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Respond-to-an-unknown-method-call/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Return-multiple-values b/Lang/Common-Lisp/Return-multiple-values new file mode 120000 index 0000000000..972128f9b3 --- /dev/null +++ b/Lang/Common-Lisp/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Reverse-a-string b/Lang/Common-Lisp/Reverse-a-string new file mode 120000 index 0000000000..abcba4d9e7 --- /dev/null +++ b/Lang/Common-Lisp/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Roman-numerals-Decode b/Lang/Common-Lisp/Roman-numerals-Decode new file mode 120000 index 0000000000..db59bab999 --- /dev/null +++ b/Lang/Common-Lisp/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Roman-numerals-Encode b/Lang/Common-Lisp/Roman-numerals-Encode new file mode 120000 index 0000000000..81b18da8d8 --- /dev/null +++ b/Lang/Common-Lisp/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Roots-of-a-function b/Lang/Common-Lisp/Roots-of-a-function new file mode 120000 index 0000000000..c7dea6e803 --- /dev/null +++ b/Lang/Common-Lisp/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Roots-of-a-quadratic-function b/Lang/Common-Lisp/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..95cb146fd3 --- /dev/null +++ b/Lang/Common-Lisp/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Roots-of-unity b/Lang/Common-Lisp/Roots-of-unity new file mode 120000 index 0000000000..85491ac55b --- /dev/null +++ b/Lang/Common-Lisp/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Rot-13 b/Lang/Common-Lisp/Rot-13 new file mode 120000 index 0000000000..ad7cd240c4 --- /dev/null +++ b/Lang/Common-Lisp/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Run-length-encoding b/Lang/Common-Lisp/Run-length-encoding new file mode 120000 index 0000000000..bf3192eee3 --- /dev/null +++ b/Lang/Common-Lisp/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Runtime-evaluation b/Lang/Common-Lisp/Runtime-evaluation new file mode 120000 index 0000000000..53392ac7b2 --- /dev/null +++ b/Lang/Common-Lisp/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Runtime-evaluation-In-an-environment b/Lang/Common-Lisp/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..36745187fa --- /dev/null +++ b/Lang/Common-Lisp/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/S-Expressions b/Lang/Common-Lisp/S-Expressions new file mode 120000 index 0000000000..5bf0d253be --- /dev/null +++ b/Lang/Common-Lisp/S-Expressions @@ -0,0 +1 @@ +../../Task/S-Expressions/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/SEDOLs b/Lang/Common-Lisp/SEDOLs new file mode 120000 index 0000000000..34aef57aa7 --- /dev/null +++ b/Lang/Common-Lisp/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Scope-modifiers b/Lang/Common-Lisp/Scope-modifiers new file mode 120000 index 0000000000..9322a0d459 --- /dev/null +++ b/Lang/Common-Lisp/Scope-modifiers @@ -0,0 +1 @@ +../../Task/Scope-modifiers/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Self-referential-sequence b/Lang/Common-Lisp/Self-referential-sequence new file mode 120000 index 0000000000..e9d81a6c69 --- /dev/null +++ b/Lang/Common-Lisp/Self-referential-sequence @@ -0,0 +1 @@ +../../Task/Self-referential-sequence/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Sequence-of-non-squares b/Lang/Common-Lisp/Sequence-of-non-squares new file mode 120000 index 0000000000..30e212b39d --- /dev/null +++ b/Lang/Common-Lisp/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Common-Lisp \ No newline at end of file diff --git a/Lang/Common-Lisp/Set b/Lang/Common-Lisp/Set new file mode 120000 index 0000000000..317ae8b293 --- /dev/null +++ b/Lang/Common-Lisp/Set @@ -0,0 +1 @@ +../../Task/Set/Common-Lisp \ No newline at end of file diff --git a/Lang/Component-Pascal/Null-object b/Lang/Component-Pascal/Null-object new file mode 120000 index 0000000000..6408b516dd --- /dev/null +++ b/Lang/Component-Pascal/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Component-Pascal \ No newline at end of file diff --git a/Lang/Curry/N-queens-problem b/Lang/Curry/N-queens-problem new file mode 120000 index 0000000000..99bbab08c7 --- /dev/null +++ b/Lang/Curry/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Curry \ 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..64743471b8 --- /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/Arbitrary-precision-integers-included b/Lang/D/Arbitrary-precision-integers-included deleted file mode 120000 index cb46f2eae2..0000000000 --- a/Lang/D/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/D \ No newline at end of file diff --git a/Lang/D/Binary-digits b/Lang/D/Binary-digits new file mode 120000 index 0000000000..24c3192c83 --- /dev/null +++ b/Lang/D/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/D \ No newline at end of file diff --git a/Lang/D/Brownian-tree b/Lang/D/Brownian-tree new file mode 120000 index 0000000000..97e433d17b --- /dev/null +++ b/Lang/D/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/D \ No newline at end of file diff --git a/Lang/D/Catalan-numbers b/Lang/D/Catalan-numbers new file mode 120000 index 0000000000..9ad0253800 --- /dev/null +++ b/Lang/D/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/D \ No newline at end of file diff --git a/Lang/D/Copy-a-string b/Lang/D/Copy-a-string new file mode 120000 index 0000000000..7445f561b4 --- /dev/null +++ b/Lang/D/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/D \ No newline at end of file diff --git a/Lang/D/Dragon-curve b/Lang/D/Dragon-curve new file mode 120000 index 0000000000..59a1bb2b71 --- /dev/null +++ b/Lang/D/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/D \ No newline at end of file diff --git a/Lang/D/Environment-variables b/Lang/D/Environment-variables new file mode 120000 index 0000000000..6cb3494f35 --- /dev/null +++ b/Lang/D/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/D \ No newline at end of file diff --git a/Lang/D/Execute-a-Markov-algorithm b/Lang/D/Execute-a-Markov-algorithm new file mode 120000 index 0000000000..ddf8825a21 --- /dev/null +++ b/Lang/D/Execute-a-Markov-algorithm @@ -0,0 +1 @@ +../../Task/Execute-a-Markov-algorithm/D \ No newline at end of file diff --git a/Lang/D/Guess-the-number-With-feedback--player- b/Lang/D/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..696b162806 --- /dev/null +++ b/Lang/D/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/D \ No newline at end of file diff --git a/Lang/D/Guess-the-number-With-feedback-player b/Lang/D/Guess-the-number-With-feedback-player deleted file mode 120000 index 2b6db6ea5b..0000000000 --- a/Lang/D/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/D \ No newline at end of file diff --git a/Lang/D/N-queens-problem b/Lang/D/N-queens-problem new file mode 120000 index 0000000000..b56fd7e221 --- /dev/null +++ b/Lang/D/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/D \ No newline at end of file diff --git a/Lang/D/Nautical-bell b/Lang/D/Nautical-bell new file mode 120000 index 0000000000..9efaa0f0f8 --- /dev/null +++ b/Lang/D/Nautical-bell @@ -0,0 +1 @@ +../../Task/Nautical-bell/D \ No newline at end of file diff --git a/Lang/D/Non-continuous-subsequences b/Lang/D/Non-continuous-subsequences new file mode 120000 index 0000000000..a77ccbc43e --- /dev/null +++ b/Lang/D/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/D \ No newline at end of file diff --git a/Lang/D/Non-decimal-radices-Convert b/Lang/D/Non-decimal-radices-Convert new file mode 120000 index 0000000000..5e4252efc8 --- /dev/null +++ b/Lang/D/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/D \ No newline at end of file diff --git a/Lang/D/Non-decimal-radices-Input b/Lang/D/Non-decimal-radices-Input new file mode 120000 index 0000000000..61eb592709 --- /dev/null +++ b/Lang/D/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/D \ No newline at end of file diff --git a/Lang/D/Non-decimal-radices-Output b/Lang/D/Non-decimal-radices-Output new file mode 120000 index 0000000000..04cc58ba49 --- /dev/null +++ b/Lang/D/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/D \ No newline at end of file diff --git a/Lang/D/Nth-root b/Lang/D/Nth-root new file mode 120000 index 0000000000..42940be18f --- /dev/null +++ b/Lang/D/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/D \ No newline at end of file diff --git a/Lang/D/Null-object b/Lang/D/Null-object new file mode 120000 index 0000000000..4dc41d2c96 --- /dev/null +++ b/Lang/D/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/D \ No newline at end of file diff --git a/Lang/D/Number-names b/Lang/D/Number-names new file mode 120000 index 0000000000..6048541f4a --- /dev/null +++ b/Lang/D/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/D \ No newline at end of file diff --git a/Lang/D/Number-reversal-game b/Lang/D/Number-reversal-game new file mode 120000 index 0000000000..7acb6c699e --- /dev/null +++ b/Lang/D/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/D \ No newline at end of file diff --git a/Lang/D/Numeric-error-propagation b/Lang/D/Numeric-error-propagation new file mode 120000 index 0000000000..7d9436049a --- /dev/null +++ b/Lang/D/Numeric-error-propagation @@ -0,0 +1 @@ +../../Task/Numeric-error-propagation/D \ No newline at end of file diff --git a/Lang/D/Numerical-integration b/Lang/D/Numerical-integration new file mode 120000 index 0000000000..f6db75a6de --- /dev/null +++ b/Lang/D/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/D \ No newline at end of file diff --git a/Lang/D/Numerical-integration-Gauss-Legendre-Quadrature b/Lang/D/Numerical-integration-Gauss-Legendre-Quadrature new file mode 120000 index 0000000000..d19af6e59d --- /dev/null +++ b/Lang/D/Numerical-integration-Gauss-Legendre-Quadrature @@ -0,0 +1 @@ +../../Task/Numerical-integration-Gauss-Legendre-Quadrature/D \ No newline at end of file diff --git a/Lang/D/Object-serialization b/Lang/D/Object-serialization new file mode 120000 index 0000000000..6e045f3cf3 --- /dev/null +++ b/Lang/D/Object-serialization @@ -0,0 +1 @@ +../../Task/Object-serialization/D \ No newline at end of file diff --git a/Lang/D/One-dimensional-cellular-automata b/Lang/D/One-dimensional-cellular-automata new file mode 120000 index 0000000000..524134dbe1 --- /dev/null +++ b/Lang/D/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/D \ No newline at end of file diff --git a/Lang/D/One-of-n-lines-in-a-file b/Lang/D/One-of-n-lines-in-a-file new file mode 120000 index 0000000000..678ee54e3c --- /dev/null +++ b/Lang/D/One-of-n-lines-in-a-file @@ -0,0 +1 @@ +../../Task/One-of-n-lines-in-a-file/D \ No newline at end of file diff --git a/Lang/D/OpenGL b/Lang/D/OpenGL new file mode 120000 index 0000000000..2efbd160e1 --- /dev/null +++ b/Lang/D/OpenGL @@ -0,0 +1 @@ +../../Task/OpenGL/D \ No newline at end of file diff --git a/Lang/D/Optional-parameters b/Lang/D/Optional-parameters new file mode 120000 index 0000000000..606ff6a1b2 --- /dev/null +++ b/Lang/D/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/D \ No newline at end of file diff --git a/Lang/D/Order-two-numerical-lists b/Lang/D/Order-two-numerical-lists new file mode 120000 index 0000000000..acfb4d1f5d --- /dev/null +++ b/Lang/D/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/D \ No newline at end of file diff --git a/Lang/D/Ordered-Partitions b/Lang/D/Ordered-Partitions new file mode 120000 index 0000000000..c51ba88279 --- /dev/null +++ b/Lang/D/Ordered-Partitions @@ -0,0 +1 @@ +../../Task/Ordered-Partitions/D \ No newline at end of file diff --git a/Lang/D/Palindrome-detection b/Lang/D/Palindrome-detection new file mode 120000 index 0000000000..158d6e3202 --- /dev/null +++ b/Lang/D/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/D \ No newline at end of file diff --git a/Lang/D/Pangram-checker b/Lang/D/Pangram-checker new file mode 120000 index 0000000000..39151d54b6 --- /dev/null +++ b/Lang/D/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/D \ No newline at end of file diff --git a/Lang/D/Parallel-calculations b/Lang/D/Parallel-calculations new file mode 120000 index 0000000000..41b28cd425 --- /dev/null +++ b/Lang/D/Parallel-calculations @@ -0,0 +1 @@ +../../Task/Parallel-calculations/D \ No newline at end of file diff --git a/Lang/D/Parametric-polymorphism b/Lang/D/Parametric-polymorphism new file mode 120000 index 0000000000..c6a6174655 --- /dev/null +++ b/Lang/D/Parametric-polymorphism @@ -0,0 +1 @@ +../../Task/Parametric-polymorphism/D \ No newline at end of file diff --git a/Lang/D/Parsing-RPN-calculator-algorithm b/Lang/D/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..48adc8a3e2 --- /dev/null +++ b/Lang/D/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/D \ No newline at end of file diff --git a/Lang/D/Parsing-RPN-to-infix-conversion b/Lang/D/Parsing-RPN-to-infix-conversion new file mode 120000 index 0000000000..fcd0d42b1d --- /dev/null +++ b/Lang/D/Parsing-RPN-to-infix-conversion @@ -0,0 +1 @@ +../../Task/Parsing-RPN-to-infix-conversion/D \ No newline at end of file diff --git a/Lang/D/Partial-function-application b/Lang/D/Partial-function-application new file mode 120000 index 0000000000..5d16fd90ab --- /dev/null +++ b/Lang/D/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/D \ No newline at end of file diff --git a/Lang/D/Pascals-triangle b/Lang/D/Pascals-triangle new file mode 120000 index 0000000000..6474061817 --- /dev/null +++ b/Lang/D/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/D \ No newline at end of file diff --git a/Lang/D/Pascals-triangle-Puzzle b/Lang/D/Pascals-triangle-Puzzle new file mode 120000 index 0000000000..f1e095cfaf --- /dev/null +++ b/Lang/D/Pascals-triangle-Puzzle @@ -0,0 +1 @@ +../../Task/Pascals-triangle-Puzzle/D \ No newline at end of file diff --git a/Lang/D/Percentage-difference-between-images b/Lang/D/Percentage-difference-between-images new file mode 120000 index 0000000000..74b984ff00 --- /dev/null +++ b/Lang/D/Percentage-difference-between-images @@ -0,0 +1 @@ +../../Task/Percentage-difference-between-images/D \ No newline at end of file diff --git a/Lang/D/Perfect-numbers b/Lang/D/Perfect-numbers new file mode 120000 index 0000000000..d8d42b4274 --- /dev/null +++ b/Lang/D/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/D \ No newline at end of file diff --git a/Lang/D/Permutation-test b/Lang/D/Permutation-test new file mode 120000 index 0000000000..f53d0e8e84 --- /dev/null +++ b/Lang/D/Permutation-test @@ -0,0 +1 @@ +../../Task/Permutation-test/D \ No newline at end of file diff --git a/Lang/D/Permutations b/Lang/D/Permutations new file mode 120000 index 0000000000..8c892ddcdf --- /dev/null +++ b/Lang/D/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/D \ No newline at end of file diff --git a/Lang/D/Permutations-Derangements b/Lang/D/Permutations-Derangements new file mode 120000 index 0000000000..debdffaf2e --- /dev/null +++ b/Lang/D/Permutations-Derangements @@ -0,0 +1 @@ +../../Task/Permutations-Derangements/D \ No newline at end of file diff --git a/Lang/D/Permutations-by-swapping b/Lang/D/Permutations-by-swapping new file mode 120000 index 0000000000..857de516e5 --- /dev/null +++ b/Lang/D/Permutations-by-swapping @@ -0,0 +1 @@ +../../Task/Permutations-by-swapping/D \ No newline at end of file diff --git a/Lang/D/Pick-random-element b/Lang/D/Pick-random-element new file mode 120000 index 0000000000..3059f82418 --- /dev/null +++ b/Lang/D/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/D \ No newline at end of file diff --git a/Lang/D/Pig-the-dice-game b/Lang/D/Pig-the-dice-game new file mode 120000 index 0000000000..a4c1a812e5 --- /dev/null +++ b/Lang/D/Pig-the-dice-game @@ -0,0 +1 @@ +../../Task/Pig-the-dice-game/D \ No newline at end of file diff --git a/Lang/D/Playing-cards b/Lang/D/Playing-cards new file mode 120000 index 0000000000..85df4b5899 --- /dev/null +++ b/Lang/D/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/D \ No newline at end of file diff --git a/Lang/D/Pointers-and-references b/Lang/D/Pointers-and-references new file mode 120000 index 0000000000..e63448b0f5 --- /dev/null +++ b/Lang/D/Pointers-and-references @@ -0,0 +1 @@ +../../Task/Pointers-and-references/D \ No newline at end of file diff --git a/Lang/D/Polymorphic-copy b/Lang/D/Polymorphic-copy new file mode 120000 index 0000000000..3129e6b4f6 --- /dev/null +++ b/Lang/D/Polymorphic-copy @@ -0,0 +1 @@ +../../Task/Polymorphic-copy/D \ No newline at end of file diff --git a/Lang/D/Polymorphism b/Lang/D/Polymorphism new file mode 120000 index 0000000000..b92b3acb0a --- /dev/null +++ b/Lang/D/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/D \ No newline at end of file diff --git a/Lang/D/Polynomial-long-division b/Lang/D/Polynomial-long-division new file mode 120000 index 0000000000..3f29d4d793 --- /dev/null +++ b/Lang/D/Polynomial-long-division @@ -0,0 +1 @@ +../../Task/Polynomial-long-division/D \ No newline at end of file diff --git a/Lang/D/Power-set b/Lang/D/Power-set new file mode 120000 index 0000000000..d424b05fde --- /dev/null +++ b/Lang/D/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/D \ No newline at end of file diff --git a/Lang/D/Price-fraction b/Lang/D/Price-fraction new file mode 120000 index 0000000000..cc84a74074 --- /dev/null +++ b/Lang/D/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/D \ No newline at end of file diff --git a/Lang/D/Primality-by-trial-division b/Lang/D/Primality-by-trial-division new file mode 120000 index 0000000000..5a353f5e26 --- /dev/null +++ b/Lang/D/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/D \ No newline at end of file diff --git a/Lang/D/Prime-decomposition b/Lang/D/Prime-decomposition new file mode 120000 index 0000000000..ec48d9c3e8 --- /dev/null +++ b/Lang/D/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/D \ No newline at end of file diff --git a/Lang/D/Priority-queue b/Lang/D/Priority-queue new file mode 120000 index 0000000000..3349b4a529 --- /dev/null +++ b/Lang/D/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/D \ No newline at end of file diff --git a/Lang/D/Probabilistic-choice b/Lang/D/Probabilistic-choice new file mode 120000 index 0000000000..8e8b2a41e6 --- /dev/null +++ b/Lang/D/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/D \ No newline at end of file diff --git a/Lang/D/Problem-of-Apollonius b/Lang/D/Problem-of-Apollonius new file mode 120000 index 0000000000..1fe441077b --- /dev/null +++ b/Lang/D/Problem-of-Apollonius @@ -0,0 +1 @@ +../../Task/Problem-of-Apollonius/D \ No newline at end of file diff --git a/Lang/D/Program-name b/Lang/D/Program-name new file mode 120000 index 0000000000..78ec43cc6f --- /dev/null +++ b/Lang/D/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/D \ No newline at end of file diff --git a/Lang/D/Pythagorean-triples b/Lang/D/Pythagorean-triples new file mode 120000 index 0000000000..149effd30a --- /dev/null +++ b/Lang/D/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/D \ No newline at end of file diff --git a/Lang/D/QR-decomposition b/Lang/D/QR-decomposition new file mode 120000 index 0000000000..f710f1c8b8 --- /dev/null +++ b/Lang/D/QR-decomposition @@ -0,0 +1 @@ +../../Task/QR-decomposition/D \ No newline at end of file diff --git a/Lang/D/Quaternion-type b/Lang/D/Quaternion-type new file mode 120000 index 0000000000..4703070a3f --- /dev/null +++ b/Lang/D/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/D \ No newline at end of file diff --git a/Lang/D/Queue-Usage b/Lang/D/Queue-Usage new file mode 120000 index 0000000000..c1bcea11ea --- /dev/null +++ b/Lang/D/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/D \ No newline at end of file diff --git a/Lang/D/RIPEMD-160 b/Lang/D/RIPEMD-160 new file mode 120000 index 0000000000..c7472267ac --- /dev/null +++ b/Lang/D/RIPEMD-160 @@ -0,0 +1 @@ +../../Task/RIPEMD-160/D \ No newline at end of file diff --git a/Lang/D/Random-numbers b/Lang/D/Random-numbers new file mode 120000 index 0000000000..5be9cc8963 --- /dev/null +++ b/Lang/D/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/D \ No newline at end of file diff --git a/Lang/D/Range-expansion b/Lang/D/Range-expansion new file mode 120000 index 0000000000..452492b8fb --- /dev/null +++ b/Lang/D/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/D \ No newline at end of file diff --git a/Lang/D/Range-extraction b/Lang/D/Range-extraction new file mode 120000 index 0000000000..33a6804ad7 --- /dev/null +++ b/Lang/D/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/D \ No newline at end of file diff --git a/Lang/D/Ray-casting-algorithm b/Lang/D/Ray-casting-algorithm new file mode 120000 index 0000000000..df09da36fd --- /dev/null +++ b/Lang/D/Ray-casting-algorithm @@ -0,0 +1 @@ +../../Task/Ray-casting-algorithm/D \ No newline at end of file diff --git a/Lang/D/Read-a-configuration-file b/Lang/D/Read-a-configuration-file new file mode 120000 index 0000000000..2ebfec2a58 --- /dev/null +++ b/Lang/D/Read-a-configuration-file @@ -0,0 +1 @@ +../../Task/Read-a-configuration-file/D \ No newline at end of file diff --git a/Lang/D/Read-a-file-line-by-line b/Lang/D/Read-a-file-line-by-line new file mode 120000 index 0000000000..bb285e515f --- /dev/null +++ b/Lang/D/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/D \ No newline at end of file diff --git a/Lang/D/Read-a-specific-line-from-a-file b/Lang/D/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..2680bd9d5e --- /dev/null +++ b/Lang/D/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/D \ No newline at end of file diff --git a/Lang/D/Read-entire-file b/Lang/D/Read-entire-file new file mode 120000 index 0000000000..7bc481ddfa --- /dev/null +++ b/Lang/D/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/D \ No newline at end of file diff --git a/Lang/D/Real-constants-and-functions b/Lang/D/Real-constants-and-functions new file mode 120000 index 0000000000..18c57ba11b --- /dev/null +++ b/Lang/D/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/D \ No newline at end of file diff --git a/Lang/D/Reduced-row-echelon-form b/Lang/D/Reduced-row-echelon-form new file mode 120000 index 0000000000..a43d76c31b --- /dev/null +++ b/Lang/D/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/D \ No newline at end of file diff --git a/Lang/D/Regular-expressions b/Lang/D/Regular-expressions new file mode 120000 index 0000000000..b4a3b7dedd --- /dev/null +++ b/Lang/D/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/D \ No newline at end of file diff --git a/Lang/D/Remove-duplicate-elements b/Lang/D/Remove-duplicate-elements new file mode 120000 index 0000000000..ad0a77f4f8 --- /dev/null +++ b/Lang/D/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/D \ No newline at end of file diff --git a/Lang/D/Remove-lines-from-a-file b/Lang/D/Remove-lines-from-a-file new file mode 120000 index 0000000000..d712f77628 --- /dev/null +++ b/Lang/D/Remove-lines-from-a-file @@ -0,0 +1 @@ +../../Task/Remove-lines-from-a-file/D \ No newline at end of file diff --git a/Lang/D/Rename-a-file b/Lang/D/Rename-a-file new file mode 120000 index 0000000000..31c91b8277 --- /dev/null +++ b/Lang/D/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/D \ No newline at end of file diff --git a/Lang/D/Repeat-a-string b/Lang/D/Repeat-a-string new file mode 120000 index 0000000000..77569cfda7 --- /dev/null +++ b/Lang/D/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/D \ No newline at end of file diff --git a/Lang/D/Resistor-mesh b/Lang/D/Resistor-mesh new file mode 120000 index 0000000000..3585faaffb --- /dev/null +++ b/Lang/D/Resistor-mesh @@ -0,0 +1 @@ +../../Task/Resistor-mesh/D \ No newline at end of file diff --git a/Lang/D/Respond-to-an-unknown-method-call b/Lang/D/Respond-to-an-unknown-method-call new file mode 120000 index 0000000000..09ecb2d83a --- /dev/null +++ b/Lang/D/Respond-to-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Respond-to-an-unknown-method-call/D \ No newline at end of file diff --git a/Lang/D/Return-multiple-values b/Lang/D/Return-multiple-values new file mode 120000 index 0000000000..bd3ed7b5a0 --- /dev/null +++ b/Lang/D/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/D \ No newline at end of file diff --git a/Lang/D/Reverse-a-string b/Lang/D/Reverse-a-string new file mode 120000 index 0000000000..3c0243b5da --- /dev/null +++ b/Lang/D/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/D \ No newline at end of file diff --git a/Lang/D/Rock-paper-scissors b/Lang/D/Rock-paper-scissors new file mode 120000 index 0000000000..62c346288a --- /dev/null +++ b/Lang/D/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/D \ No newline at end of file diff --git a/Lang/D/Roman-numerals-Decode b/Lang/D/Roman-numerals-Decode new file mode 120000 index 0000000000..e969f2e834 --- /dev/null +++ b/Lang/D/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/D \ No newline at end of file diff --git a/Lang/D/Roman-numerals-Encode b/Lang/D/Roman-numerals-Encode new file mode 120000 index 0000000000..64861fb0c8 --- /dev/null +++ b/Lang/D/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/D \ No newline at end of file diff --git a/Lang/D/Roots-of-a-function b/Lang/D/Roots-of-a-function new file mode 120000 index 0000000000..a071830b90 --- /dev/null +++ b/Lang/D/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/D \ No newline at end of file diff --git a/Lang/D/Roots-of-a-quadratic-function b/Lang/D/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..51a8e461a4 --- /dev/null +++ b/Lang/D/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/D \ No newline at end of file diff --git a/Lang/D/Roots-of-unity b/Lang/D/Roots-of-unity new file mode 120000 index 0000000000..a63fc152fb --- /dev/null +++ b/Lang/D/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/D \ No newline at end of file diff --git a/Lang/D/Rosetta-Code-Count-examples b/Lang/D/Rosetta-Code-Count-examples new file mode 120000 index 0000000000..978bf02a59 --- /dev/null +++ b/Lang/D/Rosetta-Code-Count-examples @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Count-examples/D \ No newline at end of file diff --git a/Lang/D/Rosetta-Code-Rank-languages-by-popularity b/Lang/D/Rosetta-Code-Rank-languages-by-popularity new file mode 120000 index 0000000000..cf792155f1 --- /dev/null +++ b/Lang/D/Rosetta-Code-Rank-languages-by-popularity @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-popularity/D \ No newline at end of file diff --git a/Lang/D/Rot-13 b/Lang/D/Rot-13 new file mode 120000 index 0000000000..ac0d9b028d --- /dev/null +++ b/Lang/D/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/D \ No newline at end of file diff --git a/Lang/D/Run-length-encoding b/Lang/D/Run-length-encoding new file mode 120000 index 0000000000..b4fb45f53d --- /dev/null +++ b/Lang/D/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/D \ No newline at end of file diff --git a/Lang/D/S-Expressions b/Lang/D/S-Expressions new file mode 120000 index 0000000000..433e2bdadd --- /dev/null +++ b/Lang/D/S-Expressions @@ -0,0 +1 @@ +../../Task/S-Expressions/D \ No newline at end of file diff --git a/Lang/D/SEDOLs b/Lang/D/SEDOLs new file mode 120000 index 0000000000..781db2b725 --- /dev/null +++ b/Lang/D/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/D \ No newline at end of file diff --git a/Lang/D/Same-Fringe b/Lang/D/Same-Fringe new file mode 120000 index 0000000000..ddc4826fc5 --- /dev/null +++ b/Lang/D/Same-Fringe @@ -0,0 +1 @@ +../../Task/Same-Fringe/D \ No newline at end of file diff --git a/Lang/D/Secure-temporary-file b/Lang/D/Secure-temporary-file new file mode 120000 index 0000000000..e00a5e8d3b --- /dev/null +++ b/Lang/D/Secure-temporary-file @@ -0,0 +1 @@ +../../Task/Secure-temporary-file/D \ No newline at end of file diff --git a/Lang/D/Self-describing-numbers b/Lang/D/Self-describing-numbers new file mode 120000 index 0000000000..a263a68cb3 --- /dev/null +++ b/Lang/D/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/D \ No newline at end of file diff --git a/Lang/D/Self-referential-sequence b/Lang/D/Self-referential-sequence new file mode 120000 index 0000000000..e466b86e08 --- /dev/null +++ b/Lang/D/Self-referential-sequence @@ -0,0 +1 @@ +../../Task/Self-referential-sequence/D \ No newline at end of file diff --git a/Lang/D/Semordnilap b/Lang/D/Semordnilap new file mode 120000 index 0000000000..49701f8986 --- /dev/null +++ b/Lang/D/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/D \ No newline at end of file diff --git a/Lang/D/Send-email b/Lang/D/Send-email new file mode 120000 index 0000000000..55371889da --- /dev/null +++ b/Lang/D/Send-email @@ -0,0 +1 @@ +../../Task/Send-email/D \ No newline at end of file diff --git a/Lang/D/Sequence-of-non-squares b/Lang/D/Sequence-of-non-squares new file mode 120000 index 0000000000..393da70dd6 --- /dev/null +++ b/Lang/D/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/D \ No newline at end of file diff --git a/Lang/D/Set b/Lang/D/Set new file mode 120000 index 0000000000..8fee5843cd --- /dev/null +++ b/Lang/D/Set @@ -0,0 +1 @@ +../../Task/Set/D \ No newline at end of file diff --git a/Lang/D/Set-consolidation b/Lang/D/Set-consolidation new file mode 120000 index 0000000000..fafb6b7b30 --- /dev/null +++ b/Lang/D/Set-consolidation @@ -0,0 +1 @@ +../../Task/Set-consolidation/D \ No newline at end of file diff --git a/Lang/D/Set-of-real-numbers b/Lang/D/Set-of-real-numbers new file mode 120000 index 0000000000..954cdba281 --- /dev/null +++ b/Lang/D/Set-of-real-numbers @@ -0,0 +1 @@ +../../Task/Set-of-real-numbers/D \ No newline at end of file diff --git a/Lang/DCL/Rename-a-file b/Lang/DCL/Rename-a-file new file mode 120000 index 0000000000..2970d51697 --- /dev/null +++ b/Lang/DCL/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/DCL \ No newline at end of file diff --git a/Lang/DWScript/One-dimensional-cellular-automata b/Lang/DWScript/One-dimensional-cellular-automata new file mode 120000 index 0000000000..33390e69dd --- /dev/null +++ b/Lang/DWScript/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Pascals-triangle b/Lang/DWScript/Pascals-triangle new file mode 120000 index 0000000000..8cc6960e19 --- /dev/null +++ b/Lang/DWScript/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Random-numbers b/Lang/DWScript/Random-numbers new file mode 120000 index 0000000000..3783d5b2d8 --- /dev/null +++ b/Lang/DWScript/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Range-extraction b/Lang/DWScript/Range-extraction new file mode 120000 index 0000000000..69f57ec2d2 --- /dev/null +++ b/Lang/DWScript/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Repeat-a-string b/Lang/DWScript/Repeat-a-string new file mode 120000 index 0000000000..8b4604bee2 --- /dev/null +++ b/Lang/DWScript/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Roman-numerals-Encode b/Lang/DWScript/Roman-numerals-Encode new file mode 120000 index 0000000000..7fceaef287 --- /dev/null +++ b/Lang/DWScript/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/DWScript \ No newline at end of file diff --git a/Lang/DWScript/Roots-of-a-function b/Lang/DWScript/Roots-of-a-function new file mode 120000 index 0000000000..daeecba113 --- /dev/null +++ b/Lang/DWScript/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/DWScript \ No newline at end of file diff --git a/Lang/Dart/Binary-digits b/Lang/Dart/Binary-digits new file mode 120000 index 0000000000..dc30bdf71c --- /dev/null +++ b/Lang/Dart/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Dart \ No newline at end of file diff --git a/Lang/Dart/N-queens-problem b/Lang/Dart/N-queens-problem new file mode 120000 index 0000000000..6963f2a6a3 --- /dev/null +++ b/Lang/Dart/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Dart \ No newline at end of file diff --git a/Lang/Dart/Program-name b/Lang/Dart/Program-name new file mode 120000 index 0000000000..3c30bb6497 --- /dev/null +++ b/Lang/Dart/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Dart \ No newline at end of file diff --git a/Lang/Dart/Reverse-a-string b/Lang/Dart/Reverse-a-string new file mode 120000 index 0000000000..91a8046aec --- /dev/null +++ b/Lang/Dart/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Dart \ No newline at end of file diff --git a/Lang/Deja-Vu/Pick-random-element b/Lang/Deja-Vu/Pick-random-element new file mode 120000 index 0000000000..9c44f19b50 --- /dev/null +++ b/Lang/Deja-Vu/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/Deja-Vu \ No newline at end of file diff --git a/Lang/Deja-Vu/Random-number-generator--included- b/Lang/Deja-Vu/Random-number-generator--included- new file mode 120000 index 0000000000..a5b1906acd --- /dev/null +++ b/Lang/Deja-Vu/Random-number-generator--included- @@ -0,0 +1 @@ +../../Task/Random-number-generator--included-/Deja-Vu \ No newline at end of file diff --git a/Lang/Delphi/Binary-digits b/Lang/Delphi/Binary-digits new file mode 120000 index 0000000000..2de73fb8f1 --- /dev/null +++ b/Lang/Delphi/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Brownian-tree b/Lang/Delphi/Brownian-tree new file mode 120000 index 0000000000..f883f8a640 --- /dev/null +++ b/Lang/Delphi/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Copy-a-string b/Lang/Delphi/Copy-a-string new file mode 120000 index 0000000000..82e4de7a56 --- /dev/null +++ b/Lang/Delphi/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Environment-variables b/Lang/Delphi/Environment-variables new file mode 120000 index 0000000000..20a22a5c56 --- /dev/null +++ b/Lang/Delphi/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Nth-root b/Lang/Delphi/Nth-root new file mode 120000 index 0000000000..2fcfcdb141 --- /dev/null +++ b/Lang/Delphi/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Null-object b/Lang/Delphi/Null-object new file mode 120000 index 0000000000..a462111bc3 --- /dev/null +++ b/Lang/Delphi/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Palindrome-detection b/Lang/Delphi/Palindrome-detection new file mode 120000 index 0000000000..aeb9b5d356 --- /dev/null +++ b/Lang/Delphi/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Pangram-checker b/Lang/Delphi/Pangram-checker new file mode 120000 index 0000000000..c6748ba788 --- /dev/null +++ b/Lang/Delphi/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Permutations b/Lang/Delphi/Permutations new file mode 120000 index 0000000000..d0d28cd252 --- /dev/null +++ b/Lang/Delphi/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Play-recorded-sounds b/Lang/Delphi/Play-recorded-sounds new file mode 120000 index 0000000000..62fa5c4518 --- /dev/null +++ b/Lang/Delphi/Play-recorded-sounds @@ -0,0 +1 @@ +../../Task/Play-recorded-sounds/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Playing-cards b/Lang/Delphi/Playing-cards new file mode 120000 index 0000000000..37fbb3695e --- /dev/null +++ b/Lang/Delphi/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Polymorphism b/Lang/Delphi/Polymorphism new file mode 120000 index 0000000000..21c0184097 --- /dev/null +++ b/Lang/Delphi/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Primality-by-trial-division b/Lang/Delphi/Primality-by-trial-division new file mode 120000 index 0000000000..a14b672fc5 --- /dev/null +++ b/Lang/Delphi/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Program-name b/Lang/Delphi/Program-name new file mode 120000 index 0000000000..91b5404125 --- /dev/null +++ b/Lang/Delphi/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Program-termination b/Lang/Delphi/Program-termination new file mode 120000 index 0000000000..1c8399d9da --- /dev/null +++ b/Lang/Delphi/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Quaternion-type b/Lang/Delphi/Quaternion-type new file mode 120000 index 0000000000..fe804d3654 --- /dev/null +++ b/Lang/Delphi/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Queue-Usage b/Lang/Delphi/Queue-Usage new file mode 120000 index 0000000000..754a3898b2 --- /dev/null +++ b/Lang/Delphi/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Random-numbers b/Lang/Delphi/Random-numbers new file mode 120000 index 0000000000..1010bf4a6f --- /dev/null +++ b/Lang/Delphi/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Read-a-file-line-by-line b/Lang/Delphi/Read-a-file-line-by-line new file mode 120000 index 0000000000..fd18060f80 --- /dev/null +++ b/Lang/Delphi/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Read-entire-file b/Lang/Delphi/Read-entire-file new file mode 120000 index 0000000000..dec7cff2be --- /dev/null +++ b/Lang/Delphi/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Real-constants-and-functions b/Lang/Delphi/Real-constants-and-functions new file mode 120000 index 0000000000..e227a82fda --- /dev/null +++ b/Lang/Delphi/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Remove-duplicate-elements b/Lang/Delphi/Remove-duplicate-elements new file mode 120000 index 0000000000..4417a3c791 --- /dev/null +++ b/Lang/Delphi/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Rename-a-file b/Lang/Delphi/Rename-a-file new file mode 120000 index 0000000000..a5e10c5f72 --- /dev/null +++ b/Lang/Delphi/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Repeat-a-string b/Lang/Delphi/Repeat-a-string new file mode 120000 index 0000000000..f91d72c7a3 --- /dev/null +++ b/Lang/Delphi/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Return-multiple-values b/Lang/Delphi/Return-multiple-values new file mode 120000 index 0000000000..b899cfcbe8 --- /dev/null +++ b/Lang/Delphi/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Reverse-a-string b/Lang/Delphi/Reverse-a-string new file mode 120000 index 0000000000..360074c9a1 --- /dev/null +++ b/Lang/Delphi/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Roman-numerals-Decode b/Lang/Delphi/Roman-numerals-Decode new file mode 120000 index 0000000000..6e8975ced1 --- /dev/null +++ b/Lang/Delphi/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Roman-numerals-Encode b/Lang/Delphi/Roman-numerals-Encode new file mode 120000 index 0000000000..e312c888a0 --- /dev/null +++ b/Lang/Delphi/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Scope-modifiers b/Lang/Delphi/Scope-modifiers new file mode 120000 index 0000000000..d99a6aa53d --- /dev/null +++ b/Lang/Delphi/Scope-modifiers @@ -0,0 +1 @@ +../../Task/Scope-modifiers/Delphi \ No newline at end of file diff --git a/Lang/Delphi/Send-email b/Lang/Delphi/Send-email new file mode 120000 index 0000000000..998bd30874 --- /dev/null +++ b/Lang/Delphi/Send-email @@ -0,0 +1 @@ +../../Task/Send-email/Delphi \ 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..d64134e27e --- /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/Arbitrary-precision-integers-included b/Lang/E/Arbitrary-precision-integers-included deleted file mode 120000 index fa66ba3bae..0000000000 --- a/Lang/E/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/E \ No newline at end of file diff --git a/Lang/E/Environment-variables b/Lang/E/Environment-variables new file mode 120000 index 0000000000..d930498a5d --- /dev/null +++ b/Lang/E/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/E \ No newline at end of file diff --git a/Lang/E/Named-parameters b/Lang/E/Named-parameters new file mode 120000 index 0000000000..9cf2a24d97 --- /dev/null +++ b/Lang/E/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/E \ No newline at end of file diff --git a/Lang/E/Non-decimal-radices-Convert b/Lang/E/Non-decimal-radices-Convert new file mode 120000 index 0000000000..584f712733 --- /dev/null +++ b/Lang/E/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/E \ No newline at end of file diff --git a/Lang/E/Non-decimal-radices-Input b/Lang/E/Non-decimal-radices-Input new file mode 120000 index 0000000000..52c7c4520c --- /dev/null +++ b/Lang/E/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/E \ No newline at end of file diff --git a/Lang/E/Non-decimal-radices-Output b/Lang/E/Non-decimal-radices-Output new file mode 120000 index 0000000000..21981c1bda --- /dev/null +++ b/Lang/E/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/E \ No newline at end of file diff --git a/Lang/E/Nth-root b/Lang/E/Nth-root new file mode 120000 index 0000000000..61bc48d2cd --- /dev/null +++ b/Lang/E/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/E \ No newline at end of file diff --git a/Lang/E/Null-object b/Lang/E/Null-object new file mode 120000 index 0000000000..d0de97a8e3 --- /dev/null +++ b/Lang/E/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/E \ No newline at end of file diff --git a/Lang/E/Numerical-integration b/Lang/E/Numerical-integration new file mode 120000 index 0000000000..6848306646 --- /dev/null +++ b/Lang/E/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/E \ No newline at end of file diff --git a/Lang/E/Object-serialization b/Lang/E/Object-serialization new file mode 120000 index 0000000000..23af7b1394 --- /dev/null +++ b/Lang/E/Object-serialization @@ -0,0 +1 @@ +../../Task/Object-serialization/E \ No newline at end of file diff --git a/Lang/E/One-dimensional-cellular-automata b/Lang/E/One-dimensional-cellular-automata new file mode 120000 index 0000000000..4331081907 --- /dev/null +++ b/Lang/E/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/E \ No newline at end of file diff --git a/Lang/E/Optional-parameters b/Lang/E/Optional-parameters new file mode 120000 index 0000000000..46e9a16901 --- /dev/null +++ b/Lang/E/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/E \ No newline at end of file diff --git a/Lang/E/Palindrome-detection b/Lang/E/Palindrome-detection new file mode 120000 index 0000000000..a07188d6d1 --- /dev/null +++ b/Lang/E/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/E \ No newline at end of file diff --git a/Lang/E/Pangram-checker b/Lang/E/Pangram-checker new file mode 120000 index 0000000000..a13483fc6d --- /dev/null +++ b/Lang/E/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/E \ No newline at end of file diff --git a/Lang/E/Parametric-polymorphism b/Lang/E/Parametric-polymorphism new file mode 120000 index 0000000000..712e9d1438 --- /dev/null +++ b/Lang/E/Parametric-polymorphism @@ -0,0 +1 @@ +../../Task/Parametric-polymorphism/E \ No newline at end of file diff --git a/Lang/E/Partial-function-application b/Lang/E/Partial-function-application new file mode 120000 index 0000000000..bd8d843832 --- /dev/null +++ b/Lang/E/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/E \ No newline at end of file diff --git a/Lang/E/Pascals-triangle b/Lang/E/Pascals-triangle new file mode 120000 index 0000000000..0e22a1a1b9 --- /dev/null +++ b/Lang/E/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/E \ No newline at end of file diff --git a/Lang/E/Percentage-difference-between-images b/Lang/E/Percentage-difference-between-images new file mode 120000 index 0000000000..a52c57d253 --- /dev/null +++ b/Lang/E/Percentage-difference-between-images @@ -0,0 +1 @@ +../../Task/Percentage-difference-between-images/E \ No newline at end of file diff --git a/Lang/E/Perfect-numbers b/Lang/E/Perfect-numbers new file mode 120000 index 0000000000..32d3b05c46 --- /dev/null +++ b/Lang/E/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/E \ No newline at end of file diff --git a/Lang/E/Polymorphic-copy b/Lang/E/Polymorphic-copy new file mode 120000 index 0000000000..42784f0171 --- /dev/null +++ b/Lang/E/Polymorphic-copy @@ -0,0 +1 @@ +../../Task/Polymorphic-copy/E \ No newline at end of file diff --git a/Lang/E/Polymorphism b/Lang/E/Polymorphism new file mode 120000 index 0000000000..67a2acdb1e --- /dev/null +++ b/Lang/E/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/E \ No newline at end of file diff --git a/Lang/E/Polynomial-long-division b/Lang/E/Polynomial-long-division new file mode 120000 index 0000000000..e9ad34623e --- /dev/null +++ b/Lang/E/Polynomial-long-division @@ -0,0 +1 @@ +../../Task/Polynomial-long-division/E \ No newline at end of file diff --git a/Lang/E/Power-set b/Lang/E/Power-set new file mode 120000 index 0000000000..ec9ad8f4dd --- /dev/null +++ b/Lang/E/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/E \ No newline at end of file diff --git a/Lang/E/Primality-by-trial-division b/Lang/E/Primality-by-trial-division new file mode 120000 index 0000000000..6e3fbdb532 --- /dev/null +++ b/Lang/E/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/E \ No newline at end of file diff --git a/Lang/E/Prime-decomposition b/Lang/E/Prime-decomposition new file mode 120000 index 0000000000..4cdf5c8bb9 --- /dev/null +++ b/Lang/E/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/E \ No newline at end of file diff --git a/Lang/E/Probabilistic-choice b/Lang/E/Probabilistic-choice new file mode 120000 index 0000000000..540ea2fc85 --- /dev/null +++ b/Lang/E/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/E \ No newline at end of file diff --git a/Lang/E/Program-termination b/Lang/E/Program-termination new file mode 120000 index 0000000000..8d7164f192 --- /dev/null +++ b/Lang/E/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/E \ No newline at end of file diff --git a/Lang/E/Quaternion-type b/Lang/E/Quaternion-type new file mode 120000 index 0000000000..ecc55ca8a4 --- /dev/null +++ b/Lang/E/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/E \ No newline at end of file diff --git a/Lang/E/Queue-Definition b/Lang/E/Queue-Definition new file mode 120000 index 0000000000..37140c527c --- /dev/null +++ b/Lang/E/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/E \ No newline at end of file diff --git a/Lang/E/Queue-Usage b/Lang/E/Queue-Usage new file mode 120000 index 0000000000..bf6a0465be --- /dev/null +++ b/Lang/E/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/E \ No newline at end of file diff --git a/Lang/E/Random-numbers b/Lang/E/Random-numbers new file mode 120000 index 0000000000..820dd930b5 --- /dev/null +++ b/Lang/E/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/E \ No newline at end of file diff --git a/Lang/E/Range-extraction b/Lang/E/Range-extraction new file mode 120000 index 0000000000..fd629a18d7 --- /dev/null +++ b/Lang/E/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/E \ No newline at end of file diff --git a/Lang/E/Rate-counter b/Lang/E/Rate-counter new file mode 120000 index 0000000000..1ec6148aba --- /dev/null +++ b/Lang/E/Rate-counter @@ -0,0 +1 @@ +../../Task/Rate-counter/E \ No newline at end of file diff --git a/Lang/E/Read-entire-file b/Lang/E/Read-entire-file new file mode 120000 index 0000000000..5770032c99 --- /dev/null +++ b/Lang/E/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/E \ No newline at end of file diff --git a/Lang/E/Real-constants-and-functions b/Lang/E/Real-constants-and-functions new file mode 120000 index 0000000000..6a7b16da23 --- /dev/null +++ b/Lang/E/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/E \ No newline at end of file diff --git a/Lang/E/Remove-duplicate-elements b/Lang/E/Remove-duplicate-elements new file mode 120000 index 0000000000..9b1542e6ec --- /dev/null +++ b/Lang/E/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/E \ No newline at end of file diff --git a/Lang/E/Rename-a-file b/Lang/E/Rename-a-file new file mode 120000 index 0000000000..a14000045b --- /dev/null +++ b/Lang/E/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/E \ No newline at end of file diff --git a/Lang/E/Repeat-a-string b/Lang/E/Repeat-a-string new file mode 120000 index 0000000000..f9103d2f30 --- /dev/null +++ b/Lang/E/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/E \ No newline at end of file diff --git a/Lang/E/Respond-to-an-unknown-method-call b/Lang/E/Respond-to-an-unknown-method-call new file mode 120000 index 0000000000..8270aac23a --- /dev/null +++ b/Lang/E/Respond-to-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Respond-to-an-unknown-method-call/E \ No newline at end of file diff --git a/Lang/E/Reverse-a-string b/Lang/E/Reverse-a-string new file mode 120000 index 0000000000..c7c587444d --- /dev/null +++ b/Lang/E/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/E \ No newline at end of file diff --git a/Lang/E/Rot-13 b/Lang/E/Rot-13 new file mode 120000 index 0000000000..2348456aab --- /dev/null +++ b/Lang/E/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/E \ No newline at end of file diff --git a/Lang/E/Run-length-encoding b/Lang/E/Run-length-encoding new file mode 120000 index 0000000000..8c640b0d58 --- /dev/null +++ b/Lang/E/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/E \ No newline at end of file diff --git a/Lang/E/Runtime-evaluation b/Lang/E/Runtime-evaluation new file mode 120000 index 0000000000..4048972348 --- /dev/null +++ b/Lang/E/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/E \ No newline at end of file diff --git a/Lang/E/Runtime-evaluation-In-an-environment b/Lang/E/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..d742442197 --- /dev/null +++ b/Lang/E/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/E \ No newline at end of file diff --git a/Lang/E/SEDOLs b/Lang/E/SEDOLs new file mode 120000 index 0000000000..f87f846ed7 --- /dev/null +++ b/Lang/E/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/E \ No newline at end of file diff --git a/Lang/E/Safe-addition b/Lang/E/Safe-addition new file mode 120000 index 0000000000..9283f66703 --- /dev/null +++ b/Lang/E/Safe-addition @@ -0,0 +1 @@ +../../Task/Safe-addition/E \ No newline at end of file diff --git a/Lang/E/Send-an-unknown-method-call b/Lang/E/Send-an-unknown-method-call new file mode 120000 index 0000000000..a520bd519d --- /dev/null +++ b/Lang/E/Send-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Send-an-unknown-method-call/E \ No newline at end of file diff --git a/Lang/EGL/Reverse-a-string b/Lang/EGL/Reverse-a-string new file mode 120000 index 0000000000..a1ae5b4800 --- /dev/null +++ b/Lang/EGL/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/EGL \ No newline at end of file diff --git a/Lang/EGL/Rosetta-Code-Count-examples b/Lang/EGL/Rosetta-Code-Count-examples new file mode 120000 index 0000000000..03b7618460 --- /dev/null +++ b/Lang/EGL/Rosetta-Code-Count-examples @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Count-examples/EGL \ No newline at end of file diff --git a/Lang/Eiffel/Environment-variables b/Lang/Eiffel/Environment-variables new file mode 120000 index 0000000000..fd4c5a6aaf --- /dev/null +++ b/Lang/Eiffel/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Eiffel \ No newline at end of file diff --git a/Lang/Eiffel/Polymorphism b/Lang/Eiffel/Polymorphism new file mode 120000 index 0000000000..bbbd235ccd --- /dev/null +++ b/Lang/Eiffel/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/Eiffel \ No newline at end of file diff --git a/Lang/Eiffel/Random-numbers b/Lang/Eiffel/Random-numbers new file mode 120000 index 0000000000..6ba0ed4d34 --- /dev/null +++ b/Lang/Eiffel/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Eiffel \ No newline at end of file diff --git a/Lang/Eiffel/Reverse-a-string b/Lang/Eiffel/Reverse-a-string new file mode 120000 index 0000000000..01180e8b3d --- /dev/null +++ b/Lang/Eiffel/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Eiffel \ No newline at end of file diff --git a/Lang/Ela/Order-two-numerical-lists b/Lang/Ela/Order-two-numerical-lists new file mode 120000 index 0000000000..96428b19a6 --- /dev/null +++ b/Lang/Ela/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/Ela \ No newline at end of file diff --git a/Lang/Ela/Palindrome-detection b/Lang/Ela/Palindrome-detection new file mode 120000 index 0000000000..731aac6d1f --- /dev/null +++ b/Lang/Ela/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Ela \ No newline at end of file diff --git a/Lang/Ela/Parsing-RPN-calculator-algorithm b/Lang/Ela/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..720bbb26ee --- /dev/null +++ b/Lang/Ela/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/Ela \ No newline at end of file diff --git a/Lang/Ela/Polymorphism b/Lang/Ela/Polymorphism new file mode 120000 index 0000000000..b498270e1d --- /dev/null +++ b/Lang/Ela/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/Ela \ No newline at end of file diff --git a/Lang/Ela/Scope-modifiers b/Lang/Ela/Scope-modifiers new file mode 120000 index 0000000000..d6ceac85f1 --- /dev/null +++ b/Lang/Ela/Scope-modifiers @@ -0,0 +1 @@ +../../Task/Scope-modifiers/Ela \ No newline at end of file diff --git a/Lang/Ela/Set-consolidation b/Lang/Ela/Set-consolidation new file mode 120000 index 0000000000..57a755877a --- /dev/null +++ b/Lang/Ela/Set-consolidation @@ -0,0 +1 @@ +../../Task/Set-consolidation/Ela \ No newline at end of file diff --git a/Lang/Elena/Binary-digits b/Lang/Elena/Binary-digits new file mode 120000 index 0000000000..451d5a94b9 --- /dev/null +++ b/Lang/Elena/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Elena \ No newline at end of file diff --git a/Lang/Elisa/Queue-Definition b/Lang/Elisa/Queue-Definition new file mode 120000 index 0000000000..ebfb6cc3fc --- /dev/null +++ b/Lang/Elisa/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/Elisa \ 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..fce95352a8 --- /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/Arbitrary-precision-integers-included b/Lang/Emacs-Lisp/Arbitrary-precision-integers-included deleted file mode 120000 index 4d9c0aa09a..0000000000 --- a/Lang/Emacs-Lisp/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Dragon-curve b/Lang/Emacs-Lisp/Dragon-curve new file mode 120000 index 0000000000..00a00783bf --- /dev/null +++ b/Lang/Emacs-Lisp/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Environment-variables b/Lang/Emacs-Lisp/Environment-variables new file mode 120000 index 0000000000..900c543508 --- /dev/null +++ b/Lang/Emacs-Lisp/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Program-name b/Lang/Emacs-Lisp/Program-name new file mode 120000 index 0000000000..009e8b6796 --- /dev/null +++ b/Lang/Emacs-Lisp/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Reverse-a-string b/Lang/Emacs-Lisp/Reverse-a-string new file mode 120000 index 0000000000..668b7df53e --- /dev/null +++ b/Lang/Emacs-Lisp/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Roman-numerals-Decode b/Lang/Emacs-Lisp/Roman-numerals-Decode new file mode 120000 index 0000000000..1b5d8b84e6 --- /dev/null +++ b/Lang/Emacs-Lisp/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Emacs-Lisp/Roman-numerals-Encode b/Lang/Emacs-Lisp/Roman-numerals-Encode new file mode 120000 index 0000000000..30f68dbc6c --- /dev/null +++ b/Lang/Emacs-Lisp/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Emacs-Lisp \ No newline at end of file diff --git a/Lang/Erlang/Arbitrary-precision-integers--included- b/Lang/Erlang/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..da7fbfe094 --- /dev/null +++ b/Lang/Erlang/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Arbitrary-precision-integers-included b/Lang/Erlang/Arbitrary-precision-integers-included deleted file mode 120000 index cd2d4cb2a3..0000000000 --- a/Lang/Erlang/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Binary-digits b/Lang/Erlang/Binary-digits new file mode 120000 index 0000000000..f7fc1607df --- /dev/null +++ b/Lang/Erlang/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Catalan-numbers b/Lang/Erlang/Catalan-numbers new file mode 120000 index 0000000000..5ff640aa24 --- /dev/null +++ b/Lang/Erlang/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Copy-a-string b/Lang/Erlang/Copy-a-string new file mode 120000 index 0000000000..1ad4e9e00e --- /dev/null +++ b/Lang/Erlang/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Nth-root b/Lang/Erlang/Nth-root new file mode 120000 index 0000000000..7a6700df3d --- /dev/null +++ b/Lang/Erlang/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Erlang \ No newline at end of file diff --git a/Lang/Erlang/One-dimensional-cellular-automata b/Lang/Erlang/One-dimensional-cellular-automata new file mode 120000 index 0000000000..1a1ed60a0c --- /dev/null +++ b/Lang/Erlang/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Palindrome-detection b/Lang/Erlang/Palindrome-detection new file mode 120000 index 0000000000..5bdc6562fb --- /dev/null +++ b/Lang/Erlang/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Pangram-checker b/Lang/Erlang/Pangram-checker new file mode 120000 index 0000000000..f6136de715 --- /dev/null +++ b/Lang/Erlang/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Pascals-triangle b/Lang/Erlang/Pascals-triangle new file mode 120000 index 0000000000..770c874a64 --- /dev/null +++ b/Lang/Erlang/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Perfect-numbers b/Lang/Erlang/Perfect-numbers new file mode 120000 index 0000000000..ee57fc09d2 --- /dev/null +++ b/Lang/Erlang/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Permutations b/Lang/Erlang/Permutations new file mode 120000 index 0000000000..f0556936e3 --- /dev/null +++ b/Lang/Erlang/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Power-set b/Lang/Erlang/Power-set new file mode 120000 index 0000000000..0d7a564ecf --- /dev/null +++ b/Lang/Erlang/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Price-fraction b/Lang/Erlang/Price-fraction new file mode 120000 index 0000000000..06eba06456 --- /dev/null +++ b/Lang/Erlang/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Primality-by-trial-division b/Lang/Erlang/Primality-by-trial-division new file mode 120000 index 0000000000..3ce761da16 --- /dev/null +++ b/Lang/Erlang/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Prime-decomposition b/Lang/Erlang/Prime-decomposition new file mode 120000 index 0000000000..5a3f83648f --- /dev/null +++ b/Lang/Erlang/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Program-name b/Lang/Erlang/Program-name new file mode 120000 index 0000000000..20b9813b9f --- /dev/null +++ b/Lang/Erlang/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Pythagorean-triples b/Lang/Erlang/Pythagorean-triples new file mode 120000 index 0000000000..c3af61fc99 --- /dev/null +++ b/Lang/Erlang/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Queue-Definition b/Lang/Erlang/Queue-Definition new file mode 120000 index 0000000000..1c9e4890ba --- /dev/null +++ b/Lang/Erlang/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Queue-Usage b/Lang/Erlang/Queue-Usage new file mode 120000 index 0000000000..f3dc213729 --- /dev/null +++ b/Lang/Erlang/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Random-number-generator--included- b/Lang/Erlang/Random-number-generator--included- new file mode 120000 index 0000000000..9ee85f8f67 --- /dev/null +++ b/Lang/Erlang/Random-number-generator--included- @@ -0,0 +1 @@ +../../Task/Random-number-generator--included-/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Random-numbers b/Lang/Erlang/Random-numbers new file mode 120000 index 0000000000..fbdd08d5f0 --- /dev/null +++ b/Lang/Erlang/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Read-entire-file b/Lang/Erlang/Read-entire-file new file mode 120000 index 0000000000..7519a4c540 --- /dev/null +++ b/Lang/Erlang/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Regular-expressions b/Lang/Erlang/Regular-expressions new file mode 120000 index 0000000000..87ea56367b --- /dev/null +++ b/Lang/Erlang/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Remove-duplicate-elements b/Lang/Erlang/Remove-duplicate-elements new file mode 120000 index 0000000000..5c9db41dda --- /dev/null +++ b/Lang/Erlang/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Rename-a-file b/Lang/Erlang/Rename-a-file new file mode 120000 index 0000000000..05a8287bb4 --- /dev/null +++ b/Lang/Erlang/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Repeat-a-string b/Lang/Erlang/Repeat-a-string new file mode 120000 index 0000000000..6270e8ad0e --- /dev/null +++ b/Lang/Erlang/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Reverse-a-string b/Lang/Erlang/Reverse-a-string new file mode 120000 index 0000000000..4ccb7d2fe0 --- /dev/null +++ b/Lang/Erlang/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Rock-paper-scissors b/Lang/Erlang/Rock-paper-scissors new file mode 120000 index 0000000000..9375a7a3b0 --- /dev/null +++ b/Lang/Erlang/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Roman-numerals-Encode b/Lang/Erlang/Roman-numerals-Encode new file mode 120000 index 0000000000..8a7b42749a --- /dev/null +++ b/Lang/Erlang/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Rosetta-Code-Count-examples b/Lang/Erlang/Rosetta-Code-Count-examples new file mode 120000 index 0000000000..7b2911eb3e --- /dev/null +++ b/Lang/Erlang/Rosetta-Code-Count-examples @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Count-examples/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Rot-13 b/Lang/Erlang/Rot-13 new file mode 120000 index 0000000000..3c8ca12501 --- /dev/null +++ b/Lang/Erlang/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Run-length-encoding b/Lang/Erlang/Run-length-encoding new file mode 120000 index 0000000000..e57b990adb --- /dev/null +++ b/Lang/Erlang/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Runtime-evaluation b/Lang/Erlang/Runtime-evaluation new file mode 120000 index 0000000000..7f5780c5a0 --- /dev/null +++ b/Lang/Erlang/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/Erlang \ No newline at end of file diff --git a/Lang/Erlang/Self-describing-numbers b/Lang/Erlang/Self-describing-numbers new file mode 120000 index 0000000000..4330ad047a --- /dev/null +++ b/Lang/Erlang/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/Erlang \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/Random-numbers b/Lang/Euler-Math-Toolbox/Random-numbers new file mode 120000 index 0000000000..8ec1e7cdea --- /dev/null +++ b/Lang/Euler-Math-Toolbox/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Euler-Math-Toolbox \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/Resistor-mesh b/Lang/Euler-Math-Toolbox/Resistor-mesh new file mode 120000 index 0000000000..eec40a4686 --- /dev/null +++ b/Lang/Euler-Math-Toolbox/Resistor-mesh @@ -0,0 +1 @@ +../../Task/Resistor-mesh/Euler-Math-Toolbox \ No newline at end of file diff --git a/Lang/Euler-Math-Toolbox/Reverse-a-string b/Lang/Euler-Math-Toolbox/Reverse-a-string new file mode 120000 index 0000000000..bd5cb2bd2e --- /dev/null +++ b/Lang/Euler-Math-Toolbox/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Euler-Math-Toolbox \ No newline at end of file diff --git a/Lang/Euphoria/Binary-digits b/Lang/Euphoria/Binary-digits new file mode 120000 index 0000000000..07179efaee --- /dev/null +++ b/Lang/Euphoria/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Catalan-numbers b/Lang/Euphoria/Catalan-numbers new file mode 120000 index 0000000000..e6432c2170 --- /dev/null +++ b/Lang/Euphoria/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Copy-a-string b/Lang/Euphoria/Copy-a-string new file mode 120000 index 0000000000..692c744012 --- /dev/null +++ b/Lang/Euphoria/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Environment-variables b/Lang/Euphoria/Environment-variables new file mode 120000 index 0000000000..2f65c52720 --- /dev/null +++ b/Lang/Euphoria/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Guess-the-number-With-feedback--player- b/Lang/Euphoria/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..1b05132483 --- /dev/null +++ b/Lang/Euphoria/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Guess-the-number-With-feedback-player b/Lang/Euphoria/Guess-the-number-With-feedback-player deleted file mode 120000 index 808118f582..0000000000 --- a/Lang/Euphoria/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Non-decimal-radices-Convert b/Lang/Euphoria/Non-decimal-radices-Convert new file mode 120000 index 0000000000..4559bdea51 --- /dev/null +++ b/Lang/Euphoria/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Non-decimal-radices-Output b/Lang/Euphoria/Non-decimal-radices-Output new file mode 120000 index 0000000000..1dcc061966 --- /dev/null +++ b/Lang/Euphoria/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Number-names b/Lang/Euphoria/Number-names new file mode 120000 index 0000000000..607b3ad71a --- /dev/null +++ b/Lang/Euphoria/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Number-reversal-game b/Lang/Euphoria/Number-reversal-game new file mode 120000 index 0000000000..918691ea72 --- /dev/null +++ b/Lang/Euphoria/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Numerical-integration b/Lang/Euphoria/Numerical-integration new file mode 120000 index 0000000000..d459c44193 --- /dev/null +++ b/Lang/Euphoria/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/One-dimensional-cellular-automata b/Lang/Euphoria/One-dimensional-cellular-automata new file mode 120000 index 0000000000..6325bd4881 --- /dev/null +++ b/Lang/Euphoria/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/One-of-n-lines-in-a-file b/Lang/Euphoria/One-of-n-lines-in-a-file new file mode 120000 index 0000000000..c5cb261855 --- /dev/null +++ b/Lang/Euphoria/One-of-n-lines-in-a-file @@ -0,0 +1 @@ +../../Task/One-of-n-lines-in-a-file/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Palindrome-detection b/Lang/Euphoria/Palindrome-detection new file mode 120000 index 0000000000..217f021016 --- /dev/null +++ b/Lang/Euphoria/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Pascals-triangle b/Lang/Euphoria/Pascals-triangle new file mode 120000 index 0000000000..6f7808aa74 --- /dev/null +++ b/Lang/Euphoria/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Permutations b/Lang/Euphoria/Permutations new file mode 120000 index 0000000000..5a37219314 --- /dev/null +++ b/Lang/Euphoria/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Pick-random-element b/Lang/Euphoria/Pick-random-element new file mode 120000 index 0000000000..3163dbc1a7 --- /dev/null +++ b/Lang/Euphoria/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Price-fraction b/Lang/Euphoria/Price-fraction new file mode 120000 index 0000000000..2c081598e4 --- /dev/null +++ b/Lang/Euphoria/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Primality-by-trial-division b/Lang/Euphoria/Primality-by-trial-division new file mode 120000 index 0000000000..c402d766b6 --- /dev/null +++ b/Lang/Euphoria/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Probabilistic-choice b/Lang/Euphoria/Probabilistic-choice new file mode 120000 index 0000000000..838b4e9402 --- /dev/null +++ b/Lang/Euphoria/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Program-name b/Lang/Euphoria/Program-name new file mode 120000 index 0000000000..e0701c6415 --- /dev/null +++ b/Lang/Euphoria/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Pythagorean-triples b/Lang/Euphoria/Pythagorean-triples new file mode 120000 index 0000000000..b2e3f200d3 --- /dev/null +++ b/Lang/Euphoria/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Quaternion-type b/Lang/Euphoria/Quaternion-type new file mode 120000 index 0000000000..aedb6b51e1 --- /dev/null +++ b/Lang/Euphoria/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Random-numbers b/Lang/Euphoria/Random-numbers new file mode 120000 index 0000000000..6860bcd6ad --- /dev/null +++ b/Lang/Euphoria/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Range-extraction b/Lang/Euphoria/Range-extraction new file mode 120000 index 0000000000..a6c7b5a453 --- /dev/null +++ b/Lang/Euphoria/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Read-a-file-line-by-line b/Lang/Euphoria/Read-a-file-line-by-line new file mode 120000 index 0000000000..db9d99d1f6 --- /dev/null +++ b/Lang/Euphoria/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Read-entire-file b/Lang/Euphoria/Read-entire-file new file mode 120000 index 0000000000..a605da5605 --- /dev/null +++ b/Lang/Euphoria/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Reduced-row-echelon-form b/Lang/Euphoria/Reduced-row-echelon-form new file mode 120000 index 0000000000..9106afa15b --- /dev/null +++ b/Lang/Euphoria/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Remove-duplicate-elements b/Lang/Euphoria/Remove-duplicate-elements new file mode 120000 index 0000000000..814682f118 --- /dev/null +++ b/Lang/Euphoria/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Repeat-a-string b/Lang/Euphoria/Repeat-a-string new file mode 120000 index 0000000000..5de5fa7597 --- /dev/null +++ b/Lang/Euphoria/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Return-multiple-values b/Lang/Euphoria/Return-multiple-values new file mode 120000 index 0000000000..769cacd04d --- /dev/null +++ b/Lang/Euphoria/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Reverse-a-string b/Lang/Euphoria/Reverse-a-string new file mode 120000 index 0000000000..5d5ba1c3bf --- /dev/null +++ b/Lang/Euphoria/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Rock-paper-scissors b/Lang/Euphoria/Rock-paper-scissors new file mode 120000 index 0000000000..d1a713bb58 --- /dev/null +++ b/Lang/Euphoria/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Roman-numerals-Decode b/Lang/Euphoria/Roman-numerals-Decode new file mode 120000 index 0000000000..5832088083 --- /dev/null +++ b/Lang/Euphoria/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Roman-numerals-Encode b/Lang/Euphoria/Roman-numerals-Encode new file mode 120000 index 0000000000..c5ab4ba62a --- /dev/null +++ b/Lang/Euphoria/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Rot-13 b/Lang/Euphoria/Rot-13 new file mode 120000 index 0000000000..472ca2c904 --- /dev/null +++ b/Lang/Euphoria/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Run-length-encoding b/Lang/Euphoria/Run-length-encoding new file mode 120000 index 0000000000..0b5df368f6 --- /dev/null +++ b/Lang/Euphoria/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Euphoria \ No newline at end of file diff --git a/Lang/Euphoria/Sequence-of-non-squares b/Lang/Euphoria/Sequence-of-non-squares new file mode 120000 index 0000000000..b7863f4d1b --- /dev/null +++ b/Lang/Euphoria/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Euphoria \ No newline at end of file diff --git a/Lang/FALSE/Perfect-numbers b/Lang/FALSE/Perfect-numbers new file mode 120000 index 0000000000..c7ca715132 --- /dev/null +++ b/Lang/FALSE/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Primality-by-trial-division b/Lang/FALSE/Primality-by-trial-division new file mode 120000 index 0000000000..ba40fb42c4 --- /dev/null +++ b/Lang/FALSE/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Prime-decomposition b/Lang/FALSE/Prime-decomposition new file mode 120000 index 0000000000..b28f4c1319 --- /dev/null +++ b/Lang/FALSE/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Return-multiple-values b/Lang/FALSE/Return-multiple-values new file mode 120000 index 0000000000..d8a52433b9 --- /dev/null +++ b/Lang/FALSE/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Roman-numerals-Encode b/Lang/FALSE/Roman-numerals-Encode new file mode 120000 index 0000000000..9c63f72d5e --- /dev/null +++ b/Lang/FALSE/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Rot-13 b/Lang/FALSE/Rot-13 new file mode 120000 index 0000000000..c08e1692ca --- /dev/null +++ b/Lang/FALSE/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/FALSE \ No newline at end of file diff --git a/Lang/FALSE/Run-length-encoding b/Lang/FALSE/Run-length-encoding new file mode 120000 index 0000000000..b4ff3b3979 --- /dev/null +++ b/Lang/FALSE/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/FALSE \ No newline at end of file diff --git a/Lang/FBSL/Reverse-a-string b/Lang/FBSL/Reverse-a-string new file mode 120000 index 0000000000..f0e0947be7 --- /dev/null +++ b/Lang/FBSL/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/FBSL \ No newline at end of file diff --git a/Lang/Factor/Arbitrary-precision-integers--included- b/Lang/Factor/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..66907e3901 --- /dev/null +++ b/Lang/Factor/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Factor \ No newline at end of file diff --git a/Lang/Factor/Arbitrary-precision-integers-included b/Lang/Factor/Arbitrary-precision-integers-included deleted file mode 120000 index ddb3ab07e8..0000000000 --- a/Lang/Factor/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Factor \ No newline at end of file diff --git a/Lang/Factor/Binary-digits b/Lang/Factor/Binary-digits new file mode 120000 index 0000000000..1a57d46b51 --- /dev/null +++ b/Lang/Factor/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Factor \ No newline at end of file diff --git a/Lang/Factor/Catalan-numbers b/Lang/Factor/Catalan-numbers new file mode 120000 index 0000000000..f2b1d7db1b --- /dev/null +++ b/Lang/Factor/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Factor \ No newline at end of file diff --git a/Lang/Factor/Copy-a-string b/Lang/Factor/Copy-a-string new file mode 120000 index 0000000000..d0db9d7d8a --- /dev/null +++ b/Lang/Factor/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Factor \ No newline at end of file diff --git a/Lang/Factor/Dragon-curve b/Lang/Factor/Dragon-curve new file mode 120000 index 0000000000..c326dd5a0d --- /dev/null +++ b/Lang/Factor/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/Factor \ No newline at end of file diff --git a/Lang/Factor/Environment-variables b/Lang/Factor/Environment-variables new file mode 120000 index 0000000000..d02097cf79 --- /dev/null +++ b/Lang/Factor/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Factor \ No newline at end of file diff --git a/Lang/Factor/N-queens-problem b/Lang/Factor/N-queens-problem new file mode 120000 index 0000000000..baf4608870 --- /dev/null +++ b/Lang/Factor/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Factor \ No newline at end of file diff --git a/Lang/Factor/Non-decimal-radices-Convert b/Lang/Factor/Non-decimal-radices-Convert new file mode 120000 index 0000000000..4cf1dcda9c --- /dev/null +++ b/Lang/Factor/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/Factor \ No newline at end of file diff --git a/Lang/Factor/Non-decimal-radices-Input b/Lang/Factor/Non-decimal-radices-Input new file mode 120000 index 0000000000..8a1775aa0f --- /dev/null +++ b/Lang/Factor/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/Factor \ No newline at end of file diff --git a/Lang/Factor/Non-decimal-radices-Output b/Lang/Factor/Non-decimal-radices-Output new file mode 120000 index 0000000000..1e5aa1667d --- /dev/null +++ b/Lang/Factor/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/Factor \ No newline at end of file diff --git a/Lang/Factor/Null-object b/Lang/Factor/Null-object new file mode 120000 index 0000000000..2e11c43a87 --- /dev/null +++ b/Lang/Factor/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Factor \ No newline at end of file diff --git a/Lang/Factor/Number-reversal-game b/Lang/Factor/Number-reversal-game new file mode 120000 index 0000000000..04adfbdec0 --- /dev/null +++ b/Lang/Factor/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/Factor \ No newline at end of file diff --git a/Lang/Factor/One-dimensional-cellular-automata b/Lang/Factor/One-dimensional-cellular-automata new file mode 120000 index 0000000000..24d3aac764 --- /dev/null +++ b/Lang/Factor/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Factor \ No newline at end of file diff --git a/Lang/Factor/One-of-n-lines-in-a-file b/Lang/Factor/One-of-n-lines-in-a-file new file mode 120000 index 0000000000..9abdbf34a1 --- /dev/null +++ b/Lang/Factor/One-of-n-lines-in-a-file @@ -0,0 +1 @@ +../../Task/One-of-n-lines-in-a-file/Factor \ No newline at end of file diff --git a/Lang/Factor/OpenGL b/Lang/Factor/OpenGL new file mode 120000 index 0000000000..113dff4390 --- /dev/null +++ b/Lang/Factor/OpenGL @@ -0,0 +1 @@ +../../Task/OpenGL/Factor \ No newline at end of file diff --git a/Lang/Factor/Palindrome-detection b/Lang/Factor/Palindrome-detection new file mode 120000 index 0000000000..6cf330d0d7 --- /dev/null +++ b/Lang/Factor/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Factor \ No newline at end of file diff --git a/Lang/Factor/Pangram-checker b/Lang/Factor/Pangram-checker new file mode 120000 index 0000000000..7624608a3e --- /dev/null +++ b/Lang/Factor/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Factor \ No newline at end of file diff --git a/Lang/Factor/Pascals-triangle b/Lang/Factor/Pascals-triangle new file mode 120000 index 0000000000..4b0888b3f2 --- /dev/null +++ b/Lang/Factor/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Factor \ No newline at end of file diff --git a/Lang/Factor/Perfect-numbers b/Lang/Factor/Perfect-numbers new file mode 120000 index 0000000000..97eba0a9cd --- /dev/null +++ b/Lang/Factor/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Factor \ No newline at end of file diff --git a/Lang/Factor/Pick-random-element b/Lang/Factor/Pick-random-element new file mode 120000 index 0000000000..43cb1fab26 --- /dev/null +++ b/Lang/Factor/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/Factor \ No newline at end of file diff --git a/Lang/Factor/Polymorphic-copy b/Lang/Factor/Polymorphic-copy new file mode 120000 index 0000000000..7c9fa470cd --- /dev/null +++ b/Lang/Factor/Polymorphic-copy @@ -0,0 +1 @@ +../../Task/Polymorphic-copy/Factor \ No newline at end of file diff --git a/Lang/Factor/Polymorphism b/Lang/Factor/Polymorphism new file mode 120000 index 0000000000..6da82bcd89 --- /dev/null +++ b/Lang/Factor/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/Factor \ No newline at end of file diff --git a/Lang/Factor/Power-set b/Lang/Factor/Power-set new file mode 120000 index 0000000000..75af12b6c5 --- /dev/null +++ b/Lang/Factor/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Factor \ No newline at end of file diff --git a/Lang/Factor/Primality-by-trial-division b/Lang/Factor/Primality-by-trial-division new file mode 120000 index 0000000000..129068e226 --- /dev/null +++ b/Lang/Factor/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Factor \ No newline at end of file diff --git a/Lang/Factor/Prime-decomposition b/Lang/Factor/Prime-decomposition new file mode 120000 index 0000000000..c022022af1 --- /dev/null +++ b/Lang/Factor/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Factor \ No newline at end of file diff --git a/Lang/Factor/Priority-queue b/Lang/Factor/Priority-queue new file mode 120000 index 0000000000..6347ad711a --- /dev/null +++ b/Lang/Factor/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/Factor \ No newline at end of file diff --git a/Lang/Factor/Probabilistic-choice b/Lang/Factor/Probabilistic-choice new file mode 120000 index 0000000000..9b1cc3eda1 --- /dev/null +++ b/Lang/Factor/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/Factor \ No newline at end of file diff --git a/Lang/Factor/Program-name b/Lang/Factor/Program-name new file mode 120000 index 0000000000..2ee88e0f81 --- /dev/null +++ b/Lang/Factor/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Factor \ No newline at end of file diff --git a/Lang/Factor/Pythagorean-triples b/Lang/Factor/Pythagorean-triples new file mode 120000 index 0000000000..c8f21fd124 --- /dev/null +++ b/Lang/Factor/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/Factor \ No newline at end of file diff --git a/Lang/Factor/Random-numbers b/Lang/Factor/Random-numbers new file mode 120000 index 0000000000..edeadb345d --- /dev/null +++ b/Lang/Factor/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Factor \ No newline at end of file diff --git a/Lang/Factor/Ray-casting-algorithm b/Lang/Factor/Ray-casting-algorithm new file mode 120000 index 0000000000..c0bea1f0fd --- /dev/null +++ b/Lang/Factor/Ray-casting-algorithm @@ -0,0 +1 @@ +../../Task/Ray-casting-algorithm/Factor \ No newline at end of file diff --git a/Lang/Factor/Read-a-file-line-by-line b/Lang/Factor/Read-a-file-line-by-line new file mode 120000 index 0000000000..3f201688a4 --- /dev/null +++ b/Lang/Factor/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Factor \ No newline at end of file diff --git a/Lang/Factor/Read-entire-file b/Lang/Factor/Read-entire-file new file mode 120000 index 0000000000..5a057a1118 --- /dev/null +++ b/Lang/Factor/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Factor \ No newline at end of file diff --git a/Lang/Factor/Real-constants-and-functions b/Lang/Factor/Real-constants-and-functions new file mode 120000 index 0000000000..5d25d8b58a --- /dev/null +++ b/Lang/Factor/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Factor \ No newline at end of file diff --git a/Lang/Factor/Remove-duplicate-elements b/Lang/Factor/Remove-duplicate-elements new file mode 120000 index 0000000000..3db45b1fd3 --- /dev/null +++ b/Lang/Factor/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Factor \ No newline at end of file diff --git a/Lang/Factor/Rename-a-file b/Lang/Factor/Rename-a-file new file mode 120000 index 0000000000..d97b7170ab --- /dev/null +++ b/Lang/Factor/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Factor \ No newline at end of file diff --git a/Lang/Factor/Repeat-a-string b/Lang/Factor/Repeat-a-string new file mode 120000 index 0000000000..4ec39a5385 --- /dev/null +++ b/Lang/Factor/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Factor \ No newline at end of file diff --git a/Lang/Factor/Return-multiple-values b/Lang/Factor/Return-multiple-values new file mode 120000 index 0000000000..0ec1051450 --- /dev/null +++ b/Lang/Factor/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Factor \ No newline at end of file diff --git a/Lang/Factor/Reverse-a-string b/Lang/Factor/Reverse-a-string new file mode 120000 index 0000000000..c20b1b89f5 --- /dev/null +++ b/Lang/Factor/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Factor \ No newline at end of file diff --git a/Lang/Factor/Roman-numerals-Encode b/Lang/Factor/Roman-numerals-Encode new file mode 120000 index 0000000000..3fd56e2904 --- /dev/null +++ b/Lang/Factor/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Factor \ No newline at end of file diff --git a/Lang/Factor/Roots-of-a-quadratic-function b/Lang/Factor/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..e24d1b3379 --- /dev/null +++ b/Lang/Factor/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/Factor \ No newline at end of file diff --git a/Lang/Factor/Rot-13 b/Lang/Factor/Rot-13 new file mode 120000 index 0000000000..d3a19312cc --- /dev/null +++ b/Lang/Factor/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Factor \ No newline at end of file diff --git a/Lang/Factor/Send-email b/Lang/Factor/Send-email new file mode 120000 index 0000000000..6552b250f5 --- /dev/null +++ b/Lang/Factor/Send-email @@ -0,0 +1 @@ +../../Task/Send-email/Factor \ No newline at end of file diff --git a/Lang/Factor/Set b/Lang/Factor/Set new file mode 120000 index 0000000000..ca232bdc2b --- /dev/null +++ b/Lang/Factor/Set @@ -0,0 +1 @@ +../../Task/Set/Factor \ No newline at end of file diff --git a/Lang/Fan/Roman-numerals-Encode b/Lang/Fan/Roman-numerals-Encode new file mode 120000 index 0000000000..0c61589d6f --- /dev/null +++ b/Lang/Fan/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Fan \ No newline at end of file diff --git a/Lang/Fan/Run-length-encoding b/Lang/Fan/Run-length-encoding new file mode 120000 index 0000000000..6339ce383d --- /dev/null +++ b/Lang/Fan/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Fan \ No newline at end of file diff --git a/Lang/Fancy/Respond-to-an-unknown-method-call b/Lang/Fancy/Respond-to-an-unknown-method-call new file mode 120000 index 0000000000..7c8670c9d7 --- /dev/null +++ b/Lang/Fancy/Respond-to-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Respond-to-an-unknown-method-call/Fancy \ No newline at end of file diff --git a/Lang/Fancy/Reverse-a-string b/Lang/Fancy/Reverse-a-string new file mode 120000 index 0000000000..b38fa925f5 --- /dev/null +++ b/Lang/Fancy/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Fancy \ No newline at end of file diff --git a/Lang/Fantom/Brownian-tree b/Lang/Fantom/Brownian-tree new file mode 120000 index 0000000000..a62c495ad5 --- /dev/null +++ b/Lang/Fantom/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Catalan-numbers b/Lang/Fantom/Catalan-numbers new file mode 120000 index 0000000000..ffe7334047 --- /dev/null +++ b/Lang/Fantom/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Guess-the-number-With-feedback--player- b/Lang/Fantom/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..2941bc5091 --- /dev/null +++ b/Lang/Fantom/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Guess-the-number-With-feedback-player b/Lang/Fantom/Guess-the-number-With-feedback-player deleted file mode 120000 index 75f3d69892..0000000000 --- a/Lang/Fantom/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Null-object b/Lang/Fantom/Null-object new file mode 120000 index 0000000000..331a1f8a0e --- /dev/null +++ b/Lang/Fantom/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Fantom \ No newline at end of file diff --git a/Lang/Fantom/One-dimensional-cellular-automata b/Lang/Fantom/One-dimensional-cellular-automata new file mode 120000 index 0000000000..922d06199f --- /dev/null +++ b/Lang/Fantom/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Palindrome-detection b/Lang/Fantom/Palindrome-detection new file mode 120000 index 0000000000..68759e45bb --- /dev/null +++ b/Lang/Fantom/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Pascals-triangle b/Lang/Fantom/Pascals-triangle new file mode 120000 index 0000000000..29fd03ca6b --- /dev/null +++ b/Lang/Fantom/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Playing-cards b/Lang/Fantom/Playing-cards new file mode 120000 index 0000000000..23f51b2167 --- /dev/null +++ b/Lang/Fantom/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Price-fraction b/Lang/Fantom/Price-fraction new file mode 120000 index 0000000000..745f03b6f5 --- /dev/null +++ b/Lang/Fantom/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Queue-Definition b/Lang/Fantom/Queue-Definition new file mode 120000 index 0000000000..3c7510d6cf --- /dev/null +++ b/Lang/Fantom/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Queue-Usage b/Lang/Fantom/Queue-Usage new file mode 120000 index 0000000000..46765ff233 --- /dev/null +++ b/Lang/Fantom/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Random-numbers b/Lang/Fantom/Random-numbers new file mode 120000 index 0000000000..fcfe45527c --- /dev/null +++ b/Lang/Fantom/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Read-a-configuration-file b/Lang/Fantom/Read-a-configuration-file new file mode 120000 index 0000000000..902651f6eb --- /dev/null +++ b/Lang/Fantom/Read-a-configuration-file @@ -0,0 +1 @@ +../../Task/Read-a-configuration-file/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Read-a-file-line-by-line b/Lang/Fantom/Read-a-file-line-by-line new file mode 120000 index 0000000000..105d5e7346 --- /dev/null +++ b/Lang/Fantom/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Read-entire-file b/Lang/Fantom/Read-entire-file new file mode 120000 index 0000000000..406ac8796b --- /dev/null +++ b/Lang/Fantom/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Real-constants-and-functions b/Lang/Fantom/Real-constants-and-functions new file mode 120000 index 0000000000..01b3e4b56b --- /dev/null +++ b/Lang/Fantom/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Rename-a-file b/Lang/Fantom/Rename-a-file new file mode 120000 index 0000000000..4d08572489 --- /dev/null +++ b/Lang/Fantom/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Respond-to-an-unknown-method-call b/Lang/Fantom/Respond-to-an-unknown-method-call new file mode 120000 index 0000000000..a468a57bd5 --- /dev/null +++ b/Lang/Fantom/Respond-to-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Respond-to-an-unknown-method-call/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Rot-13 b/Lang/Fantom/Rot-13 new file mode 120000 index 0000000000..59a9d97aa0 --- /dev/null +++ b/Lang/Fantom/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Send-email b/Lang/Fantom/Send-email new file mode 120000 index 0000000000..3288d8695b --- /dev/null +++ b/Lang/Fantom/Send-email @@ -0,0 +1 @@ +../../Task/Send-email/Fantom \ No newline at end of file diff --git a/Lang/Fantom/Sequence-of-non-squares b/Lang/Fantom/Sequence-of-non-squares new file mode 120000 index 0000000000..af283ba65e --- /dev/null +++ b/Lang/Fantom/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Fantom \ No newline at end of file diff --git a/Lang/Forth/Binary-digits b/Lang/Forth/Binary-digits new file mode 120000 index 0000000000..1994f64c25 --- /dev/null +++ b/Lang/Forth/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Forth \ No newline at end of file diff --git a/Lang/Forth/Catalan-numbers b/Lang/Forth/Catalan-numbers new file mode 120000 index 0000000000..cb262668c6 --- /dev/null +++ b/Lang/Forth/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Forth \ No newline at end of file diff --git a/Lang/Forth/Copy-a-string b/Lang/Forth/Copy-a-string new file mode 120000 index 0000000000..c52eeb0fa8 --- /dev/null +++ b/Lang/Forth/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Forth \ No newline at end of file diff --git a/Lang/Forth/Dragon-curve b/Lang/Forth/Dragon-curve new file mode 120000 index 0000000000..4aaad31528 --- /dev/null +++ b/Lang/Forth/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/Forth \ No newline at end of file diff --git a/Lang/Forth/Environment-variables b/Lang/Forth/Environment-variables new file mode 120000 index 0000000000..5fcc7e66bb --- /dev/null +++ b/Lang/Forth/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Forth \ No newline at end of file diff --git a/Lang/Forth/N-queens-problem b/Lang/Forth/N-queens-problem new file mode 120000 index 0000000000..a99ae56233 --- /dev/null +++ b/Lang/Forth/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Forth \ No newline at end of file diff --git a/Lang/Forth/Non-decimal-radices-Convert b/Lang/Forth/Non-decimal-radices-Convert new file mode 120000 index 0000000000..583c2a291d --- /dev/null +++ b/Lang/Forth/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/Forth \ No newline at end of file diff --git a/Lang/Forth/Non-decimal-radices-Input b/Lang/Forth/Non-decimal-radices-Input new file mode 120000 index 0000000000..a44de1af80 --- /dev/null +++ b/Lang/Forth/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/Forth \ No newline at end of file diff --git a/Lang/Forth/Non-decimal-radices-Output b/Lang/Forth/Non-decimal-radices-Output new file mode 120000 index 0000000000..0dc247e641 --- /dev/null +++ b/Lang/Forth/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/Forth \ No newline at end of file diff --git a/Lang/Forth/Nth-root b/Lang/Forth/Nth-root new file mode 120000 index 0000000000..1feca8e874 --- /dev/null +++ b/Lang/Forth/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Forth \ No newline at end of file diff --git a/Lang/Forth/Number-reversal-game b/Lang/Forth/Number-reversal-game new file mode 120000 index 0000000000..7acb75bcb9 --- /dev/null +++ b/Lang/Forth/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/Forth \ No newline at end of file diff --git a/Lang/Forth/Numerical-integration b/Lang/Forth/Numerical-integration new file mode 120000 index 0000000000..a4bb939b12 --- /dev/null +++ b/Lang/Forth/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/Forth \ No newline at end of file diff --git a/Lang/Forth/One-dimensional-cellular-automata b/Lang/Forth/One-dimensional-cellular-automata new file mode 120000 index 0000000000..e5366fe134 --- /dev/null +++ b/Lang/Forth/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Forth \ No newline at end of file diff --git a/Lang/Forth/OpenGL b/Lang/Forth/OpenGL new file mode 120000 index 0000000000..c6530053da --- /dev/null +++ b/Lang/Forth/OpenGL @@ -0,0 +1 @@ +../../Task/OpenGL/Forth \ No newline at end of file diff --git a/Lang/Forth/Palindrome-detection b/Lang/Forth/Palindrome-detection new file mode 120000 index 0000000000..1f51d8c7fb --- /dev/null +++ b/Lang/Forth/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Forth \ No newline at end of file diff --git a/Lang/Forth/Pangram-checker b/Lang/Forth/Pangram-checker new file mode 120000 index 0000000000..d42352fae4 --- /dev/null +++ b/Lang/Forth/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Forth \ No newline at end of file diff --git a/Lang/Forth/Pascals-triangle b/Lang/Forth/Pascals-triangle new file mode 120000 index 0000000000..0291c96e75 --- /dev/null +++ b/Lang/Forth/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Forth \ No newline at end of file diff --git a/Lang/Forth/Percentage-difference-between-images b/Lang/Forth/Percentage-difference-between-images new file mode 120000 index 0000000000..a9d4f16f9a --- /dev/null +++ b/Lang/Forth/Percentage-difference-between-images @@ -0,0 +1 @@ +../../Task/Percentage-difference-between-images/Forth \ No newline at end of file diff --git a/Lang/Forth/Perfect-numbers b/Lang/Forth/Perfect-numbers new file mode 120000 index 0000000000..9b56e4c4ae --- /dev/null +++ b/Lang/Forth/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Forth \ No newline at end of file diff --git a/Lang/Forth/Pig-the-dice-game b/Lang/Forth/Pig-the-dice-game new file mode 120000 index 0000000000..5c07f1a09f --- /dev/null +++ b/Lang/Forth/Pig-the-dice-game @@ -0,0 +1 @@ +../../Task/Pig-the-dice-game/Forth \ No newline at end of file diff --git a/Lang/Forth/Playing-cards b/Lang/Forth/Playing-cards new file mode 120000 index 0000000000..d530384716 --- /dev/null +++ b/Lang/Forth/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/Forth \ No newline at end of file diff --git a/Lang/Forth/Polymorphic-copy b/Lang/Forth/Polymorphic-copy new file mode 120000 index 0000000000..b5b826552c --- /dev/null +++ b/Lang/Forth/Polymorphic-copy @@ -0,0 +1 @@ +../../Task/Polymorphic-copy/Forth \ No newline at end of file diff --git a/Lang/Forth/Polymorphism b/Lang/Forth/Polymorphism new file mode 120000 index 0000000000..06c5c1df1f --- /dev/null +++ b/Lang/Forth/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/Forth \ No newline at end of file diff --git a/Lang/Forth/Power-set b/Lang/Forth/Power-set new file mode 120000 index 0000000000..cdad5e07c2 --- /dev/null +++ b/Lang/Forth/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Forth \ No newline at end of file diff --git a/Lang/Forth/Price-fraction b/Lang/Forth/Price-fraction new file mode 120000 index 0000000000..39e1110d80 --- /dev/null +++ b/Lang/Forth/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Forth \ No newline at end of file diff --git a/Lang/Forth/Primality-by-trial-division b/Lang/Forth/Primality-by-trial-division new file mode 120000 index 0000000000..2dcd9a9d28 --- /dev/null +++ b/Lang/Forth/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Forth \ No newline at end of file diff --git a/Lang/Forth/Prime-decomposition b/Lang/Forth/Prime-decomposition new file mode 120000 index 0000000000..e9a0ea937a --- /dev/null +++ b/Lang/Forth/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Forth \ No newline at end of file diff --git a/Lang/Forth/Probabilistic-choice b/Lang/Forth/Probabilistic-choice new file mode 120000 index 0000000000..4b21924127 --- /dev/null +++ b/Lang/Forth/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/Forth \ No newline at end of file diff --git a/Lang/Forth/Program-name b/Lang/Forth/Program-name new file mode 120000 index 0000000000..bd74569bad --- /dev/null +++ b/Lang/Forth/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Forth \ No newline at end of file diff --git a/Lang/Forth/Program-termination b/Lang/Forth/Program-termination new file mode 120000 index 0000000000..eb5bb2bd0b --- /dev/null +++ b/Lang/Forth/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Forth \ No newline at end of file diff --git a/Lang/Forth/Pythagorean-triples b/Lang/Forth/Pythagorean-triples new file mode 120000 index 0000000000..f325763124 --- /dev/null +++ b/Lang/Forth/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/Forth \ No newline at end of file diff --git a/Lang/Forth/Quaternion-type b/Lang/Forth/Quaternion-type new file mode 120000 index 0000000000..bed4c03ac8 --- /dev/null +++ b/Lang/Forth/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/Forth \ No newline at end of file diff --git a/Lang/Forth/Queue-Definition b/Lang/Forth/Queue-Definition new file mode 120000 index 0000000000..b92da6a790 --- /dev/null +++ b/Lang/Forth/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/Forth \ No newline at end of file diff --git a/Lang/Forth/Random-number-generator--device- b/Lang/Forth/Random-number-generator--device- new file mode 120000 index 0000000000..79e01bc351 --- /dev/null +++ b/Lang/Forth/Random-number-generator--device- @@ -0,0 +1 @@ +../../Task/Random-number-generator--device-/Forth \ No newline at end of file diff --git a/Lang/Forth/Random-numbers b/Lang/Forth/Random-numbers new file mode 120000 index 0000000000..6fc18e2388 --- /dev/null +++ b/Lang/Forth/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Forth \ No newline at end of file diff --git a/Lang/Forth/Range-extraction b/Lang/Forth/Range-extraction new file mode 120000 index 0000000000..b2bce5eaa4 --- /dev/null +++ b/Lang/Forth/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/Forth \ No newline at end of file diff --git a/Lang/Forth/Read-a-file-line-by-line b/Lang/Forth/Read-a-file-line-by-line new file mode 120000 index 0000000000..297b6aa197 --- /dev/null +++ b/Lang/Forth/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Forth \ No newline at end of file diff --git a/Lang/Forth/Read-entire-file b/Lang/Forth/Read-entire-file new file mode 120000 index 0000000000..5cbb948812 --- /dev/null +++ b/Lang/Forth/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Forth \ No newline at end of file diff --git a/Lang/Forth/Real-constants-and-functions b/Lang/Forth/Real-constants-and-functions new file mode 120000 index 0000000000..d1476a1a58 --- /dev/null +++ b/Lang/Forth/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Forth \ No newline at end of file diff --git a/Lang/Forth/Regular-expressions b/Lang/Forth/Regular-expressions new file mode 120000 index 0000000000..fbf70c950b --- /dev/null +++ b/Lang/Forth/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Forth \ No newline at end of file diff --git a/Lang/Forth/Remove-duplicate-elements b/Lang/Forth/Remove-duplicate-elements new file mode 120000 index 0000000000..a6867a88f7 --- /dev/null +++ b/Lang/Forth/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Forth \ No newline at end of file diff --git a/Lang/Forth/Rename-a-file b/Lang/Forth/Rename-a-file new file mode 120000 index 0000000000..c28289f814 --- /dev/null +++ b/Lang/Forth/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Forth \ No newline at end of file diff --git a/Lang/Forth/Repeat-a-string b/Lang/Forth/Repeat-a-string new file mode 120000 index 0000000000..e2eded7df8 --- /dev/null +++ b/Lang/Forth/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Forth \ No newline at end of file diff --git a/Lang/Forth/Return-multiple-values b/Lang/Forth/Return-multiple-values new file mode 120000 index 0000000000..6bbbc22bca --- /dev/null +++ b/Lang/Forth/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Forth \ No newline at end of file diff --git a/Lang/Forth/Reverse-a-string b/Lang/Forth/Reverse-a-string new file mode 120000 index 0000000000..b172eafb03 --- /dev/null +++ b/Lang/Forth/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Forth \ No newline at end of file diff --git a/Lang/Forth/Roman-numerals-Decode b/Lang/Forth/Roman-numerals-Decode new file mode 120000 index 0000000000..fa71b7e95c --- /dev/null +++ b/Lang/Forth/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/Forth \ No newline at end of file diff --git a/Lang/Forth/Roman-numerals-Encode b/Lang/Forth/Roman-numerals-Encode new file mode 120000 index 0000000000..fe609a3907 --- /dev/null +++ b/Lang/Forth/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Forth \ No newline at end of file diff --git a/Lang/Forth/Roots-of-a-quadratic-function b/Lang/Forth/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..dd04adc4ed --- /dev/null +++ b/Lang/Forth/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/Forth \ No newline at end of file diff --git a/Lang/Forth/Roots-of-unity b/Lang/Forth/Roots-of-unity new file mode 120000 index 0000000000..3d083d1c39 --- /dev/null +++ b/Lang/Forth/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/Forth \ No newline at end of file diff --git a/Lang/Forth/Rot-13 b/Lang/Forth/Rot-13 new file mode 120000 index 0000000000..946751a956 --- /dev/null +++ b/Lang/Forth/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Forth \ No newline at end of file diff --git a/Lang/Forth/Run-length-encoding b/Lang/Forth/Run-length-encoding new file mode 120000 index 0000000000..c4f0fea38a --- /dev/null +++ b/Lang/Forth/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Forth \ No newline at end of file diff --git a/Lang/Forth/Runtime-evaluation b/Lang/Forth/Runtime-evaluation new file mode 120000 index 0000000000..51c656aeea --- /dev/null +++ b/Lang/Forth/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/Forth \ No newline at end of file diff --git a/Lang/Forth/Runtime-evaluation-In-an-environment b/Lang/Forth/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..24bd285ec2 --- /dev/null +++ b/Lang/Forth/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/Forth \ No newline at end of file diff --git a/Lang/Forth/SEDOLs b/Lang/Forth/SEDOLs new file mode 120000 index 0000000000..bdfaf0b9a0 --- /dev/null +++ b/Lang/Forth/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/Forth \ No newline at end of file diff --git a/Lang/Forth/Self-describing-numbers b/Lang/Forth/Self-describing-numbers new file mode 120000 index 0000000000..405dc33801 --- /dev/null +++ b/Lang/Forth/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/Forth \ No newline at end of file diff --git a/Lang/Forth/Sequence-of-non-squares b/Lang/Forth/Sequence-of-non-squares new file mode 120000 index 0000000000..9ea0c644ba --- /dev/null +++ b/Lang/Forth/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Forth \ No newline at end of file diff --git a/Lang/Fortran/Brownian-tree b/Lang/Fortran/Brownian-tree new file mode 120000 index 0000000000..84a61d2923 --- /dev/null +++ b/Lang/Fortran/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Catalan-numbers b/Lang/Fortran/Catalan-numbers new file mode 120000 index 0000000000..eb3843efc4 --- /dev/null +++ b/Lang/Fortran/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Copy-a-string b/Lang/Fortran/Copy-a-string new file mode 120000 index 0000000000..a0e255b160 --- /dev/null +++ b/Lang/Fortran/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Environment-variables b/Lang/Fortran/Environment-variables new file mode 120000 index 0000000000..8dddf521f8 --- /dev/null +++ b/Lang/Fortran/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Guess-the-number-With-feedback--player- b/Lang/Fortran/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..440486e801 --- /dev/null +++ b/Lang/Fortran/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Guess-the-number-With-feedback-player b/Lang/Fortran/Guess-the-number-With-feedback-player deleted file mode 120000 index 9d1fd8ae65..0000000000 --- a/Lang/Fortran/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/Fortran \ No newline at end of file diff --git a/Lang/Fortran/N-queens-problem b/Lang/Fortran/N-queens-problem new file mode 120000 index 0000000000..63f366bc60 --- /dev/null +++ b/Lang/Fortran/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Named-parameters b/Lang/Fortran/Named-parameters new file mode 120000 index 0000000000..609ca815d6 --- /dev/null +++ b/Lang/Fortran/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Non-decimal-radices-Convert b/Lang/Fortran/Non-decimal-radices-Convert new file mode 120000 index 0000000000..a17232e1be --- /dev/null +++ b/Lang/Fortran/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Non-decimal-radices-Input b/Lang/Fortran/Non-decimal-radices-Input new file mode 120000 index 0000000000..f0a45e10e9 --- /dev/null +++ b/Lang/Fortran/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Non-decimal-radices-Output b/Lang/Fortran/Non-decimal-radices-Output new file mode 120000 index 0000000000..de7304f4b7 --- /dev/null +++ b/Lang/Fortran/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Nth-root b/Lang/Fortran/Nth-root new file mode 120000 index 0000000000..2108fbdfc8 --- /dev/null +++ b/Lang/Fortran/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Number-names b/Lang/Fortran/Number-names new file mode 120000 index 0000000000..4d1b184c25 --- /dev/null +++ b/Lang/Fortran/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Number-reversal-game b/Lang/Fortran/Number-reversal-game new file mode 120000 index 0000000000..9201dbfbf2 --- /dev/null +++ b/Lang/Fortran/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Numerical-integration b/Lang/Fortran/Numerical-integration new file mode 120000 index 0000000000..6b3c284ed2 --- /dev/null +++ b/Lang/Fortran/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/Fortran \ No newline at end of file diff --git a/Lang/Fortran/One-dimensional-cellular-automata b/Lang/Fortran/One-dimensional-cellular-automata new file mode 120000 index 0000000000..1f29b1c158 --- /dev/null +++ b/Lang/Fortran/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Optional-parameters b/Lang/Fortran/Optional-parameters new file mode 120000 index 0000000000..cd65fe5b0b --- /dev/null +++ b/Lang/Fortran/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Palindrome-detection b/Lang/Fortran/Palindrome-detection new file mode 120000 index 0000000000..3547da40e5 --- /dev/null +++ b/Lang/Fortran/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Pangram-checker b/Lang/Fortran/Pangram-checker new file mode 120000 index 0000000000..b14e17d1eb --- /dev/null +++ b/Lang/Fortran/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Pascals-triangle b/Lang/Fortran/Pascals-triangle new file mode 120000 index 0000000000..f1a07a4847 --- /dev/null +++ b/Lang/Fortran/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Percentage-difference-between-images b/Lang/Fortran/Percentage-difference-between-images new file mode 120000 index 0000000000..8c8e5a5b33 --- /dev/null +++ b/Lang/Fortran/Percentage-difference-between-images @@ -0,0 +1 @@ +../../Task/Percentage-difference-between-images/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Perfect-numbers b/Lang/Fortran/Perfect-numbers new file mode 120000 index 0000000000..5220ca263a --- /dev/null +++ b/Lang/Fortran/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Permutations b/Lang/Fortran/Permutations new file mode 120000 index 0000000000..48a5f6b835 --- /dev/null +++ b/Lang/Fortran/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Playing-cards b/Lang/Fortran/Playing-cards new file mode 120000 index 0000000000..c629477ccc --- /dev/null +++ b/Lang/Fortran/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Pointers-and-references b/Lang/Fortran/Pointers-and-references new file mode 120000 index 0000000000..3e0ff6a291 --- /dev/null +++ b/Lang/Fortran/Pointers-and-references @@ -0,0 +1 @@ +../../Task/Pointers-and-references/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Polymorphism b/Lang/Fortran/Polymorphism new file mode 120000 index 0000000000..4d99c77b5a --- /dev/null +++ b/Lang/Fortran/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Polynomial-long-division b/Lang/Fortran/Polynomial-long-division new file mode 120000 index 0000000000..d053137cde --- /dev/null +++ b/Lang/Fortran/Polynomial-long-division @@ -0,0 +1 @@ +../../Task/Polynomial-long-division/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Polynomial-regression b/Lang/Fortran/Polynomial-regression new file mode 120000 index 0000000000..e8b846231d --- /dev/null +++ b/Lang/Fortran/Polynomial-regression @@ -0,0 +1 @@ +../../Task/Polynomial-regression/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Price-fraction b/Lang/Fortran/Price-fraction new file mode 120000 index 0000000000..d47933b78a --- /dev/null +++ b/Lang/Fortran/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Primality-by-trial-division b/Lang/Fortran/Primality-by-trial-division new file mode 120000 index 0000000000..71c32a04ae --- /dev/null +++ b/Lang/Fortran/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Prime-decomposition b/Lang/Fortran/Prime-decomposition new file mode 120000 index 0000000000..e7e654be0e --- /dev/null +++ b/Lang/Fortran/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Probabilistic-choice b/Lang/Fortran/Probabilistic-choice new file mode 120000 index 0000000000..89b75ff846 --- /dev/null +++ b/Lang/Fortran/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Problem-of-Apollonius b/Lang/Fortran/Problem-of-Apollonius new file mode 120000 index 0000000000..a5e20a0678 --- /dev/null +++ b/Lang/Fortran/Problem-of-Apollonius @@ -0,0 +1 @@ +../../Task/Problem-of-Apollonius/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Program-termination b/Lang/Fortran/Program-termination new file mode 120000 index 0000000000..6c2f950f77 --- /dev/null +++ b/Lang/Fortran/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Pythagorean-triples b/Lang/Fortran/Pythagorean-triples new file mode 120000 index 0000000000..589734fd39 --- /dev/null +++ b/Lang/Fortran/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Quaternion-type b/Lang/Fortran/Quaternion-type new file mode 120000 index 0000000000..a1829748df --- /dev/null +++ b/Lang/Fortran/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Queue-Definition b/Lang/Fortran/Queue-Definition new file mode 120000 index 0000000000..7b0d075477 --- /dev/null +++ b/Lang/Fortran/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Queue-Usage b/Lang/Fortran/Queue-Usage new file mode 120000 index 0000000000..833b12e0d1 --- /dev/null +++ b/Lang/Fortran/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Random-numbers b/Lang/Fortran/Random-numbers new file mode 120000 index 0000000000..22ad731d37 --- /dev/null +++ b/Lang/Fortran/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Ray-casting-algorithm b/Lang/Fortran/Ray-casting-algorithm new file mode 120000 index 0000000000..aa9d1c33ff --- /dev/null +++ b/Lang/Fortran/Ray-casting-algorithm @@ -0,0 +1 @@ +../../Task/Ray-casting-algorithm/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Real-constants-and-functions b/Lang/Fortran/Real-constants-and-functions new file mode 120000 index 0000000000..a8e381d8b6 --- /dev/null +++ b/Lang/Fortran/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Reduced-row-echelon-form b/Lang/Fortran/Reduced-row-echelon-form new file mode 120000 index 0000000000..4fa582a9ea --- /dev/null +++ b/Lang/Fortran/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Remove-duplicate-elements b/Lang/Fortran/Remove-duplicate-elements new file mode 120000 index 0000000000..c80c46e678 --- /dev/null +++ b/Lang/Fortran/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Rename-a-file b/Lang/Fortran/Rename-a-file new file mode 120000 index 0000000000..0230202899 --- /dev/null +++ b/Lang/Fortran/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Repeat-a-string b/Lang/Fortran/Repeat-a-string new file mode 120000 index 0000000000..ad613a9802 --- /dev/null +++ b/Lang/Fortran/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Reverse-a-string b/Lang/Fortran/Reverse-a-string new file mode 120000 index 0000000000..01f72bdb65 --- /dev/null +++ b/Lang/Fortran/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Roman-numerals-Decode b/Lang/Fortran/Roman-numerals-Decode new file mode 120000 index 0000000000..62797490c5 --- /dev/null +++ b/Lang/Fortran/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Roman-numerals-Encode b/Lang/Fortran/Roman-numerals-Encode new file mode 120000 index 0000000000..b1fe7fb128 --- /dev/null +++ b/Lang/Fortran/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Roots-of-a-function b/Lang/Fortran/Roots-of-a-function new file mode 120000 index 0000000000..a57b9a319a --- /dev/null +++ b/Lang/Fortran/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Roots-of-a-quadratic-function b/Lang/Fortran/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..ace0672100 --- /dev/null +++ b/Lang/Fortran/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Roots-of-unity b/Lang/Fortran/Roots-of-unity new file mode 120000 index 0000000000..2e97bec0ec --- /dev/null +++ b/Lang/Fortran/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Rot-13 b/Lang/Fortran/Rot-13 new file mode 120000 index 0000000000..2ecaed415f --- /dev/null +++ b/Lang/Fortran/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Run-length-encoding b/Lang/Fortran/Run-length-encoding new file mode 120000 index 0000000000..644b166f8f --- /dev/null +++ b/Lang/Fortran/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Fortran \ No newline at end of file diff --git a/Lang/Fortran/SEDOLs b/Lang/Fortran/SEDOLs new file mode 120000 index 0000000000..a1b9c6071c --- /dev/null +++ b/Lang/Fortran/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/Fortran \ No newline at end of file diff --git a/Lang/Fortran/Sequence-of-non-squares b/Lang/Fortran/Sequence-of-non-squares new file mode 120000 index 0000000000..a3d758d454 --- /dev/null +++ b/Lang/Fortran/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Fortran \ No newline at end of file diff --git a/Lang/Frink/Arbitrary-precision-integers--included- b/Lang/Frink/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..d6406950b2 --- /dev/null +++ b/Lang/Frink/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Frink \ No newline at end of file diff --git a/Lang/Frink/Arbitrary-precision-integers-included b/Lang/Frink/Arbitrary-precision-integers-included deleted file mode 120000 index 0485370d60..0000000000 --- a/Lang/Frink/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Frink \ No newline at end of file diff --git a/Lang/Frink/Catalan-numbers b/Lang/Frink/Catalan-numbers new file mode 120000 index 0000000000..8e3fa533fa --- /dev/null +++ b/Lang/Frink/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Frink \ No newline at end of file diff --git a/Lang/Frink/Power-set b/Lang/Frink/Power-set new file mode 120000 index 0000000000..6537e0517c --- /dev/null +++ b/Lang/Frink/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Frink \ No newline at end of file diff --git a/Lang/Frink/Prime-decomposition b/Lang/Frink/Prime-decomposition new file mode 120000 index 0000000000..6d2face2cc --- /dev/null +++ b/Lang/Frink/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Frink \ No newline at end of file diff --git a/Lang/Frink/Read-a-file-line-by-line b/Lang/Frink/Read-a-file-line-by-line new file mode 120000 index 0000000000..418a6affd1 --- /dev/null +++ b/Lang/Frink/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Frink \ No newline at end of file diff --git a/Lang/Frink/Read-entire-file b/Lang/Frink/Read-entire-file new file mode 120000 index 0000000000..f8d83ec44d --- /dev/null +++ b/Lang/Frink/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Frink \ No newline at end of file diff --git a/Lang/Frink/Regular-expressions b/Lang/Frink/Regular-expressions new file mode 120000 index 0000000000..7a31f9b2cb --- /dev/null +++ b/Lang/Frink/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Frink \ No newline at end of file diff --git a/Lang/Frink/Repeat-a-string b/Lang/Frink/Repeat-a-string new file mode 120000 index 0000000000..153ac2e1c5 --- /dev/null +++ b/Lang/Frink/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Frink \ No newline at end of file diff --git a/Lang/Frink/Reverse-a-string b/Lang/Frink/Reverse-a-string new file mode 120000 index 0000000000..245c4d445b --- /dev/null +++ b/Lang/Frink/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Frink \ No newline at end of file diff --git a/Lang/GAP/Arbitrary-precision-integers--included- b/Lang/GAP/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..7d27dfbed3 --- /dev/null +++ b/Lang/GAP/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/GAP \ No newline at end of file diff --git a/Lang/GAP/Arbitrary-precision-integers-included b/Lang/GAP/Arbitrary-precision-integers-included deleted file mode 120000 index 4c2035fa64..0000000000 --- a/Lang/GAP/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/GAP \ No newline at end of file diff --git a/Lang/GAP/Catalan-numbers b/Lang/GAP/Catalan-numbers new file mode 120000 index 0000000000..1e0dd396f1 --- /dev/null +++ b/Lang/GAP/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/GAP \ No newline at end of file diff --git a/Lang/GAP/Copy-a-string b/Lang/GAP/Copy-a-string new file mode 120000 index 0000000000..fdd13d1f61 --- /dev/null +++ b/Lang/GAP/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/GAP \ No newline at end of file diff --git a/Lang/GAP/Ordered-Partitions b/Lang/GAP/Ordered-Partitions new file mode 120000 index 0000000000..f5b670ca90 --- /dev/null +++ b/Lang/GAP/Ordered-Partitions @@ -0,0 +1 @@ +../../Task/Ordered-Partitions/GAP \ No newline at end of file diff --git a/Lang/GAP/Palindrome-detection b/Lang/GAP/Palindrome-detection new file mode 120000 index 0000000000..eb5317bf87 --- /dev/null +++ b/Lang/GAP/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/GAP \ No newline at end of file diff --git a/Lang/GAP/Pascals-triangle b/Lang/GAP/Pascals-triangle new file mode 120000 index 0000000000..d57f507284 --- /dev/null +++ b/Lang/GAP/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/GAP \ No newline at end of file diff --git a/Lang/GAP/Perfect-numbers b/Lang/GAP/Perfect-numbers new file mode 120000 index 0000000000..3145008789 --- /dev/null +++ b/Lang/GAP/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/GAP \ No newline at end of file diff --git a/Lang/GAP/Permutation-test b/Lang/GAP/Permutation-test new file mode 120000 index 0000000000..415542fa3e --- /dev/null +++ b/Lang/GAP/Permutation-test @@ -0,0 +1 @@ +../../Task/Permutation-test/GAP \ No newline at end of file diff --git a/Lang/GAP/Permutations b/Lang/GAP/Permutations new file mode 120000 index 0000000000..08c5d20a5f --- /dev/null +++ b/Lang/GAP/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/GAP \ No newline at end of file diff --git a/Lang/GAP/Permutations-Derangements b/Lang/GAP/Permutations-Derangements new file mode 120000 index 0000000000..20899289e5 --- /dev/null +++ b/Lang/GAP/Permutations-Derangements @@ -0,0 +1 @@ +../../Task/Permutations-Derangements/GAP \ No newline at end of file diff --git a/Lang/GAP/Polynomial-long-division b/Lang/GAP/Polynomial-long-division new file mode 120000 index 0000000000..fda11dde19 --- /dev/null +++ b/Lang/GAP/Polynomial-long-division @@ -0,0 +1 @@ +../../Task/Polynomial-long-division/GAP \ No newline at end of file diff --git a/Lang/GAP/Polynomial-regression b/Lang/GAP/Polynomial-regression new file mode 120000 index 0000000000..9d7f092e55 --- /dev/null +++ b/Lang/GAP/Polynomial-regression @@ -0,0 +1 @@ +../../Task/Polynomial-regression/GAP \ No newline at end of file diff --git a/Lang/GAP/Power-set b/Lang/GAP/Power-set new file mode 120000 index 0000000000..7e044d8963 --- /dev/null +++ b/Lang/GAP/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/GAP \ No newline at end of file diff --git a/Lang/GAP/Primality-by-trial-division b/Lang/GAP/Primality-by-trial-division new file mode 120000 index 0000000000..887e566636 --- /dev/null +++ b/Lang/GAP/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/GAP \ No newline at end of file diff --git a/Lang/GAP/Prime-decomposition b/Lang/GAP/Prime-decomposition new file mode 120000 index 0000000000..7d7050e51d --- /dev/null +++ b/Lang/GAP/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/GAP \ No newline at end of file diff --git a/Lang/GAP/Quaternion-type b/Lang/GAP/Quaternion-type new file mode 120000 index 0000000000..67ec7fa115 --- /dev/null +++ b/Lang/GAP/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/GAP \ No newline at end of file diff --git a/Lang/GAP/Queue-Definition b/Lang/GAP/Queue-Definition new file mode 120000 index 0000000000..dd38d5b43f --- /dev/null +++ b/Lang/GAP/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/GAP \ No newline at end of file diff --git a/Lang/GAP/Random-number-generator--included- b/Lang/GAP/Random-number-generator--included- new file mode 120000 index 0000000000..fc7287a6bd --- /dev/null +++ b/Lang/GAP/Random-number-generator--included- @@ -0,0 +1 @@ +../../Task/Random-number-generator--included-/GAP \ No newline at end of file diff --git a/Lang/GAP/Read-a-file-line-by-line b/Lang/GAP/Read-a-file-line-by-line new file mode 120000 index 0000000000..c70e97306c --- /dev/null +++ b/Lang/GAP/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/GAP \ No newline at end of file diff --git a/Lang/GAP/Read-entire-file b/Lang/GAP/Read-entire-file new file mode 120000 index 0000000000..0e98334a51 --- /dev/null +++ b/Lang/GAP/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/GAP \ No newline at end of file diff --git a/Lang/GAP/Remove-duplicate-elements b/Lang/GAP/Remove-duplicate-elements new file mode 120000 index 0000000000..28df366cac --- /dev/null +++ b/Lang/GAP/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/GAP \ No newline at end of file diff --git a/Lang/GAP/Repeat-a-string b/Lang/GAP/Repeat-a-string new file mode 120000 index 0000000000..d3311611bd --- /dev/null +++ b/Lang/GAP/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/GAP \ No newline at end of file diff --git a/Lang/GAP/Reverse-a-string b/Lang/GAP/Reverse-a-string new file mode 120000 index 0000000000..2615d1fc09 --- /dev/null +++ b/Lang/GAP/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/GAP \ No newline at end of file diff --git a/Lang/GAP/Roots-of-a-quadratic-function b/Lang/GAP/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..3aea2bc17a --- /dev/null +++ b/Lang/GAP/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/GAP \ No newline at end of file diff --git a/Lang/GAP/Roots-of-unity b/Lang/GAP/Roots-of-unity new file mode 120000 index 0000000000..97feb836dd --- /dev/null +++ b/Lang/GAP/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/GAP \ No newline at end of file diff --git a/Lang/GAP/Rot-13 b/Lang/GAP/Rot-13 new file mode 120000 index 0000000000..2a2d0a0272 --- /dev/null +++ b/Lang/GAP/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/GAP \ No newline at end of file diff --git a/Lang/GAP/Sequence-of-non-squares b/Lang/GAP/Sequence-of-non-squares new file mode 120000 index 0000000000..ff06aeac3d --- /dev/null +++ b/Lang/GAP/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/GAP \ No newline at end of file diff --git a/Lang/GML/Copy-a-string b/Lang/GML/Copy-a-string new file mode 120000 index 0000000000..834af96646 --- /dev/null +++ b/Lang/GML/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/GML \ No newline at end of file diff --git a/Lang/GML/Palindrome-detection b/Lang/GML/Palindrome-detection new file mode 120000 index 0000000000..b98dabf5e8 --- /dev/null +++ b/Lang/GML/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/GML \ No newline at end of file diff --git a/Lang/GML/Rot-13 b/Lang/GML/Rot-13 new file mode 120000 index 0000000000..63e676426c --- /dev/null +++ b/Lang/GML/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/GML \ No newline at end of file diff --git a/Lang/GUISS/Calendar---for-real-programmers b/Lang/GUISS/Calendar---for-real-programmers new file mode 120000 index 0000000000..77e9bfb78a --- /dev/null +++ b/Lang/GUISS/Calendar---for-real-programmers @@ -0,0 +1 @@ +../../Task/Calendar---for-real-programmers/GUISS \ No newline at end of file diff --git a/Lang/GUISS/Calendar-for-real-programmers b/Lang/GUISS/Calendar-for-real-programmers deleted file mode 120000 index f45128fad9..0000000000 --- a/Lang/GUISS/Calendar-for-real-programmers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Calendar-for-real-programmers/GUISS \ No newline at end of file diff --git a/Lang/GUISS/Copy-a-string b/Lang/GUISS/Copy-a-string new file mode 120000 index 0000000000..9b90394ee9 --- /dev/null +++ b/Lang/GUISS/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/GUISS \ No newline at end of file diff --git a/Lang/GUISS/Play-recorded-sounds b/Lang/GUISS/Play-recorded-sounds new file mode 120000 index 0000000000..87490e3dcf --- /dev/null +++ b/Lang/GUISS/Play-recorded-sounds @@ -0,0 +1 @@ +../../Task/Play-recorded-sounds/GUISS \ No newline at end of file diff --git a/Lang/GUISS/Read-entire-file b/Lang/GUISS/Read-entire-file new file mode 120000 index 0000000000..827c272118 --- /dev/null +++ b/Lang/GUISS/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/GUISS \ No newline at end of file diff --git a/Lang/GUISS/Record-sound b/Lang/GUISS/Record-sound new file mode 120000 index 0000000000..83b3a73ff7 --- /dev/null +++ b/Lang/GUISS/Record-sound @@ -0,0 +1 @@ +../../Task/Record-sound/GUISS \ No newline at end of file diff --git a/Lang/GW-BASIC/Pascals-triangle b/Lang/GW-BASIC/Pascals-triangle new file mode 120000 index 0000000000..e231617c39 --- /dev/null +++ b/Lang/GW-BASIC/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/GW-BASIC \ No newline at end of file diff --git a/Lang/GW-BASIC/Program-termination b/Lang/GW-BASIC/Program-termination new file mode 120000 index 0000000000..bac6d4f63e --- /dev/null +++ b/Lang/GW-BASIC/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/GW-BASIC \ No newline at end of file diff --git a/Lang/GW-BASIC/Rot-13 b/Lang/GW-BASIC/Rot-13 new file mode 120000 index 0000000000..2058833bd7 --- /dev/null +++ b/Lang/GW-BASIC/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/GW-BASIC \ No newline at end of file diff --git a/Lang/GW-BASIC/Runtime-evaluation b/Lang/GW-BASIC/Runtime-evaluation new file mode 120000 index 0000000000..4d5973cfd2 --- /dev/null +++ b/Lang/GW-BASIC/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/GW-BASIC \ No newline at end of file diff --git a/Lang/Gambas/Copy-a-string b/Lang/Gambas/Copy-a-string new file mode 120000 index 0000000000..bb073b360c --- /dev/null +++ b/Lang/Gambas/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Gambas \ No newline at end of file diff --git a/Lang/Gema/Non-decimal-radices-Output b/Lang/Gema/Non-decimal-radices-Output new file mode 120000 index 0000000000..f743eec786 --- /dev/null +++ b/Lang/Gema/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/Gema \ No newline at end of file diff --git a/Lang/Gema/Program-termination b/Lang/Gema/Program-termination new file mode 120000 index 0000000000..74feb7c7aa --- /dev/null +++ b/Lang/Gema/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Gema \ No newline at end of file diff --git a/Lang/Gema/Reverse-a-string b/Lang/Gema/Reverse-a-string new file mode 120000 index 0000000000..7e260aa4da --- /dev/null +++ b/Lang/Gema/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Gema \ No newline at end of file diff --git a/Lang/Gema/Rot-13 b/Lang/Gema/Rot-13 new file mode 120000 index 0000000000..9e48f6aadf --- /dev/null +++ b/Lang/Gema/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Gema \ No newline at end of file diff --git a/Lang/Genyris/Runtime-evaluation-In-an-environment b/Lang/Genyris/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..b94fbbf6aa --- /dev/null +++ b/Lang/Genyris/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/Genyris \ No newline at end of file diff --git a/Lang/Go/Arbitrary-precision-integers--included- b/Lang/Go/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..1e95070754 --- /dev/null +++ b/Lang/Go/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Go \ No newline at end of file diff --git a/Lang/Go/Arbitrary-precision-integers-included b/Lang/Go/Arbitrary-precision-integers-included deleted file mode 120000 index d4f44f5c8f..0000000000 --- a/Lang/Go/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Go \ No newline at end of file diff --git a/Lang/Go/Binary-digits b/Lang/Go/Binary-digits new file mode 120000 index 0000000000..1f36fe3d7c --- /dev/null +++ b/Lang/Go/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Go \ No newline at end of file diff --git a/Lang/Go/Brownian-tree b/Lang/Go/Brownian-tree new file mode 120000 index 0000000000..f85e9322ad --- /dev/null +++ b/Lang/Go/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/Go \ No newline at end of file diff --git a/Lang/Go/Catalan-numbers b/Lang/Go/Catalan-numbers new file mode 120000 index 0000000000..5c6b4eae83 --- /dev/null +++ b/Lang/Go/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Go \ No newline at end of file diff --git a/Lang/Go/Copy-a-string b/Lang/Go/Copy-a-string new file mode 120000 index 0000000000..c5b56bf87b --- /dev/null +++ b/Lang/Go/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Go \ No newline at end of file diff --git a/Lang/Go/Dragon-curve b/Lang/Go/Dragon-curve new file mode 120000 index 0000000000..bb69524487 --- /dev/null +++ b/Lang/Go/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/Go \ No newline at end of file diff --git a/Lang/Go/Environment-variables b/Lang/Go/Environment-variables new file mode 120000 index 0000000000..7e24eef948 --- /dev/null +++ b/Lang/Go/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Go \ No newline at end of file diff --git a/Lang/Go/Execute-a-Markov-algorithm b/Lang/Go/Execute-a-Markov-algorithm new file mode 120000 index 0000000000..2e5f7ca6a1 --- /dev/null +++ b/Lang/Go/Execute-a-Markov-algorithm @@ -0,0 +1 @@ +../../Task/Execute-a-Markov-algorithm/Go \ No newline at end of file diff --git a/Lang/Go/Guess-the-number-With-feedback--player- b/Lang/Go/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..b8781aaa2f --- /dev/null +++ b/Lang/Go/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/Go \ No newline at end of file diff --git a/Lang/Go/Guess-the-number-With-feedback-player b/Lang/Go/Guess-the-number-With-feedback-player deleted file mode 120000 index a1dc313ac4..0000000000 --- a/Lang/Go/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/Go \ No newline at end of file diff --git a/Lang/Go/N-queens-problem b/Lang/Go/N-queens-problem new file mode 120000 index 0000000000..f70780bfad --- /dev/null +++ b/Lang/Go/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Go \ No newline at end of file diff --git a/Lang/Go/Non-continuous-subsequences b/Lang/Go/Non-continuous-subsequences new file mode 120000 index 0000000000..10a6cad1d2 --- /dev/null +++ b/Lang/Go/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/Go \ No newline at end of file diff --git a/Lang/Go/Non-decimal-radices-Convert b/Lang/Go/Non-decimal-radices-Convert new file mode 120000 index 0000000000..666cd21961 --- /dev/null +++ b/Lang/Go/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/Go \ No newline at end of file diff --git a/Lang/Go/Non-decimal-radices-Input b/Lang/Go/Non-decimal-radices-Input new file mode 120000 index 0000000000..e28e5df111 --- /dev/null +++ b/Lang/Go/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/Go \ No newline at end of file diff --git a/Lang/Go/Non-decimal-radices-Output b/Lang/Go/Non-decimal-radices-Output new file mode 120000 index 0000000000..ae1a8b0ca9 --- /dev/null +++ b/Lang/Go/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/Go \ No newline at end of file diff --git a/Lang/Go/Nth-root b/Lang/Go/Nth-root new file mode 120000 index 0000000000..a8e30aad55 --- /dev/null +++ b/Lang/Go/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Go \ No newline at end of file diff --git a/Lang/Go/Null-object b/Lang/Go/Null-object new file mode 120000 index 0000000000..6acfdfe978 --- /dev/null +++ b/Lang/Go/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Go \ No newline at end of file diff --git a/Lang/Go/Number-names b/Lang/Go/Number-names new file mode 120000 index 0000000000..1ded3c587b --- /dev/null +++ b/Lang/Go/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/Go \ No newline at end of file diff --git a/Lang/Go/Number-reversal-game b/Lang/Go/Number-reversal-game new file mode 120000 index 0000000000..01c881e74c --- /dev/null +++ b/Lang/Go/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/Go \ No newline at end of file diff --git a/Lang/Go/Numeric-error-propagation b/Lang/Go/Numeric-error-propagation new file mode 120000 index 0000000000..60286b89fd --- /dev/null +++ b/Lang/Go/Numeric-error-propagation @@ -0,0 +1 @@ +../../Task/Numeric-error-propagation/Go \ No newline at end of file diff --git a/Lang/Go/Numerical-integration b/Lang/Go/Numerical-integration new file mode 120000 index 0000000000..ec0b8e9f56 --- /dev/null +++ b/Lang/Go/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/Go \ No newline at end of file diff --git a/Lang/Go/Numerical-integration-Gauss-Legendre-Quadrature b/Lang/Go/Numerical-integration-Gauss-Legendre-Quadrature new file mode 120000 index 0000000000..acca0d7860 --- /dev/null +++ b/Lang/Go/Numerical-integration-Gauss-Legendre-Quadrature @@ -0,0 +1 @@ +../../Task/Numerical-integration-Gauss-Legendre-Quadrature/Go \ No newline at end of file diff --git a/Lang/Go/Object-serialization b/Lang/Go/Object-serialization new file mode 120000 index 0000000000..c2357cd4f7 --- /dev/null +++ b/Lang/Go/Object-serialization @@ -0,0 +1 @@ +../../Task/Object-serialization/Go \ No newline at end of file diff --git a/Lang/Go/One-dimensional-cellular-automata b/Lang/Go/One-dimensional-cellular-automata new file mode 120000 index 0000000000..752413f2ac --- /dev/null +++ b/Lang/Go/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Go \ No newline at end of file diff --git a/Lang/Go/One-of-n-lines-in-a-file b/Lang/Go/One-of-n-lines-in-a-file new file mode 120000 index 0000000000..6796e3dc01 --- /dev/null +++ b/Lang/Go/One-of-n-lines-in-a-file @@ -0,0 +1 @@ +../../Task/One-of-n-lines-in-a-file/Go \ No newline at end of file diff --git a/Lang/Go/Optional-parameters b/Lang/Go/Optional-parameters new file mode 120000 index 0000000000..9721f2e951 --- /dev/null +++ b/Lang/Go/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/Go \ No newline at end of file diff --git a/Lang/Go/Order-two-numerical-lists b/Lang/Go/Order-two-numerical-lists new file mode 120000 index 0000000000..ff5ae66146 --- /dev/null +++ b/Lang/Go/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/Go \ No newline at end of file diff --git a/Lang/Go/Ordered-Partitions b/Lang/Go/Ordered-Partitions new file mode 120000 index 0000000000..512bad56c8 --- /dev/null +++ b/Lang/Go/Ordered-Partitions @@ -0,0 +1 @@ +../../Task/Ordered-Partitions/Go \ No newline at end of file diff --git a/Lang/Go/Palindrome-detection b/Lang/Go/Palindrome-detection new file mode 120000 index 0000000000..8fded24ac9 --- /dev/null +++ b/Lang/Go/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Go \ No newline at end of file diff --git a/Lang/Go/Pangram-checker b/Lang/Go/Pangram-checker new file mode 120000 index 0000000000..0f26510eed --- /dev/null +++ b/Lang/Go/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Go \ No newline at end of file diff --git a/Lang/Go/Parallel-calculations b/Lang/Go/Parallel-calculations new file mode 120000 index 0000000000..e2e7692615 --- /dev/null +++ b/Lang/Go/Parallel-calculations @@ -0,0 +1 @@ +../../Task/Parallel-calculations/Go \ No newline at end of file diff --git a/Lang/Go/Parametric-polymorphism b/Lang/Go/Parametric-polymorphism new file mode 120000 index 0000000000..66e4df675a --- /dev/null +++ b/Lang/Go/Parametric-polymorphism @@ -0,0 +1 @@ +../../Task/Parametric-polymorphism/Go \ No newline at end of file diff --git a/Lang/Go/Parsing-RPN-calculator-algorithm b/Lang/Go/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..cf89fc8b84 --- /dev/null +++ b/Lang/Go/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/Go \ No newline at end of file diff --git a/Lang/Go/Parsing-RPN-to-infix-conversion b/Lang/Go/Parsing-RPN-to-infix-conversion new file mode 120000 index 0000000000..00eb53aa7c --- /dev/null +++ b/Lang/Go/Parsing-RPN-to-infix-conversion @@ -0,0 +1 @@ +../../Task/Parsing-RPN-to-infix-conversion/Go \ No newline at end of file diff --git a/Lang/Go/Parsing-Shunting-yard-algorithm b/Lang/Go/Parsing-Shunting-yard-algorithm new file mode 120000 index 0000000000..e0a91205cf --- /dev/null +++ b/Lang/Go/Parsing-Shunting-yard-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-Shunting-yard-algorithm/Go \ No newline at end of file diff --git a/Lang/Go/Pascals-triangle b/Lang/Go/Pascals-triangle new file mode 120000 index 0000000000..00c685dd36 --- /dev/null +++ b/Lang/Go/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Go \ No newline at end of file diff --git a/Lang/Go/Pascals-triangle-Puzzle b/Lang/Go/Pascals-triangle-Puzzle new file mode 120000 index 0000000000..f384f3ecb5 --- /dev/null +++ b/Lang/Go/Pascals-triangle-Puzzle @@ -0,0 +1 @@ +../../Task/Pascals-triangle-Puzzle/Go \ No newline at end of file diff --git a/Lang/Go/Percentage-difference-between-images b/Lang/Go/Percentage-difference-between-images new file mode 120000 index 0000000000..5a13e9862b --- /dev/null +++ b/Lang/Go/Percentage-difference-between-images @@ -0,0 +1 @@ +../../Task/Percentage-difference-between-images/Go \ No newline at end of file diff --git a/Lang/Go/Perfect-numbers b/Lang/Go/Perfect-numbers new file mode 120000 index 0000000000..6b90ef805f --- /dev/null +++ b/Lang/Go/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Go \ No newline at end of file diff --git a/Lang/Go/Permutation-test b/Lang/Go/Permutation-test new file mode 120000 index 0000000000..5deb9767c8 --- /dev/null +++ b/Lang/Go/Permutation-test @@ -0,0 +1 @@ +../../Task/Permutation-test/Go \ No newline at end of file diff --git a/Lang/Go/Permutations b/Lang/Go/Permutations new file mode 120000 index 0000000000..5cf9b1d4d3 --- /dev/null +++ b/Lang/Go/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Go \ No newline at end of file diff --git a/Lang/Go/Permutations-Derangements b/Lang/Go/Permutations-Derangements new file mode 120000 index 0000000000..3ebed64f58 --- /dev/null +++ b/Lang/Go/Permutations-Derangements @@ -0,0 +1 @@ +../../Task/Permutations-Derangements/Go \ No newline at end of file diff --git a/Lang/Go/Pick-random-element b/Lang/Go/Pick-random-element new file mode 120000 index 0000000000..ae0fdceeae --- /dev/null +++ b/Lang/Go/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/Go \ No newline at end of file diff --git a/Lang/Go/Pig-the-dice-game-Player b/Lang/Go/Pig-the-dice-game-Player new file mode 120000 index 0000000000..c5dedf7732 --- /dev/null +++ b/Lang/Go/Pig-the-dice-game-Player @@ -0,0 +1 @@ +../../Task/Pig-the-dice-game-Player/Go \ No newline at end of file diff --git a/Lang/Go/Playing-cards b/Lang/Go/Playing-cards new file mode 120000 index 0000000000..fe794b501d --- /dev/null +++ b/Lang/Go/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/Go \ No newline at end of file diff --git a/Lang/Go/Pointers-and-references b/Lang/Go/Pointers-and-references new file mode 120000 index 0000000000..26cae4b786 --- /dev/null +++ b/Lang/Go/Pointers-and-references @@ -0,0 +1 @@ +../../Task/Pointers-and-references/Go \ No newline at end of file diff --git a/Lang/Go/Polymorphic-copy b/Lang/Go/Polymorphic-copy new file mode 120000 index 0000000000..7014cb373f --- /dev/null +++ b/Lang/Go/Polymorphic-copy @@ -0,0 +1 @@ +../../Task/Polymorphic-copy/Go \ No newline at end of file diff --git a/Lang/Go/Polymorphism b/Lang/Go/Polymorphism new file mode 120000 index 0000000000..eb369b71a5 --- /dev/null +++ b/Lang/Go/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/Go \ No newline at end of file diff --git a/Lang/Go/Polynomial-long-division b/Lang/Go/Polynomial-long-division new file mode 120000 index 0000000000..6932c734bc --- /dev/null +++ b/Lang/Go/Polynomial-long-division @@ -0,0 +1 @@ +../../Task/Polynomial-long-division/Go \ No newline at end of file diff --git a/Lang/Go/Polynomial-regression b/Lang/Go/Polynomial-regression new file mode 120000 index 0000000000..2026d70bfc --- /dev/null +++ b/Lang/Go/Polynomial-regression @@ -0,0 +1 @@ +../../Task/Polynomial-regression/Go \ No newline at end of file diff --git a/Lang/Go/Power-set b/Lang/Go/Power-set new file mode 120000 index 0000000000..16def5d1e8 --- /dev/null +++ b/Lang/Go/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Go \ No newline at end of file diff --git a/Lang/Go/Pragmatic-directives b/Lang/Go/Pragmatic-directives new file mode 120000 index 0000000000..433a77a48b --- /dev/null +++ b/Lang/Go/Pragmatic-directives @@ -0,0 +1 @@ +../../Task/Pragmatic-directives/Go \ No newline at end of file diff --git a/Lang/Go/Price-fraction b/Lang/Go/Price-fraction new file mode 120000 index 0000000000..c044e83cd6 --- /dev/null +++ b/Lang/Go/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Go \ No newline at end of file diff --git a/Lang/Go/Primality-by-trial-division b/Lang/Go/Primality-by-trial-division new file mode 120000 index 0000000000..23dffe3320 --- /dev/null +++ b/Lang/Go/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Go \ No newline at end of file diff --git a/Lang/Go/Prime-decomposition b/Lang/Go/Prime-decomposition new file mode 120000 index 0000000000..28938a2587 --- /dev/null +++ b/Lang/Go/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Go \ No newline at end of file diff --git a/Lang/Go/Priority-queue b/Lang/Go/Priority-queue new file mode 120000 index 0000000000..a62d156dac --- /dev/null +++ b/Lang/Go/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/Go \ No newline at end of file diff --git a/Lang/Go/Probabilistic-choice b/Lang/Go/Probabilistic-choice new file mode 120000 index 0000000000..3fbf2e7a4f --- /dev/null +++ b/Lang/Go/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/Go \ No newline at end of file diff --git a/Lang/Go/Problem-of-Apollonius b/Lang/Go/Problem-of-Apollonius new file mode 120000 index 0000000000..87b7f733b0 --- /dev/null +++ b/Lang/Go/Problem-of-Apollonius @@ -0,0 +1 @@ +../../Task/Problem-of-Apollonius/Go \ No newline at end of file diff --git a/Lang/Go/Program-name b/Lang/Go/Program-name new file mode 120000 index 0000000000..41d3a8adc4 --- /dev/null +++ b/Lang/Go/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Go \ No newline at end of file diff --git a/Lang/Go/Program-termination b/Lang/Go/Program-termination new file mode 120000 index 0000000000..48f7f0a4a3 --- /dev/null +++ b/Lang/Go/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Go \ No newline at end of file diff --git a/Lang/Go/Pythagorean-triples b/Lang/Go/Pythagorean-triples new file mode 120000 index 0000000000..1dced0c273 --- /dev/null +++ b/Lang/Go/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/Go \ No newline at end of file diff --git a/Lang/Go/QR-decomposition b/Lang/Go/QR-decomposition new file mode 120000 index 0000000000..4319be970e --- /dev/null +++ b/Lang/Go/QR-decomposition @@ -0,0 +1 @@ +../../Task/QR-decomposition/Go \ No newline at end of file diff --git a/Lang/Go/Quaternion-type b/Lang/Go/Quaternion-type new file mode 120000 index 0000000000..e62c595975 --- /dev/null +++ b/Lang/Go/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/Go \ No newline at end of file diff --git a/Lang/Go/Queue-Definition b/Lang/Go/Queue-Definition new file mode 120000 index 0000000000..e823f8ca70 --- /dev/null +++ b/Lang/Go/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/Go \ No newline at end of file diff --git a/Lang/Go/Queue-Usage b/Lang/Go/Queue-Usage new file mode 120000 index 0000000000..f22d8ee508 --- /dev/null +++ b/Lang/Go/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/Go \ No newline at end of file diff --git a/Lang/Go/RIPEMD-160 b/Lang/Go/RIPEMD-160 new file mode 120000 index 0000000000..0b7a3d0c21 --- /dev/null +++ b/Lang/Go/RIPEMD-160 @@ -0,0 +1 @@ +../../Task/RIPEMD-160/Go \ No newline at end of file diff --git a/Lang/Go/Random-number-generator--device- b/Lang/Go/Random-number-generator--device- new file mode 120000 index 0000000000..fe7f860617 --- /dev/null +++ b/Lang/Go/Random-number-generator--device- @@ -0,0 +1 @@ +../../Task/Random-number-generator--device-/Go \ No newline at end of file diff --git a/Lang/Go/Random-numbers b/Lang/Go/Random-numbers new file mode 120000 index 0000000000..2f5464fe09 --- /dev/null +++ b/Lang/Go/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Go \ No newline at end of file diff --git a/Lang/Go/Range-expansion b/Lang/Go/Range-expansion new file mode 120000 index 0000000000..75a40cb5b2 --- /dev/null +++ b/Lang/Go/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/Go \ No newline at end of file diff --git a/Lang/Go/Range-extraction b/Lang/Go/Range-extraction new file mode 120000 index 0000000000..aae9415109 --- /dev/null +++ b/Lang/Go/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/Go \ No newline at end of file diff --git a/Lang/Go/Rate-counter b/Lang/Go/Rate-counter new file mode 120000 index 0000000000..be57007dd1 --- /dev/null +++ b/Lang/Go/Rate-counter @@ -0,0 +1 @@ +../../Task/Rate-counter/Go \ No newline at end of file diff --git a/Lang/Go/Ray-casting-algorithm b/Lang/Go/Ray-casting-algorithm new file mode 120000 index 0000000000..725d582dbe --- /dev/null +++ b/Lang/Go/Ray-casting-algorithm @@ -0,0 +1 @@ +../../Task/Ray-casting-algorithm/Go \ No newline at end of file diff --git a/Lang/Go/Read-a-configuration-file b/Lang/Go/Read-a-configuration-file new file mode 120000 index 0000000000..59af4a38a0 --- /dev/null +++ b/Lang/Go/Read-a-configuration-file @@ -0,0 +1 @@ +../../Task/Read-a-configuration-file/Go \ No newline at end of file diff --git a/Lang/Go/Read-a-file-line-by-line b/Lang/Go/Read-a-file-line-by-line new file mode 120000 index 0000000000..fa92045996 --- /dev/null +++ b/Lang/Go/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Go \ No newline at end of file diff --git a/Lang/Go/Read-a-specific-line-from-a-file b/Lang/Go/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..309e8e6111 --- /dev/null +++ b/Lang/Go/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/Go \ No newline at end of file diff --git a/Lang/Go/Read-entire-file b/Lang/Go/Read-entire-file new file mode 120000 index 0000000000..d963180014 --- /dev/null +++ b/Lang/Go/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Go \ No newline at end of file diff --git a/Lang/Go/Real-constants-and-functions b/Lang/Go/Real-constants-and-functions new file mode 120000 index 0000000000..218d929617 --- /dev/null +++ b/Lang/Go/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Go \ No newline at end of file diff --git a/Lang/Go/Reduced-row-echelon-form b/Lang/Go/Reduced-row-echelon-form new file mode 120000 index 0000000000..ce7d9e189a --- /dev/null +++ b/Lang/Go/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/Go \ No newline at end of file diff --git a/Lang/Go/Regular-expressions b/Lang/Go/Regular-expressions new file mode 120000 index 0000000000..f9c5b78f59 --- /dev/null +++ b/Lang/Go/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Go \ No newline at end of file diff --git a/Lang/Go/Remove-duplicate-elements b/Lang/Go/Remove-duplicate-elements new file mode 120000 index 0000000000..2fe9d2f9f6 --- /dev/null +++ b/Lang/Go/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Go \ No newline at end of file diff --git a/Lang/Go/Remove-lines-from-a-file b/Lang/Go/Remove-lines-from-a-file new file mode 120000 index 0000000000..245d90a465 --- /dev/null +++ b/Lang/Go/Remove-lines-from-a-file @@ -0,0 +1 @@ +../../Task/Remove-lines-from-a-file/Go \ No newline at end of file diff --git a/Lang/Go/Rename-a-file b/Lang/Go/Rename-a-file new file mode 120000 index 0000000000..501243a16e --- /dev/null +++ b/Lang/Go/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Go \ No newline at end of file diff --git a/Lang/Go/Rendezvous b/Lang/Go/Rendezvous new file mode 120000 index 0000000000..7142c65344 --- /dev/null +++ b/Lang/Go/Rendezvous @@ -0,0 +1 @@ +../../Task/Rendezvous/Go \ No newline at end of file diff --git a/Lang/Go/Repeat-a-string b/Lang/Go/Repeat-a-string new file mode 120000 index 0000000000..6ed205c33b --- /dev/null +++ b/Lang/Go/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Go \ No newline at end of file diff --git a/Lang/Go/Respond-to-an-unknown-method-call b/Lang/Go/Respond-to-an-unknown-method-call new file mode 120000 index 0000000000..30d26ab528 --- /dev/null +++ b/Lang/Go/Respond-to-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Respond-to-an-unknown-method-call/Go \ No newline at end of file diff --git a/Lang/Go/Return-multiple-values b/Lang/Go/Return-multiple-values new file mode 120000 index 0000000000..880731e41b --- /dev/null +++ b/Lang/Go/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Go \ No newline at end of file diff --git a/Lang/Go/Reverse-a-string b/Lang/Go/Reverse-a-string new file mode 120000 index 0000000000..71f137593c --- /dev/null +++ b/Lang/Go/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Go \ No newline at end of file diff --git a/Lang/Go/Rock-paper-scissors b/Lang/Go/Rock-paper-scissors new file mode 120000 index 0000000000..5cd6106778 --- /dev/null +++ b/Lang/Go/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/Go \ No newline at end of file diff --git a/Lang/Go/Roman-numerals-Decode b/Lang/Go/Roman-numerals-Decode new file mode 120000 index 0000000000..4370af7230 --- /dev/null +++ b/Lang/Go/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/Go \ No newline at end of file diff --git a/Lang/Go/Roman-numerals-Encode b/Lang/Go/Roman-numerals-Encode new file mode 120000 index 0000000000..372a5ea85b --- /dev/null +++ b/Lang/Go/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Go \ No newline at end of file diff --git a/Lang/Go/Roots-of-a-function b/Lang/Go/Roots-of-a-function new file mode 120000 index 0000000000..b6397fb799 --- /dev/null +++ b/Lang/Go/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/Go \ No newline at end of file diff --git a/Lang/Go/Roots-of-a-quadratic-function b/Lang/Go/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..dcec4136a5 --- /dev/null +++ b/Lang/Go/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/Go \ No newline at end of file diff --git a/Lang/Go/Roots-of-unity b/Lang/Go/Roots-of-unity new file mode 120000 index 0000000000..587fdea304 --- /dev/null +++ b/Lang/Go/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/Go \ No newline at end of file diff --git a/Lang/Go/Rosetta-Code-Count-examples b/Lang/Go/Rosetta-Code-Count-examples new file mode 120000 index 0000000000..12d28e0862 --- /dev/null +++ b/Lang/Go/Rosetta-Code-Count-examples @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Count-examples/Go \ No newline at end of file diff --git a/Lang/Go/Rosetta-Code-Find-unimplemented-tasks b/Lang/Go/Rosetta-Code-Find-unimplemented-tasks new file mode 120000 index 0000000000..aa0888ccb8 --- /dev/null +++ b/Lang/Go/Rosetta-Code-Find-unimplemented-tasks @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Find-unimplemented-tasks/Go \ No newline at end of file diff --git a/Lang/Go/Rosetta-Code-Fix-code-tags b/Lang/Go/Rosetta-Code-Fix-code-tags new file mode 120000 index 0000000000..327886fb15 --- /dev/null +++ b/Lang/Go/Rosetta-Code-Fix-code-tags @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Fix-code-tags/Go \ No newline at end of file diff --git a/Lang/Go/Rosetta-Code-Rank-languages-by-popularity b/Lang/Go/Rosetta-Code-Rank-languages-by-popularity new file mode 120000 index 0000000000..44340b6f37 --- /dev/null +++ b/Lang/Go/Rosetta-Code-Rank-languages-by-popularity @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-popularity/Go \ No newline at end of file diff --git a/Lang/Go/Rot-13 b/Lang/Go/Rot-13 new file mode 120000 index 0000000000..b9538ae0be --- /dev/null +++ b/Lang/Go/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Go \ No newline at end of file diff --git a/Lang/Go/Run-length-encoding b/Lang/Go/Run-length-encoding new file mode 120000 index 0000000000..d73bf9ded9 --- /dev/null +++ b/Lang/Go/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Go \ No newline at end of file diff --git a/Lang/Go/Runtime-evaluation b/Lang/Go/Runtime-evaluation new file mode 120000 index 0000000000..c40573fe91 --- /dev/null +++ b/Lang/Go/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/Go \ No newline at end of file diff --git a/Lang/Go/Runtime-evaluation-In-an-environment b/Lang/Go/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..a8b0867501 --- /dev/null +++ b/Lang/Go/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/Go \ No newline at end of file diff --git a/Lang/Go/S-Expressions b/Lang/Go/S-Expressions new file mode 120000 index 0000000000..ec9e5684f2 --- /dev/null +++ b/Lang/Go/S-Expressions @@ -0,0 +1 @@ +../../Task/S-Expressions/Go \ No newline at end of file diff --git a/Lang/Go/SEDOLs b/Lang/Go/SEDOLs new file mode 120000 index 0000000000..a1cce550b8 --- /dev/null +++ b/Lang/Go/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/Go \ No newline at end of file diff --git a/Lang/Go/Safe-addition b/Lang/Go/Safe-addition new file mode 120000 index 0000000000..a0c03499bf --- /dev/null +++ b/Lang/Go/Safe-addition @@ -0,0 +1 @@ +../../Task/Safe-addition/Go \ No newline at end of file diff --git a/Lang/Go/Same-Fringe b/Lang/Go/Same-Fringe new file mode 120000 index 0000000000..6ed0c3e35f --- /dev/null +++ b/Lang/Go/Same-Fringe @@ -0,0 +1 @@ +../../Task/Same-Fringe/Go \ No newline at end of file diff --git a/Lang/Go/Secure-temporary-file b/Lang/Go/Secure-temporary-file new file mode 120000 index 0000000000..553b5ce229 --- /dev/null +++ b/Lang/Go/Secure-temporary-file @@ -0,0 +1 @@ +../../Task/Secure-temporary-file/Go \ No newline at end of file diff --git a/Lang/Go/Self-describing-numbers b/Lang/Go/Self-describing-numbers new file mode 120000 index 0000000000..a6a712911a --- /dev/null +++ b/Lang/Go/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/Go \ No newline at end of file diff --git a/Lang/Go/Self-referential-sequence b/Lang/Go/Self-referential-sequence new file mode 120000 index 0000000000..d07742096d --- /dev/null +++ b/Lang/Go/Self-referential-sequence @@ -0,0 +1 @@ +../../Task/Self-referential-sequence/Go \ No newline at end of file diff --git a/Lang/Go/Semordnilap b/Lang/Go/Semordnilap new file mode 120000 index 0000000000..ee3298e992 --- /dev/null +++ b/Lang/Go/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/Go \ No newline at end of file diff --git a/Lang/Go/Send-an-unknown-method-call b/Lang/Go/Send-an-unknown-method-call new file mode 120000 index 0000000000..81bedb9184 --- /dev/null +++ b/Lang/Go/Send-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Send-an-unknown-method-call/Go \ No newline at end of file diff --git a/Lang/Go/Send-email b/Lang/Go/Send-email new file mode 120000 index 0000000000..6e0c0899c1 --- /dev/null +++ b/Lang/Go/Send-email @@ -0,0 +1 @@ +../../Task/Send-email/Go \ No newline at end of file diff --git a/Lang/Go/Sequence-of-non-squares b/Lang/Go/Sequence-of-non-squares new file mode 120000 index 0000000000..495250715d --- /dev/null +++ b/Lang/Go/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Go \ No newline at end of file diff --git a/Lang/Go/Set b/Lang/Go/Set new file mode 120000 index 0000000000..a057eb53cf --- /dev/null +++ b/Lang/Go/Set @@ -0,0 +1 @@ +../../Task/Set/Go \ No newline at end of file diff --git a/Lang/Go/Set-consolidation b/Lang/Go/Set-consolidation new file mode 120000 index 0000000000..88d70af111 --- /dev/null +++ b/Lang/Go/Set-consolidation @@ -0,0 +1 @@ +../../Task/Set-consolidation/Go \ No newline at end of file diff --git a/Lang/Golfscript/Arbitrary-precision-integers--included- b/Lang/Golfscript/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..b93012b05c --- /dev/null +++ b/Lang/Golfscript/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Golfscript \ No newline at end of file diff --git a/Lang/Golfscript/Arbitrary-precision-integers-included b/Lang/Golfscript/Arbitrary-precision-integers-included deleted file mode 120000 index be39ca4ea0..0000000000 --- a/Lang/Golfscript/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Golfscript \ No newline at end of file diff --git a/Lang/Groovy/Arbitrary-precision-integers--included- b/Lang/Groovy/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..4ecdb4a699 --- /dev/null +++ b/Lang/Groovy/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Arbitrary-precision-integers-included b/Lang/Groovy/Arbitrary-precision-integers-included deleted file mode 120000 index 735c25c2a8..0000000000 --- a/Lang/Groovy/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Binary-digits b/Lang/Groovy/Binary-digits new file mode 120000 index 0000000000..8d2272992b --- /dev/null +++ b/Lang/Groovy/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Copy-a-string b/Lang/Groovy/Copy-a-string new file mode 120000 index 0000000000..8e9c8d021a --- /dev/null +++ b/Lang/Groovy/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Environment-variables b/Lang/Groovy/Environment-variables new file mode 120000 index 0000000000..add5f10a93 --- /dev/null +++ b/Lang/Groovy/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Execute-a-Markov-algorithm b/Lang/Groovy/Execute-a-Markov-algorithm new file mode 120000 index 0000000000..25d0f5b41c --- /dev/null +++ b/Lang/Groovy/Execute-a-Markov-algorithm @@ -0,0 +1 @@ +../../Task/Execute-a-Markov-algorithm/Groovy \ No newline at end of file diff --git a/Lang/Groovy/N-queens-problem b/Lang/Groovy/N-queens-problem new file mode 120000 index 0000000000..6894dc0c7f --- /dev/null +++ b/Lang/Groovy/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Non-decimal-radices-Convert b/Lang/Groovy/Non-decimal-radices-Convert new file mode 120000 index 0000000000..e5e2261a8d --- /dev/null +++ b/Lang/Groovy/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Nth-root b/Lang/Groovy/Nth-root new file mode 120000 index 0000000000..cf7e8ca33e --- /dev/null +++ b/Lang/Groovy/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Number-names b/Lang/Groovy/Number-names new file mode 120000 index 0000000000..a1b3425970 --- /dev/null +++ b/Lang/Groovy/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Number-reversal-game b/Lang/Groovy/Number-reversal-game new file mode 120000 index 0000000000..12b0d42dc2 --- /dev/null +++ b/Lang/Groovy/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Numerical-integration b/Lang/Groovy/Numerical-integration new file mode 120000 index 0000000000..6dcda1d837 --- /dev/null +++ b/Lang/Groovy/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Object-serialization b/Lang/Groovy/Object-serialization new file mode 120000 index 0000000000..a8bacb25c1 --- /dev/null +++ b/Lang/Groovy/Object-serialization @@ -0,0 +1 @@ +../../Task/Object-serialization/Groovy \ No newline at end of file diff --git a/Lang/Groovy/One-dimensional-cellular-automata b/Lang/Groovy/One-dimensional-cellular-automata new file mode 120000 index 0000000000..58e1eb69a6 --- /dev/null +++ b/Lang/Groovy/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Order-two-numerical-lists b/Lang/Groovy/Order-two-numerical-lists new file mode 120000 index 0000000000..91bdbc44c4 --- /dev/null +++ b/Lang/Groovy/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Ordered-Partitions b/Lang/Groovy/Ordered-Partitions new file mode 120000 index 0000000000..4c5d18c0cb --- /dev/null +++ b/Lang/Groovy/Ordered-Partitions @@ -0,0 +1 @@ +../../Task/Ordered-Partitions/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Palindrome-detection b/Lang/Groovy/Palindrome-detection new file mode 120000 index 0000000000..2c50a1c9ae --- /dev/null +++ b/Lang/Groovy/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Parsing-RPN-calculator-algorithm b/Lang/Groovy/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..37db1d3621 --- /dev/null +++ b/Lang/Groovy/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Pascals-triangle b/Lang/Groovy/Pascals-triangle new file mode 120000 index 0000000000..866dad8700 --- /dev/null +++ b/Lang/Groovy/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Perfect-numbers b/Lang/Groovy/Perfect-numbers new file mode 120000 index 0000000000..e30fd92d45 --- /dev/null +++ b/Lang/Groovy/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Permutations b/Lang/Groovy/Permutations new file mode 120000 index 0000000000..d5c840add2 --- /dev/null +++ b/Lang/Groovy/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Permutations-Derangements b/Lang/Groovy/Permutations-Derangements new file mode 120000 index 0000000000..34c1b59619 --- /dev/null +++ b/Lang/Groovy/Permutations-Derangements @@ -0,0 +1 @@ +../../Task/Permutations-Derangements/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Pick-random-element b/Lang/Groovy/Pick-random-element new file mode 120000 index 0000000000..302cee9749 --- /dev/null +++ b/Lang/Groovy/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Pig-the-dice-game b/Lang/Groovy/Pig-the-dice-game new file mode 120000 index 0000000000..b4732334bd --- /dev/null +++ b/Lang/Groovy/Pig-the-dice-game @@ -0,0 +1 @@ +../../Task/Pig-the-dice-game/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Playing-cards b/Lang/Groovy/Playing-cards new file mode 120000 index 0000000000..e4fe1be163 --- /dev/null +++ b/Lang/Groovy/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Plot-coordinate-pairs b/Lang/Groovy/Plot-coordinate-pairs new file mode 120000 index 0000000000..7a2d4ff510 --- /dev/null +++ b/Lang/Groovy/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Power-set b/Lang/Groovy/Power-set new file mode 120000 index 0000000000..031157cea2 --- /dev/null +++ b/Lang/Groovy/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Price-fraction b/Lang/Groovy/Price-fraction new file mode 120000 index 0000000000..3463612f4b --- /dev/null +++ b/Lang/Groovy/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Primality-by-trial-division b/Lang/Groovy/Primality-by-trial-division new file mode 120000 index 0000000000..4a159cc669 --- /dev/null +++ b/Lang/Groovy/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Prime-decomposition b/Lang/Groovy/Prime-decomposition new file mode 120000 index 0000000000..6ba7f52f12 --- /dev/null +++ b/Lang/Groovy/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Program-name b/Lang/Groovy/Program-name new file mode 120000 index 0000000000..e7ad9b9d2d --- /dev/null +++ b/Lang/Groovy/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Program-termination b/Lang/Groovy/Program-termination new file mode 120000 index 0000000000..280cbe2218 --- /dev/null +++ b/Lang/Groovy/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Queue-Definition b/Lang/Groovy/Queue-Definition new file mode 120000 index 0000000000..87d8fa0171 --- /dev/null +++ b/Lang/Groovy/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Queue-Usage b/Lang/Groovy/Queue-Usage new file mode 120000 index 0000000000..1f77eebff2 --- /dev/null +++ b/Lang/Groovy/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Random-number-generator--device- b/Lang/Groovy/Random-number-generator--device- new file mode 120000 index 0000000000..7999cad87f --- /dev/null +++ b/Lang/Groovy/Random-number-generator--device- @@ -0,0 +1 @@ +../../Task/Random-number-generator--device-/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Random-numbers b/Lang/Groovy/Random-numbers new file mode 120000 index 0000000000..8145cf7572 --- /dev/null +++ b/Lang/Groovy/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Range-expansion b/Lang/Groovy/Range-expansion new file mode 120000 index 0000000000..e7dc7554bf --- /dev/null +++ b/Lang/Groovy/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Range-extraction b/Lang/Groovy/Range-extraction new file mode 120000 index 0000000000..dd7141477c --- /dev/null +++ b/Lang/Groovy/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Read-a-file-line-by-line b/Lang/Groovy/Read-a-file-line-by-line new file mode 120000 index 0000000000..b805432d6c --- /dev/null +++ b/Lang/Groovy/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Read-a-specific-line-from-a-file b/Lang/Groovy/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..37af43f5b3 --- /dev/null +++ b/Lang/Groovy/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Read-entire-file b/Lang/Groovy/Read-entire-file new file mode 120000 index 0000000000..c956c69707 --- /dev/null +++ b/Lang/Groovy/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Real-constants-and-functions b/Lang/Groovy/Real-constants-and-functions new file mode 120000 index 0000000000..cda7a708ab --- /dev/null +++ b/Lang/Groovy/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Reduced-row-echelon-form b/Lang/Groovy/Reduced-row-echelon-form new file mode 120000 index 0000000000..1faa4b3c0d --- /dev/null +++ b/Lang/Groovy/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Regular-expressions b/Lang/Groovy/Regular-expressions new file mode 120000 index 0000000000..432d39fc41 --- /dev/null +++ b/Lang/Groovy/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Remove-duplicate-elements b/Lang/Groovy/Remove-duplicate-elements new file mode 120000 index 0000000000..4e83a883ca --- /dev/null +++ b/Lang/Groovy/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Rename-a-file b/Lang/Groovy/Rename-a-file new file mode 120000 index 0000000000..3240f671fa --- /dev/null +++ b/Lang/Groovy/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Repeat-a-string b/Lang/Groovy/Repeat-a-string new file mode 120000 index 0000000000..6b0103b038 --- /dev/null +++ b/Lang/Groovy/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Return-multiple-values b/Lang/Groovy/Return-multiple-values new file mode 120000 index 0000000000..26d992735e --- /dev/null +++ b/Lang/Groovy/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Reverse-a-string b/Lang/Groovy/Reverse-a-string new file mode 120000 index 0000000000..5c4124ff04 --- /dev/null +++ b/Lang/Groovy/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Roman-numerals-Decode b/Lang/Groovy/Roman-numerals-Decode new file mode 120000 index 0000000000..056a19437b --- /dev/null +++ b/Lang/Groovy/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Roman-numerals-Encode b/Lang/Groovy/Roman-numerals-Encode new file mode 120000 index 0000000000..6d6a4d4365 --- /dev/null +++ b/Lang/Groovy/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Roots-of-unity b/Lang/Groovy/Roots-of-unity new file mode 120000 index 0000000000..6dffdc59d5 --- /dev/null +++ b/Lang/Groovy/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Rot-13 b/Lang/Groovy/Rot-13 new file mode 120000 index 0000000000..f9832588eb --- /dev/null +++ b/Lang/Groovy/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Run-length-encoding b/Lang/Groovy/Run-length-encoding new file mode 120000 index 0000000000..da964099b8 --- /dev/null +++ b/Lang/Groovy/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Runtime-evaluation b/Lang/Groovy/Runtime-evaluation new file mode 120000 index 0000000000..99534d4ccb --- /dev/null +++ b/Lang/Groovy/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Runtime-evaluation-In-an-environment b/Lang/Groovy/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..68543a7b8d --- /dev/null +++ b/Lang/Groovy/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/Groovy \ No newline at end of file diff --git a/Lang/Groovy/SEDOLs b/Lang/Groovy/SEDOLs new file mode 120000 index 0000000000..c14561bfda --- /dev/null +++ b/Lang/Groovy/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Secure-temporary-file b/Lang/Groovy/Secure-temporary-file new file mode 120000 index 0000000000..6f2b709450 --- /dev/null +++ b/Lang/Groovy/Secure-temporary-file @@ -0,0 +1 @@ +../../Task/Secure-temporary-file/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Semordnilap b/Lang/Groovy/Semordnilap new file mode 120000 index 0000000000..323fc2d48d --- /dev/null +++ b/Lang/Groovy/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Sequence-of-non-squares b/Lang/Groovy/Sequence-of-non-squares new file mode 120000 index 0000000000..a8feebfe99 --- /dev/null +++ b/Lang/Groovy/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Groovy \ No newline at end of file diff --git a/Lang/Groovy/Set b/Lang/Groovy/Set new file mode 120000 index 0000000000..e0806532a1 --- /dev/null +++ b/Lang/Groovy/Set @@ -0,0 +1 @@ +../../Task/Set/Groovy \ No newline at end of file diff --git a/Lang/Haskell/Arbitrary-precision-integers--included- b/Lang/Haskell/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..26c63b714d --- /dev/null +++ b/Lang/Haskell/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Arbitrary-precision-integers-included b/Lang/Haskell/Arbitrary-precision-integers-included deleted file mode 120000 index 0b8fc3144b..0000000000 --- a/Lang/Haskell/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Binary-digits b/Lang/Haskell/Binary-digits new file mode 120000 index 0000000000..c1b5f4de02 --- /dev/null +++ b/Lang/Haskell/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Brownian-tree b/Lang/Haskell/Brownian-tree new file mode 120000 index 0000000000..eed33b526b --- /dev/null +++ b/Lang/Haskell/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Catalan-numbers b/Lang/Haskell/Catalan-numbers new file mode 120000 index 0000000000..7ee2ceb2db --- /dev/null +++ b/Lang/Haskell/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Dragon-curve b/Lang/Haskell/Dragon-curve new file mode 120000 index 0000000000..9129f2a704 --- /dev/null +++ b/Lang/Haskell/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Environment-variables b/Lang/Haskell/Environment-variables new file mode 120000 index 0000000000..0f1d658a53 --- /dev/null +++ b/Lang/Haskell/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Execute-a-Markov-algorithm b/Lang/Haskell/Execute-a-Markov-algorithm new file mode 120000 index 0000000000..63e5ecb08f --- /dev/null +++ b/Lang/Haskell/Execute-a-Markov-algorithm @@ -0,0 +1 @@ +../../Task/Execute-a-Markov-algorithm/Haskell \ No newline at end of file diff --git a/Lang/Haskell/N-queens-problem b/Lang/Haskell/N-queens-problem new file mode 120000 index 0000000000..afcab6a4c0 --- /dev/null +++ b/Lang/Haskell/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Named-parameters b/Lang/Haskell/Named-parameters new file mode 120000 index 0000000000..c911e19afe --- /dev/null +++ b/Lang/Haskell/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Non-continuous-subsequences b/Lang/Haskell/Non-continuous-subsequences new file mode 120000 index 0000000000..cbf0371cb8 --- /dev/null +++ b/Lang/Haskell/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Non-decimal-radices-Convert b/Lang/Haskell/Non-decimal-radices-Convert new file mode 120000 index 0000000000..ae6b9de925 --- /dev/null +++ b/Lang/Haskell/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Non-decimal-radices-Input b/Lang/Haskell/Non-decimal-radices-Input new file mode 120000 index 0000000000..e1f966df75 --- /dev/null +++ b/Lang/Haskell/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Non-decimal-radices-Output b/Lang/Haskell/Non-decimal-radices-Output new file mode 120000 index 0000000000..11ffc7e15d --- /dev/null +++ b/Lang/Haskell/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Nth-root b/Lang/Haskell/Nth-root new file mode 120000 index 0000000000..ceb6218f6a --- /dev/null +++ b/Lang/Haskell/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Null-object b/Lang/Haskell/Null-object new file mode 120000 index 0000000000..5daea4d28d --- /dev/null +++ b/Lang/Haskell/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Number-names b/Lang/Haskell/Number-names new file mode 120000 index 0000000000..16b2a598b8 --- /dev/null +++ b/Lang/Haskell/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Number-reversal-game b/Lang/Haskell/Number-reversal-game new file mode 120000 index 0000000000..2cf95a8a86 --- /dev/null +++ b/Lang/Haskell/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Numeric-error-propagation b/Lang/Haskell/Numeric-error-propagation new file mode 120000 index 0000000000..f49658d185 --- /dev/null +++ b/Lang/Haskell/Numeric-error-propagation @@ -0,0 +1 @@ +../../Task/Numeric-error-propagation/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Numerical-integration b/Lang/Haskell/Numerical-integration new file mode 120000 index 0000000000..9fa48bdaff --- /dev/null +++ b/Lang/Haskell/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/Haskell \ No newline at end of file diff --git a/Lang/Haskell/One-dimensional-cellular-automata b/Lang/Haskell/One-dimensional-cellular-automata new file mode 120000 index 0000000000..84b9cf6e9b --- /dev/null +++ b/Lang/Haskell/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Haskell \ No newline at end of file diff --git a/Lang/Haskell/One-of-n-lines-in-a-file b/Lang/Haskell/One-of-n-lines-in-a-file new file mode 120000 index 0000000000..a642a14950 --- /dev/null +++ b/Lang/Haskell/One-of-n-lines-in-a-file @@ -0,0 +1 @@ +../../Task/One-of-n-lines-in-a-file/Haskell \ No newline at end of file diff --git a/Lang/Haskell/OpenGL b/Lang/Haskell/OpenGL new file mode 120000 index 0000000000..d20d322ec5 --- /dev/null +++ b/Lang/Haskell/OpenGL @@ -0,0 +1 @@ +../../Task/OpenGL/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Order-two-numerical-lists b/Lang/Haskell/Order-two-numerical-lists new file mode 120000 index 0000000000..b1618ca141 --- /dev/null +++ b/Lang/Haskell/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Ordered-Partitions b/Lang/Haskell/Ordered-Partitions new file mode 120000 index 0000000000..90cb0b7dd9 --- /dev/null +++ b/Lang/Haskell/Ordered-Partitions @@ -0,0 +1 @@ +../../Task/Ordered-Partitions/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Palindrome-detection b/Lang/Haskell/Palindrome-detection new file mode 120000 index 0000000000..06f69fa3ce --- /dev/null +++ b/Lang/Haskell/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Pangram-checker b/Lang/Haskell/Pangram-checker new file mode 120000 index 0000000000..6e44fde5d0 --- /dev/null +++ b/Lang/Haskell/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Parametric-polymorphism b/Lang/Haskell/Parametric-polymorphism new file mode 120000 index 0000000000..6380a6733c --- /dev/null +++ b/Lang/Haskell/Parametric-polymorphism @@ -0,0 +1 @@ +../../Task/Parametric-polymorphism/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Parsing-RPN-calculator-algorithm b/Lang/Haskell/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..23b3742dff --- /dev/null +++ b/Lang/Haskell/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Parsing-Shunting-yard-algorithm b/Lang/Haskell/Parsing-Shunting-yard-algorithm new file mode 120000 index 0000000000..de9932bf66 --- /dev/null +++ b/Lang/Haskell/Parsing-Shunting-yard-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-Shunting-yard-algorithm/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Partial-function-application b/Lang/Haskell/Partial-function-application new file mode 120000 index 0000000000..83dce67ef2 --- /dev/null +++ b/Lang/Haskell/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Pascals-triangle b/Lang/Haskell/Pascals-triangle new file mode 120000 index 0000000000..96c7454e0f --- /dev/null +++ b/Lang/Haskell/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Pascals-triangle-Puzzle b/Lang/Haskell/Pascals-triangle-Puzzle new file mode 120000 index 0000000000..f4883fd53f --- /dev/null +++ b/Lang/Haskell/Pascals-triangle-Puzzle @@ -0,0 +1 @@ +../../Task/Pascals-triangle-Puzzle/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Pattern-matching b/Lang/Haskell/Pattern-matching new file mode 120000 index 0000000000..bf88afc4e5 --- /dev/null +++ b/Lang/Haskell/Pattern-matching @@ -0,0 +1 @@ +../../Task/Pattern-matching/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Perfect-numbers b/Lang/Haskell/Perfect-numbers new file mode 120000 index 0000000000..93cc10bc40 --- /dev/null +++ b/Lang/Haskell/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Permutation-test b/Lang/Haskell/Permutation-test new file mode 120000 index 0000000000..c8f9c31c1c --- /dev/null +++ b/Lang/Haskell/Permutation-test @@ -0,0 +1 @@ +../../Task/Permutation-test/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Permutations b/Lang/Haskell/Permutations new file mode 120000 index 0000000000..ca7e83d3cb --- /dev/null +++ b/Lang/Haskell/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Permutations-Derangements b/Lang/Haskell/Permutations-Derangements new file mode 120000 index 0000000000..47bae6e075 --- /dev/null +++ b/Lang/Haskell/Permutations-Derangements @@ -0,0 +1 @@ +../../Task/Permutations-Derangements/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Permutations-by-swapping b/Lang/Haskell/Permutations-by-swapping new file mode 120000 index 0000000000..b924c301a5 --- /dev/null +++ b/Lang/Haskell/Permutations-by-swapping @@ -0,0 +1 @@ +../../Task/Permutations-by-swapping/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Pick-random-element b/Lang/Haskell/Pick-random-element new file mode 120000 index 0000000000..bda9b9cab2 --- /dev/null +++ b/Lang/Haskell/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Playing-cards b/Lang/Haskell/Playing-cards new file mode 120000 index 0000000000..8aee84ef80 --- /dev/null +++ b/Lang/Haskell/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Plot-coordinate-pairs b/Lang/Haskell/Plot-coordinate-pairs new file mode 120000 index 0000000000..763fe9e72e --- /dev/null +++ b/Lang/Haskell/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Pointers-and-references b/Lang/Haskell/Pointers-and-references new file mode 120000 index 0000000000..ae92f21835 --- /dev/null +++ b/Lang/Haskell/Pointers-and-references @@ -0,0 +1 @@ +../../Task/Pointers-and-references/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Polymorphism b/Lang/Haskell/Polymorphism new file mode 120000 index 0000000000..a6a2a859de --- /dev/null +++ b/Lang/Haskell/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Polynomial-long-division b/Lang/Haskell/Polynomial-long-division new file mode 120000 index 0000000000..1ff421907b --- /dev/null +++ b/Lang/Haskell/Polynomial-long-division @@ -0,0 +1 @@ +../../Task/Polynomial-long-division/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Polynomial-regression b/Lang/Haskell/Polynomial-regression new file mode 120000 index 0000000000..008c5315c7 --- /dev/null +++ b/Lang/Haskell/Polynomial-regression @@ -0,0 +1 @@ +../../Task/Polynomial-regression/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Power-set b/Lang/Haskell/Power-set new file mode 120000 index 0000000000..2572c3aabc --- /dev/null +++ b/Lang/Haskell/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Price-fraction b/Lang/Haskell/Price-fraction new file mode 120000 index 0000000000..af6ea46386 --- /dev/null +++ b/Lang/Haskell/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Primality-by-trial-division b/Lang/Haskell/Primality-by-trial-division new file mode 120000 index 0000000000..a055ec5d1c --- /dev/null +++ b/Lang/Haskell/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Prime-decomposition b/Lang/Haskell/Prime-decomposition new file mode 120000 index 0000000000..4d773f5f2b --- /dev/null +++ b/Lang/Haskell/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Priority-queue b/Lang/Haskell/Priority-queue new file mode 120000 index 0000000000..2efddb2ca2 --- /dev/null +++ b/Lang/Haskell/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Probabilistic-choice b/Lang/Haskell/Probabilistic-choice new file mode 120000 index 0000000000..edca5cb105 --- /dev/null +++ b/Lang/Haskell/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Problem-of-Apollonius b/Lang/Haskell/Problem-of-Apollonius new file mode 120000 index 0000000000..98b8757204 --- /dev/null +++ b/Lang/Haskell/Problem-of-Apollonius @@ -0,0 +1 @@ +../../Task/Problem-of-Apollonius/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Program-name b/Lang/Haskell/Program-name new file mode 120000 index 0000000000..a542d21cae --- /dev/null +++ b/Lang/Haskell/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Program-termination b/Lang/Haskell/Program-termination new file mode 120000 index 0000000000..f9dac6ec9d --- /dev/null +++ b/Lang/Haskell/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Pythagorean-triples b/Lang/Haskell/Pythagorean-triples new file mode 120000 index 0000000000..fd4445ec73 --- /dev/null +++ b/Lang/Haskell/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Quaternion-type b/Lang/Haskell/Quaternion-type new file mode 120000 index 0000000000..14aca84bfa --- /dev/null +++ b/Lang/Haskell/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Queue-Definition b/Lang/Haskell/Queue-Definition new file mode 120000 index 0000000000..85f6f92538 --- /dev/null +++ b/Lang/Haskell/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Queue-Usage b/Lang/Haskell/Queue-Usage new file mode 120000 index 0000000000..3dd64ba779 --- /dev/null +++ b/Lang/Haskell/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Random-number-generator--device- b/Lang/Haskell/Random-number-generator--device- new file mode 120000 index 0000000000..ab1f91d487 --- /dev/null +++ b/Lang/Haskell/Random-number-generator--device- @@ -0,0 +1 @@ +../../Task/Random-number-generator--device-/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Random-numbers b/Lang/Haskell/Random-numbers new file mode 120000 index 0000000000..7b041dad9c --- /dev/null +++ b/Lang/Haskell/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Range-expansion b/Lang/Haskell/Range-expansion new file mode 120000 index 0000000000..f94fb1db16 --- /dev/null +++ b/Lang/Haskell/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Range-extraction b/Lang/Haskell/Range-extraction new file mode 120000 index 0000000000..d7dccf0bf8 --- /dev/null +++ b/Lang/Haskell/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Ray-casting-algorithm b/Lang/Haskell/Ray-casting-algorithm new file mode 120000 index 0000000000..f8b3a05287 --- /dev/null +++ b/Lang/Haskell/Ray-casting-algorithm @@ -0,0 +1 @@ +../../Task/Ray-casting-algorithm/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Read-a-configuration-file b/Lang/Haskell/Read-a-configuration-file new file mode 120000 index 0000000000..a5112a126c --- /dev/null +++ b/Lang/Haskell/Read-a-configuration-file @@ -0,0 +1 @@ +../../Task/Read-a-configuration-file/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Read-a-specific-line-from-a-file b/Lang/Haskell/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..4c108ef87a --- /dev/null +++ b/Lang/Haskell/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Read-entire-file b/Lang/Haskell/Read-entire-file new file mode 120000 index 0000000000..d512fda6df --- /dev/null +++ b/Lang/Haskell/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Real-constants-and-functions b/Lang/Haskell/Real-constants-and-functions new file mode 120000 index 0000000000..0bb394a538 --- /dev/null +++ b/Lang/Haskell/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Reduced-row-echelon-form b/Lang/Haskell/Reduced-row-echelon-form new file mode 120000 index 0000000000..e6614c1a18 --- /dev/null +++ b/Lang/Haskell/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Regular-expressions b/Lang/Haskell/Regular-expressions new file mode 120000 index 0000000000..b1cdc41b33 --- /dev/null +++ b/Lang/Haskell/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Remove-duplicate-elements b/Lang/Haskell/Remove-duplicate-elements new file mode 120000 index 0000000000..cfafa65728 --- /dev/null +++ b/Lang/Haskell/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Remove-lines-from-a-file b/Lang/Haskell/Remove-lines-from-a-file new file mode 120000 index 0000000000..10862731fe --- /dev/null +++ b/Lang/Haskell/Remove-lines-from-a-file @@ -0,0 +1 @@ +../../Task/Remove-lines-from-a-file/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Rename-a-file b/Lang/Haskell/Rename-a-file new file mode 120000 index 0000000000..81dd42ffce --- /dev/null +++ b/Lang/Haskell/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Repeat-a-string b/Lang/Haskell/Repeat-a-string new file mode 120000 index 0000000000..d190bf9512 --- /dev/null +++ b/Lang/Haskell/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Return-multiple-values b/Lang/Haskell/Return-multiple-values new file mode 120000 index 0000000000..ca9a9712c8 --- /dev/null +++ b/Lang/Haskell/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Reverse-a-string b/Lang/Haskell/Reverse-a-string new file mode 120000 index 0000000000..6095b0ea69 --- /dev/null +++ b/Lang/Haskell/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Rock-paper-scissors b/Lang/Haskell/Rock-paper-scissors new file mode 120000 index 0000000000..829de62494 --- /dev/null +++ b/Lang/Haskell/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Roman-numerals-Decode b/Lang/Haskell/Roman-numerals-Decode new file mode 120000 index 0000000000..693bba9ebd --- /dev/null +++ b/Lang/Haskell/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Roman-numerals-Encode b/Lang/Haskell/Roman-numerals-Encode new file mode 120000 index 0000000000..b957cce4dd --- /dev/null +++ b/Lang/Haskell/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Roots-of-a-function b/Lang/Haskell/Roots-of-a-function new file mode 120000 index 0000000000..204ff8c79c --- /dev/null +++ b/Lang/Haskell/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Roots-of-a-quadratic-function b/Lang/Haskell/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..d5b8347822 --- /dev/null +++ b/Lang/Haskell/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Roots-of-unity b/Lang/Haskell/Roots-of-unity new file mode 120000 index 0000000000..95078c35df --- /dev/null +++ b/Lang/Haskell/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Rosetta-Code-Count-examples b/Lang/Haskell/Rosetta-Code-Count-examples new file mode 120000 index 0000000000..e848948d8d --- /dev/null +++ b/Lang/Haskell/Rosetta-Code-Count-examples @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Count-examples/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Rosetta-Code-Find-unimplemented-tasks b/Lang/Haskell/Rosetta-Code-Find-unimplemented-tasks new file mode 120000 index 0000000000..150cbab4dd --- /dev/null +++ b/Lang/Haskell/Rosetta-Code-Find-unimplemented-tasks @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Find-unimplemented-tasks/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Rosetta-Code-Rank-languages-by-popularity b/Lang/Haskell/Rosetta-Code-Rank-languages-by-popularity new file mode 120000 index 0000000000..3768cd4a16 --- /dev/null +++ b/Lang/Haskell/Rosetta-Code-Rank-languages-by-popularity @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-popularity/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Rot-13 b/Lang/Haskell/Rot-13 new file mode 120000 index 0000000000..29406a6fcb --- /dev/null +++ b/Lang/Haskell/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Run-length-encoding b/Lang/Haskell/Run-length-encoding new file mode 120000 index 0000000000..ce8ae28812 --- /dev/null +++ b/Lang/Haskell/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Haskell \ No newline at end of file diff --git a/Lang/Haskell/S-Expressions b/Lang/Haskell/S-Expressions new file mode 120000 index 0000000000..d66ef24e67 --- /dev/null +++ b/Lang/Haskell/S-Expressions @@ -0,0 +1 @@ +../../Task/S-Expressions/Haskell \ No newline at end of file diff --git a/Lang/Haskell/SEDOLs b/Lang/Haskell/SEDOLs new file mode 120000 index 0000000000..6798fb4bdc --- /dev/null +++ b/Lang/Haskell/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Same-Fringe b/Lang/Haskell/Same-Fringe new file mode 120000 index 0000000000..fcc97b9479 --- /dev/null +++ b/Lang/Haskell/Same-Fringe @@ -0,0 +1 @@ +../../Task/Same-Fringe/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Secure-temporary-file b/Lang/Haskell/Secure-temporary-file new file mode 120000 index 0000000000..abc1dee5a9 --- /dev/null +++ b/Lang/Haskell/Secure-temporary-file @@ -0,0 +1 @@ +../../Task/Secure-temporary-file/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Self-describing-numbers b/Lang/Haskell/Self-describing-numbers new file mode 120000 index 0000000000..771aee2514 --- /dev/null +++ b/Lang/Haskell/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Self-referential-sequence b/Lang/Haskell/Self-referential-sequence new file mode 120000 index 0000000000..98549b8765 --- /dev/null +++ b/Lang/Haskell/Self-referential-sequence @@ -0,0 +1 @@ +../../Task/Self-referential-sequence/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Semordnilap b/Lang/Haskell/Semordnilap new file mode 120000 index 0000000000..fd39566e89 --- /dev/null +++ b/Lang/Haskell/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Sequence-of-non-squares b/Lang/Haskell/Sequence-of-non-squares new file mode 120000 index 0000000000..d8d9c9a478 --- /dev/null +++ b/Lang/Haskell/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Set b/Lang/Haskell/Set new file mode 120000 index 0000000000..92ff3f5ce3 --- /dev/null +++ b/Lang/Haskell/Set @@ -0,0 +1 @@ +../../Task/Set/Haskell \ No newline at end of file diff --git a/Lang/Haskell/Set-consolidation b/Lang/Haskell/Set-consolidation new file mode 120000 index 0000000000..cc5fe42ba9 --- /dev/null +++ b/Lang/Haskell/Set-consolidation @@ -0,0 +1 @@ +../../Task/Set-consolidation/Haskell \ No newline at end of file diff --git a/Lang/Heron/N-queens-problem b/Lang/Heron/N-queens-problem new file mode 120000 index 0000000000..650b4eed07 --- /dev/null +++ b/Lang/Heron/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Heron \ No newline at end of file diff --git a/Lang/HicEst/Copy-a-string b/Lang/HicEst/Copy-a-string new file mode 120000 index 0000000000..108d170e0f --- /dev/null +++ b/Lang/HicEst/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Dragon-curve b/Lang/HicEst/Dragon-curve new file mode 120000 index 0000000000..ae4c2eaa97 --- /dev/null +++ b/Lang/HicEst/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Environment-variables b/Lang/HicEst/Environment-variables new file mode 120000 index 0000000000..4fc135e1e7 --- /dev/null +++ b/Lang/HicEst/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Non-decimal-radices-Convert b/Lang/HicEst/Non-decimal-radices-Convert new file mode 120000 index 0000000000..4b37a006f6 --- /dev/null +++ b/Lang/HicEst/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Non-decimal-radices-Input b/Lang/HicEst/Non-decimal-radices-Input new file mode 120000 index 0000000000..bad06760eb --- /dev/null +++ b/Lang/HicEst/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Non-decimal-radices-Output b/Lang/HicEst/Non-decimal-radices-Output new file mode 120000 index 0000000000..50387e819c --- /dev/null +++ b/Lang/HicEst/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Nth-root b/Lang/HicEst/Nth-root new file mode 120000 index 0000000000..9a6a75b440 --- /dev/null +++ b/Lang/HicEst/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Number-names b/Lang/HicEst/Number-names new file mode 120000 index 0000000000..ff2e9a6cd9 --- /dev/null +++ b/Lang/HicEst/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Number-reversal-game b/Lang/HicEst/Number-reversal-game new file mode 120000 index 0000000000..7ad4566b55 --- /dev/null +++ b/Lang/HicEst/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Palindrome-detection b/Lang/HicEst/Palindrome-detection new file mode 120000 index 0000000000..ec93e4cf8e --- /dev/null +++ b/Lang/HicEst/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Pangram-checker b/Lang/HicEst/Pangram-checker new file mode 120000 index 0000000000..f1a2e256e8 --- /dev/null +++ b/Lang/HicEst/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Pascals-triangle b/Lang/HicEst/Pascals-triangle new file mode 120000 index 0000000000..5f83c29f7b --- /dev/null +++ b/Lang/HicEst/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Perfect-numbers b/Lang/HicEst/Perfect-numbers new file mode 120000 index 0000000000..61238ac5db --- /dev/null +++ b/Lang/HicEst/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Plot-coordinate-pairs b/Lang/HicEst/Plot-coordinate-pairs new file mode 120000 index 0000000000..6d7113d7a7 --- /dev/null +++ b/Lang/HicEst/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Polynomial-regression b/Lang/HicEst/Polynomial-regression new file mode 120000 index 0000000000..db50c11844 --- /dev/null +++ b/Lang/HicEst/Polynomial-regression @@ -0,0 +1 @@ +../../Task/Polynomial-regression/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Price-fraction b/Lang/HicEst/Price-fraction new file mode 120000 index 0000000000..ba30ee1279 --- /dev/null +++ b/Lang/HicEst/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Primality-by-trial-division b/Lang/HicEst/Primality-by-trial-division new file mode 120000 index 0000000000..41f163a456 --- /dev/null +++ b/Lang/HicEst/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Probabilistic-choice b/Lang/HicEst/Probabilistic-choice new file mode 120000 index 0000000000..71a2dabb9c --- /dev/null +++ b/Lang/HicEst/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Program-termination b/Lang/HicEst/Program-termination new file mode 120000 index 0000000000..c77b16f664 --- /dev/null +++ b/Lang/HicEst/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Random-numbers b/Lang/HicEst/Random-numbers new file mode 120000 index 0000000000..ae63cadc0b --- /dev/null +++ b/Lang/HicEst/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Rate-counter b/Lang/HicEst/Rate-counter new file mode 120000 index 0000000000..d08fda3740 --- /dev/null +++ b/Lang/HicEst/Rate-counter @@ -0,0 +1 @@ +../../Task/Rate-counter/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Real-constants-and-functions b/Lang/HicEst/Real-constants-and-functions new file mode 120000 index 0000000000..3df1a6bad6 --- /dev/null +++ b/Lang/HicEst/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Regular-expressions b/Lang/HicEst/Regular-expressions new file mode 120000 index 0000000000..bd2c7b6dd6 --- /dev/null +++ b/Lang/HicEst/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Remove-duplicate-elements b/Lang/HicEst/Remove-duplicate-elements new file mode 120000 index 0000000000..e947c06dbf --- /dev/null +++ b/Lang/HicEst/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Rename-a-file b/Lang/HicEst/Rename-a-file new file mode 120000 index 0000000000..26bf2ac611 --- /dev/null +++ b/Lang/HicEst/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Repeat-a-string b/Lang/HicEst/Repeat-a-string new file mode 120000 index 0000000000..cb23cf09bb --- /dev/null +++ b/Lang/HicEst/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Reverse-a-string b/Lang/HicEst/Reverse-a-string new file mode 120000 index 0000000000..89a2951aca --- /dev/null +++ b/Lang/HicEst/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Roman-numerals-Encode b/Lang/HicEst/Roman-numerals-Encode new file mode 120000 index 0000000000..e39daa724c --- /dev/null +++ b/Lang/HicEst/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Roots-of-a-function b/Lang/HicEst/Roots-of-a-function new file mode 120000 index 0000000000..8721478868 --- /dev/null +++ b/Lang/HicEst/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Rosetta-Code-Rank-languages-by-popularity b/Lang/HicEst/Rosetta-Code-Rank-languages-by-popularity new file mode 120000 index 0000000000..457f520540 --- /dev/null +++ b/Lang/HicEst/Rosetta-Code-Rank-languages-by-popularity @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-popularity/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Rot-13 b/Lang/HicEst/Rot-13 new file mode 120000 index 0000000000..f37719270e --- /dev/null +++ b/Lang/HicEst/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Runtime-evaluation b/Lang/HicEst/Runtime-evaluation new file mode 120000 index 0000000000..b508ba32b9 --- /dev/null +++ b/Lang/HicEst/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Secure-temporary-file b/Lang/HicEst/Secure-temporary-file new file mode 120000 index 0000000000..2b97f0a57d --- /dev/null +++ b/Lang/HicEst/Secure-temporary-file @@ -0,0 +1 @@ +../../Task/Secure-temporary-file/HicEst \ No newline at end of file diff --git a/Lang/HicEst/Sequence-of-non-squares b/Lang/HicEst/Sequence-of-non-squares new file mode 120000 index 0000000000..ca73376af3 --- /dev/null +++ b/Lang/HicEst/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/HicEst \ No newline at end of file diff --git a/Lang/IDL/Pascals-triangle b/Lang/IDL/Pascals-triangle new file mode 120000 index 0000000000..99ece0e1e8 --- /dev/null +++ b/Lang/IDL/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/IDL \ No newline at end of file diff --git a/Lang/IDL/Random-numbers b/Lang/IDL/Random-numbers new file mode 120000 index 0000000000..e26978da49 --- /dev/null +++ b/Lang/IDL/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/IDL \ No newline at end of file diff --git a/Lang/IDL/Remove-duplicate-elements b/Lang/IDL/Remove-duplicate-elements new file mode 120000 index 0000000000..05ccdb4cde --- /dev/null +++ b/Lang/IDL/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/IDL \ No newline at end of file diff --git a/Lang/IDL/Roots-of-a-quadratic-function b/Lang/IDL/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..3b902c1d09 --- /dev/null +++ b/Lang/IDL/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/IDL \ No newline at end of file diff --git a/Lang/IDL/Roots-of-unity b/Lang/IDL/Roots-of-unity new file mode 120000 index 0000000000..7791f80719 --- /dev/null +++ b/Lang/IDL/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/IDL \ No newline at end of file diff --git a/Lang/IDL/Sequence-of-non-squares b/Lang/IDL/Sequence-of-non-squares new file mode 120000 index 0000000000..1845adc89d --- /dev/null +++ b/Lang/IDL/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/IDL \ No newline at end of file diff --git a/Lang/Icon/Arbitrary-precision-integers--included- b/Lang/Icon/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..b7d0e4eeb6 --- /dev/null +++ b/Lang/Icon/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Icon \ No newline at end of file diff --git a/Lang/Icon/Arbitrary-precision-integers-included b/Lang/Icon/Arbitrary-precision-integers-included deleted file mode 120000 index 8c434fc8d1..0000000000 --- a/Lang/Icon/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Icon \ No newline at end of file diff --git a/Lang/Icon/Binary-digits b/Lang/Icon/Binary-digits new file mode 120000 index 0000000000..933ee54968 --- /dev/null +++ b/Lang/Icon/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Icon \ No newline at end of file diff --git a/Lang/Icon/Brownian-tree b/Lang/Icon/Brownian-tree new file mode 120000 index 0000000000..8a18b095a8 --- /dev/null +++ b/Lang/Icon/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/Icon \ No newline at end of file diff --git a/Lang/Icon/Calendar---for-real-programmers b/Lang/Icon/Calendar---for-real-programmers new file mode 120000 index 0000000000..f87a3bab2a --- /dev/null +++ b/Lang/Icon/Calendar---for-real-programmers @@ -0,0 +1 @@ +../../Task/Calendar---for-real-programmers/Icon \ No newline at end of file diff --git a/Lang/Icon/Calendar-for-real-programmers b/Lang/Icon/Calendar-for-real-programmers deleted file mode 120000 index 57f8c378c9..0000000000 --- a/Lang/Icon/Calendar-for-real-programmers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Calendar-for-real-programmers/Icon \ No newline at end of file diff --git a/Lang/Icon/Catalan-numbers b/Lang/Icon/Catalan-numbers new file mode 120000 index 0000000000..0990a4dbbf --- /dev/null +++ b/Lang/Icon/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Icon \ No newline at end of file diff --git a/Lang/Icon/Copy-a-string b/Lang/Icon/Copy-a-string new file mode 120000 index 0000000000..ff2dc36b67 --- /dev/null +++ b/Lang/Icon/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Icon \ No newline at end of file diff --git a/Lang/Icon/Dragon-curve b/Lang/Icon/Dragon-curve new file mode 120000 index 0000000000..c8aa48cfc6 --- /dev/null +++ b/Lang/Icon/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/Icon \ No newline at end of file diff --git a/Lang/Icon/Environment-variables b/Lang/Icon/Environment-variables new file mode 120000 index 0000000000..b0737290a2 --- /dev/null +++ b/Lang/Icon/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Icon \ No newline at end of file diff --git a/Lang/Icon/Execute-a-Markov-algorithm b/Lang/Icon/Execute-a-Markov-algorithm new file mode 120000 index 0000000000..4d98aabcc8 --- /dev/null +++ b/Lang/Icon/Execute-a-Markov-algorithm @@ -0,0 +1 @@ +../../Task/Execute-a-Markov-algorithm/Icon \ No newline at end of file diff --git a/Lang/Icon/Guess-the-number-With-feedback--player- b/Lang/Icon/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..c5b95fd0bc --- /dev/null +++ b/Lang/Icon/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/Icon \ No newline at end of file diff --git a/Lang/Icon/Guess-the-number-With-feedback-player b/Lang/Icon/Guess-the-number-With-feedback-player deleted file mode 120000 index cfd8c80db1..0000000000 --- a/Lang/Icon/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/Icon \ No newline at end of file diff --git a/Lang/Icon/N-queens-problem b/Lang/Icon/N-queens-problem new file mode 120000 index 0000000000..8b1ac05ab6 --- /dev/null +++ b/Lang/Icon/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Icon \ No newline at end of file diff --git a/Lang/Icon/Named-parameters b/Lang/Icon/Named-parameters new file mode 120000 index 0000000000..6d3a99db1e --- /dev/null +++ b/Lang/Icon/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/Icon \ No newline at end of file diff --git a/Lang/Icon/Non-decimal-radices-Convert b/Lang/Icon/Non-decimal-radices-Convert new file mode 120000 index 0000000000..6e71b8fa68 --- /dev/null +++ b/Lang/Icon/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/Icon \ No newline at end of file diff --git a/Lang/Icon/Non-decimal-radices-Input b/Lang/Icon/Non-decimal-radices-Input new file mode 120000 index 0000000000..61920462a8 --- /dev/null +++ b/Lang/Icon/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/Icon \ No newline at end of file diff --git a/Lang/Icon/Non-decimal-radices-Output b/Lang/Icon/Non-decimal-radices-Output new file mode 120000 index 0000000000..ea97dfdc0b --- /dev/null +++ b/Lang/Icon/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/Icon \ No newline at end of file diff --git a/Lang/Icon/Nth-root b/Lang/Icon/Nth-root new file mode 120000 index 0000000000..6e5e5e2db3 --- /dev/null +++ b/Lang/Icon/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Icon \ No newline at end of file diff --git a/Lang/Icon/Null-object b/Lang/Icon/Null-object new file mode 120000 index 0000000000..69696e850e --- /dev/null +++ b/Lang/Icon/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Icon \ No newline at end of file diff --git a/Lang/Icon/Number-reversal-game b/Lang/Icon/Number-reversal-game new file mode 120000 index 0000000000..5c3d976985 --- /dev/null +++ b/Lang/Icon/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/Icon \ No newline at end of file diff --git a/Lang/Icon/One-dimensional-cellular-automata b/Lang/Icon/One-dimensional-cellular-automata new file mode 120000 index 0000000000..deedbd4e74 --- /dev/null +++ b/Lang/Icon/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Icon \ No newline at end of file diff --git a/Lang/Icon/One-of-n-lines-in-a-file b/Lang/Icon/One-of-n-lines-in-a-file new file mode 120000 index 0000000000..89f0099f3a --- /dev/null +++ b/Lang/Icon/One-of-n-lines-in-a-file @@ -0,0 +1 @@ +../../Task/One-of-n-lines-in-a-file/Icon \ No newline at end of file diff --git a/Lang/Icon/Optional-parameters b/Lang/Icon/Optional-parameters new file mode 120000 index 0000000000..c76872cc43 --- /dev/null +++ b/Lang/Icon/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/Icon \ No newline at end of file diff --git a/Lang/Icon/Order-two-numerical-lists b/Lang/Icon/Order-two-numerical-lists new file mode 120000 index 0000000000..6ccb5cd759 --- /dev/null +++ b/Lang/Icon/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/Icon \ No newline at end of file diff --git a/Lang/Icon/Palindrome-detection b/Lang/Icon/Palindrome-detection new file mode 120000 index 0000000000..a7cc755442 --- /dev/null +++ b/Lang/Icon/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Icon \ No newline at end of file diff --git a/Lang/Icon/Pangram-checker b/Lang/Icon/Pangram-checker new file mode 120000 index 0000000000..edce033656 --- /dev/null +++ b/Lang/Icon/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Icon \ No newline at end of file diff --git a/Lang/Icon/Parsing-RPN-calculator-algorithm b/Lang/Icon/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..f8faa25d8b --- /dev/null +++ b/Lang/Icon/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/Icon \ No newline at end of file diff --git a/Lang/Icon/Parsing-RPN-to-infix-conversion b/Lang/Icon/Parsing-RPN-to-infix-conversion new file mode 120000 index 0000000000..94e584f9ea --- /dev/null +++ b/Lang/Icon/Parsing-RPN-to-infix-conversion @@ -0,0 +1 @@ +../../Task/Parsing-RPN-to-infix-conversion/Icon \ No newline at end of file diff --git a/Lang/Icon/Parsing-Shunting-yard-algorithm b/Lang/Icon/Parsing-Shunting-yard-algorithm new file mode 120000 index 0000000000..29001baa85 --- /dev/null +++ b/Lang/Icon/Parsing-Shunting-yard-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-Shunting-yard-algorithm/Icon \ No newline at end of file diff --git a/Lang/Icon/Partial-function-application b/Lang/Icon/Partial-function-application new file mode 120000 index 0000000000..ee28d094f2 --- /dev/null +++ b/Lang/Icon/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/Icon \ No newline at end of file diff --git a/Lang/Icon/Pascals-triangle b/Lang/Icon/Pascals-triangle new file mode 120000 index 0000000000..3ed7987f30 --- /dev/null +++ b/Lang/Icon/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Icon \ No newline at end of file diff --git a/Lang/Icon/Percentage-difference-between-images b/Lang/Icon/Percentage-difference-between-images new file mode 120000 index 0000000000..5bce44725e --- /dev/null +++ b/Lang/Icon/Percentage-difference-between-images @@ -0,0 +1 @@ +../../Task/Percentage-difference-between-images/Icon \ No newline at end of file diff --git a/Lang/Icon/Perfect-numbers b/Lang/Icon/Perfect-numbers new file mode 120000 index 0000000000..37a03264f1 --- /dev/null +++ b/Lang/Icon/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Icon \ No newline at end of file diff --git a/Lang/Icon/Permutations b/Lang/Icon/Permutations new file mode 120000 index 0000000000..6fb453198c --- /dev/null +++ b/Lang/Icon/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Icon \ No newline at end of file diff --git a/Lang/Icon/Pick-random-element b/Lang/Icon/Pick-random-element new file mode 120000 index 0000000000..085d5a688a --- /dev/null +++ b/Lang/Icon/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/Icon \ No newline at end of file diff --git a/Lang/Icon/Pinstripe-Display b/Lang/Icon/Pinstripe-Display new file mode 120000 index 0000000000..41ac714814 --- /dev/null +++ b/Lang/Icon/Pinstripe-Display @@ -0,0 +1 @@ +../../Task/Pinstripe-Display/Icon \ No newline at end of file diff --git a/Lang/Icon/Playing-cards b/Lang/Icon/Playing-cards new file mode 120000 index 0000000000..a06ebe05c9 --- /dev/null +++ b/Lang/Icon/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/Icon \ No newline at end of file diff --git a/Lang/Icon/Plot-coordinate-pairs b/Lang/Icon/Plot-coordinate-pairs new file mode 120000 index 0000000000..463d5ccfb6 --- /dev/null +++ b/Lang/Icon/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/Icon \ No newline at end of file diff --git a/Lang/Icon/Power-set b/Lang/Icon/Power-set new file mode 120000 index 0000000000..4a195da18b --- /dev/null +++ b/Lang/Icon/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Icon \ No newline at end of file diff --git a/Lang/Icon/Pragmatic-directives b/Lang/Icon/Pragmatic-directives new file mode 120000 index 0000000000..816fd5e628 --- /dev/null +++ b/Lang/Icon/Pragmatic-directives @@ -0,0 +1 @@ +../../Task/Pragmatic-directives/Icon \ No newline at end of file diff --git a/Lang/Icon/Price-fraction b/Lang/Icon/Price-fraction new file mode 120000 index 0000000000..8dfbf211b6 --- /dev/null +++ b/Lang/Icon/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Icon \ No newline at end of file diff --git a/Lang/Icon/Primality-by-trial-division b/Lang/Icon/Primality-by-trial-division new file mode 120000 index 0000000000..31d6a108b2 --- /dev/null +++ b/Lang/Icon/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Icon \ No newline at end of file diff --git a/Lang/Icon/Prime-decomposition b/Lang/Icon/Prime-decomposition new file mode 120000 index 0000000000..315b71c025 --- /dev/null +++ b/Lang/Icon/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Icon \ No newline at end of file diff --git a/Lang/Icon/Priority-queue b/Lang/Icon/Priority-queue new file mode 120000 index 0000000000..b77cdfb42b --- /dev/null +++ b/Lang/Icon/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/Icon \ No newline at end of file diff --git a/Lang/Icon/Probabilistic-choice b/Lang/Icon/Probabilistic-choice new file mode 120000 index 0000000000..1f0cf2d3fe --- /dev/null +++ b/Lang/Icon/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/Icon \ No newline at end of file diff --git a/Lang/Icon/Problem-of-Apollonius b/Lang/Icon/Problem-of-Apollonius new file mode 120000 index 0000000000..40c9f1fe8b --- /dev/null +++ b/Lang/Icon/Problem-of-Apollonius @@ -0,0 +1 @@ +../../Task/Problem-of-Apollonius/Icon \ No newline at end of file diff --git a/Lang/Icon/Program-name b/Lang/Icon/Program-name new file mode 120000 index 0000000000..a3c8cb843c --- /dev/null +++ b/Lang/Icon/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Icon \ No newline at end of file diff --git a/Lang/Icon/Program-termination b/Lang/Icon/Program-termination new file mode 120000 index 0000000000..12509956d6 --- /dev/null +++ b/Lang/Icon/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Icon \ No newline at end of file diff --git a/Lang/Icon/Pythagorean-triples b/Lang/Icon/Pythagorean-triples new file mode 120000 index 0000000000..e71dac2858 --- /dev/null +++ b/Lang/Icon/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/Icon \ No newline at end of file diff --git a/Lang/Icon/Queue-Usage b/Lang/Icon/Queue-Usage new file mode 120000 index 0000000000..4a1e8825e4 --- /dev/null +++ b/Lang/Icon/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/Icon \ No newline at end of file diff --git a/Lang/Icon/Random-numbers b/Lang/Icon/Random-numbers new file mode 120000 index 0000000000..e672aa5bd0 --- /dev/null +++ b/Lang/Icon/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Icon \ No newline at end of file diff --git a/Lang/Icon/Range-expansion b/Lang/Icon/Range-expansion new file mode 120000 index 0000000000..a229147fda --- /dev/null +++ b/Lang/Icon/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/Icon \ No newline at end of file diff --git a/Lang/Icon/Range-extraction b/Lang/Icon/Range-extraction new file mode 120000 index 0000000000..7436a97892 --- /dev/null +++ b/Lang/Icon/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/Icon \ No newline at end of file diff --git a/Lang/Icon/Read-a-specific-line-from-a-file b/Lang/Icon/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..6f876d970d --- /dev/null +++ b/Lang/Icon/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/Icon \ No newline at end of file diff --git a/Lang/Icon/Read-entire-file b/Lang/Icon/Read-entire-file new file mode 120000 index 0000000000..7d07921e20 --- /dev/null +++ b/Lang/Icon/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Icon \ No newline at end of file diff --git a/Lang/Icon/Regular-expressions b/Lang/Icon/Regular-expressions new file mode 120000 index 0000000000..b021c1c9bc --- /dev/null +++ b/Lang/Icon/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Icon \ No newline at end of file diff --git a/Lang/Icon/Remove-duplicate-elements b/Lang/Icon/Remove-duplicate-elements new file mode 120000 index 0000000000..6667123cdf --- /dev/null +++ b/Lang/Icon/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Icon \ No newline at end of file diff --git a/Lang/Icon/Remove-lines-from-a-file b/Lang/Icon/Remove-lines-from-a-file new file mode 120000 index 0000000000..127da2f48b --- /dev/null +++ b/Lang/Icon/Remove-lines-from-a-file @@ -0,0 +1 @@ +../../Task/Remove-lines-from-a-file/Icon \ No newline at end of file diff --git a/Lang/Icon/Rename-a-file b/Lang/Icon/Rename-a-file new file mode 120000 index 0000000000..6b43d0904d --- /dev/null +++ b/Lang/Icon/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Icon \ No newline at end of file diff --git a/Lang/Icon/Repeat-a-string b/Lang/Icon/Repeat-a-string new file mode 120000 index 0000000000..3881c464a4 --- /dev/null +++ b/Lang/Icon/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Icon \ No newline at end of file diff --git a/Lang/Icon/Return-multiple-values b/Lang/Icon/Return-multiple-values new file mode 120000 index 0000000000..da6a4fd84f --- /dev/null +++ b/Lang/Icon/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Icon \ No newline at end of file diff --git a/Lang/Icon/Reverse-a-string b/Lang/Icon/Reverse-a-string new file mode 120000 index 0000000000..805a16bd47 --- /dev/null +++ b/Lang/Icon/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Icon \ No newline at end of file diff --git a/Lang/Icon/Rock-paper-scissors b/Lang/Icon/Rock-paper-scissors new file mode 120000 index 0000000000..fd9f1309c3 --- /dev/null +++ b/Lang/Icon/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/Icon \ No newline at end of file diff --git a/Lang/Icon/Roman-numerals-Decode b/Lang/Icon/Roman-numerals-Decode new file mode 120000 index 0000000000..cebfb6fb60 --- /dev/null +++ b/Lang/Icon/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/Icon \ No newline at end of file diff --git a/Lang/Icon/Roman-numerals-Encode b/Lang/Icon/Roman-numerals-Encode new file mode 120000 index 0000000000..ef20ffe485 --- /dev/null +++ b/Lang/Icon/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Icon \ No newline at end of file diff --git a/Lang/Icon/Roots-of-unity b/Lang/Icon/Roots-of-unity new file mode 120000 index 0000000000..3e2ce2c9b2 --- /dev/null +++ b/Lang/Icon/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/Icon \ No newline at end of file diff --git a/Lang/Icon/Rot-13 b/Lang/Icon/Rot-13 new file mode 120000 index 0000000000..d6344a5a6d --- /dev/null +++ b/Lang/Icon/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Icon \ No newline at end of file diff --git a/Lang/Icon/Run-length-encoding b/Lang/Icon/Run-length-encoding new file mode 120000 index 0000000000..c9e81a5cad --- /dev/null +++ b/Lang/Icon/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Icon \ No newline at end of file diff --git a/Lang/Icon/S-Expressions b/Lang/Icon/S-Expressions new file mode 120000 index 0000000000..3a84fea158 --- /dev/null +++ b/Lang/Icon/S-Expressions @@ -0,0 +1 @@ +../../Task/S-Expressions/Icon \ No newline at end of file diff --git a/Lang/Icon/SEDOLs b/Lang/Icon/SEDOLs new file mode 120000 index 0000000000..f4ee9e4e3f --- /dev/null +++ b/Lang/Icon/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/Icon \ No newline at end of file diff --git a/Lang/Icon/Scope-modifiers b/Lang/Icon/Scope-modifiers new file mode 120000 index 0000000000..d917cf9745 --- /dev/null +++ b/Lang/Icon/Scope-modifiers @@ -0,0 +1 @@ +../../Task/Scope-modifiers/Icon \ No newline at end of file diff --git a/Lang/Icon/Self-describing-numbers b/Lang/Icon/Self-describing-numbers new file mode 120000 index 0000000000..3d4fb3554e --- /dev/null +++ b/Lang/Icon/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/Icon \ No newline at end of file diff --git a/Lang/Icon/Self-referential-sequence b/Lang/Icon/Self-referential-sequence new file mode 120000 index 0000000000..2638aa4263 --- /dev/null +++ b/Lang/Icon/Self-referential-sequence @@ -0,0 +1 @@ +../../Task/Self-referential-sequence/Icon \ No newline at end of file diff --git a/Lang/Icon/Sequence-of-non-squares b/Lang/Icon/Sequence-of-non-squares new file mode 120000 index 0000000000..9751068db2 --- /dev/null +++ b/Lang/Icon/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Icon \ No newline at end of file diff --git a/Lang/Icon/Set b/Lang/Icon/Set new file mode 120000 index 0000000000..6592f42180 --- /dev/null +++ b/Lang/Icon/Set @@ -0,0 +1 @@ +../../Task/Set/Icon \ No newline at end of file diff --git a/Lang/Inform-7/Number-names b/Lang/Inform-7/Number-names new file mode 120000 index 0000000000..fafe18e5a8 --- /dev/null +++ b/Lang/Inform-7/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Number-reversal-game b/Lang/Inform-7/Number-reversal-game new file mode 120000 index 0000000000..dc82d3c155 --- /dev/null +++ b/Lang/Inform-7/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Parametric-polymorphism b/Lang/Inform-7/Parametric-polymorphism new file mode 120000 index 0000000000..c258de8cea --- /dev/null +++ b/Lang/Inform-7/Parametric-polymorphism @@ -0,0 +1 @@ +../../Task/Parametric-polymorphism/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Polymorphism b/Lang/Inform-7/Polymorphism new file mode 120000 index 0000000000..adedb0972f --- /dev/null +++ b/Lang/Inform-7/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Price-fraction b/Lang/Inform-7/Price-fraction new file mode 120000 index 0000000000..fd753ec07a --- /dev/null +++ b/Lang/Inform-7/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Read-entire-file b/Lang/Inform-7/Read-entire-file new file mode 120000 index 0000000000..adab9e9c88 --- /dev/null +++ b/Lang/Inform-7/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Regular-expressions b/Lang/Inform-7/Regular-expressions new file mode 120000 index 0000000000..53fd63bfd1 --- /dev/null +++ b/Lang/Inform-7/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Remove-duplicate-elements b/Lang/Inform-7/Remove-duplicate-elements new file mode 120000 index 0000000000..458f7c5d46 --- /dev/null +++ b/Lang/Inform-7/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Inform-7 \ No newline at end of file diff --git a/Lang/Inform-7/Repeat-a-string b/Lang/Inform-7/Repeat-a-string new file mode 120000 index 0000000000..a8ad8f0faf --- /dev/null +++ b/Lang/Inform-7/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Inform-7 \ No newline at end of file diff --git a/Lang/Io/Null-object b/Lang/Io/Null-object new file mode 120000 index 0000000000..4cdb8aad66 --- /dev/null +++ b/Lang/Io/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Io \ No newline at end of file diff --git a/Lang/Io/Number-reversal-game b/Lang/Io/Number-reversal-game new file mode 120000 index 0000000000..9236a7872b --- /dev/null +++ b/Lang/Io/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/Io \ No newline at end of file diff --git a/Lang/Io/Program-name b/Lang/Io/Program-name new file mode 120000 index 0000000000..00a70d094a --- /dev/null +++ b/Lang/Io/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Io \ No newline at end of file diff --git a/Lang/Io/Rename-a-file b/Lang/Io/Rename-a-file new file mode 120000 index 0000000000..46e4be7256 --- /dev/null +++ b/Lang/Io/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Io \ No newline at end of file diff --git a/Lang/Io/Reverse-a-string b/Lang/Io/Reverse-a-string new file mode 120000 index 0000000000..d44b59867c --- /dev/null +++ b/Lang/Io/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Io \ No newline at end of file diff --git a/Lang/Io/Roman-numerals-Encode b/Lang/Io/Roman-numerals-Encode new file mode 120000 index 0000000000..a921baea46 --- /dev/null +++ b/Lang/Io/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Io \ No newline at end of file diff --git a/Lang/Ioke/Palindrome-detection b/Lang/Ioke/Palindrome-detection new file mode 120000 index 0000000000..1c47ea443c --- /dev/null +++ b/Lang/Ioke/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Ioke \ No newline at end of file diff --git a/Lang/Ioke/Pangram-checker b/Lang/Ioke/Pangram-checker new file mode 120000 index 0000000000..68dcc0eefb --- /dev/null +++ b/Lang/Ioke/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Ioke \ No newline at end of file diff --git a/Lang/J/Arbitrary-precision-integers--included- b/Lang/J/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..5003aa07d6 --- /dev/null +++ b/Lang/J/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/J \ No newline at end of file diff --git a/Lang/J/Arbitrary-precision-integers-included b/Lang/J/Arbitrary-precision-integers-included deleted file mode 120000 index 117a4a0f52..0000000000 --- a/Lang/J/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/J \ No newline at end of file diff --git a/Lang/J/Binary-digits b/Lang/J/Binary-digits new file mode 120000 index 0000000000..5a91b5deff --- /dev/null +++ b/Lang/J/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/J \ No newline at end of file diff --git a/Lang/J/Brownian-tree b/Lang/J/Brownian-tree new file mode 120000 index 0000000000..73a3100ead --- /dev/null +++ b/Lang/J/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/J \ No newline at end of file diff --git a/Lang/J/Calendar---for-real-programmers b/Lang/J/Calendar---for-real-programmers new file mode 120000 index 0000000000..a2d759cdf1 --- /dev/null +++ b/Lang/J/Calendar---for-real-programmers @@ -0,0 +1 @@ +../../Task/Calendar---for-real-programmers/J \ No newline at end of file diff --git a/Lang/J/Calendar-for-real-programmers b/Lang/J/Calendar-for-real-programmers deleted file mode 120000 index e1a87250b6..0000000000 --- a/Lang/J/Calendar-for-real-programmers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Calendar-for-real-programmers/J \ No newline at end of file diff --git a/Lang/J/Catalan-numbers b/Lang/J/Catalan-numbers new file mode 120000 index 0000000000..2f98e2cf9b --- /dev/null +++ b/Lang/J/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/J \ No newline at end of file diff --git a/Lang/J/Copy-a-string b/Lang/J/Copy-a-string new file mode 120000 index 0000000000..c86ff7da82 --- /dev/null +++ b/Lang/J/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/J \ No newline at end of file diff --git a/Lang/J/Dragon-curve b/Lang/J/Dragon-curve new file mode 120000 index 0000000000..55d3c89ecc --- /dev/null +++ b/Lang/J/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/J \ No newline at end of file diff --git a/Lang/J/Environment-variables b/Lang/J/Environment-variables new file mode 120000 index 0000000000..70bb1736a5 --- /dev/null +++ b/Lang/J/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/J \ No newline at end of file diff --git a/Lang/J/Execute-a-Markov-algorithm b/Lang/J/Execute-a-Markov-algorithm new file mode 120000 index 0000000000..9141b5a83a --- /dev/null +++ b/Lang/J/Execute-a-Markov-algorithm @@ -0,0 +1 @@ +../../Task/Execute-a-Markov-algorithm/J \ No newline at end of file diff --git a/Lang/J/Guess-the-number-With-feedback--player- b/Lang/J/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..3062017f3a --- /dev/null +++ b/Lang/J/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/J \ No newline at end of file diff --git a/Lang/J/Guess-the-number-With-feedback-player b/Lang/J/Guess-the-number-With-feedback-player deleted file mode 120000 index 2a98134f4d..0000000000 --- a/Lang/J/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/J \ No newline at end of file diff --git a/Lang/J/N-queens-problem b/Lang/J/N-queens-problem new file mode 120000 index 0000000000..87d0f5d7d9 --- /dev/null +++ b/Lang/J/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/J \ No newline at end of file diff --git a/Lang/J/Named-parameters b/Lang/J/Named-parameters new file mode 120000 index 0000000000..0c60e9d781 --- /dev/null +++ b/Lang/J/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/J \ No newline at end of file diff --git a/Lang/J/Non-continuous-subsequences b/Lang/J/Non-continuous-subsequences new file mode 120000 index 0000000000..ce3e91fd18 --- /dev/null +++ b/Lang/J/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/J \ No newline at end of file diff --git a/Lang/J/Non-decimal-radices-Convert b/Lang/J/Non-decimal-radices-Convert new file mode 120000 index 0000000000..c9c2b3f8ec --- /dev/null +++ b/Lang/J/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/J \ No newline at end of file diff --git a/Lang/J/Non-decimal-radices-Input b/Lang/J/Non-decimal-radices-Input new file mode 120000 index 0000000000..77ccc38d5b --- /dev/null +++ b/Lang/J/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/J \ No newline at end of file diff --git a/Lang/J/Non-decimal-radices-Output b/Lang/J/Non-decimal-radices-Output new file mode 120000 index 0000000000..610d73b366 --- /dev/null +++ b/Lang/J/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/J \ No newline at end of file diff --git a/Lang/J/Nth-root b/Lang/J/Nth-root new file mode 120000 index 0000000000..b60c569508 --- /dev/null +++ b/Lang/J/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/J \ No newline at end of file diff --git a/Lang/J/Null-object b/Lang/J/Null-object new file mode 120000 index 0000000000..0a9257963a --- /dev/null +++ b/Lang/J/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/J \ No newline at end of file diff --git a/Lang/J/Number-reversal-game b/Lang/J/Number-reversal-game new file mode 120000 index 0000000000..b51ef9c683 --- /dev/null +++ b/Lang/J/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/J \ No newline at end of file diff --git a/Lang/J/Numeric-error-propagation b/Lang/J/Numeric-error-propagation new file mode 120000 index 0000000000..dd7d0e74d7 --- /dev/null +++ b/Lang/J/Numeric-error-propagation @@ -0,0 +1 @@ +../../Task/Numeric-error-propagation/J \ No newline at end of file diff --git a/Lang/J/Numerical-integration b/Lang/J/Numerical-integration new file mode 120000 index 0000000000..580399d949 --- /dev/null +++ b/Lang/J/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/J \ No newline at end of file diff --git a/Lang/J/Numerical-integration-Gauss-Legendre-Quadrature b/Lang/J/Numerical-integration-Gauss-Legendre-Quadrature new file mode 120000 index 0000000000..eb6b35e6f3 --- /dev/null +++ b/Lang/J/Numerical-integration-Gauss-Legendre-Quadrature @@ -0,0 +1 @@ +../../Task/Numerical-integration-Gauss-Legendre-Quadrature/J \ No newline at end of file diff --git a/Lang/J/Object-serialization b/Lang/J/Object-serialization new file mode 120000 index 0000000000..14dc3de028 --- /dev/null +++ b/Lang/J/Object-serialization @@ -0,0 +1 @@ +../../Task/Object-serialization/J \ No newline at end of file diff --git a/Lang/J/One-dimensional-cellular-automata b/Lang/J/One-dimensional-cellular-automata new file mode 120000 index 0000000000..3ac8483c82 --- /dev/null +++ b/Lang/J/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/J \ No newline at end of file diff --git a/Lang/J/One-of-n-lines-in-a-file b/Lang/J/One-of-n-lines-in-a-file new file mode 120000 index 0000000000..4104537ff9 --- /dev/null +++ b/Lang/J/One-of-n-lines-in-a-file @@ -0,0 +1 @@ +../../Task/One-of-n-lines-in-a-file/J \ No newline at end of file diff --git a/Lang/J/OpenGL b/Lang/J/OpenGL new file mode 120000 index 0000000000..c22d2944d8 --- /dev/null +++ b/Lang/J/OpenGL @@ -0,0 +1 @@ +../../Task/OpenGL/J \ No newline at end of file diff --git a/Lang/J/Optional-parameters b/Lang/J/Optional-parameters new file mode 120000 index 0000000000..662864a637 --- /dev/null +++ b/Lang/J/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/J \ No newline at end of file diff --git a/Lang/J/Order-two-numerical-lists b/Lang/J/Order-two-numerical-lists new file mode 120000 index 0000000000..0f2d49b6c6 --- /dev/null +++ b/Lang/J/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/J \ No newline at end of file diff --git a/Lang/J/Ordered-Partitions b/Lang/J/Ordered-Partitions new file mode 120000 index 0000000000..f21199dfe8 --- /dev/null +++ b/Lang/J/Ordered-Partitions @@ -0,0 +1 @@ +../../Task/Ordered-Partitions/J \ No newline at end of file diff --git a/Lang/J/Palindrome-detection b/Lang/J/Palindrome-detection new file mode 120000 index 0000000000..3245635903 --- /dev/null +++ b/Lang/J/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/J \ No newline at end of file diff --git a/Lang/J/Pangram-checker b/Lang/J/Pangram-checker new file mode 120000 index 0000000000..532904567b --- /dev/null +++ b/Lang/J/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/J \ No newline at end of file diff --git a/Lang/J/Parallel-calculations b/Lang/J/Parallel-calculations new file mode 120000 index 0000000000..ea7b5c2044 --- /dev/null +++ b/Lang/J/Parallel-calculations @@ -0,0 +1 @@ +../../Task/Parallel-calculations/J \ No newline at end of file diff --git a/Lang/J/Parsing-RPN-calculator-algorithm b/Lang/J/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..122938576a --- /dev/null +++ b/Lang/J/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/J \ No newline at end of file diff --git a/Lang/J/Parsing-RPN-to-infix-conversion b/Lang/J/Parsing-RPN-to-infix-conversion new file mode 120000 index 0000000000..49d26ed5b3 --- /dev/null +++ b/Lang/J/Parsing-RPN-to-infix-conversion @@ -0,0 +1 @@ +../../Task/Parsing-RPN-to-infix-conversion/J \ No newline at end of file diff --git a/Lang/J/Parsing-Shunting-yard-algorithm b/Lang/J/Parsing-Shunting-yard-algorithm new file mode 120000 index 0000000000..4f8a0c0caf --- /dev/null +++ b/Lang/J/Parsing-Shunting-yard-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-Shunting-yard-algorithm/J \ No newline at end of file diff --git a/Lang/J/Partial-function-application b/Lang/J/Partial-function-application new file mode 120000 index 0000000000..506d70f138 --- /dev/null +++ b/Lang/J/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/J \ No newline at end of file diff --git a/Lang/J/Pascals-triangle b/Lang/J/Pascals-triangle new file mode 120000 index 0000000000..49e43c836e --- /dev/null +++ b/Lang/J/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/J \ No newline at end of file diff --git a/Lang/J/Pascals-triangle-Puzzle b/Lang/J/Pascals-triangle-Puzzle new file mode 120000 index 0000000000..02047b8a9f --- /dev/null +++ b/Lang/J/Pascals-triangle-Puzzle @@ -0,0 +1 @@ +../../Task/Pascals-triangle-Puzzle/J \ No newline at end of file diff --git a/Lang/J/Pattern-matching b/Lang/J/Pattern-matching new file mode 120000 index 0000000000..9064012102 --- /dev/null +++ b/Lang/J/Pattern-matching @@ -0,0 +1 @@ +../../Task/Pattern-matching/J \ No newline at end of file diff --git a/Lang/J/Percentage-difference-between-images b/Lang/J/Percentage-difference-between-images new file mode 120000 index 0000000000..cd95f1bc8e --- /dev/null +++ b/Lang/J/Percentage-difference-between-images @@ -0,0 +1 @@ +../../Task/Percentage-difference-between-images/J \ No newline at end of file diff --git a/Lang/J/Perfect-numbers b/Lang/J/Perfect-numbers new file mode 120000 index 0000000000..2f0de78c5d --- /dev/null +++ b/Lang/J/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/J \ No newline at end of file diff --git a/Lang/J/Permutation-test b/Lang/J/Permutation-test new file mode 120000 index 0000000000..d3d4fef76a --- /dev/null +++ b/Lang/J/Permutation-test @@ -0,0 +1 @@ +../../Task/Permutation-test/J \ No newline at end of file diff --git a/Lang/J/Permutations b/Lang/J/Permutations new file mode 120000 index 0000000000..9b54738e3e --- /dev/null +++ b/Lang/J/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/J \ No newline at end of file diff --git a/Lang/J/Permutations-Derangements b/Lang/J/Permutations-Derangements new file mode 120000 index 0000000000..5f2ecc08eb --- /dev/null +++ b/Lang/J/Permutations-Derangements @@ -0,0 +1 @@ +../../Task/Permutations-Derangements/J \ No newline at end of file diff --git a/Lang/J/Permutations-by-swapping b/Lang/J/Permutations-by-swapping new file mode 120000 index 0000000000..736da5c96a --- /dev/null +++ b/Lang/J/Permutations-by-swapping @@ -0,0 +1 @@ +../../Task/Permutations-by-swapping/J \ No newline at end of file diff --git a/Lang/J/Pick-random-element b/Lang/J/Pick-random-element new file mode 120000 index 0000000000..b8b870b897 --- /dev/null +++ b/Lang/J/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/J \ No newline at end of file diff --git a/Lang/J/Pig-the-dice-game b/Lang/J/Pig-the-dice-game new file mode 120000 index 0000000000..8d9a7088c9 --- /dev/null +++ b/Lang/J/Pig-the-dice-game @@ -0,0 +1 @@ +../../Task/Pig-the-dice-game/J \ No newline at end of file diff --git a/Lang/J/Pig-the-dice-game-Player b/Lang/J/Pig-the-dice-game-Player new file mode 120000 index 0000000000..d1c66b3153 --- /dev/null +++ b/Lang/J/Pig-the-dice-game-Player @@ -0,0 +1 @@ +../../Task/Pig-the-dice-game-Player/J \ No newline at end of file diff --git a/Lang/J/Pinstripe-Display b/Lang/J/Pinstripe-Display new file mode 120000 index 0000000000..76fcbe5024 --- /dev/null +++ b/Lang/J/Pinstripe-Display @@ -0,0 +1 @@ +../../Task/Pinstripe-Display/J \ No newline at end of file diff --git a/Lang/J/Playing-cards b/Lang/J/Playing-cards new file mode 120000 index 0000000000..55e46274f8 --- /dev/null +++ b/Lang/J/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/J \ No newline at end of file diff --git a/Lang/J/Plot-coordinate-pairs b/Lang/J/Plot-coordinate-pairs new file mode 120000 index 0000000000..cb1fa14a29 --- /dev/null +++ b/Lang/J/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/J \ No newline at end of file diff --git a/Lang/J/Polymorphism b/Lang/J/Polymorphism new file mode 120000 index 0000000000..c4c806f60e --- /dev/null +++ b/Lang/J/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/J \ No newline at end of file diff --git a/Lang/J/Polynomial-long-division b/Lang/J/Polynomial-long-division new file mode 120000 index 0000000000..c10968177f --- /dev/null +++ b/Lang/J/Polynomial-long-division @@ -0,0 +1 @@ +../../Task/Polynomial-long-division/J \ No newline at end of file diff --git a/Lang/J/Polynomial-regression b/Lang/J/Polynomial-regression new file mode 120000 index 0000000000..6d26b82657 --- /dev/null +++ b/Lang/J/Polynomial-regression @@ -0,0 +1 @@ +../../Task/Polynomial-regression/J \ No newline at end of file diff --git a/Lang/J/Power-set b/Lang/J/Power-set new file mode 120000 index 0000000000..bf3c1825d6 --- /dev/null +++ b/Lang/J/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/J \ No newline at end of file diff --git a/Lang/J/Pragmatic-directives b/Lang/J/Pragmatic-directives new file mode 120000 index 0000000000..00032618ed --- /dev/null +++ b/Lang/J/Pragmatic-directives @@ -0,0 +1 @@ +../../Task/Pragmatic-directives/J \ No newline at end of file diff --git a/Lang/J/Price-fraction b/Lang/J/Price-fraction new file mode 120000 index 0000000000..a28b60bec8 --- /dev/null +++ b/Lang/J/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/J \ No newline at end of file diff --git a/Lang/J/Primality-by-trial-division b/Lang/J/Primality-by-trial-division new file mode 120000 index 0000000000..85659f1315 --- /dev/null +++ b/Lang/J/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/J \ No newline at end of file diff --git a/Lang/J/Prime-decomposition b/Lang/J/Prime-decomposition new file mode 120000 index 0000000000..1dfc74630b --- /dev/null +++ b/Lang/J/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/J \ No newline at end of file diff --git a/Lang/J/Priority-queue b/Lang/J/Priority-queue new file mode 120000 index 0000000000..03728faf65 --- /dev/null +++ b/Lang/J/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/J \ No newline at end of file diff --git a/Lang/J/Probabilistic-choice b/Lang/J/Probabilistic-choice new file mode 120000 index 0000000000..00aca1b648 --- /dev/null +++ b/Lang/J/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/J \ No newline at end of file diff --git a/Lang/J/Problem-of-Apollonius b/Lang/J/Problem-of-Apollonius new file mode 120000 index 0000000000..b910e4455d --- /dev/null +++ b/Lang/J/Problem-of-Apollonius @@ -0,0 +1 @@ +../../Task/Problem-of-Apollonius/J \ No newline at end of file diff --git a/Lang/J/Program-name b/Lang/J/Program-name new file mode 120000 index 0000000000..926cf7d3ed --- /dev/null +++ b/Lang/J/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/J \ No newline at end of file diff --git a/Lang/J/Program-termination b/Lang/J/Program-termination new file mode 120000 index 0000000000..e4f3ba3b85 --- /dev/null +++ b/Lang/J/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/J \ No newline at end of file diff --git a/Lang/J/Pythagorean-triples b/Lang/J/Pythagorean-triples new file mode 120000 index 0000000000..4b2536e69d --- /dev/null +++ b/Lang/J/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/J \ No newline at end of file diff --git a/Lang/J/QR-decomposition b/Lang/J/QR-decomposition new file mode 120000 index 0000000000..369f1719c6 --- /dev/null +++ b/Lang/J/QR-decomposition @@ -0,0 +1 @@ +../../Task/QR-decomposition/J \ No newline at end of file diff --git a/Lang/J/Quaternion-type b/Lang/J/Quaternion-type new file mode 120000 index 0000000000..0868577467 --- /dev/null +++ b/Lang/J/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/J \ No newline at end of file diff --git a/Lang/J/Queue-Definition b/Lang/J/Queue-Definition new file mode 120000 index 0000000000..48b397a09c --- /dev/null +++ b/Lang/J/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/J \ No newline at end of file diff --git a/Lang/J/Queue-Usage b/Lang/J/Queue-Usage new file mode 120000 index 0000000000..4b8128c1f3 --- /dev/null +++ b/Lang/J/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/J \ No newline at end of file diff --git a/Lang/J/Random-number-generator--device- b/Lang/J/Random-number-generator--device- new file mode 120000 index 0000000000..b29db9a596 --- /dev/null +++ b/Lang/J/Random-number-generator--device- @@ -0,0 +1 @@ +../../Task/Random-number-generator--device-/J \ No newline at end of file diff --git a/Lang/J/Random-numbers b/Lang/J/Random-numbers new file mode 120000 index 0000000000..33199b1b1d --- /dev/null +++ b/Lang/J/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/J \ No newline at end of file diff --git a/Lang/J/Range-expansion b/Lang/J/Range-expansion new file mode 120000 index 0000000000..6477ab20a9 --- /dev/null +++ b/Lang/J/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/J \ No newline at end of file diff --git a/Lang/J/Range-extraction b/Lang/J/Range-extraction new file mode 120000 index 0000000000..0f83ca3591 --- /dev/null +++ b/Lang/J/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/J \ No newline at end of file diff --git a/Lang/J/Rate-counter b/Lang/J/Rate-counter new file mode 120000 index 0000000000..a8e21ac618 --- /dev/null +++ b/Lang/J/Rate-counter @@ -0,0 +1 @@ +../../Task/Rate-counter/J \ No newline at end of file diff --git a/Lang/J/Ray-casting-algorithm b/Lang/J/Ray-casting-algorithm new file mode 120000 index 0000000000..34c28320c8 --- /dev/null +++ b/Lang/J/Ray-casting-algorithm @@ -0,0 +1 @@ +../../Task/Ray-casting-algorithm/J \ No newline at end of file diff --git a/Lang/J/Read-a-configuration-file b/Lang/J/Read-a-configuration-file new file mode 120000 index 0000000000..320f6ee007 --- /dev/null +++ b/Lang/J/Read-a-configuration-file @@ -0,0 +1 @@ +../../Task/Read-a-configuration-file/J \ No newline at end of file diff --git a/Lang/J/Read-a-file-line-by-line b/Lang/J/Read-a-file-line-by-line new file mode 120000 index 0000000000..fc9bf1421b --- /dev/null +++ b/Lang/J/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/J \ No newline at end of file diff --git a/Lang/J/Read-a-specific-line-from-a-file b/Lang/J/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..04e57c30b2 --- /dev/null +++ b/Lang/J/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/J \ No newline at end of file diff --git a/Lang/J/Read-entire-file b/Lang/J/Read-entire-file new file mode 120000 index 0000000000..6bc33e04f9 --- /dev/null +++ b/Lang/J/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/J \ No newline at end of file diff --git a/Lang/J/Real-constants-and-functions b/Lang/J/Real-constants-and-functions new file mode 120000 index 0000000000..180adb196d --- /dev/null +++ b/Lang/J/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/J \ No newline at end of file diff --git a/Lang/J/Reduced-row-echelon-form b/Lang/J/Reduced-row-echelon-form new file mode 120000 index 0000000000..6e122cac4a --- /dev/null +++ b/Lang/J/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/J \ No newline at end of file diff --git a/Lang/J/Regular-expressions b/Lang/J/Regular-expressions new file mode 120000 index 0000000000..5700770c89 --- /dev/null +++ b/Lang/J/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/J \ No newline at end of file diff --git a/Lang/J/Remove-duplicate-elements b/Lang/J/Remove-duplicate-elements new file mode 120000 index 0000000000..ddebd430fa --- /dev/null +++ b/Lang/J/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/J \ No newline at end of file diff --git a/Lang/J/Remove-lines-from-a-file b/Lang/J/Remove-lines-from-a-file new file mode 120000 index 0000000000..1cfbd66134 --- /dev/null +++ b/Lang/J/Remove-lines-from-a-file @@ -0,0 +1 @@ +../../Task/Remove-lines-from-a-file/J \ No newline at end of file diff --git a/Lang/J/Rename-a-file b/Lang/J/Rename-a-file new file mode 120000 index 0000000000..8d5febdf60 --- /dev/null +++ b/Lang/J/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/J \ No newline at end of file diff --git a/Lang/J/Repeat-a-string b/Lang/J/Repeat-a-string new file mode 120000 index 0000000000..48bfc8a98b --- /dev/null +++ b/Lang/J/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/J \ No newline at end of file diff --git a/Lang/J/Resistor-mesh b/Lang/J/Resistor-mesh new file mode 120000 index 0000000000..bb61bc6c4a --- /dev/null +++ b/Lang/J/Resistor-mesh @@ -0,0 +1 @@ +../../Task/Resistor-mesh/J \ No newline at end of file diff --git a/Lang/J/Respond-to-an-unknown-method-call b/Lang/J/Respond-to-an-unknown-method-call new file mode 120000 index 0000000000..476530312a --- /dev/null +++ b/Lang/J/Respond-to-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Respond-to-an-unknown-method-call/J \ No newline at end of file diff --git a/Lang/J/Return-multiple-values b/Lang/J/Return-multiple-values new file mode 120000 index 0000000000..063be2ad2b --- /dev/null +++ b/Lang/J/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/J \ No newline at end of file diff --git a/Lang/J/Reverse-a-string b/Lang/J/Reverse-a-string new file mode 120000 index 0000000000..ea648d4981 --- /dev/null +++ b/Lang/J/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/J \ No newline at end of file diff --git a/Lang/J/Rock-paper-scissors b/Lang/J/Rock-paper-scissors new file mode 120000 index 0000000000..76ca19decd --- /dev/null +++ b/Lang/J/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/J \ No newline at end of file diff --git a/Lang/J/Roman-numerals-Decode b/Lang/J/Roman-numerals-Decode new file mode 120000 index 0000000000..735f07481e --- /dev/null +++ b/Lang/J/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/J \ No newline at end of file diff --git a/Lang/J/Roman-numerals-Encode b/Lang/J/Roman-numerals-Encode new file mode 120000 index 0000000000..9ec94555ac --- /dev/null +++ b/Lang/J/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/J \ No newline at end of file diff --git a/Lang/J/Roots-of-a-function b/Lang/J/Roots-of-a-function new file mode 120000 index 0000000000..8bb9c8835c --- /dev/null +++ b/Lang/J/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/J \ No newline at end of file diff --git a/Lang/J/Roots-of-a-quadratic-function b/Lang/J/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..3272227028 --- /dev/null +++ b/Lang/J/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/J \ No newline at end of file diff --git a/Lang/J/Roots-of-unity b/Lang/J/Roots-of-unity new file mode 120000 index 0000000000..a10835a938 --- /dev/null +++ b/Lang/J/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/J \ No newline at end of file diff --git a/Lang/J/Rosetta-Code-Count-examples b/Lang/J/Rosetta-Code-Count-examples new file mode 120000 index 0000000000..bf0f74d897 --- /dev/null +++ b/Lang/J/Rosetta-Code-Count-examples @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Count-examples/J \ No newline at end of file diff --git a/Lang/J/Rosetta-Code-Find-unimplemented-tasks b/Lang/J/Rosetta-Code-Find-unimplemented-tasks new file mode 120000 index 0000000000..d69b65cbde --- /dev/null +++ b/Lang/J/Rosetta-Code-Find-unimplemented-tasks @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Find-unimplemented-tasks/J \ No newline at end of file diff --git a/Lang/J/Rosetta-Code-Fix-code-tags b/Lang/J/Rosetta-Code-Fix-code-tags new file mode 120000 index 0000000000..ac294949d3 --- /dev/null +++ b/Lang/J/Rosetta-Code-Fix-code-tags @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Fix-code-tags/J \ No newline at end of file diff --git a/Lang/J/Rot-13 b/Lang/J/Rot-13 new file mode 120000 index 0000000000..534bb9419e --- /dev/null +++ b/Lang/J/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/J \ No newline at end of file diff --git a/Lang/J/Run-length-encoding b/Lang/J/Run-length-encoding new file mode 120000 index 0000000000..74ef7c7123 --- /dev/null +++ b/Lang/J/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/J \ No newline at end of file diff --git a/Lang/J/Runtime-evaluation b/Lang/J/Runtime-evaluation new file mode 120000 index 0000000000..535b13d94a --- /dev/null +++ b/Lang/J/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/J \ No newline at end of file diff --git a/Lang/J/Runtime-evaluation-In-an-environment b/Lang/J/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..b8d1d93620 --- /dev/null +++ b/Lang/J/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/J \ No newline at end of file diff --git a/Lang/J/S-Expressions b/Lang/J/S-Expressions new file mode 120000 index 0000000000..a8936fb366 --- /dev/null +++ b/Lang/J/S-Expressions @@ -0,0 +1 @@ +../../Task/S-Expressions/J \ No newline at end of file diff --git a/Lang/J/SEDOLs b/Lang/J/SEDOLs new file mode 120000 index 0000000000..d0232f012f --- /dev/null +++ b/Lang/J/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/J \ No newline at end of file diff --git a/Lang/J/Safe-addition b/Lang/J/Safe-addition new file mode 120000 index 0000000000..cbfe63c6f0 --- /dev/null +++ b/Lang/J/Safe-addition @@ -0,0 +1 @@ +../../Task/Safe-addition/J \ No newline at end of file diff --git a/Lang/J/Same-Fringe b/Lang/J/Same-Fringe new file mode 120000 index 0000000000..31d4dee43d --- /dev/null +++ b/Lang/J/Same-Fringe @@ -0,0 +1 @@ +../../Task/Same-Fringe/J \ No newline at end of file diff --git a/Lang/J/Scope-modifiers b/Lang/J/Scope-modifiers new file mode 120000 index 0000000000..2b5b0c70de --- /dev/null +++ b/Lang/J/Scope-modifiers @@ -0,0 +1 @@ +../../Task/Scope-modifiers/J \ No newline at end of file diff --git a/Lang/J/Self-describing-numbers b/Lang/J/Self-describing-numbers new file mode 120000 index 0000000000..081d182a68 --- /dev/null +++ b/Lang/J/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/J \ No newline at end of file diff --git a/Lang/J/Self-referential-sequence b/Lang/J/Self-referential-sequence new file mode 120000 index 0000000000..09b313977f --- /dev/null +++ b/Lang/J/Self-referential-sequence @@ -0,0 +1 @@ +../../Task/Self-referential-sequence/J \ No newline at end of file diff --git a/Lang/J/Semordnilap b/Lang/J/Semordnilap new file mode 120000 index 0000000000..1fe42cc187 --- /dev/null +++ b/Lang/J/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/J \ No newline at end of file diff --git a/Lang/J/Sequence-of-non-squares b/Lang/J/Sequence-of-non-squares new file mode 120000 index 0000000000..131b465639 --- /dev/null +++ b/Lang/J/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/J \ No newline at end of file diff --git a/Lang/J/Set b/Lang/J/Set new file mode 120000 index 0000000000..4192da2a04 --- /dev/null +++ b/Lang/J/Set @@ -0,0 +1 @@ +../../Task/Set/J \ No newline at end of file diff --git a/Lang/J/Set-consolidation b/Lang/J/Set-consolidation new file mode 120000 index 0000000000..271d2e4ab9 --- /dev/null +++ b/Lang/J/Set-consolidation @@ -0,0 +1 @@ +../../Task/Set-consolidation/J \ No newline at end of file diff --git a/Lang/J/Set-of-real-numbers b/Lang/J/Set-of-real-numbers new file mode 120000 index 0000000000..04a9780ff4 --- /dev/null +++ b/Lang/J/Set-of-real-numbers @@ -0,0 +1 @@ +../../Task/Set-of-real-numbers/J \ No newline at end of file diff --git a/Lang/Java/Arbitrary-precision-integers--included- b/Lang/Java/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..956f5f1a6b --- /dev/null +++ b/Lang/Java/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Java \ No newline at end of file diff --git a/Lang/Java/Arbitrary-precision-integers-included b/Lang/Java/Arbitrary-precision-integers-included deleted file mode 120000 index abe7ace75c..0000000000 --- a/Lang/Java/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Java \ No newline at end of file diff --git a/Lang/Java/Binary-digits b/Lang/Java/Binary-digits new file mode 120000 index 0000000000..54db7d131e --- /dev/null +++ b/Lang/Java/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Java \ No newline at end of file diff --git a/Lang/Java/Brownian-tree b/Lang/Java/Brownian-tree new file mode 120000 index 0000000000..fcc6104978 --- /dev/null +++ b/Lang/Java/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/Java \ No newline at end of file diff --git a/Lang/Java/Catalan-numbers b/Lang/Java/Catalan-numbers new file mode 120000 index 0000000000..aecfbd1ee4 --- /dev/null +++ b/Lang/Java/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Java \ No newline at end of file diff --git a/Lang/Java/Copy-a-string b/Lang/Java/Copy-a-string new file mode 120000 index 0000000000..ce55d97d56 --- /dev/null +++ b/Lang/Java/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Java \ No newline at end of file diff --git a/Lang/Java/Dragon-curve b/Lang/Java/Dragon-curve new file mode 120000 index 0000000000..32ee4aab75 --- /dev/null +++ b/Lang/Java/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/Java \ No newline at end of file diff --git a/Lang/Java/Environment-variables b/Lang/Java/Environment-variables new file mode 120000 index 0000000000..8c3eefc0f3 --- /dev/null +++ b/Lang/Java/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Java \ No newline at end of file diff --git a/Lang/Java/Guess-the-number-With-feedback--player- b/Lang/Java/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..b1799401cb --- /dev/null +++ b/Lang/Java/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/Java \ No newline at end of file diff --git a/Lang/Java/Guess-the-number-With-feedback-player b/Lang/Java/Guess-the-number-With-feedback-player deleted file mode 120000 index c0f79efb5e..0000000000 --- a/Lang/Java/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/Java \ No newline at end of file diff --git a/Lang/Java/N-queens-problem b/Lang/Java/N-queens-problem new file mode 120000 index 0000000000..6cd3d64d0c --- /dev/null +++ b/Lang/Java/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Java \ No newline at end of file diff --git a/Lang/Java/Named-parameters b/Lang/Java/Named-parameters new file mode 120000 index 0000000000..f3fc40f079 --- /dev/null +++ b/Lang/Java/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/Java \ No newline at end of file diff --git a/Lang/Java/Non-decimal-radices-Convert b/Lang/Java/Non-decimal-radices-Convert new file mode 120000 index 0000000000..401792cbbd --- /dev/null +++ b/Lang/Java/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/Java \ No newline at end of file diff --git a/Lang/Java/Non-decimal-radices-Input b/Lang/Java/Non-decimal-radices-Input new file mode 120000 index 0000000000..4d3ea348e4 --- /dev/null +++ b/Lang/Java/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/Java \ No newline at end of file diff --git a/Lang/Java/Non-decimal-radices-Output b/Lang/Java/Non-decimal-radices-Output new file mode 120000 index 0000000000..633c0dcb22 --- /dev/null +++ b/Lang/Java/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/Java \ No newline at end of file diff --git a/Lang/Java/Nth-root b/Lang/Java/Nth-root new file mode 120000 index 0000000000..967ff4d54d --- /dev/null +++ b/Lang/Java/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Java \ No newline at end of file diff --git a/Lang/Java/Null-object b/Lang/Java/Null-object new file mode 120000 index 0000000000..556b872dfd --- /dev/null +++ b/Lang/Java/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Java \ No newline at end of file diff --git a/Lang/Java/Number-names b/Lang/Java/Number-names new file mode 120000 index 0000000000..a65011e94e --- /dev/null +++ b/Lang/Java/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/Java \ No newline at end of file diff --git a/Lang/Java/Number-reversal-game b/Lang/Java/Number-reversal-game new file mode 120000 index 0000000000..056a163b9c --- /dev/null +++ b/Lang/Java/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/Java \ No newline at end of file diff --git a/Lang/Java/Numerical-integration b/Lang/Java/Numerical-integration new file mode 120000 index 0000000000..956aa7c1cf --- /dev/null +++ b/Lang/Java/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/Java \ No newline at end of file diff --git a/Lang/Java/Object-serialization b/Lang/Java/Object-serialization new file mode 120000 index 0000000000..b99eac0512 --- /dev/null +++ b/Lang/Java/Object-serialization @@ -0,0 +1 @@ +../../Task/Object-serialization/Java \ No newline at end of file diff --git a/Lang/Java/One-dimensional-cellular-automata b/Lang/Java/One-dimensional-cellular-automata new file mode 120000 index 0000000000..2a495757c8 --- /dev/null +++ b/Lang/Java/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Java \ No newline at end of file diff --git a/Lang/Java/One-of-n-lines-in-a-file b/Lang/Java/One-of-n-lines-in-a-file new file mode 120000 index 0000000000..aba38ad0e1 --- /dev/null +++ b/Lang/Java/One-of-n-lines-in-a-file @@ -0,0 +1 @@ +../../Task/One-of-n-lines-in-a-file/Java \ No newline at end of file diff --git a/Lang/Java/OpenGL b/Lang/Java/OpenGL new file mode 120000 index 0000000000..607419db90 --- /dev/null +++ b/Lang/Java/OpenGL @@ -0,0 +1 @@ +../../Task/OpenGL/Java \ No newline at end of file diff --git a/Lang/Java/Optional-parameters b/Lang/Java/Optional-parameters new file mode 120000 index 0000000000..81d18dec37 --- /dev/null +++ b/Lang/Java/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/Java \ No newline at end of file diff --git a/Lang/Java/Order-two-numerical-lists b/Lang/Java/Order-two-numerical-lists new file mode 120000 index 0000000000..c2a57f4de3 --- /dev/null +++ b/Lang/Java/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/Java \ No newline at end of file diff --git a/Lang/Java/Palindrome-detection b/Lang/Java/Palindrome-detection new file mode 120000 index 0000000000..fec35fa02c --- /dev/null +++ b/Lang/Java/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Java \ No newline at end of file diff --git a/Lang/Java/Pangram-checker b/Lang/Java/Pangram-checker new file mode 120000 index 0000000000..367b548429 --- /dev/null +++ b/Lang/Java/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Java \ No newline at end of file diff --git a/Lang/Java/Parametric-polymorphism b/Lang/Java/Parametric-polymorphism new file mode 120000 index 0000000000..6e10b97db4 --- /dev/null +++ b/Lang/Java/Parametric-polymorphism @@ -0,0 +1 @@ +../../Task/Parametric-polymorphism/Java \ No newline at end of file diff --git a/Lang/Java/Parametrized-SQL-statement b/Lang/Java/Parametrized-SQL-statement new file mode 120000 index 0000000000..bfd7f9e750 --- /dev/null +++ b/Lang/Java/Parametrized-SQL-statement @@ -0,0 +1 @@ +../../Task/Parametrized-SQL-statement/Java \ No newline at end of file diff --git a/Lang/Java/Parsing-RPN-calculator-algorithm b/Lang/Java/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..acfb9bcf66 --- /dev/null +++ b/Lang/Java/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/Java \ No newline at end of file diff --git a/Lang/Java/Partial-function-application b/Lang/Java/Partial-function-application new file mode 120000 index 0000000000..cfb59e7f24 --- /dev/null +++ b/Lang/Java/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/Java \ No newline at end of file diff --git a/Lang/Java/Pascals-triangle b/Lang/Java/Pascals-triangle new file mode 120000 index 0000000000..92c141e6c7 --- /dev/null +++ b/Lang/Java/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Java \ No newline at end of file diff --git a/Lang/Java/Percentage-difference-between-images b/Lang/Java/Percentage-difference-between-images new file mode 120000 index 0000000000..af79e01a5a --- /dev/null +++ b/Lang/Java/Percentage-difference-between-images @@ -0,0 +1 @@ +../../Task/Percentage-difference-between-images/Java \ No newline at end of file diff --git a/Lang/Java/Perfect-numbers b/Lang/Java/Perfect-numbers new file mode 120000 index 0000000000..bca8db95eb --- /dev/null +++ b/Lang/Java/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Java \ No newline at end of file diff --git a/Lang/Java/Permutations b/Lang/Java/Permutations new file mode 120000 index 0000000000..ca0f3f8689 --- /dev/null +++ b/Lang/Java/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Java \ No newline at end of file diff --git a/Lang/Java/Permutations-Derangements b/Lang/Java/Permutations-Derangements new file mode 120000 index 0000000000..732f05a8d1 --- /dev/null +++ b/Lang/Java/Permutations-Derangements @@ -0,0 +1 @@ +../../Task/Permutations-Derangements/Java \ No newline at end of file diff --git a/Lang/Java/Pick-random-element b/Lang/Java/Pick-random-element new file mode 120000 index 0000000000..e9b525a13c --- /dev/null +++ b/Lang/Java/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/Java \ No newline at end of file diff --git a/Lang/Java/Pig-the-dice-game b/Lang/Java/Pig-the-dice-game new file mode 120000 index 0000000000..afd8c09b9b --- /dev/null +++ b/Lang/Java/Pig-the-dice-game @@ -0,0 +1 @@ +../../Task/Pig-the-dice-game/Java \ No newline at end of file diff --git a/Lang/Java/Playing-cards b/Lang/Java/Playing-cards new file mode 120000 index 0000000000..9ec25009aa --- /dev/null +++ b/Lang/Java/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/Java \ No newline at end of file diff --git a/Lang/Java/Plot-coordinate-pairs b/Lang/Java/Plot-coordinate-pairs new file mode 120000 index 0000000000..8aa98519f0 --- /dev/null +++ b/Lang/Java/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/Java \ No newline at end of file diff --git a/Lang/Java/Pointers-and-references b/Lang/Java/Pointers-and-references new file mode 120000 index 0000000000..05cb15eac8 --- /dev/null +++ b/Lang/Java/Pointers-and-references @@ -0,0 +1 @@ +../../Task/Pointers-and-references/Java \ No newline at end of file diff --git a/Lang/Java/Polymorphic-copy b/Lang/Java/Polymorphic-copy new file mode 120000 index 0000000000..d49c8e2e4c --- /dev/null +++ b/Lang/Java/Polymorphic-copy @@ -0,0 +1 @@ +../../Task/Polymorphic-copy/Java \ No newline at end of file diff --git a/Lang/Java/Polymorphism b/Lang/Java/Polymorphism new file mode 120000 index 0000000000..4e983a6148 --- /dev/null +++ b/Lang/Java/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/Java \ No newline at end of file diff --git a/Lang/Java/Power-set b/Lang/Java/Power-set new file mode 120000 index 0000000000..c4bdf1e9de --- /dev/null +++ b/Lang/Java/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Java \ No newline at end of file diff --git a/Lang/Java/Price-fraction b/Lang/Java/Price-fraction new file mode 120000 index 0000000000..b67b5eb8de --- /dev/null +++ b/Lang/Java/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Java \ No newline at end of file diff --git a/Lang/Java/Primality-by-trial-division b/Lang/Java/Primality-by-trial-division new file mode 120000 index 0000000000..d2c5e51d94 --- /dev/null +++ b/Lang/Java/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Java \ No newline at end of file diff --git a/Lang/Java/Prime-decomposition b/Lang/Java/Prime-decomposition new file mode 120000 index 0000000000..0b540a9f12 --- /dev/null +++ b/Lang/Java/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Java \ No newline at end of file diff --git a/Lang/Java/Priority-queue b/Lang/Java/Priority-queue new file mode 120000 index 0000000000..a5a9d21860 --- /dev/null +++ b/Lang/Java/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/Java \ No newline at end of file diff --git a/Lang/Java/Probabilistic-choice b/Lang/Java/Probabilistic-choice new file mode 120000 index 0000000000..1acb9cb308 --- /dev/null +++ b/Lang/Java/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/Java \ No newline at end of file diff --git a/Lang/Java/Problem-of-Apollonius b/Lang/Java/Problem-of-Apollonius new file mode 120000 index 0000000000..cde8e3fdbd --- /dev/null +++ b/Lang/Java/Problem-of-Apollonius @@ -0,0 +1 @@ +../../Task/Problem-of-Apollonius/Java \ No newline at end of file diff --git a/Lang/Java/Program-name b/Lang/Java/Program-name new file mode 120000 index 0000000000..a5794586ce --- /dev/null +++ b/Lang/Java/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Java \ No newline at end of file diff --git a/Lang/Java/Program-termination b/Lang/Java/Program-termination new file mode 120000 index 0000000000..db113954c0 --- /dev/null +++ b/Lang/Java/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Java \ No newline at end of file diff --git a/Lang/Java/Pythagorean-triples b/Lang/Java/Pythagorean-triples new file mode 120000 index 0000000000..9209e8101b --- /dev/null +++ b/Lang/Java/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/Java \ No newline at end of file diff --git a/Lang/Java/Quaternion-type b/Lang/Java/Quaternion-type new file mode 120000 index 0000000000..3cf154640d --- /dev/null +++ b/Lang/Java/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/Java \ No newline at end of file diff --git a/Lang/Java/Queue-Definition b/Lang/Java/Queue-Definition new file mode 120000 index 0000000000..9f38e227f3 --- /dev/null +++ b/Lang/Java/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/Java \ No newline at end of file diff --git a/Lang/Java/Queue-Usage b/Lang/Java/Queue-Usage new file mode 120000 index 0000000000..680ebd6b26 --- /dev/null +++ b/Lang/Java/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/Java \ No newline at end of file diff --git a/Lang/Java/RIPEMD-160 b/Lang/Java/RIPEMD-160 new file mode 120000 index 0000000000..426a305408 --- /dev/null +++ b/Lang/Java/RIPEMD-160 @@ -0,0 +1 @@ +../../Task/RIPEMD-160/Java \ No newline at end of file diff --git a/Lang/Java/Random-number-generator--device- b/Lang/Java/Random-number-generator--device- new file mode 120000 index 0000000000..d7dee5ff24 --- /dev/null +++ b/Lang/Java/Random-number-generator--device- @@ -0,0 +1 @@ +../../Task/Random-number-generator--device-/Java \ No newline at end of file diff --git a/Lang/Java/Random-numbers b/Lang/Java/Random-numbers new file mode 120000 index 0000000000..2b44077f90 --- /dev/null +++ b/Lang/Java/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Java \ No newline at end of file diff --git a/Lang/Java/Range-expansion b/Lang/Java/Range-expansion new file mode 120000 index 0000000000..4e732fc6ea --- /dev/null +++ b/Lang/Java/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/Java \ No newline at end of file diff --git a/Lang/Java/Range-extraction b/Lang/Java/Range-extraction new file mode 120000 index 0000000000..699527a4de --- /dev/null +++ b/Lang/Java/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/Java \ No newline at end of file diff --git a/Lang/Java/Read-a-file-line-by-line b/Lang/Java/Read-a-file-line-by-line new file mode 120000 index 0000000000..c0901e398d --- /dev/null +++ b/Lang/Java/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Java \ No newline at end of file diff --git a/Lang/Java/Read-a-specific-line-from-a-file b/Lang/Java/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..d8d836bc6c --- /dev/null +++ b/Lang/Java/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/Java \ No newline at end of file diff --git a/Lang/Java/Read-entire-file b/Lang/Java/Read-entire-file new file mode 120000 index 0000000000..9b76ee4401 --- /dev/null +++ b/Lang/Java/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Java \ No newline at end of file diff --git a/Lang/Java/Real-constants-and-functions b/Lang/Java/Real-constants-and-functions new file mode 120000 index 0000000000..c511928a05 --- /dev/null +++ b/Lang/Java/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Java \ No newline at end of file diff --git a/Lang/Java/Reduced-row-echelon-form b/Lang/Java/Reduced-row-echelon-form new file mode 120000 index 0000000000..ac509c5712 --- /dev/null +++ b/Lang/Java/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/Java \ No newline at end of file diff --git a/Lang/Java/Regular-expressions b/Lang/Java/Regular-expressions new file mode 120000 index 0000000000..8001e6c964 --- /dev/null +++ b/Lang/Java/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Java \ No newline at end of file diff --git a/Lang/Java/Remove-duplicate-elements b/Lang/Java/Remove-duplicate-elements new file mode 120000 index 0000000000..8eb1072a8d --- /dev/null +++ b/Lang/Java/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Java \ No newline at end of file diff --git a/Lang/Java/Rename-a-file b/Lang/Java/Rename-a-file new file mode 120000 index 0000000000..c6d27225df --- /dev/null +++ b/Lang/Java/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Java \ No newline at end of file diff --git a/Lang/Java/Repeat-a-string b/Lang/Java/Repeat-a-string new file mode 120000 index 0000000000..7f21a370a0 --- /dev/null +++ b/Lang/Java/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Java \ No newline at end of file diff --git a/Lang/Java/Return-multiple-values b/Lang/Java/Return-multiple-values new file mode 120000 index 0000000000..eb9ea17bca --- /dev/null +++ b/Lang/Java/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Java \ No newline at end of file diff --git a/Lang/Java/Reverse-a-string b/Lang/Java/Reverse-a-string new file mode 120000 index 0000000000..4663b5cae2 --- /dev/null +++ b/Lang/Java/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Java \ No newline at end of file diff --git a/Lang/Java/Rock-paper-scissors b/Lang/Java/Rock-paper-scissors new file mode 120000 index 0000000000..33cd5dd61d --- /dev/null +++ b/Lang/Java/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/Java \ No newline at end of file diff --git a/Lang/Java/Roman-numerals-Decode b/Lang/Java/Roman-numerals-Decode new file mode 120000 index 0000000000..b41c8913d3 --- /dev/null +++ b/Lang/Java/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/Java \ No newline at end of file diff --git a/Lang/Java/Roman-numerals-Encode b/Lang/Java/Roman-numerals-Encode new file mode 120000 index 0000000000..ae4d0f6877 --- /dev/null +++ b/Lang/Java/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Java \ No newline at end of file diff --git a/Lang/Java/Roots-of-a-function b/Lang/Java/Roots-of-a-function new file mode 120000 index 0000000000..c5a07947ea --- /dev/null +++ b/Lang/Java/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/Java \ No newline at end of file diff --git a/Lang/Java/Roots-of-a-quadratic-function b/Lang/Java/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..58525f3121 --- /dev/null +++ b/Lang/Java/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/Java \ No newline at end of file diff --git a/Lang/Java/Roots-of-unity b/Lang/Java/Roots-of-unity new file mode 120000 index 0000000000..bcf567d387 --- /dev/null +++ b/Lang/Java/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/Java \ No newline at end of file diff --git a/Lang/Java/Rosetta-Code-Count-examples b/Lang/Java/Rosetta-Code-Count-examples new file mode 120000 index 0000000000..94544023c4 --- /dev/null +++ b/Lang/Java/Rosetta-Code-Count-examples @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Count-examples/Java \ No newline at end of file diff --git a/Lang/Java/Rot-13 b/Lang/Java/Rot-13 new file mode 120000 index 0000000000..9e39efbd73 --- /dev/null +++ b/Lang/Java/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Java \ No newline at end of file diff --git a/Lang/Java/Run-length-encoding b/Lang/Java/Run-length-encoding new file mode 120000 index 0000000000..f09413515e --- /dev/null +++ b/Lang/Java/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Java \ No newline at end of file diff --git a/Lang/Java/Runtime-evaluation-In-an-environment b/Lang/Java/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..9e46d6425f --- /dev/null +++ b/Lang/Java/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/Java \ No newline at end of file diff --git a/Lang/Java/S-Expressions b/Lang/Java/S-Expressions new file mode 120000 index 0000000000..af614644d0 --- /dev/null +++ b/Lang/Java/S-Expressions @@ -0,0 +1 @@ +../../Task/S-Expressions/Java \ No newline at end of file diff --git a/Lang/Java/SEDOLs b/Lang/Java/SEDOLs new file mode 120000 index 0000000000..94362c6f29 --- /dev/null +++ b/Lang/Java/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/Java \ No newline at end of file diff --git a/Lang/Java/Same-Fringe b/Lang/Java/Same-Fringe new file mode 120000 index 0000000000..a2427bf40a --- /dev/null +++ b/Lang/Java/Same-Fringe @@ -0,0 +1 @@ +../../Task/Same-Fringe/Java \ No newline at end of file diff --git a/Lang/Java/Scope-modifiers b/Lang/Java/Scope-modifiers new file mode 120000 index 0000000000..6c8007d978 --- /dev/null +++ b/Lang/Java/Scope-modifiers @@ -0,0 +1 @@ +../../Task/Scope-modifiers/Java \ No newline at end of file diff --git a/Lang/Java/Secure-temporary-file b/Lang/Java/Secure-temporary-file new file mode 120000 index 0000000000..ef652e1ad0 --- /dev/null +++ b/Lang/Java/Secure-temporary-file @@ -0,0 +1 @@ +../../Task/Secure-temporary-file/Java \ No newline at end of file diff --git a/Lang/Java/Self-describing-numbers b/Lang/Java/Self-describing-numbers new file mode 120000 index 0000000000..4193126b71 --- /dev/null +++ b/Lang/Java/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/Java \ No newline at end of file diff --git a/Lang/Java/Semordnilap b/Lang/Java/Semordnilap new file mode 120000 index 0000000000..2a7f68b403 --- /dev/null +++ b/Lang/Java/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/Java \ No newline at end of file diff --git a/Lang/Java/Send-an-unknown-method-call b/Lang/Java/Send-an-unknown-method-call new file mode 120000 index 0000000000..c92709d728 --- /dev/null +++ b/Lang/Java/Send-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Send-an-unknown-method-call/Java \ No newline at end of file diff --git a/Lang/Java/Send-email b/Lang/Java/Send-email new file mode 120000 index 0000000000..4af9f74c0b --- /dev/null +++ b/Lang/Java/Send-email @@ -0,0 +1 @@ +../../Task/Send-email/Java \ No newline at end of file diff --git a/Lang/Java/Sequence-of-non-squares b/Lang/Java/Sequence-of-non-squares new file mode 120000 index 0000000000..2789ecdb0d --- /dev/null +++ b/Lang/Java/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Java \ No newline at end of file diff --git a/Lang/Java/Set b/Lang/Java/Set new file mode 120000 index 0000000000..75f78c3f72 --- /dev/null +++ b/Lang/Java/Set @@ -0,0 +1 @@ +../../Task/Set/Java \ No newline at end of file diff --git a/Lang/Java/Set-consolidation b/Lang/Java/Set-consolidation new file mode 120000 index 0000000000..74a9f522dc --- /dev/null +++ b/Lang/Java/Set-consolidation @@ -0,0 +1 @@ +../../Task/Set-consolidation/Java \ No newline at end of file diff --git a/Lang/JavaScript/Binary-digits b/Lang/JavaScript/Binary-digits new file mode 120000 index 0000000000..e0b9bce821 --- /dev/null +++ b/Lang/JavaScript/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Brownian-tree b/Lang/JavaScript/Brownian-tree new file mode 120000 index 0000000000..dfcd9bce73 --- /dev/null +++ b/Lang/JavaScript/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Catalan-numbers b/Lang/JavaScript/Catalan-numbers new file mode 120000 index 0000000000..534520e802 --- /dev/null +++ b/Lang/JavaScript/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Copy-a-string b/Lang/JavaScript/Copy-a-string new file mode 120000 index 0000000000..645c308c14 --- /dev/null +++ b/Lang/JavaScript/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Dragon-curve b/Lang/JavaScript/Dragon-curve new file mode 120000 index 0000000000..de79c759de --- /dev/null +++ b/Lang/JavaScript/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Environment-variables b/Lang/JavaScript/Environment-variables new file mode 120000 index 0000000000..64f0bf44fd --- /dev/null +++ b/Lang/JavaScript/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Guess-the-number-With-feedback--player- b/Lang/JavaScript/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..9906ba0f98 --- /dev/null +++ b/Lang/JavaScript/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Guess-the-number-With-feedback-player b/Lang/JavaScript/Guess-the-number-With-feedback-player deleted file mode 120000 index 9eda3dd737..0000000000 --- a/Lang/JavaScript/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Named-parameters b/Lang/JavaScript/Named-parameters new file mode 120000 index 0000000000..89630d4126 --- /dev/null +++ b/Lang/JavaScript/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Non-continuous-subsequences b/Lang/JavaScript/Non-continuous-subsequences new file mode 120000 index 0000000000..665aefed7f --- /dev/null +++ b/Lang/JavaScript/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Non-decimal-radices-Convert b/Lang/JavaScript/Non-decimal-radices-Convert new file mode 120000 index 0000000000..ae5ce1a589 --- /dev/null +++ b/Lang/JavaScript/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Non-decimal-radices-Input b/Lang/JavaScript/Non-decimal-radices-Input new file mode 120000 index 0000000000..da09513be6 --- /dev/null +++ b/Lang/JavaScript/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Non-decimal-radices-Output b/Lang/JavaScript/Non-decimal-radices-Output new file mode 120000 index 0000000000..2b1d2ed5c9 --- /dev/null +++ b/Lang/JavaScript/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Nth-root b/Lang/JavaScript/Nth-root new file mode 120000 index 0000000000..b88040a8f9 --- /dev/null +++ b/Lang/JavaScript/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Null-object b/Lang/JavaScript/Null-object new file mode 120000 index 0000000000..8d0e0f55cd --- /dev/null +++ b/Lang/JavaScript/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Number-reversal-game b/Lang/JavaScript/Number-reversal-game new file mode 120000 index 0000000000..2458272676 --- /dev/null +++ b/Lang/JavaScript/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/One-dimensional-cellular-automata b/Lang/JavaScript/One-dimensional-cellular-automata new file mode 120000 index 0000000000..e23267f03a --- /dev/null +++ b/Lang/JavaScript/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/OpenGL b/Lang/JavaScript/OpenGL new file mode 120000 index 0000000000..a3f0e45ee8 --- /dev/null +++ b/Lang/JavaScript/OpenGL @@ -0,0 +1 @@ +../../Task/OpenGL/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Optional-parameters b/Lang/JavaScript/Optional-parameters new file mode 120000 index 0000000000..013b190da5 --- /dev/null +++ b/Lang/JavaScript/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Palindrome-detection b/Lang/JavaScript/Palindrome-detection new file mode 120000 index 0000000000..6972e7a8d1 --- /dev/null +++ b/Lang/JavaScript/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Pangram-checker b/Lang/JavaScript/Pangram-checker new file mode 120000 index 0000000000..fe0c6dc286 --- /dev/null +++ b/Lang/JavaScript/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Parallel-calculations b/Lang/JavaScript/Parallel-calculations new file mode 120000 index 0000000000..a3d2dac298 --- /dev/null +++ b/Lang/JavaScript/Parallel-calculations @@ -0,0 +1 @@ +../../Task/Parallel-calculations/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Pascals-triangle b/Lang/JavaScript/Pascals-triangle new file mode 120000 index 0000000000..6fec36780d --- /dev/null +++ b/Lang/JavaScript/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Perfect-numbers b/Lang/JavaScript/Perfect-numbers new file mode 120000 index 0000000000..41acaec6e5 --- /dev/null +++ b/Lang/JavaScript/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Permutations b/Lang/JavaScript/Permutations new file mode 120000 index 0000000000..eb63dfa763 --- /dev/null +++ b/Lang/JavaScript/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Pick-random-element b/Lang/JavaScript/Pick-random-element new file mode 120000 index 0000000000..4e0a95602d --- /dev/null +++ b/Lang/JavaScript/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Playing-cards b/Lang/JavaScript/Playing-cards new file mode 120000 index 0000000000..480585f099 --- /dev/null +++ b/Lang/JavaScript/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Polymorphic-copy b/Lang/JavaScript/Polymorphic-copy new file mode 120000 index 0000000000..4d5abb4c74 --- /dev/null +++ b/Lang/JavaScript/Polymorphic-copy @@ -0,0 +1 @@ +../../Task/Polymorphic-copy/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Polymorphism b/Lang/JavaScript/Polymorphism new file mode 120000 index 0000000000..af31d84ed8 --- /dev/null +++ b/Lang/JavaScript/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Power-set b/Lang/JavaScript/Power-set new file mode 120000 index 0000000000..40fc598eac --- /dev/null +++ b/Lang/JavaScript/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Price-fraction b/Lang/JavaScript/Price-fraction new file mode 120000 index 0000000000..d33cb73b5d --- /dev/null +++ b/Lang/JavaScript/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Primality-by-trial-division b/Lang/JavaScript/Primality-by-trial-division new file mode 120000 index 0000000000..8672e65065 --- /dev/null +++ b/Lang/JavaScript/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Prime-decomposition b/Lang/JavaScript/Prime-decomposition new file mode 120000 index 0000000000..ae2b365762 --- /dev/null +++ b/Lang/JavaScript/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Probabilistic-choice b/Lang/JavaScript/Probabilistic-choice new file mode 120000 index 0000000000..301ed42f10 --- /dev/null +++ b/Lang/JavaScript/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Program-name b/Lang/JavaScript/Program-name new file mode 120000 index 0000000000..72772f2a66 --- /dev/null +++ b/Lang/JavaScript/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Program-termination b/Lang/JavaScript/Program-termination new file mode 120000 index 0000000000..9869e5e70f --- /dev/null +++ b/Lang/JavaScript/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Queue-Definition b/Lang/JavaScript/Queue-Definition new file mode 120000 index 0000000000..00bca42bf9 --- /dev/null +++ b/Lang/JavaScript/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Queue-Usage b/Lang/JavaScript/Queue-Usage new file mode 120000 index 0000000000..d1dc739952 --- /dev/null +++ b/Lang/JavaScript/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Random-numbers b/Lang/JavaScript/Random-numbers new file mode 120000 index 0000000000..272e724371 --- /dev/null +++ b/Lang/JavaScript/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Range-expansion b/Lang/JavaScript/Range-expansion new file mode 120000 index 0000000000..27e754c77a --- /dev/null +++ b/Lang/JavaScript/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Range-extraction b/Lang/JavaScript/Range-extraction new file mode 120000 index 0000000000..821316d6c2 --- /dev/null +++ b/Lang/JavaScript/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Rate-counter b/Lang/JavaScript/Rate-counter new file mode 120000 index 0000000000..71283b873c --- /dev/null +++ b/Lang/JavaScript/Rate-counter @@ -0,0 +1 @@ +../../Task/Rate-counter/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Read-entire-file b/Lang/JavaScript/Read-entire-file new file mode 120000 index 0000000000..60fa842c99 --- /dev/null +++ b/Lang/JavaScript/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Real-constants-and-functions b/Lang/JavaScript/Real-constants-and-functions new file mode 120000 index 0000000000..9f1a8373eb --- /dev/null +++ b/Lang/JavaScript/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Reduced-row-echelon-form b/Lang/JavaScript/Reduced-row-echelon-form new file mode 120000 index 0000000000..46518c3e2c --- /dev/null +++ b/Lang/JavaScript/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Regular-expressions b/Lang/JavaScript/Regular-expressions new file mode 120000 index 0000000000..a74c70f088 --- /dev/null +++ b/Lang/JavaScript/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Remove-duplicate-elements b/Lang/JavaScript/Remove-duplicate-elements new file mode 120000 index 0000000000..c1105c84c9 --- /dev/null +++ b/Lang/JavaScript/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Rename-a-file b/Lang/JavaScript/Rename-a-file new file mode 120000 index 0000000000..2a46616ab1 --- /dev/null +++ b/Lang/JavaScript/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Repeat-a-string b/Lang/JavaScript/Repeat-a-string new file mode 120000 index 0000000000..836158ee2f --- /dev/null +++ b/Lang/JavaScript/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Respond-to-an-unknown-method-call b/Lang/JavaScript/Respond-to-an-unknown-method-call new file mode 120000 index 0000000000..4758c98042 --- /dev/null +++ b/Lang/JavaScript/Respond-to-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Respond-to-an-unknown-method-call/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Reverse-a-string b/Lang/JavaScript/Reverse-a-string new file mode 120000 index 0000000000..b7a637d39d --- /dev/null +++ b/Lang/JavaScript/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Roman-numerals-Decode b/Lang/JavaScript/Roman-numerals-Decode new file mode 120000 index 0000000000..758c653984 --- /dev/null +++ b/Lang/JavaScript/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Roman-numerals-Encode b/Lang/JavaScript/Roman-numerals-Encode new file mode 120000 index 0000000000..1168e962b4 --- /dev/null +++ b/Lang/JavaScript/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Rosetta-Code-Fix-code-tags b/Lang/JavaScript/Rosetta-Code-Fix-code-tags new file mode 120000 index 0000000000..3933b339df --- /dev/null +++ b/Lang/JavaScript/Rosetta-Code-Fix-code-tags @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Fix-code-tags/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Rot-13 b/Lang/JavaScript/Rot-13 new file mode 120000 index 0000000000..88d1e62e86 --- /dev/null +++ b/Lang/JavaScript/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Run-length-encoding b/Lang/JavaScript/Run-length-encoding new file mode 120000 index 0000000000..d12357ce73 --- /dev/null +++ b/Lang/JavaScript/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Runtime-evaluation b/Lang/JavaScript/Runtime-evaluation new file mode 120000 index 0000000000..9caee17dec --- /dev/null +++ b/Lang/JavaScript/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Runtime-evaluation-In-an-environment b/Lang/JavaScript/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..f289230e04 --- /dev/null +++ b/Lang/JavaScript/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/SEDOLs b/Lang/JavaScript/SEDOLs new file mode 120000 index 0000000000..423545c495 --- /dev/null +++ b/Lang/JavaScript/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Self-describing-numbers b/Lang/JavaScript/Self-describing-numbers new file mode 120000 index 0000000000..f7cced7ef6 --- /dev/null +++ b/Lang/JavaScript/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/JavaScript \ No newline at end of file diff --git a/Lang/JavaScript/Send-an-unknown-method-call b/Lang/JavaScript/Send-an-unknown-method-call new file mode 120000 index 0000000000..6e1d2588b2 --- /dev/null +++ b/Lang/JavaScript/Send-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Send-an-unknown-method-call/JavaScript \ No newline at end of file diff --git a/Lang/Joy/Binary-digits b/Lang/Joy/Binary-digits new file mode 120000 index 0000000000..fafa903093 --- /dev/null +++ b/Lang/Joy/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Joy \ No newline at end of file diff --git a/Lang/Joy/Copy-a-string b/Lang/Joy/Copy-a-string new file mode 120000 index 0000000000..aa7d6d4d2a --- /dev/null +++ b/Lang/Joy/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Joy \ No newline at end of file diff --git a/Lang/Joy/Environment-variables b/Lang/Joy/Environment-variables new file mode 120000 index 0000000000..89c3bc069c --- /dev/null +++ b/Lang/Joy/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Joy \ No newline at end of file diff --git a/Lang/Joy/Number-names b/Lang/Joy/Number-names new file mode 120000 index 0000000000..cfd7db684b --- /dev/null +++ b/Lang/Joy/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/Joy \ No newline at end of file diff --git a/Lang/Joy/Order-two-numerical-lists b/Lang/Joy/Order-two-numerical-lists new file mode 120000 index 0000000000..dddc4dfc97 --- /dev/null +++ b/Lang/Joy/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/Joy \ No newline at end of file diff --git a/Lang/Joy/Primality-by-trial-division b/Lang/Joy/Primality-by-trial-division new file mode 120000 index 0000000000..974534ba38 --- /dev/null +++ b/Lang/Joy/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Joy \ No newline at end of file diff --git a/Lang/Joy/Rename-a-file b/Lang/Joy/Rename-a-file new file mode 120000 index 0000000000..c4cf2fd515 --- /dev/null +++ b/Lang/Joy/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Joy \ No newline at end of file diff --git a/Lang/Julia/Arbitrary-precision-integers--included- b/Lang/Julia/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..e4b2d67fa5 --- /dev/null +++ b/Lang/Julia/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Julia \ No newline at end of file diff --git a/Lang/Julia/Arbitrary-precision-integers-included b/Lang/Julia/Arbitrary-precision-integers-included deleted file mode 120000 index 6d0033eafb..0000000000 --- a/Lang/Julia/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Julia \ No newline at end of file diff --git a/Lang/Julia/Catalan-numbers b/Lang/Julia/Catalan-numbers new file mode 120000 index 0000000000..67a19c95fb --- /dev/null +++ b/Lang/Julia/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Julia \ No newline at end of file diff --git a/Lang/Julia/Perfect-numbers b/Lang/Julia/Perfect-numbers new file mode 120000 index 0000000000..34a646fa51 --- /dev/null +++ b/Lang/Julia/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Julia \ No newline at end of file diff --git a/Lang/Julia/Read-a-file-line-by-line b/Lang/Julia/Read-a-file-line-by-line new file mode 120000 index 0000000000..d434efcafd --- /dev/null +++ b/Lang/Julia/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Julia \ No newline at end of file diff --git a/Lang/Julia/Read-entire-file b/Lang/Julia/Read-entire-file new file mode 120000 index 0000000000..70a92d2bb9 --- /dev/null +++ b/Lang/Julia/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Julia \ No newline at end of file diff --git a/Lang/Julia/Regular-expressions b/Lang/Julia/Regular-expressions new file mode 120000 index 0000000000..f6ded844a1 --- /dev/null +++ b/Lang/Julia/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Julia \ No newline at end of file diff --git a/Lang/Julia/Remove-duplicate-elements b/Lang/Julia/Remove-duplicate-elements new file mode 120000 index 0000000000..49428ff008 --- /dev/null +++ b/Lang/Julia/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Julia \ No newline at end of file diff --git a/Lang/Julia/Repeat-a-string b/Lang/Julia/Repeat-a-string new file mode 120000 index 0000000000..9d0e7565e1 --- /dev/null +++ b/Lang/Julia/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Julia \ No newline at end of file diff --git a/Lang/Julia/Return-multiple-values b/Lang/Julia/Return-multiple-values new file mode 120000 index 0000000000..7645817505 --- /dev/null +++ b/Lang/Julia/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Julia \ No newline at end of file diff --git a/Lang/Julia/Reverse-a-string b/Lang/Julia/Reverse-a-string new file mode 120000 index 0000000000..4dd9aa6cad --- /dev/null +++ b/Lang/Julia/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Julia \ No newline at end of file diff --git a/Lang/Julia/Rock-paper-scissors b/Lang/Julia/Rock-paper-scissors new file mode 120000 index 0000000000..b8645f7874 --- /dev/null +++ b/Lang/Julia/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/Julia \ No newline at end of file diff --git a/Lang/Julia/Self-describing-numbers b/Lang/Julia/Self-describing-numbers new file mode 120000 index 0000000000..9cf5f6e01b --- /dev/null +++ b/Lang/Julia/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/Julia \ No newline at end of file diff --git a/Lang/Julia/Semordnilap b/Lang/Julia/Semordnilap new file mode 120000 index 0000000000..18eee2ad88 --- /dev/null +++ b/Lang/Julia/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/Julia \ No newline at end of file diff --git a/Lang/K/Binary-digits b/Lang/K/Binary-digits new file mode 120000 index 0000000000..15a75998b0 --- /dev/null +++ b/Lang/K/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/K \ No newline at end of file diff --git a/Lang/K/Catalan-numbers b/Lang/K/Catalan-numbers new file mode 120000 index 0000000000..e755bc6169 --- /dev/null +++ b/Lang/K/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/K \ No newline at end of file diff --git a/Lang/K/Environment-variables b/Lang/K/Environment-variables new file mode 120000 index 0000000000..91c24029fd --- /dev/null +++ b/Lang/K/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/K \ No newline at end of file diff --git a/Lang/K/Null-object b/Lang/K/Null-object new file mode 120000 index 0000000000..e46396e500 --- /dev/null +++ b/Lang/K/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/K \ No newline at end of file diff --git a/Lang/K/One-dimensional-cellular-automata b/Lang/K/One-dimensional-cellular-automata new file mode 120000 index 0000000000..b9f47a6abb --- /dev/null +++ b/Lang/K/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/K \ No newline at end of file diff --git a/Lang/K/Pangram-checker b/Lang/K/Pangram-checker new file mode 120000 index 0000000000..af64107e09 --- /dev/null +++ b/Lang/K/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/K \ No newline at end of file diff --git a/Lang/K/Pascals-triangle b/Lang/K/Pascals-triangle new file mode 120000 index 0000000000..eb9004b217 --- /dev/null +++ b/Lang/K/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/K \ No newline at end of file diff --git a/Lang/K/Perfect-numbers b/Lang/K/Perfect-numbers new file mode 120000 index 0000000000..c77acaffc5 --- /dev/null +++ b/Lang/K/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/K \ No newline at end of file diff --git a/Lang/K/Permutations b/Lang/K/Permutations new file mode 120000 index 0000000000..ca3674e32b --- /dev/null +++ b/Lang/K/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/K \ No newline at end of file diff --git a/Lang/K/Pick-random-element b/Lang/K/Pick-random-element new file mode 120000 index 0000000000..3fc5816ab9 --- /dev/null +++ b/Lang/K/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/K \ No newline at end of file diff --git a/Lang/K/Playing-cards b/Lang/K/Playing-cards new file mode 120000 index 0000000000..3d405c1ceb --- /dev/null +++ b/Lang/K/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/K \ No newline at end of file diff --git a/Lang/K/Power-set b/Lang/K/Power-set new file mode 120000 index 0000000000..4648f66d52 --- /dev/null +++ b/Lang/K/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/K \ No newline at end of file diff --git a/Lang/K/Price-fraction b/Lang/K/Price-fraction new file mode 120000 index 0000000000..691bfc1824 --- /dev/null +++ b/Lang/K/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/K \ No newline at end of file diff --git a/Lang/K/Primality-by-trial-division b/Lang/K/Primality-by-trial-division new file mode 120000 index 0000000000..a5fe32abb3 --- /dev/null +++ b/Lang/K/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/K \ No newline at end of file diff --git a/Lang/K/Range-expansion b/Lang/K/Range-expansion new file mode 120000 index 0000000000..e0570efdfa --- /dev/null +++ b/Lang/K/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/K \ No newline at end of file diff --git a/Lang/K/Range-extraction b/Lang/K/Range-extraction new file mode 120000 index 0000000000..b33c9b6dac --- /dev/null +++ b/Lang/K/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/K \ No newline at end of file diff --git a/Lang/K/Remove-duplicate-elements b/Lang/K/Remove-duplicate-elements new file mode 120000 index 0000000000..e842557dcf --- /dev/null +++ b/Lang/K/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/K \ No newline at end of file diff --git a/Lang/K/Repeat-a-string b/Lang/K/Repeat-a-string new file mode 120000 index 0000000000..041b7e1ab2 --- /dev/null +++ b/Lang/K/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/K \ No newline at end of file diff --git a/Lang/K/Roman-numerals-Decode b/Lang/K/Roman-numerals-Decode new file mode 120000 index 0000000000..434971f5ee --- /dev/null +++ b/Lang/K/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/K \ No newline at end of file diff --git a/Lang/K/Rot-13 b/Lang/K/Rot-13 new file mode 120000 index 0000000000..dff32d6aca --- /dev/null +++ b/Lang/K/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/K \ No newline at end of file diff --git a/Lang/K/Run-length-encoding b/Lang/K/Run-length-encoding new file mode 120000 index 0000000000..cd6c80f04b --- /dev/null +++ b/Lang/K/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/K \ No newline at end of file diff --git a/Lang/K/Self-describing-numbers b/Lang/K/Self-describing-numbers new file mode 120000 index 0000000000..0189373a63 --- /dev/null +++ b/Lang/K/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/K \ No newline at end of file diff --git a/Lang/KonsolScript/Copy-a-string b/Lang/KonsolScript/Copy-a-string new file mode 120000 index 0000000000..518bbf77eb --- /dev/null +++ b/Lang/KonsolScript/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/KonsolScript \ No newline at end of file diff --git a/Lang/LLVM/Program-name b/Lang/LLVM/Program-name new file mode 120000 index 0000000000..438c880ef2 --- /dev/null +++ b/Lang/LLVM/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/LLVM \ No newline at end of file diff --git a/Lang/LOLCODE/Binary-digits b/Lang/LOLCODE/Binary-digits new file mode 120000 index 0000000000..116bd74da9 --- /dev/null +++ b/Lang/LOLCODE/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/LOLCODE \ No newline at end of file diff --git a/Lang/LSE64/Primality-by-trial-division b/Lang/LSE64/Primality-by-trial-division new file mode 120000 index 0000000000..f3010d0b43 --- /dev/null +++ b/Lang/LSE64/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/LSE64 \ No newline at end of file diff --git a/Lang/LSL/Environment-variables b/Lang/LSL/Environment-variables new file mode 120000 index 0000000000..adc1e2ac74 --- /dev/null +++ b/Lang/LSL/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/LSL \ No newline at end of file diff --git a/Lang/LaTeX/Roman-numerals-Encode b/Lang/LaTeX/Roman-numerals-Encode new file mode 120000 index 0000000000..d1ffda05b3 --- /dev/null +++ b/Lang/LaTeX/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/LaTeX \ No newline at end of file diff --git a/Lang/Lang5/Binary-digits b/Lang/Lang5/Binary-digits new file mode 120000 index 0000000000..42c668713f --- /dev/null +++ b/Lang/Lang5/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Copy-a-string b/Lang/Lang5/Copy-a-string new file mode 120000 index 0000000000..932fbfad9e --- /dev/null +++ b/Lang/Lang5/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Read-entire-file b/Lang/Lang5/Read-entire-file new file mode 120000 index 0000000000..b698f63e35 --- /dev/null +++ b/Lang/Lang5/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Remove-duplicate-elements b/Lang/Lang5/Remove-duplicate-elements new file mode 120000 index 0000000000..f2d0593508 --- /dev/null +++ b/Lang/Lang5/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Lang5 \ No newline at end of file diff --git a/Lang/Lang5/Reverse-a-string b/Lang/Lang5/Reverse-a-string new file mode 120000 index 0000000000..1eb14d938a --- /dev/null +++ b/Lang/Lang5/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Lang5 \ No newline at end of file diff --git a/Lang/Lhogho/Order-two-numerical-lists b/Lang/Lhogho/Order-two-numerical-lists new file mode 120000 index 0000000000..b4d2824ef1 --- /dev/null +++ b/Lang/Lhogho/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/Lhogho \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Arbitrary-precision-integers--included- b/Lang/Liberty-BASIC/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..47d2a8fb9b --- /dev/null +++ b/Lang/Liberty-BASIC/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Arbitrary-precision-integers-included b/Lang/Liberty-BASIC/Arbitrary-precision-integers-included deleted file mode 120000 index 9fbe0b1f05..0000000000 --- a/Lang/Liberty-BASIC/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Binary-digits b/Lang/Liberty-BASIC/Binary-digits new file mode 120000 index 0000000000..baef0ed7f9 --- /dev/null +++ b/Lang/Liberty-BASIC/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Brownian-tree b/Lang/Liberty-BASIC/Brownian-tree new file mode 120000 index 0000000000..fa17d79efd --- /dev/null +++ b/Lang/Liberty-BASIC/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Catalan-numbers b/Lang/Liberty-BASIC/Catalan-numbers new file mode 120000 index 0000000000..97011ccecc --- /dev/null +++ b/Lang/Liberty-BASIC/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Copy-a-string b/Lang/Liberty-BASIC/Copy-a-string new file mode 120000 index 0000000000..ce76f72570 --- /dev/null +++ b/Lang/Liberty-BASIC/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Dragon-curve b/Lang/Liberty-BASIC/Dragon-curve new file mode 120000 index 0000000000..8fae27ea07 --- /dev/null +++ b/Lang/Liberty-BASIC/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Environment-variables b/Lang/Liberty-BASIC/Environment-variables new file mode 120000 index 0000000000..242af6163c --- /dev/null +++ b/Lang/Liberty-BASIC/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Guess-the-number-With-feedback--player- b/Lang/Liberty-BASIC/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..d51262280a --- /dev/null +++ b/Lang/Liberty-BASIC/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Guess-the-number-With-feedback-player b/Lang/Liberty-BASIC/Guess-the-number-With-feedback-player deleted file mode 120000 index 4470f16418..0000000000 --- a/Lang/Liberty-BASIC/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Non-decimal-radices-Convert b/Lang/Liberty-BASIC/Non-decimal-radices-Convert new file mode 120000 index 0000000000..aabd5959b6 --- /dev/null +++ b/Lang/Liberty-BASIC/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Nth-root b/Lang/Liberty-BASIC/Nth-root new file mode 120000 index 0000000000..f0e789097e --- /dev/null +++ b/Lang/Liberty-BASIC/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Numerical-integration b/Lang/Liberty-BASIC/Numerical-integration new file mode 120000 index 0000000000..87518c5253 --- /dev/null +++ b/Lang/Liberty-BASIC/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/One-dimensional-cellular-automata b/Lang/Liberty-BASIC/One-dimensional-cellular-automata new file mode 120000 index 0000000000..9f80f6e32b --- /dev/null +++ b/Lang/Liberty-BASIC/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/OpenGL b/Lang/Liberty-BASIC/OpenGL new file mode 120000 index 0000000000..a61f12ba40 --- /dev/null +++ b/Lang/Liberty-BASIC/OpenGL @@ -0,0 +1 @@ +../../Task/OpenGL/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Palindrome-detection b/Lang/Liberty-BASIC/Palindrome-detection new file mode 120000 index 0000000000..b7836287a7 --- /dev/null +++ b/Lang/Liberty-BASIC/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Pangram-checker b/Lang/Liberty-BASIC/Pangram-checker new file mode 120000 index 0000000000..e39aa80f90 --- /dev/null +++ b/Lang/Liberty-BASIC/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Pascals-triangle b/Lang/Liberty-BASIC/Pascals-triangle new file mode 120000 index 0000000000..3009fe696a --- /dev/null +++ b/Lang/Liberty-BASIC/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Percentage-difference-between-images b/Lang/Liberty-BASIC/Percentage-difference-between-images new file mode 120000 index 0000000000..0b5c9da041 --- /dev/null +++ b/Lang/Liberty-BASIC/Percentage-difference-between-images @@ -0,0 +1 @@ +../../Task/Percentage-difference-between-images/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Perfect-numbers b/Lang/Liberty-BASIC/Perfect-numbers new file mode 120000 index 0000000000..5da6797163 --- /dev/null +++ b/Lang/Liberty-BASIC/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Pick-random-element b/Lang/Liberty-BASIC/Pick-random-element new file mode 120000 index 0000000000..dd88c5257a --- /dev/null +++ b/Lang/Liberty-BASIC/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Pinstripe-Printer b/Lang/Liberty-BASIC/Pinstripe-Printer new file mode 120000 index 0000000000..ef6da0d58e --- /dev/null +++ b/Lang/Liberty-BASIC/Pinstripe-Printer @@ -0,0 +1 @@ +../../Task/Pinstripe-Printer/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Play-recorded-sounds b/Lang/Liberty-BASIC/Play-recorded-sounds new file mode 120000 index 0000000000..33a14e3bfc --- /dev/null +++ b/Lang/Liberty-BASIC/Play-recorded-sounds @@ -0,0 +1 @@ +../../Task/Play-recorded-sounds/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Playing-cards b/Lang/Liberty-BASIC/Playing-cards new file mode 120000 index 0000000000..1136772ab9 --- /dev/null +++ b/Lang/Liberty-BASIC/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Plot-coordinate-pairs b/Lang/Liberty-BASIC/Plot-coordinate-pairs new file mode 120000 index 0000000000..f9e6665378 --- /dev/null +++ b/Lang/Liberty-BASIC/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Price-fraction b/Lang/Liberty-BASIC/Price-fraction new file mode 120000 index 0000000000..28f54fa10a --- /dev/null +++ b/Lang/Liberty-BASIC/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Primality-by-trial-division b/Lang/Liberty-BASIC/Primality-by-trial-division new file mode 120000 index 0000000000..1513c1125e --- /dev/null +++ b/Lang/Liberty-BASIC/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Probabilistic-choice b/Lang/Liberty-BASIC/Probabilistic-choice new file mode 120000 index 0000000000..b7a4e45db9 --- /dev/null +++ b/Lang/Liberty-BASIC/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Problem-of-Apollonius b/Lang/Liberty-BASIC/Problem-of-Apollonius new file mode 120000 index 0000000000..46bea851ae --- /dev/null +++ b/Lang/Liberty-BASIC/Problem-of-Apollonius @@ -0,0 +1 @@ +../../Task/Problem-of-Apollonius/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Program-termination b/Lang/Liberty-BASIC/Program-termination new file mode 120000 index 0000000000..fa74bf973e --- /dev/null +++ b/Lang/Liberty-BASIC/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Pythagorean-triples b/Lang/Liberty-BASIC/Pythagorean-triples new file mode 120000 index 0000000000..18ae1cbb94 --- /dev/null +++ b/Lang/Liberty-BASIC/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Quaternion-type b/Lang/Liberty-BASIC/Quaternion-type new file mode 120000 index 0000000000..33da9602b0 --- /dev/null +++ b/Lang/Liberty-BASIC/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Random-numbers b/Lang/Liberty-BASIC/Random-numbers new file mode 120000 index 0000000000..20a3dfb2f4 --- /dev/null +++ b/Lang/Liberty-BASIC/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Range-expansion b/Lang/Liberty-BASIC/Range-expansion new file mode 120000 index 0000000000..dc528e89d4 --- /dev/null +++ b/Lang/Liberty-BASIC/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Range-extraction b/Lang/Liberty-BASIC/Range-extraction new file mode 120000 index 0000000000..e640ac65b6 --- /dev/null +++ b/Lang/Liberty-BASIC/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Rate-counter b/Lang/Liberty-BASIC/Rate-counter new file mode 120000 index 0000000000..e7da1716b8 --- /dev/null +++ b/Lang/Liberty-BASIC/Rate-counter @@ -0,0 +1 @@ +../../Task/Rate-counter/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Ray-casting-algorithm b/Lang/Liberty-BASIC/Ray-casting-algorithm new file mode 120000 index 0000000000..099620acdd --- /dev/null +++ b/Lang/Liberty-BASIC/Ray-casting-algorithm @@ -0,0 +1 @@ +../../Task/Ray-casting-algorithm/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Read-a-configuration-file b/Lang/Liberty-BASIC/Read-a-configuration-file new file mode 120000 index 0000000000..1be387504a --- /dev/null +++ b/Lang/Liberty-BASIC/Read-a-configuration-file @@ -0,0 +1 @@ +../../Task/Read-a-configuration-file/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Read-a-file-line-by-line b/Lang/Liberty-BASIC/Read-a-file-line-by-line new file mode 120000 index 0000000000..648325164a --- /dev/null +++ b/Lang/Liberty-BASIC/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Read-a-specific-line-from-a-file b/Lang/Liberty-BASIC/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..7e64aafb58 --- /dev/null +++ b/Lang/Liberty-BASIC/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Read-entire-file b/Lang/Liberty-BASIC/Read-entire-file new file mode 120000 index 0000000000..4907c9b97e --- /dev/null +++ b/Lang/Liberty-BASIC/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Real-constants-and-functions b/Lang/Liberty-BASIC/Real-constants-and-functions new file mode 120000 index 0000000000..c16ffe68c6 --- /dev/null +++ b/Lang/Liberty-BASIC/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Record-sound b/Lang/Liberty-BASIC/Record-sound new file mode 120000 index 0000000000..ac28648698 --- /dev/null +++ b/Lang/Liberty-BASIC/Record-sound @@ -0,0 +1 @@ +../../Task/Record-sound/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Remove-duplicate-elements b/Lang/Liberty-BASIC/Remove-duplicate-elements new file mode 120000 index 0000000000..a1b6fd84ed --- /dev/null +++ b/Lang/Liberty-BASIC/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Remove-lines-from-a-file b/Lang/Liberty-BASIC/Remove-lines-from-a-file new file mode 120000 index 0000000000..ae5523d4de --- /dev/null +++ b/Lang/Liberty-BASIC/Remove-lines-from-a-file @@ -0,0 +1 @@ +../../Task/Remove-lines-from-a-file/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Rename-a-file b/Lang/Liberty-BASIC/Rename-a-file new file mode 120000 index 0000000000..9539fb9d6a --- /dev/null +++ b/Lang/Liberty-BASIC/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Repeat-a-string b/Lang/Liberty-BASIC/Repeat-a-string new file mode 120000 index 0000000000..c7ce9f9f69 --- /dev/null +++ b/Lang/Liberty-BASIC/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Return-multiple-values b/Lang/Liberty-BASIC/Return-multiple-values new file mode 120000 index 0000000000..943c61fd8f --- /dev/null +++ b/Lang/Liberty-BASIC/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Reverse-a-string b/Lang/Liberty-BASIC/Reverse-a-string new file mode 120000 index 0000000000..0b405e2e17 --- /dev/null +++ b/Lang/Liberty-BASIC/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Rock-paper-scissors b/Lang/Liberty-BASIC/Rock-paper-scissors new file mode 120000 index 0000000000..51eae560ba --- /dev/null +++ b/Lang/Liberty-BASIC/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Roman-numerals-Decode b/Lang/Liberty-BASIC/Roman-numerals-Decode new file mode 120000 index 0000000000..b0b8f8f642 --- /dev/null +++ b/Lang/Liberty-BASIC/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Roman-numerals-Encode b/Lang/Liberty-BASIC/Roman-numerals-Encode new file mode 120000 index 0000000000..a70f5cc3e0 --- /dev/null +++ b/Lang/Liberty-BASIC/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Roots-of-a-function b/Lang/Liberty-BASIC/Roots-of-a-function new file mode 120000 index 0000000000..76ee1e46a9 --- /dev/null +++ b/Lang/Liberty-BASIC/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Roots-of-a-quadratic-function b/Lang/Liberty-BASIC/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..f1837004be --- /dev/null +++ b/Lang/Liberty-BASIC/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Roots-of-unity b/Lang/Liberty-BASIC/Roots-of-unity new file mode 120000 index 0000000000..4317ab278e --- /dev/null +++ b/Lang/Liberty-BASIC/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Rot-13 b/Lang/Liberty-BASIC/Rot-13 new file mode 120000 index 0000000000..b58693dfb5 --- /dev/null +++ b/Lang/Liberty-BASIC/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Run-length-encoding b/Lang/Liberty-BASIC/Run-length-encoding new file mode 120000 index 0000000000..1536b5fbc8 --- /dev/null +++ b/Lang/Liberty-BASIC/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Runtime-evaluation b/Lang/Liberty-BASIC/Runtime-evaluation new file mode 120000 index 0000000000..8c6cb13e39 --- /dev/null +++ b/Lang/Liberty-BASIC/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Runtime-evaluation-In-an-environment b/Lang/Liberty-BASIC/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..499bf3cfae --- /dev/null +++ b/Lang/Liberty-BASIC/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/SEDOLs b/Lang/Liberty-BASIC/SEDOLs new file mode 120000 index 0000000000..bfcc7d2673 --- /dev/null +++ b/Lang/Liberty-BASIC/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Self-describing-numbers b/Lang/Liberty-BASIC/Self-describing-numbers new file mode 120000 index 0000000000..070f46610d --- /dev/null +++ b/Lang/Liberty-BASIC/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Semordnilap b/Lang/Liberty-BASIC/Semordnilap new file mode 120000 index 0000000000..b9d061272a --- /dev/null +++ b/Lang/Liberty-BASIC/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Send-email b/Lang/Liberty-BASIC/Send-email new file mode 120000 index 0000000000..cf7d090b40 --- /dev/null +++ b/Lang/Liberty-BASIC/Send-email @@ -0,0 +1 @@ +../../Task/Send-email/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Sequence-of-non-squares b/Lang/Liberty-BASIC/Sequence-of-non-squares new file mode 120000 index 0000000000..a9feec69f4 --- /dev/null +++ b/Lang/Liberty-BASIC/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Liberty-BASIC/Set b/Lang/Liberty-BASIC/Set new file mode 120000 index 0000000000..69bd7a0c57 --- /dev/null +++ b/Lang/Liberty-BASIC/Set @@ -0,0 +1 @@ +../../Task/Set/Liberty-BASIC \ No newline at end of file diff --git a/Lang/Lisaac/Copy-a-string b/Lang/Lisaac/Copy-a-string new file mode 120000 index 0000000000..007d1ed664 --- /dev/null +++ b/Lang/Lisaac/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Lisaac \ No newline at end of file diff --git a/Lang/Locomotive-Basic/Binary-digits b/Lang/Locomotive-Basic/Binary-digits new file mode 120000 index 0000000000..3e1ac4d051 --- /dev/null +++ b/Lang/Locomotive-Basic/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Locomotive-Basic \ No newline at end of file diff --git a/Lang/Locomotive-Basic/N-queens-problem b/Lang/Locomotive-Basic/N-queens-problem new file mode 120000 index 0000000000..e56ea43b96 --- /dev/null +++ b/Lang/Locomotive-Basic/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Locomotive-Basic \ No newline at end of file diff --git a/Lang/Locomotive-Basic/Non-decimal-radices-Output b/Lang/Locomotive-Basic/Non-decimal-radices-Output new file mode 120000 index 0000000000..ee0db7d653 --- /dev/null +++ b/Lang/Locomotive-Basic/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/Locomotive-Basic \ No newline at end of file diff --git a/Lang/Locomotive-Basic/One-dimensional-cellular-automata b/Lang/Locomotive-Basic/One-dimensional-cellular-automata new file mode 120000 index 0000000000..4161571f32 --- /dev/null +++ b/Lang/Locomotive-Basic/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Locomotive-Basic \ No newline at end of file diff --git a/Lang/Locomotive-Basic/Pascals-triangle b/Lang/Locomotive-Basic/Pascals-triangle new file mode 120000 index 0000000000..823541aa79 --- /dev/null +++ b/Lang/Locomotive-Basic/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Locomotive-Basic \ No newline at end of file diff --git a/Lang/Locomotive-Basic/Pinstripe-Display b/Lang/Locomotive-Basic/Pinstripe-Display new file mode 120000 index 0000000000..51fec0fcce --- /dev/null +++ b/Lang/Locomotive-Basic/Pinstripe-Display @@ -0,0 +1 @@ +../../Task/Pinstripe-Display/Locomotive-Basic \ No newline at end of file diff --git a/Lang/Locomotive-Basic/Rename-a-file b/Lang/Locomotive-Basic/Rename-a-file new file mode 120000 index 0000000000..59575c8500 --- /dev/null +++ b/Lang/Locomotive-Basic/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Locomotive-Basic \ No newline at end of file diff --git a/Lang/Locomotive-Basic/Rock-paper-scissors b/Lang/Locomotive-Basic/Rock-paper-scissors new file mode 120000 index 0000000000..b9d5db9e9f --- /dev/null +++ b/Lang/Locomotive-Basic/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/Locomotive-Basic \ No newline at end of file diff --git a/Lang/Locomotive-Basic/Rot-13 b/Lang/Locomotive-Basic/Rot-13 new file mode 120000 index 0000000000..816f6b09db --- /dev/null +++ b/Lang/Locomotive-Basic/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Locomotive-Basic \ No newline at end of file diff --git a/Lang/Logo/Copy-a-string b/Lang/Logo/Copy-a-string new file mode 120000 index 0000000000..e1eda6041d --- /dev/null +++ b/Lang/Logo/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Logo \ No newline at end of file diff --git a/Lang/Logo/Dragon-curve b/Lang/Logo/Dragon-curve new file mode 120000 index 0000000000..d194cd184d --- /dev/null +++ b/Lang/Logo/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/Logo \ No newline at end of file diff --git a/Lang/Logo/N-queens-problem b/Lang/Logo/N-queens-problem new file mode 120000 index 0000000000..d24ebbc1f5 --- /dev/null +++ b/Lang/Logo/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Logo \ No newline at end of file diff --git a/Lang/Logo/Nth-root b/Lang/Logo/Nth-root new file mode 120000 index 0000000000..e077f8970e --- /dev/null +++ b/Lang/Logo/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Logo \ No newline at end of file diff --git a/Lang/Logo/Null-object b/Lang/Logo/Null-object new file mode 120000 index 0000000000..9fd4238db7 --- /dev/null +++ b/Lang/Logo/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Logo \ No newline at end of file diff --git a/Lang/Logo/Number-names b/Lang/Logo/Number-names new file mode 120000 index 0000000000..497dff9d39 --- /dev/null +++ b/Lang/Logo/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/Logo \ No newline at end of file diff --git a/Lang/Logo/Numerical-integration b/Lang/Logo/Numerical-integration new file mode 120000 index 0000000000..e0c5ce170e --- /dev/null +++ b/Lang/Logo/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/Logo \ No newline at end of file diff --git a/Lang/Logo/One-dimensional-cellular-automata b/Lang/Logo/One-dimensional-cellular-automata new file mode 120000 index 0000000000..60f926d94e --- /dev/null +++ b/Lang/Logo/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Logo \ No newline at end of file diff --git a/Lang/Logo/Optional-parameters b/Lang/Logo/Optional-parameters new file mode 120000 index 0000000000..64e59f92da --- /dev/null +++ b/Lang/Logo/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/Logo \ No newline at end of file diff --git a/Lang/Logo/Palindrome-detection b/Lang/Logo/Palindrome-detection new file mode 120000 index 0000000000..fa6eb03a21 --- /dev/null +++ b/Lang/Logo/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Logo \ No newline at end of file diff --git a/Lang/Logo/Pangram-checker b/Lang/Logo/Pangram-checker new file mode 120000 index 0000000000..d6ad555665 --- /dev/null +++ b/Lang/Logo/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Logo \ No newline at end of file diff --git a/Lang/Logo/Pascals-triangle b/Lang/Logo/Pascals-triangle new file mode 120000 index 0000000000..309af21089 --- /dev/null +++ b/Lang/Logo/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Logo \ No newline at end of file diff --git a/Lang/Logo/Perfect-numbers b/Lang/Logo/Perfect-numbers new file mode 120000 index 0000000000..9461d999fd --- /dev/null +++ b/Lang/Logo/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Logo \ No newline at end of file diff --git a/Lang/Logo/Pick-random-element b/Lang/Logo/Pick-random-element new file mode 120000 index 0000000000..1c5da3af10 --- /dev/null +++ b/Lang/Logo/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/Logo \ No newline at end of file diff --git a/Lang/Logo/Playing-cards b/Lang/Logo/Playing-cards new file mode 120000 index 0000000000..ac5ac8bc1a --- /dev/null +++ b/Lang/Logo/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/Logo \ No newline at end of file diff --git a/Lang/Logo/Power-set b/Lang/Logo/Power-set new file mode 120000 index 0000000000..c057b1ba6b --- /dev/null +++ b/Lang/Logo/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Logo \ No newline at end of file diff --git a/Lang/Logo/Primality-by-trial-division b/Lang/Logo/Primality-by-trial-division new file mode 120000 index 0000000000..5f0ff8f300 --- /dev/null +++ b/Lang/Logo/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Logo \ No newline at end of file diff --git a/Lang/Logo/Prime-decomposition b/Lang/Logo/Prime-decomposition new file mode 120000 index 0000000000..0a302aae93 --- /dev/null +++ b/Lang/Logo/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Logo \ No newline at end of file diff --git a/Lang/Logo/Program-termination b/Lang/Logo/Program-termination new file mode 120000 index 0000000000..d4c4dd6113 --- /dev/null +++ b/Lang/Logo/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Logo \ No newline at end of file diff --git a/Lang/Logo/Queue-Usage b/Lang/Logo/Queue-Usage new file mode 120000 index 0000000000..53859fc3c9 --- /dev/null +++ b/Lang/Logo/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/Logo \ No newline at end of file diff --git a/Lang/Logo/Random-numbers b/Lang/Logo/Random-numbers new file mode 120000 index 0000000000..270b586153 --- /dev/null +++ b/Lang/Logo/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Logo \ No newline at end of file diff --git a/Lang/Logo/Read-a-file-line-by-line b/Lang/Logo/Read-a-file-line-by-line new file mode 120000 index 0000000000..15cabd6175 --- /dev/null +++ b/Lang/Logo/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Logo \ No newline at end of file diff --git a/Lang/Logo/Real-constants-and-functions b/Lang/Logo/Real-constants-and-functions new file mode 120000 index 0000000000..458ac16ec9 --- /dev/null +++ b/Lang/Logo/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Logo \ No newline at end of file diff --git a/Lang/Logo/Remove-duplicate-elements b/Lang/Logo/Remove-duplicate-elements new file mode 120000 index 0000000000..97c86b1a4f --- /dev/null +++ b/Lang/Logo/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Logo \ No newline at end of file diff --git a/Lang/Logo/Repeat-a-string b/Lang/Logo/Repeat-a-string new file mode 120000 index 0000000000..9a13f2d9e7 --- /dev/null +++ b/Lang/Logo/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Logo \ No newline at end of file diff --git a/Lang/Logo/Reverse-a-string b/Lang/Logo/Reverse-a-string new file mode 120000 index 0000000000..10fd568c17 --- /dev/null +++ b/Lang/Logo/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Logo \ No newline at end of file diff --git a/Lang/Logo/Roman-numerals-Decode b/Lang/Logo/Roman-numerals-Decode new file mode 120000 index 0000000000..e22d8031d1 --- /dev/null +++ b/Lang/Logo/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/Logo \ No newline at end of file diff --git a/Lang/Logo/Roman-numerals-Encode b/Lang/Logo/Roman-numerals-Encode new file mode 120000 index 0000000000..ffb0881b0b --- /dev/null +++ b/Lang/Logo/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Logo \ No newline at end of file diff --git a/Lang/Logo/Roots-of-a-quadratic-function b/Lang/Logo/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..b970b1589b --- /dev/null +++ b/Lang/Logo/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/Logo \ No newline at end of file diff --git a/Lang/Logo/Rot-13 b/Lang/Logo/Rot-13 new file mode 120000 index 0000000000..016b7616ea --- /dev/null +++ b/Lang/Logo/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Logo \ No newline at end of file diff --git a/Lang/Logo/Run-length-encoding b/Lang/Logo/Run-length-encoding new file mode 120000 index 0000000000..c8724d8a52 --- /dev/null +++ b/Lang/Logo/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Logo \ No newline at end of file diff --git a/Lang/Logo/Scope-modifiers b/Lang/Logo/Scope-modifiers new file mode 120000 index 0000000000..a8494407c3 --- /dev/null +++ b/Lang/Logo/Scope-modifiers @@ -0,0 +1 @@ +../../Task/Scope-modifiers/Logo \ No newline at end of file diff --git a/Lang/Logo/Self-describing-numbers b/Lang/Logo/Self-describing-numbers new file mode 120000 index 0000000000..10f163ccbe --- /dev/null +++ b/Lang/Logo/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/Logo \ No newline at end of file diff --git a/Lang/Logo/Sequence-of-non-squares b/Lang/Logo/Sequence-of-non-squares new file mode 120000 index 0000000000..8b332ccde7 --- /dev/null +++ b/Lang/Logo/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Logo \ No newline at end of file diff --git a/Lang/Logtalk/Permutations b/Lang/Logtalk/Permutations new file mode 120000 index 0000000000..e1cbc26a18 --- /dev/null +++ b/Lang/Logtalk/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Logtalk \ No newline at end of file diff --git a/Lang/Logtalk/Power-set b/Lang/Logtalk/Power-set new file mode 120000 index 0000000000..e115480b20 --- /dev/null +++ b/Lang/Logtalk/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Logtalk \ No newline at end of file diff --git a/Lang/LotusScript/Roman-numerals-Encode b/Lang/LotusScript/Roman-numerals-Encode new file mode 120000 index 0000000000..140941c7b2 --- /dev/null +++ b/Lang/LotusScript/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/LotusScript \ No newline at end of file diff --git a/Lang/LotusScript/Send-email b/Lang/LotusScript/Send-email new file mode 120000 index 0000000000..707ddcec2b --- /dev/null +++ b/Lang/LotusScript/Send-email @@ -0,0 +1 @@ +../../Task/Send-email/LotusScript \ No newline at end of file diff --git a/Lang/Lua/Brownian-tree b/Lang/Lua/Brownian-tree new file mode 120000 index 0000000000..44fc4487f6 --- /dev/null +++ b/Lang/Lua/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/Lua \ No newline at end of file diff --git a/Lang/Lua/Catalan-numbers b/Lang/Lua/Catalan-numbers new file mode 120000 index 0000000000..bc4a26a163 --- /dev/null +++ b/Lang/Lua/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Lua \ No newline at end of file diff --git a/Lang/Lua/Copy-a-string b/Lang/Lua/Copy-a-string new file mode 120000 index 0000000000..6eb0ef9053 --- /dev/null +++ b/Lang/Lua/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Lua \ No newline at end of file diff --git a/Lang/Lua/Dragon-curve b/Lang/Lua/Dragon-curve new file mode 120000 index 0000000000..a5d34bba1d --- /dev/null +++ b/Lang/Lua/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/Lua \ No newline at end of file diff --git a/Lang/Lua/Environment-variables b/Lang/Lua/Environment-variables new file mode 120000 index 0000000000..a195ab1a92 --- /dev/null +++ b/Lang/Lua/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Lua \ No newline at end of file diff --git a/Lang/Lua/N-queens-problem b/Lang/Lua/N-queens-problem new file mode 120000 index 0000000000..6a4e099721 --- /dev/null +++ b/Lang/Lua/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Lua \ No newline at end of file diff --git a/Lang/Lua/Named-parameters b/Lang/Lua/Named-parameters new file mode 120000 index 0000000000..38437112e7 --- /dev/null +++ b/Lang/Lua/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/Lua \ No newline at end of file diff --git a/Lang/Lua/Non-decimal-radices-Input b/Lang/Lua/Non-decimal-radices-Input new file mode 120000 index 0000000000..b6693cf233 --- /dev/null +++ b/Lang/Lua/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/Lua \ No newline at end of file diff --git a/Lang/Lua/Non-decimal-radices-Output b/Lang/Lua/Non-decimal-radices-Output new file mode 120000 index 0000000000..5e4a953f5c --- /dev/null +++ b/Lang/Lua/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/Lua \ No newline at end of file diff --git a/Lang/Lua/Nth-root b/Lang/Lua/Nth-root new file mode 120000 index 0000000000..1717696857 --- /dev/null +++ b/Lang/Lua/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Lua \ No newline at end of file diff --git a/Lang/Lua/Null-object b/Lang/Lua/Null-object new file mode 120000 index 0000000000..e4aa16d257 --- /dev/null +++ b/Lang/Lua/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Lua \ No newline at end of file diff --git a/Lang/Lua/Number-names b/Lang/Lua/Number-names new file mode 120000 index 0000000000..57dd6183e2 --- /dev/null +++ b/Lang/Lua/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/Lua \ No newline at end of file diff --git a/Lang/Lua/Numerical-integration b/Lang/Lua/Numerical-integration new file mode 120000 index 0000000000..88cf7bc7b0 --- /dev/null +++ b/Lang/Lua/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/Lua \ No newline at end of file diff --git a/Lang/Lua/One-dimensional-cellular-automata b/Lang/Lua/One-dimensional-cellular-automata new file mode 120000 index 0000000000..ab87f26617 --- /dev/null +++ b/Lang/Lua/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Lua \ No newline at end of file diff --git a/Lang/Lua/OpenGL b/Lang/Lua/OpenGL new file mode 120000 index 0000000000..4dbc42d4a8 --- /dev/null +++ b/Lang/Lua/OpenGL @@ -0,0 +1 @@ +../../Task/OpenGL/Lua \ No newline at end of file diff --git a/Lang/Lua/Ordered-Partitions b/Lang/Lua/Ordered-Partitions new file mode 120000 index 0000000000..6a82baa54c --- /dev/null +++ b/Lang/Lua/Ordered-Partitions @@ -0,0 +1 @@ +../../Task/Ordered-Partitions/Lua \ No newline at end of file diff --git a/Lang/Lua/Palindrome-detection b/Lang/Lua/Palindrome-detection new file mode 120000 index 0000000000..8307b473a0 --- /dev/null +++ b/Lang/Lua/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Lua \ No newline at end of file diff --git a/Lang/Lua/Pangram-checker b/Lang/Lua/Pangram-checker new file mode 120000 index 0000000000..56aae2febe --- /dev/null +++ b/Lang/Lua/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Lua \ No newline at end of file diff --git a/Lang/Lua/Pascals-triangle b/Lang/Lua/Pascals-triangle new file mode 120000 index 0000000000..d53a99b4e3 --- /dev/null +++ b/Lang/Lua/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Lua \ No newline at end of file diff --git a/Lang/Lua/Perfect-numbers b/Lang/Lua/Perfect-numbers new file mode 120000 index 0000000000..c38eb07af6 --- /dev/null +++ b/Lang/Lua/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Lua \ No newline at end of file diff --git a/Lang/Lua/Permutations b/Lang/Lua/Permutations new file mode 120000 index 0000000000..ec355660dd --- /dev/null +++ b/Lang/Lua/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Lua \ No newline at end of file diff --git a/Lang/Lua/Pick-random-element b/Lang/Lua/Pick-random-element new file mode 120000 index 0000000000..e73d106bc9 --- /dev/null +++ b/Lang/Lua/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/Lua \ No newline at end of file diff --git a/Lang/Lua/Playing-cards b/Lang/Lua/Playing-cards new file mode 120000 index 0000000000..0046faf040 --- /dev/null +++ b/Lang/Lua/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/Lua \ No newline at end of file diff --git a/Lang/Lua/Polymorphism b/Lang/Lua/Polymorphism new file mode 120000 index 0000000000..4c53dc96fb --- /dev/null +++ b/Lang/Lua/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/Lua \ No newline at end of file diff --git a/Lang/Lua/Power-set b/Lang/Lua/Power-set new file mode 120000 index 0000000000..758c1029a6 --- /dev/null +++ b/Lang/Lua/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Lua \ No newline at end of file diff --git a/Lang/Lua/Primality-by-trial-division b/Lang/Lua/Primality-by-trial-division new file mode 120000 index 0000000000..353d5ece1b --- /dev/null +++ b/Lang/Lua/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Lua \ No newline at end of file diff --git a/Lang/Lua/Prime-decomposition b/Lang/Lua/Prime-decomposition new file mode 120000 index 0000000000..07f2af691a --- /dev/null +++ b/Lang/Lua/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Lua \ No newline at end of file diff --git a/Lang/Lua/Probabilistic-choice b/Lang/Lua/Probabilistic-choice new file mode 120000 index 0000000000..ab4a0b6596 --- /dev/null +++ b/Lang/Lua/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/Lua \ No newline at end of file diff --git a/Lang/Lua/Program-name b/Lang/Lua/Program-name new file mode 120000 index 0000000000..4dcc3359bb --- /dev/null +++ b/Lang/Lua/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Lua \ No newline at end of file diff --git a/Lang/Lua/Program-termination b/Lang/Lua/Program-termination new file mode 120000 index 0000000000..cf3586e3c6 --- /dev/null +++ b/Lang/Lua/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Lua \ No newline at end of file diff --git a/Lang/Lua/Quaternion-type b/Lang/Lua/Quaternion-type new file mode 120000 index 0000000000..09499b7f9c --- /dev/null +++ b/Lang/Lua/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/Lua \ No newline at end of file diff --git a/Lang/Lua/Queue-Definition b/Lang/Lua/Queue-Definition new file mode 120000 index 0000000000..d7da0cb0f5 --- /dev/null +++ b/Lang/Lua/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/Lua \ No newline at end of file diff --git a/Lang/Lua/Queue-Usage b/Lang/Lua/Queue-Usage new file mode 120000 index 0000000000..d1e7b9029b --- /dev/null +++ b/Lang/Lua/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/Lua \ No newline at end of file diff --git a/Lang/Lua/Read-a-configuration-file b/Lang/Lua/Read-a-configuration-file new file mode 120000 index 0000000000..45c4daabff --- /dev/null +++ b/Lang/Lua/Read-a-configuration-file @@ -0,0 +1 @@ +../../Task/Read-a-configuration-file/Lua \ No newline at end of file diff --git a/Lang/Lua/Read-a-file-line-by-line b/Lang/Lua/Read-a-file-line-by-line new file mode 120000 index 0000000000..90cb5dee89 --- /dev/null +++ b/Lang/Lua/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Lua \ No newline at end of file diff --git a/Lang/Lua/Read-entire-file b/Lang/Lua/Read-entire-file new file mode 120000 index 0000000000..627652cd51 --- /dev/null +++ b/Lang/Lua/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Lua \ No newline at end of file diff --git a/Lang/Lua/Real-constants-and-functions b/Lang/Lua/Real-constants-and-functions new file mode 120000 index 0000000000..008122c499 --- /dev/null +++ b/Lang/Lua/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Lua \ No newline at end of file diff --git a/Lang/Lua/Reduced-row-echelon-form b/Lang/Lua/Reduced-row-echelon-form new file mode 120000 index 0000000000..e9fe77f6ab --- /dev/null +++ b/Lang/Lua/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/Lua \ No newline at end of file diff --git a/Lang/Lua/Regular-expressions b/Lang/Lua/Regular-expressions new file mode 120000 index 0000000000..8df5bed6f5 --- /dev/null +++ b/Lang/Lua/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Lua \ No newline at end of file diff --git a/Lang/Lua/Remove-duplicate-elements b/Lang/Lua/Remove-duplicate-elements new file mode 120000 index 0000000000..53c3bd2629 --- /dev/null +++ b/Lang/Lua/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Lua \ No newline at end of file diff --git a/Lang/Lua/Remove-lines-from-a-file b/Lang/Lua/Remove-lines-from-a-file new file mode 120000 index 0000000000..7eaf2a1b53 --- /dev/null +++ b/Lang/Lua/Remove-lines-from-a-file @@ -0,0 +1 @@ +../../Task/Remove-lines-from-a-file/Lua \ No newline at end of file diff --git a/Lang/Lua/Rename-a-file b/Lang/Lua/Rename-a-file new file mode 120000 index 0000000000..9ec1a435c7 --- /dev/null +++ b/Lang/Lua/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Lua \ No newline at end of file diff --git a/Lang/Lua/Repeat-a-string b/Lang/Lua/Repeat-a-string new file mode 120000 index 0000000000..cab580a75b --- /dev/null +++ b/Lang/Lua/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Lua \ No newline at end of file diff --git a/Lang/Lua/Respond-to-an-unknown-method-call b/Lang/Lua/Respond-to-an-unknown-method-call new file mode 120000 index 0000000000..e70ce91dee --- /dev/null +++ b/Lang/Lua/Respond-to-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Respond-to-an-unknown-method-call/Lua \ No newline at end of file diff --git a/Lang/Lua/Return-multiple-values b/Lang/Lua/Return-multiple-values new file mode 120000 index 0000000000..cb950ab97b --- /dev/null +++ b/Lang/Lua/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Lua \ No newline at end of file diff --git a/Lang/Lua/Reverse-a-string b/Lang/Lua/Reverse-a-string new file mode 120000 index 0000000000..fd7587a2a0 --- /dev/null +++ b/Lang/Lua/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Lua \ No newline at end of file diff --git a/Lang/Lua/Roman-numerals-Decode b/Lang/Lua/Roman-numerals-Decode new file mode 120000 index 0000000000..bf896555e6 --- /dev/null +++ b/Lang/Lua/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/Lua \ No newline at end of file diff --git a/Lang/Lua/Roman-numerals-Encode b/Lang/Lua/Roman-numerals-Encode new file mode 120000 index 0000000000..9cdcd29c5c --- /dev/null +++ b/Lang/Lua/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Lua \ No newline at end of file diff --git a/Lang/Lua/Roots-of-a-quadratic-function b/Lang/Lua/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..21dbbf0c06 --- /dev/null +++ b/Lang/Lua/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/Lua \ No newline at end of file diff --git a/Lang/Lua/Roots-of-unity b/Lang/Lua/Roots-of-unity new file mode 120000 index 0000000000..6855462d00 --- /dev/null +++ b/Lang/Lua/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/Lua \ No newline at end of file diff --git a/Lang/Lua/Rosetta-Code-Fix-code-tags b/Lang/Lua/Rosetta-Code-Fix-code-tags new file mode 120000 index 0000000000..e7c76ee04a --- /dev/null +++ b/Lang/Lua/Rosetta-Code-Fix-code-tags @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Fix-code-tags/Lua \ No newline at end of file diff --git a/Lang/Lua/Rot-13 b/Lang/Lua/Rot-13 new file mode 120000 index 0000000000..75dccf99c6 --- /dev/null +++ b/Lang/Lua/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Lua \ No newline at end of file diff --git a/Lang/Lua/Run-length-encoding b/Lang/Lua/Run-length-encoding new file mode 120000 index 0000000000..77bf7176f9 --- /dev/null +++ b/Lang/Lua/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Lua \ No newline at end of file diff --git a/Lang/Lua/Runtime-evaluation b/Lang/Lua/Runtime-evaluation new file mode 120000 index 0000000000..b3f295e229 --- /dev/null +++ b/Lang/Lua/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/Lua \ No newline at end of file diff --git a/Lang/Lua/Runtime-evaluation-In-an-environment b/Lang/Lua/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..27055fa698 --- /dev/null +++ b/Lang/Lua/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/Lua \ No newline at end of file diff --git a/Lang/Lua/Secure-temporary-file b/Lang/Lua/Secure-temporary-file new file mode 120000 index 0000000000..7018b33db2 --- /dev/null +++ b/Lang/Lua/Secure-temporary-file @@ -0,0 +1 @@ +../../Task/Secure-temporary-file/Lua \ No newline at end of file diff --git a/Lang/Lua/Self-describing-numbers b/Lang/Lua/Self-describing-numbers new file mode 120000 index 0000000000..b189ac8764 --- /dev/null +++ b/Lang/Lua/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/Lua \ No newline at end of file diff --git a/Lang/Lua/Send-email b/Lang/Lua/Send-email new file mode 120000 index 0000000000..bbb76bcaca --- /dev/null +++ b/Lang/Lua/Send-email @@ -0,0 +1 @@ +../../Task/Send-email/Lua \ No newline at end of file diff --git a/Lang/Lua/Sequence-of-non-squares b/Lang/Lua/Sequence-of-non-squares new file mode 120000 index 0000000000..288f274077 --- /dev/null +++ b/Lang/Lua/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Lua \ No newline at end of file diff --git a/Lang/M4/Non-decimal-radices-Convert b/Lang/M4/Non-decimal-radices-Convert new file mode 120000 index 0000000000..ec6f67cf2c --- /dev/null +++ b/Lang/M4/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/M4 \ No newline at end of file diff --git a/Lang/M4/One-dimensional-cellular-automata b/Lang/M4/One-dimensional-cellular-automata new file mode 120000 index 0000000000..180a59a590 --- /dev/null +++ b/Lang/M4/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/M4 \ No newline at end of file diff --git a/Lang/M4/Palindrome-detection b/Lang/M4/Palindrome-detection new file mode 120000 index 0000000000..ef32695120 --- /dev/null +++ b/Lang/M4/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/M4 \ No newline at end of file diff --git a/Lang/M4/Perfect-numbers b/Lang/M4/Perfect-numbers new file mode 120000 index 0000000000..ce71c54f18 --- /dev/null +++ b/Lang/M4/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/M4 \ No newline at end of file diff --git a/Lang/M4/Playing-cards b/Lang/M4/Playing-cards new file mode 120000 index 0000000000..e687e26a77 --- /dev/null +++ b/Lang/M4/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/M4 \ No newline at end of file diff --git a/Lang/M4/Power-set b/Lang/M4/Power-set new file mode 120000 index 0000000000..fc61c35fe4 --- /dev/null +++ b/Lang/M4/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/M4 \ No newline at end of file diff --git a/Lang/M4/Primality-by-trial-division b/Lang/M4/Primality-by-trial-division new file mode 120000 index 0000000000..35ecac51e4 --- /dev/null +++ b/Lang/M4/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/M4 \ No newline at end of file diff --git a/Lang/M4/Program-termination b/Lang/M4/Program-termination new file mode 120000 index 0000000000..2f2fb8cf6d --- /dev/null +++ b/Lang/M4/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/M4 \ No newline at end of file diff --git a/Lang/M4/Regular-expressions b/Lang/M4/Regular-expressions new file mode 120000 index 0000000000..8b02a7f4cd --- /dev/null +++ b/Lang/M4/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/M4 \ No newline at end of file diff --git a/Lang/M4/Reverse-a-string b/Lang/M4/Reverse-a-string new file mode 120000 index 0000000000..888bf6f652 --- /dev/null +++ b/Lang/M4/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/M4 \ No newline at end of file diff --git a/Lang/M4/Roman-numerals-Encode b/Lang/M4/Roman-numerals-Encode new file mode 120000 index 0000000000..b5376aeba7 --- /dev/null +++ b/Lang/M4/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/M4 \ No newline at end of file diff --git a/Lang/M4/SEDOLs b/Lang/M4/SEDOLs new file mode 120000 index 0000000000..10ca482ba9 --- /dev/null +++ b/Lang/M4/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/M4 \ No newline at end of file diff --git a/Lang/MATLAB/Arbitrary-precision-integers--included- b/Lang/MATLAB/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..4f98ad69a4 --- /dev/null +++ b/Lang/MATLAB/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Arbitrary-precision-integers-included b/Lang/MATLAB/Arbitrary-precision-integers-included deleted file mode 120000 index cf35fb8cd2..0000000000 --- a/Lang/MATLAB/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Binary-digits b/Lang/MATLAB/Binary-digits new file mode 120000 index 0000000000..d543f20365 --- /dev/null +++ b/Lang/MATLAB/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Catalan-numbers b/Lang/MATLAB/Catalan-numbers new file mode 120000 index 0000000000..617a7d1213 --- /dev/null +++ b/Lang/MATLAB/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Copy-a-string b/Lang/MATLAB/Copy-a-string new file mode 120000 index 0000000000..12537bd50a --- /dev/null +++ b/Lang/MATLAB/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Environment-variables b/Lang/MATLAB/Environment-variables new file mode 120000 index 0000000000..4784015f2c --- /dev/null +++ b/Lang/MATLAB/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Named-parameters b/Lang/MATLAB/Named-parameters new file mode 120000 index 0000000000..f78fd0b3c4 --- /dev/null +++ b/Lang/MATLAB/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Nth-root b/Lang/MATLAB/Nth-root new file mode 120000 index 0000000000..880f530cf7 --- /dev/null +++ b/Lang/MATLAB/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Numerical-integration b/Lang/MATLAB/Numerical-integration new file mode 120000 index 0000000000..4ba7b0da72 --- /dev/null +++ b/Lang/MATLAB/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Palindrome-detection b/Lang/MATLAB/Palindrome-detection new file mode 120000 index 0000000000..97115cc637 --- /dev/null +++ b/Lang/MATLAB/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Pangram-checker b/Lang/MATLAB/Pangram-checker new file mode 120000 index 0000000000..3d02a01744 --- /dev/null +++ b/Lang/MATLAB/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Pascals-triangle b/Lang/MATLAB/Pascals-triangle new file mode 120000 index 0000000000..9d661b0d77 --- /dev/null +++ b/Lang/MATLAB/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Pick-random-element b/Lang/MATLAB/Pick-random-element new file mode 120000 index 0000000000..62c253ba72 --- /dev/null +++ b/Lang/MATLAB/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Plot-coordinate-pairs b/Lang/MATLAB/Plot-coordinate-pairs new file mode 120000 index 0000000000..ddff33c5fc --- /dev/null +++ b/Lang/MATLAB/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Polynomial-regression b/Lang/MATLAB/Polynomial-regression new file mode 120000 index 0000000000..854b918d1f --- /dev/null +++ b/Lang/MATLAB/Polynomial-regression @@ -0,0 +1 @@ +../../Task/Polynomial-regression/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Power-set b/Lang/MATLAB/Power-set new file mode 120000 index 0000000000..0376eee52e --- /dev/null +++ b/Lang/MATLAB/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Price-fraction b/Lang/MATLAB/Price-fraction new file mode 120000 index 0000000000..0060bd2d11 --- /dev/null +++ b/Lang/MATLAB/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Primality-by-trial-division b/Lang/MATLAB/Primality-by-trial-division new file mode 120000 index 0000000000..0c93c031c9 --- /dev/null +++ b/Lang/MATLAB/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Prime-decomposition b/Lang/MATLAB/Prime-decomposition new file mode 120000 index 0000000000..38191a82ea --- /dev/null +++ b/Lang/MATLAB/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Program-termination b/Lang/MATLAB/Program-termination new file mode 120000 index 0000000000..947b447cec --- /dev/null +++ b/Lang/MATLAB/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Pythagorean-triples b/Lang/MATLAB/Pythagorean-triples new file mode 120000 index 0000000000..214258f858 --- /dev/null +++ b/Lang/MATLAB/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/QR-decomposition b/Lang/MATLAB/QR-decomposition new file mode 120000 index 0000000000..591a3f24f7 --- /dev/null +++ b/Lang/MATLAB/QR-decomposition @@ -0,0 +1 @@ +../../Task/QR-decomposition/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Queue-Definition b/Lang/MATLAB/Queue-Definition new file mode 120000 index 0000000000..f55df20561 --- /dev/null +++ b/Lang/MATLAB/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Random-numbers b/Lang/MATLAB/Random-numbers new file mode 120000 index 0000000000..9da1287967 --- /dev/null +++ b/Lang/MATLAB/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Read-a-configuration-file b/Lang/MATLAB/Read-a-configuration-file new file mode 120000 index 0000000000..486dfde9ca --- /dev/null +++ b/Lang/MATLAB/Read-a-configuration-file @@ -0,0 +1 @@ +../../Task/Read-a-configuration-file/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Read-a-file-line-by-line b/Lang/MATLAB/Read-a-file-line-by-line new file mode 120000 index 0000000000..4c44a876ac --- /dev/null +++ b/Lang/MATLAB/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Read-a-specific-line-from-a-file b/Lang/MATLAB/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..2877272c9e --- /dev/null +++ b/Lang/MATLAB/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Read-entire-file b/Lang/MATLAB/Read-entire-file new file mode 120000 index 0000000000..1b2236321e --- /dev/null +++ b/Lang/MATLAB/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Reduced-row-echelon-form b/Lang/MATLAB/Reduced-row-echelon-form new file mode 120000 index 0000000000..1efd5c3054 --- /dev/null +++ b/Lang/MATLAB/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Remove-duplicate-elements b/Lang/MATLAB/Remove-duplicate-elements new file mode 120000 index 0000000000..3ae0421f04 --- /dev/null +++ b/Lang/MATLAB/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Rename-a-file b/Lang/MATLAB/Rename-a-file new file mode 120000 index 0000000000..b8553c094e --- /dev/null +++ b/Lang/MATLAB/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Repeat-a-string b/Lang/MATLAB/Repeat-a-string new file mode 120000 index 0000000000..dc72089136 --- /dev/null +++ b/Lang/MATLAB/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Return-multiple-values b/Lang/MATLAB/Return-multiple-values new file mode 120000 index 0000000000..d3160f6e0d --- /dev/null +++ b/Lang/MATLAB/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Reverse-a-string b/Lang/MATLAB/Reverse-a-string new file mode 120000 index 0000000000..7e9d24ed7e --- /dev/null +++ b/Lang/MATLAB/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Roots-of-a-quadratic-function b/Lang/MATLAB/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..b077ada105 --- /dev/null +++ b/Lang/MATLAB/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Roots-of-unity b/Lang/MATLAB/Roots-of-unity new file mode 120000 index 0000000000..2a5d1329e5 --- /dev/null +++ b/Lang/MATLAB/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Rosetta-Code-Count-examples b/Lang/MATLAB/Rosetta-Code-Count-examples new file mode 120000 index 0000000000..68b7269d68 --- /dev/null +++ b/Lang/MATLAB/Rosetta-Code-Count-examples @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Count-examples/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Rot-13 b/Lang/MATLAB/Rot-13 new file mode 120000 index 0000000000..5d668c195a --- /dev/null +++ b/Lang/MATLAB/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Self-describing-numbers b/Lang/MATLAB/Self-describing-numbers new file mode 120000 index 0000000000..c39827a7c5 --- /dev/null +++ b/Lang/MATLAB/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Send-an-unknown-method-call b/Lang/MATLAB/Send-an-unknown-method-call new file mode 120000 index 0000000000..652bd780ed --- /dev/null +++ b/Lang/MATLAB/Send-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Send-an-unknown-method-call/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Sequence-of-non-squares b/Lang/MATLAB/Sequence-of-non-squares new file mode 120000 index 0000000000..af06519925 --- /dev/null +++ b/Lang/MATLAB/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/MATLAB \ No newline at end of file diff --git a/Lang/MATLAB/Set b/Lang/MATLAB/Set new file mode 120000 index 0000000000..874b4f3dec --- /dev/null +++ b/Lang/MATLAB/Set @@ -0,0 +1 @@ +../../Task/Set/MATLAB \ No newline at end of file diff --git a/Lang/MAXScript/Copy-a-string b/Lang/MAXScript/Copy-a-string new file mode 120000 index 0000000000..3478ef131f --- /dev/null +++ b/Lang/MAXScript/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Null-object b/Lang/MAXScript/Null-object new file mode 120000 index 0000000000..6a7acc5340 --- /dev/null +++ b/Lang/MAXScript/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Number-names b/Lang/MAXScript/Number-names new file mode 120000 index 0000000000..7a94c1d027 --- /dev/null +++ b/Lang/MAXScript/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/OpenGL b/Lang/MAXScript/OpenGL new file mode 120000 index 0000000000..a8719ac1c2 --- /dev/null +++ b/Lang/MAXScript/OpenGL @@ -0,0 +1 @@ +../../Task/OpenGL/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Palindrome-detection b/Lang/MAXScript/Palindrome-detection new file mode 120000 index 0000000000..f5e58b0fb4 --- /dev/null +++ b/Lang/MAXScript/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Percentage-difference-between-images b/Lang/MAXScript/Percentage-difference-between-images new file mode 120000 index 0000000000..9faa1d2d8a --- /dev/null +++ b/Lang/MAXScript/Percentage-difference-between-images @@ -0,0 +1 @@ +../../Task/Percentage-difference-between-images/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Perfect-numbers b/Lang/MAXScript/Perfect-numbers new file mode 120000 index 0000000000..a6cec96bfa --- /dev/null +++ b/Lang/MAXScript/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Primality-by-trial-division b/Lang/MAXScript/Primality-by-trial-division new file mode 120000 index 0000000000..46e46141e7 --- /dev/null +++ b/Lang/MAXScript/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Random-numbers b/Lang/MAXScript/Random-numbers new file mode 120000 index 0000000000..1d3734a0d6 --- /dev/null +++ b/Lang/MAXScript/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Real-constants-and-functions b/Lang/MAXScript/Real-constants-and-functions new file mode 120000 index 0000000000..4cefc050fa --- /dev/null +++ b/Lang/MAXScript/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Remove-duplicate-elements b/Lang/MAXScript/Remove-duplicate-elements new file mode 120000 index 0000000000..66be62cd56 --- /dev/null +++ b/Lang/MAXScript/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Rename-a-file b/Lang/MAXScript/Rename-a-file new file mode 120000 index 0000000000..980c368141 --- /dev/null +++ b/Lang/MAXScript/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/MAXScript \ No newline at end of file diff --git a/Lang/MAXScript/Reverse-a-string b/Lang/MAXScript/Reverse-a-string new file mode 120000 index 0000000000..fefd04a9c6 --- /dev/null +++ b/Lang/MAXScript/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/MAXScript \ No newline at end of file diff --git a/Lang/MIRC-Scripting-Language/Regular-expressions b/Lang/MIRC-Scripting-Language/Regular-expressions new file mode 120000 index 0000000000..18795bcefa --- /dev/null +++ b/Lang/MIRC-Scripting-Language/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/MIRC-Scripting-Language \ No newline at end of file diff --git a/Lang/MMIX/Palindrome-detection b/Lang/MMIX/Palindrome-detection new file mode 120000 index 0000000000..2a5ea3c282 --- /dev/null +++ b/Lang/MMIX/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/MMIX \ No newline at end of file diff --git a/Lang/MMIX/Rot-13 b/Lang/MMIX/Rot-13 new file mode 120000 index 0000000000..d9b05bd26f --- /dev/null +++ b/Lang/MMIX/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/MMIX \ No newline at end of file diff --git a/Lang/MMIX/Run-length-encoding b/Lang/MMIX/Run-length-encoding new file mode 120000 index 0000000000..76042ef33d --- /dev/null +++ b/Lang/MMIX/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/MMIX \ No newline at end of file diff --git a/Lang/MMIX/Sequence-of-non-squares b/Lang/MMIX/Sequence-of-non-squares new file mode 120000 index 0000000000..3ce2b4d095 --- /dev/null +++ b/Lang/MMIX/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/MMIX \ No newline at end of file diff --git a/Lang/MUMPS/Copy-a-string b/Lang/MUMPS/Copy-a-string new file mode 120000 index 0000000000..c6fc4a4894 --- /dev/null +++ b/Lang/MUMPS/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Environment-variables b/Lang/MUMPS/Environment-variables new file mode 120000 index 0000000000..9bd88b8bc0 --- /dev/null +++ b/Lang/MUMPS/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/N-queens-problem b/Lang/MUMPS/N-queens-problem new file mode 120000 index 0000000000..9127f9613f --- /dev/null +++ b/Lang/MUMPS/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Null-object b/Lang/MUMPS/Null-object new file mode 120000 index 0000000000..cc7430ca5e --- /dev/null +++ b/Lang/MUMPS/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Price-fraction b/Lang/MUMPS/Price-fraction new file mode 120000 index 0000000000..008cfe029a --- /dev/null +++ b/Lang/MUMPS/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Primality-by-trial-division b/Lang/MUMPS/Primality-by-trial-division new file mode 120000 index 0000000000..5000492fc7 --- /dev/null +++ b/Lang/MUMPS/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Prime-decomposition b/Lang/MUMPS/Prime-decomposition new file mode 120000 index 0000000000..514fa678c4 --- /dev/null +++ b/Lang/MUMPS/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Problem-of-Apollonius b/Lang/MUMPS/Problem-of-Apollonius new file mode 120000 index 0000000000..e042fe2c0a --- /dev/null +++ b/Lang/MUMPS/Problem-of-Apollonius @@ -0,0 +1 @@ +../../Task/Problem-of-Apollonius/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Range-expansion b/Lang/MUMPS/Range-expansion new file mode 120000 index 0000000000..1b42d2e211 --- /dev/null +++ b/Lang/MUMPS/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Range-extraction b/Lang/MUMPS/Range-extraction new file mode 120000 index 0000000000..9e4099397d --- /dev/null +++ b/Lang/MUMPS/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Regular-expressions b/Lang/MUMPS/Regular-expressions new file mode 120000 index 0000000000..002fd0df11 --- /dev/null +++ b/Lang/MUMPS/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Remove-duplicate-elements b/Lang/MUMPS/Remove-duplicate-elements new file mode 120000 index 0000000000..928d1acf81 --- /dev/null +++ b/Lang/MUMPS/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Rename-a-file b/Lang/MUMPS/Rename-a-file new file mode 120000 index 0000000000..b5d3c14256 --- /dev/null +++ b/Lang/MUMPS/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Repeat-a-string b/Lang/MUMPS/Repeat-a-string new file mode 120000 index 0000000000..cabe90eb10 --- /dev/null +++ b/Lang/MUMPS/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Reverse-a-string b/Lang/MUMPS/Reverse-a-string new file mode 120000 index 0000000000..67356accb7 --- /dev/null +++ b/Lang/MUMPS/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Roman-numerals-Encode b/Lang/MUMPS/Roman-numerals-Encode new file mode 120000 index 0000000000..e360bdf836 --- /dev/null +++ b/Lang/MUMPS/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Rot-13 b/Lang/MUMPS/Rot-13 new file mode 120000 index 0000000000..9c1e749b88 --- /dev/null +++ b/Lang/MUMPS/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/SEDOLs b/Lang/MUMPS/SEDOLs new file mode 120000 index 0000000000..d568187dea --- /dev/null +++ b/Lang/MUMPS/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/MUMPS \ No newline at end of file diff --git a/Lang/MUMPS/Scope-modifiers b/Lang/MUMPS/Scope-modifiers new file mode 120000 index 0000000000..5813e7af9c --- /dev/null +++ b/Lang/MUMPS/Scope-modifiers @@ -0,0 +1 @@ +../../Task/Scope-modifiers/MUMPS \ No newline at end of file diff --git a/Lang/Maple/Arbitrary-precision-integers--included- b/Lang/Maple/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..4527af667f --- /dev/null +++ b/Lang/Maple/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Maple \ No newline at end of file diff --git a/Lang/Maple/Arbitrary-precision-integers-included b/Lang/Maple/Arbitrary-precision-integers-included deleted file mode 120000 index 4e0aba7d23..0000000000 --- a/Lang/Maple/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Maple \ No newline at end of file diff --git a/Lang/Maple/Binary-digits b/Lang/Maple/Binary-digits new file mode 120000 index 0000000000..1d00fb60b6 --- /dev/null +++ b/Lang/Maple/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Maple \ No newline at end of file diff --git a/Lang/Maple/Copy-a-string b/Lang/Maple/Copy-a-string new file mode 120000 index 0000000000..9b9f889bd6 --- /dev/null +++ b/Lang/Maple/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Maple \ No newline at end of file diff --git a/Lang/Maple/Permutations b/Lang/Maple/Permutations new file mode 120000 index 0000000000..c35a4c15b6 --- /dev/null +++ b/Lang/Maple/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Maple \ No newline at end of file diff --git a/Lang/Maple/Polynomial-long-division b/Lang/Maple/Polynomial-long-division new file mode 120000 index 0000000000..3992b6c400 --- /dev/null +++ b/Lang/Maple/Polynomial-long-division @@ -0,0 +1 @@ +../../Task/Polynomial-long-division/Maple \ No newline at end of file diff --git a/Lang/Maple/Primality-by-trial-division b/Lang/Maple/Primality-by-trial-division new file mode 120000 index 0000000000..a0dcab9e77 --- /dev/null +++ b/Lang/Maple/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Maple \ No newline at end of file diff --git a/Lang/Maple/Range-expansion b/Lang/Maple/Range-expansion new file mode 120000 index 0000000000..fcde921a4d --- /dev/null +++ b/Lang/Maple/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/Maple \ No newline at end of file diff --git a/Lang/Maple/Read-entire-file b/Lang/Maple/Read-entire-file new file mode 120000 index 0000000000..7ca322313e --- /dev/null +++ b/Lang/Maple/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Maple \ No newline at end of file diff --git a/Lang/Maple/Real-constants-and-functions b/Lang/Maple/Real-constants-and-functions new file mode 120000 index 0000000000..bfaecd6cd9 --- /dev/null +++ b/Lang/Maple/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Maple \ No newline at end of file diff --git a/Lang/Maple/Remove-duplicate-elements b/Lang/Maple/Remove-duplicate-elements new file mode 120000 index 0000000000..ef2eabbbc2 --- /dev/null +++ b/Lang/Maple/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Maple \ No newline at end of file diff --git a/Lang/Maple/Rename-a-file b/Lang/Maple/Rename-a-file new file mode 120000 index 0000000000..a3ed7baee8 --- /dev/null +++ b/Lang/Maple/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Maple \ No newline at end of file diff --git a/Lang/Maple/Repeat-a-string b/Lang/Maple/Repeat-a-string new file mode 120000 index 0000000000..4df8085eaf --- /dev/null +++ b/Lang/Maple/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Maple \ No newline at end of file diff --git a/Lang/Maple/Return-multiple-values b/Lang/Maple/Return-multiple-values new file mode 120000 index 0000000000..89adf801bc --- /dev/null +++ b/Lang/Maple/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Maple \ No newline at end of file diff --git a/Lang/Maple/Reverse-a-string b/Lang/Maple/Reverse-a-string new file mode 120000 index 0000000000..63bea877fa --- /dev/null +++ b/Lang/Maple/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Maple \ No newline at end of file diff --git a/Lang/Maple/Roots-of-a-function b/Lang/Maple/Roots-of-a-function new file mode 120000 index 0000000000..a9b0a853ac --- /dev/null +++ b/Lang/Maple/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/Maple \ No newline at end of file diff --git a/Lang/Maple/Rot-13 b/Lang/Maple/Rot-13 new file mode 120000 index 0000000000..7e5eec63bb --- /dev/null +++ b/Lang/Maple/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Maple \ No newline at end of file diff --git a/Lang/Maple/Set b/Lang/Maple/Set new file mode 120000 index 0000000000..8300adf85b --- /dev/null +++ b/Lang/Maple/Set @@ -0,0 +1 @@ +../../Task/Set/Maple \ No newline at end of file diff --git a/Lang/Mathematica/Arbitrary-precision-integers--included- b/Lang/Mathematica/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..0edc448f72 --- /dev/null +++ b/Lang/Mathematica/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Arbitrary-precision-integers-included b/Lang/Mathematica/Arbitrary-precision-integers-included deleted file mode 120000 index 7fcf201d66..0000000000 --- a/Lang/Mathematica/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Binary-digits b/Lang/Mathematica/Binary-digits new file mode 120000 index 0000000000..326bcfb957 --- /dev/null +++ b/Lang/Mathematica/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Brownian-tree b/Lang/Mathematica/Brownian-tree new file mode 120000 index 0000000000..ce66c8cf55 --- /dev/null +++ b/Lang/Mathematica/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Catalan-numbers b/Lang/Mathematica/Catalan-numbers new file mode 120000 index 0000000000..15f67e7664 --- /dev/null +++ b/Lang/Mathematica/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Copy-a-string b/Lang/Mathematica/Copy-a-string new file mode 120000 index 0000000000..a418b8d62b --- /dev/null +++ b/Lang/Mathematica/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Dragon-curve b/Lang/Mathematica/Dragon-curve new file mode 120000 index 0000000000..06febdac49 --- /dev/null +++ b/Lang/Mathematica/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Environment-variables b/Lang/Mathematica/Environment-variables new file mode 120000 index 0000000000..02e3003113 --- /dev/null +++ b/Lang/Mathematica/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Execute-a-Markov-algorithm b/Lang/Mathematica/Execute-a-Markov-algorithm new file mode 120000 index 0000000000..0445d2a34c --- /dev/null +++ b/Lang/Mathematica/Execute-a-Markov-algorithm @@ -0,0 +1 @@ +../../Task/Execute-a-Markov-algorithm/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Guess-the-number-With-feedback--player- b/Lang/Mathematica/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..e42282d691 --- /dev/null +++ b/Lang/Mathematica/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Guess-the-number-With-feedback-player b/Lang/Mathematica/Guess-the-number-With-feedback-player deleted file mode 120000 index 56824819ff..0000000000 --- a/Lang/Mathematica/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/N-queens-problem b/Lang/Mathematica/N-queens-problem new file mode 120000 index 0000000000..f2ed6f18a6 --- /dev/null +++ b/Lang/Mathematica/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Named-parameters b/Lang/Mathematica/Named-parameters new file mode 120000 index 0000000000..62b1c7f544 --- /dev/null +++ b/Lang/Mathematica/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Non-continuous-subsequences b/Lang/Mathematica/Non-continuous-subsequences new file mode 120000 index 0000000000..429f0db3d8 --- /dev/null +++ b/Lang/Mathematica/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Non-decimal-radices-Convert b/Lang/Mathematica/Non-decimal-radices-Convert new file mode 120000 index 0000000000..1146157a65 --- /dev/null +++ b/Lang/Mathematica/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Non-decimal-radices-Input b/Lang/Mathematica/Non-decimal-radices-Input new file mode 120000 index 0000000000..990b48b2ac --- /dev/null +++ b/Lang/Mathematica/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Non-decimal-radices-Output b/Lang/Mathematica/Non-decimal-radices-Output new file mode 120000 index 0000000000..6961114f7c --- /dev/null +++ b/Lang/Mathematica/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Nth-root b/Lang/Mathematica/Nth-root new file mode 120000 index 0000000000..d5d12e467f --- /dev/null +++ b/Lang/Mathematica/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Null-object b/Lang/Mathematica/Null-object new file mode 120000 index 0000000000..13595376a1 --- /dev/null +++ b/Lang/Mathematica/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Number-names b/Lang/Mathematica/Number-names new file mode 120000 index 0000000000..e9e1c0b89e --- /dev/null +++ b/Lang/Mathematica/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Number-reversal-game b/Lang/Mathematica/Number-reversal-game new file mode 120000 index 0000000000..39bb321a2c --- /dev/null +++ b/Lang/Mathematica/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Numeric-error-propagation b/Lang/Mathematica/Numeric-error-propagation new file mode 120000 index 0000000000..ee56fc1713 --- /dev/null +++ b/Lang/Mathematica/Numeric-error-propagation @@ -0,0 +1 @@ +../../Task/Numeric-error-propagation/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Numerical-integration b/Lang/Mathematica/Numerical-integration new file mode 120000 index 0000000000..9739a690e4 --- /dev/null +++ b/Lang/Mathematica/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Numerical-integration-Gauss-Legendre-Quadrature b/Lang/Mathematica/Numerical-integration-Gauss-Legendre-Quadrature new file mode 120000 index 0000000000..2245bfbe18 --- /dev/null +++ b/Lang/Mathematica/Numerical-integration-Gauss-Legendre-Quadrature @@ -0,0 +1 @@ +../../Task/Numerical-integration-Gauss-Legendre-Quadrature/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/One-dimensional-cellular-automata b/Lang/Mathematica/One-dimensional-cellular-automata new file mode 120000 index 0000000000..ab9efc83bf --- /dev/null +++ b/Lang/Mathematica/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Optional-parameters b/Lang/Mathematica/Optional-parameters new file mode 120000 index 0000000000..37ae0405a5 --- /dev/null +++ b/Lang/Mathematica/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Order-two-numerical-lists b/Lang/Mathematica/Order-two-numerical-lists new file mode 120000 index 0000000000..0d3ef2880d --- /dev/null +++ b/Lang/Mathematica/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Ordered-Partitions b/Lang/Mathematica/Ordered-Partitions new file mode 120000 index 0000000000..e4660ac7bf --- /dev/null +++ b/Lang/Mathematica/Ordered-Partitions @@ -0,0 +1 @@ +../../Task/Ordered-Partitions/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Palindrome-detection b/Lang/Mathematica/Palindrome-detection new file mode 120000 index 0000000000..2dea1fb2cb --- /dev/null +++ b/Lang/Mathematica/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Pangram-checker b/Lang/Mathematica/Pangram-checker new file mode 120000 index 0000000000..14de7a835d --- /dev/null +++ b/Lang/Mathematica/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Parallel-calculations b/Lang/Mathematica/Parallel-calculations new file mode 120000 index 0000000000..fa59833879 --- /dev/null +++ b/Lang/Mathematica/Parallel-calculations @@ -0,0 +1 @@ +../../Task/Parallel-calculations/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Parametrized-SQL-statement b/Lang/Mathematica/Parametrized-SQL-statement new file mode 120000 index 0000000000..02240aa175 --- /dev/null +++ b/Lang/Mathematica/Parametrized-SQL-statement @@ -0,0 +1 @@ +../../Task/Parametrized-SQL-statement/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Partial-function-application b/Lang/Mathematica/Partial-function-application new file mode 120000 index 0000000000..cdfafd79f7 --- /dev/null +++ b/Lang/Mathematica/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Pascals-triangle b/Lang/Mathematica/Pascals-triangle new file mode 120000 index 0000000000..c675b9389f --- /dev/null +++ b/Lang/Mathematica/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Pascals-triangle-Puzzle b/Lang/Mathematica/Pascals-triangle-Puzzle new file mode 120000 index 0000000000..7fb44ae2bb --- /dev/null +++ b/Lang/Mathematica/Pascals-triangle-Puzzle @@ -0,0 +1 @@ +../../Task/Pascals-triangle-Puzzle/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Percentage-difference-between-images b/Lang/Mathematica/Percentage-difference-between-images new file mode 120000 index 0000000000..72105540cf --- /dev/null +++ b/Lang/Mathematica/Percentage-difference-between-images @@ -0,0 +1 @@ +../../Task/Percentage-difference-between-images/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Perfect-numbers b/Lang/Mathematica/Perfect-numbers new file mode 120000 index 0000000000..500285bdab --- /dev/null +++ b/Lang/Mathematica/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Permutation-test b/Lang/Mathematica/Permutation-test new file mode 120000 index 0000000000..31b08ab0eb --- /dev/null +++ b/Lang/Mathematica/Permutation-test @@ -0,0 +1 @@ +../../Task/Permutation-test/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Permutations b/Lang/Mathematica/Permutations new file mode 120000 index 0000000000..48d0b097fe --- /dev/null +++ b/Lang/Mathematica/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Permutations-Derangements b/Lang/Mathematica/Permutations-Derangements new file mode 120000 index 0000000000..ef2abb5442 --- /dev/null +++ b/Lang/Mathematica/Permutations-Derangements @@ -0,0 +1 @@ +../../Task/Permutations-Derangements/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Permutations-by-swapping b/Lang/Mathematica/Permutations-by-swapping new file mode 120000 index 0000000000..c28708b36e --- /dev/null +++ b/Lang/Mathematica/Permutations-by-swapping @@ -0,0 +1 @@ +../../Task/Permutations-by-swapping/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Pick-random-element b/Lang/Mathematica/Pick-random-element new file mode 120000 index 0000000000..b9aff58e6b --- /dev/null +++ b/Lang/Mathematica/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Pig-the-dice-game b/Lang/Mathematica/Pig-the-dice-game new file mode 120000 index 0000000000..754c931365 --- /dev/null +++ b/Lang/Mathematica/Pig-the-dice-game @@ -0,0 +1 @@ +../../Task/Pig-the-dice-game/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Play-recorded-sounds b/Lang/Mathematica/Play-recorded-sounds new file mode 120000 index 0000000000..6fac2e4cc8 --- /dev/null +++ b/Lang/Mathematica/Play-recorded-sounds @@ -0,0 +1 @@ +../../Task/Play-recorded-sounds/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Playing-cards b/Lang/Mathematica/Playing-cards new file mode 120000 index 0000000000..a1015da2a4 --- /dev/null +++ b/Lang/Mathematica/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Plot-coordinate-pairs b/Lang/Mathematica/Plot-coordinate-pairs new file mode 120000 index 0000000000..d2edeeed17 --- /dev/null +++ b/Lang/Mathematica/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Polynomial-long-division b/Lang/Mathematica/Polynomial-long-division new file mode 120000 index 0000000000..dc19e97281 --- /dev/null +++ b/Lang/Mathematica/Polynomial-long-division @@ -0,0 +1 @@ +../../Task/Polynomial-long-division/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Polynomial-regression b/Lang/Mathematica/Polynomial-regression new file mode 120000 index 0000000000..e8b26463cf --- /dev/null +++ b/Lang/Mathematica/Polynomial-regression @@ -0,0 +1 @@ +../../Task/Polynomial-regression/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Power-set b/Lang/Mathematica/Power-set new file mode 120000 index 0000000000..3ba4d3eabd --- /dev/null +++ b/Lang/Mathematica/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Price-fraction b/Lang/Mathematica/Price-fraction new file mode 120000 index 0000000000..1895121a86 --- /dev/null +++ b/Lang/Mathematica/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Primality-by-trial-division b/Lang/Mathematica/Primality-by-trial-division new file mode 120000 index 0000000000..f96b28c6d6 --- /dev/null +++ b/Lang/Mathematica/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Prime-decomposition b/Lang/Mathematica/Prime-decomposition new file mode 120000 index 0000000000..94245b87ce --- /dev/null +++ b/Lang/Mathematica/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Priority-queue b/Lang/Mathematica/Priority-queue new file mode 120000 index 0000000000..3a0b592441 --- /dev/null +++ b/Lang/Mathematica/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Probabilistic-choice b/Lang/Mathematica/Probabilistic-choice new file mode 120000 index 0000000000..73c04e4e84 --- /dev/null +++ b/Lang/Mathematica/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Problem-of-Apollonius b/Lang/Mathematica/Problem-of-Apollonius new file mode 120000 index 0000000000..9e93842af4 --- /dev/null +++ b/Lang/Mathematica/Problem-of-Apollonius @@ -0,0 +1 @@ +../../Task/Problem-of-Apollonius/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Program-name b/Lang/Mathematica/Program-name new file mode 120000 index 0000000000..22893bcd69 --- /dev/null +++ b/Lang/Mathematica/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Program-termination b/Lang/Mathematica/Program-termination new file mode 120000 index 0000000000..8388728868 --- /dev/null +++ b/Lang/Mathematica/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Pythagorean-triples b/Lang/Mathematica/Pythagorean-triples new file mode 120000 index 0000000000..c5a7262cca --- /dev/null +++ b/Lang/Mathematica/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/QR-decomposition b/Lang/Mathematica/QR-decomposition new file mode 120000 index 0000000000..cdbdd19772 --- /dev/null +++ b/Lang/Mathematica/QR-decomposition @@ -0,0 +1 @@ +../../Task/QR-decomposition/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Quaternion-type b/Lang/Mathematica/Quaternion-type new file mode 120000 index 0000000000..700c56b146 --- /dev/null +++ b/Lang/Mathematica/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Queue-Definition b/Lang/Mathematica/Queue-Definition new file mode 120000 index 0000000000..62587d1d14 --- /dev/null +++ b/Lang/Mathematica/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Queue-Usage b/Lang/Mathematica/Queue-Usage new file mode 120000 index 0000000000..6052dfcbae --- /dev/null +++ b/Lang/Mathematica/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Random-numbers b/Lang/Mathematica/Random-numbers new file mode 120000 index 0000000000..5b64a7804c --- /dev/null +++ b/Lang/Mathematica/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Range-expansion b/Lang/Mathematica/Range-expansion new file mode 120000 index 0000000000..5b5d61e56e --- /dev/null +++ b/Lang/Mathematica/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Range-extraction b/Lang/Mathematica/Range-extraction new file mode 120000 index 0000000000..e595f753e6 --- /dev/null +++ b/Lang/Mathematica/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Read-a-file-line-by-line b/Lang/Mathematica/Read-a-file-line-by-line new file mode 120000 index 0000000000..18bfff0e60 --- /dev/null +++ b/Lang/Mathematica/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Read-a-specific-line-from-a-file b/Lang/Mathematica/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..73b2377323 --- /dev/null +++ b/Lang/Mathematica/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Read-entire-file b/Lang/Mathematica/Read-entire-file new file mode 120000 index 0000000000..4b34644d03 --- /dev/null +++ b/Lang/Mathematica/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Real-constants-and-functions b/Lang/Mathematica/Real-constants-and-functions new file mode 120000 index 0000000000..c2996682e9 --- /dev/null +++ b/Lang/Mathematica/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Record-sound b/Lang/Mathematica/Record-sound new file mode 120000 index 0000000000..7181f33476 --- /dev/null +++ b/Lang/Mathematica/Record-sound @@ -0,0 +1 @@ +../../Task/Record-sound/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Reduced-row-echelon-form b/Lang/Mathematica/Reduced-row-echelon-form new file mode 120000 index 0000000000..66a951fa9f --- /dev/null +++ b/Lang/Mathematica/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Regular-expressions b/Lang/Mathematica/Regular-expressions new file mode 120000 index 0000000000..7306d849c1 --- /dev/null +++ b/Lang/Mathematica/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Remove-duplicate-elements b/Lang/Mathematica/Remove-duplicate-elements new file mode 120000 index 0000000000..7fd80f9467 --- /dev/null +++ b/Lang/Mathematica/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Rename-a-file b/Lang/Mathematica/Rename-a-file new file mode 120000 index 0000000000..e5150a082a --- /dev/null +++ b/Lang/Mathematica/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Repeat-a-string b/Lang/Mathematica/Repeat-a-string new file mode 120000 index 0000000000..d250ce25f7 --- /dev/null +++ b/Lang/Mathematica/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Resistor-mesh b/Lang/Mathematica/Resistor-mesh new file mode 120000 index 0000000000..472ea568b4 --- /dev/null +++ b/Lang/Mathematica/Resistor-mesh @@ -0,0 +1 @@ +../../Task/Resistor-mesh/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Return-multiple-values b/Lang/Mathematica/Return-multiple-values new file mode 120000 index 0000000000..856e6d9388 --- /dev/null +++ b/Lang/Mathematica/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Reverse-a-string b/Lang/Mathematica/Reverse-a-string new file mode 120000 index 0000000000..9794f885ec --- /dev/null +++ b/Lang/Mathematica/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Rock-paper-scissors b/Lang/Mathematica/Rock-paper-scissors new file mode 120000 index 0000000000..c25701b0a4 --- /dev/null +++ b/Lang/Mathematica/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Roman-numerals-Decode b/Lang/Mathematica/Roman-numerals-Decode new file mode 120000 index 0000000000..c95e651404 --- /dev/null +++ b/Lang/Mathematica/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Roman-numerals-Encode b/Lang/Mathematica/Roman-numerals-Encode new file mode 120000 index 0000000000..ae5d42419a --- /dev/null +++ b/Lang/Mathematica/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Roots-of-a-function b/Lang/Mathematica/Roots-of-a-function new file mode 120000 index 0000000000..722e08b59f --- /dev/null +++ b/Lang/Mathematica/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Roots-of-a-quadratic-function b/Lang/Mathematica/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..27f9cc55b2 --- /dev/null +++ b/Lang/Mathematica/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Roots-of-unity b/Lang/Mathematica/Roots-of-unity new file mode 120000 index 0000000000..b9d9864a96 --- /dev/null +++ b/Lang/Mathematica/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Rosetta-Code-Count-examples b/Lang/Mathematica/Rosetta-Code-Count-examples new file mode 120000 index 0000000000..bb39583e78 --- /dev/null +++ b/Lang/Mathematica/Rosetta-Code-Count-examples @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Count-examples/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Rosetta-Code-Fix-code-tags b/Lang/Mathematica/Rosetta-Code-Fix-code-tags new file mode 120000 index 0000000000..8f79e5aa46 --- /dev/null +++ b/Lang/Mathematica/Rosetta-Code-Fix-code-tags @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Fix-code-tags/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Rosetta-Code-Rank-languages-by-popularity b/Lang/Mathematica/Rosetta-Code-Rank-languages-by-popularity new file mode 120000 index 0000000000..ccc906ba1a --- /dev/null +++ b/Lang/Mathematica/Rosetta-Code-Rank-languages-by-popularity @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-popularity/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Rot-13 b/Lang/Mathematica/Rot-13 new file mode 120000 index 0000000000..9db1750aab --- /dev/null +++ b/Lang/Mathematica/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Run-length-encoding b/Lang/Mathematica/Run-length-encoding new file mode 120000 index 0000000000..6cce574a8e --- /dev/null +++ b/Lang/Mathematica/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Runtime-evaluation-In-an-environment b/Lang/Mathematica/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..972c03482f --- /dev/null +++ b/Lang/Mathematica/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/SEDOLs b/Lang/Mathematica/SEDOLs new file mode 120000 index 0000000000..3930f1d03f --- /dev/null +++ b/Lang/Mathematica/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Scope-modifiers b/Lang/Mathematica/Scope-modifiers new file mode 120000 index 0000000000..61a842dc0c --- /dev/null +++ b/Lang/Mathematica/Scope-modifiers @@ -0,0 +1 @@ +../../Task/Scope-modifiers/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Secure-temporary-file b/Lang/Mathematica/Secure-temporary-file new file mode 120000 index 0000000000..84a6945af7 --- /dev/null +++ b/Lang/Mathematica/Secure-temporary-file @@ -0,0 +1 @@ +../../Task/Secure-temporary-file/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Self-describing-numbers b/Lang/Mathematica/Self-describing-numbers new file mode 120000 index 0000000000..7901765a47 --- /dev/null +++ b/Lang/Mathematica/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Self-referential-sequence b/Lang/Mathematica/Self-referential-sequence new file mode 120000 index 0000000000..a56d0a3fec --- /dev/null +++ b/Lang/Mathematica/Self-referential-sequence @@ -0,0 +1 @@ +../../Task/Self-referential-sequence/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Semordnilap b/Lang/Mathematica/Semordnilap new file mode 120000 index 0000000000..4c11bdebe9 --- /dev/null +++ b/Lang/Mathematica/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Send-email b/Lang/Mathematica/Send-email new file mode 120000 index 0000000000..2d181f04d0 --- /dev/null +++ b/Lang/Mathematica/Send-email @@ -0,0 +1 @@ +../../Task/Send-email/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Sequence-of-non-squares b/Lang/Mathematica/Sequence-of-non-squares new file mode 120000 index 0000000000..3277b5b3de --- /dev/null +++ b/Lang/Mathematica/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Set b/Lang/Mathematica/Set new file mode 120000 index 0000000000..ae921f2cd3 --- /dev/null +++ b/Lang/Mathematica/Set @@ -0,0 +1 @@ +../../Task/Set/Mathematica \ No newline at end of file diff --git a/Lang/Mathematica/Set-consolidation b/Lang/Mathematica/Set-consolidation new file mode 120000 index 0000000000..6be7e48f5c --- /dev/null +++ b/Lang/Mathematica/Set-consolidation @@ -0,0 +1 @@ +../../Task/Set-consolidation/Mathematica \ No newline at end of file diff --git a/Lang/Maxima/Arbitrary-precision-integers--included- b/Lang/Maxima/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..ad37d63e82 --- /dev/null +++ b/Lang/Maxima/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Arbitrary-precision-integers-included b/Lang/Maxima/Arbitrary-precision-integers-included deleted file mode 120000 index e9c03bae2c..0000000000 --- a/Lang/Maxima/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Binary-digits b/Lang/Maxima/Binary-digits new file mode 120000 index 0000000000..1dd4171586 --- /dev/null +++ b/Lang/Maxima/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Catalan-numbers b/Lang/Maxima/Catalan-numbers new file mode 120000 index 0000000000..458a81ba31 --- /dev/null +++ b/Lang/Maxima/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Copy-a-string b/Lang/Maxima/Copy-a-string new file mode 120000 index 0000000000..34df5023b0 --- /dev/null +++ b/Lang/Maxima/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Maxima \ No newline at end of file diff --git a/Lang/Maxima/N-queens-problem b/Lang/Maxima/N-queens-problem new file mode 120000 index 0000000000..239190f5ab --- /dev/null +++ b/Lang/Maxima/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Nth-root b/Lang/Maxima/Nth-root new file mode 120000 index 0000000000..878077c121 --- /dev/null +++ b/Lang/Maxima/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Numerical-integration b/Lang/Maxima/Numerical-integration new file mode 120000 index 0000000000..8f662b71b5 --- /dev/null +++ b/Lang/Maxima/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Numerical-integration-Gauss-Legendre-Quadrature b/Lang/Maxima/Numerical-integration-Gauss-Legendre-Quadrature new file mode 120000 index 0000000000..c62e258b54 --- /dev/null +++ b/Lang/Maxima/Numerical-integration-Gauss-Legendre-Quadrature @@ -0,0 +1 @@ +../../Task/Numerical-integration-Gauss-Legendre-Quadrature/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Order-two-numerical-lists b/Lang/Maxima/Order-two-numerical-lists new file mode 120000 index 0000000000..30defb322e --- /dev/null +++ b/Lang/Maxima/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Palindrome-detection b/Lang/Maxima/Palindrome-detection new file mode 120000 index 0000000000..2272fbc093 --- /dev/null +++ b/Lang/Maxima/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Pascals-triangle b/Lang/Maxima/Pascals-triangle new file mode 120000 index 0000000000..2a17396224 --- /dev/null +++ b/Lang/Maxima/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Perfect-numbers b/Lang/Maxima/Perfect-numbers new file mode 120000 index 0000000000..54077b19e3 --- /dev/null +++ b/Lang/Maxima/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Permutations b/Lang/Maxima/Permutations new file mode 120000 index 0000000000..0125e14138 --- /dev/null +++ b/Lang/Maxima/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Plot-coordinate-pairs b/Lang/Maxima/Plot-coordinate-pairs new file mode 120000 index 0000000000..b060d05be8 --- /dev/null +++ b/Lang/Maxima/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Power-set b/Lang/Maxima/Power-set new file mode 120000 index 0000000000..f852883e62 --- /dev/null +++ b/Lang/Maxima/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Prime-decomposition b/Lang/Maxima/Prime-decomposition new file mode 120000 index 0000000000..5e8106293a --- /dev/null +++ b/Lang/Maxima/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Priority-queue b/Lang/Maxima/Priority-queue new file mode 120000 index 0000000000..97efda451f --- /dev/null +++ b/Lang/Maxima/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Program-termination b/Lang/Maxima/Program-termination new file mode 120000 index 0000000000..7e81d8ac52 --- /dev/null +++ b/Lang/Maxima/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Maxima \ No newline at end of file diff --git a/Lang/Maxima/QR-decomposition b/Lang/Maxima/QR-decomposition new file mode 120000 index 0000000000..3f10815a92 --- /dev/null +++ b/Lang/Maxima/QR-decomposition @@ -0,0 +1 @@ +../../Task/QR-decomposition/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Queue-Definition b/Lang/Maxima/Queue-Definition new file mode 120000 index 0000000000..508ecfd149 --- /dev/null +++ b/Lang/Maxima/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Random-numbers b/Lang/Maxima/Random-numbers new file mode 120000 index 0000000000..039c6f9d47 --- /dev/null +++ b/Lang/Maxima/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Read-a-file-line-by-line b/Lang/Maxima/Read-a-file-line-by-line new file mode 120000 index 0000000000..e5950ef7b8 --- /dev/null +++ b/Lang/Maxima/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Reduced-row-echelon-form b/Lang/Maxima/Reduced-row-echelon-form new file mode 120000 index 0000000000..d310613389 --- /dev/null +++ b/Lang/Maxima/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Remove-duplicate-elements b/Lang/Maxima/Remove-duplicate-elements new file mode 120000 index 0000000000..3cbbd87822 --- /dev/null +++ b/Lang/Maxima/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Repeat-a-string b/Lang/Maxima/Repeat-a-string new file mode 120000 index 0000000000..37e25e92b6 --- /dev/null +++ b/Lang/Maxima/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Resistor-mesh b/Lang/Maxima/Resistor-mesh new file mode 120000 index 0000000000..09fba5b356 --- /dev/null +++ b/Lang/Maxima/Resistor-mesh @@ -0,0 +1 @@ +../../Task/Resistor-mesh/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Return-multiple-values b/Lang/Maxima/Return-multiple-values new file mode 120000 index 0000000000..82dd4ea26d --- /dev/null +++ b/Lang/Maxima/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Reverse-a-string b/Lang/Maxima/Reverse-a-string new file mode 120000 index 0000000000..b31e51fa17 --- /dev/null +++ b/Lang/Maxima/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Roots-of-a-function b/Lang/Maxima/Roots-of-a-function new file mode 120000 index 0000000000..a620eda36e --- /dev/null +++ b/Lang/Maxima/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Roots-of-a-quadratic-function b/Lang/Maxima/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..13ac86490b --- /dev/null +++ b/Lang/Maxima/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Roots-of-unity b/Lang/Maxima/Roots-of-unity new file mode 120000 index 0000000000..3ab2c49276 --- /dev/null +++ b/Lang/Maxima/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Rot-13 b/Lang/Maxima/Rot-13 new file mode 120000 index 0000000000..eb057070f7 --- /dev/null +++ b/Lang/Maxima/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Run-length-encoding b/Lang/Maxima/Run-length-encoding new file mode 120000 index 0000000000..c5ff4af5cd --- /dev/null +++ b/Lang/Maxima/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Runtime-evaluation b/Lang/Maxima/Runtime-evaluation new file mode 120000 index 0000000000..9f223b75d7 --- /dev/null +++ b/Lang/Maxima/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Sequence-of-non-squares b/Lang/Maxima/Sequence-of-non-squares new file mode 120000 index 0000000000..106fe83ec9 --- /dev/null +++ b/Lang/Maxima/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Maxima \ No newline at end of file diff --git a/Lang/Maxima/Set b/Lang/Maxima/Set new file mode 120000 index 0000000000..a41da0781d --- /dev/null +++ b/Lang/Maxima/Set @@ -0,0 +1 @@ +../../Task/Set/Maxima \ No newline at end of file diff --git a/Lang/Mercury/Binary-digits b/Lang/Mercury/Binary-digits new file mode 120000 index 0000000000..25f452e18d --- /dev/null +++ b/Lang/Mercury/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Environment-variables b/Lang/Mercury/Environment-variables new file mode 120000 index 0000000000..fe1782e101 --- /dev/null +++ b/Lang/Mercury/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Mercury \ No newline at end of file diff --git a/Lang/Mercury/OpenGL b/Lang/Mercury/OpenGL new file mode 120000 index 0000000000..f9ac5f1018 --- /dev/null +++ b/Lang/Mercury/OpenGL @@ -0,0 +1 @@ +../../Task/OpenGL/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Order-two-numerical-lists b/Lang/Mercury/Order-two-numerical-lists new file mode 120000 index 0000000000..1cccf75e7d --- /dev/null +++ b/Lang/Mercury/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Partial-function-application b/Lang/Mercury/Partial-function-application new file mode 120000 index 0000000000..04371e11ff --- /dev/null +++ b/Lang/Mercury/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Price-fraction b/Lang/Mercury/Price-fraction new file mode 120000 index 0000000000..0f1f8e9432 --- /dev/null +++ b/Lang/Mercury/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Real-constants-and-functions b/Lang/Mercury/Real-constants-and-functions new file mode 120000 index 0000000000..a484dc8f37 --- /dev/null +++ b/Lang/Mercury/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Repeat-a-string b/Lang/Mercury/Repeat-a-string new file mode 120000 index 0000000000..3fcebee45a --- /dev/null +++ b/Lang/Mercury/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Mercury \ No newline at end of file diff --git a/Lang/Mercury/Return-multiple-values b/Lang/Mercury/Return-multiple-values new file mode 120000 index 0000000000..bf38a5c053 --- /dev/null +++ b/Lang/Mercury/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Mercury \ No newline at end of file diff --git a/Lang/Mercury/SEDOLs b/Lang/Mercury/SEDOLs new file mode 120000 index 0000000000..9cee407ece --- /dev/null +++ b/Lang/Mercury/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/Mercury \ No newline at end of file diff --git a/Lang/Metafont/Copy-a-string b/Lang/Metafont/Copy-a-string new file mode 120000 index 0000000000..964f352b5f --- /dev/null +++ b/Lang/Metafont/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Dragon-curve b/Lang/Metafont/Dragon-curve new file mode 120000 index 0000000000..93b6e0365a --- /dev/null +++ b/Lang/Metafont/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Nth-root b/Lang/Metafont/Nth-root new file mode 120000 index 0000000000..4f4567507e --- /dev/null +++ b/Lang/Metafont/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Pascals-triangle b/Lang/Metafont/Pascals-triangle new file mode 120000 index 0000000000..a6eb42a32a --- /dev/null +++ b/Lang/Metafont/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Random-numbers b/Lang/Metafont/Random-numbers new file mode 120000 index 0000000000..3ea37a4d0d --- /dev/null +++ b/Lang/Metafont/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Real-constants-and-functions b/Lang/Metafont/Real-constants-and-functions new file mode 120000 index 0000000000..735f0de574 --- /dev/null +++ b/Lang/Metafont/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Metafont \ No newline at end of file diff --git a/Lang/Metafont/Runtime-evaluation-In-an-environment b/Lang/Metafont/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..f52d193f2c --- /dev/null +++ b/Lang/Metafont/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/Metafont \ No newline at end of file diff --git a/Lang/Mirah/Copy-a-string b/Lang/Mirah/Copy-a-string new file mode 120000 index 0000000000..af6a0eaff5 --- /dev/null +++ b/Lang/Mirah/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Mirah \ No newline at end of file diff --git a/Lang/Mirah/Palindrome-detection b/Lang/Mirah/Palindrome-detection new file mode 120000 index 0000000000..c2c184cf81 --- /dev/null +++ b/Lang/Mirah/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Mirah \ No newline at end of file diff --git a/Lang/Mirah/Random-numbers b/Lang/Mirah/Random-numbers new file mode 120000 index 0000000000..74c877ce4c --- /dev/null +++ b/Lang/Mirah/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Mirah \ No newline at end of file diff --git a/Lang/Mirah/Repeat-a-string b/Lang/Mirah/Repeat-a-string new file mode 120000 index 0000000000..25eaec5231 --- /dev/null +++ b/Lang/Mirah/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Mirah \ No newline at end of file diff --git a/Lang/Mirah/Reverse-a-string b/Lang/Mirah/Reverse-a-string new file mode 120000 index 0000000000..69a68db7cf --- /dev/null +++ b/Lang/Mirah/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Mirah \ No newline at end of file diff --git a/Lang/Mirah/Rot-13 b/Lang/Mirah/Rot-13 new file mode 120000 index 0000000000..19cde0ea60 --- /dev/null +++ b/Lang/Mirah/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Mirah \ No newline at end of file diff --git a/Lang/Modula-2/Guess-the-number-With-feedback--player- b/Lang/Modula-2/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..ee9f6d1ee3 --- /dev/null +++ b/Lang/Modula-2/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-2/Guess-the-number-With-feedback-player b/Lang/Modula-2/Guess-the-number-With-feedback-player deleted file mode 120000 index 264b7bb2d8..0000000000 --- a/Lang/Modula-2/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/Modula-2 \ No newline at end of file diff --git a/Lang/Modula-3/Binary-digits b/Lang/Modula-3/Binary-digits new file mode 120000 index 0000000000..00bed41238 --- /dev/null +++ b/Lang/Modula-3/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Copy-a-string b/Lang/Modula-3/Copy-a-string new file mode 120000 index 0000000000..afbbf37a49 --- /dev/null +++ b/Lang/Modula-3/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Named-parameters b/Lang/Modula-3/Named-parameters new file mode 120000 index 0000000000..57f667827a --- /dev/null +++ b/Lang/Modula-3/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Non-decimal-radices-Output b/Lang/Modula-3/Non-decimal-radices-Output new file mode 120000 index 0000000000..c2f0408245 --- /dev/null +++ b/Lang/Modula-3/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Null-object b/Lang/Modula-3/Null-object new file mode 120000 index 0000000000..545771356e --- /dev/null +++ b/Lang/Modula-3/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/One-dimensional-cellular-automata b/Lang/Modula-3/One-dimensional-cellular-automata new file mode 120000 index 0000000000..9000dfe263 --- /dev/null +++ b/Lang/Modula-3/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Palindrome-detection b/Lang/Modula-3/Palindrome-detection new file mode 120000 index 0000000000..fad335475b --- /dev/null +++ b/Lang/Modula-3/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Pointers-and-references b/Lang/Modula-3/Pointers-and-references new file mode 120000 index 0000000000..b489709709 --- /dev/null +++ b/Lang/Modula-3/Pointers-and-references @@ -0,0 +1 @@ +../../Task/Pointers-and-references/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Pythagorean-triples b/Lang/Modula-3/Pythagorean-triples new file mode 120000 index 0000000000..d28b3db3ee --- /dev/null +++ b/Lang/Modula-3/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Random-numbers b/Lang/Modula-3/Random-numbers new file mode 120000 index 0000000000..4132bfa60c --- /dev/null +++ b/Lang/Modula-3/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Real-constants-and-functions b/Lang/Modula-3/Real-constants-and-functions new file mode 120000 index 0000000000..7dbf3ac881 --- /dev/null +++ b/Lang/Modula-3/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Reverse-a-string b/Lang/Modula-3/Reverse-a-string new file mode 120000 index 0000000000..78817b96f1 --- /dev/null +++ b/Lang/Modula-3/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Roots-of-a-quadratic-function b/Lang/Modula-3/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..852dafd89e --- /dev/null +++ b/Lang/Modula-3/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Rot-13 b/Lang/Modula-3/Rot-13 new file mode 120000 index 0000000000..21430126f0 --- /dev/null +++ b/Lang/Modula-3/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/SEDOLs b/Lang/Modula-3/SEDOLs new file mode 120000 index 0000000000..e029087a2a --- /dev/null +++ b/Lang/Modula-3/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/Modula-3 \ No newline at end of file diff --git a/Lang/Modula-3/Sequence-of-non-squares b/Lang/Modula-3/Sequence-of-non-squares new file mode 120000 index 0000000000..c5835e167c --- /dev/null +++ b/Lang/Modula-3/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Modula-3 \ No newline at end of file diff --git a/Lang/NSIS/Environment-variables b/Lang/NSIS/Environment-variables new file mode 120000 index 0000000000..16a3046fb9 --- /dev/null +++ b/Lang/NSIS/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/NSIS \ No newline at end of file diff --git a/Lang/Nemerle/Copy-a-string b/Lang/Nemerle/Copy-a-string new file mode 120000 index 0000000000..18e8d21de8 --- /dev/null +++ b/Lang/Nemerle/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Nemerle \ No newline at end of file diff --git a/Lang/Nemerle/Named-parameters b/Lang/Nemerle/Named-parameters new file mode 120000 index 0000000000..ca8f248a15 --- /dev/null +++ b/Lang/Nemerle/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/Nemerle \ No newline at end of file diff --git a/Lang/Nemerle/Optional-parameters b/Lang/Nemerle/Optional-parameters new file mode 120000 index 0000000000..422241b494 --- /dev/null +++ b/Lang/Nemerle/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/Nemerle \ No newline at end of file diff --git a/Lang/Nemerle/Palindrome-detection b/Lang/Nemerle/Palindrome-detection new file mode 120000 index 0000000000..ce60fb5840 --- /dev/null +++ b/Lang/Nemerle/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Nemerle \ No newline at end of file diff --git a/Lang/Nemerle/Partial-function-application b/Lang/Nemerle/Partial-function-application new file mode 120000 index 0000000000..2162fa83d1 --- /dev/null +++ b/Lang/Nemerle/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/Nemerle \ No newline at end of file diff --git a/Lang/Nemerle/Remove-duplicate-elements b/Lang/Nemerle/Remove-duplicate-elements new file mode 120000 index 0000000000..c2b0d124a0 --- /dev/null +++ b/Lang/Nemerle/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Nemerle \ No newline at end of file diff --git a/Lang/Nemerle/Reverse-a-string b/Lang/Nemerle/Reverse-a-string new file mode 120000 index 0000000000..1e0aa54373 --- /dev/null +++ b/Lang/Nemerle/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Nemerle \ No newline at end of file diff --git a/Lang/NetLogo/Pick-random-element b/Lang/NetLogo/Pick-random-element new file mode 120000 index 0000000000..e0d08f6305 --- /dev/null +++ b/Lang/NetLogo/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/NetLogo \ No newline at end of file diff --git a/Lang/NetRexx/Arbitrary-precision-integers--included- b/Lang/NetRexx/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..4a08770f42 --- /dev/null +++ b/Lang/NetRexx/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Arbitrary-precision-integers-included b/Lang/NetRexx/Arbitrary-precision-integers-included deleted file mode 120000 index b066dca534..0000000000 --- a/Lang/NetRexx/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Binary-digits b/Lang/NetRexx/Binary-digits new file mode 120000 index 0000000000..360972b0af --- /dev/null +++ b/Lang/NetRexx/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Copy-a-string b/Lang/NetRexx/Copy-a-string new file mode 120000 index 0000000000..f3ee270271 --- /dev/null +++ b/Lang/NetRexx/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Environment-variables b/Lang/NetRexx/Environment-variables new file mode 120000 index 0000000000..87194f503c --- /dev/null +++ b/Lang/NetRexx/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Non-decimal-radices-Convert b/Lang/NetRexx/Non-decimal-radices-Convert new file mode 120000 index 0000000000..dbe4e5c1fd --- /dev/null +++ b/Lang/NetRexx/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Non-decimal-radices-Output b/Lang/NetRexx/Non-decimal-radices-Output new file mode 120000 index 0000000000..77f235398e --- /dev/null +++ b/Lang/NetRexx/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Nth-root b/Lang/NetRexx/Nth-root new file mode 120000 index 0000000000..d62e75b580 --- /dev/null +++ b/Lang/NetRexx/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Null-object b/Lang/NetRexx/Null-object new file mode 120000 index 0000000000..b89dde5617 --- /dev/null +++ b/Lang/NetRexx/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Palindrome-detection b/Lang/NetRexx/Palindrome-detection new file mode 120000 index 0000000000..a02f0a348d --- /dev/null +++ b/Lang/NetRexx/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Pangram-checker b/Lang/NetRexx/Pangram-checker new file mode 120000 index 0000000000..03feb697c4 --- /dev/null +++ b/Lang/NetRexx/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Parametrized-SQL-statement b/Lang/NetRexx/Parametrized-SQL-statement new file mode 120000 index 0000000000..54cf112f83 --- /dev/null +++ b/Lang/NetRexx/Parametrized-SQL-statement @@ -0,0 +1 @@ +../../Task/Parametrized-SQL-statement/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Parsing-RPN-calculator-algorithm b/Lang/NetRexx/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..25092b2db5 --- /dev/null +++ b/Lang/NetRexx/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Pick-random-element b/Lang/NetRexx/Pick-random-element new file mode 120000 index 0000000000..2002589982 --- /dev/null +++ b/Lang/NetRexx/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Polymorphic-copy b/Lang/NetRexx/Polymorphic-copy new file mode 120000 index 0000000000..aa2446d851 --- /dev/null +++ b/Lang/NetRexx/Polymorphic-copy @@ -0,0 +1 @@ +../../Task/Polymorphic-copy/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Polymorphism b/Lang/NetRexx/Polymorphism new file mode 120000 index 0000000000..f3ed960fbc --- /dev/null +++ b/Lang/NetRexx/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Pragmatic-directives b/Lang/NetRexx/Pragmatic-directives new file mode 120000 index 0000000000..a5bedb5b7a --- /dev/null +++ b/Lang/NetRexx/Pragmatic-directives @@ -0,0 +1 @@ +../../Task/Pragmatic-directives/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Primality-by-trial-division b/Lang/NetRexx/Primality-by-trial-division new file mode 120000 index 0000000000..5ff51f8fa9 --- /dev/null +++ b/Lang/NetRexx/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Program-name b/Lang/NetRexx/Program-name new file mode 120000 index 0000000000..5aa51b9eef --- /dev/null +++ b/Lang/NetRexx/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Program-termination b/Lang/NetRexx/Program-termination new file mode 120000 index 0000000000..0bef62fce8 --- /dev/null +++ b/Lang/NetRexx/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Queue-Definition b/Lang/NetRexx/Queue-Definition new file mode 120000 index 0000000000..2fabb0bbe6 --- /dev/null +++ b/Lang/NetRexx/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Queue-Usage b/Lang/NetRexx/Queue-Usage new file mode 120000 index 0000000000..2382a7affd --- /dev/null +++ b/Lang/NetRexx/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Random-number-generator--device- b/Lang/NetRexx/Random-number-generator--device- new file mode 120000 index 0000000000..ee00e9083e --- /dev/null +++ b/Lang/NetRexx/Random-number-generator--device- @@ -0,0 +1 @@ +../../Task/Random-number-generator--device-/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Random-numbers b/Lang/NetRexx/Random-numbers new file mode 120000 index 0000000000..a1c012b6c8 --- /dev/null +++ b/Lang/NetRexx/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Range-expansion b/Lang/NetRexx/Range-expansion new file mode 120000 index 0000000000..ed773ac648 --- /dev/null +++ b/Lang/NetRexx/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Range-extraction b/Lang/NetRexx/Range-extraction new file mode 120000 index 0000000000..0db17f8d07 --- /dev/null +++ b/Lang/NetRexx/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Read-a-file-line-by-line b/Lang/NetRexx/Read-a-file-line-by-line new file mode 120000 index 0000000000..7a93e0156b --- /dev/null +++ b/Lang/NetRexx/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Read-a-specific-line-from-a-file b/Lang/NetRexx/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..a40001f999 --- /dev/null +++ b/Lang/NetRexx/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Read-entire-file b/Lang/NetRexx/Read-entire-file new file mode 120000 index 0000000000..8b6716f0f9 --- /dev/null +++ b/Lang/NetRexx/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Real-constants-and-functions b/Lang/NetRexx/Real-constants-and-functions new file mode 120000 index 0000000000..3f30d620e6 --- /dev/null +++ b/Lang/NetRexx/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Regular-expressions b/Lang/NetRexx/Regular-expressions new file mode 120000 index 0000000000..7b148145da --- /dev/null +++ b/Lang/NetRexx/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Remove-duplicate-elements b/Lang/NetRexx/Remove-duplicate-elements new file mode 120000 index 0000000000..0153233c31 --- /dev/null +++ b/Lang/NetRexx/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Repeat-a-string b/Lang/NetRexx/Repeat-a-string new file mode 120000 index 0000000000..f355f8c125 --- /dev/null +++ b/Lang/NetRexx/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Return-multiple-values b/Lang/NetRexx/Return-multiple-values new file mode 120000 index 0000000000..4d2df2ee2b --- /dev/null +++ b/Lang/NetRexx/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Reverse-a-string b/Lang/NetRexx/Reverse-a-string new file mode 120000 index 0000000000..d78555b075 --- /dev/null +++ b/Lang/NetRexx/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Roman-numerals-Decode b/Lang/NetRexx/Roman-numerals-Decode new file mode 120000 index 0000000000..b309104114 --- /dev/null +++ b/Lang/NetRexx/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Rot-13 b/Lang/NetRexx/Rot-13 new file mode 120000 index 0000000000..77bb7c2e44 --- /dev/null +++ b/Lang/NetRexx/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/NetRexx \ No newline at end of file diff --git a/Lang/NetRexx/Semordnilap b/Lang/NetRexx/Semordnilap new file mode 120000 index 0000000000..e9d12b46ed --- /dev/null +++ b/Lang/NetRexx/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/NetRexx \ No newline at end of file diff --git a/Lang/NewLISP/Copy-a-string b/Lang/NewLISP/Copy-a-string new file mode 120000 index 0000000000..a6e3bb2fc4 --- /dev/null +++ b/Lang/NewLISP/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/NewLISP \ No newline at end of file diff --git a/Lang/NewLISP/Environment-variables b/Lang/NewLISP/Environment-variables new file mode 120000 index 0000000000..9969c0651a --- /dev/null +++ b/Lang/NewLISP/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/NewLISP \ No newline at end of file diff --git a/Lang/NewLISP/Random-numbers b/Lang/NewLISP/Random-numbers new file mode 120000 index 0000000000..ce39f2cecc --- /dev/null +++ b/Lang/NewLISP/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/NewLISP \ No newline at end of file diff --git a/Lang/NewLISP/Read-a-file-line-by-line b/Lang/NewLISP/Read-a-file-line-by-line new file mode 120000 index 0000000000..d8101a1ca1 --- /dev/null +++ b/Lang/NewLISP/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/NewLISP \ No newline at end of file diff --git a/Lang/NewLISP/Read-entire-file b/Lang/NewLISP/Read-entire-file new file mode 120000 index 0000000000..dc8e5bc286 --- /dev/null +++ b/Lang/NewLISP/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/NewLISP \ No newline at end of file diff --git a/Lang/NewLISP/Remove-duplicate-elements b/Lang/NewLISP/Remove-duplicate-elements new file mode 120000 index 0000000000..739edfe89e --- /dev/null +++ b/Lang/NewLISP/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/NewLISP \ No newline at end of file diff --git a/Lang/NewLISP/Rename-a-file b/Lang/NewLISP/Rename-a-file new file mode 120000 index 0000000000..cd15e6d9bd --- /dev/null +++ b/Lang/NewLISP/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/NewLISP \ No newline at end of file diff --git a/Lang/NewLISP/Repeat-a-string b/Lang/NewLISP/Repeat-a-string new file mode 120000 index 0000000000..aa22661fca --- /dev/null +++ b/Lang/NewLISP/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/NewLISP \ No newline at end of file diff --git a/Lang/NewLISP/Reverse-a-string b/Lang/NewLISP/Reverse-a-string new file mode 120000 index 0000000000..67249b4424 --- /dev/null +++ b/Lang/NewLISP/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/NewLISP \ No newline at end of file diff --git a/Lang/NewLISP/Send-email b/Lang/NewLISP/Send-email new file mode 120000 index 0000000000..6bfc25ec3c --- /dev/null +++ b/Lang/NewLISP/Send-email @@ -0,0 +1 @@ +../../Task/Send-email/NewLISP \ No newline at end of file diff --git a/Lang/Nial/One-dimensional-cellular-automata b/Lang/Nial/One-dimensional-cellular-automata new file mode 120000 index 0000000000..4bede1d6ea --- /dev/null +++ b/Lang/Nial/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Nial \ No newline at end of file diff --git a/Lang/Nial/Pascals-triangle b/Lang/Nial/Pascals-triangle new file mode 120000 index 0000000000..8856fed1f6 --- /dev/null +++ b/Lang/Nial/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Nial \ No newline at end of file diff --git a/Lang/Nial/Remove-duplicate-elements b/Lang/Nial/Remove-duplicate-elements new file mode 120000 index 0000000000..2f2d728dd9 --- /dev/null +++ b/Lang/Nial/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Nial \ No newline at end of file diff --git a/Lang/Nial/Reverse-a-string b/Lang/Nial/Reverse-a-string new file mode 120000 index 0000000000..629ffb8afa --- /dev/null +++ b/Lang/Nial/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Nial \ No newline at end of file diff --git a/Lang/Nimrod/One-dimensional-cellular-automata b/Lang/Nimrod/One-dimensional-cellular-automata new file mode 120000 index 0000000000..f5badb8b18 --- /dev/null +++ b/Lang/Nimrod/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Nimrod \ No newline at end of file diff --git a/Lang/Nimrod/Program-termination b/Lang/Nimrod/Program-termination new file mode 120000 index 0000000000..03aaf2377c --- /dev/null +++ b/Lang/Nimrod/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Nimrod \ No newline at end of file diff --git a/Lang/Nimrod/Read-entire-file b/Lang/Nimrod/Read-entire-file new file mode 120000 index 0000000000..ddeee23dfb --- /dev/null +++ b/Lang/Nimrod/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Nimrod \ No newline at end of file diff --git a/Lang/Nimrod/Reverse-a-string b/Lang/Nimrod/Reverse-a-string new file mode 120000 index 0000000000..6f7db44df6 --- /dev/null +++ b/Lang/Nimrod/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Nimrod \ No newline at end of file diff --git a/Lang/OCaml/Arbitrary-precision-integers--included- b/Lang/OCaml/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..1aaf5669d6 --- /dev/null +++ b/Lang/OCaml/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Arbitrary-precision-integers-included b/Lang/OCaml/Arbitrary-precision-integers-included deleted file mode 120000 index 4c6abea4f8..0000000000 --- a/Lang/OCaml/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Binary-digits b/Lang/OCaml/Binary-digits new file mode 120000 index 0000000000..406c4a7c41 --- /dev/null +++ b/Lang/OCaml/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Brownian-tree b/Lang/OCaml/Brownian-tree new file mode 120000 index 0000000000..5f1d4bd50e --- /dev/null +++ b/Lang/OCaml/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Copy-a-string b/Lang/OCaml/Copy-a-string new file mode 120000 index 0000000000..ece09c9ee4 --- /dev/null +++ b/Lang/OCaml/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Dragon-curve b/Lang/OCaml/Dragon-curve new file mode 120000 index 0000000000..6949fc94ca --- /dev/null +++ b/Lang/OCaml/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Environment-variables b/Lang/OCaml/Environment-variables new file mode 120000 index 0000000000..d1b69a1363 --- /dev/null +++ b/Lang/OCaml/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/OCaml \ No newline at end of file diff --git a/Lang/OCaml/N-queens-problem b/Lang/OCaml/N-queens-problem new file mode 120000 index 0000000000..55ad8f27a9 --- /dev/null +++ b/Lang/OCaml/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Named-parameters b/Lang/OCaml/Named-parameters new file mode 120000 index 0000000000..4e0aa3f939 --- /dev/null +++ b/Lang/OCaml/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Non-continuous-subsequences b/Lang/OCaml/Non-continuous-subsequences new file mode 120000 index 0000000000..a4a84a997a --- /dev/null +++ b/Lang/OCaml/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Non-decimal-radices-Convert b/Lang/OCaml/Non-decimal-radices-Convert new file mode 120000 index 0000000000..d26cb5646c --- /dev/null +++ b/Lang/OCaml/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Non-decimal-radices-Input b/Lang/OCaml/Non-decimal-radices-Input new file mode 120000 index 0000000000..188a6ae81b --- /dev/null +++ b/Lang/OCaml/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Non-decimal-radices-Output b/Lang/OCaml/Non-decimal-radices-Output new file mode 120000 index 0000000000..aa1718ff92 --- /dev/null +++ b/Lang/OCaml/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Nth-root b/Lang/OCaml/Nth-root new file mode 120000 index 0000000000..ab69a428ce --- /dev/null +++ b/Lang/OCaml/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Null-object b/Lang/OCaml/Null-object new file mode 120000 index 0000000000..0aec6e027f --- /dev/null +++ b/Lang/OCaml/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Number-names b/Lang/OCaml/Number-names new file mode 120000 index 0000000000..1459ee52d2 --- /dev/null +++ b/Lang/OCaml/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Number-reversal-game b/Lang/OCaml/Number-reversal-game new file mode 120000 index 0000000000..782869a1ed --- /dev/null +++ b/Lang/OCaml/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Numerical-integration b/Lang/OCaml/Numerical-integration new file mode 120000 index 0000000000..d11b7cca44 --- /dev/null +++ b/Lang/OCaml/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Numerical-integration-Gauss-Legendre-Quadrature b/Lang/OCaml/Numerical-integration-Gauss-Legendre-Quadrature new file mode 120000 index 0000000000..acffb8aa05 --- /dev/null +++ b/Lang/OCaml/Numerical-integration-Gauss-Legendre-Quadrature @@ -0,0 +1 @@ +../../Task/Numerical-integration-Gauss-Legendre-Quadrature/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Object-serialization b/Lang/OCaml/Object-serialization new file mode 120000 index 0000000000..94f321355d --- /dev/null +++ b/Lang/OCaml/Object-serialization @@ -0,0 +1 @@ +../../Task/Object-serialization/OCaml \ No newline at end of file diff --git a/Lang/OCaml/One-dimensional-cellular-automata b/Lang/OCaml/One-dimensional-cellular-automata new file mode 120000 index 0000000000..948f5b7f0a --- /dev/null +++ b/Lang/OCaml/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/OCaml \ No newline at end of file diff --git a/Lang/OCaml/One-of-n-lines-in-a-file b/Lang/OCaml/One-of-n-lines-in-a-file new file mode 120000 index 0000000000..6f56fc91b6 --- /dev/null +++ b/Lang/OCaml/One-of-n-lines-in-a-file @@ -0,0 +1 @@ +../../Task/One-of-n-lines-in-a-file/OCaml \ No newline at end of file diff --git a/Lang/OCaml/OpenGL b/Lang/OCaml/OpenGL new file mode 120000 index 0000000000..9bd26cc96f --- /dev/null +++ b/Lang/OCaml/OpenGL @@ -0,0 +1 @@ +../../Task/OpenGL/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Optional-parameters b/Lang/OCaml/Optional-parameters new file mode 120000 index 0000000000..6fbd11f20e --- /dev/null +++ b/Lang/OCaml/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Order-two-numerical-lists b/Lang/OCaml/Order-two-numerical-lists new file mode 120000 index 0000000000..e5f1a61cdc --- /dev/null +++ b/Lang/OCaml/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Palindrome-detection b/Lang/OCaml/Palindrome-detection new file mode 120000 index 0000000000..a0d49a5733 --- /dev/null +++ b/Lang/OCaml/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Pangram-checker b/Lang/OCaml/Pangram-checker new file mode 120000 index 0000000000..44b4aa1058 --- /dev/null +++ b/Lang/OCaml/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Parametric-polymorphism b/Lang/OCaml/Parametric-polymorphism new file mode 120000 index 0000000000..c6d7320d08 --- /dev/null +++ b/Lang/OCaml/Parametric-polymorphism @@ -0,0 +1 @@ +../../Task/Parametric-polymorphism/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Partial-function-application b/Lang/OCaml/Partial-function-application new file mode 120000 index 0000000000..9b4093c9f3 --- /dev/null +++ b/Lang/OCaml/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Pascals-triangle b/Lang/OCaml/Pascals-triangle new file mode 120000 index 0000000000..fb878b233f --- /dev/null +++ b/Lang/OCaml/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Pattern-matching b/Lang/OCaml/Pattern-matching new file mode 120000 index 0000000000..6daa6d1dcc --- /dev/null +++ b/Lang/OCaml/Pattern-matching @@ -0,0 +1 @@ +../../Task/Pattern-matching/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Percentage-difference-between-images b/Lang/OCaml/Percentage-difference-between-images new file mode 120000 index 0000000000..54acc58c8e --- /dev/null +++ b/Lang/OCaml/Percentage-difference-between-images @@ -0,0 +1 @@ +../../Task/Percentage-difference-between-images/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Perfect-numbers b/Lang/OCaml/Perfect-numbers new file mode 120000 index 0000000000..06ff381619 --- /dev/null +++ b/Lang/OCaml/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Permutations b/Lang/OCaml/Permutations new file mode 120000 index 0000000000..478d624579 --- /dev/null +++ b/Lang/OCaml/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Pick-random-element b/Lang/OCaml/Pick-random-element new file mode 120000 index 0000000000..c5b0c1a66a --- /dev/null +++ b/Lang/OCaml/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Playing-cards b/Lang/OCaml/Playing-cards new file mode 120000 index 0000000000..72b6d75dad --- /dev/null +++ b/Lang/OCaml/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Plot-coordinate-pairs b/Lang/OCaml/Plot-coordinate-pairs new file mode 120000 index 0000000000..63c979be56 --- /dev/null +++ b/Lang/OCaml/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Pointers-and-references b/Lang/OCaml/Pointers-and-references new file mode 120000 index 0000000000..547ace9126 --- /dev/null +++ b/Lang/OCaml/Pointers-and-references @@ -0,0 +1 @@ +../../Task/Pointers-and-references/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Polymorphic-copy b/Lang/OCaml/Polymorphic-copy new file mode 120000 index 0000000000..99dd28dd49 --- /dev/null +++ b/Lang/OCaml/Polymorphic-copy @@ -0,0 +1 @@ +../../Task/Polymorphic-copy/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Polymorphism b/Lang/OCaml/Polymorphism new file mode 120000 index 0000000000..4872b3b8a2 --- /dev/null +++ b/Lang/OCaml/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Polynomial-long-division b/Lang/OCaml/Polynomial-long-division new file mode 120000 index 0000000000..d3e0866f6b --- /dev/null +++ b/Lang/OCaml/Polynomial-long-division @@ -0,0 +1 @@ +../../Task/Polynomial-long-division/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Power-set b/Lang/OCaml/Power-set new file mode 120000 index 0000000000..7471cb9704 --- /dev/null +++ b/Lang/OCaml/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Price-fraction b/Lang/OCaml/Price-fraction new file mode 120000 index 0000000000..9e4dd2bb56 --- /dev/null +++ b/Lang/OCaml/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Primality-by-trial-division b/Lang/OCaml/Primality-by-trial-division new file mode 120000 index 0000000000..24e4309473 --- /dev/null +++ b/Lang/OCaml/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Prime-decomposition b/Lang/OCaml/Prime-decomposition new file mode 120000 index 0000000000..5a06868a37 --- /dev/null +++ b/Lang/OCaml/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Priority-queue b/Lang/OCaml/Priority-queue new file mode 120000 index 0000000000..f90ddb06eb --- /dev/null +++ b/Lang/OCaml/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Probabilistic-choice b/Lang/OCaml/Probabilistic-choice new file mode 120000 index 0000000000..8ec30cac94 --- /dev/null +++ b/Lang/OCaml/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Problem-of-Apollonius b/Lang/OCaml/Problem-of-Apollonius new file mode 120000 index 0000000000..cce2ac2069 --- /dev/null +++ b/Lang/OCaml/Problem-of-Apollonius @@ -0,0 +1 @@ +../../Task/Problem-of-Apollonius/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Program-name b/Lang/OCaml/Program-name new file mode 120000 index 0000000000..b1eebc450b --- /dev/null +++ b/Lang/OCaml/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Program-termination b/Lang/OCaml/Program-termination new file mode 120000 index 0000000000..dffb657b5a --- /dev/null +++ b/Lang/OCaml/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Pythagorean-triples b/Lang/OCaml/Pythagorean-triples new file mode 120000 index 0000000000..062948a4ee --- /dev/null +++ b/Lang/OCaml/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Quaternion-type b/Lang/OCaml/Quaternion-type new file mode 120000 index 0000000000..cc65de3875 --- /dev/null +++ b/Lang/OCaml/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Queue-Definition b/Lang/OCaml/Queue-Definition new file mode 120000 index 0000000000..21d6d83731 --- /dev/null +++ b/Lang/OCaml/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Queue-Usage b/Lang/OCaml/Queue-Usage new file mode 120000 index 0000000000..4f4c81b361 --- /dev/null +++ b/Lang/OCaml/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Random-number-generator--device- b/Lang/OCaml/Random-number-generator--device- new file mode 120000 index 0000000000..61873c5d23 --- /dev/null +++ b/Lang/OCaml/Random-number-generator--device- @@ -0,0 +1 @@ +../../Task/Random-number-generator--device-/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Random-numbers b/Lang/OCaml/Random-numbers new file mode 120000 index 0000000000..d45a7dc956 --- /dev/null +++ b/Lang/OCaml/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Range-expansion b/Lang/OCaml/Range-expansion new file mode 120000 index 0000000000..6d8429b529 --- /dev/null +++ b/Lang/OCaml/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Range-extraction b/Lang/OCaml/Range-extraction new file mode 120000 index 0000000000..b50dea6f5e --- /dev/null +++ b/Lang/OCaml/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Ray-casting-algorithm b/Lang/OCaml/Ray-casting-algorithm new file mode 120000 index 0000000000..d151e7f6e3 --- /dev/null +++ b/Lang/OCaml/Ray-casting-algorithm @@ -0,0 +1 @@ +../../Task/Ray-casting-algorithm/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Read-a-configuration-file b/Lang/OCaml/Read-a-configuration-file new file mode 120000 index 0000000000..4ab4e0e16f --- /dev/null +++ b/Lang/OCaml/Read-a-configuration-file @@ -0,0 +1 @@ +../../Task/Read-a-configuration-file/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Read-a-file-line-by-line b/Lang/OCaml/Read-a-file-line-by-line new file mode 120000 index 0000000000..dcc9edf0df --- /dev/null +++ b/Lang/OCaml/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Read-a-specific-line-from-a-file b/Lang/OCaml/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..9d73c26735 --- /dev/null +++ b/Lang/OCaml/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Read-entire-file b/Lang/OCaml/Read-entire-file new file mode 120000 index 0000000000..a9c19ffafb --- /dev/null +++ b/Lang/OCaml/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Real-constants-and-functions b/Lang/OCaml/Real-constants-and-functions new file mode 120000 index 0000000000..3d5c358ff9 --- /dev/null +++ b/Lang/OCaml/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Record-sound b/Lang/OCaml/Record-sound new file mode 120000 index 0000000000..4027bcd3e3 --- /dev/null +++ b/Lang/OCaml/Record-sound @@ -0,0 +1 @@ +../../Task/Record-sound/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Reduced-row-echelon-form b/Lang/OCaml/Reduced-row-echelon-form new file mode 120000 index 0000000000..eb87ca979d --- /dev/null +++ b/Lang/OCaml/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Regular-expressions b/Lang/OCaml/Regular-expressions new file mode 120000 index 0000000000..05da2611fe --- /dev/null +++ b/Lang/OCaml/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Remove-duplicate-elements b/Lang/OCaml/Remove-duplicate-elements new file mode 120000 index 0000000000..67db5594a3 --- /dev/null +++ b/Lang/OCaml/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Remove-lines-from-a-file b/Lang/OCaml/Remove-lines-from-a-file new file mode 120000 index 0000000000..c77e63efd9 --- /dev/null +++ b/Lang/OCaml/Remove-lines-from-a-file @@ -0,0 +1 @@ +../../Task/Remove-lines-from-a-file/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Rename-a-file b/Lang/OCaml/Rename-a-file new file mode 120000 index 0000000000..fae366f029 --- /dev/null +++ b/Lang/OCaml/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Repeat-a-string b/Lang/OCaml/Repeat-a-string new file mode 120000 index 0000000000..72b898c598 --- /dev/null +++ b/Lang/OCaml/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Return-multiple-values b/Lang/OCaml/Return-multiple-values new file mode 120000 index 0000000000..5ab8f00c3e --- /dev/null +++ b/Lang/OCaml/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Reverse-a-string b/Lang/OCaml/Reverse-a-string new file mode 120000 index 0000000000..e9c4f9fc1a --- /dev/null +++ b/Lang/OCaml/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Rock-paper-scissors b/Lang/OCaml/Rock-paper-scissors new file mode 120000 index 0000000000..35d8830268 --- /dev/null +++ b/Lang/OCaml/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Roman-numerals-Decode b/Lang/OCaml/Roman-numerals-Decode new file mode 120000 index 0000000000..4b01d246af --- /dev/null +++ b/Lang/OCaml/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Roman-numerals-Encode b/Lang/OCaml/Roman-numerals-Encode new file mode 120000 index 0000000000..33a89fa9fc --- /dev/null +++ b/Lang/OCaml/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Roots-of-a-function b/Lang/OCaml/Roots-of-a-function new file mode 120000 index 0000000000..92b46bcb71 --- /dev/null +++ b/Lang/OCaml/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Roots-of-a-quadratic-function b/Lang/OCaml/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..7b08cb8368 --- /dev/null +++ b/Lang/OCaml/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Roots-of-unity b/Lang/OCaml/Roots-of-unity new file mode 120000 index 0000000000..730d624219 --- /dev/null +++ b/Lang/OCaml/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Rosetta-Code-Count-examples b/Lang/OCaml/Rosetta-Code-Count-examples new file mode 120000 index 0000000000..2873044c05 --- /dev/null +++ b/Lang/OCaml/Rosetta-Code-Count-examples @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Count-examples/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Rosetta-Code-Fix-code-tags b/Lang/OCaml/Rosetta-Code-Fix-code-tags new file mode 120000 index 0000000000..8991da0ace --- /dev/null +++ b/Lang/OCaml/Rosetta-Code-Fix-code-tags @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Fix-code-tags/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Rot-13 b/Lang/OCaml/Rot-13 new file mode 120000 index 0000000000..f230f817eb --- /dev/null +++ b/Lang/OCaml/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Run-length-encoding b/Lang/OCaml/Run-length-encoding new file mode 120000 index 0000000000..d4cc242aed --- /dev/null +++ b/Lang/OCaml/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/OCaml \ No newline at end of file diff --git a/Lang/OCaml/S-Expressions b/Lang/OCaml/S-Expressions new file mode 120000 index 0000000000..8c03bae9a3 --- /dev/null +++ b/Lang/OCaml/S-Expressions @@ -0,0 +1 @@ +../../Task/S-Expressions/OCaml \ No newline at end of file diff --git a/Lang/OCaml/SEDOLs b/Lang/OCaml/SEDOLs new file mode 120000 index 0000000000..798d0ccc9d --- /dev/null +++ b/Lang/OCaml/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Same-Fringe b/Lang/OCaml/Same-Fringe new file mode 120000 index 0000000000..922fcef143 --- /dev/null +++ b/Lang/OCaml/Same-Fringe @@ -0,0 +1 @@ +../../Task/Same-Fringe/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Secure-temporary-file b/Lang/OCaml/Secure-temporary-file new file mode 120000 index 0000000000..c4723b9c08 --- /dev/null +++ b/Lang/OCaml/Secure-temporary-file @@ -0,0 +1 @@ +../../Task/Secure-temporary-file/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Semordnilap b/Lang/OCaml/Semordnilap new file mode 120000 index 0000000000..203354d380 --- /dev/null +++ b/Lang/OCaml/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Send-email b/Lang/OCaml/Send-email new file mode 120000 index 0000000000..65fd1836f4 --- /dev/null +++ b/Lang/OCaml/Send-email @@ -0,0 +1 @@ +../../Task/Send-email/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Sequence-of-non-squares b/Lang/OCaml/Sequence-of-non-squares new file mode 120000 index 0000000000..d4c4de306e --- /dev/null +++ b/Lang/OCaml/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Set b/Lang/OCaml/Set new file mode 120000 index 0000000000..90ef0bcb30 --- /dev/null +++ b/Lang/OCaml/Set @@ -0,0 +1 @@ +../../Task/Set/OCaml \ No newline at end of file diff --git a/Lang/OCaml/Set-consolidation b/Lang/OCaml/Set-consolidation new file mode 120000 index 0000000000..f7613f1b53 --- /dev/null +++ b/Lang/OCaml/Set-consolidation @@ -0,0 +1 @@ +../../Task/Set-consolidation/OCaml \ No newline at end of file diff --git a/Lang/Oberon-2/Copy-a-string b/Lang/Oberon-2/Copy-a-string new file mode 120000 index 0000000000..8fce55e955 --- /dev/null +++ b/Lang/Oberon-2/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Oberon-2 \ No newline at end of file diff --git a/Lang/Oberon-2/Range-expansion b/Lang/Oberon-2/Range-expansion new file mode 120000 index 0000000000..db47afb7df --- /dev/null +++ b/Lang/Oberon-2/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/Oberon-2 \ No newline at end of file diff --git a/Lang/Oberon-2/Range-extraction b/Lang/Oberon-2/Range-extraction new file mode 120000 index 0000000000..3488504655 --- /dev/null +++ b/Lang/Oberon-2/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/Oberon-2 \ No newline at end of file diff --git a/Lang/Objeck/Binary-digits b/Lang/Objeck/Binary-digits new file mode 120000 index 0000000000..25222f28a6 --- /dev/null +++ b/Lang/Objeck/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Copy-a-string b/Lang/Objeck/Copy-a-string new file mode 120000 index 0000000000..8b3c320c30 --- /dev/null +++ b/Lang/Objeck/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Objeck \ No newline at end of file diff --git a/Lang/Objeck/N-queens-problem b/Lang/Objeck/N-queens-problem new file mode 120000 index 0000000000..e3055dd754 --- /dev/null +++ b/Lang/Objeck/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Null-object b/Lang/Objeck/Null-object new file mode 120000 index 0000000000..56464fe683 --- /dev/null +++ b/Lang/Objeck/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Number-names b/Lang/Objeck/Number-names new file mode 120000 index 0000000000..16e016721a --- /dev/null +++ b/Lang/Objeck/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Object-serialization b/Lang/Objeck/Object-serialization new file mode 120000 index 0000000000..1f5db8a905 --- /dev/null +++ b/Lang/Objeck/Object-serialization @@ -0,0 +1 @@ +../../Task/Object-serialization/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Palindrome-detection b/Lang/Objeck/Palindrome-detection new file mode 120000 index 0000000000..1271ea2923 --- /dev/null +++ b/Lang/Objeck/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Pangram-checker b/Lang/Objeck/Pangram-checker new file mode 120000 index 0000000000..94ff9757e3 --- /dev/null +++ b/Lang/Objeck/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Parametrized-SQL-statement b/Lang/Objeck/Parametrized-SQL-statement new file mode 120000 index 0000000000..33236fae8b --- /dev/null +++ b/Lang/Objeck/Parametrized-SQL-statement @@ -0,0 +1 @@ +../../Task/Parametrized-SQL-statement/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Parsing-RPN-calculator-algorithm b/Lang/Objeck/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..a32d4c397d --- /dev/null +++ b/Lang/Objeck/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Perfect-numbers b/Lang/Objeck/Perfect-numbers new file mode 120000 index 0000000000..9b742aa149 --- /dev/null +++ b/Lang/Objeck/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Pick-random-element b/Lang/Objeck/Pick-random-element new file mode 120000 index 0000000000..5bd77e3cb1 --- /dev/null +++ b/Lang/Objeck/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Polymorphism b/Lang/Objeck/Polymorphism new file mode 120000 index 0000000000..83ce87d300 --- /dev/null +++ b/Lang/Objeck/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Primality-by-trial-division b/Lang/Objeck/Primality-by-trial-division new file mode 120000 index 0000000000..4e99e79942 --- /dev/null +++ b/Lang/Objeck/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Program-termination b/Lang/Objeck/Program-termination new file mode 120000 index 0000000000..55c5c2073e --- /dev/null +++ b/Lang/Objeck/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Queue-Usage b/Lang/Objeck/Queue-Usage new file mode 120000 index 0000000000..c929be7210 --- /dev/null +++ b/Lang/Objeck/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/Objeck \ No newline at end of file diff --git a/Lang/Objeck/RIPEMD-160 b/Lang/Objeck/RIPEMD-160 new file mode 120000 index 0000000000..ea55e2b479 --- /dev/null +++ b/Lang/Objeck/RIPEMD-160 @@ -0,0 +1 @@ +../../Task/RIPEMD-160/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Random-numbers b/Lang/Objeck/Random-numbers new file mode 120000 index 0000000000..74b6a12c18 --- /dev/null +++ b/Lang/Objeck/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Read-a-file-line-by-line b/Lang/Objeck/Read-a-file-line-by-line new file mode 120000 index 0000000000..8da645e450 --- /dev/null +++ b/Lang/Objeck/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Read-entire-file b/Lang/Objeck/Read-entire-file new file mode 120000 index 0000000000..b741f397ee --- /dev/null +++ b/Lang/Objeck/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Real-constants-and-functions b/Lang/Objeck/Real-constants-and-functions new file mode 120000 index 0000000000..1960f659ca --- /dev/null +++ b/Lang/Objeck/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Reduced-row-echelon-form b/Lang/Objeck/Reduced-row-echelon-form new file mode 120000 index 0000000000..787d6ac745 --- /dev/null +++ b/Lang/Objeck/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Regular-expressions b/Lang/Objeck/Regular-expressions new file mode 120000 index 0000000000..a13818044c --- /dev/null +++ b/Lang/Objeck/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Remove-duplicate-elements b/Lang/Objeck/Remove-duplicate-elements new file mode 120000 index 0000000000..5ac44cf360 --- /dev/null +++ b/Lang/Objeck/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Rename-a-file b/Lang/Objeck/Rename-a-file new file mode 120000 index 0000000000..ec1b8f0aa4 --- /dev/null +++ b/Lang/Objeck/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Repeat-a-string b/Lang/Objeck/Repeat-a-string new file mode 120000 index 0000000000..ad9a75c78b --- /dev/null +++ b/Lang/Objeck/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Reverse-a-string b/Lang/Objeck/Reverse-a-string new file mode 120000 index 0000000000..50eb1719ec --- /dev/null +++ b/Lang/Objeck/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Roman-numerals-Encode b/Lang/Objeck/Roman-numerals-Encode new file mode 120000 index 0000000000..544d64421d --- /dev/null +++ b/Lang/Objeck/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Roots-of-a-function b/Lang/Objeck/Roots-of-a-function new file mode 120000 index 0000000000..bd880ddd2a --- /dev/null +++ b/Lang/Objeck/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/Objeck \ No newline at end of file diff --git a/Lang/Objeck/Rot-13 b/Lang/Objeck/Rot-13 new file mode 120000 index 0000000000..8b898bbaf9 --- /dev/null +++ b/Lang/Objeck/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Objeck \ No newline at end of file diff --git a/Lang/Objective-C/Copy-a-string b/Lang/Objective-C/Copy-a-string new file mode 120000 index 0000000000..9050eedcfd --- /dev/null +++ b/Lang/Objective-C/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Objective-C \ No newline at end of file diff --git a/Lang/Objective-C/Environment-variables b/Lang/Objective-C/Environment-variables new file mode 120000 index 0000000000..6c30f11fc9 --- /dev/null +++ b/Lang/Objective-C/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Objective-C \ No newline at end of file diff --git a/Lang/Objective-C/Guess-the-number-With-feedback--player- b/Lang/Objective-C/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..6d4f15408f --- /dev/null +++ b/Lang/Objective-C/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/Objective-C \ No newline at end of file diff --git a/Lang/Objective-C/Guess-the-number-With-feedback-player b/Lang/Objective-C/Guess-the-number-With-feedback-player deleted file mode 120000 index 3ca0814c0e..0000000000 --- a/Lang/Objective-C/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/Objective-C \ No newline at end of file diff --git a/Lang/Objective-C/Named-parameters b/Lang/Objective-C/Named-parameters new file mode 120000 index 0000000000..4969e50b3c --- /dev/null +++ b/Lang/Objective-C/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/Objective-C \ No newline at end of file diff --git a/Lang/Objective-C/Null-object b/Lang/Objective-C/Null-object new file mode 120000 index 0000000000..ec9c38e05b --- /dev/null +++ b/Lang/Objective-C/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Objective-C \ No newline at end of file diff --git a/Lang/Objective-C/Object-serialization b/Lang/Objective-C/Object-serialization new file mode 120000 index 0000000000..3bdc4edede --- /dev/null +++ b/Lang/Objective-C/Object-serialization @@ -0,0 +1 @@ +../../Task/Object-serialization/Objective-C \ No newline at end of file diff --git a/Lang/Objective-C/Optional-parameters b/Lang/Objective-C/Optional-parameters new file mode 120000 index 0000000000..846bac13d3 --- /dev/null +++ b/Lang/Objective-C/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/Objective-C \ No newline at end of file diff --git a/Lang/Objective-C/Polymorphic-copy b/Lang/Objective-C/Polymorphic-copy new file mode 120000 index 0000000000..1b9cae3fb5 --- /dev/null +++ b/Lang/Objective-C/Polymorphic-copy @@ -0,0 +1 @@ +../../Task/Polymorphic-copy/Objective-C \ No newline at end of file diff --git a/Lang/Objective-C/Polymorphism b/Lang/Objective-C/Polymorphism new file mode 120000 index 0000000000..272ddb11ff --- /dev/null +++ b/Lang/Objective-C/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/Objective-C \ No newline at end of file diff --git a/Lang/Objective-C/Power-set b/Lang/Objective-C/Power-set new file mode 120000 index 0000000000..955b533dcb --- /dev/null +++ b/Lang/Objective-C/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Objective-C \ No newline at end of file diff --git a/Lang/Objective-C/Priority-queue b/Lang/Objective-C/Priority-queue new file mode 120000 index 0000000000..ee577189bd --- /dev/null +++ b/Lang/Objective-C/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/Objective-C \ No newline at end of file diff --git a/Lang/Objective-C/Program-name b/Lang/Objective-C/Program-name new file mode 120000 index 0000000000..7d933b6219 --- /dev/null +++ b/Lang/Objective-C/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Objective-C \ No newline at end of file diff --git a/Lang/Objective-C/Read-a-file-line-by-line b/Lang/Objective-C/Read-a-file-line-by-line new file mode 120000 index 0000000000..5f7e86a83e --- /dev/null +++ b/Lang/Objective-C/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Objective-C \ No newline at end of file diff --git a/Lang/Objective-C/Read-entire-file b/Lang/Objective-C/Read-entire-file new file mode 120000 index 0000000000..362232d748 --- /dev/null +++ b/Lang/Objective-C/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Objective-C \ No newline at end of file diff --git a/Lang/Objective-C/Regular-expressions b/Lang/Objective-C/Regular-expressions new file mode 120000 index 0000000000..edef7f7153 --- /dev/null +++ b/Lang/Objective-C/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Objective-C \ No newline at end of file diff --git a/Lang/Objective-C/Remove-duplicate-elements b/Lang/Objective-C/Remove-duplicate-elements new file mode 120000 index 0000000000..9d546687b6 --- /dev/null +++ b/Lang/Objective-C/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Objective-C \ No newline at end of file diff --git a/Lang/Objective-C/Rename-a-file b/Lang/Objective-C/Rename-a-file new file mode 120000 index 0000000000..d8d6a7467e --- /dev/null +++ b/Lang/Objective-C/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Objective-C \ No newline at end of file diff --git a/Lang/Objective-C/Repeat-a-string b/Lang/Objective-C/Repeat-a-string new file mode 120000 index 0000000000..b35a415239 --- /dev/null +++ b/Lang/Objective-C/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Objective-C \ No newline at end of file diff --git a/Lang/Objective-C/Respond-to-an-unknown-method-call b/Lang/Objective-C/Respond-to-an-unknown-method-call new file mode 120000 index 0000000000..d79ed320f7 --- /dev/null +++ b/Lang/Objective-C/Respond-to-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Respond-to-an-unknown-method-call/Objective-C \ No newline at end of file diff --git a/Lang/Objective-C/Reverse-a-string b/Lang/Objective-C/Reverse-a-string new file mode 120000 index 0000000000..97ed95a319 --- /dev/null +++ b/Lang/Objective-C/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Objective-C \ No newline at end of file diff --git a/Lang/Objective-C/Send-an-unknown-method-call b/Lang/Objective-C/Send-an-unknown-method-call new file mode 120000 index 0000000000..d764ffbc62 --- /dev/null +++ b/Lang/Objective-C/Send-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Send-an-unknown-method-call/Objective-C \ No newline at end of file diff --git a/Lang/Objective-C/Set b/Lang/Objective-C/Set new file mode 120000 index 0000000000..58b42165f3 --- /dev/null +++ b/Lang/Objective-C/Set @@ -0,0 +1 @@ +../../Task/Set/Objective-C \ No newline at end of file diff --git a/Lang/Octave/Brownian-tree b/Lang/Octave/Brownian-tree new file mode 120000 index 0000000000..f853b0fa2c --- /dev/null +++ b/Lang/Octave/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/Octave \ No newline at end of file diff --git a/Lang/Octave/Copy-a-string b/Lang/Octave/Copy-a-string new file mode 120000 index 0000000000..93fe2a8f6a --- /dev/null +++ b/Lang/Octave/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Octave \ No newline at end of file diff --git a/Lang/Octave/Nth-root b/Lang/Octave/Nth-root new file mode 120000 index 0000000000..7edbb2df62 --- /dev/null +++ b/Lang/Octave/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Octave \ No newline at end of file diff --git a/Lang/Octave/Palindrome-detection b/Lang/Octave/Palindrome-detection new file mode 120000 index 0000000000..3390059ea6 --- /dev/null +++ b/Lang/Octave/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Octave \ No newline at end of file diff --git a/Lang/Octave/Pascals-triangle b/Lang/Octave/Pascals-triangle new file mode 120000 index 0000000000..2bb28d5a0f --- /dev/null +++ b/Lang/Octave/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Octave \ No newline at end of file diff --git a/Lang/Octave/Plot-coordinate-pairs b/Lang/Octave/Plot-coordinate-pairs new file mode 120000 index 0000000000..27a430790d --- /dev/null +++ b/Lang/Octave/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/Octave \ No newline at end of file diff --git a/Lang/Octave/Polynomial-long-division b/Lang/Octave/Polynomial-long-division new file mode 120000 index 0000000000..e69ecc9892 --- /dev/null +++ b/Lang/Octave/Polynomial-long-division @@ -0,0 +1 @@ +../../Task/Polynomial-long-division/Octave \ No newline at end of file diff --git a/Lang/Octave/Polynomial-regression b/Lang/Octave/Polynomial-regression new file mode 120000 index 0000000000..346482ce64 --- /dev/null +++ b/Lang/Octave/Polynomial-regression @@ -0,0 +1 @@ +../../Task/Polynomial-regression/Octave \ No newline at end of file diff --git a/Lang/Octave/Primality-by-trial-division b/Lang/Octave/Primality-by-trial-division new file mode 120000 index 0000000000..b1e3b5018f --- /dev/null +++ b/Lang/Octave/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Octave \ No newline at end of file diff --git a/Lang/Octave/Prime-decomposition b/Lang/Octave/Prime-decomposition new file mode 120000 index 0000000000..1022fc4387 --- /dev/null +++ b/Lang/Octave/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Octave \ No newline at end of file diff --git a/Lang/Octave/Program-name b/Lang/Octave/Program-name new file mode 120000 index 0000000000..05ec008353 --- /dev/null +++ b/Lang/Octave/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Octave \ No newline at end of file diff --git a/Lang/Octave/Random-numbers b/Lang/Octave/Random-numbers new file mode 120000 index 0000000000..6faecd9809 --- /dev/null +++ b/Lang/Octave/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Octave \ No newline at end of file diff --git a/Lang/Octave/Real-constants-and-functions b/Lang/Octave/Real-constants-and-functions new file mode 120000 index 0000000000..6fdee1fe01 --- /dev/null +++ b/Lang/Octave/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Octave \ No newline at end of file diff --git a/Lang/Octave/Reduced-row-echelon-form b/Lang/Octave/Reduced-row-echelon-form new file mode 120000 index 0000000000..81dbbde0b8 --- /dev/null +++ b/Lang/Octave/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/Octave \ No newline at end of file diff --git a/Lang/Octave/Remove-duplicate-elements b/Lang/Octave/Remove-duplicate-elements new file mode 120000 index 0000000000..19f0135ce7 --- /dev/null +++ b/Lang/Octave/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Octave \ No newline at end of file diff --git a/Lang/Octave/Rename-a-file b/Lang/Octave/Rename-a-file new file mode 120000 index 0000000000..cf613e112b --- /dev/null +++ b/Lang/Octave/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Octave \ No newline at end of file diff --git a/Lang/Octave/Reverse-a-string b/Lang/Octave/Reverse-a-string new file mode 120000 index 0000000000..960e49a85e --- /dev/null +++ b/Lang/Octave/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Octave \ No newline at end of file diff --git a/Lang/Octave/Roots-of-a-function b/Lang/Octave/Roots-of-a-function new file mode 120000 index 0000000000..50bf50f963 --- /dev/null +++ b/Lang/Octave/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/Octave \ No newline at end of file diff --git a/Lang/Octave/Roots-of-unity b/Lang/Octave/Roots-of-unity new file mode 120000 index 0000000000..9a6efa548a --- /dev/null +++ b/Lang/Octave/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/Octave \ No newline at end of file diff --git a/Lang/Octave/Runtime-evaluation-In-an-environment b/Lang/Octave/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..f6e9b92036 --- /dev/null +++ b/Lang/Octave/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/Octave \ No newline at end of file diff --git a/Lang/Octave/Secure-temporary-file b/Lang/Octave/Secure-temporary-file new file mode 120000 index 0000000000..20133a3f82 --- /dev/null +++ b/Lang/Octave/Secure-temporary-file @@ -0,0 +1 @@ +../../Task/Secure-temporary-file/Octave \ No newline at end of file diff --git a/Lang/OpenEdge-Progress/Repeat-a-string b/Lang/OpenEdge-Progress/Repeat-a-string new file mode 120000 index 0000000000..e4812304fd --- /dev/null +++ b/Lang/OpenEdge-Progress/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/OpenEdge-Progress \ No newline at end of file diff --git a/Lang/OpenEdge-Progress/Reverse-a-string b/Lang/OpenEdge-Progress/Reverse-a-string new file mode 120000 index 0000000000..b7609f2984 --- /dev/null +++ b/Lang/OpenEdge-Progress/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/OpenEdge-Progress \ No newline at end of file diff --git a/Lang/OpenEdge-Progress/Roman-numerals-Encode b/Lang/OpenEdge-Progress/Roman-numerals-Encode new file mode 120000 index 0000000000..e1d77942cf --- /dev/null +++ b/Lang/OpenEdge-Progress/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/OpenEdge-Progress \ No newline at end of file diff --git a/Lang/Order/Partial-function-application b/Lang/Order/Partial-function-application new file mode 120000 index 0000000000..cfd956be31 --- /dev/null +++ b/Lang/Order/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/Order \ No newline at end of file diff --git a/Lang/Order/Program-name b/Lang/Order/Program-name new file mode 120000 index 0000000000..db14f65445 --- /dev/null +++ b/Lang/Order/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Order \ No newline at end of file diff --git a/Lang/OxygenBasic/Binary-digits b/Lang/OxygenBasic/Binary-digits new file mode 120000 index 0000000000..c04d5f1e2a --- /dev/null +++ b/Lang/OxygenBasic/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/OxygenBasic \ No newline at end of file diff --git a/Lang/OxygenBasic/Copy-a-string b/Lang/OxygenBasic/Copy-a-string new file mode 120000 index 0000000000..92ffce9c79 --- /dev/null +++ b/Lang/OxygenBasic/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/OxygenBasic \ No newline at end of file diff --git a/Lang/OxygenBasic/OpenGL b/Lang/OxygenBasic/OpenGL new file mode 120000 index 0000000000..5cef9ddf81 --- /dev/null +++ b/Lang/OxygenBasic/OpenGL @@ -0,0 +1 @@ +../../Task/OpenGL/OxygenBasic \ No newline at end of file diff --git a/Lang/OxygenBasic/Parallel-calculations b/Lang/OxygenBasic/Parallel-calculations new file mode 120000 index 0000000000..7e68ce8fbe --- /dev/null +++ b/Lang/OxygenBasic/Parallel-calculations @@ -0,0 +1 @@ +../../Task/Parallel-calculations/OxygenBasic \ No newline at end of file diff --git a/Lang/OxygenBasic/Polymorphic-copy b/Lang/OxygenBasic/Polymorphic-copy new file mode 120000 index 0000000000..1df9c7c057 --- /dev/null +++ b/Lang/OxygenBasic/Polymorphic-copy @@ -0,0 +1 @@ +../../Task/Polymorphic-copy/OxygenBasic \ No newline at end of file diff --git a/Lang/OxygenBasic/Polymorphism b/Lang/OxygenBasic/Polymorphism new file mode 120000 index 0000000000..7ddf47e79b --- /dev/null +++ b/Lang/OxygenBasic/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/OxygenBasic \ No newline at end of file diff --git a/Lang/OxygenBasic/Queue-Definition b/Lang/OxygenBasic/Queue-Definition new file mode 120000 index 0000000000..0c4ea7e0f6 --- /dev/null +++ b/Lang/OxygenBasic/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/OxygenBasic \ No newline at end of file diff --git a/Lang/OxygenBasic/Range-extraction b/Lang/OxygenBasic/Range-extraction new file mode 120000 index 0000000000..baa8866b44 --- /dev/null +++ b/Lang/OxygenBasic/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/OxygenBasic \ No newline at end of file diff --git a/Lang/OxygenBasic/Rate-counter b/Lang/OxygenBasic/Rate-counter new file mode 120000 index 0000000000..d50165dc49 --- /dev/null +++ b/Lang/OxygenBasic/Rate-counter @@ -0,0 +1 @@ +../../Task/Rate-counter/OxygenBasic \ No newline at end of file diff --git a/Lang/OxygenBasic/Read-a-file-line-by-line b/Lang/OxygenBasic/Read-a-file-line-by-line new file mode 120000 index 0000000000..b20c5ef702 --- /dev/null +++ b/Lang/OxygenBasic/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/OxygenBasic \ No newline at end of file diff --git a/Lang/OxygenBasic/Repeat-a-string b/Lang/OxygenBasic/Repeat-a-string new file mode 120000 index 0000000000..b1343b72e0 --- /dev/null +++ b/Lang/OxygenBasic/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/OxygenBasic \ No newline at end of file diff --git a/Lang/OxygenBasic/Return-multiple-values b/Lang/OxygenBasic/Return-multiple-values new file mode 120000 index 0000000000..ef52fa1c7b --- /dev/null +++ b/Lang/OxygenBasic/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/OxygenBasic \ No newline at end of file diff --git a/Lang/OxygenBasic/Reverse-a-string b/Lang/OxygenBasic/Reverse-a-string new file mode 120000 index 0000000000..03797bf999 --- /dev/null +++ b/Lang/OxygenBasic/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/OxygenBasic \ No newline at end of file diff --git a/Lang/OxygenBasic/Runtime-evaluation b/Lang/OxygenBasic/Runtime-evaluation new file mode 120000 index 0000000000..bf795bda06 --- /dev/null +++ b/Lang/OxygenBasic/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/OxygenBasic \ No newline at end of file diff --git a/Lang/Oxygene/Regular-expressions b/Lang/Oxygene/Regular-expressions new file mode 120000 index 0000000000..0234c166a5 --- /dev/null +++ b/Lang/Oxygene/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Oxygene \ No newline at end of file diff --git a/Lang/Oz/Arbitrary-precision-integers--included- b/Lang/Oz/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..9aa8dc7b23 --- /dev/null +++ b/Lang/Oz/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Oz \ No newline at end of file diff --git a/Lang/Oz/Arbitrary-precision-integers-included b/Lang/Oz/Arbitrary-precision-integers-included deleted file mode 120000 index 364cdd4377..0000000000 --- a/Lang/Oz/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Oz \ No newline at end of file diff --git a/Lang/Oz/Environment-variables b/Lang/Oz/Environment-variables new file mode 120000 index 0000000000..d86420142f --- /dev/null +++ b/Lang/Oz/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Oz \ No newline at end of file diff --git a/Lang/Oz/N-queens-problem b/Lang/Oz/N-queens-problem new file mode 120000 index 0000000000..aafa4d1e18 --- /dev/null +++ b/Lang/Oz/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Oz \ No newline at end of file diff --git a/Lang/Oz/Named-parameters b/Lang/Oz/Named-parameters new file mode 120000 index 0000000000..1ca861888b --- /dev/null +++ b/Lang/Oz/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/Oz \ No newline at end of file diff --git a/Lang/Oz/Non-continuous-subsequences b/Lang/Oz/Non-continuous-subsequences new file mode 120000 index 0000000000..43049961fd --- /dev/null +++ b/Lang/Oz/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/Oz \ No newline at end of file diff --git a/Lang/Oz/Non-decimal-radices-Input b/Lang/Oz/Non-decimal-radices-Input new file mode 120000 index 0000000000..792c85db1e --- /dev/null +++ b/Lang/Oz/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/Oz \ No newline at end of file diff --git a/Lang/Oz/Nth-root b/Lang/Oz/Nth-root new file mode 120000 index 0000000000..f75635e149 --- /dev/null +++ b/Lang/Oz/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Oz \ No newline at end of file diff --git a/Lang/Oz/Null-object b/Lang/Oz/Null-object new file mode 120000 index 0000000000..e8699e742a --- /dev/null +++ b/Lang/Oz/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Oz \ No newline at end of file diff --git a/Lang/Oz/Number-reversal-game b/Lang/Oz/Number-reversal-game new file mode 120000 index 0000000000..cb6ef8b7ee --- /dev/null +++ b/Lang/Oz/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/Oz \ No newline at end of file diff --git a/Lang/Oz/One-dimensional-cellular-automata b/Lang/Oz/One-dimensional-cellular-automata new file mode 120000 index 0000000000..b41c7ed745 --- /dev/null +++ b/Lang/Oz/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Oz \ No newline at end of file diff --git a/Lang/Oz/Optional-parameters b/Lang/Oz/Optional-parameters new file mode 120000 index 0000000000..15f3a9f05c --- /dev/null +++ b/Lang/Oz/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/Oz \ No newline at end of file diff --git a/Lang/Oz/Palindrome-detection b/Lang/Oz/Palindrome-detection new file mode 120000 index 0000000000..5c3210b19c --- /dev/null +++ b/Lang/Oz/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Oz \ No newline at end of file diff --git a/Lang/Oz/Pangram-checker b/Lang/Oz/Pangram-checker new file mode 120000 index 0000000000..7118309971 --- /dev/null +++ b/Lang/Oz/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Oz \ No newline at end of file diff --git a/Lang/Oz/Pascals-triangle b/Lang/Oz/Pascals-triangle new file mode 120000 index 0000000000..0ce8a156e7 --- /dev/null +++ b/Lang/Oz/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Oz \ No newline at end of file diff --git a/Lang/Oz/Pascals-triangle-Puzzle b/Lang/Oz/Pascals-triangle-Puzzle new file mode 120000 index 0000000000..80c14731d6 --- /dev/null +++ b/Lang/Oz/Pascals-triangle-Puzzle @@ -0,0 +1 @@ +../../Task/Pascals-triangle-Puzzle/Oz \ No newline at end of file diff --git a/Lang/Oz/Pattern-matching b/Lang/Oz/Pattern-matching new file mode 120000 index 0000000000..cb72a530a7 --- /dev/null +++ b/Lang/Oz/Pattern-matching @@ -0,0 +1 @@ +../../Task/Pattern-matching/Oz \ No newline at end of file diff --git a/Lang/Oz/Perfect-numbers b/Lang/Oz/Perfect-numbers new file mode 120000 index 0000000000..7138090338 --- /dev/null +++ b/Lang/Oz/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Oz \ No newline at end of file diff --git a/Lang/Oz/Polymorphic-copy b/Lang/Oz/Polymorphic-copy new file mode 120000 index 0000000000..d6947a27a9 --- /dev/null +++ b/Lang/Oz/Polymorphic-copy @@ -0,0 +1 @@ +../../Task/Polymorphic-copy/Oz \ No newline at end of file diff --git a/Lang/Oz/Polymorphism b/Lang/Oz/Polymorphism new file mode 120000 index 0000000000..2889966622 --- /dev/null +++ b/Lang/Oz/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/Oz \ No newline at end of file diff --git a/Lang/Oz/Power-set b/Lang/Oz/Power-set new file mode 120000 index 0000000000..5f481e8172 --- /dev/null +++ b/Lang/Oz/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Oz \ No newline at end of file diff --git a/Lang/Oz/Price-fraction b/Lang/Oz/Price-fraction new file mode 120000 index 0000000000..c77edcf842 --- /dev/null +++ b/Lang/Oz/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Oz \ No newline at end of file diff --git a/Lang/Oz/Program-termination b/Lang/Oz/Program-termination new file mode 120000 index 0000000000..689efadec5 --- /dev/null +++ b/Lang/Oz/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Oz \ No newline at end of file diff --git a/Lang/Oz/Queue-Definition b/Lang/Oz/Queue-Definition new file mode 120000 index 0000000000..0263455588 --- /dev/null +++ b/Lang/Oz/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/Oz \ No newline at end of file diff --git a/Lang/Oz/Queue-Usage b/Lang/Oz/Queue-Usage new file mode 120000 index 0000000000..ebcd46f05f --- /dev/null +++ b/Lang/Oz/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/Oz \ No newline at end of file diff --git a/Lang/Oz/Range-expansion b/Lang/Oz/Range-expansion new file mode 120000 index 0000000000..84eb1aa3b2 --- /dev/null +++ b/Lang/Oz/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/Oz \ No newline at end of file diff --git a/Lang/Oz/Range-extraction b/Lang/Oz/Range-extraction new file mode 120000 index 0000000000..3cf4eefc3d --- /dev/null +++ b/Lang/Oz/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/Oz \ No newline at end of file diff --git a/Lang/Oz/Read-entire-file b/Lang/Oz/Read-entire-file new file mode 120000 index 0000000000..28e03ba189 --- /dev/null +++ b/Lang/Oz/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Oz \ No newline at end of file diff --git a/Lang/Oz/Real-constants-and-functions b/Lang/Oz/Real-constants-and-functions new file mode 120000 index 0000000000..663f0c330b --- /dev/null +++ b/Lang/Oz/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Oz \ No newline at end of file diff --git a/Lang/Oz/Regular-expressions b/Lang/Oz/Regular-expressions new file mode 120000 index 0000000000..b27a711e2a --- /dev/null +++ b/Lang/Oz/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Oz \ No newline at end of file diff --git a/Lang/Oz/Remove-duplicate-elements b/Lang/Oz/Remove-duplicate-elements new file mode 120000 index 0000000000..26cd3a4269 --- /dev/null +++ b/Lang/Oz/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Oz \ No newline at end of file diff --git a/Lang/Oz/Rendezvous b/Lang/Oz/Rendezvous new file mode 120000 index 0000000000..de139efbc1 --- /dev/null +++ b/Lang/Oz/Rendezvous @@ -0,0 +1 @@ +../../Task/Rendezvous/Oz \ No newline at end of file diff --git a/Lang/Oz/Repeat-a-string b/Lang/Oz/Repeat-a-string new file mode 120000 index 0000000000..9b5ce948a4 --- /dev/null +++ b/Lang/Oz/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Oz \ No newline at end of file diff --git a/Lang/Oz/Respond-to-an-unknown-method-call b/Lang/Oz/Respond-to-an-unknown-method-call new file mode 120000 index 0000000000..a09d64d466 --- /dev/null +++ b/Lang/Oz/Respond-to-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Respond-to-an-unknown-method-call/Oz \ No newline at end of file diff --git a/Lang/Oz/Reverse-a-string b/Lang/Oz/Reverse-a-string new file mode 120000 index 0000000000..976170e0c3 --- /dev/null +++ b/Lang/Oz/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Oz \ No newline at end of file diff --git a/Lang/Oz/Roman-numerals-Encode b/Lang/Oz/Roman-numerals-Encode new file mode 120000 index 0000000000..c409756e7d --- /dev/null +++ b/Lang/Oz/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Oz \ No newline at end of file diff --git a/Lang/Oz/Rosetta-Code-Count-examples b/Lang/Oz/Rosetta-Code-Count-examples new file mode 120000 index 0000000000..777776db5b --- /dev/null +++ b/Lang/Oz/Rosetta-Code-Count-examples @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Count-examples/Oz \ No newline at end of file diff --git a/Lang/Oz/Rosetta-Code-Find-unimplemented-tasks b/Lang/Oz/Rosetta-Code-Find-unimplemented-tasks new file mode 120000 index 0000000000..0f47412111 --- /dev/null +++ b/Lang/Oz/Rosetta-Code-Find-unimplemented-tasks @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Find-unimplemented-tasks/Oz \ No newline at end of file diff --git a/Lang/Oz/Rosetta-Code-Rank-languages-by-popularity b/Lang/Oz/Rosetta-Code-Rank-languages-by-popularity new file mode 120000 index 0000000000..e6024d2faa --- /dev/null +++ b/Lang/Oz/Rosetta-Code-Rank-languages-by-popularity @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-popularity/Oz \ No newline at end of file diff --git a/Lang/Oz/Rot-13 b/Lang/Oz/Rot-13 new file mode 120000 index 0000000000..143d7f50b6 --- /dev/null +++ b/Lang/Oz/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Oz \ No newline at end of file diff --git a/Lang/Oz/Run-length-encoding b/Lang/Oz/Run-length-encoding new file mode 120000 index 0000000000..c1647ff37e --- /dev/null +++ b/Lang/Oz/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Oz \ No newline at end of file diff --git a/Lang/Oz/Runtime-evaluation b/Lang/Oz/Runtime-evaluation new file mode 120000 index 0000000000..fa73249afd --- /dev/null +++ b/Lang/Oz/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/Oz \ No newline at end of file diff --git a/Lang/Oz/Runtime-evaluation-In-an-environment b/Lang/Oz/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..805cba4289 --- /dev/null +++ b/Lang/Oz/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/Oz \ No newline at end of file diff --git a/Lang/Oz/Sequence-of-non-squares b/Lang/Oz/Sequence-of-non-squares new file mode 120000 index 0000000000..2e24885433 --- /dev/null +++ b/Lang/Oz/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Oz \ No newline at end of file diff --git a/Lang/PARI-GP/Arbitrary-precision-integers--included- b/Lang/PARI-GP/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..9cfe1cfe3c --- /dev/null +++ b/Lang/PARI-GP/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Arbitrary-precision-integers-included b/Lang/PARI-GP/Arbitrary-precision-integers-included deleted file mode 120000 index a6a8277b53..0000000000 --- a/Lang/PARI-GP/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Binary-digits b/Lang/PARI-GP/Binary-digits new file mode 120000 index 0000000000..7162bfdf06 --- /dev/null +++ b/Lang/PARI-GP/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Catalan-numbers b/Lang/PARI-GP/Catalan-numbers new file mode 120000 index 0000000000..1016343ab8 --- /dev/null +++ b/Lang/PARI-GP/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Copy-a-string b/Lang/PARI-GP/Copy-a-string new file mode 120000 index 0000000000..4037b4ef22 --- /dev/null +++ b/Lang/PARI-GP/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Environment-variables b/Lang/PARI-GP/Environment-variables new file mode 120000 index 0000000000..6c7b2927d3 --- /dev/null +++ b/Lang/PARI-GP/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Guess-the-number-With-feedback--player- b/Lang/PARI-GP/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..6e00ed3fa2 --- /dev/null +++ b/Lang/PARI-GP/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Guess-the-number-With-feedback-player b/Lang/PARI-GP/Guess-the-number-With-feedback-player deleted file mode 120000 index 5bbd01c89e..0000000000 --- a/Lang/PARI-GP/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Non-decimal-radices-Convert b/Lang/PARI-GP/Non-decimal-radices-Convert new file mode 120000 index 0000000000..00c6eb9103 --- /dev/null +++ b/Lang/PARI-GP/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Non-decimal-radices-Input b/Lang/PARI-GP/Non-decimal-radices-Input new file mode 120000 index 0000000000..dffe02e08d --- /dev/null +++ b/Lang/PARI-GP/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Non-decimal-radices-Output b/Lang/PARI-GP/Non-decimal-radices-Output new file mode 120000 index 0000000000..d3f1fadc9b --- /dev/null +++ b/Lang/PARI-GP/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Nth-root b/Lang/PARI-GP/Nth-root new file mode 120000 index 0000000000..f8558eb7bd --- /dev/null +++ b/Lang/PARI-GP/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Null-object b/Lang/PARI-GP/Null-object new file mode 120000 index 0000000000..8703f8f633 --- /dev/null +++ b/Lang/PARI-GP/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Number-names b/Lang/PARI-GP/Number-names new file mode 120000 index 0000000000..120511fa91 --- /dev/null +++ b/Lang/PARI-GP/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Number-reversal-game b/Lang/PARI-GP/Number-reversal-game new file mode 120000 index 0000000000..a2228cfd1e --- /dev/null +++ b/Lang/PARI-GP/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Numerical-integration b/Lang/PARI-GP/Numerical-integration new file mode 120000 index 0000000000..19d5ae8ff1 --- /dev/null +++ b/Lang/PARI-GP/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Numerical-integration-Gauss-Legendre-Quadrature b/Lang/PARI-GP/Numerical-integration-Gauss-Legendre-Quadrature new file mode 120000 index 0000000000..cc86ccb6cf --- /dev/null +++ b/Lang/PARI-GP/Numerical-integration-Gauss-Legendre-Quadrature @@ -0,0 +1 @@ +../../Task/Numerical-integration-Gauss-Legendre-Quadrature/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/One-dimensional-cellular-automata b/Lang/PARI-GP/One-dimensional-cellular-automata new file mode 120000 index 0000000000..60940c2234 --- /dev/null +++ b/Lang/PARI-GP/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Optional-parameters b/Lang/PARI-GP/Optional-parameters new file mode 120000 index 0000000000..10222538c5 --- /dev/null +++ b/Lang/PARI-GP/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Order-two-numerical-lists b/Lang/PARI-GP/Order-two-numerical-lists new file mode 120000 index 0000000000..301c02ab2d --- /dev/null +++ b/Lang/PARI-GP/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Palindrome-detection b/Lang/PARI-GP/Palindrome-detection new file mode 120000 index 0000000000..566294a1ef --- /dev/null +++ b/Lang/PARI-GP/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Pangram-checker b/Lang/PARI-GP/Pangram-checker new file mode 120000 index 0000000000..12af56e5e3 --- /dev/null +++ b/Lang/PARI-GP/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Parallel-calculations b/Lang/PARI-GP/Parallel-calculations new file mode 120000 index 0000000000..a3d5c54a3b --- /dev/null +++ b/Lang/PARI-GP/Parallel-calculations @@ -0,0 +1 @@ +../../Task/Parallel-calculations/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Pascals-triangle b/Lang/PARI-GP/Pascals-triangle new file mode 120000 index 0000000000..ecffcd6cfc --- /dev/null +++ b/Lang/PARI-GP/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Pascals-triangle-Puzzle b/Lang/PARI-GP/Pascals-triangle-Puzzle new file mode 120000 index 0000000000..c52f9a3874 --- /dev/null +++ b/Lang/PARI-GP/Pascals-triangle-Puzzle @@ -0,0 +1 @@ +../../Task/Pascals-triangle-Puzzle/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Perfect-numbers b/Lang/PARI-GP/Perfect-numbers new file mode 120000 index 0000000000..cb44459d76 --- /dev/null +++ b/Lang/PARI-GP/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Permutations b/Lang/PARI-GP/Permutations new file mode 120000 index 0000000000..72d9f5ffb0 --- /dev/null +++ b/Lang/PARI-GP/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Permutations-Derangements b/Lang/PARI-GP/Permutations-Derangements new file mode 120000 index 0000000000..401851f410 --- /dev/null +++ b/Lang/PARI-GP/Permutations-Derangements @@ -0,0 +1 @@ +../../Task/Permutations-Derangements/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Pick-random-element b/Lang/PARI-GP/Pick-random-element new file mode 120000 index 0000000000..6cf008a545 --- /dev/null +++ b/Lang/PARI-GP/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Playing-cards b/Lang/PARI-GP/Playing-cards new file mode 120000 index 0000000000..cbca22eec5 --- /dev/null +++ b/Lang/PARI-GP/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Plot-coordinate-pairs b/Lang/PARI-GP/Plot-coordinate-pairs new file mode 120000 index 0000000000..a18788dca6 --- /dev/null +++ b/Lang/PARI-GP/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Pointers-and-references b/Lang/PARI-GP/Pointers-and-references new file mode 120000 index 0000000000..911b6c2db1 --- /dev/null +++ b/Lang/PARI-GP/Pointers-and-references @@ -0,0 +1 @@ +../../Task/Pointers-and-references/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Polynomial-long-division b/Lang/PARI-GP/Polynomial-long-division new file mode 120000 index 0000000000..560a700107 --- /dev/null +++ b/Lang/PARI-GP/Polynomial-long-division @@ -0,0 +1 @@ +../../Task/Polynomial-long-division/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Polynomial-regression b/Lang/PARI-GP/Polynomial-regression new file mode 120000 index 0000000000..56c76a256c --- /dev/null +++ b/Lang/PARI-GP/Polynomial-regression @@ -0,0 +1 @@ +../../Task/Polynomial-regression/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Power-set b/Lang/PARI-GP/Power-set new file mode 120000 index 0000000000..1c68b3570c --- /dev/null +++ b/Lang/PARI-GP/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Price-fraction b/Lang/PARI-GP/Price-fraction new file mode 120000 index 0000000000..4c9b7c4a46 --- /dev/null +++ b/Lang/PARI-GP/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Primality-by-trial-division b/Lang/PARI-GP/Primality-by-trial-division new file mode 120000 index 0000000000..ef08856ae4 --- /dev/null +++ b/Lang/PARI-GP/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Prime-decomposition b/Lang/PARI-GP/Prime-decomposition new file mode 120000 index 0000000000..0a32c5d92b --- /dev/null +++ b/Lang/PARI-GP/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Probabilistic-choice b/Lang/PARI-GP/Probabilistic-choice new file mode 120000 index 0000000000..052e5d05bf --- /dev/null +++ b/Lang/PARI-GP/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Program-termination b/Lang/PARI-GP/Program-termination new file mode 120000 index 0000000000..e4304000b1 --- /dev/null +++ b/Lang/PARI-GP/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Pythagorean-triples b/Lang/PARI-GP/Pythagorean-triples new file mode 120000 index 0000000000..b440789c24 --- /dev/null +++ b/Lang/PARI-GP/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/QR-decomposition b/Lang/PARI-GP/QR-decomposition new file mode 120000 index 0000000000..95095e3c37 --- /dev/null +++ b/Lang/PARI-GP/QR-decomposition @@ -0,0 +1 @@ +../../Task/QR-decomposition/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Quaternion-type b/Lang/PARI-GP/Quaternion-type new file mode 120000 index 0000000000..87636fd8d1 --- /dev/null +++ b/Lang/PARI-GP/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Random-number-generator--included- b/Lang/PARI-GP/Random-number-generator--included- new file mode 120000 index 0000000000..5924826efd --- /dev/null +++ b/Lang/PARI-GP/Random-number-generator--included- @@ -0,0 +1 @@ +../../Task/Random-number-generator--included-/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Random-numbers b/Lang/PARI-GP/Random-numbers new file mode 120000 index 0000000000..e2abdf145e --- /dev/null +++ b/Lang/PARI-GP/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Rate-counter b/Lang/PARI-GP/Rate-counter new file mode 120000 index 0000000000..207de03e6f --- /dev/null +++ b/Lang/PARI-GP/Rate-counter @@ -0,0 +1 @@ +../../Task/Rate-counter/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Read-a-file-line-by-line b/Lang/PARI-GP/Read-a-file-line-by-line new file mode 120000 index 0000000000..16d397d270 --- /dev/null +++ b/Lang/PARI-GP/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Read-entire-file b/Lang/PARI-GP/Read-entire-file new file mode 120000 index 0000000000..66d5580825 --- /dev/null +++ b/Lang/PARI-GP/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Real-constants-and-functions b/Lang/PARI-GP/Real-constants-and-functions new file mode 120000 index 0000000000..8954adcb4e --- /dev/null +++ b/Lang/PARI-GP/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Reduced-row-echelon-form b/Lang/PARI-GP/Reduced-row-echelon-form new file mode 120000 index 0000000000..92f3281454 --- /dev/null +++ b/Lang/PARI-GP/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Remove-duplicate-elements b/Lang/PARI-GP/Remove-duplicate-elements new file mode 120000 index 0000000000..78af47e953 --- /dev/null +++ b/Lang/PARI-GP/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Rename-a-file b/Lang/PARI-GP/Rename-a-file new file mode 120000 index 0000000000..483e4947a4 --- /dev/null +++ b/Lang/PARI-GP/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Repeat-a-string b/Lang/PARI-GP/Repeat-a-string new file mode 120000 index 0000000000..b15ed3902a --- /dev/null +++ b/Lang/PARI-GP/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Return-multiple-values b/Lang/PARI-GP/Return-multiple-values new file mode 120000 index 0000000000..a064c2dc73 --- /dev/null +++ b/Lang/PARI-GP/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Reverse-a-string b/Lang/PARI-GP/Reverse-a-string new file mode 120000 index 0000000000..806e006857 --- /dev/null +++ b/Lang/PARI-GP/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Rock-paper-scissors b/Lang/PARI-GP/Rock-paper-scissors new file mode 120000 index 0000000000..a1df68e206 --- /dev/null +++ b/Lang/PARI-GP/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Roman-numerals-Decode b/Lang/PARI-GP/Roman-numerals-Decode new file mode 120000 index 0000000000..257057475a --- /dev/null +++ b/Lang/PARI-GP/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Roman-numerals-Encode b/Lang/PARI-GP/Roman-numerals-Encode new file mode 120000 index 0000000000..87bfc1dcd4 --- /dev/null +++ b/Lang/PARI-GP/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Roots-of-a-function b/Lang/PARI-GP/Roots-of-a-function new file mode 120000 index 0000000000..3445691ec0 --- /dev/null +++ b/Lang/PARI-GP/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Roots-of-a-quadratic-function b/Lang/PARI-GP/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..2177e54085 --- /dev/null +++ b/Lang/PARI-GP/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Roots-of-unity b/Lang/PARI-GP/Roots-of-unity new file mode 120000 index 0000000000..cf4693e7b8 --- /dev/null +++ b/Lang/PARI-GP/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Rot-13 b/Lang/PARI-GP/Rot-13 new file mode 120000 index 0000000000..7695b7e0af --- /dev/null +++ b/Lang/PARI-GP/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Run-length-encoding b/Lang/PARI-GP/Run-length-encoding new file mode 120000 index 0000000000..8ef020fa5f --- /dev/null +++ b/Lang/PARI-GP/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Runtime-evaluation-In-an-environment b/Lang/PARI-GP/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..4c55c23dc6 --- /dev/null +++ b/Lang/PARI-GP/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Self-describing-numbers b/Lang/PARI-GP/Self-describing-numbers new file mode 120000 index 0000000000..9c9164d0d8 --- /dev/null +++ b/Lang/PARI-GP/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Send-an-unknown-method-call b/Lang/PARI-GP/Send-an-unknown-method-call new file mode 120000 index 0000000000..e51f0d60b2 --- /dev/null +++ b/Lang/PARI-GP/Send-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Send-an-unknown-method-call/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Sequence-of-non-squares b/Lang/PARI-GP/Sequence-of-non-squares new file mode 120000 index 0000000000..cbae64ef65 --- /dev/null +++ b/Lang/PARI-GP/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Set b/Lang/PARI-GP/Set new file mode 120000 index 0000000000..d7125b88e4 --- /dev/null +++ b/Lang/PARI-GP/Set @@ -0,0 +1 @@ +../../Task/Set/PARI-GP \ No newline at end of file diff --git a/Lang/PARI-GP/Set-consolidation b/Lang/PARI-GP/Set-consolidation new file mode 120000 index 0000000000..70e01f151c --- /dev/null +++ b/Lang/PARI-GP/Set-consolidation @@ -0,0 +1 @@ +../../Task/Set-consolidation/PARI-GP \ No newline at end of file diff --git a/Lang/PHP/Arbitrary-precision-integers--included- b/Lang/PHP/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..a921169797 --- /dev/null +++ b/Lang/PHP/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/PHP \ No newline at end of file diff --git a/Lang/PHP/Arbitrary-precision-integers-included b/Lang/PHP/Arbitrary-precision-integers-included deleted file mode 120000 index 31b0bc7c61..0000000000 --- a/Lang/PHP/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/PHP \ No newline at end of file diff --git a/Lang/PHP/Binary-digits b/Lang/PHP/Binary-digits new file mode 120000 index 0000000000..6f248bde26 --- /dev/null +++ b/Lang/PHP/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/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..9f00b3c5e5 --- /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/Calendar-for-real-programmers b/Lang/PHP/Calendar-for-real-programmers deleted file mode 120000 index d07c5a38f9..0000000000 --- a/Lang/PHP/Calendar-for-real-programmers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Calendar-for-real-programmers/PHP \ No newline at end of file diff --git a/Lang/PHP/Catalan-numbers b/Lang/PHP/Catalan-numbers new file mode 120000 index 0000000000..aebab9c1a5 --- /dev/null +++ b/Lang/PHP/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/PHP \ No newline at end of file diff --git a/Lang/PHP/Copy-a-string b/Lang/PHP/Copy-a-string new file mode 120000 index 0000000000..943b417cce --- /dev/null +++ b/Lang/PHP/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/PHP \ No newline at end of file diff --git a/Lang/PHP/Environment-variables b/Lang/PHP/Environment-variables new file mode 120000 index 0000000000..d6009f9737 --- /dev/null +++ b/Lang/PHP/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/PHP \ No newline at end of file diff --git a/Lang/PHP/N-queens-problem b/Lang/PHP/N-queens-problem new file mode 120000 index 0000000000..0354eccba8 --- /dev/null +++ b/Lang/PHP/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/PHP \ No newline at end of file diff --git a/Lang/PHP/Non-decimal-radices-Convert b/Lang/PHP/Non-decimal-radices-Convert new file mode 120000 index 0000000000..0c0d79e85e --- /dev/null +++ b/Lang/PHP/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/PHP \ No newline at end of file diff --git a/Lang/PHP/Non-decimal-radices-Input b/Lang/PHP/Non-decimal-radices-Input new file mode 120000 index 0000000000..7ea2fc97fb --- /dev/null +++ b/Lang/PHP/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/PHP \ No newline at end of file diff --git a/Lang/PHP/Non-decimal-radices-Output b/Lang/PHP/Non-decimal-radices-Output new file mode 120000 index 0000000000..c577c78226 --- /dev/null +++ b/Lang/PHP/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/PHP \ No newline at end of file diff --git a/Lang/PHP/Nth-root b/Lang/PHP/Nth-root new file mode 120000 index 0000000000..18013ce715 --- /dev/null +++ b/Lang/PHP/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/PHP \ No newline at end of file diff --git a/Lang/PHP/Null-object b/Lang/PHP/Null-object new file mode 120000 index 0000000000..77fbe875fd --- /dev/null +++ b/Lang/PHP/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/PHP \ No newline at end of file diff --git a/Lang/PHP/Number-names b/Lang/PHP/Number-names new file mode 120000 index 0000000000..a19fdffbae --- /dev/null +++ b/Lang/PHP/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/PHP \ No newline at end of file diff --git a/Lang/PHP/Object-serialization b/Lang/PHP/Object-serialization new file mode 120000 index 0000000000..bca183e727 --- /dev/null +++ b/Lang/PHP/Object-serialization @@ -0,0 +1 @@ +../../Task/Object-serialization/PHP \ No newline at end of file diff --git a/Lang/PHP/Palindrome-detection b/Lang/PHP/Palindrome-detection new file mode 120000 index 0000000000..fa562fb320 --- /dev/null +++ b/Lang/PHP/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/PHP \ No newline at end of file diff --git a/Lang/PHP/Pangram-checker b/Lang/PHP/Pangram-checker new file mode 120000 index 0000000000..f70e3e1fa3 --- /dev/null +++ b/Lang/PHP/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/PHP \ No newline at end of file diff --git a/Lang/PHP/Parametrized-SQL-statement b/Lang/PHP/Parametrized-SQL-statement new file mode 120000 index 0000000000..9d4feb667d --- /dev/null +++ b/Lang/PHP/Parametrized-SQL-statement @@ -0,0 +1 @@ +../../Task/Parametrized-SQL-statement/PHP \ No newline at end of file diff --git a/Lang/PHP/Parsing-RPN-calculator-algorithm b/Lang/PHP/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..4ba77ba57b --- /dev/null +++ b/Lang/PHP/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/PHP \ No newline at end of file diff --git a/Lang/PHP/Pascals-triangle b/Lang/PHP/Pascals-triangle new file mode 120000 index 0000000000..deff658721 --- /dev/null +++ b/Lang/PHP/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/PHP \ No newline at end of file diff --git a/Lang/PHP/Perfect-numbers b/Lang/PHP/Perfect-numbers new file mode 120000 index 0000000000..ce88cc8af4 --- /dev/null +++ b/Lang/PHP/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/PHP \ No newline at end of file diff --git a/Lang/PHP/Pick-random-element b/Lang/PHP/Pick-random-element new file mode 120000 index 0000000000..49c57a2803 --- /dev/null +++ b/Lang/PHP/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/PHP \ No newline at end of file diff --git a/Lang/PHP/Pig-the-dice-game b/Lang/PHP/Pig-the-dice-game new file mode 120000 index 0000000000..6a6e0b21e4 --- /dev/null +++ b/Lang/PHP/Pig-the-dice-game @@ -0,0 +1 @@ +../../Task/Pig-the-dice-game/PHP \ No newline at end of file diff --git a/Lang/PHP/Playing-cards b/Lang/PHP/Playing-cards new file mode 120000 index 0000000000..f50b9f955b --- /dev/null +++ b/Lang/PHP/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/PHP \ No newline at end of file diff --git a/Lang/PHP/Pointers-and-references b/Lang/PHP/Pointers-and-references new file mode 120000 index 0000000000..be19b923da --- /dev/null +++ b/Lang/PHP/Pointers-and-references @@ -0,0 +1 @@ +../../Task/Pointers-and-references/PHP \ No newline at end of file diff --git a/Lang/PHP/Polymorphic-copy b/Lang/PHP/Polymorphic-copy new file mode 120000 index 0000000000..46dec50c99 --- /dev/null +++ b/Lang/PHP/Polymorphic-copy @@ -0,0 +1 @@ +../../Task/Polymorphic-copy/PHP \ No newline at end of file diff --git a/Lang/PHP/Polymorphism b/Lang/PHP/Polymorphism new file mode 120000 index 0000000000..aa13af0e99 --- /dev/null +++ b/Lang/PHP/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/PHP \ No newline at end of file diff --git a/Lang/PHP/Power-set b/Lang/PHP/Power-set new file mode 120000 index 0000000000..57f6c7fe9b --- /dev/null +++ b/Lang/PHP/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/PHP \ No newline at end of file diff --git a/Lang/PHP/Primality-by-trial-division b/Lang/PHP/Primality-by-trial-division new file mode 120000 index 0000000000..7265b8e9ad --- /dev/null +++ b/Lang/PHP/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/PHP \ No newline at end of file diff --git a/Lang/PHP/Priority-queue b/Lang/PHP/Priority-queue new file mode 120000 index 0000000000..57fcc4966b --- /dev/null +++ b/Lang/PHP/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/PHP \ No newline at end of file diff --git a/Lang/PHP/Program-name b/Lang/PHP/Program-name new file mode 120000 index 0000000000..1f5b96336a --- /dev/null +++ b/Lang/PHP/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/PHP \ No newline at end of file diff --git a/Lang/PHP/Program-termination b/Lang/PHP/Program-termination new file mode 120000 index 0000000000..9e6a17136a --- /dev/null +++ b/Lang/PHP/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/PHP \ No newline at end of file diff --git a/Lang/PHP/Queue-Definition b/Lang/PHP/Queue-Definition new file mode 120000 index 0000000000..80086d4de8 --- /dev/null +++ b/Lang/PHP/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/PHP \ No newline at end of file diff --git a/Lang/PHP/Queue-Usage b/Lang/PHP/Queue-Usage new file mode 120000 index 0000000000..4751973da7 --- /dev/null +++ b/Lang/PHP/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/PHP \ No newline at end of file diff --git a/Lang/PHP/Random-numbers b/Lang/PHP/Random-numbers new file mode 120000 index 0000000000..c27363e84f --- /dev/null +++ b/Lang/PHP/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/PHP \ No newline at end of file diff --git a/Lang/PHP/Range-expansion b/Lang/PHP/Range-expansion new file mode 120000 index 0000000000..4ddc4ee5ba --- /dev/null +++ b/Lang/PHP/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/PHP \ No newline at end of file diff --git a/Lang/PHP/Read-a-file-line-by-line b/Lang/PHP/Read-a-file-line-by-line new file mode 120000 index 0000000000..7ba88298be --- /dev/null +++ b/Lang/PHP/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/PHP \ No newline at end of file diff --git a/Lang/PHP/Read-entire-file b/Lang/PHP/Read-entire-file new file mode 120000 index 0000000000..a688792417 --- /dev/null +++ b/Lang/PHP/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/PHP \ No newline at end of file diff --git a/Lang/PHP/Real-constants-and-functions b/Lang/PHP/Real-constants-and-functions new file mode 120000 index 0000000000..3160e995fc --- /dev/null +++ b/Lang/PHP/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/PHP \ No newline at end of file diff --git a/Lang/PHP/Reduced-row-echelon-form b/Lang/PHP/Reduced-row-echelon-form new file mode 120000 index 0000000000..7a314ed778 --- /dev/null +++ b/Lang/PHP/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/PHP \ No newline at end of file diff --git a/Lang/PHP/Regular-expressions b/Lang/PHP/Regular-expressions new file mode 120000 index 0000000000..a7e7eddf86 --- /dev/null +++ b/Lang/PHP/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/PHP \ No newline at end of file diff --git a/Lang/PHP/Remove-duplicate-elements b/Lang/PHP/Remove-duplicate-elements new file mode 120000 index 0000000000..324344184b --- /dev/null +++ b/Lang/PHP/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/PHP \ No newline at end of file diff --git a/Lang/PHP/Rename-a-file b/Lang/PHP/Rename-a-file new file mode 120000 index 0000000000..c859e92ad0 --- /dev/null +++ b/Lang/PHP/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/PHP \ No newline at end of file diff --git a/Lang/PHP/Repeat-a-string b/Lang/PHP/Repeat-a-string new file mode 120000 index 0000000000..171b2b8119 --- /dev/null +++ b/Lang/PHP/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/PHP \ No newline at end of file diff --git a/Lang/PHP/Respond-to-an-unknown-method-call b/Lang/PHP/Respond-to-an-unknown-method-call new file mode 120000 index 0000000000..1967a73542 --- /dev/null +++ b/Lang/PHP/Respond-to-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Respond-to-an-unknown-method-call/PHP \ No newline at end of file diff --git a/Lang/PHP/Return-multiple-values b/Lang/PHP/Return-multiple-values new file mode 120000 index 0000000000..1f7c40a2e7 --- /dev/null +++ b/Lang/PHP/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/PHP \ No newline at end of file diff --git a/Lang/PHP/Reverse-a-string b/Lang/PHP/Reverse-a-string new file mode 120000 index 0000000000..f3d31caaac --- /dev/null +++ b/Lang/PHP/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/PHP \ No newline at end of file diff --git a/Lang/PHP/Roman-numerals-Decode b/Lang/PHP/Roman-numerals-Decode new file mode 120000 index 0000000000..7616f0938f --- /dev/null +++ b/Lang/PHP/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/PHP \ No newline at end of file diff --git a/Lang/PHP/Roman-numerals-Encode b/Lang/PHP/Roman-numerals-Encode new file mode 120000 index 0000000000..4310256473 --- /dev/null +++ b/Lang/PHP/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/PHP \ No newline at end of file diff --git a/Lang/PHP/Rot-13 b/Lang/PHP/Rot-13 new file mode 120000 index 0000000000..a481d369e0 --- /dev/null +++ b/Lang/PHP/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/PHP \ No newline at end of file diff --git a/Lang/PHP/Run-length-encoding b/Lang/PHP/Run-length-encoding new file mode 120000 index 0000000000..7168220c27 --- /dev/null +++ b/Lang/PHP/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/PHP \ No newline at end of file diff --git a/Lang/PHP/Runtime-evaluation b/Lang/PHP/Runtime-evaluation new file mode 120000 index 0000000000..f84da4376d --- /dev/null +++ b/Lang/PHP/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/PHP \ No newline at end of file diff --git a/Lang/PHP/Runtime-evaluation-In-an-environment b/Lang/PHP/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..599675852f --- /dev/null +++ b/Lang/PHP/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/PHP \ No newline at end of file diff --git a/Lang/PHP/SEDOLs b/Lang/PHP/SEDOLs new file mode 120000 index 0000000000..718a0ec03e --- /dev/null +++ b/Lang/PHP/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/PHP \ No newline at end of file diff --git a/Lang/PHP/Secure-temporary-file b/Lang/PHP/Secure-temporary-file new file mode 120000 index 0000000000..3dc75d089f --- /dev/null +++ b/Lang/PHP/Secure-temporary-file @@ -0,0 +1 @@ +../../Task/Secure-temporary-file/PHP \ No newline at end of file diff --git a/Lang/PHP/Semordnilap b/Lang/PHP/Semordnilap new file mode 120000 index 0000000000..913107fe86 --- /dev/null +++ b/Lang/PHP/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/PHP \ No newline at end of file diff --git a/Lang/PHP/Send-an-unknown-method-call b/Lang/PHP/Send-an-unknown-method-call new file mode 120000 index 0000000000..38ac119626 --- /dev/null +++ b/Lang/PHP/Send-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Send-an-unknown-method-call/PHP \ No newline at end of file diff --git a/Lang/PHP/Send-email b/Lang/PHP/Send-email new file mode 120000 index 0000000000..c572e1649c --- /dev/null +++ b/Lang/PHP/Send-email @@ -0,0 +1 @@ +../../Task/Send-email/PHP \ No newline at end of file diff --git a/Lang/PL-I/Binary-digits b/Lang/PL-I/Binary-digits new file mode 120000 index 0000000000..d272838422 --- /dev/null +++ b/Lang/PL-I/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Catalan-numbers b/Lang/PL-I/Catalan-numbers new file mode 120000 index 0000000000..a17f500205 --- /dev/null +++ b/Lang/PL-I/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Copy-a-string b/Lang/PL-I/Copy-a-string new file mode 120000 index 0000000000..581d08e7b0 --- /dev/null +++ b/Lang/PL-I/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Non-decimal-radices-Convert b/Lang/PL-I/Non-decimal-radices-Convert new file mode 120000 index 0000000000..de23d1d7db --- /dev/null +++ b/Lang/PL-I/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Non-decimal-radices-Input b/Lang/PL-I/Non-decimal-radices-Input new file mode 120000 index 0000000000..23478b394f --- /dev/null +++ b/Lang/PL-I/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Non-decimal-radices-Output b/Lang/PL-I/Non-decimal-radices-Output new file mode 120000 index 0000000000..85d916d277 --- /dev/null +++ b/Lang/PL-I/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Nth-root b/Lang/PL-I/Nth-root new file mode 120000 index 0000000000..01d5a0c360 --- /dev/null +++ b/Lang/PL-I/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Null-object b/Lang/PL-I/Null-object new file mode 120000 index 0000000000..535e9807d4 --- /dev/null +++ b/Lang/PL-I/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Number-names b/Lang/PL-I/Number-names new file mode 120000 index 0000000000..b199088199 --- /dev/null +++ b/Lang/PL-I/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Number-reversal-game b/Lang/PL-I/Number-reversal-game new file mode 120000 index 0000000000..feb6011450 --- /dev/null +++ b/Lang/PL-I/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Numerical-integration b/Lang/PL-I/Numerical-integration new file mode 120000 index 0000000000..3c7beb0949 --- /dev/null +++ b/Lang/PL-I/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Palindrome-detection b/Lang/PL-I/Palindrome-detection new file mode 120000 index 0000000000..ee2465b617 --- /dev/null +++ b/Lang/PL-I/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Pangram-checker b/Lang/PL-I/Pangram-checker new file mode 120000 index 0000000000..3abb8787d8 --- /dev/null +++ b/Lang/PL-I/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Parsing-RPN-calculator-algorithm b/Lang/PL-I/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..958fca9b9e --- /dev/null +++ b/Lang/PL-I/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Parsing-RPN-to-infix-conversion b/Lang/PL-I/Parsing-RPN-to-infix-conversion new file mode 120000 index 0000000000..f885b75063 --- /dev/null +++ b/Lang/PL-I/Parsing-RPN-to-infix-conversion @@ -0,0 +1 @@ +../../Task/Parsing-RPN-to-infix-conversion/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Parsing-Shunting-yard-algorithm b/Lang/PL-I/Parsing-Shunting-yard-algorithm new file mode 120000 index 0000000000..10d987187e --- /dev/null +++ b/Lang/PL-I/Parsing-Shunting-yard-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-Shunting-yard-algorithm/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Pascals-triangle b/Lang/PL-I/Pascals-triangle new file mode 120000 index 0000000000..a8691169ec --- /dev/null +++ b/Lang/PL-I/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Perfect-numbers b/Lang/PL-I/Perfect-numbers new file mode 120000 index 0000000000..f3fc9e89fb --- /dev/null +++ b/Lang/PL-I/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Pick-random-element b/Lang/PL-I/Pick-random-element new file mode 120000 index 0000000000..9978559d4b --- /dev/null +++ b/Lang/PL-I/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Price-fraction b/Lang/PL-I/Price-fraction new file mode 120000 index 0000000000..6d04f35c58 --- /dev/null +++ b/Lang/PL-I/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Primality-by-trial-division b/Lang/PL-I/Primality-by-trial-division new file mode 120000 index 0000000000..93946f69d1 --- /dev/null +++ b/Lang/PL-I/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Prime-decomposition b/Lang/PL-I/Prime-decomposition new file mode 120000 index 0000000000..3ef27b0e47 --- /dev/null +++ b/Lang/PL-I/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Program-termination b/Lang/PL-I/Program-termination new file mode 120000 index 0000000000..bc47ac079d --- /dev/null +++ b/Lang/PL-I/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Queue-Definition b/Lang/PL-I/Queue-Definition new file mode 120000 index 0000000000..00ed7f0e4b --- /dev/null +++ b/Lang/PL-I/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Queue-Usage b/Lang/PL-I/Queue-Usage new file mode 120000 index 0000000000..378f1bddd7 --- /dev/null +++ b/Lang/PL-I/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Random-number-generator--included- b/Lang/PL-I/Random-number-generator--included- new file mode 120000 index 0000000000..a35cd06f96 --- /dev/null +++ b/Lang/PL-I/Random-number-generator--included- @@ -0,0 +1 @@ +../../Task/Random-number-generator--included-/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Random-numbers b/Lang/PL-I/Random-numbers new file mode 120000 index 0000000000..78cc893abf --- /dev/null +++ b/Lang/PL-I/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Range-expansion b/Lang/PL-I/Range-expansion new file mode 120000 index 0000000000..e194f2b75f --- /dev/null +++ b/Lang/PL-I/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Range-extraction b/Lang/PL-I/Range-extraction new file mode 120000 index 0000000000..24689adfb9 --- /dev/null +++ b/Lang/PL-I/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Read-a-configuration-file b/Lang/PL-I/Read-a-configuration-file new file mode 120000 index 0000000000..ec33c8c598 --- /dev/null +++ b/Lang/PL-I/Read-a-configuration-file @@ -0,0 +1 @@ +../../Task/Read-a-configuration-file/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Read-a-file-line-by-line b/Lang/PL-I/Read-a-file-line-by-line new file mode 120000 index 0000000000..33528feaf5 --- /dev/null +++ b/Lang/PL-I/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Read-a-specific-line-from-a-file b/Lang/PL-I/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..1f0f546453 --- /dev/null +++ b/Lang/PL-I/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Read-entire-file b/Lang/PL-I/Read-entire-file new file mode 120000 index 0000000000..ffc0c439f0 --- /dev/null +++ b/Lang/PL-I/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Real-constants-and-functions b/Lang/PL-I/Real-constants-and-functions new file mode 120000 index 0000000000..606565d54e --- /dev/null +++ b/Lang/PL-I/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Remove-duplicate-elements b/Lang/PL-I/Remove-duplicate-elements new file mode 120000 index 0000000000..50f7cca11a --- /dev/null +++ b/Lang/PL-I/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Repeat-a-string b/Lang/PL-I/Repeat-a-string new file mode 120000 index 0000000000..624c5bb5a7 --- /dev/null +++ b/Lang/PL-I/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Return-multiple-values b/Lang/PL-I/Return-multiple-values new file mode 120000 index 0000000000..edbd0f39f0 --- /dev/null +++ b/Lang/PL-I/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Reverse-a-string b/Lang/PL-I/Reverse-a-string new file mode 120000 index 0000000000..f48c5ad66d --- /dev/null +++ b/Lang/PL-I/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Roman-numerals-Decode b/Lang/PL-I/Roman-numerals-Decode new file mode 120000 index 0000000000..ab87bcfd24 --- /dev/null +++ b/Lang/PL-I/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Roman-numerals-Encode b/Lang/PL-I/Roman-numerals-Encode new file mode 120000 index 0000000000..9f430a32ae --- /dev/null +++ b/Lang/PL-I/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Roots-of-a-function b/Lang/PL-I/Roots-of-a-function new file mode 120000 index 0000000000..a806a0beec --- /dev/null +++ b/Lang/PL-I/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Roots-of-a-quadratic-function b/Lang/PL-I/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..d840e440ac --- /dev/null +++ b/Lang/PL-I/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Roots-of-unity b/Lang/PL-I/Roots-of-unity new file mode 120000 index 0000000000..a5500bc28d --- /dev/null +++ b/Lang/PL-I/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Rot-13 b/Lang/PL-I/Rot-13 new file mode 120000 index 0000000000..abf567f8f8 --- /dev/null +++ b/Lang/PL-I/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Run-length-encoding b/Lang/PL-I/Run-length-encoding new file mode 120000 index 0000000000..8b4a914c44 --- /dev/null +++ b/Lang/PL-I/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/PL-I \ No newline at end of file diff --git a/Lang/PL-I/SEDOLs b/Lang/PL-I/SEDOLs new file mode 120000 index 0000000000..a824e36e46 --- /dev/null +++ b/Lang/PL-I/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Semordnilap b/Lang/PL-I/Semordnilap new file mode 120000 index 0000000000..252eea09a6 --- /dev/null +++ b/Lang/PL-I/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/PL-I \ No newline at end of file diff --git a/Lang/PL-I/Sequence-of-non-squares b/Lang/PL-I/Sequence-of-non-squares new file mode 120000 index 0000000000..cbd5c73dcf --- /dev/null +++ b/Lang/PL-I/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/PL-I \ No newline at end of file diff --git a/Lang/PL-SQL/Random-number-generator--included- b/Lang/PL-SQL/Random-number-generator--included- new file mode 120000 index 0000000000..4da5a7007c --- /dev/null +++ b/Lang/PL-SQL/Random-number-generator--included- @@ -0,0 +1 @@ +../../Task/Random-number-generator--included-/PL-SQL \ No newline at end of file diff --git a/Lang/PL-SQL/Random-numbers b/Lang/PL-SQL/Random-numbers new file mode 120000 index 0000000000..33faee859c --- /dev/null +++ b/Lang/PL-SQL/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/PL-SQL \ No newline at end of file diff --git a/Lang/PL-SQL/Roman-numerals-Decode b/Lang/PL-SQL/Roman-numerals-Decode new file mode 120000 index 0000000000..771cb0a500 --- /dev/null +++ b/Lang/PL-SQL/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/PL-SQL \ No newline at end of file diff --git a/Lang/PL-SQL/Roman-numerals-Encode b/Lang/PL-SQL/Roman-numerals-Encode new file mode 120000 index 0000000000..50e72577fa --- /dev/null +++ b/Lang/PL-SQL/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/PL-SQL \ No newline at end of file diff --git a/Lang/Pascal/Arbitrary-precision-integers--included- b/Lang/Pascal/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..1196b36f36 --- /dev/null +++ b/Lang/Pascal/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Arbitrary-precision-integers-included b/Lang/Pascal/Arbitrary-precision-integers-included deleted file mode 120000 index 4f8c5d12bb..0000000000 --- a/Lang/Pascal/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Catalan-numbers b/Lang/Pascal/Catalan-numbers new file mode 120000 index 0000000000..cb643bee24 --- /dev/null +++ b/Lang/Pascal/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Copy-a-string b/Lang/Pascal/Copy-a-string new file mode 120000 index 0000000000..dc53121e68 --- /dev/null +++ b/Lang/Pascal/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Dragon-curve b/Lang/Pascal/Dragon-curve new file mode 120000 index 0000000000..05877e1cdc --- /dev/null +++ b/Lang/Pascal/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Guess-the-number-With-feedback--player- b/Lang/Pascal/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..efa03d23be --- /dev/null +++ b/Lang/Pascal/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Guess-the-number-With-feedback-player b/Lang/Pascal/Guess-the-number-With-feedback-player deleted file mode 120000 index 40a3bd4aa4..0000000000 --- a/Lang/Pascal/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/Pascal \ No newline at end of file diff --git a/Lang/Pascal/N-queens-problem b/Lang/Pascal/N-queens-problem new file mode 120000 index 0000000000..63e8e6dd6d --- /dev/null +++ b/Lang/Pascal/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Non-decimal-radices-Convert b/Lang/Pascal/Non-decimal-radices-Convert new file mode 120000 index 0000000000..b63b65bd88 --- /dev/null +++ b/Lang/Pascal/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Number-names b/Lang/Pascal/Number-names new file mode 120000 index 0000000000..872980755d --- /dev/null +++ b/Lang/Pascal/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Numerical-integration b/Lang/Pascal/Numerical-integration new file mode 120000 index 0000000000..ba6f4e9300 --- /dev/null +++ b/Lang/Pascal/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/Pascal \ No newline at end of file diff --git a/Lang/Pascal/One-of-n-lines-in-a-file b/Lang/Pascal/One-of-n-lines-in-a-file new file mode 120000 index 0000000000..afa1ab5584 --- /dev/null +++ b/Lang/Pascal/One-of-n-lines-in-a-file @@ -0,0 +1 @@ +../../Task/One-of-n-lines-in-a-file/Pascal \ No newline at end of file diff --git a/Lang/Pascal/OpenGL b/Lang/Pascal/OpenGL new file mode 120000 index 0000000000..3a7247e217 --- /dev/null +++ b/Lang/Pascal/OpenGL @@ -0,0 +1 @@ +../../Task/OpenGL/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Palindrome-detection b/Lang/Pascal/Palindrome-detection new file mode 120000 index 0000000000..c0e8a58983 --- /dev/null +++ b/Lang/Pascal/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Pascals-triangle b/Lang/Pascal/Pascals-triangle new file mode 120000 index 0000000000..bf2de49fe6 --- /dev/null +++ b/Lang/Pascal/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Perfect-numbers b/Lang/Pascal/Perfect-numbers new file mode 120000 index 0000000000..dfdeed9d46 --- /dev/null +++ b/Lang/Pascal/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Permutations b/Lang/Pascal/Permutations new file mode 120000 index 0000000000..fd79d3d601 --- /dev/null +++ b/Lang/Pascal/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Pick-random-element b/Lang/Pascal/Pick-random-element new file mode 120000 index 0000000000..20c9f983e2 --- /dev/null +++ b/Lang/Pascal/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Price-fraction b/Lang/Pascal/Price-fraction new file mode 120000 index 0000000000..e703c311f8 --- /dev/null +++ b/Lang/Pascal/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Primality-by-trial-division b/Lang/Pascal/Primality-by-trial-division new file mode 120000 index 0000000000..a100bd4cd4 --- /dev/null +++ b/Lang/Pascal/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Prime-decomposition b/Lang/Pascal/Prime-decomposition new file mode 120000 index 0000000000..7b392e005f --- /dev/null +++ b/Lang/Pascal/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Program-name b/Lang/Pascal/Program-name new file mode 120000 index 0000000000..4e868174f3 --- /dev/null +++ b/Lang/Pascal/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Pythagorean-triples b/Lang/Pascal/Pythagorean-triples new file mode 120000 index 0000000000..efd69f7dca --- /dev/null +++ b/Lang/Pascal/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Queue-Definition b/Lang/Pascal/Queue-Definition new file mode 120000 index 0000000000..3a95c1ad16 --- /dev/null +++ b/Lang/Pascal/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Random-number-generator--device- b/Lang/Pascal/Random-number-generator--device- new file mode 120000 index 0000000000..b3c9d1700f --- /dev/null +++ b/Lang/Pascal/Random-number-generator--device- @@ -0,0 +1 @@ +../../Task/Random-number-generator--device-/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Read-a-configuration-file b/Lang/Pascal/Read-a-configuration-file new file mode 120000 index 0000000000..52bfe0cbb3 --- /dev/null +++ b/Lang/Pascal/Read-a-configuration-file @@ -0,0 +1 @@ +../../Task/Read-a-configuration-file/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Read-a-specific-line-from-a-file b/Lang/Pascal/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..6f92b7571a --- /dev/null +++ b/Lang/Pascal/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Regular-expressions b/Lang/Pascal/Regular-expressions new file mode 120000 index 0000000000..9aa5cf7923 --- /dev/null +++ b/Lang/Pascal/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Remove-duplicate-elements b/Lang/Pascal/Remove-duplicate-elements new file mode 120000 index 0000000000..63adb7082b --- /dev/null +++ b/Lang/Pascal/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Rename-a-file b/Lang/Pascal/Rename-a-file new file mode 120000 index 0000000000..c84196ec15 --- /dev/null +++ b/Lang/Pascal/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Reverse-a-string b/Lang/Pascal/Reverse-a-string new file mode 120000 index 0000000000..302c5fbe62 --- /dev/null +++ b/Lang/Pascal/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Roots-of-a-function b/Lang/Pascal/Roots-of-a-function new file mode 120000 index 0000000000..a71c861c01 --- /dev/null +++ b/Lang/Pascal/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Roots-of-a-quadratic-function b/Lang/Pascal/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..334ca81b58 --- /dev/null +++ b/Lang/Pascal/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Roots-of-unity b/Lang/Pascal/Roots-of-unity new file mode 120000 index 0000000000..a474002490 --- /dev/null +++ b/Lang/Pascal/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Rot-13 b/Lang/Pascal/Rot-13 new file mode 120000 index 0000000000..a1f6c982bb --- /dev/null +++ b/Lang/Pascal/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Run-length-encoding b/Lang/Pascal/Run-length-encoding new file mode 120000 index 0000000000..d95a5fc847 --- /dev/null +++ b/Lang/Pascal/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Pascal \ No newline at end of file diff --git a/Lang/Pascal/SEDOLs b/Lang/Pascal/SEDOLs new file mode 120000 index 0000000000..836baed31e --- /dev/null +++ b/Lang/Pascal/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Secure-temporary-file b/Lang/Pascal/Secure-temporary-file new file mode 120000 index 0000000000..bbea0350db --- /dev/null +++ b/Lang/Pascal/Secure-temporary-file @@ -0,0 +1 @@ +../../Task/Secure-temporary-file/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Self-describing-numbers b/Lang/Pascal/Self-describing-numbers new file mode 120000 index 0000000000..2cd3edbbcc --- /dev/null +++ b/Lang/Pascal/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Sequence-of-non-squares b/Lang/Pascal/Sequence-of-non-squares new file mode 120000 index 0000000000..6667335251 --- /dev/null +++ b/Lang/Pascal/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Pascal \ No newline at end of file diff --git a/Lang/Pascal/Set b/Lang/Pascal/Set new file mode 120000 index 0000000000..3cdbc15ddd --- /dev/null +++ b/Lang/Pascal/Set @@ -0,0 +1 @@ +../../Task/Set/Pascal \ No newline at end of file diff --git a/Lang/Perl-6/Arbitrary-precision-integers--included- b/Lang/Perl-6/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..43172fb7ec --- /dev/null +++ b/Lang/Perl-6/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Arbitrary-precision-integers-included b/Lang/Perl-6/Arbitrary-precision-integers-included deleted file mode 120000 index 26535d1bb0..0000000000 --- a/Lang/Perl-6/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Binary-digits b/Lang/Perl-6/Binary-digits new file mode 120000 index 0000000000..a33276bcff --- /dev/null +++ b/Lang/Perl-6/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Calendar---for-real-programmers b/Lang/Perl-6/Calendar---for-real-programmers new file mode 120000 index 0000000000..9f1aa1011f --- /dev/null +++ b/Lang/Perl-6/Calendar---for-real-programmers @@ -0,0 +1 @@ +../../Task/Calendar---for-real-programmers/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Calendar-for-real-programmers b/Lang/Perl-6/Calendar-for-real-programmers deleted file mode 120000 index c088e3414a..0000000000 --- a/Lang/Perl-6/Calendar-for-real-programmers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Calendar-for-real-programmers/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Catalan-numbers b/Lang/Perl-6/Catalan-numbers new file mode 120000 index 0000000000..5ef1b28d88 --- /dev/null +++ b/Lang/Perl-6/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Copy-a-string b/Lang/Perl-6/Copy-a-string new file mode 120000 index 0000000000..769e6c85a9 --- /dev/null +++ b/Lang/Perl-6/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Dragon-curve b/Lang/Perl-6/Dragon-curve new file mode 120000 index 0000000000..3661124ead --- /dev/null +++ b/Lang/Perl-6/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Environment-variables b/Lang/Perl-6/Environment-variables new file mode 120000 index 0000000000..d4ac47174c --- /dev/null +++ b/Lang/Perl-6/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Guess-the-number-With-feedback--player- b/Lang/Perl-6/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..c34bd2bc00 --- /dev/null +++ b/Lang/Perl-6/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Guess-the-number-With-feedback-player b/Lang/Perl-6/Guess-the-number-With-feedback-player deleted file mode 120000 index 6db52b3c91..0000000000 --- a/Lang/Perl-6/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/N-queens-problem b/Lang/Perl-6/N-queens-problem new file mode 120000 index 0000000000..37868809a5 --- /dev/null +++ b/Lang/Perl-6/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Named-parameters b/Lang/Perl-6/Named-parameters new file mode 120000 index 0000000000..79a15b4d53 --- /dev/null +++ b/Lang/Perl-6/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Nautical-bell b/Lang/Perl-6/Nautical-bell new file mode 120000 index 0000000000..105c0c31d7 --- /dev/null +++ b/Lang/Perl-6/Nautical-bell @@ -0,0 +1 @@ +../../Task/Nautical-bell/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Non-continuous-subsequences b/Lang/Perl-6/Non-continuous-subsequences new file mode 120000 index 0000000000..8576d72404 --- /dev/null +++ b/Lang/Perl-6/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Non-decimal-radices-Convert b/Lang/Perl-6/Non-decimal-radices-Convert new file mode 120000 index 0000000000..e479c88e80 --- /dev/null +++ b/Lang/Perl-6/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Non-decimal-radices-Input b/Lang/Perl-6/Non-decimal-radices-Input new file mode 120000 index 0000000000..7a97bbf3f0 --- /dev/null +++ b/Lang/Perl-6/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Non-decimal-radices-Output b/Lang/Perl-6/Non-decimal-radices-Output new file mode 120000 index 0000000000..e42446a9a6 --- /dev/null +++ b/Lang/Perl-6/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Nth-root b/Lang/Perl-6/Nth-root new file mode 120000 index 0000000000..26793e6e85 --- /dev/null +++ b/Lang/Perl-6/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Null-object b/Lang/Perl-6/Null-object new file mode 120000 index 0000000000..b987a93de4 --- /dev/null +++ b/Lang/Perl-6/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Number-names b/Lang/Perl-6/Number-names new file mode 120000 index 0000000000..a553c94a9a --- /dev/null +++ b/Lang/Perl-6/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Number-reversal-game b/Lang/Perl-6/Number-reversal-game new file mode 120000 index 0000000000..69c81fc53f --- /dev/null +++ b/Lang/Perl-6/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Numeric-error-propagation b/Lang/Perl-6/Numeric-error-propagation new file mode 120000 index 0000000000..0d2420d69b --- /dev/null +++ b/Lang/Perl-6/Numeric-error-propagation @@ -0,0 +1 @@ +../../Task/Numeric-error-propagation/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Numerical-integration b/Lang/Perl-6/Numerical-integration new file mode 120000 index 0000000000..e983e0b704 --- /dev/null +++ b/Lang/Perl-6/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Numerical-integration-Gauss-Legendre-Quadrature b/Lang/Perl-6/Numerical-integration-Gauss-Legendre-Quadrature new file mode 120000 index 0000000000..fbd485047c --- /dev/null +++ b/Lang/Perl-6/Numerical-integration-Gauss-Legendre-Quadrature @@ -0,0 +1 @@ +../../Task/Numerical-integration-Gauss-Legendre-Quadrature/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/One-dimensional-cellular-automata b/Lang/Perl-6/One-dimensional-cellular-automata new file mode 120000 index 0000000000..988533c89c --- /dev/null +++ b/Lang/Perl-6/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/One-of-n-lines-in-a-file b/Lang/Perl-6/One-of-n-lines-in-a-file new file mode 120000 index 0000000000..7e3070ca26 --- /dev/null +++ b/Lang/Perl-6/One-of-n-lines-in-a-file @@ -0,0 +1 @@ +../../Task/One-of-n-lines-in-a-file/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Optional-parameters b/Lang/Perl-6/Optional-parameters new file mode 120000 index 0000000000..0925494e00 --- /dev/null +++ b/Lang/Perl-6/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Order-two-numerical-lists b/Lang/Perl-6/Order-two-numerical-lists new file mode 120000 index 0000000000..408108a1f8 --- /dev/null +++ b/Lang/Perl-6/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Ordered-Partitions b/Lang/Perl-6/Ordered-Partitions new file mode 120000 index 0000000000..15b034213b --- /dev/null +++ b/Lang/Perl-6/Ordered-Partitions @@ -0,0 +1 @@ +../../Task/Ordered-Partitions/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Palindrome-detection b/Lang/Perl-6/Palindrome-detection new file mode 120000 index 0000000000..566087deae --- /dev/null +++ b/Lang/Perl-6/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Pangram-checker b/Lang/Perl-6/Pangram-checker new file mode 120000 index 0000000000..25ee0f1901 --- /dev/null +++ b/Lang/Perl-6/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Parallel-calculations b/Lang/Perl-6/Parallel-calculations new file mode 120000 index 0000000000..c1f8c70acf --- /dev/null +++ b/Lang/Perl-6/Parallel-calculations @@ -0,0 +1 @@ +../../Task/Parallel-calculations/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Parametric-polymorphism b/Lang/Perl-6/Parametric-polymorphism new file mode 120000 index 0000000000..d5051015d2 --- /dev/null +++ b/Lang/Perl-6/Parametric-polymorphism @@ -0,0 +1 @@ +../../Task/Parametric-polymorphism/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Parsing-RPN-calculator-algorithm b/Lang/Perl-6/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..be25b1724d --- /dev/null +++ b/Lang/Perl-6/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Parsing-RPN-to-infix-conversion b/Lang/Perl-6/Parsing-RPN-to-infix-conversion new file mode 120000 index 0000000000..8331c8b036 --- /dev/null +++ b/Lang/Perl-6/Parsing-RPN-to-infix-conversion @@ -0,0 +1 @@ +../../Task/Parsing-RPN-to-infix-conversion/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Partial-function-application b/Lang/Perl-6/Partial-function-application new file mode 120000 index 0000000000..2fab3232f7 --- /dev/null +++ b/Lang/Perl-6/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Pascals-triangle b/Lang/Perl-6/Pascals-triangle new file mode 120000 index 0000000000..aada89754d --- /dev/null +++ b/Lang/Perl-6/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Pattern-matching b/Lang/Perl-6/Pattern-matching new file mode 120000 index 0000000000..3961c4037a --- /dev/null +++ b/Lang/Perl-6/Pattern-matching @@ -0,0 +1 @@ +../../Task/Pattern-matching/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Perfect-numbers b/Lang/Perl-6/Perfect-numbers new file mode 120000 index 0000000000..d0ca6c5edc --- /dev/null +++ b/Lang/Perl-6/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Permutations b/Lang/Perl-6/Permutations new file mode 120000 index 0000000000..47bb11fd52 --- /dev/null +++ b/Lang/Perl-6/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Permutations-Derangements b/Lang/Perl-6/Permutations-Derangements new file mode 120000 index 0000000000..02cea89887 --- /dev/null +++ b/Lang/Perl-6/Permutations-Derangements @@ -0,0 +1 @@ +../../Task/Permutations-Derangements/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Permutations-by-swapping b/Lang/Perl-6/Permutations-by-swapping new file mode 120000 index 0000000000..71475db6fe --- /dev/null +++ b/Lang/Perl-6/Permutations-by-swapping @@ -0,0 +1 @@ +../../Task/Permutations-by-swapping/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Pick-random-element b/Lang/Perl-6/Pick-random-element new file mode 120000 index 0000000000..3825a5e056 --- /dev/null +++ b/Lang/Perl-6/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Pig-the-dice-game b/Lang/Perl-6/Pig-the-dice-game new file mode 120000 index 0000000000..cf9dfc41a8 --- /dev/null +++ b/Lang/Perl-6/Pig-the-dice-game @@ -0,0 +1 @@ +../../Task/Pig-the-dice-game/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Playing-cards b/Lang/Perl-6/Playing-cards new file mode 120000 index 0000000000..8d34e6c62b --- /dev/null +++ b/Lang/Perl-6/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Plot-coordinate-pairs b/Lang/Perl-6/Plot-coordinate-pairs new file mode 120000 index 0000000000..6adcf00ede --- /dev/null +++ b/Lang/Perl-6/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Pointers-and-references b/Lang/Perl-6/Pointers-and-references new file mode 120000 index 0000000000..20f5f1f551 --- /dev/null +++ b/Lang/Perl-6/Pointers-and-references @@ -0,0 +1 @@ +../../Task/Pointers-and-references/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Polymorphic-copy b/Lang/Perl-6/Polymorphic-copy new file mode 120000 index 0000000000..649df7b3ca --- /dev/null +++ b/Lang/Perl-6/Polymorphic-copy @@ -0,0 +1 @@ +../../Task/Polymorphic-copy/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Polymorphism b/Lang/Perl-6/Polymorphism new file mode 120000 index 0000000000..c39c2e9cea --- /dev/null +++ b/Lang/Perl-6/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Polynomial-long-division b/Lang/Perl-6/Polynomial-long-division new file mode 120000 index 0000000000..a94c726448 --- /dev/null +++ b/Lang/Perl-6/Polynomial-long-division @@ -0,0 +1 @@ +../../Task/Polynomial-long-division/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Power-set b/Lang/Perl-6/Power-set new file mode 120000 index 0000000000..aa111b66ba --- /dev/null +++ b/Lang/Perl-6/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Pragmatic-directives b/Lang/Perl-6/Pragmatic-directives new file mode 120000 index 0000000000..4ab40e8062 --- /dev/null +++ b/Lang/Perl-6/Pragmatic-directives @@ -0,0 +1 @@ +../../Task/Pragmatic-directives/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Price-fraction b/Lang/Perl-6/Price-fraction new file mode 120000 index 0000000000..dd2eb0423d --- /dev/null +++ b/Lang/Perl-6/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Primality-by-trial-division b/Lang/Perl-6/Primality-by-trial-division new file mode 120000 index 0000000000..c6ddb6bcb5 --- /dev/null +++ b/Lang/Perl-6/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Prime-decomposition b/Lang/Perl-6/Prime-decomposition new file mode 120000 index 0000000000..bba3fdcb3a --- /dev/null +++ b/Lang/Perl-6/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Priority-queue b/Lang/Perl-6/Priority-queue new file mode 120000 index 0000000000..da2d0abe44 --- /dev/null +++ b/Lang/Perl-6/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Probabilistic-choice b/Lang/Perl-6/Probabilistic-choice new file mode 120000 index 0000000000..d506cd0683 --- /dev/null +++ b/Lang/Perl-6/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Problem-of-Apollonius b/Lang/Perl-6/Problem-of-Apollonius new file mode 120000 index 0000000000..26bad895bc --- /dev/null +++ b/Lang/Perl-6/Problem-of-Apollonius @@ -0,0 +1 @@ +../../Task/Problem-of-Apollonius/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Program-name b/Lang/Perl-6/Program-name new file mode 120000 index 0000000000..8ddd489b1e --- /dev/null +++ b/Lang/Perl-6/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Program-termination b/Lang/Perl-6/Program-termination new file mode 120000 index 0000000000..8f5bf22572 --- /dev/null +++ b/Lang/Perl-6/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Pythagorean-triples b/Lang/Perl-6/Pythagorean-triples new file mode 120000 index 0000000000..fefe4adcec --- /dev/null +++ b/Lang/Perl-6/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Quaternion-type b/Lang/Perl-6/Quaternion-type new file mode 120000 index 0000000000..5acc18b04f --- /dev/null +++ b/Lang/Perl-6/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Queue-Definition b/Lang/Perl-6/Queue-Definition new file mode 120000 index 0000000000..6d1570c826 --- /dev/null +++ b/Lang/Perl-6/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Queue-Usage b/Lang/Perl-6/Queue-Usage new file mode 120000 index 0000000000..3a79d1e7f2 --- /dev/null +++ b/Lang/Perl-6/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/RIPEMD-160 b/Lang/Perl-6/RIPEMD-160 new file mode 120000 index 0000000000..a789f0537e --- /dev/null +++ b/Lang/Perl-6/RIPEMD-160 @@ -0,0 +1 @@ +../../Task/RIPEMD-160/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Random-number-generator--device- b/Lang/Perl-6/Random-number-generator--device- new file mode 120000 index 0000000000..15fe009c25 --- /dev/null +++ b/Lang/Perl-6/Random-number-generator--device- @@ -0,0 +1 @@ +../../Task/Random-number-generator--device-/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Random-numbers b/Lang/Perl-6/Random-numbers new file mode 120000 index 0000000000..babe0056fd --- /dev/null +++ b/Lang/Perl-6/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Range-expansion b/Lang/Perl-6/Range-expansion new file mode 120000 index 0000000000..b01b32e7d6 --- /dev/null +++ b/Lang/Perl-6/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Range-extraction b/Lang/Perl-6/Range-extraction new file mode 120000 index 0000000000..a65ad700ed --- /dev/null +++ b/Lang/Perl-6/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Rate-counter b/Lang/Perl-6/Rate-counter new file mode 120000 index 0000000000..e0a57b118c --- /dev/null +++ b/Lang/Perl-6/Rate-counter @@ -0,0 +1 @@ +../../Task/Rate-counter/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Ray-casting-algorithm b/Lang/Perl-6/Ray-casting-algorithm new file mode 120000 index 0000000000..cb849d065d --- /dev/null +++ b/Lang/Perl-6/Ray-casting-algorithm @@ -0,0 +1 @@ +../../Task/Ray-casting-algorithm/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Read-a-configuration-file b/Lang/Perl-6/Read-a-configuration-file new file mode 120000 index 0000000000..0f9290ce17 --- /dev/null +++ b/Lang/Perl-6/Read-a-configuration-file @@ -0,0 +1 @@ +../../Task/Read-a-configuration-file/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Read-a-file-line-by-line b/Lang/Perl-6/Read-a-file-line-by-line new file mode 120000 index 0000000000..b162017566 --- /dev/null +++ b/Lang/Perl-6/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Read-a-specific-line-from-a-file b/Lang/Perl-6/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..917b728000 --- /dev/null +++ b/Lang/Perl-6/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Read-entire-file b/Lang/Perl-6/Read-entire-file new file mode 120000 index 0000000000..a37c9a95fb --- /dev/null +++ b/Lang/Perl-6/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Real-constants-and-functions b/Lang/Perl-6/Real-constants-and-functions new file mode 120000 index 0000000000..a754ef4229 --- /dev/null +++ b/Lang/Perl-6/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Reduced-row-echelon-form b/Lang/Perl-6/Reduced-row-echelon-form new file mode 120000 index 0000000000..b376221e81 --- /dev/null +++ b/Lang/Perl-6/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Regular-expressions b/Lang/Perl-6/Regular-expressions new file mode 120000 index 0000000000..8b5268f8f8 --- /dev/null +++ b/Lang/Perl-6/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Remove-duplicate-elements b/Lang/Perl-6/Remove-duplicate-elements new file mode 120000 index 0000000000..e1d40e1033 --- /dev/null +++ b/Lang/Perl-6/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Remove-lines-from-a-file b/Lang/Perl-6/Remove-lines-from-a-file new file mode 120000 index 0000000000..11c3b82b0b --- /dev/null +++ b/Lang/Perl-6/Remove-lines-from-a-file @@ -0,0 +1 @@ +../../Task/Remove-lines-from-a-file/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Rename-a-file b/Lang/Perl-6/Rename-a-file new file mode 120000 index 0000000000..5d5f6ed896 --- /dev/null +++ b/Lang/Perl-6/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Repeat-a-string b/Lang/Perl-6/Repeat-a-string new file mode 120000 index 0000000000..88d783ad16 --- /dev/null +++ b/Lang/Perl-6/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Resistor-mesh b/Lang/Perl-6/Resistor-mesh new file mode 120000 index 0000000000..8f99acef55 --- /dev/null +++ b/Lang/Perl-6/Resistor-mesh @@ -0,0 +1 @@ +../../Task/Resistor-mesh/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Respond-to-an-unknown-method-call b/Lang/Perl-6/Respond-to-an-unknown-method-call new file mode 120000 index 0000000000..9951501142 --- /dev/null +++ b/Lang/Perl-6/Respond-to-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Respond-to-an-unknown-method-call/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Return-multiple-values b/Lang/Perl-6/Return-multiple-values new file mode 120000 index 0000000000..f6714050d6 --- /dev/null +++ b/Lang/Perl-6/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Reverse-a-string b/Lang/Perl-6/Reverse-a-string new file mode 120000 index 0000000000..1e76ff0c10 --- /dev/null +++ b/Lang/Perl-6/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Rock-paper-scissors b/Lang/Perl-6/Rock-paper-scissors new file mode 120000 index 0000000000..d508db4f75 --- /dev/null +++ b/Lang/Perl-6/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Roman-numerals-Decode b/Lang/Perl-6/Roman-numerals-Decode new file mode 120000 index 0000000000..d80b616863 --- /dev/null +++ b/Lang/Perl-6/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Roman-numerals-Encode b/Lang/Perl-6/Roman-numerals-Encode new file mode 120000 index 0000000000..2d16a3c9c4 --- /dev/null +++ b/Lang/Perl-6/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Roots-of-a-function b/Lang/Perl-6/Roots-of-a-function new file mode 120000 index 0000000000..5dbb4f7442 --- /dev/null +++ b/Lang/Perl-6/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Roots-of-a-quadratic-function b/Lang/Perl-6/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..78cbf06d89 --- /dev/null +++ b/Lang/Perl-6/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Roots-of-unity b/Lang/Perl-6/Roots-of-unity new file mode 120000 index 0000000000..7a2cb49710 --- /dev/null +++ b/Lang/Perl-6/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Rosetta-Code-Rank-languages-by-popularity b/Lang/Perl-6/Rosetta-Code-Rank-languages-by-popularity new file mode 120000 index 0000000000..d84ceb645d --- /dev/null +++ b/Lang/Perl-6/Rosetta-Code-Rank-languages-by-popularity @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-popularity/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Rot-13 b/Lang/Perl-6/Rot-13 new file mode 120000 index 0000000000..e70f003a7a --- /dev/null +++ b/Lang/Perl-6/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Run-length-encoding b/Lang/Perl-6/Run-length-encoding new file mode 120000 index 0000000000..df41957fa3 --- /dev/null +++ b/Lang/Perl-6/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Runtime-evaluation b/Lang/Perl-6/Runtime-evaluation new file mode 120000 index 0000000000..0259ac0ac9 --- /dev/null +++ b/Lang/Perl-6/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Runtime-evaluation-In-an-environment b/Lang/Perl-6/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..a12feaba70 --- /dev/null +++ b/Lang/Perl-6/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/S-Expressions b/Lang/Perl-6/S-Expressions new file mode 120000 index 0000000000..a637660519 --- /dev/null +++ b/Lang/Perl-6/S-Expressions @@ -0,0 +1 @@ +../../Task/S-Expressions/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/SEDOLs b/Lang/Perl-6/SEDOLs new file mode 120000 index 0000000000..a9e991a6fb --- /dev/null +++ b/Lang/Perl-6/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Same-Fringe b/Lang/Perl-6/Same-Fringe new file mode 120000 index 0000000000..957685efdc --- /dev/null +++ b/Lang/Perl-6/Same-Fringe @@ -0,0 +1 @@ +../../Task/Same-Fringe/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Scope-Function-names-and-labels b/Lang/Perl-6/Scope-Function-names-and-labels new file mode 120000 index 0000000000..dea56ea725 --- /dev/null +++ b/Lang/Perl-6/Scope-Function-names-and-labels @@ -0,0 +1 @@ +../../Task/Scope-Function-names-and-labels/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Scope-modifiers b/Lang/Perl-6/Scope-modifiers new file mode 120000 index 0000000000..6032459204 --- /dev/null +++ b/Lang/Perl-6/Scope-modifiers @@ -0,0 +1 @@ +../../Task/Scope-modifiers/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Self-describing-numbers b/Lang/Perl-6/Self-describing-numbers new file mode 120000 index 0000000000..2d752e2877 --- /dev/null +++ b/Lang/Perl-6/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Self-referential-sequence b/Lang/Perl-6/Self-referential-sequence new file mode 120000 index 0000000000..e0c7545b00 --- /dev/null +++ b/Lang/Perl-6/Self-referential-sequence @@ -0,0 +1 @@ +../../Task/Self-referential-sequence/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Semordnilap b/Lang/Perl-6/Semordnilap new file mode 120000 index 0000000000..0ffa16f3ab --- /dev/null +++ b/Lang/Perl-6/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Send-an-unknown-method-call b/Lang/Perl-6/Send-an-unknown-method-call new file mode 120000 index 0000000000..e0b4dc9caf --- /dev/null +++ b/Lang/Perl-6/Send-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Send-an-unknown-method-call/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Sequence-of-non-squares b/Lang/Perl-6/Sequence-of-non-squares new file mode 120000 index 0000000000..d8229a7018 --- /dev/null +++ b/Lang/Perl-6/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Set b/Lang/Perl-6/Set new file mode 120000 index 0000000000..d613ab36fb --- /dev/null +++ b/Lang/Perl-6/Set @@ -0,0 +1 @@ +../../Task/Set/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Set-consolidation b/Lang/Perl-6/Set-consolidation new file mode 120000 index 0000000000..d1a2b9700b --- /dev/null +++ b/Lang/Perl-6/Set-consolidation @@ -0,0 +1 @@ +../../Task/Set-consolidation/Perl-6 \ No newline at end of file diff --git a/Lang/Perl-6/Set-of-real-numbers b/Lang/Perl-6/Set-of-real-numbers new file mode 120000 index 0000000000..a54492c6b7 --- /dev/null +++ b/Lang/Perl-6/Set-of-real-numbers @@ -0,0 +1 @@ +../../Task/Set-of-real-numbers/Perl-6 \ No newline at end of file diff --git a/Lang/Perl/Arbitrary-precision-integers--included- b/Lang/Perl/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..916bf42ca6 --- /dev/null +++ b/Lang/Perl/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Perl \ No newline at end of file diff --git a/Lang/Perl/Arbitrary-precision-integers-included b/Lang/Perl/Arbitrary-precision-integers-included deleted file mode 120000 index b499abc9be..0000000000 --- a/Lang/Perl/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Perl \ No newline at end of file diff --git a/Lang/Perl/Binary-digits b/Lang/Perl/Binary-digits new file mode 120000 index 0000000000..c67028cb23 --- /dev/null +++ b/Lang/Perl/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Perl \ No newline at end of file diff --git a/Lang/Perl/Brownian-tree b/Lang/Perl/Brownian-tree new file mode 120000 index 0000000000..54f77790b3 --- /dev/null +++ b/Lang/Perl/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/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..85c695f20e --- /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/Calendar-for-real-programmers b/Lang/Perl/Calendar-for-real-programmers deleted file mode 120000 index d78355e212..0000000000 --- a/Lang/Perl/Calendar-for-real-programmers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Calendar-for-real-programmers/Perl \ No newline at end of file diff --git a/Lang/Perl/Catalan-numbers b/Lang/Perl/Catalan-numbers new file mode 120000 index 0000000000..2781799300 --- /dev/null +++ b/Lang/Perl/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Perl \ No newline at end of file diff --git a/Lang/Perl/Copy-a-string b/Lang/Perl/Copy-a-string new file mode 120000 index 0000000000..7b84da198e --- /dev/null +++ b/Lang/Perl/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Perl \ No newline at end of file diff --git a/Lang/Perl/Environment-variables b/Lang/Perl/Environment-variables new file mode 120000 index 0000000000..782796a957 --- /dev/null +++ b/Lang/Perl/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Perl \ No newline at end of file diff --git a/Lang/Perl/Execute-a-Markov-algorithm b/Lang/Perl/Execute-a-Markov-algorithm new file mode 120000 index 0000000000..3baf579d74 --- /dev/null +++ b/Lang/Perl/Execute-a-Markov-algorithm @@ -0,0 +1 @@ +../../Task/Execute-a-Markov-algorithm/Perl \ No newline at end of file diff --git a/Lang/Perl/Guess-the-number-With-feedback--player- b/Lang/Perl/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..005b1384af --- /dev/null +++ b/Lang/Perl/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/Perl \ No newline at end of file diff --git a/Lang/Perl/Guess-the-number-With-feedback-player b/Lang/Perl/Guess-the-number-With-feedback-player deleted file mode 120000 index 4445655734..0000000000 --- a/Lang/Perl/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/Perl \ No newline at end of file diff --git a/Lang/Perl/N-queens-problem b/Lang/Perl/N-queens-problem new file mode 120000 index 0000000000..8d3e3a1239 --- /dev/null +++ b/Lang/Perl/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Perl \ No newline at end of file diff --git a/Lang/Perl/Named-parameters b/Lang/Perl/Named-parameters new file mode 120000 index 0000000000..20e927f4c2 --- /dev/null +++ b/Lang/Perl/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/Perl \ No newline at end of file diff --git a/Lang/Perl/Non-continuous-subsequences b/Lang/Perl/Non-continuous-subsequences new file mode 120000 index 0000000000..35427a981a --- /dev/null +++ b/Lang/Perl/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/Perl \ No newline at end of file diff --git a/Lang/Perl/Non-decimal-radices-Convert b/Lang/Perl/Non-decimal-radices-Convert new file mode 120000 index 0000000000..c085f0f63b --- /dev/null +++ b/Lang/Perl/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/Perl \ No newline at end of file diff --git a/Lang/Perl/Non-decimal-radices-Input b/Lang/Perl/Non-decimal-radices-Input new file mode 120000 index 0000000000..177bd53103 --- /dev/null +++ b/Lang/Perl/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/Perl \ No newline at end of file diff --git a/Lang/Perl/Non-decimal-radices-Output b/Lang/Perl/Non-decimal-radices-Output new file mode 120000 index 0000000000..c82ea367b6 --- /dev/null +++ b/Lang/Perl/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/Perl \ No newline at end of file diff --git a/Lang/Perl/Nth-root b/Lang/Perl/Nth-root new file mode 120000 index 0000000000..b7ef5a3802 --- /dev/null +++ b/Lang/Perl/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Perl \ No newline at end of file diff --git a/Lang/Perl/Null-object b/Lang/Perl/Null-object new file mode 120000 index 0000000000..1eed6c367b --- /dev/null +++ b/Lang/Perl/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Perl \ No newline at end of file diff --git a/Lang/Perl/Number-names b/Lang/Perl/Number-names new file mode 120000 index 0000000000..9d3f30b8ce --- /dev/null +++ b/Lang/Perl/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/Perl \ No newline at end of file diff --git a/Lang/Perl/Number-reversal-game b/Lang/Perl/Number-reversal-game new file mode 120000 index 0000000000..8c2b552321 --- /dev/null +++ b/Lang/Perl/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/Perl \ No newline at end of file diff --git a/Lang/Perl/Numeric-error-propagation b/Lang/Perl/Numeric-error-propagation new file mode 120000 index 0000000000..b09875d0a3 --- /dev/null +++ b/Lang/Perl/Numeric-error-propagation @@ -0,0 +1 @@ +../../Task/Numeric-error-propagation/Perl \ No newline at end of file diff --git a/Lang/Perl/Object-serialization b/Lang/Perl/Object-serialization new file mode 120000 index 0000000000..4046bad668 --- /dev/null +++ b/Lang/Perl/Object-serialization @@ -0,0 +1 @@ +../../Task/Object-serialization/Perl \ No newline at end of file diff --git a/Lang/Perl/One-dimensional-cellular-automata b/Lang/Perl/One-dimensional-cellular-automata new file mode 120000 index 0000000000..1f3eff03e5 --- /dev/null +++ b/Lang/Perl/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Perl \ No newline at end of file diff --git a/Lang/Perl/OpenGL b/Lang/Perl/OpenGL new file mode 120000 index 0000000000..b99cf33eb8 --- /dev/null +++ b/Lang/Perl/OpenGL @@ -0,0 +1 @@ +../../Task/OpenGL/Perl \ No newline at end of file diff --git a/Lang/Perl/Optional-parameters b/Lang/Perl/Optional-parameters new file mode 120000 index 0000000000..6c7e673693 --- /dev/null +++ b/Lang/Perl/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/Perl \ No newline at end of file diff --git a/Lang/Perl/Order-two-numerical-lists b/Lang/Perl/Order-two-numerical-lists new file mode 120000 index 0000000000..f3832b0eaf --- /dev/null +++ b/Lang/Perl/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/Perl \ No newline at end of file diff --git a/Lang/Perl/Ordered-Partitions b/Lang/Perl/Ordered-Partitions new file mode 120000 index 0000000000..501534c434 --- /dev/null +++ b/Lang/Perl/Ordered-Partitions @@ -0,0 +1 @@ +../../Task/Ordered-Partitions/Perl \ No newline at end of file diff --git a/Lang/Perl/Palindrome-detection b/Lang/Perl/Palindrome-detection new file mode 120000 index 0000000000..2b6591aca9 --- /dev/null +++ b/Lang/Perl/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Perl \ No newline at end of file diff --git a/Lang/Perl/Pangram-checker b/Lang/Perl/Pangram-checker new file mode 120000 index 0000000000..e3290fc182 --- /dev/null +++ b/Lang/Perl/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Perl \ No newline at end of file diff --git a/Lang/Perl/Parametrized-SQL-statement b/Lang/Perl/Parametrized-SQL-statement new file mode 120000 index 0000000000..d3f4c5645f --- /dev/null +++ b/Lang/Perl/Parametrized-SQL-statement @@ -0,0 +1 @@ +../../Task/Parametrized-SQL-statement/Perl \ No newline at end of file diff --git a/Lang/Perl/Parsing-RPN-calculator-algorithm b/Lang/Perl/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..4b3083b376 --- /dev/null +++ b/Lang/Perl/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/Perl \ No newline at end of file diff --git a/Lang/Perl/Parsing-RPN-to-infix-conversion b/Lang/Perl/Parsing-RPN-to-infix-conversion new file mode 120000 index 0000000000..e6d7315580 --- /dev/null +++ b/Lang/Perl/Parsing-RPN-to-infix-conversion @@ -0,0 +1 @@ +../../Task/Parsing-RPN-to-infix-conversion/Perl \ No newline at end of file diff --git a/Lang/Perl/Partial-function-application b/Lang/Perl/Partial-function-application new file mode 120000 index 0000000000..b503f3c930 --- /dev/null +++ b/Lang/Perl/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/Perl \ No newline at end of file diff --git a/Lang/Perl/Pascals-triangle b/Lang/Perl/Pascals-triangle new file mode 120000 index 0000000000..515d30446a --- /dev/null +++ b/Lang/Perl/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Perl \ No newline at end of file diff --git a/Lang/Perl/Perfect-numbers b/Lang/Perl/Perfect-numbers new file mode 120000 index 0000000000..30c24617e4 --- /dev/null +++ b/Lang/Perl/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Perl \ No newline at end of file diff --git a/Lang/Perl/Permutations b/Lang/Perl/Permutations new file mode 120000 index 0000000000..8d7817bec8 --- /dev/null +++ b/Lang/Perl/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Perl \ No newline at end of file diff --git a/Lang/Perl/Permutations-Derangements b/Lang/Perl/Permutations-Derangements new file mode 120000 index 0000000000..a9760d8bbd --- /dev/null +++ b/Lang/Perl/Permutations-Derangements @@ -0,0 +1 @@ +../../Task/Permutations-Derangements/Perl \ No newline at end of file diff --git a/Lang/Perl/Pick-random-element b/Lang/Perl/Pick-random-element new file mode 120000 index 0000000000..468714892e --- /dev/null +++ b/Lang/Perl/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/Perl \ No newline at end of file diff --git a/Lang/Perl/Playing-cards b/Lang/Perl/Playing-cards new file mode 120000 index 0000000000..84721257fc --- /dev/null +++ b/Lang/Perl/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/Perl \ No newline at end of file diff --git a/Lang/Perl/Plot-coordinate-pairs b/Lang/Perl/Plot-coordinate-pairs new file mode 120000 index 0000000000..20b56ee0ea --- /dev/null +++ b/Lang/Perl/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/Perl \ No newline at end of file diff --git a/Lang/Perl/Pointers-and-references b/Lang/Perl/Pointers-and-references new file mode 120000 index 0000000000..3adfe04432 --- /dev/null +++ b/Lang/Perl/Pointers-and-references @@ -0,0 +1 @@ +../../Task/Pointers-and-references/Perl \ No newline at end of file diff --git a/Lang/Perl/Polymorphic-copy b/Lang/Perl/Polymorphic-copy new file mode 120000 index 0000000000..37493f1e9f --- /dev/null +++ b/Lang/Perl/Polymorphic-copy @@ -0,0 +1 @@ +../../Task/Polymorphic-copy/Perl \ No newline at end of file diff --git a/Lang/Perl/Polymorphism b/Lang/Perl/Polymorphism new file mode 120000 index 0000000000..adfcaa953f --- /dev/null +++ b/Lang/Perl/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/Perl \ No newline at end of file diff --git a/Lang/Perl/Polynomial-long-division b/Lang/Perl/Polynomial-long-division new file mode 120000 index 0000000000..f9ea3ea04d --- /dev/null +++ b/Lang/Perl/Polynomial-long-division @@ -0,0 +1 @@ +../../Task/Polynomial-long-division/Perl \ No newline at end of file diff --git a/Lang/Perl/Power-set b/Lang/Perl/Power-set new file mode 120000 index 0000000000..f02c13a943 --- /dev/null +++ b/Lang/Perl/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Perl \ No newline at end of file diff --git a/Lang/Perl/Pragmatic-directives b/Lang/Perl/Pragmatic-directives new file mode 120000 index 0000000000..6a06f11eea --- /dev/null +++ b/Lang/Perl/Pragmatic-directives @@ -0,0 +1 @@ +../../Task/Pragmatic-directives/Perl \ No newline at end of file diff --git a/Lang/Perl/Price-fraction b/Lang/Perl/Price-fraction new file mode 120000 index 0000000000..d5e6e5940c --- /dev/null +++ b/Lang/Perl/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Perl \ No newline at end of file diff --git a/Lang/Perl/Primality-by-trial-division b/Lang/Perl/Primality-by-trial-division new file mode 120000 index 0000000000..66f2b9e1b9 --- /dev/null +++ b/Lang/Perl/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Perl \ No newline at end of file diff --git a/Lang/Perl/Prime-decomposition b/Lang/Perl/Prime-decomposition new file mode 120000 index 0000000000..d7d08df3ee --- /dev/null +++ b/Lang/Perl/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Perl \ No newline at end of file diff --git a/Lang/Perl/Priority-queue b/Lang/Perl/Priority-queue new file mode 120000 index 0000000000..b38644c5de --- /dev/null +++ b/Lang/Perl/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/Perl \ No newline at end of file diff --git a/Lang/Perl/Probabilistic-choice b/Lang/Perl/Probabilistic-choice new file mode 120000 index 0000000000..38e0000a83 --- /dev/null +++ b/Lang/Perl/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/Perl \ No newline at end of file diff --git a/Lang/Perl/Program-name b/Lang/Perl/Program-name new file mode 120000 index 0000000000..3903317a41 --- /dev/null +++ b/Lang/Perl/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Perl \ No newline at end of file diff --git a/Lang/Perl/Program-termination b/Lang/Perl/Program-termination new file mode 120000 index 0000000000..995e2aa509 --- /dev/null +++ b/Lang/Perl/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Perl \ No newline at end of file diff --git a/Lang/Perl/Quaternion-type b/Lang/Perl/Quaternion-type new file mode 120000 index 0000000000..6c26830ce6 --- /dev/null +++ b/Lang/Perl/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/Perl \ No newline at end of file diff --git a/Lang/Perl/Queue-Definition b/Lang/Perl/Queue-Definition new file mode 120000 index 0000000000..c9501e0521 --- /dev/null +++ b/Lang/Perl/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/Perl \ No newline at end of file diff --git a/Lang/Perl/Queue-Usage b/Lang/Perl/Queue-Usage new file mode 120000 index 0000000000..79114443b0 --- /dev/null +++ b/Lang/Perl/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/Perl \ No newline at end of file diff --git a/Lang/Perl/Random-number-generator--device- b/Lang/Perl/Random-number-generator--device- new file mode 120000 index 0000000000..4ca99c431f --- /dev/null +++ b/Lang/Perl/Random-number-generator--device- @@ -0,0 +1 @@ +../../Task/Random-number-generator--device-/Perl \ No newline at end of file diff --git a/Lang/Perl/Random-numbers b/Lang/Perl/Random-numbers new file mode 120000 index 0000000000..7ee0f1f611 --- /dev/null +++ b/Lang/Perl/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Perl \ No newline at end of file diff --git a/Lang/Perl/Range-expansion b/Lang/Perl/Range-expansion new file mode 120000 index 0000000000..3c097c57dc --- /dev/null +++ b/Lang/Perl/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/Perl \ No newline at end of file diff --git a/Lang/Perl/Range-extraction b/Lang/Perl/Range-extraction new file mode 120000 index 0000000000..3c79d9a63b --- /dev/null +++ b/Lang/Perl/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/Perl \ No newline at end of file diff --git a/Lang/Perl/Rate-counter b/Lang/Perl/Rate-counter new file mode 120000 index 0000000000..09df5d39d2 --- /dev/null +++ b/Lang/Perl/Rate-counter @@ -0,0 +1 @@ +../../Task/Rate-counter/Perl \ No newline at end of file diff --git a/Lang/Perl/Ray-casting-algorithm b/Lang/Perl/Ray-casting-algorithm new file mode 120000 index 0000000000..80161f57fc --- /dev/null +++ b/Lang/Perl/Ray-casting-algorithm @@ -0,0 +1 @@ +../../Task/Ray-casting-algorithm/Perl \ No newline at end of file diff --git a/Lang/Perl/Read-a-configuration-file b/Lang/Perl/Read-a-configuration-file new file mode 120000 index 0000000000..8d85a10ec9 --- /dev/null +++ b/Lang/Perl/Read-a-configuration-file @@ -0,0 +1 @@ +../../Task/Read-a-configuration-file/Perl \ No newline at end of file diff --git a/Lang/Perl/Read-a-file-line-by-line b/Lang/Perl/Read-a-file-line-by-line new file mode 120000 index 0000000000..05b0a1b800 --- /dev/null +++ b/Lang/Perl/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Perl \ No newline at end of file diff --git a/Lang/Perl/Read-a-specific-line-from-a-file b/Lang/Perl/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..c5c39eaf4e --- /dev/null +++ b/Lang/Perl/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/Perl \ No newline at end of file diff --git a/Lang/Perl/Read-entire-file b/Lang/Perl/Read-entire-file new file mode 120000 index 0000000000..e86bf90228 --- /dev/null +++ b/Lang/Perl/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Perl \ No newline at end of file diff --git a/Lang/Perl/Real-constants-and-functions b/Lang/Perl/Real-constants-and-functions new file mode 120000 index 0000000000..7bbe0413d2 --- /dev/null +++ b/Lang/Perl/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Perl \ No newline at end of file diff --git a/Lang/Perl/Reduced-row-echelon-form b/Lang/Perl/Reduced-row-echelon-form new file mode 120000 index 0000000000..7517fadbfb --- /dev/null +++ b/Lang/Perl/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/Perl \ No newline at end of file diff --git a/Lang/Perl/Regular-expressions b/Lang/Perl/Regular-expressions new file mode 120000 index 0000000000..10c87e6ebd --- /dev/null +++ b/Lang/Perl/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Perl \ No newline at end of file diff --git a/Lang/Perl/Remove-duplicate-elements b/Lang/Perl/Remove-duplicate-elements new file mode 120000 index 0000000000..ece7753190 --- /dev/null +++ b/Lang/Perl/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Perl \ No newline at end of file diff --git a/Lang/Perl/Remove-lines-from-a-file b/Lang/Perl/Remove-lines-from-a-file new file mode 120000 index 0000000000..53c78edc9f --- /dev/null +++ b/Lang/Perl/Remove-lines-from-a-file @@ -0,0 +1 @@ +../../Task/Remove-lines-from-a-file/Perl \ No newline at end of file diff --git a/Lang/Perl/Rename-a-file b/Lang/Perl/Rename-a-file new file mode 120000 index 0000000000..8ce72a4aa9 --- /dev/null +++ b/Lang/Perl/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Perl \ No newline at end of file diff --git a/Lang/Perl/Repeat-a-string b/Lang/Perl/Repeat-a-string new file mode 120000 index 0000000000..621e51e648 --- /dev/null +++ b/Lang/Perl/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Perl \ No newline at end of file diff --git a/Lang/Perl/Resistor-mesh b/Lang/Perl/Resistor-mesh new file mode 120000 index 0000000000..3398c7624e --- /dev/null +++ b/Lang/Perl/Resistor-mesh @@ -0,0 +1 @@ +../../Task/Resistor-mesh/Perl \ No newline at end of file diff --git a/Lang/Perl/Respond-to-an-unknown-method-call b/Lang/Perl/Respond-to-an-unknown-method-call new file mode 120000 index 0000000000..6d919d2160 --- /dev/null +++ b/Lang/Perl/Respond-to-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Respond-to-an-unknown-method-call/Perl \ No newline at end of file diff --git a/Lang/Perl/Return-multiple-values b/Lang/Perl/Return-multiple-values new file mode 120000 index 0000000000..5c942594a3 --- /dev/null +++ b/Lang/Perl/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Perl \ No newline at end of file diff --git a/Lang/Perl/Reverse-a-string b/Lang/Perl/Reverse-a-string new file mode 120000 index 0000000000..0b2bf1668d --- /dev/null +++ b/Lang/Perl/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Perl \ No newline at end of file diff --git a/Lang/Perl/Roman-numerals-Decode b/Lang/Perl/Roman-numerals-Decode new file mode 120000 index 0000000000..13186f1ef6 --- /dev/null +++ b/Lang/Perl/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/Perl \ No newline at end of file diff --git a/Lang/Perl/Roman-numerals-Encode b/Lang/Perl/Roman-numerals-Encode new file mode 120000 index 0000000000..4b9c94cfe6 --- /dev/null +++ b/Lang/Perl/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Perl \ No newline at end of file diff --git a/Lang/Perl/Roots-of-a-function b/Lang/Perl/Roots-of-a-function new file mode 120000 index 0000000000..b55f313527 --- /dev/null +++ b/Lang/Perl/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/Perl \ No newline at end of file diff --git a/Lang/Perl/Roots-of-a-quadratic-function b/Lang/Perl/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..b9b02be12a --- /dev/null +++ b/Lang/Perl/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/Perl \ No newline at end of file diff --git a/Lang/Perl/Roots-of-unity b/Lang/Perl/Roots-of-unity new file mode 120000 index 0000000000..3b55e71db4 --- /dev/null +++ b/Lang/Perl/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/Perl \ No newline at end of file diff --git a/Lang/Perl/Rosetta-Code-Count-examples b/Lang/Perl/Rosetta-Code-Count-examples new file mode 120000 index 0000000000..7b3ef57551 --- /dev/null +++ b/Lang/Perl/Rosetta-Code-Count-examples @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Count-examples/Perl \ No newline at end of file diff --git a/Lang/Perl/Rosetta-Code-Find-unimplemented-tasks b/Lang/Perl/Rosetta-Code-Find-unimplemented-tasks new file mode 120000 index 0000000000..0e72c4d01e --- /dev/null +++ b/Lang/Perl/Rosetta-Code-Find-unimplemented-tasks @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Find-unimplemented-tasks/Perl \ No newline at end of file diff --git a/Lang/Perl/Rosetta-Code-Fix-code-tags b/Lang/Perl/Rosetta-Code-Fix-code-tags new file mode 120000 index 0000000000..9cc24cd62d --- /dev/null +++ b/Lang/Perl/Rosetta-Code-Fix-code-tags @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Fix-code-tags/Perl \ No newline at end of file diff --git a/Lang/Perl/Rosetta-Code-Rank-languages-by-popularity b/Lang/Perl/Rosetta-Code-Rank-languages-by-popularity new file mode 120000 index 0000000000..d1749cec95 --- /dev/null +++ b/Lang/Perl/Rosetta-Code-Rank-languages-by-popularity @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-popularity/Perl \ No newline at end of file diff --git a/Lang/Perl/Rot-13 b/Lang/Perl/Rot-13 new file mode 120000 index 0000000000..6428de6398 --- /dev/null +++ b/Lang/Perl/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Perl \ No newline at end of file diff --git a/Lang/Perl/Run-length-encoding b/Lang/Perl/Run-length-encoding new file mode 120000 index 0000000000..de7b189c81 --- /dev/null +++ b/Lang/Perl/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Perl \ No newline at end of file diff --git a/Lang/Perl/Runtime-evaluation b/Lang/Perl/Runtime-evaluation new file mode 120000 index 0000000000..c6c2ce79d0 --- /dev/null +++ b/Lang/Perl/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/Perl \ No newline at end of file diff --git a/Lang/Perl/Runtime-evaluation-In-an-environment b/Lang/Perl/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..6eda884818 --- /dev/null +++ b/Lang/Perl/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/Perl \ No newline at end of file diff --git a/Lang/Perl/S-Expressions b/Lang/Perl/S-Expressions new file mode 120000 index 0000000000..b34842fada --- /dev/null +++ b/Lang/Perl/S-Expressions @@ -0,0 +1 @@ +../../Task/S-Expressions/Perl \ No newline at end of file diff --git a/Lang/Perl/SEDOLs b/Lang/Perl/SEDOLs new file mode 120000 index 0000000000..00f3b5fd00 --- /dev/null +++ b/Lang/Perl/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/Perl \ No newline at end of file diff --git a/Lang/Perl/Scope-modifiers b/Lang/Perl/Scope-modifiers new file mode 120000 index 0000000000..fa510f45fa --- /dev/null +++ b/Lang/Perl/Scope-modifiers @@ -0,0 +1 @@ +../../Task/Scope-modifiers/Perl \ No newline at end of file diff --git a/Lang/Perl/Secure-temporary-file b/Lang/Perl/Secure-temporary-file new file mode 120000 index 0000000000..c2e5a961f1 --- /dev/null +++ b/Lang/Perl/Secure-temporary-file @@ -0,0 +1 @@ +../../Task/Secure-temporary-file/Perl \ No newline at end of file diff --git a/Lang/Perl/Self-describing-numbers b/Lang/Perl/Self-describing-numbers new file mode 120000 index 0000000000..a675994ee9 --- /dev/null +++ b/Lang/Perl/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/Perl \ No newline at end of file diff --git a/Lang/Perl/Self-referential-sequence b/Lang/Perl/Self-referential-sequence new file mode 120000 index 0000000000..298df6c33e --- /dev/null +++ b/Lang/Perl/Self-referential-sequence @@ -0,0 +1 @@ +../../Task/Self-referential-sequence/Perl \ No newline at end of file diff --git a/Lang/Perl/Semordnilap b/Lang/Perl/Semordnilap new file mode 120000 index 0000000000..a8b4977878 --- /dev/null +++ b/Lang/Perl/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/Perl \ No newline at end of file diff --git a/Lang/Perl/Send-an-unknown-method-call b/Lang/Perl/Send-an-unknown-method-call new file mode 120000 index 0000000000..82039e9436 --- /dev/null +++ b/Lang/Perl/Send-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Send-an-unknown-method-call/Perl \ No newline at end of file diff --git a/Lang/Perl/Send-email b/Lang/Perl/Send-email new file mode 120000 index 0000000000..33768af184 --- /dev/null +++ b/Lang/Perl/Send-email @@ -0,0 +1 @@ +../../Task/Send-email/Perl \ No newline at end of file diff --git a/Lang/Perl/Sequence-of-non-squares b/Lang/Perl/Sequence-of-non-squares new file mode 120000 index 0000000000..92325966d4 --- /dev/null +++ b/Lang/Perl/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Perl \ No newline at end of file diff --git a/Lang/Perl/Set b/Lang/Perl/Set new file mode 120000 index 0000000000..2911c98922 --- /dev/null +++ b/Lang/Perl/Set @@ -0,0 +1 @@ +../../Task/Set/Perl \ No newline at end of file diff --git a/Lang/Perl/Set-of-real-numbers b/Lang/Perl/Set-of-real-numbers new file mode 120000 index 0000000000..24de043445 --- /dev/null +++ b/Lang/Perl/Set-of-real-numbers @@ -0,0 +1 @@ +../../Task/Set-of-real-numbers/Perl \ No newline at end of file diff --git a/Lang/PicoLisp/Arbitrary-precision-integers--included- b/Lang/PicoLisp/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..38db36b44f --- /dev/null +++ b/Lang/PicoLisp/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Arbitrary-precision-integers-included b/Lang/PicoLisp/Arbitrary-precision-integers-included deleted file mode 120000 index 39a922253a..0000000000 --- a/Lang/PicoLisp/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Binary-digits b/Lang/PicoLisp/Binary-digits new file mode 120000 index 0000000000..30b8440cb3 --- /dev/null +++ b/Lang/PicoLisp/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Brownian-tree b/Lang/PicoLisp/Brownian-tree new file mode 120000 index 0000000000..c5be1dd320 --- /dev/null +++ b/Lang/PicoLisp/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/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..c49ce49cbc --- /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/Calendar-for-real-programmers b/Lang/PicoLisp/Calendar-for-real-programmers deleted file mode 120000 index cf80e6361b..0000000000 --- a/Lang/PicoLisp/Calendar-for-real-programmers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Calendar-for-real-programmers/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Catalan-numbers b/Lang/PicoLisp/Catalan-numbers new file mode 120000 index 0000000000..bb05e7916e --- /dev/null +++ b/Lang/PicoLisp/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Copy-a-string b/Lang/PicoLisp/Copy-a-string new file mode 120000 index 0000000000..2baac4edb7 --- /dev/null +++ b/Lang/PicoLisp/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Dragon-curve b/Lang/PicoLisp/Dragon-curve new file mode 120000 index 0000000000..abc0fb9fe4 --- /dev/null +++ b/Lang/PicoLisp/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Environment-variables b/Lang/PicoLisp/Environment-variables new file mode 120000 index 0000000000..c0afc2cbd7 --- /dev/null +++ b/Lang/PicoLisp/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Execute-a-Markov-algorithm b/Lang/PicoLisp/Execute-a-Markov-algorithm new file mode 120000 index 0000000000..4e00f71451 --- /dev/null +++ b/Lang/PicoLisp/Execute-a-Markov-algorithm @@ -0,0 +1 @@ +../../Task/Execute-a-Markov-algorithm/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Guess-the-number-With-feedback--player- b/Lang/PicoLisp/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..cd898a484d --- /dev/null +++ b/Lang/PicoLisp/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Guess-the-number-With-feedback-player b/Lang/PicoLisp/Guess-the-number-With-feedback-player deleted file mode 120000 index a0372b7f9a..0000000000 --- a/Lang/PicoLisp/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/N-queens-problem b/Lang/PicoLisp/N-queens-problem new file mode 120000 index 0000000000..04e5ece40a --- /dev/null +++ b/Lang/PicoLisp/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Named-parameters b/Lang/PicoLisp/Named-parameters new file mode 120000 index 0000000000..6fdd6e778f --- /dev/null +++ b/Lang/PicoLisp/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Non-continuous-subsequences b/Lang/PicoLisp/Non-continuous-subsequences new file mode 120000 index 0000000000..edc18a2f3f --- /dev/null +++ b/Lang/PicoLisp/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Non-decimal-radices-Convert b/Lang/PicoLisp/Non-decimal-radices-Convert new file mode 120000 index 0000000000..0f0b125e59 --- /dev/null +++ b/Lang/PicoLisp/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Non-decimal-radices-Input b/Lang/PicoLisp/Non-decimal-radices-Input new file mode 120000 index 0000000000..67fc082fd0 --- /dev/null +++ b/Lang/PicoLisp/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Non-decimal-radices-Output b/Lang/PicoLisp/Non-decimal-radices-Output new file mode 120000 index 0000000000..4238b7a91d --- /dev/null +++ b/Lang/PicoLisp/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Nth-root b/Lang/PicoLisp/Nth-root new file mode 120000 index 0000000000..851d1e3bd0 --- /dev/null +++ b/Lang/PicoLisp/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Null-object b/Lang/PicoLisp/Null-object new file mode 120000 index 0000000000..f083b369d7 --- /dev/null +++ b/Lang/PicoLisp/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Number-names b/Lang/PicoLisp/Number-names new file mode 120000 index 0000000000..f02ca43a46 --- /dev/null +++ b/Lang/PicoLisp/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Number-reversal-game b/Lang/PicoLisp/Number-reversal-game new file mode 120000 index 0000000000..9a92f09936 --- /dev/null +++ b/Lang/PicoLisp/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Numeric-error-propagation b/Lang/PicoLisp/Numeric-error-propagation new file mode 120000 index 0000000000..016213f063 --- /dev/null +++ b/Lang/PicoLisp/Numeric-error-propagation @@ -0,0 +1 @@ +../../Task/Numeric-error-propagation/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Numerical-integration b/Lang/PicoLisp/Numerical-integration new file mode 120000 index 0000000000..bf82a61971 --- /dev/null +++ b/Lang/PicoLisp/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Object-serialization b/Lang/PicoLisp/Object-serialization new file mode 120000 index 0000000000..278c0dfca6 --- /dev/null +++ b/Lang/PicoLisp/Object-serialization @@ -0,0 +1 @@ +../../Task/Object-serialization/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/One-dimensional-cellular-automata b/Lang/PicoLisp/One-dimensional-cellular-automata new file mode 120000 index 0000000000..67e2a91844 --- /dev/null +++ b/Lang/PicoLisp/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/One-of-n-lines-in-a-file b/Lang/PicoLisp/One-of-n-lines-in-a-file new file mode 120000 index 0000000000..050edcba8e --- /dev/null +++ b/Lang/PicoLisp/One-of-n-lines-in-a-file @@ -0,0 +1 @@ +../../Task/One-of-n-lines-in-a-file/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/OpenGL b/Lang/PicoLisp/OpenGL new file mode 120000 index 0000000000..568cec3f43 --- /dev/null +++ b/Lang/PicoLisp/OpenGL @@ -0,0 +1 @@ +../../Task/OpenGL/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Optional-parameters b/Lang/PicoLisp/Optional-parameters new file mode 120000 index 0000000000..af4e112113 --- /dev/null +++ b/Lang/PicoLisp/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Order-two-numerical-lists b/Lang/PicoLisp/Order-two-numerical-lists new file mode 120000 index 0000000000..ded2602bd8 --- /dev/null +++ b/Lang/PicoLisp/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Ordered-Partitions b/Lang/PicoLisp/Ordered-Partitions new file mode 120000 index 0000000000..efcd8d6880 --- /dev/null +++ b/Lang/PicoLisp/Ordered-Partitions @@ -0,0 +1 @@ +../../Task/Ordered-Partitions/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Palindrome-detection b/Lang/PicoLisp/Palindrome-detection new file mode 120000 index 0000000000..b22eeb30d7 --- /dev/null +++ b/Lang/PicoLisp/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Pangram-checker b/Lang/PicoLisp/Pangram-checker new file mode 120000 index 0000000000..058d4e86de --- /dev/null +++ b/Lang/PicoLisp/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Parallel-calculations b/Lang/PicoLisp/Parallel-calculations new file mode 120000 index 0000000000..9278b97279 --- /dev/null +++ b/Lang/PicoLisp/Parallel-calculations @@ -0,0 +1 @@ +../../Task/Parallel-calculations/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Parametric-polymorphism b/Lang/PicoLisp/Parametric-polymorphism new file mode 120000 index 0000000000..517afe1913 --- /dev/null +++ b/Lang/PicoLisp/Parametric-polymorphism @@ -0,0 +1 @@ +../../Task/Parametric-polymorphism/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Parametrized-SQL-statement b/Lang/PicoLisp/Parametrized-SQL-statement new file mode 120000 index 0000000000..5dd89ff82d --- /dev/null +++ b/Lang/PicoLisp/Parametrized-SQL-statement @@ -0,0 +1 @@ +../../Task/Parametrized-SQL-statement/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Parsing-RPN-calculator-algorithm b/Lang/PicoLisp/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..03ebbce6f4 --- /dev/null +++ b/Lang/PicoLisp/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Parsing-RPN-to-infix-conversion b/Lang/PicoLisp/Parsing-RPN-to-infix-conversion new file mode 120000 index 0000000000..d0efe5e095 --- /dev/null +++ b/Lang/PicoLisp/Parsing-RPN-to-infix-conversion @@ -0,0 +1 @@ +../../Task/Parsing-RPN-to-infix-conversion/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Parsing-Shunting-yard-algorithm b/Lang/PicoLisp/Parsing-Shunting-yard-algorithm new file mode 120000 index 0000000000..258d21a3fb --- /dev/null +++ b/Lang/PicoLisp/Parsing-Shunting-yard-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-Shunting-yard-algorithm/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Partial-function-application b/Lang/PicoLisp/Partial-function-application new file mode 120000 index 0000000000..b8f4d940e4 --- /dev/null +++ b/Lang/PicoLisp/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Pascals-triangle b/Lang/PicoLisp/Pascals-triangle new file mode 120000 index 0000000000..e47107447c --- /dev/null +++ b/Lang/PicoLisp/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Pascals-triangle-Puzzle b/Lang/PicoLisp/Pascals-triangle-Puzzle new file mode 120000 index 0000000000..a690fd829a --- /dev/null +++ b/Lang/PicoLisp/Pascals-triangle-Puzzle @@ -0,0 +1 @@ +../../Task/Pascals-triangle-Puzzle/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Pattern-matching b/Lang/PicoLisp/Pattern-matching new file mode 120000 index 0000000000..1c401c9f9d --- /dev/null +++ b/Lang/PicoLisp/Pattern-matching @@ -0,0 +1 @@ +../../Task/Pattern-matching/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Percentage-difference-between-images b/Lang/PicoLisp/Percentage-difference-between-images new file mode 120000 index 0000000000..d58458df91 --- /dev/null +++ b/Lang/PicoLisp/Percentage-difference-between-images @@ -0,0 +1 @@ +../../Task/Percentage-difference-between-images/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Perfect-numbers b/Lang/PicoLisp/Perfect-numbers new file mode 120000 index 0000000000..5db34753e0 --- /dev/null +++ b/Lang/PicoLisp/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Permutation-test b/Lang/PicoLisp/Permutation-test new file mode 120000 index 0000000000..d380b48e4c --- /dev/null +++ b/Lang/PicoLisp/Permutation-test @@ -0,0 +1 @@ +../../Task/Permutation-test/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Permutations b/Lang/PicoLisp/Permutations new file mode 120000 index 0000000000..5bfbf35fd0 --- /dev/null +++ b/Lang/PicoLisp/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Permutations-Derangements b/Lang/PicoLisp/Permutations-Derangements new file mode 120000 index 0000000000..d53b7e70e8 --- /dev/null +++ b/Lang/PicoLisp/Permutations-Derangements @@ -0,0 +1 @@ +../../Task/Permutations-Derangements/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Pick-random-element b/Lang/PicoLisp/Pick-random-element new file mode 120000 index 0000000000..d3a882a7de --- /dev/null +++ b/Lang/PicoLisp/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Pinstripe-Display b/Lang/PicoLisp/Pinstripe-Display new file mode 120000 index 0000000000..db0aa60e46 --- /dev/null +++ b/Lang/PicoLisp/Pinstripe-Display @@ -0,0 +1 @@ +../../Task/Pinstripe-Display/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Pinstripe-Printer b/Lang/PicoLisp/Pinstripe-Printer new file mode 120000 index 0000000000..d563416fea --- /dev/null +++ b/Lang/PicoLisp/Pinstripe-Printer @@ -0,0 +1 @@ +../../Task/Pinstripe-Printer/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Play-recorded-sounds b/Lang/PicoLisp/Play-recorded-sounds new file mode 120000 index 0000000000..170206d178 --- /dev/null +++ b/Lang/PicoLisp/Play-recorded-sounds @@ -0,0 +1 @@ +../../Task/Play-recorded-sounds/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Playing-cards b/Lang/PicoLisp/Playing-cards new file mode 120000 index 0000000000..2fe77f11a9 --- /dev/null +++ b/Lang/PicoLisp/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Plot-coordinate-pairs b/Lang/PicoLisp/Plot-coordinate-pairs new file mode 120000 index 0000000000..1246a72f3b --- /dev/null +++ b/Lang/PicoLisp/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Pointers-and-references b/Lang/PicoLisp/Pointers-and-references new file mode 120000 index 0000000000..920af76aeb --- /dev/null +++ b/Lang/PicoLisp/Pointers-and-references @@ -0,0 +1 @@ +../../Task/Pointers-and-references/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Polymorphic-copy b/Lang/PicoLisp/Polymorphic-copy new file mode 120000 index 0000000000..6ef1cc6ee3 --- /dev/null +++ b/Lang/PicoLisp/Polymorphic-copy @@ -0,0 +1 @@ +../../Task/Polymorphic-copy/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Polymorphism b/Lang/PicoLisp/Polymorphism new file mode 120000 index 0000000000..a92f918ad7 --- /dev/null +++ b/Lang/PicoLisp/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Polynomial-long-division b/Lang/PicoLisp/Polynomial-long-division new file mode 120000 index 0000000000..453f3608e7 --- /dev/null +++ b/Lang/PicoLisp/Polynomial-long-division @@ -0,0 +1 @@ +../../Task/Polynomial-long-division/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Power-set b/Lang/PicoLisp/Power-set new file mode 120000 index 0000000000..f1d46d8915 --- /dev/null +++ b/Lang/PicoLisp/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Price-fraction b/Lang/PicoLisp/Price-fraction new file mode 120000 index 0000000000..27966890c5 --- /dev/null +++ b/Lang/PicoLisp/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Primality-by-trial-division b/Lang/PicoLisp/Primality-by-trial-division new file mode 120000 index 0000000000..ff2526d00d --- /dev/null +++ b/Lang/PicoLisp/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Prime-decomposition b/Lang/PicoLisp/Prime-decomposition new file mode 120000 index 0000000000..86299eb6c5 --- /dev/null +++ b/Lang/PicoLisp/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Priority-queue b/Lang/PicoLisp/Priority-queue new file mode 120000 index 0000000000..046c71f39b --- /dev/null +++ b/Lang/PicoLisp/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Probabilistic-choice b/Lang/PicoLisp/Probabilistic-choice new file mode 120000 index 0000000000..9edbef38b9 --- /dev/null +++ b/Lang/PicoLisp/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Program-name b/Lang/PicoLisp/Program-name new file mode 120000 index 0000000000..86b8643488 --- /dev/null +++ b/Lang/PicoLisp/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Program-termination b/Lang/PicoLisp/Program-termination new file mode 120000 index 0000000000..dad607c4c4 --- /dev/null +++ b/Lang/PicoLisp/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Pythagorean-triples b/Lang/PicoLisp/Pythagorean-triples new file mode 120000 index 0000000000..b35415708a --- /dev/null +++ b/Lang/PicoLisp/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Quaternion-type b/Lang/PicoLisp/Quaternion-type new file mode 120000 index 0000000000..2120681801 --- /dev/null +++ b/Lang/PicoLisp/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Queue-Definition b/Lang/PicoLisp/Queue-Definition new file mode 120000 index 0000000000..3b473618e3 --- /dev/null +++ b/Lang/PicoLisp/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Queue-Usage b/Lang/PicoLisp/Queue-Usage new file mode 120000 index 0000000000..4779f7bb52 --- /dev/null +++ b/Lang/PicoLisp/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Random-number-generator--device- b/Lang/PicoLisp/Random-number-generator--device- new file mode 120000 index 0000000000..d519e3e28e --- /dev/null +++ b/Lang/PicoLisp/Random-number-generator--device- @@ -0,0 +1 @@ +../../Task/Random-number-generator--device-/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Random-numbers b/Lang/PicoLisp/Random-numbers new file mode 120000 index 0000000000..c4681aecd8 --- /dev/null +++ b/Lang/PicoLisp/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Range-expansion b/Lang/PicoLisp/Range-expansion new file mode 120000 index 0000000000..781347662d --- /dev/null +++ b/Lang/PicoLisp/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Range-extraction b/Lang/PicoLisp/Range-extraction new file mode 120000 index 0000000000..9fc1652bd8 --- /dev/null +++ b/Lang/PicoLisp/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Rate-counter b/Lang/PicoLisp/Rate-counter new file mode 120000 index 0000000000..ae0c3c60cd --- /dev/null +++ b/Lang/PicoLisp/Rate-counter @@ -0,0 +1 @@ +../../Task/Rate-counter/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Ray-casting-algorithm b/Lang/PicoLisp/Ray-casting-algorithm new file mode 120000 index 0000000000..08c706d0c8 --- /dev/null +++ b/Lang/PicoLisp/Ray-casting-algorithm @@ -0,0 +1 @@ +../../Task/Ray-casting-algorithm/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Read-a-configuration-file b/Lang/PicoLisp/Read-a-configuration-file new file mode 120000 index 0000000000..08f856c6ab --- /dev/null +++ b/Lang/PicoLisp/Read-a-configuration-file @@ -0,0 +1 @@ +../../Task/Read-a-configuration-file/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Read-a-file-line-by-line b/Lang/PicoLisp/Read-a-file-line-by-line new file mode 120000 index 0000000000..4c30867892 --- /dev/null +++ b/Lang/PicoLisp/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Read-a-specific-line-from-a-file b/Lang/PicoLisp/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..5250c1fd8a --- /dev/null +++ b/Lang/PicoLisp/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Read-entire-file b/Lang/PicoLisp/Read-entire-file new file mode 120000 index 0000000000..5fe5d63936 --- /dev/null +++ b/Lang/PicoLisp/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Real-constants-and-functions b/Lang/PicoLisp/Real-constants-and-functions new file mode 120000 index 0000000000..8569bfb56f --- /dev/null +++ b/Lang/PicoLisp/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Record-sound b/Lang/PicoLisp/Record-sound new file mode 120000 index 0000000000..0ed6953616 --- /dev/null +++ b/Lang/PicoLisp/Record-sound @@ -0,0 +1 @@ +../../Task/Record-sound/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Reduced-row-echelon-form b/Lang/PicoLisp/Reduced-row-echelon-form new file mode 120000 index 0000000000..2016d99530 --- /dev/null +++ b/Lang/PicoLisp/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Regular-expressions b/Lang/PicoLisp/Regular-expressions new file mode 120000 index 0000000000..aa788a17dd --- /dev/null +++ b/Lang/PicoLisp/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Remove-duplicate-elements b/Lang/PicoLisp/Remove-duplicate-elements new file mode 120000 index 0000000000..8904682523 --- /dev/null +++ b/Lang/PicoLisp/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Remove-lines-from-a-file b/Lang/PicoLisp/Remove-lines-from-a-file new file mode 120000 index 0000000000..66b5256765 --- /dev/null +++ b/Lang/PicoLisp/Remove-lines-from-a-file @@ -0,0 +1 @@ +../../Task/Remove-lines-from-a-file/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Rename-a-file b/Lang/PicoLisp/Rename-a-file new file mode 120000 index 0000000000..a04d8e252b --- /dev/null +++ b/Lang/PicoLisp/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Rendezvous b/Lang/PicoLisp/Rendezvous new file mode 120000 index 0000000000..c1e4f568f1 --- /dev/null +++ b/Lang/PicoLisp/Rendezvous @@ -0,0 +1 @@ +../../Task/Rendezvous/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Repeat-a-string b/Lang/PicoLisp/Repeat-a-string new file mode 120000 index 0000000000..c17acdda8a --- /dev/null +++ b/Lang/PicoLisp/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Respond-to-an-unknown-method-call b/Lang/PicoLisp/Respond-to-an-unknown-method-call new file mode 120000 index 0000000000..7c2bd5363b --- /dev/null +++ b/Lang/PicoLisp/Respond-to-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Respond-to-an-unknown-method-call/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Return-multiple-values b/Lang/PicoLisp/Return-multiple-values new file mode 120000 index 0000000000..7183862530 --- /dev/null +++ b/Lang/PicoLisp/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Reverse-a-string b/Lang/PicoLisp/Reverse-a-string new file mode 120000 index 0000000000..9969b2cf95 --- /dev/null +++ b/Lang/PicoLisp/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Rock-paper-scissors b/Lang/PicoLisp/Rock-paper-scissors new file mode 120000 index 0000000000..6626b8ba84 --- /dev/null +++ b/Lang/PicoLisp/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Roman-numerals-Decode b/Lang/PicoLisp/Roman-numerals-Decode new file mode 120000 index 0000000000..dcd0043757 --- /dev/null +++ b/Lang/PicoLisp/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Roman-numerals-Encode b/Lang/PicoLisp/Roman-numerals-Encode new file mode 120000 index 0000000000..18d1b5ffc4 --- /dev/null +++ b/Lang/PicoLisp/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Roots-of-a-function b/Lang/PicoLisp/Roots-of-a-function new file mode 120000 index 0000000000..26a345a302 --- /dev/null +++ b/Lang/PicoLisp/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Roots-of-a-quadratic-function b/Lang/PicoLisp/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..5bcc1cadbd --- /dev/null +++ b/Lang/PicoLisp/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Roots-of-unity b/Lang/PicoLisp/Roots-of-unity new file mode 120000 index 0000000000..022c4d4cc3 --- /dev/null +++ b/Lang/PicoLisp/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Rosetta-Code-Count-examples b/Lang/PicoLisp/Rosetta-Code-Count-examples new file mode 120000 index 0000000000..ed1164c47b --- /dev/null +++ b/Lang/PicoLisp/Rosetta-Code-Count-examples @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Count-examples/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Rosetta-Code-Find-unimplemented-tasks b/Lang/PicoLisp/Rosetta-Code-Find-unimplemented-tasks new file mode 120000 index 0000000000..bb0e9205ed --- /dev/null +++ b/Lang/PicoLisp/Rosetta-Code-Find-unimplemented-tasks @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Find-unimplemented-tasks/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Rosetta-Code-Fix-code-tags b/Lang/PicoLisp/Rosetta-Code-Fix-code-tags new file mode 120000 index 0000000000..835c48277c --- /dev/null +++ b/Lang/PicoLisp/Rosetta-Code-Fix-code-tags @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Fix-code-tags/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Rosetta-Code-Rank-languages-by-popularity b/Lang/PicoLisp/Rosetta-Code-Rank-languages-by-popularity new file mode 120000 index 0000000000..67fe9faec9 --- /dev/null +++ b/Lang/PicoLisp/Rosetta-Code-Rank-languages-by-popularity @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-popularity/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Rot-13 b/Lang/PicoLisp/Rot-13 new file mode 120000 index 0000000000..6afa8921cf --- /dev/null +++ b/Lang/PicoLisp/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Run-length-encoding b/Lang/PicoLisp/Run-length-encoding new file mode 120000 index 0000000000..f2b4c711c4 --- /dev/null +++ b/Lang/PicoLisp/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Runtime-evaluation-In-an-environment b/Lang/PicoLisp/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..e5a32613b6 --- /dev/null +++ b/Lang/PicoLisp/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/S-Expressions b/Lang/PicoLisp/S-Expressions new file mode 120000 index 0000000000..6b95687480 --- /dev/null +++ b/Lang/PicoLisp/S-Expressions @@ -0,0 +1 @@ +../../Task/S-Expressions/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/SEDOLs b/Lang/PicoLisp/SEDOLs new file mode 120000 index 0000000000..6c1d05c2bc --- /dev/null +++ b/Lang/PicoLisp/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Same-Fringe b/Lang/PicoLisp/Same-Fringe new file mode 120000 index 0000000000..d17b02853e --- /dev/null +++ b/Lang/PicoLisp/Same-Fringe @@ -0,0 +1 @@ +../../Task/Same-Fringe/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Secure-temporary-file b/Lang/PicoLisp/Secure-temporary-file new file mode 120000 index 0000000000..6ef3c443ee --- /dev/null +++ b/Lang/PicoLisp/Secure-temporary-file @@ -0,0 +1 @@ +../../Task/Secure-temporary-file/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Self-describing-numbers b/Lang/PicoLisp/Self-describing-numbers new file mode 120000 index 0000000000..1d3da8b94b --- /dev/null +++ b/Lang/PicoLisp/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Self-referential-sequence b/Lang/PicoLisp/Self-referential-sequence new file mode 120000 index 0000000000..1e8c5a0a00 --- /dev/null +++ b/Lang/PicoLisp/Self-referential-sequence @@ -0,0 +1 @@ +../../Task/Self-referential-sequence/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Send-an-unknown-method-call b/Lang/PicoLisp/Send-an-unknown-method-call new file mode 120000 index 0000000000..934dc796c5 --- /dev/null +++ b/Lang/PicoLisp/Send-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Send-an-unknown-method-call/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Send-email b/Lang/PicoLisp/Send-email new file mode 120000 index 0000000000..d5f622bc28 --- /dev/null +++ b/Lang/PicoLisp/Send-email @@ -0,0 +1 @@ +../../Task/Send-email/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Sequence-of-non-squares b/Lang/PicoLisp/Sequence-of-non-squares new file mode 120000 index 0000000000..904760b430 --- /dev/null +++ b/Lang/PicoLisp/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Set b/Lang/PicoLisp/Set new file mode 120000 index 0000000000..74ec2443c2 --- /dev/null +++ b/Lang/PicoLisp/Set @@ -0,0 +1 @@ +../../Task/Set/PicoLisp \ No newline at end of file diff --git a/Lang/PicoLisp/Set-consolidation b/Lang/PicoLisp/Set-consolidation new file mode 120000 index 0000000000..4929c7e3ba --- /dev/null +++ b/Lang/PicoLisp/Set-consolidation @@ -0,0 +1 @@ +../../Task/Set-consolidation/PicoLisp \ No newline at end of file diff --git a/Lang/Pike/Arbitrary-precision-integers--included- b/Lang/Pike/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..5b528d9d23 --- /dev/null +++ b/Lang/Pike/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Pike \ No newline at end of file diff --git a/Lang/Pike/Arbitrary-precision-integers-included b/Lang/Pike/Arbitrary-precision-integers-included deleted file mode 120000 index 3309bbf95d..0000000000 --- a/Lang/Pike/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Pike \ No newline at end of file diff --git a/Lang/Pike/Copy-a-string b/Lang/Pike/Copy-a-string new file mode 120000 index 0000000000..784afd833b --- /dev/null +++ b/Lang/Pike/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Pike \ No newline at end of file diff --git a/Lang/Pike/Null-object b/Lang/Pike/Null-object new file mode 120000 index 0000000000..5705834c1d --- /dev/null +++ b/Lang/Pike/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Pike \ No newline at end of file diff --git a/Lang/Pike/OpenGL b/Lang/Pike/OpenGL new file mode 120000 index 0000000000..b911cda5ea --- /dev/null +++ b/Lang/Pike/OpenGL @@ -0,0 +1 @@ +../../Task/OpenGL/Pike \ No newline at end of file diff --git a/Lang/Pike/Order-two-numerical-lists b/Lang/Pike/Order-two-numerical-lists new file mode 120000 index 0000000000..3c068ce97d --- /dev/null +++ b/Lang/Pike/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/Pike \ No newline at end of file diff --git a/Lang/Pike/Palindrome-detection b/Lang/Pike/Palindrome-detection new file mode 120000 index 0000000000..641095e298 --- /dev/null +++ b/Lang/Pike/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Pike \ No newline at end of file diff --git a/Lang/Pike/Read-entire-file b/Lang/Pike/Read-entire-file new file mode 120000 index 0000000000..8f07fad47a --- /dev/null +++ b/Lang/Pike/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Pike \ No newline at end of file diff --git a/Lang/Pike/Rename-a-file b/Lang/Pike/Rename-a-file new file mode 120000 index 0000000000..28acc8448a --- /dev/null +++ b/Lang/Pike/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Pike \ No newline at end of file diff --git a/Lang/Pike/Repeat-a-string b/Lang/Pike/Repeat-a-string new file mode 120000 index 0000000000..445380faa3 --- /dev/null +++ b/Lang/Pike/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Pike \ No newline at end of file diff --git a/Lang/Pike/Respond-to-an-unknown-method-call b/Lang/Pike/Respond-to-an-unknown-method-call new file mode 120000 index 0000000000..b5ecb4ba56 --- /dev/null +++ b/Lang/Pike/Respond-to-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Respond-to-an-unknown-method-call/Pike \ No newline at end of file diff --git a/Lang/Pike/Return-multiple-values b/Lang/Pike/Return-multiple-values new file mode 120000 index 0000000000..75cfe5b1ef --- /dev/null +++ b/Lang/Pike/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Pike \ No newline at end of file diff --git a/Lang/Pike/Roman-numerals-Encode b/Lang/Pike/Roman-numerals-Encode new file mode 120000 index 0000000000..c849359f69 --- /dev/null +++ b/Lang/Pike/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Pike \ No newline at end of file diff --git a/Lang/Pike/Rot-13 b/Lang/Pike/Rot-13 new file mode 120000 index 0000000000..341ab98259 --- /dev/null +++ b/Lang/Pike/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Pike \ No newline at end of file diff --git a/Lang/Pike/Runtime-evaluation b/Lang/Pike/Runtime-evaluation new file mode 120000 index 0000000000..eddaca7e1a --- /dev/null +++ b/Lang/Pike/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/Pike \ No newline at end of file diff --git a/Lang/Pike/Runtime-evaluation-In-an-environment b/Lang/Pike/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..9f0793cb12 --- /dev/null +++ b/Lang/Pike/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/Pike \ No newline at end of file diff --git a/Lang/Pike/S-Expressions b/Lang/Pike/S-Expressions new file mode 120000 index 0000000000..2832af8a69 --- /dev/null +++ b/Lang/Pike/S-Expressions @@ -0,0 +1 @@ +../../Task/S-Expressions/Pike \ No newline at end of file diff --git a/Lang/Pike/Send-an-unknown-method-call b/Lang/Pike/Send-an-unknown-method-call new file mode 120000 index 0000000000..d94d5b2a3a --- /dev/null +++ b/Lang/Pike/Send-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Send-an-unknown-method-call/Pike \ No newline at end of file diff --git a/Lang/Pike/Send-email b/Lang/Pike/Send-email new file mode 120000 index 0000000000..bc3a91d8f1 --- /dev/null +++ b/Lang/Pike/Send-email @@ -0,0 +1 @@ +../../Task/Send-email/Pike \ No newline at end of file diff --git a/Lang/PlainTeX/Catalan-numbers b/Lang/PlainTeX/Catalan-numbers new file mode 120000 index 0000000000..2267dc7058 --- /dev/null +++ b/Lang/PlainTeX/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/PlainTeX \ No newline at end of file diff --git a/Lang/Pop11/Copy-a-string b/Lang/Pop11/Copy-a-string new file mode 120000 index 0000000000..ba8d6bbed5 --- /dev/null +++ b/Lang/Pop11/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Pop11 \ No newline at end of file diff --git a/Lang/Pop11/Non-continuous-subsequences b/Lang/Pop11/Non-continuous-subsequences new file mode 120000 index 0000000000..dd70149263 --- /dev/null +++ b/Lang/Pop11/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/Pop11 \ No newline at end of file diff --git a/Lang/Pop11/Non-decimal-radices-Convert b/Lang/Pop11/Non-decimal-radices-Convert new file mode 120000 index 0000000000..318d5fc140 --- /dev/null +++ b/Lang/Pop11/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/Pop11 \ No newline at end of file diff --git a/Lang/Pop11/Polymorphism b/Lang/Pop11/Polymorphism new file mode 120000 index 0000000000..f32e644d8f --- /dev/null +++ b/Lang/Pop11/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/Pop11 \ No newline at end of file diff --git a/Lang/Pop11/Program-termination b/Lang/Pop11/Program-termination new file mode 120000 index 0000000000..4ad91f549a --- /dev/null +++ b/Lang/Pop11/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Pop11 \ No newline at end of file diff --git a/Lang/Pop11/Random-numbers b/Lang/Pop11/Random-numbers new file mode 120000 index 0000000000..3960bd882e --- /dev/null +++ b/Lang/Pop11/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Pop11 \ No newline at end of file diff --git a/Lang/Pop11/Real-constants-and-functions b/Lang/Pop11/Real-constants-and-functions new file mode 120000 index 0000000000..25d425194b --- /dev/null +++ b/Lang/Pop11/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Pop11 \ No newline at end of file diff --git a/Lang/Pop11/Remove-duplicate-elements b/Lang/Pop11/Remove-duplicate-elements new file mode 120000 index 0000000000..9e2f64df2a --- /dev/null +++ b/Lang/Pop11/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Pop11 \ No newline at end of file diff --git a/Lang/Pop11/Rename-a-file b/Lang/Pop11/Rename-a-file new file mode 120000 index 0000000000..333659b7b9 --- /dev/null +++ b/Lang/Pop11/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Pop11 \ No newline at end of file diff --git a/Lang/Pop11/Reverse-a-string b/Lang/Pop11/Reverse-a-string new file mode 120000 index 0000000000..0098df8778 --- /dev/null +++ b/Lang/Pop11/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Pop11 \ No newline at end of file diff --git a/Lang/Pop11/Rot-13 b/Lang/Pop11/Rot-13 new file mode 120000 index 0000000000..199aa194b2 --- /dev/null +++ b/Lang/Pop11/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Pop11 \ No newline at end of file diff --git a/Lang/PostScript/Copy-a-string b/Lang/PostScript/Copy-a-string new file mode 120000 index 0000000000..8cc1c3a8c0 --- /dev/null +++ b/Lang/PostScript/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/PostScript \ No newline at end of file diff --git a/Lang/PostScript/Dragon-curve b/Lang/PostScript/Dragon-curve new file mode 120000 index 0000000000..c3ec4dcabb --- /dev/null +++ b/Lang/PostScript/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/PostScript \ No newline at end of file diff --git a/Lang/PostScript/Plot-coordinate-pairs b/Lang/PostScript/Plot-coordinate-pairs new file mode 120000 index 0000000000..0fd1012b40 --- /dev/null +++ b/Lang/PostScript/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/PostScript \ No newline at end of file diff --git a/Lang/PostScript/Program-termination b/Lang/PostScript/Program-termination new file mode 120000 index 0000000000..2b15b89549 --- /dev/null +++ b/Lang/PostScript/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/PostScript \ No newline at end of file diff --git a/Lang/PostScript/Queue-Definition b/Lang/PostScript/Queue-Definition new file mode 120000 index 0000000000..1d1930f078 --- /dev/null +++ b/Lang/PostScript/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/PostScript \ No newline at end of file diff --git a/Lang/PostScript/Queue-Usage b/Lang/PostScript/Queue-Usage new file mode 120000 index 0000000000..7d68cd9d80 --- /dev/null +++ b/Lang/PostScript/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/PostScript \ No newline at end of file diff --git a/Lang/PostScript/Remove-duplicate-elements b/Lang/PostScript/Remove-duplicate-elements new file mode 120000 index 0000000000..abb49a0669 --- /dev/null +++ b/Lang/PostScript/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/PostScript \ No newline at end of file diff --git a/Lang/PostScript/Repeat-a-string b/Lang/PostScript/Repeat-a-string new file mode 120000 index 0000000000..22113abc80 --- /dev/null +++ b/Lang/PostScript/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/PostScript \ No newline at end of file diff --git a/Lang/PostScript/Reverse-a-string b/Lang/PostScript/Reverse-a-string new file mode 120000 index 0000000000..e43dea5ddf --- /dev/null +++ b/Lang/PostScript/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/PostScript \ No newline at end of file diff --git a/Lang/PostScript/Rot-13 b/Lang/PostScript/Rot-13 new file mode 120000 index 0000000000..c439d5e4b0 --- /dev/null +++ b/Lang/PostScript/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/PostScript \ No newline at end of file diff --git a/Lang/PostScript/Sequence-of-non-squares b/Lang/PostScript/Sequence-of-non-squares new file mode 120000 index 0000000000..162d7a5460 --- /dev/null +++ b/Lang/PostScript/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/PostScript \ No newline at end of file diff --git a/Lang/PowerBASIC/N-queens-problem b/Lang/PowerBASIC/N-queens-problem new file mode 120000 index 0000000000..48e0f147ef --- /dev/null +++ b/Lang/PowerBASIC/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/PowerBASIC \ No newline at end of file diff --git a/Lang/PowerBASIC/Number-names b/Lang/PowerBASIC/Number-names new file mode 120000 index 0000000000..8db3fecd1f --- /dev/null +++ b/Lang/PowerBASIC/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/PowerBASIC \ No newline at end of file diff --git a/Lang/PowerBASIC/Palindrome-detection b/Lang/PowerBASIC/Palindrome-detection new file mode 120000 index 0000000000..5cb0acf872 --- /dev/null +++ b/Lang/PowerBASIC/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/PowerBASIC \ No newline at end of file diff --git a/Lang/PowerBASIC/Permutations b/Lang/PowerBASIC/Permutations new file mode 120000 index 0000000000..fbe4ebf90f --- /dev/null +++ b/Lang/PowerBASIC/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/PowerBASIC \ No newline at end of file diff --git a/Lang/PowerBASIC/Program-name b/Lang/PowerBASIC/Program-name new file mode 120000 index 0000000000..744edb77b0 --- /dev/null +++ b/Lang/PowerBASIC/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/PowerBASIC \ No newline at end of file diff --git a/Lang/PowerBASIC/Remove-lines-from-a-file b/Lang/PowerBASIC/Remove-lines-from-a-file new file mode 120000 index 0000000000..813c171e77 --- /dev/null +++ b/Lang/PowerBASIC/Remove-lines-from-a-file @@ -0,0 +1 @@ +../../Task/Remove-lines-from-a-file/PowerBASIC \ No newline at end of file diff --git a/Lang/PowerBASIC/Repeat-a-string b/Lang/PowerBASIC/Repeat-a-string new file mode 120000 index 0000000000..b02d6a9ba7 --- /dev/null +++ b/Lang/PowerBASIC/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/PowerBASIC \ No newline at end of file diff --git a/Lang/PowerBASIC/Roman-numerals-Encode b/Lang/PowerBASIC/Roman-numerals-Encode new file mode 120000 index 0000000000..c9ce44963c --- /dev/null +++ b/Lang/PowerBASIC/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/PowerBASIC \ No newline at end of file diff --git a/Lang/PowerBASIC/Run-length-encoding b/Lang/PowerBASIC/Run-length-encoding new file mode 120000 index 0000000000..7799b79573 --- /dev/null +++ b/Lang/PowerBASIC/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/PowerBASIC \ No newline at end of file diff --git a/Lang/PowerShell/Binary-digits b/Lang/PowerShell/Binary-digits new file mode 120000 index 0000000000..3ef026e414 --- /dev/null +++ b/Lang/PowerShell/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/PowerShell \ No newline at end of file diff --git a/Lang/PowerShell/Copy-a-string b/Lang/PowerShell/Copy-a-string new file mode 120000 index 0000000000..a5237e6645 --- /dev/null +++ b/Lang/PowerShell/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/PowerShell \ No newline at end of file diff --git a/Lang/PowerShell/Environment-variables b/Lang/PowerShell/Environment-variables new file mode 120000 index 0000000000..9e910f1d4b --- /dev/null +++ b/Lang/PowerShell/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/PowerShell \ No newline at end of file diff --git a/Lang/PowerShell/Named-parameters b/Lang/PowerShell/Named-parameters new file mode 120000 index 0000000000..3d1de1878e --- /dev/null +++ b/Lang/PowerShell/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/PowerShell \ No newline at end of file diff --git a/Lang/PowerShell/Non-continuous-subsequences b/Lang/PowerShell/Non-continuous-subsequences new file mode 120000 index 0000000000..eac62e20e3 --- /dev/null +++ b/Lang/PowerShell/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/PowerShell \ No newline at end of file diff --git a/Lang/PowerShell/Non-decimal-radices-Output b/Lang/PowerShell/Non-decimal-radices-Output new file mode 120000 index 0000000000..46528ece17 --- /dev/null +++ b/Lang/PowerShell/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/PowerShell \ No newline at end of file diff --git a/Lang/PowerShell/Null-object b/Lang/PowerShell/Null-object new file mode 120000 index 0000000000..6d30e53e8a --- /dev/null +++ b/Lang/PowerShell/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/PowerShell \ No newline at end of file diff --git a/Lang/PowerShell/Pascals-triangle b/Lang/PowerShell/Pascals-triangle new file mode 120000 index 0000000000..2e595f8182 --- /dev/null +++ b/Lang/PowerShell/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/PowerShell \ No newline at end of file diff --git a/Lang/PowerShell/Perfect-numbers b/Lang/PowerShell/Perfect-numbers new file mode 120000 index 0000000000..5393f070e1 --- /dev/null +++ b/Lang/PowerShell/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/PowerShell \ No newline at end of file diff --git a/Lang/PowerShell/Primality-by-trial-division b/Lang/PowerShell/Primality-by-trial-division new file mode 120000 index 0000000000..71ef2750dc --- /dev/null +++ b/Lang/PowerShell/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/PowerShell \ No newline at end of file diff --git a/Lang/PowerShell/Program-termination b/Lang/PowerShell/Program-termination new file mode 120000 index 0000000000..2c92a77751 --- /dev/null +++ b/Lang/PowerShell/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/PowerShell \ No newline at end of file diff --git a/Lang/PowerShell/Read-entire-file b/Lang/PowerShell/Read-entire-file new file mode 120000 index 0000000000..f4a37e9df8 --- /dev/null +++ b/Lang/PowerShell/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/PowerShell \ No newline at end of file diff --git a/Lang/PowerShell/Real-constants-and-functions b/Lang/PowerShell/Real-constants-and-functions new file mode 120000 index 0000000000..6115d67c6a --- /dev/null +++ b/Lang/PowerShell/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/PowerShell \ No newline at end of file diff --git a/Lang/PowerShell/Regular-expressions b/Lang/PowerShell/Regular-expressions new file mode 120000 index 0000000000..d0b6b2d58a --- /dev/null +++ b/Lang/PowerShell/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/PowerShell \ No newline at end of file diff --git a/Lang/PowerShell/Remove-duplicate-elements b/Lang/PowerShell/Remove-duplicate-elements new file mode 120000 index 0000000000..25b8b50bfa --- /dev/null +++ b/Lang/PowerShell/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/PowerShell \ No newline at end of file diff --git a/Lang/PowerShell/Rename-a-file b/Lang/PowerShell/Rename-a-file new file mode 120000 index 0000000000..7ed1b28693 --- /dev/null +++ b/Lang/PowerShell/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/PowerShell \ No newline at end of file diff --git a/Lang/PowerShell/Repeat-a-string b/Lang/PowerShell/Repeat-a-string new file mode 120000 index 0000000000..7f9cfba278 --- /dev/null +++ b/Lang/PowerShell/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/PowerShell \ No newline at end of file diff --git a/Lang/PowerShell/Reverse-a-string b/Lang/PowerShell/Reverse-a-string new file mode 120000 index 0000000000..c43d8f413a --- /dev/null +++ b/Lang/PowerShell/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/PowerShell \ No newline at end of file diff --git a/Lang/PowerShell/Rot-13 b/Lang/PowerShell/Rot-13 new file mode 120000 index 0000000000..b75ae7dc11 --- /dev/null +++ b/Lang/PowerShell/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/PowerShell \ No newline at end of file diff --git a/Lang/PowerShell/Run-length-encoding b/Lang/PowerShell/Run-length-encoding new file mode 120000 index 0000000000..1695062639 --- /dev/null +++ b/Lang/PowerShell/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/PowerShell \ No newline at end of file diff --git a/Lang/PowerShell/Scope-modifiers b/Lang/PowerShell/Scope-modifiers new file mode 120000 index 0000000000..c8cc78783b --- /dev/null +++ b/Lang/PowerShell/Scope-modifiers @@ -0,0 +1 @@ +../../Task/Scope-modifiers/PowerShell \ No newline at end of file diff --git a/Lang/PowerShell/Sequence-of-non-squares b/Lang/PowerShell/Sequence-of-non-squares new file mode 120000 index 0000000000..a7a9ba5914 --- /dev/null +++ b/Lang/PowerShell/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/PowerShell \ No newline at end of file diff --git a/Lang/ProDOS/Copy-a-string b/Lang/ProDOS/Copy-a-string new file mode 120000 index 0000000000..b83260f903 --- /dev/null +++ b/Lang/ProDOS/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/ProDOS \ No newline at end of file diff --git a/Lang/ProDOS/Random-number-generator--device- b/Lang/ProDOS/Random-number-generator--device- new file mode 120000 index 0000000000..ad7db73733 --- /dev/null +++ b/Lang/ProDOS/Random-number-generator--device- @@ -0,0 +1 @@ +../../Task/Random-number-generator--device-/ProDOS \ No newline at end of file diff --git a/Lang/ProDOS/Rename-a-file b/Lang/ProDOS/Rename-a-file new file mode 120000 index 0000000000..c2165eafb3 --- /dev/null +++ b/Lang/ProDOS/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/ProDOS \ No newline at end of file diff --git a/Lang/Prolog/Catalan-numbers b/Lang/Prolog/Catalan-numbers new file mode 120000 index 0000000000..010b509392 --- /dev/null +++ b/Lang/Prolog/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Dragon-curve b/Lang/Prolog/Dragon-curve new file mode 120000 index 0000000000..065f1deacb --- /dev/null +++ b/Lang/Prolog/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/Prolog \ No newline at end of file diff --git a/Lang/Prolog/N-queens-problem b/Lang/Prolog/N-queens-problem new file mode 120000 index 0000000000..463751c370 --- /dev/null +++ b/Lang/Prolog/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Non-continuous-subsequences b/Lang/Prolog/Non-continuous-subsequences new file mode 120000 index 0000000000..611567f219 --- /dev/null +++ b/Lang/Prolog/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/Prolog \ No newline at end of file diff --git a/Lang/Prolog/One-dimensional-cellular-automata b/Lang/Prolog/One-dimensional-cellular-automata new file mode 120000 index 0000000000..4cad26b6d0 --- /dev/null +++ b/Lang/Prolog/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Palindrome-detection b/Lang/Prolog/Palindrome-detection new file mode 120000 index 0000000000..7cec5ab9d6 --- /dev/null +++ b/Lang/Prolog/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Pangram-checker b/Lang/Prolog/Pangram-checker new file mode 120000 index 0000000000..cbd67fdcee --- /dev/null +++ b/Lang/Prolog/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Parallel-calculations b/Lang/Prolog/Parallel-calculations new file mode 120000 index 0000000000..4703070433 --- /dev/null +++ b/Lang/Prolog/Parallel-calculations @@ -0,0 +1 @@ +../../Task/Parallel-calculations/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Parsing-RPN-calculator-algorithm b/Lang/Prolog/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..7319019fb5 --- /dev/null +++ b/Lang/Prolog/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Partial-function-application b/Lang/Prolog/Partial-function-application new file mode 120000 index 0000000000..6ae28767ce --- /dev/null +++ b/Lang/Prolog/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Pascals-triangle b/Lang/Prolog/Pascals-triangle new file mode 120000 index 0000000000..48551d8c91 --- /dev/null +++ b/Lang/Prolog/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Pascals-triangle-Puzzle b/Lang/Prolog/Pascals-triangle-Puzzle new file mode 120000 index 0000000000..0c91324c2c --- /dev/null +++ b/Lang/Prolog/Pascals-triangle-Puzzle @@ -0,0 +1 @@ +../../Task/Pascals-triangle-Puzzle/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Perfect-numbers b/Lang/Prolog/Perfect-numbers new file mode 120000 index 0000000000..ff37152e2d --- /dev/null +++ b/Lang/Prolog/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Permutations b/Lang/Prolog/Permutations new file mode 120000 index 0000000000..ffc84c73d3 --- /dev/null +++ b/Lang/Prolog/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Playing-cards b/Lang/Prolog/Playing-cards new file mode 120000 index 0000000000..4c045e8d84 --- /dev/null +++ b/Lang/Prolog/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Power-set b/Lang/Prolog/Power-set new file mode 120000 index 0000000000..14c11f502e --- /dev/null +++ b/Lang/Prolog/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Primality-by-trial-division b/Lang/Prolog/Primality-by-trial-division new file mode 120000 index 0000000000..89eec36cdb --- /dev/null +++ b/Lang/Prolog/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Prime-decomposition b/Lang/Prolog/Prime-decomposition new file mode 120000 index 0000000000..525fb04fba --- /dev/null +++ b/Lang/Prolog/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Priority-queue b/Lang/Prolog/Priority-queue new file mode 120000 index 0000000000..fc3b203f0e --- /dev/null +++ b/Lang/Prolog/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Program-termination b/Lang/Prolog/Program-termination new file mode 120000 index 0000000000..9f47fc61ec --- /dev/null +++ b/Lang/Prolog/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Queue-Definition b/Lang/Prolog/Queue-Definition new file mode 120000 index 0000000000..1e6657dcfc --- /dev/null +++ b/Lang/Prolog/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Queue-Usage b/Lang/Prolog/Queue-Usage new file mode 120000 index 0000000000..2aa8deafb9 --- /dev/null +++ b/Lang/Prolog/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Range-expansion b/Lang/Prolog/Range-expansion new file mode 120000 index 0000000000..ee39124dd3 --- /dev/null +++ b/Lang/Prolog/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Range-extraction b/Lang/Prolog/Range-extraction new file mode 120000 index 0000000000..1557b0239f --- /dev/null +++ b/Lang/Prolog/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Remove-duplicate-elements b/Lang/Prolog/Remove-duplicate-elements new file mode 120000 index 0000000000..b94efa1b16 --- /dev/null +++ b/Lang/Prolog/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Repeat-a-string b/Lang/Prolog/Repeat-a-string new file mode 120000 index 0000000000..42a32ea559 --- /dev/null +++ b/Lang/Prolog/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Reverse-a-string b/Lang/Prolog/Reverse-a-string new file mode 120000 index 0000000000..889a55d97c --- /dev/null +++ b/Lang/Prolog/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Roman-numerals-Decode b/Lang/Prolog/Roman-numerals-Decode new file mode 120000 index 0000000000..d092db27d8 --- /dev/null +++ b/Lang/Prolog/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Roman-numerals-Encode b/Lang/Prolog/Roman-numerals-Encode new file mode 120000 index 0000000000..0a77fafdaa --- /dev/null +++ b/Lang/Prolog/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Rot-13 b/Lang/Prolog/Rot-13 new file mode 120000 index 0000000000..80ca52728a --- /dev/null +++ b/Lang/Prolog/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Run-length-encoding b/Lang/Prolog/Run-length-encoding new file mode 120000 index 0000000000..8fbb54b560 --- /dev/null +++ b/Lang/Prolog/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Self-describing-numbers b/Lang/Prolog/Self-describing-numbers new file mode 120000 index 0000000000..4f20b33d11 --- /dev/null +++ b/Lang/Prolog/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/Prolog \ No newline at end of file diff --git a/Lang/Prolog/Set b/Lang/Prolog/Set new file mode 120000 index 0000000000..5607a2bfeb --- /dev/null +++ b/Lang/Prolog/Set @@ -0,0 +1 @@ +../../Task/Set/Prolog \ No newline at end of file diff --git a/Lang/Protium/Read-a-configuration-file b/Lang/Protium/Read-a-configuration-file new file mode 120000 index 0000000000..730de14d65 --- /dev/null +++ b/Lang/Protium/Read-a-configuration-file @@ -0,0 +1 @@ +../../Task/Read-a-configuration-file/Protium \ No newline at end of file diff --git a/Lang/Protium/Reverse-a-string b/Lang/Protium/Reverse-a-string new file mode 120000 index 0000000000..d345e34882 --- /dev/null +++ b/Lang/Protium/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Protium \ No newline at end of file diff --git a/Lang/Protium/Roman-numerals-Encode b/Lang/Protium/Roman-numerals-Encode new file mode 120000 index 0000000000..2dd886ad2f --- /dev/null +++ b/Lang/Protium/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Protium \ No newline at end of file diff --git a/Lang/Pure/Prime-decomposition b/Lang/Pure/Prime-decomposition new file mode 120000 index 0000000000..4776c83c5e --- /dev/null +++ b/Lang/Pure/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Pure \ No newline at end of file diff --git a/Lang/Pure/Repeat-a-string b/Lang/Pure/Repeat-a-string new file mode 120000 index 0000000000..9c0dc6e47e --- /dev/null +++ b/Lang/Pure/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Pure \ No newline at end of file diff --git a/Lang/Pure/Run-length-encoding b/Lang/Pure/Run-length-encoding new file mode 120000 index 0000000000..5ede793269 --- /dev/null +++ b/Lang/Pure/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Pure \ No newline at end of file diff --git a/Lang/PureBasic/Arbitrary-precision-integers--included- b/Lang/PureBasic/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..a4d0ba106d --- /dev/null +++ b/Lang/PureBasic/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Arbitrary-precision-integers-included b/Lang/PureBasic/Arbitrary-precision-integers-included deleted file mode 120000 index c2272798fe..0000000000 --- a/Lang/PureBasic/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Binary-digits b/Lang/PureBasic/Binary-digits new file mode 120000 index 0000000000..24801780bd --- /dev/null +++ b/Lang/PureBasic/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Brownian-tree b/Lang/PureBasic/Brownian-tree new file mode 120000 index 0000000000..2d8be95a59 --- /dev/null +++ b/Lang/PureBasic/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Catalan-numbers b/Lang/PureBasic/Catalan-numbers new file mode 120000 index 0000000000..c6d0b8b69d --- /dev/null +++ b/Lang/PureBasic/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Copy-a-string b/Lang/PureBasic/Copy-a-string new file mode 120000 index 0000000000..ed1c56ad2d --- /dev/null +++ b/Lang/PureBasic/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Dragon-curve b/Lang/PureBasic/Dragon-curve new file mode 120000 index 0000000000..5c03084098 --- /dev/null +++ b/Lang/PureBasic/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Environment-variables b/Lang/PureBasic/Environment-variables new file mode 120000 index 0000000000..6d29018b55 --- /dev/null +++ b/Lang/PureBasic/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Execute-a-Markov-algorithm b/Lang/PureBasic/Execute-a-Markov-algorithm new file mode 120000 index 0000000000..7e1cb29e30 --- /dev/null +++ b/Lang/PureBasic/Execute-a-Markov-algorithm @@ -0,0 +1 @@ +../../Task/Execute-a-Markov-algorithm/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Guess-the-number-With-feedback--player- b/Lang/PureBasic/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..6b972de354 --- /dev/null +++ b/Lang/PureBasic/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Guess-the-number-With-feedback-player b/Lang/PureBasic/Guess-the-number-With-feedback-player deleted file mode 120000 index 2965b502e7..0000000000 --- a/Lang/PureBasic/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/N-queens-problem b/Lang/PureBasic/N-queens-problem new file mode 120000 index 0000000000..2a95d99ed8 --- /dev/null +++ b/Lang/PureBasic/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Non-decimal-radices-Convert b/Lang/PureBasic/Non-decimal-radices-Convert new file mode 120000 index 0000000000..4b7cad7101 --- /dev/null +++ b/Lang/PureBasic/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Non-decimal-radices-Input b/Lang/PureBasic/Non-decimal-radices-Input new file mode 120000 index 0000000000..ef225480a6 --- /dev/null +++ b/Lang/PureBasic/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Non-decimal-radices-Output b/Lang/PureBasic/Non-decimal-radices-Output new file mode 120000 index 0000000000..32ac403c42 --- /dev/null +++ b/Lang/PureBasic/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Nth-root b/Lang/PureBasic/Nth-root new file mode 120000 index 0000000000..8ee1d9d038 --- /dev/null +++ b/Lang/PureBasic/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Null-object b/Lang/PureBasic/Null-object new file mode 120000 index 0000000000..f6c2eae809 --- /dev/null +++ b/Lang/PureBasic/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Number-names b/Lang/PureBasic/Number-names new file mode 120000 index 0000000000..5199905750 --- /dev/null +++ b/Lang/PureBasic/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Number-reversal-game b/Lang/PureBasic/Number-reversal-game new file mode 120000 index 0000000000..68926bc217 --- /dev/null +++ b/Lang/PureBasic/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Numerical-integration b/Lang/PureBasic/Numerical-integration new file mode 120000 index 0000000000..d2417158e7 --- /dev/null +++ b/Lang/PureBasic/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/One-dimensional-cellular-automata b/Lang/PureBasic/One-dimensional-cellular-automata new file mode 120000 index 0000000000..702bef2011 --- /dev/null +++ b/Lang/PureBasic/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/One-of-n-lines-in-a-file b/Lang/PureBasic/One-of-n-lines-in-a-file new file mode 120000 index 0000000000..bd460ae514 --- /dev/null +++ b/Lang/PureBasic/One-of-n-lines-in-a-file @@ -0,0 +1 @@ +../../Task/One-of-n-lines-in-a-file/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/OpenGL b/Lang/PureBasic/OpenGL new file mode 120000 index 0000000000..6d09ac2cc1 --- /dev/null +++ b/Lang/PureBasic/OpenGL @@ -0,0 +1 @@ +../../Task/OpenGL/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Order-two-numerical-lists b/Lang/PureBasic/Order-two-numerical-lists new file mode 120000 index 0000000000..f709fed1aa --- /dev/null +++ b/Lang/PureBasic/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Palindrome-detection b/Lang/PureBasic/Palindrome-detection new file mode 120000 index 0000000000..88ba568216 --- /dev/null +++ b/Lang/PureBasic/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Pangram-checker b/Lang/PureBasic/Pangram-checker new file mode 120000 index 0000000000..d3276530f7 --- /dev/null +++ b/Lang/PureBasic/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Parallel-calculations b/Lang/PureBasic/Parallel-calculations new file mode 120000 index 0000000000..c205f37440 --- /dev/null +++ b/Lang/PureBasic/Parallel-calculations @@ -0,0 +1 @@ +../../Task/Parallel-calculations/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Parametrized-SQL-statement b/Lang/PureBasic/Parametrized-SQL-statement new file mode 120000 index 0000000000..338fff7a0c --- /dev/null +++ b/Lang/PureBasic/Parametrized-SQL-statement @@ -0,0 +1 @@ +../../Task/Parametrized-SQL-statement/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Pascals-triangle b/Lang/PureBasic/Pascals-triangle new file mode 120000 index 0000000000..417ceaea32 --- /dev/null +++ b/Lang/PureBasic/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Pascals-triangle-Puzzle b/Lang/PureBasic/Pascals-triangle-Puzzle new file mode 120000 index 0000000000..74b963ccd5 --- /dev/null +++ b/Lang/PureBasic/Pascals-triangle-Puzzle @@ -0,0 +1 @@ +../../Task/Pascals-triangle-Puzzle/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Percentage-difference-between-images b/Lang/PureBasic/Percentage-difference-between-images new file mode 120000 index 0000000000..714b84ef96 --- /dev/null +++ b/Lang/PureBasic/Percentage-difference-between-images @@ -0,0 +1 @@ +../../Task/Percentage-difference-between-images/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Perfect-numbers b/Lang/PureBasic/Perfect-numbers new file mode 120000 index 0000000000..8e7741863c --- /dev/null +++ b/Lang/PureBasic/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Permutation-test b/Lang/PureBasic/Permutation-test new file mode 120000 index 0000000000..df739b44e4 --- /dev/null +++ b/Lang/PureBasic/Permutation-test @@ -0,0 +1 @@ +../../Task/Permutation-test/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Permutations b/Lang/PureBasic/Permutations new file mode 120000 index 0000000000..1912ae3b10 --- /dev/null +++ b/Lang/PureBasic/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Permutations-Derangements b/Lang/PureBasic/Permutations-Derangements new file mode 120000 index 0000000000..b4fb936255 --- /dev/null +++ b/Lang/PureBasic/Permutations-Derangements @@ -0,0 +1 @@ +../../Task/Permutations-Derangements/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Pick-random-element b/Lang/PureBasic/Pick-random-element new file mode 120000 index 0000000000..befd858d5d --- /dev/null +++ b/Lang/PureBasic/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Pinstripe-Display b/Lang/PureBasic/Pinstripe-Display new file mode 120000 index 0000000000..cc081f5820 --- /dev/null +++ b/Lang/PureBasic/Pinstripe-Display @@ -0,0 +1 @@ +../../Task/Pinstripe-Display/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Play-recorded-sounds b/Lang/PureBasic/Play-recorded-sounds new file mode 120000 index 0000000000..fac50a00f7 --- /dev/null +++ b/Lang/PureBasic/Play-recorded-sounds @@ -0,0 +1 @@ +../../Task/Play-recorded-sounds/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Playing-cards b/Lang/PureBasic/Playing-cards new file mode 120000 index 0000000000..130f99ca96 --- /dev/null +++ b/Lang/PureBasic/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Plot-coordinate-pairs b/Lang/PureBasic/Plot-coordinate-pairs new file mode 120000 index 0000000000..de3f948a6e --- /dev/null +++ b/Lang/PureBasic/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Pointers-and-references b/Lang/PureBasic/Pointers-and-references new file mode 120000 index 0000000000..f69b055099 --- /dev/null +++ b/Lang/PureBasic/Pointers-and-references @@ -0,0 +1 @@ +../../Task/Pointers-and-references/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Polymorphism b/Lang/PureBasic/Polymorphism new file mode 120000 index 0000000000..c611924c91 --- /dev/null +++ b/Lang/PureBasic/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Power-set b/Lang/PureBasic/Power-set new file mode 120000 index 0000000000..cb5e804458 --- /dev/null +++ b/Lang/PureBasic/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Price-fraction b/Lang/PureBasic/Price-fraction new file mode 120000 index 0000000000..0d0c5d4679 --- /dev/null +++ b/Lang/PureBasic/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Primality-by-trial-division b/Lang/PureBasic/Primality-by-trial-division new file mode 120000 index 0000000000..2f05823fd4 --- /dev/null +++ b/Lang/PureBasic/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Prime-decomposition b/Lang/PureBasic/Prime-decomposition new file mode 120000 index 0000000000..0911bbf692 --- /dev/null +++ b/Lang/PureBasic/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Priority-queue b/Lang/PureBasic/Priority-queue new file mode 120000 index 0000000000..b162eeb514 --- /dev/null +++ b/Lang/PureBasic/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Probabilistic-choice b/Lang/PureBasic/Probabilistic-choice new file mode 120000 index 0000000000..3a16943f8d --- /dev/null +++ b/Lang/PureBasic/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Problem-of-Apollonius b/Lang/PureBasic/Problem-of-Apollonius new file mode 120000 index 0000000000..7e1db16c23 --- /dev/null +++ b/Lang/PureBasic/Problem-of-Apollonius @@ -0,0 +1 @@ +../../Task/Problem-of-Apollonius/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Program-name b/Lang/PureBasic/Program-name new file mode 120000 index 0000000000..7b645974f6 --- /dev/null +++ b/Lang/PureBasic/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Program-termination b/Lang/PureBasic/Program-termination new file mode 120000 index 0000000000..5c2e095cd9 --- /dev/null +++ b/Lang/PureBasic/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Pythagorean-triples b/Lang/PureBasic/Pythagorean-triples new file mode 120000 index 0000000000..dbe694d13e --- /dev/null +++ b/Lang/PureBasic/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Quaternion-type b/Lang/PureBasic/Quaternion-type new file mode 120000 index 0000000000..6551ed8e89 --- /dev/null +++ b/Lang/PureBasic/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Queue-Definition b/Lang/PureBasic/Queue-Definition new file mode 120000 index 0000000000..8f687c6b48 --- /dev/null +++ b/Lang/PureBasic/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Queue-Usage b/Lang/PureBasic/Queue-Usage new file mode 120000 index 0000000000..df0f2b16a6 --- /dev/null +++ b/Lang/PureBasic/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Random-number-generator--device- b/Lang/PureBasic/Random-number-generator--device- new file mode 120000 index 0000000000..3792d21084 --- /dev/null +++ b/Lang/PureBasic/Random-number-generator--device- @@ -0,0 +1 @@ +../../Task/Random-number-generator--device-/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Random-numbers b/Lang/PureBasic/Random-numbers new file mode 120000 index 0000000000..084260546a --- /dev/null +++ b/Lang/PureBasic/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Range-expansion b/Lang/PureBasic/Range-expansion new file mode 120000 index 0000000000..91b28e30fa --- /dev/null +++ b/Lang/PureBasic/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Range-extraction b/Lang/PureBasic/Range-extraction new file mode 120000 index 0000000000..73f107bbae --- /dev/null +++ b/Lang/PureBasic/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Rate-counter b/Lang/PureBasic/Rate-counter new file mode 120000 index 0000000000..1c6811a20b --- /dev/null +++ b/Lang/PureBasic/Rate-counter @@ -0,0 +1 @@ +../../Task/Rate-counter/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Ray-casting-algorithm b/Lang/PureBasic/Ray-casting-algorithm new file mode 120000 index 0000000000..c60d596f2b --- /dev/null +++ b/Lang/PureBasic/Ray-casting-algorithm @@ -0,0 +1 @@ +../../Task/Ray-casting-algorithm/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Read-a-file-line-by-line b/Lang/PureBasic/Read-a-file-line-by-line new file mode 120000 index 0000000000..17a16bd357 --- /dev/null +++ b/Lang/PureBasic/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Read-a-specific-line-from-a-file b/Lang/PureBasic/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..8a80fd7f78 --- /dev/null +++ b/Lang/PureBasic/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Read-entire-file b/Lang/PureBasic/Read-entire-file new file mode 120000 index 0000000000..69f67e5f97 --- /dev/null +++ b/Lang/PureBasic/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Real-constants-and-functions b/Lang/PureBasic/Real-constants-and-functions new file mode 120000 index 0000000000..f5fe025214 --- /dev/null +++ b/Lang/PureBasic/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Regular-expressions b/Lang/PureBasic/Regular-expressions new file mode 120000 index 0000000000..5d7bdf3ad7 --- /dev/null +++ b/Lang/PureBasic/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Remove-duplicate-elements b/Lang/PureBasic/Remove-duplicate-elements new file mode 120000 index 0000000000..51a3d179b0 --- /dev/null +++ b/Lang/PureBasic/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Rename-a-file b/Lang/PureBasic/Rename-a-file new file mode 120000 index 0000000000..73975254c6 --- /dev/null +++ b/Lang/PureBasic/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Repeat-a-string b/Lang/PureBasic/Repeat-a-string new file mode 120000 index 0000000000..0cef9d643d --- /dev/null +++ b/Lang/PureBasic/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Return-multiple-values b/Lang/PureBasic/Return-multiple-values new file mode 120000 index 0000000000..e5a29f611d --- /dev/null +++ b/Lang/PureBasic/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Reverse-a-string b/Lang/PureBasic/Reverse-a-string new file mode 120000 index 0000000000..0a304dadc5 --- /dev/null +++ b/Lang/PureBasic/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Rock-paper-scissors b/Lang/PureBasic/Rock-paper-scissors new file mode 120000 index 0000000000..032aa071d0 --- /dev/null +++ b/Lang/PureBasic/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Roman-numerals-Decode b/Lang/PureBasic/Roman-numerals-Decode new file mode 120000 index 0000000000..73ae78c3fb --- /dev/null +++ b/Lang/PureBasic/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Roman-numerals-Encode b/Lang/PureBasic/Roman-numerals-Encode new file mode 120000 index 0000000000..5101d225f9 --- /dev/null +++ b/Lang/PureBasic/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Roots-of-a-function b/Lang/PureBasic/Roots-of-a-function new file mode 120000 index 0000000000..5fc1af321a --- /dev/null +++ b/Lang/PureBasic/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Roots-of-unity b/Lang/PureBasic/Roots-of-unity new file mode 120000 index 0000000000..fa63898155 --- /dev/null +++ b/Lang/PureBasic/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Rosetta-Code-Count-examples b/Lang/PureBasic/Rosetta-Code-Count-examples new file mode 120000 index 0000000000..36eb6d77bc --- /dev/null +++ b/Lang/PureBasic/Rosetta-Code-Count-examples @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Count-examples/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Rosetta-Code-Fix-code-tags b/Lang/PureBasic/Rosetta-Code-Fix-code-tags new file mode 120000 index 0000000000..be0183b9a5 --- /dev/null +++ b/Lang/PureBasic/Rosetta-Code-Fix-code-tags @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Fix-code-tags/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Rosetta-Code-Rank-languages-by-popularity b/Lang/PureBasic/Rosetta-Code-Rank-languages-by-popularity new file mode 120000 index 0000000000..2b3a6ed635 --- /dev/null +++ b/Lang/PureBasic/Rosetta-Code-Rank-languages-by-popularity @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-popularity/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Rot-13 b/Lang/PureBasic/Rot-13 new file mode 120000 index 0000000000..0e158e6397 --- /dev/null +++ b/Lang/PureBasic/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Run-length-encoding b/Lang/PureBasic/Run-length-encoding new file mode 120000 index 0000000000..700446c542 --- /dev/null +++ b/Lang/PureBasic/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/SEDOLs b/Lang/PureBasic/SEDOLs new file mode 120000 index 0000000000..aeecd805f5 --- /dev/null +++ b/Lang/PureBasic/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Scope-modifiers b/Lang/PureBasic/Scope-modifiers new file mode 120000 index 0000000000..c198680eed --- /dev/null +++ b/Lang/PureBasic/Scope-modifiers @@ -0,0 +1 @@ +../../Task/Scope-modifiers/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Secure-temporary-file b/Lang/PureBasic/Secure-temporary-file new file mode 120000 index 0000000000..f1f31607d0 --- /dev/null +++ b/Lang/PureBasic/Secure-temporary-file @@ -0,0 +1 @@ +../../Task/Secure-temporary-file/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Self-describing-numbers b/Lang/PureBasic/Self-describing-numbers new file mode 120000 index 0000000000..ed20c2cae3 --- /dev/null +++ b/Lang/PureBasic/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Send-email b/Lang/PureBasic/Send-email new file mode 120000 index 0000000000..0a9aca4ee9 --- /dev/null +++ b/Lang/PureBasic/Send-email @@ -0,0 +1 @@ +../../Task/Send-email/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Sequence-of-non-squares b/Lang/PureBasic/Sequence-of-non-squares new file mode 120000 index 0000000000..904ecddb2b --- /dev/null +++ b/Lang/PureBasic/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/PureBasic \ No newline at end of file diff --git a/Lang/PureBasic/Set b/Lang/PureBasic/Set new file mode 120000 index 0000000000..4d11ff0373 --- /dev/null +++ b/Lang/PureBasic/Set @@ -0,0 +1 @@ +../../Task/Set/PureBasic \ No newline at end of file diff --git a/Lang/Python/Arbitrary-precision-integers--included- b/Lang/Python/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..b2afb0323e --- /dev/null +++ b/Lang/Python/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Python \ No newline at end of file diff --git a/Lang/Python/Arbitrary-precision-integers-included b/Lang/Python/Arbitrary-precision-integers-included deleted file mode 120000 index df9f38070c..0000000000 --- a/Lang/Python/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Python \ No newline at end of file diff --git a/Lang/Python/Binary-digits b/Lang/Python/Binary-digits new file mode 120000 index 0000000000..11fbc30009 --- /dev/null +++ b/Lang/Python/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Python \ No newline at end of file diff --git a/Lang/Python/Brownian-tree b/Lang/Python/Brownian-tree new file mode 120000 index 0000000000..efadd243e0 --- /dev/null +++ b/Lang/Python/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/Python \ No newline at end of file diff --git a/Lang/Python/Catalan-numbers b/Lang/Python/Catalan-numbers new file mode 120000 index 0000000000..bbda357899 --- /dev/null +++ b/Lang/Python/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Python \ No newline at end of file diff --git a/Lang/Python/Copy-a-string b/Lang/Python/Copy-a-string new file mode 120000 index 0000000000..545a27a1ff --- /dev/null +++ b/Lang/Python/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Python \ No newline at end of file diff --git a/Lang/Python/Dragon-curve b/Lang/Python/Dragon-curve new file mode 120000 index 0000000000..8453c92da6 --- /dev/null +++ b/Lang/Python/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/Python \ No newline at end of file diff --git a/Lang/Python/Environment-variables b/Lang/Python/Environment-variables new file mode 120000 index 0000000000..024c36ed2e --- /dev/null +++ b/Lang/Python/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Python \ No newline at end of file diff --git a/Lang/Python/Execute-a-Markov-algorithm b/Lang/Python/Execute-a-Markov-algorithm new file mode 120000 index 0000000000..c820a0e827 --- /dev/null +++ b/Lang/Python/Execute-a-Markov-algorithm @@ -0,0 +1 @@ +../../Task/Execute-a-Markov-algorithm/Python \ No newline at end of file diff --git a/Lang/Python/Guess-the-number-With-feedback--player- b/Lang/Python/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..be14dd6add --- /dev/null +++ b/Lang/Python/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/Python \ No newline at end of file diff --git a/Lang/Python/Guess-the-number-With-feedback-player b/Lang/Python/Guess-the-number-With-feedback-player deleted file mode 120000 index 4163c2bb98..0000000000 --- a/Lang/Python/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/Python \ No newline at end of file diff --git a/Lang/Python/N-queens-problem b/Lang/Python/N-queens-problem new file mode 120000 index 0000000000..d7ed48554d --- /dev/null +++ b/Lang/Python/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Python \ No newline at end of file diff --git a/Lang/Python/Named-parameters b/Lang/Python/Named-parameters new file mode 120000 index 0000000000..a97241b25c --- /dev/null +++ b/Lang/Python/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/Python \ No newline at end of file diff --git a/Lang/Python/Nautical-bell b/Lang/Python/Nautical-bell new file mode 120000 index 0000000000..06a0ce18cb --- /dev/null +++ b/Lang/Python/Nautical-bell @@ -0,0 +1 @@ +../../Task/Nautical-bell/Python \ No newline at end of file diff --git a/Lang/Python/Non-continuous-subsequences b/Lang/Python/Non-continuous-subsequences new file mode 120000 index 0000000000..97a473eea6 --- /dev/null +++ b/Lang/Python/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/Python \ No newline at end of file diff --git a/Lang/Python/Non-decimal-radices-Convert b/Lang/Python/Non-decimal-radices-Convert new file mode 120000 index 0000000000..e6ed82ba42 --- /dev/null +++ b/Lang/Python/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/Python \ No newline at end of file diff --git a/Lang/Python/Non-decimal-radices-Input b/Lang/Python/Non-decimal-radices-Input new file mode 120000 index 0000000000..462bcf1bd3 --- /dev/null +++ b/Lang/Python/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/Python \ No newline at end of file diff --git a/Lang/Python/Non-decimal-radices-Output b/Lang/Python/Non-decimal-radices-Output new file mode 120000 index 0000000000..9fa7688b00 --- /dev/null +++ b/Lang/Python/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/Python \ No newline at end of file diff --git a/Lang/Python/Nth-root b/Lang/Python/Nth-root new file mode 120000 index 0000000000..e61021e359 --- /dev/null +++ b/Lang/Python/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Python \ No newline at end of file diff --git a/Lang/Python/Null-object b/Lang/Python/Null-object new file mode 120000 index 0000000000..e7cc0fa0b0 --- /dev/null +++ b/Lang/Python/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Python \ No newline at end of file diff --git a/Lang/Python/Number-reversal-game b/Lang/Python/Number-reversal-game new file mode 120000 index 0000000000..e47d749221 --- /dev/null +++ b/Lang/Python/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/Python \ No newline at end of file diff --git a/Lang/Python/Numeric-error-propagation b/Lang/Python/Numeric-error-propagation new file mode 120000 index 0000000000..7294b79b27 --- /dev/null +++ b/Lang/Python/Numeric-error-propagation @@ -0,0 +1 @@ +../../Task/Numeric-error-propagation/Python \ No newline at end of file diff --git a/Lang/Python/Numerical-integration b/Lang/Python/Numerical-integration new file mode 120000 index 0000000000..df8a8ca54f --- /dev/null +++ b/Lang/Python/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/Python \ No newline at end of file diff --git a/Lang/Python/Numerical-integration-Gauss-Legendre-Quadrature b/Lang/Python/Numerical-integration-Gauss-Legendre-Quadrature new file mode 120000 index 0000000000..18e65c60c7 --- /dev/null +++ b/Lang/Python/Numerical-integration-Gauss-Legendre-Quadrature @@ -0,0 +1 @@ +../../Task/Numerical-integration-Gauss-Legendre-Quadrature/Python \ No newline at end of file diff --git a/Lang/Python/OLE-Automation b/Lang/Python/OLE-Automation new file mode 120000 index 0000000000..25de9a4e2d --- /dev/null +++ b/Lang/Python/OLE-Automation @@ -0,0 +1 @@ +../../Task/OLE-Automation/Python \ No newline at end of file diff --git a/Lang/Python/Object-serialization b/Lang/Python/Object-serialization new file mode 120000 index 0000000000..46019775e4 --- /dev/null +++ b/Lang/Python/Object-serialization @@ -0,0 +1 @@ +../../Task/Object-serialization/Python \ No newline at end of file diff --git a/Lang/Python/One-dimensional-cellular-automata b/Lang/Python/One-dimensional-cellular-automata new file mode 120000 index 0000000000..9b894d50d0 --- /dev/null +++ b/Lang/Python/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Python \ No newline at end of file diff --git a/Lang/Python/One-of-n-lines-in-a-file b/Lang/Python/One-of-n-lines-in-a-file new file mode 120000 index 0000000000..d0feddcc14 --- /dev/null +++ b/Lang/Python/One-of-n-lines-in-a-file @@ -0,0 +1 @@ +../../Task/One-of-n-lines-in-a-file/Python \ No newline at end of file diff --git a/Lang/Python/OpenGL b/Lang/Python/OpenGL new file mode 120000 index 0000000000..ad2c182051 --- /dev/null +++ b/Lang/Python/OpenGL @@ -0,0 +1 @@ +../../Task/OpenGL/Python \ No newline at end of file diff --git a/Lang/Python/Optional-parameters b/Lang/Python/Optional-parameters new file mode 120000 index 0000000000..f35704b95b --- /dev/null +++ b/Lang/Python/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/Python \ No newline at end of file diff --git a/Lang/Python/Order-two-numerical-lists b/Lang/Python/Order-two-numerical-lists new file mode 120000 index 0000000000..1323408fb5 --- /dev/null +++ b/Lang/Python/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/Python \ No newline at end of file diff --git a/Lang/Python/Ordered-Partitions b/Lang/Python/Ordered-Partitions new file mode 120000 index 0000000000..6662756310 --- /dev/null +++ b/Lang/Python/Ordered-Partitions @@ -0,0 +1 @@ +../../Task/Ordered-Partitions/Python \ No newline at end of file diff --git a/Lang/Python/Palindrome-detection b/Lang/Python/Palindrome-detection new file mode 120000 index 0000000000..ecdf413b98 --- /dev/null +++ b/Lang/Python/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Python \ No newline at end of file diff --git a/Lang/Python/Pangram-checker b/Lang/Python/Pangram-checker new file mode 120000 index 0000000000..34e8ed2cb2 --- /dev/null +++ b/Lang/Python/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Python \ No newline at end of file diff --git a/Lang/Python/Parallel-calculations b/Lang/Python/Parallel-calculations new file mode 120000 index 0000000000..d1e1cfe873 --- /dev/null +++ b/Lang/Python/Parallel-calculations @@ -0,0 +1 @@ +../../Task/Parallel-calculations/Python \ No newline at end of file diff --git a/Lang/Python/Parametrized-SQL-statement b/Lang/Python/Parametrized-SQL-statement new file mode 120000 index 0000000000..992e927180 --- /dev/null +++ b/Lang/Python/Parametrized-SQL-statement @@ -0,0 +1 @@ +../../Task/Parametrized-SQL-statement/Python \ No newline at end of file diff --git a/Lang/Python/Parsing-RPN-calculator-algorithm b/Lang/Python/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..694cf45a88 --- /dev/null +++ b/Lang/Python/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/Python \ No newline at end of file diff --git a/Lang/Python/Parsing-RPN-to-infix-conversion b/Lang/Python/Parsing-RPN-to-infix-conversion new file mode 120000 index 0000000000..026b00406e --- /dev/null +++ b/Lang/Python/Parsing-RPN-to-infix-conversion @@ -0,0 +1 @@ +../../Task/Parsing-RPN-to-infix-conversion/Python \ No newline at end of file diff --git a/Lang/Python/Parsing-Shunting-yard-algorithm b/Lang/Python/Parsing-Shunting-yard-algorithm new file mode 120000 index 0000000000..c885ee98bd --- /dev/null +++ b/Lang/Python/Parsing-Shunting-yard-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-Shunting-yard-algorithm/Python \ No newline at end of file diff --git a/Lang/Python/Partial-function-application b/Lang/Python/Partial-function-application new file mode 120000 index 0000000000..ad835a0eee --- /dev/null +++ b/Lang/Python/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/Python \ No newline at end of file diff --git a/Lang/Python/Pascals-triangle b/Lang/Python/Pascals-triangle new file mode 120000 index 0000000000..ecc601ec55 --- /dev/null +++ b/Lang/Python/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Python \ No newline at end of file diff --git a/Lang/Python/Pascals-triangle-Puzzle b/Lang/Python/Pascals-triangle-Puzzle new file mode 120000 index 0000000000..30bff378bd --- /dev/null +++ b/Lang/Python/Pascals-triangle-Puzzle @@ -0,0 +1 @@ +../../Task/Pascals-triangle-Puzzle/Python \ No newline at end of file diff --git a/Lang/Python/Percentage-difference-between-images b/Lang/Python/Percentage-difference-between-images new file mode 120000 index 0000000000..c4eb8ad7d9 --- /dev/null +++ b/Lang/Python/Percentage-difference-between-images @@ -0,0 +1 @@ +../../Task/Percentage-difference-between-images/Python \ No newline at end of file diff --git a/Lang/Python/Perfect-numbers b/Lang/Python/Perfect-numbers new file mode 120000 index 0000000000..f3e76358f3 --- /dev/null +++ b/Lang/Python/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Python \ No newline at end of file diff --git a/Lang/Python/Permutation-test b/Lang/Python/Permutation-test new file mode 120000 index 0000000000..e3522a6333 --- /dev/null +++ b/Lang/Python/Permutation-test @@ -0,0 +1 @@ +../../Task/Permutation-test/Python \ No newline at end of file diff --git a/Lang/Python/Permutations b/Lang/Python/Permutations new file mode 120000 index 0000000000..96b4036fed --- /dev/null +++ b/Lang/Python/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Python \ No newline at end of file diff --git a/Lang/Python/Permutations-Derangements b/Lang/Python/Permutations-Derangements new file mode 120000 index 0000000000..91d2271f29 --- /dev/null +++ b/Lang/Python/Permutations-Derangements @@ -0,0 +1 @@ +../../Task/Permutations-Derangements/Python \ No newline at end of file diff --git a/Lang/Python/Permutations-by-swapping b/Lang/Python/Permutations-by-swapping new file mode 120000 index 0000000000..0fdbfbd0c8 --- /dev/null +++ b/Lang/Python/Permutations-by-swapping @@ -0,0 +1 @@ +../../Task/Permutations-by-swapping/Python \ No newline at end of file diff --git a/Lang/Python/Pick-random-element b/Lang/Python/Pick-random-element new file mode 120000 index 0000000000..0938679c78 --- /dev/null +++ b/Lang/Python/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/Python \ No newline at end of file diff --git a/Lang/Python/Pig-the-dice-game b/Lang/Python/Pig-the-dice-game new file mode 120000 index 0000000000..0a19c19589 --- /dev/null +++ b/Lang/Python/Pig-the-dice-game @@ -0,0 +1 @@ +../../Task/Pig-the-dice-game/Python \ No newline at end of file diff --git a/Lang/Python/Pig-the-dice-game-Player b/Lang/Python/Pig-the-dice-game-Player new file mode 120000 index 0000000000..9476c6d06e --- /dev/null +++ b/Lang/Python/Pig-the-dice-game-Player @@ -0,0 +1 @@ +../../Task/Pig-the-dice-game-Player/Python \ No newline at end of file diff --git a/Lang/Python/Play-recorded-sounds b/Lang/Python/Play-recorded-sounds new file mode 120000 index 0000000000..a936bbd003 --- /dev/null +++ b/Lang/Python/Play-recorded-sounds @@ -0,0 +1 @@ +../../Task/Play-recorded-sounds/Python \ No newline at end of file diff --git a/Lang/Python/Playing-cards b/Lang/Python/Playing-cards new file mode 120000 index 0000000000..7b063d4d0f --- /dev/null +++ b/Lang/Python/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/Python \ No newline at end of file diff --git a/Lang/Python/Plot-coordinate-pairs b/Lang/Python/Plot-coordinate-pairs new file mode 120000 index 0000000000..2d4fde74e7 --- /dev/null +++ b/Lang/Python/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/Python \ No newline at end of file diff --git a/Lang/Python/Pointers-and-references b/Lang/Python/Pointers-and-references new file mode 120000 index 0000000000..599f9af74c --- /dev/null +++ b/Lang/Python/Pointers-and-references @@ -0,0 +1 @@ +../../Task/Pointers-and-references/Python \ No newline at end of file diff --git a/Lang/Python/Polymorphic-copy b/Lang/Python/Polymorphic-copy new file mode 120000 index 0000000000..78d4d11b00 --- /dev/null +++ b/Lang/Python/Polymorphic-copy @@ -0,0 +1 @@ +../../Task/Polymorphic-copy/Python \ No newline at end of file diff --git a/Lang/Python/Polymorphism b/Lang/Python/Polymorphism new file mode 120000 index 0000000000..80fc1d74c1 --- /dev/null +++ b/Lang/Python/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/Python \ No newline at end of file diff --git a/Lang/Python/Polynomial-long-division b/Lang/Python/Polynomial-long-division new file mode 120000 index 0000000000..f84507545b --- /dev/null +++ b/Lang/Python/Polynomial-long-division @@ -0,0 +1 @@ +../../Task/Polynomial-long-division/Python \ No newline at end of file diff --git a/Lang/Python/Polynomial-regression b/Lang/Python/Polynomial-regression new file mode 120000 index 0000000000..cefc175f1d --- /dev/null +++ b/Lang/Python/Polynomial-regression @@ -0,0 +1 @@ +../../Task/Polynomial-regression/Python \ No newline at end of file diff --git a/Lang/Python/Power-set b/Lang/Python/Power-set new file mode 120000 index 0000000000..26987f8660 --- /dev/null +++ b/Lang/Python/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Python \ No newline at end of file diff --git a/Lang/Python/Pragmatic-directives b/Lang/Python/Pragmatic-directives new file mode 120000 index 0000000000..7acd9875f1 --- /dev/null +++ b/Lang/Python/Pragmatic-directives @@ -0,0 +1 @@ +../../Task/Pragmatic-directives/Python \ No newline at end of file diff --git a/Lang/Python/Price-fraction b/Lang/Python/Price-fraction new file mode 120000 index 0000000000..512febe612 --- /dev/null +++ b/Lang/Python/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Python \ No newline at end of file diff --git a/Lang/Python/Primality-by-trial-division b/Lang/Python/Primality-by-trial-division new file mode 120000 index 0000000000..827d0faff8 --- /dev/null +++ b/Lang/Python/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Python \ No newline at end of file diff --git a/Lang/Python/Prime-decomposition b/Lang/Python/Prime-decomposition new file mode 120000 index 0000000000..1e22a5da44 --- /dev/null +++ b/Lang/Python/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Python \ No newline at end of file diff --git a/Lang/Python/Priority-queue b/Lang/Python/Priority-queue new file mode 120000 index 0000000000..0e4ca522fb --- /dev/null +++ b/Lang/Python/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/Python \ No newline at end of file diff --git a/Lang/Python/Probabilistic-choice b/Lang/Python/Probabilistic-choice new file mode 120000 index 0000000000..bfc7db9ace --- /dev/null +++ b/Lang/Python/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/Python \ No newline at end of file diff --git a/Lang/Python/Problem-of-Apollonius b/Lang/Python/Problem-of-Apollonius new file mode 120000 index 0000000000..cefd3f0891 --- /dev/null +++ b/Lang/Python/Problem-of-Apollonius @@ -0,0 +1 @@ +../../Task/Problem-of-Apollonius/Python \ No newline at end of file diff --git a/Lang/Python/Program-name b/Lang/Python/Program-name new file mode 120000 index 0000000000..270d382b92 --- /dev/null +++ b/Lang/Python/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Python \ No newline at end of file diff --git a/Lang/Python/Program-termination b/Lang/Python/Program-termination new file mode 120000 index 0000000000..7c33d4d31b --- /dev/null +++ b/Lang/Python/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Python \ No newline at end of file diff --git a/Lang/Python/Pythagorean-triples b/Lang/Python/Pythagorean-triples new file mode 120000 index 0000000000..8a05d8353e --- /dev/null +++ b/Lang/Python/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/Python \ No newline at end of file diff --git a/Lang/Python/Quaternion-type b/Lang/Python/Quaternion-type new file mode 120000 index 0000000000..4219e34b85 --- /dev/null +++ b/Lang/Python/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/Python \ No newline at end of file diff --git a/Lang/Python/Queue-Definition b/Lang/Python/Queue-Definition new file mode 120000 index 0000000000..7541a3253c --- /dev/null +++ b/Lang/Python/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/Python \ No newline at end of file diff --git a/Lang/Python/Queue-Usage b/Lang/Python/Queue-Usage new file mode 120000 index 0000000000..a4780c0146 --- /dev/null +++ b/Lang/Python/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/Python \ No newline at end of file diff --git a/Lang/Python/RIPEMD-160 b/Lang/Python/RIPEMD-160 new file mode 120000 index 0000000000..a2c89a1d90 --- /dev/null +++ b/Lang/Python/RIPEMD-160 @@ -0,0 +1 @@ +../../Task/RIPEMD-160/Python \ No newline at end of file diff --git a/Lang/Python/Random-number-generator--device- b/Lang/Python/Random-number-generator--device- new file mode 120000 index 0000000000..91a7dee506 --- /dev/null +++ b/Lang/Python/Random-number-generator--device- @@ -0,0 +1 @@ +../../Task/Random-number-generator--device-/Python \ No newline at end of file diff --git a/Lang/Python/Random-numbers b/Lang/Python/Random-numbers new file mode 120000 index 0000000000..9776797d2b --- /dev/null +++ b/Lang/Python/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Python \ No newline at end of file diff --git a/Lang/Python/Range-expansion b/Lang/Python/Range-expansion new file mode 120000 index 0000000000..6924043a77 --- /dev/null +++ b/Lang/Python/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/Python \ No newline at end of file diff --git a/Lang/Python/Range-extraction b/Lang/Python/Range-extraction new file mode 120000 index 0000000000..7ca44982ab --- /dev/null +++ b/Lang/Python/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/Python \ No newline at end of file diff --git a/Lang/Python/Rate-counter b/Lang/Python/Rate-counter new file mode 120000 index 0000000000..5450e425c9 --- /dev/null +++ b/Lang/Python/Rate-counter @@ -0,0 +1 @@ +../../Task/Rate-counter/Python \ No newline at end of file diff --git a/Lang/Python/Ray-casting-algorithm b/Lang/Python/Ray-casting-algorithm new file mode 120000 index 0000000000..c0814ba9a2 --- /dev/null +++ b/Lang/Python/Ray-casting-algorithm @@ -0,0 +1 @@ +../../Task/Ray-casting-algorithm/Python \ No newline at end of file diff --git a/Lang/Python/Read-a-configuration-file b/Lang/Python/Read-a-configuration-file new file mode 120000 index 0000000000..476abeacd5 --- /dev/null +++ b/Lang/Python/Read-a-configuration-file @@ -0,0 +1 @@ +../../Task/Read-a-configuration-file/Python \ No newline at end of file diff --git a/Lang/Python/Read-a-file-line-by-line b/Lang/Python/Read-a-file-line-by-line new file mode 120000 index 0000000000..1073828041 --- /dev/null +++ b/Lang/Python/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Python \ No newline at end of file diff --git a/Lang/Python/Read-a-specific-line-from-a-file b/Lang/Python/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..165b4f371c --- /dev/null +++ b/Lang/Python/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/Python \ No newline at end of file diff --git a/Lang/Python/Read-entire-file b/Lang/Python/Read-entire-file new file mode 120000 index 0000000000..e532d5a88f --- /dev/null +++ b/Lang/Python/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Python \ No newline at end of file diff --git a/Lang/Python/Real-constants-and-functions b/Lang/Python/Real-constants-and-functions new file mode 120000 index 0000000000..e15c7019e0 --- /dev/null +++ b/Lang/Python/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Python \ No newline at end of file diff --git a/Lang/Python/Record-sound b/Lang/Python/Record-sound new file mode 120000 index 0000000000..ac51a3b391 --- /dev/null +++ b/Lang/Python/Record-sound @@ -0,0 +1 @@ +../../Task/Record-sound/Python \ No newline at end of file diff --git a/Lang/Python/Reduced-row-echelon-form b/Lang/Python/Reduced-row-echelon-form new file mode 120000 index 0000000000..4b0af30ee8 --- /dev/null +++ b/Lang/Python/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/Python \ No newline at end of file diff --git a/Lang/Python/Regular-expressions b/Lang/Python/Regular-expressions new file mode 120000 index 0000000000..ffa4b2a5f6 --- /dev/null +++ b/Lang/Python/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Python \ No newline at end of file diff --git a/Lang/Python/Remove-duplicate-elements b/Lang/Python/Remove-duplicate-elements new file mode 120000 index 0000000000..5cb1b58a62 --- /dev/null +++ b/Lang/Python/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Python \ No newline at end of file diff --git a/Lang/Python/Remove-lines-from-a-file b/Lang/Python/Remove-lines-from-a-file new file mode 120000 index 0000000000..0509be5845 --- /dev/null +++ b/Lang/Python/Remove-lines-from-a-file @@ -0,0 +1 @@ +../../Task/Remove-lines-from-a-file/Python \ No newline at end of file diff --git a/Lang/Python/Rename-a-file b/Lang/Python/Rename-a-file new file mode 120000 index 0000000000..896729ec59 --- /dev/null +++ b/Lang/Python/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Python \ No newline at end of file diff --git a/Lang/Python/Repeat-a-string b/Lang/Python/Repeat-a-string new file mode 120000 index 0000000000..fce4a2265f --- /dev/null +++ b/Lang/Python/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Python \ No newline at end of file diff --git a/Lang/Python/Resistor-mesh b/Lang/Python/Resistor-mesh new file mode 120000 index 0000000000..a68cff9ce5 --- /dev/null +++ b/Lang/Python/Resistor-mesh @@ -0,0 +1 @@ +../../Task/Resistor-mesh/Python \ No newline at end of file diff --git a/Lang/Python/Respond-to-an-unknown-method-call b/Lang/Python/Respond-to-an-unknown-method-call new file mode 120000 index 0000000000..37a6a070b6 --- /dev/null +++ b/Lang/Python/Respond-to-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Respond-to-an-unknown-method-call/Python \ No newline at end of file diff --git a/Lang/Python/Return-multiple-values b/Lang/Python/Return-multiple-values new file mode 120000 index 0000000000..95a875df03 --- /dev/null +++ b/Lang/Python/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Python \ No newline at end of file diff --git a/Lang/Python/Reverse-a-string b/Lang/Python/Reverse-a-string new file mode 120000 index 0000000000..ff7229af87 --- /dev/null +++ b/Lang/Python/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Python \ No newline at end of file diff --git a/Lang/Python/Rock-paper-scissors b/Lang/Python/Rock-paper-scissors new file mode 120000 index 0000000000..d5efdf9b27 --- /dev/null +++ b/Lang/Python/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/Python \ No newline at end of file diff --git a/Lang/Python/Roman-numerals-Decode b/Lang/Python/Roman-numerals-Decode new file mode 120000 index 0000000000..fdc635c504 --- /dev/null +++ b/Lang/Python/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/Python \ No newline at end of file diff --git a/Lang/Python/Roman-numerals-Encode b/Lang/Python/Roman-numerals-Encode new file mode 120000 index 0000000000..e1499f27ed --- /dev/null +++ b/Lang/Python/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Python \ No newline at end of file diff --git a/Lang/Python/Roots-of-a-function b/Lang/Python/Roots-of-a-function new file mode 120000 index 0000000000..b96e17e7e8 --- /dev/null +++ b/Lang/Python/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/Python \ No newline at end of file diff --git a/Lang/Python/Roots-of-a-quadratic-function b/Lang/Python/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..855190986c --- /dev/null +++ b/Lang/Python/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/Python \ No newline at end of file diff --git a/Lang/Python/Roots-of-unity b/Lang/Python/Roots-of-unity new file mode 120000 index 0000000000..ac6d272dc8 --- /dev/null +++ b/Lang/Python/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/Python \ No newline at end of file diff --git a/Lang/Python/Rosetta-Code-Count-examples b/Lang/Python/Rosetta-Code-Count-examples new file mode 120000 index 0000000000..96ad5ae313 --- /dev/null +++ b/Lang/Python/Rosetta-Code-Count-examples @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Count-examples/Python \ No newline at end of file diff --git a/Lang/Python/Rosetta-Code-Fix-code-tags b/Lang/Python/Rosetta-Code-Fix-code-tags new file mode 120000 index 0000000000..f942dbff1e --- /dev/null +++ b/Lang/Python/Rosetta-Code-Fix-code-tags @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Fix-code-tags/Python \ No newline at end of file diff --git a/Lang/Python/Rosetta-Code-Rank-languages-by-popularity b/Lang/Python/Rosetta-Code-Rank-languages-by-popularity new file mode 120000 index 0000000000..1b575573fe --- /dev/null +++ b/Lang/Python/Rosetta-Code-Rank-languages-by-popularity @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-popularity/Python \ No newline at end of file diff --git a/Lang/Python/Rot-13 b/Lang/Python/Rot-13 new file mode 120000 index 0000000000..99dbbb491c --- /dev/null +++ b/Lang/Python/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Python \ No newline at end of file diff --git a/Lang/Python/Run-length-encoding b/Lang/Python/Run-length-encoding new file mode 120000 index 0000000000..400c106955 --- /dev/null +++ b/Lang/Python/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Python \ No newline at end of file diff --git a/Lang/Python/Runtime-evaluation b/Lang/Python/Runtime-evaluation new file mode 120000 index 0000000000..731059ab5d --- /dev/null +++ b/Lang/Python/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/Python \ No newline at end of file diff --git a/Lang/Python/Runtime-evaluation-In-an-environment b/Lang/Python/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..f322e031e6 --- /dev/null +++ b/Lang/Python/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/Python \ No newline at end of file diff --git a/Lang/Python/S-Expressions b/Lang/Python/S-Expressions new file mode 120000 index 0000000000..337cc74445 --- /dev/null +++ b/Lang/Python/S-Expressions @@ -0,0 +1 @@ +../../Task/S-Expressions/Python \ No newline at end of file diff --git a/Lang/Python/SEDOLs b/Lang/Python/SEDOLs new file mode 120000 index 0000000000..5f5955763c --- /dev/null +++ b/Lang/Python/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/Python \ No newline at end of file diff --git a/Lang/Python/Safe-addition b/Lang/Python/Safe-addition new file mode 120000 index 0000000000..b5a4998ec9 --- /dev/null +++ b/Lang/Python/Safe-addition @@ -0,0 +1 @@ +../../Task/Safe-addition/Python \ No newline at end of file diff --git a/Lang/Python/Same-Fringe b/Lang/Python/Same-Fringe new file mode 120000 index 0000000000..04bb3a2c2e --- /dev/null +++ b/Lang/Python/Same-Fringe @@ -0,0 +1 @@ +../../Task/Same-Fringe/Python \ No newline at end of file diff --git a/Lang/Python/Scope-modifiers b/Lang/Python/Scope-modifiers new file mode 120000 index 0000000000..ce2813cfd8 --- /dev/null +++ b/Lang/Python/Scope-modifiers @@ -0,0 +1 @@ +../../Task/Scope-modifiers/Python \ No newline at end of file diff --git a/Lang/Python/Secure-temporary-file b/Lang/Python/Secure-temporary-file new file mode 120000 index 0000000000..15ca7ba11e --- /dev/null +++ b/Lang/Python/Secure-temporary-file @@ -0,0 +1 @@ +../../Task/Secure-temporary-file/Python \ No newline at end of file diff --git a/Lang/Python/Self-describing-numbers b/Lang/Python/Self-describing-numbers new file mode 120000 index 0000000000..c1a08cc58b --- /dev/null +++ b/Lang/Python/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/Python \ No newline at end of file diff --git a/Lang/Python/Self-referential-sequence b/Lang/Python/Self-referential-sequence new file mode 120000 index 0000000000..c279c52818 --- /dev/null +++ b/Lang/Python/Self-referential-sequence @@ -0,0 +1 @@ +../../Task/Self-referential-sequence/Python \ No newline at end of file diff --git a/Lang/Python/Semordnilap b/Lang/Python/Semordnilap new file mode 120000 index 0000000000..d230e12243 --- /dev/null +++ b/Lang/Python/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/Python \ No newline at end of file diff --git a/Lang/Python/Send-an-unknown-method-call b/Lang/Python/Send-an-unknown-method-call new file mode 120000 index 0000000000..95696e8a9a --- /dev/null +++ b/Lang/Python/Send-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Send-an-unknown-method-call/Python \ No newline at end of file diff --git a/Lang/Python/Send-email b/Lang/Python/Send-email new file mode 120000 index 0000000000..16f801e669 --- /dev/null +++ b/Lang/Python/Send-email @@ -0,0 +1 @@ +../../Task/Send-email/Python \ No newline at end of file diff --git a/Lang/Python/Sequence-of-non-squares b/Lang/Python/Sequence-of-non-squares new file mode 120000 index 0000000000..658770c336 --- /dev/null +++ b/Lang/Python/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Python \ No newline at end of file diff --git a/Lang/Python/Set b/Lang/Python/Set new file mode 120000 index 0000000000..81f248a541 --- /dev/null +++ b/Lang/Python/Set @@ -0,0 +1 @@ +../../Task/Set/Python \ No newline at end of file diff --git a/Lang/Python/Set-consolidation b/Lang/Python/Set-consolidation new file mode 120000 index 0000000000..1aa318f240 --- /dev/null +++ b/Lang/Python/Set-consolidation @@ -0,0 +1 @@ +../../Task/Set-consolidation/Python \ No newline at end of file diff --git a/Lang/Python/Set-of-real-numbers b/Lang/Python/Set-of-real-numbers new file mode 120000 index 0000000000..c75c7b0780 --- /dev/null +++ b/Lang/Python/Set-of-real-numbers @@ -0,0 +1 @@ +../../Task/Set-of-real-numbers/Python \ No newline at end of file diff --git a/Lang/Qi/Pascals-triangle b/Lang/Qi/Pascals-triangle new file mode 120000 index 0000000000..e73673c01d --- /dev/null +++ b/Lang/Qi/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Qi \ No newline at end of file diff --git a/Lang/Qi/Permutations b/Lang/Qi/Permutations new file mode 120000 index 0000000000..72057b4082 --- /dev/null +++ b/Lang/Qi/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Qi \ No newline at end of file diff --git a/Lang/Qi/Power-set b/Lang/Qi/Power-set new file mode 120000 index 0000000000..fc6c6d48a4 --- /dev/null +++ b/Lang/Qi/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Qi \ No newline at end of file diff --git a/Lang/Qi/Primality-by-trial-division b/Lang/Qi/Primality-by-trial-division new file mode 120000 index 0000000000..f8034bcd79 --- /dev/null +++ b/Lang/Qi/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Qi \ No newline at end of file diff --git a/Lang/Qi/Range-extraction b/Lang/Qi/Range-extraction new file mode 120000 index 0000000000..80b46a7f70 --- /dev/null +++ b/Lang/Qi/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/Qi \ No newline at end of file diff --git a/Lang/Qi/Remove-duplicate-elements b/Lang/Qi/Remove-duplicate-elements new file mode 120000 index 0000000000..91b72560ba --- /dev/null +++ b/Lang/Qi/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Qi \ No newline at end of file diff --git a/Lang/Qi/Reverse-a-string b/Lang/Qi/Reverse-a-string new file mode 120000 index 0000000000..331fb27dbe --- /dev/null +++ b/Lang/Qi/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Qi \ No newline at end of file diff --git a/Lang/Qi/Send-an-unknown-method-call b/Lang/Qi/Send-an-unknown-method-call new file mode 120000 index 0000000000..591365b7fb --- /dev/null +++ b/Lang/Qi/Send-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Send-an-unknown-method-call/Qi \ No newline at end of file diff --git a/Lang/R/Arbitrary-precision-integers--included- b/Lang/R/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..61353dedbd --- /dev/null +++ b/Lang/R/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/R \ No newline at end of file diff --git a/Lang/R/Arbitrary-precision-integers-included b/Lang/R/Arbitrary-precision-integers-included deleted file mode 120000 index 171de676d6..0000000000 --- a/Lang/R/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/R \ No newline at end of file diff --git a/Lang/R/Catalan-numbers b/Lang/R/Catalan-numbers new file mode 120000 index 0000000000..8182737bf9 --- /dev/null +++ b/Lang/R/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/R \ No newline at end of file diff --git a/Lang/R/Copy-a-string b/Lang/R/Copy-a-string new file mode 120000 index 0000000000..2df38ea849 --- /dev/null +++ b/Lang/R/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/R \ No newline at end of file diff --git a/Lang/R/Environment-variables b/Lang/R/Environment-variables new file mode 120000 index 0000000000..4cf3ca4246 --- /dev/null +++ b/Lang/R/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/R \ No newline at end of file diff --git a/Lang/R/N-queens-problem b/Lang/R/N-queens-problem new file mode 120000 index 0000000000..5dcc62f7cd --- /dev/null +++ b/Lang/R/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/R \ No newline at end of file diff --git a/Lang/R/Named-parameters b/Lang/R/Named-parameters new file mode 120000 index 0000000000..2c949a2600 --- /dev/null +++ b/Lang/R/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/R \ No newline at end of file diff --git a/Lang/R/Non-continuous-subsequences b/Lang/R/Non-continuous-subsequences new file mode 120000 index 0000000000..9101390604 --- /dev/null +++ b/Lang/R/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/R \ No newline at end of file diff --git a/Lang/R/Non-decimal-radices-Input b/Lang/R/Non-decimal-radices-Input new file mode 120000 index 0000000000..0158bbdbb5 --- /dev/null +++ b/Lang/R/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/R \ No newline at end of file diff --git a/Lang/R/Non-decimal-radices-Output b/Lang/R/Non-decimal-radices-Output new file mode 120000 index 0000000000..d6b11e65cd --- /dev/null +++ b/Lang/R/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/R \ No newline at end of file diff --git a/Lang/R/Nth-root b/Lang/R/Nth-root new file mode 120000 index 0000000000..7e4b123733 --- /dev/null +++ b/Lang/R/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/R \ No newline at end of file diff --git a/Lang/R/Null-object b/Lang/R/Null-object new file mode 120000 index 0000000000..21312e976d --- /dev/null +++ b/Lang/R/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/R \ No newline at end of file diff --git a/Lang/R/Number-reversal-game b/Lang/R/Number-reversal-game new file mode 120000 index 0000000000..93abaa3f41 --- /dev/null +++ b/Lang/R/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/R \ No newline at end of file diff --git a/Lang/R/Numerical-integration b/Lang/R/Numerical-integration new file mode 120000 index 0000000000..026bf1bd86 --- /dev/null +++ b/Lang/R/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/R \ No newline at end of file diff --git a/Lang/R/One-dimensional-cellular-automata b/Lang/R/One-dimensional-cellular-automata new file mode 120000 index 0000000000..8274e5a2f7 --- /dev/null +++ b/Lang/R/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/R \ No newline at end of file diff --git a/Lang/R/OpenGL b/Lang/R/OpenGL new file mode 120000 index 0000000000..4c3a799752 --- /dev/null +++ b/Lang/R/OpenGL @@ -0,0 +1 @@ +../../Task/OpenGL/R \ No newline at end of file diff --git a/Lang/R/Optional-parameters b/Lang/R/Optional-parameters new file mode 120000 index 0000000000..201dab653e --- /dev/null +++ b/Lang/R/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/R \ No newline at end of file diff --git a/Lang/R/Palindrome-detection b/Lang/R/Palindrome-detection new file mode 120000 index 0000000000..3a53722e17 --- /dev/null +++ b/Lang/R/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/R \ No newline at end of file diff --git a/Lang/R/Pangram-checker b/Lang/R/Pangram-checker new file mode 120000 index 0000000000..782b4e7eb7 --- /dev/null +++ b/Lang/R/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/R \ No newline at end of file diff --git a/Lang/R/Partial-function-application b/Lang/R/Partial-function-application new file mode 120000 index 0000000000..b11e411be8 --- /dev/null +++ b/Lang/R/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/R \ No newline at end of file diff --git a/Lang/R/Pascals-triangle b/Lang/R/Pascals-triangle new file mode 120000 index 0000000000..70887cf5c5 --- /dev/null +++ b/Lang/R/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/R \ No newline at end of file diff --git a/Lang/R/Perfect-numbers b/Lang/R/Perfect-numbers new file mode 120000 index 0000000000..934529f2c9 --- /dev/null +++ b/Lang/R/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/R \ No newline at end of file diff --git a/Lang/R/Permutation-test b/Lang/R/Permutation-test new file mode 120000 index 0000000000..901c7ba904 --- /dev/null +++ b/Lang/R/Permutation-test @@ -0,0 +1 @@ +../../Task/Permutation-test/R \ No newline at end of file diff --git a/Lang/R/Permutations b/Lang/R/Permutations new file mode 120000 index 0000000000..201751a0a0 --- /dev/null +++ b/Lang/R/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/R \ No newline at end of file diff --git a/Lang/R/Pick-random-element b/Lang/R/Pick-random-element new file mode 120000 index 0000000000..08bbc58271 --- /dev/null +++ b/Lang/R/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/R \ No newline at end of file diff --git a/Lang/R/Play-recorded-sounds b/Lang/R/Play-recorded-sounds new file mode 120000 index 0000000000..93cd1c10d3 --- /dev/null +++ b/Lang/R/Play-recorded-sounds @@ -0,0 +1 @@ +../../Task/Play-recorded-sounds/R \ No newline at end of file diff --git a/Lang/R/Playing-cards b/Lang/R/Playing-cards new file mode 120000 index 0000000000..f1612850ea --- /dev/null +++ b/Lang/R/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/R \ No newline at end of file diff --git a/Lang/R/Plot-coordinate-pairs b/Lang/R/Plot-coordinate-pairs new file mode 120000 index 0000000000..0b26442cd8 --- /dev/null +++ b/Lang/R/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/R \ No newline at end of file diff --git a/Lang/R/Polymorphism b/Lang/R/Polymorphism new file mode 120000 index 0000000000..5889b07d2d --- /dev/null +++ b/Lang/R/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/R \ No newline at end of file diff --git a/Lang/R/Polynomial-long-division b/Lang/R/Polynomial-long-division new file mode 120000 index 0000000000..5e8c7892bc --- /dev/null +++ b/Lang/R/Polynomial-long-division @@ -0,0 +1 @@ +../../Task/Polynomial-long-division/R \ No newline at end of file diff --git a/Lang/R/Polynomial-regression b/Lang/R/Polynomial-regression new file mode 120000 index 0000000000..859c717c58 --- /dev/null +++ b/Lang/R/Polynomial-regression @@ -0,0 +1 @@ +../../Task/Polynomial-regression/R \ No newline at end of file diff --git a/Lang/R/Power-set b/Lang/R/Power-set new file mode 120000 index 0000000000..7eae1bd4a3 --- /dev/null +++ b/Lang/R/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/R \ No newline at end of file diff --git a/Lang/R/Price-fraction b/Lang/R/Price-fraction new file mode 120000 index 0000000000..4baeffdf9c --- /dev/null +++ b/Lang/R/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/R \ No newline at end of file diff --git a/Lang/R/Primality-by-trial-division b/Lang/R/Primality-by-trial-division new file mode 120000 index 0000000000..4bbe33c841 --- /dev/null +++ b/Lang/R/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/R \ No newline at end of file diff --git a/Lang/R/Prime-decomposition b/Lang/R/Prime-decomposition new file mode 120000 index 0000000000..ea96cd54d8 --- /dev/null +++ b/Lang/R/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/R \ No newline at end of file diff --git a/Lang/R/Priority-queue b/Lang/R/Priority-queue new file mode 120000 index 0000000000..2a7f94a159 --- /dev/null +++ b/Lang/R/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/R \ No newline at end of file diff --git a/Lang/R/Probabilistic-choice b/Lang/R/Probabilistic-choice new file mode 120000 index 0000000000..936778ce71 --- /dev/null +++ b/Lang/R/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/R \ No newline at end of file diff --git a/Lang/R/Program-name b/Lang/R/Program-name new file mode 120000 index 0000000000..0e68c1d330 --- /dev/null +++ b/Lang/R/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/R \ No newline at end of file diff --git a/Lang/R/Program-termination b/Lang/R/Program-termination new file mode 120000 index 0000000000..6812fe8dd3 --- /dev/null +++ b/Lang/R/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/R \ No newline at end of file diff --git a/Lang/R/QR-decomposition b/Lang/R/QR-decomposition new file mode 120000 index 0000000000..de73c899ee --- /dev/null +++ b/Lang/R/QR-decomposition @@ -0,0 +1 @@ +../../Task/QR-decomposition/R \ No newline at end of file diff --git a/Lang/R/Quaternion-type b/Lang/R/Quaternion-type new file mode 120000 index 0000000000..2e826895b9 --- /dev/null +++ b/Lang/R/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/R \ No newline at end of file diff --git a/Lang/R/Queue-Definition b/Lang/R/Queue-Definition new file mode 120000 index 0000000000..fc47f77de5 --- /dev/null +++ b/Lang/R/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/R \ No newline at end of file diff --git a/Lang/R/Random-number-generator--included- b/Lang/R/Random-number-generator--included- new file mode 120000 index 0000000000..bae78fb1ca --- /dev/null +++ b/Lang/R/Random-number-generator--included- @@ -0,0 +1 @@ +../../Task/Random-number-generator--included-/R \ No newline at end of file diff --git a/Lang/R/Random-numbers b/Lang/R/Random-numbers new file mode 120000 index 0000000000..02bdc086b4 --- /dev/null +++ b/Lang/R/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/R \ No newline at end of file diff --git a/Lang/R/Range-expansion b/Lang/R/Range-expansion new file mode 120000 index 0000000000..dc32e7fb6e --- /dev/null +++ b/Lang/R/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/R \ No newline at end of file diff --git a/Lang/R/Ray-casting-algorithm b/Lang/R/Ray-casting-algorithm new file mode 120000 index 0000000000..3d76d44ba8 --- /dev/null +++ b/Lang/R/Ray-casting-algorithm @@ -0,0 +1 @@ +../../Task/Ray-casting-algorithm/R \ No newline at end of file diff --git a/Lang/R/Read-a-file-line-by-line b/Lang/R/Read-a-file-line-by-line new file mode 120000 index 0000000000..12b2666d2f --- /dev/null +++ b/Lang/R/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/R \ No newline at end of file diff --git a/Lang/R/Read-a-specific-line-from-a-file b/Lang/R/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..ac41dddbfc --- /dev/null +++ b/Lang/R/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/R \ No newline at end of file diff --git a/Lang/R/Read-entire-file b/Lang/R/Read-entire-file new file mode 120000 index 0000000000..f27895e147 --- /dev/null +++ b/Lang/R/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/R \ No newline at end of file diff --git a/Lang/R/Real-constants-and-functions b/Lang/R/Real-constants-and-functions new file mode 120000 index 0000000000..99707749dc --- /dev/null +++ b/Lang/R/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/R \ No newline at end of file diff --git a/Lang/R/Reduced-row-echelon-form b/Lang/R/Reduced-row-echelon-form new file mode 120000 index 0000000000..fa13d99787 --- /dev/null +++ b/Lang/R/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/R \ No newline at end of file diff --git a/Lang/R/Regular-expressions b/Lang/R/Regular-expressions new file mode 120000 index 0000000000..58251bece1 --- /dev/null +++ b/Lang/R/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/R \ No newline at end of file diff --git a/Lang/R/Rename-a-file b/Lang/R/Rename-a-file new file mode 120000 index 0000000000..d3214c3f95 --- /dev/null +++ b/Lang/R/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/R \ No newline at end of file diff --git a/Lang/R/Repeat-a-string b/Lang/R/Repeat-a-string new file mode 120000 index 0000000000..3796815973 --- /dev/null +++ b/Lang/R/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/R \ No newline at end of file diff --git a/Lang/R/Return-multiple-values b/Lang/R/Return-multiple-values new file mode 120000 index 0000000000..0799839e73 --- /dev/null +++ b/Lang/R/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/R \ No newline at end of file diff --git a/Lang/R/Reverse-a-string b/Lang/R/Reverse-a-string new file mode 120000 index 0000000000..7de72fadb0 --- /dev/null +++ b/Lang/R/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/R \ No newline at end of file diff --git a/Lang/R/Roman-numerals-Encode b/Lang/R/Roman-numerals-Encode new file mode 120000 index 0000000000..7c04412a00 --- /dev/null +++ b/Lang/R/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/R \ No newline at end of file diff --git a/Lang/R/Roots-of-a-function b/Lang/R/Roots-of-a-function new file mode 120000 index 0000000000..8c91781850 --- /dev/null +++ b/Lang/R/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/R \ No newline at end of file diff --git a/Lang/R/Roots-of-a-quadratic-function b/Lang/R/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..e8c29af260 --- /dev/null +++ b/Lang/R/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/R \ No newline at end of file diff --git a/Lang/R/Roots-of-unity b/Lang/R/Roots-of-unity new file mode 120000 index 0000000000..699087d9b5 --- /dev/null +++ b/Lang/R/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/R \ No newline at end of file diff --git a/Lang/R/Rosetta-Code-Count-examples b/Lang/R/Rosetta-Code-Count-examples new file mode 120000 index 0000000000..d6d6b87161 --- /dev/null +++ b/Lang/R/Rosetta-Code-Count-examples @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Count-examples/R \ No newline at end of file diff --git a/Lang/R/Rosetta-Code-Find-unimplemented-tasks b/Lang/R/Rosetta-Code-Find-unimplemented-tasks new file mode 120000 index 0000000000..712b1b6e80 --- /dev/null +++ b/Lang/R/Rosetta-Code-Find-unimplemented-tasks @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Find-unimplemented-tasks/R \ No newline at end of file diff --git a/Lang/R/Rosetta-Code-Fix-code-tags b/Lang/R/Rosetta-Code-Fix-code-tags new file mode 120000 index 0000000000..d83d287f10 --- /dev/null +++ b/Lang/R/Rosetta-Code-Fix-code-tags @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Fix-code-tags/R \ No newline at end of file diff --git a/Lang/R/Rosetta-Code-Rank-languages-by-popularity b/Lang/R/Rosetta-Code-Rank-languages-by-popularity new file mode 120000 index 0000000000..7477d0e199 --- /dev/null +++ b/Lang/R/Rosetta-Code-Rank-languages-by-popularity @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-popularity/R \ No newline at end of file diff --git a/Lang/R/Rot-13 b/Lang/R/Rot-13 new file mode 120000 index 0000000000..0d917fbc27 --- /dev/null +++ b/Lang/R/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/R \ No newline at end of file diff --git a/Lang/R/Run-length-encoding b/Lang/R/Run-length-encoding new file mode 120000 index 0000000000..7b6960f804 --- /dev/null +++ b/Lang/R/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/R \ No newline at end of file diff --git a/Lang/R/Runtime-evaluation b/Lang/R/Runtime-evaluation new file mode 120000 index 0000000000..431ac6e477 --- /dev/null +++ b/Lang/R/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/R \ No newline at end of file diff --git a/Lang/R/Runtime-evaluation-In-an-environment b/Lang/R/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..2f677724c7 --- /dev/null +++ b/Lang/R/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/R \ No newline at end of file diff --git a/Lang/R/SEDOLs b/Lang/R/SEDOLs new file mode 120000 index 0000000000..86134c2254 --- /dev/null +++ b/Lang/R/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/R \ No newline at end of file diff --git a/Lang/R/Scope-modifiers b/Lang/R/Scope-modifiers new file mode 120000 index 0000000000..810906172d --- /dev/null +++ b/Lang/R/Scope-modifiers @@ -0,0 +1 @@ +../../Task/Scope-modifiers/R \ No newline at end of file diff --git a/Lang/R/Sequence-of-non-squares b/Lang/R/Sequence-of-non-squares new file mode 120000 index 0000000000..a2546250ce --- /dev/null +++ b/Lang/R/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/R \ No newline at end of file diff --git a/Lang/REALbasic/Read-entire-file b/Lang/REALbasic/Read-entire-file new file mode 120000 index 0000000000..9cc725d4f2 --- /dev/null +++ b/Lang/REALbasic/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/REALbasic \ No newline at end of file diff --git a/Lang/REALbasic/Rename-a-file b/Lang/REALbasic/Rename-a-file new file mode 120000 index 0000000000..55d8c9450d --- /dev/null +++ b/Lang/REALbasic/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/REALbasic \ No newline at end of file diff --git a/Lang/REALbasic/Repeat-a-string b/Lang/REALbasic/Repeat-a-string new file mode 120000 index 0000000000..e8bd90e071 --- /dev/null +++ b/Lang/REALbasic/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/REALbasic \ No newline at end of file diff --git a/Lang/REBOL/Copy-a-string b/Lang/REBOL/Copy-a-string new file mode 120000 index 0000000000..8babad9959 --- /dev/null +++ b/Lang/REBOL/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/REBOL \ No newline at end of file diff --git a/Lang/REBOL/Environment-variables b/Lang/REBOL/Environment-variables new file mode 120000 index 0000000000..1742700711 --- /dev/null +++ b/Lang/REBOL/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/REBOL \ No newline at end of file diff --git a/Lang/REBOL/Null-object b/Lang/REBOL/Null-object new file mode 120000 index 0000000000..0b324069d2 --- /dev/null +++ b/Lang/REBOL/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/REBOL \ No newline at end of file diff --git a/Lang/REBOL/Palindrome-detection b/Lang/REBOL/Palindrome-detection new file mode 120000 index 0000000000..45e3490dd4 --- /dev/null +++ b/Lang/REBOL/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/REBOL \ No newline at end of file diff --git a/Lang/REBOL/Percentage-difference-between-images b/Lang/REBOL/Percentage-difference-between-images new file mode 120000 index 0000000000..47e0c29027 --- /dev/null +++ b/Lang/REBOL/Percentage-difference-between-images @@ -0,0 +1 @@ +../../Task/Percentage-difference-between-images/REBOL \ No newline at end of file diff --git a/Lang/REBOL/Perfect-numbers b/Lang/REBOL/Perfect-numbers new file mode 120000 index 0000000000..888589d0dd --- /dev/null +++ b/Lang/REBOL/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/REBOL \ No newline at end of file diff --git a/Lang/REBOL/Primality-by-trial-division b/Lang/REBOL/Primality-by-trial-division new file mode 120000 index 0000000000..6e14471054 --- /dev/null +++ b/Lang/REBOL/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/REBOL \ No newline at end of file diff --git a/Lang/REBOL/Program-termination b/Lang/REBOL/Program-termination new file mode 120000 index 0000000000..7c4ce8b3c8 --- /dev/null +++ b/Lang/REBOL/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/REBOL \ No newline at end of file diff --git a/Lang/REBOL/Queue-Definition b/Lang/REBOL/Queue-Definition new file mode 120000 index 0000000000..aa21697e36 --- /dev/null +++ b/Lang/REBOL/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/REBOL \ No newline at end of file diff --git a/Lang/REBOL/Queue-Usage b/Lang/REBOL/Queue-Usage new file mode 120000 index 0000000000..488c4682f8 --- /dev/null +++ b/Lang/REBOL/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/REBOL \ No newline at end of file diff --git a/Lang/REBOL/Read-entire-file b/Lang/REBOL/Read-entire-file new file mode 120000 index 0000000000..8d1ffdb8c8 --- /dev/null +++ b/Lang/REBOL/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/REBOL \ No newline at end of file diff --git a/Lang/REBOL/Regular-expressions b/Lang/REBOL/Regular-expressions new file mode 120000 index 0000000000..cc056f3dfc --- /dev/null +++ b/Lang/REBOL/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/REBOL \ No newline at end of file diff --git a/Lang/REBOL/Remove-duplicate-elements b/Lang/REBOL/Remove-duplicate-elements new file mode 120000 index 0000000000..989597f93c --- /dev/null +++ b/Lang/REBOL/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/REBOL \ No newline at end of file diff --git a/Lang/REBOL/Rename-a-file b/Lang/REBOL/Rename-a-file new file mode 120000 index 0000000000..d5b1f76dba --- /dev/null +++ b/Lang/REBOL/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/REBOL \ No newline at end of file diff --git a/Lang/REBOL/Repeat-a-string b/Lang/REBOL/Repeat-a-string new file mode 120000 index 0000000000..df3bda003c --- /dev/null +++ b/Lang/REBOL/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/REBOL \ No newline at end of file diff --git a/Lang/REBOL/Reverse-a-string b/Lang/REBOL/Reverse-a-string new file mode 120000 index 0000000000..4fa66fa042 --- /dev/null +++ b/Lang/REBOL/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/REBOL \ No newline at end of file diff --git a/Lang/REBOL/Rot-13 b/Lang/REBOL/Rot-13 new file mode 120000 index 0000000000..344b9949b8 --- /dev/null +++ b/Lang/REBOL/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/REBOL \ No newline at end of file diff --git a/Lang/REBOL/Runtime-evaluation-In-an-environment b/Lang/REBOL/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..00ac88948d --- /dev/null +++ b/Lang/REBOL/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/REBOL \ No newline at end of file diff --git a/Lang/REBOL/Send-email b/Lang/REBOL/Send-email new file mode 120000 index 0000000000..7a102c33ea --- /dev/null +++ b/Lang/REBOL/Send-email @@ -0,0 +1 @@ +../../Task/Send-email/REBOL \ No newline at end of file diff --git a/Lang/REXX/Arbitrary-precision-integers--included- b/Lang/REXX/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..0936a3fe02 --- /dev/null +++ b/Lang/REXX/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/REXX \ No newline at end of file diff --git a/Lang/REXX/Arbitrary-precision-integers-included b/Lang/REXX/Arbitrary-precision-integers-included deleted file mode 120000 index fdedb62758..0000000000 --- a/Lang/REXX/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/REXX \ No newline at end of file diff --git a/Lang/REXX/Binary-digits b/Lang/REXX/Binary-digits new file mode 120000 index 0000000000..3c052e6c1b --- /dev/null +++ b/Lang/REXX/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/REXX \ No newline at end of file diff --git a/Lang/REXX/Brownian-tree b/Lang/REXX/Brownian-tree new file mode 120000 index 0000000000..a60b84534a --- /dev/null +++ b/Lang/REXX/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/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..2c110329c1 --- /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/Calendar-for-real-programmers b/Lang/REXX/Calendar-for-real-programmers deleted file mode 120000 index 958d1bcc9b..0000000000 --- a/Lang/REXX/Calendar-for-real-programmers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Calendar-for-real-programmers/REXX \ No newline at end of file diff --git a/Lang/REXX/Catalan-numbers b/Lang/REXX/Catalan-numbers new file mode 120000 index 0000000000..e5461acb24 --- /dev/null +++ b/Lang/REXX/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/REXX \ No newline at end of file diff --git a/Lang/REXX/Copy-a-string b/Lang/REXX/Copy-a-string new file mode 120000 index 0000000000..6a2f84452f --- /dev/null +++ b/Lang/REXX/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/REXX \ No newline at end of file diff --git a/Lang/REXX/Dragon-curve b/Lang/REXX/Dragon-curve new file mode 120000 index 0000000000..1cf0803332 --- /dev/null +++ b/Lang/REXX/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/REXX \ No newline at end of file diff --git a/Lang/REXX/Environment-variables b/Lang/REXX/Environment-variables new file mode 120000 index 0000000000..671ae7b0fb --- /dev/null +++ b/Lang/REXX/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/REXX \ No newline at end of file diff --git a/Lang/REXX/Execute-a-Markov-algorithm b/Lang/REXX/Execute-a-Markov-algorithm new file mode 120000 index 0000000000..7c3ce7c541 --- /dev/null +++ b/Lang/REXX/Execute-a-Markov-algorithm @@ -0,0 +1 @@ +../../Task/Execute-a-Markov-algorithm/REXX \ No newline at end of file diff --git a/Lang/REXX/Guess-the-number-With-feedback--player- b/Lang/REXX/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..28180abdab --- /dev/null +++ b/Lang/REXX/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/REXX \ No newline at end of file diff --git a/Lang/REXX/Guess-the-number-With-feedback-player b/Lang/REXX/Guess-the-number-With-feedback-player deleted file mode 120000 index 3804a73ab0..0000000000 --- a/Lang/REXX/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/REXX \ No newline at end of file diff --git a/Lang/REXX/N-queens-problem b/Lang/REXX/N-queens-problem new file mode 120000 index 0000000000..0da1e94289 --- /dev/null +++ b/Lang/REXX/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/REXX \ No newline at end of file diff --git a/Lang/REXX/Named-parameters b/Lang/REXX/Named-parameters new file mode 120000 index 0000000000..50e20b2855 --- /dev/null +++ b/Lang/REXX/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/REXX \ No newline at end of file diff --git a/Lang/REXX/Nautical-bell b/Lang/REXX/Nautical-bell new file mode 120000 index 0000000000..f29fd30908 --- /dev/null +++ b/Lang/REXX/Nautical-bell @@ -0,0 +1 @@ +../../Task/Nautical-bell/REXX \ No newline at end of file diff --git a/Lang/REXX/Non-continuous-subsequences b/Lang/REXX/Non-continuous-subsequences new file mode 120000 index 0000000000..1aa8657af5 --- /dev/null +++ b/Lang/REXX/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/REXX \ No newline at end of file diff --git a/Lang/REXX/Non-decimal-radices-Convert b/Lang/REXX/Non-decimal-radices-Convert new file mode 120000 index 0000000000..c73b26ae95 --- /dev/null +++ b/Lang/REXX/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/REXX \ No newline at end of file diff --git a/Lang/REXX/Non-decimal-radices-Input b/Lang/REXX/Non-decimal-radices-Input new file mode 120000 index 0000000000..e8ecf606eb --- /dev/null +++ b/Lang/REXX/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/REXX \ No newline at end of file diff --git a/Lang/REXX/Non-decimal-radices-Output b/Lang/REXX/Non-decimal-radices-Output new file mode 120000 index 0000000000..44f07707dd --- /dev/null +++ b/Lang/REXX/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/REXX \ No newline at end of file diff --git a/Lang/REXX/Nth-root b/Lang/REXX/Nth-root new file mode 120000 index 0000000000..06b7c2d826 --- /dev/null +++ b/Lang/REXX/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/REXX \ No newline at end of file diff --git a/Lang/REXX/Null-object b/Lang/REXX/Null-object new file mode 120000 index 0000000000..898e0753d8 --- /dev/null +++ b/Lang/REXX/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/REXX \ No newline at end of file diff --git a/Lang/REXX/Number-reversal-game b/Lang/REXX/Number-reversal-game new file mode 120000 index 0000000000..5eb8f7b437 --- /dev/null +++ b/Lang/REXX/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/REXX \ No newline at end of file diff --git a/Lang/REXX/Numerical-integration b/Lang/REXX/Numerical-integration new file mode 120000 index 0000000000..225462b771 --- /dev/null +++ b/Lang/REXX/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/REXX \ No newline at end of file diff --git a/Lang/REXX/One-of-n-lines-in-a-file b/Lang/REXX/One-of-n-lines-in-a-file new file mode 120000 index 0000000000..d34cc398f0 --- /dev/null +++ b/Lang/REXX/One-of-n-lines-in-a-file @@ -0,0 +1 @@ +../../Task/One-of-n-lines-in-a-file/REXX \ No newline at end of file diff --git a/Lang/REXX/Operator-precedence b/Lang/REXX/Operator-precedence new file mode 120000 index 0000000000..91c8a67272 --- /dev/null +++ b/Lang/REXX/Operator-precedence @@ -0,0 +1 @@ +../../Task/Operator-precedence/REXX \ No newline at end of file diff --git a/Lang/REXX/Palindrome-detection b/Lang/REXX/Palindrome-detection new file mode 120000 index 0000000000..5d2a1cc56b --- /dev/null +++ b/Lang/REXX/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/REXX \ No newline at end of file diff --git a/Lang/REXX/Pangram-checker b/Lang/REXX/Pangram-checker new file mode 120000 index 0000000000..6acf288302 --- /dev/null +++ b/Lang/REXX/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/REXX \ No newline at end of file diff --git a/Lang/REXX/Parsing-RPN-calculator-algorithm b/Lang/REXX/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..e5b15221ce --- /dev/null +++ b/Lang/REXX/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/REXX \ No newline at end of file diff --git a/Lang/REXX/Parsing-RPN-to-infix-conversion b/Lang/REXX/Parsing-RPN-to-infix-conversion new file mode 120000 index 0000000000..3d61a9fc3a --- /dev/null +++ b/Lang/REXX/Parsing-RPN-to-infix-conversion @@ -0,0 +1 @@ +../../Task/Parsing-RPN-to-infix-conversion/REXX \ No newline at end of file diff --git a/Lang/REXX/Parsing-Shunting-yard-algorithm b/Lang/REXX/Parsing-Shunting-yard-algorithm new file mode 120000 index 0000000000..1729538091 --- /dev/null +++ b/Lang/REXX/Parsing-Shunting-yard-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-Shunting-yard-algorithm/REXX \ No newline at end of file diff --git a/Lang/REXX/Pascals-triangle b/Lang/REXX/Pascals-triangle new file mode 120000 index 0000000000..f1813390f9 --- /dev/null +++ b/Lang/REXX/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/REXX \ No newline at end of file diff --git a/Lang/REXX/Pascals-triangle-Puzzle b/Lang/REXX/Pascals-triangle-Puzzle new file mode 120000 index 0000000000..2882b08f05 --- /dev/null +++ b/Lang/REXX/Pascals-triangle-Puzzle @@ -0,0 +1 @@ +../../Task/Pascals-triangle-Puzzle/REXX \ No newline at end of file diff --git a/Lang/REXX/Perfect-numbers b/Lang/REXX/Perfect-numbers new file mode 120000 index 0000000000..4f37d7d4bc --- /dev/null +++ b/Lang/REXX/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/REXX \ No newline at end of file diff --git a/Lang/REXX/Permutation-test b/Lang/REXX/Permutation-test new file mode 120000 index 0000000000..6915191f29 --- /dev/null +++ b/Lang/REXX/Permutation-test @@ -0,0 +1 @@ +../../Task/Permutation-test/REXX \ No newline at end of file diff --git a/Lang/REXX/Permutations b/Lang/REXX/Permutations new file mode 120000 index 0000000000..5d4586c72e --- /dev/null +++ b/Lang/REXX/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/REXX \ No newline at end of file diff --git a/Lang/REXX/Permutations-Derangements b/Lang/REXX/Permutations-Derangements new file mode 120000 index 0000000000..4fe70a8959 --- /dev/null +++ b/Lang/REXX/Permutations-Derangements @@ -0,0 +1 @@ +../../Task/Permutations-Derangements/REXX \ No newline at end of file diff --git a/Lang/REXX/Pick-random-element b/Lang/REXX/Pick-random-element new file mode 120000 index 0000000000..9e9fec1c68 --- /dev/null +++ b/Lang/REXX/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/REXX \ No newline at end of file diff --git a/Lang/REXX/Pig-the-dice-game b/Lang/REXX/Pig-the-dice-game new file mode 120000 index 0000000000..f17b6d6be3 --- /dev/null +++ b/Lang/REXX/Pig-the-dice-game @@ -0,0 +1 @@ +../../Task/Pig-the-dice-game/REXX \ No newline at end of file diff --git a/Lang/REXX/Pig-the-dice-game-Player b/Lang/REXX/Pig-the-dice-game-Player new file mode 120000 index 0000000000..c3d0727149 --- /dev/null +++ b/Lang/REXX/Pig-the-dice-game-Player @@ -0,0 +1 @@ +../../Task/Pig-the-dice-game-Player/REXX \ No newline at end of file diff --git a/Lang/REXX/Playing-cards b/Lang/REXX/Playing-cards new file mode 120000 index 0000000000..64a3048595 --- /dev/null +++ b/Lang/REXX/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/REXX \ No newline at end of file diff --git a/Lang/REXX/Power-set b/Lang/REXX/Power-set new file mode 120000 index 0000000000..d18d583571 --- /dev/null +++ b/Lang/REXX/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/REXX \ No newline at end of file diff --git a/Lang/REXX/Price-fraction b/Lang/REXX/Price-fraction new file mode 120000 index 0000000000..c850746155 --- /dev/null +++ b/Lang/REXX/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/REXX \ No newline at end of file diff --git a/Lang/REXX/Primality-by-trial-division b/Lang/REXX/Primality-by-trial-division new file mode 120000 index 0000000000..3a2e0efd62 --- /dev/null +++ b/Lang/REXX/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/REXX \ No newline at end of file diff --git a/Lang/REXX/Prime-decomposition b/Lang/REXX/Prime-decomposition new file mode 120000 index 0000000000..3911d179ca --- /dev/null +++ b/Lang/REXX/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/REXX \ No newline at end of file diff --git a/Lang/REXX/Probabilistic-choice b/Lang/REXX/Probabilistic-choice new file mode 120000 index 0000000000..1867d1d050 --- /dev/null +++ b/Lang/REXX/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/REXX \ No newline at end of file diff --git a/Lang/REXX/Problem-of-Apollonius b/Lang/REXX/Problem-of-Apollonius new file mode 120000 index 0000000000..151a8cf715 --- /dev/null +++ b/Lang/REXX/Problem-of-Apollonius @@ -0,0 +1 @@ +../../Task/Problem-of-Apollonius/REXX \ No newline at end of file diff --git a/Lang/REXX/Program-name b/Lang/REXX/Program-name new file mode 120000 index 0000000000..4d7a0e7a41 --- /dev/null +++ b/Lang/REXX/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/REXX \ No newline at end of file diff --git a/Lang/REXX/Program-termination b/Lang/REXX/Program-termination new file mode 120000 index 0000000000..10cae02417 --- /dev/null +++ b/Lang/REXX/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/REXX \ No newline at end of file diff --git a/Lang/REXX/Pythagorean-triples b/Lang/REXX/Pythagorean-triples new file mode 120000 index 0000000000..21832243f3 --- /dev/null +++ b/Lang/REXX/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/REXX \ No newline at end of file diff --git a/Lang/REXX/Quaternion-type b/Lang/REXX/Quaternion-type new file mode 120000 index 0000000000..18e452fac4 --- /dev/null +++ b/Lang/REXX/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/REXX \ No newline at end of file diff --git a/Lang/REXX/Queue-Definition b/Lang/REXX/Queue-Definition new file mode 120000 index 0000000000..9ec61358b8 --- /dev/null +++ b/Lang/REXX/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/REXX \ No newline at end of file diff --git a/Lang/REXX/Queue-Usage b/Lang/REXX/Queue-Usage new file mode 120000 index 0000000000..1432dca3e5 --- /dev/null +++ b/Lang/REXX/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/REXX \ No newline at end of file diff --git a/Lang/REXX/Random-number-generator--device- b/Lang/REXX/Random-number-generator--device- new file mode 120000 index 0000000000..d9e045e435 --- /dev/null +++ b/Lang/REXX/Random-number-generator--device- @@ -0,0 +1 @@ +../../Task/Random-number-generator--device-/REXX \ No newline at end of file diff --git a/Lang/REXX/Random-numbers b/Lang/REXX/Random-numbers new file mode 120000 index 0000000000..2a4fa79539 --- /dev/null +++ b/Lang/REXX/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/REXX \ No newline at end of file diff --git a/Lang/REXX/Range-expansion b/Lang/REXX/Range-expansion new file mode 120000 index 0000000000..dd5e1cc362 --- /dev/null +++ b/Lang/REXX/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/REXX \ No newline at end of file diff --git a/Lang/REXX/Range-extraction b/Lang/REXX/Range-extraction new file mode 120000 index 0000000000..c73915776d --- /dev/null +++ b/Lang/REXX/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/REXX \ No newline at end of file diff --git a/Lang/REXX/Rate-counter b/Lang/REXX/Rate-counter new file mode 120000 index 0000000000..408b5ff0d2 --- /dev/null +++ b/Lang/REXX/Rate-counter @@ -0,0 +1 @@ +../../Task/Rate-counter/REXX \ No newline at end of file diff --git a/Lang/REXX/Ray-casting-algorithm b/Lang/REXX/Ray-casting-algorithm new file mode 120000 index 0000000000..b2e933a356 --- /dev/null +++ b/Lang/REXX/Ray-casting-algorithm @@ -0,0 +1 @@ +../../Task/Ray-casting-algorithm/REXX \ No newline at end of file diff --git a/Lang/REXX/Read-a-configuration-file b/Lang/REXX/Read-a-configuration-file new file mode 120000 index 0000000000..6ec2b0918e --- /dev/null +++ b/Lang/REXX/Read-a-configuration-file @@ -0,0 +1 @@ +../../Task/Read-a-configuration-file/REXX \ No newline at end of file diff --git a/Lang/REXX/Read-a-file-line-by-line b/Lang/REXX/Read-a-file-line-by-line new file mode 120000 index 0000000000..7ad6a6344d --- /dev/null +++ b/Lang/REXX/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/REXX \ No newline at end of file diff --git a/Lang/REXX/Read-a-specific-line-from-a-file b/Lang/REXX/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..de97f25830 --- /dev/null +++ b/Lang/REXX/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/REXX \ No newline at end of file diff --git a/Lang/REXX/Read-entire-file b/Lang/REXX/Read-entire-file new file mode 120000 index 0000000000..097147f3c7 --- /dev/null +++ b/Lang/REXX/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/REXX \ No newline at end of file diff --git a/Lang/REXX/Real-constants-and-functions b/Lang/REXX/Real-constants-and-functions new file mode 120000 index 0000000000..c00ba2a683 --- /dev/null +++ b/Lang/REXX/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/REXX \ No newline at end of file diff --git a/Lang/REXX/Reduced-row-echelon-form b/Lang/REXX/Reduced-row-echelon-form new file mode 120000 index 0000000000..e6cdf46da5 --- /dev/null +++ b/Lang/REXX/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/REXX \ No newline at end of file diff --git a/Lang/REXX/Regular-expressions b/Lang/REXX/Regular-expressions new file mode 120000 index 0000000000..36c1d2296c --- /dev/null +++ b/Lang/REXX/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/REXX \ No newline at end of file diff --git a/Lang/REXX/Remove-duplicate-elements b/Lang/REXX/Remove-duplicate-elements new file mode 120000 index 0000000000..7a52b1c102 --- /dev/null +++ b/Lang/REXX/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/REXX \ No newline at end of file diff --git a/Lang/REXX/Remove-lines-from-a-file b/Lang/REXX/Remove-lines-from-a-file new file mode 120000 index 0000000000..7d42e53ef4 --- /dev/null +++ b/Lang/REXX/Remove-lines-from-a-file @@ -0,0 +1 @@ +../../Task/Remove-lines-from-a-file/REXX \ No newline at end of file diff --git a/Lang/REXX/Rename-a-file b/Lang/REXX/Rename-a-file new file mode 120000 index 0000000000..ff6fd28b40 --- /dev/null +++ b/Lang/REXX/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/REXX \ No newline at end of file diff --git a/Lang/REXX/Repeat-a-string b/Lang/REXX/Repeat-a-string new file mode 120000 index 0000000000..4ab11f95c8 --- /dev/null +++ b/Lang/REXX/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/REXX \ No newline at end of file diff --git a/Lang/REXX/Resistor-mesh b/Lang/REXX/Resistor-mesh new file mode 120000 index 0000000000..6175984644 --- /dev/null +++ b/Lang/REXX/Resistor-mesh @@ -0,0 +1 @@ +../../Task/Resistor-mesh/REXX \ No newline at end of file diff --git a/Lang/REXX/Return-multiple-values b/Lang/REXX/Return-multiple-values new file mode 120000 index 0000000000..d48d47ff2f --- /dev/null +++ b/Lang/REXX/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/REXX \ No newline at end of file diff --git a/Lang/REXX/Reverse-a-string b/Lang/REXX/Reverse-a-string new file mode 120000 index 0000000000..69dfe828c5 --- /dev/null +++ b/Lang/REXX/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/REXX \ No newline at end of file diff --git a/Lang/REXX/Roman-numerals-Decode b/Lang/REXX/Roman-numerals-Decode new file mode 120000 index 0000000000..7bca66c963 --- /dev/null +++ b/Lang/REXX/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/REXX \ No newline at end of file diff --git a/Lang/REXX/Roman-numerals-Encode b/Lang/REXX/Roman-numerals-Encode new file mode 120000 index 0000000000..cf96bd2d84 --- /dev/null +++ b/Lang/REXX/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/REXX \ No newline at end of file diff --git a/Lang/REXX/Roots-of-a-function b/Lang/REXX/Roots-of-a-function new file mode 120000 index 0000000000..3072b53e7e --- /dev/null +++ b/Lang/REXX/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/REXX \ No newline at end of file diff --git a/Lang/REXX/Roots-of-a-quadratic-function b/Lang/REXX/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..2b09a8415c --- /dev/null +++ b/Lang/REXX/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/REXX \ No newline at end of file diff --git a/Lang/REXX/Roots-of-unity b/Lang/REXX/Roots-of-unity new file mode 120000 index 0000000000..37cb34034d --- /dev/null +++ b/Lang/REXX/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/REXX \ No newline at end of file diff --git a/Lang/REXX/Rosetta-Code-Fix-code-tags b/Lang/REXX/Rosetta-Code-Fix-code-tags new file mode 120000 index 0000000000..e17cd45332 --- /dev/null +++ b/Lang/REXX/Rosetta-Code-Fix-code-tags @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Fix-code-tags/REXX \ No newline at end of file diff --git a/Lang/REXX/Rosetta-Code-Rank-languages-by-popularity b/Lang/REXX/Rosetta-Code-Rank-languages-by-popularity new file mode 120000 index 0000000000..0a03be6588 --- /dev/null +++ b/Lang/REXX/Rosetta-Code-Rank-languages-by-popularity @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-popularity/REXX \ No newline at end of file diff --git a/Lang/REXX/Rot-13 b/Lang/REXX/Rot-13 new file mode 120000 index 0000000000..f8b25d02db --- /dev/null +++ b/Lang/REXX/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/REXX \ No newline at end of file diff --git a/Lang/REXX/Run-length-encoding b/Lang/REXX/Run-length-encoding new file mode 120000 index 0000000000..c1d2b3b1ba --- /dev/null +++ b/Lang/REXX/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/REXX \ No newline at end of file diff --git a/Lang/REXX/Runtime-evaluation b/Lang/REXX/Runtime-evaluation new file mode 120000 index 0000000000..466cad95fa --- /dev/null +++ b/Lang/REXX/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/REXX \ No newline at end of file diff --git a/Lang/REXX/Runtime-evaluation-In-an-environment b/Lang/REXX/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..d310345e24 --- /dev/null +++ b/Lang/REXX/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/REXX \ No newline at end of file diff --git a/Lang/REXX/S-Expressions b/Lang/REXX/S-Expressions new file mode 120000 index 0000000000..91fff3c782 --- /dev/null +++ b/Lang/REXX/S-Expressions @@ -0,0 +1 @@ +../../Task/S-Expressions/REXX \ No newline at end of file diff --git a/Lang/REXX/SEDOLs b/Lang/REXX/SEDOLs new file mode 120000 index 0000000000..8beff02726 --- /dev/null +++ b/Lang/REXX/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/REXX \ No newline at end of file diff --git a/Lang/REXX/Safe-addition b/Lang/REXX/Safe-addition new file mode 120000 index 0000000000..9b8f43514e --- /dev/null +++ b/Lang/REXX/Safe-addition @@ -0,0 +1 @@ +../../Task/Safe-addition/REXX \ No newline at end of file diff --git a/Lang/REXX/Same-Fringe b/Lang/REXX/Same-Fringe new file mode 120000 index 0000000000..1b84770878 --- /dev/null +++ b/Lang/REXX/Same-Fringe @@ -0,0 +1 @@ +../../Task/Same-Fringe/REXX \ No newline at end of file diff --git a/Lang/REXX/Scope-Function-names-and-labels b/Lang/REXX/Scope-Function-names-and-labels new file mode 120000 index 0000000000..28e84caf4e --- /dev/null +++ b/Lang/REXX/Scope-Function-names-and-labels @@ -0,0 +1 @@ +../../Task/Scope-Function-names-and-labels/REXX \ No newline at end of file diff --git a/Lang/REXX/Scope-modifiers b/Lang/REXX/Scope-modifiers new file mode 120000 index 0000000000..d8721ed9b7 --- /dev/null +++ b/Lang/REXX/Scope-modifiers @@ -0,0 +1 @@ +../../Task/Scope-modifiers/REXX \ No newline at end of file diff --git a/Lang/REXX/Self-describing-numbers b/Lang/REXX/Self-describing-numbers new file mode 120000 index 0000000000..4225b28b97 --- /dev/null +++ b/Lang/REXX/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/REXX \ No newline at end of file diff --git a/Lang/REXX/Self-referential-sequence b/Lang/REXX/Self-referential-sequence new file mode 120000 index 0000000000..c02f1069be --- /dev/null +++ b/Lang/REXX/Self-referential-sequence @@ -0,0 +1 @@ +../../Task/Self-referential-sequence/REXX \ No newline at end of file diff --git a/Lang/REXX/Semordnilap b/Lang/REXX/Semordnilap new file mode 120000 index 0000000000..200fec0cc9 --- /dev/null +++ b/Lang/REXX/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/REXX \ No newline at end of file diff --git a/Lang/REXX/Sequence-of-non-squares b/Lang/REXX/Sequence-of-non-squares new file mode 120000 index 0000000000..90f760ada6 --- /dev/null +++ b/Lang/REXX/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/REXX \ No newline at end of file diff --git a/Lang/REXX/Set b/Lang/REXX/Set new file mode 120000 index 0000000000..42041aceac --- /dev/null +++ b/Lang/REXX/Set @@ -0,0 +1 @@ +../../Task/Set/REXX \ No newline at end of file diff --git a/Lang/REXX/Set-consolidation b/Lang/REXX/Set-consolidation new file mode 120000 index 0000000000..08e5b64a30 --- /dev/null +++ b/Lang/REXX/Set-consolidation @@ -0,0 +1 @@ +../../Task/Set-consolidation/REXX \ No newline at end of file diff --git a/Lang/REXX/Set-of-real-numbers b/Lang/REXX/Set-of-real-numbers new file mode 120000 index 0000000000..dc6723fe81 --- /dev/null +++ b/Lang/REXX/Set-of-real-numbers @@ -0,0 +1 @@ +../../Task/Set-of-real-numbers/REXX \ No newline at end of file diff --git a/Lang/RLaB/Copy-a-string b/Lang/RLaB/Copy-a-string new file mode 120000 index 0000000000..cf75dd8386 --- /dev/null +++ b/Lang/RLaB/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/RLaB \ No newline at end of file diff --git a/Lang/RLaB/Real-constants-and-functions b/Lang/RLaB/Real-constants-and-functions new file mode 120000 index 0000000000..5721033435 --- /dev/null +++ b/Lang/RLaB/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/RLaB \ No newline at end of file diff --git a/Lang/RLaB/Reverse-a-string b/Lang/RLaB/Reverse-a-string new file mode 120000 index 0000000000..e3aa30d8cd --- /dev/null +++ b/Lang/RLaB/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/RLaB \ No newline at end of file diff --git a/Lang/RLaB/Roots-of-a-function b/Lang/RLaB/Roots-of-a-function new file mode 120000 index 0000000000..70fada4700 --- /dev/null +++ b/Lang/RLaB/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/RLaB \ No newline at end of file diff --git a/Lang/RLaB/Roots-of-unity b/Lang/RLaB/Roots-of-unity new file mode 120000 index 0000000000..47f9034e83 --- /dev/null +++ b/Lang/RLaB/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/RLaB \ No newline at end of file diff --git a/Lang/Racket/Arbitrary-precision-integers--included- b/Lang/Racket/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..559cd2bf09 --- /dev/null +++ b/Lang/Racket/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Racket \ No newline at end of file diff --git a/Lang/Racket/Arbitrary-precision-integers-included b/Lang/Racket/Arbitrary-precision-integers-included deleted file mode 120000 index 6c3f0607cf..0000000000 --- a/Lang/Racket/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Racket \ No newline at end of file diff --git a/Lang/Racket/Binary-digits b/Lang/Racket/Binary-digits new file mode 120000 index 0000000000..e49e4eb506 --- /dev/null +++ b/Lang/Racket/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Racket \ No newline at end of file diff --git a/Lang/Racket/Catalan-numbers b/Lang/Racket/Catalan-numbers new file mode 120000 index 0000000000..af60dd5e02 --- /dev/null +++ b/Lang/Racket/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Racket \ No newline at end of file diff --git a/Lang/Racket/Dragon-curve b/Lang/Racket/Dragon-curve new file mode 120000 index 0000000000..90b8ab370c --- /dev/null +++ b/Lang/Racket/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/Racket \ No newline at end of file diff --git a/Lang/Racket/Environment-variables b/Lang/Racket/Environment-variables new file mode 120000 index 0000000000..3fd627dc47 --- /dev/null +++ b/Lang/Racket/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Racket \ No newline at end of file diff --git a/Lang/Racket/Named-parameters b/Lang/Racket/Named-parameters new file mode 120000 index 0000000000..5cb0bee5b2 --- /dev/null +++ b/Lang/Racket/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/Racket \ No newline at end of file diff --git a/Lang/Racket/OpenGL b/Lang/Racket/OpenGL new file mode 120000 index 0000000000..2a0836c4a5 --- /dev/null +++ b/Lang/Racket/OpenGL @@ -0,0 +1 @@ +../../Task/OpenGL/Racket \ No newline at end of file diff --git a/Lang/Racket/Optional-parameters b/Lang/Racket/Optional-parameters new file mode 120000 index 0000000000..16be2757fb --- /dev/null +++ b/Lang/Racket/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/Racket \ No newline at end of file diff --git a/Lang/Racket/Palindrome-detection b/Lang/Racket/Palindrome-detection new file mode 120000 index 0000000000..e8d03fdc55 --- /dev/null +++ b/Lang/Racket/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Racket \ No newline at end of file diff --git a/Lang/Racket/Parametric-polymorphism b/Lang/Racket/Parametric-polymorphism new file mode 120000 index 0000000000..ca3dd1224e --- /dev/null +++ b/Lang/Racket/Parametric-polymorphism @@ -0,0 +1 @@ +../../Task/Parametric-polymorphism/Racket \ No newline at end of file diff --git a/Lang/Racket/Partial-function-application b/Lang/Racket/Partial-function-application new file mode 120000 index 0000000000..627e9d622c --- /dev/null +++ b/Lang/Racket/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/Racket \ No newline at end of file diff --git a/Lang/Racket/Pascals-triangle b/Lang/Racket/Pascals-triangle new file mode 120000 index 0000000000..fd8717c37e --- /dev/null +++ b/Lang/Racket/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Racket \ No newline at end of file diff --git a/Lang/Racket/Pattern-matching b/Lang/Racket/Pattern-matching new file mode 120000 index 0000000000..ba978936b2 --- /dev/null +++ b/Lang/Racket/Pattern-matching @@ -0,0 +1 @@ +../../Task/Pattern-matching/Racket \ No newline at end of file diff --git a/Lang/Racket/Playing-cards b/Lang/Racket/Playing-cards new file mode 120000 index 0000000000..86966428f7 --- /dev/null +++ b/Lang/Racket/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/Racket \ No newline at end of file diff --git a/Lang/Racket/Power-set b/Lang/Racket/Power-set new file mode 120000 index 0000000000..fa1f6c5976 --- /dev/null +++ b/Lang/Racket/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Racket \ No newline at end of file diff --git a/Lang/Racket/Program-name b/Lang/Racket/Program-name new file mode 120000 index 0000000000..42d59ab93f --- /dev/null +++ b/Lang/Racket/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Racket \ No newline at end of file diff --git a/Lang/Racket/Range-expansion b/Lang/Racket/Range-expansion new file mode 120000 index 0000000000..5a9864d5f9 --- /dev/null +++ b/Lang/Racket/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/Racket \ No newline at end of file diff --git a/Lang/Racket/Ray-casting-algorithm b/Lang/Racket/Ray-casting-algorithm new file mode 120000 index 0000000000..5663de4cc7 --- /dev/null +++ b/Lang/Racket/Ray-casting-algorithm @@ -0,0 +1 @@ +../../Task/Ray-casting-algorithm/Racket \ No newline at end of file diff --git a/Lang/Racket/Read-a-file-line-by-line b/Lang/Racket/Read-a-file-line-by-line new file mode 120000 index 0000000000..352f8c34c5 --- /dev/null +++ b/Lang/Racket/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Racket \ No newline at end of file diff --git a/Lang/Racket/Read-entire-file b/Lang/Racket/Read-entire-file new file mode 120000 index 0000000000..4b78264aec --- /dev/null +++ b/Lang/Racket/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Racket \ No newline at end of file diff --git a/Lang/Racket/Real-constants-and-functions b/Lang/Racket/Real-constants-and-functions new file mode 120000 index 0000000000..2a086e840a --- /dev/null +++ b/Lang/Racket/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Racket \ No newline at end of file diff --git a/Lang/Racket/Reduced-row-echelon-form b/Lang/Racket/Reduced-row-echelon-form new file mode 120000 index 0000000000..7d76d31716 --- /dev/null +++ b/Lang/Racket/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/Racket \ No newline at end of file diff --git a/Lang/Racket/Regular-expressions b/Lang/Racket/Regular-expressions new file mode 120000 index 0000000000..613fb3e6bf --- /dev/null +++ b/Lang/Racket/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Racket \ No newline at end of file diff --git a/Lang/Racket/Rename-a-file b/Lang/Racket/Rename-a-file new file mode 120000 index 0000000000..41ea094e16 --- /dev/null +++ b/Lang/Racket/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Racket \ No newline at end of file diff --git a/Lang/Racket/Repeat-a-string b/Lang/Racket/Repeat-a-string new file mode 120000 index 0000000000..74a0b1421c --- /dev/null +++ b/Lang/Racket/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Racket \ No newline at end of file diff --git a/Lang/Racket/Reverse-a-string b/Lang/Racket/Reverse-a-string new file mode 120000 index 0000000000..79e64205cd --- /dev/null +++ b/Lang/Racket/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Racket \ No newline at end of file diff --git a/Lang/Racket/Roots-of-unity b/Lang/Racket/Roots-of-unity new file mode 120000 index 0000000000..a278babe08 --- /dev/null +++ b/Lang/Racket/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/Racket \ No newline at end of file diff --git a/Lang/Racket/Rosetta-Code-Rank-languages-by-popularity b/Lang/Racket/Rosetta-Code-Rank-languages-by-popularity new file mode 120000 index 0000000000..aeb304d9d7 --- /dev/null +++ b/Lang/Racket/Rosetta-Code-Rank-languages-by-popularity @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-popularity/Racket \ No newline at end of file diff --git a/Lang/Racket/Rot-13 b/Lang/Racket/Rot-13 new file mode 120000 index 0000000000..8d244e3704 --- /dev/null +++ b/Lang/Racket/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Racket \ No newline at end of file diff --git a/Lang/Racket/S-Expressions b/Lang/Racket/S-Expressions new file mode 120000 index 0000000000..b9f6e46da7 --- /dev/null +++ b/Lang/Racket/S-Expressions @@ -0,0 +1 @@ +../../Task/S-Expressions/Racket \ No newline at end of file diff --git a/Lang/Racket/SEDOLs b/Lang/Racket/SEDOLs new file mode 120000 index 0000000000..7775cc1d21 --- /dev/null +++ b/Lang/Racket/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/Racket \ No newline at end of file diff --git a/Lang/Racket/Same-Fringe b/Lang/Racket/Same-Fringe new file mode 120000 index 0000000000..fc1bbb9e8b --- /dev/null +++ b/Lang/Racket/Same-Fringe @@ -0,0 +1 @@ +../../Task/Same-Fringe/Racket \ No newline at end of file diff --git a/Lang/Racket/Secure-temporary-file b/Lang/Racket/Secure-temporary-file new file mode 120000 index 0000000000..580a7ae9f8 --- /dev/null +++ b/Lang/Racket/Secure-temporary-file @@ -0,0 +1 @@ +../../Task/Secure-temporary-file/Racket \ No newline at end of file diff --git a/Lang/Racket/Send-email b/Lang/Racket/Send-email new file mode 120000 index 0000000000..75737d75c4 --- /dev/null +++ b/Lang/Racket/Send-email @@ -0,0 +1 @@ +../../Task/Send-email/Racket \ No newline at end of file diff --git a/Lang/Racket/Sequence-of-non-squares b/Lang/Racket/Sequence-of-non-squares new file mode 120000 index 0000000000..5ef7338916 --- /dev/null +++ b/Lang/Racket/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Racket \ No newline at end of file diff --git a/Lang/Racket/Set b/Lang/Racket/Set new file mode 120000 index 0000000000..6f0e7b7b70 --- /dev/null +++ b/Lang/Racket/Set @@ -0,0 +1 @@ +../../Task/Set/Racket \ No newline at end of file diff --git a/Lang/RapidQ/Dragon-curve b/Lang/RapidQ/Dragon-curve new file mode 120000 index 0000000000..159dfbfd18 --- /dev/null +++ b/Lang/RapidQ/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/RapidQ \ No newline at end of file diff --git a/Lang/RapidQ/Pascals-triangle b/Lang/RapidQ/Pascals-triangle new file mode 120000 index 0000000000..20fbee861a --- /dev/null +++ b/Lang/RapidQ/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/RapidQ \ No newline at end of file diff --git a/Lang/Rascal/N-queens-problem b/Lang/Rascal/N-queens-problem new file mode 120000 index 0000000000..e99dc38088 --- /dev/null +++ b/Lang/Rascal/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Rascal \ No newline at end of file diff --git a/Lang/Rascal/Number-reversal-game b/Lang/Rascal/Number-reversal-game new file mode 120000 index 0000000000..cc686eb3ca --- /dev/null +++ b/Lang/Rascal/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/Rascal \ No newline at end of file diff --git a/Lang/Rascal/Order-two-numerical-lists b/Lang/Rascal/Order-two-numerical-lists new file mode 120000 index 0000000000..7a7d271f91 --- /dev/null +++ b/Lang/Rascal/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/Rascal \ No newline at end of file diff --git a/Lang/Rascal/Palindrome-detection b/Lang/Rascal/Palindrome-detection new file mode 120000 index 0000000000..1a318a960c --- /dev/null +++ b/Lang/Rascal/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Rascal \ No newline at end of file diff --git a/Lang/Rascal/Pattern-matching b/Lang/Rascal/Pattern-matching new file mode 120000 index 0000000000..0af64220f6 --- /dev/null +++ b/Lang/Rascal/Pattern-matching @@ -0,0 +1 @@ +../../Task/Pattern-matching/Rascal \ No newline at end of file diff --git a/Lang/Rascal/Power-set b/Lang/Rascal/Power-set new file mode 120000 index 0000000000..116b742efa --- /dev/null +++ b/Lang/Rascal/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Rascal \ No newline at end of file diff --git a/Lang/Rascal/QR-decomposition b/Lang/Rascal/QR-decomposition new file mode 120000 index 0000000000..7c9dd649b2 --- /dev/null +++ b/Lang/Rascal/QR-decomposition @@ -0,0 +1 @@ +../../Task/QR-decomposition/Rascal \ No newline at end of file diff --git a/Lang/Rascal/Random-number-generator--included- b/Lang/Rascal/Random-number-generator--included- new file mode 120000 index 0000000000..d3d563c4db --- /dev/null +++ b/Lang/Rascal/Random-number-generator--included- @@ -0,0 +1 @@ +../../Task/Random-number-generator--included-/Rascal \ No newline at end of file diff --git a/Lang/Rascal/Reverse-a-string b/Lang/Rascal/Reverse-a-string new file mode 120000 index 0000000000..b0ec38fd36 --- /dev/null +++ b/Lang/Rascal/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Rascal \ No newline at end of file diff --git a/Lang/Rascal/Rock-paper-scissors b/Lang/Rascal/Rock-paper-scissors new file mode 120000 index 0000000000..46cc7556ec --- /dev/null +++ b/Lang/Rascal/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/Rascal \ No newline at end of file diff --git a/Lang/Raven/Copy-a-string b/Lang/Raven/Copy-a-string new file mode 120000 index 0000000000..4a40da245c --- /dev/null +++ b/Lang/Raven/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Raven \ No newline at end of file diff --git a/Lang/Raven/Regular-expressions b/Lang/Raven/Regular-expressions new file mode 120000 index 0000000000..e69e5f6e39 --- /dev/null +++ b/Lang/Raven/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Raven \ No newline at end of file diff --git a/Lang/Raven/Remove-duplicate-elements b/Lang/Raven/Remove-duplicate-elements new file mode 120000 index 0000000000..5f55e817e9 --- /dev/null +++ b/Lang/Raven/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Raven \ No newline at end of file diff --git a/Lang/Retro/Binary-digits b/Lang/Retro/Binary-digits new file mode 120000 index 0000000000..324e8b5cf1 --- /dev/null +++ b/Lang/Retro/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Retro \ No newline at end of file diff --git a/Lang/Retro/Copy-a-string b/Lang/Retro/Copy-a-string new file mode 120000 index 0000000000..3380283f7b --- /dev/null +++ b/Lang/Retro/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Retro \ No newline at end of file diff --git a/Lang/Retro/Environment-variables b/Lang/Retro/Environment-variables new file mode 120000 index 0000000000..3e1944e79e --- /dev/null +++ b/Lang/Retro/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Retro \ No newline at end of file diff --git a/Lang/Retro/One-dimensional-cellular-automata b/Lang/Retro/One-dimensional-cellular-automata new file mode 120000 index 0000000000..6031fc86a0 --- /dev/null +++ b/Lang/Retro/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Retro \ No newline at end of file diff --git a/Lang/Retro/Palindrome-detection b/Lang/Retro/Palindrome-detection new file mode 120000 index 0000000000..dcd02004e3 --- /dev/null +++ b/Lang/Retro/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Retro \ No newline at end of file diff --git a/Lang/Retro/Pangram-checker b/Lang/Retro/Pangram-checker new file mode 120000 index 0000000000..920b580086 --- /dev/null +++ b/Lang/Retro/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Retro \ No newline at end of file diff --git a/Lang/Retro/Pascals-triangle b/Lang/Retro/Pascals-triangle new file mode 120000 index 0000000000..191118546a --- /dev/null +++ b/Lang/Retro/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Retro \ No newline at end of file diff --git a/Lang/Retro/Program-termination b/Lang/Retro/Program-termination new file mode 120000 index 0000000000..c60bf42b0d --- /dev/null +++ b/Lang/Retro/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Retro \ No newline at end of file diff --git a/Lang/Retro/Read-entire-file b/Lang/Retro/Read-entire-file new file mode 120000 index 0000000000..c008614eda --- /dev/null +++ b/Lang/Retro/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Retro \ No newline at end of file diff --git a/Lang/Retro/Repeat-a-string b/Lang/Retro/Repeat-a-string new file mode 120000 index 0000000000..f28e856665 --- /dev/null +++ b/Lang/Retro/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Retro \ No newline at end of file diff --git a/Lang/Retro/Return-multiple-values b/Lang/Retro/Return-multiple-values new file mode 120000 index 0000000000..3e28fb0d34 --- /dev/null +++ b/Lang/Retro/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Retro \ No newline at end of file diff --git a/Lang/Retro/Reverse-a-string b/Lang/Retro/Reverse-a-string new file mode 120000 index 0000000000..0a403db433 --- /dev/null +++ b/Lang/Retro/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Retro \ No newline at end of file diff --git a/Lang/Retro/Roman-numerals-Encode b/Lang/Retro/Roman-numerals-Encode new file mode 120000 index 0000000000..40a434963d --- /dev/null +++ b/Lang/Retro/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Retro \ No newline at end of file diff --git a/Lang/Retro/Rot-13 b/Lang/Retro/Rot-13 new file mode 120000 index 0000000000..1c48c8caa9 --- /dev/null +++ b/Lang/Retro/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Retro \ No newline at end of file diff --git a/Lang/Ruby/Arbitrary-precision-integers--included- b/Lang/Ruby/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..ad485bc0e9 --- /dev/null +++ b/Lang/Ruby/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Arbitrary-precision-integers-included b/Lang/Ruby/Arbitrary-precision-integers-included deleted file mode 120000 index 565a808afb..0000000000 --- a/Lang/Ruby/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Binary-digits b/Lang/Ruby/Binary-digits new file mode 120000 index 0000000000..29996e3029 --- /dev/null +++ b/Lang/Ruby/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Brownian-tree b/Lang/Ruby/Brownian-tree new file mode 120000 index 0000000000..1e23df17e1 --- /dev/null +++ b/Lang/Ruby/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/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..15df2b5f1b --- /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/Calendar-for-real-programmers b/Lang/Ruby/Calendar-for-real-programmers deleted file mode 120000 index 3da8978d69..0000000000 --- a/Lang/Ruby/Calendar-for-real-programmers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Calendar-for-real-programmers/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Catalan-numbers b/Lang/Ruby/Catalan-numbers new file mode 120000 index 0000000000..6812496e61 --- /dev/null +++ b/Lang/Ruby/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/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 deleted file mode 120000 index 2e751f5f43..0000000000 --- a/Lang/Ruby/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N +++ /dev/null @@ -1 +0,0 @@ -../../Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/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..385d87387a --- /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/Copy-a-string b/Lang/Ruby/Copy-a-string new file mode 120000 index 0000000000..7d9ed18c4b --- /dev/null +++ b/Lang/Ruby/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Dragon-curve b/Lang/Ruby/Dragon-curve new file mode 120000 index 0000000000..186e9fb3ef --- /dev/null +++ b/Lang/Ruby/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Environment-variables b/Lang/Ruby/Environment-variables new file mode 120000 index 0000000000..4f8468ad3d --- /dev/null +++ b/Lang/Ruby/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Execute-a-Markov-algorithm b/Lang/Ruby/Execute-a-Markov-algorithm new file mode 120000 index 0000000000..e0f557e8a6 --- /dev/null +++ b/Lang/Ruby/Execute-a-Markov-algorithm @@ -0,0 +1 @@ +../../Task/Execute-a-Markov-algorithm/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Guess-the-number-With-feedback--player- b/Lang/Ruby/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..dc31f3c802 --- /dev/null +++ b/Lang/Ruby/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Guess-the-number-With-feedback-player b/Lang/Ruby/Guess-the-number-With-feedback-player deleted file mode 120000 index 821cc0809f..0000000000 --- a/Lang/Ruby/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/Ruby \ No newline at end of file diff --git a/Lang/Ruby/N-queens-problem b/Lang/Ruby/N-queens-problem new file mode 120000 index 0000000000..89f15b293c --- /dev/null +++ b/Lang/Ruby/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Named-parameters b/Lang/Ruby/Named-parameters new file mode 120000 index 0000000000..f9becde6b1 --- /dev/null +++ b/Lang/Ruby/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Non-continuous-subsequences b/Lang/Ruby/Non-continuous-subsequences new file mode 120000 index 0000000000..553ba253d5 --- /dev/null +++ b/Lang/Ruby/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Non-decimal-radices-Convert b/Lang/Ruby/Non-decimal-radices-Convert new file mode 120000 index 0000000000..be4e4de90c --- /dev/null +++ b/Lang/Ruby/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Non-decimal-radices-Input b/Lang/Ruby/Non-decimal-radices-Input new file mode 120000 index 0000000000..3163599893 --- /dev/null +++ b/Lang/Ruby/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Non-decimal-radices-Output b/Lang/Ruby/Non-decimal-radices-Output new file mode 120000 index 0000000000..4ca7cf0c1c --- /dev/null +++ b/Lang/Ruby/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Nth-root b/Lang/Ruby/Nth-root new file mode 120000 index 0000000000..639f33f0a3 --- /dev/null +++ b/Lang/Ruby/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Null-object b/Lang/Ruby/Null-object new file mode 120000 index 0000000000..2f7dc1adbd --- /dev/null +++ b/Lang/Ruby/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Number-names b/Lang/Ruby/Number-names new file mode 120000 index 0000000000..d742466311 --- /dev/null +++ b/Lang/Ruby/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Number-reversal-game b/Lang/Ruby/Number-reversal-game new file mode 120000 index 0000000000..97556b6739 --- /dev/null +++ b/Lang/Ruby/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Numeric-error-propagation b/Lang/Ruby/Numeric-error-propagation new file mode 120000 index 0000000000..3310d094c7 --- /dev/null +++ b/Lang/Ruby/Numeric-error-propagation @@ -0,0 +1 @@ +../../Task/Numeric-error-propagation/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Numerical-integration b/Lang/Ruby/Numerical-integration new file mode 120000 index 0000000000..b0dbb34ab4 --- /dev/null +++ b/Lang/Ruby/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Object-serialization b/Lang/Ruby/Object-serialization new file mode 120000 index 0000000000..7b4130f73f --- /dev/null +++ b/Lang/Ruby/Object-serialization @@ -0,0 +1 @@ +../../Task/Object-serialization/Ruby \ No newline at end of file diff --git a/Lang/Ruby/One-dimensional-cellular-automata b/Lang/Ruby/One-dimensional-cellular-automata new file mode 120000 index 0000000000..9df8fbd920 --- /dev/null +++ b/Lang/Ruby/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Ruby \ No newline at end of file diff --git a/Lang/Ruby/One-of-n-lines-in-a-file b/Lang/Ruby/One-of-n-lines-in-a-file new file mode 120000 index 0000000000..f33dd8afd7 --- /dev/null +++ b/Lang/Ruby/One-of-n-lines-in-a-file @@ -0,0 +1 @@ +../../Task/One-of-n-lines-in-a-file/Ruby \ No newline at end of file diff --git a/Lang/Ruby/OpenGL b/Lang/Ruby/OpenGL new file mode 120000 index 0000000000..0e10686755 --- /dev/null +++ b/Lang/Ruby/OpenGL @@ -0,0 +1 @@ +../../Task/OpenGL/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Optional-parameters b/Lang/Ruby/Optional-parameters new file mode 120000 index 0000000000..e20e472f66 --- /dev/null +++ b/Lang/Ruby/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Order-two-numerical-lists b/Lang/Ruby/Order-two-numerical-lists new file mode 120000 index 0000000000..66200e844a --- /dev/null +++ b/Lang/Ruby/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Palindrome-detection b/Lang/Ruby/Palindrome-detection new file mode 120000 index 0000000000..dc5fcf1b7a --- /dev/null +++ b/Lang/Ruby/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Pangram-checker b/Lang/Ruby/Pangram-checker new file mode 120000 index 0000000000..473b8a9db8 --- /dev/null +++ b/Lang/Ruby/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Parametrized-SQL-statement b/Lang/Ruby/Parametrized-SQL-statement new file mode 120000 index 0000000000..ec341ad0a1 --- /dev/null +++ b/Lang/Ruby/Parametrized-SQL-statement @@ -0,0 +1 @@ +../../Task/Parametrized-SQL-statement/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Parsing-RPN-calculator-algorithm b/Lang/Ruby/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..0359b2d963 --- /dev/null +++ b/Lang/Ruby/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Parsing-RPN-to-infix-conversion b/Lang/Ruby/Parsing-RPN-to-infix-conversion new file mode 120000 index 0000000000..8a8f58af70 --- /dev/null +++ b/Lang/Ruby/Parsing-RPN-to-infix-conversion @@ -0,0 +1 @@ +../../Task/Parsing-RPN-to-infix-conversion/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Parsing-Shunting-yard-algorithm b/Lang/Ruby/Parsing-Shunting-yard-algorithm new file mode 120000 index 0000000000..4bd21fb660 --- /dev/null +++ b/Lang/Ruby/Parsing-Shunting-yard-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-Shunting-yard-algorithm/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Partial-function-application b/Lang/Ruby/Partial-function-application new file mode 120000 index 0000000000..6c19a09363 --- /dev/null +++ b/Lang/Ruby/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Pascals-triangle b/Lang/Ruby/Pascals-triangle new file mode 120000 index 0000000000..2c82746eca --- /dev/null +++ b/Lang/Ruby/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Pascals-triangle-Puzzle b/Lang/Ruby/Pascals-triangle-Puzzle new file mode 120000 index 0000000000..7ddc7f38a8 --- /dev/null +++ b/Lang/Ruby/Pascals-triangle-Puzzle @@ -0,0 +1 @@ +../../Task/Pascals-triangle-Puzzle/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Percentage-difference-between-images b/Lang/Ruby/Percentage-difference-between-images new file mode 120000 index 0000000000..6e6f0cec84 --- /dev/null +++ b/Lang/Ruby/Percentage-difference-between-images @@ -0,0 +1 @@ +../../Task/Percentage-difference-between-images/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Perfect-numbers b/Lang/Ruby/Perfect-numbers new file mode 120000 index 0000000000..b5421cbdc5 --- /dev/null +++ b/Lang/Ruby/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Permutations b/Lang/Ruby/Permutations new file mode 120000 index 0000000000..83016d47b9 --- /dev/null +++ b/Lang/Ruby/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Permutations-Derangements b/Lang/Ruby/Permutations-Derangements new file mode 120000 index 0000000000..4cbb96febf --- /dev/null +++ b/Lang/Ruby/Permutations-Derangements @@ -0,0 +1 @@ +../../Task/Permutations-Derangements/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Pick-random-element b/Lang/Ruby/Pick-random-element new file mode 120000 index 0000000000..ab2c1f4c23 --- /dev/null +++ b/Lang/Ruby/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Pig-the-dice-game b/Lang/Ruby/Pig-the-dice-game new file mode 120000 index 0000000000..5f289bbcb3 --- /dev/null +++ b/Lang/Ruby/Pig-the-dice-game @@ -0,0 +1 @@ +../../Task/Pig-the-dice-game/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Play-recorded-sounds b/Lang/Ruby/Play-recorded-sounds new file mode 120000 index 0000000000..afbec1f431 --- /dev/null +++ b/Lang/Ruby/Play-recorded-sounds @@ -0,0 +1 @@ +../../Task/Play-recorded-sounds/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Playing-cards b/Lang/Ruby/Playing-cards new file mode 120000 index 0000000000..b994fea228 --- /dev/null +++ b/Lang/Ruby/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Plot-coordinate-pairs b/Lang/Ruby/Plot-coordinate-pairs new file mode 120000 index 0000000000..c348107f3b --- /dev/null +++ b/Lang/Ruby/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Polymorphic-copy b/Lang/Ruby/Polymorphic-copy new file mode 120000 index 0000000000..20a886e17f --- /dev/null +++ b/Lang/Ruby/Polymorphic-copy @@ -0,0 +1 @@ +../../Task/Polymorphic-copy/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Polymorphism b/Lang/Ruby/Polymorphism new file mode 120000 index 0000000000..f4f4d36ee6 --- /dev/null +++ b/Lang/Ruby/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Polynomial-long-division b/Lang/Ruby/Polynomial-long-division new file mode 120000 index 0000000000..57c5672ddb --- /dev/null +++ b/Lang/Ruby/Polynomial-long-division @@ -0,0 +1 @@ +../../Task/Polynomial-long-division/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Polynomial-regression b/Lang/Ruby/Polynomial-regression new file mode 120000 index 0000000000..0de9cc263e --- /dev/null +++ b/Lang/Ruby/Polynomial-regression @@ -0,0 +1 @@ +../../Task/Polynomial-regression/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Power-set b/Lang/Ruby/Power-set new file mode 120000 index 0000000000..13a7be4ca8 --- /dev/null +++ b/Lang/Ruby/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Price-fraction b/Lang/Ruby/Price-fraction new file mode 120000 index 0000000000..08cd34ffc5 --- /dev/null +++ b/Lang/Ruby/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Primality-by-trial-division b/Lang/Ruby/Primality-by-trial-division new file mode 120000 index 0000000000..e4fec3721f --- /dev/null +++ b/Lang/Ruby/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Prime-decomposition b/Lang/Ruby/Prime-decomposition new file mode 120000 index 0000000000..c25a7d54c6 --- /dev/null +++ b/Lang/Ruby/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Priority-queue b/Lang/Ruby/Priority-queue new file mode 120000 index 0000000000..59f81bf69b --- /dev/null +++ b/Lang/Ruby/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Probabilistic-choice b/Lang/Ruby/Probabilistic-choice new file mode 120000 index 0000000000..7c562f8c51 --- /dev/null +++ b/Lang/Ruby/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Problem-of-Apollonius b/Lang/Ruby/Problem-of-Apollonius new file mode 120000 index 0000000000..1d9b1c4e09 --- /dev/null +++ b/Lang/Ruby/Problem-of-Apollonius @@ -0,0 +1 @@ +../../Task/Problem-of-Apollonius/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Program-name b/Lang/Ruby/Program-name new file mode 120000 index 0000000000..d1f1a912ac --- /dev/null +++ b/Lang/Ruby/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Program-termination b/Lang/Ruby/Program-termination new file mode 120000 index 0000000000..aa1d97c2c5 --- /dev/null +++ b/Lang/Ruby/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Pythagorean-triples b/Lang/Ruby/Pythagorean-triples new file mode 120000 index 0000000000..50aa3fa9e0 --- /dev/null +++ b/Lang/Ruby/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Quaternion-type b/Lang/Ruby/Quaternion-type new file mode 120000 index 0000000000..c1af2a1904 --- /dev/null +++ b/Lang/Ruby/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Queue-Definition b/Lang/Ruby/Queue-Definition new file mode 120000 index 0000000000..756a9f4b98 --- /dev/null +++ b/Lang/Ruby/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/Ruby \ No newline at end of file diff --git a/Lang/Ruby/RIPEMD-160 b/Lang/Ruby/RIPEMD-160 new file mode 120000 index 0000000000..e05e2993c9 --- /dev/null +++ b/Lang/Ruby/RIPEMD-160 @@ -0,0 +1 @@ +../../Task/RIPEMD-160/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Random-number-generator--device- b/Lang/Ruby/Random-number-generator--device- new file mode 120000 index 0000000000..7bbcac7841 --- /dev/null +++ b/Lang/Ruby/Random-number-generator--device- @@ -0,0 +1 @@ +../../Task/Random-number-generator--device-/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Random-numbers b/Lang/Ruby/Random-numbers new file mode 120000 index 0000000000..2faccb47f6 --- /dev/null +++ b/Lang/Ruby/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Range-expansion b/Lang/Ruby/Range-expansion new file mode 120000 index 0000000000..858894c401 --- /dev/null +++ b/Lang/Ruby/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Range-extraction b/Lang/Ruby/Range-extraction new file mode 120000 index 0000000000..e371f7a5f6 --- /dev/null +++ b/Lang/Ruby/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Read-a-configuration-file b/Lang/Ruby/Read-a-configuration-file new file mode 120000 index 0000000000..603e658ffc --- /dev/null +++ b/Lang/Ruby/Read-a-configuration-file @@ -0,0 +1 @@ +../../Task/Read-a-configuration-file/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Read-a-file-line-by-line b/Lang/Ruby/Read-a-file-line-by-line new file mode 120000 index 0000000000..d33ef4e91d --- /dev/null +++ b/Lang/Ruby/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Read-a-specific-line-from-a-file b/Lang/Ruby/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..de5b1e2a56 --- /dev/null +++ b/Lang/Ruby/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Read-entire-file b/Lang/Ruby/Read-entire-file new file mode 120000 index 0000000000..29a49c680f --- /dev/null +++ b/Lang/Ruby/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Real-constants-and-functions b/Lang/Ruby/Real-constants-and-functions new file mode 120000 index 0000000000..0a5e252d03 --- /dev/null +++ b/Lang/Ruby/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Reduced-row-echelon-form b/Lang/Ruby/Reduced-row-echelon-form new file mode 120000 index 0000000000..a61e528b32 --- /dev/null +++ b/Lang/Ruby/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Regular-expressions b/Lang/Ruby/Regular-expressions new file mode 120000 index 0000000000..03a9c512fd --- /dev/null +++ b/Lang/Ruby/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Remove-duplicate-elements b/Lang/Ruby/Remove-duplicate-elements new file mode 120000 index 0000000000..d10474bb57 --- /dev/null +++ b/Lang/Ruby/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Remove-lines-from-a-file b/Lang/Ruby/Remove-lines-from-a-file new file mode 120000 index 0000000000..ae710f1305 --- /dev/null +++ b/Lang/Ruby/Remove-lines-from-a-file @@ -0,0 +1 @@ +../../Task/Remove-lines-from-a-file/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Rename-a-file b/Lang/Ruby/Rename-a-file new file mode 120000 index 0000000000..3733c3b4a7 --- /dev/null +++ b/Lang/Ruby/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Repeat-a-string b/Lang/Ruby/Repeat-a-string new file mode 120000 index 0000000000..e264804f48 --- /dev/null +++ b/Lang/Ruby/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Respond-to-an-unknown-method-call b/Lang/Ruby/Respond-to-an-unknown-method-call new file mode 120000 index 0000000000..8bbb2bfb37 --- /dev/null +++ b/Lang/Ruby/Respond-to-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Respond-to-an-unknown-method-call/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Return-multiple-values b/Lang/Ruby/Return-multiple-values new file mode 120000 index 0000000000..8d168f5bf9 --- /dev/null +++ b/Lang/Ruby/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Reverse-a-string b/Lang/Ruby/Reverse-a-string new file mode 120000 index 0000000000..5e1fa0249f --- /dev/null +++ b/Lang/Ruby/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Rock-paper-scissors b/Lang/Ruby/Rock-paper-scissors new file mode 120000 index 0000000000..f9a73165b2 --- /dev/null +++ b/Lang/Ruby/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Roman-numerals-Decode b/Lang/Ruby/Roman-numerals-Decode new file mode 120000 index 0000000000..01c5d77497 --- /dev/null +++ b/Lang/Ruby/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Roman-numerals-Encode b/Lang/Ruby/Roman-numerals-Encode new file mode 120000 index 0000000000..45099bbd0c --- /dev/null +++ b/Lang/Ruby/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Roots-of-a-function b/Lang/Ruby/Roots-of-a-function new file mode 120000 index 0000000000..69f1228a55 --- /dev/null +++ b/Lang/Ruby/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Roots-of-a-quadratic-function b/Lang/Ruby/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..7dc502a99a --- /dev/null +++ b/Lang/Ruby/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Roots-of-unity b/Lang/Ruby/Roots-of-unity new file mode 120000 index 0000000000..989e543f14 --- /dev/null +++ b/Lang/Ruby/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Rosetta-Code-Count-examples b/Lang/Ruby/Rosetta-Code-Count-examples new file mode 120000 index 0000000000..642419c6b7 --- /dev/null +++ b/Lang/Ruby/Rosetta-Code-Count-examples @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Count-examples/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Rosetta-Code-Find-unimplemented-tasks b/Lang/Ruby/Rosetta-Code-Find-unimplemented-tasks new file mode 120000 index 0000000000..88d0272e54 --- /dev/null +++ b/Lang/Ruby/Rosetta-Code-Find-unimplemented-tasks @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Find-unimplemented-tasks/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Rosetta-Code-Fix-code-tags b/Lang/Ruby/Rosetta-Code-Fix-code-tags new file mode 120000 index 0000000000..6864bf1ad2 --- /dev/null +++ b/Lang/Ruby/Rosetta-Code-Fix-code-tags @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Fix-code-tags/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Rosetta-Code-Rank-languages-by-popularity b/Lang/Ruby/Rosetta-Code-Rank-languages-by-popularity new file mode 120000 index 0000000000..500910a8f3 --- /dev/null +++ b/Lang/Ruby/Rosetta-Code-Rank-languages-by-popularity @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-popularity/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Rot-13 b/Lang/Ruby/Rot-13 new file mode 120000 index 0000000000..05af0cc4bb --- /dev/null +++ b/Lang/Ruby/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Run-length-encoding b/Lang/Ruby/Run-length-encoding new file mode 120000 index 0000000000..334dadaef2 --- /dev/null +++ b/Lang/Ruby/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Runtime-evaluation b/Lang/Ruby/Runtime-evaluation new file mode 120000 index 0000000000..8ecbaf2f94 --- /dev/null +++ b/Lang/Ruby/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Runtime-evaluation-In-an-environment b/Lang/Ruby/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..d5cb8f8090 --- /dev/null +++ b/Lang/Ruby/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/Ruby \ No newline at end of file diff --git a/Lang/Ruby/S-Expressions b/Lang/Ruby/S-Expressions new file mode 120000 index 0000000000..33b666ee70 --- /dev/null +++ b/Lang/Ruby/S-Expressions @@ -0,0 +1 @@ +../../Task/S-Expressions/Ruby \ No newline at end of file diff --git a/Lang/Ruby/SEDOLs b/Lang/Ruby/SEDOLs new file mode 120000 index 0000000000..ee5a94f0ed --- /dev/null +++ b/Lang/Ruby/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Safe-addition b/Lang/Ruby/Safe-addition new file mode 120000 index 0000000000..bdafd5ecff --- /dev/null +++ b/Lang/Ruby/Safe-addition @@ -0,0 +1 @@ +../../Task/Safe-addition/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Secure-temporary-file b/Lang/Ruby/Secure-temporary-file new file mode 120000 index 0000000000..42a1d3bf71 --- /dev/null +++ b/Lang/Ruby/Secure-temporary-file @@ -0,0 +1 @@ +../../Task/Secure-temporary-file/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Self-describing-numbers b/Lang/Ruby/Self-describing-numbers new file mode 120000 index 0000000000..0ebb27a7c1 --- /dev/null +++ b/Lang/Ruby/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Self-referential-sequence b/Lang/Ruby/Self-referential-sequence new file mode 120000 index 0000000000..608991a35e --- /dev/null +++ b/Lang/Ruby/Self-referential-sequence @@ -0,0 +1 @@ +../../Task/Self-referential-sequence/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Semordnilap b/Lang/Ruby/Semordnilap new file mode 120000 index 0000000000..083b63ea39 --- /dev/null +++ b/Lang/Ruby/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Send-an-unknown-method-call b/Lang/Ruby/Send-an-unknown-method-call new file mode 120000 index 0000000000..74089052a1 --- /dev/null +++ b/Lang/Ruby/Send-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Send-an-unknown-method-call/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Send-email b/Lang/Ruby/Send-email new file mode 120000 index 0000000000..0b90b2f838 --- /dev/null +++ b/Lang/Ruby/Send-email @@ -0,0 +1 @@ +../../Task/Send-email/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Sequence-of-non-squares b/Lang/Ruby/Sequence-of-non-squares new file mode 120000 index 0000000000..256ae9f859 --- /dev/null +++ b/Lang/Ruby/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Ruby \ No newline at end of file diff --git a/Lang/Ruby/Set b/Lang/Ruby/Set new file mode 120000 index 0000000000..3aa65548da --- /dev/null +++ b/Lang/Ruby/Set @@ -0,0 +1 @@ +../../Task/Set/Ruby \ No newline at end of file diff --git a/Lang/Run-BASIC/Arbitrary-precision-integers--included- b/Lang/Run-BASIC/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..cdcb87d86b --- /dev/null +++ b/Lang/Run-BASIC/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Arbitrary-precision-integers-included b/Lang/Run-BASIC/Arbitrary-precision-integers-included deleted file mode 120000 index 0acac1ad91..0000000000 --- a/Lang/Run-BASIC/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Binary-digits b/Lang/Run-BASIC/Binary-digits new file mode 120000 index 0000000000..c066937a60 --- /dev/null +++ b/Lang/Run-BASIC/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Brownian-tree b/Lang/Run-BASIC/Brownian-tree new file mode 120000 index 0000000000..c4992449f4 --- /dev/null +++ b/Lang/Run-BASIC/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Catalan-numbers b/Lang/Run-BASIC/Catalan-numbers new file mode 120000 index 0000000000..96b708cc6f --- /dev/null +++ b/Lang/Run-BASIC/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Copy-a-string b/Lang/Run-BASIC/Copy-a-string new file mode 120000 index 0000000000..427b38300f --- /dev/null +++ b/Lang/Run-BASIC/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Dragon-curve b/Lang/Run-BASIC/Dragon-curve new file mode 120000 index 0000000000..f8a7f22417 --- /dev/null +++ b/Lang/Run-BASIC/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Environment-variables b/Lang/Run-BASIC/Environment-variables new file mode 120000 index 0000000000..053943ff6d --- /dev/null +++ b/Lang/Run-BASIC/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Non-decimal-radices-Convert b/Lang/Run-BASIC/Non-decimal-radices-Convert new file mode 120000 index 0000000000..50d44647b5 --- /dev/null +++ b/Lang/Run-BASIC/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Nth-root b/Lang/Run-BASIC/Nth-root new file mode 120000 index 0000000000..0ad5e1ed62 --- /dev/null +++ b/Lang/Run-BASIC/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Number-reversal-game b/Lang/Run-BASIC/Number-reversal-game new file mode 120000 index 0000000000..11275b85d5 --- /dev/null +++ b/Lang/Run-BASIC/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/One-of-n-lines-in-a-file b/Lang/Run-BASIC/One-of-n-lines-in-a-file new file mode 120000 index 0000000000..9a132b89a4 --- /dev/null +++ b/Lang/Run-BASIC/One-of-n-lines-in-a-file @@ -0,0 +1 @@ +../../Task/One-of-n-lines-in-a-file/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Palindrome-detection b/Lang/Run-BASIC/Palindrome-detection new file mode 120000 index 0000000000..6297536da7 --- /dev/null +++ b/Lang/Run-BASIC/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Pangram-checker b/Lang/Run-BASIC/Pangram-checker new file mode 120000 index 0000000000..83bc5e6229 --- /dev/null +++ b/Lang/Run-BASIC/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Parsing-RPN-calculator-algorithm b/Lang/Run-BASIC/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..45e61dd11c --- /dev/null +++ b/Lang/Run-BASIC/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Pascals-triangle b/Lang/Run-BASIC/Pascals-triangle new file mode 120000 index 0000000000..c9989278dc --- /dev/null +++ b/Lang/Run-BASIC/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Perfect-numbers b/Lang/Run-BASIC/Perfect-numbers new file mode 120000 index 0000000000..f269b39af5 --- /dev/null +++ b/Lang/Run-BASIC/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Permutations b/Lang/Run-BASIC/Permutations new file mode 120000 index 0000000000..642be9a30f --- /dev/null +++ b/Lang/Run-BASIC/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Pick-random-element b/Lang/Run-BASIC/Pick-random-element new file mode 120000 index 0000000000..c33292e7c7 --- /dev/null +++ b/Lang/Run-BASIC/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Pig-the-dice-game b/Lang/Run-BASIC/Pig-the-dice-game new file mode 120000 index 0000000000..a78c05d035 --- /dev/null +++ b/Lang/Run-BASIC/Pig-the-dice-game @@ -0,0 +1 @@ +../../Task/Pig-the-dice-game/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Playing-cards b/Lang/Run-BASIC/Playing-cards new file mode 120000 index 0000000000..4f3665324f --- /dev/null +++ b/Lang/Run-BASIC/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Price-fraction b/Lang/Run-BASIC/Price-fraction new file mode 120000 index 0000000000..91e00824af --- /dev/null +++ b/Lang/Run-BASIC/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Primality-by-trial-division b/Lang/Run-BASIC/Primality-by-trial-division new file mode 120000 index 0000000000..47c4199218 --- /dev/null +++ b/Lang/Run-BASIC/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Priority-queue b/Lang/Run-BASIC/Priority-queue new file mode 120000 index 0000000000..e3338c320b --- /dev/null +++ b/Lang/Run-BASIC/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Random-number-generator--included- b/Lang/Run-BASIC/Random-number-generator--included- new file mode 120000 index 0000000000..9595f15d1c --- /dev/null +++ b/Lang/Run-BASIC/Random-number-generator--included- @@ -0,0 +1 @@ +../../Task/Random-number-generator--included-/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Random-numbers b/Lang/Run-BASIC/Random-numbers new file mode 120000 index 0000000000..0e5271a65a --- /dev/null +++ b/Lang/Run-BASIC/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Range-expansion b/Lang/Run-BASIC/Range-expansion new file mode 120000 index 0000000000..888b189dcd --- /dev/null +++ b/Lang/Run-BASIC/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Rate-counter b/Lang/Run-BASIC/Rate-counter new file mode 120000 index 0000000000..308f69781d --- /dev/null +++ b/Lang/Run-BASIC/Rate-counter @@ -0,0 +1 @@ +../../Task/Rate-counter/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Read-a-file-line-by-line b/Lang/Run-BASIC/Read-a-file-line-by-line new file mode 120000 index 0000000000..deb8975475 --- /dev/null +++ b/Lang/Run-BASIC/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Read-a-specific-line-from-a-file b/Lang/Run-BASIC/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..5d07dd9f65 --- /dev/null +++ b/Lang/Run-BASIC/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Real-constants-and-functions b/Lang/Run-BASIC/Real-constants-and-functions new file mode 120000 index 0000000000..c55a96f55a --- /dev/null +++ b/Lang/Run-BASIC/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Regular-expressions b/Lang/Run-BASIC/Regular-expressions new file mode 120000 index 0000000000..5651728290 --- /dev/null +++ b/Lang/Run-BASIC/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Remove-lines-from-a-file b/Lang/Run-BASIC/Remove-lines-from-a-file new file mode 120000 index 0000000000..965f87e094 --- /dev/null +++ b/Lang/Run-BASIC/Remove-lines-from-a-file @@ -0,0 +1 @@ +../../Task/Remove-lines-from-a-file/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Rename-a-file b/Lang/Run-BASIC/Rename-a-file new file mode 120000 index 0000000000..7a0c720d5b --- /dev/null +++ b/Lang/Run-BASIC/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Repeat-a-string b/Lang/Run-BASIC/Repeat-a-string new file mode 120000 index 0000000000..01aedaae7a --- /dev/null +++ b/Lang/Run-BASIC/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Return-multiple-values b/Lang/Run-BASIC/Return-multiple-values new file mode 120000 index 0000000000..6a131dec89 --- /dev/null +++ b/Lang/Run-BASIC/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Reverse-a-string b/Lang/Run-BASIC/Reverse-a-string new file mode 120000 index 0000000000..4f6cc4f86d --- /dev/null +++ b/Lang/Run-BASIC/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Rock-paper-scissors b/Lang/Run-BASIC/Rock-paper-scissors new file mode 120000 index 0000000000..1b3db3b2b0 --- /dev/null +++ b/Lang/Run-BASIC/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Roman-numerals-Decode b/Lang/Run-BASIC/Roman-numerals-Decode new file mode 120000 index 0000000000..7db14bab99 --- /dev/null +++ b/Lang/Run-BASIC/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Roman-numerals-Encode b/Lang/Run-BASIC/Roman-numerals-Encode new file mode 120000 index 0000000000..78de940da7 --- /dev/null +++ b/Lang/Run-BASIC/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Roots-of-a-quadratic-function b/Lang/Run-BASIC/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..eeeb05c3e1 --- /dev/null +++ b/Lang/Run-BASIC/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Rosetta-Code-Count-examples b/Lang/Run-BASIC/Rosetta-Code-Count-examples new file mode 120000 index 0000000000..7d3f78c25d --- /dev/null +++ b/Lang/Run-BASIC/Rosetta-Code-Count-examples @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Count-examples/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Rosetta-Code-Find-unimplemented-tasks b/Lang/Run-BASIC/Rosetta-Code-Find-unimplemented-tasks new file mode 120000 index 0000000000..9a5cded71d --- /dev/null +++ b/Lang/Run-BASIC/Rosetta-Code-Find-unimplemented-tasks @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Find-unimplemented-tasks/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Rosetta-Code-Rank-languages-by-popularity b/Lang/Run-BASIC/Rosetta-Code-Rank-languages-by-popularity new file mode 120000 index 0000000000..f635ee846d --- /dev/null +++ b/Lang/Run-BASIC/Rosetta-Code-Rank-languages-by-popularity @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-popularity/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Rot-13 b/Lang/Run-BASIC/Rot-13 new file mode 120000 index 0000000000..e8787269c7 --- /dev/null +++ b/Lang/Run-BASIC/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Run-length-encoding b/Lang/Run-BASIC/Run-length-encoding new file mode 120000 index 0000000000..08b72e2eb4 --- /dev/null +++ b/Lang/Run-BASIC/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Run-BASIC \ No newline at end of file diff --git a/Lang/Run-BASIC/Self-describing-numbers b/Lang/Run-BASIC/Self-describing-numbers new file mode 120000 index 0000000000..ed69449d0b --- /dev/null +++ b/Lang/Run-BASIC/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/Run-BASIC \ No newline at end of file diff --git a/Lang/Rust/Program-name b/Lang/Rust/Program-name new file mode 120000 index 0000000000..a3da006ccd --- /dev/null +++ b/Lang/Rust/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Rust \ No newline at end of file diff --git a/Lang/SAS/N-queens-problem b/Lang/SAS/N-queens-problem new file mode 120000 index 0000000000..e4afb32180 --- /dev/null +++ b/Lang/SAS/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/SAS \ No newline at end of file diff --git a/Lang/SAS/Permutations b/Lang/SAS/Permutations new file mode 120000 index 0000000000..a0fcb45b66 --- /dev/null +++ b/Lang/SAS/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/SAS \ No newline at end of file diff --git a/Lang/SAS/Pointers-and-references b/Lang/SAS/Pointers-and-references new file mode 120000 index 0000000000..cbe93f961e --- /dev/null +++ b/Lang/SAS/Pointers-and-references @@ -0,0 +1 @@ +../../Task/Pointers-and-references/SAS \ No newline at end of file diff --git a/Lang/SAS/Primality-by-trial-division b/Lang/SAS/Primality-by-trial-division new file mode 120000 index 0000000000..09c6d7b629 --- /dev/null +++ b/Lang/SAS/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/SAS \ No newline at end of file diff --git a/Lang/SAS/QR-decomposition b/Lang/SAS/QR-decomposition new file mode 120000 index 0000000000..a6c0a2b24a --- /dev/null +++ b/Lang/SAS/QR-decomposition @@ -0,0 +1 @@ +../../Task/QR-decomposition/SAS \ No newline at end of file diff --git a/Lang/SAS/Reverse-a-string b/Lang/SAS/Reverse-a-string new file mode 120000 index 0000000000..5ce0ddac28 --- /dev/null +++ b/Lang/SAS/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/SAS \ No newline at end of file diff --git a/Lang/SAS/Send-email b/Lang/SAS/Send-email new file mode 120000 index 0000000000..0e26f867cd --- /dev/null +++ b/Lang/SAS/Send-email @@ -0,0 +1 @@ +../../Task/Send-email/SAS \ No newline at end of file diff --git a/Lang/SETL/Remove-duplicate-elements b/Lang/SETL/Remove-duplicate-elements new file mode 120000 index 0000000000..09786a04a1 --- /dev/null +++ b/Lang/SETL/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/SETL \ No newline at end of file diff --git a/Lang/SIMPOL/Arbitrary-precision-integers--included- b/Lang/SIMPOL/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..6962e440bf --- /dev/null +++ b/Lang/SIMPOL/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/SIMPOL \ No newline at end of file diff --git a/Lang/SIMPOL/Arbitrary-precision-integers-included b/Lang/SIMPOL/Arbitrary-precision-integers-included deleted file mode 120000 index 975a0231cc..0000000000 --- a/Lang/SIMPOL/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/SIMPOL \ No newline at end of file diff --git a/Lang/SIMPOL/Polymorphism b/Lang/SIMPOL/Polymorphism new file mode 120000 index 0000000000..0e29275df8 --- /dev/null +++ b/Lang/SIMPOL/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/SIMPOL \ No newline at end of file diff --git a/Lang/SNOBOL4/Copy-a-string b/Lang/SNOBOL4/Copy-a-string new file mode 120000 index 0000000000..45e90660ab --- /dev/null +++ b/Lang/SNOBOL4/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/SNOBOL4 \ No newline at end of file diff --git a/Lang/SNOBOL4/Environment-variables b/Lang/SNOBOL4/Environment-variables new file mode 120000 index 0000000000..932a92266c --- /dev/null +++ b/Lang/SNOBOL4/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/SNOBOL4 \ No newline at end of file diff --git a/Lang/SNOBOL4/N-queens-problem b/Lang/SNOBOL4/N-queens-problem new file mode 120000 index 0000000000..1a9cb9bd77 --- /dev/null +++ b/Lang/SNOBOL4/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/SNOBOL4 \ No newline at end of file diff --git a/Lang/SNOBOL4/Palindrome-detection b/Lang/SNOBOL4/Palindrome-detection new file mode 120000 index 0000000000..6786511817 --- /dev/null +++ b/Lang/SNOBOL4/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/SNOBOL4 \ No newline at end of file diff --git a/Lang/SNOBOL4/Pangram-checker b/Lang/SNOBOL4/Pangram-checker new file mode 120000 index 0000000000..558164f8ab --- /dev/null +++ b/Lang/SNOBOL4/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/SNOBOL4 \ No newline at end of file diff --git a/Lang/SNOBOL4/Primality-by-trial-division b/Lang/SNOBOL4/Primality-by-trial-division new file mode 120000 index 0000000000..9f0eafd8df --- /dev/null +++ b/Lang/SNOBOL4/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/SNOBOL4 \ No newline at end of file diff --git a/Lang/SNOBOL4/Program-termination b/Lang/SNOBOL4/Program-termination new file mode 120000 index 0000000000..83cc63d47c --- /dev/null +++ b/Lang/SNOBOL4/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/SNOBOL4 \ No newline at end of file diff --git a/Lang/SNOBOL4/Range-expansion b/Lang/SNOBOL4/Range-expansion new file mode 120000 index 0000000000..fa4ceb61ec --- /dev/null +++ b/Lang/SNOBOL4/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/SNOBOL4 \ No newline at end of file diff --git a/Lang/SNOBOL4/Range-extraction b/Lang/SNOBOL4/Range-extraction new file mode 120000 index 0000000000..4a748e8bf0 --- /dev/null +++ b/Lang/SNOBOL4/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/SNOBOL4 \ No newline at end of file diff --git a/Lang/SNOBOL4/Read-a-file-line-by-line b/Lang/SNOBOL4/Read-a-file-line-by-line new file mode 120000 index 0000000000..a3498e11ca --- /dev/null +++ b/Lang/SNOBOL4/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/SNOBOL4 \ No newline at end of file diff --git a/Lang/SNOBOL4/Read-entire-file b/Lang/SNOBOL4/Read-entire-file new file mode 120000 index 0000000000..62da90e8d3 --- /dev/null +++ b/Lang/SNOBOL4/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/SNOBOL4 \ No newline at end of file diff --git a/Lang/SNOBOL4/Regular-expressions b/Lang/SNOBOL4/Regular-expressions new file mode 120000 index 0000000000..edff15d73a --- /dev/null +++ b/Lang/SNOBOL4/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/SNOBOL4 \ No newline at end of file diff --git a/Lang/SNOBOL4/Repeat-a-string b/Lang/SNOBOL4/Repeat-a-string new file mode 120000 index 0000000000..c86b5abf64 --- /dev/null +++ b/Lang/SNOBOL4/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/SNOBOL4 \ No newline at end of file diff --git a/Lang/SNOBOL4/Reverse-a-string b/Lang/SNOBOL4/Reverse-a-string new file mode 120000 index 0000000000..00d7977b55 --- /dev/null +++ b/Lang/SNOBOL4/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/SNOBOL4 \ No newline at end of file diff --git a/Lang/SNOBOL4/Roman-numerals-Decode b/Lang/SNOBOL4/Roman-numerals-Decode new file mode 120000 index 0000000000..73596c7e5a --- /dev/null +++ b/Lang/SNOBOL4/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/SNOBOL4 \ No newline at end of file diff --git a/Lang/SNOBOL4/Roman-numerals-Encode b/Lang/SNOBOL4/Roman-numerals-Encode new file mode 120000 index 0000000000..0cea452d61 --- /dev/null +++ b/Lang/SNOBOL4/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/SNOBOL4 \ No newline at end of file diff --git a/Lang/SNOBOL4/Rot-13 b/Lang/SNOBOL4/Rot-13 new file mode 120000 index 0000000000..e978be7a5c --- /dev/null +++ b/Lang/SNOBOL4/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/SNOBOL4 \ No newline at end of file diff --git a/Lang/SNOBOL4/Run-length-encoding b/Lang/SNOBOL4/Run-length-encoding new file mode 120000 index 0000000000..997ee82adf --- /dev/null +++ b/Lang/SNOBOL4/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/SNOBOL4 \ No newline at end of file diff --git a/Lang/SNOBOL4/Runtime-evaluation b/Lang/SNOBOL4/Runtime-evaluation new file mode 120000 index 0000000000..12fb391536 --- /dev/null +++ b/Lang/SNOBOL4/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/SNOBOL4 \ No newline at end of file diff --git a/Lang/SNOBOL4/Runtime-evaluation-In-an-environment b/Lang/SNOBOL4/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..4ad915d2ed --- /dev/null +++ b/Lang/SNOBOL4/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/SNOBOL4 \ No newline at end of file diff --git a/Lang/SQL/Repeat-a-string b/Lang/SQL/Repeat-a-string new file mode 120000 index 0000000000..b50a2484be --- /dev/null +++ b/Lang/SQL/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/SQL \ No newline at end of file diff --git a/Lang/SQL/Roman-numerals-Encode b/Lang/SQL/Roman-numerals-Encode new file mode 120000 index 0000000000..3db56271bc --- /dev/null +++ b/Lang/SQL/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/SQL \ No newline at end of file diff --git a/Lang/Sage/Reduced-row-echelon-form b/Lang/Sage/Reduced-row-echelon-form new file mode 120000 index 0000000000..5301829aad --- /dev/null +++ b/Lang/Sage/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/Sage \ No newline at end of file diff --git a/Lang/Sather/Arbitrary-precision-integers--included- b/Lang/Sather/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..9bc40a1621 --- /dev/null +++ b/Lang/Sather/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Sather \ No newline at end of file diff --git a/Lang/Sather/Arbitrary-precision-integers-included b/Lang/Sather/Arbitrary-precision-integers-included deleted file mode 120000 index 7283ce66c0..0000000000 --- a/Lang/Sather/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Sather \ No newline at end of file diff --git a/Lang/Sather/Copy-a-string b/Lang/Sather/Copy-a-string new file mode 120000 index 0000000000..f0fa509ac0 --- /dev/null +++ b/Lang/Sather/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Sather \ No newline at end of file diff --git a/Lang/Sather/Nth-root b/Lang/Sather/Nth-root new file mode 120000 index 0000000000..6afde21d4e --- /dev/null +++ b/Lang/Sather/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Sather \ No newline at end of file diff --git a/Lang/Sather/Random-numbers b/Lang/Sather/Random-numbers new file mode 120000 index 0000000000..512f162e64 --- /dev/null +++ b/Lang/Sather/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Sather \ No newline at end of file diff --git a/Lang/Sather/Regular-expressions b/Lang/Sather/Regular-expressions new file mode 120000 index 0000000000..2f59dd633d --- /dev/null +++ b/Lang/Sather/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Sather \ No newline at end of file diff --git a/Lang/Sather/Reverse-a-string b/Lang/Sather/Reverse-a-string new file mode 120000 index 0000000000..e49d752e9c --- /dev/null +++ b/Lang/Sather/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Sather \ No newline at end of file diff --git a/Lang/Scala/Arbitrary-precision-integers--included- b/Lang/Scala/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..66e0413578 --- /dev/null +++ b/Lang/Scala/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Scala \ No newline at end of file diff --git a/Lang/Scala/Arbitrary-precision-integers-included b/Lang/Scala/Arbitrary-precision-integers-included deleted file mode 120000 index 98c3992076..0000000000 --- a/Lang/Scala/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Scala \ No newline at end of file diff --git a/Lang/Scala/Binary-digits b/Lang/Scala/Binary-digits new file mode 120000 index 0000000000..e49bab0eab --- /dev/null +++ b/Lang/Scala/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Scala \ No newline at end of file diff --git a/Lang/Scala/Catalan-numbers b/Lang/Scala/Catalan-numbers new file mode 120000 index 0000000000..cf15c3f83f --- /dev/null +++ b/Lang/Scala/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Scala \ No newline at end of file diff --git a/Lang/Scala/Copy-a-string b/Lang/Scala/Copy-a-string new file mode 120000 index 0000000000..0a29f965c0 --- /dev/null +++ b/Lang/Scala/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Scala \ No newline at end of file diff --git a/Lang/Scala/Execute-a-Markov-algorithm b/Lang/Scala/Execute-a-Markov-algorithm new file mode 120000 index 0000000000..e83c74cd53 --- /dev/null +++ b/Lang/Scala/Execute-a-Markov-algorithm @@ -0,0 +1 @@ +../../Task/Execute-a-Markov-algorithm/Scala \ No newline at end of file diff --git a/Lang/Scala/N-queens-problem b/Lang/Scala/N-queens-problem new file mode 120000 index 0000000000..aad4fc76bd --- /dev/null +++ b/Lang/Scala/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Scala \ No newline at end of file diff --git a/Lang/Scala/Named-parameters b/Lang/Scala/Named-parameters new file mode 120000 index 0000000000..66e443a17d --- /dev/null +++ b/Lang/Scala/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/Scala \ No newline at end of file diff --git a/Lang/Scala/Nth-root b/Lang/Scala/Nth-root new file mode 120000 index 0000000000..ae015d87a3 --- /dev/null +++ b/Lang/Scala/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Scala \ No newline at end of file diff --git a/Lang/Scala/Null-object b/Lang/Scala/Null-object new file mode 120000 index 0000000000..2b4c68e331 --- /dev/null +++ b/Lang/Scala/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Scala \ No newline at end of file diff --git a/Lang/Scala/Numerical-integration b/Lang/Scala/Numerical-integration new file mode 120000 index 0000000000..3e4e97b128 --- /dev/null +++ b/Lang/Scala/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/Scala \ No newline at end of file diff --git a/Lang/Scala/One-dimensional-cellular-automata b/Lang/Scala/One-dimensional-cellular-automata new file mode 120000 index 0000000000..7887684cc8 --- /dev/null +++ b/Lang/Scala/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Scala \ No newline at end of file diff --git a/Lang/Scala/Optional-parameters b/Lang/Scala/Optional-parameters new file mode 120000 index 0000000000..b9337fa496 --- /dev/null +++ b/Lang/Scala/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/Scala \ No newline at end of file diff --git a/Lang/Scala/Palindrome-detection b/Lang/Scala/Palindrome-detection new file mode 120000 index 0000000000..1f0cdc3e97 --- /dev/null +++ b/Lang/Scala/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Scala \ No newline at end of file diff --git a/Lang/Scala/Pangram-checker b/Lang/Scala/Pangram-checker new file mode 120000 index 0000000000..f340df9edc --- /dev/null +++ b/Lang/Scala/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Scala \ No newline at end of file diff --git a/Lang/Scala/Parametric-polymorphism b/Lang/Scala/Parametric-polymorphism new file mode 120000 index 0000000000..bd63b07e8c --- /dev/null +++ b/Lang/Scala/Parametric-polymorphism @@ -0,0 +1 @@ +../../Task/Parametric-polymorphism/Scala \ No newline at end of file diff --git a/Lang/Scala/Partial-function-application b/Lang/Scala/Partial-function-application new file mode 120000 index 0000000000..57545b9d69 --- /dev/null +++ b/Lang/Scala/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/Scala \ No newline at end of file diff --git a/Lang/Scala/Pascals-triangle b/Lang/Scala/Pascals-triangle new file mode 120000 index 0000000000..c5b3dc9c59 --- /dev/null +++ b/Lang/Scala/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Scala \ No newline at end of file diff --git a/Lang/Scala/Pattern-matching b/Lang/Scala/Pattern-matching new file mode 120000 index 0000000000..50f07f5986 --- /dev/null +++ b/Lang/Scala/Pattern-matching @@ -0,0 +1 @@ +../../Task/Pattern-matching/Scala \ No newline at end of file diff --git a/Lang/Scala/Perfect-numbers b/Lang/Scala/Perfect-numbers new file mode 120000 index 0000000000..37efea02c8 --- /dev/null +++ b/Lang/Scala/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Scala \ No newline at end of file diff --git a/Lang/Scala/Permutations b/Lang/Scala/Permutations new file mode 120000 index 0000000000..b9e02c809d --- /dev/null +++ b/Lang/Scala/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Scala \ No newline at end of file diff --git a/Lang/Scala/Plot-coordinate-pairs b/Lang/Scala/Plot-coordinate-pairs new file mode 120000 index 0000000000..d0ed6468db --- /dev/null +++ b/Lang/Scala/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/Scala \ No newline at end of file diff --git a/Lang/Scala/Power-set b/Lang/Scala/Power-set new file mode 120000 index 0000000000..d1ed9bd2e2 --- /dev/null +++ b/Lang/Scala/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Scala \ No newline at end of file diff --git a/Lang/Scala/Price-fraction b/Lang/Scala/Price-fraction new file mode 120000 index 0000000000..f954db7613 --- /dev/null +++ b/Lang/Scala/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Scala \ No newline at end of file diff --git a/Lang/Scala/Primality-by-trial-division b/Lang/Scala/Primality-by-trial-division new file mode 120000 index 0000000000..41c3a5db84 --- /dev/null +++ b/Lang/Scala/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Scala \ No newline at end of file diff --git a/Lang/Scala/Prime-decomposition b/Lang/Scala/Prime-decomposition new file mode 120000 index 0000000000..ebc63e3714 --- /dev/null +++ b/Lang/Scala/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Scala \ No newline at end of file diff --git a/Lang/Scala/Priority-queue b/Lang/Scala/Priority-queue new file mode 120000 index 0000000000..0f0b258db8 --- /dev/null +++ b/Lang/Scala/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/Scala \ No newline at end of file diff --git a/Lang/Scala/Problem-of-Apollonius b/Lang/Scala/Problem-of-Apollonius new file mode 120000 index 0000000000..149d39a86d --- /dev/null +++ b/Lang/Scala/Problem-of-Apollonius @@ -0,0 +1 @@ +../../Task/Problem-of-Apollonius/Scala \ No newline at end of file diff --git a/Lang/Scala/Program-name b/Lang/Scala/Program-name new file mode 120000 index 0000000000..d4b16f6668 --- /dev/null +++ b/Lang/Scala/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Scala \ No newline at end of file diff --git a/Lang/Scala/Quaternion-type b/Lang/Scala/Quaternion-type new file mode 120000 index 0000000000..15f3eda4c9 --- /dev/null +++ b/Lang/Scala/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/Scala \ No newline at end of file diff --git a/Lang/Scala/Queue-Definition b/Lang/Scala/Queue-Definition new file mode 120000 index 0000000000..ecc1009753 --- /dev/null +++ b/Lang/Scala/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/Scala \ No newline at end of file diff --git a/Lang/Scala/Queue-Usage b/Lang/Scala/Queue-Usage new file mode 120000 index 0000000000..e56221a71c --- /dev/null +++ b/Lang/Scala/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/Scala \ No newline at end of file diff --git a/Lang/Scala/Random-numbers b/Lang/Scala/Random-numbers new file mode 120000 index 0000000000..d040f5810d --- /dev/null +++ b/Lang/Scala/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Scala \ No newline at end of file diff --git a/Lang/Scala/Range-expansion b/Lang/Scala/Range-expansion new file mode 120000 index 0000000000..0ef7cea0b8 --- /dev/null +++ b/Lang/Scala/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/Scala \ No newline at end of file diff --git a/Lang/Scala/Range-extraction b/Lang/Scala/Range-extraction new file mode 120000 index 0000000000..32fada2563 --- /dev/null +++ b/Lang/Scala/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/Scala \ No newline at end of file diff --git a/Lang/Scala/Rate-counter b/Lang/Scala/Rate-counter new file mode 120000 index 0000000000..6627a0f8f4 --- /dev/null +++ b/Lang/Scala/Rate-counter @@ -0,0 +1 @@ +../../Task/Rate-counter/Scala \ No newline at end of file diff --git a/Lang/Scala/Read-a-file-line-by-line b/Lang/Scala/Read-a-file-line-by-line new file mode 120000 index 0000000000..8dc8f13e19 --- /dev/null +++ b/Lang/Scala/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Scala \ No newline at end of file diff --git a/Lang/Scala/Read-a-specific-line-from-a-file b/Lang/Scala/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..101d84db7c --- /dev/null +++ b/Lang/Scala/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/Scala \ No newline at end of file diff --git a/Lang/Scala/Regular-expressions b/Lang/Scala/Regular-expressions new file mode 120000 index 0000000000..9c12a51c54 --- /dev/null +++ b/Lang/Scala/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Scala \ No newline at end of file diff --git a/Lang/Scala/Remove-duplicate-elements b/Lang/Scala/Remove-duplicate-elements new file mode 120000 index 0000000000..4a9834087a --- /dev/null +++ b/Lang/Scala/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Scala \ No newline at end of file diff --git a/Lang/Scala/Rename-a-file b/Lang/Scala/Rename-a-file new file mode 120000 index 0000000000..111e06e116 --- /dev/null +++ b/Lang/Scala/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Scala \ No newline at end of file diff --git a/Lang/Scala/Repeat-a-string b/Lang/Scala/Repeat-a-string new file mode 120000 index 0000000000..4032eb0292 --- /dev/null +++ b/Lang/Scala/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Scala \ No newline at end of file diff --git a/Lang/Scala/Respond-to-an-unknown-method-call b/Lang/Scala/Respond-to-an-unknown-method-call new file mode 120000 index 0000000000..d1e9cbfba2 --- /dev/null +++ b/Lang/Scala/Respond-to-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Respond-to-an-unknown-method-call/Scala \ No newline at end of file diff --git a/Lang/Scala/Return-multiple-values b/Lang/Scala/Return-multiple-values new file mode 120000 index 0000000000..bf18e1e87e --- /dev/null +++ b/Lang/Scala/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Scala \ No newline at end of file diff --git a/Lang/Scala/Reverse-a-string b/Lang/Scala/Reverse-a-string new file mode 120000 index 0000000000..98c4392ac6 --- /dev/null +++ b/Lang/Scala/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Scala \ No newline at end of file diff --git a/Lang/Scala/Roman-numerals-Decode b/Lang/Scala/Roman-numerals-Decode new file mode 120000 index 0000000000..ae1ab0c4c2 --- /dev/null +++ b/Lang/Scala/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/Scala \ No newline at end of file diff --git a/Lang/Scala/Roman-numerals-Encode b/Lang/Scala/Roman-numerals-Encode new file mode 120000 index 0000000000..9d9111add2 --- /dev/null +++ b/Lang/Scala/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Scala \ No newline at end of file diff --git a/Lang/Scala/Roots-of-a-quadratic-function b/Lang/Scala/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..2f03f255fc --- /dev/null +++ b/Lang/Scala/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/Scala \ No newline at end of file diff --git a/Lang/Scala/Roots-of-unity b/Lang/Scala/Roots-of-unity new file mode 120000 index 0000000000..00796e1b01 --- /dev/null +++ b/Lang/Scala/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/Scala \ No newline at end of file diff --git a/Lang/Scala/Rosetta-Code-Count-examples b/Lang/Scala/Rosetta-Code-Count-examples new file mode 120000 index 0000000000..0afd632de1 --- /dev/null +++ b/Lang/Scala/Rosetta-Code-Count-examples @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Count-examples/Scala \ No newline at end of file diff --git a/Lang/Scala/Rosetta-Code-Rank-languages-by-popularity b/Lang/Scala/Rosetta-Code-Rank-languages-by-popularity new file mode 120000 index 0000000000..c2db137221 --- /dev/null +++ b/Lang/Scala/Rosetta-Code-Rank-languages-by-popularity @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-popularity/Scala \ No newline at end of file diff --git a/Lang/Scala/Rot-13 b/Lang/Scala/Rot-13 new file mode 120000 index 0000000000..e0226a11bd --- /dev/null +++ b/Lang/Scala/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Scala \ No newline at end of file diff --git a/Lang/Scala/Run-length-encoding b/Lang/Scala/Run-length-encoding new file mode 120000 index 0000000000..539516e368 --- /dev/null +++ b/Lang/Scala/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Scala \ No newline at end of file diff --git a/Lang/Scala/SEDOLs b/Lang/Scala/SEDOLs new file mode 120000 index 0000000000..3e768667dc --- /dev/null +++ b/Lang/Scala/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/Scala \ No newline at end of file diff --git a/Lang/Scala/Secure-temporary-file b/Lang/Scala/Secure-temporary-file new file mode 120000 index 0000000000..153df5b1ba --- /dev/null +++ b/Lang/Scala/Secure-temporary-file @@ -0,0 +1 @@ +../../Task/Secure-temporary-file/Scala \ No newline at end of file diff --git a/Lang/Scala/Sequence-of-non-squares b/Lang/Scala/Sequence-of-non-squares new file mode 120000 index 0000000000..54c7435578 --- /dev/null +++ b/Lang/Scala/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Scala \ No newline at end of file diff --git a/Lang/Scala/Set b/Lang/Scala/Set new file mode 120000 index 0000000000..a08fb8a18a --- /dev/null +++ b/Lang/Scala/Set @@ -0,0 +1 @@ +../../Task/Set/Scala \ No newline at end of file diff --git a/Lang/Scheme/Arbitrary-precision-integers--included- b/Lang/Scheme/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..7beb0c5e2d --- /dev/null +++ b/Lang/Scheme/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Arbitrary-precision-integers-included b/Lang/Scheme/Arbitrary-precision-integers-included deleted file mode 120000 index 2421538c94..0000000000 --- a/Lang/Scheme/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Binary-digits b/Lang/Scheme/Binary-digits new file mode 120000 index 0000000000..911a72ac26 --- /dev/null +++ b/Lang/Scheme/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Brownian-tree b/Lang/Scheme/Brownian-tree new file mode 120000 index 0000000000..00f69cf01c --- /dev/null +++ b/Lang/Scheme/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Catalan-numbers b/Lang/Scheme/Catalan-numbers new file mode 120000 index 0000000000..09fe90f279 --- /dev/null +++ b/Lang/Scheme/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Copy-a-string b/Lang/Scheme/Copy-a-string new file mode 120000 index 0000000000..e64a7dec06 --- /dev/null +++ b/Lang/Scheme/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Execute-a-Markov-algorithm b/Lang/Scheme/Execute-a-Markov-algorithm new file mode 120000 index 0000000000..38de448074 --- /dev/null +++ b/Lang/Scheme/Execute-a-Markov-algorithm @@ -0,0 +1 @@ +../../Task/Execute-a-Markov-algorithm/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Guess-the-number-With-feedback--player- b/Lang/Scheme/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..da77932878 --- /dev/null +++ b/Lang/Scheme/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Guess-the-number-With-feedback-player b/Lang/Scheme/Guess-the-number-With-feedback-player deleted file mode 120000 index 5a88b0302d..0000000000 --- a/Lang/Scheme/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Named-parameters b/Lang/Scheme/Named-parameters new file mode 120000 index 0000000000..fde2b07a25 --- /dev/null +++ b/Lang/Scheme/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Non-continuous-subsequences b/Lang/Scheme/Non-continuous-subsequences new file mode 120000 index 0000000000..b928feb956 --- /dev/null +++ b/Lang/Scheme/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Non-decimal-radices-Input b/Lang/Scheme/Non-decimal-radices-Input new file mode 120000 index 0000000000..784c36d8b9 --- /dev/null +++ b/Lang/Scheme/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Non-decimal-radices-Output b/Lang/Scheme/Non-decimal-radices-Output new file mode 120000 index 0000000000..5274a131d7 --- /dev/null +++ b/Lang/Scheme/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Nth-root b/Lang/Scheme/Nth-root new file mode 120000 index 0000000000..ddb4c9c66e --- /dev/null +++ b/Lang/Scheme/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Null-object b/Lang/Scheme/Null-object new file mode 120000 index 0000000000..28dbfcbc2d --- /dev/null +++ b/Lang/Scheme/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Numerical-integration b/Lang/Scheme/Numerical-integration new file mode 120000 index 0000000000..8c62a63b4c --- /dev/null +++ b/Lang/Scheme/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/Scheme \ No newline at end of file diff --git a/Lang/Scheme/One-dimensional-cellular-automata b/Lang/Scheme/One-dimensional-cellular-automata new file mode 120000 index 0000000000..410428a3a5 --- /dev/null +++ b/Lang/Scheme/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Order-two-numerical-lists b/Lang/Scheme/Order-two-numerical-lists new file mode 120000 index 0000000000..ed12ff5a38 --- /dev/null +++ b/Lang/Scheme/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Palindrome-detection b/Lang/Scheme/Palindrome-detection new file mode 120000 index 0000000000..309a5d928d --- /dev/null +++ b/Lang/Scheme/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Pascals-triangle b/Lang/Scheme/Pascals-triangle new file mode 120000 index 0000000000..700dc1f8f3 --- /dev/null +++ b/Lang/Scheme/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Perfect-numbers b/Lang/Scheme/Perfect-numbers new file mode 120000 index 0000000000..9a6830efb5 --- /dev/null +++ b/Lang/Scheme/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Permutations b/Lang/Scheme/Permutations new file mode 120000 index 0000000000..ee49e1a091 --- /dev/null +++ b/Lang/Scheme/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Playing-cards b/Lang/Scheme/Playing-cards new file mode 120000 index 0000000000..dc543f16e7 --- /dev/null +++ b/Lang/Scheme/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Power-set b/Lang/Scheme/Power-set new file mode 120000 index 0000000000..ea8f06088f --- /dev/null +++ b/Lang/Scheme/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Primality-by-trial-division b/Lang/Scheme/Primality-by-trial-division new file mode 120000 index 0000000000..24b62b5d18 --- /dev/null +++ b/Lang/Scheme/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Prime-decomposition b/Lang/Scheme/Prime-decomposition new file mode 120000 index 0000000000..8639b125e0 --- /dev/null +++ b/Lang/Scheme/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Program-name b/Lang/Scheme/Program-name new file mode 120000 index 0000000000..fa1c84be0b --- /dev/null +++ b/Lang/Scheme/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Program-termination b/Lang/Scheme/Program-termination new file mode 120000 index 0000000000..e2192ab2d1 --- /dev/null +++ b/Lang/Scheme/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Queue-Definition b/Lang/Scheme/Queue-Definition new file mode 120000 index 0000000000..9142cb71bb --- /dev/null +++ b/Lang/Scheme/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Random-numbers b/Lang/Scheme/Random-numbers new file mode 120000 index 0000000000..0e54aaf893 --- /dev/null +++ b/Lang/Scheme/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Range-expansion b/Lang/Scheme/Range-expansion new file mode 120000 index 0000000000..a08783aa54 --- /dev/null +++ b/Lang/Scheme/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Range-extraction b/Lang/Scheme/Range-extraction new file mode 120000 index 0000000000..0240f2c6ab --- /dev/null +++ b/Lang/Scheme/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Read-a-file-line-by-line b/Lang/Scheme/Read-a-file-line-by-line new file mode 120000 index 0000000000..057caa49fa --- /dev/null +++ b/Lang/Scheme/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Real-constants-and-functions b/Lang/Scheme/Real-constants-and-functions new file mode 120000 index 0000000000..05e42f44b6 --- /dev/null +++ b/Lang/Scheme/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Reduced-row-echelon-form b/Lang/Scheme/Reduced-row-echelon-form new file mode 120000 index 0000000000..d2141faf07 --- /dev/null +++ b/Lang/Scheme/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Remove-duplicate-elements b/Lang/Scheme/Remove-duplicate-elements new file mode 120000 index 0000000000..0fd607a08c --- /dev/null +++ b/Lang/Scheme/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Rename-a-file b/Lang/Scheme/Rename-a-file new file mode 120000 index 0000000000..f76d394abd --- /dev/null +++ b/Lang/Scheme/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Repeat-a-string b/Lang/Scheme/Repeat-a-string new file mode 120000 index 0000000000..fda41fe73e --- /dev/null +++ b/Lang/Scheme/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Return-multiple-values b/Lang/Scheme/Return-multiple-values new file mode 120000 index 0000000000..3856e7cb31 --- /dev/null +++ b/Lang/Scheme/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Reverse-a-string b/Lang/Scheme/Reverse-a-string new file mode 120000 index 0000000000..cc6d4bdcf3 --- /dev/null +++ b/Lang/Scheme/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Roman-numerals-Encode b/Lang/Scheme/Roman-numerals-Encode new file mode 120000 index 0000000000..0725136a76 --- /dev/null +++ b/Lang/Scheme/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Roots-of-a-quadratic-function b/Lang/Scheme/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..2cd36ac000 --- /dev/null +++ b/Lang/Scheme/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Roots-of-unity b/Lang/Scheme/Roots-of-unity new file mode 120000 index 0000000000..b8d44c1108 --- /dev/null +++ b/Lang/Scheme/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Rot-13 b/Lang/Scheme/Rot-13 new file mode 120000 index 0000000000..1fe62d0e10 --- /dev/null +++ b/Lang/Scheme/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Run-length-encoding b/Lang/Scheme/Run-length-encoding new file mode 120000 index 0000000000..066263dfa5 --- /dev/null +++ b/Lang/Scheme/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Runtime-evaluation b/Lang/Scheme/Runtime-evaluation new file mode 120000 index 0000000000..3897ba153e --- /dev/null +++ b/Lang/Scheme/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Runtime-evaluation-In-an-environment b/Lang/Scheme/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..f193b575fe --- /dev/null +++ b/Lang/Scheme/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/Scheme \ No newline at end of file diff --git a/Lang/Scheme/S-Expressions b/Lang/Scheme/S-Expressions new file mode 120000 index 0000000000..fa69d0d40a --- /dev/null +++ b/Lang/Scheme/S-Expressions @@ -0,0 +1 @@ +../../Task/S-Expressions/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Sequence-of-non-squares b/Lang/Scheme/Sequence-of-non-squares new file mode 120000 index 0000000000..089263cea8 --- /dev/null +++ b/Lang/Scheme/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Scheme \ No newline at end of file diff --git a/Lang/Scheme/Set b/Lang/Scheme/Set new file mode 120000 index 0000000000..a9d3a8d9de --- /dev/null +++ b/Lang/Scheme/Set @@ -0,0 +1 @@ +../../Task/Set/Scheme \ No newline at end of file diff --git a/Lang/Sed/Read-a-file-line-by-line b/Lang/Sed/Read-a-file-line-by-line new file mode 120000 index 0000000000..5b1d183009 --- /dev/null +++ b/Lang/Sed/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Sed \ No newline at end of file diff --git a/Lang/Sed/Reverse-a-string b/Lang/Sed/Reverse-a-string new file mode 120000 index 0000000000..a6d4beafb3 --- /dev/null +++ b/Lang/Sed/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Sed \ No newline at end of file diff --git a/Lang/Seed7/Arbitrary-precision-integers--included- b/Lang/Seed7/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..7f5a5d99cd --- /dev/null +++ b/Lang/Seed7/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Arbitrary-precision-integers-included b/Lang/Seed7/Arbitrary-precision-integers-included deleted file mode 120000 index 76f16a7fd3..0000000000 --- a/Lang/Seed7/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Binary-digits b/Lang/Seed7/Binary-digits new file mode 120000 index 0000000000..c3ab614abc --- /dev/null +++ b/Lang/Seed7/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Brownian-tree b/Lang/Seed7/Brownian-tree new file mode 120000 index 0000000000..3acb7d24a9 --- /dev/null +++ b/Lang/Seed7/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Copy-a-string b/Lang/Seed7/Copy-a-string new file mode 120000 index 0000000000..4c50996d2a --- /dev/null +++ b/Lang/Seed7/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Dragon-curve b/Lang/Seed7/Dragon-curve new file mode 120000 index 0000000000..dec54ca1aa --- /dev/null +++ b/Lang/Seed7/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Environment-variables b/Lang/Seed7/Environment-variables new file mode 120000 index 0000000000..fe56ff78e7 --- /dev/null +++ b/Lang/Seed7/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Non-decimal-radices-Output b/Lang/Seed7/Non-decimal-radices-Output new file mode 120000 index 0000000000..7414389c16 --- /dev/null +++ b/Lang/Seed7/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Nth-root b/Lang/Seed7/Nth-root new file mode 120000 index 0000000000..f97173ab54 --- /dev/null +++ b/Lang/Seed7/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Number-names b/Lang/Seed7/Number-names new file mode 120000 index 0000000000..94328ab294 --- /dev/null +++ b/Lang/Seed7/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/One-dimensional-cellular-automata b/Lang/Seed7/One-dimensional-cellular-automata new file mode 120000 index 0000000000..e256d8aa77 --- /dev/null +++ b/Lang/Seed7/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/One-of-n-lines-in-a-file b/Lang/Seed7/One-of-n-lines-in-a-file new file mode 120000 index 0000000000..cb58493053 --- /dev/null +++ b/Lang/Seed7/One-of-n-lines-in-a-file @@ -0,0 +1 @@ +../../Task/One-of-n-lines-in-a-file/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Palindrome-detection b/Lang/Seed7/Palindrome-detection new file mode 120000 index 0000000000..cfbda1418b --- /dev/null +++ b/Lang/Seed7/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Pangram-checker b/Lang/Seed7/Pangram-checker new file mode 120000 index 0000000000..694e9208db --- /dev/null +++ b/Lang/Seed7/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Parametric-polymorphism b/Lang/Seed7/Parametric-polymorphism new file mode 120000 index 0000000000..c5789108b8 --- /dev/null +++ b/Lang/Seed7/Parametric-polymorphism @@ -0,0 +1 @@ +../../Task/Parametric-polymorphism/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Pascals-triangle b/Lang/Seed7/Pascals-triangle new file mode 120000 index 0000000000..6346acd352 --- /dev/null +++ b/Lang/Seed7/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Perfect-numbers b/Lang/Seed7/Perfect-numbers new file mode 120000 index 0000000000..c3e8f51b12 --- /dev/null +++ b/Lang/Seed7/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Permutations b/Lang/Seed7/Permutations new file mode 120000 index 0000000000..2d65708f5e --- /dev/null +++ b/Lang/Seed7/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Pick-random-element b/Lang/Seed7/Pick-random-element new file mode 120000 index 0000000000..e81291c8c6 --- /dev/null +++ b/Lang/Seed7/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Power-set b/Lang/Seed7/Power-set new file mode 120000 index 0000000000..137c84839a --- /dev/null +++ b/Lang/Seed7/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Price-fraction b/Lang/Seed7/Price-fraction new file mode 120000 index 0000000000..da68469fb0 --- /dev/null +++ b/Lang/Seed7/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Primality-by-trial-division b/Lang/Seed7/Primality-by-trial-division new file mode 120000 index 0000000000..0b29d9dba3 --- /dev/null +++ b/Lang/Seed7/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Prime-decomposition b/Lang/Seed7/Prime-decomposition new file mode 120000 index 0000000000..ecb24d7c6a --- /dev/null +++ b/Lang/Seed7/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Probabilistic-choice b/Lang/Seed7/Probabilistic-choice new file mode 120000 index 0000000000..04ca22af27 --- /dev/null +++ b/Lang/Seed7/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Program-name b/Lang/Seed7/Program-name new file mode 120000 index 0000000000..ab7ef0c0fa --- /dev/null +++ b/Lang/Seed7/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Program-termination b/Lang/Seed7/Program-termination new file mode 120000 index 0000000000..7727673a5c --- /dev/null +++ b/Lang/Seed7/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Pythagorean-triples b/Lang/Seed7/Pythagorean-triples new file mode 120000 index 0000000000..9036575931 --- /dev/null +++ b/Lang/Seed7/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Random-numbers b/Lang/Seed7/Random-numbers new file mode 120000 index 0000000000..58d5ce3400 --- /dev/null +++ b/Lang/Seed7/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Range-expansion b/Lang/Seed7/Range-expansion new file mode 120000 index 0000000000..51fdacd2cf --- /dev/null +++ b/Lang/Seed7/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Range-extraction b/Lang/Seed7/Range-extraction new file mode 120000 index 0000000000..76c04a6b9d --- /dev/null +++ b/Lang/Seed7/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Read-a-configuration-file b/Lang/Seed7/Read-a-configuration-file new file mode 120000 index 0000000000..239b8b1caa --- /dev/null +++ b/Lang/Seed7/Read-a-configuration-file @@ -0,0 +1 @@ +../../Task/Read-a-configuration-file/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Read-a-file-line-by-line b/Lang/Seed7/Read-a-file-line-by-line new file mode 120000 index 0000000000..ac6318c9da --- /dev/null +++ b/Lang/Seed7/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Read-a-specific-line-from-a-file b/Lang/Seed7/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..1ecf283ed2 --- /dev/null +++ b/Lang/Seed7/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Reduced-row-echelon-form b/Lang/Seed7/Reduced-row-echelon-form new file mode 120000 index 0000000000..ae5a95d5df --- /dev/null +++ b/Lang/Seed7/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Remove-duplicate-elements b/Lang/Seed7/Remove-duplicate-elements new file mode 120000 index 0000000000..415dd98449 --- /dev/null +++ b/Lang/Seed7/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Remove-lines-from-a-file b/Lang/Seed7/Remove-lines-from-a-file new file mode 120000 index 0000000000..44385c5f78 --- /dev/null +++ b/Lang/Seed7/Remove-lines-from-a-file @@ -0,0 +1 @@ +../../Task/Remove-lines-from-a-file/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Rename-a-file b/Lang/Seed7/Rename-a-file new file mode 120000 index 0000000000..87eabcaf67 --- /dev/null +++ b/Lang/Seed7/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Repeat-a-string b/Lang/Seed7/Repeat-a-string new file mode 120000 index 0000000000..0b9ba94464 --- /dev/null +++ b/Lang/Seed7/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Return-multiple-values b/Lang/Seed7/Return-multiple-values new file mode 120000 index 0000000000..4e675f3093 --- /dev/null +++ b/Lang/Seed7/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Reverse-a-string b/Lang/Seed7/Reverse-a-string new file mode 120000 index 0000000000..6a4f884195 --- /dev/null +++ b/Lang/Seed7/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Roman-numerals-Decode b/Lang/Seed7/Roman-numerals-Decode new file mode 120000 index 0000000000..bb18d17ea7 --- /dev/null +++ b/Lang/Seed7/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Roman-numerals-Encode b/Lang/Seed7/Roman-numerals-Encode new file mode 120000 index 0000000000..aa9bf3a87f --- /dev/null +++ b/Lang/Seed7/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Roots-of-a-quadratic-function b/Lang/Seed7/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..b64d756ea5 --- /dev/null +++ b/Lang/Seed7/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Roots-of-unity b/Lang/Seed7/Roots-of-unity new file mode 120000 index 0000000000..6b8ef3e533 --- /dev/null +++ b/Lang/Seed7/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Rot-13 b/Lang/Seed7/Rot-13 new file mode 120000 index 0000000000..02108d1879 --- /dev/null +++ b/Lang/Seed7/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Run-length-encoding b/Lang/Seed7/Run-length-encoding new file mode 120000 index 0000000000..7653e6803a --- /dev/null +++ b/Lang/Seed7/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/SEDOLs b/Lang/Seed7/SEDOLs new file mode 120000 index 0000000000..2bb559cbb1 --- /dev/null +++ b/Lang/Seed7/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Self-describing-numbers b/Lang/Seed7/Self-describing-numbers new file mode 120000 index 0000000000..20b566b3dc --- /dev/null +++ b/Lang/Seed7/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Sequence-of-non-squares b/Lang/Seed7/Sequence-of-non-squares new file mode 120000 index 0000000000..c0a9aa2333 --- /dev/null +++ b/Lang/Seed7/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Seed7 \ No newline at end of file diff --git a/Lang/Seed7/Set b/Lang/Seed7/Set new file mode 120000 index 0000000000..4f6f1d713f --- /dev/null +++ b/Lang/Seed7/Set @@ -0,0 +1 @@ +../../Task/Set/Seed7 \ No newline at end of file diff --git a/Lang/Shiny/Copy-a-string b/Lang/Shiny/Copy-a-string new file mode 120000 index 0000000000..e16f997ab7 --- /dev/null +++ b/Lang/Shiny/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Shiny \ No newline at end of file diff --git a/Lang/Shiny/Regular-expressions b/Lang/Shiny/Regular-expressions new file mode 120000 index 0000000000..5a0ba863cc --- /dev/null +++ b/Lang/Shiny/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Shiny \ No newline at end of file diff --git a/Lang/Slate/Copy-a-string b/Lang/Slate/Copy-a-string new file mode 120000 index 0000000000..e6effe2b78 --- /dev/null +++ b/Lang/Slate/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Slate \ No newline at end of file diff --git a/Lang/Slate/Environment-variables b/Lang/Slate/Environment-variables new file mode 120000 index 0000000000..23aa618a6b --- /dev/null +++ b/Lang/Slate/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Slate \ No newline at end of file diff --git a/Lang/Slate/Non-decimal-radices-Convert b/Lang/Slate/Non-decimal-radices-Convert new file mode 120000 index 0000000000..6399fb95f0 --- /dev/null +++ b/Lang/Slate/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/Slate \ No newline at end of file diff --git a/Lang/Slate/Null-object b/Lang/Slate/Null-object new file mode 120000 index 0000000000..32bf98f223 --- /dev/null +++ b/Lang/Slate/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Slate \ No newline at end of file diff --git a/Lang/Slate/Optional-parameters b/Lang/Slate/Optional-parameters new file mode 120000 index 0000000000..cc0096a03c --- /dev/null +++ b/Lang/Slate/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/Slate \ No newline at end of file diff --git a/Lang/Slate/Palindrome-detection b/Lang/Slate/Palindrome-detection new file mode 120000 index 0000000000..39f5d67990 --- /dev/null +++ b/Lang/Slate/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Slate \ No newline at end of file diff --git a/Lang/Slate/Perfect-numbers b/Lang/Slate/Perfect-numbers new file mode 120000 index 0000000000..2fbee2b9c0 --- /dev/null +++ b/Lang/Slate/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Slate \ No newline at end of file diff --git a/Lang/Slate/Polymorphic-copy b/Lang/Slate/Polymorphic-copy new file mode 120000 index 0000000000..43e791d50c --- /dev/null +++ b/Lang/Slate/Polymorphic-copy @@ -0,0 +1 @@ +../../Task/Polymorphic-copy/Slate \ No newline at end of file diff --git a/Lang/Slate/Polynomial-long-division b/Lang/Slate/Polynomial-long-division new file mode 120000 index 0000000000..82012a68f0 --- /dev/null +++ b/Lang/Slate/Polynomial-long-division @@ -0,0 +1 @@ +../../Task/Polynomial-long-division/Slate \ No newline at end of file diff --git a/Lang/Slate/Prime-decomposition b/Lang/Slate/Prime-decomposition new file mode 120000 index 0000000000..63d74dfeea --- /dev/null +++ b/Lang/Slate/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Slate \ No newline at end of file diff --git a/Lang/Slate/Program-termination b/Lang/Slate/Program-termination new file mode 120000 index 0000000000..f78382b493 --- /dev/null +++ b/Lang/Slate/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Slate \ No newline at end of file diff --git a/Lang/Slate/Queue-Definition b/Lang/Slate/Queue-Definition new file mode 120000 index 0000000000..b8c42f138c --- /dev/null +++ b/Lang/Slate/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/Slate \ No newline at end of file diff --git a/Lang/Slate/Real-constants-and-functions b/Lang/Slate/Real-constants-and-functions new file mode 120000 index 0000000000..dde8dee75b --- /dev/null +++ b/Lang/Slate/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Slate \ No newline at end of file diff --git a/Lang/Slate/Regular-expressions b/Lang/Slate/Regular-expressions new file mode 120000 index 0000000000..7985b1edb0 --- /dev/null +++ b/Lang/Slate/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Slate \ No newline at end of file diff --git a/Lang/Slate/Remove-duplicate-elements b/Lang/Slate/Remove-duplicate-elements new file mode 120000 index 0000000000..0695458f1d --- /dev/null +++ b/Lang/Slate/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Slate \ No newline at end of file diff --git a/Lang/Slate/Rename-a-file b/Lang/Slate/Rename-a-file new file mode 120000 index 0000000000..3f4e309c5f --- /dev/null +++ b/Lang/Slate/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Slate \ No newline at end of file diff --git a/Lang/Slate/Respond-to-an-unknown-method-call b/Lang/Slate/Respond-to-an-unknown-method-call new file mode 120000 index 0000000000..381bddef15 --- /dev/null +++ b/Lang/Slate/Respond-to-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Respond-to-an-unknown-method-call/Slate \ No newline at end of file diff --git a/Lang/Slate/Reverse-a-string b/Lang/Slate/Reverse-a-string new file mode 120000 index 0000000000..b21f358706 --- /dev/null +++ b/Lang/Slate/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Slate \ No newline at end of file diff --git a/Lang/Slate/Rot-13 b/Lang/Slate/Rot-13 new file mode 120000 index 0000000000..8acc2c65d8 --- /dev/null +++ b/Lang/Slate/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Slate \ No newline at end of file diff --git a/Lang/Slate/Runtime-evaluation b/Lang/Slate/Runtime-evaluation new file mode 120000 index 0000000000..54e19136e5 --- /dev/null +++ b/Lang/Slate/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/Slate \ No newline at end of file diff --git a/Lang/Smalltalk/Arbitrary-precision-integers--included- b/Lang/Smalltalk/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..eed475bf59 --- /dev/null +++ b/Lang/Smalltalk/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Arbitrary-precision-integers-included b/Lang/Smalltalk/Arbitrary-precision-integers-included deleted file mode 120000 index c4c742c9d3..0000000000 --- a/Lang/Smalltalk/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Binary-digits b/Lang/Smalltalk/Binary-digits new file mode 120000 index 0000000000..2f10ff6572 --- /dev/null +++ b/Lang/Smalltalk/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Copy-a-string b/Lang/Smalltalk/Copy-a-string new file mode 120000 index 0000000000..b5b15874dc --- /dev/null +++ b/Lang/Smalltalk/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Guess-the-number-With-feedback--player- b/Lang/Smalltalk/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..a4d429eae6 --- /dev/null +++ b/Lang/Smalltalk/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Guess-the-number-With-feedback-player b/Lang/Smalltalk/Guess-the-number-With-feedback-player deleted file mode 120000 index 4f3cf09f40..0000000000 --- a/Lang/Smalltalk/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Named-parameters b/Lang/Smalltalk/Named-parameters new file mode 120000 index 0000000000..a69c6414eb --- /dev/null +++ b/Lang/Smalltalk/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Non-decimal-radices-Output b/Lang/Smalltalk/Non-decimal-radices-Output new file mode 120000 index 0000000000..b72411e684 --- /dev/null +++ b/Lang/Smalltalk/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Nth-root b/Lang/Smalltalk/Nth-root new file mode 120000 index 0000000000..2950d1ca0a --- /dev/null +++ b/Lang/Smalltalk/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Null-object b/Lang/Smalltalk/Null-object new file mode 120000 index 0000000000..c08af7d9c5 --- /dev/null +++ b/Lang/Smalltalk/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Palindrome-detection b/Lang/Smalltalk/Palindrome-detection new file mode 120000 index 0000000000..26b3ecf7a3 --- /dev/null +++ b/Lang/Smalltalk/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Pangram-checker b/Lang/Smalltalk/Pangram-checker new file mode 120000 index 0000000000..7fbe0dc786 --- /dev/null +++ b/Lang/Smalltalk/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Partial-function-application b/Lang/Smalltalk/Partial-function-application new file mode 120000 index 0000000000..472f8f65e8 --- /dev/null +++ b/Lang/Smalltalk/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Perfect-numbers b/Lang/Smalltalk/Perfect-numbers new file mode 120000 index 0000000000..ba9ef7fe45 --- /dev/null +++ b/Lang/Smalltalk/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Permutations b/Lang/Smalltalk/Permutations new file mode 120000 index 0000000000..33e2d64d45 --- /dev/null +++ b/Lang/Smalltalk/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Pick-random-element b/Lang/Smalltalk/Pick-random-element new file mode 120000 index 0000000000..085e0a2bbe --- /dev/null +++ b/Lang/Smalltalk/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Playing-cards b/Lang/Smalltalk/Playing-cards new file mode 120000 index 0000000000..4f1133fb0a --- /dev/null +++ b/Lang/Smalltalk/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Polymorphism b/Lang/Smalltalk/Polymorphism new file mode 120000 index 0000000000..465c9c7cb4 --- /dev/null +++ b/Lang/Smalltalk/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Polynomial-long-division b/Lang/Smalltalk/Polynomial-long-division new file mode 120000 index 0000000000..ffcfe8783e --- /dev/null +++ b/Lang/Smalltalk/Polynomial-long-division @@ -0,0 +1 @@ +../../Task/Polynomial-long-division/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Power-set b/Lang/Smalltalk/Power-set new file mode 120000 index 0000000000..2b2fbf5aea --- /dev/null +++ b/Lang/Smalltalk/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Price-fraction b/Lang/Smalltalk/Price-fraction new file mode 120000 index 0000000000..dc8a3b7e4a --- /dev/null +++ b/Lang/Smalltalk/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Prime-decomposition b/Lang/Smalltalk/Prime-decomposition new file mode 120000 index 0000000000..a5337b6518 --- /dev/null +++ b/Lang/Smalltalk/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Program-name b/Lang/Smalltalk/Program-name new file mode 120000 index 0000000000..5879b4e2f7 --- /dev/null +++ b/Lang/Smalltalk/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Queue-Definition b/Lang/Smalltalk/Queue-Definition new file mode 120000 index 0000000000..a6cb1bf85a --- /dev/null +++ b/Lang/Smalltalk/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Rate-counter b/Lang/Smalltalk/Rate-counter new file mode 120000 index 0000000000..6fdbcecec0 --- /dev/null +++ b/Lang/Smalltalk/Rate-counter @@ -0,0 +1 @@ +../../Task/Rate-counter/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Ray-casting-algorithm b/Lang/Smalltalk/Ray-casting-algorithm new file mode 120000 index 0000000000..f926588d02 --- /dev/null +++ b/Lang/Smalltalk/Ray-casting-algorithm @@ -0,0 +1 @@ +../../Task/Ray-casting-algorithm/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Read-a-configuration-file b/Lang/Smalltalk/Read-a-configuration-file new file mode 120000 index 0000000000..751641a564 --- /dev/null +++ b/Lang/Smalltalk/Read-a-configuration-file @@ -0,0 +1 @@ +../../Task/Read-a-configuration-file/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Read-a-file-line-by-line b/Lang/Smalltalk/Read-a-file-line-by-line new file mode 120000 index 0000000000..d9355052c9 --- /dev/null +++ b/Lang/Smalltalk/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Read-entire-file b/Lang/Smalltalk/Read-entire-file new file mode 120000 index 0000000000..ec67d891e9 --- /dev/null +++ b/Lang/Smalltalk/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Real-constants-and-functions b/Lang/Smalltalk/Real-constants-and-functions new file mode 120000 index 0000000000..1c493e386a --- /dev/null +++ b/Lang/Smalltalk/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Regular-expressions b/Lang/Smalltalk/Regular-expressions new file mode 120000 index 0000000000..4126679c26 --- /dev/null +++ b/Lang/Smalltalk/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Remove-duplicate-elements b/Lang/Smalltalk/Remove-duplicate-elements new file mode 120000 index 0000000000..e1f02f696e --- /dev/null +++ b/Lang/Smalltalk/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Rename-a-file b/Lang/Smalltalk/Rename-a-file new file mode 120000 index 0000000000..9266f3d03a --- /dev/null +++ b/Lang/Smalltalk/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Repeat-a-string b/Lang/Smalltalk/Repeat-a-string new file mode 120000 index 0000000000..1696d1edb1 --- /dev/null +++ b/Lang/Smalltalk/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Respond-to-an-unknown-method-call b/Lang/Smalltalk/Respond-to-an-unknown-method-call new file mode 120000 index 0000000000..518c6f74c3 --- /dev/null +++ b/Lang/Smalltalk/Respond-to-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Respond-to-an-unknown-method-call/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Reverse-a-string b/Lang/Smalltalk/Reverse-a-string new file mode 120000 index 0000000000..3603e3036a --- /dev/null +++ b/Lang/Smalltalk/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Roman-numerals-Encode b/Lang/Smalltalk/Roman-numerals-Encode new file mode 120000 index 0000000000..4e2b1bb135 --- /dev/null +++ b/Lang/Smalltalk/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Rot-13 b/Lang/Smalltalk/Rot-13 new file mode 120000 index 0000000000..33b1e8841d --- /dev/null +++ b/Lang/Smalltalk/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Runtime-evaluation b/Lang/Smalltalk/Runtime-evaluation new file mode 120000 index 0000000000..551f6a5e4c --- /dev/null +++ b/Lang/Smalltalk/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/SEDOLs b/Lang/Smalltalk/SEDOLs new file mode 120000 index 0000000000..3abe8dec62 --- /dev/null +++ b/Lang/Smalltalk/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Send-an-unknown-method-call b/Lang/Smalltalk/Send-an-unknown-method-call new file mode 120000 index 0000000000..dcf2a152a2 --- /dev/null +++ b/Lang/Smalltalk/Send-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Send-an-unknown-method-call/Smalltalk \ No newline at end of file diff --git a/Lang/Smalltalk/Set b/Lang/Smalltalk/Set new file mode 120000 index 0000000000..78e9f906d8 --- /dev/null +++ b/Lang/Smalltalk/Set @@ -0,0 +1 @@ +../../Task/Set/Smalltalk \ No newline at end of file diff --git a/Lang/Standard-ML/Arbitrary-precision-integers--included- b/Lang/Standard-ML/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..f6441d1625 --- /dev/null +++ b/Lang/Standard-ML/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Arbitrary-precision-integers-included b/Lang/Standard-ML/Arbitrary-precision-integers-included deleted file mode 120000 index 8360f335a2..0000000000 --- a/Lang/Standard-ML/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Binary-digits b/Lang/Standard-ML/Binary-digits new file mode 120000 index 0000000000..b1cc363159 --- /dev/null +++ b/Lang/Standard-ML/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Catalan-numbers b/Lang/Standard-ML/Catalan-numbers new file mode 120000 index 0000000000..02bb555ff0 --- /dev/null +++ b/Lang/Standard-ML/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Copy-a-string b/Lang/Standard-ML/Copy-a-string new file mode 120000 index 0000000000..2baf3d2881 --- /dev/null +++ b/Lang/Standard-ML/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Environment-variables b/Lang/Standard-ML/Environment-variables new file mode 120000 index 0000000000..ca30bf32a2 --- /dev/null +++ b/Lang/Standard-ML/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/N-queens-problem b/Lang/Standard-ML/N-queens-problem new file mode 120000 index 0000000000..5b423ed880 --- /dev/null +++ b/Lang/Standard-ML/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Non-continuous-subsequences b/Lang/Standard-ML/Non-continuous-subsequences new file mode 120000 index 0000000000..b8a861cdc3 --- /dev/null +++ b/Lang/Standard-ML/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Non-decimal-radices-Convert b/Lang/Standard-ML/Non-decimal-radices-Convert new file mode 120000 index 0000000000..2e8fe105ec --- /dev/null +++ b/Lang/Standard-ML/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Non-decimal-radices-Input b/Lang/Standard-ML/Non-decimal-radices-Input new file mode 120000 index 0000000000..e082ab158d --- /dev/null +++ b/Lang/Standard-ML/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Non-decimal-radices-Output b/Lang/Standard-ML/Non-decimal-radices-Output new file mode 120000 index 0000000000..2477ec2286 --- /dev/null +++ b/Lang/Standard-ML/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Null-object b/Lang/Standard-ML/Null-object new file mode 120000 index 0000000000..b092ba35fc --- /dev/null +++ b/Lang/Standard-ML/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Numerical-integration b/Lang/Standard-ML/Numerical-integration new file mode 120000 index 0000000000..45ebd4acd2 --- /dev/null +++ b/Lang/Standard-ML/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Order-two-numerical-lists b/Lang/Standard-ML/Order-two-numerical-lists new file mode 120000 index 0000000000..6fb12e81cc --- /dev/null +++ b/Lang/Standard-ML/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Parametric-polymorphism b/Lang/Standard-ML/Parametric-polymorphism new file mode 120000 index 0000000000..b8dbc589a5 --- /dev/null +++ b/Lang/Standard-ML/Parametric-polymorphism @@ -0,0 +1 @@ +../../Task/Parametric-polymorphism/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Pattern-matching b/Lang/Standard-ML/Pattern-matching new file mode 120000 index 0000000000..2eb29c7ffa --- /dev/null +++ b/Lang/Standard-ML/Pattern-matching @@ -0,0 +1 @@ +../../Task/Pattern-matching/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Pointers-and-references b/Lang/Standard-ML/Pointers-and-references new file mode 120000 index 0000000000..f9a649a551 --- /dev/null +++ b/Lang/Standard-ML/Pointers-and-references @@ -0,0 +1 @@ +../../Task/Pointers-and-references/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Power-set b/Lang/Standard-ML/Power-set new file mode 120000 index 0000000000..a752faf1e7 --- /dev/null +++ b/Lang/Standard-ML/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Primality-by-trial-division b/Lang/Standard-ML/Primality-by-trial-division new file mode 120000 index 0000000000..b8a094692a --- /dev/null +++ b/Lang/Standard-ML/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Priority-queue b/Lang/Standard-ML/Priority-queue new file mode 120000 index 0000000000..014949b204 --- /dev/null +++ b/Lang/Standard-ML/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Program-name b/Lang/Standard-ML/Program-name new file mode 120000 index 0000000000..2ac6e704a8 --- /dev/null +++ b/Lang/Standard-ML/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Program-termination b/Lang/Standard-ML/Program-termination new file mode 120000 index 0000000000..d5f35d863b --- /dev/null +++ b/Lang/Standard-ML/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Queue-Definition b/Lang/Standard-ML/Queue-Definition new file mode 120000 index 0000000000..2052737959 --- /dev/null +++ b/Lang/Standard-ML/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Queue-Usage b/Lang/Standard-ML/Queue-Usage new file mode 120000 index 0000000000..168b0c97d1 --- /dev/null +++ b/Lang/Standard-ML/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Random-numbers b/Lang/Standard-ML/Random-numbers new file mode 120000 index 0000000000..add9574603 --- /dev/null +++ b/Lang/Standard-ML/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Real-constants-and-functions b/Lang/Standard-ML/Real-constants-and-functions new file mode 120000 index 0000000000..2fb854f20b --- /dev/null +++ b/Lang/Standard-ML/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Regular-expressions b/Lang/Standard-ML/Regular-expressions new file mode 120000 index 0000000000..148e7c0927 --- /dev/null +++ b/Lang/Standard-ML/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Rename-a-file b/Lang/Standard-ML/Rename-a-file new file mode 120000 index 0000000000..4eddbb6092 --- /dev/null +++ b/Lang/Standard-ML/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Repeat-a-string b/Lang/Standard-ML/Repeat-a-string new file mode 120000 index 0000000000..a3b4f520c4 --- /dev/null +++ b/Lang/Standard-ML/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Return-multiple-values b/Lang/Standard-ML/Return-multiple-values new file mode 120000 index 0000000000..025e48162e --- /dev/null +++ b/Lang/Standard-ML/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Reverse-a-string b/Lang/Standard-ML/Reverse-a-string new file mode 120000 index 0000000000..0d03db79b0 --- /dev/null +++ b/Lang/Standard-ML/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Rot-13 b/Lang/Standard-ML/Rot-13 new file mode 120000 index 0000000000..8dd80a3357 --- /dev/null +++ b/Lang/Standard-ML/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Run-length-encoding b/Lang/Standard-ML/Run-length-encoding new file mode 120000 index 0000000000..ed635ded69 --- /dev/null +++ b/Lang/Standard-ML/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/SEDOLs b/Lang/Standard-ML/SEDOLs new file mode 120000 index 0000000000..cf5942c2b4 --- /dev/null +++ b/Lang/Standard-ML/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Secure-temporary-file b/Lang/Standard-ML/Secure-temporary-file new file mode 120000 index 0000000000..64de1b6c24 --- /dev/null +++ b/Lang/Standard-ML/Secure-temporary-file @@ -0,0 +1 @@ +../../Task/Secure-temporary-file/Standard-ML \ No newline at end of file diff --git a/Lang/Standard-ML/Sequence-of-non-squares b/Lang/Standard-ML/Sequence-of-non-squares new file mode 120000 index 0000000000..7e7da23260 --- /dev/null +++ b/Lang/Standard-ML/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Standard-ML \ No newline at end of file diff --git a/Lang/Suneido/Named-parameters b/Lang/Suneido/Named-parameters new file mode 120000 index 0000000000..3d5b2e94c0 --- /dev/null +++ b/Lang/Suneido/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/Suneido \ No newline at end of file diff --git a/Lang/Suneido/Repeat-a-string b/Lang/Suneido/Repeat-a-string new file mode 120000 index 0000000000..d685ccc0dc --- /dev/null +++ b/Lang/Suneido/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Suneido \ No newline at end of file diff --git a/Lang/SystemVerilog/N-queens-problem b/Lang/SystemVerilog/N-queens-problem new file mode 120000 index 0000000000..54c2eee07e --- /dev/null +++ b/Lang/SystemVerilog/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/SystemVerilog \ No newline at end of file diff --git a/Lang/SystemVerilog/Pascals-triangle-Puzzle b/Lang/SystemVerilog/Pascals-triangle-Puzzle new file mode 120000 index 0000000000..26377a2453 --- /dev/null +++ b/Lang/SystemVerilog/Pascals-triangle-Puzzle @@ -0,0 +1 @@ +../../Task/Pascals-triangle-Puzzle/SystemVerilog \ No newline at end of file diff --git a/Lang/TI-83-BASIC/Binary-digits b/Lang/TI-83-BASIC/Binary-digits new file mode 120000 index 0000000000..466485a437 --- /dev/null +++ b/Lang/TI-83-BASIC/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/TI-83-BASIC \ No newline at end of file diff --git a/Lang/TI-83-BASIC/Brownian-tree b/Lang/TI-83-BASIC/Brownian-tree new file mode 120000 index 0000000000..ec6ef29e99 --- /dev/null +++ b/Lang/TI-83-BASIC/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/TI-83-BASIC \ No newline at end of file diff --git a/Lang/TI-83-BASIC/Catalan-numbers b/Lang/TI-83-BASIC/Catalan-numbers new file mode 120000 index 0000000000..d14ccc9fdb --- /dev/null +++ b/Lang/TI-83-BASIC/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/TI-83-BASIC \ No newline at end of file diff --git a/Lang/TI-83-BASIC/Copy-a-string b/Lang/TI-83-BASIC/Copy-a-string new file mode 120000 index 0000000000..f8ca55ccf7 --- /dev/null +++ b/Lang/TI-83-BASIC/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/TI-83-BASIC \ No newline at end of file diff --git a/Lang/TI-83-BASIC/Program-termination b/Lang/TI-83-BASIC/Program-termination new file mode 120000 index 0000000000..21f7ae3833 --- /dev/null +++ b/Lang/TI-83-BASIC/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/TI-83-BASIC \ No newline at end of file diff --git a/Lang/TI-83-BASIC/Reverse-a-string b/Lang/TI-83-BASIC/Reverse-a-string new file mode 120000 index 0000000000..59f38f2e65 --- /dev/null +++ b/Lang/TI-83-BASIC/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/TI-83-BASIC \ No newline at end of file diff --git a/Lang/TI-83-BASIC/Rock-paper-scissors b/Lang/TI-83-BASIC/Rock-paper-scissors new file mode 120000 index 0000000000..391e63ff21 --- /dev/null +++ b/Lang/TI-83-BASIC/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/TI-83-BASIC \ No newline at end of file diff --git a/Lang/TI-83-BASIC/Roman-numerals-Decode b/Lang/TI-83-BASIC/Roman-numerals-Decode new file mode 120000 index 0000000000..88ee8fce37 --- /dev/null +++ b/Lang/TI-83-BASIC/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/TI-83-BASIC \ No newline at end of file diff --git a/Lang/TI-83-BASIC/Roman-numerals-Encode b/Lang/TI-83-BASIC/Roman-numerals-Encode new file mode 120000 index 0000000000..e7686c51a3 --- /dev/null +++ b/Lang/TI-83-BASIC/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/TI-83-BASIC \ No newline at end of file diff --git a/Lang/TI-83-BASIC/Rot-13 b/Lang/TI-83-BASIC/Rot-13 new file mode 120000 index 0000000000..550da4cac4 --- /dev/null +++ b/Lang/TI-83-BASIC/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/TI-83-BASIC \ No newline at end of file diff --git a/Lang/TI-89-BASIC/Copy-a-string b/Lang/TI-89-BASIC/Copy-a-string new file mode 120000 index 0000000000..c81a98485f --- /dev/null +++ b/Lang/TI-89-BASIC/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/TI-89-BASIC \ No newline at end of file diff --git a/Lang/TI-89-BASIC/Dragon-curve b/Lang/TI-89-BASIC/Dragon-curve new file mode 120000 index 0000000000..ec90d9aa1c --- /dev/null +++ b/Lang/TI-89-BASIC/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/TI-89-BASIC \ No newline at end of file diff --git a/Lang/TI-89-BASIC/Non-decimal-radices-Output b/Lang/TI-89-BASIC/Non-decimal-radices-Output new file mode 120000 index 0000000000..ba9c72987f --- /dev/null +++ b/Lang/TI-89-BASIC/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/TI-89-BASIC \ No newline at end of file diff --git a/Lang/TI-89-BASIC/Plot-coordinate-pairs b/Lang/TI-89-BASIC/Plot-coordinate-pairs new file mode 120000 index 0000000000..30ed8101ef --- /dev/null +++ b/Lang/TI-89-BASIC/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/TI-89-BASIC \ No newline at end of file diff --git a/Lang/TI-89-BASIC/Polynomial-regression b/Lang/TI-89-BASIC/Polynomial-regression new file mode 120000 index 0000000000..56f6805c79 --- /dev/null +++ b/Lang/TI-89-BASIC/Polynomial-regression @@ -0,0 +1 @@ +../../Task/Polynomial-regression/TI-89-BASIC \ No newline at end of file diff --git a/Lang/TI-89-BASIC/Program-termination b/Lang/TI-89-BASIC/Program-termination new file mode 120000 index 0000000000..2083222119 --- /dev/null +++ b/Lang/TI-89-BASIC/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/TI-89-BASIC \ No newline at end of file diff --git a/Lang/TI-89-BASIC/Reduced-row-echelon-form b/Lang/TI-89-BASIC/Reduced-row-echelon-form new file mode 120000 index 0000000000..a81f42e1e0 --- /dev/null +++ b/Lang/TI-89-BASIC/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/TI-89-BASIC \ No newline at end of file diff --git a/Lang/TI-89-BASIC/Roots-of-unity b/Lang/TI-89-BASIC/Roots-of-unity new file mode 120000 index 0000000000..8f3c5a7a81 --- /dev/null +++ b/Lang/TI-89-BASIC/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/TI-89-BASIC \ No newline at end of file diff --git a/Lang/TI-89-BASIC/Runtime-evaluation-In-an-environment b/Lang/TI-89-BASIC/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..c453978702 --- /dev/null +++ b/Lang/TI-89-BASIC/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/TI-89-BASIC \ No newline at end of file diff --git a/Lang/TI-89-BASIC/Scope-modifiers b/Lang/TI-89-BASIC/Scope-modifiers new file mode 120000 index 0000000000..1e0ba88697 --- /dev/null +++ b/Lang/TI-89-BASIC/Scope-modifiers @@ -0,0 +1 @@ +../../Task/Scope-modifiers/TI-89-BASIC \ No newline at end of file diff --git a/Lang/TI-89-BASIC/Sequence-of-non-squares b/Lang/TI-89-BASIC/Sequence-of-non-squares new file mode 120000 index 0000000000..d528f3f182 --- /dev/null +++ b/Lang/TI-89-BASIC/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/TI-89-BASIC \ No newline at end of file diff --git a/Lang/TIScript/Optional-parameters b/Lang/TIScript/Optional-parameters new file mode 120000 index 0000000000..d6325dd343 --- /dev/null +++ b/Lang/TIScript/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/TIScript \ No newline at end of file diff --git a/Lang/TUSCRIPT/Copy-a-string b/Lang/TUSCRIPT/Copy-a-string new file mode 120000 index 0000000000..cff897bced --- /dev/null +++ b/Lang/TUSCRIPT/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/TUSCRIPT \ No newline at end of file diff --git a/Lang/TUSCRIPT/Number-reversal-game b/Lang/TUSCRIPT/Number-reversal-game new file mode 120000 index 0000000000..82acf37360 --- /dev/null +++ b/Lang/TUSCRIPT/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/TUSCRIPT \ No newline at end of file diff --git a/Lang/TUSCRIPT/Order-two-numerical-lists b/Lang/TUSCRIPT/Order-two-numerical-lists new file mode 120000 index 0000000000..741724bfe8 --- /dev/null +++ b/Lang/TUSCRIPT/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/TUSCRIPT \ No newline at end of file diff --git a/Lang/TUSCRIPT/Palindrome-detection b/Lang/TUSCRIPT/Palindrome-detection new file mode 120000 index 0000000000..8202a1e389 --- /dev/null +++ b/Lang/TUSCRIPT/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/TUSCRIPT \ No newline at end of file diff --git a/Lang/TUSCRIPT/Pangram-checker b/Lang/TUSCRIPT/Pangram-checker new file mode 120000 index 0000000000..71f434e595 --- /dev/null +++ b/Lang/TUSCRIPT/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/TUSCRIPT \ No newline at end of file diff --git a/Lang/TUSCRIPT/Pick-random-element b/Lang/TUSCRIPT/Pick-random-element new file mode 120000 index 0000000000..6c61a4a71e --- /dev/null +++ b/Lang/TUSCRIPT/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/TUSCRIPT \ No newline at end of file diff --git a/Lang/TUSCRIPT/Play-recorded-sounds b/Lang/TUSCRIPT/Play-recorded-sounds new file mode 120000 index 0000000000..7016eba603 --- /dev/null +++ b/Lang/TUSCRIPT/Play-recorded-sounds @@ -0,0 +1 @@ +../../Task/Play-recorded-sounds/TUSCRIPT \ No newline at end of file diff --git a/Lang/TUSCRIPT/Program-termination b/Lang/TUSCRIPT/Program-termination new file mode 120000 index 0000000000..4764297098 --- /dev/null +++ b/Lang/TUSCRIPT/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/TUSCRIPT \ No newline at end of file diff --git a/Lang/TUSCRIPT/Range-expansion b/Lang/TUSCRIPT/Range-expansion new file mode 120000 index 0000000000..f5fa02a889 --- /dev/null +++ b/Lang/TUSCRIPT/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/TUSCRIPT \ No newline at end of file diff --git a/Lang/TUSCRIPT/Range-extraction b/Lang/TUSCRIPT/Range-extraction new file mode 120000 index 0000000000..02a3fe1a9a --- /dev/null +++ b/Lang/TUSCRIPT/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/TUSCRIPT \ No newline at end of file diff --git a/Lang/TUSCRIPT/Read-a-file-line-by-line b/Lang/TUSCRIPT/Read-a-file-line-by-line new file mode 120000 index 0000000000..f941e2e99c --- /dev/null +++ b/Lang/TUSCRIPT/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/TUSCRIPT \ No newline at end of file diff --git a/Lang/TUSCRIPT/Read-a-specific-line-from-a-file b/Lang/TUSCRIPT/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..7c7a75d383 --- /dev/null +++ b/Lang/TUSCRIPT/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/TUSCRIPT \ No newline at end of file diff --git a/Lang/TUSCRIPT/Read-entire-file b/Lang/TUSCRIPT/Read-entire-file new file mode 120000 index 0000000000..0cfca6af7c --- /dev/null +++ b/Lang/TUSCRIPT/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/TUSCRIPT \ No newline at end of file diff --git a/Lang/TUSCRIPT/Remove-duplicate-elements b/Lang/TUSCRIPT/Remove-duplicate-elements new file mode 120000 index 0000000000..c22250d667 --- /dev/null +++ b/Lang/TUSCRIPT/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/TUSCRIPT \ No newline at end of file diff --git a/Lang/TUSCRIPT/Remove-lines-from-a-file b/Lang/TUSCRIPT/Remove-lines-from-a-file new file mode 120000 index 0000000000..98efde5b2b --- /dev/null +++ b/Lang/TUSCRIPT/Remove-lines-from-a-file @@ -0,0 +1 @@ +../../Task/Remove-lines-from-a-file/TUSCRIPT \ No newline at end of file diff --git a/Lang/TUSCRIPT/Rename-a-file b/Lang/TUSCRIPT/Rename-a-file new file mode 120000 index 0000000000..e53b759b54 --- /dev/null +++ b/Lang/TUSCRIPT/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/TUSCRIPT \ No newline at end of file diff --git a/Lang/TUSCRIPT/Repeat-a-string b/Lang/TUSCRIPT/Repeat-a-string new file mode 120000 index 0000000000..e3b6fa2a5c --- /dev/null +++ b/Lang/TUSCRIPT/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/TUSCRIPT \ No newline at end of file diff --git a/Lang/TUSCRIPT/Reverse-a-string b/Lang/TUSCRIPT/Reverse-a-string new file mode 120000 index 0000000000..bf2be96f00 --- /dev/null +++ b/Lang/TUSCRIPT/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/TUSCRIPT \ No newline at end of file diff --git a/Lang/TUSCRIPT/Roman-numerals-Decode b/Lang/TUSCRIPT/Roman-numerals-Decode new file mode 120000 index 0000000000..d1fee1f2ae --- /dev/null +++ b/Lang/TUSCRIPT/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/TUSCRIPT \ No newline at end of file diff --git a/Lang/TUSCRIPT/Roman-numerals-Encode b/Lang/TUSCRIPT/Roman-numerals-Encode new file mode 120000 index 0000000000..1fb28a32ef --- /dev/null +++ b/Lang/TUSCRIPT/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/TUSCRIPT \ No newline at end of file diff --git a/Lang/TUSCRIPT/Rosetta-Code-Count-examples b/Lang/TUSCRIPT/Rosetta-Code-Count-examples new file mode 120000 index 0000000000..593f1db983 --- /dev/null +++ b/Lang/TUSCRIPT/Rosetta-Code-Count-examples @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Count-examples/TUSCRIPT \ No newline at end of file diff --git a/Lang/TUSCRIPT/Rosetta-Code-Rank-languages-by-popularity b/Lang/TUSCRIPT/Rosetta-Code-Rank-languages-by-popularity new file mode 120000 index 0000000000..5c73e329b6 --- /dev/null +++ b/Lang/TUSCRIPT/Rosetta-Code-Rank-languages-by-popularity @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-popularity/TUSCRIPT \ No newline at end of file diff --git a/Lang/TUSCRIPT/Run-length-encoding b/Lang/TUSCRIPT/Run-length-encoding new file mode 120000 index 0000000000..2848a1e929 --- /dev/null +++ b/Lang/TUSCRIPT/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/TUSCRIPT \ No newline at end of file diff --git a/Lang/TUSCRIPT/SEDOLs b/Lang/TUSCRIPT/SEDOLs new file mode 120000 index 0000000000..5123339d88 --- /dev/null +++ b/Lang/TUSCRIPT/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/TUSCRIPT \ No newline at end of file diff --git a/Lang/TUSCRIPT/Secure-temporary-file b/Lang/TUSCRIPT/Secure-temporary-file new file mode 120000 index 0000000000..de39e01923 --- /dev/null +++ b/Lang/TUSCRIPT/Secure-temporary-file @@ -0,0 +1 @@ +../../Task/Secure-temporary-file/TUSCRIPT \ No newline at end of file diff --git a/Lang/TUSCRIPT/Semordnilap b/Lang/TUSCRIPT/Semordnilap new file mode 120000 index 0000000000..f9f53b9590 --- /dev/null +++ b/Lang/TUSCRIPT/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/TUSCRIPT \ No newline at end of file diff --git a/Lang/TUSCRIPT/Send-email b/Lang/TUSCRIPT/Send-email new file mode 120000 index 0000000000..910ec1dfda --- /dev/null +++ b/Lang/TUSCRIPT/Send-email @@ -0,0 +1 @@ +../../Task/Send-email/TUSCRIPT \ No newline at end of file diff --git a/Lang/TXR/Arbitrary-precision-integers--included- b/Lang/TXR/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..88f8567066 --- /dev/null +++ b/Lang/TXR/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/TXR \ No newline at end of file diff --git a/Lang/TXR/Arbitrary-precision-integers-included b/Lang/TXR/Arbitrary-precision-integers-included deleted file mode 120000 index 766c0db431..0000000000 --- a/Lang/TXR/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/TXR \ No newline at end of file diff --git a/Lang/TXR/Environment-variables b/Lang/TXR/Environment-variables new file mode 120000 index 0000000000..3475bcead5 --- /dev/null +++ b/Lang/TXR/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/TXR \ No newline at end of file diff --git a/Lang/TXR/Pangram-checker b/Lang/TXR/Pangram-checker new file mode 120000 index 0000000000..c1be388a09 --- /dev/null +++ b/Lang/TXR/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/TXR \ No newline at end of file diff --git a/Lang/TXR/Pick-random-element b/Lang/TXR/Pick-random-element new file mode 120000 index 0000000000..5bde180eca --- /dev/null +++ b/Lang/TXR/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/TXR \ No newline at end of file diff --git a/Lang/TXR/Power-set b/Lang/TXR/Power-set new file mode 120000 index 0000000000..d3107e0d7f --- /dev/null +++ b/Lang/TXR/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/TXR \ No newline at end of file diff --git a/Lang/TXR/Prime-decomposition b/Lang/TXR/Prime-decomposition new file mode 120000 index 0000000000..eaa237842c --- /dev/null +++ b/Lang/TXR/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/TXR \ No newline at end of file diff --git a/Lang/TXR/Read-a-configuration-file b/Lang/TXR/Read-a-configuration-file new file mode 120000 index 0000000000..d0a7dceb50 --- /dev/null +++ b/Lang/TXR/Read-a-configuration-file @@ -0,0 +1 @@ +../../Task/Read-a-configuration-file/TXR \ No newline at end of file diff --git a/Lang/TXR/Read-a-specific-line-from-a-file b/Lang/TXR/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..f379e3ef5c --- /dev/null +++ b/Lang/TXR/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/TXR \ No newline at end of file diff --git a/Lang/TXR/Read-entire-file b/Lang/TXR/Read-entire-file new file mode 120000 index 0000000000..a19691fb78 --- /dev/null +++ b/Lang/TXR/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/TXR \ No newline at end of file diff --git a/Lang/TXR/Regular-expressions b/Lang/TXR/Regular-expressions new file mode 120000 index 0000000000..5f90361f19 --- /dev/null +++ b/Lang/TXR/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/TXR \ No newline at end of file diff --git a/Lang/TXR/Return-multiple-values b/Lang/TXR/Return-multiple-values new file mode 120000 index 0000000000..f4aee8ae58 --- /dev/null +++ b/Lang/TXR/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/TXR \ No newline at end of file diff --git a/Lang/TXR/Rot-13 b/Lang/TXR/Rot-13 new file mode 120000 index 0000000000..70a3abb775 --- /dev/null +++ b/Lang/TXR/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/TXR \ No newline at end of file diff --git a/Lang/TXR/Scope-modifiers b/Lang/TXR/Scope-modifiers new file mode 120000 index 0000000000..3c6b2ddd8c --- /dev/null +++ b/Lang/TXR/Scope-modifiers @@ -0,0 +1 @@ +../../Task/Scope-modifiers/TXR \ No newline at end of file diff --git a/Lang/TXR/Send-email b/Lang/TXR/Send-email new file mode 120000 index 0000000000..e8f3ae9fea --- /dev/null +++ b/Lang/TXR/Send-email @@ -0,0 +1 @@ +../../Task/Send-email/TXR \ No newline at end of file diff --git a/Lang/Tcl/Arbitrary-precision-integers--included- b/Lang/Tcl/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..5216d8625d --- /dev/null +++ b/Lang/Tcl/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Arbitrary-precision-integers-included b/Lang/Tcl/Arbitrary-precision-integers-included deleted file mode 120000 index c1a2cb119a..0000000000 --- a/Lang/Tcl/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Binary-digits b/Lang/Tcl/Binary-digits new file mode 120000 index 0000000000..488d23d3fb --- /dev/null +++ b/Lang/Tcl/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Brownian-tree b/Lang/Tcl/Brownian-tree new file mode 120000 index 0000000000..c4524d252f --- /dev/null +++ b/Lang/Tcl/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/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..d49bf551a1 --- /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/Calendar-for-real-programmers b/Lang/Tcl/Calendar-for-real-programmers deleted file mode 120000 index 97e97724d3..0000000000 --- a/Lang/Tcl/Calendar-for-real-programmers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Calendar-for-real-programmers/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Catalan-numbers b/Lang/Tcl/Catalan-numbers new file mode 120000 index 0000000000..3cd19b58cb --- /dev/null +++ b/Lang/Tcl/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/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 deleted file mode 120000 index 2ff9107c8e..0000000000 --- a/Lang/Tcl/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N +++ /dev/null @@ -1 +0,0 @@ -../../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-N- b/Lang/Tcl/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N- new file mode 120000 index 0000000000..7d65393585 --- /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 deleted file mode 120000 index a8987eb00c..0000000000 --- a/Lang/Tcl/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2 +++ /dev/null @@ -1 +0,0 @@ -../../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/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..4967ab7af3 --- /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/Copy-a-string b/Lang/Tcl/Copy-a-string new file mode 120000 index 0000000000..310425a40b --- /dev/null +++ b/Lang/Tcl/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Dragon-curve b/Lang/Tcl/Dragon-curve new file mode 120000 index 0000000000..89549752ec --- /dev/null +++ b/Lang/Tcl/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Environment-variables b/Lang/Tcl/Environment-variables new file mode 120000 index 0000000000..7c57a044ce --- /dev/null +++ b/Lang/Tcl/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Execute-a-Markov-algorithm b/Lang/Tcl/Execute-a-Markov-algorithm new file mode 120000 index 0000000000..3b29b4bbe7 --- /dev/null +++ b/Lang/Tcl/Execute-a-Markov-algorithm @@ -0,0 +1 @@ +../../Task/Execute-a-Markov-algorithm/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Guess-the-number-With-feedback--player- b/Lang/Tcl/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..5a829f2a1a --- /dev/null +++ b/Lang/Tcl/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Guess-the-number-With-feedback-player b/Lang/Tcl/Guess-the-number-With-feedback-player deleted file mode 120000 index 45eec94bee..0000000000 --- a/Lang/Tcl/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/Tcl \ No newline at end of file diff --git a/Lang/Tcl/N-queens-problem b/Lang/Tcl/N-queens-problem new file mode 120000 index 0000000000..a9828a78d7 --- /dev/null +++ b/Lang/Tcl/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Named-parameters b/Lang/Tcl/Named-parameters new file mode 120000 index 0000000000..cfd6debc6b --- /dev/null +++ b/Lang/Tcl/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Nautical-bell b/Lang/Tcl/Nautical-bell new file mode 120000 index 0000000000..0e2b2bacbf --- /dev/null +++ b/Lang/Tcl/Nautical-bell @@ -0,0 +1 @@ +../../Task/Nautical-bell/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Non-continuous-subsequences b/Lang/Tcl/Non-continuous-subsequences new file mode 120000 index 0000000000..5c3f136092 --- /dev/null +++ b/Lang/Tcl/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Non-decimal-radices-Convert b/Lang/Tcl/Non-decimal-radices-Convert new file mode 120000 index 0000000000..846994e307 --- /dev/null +++ b/Lang/Tcl/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Non-decimal-radices-Input b/Lang/Tcl/Non-decimal-radices-Input new file mode 120000 index 0000000000..e483654ad3 --- /dev/null +++ b/Lang/Tcl/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Non-decimal-radices-Output b/Lang/Tcl/Non-decimal-radices-Output new file mode 120000 index 0000000000..6b7fb29d62 --- /dev/null +++ b/Lang/Tcl/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Nth-root b/Lang/Tcl/Nth-root new file mode 120000 index 0000000000..32daefcf78 --- /dev/null +++ b/Lang/Tcl/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Null-object b/Lang/Tcl/Null-object new file mode 120000 index 0000000000..b41fd799a0 --- /dev/null +++ b/Lang/Tcl/Null-object @@ -0,0 +1 @@ +../../Task/Null-object/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Number-names b/Lang/Tcl/Number-names new file mode 120000 index 0000000000..9aeea63ca9 --- /dev/null +++ b/Lang/Tcl/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Number-reversal-game b/Lang/Tcl/Number-reversal-game new file mode 120000 index 0000000000..f95be2b6d0 --- /dev/null +++ b/Lang/Tcl/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Numeric-error-propagation b/Lang/Tcl/Numeric-error-propagation new file mode 120000 index 0000000000..95be34bdd1 --- /dev/null +++ b/Lang/Tcl/Numeric-error-propagation @@ -0,0 +1 @@ +../../Task/Numeric-error-propagation/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Numerical-integration b/Lang/Tcl/Numerical-integration new file mode 120000 index 0000000000..b10d052296 --- /dev/null +++ b/Lang/Tcl/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Numerical-integration-Gauss-Legendre-Quadrature b/Lang/Tcl/Numerical-integration-Gauss-Legendre-Quadrature new file mode 120000 index 0000000000..023a5d59af --- /dev/null +++ b/Lang/Tcl/Numerical-integration-Gauss-Legendre-Quadrature @@ -0,0 +1 @@ +../../Task/Numerical-integration-Gauss-Legendre-Quadrature/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Object-serialization b/Lang/Tcl/Object-serialization new file mode 120000 index 0000000000..cedd8c9c07 --- /dev/null +++ b/Lang/Tcl/Object-serialization @@ -0,0 +1 @@ +../../Task/Object-serialization/Tcl \ No newline at end of file diff --git a/Lang/Tcl/One-dimensional-cellular-automata b/Lang/Tcl/One-dimensional-cellular-automata new file mode 120000 index 0000000000..4dd07ded85 --- /dev/null +++ b/Lang/Tcl/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Tcl \ No newline at end of file diff --git a/Lang/Tcl/One-of-n-lines-in-a-file b/Lang/Tcl/One-of-n-lines-in-a-file new file mode 120000 index 0000000000..ecb8aea5ed --- /dev/null +++ b/Lang/Tcl/One-of-n-lines-in-a-file @@ -0,0 +1 @@ +../../Task/One-of-n-lines-in-a-file/Tcl \ No newline at end of file diff --git a/Lang/Tcl/OpenGL b/Lang/Tcl/OpenGL new file mode 120000 index 0000000000..aa16afdf47 --- /dev/null +++ b/Lang/Tcl/OpenGL @@ -0,0 +1 @@ +../../Task/OpenGL/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Optional-parameters b/Lang/Tcl/Optional-parameters new file mode 120000 index 0000000000..99bca4ab01 --- /dev/null +++ b/Lang/Tcl/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Order-two-numerical-lists b/Lang/Tcl/Order-two-numerical-lists new file mode 120000 index 0000000000..0806dbec0a --- /dev/null +++ b/Lang/Tcl/Order-two-numerical-lists @@ -0,0 +1 @@ +../../Task/Order-two-numerical-lists/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Ordered-Partitions b/Lang/Tcl/Ordered-Partitions new file mode 120000 index 0000000000..23cfb8a5ce --- /dev/null +++ b/Lang/Tcl/Ordered-Partitions @@ -0,0 +1 @@ +../../Task/Ordered-Partitions/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Palindrome-detection b/Lang/Tcl/Palindrome-detection new file mode 120000 index 0000000000..4d864467b6 --- /dev/null +++ b/Lang/Tcl/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Pangram-checker b/Lang/Tcl/Pangram-checker new file mode 120000 index 0000000000..bd01efa957 --- /dev/null +++ b/Lang/Tcl/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Parallel-calculations b/Lang/Tcl/Parallel-calculations new file mode 120000 index 0000000000..efb47a1d33 --- /dev/null +++ b/Lang/Tcl/Parallel-calculations @@ -0,0 +1 @@ +../../Task/Parallel-calculations/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Parametrized-SQL-statement b/Lang/Tcl/Parametrized-SQL-statement new file mode 120000 index 0000000000..f458522d2f --- /dev/null +++ b/Lang/Tcl/Parametrized-SQL-statement @@ -0,0 +1 @@ +../../Task/Parametrized-SQL-statement/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Parsing-RPN-calculator-algorithm b/Lang/Tcl/Parsing-RPN-calculator-algorithm new file mode 120000 index 0000000000..a80925b90b --- /dev/null +++ b/Lang/Tcl/Parsing-RPN-calculator-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-RPN-calculator-algorithm/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Parsing-RPN-to-infix-conversion b/Lang/Tcl/Parsing-RPN-to-infix-conversion new file mode 120000 index 0000000000..cacddb4d93 --- /dev/null +++ b/Lang/Tcl/Parsing-RPN-to-infix-conversion @@ -0,0 +1 @@ +../../Task/Parsing-RPN-to-infix-conversion/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Parsing-Shunting-yard-algorithm b/Lang/Tcl/Parsing-Shunting-yard-algorithm new file mode 120000 index 0000000000..b7d469b73e --- /dev/null +++ b/Lang/Tcl/Parsing-Shunting-yard-algorithm @@ -0,0 +1 @@ +../../Task/Parsing-Shunting-yard-algorithm/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Partial-function-application b/Lang/Tcl/Partial-function-application new file mode 120000 index 0000000000..7e4de9f2ec --- /dev/null +++ b/Lang/Tcl/Partial-function-application @@ -0,0 +1 @@ +../../Task/Partial-function-application/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Pascals-triangle b/Lang/Tcl/Pascals-triangle new file mode 120000 index 0000000000..417e75cad5 --- /dev/null +++ b/Lang/Tcl/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Pascals-triangle-Puzzle b/Lang/Tcl/Pascals-triangle-Puzzle new file mode 120000 index 0000000000..6bef90c6c1 --- /dev/null +++ b/Lang/Tcl/Pascals-triangle-Puzzle @@ -0,0 +1 @@ +../../Task/Pascals-triangle-Puzzle/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Pattern-matching b/Lang/Tcl/Pattern-matching new file mode 120000 index 0000000000..21ce76cdc3 --- /dev/null +++ b/Lang/Tcl/Pattern-matching @@ -0,0 +1 @@ +../../Task/Pattern-matching/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Percentage-difference-between-images b/Lang/Tcl/Percentage-difference-between-images new file mode 120000 index 0000000000..0e4ed82c63 --- /dev/null +++ b/Lang/Tcl/Percentage-difference-between-images @@ -0,0 +1 @@ +../../Task/Percentage-difference-between-images/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Perfect-numbers b/Lang/Tcl/Perfect-numbers new file mode 120000 index 0000000000..6fc4478798 --- /dev/null +++ b/Lang/Tcl/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Permutation-test b/Lang/Tcl/Permutation-test new file mode 120000 index 0000000000..2e009865bf --- /dev/null +++ b/Lang/Tcl/Permutation-test @@ -0,0 +1 @@ +../../Task/Permutation-test/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Permutations b/Lang/Tcl/Permutations new file mode 120000 index 0000000000..48a704f012 --- /dev/null +++ b/Lang/Tcl/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Permutations-Derangements b/Lang/Tcl/Permutations-Derangements new file mode 120000 index 0000000000..6d8953a886 --- /dev/null +++ b/Lang/Tcl/Permutations-Derangements @@ -0,0 +1 @@ +../../Task/Permutations-Derangements/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Permutations-by-swapping b/Lang/Tcl/Permutations-by-swapping new file mode 120000 index 0000000000..7515bb46be --- /dev/null +++ b/Lang/Tcl/Permutations-by-swapping @@ -0,0 +1 @@ +../../Task/Permutations-by-swapping/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Pick-random-element b/Lang/Tcl/Pick-random-element new file mode 120000 index 0000000000..e691089bb1 --- /dev/null +++ b/Lang/Tcl/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Pig-the-dice-game b/Lang/Tcl/Pig-the-dice-game new file mode 120000 index 0000000000..032c67a498 --- /dev/null +++ b/Lang/Tcl/Pig-the-dice-game @@ -0,0 +1 @@ +../../Task/Pig-the-dice-game/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Pig-the-dice-game-Player b/Lang/Tcl/Pig-the-dice-game-Player new file mode 120000 index 0000000000..232e1e43b2 --- /dev/null +++ b/Lang/Tcl/Pig-the-dice-game-Player @@ -0,0 +1 @@ +../../Task/Pig-the-dice-game-Player/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Pinstripe-Display b/Lang/Tcl/Pinstripe-Display new file mode 120000 index 0000000000..244906821b --- /dev/null +++ b/Lang/Tcl/Pinstripe-Display @@ -0,0 +1 @@ +../../Task/Pinstripe-Display/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Pinstripe-Printer b/Lang/Tcl/Pinstripe-Printer new file mode 120000 index 0000000000..abcb8826cd --- /dev/null +++ b/Lang/Tcl/Pinstripe-Printer @@ -0,0 +1 @@ +../../Task/Pinstripe-Printer/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Play-recorded-sounds b/Lang/Tcl/Play-recorded-sounds new file mode 120000 index 0000000000..ce2f0f3919 --- /dev/null +++ b/Lang/Tcl/Play-recorded-sounds @@ -0,0 +1 @@ +../../Task/Play-recorded-sounds/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Playing-cards b/Lang/Tcl/Playing-cards new file mode 120000 index 0000000000..fc655a60f1 --- /dev/null +++ b/Lang/Tcl/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Plot-coordinate-pairs b/Lang/Tcl/Plot-coordinate-pairs new file mode 120000 index 0000000000..230d5e5cd1 --- /dev/null +++ b/Lang/Tcl/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Pointers-and-references b/Lang/Tcl/Pointers-and-references new file mode 120000 index 0000000000..c44ab5110d --- /dev/null +++ b/Lang/Tcl/Pointers-and-references @@ -0,0 +1 @@ +../../Task/Pointers-and-references/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Polymorphic-copy b/Lang/Tcl/Polymorphic-copy new file mode 120000 index 0000000000..54a3067efa --- /dev/null +++ b/Lang/Tcl/Polymorphic-copy @@ -0,0 +1 @@ +../../Task/Polymorphic-copy/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Polymorphism b/Lang/Tcl/Polymorphism new file mode 120000 index 0000000000..652c03966a --- /dev/null +++ b/Lang/Tcl/Polymorphism @@ -0,0 +1 @@ +../../Task/Polymorphism/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Polynomial-long-division b/Lang/Tcl/Polynomial-long-division new file mode 120000 index 0000000000..d96f277b61 --- /dev/null +++ b/Lang/Tcl/Polynomial-long-division @@ -0,0 +1 @@ +../../Task/Polynomial-long-division/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Polynomial-regression b/Lang/Tcl/Polynomial-regression new file mode 120000 index 0000000000..38fa80ebb4 --- /dev/null +++ b/Lang/Tcl/Polynomial-regression @@ -0,0 +1 @@ +../../Task/Polynomial-regression/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Power-set b/Lang/Tcl/Power-set new file mode 120000 index 0000000000..8695fab572 --- /dev/null +++ b/Lang/Tcl/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Price-fraction b/Lang/Tcl/Price-fraction new file mode 120000 index 0000000000..09e2f88e1c --- /dev/null +++ b/Lang/Tcl/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Primality-by-trial-division b/Lang/Tcl/Primality-by-trial-division new file mode 120000 index 0000000000..a631f45dd8 --- /dev/null +++ b/Lang/Tcl/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Prime-decomposition b/Lang/Tcl/Prime-decomposition new file mode 120000 index 0000000000..b005f44841 --- /dev/null +++ b/Lang/Tcl/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Priority-queue b/Lang/Tcl/Priority-queue new file mode 120000 index 0000000000..341ec799bf --- /dev/null +++ b/Lang/Tcl/Priority-queue @@ -0,0 +1 @@ +../../Task/Priority-queue/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Probabilistic-choice b/Lang/Tcl/Probabilistic-choice new file mode 120000 index 0000000000..c55fb66be5 --- /dev/null +++ b/Lang/Tcl/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Problem-of-Apollonius b/Lang/Tcl/Problem-of-Apollonius new file mode 120000 index 0000000000..44051fc539 --- /dev/null +++ b/Lang/Tcl/Problem-of-Apollonius @@ -0,0 +1 @@ +../../Task/Problem-of-Apollonius/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Program-name b/Lang/Tcl/Program-name new file mode 120000 index 0000000000..c986247202 --- /dev/null +++ b/Lang/Tcl/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Program-termination b/Lang/Tcl/Program-termination new file mode 120000 index 0000000000..8e50ec8858 --- /dev/null +++ b/Lang/Tcl/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Pythagorean-triples b/Lang/Tcl/Pythagorean-triples new file mode 120000 index 0000000000..ed7803f67f --- /dev/null +++ b/Lang/Tcl/Pythagorean-triples @@ -0,0 +1 @@ +../../Task/Pythagorean-triples/Tcl \ No newline at end of file diff --git a/Lang/Tcl/QR-decomposition b/Lang/Tcl/QR-decomposition new file mode 120000 index 0000000000..b03d15f07d --- /dev/null +++ b/Lang/Tcl/QR-decomposition @@ -0,0 +1 @@ +../../Task/QR-decomposition/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Quaternion-type b/Lang/Tcl/Quaternion-type new file mode 120000 index 0000000000..50905d75b8 --- /dev/null +++ b/Lang/Tcl/Quaternion-type @@ -0,0 +1 @@ +../../Task/Quaternion-type/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Queue-Definition b/Lang/Tcl/Queue-Definition new file mode 120000 index 0000000000..9648db75ad --- /dev/null +++ b/Lang/Tcl/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Queue-Usage b/Lang/Tcl/Queue-Usage new file mode 120000 index 0000000000..85800b2931 --- /dev/null +++ b/Lang/Tcl/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/Tcl \ No newline at end of file diff --git a/Lang/Tcl/RIPEMD-160 b/Lang/Tcl/RIPEMD-160 new file mode 120000 index 0000000000..e2d7a8ab99 --- /dev/null +++ b/Lang/Tcl/RIPEMD-160 @@ -0,0 +1 @@ +../../Task/RIPEMD-160/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Random-number-generator--device- b/Lang/Tcl/Random-number-generator--device- new file mode 120000 index 0000000000..3fc2722e2e --- /dev/null +++ b/Lang/Tcl/Random-number-generator--device- @@ -0,0 +1 @@ +../../Task/Random-number-generator--device-/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Random-numbers b/Lang/Tcl/Random-numbers new file mode 120000 index 0000000000..585ecdc63c --- /dev/null +++ b/Lang/Tcl/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Range-expansion b/Lang/Tcl/Range-expansion new file mode 120000 index 0000000000..ac6afea2c3 --- /dev/null +++ b/Lang/Tcl/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Range-extraction b/Lang/Tcl/Range-extraction new file mode 120000 index 0000000000..5214eb4f33 --- /dev/null +++ b/Lang/Tcl/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Rate-counter b/Lang/Tcl/Rate-counter new file mode 120000 index 0000000000..2bf98c6c50 --- /dev/null +++ b/Lang/Tcl/Rate-counter @@ -0,0 +1 @@ +../../Task/Rate-counter/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Ray-casting-algorithm b/Lang/Tcl/Ray-casting-algorithm new file mode 120000 index 0000000000..f80d6a9c8a --- /dev/null +++ b/Lang/Tcl/Ray-casting-algorithm @@ -0,0 +1 @@ +../../Task/Ray-casting-algorithm/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Read-a-configuration-file b/Lang/Tcl/Read-a-configuration-file new file mode 120000 index 0000000000..aa2302225a --- /dev/null +++ b/Lang/Tcl/Read-a-configuration-file @@ -0,0 +1 @@ +../../Task/Read-a-configuration-file/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Read-a-file-line-by-line b/Lang/Tcl/Read-a-file-line-by-line new file mode 120000 index 0000000000..b298d0e3e3 --- /dev/null +++ b/Lang/Tcl/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Read-a-specific-line-from-a-file b/Lang/Tcl/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..9b0677f828 --- /dev/null +++ b/Lang/Tcl/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Read-entire-file b/Lang/Tcl/Read-entire-file new file mode 120000 index 0000000000..23323e5bf3 --- /dev/null +++ b/Lang/Tcl/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Real-constants-and-functions b/Lang/Tcl/Real-constants-and-functions new file mode 120000 index 0000000000..2cffde7e9e --- /dev/null +++ b/Lang/Tcl/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Record-sound b/Lang/Tcl/Record-sound new file mode 120000 index 0000000000..3910b97c1b --- /dev/null +++ b/Lang/Tcl/Record-sound @@ -0,0 +1 @@ +../../Task/Record-sound/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Reduced-row-echelon-form b/Lang/Tcl/Reduced-row-echelon-form new file mode 120000 index 0000000000..56eb81d8e5 --- /dev/null +++ b/Lang/Tcl/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Regular-expressions b/Lang/Tcl/Regular-expressions new file mode 120000 index 0000000000..ac19d8dad2 --- /dev/null +++ b/Lang/Tcl/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Remove-duplicate-elements b/Lang/Tcl/Remove-duplicate-elements new file mode 120000 index 0000000000..04f4485cb8 --- /dev/null +++ b/Lang/Tcl/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Remove-lines-from-a-file b/Lang/Tcl/Remove-lines-from-a-file new file mode 120000 index 0000000000..a85d122fd9 --- /dev/null +++ b/Lang/Tcl/Remove-lines-from-a-file @@ -0,0 +1 @@ +../../Task/Remove-lines-from-a-file/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Rename-a-file b/Lang/Tcl/Rename-a-file new file mode 120000 index 0000000000..bb41e78bdd --- /dev/null +++ b/Lang/Tcl/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Rendezvous b/Lang/Tcl/Rendezvous new file mode 120000 index 0000000000..73d6bdebb3 --- /dev/null +++ b/Lang/Tcl/Rendezvous @@ -0,0 +1 @@ +../../Task/Rendezvous/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Repeat-a-string b/Lang/Tcl/Repeat-a-string new file mode 120000 index 0000000000..153d08b98c --- /dev/null +++ b/Lang/Tcl/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Resistor-mesh b/Lang/Tcl/Resistor-mesh new file mode 120000 index 0000000000..6cf1b7265b --- /dev/null +++ b/Lang/Tcl/Resistor-mesh @@ -0,0 +1 @@ +../../Task/Resistor-mesh/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Respond-to-an-unknown-method-call b/Lang/Tcl/Respond-to-an-unknown-method-call new file mode 120000 index 0000000000..2b885a9acc --- /dev/null +++ b/Lang/Tcl/Respond-to-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Respond-to-an-unknown-method-call/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Return-multiple-values b/Lang/Tcl/Return-multiple-values new file mode 120000 index 0000000000..ce7b683083 --- /dev/null +++ b/Lang/Tcl/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Reverse-a-string b/Lang/Tcl/Reverse-a-string new file mode 120000 index 0000000000..7a813a0a23 --- /dev/null +++ b/Lang/Tcl/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Rock-paper-scissors b/Lang/Tcl/Rock-paper-scissors new file mode 120000 index 0000000000..46bd29855f --- /dev/null +++ b/Lang/Tcl/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Roman-numerals-Decode b/Lang/Tcl/Roman-numerals-Decode new file mode 120000 index 0000000000..a5b221aadf --- /dev/null +++ b/Lang/Tcl/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Roman-numerals-Encode b/Lang/Tcl/Roman-numerals-Encode new file mode 120000 index 0000000000..f6021c5282 --- /dev/null +++ b/Lang/Tcl/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Roots-of-a-function b/Lang/Tcl/Roots-of-a-function new file mode 120000 index 0000000000..43a501d7eb --- /dev/null +++ b/Lang/Tcl/Roots-of-a-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-function/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Roots-of-a-quadratic-function b/Lang/Tcl/Roots-of-a-quadratic-function new file mode 120000 index 0000000000..23a1b498b4 --- /dev/null +++ b/Lang/Tcl/Roots-of-a-quadratic-function @@ -0,0 +1 @@ +../../Task/Roots-of-a-quadratic-function/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Roots-of-unity b/Lang/Tcl/Roots-of-unity new file mode 120000 index 0000000000..49fcb06620 --- /dev/null +++ b/Lang/Tcl/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Rosetta-Code-Count-examples b/Lang/Tcl/Rosetta-Code-Count-examples new file mode 120000 index 0000000000..36cc31efcb --- /dev/null +++ b/Lang/Tcl/Rosetta-Code-Count-examples @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Count-examples/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Rosetta-Code-Find-unimplemented-tasks b/Lang/Tcl/Rosetta-Code-Find-unimplemented-tasks new file mode 120000 index 0000000000..22fbcdfd56 --- /dev/null +++ b/Lang/Tcl/Rosetta-Code-Find-unimplemented-tasks @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Find-unimplemented-tasks/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Rosetta-Code-Fix-code-tags b/Lang/Tcl/Rosetta-Code-Fix-code-tags new file mode 120000 index 0000000000..6ad7902ad5 --- /dev/null +++ b/Lang/Tcl/Rosetta-Code-Fix-code-tags @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Fix-code-tags/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Rosetta-Code-Rank-languages-by-popularity b/Lang/Tcl/Rosetta-Code-Rank-languages-by-popularity new file mode 120000 index 0000000000..134eb7c0c3 --- /dev/null +++ b/Lang/Tcl/Rosetta-Code-Rank-languages-by-popularity @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-popularity/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Rot-13 b/Lang/Tcl/Rot-13 new file mode 120000 index 0000000000..0d082ea236 --- /dev/null +++ b/Lang/Tcl/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Run-length-encoding b/Lang/Tcl/Run-length-encoding new file mode 120000 index 0000000000..a7c97ce368 --- /dev/null +++ b/Lang/Tcl/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Runtime-evaluation b/Lang/Tcl/Runtime-evaluation new file mode 120000 index 0000000000..f70bc28f18 --- /dev/null +++ b/Lang/Tcl/Runtime-evaluation @@ -0,0 +1 @@ +../../Task/Runtime-evaluation/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Runtime-evaluation-In-an-environment b/Lang/Tcl/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..1a4eb5fc24 --- /dev/null +++ b/Lang/Tcl/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/Tcl \ No newline at end of file diff --git a/Lang/Tcl/S-Expressions b/Lang/Tcl/S-Expressions new file mode 120000 index 0000000000..91c2c4de88 --- /dev/null +++ b/Lang/Tcl/S-Expressions @@ -0,0 +1 @@ +../../Task/S-Expressions/Tcl \ No newline at end of file diff --git a/Lang/Tcl/SEDOLs b/Lang/Tcl/SEDOLs new file mode 120000 index 0000000000..1748a2068b --- /dev/null +++ b/Lang/Tcl/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Safe-addition b/Lang/Tcl/Safe-addition new file mode 120000 index 0000000000..40502fad23 --- /dev/null +++ b/Lang/Tcl/Safe-addition @@ -0,0 +1 @@ +../../Task/Safe-addition/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Same-Fringe b/Lang/Tcl/Same-Fringe new file mode 120000 index 0000000000..4e326e4862 --- /dev/null +++ b/Lang/Tcl/Same-Fringe @@ -0,0 +1 @@ +../../Task/Same-Fringe/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Scope-Function-names-and-labels b/Lang/Tcl/Scope-Function-names-and-labels new file mode 120000 index 0000000000..f7f6628ef8 --- /dev/null +++ b/Lang/Tcl/Scope-Function-names-and-labels @@ -0,0 +1 @@ +../../Task/Scope-Function-names-and-labels/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Scope-modifiers b/Lang/Tcl/Scope-modifiers new file mode 120000 index 0000000000..ba475f55ed --- /dev/null +++ b/Lang/Tcl/Scope-modifiers @@ -0,0 +1 @@ +../../Task/Scope-modifiers/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Secure-temporary-file b/Lang/Tcl/Secure-temporary-file new file mode 120000 index 0000000000..0cae3c8896 --- /dev/null +++ b/Lang/Tcl/Secure-temporary-file @@ -0,0 +1 @@ +../../Task/Secure-temporary-file/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Self-describing-numbers b/Lang/Tcl/Self-describing-numbers new file mode 120000 index 0000000000..4c7b15f498 --- /dev/null +++ b/Lang/Tcl/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Self-referential-sequence b/Lang/Tcl/Self-referential-sequence new file mode 120000 index 0000000000..d2739746df --- /dev/null +++ b/Lang/Tcl/Self-referential-sequence @@ -0,0 +1 @@ +../../Task/Self-referential-sequence/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Semordnilap b/Lang/Tcl/Semordnilap new file mode 120000 index 0000000000..4fa36fd270 --- /dev/null +++ b/Lang/Tcl/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Send-an-unknown-method-call b/Lang/Tcl/Send-an-unknown-method-call new file mode 120000 index 0000000000..955c83ede2 --- /dev/null +++ b/Lang/Tcl/Send-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Send-an-unknown-method-call/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Send-email b/Lang/Tcl/Send-email new file mode 120000 index 0000000000..c27a14be91 --- /dev/null +++ b/Lang/Tcl/Send-email @@ -0,0 +1 @@ +../../Task/Send-email/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Sequence-of-non-squares b/Lang/Tcl/Sequence-of-non-squares new file mode 120000 index 0000000000..20f0f44aa0 --- /dev/null +++ b/Lang/Tcl/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Set b/Lang/Tcl/Set new file mode 120000 index 0000000000..5d8848b523 --- /dev/null +++ b/Lang/Tcl/Set @@ -0,0 +1 @@ +../../Task/Set/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Set-consolidation b/Lang/Tcl/Set-consolidation new file mode 120000 index 0000000000..6c28cc9ffe --- /dev/null +++ b/Lang/Tcl/Set-consolidation @@ -0,0 +1 @@ +../../Task/Set-consolidation/Tcl \ No newline at end of file diff --git a/Lang/Tcl/Set-of-real-numbers b/Lang/Tcl/Set-of-real-numbers new file mode 120000 index 0000000000..6bb17173ce --- /dev/null +++ b/Lang/Tcl/Set-of-real-numbers @@ -0,0 +1 @@ +../../Task/Set-of-real-numbers/Tcl \ No newline at end of file diff --git a/Lang/Toka/Copy-a-string b/Lang/Toka/Copy-a-string new file mode 120000 index 0000000000..1563ce7b42 --- /dev/null +++ b/Lang/Toka/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Toka \ No newline at end of file diff --git a/Lang/Toka/Regular-expressions b/Lang/Toka/Regular-expressions new file mode 120000 index 0000000000..b6ac1ae1ba --- /dev/null +++ b/Lang/Toka/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Toka \ No newline at end of file diff --git a/Lang/Toka/Rename-a-file b/Lang/Toka/Rename-a-file new file mode 120000 index 0000000000..363cc9a2af --- /dev/null +++ b/Lang/Toka/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Toka \ No newline at end of file diff --git a/Lang/TorqueScript/Read-a-file-line-by-line b/Lang/TorqueScript/Read-a-file-line-by-line new file mode 120000 index 0000000000..bf4be89cdb --- /dev/null +++ b/Lang/TorqueScript/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/TorqueScript \ No newline at end of file diff --git a/Lang/TorqueScript/Rename-a-file b/Lang/TorqueScript/Rename-a-file new file mode 120000 index 0000000000..604980c6d9 --- /dev/null +++ b/Lang/TorqueScript/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/TorqueScript \ No newline at end of file diff --git a/Lang/TorqueScript/Repeat-a-string b/Lang/TorqueScript/Repeat-a-string new file mode 120000 index 0000000000..515b60f89d --- /dev/null +++ b/Lang/TorqueScript/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/TorqueScript \ No newline at end of file diff --git a/Lang/TorqueScript/Rock-paper-scissors b/Lang/TorqueScript/Rock-paper-scissors new file mode 120000 index 0000000000..755fd75d2b --- /dev/null +++ b/Lang/TorqueScript/Rock-paper-scissors @@ -0,0 +1 @@ +../../Task/Rock-paper-scissors/TorqueScript \ No newline at end of file diff --git a/Lang/TorqueScript/Rot-13 b/Lang/TorqueScript/Rot-13 new file mode 120000 index 0000000000..f6cffbe59e --- /dev/null +++ b/Lang/TorqueScript/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/TorqueScript \ No newline at end of file diff --git a/Lang/Trith/Copy-a-string b/Lang/Trith/Copy-a-string new file mode 120000 index 0000000000..f36434fb31 --- /dev/null +++ b/Lang/Trith/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Trith \ No newline at end of file diff --git a/Lang/Turing/Pascals-triangle b/Lang/Turing/Pascals-triangle new file mode 120000 index 0000000000..8196f8b644 --- /dev/null +++ b/Lang/Turing/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Turing \ No newline at end of file diff --git a/Lang/Turing/Reverse-a-string b/Lang/Turing/Reverse-a-string new file mode 120000 index 0000000000..193b20b31f --- /dev/null +++ b/Lang/Turing/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Turing \ No newline at end of file diff --git a/Lang/UNIX-Shell/Binary-digits b/Lang/UNIX-Shell/Binary-digits new file mode 120000 index 0000000000..fa982845b7 --- /dev/null +++ b/Lang/UNIX-Shell/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/UNIX-Shell \ No newline at end of file diff --git a/Lang/UNIX-Shell/Copy-a-string b/Lang/UNIX-Shell/Copy-a-string new file mode 120000 index 0000000000..632c6e82ec --- /dev/null +++ b/Lang/UNIX-Shell/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/UNIX-Shell \ No newline at end of file diff --git a/Lang/UNIX-Shell/Environment-variables b/Lang/UNIX-Shell/Environment-variables new file mode 120000 index 0000000000..8ab4853507 --- /dev/null +++ b/Lang/UNIX-Shell/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/UNIX-Shell \ No newline at end of file diff --git a/Lang/UNIX-Shell/Number-reversal-game b/Lang/UNIX-Shell/Number-reversal-game new file mode 120000 index 0000000000..1846122329 --- /dev/null +++ b/Lang/UNIX-Shell/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/UNIX-Shell \ No newline at end of file diff --git a/Lang/UNIX-Shell/Pangram-checker b/Lang/UNIX-Shell/Pangram-checker new file mode 120000 index 0000000000..74fbe0ce15 --- /dev/null +++ b/Lang/UNIX-Shell/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/UNIX-Shell \ No newline at end of file diff --git a/Lang/UNIX-Shell/Play-recorded-sounds b/Lang/UNIX-Shell/Play-recorded-sounds new file mode 120000 index 0000000000..7e77ed96d6 --- /dev/null +++ b/Lang/UNIX-Shell/Play-recorded-sounds @@ -0,0 +1 @@ +../../Task/Play-recorded-sounds/UNIX-Shell \ No newline at end of file diff --git a/Lang/UNIX-Shell/Power-set b/Lang/UNIX-Shell/Power-set new file mode 120000 index 0000000000..ed0288ceb6 --- /dev/null +++ b/Lang/UNIX-Shell/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/UNIX-Shell \ No newline at end of file diff --git a/Lang/UNIX-Shell/Pragmatic-directives b/Lang/UNIX-Shell/Pragmatic-directives new file mode 120000 index 0000000000..44eb65a34c --- /dev/null +++ b/Lang/UNIX-Shell/Pragmatic-directives @@ -0,0 +1 @@ +../../Task/Pragmatic-directives/UNIX-Shell \ No newline at end of file diff --git a/Lang/UNIX-Shell/Primality-by-trial-division b/Lang/UNIX-Shell/Primality-by-trial-division new file mode 120000 index 0000000000..94a4e67fdb --- /dev/null +++ b/Lang/UNIX-Shell/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/UNIX-Shell \ No newline at end of file diff --git a/Lang/UNIX-Shell/Program-name b/Lang/UNIX-Shell/Program-name new file mode 120000 index 0000000000..813d1c8d0c --- /dev/null +++ b/Lang/UNIX-Shell/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/UNIX-Shell \ No newline at end of file diff --git a/Lang/UNIX-Shell/Program-termination b/Lang/UNIX-Shell/Program-termination new file mode 120000 index 0000000000..607831ad2b --- /dev/null +++ b/Lang/UNIX-Shell/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/UNIX-Shell \ No newline at end of file diff --git a/Lang/UNIX-Shell/Random-number-generator--included- b/Lang/UNIX-Shell/Random-number-generator--included- new file mode 120000 index 0000000000..b19f9a8dc6 --- /dev/null +++ b/Lang/UNIX-Shell/Random-number-generator--included- @@ -0,0 +1 @@ +../../Task/Random-number-generator--included-/UNIX-Shell \ No newline at end of file diff --git a/Lang/UNIX-Shell/Rate-counter b/Lang/UNIX-Shell/Rate-counter new file mode 120000 index 0000000000..325fa70842 --- /dev/null +++ b/Lang/UNIX-Shell/Rate-counter @@ -0,0 +1 @@ +../../Task/Rate-counter/UNIX-Shell \ No newline at end of file diff --git a/Lang/UNIX-Shell/Read-a-file-line-by-line b/Lang/UNIX-Shell/Read-a-file-line-by-line new file mode 120000 index 0000000000..2f7cb55f74 --- /dev/null +++ b/Lang/UNIX-Shell/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/UNIX-Shell \ No newline at end of file diff --git a/Lang/UNIX-Shell/Read-entire-file b/Lang/UNIX-Shell/Read-entire-file new file mode 120000 index 0000000000..4d5380d321 --- /dev/null +++ b/Lang/UNIX-Shell/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/UNIX-Shell \ No newline at end of file diff --git a/Lang/UNIX-Shell/Remove-lines-from-a-file b/Lang/UNIX-Shell/Remove-lines-from-a-file new file mode 120000 index 0000000000..c78faa9388 --- /dev/null +++ b/Lang/UNIX-Shell/Remove-lines-from-a-file @@ -0,0 +1 @@ +../../Task/Remove-lines-from-a-file/UNIX-Shell \ No newline at end of file diff --git a/Lang/UNIX-Shell/Rename-a-file b/Lang/UNIX-Shell/Rename-a-file new file mode 120000 index 0000000000..9ca4d0c9a0 --- /dev/null +++ b/Lang/UNIX-Shell/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/UNIX-Shell \ No newline at end of file diff --git a/Lang/UNIX-Shell/Repeat-a-string b/Lang/UNIX-Shell/Repeat-a-string new file mode 120000 index 0000000000..48d53cda52 --- /dev/null +++ b/Lang/UNIX-Shell/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/UNIX-Shell \ No newline at end of file diff --git a/Lang/UNIX-Shell/Respond-to-an-unknown-method-call b/Lang/UNIX-Shell/Respond-to-an-unknown-method-call new file mode 120000 index 0000000000..264fc1f60b --- /dev/null +++ b/Lang/UNIX-Shell/Respond-to-an-unknown-method-call @@ -0,0 +1 @@ +../../Task/Respond-to-an-unknown-method-call/UNIX-Shell \ No newline at end of file diff --git a/Lang/UNIX-Shell/Return-multiple-values b/Lang/UNIX-Shell/Return-multiple-values new file mode 120000 index 0000000000..089dac996a --- /dev/null +++ b/Lang/UNIX-Shell/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/UNIX-Shell \ No newline at end of file diff --git a/Lang/UNIX-Shell/Rot-13 b/Lang/UNIX-Shell/Rot-13 new file mode 120000 index 0000000000..49b3e302fe --- /dev/null +++ b/Lang/UNIX-Shell/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/UNIX-Shell \ No newline at end of file diff --git a/Lang/UNIX-Shell/Runtime-evaluation-In-an-environment b/Lang/UNIX-Shell/Runtime-evaluation-In-an-environment new file mode 120000 index 0000000000..492affc430 --- /dev/null +++ b/Lang/UNIX-Shell/Runtime-evaluation-In-an-environment @@ -0,0 +1 @@ +../../Task/Runtime-evaluation-In-an-environment/UNIX-Shell \ No newline at end of file diff --git a/Lang/UNIX-Shell/Scope-Function-names-and-labels b/Lang/UNIX-Shell/Scope-Function-names-and-labels new file mode 120000 index 0000000000..1189c47457 --- /dev/null +++ b/Lang/UNIX-Shell/Scope-Function-names-and-labels @@ -0,0 +1 @@ +../../Task/Scope-Function-names-and-labels/UNIX-Shell \ No newline at end of file diff --git a/Lang/UNIX-Shell/Secure-temporary-file b/Lang/UNIX-Shell/Secure-temporary-file new file mode 120000 index 0000000000..d6526c41a5 --- /dev/null +++ b/Lang/UNIX-Shell/Secure-temporary-file @@ -0,0 +1 @@ +../../Task/Secure-temporary-file/UNIX-Shell \ No newline at end of file diff --git a/Lang/UnixPipes/Power-set b/Lang/UnixPipes/Power-set new file mode 120000 index 0000000000..d3bbc3076e --- /dev/null +++ b/Lang/UnixPipes/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/UnixPipes \ No newline at end of file diff --git a/Lang/UnixPipes/Queue-Definition b/Lang/UnixPipes/Queue-Definition new file mode 120000 index 0000000000..af3cacc7d9 --- /dev/null +++ b/Lang/UnixPipes/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/UnixPipes \ No newline at end of file diff --git a/Lang/UnixPipes/Remove-duplicate-elements b/Lang/UnixPipes/Remove-duplicate-elements new file mode 120000 index 0000000000..f5330a1cc3 --- /dev/null +++ b/Lang/UnixPipes/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/UnixPipes \ No newline at end of file diff --git a/Lang/UnixPipes/Rosetta-Code-Rank-languages-by-popularity b/Lang/UnixPipes/Rosetta-Code-Rank-languages-by-popularity new file mode 120000 index 0000000000..dd8942e0ea --- /dev/null +++ b/Lang/UnixPipes/Rosetta-Code-Rank-languages-by-popularity @@ -0,0 +1 @@ +../../Task/Rosetta-Code-Rank-languages-by-popularity/UnixPipes \ No newline at end of file diff --git a/Lang/Unlambda/Program-termination b/Lang/Unlambda/Program-termination new file mode 120000 index 0000000000..9e137c15b3 --- /dev/null +++ b/Lang/Unlambda/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Unlambda \ No newline at end of file diff --git a/Lang/Unlambda/Reverse-a-string b/Lang/Unlambda/Reverse-a-string new file mode 120000 index 0000000000..f33df7d387 --- /dev/null +++ b/Lang/Unlambda/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Unlambda \ No newline at end of file diff --git a/Lang/Unlambda/Rot-13 b/Lang/Unlambda/Rot-13 new file mode 120000 index 0000000000..1209b366cf --- /dev/null +++ b/Lang/Unlambda/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Unlambda \ No newline at end of file diff --git a/Lang/Ursala/Arbitrary-precision-integers--included- b/Lang/Ursala/Arbitrary-precision-integers--included- new file mode 120000 index 0000000000..269a2dbe33 --- /dev/null +++ b/Lang/Ursala/Arbitrary-precision-integers--included- @@ -0,0 +1 @@ +../../Task/Arbitrary-precision-integers--included-/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Arbitrary-precision-integers-included b/Lang/Ursala/Arbitrary-precision-integers-included deleted file mode 120000 index 2b3fab76dd..0000000000 --- a/Lang/Ursala/Arbitrary-precision-integers-included +++ /dev/null @@ -1 +0,0 @@ -../../Task/Arbitrary-precision-integers-included/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Catalan-numbers b/Lang/Ursala/Catalan-numbers new file mode 120000 index 0000000000..1239a98c33 --- /dev/null +++ b/Lang/Ursala/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Environment-variables b/Lang/Ursala/Environment-variables new file mode 120000 index 0000000000..0c4151a4f6 --- /dev/null +++ b/Lang/Ursala/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Ursala \ No newline at end of file diff --git a/Lang/Ursala/N-queens-problem b/Lang/Ursala/N-queens-problem new file mode 120000 index 0000000000..1c2201d121 --- /dev/null +++ b/Lang/Ursala/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Non-continuous-subsequences b/Lang/Ursala/Non-continuous-subsequences new file mode 120000 index 0000000000..8a96e6a117 --- /dev/null +++ b/Lang/Ursala/Non-continuous-subsequences @@ -0,0 +1 @@ +../../Task/Non-continuous-subsequences/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Non-decimal-radices-Convert b/Lang/Ursala/Non-decimal-radices-Convert new file mode 120000 index 0000000000..da9ba2e191 --- /dev/null +++ b/Lang/Ursala/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Nth-root b/Lang/Ursala/Nth-root new file mode 120000 index 0000000000..717fce9c08 --- /dev/null +++ b/Lang/Ursala/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Numerical-integration b/Lang/Ursala/Numerical-integration new file mode 120000 index 0000000000..19937bc066 --- /dev/null +++ b/Lang/Ursala/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Numerical-integration-Gauss-Legendre-Quadrature b/Lang/Ursala/Numerical-integration-Gauss-Legendre-Quadrature new file mode 120000 index 0000000000..7eed9dbd11 --- /dev/null +++ b/Lang/Ursala/Numerical-integration-Gauss-Legendre-Quadrature @@ -0,0 +1 @@ +../../Task/Numerical-integration-Gauss-Legendre-Quadrature/Ursala \ No newline at end of file diff --git a/Lang/Ursala/One-dimensional-cellular-automata b/Lang/Ursala/One-dimensional-cellular-automata new file mode 120000 index 0000000000..1d4b559166 --- /dev/null +++ b/Lang/Ursala/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Optional-parameters b/Lang/Ursala/Optional-parameters new file mode 120000 index 0000000000..be0dea530a --- /dev/null +++ b/Lang/Ursala/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Ordered-Partitions b/Lang/Ursala/Ordered-Partitions new file mode 120000 index 0000000000..eb9fce793a --- /dev/null +++ b/Lang/Ursala/Ordered-Partitions @@ -0,0 +1 @@ +../../Task/Ordered-Partitions/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Palindrome-detection b/Lang/Ursala/Palindrome-detection new file mode 120000 index 0000000000..4d1c3cc274 --- /dev/null +++ b/Lang/Ursala/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Pangram-checker b/Lang/Ursala/Pangram-checker new file mode 120000 index 0000000000..49b66667a2 --- /dev/null +++ b/Lang/Ursala/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Parametric-polymorphism b/Lang/Ursala/Parametric-polymorphism new file mode 120000 index 0000000000..1301d9a7c0 --- /dev/null +++ b/Lang/Ursala/Parametric-polymorphism @@ -0,0 +1 @@ +../../Task/Parametric-polymorphism/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Pascals-triangle b/Lang/Ursala/Pascals-triangle new file mode 120000 index 0000000000..f96fb76485 --- /dev/null +++ b/Lang/Ursala/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Perfect-numbers b/Lang/Ursala/Perfect-numbers new file mode 120000 index 0000000000..0ecd25e18e --- /dev/null +++ b/Lang/Ursala/Perfect-numbers @@ -0,0 +1 @@ +../../Task/Perfect-numbers/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Permutation-test b/Lang/Ursala/Permutation-test new file mode 120000 index 0000000000..6eb1908c2f --- /dev/null +++ b/Lang/Ursala/Permutation-test @@ -0,0 +1 @@ +../../Task/Permutation-test/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Permutations b/Lang/Ursala/Permutations new file mode 120000 index 0000000000..22ab1e5484 --- /dev/null +++ b/Lang/Ursala/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Plot-coordinate-pairs b/Lang/Ursala/Plot-coordinate-pairs new file mode 120000 index 0000000000..4902a1d9b0 --- /dev/null +++ b/Lang/Ursala/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Polynomial-long-division b/Lang/Ursala/Polynomial-long-division new file mode 120000 index 0000000000..7df2a84924 --- /dev/null +++ b/Lang/Ursala/Polynomial-long-division @@ -0,0 +1 @@ +../../Task/Polynomial-long-division/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Polynomial-regression b/Lang/Ursala/Polynomial-regression new file mode 120000 index 0000000000..dfd363f94a --- /dev/null +++ b/Lang/Ursala/Polynomial-regression @@ -0,0 +1 @@ +../../Task/Polynomial-regression/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Power-set b/Lang/Ursala/Power-set new file mode 120000 index 0000000000..ca20002bbe --- /dev/null +++ b/Lang/Ursala/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Price-fraction b/Lang/Ursala/Price-fraction new file mode 120000 index 0000000000..1241b6c57c --- /dev/null +++ b/Lang/Ursala/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Primality-by-trial-division b/Lang/Ursala/Primality-by-trial-division new file mode 120000 index 0000000000..19ef016a3e --- /dev/null +++ b/Lang/Ursala/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Probabilistic-choice b/Lang/Ursala/Probabilistic-choice new file mode 120000 index 0000000000..b672f32d16 --- /dev/null +++ b/Lang/Ursala/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Random-numbers b/Lang/Ursala/Random-numbers new file mode 120000 index 0000000000..df20e0b664 --- /dev/null +++ b/Lang/Ursala/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Range-expansion b/Lang/Ursala/Range-expansion new file mode 120000 index 0000000000..a33c4735db --- /dev/null +++ b/Lang/Ursala/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Range-extraction b/Lang/Ursala/Range-extraction new file mode 120000 index 0000000000..d3abdab16b --- /dev/null +++ b/Lang/Ursala/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Ray-casting-algorithm b/Lang/Ursala/Ray-casting-algorithm new file mode 120000 index 0000000000..5a067d2db0 --- /dev/null +++ b/Lang/Ursala/Ray-casting-algorithm @@ -0,0 +1 @@ +../../Task/Ray-casting-algorithm/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Reduced-row-echelon-form b/Lang/Ursala/Reduced-row-echelon-form new file mode 120000 index 0000000000..0ecea087bc --- /dev/null +++ b/Lang/Ursala/Reduced-row-echelon-form @@ -0,0 +1 @@ +../../Task/Reduced-row-echelon-form/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Remove-duplicate-elements b/Lang/Ursala/Remove-duplicate-elements new file mode 120000 index 0000000000..497b4565e5 --- /dev/null +++ b/Lang/Ursala/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Repeat-a-string b/Lang/Ursala/Repeat-a-string new file mode 120000 index 0000000000..f3a57ab751 --- /dev/null +++ b/Lang/Ursala/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Reverse-a-string b/Lang/Ursala/Reverse-a-string new file mode 120000 index 0000000000..0826f7c2b6 --- /dev/null +++ b/Lang/Ursala/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Roman-numerals-Encode b/Lang/Ursala/Roman-numerals-Encode new file mode 120000 index 0000000000..afb2f7510a --- /dev/null +++ b/Lang/Ursala/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Roots-of-unity b/Lang/Ursala/Roots-of-unity new file mode 120000 index 0000000000..79e3ccd131 --- /dev/null +++ b/Lang/Ursala/Roots-of-unity @@ -0,0 +1 @@ +../../Task/Roots-of-unity/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Rot-13 b/Lang/Ursala/Rot-13 new file mode 120000 index 0000000000..bde64176ff --- /dev/null +++ b/Lang/Ursala/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Run-length-encoding b/Lang/Ursala/Run-length-encoding new file mode 120000 index 0000000000..cc14c0e422 --- /dev/null +++ b/Lang/Ursala/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Ursala \ No newline at end of file diff --git a/Lang/Ursala/SEDOLs b/Lang/Ursala/SEDOLs new file mode 120000 index 0000000000..3be8c6a57b --- /dev/null +++ b/Lang/Ursala/SEDOLs @@ -0,0 +1 @@ +../../Task/SEDOLs/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Scope-modifiers b/Lang/Ursala/Scope-modifiers new file mode 120000 index 0000000000..b0403ac589 --- /dev/null +++ b/Lang/Ursala/Scope-modifiers @@ -0,0 +1 @@ +../../Task/Scope-modifiers/Ursala \ No newline at end of file diff --git a/Lang/Ursala/Sequence-of-non-squares b/Lang/Ursala/Sequence-of-non-squares new file mode 120000 index 0000000000..ec8d3d95e9 --- /dev/null +++ b/Lang/Ursala/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/Ursala \ No newline at end of file diff --git a/Lang/V/Copy-a-string b/Lang/V/Copy-a-string new file mode 120000 index 0000000000..777e7d9085 --- /dev/null +++ b/Lang/V/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/V \ No newline at end of file diff --git a/Lang/V/Power-set b/Lang/V/Power-set new file mode 120000 index 0000000000..d5d72f3aa2 --- /dev/null +++ b/Lang/V/Power-set @@ -0,0 +1 @@ +../../Task/Power-set/V \ No newline at end of file diff --git a/Lang/V/Primality-by-trial-division b/Lang/V/Primality-by-trial-division new file mode 120000 index 0000000000..1dfc2c12fa --- /dev/null +++ b/Lang/V/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/V \ No newline at end of file diff --git a/Lang/V/Prime-decomposition b/Lang/V/Prime-decomposition new file mode 120000 index 0000000000..7678e03599 --- /dev/null +++ b/Lang/V/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/V \ No newline at end of file diff --git a/Lang/V/Queue-Definition b/Lang/V/Queue-Definition new file mode 120000 index 0000000000..658d6d6e3f --- /dev/null +++ b/Lang/V/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/V \ No newline at end of file diff --git a/Lang/VBA/Catalan-numbers b/Lang/VBA/Catalan-numbers new file mode 120000 index 0000000000..ecfd54bc2c --- /dev/null +++ b/Lang/VBA/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/VBA \ No newline at end of file diff --git a/Lang/VBA/Palindrome-detection b/Lang/VBA/Palindrome-detection new file mode 120000 index 0000000000..b07645ff9d --- /dev/null +++ b/Lang/VBA/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/VBA \ No newline at end of file diff --git a/Lang/VBA/Pangram-checker b/Lang/VBA/Pangram-checker new file mode 120000 index 0000000000..bc8d8f1fcd --- /dev/null +++ b/Lang/VBA/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/VBA \ No newline at end of file diff --git a/Lang/VBA/Permutations b/Lang/VBA/Permutations new file mode 120000 index 0000000000..d5e27404d3 --- /dev/null +++ b/Lang/VBA/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/VBA \ No newline at end of file diff --git a/Lang/VBA/Play-recorded-sounds b/Lang/VBA/Play-recorded-sounds new file mode 120000 index 0000000000..479278905c --- /dev/null +++ b/Lang/VBA/Play-recorded-sounds @@ -0,0 +1 @@ +../../Task/Play-recorded-sounds/VBA \ No newline at end of file diff --git a/Lang/VBA/Program-name b/Lang/VBA/Program-name new file mode 120000 index 0000000000..8020d0334c --- /dev/null +++ b/Lang/VBA/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/VBA \ No newline at end of file diff --git a/Lang/VBA/Range-expansion b/Lang/VBA/Range-expansion new file mode 120000 index 0000000000..f23d23a64a --- /dev/null +++ b/Lang/VBA/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/VBA \ No newline at end of file diff --git a/Lang/VBA/Range-extraction b/Lang/VBA/Range-extraction new file mode 120000 index 0000000000..a084392630 --- /dev/null +++ b/Lang/VBA/Range-extraction @@ -0,0 +1 @@ +../../Task/Range-extraction/VBA \ No newline at end of file diff --git a/Lang/VBA/Repeat-a-string b/Lang/VBA/Repeat-a-string new file mode 120000 index 0000000000..352f9e0325 --- /dev/null +++ b/Lang/VBA/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/VBA \ No newline at end of file diff --git a/Lang/VBA/Reverse-a-string b/Lang/VBA/Reverse-a-string new file mode 120000 index 0000000000..b8a340410c --- /dev/null +++ b/Lang/VBA/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/VBA \ No newline at end of file diff --git a/Lang/VBScript/Execute-a-Markov-algorithm b/Lang/VBScript/Execute-a-Markov-algorithm new file mode 120000 index 0000000000..1ffd672ea0 --- /dev/null +++ b/Lang/VBScript/Execute-a-Markov-algorithm @@ -0,0 +1 @@ +../../Task/Execute-a-Markov-algorithm/VBScript \ No newline at end of file diff --git a/Lang/VBScript/Palindrome-detection b/Lang/VBScript/Palindrome-detection new file mode 120000 index 0000000000..7994674010 --- /dev/null +++ b/Lang/VBScript/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/VBScript \ No newline at end of file diff --git a/Lang/VBScript/Pangram-checker b/Lang/VBScript/Pangram-checker new file mode 120000 index 0000000000..410fe2a0cb --- /dev/null +++ b/Lang/VBScript/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/VBScript \ No newline at end of file diff --git a/Lang/VBScript/Playing-cards b/Lang/VBScript/Playing-cards new file mode 120000 index 0000000000..f5c16fde6e --- /dev/null +++ b/Lang/VBScript/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/VBScript \ No newline at end of file diff --git a/Lang/VBScript/Program-termination b/Lang/VBScript/Program-termination new file mode 120000 index 0000000000..bb8f9b7921 --- /dev/null +++ b/Lang/VBScript/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/VBScript \ No newline at end of file diff --git a/Lang/VBScript/Read-entire-file b/Lang/VBScript/Read-entire-file new file mode 120000 index 0000000000..6796d59d21 --- /dev/null +++ b/Lang/VBScript/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/VBScript \ No newline at end of file diff --git a/Lang/Vala/Program-name b/Lang/Vala/Program-name new file mode 120000 index 0000000000..f65e38a11b --- /dev/null +++ b/Lang/Vala/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Vala \ No newline at end of file diff --git a/Lang/Vala/Read-a-file-line-by-line b/Lang/Vala/Read-a-file-line-by-line new file mode 120000 index 0000000000..c3c66ae226 --- /dev/null +++ b/Lang/Vala/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Vala \ No newline at end of file diff --git a/Lang/Vala/Read-entire-file b/Lang/Vala/Read-entire-file new file mode 120000 index 0000000000..a089f2e8a4 --- /dev/null +++ b/Lang/Vala/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Vala \ No newline at end of file diff --git a/Lang/Vala/Regular-expressions b/Lang/Vala/Regular-expressions new file mode 120000 index 0000000000..6d1fe0e61f --- /dev/null +++ b/Lang/Vala/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Vala \ No newline at end of file diff --git a/Lang/Vala/Repeat-a-string b/Lang/Vala/Repeat-a-string new file mode 120000 index 0000000000..45223309cd --- /dev/null +++ b/Lang/Vala/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Vala \ No newline at end of file diff --git a/Lang/Vedit-macro-language/Binary-digits b/Lang/Vedit-macro-language/Binary-digits new file mode 120000 index 0000000000..6e618a103f --- /dev/null +++ b/Lang/Vedit-macro-language/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Vedit-macro-language \ No newline at end of file diff --git a/Lang/Vedit-macro-language/Calendar---for-real-programmers b/Lang/Vedit-macro-language/Calendar---for-real-programmers new file mode 120000 index 0000000000..5e7c6a018c --- /dev/null +++ b/Lang/Vedit-macro-language/Calendar---for-real-programmers @@ -0,0 +1 @@ +../../Task/Calendar---for-real-programmers/Vedit-macro-language \ No newline at end of file diff --git a/Lang/Vedit-macro-language/Calendar-for-real-programmers b/Lang/Vedit-macro-language/Calendar-for-real-programmers deleted file mode 120000 index 2ae35a116f..0000000000 --- a/Lang/Vedit-macro-language/Calendar-for-real-programmers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Calendar-for-real-programmers/Vedit-macro-language \ No newline at end of file diff --git a/Lang/Vedit-macro-language/Dragon-curve b/Lang/Vedit-macro-language/Dragon-curve new file mode 120000 index 0000000000..61f89964ff --- /dev/null +++ b/Lang/Vedit-macro-language/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/Vedit-macro-language \ No newline at end of file diff --git a/Lang/Vedit-macro-language/Environment-variables b/Lang/Vedit-macro-language/Environment-variables new file mode 120000 index 0000000000..73c2f758dd --- /dev/null +++ b/Lang/Vedit-macro-language/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/Vedit-macro-language \ No newline at end of file diff --git a/Lang/Vedit-macro-language/One-dimensional-cellular-automata b/Lang/Vedit-macro-language/One-dimensional-cellular-automata new file mode 120000 index 0000000000..bc9914d01f --- /dev/null +++ b/Lang/Vedit-macro-language/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Vedit-macro-language \ No newline at end of file diff --git a/Lang/Vedit-macro-language/Palindrome-detection b/Lang/Vedit-macro-language/Palindrome-detection new file mode 120000 index 0000000000..b7616cd323 --- /dev/null +++ b/Lang/Vedit-macro-language/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Vedit-macro-language \ No newline at end of file diff --git a/Lang/Vedit-macro-language/Pascals-triangle b/Lang/Vedit-macro-language/Pascals-triangle new file mode 120000 index 0000000000..32e91cd7b1 --- /dev/null +++ b/Lang/Vedit-macro-language/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/Vedit-macro-language \ No newline at end of file diff --git a/Lang/Vedit-macro-language/Percentage-difference-between-images b/Lang/Vedit-macro-language/Percentage-difference-between-images new file mode 120000 index 0000000000..6b12af2277 --- /dev/null +++ b/Lang/Vedit-macro-language/Percentage-difference-between-images @@ -0,0 +1 @@ +../../Task/Percentage-difference-between-images/Vedit-macro-language \ No newline at end of file diff --git a/Lang/Vedit-macro-language/Playing-cards b/Lang/Vedit-macro-language/Playing-cards new file mode 120000 index 0000000000..7bfd151a2d --- /dev/null +++ b/Lang/Vedit-macro-language/Playing-cards @@ -0,0 +1 @@ +../../Task/Playing-cards/Vedit-macro-language \ No newline at end of file diff --git a/Lang/Vedit-macro-language/Program-termination b/Lang/Vedit-macro-language/Program-termination new file mode 120000 index 0000000000..f6ea821ab9 --- /dev/null +++ b/Lang/Vedit-macro-language/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Vedit-macro-language \ No newline at end of file diff --git a/Lang/Vedit-macro-language/Read-a-configuration-file b/Lang/Vedit-macro-language/Read-a-configuration-file new file mode 120000 index 0000000000..a224201783 --- /dev/null +++ b/Lang/Vedit-macro-language/Read-a-configuration-file @@ -0,0 +1 @@ +../../Task/Read-a-configuration-file/Vedit-macro-language \ No newline at end of file diff --git a/Lang/Vedit-macro-language/Read-a-file-line-by-line b/Lang/Vedit-macro-language/Read-a-file-line-by-line new file mode 120000 index 0000000000..12e149e112 --- /dev/null +++ b/Lang/Vedit-macro-language/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Vedit-macro-language \ No newline at end of file diff --git a/Lang/Vedit-macro-language/Read-a-specific-line-from-a-file b/Lang/Vedit-macro-language/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..01c4441267 --- /dev/null +++ b/Lang/Vedit-macro-language/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/Vedit-macro-language \ No newline at end of file diff --git a/Lang/Vedit-macro-language/Read-entire-file b/Lang/Vedit-macro-language/Read-entire-file new file mode 120000 index 0000000000..b7d9cf9cdd --- /dev/null +++ b/Lang/Vedit-macro-language/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Vedit-macro-language \ No newline at end of file diff --git a/Lang/Vedit-macro-language/Regular-expressions b/Lang/Vedit-macro-language/Regular-expressions new file mode 120000 index 0000000000..e8de8d6028 --- /dev/null +++ b/Lang/Vedit-macro-language/Regular-expressions @@ -0,0 +1 @@ +../../Task/Regular-expressions/Vedit-macro-language \ No newline at end of file diff --git a/Lang/Vedit-macro-language/Remove-duplicate-elements b/Lang/Vedit-macro-language/Remove-duplicate-elements new file mode 120000 index 0000000000..730c5cc421 --- /dev/null +++ b/Lang/Vedit-macro-language/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/Vedit-macro-language \ No newline at end of file diff --git a/Lang/Vedit-macro-language/Rename-a-file b/Lang/Vedit-macro-language/Rename-a-file new file mode 120000 index 0000000000..6315cf32bf --- /dev/null +++ b/Lang/Vedit-macro-language/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Vedit-macro-language \ No newline at end of file diff --git a/Lang/Vedit-macro-language/Repeat-a-string b/Lang/Vedit-macro-language/Repeat-a-string new file mode 120000 index 0000000000..feb0c81738 --- /dev/null +++ b/Lang/Vedit-macro-language/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Vedit-macro-language \ No newline at end of file diff --git a/Lang/Vedit-macro-language/Reverse-a-string b/Lang/Vedit-macro-language/Reverse-a-string new file mode 120000 index 0000000000..e9a38d5c0c --- /dev/null +++ b/Lang/Vedit-macro-language/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Vedit-macro-language \ No newline at end of file diff --git a/Lang/Vedit-macro-language/Roman-numerals-Decode b/Lang/Vedit-macro-language/Roman-numerals-Decode new file mode 120000 index 0000000000..0e50202616 --- /dev/null +++ b/Lang/Vedit-macro-language/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/Vedit-macro-language \ No newline at end of file diff --git a/Lang/Vedit-macro-language/Roman-numerals-Encode b/Lang/Vedit-macro-language/Roman-numerals-Encode new file mode 120000 index 0000000000..8b790eca37 --- /dev/null +++ b/Lang/Vedit-macro-language/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Vedit-macro-language \ No newline at end of file diff --git a/Lang/Vedit-macro-language/Rot-13 b/Lang/Vedit-macro-language/Rot-13 new file mode 120000 index 0000000000..ec6090cbe1 --- /dev/null +++ b/Lang/Vedit-macro-language/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Vedit-macro-language \ No newline at end of file diff --git a/Lang/Vedit-macro-language/Run-length-encoding b/Lang/Vedit-macro-language/Run-length-encoding new file mode 120000 index 0000000000..0b583d8d0a --- /dev/null +++ b/Lang/Vedit-macro-language/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/Vedit-macro-language \ No newline at end of file diff --git a/Lang/Visual-Basic-.NET/Binary-digits b/Lang/Visual-Basic-.NET/Binary-digits new file mode 120000 index 0000000000..a9f30f9f25 --- /dev/null +++ b/Lang/Visual-Basic-.NET/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Visual-Basic-.NET \ No newline at end of file diff --git a/Lang/Visual-Basic-.NET/Brownian-tree b/Lang/Visual-Basic-.NET/Brownian-tree new file mode 120000 index 0000000000..70a7de7fe6 --- /dev/null +++ b/Lang/Visual-Basic-.NET/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/Visual-Basic-.NET \ No newline at end of file diff --git a/Lang/Visual-Basic-.NET/Copy-a-string b/Lang/Visual-Basic-.NET/Copy-a-string new file mode 120000 index 0000000000..a17bfd2ccf --- /dev/null +++ b/Lang/Visual-Basic-.NET/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/Visual-Basic-.NET \ No newline at end of file diff --git a/Lang/Visual-Basic-.NET/Number-names b/Lang/Visual-Basic-.NET/Number-names new file mode 120000 index 0000000000..6a23720207 --- /dev/null +++ b/Lang/Visual-Basic-.NET/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/Visual-Basic-.NET \ No newline at end of file diff --git a/Lang/Visual-Basic-.NET/One-dimensional-cellular-automata b/Lang/Visual-Basic-.NET/One-dimensional-cellular-automata new file mode 120000 index 0000000000..6db06c1c35 --- /dev/null +++ b/Lang/Visual-Basic-.NET/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/Visual-Basic-.NET \ No newline at end of file diff --git a/Lang/Visual-Basic-.NET/Read-a-file-line-by-line b/Lang/Visual-Basic-.NET/Read-a-file-line-by-line new file mode 120000 index 0000000000..e92eecb40d --- /dev/null +++ b/Lang/Visual-Basic-.NET/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Visual-Basic-.NET \ No newline at end of file diff --git a/Lang/Visual-Basic-.NET/Read-entire-file b/Lang/Visual-Basic-.NET/Read-entire-file new file mode 120000 index 0000000000..9433bc266c --- /dev/null +++ b/Lang/Visual-Basic-.NET/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Visual-Basic-.NET \ No newline at end of file diff --git a/Lang/Visual-Basic-.NET/Rename-a-file b/Lang/Visual-Basic-.NET/Rename-a-file new file mode 120000 index 0000000000..94820aae2c --- /dev/null +++ b/Lang/Visual-Basic-.NET/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Visual-Basic-.NET \ No newline at end of file diff --git a/Lang/Visual-Basic-.NET/Repeat-a-string b/Lang/Visual-Basic-.NET/Repeat-a-string new file mode 120000 index 0000000000..ef48bb5879 --- /dev/null +++ b/Lang/Visual-Basic-.NET/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Visual-Basic-.NET \ No newline at end of file diff --git a/Lang/Visual-Basic-.NET/Reverse-a-string b/Lang/Visual-Basic-.NET/Reverse-a-string new file mode 120000 index 0000000000..747221f8f4 --- /dev/null +++ b/Lang/Visual-Basic-.NET/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Visual-Basic-.NET \ No newline at end of file diff --git a/Lang/Visual-Basic-.NET/Rot-13 b/Lang/Visual-Basic-.NET/Rot-13 new file mode 120000 index 0000000000..ac7ae35fe4 --- /dev/null +++ b/Lang/Visual-Basic-.NET/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Visual-Basic-.NET \ No newline at end of file diff --git a/Lang/Visual-Basic/Named-parameters b/Lang/Visual-Basic/Named-parameters new file mode 120000 index 0000000000..68044b7f1e --- /dev/null +++ b/Lang/Visual-Basic/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/Visual-Basic \ No newline at end of file diff --git a/Lang/Visual-Basic/Number-names b/Lang/Visual-Basic/Number-names new file mode 120000 index 0000000000..0f104af3a9 --- /dev/null +++ b/Lang/Visual-Basic/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/Visual-Basic \ No newline at end of file diff --git a/Lang/Visual-Basic/Program-name b/Lang/Visual-Basic/Program-name new file mode 120000 index 0000000000..d0fef045f3 --- /dev/null +++ b/Lang/Visual-Basic/Program-name @@ -0,0 +1 @@ +../../Task/Program-name/Visual-Basic \ No newline at end of file diff --git a/Lang/Visual-Basic/Program-termination b/Lang/Visual-Basic/Program-termination new file mode 120000 index 0000000000..34f905e881 --- /dev/null +++ b/Lang/Visual-Basic/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/Visual-Basic \ No newline at end of file diff --git a/Lang/Visual-Basic/Read-a-configuration-file b/Lang/Visual-Basic/Read-a-configuration-file new file mode 120000 index 0000000000..1c0006a8ec --- /dev/null +++ b/Lang/Visual-Basic/Read-a-configuration-file @@ -0,0 +1 @@ +../../Task/Read-a-configuration-file/Visual-Basic \ No newline at end of file diff --git a/Lang/Visual-Basic/Read-a-file-line-by-line b/Lang/Visual-Basic/Read-a-file-line-by-line new file mode 120000 index 0000000000..2cda97af30 --- /dev/null +++ b/Lang/Visual-Basic/Read-a-file-line-by-line @@ -0,0 +1 @@ +../../Task/Read-a-file-line-by-line/Visual-Basic \ No newline at end of file diff --git a/Lang/Visual-Basic/Roman-numerals-Encode b/Lang/Visual-Basic/Roman-numerals-Encode new file mode 120000 index 0000000000..79e3d74561 --- /dev/null +++ b/Lang/Visual-Basic/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/Visual-Basic \ No newline at end of file diff --git a/Lang/Whitespace/Binary-digits b/Lang/Whitespace/Binary-digits new file mode 120000 index 0000000000..1cdbdf7901 --- /dev/null +++ b/Lang/Whitespace/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/Whitespace \ No newline at end of file diff --git a/Lang/X86-Assembly/Binary-digits b/Lang/X86-Assembly/Binary-digits new file mode 120000 index 0000000000..0206ab2ff2 --- /dev/null +++ b/Lang/X86-Assembly/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/X86-Assembly \ No newline at end of file diff --git a/Lang/X86-Assembly/Calendar---for-real-programmers b/Lang/X86-Assembly/Calendar---for-real-programmers new file mode 120000 index 0000000000..6f502b97ec --- /dev/null +++ b/Lang/X86-Assembly/Calendar---for-real-programmers @@ -0,0 +1 @@ +../../Task/Calendar---for-real-programmers/X86-Assembly \ No newline at end of file diff --git a/Lang/X86-Assembly/Calendar-for-real-programmers b/Lang/X86-Assembly/Calendar-for-real-programmers deleted file mode 120000 index 7898a19dd9..0000000000 --- a/Lang/X86-Assembly/Calendar-for-real-programmers +++ /dev/null @@ -1 +0,0 @@ -../../Task/Calendar-for-real-programmers/X86-Assembly \ No newline at end of file diff --git a/Lang/X86-Assembly/Dragon-curve b/Lang/X86-Assembly/Dragon-curve new file mode 120000 index 0000000000..1e16da718c --- /dev/null +++ b/Lang/X86-Assembly/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/X86-Assembly \ No newline at end of file diff --git a/Lang/X86-Assembly/Rot-13 b/Lang/X86-Assembly/Rot-13 new file mode 120000 index 0000000000..6233cf6df5 --- /dev/null +++ b/Lang/X86-Assembly/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/X86-Assembly \ No newline at end of file diff --git a/Lang/XPL0/Binary-digits b/Lang/XPL0/Binary-digits new file mode 120000 index 0000000000..12e9e55296 --- /dev/null +++ b/Lang/XPL0/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Brownian-tree b/Lang/XPL0/Brownian-tree new file mode 120000 index 0000000000..ee5fb1b71d --- /dev/null +++ b/Lang/XPL0/Brownian-tree @@ -0,0 +1 @@ +../../Task/Brownian-tree/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Catalan-numbers b/Lang/XPL0/Catalan-numbers new file mode 120000 index 0000000000..50bb50f6e4 --- /dev/null +++ b/Lang/XPL0/Catalan-numbers @@ -0,0 +1 @@ +../../Task/Catalan-numbers/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Copy-a-string b/Lang/XPL0/Copy-a-string new file mode 120000 index 0000000000..4755b8c574 --- /dev/null +++ b/Lang/XPL0/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Dragon-curve b/Lang/XPL0/Dragon-curve new file mode 120000 index 0000000000..d4af5e1e5a --- /dev/null +++ b/Lang/XPL0/Dragon-curve @@ -0,0 +1 @@ +../../Task/Dragon-curve/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Environment-variables b/Lang/XPL0/Environment-variables new file mode 120000 index 0000000000..d6e19887b5 --- /dev/null +++ b/Lang/XPL0/Environment-variables @@ -0,0 +1 @@ +../../Task/Environment-variables/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Guess-the-number-With-feedback--player- b/Lang/XPL0/Guess-the-number-With-feedback--player- new file mode 120000 index 0000000000..5fc5bdc75c --- /dev/null +++ b/Lang/XPL0/Guess-the-number-With-feedback--player- @@ -0,0 +1 @@ +../../Task/Guess-the-number-With-feedback--player-/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Guess-the-number-With-feedback-player b/Lang/XPL0/Guess-the-number-With-feedback-player deleted file mode 120000 index 71c2072a2e..0000000000 --- a/Lang/XPL0/Guess-the-number-With-feedback-player +++ /dev/null @@ -1 +0,0 @@ -../../Task/Guess-the-number-With-feedback-player/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/N-queens-problem b/Lang/XPL0/N-queens-problem new file mode 120000 index 0000000000..ead7a03df2 --- /dev/null +++ b/Lang/XPL0/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Non-decimal-radices-Convert b/Lang/XPL0/Non-decimal-radices-Convert new file mode 120000 index 0000000000..fcf7b0ab22 --- /dev/null +++ b/Lang/XPL0/Non-decimal-radices-Convert @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Convert/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Non-decimal-radices-Input b/Lang/XPL0/Non-decimal-radices-Input new file mode 120000 index 0000000000..4eea024e7b --- /dev/null +++ b/Lang/XPL0/Non-decimal-radices-Input @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Input/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Non-decimal-radices-Output b/Lang/XPL0/Non-decimal-radices-Output new file mode 120000 index 0000000000..aa1a0e4db4 --- /dev/null +++ b/Lang/XPL0/Non-decimal-radices-Output @@ -0,0 +1 @@ +../../Task/Non-decimal-radices-Output/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Nth-root b/Lang/XPL0/Nth-root new file mode 120000 index 0000000000..d77391c9a1 --- /dev/null +++ b/Lang/XPL0/Nth-root @@ -0,0 +1 @@ +../../Task/Nth-root/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Number-names b/Lang/XPL0/Number-names new file mode 120000 index 0000000000..8ea23516ed --- /dev/null +++ b/Lang/XPL0/Number-names @@ -0,0 +1 @@ +../../Task/Number-names/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Number-reversal-game b/Lang/XPL0/Number-reversal-game new file mode 120000 index 0000000000..c2d26cf7b7 --- /dev/null +++ b/Lang/XPL0/Number-reversal-game @@ -0,0 +1 @@ +../../Task/Number-reversal-game/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Numerical-integration b/Lang/XPL0/Numerical-integration new file mode 120000 index 0000000000..b403759ba0 --- /dev/null +++ b/Lang/XPL0/Numerical-integration @@ -0,0 +1 @@ +../../Task/Numerical-integration/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/One-dimensional-cellular-automata b/Lang/XPL0/One-dimensional-cellular-automata new file mode 120000 index 0000000000..fbb87fa81c --- /dev/null +++ b/Lang/XPL0/One-dimensional-cellular-automata @@ -0,0 +1 @@ +../../Task/One-dimensional-cellular-automata/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Palindrome-detection b/Lang/XPL0/Palindrome-detection new file mode 120000 index 0000000000..e9bf6e251a --- /dev/null +++ b/Lang/XPL0/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Pangram-checker b/Lang/XPL0/Pangram-checker new file mode 120000 index 0000000000..2076f9ee69 --- /dev/null +++ b/Lang/XPL0/Pangram-checker @@ -0,0 +1 @@ +../../Task/Pangram-checker/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Pascals-triangle b/Lang/XPL0/Pascals-triangle new file mode 120000 index 0000000000..3a5d43f057 --- /dev/null +++ b/Lang/XPL0/Pascals-triangle @@ -0,0 +1 @@ +../../Task/Pascals-triangle/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Permutations b/Lang/XPL0/Permutations new file mode 120000 index 0000000000..f05eb059f8 --- /dev/null +++ b/Lang/XPL0/Permutations @@ -0,0 +1 @@ +../../Task/Permutations/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Permutations-by-swapping b/Lang/XPL0/Permutations-by-swapping new file mode 120000 index 0000000000..7da035352d --- /dev/null +++ b/Lang/XPL0/Permutations-by-swapping @@ -0,0 +1 @@ +../../Task/Permutations-by-swapping/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Pick-random-element b/Lang/XPL0/Pick-random-element new file mode 120000 index 0000000000..1504ee5f7e --- /dev/null +++ b/Lang/XPL0/Pick-random-element @@ -0,0 +1 @@ +../../Task/Pick-random-element/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Pig-the-dice-game b/Lang/XPL0/Pig-the-dice-game new file mode 120000 index 0000000000..34011e2c01 --- /dev/null +++ b/Lang/XPL0/Pig-the-dice-game @@ -0,0 +1 @@ +../../Task/Pig-the-dice-game/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Pinstripe-Display b/Lang/XPL0/Pinstripe-Display new file mode 120000 index 0000000000..d8603f5246 --- /dev/null +++ b/Lang/XPL0/Pinstripe-Display @@ -0,0 +1 @@ +../../Task/Pinstripe-Display/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Plot-coordinate-pairs b/Lang/XPL0/Plot-coordinate-pairs new file mode 120000 index 0000000000..c7e83193e6 --- /dev/null +++ b/Lang/XPL0/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Pointers-and-references b/Lang/XPL0/Pointers-and-references new file mode 120000 index 0000000000..bdcd8d272b --- /dev/null +++ b/Lang/XPL0/Pointers-and-references @@ -0,0 +1 @@ +../../Task/Pointers-and-references/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Price-fraction b/Lang/XPL0/Price-fraction new file mode 120000 index 0000000000..bce35ff4d0 --- /dev/null +++ b/Lang/XPL0/Price-fraction @@ -0,0 +1 @@ +../../Task/Price-fraction/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Primality-by-trial-division b/Lang/XPL0/Primality-by-trial-division new file mode 120000 index 0000000000..433109b0c5 --- /dev/null +++ b/Lang/XPL0/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Probabilistic-choice b/Lang/XPL0/Probabilistic-choice new file mode 120000 index 0000000000..71b566861d --- /dev/null +++ b/Lang/XPL0/Probabilistic-choice @@ -0,0 +1 @@ +../../Task/Probabilistic-choice/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Program-termination b/Lang/XPL0/Program-termination new file mode 120000 index 0000000000..40905cd9b8 --- /dev/null +++ b/Lang/XPL0/Program-termination @@ -0,0 +1 @@ +../../Task/Program-termination/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Queue-Definition b/Lang/XPL0/Queue-Definition new file mode 120000 index 0000000000..50f41210ec --- /dev/null +++ b/Lang/XPL0/Queue-Definition @@ -0,0 +1 @@ +../../Task/Queue-Definition/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Queue-Usage b/Lang/XPL0/Queue-Usage new file mode 120000 index 0000000000..cd8b06bc67 --- /dev/null +++ b/Lang/XPL0/Queue-Usage @@ -0,0 +1 @@ +../../Task/Queue-Usage/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Random-number-generator--device- b/Lang/XPL0/Random-number-generator--device- new file mode 120000 index 0000000000..0d1ddb06ff --- /dev/null +++ b/Lang/XPL0/Random-number-generator--device- @@ -0,0 +1 @@ +../../Task/Random-number-generator--device-/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Random-number-generator--included- b/Lang/XPL0/Random-number-generator--included- new file mode 120000 index 0000000000..559fdf1b50 --- /dev/null +++ b/Lang/XPL0/Random-number-generator--included- @@ -0,0 +1 @@ +../../Task/Random-number-generator--included-/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Range-expansion b/Lang/XPL0/Range-expansion new file mode 120000 index 0000000000..48c1a234c6 --- /dev/null +++ b/Lang/XPL0/Range-expansion @@ -0,0 +1 @@ +../../Task/Range-expansion/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Rate-counter b/Lang/XPL0/Rate-counter new file mode 120000 index 0000000000..06c11dd516 --- /dev/null +++ b/Lang/XPL0/Rate-counter @@ -0,0 +1 @@ +../../Task/Rate-counter/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Read-a-specific-line-from-a-file b/Lang/XPL0/Read-a-specific-line-from-a-file new file mode 120000 index 0000000000..d6c4541431 --- /dev/null +++ b/Lang/XPL0/Read-a-specific-line-from-a-file @@ -0,0 +1 @@ +../../Task/Read-a-specific-line-from-a-file/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Read-entire-file b/Lang/XPL0/Read-entire-file new file mode 120000 index 0000000000..0784e87675 --- /dev/null +++ b/Lang/XPL0/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Real-constants-and-functions b/Lang/XPL0/Real-constants-and-functions new file mode 120000 index 0000000000..373a8b3820 --- /dev/null +++ b/Lang/XPL0/Real-constants-and-functions @@ -0,0 +1 @@ +../../Task/Real-constants-and-functions/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Remove-duplicate-elements b/Lang/XPL0/Remove-duplicate-elements new file mode 120000 index 0000000000..74be6e0806 --- /dev/null +++ b/Lang/XPL0/Remove-duplicate-elements @@ -0,0 +1 @@ +../../Task/Remove-duplicate-elements/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Repeat-a-string b/Lang/XPL0/Repeat-a-string new file mode 120000 index 0000000000..ba9b38136a --- /dev/null +++ b/Lang/XPL0/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Resistor-mesh b/Lang/XPL0/Resistor-mesh new file mode 120000 index 0000000000..51f9b89da5 --- /dev/null +++ b/Lang/XPL0/Resistor-mesh @@ -0,0 +1 @@ +../../Task/Resistor-mesh/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Return-multiple-values b/Lang/XPL0/Return-multiple-values new file mode 120000 index 0000000000..cf657822d1 --- /dev/null +++ b/Lang/XPL0/Return-multiple-values @@ -0,0 +1 @@ +../../Task/Return-multiple-values/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Reverse-a-string b/Lang/XPL0/Reverse-a-string new file mode 120000 index 0000000000..9ceabcb30a --- /dev/null +++ b/Lang/XPL0/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Roman-numerals-Decode b/Lang/XPL0/Roman-numerals-Decode new file mode 120000 index 0000000000..38154fd44d --- /dev/null +++ b/Lang/XPL0/Roman-numerals-Decode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Decode/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Rot-13 b/Lang/XPL0/Rot-13 new file mode 120000 index 0000000000..0bcf350e43 --- /dev/null +++ b/Lang/XPL0/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Run-length-encoding b/Lang/XPL0/Run-length-encoding new file mode 120000 index 0000000000..940b46936b --- /dev/null +++ b/Lang/XPL0/Run-length-encoding @@ -0,0 +1 @@ +../../Task/Run-length-encoding/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Self-describing-numbers b/Lang/XPL0/Self-describing-numbers new file mode 120000 index 0000000000..e2111fcd85 --- /dev/null +++ b/Lang/XPL0/Self-describing-numbers @@ -0,0 +1 @@ +../../Task/Self-describing-numbers/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Semordnilap b/Lang/XPL0/Semordnilap new file mode 120000 index 0000000000..51291ea439 --- /dev/null +++ b/Lang/XPL0/Semordnilap @@ -0,0 +1 @@ +../../Task/Semordnilap/XPL0 \ No newline at end of file diff --git a/Lang/XPL0/Sequence-of-non-squares b/Lang/XPL0/Sequence-of-non-squares new file mode 120000 index 0000000000..df48a7751f --- /dev/null +++ b/Lang/XPL0/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/XPL0 \ No newline at end of file diff --git a/Lang/XSLT/N-queens-problem b/Lang/XSLT/N-queens-problem new file mode 120000 index 0000000000..0697343fd5 --- /dev/null +++ b/Lang/XSLT/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/XSLT \ No newline at end of file diff --git a/Lang/XSLT/Named-parameters b/Lang/XSLT/Named-parameters new file mode 120000 index 0000000000..4649331be3 --- /dev/null +++ b/Lang/XSLT/Named-parameters @@ -0,0 +1 @@ +../../Task/Named-parameters/XSLT \ No newline at end of file diff --git a/Lang/XSLT/Optional-parameters b/Lang/XSLT/Optional-parameters new file mode 120000 index 0000000000..bb0c658019 --- /dev/null +++ b/Lang/XSLT/Optional-parameters @@ -0,0 +1 @@ +../../Task/Optional-parameters/XSLT \ No newline at end of file diff --git a/Lang/XSLT/Prime-decomposition b/Lang/XSLT/Prime-decomposition new file mode 120000 index 0000000000..ca0eb48beb --- /dev/null +++ b/Lang/XSLT/Prime-decomposition @@ -0,0 +1 @@ +../../Task/Prime-decomposition/XSLT \ No newline at end of file diff --git a/Lang/XSLT/Roman-numerals-Encode b/Lang/XSLT/Roman-numerals-Encode new file mode 120000 index 0000000000..ca9f983565 --- /dev/null +++ b/Lang/XSLT/Roman-numerals-Encode @@ -0,0 +1 @@ +../../Task/Roman-numerals-Encode/XSLT \ No newline at end of file diff --git a/Lang/XSLT/Rot-13 b/Lang/XSLT/Rot-13 new file mode 120000 index 0000000000..8088b441b6 --- /dev/null +++ b/Lang/XSLT/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/XSLT \ No newline at end of file diff --git a/Lang/Xanadu/N-queens-problem b/Lang/Xanadu/N-queens-problem new file mode 120000 index 0000000000..70f79d054d --- /dev/null +++ b/Lang/Xanadu/N-queens-problem @@ -0,0 +1 @@ +../../Task/N-queens-problem/Xanadu \ No newline at end of file diff --git a/Lang/Yorick/Palindrome-detection b/Lang/Yorick/Palindrome-detection new file mode 120000 index 0000000000..d6e74a9795 --- /dev/null +++ b/Lang/Yorick/Palindrome-detection @@ -0,0 +1 @@ +../../Task/Palindrome-detection/Yorick \ No newline at end of file diff --git a/Lang/Yorick/Plot-coordinate-pairs b/Lang/Yorick/Plot-coordinate-pairs new file mode 120000 index 0000000000..252b75c6b0 --- /dev/null +++ b/Lang/Yorick/Plot-coordinate-pairs @@ -0,0 +1 @@ +../../Task/Plot-coordinate-pairs/Yorick \ No newline at end of file diff --git a/Lang/Yorick/Random-numbers b/Lang/Yorick/Random-numbers new file mode 120000 index 0000000000..db944556b7 --- /dev/null +++ b/Lang/Yorick/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/Yorick \ No newline at end of file diff --git a/Lang/Yorick/Read-entire-file b/Lang/Yorick/Read-entire-file new file mode 120000 index 0000000000..afa0f4946d --- /dev/null +++ b/Lang/Yorick/Read-entire-file @@ -0,0 +1 @@ +../../Task/Read-entire-file/Yorick \ No newline at end of file diff --git a/Lang/Yorick/Rename-a-file b/Lang/Yorick/Rename-a-file new file mode 120000 index 0000000000..a107f95cc9 --- /dev/null +++ b/Lang/Yorick/Rename-a-file @@ -0,0 +1 @@ +../../Task/Rename-a-file/Yorick \ No newline at end of file diff --git a/Lang/Yorick/Repeat-a-string b/Lang/Yorick/Repeat-a-string new file mode 120000 index 0000000000..a116e43f11 --- /dev/null +++ b/Lang/Yorick/Repeat-a-string @@ -0,0 +1 @@ +../../Task/Repeat-a-string/Yorick \ No newline at end of file diff --git a/Lang/Yorick/Reverse-a-string b/Lang/Yorick/Reverse-a-string new file mode 120000 index 0000000000..e9da2874de --- /dev/null +++ b/Lang/Yorick/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Yorick \ No newline at end of file diff --git a/Lang/ZX-Spectrum-Basic/Binary-digits b/Lang/ZX-Spectrum-Basic/Binary-digits new file mode 120000 index 0000000000..d7c3c0bed8 --- /dev/null +++ b/Lang/ZX-Spectrum-Basic/Binary-digits @@ -0,0 +1 @@ +../../Task/Binary-digits/ZX-Spectrum-Basic \ No newline at end of file diff --git a/Lang/ZX-Spectrum-Basic/Copy-a-string b/Lang/ZX-Spectrum-Basic/Copy-a-string new file mode 120000 index 0000000000..71e721f070 --- /dev/null +++ b/Lang/ZX-Spectrum-Basic/Copy-a-string @@ -0,0 +1 @@ +../../Task/Copy-a-string/ZX-Spectrum-Basic \ No newline at end of file diff --git a/Lang/ZX-Spectrum-Basic/Random-numbers b/Lang/ZX-Spectrum-Basic/Random-numbers new file mode 120000 index 0000000000..c4a42bbf73 --- /dev/null +++ b/Lang/ZX-Spectrum-Basic/Random-numbers @@ -0,0 +1 @@ +../../Task/Random-numbers/ZX-Spectrum-Basic \ No newline at end of file diff --git a/Lang/ZX-Spectrum-Basic/Rot-13 b/Lang/ZX-Spectrum-Basic/Rot-13 new file mode 120000 index 0000000000..c8527d5f58 --- /dev/null +++ b/Lang/ZX-Spectrum-Basic/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/ZX-Spectrum-Basic \ No newline at end of file diff --git a/Lang/ZX-Spectrum-Basic/Scope-Function-names-and-labels b/Lang/ZX-Spectrum-Basic/Scope-Function-names-and-labels new file mode 120000 index 0000000000..9f6db9bc66 --- /dev/null +++ b/Lang/ZX-Spectrum-Basic/Scope-Function-names-and-labels @@ -0,0 +1 @@ +../../Task/Scope-Function-names-and-labels/ZX-Spectrum-Basic \ No newline at end of file diff --git a/Meta/Task.yaml b/Meta/Task.yaml index b2ea35bc04..d07fddfc49 100644 --- a/Meta/Task.yaml +++ b/Meta/Task.yaml @@ -81,7 +81,7 @@ Apply a callback to an array: url: Apply_a_callback_to_an_array Arbitrary-precision integers (included): name: Arbitrary-precision integers (included) - path: Arbitrary-precision-integers-included + path: Arbitrary-precision-integers--included- url: Arbitrary-precision_integers_(included) Arena storage pool: name: Arena storage pool @@ -179,6 +179,10 @@ Best shuffle: name: Best shuffle path: Best-shuffle url: Best_shuffle +Binary digits: + name: Binary digits + path: Binary-digits + url: Binary_digits Binary search: name: Binary search path: Binary-search @@ -255,6 +259,10 @@ Break OO privacy: name: Break OO privacy path: Break-OO-privacy url: Break_OO_privacy +Brownian tree: + name: Brownian tree + path: Brownian-tree + url: Brownian_tree Bulls and cows: name: Bulls and cows path: Bulls-and-cows @@ -281,7 +289,7 @@ Calendar: url: Calendar Calendar - for "real" programmers: name: Calendar - for "real" programmers - path: 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 @@ -311,6 +319,10 @@ Case-sensitivity of identifiers: name: Case-sensitivity of identifiers path: Case-sensitivity-of-identifiers url: Case-sensitivity_of_identifiers +Catalan numbers: + name: Catalan numbers + path: Catalan-numbers + url: Catalan_numbers Catmull–Clark subdivision surface: name: Catmull–Clark subdivision surface path: Catmull-Clark-subdivision-surface @@ -429,17 +441,21 @@ 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 + 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 + 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 +Copy a string: + name: Copy a string + path: Copy-a-string + url: Copy_a_string Count in factors: name: Count in factors path: Count-in-factors @@ -584,6 +600,10 @@ Doubly-linked list/Traversal: name: Doubly-linked list/Traversal path: Doubly-linked-list-Traversal url: Doubly-linked_list/Traversal +Dragon curve: + name: Dragon curve + path: Dragon-curve + url: Dragon_curve Draw a cuboid: name: Draw a cuboid path: Draw-a-cuboid @@ -632,6 +652,10 @@ Enumerations: name: Enumerations path: Enumerations url: Enumerations +Environment variables: + name: Environment variables + path: Environment-variables + url: Environment_variables Equilibrium index: name: Equilibrium index path: Equilibrium-index @@ -676,6 +700,14 @@ Execute HQ9+: name: Execute HQ9+ path: Execute-HQ9+ url: Execute_HQ9+ +Execute SNUSP: + name: Execute SNUSP + path: Execute-SNUSP + url: Execute_SNUSP +Execute a Markov algorithm: + name: Execute a Markov algorithm + path: Execute-a-Markov-algorithm + url: Execute_a_Markov_algorithm Execute a system command: name: Execute a system command path: Execute-a-system-command @@ -894,7 +926,7 @@ Guess the number/With feedback: url: Guess_the_number/With_feedback Guess the number/With feedback (player): name: Guess the number/With feedback (player) - path: Guess-the-number-With-feedback-player + path: Guess-the-number-With-feedback--player- url: Guess_the_number/With_feedback_(player) HTTP: name: HTTP @@ -1444,23 +1476,523 @@ Mutual recursion: name: Mutual recursion path: Mutual-recursion url: Mutual_recursion +N-queens problem: + name: N-queens problem + path: N-queens-problem + url: N-queens_problem +Named parameters: + name: Named parameters + path: Named-parameters + url: Named_parameters Narcissist: name: Narcissist path: Narcissist url: Narcissist +Nautical bell: + name: Nautical bell + path: Nautical-bell + url: Nautical_bell +Non-continuous subsequences: + name: Non-continuous subsequences + path: Non-continuous-subsequences + url: Non-continuous_subsequences +Non-decimal radices/Convert: + name: Non-decimal radices/Convert + path: Non-decimal-radices-Convert + url: Non-decimal_radices/Convert +Non-decimal radices/Input: + name: Non-decimal radices/Input + path: Non-decimal-radices-Input + url: Non-decimal_radices/Input +Non-decimal radices/Output: + name: Non-decimal radices/Output + path: Non-decimal-radices-Output + url: Non-decimal_radices/Output +Nth root: + name: Nth root + path: Nth-root + url: Nth_root +Null object: + name: Null object + path: Null-object + url: Null_object +Number names: + name: Number names + path: Number-names + url: Number_names +Number reversal game: + name: Number reversal game + path: Number-reversal-game + url: Number_reversal_game +Numeric error propagation: + name: Numeric error propagation + path: Numeric-error-propagation + url: Numeric_error_propagation +Numerical integration: + name: Numerical integration + path: Numerical-integration + url: Numerical_integration +Numerical integration/Gauss-Legendre Quadrature: + name: Numerical integration/Gauss-Legendre Quadrature + path: Numerical-integration-Gauss-Legendre-Quadrature + url: Numerical_integration/Gauss-Legendre_Quadrature +OLE Automation: + name: OLE Automation + path: OLE-Automation + url: OLE_Automation +Object serialization: + name: Object serialization + path: Object-serialization + url: Object_serialization +One of n lines in a file: + name: One of n lines in a file + path: One-of-n-lines-in-a-file + url: One_of_n_lines_in_a_file +One-dimensional cellular automata: + name: One-dimensional cellular automata + path: One-dimensional-cellular-automata + url: One-dimensional_cellular_automata +OpenGL: + name: OpenGL + path: OpenGL + url: OpenGL +Operator precedence: + name: Operator precedence + path: Operator-precedence + url: Operator_precedence +Optional parameters: + name: Optional parameters + path: Optional-parameters + url: Optional_parameters +Order two numerical lists: + name: Order two numerical lists + path: Order-two-numerical-lists + url: Order_two_numerical_lists +Ordered Partitions: + name: Ordered Partitions + path: Ordered-Partitions + url: Ordered_Partitions Ordered words: name: Ordered words path: Ordered-words url: Ordered_words +Palindrome detection: + name: Palindrome detection + path: Palindrome-detection + url: Palindrome_detection +Pangram checker: + name: Pangram checker + path: Pangram-checker + url: Pangram_checker +Parallel calculations: + name: Parallel calculations + path: Parallel-calculations + url: Parallel_calculations +Parametric polymorphism: + name: Parametric polymorphism + path: Parametric-polymorphism + url: Parametric_polymorphism +Parametrized SQL statement: + name: Parametrized SQL statement + path: Parametrized-SQL-statement + url: Parametrized_SQL_statement +Parsing/RPN calculator algorithm: + name: Parsing/RPN calculator algorithm + path: Parsing-RPN-calculator-algorithm + url: Parsing/RPN_calculator_algorithm +Parsing/RPN to infix conversion: + name: Parsing/RPN to infix conversion + path: Parsing-RPN-to-infix-conversion + url: Parsing/RPN_to_infix_conversion +Parsing/Shunting-yard algorithm: + name: Parsing/Shunting-yard algorithm + path: Parsing-Shunting-yard-algorithm + url: Parsing/Shunting-yard_algorithm +Partial function application: + name: Partial function application + path: Partial-function-application + url: Partial_function_application +Pascal's triangle: + name: Pascal's triangle + path: Pascals-triangle + url: Pascal's_triangle +Pascal's triangle/Puzzle: + name: Pascal's triangle/Puzzle + path: Pascals-triangle-Puzzle + url: Pascal's_triangle/Puzzle +Pattern matching: + name: Pattern matching + path: Pattern-matching + url: Pattern_matching +Percentage difference between images: + name: Percentage difference between images + path: Percentage-difference-between-images + url: Percentage_difference_between_images +Perfect numbers: + name: Perfect numbers + path: Perfect-numbers + url: Perfect_numbers +Permutation test: + name: Permutation test + path: Permutation-test + url: Permutation_test +Permutations: + name: Permutations + path: Permutations + url: Permutations +Permutations by swapping: + name: Permutations by swapping + path: Permutations-by-swapping + url: Permutations_by_swapping +Permutations/Derangements: + name: Permutations/Derangements + path: Permutations-Derangements + url: Permutations/Derangements Pi: name: Pi path: Pi url: Pi +Pick random element: + name: Pick random element + path: Pick-random-element + url: Pick_random_element +Pig the dice game: + name: Pig the dice game + path: Pig-the-dice-game + url: Pig_the_dice_game +Pig the dice game/Player: + name: Pig the dice game/Player + path: Pig-the-dice-game-Player + url: Pig_the_dice_game/Player +Pinstripe/Display: + name: Pinstripe/Display + path: Pinstripe-Display + url: Pinstripe/Display +Pinstripe/Printer: + name: Pinstripe/Printer + path: Pinstripe-Printer + url: Pinstripe/Printer +Play recorded sounds: + name: Play recorded sounds + path: Play-recorded-sounds + url: Play_recorded_sounds +Playing cards: + name: Playing cards + path: Playing-cards + url: Playing_cards +Plot coordinate pairs: + name: Plot coordinate pairs + path: Plot-coordinate-pairs + url: Plot_coordinate_pairs +Pointers and references: + name: Pointers and references + path: Pointers-and-references + url: Pointers_and_references +Polymorphic copy: + name: Polymorphic copy + path: Polymorphic-copy + url: Polymorphic_copy +Polymorphism: + name: Polymorphism + path: Polymorphism + url: Polymorphism +Polynomial long division: + name: Polynomial long division + path: Polynomial-long-division + url: Polynomial_long_division +Polynomial regression: + name: Polynomial regression + path: Polynomial-regression + url: Polynomial_regression +Power set: + name: Power set + path: Power-set + url: Power_set +Pragmatic directives: + name: Pragmatic directives + path: Pragmatic-directives + url: Pragmatic_directives +Price fraction: + name: Price fraction + path: Price-fraction + url: Price_fraction +Primality by trial division: + name: Primality by trial division + path: Primality-by-trial-division + url: Primality_by_trial_division +Prime decomposition: + name: Prime decomposition + path: Prime-decomposition + url: Prime_decomposition +Priority queue: + name: Priority queue + path: Priority-queue + url: Priority_queue +Probabilistic choice: + name: Probabilistic choice + path: Probabilistic-choice + url: Probabilistic_choice +Problem of Apollonius: + name: Problem of Apollonius + path: Problem-of-Apollonius + url: Problem_of_Apollonius +Program name: + name: Program name + path: Program-name + url: Program_name +Program termination: + name: Program termination + path: Program-termination + url: Program_termination +Pythagorean triples: + name: Pythagorean triples + path: Pythagorean-triples + url: Pythagorean_triples +QR decomposition: + name: QR decomposition + path: QR-decomposition + url: QR_decomposition +Quaternion type: + name: Quaternion type + path: Quaternion-type + url: Quaternion_type +Queue/Definition: + name: Queue/Definition + path: Queue-Definition + url: Queue/Definition +Queue/Usage: + name: Queue/Usage + path: Queue-Usage + url: Queue/Usage Quine: name: Quine path: Quine url: Quine +RCRPG: + name: RCRPG + path: RCRPG + url: RCRPG +RIPEMD-160: + name: RIPEMD-160 + path: RIPEMD-160 + url: RIPEMD-160 +Random number generator (device): + name: Random number generator (device) + path: Random-number-generator--device- + url: Random_number_generator_(device) +Random number generator (included): + name: Random number generator (included) + path: Random-number-generator--included- + url: Random_number_generator_(included) +Random numbers: + name: Random numbers + path: Random-numbers + url: Random_numbers +Range expansion: + name: Range expansion + path: Range-expansion + url: Range_expansion +Range extraction: + name: Range extraction + path: Range-extraction + url: Range_extraction +Rate counter: + name: Rate counter + path: Rate-counter + url: Rate_counter +Ray-casting algorithm: + name: Ray-casting algorithm + path: Ray-casting-algorithm + url: Ray-casting_algorithm +Read a configuration file: + name: Read a configuration file + path: Read-a-configuration-file + url: Read_a_configuration_file +Read a file line by line: + name: Read a file line by line + path: Read-a-file-line-by-line + url: Read_a_file_line_by_line +Read a specific line from a file: + name: Read a specific line from a file + path: Read-a-specific-line-from-a-file + url: Read_a_specific_line_from_a_file +Read entire file: + name: Read entire file + path: Read-entire-file + url: Read_entire_file +Real constants and functions: + name: Real constants and functions + path: Real-constants-and-functions + url: Real_constants_and_functions +Record sound: + name: Record sound + path: Record-sound + url: Record_sound +Reduced row echelon form: + name: Reduced row echelon form + path: Reduced-row-echelon-form + url: Reduced_row_echelon_form +Regular expressions: + name: Regular expressions + path: Regular-expressions + url: Regular_expressions +Remove duplicate elements: + name: Remove duplicate elements + path: Remove-duplicate-elements + url: Remove_duplicate_elements +Remove lines from a file: + name: Remove lines from a file + path: Remove-lines-from-a-file + url: Remove_lines_from_a_file +Rename a file: + name: Rename a file + path: Rename-a-file + url: Rename_a_file +Rendezvous: + name: Rendezvous + path: Rendezvous + url: Rendezvous +Repeat a string: + name: Repeat a string + path: Repeat-a-string + url: Repeat_a_string +Resistor mesh: + name: Resistor mesh + path: Resistor-mesh + url: Resistor_mesh +Respond to an unknown method call: + name: Respond to an unknown method call + path: Respond-to-an-unknown-method-call + url: Respond_to_an_unknown_method_call +Return multiple values: + name: Return multiple values + path: Return-multiple-values + url: Return_multiple_values +Reverse a string: + name: Reverse a string + path: Reverse-a-string + url: Reverse_a_string +Rock-paper-scissors: + name: Rock-paper-scissors + path: Rock-paper-scissors + url: Rock-paper-scissors +Roman numerals/Decode: + name: Roman numerals/Decode + path: Roman-numerals-Decode + url: Roman_numerals/Decode +Roman numerals/Encode: + name: Roman numerals/Encode + path: Roman-numerals-Encode + url: Roman_numerals/Encode +Roots of a function: + name: Roots of a function + path: Roots-of-a-function + url: Roots_of_a_function +Roots of a quadratic function: + name: Roots of a quadratic function + path: Roots-of-a-quadratic-function + url: Roots_of_a_quadratic_function +Roots of unity: + name: Roots of unity + path: Roots-of-unity + url: Roots_of_unity +Rosetta Code/Count examples: + name: Rosetta Code/Count examples + path: Rosetta-Code-Count-examples + url: Rosetta_Code/Count_examples +Rosetta Code/Find unimplemented tasks: + name: Rosetta Code/Find unimplemented tasks + path: Rosetta-Code-Find-unimplemented-tasks + url: Rosetta_Code/Find_unimplemented_tasks +Rosetta Code/Fix code tags: + name: Rosetta Code/Fix code tags + path: Rosetta-Code-Fix-code-tags + url: Rosetta_Code/Fix_code_tags +Rosetta Code/Rank languages by popularity: + name: Rosetta Code/Rank languages by popularity + path: Rosetta-Code-Rank-languages-by-popularity + url: Rosetta_Code/Rank_languages_by_popularity +Rot-13: + name: Rot-13 + path: Rot-13 + url: Rot-13 +Run-length encoding: + name: Run-length encoding + path: Run-length-encoding + url: Run-length_encoding +Runtime evaluation: + name: Runtime evaluation + path: Runtime-evaluation + url: Runtime_evaluation +Runtime evaluation/In an environment: + name: Runtime evaluation/In an environment + path: Runtime-evaluation-In-an-environment + url: Runtime_evaluation/In_an_environment +S-Expressions: + name: S-Expressions + path: S-Expressions + url: S-Expressions +SEDOLs: + name: SEDOLs + path: SEDOLs + url: SEDOLs +Safe addition: + name: Safe addition + path: Safe-addition + url: Safe_addition +Same Fringe: + name: Same Fringe + path: Same-Fringe + url: Same_Fringe +Scope modifiers: + name: Scope modifiers + path: Scope-modifiers + url: Scope_modifiers +Scope/Function names and labels: + name: Scope/Function names and labels + path: Scope-Function-names-and-labels + url: Scope/Function_names_and_labels Search a list: name: Search a list path: Search-a-list url: Search_a_list +Secure temporary file: + name: Secure temporary file + path: Secure-temporary-file + url: Secure_temporary_file +Self-describing numbers: + name: Self-describing numbers + path: Self-describing-numbers + url: Self-describing_numbers +Self-referential sequence: + name: Self-referential sequence + path: Self-referential-sequence + url: Self-referential_sequence +Semordnilap: + name: Semordnilap + path: Semordnilap + url: Semordnilap +Send an unknown method call: + name: Send an unknown method call + path: Send-an-unknown-method-call + url: Send_an_unknown_method_call +Send email: + name: Send email + path: Send-email + url: Send_email +Sequence of non-squares: + name: Sequence of non-squares + path: Sequence-of-non-squares + url: Sequence_of_non-squares +Set: + name: Set + path: Set + url: Set +Set consolidation: + name: Set consolidation + path: Set-consolidation + url: Set_consolidation +Set of real numbers: + name: Set of real numbers + path: Set-of-real-numbers + url: Set_of_real_numbers diff --git a/Task/Arbitrary-precision-integers-included/0DESCRIPTION b/Task/Arbitrary-precision-integers--included-/0DESCRIPTION similarity index 100% rename from Task/Arbitrary-precision-integers-included/0DESCRIPTION rename to Task/Arbitrary-precision-integers--included-/0DESCRIPTION diff --git a/Task/Arbitrary-precision-integers-included/1META.yaml b/Task/Arbitrary-precision-integers--included-/1META.yaml similarity index 100% rename from Task/Arbitrary-precision-integers-included/1META.yaml rename to Task/Arbitrary-precision-integers--included-/1META.yaml diff --git a/Task/Arbitrary-precision-integers-included/ACL2/arbitrary-precision-integers-included.acl2 b/Task/Arbitrary-precision-integers--included-/ACL2/arbitrary-precision-integers--included-.acl2 similarity index 100% rename from Task/Arbitrary-precision-integers-included/ACL2/arbitrary-precision-integers-included.acl2 rename to Task/Arbitrary-precision-integers--included-/ACL2/arbitrary-precision-integers--included-.acl2 diff --git a/Task/Arbitrary-precision-integers-included/Ada/arbitrary-precision-integers-included.ada b/Task/Arbitrary-precision-integers--included-/Ada/arbitrary-precision-integers--included-.ada similarity index 100% rename from Task/Arbitrary-precision-integers-included/Ada/arbitrary-precision-integers-included.ada rename to Task/Arbitrary-precision-integers--included-/Ada/arbitrary-precision-integers--included-.ada diff --git a/Task/Arbitrary-precision-integers-included/Alore/arbitrary-precision-integers-included.alore b/Task/Arbitrary-precision-integers--included-/Alore/arbitrary-precision-integers--included-.alore similarity index 100% rename from Task/Arbitrary-precision-integers-included/Alore/arbitrary-precision-integers-included.alore rename to Task/Arbitrary-precision-integers--included-/Alore/arbitrary-precision-integers--included-.alore diff --git a/Task/Arbitrary-precision-integers-included/Bracmat/arbitrary-precision-integers-included.bracmat b/Task/Arbitrary-precision-integers--included-/Bracmat/arbitrary-precision-integers--included-.bracmat similarity index 100% rename from Task/Arbitrary-precision-integers-included/Bracmat/arbitrary-precision-integers-included.bracmat rename to Task/Arbitrary-precision-integers--included-/Bracmat/arbitrary-precision-integers--included-.bracmat 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 similarity index 100% rename from Task/Arbitrary-precision-integers-included/C-sharp/arbitrary-precision-integers-included.cs rename to Task/Arbitrary-precision-integers--included-/C-sharp/arbitrary-precision-integers--included-.cs diff --git a/Task/Arbitrary-precision-integers-included/C/arbitrary-precision-integers-included-1.c b/Task/Arbitrary-precision-integers--included-/C/arbitrary-precision-integers--included--1.c similarity index 100% rename from Task/Arbitrary-precision-integers-included/C/arbitrary-precision-integers-included-1.c rename to Task/Arbitrary-precision-integers--included-/C/arbitrary-precision-integers--included--1.c diff --git a/Task/Arbitrary-precision-integers-included/C/arbitrary-precision-integers-included-2.c b/Task/Arbitrary-precision-integers--included-/C/arbitrary-precision-integers--included--2.c similarity index 100% rename from Task/Arbitrary-precision-integers-included/C/arbitrary-precision-integers-included-2.c rename to Task/Arbitrary-precision-integers--included-/C/arbitrary-precision-integers--included--2.c diff --git a/Task/Arbitrary-precision-integers-included/Clojure/arbitrary-precision-integers-included-1.clj b/Task/Arbitrary-precision-integers--included-/Clojure/arbitrary-precision-integers--included--1.clj similarity index 100% rename from Task/Arbitrary-precision-integers-included/Clojure/arbitrary-precision-integers-included-1.clj rename to Task/Arbitrary-precision-integers--included-/Clojure/arbitrary-precision-integers--included--1.clj diff --git a/Task/Arbitrary-precision-integers-included/Clojure/arbitrary-precision-integers-included-2.clj b/Task/Arbitrary-precision-integers--included-/Clojure/arbitrary-precision-integers--included--2.clj similarity index 100% rename from Task/Arbitrary-precision-integers-included/Clojure/arbitrary-precision-integers-included-2.clj rename to Task/Arbitrary-precision-integers--included-/Clojure/arbitrary-precision-integers--included--2.clj 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 similarity index 100% rename from Task/Arbitrary-precision-integers-included/Common-Lisp/arbitrary-precision-integers-included.lisp rename to Task/Arbitrary-precision-integers--included-/Common-Lisp/arbitrary-precision-integers--included-.lisp 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 similarity index 100% rename from Task/Arbitrary-precision-integers-included/D/arbitrary-precision-integers-included.d rename to Task/Arbitrary-precision-integers--included-/D/arbitrary-precision-integers--included-.d 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 similarity index 100% rename from Task/Arbitrary-precision-integers-included/E/arbitrary-precision-integers-included.e rename to Task/Arbitrary-precision-integers--included-/E/arbitrary-precision-integers--included-.e 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 similarity index 100% rename from Task/Arbitrary-precision-integers-included/Emacs-Lisp/arbitrary-precision-integers-included.l rename to Task/Arbitrary-precision-integers--included-/Emacs-Lisp/arbitrary-precision-integers--included-.l diff --git a/Task/Arbitrary-precision-integers-included/Erlang/arbitrary-precision-integers-included.erl b/Task/Arbitrary-precision-integers--included-/Erlang/arbitrary-precision-integers--included-.erl similarity index 100% rename from Task/Arbitrary-precision-integers-included/Erlang/arbitrary-precision-integers-included.erl rename to Task/Arbitrary-precision-integers--included-/Erlang/arbitrary-precision-integers--included-.erl diff --git a/Task/Arbitrary-precision-integers-included/Factor/arbitrary-precision-integers-included.factor b/Task/Arbitrary-precision-integers--included-/Factor/arbitrary-precision-integers--included-.factor similarity index 100% rename from Task/Arbitrary-precision-integers-included/Factor/arbitrary-precision-integers-included.factor rename to Task/Arbitrary-precision-integers--included-/Factor/arbitrary-precision-integers--included-.factor diff --git a/Task/Arbitrary-precision-integers-included/Frink/arbitrary-precision-integers-included.frink b/Task/Arbitrary-precision-integers--included-/Frink/arbitrary-precision-integers--included-.frink similarity index 100% rename from Task/Arbitrary-precision-integers-included/Frink/arbitrary-precision-integers-included.frink rename to Task/Arbitrary-precision-integers--included-/Frink/arbitrary-precision-integers--included-.frink diff --git a/Task/Arbitrary-precision-integers-included/GAP/arbitrary-precision-integers-included.gap b/Task/Arbitrary-precision-integers--included-/GAP/arbitrary-precision-integers--included-.gap similarity index 100% rename from Task/Arbitrary-precision-integers-included/GAP/arbitrary-precision-integers-included.gap rename to Task/Arbitrary-precision-integers--included-/GAP/arbitrary-precision-integers--included-.gap diff --git a/Task/Arbitrary-precision-integers-included/Go/arbitrary-precision-integers-included.go b/Task/Arbitrary-precision-integers--included-/Go/arbitrary-precision-integers--included-.go similarity index 100% rename from Task/Arbitrary-precision-integers-included/Go/arbitrary-precision-integers-included.go rename to Task/Arbitrary-precision-integers--included-/Go/arbitrary-precision-integers--included-.go diff --git a/Task/Arbitrary-precision-integers-included/Golfscript/arbitrary-precision-integers-included.golfscript b/Task/Arbitrary-precision-integers--included-/Golfscript/arbitrary-precision-integers--included-.golfscript similarity index 100% rename from Task/Arbitrary-precision-integers-included/Golfscript/arbitrary-precision-integers-included.golfscript rename to Task/Arbitrary-precision-integers--included-/Golfscript/arbitrary-precision-integers--included-.golfscript diff --git a/Task/Arbitrary-precision-integers-included/Groovy/arbitrary-precision-integers-included-1.groovy b/Task/Arbitrary-precision-integers--included-/Groovy/arbitrary-precision-integers--included--1.groovy similarity index 100% rename from Task/Arbitrary-precision-integers-included/Groovy/arbitrary-precision-integers-included-1.groovy rename to Task/Arbitrary-precision-integers--included-/Groovy/arbitrary-precision-integers--included--1.groovy diff --git a/Task/Arbitrary-precision-integers-included/Groovy/arbitrary-precision-integers-included-2.groovy b/Task/Arbitrary-precision-integers--included-/Groovy/arbitrary-precision-integers--included--2.groovy similarity index 100% rename from Task/Arbitrary-precision-integers-included/Groovy/arbitrary-precision-integers-included-2.groovy rename to Task/Arbitrary-precision-integers--included-/Groovy/arbitrary-precision-integers--included--2.groovy diff --git a/Task/Arbitrary-precision-integers-included/Haskell/arbitrary-precision-integers-included.hs b/Task/Arbitrary-precision-integers--included-/Haskell/arbitrary-precision-integers--included-.hs similarity index 100% rename from Task/Arbitrary-precision-integers-included/Haskell/arbitrary-precision-integers-included.hs rename to Task/Arbitrary-precision-integers--included-/Haskell/arbitrary-precision-integers--included-.hs diff --git a/Task/Arbitrary-precision-integers-included/Icon/arbitrary-precision-integers-included.icon b/Task/Arbitrary-precision-integers--included-/Icon/arbitrary-precision-integers--included-.icon similarity index 100% rename from Task/Arbitrary-precision-integers-included/Icon/arbitrary-precision-integers-included.icon rename to Task/Arbitrary-precision-integers--included-/Icon/arbitrary-precision-integers--included-.icon diff --git a/Task/Arbitrary-precision-integers-included/J/arbitrary-precision-integers-included.j b/Task/Arbitrary-precision-integers--included-/J/arbitrary-precision-integers--included-.j similarity index 100% rename from Task/Arbitrary-precision-integers-included/J/arbitrary-precision-integers-included.j rename to Task/Arbitrary-precision-integers--included-/J/arbitrary-precision-integers--included-.j diff --git a/Task/Arbitrary-precision-integers-included/Java/arbitrary-precision-integers-included.java b/Task/Arbitrary-precision-integers--included-/Java/arbitrary-precision-integers--included-.java similarity index 100% rename from Task/Arbitrary-precision-integers-included/Java/arbitrary-precision-integers-included.java rename to Task/Arbitrary-precision-integers--included-/Java/arbitrary-precision-integers--included-.java diff --git a/Task/Arbitrary-precision-integers-included/Julia/arbitrary-precision-integers-included.julia b/Task/Arbitrary-precision-integers--included-/Julia/arbitrary-precision-integers--included-.julia similarity index 100% rename from Task/Arbitrary-precision-integers-included/Julia/arbitrary-precision-integers-included.julia rename to Task/Arbitrary-precision-integers--included-/Julia/arbitrary-precision-integers--included-.julia diff --git a/Task/Arbitrary-precision-integers-included/Liberty-BASIC/arbitrary-precision-integers-included.liberty b/Task/Arbitrary-precision-integers--included-/Liberty-BASIC/arbitrary-precision-integers--included-.liberty similarity index 100% rename from Task/Arbitrary-precision-integers-included/Liberty-BASIC/arbitrary-precision-integers-included.liberty rename to Task/Arbitrary-precision-integers--included-/Liberty-BASIC/arbitrary-precision-integers--included-.liberty diff --git a/Task/Arbitrary-precision-integers-included/MATLAB/arbitrary-precision-integers-included.m b/Task/Arbitrary-precision-integers--included-/MATLAB/arbitrary-precision-integers--included-.m similarity index 100% rename from Task/Arbitrary-precision-integers-included/MATLAB/arbitrary-precision-integers-included.m rename to Task/Arbitrary-precision-integers--included-/MATLAB/arbitrary-precision-integers--included-.m diff --git a/Task/Arbitrary-precision-integers-included/Maple/arbitrary-precision-integers-included-1.maple b/Task/Arbitrary-precision-integers--included-/Maple/arbitrary-precision-integers--included--1.maple similarity index 100% rename from Task/Arbitrary-precision-integers-included/Maple/arbitrary-precision-integers-included-1.maple rename to Task/Arbitrary-precision-integers--included-/Maple/arbitrary-precision-integers--included--1.maple diff --git a/Task/Arbitrary-precision-integers-included/Maple/arbitrary-precision-integers-included-2.maple b/Task/Arbitrary-precision-integers--included-/Maple/arbitrary-precision-integers--included--2.maple similarity index 100% rename from Task/Arbitrary-precision-integers-included/Maple/arbitrary-precision-integers-included-2.maple rename to Task/Arbitrary-precision-integers--included-/Maple/arbitrary-precision-integers--included--2.maple diff --git a/Task/Arbitrary-precision-integers-included/Mathematica/arbitrary-precision-integers-included.math b/Task/Arbitrary-precision-integers--included-/Mathematica/arbitrary-precision-integers--included-.math similarity index 100% rename from Task/Arbitrary-precision-integers-included/Mathematica/arbitrary-precision-integers-included.math rename to Task/Arbitrary-precision-integers--included-/Mathematica/arbitrary-precision-integers--included-.math diff --git a/Task/Arbitrary-precision-integers-included/Maxima/arbitrary-precision-integers-included.maxima b/Task/Arbitrary-precision-integers--included-/Maxima/arbitrary-precision-integers--included-.maxima similarity index 100% rename from Task/Arbitrary-precision-integers-included/Maxima/arbitrary-precision-integers-included.maxima rename to Task/Arbitrary-precision-integers--included-/Maxima/arbitrary-precision-integers--included-.maxima diff --git a/Task/Arbitrary-precision-integers-included/NetRexx/arbitrary-precision-integers-included-1.netrexx b/Task/Arbitrary-precision-integers--included-/NetRexx/arbitrary-precision-integers--included--1.netrexx similarity index 100% rename from Task/Arbitrary-precision-integers-included/NetRexx/arbitrary-precision-integers-included-1.netrexx rename to Task/Arbitrary-precision-integers--included-/NetRexx/arbitrary-precision-integers--included--1.netrexx diff --git a/Task/Arbitrary-precision-integers-included/NetRexx/arbitrary-precision-integers-included-2.netrexx b/Task/Arbitrary-precision-integers--included-/NetRexx/arbitrary-precision-integers--included--2.netrexx similarity index 100% rename from Task/Arbitrary-precision-integers-included/NetRexx/arbitrary-precision-integers-included-2.netrexx rename to Task/Arbitrary-precision-integers--included-/NetRexx/arbitrary-precision-integers--included--2.netrexx diff --git a/Task/Arbitrary-precision-integers-included/NetRexx/arbitrary-precision-integers-included-3.netrexx b/Task/Arbitrary-precision-integers--included-/NetRexx/arbitrary-precision-integers--included--3.netrexx similarity index 100% rename from Task/Arbitrary-precision-integers-included/NetRexx/arbitrary-precision-integers-included-3.netrexx rename to Task/Arbitrary-precision-integers--included-/NetRexx/arbitrary-precision-integers--included--3.netrexx diff --git a/Task/Arbitrary-precision-integers-included/OCaml/arbitrary-precision-integers-included-1.ocaml b/Task/Arbitrary-precision-integers--included-/OCaml/arbitrary-precision-integers--included--1.ocaml similarity index 100% rename from Task/Arbitrary-precision-integers-included/OCaml/arbitrary-precision-integers-included-1.ocaml rename to Task/Arbitrary-precision-integers--included-/OCaml/arbitrary-precision-integers--included--1.ocaml diff --git a/Task/Arbitrary-precision-integers-included/OCaml/arbitrary-precision-integers-included-2.ocaml b/Task/Arbitrary-precision-integers--included-/OCaml/arbitrary-precision-integers--included--2.ocaml similarity index 100% rename from Task/Arbitrary-precision-integers-included/OCaml/arbitrary-precision-integers-included-2.ocaml rename to Task/Arbitrary-precision-integers--included-/OCaml/arbitrary-precision-integers--included--2.ocaml diff --git a/Task/Arbitrary-precision-integers-included/Oz/arbitrary-precision-integers-included.oz b/Task/Arbitrary-precision-integers--included-/Oz/arbitrary-precision-integers--included-.oz similarity index 100% rename from Task/Arbitrary-precision-integers-included/Oz/arbitrary-precision-integers-included.oz rename to Task/Arbitrary-precision-integers--included-/Oz/arbitrary-precision-integers--included-.oz diff --git a/Task/Arbitrary-precision-integers-included/PARI-GP/arbitrary-precision-integers-included.pari b/Task/Arbitrary-precision-integers--included-/PARI-GP/arbitrary-precision-integers--included-.pari similarity index 100% rename from Task/Arbitrary-precision-integers-included/PARI-GP/arbitrary-precision-integers-included.pari rename to Task/Arbitrary-precision-integers--included-/PARI-GP/arbitrary-precision-integers--included-.pari diff --git a/Task/Arbitrary-precision-integers-included/PHP/arbitrary-precision-integers-included.php b/Task/Arbitrary-precision-integers--included-/PHP/arbitrary-precision-integers--included-.php similarity index 100% rename from Task/Arbitrary-precision-integers-included/PHP/arbitrary-precision-integers-included.php rename to Task/Arbitrary-precision-integers--included-/PHP/arbitrary-precision-integers--included-.php diff --git a/Task/Arbitrary-precision-integers-included/Pascal/arbitrary-precision-integers-included.pascal b/Task/Arbitrary-precision-integers--included-/Pascal/arbitrary-precision-integers--included-.pascal similarity index 100% rename from Task/Arbitrary-precision-integers-included/Pascal/arbitrary-precision-integers-included.pascal rename to Task/Arbitrary-precision-integers--included-/Pascal/arbitrary-precision-integers--included-.pascal diff --git a/Task/Arbitrary-precision-integers-included/Perl-6/arbitrary-precision-integers-included.pl6 b/Task/Arbitrary-precision-integers--included-/Perl-6/arbitrary-precision-integers--included-.pl6 similarity index 100% rename from Task/Arbitrary-precision-integers-included/Perl-6/arbitrary-precision-integers-included.pl6 rename to Task/Arbitrary-precision-integers--included-/Perl-6/arbitrary-precision-integers--included-.pl6 diff --git a/Task/Arbitrary-precision-integers-included/Perl/arbitrary-precision-integers-included-1.pl b/Task/Arbitrary-precision-integers--included-/Perl/arbitrary-precision-integers--included--1.pl similarity index 100% rename from Task/Arbitrary-precision-integers-included/Perl/arbitrary-precision-integers-included-1.pl rename to Task/Arbitrary-precision-integers--included-/Perl/arbitrary-precision-integers--included--1.pl diff --git a/Task/Arbitrary-precision-integers-included/Perl/arbitrary-precision-integers-included-2.pl b/Task/Arbitrary-precision-integers--included-/Perl/arbitrary-precision-integers--included--2.pl similarity index 100% rename from Task/Arbitrary-precision-integers-included/Perl/arbitrary-precision-integers-included-2.pl rename to Task/Arbitrary-precision-integers--included-/Perl/arbitrary-precision-integers--included--2.pl diff --git a/Task/Arbitrary-precision-integers-included/Perl/arbitrary-precision-integers-included-3.pl b/Task/Arbitrary-precision-integers--included-/Perl/arbitrary-precision-integers--included--3.pl similarity index 100% rename from Task/Arbitrary-precision-integers-included/Perl/arbitrary-precision-integers-included-3.pl rename to Task/Arbitrary-precision-integers--included-/Perl/arbitrary-precision-integers--included--3.pl diff --git a/Task/Arbitrary-precision-integers-included/PicoLisp/arbitrary-precision-integers-included.l b/Task/Arbitrary-precision-integers--included-/PicoLisp/arbitrary-precision-integers--included-.l similarity index 100% rename from Task/Arbitrary-precision-integers-included/PicoLisp/arbitrary-precision-integers-included.l rename to Task/Arbitrary-precision-integers--included-/PicoLisp/arbitrary-precision-integers--included-.l diff --git a/Task/Arbitrary-precision-integers-included/Pike/arbitrary-precision-integers-included.pike b/Task/Arbitrary-precision-integers--included-/Pike/arbitrary-precision-integers--included-.pike similarity index 100% rename from Task/Arbitrary-precision-integers-included/Pike/arbitrary-precision-integers-included.pike rename to Task/Arbitrary-precision-integers--included-/Pike/arbitrary-precision-integers--included-.pike diff --git a/Task/Arbitrary-precision-integers-included/PureBasic/arbitrary-precision-integers-included.purebasic b/Task/Arbitrary-precision-integers--included-/PureBasic/arbitrary-precision-integers--included-.purebasic similarity index 100% rename from Task/Arbitrary-precision-integers-included/PureBasic/arbitrary-precision-integers-included.purebasic rename to Task/Arbitrary-precision-integers--included-/PureBasic/arbitrary-precision-integers--included-.purebasic diff --git a/Task/Arbitrary-precision-integers-included/Python/arbitrary-precision-integers-included.py b/Task/Arbitrary-precision-integers--included-/Python/arbitrary-precision-integers--included-.py similarity index 100% rename from Task/Arbitrary-precision-integers-included/Python/arbitrary-precision-integers-included.py rename to Task/Arbitrary-precision-integers--included-/Python/arbitrary-precision-integers--included-.py diff --git a/Task/Arbitrary-precision-integers-included/R/arbitrary-precision-integers-included.r b/Task/Arbitrary-precision-integers--included-/R/arbitrary-precision-integers--included-.r similarity index 100% rename from Task/Arbitrary-precision-integers-included/R/arbitrary-precision-integers-included.r rename to Task/Arbitrary-precision-integers--included-/R/arbitrary-precision-integers--included-.r diff --git a/Task/Arbitrary-precision-integers-included/REXX/arbitrary-precision-integers-included-1.rexx b/Task/Arbitrary-precision-integers--included-/REXX/arbitrary-precision-integers--included--1.rexx similarity index 100% rename from Task/Arbitrary-precision-integers-included/REXX/arbitrary-precision-integers-included-1.rexx rename to Task/Arbitrary-precision-integers--included-/REXX/arbitrary-precision-integers--included--1.rexx diff --git a/Task/Arbitrary-precision-integers-included/REXX/arbitrary-precision-integers-included-2.rexx b/Task/Arbitrary-precision-integers--included-/REXX/arbitrary-precision-integers--included--2.rexx similarity index 100% rename from Task/Arbitrary-precision-integers-included/REXX/arbitrary-precision-integers-included-2.rexx rename to Task/Arbitrary-precision-integers--included-/REXX/arbitrary-precision-integers--included--2.rexx diff --git a/Task/Arbitrary-precision-integers-included/Racket/arbitrary-precision-integers-included.rkt b/Task/Arbitrary-precision-integers--included-/Racket/arbitrary-precision-integers--included-.rkt similarity index 100% rename from Task/Arbitrary-precision-integers-included/Racket/arbitrary-precision-integers-included.rkt rename to Task/Arbitrary-precision-integers--included-/Racket/arbitrary-precision-integers--included-.rkt diff --git a/Task/Arbitrary-precision-integers-included/Ruby/arbitrary-precision-integers-included.rb b/Task/Arbitrary-precision-integers--included-/Ruby/arbitrary-precision-integers--included-.rb similarity index 100% rename from Task/Arbitrary-precision-integers-included/Ruby/arbitrary-precision-integers-included.rb rename to Task/Arbitrary-precision-integers--included-/Ruby/arbitrary-precision-integers--included-.rb diff --git a/Task/Arbitrary-precision-integers-included/Run-BASIC/arbitrary-precision-integers-included.run b/Task/Arbitrary-precision-integers--included-/Run-BASIC/arbitrary-precision-integers--included-.run similarity index 100% rename from Task/Arbitrary-precision-integers-included/Run-BASIC/arbitrary-precision-integers-included.run rename to Task/Arbitrary-precision-integers--included-/Run-BASIC/arbitrary-precision-integers--included-.run diff --git a/Task/Arbitrary-precision-integers-included/SIMPOL/arbitrary-precision-integers-included.simpol b/Task/Arbitrary-precision-integers--included-/SIMPOL/arbitrary-precision-integers--included-.simpol similarity index 100% rename from Task/Arbitrary-precision-integers-included/SIMPOL/arbitrary-precision-integers-included.simpol rename to Task/Arbitrary-precision-integers--included-/SIMPOL/arbitrary-precision-integers--included-.simpol diff --git a/Task/Arbitrary-precision-integers-included/Sather/arbitrary-precision-integers-included.sa b/Task/Arbitrary-precision-integers--included-/Sather/arbitrary-precision-integers--included-.sa similarity index 100% rename from Task/Arbitrary-precision-integers-included/Sather/arbitrary-precision-integers-included.sa rename to Task/Arbitrary-precision-integers--included-/Sather/arbitrary-precision-integers--included-.sa diff --git a/Task/Arbitrary-precision-integers-included/Scala/arbitrary-precision-integers-included.scala b/Task/Arbitrary-precision-integers--included-/Scala/arbitrary-precision-integers--included-.scala similarity index 100% rename from Task/Arbitrary-precision-integers-included/Scala/arbitrary-precision-integers-included.scala rename to Task/Arbitrary-precision-integers--included-/Scala/arbitrary-precision-integers--included-.scala diff --git a/Task/Arbitrary-precision-integers-included/Scheme/arbitrary-precision-integers-included.ss b/Task/Arbitrary-precision-integers--included-/Scheme/arbitrary-precision-integers--included-.ss similarity index 100% rename from Task/Arbitrary-precision-integers-included/Scheme/arbitrary-precision-integers-included.ss rename to Task/Arbitrary-precision-integers--included-/Scheme/arbitrary-precision-integers--included-.ss diff --git a/Task/Arbitrary-precision-integers-included/Seed7/arbitrary-precision-integers-included.seed7 b/Task/Arbitrary-precision-integers--included-/Seed7/arbitrary-precision-integers--included-.seed7 similarity index 100% rename from Task/Arbitrary-precision-integers-included/Seed7/arbitrary-precision-integers-included.seed7 rename to Task/Arbitrary-precision-integers--included-/Seed7/arbitrary-precision-integers--included-.seed7 diff --git a/Task/Arbitrary-precision-integers-included/Smalltalk/arbitrary-precision-integers-included-1.st b/Task/Arbitrary-precision-integers--included-/Smalltalk/arbitrary-precision-integers--included--1.st similarity index 100% rename from Task/Arbitrary-precision-integers-included/Smalltalk/arbitrary-precision-integers-included-1.st rename to Task/Arbitrary-precision-integers--included-/Smalltalk/arbitrary-precision-integers--included--1.st diff --git a/Task/Arbitrary-precision-integers-included/Smalltalk/arbitrary-precision-integers-included-2.st b/Task/Arbitrary-precision-integers--included-/Smalltalk/arbitrary-precision-integers--included--2.st similarity index 100% rename from Task/Arbitrary-precision-integers-included/Smalltalk/arbitrary-precision-integers-included-2.st rename to Task/Arbitrary-precision-integers--included-/Smalltalk/arbitrary-precision-integers--included--2.st diff --git a/Task/Arbitrary-precision-integers-included/Standard-ML/arbitrary-precision-integers-included.ml b/Task/Arbitrary-precision-integers--included-/Standard-ML/arbitrary-precision-integers--included-.ml similarity index 100% rename from Task/Arbitrary-precision-integers-included/Standard-ML/arbitrary-precision-integers-included.ml rename to Task/Arbitrary-precision-integers--included-/Standard-ML/arbitrary-precision-integers--included-.ml diff --git a/Task/Arbitrary-precision-integers-included/TXR/arbitrary-precision-integers-included.txr b/Task/Arbitrary-precision-integers--included-/TXR/arbitrary-precision-integers--included-.txr similarity index 100% rename from Task/Arbitrary-precision-integers-included/TXR/arbitrary-precision-integers-included.txr rename to Task/Arbitrary-precision-integers--included-/TXR/arbitrary-precision-integers--included-.txr diff --git a/Task/Arbitrary-precision-integers-included/Tcl/arbitrary-precision-integers-included.tcl b/Task/Arbitrary-precision-integers--included-/Tcl/arbitrary-precision-integers--included-.tcl similarity index 100% rename from Task/Arbitrary-precision-integers-included/Tcl/arbitrary-precision-integers-included.tcl rename to Task/Arbitrary-precision-integers--included-/Tcl/arbitrary-precision-integers--included-.tcl diff --git a/Task/Arbitrary-precision-integers-included/Ursala/arbitrary-precision-integers-included.ursala b/Task/Arbitrary-precision-integers--included-/Ursala/arbitrary-precision-integers--included-.ursala similarity index 100% rename from Task/Arbitrary-precision-integers-included/Ursala/arbitrary-precision-integers-included.ursala rename to Task/Arbitrary-precision-integers--included-/Ursala/arbitrary-precision-integers--included-.ursala diff --git a/Task/Binary-digits/0815/binary-digits-1.0815 b/Task/Binary-digits/0815/binary-digits-1.0815 new file mode 100644 index 0000000000..9f9299536e --- /dev/null +++ b/Task/Binary-digits/0815/binary-digits-1.0815 @@ -0,0 +1,12 @@ +}:r:|~ Read numbers in a loop. + }:b: Treat the queue as a stack and + <:2:= accumulate the binary digits + /=>&~ of the given number. + ^:b: + <:0:-> Enqueue negative 1 as a sentinel. + { Dequeue the first binary digit. + }:p: + ~%={+ Rotate each binary digit into place and print it. + ^:p: + <:a:~$ Output a newline. +^:r: diff --git a/Task/Binary-digits/0815/binary-digits-2.0815 b/Task/Binary-digits/0815/binary-digits-2.0815 new file mode 100644 index 0000000000..8350cbb626 --- /dev/null +++ b/Task/Binary-digits/0815/binary-digits-2.0815 @@ -0,0 +1,4 @@ +echo -e "5\n32\n2329" | 0815 bin.0 +101 +110010 +10001100101001 diff --git a/Task/Binary-digits/0DESCRIPTION b/Task/Binary-digits/0DESCRIPTION new file mode 100644 index 0000000000..1726825478 --- /dev/null +++ b/Task/Binary-digits/0DESCRIPTION @@ -0,0 +1,7 @@ +The task is to output the sequence of binary digits for a given [[wp:Natural number|non-negative integer]]. + +The decimal value 5, should produce an output of 101 +The decimal value 50 should produce an output of 110010 +The decimal value 9000 should produce an output of 10001100101000 + +The results can be achieved using builtin radix functions within the language, if these are available, or alternatively a user defined function can be used. The output produced should consist just of the binary digits of each number followed by a newline. There should be no other whitespace, radix or sign markers in the produced output, and [[wp:Leading zero|leading zeros]] should not appear in the results. diff --git a/Task/Binary-digits/1META.yaml b/Task/Binary-digits/1META.yaml new file mode 100644 index 0000000000..4f4b33e2dd --- /dev/null +++ b/Task/Binary-digits/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Radices +note: Basic language learning diff --git a/Task/Binary-digits/ACL2/binary-digits.acl2 b/Task/Binary-digits/ACL2/binary-digits.acl2 new file mode 100644 index 0000000000..d83c73f3de --- /dev/null +++ b/Task/Binary-digits/ACL2/binary-digits.acl2 @@ -0,0 +1,15 @@ +(include-book "arithmetic-3/top" :dir :system) + +(defun bin-string-r (x) + (if (zp x) + "" + (string-append + (bin-string-r (floor x 2)) + (if (= 1 (mod x 2)) + "1" + "0")))) + +(defun bin-string (x) + (if (zp x) + "0" + (bin-string-r x))) diff --git a/Task/Binary-digits/ALGOL-68/binary-digits.alg b/Task/Binary-digits/ALGOL-68/binary-digits.alg new file mode 100644 index 0000000000..10b4866018 --- /dev/null +++ b/Task/Binary-digits/ALGOL-68/binary-digits.alg @@ -0,0 +1,14 @@ +#!/usr/local/bin/a68g --script # + +printf(( + $g" => "2r3d l$, 5, BIN 5, + $g" => "2r6d l$, 50, BIN 50, + $g" => "2r14d l$, 9000, BIN 9000 +)); + +# or coerce to an array of BOOL # +print(( + 5, " => ", []BOOL(BIN 5)[bits width-3+1:], new line, + 50, " => ", []BOOL(BIN 50)[bits width-6+1:], new line, + 9000, " => ", []BOOL(BIN 9000)[bits width-14+1:], new line +)) diff --git a/Task/Binary-digits/AWK/binary-digits.awk b/Task/Binary-digits/AWK/binary-digits.awk new file mode 100644 index 0000000000..34b883eee5 --- /dev/null +++ b/Task/Binary-digits/AWK/binary-digits.awk @@ -0,0 +1,23 @@ +BEGIN { + print tobinary(5) + print tobinary(50) + print tobinary(9000) +} + +function tobinary(num) { + outstr = "" + l = num + while ( l ) { + if ( l%2 == 0 ) { + outstr = "0" outstr + } else { + outstr = "1" outstr + } + l = int(l/2) + } + # Make sure we output a zero for a value of zero + if ( outstr == "" ) { + outstr = "0" + } + return outstr +} diff --git a/Task/Binary-digits/Ada/binary-digits.ada b/Task/Binary-digits/Ada/binary-digits.ada new file mode 100644 index 0000000000..0fefbc2dc8 --- /dev/null +++ b/Task/Binary-digits/Ada/binary-digits.ada @@ -0,0 +1,28 @@ +with Ada.Text_IO; + +procedure Binary_Output is + + package IIO is new Ada.Text_IO.Integer_IO(Integer); + + function To_Binary(N: Natural) return String is + S: String(1 .. 1000); -- more than plenty! + Left: Positive := S'First; + Right: Positive := S'Last; + begin + IIO.Put(To => S, Item => N, Base => 2); -- This is the conversion! + -- Now S is a String with many spaces and some "2#...#" somewhere. + -- We only need the "..." part without spaces or base markers. + while S(Left) /= '#' loop + Left := Left + 1; + end loop; + while S(Right) /= '#' loop + Right := Right - 1; + end loop; + return S(Left+1 .. Right-1); + end To_Binary; + +begin + Ada.Text_IO.Put_Line(To_Binary(5)); -- 101 + Ada.Text_IO.Put_Line(To_Binary(50)); -- 110010 + Ada.Text_IO.Put_Line(To_Binary(9000)); -- 10001100101000 +end Binary_Output; diff --git a/Task/Binary-digits/AutoHotkey/binary-digits.ahk b/Task/Binary-digits/AutoHotkey/binary-digits.ahk new file mode 100644 index 0000000000..9ae02412de --- /dev/null +++ b/Task/Binary-digits/AutoHotkey/binary-digits.ahk @@ -0,0 +1,10 @@ +MsgBox % NumberToBinary(5) ;101 +MsgBox % NumberToBinary(50) ;110010 +MsgBox % NumberToBinary(9000) ;10001100101000 + +NumberToBinary(InputNumber) +{ + While, InputNumber + Result := (InputNumber & 1) . Result, InputNumber >>= 1 + Return, Result +} diff --git a/Task/Binary-digits/AutoIt/binary-digits.autoit b/Task/Binary-digits/AutoIt/binary-digits.autoit new file mode 100644 index 0000000000..7f528b0718 --- /dev/null +++ b/Task/Binary-digits/AutoIt/binary-digits.autoit @@ -0,0 +1,15 @@ +ConsoleWrite(IntToBin(50) & @CRLF) + +Func IntToBin($iInt) + $Stack = ObjCreate("System.Collections.Stack") + Local $b = -1, $r = "" + While $iInt <> 0 + $b = Mod($iInt, 2) + $iInt = INT($iInt/2) + $Stack.Push ($b) + WEnd + For $i = 1 TO $Stack.Count + $r &= $Stack.Pop + Next + Return $r +EndFunc ;==>IntToBin diff --git a/Task/Binary-digits/BBC-BASIC/binary-digits-1.bbc b/Task/Binary-digits/BBC-BASIC/binary-digits-1.bbc new file mode 100644 index 0000000000..337ed4d21a --- /dev/null +++ b/Task/Binary-digits/BBC-BASIC/binary-digits-1.bbc @@ -0,0 +1,16 @@ + FOR num% = 0 TO 16 + PRINT FN_tobase(num%, 2, 0) + NEXT + 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%MODB% + 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/Binary-digits/BBC-BASIC/binary-digits-2.bbc b/Task/Binary-digits/BBC-BASIC/binary-digits-2.bbc new file mode 100644 index 0000000000..d0beba07cc --- /dev/null +++ b/Task/Binary-digits/BBC-BASIC/binary-digits-2.bbc @@ -0,0 +1,12 @@ +PRINT FNbinary(5) +PRINT FNbinary(50) +PRINT FNbinary(9000) +END + +DEF FNbinary(N%) +LOCAL A$ +REPEAT + A$ = STR$(N% AND 1) + A$ + N% = N% >>> 1 : REM BBC Basic prior to V5 can use N% = N% DIV 2 +UNTIL N% = 0 +=A$ diff --git a/Task/Binary-digits/Batch-File/binary-digits.bat b/Task/Binary-digits/Batch-File/binary-digits.bat new file mode 100644 index 0000000000..54973e9952 --- /dev/null +++ b/Task/Binary-digits/Batch-File/binary-digits.bat @@ -0,0 +1,14 @@ +@echo off +:num2bin IntVal [RtnVar] + setlocal enableDelayedExpansion + set /a n=%~1 + set rtn= + for /l %%b in (0,1,31) do ( + set /a "d=n&1, n>>=1" + set rtn=!d!!rtn! + ) + for /f "tokens=* delims=0" %%a in ("!rtn!") do set rtn=%%a + (endlocal & rem -- return values + if "%~2" neq "" (set %~2=%rtn%) else echo %rtn% + ) +exit /b diff --git a/Task/Binary-digits/Brainf---/binary-digits.bf b/Task/Binary-digits/Brainf---/binary-digits.bf new file mode 100644 index 0000000000..a0de85bda5 --- /dev/null +++ b/Task/Binary-digits/Brainf---/binary-digits.bf @@ -0,0 +1,17 @@ ++[ Start with n=1 to kick off the loop +[>>++<< Set up {n 0 2} for divmod magic +[->+>- Then +[>+>>]> do +[+[-<+>]>+>>] the +<<<<<<] magic +>>>+ Increment n % 2 so that 0s don't break things +>] Move into n / 2 and divmod that unless it's 0 +-< Set up sentinel ‑1 then move into the first binary digit +[++++++++ ++++++++ ++++++++ Add 47 to get it to ASCII + ++++++++ ++++++++ +++++++. and print it +[<]<] Get to a 0; the cell to the left is the next binary 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/Binary-digits/Burlesque/binary-digits.blq b/Task/Binary-digits/Burlesque/binary-digits.blq new file mode 100644 index 0000000000..1a51259889 --- /dev/null +++ b/Task/Binary-digits/Burlesque/binary-digits.blq @@ -0,0 +1,4 @@ +blsq ) {5 50 9000}{2B!}m[uN +101 +110010 +10001100101000 diff --git a/Task/Binary-digits/C++/binary-digits.cpp b/Task/Binary-digits/C++/binary-digits.cpp new file mode 100644 index 0000000000..2932ef8353 --- /dev/null +++ b/Task/Binary-digits/C++/binary-digits.cpp @@ -0,0 +1,25 @@ +#include +#include +#include +#include + +void print_bin(int n) +{ + // convert to binary, then to string + std::string str = std::bitset(n).to_string(); + // trim leading zeroes + if(n == 0) + str = "0"; + else + str = str.substr(str.find('1')); + // output + std::cout << str << '\n'; +} + +int main() +{ + print_bin(0); + print_bin(5); + print_bin(50); + print_bin(9000); +} diff --git a/Task/Binary-digits/C/binary-digits-1.c b/Task/Binary-digits/C/binary-digits-1.c new file mode 100644 index 0000000000..08c7c0c86a --- /dev/null +++ b/Task/Binary-digits/C/binary-digits-1.c @@ -0,0 +1,20 @@ +#include + +void bin(int x, char *s) +{ + char*_(int x){ + *(s = x ? _(x >> 1) : s) = (x & 1) + '0'; + return ++s; + } + *_(x) = 0; +} + +int main() +{ + char a[100]; + int i; + for (i = 0; i <= 1984; i += 31) + bin(i, a), printf("%4d: %s\n", i, a); + + return 0; +} diff --git a/Task/Binary-digits/C/binary-digits-2.c b/Task/Binary-digits/C/binary-digits-2.c new file mode 100644 index 0000000000..70aef3c276 --- /dev/null +++ b/Task/Binary-digits/C/binary-digits-2.c @@ -0,0 +1,30 @@ +#include + +void IntToBitString(unsigned int number) +{ + int num_bits = sizeof(unsigned int) * 8; + + bool startPrinting = false; + for (int bit_pos=num_bits-1; bit_pos >= 0; bit_pos--) + { + bool isBitSet = (number & (1< + new Number(n).toString(2) + +console.log binary n for n in [5, 50, 9000] diff --git a/Task/Binary-digits/Common-Lisp/binary-digits.lisp b/Task/Binary-digits/Common-Lisp/binary-digits.lisp new file mode 100644 index 0000000000..e2ce5c309f --- /dev/null +++ b/Task/Binary-digits/Common-Lisp/binary-digits.lisp @@ -0,0 +1 @@ +(format t "~b" 5) diff --git a/Task/Binary-digits/D/binary-digits.d b/Task/Binary-digits/D/binary-digits.d new file mode 100644 index 0000000000..45dba745d2 --- /dev/null +++ b/Task/Binary-digits/D/binary-digits.d @@ -0,0 +1,6 @@ +import std.stdio; + +void main() { + foreach (i; 0 .. 16) + writefln("%b", i); +} diff --git a/Task/Binary-digits/Dart/binary-digits.dart b/Task/Binary-digits/Dart/binary-digits.dart new file mode 100644 index 0000000000..4964b4a29a --- /dev/null +++ b/Task/Binary-digits/Dart/binary-digits.dart @@ -0,0 +1,25 @@ +String binary(int n) { + if(n<0) + throw new IllegalArgumentException("negative numbers require 2s complement"); + if(n==0) return "0"; + String res=""; + while(n>0) { + res=(n%2).toString()+res; + n=(n/2).toInt(); + } + return res; +} + +main() { + print(binary(0)); + print(binary(1)); + print(binary(5)); + print(binary(10)); + print(binary(50)); + print(binary(9000)); + print(binary(65535)); + print(binary(0xaa5511ff)); + print(binary(0x123456789abcde)); + // fails due to precision limit + print(binary(0x123456789abcdef)); +} diff --git a/Task/Binary-digits/Delphi/binary-digits.delphi b/Task/Binary-digits/Delphi/binary-digits.delphi new file mode 100644 index 0000000000..e993e8e9ae --- /dev/null +++ b/Task/Binary-digits/Delphi/binary-digits.delphi @@ -0,0 +1,18 @@ +procedure Binary_Digits; + + function IntToBinStr(AInt : integer) : string; + + begin + Result := ''; + while AInt > 0 do + begin + Result := Chr(Ord('0')+(AInt mod 2))+Result; + AInt := AInt div 2; + end; + end; + +begin + writeln(' 5: '+IntToBinStr(5)); + writeln(' 50: '+IntToBinStr(50)); + writeln('9000: '+IntToBinStr(9000)); +end; diff --git a/Task/Binary-digits/Elena/binary-digits.elena b/Task/Binary-digits/Elena/binary-digits.elena new file mode 100644 index 0000000000..262343812f --- /dev/null +++ b/Task/Binary-digits/Elena/binary-digits.elena @@ -0,0 +1,11 @@ +#define std'dictionary'*. +#define ext'convertors'*. + +// --- Program --- + +#symbol Program = +[ + 'program'output write &numeric:5 &radix:2 &:eintformatter << "%n". + 'program'output write &numeric:50 &radix:2 &:eintformatter << "%n". + 'program'output write &numeric:9000 &radix:2 &:eintformatter << "%n". +]. diff --git a/Task/Binary-digits/Erlang/binary-digits.erl b/Task/Binary-digits/Erlang/binary-digits.erl new file mode 100644 index 0000000000..e6c3840b6c --- /dev/null +++ b/Task/Binary-digits/Erlang/binary-digits.erl @@ -0,0 +1 @@ +lists:map( fun(N) -> io:fwrite("~.2B~n", [N]) end, [5, 50, 9000]). diff --git a/Task/Binary-digits/Euphoria/binary-digits.euphoria b/Task/Binary-digits/Euphoria/binary-digits.euphoria new file mode 100644 index 0000000000..8778bdea7e --- /dev/null +++ b/Task/Binary-digits/Euphoria/binary-digits.euphoria @@ -0,0 +1,13 @@ +function toBinary(integer i) + sequence s + s = {} + while i do + s = prepend(s, '0'+and_bits(i,1)) + i = floor(i/2) + end while + return s +end function + +puts(1, toBinary(5) & '\n') +puts(1, toBinary(50) & '\n') +puts(1, toBinary(9000) & '\n') diff --git a/Task/Binary-digits/Factor/binary-digits.factor b/Task/Binary-digits/Factor/binary-digits.factor new file mode 100644 index 0000000000..e909db903d --- /dev/null +++ b/Task/Binary-digits/Factor/binary-digits.factor @@ -0,0 +1,5 @@ +USING: io kernel math math.parser ; + +5 >bin print +50 >bin print +9000 >bin print diff --git a/Task/Binary-digits/Forth/binary-digits.fth b/Task/Binary-digits/Forth/binary-digits.fth new file mode 100644 index 0000000000..fa90e5a700 --- /dev/null +++ b/Task/Binary-digits/Forth/binary-digits.fth @@ -0,0 +1,4 @@ +9000 50 5 +2 base ! +. . . +decimal diff --git a/Task/Binary-digits/Go/binary-digits.go b/Task/Binary-digits/Go/binary-digits.go new file mode 100644 index 0000000000..2d75ea6054 --- /dev/null +++ b/Task/Binary-digits/Go/binary-digits.go @@ -0,0 +1,11 @@ +package main + +import ( + "fmt" +) + +func main() { + for i := 0; i < 16; i++ { + fmt.Printf("%b\n", i) + } +} diff --git a/Task/Binary-digits/Groovy/binary-digits.groovy b/Task/Binary-digits/Groovy/binary-digits.groovy new file mode 100644 index 0000000000..afe4535530 --- /dev/null +++ b/Task/Binary-digits/Groovy/binary-digits.groovy @@ -0,0 +1,7 @@ +print ''' + n binary +----- --------------- +''' +[5, 50, 9000].each { + printf('%5d %15s\n', it, Integer.toBinaryString(it)) +} diff --git a/Task/Binary-digits/Haskell/binary-digits.hs b/Task/Binary-digits/Haskell/binary-digits.hs new file mode 100644 index 0000000000..fcf217e471 --- /dev/null +++ b/Task/Binary-digits/Haskell/binary-digits.hs @@ -0,0 +1,16 @@ +import Data.List +import Numeric +import Text.Printf + +-- Use the built-in function showIntAtBase. +toBin n = showIntAtBase 2 ("01" !!) n "" + +-- Implement our own version. +toBin' 0 = [] +toBin' x = (toBin' $ x `div` 2) ++ (show $ x `mod` 2) + +printToBin n = putStrLn $ printf "%4d %14s %14s" n (toBin n) (toBin' n) + +main = do + putStrLn $ printf "%4s %14s %14s" "N" "toBin" "toBin'" + mapM_ printToBin [5, 50, 9000] diff --git a/Task/Binary-digits/Icon/binary-digits.icon b/Task/Binary-digits/Icon/binary-digits.icon new file mode 100644 index 0000000000..2d4bde0b19 --- /dev/null +++ b/Task/Binary-digits/Icon/binary-digits.icon @@ -0,0 +1,23 @@ +procedure main() +every i := 5 | 50 | 255 | 1285 | 9000 do + write(i," = ",binary(i)) +end + +procedure binary(n) #: return bitstring for integer n +static CT, cm, cb +initial { + CT := table() # cache table for results + cm := 2 ^ (cb := 4) # (tunable) cache modulus & pad bits + } + +b := "" # build reversed bit string +while n > 0 do { # use cached result ... + if not (b ||:= \CT[1(i := n % cm, n /:= cm) ]) then { + CT[j := i] := "" # ...or start new cache entry + while j > 0 do + CT[i] ||:= "01"[ 1(1+j % 2, j /:= 2 )] + b ||:= CT[i] := left(CT[i],cb,"0") # finish cache with padding + } + } +return reverse(trim(b,"0")) # nothing extraneous +end diff --git a/Task/Binary-digits/J/binary-digits.j b/Task/Binary-digits/J/binary-digits.j new file mode 100644 index 0000000000..c8ef29b83f --- /dev/null +++ b/Task/Binary-digits/J/binary-digits.j @@ -0,0 +1,7 @@ + tobin=: -.&' '@":@#: + tobin 5 +101 + tobin 50 +110010 + tobin 9000 +10001100101000 diff --git a/Task/Binary-digits/Java/binary-digits.java b/Task/Binary-digits/Java/binary-digits.java new file mode 100644 index 0000000000..5935d3606c --- /dev/null +++ b/Task/Binary-digits/Java/binary-digits.java @@ -0,0 +1,7 @@ +public class Main { + public static void main(String[] args) { + System.out.println(Integer.toBinaryString(5)); + System.out.println(Integer.toBinaryString(50)); + System.out.println(Integer.toBinaryString(9000)); + } +} diff --git a/Task/Binary-digits/JavaScript/binary-digits.js b/Task/Binary-digits/JavaScript/binary-digits.js new file mode 100644 index 0000000000..a117653a9d --- /dev/null +++ b/Task/Binary-digits/JavaScript/binary-digits.js @@ -0,0 +1,7 @@ +function toBinary(number) { + return new Number(number).toString(2); +} +var demoValues = [5, 50, 9000]; +for (var i=0; i0 + dec2bin$=str$(num mod 2)+dec2bin$ + num=int(num/2) + wend +end function diff --git a/Task/Binary-digits/Locomotive-Basic/binary-digits.locomotive b/Task/Binary-digits/Locomotive-Basic/binary-digits.locomotive new file mode 100644 index 0000000000..edbad56364 --- /dev/null +++ b/Task/Binary-digits/Locomotive-Basic/binary-digits.locomotive @@ -0,0 +1,3 @@ +10 PRINT BIN$(5) +20 PRINT BIN$(50) +30 PRINT BIN$(9000) diff --git a/Task/Binary-digits/MATLAB/binary-digits.m b/Task/Binary-digits/MATLAB/binary-digits.m new file mode 100644 index 0000000000..b3de3d38de --- /dev/null +++ b/Task/Binary-digits/MATLAB/binary-digits.m @@ -0,0 +1,3 @@ + dec2bin(5) + dec2bin(50) + dec2bin(9000) diff --git a/Task/Binary-digits/Maple/binary-digits.maple b/Task/Binary-digits/Maple/binary-digits.maple new file mode 100644 index 0000000000..b97c5923b3 --- /dev/null +++ b/Task/Binary-digits/Maple/binary-digits.maple @@ -0,0 +1,4 @@ +> printf( "%d\n", convert( 50, 'binary' ) ); +110010 +> printf( "%d\n", convert( 9000, 'binary' ) ); +10001100101000 diff --git a/Task/Binary-digits/Mathematica/binary-digits.math b/Task/Binary-digits/Mathematica/binary-digits.math new file mode 100644 index 0000000000..8f27c88ac0 --- /dev/null +++ b/Task/Binary-digits/Mathematica/binary-digits.math @@ -0,0 +1 @@ +StringJoin @@ ToString /@ IntegerDigits[50, 2] diff --git a/Task/Binary-digits/Maxima/binary-digits.maxima b/Task/Binary-digits/Maxima/binary-digits.maxima new file mode 100644 index 0000000000..7e16fd7303 --- /dev/null +++ b/Task/Binary-digits/Maxima/binary-digits.maxima @@ -0,0 +1,15 @@ +digits([arg]) := block( + [n: first(arg), b: if length(arg) > 1 then second(arg) else 10, v: [ ], q], + if n = 0 then [0] else ( + while n # 0 do ( + [n, q]: divide(n, b), + v: endcons(q, v) + ), + v + ) +)$ + +binary(n) := simplode(reverse(digits(9000, 2)))$ + +binary(9000); +"10001100101000" diff --git a/Task/Binary-digits/Mercury/binary-digits.mercury b/Task/Binary-digits/Mercury/binary-digits.mercury new file mode 100644 index 0000000000..1e1bcd8791 --- /dev/null +++ b/Task/Binary-digits/Mercury/binary-digits.mercury @@ -0,0 +1,17 @@ +:- module binary_digits. +:- interface. + +:- import_module io. +:- pred main(io::di, io::uo) is det. + +:- implementation. +:- import_module int, list, string. + +main(!IO) :- + list.foldl(print_binary_digits, [5, 50, 9000], !IO). + +:- pred print_binary_digits(int::in, io::di, io::uo) is det. + +print_binary_digits(N, !IO) :- + io.write_string(int_to_base_string(N, 2), !IO), + io.nl(!IO). diff --git a/Task/Binary-digits/Modula-3/binary-digits.mod3 b/Task/Binary-digits/Modula-3/binary-digits.mod3 new file mode 100644 index 0000000000..2fc1ce3ad6 --- /dev/null +++ b/Task/Binary-digits/Modula-3/binary-digits.mod3 @@ -0,0 +1,11 @@ +MODULE Binary EXPORTS Main; + +IMPORT IO, Fmt; + +VAR num := 10; + +BEGIN + IO.Put(Fmt.Int(num, 2) & "\n"); + num := 150; + IO.Put(Fmt.Int(num, 2) & "\n"); +END Binary. diff --git a/Task/Binary-digits/NetRexx/binary-digits.netrexx b/Task/Binary-digits/NetRexx/binary-digits.netrexx new file mode 100644 index 0000000000..a4118704a0 --- /dev/null +++ b/Task/Binary-digits/NetRexx/binary-digits.netrexx @@ -0,0 +1,12 @@ +/* NetRexx */ + +options replace format comments java crossref savelog symbols nobinary + +nums = [5, 50, 9000] + +loop n_ = 0 to nums.length - 1 + v_ = nums[n_] + say v_.d2x.x2b.strip('L', 0) + end n_ + +return diff --git a/Task/Binary-digits/OCaml/binary-digits.ocaml b/Task/Binary-digits/OCaml/binary-digits.ocaml new file mode 100644 index 0000000000..4ee9dc2649 --- /dev/null +++ b/Task/Binary-digits/OCaml/binary-digits.ocaml @@ -0,0 +1,12 @@ +let bin_of_int d = + if d < 0 then invalid_arg "bin_of_int" else + if d = 0 then "0" else + let rec aux acc d = + if d = 0 then acc else + aux (string_of_int (d land 1) :: acc) (d lsr 1) + in + String.concat "" (aux [] d) + +let () = + let d = read_int () in + Printf.printf "%8s\n" (bin_of_int d) diff --git a/Task/Binary-digits/Objeck/binary-digits.objeck b/Task/Binary-digits/Objeck/binary-digits.objeck new file mode 100644 index 0000000000..43577bbdd7 --- /dev/null +++ b/Task/Binary-digits/Objeck/binary-digits.objeck @@ -0,0 +1,9 @@ +bundle Default { + class Binary { + function : Main(args : String[]) ~ Nil { + 5->ToBinaryString()->PrintLine(); + 50->ToBinaryString()->PrintLine(); + 9000->ToBinaryString()->PrintLine(); + } + } +} diff --git a/Task/Binary-digits/OxygenBasic/binary-digits.oxy b/Task/Binary-digits/OxygenBasic/binary-digits.oxy new file mode 100644 index 0000000000..fe00cc53c5 --- /dev/null +++ b/Task/Binary-digits/OxygenBasic/binary-digits.oxy @@ -0,0 +1,42 @@ +function BinaryBits(sys n) as string + string buf=nuls 32 + sys p=strptr buf + sys le + mov eax,n + mov edi,p + mov ecx,32 + ' + 'STRIP LEADING ZEROS + ( + dec ecx + jl fwd done + shl eax,1 + jnc repeat + ) + 'PLACE DIGITS + ' + mov byte [edi],49 '1' + inc edi + ( + cmp ecx,0 + jle exit + mov dl,48 '0' + shl eax,1 + ( + jnc exit + mov dl,49 '1' + ) + mov [edi],dl + inc edi + dec ecx + repeat + ) + done: + ' + sub edi,p + mov le,edi + if le then return left buf,le + return "0" +end function + +print BinaryBits 0xaa 'result 10101010 diff --git a/Task/Binary-digits/PARI-GP/binary-digits.pari b/Task/Binary-digits/PARI-GP/binary-digits.pari new file mode 100644 index 0000000000..b30a247c68 --- /dev/null +++ b/Task/Binary-digits/PARI-GP/binary-digits.pari @@ -0,0 +1 @@ +bin(n:int)=concat(apply(s->Str(s),binary(n))) diff --git a/Task/Binary-digits/PHP/binary-digits.php b/Task/Binary-digits/PHP/binary-digits.php new file mode 100644 index 0000000000..093b1194e5 --- /dev/null +++ b/Task/Binary-digits/PHP/binary-digits.php @@ -0,0 +1,4 @@ + "101" + +: (bin 50) +-> "110010" + +: (bin 9000) +-> "10001100101000" diff --git a/Task/Binary-digits/PowerShell/binary-digits.psh b/Task/Binary-digits/PowerShell/binary-digits.psh new file mode 100644 index 0000000000..fbfb21b747 --- /dev/null +++ b/Task/Binary-digits/PowerShell/binary-digits.psh @@ -0,0 +1 @@ +@(5,50,900) | foreach-object { [Convert]::ToString($_,2) } diff --git a/Task/Binary-digits/PureBasic/binary-digits.purebasic b/Task/Binary-digits/PureBasic/binary-digits.purebasic new file mode 100644 index 0000000000..c8ee6c2a81 --- /dev/null +++ b/Task/Binary-digits/PureBasic/binary-digits.purebasic @@ -0,0 +1,8 @@ +If OpenConsole() + PrintN(Bin(5)) ;101 + PrintN(Bin(50)) ;110010 + PrintN(Bin(9000)) ;10001100101000 + + Print(#CRLF$ + #CRLF$ + "Press ENTER to exit"): Input() + CloseConsole() +EndIf diff --git a/Task/Binary-digits/Python/binary-digits-1.py b/Task/Binary-digits/Python/binary-digits-1.py new file mode 100644 index 0000000000..01f520b4d0 --- /dev/null +++ b/Task/Binary-digits/Python/binary-digits-1.py @@ -0,0 +1,18 @@ +>>> for i in range(16): print('{0:b}'.format(i)) + +0 +1 +10 +11 +100 +101 +110 +111 +1000 +1001 +1010 +1011 +1100 +1101 +1110 +1111 diff --git a/Task/Binary-digits/Python/binary-digits-2.py b/Task/Binary-digits/Python/binary-digits-2.py new file mode 100644 index 0000000000..1ad92d4db0 --- /dev/null +++ b/Task/Binary-digits/Python/binary-digits-2.py @@ -0,0 +1,18 @@ +>>> for i in range(16): print(bin(i)) + +0b0 +0b1 +0b10 +0b11 +0b100 +0b101 +0b110 +0b111 +0b1000 +0b1001 +0b1010 +0b1011 +0b1100 +0b1101 +0b1110 +0b1111 diff --git a/Task/Binary-digits/Python/binary-digits-3.py b/Task/Binary-digits/Python/binary-digits-3.py new file mode 100644 index 0000000000..742e2ecbe8 --- /dev/null +++ b/Task/Binary-digits/Python/binary-digits-3.py @@ -0,0 +1,20 @@ +>>> oct2bin = {'0': '000', '1': '001', '2': '010', '3': '011', '4': '100', '5': '101', '6': '110', '7': '111'} +>>> bin = lambda n: ''.join(oct2bin[octdigit] for octdigit in '%o' % n).lstrip('0') or '0' +>>> for i in range(16): print(bin(i)) + +0 +1 +10 +11 +100 +101 +110 +111 +1000 +1001 +1010 +1011 +1100 +1101 +1110 +1111 diff --git a/Task/Binary-digits/REXX/binary-digits-1.rexx b/Task/Binary-digits/REXX/binary-digits-1.rexx new file mode 100644 index 0000000000..6efcaa9091 --- /dev/null +++ b/Task/Binary-digits/REXX/binary-digits-1.rexx @@ -0,0 +1,13 @@ +/*REXX program demonstrates converting decimal ───► binary. */ +numeric digits 1000 + +x.1 = 0 +x.2 = 5 +x.3 = 50 +x.4 = 9000 + + do j=1 for 4 + y = x2b(d2x(x.j)) + 0 + say right(x.j,20) 'decimal, and in binary:' y + end /*j*/ + /*stick a fork in it, we're done.*/ diff --git a/Task/Binary-digits/REXX/binary-digits-2.rexx b/Task/Binary-digits/REXX/binary-digits-2.rexx new file mode 100644 index 0000000000..d8ced54a37 --- /dev/null +++ b/Task/Binary-digits/REXX/binary-digits-2.rexx @@ -0,0 +1,13 @@ +/*REXX program demonstrates converting decimal ───► binary. */ + +x.1 = 0 +x.2 = 5 +x.3 = 50 +x.4 = 9000 + + do j=1 for 4 + y = strip( x2b( d2x( x.j )), 'L', 0) + if y=='' then y=0 + say right(x.j,20) 'decimal, and in binary:' y + end /*j*/ + /*stick a fork in it, we're done.*/ diff --git a/Task/Binary-digits/REXX/binary-digits-3.rexx b/Task/Binary-digits/REXX/binary-digits-3.rexx new file mode 100644 index 0000000000..63f3f1829a --- /dev/null +++ b/Task/Binary-digits/REXX/binary-digits-3.rexx @@ -0,0 +1,11 @@ +/*REXX program demonstrates converting decimal ───► binary. */ + +x.1 = 0 +x.2 = 5 +x.3 = 50 +x.4 = 9000 + do j=1 for 4 + y = word( strip( x2b( d2x( x.j )), 'L', 0) 0, 1) + say right(x.j,20) 'decimal, and in binary:' y + end /*j*/ + /*stick a fork in it, we're done.*/ diff --git a/Task/Binary-digits/Racket/binary-digits.rkt b/Task/Binary-digits/Racket/binary-digits.rkt new file mode 100644 index 0000000000..ce748521d8 --- /dev/null +++ b/Task/Binary-digits/Racket/binary-digits.rkt @@ -0,0 +1,3 @@ +#lang racket +(for ([i 16]) + (displayln (number->string i 2))) diff --git a/Task/Binary-digits/Retro/binary-digits.retro b/Task/Binary-digits/Retro/binary-digits.retro new file mode 100644 index 0000000000..0ee09ad428 --- /dev/null +++ b/Task/Binary-digits/Retro/binary-digits.retro @@ -0,0 +1 @@ +9000 50 5 3 [ binary putn cr decimal ] times diff --git a/Task/Binary-digits/Ruby/binary-digits-1.rb b/Task/Binary-digits/Ruby/binary-digits-1.rb new file mode 100644 index 0000000000..cc11d2dbb5 --- /dev/null +++ b/Task/Binary-digits/Ruby/binary-digits-1.rb @@ -0,0 +1,3 @@ +[5,50,9000].each do |n| + puts "%b" % n +end diff --git a/Task/Binary-digits/Ruby/binary-digits-2.rb b/Task/Binary-digits/Ruby/binary-digits-2.rb new file mode 100644 index 0000000000..97dc972e50 --- /dev/null +++ b/Task/Binary-digits/Ruby/binary-digits-2.rb @@ -0,0 +1,3 @@ +for n in [5,50,9000] + puts n.to_s(2) +end diff --git a/Task/Binary-digits/Ruby/binary-digits.rb b/Task/Binary-digits/Ruby/binary-digits.rb new file mode 100644 index 0000000000..7259380f14 --- /dev/null +++ b/Task/Binary-digits/Ruby/binary-digits.rb @@ -0,0 +1,4 @@ +16.times do |i| + puts '%b' % i + puts i.to_s 2 +end diff --git a/Task/Binary-digits/Run-BASIC/binary-digits.run b/Task/Binary-digits/Run-BASIC/binary-digits.run new file mode 100644 index 0000000000..655167f4d3 --- /dev/null +++ b/Task/Binary-digits/Run-BASIC/binary-digits.run @@ -0,0 +1,14 @@ +input "Number to convert:";a +while 2^(n+1) < a + n = n + 1 +wend + +for i = n to 0 step -1 + x = 2^i + if a >= x then + print 1; + a = a - x + else + print 0; + end if +next diff --git a/Task/Binary-digits/Scala/binary-digits.scala b/Task/Binary-digits/Scala/binary-digits.scala new file mode 100644 index 0000000000..867843bd87 --- /dev/null +++ b/Task/Binary-digits/Scala/binary-digits.scala @@ -0,0 +1,3 @@ +5 toBinaryString // 101 +50 toBinaryString // 110010 +9000 toBinaryString // 10001100101000 diff --git a/Task/Binary-digits/Scheme/binary-digits.ss b/Task/Binary-digits/Scheme/binary-digits.ss new file mode 100644 index 0000000000..e21c4929ec --- /dev/null +++ b/Task/Binary-digits/Scheme/binary-digits.ss @@ -0,0 +1,3 @@ +(display (number->string 5 2)) (newline) +(display (number->string 50 2)) (newline) +(display (number->string 9000 2)) (newline) diff --git a/Task/Binary-digits/Seed7/binary-digits.seed7 b/Task/Binary-digits/Seed7/binary-digits.seed7 new file mode 100644 index 0000000000..8e0d6a8e02 --- /dev/null +++ b/Task/Binary-digits/Seed7/binary-digits.seed7 @@ -0,0 +1,10 @@ +$ include "seed7_05.s7i"; + +const proc: main is func + local + var integer: number is 0; + begin + for number range 0 to 16 do + writeln(str(number, 2)); + end for; + end func; diff --git a/Task/Binary-digits/Smalltalk/binary-digits-1.st b/Task/Binary-digits/Smalltalk/binary-digits-1.st new file mode 100644 index 0000000000..b5aaaa5327 --- /dev/null +++ b/Task/Binary-digits/Smalltalk/binary-digits-1.st @@ -0,0 +1,3 @@ +5 printOn: Stdout radix:2 +50 printOn: Stdout radix:2 +9000 printOn: Stdout radix:2 diff --git a/Task/Binary-digits/Smalltalk/binary-digits-2.st b/Task/Binary-digits/Smalltalk/binary-digits-2.st new file mode 100644 index 0000000000..a9c2767379 --- /dev/null +++ b/Task/Binary-digits/Smalltalk/binary-digits-2.st @@ -0,0 +1 @@ +#(5 50 9000) do:[:each | each printOn: Stdout radix:2. Stdout cr] diff --git a/Task/Binary-digits/Standard-ML/binary-digits.ml b/Task/Binary-digits/Standard-ML/binary-digits.ml new file mode 100644 index 0000000000..11df313ddd --- /dev/null +++ b/Task/Binary-digits/Standard-ML/binary-digits.ml @@ -0,0 +1,3 @@ +print (Int.fmt StringCvt.BIN 5 ^ "\n"); +print (Int.fmt StringCvt.BIN 50 ^ "\n"); +print (Int.fmt StringCvt.BIN 9000 ^ "\n"); diff --git a/Task/Binary-digits/TI-83-BASIC/binary-digits-1.ti-83 b/Task/Binary-digits/TI-83-BASIC/binary-digits-1.ti-83 new file mode 100644 index 0000000000..7a9521b14c --- /dev/null +++ b/Task/Binary-digits/TI-83-BASIC/binary-digits-1.ti-83 @@ -0,0 +1,19 @@ +PROGRAM:BINARY +:Disp "NUMBER TO" +:Disp "CONVERT:" +:Input A +:0→N +:0→B +:While 2^(N+1)≤A +:N+1→N +:End +:While N≥0 +:iPart(A/2^N)→C +:10^(N)*C+B→B +:If C=1 +:Then +:A-2^N→A +:End +:N-1→N +:End +:Disp B diff --git a/Task/Binary-digits/TI-83-BASIC/binary-digits-2.ti-83 b/Task/Binary-digits/TI-83-BASIC/binary-digits-2.ti-83 new file mode 100644 index 0000000000..bd69ea23cd --- /dev/null +++ b/Task/Binary-digits/TI-83-BASIC/binary-digits-2.ti-83 @@ -0,0 +1,9 @@ +PROGRAM:BINARY +:Input X +:" "→Str1 +:Repeat X=0 + :X/2→X + :sub("01",2fPart(X)+1,1)+Str1→Str1 + :iPart(X)→X +:End +:Str1 diff --git a/Task/Binary-digits/TI-83-BASIC/binary-digits-3.ti-83 b/Task/Binary-digits/TI-83-BASIC/binary-digits-3.ti-83 new file mode 100644 index 0000000000..d5e0dac65f --- /dev/null +++ b/Task/Binary-digits/TI-83-BASIC/binary-digits-3.ti-83 @@ -0,0 +1,5 @@ +PROGRAM:BINARY +:Disp "NUMBER TO" +:Disp "CONVERT" +:Input "Str1" +:Disp real(25,Str1,10,2) diff --git a/Task/Binary-digits/Tcl/binary-digits-1.tcl b/Task/Binary-digits/Tcl/binary-digits-1.tcl new file mode 100644 index 0000000000..0168796234 --- /dev/null +++ b/Task/Binary-digits/Tcl/binary-digits-1.tcl @@ -0,0 +1,6 @@ +proc num2bin num { + # Convert to _fixed width_ big-endian 32-bit binary + binary scan [binary format "I" $num] "B*" binval + # Strip useless leading zeros by reinterpreting as a big decimal integer + scan $binval "%lld" +} diff --git a/Task/Binary-digits/Tcl/binary-digits-2.tcl b/Task/Binary-digits/Tcl/binary-digits-2.tcl new file mode 100644 index 0000000000..655dcebebe --- /dev/null +++ b/Task/Binary-digits/Tcl/binary-digits-2.tcl @@ -0,0 +1,7 @@ +for {set x 0} {$x < 16} {incr x} { + puts [num2bin $x] +} +puts "--------------" +puts [num2bin 5] +puts [num2bin 50] +puts [num2bin 9000] diff --git a/Task/Binary-digits/UNIX-Shell/binary-digits.sh b/Task/Binary-digits/UNIX-Shell/binary-digits.sh new file mode 100644 index 0000000000..a97ea8c526 --- /dev/null +++ b/Task/Binary-digits/UNIX-Shell/binary-digits.sh @@ -0,0 +1,9 @@ +# Define a function to output binary digits +tobinary() { + # We use the bench calculator for our conversion + echo "obase=2;$1"|bc +} + +# Call the function with each of our values +tobinary 5 +tobinary 50 diff --git a/Task/Binary-digits/Vedit-macro-language/binary-digits.vedit b/Task/Binary-digits/Vedit-macro-language/binary-digits.vedit new file mode 100644 index 0000000000..c1ed9e3034 --- /dev/null +++ b/Task/Binary-digits/Vedit-macro-language/binary-digits.vedit @@ -0,0 +1,17 @@ +repeat (ALL) { + #10 = Get_Num("Give a numeric value, -1 to end: ", STATLINE) + if (#10 < 0) { break } + Call("BINARY") + Update() +} +return + +:BINARY: +do { + Num_Ins(#10 & 1, LEFT+NOCR) + #10 = #10 >> 1 + Char(-1) +} while (#10 > 0) +EOL +Ins_Newline +Return diff --git a/Task/Binary-digits/Visual-Basic-.NET/binary-digits.visual b/Task/Binary-digits/Visual-Basic-.NET/binary-digits.visual new file mode 100644 index 0000000000..b0d34bbb3d --- /dev/null +++ b/Task/Binary-digits/Visual-Basic-.NET/binary-digits.visual @@ -0,0 +1,5 @@ +Sub Main() + Console.WriteLine("5: " & Convert.ToString(5, 2)) + Console.WriteLine("50: " & Convert.ToString(50, 2)) + Console.WriteLine("9000: " & Convert.ToString(9000, 2)) +End Sub diff --git a/Task/Binary-digits/Whitespace/binary-digits-1.ws b/Task/Binary-digits/Whitespace/binary-digits-1.ws new file mode 100644 index 0000000000..09c0ba967e --- /dev/null +++ b/Task/Binary-digits/Whitespace/binary-digits-1.ws @@ -0,0 +1 @@ + diff --git a/Task/Binary-digits/Whitespace/binary-digits-2.ws b/Task/Binary-digits/Whitespace/binary-digits-2.ws new file mode 100644 index 0000000000..16acb3c5de --- /dev/null +++ b/Task/Binary-digits/Whitespace/binary-digits-2.ws @@ -0,0 +1,33 @@ +push 0 +; Increment indefinitely. +0: + push -1 ; Sentinel value so the printer knows when to stop. + copy 1 + call 1 + push 10 + ochr + push 1 + add + jump 0 +; Get the binary digits on the stack in reverse order. +1: + dup + push 2 + mod + swap + push 2 + div + push 0 + copy 1 + sub + jn 1 + pop +; Print them. +2: + dup + jn 3 ; Stop at the sentinel. + onum + jump 2 +3: + pop + ret diff --git a/Task/Binary-digits/X86-Assembly/binary-digits.x86 b/Task/Binary-digits/X86-Assembly/binary-digits.x86 new file mode 100644 index 0000000000..bae58c5b75 --- /dev/null +++ b/Task/Binary-digits/X86-Assembly/binary-digits.x86 @@ -0,0 +1,29 @@ + .model tiny + .code + .486 + org 100h +start: mov ax, 5 + call binout + call crlf + mov ax, 50 + call binout + call crlf + mov ax, 9000 + call binout + +crlf: mov al, 0Dh ;new line + int 29h + mov al, 0Ah + int 29h + ret + +binout: push ax + shr ax, 1 + je bo10 + call binout +bo10: pop ax + and al, 01h + or al, '0' + int 29h ;display character + ret + end start diff --git a/Task/Binary-digits/XPL0/binary-digits.xpl0 b/Task/Binary-digits/XPL0/binary-digits.xpl0 new file mode 100644 index 0000000000..32bda99bc3 --- /dev/null +++ b/Task/Binary-digits/XPL0/binary-digits.xpl0 @@ -0,0 +1,17 @@ +include c:\cxpl\codes; \intrinsic code declarations + +proc BinOut(N); \Output N in binary +int N; +int R; +[R:= N&1; +N:= N>>1; +if N then BinOut(N); +ChOut(0, R+^0); +]; + +int I; +[I:= 0; +repeat BinOut(I); CrLf(0); + I:= I+1; +until KeyHit or I=0; +] diff --git a/Task/Binary-digits/ZX-Spectrum-Basic/binary-digits.zx b/Task/Binary-digits/ZX-Spectrum-Basic/binary-digits.zx new file mode 100644 index 0000000000..5ea8115ea9 --- /dev/null +++ b/Task/Binary-digits/ZX-Spectrum-Basic/binary-digits.zx @@ -0,0 +1,14 @@ +10 LET n=5: GO SUB 1000: PRINT s$ +20 LET n=50: GO SUB 1000: PRINT s$ +30 LET n=9000: GO SUB 1000: PRINT s$ +999 STOP +1000 REM convert to binary +1010 LET t=n: REM temporary variable +1020 LET s$="": REM this will contain our binary digits +1030 LET sf=0: REM output has not started yet +1040 FOR l=126 TO 0 STEP -1 +1050 LET d$="0": REM assume next digit is zero +1060 IF t>=(2^l) THEN LET d$="1": LET t=t-(2^l): LET sf=1 +1070 IF (sf <> 0) THEN LET s$=s$+d$ +1080 NEXT l +1090 RETURN diff --git a/Task/Brownian-tree/0DESCRIPTION b/Task/Brownian-tree/0DESCRIPTION new file mode 100644 index 0000000000..25d48e3f8c --- /dev/null +++ b/Task/Brownian-tree/0DESCRIPTION @@ -0,0 +1,9 @@ +Generate and draw a [[wp:Brownian tree|Brownian Tree]]. + +A Brownian Tree is generated as a result of an initial seed, followed by the interaction of two processes. + +# The initial "seed" is placed somewhere within the field. Where is not particularly important; it could be randomized, or it could be a fixed point. +# Particles are injected into the field, and are individually given a (typically random) motion pattern. +# When a particle collides with the seed or tree, its position is fixed, and it's considered to be part of the tree. + +Because of the lax rules governing the random nature of the particle's placement and motion, no two resulting trees are really expected to be the same, or even necessarily have the same general shape. diff --git a/Task/Brownian-tree/1META.yaml b/Task/Brownian-tree/1META.yaml new file mode 100644 index 0000000000..77e833cb39 --- /dev/null +++ b/Task/Brownian-tree/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Raster graphics operations +note: Fractals diff --git a/Task/Brownian-tree/AutoHotkey/brownian-tree.ahk b/Task/Brownian-tree/AutoHotkey/brownian-tree.ahk new file mode 100644 index 0000000000..c96caf1207 --- /dev/null +++ b/Task/Brownian-tree/AutoHotkey/brownian-tree.ahk @@ -0,0 +1,53 @@ +SetBatchLines -1 +Process, Priority,, high +size := 400 +D := .08 +num := size * size * d +field:= Object() +field[size//2, size//2] := true ; set the seed +lost := 0 + +Loop % num +{ + x := Rnd(1, size), y := Rnd(1, size) + Loop + { + oldX := X, oldY := Y + x += Rnd(-1, 1), y += Rnd(1, -1) + If ( field[x, y] ) + { + field[oldX, oldY] := true + break + } + If ( X > Size ) or ( Y > Size) or ( X < 1 ) or ( Y < 1 ) + { + lost++ + break + } + } +} + +pToken := Gdip_startup() +pBitmap := Gdip_CreateBitmap(size, size) +loop %size% +{ + x := A_index + Loop %size% + { + If ( field[x, A_Index] ) + { + Gdip_SetPixel(pBitmap, x, A_Index, 0xFF0000FF) + } + } +} +Gdip_SaveBitmapToFile(pBitmap, "brownian.png") +Gdip_DisposeImage(pBitmap) +Gdip_Shutdown(pToken) +Run brownian.png + +MsgBox lost %lost% + +Rnd(min, max){ + Random, r, min, max + return r +} diff --git a/Task/Brownian-tree/BBC-BASIC/brownian-tree.bbc b/Task/Brownian-tree/BBC-BASIC/brownian-tree.bbc new file mode 100644 index 0000000000..6f564fb57b --- /dev/null +++ b/Task/Brownian-tree/BBC-BASIC/brownian-tree.bbc @@ -0,0 +1,27 @@ + SYS "SetWindowText", @hwnd%, "Brownian Tree" + SIZE = 400 + + VDU 23,22,SIZE;SIZE;8,16,16,0 + GCOL 10 + + REM set the seed: + PLOT SIZE, SIZE + + OFF + REPEAT + + REM set particle's initial position: + REPEAT + X% = RND(SIZE)-1 + Y% = RND(SIZE)-1 + UNTIL POINT(2*X%,2*Y%) = 0 + + REPEAT + oldX% = X% + oldY% = Y% + X% += RND(3) - 2 + Y% += RND(3) - 2 + UNTIL POINT(2*X%,2*Y%) + IF X%>=0 IF X%=0 IF Y% +#include +#include +#include +#include + +#define NUM_PARTICLES 1000 +#define SIZE 800 + +void draw_brownian_tree(int world[SIZE][SIZE]){ + int px, py; // particle values + int dx, dy; // offsets + int i; + + // set the seed + world[rand() % SIZE][rand() % SIZE] = 1; + + for (i = 0; i < NUM_PARTICLES; i++){ + // set particle's initial position + px = rand() % SIZE; + py = rand() % SIZE; + + while (1){ + // randomly choose a direction + dx = rand() % 3 - 1; + dy = rand() % 3 - 1; + + if (dx + px < 0 || dx + px >= SIZE || dy + py < 0 || dy + py >= SIZE){ + // plop the particle into some other random location + px = rand() % SIZE; + py = rand() % SIZE; + }else if (world[py + dy][px + dx] != 0){ + // bumped into something + world[py][px] = 1; + break; + }else{ + py += dy; + px += dx; + } + } + } +} + +int main(){ + int world[SIZE][SIZE]; + FIBITMAP * img; + RGBQUAD rgb; + int x, y; + + memset(world, 0, sizeof world); + srand((unsigned)time(NULL)); + + draw_brownian_tree(world); + + img = FreeImage_Allocate(SIZE, SIZE, 32, 0, 0, 0); + + for (y = 0; y < SIZE; y++){ + for (x = 0; x < SIZE; x++){ + rgb.rgbRed = rgb.rgbGreen = rgb.rgbBlue = (world[y][x] ? 255 : 0); + FreeImage_SetPixelColor(img, x, y, &rgb); + } + } + FreeImage_Save(FIF_BMP, img, "brownian_tree.bmp", 0); + FreeImage_Unload(img); +} diff --git a/Task/Brownian-tree/C/brownian-tree-2.c b/Task/Brownian-tree/C/brownian-tree-2.c new file mode 100644 index 0000000000..c40d9ba75c --- /dev/null +++ b/Task/Brownian-tree/C/brownian-tree-2.c @@ -0,0 +1,43 @@ +#include +#include +#include +#include + +#define SIDE 600 +#define NUM_PARTICLES 10000 + +bool W[SIDE][SIDE]; + +int main() { + srand((unsigned)time(NULL)); + W[SIDE / 2][SIDE / 2] = true; + + for (int i = 0; i < NUM_PARTICLES; i++) { + unsigned int x, y; + OVER: do { + x = rand() % (SIDE - 2) + 1; + y = rand() % (SIDE - 2) + 1; + } while (W[y][x]); + + while (W[y-1][x-1] + W[y-1][x] + W[y-1][x+1] + + W[y][x-1] + W[y][x+1] + + W[y+1][x-1] + W[y+1][x] + W[y+1][x+1] == 0) { + unsigned int dxy = rand() % 8; + if (dxy > 3) dxy++; + x += (dxy % 3) - 1; + y += (dxy / 3) - 1; + if (x < 1 || x >= SIDE - 1 || y < 1 || y >= SIDE - 1) + goto OVER; + } + + W[y][x] = true; + } + + printf("P1\n%d %d\n", SIDE, SIDE); + for (int r = 0; r < SIDE; r++) { + for (int c = 0; c < SIDE; c++) + printf("%d ", W[r][c]); + putchar('\n'); + } + return 0; +} diff --git a/Task/Brownian-tree/D/brownian-tree.d b/Task/Brownian-tree/D/brownian-tree.d new file mode 100644 index 0000000000..d3e22b487f --- /dev/null +++ b/Task/Brownian-tree/D/brownian-tree.d @@ -0,0 +1,38 @@ +import core.stdc.stdio, std.random, grayscale_image; + +enum uint side = 600; // Square world side. +enum uint num_particles = 1_000; +static assert(side > 2 && num_particles < (side ^^ 2 * 0.7)); + +void main() { + auto rng = Xorshift(unpredictableSeed); + ubyte[side][side] W; // World. + W[side / 2][side / 2] = 1; // Set tree root. + + foreach (immutable _; 0 .. num_particles) { + // Random initial particle position. + OVER: uint x, y; + do { + x = uniform(1, side - 1, rng); + y = uniform(1, side - 1, rng); + } while (W[y][x]); // Assure the chosen cell is empty. + + while (W[y-1][x-1] + W[y-1][x] + W[y-1][x+1] + + W[y][x-1] + W[y][x+1] + + W[y+1][x-1] + W[y+1][x] + W[y+1][x+1] == 0) { + // Randomly choose a direction (Moore neighborhood). + uint dxy = uniform(0, 8, rng); + if (dxy > 3) dxy++; // To avoid the center. + x += (dxy % 3) - 1; + y += (dxy / 3) - 1; + if (x < 1 || x >= side - 1 || y < 1 || y >= side - 1) + goto OVER; + } + + W[y][x] = 1; // Touched, set the cell. + } + + ubyte[] data = (&W[0][0])[0 .. side ^^ 2]; // Flat view. + data[] += 255; + Image!ubyte.fromData(data, side,side).savePGM("brownian_tree.pgm"); +} diff --git a/Task/Brownian-tree/Delphi/brownian-tree.delphi b/Task/Brownian-tree/Delphi/brownian-tree.delphi new file mode 100644 index 0000000000..60731c894c --- /dev/null +++ b/Task/Brownian-tree/Delphi/brownian-tree.delphi @@ -0,0 +1,54 @@ +const + SIZE = 256; + NUM_PARTICLES = 1000; + +procedure TForm1.Button1Click(Sender: TObject); +type + TByteArray = array[0..0] of Byte; + PByteArray = ^TByteArray; +var + B: TBitmap; + I: Integer; + P, D: TPoint; +begin + Randomize; + B := TBitmap.Create; + try + B.Width := SIZE; + B.Height := SIZE; + B.PixelFormat := pf8bit; + + B.Canvas.Brush.Color := clBlack; + B.Canvas.FillRect(B.Canvas.ClipRect); + B.Canvas.Pixels[Random(SIZE), Random(SIZE)] := clWhite; + + For I := 0 to NUM_PARTICLES - 1 do + Begin + P.X := Random(SIZE); + P.Y := Random(SIZE); + + While true do + Begin + D.X := Random(3) - 1; + D.Y := Random(3) - 1; + Inc(P.X, D.X); + Inc(P.Y, D.Y); + + If ((P.X or P.Y) < 0) or (P.X >= SIZE) or (P.Y >= SIZE) Then + Begin + P.X := Random(SIZE); + P.Y := Random(SIZE); + end + else if PByteArray(B.ScanLine[P.Y])^[P.X] <> 0 then + begin + PByteArray(B.ScanLine[P.Y-D.Y])^[P.X-D.X] := $FF; + Break; + end; + end; + end; + + Canvas.Draw(0, 0, B); + finally + FreeAndNil(B); + end; +end; diff --git a/Task/Brownian-tree/Fantom/brownian-tree.fantom b/Task/Brownian-tree/Fantom/brownian-tree.fantom new file mode 100644 index 0000000000..f9b6fbbf7b --- /dev/null +++ b/Task/Brownian-tree/Fantom/brownian-tree.fantom @@ -0,0 +1,101 @@ +using fwt +using gfx + +class Main +{ + public static Void main () + { + particles := Particles (300, 200) + 1000.times { particles.addParticle } // add 1000 particles + Window // open up a display for the final tree + { + title = "Brownian Tree" + EdgePane + { + center = ScrollPane { content = ParticleCanvas(particles) } + }, + }.open + } +} + +class Particles +{ + Bool[][] image + Int height + Int width + + new make (Int height, Int width) + { + this.height = height + this.width = width + // set up initial image as an array of booleans with one set cell + image = [,] + width.times |w| + { + row := [,] + height.times { row.add (false) } + image.add (row) + } + image[Int.random(0..= ll ) .and. ( v <= ul ) + end function bounded + + + subroutine draw_brownian_tree(w) + integer, dimension(:,:), intent(inout) :: w + + integer :: px, py, dx, dy, i + integer :: xsize, ysize + + xsize = size(w, 1) + ysize = size(w, 2) + + w(randbetween(1, xsize), randbetween(1, ysize)) = 1 + + do i = 1, num_particles + px = randbetween(1, xsize) + py = randbetween(1, ysize) + + do + dx = randbetween(-1, 1) + dy = randbetween(-1, 1) + if ( .not. bounded(dx+px, 1, xsize) .or. .not. bounded(dy+py, 1, ysize) ) then + px = randbetween(1, xsize) + py = randbetween(1, ysize) + else if ( w(px+dx, py+dy) /= 0 ) then + w(px, py) = 1 + exit + else + py = py + dy + px = px + dx + end if + end do + end do + + end subroutine draw_brownian_tree + +end program diff --git a/Task/Brownian-tree/Go/brownian-tree-1.go b/Task/Brownian-tree/Go/brownian-tree-1.go new file mode 100644 index 0000000000..fca42678c5 --- /dev/null +++ b/Task/Brownian-tree/Go/brownian-tree-1.go @@ -0,0 +1,85 @@ +package main + +import ( + "fmt" + "image" + "image/color" + "image/png" + "math/rand" + "os" +) + +const w = 400 // image width +const h = 300 // image height +const n = 15000 // number of particles to add +const frost = 255 // white + +var g *image.Gray + +func main() { + g = image.NewGray(image.Rectangle{image.Point{0, 0}, image.Point{w, h}}) + // off center seed position makes pleasingly asymetrical tree + g.SetGray(w/3, h/3, color.Gray{frost}) +generate: + for a := 0; a < n; { + // generate random position for new particle + rp := image.Point{rand.Intn(w), rand.Intn(h)} + if g.At(rp.X, rp.Y).(color.Gray).Y == frost { + // position is already set. find a nearby free position. + for { + rp.X += rand.Intn(3) - 1 + rp.Y += rand.Intn(3) - 1 + // execpt if we run out of bounds, consider the particle lost. + if !rp.In(g.Rect) { + continue generate + } + if g.At(rp.X, rp.Y).(color.Gray).Y != frost { + break + } + } + } else { + // else particle is in free space. let it wander + // until it touches tree + for !hasNeighbor(rp) { + rp.X += rand.Intn(3) - 1 + rp.Y += rand.Intn(3) - 1 + // but again, if it wanders out of bounds consider it lost. + if !rp.In(g.Rect) { + continue generate + } + } + } + // x, y now specify a free position toucing the tree. + g.SetGray(rp.X, rp.Y, color.Gray{frost}) + a++ + // progress indicator + if a%100 == 0 { + fmt.Println(a, "of", n) + } + } + f, err := os.Create("tree.png") + if err != nil { + fmt.Println(err) + return + } + err = png.Encode(f, g) + if err != nil { + fmt.Println(err) + } + f.Close() +} + +var n8 = []image.Point{ + {-1, -1}, {-1, 0}, {-1, 1}, + {0, -1}, {0, 1}, + {1, -1}, {1, 0}, {1, 1}} + +func hasNeighbor(p image.Point) bool { + for _, n := range n8 { + o := p.Add(n) + if o.In(g.Rect) && g.At(o.X, o.Y).(color.Gray).Y == frost { + return true + } + } + return false +} diff --git a/Task/Brownian-tree/Go/brownian-tree-2.go b/Task/Brownian-tree/Go/brownian-tree-2.go new file mode 100644 index 0000000000..e67e53a251 --- /dev/null +++ b/Task/Brownian-tree/Go/brownian-tree-2.go @@ -0,0 +1,79 @@ +package main + +// Files required to build supporting package raster are found in: +// * Bitmap +// * Grayscale image +// * Write a PPM file + +import ( + "fmt" + "math/rand" + "raster" +) + +const w = 400 // image width +const h = 300 // image height +const n = 15000 // number of particles to add +const frost = 65535 // white + +var g *raster.Grmap + +func main() { + g = raster.NewGrmap(w, h) + // off center seed position makes pleasingly asymetrical tree + g.SetPx(w/3, h/3, frost) + var x, y int +generate: + for a := 0; a < n; { + // generate random position for new particle + x, y = rand.Intn(w), rand.Intn(h) + switch p, ok := g.GetPx(x, y); p { + case frost: + // position is already set. find a nearby free position. + for p == frost { + x += rand.Intn(3) - 1 + y += rand.Intn(3) - 1 + p, ok = g.GetPx(x, y) + + // execpt if we run out of bounds, consider the particle lost. + if !ok { + continue generate + } + } + default: + // else particle is in free space. let it wander + // until it touches tree + for !hasNeighbor(x, y) { + x += rand.Intn(3) - 1 + y += rand.Intn(3) - 1 + // but again, if it wanders out of bounds consider it lost. + _, ok = g.GetPx(x, y) + if !ok { + continue generate + } + } + } + // x, y now specify a free position toucing the tree. + g.SetPx(x, y, frost) + a++ + // progress indicator + if a%100 == 0 { + fmt.Println(a, "of", n) + } + } + g.Bitmap().WritePpmFile("tree.ppm") +} + +var n8 = [][]int{ + {-1, -1}, {-1, 0}, {-1, 1}, + { 0, -1}, { 0, 1}, + { 1, -1}, { 1, 0}, { 1, 1}} + +func hasNeighbor(x, y int) bool { + for _, n := range n8 { + if p, ok := g.GetPx(x+n[0], y+n[1]); ok && p == frost { + return true + } + } + return false +} diff --git a/Task/Brownian-tree/Haskell/brownian-tree.hs b/Task/Brownian-tree/Haskell/brownian-tree.hs new file mode 100644 index 0000000000..158de7da24 --- /dev/null +++ b/Task/Brownian-tree/Haskell/brownian-tree.hs @@ -0,0 +1,46 @@ +import Control.Monad +import Control.Monad.ST +import Data.STRef +import Data.Array.ST +import System.Random +import Bitmap +import Bitmap.BW +import Bitmap.Netpbm + +main = do + g <- getStdGen + (t, _) <- stToIO $ drawTree (50, 50) (25, 25) 300 g + writeNetpbm "/tmp/tree.pbm" t + +drawTree :: (Int, Int) -> (Int, Int) -> Int -> StdGen -> ST s (Image s BW, StdGen) +drawTree (width, height) start steps stdgen = do + img <- image width height off + setPix img (Pixel start) on + gen <- newSTRef stdgen + let -- randomElem :: [a] -> ST s a + randomElem l = do + stdgen <- readSTRef gen + let (i, stdgen') = randomR (0, length l - 1) stdgen + writeSTRef gen stdgen' + return $ l !! i + -- newPoint :: ST s (Int, Int) + newPoint = do + p <- randomElem border + c <- getPix img $ Pixel p + if c == off then return p else newPoint + -- wander :: (Int, Int) -> ST s () + wander p = do + next <- randomElem $ filter (inRange pointRange) $ adjacent p + c <- getPix img $ Pixel next + if c == on then setPix img (Pixel p) on else wander next + replicateM_ steps $ newPoint >>= wander + stdgen <- readSTRef gen + return (img, stdgen) + where pointRange = ((0, 0), (width - 1, height - 1)) + adjacent (x, y) = [(x - 1, y - 1), (x, y - 1), (x + 1, y - 1), + (x - 1, y), (x + 1, y), + (x - 1, y + 1), (x, y + 1), (x + 1, y + 1)] + border = liftM2 (,) [0, width - 1] [0 .. height - 1] ++ + liftM2 (,) [1 .. width - 2] [0, height - 1] + off = black + on = white diff --git a/Task/Brownian-tree/Icon/brownian-tree.icon b/Task/Brownian-tree/Icon/brownian-tree.icon new file mode 100644 index 0000000000..34c26769ad --- /dev/null +++ b/Task/Brownian-tree/Icon/brownian-tree.icon @@ -0,0 +1,66 @@ +link graphics,printf + +procedure main() # brownian tree + +Density := .08 # % particles to area +SeedArea := .5 # central area to confine seed +ParticleArea := .7 # central area to exclude particles appearing +Height := Width := 400 # canvas + +Particles := Height * Width * Density +Field := list(Height) +every !Field := list(Width) + +Size := sprintf("size=%d,%d",Width,Height) +Fg := sprintf("fg=%s",?["green","red","blue"]) +Label := sprintf("label=Brownian Tree %dx%d PA=%d%% SA=%d%% D=%d%%", + Width,Height,ParticleArea*100,SeedArea*100,Density*100) +WOpen(Label,Size,Fg,"bg=black") | stop("Unable to open Window") + +sx := Height * SetInside(SeedArea) +sy := Width * SetInside(SeedArea) +Field[sx,sy] := 1 +DrawPoint(sx,sy) # Seed the field + +Lost := 0 + +every 1 to Particles do { + repeat { + px := Height * SetOutside(ParticleArea) + py := Width * SetOutside(ParticleArea) + if /Field[px,py] then + break # don't materialize in the tree + } + repeat { + dx := delta() + dy := delta() + if not ( xy := Field[px+dx,py+dy] ) then { + Lost +:= 1 + next # lost try again + } + if \xy then + break # collision + + px +:= dx # move to clear spot + py +:= dy + } + Field[px,py] := 1 + DrawPoint(px,py) # Stick the particle + } +printf("Brownian Tree Complete: Particles=%d Lost=%d.\n",Particles,Lost) +WDone() +end + +procedure delta() #: return a random 1 pixel perturbation + return integer(?0 * 3) - 1 +end + +procedure SetInside(core) #: set coord inside area + return core * ?0 + (1-core)/2 +end + +procedure SetOutside(core) #: set coord outside area + pt := ?0 * (1 - core) + pt +:= ( pt > (1-core)/2, core) + return pt +end diff --git a/Task/Brownian-tree/J/brownian-tree-1.j b/Task/Brownian-tree/J/brownian-tree-1.j new file mode 100644 index 0000000000..5cc44c9bfd --- /dev/null +++ b/Task/Brownian-tree/J/brownian-tree-1.j @@ -0,0 +1,19 @@ +brtr=:4 :0 + seed=. ?x + clip=. 0 >. (<:x) <."1 ] + near=. [: clip +"1/&(,"0/~i:1) + p=.i.0 2 + mask=. 1 (<"1 near seed)} x$0 + field=.1 ( particles; + static Random rand = new Random(); + + public BrownianTree() { + super("Brownian Tree"); + setBounds(100, 100, 400, 300); + setDefaultCloseOperation(EXIT_ON_CLOSE); + I = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB); + I.setRGB(I.getWidth() / 2, I.getHeight() / 2, 0xff00); + particles = new LinkedList(); + } + + @Override + public void paint(Graphics g) { + g.drawImage(I, 0, 0, this); + } + + public void run() { + for (int i = 0; i < 20000; i++) { + particles.add(new Particle()); + } + while (!particles.isEmpty()) { + for (Iterator it = particles.iterator(); it.hasNext();) { + if (it.next().move()) { + it.remove(); + } + } + repaint(); + } + } + + public static void main(String[] args) { + BrownianTree b = new BrownianTree(); + b.setVisible(true); + new Thread(b).start(); + } + + private class Particle { + + private int x, y; + + private Particle() { + x = rand.nextInt(I.getWidth()); + y = rand.nextInt(I.getHeight()); + } + + /* returns true if either out of bounds or collided with tree */ + private boolean move() { + int dx = rand.nextInt(3) - 1; + int dy = rand.nextInt(3) - 1; + if ((x + dx < 0) || (y + dy < 0) + || (y + dy >= I.getHeight()) || (x + dx >= I.getWidth())) { + return true; + } + x += dx; + y += dy; + if ((I.getRGB(x, y) & 0xff00) == 0xff00) { + I.setRGB(x - dx, y - dy, 0xff00); + return true; + } + return false; + } + } +} diff --git a/Task/Brownian-tree/JavaScript/brownian-tree-1.js b/Task/Brownian-tree/JavaScript/brownian-tree-1.js new file mode 100644 index 0000000000..3a21c18f49 --- /dev/null +++ b/Task/Brownian-tree/JavaScript/brownian-tree-1.js @@ -0,0 +1,128 @@ +function brownian(canvasId, messageId) { + var canvas = document.getElementById(canvasId); + var ctx = canvas.getContext("2d"); + + // Options + var drawPos = true; + var seedResolution = 50; + var clearShade = 0; // 0..255 + + // Static state + var width = canvas.width; + var height = canvas.height; + var cx = width/2; + var cy = height/2; + var clearStyle = "rgba("+clearShade+", "+clearShade+", "+clearShade+", 1)"; + + // Utilities + function radius(x,y) { + return Math.sqrt((x-cx)*(x-cy)+(y-cx)*(y-cy)); + } + function test(x, y) { + if (x < 0 || y < 0 || x >= width || y >= height) + return false; + var data = ctx.getImageData(x, y, 1, 1).data; + return data[0] != clearShade || data[1] != clearShade || data[2] != clearShade; + } + var shade = 120; + function setc(x, y, c) { + //var imgd = ctx.createImageData(1, 1); + //var pix = imgd.data; + //pix[0] = pix[1] = pix[2] = c == 255 ? 255 : shade; + //pix[3] = 255; + //shade = (shade + 1) % 254; + //ctx.putImageData(imgd, x, y); + //ctx.fillStyle = "rgba("+c+", "+c+", "+c+", 1)"; + shade = (shade + 0.02) % 360; + if (c) { + ctx.fillStyle = "hsl("+shade+", 100%, 50%)"; + } else { + ctx.fillStyle = clearStyle; + } + ctx.fillRect (x, y, 1, 1); + } + function set(x,y) { + setc(x,y,true); + } + function clear(x,y) { + setc(x,y,false); + } + + // Initialize canvas to blank opaque + ctx.fillStyle = clearStyle; + ctx.fillRect (0, 0, width, height); + + // Current position + var x; + var y; + + // Farthest distance from center a particle has yet been placed. + var closeRadius = 1; + + // Place seed + set(cx, cy); + + // Choose a new random position for a particle (not necessarily unoccupied) + function newpos() { + // Wherever particles are injected, the tree will tend to grow faster + // toward it. Ideally, particles wander in from infinity; the best we + // could do is to have them wander in from the edge of the field. + // But in order to have the rendering occur in a reasonable time when + // the seed is small, without too much visible bias, we instead place + // the particles in a coarse grid. The final tree will cover every + // point on the grid. + // + // There's probably a better strategy than this. + x = Math.floor(Math.random()*(width/seedResolution))*seedResolution; + y = Math.floor(Math.random()*(height/seedResolution))*seedResolution; + } + newpos(); + + var animation; + animation = window.setInterval(function () { + if (drawPos) clear(x,y); + for (var i = 0; i < 10000; i++) { + var ox = x; + var oy = y; + + // Changing this to use only the first four directions will result + // in a denser tree. + switch (Math.floor(Math.random()*8)) { + case 0: x++; break; + case 1: x--; break; + case 2: y++; break; + case 3: y--; break; + case 4: x++; y++; break; + case 5: x--; y++; break; + case 6: x++; y--; break; + case 7: x--; y--; break; + } + if (x < 0 || y < 0 || + x >= width || y >= height || + radius(x,y) > closeRadius+seedResolution+2) { + // wandered out of bounds or out of interesting range of the + // tree, so pick a new spot + var progress = 1000; + do { + newpos(); + progress--; + } while ((test(x-1,y-1) || test(x,y-1) || test(x+1,y-1) || + test(x-1,y ) || test(x,y ) || test(x+1,y ) || + test(x-1,y+1) || test(x,y+1) || test(x+1,y+1)) && progress > 0); + if (progress <= 0) { + document.getElementById(messageId).appendChild(document.createTextNode("Stopped for lack of room.")); + clearInterval(animation); + break; + } + } + if (test(x, y)) { + // hit something, mark where we came from and pick a new spot + set(ox,oy); + closeRadius = Math.max(closeRadius, radius(ox,oy)); + newpos(); + } + } + if (drawPos) set(x,y); + }, 1); + +} diff --git a/Task/Brownian-tree/JavaScript/brownian-tree-2.js b/Task/Brownian-tree/JavaScript/brownian-tree-2.js new file mode 100644 index 0000000000..e08c33cf00 --- /dev/null +++ b/Task/Brownian-tree/JavaScript/brownian-tree-2.js @@ -0,0 +1,9 @@ + + + + + + +
+ + diff --git a/Task/Brownian-tree/Liberty-BASIC/brownian-tree.liberty b/Task/Brownian-tree/Liberty-BASIC/brownian-tree.liberty new file mode 100644 index 0000000000..27181f8244 --- /dev/null +++ b/Task/Brownian-tree/Liberty-BASIC/brownian-tree.liberty @@ -0,0 +1,83 @@ +'[RC]Brownian motion tree + nomainwin + dim screen(600,600) + WindowWidth = 600 + WindowHeight = 600 + open "Brownian" for graphics_nsb_nf as #1 + #1 "trapclose [quit]" + #1 "down ; fill blue" + rad=57.29577951 + particles=500 + + 'draw starting circle and mid point + for n= 1 to 360 + x=300-(200*sin(n/rad)) + y=300-(200*cos(n/rad)) + #1, "color white ; set ";x;" ";y + screen(x,y)=1 + next n + #1, "color white ; set 300 300" + screen(300,300)=1 + + 'set up initial particles + dim particle(particles,9)'x y deltax deltay rotx roty + for n = 1 to particles + gosub [randomparticle] + next + + 'start timed drawing loop + timer 17, [draw] + wait + + + [draw] + #1 "discard" + scan + for n = 1 to particles + oldx=particle(n,1) + oldy=particle(n,2) + + 'erase particle + if not(screen(oldx,oldy)) then + #1 "color blue ; set ";oldx;" ";oldy + end if + + 'move particle x + particle(n,1)=particle(n,1)+int((sin(particle(n,6)/rad)*10)+particle(n,3)) + particle(n,5)=particle(n,5)+6 mod 360 + if particle(n,1)>599 or particle(n,1)<1 then gosub [randomparticle] + + 'move particle y + particle(n,2)=particle(n,2)+int((sin(particle(n,5)/rad)*10)+particle(n,4)) + particle(n,6)=particle(n,6)+6 mod 360 + if particle(n,2)>599 or particle(n,2)<1 then gosub [randomparticle] + + 'checkhit + x=particle(n,1) + y=particle(n,2) + if screen(x-1,y-1) or screen(x-1,y) or screen(x-1,y+1)_ + or screen(x,y-1) or screen(x,y) or screen(x,y+1)_ + or screen(x+1,y-1) or screen(x+1,y) or screen(x+1,y+1) then + #1 "color white ; set ";particle(n,1);" ";particle(n,2) + screen(particle(n,1),particle(n,2))=1 + else + #1 "color red ; set ";particle(n,1);" ";particle(n,2) + end if + next + wait + + + + [randomparticle] + particle(n,1)=int(rnd(0)*599)+1 + particle(n,2)=int(rnd(0)*599)+1 + particle(n,3)=int(2-rnd(0)*4) + particle(n,4)=int(2-rnd(0)*4) + particle(n,5)=int(rnd(0)*360) + particle(n,6)=int(rnd(0)*360) + return + + [quit] + timer 0 + close #1 + end diff --git a/Task/Brownian-tree/Lua/brownian-tree.lua b/Task/Brownian-tree/Lua/brownian-tree.lua new file mode 100644 index 0000000000..49e3ca8829 --- /dev/null +++ b/Task/Brownian-tree/Lua/brownian-tree.lua @@ -0,0 +1,67 @@ +function SetSeed( f ) + for i = 1, #f[1] do -- the whole boundary of the scene is used as the seed + f[1][i] = 1 + f[#f][i] = 1 + end + for i = 1, #f do + f[i][1] = 1 + f[i][#f[1]] = 1 + end +end + +function SetParticle( f ) + local pos_x, pos_y + repeat + pos_x = math.random( #f ) + pos_y = math.random( #f[1] ) + until f[pos_x][pos_y] == 0 + + return pos_x, pos_y +end + + +function Iterate( f, num_particles ) + for i = 1, num_particles do + local pos_x, pos_y = SetParticle( f ) + + while true do + local dx = math.random(5) - 3 + local dy = math.random(5) - 3 + + if ( pos_x+dx >= 1 and pos_x+dx <= #f and pos_y+dy >= 1 and pos_y+dy <= #f[1] ) then + if f[pos_x+dx][pos_y+dy] ~= 0 then + f[pos_x][pos_y] = 1 + break + else + pos_x = pos_x + dx + pos_y = pos_y + dy + end + end + end + end +end + + +size_x, size_y = 400, 400 -- size of the scene +num_particles = 16000 + +math.randomseed( os.time() ) + +f = {} +for i = 1, size_x do + f[i] = {} + for j = 1, size_y do + f[i][j] = 0 + end +end + +SetSeed( f ) +Iterate( f, num_particles ) + +-- prepare the data for writing into a ppm-image file +for i = 1, size_x do + for j = 1, size_y do + if f[i][j] == 1 then f[i][j] = 255 end + end +end +Write_PPM( "brownian_tree.ppm", ConvertToColorImage(f) ) diff --git a/Task/Brownian-tree/Mathematica/brownian-tree.math b/Task/Brownian-tree/Mathematica/brownian-tree.math new file mode 100644 index 0000000000..fdc82aea25 --- /dev/null +++ b/Task/Brownian-tree/Mathematica/brownian-tree.math @@ -0,0 +1,26 @@ +canvasdim = 1000; +n = 0.35*canvasdim^2; +canvas = ConstantArray[0, {canvasdim, canvasdim}]; +init = Floor@(0.5*{canvasdim, canvasdim}); (*RandomInteger[canvasdim,2]*) +canvas[[init[[1]], init[[2]]]] = 1; (*1st particle initialized to midpoint*) + +Monitor[ (*Provides real-time intermediate result monitoring*) + Do[ + particle = RandomInteger[canvasdim, 2]; + While[True, + ds = RandomInteger[{-1, 1}, 2]; + While[ (*New Particle Domain Limit Section*) + !And @@ (0 < (particle + ds)[[#]] <= canvasdim & /@ {1, 2}), + particle = RandomInteger[canvasdim, 2]; + ]; + (* Particle Aggregation Section *) + If[canvas[[(particle + ds)[[1]], (particle + ds)[[2]]]] > 0, + canvas[[particle[[1]], particle[[2]]]] = i; + Break[], + particle += ds + ]; + ], + {i, n}], + {i, (particle + ds), MatrixPlot@canvas} + ] +MatrixPlot[canvas,FrameTicks->None,ColorFunction->"DarkRainbow",ColorRules->{0 -> None}] diff --git a/Task/Brownian-tree/OCaml/brownian-tree.ocaml b/Task/Brownian-tree/OCaml/brownian-tree.ocaml new file mode 100644 index 0000000000..095eb7cbb6 --- /dev/null +++ b/Task/Brownian-tree/OCaml/brownian-tree.ocaml @@ -0,0 +1,48 @@ +let world_width = 400 +let world_height = 400 +let num_particles = 20_000 + +let () = + assert(num_particles > 0); + assert(world_width * world_height > num_particles); +;; + +let dla ~world = + (* put the tree seed *) + world.(world_height / 2).(world_width / 2) <- 1; + + for i = 1 to num_particles do + (* looping helper function *) + let rec aux px py = + (* randomly choose a direction *) + let dx = (Random.int 3) - 1 (* offsets *) + and dy = (Random.int 3) - 1 in + + if dx + px < 0 || dx + px >= world_width || + dy + py < 0 || dy + py >= world_height then + (* plop the particle into some other random location *) + aux (Random.int world_width) (Random.int world_height) + else if world.(py + dy).(px + dx) <> 0 then + (* bumped into something, particle set *) + world.(py).(px) <- 1 + else + aux (px + dx) (py + dy) + in + (* set particle's initial position *) + aux (Random.int world_width) (Random.int world_height) + done + +let to_pbm ~world = + print_endline "P1"; (* Type=Portable bitmap, Encoding=ASCII *) + Printf.printf "%d %d\n" world_width world_height; + Array.iter (fun line -> + Array.iter print_int line; + print_newline() + ) world + +let () = + Random.self_init(); + let world = Array.make_matrix world_width world_height 0 in + dla ~world; + to_pbm ~world; +;; diff --git a/Task/Brownian-tree/Octave/brownian-tree.octave b/Task/Brownian-tree/Octave/brownian-tree.octave new file mode 100644 index 0000000000..ad33987f49 --- /dev/null +++ b/Task/Brownian-tree/Octave/brownian-tree.octave @@ -0,0 +1,27 @@ +function r = browniantree(xsize, ysize = xsize, numparticle = 1000) + r = zeros(xsize, ysize, "uint8"); + r(unidrnd(xsize), unidrnd(ysize)) = 1; + + for i = 1:numparticle + px = unidrnd(xsize-1)+1; + py = unidrnd(ysize-1)+1; + while(1) + dx = unidrnd(2) - 1; + dy = unidrnd(2) - 1; + if ( (dx+px < 1) || (dx+px > xsize) || (dy+py < 1) || (dy+py > ysize) ) + px = unidrnd(xsize-1)+1; + py = unidrnd(ysize-1)+1; + elseif ( r(px+dx, py+dy) != 0 ) + r(px, py) = 1; + break; + else + px += dx; + py += dy; + endif + endwhile + endfor +endfunction + +r = browniantree(200); +r( r > 0 ) = 255; +jpgwrite("browniantree.jpg", r, 100); % image package diff --git a/Task/Brownian-tree/Perl/brownian-tree.pl b/Task/Brownian-tree/Perl/brownian-tree.pl new file mode 100644 index 0000000000..fa3488b28d --- /dev/null +++ b/Task/Brownian-tree/Perl/brownian-tree.pl @@ -0,0 +1,158 @@ +sub PI() { atan2(1,1) * 4 } # The, er, pi +sub STEP() { .5 } # How far does the particle move each step. Affects + # both speed and accuracy greatly +sub STOP_RADIUS() { 100 } # When the tree reaches this far from center, end + +# At each step, move this much towards center. Bigger numbers help the speed because +# particles are less likely to wander off, but greatly affects tree shape. +# Should be between 0 and 1 ish. Set to 0 for pain. +sub ATTRACT() { .2 } + +my @particles = map([ map([], 0 .. 2 * STOP_RADIUS) ], 0 .. 2 * STOP_RADIUS); +push @{ $particles[STOP_RADIUS][STOP_RADIUS] }, [0, 0]; + +my $r_start = 3; +my $max_dist = 0; + +sub dist2 { + my ($dx, $dy) = ($_[0][0] - $_[1][0], $_[0][1] - $_[1][1]); + $dx * $dx + $dy * $dy +} + +sub move { + my $p = shift; + # moved too far, kill particle + # return if dist2($p, [0, 0]) > 2 * $r_start * $r_start; + $p->[0] += 2 * $r_start while $p->[0] < -$r_start; + $p->[0] -= 2 * $r_start while $p->[0] > $r_start; + $p->[1] += 2 * $r_start while $p->[1] < -$r_start; + $p->[1] -= 2 * $r_start while $p->[1] > $r_start; + + my ($ix, $iy) = (int($p->[0]), int($p->[1])); + my $dist = 2 * $r_start * $r_start; + my $nearest; + + # see if the particle is close enough to stick to an exist one + for ($ix - 1 .. $ix + 1) { + my $idx = STOP_RADIUS + $_; + next if $idx > 2 * STOP_RADIUS || $idx < 0; + my $xs = $particles[ $idx ]; + for ($iy - 1 .. $iy + 1) { + my $idx = STOP_RADIUS + $_; + next if $idx > 2 * STOP_RADIUS || $idx < 0; + for (@{ $xs->[ $idx ] }) { + my $d = dist2($p, $_); + next if $d > 2; + next if $d > $dist; + + $dist = $d; + $nearest = $_; + } + } + } + + # yes, found one + if ($nearest) { + my $displace = [ $p->[0] - $nearest->[0], + $p->[1] - $nearest->[1] ]; + my $angle = atan2($displace->[1], $displace->[0]); + $p->[0] = $nearest->[0] + cos($angle); + $p->[1] = $nearest->[1] + sin($angle); + + push @{$particles[$ix + STOP_RADIUS][$iy + STOP_RADIUS]}, [ @$p ]; + $dist = sqrt dist2($p); + + if ($dist + 10 > $r_start && $r_start < STOP_RADIUS + 10) { + $r_start = $dist + 10 + } + if (int($dist + 1) > $max_dist) { + $max_dist = int($dist + 1); + # write_eps(); + # system('pstopnm -portrait -xborder 0 -yborder 0 test.eps 2> /dev/null'); + # system('pnmtopng test.eps001.ppm 2>/dev/null > test.png'); + return 3 if $max_dist >= STOP_RADIUS; + } + return 2; + } + + # random walk + my $angle = rand(2 * PI); + $p->[0] += STEP * cos($angle); + $p->[1] += STEP * sin($angle); + + # drag particle towards center by some distance + my $nudge; + if (sqrt(dist2($p, [0, 0])) > STOP_RADIUS + 1) { + $nudge = 1; + } else { + $nudge = STEP * ATTRACT; + } + + if ($nudge) { + $angle = atan2($p->[1], $p->[0]); + $p->[0] -= $nudge * cos($angle); + $p->[1] -= $nudge * sin($angle); + } + + return 1; +} + +my $count; +PARTICLE: while (1) { + my $a = rand(2 * PI); + my $p = [ $r_start * cos($a), $r_start * sin($a) ]; + while ($_ = move($p)) { + given ($_) { + when (1) { next } + when (2) { $count++; last; } + when (3) { last PARTICLE } + default { last } + } + } + print STDERR "$count $max_dist/@{[int($r_start)]}/@{[STOP_RADIUS]}\r" unless $count% 7; +} + +sub write_eps { + my $size = 128; + my $p = $size / (STOP_RADIUS * 1.05); + my $b = STOP_RADIUS * $p; + if ($p < 1) { + $size = STOP_RADIUS * 1.05; + $b = STOP_RADIUS; + $p = 1; + } + + my $hp = $p / 2; + + open OUT, ">", "test.eps"; + + # print EPS to standard out + print OUT <<"HEAD"; +%!PS-Adobe-3.0 EPSF-3.0 +%%BoundingBox: 0 0 @{[$size*2, $size*2]} +$size $size translate +/l{ rlineto }def +/c{ $hp 0 360 arc fill }def +-$size -$size moveto +$size 2 mul 0 l +0 $size 2 mul l +-$size 2 mul 0 l +closepath +0 setgray fill +0 setlinewidth .1 setgray 0 0 $b 0 360 arc stroke +.8 setgray /TimesRoman findfont 16 scalefont setfont +-$size 10 add $size -16 add moveto +(Step = @{[STEP]} Attract = @{[ATTRACT]}) show +0 1 0 setrgbcolor newpath +HEAD + + for (@particles) { + for (@$_) { + printf OUT "%.3g %.3g c ", map { $_ * $p } @$_ for @$_; + } + } + print OUT "\n%%EOF"; + close OUT; +} + +write_eps; diff --git a/Task/Brownian-tree/PicoLisp/brownian-tree.l b/Task/Brownian-tree/PicoLisp/brownian-tree.l new file mode 100644 index 0000000000..7cf4b01398 --- /dev/null +++ b/Task/Brownian-tree/PicoLisp/brownian-tree.l @@ -0,0 +1,19 @@ +(load "@lib/simul.l") + +(de brownianTree (File Size Cnt) + (let Img (grid Size Size) + (put Img (/ Size 2) (/ Size 2) 'pix T) + (use (P Q) + (do Cnt + (setq P (get Img (rand 1 Size) (rand 1 Size))) + (loop + (setq Q ((if2 (rand T) (rand T) north east south west) P)) + (T (; Q pix) (put P 'pix T)) + (setq P (or Q (get Img (rand 1 Size) (rand 1 Size)))) ) ) ) + (out "img.pbm" + (prinl "P1") + (prinl Size " " Size) + (for L Img + (for This L + (prin (if (: pix) 1 0)) ) + (prinl) ) ) ) ) diff --git a/Task/Brownian-tree/PureBasic/brownian-tree.purebasic b/Task/Brownian-tree/PureBasic/brownian-tree.purebasic new file mode 100644 index 0000000000..d8e77dccb4 --- /dev/null +++ b/Task/Brownian-tree/PureBasic/brownian-tree.purebasic @@ -0,0 +1,39 @@ +#Window1 = 0 +#Image1 = 0 +#ImgGadget = 0 + +#NUM_PARTICLES = 3000 +#width = 200 +#height = 200 +#xmax = #width -3 +#ymax = #height -3 +Define.i Event ,i ,x,y + +If OpenWindow(#Window1, 0, 0, #width, #height, "Brownian Tree PureBasic Example", #PB_Window_SystemMenu ) + If CreateImage(#Image1, #width, #height) + ImageGadget(#ImgGadget, 0, 0, #width, #height, ImageID(#Image1)) + StartDrawing(ImageOutput(#Image1)) + FrontColor($FFFFFF) + Plot( Random(#xmax) , Random(#ymax )) + StopDrawing() + SetGadgetState(#ImgGadget, ImageID(#Image1)) + For i = 1 To #NUM_PARTICLES + x = Random(#xmax)+1 : y = Random (#ymax)+1 + StartDrawing(ImageOutput(#Image1)) + While Point(x+1, y+1) + Point(x, y+1)+Point(x+1, y)+Point(x-1, y-1)+Point(x-1, y)+Point(x, y-1) = 0 + x = x + (Random(2)-1) : y = y + (Random(2)-1) + If x < 1 Or x > #xmax Or y < 1 Or y > #ymax + x = Random(#xmax)+1 : y = Random (#ymax)+1 + EndIf + Wend + Plot(x,y) + StopDrawing() + SetGadgetState(#ImgGadget, ImageID(#Image1)) + Next + + EndIf + + Repeat + Event = WaitWindowEvent() + Until Event = #PB_Event_CloseWindow +EndIf diff --git a/Task/Brownian-tree/Python/brownian-tree.py b/Task/Brownian-tree/Python/brownian-tree.py new file mode 100644 index 0000000000..e6239ef438 --- /dev/null +++ b/Task/Brownian-tree/Python/brownian-tree.py @@ -0,0 +1,101 @@ +import pygame, sys, os +from pygame.locals import * +from random import randint +pygame.init() + +MAXSPEED = 15 +SIZE = 3 +COLOR = (45, 90, 45) +WINDOWSIZE = 400 +TIMETICK = 1 +MAXPART = 50 + +freeParticles = pygame.sprite.Group() +tree = pygame.sprite.Group() + +window = pygame.display.set_mode((WINDOWSIZE, WINDOWSIZE)) +pygame.display.set_caption("Brownian Tree") + +screen = pygame.display.get_surface() + + +class Particle(pygame.sprite.Sprite): + def __init__(self, vector, location, surface): + pygame.sprite.Sprite.__init__(self) + self.vector = vector + self.surface = surface + self.accelerate(vector) + self.add(freeParticles) + self.rect = pygame.Rect(location[0], location[1], SIZE, SIZE) + self.surface.fill(COLOR, self.rect) + + def onEdge(self): + if self.rect.left <= 0: + self.vector = (abs(self.vector[0]), self.vector[1]) + elif self.rect.top <= 0: + self.vector = (self.vector[0], abs(self.vector[1])) + elif self.rect.right >= WINDOWSIZE: + self.vector = (-abs(self.vector[0]), self.vector[1]) + elif self.rect.bottom >= WINDOWSIZE: + self.vector = (self.vector[0], -abs(self.vector[1])) + + def update(self): + if freeParticles in self.groups(): + self.surface.fill((0,0,0), self.rect) + self.remove(freeParticles) + if pygame.sprite.spritecollideany(self, freeParticles): + self.accelerate((randint(-MAXSPEED, MAXSPEED), + randint(-MAXSPEED, MAXSPEED))) + self.add(freeParticles) + elif pygame.sprite.spritecollideany(self, tree): + self.stop() + else: + self.add(freeParticles) + + self.onEdge() + + if (self.vector == (0,0)) and tree not in self.groups(): + self.accelerate((randint(-MAXSPEED, MAXSPEED), + randint(-MAXSPEED, MAXSPEED))) + self.rect.move_ip(self.vector[0], self.vector[1]) + self.surface.fill(COLOR, self.rect) + + def stop(self): + self.vector = (0,0) + self.remove(freeParticles) + self.add(tree) + + def accelerate(self, vector): + self.vector = vector + +NEW = USEREVENT + 1 +TICK = USEREVENT + 2 + +pygame.time.set_timer(NEW, 50) +pygame.time.set_timer(TICK, TIMETICK) + + +def input(events): + for event in events: + if event.type == QUIT: + sys.exit(0) + elif event.type == NEW and (len(freeParticles) < MAXPART): + Particle((randint(-MAXSPEED,MAXSPEED), + randint(-MAXSPEED,MAXSPEED)), + (randint(0, WINDOWSIZE), randint(0, WINDOWSIZE)), + screen) + elif event.type == TICK: + freeParticles.update() + + +half = WINDOWSIZE/2 +tenth = WINDOWSIZE/10 + +root = Particle((0,0), + (randint(half-tenth, half+tenth), + randint(half-tenth, half+tenth)), screen) +root.stop() + +while True: + input(pygame.event.get()) + pygame.display.flip() diff --git a/Task/Brownian-tree/REXX/brownian-tree.rexx b/Task/Brownian-tree/REXX/brownian-tree.rexx new file mode 100644 index 0000000000..817748d5df --- /dev/null +++ b/Task/Brownian-tree/REXX/brownian-tree.rexx @@ -0,0 +1,108 @@ +/*REXX program shows brownian motion of dust in a field with one seed. */ +parse arg height width motes . +if height=='' | height==',' then height=0 +if width=='' | width==',' then width=0 +if motes=='' then motes='10%' /*nn% Calculate # of dust motes.*/ + /* ... otherwise just the number.*/ +tree ='*' /*an affixed dust speck (tree). */ +mote ='fa'x /*char for a loose mote (of dust)*/ +empty=' ' /*char for an empty spot in field*/ +clearScr='CLS' /*(DOS?) command to clear screen.*/ +eons=1000000 /*time limit for browian movement*/ +snapshot=0 /*every n winks, show snapshot.*/ +snaptime=2 /*every n secs, show snapshot.*/ +seedPos=30 45 /*place seed in this field pos. */ +seedPos=0 /*if =0, use middle of the field.*/ + /*if -1, use random placement. */ + /*otherwise, place it at seedPos.*/ +randseed=0 /*set RANDSEED for repeatability.*/ +if randseed\==0 then call random ,,randseed /*set the 1st random num.*/ + +if height==0 | width==0 then _=scrsize() /*not all REXXes have SCRSIZE.*/ +if height==0 then height=word(_,1)-3 +if width==0 then width=word(_,2)-1 + + seedAt=seedPos +if seedPos== 0 then seedAt=width%2 height%2 +if seedPos==-1 then seedAt=random(1,width) random(1,height) +parse var seedAt xs ys . + +if right(motes,1)=='%' then motes=height*width*strip(motes,,'%')%100 +@.=empty /*create the field, all empty. */ + + do j=1 for motes /*sprinkle dust motes randomly. */ + rx=random(1, width); ry=random(1,height); @.rx.ry=mote + end /*j*/ + /*plant the seed from which the */ + /*tree will grow from dust motes */ +@.xs.ys=tree /*that affixed themselves. */ +call show /*show field before we mess it up*/ +tim=0 /*the time (in secs) of last show*/ +loX=1; hiX= width /*used to optimize mote searching*/ +loY=1; hiY=height /* " " " " " */ + + /*═════════════════════════════soooo, this is brownian motion.*/ + do winks=1 for eons until \motion /*EONs is used just in case of ∞.*/ + motion=0 /*turn off brownian motion flag. */ + if snapshot \== 0 then if winks//snapshot==0 then call show + if snaptime \== 0 then do; t=time('S') + if t\==tim & t//snaptime==0 then do + tim=time('s') + call show + end + end + minX=loX; maxX=hiX /*as the tree grows, the search */ + minY=loY; maxY=hiY /* for dust motes gets faster. */ + loX= width; hiX=1 /*used to limit mote searching. */ + loY=height; hiY=1 /* " " " " " */ + + do x =minX to maxX; xm=x-1; xp=x+1 + do y=minY to maxY; if @.x.y\==mote then iterate + if xhiX then hiX=x /*is faster than: hiX=max(X hiX) */ + if yhiY then hiY=y /*is faster than: hiY=max(y hiY) */ + if @.xm.y ==tree then do; @.x.y=tree; iterate; end /*neighbor?*/ + if @.xp.y ==tree then do; @.x.y=tree; iterate; end /*neighbor?*/ + ym=y-1 + if @.x.ym ==tree then do; @.x.y=tree; iterate; end /*neighbor?*/ + if @.xm.ym==tree then do; @.x.y=tree; iterate; end /*neighbor?*/ + if @.xp.ym==tree then do; @.x.y=tree; iterate; end /*neighbor?*/ + yp=y+1 + if @.x.yp ==tree then do; @.x.y=tree; iterate; end /*neighbor?*/ + if @.xm.yp==tree then do; @.x.y=tree; iterate; end /*neighbor?*/ + if @.xp.yp==tree then do; @.x.y=tree; iterate; end /*neighbor?*/ + motion=1 /*brownian motion is coming up. */ + xb=x+random(1,3)-2 /*apply brownian motion for X. */ + yb=y+random(1,3)-2 /*apply brownian motion for Y. */ + if @.xb.yb\==empty then iterate /*can the mote move there ? */ + @.x.y=empty /*"blank" out the old position. */ + @.xb.yb=mote /*move the mote (or possibly not)*/ + if xbhiX then hiX=min( width,xb) + if ybhiY then hiY=min(height,yb) + end /*y*/ + end /*x*/ + call crop + end /*winks*/ + +call show +exit /*stick a fork in it, we're done.*/ +/*────────────────────────────────SHOW subroutine───────────────────────*/ +show: clearScr /*not necessary, but speeds it up*/ + do ys=height by -1 for height; aRow= + do xs=1 for width; aRow=aRow||@.xs.ys + end /*xs*/ + say aRow + end /*ys*/ +return +/*────────────────────────────────CROP subroutine───────────────────────*/ +crop: if loX>1 & hiX1 & hiY= SIZE or dy + py < 0 or dy + py >= SIZE + # plop the particle into some other random location + px = rand SIZE + py = rand SIZE + elsif world[py + dy][px + dx] != 0 + # bumped into something + world[py][px] = 1 + break + else + py += dy + px += dx + end + end + end +end + +world = Array.new(SIZE) { Array.new(SIZE, 0) } +srand Time.now.to_i + +draw_brownian_tree world + +img = Magick::Image.new(SIZE, SIZE) do + self.background_color = "black" +end + +draw = Magick::Draw.new +draw.fill "white" + +world.each_with_index do |row, y| + row.each_with_index do |colour, x| + draw.point x, y if colour != 0 + end +end + +draw.draw img +img.write "brownian_tree.bmp" diff --git a/Task/Brownian-tree/Run-BASIC/brownian-tree.run b/Task/Brownian-tree/Run-BASIC/brownian-tree.run new file mode 100644 index 0000000000..0302035fb2 --- /dev/null +++ b/Task/Brownian-tree/Run-BASIC/brownian-tree.run @@ -0,0 +1,26 @@ +numParticles = 3000 +dim canvas(201,201) +canvas(rnd(1) * 100 , rnd(1) * 200) = 1 'start point +for i = 1 To numParticles + x = (rnd(1) * 199) + 1 + y = (rnd(1) * 199) + 1 + + while canvas(x+1, y+1) + canvas(x, y+1)+canvas(x+1, y)+canvas(x-1, y-1)+canvas(x-1, y)+canvas(x, y-1) = 0 + x = x + (rnd(1)* 2) + 1 + y = y + (rnd(1)* 2) + 1 + If x < 1 Or x > 200 Or y < 1 Or y > 200 then + x = (rnd(1) * 199) + 1 + y = (rnd(1) * 199) + 1 + end if + wend + canvas(x,y) = 1 +next i + +graphic #g, 200,200 +for x = 1 to 200 + for y = 1 to 200 + if canvas(x,y) = 1 then #g "color green ; set "; x; " "; y else #g "color blue ; set "; x; " "; y + next y +next x +render #g +#g "flush" diff --git a/Task/Brownian-tree/Scheme/brownian-tree.ss b/Task/Brownian-tree/Scheme/brownian-tree.ss new file mode 100644 index 0000000000..b924ac4f54 --- /dev/null +++ b/Task/Brownian-tree/Scheme/brownian-tree.ss @@ -0,0 +1,108 @@ +; Save bitmap to external file +(define (save-pbm bitmap filename) + (define f (open-output-file filename)) + (simple-format f "P1\n~A ~A\n" + (list-ref (array-dimensions bitmap) 0) + (list-ref (array-dimensions bitmap) 1)) + (do ((c 0 (+ c 1))) ((eqv? c (list-ref (array-dimensions bitmap) 1))) + (do ((r 0 (+ r 1))) ((eqv? r (list-ref (array-dimensions bitmap) 0))) + (display (array-ref bitmap r c) f)) + (newline f)) + (close-output-port f) +) + +; Return a random coordinate in the bitmap that isn't filled yet along with a direction +(define (new-particle bitmap) + (define x (random (list-ref (array-dimensions bitmap) 0))) + (define y (random (list-ref (array-dimensions bitmap) 1))) + (define dx (- (random 3) 1)) + (define dy (- (random 3) 1)) + ;Repeat until we find an unused location + (if (> (array-ref bitmap x y) 0) + (new-particle bitmap) + (list (list x y) (list dx dy)))) + +; Check neighboring coordinates to see if a collision occured +(define (collision-check bitmap p) + (define c #f) + (define oob #f) + (define x (list-ref (car p) 0)) + (define y (list-ref (car p) 1)) + (define dx (list-ref (cadr p) 0)) + (define dy (list-ref (cadr p) 1)) + (define w (list-ref (array-dimensions bitmap) 0)) + (define h (list-ref (array-dimensions bitmap) 1)) + + ; If the particle hasn't gone out of bounds keep checking for a collision + (if (or (> 0 x) (> 0 y) (<= w x) (<= h y)) + (set! oob #t) + (do ((x (- (list-ref (car p) 0) 1) (+ x 1))) ((eqv? x (+ (list-ref (car p) 0) 2))) + (do ((y (- (list-ref (car p) 1) 1) (+ y 1))) ((eqv? y (+ (list-ref (car p) 1) 2))) + ; Check existing neighbors for collisions + (if (and (<= 0 x) (<= 0 y) (> w x) (> h y)) + (if (not (zero? (array-ref bitmap x y))) + (set! c #t)))))) + (if oob + #f ; Return false if out of bounds + (if c + p ; Return the point of collision if a collision occured + (if (and (zero? dx) (zero? dy)) + #f ; Return false if particle is motionless with no collision + (collision-check bitmap (particle-move p)))))) + +; Plot a particle on the bitmap +(define (particle-plot! bitmap p) + (array-set! bitmap 1 (list-ref (car p) 0) (list-ref (car p) 1))) + +; Move a particle along its slope +(define (particle-move p) + (list (list + (+ (list-ref (car p) 0) (list-ref (cadr p) 0)) + (+ (list-ref (car p) 1) (list-ref (cadr p) 1))) + (cadr p))) + +; Grow a brownian tree +(define (grow-brownian-tree! bitmap collisions) + (define w (list-ref (array-dimensions bitmap) 0)) + (define h (list-ref (array-dimensions bitmap) 1)) + + ; Generate a new particle at a random location + (define p (new-particle bitmap)) + + ; Find a collision or lack of one and plot it on the bitmap + (set! p (collision-check bitmap p)) + (if p (begin + ; Display collision number and the place it happened + (display collisions)(display ": ")(display (car p))(newline) + (set! collisions (- collisions 1)) + ; Plot the point + (particle-plot! bitmap p))) + + ; If we're done say so + (if (zero? collisions) + (display "Done\n")) + + ; Keep going until we have enough collisions + ; or have filled the bitmap + (if (and (< 0 collisions) (memq 0 (array->list (array-contents bitmap)))) + (grow-brownian-tree! bitmap collisions))) + +; Plot a random point to seed the brownian tree +(define (seed-brownian-tree! bitmap) + (define p (new-particle bitmap)) + (particle-plot! bitmap p)) + +;;; Example usage ;;; +; Seed the random number generator +(let ((time (gettimeofday))) + (set! *random-state* + (seed->random-state (+ (car time) (cdr time))))) + +; Generate a tree with 320*240 collisions on a bitmap of the size 640x480 +; The bitmap is zeroed to start and written with a one where a collision occurs +(define bitmap (make-array 0 640 480)) +(seed-brownian-tree! bitmap) +(grow-brownian-tree! bitmap (* 320 240)) + +; Save to a portable bitmap file +(save-pbm bitmap "brownian-tree.pbm") diff --git a/Task/Brownian-tree/Seed7/brownian-tree.seed7 b/Task/Brownian-tree/Seed7/brownian-tree.seed7 new file mode 100644 index 0000000000..a3f630fa01 --- /dev/null +++ b/Task/Brownian-tree/Seed7/brownian-tree.seed7 @@ -0,0 +1,53 @@ +$ include "seed7_05.s7i"; + include "draw.s7i"; + include "keybd.s7i"; + +const integer: SIZE is 300; +const integer: SCALE is 1; + +const proc: genBrownianTree (in integer: fieldSize, in integer: numParticles) is func + local + var array array integer: world is 0 times 0 times 0; + var integer: px is 0; + var integer: py is 0; + var integer: dx is 0; + var integer: dy is 0; + var integer: i is 0; + var boolean: bumped is FALSE; + begin + world := fieldSize times fieldSize times 0; + world[rand(1, fieldSize)][rand(1, fieldSize)] := 1; # Set the seed + for i range 1 to numParticles do + # Set particle's initial position + px := rand(1, fieldSize); + py := rand(1, fieldSize); + bumped := FALSE; + repeat + # Randomly choose a direction + dx := rand(-1, 1); + dy := rand(-1, 1); + if dx + px < 1 or dx + px > fieldSize or dy + py < 1 or dy + py > fieldSize then + # Plop the particle into some other random location + px := rand(1, fieldSize); + py := rand(1, fieldSize); + elsif world[py + dy][px + dx] <> 0 then + # Bumped into something + world[py][px] := 1; + rect(SCALE * pred(px), SCALE * pred(py), SCALE, SCALE, white); + DRAW_FLUSH; + bumped := TRUE; + else + py +:= dy; + px +:= dx; + end if; + until bumped; + end for; + end func; + +const proc: main is func + begin + screen(SIZE * SCALE, SIZE * SCALE); + KEYBOARD := GRAPH_KEYBOARD; + genBrownianTree(SIZE, 20000); + readln(KEYBOARD); + end func; diff --git a/Task/Brownian-tree/TI-83-BASIC/brownian-tree.ti-83 b/Task/Brownian-tree/TI-83-BASIC/brownian-tree.ti-83 new file mode 100644 index 0000000000..5a08b79824 --- /dev/null +++ b/Task/Brownian-tree/TI-83-BASIC/brownian-tree.ti-83 @@ -0,0 +1,27 @@ +:StoreGDB 0 +:ClrDraw +:FnOff +:AxesOff +:Pxl-On(31,47) +:For(I,1,50) +:randInt(1,93)→X +:randInt(1,61)→Y +:1→A +:While A +:randInt(1,4)→D +:Pxl-Off(Y,X) +:If D=1 and Y≥2 +:Y-1→Y +:If D=2 and X≤92 +:X+1→X +:If D=3 and Y≤60 +:Y+1→Y +:If D=4 and X≥2 +:X-1→X +:Pxl-On(Y,X) +:If pxl-Test(Y+1,X) or pxl-Test(Y+1,X+1) or pxl-Test(Y+1,X-1) or pxl-Test(Y,X+1) or pxl-Test(Y,X-1) or pxl-Test(Y-1,X) or pxl-Test(Y-1,X-1) or pxl-Test(Y-1,X+1) +:0→A +:End +:End +:Pause +:RecallGDB 0 diff --git a/Task/Brownian-tree/Tcl/brownian-tree.tcl b/Task/Brownian-tree/Tcl/brownian-tree.tcl new file mode 100644 index 0000000000..49130e9b28 --- /dev/null +++ b/Task/Brownian-tree/Tcl/brownian-tree.tcl @@ -0,0 +1,52 @@ +package require Tcl 8.5 +package require Tk + +set SIZE 300 + +image create photo brownianTree -width $SIZE -height $SIZE +interp alias {} plot {} brownianTree put white -to +brownianTree put black -to 0 0 [expr {$SIZE-1}] [expr {$SIZE-1}] +proc rnd {range} {expr {int(rand() * $range)}} + +proc makeBrownianTree count { + global SIZE + # Set the seed + plot [rnd $SIZE] [rnd $SIZE] + for {set i 0} {$i<$count} {incr i} { + # Set a random particle's initial position + set px [rnd $SIZE] + set py [rnd $SIZE] + + while 1 { + # Randomly choose a direction + set dx [expr {[rnd 3] - 1}] + set dy [expr {[rnd 3] - 1}] + + # If we are going out of bounds... + if {$px+$dx < 0 || $px+$dx >= $SIZE || $py+$dy < 0 || $py+$dy>=$SIZE} { + # Out of bounds, so move back in + set dx [expr {[rnd 3] - 1}] + set dy [expr {[rnd 3] - 1}] + continue + } + + set ox $px + set oy $py + # Move/see if we would hit anything + incr px $dx + incr py $dy + if {[lindex [brownianTree get $px $py] 0]} { + # Hit something, so plot where we were + plot $ox $oy + break + } + } + ## For display while things are processing, uncomment next line + #update;puts -nonewline .;flush stdout + } +} + +pack [label .l -image brownianTree] +update +makeBrownianTree 1000 +brownianTree write tree.ppm diff --git a/Task/Brownian-tree/Visual-Basic-.NET/brownian-tree.visual b/Task/Brownian-tree/Visual-Basic-.NET/brownian-tree.visual new file mode 100644 index 0000000000..d775fedd85 --- /dev/null +++ b/Task/Brownian-tree/Visual-Basic-.NET/brownian-tree.visual @@ -0,0 +1,129 @@ +Imports System.Drawing.Imaging + +Public Class Form1 + + ReadOnly iCanvasColor As Integer = Color.Black.ToArgb + ReadOnly iSeedColor As Integer = Color.White.ToArgb + + Dim iCanvasWidth As Integer = 0 + Dim iCanvasHeight As Integer = 0 + + Dim iPixels() As Integer = Nothing + + Private Sub BrownianTree() + + Dim oCanvas As Bitmap = Nothing + Dim oRandom As New Random(Now.Millisecond) + Dim oXY As Point = Nothing + Dim iParticleCount As Integer = 0 + + iCanvasWidth = ClientSize.Width + iCanvasHeight = ClientSize.Height + + oCanvas = New Bitmap(iCanvasWidth, iCanvasHeight, Imaging.PixelFormat.Format24bppRgb) + + Graphics.FromImage(oCanvas).Clear(Color.FromArgb(iCanvasColor)) + + iPixels = GetData(oCanvas) + + ' We'll use about 10% of the total number of pixels in the canvas for the particle count. + iParticleCount = CInt(iPixels.Length * 0.1) + + ' Set the seed to a random location on the canvas. + iPixels(oRandom.Next(iPixels.Length)) = iSeedColor + + ' Run through the particles. + For i As Integer = 0 To iParticleCount + Do + ' Find an open pixel. + oXY = New Point(oRandom.Next(oCanvas.Width), oRandom.Next(oCanvas.Height)) + Loop While iPixels(oXY.Y * oCanvas.Width + oXY.X) = iSeedColor + + ' Jitter until the pixel bumps another. + While Not CheckAdjacency(oXY) + oXY.X += oRandom.Next(-1, 2) + oXY.Y += oRandom.Next(-1, 2) + + ' Make sure we don't jitter ourselves out of bounds. + If oXY.X < 0 Then oXY.X = 0 Else If oXY.X >= oCanvas.Width Then oXY.X = oCanvas.Width - 1 + If oXY.Y < 0 Then oXY.Y = 0 Else If oXY.Y >= oCanvas.Height Then oXY.Y = oCanvas.Height - 1 + End While + + iPixels(oXY.Y * oCanvas.Width + oXY.X) = iSeedColor + + ' If you'd like to see updates as each particle collides and becomes + ' part of the tree, uncomment the next 4 lines (it does slow it down slightly). + ' SetData(oCanvas, iPixels) + ' BackgroundImage = oCanvas + ' Invalidate() + ' Application.DoEvents() + Next + + oCanvas.Save("BrownianTree.bmp") + BackgroundImage = oCanvas + + End Sub + + ' Check adjacent pixels for an illuminated pixel. + Private Function CheckAdjacency(ByVal XY As Point) As Boolean + + Dim n As Integer = 0 + + For y As Integer = -1 To 1 + ' Make sure not to drop off the top or bottom of the image. + If (XY.Y + y < 0) OrElse (XY.Y + y >= iCanvasHeight) Then Continue For + + For x As Integer = -1 To 1 + ' Make sure not to drop off the left or right of the image. + If (XY.X + x < 0) OrElse (XY.X + x >= iCanvasWidth) Then Continue For + + ' Don't run the test on the calling pixel. + If y <> 0 AndAlso x <> 0 Then + n = (XY.Y + y) * iCanvasWidth + (XY.X + x) + If iPixels(n) = iSeedColor Then Return True + End If + Next + Next + + Return False + + End Function + + Private Function GetData(ByVal Map As Bitmap) As Integer() + + Dim oBMPData As BitmapData = Nothing + Dim oData() As Integer = Nothing + + oBMPData = Map.LockBits(New Rectangle(0, 0, Map.Width, Map.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb) + + Array.Resize(oData, Map.Width * Map.Height) + + Runtime.InteropServices.Marshal.Copy(oBMPData.Scan0, oData, 0, oData.Length) + + Map.UnlockBits(oBMPData) + + Return oData + + End Function + + Private Sub SetData(ByVal Map As Bitmap, ByVal Data As Integer()) + + Dim oBMPData As BitmapData = Nothing + + oBMPData = Map.LockBits(New Rectangle(0, 0, Map.Width, Map.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb) + + Runtime.InteropServices.Marshal.Copy(Data, 0, oBMPData.Scan0, Data.Length) + + Map.UnlockBits(oBMPData) + + End Sub + + Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load + DoubleBuffered = True + BackgroundImageLayout = ImageLayout.Center + Show() + Activate() + Application.DoEvents() + BrownianTree() + End Sub +End Class diff --git a/Task/Brownian-tree/XPL0/brownian-tree.xpl0 b/Task/Brownian-tree/XPL0/brownian-tree.xpl0 new file mode 100644 index 0000000000..22c3f37468 --- /dev/null +++ b/Task/Brownian-tree/XPL0/brownian-tree.xpl0 @@ -0,0 +1,18 @@ +include c:\cxpl\codes; \intrinsic 'code' declarations +def W=128, H=W; \width and height of field +int X, Y; +[SetVid($13); \set 320x200 graphic video mode +Point(W/2, H/2, 6\brown\); \place seed in center of field +loop [repeat X:= Ran(W); Y:= Ran(H); \inject particle + until ReadPix(X,Y) = 0; \ in an empty location + loop [Point(X, Y, 6\brown\); \show particle + if ReadPix(X-1,Y) or ReadPix(X+1,Y) or \particle collided + ReadPix(X,Y-1) or ReadPix(X,Y+1) then quit; + Point(X, Y, 0\black\); \erase particle + X:= X + Ran(3)-1; \(Brownian) move particle + Y:= Y + Ran(3)-1; + if X<0 or X>=W or Y<0 or Y>=H then quit; \out of bounds + ]; + if KeyHit then [SetVid(3); quit]; \restore text mode + ]; +] diff --git a/Task/Calendar-for-real-programmers/0DESCRIPTION b/Task/Calendar---for-real-programmers/0DESCRIPTION similarity index 100% rename from Task/Calendar-for-real-programmers/0DESCRIPTION rename to Task/Calendar---for-real-programmers/0DESCRIPTION diff --git a/Task/Calendar-for-real-programmers/1META.yaml b/Task/Calendar---for-real-programmers/1META.yaml similarity index 100% rename from Task/Calendar-for-real-programmers/1META.yaml rename to Task/Calendar---for-real-programmers/1META.yaml 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 similarity index 100% rename from Task/Calendar-for-real-programmers/ALGOL-68/calendar-for-real-programmers.alg rename to Task/Calendar---for-real-programmers/ALGOL-68/calendar---for-real-programmers.alg 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 similarity index 100% rename from Task/Calendar-for-real-programmers/Ada/calendar-for-real-programmers.ada rename to Task/Calendar---for-real-programmers/Ada/calendar---for-real-programmers.ada 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 similarity index 100% rename from Task/Calendar-for-real-programmers/BBC-BASIC/calendar-for-real-programmers.bbc rename to Task/Calendar---for-real-programmers/BBC-BASIC/calendar---for-real-programmers.bbc diff --git a/Task/Calendar-for-real-programmers/GUISS/calendar-for-real-programmers.guiss b/Task/Calendar---for-real-programmers/GUISS/calendar---for-real-programmers.guiss similarity index 100% rename from Task/Calendar-for-real-programmers/GUISS/calendar-for-real-programmers.guiss rename to Task/Calendar---for-real-programmers/GUISS/calendar---for-real-programmers.guiss diff --git a/Task/Calendar-for-real-programmers/Icon/calendar-for-real-programmers-1.icon b/Task/Calendar---for-real-programmers/Icon/calendar---for-real-programmers-1.icon similarity index 100% rename from Task/Calendar-for-real-programmers/Icon/calendar-for-real-programmers-1.icon rename to Task/Calendar---for-real-programmers/Icon/calendar---for-real-programmers-1.icon diff --git a/Task/Calendar-for-real-programmers/Icon/calendar-for-real-programmers-2.icon b/Task/Calendar---for-real-programmers/Icon/calendar---for-real-programmers-2.icon similarity index 100% rename from Task/Calendar-for-real-programmers/Icon/calendar-for-real-programmers-2.icon rename to Task/Calendar---for-real-programmers/Icon/calendar---for-real-programmers-2.icon diff --git a/Task/Calendar-for-real-programmers/J/calendar-for-real-programmers-1.j b/Task/Calendar---for-real-programmers/J/calendar---for-real-programmers-1.j similarity index 100% rename from Task/Calendar-for-real-programmers/J/calendar-for-real-programmers-1.j rename to Task/Calendar---for-real-programmers/J/calendar---for-real-programmers-1.j diff --git a/Task/Calendar-for-real-programmers/J/calendar-for-real-programmers-2.j b/Task/Calendar---for-real-programmers/J/calendar---for-real-programmers-2.j similarity index 100% rename from Task/Calendar-for-real-programmers/J/calendar-for-real-programmers-2.j rename to Task/Calendar---for-real-programmers/J/calendar---for-real-programmers-2.j 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 similarity index 100% rename from Task/Calendar-for-real-programmers/PHP/calendar-for-real-programmers.php rename to Task/Calendar---for-real-programmers/PHP/calendar---for-real-programmers.php diff --git a/Task/Calendar-for-real-programmers/Perl-6/calendar-for-real-programmers.pl6 b/Task/Calendar---for-real-programmers/Perl-6/calendar---for-real-programmers.pl6 similarity index 100% rename from Task/Calendar-for-real-programmers/Perl-6/calendar-for-real-programmers.pl6 rename to Task/Calendar---for-real-programmers/Perl-6/calendar---for-real-programmers.pl6 diff --git a/Task/Calendar-for-real-programmers/Perl/calendar-for-real-programmers-1.pl b/Task/Calendar---for-real-programmers/Perl/calendar---for-real-programmers-1.pl similarity index 100% rename from Task/Calendar-for-real-programmers/Perl/calendar-for-real-programmers-1.pl rename to Task/Calendar---for-real-programmers/Perl/calendar---for-real-programmers-1.pl 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 similarity index 100% rename from Task/Calendar-for-real-programmers/Perl/calendar-for-real-programmers-2.pl rename to Task/Calendar---for-real-programmers/Perl/calendar---for-real-programmers-2.pl 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 similarity index 100% rename from Task/Calendar-for-real-programmers/PicoLisp/calendar-for-real-programmers.l rename to Task/Calendar---for-real-programmers/PicoLisp/calendar---for-real-programmers.l 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 similarity index 100% rename from Task/Calendar-for-real-programmers/REXX/calendar-for-real-programmers.rexx rename to Task/Calendar---for-real-programmers/REXX/calendar---for-real-programmers.rexx 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 similarity index 100% rename from Task/Calendar-for-real-programmers/Ruby/calendar-for-real-programmers-1.rb rename to Task/Calendar---for-real-programmers/Ruby/calendar---for-real-programmers-1.rb 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 similarity index 100% rename from Task/Calendar-for-real-programmers/Ruby/calendar-for-real-programmers-2.rb rename to Task/Calendar---for-real-programmers/Ruby/calendar---for-real-programmers-2.rb 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 similarity index 100% rename from Task/Calendar-for-real-programmers/Tcl/calendar-for-real-programmers.tcl rename to Task/Calendar---for-real-programmers/Tcl/calendar---for-real-programmers.tcl diff --git a/Task/Calendar-for-real-programmers/Vedit-macro-language/calendar-for-real-programmers.vedit b/Task/Calendar---for-real-programmers/Vedit-macro-language/calendar---for-real-programmers.vedit similarity index 100% rename from Task/Calendar-for-real-programmers/Vedit-macro-language/calendar-for-real-programmers.vedit rename to Task/Calendar---for-real-programmers/Vedit-macro-language/calendar---for-real-programmers.vedit diff --git a/Task/Calendar-for-real-programmers/X86-Assembly/calendar-for-real-programmers.x86 b/Task/Calendar---for-real-programmers/X86-Assembly/calendar---for-real-programmers.x86 similarity index 100% rename from Task/Calendar-for-real-programmers/X86-Assembly/calendar-for-real-programmers.x86 rename to Task/Calendar---for-real-programmers/X86-Assembly/calendar---for-real-programmers.x86 diff --git a/Task/Catalan-numbers/0DESCRIPTION b/Task/Catalan-numbers/0DESCRIPTION new file mode 100644 index 0000000000..9a089629db --- /dev/null +++ b/Task/Catalan-numbers/0DESCRIPTION @@ -0,0 +1,13 @@ +Catalan numbers are a sequence of numbers which can be defined directly: +:C_n = \frac{1}{n+1}{2n\choose n} = \frac{(2n)!}{(n+1)!\,n!} \qquad\mbox{ for }n\ge 0. +Or recursively: +:C_0 = 1 \quad \mbox{and} \quad C_{n+1}=\sum_{i=0}^{n}C_i\,C_{n-i}\quad\text{for }n\ge 0; +Or alternatively (also recursive): +:C_0 = 1 \quad \mbox{and} \quad C_n=\frac{2(2n-1)}{n+1}C_{n-1}, + +Implement at least one of these algorithms and print out the first 15 Catalan numbers with each. [[Memoization]] is not required, but may be worth the effort when using the second method above. + +;Cf.: +* [[Pascal's triangle]] +* [http://milan.milanovic.org/math/english/fibo/fibo4.html Catalan Numbers and the Pascal Triangle] +* http://rosettacode.org/wiki/Catalan_numbers#An_Alternative_Approach diff --git a/Task/Catalan-numbers/1META.yaml b/Task/Catalan-numbers/1META.yaml new file mode 100644 index 0000000000..8644b2ad9b --- /dev/null +++ b/Task/Catalan-numbers/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Arithmetic operations diff --git a/Task/Catalan-numbers/AWK/catalan-numbers.awk b/Task/Catalan-numbers/AWK/catalan-numbers.awk new file mode 100644 index 0000000000..ad0092ec0a --- /dev/null +++ b/Task/Catalan-numbers/AWK/catalan-numbers.awk @@ -0,0 +1,16 @@ +# syntax: GAWK -f CATALAN_NUMBERS.AWK +BEGIN { + for (i=0; i<=15; i++) { + printf("%2d %10d\n",i,catalan(i)) + } + exit(0) +} +function catalan(n, ans) { + if (n == 0) { + ans = 1 + } + else { + ans = ((2*(2*n-1))/(n+1))*catalan(n-1) + } + return(ans) +} diff --git a/Task/Catalan-numbers/Ada/catalan-numbers.ada b/Task/Catalan-numbers/Ada/catalan-numbers.ada new file mode 100644 index 0000000000..aa503151a3 --- /dev/null +++ b/Task/Catalan-numbers/Ada/catalan-numbers.ada @@ -0,0 +1,16 @@ +with Ada.Text_IO; use Ada.Text_IO; + +procedure Test_Catalan is + function Catalan (N : Natural) return Natural is + Result : Positive := 1; + begin + for I in 1..N loop + Result := Result * 2 * (2 * I - 1) / (I + 1); + end loop; + return Result; + end Catalan; +begin + for N in 0..15 loop + Put_Line (Integer'Image (N) & " =" & Integer'Image (Catalan (N))); + end loop; +end Test_Catalan; diff --git a/Task/Catalan-numbers/AutoHotkey/catalan-numbers.ahk b/Task/Catalan-numbers/AutoHotkey/catalan-numbers.ahk new file mode 100644 index 0000000000..1cc6e4c4f8 --- /dev/null +++ b/Task/Catalan-numbers/AutoHotkey/catalan-numbers.ahk @@ -0,0 +1,20 @@ +Loop 15 + out .= "`n" Catalan(A_Index) +Msgbox % clipboard := SubStr(out, 2) +catalan( n ) { +; By [VxE]. Returns ((2n)! / ((n + 1)! * n!)) if 0 <= N <= 22 (higher than 22 results in overflow) +If ( n < 3 ) ; values less than 3 are handled specially + Return n < 0 ? "" : n = 0 ? 1 : n + +i := 1 ; initialize the accumulator to 1 + +Loop % n - 1 >> 1 ; build the numerator by multiplying odd values between 2N and N+1 + i *= 1 + ( n - A_Index << 1 ) + +i <<= ( n - 2 >> 1 ) ; multiply the numerator by powers of 2 according to N + +Loop % n - 3 >> 1 ; finish up by (integer) dividing by each of the non-cancelling factors + i //= A_Index + 2 + +Return i +} diff --git a/Task/Catalan-numbers/BASIC/catalan-numbers.basic b/Task/Catalan-numbers/BASIC/catalan-numbers.basic new file mode 100644 index 0000000000..d374bf70f8 --- /dev/null +++ b/Task/Catalan-numbers/BASIC/catalan-numbers.basic @@ -0,0 +1,18 @@ +DECLARE FUNCTION catalan (n as INTEGER) AS SINGLE + +REDIM SHARED results(0) AS SINGLE + +FOR x% = 1 TO 15 + PRINT x%, catalan (x%) +NEXT + +FUNCTION catalan (n as INTEGER) AS SINGLE + IF UBOUND(results) < n THEN REDIM PRESERVE results(n) + + IF 0 = n THEN + results(0) = 1 + ELSE + results(n) = ((2 * ((2 * n) - 1)) / (n + 1)) * catalan(n - 1) + END IF + catalan = results(n) +END FUNCTION diff --git a/Task/Catalan-numbers/BBC-BASIC/catalan-numbers.bbc b/Task/Catalan-numbers/BBC-BASIC/catalan-numbers.bbc new file mode 100644 index 0000000000..403c2ec92d --- /dev/null +++ b/Task/Catalan-numbers/BBC-BASIC/catalan-numbers.bbc @@ -0,0 +1,8 @@ + FOR i% = 1 TO 15 + PRINT FNcatalan(i%) + NEXT + END + + DEF FNcatalan(n%) + IF n% = 0 THEN = 1 + = 2 * (2 * n% - 1) * FNcatalan(n% - 1) / (n% + 1) diff --git a/Task/Catalan-numbers/Bracmat/catalan-numbers-1.bracmat b/Task/Catalan-numbers/Bracmat/catalan-numbers-1.bracmat new file mode 100644 index 0000000000..8429e0891c --- /dev/null +++ b/Task/Catalan-numbers/Bracmat/catalan-numbers-1.bracmat @@ -0,0 +1,55 @@ +( out$straight +& ( C + = + . ( F + = i prod + . !arg:0&1 + | 1:?prod + & 0:?i + & whl + ' ( 1+!i:~>!arg:?i + & !i*!prod:?prod + ) + & !prod + ) + & F$(2*!arg)*(F$(!arg+1)*F$!arg)^-1 + ) +& -1:?n +& whl + ' ( 1+!n:~>15:?n + & out$(str$(C !n " = " C$!n)) + ) +& out$"recursive, with memoization, without fractions" +& :?seenCs +& ( C + = i sum + . !arg:0&1 + | ( !seenCs:? (!arg.?sum) ? + | 0:?sum + & -1:?i + & whl + ' ( 1+!i:15:?n + & out$(str$(C !n " = " C$!n)) + ) +& out$"recursive, without memoization, with fractions" +& ( C + = + . !arg:0&1 + | 2*(2*!arg+-1)*(!arg+1)^-1*C$(!arg+-1) + ) +& -1:?n +& whl + ' ( 1+!n:~>15:?n + & out$(str$(C !n " = " C$!n)) + ) +& +); diff --git a/Task/Catalan-numbers/Bracmat/catalan-numbers-2.bracmat b/Task/Catalan-numbers/Bracmat/catalan-numbers-2.bracmat new file mode 100644 index 0000000000..1644a8a1e4 --- /dev/null +++ b/Task/Catalan-numbers/Bracmat/catalan-numbers-2.bracmat @@ -0,0 +1,51 @@ +straight +C0 = 1 +C1 = 1 +C2 = 2 +C3 = 5 +C4 = 14 +C5 = 42 +C6 = 132 +C7 = 429 +C8 = 1430 +C9 = 4862 +C10 = 16796 +C11 = 58786 +C12 = 208012 +C13 = 742900 +C14 = 2674440 +C15 = 9694845 +recursive, with memoization, without fractions +C0 = 1 +C1 = 1 +C2 = 2 +C3 = 5 +C4 = 14 +C5 = 42 +C6 = 132 +C7 = 429 +C8 = 1430 +C9 = 4862 +C10 = 16796 +C11 = 58786 +C12 = 208012 +C13 = 742900 +C14 = 2674440 +C15 = 9694845 +recursive, without memoization, with fractions +C0 = 1 +C1 = 1 +C2 = 2 +C3 = 5 +C4 = 14 +C5 = 42 +C6 = 132 +C7 = 429 +C8 = 1430 +C9 = 4862 +C10 = 16796 +C11 = 58786 +C12 = 208012 +C13 = 742900 +C14 = 2674440 +C15 = 9694845 diff --git a/Task/Catalan-numbers/Brat/catalan-numbers.brat b/Task/Catalan-numbers/Brat/catalan-numbers.brat new file mode 100644 index 0000000000..6c8e3b8141 --- /dev/null +++ b/Task/Catalan-numbers/Brat/catalan-numbers.brat @@ -0,0 +1,9 @@ +catalan = { n | + true? n == 0 + { 1 } + { (2 * ( 2 * n - 1) / ( n + 1 )) * catalan(n - 1) } +} + +0.to 15 { n | + p "#{n} - #{catalan n}" +} diff --git a/Task/Catalan-numbers/C++/catalan-numbers-1.cpp b/Task/Catalan-numbers/C++/catalan-numbers-1.cpp new file mode 100644 index 0000000000..516fa04aba --- /dev/null +++ b/Task/Catalan-numbers/C++/catalan-numbers-1.cpp @@ -0,0 +1,60 @@ +#if !defined __ALGORITHMS_H__ +#define __ALGORITHMS_H__ + +namespace rosetta + { + namespace catalanNumbers + { + namespace detail + { + + class Factorial + { + public: + unsigned long long operator()(unsigned n)const; + }; + + class BinomialCoefficient + { + public: + unsigned long long operator()(unsigned n, unsigned k)const; + }; + + } //namespace detail + + class CatalanNumbersDirectFactorial + { + public: + CatalanNumbersDirectFactorial(); + unsigned long long operator()(unsigned n)const; + private: + detail::Factorial factorial; + }; + + class CatalanNumbersDirectBinomialCoefficient + { + public: + CatalanNumbersDirectBinomialCoefficient(); + unsigned long long operator()(unsigned n)const; + private: + detail::BinomialCoefficient binomialCoefficient; + }; + + class CatalanNumbersRecursiveSum + { + public: + CatalanNumbersRecursiveSum(); + unsigned long long operator()(unsigned n)const; + }; + + class CatalanNumbersRecursiveFraction + { + public: + CatalanNumbersRecursiveFraction(); + unsigned long long operator()(unsigned n)const; + }; + + } //namespace catalanNumbers + } //namespace rosetta + +#endif //!defined __ALGORITHMS_H__ diff --git a/Task/Catalan-numbers/C++/catalan-numbers-2.cpp b/Task/Catalan-numbers/C++/catalan-numbers-2.cpp new file mode 100644 index 0000000000..62c6e16878 --- /dev/null +++ b/Task/Catalan-numbers/C++/catalan-numbers-2.cpp @@ -0,0 +1,101 @@ +#include +using std::cout; +using std::endl; +#include +using std::floor; + +#include "algorithms.h" +using namespace rosetta::catalanNumbers; + + +CatalanNumbersDirectFactorial::CatalanNumbersDirectFactorial() + { + cout<<"Direct calculation using the factorial"<1) + { + unsigned long long nFac = factorial(n); + return factorial(2 * n) / ((n + 1) * nFac * nFac); + } + else + { + return 1; + } + } + + +CatalanNumbersDirectBinomialCoefficient::CatalanNumbersDirectBinomialCoefficient() + { + cout<<"Direct calculation using a binomial coefficient"<1) + return double(1) / (n + 1) * binomialCoefficient(2 * n, n); + else + return 1; + } + + +CatalanNumbersRecursiveSum::CatalanNumbersRecursiveSum() + { + cout<<"Recursive calculation using a sum"<1) + { + const unsigned n_ = n - 1; + unsigned long long sum = 0; + for(unsigned i = 0; i <= n_; i++) + sum += operator()(i) * operator()(n_ - i); + return sum; + } + else + { + return 1; + } + } + + +CatalanNumbersRecursiveFraction::CatalanNumbersRecursiveFraction() + { + cout<<"Recursive calculation using a fraction"<1) + return (double(2 * (2 * n - 1)) / (n + 1)) * operator()(n-1); + else + return 1; + } + + +unsigned long long detail::Factorial::operator()(unsigned n)const + { + if(n>1) + return n * operator()(n-1); + else + return 1; + } + + +unsigned long long detail::BinomialCoefficient::operator()(unsigned n, unsigned k)const + { + if(k == 0) + return 1; + + if(n == 0) + return 0; + + double product = 1; + for(unsigned i = 1; i <= k; i++) + product *= (double(n - (k - i)) / i); + return (unsigned long long)(floor(product + 0.5)); + } diff --git a/Task/Catalan-numbers/C++/catalan-numbers-3.cpp b/Task/Catalan-numbers/C++/catalan-numbers-3.cpp new file mode 100644 index 0000000000..442a7c0e41 --- /dev/null +++ b/Task/Catalan-numbers/C++/catalan-numbers-3.cpp @@ -0,0 +1,26 @@ +#if !defined __TESTER_H__ +#define __TESTER_H__ + +#include + +namespace rosetta + { + namespace catalanNumbers + { + + template + class Test + { + public: + static void Do() + { + A algorithm; + for(int i = 0; i <= N; i++) + std::cout<<"C("<::Do(); + Test<15, CatalanNumbersDirectBinomialCoefficient>::Do(); + Test<15, CatalanNumbersRecursiveFraction>::Do(); + Test<15, CatalanNumbersRecursiveSum>::Do(); + return 0; + } diff --git a/Task/Catalan-numbers/C++/catalan-numbers-5.cpp b/Task/Catalan-numbers/C++/catalan-numbers-5.cpp new file mode 100644 index 0000000000..ebe93400fe --- /dev/null +++ b/Task/Catalan-numbers/C++/catalan-numbers-5.cpp @@ -0,0 +1,16 @@ +// Generate Catalan Numbers +// +// Nigel Galloway: June 9th., 2012 +// +#include +int main() { + const int N = 15; + int t[N+2] = {0,1}; + for(int i = 1; i<=N; i++){ + for(int j = i; j>1; j--) t[j] = t[j] + t[j-1]; + t[i+1] = t[i]; + for(int j = i+1; j>1; j--) t[j] = t[j] + t[j-1]; + std::cout << t[i+1] - t[i] << " "; + } + return 0; +} diff --git a/Task/Catalan-numbers/C/catalan-numbers-1.c b/Task/Catalan-numbers/C/catalan-numbers-1.c new file mode 100644 index 0000000000..e53382ede7 --- /dev/null +++ b/Task/Catalan-numbers/C/catalan-numbers-1.c @@ -0,0 +1,46 @@ +#include + +typedef unsigned long long ull; + +ull binomial(ull m, ull n) +{ + ull r = 1, d = m - n; + if (d > n) { n = d; d = m - n; } + + while (m > n) { + r *= m--; + while (d > 1 && ! (r%d) ) r /= d--; + } + + return r; +} + +ull catalan1(int n) { + return binomial(2 * n, n) / (1 + n); +} + +ull catalan2(int n) { + int i; + ull r = !n; + + for (i = 0; i < n; i++) + r += catalan2(i) * catalan2(n - 1 - i); + return r; +} + +ull catalan3(int n) +{ + return n ? 2 * (2 * n - 1) * catalan3(n - 1) / (1 + n) : 1; +} + +int main(void) +{ + int i; + puts("\tdirect\tsumming\tfrac"); + for (i = 0; i < 16; i++) { + printf("%d\t%llu\t%llu\t%llu\n", i, + catalan1(i), catalan2(i), catalan3(i)); + } + + return 0; +} diff --git a/Task/Catalan-numbers/C/catalan-numbers-2.c b/Task/Catalan-numbers/C/catalan-numbers-2.c new file mode 100644 index 0000000000..7ee219e92c --- /dev/null +++ b/Task/Catalan-numbers/C/catalan-numbers-2.c @@ -0,0 +1,114 @@ +namespace CatalanNumbers +{ + /// + /// Class that holds all options. + /// + public class CatalanNumberGenerator + { + private static double Factorial(double n) + { + if (n == 0) + return 1; + + return n * Factorial(n - 1); + } + + public double FirstOption(double n) + { + const double topMultiplier = 2; + return Factorial(topMultiplier * n) / (Factorial(n + 1) * Factorial(n)); + } + + public double SecondOption(double n) + { + if (n == 0) + { + return 1; + } + double sum = 0; + double i = 0; + for (; i <= (n - 1); i++) + { + sum += SecondOption(i) * SecondOption((n - 1) - i); + } + return sum; + } + + public double ThirdOption(double n) + { + if (n == 0) + { + return 1; + } + return ((2 * (2 * n - 1)) / (n + 1)) * ThirdOption(n - 1); + } + } +} + + +// Program.cs +using System; +using System.Configuration; + +// Main program +// Be sure to add the following to the App.config file and add a reference to System.Configuration: +// +// +// +// +// +// +// +namespace CatalanNumbers +{ + class Program + { + static void Main(string[] args) + { + CatalanNumberGenerator generator = new CatalanNumberGenerator(); + int i = 0; + DateTime initial; + DateTime final; + TimeSpan ts; + + try + { + initial = DateTime.Now; + for (; i <= Convert.ToInt32(ConfigurationManager.AppSettings["MaxCatalanNumber"]); i++) + { + Console.WriteLine("CatalanNumber({0}):{1}", i, generator.FirstOption(i)); + } + final = DateTime.Now; + ts = final - initial; + Console.WriteLine("It took {0}.{1} to execute\n", ts.Seconds, ts.Milliseconds); + + i = 0; + initial = DateTime.Now; + for (; i <= Convert.ToInt32(ConfigurationManager.AppSettings["MaxCatalanNumber"]); i++) + { + Console.WriteLine("CatalanNumber({0}):{1}", i, generator.SecondOption(i)); + } + final = DateTime.Now; + ts = final - initial; + Console.WriteLine("It took {0}.{1} to execute\n", ts.Seconds, ts.Milliseconds); + + i = 0; + initial = DateTime.Now; + for (; i <= Convert.ToInt32(ConfigurationManager.AppSettings["MaxCatalanNumber"]); i++) + { + Console.WriteLine("CatalanNumber({0}):{1}", i, generator.ThirdOption(i)); + } + final = DateTime.Now; + ts = final - initial; + Console.WriteLine("It took {0}.{1} to execute", ts.Seconds, ts.Milliseconds, ts.TotalMilliseconds); + Console.ReadLine(); + } + catch (Exception ex) + { + Console.WriteLine("Stopped at index {0}:", i); + Console.WriteLine(ex.Message); + Console.ReadLine(); + } + } + } +} diff --git a/Task/Catalan-numbers/Clojure/catalan-numbers.clj b/Task/Catalan-numbers/Clojure/catalan-numbers.clj new file mode 100644 index 0000000000..57fb520b3a --- /dev/null +++ b/Task/Catalan-numbers/Clojure/catalan-numbers.clj @@ -0,0 +1,17 @@ +(def ! (memoize #(apply * (range 1 (inc %))))) + +(defn catalan-numbers-direct [] + (map #(/ (! (* 2 %)) + (* (! (inc %)) (! %))) (range))) + +(def catalan-numbers-recursive + #(->> [1 1] ; [c0 n1] + (iterate (fn [[c n]] + [(* 2 (dec (* 2 n)) (/ (inc n)) c) (inc n)]) ,) + (map first ,))) + +user> (take 15 (catalan-numbers-direct)) +(1 1 2 5 14 42 132 429 1430 4862 16796 58786 208012 742900 2674440) + +user> (take 15 (catalan-numbers-recursive)) +(1 1 2 5 14 42 132 429 1430 4862 16796 58786 208012 742900 2674440) diff --git a/Task/Catalan-numbers/Common-Lisp/catalan-numbers.lisp b/Task/Catalan-numbers/Common-Lisp/catalan-numbers.lisp new file mode 100644 index 0000000000..90dc815c36 --- /dev/null +++ b/Task/Catalan-numbers/Common-Lisp/catalan-numbers.lisp @@ -0,0 +1,28 @@ +(defun catalan1 (n) + ;; factorial. CLISP actually has "!" defined for this + (labels ((! (x) (if (zerop x) 1 (* x (! (1- x)))))) + (/ (! (* 2 n)) (! (1+ n)) (! n)))) + +;; cache +(defparameter *catalans* (make-array 5 + :fill-pointer 0 + :adjustable t + :element-type 'integer)) +(defun catalan2 (n) + (if (zerop n) 1 + ;; check cache + (if (< n (length *catalans*)) (aref *catalans* n) + (loop with c = 0 for i from 0 to (1- n) collect + (incf c (* (catalan2 i) (catalan2 (- n 1 i)))) + ;; lower values always get calculated first, so + ;; vector-push-extend is safe + finally (progn (vector-push-extend c *catalans*) (return c)))))) + +(defun catalan3 (n) + (if (zerop n) 1 (/ (* 2 (+ n n -1) (catalan3 (1- n))) (1+ n)))) + +;;; test all three methods +(loop for f in (list #'catalan1 #'catalan2 #'catalan3) + for i from 1 to 3 do + (format t "~%Method ~d:~%" i) + (dotimes (i 16) (format t "C(~2d) = ~d~%" i (funcall f i)))) diff --git a/Task/Catalan-numbers/D/catalan-numbers.d b/Task/Catalan-numbers/D/catalan-numbers.d new file mode 100644 index 0000000000..a5e7fd5651 --- /dev/null +++ b/Task/Catalan-numbers/D/catalan-numbers.d @@ -0,0 +1,29 @@ +import std.stdio, std.bigint, std.functional; + +BigInt factorial(uint n) { + alias memoize!factorial mfact; + return n ? mfact(n - 1) * n : BigInt(1); +} + +auto cats1(uint n) { + return factorial(2 * n) / (factorial(n + 1) * factorial(n)); +} + +BigInt cats2(uint n) { + alias memoize!cats2 mcats2; + if (n == 0) return BigInt(1); + auto sum = BigInt(0); + foreach (i; 0 .. n) + sum += mcats2(i) * mcats2(n - 1 - i); + return sum; +} + +BigInt cats3(uint n) { + alias memoize!cats3 mcats3; + return n ? (4*n - 2) * mcats3(n - 1) / (n + 1) : BigInt(1); +} + +void main() { + foreach (i; 0 .. 15) + writefln("%2d => %s %s %s", i, cats1(i), cats2(i), cats3(i)); +} diff --git a/Task/Catalan-numbers/Erlang/catalan-numbers.erl b/Task/Catalan-numbers/Erlang/catalan-numbers.erl new file mode 100644 index 0000000000..a7712f64b3 --- /dev/null +++ b/Task/Catalan-numbers/Erlang/catalan-numbers.erl @@ -0,0 +1,30 @@ +-module(catalan). + +-export([test/0]). + +cat(N) -> + factorial(2 * N) div (factorial(N+1) * factorial(N)). + +factorial(N) -> + fac1(N,1). + +fac1(0,Acc) -> + Acc; +fac1(N,Acc) -> + fac1(N-1, N * Acc). + +cat_r1(0) -> + 1; +cat_r1(N) -> + lists:sum([cat_r1(I)*cat_r1(N-1-I) || I <- lists:seq(0,N-1)]). + +cat_r2(0) -> + 1; +cat_r2(N) -> + cat_r2(N - 1) * (2 * ((2 * N) - 1)) div (N + 1). + +test() -> + TestList = lists:seq(0,14), + io:format("Directly:\n~p\n",[[cat(N) || N <- TestList]]), + io:format("1st recusive method:\n~p\n",[[cat_r1(N) || N <- TestList]]), + io:format("2nd recusive method:\n~p\n",[[cat_r2(N) || N <- TestList]]). diff --git a/Task/Catalan-numbers/Euphoria/catalan-numbers.euphoria b/Task/Catalan-numbers/Euphoria/catalan-numbers.euphoria new file mode 100644 index 0000000000..c57c8bc2a8 --- /dev/null +++ b/Task/Catalan-numbers/Euphoria/catalan-numbers.euphoria @@ -0,0 +1,23 @@ +--Catalan number task from Rosetta Code wiki +--User:Lnettnay + +--function from factorial task +function factorial(integer n) +atom f = 1 +while n > 1 do + f *= n + n -= 1 +end while + +return f +end function + +function catalan(integer n) +atom numerator = factorial(2 * n) +atom denominator = factorial(n+1)*factorial(n) +return numerator/denominator +end function + +for i = 0 to 15 do + ? catalan(i) +end for diff --git a/Task/Catalan-numbers/Factor/catalan-numbers.factor b/Task/Catalan-numbers/Factor/catalan-numbers.factor new file mode 100644 index 0000000000..7c9afc249a --- /dev/null +++ b/Task/Catalan-numbers/Factor/catalan-numbers.factor @@ -0,0 +1,23 @@ +: next ( seq -- newseq ) + [ ] [ last ] [ length ] tri + [ 2 * 1 - 2 * ] [ 1 + ] bi / + * suffix ; +: Catalan ( n -- seq ) V{ 1 } swap 1 - [ next ] times ; +15 Catalan . +V{ + 1 + 1 + 2 + 5 + 14 + 42 + 132 + 429 + 1430 + 4862 + 16796 + 58786 + 208012 + 742900 + 2674440 +} diff --git a/Task/Catalan-numbers/Fantom/catalan-numbers.fantom b/Task/Catalan-numbers/Fantom/catalan-numbers.fantom new file mode 100644 index 0000000000..4da2be500f --- /dev/null +++ b/Task/Catalan-numbers/Fantom/catalan-numbers.fantom @@ -0,0 +1,52 @@ +class Main +{ + static Int factorial (Int n) + { + Int res := 1 + if (n>1) + (2..n).each |i| { res *= i } + return res + } + + static Int catalanA (Int n) + { + return factorial(2*n)/(factorial(n+1) * factorial(n)) + } + + static Int catalanB (Int n) + { + if (n == 0) + { + return 1 + } + else + { + sum := 0 + n.times |i| { sum += catalanB(i) * catalanB(n-1-i) } + return sum + } + } + + static Int catalanC (Int n) + { + if (n == 0) + { + return 1 + } + else + { + return catalanC(n-1)*2*(2*n-1)/(n+1) + } + } + + public static Void main () + { + (1..15).each |n| + { + echo (n.toStr.padl(4) + + catalanA(n).toStr.padl(10) + + catalanB(n).toStr.padl(10) + + catalanC(n).toStr.padl(10)) + } + } +} diff --git a/Task/Catalan-numbers/Forth/catalan-numbers.fth b/Task/Catalan-numbers/Forth/catalan-numbers.fth new file mode 100644 index 0000000000..96d4c780cb --- /dev/null +++ b/Task/Catalan-numbers/Forth/catalan-numbers.fth @@ -0,0 +1 @@ +: catalan ( n -- ) 1 swap 1+ 1 do dup cr . i 2* 1- 2* i 1+ */ loop drop ; diff --git a/Task/Catalan-numbers/Fortran/catalan-numbers.f b/Task/Catalan-numbers/Fortran/catalan-numbers.f new file mode 100644 index 0000000000..55f2da808b --- /dev/null +++ b/Task/Catalan-numbers/Fortran/catalan-numbers.f @@ -0,0 +1,44 @@ +program main + !======================================================================================= + implicit none + + !=== Local data + integer :: n + + !=== External procedures + double precision, external :: catalan_numbers + + !=== Execution ========================================================================= + + write(*,'(1x,a)')'===============' + write(*,'(5x,a,6x,a)')'n','c(n)' + write(*,'(1x,a)')'---------------' + + do n = 0, 14 + write(*,'(1x,i5,i10)') n, int(catalan_numbers(n)) + enddo + + write(*,'(1x,a)')'===============' + + !======================================================================================= +end program main +!BL +!BL +!BL +double precision recursive function catalan_numbers(n) result(value) + !======================================================================================= + implicit none + + !=== Input, ouput data + integer, intent(in) :: n + + !=== Execution ========================================================================= + + if ( n .eq. 0 ) then + value = 1 + else + value = ( 2.0d0 * dfloat(2 * n - 1) / dfloat( n + 1 ) ) * catalan_numbers(n-1) + endif + + !======================================================================================= +end function catalan_numbers diff --git a/Task/Catalan-numbers/Frink/catalan-numbers.frink b/Task/Catalan-numbers/Frink/catalan-numbers.frink new file mode 100644 index 0000000000..d033afda37 --- /dev/null +++ b/Task/Catalan-numbers/Frink/catalan-numbers.frink @@ -0,0 +1,3 @@ +catalan[n] := binomial[2n,n]/(n+1) +for n = 0 to 15 + println[catalan[n]] diff --git a/Task/Catalan-numbers/GAP/catalan-numbers.gap b/Task/Catalan-numbers/GAP/catalan-numbers.gap new file mode 100644 index 0000000000..7a6b5b59ad --- /dev/null +++ b/Task/Catalan-numbers/GAP/catalan-numbers.gap @@ -0,0 +1,34 @@ +Catalan1 := function(n) + return Binomial(2*n, n) - Binomial(2*n, n - 1); +end; + +Catalan2 := function(n) + return Binomial(2*n, n)/(n + 1); +end; + +Catalan3 := function(n) + local k, c; + c := 1; + k := 0; + while k < n do + k := k + 1; + c := 2*(2*k - 1)*c/(k + 1); + od; + return c; +end; + +Catalan4_memo := [1]; +Catalan4 := function(n) + if not IsBound(Catalan4_memo[n + 1]) then + Catalan4_memo[n + 1] := Sum([0 .. n - 1], i -> Catalan4(i)*Catalan4(n - 1 - i)); + fi; + return Catalan4_memo[n + 1]; +end; + +# The first fifteen: 0 to 14 ! +List([0 .. 14], n -> Catalan1(n)); +List([0 .. 14], n -> Catalan2(n)); +List([0 .. 14], n -> Catalan3(n)); +List([0 .. 14], n -> Catalan4(n)); +# Same output for all four: +# [ 1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796, 58786, 208012, 742900, 2674440 ] diff --git a/Task/Catalan-numbers/Go/catalan-numbers.go b/Task/Catalan-numbers/Go/catalan-numbers.go new file mode 100644 index 0000000000..720dce4ee3 --- /dev/null +++ b/Task/Catalan-numbers/Go/catalan-numbers.go @@ -0,0 +1,13 @@ +package main + +import ( + "fmt" + "math/big" +) + +func main() { + var b, c big.Int + for n := int64(0); n < 15; n++ { + fmt.Println(c.Div(b.Binomial(n*2, n), c.SetInt64(n+1))) + } +} diff --git a/Task/Catalan-numbers/Haskell/catalan-numbers.hs b/Task/Catalan-numbers/Haskell/catalan-numbers.hs new file mode 100644 index 0000000000..00a17a0428 --- /dev/null +++ b/Task/Catalan-numbers/Haskell/catalan-numbers.hs @@ -0,0 +1,10 @@ +-- Three infinite lists, corresponding to the three definitions in the problem +-- statement. + +cats1 = map (\n -> product [n+2..2*n] `div` product [1..n]) [0..] + +cats2 = 1 : map (\n -> sum $ zipWith (*) (reverse (take n cats2)) cats2) [1..] + +cats3 = scanl (\c n -> c*2*(2*n-1) `div` (n+1)) 1 [1..] + +main = mapM_ (print . take 15) [cats1, cats2, cats3] diff --git a/Task/Catalan-numbers/Icon/catalan-numbers.icon b/Task/Catalan-numbers/Icon/catalan-numbers.icon new file mode 100644 index 0000000000..d7ddd341a2 --- /dev/null +++ b/Task/Catalan-numbers/Icon/catalan-numbers.icon @@ -0,0 +1,11 @@ +procedure main(arglist) +every writes(catalan(i)," ") +end + +procedure catalan(n) # return catalan(n) or fail +static M +initial M := table() + +if n > 0 then + return (n = 1) | \M[n] | ( M[n] := (2*(2*n-1)*catalan(n-1))/(n+1)) +end diff --git a/Task/Catalan-numbers/J/catalan-numbers.j b/Task/Catalan-numbers/J/catalan-numbers.j new file mode 100644 index 0000000000..2032cd303c --- /dev/null +++ b/Task/Catalan-numbers/J/catalan-numbers.j @@ -0,0 +1,2 @@ + ((! +:) % >:) i.15x +1 1 2 5 14 42 132 429 1430 4862 16796 58786 208012 742900 2674440 diff --git a/Task/Catalan-numbers/Java/catalan-numbers.java b/Task/Catalan-numbers/Java/catalan-numbers.java new file mode 100644 index 0000000000..9c28e64c68 --- /dev/null +++ b/Task/Catalan-numbers/Java/catalan-numbers.java @@ -0,0 +1,65 @@ +import java.util.HashMap; +import java.util.Map; + +public class Catalan { + private static final Map facts = new HashMap(); + private static final Map catsI = new HashMap(); + private static final Map catsR1 = new HashMap(); + private static final Map catsR2 = new HashMap(); + + static{//pre-load the memoization maps with some answers + facts.put(0L, 1D); + facts.put(1L, 1D); + facts.put(2L, 2D); + + catsI.put(0L, 1D); + catsR1.put(0L, 1D); + catsR2.put(0L, 1D); + } + + private static double fact(long n){ + if(facts.containsKey(n)){ + return facts.get(n); + } + double fact = 1; + for(long i = 2; i <= n; i++){ + fact *= i; //could be further optimized, but it would probably be ugly + } + facts.put(n, fact); + return fact; + } + + private static double catI(long n){ + if(!catsI.containsKey(n)){ + catsI.put(n, fact(2 * n)/(fact(n+1)*fact(n))); + } + return catsI.get(n); + } + + private static double catR1(long n){ + if(catsR1.containsKey(n)){ + return catsR1.get(n); + } + double sum = 0; + for(int i = 0; i < n; i++){ + sum += catR1(i) * catR1(n - 1 - i); + } + catsR1.put(n, sum); + return sum; + } + + private static double catR2(long n){ + if(!catsR2.containsKey(n)){ + catsR2.put(n, ((2.0*(2*(n-1) + 1))/(n + 1)) * catR2(n-1)); + } + return catsR2.get(n); + } + + public static void main(String[] args){ + for(int i = 0; i <= 15; i++){ + System.out.println(catI(i)); + System.out.println(catR1(i)); + System.out.println(catR2(i)); + } + } +} diff --git a/Task/Catalan-numbers/JavaScript/catalan-numbers-1.js b/Task/Catalan-numbers/JavaScript/catalan-numbers-1.js new file mode 100644 index 0000000000..ffea51d934 --- /dev/null +++ b/Task/Catalan-numbers/JavaScript/catalan-numbers-1.js @@ -0,0 +1,29 @@ +Catalan +

diff --git a/Task/Catalan-numbers/JavaScript/catalan-numbers-2.js b/Task/Catalan-numbers/JavaScript/catalan-numbers-2.js
new file mode 100644
index 0000000000..2327812afd
--- /dev/null
+++ b/Task/Catalan-numbers/JavaScript/catalan-numbers-2.js
@@ -0,0 +1,17 @@
+       meth1   meth2   meth3
+0	1	1	1
+1	1	1	1
+2	2	2	2
+3	5	5	5
+4	14	14	14
+5	42	42	42
+6	132	132	132
+7	429	429	429
+8	1430	1430	1430
+9	4862	4862	4862
+10	16796	16796	16796
+11	58786	58786	58786
+12	208012	208012	208012
+13	742900	742900	742900
+14	2674440	2674440	2674440
+15	9694845	9694845	9694845
diff --git a/Task/Catalan-numbers/Julia/catalan-numbers.julia b/Task/Catalan-numbers/Julia/catalan-numbers.julia
new file mode 100644
index 0000000000..a01697bae4
--- /dev/null
+++ b/Task/Catalan-numbers/Julia/catalan-numbers.julia
@@ -0,0 +1,3 @@
+function catalan(n)
+	binomial(2n,n)/(n+1)
+end
diff --git a/Task/Catalan-numbers/K/catalan-numbers.k b/Task/Catalan-numbers/K/catalan-numbers.k
new file mode 100644
index 0000000000..1271cb5214
--- /dev/null
+++ b/Task/Catalan-numbers/K/catalan-numbers.k
@@ -0,0 +1,3 @@
+  catalan: {_{*/(x-i)%1+i:!y-1}[2*x;x+1]%x+1}
+  catalan'!:15
+1 1 2 5 14 42 132 429 1430 4862 16796 58786 208012 742900 2674440
diff --git a/Task/Catalan-numbers/Liberty-BASIC/catalan-numbers.liberty b/Task/Catalan-numbers/Liberty-BASIC/catalan-numbers.liberty
new file mode 100644
index 0000000000..5fb6afbb21
--- /dev/null
+++ b/Task/Catalan-numbers/Liberty-BASIC/catalan-numbers.liberty
@@ -0,0 +1,53 @@
+print "non-recursive version"
+print catNonRec(5)
+for i = 0 to 15
+    print i;"   =   "; catNonRec(i)
+next
+print
+
+print "recursive version"
+print catRec(5)
+for i = 0 to 15
+    print i;"   =   "; catRec(i)
+next
+print
+
+print "recursive with memoisation"
+redim cats(20)  'clear the array
+print catRecMemo(5)
+for i = 0 to 15
+    print i;"   =   "; catRecMemo(i)
+next
+print
+
+
+wait
+
+function catNonRec(n)   'non-recursive version
+    catNonRec=1
+    for i=1 to n
+        catNonRec=((2*((2*i)-1))/(i+1))*catNonRec
+    next
+end function
+
+function catRec(n)  'recursive version
+    if n=0 then
+        catRec=1
+    else
+        catRec=((2*((2*n)-1))/(n+1))*catRec(n-1)
+    end if
+end function
+
+function catRecMemo(n)  'recursive version with memoisation
+    if n=0 then
+        catRecMemo=1
+    else
+        if cats(n-1)=0 then    'call it recursively only if not already calculated
+            prev = catRecMemo(n-1)
+        else
+            prev = cats(n-1)
+        end if
+        catRecMemo=((2*((2*n)-1))/(n+1))*prev
+    end if
+    cats(n) = catRecMemo    'memoisation for future use
+end function
diff --git a/Task/Catalan-numbers/Lua/catalan-numbers.lua b/Task/Catalan-numbers/Lua/catalan-numbers.lua
new file mode 100644
index 0000000000..605c9ece10
--- /dev/null
+++ b/Task/Catalan-numbers/Lua/catalan-numbers.lua
@@ -0,0 +1,13 @@
+-- recursive with memoization
+catalan = {[0] = 1}
+setmetatable(catalan, {
+	__index = function(c, n)
+			c[n] = c[n-1]*2*(2*n-1)/(n+1)
+			return c[n]
+		end
+	}
+)
+
+for i=0,14 do
+	print(catalan[i])
+end
diff --git a/Task/Catalan-numbers/MATLAB/catalan-numbers-1.m b/Task/Catalan-numbers/MATLAB/catalan-numbers-1.m
new file mode 100644
index 0000000000..07ec109bca
--- /dev/null
+++ b/Task/Catalan-numbers/MATLAB/catalan-numbers-1.m
@@ -0,0 +1,5 @@
+function n = catalanNumbers(n)
+    for i = (1:length(n))
+        n(i) = (1/(n(i)+1))*nchoosek(2*n(i),n(i));
+    end
+end
diff --git a/Task/Catalan-numbers/MATLAB/catalan-numbers-2.m b/Task/Catalan-numbers/MATLAB/catalan-numbers-2.m
new file mode 100644
index 0000000000..37dcf3fb59
--- /dev/null
+++ b/Task/Catalan-numbers/MATLAB/catalan-numbers-2.m
@@ -0,0 +1,3 @@
+function n = catalanNumbers(n)
+    n = prod(n+1:2*n)/prod(1:n+1);
+end
diff --git a/Task/Catalan-numbers/MATLAB/catalan-numbers-3.m b/Task/Catalan-numbers/MATLAB/catalan-numbers-3.m
new file mode 100644
index 0000000000..db449e504a
--- /dev/null
+++ b/Task/Catalan-numbers/MATLAB/catalan-numbers-3.m
@@ -0,0 +1,28 @@
+>> catalanNumbers(14)
+
+ans =
+
+     2674440
+
+>> catalanNumbers((0:17))'
+
+ans =
+
+           1
+           1
+           2
+           5
+          14
+          42
+         132
+         429
+        1430
+        4862
+       16796
+       58786
+      208012
+      742900
+     2674440
+     9694845
+    35357670
+   129644790
diff --git a/Task/Catalan-numbers/Mathematica/catalan-numbers-1.math b/Task/Catalan-numbers/Mathematica/catalan-numbers-1.math
new file mode 100644
index 0000000000..b435724ef2
--- /dev/null
+++ b/Task/Catalan-numbers/Mathematica/catalan-numbers-1.math
@@ -0,0 +1 @@
+CatalanN[n_Integer /; n >= 0] := (2 n)!/((n + 1)! n!)
diff --git a/Task/Catalan-numbers/Mathematica/catalan-numbers-2.math b/Task/Catalan-numbers/Mathematica/catalan-numbers-2.math
new file mode 100644
index 0000000000..5bec016db9
--- /dev/null
+++ b/Task/Catalan-numbers/Mathematica/catalan-numbers-2.math
@@ -0,0 +1,18 @@
+TableForm[CatalanN/@Range[0,15]]
+//TableForm=
+1
+1
+2
+5
+14
+42
+132
+429
+1430
+4862
+16796
+58786
+208012
+742900
+2674440
+9694845
diff --git a/Task/Catalan-numbers/Maxima/catalan-numbers.maxima b/Task/Catalan-numbers/Maxima/catalan-numbers.maxima
new file mode 100644
index 0000000000..7e9cf32abc
--- /dev/null
+++ b/Task/Catalan-numbers/Maxima/catalan-numbers.maxima
@@ -0,0 +1,11 @@
+/* The following is an array function, hence the square brackets. It uses memoization automatically */
+cata[n] := sum(cata[i]*cata[n - 1 - i], i, 0, n - 1)$
+cata[0]: 1$
+
+cata2(n) := binomial(2*n, n)/(n + 1)$
+
+makelist(cata[n], n, 0, 14);
+
+makelist(cata2(n), n, 0, 14);
+
+/* both return [1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796, 58786, 208012, 742900, 2674440] */
diff --git a/Task/Catalan-numbers/PARI-GP/catalan-numbers-1.pari b/Task/Catalan-numbers/PARI-GP/catalan-numbers-1.pari
new file mode 100644
index 0000000000..146c37dddd
--- /dev/null
+++ b/Task/Catalan-numbers/PARI-GP/catalan-numbers-1.pari
@@ -0,0 +1 @@
+Catalan(n)=binomial(2*n,n+1)/n
diff --git a/Task/Catalan-numbers/PARI-GP/catalan-numbers-2.pari b/Task/Catalan-numbers/PARI-GP/catalan-numbers-2.pari
new file mode 100644
index 0000000000..4b55d02750
--- /dev/null
+++ b/Task/Catalan-numbers/PARI-GP/catalan-numbers-2.pari
@@ -0,0 +1 @@
+Catalan(n)=(2*n)!/(n+1)!/n!
diff --git a/Task/Catalan-numbers/PARI-GP/catalan-numbers-3.pari b/Task/Catalan-numbers/PARI-GP/catalan-numbers-3.pari
new file mode 100644
index 0000000000..a5f3f8e4fb
--- /dev/null
+++ b/Task/Catalan-numbers/PARI-GP/catalan-numbers-3.pari
@@ -0,0 +1 @@
+Catalan(n)=prod(k=n+2,2*n,k)/prod(k=2,n,k)
diff --git a/Task/Catalan-numbers/PARI-GP/catalan-numbers-4.pari b/Task/Catalan-numbers/PARI-GP/catalan-numbers-4.pari
new file mode 100644
index 0000000000..d6cb360be0
--- /dev/null
+++ b/Task/Catalan-numbers/PARI-GP/catalan-numbers-4.pari
@@ -0,0 +1,6 @@
+Catalan(n)={
+  my(t=1);
+  for(k=n+2,2*n,t*=k);
+  for(k=2,n,t/=k);
+  t
+};
diff --git a/Task/Catalan-numbers/PARI-GP/catalan-numbers-5.pari b/Task/Catalan-numbers/PARI-GP/catalan-numbers-5.pari
new file mode 100644
index 0000000000..43202f8b66
--- /dev/null
+++ b/Task/Catalan-numbers/PARI-GP/catalan-numbers-5.pari
@@ -0,0 +1 @@
+vector(15,n,Catalan(n))
diff --git a/Task/Catalan-numbers/PHP/catalan-numbers.php b/Task/Catalan-numbers/PHP/catalan-numbers.php
new file mode 100644
index 0000000000..995bf60212
--- /dev/null
+++ b/Task/Catalan-numbers/PHP/catalan-numbers.php
@@ -0,0 +1,33 @@
+ 1);
+
+  private function fill_cache($i)
+  {
+    $accum = 0;
+    $n = $i-1;
+    for($k = 0; $k <= $n; $k++)
+    {
+      $accum += $this->item($k)*$this->item($n-$k);
+    }
+    self::$cache[$i] = $accum;
+  }
+  function item($i)
+  {
+    if (!isset(self::$cache[$i]))
+    {
+      $this->fill_cache($i);
+    }
+    return self::$cache[$i];
+  }
+}
+
+$cn = new CatalanNumbersSerie();
+for($i = 0; $i <= 15;$i++)
+{
+  $r = $cn->item($i);
+  echo "$i = $r\r\n";
+}
+?>
diff --git a/Task/Catalan-numbers/PL-I/catalan-numbers.pli b/Task/Catalan-numbers/PL-I/catalan-numbers.pli
new file mode 100644
index 0000000000..1031da791a
--- /dev/null
+++ b/Task/Catalan-numbers/PL-I/catalan-numbers.pli
@@ -0,0 +1,19 @@
+catalan: procedure options (main);   /* 23 February 2012 */
+   declare (i, n) fixed;
+
+   put skip list ('How many catalan numbers do you want?');
+   get list (n);
+
+   do i = 0 to n;
+      put skip list (c(i));
+   end;
+
+c: procedure (n) recursive returns (fixed decimal (15));
+   declare n fixed;
+
+   if n <= 1 then return (1);
+
+   return ( 2*(2*n-1) * c(n-1) / (n + 1) );
+end c;
+
+end catalan;
diff --git a/Task/Catalan-numbers/Pascal/catalan-numbers.pascal b/Task/Catalan-numbers/Pascal/catalan-numbers.pascal
new file mode 100644
index 0000000000..65f0124409
--- /dev/null
+++ b/Task/Catalan-numbers/Pascal/catalan-numbers.pascal
@@ -0,0 +1,19 @@
+Program CatalanNumbers(output);
+
+function catalanNumber1(n: integer): double;
+  begin
+    if n = 0 then
+      catalanNumber1 := 1.0
+    else
+      catalanNumber1 := double(4 * n - 2) / double(n + 1) * catalanNumber1(n-1);
+  end;
+
+var
+  number: integer;
+
+begin
+  writeln('Catalan Numbers');
+  writeln('Recursion with a fraction:');
+  for number := 0 to 14 do
+    writeln (number:3, round(catalanNumber1(number)):9);
+end.
diff --git a/Task/Catalan-numbers/Perl-6/catalan-numbers.pl6 b/Task/Catalan-numbers/Perl-6/catalan-numbers.pl6
new file mode 100644
index 0000000000..0c31652ae7
--- /dev/null
+++ b/Task/Catalan-numbers/Perl-6/catalan-numbers.pl6
@@ -0,0 +1,3 @@
+my @catalan := 1, { (state $n)++; 2*(2*$n-1)/($n+1) * $_ } ... *;
+
+.say for @catalan[^15];
diff --git a/Task/Catalan-numbers/Perl/catalan-numbers-1.pl b/Task/Catalan-numbers/Perl/catalan-numbers-1.pl
new file mode 100644
index 0000000000..696d643fa4
--- /dev/null
+++ b/Task/Catalan-numbers/Perl/catalan-numbers-1.pl
@@ -0,0 +1,4 @@
+sub f { $_[0] ? $_[0] * f($_[0]-1) : 1 }
+sub catalan { f(2 * $_[0]) / f($_[0]) / f($_[0]+1) }
+
+print "$_\t@{[ catalan($_) ]}\n" for 0 .. 20;
diff --git a/Task/Catalan-numbers/Perl/catalan-numbers-2.pl b/Task/Catalan-numbers/Perl/catalan-numbers-2.pl
new file mode 100644
index 0000000000..fd21456c07
--- /dev/null
+++ b/Task/Catalan-numbers/Perl/catalan-numbers-2.pl
@@ -0,0 +1,8 @@
+my @c = (1);
+sub catalan {
+        use bigint;
+        $c[$_[0]] //= catalan($_[0]-1) * (4 * $_[0]-2) / ($_[0]+1)
+}
+
+# most of the time is spent displaying the long numbers, actually
+print "$_\t", catalan($_), "\n" for 0 .. 10000;
diff --git a/Task/Catalan-numbers/PicoLisp/catalan-numbers.l b/Task/Catalan-numbers/PicoLisp/catalan-numbers.l
new file mode 100644
index 0000000000..7395367737
--- /dev/null
+++ b/Task/Catalan-numbers/PicoLisp/catalan-numbers.l
@@ -0,0 +1,33 @@
+# Factorial
+(de fact (N)
+   (if (=0 N)
+      1
+      (* N (fact (dec N))) ) )
+
+# Directly
+(de catalanDir (N)
+   (/ (fact (* 2 N)) (fact (inc N)) (fact N)) )
+
+# Recursively
+(de catalanRec (N)
+   (if (=0 N)
+      1
+      (cache '(NIL) (pack (char (hash N)) N)  # Memoize
+         (sum
+            '((I) (* (catalanRec I) (catalanRec (- N I 1))))
+            (range 0 (dec N)) ) ) ) )
+
+# Alternatively
+(de catalanAlt (N)
+   (if (=0 N)
+      1
+      (*/ 2 (dec (* 2 N)) (catalanAlt (dec N)) (inc N)) ) )
+
+# Test
+(for (N 0 (> 15 N) (inc N))
+   (tab (2 4 8 8 8)
+      N
+      " => "
+      (catalanDir N)
+      (catalanRec N)
+      (catalanAlt N) ) )
diff --git a/Task/Catalan-numbers/PlainTeX/catalan-numbers.tex b/Task/Catalan-numbers/PlainTeX/catalan-numbers.tex
new file mode 100644
index 0000000000..0b7113ddac
--- /dev/null
+++ b/Task/Catalan-numbers/PlainTeX/catalan-numbers.tex
@@ -0,0 +1,22 @@
+\newcount\n
+\newcount\r
+\newcount\x
+\newcount\ii
+
+\def\catalan#1{%
+	\n#1\advance\n by1\ii1\r1%
+	\loop{%
+		\x\ii%
+		\multiply\x by 2 \advance\x by -1 \multiply\x by 2%
+		\global\multiply\r by\x%
+		\global\advance\ii by1%
+		\global\divide\r by\ii%
+	} \ifnum\number\ii<\n\repeat%
+	\the\r
+}
+
+\rightskip=0pt plus1fil\parindent=0pt
+\loop{${\rm Catalan}(\the\x) = \catalan{\the\x}$\hfil\break}%
+	\advance\x by 1\ifnum\x<15\repeat
+
+\bye
diff --git a/Task/Catalan-numbers/Prolog/catalan-numbers.pro b/Task/Catalan-numbers/Prolog/catalan-numbers.pro
new file mode 100644
index 0000000000..ba46d3eb74
--- /dev/null
+++ b/Task/Catalan-numbers/Prolog/catalan-numbers.pro
@@ -0,0 +1,17 @@
+catalan(N) :-
+	length(L1, N),
+	L = [1 | L1],
+	init(1,1,L1),
+	numlist(0, N, NL),
+	maplist(my_write, NL, L).
+
+
+init(_, _, []).
+
+init(V, N, [H | T]) :-
+	N1 is N+1,
+	H is 2 * (2 * N - 1) * V / N1,
+	init(H, N1, T).
+
+my_write(N, V) :-
+	format('~w : ~w~n', [N, V]).
diff --git a/Task/Catalan-numbers/PureBasic/catalan-numbers.purebasic b/Task/Catalan-numbers/PureBasic/catalan-numbers.purebasic
new file mode 100644
index 0000000000..f37300b150
--- /dev/null
+++ b/Task/Catalan-numbers/PureBasic/catalan-numbers.purebasic
@@ -0,0 +1,23 @@
+; saving the division for last ensures we divide the largest
+; numerator by the smallest denominator
+
+Procedure.q CatalanNumber(n.q)
+If n<0:ProcedureReturn 0:EndIf
+If n=0:ProcedureReturn 1:EndIf
+ProcedureReturn (2*(2*n-1))*CatalanNumber(n-1)/(n+1)
+EndProcedure
+
+ls=25
+rs=12
+
+a.s=""
+a.s+LSet(RSet("n",rs),ls)+"CatalanNumber(n)"
+; cw(a.s)
+Debug a.s
+
+For n=0 to 33 ;33 largest correct quad for n
+a.s=""
+a.s+LSet(RSet(Str(n),rs),ls)+Str(CatalanNumber(n))
+; cw(a.s)
+Debug a.s
+Next
diff --git a/Task/Catalan-numbers/Python/catalan-numbers.py b/Task/Catalan-numbers/Python/catalan-numbers.py
new file mode 100644
index 0000000000..1faf1ea187
--- /dev/null
+++ b/Task/Catalan-numbers/Python/catalan-numbers.py
@@ -0,0 +1,44 @@
+from math import factorial
+import functools
+
+def memoize(func):
+    cache = {}
+    def memoized(key):
+        # Returned, new, memoized version of decorated function
+        if key not in cache:
+            cache[key] = func(key)
+        return cache[key]
+    return functools.update_wrapper(memoized, func)
+
+
+@memoize
+def fact(n):
+    return factorial(n)
+
+def cat_direct(n):
+    return fact(2*n) // fact(n + 1) // fact(n)
+
+@memoize
+def catR1(n):
+    return ( 1 if n == 0
+             else sum( catR1(i) * catR1(n - 1 - i)
+                       for i in range(n) ) )
+
+@memoize
+def catR2(n):
+    return ( 1 if n == 0
+             else ( ( 4 * n - 2 ) * catR2( n - 1) ) // ( n + 1 ) )
+
+
+if __name__ == '__main__':
+    def pr(results):
+        fmt = '%-10s %-10s %-10s'
+        print ((fmt % tuple(c.__name__ for c in defs)).upper())
+        print (fmt % (('='*10,)*3))
+        for r in zip(*results):
+            print (fmt % r)
+
+
+    defs = (cat_direct, catR1, catR2)
+    results = [ tuple(c(i) for i in range(15)) for c in defs ]
+    pr(results)
diff --git a/Task/Catalan-numbers/R/catalan-numbers.r b/Task/Catalan-numbers/R/catalan-numbers.r
new file mode 100644
index 0000000000..67ac88e7a1
--- /dev/null
+++ b/Task/Catalan-numbers/R/catalan-numbers.r
@@ -0,0 +1,4 @@
+catalan <- function(n) choose(2*n, n)/(n + 1)
+catalan(1:15)
+# [1]       1       2       5      14      42     132     429    1430    4862
+#[10]   16796   58786  208012  742900 2674440 9694845
diff --git a/Task/Catalan-numbers/REXX/catalan-numbers.rexx b/Task/Catalan-numbers/REXX/catalan-numbers.rexx
new file mode 100644
index 0000000000..e3fb084f46
--- /dev/null
+++ b/Task/Catalan-numbers/REXX/catalan-numbers.rexx
@@ -0,0 +1,47 @@
+/*REXX program calculates Catalan numbers using three different methods.*/
+parse arg bot top .                    /*get args from the command line.*/
+if bot=='' then do; top=15; bot=0; end /*No args? Use a range of 0 ─► 15*/
+if top=='' then top=bot                /*No top?  Use the bottom for it.*/
+numeric digits max(20,5*top)           /*no limit on big Catalan numbers*/
+w=length(top)                          /*use  W  to align Catalan index.*/
+
+say;  say center(' Catalan numbers, method 1 ' , 79, '-');    !.=0
+                          do m1=bot  to top
+                          say right(m1,w)  '='  catalan1(m1)
+                          end     /*m1*/
+
+say;  say center(' Catalan numbers, method 2 ' , 79, '-');    c.=0;  c.0=1
+                          do m2=bot  to top
+                          say right(m2,w)  '='  catalan2(m2)
+                          end     /*m2*/
+
+say;  say center(' Catalan numbers, method 3 ' , 79, '-');    c.=0;  c.0=1
+                          do m3=bot  to top
+                          say right(m3,w)  '='  catalan3(m3)
+                          end     /*m3*/
+exit                                   /*stick a fork in it, we're done.*/
+
+/*──────────────────────────────────catalan method 1────────────────────*/
+catalan1: procedure expose !.; parse arg n  /*n+n  is faster than  2*n  */
+return !(n+n)  %    ( (n+1)  *  !(n)**2 )   /*using COMB would be faster*/
+
+/*──────────────────────────────────catalan method 2────────────────────*/
+catalan2: procedure expose c.; parse arg n; if c.n\==0 then return c.n
+s=0;     do j=0  to  n-1
+         s=s   +   catalan2(j) * catalan2(n-j-1)    /*recursive invokes.*/
+         end   /*j*/
+c.n=s                                  /*use REXX memoization technique.*/
+return s
+
+/*──────────────────────────────────catalan method 3────────────────────*/
+catalan3: procedure expose c.; parse arg n;  if c.n\==0 then return c.n
+c.n=(4*n-2) * catalan3(n-1) % (n+1)    /*use REXX memoization technique.*/
+return c.n
+
+/*──────────────────────────────────! (factorial) function──────────────*/
+!: procedure expose !.;   parse arg x;   if !.x\==0 then return !.x;   !=1
+            do k=1  for x
+            !=!*k
+            end   /*k*/
+!.x=!                                  /*use REXX memoization technique.*/
+return !
diff --git a/Task/Catalan-numbers/Racket/catalan-numbers.rkt b/Task/Catalan-numbers/Racket/catalan-numbers.rkt
new file mode 100644
index 0000000000..a528d4dba1
--- /dev/null
+++ b/Task/Catalan-numbers/Racket/catalan-numbers.rkt
@@ -0,0 +1,12 @@
+#lang racket
+(require planet2)
+; (install "this-and-that")  ; uncomment to install
+(require memoize/memo)
+
+(define/memo* (catalan m)
+  (if (= m 0)
+      1
+      (for/sum ([i m])
+        (* (catalan i) (catalan (- m i 1))))))
+
+(map catalan (range 1 15))
diff --git a/Task/Catalan-numbers/Ruby/catalan-numbers.rb b/Task/Catalan-numbers/Ruby/catalan-numbers.rb
new file mode 100644
index 0000000000..a44b359b87
--- /dev/null
+++ b/Task/Catalan-numbers/Ruby/catalan-numbers.rb
@@ -0,0 +1,42 @@
+# direct
+
+def factorial(n)
+  (1..n).reduce(:*)
+end
+
+def catalan_direct(n)
+  factorial(2*n) / (factorial(n+1) * factorial(n))
+end
+
+# recursive
+
+def catalan_rec1(n)
+  return 1 if n == 0
+  (0..n-1).inject(0) {|sum, i| sum + catalan_rec1(i) * catalan_rec1(n-1-i)}
+end
+
+def catalan_rec2(n)
+  return 1 if n == 0
+  2*(2*n - 1) * catalan_rec2(n-1) /(n+1)
+end
+
+# performance and results
+
+require 'benchmark'
+require 'memoize'
+include Memoize
+
+Benchmark.bm(10) do |b|
+  b.report('forget') {
+    16.times {|n| [n, catalan_direct(n), catalan_rec1(n), catalan_rec2(n)]}
+  }
+  b.report('memoized') {
+    memoize :factorial
+    memoize :catalan_direct
+    memoize :catalan_rec1
+    memoize :catalan_rec2
+    16.times {|n| [n, catalan_direct(n), catalan_rec1(n), catalan_rec2(n)]}
+  }
+end
+
+16.times {|n| p [n, catalan_direct(n), catalan_rec1(n), catalan_rec2(n)]}
diff --git a/Task/Catalan-numbers/Run-BASIC/catalan-numbers.run b/Task/Catalan-numbers/Run-BASIC/catalan-numbers.run
new file mode 100644
index 0000000000..5f93ddb672
--- /dev/null
+++ b/Task/Catalan-numbers/Run-BASIC/catalan-numbers.run
@@ -0,0 +1,11 @@
+FOR i = 1 TO 15
+    PRINT i;" ";catalan(i)
+NEXT
+
+FUNCTION catalan(n)
+  IF n = 0 THEN
+      catalan = 1
+  ELSE
+      catalan = ((2 * ((2 * n) - 1)) / (n + 1)) * catalan(n - 1)
+ END IF
+END FUNCTION
diff --git a/Task/Catalan-numbers/Scala/catalan-numbers.scala b/Task/Catalan-numbers/Scala/catalan-numbers.scala
new file mode 100644
index 0000000000..3fd82d209f
--- /dev/null
+++ b/Task/Catalan-numbers/Scala/catalan-numbers.scala
@@ -0,0 +1,10 @@
+object Catalan {
+  def factorial(n: BigInt) = BigInt(1).to(n).foldLeft(BigInt(1))(_ * _)
+  def catalan(n: BigInt) = factorial(2 * n) / (factorial(n + 1) * factorial(n))
+
+  def main(args: Array[String]) {
+    for (n <- 1 to 15) {
+      println("catalan(" + n + ") = " + catalan(n))
+    }
+  }
+}
diff --git a/Task/Catalan-numbers/Scheme/catalan-numbers.ss b/Task/Catalan-numbers/Scheme/catalan-numbers.ss
new file mode 100644
index 0000000000..2f597c937d
--- /dev/null
+++ b/Task/Catalan-numbers/Scheme/catalan-numbers.ss
@@ -0,0 +1,8 @@
+(define (catalan m)
+    (let loop ((c 1)(n 0))
+        (if (not (eqv? n m))
+            (begin
+                (display n)(display ": ")(display c)(newline)
+                (loop (* (/ (* 2 (- (* 2 (+ n 1)) 1)) (+ (+ n 1) 1)) c) (+ n 1) )))))
+
+(catalan 15)
diff --git a/Task/Catalan-numbers/Standard-ML/catalan-numbers.ml b/Task/Catalan-numbers/Standard-ML/catalan-numbers.ml
new file mode 100644
index 0000000000..3bcf09b2ba
--- /dev/null
+++ b/Task/Catalan-numbers/Standard-ML/catalan-numbers.ml
@@ -0,0 +1,32 @@
+(*
+ * val catalan : int -> int
+ * Returns the nth Catalan number.
+ *)
+fun catalan 0 = 1
+|   catalan n = ((4 * n - 2) * catalan(n - 1)) div (n + 1);
+
+(*
+ * val print_catalans : int -> unit
+ * Prints out Catalan numbers 0 through 15.
+ *)
+fun print_catalans(n) =
+    if n > 15 then ()
+    else (print (Int.toString(catalan n) ^ "\n"); print_catalans(n + 1)); print_catalans(0);
+(*
+ * 1
+ * 1
+ * 2
+ * 5
+ * 14
+ * 42
+ * 132
+ * 429
+ * 1430
+ * 4862
+ * 16796
+ * 58786
+ * 208012
+ * 742900
+ * 2674440
+ * 9694845
+ *)
diff --git a/Task/Catalan-numbers/TI-83-BASIC/catalan-numbers.ti-83 b/Task/Catalan-numbers/TI-83-BASIC/catalan-numbers.ti-83
new file mode 100644
index 0000000000..93a815c714
--- /dev/null
+++ b/Task/Catalan-numbers/TI-83-BASIC/catalan-numbers.ti-83
@@ -0,0 +1,3 @@
+:For(I,1,15
+:Disp (2I)!/((I+1)!I!
+:End
diff --git a/Task/Catalan-numbers/Tcl/catalan-numbers-1.tcl b/Task/Catalan-numbers/Tcl/catalan-numbers-1.tcl
new file mode 100644
index 0000000000..1b09dc0b0c
--- /dev/null
+++ b/Task/Catalan-numbers/Tcl/catalan-numbers-1.tcl
@@ -0,0 +1,19 @@
+package require Tcl 8.5
+
+# Memoization wrapper
+proc memoize {function value generator} {
+    variable memoize
+    set key $function,$value
+    if {![info exists memoize($key)]} {
+	set memoize($key) [uplevel 1 $generator]
+    }
+    return $memoize($key)
+}
+
+# The simplest recursive definition
+proc tcl::mathfunc::catalan n {
+    if {[incr n 0] < 0} {error "must not be negative"}
+    memoize catalan $n {expr {
+	$n == 0 ? 1 : 2 * (2*$n - 1) * catalan($n - 1) / ($n + 1)
+    }}
+}
diff --git a/Task/Catalan-numbers/Tcl/catalan-numbers-2.tcl b/Task/Catalan-numbers/Tcl/catalan-numbers-2.tcl
new file mode 100644
index 0000000000..3e25020dff
--- /dev/null
+++ b/Task/Catalan-numbers/Tcl/catalan-numbers-2.tcl
@@ -0,0 +1,3 @@
+for {set i 0} {$i < 15} {incr i} {
+    puts "C_$i = [expr {catalan($i)}]"
+}
diff --git a/Task/Catalan-numbers/Ursala/catalan-numbers.ursala b/Task/Catalan-numbers/Ursala/catalan-numbers.ursala
new file mode 100644
index 0000000000..b005335b45
--- /dev/null
+++ b/Task/Catalan-numbers/Ursala/catalan-numbers.ursala
@@ -0,0 +1,8 @@
+#import std
+#import nat
+
+catalan = quotient^\successor choose^/double ~&
+
+#cast %nL
+
+t = catalan* iota 16
diff --git a/Task/Catalan-numbers/VBA/catalan-numbers.vba b/Task/Catalan-numbers/VBA/catalan-numbers.vba
new file mode 100644
index 0000000000..fac18814d2
--- /dev/null
+++ b/Task/Catalan-numbers/VBA/catalan-numbers.vba
@@ -0,0 +1,34 @@
+Public Sub Catalan1(n As Integer)
+'Computes the first n Catalan numbers according to the first recursion given
+Dim Cat() As Long
+Dim sum As Long
+
+ReDim Cat(n)
+Cat(0) = 1
+For i = 0 To n - 1
+  sum = 0
+  For j = 0 To i
+    sum = sum + Cat(j) * Cat(i - j)
+  Next j
+  Cat(i + 1) = sum
+Next i
+Debug.Print
+For i = 0 To n
+  Debug.Print i, Cat(i)
+Next
+End Sub
+
+Public Sub Catalan2(n As Integer)
+'Computes the first n Catalan numbers according to the second recursion given
+Dim Cat() As Long
+
+ReDim Cat(n)
+Cat(0) = 1
+For i = 1 To n
+  Cat(i) = 2 * Cat(i - 1) * (2 * i - 1) / (i + 1)
+Next i
+Debug.Print
+For i = 0 To n
+  Debug.Print i, Cat(i)
+Next
+End Sub
diff --git a/Task/Catalan-numbers/XPL0/catalan-numbers.xpl0 b/Task/Catalan-numbers/XPL0/catalan-numbers.xpl0
new file mode 100644
index 0000000000..268936f967
--- /dev/null
+++ b/Task/Catalan-numbers/XPL0/catalan-numbers.xpl0
@@ -0,0 +1,9 @@
+code CrLf=9, IntOut=11;
+int  C, N;
+[C:= 1;
+IntOut(0, C);  CrLf(0);
+for N:= 1 to 14 do
+    [C:= C*2*(2*N-1)/(N+1);
+    IntOut(0, C);  CrLf(0);
+    ];
+]
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
similarity index 100%
rename from Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/0DESCRIPTION
rename to Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N-/0DESCRIPTION
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
similarity index 100%
rename from Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-1.cpp
rename to Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N-/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n--1.cpp
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
similarity index 100%
rename from Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-2.cpp
rename to Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N-/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n--2.cpp
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
similarity index 100%
rename from Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-3.cpp
rename to Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N-/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n--3.cpp
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
similarity index 100%
rename from Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-4.cpp
rename to Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N-/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n--4.cpp
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
similarity index 100%
rename from Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-5.cpp
rename to Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N-/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n--5.cpp
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
similarity index 100%
rename from Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-6.cpp
rename to Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N-/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n--6.cpp
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
similarity index 100%
rename from Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-7.cpp
rename to Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N-/C++/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n--7.cpp
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
similarity index 100%
rename from Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Ruby/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-1.rb
rename to Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N-/Ruby/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n--1.rb
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
similarity index 100%
rename from Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Ruby/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-2.rb
rename to Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N-/Ruby/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n--2.rb
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
similarity index 100%
rename from Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Ruby/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-3.rb
rename to Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N-/Ruby/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n--3.rb
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
similarity index 100%
rename from Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Ruby/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-4.rb
rename to Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N-/Ruby/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n--4.rb
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
similarity index 100%
rename from Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Tcl/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-1.tcl
rename to Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N-/Tcl/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n--1.tcl
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
similarity index 100%
rename from Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N/Tcl/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n-2.tcl
rename to Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N-/Tcl/continued-fraction-arithmetic-g-matrix-ng,-contined-fraction-n--2.tcl
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
similarity index 100%
rename from Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/0DESCRIPTION
rename to Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2-/0DESCRIPTION
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
similarity index 100%
rename from Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2/1META.yaml
rename to Task/Continued-fraction-Arithmetic-G-matrix-NG,-Contined-Fraction-N1,-Contined-Fraction-N2-/1META.yaml
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
similarity index 100%
rename from 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
rename to 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
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
similarity index 100%
rename from 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
rename to 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
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
similarity index 100%
rename from 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
rename to 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
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
similarity index 100%
rename from 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
rename to 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
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
similarity index 100%
rename from 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
rename to 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
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
similarity index 100%
rename from 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
rename to 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
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
similarity index 100%
rename from 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
rename to 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
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
similarity index 100%
rename from 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
rename to 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
diff --git a/Task/Copy-a-string/0DESCRIPTION b/Task/Copy-a-string/0DESCRIPTION
new file mode 100644
index 0000000000..8e5efbca12
--- /dev/null
+++ b/Task/Copy-a-string/0DESCRIPTION
@@ -0,0 +1 @@
+This task is about copying a string. Where it is relevant, distinguish between copying the contents of a string versus making an additional reference to an existing string.
diff --git a/Task/Copy-a-string/1META.yaml b/Task/Copy-a-string/1META.yaml
new file mode 100644
index 0000000000..3bdc51ea57
--- /dev/null
+++ b/Task/Copy-a-string/1META.yaml
@@ -0,0 +1,4 @@
+---
+category:
+- String manipulation
+note: Basic language learning
diff --git a/Task/Copy-a-string/ABAP/copy-a-string.abap b/Task/Copy-a-string/ABAP/copy-a-string.abap
new file mode 100644
index 0000000000..d95fe152f3
--- /dev/null
+++ b/Task/Copy-a-string/ABAP/copy-a-string.abap
@@ -0,0 +1,3 @@
+data: lv_string1 type string value 'Test',
+      lv_string2 type string.
+lv_string2 = lv_string1.
diff --git a/Task/Copy-a-string/ALGOL-68/copy-a-string.alg b/Task/Copy-a-string/ALGOL-68/copy-a-string.alg
new file mode 100644
index 0000000000..6b4b0a8a77
--- /dev/null
+++ b/Task/Copy-a-string/ALGOL-68/copy-a-string.alg
@@ -0,0 +1,4 @@
+(
+  STRING src:="Hello", dest;
+  dest:=src
+)
diff --git a/Task/Copy-a-string/AWK/copy-a-string.awk b/Task/Copy-a-string/AWK/copy-a-string.awk
new file mode 100644
index 0000000000..1f1c7b1f0c
--- /dev/null
+++ b/Task/Copy-a-string/AWK/copy-a-string.awk
@@ -0,0 +1,6 @@
+BEGIN {
+  a = "a string"
+  b = a
+  sub(/a/, "X", a) # modify a
+  print b  # b is a copy, not a reference to...
+}
diff --git a/Task/Copy-a-string/ActionScript/copy-a-string.as b/Task/Copy-a-string/ActionScript/copy-a-string.as
new file mode 100644
index 0000000000..ef30091021
--- /dev/null
+++ b/Task/Copy-a-string/ActionScript/copy-a-string.as
@@ -0,0 +1,2 @@
+var str1:String = "Hello";
+var str2:String = str1;
diff --git a/Task/Copy-a-string/Ada/copy-a-string-1.ada b/Task/Copy-a-string/Ada/copy-a-string-1.ada
new file mode 100644
index 0000000000..45c6d81f92
--- /dev/null
+++ b/Task/Copy-a-string/Ada/copy-a-string-1.ada
@@ -0,0 +1,2 @@
+Src : String := "Hello";
+Dest : String := Src;
diff --git a/Task/Copy-a-string/Ada/copy-a-string-2.ada b/Task/Copy-a-string/Ada/copy-a-string-2.ada
new file mode 100644
index 0000000000..dd7081031a
--- /dev/null
+++ b/Task/Copy-a-string/Ada/copy-a-string-2.ada
@@ -0,0 +1,3 @@
+Src : String := "Rosetta Stone";
+Dest : String := Src(1..7); -- Assigns "Rosetta" to Dest
+Dest2 : String := Src(9..13); -- Assigns "Stone" to Dest2
diff --git a/Task/Copy-a-string/Ada/copy-a-string-3.ada b/Task/Copy-a-string/Ada/copy-a-string-3.ada
new file mode 100644
index 0000000000..3c40dd4ae0
--- /dev/null
+++ b/Task/Copy-a-string/Ada/copy-a-string-3.ada
@@ -0,0 +1,6 @@
+-- Instantiate the generic package Ada.Strings.Bounded.Generic_Bounded_Length with a maximum length of 80 characters
+package Flexible_String is new Ada.Strings.Bounded.Generic_Bounded_Length(80);
+use Flexible_String;
+
+Src : Bounded_String := To_Bounded_String("Hello");
+Dest : Bounded_String := Src;
diff --git a/Task/Copy-a-string/Ada/copy-a-string-4.ada b/Task/Copy-a-string/Ada/copy-a-string-4.ada
new file mode 100644
index 0000000000..3e4431a025
--- /dev/null
+++ b/Task/Copy-a-string/Ada/copy-a-string-4.ada
@@ -0,0 +1,3 @@
+-- The package Ada.Strings.Unbounded contains the definition of the Unbounded_String type and all its methods
+Src : Unbounded_String := To_Unbounded_String("Hello");
+Dest : Unbounded_String := Src;
diff --git a/Task/Copy-a-string/AutoHotkey/copy-a-string.ahk b/Task/Copy-a-string/AutoHotkey/copy-a-string.ahk
new file mode 100644
index 0000000000..4c9dae06d1
--- /dev/null
+++ b/Task/Copy-a-string/AutoHotkey/copy-a-string.ahk
@@ -0,0 +1,2 @@
+src := "Hello"
+dst := src
diff --git a/Task/Copy-a-string/AutoIt/copy-a-string.autoit b/Task/Copy-a-string/AutoIt/copy-a-string.autoit
new file mode 100644
index 0000000000..21d288ca03
--- /dev/null
+++ b/Task/Copy-a-string/AutoIt/copy-a-string.autoit
@@ -0,0 +1,2 @@
+$Src= "Hello"
+$dest = $Src
diff --git a/Task/Copy-a-string/BBC-BASIC/copy-a-string.bbc b/Task/Copy-a-string/BBC-BASIC/copy-a-string.bbc
new file mode 100644
index 0000000000..99b5babba5
--- /dev/null
+++ b/Task/Copy-a-string/BBC-BASIC/copy-a-string.bbc
@@ -0,0 +1,11 @@
+      source$ = "Hello, world!"
+
+      REM Copy the contents of a string:
+      copy$ = source$
+      PRINT copy$
+
+      REM Make an additional reference to a string:
+      !^same$ = !^source$
+      ?(^same$+4) = ?(^source$+4)
+      ?(^same$+5) = ?(^source$+5)
+      PRINT same$
diff --git a/Task/Copy-a-string/Batch-File/copy-a-string.bat b/Task/Copy-a-string/Batch-File/copy-a-string.bat
new file mode 100644
index 0000000000..5bbb3421c5
--- /dev/null
+++ b/Task/Copy-a-string/Batch-File/copy-a-string.bat
@@ -0,0 +1,2 @@
+set src=Hello
+set dst=%src%
diff --git a/Task/Copy-a-string/Bracmat/copy-a-string.bracmat b/Task/Copy-a-string/Bracmat/copy-a-string.bracmat
new file mode 100644
index 0000000000..20a16618f4
--- /dev/null
+++ b/Task/Copy-a-string/Bracmat/copy-a-string.bracmat
@@ -0,0 +1,8 @@
+abcdef:?a;
+!a:?b;
+
+c=abcdef;
+!c:?d;
+
+!a:!b { variables a and b are the same and probably referencing the same string }
+!a:!d { variables a and d are also the same but not referencing the same string }
diff --git a/Task/Copy-a-string/C++/copy-a-string.cpp b/Task/Copy-a-string/C++/copy-a-string.cpp
new file mode 100644
index 0000000000..18f0a2ec3a
--- /dev/null
+++ b/Task/Copy-a-string/C++/copy-a-string.cpp
@@ -0,0 +1,13 @@
+#include 
+#include 
+#include 
+
+int main( ) {
+   std::string original ( "This is the original" ) ;
+   std::string mycopy( original.length( ) , ' ' ) ;
+   std::copy ( original.begin( ) , original.end( ) , mycopy.begin( ) ) ;
+   std::cout << "This is the copy: " << mycopy << std::endl ;
+   original.assign( "Now we change the original! " ) ;
+   std::cout << "mycopy still is " << mycopy << std::endl ;
+   return 0 ;
+}
diff --git a/Task/Copy-a-string/C/copy-a-string-1.c b/Task/Copy-a-string/C/copy-a-string-1.c
new file mode 100644
index 0000000000..ef532dd080
--- /dev/null
+++ b/Task/Copy-a-string/C/copy-a-string-1.c
@@ -0,0 +1,60 @@
+#include 	/* exit(), free() */
+#include 	/* fputs(), perror(), printf() */
+#include 
+
+int
+main()
+{
+	size_t len;
+	char src[] = "Hello";
+	char dst1[80], dst2[80];
+	char *dst3, *ref;
+
+	/*
+	 * Option 1. Use strcpy() from .
+	 *
+	 * DANGER! strcpy() can overflow the destination buffer.
+	 * strcpy() is only safe if the source string is shorter than
+	 * the destination buffer. We know that "Hello" (6 characters
+	 * with the final '\0') easily fits in dst1 (80 characters).
+	 */
+	strcpy(dst1, src);
+
+	/*
+	 * Option 2. Use strlen() and memcpy() from , to copy
+	 * strlen(src) + 1 bytes including the final '\0'.
+	 */
+	len = strlen(src);
+	if (len >= sizeof dst2) {
+		fputs("The buffer is too small!\n", stderr);
+		exit(1);
+	}
+	memcpy(dst2, src, len + 1);
+
+	/*
+	 * Option 3. Use strdup() from , to allocate a copy.
+	 */
+	dst3 = strdup(src);
+	if (dst3 == NULL) {
+		/* Failed to allocate memory! */
+		perror("strdup");
+		exit(1);
+	}
+
+	/* Create another reference to the source string. */
+	ref = src;
+
+	/* Modify the source string, not its copies. */
+	memset(src, '-', 5);
+
+	printf(" src: %s\n", src);   /*  src: ----- */
+	printf("dst1: %s\n", dst1);  /* dst1: Hello */
+	printf("dst2: %s\n", dst2);  /* dst2: Hello */
+	printf("dst3: %s\n", dst3);  /* dst3: Hello */
+	printf(" ref: %s\n", ref);   /*  ref: ----- */
+
+	/* Free memory from strdup(). */
+	free(dst3);
+
+	return 0;
+}
diff --git a/Task/Copy-a-string/C/copy-a-string-2.c b/Task/Copy-a-string/C/copy-a-string-2.c
new file mode 100644
index 0000000000..3c7c78b53b
--- /dev/null
+++ b/Task/Copy-a-string/C/copy-a-string-2.c
@@ -0,0 +1,22 @@
+#include 	/* exit() */
+#include 	/* fputs(), printf() */
+#include 
+
+int
+main()
+{
+	char src[] = "Hello";
+	char dst[80];
+
+	/* Use strlcpy() from . */
+	if (strlcpy(dst, src, sizeof dst) >= sizeof dst) {
+		fputs("The buffer is too small!\n", stderr);
+		exit(1);
+	}
+
+	memset(src, '-', 5);
+	printf("src: %s\n", src);  /* src: ----- */
+	printf("dst: %s\n", dst);  /* dst: Hello */
+
+	return 0;
+}
diff --git a/Task/Copy-a-string/Clojure/copy-a-string.clj b/Task/Copy-a-string/Clojure/copy-a-string.clj
new file mode 100644
index 0000000000..37f9aad8f5
--- /dev/null
+++ b/Task/Copy-a-string/Clojure/copy-a-string.clj
@@ -0,0 +1,3 @@
+(let [s "hello"
+      s1 s]
+  (println s s1))
diff --git a/Task/Copy-a-string/ColdFusion/copy-a-string.cfm b/Task/Copy-a-string/ColdFusion/copy-a-string.cfm
new file mode 100644
index 0000000000..06bd72e314
--- /dev/null
+++ b/Task/Copy-a-string/ColdFusion/copy-a-string.cfm
@@ -0,0 +1,2 @@
+
+
diff --git a/Task/Copy-a-string/Common-Lisp/copy-a-string.lisp b/Task/Copy-a-string/Common-Lisp/copy-a-string.lisp
new file mode 100644
index 0000000000..9f2c274588
--- /dev/null
+++ b/Task/Copy-a-string/Common-Lisp/copy-a-string.lisp
@@ -0,0 +1,10 @@
+(let* ((s1     "Hello")        ; s1 is a variable containing a string
+       (s1-ref s1)             ; another variable with the same value
+       (s2     (copy-seq s1))) ; s2 has a distinct string object with the same contents
+  (assert (eq s1 s1-ref))      ; same object
+  (assert (not (eq s1 s2)))    ; different object
+  (assert (equal s1 s2))       ; same contents
+
+  (fill s2 #\!)                ; overwrite s2
+  (princ s1)
+  (princ s2))                  ; will print "Hello!!!!!"
diff --git a/Task/Copy-a-string/D/copy-a-string.d b/Task/Copy-a-string/D/copy-a-string.d
new file mode 100644
index 0000000000..38ba8020cb
--- /dev/null
+++ b/Task/Copy-a-string/D/copy-a-string.d
@@ -0,0 +1,12 @@
+void main() {
+    string src = "This is a string";
+
+    // copy contents:
+    auto dest1 = src.idup;
+
+    // copy contents to mutable char array
+    auto dest2 = src.dup;
+
+    // copy just the fat reference of the string
+    auto dest3 = src;
+}
diff --git a/Task/Copy-a-string/Delphi/copy-a-string.delphi b/Task/Copy-a-string/Delphi/copy-a-string.delphi
new file mode 100644
index 0000000000..5ba2759d8b
--- /dev/null
+++ b/Task/Copy-a-string/Delphi/copy-a-string.delphi
@@ -0,0 +1,15 @@
+program CopyString;
+
+{$APPTYPE CONSOLE}
+
+var
+  s1: string;
+  s2: string;
+begin
+  s1 := 'Goodbye';
+  s2 := s1; // S2 points at the same string as S1
+  s2 := s2 + ', World!'; // A new string is created for S2
+
+  Writeln(s1);
+  Writeln(s2);
+end.
diff --git a/Task/Copy-a-string/Erlang/copy-a-string.erl b/Task/Copy-a-string/Erlang/copy-a-string.erl
new file mode 100644
index 0000000000..b9775683e6
--- /dev/null
+++ b/Task/Copy-a-string/Erlang/copy-a-string.erl
@@ -0,0 +1,2 @@
+Src = "Hello".
+Dst = Src.
diff --git a/Task/Copy-a-string/Euphoria/copy-a-string.euphoria b/Task/Copy-a-string/Euphoria/copy-a-string.euphoria
new file mode 100644
index 0000000000..e29173ed2d
--- /dev/null
+++ b/Task/Copy-a-string/Euphoria/copy-a-string.euphoria
@@ -0,0 +1,2 @@
+sequence first = "ABC"
+sequence newOne = first
diff --git a/Task/Copy-a-string/Factor/copy-a-string-1.factor b/Task/Copy-a-string/Factor/copy-a-string-1.factor
new file mode 100644
index 0000000000..465897611b
--- /dev/null
+++ b/Task/Copy-a-string/Factor/copy-a-string-1.factor
@@ -0,0 +1,4 @@
+"This is a mutable string." dup ! reference
+"Let's make a deal!" dup clone  ! copy
+"New" " string" append .               ! new string
+    "New string"
diff --git a/Task/Copy-a-string/Factor/copy-a-string-2.factor b/Task/Copy-a-string/Factor/copy-a-string-2.factor
new file mode 100644
index 0000000000..a676583d98
--- /dev/null
+++ b/Task/Copy-a-string/Factor/copy-a-string-2.factor
@@ -0,0 +1,2 @@
+SBUF" Grow me!" dup "  OK." append
+    SBUF" Grow me!  OK."
diff --git a/Task/Copy-a-string/Factor/copy-a-string-3.factor b/Task/Copy-a-string/Factor/copy-a-string-3.factor
new file mode 100644
index 0000000000..8c40326d51
--- /dev/null
+++ b/Task/Copy-a-string/Factor/copy-a-string-3.factor
@@ -0,0 +1,2 @@
+SBUF" I'll be a string someday." >string .
+    "I'll be a string someday."
diff --git a/Task/Copy-a-string/Forth/copy-a-string.fth b/Task/Copy-a-string/Forth/copy-a-string.fth
new file mode 100644
index 0000000000..397617bf0e
--- /dev/null
+++ b/Task/Copy-a-string/Forth/copy-a-string.fth
@@ -0,0 +1,9 @@
+\ Allocate two string buffers
+create stringa 256 allot
+create stringb 256 allot
+
+\ Copy a constant string into a string buffer
+s" Hello" stringa place
+
+\ Copy the contents of one string buffer into another
+stringa count  stringb place
diff --git a/Task/Copy-a-string/Fortran/copy-a-string.f b/Task/Copy-a-string/Fortran/copy-a-string.f
new file mode 100644
index 0000000000..4cf51efb9b
--- /dev/null
+++ b/Task/Copy-a-string/Fortran/copy-a-string.f
@@ -0,0 +1 @@
+str2 = str1
diff --git a/Task/Copy-a-string/GAP/copy-a-string.gap b/Task/Copy-a-string/GAP/copy-a-string.gap
new file mode 100644
index 0000000000..876fab4fc5
--- /dev/null
+++ b/Task/Copy-a-string/GAP/copy-a-string.gap
@@ -0,0 +1,13 @@
+#In GAP strings are lists of characters. An affectation simply copy references
+a := "more";
+b := a;
+b{[1..4]} := "less";
+a;
+# "less"
+
+# Here is a true copy
+a := "more";
+b := ShallowCopy(a);
+b{[1..4]} := "less";
+a;
+# "more"
diff --git a/Task/Copy-a-string/GML/copy-a-string.gml b/Task/Copy-a-string/GML/copy-a-string.gml
new file mode 100644
index 0000000000..5669d8cecc
--- /dev/null
+++ b/Task/Copy-a-string/GML/copy-a-string.gml
@@ -0,0 +1,2 @@
+src = "string"
+dest = src
diff --git a/Task/Copy-a-string/GUISS/copy-a-string.guiss b/Task/Copy-a-string/GUISS/copy-a-string.guiss
new file mode 100644
index 0000000000..2c69c2e5ff
--- /dev/null
+++ b/Task/Copy-a-string/GUISS/copy-a-string.guiss
@@ -0,0 +1,3 @@
+Start.Programs,Accessories,Notepad,
+Type:Hello world[pling],Highlight:Hello world[pling],
+Menu,Edit,Copy,Menu,Edit,Paste
diff --git a/Task/Copy-a-string/Gambas/copy-a-string.gambas b/Task/Copy-a-string/Gambas/copy-a-string.gambas
new file mode 100644
index 0000000000..bc990ccb95
--- /dev/null
+++ b/Task/Copy-a-string/Gambas/copy-a-string.gambas
@@ -0,0 +1,4 @@
+DIM src AS String
+DIM dst AS String
+src = "Hello"
+dst = src
diff --git a/Task/Copy-a-string/Go/copy-a-string.go b/Task/Copy-a-string/Go/copy-a-string.go
new file mode 100644
index 0000000000..4c9dae06d1
--- /dev/null
+++ b/Task/Copy-a-string/Go/copy-a-string.go
@@ -0,0 +1,2 @@
+src := "Hello"
+dst := src
diff --git a/Task/Copy-a-string/Groovy/copy-a-string-1.groovy b/Task/Copy-a-string/Groovy/copy-a-string-1.groovy
new file mode 100644
index 0000000000..946c476bab
--- /dev/null
+++ b/Task/Copy-a-string/Groovy/copy-a-string-1.groovy
@@ -0,0 +1,3 @@
+def string = 'Scooby-doo-bee-doo'    // assigns string object to a variable reference
+def stringRef = string               // assigns another variable reference to the same object
+def stringCopy = new String(string)  // copies string value into a new object, and assigns to a third variable reference
diff --git a/Task/Copy-a-string/Groovy/copy-a-string-2.groovy b/Task/Copy-a-string/Groovy/copy-a-string-2.groovy
new file mode 100644
index 0000000000..ca43da844a
--- /dev/null
+++ b/Task/Copy-a-string/Groovy/copy-a-string-2.groovy
@@ -0,0 +1,4 @@
+assert string == stringRef           // they have equal values (like Java equals(), not like Java ==)
+assert string.is(stringRef)          // they are references to the same objext (like Java ==)
+assert string == stringCopy          // they have equal values
+assert ! string.is(stringCopy)       // they are references to different objects (like Java !=)
diff --git a/Task/Copy-a-string/HicEst/copy-a-string.hicest b/Task/Copy-a-string/HicEst/copy-a-string.hicest
new file mode 100644
index 0000000000..aae9abc6e4
--- /dev/null
+++ b/Task/Copy-a-string/HicEst/copy-a-string.hicest
@@ -0,0 +1,2 @@
+src = "Hello World"
+dst = src
diff --git a/Task/Copy-a-string/Icon/copy-a-string.icon b/Task/Copy-a-string/Icon/copy-a-string.icon
new file mode 100644
index 0000000000..993c27b784
--- /dev/null
+++ b/Task/Copy-a-string/Icon/copy-a-string.icon
@@ -0,0 +1,6 @@
+procedure main()
+    a := "qwerty"
+    b := a
+    b[2+:4] := "uarterl"
+    write(a," -> ",b)
+end
diff --git a/Task/Copy-a-string/J/copy-a-string.j b/Task/Copy-a-string/J/copy-a-string.j
new file mode 100644
index 0000000000..25a339780f
--- /dev/null
+++ b/Task/Copy-a-string/J/copy-a-string.j
@@ -0,0 +1,2 @@
+src  =: 'hello'
+dest =: src
diff --git a/Task/Copy-a-string/Java/copy-a-string-1.java b/Task/Copy-a-string/Java/copy-a-string-1.java
new file mode 100644
index 0000000000..335dd04e19
--- /dev/null
+++ b/Task/Copy-a-string/Java/copy-a-string-1.java
@@ -0,0 +1,7 @@
+String src = "Hello";
+String newAlias = src;
+String strCopy = new String(src);
+
+//"newAlias == src" is true
+//"strCopy == src" is false
+//"strCopy.equals(src)" is true
diff --git a/Task/Copy-a-string/Java/copy-a-string-2.java b/Task/Copy-a-string/Java/copy-a-string-2.java
new file mode 100644
index 0000000000..f4bebf005a
--- /dev/null
+++ b/Task/Copy-a-string/Java/copy-a-string-2.java
@@ -0,0 +1 @@
+StringBuffer srcCopy = new StringBuffer("Hello");
diff --git a/Task/Copy-a-string/JavaScript/copy-a-string-1.js b/Task/Copy-a-string/JavaScript/copy-a-string-1.js
new file mode 100644
index 0000000000..3dea94432c
--- /dev/null
+++ b/Task/Copy-a-string/JavaScript/copy-a-string-1.js
@@ -0,0 +1,4 @@
+var container = {myString: "Hello"};
+var containerCopy = container; // Now both identifiers refer to the same object
+
+containerCopy.myString = "Goodbye"; // container.myString will also return "Goodbye"
diff --git a/Task/Copy-a-string/JavaScript/copy-a-string-2.js b/Task/Copy-a-string/JavaScript/copy-a-string-2.js
new file mode 100644
index 0000000000..b40d6b22d1
--- /dev/null
+++ b/Task/Copy-a-string/JavaScript/copy-a-string-2.js
@@ -0,0 +1,4 @@
+var a = "Hello";
+var b = a; // Same as saying window.b = window.a
+
+b = "Goodbye" // b contains a copy of a's value and a will still return "Hello"
diff --git a/Task/Copy-a-string/Joy/copy-a-string.joy b/Task/Copy-a-string/Joy/copy-a-string.joy
new file mode 100644
index 0000000000..21c5059dbc
--- /dev/null
+++ b/Task/Copy-a-string/Joy/copy-a-string.joy
@@ -0,0 +1 @@
+"hello" dup
diff --git a/Task/Copy-a-string/KonsolScript/copy-a-string.konsolscript b/Task/Copy-a-string/KonsolScript/copy-a-string.konsolscript
new file mode 100644
index 0000000000..221c382d2c
--- /dev/null
+++ b/Task/Copy-a-string/KonsolScript/copy-a-string.konsolscript
@@ -0,0 +1,2 @@
+Var:String str1 = "Hello";
+Var:String str2 = str1;
diff --git a/Task/Copy-a-string/Lang5/copy-a-string.lang5 b/Task/Copy-a-string/Lang5/copy-a-string.lang5
new file mode 100644
index 0000000000..60f54bd260
--- /dev/null
+++ b/Task/Copy-a-string/Lang5/copy-a-string.lang5
@@ -0,0 +1 @@
+'hello dup
diff --git a/Task/Copy-a-string/Liberty-BASIC/copy-a-string.liberty b/Task/Copy-a-string/Liberty-BASIC/copy-a-string.liberty
new file mode 100644
index 0000000000..8ece696bbc
--- /dev/null
+++ b/Task/Copy-a-string/Liberty-BASIC/copy-a-string.liberty
@@ -0,0 +1,4 @@
+src$ = "Hello"
+dest$ = src$
+print src$
+print dest$
diff --git a/Task/Copy-a-string/Lisaac/copy-a-string.lisaac b/Task/Copy-a-string/Lisaac/copy-a-string.lisaac
new file mode 100644
index 0000000000..21a7289b43
--- /dev/null
+++ b/Task/Copy-a-string/Lisaac/copy-a-string.lisaac
@@ -0,0 +1,9 @@
++ scon : STRING_CONSTANT;
++ svar : STRING;
+
+scon := "sample";
+svar := STRING.create 20;
+svar.copy scon;
+svar.append "!\n";
+
+svar.print;
diff --git a/Task/Copy-a-string/Logo/copy-a-string.logo b/Task/Copy-a-string/Logo/copy-a-string.logo
new file mode 100644
index 0000000000..72eab59371
--- /dev/null
+++ b/Task/Copy-a-string/Logo/copy-a-string.logo
@@ -0,0 +1,10 @@
+make "a "foo
+make "b "foo
+print .eq :a :b   ; true, identical symbols are reused
+
+make "c :a
+print .eq :a :c   ; true, copy a reference
+
+make "c word :b "||  ; force a copy of the contents of a word by appending the empty word
+print equal? :b :c   ; true
+print .eq :b :c     ; false
diff --git a/Task/Copy-a-string/Lua/copy-a-string.lua b/Task/Copy-a-string/Lua/copy-a-string.lua
new file mode 100644
index 0000000000..ee6294e308
--- /dev/null
+++ b/Task/Copy-a-string/Lua/copy-a-string.lua
@@ -0,0 +1,4 @@
+a = "string"
+b = a
+print(a == b) -->true
+print(b) -->string
diff --git a/Task/Copy-a-string/MATLAB/copy-a-string.m b/Task/Copy-a-string/MATLAB/copy-a-string.m
new file mode 100644
index 0000000000..8d539fd1bf
--- /dev/null
+++ b/Task/Copy-a-string/MATLAB/copy-a-string.m
@@ -0,0 +1,2 @@
+string1 = 'Hello';
+string2 = string1;
diff --git a/Task/Copy-a-string/MAXScript/copy-a-string.maxscript b/Task/Copy-a-string/MAXScript/copy-a-string.maxscript
new file mode 100644
index 0000000000..bc9773c71f
--- /dev/null
+++ b/Task/Copy-a-string/MAXScript/copy-a-string.maxscript
@@ -0,0 +1,2 @@
+str1 = "Hello"
+str2 = copy str1
diff --git a/Task/Copy-a-string/MUMPS/copy-a-string.mumps b/Task/Copy-a-string/MUMPS/copy-a-string.mumps
new file mode 100644
index 0000000000..8d1b3edbc6
--- /dev/null
+++ b/Task/Copy-a-string/MUMPS/copy-a-string.mumps
@@ -0,0 +1,2 @@
+SET S1="Greetings, Planet"
+SET S2=S1
diff --git a/Task/Copy-a-string/Maple/copy-a-string.maple b/Task/Copy-a-string/Maple/copy-a-string.maple
new file mode 100644
index 0000000000..1b42224aa4
--- /dev/null
+++ b/Task/Copy-a-string/Maple/copy-a-string.maple
@@ -0,0 +1,13 @@
+> s := "some string";
+                           s := "some string"
+
+> t := "some string";
+                           t := "some string"
+
+> evalb( s = t ); # they are equal
+                                  true
+
+> addressof( s ) = addressof( t ); # not just equal data, but the same address in memory
+                        3078334210 = 3078334210
+
+> u := t: # copy reference
diff --git a/Task/Copy-a-string/Mathematica/copy-a-string.math b/Task/Copy-a-string/Mathematica/copy-a-string.math
new file mode 100644
index 0000000000..5230fe5cf4
--- /dev/null
+++ b/Task/Copy-a-string/Mathematica/copy-a-string.math
@@ -0,0 +1,2 @@
+a="Hello World"
+b=a
diff --git a/Task/Copy-a-string/Maxima/copy-a-string.maxima b/Task/Copy-a-string/Maxima/copy-a-string.maxima
new file mode 100644
index 0000000000..dd5b5837f5
--- /dev/null
+++ b/Task/Copy-a-string/Maxima/copy-a-string.maxima
@@ -0,0 +1,19 @@
+/* It's possible in Maxima to access individual characters by subscripts, but it's not the usual way.
+Also, the result is "Lisp character", which cannot be used by other Maxima functions except cunlisp. The usual
+way to access characters is charat, returning a "Maxima character" (actually a one characte string). With the latter,
+it's impossible to modify a string in place, thus scopy is of little use. */
+
+a: "loners"$
+b: scopy(a)$
+c: a$
+
+c[2]: c[5]$
+
+a;
+"losers"
+
+b;
+"loners"
+
+c;
+"losers"
diff --git a/Task/Copy-a-string/Metafont/copy-a-string.metafont b/Task/Copy-a-string/Metafont/copy-a-string.metafont
new file mode 100644
index 0000000000..3366fbad12
--- /dev/null
+++ b/Task/Copy-a-string/Metafont/copy-a-string.metafont
@@ -0,0 +1,7 @@
+string s, a;
+s := "hello";
+a := s;
+s := s & " world";
+message s;  % writes "hello world"
+message a;  % writes "hello"
+end
diff --git a/Task/Copy-a-string/Mirah/copy-a-string.mirah b/Task/Copy-a-string/Mirah/copy-a-string.mirah
new file mode 100644
index 0000000000..54665c171a
--- /dev/null
+++ b/Task/Copy-a-string/Mirah/copy-a-string.mirah
@@ -0,0 +1,8 @@
+src = "Hello"
+new_alias = src
+
+puts 'interned strings are equal' if src == new_alias
+
+str_copy = String.new(src)
+puts 'non-interned strings are not equal' if str_copy != src
+puts 'compare strings with equals()' if str_copy.equals(src)
diff --git a/Task/Copy-a-string/Modula-3/copy-a-string.mod3 b/Task/Copy-a-string/Modula-3/copy-a-string.mod3
new file mode 100644
index 0000000000..e9051c5d8a
--- /dev/null
+++ b/Task/Copy-a-string/Modula-3/copy-a-string.mod3
@@ -0,0 +1,2 @@
+VAR src: TEXT := "Foo";
+VAR dst: TEXT := src;
diff --git a/Task/Copy-a-string/Nemerle/copy-a-string.nemerle b/Task/Copy-a-string/Nemerle/copy-a-string.nemerle
new file mode 100644
index 0000000000..e9c81bbae5
--- /dev/null
+++ b/Task/Copy-a-string/Nemerle/copy-a-string.nemerle
@@ -0,0 +1,18 @@
+using System;
+using System.Console;
+using Nemerle;
+
+module StrCopy
+{
+    Main() : void
+    {
+        mutable str1 = "I am not changed";      // str1 is bound to literal
+        def str2 = lazy(str1);                  // str2 will be bound when evaluated
+        def str3 = str1;                        // str3 is bound to value of str1
+        str1 = "I am changed";                  // str1 is bound to new literal
+        Write($"$(str1)\n$(str2)\n$(str3)\n");  // str2 is bound to value of str1
+        // Output: I am changed
+        //         I am changed
+        //         I am not changed
+    }
+}
diff --git a/Task/Copy-a-string/NetRexx/copy-a-string.netrexx b/Task/Copy-a-string/NetRexx/copy-a-string.netrexx
new file mode 100644
index 0000000000..9d0ba4bce3
--- /dev/null
+++ b/Task/Copy-a-string/NetRexx/copy-a-string.netrexx
@@ -0,0 +1,10 @@
+/* NetRexx */
+options replace format comments java crossref symbols nobinary
+
+s1 = 'This is a Rexx string'
+s2 = s1
+
+s2 = s2.changestr(' ', '_')
+
+say s1
+say s2
diff --git a/Task/Copy-a-string/NewLISP/copy-a-string.newlisp b/Task/Copy-a-string/NewLISP/copy-a-string.newlisp
new file mode 100644
index 0000000000..5a3663c4df
--- /dev/null
+++ b/Task/Copy-a-string/NewLISP/copy-a-string.newlisp
@@ -0,0 +1,6 @@
+(define (assert f msg) (if (not f) (println msg)))
+
+(setq  s "Greetings!"  c (copy s))
+(reverse c) ; Modifies c in place.
+
+(assert (= s c) "Strings not equal.")
diff --git a/Task/Copy-a-string/OCaml/copy-a-string.ocaml b/Task/Copy-a-string/OCaml/copy-a-string.ocaml
new file mode 100644
index 0000000000..8bf288b989
--- /dev/null
+++ b/Task/Copy-a-string/OCaml/copy-a-string.ocaml
@@ -0,0 +1 @@
+let dst = String.copy src
diff --git a/Task/Copy-a-string/Oberon-2/copy-a-string.oberon-2 b/Task/Copy-a-string/Oberon-2/copy-a-string.oberon-2
new file mode 100644
index 0000000000..4925c967ab
--- /dev/null
+++ b/Task/Copy-a-string/Oberon-2/copy-a-string.oberon-2
@@ -0,0 +1,10 @@
+MODULE CopyString;
+TYPE
+	String = ARRAY 128 OF CHAR;
+VAR
+	a,b: String;
+
+BEGIN
+	a := "plain string";
+	COPY(a,b);
+END CopyString.
diff --git a/Task/Copy-a-string/Objeck/copy-a-string.objeck b/Task/Copy-a-string/Objeck/copy-a-string.objeck
new file mode 100644
index 0000000000..cbe511f97c
--- /dev/null
+++ b/Task/Copy-a-string/Objeck/copy-a-string.objeck
@@ -0,0 +1,2 @@
+a := "GoodBye!";
+b := a;
diff --git a/Task/Copy-a-string/Objective-C/copy-a-string-1.m b/Task/Copy-a-string/Objective-C/copy-a-string-1.m
new file mode 100644
index 0000000000..6a670ee2b6
--- /dev/null
+++ b/Task/Copy-a-string/Objective-C/copy-a-string-1.m
@@ -0,0 +1,4 @@
+NSString *original = @"Literal String";
+NSString *new = [original copy];
+NSString *anotherNew = [NSString stringWithString:original];
+NSString *newMutable = [original mutableCopy];
diff --git a/Task/Copy-a-string/Objective-C/copy-a-string-2.m b/Task/Copy-a-string/Objective-C/copy-a-string-2.m
new file mode 100644
index 0000000000..c0c59c6c95
--- /dev/null
+++ b/Task/Copy-a-string/Objective-C/copy-a-string-2.m
@@ -0,0 +1,4 @@
+NSMutableString *original = [NSMutableString stringWithString:@"Literal String"];
+NSString *immutable = [original copy];
+NSString *anotherImmutable = [NSString stringWithString:original];
+NSMutableString *mutable = [original mutableCopy];
diff --git a/Task/Copy-a-string/Objective-C/copy-a-string-3.m b/Task/Copy-a-string/Objective-C/copy-a-string-3.m
new file mode 100644
index 0000000000..f5cf73d5db
--- /dev/null
+++ b/Task/Copy-a-string/Objective-C/copy-a-string-3.m
@@ -0,0 +1,2 @@
+const char *cstring = "I'm a plain C string";
+NSString *string = [NSString stringWithUTF8String:cstring];
diff --git a/Task/Copy-a-string/Objective-C/copy-a-string-4.m b/Task/Copy-a-string/Objective-C/copy-a-string-4.m
new file mode 100644
index 0000000000..9350717903
--- /dev/null
+++ b/Task/Copy-a-string/Objective-C/copy-a-string-4.m
@@ -0,0 +1,2 @@
+char bytes[] = "some data";
+NSString *string = [[NSString alloc] initWithBytes:bytes length:9 encoding:NSASCIIStringEncoding];
diff --git a/Task/Copy-a-string/Octave/copy-a-string.octave b/Task/Copy-a-string/Octave/copy-a-string.octave
new file mode 100644
index 0000000000..4cf51efb9b
--- /dev/null
+++ b/Task/Copy-a-string/Octave/copy-a-string.octave
@@ -0,0 +1 @@
+str2 = str1
diff --git a/Task/Copy-a-string/OxygenBasic/copy-a-string.oxy b/Task/Copy-a-string/OxygenBasic/copy-a-string.oxy
new file mode 100644
index 0000000000..20a0d3ca52
--- /dev/null
+++ b/Task/Copy-a-string/OxygenBasic/copy-a-string.oxy
@@ -0,0 +1,2 @@
+string s, t="hello"
+s=t
diff --git a/Task/Copy-a-string/PARI-GP/copy-a-string-1.pari b/Task/Copy-a-string/PARI-GP/copy-a-string-1.pari
new file mode 100644
index 0000000000..d28d54796d
--- /dev/null
+++ b/Task/Copy-a-string/PARI-GP/copy-a-string-1.pari
@@ -0,0 +1 @@
+s1=s
diff --git a/Task/Copy-a-string/PARI-GP/copy-a-string-2.pari b/Task/Copy-a-string/PARI-GP/copy-a-string-2.pari
new file mode 100644
index 0000000000..ba7b8cdd09
--- /dev/null
+++ b/Task/Copy-a-string/PARI-GP/copy-a-string-2.pari
@@ -0,0 +1,2 @@
+GEN string_copy = gcopy(string);
+GEN string_ref = string;
diff --git a/Task/Copy-a-string/PHP/copy-a-string.php b/Task/Copy-a-string/PHP/copy-a-string.php
new file mode 100644
index 0000000000..c943884ba1
--- /dev/null
+++ b/Task/Copy-a-string/PHP/copy-a-string.php
@@ -0,0 +1,2 @@
+$src = "Hello";
+$dst = $src;
diff --git a/Task/Copy-a-string/PL-I/copy-a-string.pli b/Task/Copy-a-string/PL-I/copy-a-string.pli
new file mode 100644
index 0000000000..9c8bcc231b
--- /dev/null
+++ b/Task/Copy-a-string/PL-I/copy-a-string.pli
@@ -0,0 +1,3 @@
+   declare (s1, s2) character (20) varying;
+   s1 = 'now is the time';
+   s2 = s1;
diff --git a/Task/Copy-a-string/Pascal/copy-a-string.pascal b/Task/Copy-a-string/Pascal/copy-a-string.pascal
new file mode 100644
index 0000000000..90fe98f704
--- /dev/null
+++ b/Task/Copy-a-string/Pascal/copy-a-string.pascal
@@ -0,0 +1,28 @@
+program in,out;
+
+type
+
+   pString = ^string;
+
+var
+
+   s1,s2 : string ;
+   pStr  : pString ;
+
+begin
+
+   /* direct copy */
+   s1 := 'Now is the time for all good men to come to the aid of their party.'
+   s2 := s1 ;
+
+   writeln(s1);
+   writeln(s2);
+
+   /* By Reference */
+   pStr := @s1 ;
+   writeln(pStr^);
+
+   pStr := @s2 ;
+   writeln(pStr^);
+
+end;
diff --git a/Task/Copy-a-string/Perl-6/copy-a-string-1.pl6 b/Task/Copy-a-string/Perl-6/copy-a-string-1.pl6
new file mode 100644
index 0000000000..efe8b2355a
--- /dev/null
+++ b/Task/Copy-a-string/Perl-6/copy-a-string-1.pl6
@@ -0,0 +1,6 @@
+my $original = 'Hello.';
+my $copy = $original;
+say $copy;            # prints "Hello."
+$copy = 'Goodbye.';
+say $copy;            # prints "Goodbye."
+say $original;        # prints "Hello."
diff --git a/Task/Copy-a-string/Perl-6/copy-a-string-2.pl6 b/Task/Copy-a-string/Perl-6/copy-a-string-2.pl6
new file mode 100644
index 0000000000..8a319eb841
--- /dev/null
+++ b/Task/Copy-a-string/Perl-6/copy-a-string-2.pl6
@@ -0,0 +1,6 @@
+my $original = 'Hello.';
+my $bound := $original;
+say $bound;           # prints "Hello."
+$bound = 'Goodbye.';
+say $bound;           # prints "Goodbye."
+say $original;        # prints "Goodbye."
diff --git a/Task/Copy-a-string/Perl-6/copy-a-string-3.pl6 b/Task/Copy-a-string/Perl-6/copy-a-string-3.pl6
new file mode 100644
index 0000000000..2583cf6b79
--- /dev/null
+++ b/Task/Copy-a-string/Perl-6/copy-a-string-3.pl6
@@ -0,0 +1,12 @@
+my $original = 'Hello.';
+my $bound-ro ::= $original;
+say $bound-ro;        # prints "Hello."
+try {
+  $bound-ro = 'Runtime error!';
+  CATCH {
+    say "$!";         # prints "Cannot modify readonly value"
+  };
+};
+say $bound-ro;        # prints "Hello."
+$original = 'Goodbye.';
+say $bound-ro;        # prints "Goodbye."
diff --git a/Task/Copy-a-string/Perl/copy-a-string-1.pl b/Task/Copy-a-string/Perl/copy-a-string-1.pl
new file mode 100644
index 0000000000..2fdda1f82a
--- /dev/null
+++ b/Task/Copy-a-string/Perl/copy-a-string-1.pl
@@ -0,0 +1,4 @@
+my $original = 'Hello.';
+my $new = $original;
+$new = 'Goodbye.';
+print "$original\n";   # prints "Hello."
diff --git a/Task/Copy-a-string/Perl/copy-a-string-2.pl b/Task/Copy-a-string/Perl/copy-a-string-2.pl
new file mode 100644
index 0000000000..03d65d8c61
--- /dev/null
+++ b/Task/Copy-a-string/Perl/copy-a-string-2.pl
@@ -0,0 +1,4 @@
+my $original = 'Hello.';
+my $ref = \$original;
+$$ref = 'Goodbye.';
+print "$original\n";   # prints "Goodbye."
diff --git a/Task/Copy-a-string/Perl/copy-a-string-3.pl b/Task/Copy-a-string/Perl/copy-a-string-3.pl
new file mode 100644
index 0000000000..5d6b88cca0
--- /dev/null
+++ b/Task/Copy-a-string/Perl/copy-a-string-3.pl
@@ -0,0 +1,5 @@
+my $original = 'Hello.';
+our $alias;
+local *alias = \$original;
+$alias = 'Good evening.';
+print "$original\n";   # prints "Good evening."
diff --git a/Task/Copy-a-string/Perl/copy-a-string-4.pl b/Task/Copy-a-string/Perl/copy-a-string-4.pl
new file mode 100644
index 0000000000..5af0a4ebf0
--- /dev/null
+++ b/Task/Copy-a-string/Perl/copy-a-string-4.pl
@@ -0,0 +1,6 @@
+use Lexical::Alias;
+my $original = 'Hello.';
+my $alias;
+alias $alias, $original;
+$alias = 'Good evening.';
+print "$original\n";   # prints "Good evening."
diff --git a/Task/Copy-a-string/PicoLisp/copy-a-string.l b/Task/Copy-a-string/PicoLisp/copy-a-string.l
new file mode 100644
index 0000000000..1e2200a444
--- /dev/null
+++ b/Task/Copy-a-string/PicoLisp/copy-a-string.l
@@ -0,0 +1,3 @@
+(setq Str1 "abcdef")
+(setq Str2 Str1)                       # Create a reference to that symbol
+(setq Str3 (name Str1))                # Create new symbol with name "abcdef"
diff --git a/Task/Copy-a-string/Pike/copy-a-string.pike b/Task/Copy-a-string/Pike/copy-a-string.pike
new file mode 100644
index 0000000000..fe848b4fcb
--- /dev/null
+++ b/Task/Copy-a-string/Pike/copy-a-string.pike
@@ -0,0 +1,4 @@
+int main(){
+   string hi = "Hello World.";
+   string ih = hi;
+}
diff --git a/Task/Copy-a-string/Pop11/copy-a-string-1.pop11 b/Task/Copy-a-string/Pop11/copy-a-string-1.pop11
new file mode 100644
index 0000000000..cb015964f5
--- /dev/null
+++ b/Task/Copy-a-string/Pop11/copy-a-string-1.pop11
@@ -0,0 +1,3 @@
+vars src, dst;
+'Hello' -> src;
+copy(src) -> dst;
diff --git a/Task/Copy-a-string/Pop11/copy-a-string-2.pop11 b/Task/Copy-a-string/Pop11/copy-a-string-2.pop11
new file mode 100644
index 0000000000..4827b85c29
--- /dev/null
+++ b/Task/Copy-a-string/Pop11/copy-a-string-2.pop11
@@ -0,0 +1,2 @@
+vars src='Hello';
+vars dst=copy(src);
diff --git a/Task/Copy-a-string/PostScript/copy-a-string.ps b/Task/Copy-a-string/PostScript/copy-a-string.ps
new file mode 100644
index 0000000000..1b1a195527
--- /dev/null
+++ b/Task/Copy-a-string/PostScript/copy-a-string.ps
@@ -0,0 +1 @@
+(hello) dup length string copy
diff --git a/Task/Copy-a-string/PowerShell/copy-a-string-1.psh b/Task/Copy-a-string/PowerShell/copy-a-string-1.psh
new file mode 100644
index 0000000000..91177b9261
--- /dev/null
+++ b/Task/Copy-a-string/PowerShell/copy-a-string-1.psh
@@ -0,0 +1,2 @@
+$str = "foo"
+$dup = $str
diff --git a/Task/Copy-a-string/PowerShell/copy-a-string-2.psh b/Task/Copy-a-string/PowerShell/copy-a-string-2.psh
new file mode 100644
index 0000000000..e29eed72c8
--- /dev/null
+++ b/Task/Copy-a-string/PowerShell/copy-a-string-2.psh
@@ -0,0 +1 @@
+$dup = $str.Clone()
diff --git a/Task/Copy-a-string/ProDOS/copy-a-string.dos b/Task/Copy-a-string/ProDOS/copy-a-string.dos
new file mode 100644
index 0000000000..ab067ad85a
--- /dev/null
+++ b/Task/Copy-a-string/ProDOS/copy-a-string.dos
@@ -0,0 +1,4 @@
+editvar /newvar /value=a /userinput=1 /title=Enter a string to be copied:
+editvar /newvar /value=b /userinput=1 /title=Enter current directory of the string:
+editvar /newvar /value=c /userinput=1 /title=Enter file to copy to:
+copy -a- from -b- to -c-
diff --git a/Task/Copy-a-string/PureBasic/copy-a-string.purebasic b/Task/Copy-a-string/PureBasic/copy-a-string.purebasic
new file mode 100644
index 0000000000..ee19d6c2cc
--- /dev/null
+++ b/Task/Copy-a-string/PureBasic/copy-a-string.purebasic
@@ -0,0 +1,2 @@
+src$ = "Hello"
+dst$ = src$
diff --git a/Task/Copy-a-string/Python/copy-a-string-1.py b/Task/Copy-a-string/Python/copy-a-string-1.py
new file mode 100644
index 0000000000..c4ad7ce2f4
--- /dev/null
+++ b/Task/Copy-a-string/Python/copy-a-string-1.py
@@ -0,0 +1,8 @@
+>>> src = "hello"
+>>> a = src
+>>> b = src[:]
+>>> import copy
+>>> c = copy.copy(src)
+>>> d = copy.deepcopy(src)
+>>> src is a is b is c is d
+True
diff --git a/Task/Copy-a-string/Python/copy-a-string-2.py b/Task/Copy-a-string/Python/copy-a-string-2.py
new file mode 100644
index 0000000000..9627b23946
--- /dev/null
+++ b/Task/Copy-a-string/Python/copy-a-string-2.py
@@ -0,0 +1,6 @@
+>>> a = 'hello'
+>>> b = ''.join(a)
+>>> a == b
+True
+>>> b is a  ### Might be True ... depends on "interning" implementation details!
+False
diff --git a/Task/Copy-a-string/R/copy-a-string.r b/Task/Copy-a-string/R/copy-a-string.r
new file mode 100644
index 0000000000..29fc4ab2e6
--- /dev/null
+++ b/Task/Copy-a-string/R/copy-a-string.r
@@ -0,0 +1,2 @@
+str1 <- "abc"
+str2 <- str1
diff --git a/Task/Copy-a-string/REBOL/copy-a-string.rebol b/Task/Copy-a-string/REBOL/copy-a-string.rebol
new file mode 100644
index 0000000000..cbdede8a50
--- /dev/null
+++ b/Task/Copy-a-string/REBOL/copy-a-string.rebol
@@ -0,0 +1,23 @@
+REBOL [
+    Title: "String Copy"
+    Date: 2009-12-16
+    Author: oofoe
+    URL: http://rosettacode.org/wiki/Copy_a_string
+]
+
+x: y: "Testing."
+y/2: #"X"
+print ["Both variables reference same string:" mold x "," mold y]
+
+x: "Slackeriffic!"
+print ["Now reference different strings:" mold x "," mold y]
+
+y: copy x        ; String copy here!
+y/3: #"X"        ; Modify string.
+print ["x copied to y, then modified:" mold x "," mold y]
+
+y: copy/part x 7 ; Copy only the first part of y to x.
+print ["Partial copy:" mold x "," mold y]
+
+y: copy/part  skip x 2  3
+print ["Partial copy from offset:" mold x "," mold y]
diff --git a/Task/Copy-a-string/REXX/copy-a-string.rexx b/Task/Copy-a-string/REXX/copy-a-string.rexx
new file mode 100644
index 0000000000..6d7223de5c
--- /dev/null
+++ b/Task/Copy-a-string/REXX/copy-a-string.rexx
@@ -0,0 +1,2 @@
+src = "this is a string"
+dst = src
diff --git a/Task/Copy-a-string/RLaB/copy-a-string.rlab b/Task/Copy-a-string/RLaB/copy-a-string.rlab
new file mode 100644
index 0000000000..982957f962
--- /dev/null
+++ b/Task/Copy-a-string/RLaB/copy-a-string.rlab
@@ -0,0 +1,4 @@
+>> s1 = "A string"
+A string
+>> s2 = s1
+A string
diff --git a/Task/Copy-a-string/Raven/copy-a-string-1.raven b/Task/Copy-a-string/Raven/copy-a-string-1.raven
new file mode 100644
index 0000000000..c85454e1bb
--- /dev/null
+++ b/Task/Copy-a-string/Raven/copy-a-string-1.raven
@@ -0,0 +1,2 @@
+'abc' as a
+a as b
diff --git a/Task/Copy-a-string/Raven/copy-a-string-2.raven b/Task/Copy-a-string/Raven/copy-a-string-2.raven
new file mode 100644
index 0000000000..83114cda50
--- /dev/null
+++ b/Task/Copy-a-string/Raven/copy-a-string-2.raven
@@ -0,0 +1,2 @@
+'abc' as a
+a copy as b
diff --git a/Task/Copy-a-string/Retro/copy-a-string.retro b/Task/Copy-a-string/Retro/copy-a-string.retro
new file mode 100644
index 0000000000..88609ba35d
--- /dev/null
+++ b/Task/Copy-a-string/Retro/copy-a-string.retro
@@ -0,0 +1 @@
+"this is a string" dup tempString
diff --git a/Task/Copy-a-string/Ruby/copy-a-string.rb b/Task/Copy-a-string/Ruby/copy-a-string.rb
new file mode 100644
index 0000000000..12dff3df12
--- /dev/null
+++ b/Task/Copy-a-string/Ruby/copy-a-string.rb
@@ -0,0 +1,4 @@
+original = "hello"
+reference = original
+copy1 = original.dup          # instance of original.class
+copy2 = String.new(original)  # instance of String
diff --git a/Task/Copy-a-string/Run-BASIC/copy-a-string.run b/Task/Copy-a-string/Run-BASIC/copy-a-string.run
new file mode 100644
index 0000000000..d9e369566a
--- /dev/null
+++ b/Task/Copy-a-string/Run-BASIC/copy-a-string.run
@@ -0,0 +1,2 @@
+origString$ = "Hello!"     ' create original string
+newString$  = origString$  ' make new strig from original
diff --git a/Task/Copy-a-string/SNOBOL4/copy-a-string.sno b/Task/Copy-a-string/SNOBOL4/copy-a-string.sno
new file mode 100644
index 0000000000..f1dbc15cb4
--- /dev/null
+++ b/Task/Copy-a-string/SNOBOL4/copy-a-string.sno
@@ -0,0 +1,8 @@
+* copy a to b
+          b = a = "test"
+          output = a
+          output = b
+* change the copy
+          b "t" = "T"
+          output = b
+end
diff --git a/Task/Copy-a-string/Sather/copy-a-string.sa b/Task/Copy-a-string/Sather/copy-a-string.sa
new file mode 100644
index 0000000000..3a9bba892f
--- /dev/null
+++ b/Task/Copy-a-string/Sather/copy-a-string.sa
@@ -0,0 +1,7 @@
+class MAIN is
+  main is
+    s  ::= "a string";
+    s1 ::= s;
+    -- s1 is a copy
+  end;
+end;
diff --git a/Task/Copy-a-string/Scala/copy-a-string.scala b/Task/Copy-a-string/Scala/copy-a-string.scala
new file mode 100644
index 0000000000..d77667d784
--- /dev/null
+++ b/Task/Copy-a-string/Scala/copy-a-string.scala
@@ -0,0 +1,2 @@
+val src = "Hello"
+val des = src
diff --git a/Task/Copy-a-string/Scheme/copy-a-string.ss b/Task/Copy-a-string/Scheme/copy-a-string.ss
new file mode 100644
index 0000000000..78b7afeb4a
--- /dev/null
+++ b/Task/Copy-a-string/Scheme/copy-a-string.ss
@@ -0,0 +1 @@
+(define dst (string-copy src))
diff --git a/Task/Copy-a-string/Seed7/copy-a-string.seed7 b/Task/Copy-a-string/Seed7/copy-a-string.seed7
new file mode 100644
index 0000000000..13289799b0
--- /dev/null
+++ b/Task/Copy-a-string/Seed7/copy-a-string.seed7
@@ -0,0 +1,3 @@
+var string: dest is "";
+
+dest := "Hello";
diff --git a/Task/Copy-a-string/Shiny/copy-a-string.shiny b/Task/Copy-a-string/Shiny/copy-a-string.shiny
new file mode 100644
index 0000000000..786a1bd2d9
--- /dev/null
+++ b/Task/Copy-a-string/Shiny/copy-a-string.shiny
@@ -0,0 +1,2 @@
+src: 'hello'
+cpy: src
diff --git a/Task/Copy-a-string/Slate/copy-a-string.slate b/Task/Copy-a-string/Slate/copy-a-string.slate
new file mode 100644
index 0000000000..87e9897cf8
--- /dev/null
+++ b/Task/Copy-a-string/Slate/copy-a-string.slate
@@ -0,0 +1 @@
+[ | :s | s == s copy] applyTo: {'hello'}. "returns False"
diff --git a/Task/Copy-a-string/Smalltalk/copy-a-string.st b/Task/Copy-a-string/Smalltalk/copy-a-string.st
new file mode 100644
index 0000000000..1a96f21266
--- /dev/null
+++ b/Task/Copy-a-string/Smalltalk/copy-a-string.st
@@ -0,0 +1,7 @@
+|s1 s2|
+"bind the var s1 to the object string on the right"
+s1 := 'i am a string'.
+"bind the var s2 to the same object..."
+s2 := s1.
+"bind s2 to a copy of the object bound to s1"
+s2 := (s1 copy).
diff --git a/Task/Copy-a-string/Standard-ML/copy-a-string-1.ml b/Task/Copy-a-string/Standard-ML/copy-a-string-1.ml
new file mode 100644
index 0000000000..082db97bde
--- /dev/null
+++ b/Task/Copy-a-string/Standard-ML/copy-a-string-1.ml
@@ -0,0 +1,4 @@
+val src = "Hello";
+val srcCopy = CharArray.array (size src, #"x"); (* 'x' is just dummy character *)
+CharArray.copyVec {src = src, dst = srcCopy, di = 0};
+src = CharArray.vector srcCopy; (* evaluates to true *)
diff --git a/Task/Copy-a-string/Standard-ML/copy-a-string-2.ml b/Task/Copy-a-string/Standard-ML/copy-a-string-2.ml
new file mode 100644
index 0000000000..dde78e09d9
--- /dev/null
+++ b/Task/Copy-a-string/Standard-ML/copy-a-string-2.ml
@@ -0,0 +1,2 @@
+val srcCopy2 = CharArray.array (CharArray.length srcCopy, #"x"); (* 'x' is just dummy character *)
+CharArray.copy {src = srcCopy, dst = srcCopy2, di = 0};
diff --git a/Task/Copy-a-string/TI-83-BASIC/copy-a-string.ti-83 b/Task/Copy-a-string/TI-83-BASIC/copy-a-string.ti-83
new file mode 100644
index 0000000000..7bd0518497
--- /dev/null
+++ b/Task/Copy-a-string/TI-83-BASIC/copy-a-string.ti-83
@@ -0,0 +1,2 @@
+:"Rosetta Code"→Str1
+:Str1→Str2
diff --git a/Task/Copy-a-string/TI-89-BASIC/copy-a-string.ti-89 b/Task/Copy-a-string/TI-89-BASIC/copy-a-string.ti-89
new file mode 100644
index 0000000000..b568101e09
--- /dev/null
+++ b/Task/Copy-a-string/TI-89-BASIC/copy-a-string.ti-89
@@ -0,0 +1,2 @@
+:"Rosetta Code"→str1
+:str1→str2
diff --git a/Task/Copy-a-string/TUSCRIPT/copy-a-string.tuscript b/Task/Copy-a-string/TUSCRIPT/copy-a-string.tuscript
new file mode 100644
index 0000000000..b956516891
--- /dev/null
+++ b/Task/Copy-a-string/TUSCRIPT/copy-a-string.tuscript
@@ -0,0 +1,3 @@
+$$ MODE TUSCRIPT
+str="Hello"
+dst=str
diff --git a/Task/Copy-a-string/Tcl/copy-a-string.tcl b/Task/Copy-a-string/Tcl/copy-a-string.tcl
new file mode 100644
index 0000000000..bab1d7bf37
--- /dev/null
+++ b/Task/Copy-a-string/Tcl/copy-a-string.tcl
@@ -0,0 +1,2 @@
+set src "Rosetta Code"
+set dst $src
diff --git a/Task/Copy-a-string/Toka/copy-a-string.toka b/Task/Copy-a-string/Toka/copy-a-string.toka
new file mode 100644
index 0000000000..1ea6cd5a19
--- /dev/null
+++ b/Task/Copy-a-string/Toka/copy-a-string.toka
@@ -0,0 +1,2 @@
+" hello" is-data a
+a string.clone is-data b
diff --git a/Task/Copy-a-string/Trith/copy-a-string.trith b/Task/Copy-a-string/Trith/copy-a-string.trith
new file mode 100644
index 0000000000..c5a2cc5786
--- /dev/null
+++ b/Task/Copy-a-string/Trith/copy-a-string.trith
@@ -0,0 +1 @@
+"Hello" dup
diff --git a/Task/Copy-a-string/UNIX-Shell/copy-a-string.sh b/Task/Copy-a-string/UNIX-Shell/copy-a-string.sh
new file mode 100644
index 0000000000..a64d58aac2
--- /dev/null
+++ b/Task/Copy-a-string/UNIX-Shell/copy-a-string.sh
@@ -0,0 +1,2 @@
+foo="Hello"
+bar=$foo    # This is a copy of the string
diff --git a/Task/Copy-a-string/V/copy-a-string.v b/Task/Copy-a-string/V/copy-a-string.v
new file mode 100644
index 0000000000..21c5059dbc
--- /dev/null
+++ b/Task/Copy-a-string/V/copy-a-string.v
@@ -0,0 +1 @@
+"hello" dup
diff --git a/Task/Copy-a-string/Visual-Basic-.NET/copy-a-string-1.visual b/Task/Copy-a-string/Visual-Basic-.NET/copy-a-string-1.visual
new file mode 100644
index 0000000000..2f46279ab4
--- /dev/null
+++ b/Task/Copy-a-string/Visual-Basic-.NET/copy-a-string-1.visual
@@ -0,0 +1,9 @@
+'Immutable Strings
+Dim a = "Test string"
+Dim b = a 'reference to same string
+Dim c = New String(a.ToCharArray) 'new string, normally not used
+
+'Mutable Strings
+Dim x As New Text.StringBuilder("Test string")
+Dim y = x 'reference
+Dim z = New Text.StringBuilder(x.ToString) 'new string
diff --git a/Task/Copy-a-string/Visual-Basic-.NET/copy-a-string-2.visual b/Task/Copy-a-string/Visual-Basic-.NET/copy-a-string-2.visual
new file mode 100644
index 0000000000..916ff4f4a2
--- /dev/null
+++ b/Task/Copy-a-string/Visual-Basic-.NET/copy-a-string-2.visual
@@ -0,0 +1,2 @@
+Dim a As String = "Test String"
+Dim b As String = String.Copy(a) ' New string
diff --git a/Task/Copy-a-string/XPL0/copy-a-string.xpl0 b/Task/Copy-a-string/XPL0/copy-a-string.xpl0
new file mode 100644
index 0000000000..e838129931
--- /dev/null
+++ b/Task/Copy-a-string/XPL0/copy-a-string.xpl0
@@ -0,0 +1,13 @@
+proc StrCopy(A, B);     \Copy string: A --> B
+char A, B;              \Strings: B must already have enough space "Reserved"
+int  I;                 \Beware if strings overlap
+for I:= 0 to -1>>1-1 do
+    [B(I):= A(I);
+    if A(I) >= $80 then return
+    ];
+
+char S1, S2, S3(13);
+[S1:= "Hello, world!";  \S1 now points to the string
+S2:= S1;                \S2 now also points to the string
+StrCopy(S1, S3);        \S3 points to a separate copy of the string
+]
diff --git a/Task/Copy-a-string/ZX-Spectrum-Basic/copy-a-string.zx b/Task/Copy-a-string/ZX-Spectrum-Basic/copy-a-string.zx
new file mode 100644
index 0000000000..912a4bdd72
--- /dev/null
+++ b/Task/Copy-a-string/ZX-Spectrum-Basic/copy-a-string.zx
@@ -0,0 +1,2 @@
+10 LET a$ = "Hello": REM a$ is the original string
+20 LET b$ = a$: REM b$ is the copy
diff --git a/Task/Dragon-curve/0DESCRIPTION b/Task/Dragon-curve/0DESCRIPTION
new file mode 100644
index 0000000000..95a84fea23
--- /dev/null
+++ b/Task/Dragon-curve/0DESCRIPTION
@@ -0,0 +1 @@
+Create and display a [[wp:dragon curve|dragon curve]] fractal. (You may either display the curve directly or write it to an image file.)
diff --git a/Task/Dragon-curve/1META.yaml b/Task/Dragon-curve/1META.yaml
new file mode 100644
index 0000000000..b3db16632c
--- /dev/null
+++ b/Task/Dragon-curve/1META.yaml
@@ -0,0 +1,4 @@
+---
+category:
+- Recursion
+note: Fractals
diff --git a/Task/Dragon-curve/ALGOL-68/dragon-curve.alg b/Task/Dragon-curve/ALGOL-68/dragon-curve.alg
new file mode 100644
index 0000000000..f1aabda413
--- /dev/null
+++ b/Task/Dragon-curve/ALGOL-68/dragon-curve.alg
@@ -0,0 +1,101 @@
+REAL sqrt 2 = sqrt(2), degrees = pi/180, width = 800-15, height = 600-15;
+
+PROC raise exception = ([]STRING args)VOID: (
+  putf(stand error, ($gx$, args, $l$));
+  stop
+);
+
+STRUCT (REAL x, y, heading, BOOL pen down) turtle;
+
+PROC turtle init = VOID: (
+  draw erase (window);
+  turtle := (0.5, 0.5, 0, TRUE);
+  draw move (window, x OF turtle, y OF turtle);
+  draw colour name(window, "white")
+);
+
+PROC turtle left = (REAL left turn)VOID:
+  heading OF turtle +:= left turn;
+
+PROC turtle right = (REAL right turn)VOID:
+  heading OF turtle -:= right turn;
+
+PROC turtle forward = (REAL distance)VOID:(
+  x OF turtle +:= distance * cos(heading OF turtle) / width * height;
+  y OF turtle +:= distance * sin(heading OF turtle);
+  IF pen down OF turtle THEN
+    draw line
+  ELSE
+    draw move
+  FI (window, x OF turtle, y OF turtle)
+);
+
+STRUCT ( INT count, depth, current shade, upb lines, upb colours ) morph;
+
+PROC morph init = (INT depth)VOID: (
+  count OF morph := 0;
+  depth OF morph := depth;
+  current shade OF morph := -1;
+  upb lines OF morph := 2**depth;
+  upb colours OF morph := 16
+);
+
+PROC morph colour = VOID: (
+  INT colour sectors = 3; # RGB #
+  INT candidate shade = ENTIER ( count OF morph / upb lines OF morph * upb colours OF morph );
+  IF candidate shade /= current shade OF morph THEN
+    current shade OF morph := candidate shade;
+    REAL colour sector = colour sectors * candidate shade / upb colours OF morph - 0.5;
+    REAL shade = colour sector - ENTIER colour sector;
+    CASE ENTIER colour sector + 1 # of 3 # IN
+      draw colour (window, 1 - shade, shade, 0),
+      draw colour (window, 0, 1 - shade, shade)
+    OUT
+      draw colour (window, shade, 0, 1 - shade)
+    ESAC
+  FI;
+  count OF morph +:= 1
+);
+
+PROC dragon init = VOID: (
+  pen down OF turtle := FALSE;
+    turtle forward(23/64); turtle right(90*degrees);
+    turtle forward (1/8);  turtle right(90*degrees);
+  pen down OF turtle := TRUE
+);
+
+PROC dragon = (REAL in step, in length, PROC(REAL)VOID zig, zag)VOID: (
+  IF in step <= 0 THEN
+    morph colour;
+    turtle forward(in length)
+  ELSE
+    REAL step = in step - 1;
+    REAL length = in length / sqrt 2;
+
+    zig(45*degrees);
+    dragon(step, length, turtle right, turtle left);
+    zag(90*degrees);
+    dragon(step, length, turtle left, turtle right);
+    zig(45*degrees)
+  FI
+);
+
+PROC window init = VOID: (
+  STRING aspect; FILE f; associate(f, aspect); putf(f, ($g(-4)"x"g(-3)$, width, height));
+  IF NOT draw device (window, "X", aspect)THEN
+    raise exception("cannot initialise X draw device") FI;
+  IF open (window, "Dragon Curve", stand draw channel) /= 0 THEN
+    raise exception("cannot open Dragon Curve window") FI
+);
+
+FILE window; window init;
+  INT cycle length = 18;
+  FOR snap shot TO cycle length DO
+    INT depth := (snap shot - 2) MOD cycle length;
+    turtle init; dragon init; morph init(depth);
+# move to initial turtle location #
+    dragon(depth, 7/8, turtle right, turtle left);
+    draw show (window);
+    VOID(system("sleep 1"))
+  OD;
+close (window)
diff --git a/Task/Dragon-curve/BASIC/dragon-curve.basic b/Task/Dragon-curve/BASIC/dragon-curve.basic
new file mode 100644
index 0000000000..249e1fcd18
--- /dev/null
+++ b/Task/Dragon-curve/BASIC/dragon-curve.basic
@@ -0,0 +1,29 @@
+DIM SHARED angle AS Double
+
+SUB turn (degrees AS Double)
+    angle = angle + degrees*3.14159265/180
+END SUB
+
+SUB forward (length AS Double)
+    LINE - STEP (cos(angle)*length, sin(angle)*length), 7
+END SUB
+
+SUB dragon (length AS Double, split AS Integer, d AS Double)
+    IF split=0 THEN
+        forward length
+    ELSE
+	turn d*45
+	dragon length/1.4142136, split-1, 1
+	turn -d*90
+	dragon length/1.4142136, split-1, -1
+	turn d*45
+    END IF
+END SUB
+
+' Main program
+
+SCREEN 12
+angle = 0
+PSET (150,180), 0
+dragon 400, 12, 1
+SLEEP
diff --git a/Task/Dragon-curve/BASIC256/dragon-curve.basic256 b/Task/Dragon-curve/BASIC256/dragon-curve.basic256
new file mode 100644
index 0000000000..25b1b0983a
--- /dev/null
+++ b/Task/Dragon-curve/BASIC256/dragon-curve.basic256
@@ -0,0 +1,50 @@
+# Version without functions (for BASIC-256 ver. 0.9.6.66)
+
+graphsize 390,270
+
+level = 18 : insize = 247		# initial values
+x = 92 : y = 94	        		#
+
+iters = 2^level		        	# total number of iterations
+qiter = 510/iters			# constant for computing colors
+SQ = sqrt(2) : QPI = pi/4		# constants
+
+rotation = 0 : iter = 0 : rq = 1.0	# state variables
+dim rqs(level)			        # stack for rq (rotation coefficient)
+
+color white
+fastgraphics
+rect 0,0,graphwidth,graphheight
+refresh
+gosub dragon
+refresh
+imgsave "Dragon_curve_BASIC-256.png", "PNG"
+end
+
+dragon:
+	if level<=0 then
+		yn = sin(rotation)*insize + y
+		xn = cos(rotation)*insize + x
+		if iter*2
+#include 
+#include 
+#include 
+
+/* x, y: coordinates of current point; dx, dy: direction of movement.
+ * Think turtle graphics.  They are divided by scale, so as to keep
+ * very small coords/increments without losing precission. clen is
+ * the path length travelled, which should equal to scale at the end
+ * of the curve.
+ */
+long long x, y, dx, dy, scale, clen;
+typedef struct { double r, g, b; } rgb;
+rgb ** pix;
+
+/* for every depth increase, rotate 45 degrees and scale up by sqrt(2)
+ * Note how coords can still be represented by integers.
+ */
+void sc_up()
+{
+	long long tmp = dx - dy; dy = dx + dy; dx = tmp;
+	scale *= 2; x *= 2; y *= 2;
+}
+
+/* Hue changes from 0 to 360 degrees over entire length of path; Value
+ * oscillates along the path to give some contrast between segments
+ * close to each other spatially.  RGB derived from HSV gets *added*
+ * to each pixel reached; they'll be dealt with later.
+ */
+void h_rgb(long long x, long long y)
+{
+	rgb *p = &pix[y][x];
+
+#	define SAT 1
+	double h = 6.0 * clen / scale;
+	double VAL = 1 - (cos(3.141592653579 * 64 * clen / scale) - 1) / 4;
+	double c = SAT * VAL;
+	double X = c * (1 - fabs(fmod(h, 2) - 1));
+
+	switch((int)h) {
+	case 0: p->r += c; p->g += X; return;
+	case 1:	p->r += X; p->g += c; return;
+	case 2: p->g += c; p->b += X; return;
+	case 3: p->g += X; p->b += c; return;
+	case 4: p->r += X; p->b += c; return;
+	default:
+		p->r += c; p->b += X;
+	}
+}
+
+/* string rewriting.  No need to keep the string itself, just execute
+ * its instruction recursively.
+ */
+void iter_string(const char * str, int d)
+{
+	long tmp;
+#	define LEFT  tmp = -dy; dy = dx; dx = tmp
+#	define RIGHT tmp = dy; dy = -dx; dx = tmp
+	while (*str != '\0') {
+		switch(*(str++)) {
+		case 'X':	if (d) iter_string("X+YF+", d - 1); continue;
+		case 'Y':	if (d) iter_string("-FX-Y", d - 1); continue;
+		case '+':	RIGHT; continue;
+		case '-':	LEFT;  continue;
+		case 'F':
+                        /* draw: increment path length; add color; move. Here
+                         * is why the code does not allow user to choose arbitrary
+                         * image size: if it's not a power of two, aliasing will
+                         * occur and grid-like bright or dark lines will result
+                         * when normalized later.  It can be gotten rid of, but that
+                         * involves computing multiplicative order and would be a huge
+                         * bore.
+                         */
+				clen ++;
+				h_rgb(x/scale, y/scale);
+				x += dx; y += dy;
+				continue;
+		}
+	}
+}
+
+void dragon(long leng, int depth)
+{
+	long i, d = leng / 3 + 1;
+	long h = leng + 3, w = leng + d * 3 / 2 + 2;
+
+	/* allocate pixel buffer */
+	rgb *buf = malloc(sizeof(rgb) * w * h);
+	pix = malloc(sizeof(rgb *) * h);
+	for (i = 0; i < h; i++)
+		pix[i] = buf + w * i;
+	memset(buf, 0, sizeof(rgb) * w * h);
+
+        /* init coords; scale up to desired; exec string */
+	x = y = d; dx = leng; dy = 0; scale = 1; clen = 0;
+	for (i = 0; i < depth; i++) sc_up();
+	iter_string("FX", depth);
+
+	/* write color PNM file */
+	unsigned char *fpix = malloc(w * h * 3);
+	double maxv = 0, *dbuf = (double*)buf;
+
+        /* find highest value among pixels; normalize image according
+         * to it.  Highest value would be at points most travelled, so
+         * this ends up giving curve edge a nice fade -- it's more apparaent
+         * if we increase iteration depth by one or two.
+         */
+	for (i = 3 * w * h - 1; i >= 0; i--)
+		if (dbuf[i] > maxv) maxv = dbuf[i];
+	for (i = 3 * h * w - 1; i >= 0; i--)
+		fpix[i] = 255 * dbuf[i] / maxv;
+
+	printf("P6\n%ld %ld\n255\n", w, h);
+	fflush(stdout); /* printf and fwrite may treat buffer differently */
+	fwrite(fpix, h * w * 3, 1, stdout);
+}
+
+int main(int c, char ** v)
+{
+	int size, depth;
+
+	depth  = (c > 1) ? atoi(v[1]) : 10;
+	size = 1 << depth;
+
+	fprintf(stderr, "size: %d depth: %d\n", size, depth);
+	dragon(size, depth * 2);
+
+	return 0;
+}
diff --git a/Task/Dragon-curve/Common-Lisp/dragon-curve.lisp b/Task/Dragon-curve/Common-Lisp/dragon-curve.lisp
new file mode 100644
index 0000000000..6b120b671e
--- /dev/null
+++ b/Task/Dragon-curve/Common-Lisp/dragon-curve.lisp
@@ -0,0 +1,19 @@
+(defpackage #:dragon
+  (:use #:clim-lisp #:clim)
+  (:export #:dragon #:dragon-part))
+(in-package #:dragon)
+
+(defun dragon-part (depth bend-direction)
+  (if (zerop depth)
+      (draw-line* *standard-output* 0 0 1 0)
+      (with-scaling (t (/ (sqrt 2)))
+        (with-rotation (t (* pi -1/4 bend-direction))
+          (dragon-part (1- depth) 1)
+          (with-translation (t 1 0)
+            (with-rotation (t (* pi 1/2 bend-direction))
+              (dragon-part (1- depth) -1)))))))
+
+(defun dragon (&optional (depth 7) (size 100))
+  (with-room-for-graphics ()
+    (with-scaling (t size)
+      (dragon-part depth 1))))
diff --git a/Task/Dragon-curve/D/dragon-curve-1.d b/Task/Dragon-curve/D/dragon-curve-1.d
new file mode 100644
index 0000000000..1f94f96e5a
--- /dev/null
+++ b/Task/Dragon-curve/D/dragon-curve-1.d
@@ -0,0 +1,106 @@
+import std.stdio, std.string;
+
+struct Board {
+    enum char spc = ' ';
+    char[][] b = [[' ']]; // Set at least 1x1 board.
+    int shiftx, shifty;
+
+    void clear() pure nothrow {
+        shiftx = shifty = 0;
+        b = [['\0']];
+    }
+
+    void check(in int x, in int y) pure nothrow {
+        while (y + shifty < 0) {
+            auto newr = new char[b[0].length];
+            newr[] = spc;
+            b = newr ~ b;
+            shifty++;
+        }
+
+        while (y + shifty >= b.length) {
+            auto newr = new char[b[0].length];
+            newr[] = spc;
+            b ~= newr;
+        }
+
+        while (x + shiftx < 0) {
+            foreach (ref c; b)
+                c = [spc] ~ c;
+            shiftx++;
+        }
+
+        while (x + shiftx >= b[0].length)
+            foreach (ref c; b)
+                c ~= [spc];
+    }
+
+    char opIndexAssign(in char value, in int x, in int y)
+    pure nothrow {
+        check(x, y);
+        b[y + shifty][x + shiftx] = value;
+        return value;
+    }
+
+    string toString() const /*pure*/ {
+        return xformat("%-(%s\n%)", b);
+    }
+}
+
+struct Turtle {
+    static struct TState {
+        int[2] xy;
+        int heading;
+    }
+
+    enum int[2][] dirs = [[1, 0],  [1,   1], [0,  1], [-1,  1],
+                          [-1, 0], [-1, -1], [0, -1],  [1, -1]];
+    enum string trace = r"-\|/-\|/";
+    TState t;
+
+    void reset() pure nothrow {
+        t = typeof(t).init;
+    }
+
+    void turn(in int dir) pure nothrow {
+        t.heading = (t.heading + 8 + dir) % 8;
+    }
+
+    void forward(ref Board b) pure /*nothrow*/ {
+        with (t) {
+            xy[] += dirs[heading][];
+            b[xy[0], xy[1]] = trace[heading];
+            xy[] += dirs[heading][];
+            b[xy[0], xy[1]] = b.spc;
+        }
+    }
+}
+
+void dragonX(in int n, ref Turtle t, ref Board b) pure /*nothrow*/ {
+    if (n >= 0) { // X -> X+YF+
+        dragonX(n - 1, t, b);
+        t.turn(2);
+        dragonY(n - 1, t, b);
+        t.forward(b);
+        t.turn(2);
+    }
+}
+
+void dragonY(in int n, ref Turtle t, ref Board b) pure /*nothrow*/ {
+    if (n >= 0) { // Y -> -FX-Y
+        t.turn(-2);
+        t.forward(b);
+        dragonX(n - 1, t, b);
+        t.turn(-2);
+        dragonY(n - 1, t, b);
+    }
+}
+
+void main() {
+    Turtle t;
+    Board b;
+                      // Seed : FX
+    t.forward(b);     // <- F
+    dragonX(7, t, b); // <- X
+    writeln(b);
+}
diff --git a/Task/Dragon-curve/D/dragon-curve-2.d b/Task/Dragon-curve/D/dragon-curve-2.d
new file mode 100644
index 0000000000..0ea775e2d4
--- /dev/null
+++ b/Task/Dragon-curve/D/dragon-curve-2.d
@@ -0,0 +1,19 @@
+import std.stdio, std.string;
+
+string drx(in size_t n) pure nothrow {
+    return n ? (drx(n - 1) ~ " +" ~ dry(n - 1) ~ " f +") : "";
+}
+
+string dry(in size_t n) pure nothrow {
+    return n ? (" - f" ~ drx(n - 1) ~ " -" ~ dry(n - 1)) : "";
+}
+
+string dragonCurvePS(in size_t n) pure nothrow {
+    return ["0 setlinewidth 300 400 moveto",
+            "/f{2 0 rlineto}def/+{90 rotate}def/-{-90 rotate}def\n",
+            "f", drx(n), " stroke showpage"].join();
+}
+
+void main() {
+    writeln(dragonCurvePS(9)); // Increase this for a bigger curve.
+}
diff --git a/Task/Dragon-curve/Emacs-Lisp/dragon-curve.l b/Task/Dragon-curve/Emacs-Lisp/dragon-curve.l
new file mode 100644
index 0000000000..446718b233
--- /dev/null
+++ b/Task/Dragon-curve/Emacs-Lisp/dragon-curve.l
@@ -0,0 +1,92 @@
+(require 'cl) ;; Emacs 22 and earlier for `ignore-errors'
+
+(defun dragon-ensure-line-above ()
+  "If point is in the first line of the buffer then insert a new line above."
+  (when (= (line-beginning-position) (point-min))
+    (save-excursion
+      (goto-char (point-min))
+      (insert "\n"))))
+
+(defun dragon-ensure-column-left ()
+  "If point is in the first column then insert a new column to the left.
+This is designed for use in `picture-mode'."
+  (when (zerop (current-column))
+    (save-excursion
+      (goto-char (point-min))
+      (insert " ")
+      (while (= 0 (forward-line 1))
+        (insert " ")))
+    (picture-forward-column 1)))
+
+(defun dragon-insert-char (char len)
+  "Insert CHAR repeated LEN many times.
+After each CHAR point move in the current `picture-mode'
+direction (per `picture-set-motion' etc).
+
+This is the same as `picture-insert' except in column 0 or row 0
+a new row or column is inserted to make room, with existing
+buffer contents shifted down or right."
+
+  (dotimes (i len)
+    (dragon-ensure-line-above)
+    (dragon-ensure-column-left)
+    (picture-insert char 1)))
+
+(defun dragon-bit-above-lowest-0bit (n)
+  "Return the bit above the lowest 0-bit in N.
+For example N=43 binary \"101011\" has lowest 0-bit at \"...0..\"
+and the bit above that is \"..1...\" so return 8 which is that
+bit."
+  (logand n (1+ (logxor n (1+ n)))))
+
+(defun dragon-next-turn-right-p (n)
+  "Return non-nil if the dragon curve should turn right after segment N.
+Segments are numbered from N=0 for the first, so calling with N=0
+is whether to turn right after drawing that N=0 segment."
+  (zerop (dragon-bit-above-lowest-0bit n)))
+
+(defun dragon-picture (len step)
+  "Draw the dragon curve in a *dragon* buffer.
+LEN is the number of segments of the curve to draw.
+STEP is the length of each segment, in characters.
+
+Any LEN can be given but a power-of-2 such as 256 shows the
+self-similar nature of the curve.
+
+If STEP >= 2 then the segments are lines using \"-\" or \"|\"
+characters (`picture-rectangle-h' and `picture-rectangle-v').
+If STEP=1 then only \"+\" corners.
+
+There's a `sit-for' delay in the drawing loop to draw the curve
+progressively on screen."
+
+  (interactive (list (read-number "Length of curve " 256)
+                     (read-number "Each step size " 3)))
+  (unless (>= step 1)
+    (error "Step length must be >= 1"))
+
+  (switch-to-buffer "*dragon*")
+  (erase-buffer)
+  (ignore-errors ;; if already in picture-mode
+    (picture-mode))
+
+  (dotimes (n len)  ;; n=0 to len-1, inclusive
+    (dragon-insert-char ?+ 1)  ;; corner char
+    (dragon-insert-char (if (zerop picture-vertical-step)
+                                    picture-rectangle-h picture-rectangle-v)
+                                (1- step))  ;; line chars
+
+    (if (dragon-next-turn-right-p n)
+        ;; turn right
+        (picture-set-motion (- picture-horizontal-step) picture-vertical-step)
+      ;; turn left
+      (picture-set-motion picture-horizontal-step (- picture-vertical-step)))
+
+    ;; delay to display the drawing progressively
+    (sit-for .01))
+
+  (picture-insert ?+ 1) ;; endpoint
+  (picture-mode-exit)
+  (goto-char (point-min)))
+
+(dragon-picture 128 2)
diff --git a/Task/Dragon-curve/Factor/dragon-curve.factor b/Task/Dragon-curve/Factor/dragon-curve.factor
new file mode 100644
index 0000000000..55ca257e7f
--- /dev/null
+++ b/Task/Dragon-curve/Factor/dragon-curve.factor
@@ -0,0 +1,53 @@
+USING: accessors colors colors.hsv fry kernel locals math
+math.constants math.functions opengl.gl typed ui ui.gadgets
+ui.gadgets.canvas ui.render ;
+
+IN: dragon
+
+CONSTANT: depth 12
+
+TUPLE: turtle
+    { angle fixnum }
+    { color float }
+    { x float }
+    { y float } ;
+
+TYPED: nxt-color ( turtle: turtle -- turtle )
+    [ [ 360 2 depth ^ /f + ] keep
+      1.0 1.0 1.0  >rgba-components glColor4d
+    ] change-color ; inline
+
+TYPED: draw-fwd ( x1: float y1: float x2: float y2: float -- )
+    GL_LINES glBegin glVertex2d glVertex2d glEnd ; inline
+
+TYPED:: fwd ( turtle: turtle l: float -- )
+    turtle x>>
+    turtle y>>
+    turtle angle>> pi * 180 / :> ( x y angle )
+    l angle [ cos * x + ] [ sin * y + ] 2bi :> ( dx dy )
+    turtle x y dx dy [ draw-fwd ] 2keep [ >>x ] [ >>y ] bi* drop ; inline
+
+TYPED: trn ( turtle: turtle d: fixnum -- turtle )
+    '[ _ + ] change-angle ; inline
+
+TYPED:: dragon' ( turtle: turtle l: float s: fixnum d: fixnum -- )
+    s zero? [
+        turtle nxt-color l fwd ! don't like this drop
+    ] [
+        turtle d  45 * trn l 2 sqrt / s 1 -  1 dragon'
+        turtle d -90 * trn l 2 sqrt / s 1 - -1 dragon'
+        turtle d  45 * trn drop
+    ] if ;
+
+: dragon ( -- )
+    0 0 150 180 turtle boa 400 depth 1 dragon' ;
+
+TUPLE: dragon-canvas < canvas ;
+
+M: dragon-canvas draw-gadget* [ drop dragon ] draw-canvas ;
+M: dragon-canvas pref-dim* drop { 640 480 } ;
+
+MAIN-WINDOW: dragon-window { { title "Dragon Curve" } }
+    dragon-canvas new-canvas >>gadgets ;
+
+MAIN: dragon-window
diff --git a/Task/Dragon-curve/Forth/dragon-curve-1.fth b/Task/Dragon-curve/Forth/dragon-curve-1.fth
new file mode 100644
index 0000000000..24a9a6ca44
--- /dev/null
+++ b/Task/Dragon-curve/Forth/dragon-curve-1.fth
@@ -0,0 +1,14 @@
+include turtle.fs
+
+2 value dragon-step
+
+: dragon ( depth dir -- )
+  over 0= if dragon-step fd  2drop exit then
+  dup rt
+  over 1-  45 recurse
+  dup 2* lt
+  over 1- -45 recurse
+  rt drop ;
+
+home clear
+10 45 dragon
diff --git a/Task/Dragon-curve/Forth/dragon-curve-2.fth b/Task/Dragon-curve/Forth/dragon-curve-2.fth
new file mode 100644
index 0000000000..c00dc12607
--- /dev/null
+++ b/Task/Dragon-curve/Forth/dragon-curve-2.fth
@@ -0,0 +1,20 @@
+include lib/graphics.4th
+include lib/gturtle.4th
+
+2 constant dragon-step
+
+: dragon ( depth dir -- )
+  over 0= if dragon-step forward 2drop exit then
+  dup right
+  over 1-  45 recurse
+  dup 2* left
+  over 1- -45 recurse
+  right drop ;
+
+150 pic_width !
+210 pic_height !
+color_image
+
+clear-screen 50 95 turtle!
+xpendown 13 45 dragon
+s" 4tHdragon.ppm" save_image
diff --git a/Task/Dragon-curve/Go/dragon-curve-1.go b/Task/Dragon-curve/Go/dragon-curve-1.go
new file mode 100644
index 0000000000..5129430a29
--- /dev/null
+++ b/Task/Dragon-curve/Go/dragon-curve-1.go
@@ -0,0 +1,76 @@
+package main
+
+import (
+    "fmt"
+    "image"
+    "image/color"
+    "image/draw"
+    "image/png"
+    "math"
+    "os"
+)
+
+// separation of the the two endpoints
+// make this a power of 2 for prettiest output
+const sep = 512
+// depth of recursion.  adjust as desired for different visual effects.
+const depth = 14
+
+var s = math.Sqrt2 / 2
+var sin = []float64{0, s, 1, s, 0, -s, -1, -s}
+var cos = []float64{1, s, 0, -s, -1, -s, 0, s}
+var p = color.NRGBA{64, 192, 96, 255}
+var b *image.NRGBA
+
+func main() {
+    width := sep * 11 / 6
+    height := sep * 4 / 3
+    bounds := image.Rect(0, 0, width, height)
+    b = image.NewNRGBA(bounds)
+    draw.Draw(b, bounds, image.NewUniform(color.White), image.ZP, draw.Src)
+    dragon(14, 0, 1, sep, sep/2, sep*5/6)
+    f, err := os.Create("dragon.png")
+    if err != nil {
+        fmt.Println(err)
+        return
+    }
+    if err = png.Encode(f, b); err != nil {
+        fmt.Println(err)
+    }
+    if err = f.Close(); err != nil {
+        fmt.Println(err)
+    }
+}
+
+func dragon(n, a, t int, d, x, y float64) {
+    if n <= 1 {
+        // Go packages used here do not have line drawing functions
+        // so we implement a very simple line drawing algorithm here.
+        // We take advantage of knowledge that we are always drawing
+        // 45 degree diagonal lines.
+        x1 := int(x + .5)
+        y1 := int(y + .5)
+        x2 := int(x + d*cos[a] + .5)
+        y2 := int(y + d*sin[a] + .5)
+        xInc := 1
+        if x1 > x2 {
+            xInc = -1
+        }
+        yInc := 1
+        if y1 > y2 {
+            yInc = -1
+        }
+        for x, y := x1, y1; ; x, y = x+xInc, y+yInc {
+            b.Set(x, y, p)
+            if x == x2 {
+                break
+            }
+        }
+        return
+    }
+    d *= s
+    a1 := (a - t) & 7
+    a2 := (a + t) & 7
+    dragon(n-1, a1, 1, d, x, y)
+    dragon(n-1, a2, -1, d, x+d*cos[a1], y+d*sin[a1])
+}
diff --git a/Task/Dragon-curve/Go/dragon-curve-2.go b/Task/Dragon-curve/Go/dragon-curve-2.go
new file mode 100644
index 0000000000..6b733fe5e4
--- /dev/null
+++ b/Task/Dragon-curve/Go/dragon-curve-2.go
@@ -0,0 +1,43 @@
+package main
+
+// Files required to build supporting package raster are found in:
+// * Bitmap
+// * Write a PPM file
+
+import (
+    "math"
+    "raster"
+)
+
+// separation of the the two endpoints
+// make this a power of 2 for prettiest output
+const sep = 512
+// depth of recursion.  adjust as desired for different visual effects.
+const depth = 14
+
+var s = math.Sqrt2 / 2
+var sin = []float64{0, s, 1, s, 0, -s, -1, -s}
+var cos = []float64{1, s, 0, -s, -1, -s, 0, s}
+var p = raster.Pixel{64, 192, 96}
+var b *raster.Bitmap
+
+func main() {
+    width := sep * 11 / 6
+    height := sep * 4 / 3
+    b = raster.NewBitmap(width, height)
+    b.Fill(raster.Pixel{255, 255, 255})
+    dragon(14, 0, 1, sep, sep/2, sep*5/6)
+    b.WritePpmFile("dragon.ppm")
+}
+
+func dragon(n, a, t int, d, x, y float64) {
+    if n <= 1 {
+        b.Line(int(x+.5), int(y+.5), int(x+d*cos[a]+.5), int(y+d*sin[a]+.5), p)
+        return
+    }
+    d *= s
+    a1 := (a - t) & 7
+    a2 := (a + t) & 7
+    dragon(n-1, a1, 1, d, x, y)
+    dragon(n-1, a2, -1, d, x+d*cos[a1], y+d*sin[a1])
+}
diff --git a/Task/Dragon-curve/Haskell/dragon-curve-1.hs b/Task/Dragon-curve/Haskell/dragon-curve-1.hs
new file mode 100644
index 0000000000..fdebe8150b
--- /dev/null
+++ b/Task/Dragon-curve/Haskell/dragon-curve-1.hs
@@ -0,0 +1,18 @@
+import Data.List
+import Graphics.Gnuplot.Simple
+
+-- diamonds
+-- pl = [[0,1],[1,0]]
+
+pl = [[0,0],[0,1]]
+r_90 = [[0,1],[-1,0]]
+
+ip :: [Int] -> [Int] -> Int
+ip xs = sum . zipWith (*) xs
+matmul xss yss = map (\xs -> map (ip xs ). transpose $ yss) xss
+
+vmoot xs = (xs++).map (zipWith (+) lxs). flip matmul r_90.
+          map (flip (zipWith (-)) lxs) .reverse . init $ xs
+   where lxs = last xs
+
+dragoncurve = iterate vmoot pl
diff --git a/Task/Dragon-curve/Haskell/dragon-curve-2.hs b/Task/Dragon-curve/Haskell/dragon-curve-2.hs
new file mode 100644
index 0000000000..797d72b985
--- /dev/null
+++ b/Task/Dragon-curve/Haskell/dragon-curve-2.hs
@@ -0,0 +1,11 @@
+x 0 = ""
+x n = (x$n-1)++" +"++(y$n-1)++" f +"
+y 0 = ""
+y n = " - f"++(x$n-1)++" -"++(y$n-1)
+
+dragon n =
+	concat ["0 setlinewidth 300 400 moveto",
+		"/f{2 0 rlineto}def/+{90 rotate}def/-{-90 rotate}def\n",
+		"f", x n, " stroke showpage"]
+
+main = putStrLn $ dragon 14
diff --git a/Task/Dragon-curve/HicEst/dragon-curve.hicest b/Task/Dragon-curve/HicEst/dragon-curve.hicest
new file mode 100644
index 0000000000..186bad6eab
--- /dev/null
+++ b/Task/Dragon-curve/HicEst/dragon-curve.hicest
@@ -0,0 +1,30 @@
+    CHARACTER dragon
+
+ 1  DLG(NameEdit=orders,DNum,  Button='&OK', TItle=dragon) ! input orders
+    WINDOW(WINdowhandle=wh, Height=1, X=1, TItle='Dragon curves up to order '//orders)
+
+    IF( LEN(dragon) < 2^orders) ALLOCATE(dragon, 2^orders)
+
+    AXIS(WINdowhandle=wh, Xaxis=2048, Yaxis=2048) ! 2048: black, linear, noGrid, noScales
+    dragon = ' '
+    NorthEastSouthWest = 0
+    x = 0
+    y = 1
+    LINE(PenUp, Color=1, x=0, y=0, x=x, y=y)
+    last = 1
+
+    DO order = 1, orders
+       changeRtoL = LEN_TRIM(dragon) + 1 + (LEN_TRIM(dragon) + 1)/2
+       dragon = TRIM(dragon) // 'R' // TRIM(dragon)
+       IF(changeRtoL > 2) dragon(changeRtoL) = 'L'
+
+       DO last = last, LEN_TRIM(dragon)
+          NorthEastSouthWest = MOD( NorthEastSouthWest-2*(dragon(last)=='L')+5, 4 )
+          x = x + (NorthEastSouthWest==1) - (NorthEastSouthWest==3)
+          y = y + (NorthEastSouthWest==0) - (NorthEastSouthWest==2)
+          LINE(Color=order, X=x, Y=y)
+       ENDDO
+    ENDDO
+    GOTO 1 ! this is to stimulate a discussion
+
+ END
diff --git a/Task/Dragon-curve/Icon/dragon-curve.icon b/Task/Dragon-curve/Icon/dragon-curve.icon
new file mode 100644
index 0000000000..fa6f896b40
--- /dev/null
+++ b/Task/Dragon-curve/Icon/dragon-curve.icon
@@ -0,0 +1,20 @@
+link linddraw,wopen
+
+procedure main()
+ gener   := 12                 # generations
+ w := h := 800                 # window size
+ rewrite := table()            # L rewrite rules
+ rewrite["X"] := "X+YF+"
+ rewrite["Y"] := "-FX-Y"
+ every (C := '') ++:= !!rewrite
+ every /rewrite[c := !C] := c  # map all rule characters
+
+ WOpen("size=" || w || "," || h, "dx=" || (w / 2),  "dy=" || (h / 2)) | stop("*** cannot open window")
+ WAttrib("fg=blue")
+
+ linddraw(0, 0, "FX", rewrite, 5, 90.0, gener, 0)
+ #        x,y, axiom, rules, length, angle, generations, delay
+
+ WriteImage("dragon-unicon" || ".gif")   # save the image
+ WDone()
+end
diff --git a/Task/Dragon-curve/J/dragon-curve-1.j b/Task/Dragon-curve/J/dragon-curve-1.j
new file mode 100644
index 0000000000..54415aa64e
--- /dev/null
+++ b/Task/Dragon-curve/J/dragon-curve-1.j
@@ -0,0 +1,4 @@
+require 'plot'
+start=: 0 0,: 1 0
+step=: ],{: +"1 (0 _1,: 1 0) +/ .*~ |.@}: -"1 {:
+plot <"1 |: step^:13 start
diff --git a/Task/Dragon-curve/J/dragon-curve-2.j b/Task/Dragon-curve/J/dragon-curve-2.j
new file mode 100644
index 0000000000..eff0cca2d6
--- /dev/null
+++ b/Task/Dragon-curve/J/dragon-curve-2.j
@@ -0,0 +1 @@
+([:pd[:<"1|:)every'reset';|.'show';step&.>^:(i.17) turns;
+    private double startingAngle, side;
+
+    public DragonCurve(int iter) {
+        super("Dragon Curve");
+        setBounds(100, 100, 800, 600);
+        setDefaultCloseOperation(EXIT_ON_CLOSE);
+        turns = getSequence(iter);
+        startingAngle = -iter * (Math.PI / 4);
+        side = 400 / Math.pow(2, iter / 2.);
+    }
+
+    public List getSequence(int iterations) {
+        List turnSequence = new ArrayList();
+        for (int i = 0; i < iterations; i++) {
+            List copy = new ArrayList(turnSequence);
+            Collections.reverse(copy);
+            turnSequence.add(1);
+            for (Integer turn : copy) {
+                turnSequence.add(-turn);
+            }
+        }
+        return turnSequence;
+    }
+
+    @Override
+    public void paint(Graphics g) {
+        g.setColor(Color.BLACK);
+        double angle = startingAngle;
+        int x1 = 230, y1 = 350;
+        int x2 = x1 + (int) (Math.cos(angle) * side);
+        int y2 = y1 + (int) (Math.sin(angle) * side);
+        g.drawLine(x1, y1, x2, y2);
+        x1 = x2;
+        y1 = y2;
+        for (Integer turn : turns) {
+            angle += turn * (Math.PI / 2);
+            x2 = x1 + (int) (Math.cos(angle) * side);
+            y2 = y1 + (int) (Math.sin(angle) * side);
+            g.drawLine(x1, y1, x2, y2);
+            x1 = x2;
+            y1 = y2;
+        }
+    }
+
+    public static void main(String[] args) {
+        new DragonCurve(14).setVisible(true);
+    }
+}
diff --git a/Task/Dragon-curve/JavaScript/dragon-curve-1.js b/Task/Dragon-curve/JavaScript/dragon-curve-1.js
new file mode 100644
index 0000000000..3176fa5cea
--- /dev/null
+++ b/Task/Dragon-curve/JavaScript/dragon-curve-1.js
@@ -0,0 +1,97 @@
+var DRAGON = (function () {
+   // MATRIX MATH
+   // -----------
+
+   var matrix = {
+      mult: function ( m, v ) {
+         return [ m[0][0] * v[0] + m[0][1] * v[1],
+                  m[1][0] * v[0] + m[1][1] * v[1] ];
+      },
+
+      minus: function ( a, b ) {
+         return [ a[0]-b[0], a[1]-b[1] ];
+      },
+
+      plus: function ( a, b ) {
+         return [ a[0]+b[0], a[1]+b[1] ];
+      }
+   };
+
+
+   // SVG STUFF
+   // ---------
+
+   // Turn a pair of points into an SVG path like "M1 1L2 2".
+   var toSVGpath = function (a, b) {  // type system fail
+      return "M" + a[0] + " " + a[1] + "L" + b[0] + " " + b[1];
+   };
+
+
+   // DRAGON MAKING
+   // -------------
+
+   // Make a dragon with a better fractal algorithm
+   var fractalMakeDragon = function (svgid, ptA, ptC, state, lr, interval) {
+
+      // make a new 
+      var path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
+      path.setAttribute( "class",  "dragon");
+      path.setAttribute( "d", toSVGpath(ptA, ptC) );
+
+      // append the new path to the existing 
+      var svg = document.getElementById(svgid); // call could be eliminated
+      svg.appendChild(path);
+
+      // if we have more iterations to go...
+      if (state > 1) {
+
+         // make a new point, either to the left or right
+         var growNewPoint = function (ptA, ptC, lr) {
+            var left  = [[ 1/2,-1/2 ],
+                         [ 1/2, 1/2 ]];
+
+            var right = [[ 1/2, 1/2 ],
+                         [-1/2, 1/2 ]];
+
+            return matrix.plus(ptA, matrix.mult( lr ? left : right,
+                                                 matrix.minus(ptC, ptA) ));
+         };
+
+         var ptB = growNewPoint(ptA, ptC, lr, state);
+
+         // then recurse using each new line, one left, one right
+         var recurse = function () {
+            // when recursing deeper, delete this svg path
+            svg.removeChild(path);
+
+            // then invoke again for new pair, decrementing the state
+            fractalMakeDragon(svgid, ptB, ptA, state-1, lr, interval);
+            fractalMakeDragon(svgid, ptB, ptC, state-1, lr, interval);
+         };
+
+         window.setTimeout(recurse, interval);
+      }
+   };
+
+
+   // Export these functions
+   // ----------------------
+   return {
+      fractal: fractalMakeDragon
+
+      // ARGUMENTS
+      // ---------
+      //    svgid    id of  element
+      //    ptA      first point [x,y] (from top left)
+      //    ptC      second point [x,y]
+      //    state    number indicating how many steps to recurse
+      //    lr       true/false to make new point on left or right
+
+      // CONFIG
+      // ------
+      // CSS rules should be made for the following
+      //    svg#fractal
+      //    svg path.dragon
+   };
+
+}());
diff --git a/Task/Dragon-curve/JavaScript/dragon-curve-2.js b/Task/Dragon-curve/JavaScript/dragon-curve-2.js
new file mode 100644
index 0000000000..6f075a8271
--- /dev/null
+++ b/Task/Dragon-curve/JavaScript/dragon-curve-2.js
@@ -0,0 +1,10 @@
+...
+
+...
+
+ +
+ +... diff --git a/Task/Dragon-curve/Liberty-BASIC/dragon-curve.liberty b/Task/Dragon-curve/Liberty-BASIC/dragon-curve.liberty new file mode 100644 index 0000000000..3ed1ad396b --- /dev/null +++ b/Task/Dragon-curve/Liberty-BASIC/dragon-curve.liberty @@ -0,0 +1,56 @@ +nomainwin + mainwin 50 20 + + WindowHeight =620 + WindowWidth =690 + + open "Graphics library" for graphics as #a + + #a, "trapclose [quit]" + + #a "down" + + Turn$ ="R" + Pace =100 + s = 16 + +[again] + print Turn$ + + #a "cls ; home ; north ; down ; fill black" + + for i =1 to len( Turn$) + v =255 *i /len( Turn$) + #a "color "; v; " 120 "; 255 -v + #a "go "; Pace + if mid$( Turn$, i, 1) ="R" then #a "turn 90" else #a "turn -90" + next i + + #a "color 255 120 0" + #a "go "; Pace + #a "flush" + + FlippedTurn$ ="" + for i =len( Turn$) to 1 step -1 + if mid$( Turn$, i, 1) ="R" then FlippedTurn$ =FlippedTurn$ +"L" else FlippedTurn$ =FlippedTurn$ +"R" + next i + + Turn$ =Turn$ +"R" +FlippedTurn$ + + Pace =Pace /1.35 + + scan + + timer 1000, [j] + wait +[j] + timer 0 + + if len( Turn$) <40000 then goto [again] + + +wait + +[quit] + close #a + end diff --git a/Task/Dragon-curve/Logo/dragon-curve-1.logo b/Task/Dragon-curve/Logo/dragon-curve-1.logo new file mode 100644 index 0000000000..4806040a4f --- /dev/null +++ b/Task/Dragon-curve/Logo/dragon-curve-1.logo @@ -0,0 +1,13 @@ +to dcr :step :length + make "step :step - 1 + make "length :length / 1.41421 + if :step > 0 [rt 45 dcr :step :length lt 90 dcl :step :length rt 45] + if :step = 0 [rt 45 fd :length lt 90 fd :length rt 45] +end + +to dcl :step :length + make "step :step - 1 + make "length :length / 1.41421 + if :step > 0 [lt 45 dcr :step :length rt 90 dcl :step :length lt 45] + if :step = 0 [lt 45 fd :length rt 90 fd :length lt 45] +end diff --git a/Task/Dragon-curve/Logo/dragon-curve-2.logo b/Task/Dragon-curve/Logo/dragon-curve-2.logo new file mode 100644 index 0000000000..3cc7def047 --- /dev/null +++ b/Task/Dragon-curve/Logo/dragon-curve-2.logo @@ -0,0 +1,11 @@ +to dc :step :length :dir + if :step = 0 [fd :length stop] + rt :dir + dc :step-1 :length/1.41421 45 + lt :dir lt :dir + dc :step-1 :length/1.41421 -45 + rt :dir +end +to dragon :step :length + dc :step :length 45 +end diff --git a/Task/Dragon-curve/Logo/dragon-curve-3.logo b/Task/Dragon-curve/Logo/dragon-curve-3.logo new file mode 100644 index 0000000000..0868f47776 --- /dev/null +++ b/Task/Dragon-curve/Logo/dragon-curve-3.logo @@ -0,0 +1,15 @@ +to O :step :length + if :step=1 [Rt 90 fd :length Lt 90] [O (:step - 1) (:length / 1.41421) N (:step - 1) (:length / 1.41421)] +end + +to N :step :length + if :step=1 [fd :length] [W (:step - 1) (:length / 1.41421) N (:step - 1) (:length / 1.41421)] +end + +to W :step :length + if :step=1 [Lt 90 fd :length Rt 90] [W (:step - 1) (:length / 1.41421) S (:step - 1) (:length / 1.41421)] +end + +to S :step :length + if :step=1 [Rt 180 fd :length Lt 180] [O (:step - 1) (:length / 1.41421) S (:step - 1) (:length / 1.41421)] +end diff --git a/Task/Dragon-curve/Logo/dragon-curve-4.logo b/Task/Dragon-curve/Logo/dragon-curve-4.logo new file mode 100644 index 0000000000..79e32db407 --- /dev/null +++ b/Task/Dragon-curve/Logo/dragon-curve-4.logo @@ -0,0 +1,24 @@ +; Return the bit above the lowest 1-bit in :n. +; If :n = binary "...z100..00" then the return is "z000..00". +; Eg. n=22 is binary 10110 the lowest 1-bit is the "...1." and the return is +; bit above that "..1.," which is 4. +to bit.above.lowest.1bit :n + output bitand :n (1 + (bitxor :n (:n - 1))) +end + +; Return angle +90 or -90 for dragon curve turn at point :n. +; The curve is reckoned as starting from n=0 so the first turn is at n=1. +to dragon.turn.angle :n + output ifelse (bit.above.lowest.1bit :n) = 0 [90] [-90] +end + +; Draw :steps many segments of the dragon curve. +to dragon :steps + localmake "step.len 12 ; length of each step + repeat :steps [ + forward :step.len + left dragon.turn.angle repcount ; repcount = 1 to :steps inclusive + ] +end + +dragon 256 diff --git a/Task/Dragon-curve/Logo/dragon-curve-5.logo b/Task/Dragon-curve/Logo/dragon-curve-5.logo new file mode 100644 index 0000000000..3efcade353 --- /dev/null +++ b/Task/Dragon-curve/Logo/dragon-curve-5.logo @@ -0,0 +1,20 @@ +; Draw :steps many segments of the dragon curve, with corners chamfered +; off with little 45-degree diagonals. +; Done this way the vertices don't touch. +to dragon.chamfer :steps + localmake "step.len 12 ; length of each step + localmake "straight.frac 0.5 ; fraction of the step to go straight + + localmake "straight.len :step.len * :straight.frac + localmake "diagonal.len (:step.len - :straight.len) * sqrt(1/2) + + repeat :steps [ + localmake "turn (dragon.turn.angle repcount)/2 ; +45 or -45 + forward :straight.len + left :turn + forward :diagonal.len + left :turn + ] +end + +dragon.chamfer 256 diff --git a/Task/Dragon-curve/Lua/dragon-curve.lua b/Task/Dragon-curve/Lua/dragon-curve.lua new file mode 100644 index 0000000000..712d9e74f7 --- /dev/null +++ b/Task/Dragon-curve/Lua/dragon-curve.lua @@ -0,0 +1,93 @@ +function dragon() + local l = "l" + local r = "r" + local inverse = {l = r, r = l} + local field = {r} + local num = 1 + local loop_limit = 6 --increase this number to render a bigger curve + for discard=1,loop_limit do + field[num+1] = r + for i=1,num do + field[i+num+1] = inverse[field[num-i+1]] + end + num = num*2+1 + end + return field +end + +function render(field, w, h, l) + local x = 0 + local y = 0 + local points = {} + local highest_x = 0 + local highest_y = 0 + local lowest_x = 0 + local lowest_y = 0 + local l = "l" + local r = "r" + local u = "u" + local d = "d" + local heading = u + local turn = {r = {r = d, d = l, l = u, u = r}, l = {r = u, u = l, l = d, d = r}} + for k, v in ipairs(field) do + heading = turn[v][heading] + for i=1,3 do + points[#points+1] = {x, y} + if heading == l then + x = x-w + elseif heading == r then + x = x+w + elseif heading == u then + y = y-h + elseif heading == d then + y = y+h + end + if x > highest_x then + highest_x = x + elseif x < lowest_x then + lowest_x = x + end + if y > highest_y then + highest_y = y + elseif y < lowest_y then + lowest_y = y + end + end + end + points[#points+1] = {x, y} + highest_x = highest_x - lowest_x + 1 + highest_y = highest_y - lowest_y + 1 + for k, v in ipairs(points) do + v[1] = v[1] - lowest_x + 1 + v[2] = v[2] - lowest_y + 1 + end + return highest_x, highest_y, points +end + +function render_text_mode() + local width, height, points = render(dragon(), 1, 1, 1) + local rows = {} + for i=1,height do + rows[i] = {} + for j=1,width do + rows[i][j] = ' ' + end + end + for k, v in ipairs(points) do + rows[v[2]][v[1]] = "*" + end + + for i=1,height do + print(table.concat(rows[i], "")) + end +end + +function dump_points() + local width, height, points = render(dragon(), 4, 4, 1) + for k, v in ipairs(points) do + print(unpack(v)) + end +end + +--replace this line with dump_points() to output a list of coordinates: +render_text_mode() diff --git a/Task/Dragon-curve/Mathematica/dragon-curve.math b/Task/Dragon-curve/Mathematica/dragon-curve.math new file mode 100644 index 0000000000..06c7ec5545 --- /dev/null +++ b/Task/Dragon-curve/Mathematica/dragon-curve.math @@ -0,0 +1,4 @@ +FoldOutLine[{a_,b_}]:={{a,#},{b,#}}&[a+0.5(b-a)+{{0.,0.5},{-0.5,0.}}.(b-a)] +NextStep[in_]:=Flatten[FoldOutLine/@in,1] +lines={{{0.,0.},{1.,0.}}}; +Graphics[Line/@Nest[NextStep,lines,11]] diff --git a/Task/Dragon-curve/Metafont/dragon-curve.metafont b/Task/Dragon-curve/Metafont/dragon-curve.metafont new file mode 100644 index 0000000000..a2061d786f --- /dev/null +++ b/Task/Dragon-curve/Metafont/dragon-curve.metafont @@ -0,0 +1,20 @@ +mode_setup; +dragoniter := 8; +beginchar("D", 25pt#, 25pt#, 0pt#); + pickup pencircle scaled .5pt; + x1 = 0; x2 = w; y1 = y2 = .5h; + mstep := .5; sg := -1; + for i = 1 upto dragoniter: + for v = 1 step mstep until (2-mstep): + if unknown z[v+mstep]: + pair t; + t := .7071[ z[v], z[v+2mstep] ]; + z[v+mstep] = t rotatedaround(z[v], 45sg); + sg := -1*sg; + fi + endfor + mstep := mstep/2; + endfor + draw for v:=1 step 2mstep until (2-2mstep): z[v] -- endfor z[2]; +endchar; +end diff --git a/Task/Dragon-curve/OCaml/dragon-curve-1.ocaml b/Task/Dragon-curve/OCaml/dragon-curve-1.ocaml new file mode 100644 index 0000000000..5662e68c91 --- /dev/null +++ b/Task/Dragon-curve/OCaml/dragon-curve-1.ocaml @@ -0,0 +1,78 @@ +(* This constant does not seem to be defined anywhere in the standard modules *) +let pi = acos (-1.0); + +(* +** CLASS dragon_curve_computer: +** ---------------------------- +** Computes the coordinates for the line drawing the curve. +** - initial_x initial_y: coordinates for starting point for curve +** - total_length: total length for the curve +** - total_splits: total number of splits to perform +*) +class dragon_curve_computer initial_x initial_y total_length total_splits = + object(self) + val mutable current_x = (float_of_int initial_x) (* current x coordinate in curve *) + val mutable current_y = (float_of_int initial_y) (* current y coordinate in curve *) + val mutable current_angle = 0.0 (* current angle *) + + (* + ** METHOD compute_coords: + ** ---------------------- + ** Actually computes the coordinates in the line for the curve + ** - length: length for current iteration + ** - nb_splits: number of splits to perform for current iteration + ** - direction: direction for current line (-1.0 or 1.0) + ** Returns: the list of coordinates for the line in this iteration + *) + method compute_coords length nb_splits direction = + (* If all splits have been done *) + if nb_splits = 0 + then + begin + (* Draw line segment, updating current coordinates *) + current_x <- current_x +. length *. cos current_angle; + current_y <- current_y +. length *. sin current_angle; + [(int_of_float current_x, int_of_float current_y)] + end + (* If there are still splits to perform *) + else + begin + (* Compute length for next iteration *) + let sub_length = length /. sqrt 2.0 in + (* Turn 45 degrees to left or right depending on current direction and draw part + of curve in this direction *) + current_angle <- current_angle +. direction *. pi /. 4.0; + let coords1 = self#compute_coords sub_length (nb_splits - 1) 1.0 in + (* Turn 90 degrees in the other direction and draw part of curve in that direction *) + current_angle <- current_angle -. direction *. pi /. 2.0; + let coords2 = self#compute_coords sub_length (nb_splits - 1) (-1.0) in + (* Turn back 45 degrees to set head in the initial direction again *) + current_angle <- current_angle +. direction *. pi /. 4.0; + (* Concatenate both sub-curves to get the full curve for this iteration *) + coords1 @ coords2 + end + + (* + ** METHOD get_coords: + ** ------------------ + ** Returns the coordinates for the curve with the parameters set in the object initializer + *) + method get_coords = self#compute_coords total_length total_splits 1.0 + end;; + + +(* +** MAIN PROGRAM: +** ============= +*) +let () = + (* Curve is displayed in a Tk canvas *) + let top=Tk.openTk() in + let c = Canvas.create ~width:400 ~height:400 top in + Tk.pack [c]; + (* Create instance computing the curve coordinates *) + let dcc = new dragon_curve_computer 100 200 200.0 16 in + (* Create line with these coordinates in canvas *) + ignore (Canvas.create_line ~xys: dcc#get_coords c); + Tk.mainLoop (); +;; diff --git a/Task/Dragon-curve/OCaml/dragon-curve-2.ocaml b/Task/Dragon-curve/OCaml/dragon-curve-2.ocaml new file mode 100644 index 0000000000..4e8dde326e --- /dev/null +++ b/Task/Dragon-curve/OCaml/dragon-curve-2.ocaml @@ -0,0 +1,15 @@ +let zig (x1,y1) (x2,y2) = (x1+x2+y1-y2)/2, (x2-x1+y1+y2)/2 +let zag (x1,y1) (x2,y2) = (x1+x2-y1+y2)/2, (x1-x2+y1+y2)/2 + +let rec dragon p1 p2 p3 n = + if n = 0 then [p1;p2] else + (dragon p1 (zig p1 p2) p2 (n-1)) @ (dragon p2 (zag p2 p3) p3 (n-1)) + +let _ = + let top = Tk.openTk() in + let c = Canvas.create ~width:430 ~height:300 top in + Tk.pack [c]; + let p1, p2 = (100, 100), (356,100) in + let points = dragon p1 (zig p1 p2) p2 15 in + ignore (Canvas.create_line ~xys: points c); + Tk.mainLoop () diff --git a/Task/Dragon-curve/Pascal/dragon-curve-1.pascal b/Task/Dragon-curve/Pascal/dragon-curve-1.pascal new file mode 100644 index 0000000000..a38e05cca4 --- /dev/null +++ b/Task/Dragon-curve/Pascal/dragon-curve-1.pascal @@ -0,0 +1,43 @@ +procedure dcr(step,dir:integer;length:real); + begin; + step:=step -1; + length:= length/sqrt(2); + if dir > 0 then + begin + if step > 0 then + begin + turnright(45); + dcr(step,1,length); + turnleft(90); + dcr(step,0,length); + turnright(45); + end + else + begin + turnright(45); + forward(length); + turnleft(90); + forward(length); + turnright(45); + end; + end + else + begin + if step > 0 then + begin + turnleft(45); + dcr(step,1,length); + turnright(90); + dcr(step,0,length); + turnleft(45); + end + else + begin + turnleft(45); + forward(length); + turnright(90); + forward(length); + turnleft(45); + end; + end; +end; diff --git a/Task/Dragon-curve/Pascal/dragon-curve-2.pascal b/Task/Dragon-curve/Pascal/dragon-curve-2.pascal new file mode 100644 index 0000000000..d8d6dce57e --- /dev/null +++ b/Task/Dragon-curve/Pascal/dragon-curve-2.pascal @@ -0,0 +1,8 @@ +begin + init; + penup; + back(100); + pendown; + dcr(step,direction,length); + close; +end. diff --git a/Task/Dragon-curve/Perl-6/dragon-curve.pl6 b/Task/Dragon-curve/Perl-6/dragon-curve.pl6 new file mode 100644 index 0000000000..4eec9c2d0f --- /dev/null +++ b/Task/Dragon-curve/Perl-6/dragon-curve.pl6 @@ -0,0 +1,25 @@ +say " + +"; + +my $order = 10; # akin to number of recursion steps +my $d_size = 1000; # size in pixels +my $turn_angle = pi/2; # turn angle of each segment, 90 degrees for the canonical dragon + +my $angle = pi - ($order * (pi/4)); # starting angle +my $len = ($d_size/1.5) / sqrt(2)**$order; # size of each segment +my ($x, $y) = ($d_size*5/6, $d_size*1/3); # starting point + +for 0..2**$order-1 -> $i +{ + # find which side to turn based on the iteration + $angle += ((($i +& -$i) +< 1) +& $i) ?? -$turn_angle !! $turn_angle; + + my ($dx, $dy) = ($x + $len * $angle.sin, $y - $len * $angle.cos); + say ""; + ($x, $y) = ($dx, $dy); +} + +say ""; diff --git a/Task/Dragon-curve/PicoLisp/dragon-curve.l b/Task/Dragon-curve/PicoLisp/dragon-curve.l new file mode 100644 index 0000000000..b6acd72e47 --- /dev/null +++ b/Task/Dragon-curve/PicoLisp/dragon-curve.l @@ -0,0 +1,40 @@ +# Need some turtle graphics +(load "@lib/math.l") + +(setq + *TurtleX 100 # X position + *TurtleY 75 # Y position + *TurtleA 0.0 ) # Angle + +(de fd (Img Len) # Forward + (let (R (*/ *TurtleA pi 180.0) DX (*/ (cos R) Len 1.0) DY (*/ (sin R) Len 1.0)) + (brez Img *TurtleX *TurtleY DX DY) + (inc '*TurtleX DX) + (inc '*TurtleY DY) ) ) + +(de rt (A) # Right turn + (inc '*TurtleA A) ) + +(de lt (A) # Left turn + (dec '*TurtleA A) ) + + +# Dragon curve stuff +(de *DragonStep . 4) + +(de dragon (Img Depth Dir) + (if (=0 Depth) + (fd Img *DragonStep) + (rt Dir) + (dragon Img (dec Depth) 45.0) + (lt (* 2 Dir)) + (dragon Img (dec Depth) -45.0) + (rt Dir) ) ) + +# Run it +(let Img (make (do 200 (link (need 300 0)))) # Create image 300 x 200 + (dragon Img 10 45.0) # Build dragon curve + (out "img.pbm" # Write to bitmap file + (prinl "P1") + (prinl 300 " " 200) + (mapc prinl Img) ) ) diff --git a/Task/Dragon-curve/PostScript/dragon-curve-1.ps b/Task/Dragon-curve/PostScript/dragon-curve-1.ps new file mode 100644 index 0000000000..a988ef1470 --- /dev/null +++ b/Task/Dragon-curve/PostScript/dragon-curve-1.ps @@ -0,0 +1,44 @@ +%!PS +%%BoundingBox: 0 0 550 400 +/ifpendown false def +/rotation 0 def +/srootii 2 sqrt def +/turn { + rotation add /rotation exch def + } def +/forward { + dup rotation cos mul + exch rotation sin mul + ifpendown + { rlineto } + { rmoveto } + ifelse + } def +/penup { + /ifpendown false def + } def +/pendown { + /ifpendown true def + } def + +/dragon { % [ length, split, d ] + dup + dup 1 get 0 eq + { 0 get forward } + { dup 2 get 45 mul turn + dup aload pop pop + 1 sub exch srootii div exch + 1 3 array astore dragon pop + dup 2 get 90 mul neg turn + dup aload pop pop + 1 sub exch srootii div exch + -1 3 array astore dragon + dup 2 get 45 mul turn + } + ifelse + pop + } def +150 150 moveto pendown [ 300 12 1 ] dragon stroke +% 0 0 moveto 550 0 rlineto 0 400 rlineto -550 0 rlineto closepath stroke +showpage +%%END diff --git a/Task/Dragon-curve/PostScript/dragon-curve-2.ps b/Task/Dragon-curve/PostScript/dragon-curve-2.ps new file mode 100644 index 0000000000..13d03c3acf --- /dev/null +++ b/Task/Dragon-curve/PostScript/dragon-curve-2.ps @@ -0,0 +1,22 @@ +%!PS-Adobe-3.0 +%%BoundingBox 0 0 300 300 + +/+ { 90 rotate } def +/- {-90 rotate } def +/!1 { dup 1 sub dup 0 eq not } def + +/F { 180 0 rlineto } def +/X { !1 { X + Y F + } if pop } def +/Y { !1 { - F X - Y } if pop } def + +/dragon { + gsave + 70 180 moveto + dup 1 sub { 1 2 div sqrt dup scale -45 rotate } repeat + F X stroke + grestore +} def + +1 1 20 { dragon showpage } for + +%%EOF diff --git a/Task/Dragon-curve/Prolog/dragon-curve.pro b/Task/Dragon-curve/Prolog/dragon-curve.pro new file mode 100644 index 0000000000..cca7a2d174 --- /dev/null +++ b/Task/Dragon-curve/Prolog/dragon-curve.pro @@ -0,0 +1,60 @@ +dragonCurve(N) :- + dcg_dg(N, [left], DCL, []), + Side = 4, + Angle is -N * (pi/4), + dcg_computePath(Side, Angle, DCL, point(180,400), P, []), + new(D, window('Dragon Curve')), + send(D, size, size(800,600)), + new(Path, path(poly)), + send_list(Path, append, P), + send(D, display, Path), + send(D, open). + + +% compute the list of points of the Dragon Curve +dcg_computePath(Side, Angle, [left | DCT], point(X1, Y1)) --> + [point(X1, Y1)], + { X2 is X1 + Side * cos(Angle), + Y2 is Y1 + Side * sin(Angle), + Angle1 is Angle + pi / 2 + }, + dcg_computePath(Side, Angle1, DCT, point(X2, Y2)). + +dcg_computePath(Side, Angle, [right | DCT], point(X1, Y1)) --> + [point(X1, Y1)], + { X2 is X1 + Side * cos(Angle), + Y2 is Y1 + Side * sin(Angle), + Angle1 is Angle - pi / 2 + }, + dcg_computePath(Side, Angle1, DCT, point(X2, Y2)). + + +dcg_computePath(_Side, _Angle, [], point(X1, Y1)) --> + [ point(X1, Y1)]. + + +% compute the list of the "turns" of the Dragon Curve +dcg_dg(1, L) --> L. + +dcg_dg(N, L) --> + {dcg_dg(L, L1, []), + N1 is N - 1}, + dcg_dg(N1, L1). + +% one interation of the process +dcg_dg(L) --> + L, + [left], + inverse(L). + +inverse([H | T]) --> + inverse(T), + inverse(H). + +inverse([]) --> []. + +inverse(left) --> + [right]. + +inverse(right) --> + [left]. diff --git a/Task/Dragon-curve/PureBasic/dragon-curve.purebasic b/Task/Dragon-curve/PureBasic/dragon-curve.purebasic new file mode 100644 index 0000000000..60fba552b3 --- /dev/null +++ b/Task/Dragon-curve/PureBasic/dragon-curve.purebasic @@ -0,0 +1,39 @@ +#SqRt2 = 1.4142136 +#SizeH = 800: #SizeV = 550 +Global angle.d, px, py, imageNum + +Procedure turn(degrees.d) + angle + degrees * #PI / 180 +EndProcedure + +Procedure forward(length.d) + Protected w = Cos(angle) * length + Protected h = Sin(angle) * length + LineXY(px, py, px + w, py + h, RGB(255,255,255)) + px + w: py + h +EndProcedure + +Procedure dragon(length.d, split, d.d) + If split = 0 + forward(length) + Else + turn(d * 45) + dragon(length / #SqRt2, split - 1, 1) + turn(-d * 90) + dragon(length / #SqRt2, split - 1, -1) + turn(d * 45) + EndIf +EndProcedure + +OpenWindow(0, 0, 0, #SizeH, #SizeV, "DragonCurve", #PB_Window_SystemMenu) +imageNum = CreateImage(#PB_Any, #SizeH, #SizeV, 32) +ImageGadget(0, 0, 0, 0, 0, ImageID(imageNum)) + +angle = 0: px = 185: py = 190 +If StartDrawing(ImageOutput(imageNum)) + dragon(400, 15, 1) + StopDrawing() + SetGadgetState(0, ImageID(imageNum)) +EndIf + +Repeat: Until WaitWindowEvent(10) = #PB_Event_CloseWindow diff --git a/Task/Dragon-curve/Python/dragon-curve-1.py b/Task/Dragon-curve/Python/dragon-curve-1.py new file mode 100644 index 0000000000..48d335a222 --- /dev/null +++ b/Task/Dragon-curve/Python/dragon-curve-1.py @@ -0,0 +1,37 @@ +from turtle import * + +def dragon(step, length): + dcr(step, length) + +def dcr(step, length): + step -= 1 + length /= 1.41421 + if step > 0: + right(45) + dcr(step, length) + left(90) + dcl(step, length) + right(45) + else: + right(45) + forward(length) + left(90) + forward(length) + right(45) + +def dcl(step, length): + step -= 1 + length /= 1.41421 + + if step > 0: + left(45) + dcr(step, length) + right(90) + dcl(step, length) + left(45) + else: + left(45) + forward(length) + right(90) + forward(length) + left(45) diff --git a/Task/Dragon-curve/Python/dragon-curve-2.py b/Task/Dragon-curve/Python/dragon-curve-2.py new file mode 100644 index 0000000000..8ac3773a9b --- /dev/null +++ b/Task/Dragon-curve/Python/dragon-curve-2.py @@ -0,0 +1,18 @@ +from turtle import right, left, forward, speed, exitonclick, hideturtle + +def dragon(level=4, size=200, zig=right, zag=left): + if level <= 0: + forward(size) + return + + size /= 1.41421 + zig(45) + dragon(level-1, size, right, left) + zag(90) + dragon(level-1, size, left, right) + zig(45) + +speed(0) +hideturtle() +dragon(6) +exitonclick() # click to exit diff --git a/Task/Dragon-curve/Python/dragon-curve-3.py b/Task/Dragon-curve/Python/dragon-curve-3.py new file mode 100644 index 0000000000..c2dda2095b --- /dev/null +++ b/Task/Dragon-curve/Python/dragon-curve-3.py @@ -0,0 +1,16 @@ +from turtle import right, left, forward, speed, exitonclick, hideturtle + +def dragon(level=4, size=200, direction=45): + if level: + right(direction) + dragon(level-1, size/1.41421356237, 45) + left(direction * 2) + dragon(level-1, size/1.41421356237, -45) + right(direction) + else: + forward(size) + +speed(0) +hideturtle() +dragon(6) +exitonclick() # click to exit diff --git a/Task/Dragon-curve/REXX/dragon-curve.rexx b/Task/Dragon-curve/REXX/dragon-curve.rexx new file mode 100644 index 0000000000..123817063b --- /dev/null +++ b/Task/Dragon-curve/REXX/dragon-curve.rexx @@ -0,0 +1,36 @@ +/*REXX program to draw an ASCII Dragon Curve (or Harter-Heighway dragon)*/ +d.=1; d.L=-1; @.=' '; x=0; x2=x; y=0; y2=y; @.x.y='∙'; z=1 +plot_pts='123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZΘ' +minx=0; maxx=0; miny=0; maxy=0 /*assign various constants & vars*/ +parse arg # p c . /*# is # iterations, P=init dir.*/ +if #=='' | #==',' then #=11 /*Not specified? Use the default*/ +if p=='' | p==',' then p=0 /*Not specified? Use the default*/ +if c=='' then c=plot_pts /*Not specified? Use the default*/ +if length(c)==2 then c=x2c(c) /*hexadecimal code was specified?*/ +if length(c)==3 then c=d2c(c) /* decimal " " " ?*/ +$= /*nullify the dragon curve string*/ + do # /*create the dragon curve string.*/ + $=$'R'reverse(translate($,'RL','LR')) /*append,flip,reverse.*/ + end /*#*/ + /*create dragon curve.*/ + do j=1 for length($); _=substr($,j,1) /*get next direction.*/ + p=(p+d._)//4; if p<0 then p=p+4 /*move in a direction.*/ + if p==0 then do; y=y+1; y2=y+1; end /*going east map-wise.*/ + if p==1 then do; x=x+1; x2=x+1; end /* " south " */ + if p==2 then do; y=y-1; y2=y-1; end /* " west " */ + if p==3 then do; x=x-1; x2=x-1; end /* " north " */ + if j>2**z then z=z+1 /*the curve being done*/ + !=substr(c,z,1); if !==' ' then !=right(c,1) /*choose plot pt char.*/ + @.x.y=!; @.x2.y2=! /*draw part of dragon.*/ + minx=min(minx,x,x2); maxx=max(maxx,x,x2); x=x2 /*define graph limits.*/ + miny=min(miny,y,y2); maxy=max(maxy,y,y2); y=y2 /* " " " */ + end /*j*/ + /*display dragon curve on screen.*/ + do r=minx to maxx; a= /*nullify the line to be drawn. */ + do c=miny to maxy /*create a line (row) of points. */ + a=a || @.r.c /*build one column at a time. */ + end /*c*/ + a=strip(a,'T') /*be nice & strip trailing blanks*/ + if a\=='' then say a /*display a line (row) of points.*/ + end /*r*/ + /*stick a fork in it, we're done.*/ diff --git a/Task/Dragon-curve/Racket/dragon-curve.rkt b/Task/Dragon-curve/Racket/dragon-curve.rkt new file mode 100644 index 0000000000..b8ae63cb63 --- /dev/null +++ b/Task/Dragon-curve/Racket/dragon-curve.rkt @@ -0,0 +1,38 @@ +#lang racket + +(require plot) + +(define (dragon-turn n) + (if (> (bitwise-and (arithmetic-shift (bitwise-and n (- n)) 1) n) 0) + 'L + 'R)) + +(define (rotate heading dir) + (cond + [(eq? dir 'R) (cond [(eq? heading 'N) 'E] + [(eq? heading 'E) 'S] + [(eq? heading 'S) 'W] + [(eq? heading 'W) 'N])] + [(eq? dir 'L) (cond [(eq? heading 'N) 'W] + [(eq? heading 'E) 'N] + [(eq? heading 'S) 'E] + [(eq? heading 'W) 'S])])) +(define (step pos heading) + (cond + [(eq? heading 'N) (list (car pos) (add1 (cadr pos)))] + [(eq? heading 'E) (list (add1 (car pos)) (cadr pos))] + [(eq? heading 'S) (list (car pos) (sub1 (cadr pos)))] + [(eq? heading 'W) (list (sub1 (car pos)) (cadr pos))] + )) + +(let-values ([(dir pos trail) + (for/fold ([dir 'N] + [pos (list 0 0)] + [trail '((0 0))]) + ([n (in-range 0 50000)]) + (let* ([new-dir (rotate dir (dragon-turn n))] + [new-pos (step pos new-dir)]) + (values new-dir + new-pos + (cons new-pos trail))))]) + (plot-file (lines trail) "dragon.png" 'png)) diff --git a/Task/Dragon-curve/RapidQ/dragon-curve.rapidq b/Task/Dragon-curve/RapidQ/dragon-curve.rapidq new file mode 100644 index 0000000000..9951789db8 --- /dev/null +++ b/Task/Dragon-curve/RapidQ/dragon-curve.rapidq @@ -0,0 +1,44 @@ +DIM angle AS Double +DIM x AS Double, y AS Double +DECLARE SUB PaintCanvas + +CREATE form AS QForm + Width = 800 + Height = 600 + CREATE canvas AS QCanvas + Height = form.ClientHeight + Width = form.ClientWidth + OnPaint = PaintCanvas + END CREATE +END CREATE + +SUB turn (degrees AS Double) + angle = angle + degrees*3.14159265/180 +END SUB + +SUB forward (length AS Double) + x2 = x + cos(angle)*length + y2 = y + sin(angle)*length + canvas.Line(x, y, x2, y2, &Haaffff) + x = x2: y = y2 +END SUB + +SUB dragon (length AS Double, split AS Integer, d AS Double) + IF split=0 THEN + forward length + ELSE + turn d*45 + dragon length/1.4142136, split-1, 1 + turn -d*90 + dragon length/1.4142136, split-1, -1 + turn d*45 + END IF +END SUB + +SUB PaintCanvas + canvas.FillRect(0, 0, canvas.Width, canvas.Height, &H102800) + x = 220: y = 220: angle = 0 + dragon 384, 12, 1 +END SUB + +form.ShowModal diff --git a/Task/Dragon-curve/Ruby/dragon-curve.rb b/Task/Dragon-curve/Ruby/dragon-curve.rb new file mode 100644 index 0000000000..019de4e609 --- /dev/null +++ b/Task/Dragon-curve/Ruby/dragon-curve.rb @@ -0,0 +1,32 @@ +Point = Struct.new(:x, :y) +Line = Struct.new(:start, :stop) + +Shoes.app(:width => 800, :height => 600, :resizable => false) do + + def split_segments(n) + dir = 1 + @segments = @segments.inject([]) do |new, l| + a, b, c, d = l.start.x, l.start.y, l.stop.x, l.stop.y + + mid_x = a + (c-a)/2.0 - (d-b)/2.0*dir + mid_y = b + (d-b)/2.0 + (c-a)/2.0*dir + mid_p = Point.new(mid_x, mid_y) + + dir *= -1 + new << Line.new(l.start, mid_p) + new << Line.new(mid_p, l.stop) + end + end + + @segments = [Line.new(Point.new(200,200), Point.new(600,200))] + 15.times do |n| + info "calculating frame #{n}" + split_segments(n) + end + + stack do + @segments.each do |l| + line l.start.x, l.start.y, l.stop.x, l.stop.y + end + end +end diff --git a/Task/Dragon-curve/Run-BASIC/dragon-curve.run b/Task/Dragon-curve/Run-BASIC/dragon-curve.run new file mode 100644 index 0000000000..6dd8d8d417 --- /dev/null +++ b/Task/Dragon-curve/Run-BASIC/dragon-curve.run @@ -0,0 +1,30 @@ +graphic #g, 600,600 +RL$ = "R" +loc = 90 +pass = 0 + +[loop] +#g "cls ; home ; north ; down ; fill black" +for i =1 to len(RL$) + v = 255 * i /len(RL$) + #g "color "; v; " 120 "; 255 -v + #g "go "; loc + if mid$(RL$,i,1) ="R" then #g "turn 90" else #g "turn -90" +next i + +#g "color 255 120 0" +#g "go "; loc +LR$ ="" +for i =len( RL$) to 1 step -1 + if mid$( RL$, i, 1) ="R" then LR$ =LR$ +"L" else LR$ =LR$ +"R" +next i + +RL$ = RL$ + "R" + LR$ +loc = loc / 1.35 +pass = pass + 1 +render #g +input xxx +cls + +if pass < 16 then goto [loop] +end diff --git a/Task/Dragon-curve/Seed7/dragon-curve.seed7 b/Task/Dragon-curve/Seed7/dragon-curve.seed7 new file mode 100644 index 0000000000..d91d66ad8d --- /dev/null +++ b/Task/Dragon-curve/Seed7/dragon-curve.seed7 @@ -0,0 +1,48 @@ +$ include "seed7_05.s7i"; + include "float.s7i"; + include "math.s7i"; + include "draw.s7i"; + include "keybd.s7i"; + +var float: angle is 0.0; +var integer: x is 220; +var integer: y is 220; + +const proc: turn (in integer: degrees) is func + begin + angle +:= flt(degrees) * PI / 180.0 + end func; + +const proc: forward (in float: length) is func + local + var integer: x2 is 0; + var integer: y2 is 0; + begin + x2 := x + trunc(cos(angle) * length); + y2 := y + trunc(sin(angle) * length); + lineTo(x, y, x2, y2, black); + x := x2; + y := y2; + end func; + +const proc: dragon (in float: length, in integer: split, in integer: direct) is func + begin + if split = 0 then + forward(length); + else + turn(direct * 45); + dragon(length/1.4142136, pred(split), 1); + turn(-direct * 90); + dragon(length/1.4142136, pred(split), -1); + turn(direct * 45); + end if; + end func; + +const proc: main is func + begin + screen(976, 654); + clear(curr_win, white); + KEYBOARD := GRAPH_KEYBOARD; + dragon(768.0, 14, 1); + ignore(getc(KEYBOARD)); + end func; diff --git a/Task/Dragon-curve/TI-89-BASIC/dragon-curve.ti-89 b/Task/Dragon-curve/TI-89-BASIC/dragon-curve.ti-89 new file mode 100644 index 0000000000..8b840e68eb --- /dev/null +++ b/Task/Dragon-curve/TI-89-BASIC/dragon-curve.ti-89 @@ -0,0 +1,17 @@ +Define dragon = (iter, xform) +Prgm + Local a,b + If iter > 0 Then + dragon(iter-1, xform*[[.5,.5,0][–.5,.5,0][0,0,1]]) + dragon(iter-1, xform*[[–.5,.5,0][–.5,–.5,1][0,0,1]]) + Else + xform*[0;0;1]→a + xform*[0;1;1]→b + PxlLine floor(a[1,1]), floor(a[2,1]), floor(b[1,1]), floor(b[2,1]) + EndIf +EndPrgm + +FnOff +PlotsOff +ClrDraw +dragon(7, [[75,0,26] [0,75,47] [0,0,1]]) diff --git a/Task/Dragon-curve/Tcl/dragon-curve.tcl b/Task/Dragon-curve/Tcl/dragon-curve.tcl new file mode 100644 index 0000000000..1dcd79c6ad --- /dev/null +++ b/Task/Dragon-curve/Tcl/dragon-curve.tcl @@ -0,0 +1,42 @@ +package require Tk + +set pi [expr acos(-1)] +set r2 [expr sqrt(2)] + +proc turn {degrees} { + global a pi + set a [expr {$a + $degrees*$pi/180}] +} +proc forward {len} { + global a coords + lassign [lrange $coords end-1 end] x y + lappend coords [expr {$x + cos($a)*$len}] [expr {$y + sin($a)*$len}] +} +proc dragon {len split {d 1}} { + global r2 coords + if {$split == 0} { + forward $len + return + } + + # This next part is only necessary to allow the illustration of progress + if {$split == 10 && [llength $::coords]>2} { + .c coords dragon $::coords + update + } + + incr split -1 + set sublen [expr {$len/$r2}] + turn [expr {$d*45}] + dragon $sublen $split 1 + turn [expr {$d*-90}] + dragon $sublen $split -1 + turn [expr {$d*45}] +} + +set coords {150 180} +set a 0.0 +pack [canvas .c -width 700 -height 500] +.c create line {0 0 0 0} -tag dragon +dragon 400 17 +.c coords dragon $coords diff --git a/Task/Dragon-curve/Vedit-macro-language/dragon-curve.vedit b/Task/Dragon-curve/Vedit-macro-language/dragon-curve.vedit new file mode 100644 index 0000000000..45025fd0ee --- /dev/null +++ b/Task/Dragon-curve/Vedit-macro-language/dragon-curve.vedit @@ -0,0 +1,100 @@ +File_Open("|(USER_MACRO)\dragon.bmp", OVERWRITE+NOEVENT) +BOF Del_Char(ALL) + +#11 = 640 // width of the image +#12 = 480 // height of the image +Call("CREATE_BMP") + +#1 = 384 // dx +#2 = 0 // dy +#3 = 6 // depth of recursion +#4 = 1 // flip +#5 = 150 // x +#6 = 300 // y +Call("DRAGON") +Buf_Close(NOMSG) + +Sys(`start "" "|(USER_MACRO)\dragon.bmp"`, DOS+SUPPRESS+SIMPLE+NOWAIT) +return + +///////////////////////////////////////////////////////////////////// +// +// Dragon fractal, recursive +// +:DRAGON: +if (#3 == 0) { + Call("DRAW_LINE") +} else { + #1 /= 2 + #2 /= 2 + #3-- + if (#4) { + Num_Push(1,4) #4=1; #7=#1; #1=#2; #2=-#7; Call("DRAGON") Num_Pop(1,4) + Num_Push(1,4) #4=0; Call("DRAGON") Num_Pop(1,4) + Num_Push(1,4) #4=1; #7=#1; #1=-#2; #2=#7; Call("DRAGON") Num_Pop(1,4) + Num_Push(1,4) #4=0; Call("DRAGON") Num_Pop(1,4) + } else { + Num_Push(1,4) #4=1; Call("DRAGON") Num_Pop(1,4) + Num_Push(1,4) #4=0; #7=#1; #1=-#2; #2=#7; Call("DRAGON") Num_Pop(1,4) + Num_Push(1,4) #4=1; Call("DRAGON") Num_Pop(1,4) + Num_Push(1,4) #4=0; #7=#1; #1=#2; #2=-#7; Call("DRAGON") Num_Pop(1,4) + } +} +return + +///////////////////////////////////////////////////////////////////// +// +// Daw a horizontal, vertical or diagonal line. #1 = dx, #2 = dy +// +:DRAW_LINE: +while (#1 || #2 ) { + #21 = (#1>0) - (#1<0) + #22 = (#2>0) - (#2<0) + #5 += #21; #1 -= #21 + #6 += #22; #2 -= #22 + Goto_Pos(1078 + #5 + #6*#11) + IC(255, OVERWRITE) // plot a pixel +} +return + +///////////////////////////////////////////////////////////////////// +// +// Create a bitmap file +// +:CREATE_BMP: + +// BITMAPFILEHEADER: +IT("BM") // bfType +#10 = 1078+#11*#12 // file size +Call("INS_4BYTES") +IC(0, COUNT, 4) // reserved +#10 = 1078; Call("INS_4BYTES") // offset to bitmap data + +// BITMAPINFOHEADER: +#10 = 40; Call("INS_4BYTES") // size of BITMAPINFOHEADER +#10 = #11; Call("INS_4BYTES") // width of image +#10 = #12; Call("INS_4BYTES") // height of image +IC(1) IC(0) // number of bitplanes = 1 +IC(8) IC(0) // bits/pixel = 8 +IC(0, COUNT, 24) // compression, number of colors etc. + +// Color table - create greyscale palette +for (#1 = 0; #1 < 256; #1++) { + IC(#1) IC(#1) IC(#1) IC(0) +} + +// Pixel data - init to black +for (#1 = 0; #1 < #12; #1++) { + IC(0, COUNT, #11) +} +return + +// +// Write 32 bit binary value from #10 in the file +// +:INS_4BYTES: +for (#1 = 0; #1 < 4; #1++) { + Ins_Char(#10 & 0xff) + #10 = #10 >> 8 +} +return diff --git a/Task/Dragon-curve/X86-Assembly/dragon-curve.x86 b/Task/Dragon-curve/X86-Assembly/dragon-curve.x86 new file mode 100644 index 0000000000..07eef7e108 --- /dev/null +++ b/Task/Dragon-curve/X86-Assembly/dragon-curve.x86 @@ -0,0 +1,62 @@ + .model tiny + .code + .486 + org 100h ;assume ax=0, bx=0, sp=-2 +start: mov al, 13h ;(ah=0) set 320x200 video graphics mode + int 10h + push 0A000h + pop es + mov si, 8000h ;color + + mov cx, 75*256+100 ;coordinates of initial horizontal line segment + mov dx, 75*256+164 ;use power of 2 for length + + call dragon + mov ah, 0 ;wait for keystroke + int 16h + mov ax, 0003h ;restore normal text mode + int 10h + ret + +dragon: cmp sp, -100 ;at maximum recursion depth? + jne drag30 ;skip if not + mov bl, dh ;draw at max depth to get solid image + imul di, bx, 320 ;(bh=0) plot point at X=dl, Y=dh + mov bl, dl + add di, bx + mov ax, si ;color + shr ax, 13 + or al, 8 ;use bright colors 8..F + stosb ;es:[di++]:= al + inc si + ret +drag30: + push cx ;preserve points P and Q + push dx + + xchg ax, dx ;DX:= Q(0)-P(0); + sub al, cl + sub ah, ch ;DY:= Q(1)-P(1); + + mov dx, ax ;new point + sub dl, ah ;R(0):= P(0) + (DX-DY)/2 + jns drag40 + inc dl +drag40: sar dl, 1 ;dl:= (al-ah)/2 + cl + add dl, cl + + add dh, al ;R(1):= P(1) + (DX+DY)/2; + jns drag45 + inc dh +drag45: sar dh, 1 ;dh:= (al+ah)/2 + ch + add dh, ch + + call dragon ;Dragon(P, R); + pop cx ;get Q + push cx + call dragon ;Dragon(Q, R); + + pop dx ;restore points + pop cx + ret + end start diff --git a/Task/Dragon-curve/XPL0/dragon-curve.xpl0 b/Task/Dragon-curve/XPL0/dragon-curve.xpl0 new file mode 100644 index 0000000000..f2fba820d9 --- /dev/null +++ b/Task/Dragon-curve/XPL0/dragon-curve.xpl0 @@ -0,0 +1,26 @@ +include c:\cxpl\codes; \intrinsic 'code' declarations + +proc Dragon(D, P, Q); \Draw a colorful dragon curve +int D, P, Q; \recursive depth, coordinates of line segment +int R(2), \coordinates of generated new point + DX, DY, C; \deltas, color +[C:= [0]; \color is a local, static-like variable +D:= D+1; \depth of recursion increases +if D >= 13 then \draw lines at maximum depth to get solid image + [Move(P(0), P(1)); Line(Q(0), Q(1), C(0)>>9+4!8); C(0):= C(0)+1; return]; +DX:= Q(0)-P(0); DY:= Q(1)-P(1); +R(0):= P(0) + (DX-DY)/2; \new point +R(1):= P(1) + (DX+DY)/2; +Dragon(D, P, R); \draw two segments that include the new point +Dragon(D, Q, R); +]; + +int X, Y, P(2), Q(2); +[SetVid($101); \set 640x480 video graphics mode +X:= 32; Y:= 32; \coordinates of initial horizontal line segment +P(0):= X; P(1):= Y; +Q(0):= X+64; Q(1):= Y; \(power of two length works best for integers) +Dragon(0, P, Q); \draw its dragon curve +X:= ChIn(1); \wait for keystroke +SetVid(3); \restore normal text mode +] diff --git a/Task/Environment-variables/0DESCRIPTION b/Task/Environment-variables/0DESCRIPTION new file mode 100644 index 0000000000..105e0e423e --- /dev/null +++ b/Task/Environment-variables/0DESCRIPTION @@ -0,0 +1 @@ +Show how to get one of your process's [[wp:Environment variable|environment variables]]. The available variables vary by system; some of the common ones available on Unix include PATH, HOME, USER. diff --git a/Task/Environment-variables/1META.yaml b/Task/Environment-variables/1META.yaml new file mode 100644 index 0000000000..45cd327e07 --- /dev/null +++ b/Task/Environment-variables/1META.yaml @@ -0,0 +1,5 @@ +--- +category: +- Environment variables +- Initialization +note: Programming environment operations diff --git a/Task/Environment-variables/ALGOL-68/environment-variables.alg b/Task/Environment-variables/ALGOL-68/environment-variables.alg new file mode 100644 index 0000000000..22e60c639b --- /dev/null +++ b/Task/Environment-variables/ALGOL-68/environment-variables.alg @@ -0,0 +1 @@ +print((getenv("HOME"), new line)) diff --git a/Task/Environment-variables/AWK/environment-variables-1.awk b/Task/Environment-variables/AWK/environment-variables-1.awk new file mode 100644 index 0000000000..1ad6c819f2 --- /dev/null +++ b/Task/Environment-variables/AWK/environment-variables-1.awk @@ -0,0 +1,2 @@ +$ awk 'BEGIN{print "HOME:"ENVIRON["HOME"],"USER:"ENVIRON["USER"]}' +HOME:/home/suchrich USER:SuchRich diff --git a/Task/Environment-variables/AWK/environment-variables-2.awk b/Task/Environment-variables/AWK/environment-variables-2.awk new file mode 100644 index 0000000000..99e42e6910 --- /dev/null +++ b/Task/Environment-variables/AWK/environment-variables-2.awk @@ -0,0 +1,2 @@ +$ awk -v h=$HOME -v u=$USER 'BEGIN{print "HOME:"h,"USER:"u}' +HOME:/home/suchrich USER:SuchRich diff --git a/Task/Environment-variables/Ada/environment-variables-1.ada b/Task/Environment-variables/Ada/environment-variables-1.ada new file mode 100644 index 0000000000..8af8d02837 --- /dev/null +++ b/Task/Environment-variables/Ada/environment-variables-1.ada @@ -0,0 +1,7 @@ +with Ada.Environment_Variables; use Ada.Environment_Variables; +with Ada.Text_Io; use Ada.Text_Io; + +procedure Print_Path is +begin + Put_Line("Path : " & Value("PATH")); +end Print_Path; diff --git a/Task/Environment-variables/Ada/environment-variables-2.ada b/Task/Environment-variables/Ada/environment-variables-2.ada new file mode 100644 index 0000000000..912826f766 --- /dev/null +++ b/Task/Environment-variables/Ada/environment-variables-2.ada @@ -0,0 +1,11 @@ +with Ada.Environment_Variables; use Ada.Environment_Variables; +with Ada.Text_Io; use Ada.Text_Io; + +procedure Env_Vars is + procedure Print_Vars(Name, Value : in String) is + begin + Put_Line(Name & " : " & Value); + end Print_Vars; +begin + Iterate(Print_Vars'access); +end Env_Vars; diff --git a/Task/Environment-variables/Ada/environment-variables-3.ada b/Task/Environment-variables/Ada/environment-variables-3.ada new file mode 100644 index 0000000000..2ce2b988da --- /dev/null +++ b/Task/Environment-variables/Ada/environment-variables-3.ada @@ -0,0 +1,15 @@ +with Ada.Wide_Wide_Text_IO; + +with League.Application; +with League.Strings; + +procedure Main is + + function "+" + (Item : Wide_Wide_String) return League.Strings.Universal_String + renames League.Strings.To_Universal_String; + +begin + Ada.Wide_Wide_Text_IO.Put_Line + (League.Application.Environment.Value (+"HOME").To_Wide_Wide_String); +end Main; diff --git a/Task/Environment-variables/AutoHotkey/environment-variables.ahk b/Task/Environment-variables/AutoHotkey/environment-variables.ahk new file mode 100644 index 0000000000..7a4efc22b8 --- /dev/null +++ b/Task/Environment-variables/AutoHotkey/environment-variables.ahk @@ -0,0 +1,2 @@ +EnvGet, OutputVar, Path +MsgBox, %OutputVar% diff --git a/Task/Environment-variables/BASIC/environment-variables-1.basic b/Task/Environment-variables/BASIC/environment-variables-1.basic new file mode 100644 index 0000000000..7f5c01d29e --- /dev/null +++ b/Task/Environment-variables/BASIC/environment-variables-1.basic @@ -0,0 +1,2 @@ +x$ = ENVIRON$("path") +PRINT x$ diff --git a/Task/Environment-variables/BASIC/environment-variables-2.basic b/Task/Environment-variables/BASIC/environment-variables-2.basic new file mode 100644 index 0000000000..10cbaccf17 --- /dev/null +++ b/Task/Environment-variables/BASIC/environment-variables-2.basic @@ -0,0 +1,3 @@ +10 PRINT "The border colour is "; PEEK (23624): REM bordcr +20 PRINT "The ramtop address is "; PEEK (23730) + 256 * PEEK (23731): REM ramtop +30 POKE 23609,50: REM set keyboard pip to 50 diff --git a/Task/Environment-variables/BBC-BASIC/environment-variables.bbc b/Task/Environment-variables/BBC-BASIC/environment-variables.bbc new file mode 100644 index 0000000000..93f5c9a3cc --- /dev/null +++ b/Task/Environment-variables/BBC-BASIC/environment-variables.bbc @@ -0,0 +1,10 @@ + PRINT FNenvironment("PATH") + PRINT FNenvironment("USERNAME") + END + + DEF FNenvironment(envar$) + LOCAL buffer%, size% + SYS "GetEnvironmentVariable", envar$, 0, 0 TO size% + DIM buffer% LOCAL size% + SYS "GetEnvironmentVariable", envar$, buffer%, size%+1 + = $$buffer% diff --git a/Task/Environment-variables/Batch-File/environment-variables-1.bat b/Task/Environment-variables/Batch-File/environment-variables-1.bat new file mode 100644 index 0000000000..653f9661b9 --- /dev/null +++ b/Task/Environment-variables/Batch-File/environment-variables-1.bat @@ -0,0 +1 @@ +echo %Foo% diff --git a/Task/Environment-variables/Batch-File/environment-variables-2.bat b/Task/Environment-variables/Batch-File/environment-variables-2.bat new file mode 100644 index 0000000000..8119cf71ae --- /dev/null +++ b/Task/Environment-variables/Batch-File/environment-variables-2.bat @@ -0,0 +1,2 @@ +set +set Foo diff --git a/Task/Environment-variables/C++/environment-variables.cpp b/Task/Environment-variables/C++/environment-variables.cpp new file mode 100644 index 0000000000..1acd071aca --- /dev/null +++ b/Task/Environment-variables/C++/environment-variables.cpp @@ -0,0 +1,8 @@ +#include +#include + +int main() +{ + puts(getenv("HOME")); + return 0; +} diff --git a/Task/Environment-variables/C/environment-variables.c b/Task/Environment-variables/C/environment-variables.c new file mode 100644 index 0000000000..fb0aefc0ca --- /dev/null +++ b/Task/Environment-variables/C/environment-variables.c @@ -0,0 +1,7 @@ +#include +#include + +int main() { + puts(getenv("HOME")); + return 0; +} diff --git a/Task/Environment-variables/Clojure/environment-variables.clj b/Task/Environment-variables/Clojure/environment-variables.clj new file mode 100644 index 0000000000..e09036892b --- /dev/null +++ b/Task/Environment-variables/Clojure/environment-variables.clj @@ -0,0 +1 @@ +(System/getenv "HOME") diff --git a/Task/Environment-variables/CoffeeScript/environment-variables.coffeescript b/Task/Environment-variables/CoffeeScript/environment-variables.coffeescript new file mode 100644 index 0000000000..ce077ffed2 --- /dev/null +++ b/Task/Environment-variables/CoffeeScript/environment-variables.coffeescript @@ -0,0 +1,2 @@ +for var_name in ['PATH', 'HOME', 'LANG', 'USER'] + console.log var_name, process.env[var_name] diff --git a/Task/Environment-variables/Common-Lisp/environment-variables-1.lisp b/Task/Environment-variables/Common-Lisp/environment-variables-1.lisp new file mode 100644 index 0000000000..05a5628404 --- /dev/null +++ b/Task/Environment-variables/Common-Lisp/environment-variables-1.lisp @@ -0,0 +1 @@ +(lispworks:environment-variable "USER") diff --git a/Task/Environment-variables/Common-Lisp/environment-variables-2.lisp b/Task/Environment-variables/Common-Lisp/environment-variables-2.lisp new file mode 100644 index 0000000000..49614876e5 --- /dev/null +++ b/Task/Environment-variables/Common-Lisp/environment-variables-2.lisp @@ -0,0 +1 @@ +(sb-ext:posix-getenv "USER") diff --git a/Task/Environment-variables/Common-Lisp/environment-variables-3.lisp b/Task/Environment-variables/Common-Lisp/environment-variables-3.lisp new file mode 100644 index 0000000000..a66a5104d3 --- /dev/null +++ b/Task/Environment-variables/Common-Lisp/environment-variables-3.lisp @@ -0,0 +1 @@ +(ccl:getenv "USER") diff --git a/Task/Environment-variables/Common-Lisp/environment-variables-4.lisp b/Task/Environment-variables/Common-Lisp/environment-variables-4.lisp new file mode 100644 index 0000000000..75bf2dc51e --- /dev/null +++ b/Task/Environment-variables/Common-Lisp/environment-variables-4.lisp @@ -0,0 +1 @@ +(getenv "HOME") diff --git a/Task/Environment-variables/D/environment-variables-1.d b/Task/Environment-variables/D/environment-variables-1.d new file mode 100644 index 0000000000..1dec2fded4 --- /dev/null +++ b/Task/Environment-variables/D/environment-variables-1.d @@ -0,0 +1,5 @@ +import std.stdio, std.process; + +void main() { + auto home = getenv("HOME"); +} diff --git a/Task/Environment-variables/D/environment-variables-2.d b/Task/Environment-variables/D/environment-variables-2.d new file mode 100644 index 0000000000..19bee644ed --- /dev/null +++ b/Task/Environment-variables/D/environment-variables-2.d @@ -0,0 +1,5 @@ +import tango.sys.Environment; + +void main() { + auto home = Environment("HOME"); +} diff --git a/Task/Environment-variables/Delphi/environment-variables.delphi b/Task/Environment-variables/Delphi/environment-variables.delphi new file mode 100644 index 0000000000..f109796f55 --- /dev/null +++ b/Task/Environment-variables/Delphi/environment-variables.delphi @@ -0,0 +1,9 @@ +program EnvironmentVariable; + +{$APPTYPE CONSOLE} + +uses SysUtils; + +begin + WriteLn('Temp = ' + GetEnvironmentVariable('TEMP')); +end. diff --git a/Task/Environment-variables/E/environment-variables.e b/Task/Environment-variables/E/environment-variables.e new file mode 100644 index 0000000000..796de7b39c --- /dev/null +++ b/Task/Environment-variables/E/environment-variables.e @@ -0,0 +1 @@ +.getenv("HOME") diff --git a/Task/Environment-variables/Eiffel/environment-variables.e b/Task/Environment-variables/Eiffel/environment-variables.e new file mode 100644 index 0000000000..87da52e0c5 --- /dev/null +++ b/Task/Environment-variables/Eiffel/environment-variables.e @@ -0,0 +1,13 @@ +class + APPLICATION +inherit + EXECUTION_ENVIRONMENT +create + make +feature {NONE} -- Initialization + make + -- Retrieve and print value for environment variable `USERNAME'. + do + print (get ("USERNAME")) + end +end diff --git a/Task/Environment-variables/Emacs-Lisp/environment-variables.l b/Task/Environment-variables/Emacs-Lisp/environment-variables.l new file mode 100644 index 0000000000..75bf2dc51e --- /dev/null +++ b/Task/Environment-variables/Emacs-Lisp/environment-variables.l @@ -0,0 +1 @@ +(getenv "HOME") diff --git a/Task/Environment-variables/Euphoria/environment-variables.euphoria b/Task/Environment-variables/Euphoria/environment-variables.euphoria new file mode 100644 index 0000000000..03550feef3 --- /dev/null +++ b/Task/Environment-variables/Euphoria/environment-variables.euphoria @@ -0,0 +1 @@ +puts(1,getenv("PATH")) diff --git a/Task/Environment-variables/Factor/environment-variables.factor b/Task/Environment-variables/Factor/environment-variables.factor new file mode 100644 index 0000000000..035150b57e --- /dev/null +++ b/Task/Environment-variables/Factor/environment-variables.factor @@ -0,0 +1 @@ +"HOME" os-env print diff --git a/Task/Environment-variables/Forth/environment-variables.fth b/Task/Environment-variables/Forth/environment-variables.fth new file mode 100644 index 0000000000..c0c449c8f2 --- /dev/null +++ b/Task/Environment-variables/Forth/environment-variables.fth @@ -0,0 +1 @@ +s" HOME" getenv type diff --git a/Task/Environment-variables/Fortran/environment-variables.f b/Task/Environment-variables/Fortran/environment-variables.f new file mode 100644 index 0000000000..ad4674ff50 --- /dev/null +++ b/Task/Environment-variables/Fortran/environment-variables.f @@ -0,0 +1,15 @@ +program show_home +implicit none +character(len=32) :: home_val ! The string value of the variable HOME +integer :: home_len ! The actual length of the value +integer :: stat ! The status of the value: + ! 0 = ok + ! 1 = variable does not exist + ! -1 = variable is not long enought to hold the result +call get_environment_variable('HOME', home_val, home_len, stat) +if (stat == 0) then + write(*,'(a)') 'HOME = '//trim(home_val) +else + write(*,'(a)') 'No HOME to go to!' +end if +end program show_home diff --git a/Task/Environment-variables/Go/environment-variables-1.go b/Task/Environment-variables/Go/environment-variables-1.go new file mode 100644 index 0000000000..c2fdf15394 --- /dev/null +++ b/Task/Environment-variables/Go/environment-variables-1.go @@ -0,0 +1,10 @@ +package main + +import ( + "fmt" + "os" +) + +func main() { + fmt.Println(os.Getenv("SHELL")) +} diff --git a/Task/Environment-variables/Go/environment-variables-2.go b/Task/Environment-variables/Go/environment-variables-2.go new file mode 100644 index 0000000000..535c301938 --- /dev/null +++ b/Task/Environment-variables/Go/environment-variables-2.go @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "os" + "strings" +) + +func main() { + s := "SHELL" + se := s + "=" + for _, v := range os.Environ() { + if strings.HasPrefix(v, se) { + fmt.Println(s, "has value", v[len(se):]) + return + } + } + fmt.Println(s, "not found") +} diff --git a/Task/Environment-variables/Groovy/environment-variables.groovy b/Task/Environment-variables/Groovy/environment-variables.groovy new file mode 100644 index 0000000000..fdc651ea12 --- /dev/null +++ b/Task/Environment-variables/Groovy/environment-variables.groovy @@ -0,0 +1 @@ +System.getenv().each { property, value -> println "$property = $value"} diff --git a/Task/Environment-variables/Haskell/environment-variables.hs b/Task/Environment-variables/Haskell/environment-variables.hs new file mode 100644 index 0000000000..0691f5fe31 --- /dev/null +++ b/Task/Environment-variables/Haskell/environment-variables.hs @@ -0,0 +1,3 @@ +import System.Environment +main = do getEnv "HOME" >>= print -- get env var + getEnvironment >>= print -- get the entire environment as a list of (key, value) pairs diff --git a/Task/Environment-variables/HicEst/environment-variables.hicest b/Task/Environment-variables/HicEst/environment-variables.hicest new file mode 100644 index 0000000000..57d518593e --- /dev/null +++ b/Task/Environment-variables/HicEst/environment-variables.hicest @@ -0,0 +1,4 @@ +CHARACTER string*255 + +string = "PATH=" +SYSTEM(GEteNV = string) diff --git a/Task/Environment-variables/Icon/environment-variables.icon b/Task/Environment-variables/Icon/environment-variables.icon new file mode 100644 index 0000000000..799ad5fb8f --- /dev/null +++ b/Task/Environment-variables/Icon/environment-variables.icon @@ -0,0 +1,7 @@ +procedure main(arglist) + +if *envars = 0 then envars := ["HOME", "TRACE", "BLKSIZE","STRSIZE","COEXPSIZE","MSTKSIZE", "IPATH","LPATH","NOERRBUF"] + +every v := !sort(envars) do + write(v," = ",image(getenv(v))|"* not set *") +end diff --git a/Task/Environment-variables/J/environment-variables.j b/Task/Environment-variables/J/environment-variables.j new file mode 100644 index 0000000000..d7b29c92e8 --- /dev/null +++ b/Task/Environment-variables/J/environment-variables.j @@ -0,0 +1 @@ +2!:5'HOME' diff --git a/Task/Environment-variables/Java/environment-variables.java b/Task/Environment-variables/Java/environment-variables.java new file mode 100644 index 0000000000..d968f13821 --- /dev/null +++ b/Task/Environment-variables/Java/environment-variables.java @@ -0,0 +1,2 @@ +System.getenv("HOME") // get env var +System.getenv() // get the entire environment as a Map of keys to values diff --git a/Task/Environment-variables/JavaScript/environment-variables.js b/Task/Environment-variables/JavaScript/environment-variables.js new file mode 100644 index 0000000000..072ccc22be --- /dev/null +++ b/Task/Environment-variables/JavaScript/environment-variables.js @@ -0,0 +1,3 @@ +var shell = new ActiveXObject("WScript.Shell"); +var env = shell.Environment("PROCESS"); +WScript.echo('SYSTEMROOT=' + env.item('SYSTEMROOT')); diff --git a/Task/Environment-variables/Joy/environment-variables.joy b/Task/Environment-variables/Joy/environment-variables.joy new file mode 100644 index 0000000000..ede058ca9f --- /dev/null +++ b/Task/Environment-variables/Joy/environment-variables.joy @@ -0,0 +1 @@ +"HOME" getenv. diff --git a/Task/Environment-variables/K/environment-variables.k b/Task/Environment-variables/K/environment-variables.k new file mode 100644 index 0000000000..b114b01fa0 --- /dev/null +++ b/Task/Environment-variables/K/environment-variables.k @@ -0,0 +1 @@ +_getenv "HOME" diff --git a/Task/Environment-variables/LSL/environment-variables.lsl b/Task/Environment-variables/LSL/environment-variables.lsl new file mode 100644 index 0000000000..2e7d594394 --- /dev/null +++ b/Task/Environment-variables/LSL/environment-variables.lsl @@ -0,0 +1,8 @@ +default { + state_entry() { + llOwnerSay("llGetTimestamp()="+(string)llGetTimestamp()); + llOwnerSay("llGetEnergy()="+(string)llGetEnergy()); + llOwnerSay("llGetFreeMemory()="+(string)llGetFreeMemory()); + llOwnerSay("llGetMemoryLimit()="+(string)llGetMemoryLimit()); + } +} diff --git a/Task/Environment-variables/Liberty-BASIC/environment-variables-1.liberty b/Task/Environment-variables/Liberty-BASIC/environment-variables-1.liberty new file mode 100644 index 0000000000..6867b25e33 --- /dev/null +++ b/Task/Environment-variables/Liberty-BASIC/environment-variables-1.liberty @@ -0,0 +1,2 @@ +print StartupDir$ +print DefaultDir$ diff --git a/Task/Environment-variables/Liberty-BASIC/environment-variables-2.liberty b/Task/Environment-variables/Liberty-BASIC/environment-variables-2.liberty new file mode 100644 index 0000000000..d37f61b541 --- /dev/null +++ b/Task/Environment-variables/Liberty-BASIC/environment-variables-2.liberty @@ -0,0 +1,29 @@ +print GetEnvironmentVariable$("USERNAME") + print GetEnvironmentVariable$("USERPROFILE") ' equivalent to UNIX HOME variable + print GetEnvironmentVariable$("PATH") + end + +function GetEnvironmentVariable$(lpName$) + 'get the value of an environment variable + nSize = 1024 + +[Retry] + lpBuffer$ = space$(nSize) + + calldll #kernel32, "GetEnvironmentVariableA", _ + lpName$ as ptr, _ + lpBuffer$ as ptr, _ + nSize as ulong, _ + result as ulong + + select case + ' buffer too small + case result > nSize + nSize = result + goto [Retry] + + ' variable found + case result > 0 + GetEnvironmentVariable$ = left$(lpBuffer$, result) + end select +end function diff --git a/Task/Environment-variables/Lua/environment-variables.lua b/Task/Environment-variables/Lua/environment-variables.lua new file mode 100644 index 0000000000..9f230fbceb --- /dev/null +++ b/Task/Environment-variables/Lua/environment-variables.lua @@ -0,0 +1 @@ +print( os.getenv( "PATH" ) ) diff --git a/Task/Environment-variables/MATLAB/environment-variables.m b/Task/Environment-variables/MATLAB/environment-variables.m new file mode 100644 index 0000000000..cefcf1dfba --- /dev/null +++ b/Task/Environment-variables/MATLAB/environment-variables.m @@ -0,0 +1,3 @@ + getenv('HOME') + getenv('PATH') + getenv('USER') diff --git a/Task/Environment-variables/MUMPS/environment-variables.mumps b/Task/Environment-variables/MUMPS/environment-variables.mumps new file mode 100644 index 0000000000..f004e760ed --- /dev/null +++ b/Task/Environment-variables/MUMPS/environment-variables.mumps @@ -0,0 +1,2 @@ + Set X=$ZF(-1,"show logical") + Set X=$ZF(-1,"show symbol") diff --git a/Task/Environment-variables/Mathematica/environment-variables.math b/Task/Environment-variables/Mathematica/environment-variables.math new file mode 100644 index 0000000000..eebc4223a9 --- /dev/null +++ b/Task/Environment-variables/Mathematica/environment-variables.math @@ -0,0 +1 @@ +Environment["PATH"] diff --git a/Task/Environment-variables/Mercury/environment-variables.mercury b/Task/Environment-variables/Mercury/environment-variables.mercury new file mode 100644 index 0000000000..204db7f2f5 --- /dev/null +++ b/Task/Environment-variables/Mercury/environment-variables.mercury @@ -0,0 +1,18 @@ +:- module env_var. +:- interface. + +:- import_module io. +:- pred main(io::di, io::uo) is det. + +:- implementation. +:- import_module maybe, string. + +main(!IO) :- + io.get_environment_var("HOME", MaybeValue, !IO), + ( + MaybeValue = yes(Value), + io.write_string("HOME is " ++ Value ++ "\n", !IO) + ; + MaybeValue = no, + io.write_string("environment variable HOME not set\n", !IO) + ). diff --git a/Task/Environment-variables/NSIS/environment-variables.nsis b/Task/Environment-variables/NSIS/environment-variables.nsis new file mode 100644 index 0000000000..38f525edfc --- /dev/null +++ b/Task/Environment-variables/NSIS/environment-variables.nsis @@ -0,0 +1,3 @@ +ExpandEnvStrings $0 "%PATH%" ; Retrieve PATH and place it in builtin register 0. +ExpandEnvStrings $1 "%USERPROFILE%" ; Retrieve the user's profile location and place it in builtin register 1. +ExpandEnvStrings $2 "%USERNAME%" ; Retrieve the user's account name and place it in builtin register 2. diff --git a/Task/Environment-variables/NetRexx/environment-variables.netrexx b/Task/Environment-variables/NetRexx/environment-variables.netrexx new file mode 100644 index 0000000000..f95fb3b467 --- /dev/null +++ b/Task/Environment-variables/NetRexx/environment-variables.netrexx @@ -0,0 +1,60 @@ +/* NetRexx */ +options replace format comments java crossref symbols nobinary + +runSample(arg) +return + +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +method sysEnvironment(vn = '') public static + if vn.length > 0 then do + envName = vn + envValu = System.getenv(envName) + if envValu = null then envValu = '' + say envName '=' envValu + end + else do + envVars = System.getenv() + key = String + loop key over envVars.keySet() + envName = key + envValu = String envVars.get(key) + say envName '=' envValu + end key + end + return + +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +method sysProperties(vn = '') public static + if vn.length > 0 then do + propName = vn + propValu = System.getProperty(propName) + if propValu = null then propValu = '' + say propName '=' propValu + end + else do + sysProps = System.getProperties() + key = String + loop key over sysProps.keySet() + propName = key + propValu = sysProps.getProperty(key) + say propName '=' propValu + end key + end + return + +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +method runSample(arg) public static + parse arg ev pv . + if ev = '' then ev = 'CLASSPATH' + if pv = '' then pv = 'java.class.path' + say '-'.left(80, '-').overlay(' Environment "'ev'" ', 5) + sysEnvironment(ev) + say '-'.left(80, '-').overlay(' Properties "'pv'" ', 5) + sysProperties(pv) + say + say '-'.left(80, '-').overlay(' Environment ', 5) + sysEnvironment() + say '-'.left(80, '-').overlay(' Properties ', 5) + sysProperties() + say + return diff --git a/Task/Environment-variables/NewLISP/environment-variables.newlisp b/Task/Environment-variables/NewLISP/environment-variables.newlisp new file mode 100644 index 0000000000..7b5a5410ac --- /dev/null +++ b/Task/Environment-variables/NewLISP/environment-variables.newlisp @@ -0,0 +1,4 @@ +> (env "SHELL") +"/bin/zsh" +> (env "TERM") +"xterm" diff --git a/Task/Environment-variables/OCaml/environment-variables.ocaml b/Task/Environment-variables/OCaml/environment-variables.ocaml new file mode 100644 index 0000000000..e8880a190a --- /dev/null +++ b/Task/Environment-variables/OCaml/environment-variables.ocaml @@ -0,0 +1 @@ +Sys.getenv "HOME" diff --git a/Task/Environment-variables/Objective-C/environment-variables.m b/Task/Environment-variables/Objective-C/environment-variables.m new file mode 100644 index 0000000000..d2c68276f2 --- /dev/null +++ b/Task/Environment-variables/Objective-C/environment-variables.m @@ -0,0 +1 @@ +[[[NSProcessInfo processInfo] environment] objectForKey:@"HOME"] diff --git a/Task/Environment-variables/Oz/environment-variables.oz b/Task/Environment-variables/Oz/environment-variables.oz new file mode 100644 index 0000000000..ac2f008c53 --- /dev/null +++ b/Task/Environment-variables/Oz/environment-variables.oz @@ -0,0 +1 @@ +{System.showInfo "This is where Mozart is installed: "#{OS.getEnv 'OZHOME'}} diff --git a/Task/Environment-variables/PARI-GP/environment-variables-1.pari b/Task/Environment-variables/PARI-GP/environment-variables-1.pari new file mode 100644 index 0000000000..1399473874 --- /dev/null +++ b/Task/Environment-variables/PARI-GP/environment-variables-1.pari @@ -0,0 +1 @@ +getenv("HOME") diff --git a/Task/Environment-variables/PARI-GP/environment-variables-2.pari b/Task/Environment-variables/PARI-GP/environment-variables-2.pari new file mode 100644 index 0000000000..402676d5a3 --- /dev/null +++ b/Task/Environment-variables/PARI-GP/environment-variables-2.pari @@ -0,0 +1 @@ +externstr("echo $HOME") diff --git a/Task/Environment-variables/PARI-GP/environment-variables-3.pari b/Task/Environment-variables/PARI-GP/environment-variables-3.pari new file mode 100644 index 0000000000..b52a5944ec --- /dev/null +++ b/Task/Environment-variables/PARI-GP/environment-variables-3.pari @@ -0,0 +1 @@ +extern("echo \"\\\"$HOME\\\"\"") diff --git a/Task/Environment-variables/PARI-GP/environment-variables-4.pari b/Task/Environment-variables/PARI-GP/environment-variables-4.pari new file mode 100644 index 0000000000..e299ef3dcd --- /dev/null +++ b/Task/Environment-variables/PARI-GP/environment-variables-4.pari @@ -0,0 +1 @@ +echo "\"$HOME\"" diff --git a/Task/Environment-variables/PARI-GP/environment-variables-5.pari b/Task/Environment-variables/PARI-GP/environment-variables-5.pari new file mode 100644 index 0000000000..c348645edd --- /dev/null +++ b/Task/Environment-variables/PARI-GP/environment-variables-5.pari @@ -0,0 +1 @@ +extern("echo Pi") diff --git a/Task/Environment-variables/PHP/environment-variables.php b/Task/Environment-variables/PHP/environment-variables.php new file mode 100644 index 0000000000..681a1524e4 --- /dev/null +++ b/Task/Environment-variables/PHP/environment-variables.php @@ -0,0 +1 @@ +$_ENV['HOME'] diff --git a/Task/Environment-variables/Perl-6/environment-variables.pl6 b/Task/Environment-variables/Perl-6/environment-variables.pl6 new file mode 100644 index 0000000000..375ac05b43 --- /dev/null +++ b/Task/Environment-variables/Perl-6/environment-variables.pl6 @@ -0,0 +1 @@ +say %*ENV; diff --git a/Task/Environment-variables/Perl/environment-variables.pl b/Task/Environment-variables/Perl/environment-variables.pl new file mode 100644 index 0000000000..a9e5d18245 --- /dev/null +++ b/Task/Environment-variables/Perl/environment-variables.pl @@ -0,0 +1 @@ +print $ENV{HOME}, "\n"; diff --git a/Task/Environment-variables/PicoLisp/environment-variables.l b/Task/Environment-variables/PicoLisp/environment-variables.l new file mode 100644 index 0000000000..68117901c0 --- /dev/null +++ b/Task/Environment-variables/PicoLisp/environment-variables.l @@ -0,0 +1,5 @@ +: (sys "TERM") +-> "xterm" + +: (sys "SHELL") +-> "/bin/bash" diff --git a/Task/Environment-variables/PowerShell/environment-variables-1.psh b/Task/Environment-variables/PowerShell/environment-variables-1.psh new file mode 100644 index 0000000000..58f6d5c9e8 --- /dev/null +++ b/Task/Environment-variables/PowerShell/environment-variables-1.psh @@ -0,0 +1 @@ +$Env:Path diff --git a/Task/Environment-variables/PowerShell/environment-variables-2.psh b/Task/Environment-variables/PowerShell/environment-variables-2.psh new file mode 100644 index 0000000000..3d59e5425f --- /dev/null +++ b/Task/Environment-variables/PowerShell/environment-variables-2.psh @@ -0,0 +1 @@ +Get-ChildItem Env: diff --git a/Task/Environment-variables/PureBasic/environment-variables-1.purebasic b/Task/Environment-variables/PureBasic/environment-variables-1.purebasic new file mode 100644 index 0000000000..bcdb586339 --- /dev/null +++ b/Task/Environment-variables/PureBasic/environment-variables-1.purebasic @@ -0,0 +1 @@ +GetEnvironmentVariable("Name") diff --git a/Task/Environment-variables/PureBasic/environment-variables-2.purebasic b/Task/Environment-variables/PureBasic/environment-variables-2.purebasic new file mode 100644 index 0000000000..9ac2602c13 --- /dev/null +++ b/Task/Environment-variables/PureBasic/environment-variables-2.purebasic @@ -0,0 +1,8 @@ +If OpenConsole() + PrintN("Path:"+#CRLF$ + GetEnvironmentVariable("PATH")) + PrintN(#CRLF$+#CRLF$+"NUMBER_OF_PROCESSORS= "+ GetEnvironmentVariable("NUMBER_OF_PROCESSORS")) + + PrintN(#CRLF$+#CRLF$+"Press Enter to quit.") + Input() + CloseConsole() +EndIf diff --git a/Task/Environment-variables/Python/environment-variables.py b/Task/Environment-variables/Python/environment-variables.py new file mode 100644 index 0000000000..5f9c25bbca --- /dev/null +++ b/Task/Environment-variables/Python/environment-variables.py @@ -0,0 +1,2 @@ +import os +os.environ['HOME'] diff --git a/Task/Environment-variables/R/environment-variables.r b/Task/Environment-variables/R/environment-variables.r new file mode 100644 index 0000000000..6346b090d9 --- /dev/null +++ b/Task/Environment-variables/R/environment-variables.r @@ -0,0 +1 @@ +Sys.getenv("PATH") diff --git a/Task/Environment-variables/REBOL/environment-variables.rebol b/Task/Environment-variables/REBOL/environment-variables.rebol new file mode 100644 index 0000000000..22bee1c765 --- /dev/null +++ b/Task/Environment-variables/REBOL/environment-variables.rebol @@ -0,0 +1 @@ +print get-env "HOME" diff --git a/Task/Environment-variables/REXX/environment-variables-1.rexx b/Task/Environment-variables/REXX/environment-variables-1.rexx new file mode 100644 index 0000000000..4d0ff0de8d --- /dev/null +++ b/Task/Environment-variables/REXX/environment-variables-1.rexx @@ -0,0 +1,3 @@ +/*REXX program shows how to get an environmental variable under Windows*/ + +x=value('TEMP',,'SYSTEM') diff --git a/Task/Environment-variables/REXX/environment-variables-2.rexx b/Task/Environment-variables/REXX/environment-variables-2.rexx new file mode 100644 index 0000000000..ee0ce842d3 --- /dev/null +++ b/Task/Environment-variables/REXX/environment-variables-2.rexx @@ -0,0 +1,3 @@ +/*REXX program shows how to get an environmental variable under Windows*/ + +x=value('TEMP',,'ENVIRONMENT') diff --git a/Task/Environment-variables/REXX/environment-variables-3.rexx b/Task/Environment-variables/REXX/environment-variables-3.rexx new file mode 100644 index 0000000000..9cf9a8f00f --- /dev/null +++ b/Task/Environment-variables/REXX/environment-variables-3.rexx @@ -0,0 +1 @@ +x=getenv("PATH") /* Get the contents of the path environment variable */ diff --git a/Task/Environment-variables/Racket/environment-variables.rkt b/Task/Environment-variables/Racket/environment-variables.rkt new file mode 100644 index 0000000000..287a1351ca --- /dev/null +++ b/Task/Environment-variables/Racket/environment-variables.rkt @@ -0,0 +1,2 @@ +#lang racket +(getenv "HOME") diff --git a/Task/Environment-variables/Retro/environment-variables.retro b/Task/Environment-variables/Retro/environment-variables.retro new file mode 100644 index 0000000000..2736eda69f --- /dev/null +++ b/Task/Environment-variables/Retro/environment-variables.retro @@ -0,0 +1,2 @@ +here "HOME" getEnv +here puts diff --git a/Task/Environment-variables/Ruby/environment-variables.rb b/Task/Environment-variables/Ruby/environment-variables.rb new file mode 100644 index 0000000000..361926e9f1 --- /dev/null +++ b/Task/Environment-variables/Ruby/environment-variables.rb @@ -0,0 +1 @@ +ENV['HOME'] diff --git a/Task/Environment-variables/Run-BASIC/environment-variables.run b/Task/Environment-variables/Run-BASIC/environment-variables.run new file mode 100644 index 0000000000..d73b72ca9d --- /dev/null +++ b/Task/Environment-variables/Run-BASIC/environment-variables.run @@ -0,0 +1,20 @@ +' ------- Major environment variables ------------------------------------------- +'DefaultDir$ - The folder path where program files are read/written by default +'Platform$ - The operating system on which Run BASIC is being hosted +'UserInfo$ - This is information about the user's web browser +'UrlKeys$ - Contains informational parameters from the URL submitted when the user connected +'UserAddress$ - Contains the IP address of the user +'ProjectsRoot$ - The folder path where Run BASIC keeps programming projects +'ResourcesRoot$ - The folder path where Run BASIC keeps web-servable files +'Err$ - A description of the last runtime error +'Err - A numeric code for the last runtime error (errors that have no code use zero) +'EventKey$ - The id of the object that generated the last user event +'RowIndex - The numeric index of the table or database accessor link that generated the last user event + + +print "User Info is : ";UserInfo$ +print "Platform is : ";Platform$ +print "Url Keys is : ";UrlKeys$ +print "User Address is: ";UserAddress$ +print "Event Key is : ";EventKey$ +print "Default Dir is : ";DefaultDir$ diff --git a/Task/Environment-variables/SNOBOL4/environment-variables.sno b/Task/Environment-variables/SNOBOL4/environment-variables.sno new file mode 100644 index 0000000000..105fad4a45 --- /dev/null +++ b/Task/Environment-variables/SNOBOL4/environment-variables.sno @@ -0,0 +1,2 @@ + output = host(4,'PATH') +end diff --git a/Task/Environment-variables/Seed7/environment-variables.seed7 b/Task/Environment-variables/Seed7/environment-variables.seed7 new file mode 100644 index 0000000000..9dcb002ca1 --- /dev/null +++ b/Task/Environment-variables/Seed7/environment-variables.seed7 @@ -0,0 +1,6 @@ +$ include "seed7_05.s7i"; + +const proc: main is func + begin + writeln(getenv("HOME")); + end func; diff --git a/Task/Environment-variables/Slate/environment-variables.slate b/Task/Environment-variables/Slate/environment-variables.slate new file mode 100644 index 0000000000..e4b92139f5 --- /dev/null +++ b/Task/Environment-variables/Slate/environment-variables.slate @@ -0,0 +1,2 @@ +Environment variables at: 'PATH'. +"==> '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games'" diff --git a/Task/Environment-variables/Standard-ML/environment-variables.ml b/Task/Environment-variables/Standard-ML/environment-variables.ml new file mode 100644 index 0000000000..e21e707cb5 --- /dev/null +++ b/Task/Environment-variables/Standard-ML/environment-variables.ml @@ -0,0 +1 @@ +OS.Process.getEnv "HOME" diff --git a/Task/Environment-variables/TXR/environment-variables-1.txr b/Task/Environment-variables/TXR/environment-variables-1.txr new file mode 100644 index 0000000000..722f5dfcdf --- /dev/null +++ b/Task/Environment-variables/TXR/environment-variables-1.txr @@ -0,0 +1,4 @@ +@(next :env) +@(collect) +@VAR=@VAL +@(end) diff --git a/Task/Environment-variables/TXR/environment-variables-2.txr b/Task/Environment-variables/TXR/environment-variables-2.txr new file mode 100644 index 0000000000..0ec85dcb7b --- /dev/null +++ b/Task/Environment-variables/TXR/environment-variables-2.txr @@ -0,0 +1,6 @@ +@(next :env) +@(gather) +HOME=@home +USER=@user +PATH=@path +@(end) diff --git a/Task/Environment-variables/TXR/environment-variables-3.txr b/Task/Environment-variables/TXR/environment-variables-3.txr new file mode 100644 index 0000000000..cb5ac570ba --- /dev/null +++ b/Task/Environment-variables/TXR/environment-variables-3.txr @@ -0,0 +1,7 @@ +@(next :env) +@(gather :vars (home user path (shell "/bin/sh"))) +HOME=@home +USER=@user +PATH=@path +SHELL=@shell +@(end) diff --git a/Task/Environment-variables/Tcl/environment-variables.tcl b/Task/Environment-variables/Tcl/environment-variables.tcl new file mode 100644 index 0000000000..10360c2ae8 --- /dev/null +++ b/Task/Environment-variables/Tcl/environment-variables.tcl @@ -0,0 +1 @@ +$env(HOME) diff --git a/Task/Environment-variables/UNIX-Shell/environment-variables-1.sh b/Task/Environment-variables/UNIX-Shell/environment-variables-1.sh new file mode 100644 index 0000000000..2d6c8a4359 --- /dev/null +++ b/Task/Environment-variables/UNIX-Shell/environment-variables-1.sh @@ -0,0 +1 @@ +echo "$HOME" diff --git a/Task/Environment-variables/UNIX-Shell/environment-variables-2.sh b/Task/Environment-variables/UNIX-Shell/environment-variables-2.sh new file mode 100644 index 0000000000..b021eb4294 --- /dev/null +++ b/Task/Environment-variables/UNIX-Shell/environment-variables-2.sh @@ -0,0 +1 @@ +export VAR diff --git a/Task/Environment-variables/Ursala/environment-variables.ursala b/Task/Environment-variables/Ursala/environment-variables.ursala new file mode 100644 index 0000000000..9e2475930e --- /dev/null +++ b/Task/Environment-variables/Ursala/environment-variables.ursala @@ -0,0 +1,5 @@ +#import std + +#executable ('parameterized','') + +showenv = <.file$[contents: --<''>]>+ %smP+ ~&n-={'TERM','SHELL','X11BROWSER'}*~+ ~environs diff --git a/Task/Environment-variables/Vedit-macro-language/environment-variables-1.vedit b/Task/Environment-variables/Vedit-macro-language/environment-variables-1.vedit new file mode 100644 index 0000000000..bee96f461f --- /dev/null +++ b/Task/Environment-variables/Vedit-macro-language/environment-variables-1.vedit @@ -0,0 +1,2 @@ +Get_Environment(10,"PATH") +Message(@10) diff --git a/Task/Environment-variables/Vedit-macro-language/environment-variables-2.vedit b/Task/Environment-variables/Vedit-macro-language/environment-variables-2.vedit new file mode 100644 index 0000000000..4e1aab8301 --- /dev/null +++ b/Task/Environment-variables/Vedit-macro-language/environment-variables-2.vedit @@ -0,0 +1 @@ +GE(10,"PATH") M(@10) diff --git a/Task/Environment-variables/XPL0/environment-variables.xpl0 b/Task/Environment-variables/XPL0/environment-variables.xpl0 new file mode 100644 index 0000000000..88c0454e82 --- /dev/null +++ b/Task/Environment-variables/XPL0/environment-variables.xpl0 @@ -0,0 +1,28 @@ +include c:\cxpl\codes; \intrinsic 'code' declarations +string 0; \use zero-terminated strings +int CpuReg, PspSeg, EnvSeg, I, J, C; +char EnvVar; +[CpuReg:= GetReg; \access CPU registers +PspSeg:= CpuReg(9); \get segment address of our PSP +EnvSeg:= Peek(PspSeg,$2C) + Peek(PspSeg,$2D)<<8; +EnvVar:= "PATH"; \environment variable +I:= 0; +loop [J:= 0; + loop [C:= Peek(EnvSeg,I); I:= I+1; + if C = 0 then quit; + if C = EnvVar(J) then + [J:= J+1; + if J = 4 then + [Text(0, EnvVar); \show env. var. + loop [C:= Peek(EnvSeg,I); \ and rest of + I:= I+1; \ its string + if C = 0 then exit; + ChOut(0, C); + ]; + ]; + ] + else J:= 5; \line must start with environment variable + ]; + if Peek(EnvSeg,I) = 0 then quit; \double 0 = env. var. not found + ]; +] diff --git a/Task/Execute-SNUSP/0DESCRIPTION b/Task/Execute-SNUSP/0DESCRIPTION new file mode 100644 index 0000000000..eaafee6114 --- /dev/null +++ b/Task/Execute-SNUSP/0DESCRIPTION @@ -0,0 +1,3 @@ +{{implementation|SNUSP}}'''RCSNUSP''' is a set of [[SNUSP]] compilers and interpreters written for Rosetta Code in a variety of languages. Below are links to each of the versions of RCSNUSP. + +An implementation need only properly implement the Core SNUSP instructions ('$', '\', '/', '+', '-', '<', '>', ',', '.', '!', and '?'). Modular SNUSP ('#', '@') and Bloated SNUSP (':', ';', '%', and '&') are also allowed, but not required. Any extra characters that you implement should be noted in the description of your implementation. Any cell size is allowed, EOF support is optional, as is whether you have bounded or unbounded memory. diff --git a/Task/Execute-SNUSP/1META.yaml b/Task/Execute-SNUSP/1META.yaml new file mode 100644 index 0000000000..aba307f8bf --- /dev/null +++ b/Task/Execute-SNUSP/1META.yaml @@ -0,0 +1,3 @@ +--- +category: +- Compilers and Interpreters diff --git a/Task/Execute-a-Markov-algorithm/0DESCRIPTION b/Task/Execute-a-Markov-algorithm/0DESCRIPTION new file mode 100644 index 0000000000..afdc11b4d3 --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/0DESCRIPTION @@ -0,0 +1,127 @@ +Create an interpreter for a [[wp:Markov algorithm|Markov Algorithm]]. Rules have the syntax: + ::= (( | ) +)* + ::= # {} + ::= -> [.] + ::= ( | ) [] +There is one rule per line. If there is a . present before the , then this is a terminating rule in which case the interpreter must halt execution. A ruleset consists of a sequence of rules, with optional comments. + +=Rulesets= + +Use the following tests on entries: + +==Ruleset 1== +
+# This rules file is extracted from Wikipedia:
+# http://en.wikipedia.org/wiki/Markov_Algorithm
+A -> apple
+B -> bag
+S -> shop
+T -> the
+the shop -> my brother
+a never used -> .terminating rule
+
+Sample text of: +: I bought a B of As from T S. +Should generate the output: +: I bought a bag of apples from my brother. + +==Ruleset 2== +A test of the terminating rule +
+# Slightly modified from the rules on Wikipedia
+A -> apple
+B -> bag
+S -> .shop
+T -> the
+the shop -> my brother
+a never used -> .terminating rule
+Sample text of: +: I bought a B of As from T S. +Should generate: +: I bought a bag of apples from T shop. + +==Ruleset 3== +This tests for correct substitution order and may trap simple regexp based replacement routines if special regexp characters are not escaped. +
# BNF Syntax testing rules
+A -> apple
+WWWW -> with
+Bgage -> ->.*
+B -> bag
+->.* -> money
+W -> WW
+S -> .shop
+T -> the
+the shop -> my brother
+a never used -> .terminating rule
+Sample text of: +: I bought a B of As W my Bgage from T S. +Should generate: +: I bought a bag of apples with my money from T shop. + +==Ruleset 4== +This tests for correct order of scanning of rules, and may trap replacement routines that scan in the wrong order. It implements a general unary multiplication engine. (Note that the input expression must be placed within underscores in this implementation.) +
+### Unary Multiplication Engine, for testing Markov Algorithm implementations
+### By Donal Fellows.
+# Unary addition engine
+_+1 -> _1+
+1+1 -> 11+
+# Pass for converting from the splitting of multiplication into ordinary
+# addition
+1! -> !1
+,! -> !+
+_! -> _
+# Unary multiplication by duplicating left side, right side times
+1*1 -> x,@y
+1x -> xX
+X, -> 1,1
+X1 -> 1X
+_x -> _X
+,x -> ,X
+y1 -> 1y
+y_ -> _
+# Next phase of applying
+1@1 -> x,@y
+1@_ -> @_
+,@_ -> !_
+++ -> +
+# Termination cleanup for addition
+_1 -> 1
+1+_ -> 1
+_+_ ->
+
+Sample text of: +: _1111*11111_ +should generate the output: +: 11111111111111111111 + +==Ruleset 5== +A simple Turing machine, implementing a three-state busy beaver. The tape consists of 0s and 1s, the states are A, B, C and H (for Halt), and the head position is indicated by writing the state letter before the character where the head is. All parts of the initial tape the machine operates on have to be given in the input. + +Besides demonstrating that the Markov algorithm is Turing-complete, it also made me catch a bug in the C++ implementation which wasn't caught by the first four rulesets. +
+# Turing machine: three-state busy beaver
+#
+# state A, symbol 0 => write 1, move right, new state B
+A0 -> 1B
+# state A, symbol 1 => write 1, move left, new state C
+0A1 -> C01
+1A1 -> C11
+# state B, symbol 0 => write 1, move left, new state A
+0B0 -> A01
+1B0 -> A11
+# state B, symbol 1 => write 1, move right, new state B
+B1 -> 1B
+# state C, symbol 0 => write 1, move left, new state B
+0C0 -> B01
+1C0 -> B11
+# state C, symbol 1 => write 1, move left, halt
+0C1 -> H01
+1C1 -> H11
+
+This ruleset should turn +: 000000A000000 +into +: 00011H1111000 + +=Examples= diff --git a/Task/Execute-a-Markov-algorithm/1META.yaml b/Task/Execute-a-Markov-algorithm/1META.yaml new file mode 100644 index 0000000000..d82b7779d0 --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Compilers and Interpreters diff --git a/Task/Execute-a-Markov-algorithm/Ada/execute-a-markov-algorithm-1.ada b/Task/Execute-a-Markov-algorithm/Ada/execute-a-markov-algorithm-1.ada new file mode 100644 index 0000000000..856f18c959 --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/Ada/execute-a-markov-algorithm-1.ada @@ -0,0 +1,26 @@ +with Ada.Strings.Unbounded; + +package Markov is + use Ada.Strings.Unbounded; + type Ruleset (Length : Natural) is private; + type String_Array is array (Positive range <>) of Unbounded_String; + function Parse (S : String_Array) return Ruleset; + function Apply (R : Ruleset; S : String) return String; +private + type Entry_Kind is (Comment, Rule); + type Set_Entry (Kind : Entry_Kind := Rule) is record + case Kind is + when Rule => + Source : Unbounded_String; + Target : Unbounded_String; + Is_Terminating : Boolean; + when Comment => + Text : Unbounded_String; + end case; + end record; + subtype Rule_Entry is Set_Entry (Kind => Rule); + type Entry_Array is array (Positive range <>) of Set_Entry; + type Ruleset (Length : Natural) is record + Entries : Entry_Array (1 .. Length); + end record; +end Markov; diff --git a/Task/Execute-a-Markov-algorithm/Ada/execute-a-markov-algorithm-2.ada b/Task/Execute-a-Markov-algorithm/Ada/execute-a-markov-algorithm-2.ada new file mode 100644 index 0000000000..2182403cc7 --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/Ada/execute-a-markov-algorithm-2.ada @@ -0,0 +1,81 @@ +package body Markov is + + function Parse (S : String_Array) return Ruleset is + Result : Ruleset (Length => S'Length); + begin + for I in S'Range loop + if Length (S (I)) = 0 or else Element (S (I), 1) = '#' then + Result.Entries (I) := (Kind => Comment, Text => S (I)); + else + declare + Separator : Natural; + Terminating : Boolean; + Target : Unbounded_String; + begin + Separator := Index (S (I), " -> "); + if Separator = 0 then + raise Constraint_Error; + end if; + Target := + Unbounded_Slice + (Source => S (I), + Low => Separator + 4, + High => Length (S (I))); + Terminating := Length (Target) > 0 + and then Element (Target, 1) = '.'; + if Terminating then + Delete (Source => Target, From => 1, Through => 1); + end if; + Result.Entries (I) := + (Kind => Rule, + Source => Unbounded_Slice + (Source => S (I), + Low => 1, + High => Separator - 1), + Target => Target, + Is_Terminating => Terminating); + end; + end if; + end loop; + return Result; + end Parse; + + procedure Apply + (R : Rule_Entry; + S : in out Unbounded_String; + Modified : in out Boolean) + is + Pattern : String := To_String (R.Source); + Where : Natural := Index (S, Pattern); + begin + while Where /= 0 loop + Modified := True; + Replace_Slice + (Source => S, + Low => Where, + High => Where + Pattern'Length - 1, + By => To_String (R.Target)); + Where := Index (S, Pattern, Where + Length (R.Target)); + end loop; + end Apply; + + function Apply (R : Ruleset; S : String) return String is + Result : Unbounded_String := To_Unbounded_String (S); + Current_Rule : Set_Entry; + Modified : Boolean := False; + begin + loop + Modified := False; + for I in R.Entries'Range loop + Current_Rule := R.Entries (I); + if Current_Rule.Kind = Rule then + Apply (Current_Rule, Result, Modified); + exit when Current_Rule.Is_Terminating or else Modified; + end if; + end loop; + exit when not Modified; + end loop; + return To_String (Result); + end Apply; + +end Markov; diff --git a/Task/Execute-a-Markov-algorithm/Ada/execute-a-markov-algorithm-3.ada b/Task/Execute-a-Markov-algorithm/Ada/execute-a-markov-algorithm-3.ada new file mode 100644 index 0000000000..b43ea547b8 --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/Ada/execute-a-markov-algorithm-3.ada @@ -0,0 +1,48 @@ +with Ada.Command_Line; +with Ada.Text_IO.Unbounded_IO; +with Ada.Strings.Unbounded; +with Markov; + +procedure Test_Markov is + use Ada.Strings.Unbounded; + package IO renames Ada.Text_IO.Unbounded_IO; + Rule_File : Ada.Text_IO.File_Type; + Line_Count : Natural := 0; +begin + if Ada.Command_Line.Argument_Count /= 2 then + Ada.Text_IO.Put_Line ("Usage: test_markov ruleset_file source_file"); + return; + end if; + Ada.Text_IO.Open + (File => Rule_File, + Mode => Ada.Text_IO.In_File, + Name => Ada.Command_Line.Argument (1)); + while not Ada.Text_IO.End_Of_File (Rule_File) loop + Ada.Text_IO.Skip_Line (Rule_File); + Line_Count := Line_Count + 1; + end loop; + declare + Lines : Markov.String_Array (1 .. Line_Count); + begin + Ada.Text_IO.Reset (Rule_File); + for I in Lines'Range loop + Lines (I) := IO.Get_Line (Rule_File); + end loop; + Ada.Text_IO.Close (Rule_File); + + declare + Ruleset : Markov.Ruleset := Markov.Parse (Lines); + Source_File : Ada.Text_IO.File_Type; + begin + Ada.Text_IO.Open + (File => Source_File, + Mode => Ada.Text_IO.In_File, + Name => Ada.Command_Line.Argument (2)); + while not Ada.Text_IO.End_Of_File (Source_File) loop + Ada.Text_IO.Put_Line + (Markov.Apply (Ruleset, Ada.Text_IO.Get_Line (Source_File))); + end loop; + Ada.Text_IO.Close (Source_File); + end; + end; +end Test_Markov; diff --git a/Task/Execute-a-Markov-algorithm/AutoHotkey/execute-a-markov-algorithm.ahk b/Task/Execute-a-Markov-algorithm/AutoHotkey/execute-a-markov-algorithm.ahk new file mode 100644 index 0000000000..cd843fbb9a --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/AutoHotkey/execute-a-markov-algorithm.ahk @@ -0,0 +1,354 @@ +;--------------------------------------------------------------------------- +; Markov Algorithm.ahk +; by wolf_II +;--------------------------------------------------------------------------- +; interpreter for a Markov Algorithm +;--------------------------------------------------------------------------- + + + +;--------------------------------------------------------------------------- +AutoExecute: ; auto-execute section of the script +;--------------------------------------------------------------------------- + #SingleInstance, Force ; only one instance allowed + #NoEnv ; don't check empty variables + StartupDir := A_WorkingDir ; remember startup directory + SetWorkingDir, %A_ScriptDir% ; change directoy + StringCaseSense, On ; case sensitive comparisons + ;----------------------------------------------------------------------- + AppName := "Markov Algorithm" + Gosub, GuiCreate + Gui, Show,, %AppName% + +Return + + + +;--------------------------------------------------------------------------- +GuiCreate: ; create the GUI +;--------------------------------------------------------------------------- + ; GUI options + Gui, -MinimizeBox + Gui, Add, Edit, y0 h0 ; catch the focus + + ; Ruleset + Gui, Add, GroupBox, w445 h145 Section, Ruleset + Gui, Add, Edit, xs+15 ys+20 w300 r8 vRuleset + Gui, Add, Button, x+15 w100, Load Ruleset + Gui, Add, Button, wp, Save Ruleset + Gui, Add, Button, w30, 1 + Gui, Add, Button, x+5 wp, 2 + Gui, Add, Button, x+5 wp, 3 + Gui, Add, Button, xs+330 y+6 wp, 4 + Gui, Add, Button, x+5 wp, 5 + + ; String + Gui, Add, GroupBox, xs w445 h75 Section, String + Gui, Add, Edit, xs+15 ys+20 w300 vString + Gui, Add, Button, x+15 w100, Apply Ruleset + Gui, Add, Button, xp wp Hidden, Stop + Gui, Add, CheckBox, xs+15 yp+30 vSingleStepping, Single Stepping? + + ; Output + Gui, Add, GroupBox, xs w445 h235 Section, Output + Gui, Add, Edit, xs+15 ys+20 w415 r15 ReadOnly vOutput HwndhOut + +Return + + + +;--------------------------------------------------------------------------- +GuiClose: +;--------------------------------------------------------------------------- + ExitApp + +Return + + + +;--------------------------------------------------------------------------- +ButtonLoadRuleset: ; load ruleset from file +;--------------------------------------------------------------------------- + Gui, +OwnDialogs + FileSelectFile, RulesetFile,,, Load Ruleset, *.markov + If Not SubStr(RulesetFile, -6) = ".markov" + RulesetFile .= ".markov" + If FileExist(RulesetFile) { + FileRead, Ruleset, %RulesetFile% + GuiControl,, Ruleset, %Ruleset% + } Else + MsgBox, 16, Error - %AppName%, File not found:`n`n"%RulesetFile%" + +Return + + + +;--------------------------------------------------------------------------- +ButtonSaveRuleset: ; save ruleset to file +;--------------------------------------------------------------------------- + Gui, +OwnDialogs + Gui, Submit, NoHide + FileSelectFile, RulesetFile, S16,, Save Ruleset, *.markov + If Not SubStr(RulesetFile, -6) = ".markov" + RulesetFile .= ".markov" + FileDelete, %RulesetFile% + FileAppend, %Ruleset%, %RulesetFile% + Gui, Show + +Return + + +_ +;--------------------------------------------------------------------------- +Button1: ; http://rosettacode.org/wiki/Execute_a_Markov_algorithm#Ruleset_1 +;--------------------------------------------------------------------------- + GuiControl,, Output ; clear output + GuiControl,, String, I bought a B of As from T S. + GuiControl,, Ruleset, + (LTrim + # This rules file is extracted from Wikipedia: + # http://en.wikipedia.org/wiki/Markov_Algorithm + A -> apple + B -> bag + S -> shop + T -> the + the shop -> my brother + a never used -> .terminating rule + ) + +Return + + + +;--------------------------------------------------------------------------- +Button2: ; http://rosettacode.org/wiki/Execute_a_Markov_algorithm#Ruleset_2 +;--------------------------------------------------------------------------- + GuiControl,, Output ; clear output + GuiControl,, String, I bought a B of As from T S. + GuiControl,, Ruleset, + (LTrim + # Slightly modified from the rules on Wikipedia + A -> apple + B -> bag + S -> .shop + T -> the + the shop -> my brother + a never used -> .terminating rule + ) + +Return + + + +;--------------------------------------------------------------------------- +Button3: ; http://rosettacode.org/wiki/Execute_a_Markov_algorithm#Ruleset_3 +;--------------------------------------------------------------------------- + GuiControl,, Output ; clear output + GuiControl,, String, I bought a B of As W my Bgage from T S. + GuiControl,, Ruleset, + (LTrim + # BNF Syntax testing rules + A -> apple + WWWW -> with + Bgage -> ->.* + B -> bag + ->.* -> money + W -> WW + S -> .shop + T -> the + the shop -> my brother + a never used -> .terminating rule + ) + +Return + + + +;--------------------------------------------------------------------------- +Button4: ; http://rosettacode.org/wiki/Execute_a_Markov_algorithm#Ruleset_4 +;--------------------------------------------------------------------------- + GuiControl,, Output ; clear output + GuiControl,, String, _1111*11111_ + GuiControl,, Ruleset, + (LTrim + ### Unary Multiplication Engine, for testing Markov Algorithm implementations + ### By Donal Fellows. + # Unary addition engine + _+1 -> _1+ + 1+1 -> 11+ + # Pass for converting from the splitting of multiplication into ordinary + # addition + 1! -> !1 + ,! -> !+ + _! -> _ + # Unary multiplication by duplicating left side, right side times + 1*1 -> x,@y + 1x -> xX + X, -> 1,1 + X1 -> 1X + _x -> _X + ,x -> ,X + y1 -> 1y + y_ -> _ + # Next phase of applying + 1@1 -> x,@y + 1@_ -> @_ + ,@_ -> !_ + ++ -> + + # Termination cleanup for addition + _1 -> 1 + 1+_ -> 1 + _+_ -> + ) + +Return + + + +;--------------------------------------------------------------------------- +Button5: ; http://rosettacode.org/wiki/Execute_a_Markov_algorithm#Ruleset_5 +;--------------------------------------------------------------------------- + GuiControl,, Output ; clear output + GuiControl,, String, 000000A000000 + GuiControl,, Ruleset, + (LTrim + # Turing machine: three-state busy beaver + # + # state A, symbol 0 => write 1, move right, new state B + A0 -> 1B + # state A, symbol 1 => write 1, move left, new state C + 0A1 -> C01 + 1A1 -> C11 + # state B, symbol 0 => write 1, move left, new state A + 0B0 -> A01 + 1B0 -> A11 + # state B, symbol 1 => write 1, move right, new state B + B1 -> 1B + # state C, symbol 0 => write 1, move left, new state B + 0C0 -> B01 + 1C0 -> B11 + # state C, symbol 1 => write 1, move left, halt + 0C1 -> H01 + 1C1 -> H11 + ) + +Return + + + +;--------------------------------------------------------------------------- +ButtonApplyRuleset: ; flow control for Algorithm +;--------------------------------------------------------------------------- + ; prepare + Gui, Submit, NoHide + GuiControl,, Output ; clear + Controls(False) ; disable + Count := 0 + Subst := True + Stop := False + + ; keep substituting for as long as necessary + While, Subst { + Subst := False ; reset control variable + IfEqual, Stop, 1, Break + Gosub, Algorithm + } + + ; clean up + Output("Substitution count: " Count) + Controls(True) ; re-enable + +Return + + + +;--------------------------------------------------------------------------- +ButtonStop: ; this button is initially hidden +;--------------------------------------------------------------------------- + Stop := True + +Return + + + +;--------------------------------------------------------------------------- +Algorithm: ; http://rosettacode.org/wiki/Execute_a_Markov_algorithm +;--------------------------------------------------------------------------- + ; Parse the ruleset and apply each rule to the string. Whenever a rule + ; has changed the string goto first rule. Continue until a encountering + ; a terminating rule, or until no further changes to the strings are + ; made. + ;----------------------------------------------------------------------- + Loop, Parse, Ruleset, `n, `r ; always start from the beginning + { + ; check for comment + If SubStr(A_LoopField, 1, 1) = "#" + Continue ; get next line + + ; split a rule into $Search, $Terminator and $Replace + LookFor := "(?P.+) -> (?P\.?)(?P.+)" + RegExMatch(A_LoopField, LookFor, $) + + ; single stepping through possible substitutions + If SingleStepping + MsgBox,, %AppName%, % "" + . "Rule = """ A_LoopField """`n`n" + . "Search`t= """ $Search """`n" + . "Replace`t= """ $Replace """`n" + . "Termintor`t= """ ($Terminator ? "True" : "False") """`n" + + ; try to substitute + StringReplace, String, String, %$Search%, %$Replace%, UseErrorLevel + + ; any success? + If ErrorLevel { ; yes, substitution done + Count++ ; keep count + Subst := True ; set control variable + Output(String) ; write new string to output + } + + ; terminate? + If $Terminator { ; yes, terminate + Stop := True ; set control variable + Break ; back to flow control + } + + ; we are not yet terminated ... + If Subst ; but we just did a substitution + Break ; back to flow control + } + +Return + + + +;--------------------------------------------------------------------------- +Controls(Bool) { ; [en|dis]able controls +;--------------------------------------------------------------------------- + Enable := Bool ? "+" : "-" + Disable := Bool ? "-" : "+" + Loop, 2 + GuiControl, %Disable%ReadOnly, % "Edit" A_Index + 1 + Loop, 7 + GuiControl, %Disable%Disabled, % "Button" A_Index + 1 + GuiControl, %Disable%Disabled, Edit4 + GuiControl, %Disable%Hidden, Button10 + GuiControl, %Enable%Hidden, Button11 + GuiControl, %Disable%Disabled, Button12 +} + + + +;--------------------------------------------------------------------------- +Output(Text) { ; append text to output +;--------------------------------------------------------------------------- + static EM_REPLACESEL = 0xC2 + global hOut + Sleep, 100 + Text .= "`r`n" + SendMessage, EM_REPLACESEL,, &Text,, ahk_id %hOut% +} + + + +;---------- end of file ---------------------------------------------------- diff --git a/Task/Execute-a-Markov-algorithm/BBC-BASIC/execute-a-markov-algorithm.bbc b/Task/Execute-a-Markov-algorithm/BBC-BASIC/execute-a-markov-algorithm.bbc new file mode 100644 index 0000000000..bd3b5f8931 --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/BBC-BASIC/execute-a-markov-algorithm.bbc @@ -0,0 +1,35 @@ + PRINT FNmarkov("ruleset1.txt", "I bought a B of As from T S.") + PRINT FNmarkov("ruleset2.txt", "I bought a B of As from T S.") + PRINT FNmarkov("ruleset3.txt", "I bought a B of As W my Bgage from T S.") + PRINT FNmarkov("ruleset4.txt", "_1111*11111_") + PRINT FNmarkov("ruleset5.txt", "000000A000000") + END + + DEF FNmarkov(rulefile$, text$) + LOCAL i%, done%, rules%, rule$, old$, new$ + rules% = OPENIN(rulefile$) + IF rules%=0 ERROR 100, "Cannot open rules file" + REPEAT + rule$ = GET$#rules% + IF ASC(rule$)<>35 THEN + REPEAT + i% = INSTR(rule$, CHR$(9)) + IF i% MID$(rule$,i%,1) = " " + UNTIL i%=0 + i% = INSTR(rule$, " -> ") + IF i% THEN + old$ = LEFT$(rule$,i%-1) + WHILE RIGHT$(old$)=" " old$ = LEFT$(old$) : ENDWHILE + new$ = MID$(rule$,i%+4) + WHILE ASC(new$)=32 new$ = MID$(new$,2) : ENDWHILE + IF ASC(new$)=46 new$ = MID$(new$,2) : done% = TRUE + i% = INSTR(text$,old$) + IF i% THEN + text$ = LEFT$(text$,i%-1) + new$ + MID$(text$,i%+LEN(old$)) + PTR#rules% = 0 + ENDIF + ENDIF + ENDIF + UNTIL EOF#rules% OR done% + CLOSE #rules% + = text$ diff --git a/Task/Execute-a-Markov-algorithm/C++/execute-a-markov-algorithm.cpp b/Task/Execute-a-Markov-algorithm/C++/execute-a-markov-algorithm.cpp new file mode 100644 index 0000000000..abb5656c3b --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/C++/execute-a-markov-algorithm.cpp @@ -0,0 +1,113 @@ +#include +#include +#include +#include +#include + +struct rule +{ + std::string pattern; + std::string replacement; + bool terminal; + rule(std::string pat, std::string rep, bool term): + pattern(pat), + replacement(rep), + terminal(term) + { + } +}; + +std::string const whitespace = " \t"; +std::string::size_type const npos = std::string::npos; + +bool is_whitespace(char c) +{ + return whitespace.find(c) != npos; +} + +std::vector read_rules(std::ifstream& rulefile) +{ + std::vector rules; + std::string line; + while (std::getline(rulefile, line)) + { + std::string::size_type pos; + + // remove comments + pos = line.find('#'); + if (pos != npos) + line.resize(pos); + + // ignore lines consisting only of whitespace + if (line.find_first_not_of(whitespace) == npos) + continue; + + // find "->" surrounded by whitespace + pos = line.find("->"); + while (pos != npos && (pos == 0 || !is_whitespace(line[pos-1]))) + pos = line.find("->", pos+1); + + if (pos == npos || line.length() < pos+3 || !is_whitespace(line[pos+2])) + { + std::cerr << "invalid rule: " << line << "\n"; + std::exit(EXIT_FAILURE); + } + + std::string pattern = line.substr(0, pos-1); + std::string replacement = line.substr(pos+3); + + // remove additional separating whitespace + pattern.erase(pattern.find_last_not_of(whitespace)+1); + replacement.erase(0, replacement.find_first_not_of(whitespace)); + + // test for terminal rule + bool terminal = !replacement.empty() && replacement[0] == '.'; + if (terminal) + replacement.erase(0,1); + + rules.push_back(rule(pattern, replacement, terminal)); + } + + return rules; +} + +std::string markov(std::vector rules, std::string input) +{ + std::string& output = input; + std::vector::iterator iter = rules.begin(); + + // Loop through each rule, transforming our current version + // with each rule. + while (iter != rules.end()) + { + std::string::size_type pos = output.find(iter->pattern); + if (pos != npos) + { + output.replace(pos, iter->pattern.length(), iter->replacement); + if (iter->terminal) + break; + iter = rules.begin(); + } + else + ++iter; + } + + return output; +} + +int main(int argc, char* argv[]) +{ + if (argc != 3) + { + std::cout << "usage:\n " << argv[0] << " rulefile text\n"; + return EXIT_FAILURE; + } + + std::ifstream rulefile(argv[1]); + std::vector rules = read_rules(rulefile); + + std::string input(argv[2]); + std::string output = markov(rules, input); + + std::cout << output << "\n"; +} diff --git a/Task/Execute-a-Markov-algorithm/C/execute-a-markov-algorithm-1.c b/Task/Execute-a-Markov-algorithm/C/execute-a-markov-algorithm-1.c new file mode 100644 index 0000000000..6242d0725b --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/C/execute-a-markov-algorithm-1.c @@ -0,0 +1,203 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +typedef struct { char * s; size_t alloc_len; } string; + +typedef struct { + char *pat, *repl; + int terminate; +} rule_t; + +typedef struct { + int n; + rule_t *rules; + char *buf; +} ruleset_t; + +void ruleset_del(ruleset_t *r) +{ + if (r->rules) free(r->rules); + if (r->buf) free(r->buf); + free(r); +} + +string * str_new(const char *s) +{ + int l = strlen(s); + string *str = malloc(sizeof(string)); + str->s = malloc(l + 1); + strcpy(str->s, s); + str->alloc_len = l + 1; + return str; +} + +void str_append(string *str, const char *s, int len) +{ + int l = strlen(str->s); + if (len == -1) len = strlen(s); + + if (str->alloc_len < l + len + 1) { + str->alloc_len = l + len + 1; + str->s = realloc(str->s, str->alloc_len); + } + memcpy(str->s + l, s, len); + str->s[l + len] = '\0'; +} + +/* swap content of dest and src, and truncate src string */ +void str_transfer(string *dest, string *src) +{ + size_t tlen = dest->alloc_len; + dest->alloc_len = src->alloc_len; + src->alloc_len = tlen; + + char *ts = dest->s; + dest->s = src->s; + src->s = ts; + src->s[0] = '\0'; +} + +void str_del(string *s) +{ + if (s->s) free(s->s); + free(s); +} + +void str_markov(string *str, ruleset_t *r) +{ + int i, j, sl, pl; + int changed = 0, done = 0; + string *tmp = str_new(""); + + while (!done) { + changed = 0; + for (i = 0; !done && !changed && i < r->n; i++) { + pl = strlen(r->rules[i].pat); + sl = strlen(str->s); + for (j = 0; j < sl; j++) { + if (strncmp(str->s + j, r->rules[i].pat, pl)) + continue; + str_append(tmp, str->s, j); + str_append(tmp, r->rules[i].repl, -1); + str_append(tmp, str->s + j + pl, -1); + + str_transfer(str, tmp); + changed = 1; + + if (r->rules[i].terminate) + done = 1; + break; + } + } + if (!changed) break; + } + str_del(tmp); + return; +} + +ruleset_t* read_rules(const char *name) +{ + struct stat s; + char *buf; + size_t i, j, k, tmp; + rule_t *rules = 0; + int n = 0; /* number of rules */ + + int fd = open(name, O_RDONLY); + if (fd == -1) return 0; + + fstat(fd, &s); + buf = malloc(s.st_size + 2); + read(fd, buf, s.st_size); + buf[s.st_size] = '\n'; + buf[s.st_size + 1] = '\0'; + close(fd); + + for (i = j = 0; buf[i] != '\0'; i++) { + if (buf[i] != '\n') continue; + + /* skip comments */ + if (buf[j] == '#' || i == j) { + j = i + 1; + continue; + } + + /* find the '->' */ + for (k = j + 1; k < i - 3; k++) + if (isspace(buf[k]) && !strncmp(buf + k + 1, "->", 2)) + break; + + if (k >= i - 3) { + printf("parse error: no -> in %.*s\n", i - j, buf + j); + break; + } + + /* left side: backtrack through whitespaces */ + for (tmp = k; tmp > j && isspace(buf[--tmp]); ); + if (tmp < j) { + printf("left side blank? %.*s\n", i - j, buf + j); + break; + } + buf[++tmp] = '\0'; + + /* right side */ + for (k += 3; k < i && isspace(buf[++k]);); + buf[i] = '\0'; + + rules = realloc(rules, sizeof(rule_t) * (1 + n)); + rules[n].pat = buf + j; + + if (buf[k] == '.') { + rules[n].terminate = 1; + rules[n].repl = buf + k + 1; + } else { + rules[n].terminate = 0; + rules[n].repl = buf + k; + } + n++; + + j = i + 1; + } + + ruleset_t *r = malloc(sizeof(ruleset_t)); + r->buf = buf; + r->rules = rules; + r->n = n; + return r; +} + +int test_rules(const char *s, const char *file) +{ + ruleset_t * r = read_rules(file); + if (!r) return 0; + printf("Rules from '%s' ok\n", file); + + string *ss = str_new(s); + printf("text: %s\n", ss->s); + + str_markov(ss, r); + printf("markoved: %s\n", ss->s); + + str_del(ss); + ruleset_del(r); + + return printf("\n"); +} + +int main() +{ + /* rule 1-5 are files containing rules from page top */ + test_rules("I bought a B of As from T S.", "rule1"); + test_rules("I bought a B of As from T S.", "rule2"); + test_rules("I bought a B of As W my Bgage from T S.", "rule3"); + test_rules("_1111*11111_", "rule4"); + test_rules("000000A000000", "rule5"); + + return 0; +} diff --git a/Task/Execute-a-Markov-algorithm/C/execute-a-markov-algorithm-2.c b/Task/Execute-a-Markov-algorithm/C/execute-a-markov-algorithm-2.c new file mode 100644 index 0000000000..b334891258 --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/C/execute-a-markov-algorithm-2.c @@ -0,0 +1,19 @@ +Rules from 'rule1' ok +text: I bought a B of As from T S. +markoved: I bought a bag of apples from my brother. + +Rules from 'rule2' ok +text: I bought a B of As from T S. +markoved: I bought a bag of apples from T shop. + +Rules from 'rule3' ok +text: I bought a B of As W my Bgage from T S. +markoved: I bought a bag of apples with my money from T shop. + +Rules from 'rule4' ok +text: _1111*11111_ +markoved: 11111111111111111111 + +Rules from 'rule5' ok +text: 000000A000000 +markoved: 00011H1111000 diff --git a/Task/Execute-a-Markov-algorithm/D/execute-a-markov-algorithm.d b/Task/Execute-a-Markov-algorithm/D/execute-a-markov-algorithm.d new file mode 100644 index 0000000000..dd725b8783 --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/D/execute-a-markov-algorithm.d @@ -0,0 +1,32 @@ +import std.stdio, std.array, std.file, std.regex, std.string, + std.range; + +void main() { + string[][] rules = readText("markov_rules.txt").splitLines() + .split(""); + auto tests = readText("markov_tests.txt").splitLines(); + auto re = ctRegex!(r"^([^#]*?)\s+->\s+(\.?)(.*)"); // 130 MB RAM. + + auto pairs = zip(StoppingPolicy.requireSameLength, tests, rules); + foreach (test, rule; pairs) { + auto origTest = test.dup; + + string[][] capt; + foreach (line; rule) { + auto m = line.match(re); + if (!m.empty) + capt ~= m.captures.array()[1 .. $]; + } + + REDO: + auto copy = test; + foreach (c; capt) { + test = test.replace(c[0], c[2]); + if (c[1] == ".") + break; + if (test != copy) + goto REDO; + } + writefln("%s\n%s\n", origTest, test); + } +} diff --git a/Task/Execute-a-Markov-algorithm/Go/execute-a-markov-algorithm-1.go b/Task/Execute-a-Markov-algorithm/Go/execute-a-markov-algorithm-1.go new file mode 100644 index 0000000000..26d343dec3 --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/Go/execute-a-markov-algorithm-1.go @@ -0,0 +1,91 @@ +package main + +import ( + "fmt" + "strings" +) + +type testCase struct { + ruleSet, sample, output string +} + +var testSet []testCase // initialized in separate source file + +func main() { + fmt.Println("validating", len(testSet), "test cases") + var failures bool + for i, tc := range testSet { + if r := ma(tc.ruleSet, tc.sample); r != tc.output { + fmt.Println("test", i+1, "fail") + failures = true + } + } + if !failures { + fmt.Println("no failures") + } +} + +type rule struct { + pat string + rep string + term bool +} + +func ma(rs, s string) string { + // compile rules per task description + var rules []rule + for _, line := range strings.Split(rs, "\n") { + if line == "" || line[0] == '#' { + continue + } + a := strings.Index(line, "->") + if a == -1 { + fmt.Println("invalid rule:", line) + return "" + + } + pat := line[:a] + for { + if pat == "" { + b := strings.Index(line[a+2:], "->") + if b == -1 { + fmt.Println("invalid rule:", line) + return "" + } + a += 2 + b + pat = line[:a] + continue + } + last := pat[len(pat)-1] + if last != ' ' && last != '\t' { + break + } + pat = pat[:len(pat)-1] + } + rep := line[a+2:] + for rep > "" && (rep[0] == ' ' || rep[0] == '\t') { + rep = rep[1:] + } + var term bool + if rep > "" && rep[0] == '.' { + term = true + rep = rep[1:] + } + rules = append(rules, rule{pat, rep, term}) + } + // execute algorithm per WP + for r := 0; r < len(rules); { + pat := rules[r].pat + if f := strings.Index(s, pat); f == -1 { + r++ + } else { + + s = s[:f] + rules[r].rep + s[f+len(pat):] + if rules[r].term { + break + } + r = 0 + } + } + return s +} diff --git a/Task/Execute-a-Markov-algorithm/Go/execute-a-markov-algorithm-2.go b/Task/Execute-a-Markov-algorithm/Go/execute-a-markov-algorithm-2.go new file mode 100644 index 0000000000..e9a0d20691 --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/Go/execute-a-markov-algorithm-2.go @@ -0,0 +1,20 @@ +package main + +func init() { + testSet = []testCase{ + { +`# This rules file is extracted from Wikipedia: +# http://en.wikipedia.org/wiki/Markov_Algorithm +A -> apple +B -> bag +S -> shop +T -> the +the shop -> my brother +a never used -> .terminating rule`, + "I bought a B of As from T S.", + "I bought a bag of apples from my brother."}, + { +`# Slightly modified from the rules on Wikipedia +A -> apple +B -> bag +... diff --git a/Task/Execute-a-Markov-algorithm/Groovy/execute-a-markov-algorithm-1.groovy b/Task/Execute-a-Markov-algorithm/Groovy/execute-a-markov-algorithm-1.groovy new file mode 100644 index 0000000000..d12373359e --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/Groovy/execute-a-markov-algorithm-1.groovy @@ -0,0 +1,25 @@ +def markovInterpreterFor = { rules -> + def ruleMap = [:] + rules.eachLine { line -> + (line =~ /\s*(.+)\s->\s([.]?)(.+)\s*/).each { text, key, terminating, value -> + if (key.startsWith('#')) { return } + ruleMap[key] = [text: value, terminating: terminating] + } + } + [interpret: { text -> + def originalText = '' + while (originalText != text) { + originalText = text + for (Map.Entry e : ruleMap.entrySet()) { + if (text.indexOf(e.key) >= 0) { + text = text.replace(e.key, e.value.text) + if (e.value.terminating) { + return text + } + break + } + } + } + text + }] +} diff --git a/Task/Execute-a-Markov-algorithm/Groovy/execute-a-markov-algorithm-2.groovy b/Task/Execute-a-Markov-algorithm/Groovy/execute-a-markov-algorithm-2.groovy new file mode 100644 index 0000000000..0c063e545e --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/Groovy/execute-a-markov-algorithm-2.groovy @@ -0,0 +1,33 @@ +def verify = { ruleset -> + [withInput: { text -> + [hasOutput: { expected -> + def result = ruleset.interpret(text) + println "Input: '$text' has output: '$result'" + assert expected == result + }] + }] +} + +def ruleset1 = markovInterpreterFor(""" +# This rules file is extracted from Wikipedia: +# http://en.wikipedia.org/wiki/Markov_Algorithm +A -> apple +B -> bag +S -> shop +T -> the +the shop -> my brother +a never used -> .terminating rule""") +println ruleset1.interpret('I bought a B of As from T S.') +verify ruleset1 withInput 'I bought a bag of apples from T shop.' hasOutput 'I bought a bag of apples from my brother.' + +def ruleset2 = markovInterpreterFor("""...""") +verify ruleset2 withInput 'I bought a B of As from T S.' hasOutput 'I bought a bag of apples from T shop.' + +def ruleset3 = markovInterpreterFor("""...""") +verify ruleset3 withInput 'I bought a B of As W my Bgage from T S.' hasOutput 'I bought a bag of apples with my money from T shop.' + +def ruleset4 = markovInterpreterFor("""...""") +verify ruleset4 withInput '_1111*11111_' hasOutput '11111111111111111111' + +def ruleset5 = markovInterpreterFor("""...""") +verify ruleset5 withInput '000000A000000' hasOutput '00011H1111000' diff --git a/Task/Execute-a-Markov-algorithm/Haskell/execute-a-markov-algorithm.hs b/Task/Execute-a-Markov-algorithm/Haskell/execute-a-markov-algorithm.hs new file mode 100644 index 0000000000..dc4fc854c0 --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/Haskell/execute-a-markov-algorithm.hs @@ -0,0 +1,43 @@ +import Data.List (isPrefixOf) +import Data.Maybe (catMaybes) +import Control.Monad +import Text.ParserCombinators.Parsec +import System.IO +import System.Environment (getArgs) + +main = do + args <- getArgs + unless (length args == 1) $ + fail "Please provide exactly one source file as an argument." + let sourcePath = head args + source <- readFile sourcePath + input <- getContents + case parse markovParser sourcePath source of + Right rules -> putStr $ runMarkov rules input + Left err -> hPutStrLn stderr $ "Parse error at " ++ show err + +data Rule = Rule + {from :: String, terminating :: Bool, to :: String} + +markovParser :: Parser [Rule] +markovParser = liftM catMaybes $ + (comment <|> rule) `sepEndBy` many1 newline + where comment = char '#' >> skipMany nonnl >> return Nothing + rule = liftM Just $ liftM3 Rule + (manyTill (nonnl "pattern character") $ try arrow) + (succeeds $ char '.') + (many nonnl) + arrow = ws >> string "->" >> ws "whitespace-delimited arrow" + nonnl = noneOf "\n" + ws = many1 $ oneOf " \t" + succeeds p = option False $ p >> return True + +runMarkov :: [Rule] -> String -> String +runMarkov rules s = f rules s + where f [] s = s + f (Rule from terminating to : rs) s = g "" s + where g _ "" = f rs s + g before ahead@(a : as) = if from `isPrefixOf` ahead + then let new = reverse before ++ to ++ drop (length from) ahead + in if terminating then new else f rules new + else g (a : before) as diff --git a/Task/Execute-a-Markov-algorithm/Icon/execute-a-markov-algorithm.icon b/Task/Execute-a-Markov-algorithm/Icon/execute-a-markov-algorithm.icon new file mode 100644 index 0000000000..f83dfcc44b --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/Icon/execute-a-markov-algorithm.icon @@ -0,0 +1,22 @@ +procedure main(A) + rules := loadRules(open(A[1],"r")) + every write(line := !&input, " -> ",apply(rules, line)) +end + +record rule(pat, term, rep) + +procedure loadRules(f) + rules := [] + every !f ? if not ="#" then put(rules, + rule(1(trim(tab(find("->"))),move(2),tab(many(' \t'))), + (="."|&null), trim(tab(0)))) + return rules +end + +procedure apply(rules, line) + s := line + repeat { + s ?:= tab(find((r := !rules).pat)) || r.rep || (move(*r.pat),tab(0)) + if (s == line) | \r.term then return s else line := s + } +end diff --git a/Task/Execute-a-Markov-algorithm/J/execute-a-markov-algorithm-1.j b/Task/Execute-a-Markov-algorithm/J/execute-a-markov-algorithm-1.j new file mode 100644 index 0000000000..2680db9e4a --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/J/execute-a-markov-algorithm-1.j @@ -0,0 +1,30 @@ +require'strings regex' + +markovLexer =: verb define + rules =. LF cut TAB&=`(,:&' ')}y + rules =. a: -.~ (dltb@:{.~ i:&'#')&.> rules + rules =. 0 _1 {"1 '\s+->\s+' (rxmatch rxcut ])S:0 rules + (,. ] (}.&.>~ ,. ]) ('.'={.)&.>)/ |: rules +) + + +replace =: dyad define + 'index patternLength replacement'=. x + 'head tail' =. index split y + head, replacement, patternLength }. tail +) + +matches =: E. i. 1: + +markov =: dyad define + ruleIdx =. 0 [ rules =. markovLexer x + while. ruleIdx < #rules do. + 'pattern replacement terminating' =. ruleIdx { rules + ruleIdx =. 1 + ruleIdx + if. (#y) > index =. pattern matches y do. + y =. (index ; (#pattern) ; replacement) replace y + ruleIdx =. _ * terminating + end. + end. + y +) diff --git a/Task/Execute-a-Markov-algorithm/J/execute-a-markov-algorithm-2.j b/Task/Execute-a-Markov-algorithm/J/execute-a-markov-algorithm-2.j new file mode 100644 index 0000000000..243f11fd3a --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/J/execute-a-markov-algorithm-2.j @@ -0,0 +1,13 @@ + m1 =. noun define + # This rules file is extracted from Wikipedia: + # http://en.wikipedia.org/wiki/Markov_Algorithm + A -> apple + B -> bag + S -> shop + T -> the + the shop -> my brother + a never used -> .terminating rule +) + + m1 markov 'I bought a B of As from T S.' +I bought a bag of apples from my brother. diff --git a/Task/Execute-a-Markov-algorithm/Mathematica/execute-a-markov-algorithm-1.math b/Task/Execute-a-Markov-algorithm/Mathematica/execute-a-markov-algorithm-1.math new file mode 100644 index 0000000000..b4d070dbdd --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/Mathematica/execute-a-markov-algorithm-1.math @@ -0,0 +1,12 @@ +markov[ruleset_, text_] := + Module[{terminating = False, output = text, + rules = StringCases[ + ruleset, {StartOfLine ~~ pattern : Except["\n"] .. ~~ + " " | "\t" .. ~~ "->" ~~ " " | "\t" .. ~~ dot : "" | "." ~~ + replacement : Except["\n"] .. ~~ EndOfLine :> {pattern, + replacement, dot == "."}}]}, + While[! terminating, terminating = True; + Do[If[! StringFreeQ[output, rule[[1]]], + output = StringReplace[output, rule[[1]] -> rule[[2]]]; + If[! rule[[3]], terminating = False]; Break[]], {rule, rules}]]; + output]; diff --git a/Task/Execute-a-Markov-algorithm/Mathematica/execute-a-markov-algorithm-2.math b/Task/Execute-a-Markov-algorithm/Mathematica/execute-a-markov-algorithm-2.math new file mode 100644 index 0000000000..41bb1983fa --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/Mathematica/execute-a-markov-algorithm-2.math @@ -0,0 +1,18 @@ +markov["# Turing machine: three-state busy beaver + # + # state A, symbol 0 => write 1, move right, new state B + A0 -> 1B + # state A, symbol 1 => write 1, move left, new state C + 0A1 -> C01 + 1A1 -> C11 + # state B, symbol 0 => write 1, move left, new state A + 0B0 -> A01 + 1B0 -> A11 + # state B, symbol 1 => write 1, move right, new state B + B1 -> 1B + # state C, symbol 0 => write 1, move left, new state B + 0C0 -> B01 + 1C0 -> B11 + # state C, symbol 1 => write 1, move left, halt + 0C1 -> H01 + 1C1 -> H11", "000000A000000"] diff --git a/Task/Execute-a-Markov-algorithm/Perl/execute-a-markov-algorithm.pl b/Task/Execute-a-Markov-algorithm/Perl/execute-a-markov-algorithm.pl new file mode 100644 index 0000000000..9013b9da8d --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/Perl/execute-a-markov-algorithm.pl @@ -0,0 +1,18 @@ +@ARGV == 1 or die "Please provide exactly one source file as an argument.\n"; +open my $source, '<', $ARGV[0] or die "I couldn't open \"$ARGV[0]\" for reading. ($!.)\n"; +my @rules; +while (<$source>) + {/\A#/ and next; + my @a = /(.*?)\s+->\s+(\.?)(.*)/ or die "Syntax error: $_"; + push @rules, \@a;} +close $source; + +my $input = do {local $/; ;}; + +OUTER: + {foreach (@rules) + {my ($from, $terminating, $to) = @$_; + $input =~ s/\Q$from\E/$to/ + and ($terminating ? last OUTER : redo OUTER);}} + +print $input; diff --git a/Task/Execute-a-Markov-algorithm/PicoLisp/execute-a-markov-algorithm.l b/Task/Execute-a-Markov-algorithm/PicoLisp/execute-a-markov-algorithm.l new file mode 100644 index 0000000000..791d3e7dc2 --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/PicoLisp/execute-a-markov-algorithm.l @@ -0,0 +1,19 @@ +(de markov (File Text) + (use (@A @Z R) + (let Rules + (make + (in File + (while (skip "#") + (when (match '(@A " " "-" ">" " " @Z) (replace (line) "@" "#")) + (link (cons (clip @A) (clip @Z))) ) ) ) ) + (setq Text (chop Text)) + (pack + (loop + (NIL + (find + '((R) (match (append '(@A) (car R) '(@Z)) Text)) + Rules ) + Text ) + (T (= "." (cadr (setq R @))) + (append @A (cddr R) @Z) ) + (setq Text (append @A (cdr R) @Z)) ) ) ) ) ) diff --git a/Task/Execute-a-Markov-algorithm/PureBasic/execute-a-markov-algorithm.purebasic b/Task/Execute-a-Markov-algorithm/PureBasic/execute-a-markov-algorithm.purebasic new file mode 100644 index 0000000000..1cd99d686d --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/PureBasic/execute-a-markov-algorithm.purebasic @@ -0,0 +1,113 @@ +Structure mRule + pattern.s + replacement.s + isTerminal.i +EndStructure + +Procedure parseRule(text.s, List rules.mRule()) + #tab = 9: #space = 32: #whiteSpace$ = Chr(#space) + Chr(#tab) + Protected tLen, cPtr, nChar.c, pEnd, pLast, pattern.s + + cPtr = 1 + If FindString(#whiteSpace$, Left(text, cPtr), 1): ProcedureReturn 0: EndIf ;parse error + If Left(text, cPtr) = "#": ProcedureReturn 2: EndIf ;comment skipped + + tLen = Len(text) + Repeat + cPtr + 1 + If cPtr > tLen: ProcedureReturn 0: EndIf ;parse error + nChar = Asc(Mid(text, cPtr, 1)) + Select nChar + Case #space, #tab + Select pEnd + Case 0 To 2 + pEnd = 1 + pLast = cPtr - 1 + Case 3 + pattern = Left(text, pLast) + EndSelect + Case '-' + If pEnd = 1: pEnd = 2: EndIf + Case '>' + If pEnd = 2: pEnd = 3: EndIf + EndSelect + Until pattern <> "" + + Repeat + cPtr + 1 + Until Not FindString(#whiteSpace$, Mid(text, cPtr, 1), 1) + Protected isTerminal + If Mid(text, cPtr, 1) = "." + isTerminal = #True: cPtr + 1 + EndIf + + LastElement(rules()): AddElement(rules()) + rules()\pattern = pattern + rules()\replacement = Right(text, tLen - cPtr + 1) + rules()\isTerminal = isTerminal + ProcedureReturn 1 ;processed rule +EndProcedure + +Procedure.s interpretMarkov(text.s, List rules.mRule()) + Repeat + madeReplacement = #False + ForEach rules() + If FindString(text, rules()\pattern, 1) + text = ReplaceString(text, rules()\pattern, rules()\replacement) + madeReplacement = #True: isFinished = rules()\isTerminal + Break + EndIf + Next + Until Not madeReplacement Or isFinished + ProcedureReturn text +EndProcedure + +Procedure addRule(text.s, List rules.mRule()) + Protected result = parseRule(text, rules()) + Select result + Case 0: AddGadgetItem(7, -1, "Invalid rule: " + #DQUOTE$ + text + #DQUOTE$) + Case 1: AddGadgetItem(7, -1, "Added: " + #DQUOTE$ + text + #DQUOTE$) + Case 2: AddGadgetItem(7, -1, "Comment: " + #DQUOTE$ + text + #DQUOTE$) + EndSelect +EndProcedure + +OpenWindow(0, 0, 0, 350, 300, "Markov Algorithm Interpreter", #PB_Window_SystemMenu) +ButtonGadget(0, 45, 10, 75, 20, "Load Ruleset") +ButtonGadget(1, 163, 10, 65, 20, "Add Rule") +ButtonGadget(2, 280, 10, 65, 20, "Interpret") +TextGadget(3, 5, 40, 30, 20, "Input:") +StringGadget(4, 45, 40, 300, 20,"") +TextGadget(5, 5, 100, 35, 20, "Output:") +ButtonGadget(6, 160, 70, 70, 20, "Clear Output") +EditorGadget(7, 45, 100, 300, 195, #PB_Editor_ReadOnly) + +NewList rules.mRule() +Define event, isDone, text.s, result, file.s +Repeat + event = WaitWindowEvent() + Select event + Case #PB_Event_Gadget + Select EventGadget() + Case 0 + Define file.s, rule.s + file = OpenFileRequester("Select rule set", "*.txt", "Text (*.txt)|*.txt", 0) + If file + ClearList(rules()) + ReadFile(0, file) + While Not(Eof(0)) + addRule(ReadString(0), rules()) + Wend + AddGadgetItem(7, -1, "Loaded " + Str(ListSize(rules())) + " rules."): AddGadgetItem(7, -1, "") + EndIf + Case 1 + addRule(GetGadgetText(4), rules()) + Case 2 + text = GetGadgetText(4): AddGadgetItem(7, -1, "Interpret: " + #DQUOTE$ + text + #DQUOTE$) + AddGadgetItem(7, -1, "Result: " + #DQUOTE$ + interpretMarkov(text, rules()) + #DQUOTE$): AddGadgetItem(7, -1, "") + Case 6 + ClearGadgetItems(7) + EndSelect + Case #PB_Event_CloseWindow + isDone = #True + EndSelect +Until isDone diff --git a/Task/Execute-a-Markov-algorithm/Python/execute-a-markov-algorithm.py b/Task/Execute-a-Markov-algorithm/Python/execute-a-markov-algorithm.py new file mode 100644 index 0000000000..e0c706f4e5 --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/Python/execute-a-markov-algorithm.py @@ -0,0 +1,134 @@ +import re + +def extractreplacements(grammar): + return [ (matchobj.group('pat'), matchobj.group('repl'), bool(matchobj.group('term'))) + for matchobj in re.finditer(syntaxre, grammar) + if matchobj.group('rule')] + +def replace(text, replacements): + while True: + for pat, repl, term in replacements: + if pat in text: + text = text.replace(pat, repl, 1) + if term: + return text + break + else: + return text + +syntaxre = r"""(?mx) +^(?: + (?: (?P \# .* ) ) | + (?: (?P \s* ) (?: \n | $ ) ) | + (?: (?P (?P .+? ) \s+ -> \s+ (?P \.)? (?P .+) ) ) +)$ +""" + +grammar1 = """\ +# This rules file is extracted from Wikipedia: +# http://en.wikipedia.org/wiki/Markov_Algorithm +A -> apple +B -> bag +S -> shop +T -> the +the shop -> my brother +a never used -> .terminating rule +""" + +grammar2 = '''\ +# Slightly modified from the rules on Wikipedia +A -> apple +B -> bag +S -> .shop +T -> the +the shop -> my brother +a never used -> .terminating rule +''' + +grammar3 = '''\ +# BNF Syntax testing rules +A -> apple +WWWW -> with +Bgage -> ->.* +B -> bag +->.* -> money +W -> WW +S -> .shop +T -> the +the shop -> my brother +a never used -> .terminating rule +''' + +grammar4 = '''\ +### Unary Multiplication Engine, for testing Markov Algorithm implementations +### By Donal Fellows. +# Unary addition engine +_+1 -> _1+ +1+1 -> 11+ +# Pass for converting from the splitting of multiplication into ordinary +# addition +1! -> !1 +,! -> !+ +_! -> _ +# Unary multiplication by duplicating left side, right side times +1*1 -> x,@y +1x -> xX +X, -> 1,1 +X1 -> 1X +_x -> _X +,x -> ,X +y1 -> 1y +y_ -> _ +# Next phase of applying +1@1 -> x,@y +1@_ -> @_ +,@_ -> !_ +++ -> + +# Termination cleanup for addition +_1 -> 1 +1+_ -> 1 +_+_ -> +''' + +grammar5 = '''\ +# Turing machine: three-state busy beaver +# +# state A, symbol 0 => write 1, move right, new state B +A0 -> 1B +# state A, symbol 1 => write 1, move left, new state C +0A1 -> C01 +1A1 -> C11 +# state B, symbol 0 => write 1, move left, new state A +0B0 -> A01 +1B0 -> A11 +# state B, symbol 1 => write 1, move right, new state B +B1 -> 1B +# state C, symbol 0 => write 1, move left, new state B +0C0 -> B01 +1C0 -> B11 +# state C, symbol 1 => write 1, move left, halt +0C1 -> H01 +1C1 -> H11 +''' + +text1 = "I bought a B of As from T S." + +text2 = "I bought a B of As W my Bgage from T S." + +text3 = '_1111*11111_' + +text4 = '000000A000000' + + +if __name__ == '__main__': + assert replace(text1, extractreplacements(grammar1)) \ + == 'I bought a bag of apples from my brother.' + assert replace(text1, extractreplacements(grammar2)) \ + == 'I bought a bag of apples from T shop.' + # Stretch goals + assert replace(text2, extractreplacements(grammar3)) \ + == 'I bought a bag of apples with my money from T shop.' + assert replace(text3, extractreplacements(grammar4)) \ + == '11111111111111111111' + assert replace(text4, extractreplacements(grammar5)) \ + == '00011H1111000' diff --git a/Task/Execute-a-Markov-algorithm/REXX/execute-a-markov-algorithm.rexx b/Task/Execute-a-Markov-algorithm/REXX/execute-a-markov-algorithm.rexx new file mode 100644 index 0000000000..9b1775c78d --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/REXX/execute-a-markov-algorithm.rexx @@ -0,0 +1,41 @@ +/*REXX pgm to execute a Markov algorithm(s) against specified entries.*/ +parse arg low high . /*allow which ruleset to process.*/ +if low=='' | low==',' then low=1 /*assume a default if none given.*/ +if high=='' | high==',' then high=6 /*assume a default if none given.*/ +tellE = low<0; tellR = high<0 /*flags: display file contents. */ +call readEntry + do j=abs(low) to abs(high) /*process each of these rulesets.*/ + call readRules j /*read a particular ruleset. */ + call execRules j /*execute " " " */ + say 'result for ruleset' j"≡"!.j + end /*j*/ +exit /*stick a fork in it, we're done.*/ +/*───────────────────────────────EXECRULES──────────────────────────────*/ +execRules: parse arg q .; if tellE | tellR then say + do f=1 /* forever */ + do k=1 while @.k\==''; if left(@.k,1)=='#' | @.k='' then iterate + parse var @.k a ' ->' b; a=strip(a); b=strip(b) + fullstop= left(b,1)=='.' /*is this a fullstop rule? */ + if fullstop then b=substr(b,2) /*purify the B part of the rule. */ + old=!.q /*remember value before change. */ + !.q=changestr(a, !.q, b) /*implement the ruleset change. */ + if fullstop then if old\==!.q then return /*should we stop?*/ + if old\==!.q then iterate f /*Entry changed? Then start over*/ + end /*k*/ + leave + end /*f*/ +return +/*───────────────────────────────READRULES──────────────────────────────*/ +readRules: parse arg ? .; rFID='MARKOV_R.'?; if tellR then say +@.= /*placeholder: all Markov rules.*/ + do r=1 while lines(rFID)\==0 /*read the input file until E-O-F*/ + @.r=linein(rFID); if tellR then say 'ruleSet' ?"."left(r,4)'≡'@.r + end /*r*/ /*(above) read and maybe echo it.*/ +return +/*───────────────────────────────READENTRY──────────────────────────────*/ +readEntry: eFID='MARKOV.ENT'; if tellE then say +!.= /*placeholder: all test entries.*/ + do e=1 while lines(eFID)\==0 /*read the input file until E-O-F*/ + !.e=linein(eFID); if tellE then say 'test entry' e"≡"!.e + end /*e*/ /*(above) read and maybe echo it.*/ +return diff --git a/Task/Execute-a-Markov-algorithm/Ruby/execute-a-markov-algorithm.rb b/Task/Execute-a-Markov-algorithm/Ruby/execute-a-markov-algorithm.rb new file mode 100644 index 0000000000..2d25124cda --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/Ruby/execute-a-markov-algorithm.rb @@ -0,0 +1,20 @@ +raise "Please input an input code file, an input data file, and an output file." if ARGV.size < 3 + +rules = File.readlines(ARGV[0]).inject([]) do |rules, line| + if line =~ /^\s*#/ + rules + elsif line =~ /^(.+)\s+->\s+(\.?)(.*)$/ + rules << [$1, $3, $2 != ""] + else + raise "Syntax error: #{line}" + end +end + +File.open(ARGV[2], "w") do |file| + file.write(File.read(ARGV[1]).tap { |input_data| + while (matched = rules.find { |match, replace, term| + input_data[match] and input_data.sub!(match, replace) + }) and !matched[2] + end + }) +end diff --git a/Task/Execute-a-Markov-algorithm/Scala/execute-a-markov-algorithm-1.scala b/Task/Execute-a-Markov-algorithm/Scala/execute-a-markov-algorithm-1.scala new file mode 100644 index 0000000000..a7a468ce39 --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/Scala/execute-a-markov-algorithm-1.scala @@ -0,0 +1,30 @@ +import scala.io.Source + +object MarkovAlgorithm { + val RulePattern = """(.*?)\s+->\s+(\.?)(.*)""".r + val CommentPattern = """#.*|\s*""".r + + def rule(line: String) = line match { + case CommentPattern() => None + case RulePattern(pattern, terminal, replacement) => Some(pattern, replacement, terminal == ".") + case _ => error("Syntax error on line "+line) + } + + def main(args: Array[String]) { + if (args.size != 2 ) { + println("Syntax: MarkovAlgorithm inputFile inputPattern") + exit(1) + } + + val rules = (Source fromPath args(0) getLines () map rule).toList.flatten + + def algorithm(input: String): String = rules find (input contains _._1) match { + case Some((pattern, replacement, true)) => input replaceFirst ("\\Q"+pattern+"\\E", replacement) + case Some((pattern, replacement, false)) => algorithm(input replaceFirst ("\\Q"+pattern+"\\E", replacement)) + case None => input + } + + println(args(1)) + println(algorithm(args(1))) + } +} diff --git a/Task/Execute-a-Markov-algorithm/Scala/execute-a-markov-algorithm-2.scala b/Task/Execute-a-Markov-algorithm/Scala/execute-a-markov-algorithm-2.scala new file mode 100644 index 0000000000..f1e17741d1 --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/Scala/execute-a-markov-algorithm-2.scala @@ -0,0 +1,16 @@ +import scala.io.Source + +if (argv.size != 2 ) error("Syntax: MarkovAlgorithm inputFile inputPattern") + +val rulePattern = """(.*?)\s+->\s+(\.?)(.*)""".r +val isComment = (_: String) matches "#.*|\\s*" +val rules = Source fromPath args(0) getLines () filterNot isComment map (rulePattern unapplySeq _ get) toList; + +def algorithm(input: String): String = rules find (input contains _.head) match { + case Some(Seq(pattern, ".", replacement)) => input replaceFirst ("\\Q"+pattern+"\\E", replacement) + case Some(Seq(pattern, "", replacement)) => algorithm(input replaceFirst ("\\Q"+pattern+"\\E", replacement)) + case None => input +} + +println(argv(1)) +println(algorithm(argv(1))) diff --git a/Task/Execute-a-Markov-algorithm/Scheme/execute-a-markov-algorithm.ss b/Task/Execute-a-Markov-algorithm/Scheme/execute-a-markov-algorithm.ss new file mode 100644 index 0000000000..5dc344ce3e --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/Scheme/execute-a-markov-algorithm.ss @@ -0,0 +1,47 @@ +(define split-into-lines + (lambda (str) + (let loop ((index 0) + (result '())) + (let ((next-index (string-index str #\newline index))) + (if next-index + (loop (+ next-index 1) + (cons (substring str index next-index) result)) + (reverse (cons (substring str index) result))))))) + +(define parse-rules + (lambda (str) + (let loop ((rules (split-into-lines str)) + (result '())) + (if (null? rules) + (reverse result) + (let ((rule (car rules))) + (loop (cdr rules) + (if (or (string=? rule "") + (eq? (string-ref rule 0) #\#)) + result + (cons + (let ((index (string-contains rule "->" 1))) + (list (string-trim-right (substring rule 0 index)) + (string-trim (substring rule (+ index 2))))) + result)))))))) + + +(define apply-rules + (lambda (str rules) + (let loop ((remaining rules) + (result str)) + (if (null? remaining) + result + (let* ((rule (car remaining)) + (pattern (car rule)) + (replacement (cadr rule)) + (start (string-contains result pattern))) + (if start + (if (eq? #\. (string-ref replacement 0)) + (string-replace result replacement start + (+ start (string-length pattern)) 1) + (apply-rules + (string-replace result replacement start + (+ start (string-length pattern))) + rules)) + (loop (cdr remaining) result))))))) diff --git a/Task/Execute-a-Markov-algorithm/Tcl/execute-a-markov-algorithm-1.tcl b/Task/Execute-a-Markov-algorithm/Tcl/execute-a-markov-algorithm-1.tcl new file mode 100644 index 0000000000..c466e88c91 --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/Tcl/execute-a-markov-algorithm-1.tcl @@ -0,0 +1,41 @@ +package require Tcl 8.5 +if {$argc < 3} {error "usage: $argv0 ruleFile inputFile outputFile"} +lassign $argv ruleFile inputFile outputFile + +# Read the file of rules +set rules {} +set f [open $ruleFile] +foreach line [split [read $f] \n[close $f]] { + if {[string match "#*" $line] || $line eq ""} continue + if {[regexp {^(.+)\s+->\s+(\.?)(.*)$} $line -> from final to]} { + lappend rules $from $to [string compare "." $final] [string length $from] + } else { + error "Syntax error: \"$line\"" + } +} + +# Apply the rules +set f [open $inputFile] +set out [open $outputFile w] +foreach line [split [read $f] \n[close $f]] { + set any 1 + while {$any} { + set any 0 + foreach {from to more fl} $rules { + # If we match the 'from' pattern... + if {[set idx [string first $from $line]] >= 0} { + # Change for the 'to' replacement + set line [string replace $line $idx [expr {$idx+$fl-1}] $to] + + # Stop if we terminate, otherwise note that we've more work to do + set any $more + break; # Restart search for rules to apply + } + } + #DEBUG# puts $line + } + + # Output the processed line + puts $out $line +} +close $out diff --git a/Task/Execute-a-Markov-algorithm/Tcl/execute-a-markov-algorithm-2.tcl b/Task/Execute-a-Markov-algorithm/Tcl/execute-a-markov-algorithm-2.tcl new file mode 100644 index 0000000000..a2b437b39b --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/Tcl/execute-a-markov-algorithm-2.tcl @@ -0,0 +1,28 @@ +package require Tcl 8.5 +if {$argc < 3} {error "usage: $argv0 ruleFile inputFile outputFile"} +lassign $argv ruleFile inputFile outputFile + +# Read the file of rules +set rules {} +set f [open $ruleFile] +foreach line [split [read $f] \n[close $f]] { + if {[string match "#*" $line] || $line eq ""} continue + if {[regexp {^(.+)\s+->\s+(.*)$} $line -> from to]} { + dict set rules $from $to + } else { + error "Syntax error: \"$line\"" + } +} + +# Apply the rules in a simplistic manner +set in [open $inputFile] +set out [open $outputFile w] +set data [read $in] +close $in +while 1 { + set newData [string map $rules $data] + if {$newData eq $data} break + set data $newData +} +puts $out $data +close $out diff --git a/Task/Execute-a-Markov-algorithm/VBScript/execute-a-markov-algorithm-1.vbscript b/Task/Execute-a-Markov-algorithm/VBScript/execute-a-markov-algorithm-1.vbscript new file mode 100644 index 0000000000..aece3cfe1b --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/VBScript/execute-a-markov-algorithm-1.vbscript @@ -0,0 +1,73 @@ +class markovparser + + dim aRules + public property let ruleset( sBlock ) + dim i + aRules = split( sBlock, vbNewLine ) + '~ remove blank lines from end of array + do while aRules( ubound( aRules ) ) = vbnullstring + redim preserve aRules( ubound( aRules ) - 1 ) + loop + '~ parse array + for i = lbound( aRules ) to ubound( aRules ) + if left( aRules( i ), 1 ) = "#" then + aRules( i ) = Array( vbnullstring, aRules(i)) + else + aRules( i ) = Split( aRules( i ), " -> ", 2 ) + end if + next + end property + + public function apply( sArg ) + dim ruleapplied + dim terminator + dim was + dim i + dim repl + dim changes + + ruleapplied = true + terminator = false + + do while ruleapplied and (not terminator) + changes = 0 + was = sArg + for i = lbound( aRules ) to ubound( aRules ) + repl = aRules(i)(1) + if left( repl, 1 ) = "." then + terminator = true + repl = mid( repl, 2 ) + end if + sArg = replace( sArg, aRules(i)(0), repl) + if was <> sArg then + changes = changes + 1 + if changes = 1 then + exit for + end if + end if + if terminator then + exit for + end if + next + if changes = 0 then + ruleapplied = false + end if + loop + apply = sArg + end function + + sub dump + dim i + for i = lbound( aRules ) to ubound( aRules ) + wscript.echo eef(aRules(i)(0)=vbnullstring,aRules(i)(1),aRules(i)(0)& " -> " & aRules(i)(1)) & eef( left( aRules(i)(1), 1 ) = ".", " #terminator", "" ) + next + end sub + + private function eef( bCond, sExp1, sExp2 ) + if bCond then + eef = sExp1 + else + eef = sExp2 + end if + end function +end class diff --git a/Task/Execute-a-Markov-algorithm/VBScript/execute-a-markov-algorithm-2.vbscript b/Task/Execute-a-Markov-algorithm/VBScript/execute-a-markov-algorithm-2.vbscript new file mode 100644 index 0000000000..293f9b1cfd --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/VBScript/execute-a-markov-algorithm-2.vbscript @@ -0,0 +1,60 @@ +dim m1 +set m1 = new markovparser +m1.ruleset = "# This rules file is extracted from Wikipedia:" & vbNewLine & _ +"# http://en.wikipedia.org/wiki/Markov_Algorithm" & vbNewLine & _ +"A -> apple" & vbNewLine & _ +"B -> bag" & vbNewLine & _ +"S -> shop" & vbNewLine & _ +"T -> the" & vbNewLine & _ +"the shop -> my brother" & vbNewLine & _ +"a never used -> .terminating rule" +wscript.echo m1.apply( "I bought a B of As from T S.") + +dim m2 +set m2 = new markovparser +m2.ruleset = replace( "# Slightly modified from the rules on Wikipedia\nA -> apple\nB -> bag\nS -> .shop\nT -> the\nthe shop -> my brother\na never used -> .terminating rule", "\n", vbNewLine ) +'~ m1.dump +wscript.echo m2.apply( "I bought a B of As from T S.") + +dim m3 +set m3 = new markovparser +m3.ruleset = replace("# BNF Syntax testing rules\nA -> apple\nWWWW -> with\nBgage -> ->.*\nB -> bag" & vbNewLine & _ +"->.* -> money\nW -> WW\nS -> .shop\nT -> the\nthe shop -> my brother\na never used -> .terminating rule", "\n", vbNewLine ) +wscript.echo m3.apply("I bought a B of As W my Bgage from T S.") + +set m4 = new markovparser +m4.ruleset = "### Unary Multiplication Engine, for testing Markov Algorithm implementations" & vbNewLine & _ +"### By Donal Fellows." & vbNewLine & _ +"# Unary addition engine" & vbNewLine & _ +"_+1 -> _1+" & vbNewLine & _ +"1+1 -> 11+" & vbNewLine & _ +"# Pass for converting from the splitting of multiplication into ordinary" & vbNewLine & _ +"# addition" & vbNewLine & _ +"1! -> !1" & vbNewLine & _ +",! -> !+" & vbNewLine & _ +"_! -> _" & vbNewLine & _ +"# Unary multiplication by duplicating left side, right side times" & vbNewLine & _ +"1*1 -> x,@y" & vbNewLine & _ +"1x -> xX" & vbNewLine & _ +"X, -> 1,1" & vbNewLine & _ +"X1 -> 1X" & vbNewLine & _ +"_x -> _X" & vbNewLine & _ +",x -> ,X" & vbNewLine & _ +"y1 -> 1y" & vbNewLine & _ +"y_ -> _" & vbNewLine & _ +"# Next phase of applying" & vbNewLine & _ +"1@1 -> x,@y" & vbNewLine & _ +"1@_ -> @_" & vbNewLine & _ +",@_ -> !_" & vbNewLine & _ +"++ -> +" & vbNewLine & _ +"# Termination cleanup for addition" & vbNewLine & _ +"_1 -> 1" & vbNewLine & _ +"1+_ -> 1" & vbNewLine & _ +"_+_ -> " +'~ m4.dump +wscript.echo m4.apply( "_1111*11111_") + +set fso = createobject("scripting.filesystemobject") +set m5 = new markovparser +m5.ruleset = fso.opentextfile("busybeaver.tur").readall +wscript.echo m5.apply("000000A000000") diff --git a/Task/Execute-a-Markov-algorithm/VBScript/execute-a-markov-algorithm-3.vbscript b/Task/Execute-a-Markov-algorithm/VBScript/execute-a-markov-algorithm-3.vbscript new file mode 100644 index 0000000000..c13bf2feb9 --- /dev/null +++ b/Task/Execute-a-Markov-algorithm/VBScript/execute-a-markov-algorithm-3.vbscript @@ -0,0 +1,5 @@ +I bought a bag of apples from my brother. +I bought a bag of apples from T shop. +I bought a bag of apples with my money from T shop. +11111111111111111111 +00011H1111000 diff --git a/Task/Guess-the-number-With-feedback-player/0DESCRIPTION b/Task/Guess-the-number-With-feedback--player-/0DESCRIPTION similarity index 100% rename from Task/Guess-the-number-With-feedback-player/0DESCRIPTION rename to Task/Guess-the-number-With-feedback--player-/0DESCRIPTION diff --git a/Task/Guess-the-number-With-feedback-player/1META.yaml b/Task/Guess-the-number-With-feedback--player-/1META.yaml similarity index 100% rename from Task/Guess-the-number-With-feedback-player/1META.yaml rename to Task/Guess-the-number-With-feedback--player-/1META.yaml diff --git a/Task/Guess-the-number-With-feedback-player/Ada/guess-the-number-with-feedback-player.ada b/Task/Guess-the-number-With-feedback--player-/Ada/guess-the-number-with-feedback--player-.ada similarity index 100% rename from Task/Guess-the-number-With-feedback-player/Ada/guess-the-number-with-feedback-player.ada rename to Task/Guess-the-number-With-feedback--player-/Ada/guess-the-number-with-feedback--player-.ada diff --git a/Task/Guess-the-number-With-feedback-player/AutoHotkey/guess-the-number-with-feedback-player.ahk b/Task/Guess-the-number-With-feedback--player-/AutoHotkey/guess-the-number-with-feedback--player-.ahk similarity index 100% rename from Task/Guess-the-number-With-feedback-player/AutoHotkey/guess-the-number-with-feedback-player.ahk rename to Task/Guess-the-number-With-feedback--player-/AutoHotkey/guess-the-number-with-feedback--player-.ahk diff --git a/Task/Guess-the-number-With-feedback-player/BBC-BASIC/guess-the-number-with-feedback-player.bbc b/Task/Guess-the-number-With-feedback--player-/BBC-BASIC/guess-the-number-with-feedback--player-.bbc similarity index 100% rename from Task/Guess-the-number-With-feedback-player/BBC-BASIC/guess-the-number-with-feedback-player.bbc rename to Task/Guess-the-number-With-feedback--player-/BBC-BASIC/guess-the-number-with-feedback--player-.bbc diff --git a/Task/Guess-the-number-With-feedback-player/C++/guess-the-number-with-feedback-player.cpp b/Task/Guess-the-number-With-feedback--player-/C++/guess-the-number-with-feedback--player-.cpp similarity index 100% rename from Task/Guess-the-number-With-feedback-player/C++/guess-the-number-with-feedback-player.cpp rename to Task/Guess-the-number-With-feedback--player-/C++/guess-the-number-with-feedback--player-.cpp diff --git a/Task/Guess-the-number-With-feedback-player/C/guess-the-number-with-feedback-player.c b/Task/Guess-the-number-With-feedback--player-/C/guess-the-number-with-feedback--player-.c similarity index 100% rename from Task/Guess-the-number-With-feedback-player/C/guess-the-number-with-feedback-player.c rename to Task/Guess-the-number-With-feedback--player-/C/guess-the-number-with-feedback--player-.c diff --git a/Task/Guess-the-number-With-feedback-player/Clojure/guess-the-number-with-feedback-player.clj b/Task/Guess-the-number-With-feedback--player-/Clojure/guess-the-number-with-feedback--player-.clj similarity index 100% rename from Task/Guess-the-number-With-feedback-player/Clojure/guess-the-number-with-feedback-player.clj rename to Task/Guess-the-number-With-feedback--player-/Clojure/guess-the-number-with-feedback--player-.clj diff --git a/Task/Guess-the-number-With-feedback-player/D/guess-the-number-with-feedback-player.d b/Task/Guess-the-number-With-feedback--player-/D/guess-the-number-with-feedback--player-.d similarity index 100% rename from Task/Guess-the-number-With-feedback-player/D/guess-the-number-with-feedback-player.d rename to Task/Guess-the-number-With-feedback--player-/D/guess-the-number-with-feedback--player-.d diff --git a/Task/Guess-the-number-With-feedback-player/Euphoria/guess-the-number-with-feedback-player.euphoria b/Task/Guess-the-number-With-feedback--player-/Euphoria/guess-the-number-with-feedback--player-.euphoria similarity index 100% rename from Task/Guess-the-number-With-feedback-player/Euphoria/guess-the-number-with-feedback-player.euphoria rename to Task/Guess-the-number-With-feedback--player-/Euphoria/guess-the-number-with-feedback--player-.euphoria diff --git a/Task/Guess-the-number-With-feedback-player/Fantom/guess-the-number-with-feedback-player.fantom b/Task/Guess-the-number-With-feedback--player-/Fantom/guess-the-number-with-feedback--player-.fantom similarity index 100% rename from Task/Guess-the-number-With-feedback-player/Fantom/guess-the-number-with-feedback-player.fantom rename to Task/Guess-the-number-With-feedback--player-/Fantom/guess-the-number-with-feedback--player-.fantom diff --git a/Task/Guess-the-number-With-feedback-player/Fortran/guess-the-number-with-feedback-player.f b/Task/Guess-the-number-With-feedback--player-/Fortran/guess-the-number-with-feedback--player-.f similarity index 100% rename from Task/Guess-the-number-With-feedback-player/Fortran/guess-the-number-with-feedback-player.f rename to Task/Guess-the-number-With-feedback--player-/Fortran/guess-the-number-with-feedback--player-.f diff --git a/Task/Guess-the-number-With-feedback-player/Go/guess-the-number-with-feedback-player-1.go b/Task/Guess-the-number-With-feedback--player-/Go/guess-the-number-with-feedback--player--1.go similarity index 100% rename from Task/Guess-the-number-With-feedback-player/Go/guess-the-number-with-feedback-player-1.go rename to Task/Guess-the-number-With-feedback--player-/Go/guess-the-number-with-feedback--player--1.go diff --git a/Task/Guess-the-number-With-feedback-player/Go/guess-the-number-with-feedback-player-2.go b/Task/Guess-the-number-With-feedback--player-/Go/guess-the-number-with-feedback--player--2.go similarity index 100% rename from Task/Guess-the-number-With-feedback-player/Go/guess-the-number-with-feedback-player-2.go rename to Task/Guess-the-number-With-feedback--player-/Go/guess-the-number-with-feedback--player--2.go diff --git a/Task/Guess-the-number-With-feedback-player/Icon/guess-the-number-with-feedback-player.icon b/Task/Guess-the-number-With-feedback--player-/Icon/guess-the-number-with-feedback--player-.icon similarity index 100% rename from Task/Guess-the-number-With-feedback-player/Icon/guess-the-number-with-feedback-player.icon rename to Task/Guess-the-number-With-feedback--player-/Icon/guess-the-number-with-feedback--player-.icon diff --git a/Task/Guess-the-number-With-feedback-player/J/guess-the-number-with-feedback-player-1.j b/Task/Guess-the-number-With-feedback--player-/J/guess-the-number-with-feedback--player--1.j similarity index 100% rename from Task/Guess-the-number-With-feedback-player/J/guess-the-number-with-feedback-player-1.j rename to Task/Guess-the-number-With-feedback--player-/J/guess-the-number-with-feedback--player--1.j diff --git a/Task/Guess-the-number-With-feedback-player/J/guess-the-number-with-feedback-player-2.j b/Task/Guess-the-number-With-feedback--player-/J/guess-the-number-with-feedback--player--2.j similarity index 100% rename from Task/Guess-the-number-With-feedback-player/J/guess-the-number-with-feedback-player-2.j rename to Task/Guess-the-number-With-feedback--player-/J/guess-the-number-with-feedback--player--2.j diff --git a/Task/Guess-the-number-With-feedback-player/Java/guess-the-number-with-feedback-player.java b/Task/Guess-the-number-With-feedback--player-/Java/guess-the-number-with-feedback--player-.java similarity index 100% rename from Task/Guess-the-number-With-feedback-player/Java/guess-the-number-with-feedback-player.java rename to Task/Guess-the-number-With-feedback--player-/Java/guess-the-number-with-feedback--player-.java diff --git a/Task/Guess-the-number-With-feedback-player/JavaScript/guess-the-number-with-feedback-player.js b/Task/Guess-the-number-With-feedback--player-/JavaScript/guess-the-number-with-feedback--player-.js similarity index 100% rename from Task/Guess-the-number-With-feedback-player/JavaScript/guess-the-number-with-feedback-player.js rename to Task/Guess-the-number-With-feedback--player-/JavaScript/guess-the-number-with-feedback--player-.js diff --git a/Task/Guess-the-number-With-feedback-player/Liberty-BASIC/guess-the-number-with-feedback-player.liberty b/Task/Guess-the-number-With-feedback--player-/Liberty-BASIC/guess-the-number-with-feedback--player-.liberty similarity index 100% rename from Task/Guess-the-number-With-feedback-player/Liberty-BASIC/guess-the-number-with-feedback-player.liberty rename to Task/Guess-the-number-With-feedback--player-/Liberty-BASIC/guess-the-number-with-feedback--player-.liberty diff --git a/Task/Guess-the-number-With-feedback-player/Mathematica/guess-the-number-with-feedback-player.math b/Task/Guess-the-number-With-feedback--player-/Mathematica/guess-the-number-with-feedback--player-.math similarity index 100% rename from Task/Guess-the-number-With-feedback-player/Mathematica/guess-the-number-with-feedback-player.math rename to Task/Guess-the-number-With-feedback--player-/Mathematica/guess-the-number-with-feedback--player-.math diff --git a/Task/Guess-the-number-With-feedback-player/Modula-2/guess-the-number-with-feedback-player.mod2 b/Task/Guess-the-number-With-feedback--player-/Modula-2/guess-the-number-with-feedback--player-.mod2 similarity index 100% rename from Task/Guess-the-number-With-feedback-player/Modula-2/guess-the-number-with-feedback-player.mod2 rename to Task/Guess-the-number-With-feedback--player-/Modula-2/guess-the-number-with-feedback--player-.mod2 diff --git a/Task/Guess-the-number-With-feedback-player/Objective-C/guess-the-number-with-feedback-player.m b/Task/Guess-the-number-With-feedback--player-/Objective-C/guess-the-number-with-feedback--player-.m similarity index 100% rename from Task/Guess-the-number-With-feedback-player/Objective-C/guess-the-number-with-feedback-player.m rename to Task/Guess-the-number-With-feedback--player-/Objective-C/guess-the-number-with-feedback--player-.m diff --git a/Task/Guess-the-number-With-feedback-player/PARI-GP/guess-the-number-with-feedback-player.pari b/Task/Guess-the-number-With-feedback--player-/PARI-GP/guess-the-number-with-feedback--player-.pari similarity index 100% rename from Task/Guess-the-number-With-feedback-player/PARI-GP/guess-the-number-with-feedback-player.pari rename to Task/Guess-the-number-With-feedback--player-/PARI-GP/guess-the-number-with-feedback--player-.pari diff --git a/Task/Guess-the-number-With-feedback-player/Pascal/guess-the-number-with-feedback-player.pascal b/Task/Guess-the-number-With-feedback--player-/Pascal/guess-the-number-with-feedback--player-.pascal similarity index 100% rename from Task/Guess-the-number-With-feedback-player/Pascal/guess-the-number-with-feedback-player.pascal rename to Task/Guess-the-number-With-feedback--player-/Pascal/guess-the-number-with-feedback--player-.pascal diff --git a/Task/Guess-the-number-With-feedback-player/Perl-6/guess-the-number-with-feedback-player.pl6 b/Task/Guess-the-number-With-feedback--player-/Perl-6/guess-the-number-with-feedback--player-.pl6 similarity index 100% rename from Task/Guess-the-number-With-feedback-player/Perl-6/guess-the-number-with-feedback-player.pl6 rename to Task/Guess-the-number-With-feedback--player-/Perl-6/guess-the-number-with-feedback--player-.pl6 diff --git a/Task/Guess-the-number-With-feedback-player/Perl/guess-the-number-with-feedback-player.pl b/Task/Guess-the-number-With-feedback--player-/Perl/guess-the-number-with-feedback--player-.pl similarity index 100% rename from Task/Guess-the-number-With-feedback-player/Perl/guess-the-number-with-feedback-player.pl rename to Task/Guess-the-number-With-feedback--player-/Perl/guess-the-number-with-feedback--player-.pl diff --git a/Task/Guess-the-number-With-feedback-player/PicoLisp/guess-the-number-with-feedback-player.l b/Task/Guess-the-number-With-feedback--player-/PicoLisp/guess-the-number-with-feedback--player-.l similarity index 100% rename from Task/Guess-the-number-With-feedback-player/PicoLisp/guess-the-number-with-feedback-player.l rename to Task/Guess-the-number-With-feedback--player-/PicoLisp/guess-the-number-with-feedback--player-.l diff --git a/Task/Guess-the-number-With-feedback-player/PureBasic/guess-the-number-with-feedback-player.purebasic b/Task/Guess-the-number-With-feedback--player-/PureBasic/guess-the-number-with-feedback--player-.purebasic similarity index 100% rename from Task/Guess-the-number-With-feedback-player/PureBasic/guess-the-number-with-feedback-player.purebasic rename to Task/Guess-the-number-With-feedback--player-/PureBasic/guess-the-number-with-feedback--player-.purebasic diff --git a/Task/Guess-the-number-With-feedback-player/Python/guess-the-number-with-feedback-player-1.py b/Task/Guess-the-number-With-feedback--player-/Python/guess-the-number-with-feedback--player--1.py similarity index 100% rename from Task/Guess-the-number-With-feedback-player/Python/guess-the-number-with-feedback-player-1.py rename to Task/Guess-the-number-With-feedback--player-/Python/guess-the-number-with-feedback--player--1.py diff --git a/Task/Guess-the-number-With-feedback-player/Python/guess-the-number-with-feedback-player-2.py b/Task/Guess-the-number-With-feedback--player-/Python/guess-the-number-with-feedback--player--2.py similarity index 100% rename from Task/Guess-the-number-With-feedback-player/Python/guess-the-number-with-feedback-player-2.py rename to Task/Guess-the-number-With-feedback--player-/Python/guess-the-number-with-feedback--player--2.py diff --git a/Task/Guess-the-number-With-feedback-player/REXX/guess-the-number-with-feedback-player-1.rexx b/Task/Guess-the-number-With-feedback--player-/REXX/guess-the-number-with-feedback--player--1.rexx similarity index 100% rename from Task/Guess-the-number-With-feedback-player/REXX/guess-the-number-with-feedback-player-1.rexx rename to Task/Guess-the-number-With-feedback--player-/REXX/guess-the-number-with-feedback--player--1.rexx diff --git a/Task/Guess-the-number-With-feedback-player/REXX/guess-the-number-with-feedback-player-2.rexx b/Task/Guess-the-number-With-feedback--player-/REXX/guess-the-number-with-feedback--player--2.rexx similarity index 100% rename from Task/Guess-the-number-With-feedback-player/REXX/guess-the-number-with-feedback-player-2.rexx rename to Task/Guess-the-number-With-feedback--player-/REXX/guess-the-number-with-feedback--player--2.rexx diff --git a/Task/Guess-the-number-With-feedback-player/Ruby/guess-the-number-with-feedback-player.rb b/Task/Guess-the-number-With-feedback--player-/Ruby/guess-the-number-with-feedback--player-.rb similarity index 100% rename from Task/Guess-the-number-With-feedback-player/Ruby/guess-the-number-with-feedback-player.rb rename to Task/Guess-the-number-With-feedback--player-/Ruby/guess-the-number-with-feedback--player-.rb diff --git a/Task/Guess-the-number-With-feedback-player/Scheme/guess-the-number-with-feedback-player.ss b/Task/Guess-the-number-With-feedback--player-/Scheme/guess-the-number-with-feedback--player-.ss similarity index 100% rename from Task/Guess-the-number-With-feedback-player/Scheme/guess-the-number-with-feedback-player.ss rename to Task/Guess-the-number-With-feedback--player-/Scheme/guess-the-number-with-feedback--player-.ss diff --git a/Task/Guess-the-number-With-feedback-player/Smalltalk/guess-the-number-with-feedback-player-1.st b/Task/Guess-the-number-With-feedback--player-/Smalltalk/guess-the-number-with-feedback--player--1.st similarity index 100% rename from Task/Guess-the-number-With-feedback-player/Smalltalk/guess-the-number-with-feedback-player-1.st rename to Task/Guess-the-number-With-feedback--player-/Smalltalk/guess-the-number-with-feedback--player--1.st diff --git a/Task/Guess-the-number-With-feedback-player/Smalltalk/guess-the-number-with-feedback-player-2.st b/Task/Guess-the-number-With-feedback--player-/Smalltalk/guess-the-number-with-feedback--player--2.st similarity index 100% rename from Task/Guess-the-number-With-feedback-player/Smalltalk/guess-the-number-with-feedback-player-2.st rename to Task/Guess-the-number-With-feedback--player-/Smalltalk/guess-the-number-with-feedback--player--2.st diff --git a/Task/Guess-the-number-With-feedback-player/Smalltalk/guess-the-number-with-feedback-player-3.st b/Task/Guess-the-number-With-feedback--player-/Smalltalk/guess-the-number-with-feedback--player--3.st similarity index 100% rename from Task/Guess-the-number-With-feedback-player/Smalltalk/guess-the-number-with-feedback-player-3.st rename to Task/Guess-the-number-With-feedback--player-/Smalltalk/guess-the-number-with-feedback--player--3.st diff --git a/Task/Guess-the-number-With-feedback-player/Smalltalk/guess-the-number-with-feedback-player-4.st b/Task/Guess-the-number-With-feedback--player-/Smalltalk/guess-the-number-with-feedback--player--4.st similarity index 100% rename from Task/Guess-the-number-With-feedback-player/Smalltalk/guess-the-number-with-feedback-player-4.st rename to Task/Guess-the-number-With-feedback--player-/Smalltalk/guess-the-number-with-feedback--player--4.st diff --git a/Task/Guess-the-number-With-feedback-player/Tcl/guess-the-number-with-feedback-player.tcl b/Task/Guess-the-number-With-feedback--player-/Tcl/guess-the-number-with-feedback--player-.tcl similarity index 100% rename from Task/Guess-the-number-With-feedback-player/Tcl/guess-the-number-with-feedback-player.tcl rename to Task/Guess-the-number-With-feedback--player-/Tcl/guess-the-number-with-feedback--player-.tcl diff --git a/Task/Guess-the-number-With-feedback-player/XPL0/guess-the-number-with-feedback-player.xpl0 b/Task/Guess-the-number-With-feedback--player-/XPL0/guess-the-number-with-feedback--player-.xpl0 similarity index 100% rename from Task/Guess-the-number-With-feedback-player/XPL0/guess-the-number-with-feedback-player.xpl0 rename to Task/Guess-the-number-With-feedback--player-/XPL0/guess-the-number-with-feedback--player-.xpl0 diff --git a/Task/Largest-int-from-concatenated-ints/Ruby/largest-int-from-concatenated-ints-2.rb b/Task/Largest-int-from-concatenated-ints/Ruby/largest-int-from-concatenated-ints-2.rb index 87cb466228..561f5e344c 100644 --- a/Task/Largest-int-from-concatenated-ints/Ruby/largest-int-from-concatenated-ints-2.rb +++ b/Task/Largest-int-from-concatenated-ints/Ruby/largest-int-from-concatenated-ints-2.rb @@ -1,6 +1,6 @@ def icsort nums maxlen = nums.max.to_s.length - nums.map{ |x| x.to_s }.sort_by { |x| x * (maxlen / x.length + 1) }.reverse + nums.map{ |x| x.to_s }.sort_by { |x| x * (maxlen * 2 / x.length) }.reverse end [[54, 546, 548, 60], [1, 34, 3, 98, 9, 76, 45, 4]].each do |c| diff --git a/Task/Loops-Infinite/6800-Assembly/loops-infinite.6800 b/Task/Loops-Infinite/6800-Assembly/loops-infinite.6800 new file mode 100644 index 0000000000..93920b7c87 --- /dev/null +++ b/Task/Loops-Infinite/6800-Assembly/loops-infinite.6800 @@ -0,0 +1,31 @@ + .cr 6800 + .tf spam6800.obj,AP1 + .lf spam6800 +;=====================================================; +; Infinite SPAM loop for the Motorola 6800 ; +; by barrym 2013-04-10 ; +;-----------------------------------------------------; +; Prints the message "SPAM" repeatedly to an ascii ; +; terminal (console) connected to a 1970s vintage ; +; SWTPC 6800 system, which is the target device for ; +; this assembly. ; +; Many thanks to: ; +; swtpc.com for hosting Michael Holley's documents! ; +; sbprojects.com for a very nice assembler! ; +; swtpcemu.com for a very capable emulator! ; +; reg x is the string pointer ; +; reg a holds the ascii char to be output ; +;-----------------------------------------------------; +outeee = $e1d1 ROM: console putchar routine + .or $0f00 +;-----------------------------------------------------; +main ldx #string Point to the string + bra puts and print it +outs jsr outeee Emit a as ascii + inx Advance the string pointer +puts ldaa ,x Load a string character + bne outs Print it if non-null + bra main else restart +;=====================================================; +string .as "SPAM",#13,#10,#0 + .en diff --git a/Task/N-queens-problem/0DESCRIPTION b/Task/N-queens-problem/0DESCRIPTION new file mode 100644 index 0000000000..357eab34d2 --- /dev/null +++ b/Task/N-queens-problem/0DESCRIPTION @@ -0,0 +1,4 @@ +Solve the [[WP:Eight_queens_puzzle|eight queens puzzle]]. You can extend the problem to solve the puzzle with a board of side NxN. + +;Cf. +* [[Knight's tour]] diff --git a/Task/N-queens-problem/ALGOL-68/n-queens-problem.alg b/Task/N-queens-problem/ALGOL-68/n-queens-problem.alg new file mode 100644 index 0000000000..4b35b32487 --- /dev/null +++ b/Task/N-queens-problem/ALGOL-68/n-queens-problem.alg @@ -0,0 +1,51 @@ +INT ofs = 1, # Algol68 normally uses array offset of 1 # + dim = 8; # dim X dim chess board # +[ofs:dim+ofs-1]INT b; + +PROC unsafe = (INT y)BOOL:( + INT i, t, x; + x := b[y]; + FOR i TO y - LWB b DO + t := b[y - i]; + IF t = x THEN break true + ELIF t = x - i THEN break true + ELIF t = x + i THEN break true + FI + OD; + FALSE EXIT +break true: + TRUE +); + +INT s := 0; + +PROC print board = VOID:( + INT x, y; + print((new line, "Solution # ", s+:=1, new line)); + FOR y FROM LWB b TO UPB b DO + FOR x FROM LWB b TO UPB b DO + print("|"+(b[y]=x|"Q"|: ODD(x+y)|"/"|" ")) + OD; + print(("|", new line)) + OD +); + +main: ( + INT y := LWB b; + b[LWB b] := LWB b - 1; + FOR i WHILE y >= LWB b DO + WHILE + b[y]+:=1; + # BREAK # IF b[y] <= UPB b THEN unsafe(y) ELSE FALSE FI + DO SKIP OD; + IF b[y] <= UPB b THEN + IF y < UPB b THEN + b[y+:=1] := LWB b - 1 + ELSE + print board + FI + ELSE + y-:=1 + FI + OD +) diff --git a/Task/N-queens-problem/Ada/n-queens-problem.ada b/Task/N-queens-problem/Ada/n-queens-problem.ada new file mode 100644 index 0000000000..565d6b200f --- /dev/null +++ b/Task/N-queens-problem/Ada/n-queens-problem.ada @@ -0,0 +1,50 @@ +with Ada.Text_IO; use Ada.Text_IO; + +procedure Queens is + Board : array (1..8, 1..8) of Boolean := (others => (others => False)); + function Test (Row, Column : Integer) return Boolean is + begin + for J in 1..Column - 1 loop + if ( Board (Row, J) + or else + (Row > J and then Board (Row - J, Column - J)) + or else + (Row + J <= 8 and then Board (Row + J, Column - J)) + ) then + return False; + end if; + end loop; + return True; + end Test; + function Fill (Column : Integer) return Boolean is + begin + for Row in Board'Range (1) loop + if Test (Row, Column) then + Board (Row, Column) := True; + if Column = 8 or else Fill (Column + 1) then + return True; + end if; + Board (Row, Column) := False; + end if; + end loop; + return False; + end Fill; +begin + if not Fill (1) then + raise Program_Error; + end if; + for I in Board'Range (1) loop + Put (Integer'Image (9 - I)); + for J in Board'Range (2) loop + if Board (I, J) then + Put ("|Q"); + elsif (I + J) mod 2 = 1 then + Put ("|/"); + else + Put ("| "); + end if; + end loop; + Put_Line ("|"); + end loop; + Put_Line (" A B C D E F G H"); +end Queens; diff --git a/Task/N-queens-problem/AutoHotkey/n-queens-problem-1.ahk b/Task/N-queens-problem/AutoHotkey/n-queens-problem-1.ahk new file mode 100644 index 0000000000..16a102e98f --- /dev/null +++ b/Task/N-queens-problem/AutoHotkey/n-queens-problem-1.ahk @@ -0,0 +1,80 @@ +; +; Post: http://www.autohotkey.com/forum/viewtopic.php?p=353059#353059 +; Timestamp: 05/may/2010 +; + +MsgBox % funcNQP(5) +MsgBox % funcNQP(8) + +Return + +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +; +; ** USED VARIABLES ** +; +; Global: All variables named Array[???] +; +; Function funcNPQ: nQueens , OutText , qIndex +; +; Function Unsafe: nIndex , Idx , Tmp , Aux +; +; Function PutBoard: Output , QueensN , Stc , xxx , yyy +; +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +funcNQP(nQueens) +{ + Global + Array[0] := -1 + Local OutText , qIndex := 0 + While ( qIndex >= 0 ) + { + Array[%qIndex%]++ + While ( (Array[%qIndex%] < nQueens) && Unsafe(qIndex) ) + Array[%qIndex%]++ + If ( Array[%qIndex%] < nQueens ) + { + If ( qIndex < nQueens-1 ) + qIndex++ , Array[%qIndex%] := -1 + Else + PutBoard(OutText,nQueens) + } + Else + qIndex-- + } + Return OutText +} + +;------------------------------------------ + +Unsafe(nIndex) +{ + Global + Local Idx := 1 , Tmp := 0 , Aux := Array[%nIndex%] + While ( Idx <= nIndex ) + { + Tmp := "Array[" nIndex - Idx "]" + Tmp := % %Tmp% + If ( ( Tmp = Aux ) || ( Tmp = Aux-Idx ) || ( Tmp = Aux+Idx ) ) + Return 1 + Idx++ + } + Return 0 +} + +;------------------------------------------ + +PutBoard(ByRef Output,QueensN) +{ + Global + Static Stc = 0 + Local xxx := 0 , yyy := 0 + Output .= "`n`nSolution #" (++Stc) "`n" + While ( yyy < QueensN ) + { + xxx := 0 + While ( xxx < QueensN ) + Output .= ( "|" ( ( Array[%yyy%] = xxx ) ? "Q" : "_" ) ) , xxx++ + Output .= "|`n" , yyy++ + } +} diff --git a/Task/N-queens-problem/AutoHotkey/n-queens-problem-2.ahk b/Task/N-queens-problem/AutoHotkey/n-queens-problem-2.ahk new file mode 100644 index 0000000000..9ffe2f64ac --- /dev/null +++ b/Task/N-queens-problem/AutoHotkey/n-queens-problem-2.ahk @@ -0,0 +1,90 @@ +N := 5 +Number: ; main entrance for different # of queens + SI := 1 + Progress b2 w250 zh0 fs9, Calculating all solutions for %N% Queens ... + Gosub GuiCreate + Result := SubStr(Queens(N),2) + Progress Off + Gui Show,,%N%-Queens + StringSplit o, Result, `n +Fill: ; show solutions + GuiControl,,SI, %SI% / %o0% + Loop Parse, o%SI%, `, + { + C := A_Index + Loop %N% + GuiControl,,%C%_%A_Index% ; clear fields + GuiControl,,%C%_%A_LoopField%, r + } +Return ;----------------------------------------------------------------------- + +Queens(N) { ; Size of the board + Local c, O ; global array r + r1 := 1, c := 2, r2 := 3, O := "" ; init: r%c% = row of Queen in column c + + Right: ; move to next column + If (c = N) { ; found solution + Loop %N% ; save row indices of Queens + O .= (A_Index = 1 ? "`n" : ",") r%A_Index% + GOTO % --c ? "Down" : "OUT" ; for ALL solutions + } + c++, r%c% := 1 ; next column, top row + GoTo % BAD(c) ? "Down" : "Right" + Down: ; move down to next row + If (r%c% = N) + GoTo % --c ? "Down" : "OUT" + r%c%++ ; row down + GoTo % BAD(c) ? "Down" : "Right" + OUT: + Return O +} ;---------------------------------------------------------------------------- + +BAD(c) { ; Check placed Queens against Queen in row r%c%, column c + Loop % c-1 + If (r%A_Index% = r%c% || ABS(r%A_Index%-r%c%) = c-A_Index) + Return 1 +} ;---------------------------------------------------------------------------- + +GuiCreate: ; Draw chess board + Gui Margin, 20, 15 + Gui Font, s16, Marlett + Loop %N% { + C := A_Index + Loop %N% { ; fields + R := A_Index, X := 40*C-17, Y := 40*R-22 + Gui Add, Progress, x%X% y%Y% w41 h41 Cdddddd, % 100*(R+C & 1) ;% shade fields + Gui Add, Text, x%X% y%Y% w41 h41 BackGroundTrans Border Center 0x200 v%C%_%R% + } + } + Gui Add, Button, x%x% w43 h25 gBF, 4 ; forth (default) + Gui Add, Button,xm yp w43 h25 gBF, 3 ; back + + Gui Font, bold, Comic Sans MS + Gui Add, Text,% "x62 yp hp Center 0x200 vSI w" 40*N-80 + + Menu FileMenu, Add, E&xit, GuiClose + Loop 9 + Menu CalcMenu, Add, % "Calculate " A_Index+3 " Queens", Calculate ;% + Menu HelpMenu, Add, &About, AboutBox + Menu MainMenu, Add, &File, :FileMenu + Menu MainMenu, Add, &Calculate, :CalcMenu + Menu MainMenu, Add, &Help, :HelpMenu + Gui Menu, Mainmenu +Return ; ---------------------------------------------------------------------- + +AboutBox: ; message box with AboutText + Gui 1: +OwnDialogs + MsgBox, 64, About N-Queens, Many thanks ... +Return + +Calculate: ; menu handler for calculations + N := A_ThisMenuItemPos + 3 + Gui Destroy + GoTo Number ; ------------------------------------------------------------- + +BF: + SI := mod(SI+o0-2*(A_GuiControl=3), o0) + 1 ; left button text is "3" + GoTo Fill ; ---------------------------------------------------------------- + +GuiClose: +ExitApp diff --git a/Task/N-queens-problem/BBC-BASIC/n-queens-problem.bbc b/Task/N-queens-problem/BBC-BASIC/n-queens-problem.bbc new file mode 100644 index 0000000000..8e46b43e7d --- /dev/null +++ b/Task/N-queens-problem/BBC-BASIC/n-queens-problem.bbc @@ -0,0 +1,61 @@ + Size% = 8 + Cell% = 32 + VDU 23,22,Size%*Cell%;Size%*Cell%;Cell%,Cell%,16,128+8,5 + *font Arial Unicode MS,16 + GCOL 3,11 + FOR i% = 0 TO Size%-1 STEP 2 + RECTANGLE FILL i%*Cell%*2,0,Cell%*2,Size%*Cell%*2 + RECTANGLE FILL 0,i%*Cell%*2,Size%*Cell%*2,Cell%*2 + NEXT + num% = FNqueens(Size%, Cell%) + SYS "SetWindowText", @hwnd%, "Total " + STR$(num%) + " solutions" + REPEAT : WAIT 1 : UNTIL FALSE + END + + DEF FNqueens(n%, s%) + LOCAL i%, j%, m%, p%, q%, r%, a%(), b%(), c%() + DIM a%(n%), b%(n%), c%(4*n%-2) + FOR i% = 1 TO DIM(a%(),1) : a%(i%) = i% : NEXT + m% = 0 + i% = 1 + j% = 0 + r% = 2*n%-1 + REPEAT + i% -= 1 + j% += 1 + p% = 0 + q% = -r% + REPEAT + i% += 1 + c%(p%) = 1 + c%(q%+r%) = 1 + SWAP a%(i%),a%(j%) + p% = i% - a%(i%) + n% + q% = i% + a%(i%) - 1 + b%(i%) = j% + j% = i% + 1 + UNTIL j% > n% OR c%(p%) OR c%(q%+r%) + IF c%(p%)=0 IF c%(q%+r%)=0 THEN + IF m% = 0 THEN + FOR p% = 1 TO n% + MOVE 2*s%*(a%(p%)-1)+6, 2*s%*p%+6 + PRINT "♛"; + NEXT + ENDIF + m% += 1 + ENDIF + j% = b%(i%) + WHILE j% >= n% AND i% <> 0 + REPEAT + SWAP a%(i%), a%(j%) + j% = j%-1 + UNTIL j% < i% + i% -= 1 + p% = i% - a%(i%) + n% + q% = i% + a%(i%) - 1 + j% = b%(i%) + c%(p%) = 0 + c%(q%+r%) = 0 + ENDWHILE + UNTIL i% = 0 + = m% diff --git a/Task/N-queens-problem/BCPL/n-queens-problem-1.bcpl b/Task/N-queens-problem/BCPL/n-queens-problem-1.bcpl new file mode 100644 index 0000000000..ae1f553707 --- /dev/null +++ b/Task/N-queens-problem/BCPL/n-queens-problem-1.bcpl @@ -0,0 +1,30 @@ +// This can be run using Cintcode BCPL freely available from www.cl.cam.ac.uk/users/mr10. + +GET "libhdr.h" + +GLOBAL { count:ug; all } + +LET try(ld, row, rd) BE TEST row=all + + THEN count := count + 1 + + ELSE { LET poss = all & ~(ld | row | rd) + WHILE poss DO + { LET p = poss & -poss + poss := poss - p + try(ld+p << 1, row+p, rd+p >> 1) + } + } + +LET start() = VALOF +{ all := 1 + + FOR i = 1 TO 16 DO + { count := 0 + try(0, 0, 0) + writef("Number of solutions to %i2-queens is %i7*n", i, count) + all := 2*all + 1 + } + + RESULTIS 0 +} diff --git a/Task/N-queens-problem/BCPL/n-queens-problem-2.bcpl b/Task/N-queens-problem/BCPL/n-queens-problem-2.bcpl new file mode 100644 index 0000000000..2d7dc6fc42 --- /dev/null +++ b/Task/N-queens-problem/BCPL/n-queens-problem-2.bcpl @@ -0,0 +1,134 @@ +GET "libhdr.h" +GET "mc.h" + +MANIFEST { + lo=1; hi=16 + dlevel=#b0000 + + // Register mnemonics + ld = mc_a + row = mc_b + rd = mc_c + poss = mc_d + p = mc_e + count = mc_f +} + +LET start() = VALOF +{ // Load the dynamic code generation package + LET mcseg = globin(loadseg("mci386")) + LET mcb = 0 + + UNLESS mcseg DO + { writef("Trouble with MC package: mci386*n") + GOTO fin + } + + // Create an MC instance for hi functions with a data space + // of 10 words and code space of 40000 + mcb := mcInit(hi, 10, 40000) + + UNLESS mcb DO + { writef("Unable to create an mci386 instance*n") + GOTO fin + } + + mc := 0 // Currently no selected MC instance + mcSelect(mcb) + + mcK(mc_debug, dlevel) // Set the debugging level + + FOR n = lo TO hi DO + { mcComment("*n*n// Code for a %nx%n board*n", n, n) + gencode(n) // Compile the code for an nxn board + } + + mcF(mc_end) // End of code generation + + writef("Code generation complete*n") + + FOR n = lo TO hi DO + { LET k = mcCall(n) + writef("Number of solutions to %i2-queens is %i9*n", n, k) + } + +fin: + IF mc DO mcClose() + IF mcseg DO unloadseg(mcseg) + + writef("*n*nEnd of run*n") +} + +AND gencode(n) BE +{ LET all = (1<>1) + mcRR(mc_add, ld, p) + mcRK(mc_lsh, ld, 1) // ld := (ld+p)<<1 + mcRR(mc_add, row, p) // row := row+p + mcRR(mc_add, rd, p) + mcRK(mc_rsh, rd, 1) // rd := (rd+p)>>1 + + cmpltry(i+1, n, all) // Compile code for row i+1 + + mcR (mc_pop, poss) // Restore the state + mcR (mc_pop, rd) + mcR (mc_pop, row) + mcR (mc_pop, ld) + + mcRK(mc_cmp, poss, 0) + mcJL(mc_jne, M) // } REPEATWHILE poss + } + + mcL(mc_lab, L) + mcComment("// End of code from try(%n, %n, %n)*n*n", + i, n, all) +} diff --git a/Task/N-queens-problem/C/n-queens-problem-1.c b/Task/N-queens-problem/C/n-queens-problem-1.c new file mode 100644 index 0000000000..2dc59e4e1f --- /dev/null +++ b/Task/N-queens-problem/C/n-queens-problem-1.c @@ -0,0 +1,31 @@ +#include +#include + +int count = 0; +void solve(int n, int col, int *hist) +{ + if (col == n) { + printf("\nNo. %d\n-----\n", ++count); + for (int i = 0; i < n; i++, putchar('\n')) + for (int j = 0; j < n; j++) + putchar(j == hist[i] ? 'Q' : ((i + j) & 1) ? ' ' : '.'); + + return; + } + +# define attack(i, j) (hist[j] == i || abs(hist[j] - i) == col - j) + for (int i = 0, j = 0; i < n; i++) { + for (j = 0; j < col && !attack(i, j); j++); + if (j < col) continue; + + hist[col] = i; + solve(n, col + 1, hist); + } +} + +int main(int n, char **argv) +{ + if (n <= 1 || (n = atoi(argv[1])) <= 0) n = 8; + int hist[n]; + solve(n, 0, hist); +} diff --git a/Task/N-queens-problem/C/n-queens-problem-2.c b/Task/N-queens-problem/C/n-queens-problem-2.c new file mode 100644 index 0000000000..dcc46bb728 --- /dev/null +++ b/Task/N-queens-problem/C/n-queens-problem-2.c @@ -0,0 +1,38 @@ +#include +#include +#include + +typedef uint32_t uint; +uint full, *qs, count = 0, nn; + +void solve(uint d, uint c, uint l, uint r) +{ + uint b, a, *s; + if (!d) { + count++; +#if 0 + printf("\nNo. %d\n===========\n", count); + for (a = 0; a < nn; a++, putchar('\n')) + for (b = 0; b < nn; b++, putchar(' ')) + putchar(" -QQ"[((b == qs[a])<<1)|((a + b)&1)]); +#endif + return; + } + + a = (c | (l <<= 1) | (r >>= 1)) & full; + if (a != full) + for (*(s = qs + --d) = 0, b = 1; b <= full; (*s)++, b <<= 1) + if (!(b & a)) solve(d, b|c, b|l, b|r); +} + +int main(int n, char **argv) +{ + if (n <= 1 || (nn = atoi(argv[1])) <= 0) nn = 8; + + qs = calloc(nn, sizeof(int)); + full = (1U << nn) - 1; + + solve(nn, 0, 0, 0); + printf("\nSolutions: %d\n", count); + return 0; +} diff --git a/Task/N-queens-problem/C/n-queens-problem-3.c b/Task/N-queens-problem/C/n-queens-problem-3.c new file mode 100644 index 0000000000..3316ea1a70 --- /dev/null +++ b/Task/N-queens-problem/C/n-queens-problem-3.c @@ -0,0 +1,91 @@ +#include +#include + +typedef unsigned int uint; +uint count = 0; + +#define ulen sizeof(uint) * 8 + +/* could have defined as int solve(...), but void may have less + chance to confuse poor optimizer */ +void solve(int n) +{ + int cnt = 0; + const uint full = -(int)(1 << (ulen - n)); + register uint bits, pos, *m, d, e; + + uint b0, b1, l[32], r[32], c[32], mm[33] = {0}; + n -= 3; + /* require second queen to be left of the first queen, so + we ever only test half of the possible solutions. This + is why we can't handle n=1 here */ + for (b0 = 1U << (ulen - n - 3); b0; b0 <<= 1) { + for (b1 = b0 << 2; b1; b1 <<= 1) { + d = n; + /* c: columns occupied by previous queens. + l: columns attacked by left diagonals + r: by right diagnoals */ + c[n] = b0 | b1; + l[n] = (b0 << 2) | (b1 << 1); + r[n] = (b0 >> 2) | (b1 >> 1); + + /* availabe columns on current row. m is stack */ + bits = *(m = mm + 1) = full & ~(l[n] | r[n] | c[n]); + + while (bits) { + /* d: depth, aka row. counting backwards + because !d is often faster than d != n */ + while (d) { + /* pos is right most nonzero bit */ + pos = -(int)bits & bits; + + /* mark bit used. only put current bits + on stack if not zero, so backtracking + will skip exhausted rows (because reading + stack variable is sloooow compared to + registers) */ + if ((bits &= ~pos)) + *m++ = bits | d; + + /* faster than l[d+1] = l[d]... */ + e = d--; + l[d] = (l[e] | pos) << 1; + r[d] = (r[e] | pos) >> 1; + c[d] = c[e] | pos; + + bits = full & ~(l[d] | r[d] | c[d]); + + if (!bits) break; + if (!d) { cnt++; break; } + } + /* Bottom of stack m is a zero'd field acting + as sentinel. When saving to stack, left + 27 bits are the available columns, while + right 5 bits is the depth. Hence solution + is limited to size 27 board -- not that it + matters in foreseeable future. */ + d = (bits = *--m) & 31U; + bits &= ~31U; + } + } + } + count = cnt * 2; +} + +int main(int c, char **v) +{ + int nn; + if (c <= 1 || (nn = atoi(v[1])) <= 0) nn = 8; + + if (nn > 27) { + fprintf(stderr, "Value too large, abort\n"); + exit(1); + } + + /* Can't solve size 1 board; might as well skip 2 and 3 */ + if (nn < 4) count = nn == 1; + else solve(nn); + + printf("\nSolutions: %d\n", count); + return 0; +} diff --git a/Task/N-queens-problem/Clojure/n-queens-problem.clj b/Task/N-queens-problem/Clojure/n-queens-problem.clj new file mode 100644 index 0000000000..bbf749c4b0 --- /dev/null +++ b/Task/N-queens-problem/Clojure/n-queens-problem.clj @@ -0,0 +1,23 @@ +(def size 8) + +(defn extends? [v n] + (let [k (count v)] + (not-any? true? + (for [i (range k) :let [vi (v i)]] + (or + (= vi n) ;check for shared row + (= (- k i) (Math/abs (- n vi)))))))) ;check for shared diagonal + +(defn extend [vs] + (for [v vs + n (range 1 (inc size)) :when (extends? v n)] + (conj v n))) + + +(def solutions + (nth (iterate extend [[]]) size)) + +(doseq [s solutions] + (println s)) + +(println (count solutions) "solutions") diff --git a/Task/N-queens-problem/CoffeeScript/n-queens-problem.coffeescript b/Task/N-queens-problem/CoffeeScript/n-queens-problem.coffeescript new file mode 100644 index 0000000000..a090bbe113 --- /dev/null +++ b/Task/N-queens-problem/CoffeeScript/n-queens-problem.coffeescript @@ -0,0 +1,111 @@ +# Unlike traditional N-Queens solutions that use recursion, this +# program attempts to more closely model the "human" algorithm. +# +# In this algorithm, the function keeps placing queens on the board +# until there is no longer a safe square. If the 8th queen has been +# placed, the solution is noted. If fewer than 8th queens have been +# placed, then you are at a dead end. In either case, backtracking occurs. +# The LAST queen placed on the board gets pulled, then it gets moved +# to the next safe square. (We backtrack even after a "good" attempt in +# order to get to a new solution.) This backtracking may repeat itself +# several times until the original misplaced queen finally is proven to +# be a dead end. +# +# Many N-Queens solutions use lazy logic (along with geometry shortcuts) +# to determine whether a queen is under attack. In this algorithm, we +# are more proactive, essentially updating a sieve every time we lay a +# queen down. To make backtracking easier, the sieve uses ref-counts vs. +# a simple safe/unsafe boolean. +# +# We precompute the "attack graph" up front, and then we essentially ignore +# the geometry of the problem. This approach, while perhaps suboptimal for +# queens, probably is more flexible for general "coexistence" problems. +nqueens = (n) -> + neighbors = precompute_neighbors(n) + + board = [] + num_solutions = 0 + num_backtracks = 0 + queens = [] + pos = 0 + + for p in [0...n*n] + board.push 0 + + attack = (pos, delta=1) -> + for neighbor in neighbors[pos] + board[neighbor] += delta + + backtrack = -> + pos = queens.pop() + attack pos, -1 # unattack queen you just pulled + pos += 1 + num_backtracks += 1 + + # The following loop finds all 92 solutions to + # the 8-queens problem (for n=8). + while true + if pos >= n*n + if queens.length == 0 + break + backtrack() + continue + + # If a square is empty + if board[pos] == 0 + attack pos + queens.push pos + if queens.length == n + num_solutions += 1 + show_queens queens, n + backtrack() + pos += 1 + + console.log "#{num_solutions} solutions" + console.log "#{num_backtracks} backtracks" + + +precompute_neighbors = (n) -> + # For each board position, build a list of all + # the board positions that would be under attack if + # you placed a queen on it. This assumes a 1d array + # of squares. + neighbors = [] + + find_neighbors = (pos) -> + arr = [] + row = Math.floor pos / n + col = pos % n + for i in [0...n] + if i != col + arr.push row*n + i + r1 = row + col - i + r2 = row + i - col + if 0 <= r1 and r1 < n + arr.push r1*n + i + if 0 <= r2 and r2 < n + arr.push r2*n + i + if i != row + arr.push i*n + col + arr + + for pos in [0...n*n] + neighbors.push find_neighbors(pos) + neighbors + + +show_queens = (queens, n) -> + # precondition: queens is a sorted array of integers, + # and each row is represented + console.log "\n------" + for q in queens + col = q % n + s = '' + for c in [0...n] + if c == col + s += "Q " + else + s += "* " + console.log s + "\n" + +nqueens(8) diff --git a/Task/N-queens-problem/Common-Lisp/n-queens-problem.lisp b/Task/N-queens-problem/Common-Lisp/n-queens-problem.lisp new file mode 100644 index 0000000000..b84ee246e3 --- /dev/null +++ b/Task/N-queens-problem/Common-Lisp/n-queens-problem.lisp @@ -0,0 +1,22 @@ +(defun n-queens (n m) + (if (= n 1) + (loop for x from 1 to m collect (list x)) + (loop for sol in (n-queens (1- n) m) nconc + (loop for col from 1 to m when + (loop for row from 0 to (length sol) for c in sol + always (and (/= col c) + (/= (abs (- c col)) (1+ row))) + finally (return (cons col sol))) + collect it)))) + +(defun show-solution (b n) + (loop for i in b do + (format t "~{~A~^~}~%" + (loop for x from 1 to n collect (if (= x i) "Q " ". ")))) + (terpri)) + +(let ((i 0) (n 8)) + (mapc #'(lambda (s) + (format t "Solution ~a:~%" (incf i)) + (show-solution s n)) + (n-queens n n))) diff --git a/Task/N-queens-problem/Curry/n-queens-problem-1.curry b/Task/N-queens-problem/Curry/n-queens-problem-1.curry new file mode 100644 index 0000000000..cf3b69e538 --- /dev/null +++ b/Task/N-queens-problem/Curry/n-queens-problem-1.curry @@ -0,0 +1,58 @@ +-- 8-queens implementation with the Constrained Constructor pattern +-- Sergio Antoy +-- Fri Jul 13 07:05:32 PDT 2001 + +-- Place 8 queens on a chessboard so that no queen can capture +-- (and be captured by) any other queen. + +-- Non-deterministic choice operator + +infixl 0 ! +X ! _ = X +_ ! Y = Y + +-- A solution is represented by a list of integers. +-- The i-th integer in the list is the column of the board +-- in which the queen in the i-th row is placed. +-- Rows and columns are numbered from 1 to 8. +-- For example, [4,2,7,3,6,8,5,1] is a solution where the +-- the queen in row 1 is in column 4, etc. +-- Any solution must be a permutation of [1,2,...,8]. + +-- The state of a queen is its position, row and column, on the board. +-- Operation column is a particularly simple instance +-- of a Constrained Constructor pattern. +-- When it is invoked, it produces only valid states. + +column = 1 ! 2 ! 3 ! 4 ! 5 ! 6 ! 7 ! 8 + +-- A path of the puzzle is a sequence of successive placements of +-- queens on the board. It is not explicitly defined as a type. +-- A path is a potential solution in the making. + +-- Constrained Constructor on a path +-- Any path must be valid, i.e., any column must be in the range 1..8 +-- and different from any other column in the path. +-- Furthermore, the path must be safe for the queens. +-- No queen in a path may capture any other queen in the path. +-- Operation makePath add column n to path c or fails. + +makePath c n | valid c && safe c 1 = n:c + where valid c | n =:= column = uniq c + where uniq [] = True + uniq (c:cs) = n /= c && uniq cs + safe [] _ = True + safe (c:cs) k = abs (n-c) /= k && safe cs (k+1) + where abs x = if x < 0 then -x else x + +-- extend the path argument till all the queens are on the board +-- see the Incremental Solution pattern + +extend p = if (length p == 8) + then p + else extend (makePath p x) + where x free + +-- solve the puzzle + +main = extend [] diff --git a/Task/N-queens-problem/Curry/n-queens-problem-2.curry b/Task/N-queens-problem/Curry/n-queens-problem-2.curry new file mode 100644 index 0000000000..61e2aa738a --- /dev/null +++ b/Task/N-queens-problem/Curry/n-queens-problem-2.curry @@ -0,0 +1,34 @@ +-- N-queens puzzle implemented with "Distinct Choices" pattern +-- Sergio Antoy +-- Tue Sep 4 13:16:20 PDT 2001 +-- updated: Mon Sep 23 15:22:15 PDT 2002 + +import Integer + +queens x | y =:= permute x & void (capture y) = y where y free + +capture y = let l1,l2,l3,y1,y2 free in + l1 ++ [y1] ++ l2 ++ [y2] ++ l3 =:= y & abs (y1-y2) =:= length l2 + 1 + +-- negation as failure (implemented by encapsulated search): +void c = (findall \_->c) =:= [] + +-- How does this permutation algorithm work? +-- Only the elements [0,1,...,n-1] can be permuted. +-- The reason is that each element is used as an index in a list. +-- A list, called store, of free variables of length n is created. +-- Then, the n iterations described below are executed. +-- At the i-th iteration, an element, say s, +-- of the initial list is non-deterministically selected. +-- This element is used as index in the store. +-- The s-th variable of the store is unified with i. +-- At the end of the iterations, the elements of the store +-- are a permutation of [0,1,...,n-1], i.e., the elements +-- are unique since two iterations cannot select the same index. + +permute n = result n + where result n = if n==0 then [] else pick n store : result (n-1) + pick i store | store !! k =:= i = k where k = range n + range n | n > 0 = range (n-1) ! (n-1) + store = free +-- end diff --git a/Task/N-queens-problem/Curry/n-queens-problem-3.curry b/Task/N-queens-problem/Curry/n-queens-problem-3.curry new file mode 100644 index 0000000000..a761f73925 --- /dev/null +++ b/Task/N-queens-problem/Curry/n-queens-problem-3.curry @@ -0,0 +1,59 @@ +-- 8-queens implementation with both the Constrained Constructor +-- and the Fused Generate and Test patterns. +-- Sergio Antoy +-- Fri Jul 13 07:05:32 PDT 2001 + +-- Place 8 queens on a chessboard so that no queen can capture +-- (and be captured by) any other queen. + +-- Non-deterministic choice operator + +infixl 0 ! +X ! _ = X +_ ! Y = Y + +-- A solution is represented by a list of integers. +-- The i-th integer in the list is the column of the board +-- in which the queen in the i-th row is placed. +-- Rows and columns are numbered from 1 to 8. +-- For example, [4,2,7,3,6,8,5,1] is a solution where the +-- the queen in row 1 is in column 4, etc. +-- Any solution must be a permutation of [1,2,...,8]. + +-- The state of a queen is its position, row and column, on the board. +-- Operation column is a particularly simple instance +-- of a Constrained Constructor pattern. +-- When it is invoked, it produces only valid states. + +column = 1 ! 2 ! 3 ! 4 ! 5 ! 6 ! 7 ! 8 + +-- A path of the puzzle is a sequence of successive placements of +-- queens on the board. It is not explicitly defined as a type. +-- A path is a potential solution in the making. + +-- Constrained Constructor on a path +-- Any path must be valid, i.e., any column must be in the range 1..8 +-- and different from any other column in the path. +-- Furthermore, the path must be safe for the queens. +-- No queen in a path may capture any other queen in the path. +-- Operation makePath add column n to path c or fails. + +makePath c n | valid c && safe c 1 = n:c + where valid c | n =:= column = uniq c + where uniq [] = True + uniq (c:cs) = n /= c && uniq cs + safe [] _ = True + safe (c:cs) k = abs (n-c) /= k && safe cs (k+1) + where abs x = if x < 0 then -x else x + +-- extend the path argument till all the queens are on the board +-- see the Incremental Solution pattern + +extend p = if (length p == 8) + then p + else extend (makePath p x) + where x free + +-- solve the puzzle + +main = extend [] diff --git a/Task/N-queens-problem/D/n-queens-problem-1.d b/Task/N-queens-problem/D/n-queens-problem-1.d new file mode 100644 index 0000000000..64113b9f40 --- /dev/null +++ b/Task/N-queens-problem/D/n-queens-problem-1.d @@ -0,0 +1,44 @@ +import std.stdio; + +enum int SIDE = 8; +int[SIDE] board; + +bool unsafe(in int y) nothrow { + immutable int x = board[y]; + foreach (i; 1 .. y + 1) { + int t = board[y - i]; + if ((t == x) || (t == x - i) || (t == x + i)) + return true; + } + + return false; +} + +void showBoard() { + static int s = 1; + writeln("\nSolution #", s++); + foreach (y; 0 .. SIDE) { + foreach (x; 0 .. SIDE) + write(board[y] == x ? '*' : '.'); + writeln(); + } +} + +void main() { + int y = 0; + board[0] = -1; + + while (y >= 0) { + do { + board[y]++; + } while (board[y] < SIDE && unsafe(y)); + + if (board[y] < SIDE) { + if (y < (SIDE - 1)) + board[++y] = -1; + else + showBoard(); + } else + y--; + } +} diff --git a/Task/N-queens-problem/D/n-queens-problem-2.d b/Task/N-queens-problem/D/n-queens-problem-2.d new file mode 100644 index 0000000000..d72fe3cca9 --- /dev/null +++ b/Task/N-queens-problem/D/n-queens-problem-2.d @@ -0,0 +1,90 @@ +import std.stdio, std.conv; + +uint nQueens(in uint nn) pure nothrow +in { + assert(nn > 0 && nn <= 27, + "'side' value must be in 1 .. 27."); +} body { + if (nn < 4) + return nn == 1; + + enum uint ulen = uint.sizeof * 8; + immutable uint full = uint.max - ((1 << (ulen - nn)) - 1); + immutable n = nn - 3; + + uint count; + uint[32] l=void, r=void, c=void; + uint[33] mm; // mm and mmi are a stack + + // Require second queen to be left of the first queen, so + // we ever only test half of the possible solutions. This + // is why we can't handle n=1 here. + for (uint b0 = 1U << (ulen - n - 3); b0; b0 <<= 1) { + for (uint b1 = b0 << 2; b1; b1 <<= 1) { + uint d = n; + // c: columns occupied by previous queens. + c[n] = b0 | b1; + // l: columns attacked by left diagonals + l[n] = (b0 << 2) | (b1 << 1); + // r: by right diagnoals + r[n] = (b0 >> 2) | (b1 >> 1); + + // availabe columns on current row + uint bits = full & ~(l[n] | r[n] | c[n]); + + uint mmi = 1; + mm[mmi] = bits; + + while (bits) { + // d: depth, aka row. counting backwards + // because !d is often faster than d != n + while (d) { + // pos is right most nonzero bit + immutable uint pos = -(cast(int)bits) & bits; + + // Mark bit used. Only put current bits on + // stack if not zero, so backtracking will + // skip exhausted rows (because reading stack + // variable is slow compared to registers). + bits &= ~pos; + if (bits) { + mm[mmi] = bits | d; + mmi++; + } + + d--; + l[d] = (l[d+1] | pos) << 1; + r[d] = (r[d+1] | pos) >> 1; + c[d] = c[d+1] | pos; + + bits = full & ~(l[d] | r[d] | c[d]); + + if (!bits) + break; + if (!d) { + count++; + break; + } + } + + // Bottom of stack m is a zero'd field acting as + // sentinel. When saving to stack, left 27 bits + // are the available columns, while right 5 bits + // is the depth. Hence solution is limited to size + // 27 board -- not that it matters in foreseeable + // future. + mmi--; + bits = mm[mmi]; + d = bits & 31U; + bits &= ~31U; + } + } + } + + return count * 2; +} + +void main(string[] args) { + immutable int side = (args.length >= 2) ? to!int(args[1]) : 8; + writefln("N-queens(%d) = %d solutions.", side, nQueens(side)); +} diff --git a/Task/N-queens-problem/Dart/n-queens-problem.dart b/Task/N-queens-problem/Dart/n-queens-problem.dart new file mode 100644 index 0000000000..55d5f5a512 --- /dev/null +++ b/Task/N-queens-problem/Dart/n-queens-problem.dart @@ -0,0 +1,65 @@ +/** +Return true if queen placement q[n] does not conflict with +other queens q[0] through q[n-1] +*/ +isConsistent(List q, int n) { + for (int i=0; i x + q iota [ + x swap + [ board nth ] keep + q swap - + [ + /= ] + [ - /= ] 3bi and + ] all? + ] ; + +: solution? ( board -- ? ) + dup length iota [ dupd safe? ] all? nip ; + +: queens ( n -- l ) + iota all-permutations [ solution? ] filter ; + +: .queens ( n -- ) + queens + [ + [ 1 + "%d " printf ] each nl + ] each ; diff --git a/Task/N-queens-problem/Forth/n-queens-problem.fth b/Task/N-queens-problem/Forth/n-queens-problem.fth new file mode 100644 index 0000000000..1d063ea3f5 --- /dev/null +++ b/Task/N-queens-problem/Forth/n-queens-problem.fth @@ -0,0 +1,29 @@ +variable solutions +variable nodes + +: bits ( n -- mask ) 1 swap lshift 1- ; +: lowBit ( mask -- bit ) dup negate and ; +: lowBit- ( mask -- bits ) dup 1- and ; + +: next3 ( dl dr f files -- dl dr f dl' dr' f' ) + invert >r + 2 pick r@ and 2* 1+ + 2 pick r@ and 2/ + 2 pick r> and ; + +: try ( dl dr f -- ) + dup if + 1 nodes +! + dup 2over and and + begin ?dup while + dup >r lowBit next3 recurse r> lowBit- + repeat + else 1 solutions +! then + drop 2drop ; + +: queens ( n -- ) + 0 solutions ! 0 nodes ! + -1 -1 rot bits try + solutions @ . ." solutions, " nodes @ . ." nodes" ; + +8 queens \ 92 solutions, 1965 nodes diff --git a/Task/N-queens-problem/Fortran/n-queens-problem-1.f b/Task/N-queens-problem/Fortran/n-queens-problem-1.f new file mode 100644 index 0000000000..f195a68c59 --- /dev/null +++ b/Task/N-queens-problem/Fortran/n-queens-problem-1.f @@ -0,0 +1,101 @@ +program Nqueens + implicit none + + integer, parameter :: n = 8 ! size of board + integer :: file = 1, rank = 1, queens = 0 + integer :: i + logical :: board(n,n) = .false. + + do while (queens < n) + board(file, rank) = .true. + if(is_safe(board, file, rank)) then + queens = queens + 1 + file = 1 + rank = rank + 1 + else + board(file, rank) = .false. + file = file + 1 + do while(file > n) + rank = rank - 1 + if (rank < 1) then + write(*, "(a,i0)") "No solution for n = ", n + stop + end if + do i = 1, n + if (board(i, rank)) then + file = i + board(file, rank) = .false. + queens = queens - 1 + file = i + 1 + exit + end if + end do + end do + end if + end do + + call Printboard(board) + +contains + +function is_safe(board, file, rank) + logical :: is_safe + logical, intent(in) :: board(:,:) + integer, intent(in) :: file, rank + integer :: i, f, r + + is_safe = .true. + do i = rank-1, 1, -1 + if(board(file, i)) then + is_safe = .false. + return + end if + end do + + f = file - 1 + r = rank - 1 + do while(f > 0 .and. r > 0) + if(board(f, r)) then + is_safe = .false. + return + end if + f = f - 1 + r = r - 1 + end do + + f = file + 1 + r = rank - 1 + do while(f <= n .and. r > 0) + if(board(f, r)) then + is_safe = .false. + return + end if + f = f + 1 + r = r - 1 + end do +end function + +subroutine Printboard(board) + logical, intent(in) :: board(:,:) + character(n*4+1) :: line + integer :: f, r + + write(*, "(a, i0)") "n = ", n + line = repeat("+---", n) // "+" + do r = 1, n + write(*, "(a)") line + do f = 1, n + write(*, "(a)", advance="no") "|" + if(board(f, r)) then + write(*, "(a)", advance="no") " Q " + else if(mod(f+r, 2) == 0) then + write(*, "(a)", advance="no") " " + else + write(*, "(a)", advance="no") "###" + end if + end do + write(*, "(a)") "|" + end do + write(*, "(a)") line +end subroutine +end program diff --git a/Task/N-queens-problem/Fortran/n-queens-problem-2.f b/Task/N-queens-problem/Fortran/n-queens-problem-2.f new file mode 100644 index 0000000000..f80dfab724 --- /dev/null +++ b/Task/N-queens-problem/Fortran/n-queens-problem-2.f @@ -0,0 +1,72 @@ +C This one implements depth-first backtracking. +C See the 2nd program for Scheme on the "Permutations" page for the +C main idea. +C As is, the program only prints the number of n-queens configurations. +C To print also the configurations, uncomment the line after label 80. + program queens + implicit integer(a-z) + parameter(l=18) + dimension a(l),s(l),u(4*l-2) + do 10 i=1,l + 10 a(i)=i + do 20 i=1,4*l-2 + 20 u(i)=0 + do 110 n=1,l + m=0 + i=1 + r=2*n-1 + go to 40 + 30 s(i)=j + u(p)=1 + u(q+r)=1 + i=i+1 + 40 if(i.gt.n) go to 80 + j=i + 50 z=a(i) + y=a(j) + p=i-y+n + q=i+y-1 + a(i)=y + a(j)=z + if((u(p).eq.0).and.(u(q+r).eq.0)) goto 30 + 60 j=j+1 + if(j.le.n) go to 50 + 70 j=j-1 + if(j.eq.i) go to 90 + z=a(i) + a(i)=a(j) + a(j)=z + go to 70 + 80 m=m+1 +C print *,(a(k),k=1,n) + 90 i=i-1 + if(i.eq.0) go to 100 + p=i-a(i)+n + q=i+a(i)-1 + j=s(i) + u(p)=0 + u(q+r)=0 + go to 60 + 100 print *,n,m + 110 continue + end + +C Output +C 1 1 +C 2 0 +C 3 0 +C 4 2 +C 5 10 +C 6 4 +C 7 40 +C 8 92 +C 9 352 +C 10 724 +C 11 2680 +C 12 14200 +C 13 73712 +C 14 365596 +C 15 2279184 +C 16 14772512 +C 17 95815104 +C 18 666090624 diff --git a/Task/N-queens-problem/Fortran/n-queens-problem-3.f b/Task/N-queens-problem/Fortran/n-queens-problem-3.f new file mode 100644 index 0000000000..54a6a8b1fc --- /dev/null +++ b/Task/N-queens-problem/Fortran/n-queens-problem-3.f @@ -0,0 +1,106 @@ + MODULE QUEENS_MOD + IMPLICIT NONE + INTEGER, PARAMETER :: LONG=SELECTED_INT_KIND(17) + CONTAINS + FUNCTION PQUEENS(N,K1,K2) RESULT(M) + IMPLICIT NONE + INTEGER(KIND=LONG) :: M + INTEGER, INTENT(IN) :: N,K1,K2 + INTEGER, PARAMETER :: L=20 + INTEGER :: A(L),S(L),U(4*L-2) + INTEGER :: I,J,Y,Z,P,Q,R + DO 10 I=1,N + 10 A(I)=I + DO 20 I=1,4*N-2 + 20 U(I)=0 + M=0 + R=2*N-1 + IF(K1.EQ.K2) RETURN + P=1-K1+N + Q=1+K1-1 + IF((U(P).NE.0).OR.(U(Q+R).NE.0)) RETURN + U(P)=1 + U(Q+R)=1 + Z=A(1) + A(1)=A(K1) + A(K1)=Z + P=2-K2+N + Q=2+K2-1 + IF((U(P).NE.0).OR.(U(Q+R).NE.0)) RETURN + U(P)=1 + U(Q+R)=1 + IF(K2.NE.1) THEN + Z=A(2) + A(2)=A(K2) + A(K2)=Z + ELSE + Z=A(2) + A(2)=A(K1) + A(K1)=Z + END IF + I=3 + GO TO 40 + 30 S(I)=J + U(P)=1 + U(Q+R)=1 + I=I+1 + 40 IF(I.GT.N) GO TO 80 + J=I + 50 Z=A(I) + Y=A(J) + P=I-Y+N + Q=I+Y-1 + A(I)=Y + A(J)=Z + IF((U(P).EQ.0).AND.(U(Q+R).EQ.0)) GO TO 30 + 60 J=J+1 + IF(J.LE.N) GO TO 50 + 70 J=J-1 + IF(J.EQ.I) GO TO 90 + Z=A(I) + A(I)=A(J) + A(J)=Z + GO TO 70 + 80 M=M+1 + 90 I=I-1 + IF(I.EQ.2) RETURN + P=I-A(I)+N + Q=I+A(I)-1 + J=S(I) + U(P)=0 + U(Q+R)=0 + GO TO 60 + END FUNCTION + END MODULE + PROGRAM QUEENS + USE OMP_LIB + USE QUEENS_MOD + IMPLICIT NONE + INTEGER, PARAMETER :: L=20 + INTEGER :: N,I,J,A(L*L,2),K,P,Q + INTEGER(KIND=LONG) :: S,B(L*L) + DOUBLE PRECISION :: T1,T2 + DO N=6,18 + K=0 + P=N/2 + Q=MOD(N,2)*(P+1) + DO I=1,N + DO J=1,N + IF((ABS(I-J).GT.1).AND.((I.LE.P).OR.((I.EQ.Q).AND.(J.LT.I)))) THEN + K=K+1 + A(K,1)=I + A(K,2)=J + END IF + END DO + END DO + S=0 + T1=OMP_GET_WTIME() +C$OMP PARALLEL DO SCHEDULE(DYNAMIC) + DO I=1,K + B(I)=PQUEENS(N,A(I,1),A(I,2)) + END DO +C$OMP END PARALLEL DO + T2=OMP_GET_WTIME() + PRINT '(I4,I12,F12.3)',N,2*SUM(B(1:K)),T2-T1 + END DO + END PROGRAM diff --git a/Task/N-queens-problem/Go/n-queens-problem.go b/Task/N-queens-problem/Go/n-queens-problem.go new file mode 100644 index 0000000000..45a61d8f0f --- /dev/null +++ b/Task/N-queens-problem/Go/n-queens-problem.go @@ -0,0 +1,61 @@ +// A fairly literal translation of the example program on the referenced +// WP page. Well, it happened to be the example program the day I completed +// the task. It seems from the WP history that there has been some churn +// in the posted example program. The example program of the day was in +// Pascal and was credited to Niklaus Wirth, from his "Algorithms + +// Data Structures = Programs." +package main + +import "fmt" + +var ( + i int + q bool + a [9]bool + b [17]bool + c [15]bool // offset by 7 relative to the Pascal version + x [9]int +) + +func try(i int) { + for j := 1; ; j++ { + q = false + if a[j] && b[i+j] && c[i-j+7] { + x[i] = j + a[j] = false + b[i+j] = false + c[i-j+7] = false + if i < 8 { + try(i + 1) + if !q { + a[j] = true + b[i+j] = true + c[i-j+7] = true + } + } else { + q = true + } + } + if q || j == 8 { + break + } + } +} + +func main() { + for i := 1; i <= 8; i++ { + a[i] = true + } + for i := 2; i <= 16; i++ { + b[i] = true + } + for i := 0; i <= 14; i++ { + c[i] = true + } + try(1) + if q { + for i := 1; i <= 8; i++ { + fmt.Println(i, x[i]) + } + } +} diff --git a/Task/N-queens-problem/Groovy/n-queens-problem-1.groovy b/Task/N-queens-problem/Groovy/n-queens-problem-1.groovy new file mode 100644 index 0000000000..e5bab51ed1 --- /dev/null +++ b/Task/N-queens-problem/Groovy/n-queens-problem-1.groovy @@ -0,0 +1,24 @@ +def listOrder = { a, b -> + def k = [a.size(), b.size()].min() + def i = (0.. b[i] : a.size() <=> b.size() +} + +def orderedPermutations = { list -> + def n = list.size() + (0.. + def n = list.size() + n == 1 || (0..<(n-1)).every{ i -> + ((i+1).. + !([list[i]+j-i, list[i]+i-j].contains(list[j])) + } + } +} + +def queensDistinctSolutions = { n -> + // each permutation is an N-Rooks solution + orderedPermutations((0.. + final n = list.size() + def tList = [0] * n + (0.. + list.reverse() + } + + public static final horiz = { list -> + final n = list.size() + list.collect { n - it - 1 } + } +} + +enum Rotations { + r0([]), + r90([Reflect.vert, Reflect.diag]), + r180([Reflect.vert, Reflect.diag, Reflect.vert, Reflect.diag]), + r270([Reflect.diag, Reflect.vert]); + + private final List operations + + private Rotations(List ops) { + operations = ops ?: [] + } + + public static void eliminateDups(primary, solutions) { + (r0..r270).each { rot -> rot.eliminateDuplicates(primary, solutions) } + } + + private void eliminateDuplicates(primary, solutions) { + def rotated = [] + primary + operations.each { rotated = it(rotated) } + solutions.removeAll([rotated, Reflect.vert(rotated)]) + } +} + +def queensUniqueSolutions = { start -> + assert start instanceof Number || start instanceof List + def qus = (start instanceof Number) \ + ? queensDistinctSolutions(start) \ + : [] + start + for (def i = 0; i < qus.size()-1; i++) { + Rotations.eliminateDups(qus[i], qus[(i+1)..<(qus.size())]) + } + qus +} diff --git a/Task/N-queens-problem/Groovy/n-queens-problem-3.groovy b/Task/N-queens-problem/Groovy/n-queens-problem-3.groovy new file mode 100644 index 0000000000..09ff6ffdbe --- /dev/null +++ b/Task/N-queens-problem/Groovy/n-queens-problem-3.groovy @@ -0,0 +1,8 @@ +(1..9).each { n -> + def qds = queensDistinctSolutions(n) + def qus = queensUniqueSolutions(qds) + println ([boardSize:n, "number of distinct solutions":qds.size(), "number of unique solutions":qus.size()]) + if(n < 9) { qus.each { println it } } + else { println "first:${qus[0]}"; println "last:${qus[-1]}" } + println() +} diff --git a/Task/N-queens-problem/Haskell/n-queens-problem.hs b/Task/N-queens-problem/Haskell/n-queens-problem.hs new file mode 100644 index 0000000000..5048f7fdfb --- /dev/null +++ b/Task/N-queens-problem/Haskell/n-queens-problem.hs @@ -0,0 +1,31 @@ +import Control.Monad +import Data.List + +-- given n, "queens n" solves the n-queens problem, returning a list of all the +-- safe arrangements. each solution is a list of the columns where the queens are +-- located for each row +queens :: Int -> [[Int]] +queens n = map fst $ foldM oneMoreQueen ([],[1..n]) [1..n] where + + -- foldM :: (Monad m) => (a -> b -> m a) -> a -> [b] -> m a + -- foldM folds (from left to right) in the list monad, which is convenient for + -- "nondeterminstically" finding "all possible solutions" of something. the + -- initial value [] corresponds to the only safe arrangement of queens in 0 rows + + -- given a safe arrangement y of queens in the first i rows, and a list of + -- possible choices, "oneMoreQueen y _" returns a list of all the safe + -- arrangements of queens in the first (i+1) rows along with remaining choices + oneMoreQueen (y,d) _ = [ (x:y, d\\[x]) | x <- d, safe x y 1] + +-- "safe x y n" tests whether a queen at column x is safe from previous +-- queens as recorded in y, at the distance n rows away +safe x [] n = True +safe x (c:y) n = and [ x /= c , x /= c + n , x /= c - n , safe x y (n+1)] + +-- prints what the board looks like for a solution; with an extra newline +printSolution y = let n = length y in + do mapM_ (\x -> putStrLn [if z == x then 'Q' else '.' | z <- [1..n]]) y + putStrLn "" + +-- prints all the solutions for 6 queens +main = mapM_ printSolution $ queens 6 diff --git a/Task/N-queens-problem/Heron/n-queens-problem.heron b/Task/N-queens-problem/Heron/n-queens-problem.heron new file mode 100644 index 0000000000..b510eecfe0 --- /dev/null +++ b/Task/N-queens-problem/Heron/n-queens-problem.heron @@ -0,0 +1,95 @@ +module NQueens { + inherits { + Heron.Windows.Console; + } + fields { + n : Int = 4; + sols : List = new List(); + } + methods { + PosToString(row : Int, col : Int) : String { + return "row " + row.ToString() + ", col " + col.ToString(); + } + AddQueen(b : Board, row : Int, col : Int) + { + if (!b.TryAddQueen(row, col)) + return; + if (row < n - 1) + foreach (i in 0..n-1) + AddQueen(new Board(b), row + 1, i); + else + sols.Add(b); + } + Main() { + foreach (i in 0..n-1) + AddQueen(new Board(), 0, i); + foreach (b in sols) { + b.Output(); + WriteLine(""); + } + WriteLine("Found " + sols.Count().ToString() + " solutions"); + } + } +} + +class Board { + fields { + rows = new List(); + } + methods { + Constructor() { + foreach (r in 0..n-1) { + var col = new List(); + foreach (c in 0..n-1) + col.Add(false); + rows.Add(col); + } + } + Constructor(b : Board) { + Constructor(); + foreach (r in 0..n-1) + foreach (c in 0..n-1) + SetSpaceOccupied(r, c, b.SpaceOccupied(r, c)); + } + SpaceOccupied(row : Int, col : Int) : Bool { + return rows[row][col]; + } + SetSpaceOccupied(row : Int, col : Int, b : Bool) { + rows[row][col] = b; + } + ValidPos(row : Int, col : Int) : Bool { + return ((row >= 0) && (row < n)) && ((col >= 0) && (col < n)); + } + VectorOccupied(row : Int, col : Int, rowDir : Int, colDir : Int) : Bool { + var nextRow = row + rowDir; + var nextCol = col + colDir; + if (!ValidPos(nextRow, nextCol)) + return false; + if (SpaceOccupied(nextRow, nextCol)) + return true; + return VectorOccupied(nextRow, nextCol, rowDir, colDir); + } + TryAddQueen(row : Int, col : Int) : Bool { + foreach (rowDir in -1..1) + foreach (colDir in -1..1) + if (rowDir != 0 || colDir != 0) + if (VectorOccupied(row, col, rowDir, colDir)) + return false; + SetSpaceOccupied(row, col, true); + return true; + } + Output() { + foreach (row in 0..n-1) { + foreach (col in 0..n-1) { + if (SpaceOccupied(row, col)) { + Write("Q"); + } + else { + Write("."); + } + } + WriteLine(""); + } + } + } +} diff --git a/Task/N-queens-problem/Icon/n-queens-problem-1.icon b/Task/N-queens-problem/Icon/n-queens-problem-1.icon new file mode 100644 index 0000000000..2bfb5cccba --- /dev/null +++ b/Task/N-queens-problem/Icon/n-queens-problem-1.icon @@ -0,0 +1,16 @@ +procedure main() + write(q(1), " ", q(2), " ", q(3), " ", q(4), " ", q(5), " ", q(6), " ", q(7), " ", q(8)) +end + +procedure q(c) + static udiag, ddiag, row + + initial { + udiag := list(15, 0) + ddiag := list(15, 0) + row := list(8, 0) + } + + every 0 = row[r := 1 to 8] = ddiag[r + c - 1] = udiag[8 + r - c] do # test if free + suspend row[r] <- ddiag[r + c - 1] <- udiag[8 + r - c] <- r # place and yield +end diff --git a/Task/N-queens-problem/Icon/n-queens-problem-2.icon b/Task/N-queens-problem/Icon/n-queens-problem-2.icon new file mode 100644 index 0000000000..8cce154da3 --- /dev/null +++ b/Task/N-queens-problem/Icon/n-queens-problem-2.icon @@ -0,0 +1,3 @@ +procedure main() + every write(q(1), " ", q(2), " ", q(3), " ", q(4), " ", q(5), " ", q(6), " ", q(7), " ", q(8)) +end diff --git a/Task/N-queens-problem/Icon/n-queens-problem-3.icon b/Task/N-queens-problem/Icon/n-queens-problem-3.icon new file mode 100644 index 0000000000..afefa82f60 --- /dev/null +++ b/Task/N-queens-problem/Icon/n-queens-problem-3.icon @@ -0,0 +1,35 @@ +global n, rw, dd, ud + +procedure main(args) + n := integer(args[1]) | 8 + rw := list(n) + dd := list(2*n-1) + ud := list(2*n-1) + solvequeen(1) +end + +procedure solvequeen(c) + if (c > n) then return show() + else suspend placequeen(c) & solvequeen(c+1) +end + +procedure placequeen(c) + suspend (/rw[r := 1 to n] <- /dd[r+c-1] <- /ud[n+r-c] <- c) +end + +procedure show() + static count, line, border + initial { + count := 0 + line := repl("| ",n) || "|" + border := repl("----",n) || "-" + } + write("solution: ", count+:=1) + write(" ", border) + every line[4*(!rw - 1) + 3] <- "Q" do { + write(" ", line) + write(" ", border) + } + write() + return # Comment out to see all possible solutions +end diff --git a/Task/N-queens-problem/J/n-queens-problem.j b/Task/N-queens-problem/J/n-queens-problem.j new file mode 100644 index 0000000000..fbb3caa9b4 --- /dev/null +++ b/Task/N-queens-problem/J/n-queens-problem.j @@ -0,0 +1,4 @@ +perm =: ! A.&i. ] NB. all permutations of integers 0 to y +comb2 =: (, #: I.@,@(= 0) { + do { + b[y]++; + } while ((b[y] < 8) && unsafe(y)); + if (b[y] < 8) { + if (y < 7) { + b[++y] = -1; + } else { + putboard(); + } + } else { + y--; + } + } + } +} diff --git a/Task/N-queens-problem/Locomotive-Basic/n-queens-problem.locomotive b/Task/N-queens-problem/Locomotive-Basic/n-queens-problem.locomotive new file mode 100644 index 0000000000..c217e68974 --- /dev/null +++ b/Task/N-queens-problem/Locomotive-Basic/n-queens-problem.locomotive @@ -0,0 +1,52 @@ +10 mode 1:defint a-z +20 while n<4:input "How many queens (N>=4)";n:wend +30 dim q(n),e(n),o(n) +40 r=n mod 6 +50 if r<>2 and r<>3 then gosub 320:goto 220 +60 for i=1 to int(n/2) +70 e(i)=2*i +80 next +90 for i=1 to round(n/2) +100 o(i)=2*i-1 +110 next +120 if r=2 then gosub 410 +130 if r=3 then gosub 460 +140 s=1 +150 for i=1 to n +160 if e(i)>0 then q(s)=e(i):s=s+1 +170 next +180 for i=1 to n +190 if o(i)>0 then q(s)=o(i):s=s+1 +200 next +210 ' print board +220 cls +230 for i=1 to n +240 locate i,26-q(i):print chr$(238); +250 locate i,24-n :print chr$(96+i); +260 locate n+1,26-i :print i; +270 next +280 locate 1,1 +290 call &bb06 +300 end +310 ' the simple case +320 p=1 +330 for i=1 to n +340 if i mod 2=0 then q(p)=i:p=p+1 +350 next +360 for i=1 to n +370 if i mod 2 then q(p)=i:p=p+1 +380 next +390 return +400 ' edit list when remainder is 2 +410 for i=1 to n +420 if o(i)=3 then o(i)=1 else if o(i)=1 then o(i)=3 +430 if o(i)=5 then o(i)=-1 else if o(i)=0 then o(i)=5:return +440 next +450 ' edit list when remainder is 3 +460 for i=1 to n +470 if e(i)=2 then e(i)=-1 else if e(i)=0 then e(i)=2:goto 500 +480 next +490 ' edit list some more +500 for i=1 to n +510 if o(i)=1 or o(i)=3 then o(i)=-1 else if o(i)=0 then o(i)=1:o(i+1)=3:return +520 next diff --git a/Task/N-queens-problem/Logo/n-queens-problem.logo b/Task/N-queens-problem/Logo/n-queens-problem.logo new file mode 100644 index 0000000000..e3ab380f0c --- /dev/null +++ b/Task/N-queens-problem/Logo/n-queens-problem.logo @@ -0,0 +1,17 @@ +to try :files :diag1 :diag2 :tried + if :files = 0 [make "solutions :solutions+1 show :tried stop] + localmake "safe (bitand :files :diag1 :diag2) + until [:safe = 0] [ + localmake "f bitnot bitand :safe minus :safe + try bitand :files :f ashift bitand :diag1 :f -1 (ashift bitand :diag2 :f 1)+1 fput bitnot :f :tried + localmake "safe bitand :safe :safe-1 + ] +end + +to queens :n + make "solutions 0 + try (lshift 1 :n)-1 -1 -1 [] + output :solutions +end + +print queens 8 ; 92 diff --git a/Task/N-queens-problem/Lua/n-queens-problem.lua b/Task/N-queens-problem/Lua/n-queens-problem.lua new file mode 100644 index 0000000000..80ce581a1f --- /dev/null +++ b/Task/N-queens-problem/Lua/n-queens-problem.lua @@ -0,0 +1,46 @@ +N = 8 + +board = {} +for i = 1, N do + board[i] = {} + for j = 1, N do + board[i][j] = false + end +end + +function Allowed( x, y ) + for i = 1, x-1 do + if ( board[i][y] ) or ( i <= y and board[x-i][y-i] ) or ( y+i <= N and board[x-i][y+i] ) then + return false + end + end + return true +end + +function Find_Solution( x ) + for y = 1, N do + if Allowed( x, y ) then + board[x][y] = true + if x == N or Find_Solution( x+1 ) then + return true + end + board[x][y] = false + end + end + return false +end + +if Find_Solution( 1 ) then + for i = 1, N do + for j = 1, N do + if board[i][j] then + io.write( "|Q" ) + else + io.write( "| " ) + end + end + print( "|" ) + end +else + print( string.format( "No solution for %d queens.\n", N ) ) +end diff --git a/Task/N-queens-problem/MUMPS/n-queens-problem.mumps b/Task/N-queens-problem/MUMPS/n-queens-problem.mumps new file mode 100644 index 0000000000..19b9a533f6 --- /dev/null +++ b/Task/N-queens-problem/MUMPS/n-queens-problem.mumps @@ -0,0 +1,268 @@ +Queens New count,flip,row,sol + Set sol=0 + For row(1)=1:1:4 Do try(2) ; Not 8, the other 4 are symmetric... + ; + ; Remove symmetric solutions + Set sol="" For Set sol=$Order(sol(sol)) Quit:sol="" Do + . New xx,yy + . Kill sol($Translate(sol,12345678,87654321)) ; Vertical flip + . Kill sol($Reverse(sol)) ; Horizontal flip + . Set flip="--------" for xx=1:1:8 Do ; Flip over top left to bottom right diagonal + . . New nx,ny + . . Set yy=$Extract(sol,xx),nx=8+1-xx,ny=8+1-yy + . . Set $Extract(flip,ny)=nx + . . Quit + . Kill sol(flip) + . Set flip="--------" for xx=1:1:8 Do ; Flip over top right to bottom left diagonal + . . New nx,ny + . . Set yy=$Extract(sol,xx),nx=xx,ny=yy + . . Set $Extract(flip,ny)=nx + . . Quit + . Kill sol(flip) + . Quit + ; + ; Display remaining solutions + Set count=0,sol="" For Set sol=$Order(sol(sol)) Quit:sol="" Do Quit:sol="" + . New s1,s2,s3,txt,x,y + . Set s1=sol,s2=$Order(sol(s1)),s3="" Set:s2'="" s3=$Order(sol(s2)) + . Set txt="+--+--+--+--+--+--+--+--+" + . Write !," ",txt Write:s2'="" " ",txt Write:s3'="" " ",txt + . For y=8:-1:1 Do + . . Write !,y," |" + . . For x=1:1:8 Write $Select($Extract(s1,x)=y:" Q",x+y#2:" ",1:"##"),"|" + . . If s2'="" Write " |" + . . If s2'="" For x=1:1:8 Write $Select($Extract(s2,x)=y:" Q",x+y#2:" ",1:"##"),"|" + . . If s3'="" Write " |" + . . If s3'="" For x=1:1:8 Write $Select($Extract(s3,x)=y:" Q",x+y#2:" ",1:"##"),"|" + . . Write !," ",txt Write:s2'="" " ",txt Write:s3'="" " ",txt + . . Quit + . Set txt=" A B C D E F G H" + . Write !," ",txt Write:s2'="" " ",txt Write:s3'="" " ",txt Write ! + . Set sol=s3 + . Quit + Quit +try(col) New ok,pcol + If col>8 Do Quit + . New out,x + . Set out="" For x=1:1:8 Set out=out_row(x) + . Set sol(out)=1 + . Quit + For row(col)=1:1:8 Do + . Set ok=1 + . For pcol=1:1:col-1 If row(pcol)=row(col) Set ok=0 Quit + . Quit:'ok + . For pcol=1:1:col-1 If col-pcol=$Translate(row(pcol)-row(col),"-") Set ok=0 Quit + . Quit:'ok + . Do try(col+1) + . Quit + Quit +Do Queens + + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +8 | |##| Q|##| |##| |##| | |##| Q|##| |##| |##| | |##| | Q| |##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +7 |##| |##| |##| Q|##| | |##| |##| | Q| |##| | |##| |##| |##| | Q| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +6 | |##| | Q| |##| |##| | | Q| |##| |##| |##| | |##| Q|##| |##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +5 |##| Q|##| |##| |##| | |##| |##| |##| |##| Q| |##| |##| |##| |##| Q| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +4 | |##| |##| |##| | Q| | |##| |##| | Q| |##| | | Q| |##| |##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +3 |##| |##| | Q| |##| | |##| |##| Q|##| |##| | |##| |##| | Q| |##| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +2 | |##| |##| |##| Q|##| | |##| |##| |##| Q|##| | Q|##| |##| |##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +1 | Q| |##| |##| |##| | | Q| |##| |##| |##| | |##| |##| |##| Q|##| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ + A B C D E F G H A B C D E F G H A B C D E F G H + + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +8 | |##| |##| | Q| |##| | |##| |##| | Q| |##| | |##| |##| | Q| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +7 |##| | Q| |##| |##| | |##| | Q| |##| |##| | |##| |##| Q|##| |##| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +6 | |##| |##| |##| Q|##| | |##| |##| |##| Q|##| | | Q| |##| |##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +5 |##| Q|##| |##| |##| | |##| Q|##| |##| |##| | |##| |##| |##| |##| Q| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +4 | |##| |##| |##| | Q| | |##| | Q| |##| |##| | |##| |##| Q|##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +3 |##| |##| | Q| |##| | |##| |##| |##| |##| Q| |##| |##| |##| | Q| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +2 | Q|##| |##| |##| |##| | Q|##| |##| |##| |##| | Q|##| |##| |##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +1 |##| |##| Q|##| |##| | |##| |##| | Q| |##| | |##| | Q| |##| |##| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ + A B C D E F G H A B C D E F G H A B C D E F G H + + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +8 | |##| Q|##| |##| |##| | |##| |##| Q|##| |##| | |##| | Q| |##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +7 |##| |##| |##| | Q| | |##| Q|##| |##| |##| | |##| Q|##| |##| |##| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +6 | | Q| |##| |##| |##| | |##| | Q| |##| |##| | |##| |##| |##| Q|##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +5 |##| |##| |##| |##| Q| |##| |##| |##| Q|##| | |##| | Q| |##| |##| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +4 | |##| |##| | Q| |##| | |##| |##| |##| | Q| | |##| |##| | Q| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +3 |##| |##| Q|##| |##| | |##| | Q| |##| |##| | |##| |##| |##| |##| Q| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +2 | Q|##| |##| |##| |##| | Q|##| |##| |##| |##| | Q|##| |##| |##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +1 |##| |##| | Q| |##| | |##| |##| |##| | Q| | |##| |##| | Q| |##| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ + A B C D E F G H A B C D E F G H A B C D E F G H + + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +8 | | Q| |##| |##| |##| | |##| | Q| |##| |##| | |##| | Q| |##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +7 |##| |##| |##| | Q| | |##| |##| |##| Q|##| | |##| |##| |##| | Q| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +6 | |##| Q|##| |##| |##| | |##| |##| |##| | Q| | |##| |##| Q|##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +5 |##| |##| |##| Q|##| | |##| Q|##| |##| |##| | |##| Q|##| |##| |##| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +4 | |##| |##| |##| | Q| | |##| |##| |##| Q|##| | |##| |##| | Q| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +3 |##| |##| | Q| |##| | | Q| |##| |##| |##| | | Q| |##| |##| |##| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +2 | Q|##| |##| |##| |##| | |##| Q|##| |##| |##| | |##| Q|##| |##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +1 |##| |##| Q|##| |##| | |##| |##| | Q| |##| | |##| |##| |##| |##| Q| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ + A B C D E F G H A B C D E F G H A B C D E F G H + + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +8 | |##| Q|##| |##| |##| | |##| |##| Q|##| |##| | |##| |##| Q|##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +7 |##| |##| |##| Q|##| | |##| |##| |##| | Q| | |##| |##| |##| | Q| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +6 | |##| |##| |##| | Q| | | Q| |##| |##| |##| | | Q| |##| |##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +5 |##| Q|##| |##| |##| | |##| |##| Q|##| |##| | |##| |##| |##| Q|##| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +4 | |##| | Q| |##| |##| | |##| |##| |##| | Q| | |##| Q|##| |##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +3 | Q| |##| |##| |##| | | Q| |##| |##| |##| | | Q| |##| |##| |##| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +2 | |##| |##| |##| Q|##| | |##| Q|##| |##| |##| | |##| | Q| |##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +1 |##| |##| | Q| |##| | |##| |##| |##| Q|##| | |##| |##| |##| |##| Q| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ + A B C D E F G H A B C D E F G H A B C D E F G H + + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +8 | |##| Q|##| |##| |##| | |##| Q|##| |##| |##| | |##| | Q| |##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +7 |##| |##| |##| Q|##| | |##| |##| |##| | Q| | |##| Q|##| |##| |##| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +6 | | Q| |##| |##| |##| | | Q| |##| |##| |##| | |##| |##| |##| | Q| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +5 |##| |##| | Q| |##| | |##| |##| |##| |##| Q| |##| |##| | Q| |##| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +4 | |##| |##| |##| | Q| | |##| |##| Q|##| |##| | |##| |##| |##| Q|##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +3 | Q| |##| |##| |##| | | Q| |##| |##| |##| | | Q| |##| |##| |##| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +2 | |##| |##| |##| Q|##| | |##| | Q| |##| |##| | |##| Q|##| |##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +1 |##| |##| Q|##| |##| | |##| |##| |##| Q|##| | |##| |##| |##| Q|##| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ + A B C D E F G H A B C D E F G H A B C D E F G H + + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +8 | |##| | Q| |##| |##| | | Q| |##| |##| |##| | |##| | Q| |##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +7 |##| Q|##| |##| |##| | |##| |##| Q|##| |##| | |##| |##| |##| |##| Q| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +6 | |##| |##| Q|##| |##| | |##| |##| | Q| |##| | |##| |##| Q|##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +5 |##| |##| |##| |##| Q| |##| |##| |##| |##| Q| |##| | Q| |##| |##| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +4 | |##| |##| | Q| |##| | |##| Q|##| |##| |##| | Q|##| |##| |##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +3 | Q| |##| |##| |##| | | Q| |##| |##| |##| | |##| |##| |##| | Q| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +2 | |##| Q|##| |##| |##| | |##| |##| |##| Q|##| | | Q| |##| |##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +1 |##| |##| |##| | Q| | |##| |##| | Q| |##| | |##| |##| |##| Q|##| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ + A B C D E F G H A B C D E F G H A B C D E F G H + + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +8 | |##| |##| | Q| |##| | |##| Q|##| |##| |##| | |##| Q|##| |##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +7 |##| | Q| |##| |##| | |##| |##| | Q| |##| | |##| |##| |##| |##| Q| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +6 | |##| |##| Q|##| |##| | |##| |##| |##| | Q| | |##| | Q| |##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +5 |##| |##| |##| |##| Q| |##| |##| Q|##| |##| | |##| |##| |##| | Q| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +4 | Q|##| |##| |##| |##| | Q|##| |##| |##| |##| | Q|##| |##| |##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +3 |##| |##| Q|##| |##| | |##| |##| |##| | Q| | |##| |##| |##| Q|##| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +2 | | Q| |##| |##| |##| | | Q| |##| |##| |##| | | Q| |##| |##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +1 |##| |##| |##| | Q| | |##| |##| |##| Q|##| | |##| |##| | Q| |##| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ + A B C D E F G H A B C D E F G H A B C D E F G H + + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +8 | |##| |##| | Q| |##| | |##| Q|##| |##| |##| | |##| | Q| |##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +7 |##| |##| |##| |##| Q| |##| |##| | Q| |##| | |##| Q|##| |##| |##| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +6 | | Q| |##| |##| |##| | | Q| |##| |##| |##| | |##| |##| |##| | Q| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +5 |##| |##| Q|##| |##| | |##| |##| |##| |##| Q| |##| |##| |##| Q|##| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +4 | Q|##| |##| |##| |##| | Q|##| |##| |##| |##| | Q|##| |##| |##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +3 |##| |##| |##| | Q| | |##| |##| |##| | Q| | |##| | Q| |##| |##| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +2 | |##| |##| Q|##| |##| | |##| | Q| |##| |##| | |##| |##| Q|##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +1 |##| | Q| |##| |##| | |##| |##| |##| Q|##| | |##| |##| |##| | Q| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ + A B C D E F G H A B C D E F G H A B C D E F G H + + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +8 | |##| |##| |##| | Q| | | Q| |##| |##| |##| | | Q| |##| |##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +7 |##| Q|##| |##| |##| | |##| |##| |##| | Q| | |##| |##| | Q| |##| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +6 | |##| |##| Q|##| |##| | |##| |##| Q|##| |##| | |##| |##| |##| Q|##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +5 |##| | Q| |##| |##| | |##| |##| |##| |##| Q| |##| |##| Q|##| |##| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +4 | Q|##| |##| |##| |##| | Q|##| |##| |##| |##| | Q|##| |##| |##| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +3 |##| |##| |##| | Q| | |##| |##| Q|##| |##| | |##| |##| |##| |##| Q| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +2 | |##| | Q| |##| |##| | |##| |##| | Q| |##| | |##| |##| | Q| |##| + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +1 |##| |##| |##| Q|##| | |##| | Q| |##| |##| | |##| | Q| |##| |##| | + +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+ + A B C D E F G H A B C D E F G H A B C D E F G H + + +--+--+--+--+--+--+--+--+ +8 | | Q| |##| |##| |##| + +--+--+--+--+--+--+--+--+ +7 |##| |##| |##| Q|##| | + +--+--+--+--+--+--+--+--+ +6 | |##| |##| |##| | Q| + +--+--+--+--+--+--+--+--+ +5 |##| | Q| |##| |##| | + +--+--+--+--+--+--+--+--+ +4 | Q|##| |##| |##| |##| + +--+--+--+--+--+--+--+--+ +3 |##| |##| Q|##| |##| | + +--+--+--+--+--+--+--+--+ +2 | |##| |##| |##| Q|##| + +--+--+--+--+--+--+--+--+ +1 |##| |##| | Q| |##| | + +--+--+--+--+--+--+--+--+ + A B C D E F G H diff --git a/Task/N-queens-problem/Mathematica/n-queens-problem-1.math b/Task/N-queens-problem/Mathematica/n-queens-problem-1.math new file mode 100644 index 0000000000..cb01104e3a --- /dev/null +++ b/Task/N-queens-problem/Mathematica/n-queens-problem-1.math @@ -0,0 +1,9 @@ +safe[q_List, n_] := + With[{l = Length@q}, + Length@Union@q == Length@Union[q + Range@l] == + Length@Union[q - Range@l] == l] +nQueen[q_List:{}, n_] := + If[safe[q, n], + If[Length[q] == n, q, + Cases[Flatten[{nQueen[Append[q, #], n]}, 2] & /@ Range[n], + Except[{Null} | {}]]], Null] diff --git a/Task/N-queens-problem/Mathematica/n-queens-problem-2.math b/Task/N-queens-problem/Mathematica/n-queens-problem-2.math new file mode 100644 index 0000000000..c1317e8485 --- /dev/null +++ b/Task/N-queens-problem/Mathematica/n-queens-problem-2.math @@ -0,0 +1,5 @@ +matrixView[n_] := + Grid[Normal@ + SparseArray[MapIndexed[{#, First@#2} -> "Q" &, #], {n, n}, "."], + Frame -> All] & /@ nQueen[n] +matrixView[6] // OutputForm diff --git a/Task/N-queens-problem/Maxima/n-queens-problem.maxima b/Task/N-queens-problem/Maxima/n-queens-problem.maxima new file mode 100644 index 0000000000..143865aa01 --- /dev/null +++ b/Task/N-queens-problem/Maxima/n-queens-problem.maxima @@ -0,0 +1,18 @@ +/* translation of Fortran 77, return solutions as permutations */ + +queens(n) := block([a, i, j, m, p, q, r, s, u, v, w, y, z], +a: makelist(i, i, 1, n), s: a*0, u: makelist(0, i, 1, 4*n - 2), +m: 0, i: 1, r: 2*n - 1, w: [ ], go(L40), L30, s[i]: j, u[p]: 1, +u[q + r]: 1, i: i + 1, L40, if i > n then go(L80), j: i, L50, +z: a[i], y: a[j], p: i - y + n, q: i + y - 1, a[i]: y, a[j]: z, +if u[p] = 0 and u[q + r] = 0 then go(L30), L60, j: j + 1, +if j <= n then go(L50), L70, j: j - 1, if j = i then go(L90), +z: a[i], a[i]: a[j], a[j]: z, go(L70), L80, m: m + 1, +w: endcons(copylist(a), w), L90, i: i - 1, if i = 0 then go(L100), +p: i - a[i] + n, q: i + a[i] - 1, j: s[i], u[p]: 0, u[q + r]: 0, +go(L60), L100, w)$ + +queens(8); /* [[1, 5, 8, 6, 3, 7, 2, 4], + [1, 6, 8, 3, 7, 4, 2, 5], + ...]] */ +length(%); /* 92 */ diff --git a/Task/N-queens-problem/OCaml/n-queens-problem-1.ocaml b/Task/N-queens-problem/OCaml/n-queens-problem-1.ocaml new file mode 100644 index 0000000000..21f9505ba3 --- /dev/null +++ b/Task/N-queens-problem/OCaml/n-queens-problem-1.ocaml @@ -0,0 +1,59 @@ +(* Authors: Nicolas Barnier, Pascal Brisset + Copyright 2004 CENA. All rights reserved. + This code is distributed under the terms of the GNU LGPL *) + +open Facile +open Easy + +(* Print a solution *) +let print queens = + let n = Array.length queens in + if n <= 10 then (* Pretty printing *) + for i = 0 to n - 1 do + let c = Fd.int_value queens.(i) in (* queens.(i) is bound *) + for j = 0 to n - 1 do + Printf.printf "%c " (if j = c then '*' else '-') + done; + print_newline () + done + else (* Short print *) + for i = 0 to n-1 do + Printf.printf "line %d : col %a\n" i Fd.fprint queens.(i) + done; + flush stdout; +;; + +(* Solve the n-queens problem *) +let queens n = + (* n decision variables in 0..n-1 *) + let queens = Fd.array n 0 (n-1) in + + (* 2n auxiliary variables for diagonals *) + let shift op = Array.mapi (fun i qi -> Arith.e2fd (op (fd2e qi) (i2e i))) queens in + let diag1 = shift (+~) and diag2 = shift (-~) in + + (* Global constraints *) + Cstr.post (Alldiff.cstr queens); + Cstr.post (Alldiff.cstr diag1); + Cstr.post (Alldiff.cstr diag2); + + (* Heuristic Min Size, Min Value *) + let h a = (Var.Attr.size a, Var.Attr.min a) in + let min_min = Goals.Array.choose_index (fun a1 a2 -> h a1 < h a2) in + + (* Search goal *) + let labeling = Goals.Array.forall ~select:min_min Goals.indomain in + + (* Solve *) + let bt = ref 0 in + if Goals.solve ~control:(fun b -> bt := b) (labeling queens) then begin + Printf.printf "%d backtracks\n" !bt; + print queens + end else + prerr_endline "No solution" + +let _ = + if Array.length Sys.argv <> 2 + then raise (Failure "Usage: queens "); + Gc.set ({(Gc.get ()) with Gc.space_overhead = 500}); (* May help except with an underRAMed system *) + queens (int_of_string Sys.argv.(1));; diff --git a/Task/N-queens-problem/OCaml/n-queens-problem-2.ocaml b/Task/N-queens-problem/OCaml/n-queens-problem-2.ocaml new file mode 100644 index 0000000000..792125c2bb --- /dev/null +++ b/Task/N-queens-problem/OCaml/n-queens-problem-2.ocaml @@ -0,0 +1,32 @@ +let solutions n = + + let show board = + let pr v = + for i = 1 to n do + print_string (if i=v then " q" else " _"); + done; + print_newline() in + List.iter pr board; + print_newline() in + + let rec safe i j k = function + | [] -> true + | h::t -> h<>i && h<>j && h<>k && safe i (j+1) (k-1) t in + + let rec loop col p = + for i = 1 to n + do + if safe i (i+1) (i-1) p then + let p' = i::p in + if col = n then show p' + else loop (col+1) p' + done in + + loop 1 [] in + +let n = + if Array.length Sys.argv > 1 + then int_of_string Sys.argv.(1) + else 8 in + +solutions n diff --git a/Task/N-queens-problem/Objeck/n-queens-problem.objeck b/Task/N-queens-problem/Objeck/n-queens-problem.objeck new file mode 100644 index 0000000000..b0c1b2668e --- /dev/null +++ b/Task/N-queens-problem/Objeck/n-queens-problem.objeck @@ -0,0 +1,57 @@ +bundle Default { + class NQueens { + b : static : Int[]; + s : static : Int; + + function : Main(args : String[]) ~ Nil { + b := Int->New[8]; + s := 0; + + y := 0; + b[0] := -1; + + while (y >= 0) { + do { + b[y]+=1; + } + while((b[y] < 8) & Unsafe(y)); + + if(b[y] < 8) { + if (y < 7) { + b[y + 1] := -1; + y += 1; + } + else { + PutBoard(); + }; + } + else { + y-=1; + }; + }; + } + + function : Unsafe(y : Int) ~ Bool { + x := b[y]; + for(i := 1; i <= y; i+=1;) { + t := b[y - i]; + if(t = x | t = x - i | t = x + i) { + return true; + }; + }; + + return false; + } + + function : PutBoard() ~ Nil { + IO.Console->Print("\n\nSolution ")->PrintLine(s + 1); + s += 1; + for(y := 0; y < 8; y+=1;) { + for(x := 0; x < 8; x+=1;) { + IO.Console->Print((b[y] = x) ? "|Q" : "|_"); + }; + "|"->PrintLine(); + }; + } + } +} diff --git a/Task/N-queens-problem/Oz/n-queens-problem.oz b/Task/N-queens-problem/Oz/n-queens-problem.oz new file mode 100644 index 0000000000..a386b85390 --- /dev/null +++ b/Task/N-queens-problem/Oz/n-queens-problem.oz @@ -0,0 +1,68 @@ +declare + fun {Queens N} + proc {$ Board} + %% a board is a N-tuple of rows + Board = {MakeTuple queens N} + for Y in 1..N do + %% a row is a N-tuple of values in [0,1] + %% (0: no queen, 1: queen) + Board.Y = {FD.tuple row N 0#1} + end + + {ForAll {Rows Board} SumIs1} + {ForAll {Columns Board} SumIs1} + + %% for every two points on a diagonal + for [X1#Y1 X2#Y2] in {DiagonalPairs N} do + %$ at most one of them has a queen + Board.Y1.X1 + Board.Y2.X2 =<: 1 + end + + %% enumerate all such boards + {FD.distribute naive {FlatBoard Board}} + end + end + + fun {Rows Board} + {Record.toList Board} + end + + fun {Columns Board} + for X in {Arity Board.1} collect:C1 do + {C1 + for Y in {Arity Board} collect:C2 do + {C2 Board.Y.X} + end} + end + end + + proc {SumIs1 Xs} + {FD.sum Xs '=:' 1} + end + + fun {DiagonalPairs N} + proc {Coords Root} + [X1#Y1 X2#Y2] = Root + Diff + in + X1::1#N Y1::1#N + X2::1#N Y2::1#N + %% (X1,Y1) and (X2,Y2) are on a diagonal if {Abs X2-X1} = {Abs Y2-Y1} + Diff::1#N-1 + {FD.distance X2 X1 '=:' Diff} + {FD.distance Y2 Y1 '=:' Diff} + %% enumerate all such coordinates + {FD.distribute naive [X1 Y1 X2 Y2]} + end + in + {SearchAll Coords} + end + + fun {FlatBoard Board} + {Flatten {Record.toList {Record.map Board Record.toList}}} + end + + Solutions = {SearchAll {Queens 8}} +in + {Length Solutions} = 92 %% assert + {Inspect {List.take Solutions 3}} diff --git a/Task/N-queens-problem/PHP/n-queens-problem.php b/Task/N-queens-problem/PHP/n-queens-problem.php new file mode 100644 index 0000000000..23dd00be3e --- /dev/null +++ b/Task/N-queens-problem/PHP/n-queens-problem.php @@ -0,0 +1,175 @@ + + + +n x n Queen solving program + + + +n x n Queen solving program"; + +//Get the size of the board +$boardX = $_POST['boardX']; +$boardY = $_POST['boardX']; + +// Function to rotate a board 90 degrees +function rotateBoard($p, $boardX) { +$a=0; +while ($a < count($p)) { + $b = strlen(decbin($p[$a]))-1; + $tmp[$b] = 1 << ($boardX - $a - 1); + ++$a; + } +ksort($tmp); +return $tmp; +} + +// This function will find rotations of a solution +function findRotation($p, $boardX,$solutions){ +$tmp = rotateBoard($p,$boardX); +// Rotated 90 +if (in_array($tmp,$solutions)) {} +else {$solutions[] = $tmp;} + +$tmp = rotateBoard($tmp,$boardX); +// Rotated 180 +if (in_array($tmp,$solutions)){} +else {$solutions[] = $tmp;} + +$tmp = rotateBoard($tmp,$boardX); +// Rotated 270 +if (in_array($tmp,$solutions)){} +else {$solutions[] = $tmp;} + +// Reflected +$tmp = array_reverse($p); +if (in_array($tmp,$solutions)){} +else {$solutions[] = $tmp;} + +$tmp = rotateBoard($tmp,$boardX); +// Reflected and Rotated 90 +if (in_array($tmp,$solutions)){} +else {$solutions[] = $tmp;} + +$tmp = rotateBoard($tmp,$boardX); +// Reflected and Rotated 180 +if (in_array($tmp,$solutions)){} +else {$solutions[] = $tmp;} + +$tmp = rotateBoard($tmp,$boardX); +// Reflected and Rotated 270 +if (in_array($tmp,$solutions)){} +else {$solutions[] = $tmp;} +return $solutions; +} + +// This is a function which will render the board +function renderBoard($p,$boardX) { +echo ""; +for ($y = 0; $y < $boardX; ++$y) { + echo ''; + for ($x = 0; $x < $boardX; ++$x){ + if (($x+$y) & 1) { $cellCol = '#9C661F';} + else {$cellCol = '#FCE6C9';} + + if ($p[$y] == 1 << $x) { echo "";} + else { echo "";} + } + echo ''; +} +echo '
 '; + +} + +//This function allows me to generate the next order of rows. +function pc_next_permutation($p) { +$size = count($p) - 1; +// slide down the array looking for where we're smaller than the next guy + +for ($i = $size - 1; $p[$i] >= $p[$i+1]; --$i) { } + +// if this doesn't occur, we've finished our permutations +// the array is reversed: (1, 2, 3, 4) => (4, 3, 2, 1) +if ($i == -1) { return false; } + +// slide down the array looking for a bigger number than what we found before +for ($j = $size; $p[$j] <= $p[$i]; --$j) { } +// swap them +$tmp = $p[$i]; $p[$i] = $p[$j]; $p[$j] = $tmp; +// now reverse the elements in between by swapping the ends +for (++$i, $j = $size; $i < $j; ++$i, --$j) +{ $tmp = $p[$i]; $p[$i] = $p[$j]; $p[$j] = $tmp; } +return $p; +} + +//This function needs to check the current state to see if there are any +function checkBoard($p,$boardX) { + $a = 0; //this is the row being checked + while ($a < count($p)) { + $b = 1; + while ($b < ($boardX - $a)){ + $x = $p[$a+$b] << $b; + $y = $p[$a+$b] >> $b; + if ($p[$a] == $x | $p[$a] == $y) { return false;} + ++$b; + } + ++$a; + } + return true; +} + + +if (isset($_POST['process']) && isset($_POST['boardX'])) +{ +//Within here is the code that needs to be run if process is clicked. + + +//First I need to create the different possible rows +for ($x = 0; $x < $boardX; ++$x){ + $row[$x] = 1 << $x; + } + +//Now I need to create all the possible orders of rows, will be equal to [boardY]! +$solcount = 0; +$solutions = array(); +while ($row != false) { + if (checkBoard($row,$boardX)){ + if(!in_array($row,$solutions)){ + $solutions[] = $row; + renderBoard($row,$boardX); + $solutions = findRotation($row,$boardX,$solutions); + ++$solcount; + } + + } + $row = pc_next_permutation($row); + + } +echo "

    Rows/Columns: ".$boardX."
    Unique Solutions: ".$solcount."
    Total Solutions: ".count($solutions)." - Note: This includes symmetrical solutions
"; +//print_r($solutions); +} + +//This code collects the starting parameters +echo <<<_END +
+    Number of columns/rows + +
+ +_END; + +?> + + diff --git a/Task/N-queens-problem/Pascal/n-queens-problem.pascal b/Task/N-queens-problem/Pascal/n-queens-problem.pascal new file mode 100644 index 0000000000..617a48c86c --- /dev/null +++ b/Task/N-queens-problem/Pascal/n-queens-problem.pascal @@ -0,0 +1,81 @@ +program queens; + +const l=16; + +var i,j,k,m,n,p,q,r,y,z: integer; + a,s: array[1..l] of integer; + u: array[1..4*l-2] of integer; + +label L3,L4,L5,L6,L7,L8,L9,L10; + +begin + for i:=1 to l do a[i]:=i; + for i:=1 to 4*l-2 do u[i]:=0; + for n:=1 to l do + begin + m:=0; + i:=1; + r:=2*n-1; + goto L4; +L3: + s[i]:=j; + u[p]:=1; + u[q+r]:=1; + i:=i+1; +L4: + if i>n then goto L8; + j:=i; +L5: + z:=a[i]; + y:=a[j]; + p:=i-y+n; + q:=i+y-1; + a[i]:=y; + a[j]:=z; + if (u[p]=0) and (u[q+r]=0) then goto L3; +L6: + j:=j+1; + if j<=n then goto L5; +L7: + j:=j-1; + if j=i then goto L9; + z:=a[i]; + a[i]:=a[j]; + a[j]:=z; + goto L7; +L8: + m:=m+1; + { uncomment the following to print solutions } + { write(n,' ',m,':'); + for k:=1 to n do write(' ',a[k]); + writeln; } +L9: + i:=i-1; + if i=0 then goto L10; + p:=i-a[i]+n; + q:=i+a[i]-1; + j:=s[i]; + u[p]:=0; + u[q+r]:=0; + goto L6; +L10: + writeln(n,' ',m); + end; +end. + +{ 1 1 + 2 0 + 3 0 + 4 2 + 5 10 + 6 4 + 7 40 + 8 92 + 9 352 + 10 724 + 11 2680 + 12 14200 + 13 73712 + 14 365596 + 15 2279184 + 16 14772512 } diff --git a/Task/N-queens-problem/Perl-6/n-queens-problem.pl6 b/Task/N-queens-problem/Perl-6/n-queens-problem.pl6 new file mode 100644 index 0000000000..ab785edb6c --- /dev/null +++ b/Task/N-queens-problem/Perl-6/n-queens-problem.pl6 @@ -0,0 +1,30 @@ +sub MAIN($N = 8) { + sub collision(@field, $row) { + for ^$row -> $i { + my $distance = @field[$i] - @field[$row]; + return 1 if $distance == any(0, $row - $i, $i - $row); + } + 0; + } + sub search(@field is rw, $row) { + if $row == $N { + return @field; + } else { + for ^$N -> $i { + @field[$row] = $i; + if !collision(@field, $row) { + my @r = search(@field, $row + 1) and return @r; + } + } + } + Nil; + } + for 0 .. $N / 2 { + if my @f = search [$_], 1 { + say ~@f; + last; + } + } +} +# output: +0 4 7 5 2 6 1 3 diff --git a/Task/N-queens-problem/Perl/n-queens-problem.pl b/Task/N-queens-problem/Perl/n-queens-problem.pl new file mode 100644 index 0000000000..b5b1ef3a09 --- /dev/null +++ b/Task/N-queens-problem/Perl/n-queens-problem.pl @@ -0,0 +1,41 @@ +my ($board_size, @occupied, @past, @solutions); + +sub try_column { + my ($depth, @diag) = shift; + if ($depth == $board_size) { + push @solutions, "@past\n"; + return; + } + + # @diag: marks cells diagonally attackable by any previous queens. + # Here it's pre-allocated to double size just so we don't need + # to worry about negative indices. + $#diag = 2 * $board_size; + for (0 .. $#past) { + $diag[ $past[$_] + $depth - $_ ] = 1; + $diag[ $past[$_] - $depth + $_ ] = 1; + } + + for my $row (0 .. $board_size - 1) { + next if $occupied[$row] || $diag[$row]; + + # @past: row numbers of previous queens + # @occupied: rows already used. This gets inherited by each + # recursion so we don't need to repeatedly look them up + push @past, $row; + $occupied[$row] = 1; + + try_column($depth + 1); + + # clean up, for next recursion + $occupied[$row] = 0; + pop @past; + } +} + +$board_size = 12; # takes a minute or so, 14,200 solutions +try_column(0); + +local $" = "\n"; +print @solutions; +print "total ", scalar(@solutions), " solutions\n"; diff --git a/Task/N-queens-problem/PicoLisp/n-queens-problem-1.l b/Task/N-queens-problem/PicoLisp/n-queens-problem-1.l new file mode 100644 index 0000000000..fd6fe9eb6b --- /dev/null +++ b/Task/N-queens-problem/PicoLisp/n-queens-problem-1.l @@ -0,0 +1,11 @@ +(load "@lib/simul.l") # for 'permute' + +(de queens (N) + (let (R (range 1 N) Cnt 0) + (for L (permute (range 1 N)) + (when + (= N # from the Python solution + (length (uniq (mapcar + L R))) + (length (uniq (mapcar - L R))) ) + (inc 'Cnt) ) ) + Cnt ) ) diff --git a/Task/N-queens-problem/PicoLisp/n-queens-problem-2.l b/Task/N-queens-problem/PicoLisp/n-queens-problem-2.l new file mode 100644 index 0000000000..071108d6d4 --- /dev/null +++ b/Task/N-queens-problem/PicoLisp/n-queens-problem-2.l @@ -0,0 +1,16 @@ +(de queens (N) + (let (R (range 1 N) L (copy R) X L Cnt 0) + (recur (X) # Permute + (if (cdr X) + (do (length X) + (recurse (cdr X)) + (rot X) ) + (or + (seek # Direct check for duplicates + '((L) (member (car L) (cdr L))) + (mapcar + L R) ) + (seek + '((L) (member (car L) (cdr L))) + (mapcar - L R) ) + (inc 'Cnt) ) ) ) + Cnt ) ) diff --git a/Task/N-queens-problem/PowerBASIC/n-queens-problem.powerbasic b/Task/N-queens-problem/PowerBASIC/n-queens-problem.powerbasic new file mode 100644 index 0000000000..6c84d18c86 --- /dev/null +++ b/Task/N-queens-problem/PowerBASIC/n-queens-problem.powerbasic @@ -0,0 +1,40 @@ + defint a-z + option base 1 + input "n=",n + dim a(n), s(n), u(4*n-2) + for i=1 to n: a(i)=i: next + for i=1 to 4*n-2: u(i)=0: next + m=0 + i=1 + r=2*n-1 + goto 20 +10 s(i)=j + u(p)=1 + u(q+r)=1 + incr i +20 if i>n goto 60 + j=i +30 z=a(i) + y=a(j) + p=i-y+n + q=i+y-1 + a(i)=y + a(j)=z + if u(p)=0 and u(q+r)=0 goto 10 +40 incr j + if j<=n goto 30 +50 decr j + if j=i goto 70 + swap a(i),a(j) + goto 50 +60 incr m + for k=1 to n: print a(k);: next: print +70 decr i + if i=0 goto 80 + p=i-a(i)+n + q=i+a(i)-1 + j=s(i) + u(p)=0 + u(q+r)=0 + goto 40 +80 print m diff --git a/Task/N-queens-problem/Prolog/n-queens-problem-1.pro b/Task/N-queens-problem/Prolog/n-queens-problem-1.pro new file mode 100644 index 0000000000..0672e13bcc --- /dev/null +++ b/Task/N-queens-problem/Prolog/n-queens-problem-1.pro @@ -0,0 +1,21 @@ +solution([]). + +solution([X/Y|Others]) :- + solution(Others), + member(Y, [1,2,3,4,5,6,7,8]), + noattack(X/Y, Others). + +noattack(_,[]). + +noattack(X/Y,[X1/Y1|Others]) :- + Y =\= Y1, + Y1 - Y =\= X1 - X, + Y1 - Y =\= X - X1, + noattack(X/Y,Others). + +member(Item,[Item|Rest]). + +member(Item,[First|Rest]) :- + member(Item,Rest). + +template([1/Y1,2/Y2,3/Y3,4/Y4,5/Y5,6/Y6,7/Y7,8/Y8]). diff --git a/Task/N-queens-problem/Prolog/n-queens-problem-2.pro b/Task/N-queens-problem/Prolog/n-queens-problem-2.pro new file mode 100644 index 0000000000..e8086d7e54 --- /dev/null +++ b/Task/N-queens-problem/Prolog/n-queens-problem-2.pro @@ -0,0 +1,28 @@ +solution(Queens) :- + permutation([1,2,3,4,5,6,7,8], Queens), + safe(Queens). + +permutation([],[]). + +permutation([Head|Tail],PermList) :- + permutation(Tail,PermTail), + del(Head,PermList,PermTail). + +del(Item,[Item|List],List). + +del(Item,[First|List],[First|List1]) :- + del(Item,List,List1). + +safe([]). + +safe([Queen|Others]) :- + safe(Others), + noattack(Queen,Others,1). + +noattack(_,[],_). + +noattack(Y,[Y1|Ylist],Xdist) :- + Y1-Y=\=Xdist, + Y-Y1=\=Xdist, + Dist1 is Xdist + 1, + noattack(Y,Ylist,Dist1). diff --git a/Task/N-queens-problem/Prolog/n-queens-problem-3.pro b/Task/N-queens-problem/Prolog/n-queens-problem-3.pro new file mode 100644 index 0000000000..37c6a2ec42 --- /dev/null +++ b/Task/N-queens-problem/Prolog/n-queens-problem-3.pro @@ -0,0 +1,20 @@ +solution(Ylist) :- + sol(Ylist,[1,2,3,4,5,6,7,8], + [1,2,3,4,5,6,7,8], + [-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7], + [2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]). + +sol([],[],[],Du,Dv). + +sol([Y|Ylist],[X|Dx1],Dy,Du,Dv) :- + del(Y,Dy,Dy1), + U is X-Y, + del(U,Du,Du1), + V is X+Y, + del(V,Dv,Dv1), + sol(Ylist,Dx1, Dy1,Du1,Dv1). + +del(Item,[Item|List],List). + +del(Item,[First|List],[First|List1]) :- + del(Item,List,List1). diff --git a/Task/N-queens-problem/PureBasic/n-queens-problem.purebasic b/Task/N-queens-problem/PureBasic/n-queens-problem.purebasic new file mode 100644 index 0000000000..7909b92f48 --- /dev/null +++ b/Task/N-queens-problem/PureBasic/n-queens-problem.purebasic @@ -0,0 +1,80 @@ +Global solutions + +Procedure showBoard(Array queenCol(1)) + Protected row, column, n = ArraySize(queenCol()) + + PrintN(" Solution " + Str(solutions)) + For row = 0 To n + For column = 0 To n + If queenCol(row) = column + Print("|Q") + Else + Print("| ") + EndIf + Next + PrintN("|") + Next +EndProcedure + +Macro advanceIfPossible() + x + 1 + While x <= n And columns(x): x + 1: Wend + If x > n + ProcedureReturn #False ;backtrack + EndIf +EndMacro + +Procedure placeQueens(Array queenCol(1), Array columns(1), row = 0) + Protected n = ArraySize(queenCol()) + + If row > n + solutions + 1 + showBoard(queenCol()) + ProcedureReturn #False ;backtrack + EndIf + + Protected x, queen, passed + While columns(x): x + 1: Wend + + ;place a new queen in one of the available columns + Repeat + passed = #True + For queen = 0 To row - 1 + If ((queenCol(queen) - x) = (queen - row)) Or ((queenCol(queen) - x) = -(queen - row)) + advanceIfPossible() + passed = #False + Break ;ForNext loop + EndIf + Next + + If passed + queenCol(row) = x: columns(x) = 1 + If Not placeQueens(queenCol(), columns(), row + 1) + columns(x) = 0 + advanceIfPossible() + EndIf + EndIf + ForEver +EndProcedure + +Procedure queens(n) + If n > 0 + Dim queenCol(n - 1) + Dim columns(n - 1) + placeQueens(queenCol(), columns()) + EndIf +EndProcedure + +If OpenConsole() + Define i + For i = 1 To 12 + solutions = 0 + queens(i) + PrintN(#CRLF$ + Str(solutions) + " solutions found for " + Str(i) + "-queens.") + Input() + Next + + Print(#CRLF$ + "Press ENTER to exit") + Input() + CloseConsole() +EndIf diff --git a/Task/N-queens-problem/Python/n-queens-problem-1.py b/Task/N-queens-problem/Python/n-queens-problem-1.py new file mode 100644 index 0000000000..6cad63b0c7 --- /dev/null +++ b/Task/N-queens-problem/Python/n-queens-problem-1.py @@ -0,0 +1,8 @@ +from itertools import permutations + +n = 8 +cols = range(n) +for vec in permutations(cols): + if n == len(set(vec[i]+i for i in cols)) \ + == len(set(vec[i]-i for i in cols)): + print ( vec ) diff --git a/Task/N-queens-problem/Python/n-queens-problem-2.py b/Task/N-queens-problem/Python/n-queens-problem-2.py new file mode 100644 index 0000000000..8510f75472 --- /dev/null +++ b/Task/N-queens-problem/Python/n-queens-problem-2.py @@ -0,0 +1,2 @@ +def board(vec): + print ("\n".join('.' * i + 'Q' + '.' * (n-i-1) for i in vec) + "\n===\n") diff --git a/Task/N-queens-problem/Python/n-queens-problem-3.py b/Task/N-queens-problem/Python/n-queens-problem-3.py new file mode 100644 index 0000000000..6786a5d457 --- /dev/null +++ b/Task/N-queens-problem/Python/n-queens-problem-3.py @@ -0,0 +1,17 @@ +# From: http://wiki.python.org/moin/SimplePrograms, with permission from the author, Steve Howell +BOARD_SIZE = 8 + +def under_attack(col, queens): + return col in queens or \ + any(abs(col - x) == len(queens)-i for i,x in enumerate(queens)) + +def solve(n): + solutions = [[]] + for row in range(n): + solutions = [solution+[i+1] + for solution in solutions + for i in range(BOARD_SIZE) + if not under_attack(i+1, solution)] + return solutions + +for answer in solve(BOARD_SIZE): print(list(enumerate(answer, start=1))) diff --git a/Task/N-queens-problem/Python/n-queens-problem-4.py b/Task/N-queens-problem/Python/n-queens-problem-4.py new file mode 100644 index 0000000000..f0c60851c3 --- /dev/null +++ b/Task/N-queens-problem/Python/n-queens-problem-4.py @@ -0,0 +1,19 @@ +BOARD_SIZE = 8 + +def under_attack(col, queens): + return col in queens or \ + any(abs(col - x) == len(queens)-i for i,x in enumerate(queens)) + +def solve(n): + solutions = [[]] + for row in range(n): + solutions = (solution+[i+1] + for solution in solutions # first for clause is evaluated immediately, + # so "solutions" is correctly captured + for i in range(BOARD_SIZE) + if not under_attack(i+1, solution)) + return solutions + +answers = solve(BOARD_SIZE) +first_answer = next(answers) +print(list(enumerate(first_answer, start=1))) diff --git a/Task/N-queens-problem/R/n-queens-problem.r b/Task/N-queens-problem/R/n-queens-problem.r new file mode 100644 index 0000000000..5d8d5b3923 --- /dev/null +++ b/Task/N-queens-problem/R/n-queens-problem.r @@ -0,0 +1,28 @@ +# Brute force, see the "Permutations" page for the next.perm function +safe <- function(p) { + n <- length(p) + for(i in 1:(n-1)) { + for(j in (i+1):n) { + if(abs(p[j] - p[i]) == abs(j - i)) return(FALSE) + } + } + return(TRUE) +} + +queens <- function(n) { + p <- 1:n + k <- 0 + while(!is.null(p)) { + if(safe(p)) { + cat(p,"\n") + k <- k + 1 + } + p <- next.perm(p) + } + return(k) +} + +queens(8) +# 1 5 8 6 3 7 2 4 +# ... +# 92 diff --git a/Task/N-queens-problem/REXX/n-queens-problem.rexx b/Task/N-queens-problem/REXX/n-queens-problem.rexx new file mode 100644 index 0000000000..446ee6533a --- /dev/null +++ b/Task/N-queens-problem/REXX/n-queens-problem.rexx @@ -0,0 +1,64 @@ +/*REXX program place N queens on a NxN chessboard (the 8 queens problem)*/ +parse arg N . /*get board size arg (if any). */ +if N=='' then N=8 /*No argument? Use the default.*/ +file=1; rank=1; q=0 /*starting place, # of queens. */ +@.=0; !=left('', 9* (N<18)) /*define empty board, indentation*/ +/*═════════════════════════════════════find solution: N queens problem.*/ + do while qN; rank=rank-1 + if rank==0 then call noSol + do j=1 for N + if @.j.rank then do; file=j; @.file.rank=0 + q=q-1; file=j+1 + leave /*j*/ + end + end /*j*/ + end /*do while file>N*/ + end /*else do*/ + end /*while qn then goto L80; +j=i; +L50: +z=a(i); +y=a(j); +p=i-y+n; +q=i+y-1; +a(i)=y; +a(j)=z; +if u(p)=0 and u(q+r)=0 then goto L30; +L60: +j=j+1; +if j<=n then goto L50; +L70: +j=j-1; +if j=i then goto L90; +z=a(i); +a(i)=a(j); +a(j)=z; +goto L70; +L80: +m=m+1; +output; +L90: +i=i-1; +if i=0 then goto L100; +p=i-a(i)+n; +q=i+a(i)-1; +j=s(i); +u(p)=0; +u(q+r)=0; +goto L60; +L100: +put n m; +keep p1-p8; +run; diff --git a/Task/N-queens-problem/SNOBOL4/n-queens-problem.sno b/Task/N-queens-problem/SNOBOL4/n-queens-problem.sno new file mode 100644 index 0000000000..2b2794226f --- /dev/null +++ b/Task/N-queens-problem/SNOBOL4/n-queens-problem.sno @@ -0,0 +1,23 @@ +* N queens problem +* Set N to the desired number. The program prints out all solution boards. + N = 5 + NM1 = N - 1; NP1 = N + 1; NSZ = N * NP1; &STLIMIT = 10 ** 9; &ANCHOR = 1 + DEFINE('SOLVE(B)I') +* This pattern tests if the first queen attacks any of the others: + TEST = BREAK('Q') 'Q' (ARBNO(LEN(N) '-') LEN(N) 'Q' ++ | ARBNO(LEN(NP1) '-') LEN(NP1) 'Q' ++ | ARBNO(LEN(NM1) '-') LEN(NM1) 'Q') + P = LEN(NM1) . X LEN(1); L = 'Q' DUPL('-',NM1) ' ' + SOLVE() :(END) +SOLVE EQ(SIZE(B),NSZ) :S(PRINT) +* Add another row with a queen: + B = L B +LOOP I = LT(I,N) I + 1 :F(RETURN) + B TEST :S(NEXT) + SOLVE(B) +* Try queen in next square: +NEXT B P = '-' X :(LOOP) +PRINT SOLUTION = SOLUTION + 1 + OUTPUT = 'Solution number ' SOLUTION ' is:' +PRTLOOP B LEN(NP1) . OUTPUT = :S(PRTLOOP)F(RETURN) +END diff --git a/Task/N-queens-problem/Scala/n-queens-problem.scala b/Task/N-queens-problem/Scala/n-queens-problem.scala new file mode 100644 index 0000000000..3052880f2e --- /dev/null +++ b/Task/N-queens-problem/Scala/n-queens-problem.scala @@ -0,0 +1,20 @@ +case class Pos(row: Int, column: Int) { + def sameRow(p: Pos) = row == p.row + def sameColumn(p: Pos) = column == p.column + def sameDiag(p: Pos) = (p.column - column).abs == (p.row - row).abs + def illegal(p: Pos) = sameRow(p) || sameColumn(p) || sameDiag(p) + def legal(p: Pos) = !illegal(p) +} + +def rowSet(size: Int, row: Int) = Iterator.tabulate(size)(column => Pos(row, column)) + +def expand(solutions: Iterator[List[Pos]], size: Int, row: Int) = + for { + solution <- solutions + pos <- rowSet(size, row) + if solution forall (_ legal pos) + } yield pos :: solution + +def seed(size: Int) = rowSet(size, 0) map (sol => List(sol)) + +def solve(size: Int) = (1 until size).foldLeft(seed(size)) (expand(_, size, _)) diff --git a/Task/N-queens-problem/Standard-ML/n-queens-problem.ml b/Task/N-queens-problem/Standard-ML/n-queens-problem.ml new file mode 100644 index 0000000000..a543ee05bd --- /dev/null +++ b/Task/N-queens-problem/Standard-ML/n-queens-problem.ml @@ -0,0 +1,39 @@ +(* + * val threat : (int * int) -> (int * int) -> bool + * Returns true iff the queens at the given positions threaten each other + *) +fun threat (x, y) (x', y') = + x = x' orelse y = y' orelse abs(x - x') = abs(y - y'); + +(* + * val conflict : (int * int) -> (int * int) list -> bool + * Returns true if there exists a conflict with the position and the list of queens. + *) +fun conflict pos = List.exists (threat pos); + +(* + * val addqueen : (int * int * (int * int) list * (unit -> (int * int) list option)) -> (int * int) list option + * Returns either NONE in the case that no solution exists or SOME(l) where l is a list of positions making up the solution. + *) +fun addqueen(i, n, qs, fc) = + let + fun try j = + if j > n then fc() + else if (conflict (i, j) qs) then try (j + 1) + else if i = n then SOME((i, j)::qs) + else addqueen(i + 1, n, (i,j)::qs, fn() => try (j + 1)) + in + try 1 + end; + +(* + * val queens : int -> (int * int) list option + * Given the board dimension n, returns a solution for the n-queens problem. + *) +fun queens(n) = addqueen(1, n, [], fn () => NONE); + +(* SOME [(8,4),(7,2),(6,7),(5,3),(4,6),(3,8),(2,5),(1,1)] *) +queens(8); + +(* NONE *) +queens(2); diff --git a/Task/N-queens-problem/SystemVerilog/n-queens-problem.v b/Task/N-queens-problem/SystemVerilog/n-queens-problem.v new file mode 100644 index 0000000000..8e8d303350 --- /dev/null +++ b/Task/N-queens-problem/SystemVerilog/n-queens-problem.v @@ -0,0 +1,37 @@ +program N_queens; + + parameter SIZE_LOG2 = 3; + parameter SIZE = 1 << SIZE_LOG2; + + `define ABS_DIFF(a,b) (a>b?a-b:b-a) + + class board; + rand bit [SIZE_LOG2-1:0] row[SIZE]; + + constraint rook_moves { + foreach (row[i]) foreach (row[j]) if (i < j) { + row[i] != row[j]; + } + } + + constraint diagonal_moves { + foreach (row[i]) foreach (row[j]) if (i < j) { + `ABS_DIFF(row[i], row[j]) != `ABS_DIFF(i,j); + } + } + + function void next; + randomize; + foreach (row[i]) begin + automatic bit [SIZE-1:0] x = 1 << row[i]; + $display( " %b", x ); + end + $display("--"); + endfunction + + endclass + + board b = new; + initial repeat(1) b.next; + +endprogram diff --git a/Task/N-queens-problem/Tcl/n-queens-problem.tcl b/Task/N-queens-problem/Tcl/n-queens-problem.tcl new file mode 100644 index 0000000000..ab9f2c8d3a --- /dev/null +++ b/Task/N-queens-problem/Tcl/n-queens-problem.tcl @@ -0,0 +1,47 @@ +package require Tcl 8.5 + +proc unsafe {y} { + global b + set x [lindex $b $y] + for {set i 1} {$i <= $y} {incr i} { + set t [lindex $b [expr {$y - $i}]] + if {$t==$x || $t==$x-$i || $t==$x+$i} { + return 1 + } + } + return 0 +} + +proc putboard {} { + global b s N + puts "\n\nSolution #[incr s]" + for {set y 0} {$y < $N} {incr y} { + for {set x 0} {$x < $N} {incr x} { + puts -nonewline [expr {[lindex $b $y] == $x ? "|Q" : "|_"}] + } + puts "|" + } +} + +proc main {n} { + global b N + set N $n + set b [lrepeat $N 0] + set y 0 + lset b 0 -1 + while {$y >= 0} { + lset b $y [expr {[lindex $b $y] + 1}] + while {[lindex $b $y] < $N && [unsafe $y]} { + lset b $y [expr {[lindex $b $y] + 1}] + } + if {[lindex $b $y] >= $N} { + incr y -1 + } elseif {$y < $N-1} { + lset b [incr y] -1; + } else { + putboard + } + } +} + +main [expr {$argc ? int(0+[lindex $argv 0]) : 8}] diff --git a/Task/N-queens-problem/Ursala/n-queens-problem.ursala b/Task/N-queens-problem/Ursala/n-queens-problem.ursala new file mode 100644 index 0000000000..aec78a03b3 --- /dev/null +++ b/Task/N-queens-problem/Ursala/n-queens-problem.ursala @@ -0,0 +1,18 @@ +#import std +#import nat + +remove_reflections = ^D(length@ht,~&); ~&K2hlPS+ * ^lrNCCs/~&r difference*D +remove_rotations = ~&K2hlrS2S+ * num; ~&srlXSsPNCCs + +#executable <'par',''> +#optimize+ + +queens = + +%np+~command.options.&h.keyword.&iNC; -+ + ~&iNC+ file$[contents: --<''>+ mat` *+ %nP*=*], + remove_rotations+ remove_reflections+ ~&rSSs+ nleq-<&l*rFlhthPXPSPS, + ~&i&& ~&lNrNCXX; ~&rr->rl ^/~&l ~&lrrhrSiF4E?/~&rrlPlCrtPX @r ^|/~& ^|T\~& -+ + -<&l^|*DlrTS/~& ~&iiDlSzyCK9hlPNNXXtCS, + ^jrX/~& @rZK20lrpblPOlrEkPK13lhPK2 ~&i&& nleq$-&lh+-, + ^/~&NNXS+iota -<&l+ ~&plll2llr2lrPrNCCCCNXS*=irSxPSp+ ^H/block iota; *iiK0 ^/~& sum+- diff --git a/Task/N-queens-problem/XPL0/n-queens-problem.xpl0 b/Task/N-queens-problem/XPL0/n-queens-problem.xpl0 new file mode 100644 index 0000000000..d16a7e45ca --- /dev/null +++ b/Task/N-queens-problem/XPL0/n-queens-problem.xpl0 @@ -0,0 +1,57 @@ +def N=8; \board size (NxN) +int R, C; \row and column of board +char B(N,N); \board +include c:\cxpl\codes; + +proc Try; \Try adding a queen to the board +int R; \row, for each level of recursion + + func Okay; + \Returns 'true' if no row, column, or diagonal from square R,C has a queen + int I; + [for I:= 0 to N-1 do + [if B(I,C) then return false; \row is occupied + if B(R,I) then return false; \column is occupied + if R+I=0 & C-I>=0 then + if B(R-I, C-I) then return false; \diagonal up left + if R-I>=0 & C+I=0 then + if B(R+I, C-I) then return false; \diagonal down left + ]; + return true; + ]; \Okay + +[ \Try +if C>=N then + [for R:= 0 to N-1 do \display solution + [ChOut(0, ^ ); \(avoids scrolling up a color) + for C:= 0 to N-1 do + [Attrib(if (R|C)&1 then $0F else $4F); \checkerboard pattern + ChOut(6, if B(R,C) then $F2 else ^ ); \cute queen symbol + ChOut(6, if B(R,C) then $F3 else ^ ); + ]; + CrLf(0); + ]; + exit; \one solution is enough + ]; +for R:= 0 to N-1 do + [if Okay(R,C) then \a queen can be placed here + [B(R,C):= true; \ so do it + C:= C+1; \move to next column + Try; \ and try from there + C:= C-1; \didn't work: backup + B(R,C):= false; \undo queen placement + ]; + ]; +]; \Try + + +[for R:= 0 to N-1 do \clear the board + for C:= 0 to N-1 do + B(R,C):= false; +C:= 0; \start at left column +Try; +] diff --git a/Task/N-queens-problem/XSLT/n-queens-problem-1.xslt b/Task/N-queens-problem/XSLT/n-queens-problem-1.xslt new file mode 100644 index 0000000000..77f2447ed7 --- /dev/null +++ b/Task/N-queens-problem/XSLT/n-queens-problem-1.xslt @@ -0,0 +1,5 @@ +15863724 +16837425 +... 88 lines omitted ... +83162574 +84136275 diff --git a/Task/N-queens-problem/XSLT/n-queens-problem-2.xslt b/Task/N-queens-problem/XSLT/n-queens-problem-2.xslt new file mode 100644 index 0000000000..da8135ac38 --- /dev/null +++ b/Task/N-queens-problem/XSLT/n-queens-problem-2.xslt @@ -0,0 +1,126 @@ + + + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + +
+    
+    
+      
+    
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + this['node-set'] = function (x) { + return x; + } + + +
diff --git a/Task/N-queens-problem/Xanadu/n-queens-problem.xanadu b/Task/N-queens-problem/Xanadu/n-queens-problem.xanadu new file mode 100644 index 0000000000..9ad2253b56 --- /dev/null +++ b/Task/N-queens-problem/Xanadu/n-queens-problem.xanadu @@ -0,0 +1,69 @@ +int abs(i: int) { + if (i >= 0) return i; else return -i; +} + +unit print_dots(n: int) { + while (n > 0) { print_string("."); n = n - 1; } + return; +} + +{size:int | 0 < size} +unit print_board (board[size]: int, size: int(size)) { + var: int n, row;; + + invariant: [i:nat] (row: int(i)) + for (row = 0; row < size; row = row + 1) { + n = board[row]; + print_dots(n-1); + print_string("Q"); + print_dots(size - n); + print_newline(); + } + print_newline(); + return; +} + +{size:int, j:int | 0 <= j < size} +bool test (j: int(j), board[size]: int) { + var: int diff, i, qi, qj;; + + qj = board[j]; + + invariant: [i:nat] (i: int(i)) + for (i = 0; i < j; i = i + 1) { + qi = board[i]; diff = abs (qi - qj); + if (diff == 0) { return false; } + else { if (diff == j - i) return false; } + } + return true; +} + +{size:int | 0 < size} +nat queen(size: int(size)) { + var: int board[], next, row; nat count;; + + count = 0; row = 0; board = alloc(size, 0); + + invariant: [n:nat | n < size] (row: int(n)) + while (true) { + next = board[row]; next = next + 1; + if (next > size) { + if (row == 0) break; else { board[row] = 0; row = row - 1; } + } else { + board[row] = next; + if (test(row, board)) { + row = row + 1; + if (row == size) { + count = count + 1; + print_board(board, size); + row = row - 1; + } + } + } + } + return count; +} + +int main () { + return queen (8); +} diff --git a/Task/Named-parameters/0DESCRIPTION b/Task/Named-parameters/0DESCRIPTION new file mode 100644 index 0000000000..1956d77502 --- /dev/null +++ b/Task/Named-parameters/0DESCRIPTION @@ -0,0 +1,13 @@ +{{omit from|BBC BASIC}} +Create a function which takes in a number of arguments which are specified by name rather than (necessarily) position, and show how to call the function. If the language supports reordering the arguments or optionally omitting some of them, note this. + +'''Note:''' +: Named parameters relies on being able to use the names given to function parameters when the function is defined, when assigning arguments when the function is called. +: For example, if f a function were to be defined as define func1( paramname1, paramname2); then it could be called normally as func1(argument1, argument2) and in the called function paramname1 would be associated with argument1 and paramname2 with argument2. +: func1 '''must also be able to be called in a way that visually binds each parameter to its respective argument, irrespective of argument order''', for example: func1(paramname2=argument2, paramname1=argument1) which ''explicitly'' makes the same parameter/argument bindings as before. +: Named parameters are often a feature of languages used in safety critical areas such as [[wp:Verilog|Verilog]] and [[wp:VHDL|VHDL]]. + +'''See also:''' +* [[Varargs]] +* [[Optional parameters]] +* [[wp:Named parameter|Wikipedia: Named parameter]] diff --git a/Task/Named-parameters/1META.yaml b/Task/Named-parameters/1META.yaml new file mode 100644 index 0000000000..659c8686af --- /dev/null +++ b/Task/Named-parameters/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Basic language learning diff --git a/Task/Named-parameters/ALGOL-68/named-parameters.alg b/Task/Named-parameters/ALGOL-68/named-parameters.alg new file mode 100644 index 0000000000..f76c080aef --- /dev/null +++ b/Task/Named-parameters/ALGOL-68/named-parameters.alg @@ -0,0 +1,28 @@ +#!/usr/local/bin/a68g --script # + +MODE OPTNAME = STRUCT(STRING name), + OPTSPECIES = STRUCT(STRING species), + OPTBREED = STRUCT(STRING breed), + OWNER=STRUCT(STRING first name, middle name, last name); + +# due to the Yoneda ambiguity simple arguments must have an unique operator defined # +OP NAME = (STRING name)OPTNAME: (OPTNAME opt; name OF opt := name; opt), + SPECIES = (STRING species)OPTSPECIES: (OPTSPECIES opt; species OF opt := species; opt), + BREED = (STRING breed)OPTBREED: (OPTBREED opt; breed OF opt := breed; opt); + +PROC print pet = ([]UNION(OPTNAME,OPTSPECIES,OPTBREED,OWNER) option)VOID: ( + STRING name:="Rex", species:="Dinosaur", breed:="Tyrannosaurus"; # Defaults # + OWNER owner := ("George","W.","Bush"); + FOR i TO UPB option DO + CASE option[i] IN + (OPTNAME option): name := name OF option, + (OPTSPECIES option): species := species OF option, + (OPTBREED option): breed := breed OF option, + (OWNER option): owner := option + ESAC + OD; + printf(($gx$,"Details: a",breed,species,"named",name,"owned by",owner,$l$)) +); + +print pet((NAME "Mike", SPECIES "Dog", BREED "Irish Setter", OWNER("Harry", "S.", "Truman"))); +print pet(()) diff --git a/Task/Named-parameters/Ada/named-parameters-1.ada b/Task/Named-parameters/Ada/named-parameters-1.ada new file mode 100644 index 0000000000..9d0794a7c5 --- /dev/null +++ b/Task/Named-parameters/Ada/named-parameters-1.ada @@ -0,0 +1 @@ +procedure Foo (Arg_1 : Integer; Arg_2 : Float := 0.0); diff --git a/Task/Named-parameters/Ada/named-parameters-2.ada b/Task/Named-parameters/Ada/named-parameters-2.ada new file mode 100644 index 0000000000..fa8716bd6d --- /dev/null +++ b/Task/Named-parameters/Ada/named-parameters-2.ada @@ -0,0 +1,4 @@ +Foo (1, 0.0); +Foo (1); +Foo (Arg_2 => 0.0, Arg_1 => 1); +Foo (Arg_1 => 1); diff --git a/Task/Named-parameters/AppleScript/named-parameters-1.applescript b/Task/Named-parameters/AppleScript/named-parameters-1.applescript new file mode 100644 index 0000000000..d1362a7af8 --- /dev/null +++ b/Task/Named-parameters/AppleScript/named-parameters-1.applescript @@ -0,0 +1,9 @@ +on getName(x) + set {firstName, lastName} to {"?", "?"} + try + set firstName to x's firstName + end try + try + set lastName to x's lastName + end try +end getName diff --git a/Task/Named-parameters/AppleScript/named-parameters-2.applescript b/Task/Named-parameters/AppleScript/named-parameters-2.applescript new file mode 100644 index 0000000000..1ed7d29e15 --- /dev/null +++ b/Task/Named-parameters/AppleScript/named-parameters-2.applescript @@ -0,0 +1,4 @@ +getName({firstName:"John", lastName:"Doe"}) +--> Returns: "John, Doe" +getName({lastName:"Doe"}) +--> Returns: "?, Doe" diff --git a/Task/Named-parameters/AutoHotkey/named-parameters.ahk b/Task/Named-parameters/AutoHotkey/named-parameters.ahk new file mode 100644 index 0000000000..4c53f8cb0d --- /dev/null +++ b/Task/Named-parameters/AutoHotkey/named-parameters.ahk @@ -0,0 +1,12 @@ +MyFunc( "Val=0, w=1024, Text=The Quick Brown Fox, newVar=I'm New" ) + +MyFunc( _overrides="" ) { + Static x=5, y=5, w=100, h=100, Count + Name:="AutoHotkey", Type:="Scripting", Text:="qwerty", Val:=True + + Loop, Parse, _overrides,`,=, %A_Space% ; Override routine for Local/Static variables + A_Index & 1 ? (_:=A_LoopField) : (%_%:=A_LoopField) + +Listvars + WinWaitClose, %A_ScriptFullPath% +} diff --git a/Task/Named-parameters/C++/named-parameters-1.cpp b/Task/Named-parameters/C++/named-parameters-1.cpp new file mode 100644 index 0000000000..af208091e1 --- /dev/null +++ b/Task/Named-parameters/C++/named-parameters-1.cpp @@ -0,0 +1,27 @@ +class foo_params{ + friend void foo(foo_params p); +public: + foo_params(int r): + required_param_(r), + optional_x_(0), + optional_y_(1), + optional_z_(3.1415) + {} + foo_params& x(int i){ + optional_x_=i; + return *this; + } + foo_params& y(int i){ + optional_y_=i; + return *this; + } + foo_params& z(float f){ + optional_z_=f; + return *this; + } +private: + int required_param_; + int optional_x_; + int optional_y_; + float optional_z_; +}; diff --git a/Task/Named-parameters/C++/named-parameters-2.cpp b/Task/Named-parameters/C++/named-parameters-2.cpp new file mode 100644 index 0000000000..bb40d61f66 --- /dev/null +++ b/Task/Named-parameters/C++/named-parameters-2.cpp @@ -0,0 +1 @@ +void foo(foo_params p){ . . .} diff --git a/Task/Named-parameters/C++/named-parameters-3.cpp b/Task/Named-parameters/C++/named-parameters-3.cpp new file mode 100644 index 0000000000..881904b60d --- /dev/null +++ b/Task/Named-parameters/C++/named-parameters-3.cpp @@ -0,0 +1 @@ +foo(foo_params(42).x(7).z(23.54)); diff --git a/Task/Named-parameters/C++/named-parameters-4.cpp b/Task/Named-parameters/C++/named-parameters-4.cpp new file mode 100644 index 0000000000..37c2025e3c --- /dev/null +++ b/Task/Named-parameters/C++/named-parameters-4.cpp @@ -0,0 +1,26 @@ +#include +#include +#include + +BOOST_PARAMETER_NAME(foo) +BOOST_PARAMETER_NAME(bar) +BOOST_PARAMETER_NAME(baz) +BOOST_PARAMETER_NAME(bonk) + +BOOST_PARAMETER_FUNCTION( + (int), // the return type of the function, the parentheses are required. + function_with_named_parameters, // the name of the function. + tag, // part of the deep magic. If you use BOOST_PARAMETER_NAME you need to put "tag" here. + (required // names and types of all required parameters, parentheses are required. + (foo, (int)) + (bar, (float)) + ) + (optional // names, types, and default values of all optional parameters. + (baz, (bool) , false) + (bonk, (std::string), "default value") + ) +) +{ + if (baz && (bar > 1.0)) return foo; + return bonk.size(); +} diff --git a/Task/Named-parameters/C++/named-parameters-5.cpp b/Task/Named-parameters/C++/named-parameters-5.cpp new file mode 100644 index 0000000000..752f677680 --- /dev/null +++ b/Task/Named-parameters/C++/named-parameters-5.cpp @@ -0,0 +1,5 @@ +function_with_named_parameters(1, 10.0); +function_with_named_parameters(7, _bar = 3.14); +function_with_named_parameters( _bar = 0.0, _foo = 42); +function_with_named_parameters( _bar = 2.5, _bonk= "Hello", _foo = 9); +function_with_named_parameters(9, 2.5, true, "Hello"); diff --git a/Task/Named-parameters/C/named-parameters.c b/Task/Named-parameters/C/named-parameters.c new file mode 100644 index 0000000000..e69927952c --- /dev/null +++ b/Task/Named-parameters/C/named-parameters.c @@ -0,0 +1,48 @@ +#include + +// 1. Named parameters + +typedef struct { int x, y, z; } FTest_args; + +void FTest (FTest_args args) { + printf("x: %d, y: %d, z: %d\n", args.x, args.y, args.z); +} + +#define FT(...) FTest((FTest_args){ __VA_ARGS__ }) + + +// 2. Default parameters + +#define DFT(...) FTest((FTest_args){ .x = 142, .y = 143, .z = 144, __VA_ARGS__ }) + + +// 3. Convenience wrapper to avoid accessing args as "args.name" + +void FTest2 (int x, int y, int z) { + printf("x: %d, y: %d, z: %d\n", x, y, z); +} + +static inline void FTest2_default_wrapper (FTest_args args) { + return FTest2(args.x, args.y, args.z); +} + +#define DF2(...) FTest2_default_wrapper((FTest_args){ .x = 142, .y = 143, .z = 144, __VA_ARGS__ }) + + +int main(int argc, char **argv) +{ + // Named parameters + FTest((FTest_args){ .y = 10 }); + FTest((FTest_args){ .y = 10, .z = 42 }); + FT( .z = 47, .y = 10, .x = 42 ); + + // Default parameters + DFT(); + DFT( .z = 99 ); + + // Default parameters with wrapper + DF2(); + DF2( .z = 99 ); + + return 0; +} diff --git a/Task/Named-parameters/Clojure/named-parameters-1.clj b/Task/Named-parameters/Clojure/named-parameters-1.clj new file mode 100644 index 0000000000..2f9bef4715 --- /dev/null +++ b/Task/Named-parameters/Clojure/named-parameters-1.clj @@ -0,0 +1,4 @@ +(defn foo [& opts] + (let [opts (merge {:bar 1 :baz 2} (apply hash-map opts)) + {:keys [bar baz]} opts] + [bar baz])) diff --git a/Task/Named-parameters/Clojure/named-parameters-2.clj b/Task/Named-parameters/Clojure/named-parameters-2.clj new file mode 100644 index 0000000000..22b9db776c --- /dev/null +++ b/Task/Named-parameters/Clojure/named-parameters-2.clj @@ -0,0 +1,2 @@ +(defn foo [& {:keys [bar baz] :or {bar 1, baz 2}}] + [bar baz]) diff --git a/Task/Named-parameters/Clojure/named-parameters-3.clj b/Task/Named-parameters/Clojure/named-parameters-3.clj new file mode 100644 index 0000000000..adf128df7d --- /dev/null +++ b/Task/Named-parameters/Clojure/named-parameters-3.clj @@ -0,0 +1,3 @@ +(use 'clojure.contrib.def) +(defnk foo [:bar 1 :baz 2] + [bar baz]) diff --git a/Task/Named-parameters/Common-Lisp/named-parameters-1.lisp b/Task/Named-parameters/Common-Lisp/named-parameters-1.lisp new file mode 100644 index 0000000000..55e2066db0 --- /dev/null +++ b/Task/Named-parameters/Common-Lisp/named-parameters-1.lisp @@ -0,0 +1,6 @@ +(defun print-name (&key first (last "?")) + (princ last) + (when first + (princ ", ") + (princ first)) + (values)) diff --git a/Task/Named-parameters/Common-Lisp/named-parameters-2.lisp b/Task/Named-parameters/Common-Lisp/named-parameters-2.lisp new file mode 100644 index 0000000000..e7c632b3db --- /dev/null +++ b/Task/Named-parameters/Common-Lisp/named-parameters-2.lisp @@ -0,0 +1,8 @@ +CL-USER> (print-name) +? +CL-USER> (print-name :first "John") +?, John +CL-USER> (print-name :first "John" :last "Doe") +Doe, John +CL-USER> (print-name :last "Doe") +Doe diff --git a/Task/Named-parameters/E/named-parameters-1.e b/Task/Named-parameters/E/named-parameters-1.e new file mode 100644 index 0000000000..99705fdb1b --- /dev/null +++ b/Task/Named-parameters/E/named-parameters-1.e @@ -0,0 +1,11 @@ +def printName([=> first := null, => last := null]) { + if (last == null) { + print("?") + } else { + print(last) + } + if (first != null) { + print(", ") + print(first) + } +} diff --git a/Task/Named-parameters/E/named-parameters-2.e b/Task/Named-parameters/E/named-parameters-2.e new file mode 100644 index 0000000000..828ec905ae --- /dev/null +++ b/Task/Named-parameters/E/named-parameters-2.e @@ -0,0 +1,8 @@ +? printName(["first" => "John"]) +?, John + +? printName(["last" => "Doe"]) +Doe + +? printName(["first" => "John", "last" => "Doe"]) +Doe, John diff --git a/Task/Named-parameters/Fortran/named-parameters-1.f b/Task/Named-parameters/Fortran/named-parameters-1.f new file mode 100644 index 0000000000..06969d64f1 --- /dev/null +++ b/Task/Named-parameters/Fortran/named-parameters-1.f @@ -0,0 +1,5 @@ +subroutine a_sub(arg1, arg2, arg3) + integer, intent(in) :: arg1, arg2 + integer, intent(out), optional :: arg3 + ! ... +end subroutine a_sub diff --git a/Task/Named-parameters/Fortran/named-parameters-2.f b/Task/Named-parameters/Fortran/named-parameters-2.f new file mode 100644 index 0000000000..a505782b06 --- /dev/null +++ b/Task/Named-parameters/Fortran/named-parameters-2.f @@ -0,0 +1,4 @@ +! usage + integer :: r + call a_sub(1,2, r) + call a_sub(arg2=2, arg1=1) diff --git a/Task/Named-parameters/Fortran/named-parameters-3.f b/Task/Named-parameters/Fortran/named-parameters-3.f new file mode 100644 index 0000000000..bdb6334903 --- /dev/null +++ b/Task/Named-parameters/Fortran/named-parameters-3.f @@ -0,0 +1,5 @@ +subroutine b_sub(arg1, arg2) + integer, intent(in), optional :: arg1 + integer, intent(in) :: arg2 + !... +end subroutine b_sub diff --git a/Task/Named-parameters/Fortran/named-parameters-4.f b/Task/Named-parameters/Fortran/named-parameters-4.f new file mode 100644 index 0000000000..9a1ea59ad5 --- /dev/null +++ b/Task/Named-parameters/Fortran/named-parameters-4.f @@ -0,0 +1,4 @@ +call b_sub(1) ! error: missing non optional arg2 +call b_sub(arg2=1) ! ok +call b_sub(1, 2) ! ok: arg1 is 1, arg2 is 2 +call b_sub(arg2=2, arg1=1) ! the same as the previous line diff --git a/Task/Named-parameters/Haskell/named-parameters-1.hs b/Task/Named-parameters/Haskell/named-parameters-1.hs new file mode 100644 index 0000000000..eb7a518684 --- /dev/null +++ b/Task/Named-parameters/Haskell/named-parameters-1.hs @@ -0,0 +1,8 @@ +data X = X +data Y = Y +data Point = Point Int Int deriving Show + +createPointAt :: X -> Int -> Y -> Int -> Point +createPointAt X x Y y = Point x y + +main = print $ createPointAt X 5 Y 3 diff --git a/Task/Named-parameters/Haskell/named-parameters-2.hs b/Task/Named-parameters/Haskell/named-parameters-2.hs new file mode 100644 index 0000000000..f16c183a18 --- /dev/null +++ b/Task/Named-parameters/Haskell/named-parameters-2.hs @@ -0,0 +1,6 @@ +data Point = Point {x, y :: Int} deriving Show +defaultPoint = Point {x = 0, y = 0} + +createPointAt :: Point -> Point +createPointAt = id +main = print $ createPointAt (defaultPoint { y = 3, x = 5 }) diff --git a/Task/Named-parameters/Icon/named-parameters.icon b/Task/Named-parameters/Icon/named-parameters.icon new file mode 100644 index 0000000000..76bd6f5f7b --- /dev/null +++ b/Task/Named-parameters/Icon/named-parameters.icon @@ -0,0 +1,20 @@ +procedure main() + testproc("x:=",1,"y:=",2,"z:=",3) + testproc("x:=",3,"y:=",1,"z:=",2) + testproc("z:=",4,"x:=",2,"y:=",3) + testproc("i:=",1,"y:=",2,"z:=",3) +end + +procedure testproc(A[]) #: demo to test named parameters + write("Calling testproc") + + while a := get(A) do # implement named parameters here + (( a ? (v := =!["x","y","z"], =":=") | # valid parameter name? + stop("No parameter ",a)) & # . . no + ((variable(a[1:-2]) := get(A)) | # assign + runerr(205,a))) # . . problem + + write(" x:=",x) + write(" y:=",y) + write(" z:=",z) +end diff --git a/Task/Named-parameters/J/named-parameters.j b/Task/Named-parameters/J/named-parameters.j new file mode 100644 index 0000000000..178117824e --- /dev/null +++ b/Task/Named-parameters/J/named-parameters.j @@ -0,0 +1,26 @@ +NB. Strand notation +myFunc['c:\file.txt' 906 'blue' fs] + +NB. Commas, like other langs +myFunc['c:\file.txt', 906, 'blue' fs] + +NB. Unspecified args are defaulted ("optional") +myFunc['c:\file.txt' fs] + +NB. Can use named arguments, like eg VB +myFunc[color='blue' fs] + +NB. Often values needn't be quoted +myFunc[color= blue fs] + +NB. Combination of comma syntax and name=value +myFunc[max=906, color=blue fs] + +NB. Spelling of names is flexible +myFunc[MAX=906, COLOR=blue fs] + +NB. Order of names is flexible +myFunc[COLOR=blue, MAX=906 fs] + +NB. Even the delimiters are flexible... +myFunc diff --git a/Task/Named-parameters/Java/named-parameters.java b/Task/Named-parameters/Java/named-parameters.java new file mode 100644 index 0000000000..ee99e49c93 --- /dev/null +++ b/Task/Named-parameters/Java/named-parameters.java @@ -0,0 +1 @@ +processNutritionFacts(new NutritionFacts.Builder(240, 8).calories(100).sodium(35).carbohydrate(27).build()); diff --git a/Task/Named-parameters/JavaScript/named-parameters.js b/Task/Named-parameters/JavaScript/named-parameters.js new file mode 100644 index 0000000000..f892727ff4 --- /dev/null +++ b/Task/Named-parameters/JavaScript/named-parameters.js @@ -0,0 +1,12 @@ +function example(options) { + // assign some defaults where the user's has not provided a value + opts = {} + opts.foo = options.foo || 0; + opts.bar = options.bar || 1; + opts.grill = options.grill || 'pork chops' + + alert("foo is " + opts.foo + ", bar is " + opts.bar + ", and grill is " + opts.grill); +} + +example({grill: "lamb kebab", bar: 3.14}); +// => "foo is 0, bar is 3.14, and grill is lamb kebab" diff --git a/Task/Named-parameters/Lua/named-parameters.lua b/Task/Named-parameters/Lua/named-parameters.lua new file mode 100644 index 0000000000..375ba2805a --- /dev/null +++ b/Task/Named-parameters/Lua/named-parameters.lua @@ -0,0 +1,8 @@ +function CreatePet(options) + local name=options.name + local species=options.species + local breed=options.breed + print('Created a '..breed..' '..species..' named '..name) +end +CreatePet{name='Rex',species='Dog',breed='Irish Setter'} +--position does not matter here. diff --git a/Task/Named-parameters/MATLAB/named-parameters.m b/Task/Named-parameters/MATLAB/named-parameters.m new file mode 100644 index 0000000000..8292472321 --- /dev/null +++ b/Task/Named-parameters/MATLAB/named-parameters.m @@ -0,0 +1,15 @@ + function foo(varargin) + for k= 1:2:length(varargin); + switch (varargin{k}) + case {'param1'} + param1 = varargin{k+1}; + case {'param2'} + param2 = varargin{k+1}; + end; + end; + printf('param1: %s\n',param1); + printf('param2: %s\n',param2); + end; + + foo('param1','a1','param2','b2'); + foo('param2','b2','param1','a1'); diff --git a/Task/Named-parameters/Mathematica/named-parameters.math b/Task/Named-parameters/Mathematica/named-parameters.math new file mode 100644 index 0000000000..b3d1fbffac --- /dev/null +++ b/Task/Named-parameters/Mathematica/named-parameters.math @@ -0,0 +1,7 @@ +Options[fn]={Add->False,Offset-> 0}; +fn[x_,y_,OptionsPattern[]]:=If[OptionValue[Add]==True,x+y+OptionValue[Offset],{x,y,OptionValue[Offset]}] + +fn[3,4,{Add->True,Offset->2}] +->9 +fn[3,4,{Offset->2,Add->True}] +->9 diff --git a/Task/Named-parameters/Modula-3/named-parameters-1.mod3 b/Task/Named-parameters/Modula-3/named-parameters-1.mod3 new file mode 100644 index 0000000000..9c75ccda61 --- /dev/null +++ b/Task/Named-parameters/Modula-3/named-parameters-1.mod3 @@ -0,0 +1 @@ +PROCEDURE Foo(Arg1: INTEGER; Arg2: REAL := 0.0); diff --git a/Task/Named-parameters/Modula-3/named-parameters-2.mod3 b/Task/Named-parameters/Modula-3/named-parameters-2.mod3 new file mode 100644 index 0000000000..568471e2ba --- /dev/null +++ b/Task/Named-parameters/Modula-3/named-parameters-2.mod3 @@ -0,0 +1,4 @@ +Foo(1, 0.0); +Foo(1); +Foo(Arg2 := 0.0, Arg1 := 1); +Foo(Arg1 := 1); diff --git a/Task/Named-parameters/Nemerle/named-parameters.nemerle b/Task/Named-parameters/Nemerle/named-parameters.nemerle new file mode 100644 index 0000000000..c898326658 --- /dev/null +++ b/Task/Named-parameters/Nemerle/named-parameters.nemerle @@ -0,0 +1,4 @@ +Foo(number : int, word = "Default", option = true) : void // note type inference with default values + +Foo(word = "Bird", number = 3) // an argument with a default value can be omitted from function call +Foo(3, option = false, word = "Bird") // unnamed arguments must be in same order as function definition and precede named arguments diff --git a/Task/Named-parameters/OCaml/named-parameters.ocaml b/Task/Named-parameters/OCaml/named-parameters.ocaml new file mode 100644 index 0000000000..9862bdf5ae --- /dev/null +++ b/Task/Named-parameters/OCaml/named-parameters.ocaml @@ -0,0 +1,6 @@ +# let foo ~arg1 ~arg2 = arg1 + arg2;; +val foo : arg1:int -> arg2:int -> int = +# let foo ~arg1:x ~arg2:y = x + y;; (* you can also use different variable names internally if you want *) +val foo : arg1:int -> arg2:int -> int = +# foo ~arg2:17 ~arg1:42;; +- : int = 59 diff --git a/Task/Named-parameters/Objective-C/named-parameters-1.m b/Task/Named-parameters/Objective-C/named-parameters-1.m new file mode 100644 index 0000000000..6484c94c23 --- /dev/null +++ b/Task/Named-parameters/Objective-C/named-parameters-1.m @@ -0,0 +1,8 @@ +@interface Demo : Object { + // Omitted ... +} + +- (double) hypotenuseOfX: (double)x andY: (double)y; +- (double) hypotenuseOfX: (double)x andY: (double)y andZ: (double)z; + +@end diff --git a/Task/Named-parameters/Objective-C/named-parameters-2.m b/Task/Named-parameters/Objective-C/named-parameters-2.m new file mode 100644 index 0000000000..cbb062bf12 --- /dev/null +++ b/Task/Named-parameters/Objective-C/named-parameters-2.m @@ -0,0 +1,10 @@ +@implementation Demo + +- (double) hypotenuseOfX: (double)x andY: (double)y { + return hypot(x,y); +} +- (double) hypotenuseOfX: (double)x andY: (double)y andZ: (double)z { + return hypot(hypot(x, y), z); +} + +@end diff --git a/Task/Named-parameters/Objective-C/named-parameters-3.m b/Task/Named-parameters/Objective-C/named-parameters-3.m new file mode 100644 index 0000000000..a310a9b00a --- /dev/null +++ b/Task/Named-parameters/Objective-C/named-parameters-3.m @@ -0,0 +1,2 @@ +Demo *example = [[Demo alloc] init]; +double h = [example hypotenuseOfX:1.23 andY:3.79]; diff --git a/Task/Named-parameters/Oz/named-parameters-1.oz b/Task/Named-parameters/Oz/named-parameters-1.oz new file mode 100644 index 0000000000..7001130b89 --- /dev/null +++ b/Task/Named-parameters/Oz/named-parameters-1.oz @@ -0,0 +1,15 @@ +declare +class Foo + meth init skip end + meth bar(PP %% positional parameter + named1:N1 + named2:N2 + namedWithDefault:NWD <= 42) + {System.showInfo "PP: "#PP#", N1: "#N1#", N2: "#N2#", NWD: "#NWD} + end +end + +O = {New Foo init} +{O bar(1 named1:2 named2:3 namedWithDefault:4)} %% ok +{O bar(1 named2:2 named1:3)} %% ok +{O bar(1 named1:2)} %% not ok, "missing message feature in object application" diff --git a/Task/Named-parameters/Oz/named-parameters-2.oz b/Task/Named-parameters/Oz/named-parameters-2.oz new file mode 100644 index 0000000000..eb2e58bd2f --- /dev/null +++ b/Task/Named-parameters/Oz/named-parameters-2.oz @@ -0,0 +1,10 @@ +declare +proc {Foo PP Other=unit(named1:N1 named2:N2 ...)} + NWD = {CondSelect Other namedWithDefault 42} +in + {System.showInfo "PP: "#PP#", N1: "#N1#", N2: "#N2#", NWD: "#NWD} +end + +{Foo 1 unit(named1:2 named2:3 namedWithDefault:4)} +{Foo 1 unit(named2:2 named1:3)} +{Foo 1 unit(named1:2)} %% not ok... diff --git a/Task/Named-parameters/Perl-6/named-parameters-1.pl6 b/Task/Named-parameters/Perl-6/named-parameters-1.pl6 new file mode 100644 index 0000000000..adea1654e7 --- /dev/null +++ b/Task/Named-parameters/Perl-6/named-parameters-1.pl6 @@ -0,0 +1,3 @@ +sub funkshun ($a, $b?, $c = 15, :$d, *@e, *%f) { + ... +} diff --git a/Task/Named-parameters/Perl-6/named-parameters-2.pl6 b/Task/Named-parameters/Perl-6/named-parameters-2.pl6 new file mode 100644 index 0000000000..2725ecea6c --- /dev/null +++ b/Task/Named-parameters/Perl-6/named-parameters-2.pl6 @@ -0,0 +1,5 @@ +sub funkshun ($a, $b?, $c = 15, :$d, *@e, *%f) { + say "$a $b $c $d"; + say join ' ', @e; + say join ' ', keys %f; +} diff --git a/Task/Named-parameters/Perl-6/named-parameters-3.pl6 b/Task/Named-parameters/Perl-6/named-parameters-3.pl6 new file mode 100644 index 0000000000..6b7849eb3f --- /dev/null +++ b/Task/Named-parameters/Perl-6/named-parameters-3.pl6 @@ -0,0 +1,3 @@ +funkshun + 'Alfa', k1 => 'v1', c => 'Charlie', 'Bravo', 'e1', + d => 'Delta', 'e2', k2 => 'v2'; diff --git a/Task/Named-parameters/Perl/named-parameters-1.pl b/Task/Named-parameters/Perl/named-parameters-1.pl new file mode 100644 index 0000000000..5a1f09a9c2 --- /dev/null +++ b/Task/Named-parameters/Perl/named-parameters-1.pl @@ -0,0 +1,12 @@ +sub funkshun + {my %h = @_; + # Print every argument and its value. + print qq(Argument "$_" has value "$h{$_}".\n) + foreach sort keys %h; + # If a 'verbosity' argument was passed in, print its value, + # whatever that value may be. + exists $h{verbosity} + and print "Verbosity specified as $h{verbosity}.\n"; + # Say that safe mode is on if 'safe' is set to a true value. + # Otherwise, say that it's off. + print "Safe mode ", ($h{safe} ? 'on' : 'off'), ".\n";} diff --git a/Task/Named-parameters/Perl/named-parameters-2.pl b/Task/Named-parameters/Perl/named-parameters-2.pl new file mode 100644 index 0000000000..ab294b3797 --- /dev/null +++ b/Task/Named-parameters/Perl/named-parameters-2.pl @@ -0,0 +1,3 @@ +funkshun + verbosity => 3, password => 'foobie blech', + extra_lives => 3, '42' => 'answer', password => 'joshua'; diff --git a/Task/Named-parameters/PicoLisp/named-parameters-1.l b/Task/Named-parameters/PicoLisp/named-parameters-1.l new file mode 100644 index 0000000000..38b75fd484 --- /dev/null +++ b/Task/Named-parameters/PicoLisp/named-parameters-1.l @@ -0,0 +1,6 @@ +(de foo @ + (bind (rest) # Bind symbols in CARs to values in CDRs + (println 'Bar 'is Bar) + (println 'Mumble 'is Mumble) ) ) + +(foo '(Bar . 123) '(Mumble . "def")) diff --git a/Task/Named-parameters/PicoLisp/named-parameters-2.l b/Task/Named-parameters/PicoLisp/named-parameters-2.l new file mode 100644 index 0000000000..babbcc2b6e --- /dev/null +++ b/Task/Named-parameters/PicoLisp/named-parameters-2.l @@ -0,0 +1,7 @@ +(de foo @ + (bind (next) # Save all symbols in first argument + (mapc set (arg) (rest)) # then bind them to remaining arguments + (println 'Bar 'is Bar) + (println 'Mumble 'is Mumble) ) ) + +(foo '(Bar Mumble) 123 "def") diff --git a/Task/Named-parameters/PowerShell/named-parameters-1.psh b/Task/Named-parameters/PowerShell/named-parameters-1.psh new file mode 100644 index 0000000000..6981a4a859 --- /dev/null +++ b/Task/Named-parameters/PowerShell/named-parameters-1.psh @@ -0,0 +1,3 @@ +function Test { + Write-Host Argument 1 is $args[0] +} diff --git a/Task/Named-parameters/PowerShell/named-parameters-2.psh b/Task/Named-parameters/PowerShell/named-parameters-2.psh new file mode 100644 index 0000000000..f7ec22d90c --- /dev/null +++ b/Task/Named-parameters/PowerShell/named-parameters-2.psh @@ -0,0 +1,5 @@ +function Test ($SomeArgument, $AnotherArgument, $ThirdArgument) { + Write-Host "Some argument: $SomeArgument" + Write-Host "Another argument: $AnotherArgument" + Write-Host "Third argument: $ThirdArgument" +} diff --git a/Task/Named-parameters/PowerShell/named-parameters-3.psh b/Task/Named-parameters/PowerShell/named-parameters-3.psh new file mode 100644 index 0000000000..932e4ec01b --- /dev/null +++ b/Task/Named-parameters/PowerShell/named-parameters-3.psh @@ -0,0 +1,3 @@ +function SwitchTest ([switch] $on) { + Write-Host Switched $(if ($on) { "on" } else { "off" }) +} diff --git a/Task/Named-parameters/PowerShell/named-parameters-4.psh b/Task/Named-parameters/PowerShell/named-parameters-4.psh new file mode 100644 index 0000000000..a311e94196 --- /dev/null +++ b/Task/Named-parameters/PowerShell/named-parameters-4.psh @@ -0,0 +1,3 @@ +function Greeting ($Name = "Nobody") { + Write-Host Hello, $Name! +} diff --git a/Task/Named-parameters/Python/named-parameters-1.py b/Task/Named-parameters/Python/named-parameters-1.py new file mode 100644 index 0000000000..0e6360acb7 --- /dev/null +++ b/Task/Named-parameters/Python/named-parameters-1.py @@ -0,0 +1,5 @@ +def subtract(x, y): + return x - y + +subtract(5, 3) # used as positional parameters; evaluates to 2 +subtract(y = 3, x = 5) # used as named parameters; evaluates to 2 diff --git a/Task/Named-parameters/Python/named-parameters-2.py b/Task/Named-parameters/Python/named-parameters-2.py new file mode 100644 index 0000000000..ed2433ce05 --- /dev/null +++ b/Task/Named-parameters/Python/named-parameters-2.py @@ -0,0 +1,107 @@ +>>> from __future__ import print_function +>>> +>>> def show_args(defparam1, defparam2 = 'default value', *posparam, **keyparam): + "Straight-forward function to show its arguments" + print (" Default Parameters:") + print (" defparam1 value is:", defparam1) + print (" defparam2 value is:", defparam2) + + print (" Positional Arguments:") + if posparam: + n = 0 + for p in posparam: + print (" positional argument:", n, "is:", p) + n += 1 + else: + print (" ") + + print (" Keyword Arguments (by sorted key name):") + if keyparam: + for k,v in sorted(keyparam.items()): + print (" keyword argument:", k, "is:", v) + else: + print (" ") + + +>>> show_args('POSITIONAL', 'ARGUMENTS') + Default Parameters: + defparam1 value is: POSITIONAL + defparam2 value is: ARGUMENTS + Positional Arguments: + + Keyword Arguments (by sorted key name): + +>>> show_args(defparam2='ARGUMENT', defparam1='KEYWORD') + Default Parameters: + defparam1 value is: KEYWORD + defparam2 value is: ARGUMENT + Positional Arguments: + + Keyword Arguments (by sorted key name): + +>>> show_args( *('SEQUENCE', 'ARGUMENTS') ) + Default Parameters: + defparam1 value is: SEQUENCE + defparam2 value is: ARGUMENTS + Positional Arguments: + + Keyword Arguments (by sorted key name): + +>>> show_args( **{'defparam2':'ARGUMENTS', 'defparam1':'MAPPING'} ) + Default Parameters: + defparam1 value is: MAPPING + defparam2 value is: ARGUMENTS + Positional Arguments: + + Keyword Arguments (by sorted key name): + +>>> show_args('ONLY DEFINE defparam1 ARGUMENT') + Default Parameters: + defparam1 value is: ONLY DEFINE defparam1 ARGUMENT + defparam2 value is: default value + Positional Arguments: + + Keyword Arguments (by sorted key name): + +>>> show_args('POSITIONAL', 'ARGUMENTS', + 'EXTRA', 'POSITIONAL', 'ARGUMENTS') + Default Parameters: + defparam1 value is: POSITIONAL + defparam2 value is: ARGUMENTS + Positional Arguments: + positional argument: 0 is: EXTRA + positional argument: 1 is: POSITIONAL + positional argument: 2 is: ARGUMENTS + Keyword Arguments (by sorted key name): + +>>> show_args('POSITIONAL', 'ARGUMENTS', + kwa1='EXTRA', kwa2='KEYWORD', kwa3='ARGUMENTS') + Default Parameters: + defparam1 value is: POSITIONAL + defparam2 value is: ARGUMENTS + Positional Arguments: + + Keyword Arguments (by sorted key name): + keyword argument: kwa1 is: EXTRA + keyword argument: kwa2 is: KEYWORD + keyword argument: kwa3 is: ARGUMENTS +>>> show_args('POSITIONAL', + 'ARGUMENTS', 'EXTRA', 'POSITIONAL', 'ARGUMENTS', + kwa1='EXTRA', kwa2='KEYWORD', kwa3='ARGUMENTS') + Default Parameters: + defparam1 value is: POSITIONAL + defparam2 value is: ARGUMENTS + Positional Arguments: + positional argument: 0 is: EXTRA + positional argument: 1 is: POSITIONAL + positional argument: 2 is: ARGUMENTS + Keyword Arguments (by sorted key name): + keyword argument: kwa1 is: EXTRA + keyword argument: kwa2 is: KEYWORD + keyword argument: kwa3 is: ARGUMENTS +>>> # But note: +>>> show_args('POSITIONAL', 'ARGUMENTS', + kwa1='EXTRA', kwa2='KEYWORD', kwa3='ARGUMENTS', + 'EXTRA', 'POSITIONAL', 'ARGUMENTS') +SyntaxError: non-keyword arg after keyword arg +>>> diff --git a/Task/Named-parameters/R/named-parameters.r b/Task/Named-parameters/R/named-parameters.r new file mode 100644 index 0000000000..d7a2250a64 --- /dev/null +++ b/Task/Named-parameters/R/named-parameters.r @@ -0,0 +1,10 @@ +divide <- function(numerator, denominator) { + numerator / denominator +} + +divide(3, 2) # 1.5 +divide(numerator=3, denominator=2) # 1.5 +divide(n=3, d=2) # 1.5 +divide(den=3, num=2) # 0.66 +divide(den=3, 2) # 0.66 +divide(3, num=2) # 0.66 diff --git a/Task/Named-parameters/REXX/named-parameters.rexx b/Task/Named-parameters/REXX/named-parameters.rexx new file mode 100644 index 0000000000..8257f1341f --- /dev/null +++ b/Task/Named-parameters/REXX/named-parameters.rexx @@ -0,0 +1,76 @@ +/*REXX pgm shows named parameters when called as a subroutine/function*/ +/*┌────────────────────────────────────────────────────────────────────┐ + │ The syntax of: xxx = func1(parmName2=arg2, parmName1=arg1) │ + │ │ + │ in the REXX language is interpreted specifically as: │ + │ │ + │ xxx = func1( yyy , zzz ) │ + │ │ + │ where yyy is the logical result of comparing (the REXX variables)│ + │ │ + │ parmName2 with arg2 and │ + │ │ + │ where zzz is the logical result of comparing (the REXX variables)│ + │ │ + │ parmName1 with arg1 │ + │ │ + │ (either as two strings, or arithmetically if both "parmName2" and │ + │ "arg2" are both valid REXX numbers. In the REXX language, there │ + │ is no way to declare (define) what a variable is [or its type], as │ + │ each literal that can be a variable is assumed to be one. If it's │ + │ not defined, then its uppercase name is used for the value. │ + │ │ + │ Consider the one-line REXX program: say Where are you? │ + │ causes REXX to consider that four-word expression as a "SAY" │ + │ statement, followed by three REXX variables, each of which aren't │ + │ defined (that is, have a value), so REXX uses a value which is the │ + │ uppercased value of the REXX variable name, namely three values in │ + │ this case, so the following is displayed: WHERE ARE YOU? │ + │ │ + │ [There is a mechanism in REXX to catch this behavior and raise the │ + │ NOVALUE condition.] │ + │ │ + │ To allow a solution to be used for this task's requirement, and │ + │ and not get tangled up with the legal REXX syntactical expressions │ + │ shown, this REXX programming example uses a variation of the │ + │ task's illustration to allow a method in REXX of using named │ + │ parameters: xxx = func1('parmName2=' arg2, "parmName1=" arg1) │ + │ │ + │ Also, REXX allows the omitting of arguments by just specifying a │ + │ comma (or nothing at all, in the case of a single argument): │ + │ │ + │ xxx = func1(,zzz) │ + │ │ + │ would indicate that the 1st argument has been omitted. │ + │ │ + │ xxx = func1(yyy) │ + │ │ + │ would indicate that the 2nd argument (and all other subsequent │ + │ arguments) has/have been omitted. │ + └────────────────────────────────────────────────────────────────────┘*/ + +parse arg count,itemX /*assume 2 values have been used,*/ + /*or whatever ... just to show...*/ + do j=1 for arg(); _=arg(1) /*now, lets examine each argument*/ + if arg(j,'Omitted') then iterate /*skip examining if argJ omitted.*/ + /*(above) This is superfluous, */ + /* but it demonstrates a method. */ + if \arg(j,"Exists") then iterate /*exactly the same as previous. */ + /*Only 1st char (2nd arg) is used*/ + first=strip(word(_,1)) /*extract the 1st word in arg(j).*/ + if right(first,1)\=='=' then iterate /*skip if 1st word isn't: xxx= */ + parse var _ varname '= ' value /*parse the named variable &value*/ + if varname=='' then iterate /*not the correct format, so skip*/ + /*(above) fix this for real pgm. */ + call value varname,value /*use BIF to set REXX variable. */ + end /*j*/ + +/* ∙∙∙ perform some REXX magic here with specified parameters and stuff:*/ +/* do this, do that, perform dis & dat, compute, gears whiz, cogs */ +/* turn, wheels spin, belts move, things get assigned, stuff gets */ +/* computed, wheels spin, belts move, things get assigned, motors*/ +/* humm, engines roar, coal gets burned, water turns to steam, real */ +/* work (some of it useful) gets done, and something is produced. */ + +return 'the final meaning of life, or 42 --- whichever is appropriate.' + /*stick a fork in it, we're done.*/ diff --git a/Task/Named-parameters/Racket/named-parameters.rkt b/Task/Named-parameters/Racket/named-parameters.rkt new file mode 100644 index 0000000000..6a9733aeef --- /dev/null +++ b/Task/Named-parameters/Racket/named-parameters.rkt @@ -0,0 +1,12 @@ +#lang racket + +(define (pizza sauce + ;; mandatory keyword argument + #:topping topping + ;; optional keyword argument with default + #:type [type "deep dish"]) + (printf "~a pizza with ~a sauce topped with ~a~n" + type sauce topping)) + +(pizza "tomato" #:topping "onion") +(pizza #:topping "onion" "garlic" #:type "pan") diff --git a/Task/Named-parameters/Ruby/named-parameters-1.rb b/Task/Named-parameters/Ruby/named-parameters-1.rb new file mode 100644 index 0000000000..e66eafbe1f --- /dev/null +++ b/Task/Named-parameters/Ruby/named-parameters-1.rb @@ -0,0 +1,6 @@ +def example(foo: 0, bar: 1, grill: "pork chops") + puts "foo is #{foo}, bar is #{bar}, and grill is #{grill}" +end + +# Note that :foo is omitted and :grill precedes :bar +example(grill: "lamb kebab", bar: 3.14) diff --git a/Task/Named-parameters/Ruby/named-parameters-2.rb b/Task/Named-parameters/Ruby/named-parameters-2.rb new file mode 100644 index 0000000000..c1230b317b --- /dev/null +++ b/Task/Named-parameters/Ruby/named-parameters-2.rb @@ -0,0 +1,11 @@ +def example(opts = {}) + # Hash#merge raises TypeError if _opts_ is not a Hash. + # Nothing checks if _opts_ contains unknown keys. + defaults = {foo: 0, bar: 1, grill: "pork chops"} + opts = defaults.merge(opts) + + printf("foo is %s, bar is %s, and grill is %s\n", + opts[:foo], opts[:bar], opts[:grill]) +end + +example(grill: "lamb kebab", bar: 3.14) diff --git a/Task/Named-parameters/Ruby/named-parameters-3.rb b/Task/Named-parameters/Ruby/named-parameters-3.rb new file mode 100644 index 0000000000..dade0e83ee --- /dev/null +++ b/Task/Named-parameters/Ruby/named-parameters-3.rb @@ -0,0 +1,8 @@ +def example(opts = {}) + defaults = {:foo => 0, :bar => 1, :grill => "pork chops"} + opts = defaults.merge(opts) + printf("foo is %s, bar is %s, and grill is %s\n", + opts[:foo], opts[:bar], opts[:grill]) +end + +example(:grill => "lamb kebab", :bar => 3.14) diff --git a/Task/Named-parameters/Scala/named-parameters-1.scala b/Task/Named-parameters/Scala/named-parameters-1.scala new file mode 100644 index 0000000000..1a53b7379b --- /dev/null +++ b/Task/Named-parameters/Scala/named-parameters-1.scala @@ -0,0 +1 @@ +def add(x: Int, y: Int = 1) = x + y diff --git a/Task/Named-parameters/Scala/named-parameters-2.scala b/Task/Named-parameters/Scala/named-parameters-2.scala new file mode 100644 index 0000000000..95bf3c32f3 --- /dev/null +++ b/Task/Named-parameters/Scala/named-parameters-2.scala @@ -0,0 +1,5 @@ +scala> add(5) +6 + +scala> add(y=10, x=4) +14 diff --git a/Task/Named-parameters/Scheme/named-parameters-1.ss b/Task/Named-parameters/Scheme/named-parameters-1.ss new file mode 100644 index 0000000000..b078763917 --- /dev/null +++ b/Task/Named-parameters/Scheme/named-parameters-1.ss @@ -0,0 +1,21 @@ +(define (keyarg-parser argdefs args kont) + (apply kont + (map (lambda (argdef) + (let loop ((args args)) + (cond ((null? args) + (cadr argdef)) + ((eq? (car argdef) (car args)) + (cadr args)) + (else + (loop (cdr args)))))) + argdefs))) + +(define (print-name . args) + (keyarg-parser '((first #f)(last "?")) + args + (lambda (first last) + (display last) + (cond (first + (display ", ") + (display first))) + (newline)))) diff --git a/Task/Named-parameters/Scheme/named-parameters-2.ss b/Task/Named-parameters/Scheme/named-parameters-2.ss new file mode 100644 index 0000000000..e253844719 --- /dev/null +++ b/Task/Named-parameters/Scheme/named-parameters-2.ss @@ -0,0 +1,8 @@ +=> (print-name) +? +=> (print-name 'first "John") +?, John +=>(print-name 'first "John" 'last "Doe") +Doe, John +=>(print-name 'last "Doe") +Doe diff --git a/Task/Named-parameters/Smalltalk/named-parameters.st b/Task/Named-parameters/Smalltalk/named-parameters.st new file mode 100644 index 0000000000..e7e595162b --- /dev/null +++ b/Task/Named-parameters/Smalltalk/named-parameters.st @@ -0,0 +1,9 @@ +Object subclass: AnotherClass [ + "..." + initWithArray: anArray [ "single argument" ] + initWithArray: anArray andString: aString [ + "two args; these two methods in usage resemble + a named argument, with optional andString argument" + ] + "..." +] diff --git a/Task/Named-parameters/Suneido/named-parameters-1.suneido b/Task/Named-parameters/Suneido/named-parameters-1.suneido new file mode 100644 index 0000000000..d469059a18 --- /dev/null +++ b/Task/Named-parameters/Suneido/named-parameters-1.suneido @@ -0,0 +1,6 @@ +test = function (one, two, three = '', four = '', five = '') + { + Print('one: ' $ one $ ', two: ' $ two $ ', three: ' $ three $ + ', four: ' $ four $ ', five: ' $ five) + } +test('1', '2', five: '5', three: '3') diff --git a/Task/Named-parameters/Suneido/named-parameters-2.suneido b/Task/Named-parameters/Suneido/named-parameters-2.suneido new file mode 100644 index 0000000000..8741048962 --- /dev/null +++ b/Task/Named-parameters/Suneido/named-parameters-2.suneido @@ -0,0 +1 @@ +one: 1, two: 2, three: 3, four: , five: 5 diff --git a/Task/Named-parameters/Tcl/named-parameters-1.tcl b/Task/Named-parameters/Tcl/named-parameters-1.tcl new file mode 100644 index 0000000000..442bf904ae --- /dev/null +++ b/Task/Named-parameters/Tcl/named-parameters-1.tcl @@ -0,0 +1,11 @@ +proc example args { + # Set the defaults + array set opts {-foo 0 -bar 1 -grill "hamburger"} + # Merge in the values from the caller + array set opts $args + # Use the arguments + return "foo is $opts(-foo), bar is $opts(-bar), and grill is $opts(-grill)" +} +# Note that -foo is omitted and -grill precedes -bar +example -grill "lamb kebab" -bar 3.14 +# => ‘foo is 0, bar is 3.14, and grill is lamb kebab’ diff --git a/Task/Named-parameters/Tcl/named-parameters-2.tcl b/Task/Named-parameters/Tcl/named-parameters-2.tcl new file mode 100644 index 0000000000..162f5f38e9 --- /dev/null +++ b/Task/Named-parameters/Tcl/named-parameters-2.tcl @@ -0,0 +1,18 @@ +package require opt +tcl::OptProc example { + {-foo -int 0 "The number of foos"} + {-bar -float 1.0 "How much bar-ness"} + {-grill -any "hamburger" "What to cook on the grill"} +} { + return "foo is $foo, bar is $bar, and grill is $grill" +} +example -grill "lamb kebab" -bar 3.14 +# => ‘foo is 0, bar is 3.14, and grill is lamb kebab’ +example -help +# Usage information: +# Var/FlagName Type Value Help +# ------------ ---- ----- ---- +# ( -help gives this help ) +# -foo int (0) The number of foos +# -bar float (1.0) How much bar-ness +# -grill any (hamburger) What to cook on the grill diff --git a/Task/Named-parameters/Visual-Basic/named-parameters.vb b/Task/Named-parameters/Visual-Basic/named-parameters.vb new file mode 100644 index 0000000000..4e453f9f22 --- /dev/null +++ b/Task/Named-parameters/Visual-Basic/named-parameters.vb @@ -0,0 +1,8 @@ +'the function +Sub whatever(foo As Long, bar As Integer, baz As Byte, qux As String) + '... +End Sub +'calling the function -- note the Pascal-style assignment operator +Sub crap() + whatever bar:=1, baz:=2, foo:=-1, qux:="Why is ev'rybody always pickin' on me?" +End Sub diff --git a/Task/Named-parameters/XSLT/named-parameters.xslt b/Task/Named-parameters/XSLT/named-parameters.xslt new file mode 100644 index 0000000000..11ad061233 --- /dev/null +++ b/Task/Named-parameters/XSLT/named-parameters.xslt @@ -0,0 +1,4 @@ + + + ... + diff --git a/Task/Nautical-bell/0DESCRIPTION b/Task/Nautical-bell/0DESCRIPTION new file mode 100644 index 0000000000..f900f892b9 --- /dev/null +++ b/Task/Nautical-bell/0DESCRIPTION @@ -0,0 +1,4 @@ +The task is to write a small program that emulates a [[wp:Ship's bell#Timing_of_duty_periods|nautical bell]] producing a ringing bell pattern at certain times throughout the day. +The bell timing should be in accordance with [[wp:GMT|Greenwich Mean Time]], unless locale dictates otherwise. + +It is permissible for the program to [[Run as a daemon or service|daemonize]], or to slave off a scheduler, and it is permissible to use alternative notification methods (such as producing a written notice "Two Bells Gone"), if these are more usual for the system type. diff --git a/Task/Nautical-bell/1META.yaml b/Task/Nautical-bell/1META.yaml new file mode 100644 index 0000000000..e71737a981 --- /dev/null +++ b/Task/Nautical-bell/1META.yaml @@ -0,0 +1,3 @@ +--- +category: +- Date and time diff --git a/Task/Nautical-bell/D/nautical-bell.d b/Task/Nautical-bell/D/nautical-bell.d new file mode 100644 index 0000000000..3e4253d489 --- /dev/null +++ b/Task/Nautical-bell/D/nautical-bell.d @@ -0,0 +1,50 @@ +import std.stdio, core.thread, std.datetime; + +class NauticalBell : Thread { + private shared bool stopped; + + this() { + super(&run); + } + + void run() { + uint numBells; + auto time = cast(TimeOfDay)Clock.currTime(); + auto next = TimeOfDay(); + + void setNextBellTime() { + next += minutes(30); + numBells = 1 + (numBells % 8); + } + + while (next < time) + setNextBellTime(); + + while (!this.stopped) { + time = cast(TimeOfDay)Clock.currTime(); + if (next.minute == time.minute && + next.hour == time.hour) { + immutable bells = numBells == 1 ? "bell" : "bells"; + writefln("%s : %d %s", time, numBells, bells); + setNextBellTime(); + } + sleep(dur!"msecs"(100)); + yield(); + } + } + + void stop() { + this.stopped = true; + } +} + +void main() { + auto bells = new NauticalBell(); + bells.isDaemon(true); + bells.start(); + try { + bells.join(); + } catch (ThreadException e) { + writeln(e.msg); + } +} diff --git a/Task/Nautical-bell/Perl-6/nautical-bell.pl6 b/Task/Nautical-bell/Perl-6/nautical-bell.pl6 new file mode 100644 index 0000000000..88f7f917d6 --- /dev/null +++ b/Task/Nautical-bell/Perl-6/nautical-bell.pl6 @@ -0,0 +1,41 @@ +my @watch = ; +my @ordinal = ; + +my $thishour; +my $thisminute = ''; + +loop { + my $utc = DateTime.new(time); + if $utc.minute ~~ any(0,30) and $utc.minute != $thisminute { + $thishour = $utc.hour; + $thisminute = $utc.minute; + bell($thishour, $thisminute); + } + printf "%s%02d:%02d:%02d", "\r", $utc.hour, $utc.minute, $utc.second; + sleep(1); +} + +sub bell ($hour, $minute) { + + my $bells = (($hour % 4) * 2 + $minute div 30) || 8; + + printf "%s%02d:%02d %9s watch, %6s Bell%s Gone: \t", "\b" x 9, $hour, $minute, + @watch[($hour div 4 - !?($minute + $hour % 4) + 6) % 6], + @ordinal[$bells - 1], $bells == 1 ?? '' !! 's'; + + chime($bells); + + sub chime ($count) { + for 1..$count div 2 { + print "\a♫ "; + sleep .25; + print "\a"; + sleep .75; + } + if $count % 2 { + print "\a♪"; + sleep 1; + } + print "\n"; + } +} diff --git a/Task/Nautical-bell/Python/nautical-bell.py b/Task/Nautical-bell/Python/nautical-bell.py new file mode 100644 index 0000000000..e1acadf812 --- /dev/null +++ b/Task/Nautical-bell/Python/nautical-bell.py @@ -0,0 +1,63 @@ +import time, calendar, sched, winsound + +duration = 750 # Bell duration in ms +freq = 1280 # Bell frequency in hertz +bellchar = "\u2407" +watches = 'Middle,Morning,Forenoon,Afternoon,First/Last dog,First'.split(',') + +def gap(n=1): + time.sleep(n * duration / 1000) +off = gap + +def on(n=1): + winsound.Beep(freq, n * duration) + +def bong(): + on(); off(0.5) + +def bongs(m): + for i in range(m): + print(bellchar, end=' ') + bong() + if i % 2: + print(' ', end='') + off(0.5) + print('') + +scheds = sched.scheduler(time.time, time.sleep) + +def ships_bell(now=None): + def adjust_to_half_hour(atime): + atime[4] = (atime[4] // 30) * 30 + atime[5] = 0 + return atime + + debug = now is not None + rightnow = time.gmtime() + if not debug: + now = adjust_to_half_hour( list(rightnow) ) + then = now[::] + then[4] += 30 + hr, mn = now[3:5] + watch, b = divmod(int(2 * hr + mn // 30 - 1), 8) + b += 1 + bells = '%i bell%s' % (b, 's' if b > 1 else ' ') + if debug: + print("%02i:%02i, %-20s %s" % (now[3], now[4], watches[watch] + ' watch', bells), end=' ') + else: + print("%02i:%02i, %-20s %s" % (rightnow[3], rightnow[4], watches[watch] + ' watch', bells), end=' ') + bongs(b) + if not debug: + scheds.enterabs(calendar.timegm(then), 0, ships_bell) + #print(time.struct_time(then)) + scheds.run() + +def dbg_tester(): + for h in range(24): + for m in (0, 30): + if (h,m) == (24,30): break + ships_bell( [2013, 3, 2, h, m, 15, 5, 61, 0] ) + + +if __name__ == '__main__': + ships_bell() diff --git a/Task/Nautical-bell/REXX/nautical-bell.rexx b/Task/Nautical-bell/REXX/nautical-bell.rexx new file mode 100644 index 0000000000..587d97fc64 --- /dev/null +++ b/Task/Nautical-bell/REXX/nautical-bell.rexx @@ -0,0 +1,24 @@ +/*REXX pgm sounds "bells" (using PC speaker) when running (perpetually).*/ +echo= arg()\==0 /*echo time & bells if any args. */ +signal on halt /*allow a clean way to stop prog.*/ +t.1 = '00:30 01:00 01:30 02:00 02:30 03:00 03:30 04:00' +t.2 = '04:30 05:00 05:30 06:00 06:30 07:00 07:30 08:00' +t.3 = '08:30 09:00 09:30 10:00 10:30 11:00 11:30 12:00' + + do forever; t=time(); ss=right(t,2); mn=right(t,2) /*times.*/ + ct=time('C') /*[↓] add leading zero.*/ + hhmmc=left( right( ct, 7, 0), 5) /*HH:MM (leading zero).*/ + if echo then say center(arg(1) ct, 79) /*echo arg1 with time ?*/ + if ss\==00 & mn\==00 & mn\==30 then /*wait for next min ? */ + do; call delay 60-ss; iterate; end /*delay fraction of min*/ + + /*[↓] # bells to peel.*/ + do j=1 for 3 until $\==0; $=wordpos(hhmmc,t.j); end /*j*/ + + if $\==0 & echo then say center($ "bells", 79) /*echo bells? */ + + do k=1 for $; call sound 650,1; call delay 1+(k//2==0); end /*k*/ + /*[↑] peel and pause.*/ + call delay 60 /*ensure don't re-peel.*/ + end /*forever*/ +halt: /*stick a fork in it, we're done.*/ diff --git a/Task/Nautical-bell/Tcl/nautical-bell.tcl b/Task/Nautical-bell/Tcl/nautical-bell.tcl new file mode 100644 index 0000000000..9ead6b06e2 --- /dev/null +++ b/Task/Nautical-bell/Tcl/nautical-bell.tcl @@ -0,0 +1,75 @@ +# More sophisticated versions are possible, such as playing a bell sample +# using the Snack library. +proc ringTheBell {} { + puts -nonewline "\a" +} + +# The code to convert the (parsed) time into rings of the ship's bell and +# printing of the name of the bell. +proc strikeBell {hour minute} { + global suppressNormalOutput + set watches { + Middle Middle Morning Morning Forenoon Forenoon + Afternoon Afternoon {First dog} {Last dog} First First + } + set cardinals {one two three four five six seven eight} + set bells [expr {(($hour % 4) * 2 + $minute / 30)}] + if {!$bells} {set bells 8} + puts -nonewline [format "%02d:%02d %9s watch, %6s bell%s gone: \t" \ + $hour $minute [lindex $watches [expr { + ($hour/2 - ($minute==0 && $hour%2==0)) % 12 + }]] [lindex $cardinals [expr {$bells - 1}]] \ + [expr {$bells == 1 ? "" : "s"}]] + + # Set up the ringing of the bells to be done asynchronously + set t 0 + set suppressNormalOutput 1 + for {set i 0} {$i < $bells-1} {incr i 2} { + after $t { + ringTheBell + puts -nonewline "\u266b " + } + incr t 250 + after $t { + ringTheBell + } + incr t 750 + } + if {$bells % 2} { + after $t { + ringTheBell + puts -nonewline "\u266a\n" + set suppressNormalOutput 0 + } + } else { + after $t { + puts "" + set suppressNormalOutput 0 + } + } +} + +# Main handler; designed to be called every second, which is plenty. +proc nauticalBell {} { + global last suppressNormalOutput + scan [clock format [clock seconds] -format "%H:%M" -gmt 1] "%d:%d" h m + if {$last != $m} { + set last $m + if {$m%30 == 0} { + strikeBell $h $m + } elseif {!$suppressNormalOutput} { + puts -nonewline [format "%02d:%02d\r" $h $m] + } + } +} + +# Set things up, using Tcl's event loop to do the processing +proc every {delay script} { + after $delay [list every $delay $script] + uplevel #0 $script +} +set last "" +set suppressNormalOutput 0 +fconfigure stdout -buffering none +every 1000 nauticalBell +vwait forever; # Only needed if not running an event loop otherwise diff --git a/Task/Non-continuous-subsequences/0DESCRIPTION b/Task/Non-continuous-subsequences/0DESCRIPTION new file mode 100644 index 0000000000..1a69a354d5 --- /dev/null +++ b/Task/Non-continuous-subsequences/0DESCRIPTION @@ -0,0 +1,11 @@ +Consider some sequence of elements. (It differs from a mere set of elements by having an ordering among members.) + +A ''subsequence'' contains some subset of the elements of this sequence, in the same order. + +A ''continuous'' subsequence is one in which no elements are missing between the first and last elements of the subsequence. + +Note: Subsequences are defined ''structurally'', not by their contents. So a sequence ''a,b,c,d'' will always have the same subsequences and continuous subsequences, no matter which values are substituted; it may even be the same value. + +'''Task''': Find all non-continuous subsequences for a given sequence. Example: For the sequence ''1,2,3,4'', there are five non-continuous subsequences, namely ''1,3''; ''1,4''; ''2,4''; ''1,3,4'' and ''1,2,4''. + +'''Goal''': There are different ways to calculate those subsequences. Demonstrate algorithm(s) that are natural for the language. diff --git a/Task/Non-continuous-subsequences/1META.yaml b/Task/Non-continuous-subsequences/1META.yaml new file mode 100644 index 0000000000..9e130e8a7b --- /dev/null +++ b/Task/Non-continuous-subsequences/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Discrete math diff --git a/Task/Non-continuous-subsequences/ALGOL-68/non-continuous-subsequences-1.alg b/Task/Non-continuous-subsequences/ALGOL-68/non-continuous-subsequences-1.alg new file mode 100644 index 0000000000..ffa58d427b --- /dev/null +++ b/Task/Non-continuous-subsequences/ALGOL-68/non-continuous-subsequences-1.alg @@ -0,0 +1,35 @@ +PROC test non continuous = VOID: BEGIN + MODE SEQMODE = CHAR; + MODE SEQ = [1:0]SEQMODE; + MODE YIELDSEQ = PROC(SEQ)VOID; + + PROC gen ncs = + ( SEQ tail, # To generate subsequences of # + SEQ head, # Already generated # + BOOL contiguous,# It is still continuous # + YIELDSEQ yield + ) VOID: + BEGIN + IF NOT contiguous ANDTH UPB head > 1 THEN + yield (head) + FI; + IF UPB tail /= 0 THEN + [UPB head+1]SEQMODE new head; + new head [:UPB head] := head; + FOR i TO UPB tail DO + new head [UPB new head] := tail [i]; + gen ncs + ( tail[i + 1:UPB tail], + new head, + contiguous ANDTH (i = LWB tail OREL UPB head = 0), + yield + ) + OD + FI + END # put ncs #; + + # FOR SEQ seq IN # gen ncs(("a","e","i","o","u"), (), TRUE, # ) DO ( # + ## (SEQ seq)VOID: + print((seq, new line)) + # OD # ) +END; test non continuous diff --git a/Task/Non-continuous-subsequences/ALGOL-68/non-continuous-subsequences-2.alg b/Task/Non-continuous-subsequences/ALGOL-68/non-continuous-subsequences-2.alg new file mode 100644 index 0000000000..13a068becc --- /dev/null +++ b/Task/Non-continuous-subsequences/ALGOL-68/non-continuous-subsequences-2.alg @@ -0,0 +1,47 @@ +MODE SEQMODE = STRING; +MODE SEQ = [1:0]SEQMODE; +MODE YIELDSEQ = PROC(SEQ)VOID; + +PROC gen ncs = (SEQ seq, YIELDSEQ yield)VOID: +BEGIN + IF UPB seq - 1 > bits width THEN stop FI; + [UPB seq]SEQMODE out; INT upb out; + + BITS lim := 16r1 SHL UPB seq; + BITS upb k := lim SHR 1; + # assert(lim); # + + BITS empty = 16r000000000; # const # + + FOR j TO ABS lim-1 DO + INT state := 1; + BITS k1 := upb k; + WHILE k1 NE empty DO + BITS b := BIN j AND k1; + CASE state IN + # state 1 # IF b NE empty THEN state +:= 1 FI, + # state 2 # IF b EQ empty THEN state +:= 1 FI, + # state 3 # + BEGIN + IF b EQ empty THEN GO TO continue k1 FI; + upb out := 0; + BITS k2 := upb k; FOR i WHILE k2 NE empty DO + IF (BIN j AND k2) NE empty THEN out[upb out +:= 1] := seq[i] FI; + k2 := k2 SHR 1 + OD; + yield(out[:upb out]); + k1 := empty # empty: ending containing loop # + END + ESAC; + continue k1: k1 := k1 SHR 1 + OD + OD +END; + +main:( + []STRING seqs = ("a","e","i","o","u"); +# FOR SEQ seq IN # gen ncs(seqs, # ) DO ( # +## (SEQ seq)VOID: + print((seq, new line)) +# OD # ) +) diff --git a/Task/Non-continuous-subsequences/Ada/non-continuous-subsequences.ada b/Task/Non-continuous-subsequences/Ada/non-continuous-subsequences.ada new file mode 100644 index 0000000000..ff88f76ea3 --- /dev/null +++ b/Task/Non-continuous-subsequences/Ada/non-continuous-subsequences.ada @@ -0,0 +1,37 @@ +with Ada.Text_IO; use Ada.Text_IO; + +procedure Test_Non_Continuous is + type Sequence is array (Positive range <>) of Integer; + procedure Put_NCS + ( Tail : Sequence; -- To generate subsequences of + Head : Sequence := (1..0 => 1); -- Already generated + Contiguous : Boolean := True -- It is still continuous + ) is + begin + if not Contiguous and then Head'Length > 1 then + for I in Head'Range loop + Put (Integer'Image (Head (I))); + end loop; + New_Line; + end if; + if Tail'Length /= 0 then + declare + New_Head : Sequence (Head'First..Head'Last + 1); + begin + New_Head (Head'Range) := Head; + for I in Tail'Range loop + New_Head (New_Head'Last) := Tail (I); + Put_NCS + ( Tail => Tail (I + 1..Tail'Last), + Head => New_Head, + Contiguous => Contiguous and then (I = Tail'First or else Head'Length = 0) + ); + end loop; + end; + end if; + end Put_NCS; +begin + Put_NCS ((1,2,3)); New_Line; + Put_NCS ((1,2,3,4)); New_Line; + Put_NCS ((1,2,3,4,5)); New_Line; +end Test_Non_Continuous; diff --git a/Task/Non-continuous-subsequences/AutoHotkey/non-continuous-subsequences.ahk b/Task/Non-continuous-subsequences/AutoHotkey/non-continuous-subsequences.ahk new file mode 100644 index 0000000000..ffaa9638c3 --- /dev/null +++ b/Task/Non-continuous-subsequences/AutoHotkey/non-continuous-subsequences.ahk @@ -0,0 +1,20 @@ +MsgBox % noncontinuous("a,b,c,d,e", ",") +MsgBox % noncontinuous("1,2,3,4", ",") + +noncontinuous(list, delimiter) +{ +stringsplit, seq, list, %delimiter% +n := seq0 ; sequence length +Loop % x := (1< number + t .= "`n" ; new sequences in new lines + } +} +return t +} + +ToBin(n,W=16) { ; LS W-bits of Binary representation of n + Return W=1 ? n&1 : ToBin(n>>1,W-1) . n&1 +} diff --git a/Task/Non-continuous-subsequences/BBC-BASIC/non-continuous-subsequences.bbc b/Task/Non-continuous-subsequences/BBC-BASIC/non-continuous-subsequences.bbc new file mode 100644 index 0000000000..36b6283231 --- /dev/null +++ b/Task/Non-continuous-subsequences/BBC-BASIC/non-continuous-subsequences.bbc @@ -0,0 +1,32 @@ + DIM list1$(3) + list1$() = "1", "2", "3", "4" + PRINT "For [1, 2, 3, 4] non-continuous subsequences are:" + PROCnon_continuous_subsequences(list1$()) + DIM list2$(4) + list2$() = "1", "2", "3", "4", "5" + PRINT "For [1, 2, 3, 4, 5] non-continuous subsequences are:" + PROCnon_continuous_subsequences(list2$()) + END + + DEF PROCnon_continuous_subsequences(l$()) + LOCAL i%, j%, g%, n%, r%, s%, w%, a$, b$ + n% = DIM(l$(),1) + FOR s% = 0 TO n%-2 + FOR g% = s%+1 TO n%-1 + a$ = "[" + FOR i% = s% TO g%-1 + a$ += l$(i%) + ", " + NEXT + FOR w% = 1 TO n%-g% + r% = n%+1-g%-w% + FOR i% = 1 TO 2^r%-1 STEP 2 + b$ = a$ + FOR j% = 0 TO r%-1 + IF i% AND 2^j% b$ += l$(g%+w%+j%) + ", " + NEXT + PRINT LEFT$(LEFT$(b$)) + "]" + NEXT i% + NEXT w% + NEXT g% + NEXT s% + ENDPROC diff --git a/Task/Non-continuous-subsequences/Bracmat/non-continuous-subsequences.bracmat b/Task/Non-continuous-subsequences/Bracmat/non-continuous-subsequences.bracmat new file mode 100644 index 0000000000..8cd24addea --- /dev/null +++ b/Task/Non-continuous-subsequences/Bracmat/non-continuous-subsequences.bracmat @@ -0,0 +1,20 @@ +( ( noncontinuous + = sub + . ( sub + = su a nc + . !arg:(?su.?nc) + & !su + : % + %?a + ( %:[%(sub$(!sjt.!nc !a)) + | ? + & !nc:~ + & out$(!nc !a) + & ~ + ) + ) + & sub$(dummy !arg.) + | + ) +& noncontinuous$(e r n i t) +); diff --git a/Task/Non-continuous-subsequences/C/non-continuous-subsequences-1.c b/Task/Non-continuous-subsequences/C/non-continuous-subsequences-1.c new file mode 100644 index 0000000000..7fa8a9091e --- /dev/null +++ b/Task/Non-continuous-subsequences/C/non-continuous-subsequences-1.c @@ -0,0 +1,20 @@ +#include +#include + +int main(int c, char **v) +{ + unsigned int n = 1 << (c - 1), i = n, j, k; + assert(n); + + while (i--) { + if (!(i & (i + (i & -(int)i)))) // consecutive 1s + continue; + + for (j = n, k = 1; j >>= 1; k++) + if (i & j) printf("%s ", v[k]); + + putchar('\n'); + } + + return 0; +} diff --git a/Task/Non-continuous-subsequences/C/non-continuous-subsequences-2.c b/Task/Non-continuous-subsequences/C/non-continuous-subsequences-2.c new file mode 100644 index 0000000000..293880ce50 --- /dev/null +++ b/Task/Non-continuous-subsequences/C/non-continuous-subsequences-2.c @@ -0,0 +1,25 @@ +#include +#include +#include + +void binprint(unsigned int n, unsigned int m) +{ + char c[sizeof(n) * 8 + 1]; + int i = 0; + while (m >>= 1) c[i++] = n & m ? '#' : '-'; + c[i] = 0; + puts(c); +} + +int main(int c, char **v) +{ + unsigned int n, gap, left, right; + if (c < 2 || ! (n = 1 << atoi(v[1]))) n = 16; + + for (gap = 2; gap < n; gap <<= 1) + for (left = gap << 1; left < n; left |= left << 1) + for (right = 1; right < gap; right++) + binprint(left | right, n); + + return 0; +} diff --git a/Task/Non-continuous-subsequences/C/non-continuous-subsequences-3.c b/Task/Non-continuous-subsequences/C/non-continuous-subsequences-3.c new file mode 100644 index 0000000000..bed117754c --- /dev/null +++ b/Task/Non-continuous-subsequences/C/non-continuous-subsequences-3.c @@ -0,0 +1,51 @@ +#include + +typedef unsigned char sint; +enum states { s_blnk = 0, s_tran, s_cont, s_disj }; + +/* Recursively look at each item in list, taking both choices of + picking the item or not. The state at each step depends on prvious + pickings, with the state transition table: + blank + no pick -> blank + blank + pick -> contiguous + transitional + no pick -> transitional + transitional + pick -> disjoint + contiguous + no pick -> transitional + contiguous + pick -> contiguous + disjoint + pick -> disjoint + disjoint + no pick -> disjoint + At first step, before looking at any item, state is blank. + Because state is known at each step and needs not be calculated, + it can be quite fast. +*/ +unsigned char tbl[][2] = { + { s_blnk, s_cont }, + { s_tran, s_disj }, + { s_tran, s_cont }, + { s_disj, s_disj }, +}; + +void pick(sint n, sint step, sint state, char **v, unsigned long bits) +{ + int i, b; + if (step == n) { + if (state != s_disj) return; + for (i = 0, b = 1; i < n; i++, b <<= 1) + if ((b & bits)) printf("%s ", v[i]); + putchar('\n'); + return; + } + + bits <<= 1; + pick(n, step + 1, tbl[state][0], v, bits); /* no pick */ + pick(n, step + 1, tbl[state][1], v, bits | 1); /* pick */ +} + +int main(int c, char **v) +{ + if (c - 1 >= sizeof(unsigned long) * 4) + printf("Too many items"); + else + pick(c - 1, 0, s_blnk, v + 1, 0); + return 0; +} diff --git a/Task/Non-continuous-subsequences/Clojure/non-continuous-subsequences.clj b/Task/Non-continuous-subsequences/Clojure/non-continuous-subsequences.clj new file mode 100644 index 0000000000..e5af46f21e --- /dev/null +++ b/Task/Non-continuous-subsequences/Clojure/non-continuous-subsequences.clj @@ -0,0 +1,16 @@ +(use '[clojure.contrib.combinatorics :only (subsets)]) + +(defn of-min-length [min-length] + (fn [s] (>= (count s) min-length))) + +(defn runs [c l] + (map (partial take l) (take-while not-empty (iterate rest c)))) + +(defn is-subseq? [c sub] + (some identity (map = (runs c (count sub)) (repeat sub)))) + +(defn non-continuous-subsequences [s] + (filter (complement (partial is-subseq? s)) (subsets s))) + + +(filter (of-min-length 2) (non-continuous-subsequences [:a :b :c :d])) diff --git a/Task/Non-continuous-subsequences/CoffeeScript/non-continuous-subsequences-1.coffeescript b/Task/Non-continuous-subsequences/CoffeeScript/non-continuous-subsequences-1.coffeescript new file mode 100644 index 0000000000..083089fd98 --- /dev/null +++ b/Task/Non-continuous-subsequences/CoffeeScript/non-continuous-subsequences-1.coffeescript @@ -0,0 +1,57 @@ +is_contigous_binary = (n) -> + # return true if binary representation of n is + # of the form 1+0+ + # examples: + # 0 true + # 1 true + # 100 true + # 110 true + # 1001 false + # 1010 false + + # special case zero, or you'll get an infinite loop later + return true if n == 0 + + # first remove 0s from end + while n % 2 == 0 + n = n / 2 + + # next, take advantage of the fact that a continuous + # run of 1s would be of the form 2^n - 1 + is_power_of_two(n + 1) + +is_power_of_two = (m) -> + while m % 2 == 0 + m = m / 2 + m == 1 + +seq_from_bitmap = (arr, n) -> + # grabs elements from array according to a bitmap + # e.g. if n == 13 (1101), and arr = ['a', 'b', 'c', 'd'], + # then return ['a', 'c', 'd'] (flipping bits to 1011, so + # that least significant bit comes first) + i = 0 + new_arr = [] + while n > 0 + if n % 2 == 1 + new_arr.push arr[i] + n -= 1 + n /= 2 + i += 1 + new_arr + +non_contig_subsequences = (arr) -> + # Return all subsqeuences from an array that have a "hole" in + # them. The order of the subsequences is not specified here. + + # This algorithm uses binary counting, so it is limited to + # small lists, but large lists would be unwieldy regardless. + bitmasks = [0...Math.pow(2, arr.length)] + (seq_from_bitmap arr, n for n in bitmasks when !is_contigous_binary n) + +arr = [1,2,3,4] +console.log non_contig_subsequences arr +for n in [1..10] + arr = [1..n] + num_solutions = non_contig_subsequences(arr).length + console.log "for n=#{n} there are #{num_solutions} solutions" diff --git a/Task/Non-continuous-subsequences/CoffeeScript/non-continuous-subsequences-2.coffeescript b/Task/Non-continuous-subsequences/CoffeeScript/non-continuous-subsequences-2.coffeescript new file mode 100644 index 0000000000..33d7bfd36c --- /dev/null +++ b/Task/Non-continuous-subsequences/CoffeeScript/non-continuous-subsequences-2.coffeescript @@ -0,0 +1,16 @@ +> coffee non_contig_subseq.coffee +[ [ 1, 3 ], + [ 1, 4 ], + [ 2, 4 ], + [ 1, 2, 4 ], + [ 1, 3, 4 ] ] +for n=1 there are 0 solutions +for n=2 there are 0 solutions +for n=3 there are 1 solutions +for n=4 there are 5 solutions +for n=5 there are 16 solutions +for n=6 there are 42 solutions +for n=7 there are 99 solutions +for n=8 there are 219 solutions +for n=9 there are 466 solutions +for n=10 there are 968 solutions diff --git a/Task/Non-continuous-subsequences/Common-Lisp/non-continuous-subsequences-1.lisp b/Task/Non-continuous-subsequences/Common-Lisp/non-continuous-subsequences-1.lisp new file mode 100644 index 0000000000..922bd0ce1d --- /dev/null +++ b/Task/Non-continuous-subsequences/Common-Lisp/non-continuous-subsequences-1.lisp @@ -0,0 +1,21 @@ +(defun all-subsequences (list) + (labels ((subsequences (tail &optional (acc '()) (result '())) + "Return a list of the subsequence designators of the + subsequences of tail. Each subsequence designator is a + list of tails of tail, the subsequence being the first + element of each tail." + (if (endp tail) + (list* (reverse acc) result) + (subsequences (rest tail) (list* tail acc) + (append (subsequences (rest tail) acc) result)))) + (continuous-p (subsequence-d) + "True if the designated subsequence is continuous." + (loop for i in subsequence-d + for j on (first subsequence-d) + always (eq i j))) + (designated-sequence (subsequence-d) + "Destructively transforms a subsequence designator into + the designated subsequence." + (map-into subsequence-d 'first subsequence-d))) + (let ((nc-subsequences (delete-if #'continuous-p (subsequences list)))) + (map-into nc-subsequences #'designated-sequence nc-subsequences)))) diff --git a/Task/Non-continuous-subsequences/Common-Lisp/non-continuous-subsequences-2.lisp b/Task/Non-continuous-subsequences/Common-Lisp/non-continuous-subsequences-2.lisp new file mode 100644 index 0000000000..2297b1967e --- /dev/null +++ b/Task/Non-continuous-subsequences/Common-Lisp/non-continuous-subsequences-2.lisp @@ -0,0 +1,16 @@ +(defun all-subsequences2 (list) + (labels ((recurse (s list) + (if (endp list) + (if (>= s 3) + '(()) + '()) + (let ((x (car list)) + (xs (cdr list))) + (if (evenp s) + (append (mapcar (lambda (ys) (cons x ys)) + (recurse (+ s 1) xs)) + (recurse s xs)) + (append (mapcar (lambda (ys) (cons x ys)) + (recurse s xs)) + (recurse (+ s 1) xs))))))) + (recurse 0 list))) diff --git a/Task/Non-continuous-subsequences/D/non-continuous-subsequences-1.d b/Task/Non-continuous-subsequences/D/non-continuous-subsequences-1.d new file mode 100644 index 0000000000..d28fc9fdf3 --- /dev/null +++ b/Task/Non-continuous-subsequences/D/non-continuous-subsequences-1.d @@ -0,0 +1,18 @@ +import std.stdio; + +T[][] ncsub(T)(in T[] seq, in int s=0) pure nothrow { + if (seq.length) { + T[][] aux; + foreach (ys; ncsub(seq[1..$], s + !(s % 2))) + aux ~= seq[0] ~ ys; + return aux ~ ncsub(seq[1..$], s + s % 2); + } else + return new T[][](s >= 3, 0); +} + +void main() { + writeln(ncsub([1, 2, 3])); + writeln(ncsub([1, 2, 3, 4])); + foreach (nc; ncsub([1, 2, 3, 4, 5])) + writeln(nc); +} diff --git a/Task/Non-continuous-subsequences/D/non-continuous-subsequences-2.d b/Task/Non-continuous-subsequences/D/non-continuous-subsequences-2.d new file mode 100644 index 0000000000..3c74a151e3 --- /dev/null +++ b/Task/Non-continuous-subsequences/D/non-continuous-subsequences-2.d @@ -0,0 +1,43 @@ +struct Ncsub(T) { + T[] seq; + + int opApply(int delegate(ref int[]) dg) const { + immutable int n = seq.length; + int result; + auto S = new int[n]; + + FOR_I: + foreach (i; 1 .. 1 << seq.length) { + int len_S; + bool nc = false; + foreach (j; 0 .. seq.length + 1) { + immutable int k = i >> j; + if (k == 0) { + if (nc) { + auto auxS = S[0 .. len_S]; + result = dg(auxS); + if (result) + break FOR_I; + } + break; + } else if (k % 2) { + S[len_S] = seq[j]; + len_S++; + } else if (len_S) + nc = true; + } + } + + return result; + } +} + +void main() { + import std.array, std.range; + //assert(iota(24).array().Ncsub!int().walkLength() == 16_776_915); + auto r = array(iota(24)); + int counter; + foreach (s; Ncsub!int(r)) + counter++; + assert(counter == 16_776_915); +} diff --git a/Task/Non-continuous-subsequences/Go/non-continuous-subsequences.go b/Task/Non-continuous-subsequences/Go/non-continuous-subsequences.go new file mode 100644 index 0000000000..40c7fe31eb --- /dev/null +++ b/Task/Non-continuous-subsequences/Go/non-continuous-subsequences.go @@ -0,0 +1,39 @@ +package main + +import "fmt" + +const ( // state: + m = iota // missing: all elements missing so far + c // continuous: all elements included so far are continuous + cm // one or more continuous followed by one or more missing + cmc // non-continuous subsequence +) + +func ncs(s []int) [][]int { + if len(s) < 3 { + return nil + } + return append(n2(nil, s[1:], m), n2([]int{s[0]}, s[1:], c)...) +} + +var skip = []int{m, cm, cm, cmc} +var incl = []int{c, c, cmc, cmc} + +func n2(ss, tail []int, seq int) [][]int { + if len(tail) == 0 { + if seq != cmc { + return nil + } + return [][]int{ss} + } + return append(n2(append([]int{}, ss...), tail[1:], skip[seq]), + n2(append(ss, tail[0]), tail[1:], incl[seq])...) +} + +func main() { + ss := ncs([]int{1, 2, 3, 4}) + fmt.Println(len(ss), "non-continuous subsequences:") + for _, s := range ss { + fmt.Println(" ", s) + } +} diff --git a/Task/Non-continuous-subsequences/Haskell/non-continuous-subsequences-1.hs b/Task/Non-continuous-subsequences/Haskell/non-continuous-subsequences-1.hs new file mode 100644 index 0000000000..a0e69bf206 --- /dev/null +++ b/Task/Non-continuous-subsequences/Haskell/non-continuous-subsequences-1.hs @@ -0,0 +1,9 @@ +action p x = if p x then succ x else x + +fenceM p q s [] = guard (q s) >> return [] +fenceM p q s (x:xs) = do + (f,g) <- p + ys <- fenceM p q (g s) xs + return $ f x ys + +ncsubseq = fenceM [((:), action even), (flip const, action odd)] (>= 3) 0 diff --git a/Task/Non-continuous-subsequences/Haskell/non-continuous-subsequences-2.hs b/Task/Non-continuous-subsequences/Haskell/non-continuous-subsequences-2.hs new file mode 100644 index 0000000000..bd98465c28 --- /dev/null +++ b/Task/Non-continuous-subsequences/Haskell/non-continuous-subsequences-2.hs @@ -0,0 +1,4 @@ +continuous = null . dropWhile not . dropWhile id . dropWhile not +ncs xs = map (map fst . filter snd . zip xs) $ + filter (not . continuous) $ + mapM (const [True,False]) xs diff --git a/Task/Non-continuous-subsequences/Haskell/non-continuous-subsequences-3.hs b/Task/Non-continuous-subsequences/Haskell/non-continuous-subsequences-3.hs new file mode 100644 index 0000000000..fb90efc6b7 --- /dev/null +++ b/Task/Non-continuous-subsequences/Haskell/non-continuous-subsequences-3.hs @@ -0,0 +1,10 @@ +import Data.List + +poset = foldr (\x p -> p ++ map (x:) p) [[]] + +ncsubs [] = [[]] +ncsubs (x:xs) = tail $ nc [x] xs + where + nc [_] [] = [[]] + nc (_:x:xs) [] = nc [x] xs + nc xs (y:ys) = (nc (xs++[y]) ys) ++ map (xs++) (tail $ poset ys) diff --git a/Task/Non-continuous-subsequences/Haskell/non-continuous-subsequences-4.hs b/Task/Non-continuous-subsequences/Haskell/non-continuous-subsequences-4.hs new file mode 100644 index 0000000000..a4313a4186 --- /dev/null +++ b/Task/Non-continuous-subsequences/Haskell/non-continuous-subsequences-4.hs @@ -0,0 +1,8 @@ +import Data.List (subsequences, tails, delete) + +disjoint a = concatMap (cutAt a) [1..length a - 2] where + cutAt s n = [a ++ b | b <- delete [] (subsequences right), + a <- init (tails left) ] where + (left, _:right) = splitAt n s + +main = print $ length $ disjoint [1..20] diff --git a/Task/Non-continuous-subsequences/Haskell/non-continuous-subsequences-5.hs b/Task/Non-continuous-subsequences/Haskell/non-continuous-subsequences-5.hs new file mode 100644 index 0000000000..1783736edc --- /dev/null +++ b/Task/Non-continuous-subsequences/Haskell/non-continuous-subsequences-5.hs @@ -0,0 +1,15 @@ +import Data.List (inits, tails) + +subseqs [] = [] +subseqs (x:xs) = [x] : map (x:) s ++ s where s = subseqs xs + +consecs x = concatMap (tail.inits) (tails x) + +minus [] [] = [] +minus (a:as) bb@(b:bs) + | a == b = minus as bs + | otherwise = a:minus as bb + +disjoint s = (subseqs s) `minus` (consecs s) + +main = mapM_ print $ disjoint [1..4] diff --git a/Task/Non-continuous-subsequences/J/non-continuous-subsequences-1.j b/Task/Non-continuous-subsequences/J/non-continuous-subsequences-1.j new file mode 100644 index 0000000000..1ef2f0636d --- /dev/null +++ b/Task/Non-continuous-subsequences/J/non-continuous-subsequences-1.j @@ -0,0 +1,4 @@ +allmasks=: 2 #:@i.@^ # +firstend=:1 0 i.&1@E."1 ] +laststart=: 0 1 {:@I.@E."1 ] +noncont=: <@#~ (#~ firstend < laststart)@allmasks diff --git a/Task/Non-continuous-subsequences/J/non-continuous-subsequences-2.j b/Task/Non-continuous-subsequences/J/non-continuous-subsequences-2.j new file mode 100644 index 0000000000..9875cea757 --- /dev/null +++ b/Task/Non-continuous-subsequences/J/non-continuous-subsequences-2.j @@ -0,0 +1,10 @@ + noncont 1+i.4 +┌───┬───┬───┬─────┬─────┐ +│2 4│1 4│1 3│1 3 4│1 2 4│ +└───┴───┴───┴─────┴─────┘ + noncont 'aeiou' +┌──┬──┬──┬───┬───┬──┬──┬───┬──┬───┬───┬────┬───┬───┬────┬────┐ +│iu│eu│eo│eou│eiu│au│ao│aou│ai│aiu│aio│aiou│aeu│aeo│aeou│aeiu│ +└──┴──┴──┴───┴───┴──┴──┴───┴──┴───┴───┴────┴───┴───┴────┴────┘ + #noncont i.10 +968 diff --git a/Task/Non-continuous-subsequences/J/non-continuous-subsequences-3.j b/Task/Non-continuous-subsequences/J/non-continuous-subsequences-3.j new file mode 100644 index 0000000000..b2879bd306 --- /dev/null +++ b/Task/Non-continuous-subsequences/J/non-continuous-subsequences-3.j @@ -0,0 +1,2 @@ +contmasks=: a: ;@, 1 <:/~@i.&.>@i.@+ # +noncont=: <@#~ (allmasks -. contmasks) diff --git a/Task/Non-continuous-subsequences/JavaScript/non-continuous-subsequences.js b/Task/Non-continuous-subsequences/JavaScript/non-continuous-subsequences.js new file mode 100644 index 0000000000..ba3b8ef451 --- /dev/null +++ b/Task/Non-continuous-subsequences/JavaScript/non-continuous-subsequences.js @@ -0,0 +1,24 @@ +function non_continuous_subsequences(ary) { + var non_continuous = new Array(); + for (var i = 0; i < ary.length; i++) { + if (! is_array_continuous(ary[i])) { + non_continuous.push(ary[i]); + } + } + return non_continuous; +} + +function is_array_continuous(ary) { + if (ary.length < 2) + return true; + for (var j = 1; j < ary.length; j++) { + if (ary[j] - ary[j-1] != 1) { + return false; + } + } + return true; +} + +load('json2.js'); /* http://www.json.org/js.html */ + +print(JSON.stringify( non_continuous_subsequences( powerset([1,2,3,4])))); diff --git a/Task/Non-continuous-subsequences/Mathematica/non-continuous-subsequences-1.math b/Task/Non-continuous-subsequences/Mathematica/non-continuous-subsequences-1.math new file mode 100644 index 0000000000..c86091322f --- /dev/null +++ b/Task/Non-continuous-subsequences/Mathematica/non-continuous-subsequences-1.math @@ -0,0 +1,3 @@ +GoodBad[i_List]:=Not[MatchQ[Differences[i],{1..}|{}]] +n=5 +Select[Subsets[Range[n]],GoodBad] diff --git a/Task/Non-continuous-subsequences/Mathematica/non-continuous-subsequences-2.math b/Task/Non-continuous-subsequences/Mathematica/non-continuous-subsequences-2.math new file mode 100644 index 0000000000..3302a979be --- /dev/null +++ b/Task/Non-continuous-subsequences/Mathematica/non-continuous-subsequences-2.math @@ -0,0 +1 @@ + {{1,3},{1,4},{1,5},{2,4},{2,5},{3,5},{1,2,4},{1,2,5},{1,3,4},{1,3,5},{1,4,5},{2,3,5},{2,4,5},{1,2,3,5},{1,2,4,5},{1,3,4,5}} diff --git a/Task/Non-continuous-subsequences/OCaml/non-continuous-subsequences.ocaml b/Task/Non-continuous-subsequences/OCaml/non-continuous-subsequences.ocaml new file mode 100644 index 0000000000..cb2a2d4fc8 --- /dev/null +++ b/Task/Non-continuous-subsequences/OCaml/non-continuous-subsequences.ocaml @@ -0,0 +1,22 @@ +let rec fence s = function + [] -> + if s >= 3 then + [[]] + else + [] + + | x :: xs -> + if s mod 2 = 0 then + List.map + (fun ys -> x :: ys) + (fence (s + 1) xs) + @ + fence s xs + else + List.map + (fun ys -> x :: ys) + (fence s xs) + @ + fence (s + 1) xs + +let ncsubseq = fence 0 diff --git a/Task/Non-continuous-subsequences/Oz/non-continuous-subsequences.oz b/Task/Non-continuous-subsequences/Oz/non-continuous-subsequences.oz new file mode 100644 index 0000000000..8e5272ca04 --- /dev/null +++ b/Task/Non-continuous-subsequences/Oz/non-continuous-subsequences.oz @@ -0,0 +1,25 @@ +declare + fun {NCSubseq SeqList} + Seq = {FS.value.make SeqList} + proc {Script Result} + %% the result is a subset of Seq + {FS.subset Result Seq} + + %% at least one element of Seq is missing + local Gap in + {FS.include Gap Seq} + {FS.exclude Gap Result} + %% and this element is between the smallest + %% and the largest elements of the subsequence + Gap >: {FS.int.min Result} + Gap <: {FS.int.max Result} + end + + %% enumerate all such sets + {FS.distribute naive [Result]} + end + in + {Map {SearchAll Script} FS.reflect.lowerBoundList} + end +in + {Inspect {NCSubseq [1 2 3 4]}} diff --git a/Task/Non-continuous-subsequences/Perl-6/non-continuous-subsequences.pl6 b/Task/Non-continuous-subsequences/Perl-6/non-continuous-subsequences.pl6 new file mode 100644 index 0000000000..0228a7d25e --- /dev/null +++ b/Task/Non-continuous-subsequences/Perl-6/non-continuous-subsequences.pl6 @@ -0,0 +1,11 @@ +sub non_continuous_subsequences ( *@list ) { + powerset(@list).grep: { 1 != all( .[ 0 ^.. .end] Z- .[0 ..^ .end] ) } +} + +sub powerset ( *@list ) { + reduce( -> @L, $n { [ @L, @L.map: {[ .list, $n ]} ] }, [[]], @list ); +} + +say ~ non_continuous_subsequences( 1..3 )».perl; +say ~ non_continuous_subsequences( 1..4 )».perl; +say ~ non_continuous_subsequences( ^4 ).map: {[[.list]].perl}; diff --git a/Task/Non-continuous-subsequences/Perl/non-continuous-subsequences.pl b/Task/Non-continuous-subsequences/Perl/non-continuous-subsequences.pl new file mode 100644 index 0000000000..dcb4a1ada3 --- /dev/null +++ b/Task/Non-continuous-subsequences/Perl/non-continuous-subsequences.pl @@ -0,0 +1,17 @@ +my ($max, @current); +sub non_continuous { + my ($idx, $has_gap, $found) = @_; + + for ($idx .. $max) { + push @current, $_; + # print "@current\n" if $has_gap; # uncomment for huge output + $found ++ if $has_gap; + $found += non_continuous($_ + 1, $has_gap) if $_ < $max; + pop @current; + $has_gap = @current; # don't set gap flag if it's empty still + } + $found; +} + +$max = 20; # 1048365 sequences, 10 seconds-ish +print "found ", non_continuous(1), " sequences\n"; diff --git a/Task/Non-continuous-subsequences/PicoLisp/non-continuous-subsequences.l b/Task/Non-continuous-subsequences/PicoLisp/non-continuous-subsequences.l new file mode 100644 index 0000000000..6c745da4cb --- /dev/null +++ b/Task/Non-continuous-subsequences/PicoLisp/non-continuous-subsequences.l @@ -0,0 +1,15 @@ +(de ncsubseq (Lst) + (let S 0 + (recur (S Lst) + (ifn Lst + (and (>= S 3) '(NIL)) + (let (X (car Lst) XS (cdr Lst)) + (ifn (bit? 1 S) # even + (conc + (mapcar '((YS) (cons X YS)) + (recurse (inc S) XS) ) + (recurse S XS) ) + (conc + (mapcar '((YS) (cons X YS)) + (recurse S XS) ) + (recurse (inc S) XS) ) ) ) ) ) ) ) diff --git a/Task/Non-continuous-subsequences/Pop11/non-continuous-subsequences-1.pop11 b/Task/Non-continuous-subsequences/Pop11/non-continuous-subsequences-1.pop11 new file mode 100644 index 0000000000..7e11154186 --- /dev/null +++ b/Task/Non-continuous-subsequences/Pop11/non-continuous-subsequences-1.pop11 @@ -0,0 +1,24 @@ +define ncsubseq(l); + lvars acc = [], gap_started = false, is_continuous = true; + define do_it(l1, l2); + dlocal gap_started; + lvars el, save_is_continuous = is_continuous; + if l2 = [] then + if not(is_continuous) then + cons(l1, acc) -> acc; + endif; + else + front(l2) -> el; + back(l2) -> l2; + not(gap_started) and is_continuous -> is_continuous; + do_it(cons(el, l1), l2); + save_is_continuous -> is_continuous; + not(l1 = []) or gap_started -> gap_started; + do_it(l1, l2); + endif; + enddefine; + do_it([], rev(l)); + acc; +enddefine; + +ncsubseq([1 2 3 4 5]) => diff --git a/Task/Non-continuous-subsequences/Pop11/non-continuous-subsequences-2.pop11 b/Task/Non-continuous-subsequences/Pop11/non-continuous-subsequences-2.pop11 new file mode 100644 index 0000000000..2f3e37f3cc --- /dev/null +++ b/Task/Non-continuous-subsequences/Pop11/non-continuous-subsequences-2.pop11 @@ -0,0 +1,2 @@ +[[1 3] [1 4] [2 4] [1 2 4] [1 3 4] [1 5] [2 5] [1 2 5] [3 5] [1 3 5] + [2 3 5] [1 2 3 5] [1 4 5] [2 4 5] [1 2 4 5] [1 3 4 5]] diff --git a/Task/Non-continuous-subsequences/PowerShell/non-continuous-subsequences.psh b/Task/Non-continuous-subsequences/PowerShell/non-continuous-subsequences.psh new file mode 100644 index 0000000000..e6eda94501 --- /dev/null +++ b/Task/Non-continuous-subsequences/PowerShell/non-continuous-subsequences.psh @@ -0,0 +1,69 @@ +Function SubSequence ( [Array] $S, [Boolean] $all=$false ) +{ + $sc = $S.count + if( $sc -gt ( 2 - [Int32] $all ) ) { + [void] $sc-- + 0..$sc | ForEach-Object { + $gap = $_ + "$( $S[ $_ ] )" + if( $gap -lt $sc ) + { + SubSequence ( ( $gap + 1 )..$sc | Where-Object { $_ -ne $gap } ) ( ( $gap -ne 0 ) -or $all ) | ForEach-Object { + [String]::Join( ',', ( ( [String]$_ ).Split(',') | ForEach-Object { + $lt = $true + } { + if( $lt -and ( $_ -gt $gap ) ) + { + $S[ $gap ] + $lt = $false + } + $S[ $_ ] + } { + if( $lt ) + { + $S[ $gap ] + } + } + ) ) + } + } + } + #[String]::Join( ',', $S) + } else { + $S | ForEach-Object { [String] $_ } + } +} + +Function NonContinuous-SubSequence ( [Array] $S ) +{ + $sc = $S.count + if( $sc -eq 3 ) + { + [String]::Join( ',', $S[ ( 0,2 ) ] ) + } elseif ( $sc -gt 3 ) { + [void] $sc-- + $gaps = @() + $gaps += ( ( NonContinuous-SubSequence ( 1..$sc ) ) | ForEach-Object { + $gap1 = ",$_," + "0,{0}" -f ( [String]::Join( ',', ( 1..$sc | Where-Object { $gap1 -notmatch "$_," } ) ) ) + } ) + $gaps += 1..( $sc - 1 ) + 2..( $sc - 1 ) | ForEach-Object { + $gap2 = $_ - 1 + $gaps += ( ( SubSequence ( $_..$sc ) ) | ForEach-Object { + "$gap2,$_" + } ) + } + #Write-Host "S $S gaps $gaps" + $gaps | ForEach-Object { + $gap3 = ",$_," + "$( 0..$sc | Where-Object { $gap3 -notmatch ",$_," } | ForEach-Object { + $S[$_] + } )" -replace ' ', ',' + } + } else { + $null + } +} + +( NonContinuous-SubSequence 'a','b','c','d','e' ) | Select-Object length, @{Name='value';Expression={ $_ } } | Sort-Object length, value | ForEach-Object { $_.value } diff --git a/Task/Non-continuous-subsequences/Prolog/non-continuous-subsequences-1.pro b/Task/Non-continuous-subsequences/Prolog/non-continuous-subsequences-1.pro new file mode 100644 index 0000000000..ab8233f4bb --- /dev/null +++ b/Task/Non-continuous-subsequences/Prolog/non-continuous-subsequences-1.pro @@ -0,0 +1,25 @@ +% fetch all the subsequences +ncsubs(L, LNCSL) :- + setof(NCSL, one_ncsubs(L, NCSL), LNCSL). + +% how to build one subsequence +one_ncsubs(L, NCSL) :- + extract_elem(L, NCSL); + ( sublist(L, L1), + one_ncsubs(L1, NCSL)). + +% extract one element of the list +% this element is neither the first nor the last. +extract_elem(L, NCSL) :- + length(L, Len), + Len1 is Len - 2, + between(1, Len1, I), + nth0(I, L, Elem), + select(Elem, L, NCS1), + ( NCSL = NCS1; extract_elem(NCS1, NCSL)). + +% extract the first or the last element of the list +sublist(L, SL) :- + (L = [_|SL]; + reverse(L, [_|SL1]), + reverse(SL1, SL)). diff --git a/Task/Non-continuous-subsequences/Prolog/non-continuous-subsequences-2.pro b/Task/Non-continuous-subsequences/Prolog/non-continuous-subsequences-2.pro new file mode 100644 index 0000000000..f9ff0b506a --- /dev/null +++ b/Task/Non-continuous-subsequences/Prolog/non-continuous-subsequences-2.pro @@ -0,0 +1,2 @@ +?- ncsubs([a,e,i,o,u], L). +L = [[a,e,i,u],[a,e,o],[a,e,o,u],[a,e,u],[a,i],[a,i,o],[a,i,o,u],[a,i,u],[a,o],[a,o,u],[a,u],[e,i,u],[e,o],[e,o,u],[e,u],[i,u]] diff --git a/Task/Non-continuous-subsequences/Python/non-continuous-subsequences-1.py b/Task/Non-continuous-subsequences/Python/non-continuous-subsequences-1.py new file mode 100644 index 0000000000..577d151d22 --- /dev/null +++ b/Task/Non-continuous-subsequences/Python/non-continuous-subsequences-1.py @@ -0,0 +1,9 @@ +def ncsub(seq, s=0): + if seq: + x = seq[:1] + xs = seq[1:] + p2 = s % 2 + p1 = not p2 + return [x + ys for ys in ncsub(xs, s + p1)] + ncsub(xs, s + p2) + else: + return [[]] if s >= 3 else [] diff --git a/Task/Non-continuous-subsequences/Python/non-continuous-subsequences-2.py b/Task/Non-continuous-subsequences/Python/non-continuous-subsequences-2.py new file mode 100644 index 0000000000..700c6541f1 --- /dev/null +++ b/Task/Non-continuous-subsequences/Python/non-continuous-subsequences-2.py @@ -0,0 +1,40 @@ +from sys import argv +import psyco + +def C(n, k): + result = 1 + for d in xrange(1, k+1): + result *= n + n -= 1 + result /= d + return result + +# http://oeis.org/A002662 +nsubs = lambda n: sum(C(n, k) for k in xrange(3, n+1)) + +def ncsub(seq): + n = len(seq) + result = [None] * nsubs(n) + pos = 0 + + for i in xrange(1, 2 ** n): + S = [] + nc = False + for j in xrange(n + 1): + k = i >> j + if k == 0: + if nc: + result[pos] = S + pos += 1 + break + elif k % 2: + S.append(seq[j]) + elif S: + nc = True + return result + +from sys import argv +import psyco +psyco.full() +n = 10 if len(argv) < 2 else int(argv[1]) +print len( ncsub(range(1, n)) ) diff --git a/Task/Non-continuous-subsequences/R/non-continuous-subsequences.r b/Task/Non-continuous-subsequences/R/non-continuous-subsequences.r new file mode 100644 index 0000000000..0dbb6ab040 --- /dev/null +++ b/Task/Non-continuous-subsequences/R/non-continuous-subsequences.r @@ -0,0 +1,17 @@ +ncsub <- function(x) +{ + n <- length(x) + a <- seq_len(n) + seqlist <- list() + for(i in 2:(n-1)) + { + seqs <- combn(a, i) # Get all subseqs + ok <- apply(seqs, 2, function(x) any(diff(x)!=1)) # Find noncts ones + newseqs <- unlist(apply(seqs[,ok], 2, function(x) list(x)), recursive=FALSE) # Convert matrix to list of its columns + seqlist <- c(seqlist, newseqs) # Append to existing list + } + lapply(seqlist, function(index) x[index]) +} +# Example usage +ncsub(1:4) +ncsub(letters[1:5]) diff --git a/Task/Non-continuous-subsequences/REXX/non-continuous-subsequences.rexx b/Task/Non-continuous-subsequences/REXX/non-continuous-subsequences.rexx new file mode 100644 index 0000000000..7723033ca1 --- /dev/null +++ b/Task/Non-continuous-subsequences/REXX/non-continuous-subsequences.rexx @@ -0,0 +1,33 @@ +/*REXX program to list non-continuous subsequences (NCS), given a seq.*/ +parse arg list /*the the list from the CL.*/ +if list='' then list=1 2 3 4 5 /*Specified? Use default. */ +say 'list=' space(list); say /*show list to the terminal*/ +w=words(list) ; #=0 /*# words in list; # of NCS*/ +$=left(123456789,w) /*build a string of digits.*/ +tail=right($,max(0,w-2)) /*construct a "fast" tail. */ + + do j=13 to left($,1) || tail /*step through the list. */ + if verify(j,$)\==0 then iterate /*Not one of the chosen? */ + f=left(j,1) /*the first digit of j. */ + NCS=0 /*not non-continuous subseq*/ + do k=2 to length(j); _=substr(j,k,1) /*pick off a single digit. */ + if _ <= f then iterate j /*if next digit ≤ then skip*/ + if _ \== f+1 then NCS=1 /*it's OK as of now. */ + f=_ /*we now got a new next dig*/ + end /*k*/ + + if \NCS then iterate /*¬OK? Then skip this num.*/ + #=#+1 /*Eureka! We found one. */ + x= /*the beginning of the NCS.*/ + do m=1 for length(j) /*build a thingy to display*/ + x=x word(list,substr(j,m,1)) /*pick off a number to show*/ + end /*m*/ + + say 'a non-continuous subsequence: ' x /*show a non-cont. subseq. */ + end /*j*/ + +if #==0 then #='no' /*make it more gooder Eng. */ +say; say # "non-continuous subsequence"s(#) 'were found.' +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────S subroutine───────────────────────*/ +s: if arg(1)==1 then return ''; return word(arg(2) 's',1) /*plurals.*/ diff --git a/Task/Non-continuous-subsequences/Ruby/non-continuous-subsequences.rb b/Task/Non-continuous-subsequences/Ruby/non-continuous-subsequences.rb new file mode 100644 index 0000000000..ce9adbd560 --- /dev/null +++ b/Task/Non-continuous-subsequences/Ruby/non-continuous-subsequences.rb @@ -0,0 +1,21 @@ +class Array + def func_power_set + inject([[]]) { |ps,item| # for each item in the Array + ps + # take the powerset up to now and add + ps.map { |e| e + [item] } # it again, with the item appended to each element + } + end + + def non_continuous_subsequences + func_power_set.find_all {|seq| not seq.continuous} + end + + def continuous + each_cons(2) {|a, b| return false if a+1 != b} + true + end +end + +p (1..3).to_a.non_continuous_subsequences +p (1..4).to_a.non_continuous_subsequences +p (1..5).to_a.non_continuous_subsequences diff --git a/Task/Non-continuous-subsequences/Scheme/non-continuous-subsequences.ss b/Task/Non-continuous-subsequences/Scheme/non-continuous-subsequences.ss new file mode 100644 index 0000000000..145bd19d31 --- /dev/null +++ b/Task/Non-continuous-subsequences/Scheme/non-continuous-subsequences.ss @@ -0,0 +1,18 @@ +(define (ncsubseq lst) + (let recurse ((s 0) + (lst lst)) + (if (null? lst) + (if (>= s 3) + '(()) + '()) + (let ((x (car lst)) + (xs (cdr lst))) + (if (even? s) + (append + (map (lambda (ys) (cons x ys)) + (recurse (+ s 1) xs)) + (recurse s xs)) + (append + (map (lambda (ys) (cons x ys)) + (recurse s xs)) + (recurse (+ s 1) xs))))))) diff --git a/Task/Non-continuous-subsequences/Standard-ML/non-continuous-subsequences.ml b/Task/Non-continuous-subsequences/Standard-ML/non-continuous-subsequences.ml new file mode 100644 index 0000000000..6b440eb644 --- /dev/null +++ b/Task/Non-continuous-subsequences/Standard-ML/non-continuous-subsequences.ml @@ -0,0 +1,21 @@ +fun fence s [] = + if s >= 3 then + [[]] + else + [] + + | fence s (x :: xs) = + if s mod 2 = 0 then + map + (fn ys => x :: ys) + (fence (s + 1) xs) + @ + fence s xs + else + map + (fn ys => x :: ys) + (fence s xs) + @ + fence (s + 1) xs + +fun ncsubseq xs = fence 0 xs diff --git a/Task/Non-continuous-subsequences/Tcl/non-continuous-subsequences.tcl b/Task/Non-continuous-subsequences/Tcl/non-continuous-subsequences.tcl new file mode 100644 index 0000000000..e29d91e39d --- /dev/null +++ b/Task/Non-continuous-subsequences/Tcl/non-continuous-subsequences.tcl @@ -0,0 +1,23 @@ + proc subsets l { + set res [list [list]] + foreach e $l { + foreach subset $res {lappend res [lappend subset $e]} + } + return $res + } + proc is_not_continuous seq { + set last [lindex $seq 0] + foreach e [lrange $seq 1 end] { + if {$e-1 != $last} {return 1} + set last $e + } + return 0 + } + proc lfilter {f list} { + set res {} + foreach i $list {if [$f $i] {lappend res $i}} + return $res + } + +% lfilter is_not_continuous [subsets {1 2 3 4}] +{1 3} {1 4} {2 4} {1 2 4} {1 3 4} diff --git a/Task/Non-continuous-subsequences/Ursala/non-continuous-subsequences.ursala b/Task/Non-continuous-subsequences/Ursala/non-continuous-subsequences.ursala new file mode 100644 index 0000000000..da91c00e1b --- /dev/null +++ b/Task/Non-continuous-subsequences/Ursala/non-continuous-subsequences.ursala @@ -0,0 +1,7 @@ +#import std + +noncontinuous = num; ^rlK3ZK17rSS/~& powerset + +#show+ + +examples = noncontinuous 'abcde' diff --git a/Task/Non-decimal-radices-Convert/0DESCRIPTION b/Task/Non-decimal-radices-Convert/0DESCRIPTION new file mode 100644 index 0000000000..cb36e813b8 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/0DESCRIPTION @@ -0,0 +1,7 @@ +Number base conversion is when you express a stored integer in an integer base, such as in octal (base 8) or binary (base 2). It also is involved when you take a string representing a number in a given base and convert it to the stored integer form. Normally, a stored integer is in binary, but that's typically invisible to the user, who normally enters or sees stored integers as decimal. + +Write a function (or identify the built-in function) which is passed a non-negative integer to convert, and another integer representing the base. It should return a string containing the digits of the resulting number, without leading zeros except for the number 0 itself. For the digits beyond 9, one should use the lowercase English alphabet, where the digit a = 9+1, b = a+1, etc. The decimal number 26 expressed in base 16 would be 1a, for example. + +Write a second function which is passed a string and an integer base, and it returns an integer representing that string interpreted in that base. + +The programs may be limited by the word size or other such constraint of a given language. There is no need to do error checking for negatives, bases less than 2, or inappropriate digits. diff --git a/Task/Non-decimal-radices-Convert/1META.yaml b/Task/Non-decimal-radices-Convert/1META.yaml new file mode 100644 index 0000000000..8644b2ad9b --- /dev/null +++ b/Task/Non-decimal-radices-Convert/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Arithmetic operations diff --git a/Task/Non-decimal-radices-Convert/ACL2/non-decimal-radices-convert.acl2 b/Task/Non-decimal-radices-Convert/ACL2/non-decimal-radices-convert.acl2 new file mode 100644 index 0000000000..432323e894 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/ACL2/non-decimal-radices-convert.acl2 @@ -0,0 +1,35 @@ +(defun digit-value (chr) + (cond ((and (char>= chr #\0) + (char<= chr #\9)) + (- (char-code chr) (char-code #\0))) + ((and (char>= chr #\A) + (char<= chr #\Z)) + (+ (- (char-code chr) (char-code #\A)) 10)) + ((and (char>= chr #\a) + (char<= chr #\z)) + (+ (- (char-code chr) (char-code #\a)) 10)))) + +(defun value-digit (n) + (if (< n 10) + (code-char (+ n (char-code #\0))) + (code-char (+ (- n 10) (char-code #\A))))) + +(defun num-from-cs (cs base) + (if (endp cs) + 0 + (+ (digit-value (first cs)) + (* base (num-from-cs (rest cs) base))))) + +(defun parse-num (str base) + (num-from-cs (reverse (coerce str 'list)) base)) + +(include-book "arithmetic-3/top" :dir :system) + +(defun num-to-cs (num base) + (if (or (zp num) (zp base) (= base 1)) + nil + (cons (value-digit (mod num base)) + (num-to-cs (floor num base) base)))) + +(defun show-num (num base) + (coerce (reverse (num-to-cs num base)) 'string)) diff --git a/Task/Non-decimal-radices-Convert/ALGOL-68/non-decimal-radices-convert-1.alg b/Task/Non-decimal-radices-Convert/ALGOL-68/non-decimal-radices-convert-1.alg new file mode 100644 index 0000000000..53aa9d9b44 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/ALGOL-68/non-decimal-radices-convert-1.alg @@ -0,0 +1,14 @@ +INT base = 16, from dec = 26; +BITS to bits; + +FORMAT hex repr = $n(base)r2d$; + +FILE f; STRING str; + +associate(f, str); +putf(f, (hex repr, BIN from dec)); +print(("Hex: ",str, new line)); + +reset(f); +getf(f, (hex repr, to bits)); +print(("Int: ",ABS to bits, new line)) diff --git a/Task/Non-decimal-radices-Convert/ALGOL-68/non-decimal-radices-convert-2.alg b/Task/Non-decimal-radices-Convert/ALGOL-68/non-decimal-radices-convert-2.alg new file mode 100644 index 0000000000..7d44dd5afb --- /dev/null +++ b/Task/Non-decimal-radices-Convert/ALGOL-68/non-decimal-radices-convert-2.alg @@ -0,0 +1,36 @@ +STRING numeric alpha = "0123456789abcdefghijklmnopqrstuvwxyz"; + +PROC raise value error = ([]STRING args)VOID: ( + put(stand error, "Value error"); + STRING sep := ": "; + FOR index TO UPB args - 1 DO put(stand error, (sep, args[index])); sep:=", " OD; + new line(stand error); + stop +); + +PROC base n = (INT num, base)STRING: ( + PROC base n = (INT num, base)STRING: + ( num = 0 | "" | base n(num OVER base, base) + numeric alpha[@0][num MOD base]); + ( num = 0 | "0" |: num > 0 | base n(num, base) | "-" + base n(-num, base) ) +); + +PROC unsigned int = (STRING repr, INT base)INT: + IF UPB repr < LWB repr THEN 0 ELSE + INT pos; + IF NOT char in string(repr[UPB repr], pos, numeric alpha) THEN + raise value error("CHAR """+repr[UPB repr]+""" not valid") + FI; + unsigned int(repr[:UPB repr-1], base) * base + pos - 1 + FI +; + +PROC int = (STRING repr, INT base)INT: + ( repr[LWB repr]="-" | -unsigned int(repr[LWB repr + 1:], base) | unsigned int(repr, base) ); + +[]INT test = (-256, -255, -26, -25, 0, 25, 26, 255, 256); +FOR index TO UPB test DO + INT k = test[index]; + STRING s = base n(k,16); # returns the string 1a # + INT i = int(s,16); # returns the integer 26 # + print((k," => ", s, " => ", i, new line)) +OD diff --git a/Task/Non-decimal-radices-Convert/AWK/non-decimal-radices-convert.awk b/Task/Non-decimal-radices-Convert/AWK/non-decimal-radices-convert.awk new file mode 100644 index 0000000000..ffadbc5d8d --- /dev/null +++ b/Task/Non-decimal-radices-Convert/AWK/non-decimal-radices-convert.awk @@ -0,0 +1,28 @@ +function strtol(str, base) +{ + symbols = "0123456789abcdefghijklmnopqrstuvwxyz" + res = 0 + str = tolower(str) + for(i=1; i < length(str); i++) { + res += index(symbols, substr(str, i, 1)) - 1 + res *= base + } + res += index(symbols, substr(str, length(str), 1)) - 1 + return res +} + +function ltostr(num, base) +{ + symbols = "0123456789abcdefghijklmnopqrstuvwxyz" + res = "" + do { + res = substr(symbols, num%base + 1, 1) res + num = int(num/base) + } while ( num != 0 ) + return res +} + +BEGIN { + print strtol("7b", 16) + print ltostr(123, 16) +} diff --git a/Task/Non-decimal-radices-Convert/Ada/non-decimal-radices-convert.ada b/Task/Non-decimal-radices-Convert/Ada/non-decimal-radices-convert.ada new file mode 100644 index 0000000000..1842ce83e1 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Ada/non-decimal-radices-convert.ada @@ -0,0 +1,54 @@ +with Ada.Text_Io; use Ada.Text_Io; +with Ada.Strings.Fixed; +With Ada.Strings.Unbounded; + +procedure Number_Base_Conversion is + Max_Base : constant := 36; + subtype Base_Type is Integer range 2..Max_Base; + Num_Digits : constant String := "0123456789abcdefghijklmnopqrstuvwxyz"; + Invalid_Digit : exception; + + function To_Decimal(Value : String; Base : Base_Type) return Integer is + use Ada.Strings.Fixed; + Result : Integer := 0; + Decimal_Value : Integer; + Radix_Offset : Natural := 0; + begin + for I in reverse Value'range loop + Decimal_Value := Index(Num_Digits, Value(I..I)) - 1; + if Decimal_Value < 0 then + raise Invalid_Digit; + end if; + Result := Result + (Base**Radix_Offset * Decimal_Value); + Radix_Offset := Radix_Offset + 1; + end loop; + return Result; + end To_Decimal; + + function To_Base(Value : Natural; Base : Base_Type) return String is + use Ada.Strings.Unbounded; + Result : Unbounded_String := Null_Unbounded_String; + Temp : Natural := Value; + Base_Digit : String(1..1); + begin + if Temp = 0 then + return "0"; + end if; + while Temp > 0 loop + Base_Digit(1) := Num_Digits((Temp mod Base) + 1); + if Result = Null_Unbounded_String then + Append(Result, Base_Digit); + else + Insert(Source => Result, + Before => 1, + New_Item => Base_Digit); + end if; + Temp := Temp / Base; + end loop; + return To_String(Result); + end To_Base; + +begin + Put_Line("26 converted to base 16 is " & To_Base(26, 16)); + Put_line("1a (base 16) is decimal" & Integer'image(To_Decimal("1a", 16))); +end Number_Base_Conversion; diff --git a/Task/Non-decimal-radices-Convert/AutoHotkey/non-decimal-radices-convert-1.ahk b/Task/Non-decimal-radices-Convert/AutoHotkey/non-decimal-radices-convert-1.ahk new file mode 100644 index 0000000000..7cd934c231 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/AutoHotkey/non-decimal-radices-convert-1.ahk @@ -0,0 +1,25 @@ +MsgBox % number2base(200, 16) ; 12 +MsgBox % parse(200, 16) ; 512 + +number2base(number, base) +{ + While, base < digit := floor(number / base) + { + result := mod(number, base) . result + number := digit + } + result := digit . result + Return result +} + +parse(number, base) +{ + result = 0 + pos := StrLen(number) - 1 + Loop, Parse, number + { + result := ((base ** pos) * A_LoopField) + result + base -= 1 + } + Return result +} diff --git a/Task/Non-decimal-radices-Convert/AutoHotkey/non-decimal-radices-convert-2.ahk b/Task/Non-decimal-radices-Convert/AutoHotkey/non-decimal-radices-convert-2.ahk new file mode 100644 index 0000000000..fed66ac0e0 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/AutoHotkey/non-decimal-radices-convert-2.ahk @@ -0,0 +1,13 @@ +MsgBox % ToBase(29,3) +MsgBox % ToBase(255,16) + +MsgBox % FromBase("100",8) +MsgBox % FromBase("ff",16) + +ToBase(n,b) { ; n >= 0, 1 < b <= 36 + Return (n < b ? "" : ToBase(n//b,b)) . ((d:=mod(n,b)) < 10 ? d : Chr(d+87)) +} + +FromBase(s,b) { ; convert base b number s=strings of 0..9,a..z, to AHK number + Return (L:=StrLen(s))=0 ? "":(L>1 ? FromBase(SubStr(s,1,L-1),b)*b:0) + ((c:=Asc(SubStr(s,0)))>57 ? c-87:c-48) +} diff --git a/Task/Non-decimal-radices-Convert/BBC-BASIC/non-decimal-radices-convert.bbc b/Task/Non-decimal-radices-Convert/BBC-BASIC/non-decimal-radices-convert.bbc new file mode 100644 index 0000000000..c26a60c392 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/BBC-BASIC/non-decimal-radices-convert.bbc @@ -0,0 +1,28 @@ + PRINT " 0 (decimal) -> " FNtobase(0, 16) " (base 16)" + PRINT " 26 (decimal) -> " FNtobase(26, 16) " (base 16)" + PRINT "383 (decimal) -> " FNtobase(383, 16) " (base 16)" + PRINT " 26 (decimal) -> " FNtobase(26, 2) " (base 2)" + PRINT "383 (decimal) -> " FNtobase(383, 2) " (base 2)" + PRINT " 1a (base 16) -> " ;FNfrombase("1a", 16) " (decimal)" + PRINT " 1A (base 16) -> " ;FNfrombase("1A", 16) " (decimal)" + PRINT "17f (base 16) -> " ;FNfrombase("17f", 16) " (decimal)" + PRINT "101111111 (base 2) -> " ;FNfrombase("101111111", 2) " (decimal)" + END + + DEF FNtobase(N%, B%) + LOCAL D%,A$ + REPEAT + D% = N% MOD B% + N% DIV= B% + A$ = CHR$(48 + D% - 39*(D%>9)) + A$ + UNTIL N% = FALSE + =A$ + + DEF FNfrombase(A$, B%) + LOCAL N% + REPEAT + N% *= B% + N% += ASC(A$) - 48 + 7*(ASCA$>64) + 32*(ASCA$>96) + A$ = MID$(A$,2) + UNTIL A$ = "" + = N% diff --git a/Task/Non-decimal-radices-Convert/Bracmat/non-decimal-radices-convert.bracmat b/Task/Non-decimal-radices-Convert/Bracmat/non-decimal-radices-convert.bracmat new file mode 100644 index 0000000000..aa99840ea1 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Bracmat/non-decimal-radices-convert.bracmat @@ -0,0 +1,23 @@ + ( display + = + . !arg:<10 + | !arg:<36&chr$(asc$a+!arg+-10) + | "Base too big" + ) +& ( base + = n b + . !arg:(?n.?b) + & !n:-1:?n + & put$"Enter base (less than 37):" + & get$:~/#>1:~>36:?b + & out$(!n " in base " !b " is " str$(base$(!n.!b))) + ); diff --git a/Task/Non-decimal-radices-Convert/C++/non-decimal-radices-convert.cpp b/Task/Non-decimal-radices-Convert/C++/non-decimal-radices-convert.cpp new file mode 100644 index 0000000000..1e2d24647d --- /dev/null +++ b/Task/Non-decimal-radices-Convert/C++/non-decimal-radices-convert.cpp @@ -0,0 +1,29 @@ +#include +#include +#include +#include + +std::string const digits = "0123456789abcdefghijklmnopqrstuvwxyz"; + +std::string to_base(unsigned long num, int base) +{ + if (num == 0) + return "0"; + + std::string result; + while (num > 0) { + std::ldiv_t temp = std::div(num, (long)base); + result += digits[temp.rem]; + num = temp.quot; + } + std::reverse(result.begin(), result.end()); + return result; +} + +unsigned long from_base(std::string const& num_str, int base) +{ + unsigned long result = 0; + for (std::string::size_type pos = 0; pos < num_str.length(); ++pos) + result = result * base + digits.find(num_str[pos]); + return result; +} diff --git a/Task/Non-decimal-radices-Convert/C/non-decimal-radices-convert.c b/Task/Non-decimal-radices-Convert/C/non-decimal-radices-convert.c new file mode 100644 index 0000000000..3f02a8bb0b --- /dev/null +++ b/Task/Non-decimal-radices-Convert/C/non-decimal-radices-convert.c @@ -0,0 +1,48 @@ +#include +#include +#include +#include + +char *to_base(int64_t num, int base) +{ + char *tbl = "0123456789abcdefghijklmnopqrstuvwxyz"; + char buf[66] = {'\0'}; + char *out; + uint64_t n; + int i, len = 0, neg = 0; + if (base > 36) { + fprintf(stderr, "base %d too large\n", base); + return 0; + } + + /* safe against most negative integer */ + n = ((neg = num < 0)) ? (~num) + 1 : num; + + do { buf[len++] = tbl[n % base]; } while(n /= base); + + out = malloc(len + neg + 1); + for (i = neg; len > 0; i++) out[i] = buf[--len]; + if (neg) out[0] = '-'; + + return out; +} + +long from_base(const char *num_str, int base) +{ + char *endptr; + /* there is also strtoul() for parsing into an unsigned long */ + /* in C99, there is also strtoll() and strtoull() for parsing into long long and + * unsigned long long, respectively */ + int result = strtol(num_str, &endptr, base); + return result; +} + +int main() +{ + int64_t x; + x = ~(1LL << 63) + 1; + printf("%lld in base 2: %s\n", x, to_base(x, 2)); + x = 383; + printf("%lld in base 16: %s\n", x, to_base(x, 16)); + return 0; +} diff --git a/Task/Non-decimal-radices-Convert/Cache-ObjectScript/non-decimal-radices-convert.cos b/Task/Non-decimal-radices-Convert/Cache-ObjectScript/non-decimal-radices-convert.cos new file mode 100644 index 0000000000..0a290fe7c0 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Cache-ObjectScript/non-decimal-radices-convert.cos @@ -0,0 +1,67 @@ +Class Utils.Number [ Abstract ] +{ + +ClassMethod ConvertBase10ToN(pNum As %Integer = "", pBase As %Integer = "", pBaseStr As %String = "", pPos As %Integer = 0) As %String +{ + If pNum=0 Quit "" + Set str=..ConvertBase10ToN(pNum\pBase, pBase, pBaseStr, pPos+1) + Quit str_$Extract(pBaseStr, pNum#pBase+1) +} + +ClassMethod ConvertBaseNTo10(pStr As %String = "", pBase As %Integer = "", pBaseStr As %String = "", pPos As %Integer = 0) As %Integer +{ + If pStr="" Quit 0 + Set num=..ConvertBaseNTo10($Extract(pStr, 1, *-1), pBase, pBaseStr, pPos+1) + Set dec=$Find(pBaseStr, $Extract(pStr, *))-2 + Quit num+(dec*(pBase**pPos)) +} + +ClassMethod ConvertBase(pStr As %String = "", pFrom As %Integer = 10, pTo As %Integer = 10, pBaseStr As %String = "", pLen As %Integer = 0) As %String +{ + // some initialisation + If pBaseStr="" Set pBaseStr="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" + + // check input values + If pFrom=10 Set pStr=$Number(pStr, "i", 0) If pStr="" Quit "" + Set pFrom=$Number(pFrom, "i", 2, 94) If pFrom="" Quit "" + Set pTo=$Number(pTo, "i", 2, 94) If pTo="" Quit "" + Set pLen=$Number(pLen, "i", 0, 32) If pLen="" Quit "" + + // does base number exceed base string? + If pFrom>$Length(pBaseStr) Quit "" + If pTo>$Length(pBaseStr) Quit "" + + // allow for upper/lowercase values + If pTo=10 { + If $Match(pStr, "^[0-9a-z]+$"), $Match($Extract(pBaseStr, 1, pFrom), "^[0-9A-Z]+$") { + Set pStr=$ZConvert(pStr, "U") + } + If $Match(pStr, "^[0-9A-Z]+$"), $Match($Extract(pBaseStr, 1, pFrom), "^[0-9a-z]+$") { + Set pStr=$ZConvert(pStr, "L") + } + } + + // do the conversion + If pFrom=pTo { + Set pStr=pStr + } ElseIf pFrom=10 { + Set pStr=..ConvertBase10ToN($Select(pStr=0: "", 1: pStr), pTo, pBaseStr) + } ElseIf pTo=10 { + Set pStr=..ConvertBaseNTo10(pStr, pFrom, pBaseStr) + } Else { + Set pStr=..ConvertBase10ToN(..ConvertBaseNTo10(pStr, pFrom, pBaseStr), pTo, pBaseStr) + } + + // return value + If pLen=0 Quit pStr + If pTo'=10 Quit ..PadStr(pStr, pLen, $Extract(pBaseStr)) + Quit ..PadStr(pStr, pLen) +} + +ClassMethod PadStr(pStr As %String, pLen As %Integer, pZero As %String = 0) As %String [ Private ] +{ + If $Length(pStr)>pLen Quit pStr + Quit $Translate($Justify(pStr, pLen), " ", pZero) +} + +} diff --git a/Task/Non-decimal-radices-Convert/Common-Lisp/non-decimal-radices-convert.lisp b/Task/Non-decimal-radices-Convert/Common-Lisp/non-decimal-radices-convert.lisp new file mode 100644 index 0000000000..5e9400650a --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Common-Lisp/non-decimal-radices-convert.lisp @@ -0,0 +1,2 @@ +(parse-integer "1a" :radix 16) ; returns multiple values: 26, 2 +(write-to-string 26 :base 16) ; also "1A" diff --git a/Task/Non-decimal-radices-Convert/D/non-decimal-radices-convert-1.d b/Task/Non-decimal-radices-Convert/D/non-decimal-radices-convert-1.d new file mode 100644 index 0000000000..b38037a7a4 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/D/non-decimal-radices-convert-1.d @@ -0,0 +1,8 @@ +import std.stdio, std.conv, std.string; + +void main() { + "1abcd".to!int(16).writeln(); + + toLower(60_272_032_366.to!string(36) ~ " " ~ + 591_458.to!string(36)).writeln(); +} diff --git a/Task/Non-decimal-radices-Convert/D/non-decimal-radices-convert-2.d b/Task/Non-decimal-radices-Convert/D/non-decimal-radices-convert-2.d new file mode 100644 index 0000000000..2d99daf2f3 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/D/non-decimal-radices-convert-2.d @@ -0,0 +1,62 @@ +import std.stdio, std.array, std.ascii; + +enum string mDigits = "0123456789abcdefghijklmnopqrstuvwxyz"; + +ulong atoiRadix(in string str, in int radix=10, int* consumed=null) { + static int dtoi(in char dc, in int radix) { + static int[immutable char] digit; + immutable char d = cast(char)toLower(dc); + if (digit.length == 0) // not init yet + foreach (i, c; mDigits) + digit[c] = i; + if (radix > 1 && radix <= digit.length && + d in digit && digit[d] < radix) + return digit[d]; + return int.min; // a negative for error. + } + + ulong result; + int sp; + for (; sp < str.length; sp++) { + immutable int d = dtoi(str[sp], radix); + if (d >= 0) // valid digit char + result = radix * result + d; + else + break; + } + if (sp != str.length) // some char in str not converted. + sp = -sp; + if (consumed !is null) // signal error if not positive. + *consumed = sp; + return result; +} + +string itoaRadix(ulong num, in int radix=10) pure nothrow +in { + assert(radix > 1 && radix <= mDigits.length); +} body { + string result; + while (num > 0) { + //immutable int d = num % radix; + immutable int d = cast(int)(num % radix); + result = mDigits[d] ~ result; + num = (num - d) / radix; + } + return result.empty ? "0" : result; +} + +void main() { + immutable string numStr = "1ABcdxyz???"; + + int ate; + writef("'%s' (base %d) = %d", numStr, 16, + atoiRadix(numStr, 16, &ate)); + + if (ate <= 0) + writefln("\tConverted only: '%s'", numStr[0 .. -ate]); + else + writeln(); + + writeln(itoaRadix(60_272_032_366, 36), " ", + itoaRadix(591_458, 36)); +} diff --git a/Task/Non-decimal-radices-Convert/E/non-decimal-radices-convert-1.e b/Task/Non-decimal-radices-Convert/E/non-decimal-radices-convert-1.e new file mode 100644 index 0000000000..38408042fe --- /dev/null +++ b/Task/Non-decimal-radices-Convert/E/non-decimal-radices-convert-1.e @@ -0,0 +1,4 @@ +def stringToInteger := __makeInt +def integerToString(i :int, base :int) { + return i.toString(base) +} diff --git a/Task/Non-decimal-radices-Convert/E/non-decimal-radices-convert-2.e b/Task/Non-decimal-radices-Convert/E/non-decimal-radices-convert-2.e new file mode 100644 index 0000000000..fea14d1d12 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/E/non-decimal-radices-convert-2.e @@ -0,0 +1,5 @@ +? stringToInteger("200", 16) +# value: 512 + +? integerToString(200, 16) +# value: "c8" diff --git a/Task/Non-decimal-radices-Convert/Euphoria/non-decimal-radices-convert.euphoria b/Task/Non-decimal-radices-Convert/Euphoria/non-decimal-radices-convert.euphoria new file mode 100644 index 0000000000..d9bbf17abf --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Euphoria/non-decimal-radices-convert.euphoria @@ -0,0 +1,35 @@ +function to_base(integer i, integer base) + integer rem + sequence s + s = "" + while i > 0 do + rem = remainder(i,base) + if rem < 10 then + s = prepend(s, '0'+rem) + else + s = prepend(s, 'a'-10+rem) + end if + i = floor(i/base) + end while + + if length(s) = 0 then + s = "0" + end if + + return s +end function + +function from_base(sequence s, integer base) + integer i,d + i = 0 + for n = 1 to length(s) do + i *= base + if s[n] >= '0' and s[n] <= '9' then + d = s[n]-'0' + elsif s[n] >= 'a' then + d = s[n]-'a'+10 + end if + i += d + end for + return i +end function diff --git a/Task/Non-decimal-radices-Convert/Factor/non-decimal-radices-convert.factor b/Task/Non-decimal-radices-Convert/Factor/non-decimal-radices-convert.factor new file mode 100644 index 0000000000..090df92327 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Factor/non-decimal-radices-convert.factor @@ -0,0 +1,4 @@ +USE: math.parser + +12345 16 >base . +"3039" 16 base> . diff --git a/Task/Non-decimal-radices-Convert/Forth/non-decimal-radices-convert-1.fth b/Task/Non-decimal-radices-Convert/Forth/non-decimal-radices-convert-1.fth new file mode 100644 index 0000000000..b547b90d61 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Forth/non-decimal-radices-convert-1.fth @@ -0,0 +1,6 @@ +42 dup +2 base ! +. \ 101010 +hex +. \ 2A +decimal diff --git a/Task/Non-decimal-radices-Convert/Forth/non-decimal-radices-convert-2.fth b/Task/Non-decimal-radices-Convert/Forth/non-decimal-radices-convert-2.fth new file mode 100644 index 0000000000..146ef394c0 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Forth/non-decimal-radices-convert-2.fth @@ -0,0 +1 @@ +$ff . \ 255 diff --git a/Task/Non-decimal-radices-Convert/Fortran/non-decimal-radices-convert.f b/Task/Non-decimal-radices-Convert/Fortran/non-decimal-radices-convert.f new file mode 100644 index 0000000000..616030f1fa --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Fortran/non-decimal-radices-convert.f @@ -0,0 +1,46 @@ +MODULE Conversion + IMPLICIT NONE + CHARACTER(36) :: alphanum = "0123456789abcdefghijklmnopqrstuvwxyz" + + CONTAINS + + FUNCTION ToDecimal(base, instr) + INTEGER :: ToDecimal + INTEGER :: length, i, n, base + CHARACTER(*) :: instr + + ToDecimal = 0 + length = LEN(instr) + DO i = 1, length + n = INDEX(alphanum, instr(i:i)) - 1 + n = n * base**(length-i) + Todecimal = ToDecimal + n + END DO + END FUNCTION ToDecimal + + FUNCTION ToBase(base, number) + CHARACTER(31) :: ToBase + INTEGER :: base, number, i, rem + + ToBase = " " + DO i = 31, 1, -1 + IF(number < base) THEN + ToBase(i:i) = alphanum(number+1:number+1) + EXIT + END IF + rem = MOD(number, base) + ToBase(i:i) = alphanum(rem+1:rem+1) + number = number / base + END DO + ToBase = ADJUSTL(ToBase) + END FUNCTION ToBase + +END MODULE Conversion + +PROGRAM Base_Convert + USE Conversion + + WRITE (*,*) ToDecimal(16, "1a") + WRITE (*,*) ToBase(16, 26) + +END PROGRAM diff --git a/Task/Non-decimal-radices-Convert/Go/non-decimal-radices-convert.go b/Task/Non-decimal-radices-Convert/Go/non-decimal-radices-convert.go new file mode 100644 index 0000000000..afa43dee14 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Go/non-decimal-radices-convert.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" + "math/big" + "strconv" +) + +func main () { + s := strconv.FormatInt(26, 16) // returns the string "1a" + fmt.Println(s) + + i, err := strconv.ParseInt("1a", 16, 64) // returns the integer (int64) 26 + if err == nil { + fmt.Println(i) + } + b, ok := new(big.Int).SetString("1a", 16) // returns the big integer 26 + if ok { + fmt.Println(b) + } +} diff --git a/Task/Non-decimal-radices-Convert/Groovy/non-decimal-radices-convert-1.groovy b/Task/Non-decimal-radices-Convert/Groovy/non-decimal-radices-convert-1.groovy new file mode 100644 index 0000000000..e108fd9140 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Groovy/non-decimal-radices-convert-1.groovy @@ -0,0 +1,2 @@ +def radixParse = { s, radix -> Integer.parseInt(s, radix) } +def radixFormat = { i, radix -> Integer.toString(i, radix) } diff --git a/Task/Non-decimal-radices-Convert/Groovy/non-decimal-radices-convert-2.groovy b/Task/Non-decimal-radices-Convert/Groovy/non-decimal-radices-convert-2.groovy new file mode 100644 index 0000000000..4bd2894b32 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Groovy/non-decimal-radices-convert-2.groovy @@ -0,0 +1,11 @@ +def numString = '101' +(2..Character.MAX_RADIX).each { radix -> + def value = radixParse(numString, radix) + assert value == radix**2 + 1 + printf (" %3s (%2d) == %4d (10)\n", numString, radix, value) + + def valM2str = radixFormat(value - 2, radix) + def biggestDigit = radixFormat(radix - 1, radix) + assert valM2str == biggestDigit + biggestDigit + printf ("%3s (%2d) - 2 (10) == %4s (%2d)\n", numString, radix, valM2str, radix) +} diff --git a/Task/Non-decimal-radices-Convert/Haskell/non-decimal-radices-convert-1.hs b/Task/Non-decimal-radices-Convert/Haskell/non-decimal-radices-convert-1.hs new file mode 100644 index 0000000000..38313f9202 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Haskell/non-decimal-radices-convert-1.hs @@ -0,0 +1,4 @@ +Prelude> Numeric.showIntAtBase 16 Char.intToDigit 42 "" +"2a" +Prelude> fst $ head $ Numeric.readInt 16 Char.isHexDigit Char.digitToInt "2a" +42 diff --git a/Task/Non-decimal-radices-Convert/Haskell/non-decimal-radices-convert-2.hs b/Task/Non-decimal-radices-Convert/Haskell/non-decimal-radices-convert-2.hs new file mode 100644 index 0000000000..82eef27eb9 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Haskell/non-decimal-radices-convert-2.hs @@ -0,0 +1,21 @@ +import Data.List +import Data.Char + +toBase :: Int -> Int -> [Int] +toBase b v = toBase' [] v where + toBase' a 0 = a + toBase' a v = toBase' (r:a) q where (q,r) = v `divMod` b + +fromBase :: Int -> [Int] -> Int +fromBase b ds = foldl' (\n k -> n * b + k) 0 ds + +toAlphaDigits :: [Int] -> String +toAlphaDigits = map convert where + convert n | n < 10 = chr (n + ord '0') + | otherwise = chr (n + ord 'a' - 10) + +fromAlphaDigits :: String -> [Int] +fromAlphaDigits = map convert where + convert c | isDigit c = ord c - ord '0' + | isUpper c = ord c - ord 'A' + 10 + | isLower c = ord c - ord 'a' + 10 diff --git a/Task/Non-decimal-radices-Convert/Haskell/non-decimal-radices-convert-3.hs b/Task/Non-decimal-radices-Convert/Haskell/non-decimal-radices-convert-3.hs new file mode 100644 index 0000000000..693f3422f1 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Haskell/non-decimal-radices-convert-3.hs @@ -0,0 +1,4 @@ +*Main> toAlphaDigits $ toBase 16 $ 42 +"2a" +*Main> fromBase 16 $ fromAlphaDigits $ "2a" +42 diff --git a/Task/Non-decimal-radices-Convert/HicEst/non-decimal-radices-convert-1.hicest b/Task/Non-decimal-radices-Convert/HicEst/non-decimal-radices-convert-1.hicest new file mode 100644 index 0000000000..1e38a58407 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/HicEst/non-decimal-radices-convert-1.hicest @@ -0,0 +1,28 @@ +CHARACTER txt*80 + + num = 36^7 -1 ! 7836416410 + CALL DecToBase(num, txt, 36) + WRITE(ClipBoard, Name) num, txt, BaseToDec(36, txt) + END + +FUNCTION BaseToDec(base, string) + CHARACTER string + BaseToDec = 0 + length = LEN_TRIM(string) + DO i = 1, length + n = INDEX("0123456789abcdefghijklmnopqrstuvwxyz", string(i)) - 1 + BaseToDec = BaseToDec + n * base^(length-i) + ENDDO + END + +SUBROUTINE DectoBase(decimal, string, base) + CHARACTER string + string = '0' + temp = decimal + length = CEILING( LOG(decimal+1, base) ) + DO i = length, 1, -1 + n = MOD( temp, base ) + string(i) = "0123456789abcdefghijklmnopqrstuvwxyz"(n+1) + temp = INT(temp / base) + ENDDO + END diff --git a/Task/Non-decimal-radices-Convert/HicEst/non-decimal-radices-convert-2.hicest b/Task/Non-decimal-radices-Convert/HicEst/non-decimal-radices-convert-2.hicest new file mode 100644 index 0000000000..3603f69012 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/HicEst/non-decimal-radices-convert-2.hicest @@ -0,0 +1 @@ +num=7836416410; txt=zzzzzzz; 7836416410; diff --git a/Task/Non-decimal-radices-Convert/Icon/non-decimal-radices-convert.icon b/Task/Non-decimal-radices-Convert/Icon/non-decimal-radices-convert.icon new file mode 100644 index 0000000000..c249f23320 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Icon/non-decimal-radices-convert.icon @@ -0,0 +1,26 @@ +procedure main() + every ( ns := "16r5a" | "-12r1a" ) & + ( b := 8 | 12 | 16 ) do { + ns2 := convert(n := numeric(ns),b) + printf("ns=%s -> n=%d -> %s\n",ns,n,ns2) + } +end + +link printf + +procedure convert(i,b) #: convert i to base b radix representation +static digits +initial digits := &digits || &lcase + + i := integer(i) | runerr(101, i) # arg/error checking + /b := 10 | ( 2 < (b := integer(b)) <= *digits ) | runerr(205,b) + + if b = 10 then return i + else { + p := (s := "", (i := -(0 > i),"-")|"") || b || "r" # prefix/setup + until i = 0 & *s > 0 do + s ||:= digits[1 + 1( i % b, i /:= b)] + + return p || reverse(s) + } +end diff --git a/Task/Non-decimal-radices-Convert/J/non-decimal-radices-convert-1.j b/Task/Non-decimal-radices-Convert/J/non-decimal-radices-convert-1.j new file mode 100644 index 0000000000..2ee6e4e285 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/J/non-decimal-radices-convert-1.j @@ -0,0 +1,2 @@ + 2b100 8b100 10b_100 16b100 36b100 36bzy +4 64 _100 256 1296 1294 diff --git a/Task/Non-decimal-radices-Convert/J/non-decimal-radices-convert-2.j b/Task/Non-decimal-radices-Convert/J/non-decimal-radices-convert-2.j new file mode 100644 index 0000000000..4b4977eeb0 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/J/non-decimal-radices-convert-2.j @@ -0,0 +1,3 @@ +numerals=: '0123456789abcdefghijklmnopqrstuvwxyz' +baseNtoL=: numerals {~ #.inv +baseLtoN=: [ #. numerals i. ] diff --git a/Task/Non-decimal-radices-Convert/J/non-decimal-radices-convert-3.j b/Task/Non-decimal-radices-Convert/J/non-decimal-radices-convert-3.j new file mode 100644 index 0000000000..59eca0a25a --- /dev/null +++ b/Task/Non-decimal-radices-Convert/J/non-decimal-radices-convert-3.j @@ -0,0 +1,7 @@ + 2 baseNtoL 100 101 +1100100 +1100101 + 16 baseNtoL 26 +1a + 36 baseLtoN 'zy' +1294 diff --git a/Task/Non-decimal-radices-Convert/J/non-decimal-radices-convert-4.j b/Task/Non-decimal-radices-Convert/J/non-decimal-radices-convert-4.j new file mode 100644 index 0000000000..68c03f673a --- /dev/null +++ b/Task/Non-decimal-radices-Convert/J/non-decimal-radices-convert-4.j @@ -0,0 +1,6 @@ + base=: baseNtoL :: baseLtoN + + 16 base 'aa' +170 + 16 base 170 +aa diff --git a/Task/Non-decimal-radices-Convert/Java/non-decimal-radices-convert-1.java b/Task/Non-decimal-radices-Convert/Java/non-decimal-radices-convert-1.java new file mode 100644 index 0000000000..9c0b978433 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Java/non-decimal-radices-convert-1.java @@ -0,0 +1,7 @@ +public static long backToTen(String num, int oldBase){ + return Long.parseLong(num, oldBase); //takes both uppercase and lowercase letters +} + +public static String tenToBase(long num, int newBase){ + return Long.toString(num, newBase);//add .toUpperCase() for capital letters +} diff --git a/Task/Non-decimal-radices-Convert/Java/non-decimal-radices-convert-2.java b/Task/Non-decimal-radices-Convert/Java/non-decimal-radices-convert-2.java new file mode 100644 index 0000000000..6059898b9a --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Java/non-decimal-radices-convert-2.java @@ -0,0 +1,7 @@ +public static BigInteger backToTenBig(String num, int oldBase){ + return new BigInteger(num, oldBase); //takes both uppercase and lowercase letters +} + +public static String tenBigToBase(BigInteger num, int newBase){ + return num.toString(newBase);//add .toUpperCase() for capital letters +} diff --git a/Task/Non-decimal-radices-Convert/JavaScript/non-decimal-radices-convert.js b/Task/Non-decimal-radices-Convert/JavaScript/non-decimal-radices-convert.js new file mode 100644 index 0000000000..f65c546d34 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/JavaScript/non-decimal-radices-convert.js @@ -0,0 +1,5 @@ +k = 26 +s = k.toString(16) //gives 1a +i = parseInt('1a',16) //gives 26 +//optional special case for hex: +i = +('0x'+s) //hexadecimal base 16, if s='1a' then i=26. diff --git a/Task/Non-decimal-radices-Convert/Liberty-BASIC/non-decimal-radices-convert.liberty b/Task/Non-decimal-radices-Convert/Liberty-BASIC/non-decimal-radices-convert.liberty new file mode 100644 index 0000000000..f2f379a3ef --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Liberty-BASIC/non-decimal-radices-convert.liberty @@ -0,0 +1,32 @@ + ' Base Converter v6 + + global alphanum$ + alphanum$ ="0123456789abcdefghijklmnopqrstuvwxyz" + + for i =1 to 20 + RandNum = int( 100 *rnd( 1)) + base =2 +int( 35 *rnd( 1)) + + print "Decimal "; using( "###", RandNum); " to base "; using( "###", base);_ + " is "; toBase$( base, RandNum),_ + " back to dec. "; toDecimal( base, toBase$( base, RandNum)) + next i + + end ' ___________________________________________________________ + + function toBase$( base, number) ' Convert decimal variable to number string. + toBase$ ="" + for i =10 to 1 step -1 + remainder =number mod base + toBase$ =mid$( alphanum$, remainder +1, 1) +toBase$ + number =int( number /base) + if number <1 then exit for + next i + end function + + function toDecimal( base, s$) ' Convert number string to decimal variable. + toDecimal =0 + for i =1 to len( s$) + toDecimal =toDecimal *base +instr( alphanum$, mid$( s$, i, 1), 1) -1 + next i + end function diff --git a/Task/Non-decimal-radices-Convert/M4/non-decimal-radices-convert.m4 b/Task/Non-decimal-radices-Convert/M4/non-decimal-radices-convert.m4 new file mode 100644 index 0000000000..e351837905 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/M4/non-decimal-radices-convert.m4 @@ -0,0 +1,3 @@ +eval(26,16) +define(`frombase',`eval(0r$2:$1)') +frombase(1a,16) diff --git a/Task/Non-decimal-radices-Convert/Mathematica/non-decimal-radices-convert.math b/Task/Non-decimal-radices-Convert/Mathematica/non-decimal-radices-convert.math new file mode 100644 index 0000000000..f9a4e89fe0 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Mathematica/non-decimal-radices-convert.math @@ -0,0 +1,2 @@ +IntegerString[26,16] +FromDigits["1a", 16]) diff --git a/Task/Non-decimal-radices-Convert/NetRexx/non-decimal-radices-convert.netrexx b/Task/Non-decimal-radices-Convert/NetRexx/non-decimal-radices-convert.netrexx new file mode 100644 index 0000000000..94fa1fdae8 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/NetRexx/non-decimal-radices-convert.netrexx @@ -0,0 +1,39 @@ +/* NetRexx */ +options replace format comments java crossref symbols nobinary + +import java.math.BigInteger + +numeric digits 200 + +parse arg input -- input should be val, radix; no input results in using default test data +-- test data - number pairs where 1st is value and 2nd is target radix +inputs = [ - + '1234, 10', '01234, 8', 'fe, 16', 'f0e, 16', - + '0, 10', '00, 2', '11, 2', '070, 8', - + '77, 8', 'f0e, 16', '070, 16', '0xf0e, 36', - + '000999ABCXYZ, 36', 'ff, 36', 'f, 16', 'z, 37' - + ] +if input.length() > 0 then inputs = [input] -- replace test data with user input + +loop i_ = 0 to inputs.length - 1 + do + in = inputs[i_] + parse in val . ',' radix . + valB = toDecimal(val, radix) -- NetRexx default is to store digits as Rexx strings + valD = fromDecimal(valB + 0, radix) -- Add zero just to prove the result treated as a number + say val.right(16)'['radix.right(2, 0)']:' valB.right(16)'[10] ==' valD.right(16)'['radix.right(2, 0)']' + catch nx = NumberFormatException + say 'Error -- Input:' val', radix:' radix + nx.printStackTrace() + end + end i_ + +return + +method toDecimal(val = String, radix = int 10) public static returns Rexx + bi = BigInteger(val, radix) + return bi.toString() + +method fromDecimal(val = String, radix = int 10) public static returns Rexx + bi = BigInteger(val.toString(), 10) + return bi.toString(radix) diff --git a/Task/Non-decimal-radices-Convert/OCaml/non-decimal-radices-convert-1.ocaml b/Task/Non-decimal-radices-Convert/OCaml/non-decimal-radices-convert-1.ocaml new file mode 100644 index 0000000000..0e8bc12f17 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/OCaml/non-decimal-radices-convert-1.ocaml @@ -0,0 +1,12 @@ +let int_of_basen n str = + match n with + | 16 -> int_of_string("0x" ^ str) + | 2 -> int_of_string("0b" ^ str) + | 8 -> int_of_string("0o" ^ str) + | _ -> failwith "unhandled" + +let basen_of_int n d = + match n with + | 16 -> Printf.sprintf "%x" d + | 8 -> Printf.sprintf "%o" d + | _ -> failwith "unhandled" diff --git a/Task/Non-decimal-radices-Convert/OCaml/non-decimal-radices-convert-2.ocaml b/Task/Non-decimal-radices-Convert/OCaml/non-decimal-radices-convert-2.ocaml new file mode 100644 index 0000000000..c39e25a9f4 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/OCaml/non-decimal-radices-convert-2.ocaml @@ -0,0 +1,32 @@ +let to_base b v = + let rec to_base' a v = + if v = 0 then + a + else + to_base' (v mod b :: a) (v / b) + in + to_base' [] v + +let from_base b ds = + List.fold_left (fun n k -> n * b + k) 0 ds + +let to_alpha_digit n = + if n < 10 then + char_of_int (n + int_of_char '0') + else + char_of_int (n + int_of_char 'a' - 10) + +let to_alpha_digits ds = + let buf = Buffer.create (List.length ds) in + List.iter (fun i -> Buffer.add_char buf (to_alpha_digit i)) ds; + Buffer.contents buf + +let from_alpha_digit c = match c with + '0'..'9' -> int_of_char c - int_of_char '0' + | 'A'..'Z' -> int_of_char c - int_of_char 'A' + 10 + | 'a'..'z' -> int_of_char c - int_of_char 'a' + 10 + +let from_alpha_digits s = + let result = ref [] in + String.iter (fun c -> result := from_alpha_digit c :: !result) s; + List.rev !result diff --git a/Task/Non-decimal-radices-Convert/PARI-GP/non-decimal-radices-convert.pari b/Task/Non-decimal-radices-Convert/PARI-GP/non-decimal-radices-convert.pari new file mode 100644 index 0000000000..eb2ae42f4d --- /dev/null +++ b/Task/Non-decimal-radices-Convert/PARI-GP/non-decimal-radices-convert.pari @@ -0,0 +1,17 @@ +toBase(n,b)={ + my(s="",t); + while(n, + t=n%b; + n\=b; + s=Str(if(t<=9,t,Strchr(Vecsmall([87+t]))),s) + ); + if(#s,s,"0") +}; +fromBase(s,b)={ + my(t=0); + s=Vecsmall(s); + forstep(i=#s,1,-1, + t=b*t+s[i]-if(s[i]<58,48,87) + ); + t +}; diff --git a/Task/Non-decimal-radices-Convert/PHP/non-decimal-radices-convert-1.php b/Task/Non-decimal-radices-Convert/PHP/non-decimal-radices-convert-1.php new file mode 100644 index 0000000000..ab21216d3c --- /dev/null +++ b/Task/Non-decimal-radices-Convert/PHP/non-decimal-radices-convert-1.php @@ -0,0 +1 @@ +base_convert("26", 10, 16); // returns "1a" diff --git a/Task/Non-decimal-radices-Convert/PHP/non-decimal-radices-convert-2.php b/Task/Non-decimal-radices-Convert/PHP/non-decimal-radices-convert-2.php new file mode 100644 index 0000000000..6de460aff0 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/PHP/non-decimal-radices-convert-2.php @@ -0,0 +1 @@ +intval("1a", 16); // returns 26 diff --git a/Task/Non-decimal-radices-Convert/PHP/non-decimal-radices-convert-3.php b/Task/Non-decimal-radices-Convert/PHP/non-decimal-radices-convert-3.php new file mode 100644 index 0000000000..5a0f905ee4 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/PHP/non-decimal-radices-convert-3.php @@ -0,0 +1 @@ +base_convert(26, 10, 16); // returns "1a" diff --git a/Task/Non-decimal-radices-Convert/PHP/non-decimal-radices-convert-4.php b/Task/Non-decimal-radices-Convert/PHP/non-decimal-radices-convert-4.php new file mode 100644 index 0000000000..626ac0a118 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/PHP/non-decimal-radices-convert-4.php @@ -0,0 +1,12 @@ +// converts int to binary string +decbin(26); // returns "11010" +// converts int to octal string +decoct(26); // returns "32" +// converts int to hex string +dechex(26); // returns "1a" +// converts binary string to int +bindec("11010"); // returns 26 +// converts octal string to int +octdec("32"); // returns 26 +// converts hex string to int +hexdec("1a"); // returns 26 diff --git a/Task/Non-decimal-radices-Convert/PL-I/non-decimal-radices-convert.pli b/Task/Non-decimal-radices-Convert/PL-I/non-decimal-radices-convert.pli new file mode 100644 index 0000000000..fceb166732 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/PL-I/non-decimal-radices-convert.pli @@ -0,0 +1,12 @@ +convert: procedure (N, base) returns (character (64) varying) recursive; + declare N fixed binary (31), base fixed binary; + declare table (0:15) character ( + '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'); + declare s character (64) varying; + + if N = 0 then return (''); + + s = convert(N/base, base); + return (s || table(mod(N, base)) ); +end convert; diff --git a/Task/Non-decimal-radices-Convert/Pascal/non-decimal-radices-convert.pascal b/Task/Non-decimal-radices-Convert/Pascal/non-decimal-radices-convert.pascal new file mode 100644 index 0000000000..e337e82ec7 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Pascal/non-decimal-radices-convert.pascal @@ -0,0 +1,45 @@ +Program ConvertDemo(output); + +uses + Math, SysUtils; + +const + alphanum = '0123456789abcdefghijklmnopqrstuvwxyz'; + +function ToDecimal(base: integer; instring: string): integer; + var + inlength, i, n: integer; + begin + ToDecimal := 0; + inlength := length(instring); + for i := 1 to inlength do + begin + n := pos(instring[i], alphanum) - 1; + n := n * base**(inlength-i); + Todecimal := ToDecimal + n; + end; + end; + +function ToBase(base, number: integer): string; + var + i, rem: integer; + begin + ToBase :=' '; + for i := 31 downto 1 do + begin + if (number < base) then + begin + ToBase[i] := alphanum[number+1]; + break; + end; + rem := number mod base; + ToBase[i] := alphanum[rem+1]; + number := number div base; + end; + ToBase := trimLeft(ToBase); + end; + +begin + writeln ('1A: ', ToDecimal(16, '1a')); + writeln ('26: ', ToBase(16, 26)); +end. diff --git a/Task/Non-decimal-radices-Convert/Perl-6/non-decimal-radices-convert.pl6 b/Task/Non-decimal-radices-Convert/Perl-6/non-decimal-radices-convert.pl6 new file mode 100644 index 0000000000..84dc6ae6f1 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Perl-6/non-decimal-radices-convert.pl6 @@ -0,0 +1,7 @@ +sub from-base(Str $str, Int $base) { + +":$base\<$str>"; +} + +sub to-base(Real $num, Int $base) { + $num.base($base); +} diff --git a/Task/Non-decimal-radices-Convert/Perl/non-decimal-radices-convert-1.pl b/Task/Non-decimal-radices-Convert/Perl/non-decimal-radices-convert-1.pl new file mode 100644 index 0000000000..15198adbac --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Perl/non-decimal-radices-convert-1.pl @@ -0,0 +1,5 @@ +use POSIX; + +my ($num, $n_unparsed) = strtol('1a', 16); +$n_unparsed == 0 or die "invalid characters found"; +print "$num\n"; # prints "26" diff --git a/Task/Non-decimal-radices-Convert/Perl/non-decimal-radices-convert-2.pl b/Task/Non-decimal-radices-Convert/Perl/non-decimal-radices-convert-2.pl new file mode 100644 index 0000000000..6897c94388 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Perl/non-decimal-radices-convert-2.pl @@ -0,0 +1,14 @@ +sub digitize +# Converts an integer to a single digit. + {my $i = shift; + $i < 10 + ? $i + : ('a' .. 'z')[$i - 10];} + +sub to_base + {my ($int, $radix) = @_; + my $numeral = ''; + do { + $numeral .= digitize($int % $radix); + } while $int = int($int / $radix); + scalar reverse $numeral;} diff --git a/Task/Non-decimal-radices-Convert/PicoLisp/non-decimal-radices-convert.l b/Task/Non-decimal-radices-Convert/PicoLisp/non-decimal-radices-convert.l new file mode 100644 index 0000000000..df76228560 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/PicoLisp/non-decimal-radices-convert.l @@ -0,0 +1,22 @@ +(de numToString (N Base) + (default Base 10) + (let L NIL + (loop + (let C (% N Base) + (and (> C 9) (inc 'C 39)) + (push 'L (char (+ C `(char "0")))) ) + (T (=0 (setq N (/ N Base)))) ) + (pack L) ) ) + +(de stringToNum (S Base) + (default Base 10) + (let N 0 + (for C (chop S) + (when (> (setq C (- (char C) `(char "0"))) 9) + (dec 'C 39) ) + (setq N (+ C (* N Base))) ) + N ) ) + +(prinl (numToString 26 16)) +(prinl (stringToNum "1a" 16)) +(prinl (numToString 123456789012345678901234567890 36)) diff --git a/Task/Non-decimal-radices-Convert/Pop11/non-decimal-radices-convert-1.pop11 b/Task/Non-decimal-radices-Convert/Pop11/non-decimal-radices-convert-1.pop11 new file mode 100644 index 0000000000..62f0696480 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Pop11/non-decimal-radices-convert-1.pop11 @@ -0,0 +1,3 @@ +define number_to_base(n, base); + radix_apply(n, '%p', sprintf, base); +enddefine; diff --git a/Task/Non-decimal-radices-Convert/Pop11/non-decimal-radices-convert-2.pop11 b/Task/Non-decimal-radices-Convert/Pop11/non-decimal-radices-convert-2.pop11 new file mode 100644 index 0000000000..7d626950b6 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Pop11/non-decimal-radices-convert-2.pop11 @@ -0,0 +1,3 @@ +define string_in_base_to_number(s, base); + incharitem(stringin(base >< ':' >< s))(); +enddefine; diff --git a/Task/Non-decimal-radices-Convert/PureBasic/non-decimal-radices-convert.purebasic b/Task/Non-decimal-radices-Convert/PureBasic/non-decimal-radices-convert.purebasic new file mode 100644 index 0000000000..23d20ea872 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/PureBasic/non-decimal-radices-convert.purebasic @@ -0,0 +1,36 @@ +Global alphanum$ = "0123456789abcdefghijklmnopqrstuvwxyz" ;36 digits +#maxIntegerBitSize = SizeOf(Integer) * 8 + +Procedure toDecimal(base, s.s) + Protected length, i, toDecimal + + length = Len(s) + If length: toDecimal = FindString(alphanum$, Left(s, 1), 1) - 1: EndIf + + For i = 2 To length + toDecimal * base + FindString(alphanum$, Mid(s, i, 1), 1) - 1 + Next + ProcedureReturn toDecimal +EndProcedure + +Procedure.s toBase(base, number) + Protected i, rem, toBase.s{#maxIntegerBitSize} = Space(#maxIntegerBitSize) + + For i = #maxIntegerBitSize To 1 Step -1 + rem = number % base + PokeC(@toBase + i - 1, PeekC(@alphanum$ + rem)) + If number < base: Break: EndIf + number / base + Next + ProcedureReturn LTrim(toBase) +EndProcedure + +If OpenConsole() + PrintN( Str(toDecimal(16, "1a")) ) + + PrintN( toBase(16, 26) ) + + Print(#CRLF$ + #CRLF$ + "Press ENTER to exit") + Input() + CloseConsole() +EndIf diff --git a/Task/Non-decimal-radices-Convert/Python/non-decimal-radices-convert-1.py b/Task/Non-decimal-radices-Convert/Python/non-decimal-radices-convert-1.py new file mode 100644 index 0000000000..fb7439f31a --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Python/non-decimal-radices-convert-1.py @@ -0,0 +1 @@ +i = int('1a',16) # returns the integer 26 diff --git a/Task/Non-decimal-radices-Convert/Python/non-decimal-radices-convert-2.py b/Task/Non-decimal-radices-Convert/Python/non-decimal-radices-convert-2.py new file mode 100644 index 0000000000..82c379fc64 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Python/non-decimal-radices-convert-2.py @@ -0,0 +1,17 @@ +digits = "0123456789abcdefghijklmnopqrstuvwxyz" +def baseN(num,b): + return (((num == 0) and "0" ) + or ( baseN(num // b, b).lstrip("0") + + digits[num % b])) + +# alternatively: +def baseN(num,b): + if num == 0: return "0" + result = "" + while num != 0: + num, d = divmod(num, b) + result += digits[d] + return result[::-1] # reverse + +k = 26 +s = baseN(k,16) # returns the string 1a diff --git a/Task/Non-decimal-radices-Convert/REXX/non-decimal-radices-convert.rexx b/Task/Non-decimal-radices-Convert/REXX/non-decimal-radices-convert.rexx new file mode 100644 index 0000000000..8561942af0 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/REXX/non-decimal-radices-convert.rexx @@ -0,0 +1,46 @@ +/*REXX program converts numbers from one base to another, from 2 ──► 90.*/ +/*┌────────────────────────────────────────────────────────────────────┐ +┌─┘ Input to this program (bases must be positive whole numbers): └─┐ +│ │ +│ x is required (it may have a sign). │ +│ toBase the base to convert X to. │ +│ inBase the base X is expressed in. │ +│ │ +│ toBase or inBase can be a comma (,) which causes the default │ +└─┐ of 10 to be used. The limits of bases are: 2 ──► 90. ┌─┘ + └────────────────────────────────────────────────────────────────────┘*/ +@abc='abcdefghijklmnopqrstuvwxyz' /*lowercase Latin alphabet. */ +@abcU=@abc; upper @abcU /*go whole hog and extend 'em. */ +@@@=0123456789||@abc||@abcU /*prefix 'em with numeric digits.*/ +@@@=@@@'<>[]{}()?~!@#$%^&*_=|\/;:¢¬≈' /*add some special chars as well.*/ + /*special chars must be viewable.*/ +numeric digits 1000 /*what da hey, support gihugeics.*/ +maxB=length(@@@) /*max base (radix) supported here*/ +parse arg x toB inB 1 ox . /*get a number, toBase, inBase*/ +if toB=='' | toB==',' then toB=10 /*if skipped, assume default (10)*/ +if inB=='' | inB==',' then inB=10 /* " " " " " */ +if inB<2 | inb>maxB then call erb 'inBase',inB /*bad boy inBase.*/ +if toB<2 | tob>maxB then call erb 'toBase',toB /* " " toBase.*/ +if x=='' then call erm /* " " number.*/ +sigX=left(x,1); if pos(sigX,"-+")\==0 then x=substr(x,2) /*X has sign?*/ + else sigX= /*no sign. */ +#=0; do j=1 for length(x) /*convert X, base inB ──► base 10*/ + _=substr(x,j,1) /*pick off a "digit" from X. */ + v=pos(_,@@@) /*get the value of this "digit". */ + if v==0 | v>inB then call erd x,j,inB /*illegal "digit"? */ + #=#*inB+v-1 /*construct new num, dig by dig. */ + end /*j*/ + +y=; do while # >= toB /*convert #, base 10 ──► base toB*/ + y=substr(@@@,(#//toB)+1,1)y /*construct the output number. */ + #=#%toB /*... and whittle # down also. */ + end /*while #>-toB*/ + +y=sigX || substr(@@@,#+1,1)y /*prepend the sign if it existed.*/ +say ox "(base" inB')' center('is',20) y "(base" toB')' /*show & tell.*/ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────error subroutines───────────────────*/ +erb: call ser; say 'illegal' arg(2) "base:" arg(1) "must be in range: 2──►" maxB +erd: call ser; say 'illegal "digit" in' x":" _ +erm: call ser; say 'no argument specified.' +ser: say; say '*** error! ***'; say; exit 13 diff --git a/Task/Non-decimal-radices-Convert/Ruby/non-decimal-radices-convert-1.rb b/Task/Non-decimal-radices-Convert/Ruby/non-decimal-radices-convert-1.rb new file mode 100644 index 0000000000..468f84352f --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Ruby/non-decimal-radices-convert-1.rb @@ -0,0 +1,2 @@ +s = 26.to_s(16) # returns the string 1a +i = '1a'.to_i(16) # returns the integer 26 diff --git a/Task/Non-decimal-radices-Convert/Ruby/non-decimal-radices-convert-2.rb b/Task/Non-decimal-radices-Convert/Ruby/non-decimal-radices-convert-2.rb new file mode 100644 index 0000000000..abf9962fea --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Ruby/non-decimal-radices-convert-2.rb @@ -0,0 +1 @@ +"59".to_i(7) # returns 5, but this is probably not what you wanted diff --git a/Task/Non-decimal-radices-Convert/Ruby/non-decimal-radices-convert-3.rb b/Task/Non-decimal-radices-Convert/Ruby/non-decimal-radices-convert-3.rb new file mode 100644 index 0000000000..856fd2c7e7 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Ruby/non-decimal-radices-convert-3.rb @@ -0,0 +1,32 @@ +module BaseConvert + DIGITS = %w{0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z} + + def baseconvert(str, basefrom, baseto) + dec2base(base2dec(str, basefrom), baseto) + end + + def base2dec(str, base) + raise ArgumentError, "base is invalid" unless base.between?(2, DIGITS.length) + res = 0 + str.to_s.downcase.each_char do |c| + idx = DIGITS[0,base].find_index(c) + idx.nil? and raise ArgumentError, "invalid base-#{base} digit: #{c}" + res = res * base + idx + end + res + end + + def dec2base(n, base) + return "0" if n == 0 + raise ArgumentError, "base is invalid" unless base.between?(2, DIGITS.length) + res = [] + while n > 0 + n, r = n.divmod(base) + res.unshift(DIGITS[r]) + end + res.join("") + end +end + +include BaseConvert +p baseconvert("107h", 23, 7) # => "50664" diff --git a/Task/Non-decimal-radices-Convert/Run-BASIC/non-decimal-radices-convert.run b/Task/Non-decimal-radices-Convert/Run-BASIC/non-decimal-radices-convert.run new file mode 100644 index 0000000000..25ce787b6e --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Run-BASIC/non-decimal-radices-convert.run @@ -0,0 +1,28 @@ +global basCvt$ +basCvt$ ="0123456789abcdefghijklmnopqrstuvwxyz" +html "" + +for i =1 to 10 + RandNum = int(100 * rnd(1)) + base = 2 +int(35 * rnd(1)) + + html "" +next i +html "
DecimalTo BaseNumto Dec
";using("###", RandNum);"";using("###", base);"";toBase$(base,RandNum);"";toDecimal( base, toBase$( base, RandNum));"
" +end + +function toBase$(b,n) ' b=base n=nmber + toBase$ ="" + for i =10 to 1 step -1 + toBase$ =mid$(basCvt$,n mod b +1,1) +toBase$ + n =int( n /b) + if n <1 then exit for + next i +end function + +function toDecimal( b, s$) ' scring number to decimal + toDecimal =0 + for i =1 to len( s$) + toDecimal = toDecimal * b + instr(basCvt$,mid$(s$,i,1),1) -1 + next i +end function diff --git a/Task/Non-decimal-radices-Convert/Slate/non-decimal-radices-convert.slate b/Task/Non-decimal-radices-Convert/Slate/non-decimal-radices-convert.slate new file mode 100644 index 0000000000..1442ea510a --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Slate/non-decimal-radices-convert.slate @@ -0,0 +1,2 @@ +26 printString &radix: 16 +Integer readFrom: '1A' &radix: 16. diff --git a/Task/Non-decimal-radices-Convert/Standard-ML/non-decimal-radices-convert.ml b/Task/Non-decimal-radices-Convert/Standard-ML/non-decimal-radices-convert.ml new file mode 100644 index 0000000000..f473a70e27 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Standard-ML/non-decimal-radices-convert.ml @@ -0,0 +1,25 @@ +fun toBase b v = let + fun toBase' (a, 0) = a + | toBase' (a, v) = toBase' (v mod b :: a, v div b) +in + toBase' ([], v) +end + +fun fromBase b ds = + foldl (fn (k, n) => n * b + k) 0 ds + +val toAlphaDigits = let + fun convert n = if n < 10 then chr (n + ord #"0") + else chr (n + ord #"a" - 10) +in + implode o map convert +end + +val fromAlphaDigits = let + fun convert c = if Char.isDigit c then ord c - ord #"0" + else if Char.isUpper c then ord c - ord #"A" + 10 + else if Char.isLower c then ord c - ord #"a" + 10 + else raise Match +in + map convert o explode +end diff --git a/Task/Non-decimal-radices-Convert/Tcl/non-decimal-radices-convert.tcl b/Task/Non-decimal-radices-Convert/Tcl/non-decimal-radices-convert.tcl new file mode 100644 index 0000000000..91f8b9dd83 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Tcl/non-decimal-radices-convert.tcl @@ -0,0 +1,28 @@ +namespace eval baseconvert { + variable chars "0123456789abcdefghijklmnopqrstuvwxyz" + namespace export baseconvert +} +proc baseconvert::dec2base {n b} { + variable chars + expr {$n == 0 ? 0 + : "[string trimleft [dec2base [expr {$n/$b}] $b] 0][string index $chars [expr {$n%$b}]]" + } +} +proc baseconvert::base2dec {n b} { + variable chars + set sum 0 + foreach char [split $n ""] { + set d [string first $char [string range $chars 0 [expr {$b - 1}]]] + if {$d == -1} {error "invalid base-$b digit '$char' in $n"} + set sum [expr {$sum * $b + $d}] + } + return $sum +} +proc baseconvert::baseconvert {n basefrom baseto} { + dec2base [base2dec $n $basefrom] $baseto +} + +namespace import baseconvert::baseconvert +baseconvert 12345 10 23 ;# ==> 107h +baseconvert 107h 23 7 ;# ==> 50664 +baseconvert 50664 7 10 ;# ==> 12345 diff --git a/Task/Non-decimal-radices-Convert/Ursala/non-decimal-radices-convert-1.ursala b/Task/Non-decimal-radices-Convert/Ursala/non-decimal-radices-convert-1.ursala new file mode 100644 index 0000000000..e980ea84f7 --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Ursala/non-decimal-radices-convert-1.ursala @@ -0,0 +1,6 @@ +#import std +#import nat + +num_to_string "b" = ||'0'! (-: num digits--letters)*+ @NiX ~&r->l ^|rrPlCrlPX/~& division\"b" + +string_to_num "b" = @x =>0 sum^|/(-:@rlXS num digits--letters) product/"b" diff --git a/Task/Non-decimal-radices-Convert/Ursala/non-decimal-radices-convert-2.ursala b/Task/Non-decimal-radices-Convert/Ursala/non-decimal-radices-convert-2.ursala new file mode 100644 index 0000000000..2ed9e5ab2d --- /dev/null +++ b/Task/Non-decimal-radices-Convert/Ursala/non-decimal-radices-convert-2.ursala @@ -0,0 +1,11 @@ +test_data = <1,2,15,32,100,65536,323498993> + +#cast %sLnLUL + +tests = + +< + num_to_string32* test_data, + string_to_num32* num_to_string32* test_data, + num_to_string8* test_data, + string_to_num8* num_to_string8* test_data> diff --git a/Task/Non-decimal-radices-Convert/XPL0/non-decimal-radices-convert.xpl0 b/Task/Non-decimal-radices-Convert/XPL0/non-decimal-radices-convert.xpl0 new file mode 100644 index 0000000000..f808bc680d --- /dev/null +++ b/Task/Non-decimal-radices-Convert/XPL0/non-decimal-radices-convert.xpl0 @@ -0,0 +1,31 @@ +include c:\cxpl\codes; \intrinsic 'code' declarations +string 0; \use zero-terminated string convention + +func Num2Str(N, B); \Convert integer N to a numeric string in base B +int N, B; +char S(32); int I; +[I:= 31; +S(31):= 0; \terminate string +repeat I:= I-1; + N:= N/B; + S(I):= rem(0) + (if rem(0)<=9 then ^0 else ^a-10); +until N=0; +return @S(I); \BEWARE! very temporary string space +]; + +func Str2Num(S, B); \Convert numeric string S in base B to an integer +char S; int B; +int I, N; +[I:= 0; N:= 0; +while S(I) do + [N:= N*B + S(I) - (if S(I)<=^9 then ^0 else ^a-10); I:= I+1]; +return N; +]; + +[Text(0, Num2Str(0, 10)); CrLf(0); + Text(0, Num2Str(26, 16)); CrLf(0); + Text(0, Num2Str($7FFF_FFFF, 2)); CrLf(0); + IntOut(0, Str2Num("0100", 2)); CrLf(0); + IntOut(0, Str2Num("1a", 16)); CrLf(0); + IntOut(0, Str2Num("deadbeef", 16)); CrLf(0); +] diff --git a/Task/Non-decimal-radices-Input/0DESCRIPTION b/Task/Non-decimal-radices-Input/0DESCRIPTION new file mode 100644 index 0000000000..b9e2c554ce --- /dev/null +++ b/Task/Non-decimal-radices-Input/0DESCRIPTION @@ -0,0 +1,9 @@ +It is common to have a string containing a number written in some format, with the most common ones being decimal, hexadecimal, octal and binary. Such strings are found in many places (user interfaces, configuration files, XML data, network protocols, etc.) + +This task requires parsing of such a string (which may be assumed to contain nothing else) using the language's built-in facilities if possible. Parsing of decimal strings is required, parsing of other formats is optional but should be shown (i.e., if the language can parse in base-19 then that should be illustrated). + +The solutions may assume that the base of the number in the string is known. In particular, if your language has a facility to guess the base of a number by looking at a prefix (e.g. "0x" for hexadecimal) or other distinguishing syntax as it parses it, please show that. + +The reverse operation is in task [[Common number base formatting]] + +For general number base conversion, see [[Number base conversion]]. diff --git a/Task/Non-decimal-radices-Input/1META.yaml b/Task/Non-decimal-radices-Input/1META.yaml new file mode 100644 index 0000000000..8644b2ad9b --- /dev/null +++ b/Task/Non-decimal-radices-Input/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Arithmetic operations diff --git a/Task/Non-decimal-radices-Input/ALGOL-68/non-decimal-radices-input.alg b/Task/Non-decimal-radices-Input/ALGOL-68/non-decimal-radices-input.alg new file mode 100644 index 0000000000..533ddaa9a0 --- /dev/null +++ b/Task/Non-decimal-radices-Input/ALGOL-68/non-decimal-radices-input.alg @@ -0,0 +1,25 @@ +main: +( + FILE fbuf; STRING sbuf; + + OP FBUF = (STRING in sbuf)REF FILE: ( + sbuf := in sbuf; + associate(fbuf, sbuf); + fbuf + ); + + BITS num; + + getf(FBUF("0123459"), ($10r7d$, num)); + printf(($gl$, ABS num)); # prints 123459 # + + getf(FBUF("abcf123"), ($16r7d$, num)); + printf(($gl$, ABS num)); # prints 180154659 # + + getf(FBUF("7651"), ($8r4d$, num)); + printf(($gl$, ABS num)); # prints 4009 # + + getf(FBUF("1010011010"), ($2r10d$, num)); + printf(($gl$, ABS num)) # prints 666 # + +) diff --git a/Task/Non-decimal-radices-Input/Ada/non-decimal-radices-input.ada b/Task/Non-decimal-radices-Input/Ada/non-decimal-radices-input.ada new file mode 100644 index 0000000000..eee4a4aa54 --- /dev/null +++ b/Task/Non-decimal-radices-Input/Ada/non-decimal-radices-input.ada @@ -0,0 +1,14 @@ +with Ada.Text_IO; +procedure Numbers is + package Int_IO is new Ada.Text_IO.Integer_IO (Integer); + package Float_IO is new Ada.Text_IO.Float_IO (Float); +begin + Int_IO.Put (Integer'Value ("16#ABCF123#")); + Ada.Text_IO.New_Line; + Int_IO.Put (Integer'Value ("8#7651#")); + Ada.Text_IO.New_Line; + Int_IO.Put (Integer'Value ("2#1010011010#")); + Ada.Text_IO.New_Line; + Float_IO.Put (Float'Value ("16#F.FF#E+2")); + Ada.Text_IO.New_Line; +end Numbers; diff --git a/Task/Non-decimal-radices-Input/BBC-BASIC/non-decimal-radices-input.bbc b/Task/Non-decimal-radices-Input/BBC-BASIC/non-decimal-radices-input.bbc new file mode 100644 index 0000000000..b806936f07 --- /dev/null +++ b/Task/Non-decimal-radices-Input/BBC-BASIC/non-decimal-radices-input.bbc @@ -0,0 +1,10 @@ + REM VAL parses decimal strings: + PRINT VAL("0") + PRINT VAL("123456789") + PRINT VAL("-987654321") + + REM EVAL can be used to parse binary and hexadecimal strings: + PRINT EVAL("%10101010") + PRINT EVAL("%1111111111") + PRINT EVAL("&ABCD") + PRINT EVAL("&FFFFFFFF") diff --git a/Task/Non-decimal-radices-Input/C++/non-decimal-radices-input.cpp b/Task/Non-decimal-radices-Input/C++/non-decimal-radices-input.cpp new file mode 100644 index 0000000000..109a64d5b2 --- /dev/null +++ b/Task/Non-decimal-radices-Input/C++/non-decimal-radices-input.cpp @@ -0,0 +1,23 @@ +#include +#include + +int main() +{ + int num; + + std::istringstream("0123459") >> num; + std::cout << num << std::endl; // prints 123459 + + std::istringstream("0123459") >> std::dec >> num; + std::cout << num << std::endl; // prints 123459 + + std::istringstream("abcf123") >> std::hex >> num; + std::cout << num << std::endl; // prints 180154659 + + std::istringstream("7651") >> std::oct >> num; + std::cout << num << std::endl; // prints 4009 + + // binary not supported + + return 0; +} diff --git a/Task/Non-decimal-radices-Input/C/non-decimal-radices-input-1.c b/Task/Non-decimal-radices-Input/C/non-decimal-radices-input-1.c new file mode 100644 index 0000000000..5acfa37c8a --- /dev/null +++ b/Task/Non-decimal-radices-Input/C/non-decimal-radices-input-1.c @@ -0,0 +1,19 @@ +#include + +int main() +{ + int num; + + sscanf("0123459", "%d", &num); + printf("%d\n", num); /* prints 123459 */ + + sscanf("abcf123", "%x", &num); + printf("%d\n", num); /* prints 180154659 */ + + sscanf("7651", "%o", &num); + printf("%d\n", num); /* prints 4009 */ + + /* binary not supported */ + + return 0; +} diff --git a/Task/Non-decimal-radices-Input/C/non-decimal-radices-input-2.c b/Task/Non-decimal-radices-Input/C/non-decimal-radices-input-2.c new file mode 100644 index 0000000000..0149f80972 --- /dev/null +++ b/Task/Non-decimal-radices-Input/C/non-decimal-radices-input-2.c @@ -0,0 +1,25 @@ +#include +#include +#include + +int main() +{ + int num; + char *endptr; + + num = strtol("123459", &endptr, 0); + assert(*endptr == '\0'); + printf("%d\n", num); /* prints 123459 */ + + num = strtol("0xabcf123", &endptr, 0); + assert(*endptr == '\0'); + printf("%d\n", num); /* prints 180154659 */ + + num = strtol("07651", &endptr, 0); + assert(*endptr == '\0'); + printf("%d\n", num); /* prints 4009 */ + + /* binary not supported */ + + return 0; +} diff --git a/Task/Non-decimal-radices-Input/Common-Lisp/non-decimal-radices-input.lisp b/Task/Non-decimal-radices-Input/Common-Lisp/non-decimal-radices-input.lisp new file mode 100644 index 0000000000..9e33fdb7ec --- /dev/null +++ b/Task/Non-decimal-radices-Input/Common-Lisp/non-decimal-radices-input.lisp @@ -0,0 +1 @@ +(parse-integer "abc" :radix 20 :junk-allowed t) ; => 4232 diff --git a/Task/Non-decimal-radices-Input/D/non-decimal-radices-input.d b/Task/Non-decimal-radices-Input/D/non-decimal-radices-input.d new file mode 100644 index 0000000000..367770331a --- /dev/null +++ b/Task/Non-decimal-radices-Input/D/non-decimal-radices-input.d @@ -0,0 +1,8 @@ +import std.stdio, std.conv; + +void main() { + immutable text = "100"; + foreach (base; 2 .. 21) + writefln("String '%s' in base %d is %d in base 10" , + text, base, to!int(text, base)); +} diff --git a/Task/Non-decimal-radices-Input/E/non-decimal-radices-input.e b/Task/Non-decimal-radices-Input/E/non-decimal-radices-input.e new file mode 100644 index 0000000000..adc4742a11 --- /dev/null +++ b/Task/Non-decimal-radices-Input/E/non-decimal-radices-input.e @@ -0,0 +1,5 @@ +? __makeInt("200", 16) +# value: 512 + +? __makeInt("200", 10) +# value: 200 diff --git a/Task/Non-decimal-radices-Input/Factor/non-decimal-radices-input.factor b/Task/Non-decimal-radices-Input/Factor/non-decimal-radices-input.factor new file mode 100644 index 0000000000..5ddb6c5395 --- /dev/null +++ b/Task/Non-decimal-radices-Input/Factor/non-decimal-radices-input.factor @@ -0,0 +1,2 @@ +IN: math.parser +: oct> ( str -- n/f ) 8 base> ; inline diff --git a/Task/Non-decimal-radices-Input/Forth/non-decimal-radices-input.fth b/Task/Non-decimal-radices-Input/Forth/non-decimal-radices-input.fth new file mode 100644 index 0000000000..f3f28b9c47 --- /dev/null +++ b/Task/Non-decimal-radices-Input/Forth/non-decimal-radices-input.fth @@ -0,0 +1,6 @@ +: parse# ( str len -- u true | false ) + 0. 2SWAP DUP >R >NUMBER NIP NIP + R> <> DUP 0= IF NIP THEN ; + +: base# ( str len base -- u true | false ) + BASE @ >R BASE ! parse# R> BASE ! ; diff --git a/Task/Non-decimal-radices-Input/Fortran/non-decimal-radices-input.f b/Task/Non-decimal-radices-Input/Fortran/non-decimal-radices-input.f new file mode 100644 index 0000000000..472b9f0b1f --- /dev/null +++ b/Task/Non-decimal-radices-Input/Fortran/non-decimal-radices-input.f @@ -0,0 +1,23 @@ +program Example + implicit none + + integer :: num + character(32) :: str + + str = "0123459" + read(str, "(i10)") num ! Decimal + write(*,*) num ! Prints 123459 + + str = "abcf123" + read(str, "(z8)") num ! Hexadecimal + write(*,*) num ! Prints 180154659 + + str = "7651" + read(str, "(o11)") num ! Octal + write(*,*) num ! Prints 4009 + + str = "1010011010" + read(str, "(b32)") num ! Binary + write(*,*) num ! Prints 666 + +end program diff --git a/Task/Non-decimal-radices-Input/Go/non-decimal-radices-input.go b/Task/Non-decimal-radices-Input/Go/non-decimal-radices-input.go new file mode 100644 index 0000000000..5609efb7bf --- /dev/null +++ b/Task/Non-decimal-radices-Input/Go/non-decimal-radices-input.go @@ -0,0 +1,55 @@ +package main + +import ( + "bytes" + "fmt" + "math/big" + "strconv" +) + +func main() { + // package strconv: the most common string to int conversion, + // base 10 only. + x, _ := strconv.Atoi("13") + fmt.Println(x) + + // ParseInt handles arbitrary bases from 2 to 36, and returns + // a result of the requested size (64 bits shown here.) + x64, _ := strconv.ParseInt("3c2", 19, 64) + fmt.Println(x64) + + // package bytes+fmt: allows direct conversion from strings + // to integer types for bases 2, 8, 10, and 16. + // (Fscanf and scanf are more common for reading from + // files or stdin than for reading from strings.) + fmt.Fscanf(bytes.NewBufferString("1101"), "%b", &x) + fmt.Println(x) + + fmt.Fscanf(bytes.NewBufferString("15"), "%o", &x) + fmt.Println(x) + + fmt.Fscanf(bytes.NewBufferString("13"), "%d", &x) + fmt.Println(x) + + fmt.Fscanf(bytes.NewBufferString("d"), "%x", &x) + fmt.Println(x) + + // package big: allows conversion from string to big integer. + // any base from 2 to 16 can be specified as second parameter. + var z big.Int + z.SetString("111", 3) + fmt.Println(&z) + + // if second parameter is 0, base is determined by prefix, if any + z.SetString("0b1101", 0) // 0b -> base 2 + fmt.Println(&z) + + z.SetString("015", 0) // 0 -> base 8 + fmt.Println(&z) + + z.SetString("13", 0) // no prefix -> base 10 + fmt.Println(&z) + + z.SetString("0xd", 0) // 0x -> base 16 + fmt.Println(&z) +} diff --git a/Task/Non-decimal-radices-Input/Haskell/non-decimal-radices-input.hs b/Task/Non-decimal-radices-Input/Haskell/non-decimal-radices-input.hs new file mode 100644 index 0000000000..8ab0085c23 --- /dev/null +++ b/Task/Non-decimal-radices-Input/Haskell/non-decimal-radices-input.hs @@ -0,0 +1,6 @@ +Prelude> read "123459" :: Integer +123459 +Prelude> read "0xabcf123" :: Integer +180154659 +Prelude> read "0o7651" :: Integer +4009 diff --git a/Task/Non-decimal-radices-Input/HicEst/non-decimal-radices-input.hicest b/Task/Non-decimal-radices-Input/HicEst/non-decimal-radices-input.hicest new file mode 100644 index 0000000000..cf7bf75f31 --- /dev/null +++ b/Task/Non-decimal-radices-Input/HicEst/non-decimal-radices-input.hicest @@ -0,0 +1,4 @@ +READ(Text="123459 ", Format="i10") dec ! 123459 +READ(Text=" abcf123 ", Format="Z10") hex ! 180154659 +READ(Text=" 7651 ", Format="o10") oct ! 4009 +READ(Text=" 101011001", Format="B10.10") bin ! 345 diff --git a/Task/Non-decimal-radices-Input/Icon/non-decimal-radices-input.icon b/Task/Non-decimal-radices-Input/Icon/non-decimal-radices-input.icon new file mode 100644 index 0000000000..ba36a0037f --- /dev/null +++ b/Task/Non-decimal-radices-Input/Icon/non-decimal-radices-input.icon @@ -0,0 +1,12 @@ +procedure convert (str) + write (left(str, 10) || " = " || integer(str)) +end + +procedure main () + convert (" 2r1001") + convert (" 8r7135") + convert ("16rABC1234") + convert ("36r1Z") + + write ("2r1001" + "36r1Z") # shows type conversion, string->integer +end diff --git a/Task/Non-decimal-radices-Input/J/non-decimal-radices-input-1.j b/Task/Non-decimal-radices-Input/J/non-decimal-radices-input-1.j new file mode 100644 index 0000000000..97e8427252 --- /dev/null +++ b/Task/Non-decimal-radices-Input/J/non-decimal-radices-input-1.j @@ -0,0 +1 @@ + baseN=: (, 'b'&,)&.": diff --git a/Task/Non-decimal-radices-Input/J/non-decimal-radices-input-2.j b/Task/Non-decimal-radices-Input/J/non-decimal-radices-input-2.j new file mode 100644 index 0000000000..004b3ed36d --- /dev/null +++ b/Task/Non-decimal-radices-Input/J/non-decimal-radices-input-2.j @@ -0,0 +1 @@ + baseN=: 0&".@,&": 'b' , ] NB. Use if the source of the non-decimal "numbers" is not trustworthy diff --git a/Task/Non-decimal-radices-Input/J/non-decimal-radices-input-3.j b/Task/Non-decimal-radices-Input/J/non-decimal-radices-input-3.j new file mode 100644 index 0000000000..d86b44e980 --- /dev/null +++ b/Task/Non-decimal-radices-Input/J/non-decimal-radices-input-3.j @@ -0,0 +1,6 @@ + 16 baseN 'abcf123' +180154659 + 8 baseN '7651' +4009 + 10 baseN '123459' +123459 diff --git a/Task/Non-decimal-radices-Input/J/non-decimal-radices-input-4.j b/Task/Non-decimal-radices-Input/J/non-decimal-radices-input-4.j new file mode 100644 index 0000000000..c55250227e --- /dev/null +++ b/Task/Non-decimal-radices-Input/J/non-decimal-radices-input-4.j @@ -0,0 +1,2 @@ + 16babcf123 8b7651 10b123459 +180154659 4009 123459 diff --git a/Task/Non-decimal-radices-Input/J/non-decimal-radices-input-5.j b/Task/Non-decimal-radices-Input/J/non-decimal-radices-input-5.j new file mode 100644 index 0000000000..e80debdf21 --- /dev/null +++ b/Task/Non-decimal-radices-Input/J/non-decimal-radices-input-5.j @@ -0,0 +1,2 @@ + 2bhelloworld +17955 diff --git a/Task/Non-decimal-radices-Input/J/non-decimal-radices-input-6.j b/Task/Non-decimal-radices-Input/J/non-decimal-radices-input-6.j new file mode 100644 index 0000000000..58650599cf --- /dev/null +++ b/Task/Non-decimal-radices-Input/J/non-decimal-radices-input-6.j @@ -0,0 +1,2 @@ + 1000bogus +24016030028 diff --git a/Task/Non-decimal-radices-Input/Java/non-decimal-radices-input-1.java b/Task/Non-decimal-radices-Input/Java/non-decimal-radices-input-1.java new file mode 100644 index 0000000000..df18ec6486 --- /dev/null +++ b/Task/Non-decimal-radices-Input/Java/non-decimal-radices-input-1.java @@ -0,0 +1,3 @@ +Scanner sc = new Scanner(System.in); //or any other InputStream or String +sc.useRadix(base); //any number from Character.MIN_RADIX (2) to CHARACTER.MAX_RADIX (36) +sc.nextInt(); //read in a value diff --git a/Task/Non-decimal-radices-Input/Java/non-decimal-radices-input-2.java b/Task/Non-decimal-radices-Input/Java/non-decimal-radices-input-2.java new file mode 100644 index 0000000000..3799d3814e --- /dev/null +++ b/Task/Non-decimal-radices-Input/Java/non-decimal-radices-input-2.java @@ -0,0 +1 @@ +int number = Integer.parseInt(stringNum, base); diff --git a/Task/Non-decimal-radices-Input/Java/non-decimal-radices-input-3.java b/Task/Non-decimal-radices-Input/Java/non-decimal-radices-input-3.java new file mode 100644 index 0000000000..07570dd447 --- /dev/null +++ b/Task/Non-decimal-radices-Input/Java/non-decimal-radices-input-3.java @@ -0,0 +1,3 @@ +Integer.decode("0xabcf123"); // hex +Integer.decode("07651"); // octal +Integer.decode("123459"); // decimal diff --git a/Task/Non-decimal-radices-Input/JavaScript/non-decimal-radices-input-1.js b/Task/Non-decimal-radices-Input/JavaScript/non-decimal-radices-input-1.js new file mode 100644 index 0000000000..c53c22b5e1 --- /dev/null +++ b/Task/Non-decimal-radices-Input/JavaScript/non-decimal-radices-input-1.js @@ -0,0 +1,6 @@ ++"0123459"; // 123459 ++"0xabcf123"; // 180154659 + +// also supports negative numbers, but not for hex: ++"-0123459"; // -123459 ++"-0xabcf123"; // NaN diff --git a/Task/Non-decimal-radices-Input/JavaScript/non-decimal-radices-input-2.js b/Task/Non-decimal-radices-Input/JavaScript/non-decimal-radices-input-2.js new file mode 100644 index 0000000000..f2f1577f49 --- /dev/null +++ b/Task/Non-decimal-radices-Input/JavaScript/non-decimal-radices-input-2.js @@ -0,0 +1,12 @@ +parseInt(" 0xF", 16); +parseInt(" F", 16); +parseInt("17", 8); +parseInt(021, 8); +parseInt("015", 10); +parseInt(15.99, 10); +parseInt("FXX123", 16); +parseInt("1111", 2); +parseInt("15*3", 10); +parseInt("15e2", 10); +parseInt("15px", 10); +parseInt("12", 13); diff --git a/Task/Non-decimal-radices-Input/JavaScript/non-decimal-radices-input-3.js b/Task/Non-decimal-radices-Input/JavaScript/non-decimal-radices-input-3.js new file mode 100644 index 0000000000..c5a1520b89 --- /dev/null +++ b/Task/Non-decimal-radices-Input/JavaScript/non-decimal-radices-input-3.js @@ -0,0 +1,2 @@ +parseInt("Hello", 8); // Not a number at all +parseInt("546", 2); // Digits are not valid for binary representations diff --git a/Task/Non-decimal-radices-Input/JavaScript/non-decimal-radices-input-4.js b/Task/Non-decimal-radices-Input/JavaScript/non-decimal-radices-input-4.js new file mode 100644 index 0000000000..a1f526cc6d --- /dev/null +++ b/Task/Non-decimal-radices-Input/JavaScript/non-decimal-radices-input-4.js @@ -0,0 +1,10 @@ +parseInt("-F", 16); +parseInt("-0F", 16); +parseInt("-0XF", 16); +parseInt(-10, 16); +parseInt(-15.1, 10) +parseInt(" -17", 8); +parseInt(" -15", 10); +parseInt("-1111", 2); +parseInt("-15e1", 10); +parseInt("-12", 13); diff --git a/Task/Non-decimal-radices-Input/JavaScript/non-decimal-radices-input-5.js b/Task/Non-decimal-radices-Input/JavaScript/non-decimal-radices-input-5.js new file mode 100644 index 0000000000..e69929663a --- /dev/null +++ b/Task/Non-decimal-radices-Input/JavaScript/non-decimal-radices-input-5.js @@ -0,0 +1 @@ +parseInt("0e0", 16); diff --git a/Task/Non-decimal-radices-Input/JavaScript/non-decimal-radices-input-6.js b/Task/Non-decimal-radices-Input/JavaScript/non-decimal-radices-input-6.js new file mode 100644 index 0000000000..1f1d22b5e9 --- /dev/null +++ b/Task/Non-decimal-radices-Input/JavaScript/non-decimal-radices-input-6.js @@ -0,0 +1,2 @@ +parseInt("0e0"); // 0 +parseInt("08"); // 0, '8' is not an octal digit. diff --git a/Task/Non-decimal-radices-Input/Lua/non-decimal-radices-input.lua b/Task/Non-decimal-radices-Input/Lua/non-decimal-radices-input.lua new file mode 100644 index 0000000000..3c2d43e425 --- /dev/null +++ b/Task/Non-decimal-radices-Input/Lua/non-decimal-radices-input.lua @@ -0,0 +1,4 @@ +print( tonumber("123") ) +print( tonumber("a5b0", 16) ) +print( tonumber("011101", 2) ) +print( tonumber("za3r", 36) ) diff --git a/Task/Non-decimal-radices-Input/Mathematica/non-decimal-radices-input.math b/Task/Non-decimal-radices-Input/Mathematica/non-decimal-radices-input.math new file mode 100644 index 0000000000..1408790b6a --- /dev/null +++ b/Task/Non-decimal-radices-Input/Mathematica/non-decimal-radices-input.math @@ -0,0 +1,5 @@ +19^^91g5dcg2h6da7260a9f3c4a +->123456789012345678901234567890 + +2^^11110001001000000 +->123456 diff --git a/Task/Non-decimal-radices-Input/OCaml/non-decimal-radices-input-1.ocaml b/Task/Non-decimal-radices-Input/OCaml/non-decimal-radices-input-1.ocaml new file mode 100644 index 0000000000..3fcba9937a --- /dev/null +++ b/Task/Non-decimal-radices-Input/OCaml/non-decimal-radices-input-1.ocaml @@ -0,0 +1,8 @@ +# int_of_string "123459";; +- : int = 123459 +# int_of_string "0xabcf123";; +- : int = 180154659 +# int_of_string "0o7651";; +- : int = 4009 +# int_of_string "0b101011001";; +- : int = 345 diff --git a/Task/Non-decimal-radices-Input/OCaml/non-decimal-radices-input-2.ocaml b/Task/Non-decimal-radices-Input/OCaml/non-decimal-radices-input-2.ocaml new file mode 100644 index 0000000000..af8e324460 --- /dev/null +++ b/Task/Non-decimal-radices-Input/OCaml/non-decimal-radices-input-2.ocaml @@ -0,0 +1,6 @@ +# Scanf.sscanf "123459" "%d" (fun x -> x);; +- : int = 123459 +# Scanf.sscanf "abcf123" "%x" (fun x -> x);; +- : int = 180154659 +# Scanf.sscanf "7651" "%o" (fun x -> x);; +- : int = 4009 diff --git a/Task/Non-decimal-radices-Input/Oz/non-decimal-radices-input.oz b/Task/Non-decimal-radices-Input/Oz/non-decimal-radices-input.oz new file mode 100644 index 0000000000..77332300c9 --- /dev/null +++ b/Task/Non-decimal-radices-Input/Oz/non-decimal-radices-input.oz @@ -0,0 +1,4 @@ +{String.toInt "42"} %% decimal += {String.toInt "0x2a"} %% hexadecimal += {String.toInt "052"} %% octal += {String.toInt "0b101010"} %% binary diff --git a/Task/Non-decimal-radices-Input/PARI-GP/non-decimal-radices-input.pari b/Task/Non-decimal-radices-Input/PARI-GP/non-decimal-radices-input.pari new file mode 100644 index 0000000000..668e8aefef --- /dev/null +++ b/Task/Non-decimal-radices-Input/PARI-GP/non-decimal-radices-input.pari @@ -0,0 +1,16 @@ +convert(numb1,b1,b2)={ + my(B=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],a=0,c=""); + numb1=Vec(Str(numb1)); + forstep(y=#numb1,1,-1, + for(x=1,b1, + if(numb1[y]==B[x], + a=a+(x-1)*b1^(#numb1-y) + ) + ) + ); + until(a/b2==0, + c=concat(B[a%b2+1],c); + a=a\b2 + ); + c +}; diff --git a/Task/Non-decimal-radices-Input/PHP/non-decimal-radices-input-1.php b/Task/Non-decimal-radices-Input/PHP/non-decimal-radices-input-1.php new file mode 100644 index 0000000000..ea1a33865d --- /dev/null +++ b/Task/Non-decimal-radices-Input/PHP/non-decimal-radices-input-1.php @@ -0,0 +1,7 @@ + diff --git a/Task/Non-decimal-radices-Input/PHP/non-decimal-radices-input-2.php b/Task/Non-decimal-radices-Input/PHP/non-decimal-radices-input-2.php new file mode 100644 index 0000000000..77fa8f3f24 --- /dev/null +++ b/Task/Non-decimal-radices-Input/PHP/non-decimal-radices-input-2.php @@ -0,0 +1,5 @@ + diff --git a/Task/Non-decimal-radices-Input/PHP/non-decimal-radices-input-3.php b/Task/Non-decimal-radices-Input/PHP/non-decimal-radices-input-3.php new file mode 100644 index 0000000000..e047933636 --- /dev/null +++ b/Task/Non-decimal-radices-Input/PHP/non-decimal-radices-input-3.php @@ -0,0 +1,5 @@ + diff --git a/Task/Non-decimal-radices-Input/PL-I/non-decimal-radices-input.pli b/Task/Non-decimal-radices-Input/PL-I/non-decimal-radices-input.pli new file mode 100644 index 0000000000..d7f148e800 --- /dev/null +++ b/Task/Non-decimal-radices-Input/PL-I/non-decimal-radices-input.pli @@ -0,0 +1,6 @@ +get edit (N) (A(7)); /* decimal input of 7 columns */ +put skip list (N); + +declare BS bit (32); +get edit (BS) (B(32)); /* Binary input of 32 binary digits. */ +put skip edit (BS) (B); diff --git a/Task/Non-decimal-radices-Input/Perl-6/non-decimal-radices-input-1.pl6 b/Task/Non-decimal-radices-Input/Perl-6/non-decimal-radices-input-1.pl6 new file mode 100644 index 0000000000..c37d486677 --- /dev/null +++ b/Task/Non-decimal-radices-Input/Perl-6/non-decimal-radices-input-1.pl6 @@ -0,0 +1,4 @@ +say 0b11011; # -> 27 +say 0o11011; # -> 4617 +say 0d11011; # -> 11011 +say 0x11011; # -> 69649 diff --git a/Task/Non-decimal-radices-Input/Perl-6/non-decimal-radices-input-2.pl6 b/Task/Non-decimal-radices-Input/Perl-6/non-decimal-radices-input-2.pl6 new file mode 100644 index 0000000000..b6aa790c71 --- /dev/null +++ b/Task/Non-decimal-radices-Input/Perl-6/non-decimal-radices-input-2.pl6 @@ -0,0 +1,37 @@ +my $n = '11011'; + +say :2($n); # -> 27 +say :3($n); # -> 112 +say :4($n); # -> 325 +say :5($n); # -> 756 +say :6($n); # -> 1519 +say :7($n); # -> 2752 +say :8($n); # -> 4617 +say :9($n); # -> 7300 +say :10($n); # -> 11011 +say :11($n); # -> 15984 +say :12($n); # -> 22477 +say :13($n); # -> 30772 +say :14($n); # -> 41175 +say :15($n); # -> 54016 +say :16($n); # -> 69649 +say :17($n); # -> 88452 +say :18($n); # -> 110827 +say :19($n); # -> 137200 +say :20($n); # -> 168021 +say :21($n); # -> 203764 +say :22($n); # -> 244927 +say :23($n); # -> 292032 +say :24($n); # -> 345625 +say :25($n); # -> 406276 +say :26($n); # -> 474579 +say :27($n); # -> 551152 +say :28($n); # -> 636637 +say :29($n); # -> 731700 +say :30($n); # -> 837031 +say :31($n); # -> 953344 +say :32($n); # -> 1081377 +say :33($n); # -> 1221892 +say :34($n); # -> 1375675 +say :35($n); # -> 1543536 +say :36($n); # -> 1726309 diff --git a/Task/Non-decimal-radices-Input/Perl/non-decimal-radices-input.pl b/Task/Non-decimal-radices-Input/Perl/non-decimal-radices-input.pl new file mode 100644 index 0000000000..0338ef6973 --- /dev/null +++ b/Task/Non-decimal-radices-Input/Perl/non-decimal-radices-input.pl @@ -0,0 +1,15 @@ +my $dec = "0123459"; +my $hex_noprefix = "abcf123"; +my $hex_withprefix = "0xabcf123"; +my $oct_noprefix = "7651"; +my $oct_withprefix = "07651"; +my $bin_withprefix = "0b101011001"; + +print 0 + $dec, "\n"; # => 123459 +print hex($hex_noprefix), "\n"; # => 180154659 +print hex($hex_withprefix), "\n"; # => 180154659 +print oct($hex_withprefix), "\n"; # => 180154659 +print oct($oct_noprefix), "\n"; # => 4009 +print oct($oct_withprefix), "\n"; # => 4009 +print oct($bin_withprefix), "\n"; # => 345 +# nothing for binary without prefix diff --git a/Task/Non-decimal-radices-Input/PicoLisp/non-decimal-radices-input.l b/Task/Non-decimal-radices-Input/PicoLisp/non-decimal-radices-input.l new file mode 100644 index 0000000000..4e393572a6 --- /dev/null +++ b/Task/Non-decimal-radices-Input/PicoLisp/non-decimal-radices-input.l @@ -0,0 +1,9 @@ +(de parseNumber (S Base) + (let N 0 + (for C (chop S) + (when (> (setq C (- (char C) `(char "0"))) 9) + (dec 'C 39) ) + (setq N (+ C (* N Base))) ) + N ) ) + +(println (parseNumber "91g5dcg2h6da7260a9f3c4a" 19)) diff --git a/Task/Non-decimal-radices-Input/PureBasic/non-decimal-radices-input.purebasic b/Task/Non-decimal-radices-Input/PureBasic/non-decimal-radices-input.purebasic new file mode 100644 index 0000000000..d36b71a048 --- /dev/null +++ b/Task/Non-decimal-radices-Input/PureBasic/non-decimal-radices-input.purebasic @@ -0,0 +1,5 @@ + ;Val() parses integer strings + ; decimal numbers have no prefix, hexadecimal needs a prefix of '$', binary needs a prefix of '%' + Val("1024102410241024") ; => 1024102410241024 + Val("$10FFFFFFFF") ; => 73014444031 + Val("%1000") ; => 8 diff --git a/Task/Non-decimal-radices-Input/Python/non-decimal-radices-input.py b/Task/Non-decimal-radices-Input/Python/non-decimal-radices-input.py new file mode 100644 index 0000000000..ffe0944f86 --- /dev/null +++ b/Task/Non-decimal-radices-Input/Python/non-decimal-radices-input.py @@ -0,0 +1,25 @@ +>>> text = '100' +>>> for base in range(2,21): + print ("String '%s' in base %i is %i in base 10" + % (text, base, int(text, base))) + + +String '100' in base 2 is 4 in base 10 +String '100' in base 3 is 9 in base 10 +String '100' in base 4 is 16 in base 10 +String '100' in base 5 is 25 in base 10 +String '100' in base 6 is 36 in base 10 +String '100' in base 7 is 49 in base 10 +String '100' in base 8 is 64 in base 10 +String '100' in base 9 is 81 in base 10 +String '100' in base 10 is 100 in base 10 +String '100' in base 11 is 121 in base 10 +String '100' in base 12 is 144 in base 10 +String '100' in base 13 is 169 in base 10 +String '100' in base 14 is 196 in base 10 +String '100' in base 15 is 225 in base 10 +String '100' in base 16 is 256 in base 10 +String '100' in base 17 is 289 in base 10 +String '100' in base 18 is 324 in base 10 +String '100' in base 19 is 361 in base 10 +String '100' in base 20 is 400 in base 10 diff --git a/Task/Non-decimal-radices-Input/R/non-decimal-radices-input.r b/Task/Non-decimal-radices-Input/R/non-decimal-radices-input.r new file mode 100644 index 0000000000..fbfd98983c --- /dev/null +++ b/Task/Non-decimal-radices-Input/R/non-decimal-radices-input.r @@ -0,0 +1,8 @@ +# parse a string to decimal +as.numeric("20") # 20 +# parse a hex-string to decimal +as.numeric("0x20") # 32 +# parse a string to hexadecimal +as.hexmode(as.numeric("32")) # "20" +# parse a string to octal +as.octmode(as.numeric("20")) # "24" diff --git a/Task/Non-decimal-radices-Input/REXX/non-decimal-radices-input.rexx b/Task/Non-decimal-radices-Input/REXX/non-decimal-radices-input.rexx new file mode 100644 index 0000000000..ce537a4d74 --- /dev/null +++ b/Task/Non-decimal-radices-Input/REXX/non-decimal-radices-input.rexx @@ -0,0 +1,85 @@ +/*REXX program demonstrates REXX's ability to handle non-decimal radices*/ +/*┌────────────────────────────────────────────────────────────────────┐ +┌─┘ In REXX, there are no numeric-type variables (integer, float, real,└─┐ +│ logical, complex, double, etc), only character. Everything is stored │ +│ as a character string. Arithmetic is done almost exactly the way a │ +│ schoolchild would perform it. To add, align the two numbers up (right │ +│ justified, with the decimal being the pivot) and simply add the columns│ +│ up, noting carries and the signs. Multiplication and division are │ +└─┐ simarily performed. ┌─┘ + └────────────────────────────────────────────────────────────────────┘*/ +a=123 /*all of these assignments are identical: */ +b='123' /*there is no difference in the assignments*/ +c='1' || "2" || '3' +d= 1 || 2 || 3 +e= 12 || 3 +f=120 + 3 +g=substr(9912388,3,2) +h=left(123456,3) +i=right(777.123,3) +j=12 + ' 3 ' +k=0000000123.0000/1 /*divison "normalizes the number (───► 123)*/ + + /*parsing then, of a decimal number is no */ + /*different then parsing a character string*/ + /*because decimal numbers ARE character */ + /*strings. As such, numbers may have */ + /*leading and/or trailing blanks, and in */ + /*some cases, imbedded blanks (after any */ + /*leading sign). */ + +aa=' 123 ' /*AA's exact value is different the A, */ + /*but it's numerically equal to A. */ +bb=123. /*the same can be said for the rest of 'em.*/ +cc=+123 +dd=' + 123' +ee=0000123 +ff=1.23e+1 +gg=001.23E0002 +hh=1230e-1 +ii=122.999999999999999999999999999999999 /*assuming NUMERIC DIGITS 9 */ +jj= +++123 +kk= - -123 + +bingoA='10101'b /*stores a binary value. */ +bingoB='10101'B /* B can be uppercase. */ +bingoC='1 0101'b /*apostrophes may be used*/ +bingoD="1 0101"b /*quotes may be used. */ + +hyoidA='deadbeaf'x /*stores a hexadecimal value.*/ +hyoidB="deadbeaf"X +hyoidC='dead beaf'X +hyoidD='de ad be af'X +hyoidE='dead be af'X +hyoidF='7abc'x + /*REXX has several built-in functions */ + /*(BIFs) to handle conversions of the */ + /*above-mentioned "number" formats. */ + +cyanA=d2x(a) /*converts a decimal string to hexadecimal*/ +cyanB=d2x(5612) /*converts a decimal string to hexadecimal*/ + +cyanD=b2x(101101) /*converts a binary string to hexadecimal*/ + +cyanE=b2c(101101) /*some REXXes support this, others don't. */ +cyanF=c2b('copernicium') /*some REXXes support this, others don't. */ + +cyanG=c2d('nilla') /*converts a character string to decimal. */ +cyanH=d2c(251) /*converts a decimal number to character. */ + +cyanI=x2d(fab) /*converts a hexadcimal string to decinal.*/ +cyanJ=x2c(fab) /*converts a hexadcimal string to chars. */ +cyanK=x2b(fab) /*converts a hexadcimal string to binary. */ + +befog=d2b(144) /*there's no dec──►binary, but see below.*/ +unfog=b2d(101) /*there's no bin──►decimal, but see below.*/ + + do j=0 to 27 /*show some simple low-value conversions. */ + say right(j,2) 'in decimal is' d2b(j) "in binary and" d2x(j) 'in hex.' + end /*j*/ +exit /*stick a fork in it, we're done.*/ +/*────────────────────────────add these subroutines to end─of─program. */ +d2b: return word(strip(x2b(d2x(arg(1))),'L',0) 0,1) /*convert dec──►bin*/ +b2d: return x2d(b2x(arg(1))) /*convert bin──►dec*/ +b2c: return x2c(b2x(arg(1))) /*convert bin──►chr*/ +c2b: return word(strip(x2b(c2x(arg(1))),'L',0) 0,1) /*convert chr──►bin*/ diff --git a/Task/Non-decimal-radices-Input/Ruby/non-decimal-radices-input-1.rb b/Task/Non-decimal-radices-Input/Ruby/non-decimal-radices-input-1.rb new file mode 100644 index 0000000000..938cd0035b --- /dev/null +++ b/Task/Non-decimal-radices-Input/Ruby/non-decimal-radices-input-1.rb @@ -0,0 +1,9 @@ +dec1 = "0123459" +hex2 = "abcf123" +oct3 = "7651" +bin4 = "101011001" + +dec1.to_i # => 123459 +hex2.hex # => 180154659 +oct3.oct # => 4009 +# nothing for binary diff --git a/Task/Non-decimal-radices-Input/Ruby/non-decimal-radices-input-2.rb b/Task/Non-decimal-radices-Input/Ruby/non-decimal-radices-input-2.rb new file mode 100644 index 0000000000..642bb49f96 --- /dev/null +++ b/Task/Non-decimal-radices-Input/Ruby/non-decimal-radices-input-2.rb @@ -0,0 +1,5 @@ +Integer(dec1) # => ArgumentError: invalid value for Integer: "0123459" +Integer(dec1.sub(/^0+/,"")) # => 123459 +Integer("0x" + hex2) # => 180154659 +Integer("0" + oct3) # => 4009 +Integer("0b" + bin4) # => 345 diff --git a/Task/Non-decimal-radices-Input/Ruby/non-decimal-radices-input-3.rb b/Task/Non-decimal-radices-Input/Ruby/non-decimal-radices-input-3.rb new file mode 100644 index 0000000000..a6cddf7a50 --- /dev/null +++ b/Task/Non-decimal-radices-Input/Ruby/non-decimal-radices-input-3.rb @@ -0,0 +1,5 @@ +dec1.to_i(0) # => 5349 (which is 12345 in octal, the 9 is discarded) +dec1.sub(/^0+/,"").to_i(0) # => 123459 +("0x" + hex2).to_i(0) # => 180154659 +("0" + oct3).to_i(0) # => 4009 +("0b" + bin4).to_i(0) # => 345 diff --git a/Task/Non-decimal-radices-Input/Ruby/non-decimal-radices-input-4.rb b/Task/Non-decimal-radices-Input/Ruby/non-decimal-radices-input-4.rb new file mode 100644 index 0000000000..068b95c8f0 --- /dev/null +++ b/Task/Non-decimal-radices-Input/Ruby/non-decimal-radices-input-4.rb @@ -0,0 +1,5 @@ +require 'scanf' +dec1.scanf("%d") # => [123459] +hex2.scanf("%x") # => [180154659] +oct3.scanf("%o") # => [4009] +# no scanf specifier for binary numbers. diff --git a/Task/Non-decimal-radices-Input/Scheme/non-decimal-radices-input.ss b/Task/Non-decimal-radices-Input/Scheme/non-decimal-radices-input.ss new file mode 100644 index 0000000000..315c3cd666 --- /dev/null +++ b/Task/Non-decimal-radices-Input/Scheme/non-decimal-radices-input.ss @@ -0,0 +1,8 @@ +> (string->number "abcf123" 16) ; hex +180154659 +> (string->number "123459" 10) ; decimal, the "10" is optional +123459 +> (string->number "7651" 8) ; octal +4009 +> (string->number "101011001" 2) ; binary +345 diff --git a/Task/Non-decimal-radices-Input/Standard-ML/non-decimal-radices-input.ml b/Task/Non-decimal-radices-Input/Standard-ML/non-decimal-radices-input.ml new file mode 100644 index 0000000000..440854037a --- /dev/null +++ b/Task/Non-decimal-radices-Input/Standard-ML/non-decimal-radices-input.ml @@ -0,0 +1,10 @@ +- Int.fromString "0123459"; +val it = SOME 123459 : int option +- StringCvt.scanString (Int.scan StringCvt.HEX) "0xabcf123"; +val it = SOME 180154659 : int option +- StringCvt.scanString (Int.scan StringCvt.HEX) "abcf123"; +val it = SOME 180154659 : int option +- StringCvt.scanString (Int.scan StringCvt.OCT) "7651"; +val it = SOME 4009 : int option +- StringCvt.scanString (Int.scan StringCvt.BIN) "101011001"; +val it = SOME 345 : int option diff --git a/Task/Non-decimal-radices-Input/Tcl/non-decimal-radices-input-1.tcl b/Task/Non-decimal-radices-Input/Tcl/non-decimal-radices-input-1.tcl new file mode 100644 index 0000000000..f2a11ec1c8 --- /dev/null +++ b/Task/Non-decimal-radices-Input/Tcl/non-decimal-radices-input-1.tcl @@ -0,0 +1,16 @@ +package require Tcl 8.6; # For easy scanning of binary + +# The strings to parse +set dec1 "0123459" +set hex2 "abcf123" +set oct3 "7651" +set bin4 "101011001" + +# Parse the numbers +scan $dec1 "%d" v1 +scan $hex2 "%x" v2 +scan $oct3 "%o" v3 +scan $bin4 "%b" v4; # Only 8.6-specific operation; others work in all versions + +# Print out what happened +puts "$dec1->$v1 $hex2->$v2 $oct3->$v3 $bin4->$v4" diff --git a/Task/Non-decimal-radices-Input/Tcl/non-decimal-radices-input-2.tcl b/Task/Non-decimal-radices-Input/Tcl/non-decimal-radices-input-2.tcl new file mode 100644 index 0000000000..e80dffdb67 --- /dev/null +++ b/Task/Non-decimal-radices-Input/Tcl/non-decimal-radices-input-2.tcl @@ -0,0 +1,10 @@ +proc scanbase {str base} { + set res 0 + set digits {0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z} + foreach char [split [string tolower $str] ""] { + set value [lsearch [lrange $digits 0 [expr {$base - 1}]] $char] + if {$value < 0} {error "bad digit $char"} + set res [expr {$res*$base + $value}] + } + return $res +} diff --git a/Task/Non-decimal-radices-Input/XPL0/non-decimal-radices-input.xpl0 b/Task/Non-decimal-radices-Input/XPL0/non-decimal-radices-input.xpl0 new file mode 100644 index 0000000000..53beb66f17 --- /dev/null +++ b/Task/Non-decimal-radices-Input/XPL0/non-decimal-radices-input.xpl0 @@ -0,0 +1,12 @@ +include c:\cxpl\codes; +int N; real R; +[Text(8, "123_456"); +N:= IntIn(8); +IntOut(0, N); CrLf(0); +Text(8, "ABcd12"); +N:= HexIn(8); +HexOut(0, N); CrLf(0); +Text(8, "-3.14159e3"); +R:= RlIn(8); +RlOut(0, R); CrLf(0); +] diff --git a/Task/Non-decimal-radices-Output/0DESCRIPTION b/Task/Non-decimal-radices-Output/0DESCRIPTION new file mode 100644 index 0000000000..7be9e4200e --- /dev/null +++ b/Task/Non-decimal-radices-Output/0DESCRIPTION @@ -0,0 +1,5 @@ +Programming languages often have built-in routines to convert a non-negative integer for printing in different number bases. Such common number bases might include binary, [[Octal]] and [[Hexadecimal]]. + +Show how to print a small range of integers in some different bases, as supported by standard routines of your programming language. (Note: this is distinct from [[Number base conversion]] as a user-defined conversion function is '''not''' asked for.) + +The reverse operation is [[Common number base parsing]]. diff --git a/Task/Non-decimal-radices-Output/1META.yaml b/Task/Non-decimal-radices-Output/1META.yaml new file mode 100644 index 0000000000..8644b2ad9b --- /dev/null +++ b/Task/Non-decimal-radices-Output/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Arithmetic operations diff --git a/Task/Non-decimal-radices-Output/ALGOL-68/non-decimal-radices-output.alg b/Task/Non-decimal-radices-Output/ALGOL-68/non-decimal-radices-output.alg new file mode 100644 index 0000000000..47b30b57d8 --- /dev/null +++ b/Task/Non-decimal-radices-Output/ALGOL-68/non-decimal-radices-output.alg @@ -0,0 +1,5 @@ +main:( + FOR i TO 33 DO + printf(($10r6d," "16r6d," "8r6dl$, BIN i, BIN i, BIN i)) + OD +) diff --git a/Task/Non-decimal-radices-Output/AWK/non-decimal-radices-output.awk b/Task/Non-decimal-radices-Output/AWK/non-decimal-radices-output.awk new file mode 100644 index 0000000000..283d1403ab --- /dev/null +++ b/Task/Non-decimal-radices-Output/AWK/non-decimal-radices-output.awk @@ -0,0 +1,7 @@ +$ awk '{printf("%d 0%o 0x%x\n",$1,$1,$1)}' +10 +10 012 0xa +16 +16 020 0x10 +255 +255 0377 0xff diff --git a/Task/Non-decimal-radices-Output/Ada/non-decimal-radices-output.ada b/Task/Non-decimal-radices-Output/Ada/non-decimal-radices-output.ada new file mode 100644 index 0000000000..2c3f00419d --- /dev/null +++ b/Task/Non-decimal-radices-Output/Ada/non-decimal-radices-output.ada @@ -0,0 +1,12 @@ +with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; +with Ada.Text_IO; use Ada.Text_IO; + +procedure Test_Integer_Text_IO is +begin + for I in 1..33 loop + Put (I, Width =>3, Base=> 10); + Put (I, Width =>7, Base=> 16); + Put (I, Width =>6, Base=> 8); + New_Line; + end loop; +end Test_Integer_Text_IO; diff --git a/Task/Non-decimal-radices-Output/AutoHotkey/non-decimal-radices-output.ahk b/Task/Non-decimal-radices-Output/AutoHotkey/non-decimal-radices-output.ahk new file mode 100644 index 0000000000..99d52027dd --- /dev/null +++ b/Task/Non-decimal-radices-Output/AutoHotkey/non-decimal-radices-output.ahk @@ -0,0 +1,7 @@ +MsgBox % BC("FF",16,3) ; -> 100110 in base 3 = FF in hex = 256 in base 10 + +BC(NumStr,InputBase=8,OutputBase=10) { + Static S = 12345678901234567890123456789012345678901234567890123456789012345 + DllCall("msvcrt\_i64toa","Int64",DllCall("msvcrt\_strtoui64","Str",NumStr,"Uint",0,"UInt",InputBase,"CDECLInt64"),"Str",S,"UInt",OutputBase,"CDECL") + Return S +} diff --git a/Task/Non-decimal-radices-Output/BBC-BASIC/non-decimal-radices-output.bbc b/Task/Non-decimal-radices-Output/BBC-BASIC/non-decimal-radices-output.bbc new file mode 100644 index 0000000000..19dc7efb71 --- /dev/null +++ b/Task/Non-decimal-radices-Output/BBC-BASIC/non-decimal-radices-output.bbc @@ -0,0 +1,8 @@ + REM STR$ converts to a decimal string: + PRINT STR$(0) + PRINT STR$(123456789) + PRINT STR$(-987654321) + + REM STR$~ converts to a hexadecimal string: + PRINT STR$~(43981) + PRINT STR$~(-1) diff --git a/Task/Non-decimal-radices-Output/C++/non-decimal-radices-output.cpp b/Task/Non-decimal-radices-Output/C++/non-decimal-radices-output.cpp new file mode 100644 index 0000000000..db305d0453 --- /dev/null +++ b/Task/Non-decimal-radices-Output/C++/non-decimal-radices-output.cpp @@ -0,0 +1,12 @@ +#include +#include + +int main() +{ + for (int i = 0; i <= 33; i++) + std::cout << std::setw(6) << std::dec << i << " " + << std::setw(6) << std::hex << i << " " + << std::setw(6) << std::oct << i << std::endl; + + return 0; +} diff --git a/Task/Non-decimal-radices-Output/C/non-decimal-radices-output.c b/Task/Non-decimal-radices-Output/C/non-decimal-radices-output.c new file mode 100644 index 0000000000..90a8eb3487 --- /dev/null +++ b/Task/Non-decimal-radices-Output/C/non-decimal-radices-output.c @@ -0,0 +1,11 @@ +#include + +int main() +{ + int i; + + for(i=1; i <= 33; i++) + printf("%6d %6x %6o\n", i, i, i); + + return 0; +} diff --git a/Task/Non-decimal-radices-Output/Clojure/non-decimal-radices-output.clj b/Task/Non-decimal-radices-Output/Clojure/non-decimal-radices-output.clj new file mode 100644 index 0000000000..df6e65bd03 --- /dev/null +++ b/Task/Non-decimal-radices-Output/Clojure/non-decimal-radices-output.clj @@ -0,0 +1,6 @@ +(Integer/toBinaryString 25) ; returns "11001" +(Integer/toOctalString 25) ; returns "31" +(Integer/toHexString 25) ; returns "19" + +(dotimes [i 20] + (println (Integer/toHexString i))) diff --git a/Task/Non-decimal-radices-Output/Common-Lisp/non-decimal-radices-output.lisp b/Task/Non-decimal-radices-Output/Common-Lisp/non-decimal-radices-output.lisp new file mode 100644 index 0000000000..42b59aedf5 --- /dev/null +++ b/Task/Non-decimal-radices-Output/Common-Lisp/non-decimal-radices-output.lisp @@ -0,0 +1,2 @@ +(loop for n from 0 to 33 do + (format t " ~6B ~3O ~2D ~2X~%" n n n n)) diff --git a/Task/Non-decimal-radices-Output/D/non-decimal-radices-output-1.d b/Task/Non-decimal-radices-Output/D/non-decimal-radices-output-1.d new file mode 100644 index 0000000000..220d9fff72 --- /dev/null +++ b/Task/Non-decimal-radices-Output/D/non-decimal-radices-output-1.d @@ -0,0 +1,8 @@ +import std.stdio; + +void main() { + writeln("Base: 2 8 10 16"); + writeln("----------------------------"); + foreach (i; 0 .. 34) + writefln(" %6b %6o %6d %6x", i, i, i, i); +} diff --git a/Task/Non-decimal-radices-Output/D/non-decimal-radices-output-2.d b/Task/Non-decimal-radices-Output/D/non-decimal-radices-output-2.d new file mode 100644 index 0000000000..d1cdbe0dc8 --- /dev/null +++ b/Task/Non-decimal-radices-Output/D/non-decimal-radices-output-2.d @@ -0,0 +1,2 @@ +for (int i = 0; i < 35; i++) + Stdout.formatln ("{:b8} {:o3} {} {:x2}", i, i, i, i); diff --git a/Task/Non-decimal-radices-Output/E/non-decimal-radices-output.e b/Task/Non-decimal-radices-Output/E/non-decimal-radices-output.e new file mode 100644 index 0000000000..0206d1834d --- /dev/null +++ b/Task/Non-decimal-radices-Output/E/non-decimal-radices-output.e @@ -0,0 +1,7 @@ +for value in 0..33 { + for base in [2, 8, 10, 12, 16, 36] { + def s := value.toString(base) + print(" " * (8 - s.size()), s) + } + println() +} diff --git a/Task/Non-decimal-radices-Output/Euphoria/non-decimal-radices-output.euphoria b/Task/Non-decimal-radices-Output/Euphoria/non-decimal-radices-output.euphoria new file mode 100644 index 0000000000..a5eb9d8f8d --- /dev/null +++ b/Task/Non-decimal-radices-Output/Euphoria/non-decimal-radices-output.euphoria @@ -0,0 +1,3 @@ +for i = 1 to 33 do + printf(1,"%6d %6x %6o\n",{i,i,i}) +end for diff --git a/Task/Non-decimal-radices-Output/Factor/non-decimal-radices-output.factor b/Task/Non-decimal-radices-Output/Factor/non-decimal-radices-output.factor new file mode 100644 index 0000000000..96a762c272 --- /dev/null +++ b/Task/Non-decimal-radices-Output/Factor/non-decimal-radices-output.factor @@ -0,0 +1 @@ +1234567 2 36 [a,b] [ >base print ] with each diff --git a/Task/Non-decimal-radices-Output/Forth/non-decimal-radices-output-1.fth b/Task/Non-decimal-radices-Output/Forth/non-decimal-radices-output-1.fth new file mode 100644 index 0000000000..ba870fb26e --- /dev/null +++ b/Task/Non-decimal-radices-Output/Forth/non-decimal-radices-output-1.fth @@ -0,0 +1,5 @@ +: main 34 1 do cr i dec. i hex. loop ; +main +... +11 $B +... diff --git a/Task/Non-decimal-radices-Output/Forth/non-decimal-radices-output-2.fth b/Task/Non-decimal-radices-Output/Forth/non-decimal-radices-output-2.fth new file mode 100644 index 0000000000..8d1d7f5772 --- /dev/null +++ b/Task/Non-decimal-radices-Output/Forth/non-decimal-radices-output-2.fth @@ -0,0 +1,3 @@ +: base. ( n base -- ) base @ >r base ! . r> base ! ; +: oct. ( n -- ) 8 base. ; +: bin. ( n -- ) 2 base. ; diff --git a/Task/Non-decimal-radices-Output/Fortran/non-decimal-radices-output.f b/Task/Non-decimal-radices-Output/Fortran/non-decimal-radices-output.f new file mode 100644 index 0000000000..a7199afa47 --- /dev/null +++ b/Task/Non-decimal-radices-Output/Fortran/non-decimal-radices-output.f @@ -0,0 +1,3 @@ +do n = 1, 33 + write(*, "(b6, o4, i4, z4)") n, n, n, n +end do diff --git a/Task/Non-decimal-radices-Output/Gema/non-decimal-radices-output.gema b/Task/Non-decimal-radices-Output/Gema/non-decimal-radices-output.gema new file mode 100644 index 0000000000..e6b6ac951d --- /dev/null +++ b/Task/Non-decimal-radices-Output/Gema/non-decimal-radices-output.gema @@ -0,0 +1,3 @@ +0x
=$0 (@radix{16;10;$1}, 0@radix{16;8;$1}) +0=$0 (@radix{8;10;$1}, 0x@radix{8;16;$1}) +=$0 (0x@radix{10;16;$1}, 0@radix{10;8;$1}) diff --git a/Task/Non-decimal-radices-Output/Go/non-decimal-radices-output.go b/Task/Non-decimal-radices-Output/Go/non-decimal-radices-output.go new file mode 100644 index 0000000000..380f6b42ba --- /dev/null +++ b/Task/Non-decimal-radices-Output/Go/non-decimal-radices-output.go @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "math/big" + "strconv" +) + +func main() { + // package strconv: + // Itoa is the most common int to string conversion. it is base 10 only. + x := strconv.Itoa(13) + fmt.Printf("%q\n", x) + + // FormatInt handles arbitrary bases from 2 to 36. + x = strconv.FormatInt(1313, 19) + fmt.Printf("%q\n", x) + + // package fmt: allows direct conversion from integer + // to string types for bases 2, 8, 10, and 16. + fmt.Printf("%b\n", 13) + fmt.Printf("%o\n", 13) + fmt.Printf("%d\n", 13) + fmt.Printf("%x\n", 13) + + // package big: string conversion is base 10 only. + fmt.Println(big.NewInt(13)) +} diff --git a/Task/Non-decimal-radices-Output/Haskell/non-decimal-radices-output-1.hs b/Task/Non-decimal-radices-Output/Haskell/non-decimal-radices-output-1.hs new file mode 100644 index 0000000000..616f23ae7e --- /dev/null +++ b/Task/Non-decimal-radices-Output/Haskell/non-decimal-radices-output-1.hs @@ -0,0 +1,6 @@ +import Text.Printf + +main :: IO () +main = mapM_ f [0..33] where + f :: Int -> IO () + f n = printf " %3o %2d %2X\n" n n n -- binary not supported diff --git a/Task/Non-decimal-radices-Output/Haskell/non-decimal-radices-output-2.hs b/Task/Non-decimal-radices-Output/Haskell/non-decimal-radices-output-2.hs new file mode 100644 index 0000000000..e198f08488 --- /dev/null +++ b/Task/Non-decimal-radices-Output/Haskell/non-decimal-radices-output-2.hs @@ -0,0 +1,6 @@ +import Numeric + +main :: IO () +main = mapM_ f [0..33] where + f :: Int -> IO () + f n = putStrLn $ " " ++ showOct n "" ++ " " ++ show n ++ " " ++ showHex n "" diff --git a/Task/Non-decimal-radices-Output/HicEst/non-decimal-radices-output.hicest b/Task/Non-decimal-radices-Output/HicEst/non-decimal-radices-output.hicest new file mode 100644 index 0000000000..e6ec7158ab --- /dev/null +++ b/Task/Non-decimal-radices-Output/HicEst/non-decimal-radices-output.hicest @@ -0,0 +1,3 @@ +DO n = 1, 33 + WRITE(Format="b6.0, o4.0, i4.0, z4.0") n, n, n, n +ENDDO diff --git a/Task/Non-decimal-radices-Output/Icon/non-decimal-radices-output.icon b/Task/Non-decimal-radices-Output/Icon/non-decimal-radices-output.icon new file mode 100644 index 0000000000..88a1e91302 --- /dev/null +++ b/Task/Non-decimal-radices-Output/Icon/non-decimal-radices-output.icon @@ -0,0 +1,10 @@ +rocedure main() +write("Non-decimal radices/Output") +every i := 255 | 2 | 5 | 16 do { + printf("%%d = %d\n",i) # integer format + printf("%%x = %x\n",i) # hex format + printf("%%o = %o\n",i) # octal format + printf("%%s = %s\n",i) # string format + printf("%%i = %i\n",i) # image format + } +end diff --git a/Task/Non-decimal-radices-Output/J/non-decimal-radices-output-1.j b/Task/Non-decimal-radices-Output/J/non-decimal-radices-output-1.j new file mode 100644 index 0000000000..80789334ab --- /dev/null +++ b/Task/Non-decimal-radices-Output/J/non-decimal-radices-output-1.j @@ -0,0 +1,6 @@ + 2 #.inv 12 +1 1 0 0 + 3 #.inv 100 +1 0 2 0 1 + 16 #.inv 180097588 +10 11 12 1 2 3 4 diff --git a/Task/Non-decimal-radices-Output/J/non-decimal-radices-output-2.j b/Task/Non-decimal-radices-Output/J/non-decimal-radices-output-2.j new file mode 100644 index 0000000000..f3f3394915 --- /dev/null +++ b/Task/Non-decimal-radices-Output/J/non-decimal-radices-output-2.j @@ -0,0 +1,4 @@ + 8 #.inv 4009 +7 6 5 1 + -.&' '": 8 #.inv 4009 +7651 diff --git a/Task/Non-decimal-radices-Output/J/non-decimal-radices-output-3.j b/Task/Non-decimal-radices-Output/J/non-decimal-radices-output-3.j new file mode 100644 index 0000000000..8ed13b9a7f --- /dev/null +++ b/Task/Non-decimal-radices-Output/J/non-decimal-radices-output-3.j @@ -0,0 +1,3 @@ + require 'convert' + hfd 180097588 +ABC1234 diff --git a/Task/Non-decimal-radices-Output/Java/non-decimal-radices-output.java b/Task/Non-decimal-radices-Output/Java/non-decimal-radices-output.java new file mode 100644 index 0000000000..29f2b1de57 --- /dev/null +++ b/Task/Non-decimal-radices-Output/Java/non-decimal-radices-output.java @@ -0,0 +1,11 @@ +public static void main(String args[]){ + for(int a= 0;a < 33;a++){ + System.out.println(Integer.toBinaryString(a)); + System.out.println(Integer.toOctalString(a)); + System.out.println(Integer.toHexString(a)); + //the above methods treat the integer as unsigned + //there are also corresponding Long.to***String() methods for long's. + + System.out.printf("%3o %2d %2x\n",a ,a ,a); //printf like the other languages; binary not supported + } +} diff --git a/Task/Non-decimal-radices-Output/JavaScript/non-decimal-radices-output.js b/Task/Non-decimal-radices-Output/JavaScript/non-decimal-radices-output.js new file mode 100644 index 0000000000..1ca3fe9d58 --- /dev/null +++ b/Task/Non-decimal-radices-Output/JavaScript/non-decimal-radices-output.js @@ -0,0 +1,7 @@ +var bases = [2, 8, 10, 16, 24]; +for (var n = 0; n <= 33; n++) { + var row = []; + for (var i = 0; i < bases.length; i++) + row.push( n.toString(bases[i]) ); + print(row.join(', ')); +} diff --git a/Task/Non-decimal-radices-Output/Locomotive-Basic/non-decimal-radices-output.locomotive b/Task/Non-decimal-radices-Output/Locomotive-Basic/non-decimal-radices-output.locomotive new file mode 100644 index 0000000000..d6047ee109 --- /dev/null +++ b/Task/Non-decimal-radices-Output/Locomotive-Basic/non-decimal-radices-output.locomotive @@ -0,0 +1,3 @@ +10 FOR i=1 TO 20 +20 PRINT i,BIN$(i),HEX$(i) +30 NEXT diff --git a/Task/Non-decimal-radices-Output/Lua/non-decimal-radices-output.lua b/Task/Non-decimal-radices-Output/Lua/non-decimal-radices-output.lua new file mode 100644 index 0000000000..d8654f6e8b --- /dev/null +++ b/Task/Non-decimal-radices-Output/Lua/non-decimal-radices-output.lua @@ -0,0 +1,3 @@ +for i = 1, 33 do + print( string.format( "%o \t %d \t %x", i, i, i ) ) +end diff --git a/Task/Non-decimal-radices-Output/Mathematica/non-decimal-radices-output.math b/Task/Non-decimal-radices-Output/Mathematica/non-decimal-radices-output.math new file mode 100644 index 0000000000..6dc95af130 --- /dev/null +++ b/Task/Non-decimal-radices-Output/Mathematica/non-decimal-radices-output.math @@ -0,0 +1,2 @@ +Scan[Print[IntegerString[#, 2], ",", IntegerString[#, 8], +",",#, ",",IntegerString[#, 16],",", IntegerString[#, 36]]&, Range[38]] diff --git a/Task/Non-decimal-radices-Output/Modula-3/non-decimal-radices-output.mod3 b/Task/Non-decimal-radices-Output/Modula-3/non-decimal-radices-output.mod3 new file mode 100644 index 0000000000..d2b2e23e57 --- /dev/null +++ b/Task/Non-decimal-radices-Output/Modula-3/non-decimal-radices-output.mod3 @@ -0,0 +1,12 @@ +MODULE Conv EXPORTS Main; + +IMPORT IO, Fmt; + +BEGIN + FOR i := 1 TO 33 DO + IO.Put(Fmt.Int(i, base := 10) & " "); + IO.Put(Fmt.Int(i, base := 16) & " "); + IO.Put(Fmt.Int(i, base := 8) & " "); + IO.Put("\n"); + END; +END Conv. diff --git a/Task/Non-decimal-radices-Output/NetRexx/non-decimal-radices-output.netrexx b/Task/Non-decimal-radices-Output/NetRexx/non-decimal-radices-output.netrexx new file mode 100644 index 0000000000..f89ffb6034 --- /dev/null +++ b/Task/Non-decimal-radices-Output/NetRexx/non-decimal-radices-output.netrexx @@ -0,0 +1,38 @@ +/* NetRexx */ +options replace format comments java crossref symbols nobinary + +import java.util.Formatter + +loop i_ = 1 to 3 + loop n_ = 20 to 20000 by 2131 + select case i_ + when 1 then say useBif(n_) + when 2 then say useJavaFormat(n_) + when 3 then say useJavaNumber(n_) + otherwise nop + end + end n_ + say +end i_ + +return + +-- NetRexx doesn't have a decimal to octal conversion +method useBif(n_) public static + d_ = '_' + return '[Base 16='n_.d2x().right(8)',Base 10='n_.right(8)',Base 8='d_.right(8)',Base 2='n_.d2x().x2b().right(20)']' + +-- Some of Java's java.lang.Number classes have conversion methods +method useJavaNumber(n_) public static + nx = Long.toHexString(n_) + nd = Long.toString(n_) + no = Long.toOctalString(n_) + nb = Long.toBinaryString(n_) + return '[Base 16='Rexx(nx).right(8)',Base 10='Rexx(nd).right(8)',Base 8='Rexx(no).right(8)',Base 2='Rexx(nb).right(20)']' + +-- Java Formatter doesn't have a decimal to binary conversion +method useJavaFormat(n_) public static + fb = StringBuilder() + fm = Formatter(fb) + fm.format("[Base 16=%1$8x,Base 10=%1$8d,Base 8=%1$8o,Base 2=%2$20s]", [Object Long(n_), String('_')]) + return fb.toString() diff --git a/Task/Non-decimal-radices-Output/OCaml/non-decimal-radices-output.ocaml b/Task/Non-decimal-radices-Output/OCaml/non-decimal-radices-output.ocaml new file mode 100644 index 0000000000..92ee113ed7 --- /dev/null +++ b/Task/Non-decimal-radices-Output/OCaml/non-decimal-radices-output.ocaml @@ -0,0 +1,3 @@ +for n = 0 to 33 do + Printf.printf " %3o %2d %2X\n" n n n (* binary not supported *) +done diff --git a/Task/Non-decimal-radices-Output/PARI-GP/non-decimal-radices-output.pari b/Task/Non-decimal-radices-Output/PARI-GP/non-decimal-radices-output.pari new file mode 100644 index 0000000000..66cf553f33 --- /dev/null +++ b/Task/Non-decimal-radices-Output/PARI-GP/non-decimal-radices-output.pari @@ -0,0 +1,7 @@ +printbinary(n)={ + n=binary(n); + for(i=1,#n,print1(n[i])) +}; +printdecimal(n)={ + print1(n) +}; diff --git a/Task/Non-decimal-radices-Output/PHP/non-decimal-radices-output-1.php b/Task/Non-decimal-radices-Output/PHP/non-decimal-radices-output-1.php new file mode 100644 index 0000000000..d0808988bf --- /dev/null +++ b/Task/Non-decimal-radices-Output/PHP/non-decimal-radices-output-1.php @@ -0,0 +1,5 @@ + diff --git a/Task/Non-decimal-radices-Output/PHP/non-decimal-radices-output-2.php b/Task/Non-decimal-radices-Output/PHP/non-decimal-radices-output-2.php new file mode 100644 index 0000000000..40d8897c2e --- /dev/null +++ b/Task/Non-decimal-radices-Output/PHP/non-decimal-radices-output-2.php @@ -0,0 +1,5 @@ + diff --git a/Task/Non-decimal-radices-Output/PL-I/non-decimal-radices-output.pli b/Task/Non-decimal-radices-Output/PL-I/non-decimal-radices-output.pli new file mode 100644 index 0000000000..0ef352452f --- /dev/null +++ b/Task/Non-decimal-radices-Output/PL-I/non-decimal-radices-output.pli @@ -0,0 +1,3 @@ +get list (n); +put skip list (n); /* Prints N in decimal */ +put skip edit (n) (B); /* prints N as a bit string, N > 0 */ diff --git a/Task/Non-decimal-radices-Output/Perl-6/non-decimal-radices-output.pl6 b/Task/Non-decimal-radices-Output/Perl-6/non-decimal-radices-output.pl6 new file mode 100644 index 0000000000..3c70fd8975 --- /dev/null +++ b/Task/Non-decimal-radices-Output/Perl-6/non-decimal-radices-output.pl6 @@ -0,0 +1,3 @@ +for 0..33 -> $n { + printf " %6b %3o %2d %2X\n", $n xx 4; +} diff --git a/Task/Non-decimal-radices-Output/Perl/non-decimal-radices-output.pl b/Task/Non-decimal-radices-Output/Perl/non-decimal-radices-output.pl new file mode 100644 index 0000000000..0236362580 --- /dev/null +++ b/Task/Non-decimal-radices-Output/Perl/non-decimal-radices-output.pl @@ -0,0 +1,3 @@ +foreach my $n (0..33) { + printf " %6b %3o %2d %2X\n", $n, $n, $n, $n; +} diff --git a/Task/Non-decimal-radices-Output/PicoLisp/non-decimal-radices-output.l b/Task/Non-decimal-radices-Output/PicoLisp/non-decimal-radices-output.l new file mode 100644 index 0000000000..55b18a3067 --- /dev/null +++ b/Task/Non-decimal-radices-Output/PicoLisp/non-decimal-radices-output.l @@ -0,0 +1,11 @@ +(de printNumber (N Base) + (when (>= N Base) + (printNumber (/ N Base) Base) ) + (let C (% N Base) + (and (> C 9) (inc 'C 39)) + (prin (char (+ C `(char "0")))) ) ) + +(printNumber 26 16)) +(prinl) +(printNumber 123456789012345678901234567890 36)) +(prinl) diff --git a/Task/Non-decimal-radices-Output/PowerShell/non-decimal-radices-output.psh b/Task/Non-decimal-radices-Output/PowerShell/non-decimal-radices-output.psh new file mode 100644 index 0000000000..4784f6db54 --- /dev/null +++ b/Task/Non-decimal-radices-Output/PowerShell/non-decimal-radices-output.psh @@ -0,0 +1,9 @@ +foreach ($n in 0..33) { + "Base 2: " + [Convert]::ToString($n, 2) + "Base 8: " + [Convert]::ToString($n, 8) + "Base 10: " + $n + "Base 10: " + [Convert]::ToString($n, 10) + "Base 10: " + ("{0:D}" -f $n) + "Base 16: " + [Convert]::ToString($n, 16) + "Base 16: " + ("{0:X}" -f $n) +} diff --git a/Task/Non-decimal-radices-Output/PureBasic/non-decimal-radices-output.purebasic b/Task/Non-decimal-radices-Output/PureBasic/non-decimal-radices-output.purebasic new file mode 100644 index 0000000000..b991325ab9 --- /dev/null +++ b/Task/Non-decimal-radices-Output/PureBasic/non-decimal-radices-output.purebasic @@ -0,0 +1,6 @@ +For i=105 To 115 + Bin$=RSet(Bin(i),8,"0") ;- Convert to wanted type & pad with '0' + Hex$=RSet(Hex(i),4,"0") + Dec$=RSet(Str(i),3) + PrintN(Dec$+" decimal = %"+Bin$+" = $"+Hex$+".") +Next diff --git a/Task/Non-decimal-radices-Output/Python/non-decimal-radices-output-1.py b/Task/Non-decimal-radices-Output/Python/non-decimal-radices-output-1.py new file mode 100644 index 0000000000..0fc234c1e0 --- /dev/null +++ b/Task/Non-decimal-radices-Output/Python/non-decimal-radices-output-1.py @@ -0,0 +1,42 @@ +>>> for n in range(34): + print " {0:6b} {1:3o} {2:2d} {3:2X}".format(n, n, n, n) + #The following would give the same output, and, + #due to the outer brackets, works with Python 3.0 too + #print ( " {n:6b} {n:3o} {n:2d} {n:2X}".format(n=n) ) + + + 0 0 0 0 + 1 1 1 1 + 10 2 2 2 + 11 3 3 3 + 100 4 4 4 + 101 5 5 5 + 110 6 6 6 + 111 7 7 7 + 1000 10 8 8 + 1001 11 9 9 + 1010 12 10 A + 1011 13 11 B + 1100 14 12 C + 1101 15 13 D + 1110 16 14 E + 1111 17 15 F + 10000 20 16 10 + 10001 21 17 11 + 10010 22 18 12 + 10011 23 19 13 + 10100 24 20 14 + 10101 25 21 15 + 10110 26 22 16 + 10111 27 23 17 + 11000 30 24 18 + 11001 31 25 19 + 11010 32 26 1A + 11011 33 27 1B + 11100 34 28 1C + 11101 35 29 1D + 11110 36 30 1E + 11111 37 31 1F + 100000 40 32 20 + 100001 41 33 21 +>>> diff --git a/Task/Non-decimal-radices-Output/Python/non-decimal-radices-output-2.py b/Task/Non-decimal-radices-Output/Python/non-decimal-radices-output-2.py new file mode 100644 index 0000000000..268fbc908e --- /dev/null +++ b/Task/Non-decimal-radices-Output/Python/non-decimal-radices-output-2.py @@ -0,0 +1,2 @@ +for n in range(34): + print " %3o %2d %2X" % (n, n, n) diff --git a/Task/Non-decimal-radices-Output/Python/non-decimal-radices-output-3.py b/Task/Non-decimal-radices-Output/Python/non-decimal-radices-output-3.py new file mode 100644 index 0000000000..522c610cd9 --- /dev/null +++ b/Task/Non-decimal-radices-Output/Python/non-decimal-radices-output-3.py @@ -0,0 +1,8 @@ +n = 33 +#Python 3.x: +print(bin(n), oct(n), n, hex(n)) # bin() only available in Python 3.x and 2.6 +# output: 0b100001 0o41 33 0x21 + +#Python 2.x: +#print oct(n), n, hex(n) +# output: 041 33 0x21 diff --git a/Task/Non-decimal-radices-Output/R/non-decimal-radices-output.r b/Task/Non-decimal-radices-Output/R/non-decimal-radices-output.r new file mode 100644 index 0000000000..89ac96e16b --- /dev/null +++ b/Task/Non-decimal-radices-Output/R/non-decimal-radices-output.r @@ -0,0 +1,8 @@ +# dec to oct +as.octmode(x) +# dec to hex +as.hexmode(x) +# oct or hex to dec +as.integer(x) +# or +as.numeric(x) diff --git a/Task/Non-decimal-radices-Output/REXX/non-decimal-radices-output-1.rexx b/Task/Non-decimal-radices-Output/REXX/non-decimal-radices-output-1.rexx new file mode 100644 index 0000000000..8a36d4c558 --- /dev/null +++ b/Task/Non-decimal-radices-Output/REXX/non-decimal-radices-output-1.rexx @@ -0,0 +1,10 @@ +/*REXX pgm shows REXX's ability to show decimal numbers in binary & hex.*/ + + do j=0 to 50 /*show some low-value num conversions*/ + say right(j,3) ' in decimal is', + right(d2b(j),12) " in binary", + right(d2x(j),12) ' in hexadecimal.' + end /*j*/ +exit /*stick a fork in it, we're done.*/ +/*────────────────────────────D2B subroutine────────────────────────────*/ +d2b: return word(strip(x2b(d2x(arg(1))),'L',0) 0,1) /*convert dec──►bin*/ diff --git a/Task/Non-decimal-radices-Output/REXX/non-decimal-radices-output-2.rexx b/Task/Non-decimal-radices-Output/REXX/non-decimal-radices-output-2.rexx new file mode 100644 index 0000000000..8a02da6f61 --- /dev/null +++ b/Task/Non-decimal-radices-Output/REXX/non-decimal-radices-output-2.rexx @@ -0,0 +1,11 @@ +/*REXX program shows REXX's ability to show dec nums in bin/hex/base256.*/ + + do j=14 to 67 /*display some lower-value numbers. */ + say right(j,3) ' in decimal is', + right(d2b(j),12) " in binary", + right(d2x(j),12) ' in hexadecimal', + right(d2c(j),12) ' in base256.' + end +exit /*stick a fork in it, we're done.*/ +/*────────────────────────────D2B subroutine────────────────────────────*/ +d2b: return word(strip(x2b(d2x(arg(1))),'L',0) 0,1) /*convert dec──►bin*/ diff --git a/Task/Non-decimal-radices-Output/Ruby/non-decimal-radices-output.rb b/Task/Non-decimal-radices-Output/Ruby/non-decimal-radices-output.rb new file mode 100644 index 0000000000..b88bdfcd9a --- /dev/null +++ b/Task/Non-decimal-radices-Output/Ruby/non-decimal-radices-output.rb @@ -0,0 +1,38 @@ +irb(main):001:0> for n in 0..33 +irb(main):002:1> puts " %6b %3o %2d %2X" % [n, n, n, n] +irb(main):003:1> end + 0 0 0 0 + 1 1 1 1 + 10 2 2 2 + 11 3 3 3 + 100 4 4 4 + 101 5 5 5 + 110 6 6 6 + 111 7 7 7 + 1000 10 8 8 + 1001 11 9 9 + 1010 12 10 A + 1011 13 11 B + 1100 14 12 C + 1101 15 13 D + 1110 16 14 E + 1111 17 15 F + 10000 20 16 10 + 10001 21 17 11 + 10010 22 18 12 + 10011 23 19 13 + 10100 24 20 14 + 10101 25 21 15 + 10110 26 22 16 + 10111 27 23 17 + 11000 30 24 18 + 11001 31 25 19 + 11010 32 26 1A + 11011 33 27 1B + 11100 34 28 1C + 11101 35 29 1D + 11110 36 30 1E + 11111 37 31 1F + 100000 40 32 20 + 100001 41 33 21 +=> 0..33 diff --git a/Task/Non-decimal-radices-Output/Scheme/non-decimal-radices-output.ss b/Task/Non-decimal-radices-Output/Scheme/non-decimal-radices-output.ss new file mode 100644 index 0000000000..00a2b9f62a --- /dev/null +++ b/Task/Non-decimal-radices-Output/Scheme/non-decimal-radices-output.ss @@ -0,0 +1,10 @@ +(do ((i 0 (+ i 1))) + ((>= i 33)) + (display (number->string i 2)) ; binary + (display " ") + (display (number->string i 8)) ; octal + (display " ") + (display (number->string i 10)) ; decimal, the "10" is optional + (display " ") + (display (number->string i 16)) ; hex + (newline)) diff --git a/Task/Non-decimal-radices-Output/Seed7/non-decimal-radices-output.seed7 b/Task/Non-decimal-radices-Output/Seed7/non-decimal-radices-output.seed7 new file mode 100644 index 0000000000..1af0e46940 --- /dev/null +++ b/Task/Non-decimal-radices-Output/Seed7/non-decimal-radices-output.seed7 @@ -0,0 +1,12 @@ +$ include "seed7_05.s7i"; + +const proc: main is func + local + var integer: i is 0; + begin + for i range 1 to 33 do + writeln(i lpad 6 <& + i radix 8 lpad 6 <& + i radix 16 lpad 6); + end for; + end func; diff --git a/Task/Non-decimal-radices-Output/Smalltalk/non-decimal-radices-output.st b/Task/Non-decimal-radices-Output/Smalltalk/non-decimal-radices-output.st new file mode 100644 index 0000000000..1facf9fb3a --- /dev/null +++ b/Task/Non-decimal-radices-Output/Smalltalk/non-decimal-radices-output.st @@ -0,0 +1,4 @@ +1 to: 33 do: [ :i | + ('%1 %2 %3' % { i printStringRadix: 8. i printStringRadix: 16. i printStringRadix: 2 }) + printNl. +]. diff --git a/Task/Non-decimal-radices-Output/Standard-ML/non-decimal-radices-output.ml b/Task/Non-decimal-radices-Output/Standard-ML/non-decimal-radices-output.ml new file mode 100644 index 0000000000..5613434cfe --- /dev/null +++ b/Task/Non-decimal-radices-Output/Standard-ML/non-decimal-radices-output.ml @@ -0,0 +1,12 @@ +let + fun loop i = + if i < 34 then ( + print (Int.fmt StringCvt.BIN i ^ "\t" + ^ Int.fmt StringCvt.OCT i ^ "\t" + ^ Int.fmt StringCvt.DEC i ^ "\t" + ^ Int.fmt StringCvt.HEX i ^ "\n"); + loop (i+1) + ) else () +in + loop 0 +end diff --git a/Task/Non-decimal-radices-Output/TI-89-BASIC/non-decimal-radices-output-1.ti-89 b/Task/Non-decimal-radices-Output/TI-89-BASIC/non-decimal-radices-output-1.ti-89 new file mode 100644 index 0000000000..6e21d85711 --- /dev/null +++ b/Task/Non-decimal-radices-Output/TI-89-BASIC/non-decimal-radices-output-1.ti-89 @@ -0,0 +1,9 @@ +Local old +getMode("Base")→old +setMode("Base", "BIN") +Disp string(16) +setMode("Base", "HEX") +Disp string(16) +setMode("Base", "DEC") +Disp string(16) +setMode("Base", old) diff --git a/Task/Non-decimal-radices-Output/TI-89-BASIC/non-decimal-radices-output-2.ti-89 b/Task/Non-decimal-radices-Output/TI-89-BASIC/non-decimal-radices-output-2.ti-89 new file mode 100644 index 0000000000..b0238c8272 --- /dev/null +++ b/Task/Non-decimal-radices-Output/TI-89-BASIC/non-decimal-radices-output-2.ti-89 @@ -0,0 +1,3 @@ +0b10000 +0h10 +16 diff --git a/Task/Non-decimal-radices-Output/Tcl/non-decimal-radices-output-1.tcl b/Task/Non-decimal-radices-Output/Tcl/non-decimal-radices-output-1.tcl new file mode 100644 index 0000000000..da89462b1b --- /dev/null +++ b/Task/Non-decimal-radices-Output/Tcl/non-decimal-radices-output-1.tcl @@ -0,0 +1,3 @@ +for {set n 0} {$n <= 33} {incr n} { + puts [format " %3o %2d %2X" $n $n $n] +} diff --git a/Task/Non-decimal-radices-Output/Tcl/non-decimal-radices-output-2.tcl b/Task/Non-decimal-radices-Output/Tcl/non-decimal-radices-output-2.tcl new file mode 100644 index 0000000000..427f6305dc --- /dev/null +++ b/Task/Non-decimal-radices-Output/Tcl/non-decimal-radices-output-2.tcl @@ -0,0 +1,10 @@ +# process the value as if it's a string +proc int2bits {i} { + string map {0 000 1 001 2 010 3 011 4 100 5 101 6 110 7 111} [format %o $i] +} + +# format the number string as an integer, then scan into a binary string +proc int2bits {i} { + binary scan [binary format I1 $i] B* x + return $x +} diff --git a/Task/Non-decimal-radices-Output/XPL0/non-decimal-radices-output.xpl0 b/Task/Non-decimal-radices-Output/XPL0/non-decimal-radices-output.xpl0 new file mode 100644 index 0000000000..214dcaf979 --- /dev/null +++ b/Task/Non-decimal-radices-Output/XPL0/non-decimal-radices-output.xpl0 @@ -0,0 +1,8 @@ +include c:\cxpl\codes; +int N; +[N:= 2; +repeat HexOut(0, N); Text(0, " "); + IntOut(0, N); CrLf(0); + N:= N*N; +until N=0; +] diff --git a/Task/Nth-root/0DESCRIPTION b/Task/Nth-root/0DESCRIPTION new file mode 100644 index 0000000000..6a170b0cb0 --- /dev/null +++ b/Task/Nth-root/0DESCRIPTION @@ -0,0 +1 @@ +Implement the algorithm to compute the principal [[wp:Nth root|''n''th root]] \sqrt[n]A of a positive real number ''A'', as explained at the [[wp:Nth root algorithm|Wikipedia page]]. diff --git a/Task/Nth-root/1META.yaml b/Task/Nth-root/1META.yaml new file mode 100644 index 0000000000..f407ff9d83 --- /dev/null +++ b/Task/Nth-root/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Classic CS problems and programs diff --git a/Task/Nth-root/ALGOL-68/nth-root.alg b/Task/Nth-root/ALGOL-68/nth-root.alg new file mode 100644 index 0000000000..7544059e8b --- /dev/null +++ b/Task/Nth-root/ALGOL-68/nth-root.alg @@ -0,0 +1,25 @@ +REAL default p = 0.001; + +PROC nth root = (INT n, LONG REAL a, p)LONG REAL: +( + [2]LONG REAL x := (a, a/n); + + WHILE ABS(x[2] - x[1]) > p DO + x := (x[2], ((n-1)*x[2] + a/x[2]**(n-1))/n ) + OD; + x[2] +); + +PRIO ROOT = 8; +OP ROOT = (INT n, LONG REAL a)LONG REAL: nth root(n, a, default p); +OP ROOT = (INT n, INT a)LONG REAL: nth root(n, a, default p); + +main: +( + printf(($2(" "gl)$, + nth root(10, LONG 7131.5 ** 10, default p), + nth root(5, 34, default p))); + printf(($2(" "gl)$, + 10 ROOT ( LONG 7131.5 ** 10 ), + 5 ROOT 34)) +) diff --git a/Task/Nth-root/AWK/nth-root.awk b/Task/Nth-root/AWK/nth-root.awk new file mode 100644 index 0000000000..a1975a623e --- /dev/null +++ b/Task/Nth-root/AWK/nth-root.awk @@ -0,0 +1,22 @@ +#!/usr/bin/awk -f +BEGIN { + # test + print nthroot(8,3) + print nthroot(16,2) + print nthroot(16,4) + print nthroot(125,3) + print nthroot(3,3) + print nthroot(3,2) +} + +function nthroot(y,n) { + eps = 1e-15; # relative accuracy + x = 1; + do { + d = ( y / ( x^(n-1) ) - x ) / n ; + x += d; + e = eps*x; # absolute accuracy + } while ( d < -e || d > e ) + + return x +} diff --git a/Task/Nth-root/Ada/nth-root.ada b/Task/Nth-root/Ada/nth-root.ada new file mode 100644 index 0000000000..244d05ddf4 --- /dev/null +++ b/Task/Nth-root/Ada/nth-root.ada @@ -0,0 +1,27 @@ +with Ada.Text_IO; use Ada.Text_IO; + +procedure Test_Nth_Root is + generic + type Real is digits <>; + function Nth_Root (Value : Real; N : Positive) return Real; + + function Nth_Root (Value : Real; N : Positive) return Real is + type Index is mod 2; + X : array (Index) of Real := (Value, Value); + K : Index := 0; + begin + loop + X (K + 1) := ( (Real (N) - 1.0) * X (K) + Value / X (K) ** (N-1) ) / Real (N); + exit when X (K + 1) >= X (K); + K := K + 1; + end loop; + return X (K + 1); + end Nth_Root; + + function Long_Nth_Root is new Nth_Root (Long_Float); +begin + Put_Line ("1024.0 10th =" & Long_Float'Image (Long_Nth_Root (1024.0, 10))); + Put_Line (" 27.0 3rd =" & Long_Float'Image (Long_Nth_Root (27.0, 3))); + Put_Line (" 2.0 2nd =" & Long_Float'Image (Long_Nth_Root (2.0, 2))); + Put_Line ("5642.0 125th =" & Long_Float'Image (Long_Nth_Root (5642.0, 125))); +end Test_Nth_Root; diff --git a/Task/Nth-root/AutoHotkey/nth-root.ahk b/Task/Nth-root/AutoHotkey/nth-root.ahk new file mode 100644 index 0000000000..51667acb39 --- /dev/null +++ b/Task/Nth-root/AutoHotkey/nth-root.ahk @@ -0,0 +1,19 @@ +p := 0.000001 + +MsgBox, % nthRoot( 10, 7131.5**10, p) "`n" + . nthRoot( 5, 34.0 , p) "`n" + . nthRoot( 2, 2 , p) "`n" + . nthRoot(0.5, 7 , p) "`n" + + +;--------------------------------------------------------------------------- +nthRoot(n, A, p) { ; http://en.wikipedia.org/wiki/Nth_root_algorithm +;--------------------------------------------------------------------------- + x1 := A + x2 := A / n + While Abs(x1 - x2) > p { + x1 := x2 + x2 := ((n-1)*x2+A/x2**(n-1))/n + } + Return, x2 +} diff --git a/Task/Nth-root/AutoIt/nth-root.autoit b/Task/Nth-root/AutoIt/nth-root.autoit new file mode 100644 index 0000000000..6d7d26f4b2 --- /dev/null +++ b/Task/Nth-root/AutoIt/nth-root.autoit @@ -0,0 +1,26 @@ +;AutoIt Version: 3.2.10.0 +$A=4913 +$n=3 +$x=20 +ConsoleWrite ($n& " root of "& $A & " is " &nth_root_it($A,$n,$x)) +ConsoleWrite ($n& " root of "& $A & " is " &nth_root_rec($A,$n,$x)) + +;Iterative +Func nth_root_it($A,$n,$x) + $x0="0" + While StringCompare(string($x0),string($x)) + ConsoleWrite ($x&@CRLF) + $x0=$x + $x=((($n-1)*$x)+($A/$x^($n-1)))/$n + WEnd + Return $x +EndFunc + +;Recursive +Func nth_root_rec($A,$n,$x) + ConsoleWrite ($x&@CRLF) + If $x==((($n-1)*$x)+($A/$x^($n-1)))/$n Then + Return $x + EndIf + Return nth_root_rec($A,$n,((($n-1)*$x)+($A/$x^($n-1)))/$n) +EndFunc diff --git a/Task/Nth-root/BASIC/nth-root-1.basic b/Task/Nth-root/BASIC/nth-root-1.basic new file mode 100644 index 0000000000..348ede80de --- /dev/null +++ b/Task/Nth-root/BASIC/nth-root-1.basic @@ -0,0 +1,11 @@ +FUNCTION RootX (tBase AS DOUBLE, tExp AS DOUBLE, diffLimit AS DOUBLE) AS DOUBLE + DIM tmp1 AS DOUBLE, tmp2 AS DOUBLE + ' Initial guess: + tmp1 = tBase / tExp + DO + tmp2 = tmp1 + ' 1# tells compiler that "1" is a double, not an integer + tmp1 = (((tExp - 1#) * tmp2) + (tBase / (tmp2 ^ (tExp - 1#)))) / tExp + LOOP WHILE (ABS(tmp1 - tmp2) > diffLimit) + RootX = tmp1 +END FUNCTION diff --git a/Task/Nth-root/BASIC/nth-root-2.basic b/Task/Nth-root/BASIC/nth-root-2.basic new file mode 100644 index 0000000000..2d8d85d6c0 --- /dev/null +++ b/Task/Nth-root/BASIC/nth-root-2.basic @@ -0,0 +1 @@ +FUNCTION RootX# (tBase AS DOUBLE, tExp AS DOUBLE, diffLimit AS DOUBLE) diff --git a/Task/Nth-root/BASIC/nth-root-3.basic b/Task/Nth-root/BASIC/nth-root-3.basic new file mode 100644 index 0000000000..077503d9b9 --- /dev/null +++ b/Task/Nth-root/BASIC/nth-root-3.basic @@ -0,0 +1 @@ +PRINT "The "; e; "th root of "; b; " is "; RootX(b, e, .000001) diff --git a/Task/Nth-root/BBC-BASIC/nth-root.bbc b/Task/Nth-root/BBC-BASIC/nth-root.bbc new file mode 100644 index 0000000000..86a646a2b8 --- /dev/null +++ b/Task/Nth-root/BBC-BASIC/nth-root.bbc @@ -0,0 +1,13 @@ + *FLOAT 64 + @% = &D0D + PRINT "Cube root of 5 is "; FNroot(3, 5, 0) + PRINT "125th root of 5643 is "; FNroot(125, 5643, 0) + END + + DEF FNroot(n%, a, d) + LOCAL x0, x1 : x0 = a / n% : REM Initial guess + REPEAT + x1 = ((n% - 1)*x0 + a/x0^(n%-1)) / n% + SWAP x0, x1 + UNTIL ABS (x0 - x1) <= d + = x0 diff --git a/Task/Nth-root/C++/nth-root-1.cpp b/Task/Nth-root/C++/nth-root-1.cpp new file mode 100644 index 0000000000..bf3334189c --- /dev/null +++ b/Task/Nth-root/C++/nth-root-1.cpp @@ -0,0 +1,12 @@ +double NthRoot(double m_nValue, double index, double guess, double pc) + { + double result = guess; + double result_next; + do + { + result_next = (1.0/index)*((index-1.0)*result+(m_nValue)/(pow(result,(index-1.0)))); + result = result_next; + pc--; + }while(pc>1); + return result; + }; diff --git a/Task/Nth-root/C++/nth-root-2.cpp b/Task/Nth-root/C++/nth-root-2.cpp new file mode 100644 index 0000000000..36f91f5c94 --- /dev/null +++ b/Task/Nth-root/C++/nth-root-2.cpp @@ -0,0 +1,4 @@ +double NthRoot(double value, double degree) +{ + return pow(value, (double)(1 / degree)); +}; diff --git a/Task/Nth-root/C/nth-root.c b/Task/Nth-root/C/nth-root.c new file mode 100644 index 0000000000..f5fb6613d3 --- /dev/null +++ b/Task/Nth-root/C/nth-root.c @@ -0,0 +1,31 @@ +#include +#include + +inline double abs_(double x) { return x >= 0 ? x : -x; } +double pow_(double x, int e) +{ + double ret = 1; + for (ret = 1; e; x *= x, e >>= 1) + if ((e & 1)) ret *= x; + return ret; +} + +double root(double a, int n) +{ + double d, x = 1; + if (!a) return 0; + if (n < 1 || (a < 0 && !(n&1))) return 0./0.; /* NaN */ + + do { d = (a / pow_(x, n - 1) - x) / n; + x+= d; + } while (abs_(d) >= abs_(x) * (DBL_EPSILON * 10)); + + return x; +} + +int main() +{ + double x = pow_(-3.14159, 15); + printf("root(%g, 15) = %g\n", x, root(x, 15)); + return 0; +} diff --git a/Task/Nth-root/CoffeeScript/nth-root-1.coffeescript b/Task/Nth-root/CoffeeScript/nth-root-1.coffeescript new file mode 100644 index 0000000000..572bbfd136 --- /dev/null +++ b/Task/Nth-root/CoffeeScript/nth-root-1.coffeescript @@ -0,0 +1,26 @@ +nth_root = (A, n, precision=0.0000000000001) -> + x = 1 + while true + x_new = (1 / n) * ((n - 1) * x + A / Math.pow(x, n - 1)) + return x_new if Math.abs(x_new - x) < precision + x = x_new + +# tests +do -> + tests = [ + [8, 3] + [16, 4] + [32, 5] + [343, 3] + [1024, 10] + [1000000000, 3] + [1000000000, 9] + [100, 2] + [100, 3] + [100, 5] + [100, 10] + ] + for test in tests + [x, n] = test + root = nth_root x, n + console.log "#{x} root #{n} = #{root} (root^#{n} = #{Math.pow root, n})" diff --git a/Task/Nth-root/CoffeeScript/nth-root-2.coffeescript b/Task/Nth-root/CoffeeScript/nth-root-2.coffeescript new file mode 100644 index 0000000000..d669dabf27 --- /dev/null +++ b/Task/Nth-root/CoffeeScript/nth-root-2.coffeescript @@ -0,0 +1,12 @@ +> coffee nth_root.coffee +8 root 3 = 2 (root^3 = 8) +16 root 4 = 2 (root^4 = 16) +32 root 5 = 2 (root^5 = 32) +343 root 3 = 7 (root^3 = 343) +1024 root 10 = 2 (root^10 = 1024) +1000000000 root 3 = 1000 (root^3 = 1000000000) +1000000000 root 9 = 10 (root^9 = 1000000000) +100 root 2 = 10 (root^2 = 100) +100 root 3 = 4.641588833612778 (root^3 = 99.99999999999997) +100 root 5 = 2.5118864315095806 (root^5 = 100.0000000000001) +100 root 10 = 1.5848931924611134 (root^10 = 99.99999999999993) diff --git a/Task/Nth-root/Common-Lisp/nth-root-1.lisp b/Task/Nth-root/Common-Lisp/nth-root-1.lisp new file mode 100644 index 0000000000..8280e3bd0c --- /dev/null +++ b/Task/Nth-root/Common-Lisp/nth-root-1.lisp @@ -0,0 +1,9 @@ +(defun nth-root (n a &optional (epsilon .0001) (guess (1- n))) + (assert (and (> n 1) (> a 0))) + (flet ((next (x) + (/ (+ (* (1- n) x) + (/ a (expt x (1- n)))) + n))) + (do* ((xi guess xi+1) + (xi+1 (next xi) (next xi))) + ((< (abs (- xi+1 xi)) epsilon) xi+1)))) diff --git a/Task/Nth-root/Common-Lisp/nth-root-2.lisp b/Task/Nth-root/Common-Lisp/nth-root-2.lisp new file mode 100644 index 0000000000..c456222df1 --- /dev/null +++ b/Task/Nth-root/Common-Lisp/nth-root-2.lisp @@ -0,0 +1,4 @@ +(let* ((r (nth-root 3 10)) + (rf (coerce r 'float))) + (print (* r r r )) + (print (* rf rf rf))) diff --git a/Task/Nth-root/D/nth-root.d b/Task/Nth-root/D/nth-root.d new file mode 100644 index 0000000000..8d0e9dd8aa --- /dev/null +++ b/Task/Nth-root/D/nth-root.d @@ -0,0 +1,13 @@ +import std.stdio, std.math; + +real nthroot(in int n, in real A, in real p=0.001) pure nothrow { + real[2] x = [A, A / n]; + while (abs(x[1] - x[0]) > p) + x = [x[1], ((n - 1) * x[1] + A / (x[1] ^^ (n-1))) / n]; + return x[1]; +} + +void main() { + writeln(nthroot(10, 7131.5 ^^ 10)); + writeln(nthroot(6, 64)); +} diff --git a/Task/Nth-root/Delphi/nth-root.delphi b/Task/Nth-root/Delphi/nth-root.delphi new file mode 100644 index 0000000000..8db4498177 --- /dev/null +++ b/Task/Nth-root/Delphi/nth-root.delphi @@ -0,0 +1,15 @@ +USES + Math; + +function NthRoot(A, Precision: Double; n: Integer): Double; +var + x_p, X: Double; +begin + x_p := Sqrt(A); + while Abs(A - Power(x_p, n)) > Precision do + begin + x := (1/n) * (((n-1) * x_p) + (A/(Power(x_p, n - 1)))); + x_p := x; + end; + Result := x_p; +end; diff --git a/Task/Nth-root/E/nth-root.e b/Task/Nth-root/E/nth-root.e new file mode 100644 index 0000000000..58aef5fbb3 --- /dev/null +++ b/Task/Nth-root/E/nth-root.e @@ -0,0 +1,12 @@ +def nthroot(n, x) { + require(n > 1 && x > 0) + def np := n - 1 + def iter(g) { return (np*g + x/g**np) / n } + var g1 := x + var g2 := iter(g1) + while (!(g1 <=> g2)) { + g1 := iter(g1) + g2 := iter(iter(g2)) + } + return g1 +} diff --git a/Task/Nth-root/Erlang/nth-root-1.erl b/Task/Nth-root/Erlang/nth-root-1.erl new file mode 100644 index 0000000000..2e492c02dc --- /dev/null +++ b/Task/Nth-root/Erlang/nth-root-1.erl @@ -0,0 +1,6 @@ +fixed_point(F, Guess, Tolerance) -> + fixed_point(F, Guess, Tolerance, F(Guess)). +fixed_point(_, Guess, Tolerance, Next) when abs(Guess - Next) < Tolerance -> + Next; +fixed_point(F, _, Tolerance, Next) -> + fixed_point(F, Next, Tolerance, F(Next)). diff --git a/Task/Nth-root/Erlang/nth-root-2.erl b/Task/Nth-root/Erlang/nth-root-2.erl new file mode 100644 index 0000000000..e633039069 --- /dev/null +++ b/Task/Nth-root/Erlang/nth-root-2.erl @@ -0,0 +1,4 @@ +nth_root(N, X) -> nth_root(N, X, 1.0e-5). +nth_root(N, X, Precision) -> + F = fun(Prev) -> ((N - 1) * Prev + X / math:pow(Prev, (N-1))) / N end, + fixed_point(F, X, Precision). diff --git a/Task/Nth-root/Forth/nth-root.fth b/Task/Nth-root/Forth/nth-root.fth new file mode 100644 index 0000000000..58f33e10c6 --- /dev/null +++ b/Task/Nth-root/Forth/nth-root.fth @@ -0,0 +1,11 @@ +: th-root { F: a F: n -- a^1/n } + a + begin + a fover n 1e f- f** f/ + fover n 1e f- f* + f+ n f/ + fswap fover 1e-5 f~ + until ; + +34e 5e th-root f. \ 2.02439745849989 +34e 5e 1/f f** f. \ 2.02439745849989 diff --git a/Task/Nth-root/Fortran/nth-root.f b/Task/Nth-root/Fortran/nth-root.f new file mode 100644 index 0000000000..881957d030 --- /dev/null +++ b/Task/Nth-root/Fortran/nth-root.f @@ -0,0 +1,42 @@ +program NthRootTest + implicit none + + print *, nthroot(10, 7131.5**10) + print *, nthroot(5, 34.0) + +contains + + function nthroot(n, A, p) + real :: nthroot + integer, intent(in) :: n + real, intent(in) :: A + real, intent(in), optional :: p + + real :: rp, x(2) + + if ( A < 0 ) then + stop "A < 0" ! we handle only real positive numbers + elseif ( A == 0 ) then + nthroot = 0 + return + end if + + if ( present(p) ) then + rp = p + else + rp = 0.001 + end if + + x(1) = A + x(2) = A/n ! starting "guessed" value... + + do while ( abs(x(2) - x(1)) > rp ) + x(1) = x(2) + x(2) = ((n-1.0)*x(2) + A/(x(2) ** (n-1.0)))/real(n) + end do + + nthroot = x(2) + + end function nthroot + +end program NthRootTest diff --git a/Task/Nth-root/Go/nth-root.go b/Task/Nth-root/Go/nth-root.go new file mode 100644 index 0000000000..7400b0f028 --- /dev/null +++ b/Task/Nth-root/Go/nth-root.go @@ -0,0 +1,19 @@ +func root(a float64, n int) float64 { + n1 := n - 1 + n1f, rn := float64(n1), 1/float64(n) + x, x0 := 1., 0. + for { + potx, t2 := 1/x, a + for b := n1; b > 0; b >>= 1 { + if b&1 == 1 { + t2 *= potx + } + potx *= potx + } + x0, x = x, rn*(n1f*x+t2) + if math.Abs(x-x0)*1e15 < x { + break + } + } + return x +} diff --git a/Task/Nth-root/Groovy/nth-root-1.groovy b/Task/Nth-root/Groovy/nth-root-1.groovy new file mode 100644 index 0000000000..5579e42ae8 --- /dev/null +++ b/Task/Nth-root/Groovy/nth-root-1.groovy @@ -0,0 +1,13 @@ +import static Constants.tolerance +import static java.math.RoundingMode.HALF_UP + +def root(double base, double n) { + double xOld = 1 + double xNew = 0 + while (true) { + xNew = ((n - 1) * xOld + base/(xOld)**(n - 1))/n + if ((xNew - xOld).abs() < tolerance) { break } + xOld = xNew + } + (xNew as BigDecimal).setScale(7, HALF_UP) +} diff --git a/Task/Nth-root/Groovy/nth-root-2.groovy b/Task/Nth-root/Groovy/nth-root-2.groovy new file mode 100644 index 0000000000..e05c631c8e --- /dev/null +++ b/Task/Nth-root/Groovy/nth-root-2.groovy @@ -0,0 +1,21 @@ +class Constants { + static final tolerance = 0.00001 +} + +print ''' + Base Power Calc'd Root Actual Root +------- ------ ----------- ----------- +''' +def testCases = [ + [b:32.0, n:5.0, r:2.0], + [b:81.0, n:4.0, r:3.0], + [b:Math.PI**2, n:4.0, r:Math.PI**(0.5)], + [b:7.0, n:0.5, r:49.0], +] + +testCases.each { + def r = root(it.b, it.n) + printf('%7.4f %6.4f %11.4f %11.4f\n', + it.b, it.n, r, it.r) + assert (r - it.r).abs() <= tolerance +} diff --git a/Task/Nth-root/Haskell/nth-root.hs b/Task/Nth-root/Haskell/nth-root.hs new file mode 100644 index 0000000000..1ca0426485 --- /dev/null +++ b/Task/Nth-root/Haskell/nth-root.hs @@ -0,0 +1 @@ +n `nthRoot` x = fst $ until (uncurry(==)) (\(_,x0) -> (x0,((n-1)*x0+x/x0**(n-1))/n)) (x,x/n) diff --git a/Task/Nth-root/HicEst/nth-root.hicest b/Task/Nth-root/HicEst/nth-root.hicest new file mode 100644 index 0000000000..c30ed5b1d5 --- /dev/null +++ b/Task/Nth-root/HicEst/nth-root.hicest @@ -0,0 +1,19 @@ +WRITE(Messagebox) NthRoot(5, 34) +WRITE(Messagebox) NthRoot(10, 7131.5^10) + +FUNCTION NthRoot(n, A) + REAL :: prec = 0.001 + + IF( (n > 0) * (A > 0) ) THEN + NthRoot = A / n + DO i = 1, 1/prec + x = ((n-1)*NthRoot + A/(NthRoot^(n-1))) / n + IF( ABS(x - NthRoot) <= prec ) THEN + RETURN + ENDIF + NthRoot = x + ENDDO + ENDIF + + WRITE(Messagebox, Name) 'Cannot solve problem for:', prec, n, A +END diff --git a/Task/Nth-root/Icon/nth-root.icon b/Task/Nth-root/Icon/nth-root.icon new file mode 100644 index 0000000000..945f99dbd7 --- /dev/null +++ b/Task/Nth-root/Icon/nth-root.icon @@ -0,0 +1,23 @@ +procedure main() + showroot(125,3) + showroot(27,3) + showroot(1024,10) + showroot(39.0625,4) + showroot(7131.5^10,10) +end + +procedure showroot(a,n) + printf("%i-th root of %i = %i\n",n,a,root(a,n)) +end + +procedure root(a,n,p) #: finds the n-th root of the number a to precision p + if n < 0 | type(n) !== "integer" then runerr(101,n) + if a < 0 then runerr(205,a) + /p := 1e-14 # precision + xn := a / real(n) # initial guess + while abs(a - xn^n) > p do + xn := ((n - 1) * (xi := xn) + a / (xi ^ (n-1))) / real(n) + return xn +end + +link printf diff --git a/Task/Nth-root/J/nth-root.j b/Task/Nth-root/J/nth-root.j new file mode 100644 index 0000000000..eaa009b295 --- /dev/null +++ b/Task/Nth-root/J/nth-root.j @@ -0,0 +1,5 @@ + '`N X NP' =. (0 { [)`(1 { [)`(2 { [) + iter =. N %~ (NP * ]) + X % ] ^ NP + nth_root =: (, , _1+[) iter^:_ f. ] + 10 nth_root 7131.5^10 +7131.5 diff --git a/Task/Nth-root/Java/nth-root-1.java b/Task/Nth-root/Java/nth-root-1.java new file mode 100644 index 0000000000..a81d7d678f --- /dev/null +++ b/Task/Nth-root/Java/nth-root-1.java @@ -0,0 +1,18 @@ +public static double nthroot(int n, double A) { + return nthroot(n, A, .001); +} +public static double nthroot(int n, double A, double p) { + if(A < 0) { + System.err.println("A < 0");// we handle only real positive numbers + return -1; + } else if(A == 0) { + return 0; + } + double x_prev = A; + double x = A / n; // starting "guessed" value... + while(Math.abs(x - x_prev) > p) { + x_prev = x; + x = ((n - 1.0) * x + A / Math.pow(x, n - 1.0)) / n; + } + return x; +} diff --git a/Task/Nth-root/Java/nth-root-2.java b/Task/Nth-root/Java/nth-root-2.java new file mode 100644 index 0000000000..e8bbe4483f --- /dev/null +++ b/Task/Nth-root/Java/nth-root-2.java @@ -0,0 +1,15 @@ +public static double nthroot(int n, double x) { + assert (n > 1 && x > 0); + int np = n - 1; + double g1 = x; + double g2 = iter(g1, np, n, x); + while (g1 != g2) { + g1 = iter(g1, np, n, x); + g2 = iter(iter(g2, np, n, x), np, n, x); + } + return g1; +} + +private static double iter(double g, int np, int n, double x) { + return (np * g + x / Math.pow(g, np)) / n; +} diff --git a/Task/Nth-root/JavaScript/nth-root.js b/Task/Nth-root/JavaScript/nth-root.js new file mode 100644 index 0000000000..d97e054dea --- /dev/null +++ b/Task/Nth-root/JavaScript/nth-root.js @@ -0,0 +1,11 @@ +function nthRoot(num, nArg, precArg) { + var n = nArg || 2; + var prec = precArg || 12; + + var x = 1; // Initial guess. + for (var i=0; ip + x( 0) =x( 1) + x( 1) =( ( n -1.0) *x( 1) +A /x( 1)^( n -1.0)) /n + wend + NthRoot =x( 1) +end function + +end diff --git a/Task/Nth-root/Logo/nth-root.logo b/Task/Nth-root/Logo/nth-root.logo new file mode 100644 index 0000000000..aaa0b1495a --- /dev/null +++ b/Task/Nth-root/Logo/nth-root.logo @@ -0,0 +1,11 @@ +to about :a :b + output and [:a - :b < 1e-5] [:a - :b > -1e-5] +end + +to root :n :a [:guess :a] + localmake "next ((:n-1) * :guess + :a / power :guess (:n-1)) / n + if about :guess :next [output :next] + output (root :n :a :next) +end + +show root 5 34 ; 2.02439745849989 diff --git a/Task/Nth-root/Lua/nth-root.lua b/Task/Nth-root/Lua/nth-root.lua new file mode 100644 index 0000000000..d0b7bc481a --- /dev/null +++ b/Task/Nth-root/Lua/nth-root.lua @@ -0,0 +1,3 @@ +function nth_root(num,root) + return num^(1/root) +end diff --git a/Task/Nth-root/MATLAB/nth-root-1.m b/Task/Nth-root/MATLAB/nth-root-1.m new file mode 100644 index 0000000000..af1bee87ea --- /dev/null +++ b/Task/Nth-root/MATLAB/nth-root-1.m @@ -0,0 +1,13 @@ +function answer = nthRoot(number,root) + + format long + + answer = number / root; + guess = number; + + while not(guess == answer) + guess = answer; + answer = (1/root)*( ((root - 1)*guess) + ( number/(guess^(root - 1)) ) ); + end + +end diff --git a/Task/Nth-root/MATLAB/nth-root-2.m b/Task/Nth-root/MATLAB/nth-root-2.m new file mode 100644 index 0000000000..fbf390f193 --- /dev/null +++ b/Task/Nth-root/MATLAB/nth-root-2.m @@ -0,0 +1,5 @@ +>> nthRoot(2,2) + +ans = + + 1.414213562373095 diff --git a/Task/Nth-root/Mathematica/nth-root.math b/Task/Nth-root/Mathematica/nth-root.math new file mode 100644 index 0000000000..9c3c62872b --- /dev/null +++ b/Task/Nth-root/Mathematica/nth-root.math @@ -0,0 +1 @@ +Root[A,n] diff --git a/Task/Nth-root/Maxima/nth-root.maxima b/Task/Nth-root/Maxima/nth-root.maxima new file mode 100644 index 0000000000..663d0f51c0 --- /dev/null +++ b/Task/Nth-root/Maxima/nth-root.maxima @@ -0,0 +1,13 @@ +nth_root(a, n) := block( + [x, y, d, p: fpprec], + fpprec: p + 10, + x: bfloat(a), + eps: 10.0b0^-p, + y: do ( + d: bfloat((a / x^(n - 1) - x) / n), + if abs(d) < eps * x then return(x), + x: x + d + ), + fpprec: p, + bfloat(y) +)$ diff --git a/Task/Nth-root/Metafont/nth-root.metafont b/Task/Nth-root/Metafont/nth-root.metafont new file mode 100644 index 0000000000..e7f1692177 --- /dev/null +++ b/Task/Nth-root/Metafont/nth-root.metafont @@ -0,0 +1,17 @@ +vardef mnthroot(expr n, A) = + x0 := A / n; + m := n - 1; + forever: + x1 := (m*x0 + A/(x0 ** m)) / n; + exitif abs(x1 - x0) < abs(x0 * 0.0001); + x0 := x1; + endfor; + x1 +enddef; + +primarydef n nthroot A = mnthroot(n, A) enddef; + +show 5 nthroot 34; % 2.0244 +show 0.5 nthroot 7; % 49.00528 + +bye diff --git a/Task/Nth-root/NetRexx/nth-root.netrexx b/Task/Nth-root/NetRexx/nth-root.netrexx new file mode 100644 index 0000000000..fc4228f7b5 --- /dev/null +++ b/Task/Nth-root/NetRexx/nth-root.netrexx @@ -0,0 +1,78 @@ +/*NetRexx program to calculate the Nth root of X, with DIGS accuracy. */ +class nth_root + + method main(args=String[]) static + if args.length < 2 then + do + say "at least 2 arguments expected" + exit + end + x = args[0] + root = args[1] + if args.length > 2 then digs = args[2] + + if root=='' then root=2 + if digs = null, digs = '' then digs=20 + numeric digits digs + say ' x = ' x + say ' root = ' root + say 'digits = ' digs + say 'answer = ' root(x,root,digs) + + method root(x,r,digs) static --procedure; parse arg x,R 1 oldR /*assign 2nd arg-->r and rOrig. */ + /*this subroutine will use the */ + /*digits from the calling prog. */ + /*The default digits is 9. */ + R = r + oldR = r + if r=0 then do + say + say '*** error! ***' + say "a root of zero can't be specified." + say + return '[n/a]' + end + + R=R.abs() /*use absolute value of root. */ + + if x<0 & (R//2==0) then do + say + say '*** error! ***' + say "an even root can't be calculated for a" - + 'negative number,' + say 'the result would be complex.' + say + return '[n/a]' + end + + if x=0 | r=1 then return x/1 /*handle couple of special cases.*/ + Rm1=R-1 /*just a fast version of ROOT-1 */ + oldDigs=digs /*get the current number of digs.*/ + dm=oldDigs+5 /*we need a little guard room. */ + ax=x.abs() /*the absolute value of X. */ + g=(ax+1)/r**r /*take a good stab at 1st guess. */ + -- numeric fuzz 3 /*fuzz digits for higher roots. */ + d=5 /*start with only five digits. */ + /*each calc doubles precision. */ + + loop forever + + d=d+d + if d>dm then d = dm /*double the digits, but not>DM. */ + numeric digits d /*tell REXX to use D digits. */ + old=0 /*assume some kind of old guess. */ + + loop forever + _=(Rm1*g**R+ax)/R/g**rm1 /*this is the nitty-gritty stuff.*/ + if _=g | _=old then leave /*computed close to this before? */ + old=g /*now, keep calculation for OLD. */ + g=_ /*set calculation to guesstimate.*/ + end + + if d==dm then leave /*found the root for DM digits ? */ + end + + _=g*x.sign() /*correct the sign (maybe). */ + if oldR<0 then return _=1/_ /*root < 0 ? Reciprocal it is.*/ + numeric digits oldDigs /*re-instate the original digits.*/ + return _/1 /*normalize the number to digs. */ diff --git a/Task/Nth-root/OCaml/nth-root.ocaml b/Task/Nth-root/OCaml/nth-root.ocaml new file mode 100644 index 0000000000..db77dd3135 --- /dev/null +++ b/Task/Nth-root/OCaml/nth-root.ocaml @@ -0,0 +1,12 @@ +let nthroot ~n ~a ?(tol=0.001) () = + let nf = float n in let nf1 = nf -. 1.0 in + let rec iter x = + let x' = (nf1 *. x +. a /. (x ** nf1)) /. nf in + if tol > abs_float (x -. x') then x' else iter x' in + iter 1.0 +;; + +let () = + Printf.printf "%g\n" (nthroot 10 (7131.5 ** 10.0) ()); + Printf.printf "%g\n" (nthroot 5 34.0 ()); +;; diff --git a/Task/Nth-root/Octave/nth-root-1.octave b/Task/Nth-root/Octave/nth-root-1.octave new file mode 100644 index 0000000000..483987c34a --- /dev/null +++ b/Task/Nth-root/Octave/nth-root-1.octave @@ -0,0 +1 @@ + r = A.^(1./n) diff --git a/Task/Nth-root/Octave/nth-root-2.octave b/Task/Nth-root/Octave/nth-root-2.octave new file mode 100644 index 0000000000..4dad576ba0 --- /dev/null +++ b/Task/Nth-root/Octave/nth-root-2.octave @@ -0,0 +1,12 @@ +function r = m_nthroot(n, A) + x0 = A / n; + m = n - 1; + while(1) + x1 = (m*x0 + A./ x0 .^ m) / n; + if ( abs(x1-x0) < abs(x0 * 1e-9) ) + r = x1; + return + endif + x0 = x1; + endwhile +endfunction diff --git a/Task/Nth-root/Octave/nth-root-3.octave b/Task/Nth-root/Octave/nth-root-3.octave new file mode 100644 index 0000000000..101ae4c4a5 --- /dev/null +++ b/Task/Nth-root/Octave/nth-root-3.octave @@ -0,0 +1,8 @@ +function r = m_nthroot(n, A) + r = A / n; + m = n - 1; + do + d = (A ./ r .^ m - r) / n; + r+= d; + until (abs(d) < abs(r * 1e-9)) +endfunction diff --git a/Task/Nth-root/Octave/nth-root-4.octave b/Task/Nth-root/Octave/nth-root-4.octave new file mode 100644 index 0000000000..e3e8819e68 --- /dev/null +++ b/Task/Nth-root/Octave/nth-root-4.octave @@ -0,0 +1,6 @@ +m_nthroot(10, 7131.5 .^ 10) +nthroot(7131.5 .^ 10, 10) +m_nthroot(5, 34) +nthroot(34, 5) +m_nthroot(0.5, 7) +nthroot(7, .5) diff --git a/Task/Nth-root/Oz/nth-root.oz b/Task/Nth-root/Oz/nth-root.oz new file mode 100644 index 0000000000..eaee53b2e5 --- /dev/null +++ b/Task/Nth-root/Oz/nth-root.oz @@ -0,0 +1,19 @@ +declare + fun {NthRoot NInt A} + N = {Int.toFloat NInt} + + fun {Next X} + ( (N-1.0)*X + A / {Pow X N-1.0} ) / N + end + in + {Until Value.'==' Next A/N} + end + + fun {Until P F X} + case {F X} + of NX andthen {P NX X} then X + [] NX then {Until P F NX} + end + end +in + {Show {NthRoot 2 2.0}} diff --git a/Task/Nth-root/PARI-GP/nth-root.pari b/Task/Nth-root/PARI-GP/nth-root.pari new file mode 100644 index 0000000000..73ace05f1d --- /dev/null +++ b/Task/Nth-root/PARI-GP/nth-root.pari @@ -0,0 +1 @@ +root(n,A)=A^(1/n); diff --git a/Task/Nth-root/PHP/nth-root.php b/Task/Nth-root/PHP/nth-root.php new file mode 100644 index 0000000000..1a27ade9a2 --- /dev/null +++ b/Task/Nth-root/PHP/nth-root.php @@ -0,0 +1,11 @@ +function nthroot($number, $root, $p = P) +{ + $x[0] = $number; + $x[1] = $number/$root; + while(abs($x[1]-$x[0]) > $p) + { + $x[0] = $x[1]; + $x[1] = (($root-1)*$x[1] + $number/pow($x[1], $root-1))/$root; + } + return $x[1]; +} diff --git a/Task/Nth-root/PL-I/nth-root.pli b/Task/Nth-root/PL-I/nth-root.pli new file mode 100644 index 0000000000..f957041c9f --- /dev/null +++ b/Task/Nth-root/PL-I/nth-root.pli @@ -0,0 +1,13 @@ +/* Finds the N-th root of the number A */ +root: procedure (A, N) returns (float); + declare A float, N fixed binary; + declare (xi, xip1) float; + + xi = 1; /* An initial guess */ + do forever; + xip1 = ((n-1)*xi + A/xi**(n-1) ) / n; + if abs(xip1-xi) < 1e-5 then leave; + xi = xip1; + end; + return (xi); +end root; diff --git a/Task/Nth-root/Perl-6/nth-root.pl6 b/Task/Nth-root/Perl-6/nth-root.pl6 new file mode 100644 index 0000000000..e0056fea42 --- /dev/null +++ b/Task/Nth-root/Perl-6/nth-root.pl6 @@ -0,0 +1,11 @@ +sub nth-root ($n, $A, $p=1e-9) +{ + my $x0 = $A / $n; + loop { + my $x1 = (($n-1) * $x0 + $A / ($x0 ** ($n-1))) / $n; + return $x1 if abs($x1-$x0) < abs($x0 * $p); + $x0 = $x1; + } +} + +say nth-root(3,8); diff --git a/Task/Nth-root/Perl/nth-root-1.pl b/Task/Nth-root/Perl/nth-root-1.pl new file mode 100644 index 0000000000..c09d23f2d7 --- /dev/null +++ b/Task/Nth-root/Perl/nth-root-1.pl @@ -0,0 +1,14 @@ +use strict; + +sub nthroot ($$) +{ + my ( $n, $A ) = @_; + + my $x0 = $A / $n; + my $m = $n - 1.0; + while(1) { + my $x1 = ($m * $x0 + $A / ($x0 ** $m)) / $n; + return $x1 if abs($x1 - $x0) < abs($x0 * 1e-9); + $x0 = $x1; + } +} diff --git a/Task/Nth-root/Perl/nth-root-2.pl b/Task/Nth-root/Perl/nth-root-2.pl new file mode 100644 index 0000000000..043499dd56 --- /dev/null +++ b/Task/Nth-root/Perl/nth-root-2.pl @@ -0,0 +1,3 @@ +print nthroot(5, 34), "\n"; +print nthroot(10, 7131.5 ** 10), "\n"; +print nthroot(0.5, 7), "\n"; diff --git a/Task/Nth-root/PicoLisp/nth-root.l b/Task/Nth-root/PicoLisp/nth-root.l new file mode 100644 index 0000000000..6ba97e0386 --- /dev/null +++ b/Task/Nth-root/PicoLisp/nth-root.l @@ -0,0 +1,17 @@ +(load "@lib/math.l") + +(de nthRoot (N A) + (let (X1 A X2 (*/ A N)) + (until (= X1 X2) + (setq + X1 X2 + X2 (*/ + (+ + (* X1 (dec N)) + (*/ A 1.0 (pow X1 (* (dec N) 1.0))) ) + N ) ) ) + X2 ) ) + +(prinl (format (nthroot 2 2.0) *Scl)) +(prinl (format (nthroot 3 12.3) *Scl)) +(prinl (format (nthroot 4 45.6) *Scl)) diff --git a/Task/Nth-root/PureBasic/nth-root.purebasic b/Task/Nth-root/PureBasic/nth-root.purebasic new file mode 100644 index 0000000000..3f37227b26 --- /dev/null +++ b/Task/Nth-root/PureBasic/nth-root.purebasic @@ -0,0 +1,19 @@ +#Def_p=0.001 + +Procedure.d Nth_root(n.i, A.d, p.d=#Def_p) + Protected Dim x.d(1) + x(0)=A: x(1)=A/n + While Abs(x(1)-x(0))>p + x(0)=x(1) + x(1)=((n-1.0)*x(1)+A/Pow(x(1),n-1.0))/n + Wend + ProcedureReturn x(1) +EndProcedure + +;////////////////////////////// +Debug "125'th root of 5642 is" +Debug Pow(5642,1/125) +Debug "First estimate is:" +Debug Nth_root(125,5642) +Debug "And better:" +Debug Nth_root(125,5642,0.00001) diff --git a/Task/Nth-root/Python/nth-root-1.py b/Task/Nth-root/Python/nth-root-1.py new file mode 100644 index 0000000000..0c7d1b753e --- /dev/null +++ b/Task/Nth-root/Python/nth-root-1.py @@ -0,0 +1,13 @@ +from decimal import Decimal, getcontext + +def nthroot (n, A, precision): + getcontext().prec = precision + + n = Decimal(n) + x_0 = A / n #step 1: make a while guess. + x_1 = 1 #need it to exist before step 2 + while True: + #step 2: + x_0, x_1 = x_1, (1 / n)*((n - 1)*x_0 + (A / (x_0 ** (n - 1)))) + if x_0 == x_1: + return x_1 diff --git a/Task/Nth-root/Python/nth-root-2.py b/Task/Nth-root/Python/nth-root-2.py new file mode 100644 index 0000000000..5e9a52335f --- /dev/null +++ b/Task/Nth-root/Python/nth-root-2.py @@ -0,0 +1,3 @@ +print nthroot(5, 34, 10) +print nthroot(10,42, 20) +print nthroot(2, 5, 400) diff --git a/Task/Nth-root/R/nth-root.r b/Task/Nth-root/R/nth-root.r new file mode 100644 index 0000000000..b1e4c8fc66 --- /dev/null +++ b/Task/Nth-root/R/nth-root.r @@ -0,0 +1,12 @@ +nthroot <- function(A, n, tol=sqrt(.Machine$double.eps)) +{ + ifelse(A < 1, x0 <- A * n, x0 <- A / n) + repeat + { + x1 <- ((n-1)*x0 + A / x0^(n-1))/n + if(abs(x1 - x0) > tol) x0 <- x1 else break + } + x1 +} +nthroot(7131.5^10, 10) # 7131.5 +nthroot(7, 0.5) # 49 diff --git a/Task/Nth-root/REXX/nth-root.rexx b/Task/Nth-root/REXX/nth-root.rexx new file mode 100644 index 0000000000..a3c8430c9b --- /dev/null +++ b/Task/Nth-root/REXX/nth-root.rexx @@ -0,0 +1,39 @@ +/*REXX program calculates the Nth root of X, with DIGS accuracy. */ +parse arg x root digs . /*get specified args from the CL.*/ +if x=='' then x=2 /*Not specified? Then use default*/ +if root=='' then root=2 /* " " " " " */ +if digs=='' then digs=65 /* " " " " " */ +numeric digits digs /*set the precision to DIGS. */ +say ' x = ' x /*echo the value of X. */ +say ' root = ' root /*echo the value of ROOT. */ +say ' digits = ' digs /*echo the value of DIGS. */ +say ' answer = ' root(x,root) /*show the value of ANSWER. */ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────ROOT subroutine─────────────────────*/ +root: procedure; parse arg x 1 Ox,r . 1 Or /*1st arg──►x&Ox, 2nd──►r&Or*/ +if r=='' then r=2 /*Was root specified? Assume √.*/ +if r=0 then return '[n/a]' /*oops-ay! Can't do zeroth root.*/ +complex= x<0 & R//2==0 /*will the result be complex? */ +oDigs=digits() /*get the current number of digs.*/ +if x=0 | r=1 then return x/1 /*handle couple of special cases.*/ +dm=oDigs+5 /*we need a little guard room. */ +r=abs(r); x=abs(x) /*the absolute values of R and X.*/ +rm=r-1 /*just a fast version of ROOT -1*/ +numeric form /*take a good guess at the root─┐*/ +parse value format(x,2,1,,0) 'E0' with ? 'E' _ . /* ◄───────────┘*/ +g=(?/r'E'_%r)+(x>1) /*kinda uses a crude "logrithm". */ +numeric fuzz 3 /*fuzz digits for higher roots. */ +d=5 /*start with only five digits. */ + do until d==dm; d=min(d+d,dm) /*each interation doubles prec. */ + numeric digits d /*tell REXX to use D digits. */ + old=-1 /*assume some kind of old guess. */ + do until old=g; old=g /*where da rubber meets da road─┐*/ + g=(rm*g**r+x) / r / g**rm /*nitty-gritty root computation◄┘*/ + end /*until old=g*/ /*maybe until the cows come home.*/ + end /*until d==dm*/ /*and wait for more cows to come.*/ + +if g=0 then return 0 /*in case the jillionth root = 0.*/ +if Or<0 then g=1/g /*root < 0 ? Reciprocal it is!*/ +if \complex then g=g*sign(Ox) /*adjust the sign (maybe). */ +numeric digits oDigs /*reinstate the original digits. */ +return g/1 || left('j',complex) /*normalize # to digs, append j ?*/ diff --git a/Task/Nth-root/Ruby/nth-root.rb b/Task/Nth-root/Ruby/nth-root.rb new file mode 100644 index 0000000000..2906f2cda9 --- /dev/null +++ b/Task/Nth-root/Ruby/nth-root.rb @@ -0,0 +1,10 @@ +def nthroot(n, a, precision = 1e-5) + x = Float(a) + begin + prev = x + x = ((n - 1) * prev + a / (prev ** (n - 1))) / n + end while (prev - x).abs > precision + x +end + +p nthroot(5,34) # => 2.02439745849989 diff --git a/Task/Nth-root/Run-BASIC/nth-root.run b/Task/Nth-root/Run-BASIC/nth-root.run new file mode 100644 index 0000000000..74339128e7 --- /dev/null +++ b/Task/Nth-root/Run-BASIC/nth-root.run @@ -0,0 +1,21 @@ +print "Root 125th Root of 5643 Precision .001 ";using( "#.###############", NthRoot( 125, 5642, 0.001 )) +print "125th Root of 5643 Precision .001 ";using( "#.###############", NthRoot( 125, 5642, 0.001 )) +print "125th Root of 5643 Precision .00001 ";using( "#.###############", NthRoot( 125, 5642, 0.00001)) +print " 3rd Root of 27 Precision .00001 ";using( "#.###############", NthRoot( 3, 27, 0.00001)) +print " 2nd Root of 2 Precision .00001 ";using( "#.###############", NthRoot( 2, 2, 0.00001)) +print " 10th Root of 1024 Precision .00001 ";using( "#.###############", NthRoot( 10, 1024, 0.00001)) + +wait + +function NthRoot( root, A, precision) + x0 = A + x1 = A /root + while abs( x1 -x0) >precision + x0 = x1 + x1 = x1 / 1.0 ' force float + x1 = (( root -1.0) *x1 +A /x1^( root -1.0)) /root + wend + NthRoot =x1 +end function + +end diff --git a/Task/Nth-root/Sather/nth-root-1.sa b/Task/Nth-root/Sather/nth-root-1.sa new file mode 100644 index 0000000000..d1e7d0220b --- /dev/null +++ b/Task/Nth-root/Sather/nth-root-1.sa @@ -0,0 +1,16 @@ +class MATH is + nthroot(n:INT, a:FLT):FLT + pre n > 0 + is + x0 ::= a / n.flt; + m ::= n - 1; + loop + x1 ::= (m.flt * x0 + a/(x0^(m.flt))) / n.flt; + if (x1 - x0).abs < (x0 * 1.0e-9).abs then + return x1; + end; + x0 := x1; + end; + end; + +end; diff --git a/Task/Nth-root/Sather/nth-root-2.sa b/Task/Nth-root/Sather/nth-root-2.sa new file mode 100644 index 0000000000..4e8ebc42ab --- /dev/null +++ b/Task/Nth-root/Sather/nth-root-2.sa @@ -0,0 +1,6 @@ +class MAIN is + main is + a:FLT := 2.5 ^ 10.0; + #OUT + MATH::nthroot(10, a) + "\n"; + end; +end; diff --git a/Task/Nth-root/Scala/nth-root.scala b/Task/Nth-root/Scala/nth-root.scala new file mode 100644 index 0000000000..999daa2faa --- /dev/null +++ b/Task/Nth-root/Scala/nth-root.scala @@ -0,0 +1,16 @@ +object NthRoot { + + def main(args: Array[String]) { + println(nthroot(3, 32)) + } + + def nthroot1(n: Int, a: Double): Double = { + def loop(x0: Double) : Double = { + val x1 = (1.0d/n * ((n - 1) * x0 + a/math.pow(x0, n-1))) + if (x0 <= x1) x0 + else loop(x1) + } + + return loop(a/2) + } +} diff --git a/Task/Nth-root/Scheme/nth-root.ss b/Task/Nth-root/Scheme/nth-root.ss new file mode 100644 index 0000000000..6c4725c542 --- /dev/null +++ b/Task/Nth-root/Scheme/nth-root.ss @@ -0,0 +1,18 @@ +(define (root number degree tolerance) + (define (good-enough? next guess) + (< (abs (- next guess)) tolerance)) + (define (improve guess) + (/ (+ (* (- degree 1) guess) (/ number (expt guess (- degree 1)))) degree)) + (define (*root guess) + (let ((next (improve guess))) + (if (good-enough? next guess) + guess + (*root next)))) + (*root 1.0)) + +(display (root (expt 2 10) 10 0.1)) +(newline) +(display (root (expt 2 10) 10 0.01)) +(newline) +(display (root (expt 2 10) 10 0.001)) +(newline) diff --git a/Task/Nth-root/Seed7/nth-root.seed7 b/Task/Nth-root/Seed7/nth-root.seed7 new file mode 100644 index 0000000000..88d7934609 --- /dev/null +++ b/Task/Nth-root/Seed7/nth-root.seed7 @@ -0,0 +1,13 @@ +const func float: nthRoot (in integer: n, in float: a) is func + result + var float: x1 is 0.0; + local + var float: x0 is 0.0; + begin + x0 := a; + x1 := a / flt(n); + while abs(x1 - x0) >= abs(x0 * 1.0E-9) do + x0 := x1; + x1 := (flt(pred(n)) * x0 + a / x0 ** pred(n)) / flt(n); + end while; + end func; diff --git a/Task/Nth-root/Smalltalk/nth-root-1.st b/Task/Nth-root/Smalltalk/nth-root-1.st new file mode 100644 index 0000000000..a9e87ddf4a --- /dev/null +++ b/Task/Nth-root/Smalltalk/nth-root-1.st @@ -0,0 +1,13 @@ +Number extend [ + nthRoot: n [ + |x0 m x1| + x0 := (self / n) asFloatD. + m := n - 1. + [true] whileTrue: [ + x1 := ( (m * x0) + (self/(x0 raisedTo: m))) / n. + ((x1 - x0) abs) < ((x0 * 1e-9) abs) + ifTrue: [ ^ x1 ]. + x0 := x1 + ] + ] +]. diff --git a/Task/Nth-root/Smalltalk/nth-root-2.st b/Task/Nth-root/Smalltalk/nth-root-2.st new file mode 100644 index 0000000000..e9f4fb1ee5 --- /dev/null +++ b/Task/Nth-root/Smalltalk/nth-root-2.st @@ -0,0 +1,3 @@ +(34 nthRoot: 5) displayNl. +((7131.5 raisedTo: 10) nthRoot: 10) displayNl. +(7 nthRoot: 0.5) displayNl. diff --git a/Task/Nth-root/Tcl/nth-root-1.tcl b/Task/Nth-root/Tcl/nth-root-1.tcl new file mode 100644 index 0000000000..37d37551ca --- /dev/null +++ b/Task/Nth-root/Tcl/nth-root-1.tcl @@ -0,0 +1,3 @@ +proc nthroot {n A} { + expr {pow($A, 1.0/$n)} +} diff --git a/Task/Nth-root/Tcl/nth-root-2.tcl b/Task/Nth-root/Tcl/nth-root-2.tcl new file mode 100644 index 0000000000..56cc011152 --- /dev/null +++ b/Task/Nth-root/Tcl/nth-root-2.tcl @@ -0,0 +1,11 @@ +proc nthroot {n A} { + set x0 [expr {$A / double($n)}] + set m [expr {$n - 1.0}] + while 1 { + set x1 [expr {($m*$x0 + $A/$x0**$m) / $n}] + if {abs($x1 - $x0) < abs($x0 * 1e-9)} { + return $x1 + } + set x0 $x1 + } +} diff --git a/Task/Nth-root/Tcl/nth-root-3.tcl b/Task/Nth-root/Tcl/nth-root-3.tcl new file mode 100644 index 0000000000..b6fa45bc95 --- /dev/null +++ b/Task/Nth-root/Tcl/nth-root-3.tcl @@ -0,0 +1,5 @@ +puts [nthroot 2 2] +puts [nthroot 5 34] +puts [nthroot 5 [expr {34**5}]] +puts [nthroot 10 [expr 7131.5**10]] +puts [nthroot 0.5 7]; # Squaring! diff --git a/Task/Nth-root/Ursala/nth-root-1.ursala b/Task/Nth-root/Ursala/nth-root-1.ursala new file mode 100644 index 0000000000..cce0a03466 --- /dev/null +++ b/Task/Nth-root/Ursala/nth-root-1.ursala @@ -0,0 +1,8 @@ +#import nat +#import flo + +nthroot = + +-+ + ("n","n-1"). "A". ("x". div\"n" plus/times("n-1","x") div("A",pow("x","n-1")))^== 1., + float^~/~& predecessor+- diff --git a/Task/Nth-root/Ursala/nth-root-2.ursala b/Task/Nth-root/Ursala/nth-root-2.ursala new file mode 100644 index 0000000000..98a075c8ab --- /dev/null +++ b/Task/Nth-root/Ursala/nth-root-2.ursala @@ -0,0 +1,9 @@ +#cast %eL + +examples = + +< + nthroot2 2., + nthroot5 34., + nthroot5 pow(34.,5.), + nthroot10 pow(7131.5,10.)> diff --git a/Task/Nth-root/XPL0/nth-root.xpl0 b/Task/Nth-root/XPL0/nth-root.xpl0 new file mode 100644 index 0000000000..c29d27d80a --- /dev/null +++ b/Task/Nth-root/XPL0/nth-root.xpl0 @@ -0,0 +1,21 @@ +include c:\cxpl\stdlib; + +func real NRoot(A, N); \Return the Nth root of A +real A, N; +real X, X0, Y; +int I; +[X:= 1.0; \initial guess +repeat X0:= X; + Y:= 1.0; + for I:= 1 to fix(N)-1 do Y:= Y*X0; + X:= ((N-1.0)*X0 + A/Y) / N; +until abs(X-X0) < 1.0E-15; \(until X=X0 doesn't always work) +return X; +]; + +[Format(5, 15); +RlOut(0, NRoot( 2., 2.)); CrLf(0); +RlOut(0, Power( 2., 0.5)); CrLf(0); \for comparison +RlOut(0, NRoot(27., 3.)); CrLf(0); +RlOut(0, NRoot(1024.,10.)); CrLf(0); +] diff --git a/Task/Null-object/0DESCRIPTION b/Task/Null-object/0DESCRIPTION new file mode 100644 index 0000000000..aee9a0dda6 --- /dev/null +++ b/Task/Null-object/0DESCRIPTION @@ -0,0 +1,5 @@ +'''Null''' (or '''nil''') is the computer science concept of an undefined or unbound object. Some languages have an explicit way to access the null object, and some don't. Some languages distinguish the null object from [[undefined values]], and some don't. + +Show how to access null in your language by checking to see if an object is equivalent to the null object. + +''This task is not about whether a variable is defined. The task is about "null"-like values in various languages, which may or may not be related to the defined-ness of variables in your language.'' diff --git a/Task/Null-object/1META.yaml b/Task/Null-object/1META.yaml new file mode 100644 index 0000000000..659c8686af --- /dev/null +++ b/Task/Null-object/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Basic language learning diff --git a/Task/Null-object/ALGOL-68/null-object.alg b/Task/Null-object/ALGOL-68/null-object.alg new file mode 100644 index 0000000000..cde62d7157 --- /dev/null +++ b/Task/Null-object/ALGOL-68/null-object.alg @@ -0,0 +1,19 @@ +REF STRING no result = NIL; +STRING result := ""; + +IF no result :=: NIL THEN print(("no result :=: NIL", new line)) FI; +IF result :/=: NIL THEN print(("result :/=: NIL", new line)) FI; + +IF no result IS NIL THEN print(("no result IS NIL", new line)) FI; +IF result ISNT NIL THEN print(("result ISNT NIL", new line)) FI; + +COMMENT using the UNESCO/IFIP/WG2.1 ALGOL 68 character set + result := °; + IF REF STRING(result) :≠: ° THEN print(("result ≠ °", new line)) FI; +END COMMENT + +# Note the following gotcha: # + +REF STRING var := NIL; +IF var ISNT NIL THEN print(("The address of var ISNT NIL",new line)) FI; +IF var IS REF STRING(NIL) THEN print(("The address of var IS REF STRING(NIL)",new line)) FI diff --git a/Task/Null-object/ActionScript/null-object.as b/Task/Null-object/ActionScript/null-object.as new file mode 100644 index 0000000000..12f14d1b53 --- /dev/null +++ b/Task/Null-object/ActionScript/null-object.as @@ -0,0 +1,2 @@ +if (object == null) + trace("object is null"); diff --git a/Task/Null-object/Ada/null-object.ada b/Task/Null-object/Ada/null-object.ada new file mode 100644 index 0000000000..4f3f8f82de --- /dev/null +++ b/Task/Null-object/Ada/null-object.ada @@ -0,0 +1,5 @@ +with Ada.Text_Io; + +if Object = null then + Ada.Text_Io.Put_line("object is null"); +end if; diff --git a/Task/Null-object/AmigaE/null-object.amiga b/Task/Null-object/AmigaE/null-object.amiga new file mode 100644 index 0000000000..adf96225cd --- /dev/null +++ b/Task/Null-object/AmigaE/null-object.amiga @@ -0,0 +1,5 @@ +DEF x : PTR TO object +-> ... +IF object <> NIL + -> ... +ENDIF diff --git a/Task/Null-object/AppleScript/null-object.applescript b/Task/Null-object/AppleScript/null-object.applescript new file mode 100644 index 0000000000..ba49b6039b --- /dev/null +++ b/Task/Null-object/AppleScript/null-object.applescript @@ -0,0 +1,7 @@ +if x is missing value then + display dialog "x is missing value" +end if + +if x is null then + display dialog "x is null" +end if diff --git a/Task/Null-object/AutoHotkey/null-object.ahk b/Task/Null-object/AutoHotkey/null-object.ahk new file mode 100644 index 0000000000..81f72bb47e --- /dev/null +++ b/Task/Null-object/AutoHotkey/null-object.ahk @@ -0,0 +1,2 @@ +If (object == null) + MsgBox, object is null diff --git a/Task/Null-object/BBC-BASIC/null-object.bbc b/Task/Null-object/BBC-BASIC/null-object.bbc new file mode 100644 index 0000000000..6480acd3a8 --- /dev/null +++ b/Task/Null-object/BBC-BASIC/null-object.bbc @@ -0,0 +1,13 @@ + PROCtestobjects + END + + DEF PROCtestobjects + PRIVATE a(), b(), s{}, t{} + DIM a(123) + DIM s{a%, b#, c$} + + IF !^a() <= 1 PRINT "a() is null" ELSE PRINT "a() is not null" + IF !^b() <= 1 PRINT "b() is null" ELSE PRINT "b() is not null" + IF !^s{} <= 1 PRINT "s{} is null" ELSE PRINT "s{} is not null" + IF !^t{} <= 1 PRINT "t{} is null" ELSE PRINT "t{} is not null" + ENDPROC diff --git a/Task/Null-object/Babel/null-object.pb b/Task/Null-object/Babel/null-object.pb new file mode 100644 index 0000000000..471f7843a6 --- /dev/null +++ b/Task/Null-object/Babel/null-object.pb @@ -0,0 +1 @@ +{ nil { nil? } { "Whew!\n" } { "Something is terribly wrong!\n" } ifte << } diff --git a/Task/Null-object/C++/null-object-1.cpp b/Task/Null-object/C++/null-object-1.cpp new file mode 100644 index 0000000000..3de64d3a7d --- /dev/null +++ b/Task/Null-object/C++/null-object-1.cpp @@ -0,0 +1,5 @@ +#include +#include +if (object == 0) { + std::cout << "object is null"; +} diff --git a/Task/Null-object/C++/null-object-2.cpp b/Task/Null-object/C++/null-object-2.cpp new file mode 100644 index 0000000000..5579ccaf48 --- /dev/null +++ b/Task/Null-object/C++/null-object-2.cpp @@ -0,0 +1,12 @@ +#include +#include + +boost::optional maybeInt() + +int main() +{ + boost::optional maybe = maybeInt(); + + if(!maybe) + std::cout << "object is null\n"; +} diff --git a/Task/Null-object/C/null-object.c b/Task/Null-object/C/null-object.c new file mode 100644 index 0000000000..15f7e4e754 --- /dev/null +++ b/Task/Null-object/C/null-object.c @@ -0,0 +1,11 @@ +#include + +int main() +{ + char *object = 0; + + if (object == NULL) { + puts("object is null"); + } + return 0; +} diff --git a/Task/Null-object/Clojure/null-object-1.clj b/Task/Null-object/Clojure/null-object-1.clj new file mode 100644 index 0000000000..4350a6fcb2 --- /dev/null +++ b/Task/Null-object/Clojure/null-object-1.clj @@ -0,0 +1,2 @@ +(let [x nil] + (println "Object is" (if (nil? x) "nil" "not nil"))) diff --git a/Task/Null-object/Clojure/null-object-2.clj b/Task/Null-object/Clojure/null-object-2.clj new file mode 100644 index 0000000000..028dc197b6 --- /dev/null +++ b/Task/Null-object/Clojure/null-object-2.clj @@ -0,0 +1 @@ +(find (ns-interns *ns*) 'foo) diff --git a/Task/Null-object/Clojure/null-object-3.clj b/Task/Null-object/Clojure/null-object-3.clj new file mode 100644 index 0000000000..f995700b1b --- /dev/null +++ b/Task/Null-object/Clojure/null-object-3.clj @@ -0,0 +1 @@ +(ns-unmap *ns* 'foo) diff --git a/Task/Null-object/Common-Lisp/null-object-1.lisp b/Task/Null-object/Common-Lisp/null-object-1.lisp new file mode 100644 index 0000000000..e47f910b7b --- /dev/null +++ b/Task/Null-object/Common-Lisp/null-object-1.lisp @@ -0,0 +1 @@ +(if (condition) (do-this)) diff --git a/Task/Null-object/Common-Lisp/null-object-2.lisp b/Task/Null-object/Common-Lisp/null-object-2.lisp new file mode 100644 index 0000000000..39604874f1 --- /dev/null +++ b/Task/Null-object/Common-Lisp/null-object-2.lisp @@ -0,0 +1,5 @@ +(defmethod car* ((arg cons)) + (car arg)) + +(defmethod car* ((arg null)) + nil) diff --git a/Task/Null-object/Common-Lisp/null-object-3.lisp b/Task/Null-object/Common-Lisp/null-object-3.lisp new file mode 100644 index 0000000000..b615e5952a --- /dev/null +++ b/Task/Null-object/Common-Lisp/null-object-3.lisp @@ -0,0 +1,2 @@ +(defmethod car* ((arg t)) ;; can just be written (defmethod car* (arg) ...) + (error "CAR*: ~s is neither a cons nor nil" arg)) diff --git a/Task/Null-object/Component-Pascal/null-object.component b/Task/Null-object/Component-Pascal/null-object.component new file mode 100644 index 0000000000..4a93f372c4 --- /dev/null +++ b/Task/Null-object/Component-Pascal/null-object.component @@ -0,0 +1,17 @@ +MODULE ObjectNil; +IMPORT StdLog; +TYPE + Object = POINTER TO ObjectDesc; + ObjectDesc = RECORD + END; +VAR + x: Object; (* default initialization to NIL *) + +PROCEDURE DoIt*; +BEGIN + IF x = NIL THEN + StdLog.String("x is NIL");StdLog.Ln + END +END DoIt; + +END ObjectNil. diff --git a/Task/Null-object/D/null-object.d b/Task/Null-object/D/null-object.d new file mode 100644 index 0000000000..b3998df4b7 --- /dev/null +++ b/Task/Null-object/D/null-object.d @@ -0,0 +1,12 @@ +import std.stdio; + +class K {} + +void main() { + K k; + if (k is null) + writeln("k is null"); + k = new K; + if (k !is null) + writeln("Now k is not null"); +} diff --git a/Task/Null-object/Delphi/null-object.delphi b/Task/Null-object/Delphi/null-object.delphi new file mode 100644 index 0000000000..fb057c3426 --- /dev/null +++ b/Task/Null-object/Delphi/null-object.delphi @@ -0,0 +1,6 @@ + // the following are equivalent + if lObject = nil then + ... + + if not Assigned(lObject) then + ... diff --git a/Task/Null-object/E/null-object.e b/Task/Null-object/E/null-object.e new file mode 100644 index 0000000000..da3d06b1af --- /dev/null +++ b/Task/Null-object/E/null-object.e @@ -0,0 +1 @@ +object == null diff --git a/Task/Null-object/Factor/null-object.factor b/Task/Null-object/Factor/null-object.factor new file mode 100644 index 0000000000..db5973fb1d --- /dev/null +++ b/Task/Null-object/Factor/null-object.factor @@ -0,0 +1 @@ +: is-f? ( obj -- ? ) f = ; diff --git a/Task/Null-object/Fantom/null-object.fantom b/Task/Null-object/Fantom/null-object.fantom new file mode 100644 index 0000000000..f77829bbf3 --- /dev/null +++ b/Task/Null-object/Fantom/null-object.fantom @@ -0,0 +1,7 @@ +fansh> x := null +fansh> x == null +true +fansh> x = 1 +1 +fansh> x == null +false diff --git a/Task/Null-object/Go/null-object.go b/Task/Null-object/Go/null-object.go new file mode 100644 index 0000000000..8e233fd089 --- /dev/null +++ b/Task/Null-object/Go/null-object.go @@ -0,0 +1,21 @@ +package main + +import "fmt" + +var ( + s []int // slice type + p *int // pointer type + f func() // function type + i interface{} // interface type + m map[int]int // map type + c chan int // channel type +) + +func main() { + fmt.Println(s == nil) + fmt.Println(p == nil) + fmt.Println(f == nil) + fmt.Println(i == nil) + fmt.Println(m == nil) + fmt.Println(c == nil) +} diff --git a/Task/Null-object/Haskell/null-object-1.hs b/Task/Null-object/Haskell/null-object-1.hs new file mode 100644 index 0000000000..67e4f00697 --- /dev/null +++ b/Task/Null-object/Haskell/null-object-1.hs @@ -0,0 +1,3 @@ +undefined -- undefined value provided by the standard library +error "oops" -- another undefined value +head [] -- undefined, you can't take the head of an empty list diff --git a/Task/Null-object/Haskell/null-object-2.hs b/Task/Null-object/Haskell/null-object-2.hs new file mode 100644 index 0000000000..963fcdd913 --- /dev/null +++ b/Task/Null-object/Haskell/null-object-2.hs @@ -0,0 +1 @@ + data Maybe a = Nothing | Just a diff --git a/Task/Null-object/Haskell/null-object-3.hs b/Task/Null-object/Haskell/null-object-3.hs new file mode 100644 index 0000000000..4313e6c876 --- /dev/null +++ b/Task/Null-object/Haskell/null-object-3.hs @@ -0,0 +1,3 @@ +case thing of + Nothing -> "It's Nothing. Or null, whatever." + Just v -> "It's not Nothing; it is " ++ show v ++ "." diff --git a/Task/Null-object/Icon/null-object.icon b/Task/Null-object/Icon/null-object.icon new file mode 100644 index 0000000000..ca608f81f1 --- /dev/null +++ b/Task/Null-object/Icon/null-object.icon @@ -0,0 +1,10 @@ +procedure main() +nulltest("a",a) # unassigned variables are null by default +nulltest("b",b := &null) # explicit assignment is possible +nulltest("c",c := "anything") +nulltest("c",c := &null) # varibables can't be undefined +end + +procedure nulltest(name,var) +return write(name, if /var then " is" else " is not"," null.") +end diff --git a/Task/Null-object/Io/null-object.io b/Task/Null-object/Io/null-object.io new file mode 100644 index 0000000000..6675907ae5 --- /dev/null +++ b/Task/Null-object/Io/null-object.io @@ -0,0 +1 @@ +if(object == nil, "object is nil" println) diff --git a/Task/Null-object/J/null-object-1.j b/Task/Null-object/J/null-object-1.j new file mode 100644 index 0000000000..910bf660de --- /dev/null +++ b/Task/Null-object/J/null-object-1.j @@ -0,0 +1 @@ +isUndefined=: _1 = nc@boxxopen diff --git a/Task/Null-object/J/null-object-2.j b/Task/Null-object/J/null-object-2.j new file mode 100644 index 0000000000..b65cac8b0b --- /dev/null +++ b/Task/Null-object/J/null-object-2.j @@ -0,0 +1,5 @@ + isUndefined 'foo' +1 + foo=:9 + isUndefined 'foo' +0 diff --git a/Task/Null-object/J/null-object-3.j b/Task/Null-object/J/null-object-3.j new file mode 100644 index 0000000000..a883108b4f --- /dev/null +++ b/Task/Null-object/J/null-object-3.j @@ -0,0 +1,10 @@ + 1 1 0 1#3 4 _ 5 +3 4 5 + I.1 1 0 1 +0 1 3 + 0 1 3 { 3 4 _ 5 +3 4 5 + 1 1 0 1 #inv 3 4 5 +3 4 0 5 + 1 1 0 1 #!._ inv 3 4 5 +3 4 _ 5 diff --git a/Task/Null-object/Java/null-object.java b/Task/Null-object/Java/null-object.java new file mode 100644 index 0000000000..e2aa046425 --- /dev/null +++ b/Task/Null-object/Java/null-object.java @@ -0,0 +1,4 @@ +// here "object" is a reference +if (object == null) { + System.out.println("object is null"); +} diff --git a/Task/Null-object/JavaScript/null-object.js b/Task/Null-object/JavaScript/null-object.js new file mode 100644 index 0000000000..3d1cf10f87 --- /dev/null +++ b/Task/Null-object/JavaScript/null-object.js @@ -0,0 +1,6 @@ +if (object === null) { + alert("object is null"); + // The object is nothing +} + +typeof null === "object"; // This stands since the beginning of JavaScript diff --git a/Task/Null-object/K/null-object.k b/Task/Null-object/K/null-object.k new file mode 100644 index 0000000000..ea07c87f1c --- /dev/null +++ b/Task/Null-object/K/null-object.k @@ -0,0 +1,6 @@ + (1;;2) ~ (1 ; _n ; 2) / ~ is ''identical to'' or ''match'' . +1 + _n ~' ( 1 ; ; 2 ) / ''match each'' +0 1 0 + +additional properties : _n@i and _n?i are i; _n`v is _n diff --git a/Task/Null-object/Logo/null-object.logo b/Task/Null-object/Logo/null-object.logo new file mode 100644 index 0000000000..c9598fb7ce --- /dev/null +++ b/Task/Null-object/Logo/null-object.logo @@ -0,0 +1,6 @@ +to test :thing +if empty? :thing [print [list or word is empty]] +end + +print empty? [] ; true +print empty? "|| ; true diff --git a/Task/Null-object/Lua/null-object.lua b/Task/Null-object/Lua/null-object.lua new file mode 100644 index 0000000000..2b6120482d --- /dev/null +++ b/Task/Null-object/Lua/null-object.lua @@ -0,0 +1,2 @@ +isnil = (object == nil) +print(isnil) diff --git a/Task/Null-object/MAXScript/null-object.maxscript b/Task/Null-object/MAXScript/null-object.maxscript new file mode 100644 index 0000000000..8071e7f286 --- /dev/null +++ b/Task/Null-object/MAXScript/null-object.maxscript @@ -0,0 +1 @@ +if obj == undefined then print "Obj is undefined" diff --git a/Task/Null-object/MUMPS/null-object.mumps b/Task/Null-object/MUMPS/null-object.mumps new file mode 100644 index 0000000000..55329a02f3 --- /dev/null +++ b/Task/Null-object/MUMPS/null-object.mumps @@ -0,0 +1,18 @@ +CACHE>WRITE $DATA(VARI) +0 +CACHE>SET VARI="HELLO" WRITE $DATA(VARI) +1 +CACHE>NEW VARI WRITE $DATA(VARI) ;Change to a new scope +0 +CACHE 1S1>SET VARI(1,2)="DOWN" WRITE $DATA(VARI) +10 +CACHE 1S1>WRITE $DATA(VARI(1)) +10 +CACHE 1S1>WRITE $D(VARI(1,2)) +1 +CACHE 1S1>SET VARI(1)="UP" WRITE $DATA(VARI(1)) +11 +QUIT ;Leave the scope + +W $DATA(VARI)," ",VARI +1 HELLO diff --git a/Task/Null-object/Mathematica/null-object-1.math b/Task/Null-object/Mathematica/null-object-1.math new file mode 100644 index 0000000000..9ae5be1af9 --- /dev/null +++ b/Task/Null-object/Mathematica/null-object-1.math @@ -0,0 +1 @@ +x=Null; diff --git a/Task/Null-object/Mathematica/null-object-2.math b/Task/Null-object/Mathematica/null-object-2.math new file mode 100644 index 0000000000..382c5571c5 --- /dev/null +++ b/Task/Null-object/Mathematica/null-object-2.math @@ -0,0 +1,3 @@ +x =. +x = (1 + 2;) +FullForm[x] diff --git a/Task/Null-object/Mathematica/null-object-3.math b/Task/Null-object/Mathematica/null-object-3.math new file mode 100644 index 0000000000..2f476de67c --- /dev/null +++ b/Task/Null-object/Mathematica/null-object-3.math @@ -0,0 +1 @@ +SameQ[x,Null] diff --git a/Task/Null-object/Mathematica/null-object-4.math b/Task/Null-object/Mathematica/null-object-4.math new file mode 100644 index 0000000000..257fccd4ce --- /dev/null +++ b/Task/Null-object/Mathematica/null-object-4.math @@ -0,0 +1 @@ +x===Null diff --git a/Task/Null-object/Mathematica/null-object-5.math b/Task/Null-object/Mathematica/null-object-5.math new file mode 100644 index 0000000000..234c60272d --- /dev/null +++ b/Task/Null-object/Mathematica/null-object-5.math @@ -0,0 +1,4 @@ +x =.; +ValueQ[x] +x = 3; +ValueQ[x] diff --git a/Task/Null-object/Mathematica/null-object-6.math b/Task/Null-object/Mathematica/null-object-6.math new file mode 100644 index 0000000000..91d6f80f27 --- /dev/null +++ b/Task/Null-object/Mathematica/null-object-6.math @@ -0,0 +1,2 @@ +False +True diff --git a/Task/Null-object/Modula-3/null-object-1.mod3 b/Task/Null-object/Modula-3/null-object-1.mod3 new file mode 100644 index 0000000000..68c9d1edaa --- /dev/null +++ b/Task/Null-object/Modula-3/null-object-1.mod3 @@ -0,0 +1 @@ +VAR foo := NIL diff --git a/Task/Null-object/Modula-3/null-object-2.mod3 b/Task/Null-object/Modula-3/null-object-2.mod3 new file mode 100644 index 0000000000..47bce51b8d --- /dev/null +++ b/Task/Null-object/Modula-3/null-object-2.mod3 @@ -0,0 +1 @@ +VAR foo: REF INTEGER := NIL; diff --git a/Task/Null-object/Modula-3/null-object-3.mod3 b/Task/Null-object/Modula-3/null-object-3.mod3 new file mode 100644 index 0000000000..b640592e4b --- /dev/null +++ b/Task/Null-object/Modula-3/null-object-3.mod3 @@ -0,0 +1,3 @@ +IF foo = NIL THEN + IO.Put("Object is nil.\n"); +END; diff --git a/Task/Null-object/NetRexx/null-object.netrexx b/Task/Null-object/NetRexx/null-object.netrexx new file mode 100644 index 0000000000..db2051e675 --- /dev/null +++ b/Task/Null-object/NetRexx/null-object.netrexx @@ -0,0 +1,6 @@ +/* NetRexx */ +options replace format comments java crossref symbols binary + +robject = Rexx -- create an object for which the value is undefined +say String.valueOf(robject) -- will report the text "null" +if robject = null then say 'Really, it''s "null"!' diff --git a/Task/Null-object/OCaml/null-object-1.ocaml b/Task/Null-object/OCaml/null-object-1.ocaml new file mode 100644 index 0000000000..d6813a040a --- /dev/null +++ b/Task/Null-object/OCaml/null-object-1.ocaml @@ -0,0 +1 @@ +type 'a option = None | Some of 'a diff --git a/Task/Null-object/OCaml/null-object-2.ocaml b/Task/Null-object/OCaml/null-object-2.ocaml new file mode 100644 index 0000000000..e4195d3737 --- /dev/null +++ b/Task/Null-object/OCaml/null-object-2.ocaml @@ -0,0 +1,3 @@ +match v with +| None -> "unbound value" +| Some _ -> "bounded value" diff --git a/Task/Null-object/Objeck/null-object.objeck b/Task/Null-object/Objeck/null-object.objeck new file mode 100644 index 0000000000..28f60a7dd0 --- /dev/null +++ b/Task/Null-object/Objeck/null-object.objeck @@ -0,0 +1,4 @@ +# here "object" is a reference +if(object = Nil) { + "object is null"->PrintLine(); +}; diff --git a/Task/Null-object/Objective-C/null-object-1.m b/Task/Null-object/Objective-C/null-object-1.m new file mode 100644 index 0000000000..6bf0e57170 --- /dev/null +++ b/Task/Null-object/Objective-C/null-object-1.m @@ -0,0 +1,4 @@ +// here "object" is an object pointer +if (object == nil) { + NSLog("object is nil"); +} diff --git a/Task/Null-object/Objective-C/null-object-2.m b/Task/Null-object/Objective-C/null-object-2.m new file mode 100644 index 0000000000..0ae8324ef0 --- /dev/null +++ b/Task/Null-object/Objective-C/null-object-2.m @@ -0,0 +1 @@ +[nil fooBar]; diff --git a/Task/Null-object/Oz/null-object-1.oz b/Task/Null-object/Oz/null-object-1.oz new file mode 100644 index 0000000000..e8c1c19dda --- /dev/null +++ b/Task/Null-object/Oz/null-object-1.oz @@ -0,0 +1,4 @@ +declare + X +in + {Show X+2} %% blocks diff --git a/Task/Null-object/Oz/null-object-2.oz b/Task/Null-object/Oz/null-object-2.oz new file mode 100644 index 0000000000..b6ed1038d4 --- /dev/null +++ b/Task/Null-object/Oz/null-object-2.oz @@ -0,0 +1,4 @@ +declare + X = {Value.failed dontTouchMe} +in + {Wait X} %% throws dontTouchMe diff --git a/Task/Null-object/Oz/null-object-3.oz b/Task/Null-object/Oz/null-object-3.oz new file mode 100644 index 0000000000..d5d3971a9f --- /dev/null +++ b/Task/Null-object/Oz/null-object-3.oz @@ -0,0 +1,6 @@ +declare + X = just("Data") +in + case X of nothing then skip + [] just(Result) then {Show Result} + end diff --git a/Task/Null-object/PARI-GP/null-object.pari b/Task/Null-object/PARI-GP/null-object.pari new file mode 100644 index 0000000000..9033f42ce9 --- /dev/null +++ b/Task/Null-object/PARI-GP/null-object.pari @@ -0,0 +1 @@ +foo!='foo diff --git a/Task/Null-object/PHP/null-object.php b/Task/Null-object/PHP/null-object.php new file mode 100644 index 0000000000..d4d4867d95 --- /dev/null +++ b/Task/Null-object/PHP/null-object.php @@ -0,0 +1,3 @@ +$x = NULL; +if (is_null($x)) + echo "\$x is null\n"; diff --git a/Task/Null-object/PL-I/null-object.pli b/Task/Null-object/PL-I/null-object.pli new file mode 100644 index 0000000000..08bac2c6a0 --- /dev/null +++ b/Task/Null-object/PL-I/null-object.pli @@ -0,0 +1,7 @@ +declare x fixed decimal (10); +... +if ^valid(x) then signal error; + +declare y picture 'A9XAAA9'; +... +if ^valid(y) then signal error; diff --git a/Task/Null-object/Perl-6/null-object-1.pl6 b/Task/Null-object/Perl-6/null-object-1.pl6 new file mode 100644 index 0000000000..f3f7e572a8 --- /dev/null +++ b/Task/Null-object/Perl-6/null-object-1.pl6 @@ -0,0 +1,8 @@ +my $var; +say $var.WHAT; # Any() +$var = 42; +say $var.WHAT; # Int() +say $var.defined; # True +$var = Nil; +say $var.WHAT; # Any() +say $var.defined # False diff --git a/Task/Null-object/Perl-6/null-object-2.pl6 b/Task/Null-object/Perl-6/null-object-2.pl6 new file mode 100644 index 0000000000..c320a535b2 --- /dev/null +++ b/Task/Null-object/Perl-6/null-object-2.pl6 @@ -0,0 +1,4 @@ +my Mu $junction; +say $junction.WHAT; # Mu() +$junction = 1 | 2 | 3; +say $junction.WHAT; # Junction() diff --git a/Task/Null-object/Perl-6/null-object-3.pl6 b/Task/Null-object/Perl-6/null-object-3.pl6 new file mode 100644 index 0000000000..52ff25ed2a --- /dev/null +++ b/Task/Null-object/Perl-6/null-object-3.pl6 @@ -0,0 +1,5 @@ +my Str $str; +say $str.WHAT; # Str() +$str = "I am a string."; +say $str.WHAT; # Str() +$str = 42; # (fails) diff --git a/Task/Null-object/Perl/null-object-1.pl b/Task/Null-object/Perl/null-object-1.pl new file mode 100644 index 0000000000..291a1c4388 --- /dev/null +++ b/Task/Null-object/Perl/null-object-1.pl @@ -0,0 +1 @@ +print defined($x) ? 'Defined' : 'Undefined', ".\n"; diff --git a/Task/Null-object/Perl/null-object-2.pl b/Task/Null-object/Perl/null-object-2.pl new file mode 100644 index 0000000000..51706759b1 --- /dev/null +++ b/Task/Null-object/Perl/null-object-2.pl @@ -0,0 +1 @@ +say $number // "unknown"; diff --git a/Task/Null-object/PicoLisp/null-object-1.l b/Task/Null-object/PicoLisp/null-object-1.l new file mode 100644 index 0000000000..3f8b23fb93 --- /dev/null +++ b/Task/Null-object/PicoLisp/null-object-1.l @@ -0,0 +1,2 @@ +(if (not MyNewVariable) + (handle value-is-NIL) ) diff --git a/Task/Null-object/PicoLisp/null-object-2.l b/Task/Null-object/PicoLisp/null-object-2.l new file mode 100644 index 0000000000..b24a35649d --- /dev/null +++ b/Task/Null-object/PicoLisp/null-object-2.l @@ -0,0 +1,2 @@ +(unless MyNewVariable + (handle value-is-NIL) ) diff --git a/Task/Null-object/Pike/null-object.pike b/Task/Null-object/Pike/null-object.pike new file mode 100644 index 0000000000..18b9e3514b --- /dev/null +++ b/Task/Null-object/Pike/null-object.pike @@ -0,0 +1,12 @@ +> mapping bar; +> bar; +Result: 0 +> bar = ([ "foo":0 ]); +> bar->foo; +Result 0; +> zero_type(bar->foo); +Result: 0 +> bar->baz; +Result: 0 +> zero_type(bar->baz); +Result: 1 diff --git a/Task/Null-object/PowerShell/null-object.psh b/Task/Null-object/PowerShell/null-object.psh new file mode 100644 index 0000000000..1a8cf9a154 --- /dev/null +++ b/Task/Null-object/PowerShell/null-object.psh @@ -0,0 +1,3 @@ +if ($null -eq $object) { + ... +} diff --git a/Task/Null-object/PureBasic/null-object.purebasic b/Task/Null-object/PureBasic/null-object.purebasic new file mode 100644 index 0000000000..e194e766a0 --- /dev/null +++ b/Task/Null-object/PureBasic/null-object.purebasic @@ -0,0 +1,3 @@ +If variable = #Null + Debug "Variable has no value" +EndIf diff --git a/Task/Null-object/Python/null-object.py b/Task/Null-object/Python/null-object.py new file mode 100644 index 0000000000..c590af8747 --- /dev/null +++ b/Task/Null-object/Python/null-object.py @@ -0,0 +1,5 @@ +x = None +if x is None: + print "x is None" +else: + print "x is not None" diff --git a/Task/Null-object/R/null-object.r b/Task/Null-object/R/null-object.r new file mode 100644 index 0000000000..0cb1438ae6 --- /dev/null +++ b/Task/Null-object/R/null-object.r @@ -0,0 +1,6 @@ +is.null(NULL) # TRUE +is.null(123) # FALSE +is.null(NA) # FALSE +123==NULL # Empty logical value, with a warning +foo <- function(){} # function that does nothing +foo() # returns NULL diff --git a/Task/Null-object/REBOL/null-object.rebol b/Task/Null-object/REBOL/null-object.rebol new file mode 100644 index 0000000000..6109c17457 --- /dev/null +++ b/Task/Null-object/REBOL/null-object.rebol @@ -0,0 +1,3 @@ +x: none + +print ["x" either none? x ["is"]["isn't"] "none."] diff --git a/Task/Null-object/REXX/null-object.rexx b/Task/Null-object/REXX/null-object.rexx new file mode 100644 index 0000000000..2328ea26c7 --- /dev/null +++ b/Task/Null-object/REXX/null-object.rexx @@ -0,0 +1,13 @@ +/*REXX program demonstrates null strings, and also undefined values. */ + +if symbol('ABC')=="VAR" then say 'variable ABC is defined, value='abc"<<<" + else say "variable ABC isn't defined." +xyz=47 +if symbol('XYZ')=="VAR" then say 'variable XYZ is defined, value='xyz"<<<" + else say "variable XYZ isn't defined." +drop xyz +if symbol('XYZ')=="VAR" then say 'variable XYZ is defined, value='xyz"<<<" + else say "variable XYZ isn't defined." +cat='' +if symbol('CAT')=="VAR" then say 'variable CAT is defined, value='cat"<<<" + else say "variable CAT isn't defined." diff --git a/Task/Null-object/Ruby/null-object.rb b/Task/Null-object/Ruby/null-object.rb new file mode 100644 index 0000000000..9ef3c9201e --- /dev/null +++ b/Task/Null-object/Ruby/null-object.rb @@ -0,0 +1 @@ + puts "object is null" if object.nil? diff --git a/Task/Null-object/Scala/null-object.scala b/Task/Null-object/Scala/null-object.scala new file mode 100644 index 0000000000..8000aa6a28 --- /dev/null +++ b/Task/Null-object/Scala/null-object.scala @@ -0,0 +1,22 @@ +scala> Nil +res0: scala.collection.immutable.Nil.type = List() + +scala> Nil == List() +res1: Boolean = true + +scala> Null +:8: error: not found: value Null + Null + ^ + +scala> null +res3: Null = null + +scala> None +res4: None.type = None + +scala> Unit +res5: Unit.type = object scala.Unit + +scala> val a = println() +a: Unit = () diff --git a/Task/Null-object/Scheme/null-object.ss b/Task/Null-object/Scheme/null-object.ss new file mode 100644 index 0000000000..a63432d22c --- /dev/null +++ b/Task/Null-object/Scheme/null-object.ss @@ -0,0 +1 @@ +(null? object) diff --git a/Task/Null-object/Slate/null-object.slate b/Task/Null-object/Slate/null-object.slate new file mode 100644 index 0000000000..4bc2432221 --- /dev/null +++ b/Task/Null-object/Slate/null-object.slate @@ -0,0 +1 @@ +Nil isNil = True. diff --git a/Task/Null-object/Smalltalk/null-object-1.st b/Task/Null-object/Smalltalk/null-object-1.st new file mode 100644 index 0000000000..30f5247f3e --- /dev/null +++ b/Task/Null-object/Smalltalk/null-object-1.st @@ -0,0 +1,6 @@ +object isNil ifTrue: [ "true block" ] + ifFalse: [ "false block" ]. +nil isNil ifTrue: [ 'true!' displayNl ]. "output: true!" +foo isNil ifTrue: [ 'ouch' displayNl ]. +x := (foo == nil). +x := foo isNil diff --git a/Task/Null-object/Smalltalk/null-object-2.st b/Task/Null-object/Smalltalk/null-object-2.st new file mode 100644 index 0000000000..9805722609 --- /dev/null +++ b/Task/Null-object/Smalltalk/null-object-2.st @@ -0,0 +1,6 @@ +foo := nil. +foo class. "-> UndefinedObject" +foo respondsTo: #'bar'. "asking if a message is implemented" + +foo class compile:'fancyOperation ^ 123'. +foo fancyOperation "->123" diff --git a/Task/Null-object/Standard-ML/null-object-1.ml b/Task/Null-object/Standard-ML/null-object-1.ml new file mode 100644 index 0000000000..930f7ef58a --- /dev/null +++ b/Task/Null-object/Standard-ML/null-object-1.ml @@ -0,0 +1 @@ +datatype 'a option = NONE | SOME of 'a diff --git a/Task/Null-object/Standard-ML/null-object-2.ml b/Task/Null-object/Standard-ML/null-object-2.ml new file mode 100644 index 0000000000..9833c1714e --- /dev/null +++ b/Task/Null-object/Standard-ML/null-object-2.ml @@ -0,0 +1,2 @@ +case v of NONE => "unbound value" + | SOME _ => "bounded value" diff --git a/Task/Null-object/Tcl/null-object-1.tcl b/Task/Null-object/Tcl/null-object-1.tcl new file mode 100644 index 0000000000..ba5948de15 --- /dev/null +++ b/Task/Null-object/Tcl/null-object-1.tcl @@ -0,0 +1 @@ +if {$value eq ""} ... diff --git a/Task/Null-object/Tcl/null-object-2.tcl b/Task/Null-object/Tcl/null-object-2.tcl new file mode 100644 index 0000000000..1f86652b01 --- /dev/null +++ b/Task/Null-object/Tcl/null-object-2.tcl @@ -0,0 +1,3 @@ +if {![info exist nullvar]} ... +if {![info exists arr(nullval)]} ... +if {![dict exists $dic nullval]} ... diff --git a/Task/Number-names/0DESCRIPTION b/Task/Number-names/0DESCRIPTION new file mode 100644 index 0000000000..fb055349cb --- /dev/null +++ b/Task/Number-names/0DESCRIPTION @@ -0,0 +1 @@ +Show how to spell out a number in English. You can use a preexisting implementation or roll your own, but you should support inputs up to at least one million (or the maximum value of your language's default bounded integer type, if that's less). Support for inputs other than positive integers (like zero, negative integers, and floating-point numbers) is optional. diff --git a/Task/Number-names/1META.yaml b/Task/Number-names/1META.yaml new file mode 100644 index 0000000000..8644b2ad9b --- /dev/null +++ b/Task/Number-names/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Arithmetic operations diff --git a/Task/Number-names/ALGOL-68/number-names-1.alg b/Task/Number-names/ALGOL-68/number-names-1.alg new file mode 100644 index 0000000000..437f620249 --- /dev/null +++ b/Task/Number-names/ALGOL-68/number-names-1.alg @@ -0,0 +1,38 @@ +PROC number words = (INT n)STRING:( + # returns a string representation of n in words. Currently + deals with anything from 0 to 999 999 999. # + []STRING digits = []STRING + ("zero","one","two","three","four","five","six","seven","eight","nine")[@0]; + []STRING teens = []STRING + ("ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen")[@0]; + []STRING decades = []STRING + ("twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety")[@2]; + + PROC three digits = (INT n)STRING: ( + # does the conversion for n from 0 to 999. # + INT tens = n MOD 100 OVER 10; + INT units = n MOD 10; + (n >= 100|digits[n OVER 100] + " " + "hundred" + (n MOD 100 /= 0|" and "|"")|"") + + (tens /= 0|(tens = 1|teens[units]|decades[tens] + (units /= 0|"-"|""))|"") + + (units /= 0 AND tens /= 1 OR n = 0|digits[units]|"") + ); + INT m = n OVER 1 000 000; + INT k = n MOD 1 000 000 OVER 1000; + INT u = n MOD 1000; + (m /= 0|three digits(m) + " million"|"") + + (m /= 0 AND (k /= 0 OR u >= 100)|", "|"") + + (k /= 0|three digits(k) + " thousand"|"") + + ((m /= 0 OR k /= 0) AND u > 0 AND u < 100|" and " |: k /= 0 AND u /= 0|", "|"") + + (u /= 0 OR n = 0|three digits(u)|"") + ); + +on logical file end(stand in, (REF FILE f)BOOL: GOTO stop iteration); +on value error(stand in, (REF FILE f)BOOL: GOTO stop iteration); +DO # until user hits EOF # + INT n; + print("n? "); + read((n, new line)); + print((number words(n), new line)) +OD; +stop iteration: + SKIP diff --git a/Task/Number-names/ALGOL-68/number-names-2.alg b/Task/Number-names/ALGOL-68/number-names-2.alg new file mode 100644 index 0000000000..36f3d76bd8 --- /dev/null +++ b/Task/Number-names/ALGOL-68/number-names-2.alg @@ -0,0 +1,89 @@ +MODE EXCEPTION = STRUCT(STRING name, PROC VOID handler); +EXCEPTION value error = ("Value Error", stop); + +PROC raise = (EXCEPTION exception, STRING str error)VOID: ( + put(stand error, (name OF exception,": ",str error, new line)); + handler OF exception +); + +MODE LINT = LONG LONG INT; + +BOOL locale euro := TRUE; + +PROC spell integer = (LINT n)STRING: ( + []STRING tens = []STRING (~, ~, "twenty", "thirty", "forty", + "fifty", "sixty", "seventy", "eighty", "ninety")[@0]; + + []STRING small = []STRING ("zero", "one", "two", "three", "four", "five", + "six", "seven", "eight", "nine", "ten", "eleven", + "twelve", "thirteen", "fourteen", "fifteen", + "sixteen", "seventeen", "eighteen", "nineteen")[@0]; + + []STRING bl = []STRING (~, ~, "m", "b", "tr", "quadr", + "quint", "sext", "sept", "oct", "non", "dec")[@0]; + + PROC nonzero = (STRING c, LINT n)STRING: + IF n = 0 THEN "" ELSE c + spell integer(n) FI; + + PROC big =(INT e, LINT n)STRING: + spell integer(n) + + CASE e+1 IN + #0# "", + #1# " thousand" + OUT + " " + + IF locale euro THEN # handle millard, billard & trillard etc # + bl[e OVER 2 + 1 ]+"ill" + CASE e MOD 2 IN "ard" OUT "ion" ESAC + ELSE + bl[e]+"illion" + FI + ESAC; + + PROC base1000 rev = (LINT in n, PROC (INT,LINT)VOID yield)VOID: ( + # generates the value of the digits of n in base 1000 # + # (i.e. 3-digit chunks), in reverse. # + LINT n := in n; + FOR e FROM 0 WHILE n /= 0 DO + LINT r = n MOD 1000; + n := n OVER 1000; + yield(e, r) + OD + ); + + IF n < 1000 THEN + INT ssn := SHORTEN SHORTEN n; + IF ssn < 0 THEN + raise (value error, "spell integer: negative input"); ~ + ELIF ssn < 20 THEN + small[ssn] + ELIF ssn < 100 THEN + INT a = ssn OVER 10, + b = ssn MOD 10; + tens[a] + nonzero("-", b) + ELIF ssn < 1000 THEN + INT a = ssn OVER 100, + b = ssn MOD 100; + small[a] + " hundred" + ( b NE 0 | " and" | "") + nonzero(" ", b) + FI + ELSE + STRING out := "", sep:=""; + # FOR e, x IN # base1000 rev(n, # DO # + (INT e, LINT x)VOID: + IF x NE 0 THEN + big(e,x) + sep +=: out; + sep := IF e = 0 AND x < 100 THEN " and " ELSE ", " FI + FI + ) + # OD #; + out + FI +); + +PROC example = (LINT n)VOID: + print((whole(n,0),": ", spell integer(n), new line)); + +# examples # +LINT prod := 0; +FOR i TO 6 DO prod := prod * 10**i + i; example(prod) OD; + +example(1278); example(1572); example(2010) diff --git a/Task/Number-names/AWK/number-names.awk b/Task/Number-names/AWK/number-names.awk new file mode 100644 index 0000000000..80b06f05e5 --- /dev/null +++ b/Task/Number-names/AWK/number-names.awk @@ -0,0 +1,50 @@ +# syntax: GAWK -f NUMBER_NAMES.AWK +BEGIN { + init_numtowords() + n = split("-10 0 .1 8 100 123 1001 99999 100000 9123456789 111000000111",arr," ") + for (i=1; i<=n; i++) { + printf("%s = %s\n",arr[i],numtowords(arr[i])) + } + exit(0) +} +# source: The AWK Programming Language, page 75 +function numtowords(n, minus,str) { + if (n < 0) { + n = n * -1 + minus = "minus " + } + if (n == 0) { + str = "zero" + } + else { + str = intowords(n) + } + gsub(/ /," ",str) + return(minus str) +} +function intowords(n) { + n = int(n) + if (n >= 1000000000000) { + return intowords(n/1000000000000) " trillion " intowords(n%1000000000000) + } + if (n >= 1000000000) { + return intowords(n/1000000000) " billion " intowords(n%1000000000) + } + if (n >= 1000000) { + return intowords(n/1000000) " million " intowords(n%1000000) + } + if (n >= 1000) { + return intowords(n/1000) " thousand " intowords(n%1000) + } + if (n >= 100) { + return intowords(n/100) " hundred " intowords(n%100) + } + if (n >= 20) { + return tens[int(n/10)] " " intowords(n%10) + } + return(nums[n]) +} +function init_numtowords() { + split("one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen",nums," ") + split("ten twenty thirty forty fifty sixty seventy eighty ninety",tens," ") +} diff --git a/Task/Number-names/Ada/number-names.ada b/Task/Number-names/Ada/number-names.ada new file mode 100644 index 0000000000..7ad9511865 --- /dev/null +++ b/Task/Number-names/Ada/number-names.ada @@ -0,0 +1,132 @@ +with Ada.Text_IO; + +procedure Integers_In_English is + + type Spellable is range -999_999_999_999_999_999..999_999_999_999_999_999; + function Spell (N : Spellable) return String is + function Twenty (N : Spellable) return String is + begin + case N mod 20 is + when 0 => return "zero"; + when 1 => return "one"; + when 2 => return "two"; + when 3 => return "three"; + when 4 => return "four"; + when 5 => return "five"; + when 6 => return "six"; + when 7 => return "seven"; + when 8 => return "eight"; + when 9 => return "nine"; + when 10 => return "ten"; + when 11 => return "eleven"; + when 12 => return "twelve"; + when 13 => return "thirteen"; + when 14 => return "fourteen"; + when 15 => return "fifteen"; + when 16 => return "sixteen"; + when 17 => return "seventeen"; + when 18 => return "eighteen"; + when others => return "nineteen"; + end case; + end Twenty; + + function Decade (N : Spellable) return String is + begin + case N mod 10 is + when 2 => return "twenty"; + when 3 => return "thirty"; + when 4 => return "forty"; + when 5 => return "fifty"; + when 6 => return "sixty"; + when 7 => return "seventy"; + when 8 => return "eighty"; + when others => return "ninety"; + end case; + end Decade; + + function Hundred (N : Spellable) return String is + begin + if N < 20 then + return Twenty (N); + elsif 0 = N mod 10 then + return Decade (N / 10 mod 10); + else + return Decade (N / 10) & '-' & Twenty (N mod 10); + end if; + end Hundred; + + function Thousand (N : Spellable) return String is + begin + if N < 100 then + return Hundred (N); + elsif 0 = N mod 100 then + return Twenty (N / 100) & " hundred"; + else + return Twenty (N / 100) & " hundred and " & Hundred (N mod 100); + end if; + end Thousand; + + function Triplet + ( N : Spellable; + Order : Spellable; + Name : String; + Rest : not null access function (N : Spellable) return String + ) return String is + High : Spellable := N / Order; + Low : Spellable := N mod Order; + begin + if High = 0 then + return Rest (Low); + elsif Low = 0 then + return Thousand (High) & ' ' & Name; + else + return Thousand (High) & ' ' & Name & ", " & Rest (Low); + end if; + end Triplet; + + function Million (N : Spellable) return String is + begin + return Triplet (N, 10**3, "thousand", Thousand'Access); + end Million; + + function Milliard (N : Spellable) return String is + begin + return Triplet (N, 10**6, "million", Million'Access); + end Milliard; + + function Billion (N : Spellable) return String is + begin + return Triplet (N, 10**9, "milliard", Milliard'Access); + end Billion; + + function Billiard (N : Spellable) return String is + begin + return Triplet (N, 10**12, "billion", Billion'Access); + end Billiard; + + begin + if N < 0 then + return "negative " & Spell(-N); + else + return Triplet (N, 10**15, "billiard", Billiard'Access); + end if; + end Spell; + + procedure Spell_And_Print(N: Spellable) is + Number: constant String := Spellable'Image(N); + Spaces: constant String(1 .. 20) := (others => ' '); -- 20 * ' ' + begin + Ada.Text_IO.Put_Line(Spaces(Spaces'First .. Spaces'Last-Number'Length) + & Number & ' ' & Spell(N)); + end Spell_And_Print; + + Samples: constant array (Natural range <>) of Spellable + := (99, 300, 310, 1_501, 12_609, 512_609, 43_112_609, 77_000_112_609, + 2_000_000_000_100, 999_999_999_999_999_999, + 0, -99, -1501, -77_000_112_609, -123_456_789_987_654_321); + +begin + for I in Samples'Range loop + Spell_And_Print(Samples(I)); + end loop; +end Integers_In_English; diff --git a/Task/Number-names/AutoHotkey/number-names.ahk b/Task/Number-names/AutoHotkey/number-names.ahk new file mode 100644 index 0000000000..304d4f6596 --- /dev/null +++ b/Task/Number-names/AutoHotkey/number-names.ahk @@ -0,0 +1,40 @@ +Loop { ; TEST LOOP + n = + Random Digits, 1, 36 ; random number with up to 36 digits + Loop %Digits% { + Random Digit, 0, 9 ; can have leading 0s + n .= Digit + } + MsgBox 1, Number Names, % PrettyNumber(n) "`n`n" Spell(n) "`n`n" + IfMsgBox Cancel, Break +} + +Spell(n) { ; recursive function to spell out the name of a max 36 digit integer, after leading 0s removed + Static p1=" thousand ",p2=" million ",p3=" billion ",p4=" trillion ",p5=" quadrillion ",p6=" quintillion " + , p7=" sextillion ",p8=" septillion ",p9=" octillion ",p10=" nonillion ",p11=" decillion " + , t2="twenty",t3="thirty",t4="forty",t5="fifty",t6="sixty",t7="seventy",t8="eighty",t9="ninety" + , o0="zero",o1="one",o2="two",o3="three",o4="four",o5="five",o6="six",o7="seven",o8="eight" + , o9="nine",o10="ten",o11="eleven",o12="twelve",o13="thirteen",o14="fourteen",o15="fifteen" + , o16="sixteen",o17="seventeen",o18="eighteen",o19="nineteen" + + n :=RegExReplace(n,"^0+(\d)","$1") ; remove leading 0s from n + + If (11 < d := (StrLen(n)-1)//3) ; #of digit groups of 3 + Return "Number too big" + + If (d) ; more than 3 digits + Return Spell(SubStr(n,1,-3*d)) p%d% ((s:=SubStr(n,1-3*d)) ? ", " Spell(s) : "") + + i := SubStr(n,1,1) + If (n > 99) ; 3 digits + Return o%i% " hundred" ((s:=SubStr(n,2)) ? " and " Spell(s) : "") + + If (n > 19) ; n = 20..99 + Return t%i% ((o:=SubStr(n,2)) ? "-" o%o% : "") + + Return o%n% ; n = 0..19 +} + +PrettyNumber(n) { ; inserts thousands separators into a number string + Return RegExReplace( RegExReplace(n,"^0+(\d)","$1"), "\G\d+?(?=(\d{3})+(?:\D|$))", "$0,") +} diff --git a/Task/Number-names/BASIC/number-names.basic b/Task/Number-names/BASIC/number-names.basic new file mode 100644 index 0000000000..15bf37675d --- /dev/null +++ b/Task/Number-names/BASIC/number-names.basic @@ -0,0 +1,73 @@ +DECLARE FUNCTION int2Text$ (number AS LONG) + +'small +DATA "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten" +DATA "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" +'tens +DATA "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety" +'big +DATA "thousand", "million", "billion" + +DIM SHARED small(1 TO 19) AS STRING, tens(7) AS STRING, big(2) AS STRING + +DIM tmpInt AS INTEGER + +FOR tmpInt = 1 TO 19 + READ small(tmpInt) +NEXT +FOR tmpInt = 0 TO 7 + READ tens(tmpInt) +NEXT +FOR tmpInt = 0 TO 2 + READ big(tmpInt) +NEXT + + +DIM n AS LONG + +INPUT "Gimme a number! ", n +PRINT int2Text$(n) + +FUNCTION int2Text$ (number AS LONG) + DIM num AS LONG, outP AS STRING, unit AS INTEGER + DIM tmpLng1 AS LONG + + IF 0 = number THEN + int2Text$ = "zero" + EXIT FUNCTION + END IF + + num = ABS(number) + + DO + tmpLng1 = num MOD 100 + SELECT CASE tmpLng1 + CASE 1 TO 19 + outP = small(tmpLng1) + " " + outP + CASE 20 TO 99 + SELECT CASE tmpLng1 MOD 10 + CASE 0 + outP = tens((tmpLng1 \ 10) - 2) + " " + outP + CASE ELSE + outP = tens((tmpLng1 \ 10) - 2) + "-" + small(tmpLng1 MOD 10) + " " + outP + END SELECT + END SELECT + + tmpLng1 = (num MOD 1000) \ 100 + IF tmpLng1 THEN + outP = small(tmpLng1) + " hundred " + outP + END IF + + num = num \ 1000 + IF num < 1 THEN EXIT DO + + tmpLng1 = num MOD 1000 + IF tmpLng1 THEN outP = big(unit) + " " + outP + + unit = unit + 1 + LOOP + + IF number < 0 THEN outP = "negative " + outP + + int2Text$ = RTRIM$(outP) +END FUNCTION diff --git a/Task/Number-names/BBC-BASIC/number-names.bbc b/Task/Number-names/BBC-BASIC/number-names.bbc new file mode 100644 index 0000000000..2923a4e66f --- /dev/null +++ b/Task/Number-names/BBC-BASIC/number-names.bbc @@ -0,0 +1,40 @@ + DIM test%(20) + test%() = 0, 1, 2, 19, 20, 21, 99, 100, 101, 300, 310, 1001, -1327, 1501, \ + \ 10203, 12609, 101104, 102003, 467889, 1005006, -123000789 + FOR i% = 0 TO DIM(test%(),1) + PRINT FNsaynumber(test%(i%)) + NEXT + END + + DEF FNsaynumber(n%) + LOCAL number%(), number$(), i%, t%, a$ + DIM number%(29), number$(29) + number%() = 1000000000, 1000000, 1000, 100, 90, 80, 70, 60, 50, 40, 30, 20, \ + \ 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2 + number$() = "billion", "million", "thousand", "hundred", "ninety", "eighty", \ + \ "seventy", "sixty", "fifty", "forty", "thirty", "twenty", \ + \ "nineteen", "eighteen", "seventeen", "sixteen", "fifteen", \ + \ "fourteen", "thirteen", "twelve", "eleven", "ten", "nine", \ + \ "eight", "seven", "six", "five", "four", "three", "two" + + IF n% < 0 THEN = "minus " + FNsaynumber(-n%) + IF n% = 0 THEN = "zero" + IF n% = 1 THEN = "one " + + FOR i% = 0 TO DIM(number%(),1) + IF n% >= number%(i%) THEN + t% = n% DIV number%(i%) + IF t%=1 AND i%<4 a$ += "one " ELSE IF t%<>1 a$ += FNsaynumber(t%) + a$ += number$(i%) + t% = n% MOD number%(i%) + CASE TRUE OF + WHEN i%>3 AND i%<12 AND t%<>0: a$ += "-" + WHEN i%<=3 AND t%>=100: a$ += ", " + WHEN i%<=3 AND t%<>0 AND t%<100: a$ += " and " + OTHERWISE: a$ += " " + ENDCASE + IF t% a$ += FNsaynumber(t%) ELSE IF i%<12 a$ += " " + EXIT FOR + ENDIF + NEXT i% + = a$ diff --git a/Task/Number-names/C++/number-names.cpp b/Task/Number-names/C++/number-names.cpp new file mode 100644 index 0000000000..cf0e0e9412 --- /dev/null +++ b/Task/Number-names/C++/number-names.cpp @@ -0,0 +1,69 @@ +#include +#include +using std::string; + +const char* smallNumbers[] = { + "zero", "one", "two", "three", "four", "five", + "six", "seven", "eight", "nine", "ten", + "eleven", "twelve", "thirteen", "fourteen", "fifteen", + "sixteen", "seventeen", "eighteen", "nineteen" +}; + +string spellHundreds(unsigned n) { + string res; + if (n > 99) { + res = smallNumbers[n/100]; + res += " hundred"; + n %= 100; + if (n) res += " and "; + } + if (n >= 20) { + static const char* Decades[] = { + "", "", "twenty", "thirty", "forty", + "fifty", "sixty", "seventy", "eighty", "ninety" + }; + res += Decades[n/10]; + n %= 10; + if (n) res += "-"; + } + if (n < 20 && n > 0) + res += smallNumbers[n]; + return res; +} + + +const char* thousandPowers[] = { + " billion", " million", " thousand", "" }; + +typedef unsigned long Spellable; + +string spell(Spellable n) { + if (n < 20) return smallNumbers[n]; + string res; + const char** pScaleName = thousandPowers; + Spellable scaleFactor = 1000000000; // 1 billion + while (scaleFactor > 0) { + if (n >= scaleFactor) { + Spellable h = n / scaleFactor; + res += spellHundreds(h) + *pScaleName; + n %= scaleFactor; + if (n) res += ", "; + } + scaleFactor /= 1000; + ++pScaleName; + } + return res; +} + +int main() { +#define SPELL_IT(x) std::cout << #x " " << spell(x) << std::endl; + SPELL_IT( 99); + SPELL_IT( 300); + SPELL_IT( 310); + SPELL_IT( 1501); + SPELL_IT( 12609); + SPELL_IT( 512609); + SPELL_IT(43112609); + SPELL_IT(1234567890); + return 0; +} diff --git a/Task/Number-names/C/number-names.c b/Task/Number-names/C/number-names.c new file mode 100644 index 0000000000..7365211190 --- /dev/null +++ b/Task/Number-names/C/number-names.c @@ -0,0 +1,137 @@ +#include +#include + +const char *ones[] = { 0, "one", "two", "three", "four", + "five", "six", "seven", "eight", "nine", + "ten", "eleven", "twelve", "thirteen", "fourteen", + "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" }; +const char *tens[] = { 0, "ten", "twenty", "thirty", "forty", + "fifty", "sixty", "seventy", "eighty", "ninety" }; +const char *llions[] = { 0, "thousand", "million", "billion", "trillion", +// "quadrillion", "quintillion", "sextillion", "septillion", +// "octillion", "nonillion", "decillion" + }; +const int maxillion = sizeof(llions) / sizeof(llions[0]) * 3 - 3; + +int say_hundred(const char *s, int len, int depth, int has_lead) +{ + int c[3], i; + for (i = -3; i < 0; i++) { + if (len + i >= 0) c[i + 3] = s[len + i] - '0'; + else c[i + 3] = 0; + } + if (!(c[0] + c[1] + c[2])) return 0; + + if (c[0]) { + printf("%s hundred", ones[c[0]]); + has_lead = 1; + } + + if (has_lead && (c[1] || c[2])) + printf((!depth || c[0]) && (!c[0] || !c[1]) ? "and " : + c[0] ? " " : ""); + + if (c[1] < 2) { + if (c[1] || c[2]) printf("%s", ones[c[1] * 10 + c[2]]); + } else { + if (c[1]) { + printf("%s", tens[c[1]]); + if (c[2]) putchar('-'); + } + if (c[2]) printf("%s", ones[c[2]]); + } + + return 1; +} + +int say_maxillion(const char *s, int len, int depth, int has_lead) +{ + int n = len / 3, r = len % 3; + if (!r) { + n--; + r = 3; + } + const char *e = s + r; + do { + if (say_hundred(s, r, n, has_lead) && n) { + has_lead = 1; + printf(" %s", llions[n]); + if (!depth) printf(", "); + else printf(" "); + } + s = e; e += 3; + } while (r = 3, n--); + + return 1; +} + +void say_number(const char *s) +{ + int len, i, got_sign = 0; + + while (*s == ' ') s++; + if (*s < '0' || *s > '9') { + if (*s == '-') got_sign = -1; + else if (*s == '+') got_sign = 1; + else goto nan; + s++; + } else + got_sign = 1; + + while (*s == '0') { + s++; + if (*s == '\0') { + printf("zero\n"); + return; + } + } + + len = strlen(s); + if (!len) goto nan; + + for (i = 0; i < len; i++) { + if (s[i] < '0' || s[i] > '9') { + printf("(not a number)"); + return; + } + } + if (got_sign == -1) printf("minus "); + + int n = len / maxillion; + int r = len % maxillion; + if (!r) { + r = maxillion; + n--; + } + + const char *end = s + len - n * maxillion; + int has_lead = 0; + do { + if ((has_lead = say_maxillion(s, r, n, has_lead))) { + for (i = 0; i < n; i++) + printf(" %s", llions[maxillion / 3]); + if (n) printf(", "); + } + n--; + r = maxillion; + s = end; + end += r; + } while (n >= 0); + + printf("\n"); + return; + +nan: printf("not a number\n"); + return; +} + +int main() +{ + say_number("-42"); + say_number("1984"); + say_number("10000"); + say_number("1024"); + say_number("1001001001001"); + say_number("123456789012345678901234567890123456789012345678900000001"); + return 0; +} diff --git a/Task/Number-names/Clojure/number-names.clj b/Task/Number-names/Clojure/number-names.clj new file mode 100644 index 0000000000..ea044af867 --- /dev/null +++ b/Task/Number-names/Clojure/number-names.clj @@ -0,0 +1,2 @@ +(clojure.pprint/cl-format nil "~R" 1234) +=> "one thousand, two hundred thirty-four" diff --git a/Task/Number-names/CoffeeScript/number-names-1.coffeescript b/Task/Number-names/CoffeeScript/number-names-1.coffeescript new file mode 100644 index 0000000000..00571a360c --- /dev/null +++ b/Task/Number-names/CoffeeScript/number-names-1.coffeescript @@ -0,0 +1,57 @@ +spell_integer = (n) -> + tens = [null, null, "twenty", "thirty", "forty", + "fifty", "sixty", "seventy", "eighty", "ninety"] + + small = ["zero", "one", "two", "three", "four", "five", + "six", "seven", "eight", "nine", "ten", "eleven", + "twelve", "thirteen", "fourteen", "fifteen", + "sixteen", "seventeen", "eighteen", "nineteen"] + + bl = [null, null, "m", "b", "tr", "quadr", + "quint", "sext", "sept", "oct", "non", "dec"] + + divmod = (n, d) -> + [Math.floor(n / d), n % d] + + nonzero = (c, n) -> + if n == 0 + "" + else + c + spell_integer n + + big = (e, n) -> + if e == 0 + spell_integer n + else if e == 1 + spell_integer(n) + " thousand" + else + spell_integer(n) + " " + bl[e] + "illion" + + base1000_rev = (n) -> + # generates the value of the digits of n in base 1000 + # (i.e. 3-digit chunks), in reverse. + chunks = [] + while n != 0 + [n, r] = divmod n, 1000 + chunks.push r + chunks + + if n < 0 + throw Error "spell_integer: negative input" + else if n < 20 + small[n] + else if n < 100 + [a, b] = divmod n, 10 + tens[a] + nonzero("-", b) + else if n < 1000 + [a, b] = divmod n, 100 + small[a] + " hundred" + nonzero(" ", b) + else + chunks = (big(exp, x) for x, exp in base1000_rev(n) when x) + chunks.reverse().join ', ' + +# example +console.log spell_integer 1278 +console.log spell_integer 1752 +console.log spell_integer 2010 +console.log spell_integer 4000123007913 diff --git a/Task/Number-names/CoffeeScript/number-names-2.coffeescript b/Task/Number-names/CoffeeScript/number-names-2.coffeescript new file mode 100644 index 0000000000..290302a78e --- /dev/null +++ b/Task/Number-names/CoffeeScript/number-names-2.coffeescript @@ -0,0 +1,5 @@ +> coffee spell_number.coffee +one thousand, two hundred seventy-eight +one thousand, seven hundred fifty-two +two thousand, ten +four trillion, one hundred twenty-three million, seven thousand, nine hundred thirteen diff --git a/Task/Number-names/Common-Lisp/number-names.lisp b/Task/Number-names/Common-Lisp/number-names.lisp new file mode 100644 index 0000000000..9160f3622e --- /dev/null +++ b/Task/Number-names/Common-Lisp/number-names.lisp @@ -0,0 +1,2 @@ +(format nil "~R" 1234) +=> "one thousand two hundred thirty-four" diff --git a/Task/Number-names/D/number-names.d b/Task/Number-names/D/number-names.d new file mode 100644 index 0000000000..3cb383e82b --- /dev/null +++ b/Task/Number-names/D/number-names.d @@ -0,0 +1,60 @@ +import std.stdio, std.string; + +string spellInteger(in long n) pure nothrow { + static immutable tens = ["", "", "twenty", "thirty", "forty", + "fifty", "sixty", "seventy", "eighty", "ninety"]; + + static immutable small = "zero one two three four five six + seven eight nine ten eleven twelve thirteen fourteen + fifteen sixteen seventeen eighteen nineteen".split(); + + static immutable bl = ["", "", "m", "b", "tr", + "quadr", "quint", "sext", "sept", "oct", "non", "dec"]; + + static string nonZero(in string c, in int n) pure nothrow { + return n == 0 ? "" : c ~ spellInteger(n); + } + + static string big(in int e, in int n) pure nothrow { + switch (e) { + case 0: return spellInteger(n); + case 1: return spellInteger(n) ~ " thousand"; + default: return spellInteger(n) ~ " " ~ bl[e] ~ "illion"; + } + } + + /// Generates the value of the digits of n in + /// base 1000 (i.e. 3-digit chunks), in reverse. + static int[] base1000Reverse(in long nn) pure nothrow { + long n = nn; + int[] result; + while (n) { + result ~= n % 1000; + n /= 1000; + } + return result; + } + + if (n < 0) { + return "negative " ~ spellInteger(-n); + } else if (n < 1000) { + int ni = cast(int)n; // D doesn't infer this. + if (ni < 20) { + return small[ni]; + } else if (ni < 100) { + return tens[ni / 10] ~ nonZero("-", ni % 10); + } else // ni < 1000 + return small[ni / 100] ~ " hundred" ~ + nonZero(" ", ni % 100); + } else { + string[] pieces; + foreach_reverse (e, x; base1000Reverse(n)) + pieces ~= big(e, x); + return pieces.join(", "); + } +} + +void main() { + foreach (i; -10 .. 1_000) + writeln(i, " ", spellInteger(i)); +} diff --git a/Task/Number-names/Euphoria/number-names.euphoria b/Task/Number-names/Euphoria/number-names.euphoria new file mode 100644 index 0000000000..878428a137 --- /dev/null +++ b/Task/Number-names/Euphoria/number-names.euphoria @@ -0,0 +1,72 @@ +function abs(atom i) + if i < 0 then + return -i + else + return i + end if +end function + +constant small = {"one", "two", "three", "four", "five", "six", "seven", "eight", + "nine", "ten","eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", + "seventeen", "eighteen", "nineteen"} + +constant tens = {"twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", + "ninety"} + +constant big = {"thousand", "million", "billion"} + +function int2text(atom number) + atom num + integer unit, tmpLng1 + sequence outP + outP = "" + num = 0 + unit = 1 + tmpLng1 = 0 + + if number = 0 then + return "zero" + end if + + num = abs(number) + while 1 do + tmpLng1 = remainder(num,100) + if tmpLng1 > 0 and tmpLng1 < 20 then + outP = small[tmpLng1] & ' ' & outP + elsif tmpLng1 >= 20 then + if remainder(tmpLng1,10) = 0 then + outP = tens[floor(tmpLng1/10)-1] & ' ' & outP + else + outP = tens[floor(tmpLng1/10)-1] & '-' & small[remainder(tmpLng1, 10)] & ' ' & outP + end if + end if + + tmpLng1 = floor(remainder(num, 1000) / 100) + if tmpLng1 then + outP = small[tmpLng1] & " hundred " & outP + end if + + num = floor(num/1000) + if num < 1 then + exit + end if + + tmpLng1 = remainder(num,1000) + if tmpLng1 then + outP = big[unit] & ' ' & outP + end if + + unit = unit + 1 + end while + + if number < 0 then + outP = "negative " & outP + end if + + return outP[1..$-1] +end function + +puts(1,int2text(900000001) & "\n") +puts(1,int2text(1234567890) & "\n") +puts(1,int2text(-987654321) & "\n") +puts(1,int2text(0) & "\n") diff --git a/Task/Number-names/Fortran/number-names.f b/Task/Number-names/Fortran/number-names.f new file mode 100644 index 0000000000..a932dc3af7 --- /dev/null +++ b/Task/Number-names/Fortran/number-names.f @@ -0,0 +1,67 @@ +program spell + + implicit none + integer :: e + integer :: i + integer :: m + integer :: n + character (9), dimension (19), parameter :: small = & + & (/'one ', 'two ', 'three ', 'four ', & + & 'five ', 'six ', 'seven ', 'eight ', & + & 'nine ', 'ten ', 'eleven ', 'twelve ', & + & 'thirteen ', 'fourteen ', 'fifteen ', 'sixteen ', & + & 'seventeen', 'eighteen ', 'nineteen '/) + character (7), dimension (2 : 9), parameter :: tens = & + & (/'twenty ', 'thirty ', 'forty ', 'fifty ', 'sixty ', & + & 'seventy', 'eighty ', 'ninety '/) + character (8), dimension (3), parameter :: big = & + & (/'thousand', 'million ', 'billion '/) + character (256) :: r + + do + read (*, *, iostat = i) n + if (i /= 0) then + exit + end if + if (n == 0) then + r = 'zero' + else + r = '' + m = abs (n) + e = 0 + do + if (m == 0) then + exit + end if + if (modulo (m, 1000) > 0) then + if (e > 0) then + r = trim (big (e)) // ' ' // r + end if + if (modulo (m, 100) > 0) then + if (modulo (m, 100) < 20) then + r = trim (small (modulo (m, 100))) // ' ' // r + else + if (modulo (m, 10) > 0) then + r = trim (small (modulo (m, 10))) // ' ' // r + r = trim (tens (modulo (m, 100) / 10)) // '-' // r + else + r = trim (tens (modulo (m, 100) / 10)) // ' ' // r + end if + end if + end if + if (modulo (m, 1000) / 100 > 0) then + r = 'hundred' // ' ' // r + r = trim (small (modulo (m, 1000) / 100)) // ' ' // r + end if + end if + m = m / 1000 + e = e + 1 + end do + if (n < 0) then + r = 'negative' // ' ' // r + end if + end if + write (*, '(a)') trim (r) + end do + +end program spell diff --git a/Task/Number-names/Go/number-names.go b/Task/Number-names/Go/number-names.go new file mode 100644 index 0000000000..9527cfaa07 --- /dev/null +++ b/Task/Number-names/Go/number-names.go @@ -0,0 +1,54 @@ +package main + +import "fmt" + +func main() { + for _, n := range []int64{12, 1048576, 9e18} { + fmt.Println(say(n)) + } +} + +var small = []string{"", "one", "two", "three", "four", "five", "six", + "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", + "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"} +var tens = []string{"ones", "ten", "twenty", "thirty", "forty", + "fifty", "sixty", "seventy", "eighty", "ninety"} +var illions = []string{"thousand", "million", "billion", + "trillion", "quadrillion", "quintillion"} + +func say(n int64) string { + switch { + case n < 1: + case n < 20: + return small[n] + case n < 100: + t := tens[n/10] + s := n % 10 + if s > 0 { + t += " " + small[s] + } + return t + case n < 1000: + h := small[n/100] + " hundred" + s := n % 100 + if s > 0 { + h += " " + say(s) + } + return h + default: + sx := say(n % 1000) + for i := 0; n >= 1000; i++ { + n /= 1000 + p := n % 1000 + if p > 0 { + ix := say(p) + " " + illions[i] + if sx > "" { + ix += " " + sx + } + sx = ix + } + } + return sx + } + return "" +} diff --git a/Task/Number-names/Groovy/number-names.groovy b/Task/Number-names/Groovy/number-names.groovy new file mode 100644 index 0000000000..e1e381a2a8 --- /dev/null +++ b/Task/Number-names/Groovy/number-names.groovy @@ -0,0 +1,75 @@ +def divMod(BigInteger number, BigInteger divisor) { + def qr = number.divideAndRemainder(divisor) + [div:qr[0], remainder:qr[1]] +} + +def toText(value) { + value = value as BigInteger + def units = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', + 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'] + def tens = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety'] + def big = ['', 'thousand'] + ['m', 'b', 'tr', 'quadr', 'quint', 'sext', 'sept', 'oct', 'non', 'dec'].collect { "${it}illion"} + + if (value < 0) { + "negative ${toText(-value)}" + } else if (value < 20) { + units[value] + } else if (value < 100) { + divMod(value, 10).with { "${tens[div]} ${units[remainder]}".replace(' zero', '') } + } else if (value < 1000) { + divMod(value, 100).with { "${toText(div)} hundred and ${toText(remainder)}".replace(' and zero', '') } + } else { + def chunks = [] + while (value != 0) { + divMod(value, 1000).with { + chunks << remainder + value = div + } + } + if (chunks.size() > big.size()) { + throw new IllegalArgumentException("Number overflow") + } + def text = [] + (0.. + if (chunks[index] > 0) { + text << "${toText(chunks[index])}${index == 0 ? '' : ' ' + big[index]}" + if (index == 0 && chunks[index] < 100) { + text << "and" + } + } + } + text.reverse().join(', ').replace(', and,', ' and') + } +} + +// Add this method to all Numbers +Number.metaClass.toText = { toText(delegate) } + +println toText(29) +println 40.toText() +println toText(401) +println 9003.toText() +println toText(8011673) +println 8000100.toText() +println 4629436.toText() +948623487512387455323784623842314234.toText().split(',').each { println it.trim() } + +def verifyToText(expected, value) { + println "Checking '$expected' == $value" + def actual = value.toText() + assert expected == actual +} + +verifyToText 'nineteen', 19 +verifyToText 'one thousand, two hundred and thirty four', 1234 +verifyToText 'twenty three million, four hundred and fifty nine thousand, six hundred and twelve', 23459612 +verifyToText 'one thousand, nine hundred and ninety nine', 1999 +verifyToText 'negative six hundred and one', -601 +verifyToText 'twelve billion and nineteen', 12000000019 +verifyToText 'negative one billion, two hundred and thirty four million, five hundred and sixty seven thousand, eight hundred and ninety', -1234567890 +verifyToText 'one hundred and one', 101 +verifyToText 'one thousand and one', 1001 +verifyToText 'one million, one hundred and one', 1000101 +verifyToText 'one million and forty five', 1000045 +verifyToText 'one million and fifteen', 1000015 +verifyToText 'one billion, forty five thousand and one', 1000045001 diff --git a/Task/Number-names/Haskell/number-names.hs b/Task/Number-names/Haskell/number-names.hs new file mode 100644 index 0000000000..d237b9e811 --- /dev/null +++ b/Task/Number-names/Haskell/number-names.hs @@ -0,0 +1,36 @@ +import Data.List (intercalate, unfoldr) + +spellInteger :: Integer -> String +spellInteger n + | n < 0 = "negative " ++ spellInteger (-n) + | n < 20 = small n + | n < 100 = let (a, b) = n `divMod` 10 + in tens a ++ nonzero '-' b + | n < 1000 = let (a, b) = n `divMod` 100 + in small a ++ " hundred" ++ nonzero ' ' b + | otherwise = intercalate ", " $ map big $ reverse $ + filter ((/= 0) . snd) $ zip [0..] $ unfoldr uff n + + where nonzero :: Char -> Integer -> String + nonzero _ 0 = "" + nonzero c n = c : spellInteger n + + uff :: Integer -> Maybe (Integer, Integer) + uff 0 = Nothing + uff n = Just $ uncurry (flip (,)) $ n `divMod` 1000 + + small, tens :: Integer -> String + small = (["zero", "one", "two", "three", "four", "five", + "six", "seven", "eight", "nine", "ten", "eleven", + "twelve", "thirteen", "fourteen", "fifteen", "sixteen", + "seventeen", "eighteen", "nineteen"] !!) . fromEnum + tens = ([undefined, undefined, "twenty", "thirty", "forty", + "fifty", "sixty", "seventy", "eighty", "ninety"] !!) . + fromEnum + + big :: (Int, Integer) -> String + big (0, n) = spellInteger n + big (1, n) = spellInteger n ++ " thousand" + big (e, n) = spellInteger n ++ ' ' : (l !! e) ++ "illion" + where l = [undefined, undefined, "m", "b", "tr", "quadr", + "quint", "sext", "sept", "oct", "non", "dec"] diff --git a/Task/Number-names/HicEst/number-names-1.hicest b/Task/Number-names/HicEst/number-names-1.hicest new file mode 100644 index 0000000000..c1f28366db --- /dev/null +++ b/Task/Number-names/HicEst/number-names-1.hicest @@ -0,0 +1,70 @@ +SUBROUTINE NumberToWords(number) + CHARACTER outP*255, small*130, tens*80, big*80 + REAL :: decimal_places = 7 + INIT( APPENDIX("#literals"), small, tens, big) + + num = ABS( INT(number) ) + order = 0 + outP = ' ' + DO i = 1, num + 1 + tmp = MOD(num, 100) + IF(tmp > 19) THEN + EDIT(Text=tens, ITeM=INT(MOD(tmp/10, 10)), Parse=medium) + IF( MOD(tmp, 10) ) THEN + EDIT(Text=small, ITeM=MOD(tmp,10)+1, Parse=mini) + outP = medium // '-' // mini // ' ' // outP + ELSE + outP = medium // ' ' // outP + ENDIF + ELSEIF(tmp > 0) THEN + EDIT(Text=small, ITeM=tmp+1, Parse=mini) + outP = mini // ' '// outP + ELSEIF(number == 0) THEN + outP = 'zero' + ENDIF + + tmp = INT(MOD(num, 1000) / 100) + IF(tmp) THEN + EDIT(Text=small, ITeM=tmp+1, Parse=oneto19) + outP = oneto19 // ' hundred ' // outP + ENDIF + + num = INT(num /1000) + IF( num == 0) THEN + IF(number < 0) outP = 'minus ' // outP + fraction = ABS( MOD(number, 1) ) + IF(fraction) WRITE(Text=outP, APPend) ' point' + DO j = 1, decimal_places + IF( fraction >= 10^(-decimal_places) ) THEN + num = INT( 10.01 * fraction ) + EDIT(Text=small, ITeM=num+1, Parse=digit) + WRITE(Text=outP, APPend) ' ', digit + fraction = 10*fraction - num + ENDIF + ENDDO + OPEN(FIle="temp.txt", APPend) + WRITE(FIle="temp.txt", Format='F10, " = ", A', CLoSe=1) number, outP + RETURN + ENDIF + + order = order + 1 + EDIT(Text=big, ITeM=order, Parse=kilo) + IF( MOD(num, 1000) ) outP = kilo // ' and '// outP + ENDDO +END + +CALL NumberToWords( 0 ) +CALL NumberToWords( 1234 ) +CALL NumberToWords( 1234/100 ) +CALL NumberToWords( 10000000 + 1.2 ) +CALL NumberToWords( 2^15 ) +CALL NumberToWords( 0.001 ) +CALL NumberToWords( -EXP(1) ) + +#literals + SMALL= zero one two three four five six seven eight nine ten & + eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen + + TENS=ten twenty thirty forty fifty sixty seventy eighty ninety + + BIG=thousand million billion trillion quadrillion diff --git a/Task/Number-names/HicEst/number-names-2.hicest b/Task/Number-names/HicEst/number-names-2.hicest new file mode 100644 index 0000000000..13bedae66c --- /dev/null +++ b/Task/Number-names/HicEst/number-names-2.hicest @@ -0,0 +1,7 @@ +0 = zero +1234 = one thousand and two hundred thirty-four +12.34 = twelve point three four +10000001.2 = ten million and one point two +32768 = thirty-two thousand and seven hundred sixty-eight +1E-3 = point zero zero one +-2.7182818 = minus two point seven one eight two eight one eight diff --git a/Task/Number-names/HicEst/number-names-3.hicest b/Task/Number-names/HicEst/number-names-3.hicest new file mode 100644 index 0000000000..3c0ceb6097 --- /dev/null +++ b/Task/Number-names/HicEst/number-names-3.hicest @@ -0,0 +1,6 @@ +link numbers # commas, spell + +procedure main(arglist) +every x := !arglist do + write(commas(x), " -> ",spell(x)) +end diff --git a/Task/Number-names/HicEst/number-names-4.hicest b/Task/Number-names/HicEst/number-names-4.hicest new file mode 100644 index 0000000000..39abfc90d1 --- /dev/null +++ b/Task/Number-names/HicEst/number-names-4.hicest @@ -0,0 +1,37 @@ +procedure spell(n) #: spell out integer (short scale) + local m, i + static scale + initial { + scale := [ "thousand", "million", "billion", "trillion", "quadrillion", "quintillion", "sextillion","septillion"] + every scale[i := 1 to *scale ] := [ integer(repl("999",i + 1)), -3 * i, " "||scale[i] ] + push(scale,[999,2," hundred"]) + } + + n := integer(n) | stop(image(n)," is not an integer") + if n < 0 then return "negative " || spell(-n) + if n <= 12 then return { + "0zero,1one,2two,3three,4four,5five,6six,7seven,8eight,_ + 9nine,10ten,11eleven,12twelve," ? { + tab(find(n)) + move(*n) + tab(find(",")) + } + } + else if n <= 19 then return { + spell(n[2] || "0") ? + (if ="for" then "four" else tab(find("ty"))) || "teen" + } + else if n <= 99 then return { + "2twen,3thir,4for,5fif,6six,7seven,8eigh,9nine," ? { + tab(find(n[1])) + move(1) + tab(find(",")) || "ty" || + (if n[2] ~= 0 then "-" || spell(n[2]) else "") + } + } + else if n <= scale[i := 1 to *scale,1] then return { # generalize based on scale + spell(n[1:scale[i,2]]) || scale[i,3] || + (if (m := n[scale[i,2]:0]) ~= 0 then " and " || spell(m) else "") + } + else fail # really big +end diff --git a/Task/Number-names/Inform-7/number-names-1.inf b/Task/Number-names/Inform-7/number-names-1.inf new file mode 100644 index 0000000000..4f693665a5 --- /dev/null +++ b/Task/Number-names/Inform-7/number-names-1.inf @@ -0,0 +1 @@ +say 32767 in words; diff --git a/Task/Number-names/Inform-7/number-names-2.inf b/Task/Number-names/Inform-7/number-names-2.inf new file mode 100644 index 0000000000..046843244e --- /dev/null +++ b/Task/Number-names/Inform-7/number-names-2.inf @@ -0,0 +1 @@ +say 2147483647 in words; diff --git a/Task/Number-names/Inform-7/number-names-3.inf b/Task/Number-names/Inform-7/number-names-3.inf new file mode 100644 index 0000000000..683ce48b1a --- /dev/null +++ b/Task/Number-names/Inform-7/number-names-3.inf @@ -0,0 +1,24 @@ +u=. ;:'one two three four five six seven eight nine' +v=. ;:'ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen' +t=. ;:'twenty thirty forty fifty sixty seventy eighty ninety' +EN100=: '' ; u , v , , t ,&.>/ '';'-',&.>u + +z=. '' ; 'thousand' ; (;:'m b tr quadr quint sext sept oct non'),&.> <'illion' +u=. ;:'un duo tre quattuor quin sex septen octo novem' +t=. (;:'dec vigint trigint quadragint quinquagint sexagint septuagint octogint nonagint'),&.><'illion' +ENU=: z , (, t ,~&.>/ '';u) , <'centillion' + +en3=: 4 : 0 + 'p q'=. 0 100#:y + (p{::EN100),((*p)#' hundred'),((p*&*q)#x),q{::EN100 +) + +en=: 4 : 0 + d=. 1000&#.^:_1 y + assert. (0<:y) *. ((=<.)y) *. d <:&# ENU + c=. x&en3&.> (*d)#d + ((0=y)#'zero') , (-2+*{:d) }. ; , c,.(<' '),.(ENU{~I.&.|.*d),.<', ' +) + +uk=: ' and '&en NB. British +us=: ' ' &en NB. American diff --git a/Task/Number-names/Java/number-names-1.java b/Task/Number-names/Java/number-names-1.java new file mode 100644 index 0000000000..98195269c9 --- /dev/null +++ b/Task/Number-names/Java/number-names-1.java @@ -0,0 +1,64 @@ +public class Int2Words { + static String[] small = {"one", "two", "three", "four", "five", "six", + "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", + "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"}; + static String[] tens = {"twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", + "ninety"}; + static String[] big = {"thousand", "million", "billion", "trillion"}; + + public static void main(String[] args) { + System.out.println(int2Text(900000001)); + System.out.println(int2Text(1234567890)); + System.out.println(int2Text(-987654321)); + System.out.println(int2Text(0)); + } + + public static String int2Text(long number) { + long num = 0; + String outP = ""; + int unit = 0; + long tmpLng1 = 0; + + if (number == 0) { + return "zero"; + } + + num = Math.abs(number); + + for (;;) { + tmpLng1 = num % 100; + if (tmpLng1 >= 1 && tmpLng1 <= 19) { + outP = small[(int) tmpLng1 - 1] + " " + outP; + } else if (tmpLng1 >= 20 && tmpLng1 <= 99) { + if (tmpLng1 % 10 == 0) { + outP = tens[(int) (tmpLng1 / 10) - 2] + " " + outP; + } else { + outP = tens[(int) (tmpLng1 / 10) - 2] + "-" + + small[(int) (tmpLng1 % 10) - 1] + " " + outP; + } + } + + tmpLng1 = (num % 1000) / 100; + if (tmpLng1 != 0) { + outP = small[(int) tmpLng1 - 1] + " hundred " + outP; + } + + num /= 1000; + if (num == 0) { + break; + } + + tmpLng1 = num % 1000; + if (tmpLng1 != 0) { + outP = big[unit] + " " + outP; + } + unit++; + } + + if (number < 0) { + outP = "negative " + outP; + } + + return outP.trim(); + } +} diff --git a/Task/Number-names/Java/number-names-2.java b/Task/Number-names/Java/number-names-2.java new file mode 100644 index 0000000000..0e436022be --- /dev/null +++ b/Task/Number-names/Java/number-names-2.java @@ -0,0 +1,18 @@ +public class NumberToWordsConverter { // works upto 9999999 + + final private static String[] units = {"Zero","One","Two","Three","Four", + "Five","Six","Seven","Eight","Nine","Ten", + "Eleven","Twelve","Thirteen","Fourteen","Fifteen", + "Sixteen","Seventeen","Eighteen","Nineteen"}; + final private static String[] tens = {"","","Twenty","Thirty","Forty","Fifty", + "Sixty","Seventy","Eighty","Ninety"}; + + public static String convert(Integer i) { + // + if( i < 20) return units[i]; + if( i < 100) return tens[i/10] + ((i % 10 > 0)? " " + convert(i % 10):""); + if( i < 1000) return units[i/100] + " Hundred" + ((i % 100 > 0)?" and " + convert(i % 100):""); + if( i < 1000000) return convert(i / 1000) + " Thousand " + ((i % 1000 > 0)? " " + convert(i % 1000):"") ; + return convert(i / 1000000) + " Million " + ((i % 1000000 > 0)? " " + convert(i % 1000000):"") ; + } +} diff --git a/Task/Number-names/Joy/number-names.joy b/Task/Number-names/Joy/number-names.joy new file mode 100644 index 0000000000..7a419e4e0a --- /dev/null +++ b/Task/Number-names/Joy/number-names.joy @@ -0,0 +1,43 @@ +DEFINE units == +[ "zero" "one" "two" "three" "four" "five" "six" "seven" "eight" "nine" "ten" + "eleven" "twelve" "thirteen" "fourteen" "fifteen" "sixteen" "seventeen" + "eighteen" "nineteen" ]; + +tens == +[ "ten" "twenty" "thirty" "forty" "fifty" "sixty" "seventy" "eighty" "ninety" ]; + +convert6 == +[1000000 <] +[1000 div swap convert " thousand " putchars convert3] +[1000000 div swap convert " million " putchars convert3] +ifte; + +convert5 == +[null] +[] +[" and " putchars convert] +ifte; + +convert4 == +[1000 <] +[100 div swap units of putchars " hundred" putchars convert5] +[convert6] +ifte; + +convert3 == +[null] +[] +[32 putch convert] +ifte; + +convert2 == +[100 <] +[10 div swap pred tens of putchars convert3] +[convert4] +ifte; + +convert == +[20 <] +[units of putchars] +[convert2] +ifte. diff --git a/Task/Number-names/Logo/number-names.logo b/Task/Number-names/Logo/number-names.logo new file mode 100644 index 0000000000..d607b88c3c --- /dev/null +++ b/Task/Number-names/Logo/number-names.logo @@ -0,0 +1,28 @@ +make "numbers {one two three four five six seven eight nine ten + eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen} + +make "tens {twenty thirty forty fifty sixty seventy eighty ninety}@2 + +make "thou [[] thousand million billion trillion] ; expand as desired + +to to.english.thou :n :thou + if :n = 0 [output []] + if :n < 20 [output sentence item :n :numbers first :thou] + if :n < 100 [output (sentence item int :n/10 :tens + to.english.thou modulo :n 10 [[]] + first :thou)] + if :n < 1000 [output (sentence item int :n/100 :numbers + "hundred + to.english.thou modulo :n 100 [[]] + first :thou)] + output (sentence to.english.thou int :n/1000 butfirst :thou + to.english.thou modulo :n 1000 :thou) +end + +to to.english :n + if :n = 0 [output "zero] + if :n > 0 [output to.english.thou :n :thou] + [output sentence "negative to.english.thou minus :n :thou] +end + +print to.english 1234567 ; one million two hundred thirty four thousand five hundred sixty seven diff --git a/Task/Number-names/Lua/number-names.lua b/Task/Number-names/Lua/number-names.lua new file mode 100644 index 0000000000..39b0ee0064 --- /dev/null +++ b/Task/Number-names/Lua/number-names.lua @@ -0,0 +1,37 @@ +words = {"one ", "two ", "three ", "four ", "five ", "six ", "seven ", "eight ", "nine "} +levels = {"thousand ", "million ", "billion ", "trillion ", "quadrillion ", "quintillion ", "sextillion ", "septillion ", "octillion ", [0] = ""} +iwords = {"ten ", "twenty ", "thirty ", "forty ", "fifty ", "sixty ", "seventy ", "eighty ", "ninety "} +twords = {"eleven ", "twelve ", "thirteen ", "fourteen ", "fifteen ", "sixteen ", "seventeen ", "eighteen ", "nineteen "} + +function digits(n) + local i, ret = -1 + return function() + i, ret = i + 1, n % 10 + if n > 0 then + n = math.floor(n / 10) + return i, ret + end + end +end + +level = false +function getname(pos, dig) --stateful, but effective. + level = level or pos % 3 == 0 + if(dig == 0) then return "" end + local name = (pos % 3 == 1 and iwords[dig] or words[dig]) .. (pos % 3 == 2 and "hundred " or "") + if(level) then name, level = name .. levels[math.floor(pos / 3)], false end + return name +end + +local val, vword = io.read() + 0, "" + +for i, v in digits(val) do + vword = getname(i, v) .. vword +end + +for i, v in ipairs(words) do + vword = vword:gsub("ty " .. v, "ty-" .. v) + vword = vword:gsub("ten " .. v, twords[i]) +end + +if #vword == 0 then print "zero" else print(vword) end diff --git a/Task/Number-names/MAXScript/number-names-1.maxscript b/Task/Number-names/MAXScript/number-names-1.maxscript new file mode 100644 index 0000000000..6a2caa55c9 --- /dev/null +++ b/Task/Number-names/MAXScript/number-names-1.maxscript @@ -0,0 +1,55 @@ +fn NumberToWord myNum = ( + local Result = "" + while myNum != 0 do ( + Result += case of ( + (myNum >= 1000):(myNum -= 1000; "one thousand") + (myNum > 900): (myNum -= 900 ; "nine hundred and") + (myNum == 900): (myNum -= 900 ; "nine hundred") + (myNum > 800): (myNum -= 800 ; "eight hundred and") + (myNum == 800): (myNum -= 900 ; "eight hundred") + (myNum > 700): (myNum -= 700 ; "seven hundred and") + (myNum == 700): (myNum -= 900 ; "seven hundred") + (myNum > 600): (myNum -= 600 ; "six hundred and") + (myNum == 600): (myNum -= 900 ; "six hundred") + (myNum > 500): (myNum -= 500 ; "five hundred and") + (myNum == 500): (myNum -= 900 ; "five hundred") + (myNum > 400): (myNum -= 400 ; "four hundred and") + (myNum == 400): (myNum -= 900 ; "four hundred") + (myNum > 300): (myNum -= 300 ; "three hundred and") + (myNum == 300): (myNum -= 900 ; "three hundred") + (myNum > 200): (myNum -= 200 ; "two hundred and") + (myNum == 200): (myNum -= 900 ; "two hundred") + (myNum > 100): (myNum -= 100 ; "one hundred and") + (myNum == 100): (myNum -= 100 ; "one hundred") + (myNum >= 90): (myNum -= 90 ; "ninety") + (myNum >= 80): (myNum -= 80 ; "eighty") + (myNum >= 70): (myNum -= 70 ; "seventy") + (myNum >= 60): (myNum -= 60 ; "sixty") + (myNum >= 50): (myNum -= 50 ; "fifty") + (myNum >= 40): (myNum -= 40 ; "fourty") + (myNum >= 30): (myNum -= 30 ; "thirty") + (myNum >= 20): (myNum -= 20 ; "twenty") + (myNum >= 19): (myNum -= 19 ; "nineteen") + (myNum >= 18): (myNum -= 18 ; "eighteen") + (myNum >= 17): (myNum -= 17 ; "seventeen") + (myNum >= 16): (myNum -= 16 ; "sixteen") + (myNum >= 15): (myNum -= 15 ; "fifteen") + (myNum >= 14): (myNum -= 14 ; "fourteen") + (myNum >= 13): (myNum -= 13 ; "thirteen") + (myNum >= 12): (myNum -= 12 ; "twelve") + (myNum >= 11): (myNum -= 11 ; "eleven") + (myNum >= 10): (myNum -= 10 ; "ten") + (myNum >= 9): (myNum -= 9 ; "nine") + (myNum >= 8): (myNum -= 8 ; "eight") + (myNum >= 7): (myNum -= 7 ; "seven") + (myNum >= 6): (myNum -= 6 ; "six") + (myNum >= 5): (myNum -= 5 ; "five") + (myNum >= 4): (myNum -= 4 ; "four") + (myNum >= 3): (myNum -= 3 ; "three") + (myNum >= 2): (myNum -= 2 ; "two") + (myNum >= 1): (myNum -= 1 ; "one") + ) + if myNum != 0 then result += " " + ) + result +) diff --git a/Task/Number-names/MAXScript/number-names-2.maxscript b/Task/Number-names/MAXScript/number-names-2.maxscript new file mode 100644 index 0000000000..84650321ea --- /dev/null +++ b/Task/Number-names/MAXScript/number-names-2.maxscript @@ -0,0 +1 @@ +NumberToWord(123) diff --git a/Task/Number-names/Mathematica/number-names.math b/Task/Number-names/Mathematica/number-names.math new file mode 100644 index 0000000000..774d940da0 --- /dev/null +++ b/Task/Number-names/Mathematica/number-names.math @@ -0,0 +1,24 @@ +small = "zero"["one", "two", "three", "four", "five", "six", "seven", + "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", + "fifteen", "sixteen", "seventeen", "eighteen", + "nineteen"]; tens = # <> "-" & /@ {"twenty", "thirty", "forty", + "fifty", "sixty", "seventy", "eighty", "ninety"}; +big = Prepend[ + " " <> # & /@ {"thousand", "million", "billion", "trillion", + "quadrillion", "quintillion", "sextillion", "septillion", + "octillion", "nonillion", "decillion", "undecillion", + "duodecillion", "tredecillion"}, ""]; +name[n_Integer] := "negative " <> name[-n] /; n < 0; +name[n_Integer] := small[[n]] /; 0 <= n < 20; +name[n_Integer] := + StringTrim[tens[[#1 - 1]] <> small[[#2]] & @@ IntegerDigits[n], + "-zero"] /; 10 <= n < 100; +name[n_Integer] := + StringTrim[ + small[[#1]] <> " hundred and " <> name@#2 & @@ + IntegerDigits[n, 100], " and zero"] /; 100 <= n < 1000; +name[n_Integer] := + StringJoin@ + Riffle[Select[ + MapThread[StringJoin, {name /@ #, Reverse@big[[;; Length@#]]}] &@ + IntegerDigits[n, 1000], StringFreeQ[#, "zero"] &], ","]; diff --git a/Task/Number-names/OCaml/number-names.ocaml b/Task/Number-names/OCaml/number-names.ocaml new file mode 100644 index 0000000000..f8f406fd43 --- /dev/null +++ b/Task/Number-names/OCaml/number-names.ocaml @@ -0,0 +1,57 @@ +let div_mod n d = (n / d, n mod d) +let join = String.concat ", " ;; + +let rec nonzero = function + | _, 0 -> "" + | c, n -> c ^ (spell_integer n) + +and tens n = + [| ""; ""; "twenty"; "thirty"; "forty"; "fifty"; + "sixty"; "seventy"; "eighty"; "ninety" |].(n) + +and small n = + [| "zero"; "one"; "two"; "three"; "four"; "five"; + "six"; "seven"; "eight"; "nine"; "ten"; "eleven"; + "twelve"; "thirteen"; "fourteen"; "fifteen"; + "sixteen";"seventeen"; "eighteen"; "nineteen" |].(n) + +and bl = [| ""; ""; "m"; "b"; "tr"; "quadr"; "quint"; + "sext"; "sept"; "oct"; "non"; "dec" |] + +and big = function + | 0, n -> (spell_integer n) + | 1, n -> (spell_integer n) ^ " thousand" + | e, n -> (spell_integer n) ^ " " ^ bl.(e) ^ "illion" + +and uff acc = function + | 0 -> List.rev acc + | n -> + let a, b = div_mod n 1000 in + uff (b::acc) a + +and spell_integer = function + | n when n < 0 -> invalid_arg "spell_integer: negative input" + | n when n < 20 -> small n + | n when n < 100 -> + let a, b = div_mod n 10 in + (tens a) ^ nonzero("-", b) + | n when n < 1000 -> + let a, b = div_mod n 100 in + (small a) ^ " hundred" ^ nonzero(" ", b) + | n -> + let seg = (uff [] n) in + let _, segn = + (* just add the index of the item in the list *) + List.fold_left + (fun (i,acc) v -> (succ i, (i,v)::acc)) + (0,[]) + seg + in + let fsegn = + (* remove right part "zero" *) + List.filter + (function (_,0) -> false | _ -> true) + segn + in + join(List.map big fsegn) +;; diff --git a/Task/Number-names/Objeck/number-names.objeck b/Task/Number-names/Objeck/number-names.objeck new file mode 100644 index 0000000000..7c958266a9 --- /dev/null +++ b/Task/Number-names/Objeck/number-names.objeck @@ -0,0 +1,93 @@ +class NumberNames { + small : static : String[]; + tens : static : String[]; + big : static : String[]; + + function : Main(args : String[]) ~ Nil { + small := ["one", "two", "three", "four", "five", "six", "seven", + "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", + "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"]; + tens := ["twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]; + big := ["thousand", "million", "billion", "trillion"]; + + Int2Text(900000001)->PrintLine(); + Int2Text(1234567890)->PrintLine(); + Int2Text(-987654321)->PrintLine(); + Int2Text(0)->PrintLine(); + } + + function : native : Int2Text(number : Int) ~ String { + num := 0; + outP := ""; + unit := 0; + tmpLng1 := 0; + + if (number = 0) { + return "zero"; + }; + + num := number->Abs(); + + while(true) { + tmpLng1 := num % 100; + if (tmpLng1 >= 1 & tmpLng1 <= 19) { + tmp := String->New(); + tmp->Append(small[tmpLng1 - 1]); + tmp->Append(" "); + tmp->Append(outP); + outP := tmp; + } + else if (tmpLng1 >= 20 & tmpLng1 <= 99) { + if (tmpLng1 % 10 = 0) { + tmp := String->New(); + tmp->Append(tens[(tmpLng1 / 10) - 2]); + tmp->Append(" "); + tmp->Append(outP); + outP := tmp; + } + else { + tmp := String->New(); + tmp->Append(tens[(tmpLng1 / 10) - 2]); + tmp->Append( "-"); + tmp->Append(small[(tmpLng1 % 10) - 1]); + tmp->Append(" "); + tmp->Append(outP); + outP := tmp; + }; + }; + + tmpLng1 := (num % 1000) / 100; + if (tmpLng1 <> 0) { + tmp := String->New(); + tmp->Append(small[tmpLng1 - 1]); + tmp->Append(" hundred "); + tmp->Append(outP); + outP := tmp; + }; + + num /= 1000; + if (num = 0) { + break; + }; + + tmpLng1 := num % 1000; + if (tmpLng1 <> 0) { + tmp := String->New(); + tmp->Append(big[unit]); + tmp->Append(" "); + tmp->Append(outP); + outP := tmp; + }; + unit+=1; + }; + + if (number < 0) { + tmp := String->New(); + tmp->Append("negative "); + tmp->Append(outP); + outP := tmp; + }; + + return outP->Trim(); + } +} diff --git a/Task/Number-names/PARI-GP/number-names.pari b/Task/Number-names/PARI-GP/number-names.pari new file mode 100644 index 0000000000..1f33d8e253 --- /dev/null +++ b/Task/Number-names/PARI-GP/number-names.pari @@ -0,0 +1,34 @@ +Eng(n:int)={ + my(tmp,s=""); + if (n >= 1000000, + tmp = n\1000000; + s = Str(Eng(tmp), " million"); + n -= tmp * 1000000; + if (!n, return(s)); + s = Str(s, " ") + ); + if (n >= 1000, + tmp = n\1000; + s = Str(Eng(tmp), " thousand"); + n -= tmp * 1000; + if (!n, return(s)); + s = Str(s, " ") + ); + if (n >= 100, + tmp = n\100; + s = Str(Edigit(tmp), " hundred"); + n -= tmp * 100; + if (!n, return(s)); + s = Str(s, " ") + ); + if (n < 20, + return (Str(s, ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "ninteen"][n])) + ); + tmp = n\10; + s = Str(s, [0, "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"][tmp]); + n -= tmp * 10; + if (n, Str(s, "-", Edigit(n)), s) +}; +Edigit(n)={ + ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine"][n] +}; diff --git a/Task/Number-names/PHP/number-names-1.php b/Task/Number-names/PHP/number-names-1.php new file mode 100644 index 0000000000..745448d108 --- /dev/null +++ b/Task/Number-names/PHP/number-names-1.php @@ -0,0 +1,57 @@ +$orderOfMag = array('Hundred', 'Thousand,', 'Million,', 'Billion,', 'Trillion,'); +$smallNumbers = array('Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', +'Ten', 'Eleven', 'Twelve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eighteen', 'Nineteen'); +$decades = array('', '', 'Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety'); + +function NumberToEnglish($num, $count = 0){ + global $orderOfMag, $smallNumbers, $decades; + $isLast = true; + $str = ''; + + if ($num < 0){ + $str = 'Negative '; + $num = abs($num); + } + + (int) $thisPart = substr((string) $num, -3); + + if (strlen((string) $num) > 3){ + // Number still too big, work on a smaller chunk + $str .= NumberToEnglish((int) substr((string) $num, 0, strlen((string) $num) - 3), $count + 1); + $isLast = false; + } + + // do translation stuff + if (($count == 0 || $isLast) && ($str == '' || $str == 'Negative ')) + // This is either a very small number or the most significant digits of the number. Either way we don't want a preceeding "and" + $and = ''; + else + $and = ' and '; + + if ($thisPart > 99){ + // Hundreds part of the number chunk + $str .= ($isLast ? '' : ' ') . "{$smallNumbers[$thisPart/100]} {$orderOfMag[0]}"; + + if(($thisPart %= 100) == 0){ + // There is nothing else to do for this chunk (was a multiple of 100) + $str .= " {$orderOfMag[$count]}"; + return $str; + } + $and = ' and '; // Set up our and string to the word "and" since there is something in the hundreds place of this chunk + } + + if ($thisPart >= 20){ + // Tens part of the number chunk + $str .= "{$and}{$decades[$thisPart /10]}"; + $and = ' '; // Make sure we don't have any extranious "and"s + if(($thisPart %= 10) == 0) + return $str . ($count != 0 ? " {$orderOfMag[$count]}" : ''); + } + + if ($thisPart < 20 && $thisPart > 0) + // Ones part of the number chunk + return $str . "{$and}{$smallNumbers[(int) $thisPart]} " . ($count != 0 ? $orderOfMag[$count] : ''); + elseif ($thisPart == 0 && strlen($thisPart) == 1) + // The number is zero + return $str . "{$smallNumbers[(int)$thisPart]}"; +} diff --git a/Task/Number-names/PHP/number-names-2.php b/Task/Number-names/PHP/number-names-2.php new file mode 100644 index 0000000000..d396411078 --- /dev/null +++ b/Task/Number-names/PHP/number-names-2.php @@ -0,0 +1,6 @@ +NumberToEnglish(0); +NumberToEnglish(12); +NumberToEnglish(123); +NumberToEnglish(1234567890123); +NumberToEnglish(65535); +NumberToEnglish(-54321); diff --git a/Task/Number-names/PL-I/number-names.pli b/Task/Number-names/PL-I/number-names.pli new file mode 100644 index 0000000000..a91b2fb042 --- /dev/null +++ b/Task/Number-names/PL-I/number-names.pli @@ -0,0 +1,54 @@ + declare integer_names (0:20) character (9) varying static initial + ('zero', 'one', 'two', 'three', 'four', 'five', 'six', + 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', + 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', + 'eighteen', 'nineteen', 'twenty' ); + declare x(10) character (7) varying static initial + ('ten', 'twenty', 'thirty', 'fourty', 'fifty', + 'sixty', 'seventy', 'eighty', 'ninety', 'hundred'); + declare y(0:5) character (10) varying static initial + ('', '', ' thousand ', ' million ', ' billion ', ' trillion '); + declare (i, j, m, t) fixed binary (31); + declare (units, tens, hundreds, thousands) fixed binary (7); + declare (h, v, value) character (200) varying; + declare (d, k, n) fixed decimal (15); + declare three_digits fixed decimal (3); + + value = ''; + i = 5; + k = n; + do d = 1000000000000 repeat d/1000 while (d > 0); + i = i - 1; + three_digits = k/d; + k = mod(k, d); + if three_digits = 0 then iterate; + + units = mod(three_digits, 10); + t = three_digits / 10; + tens = mod(t, 10); + hundreds = three_digits / 100; + m = mod(three_digits, 100); + if m <= 20 then + v = integer_names(m); + else if units = 0 then + v = ''; + else + v = integer_names(units); + if tens >= 2 & units ^= 0 then + v = x(tens) || v; + else if tens > 2 & units = 0 then + v = v || x(tens); + + if units + tens = 0 then + if n > 0 then v = ''; + if hundreds > 0 then + h = integer_names(hundreds) || ' hundred '; + else + h = ''; + if three_digits > 100 & (tens + units > 0) then + v = 'and ' || v; + if i = 1 & value ^= '' & three_digits <= 9 then + v = 'and ' || v; + value = value ||h || v || y(i); + end; + put skip edit (trim(N), ' = ', value) (a); diff --git a/Task/Number-names/Pascal/number-names.pascal b/Task/Number-names/Pascal/number-names.pascal new file mode 100644 index 0000000000..16fa7fe6e7 --- /dev/null +++ b/Task/Number-names/Pascal/number-names.pascal @@ -0,0 +1,82 @@ +program NumberNames(output); + +const + smallies: array[1..19] of string = + ('one', 'two', 'three', 'four', 'five', 'six', + 'seven', 'eight', 'nine', 'ten', 'eleven', + 'twelve', 'thirteen', 'fourteen', 'fifteen', + 'sixteen', 'seventeen', 'eighteen', 'nineteen'); + tens: array[2..9] of string = + ('twenty', 'thirty', 'forty', 'fifty', + 'sixty', 'seventy', 'eighty', 'ninety'); + +function domaxies(number: int64): string; + const + maxies: array[0..5] of string = + (' thousand', ' million', ' billion', + ' trillion', ' quadrillion', ' quintillion'); + begin + domaxies := ''; + if number >= 0 then + domaxies := maxies[number]; + end; + +function doHundreds( number: int64): string; + begin + doHundreds := ''; + if number > 99 then + begin + doHundreds := smallies[number div 100]; + doHundreds := doHundreds + ' hundred'; + number := number mod 100; + if number > 0 then + doHundreds := doHundreds + ' and '; + end; + if number >= 20 then + begin + doHundreds := doHundreds + tens[number div 10]; + number := number mod 10; + if number > 0 then + doHundreds := doHundreds + '-'; + end; + if (0 < number) and (number < 20) then + doHundreds := doHundreds + smallies[number]; + end; + +function spell(number: int64): string; + var + scaleFactor: int64 = 1000000000000000000; + maxieStart, h: int64; + begin + spell := ''; + maxieStart := 5; + if number < 20 then + spell := smallies[number]; + while scaleFactor > 0 do + begin + if number > scaleFactor then + begin + h := number div scaleFactor; + spell := spell + doHundreds(h) + domaxies(maxieStart); + number := number mod scaleFactor; + if number > 0 then + spell := spell + ', '; + end; + scaleFactor := scaleFactor div 1000; + dec(maxieStart); + end; + end; + +begin + writeln(99, ': ', spell(99)); + writeln(234, ': ', spell(234)); + writeln(7342, ': ', spell(7342)); + writeln(32784, ': ', spell(32784)); + writeln(234345, ': ', spell(234345)); + writeln(2343451, ': ', spell(2343451)); + writeln(23434534, ': ', spell(23434534)); + writeln(234345456, ': ', spell(234345456)); + writeln(2343454569, ': ', spell(2343454569)); + writeln(2343454564356, ': ', spell(2343454564356)); + writeln(2345286538456328, ': ', spell(2345286538456328)); +end. diff --git a/Task/Number-names/Perl-6/number-names.pl6 b/Task/Number-names/Perl-6/number-names.pl6 new file mode 100644 index 0000000000..4d910380df --- /dev/null +++ b/Task/Number-names/Perl-6/number-names.pl6 @@ -0,0 +1,34 @@ +constant @I = ; +constant @X = <0 X twenty thirty forty fifty sixty seventy eighty ninety>; +constant @C = @I X~ ' hundred'; +constant @M = (<0 thousand>, + ((, + (map { ('', ).flat X~ $_ }, + ), + 'cent').flat X~ 'illion')).flat; + +sub int-name ($num) { + if $num.substr(0,1) eq '-' { return "negative {int-name($num.substr(1))}" } + if $num eq '0' { return @I[0] } + my $m = 0; + return join ', ', reverse gather for $num.flip.comb(/\d ** 1..3/) { + my ($i,$x,$c) = .comb; + if $i or $x or $c { + take join ' ', gather { + if $c { take @C[$c] } + if $x and $x == 1 { take @I[$i+10] } + else { + if $x { take @X[$x] } + if $i { take @I[$i] } + } + take @M[$m] // die "WOW! ZILLIONS!\n" if $m; + } + } + $m++; + } +} + +while '' ne (my $n = prompt("Number: ")) { + say int-name($n); +} diff --git a/Task/Number-names/Perl/number-names.pl b/Task/Number-names/Perl/number-names.pl new file mode 100644 index 0000000000..ea069a615b --- /dev/null +++ b/Task/Number-names/Perl/number-names.pl @@ -0,0 +1,3 @@ +use Lingua::EN::Numbers 'num2en'; + +print num2en(123456789), "\n"; diff --git a/Task/Number-names/PicoLisp/number-names.l b/Task/Number-names/PicoLisp/number-names.l new file mode 100644 index 0000000000..1fded12189 --- /dev/null +++ b/Task/Number-names/PicoLisp/number-names.l @@ -0,0 +1,22 @@ +(de numName (N) + (cond + ((=0 N) "zero") + ((lt0 N) (pack "minus " (numName (- N)))) + (T (numNm N)) ) ) + +(de numNm (N) + (cond + ((=0 N)) + ((> 14 N) + (get '("one" "two" "three" "four" "five" "six" "seven" "eight" "nine" "ten" "eleven" "twelve" "thirteen") N) ) + ((= 15 N) "fifteen") + ((= 18 N) "eighteen") + ((> 20 N) (pack (numNm (% N 10)) "teen")) + ((> 100 N) + (pack + (get '("twen" "thir" "for" "fif" "six" "seven" "eigh" "nine") (dec (/ N 10))) + "ty" + (unless (=0 (% N 10)) + (pack "-" (numNm (% N 10))) ) ) ) + ((rank N '((100 . "hundred") (1000 . "thousand") (1000000 . "million"))) + (pack (numNm (/ N (car @))) " " (cdr @) " " (numNm (% N (car @)))) ) ) ) diff --git a/Task/Number-names/PowerBASIC/number-names.powerbasic b/Task/Number-names/PowerBASIC/number-names.powerbasic new file mode 100644 index 0000000000..f4653f71c1 --- /dev/null +++ b/Task/Number-names/PowerBASIC/number-names.powerbasic @@ -0,0 +1,68 @@ +FUNCTION int2Text (number AS QUAD) AS STRING + IF 0 = number THEN + FUNCTION = "zero" + EXIT FUNCTION + END IF + + DIM num AS QUAD, outP AS STRING, unit AS LONG + DIM tmpLng1 AS QUAD + + DIM small(1 TO 19) AS STRING, tens(7) AS STRING, big(5) AS STRING + + DIM tmpInt AS LONG, dcnt AS LONG + + ARRAY ASSIGN small() = "one", "two", "three", "four", "five", "six", _ + "seven", "eight", "nine", "ten", "eleven", _ + "twelve", "thirteen", "fourteen", "fifteen", _ + "sixteen", "seventeen", "eighteen", "nineteen" + ARRAY ASSIGN tens() = "twenty", "thirty", "forty", "fifty", "sixty", _ + "seventy", "eighty", "ninety" + ARRAY ASSIGN big() = "thousand", "million", "billion", "trillion", _ + "quadrillion", "quintillion" + + num = ABS(number) + + DO + tmpLng1 = num MOD 100 + SELECT CASE tmpLng1 + CASE 1 TO 19 + outP = small(tmpLng1) + " " + outP + CASE 20 TO 99 + SELECT CASE tmpLng1 MOD 10 + CASE 0 + outP = tens((tmpLng1 \ 10) - 2) + " " + outP + CASE ELSE + outP = tens((tmpLng1 \ 10) - 2) + "-" + small(tmpLng1 MOD 10) + " " + outP + END SELECT + END SELECT + + tmpLng1 = (num MOD 1000) \ 100 + IF tmpLng1 THEN + outP = small(tmpLng1) + " hundred " + outP + END IF + + num = num \ 1000 + IF num < 1 THEN EXIT DO + + tmpLng1 = num MOD 1000 + IF tmpLng1 THEN outP = big(unit) + " " + outP + + unit = unit + 1 + LOOP + + IF number < 0 THEN outP = "negative " + outP + + FUNCTION = RTRIM$(outP) +END FUNCTION + + +FUNCTION PBMAIN () AS LONG + DIM n AS QUAD + + #IF %DEF(%PB_CC32) + INPUT "Gimme a number! ", n + #ELSE + n = VAL(INPUTBOX$("Gimme a number!", "Now!")) + #ENDIF + ? int2Text(n) +END FUNCTION diff --git a/Task/Number-names/PureBasic/number-names-1.purebasic b/Task/Number-names/PureBasic/number-names-1.purebasic new file mode 100644 index 0000000000..469a04b249 --- /dev/null +++ b/Task/Number-names/PureBasic/number-names-1.purebasic @@ -0,0 +1,120 @@ +DataSection + numberNames: + ;small + Data.s "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten" + Data.s "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" + ;tens + Data.s "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety" + ;big, non-Chuquet system + Data.s "thousand", "million", "billion", "trillion", "quadrillion", "quintillion", "sextillion" + Data.s "septillion", "octillion", "nonillion", "decillion", "undecillion", "duodecillion" + Data.s "tredecillion" +EndDataSection + +Procedure.s numberWords(number.s) + ;handles integers from -1E45 to +1E45 + Static isInitialized = #False + Static Dim small.s(19) + Static Dim tens.s(9) + Static Dim big.s(14) + + If Not isInitialized + Restore numberNames + For i = 1 To 19 + Read.s small(i) + Next + For i = 2 To 9 + Read.s tens(i) + Next + For i = 1 To 14 + Read.s big(i) + Next + isInitialized = #True + EndIf + + For i = 1 To Len(number) + If Not FindString("- 0123456789", Mid(number,i,1), 1) + number = Left(number, i - 1) ;trim number to the last valid character + Break ;exit loop + EndIf + Next + + Protected IsNegative = #False + number = Trim(number) + If Left(number,1) = "-" + IsNegative = #True + number = Trim(Mid(number, 2)) + EndIf + + If CountString(number, "0") = Len(number) + ProcedureReturn "zero" + EndIf + + If Len(number) > 45 + ProcedureReturn "Number is too big!" + EndIf + + Protected num.s = number, output.s, unit, unitOutput.s, working + + Repeat + working = Val(Right(num, 2)) + unitOutput = "" + Select working + Case 1 To 19 + unitOutput = small(working) + Case 20 To 99 + If working % 10 + unitOutput = tens(working / 10) + "-" + small(working % 10) + Else + unitOutput = tens(working / 10) + EndIf + EndSelect + + working = Val(Right(num, 3)) / 100 + If working + If unitOutput <> "" + unitOutput = small(working) + " hundred " + unitOutput + Else + unitOutput = small(working) + " hundred" + EndIf + EndIf + + If unitOutput <> "" And unit > 0 + unitOutput + " " + big(unit) + If output <> "" + unitOutput + ", " + EndIf + EndIf + + output = unitOutput + output + + If Len(num) > 3 + num = Left(num, Len(num) - 3) + unit + 1 + Else + Break ;exit loop + EndIf + ForEver + + If IsNegative + output = "negative " + output + EndIf + + ProcedureReturn output +EndProcedure + +Define n$ +If OpenConsole() + Repeat + Repeat + Print("Give me an integer (or q to quit)! ") + n$ = Input() + Until n$ <> "" + + If Left(Trim(n$),1) = "q" + Break ;exit loop + EndIf + PrintN(numberWords(n$)) + ForEver + CloseConsole() +EndIf diff --git a/Task/Number-names/PureBasic/number-names-2.purebasic b/Task/Number-names/PureBasic/number-names-2.purebasic new file mode 100644 index 0000000000..ec60e1b8b0 --- /dev/null +++ b/Task/Number-names/PureBasic/number-names-2.purebasic @@ -0,0 +1,48 @@ +def spell_integer(n): + tens = [None, None, "twenty", "thirty", "forty", + "fifty", "sixty", "seventy", "eighty", "ninety"] + + small = ["zero", "one", "two", "three", "four", "five", + "six", "seven", "eight", "nine", "ten", "eleven", + "twelve", "thirteen", "fourteen", "fifteen", + "sixteen", "seventeen", "eighteen", "nineteen"] + + bl = [None, None, "m", "b", "tr", "quadr", + "quint", "sext", "sept", "oct", "non", "dec"] + + def nonzero(c, n): + return "" if n == 0 else c + spell_integer(n) + + def big(e, n): + if e == 0: + return spell_integer(n) + elif e == 1: + return spell_integer(n) + " thousand" + else: + return spell_integer(n) + " " + bl[e] + "illion" + + def base1000_rev(n): + # generates the value of the digits of n in base 1000 + # (i.e. 3-digit chunks), in reverse. + while n != 0: + n, r = divmod(n, 1000) + yield r + + if n < 0: + return "negative " + spell_integer(-n) + elif n < 20: + return small[n] + elif n < 100: + a, b = divmod(n, 10) + return tens[a] + nonzero("-", b) + elif n < 1000: + a, b = divmod(n, 100) + return small[a] + " hundred" + nonzero(" ", b) + else: + return ", ".join([big(e, x) for e, x in + enumerate(base1000_rev(n)) if x][::-1]) + +# example +print spell_integer(1278) +print spell_integer(1752) +print spell_integer(2010) diff --git a/Task/Number-names/Ruby/number-names.rb b/Task/Number-names/Ruby/number-names.rb new file mode 100644 index 0000000000..651944172c --- /dev/null +++ b/Task/Number-names/Ruby/number-names.rb @@ -0,0 +1,59 @@ +SMALL = %w(zero one two three four five six seven eight nine ten + eleven twelve thirteen fourteen fifteen sixteen seventeen + eighteen nineteen) + +TENS = %w(wrong wrong twenty thirty forty fifty sixty seventy + eighty ninety) + +BIG = [nil, "thousand"] + + %w( m b tr quadr quint sext sept oct non dec).map{ |p| "#{p}illion" } + + +def wordify number + if number < 0 + "negative #{wordify -number}" + + elsif number < 20 + SMALL[number] + + elsif number < 100 + div, mod = number.divmod(10) + "#{TENS[div]}-#{wordify mod}".chomp("-zero") + + elsif number < 1000 + div, mod = number.divmod(100) + "#{wordify div} hundred and #{wordify mod}".chomp(" and zero") + + else + # separate into 3-digit chunks + chunks = [] + div = number + while div != 0 + div, mod = div.divmod(1000) + chunks << mod # will store smallest to largest + end + + if chunks.length > BIG.length + raise ArgumentError, "Integer value too large." + end + + chunks.map{ |c| wordify c }. + zip(BIG). # zip pairs up corresponding elements from the two arrays + find_all { |c| c[0] != 'zero' }. + map{ |c| c.join ' '}. # join ["forty", "thousand"] + reverse. + join(', '). # join chunks + strip + end +end + +[-1123, 0, 1, 20, 123, 200, 220, 1245, 2000, 2200, 2220, 467889, 23_000_467, + 23_234_467, 2_235_654_234, 12_123_234_543_543_456, + 123890812938219038290489327894327894723897432].each do |n| + print "#{n}: " + begin + puts "'#{wordify n}'" + rescue => e + puts "Error: #{e}" + end +end diff --git a/Task/Number-names/Seed7/number-names.seed7 b/Task/Number-names/Seed7/number-names.seed7 new file mode 100644 index 0000000000..ea315c08c6 --- /dev/null +++ b/Task/Number-names/Seed7/number-names.seed7 @@ -0,0 +1,12 @@ +$ include "seed7_05.s7i"; + include "stdio.s7i"; + include "wrinum.s7i"; + +const proc: main is func + local + var integer: number is 0; + begin + for number range 1 to 999999 do + writeln(str(ENGLISH, number)); + end for; + end func; diff --git a/Task/Number-names/Tcl/number-names.tcl b/Task/Number-names/Tcl/number-names.tcl new file mode 100644 index 0000000000..6f0032665f --- /dev/null +++ b/Task/Number-names/Tcl/number-names.tcl @@ -0,0 +1,72 @@ +proc int2words {n} { + if { ! [regexp -- {^(-?\d+)$} $n -> n]} { + error "not a decimal integer" + } + if {$n == 0} { + return zero + } + if {$n < 0} { + return "negative [int2words [expr {abs($n)}]]" + } + if {[string length $n] > 36} { + error "value too large to represent" + } + + set groups [get_groups $n] + set l [llength $groups] + foreach group $groups { + incr l -1 + # ensure any group with a leading zero is not treated as octal + set val [scan $group %d] + if {$val > 0} { + lappend result [group2words $val $l] + } + } + return [join $result ", "] +} + +set small {"" one two three four five six seven eight nine ten eleven twelve + thirteen fourteen fifteen sixteen seventeen eighteen nineteen} +set tens {"" "" twenty thirty forty fifty sixty seventy eighty ninety} +set powers {"" thousand} +foreach p {m b tr quadr quint sext sept oct non dec} {lappend powers ${p}illion} + +proc group2words {n level} { + global small tens powers + if {$n < 20} { + lappend result [lindex $small $n] + } elseif {$n < 100} { + lassign [divmod $n 10] a b + set result [lindex $tens $a] + if {$b > 0} { + append result - [lindex $small $b] + } + } else { + lassign [divmod $n 100] a b + lappend result [lindex $small $a] hundred + if {$b > 0} { + lappend result and [group2words $b 0] + } + } + return [join [concat $result [lindex $powers $level]]] +} + +proc divmod {n d} { + return [list [expr {$n / $d}] [expr {$n % $d}]] +} + +proc get_groups {num} { + # from http://wiki.tcl.tk/5000 + while {[regsub {^([-+]?\d+)(\d\d\d)} $num {\1 \2} num]} {} + return [split $num] +} + +foreach test { + 0 -0 5 -5 10 25 99 100 101 999 1000 1008 1010 54321 1234567890 + 0x7F + 123456789012345678901234567890123456 + 1234567890123456789012345678901234567 +} { + catch {int2words $test} result + puts "$test -> $result" +} diff --git a/Task/Number-names/Visual-Basic-.NET/number-names.visual b/Task/Number-names/Visual-Basic-.NET/number-names.visual new file mode 100644 index 0000000000..50269848a6 --- /dev/null +++ b/Task/Number-names/Visual-Basic-.NET/number-names.visual @@ -0,0 +1,28 @@ +Module Module1 + + Sub Main() + Dim i As Integer + Console.WriteLine("Enter a number") + i = Console.ReadLine() + Console.WriteLine(words(i)) + Console.ReadLine() + End Sub + + Function words(ByVal Number As Integer) As String + Dim small() As String = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", + "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", + "eighteen", "nineteen"} + Dim tens() As String = {"", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"} + Select Case Number + Case Is < 20 + words = small(Number) + Case 20 To 99 + words = tens(Number \ 10) + " " + small(Number Mod 10) + Case 100 To 999 + words = small(Number \ 100) + " hundred " + IIf(((Number Mod 100) <> 0), "and ", "") + words(Number Mod 100) + Case 1000 + words = "one thousand" + End Select + End Function + +End Module diff --git a/Task/Number-names/Visual-Basic/number-names.vb b/Task/Number-names/Visual-Basic/number-names.vb new file mode 100644 index 0000000000..a87dee6ebe --- /dev/null +++ b/Task/Number-names/Visual-Basic/number-names.vb @@ -0,0 +1,60 @@ +Option Explicit + +Private small As Variant, tens As Variant, big As Variant + +Sub Main() + small = Array("one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", _ + "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", _ + "eighteen", "nineteen") + tens = Array("twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety") + big = Array("thousand", "million", "billion") + + Dim tmpInt As Long + tmpInt = Val(InputBox("Gimme a number!", "NOW!", Trim$(Year(Now)) & IIf(Month(Now) < 10, "0", "") & _ + Trim$(Month(Now)) & IIf(Day(Now) < 10, "0", "") & Trim$(Day(Now)))) + MsgBox int2Text$(tmpInt) +End Sub + +Function int2Text$(number As Long) + Dim num As Long, outP As String, unit As Integer + Dim tmpLng1 As Long + + If 0 = number Then + int2Text$ = "zero" + Exit Function + End If + + num = Abs(number) + + Do + tmpLng1 = num Mod 100 + Select Case tmpLng1 + Case 1 To 19 + outP = small(tmpLng1 - 1) + " " + outP + Case 20 To 99 + Select Case tmpLng1 Mod 10 + Case 0 + outP = tens((tmpLng1 \ 10) - 2) + " " + outP + Case Else + outP = tens((tmpLng1 \ 10) - 2) + "-" + small(tmpLng1 Mod 10) + " " + outP + End Select + End Select + + tmpLng1 = (num Mod 1000) \ 100 + If tmpLng1 Then + outP = small(tmpLng1 - 1) + " hundred " + outP + End If + + num = num \ 1000 + If num < 1 Then Exit Do + + tmpLng1 = num Mod 1000 + If tmpLng1 Then outP = big(unit) + " " + outP + + unit = unit + 1 + Loop + + If number < 0 Then outP = "negative " & outP + + int2Text$ = Trim$(outP) +End Function diff --git a/Task/Number-names/XPL0/number-names.xpl0 b/Task/Number-names/XPL0/number-names.xpl0 new file mode 100644 index 0000000000..0966e52463 --- /dev/null +++ b/Task/Number-names/XPL0/number-names.xpl0 @@ -0,0 +1,53 @@ +code ChOut=8, CrLf=9, Text=12; + +proc NumName(Dev, Num); \Output integer Num in prose to device Dev +int Dev, Num; +int OneTbl, TenTbl, ThoTbl, ThoPwr, I, Quot; + + proc Out999(N); \Output number in range 0..999 (0 does nothing) + int N; + int Huns, Tens, Ones; + [Huns:= N/100; \0..9 + N:= rem(0); \0..99 + Tens:= N/10; \0..9 + Ones:= rem(0); \0..9 + if Huns # 0 then + [Text(Dev, OneTbl(Huns)); \1..9 + Text(Dev, " hundred ")]; + if Tens >= 2 then + [Text(Dev, TenTbl(Tens)); + if Ones # 0 then + [ChOut(Dev, ^-); Text(Dev, OneTbl(Ones))]; + ] + else if N # 0 then Text(Dev, OneTbl(N)); \N = 1..19 + ]; + +[if Num = 0 then [Text(Dev, "zero"); return]; +if Num < 0 then [Num:= -Num; Text(Dev, "minus ")]; + +OneTbl:=[0, "one", "two", "three", "four", + "five", "six", "seven", "eight", "nine", + "ten", "eleven", "twelve", "thirteen", "fourteen", + "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"]; +TenTbl:=[0, 0, "twenty", "thirty", "forty", + "fifty", "sixty", "seventy", "eighty", "ninety"]; +ThoTbl:=[" billion ", " million ", " thousand "]; + +ThoPwr:= 1000000000; +for I:= 0 to 2 do + [Quot:= Num/ThoPwr; + Num:= rem(0); + if Quot # 0 then + [Out999(Quot); Text(Dev, ThoTbl(I))]; + ThoPwr:= ThoPwr/1000; + ]; +Out999(Num); +]; + +[NumName(0, 0); CrLf(0); +NumName(0, 13); CrLf(0); +NumName(0, 789); CrLf(0); +NumName(0, -604_001); CrLf(0); +NumName(0, 1_000_000); CrLf(0); +NumName(0, 1_234_567_890); CrLf(0); +] diff --git a/Task/Number-reversal-game/0DESCRIPTION b/Task/Number-reversal-game/0DESCRIPTION new file mode 100644 index 0000000000..7dd87ad7d9 --- /dev/null +++ b/Task/Number-reversal-game/0DESCRIPTION @@ -0,0 +1,12 @@ +Given a jumbled list of the numbers 1 to 9 that are definitely ''not'' in ascending order, show the list then +ask the player how many digits from the left to reverse. +Reverse those digits, then ask again, until all the +digits end up in ascending order. + +The score is the count of the reversals needed to attain the ascending order. + +Note: Assume the players input does not need extra validation. + +;Cf. +* [[Sorting algorithms/Pancake sort]], [[wp:Pancake sorting|Pancake sorting]]. +* [[Topswops]] diff --git a/Task/Number-reversal-game/1META.yaml b/Task/Number-reversal-game/1META.yaml new file mode 100644 index 0000000000..a2413d963b --- /dev/null +++ b/Task/Number-reversal-game/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Games diff --git a/Task/Number-reversal-game/AWK/number-reversal-game.awk b/Task/Number-reversal-game/AWK/number-reversal-game.awk new file mode 100644 index 0000000000..1d28e2c18e --- /dev/null +++ b/Task/Number-reversal-game/AWK/number-reversal-game.awk @@ -0,0 +1,79 @@ +BEGIN { + print "\nWelcome to the number reversal game!\n" + + print "You must put the numbers in order from 1 to 9." + print "Your only moves are to reverse groups of numbers" + print "on the left side of the list." + + newgame() + prompt() +} + +# start a new game +function newgame( i, j, t) { + # score = number of moves + score = 0 + + # list = list of numbers + split("123456789", list, "") + do { + # Knuth shuffle + for (i = 9; i > 1; i--) { + j = int(i * rand()) + 1 + t = list[i] + list[i] = list[j] + list[j] = t + } + } while (win()) +} + +# numbers in order? +function win( i) { + # check if list[1] == 1, list[2] == 2, ... + for (i = 1; i <= 9; i++) if (list[i] != i) return 0 + return 1 +} + +# user prompt +function prompt( i) { + printf "\nYour list: " + for (i = 1; i < 9; i++) printf "%d, ", list[i] + printf "%d\n", list[9] + + if (win()) { + print "YOU WIN!" + printf "Your score is %d moves.\n", score + printf "Would you like to play again (y/n)? " + again = 1 + } else { + printf "How many numbers to reverse? " + } +} + +# user input in $1 +{ + if (again) { + again = 0 + if (tolower(substr($1, 1, 1)) == "y") + newgame() + else + exit + } else { + score += 1 + reverse($1) + } + prompt() +} + +function reverse(right, left, t) { + left = 1 + while (right > left) { + t = list[left] + list[left] = list[right] + list[right] = t + left++ + right-- + } +} + +END { print "\n\nBye!" } diff --git a/Task/Number-reversal-game/Ada/number-reversal-game.ada b/Task/Number-reversal-game/Ada/number-reversal-game.ada new file mode 100644 index 0000000000..eb790cf0d6 --- /dev/null +++ b/Task/Number-reversal-game/Ada/number-reversal-game.ada @@ -0,0 +1,75 @@ +with Ada.Text_Io; use Ada.Text_Io; +with Ada.Integer_Text_Io; use Ada.Integer_Text_Io; +with Ada.Numerics.Discrete_Random; + +procedure NumberReverse is + + subtype RandRange is Integer range 1..9; + type NumArrayType is array (Integer range 1..9) of Integer; + + package RandNumbers is new Ada.Numerics.Discrete_Random(RandRange); + use RandNumbers; + + G : Generator; + + procedure FillArray (A : in out NumArrayType) is + Temp : RandRange; + begin + A := (others => 0); + for I in 1..9 loop + Temp := Random(G); + while A(Temp) /= 0 loop + Temp := Random(G); + end loop; + A(Temp) := I; + end loop; + end FillArray; + + procedure Put(A : in NumArrayType) is + begin + for I in 1..9 loop + Put(A(I), 0); + Put(" "); + end loop; + end Put; + + procedure Prompt (Index : out Integer) is + begin + New_Line; + Put("How many numbers would you like to reverse: "); + Get(Index); + end Prompt; + + procedure ReverseArray(Arr : in out NumArrayType; + Index : in Integer) is + Temp : RandRange; + begin + for I in 1..Index/2 loop + Temp := Arr(I); + Arr(I) := Arr(Index + 1 - I); + Arr(Index + 1 - I) := Temp; + end loop; + end ReverseArray; + + Sorted : constant NumArrayType := (1,2,3,4,5,6,7,8,9); + Arr : NumArrayType; + Index : Integer; + Count : Integer := 0; +begin + Reset(G); + loop + FillArray(Arr); + exit when Sorted /= Arr; + end loop; + loop + Put(Arr); + Prompt(Index); + Count := Count + 1; + ReverseArray(Arr, Index); + exit when Sorted = Arr; + end loop; + Put(Arr); + New_Line; + Put("Congratulations! You win. It took " & + Integer'Image(Count) & " tries."); +end NumberReverse; diff --git a/Task/Number-reversal-game/AutoHotkey/number-reversal-game.ahk b/Task/Number-reversal-game/AutoHotkey/number-reversal-game.ahk new file mode 100644 index 0000000000..188a82c18d --- /dev/null +++ b/Task/Number-reversal-game/AutoHotkey/number-reversal-game.ahk @@ -0,0 +1,34 @@ +; Submitted by MasterFocus --- http://tiny.cc/iTunis + +ScrambledList := CorrectList := "1 2 3 4 5 6 7 8 9" ; Declare two identical correct sequences +While ( ScrambledList = CorrectList ) + Sort, ScrambledList, Random D%A_Space% ; Shuffle one of them inside a While-loop to ensure it's shuffled + +Attempts := 0 +While ( ScrambledList <> CorrectList ) ; Repeat until the sequence is correct +{ + InputBox, EnteredNumber, Number Reversal Game, Attempts so far: %Attempts%`n`nCurrent sequence: %ScrambledList%`n`nHow many numbers (from the left) should be flipped?, , 400, 200 + If ErrorLevel + ExitApp ; Exit if user presses ESC or Cancel + If EnteredNumber is not integer + Continue ; Discard attempt if entered number is not an integer + If ( EnteredNumber <= 1 ) + Continue ; Discard attempt if entered number is <= 1 + Attempts++ ; Increase the number of attempts + ; Reverse the first part of the string and add the second part + ; The entered number is multiplied by 2 to deal with the spaces + ScrambledList := Reverse(SubStr(ScrambledList,1,(EnteredNumber*2)-1)) SubStr(ScrambledList,EnteredNumber*2) +} + +MsgBox, You took %Attempts% attempts to get the correct sequence. ; Final message + +Return + +;------------------- + +Reverse(Str) ; Auxiliar function (flips a string) +{ + Loop, Parse, Str + Out := A_LoopField Out + Return Out +} diff --git a/Task/Number-reversal-game/BASIC/number-reversal-game.basic b/Task/Number-reversal-game/BASIC/number-reversal-game.basic new file mode 100644 index 0000000000..a18ba890b1 --- /dev/null +++ b/Task/Number-reversal-game/BASIC/number-reversal-game.basic @@ -0,0 +1,55 @@ +PRINT "Given a jumbled list of the numbers 1 to 9," +PRINT "you must select how many digits from the left to reverse." +PRINT "Your goal is to get the digits in order with 1 on the left and 9 on the right." + +RANDOMIZE TIMER + +DIM nums(1 TO 9) AS INTEGER +DIM L0 AS INTEGER, n AS INTEGER, flp AS INTEGER, tries AS INTEGER, again AS INTEGER + +'initial values +FOR L0 = 1 TO 9 + nums(L0) = L0 +NEXT + +DO 'shuffle + FOR L0 = 9 TO 2 STEP -1 + n = INT(RND * (L0)) + 1 + IF n <> L0 THEN SWAP nums(n), nums(L0) + NEXT + FOR L0 = 1 TO 8 'make sure it's not in order + IF nums(L0) > nums(L0 + 1) THEN EXIT DO + NEXT +LOOP + +again = -1 +DO + IF tries < 10 THEN PRINT " "; + PRINT tries; ":"; + FOR L0 = 1 TO 9 + PRINT nums(L0); + NEXT + + IF NOT again THEN EXIT DO + + INPUT " -- How many numbers should be flipped"; flp + IF flp < 0 THEN flp = 0 + IF flp > 9 THEN flp = 0 + + FOR L0 = 1 TO (flp \ 2) + SWAP nums(L0), nums(flp - L0 + 1) + NEXT + + again = 0 + 'check for order + FOR L0 = 1 TO 8 + IF nums(L0) > nums(L0 + 1) THEN + again = -1 + EXIT FOR + END IF + NEXT + + IF flp > 0 THEN tries = tries + 1 +LOOP + +PRINT : PRINT "You took "; LTRIM$(RTRIM$(STR$(tries))); " tries to put the digits in order." diff --git a/Task/Number-reversal-game/BBC-BASIC/number-reversal-game.bbc b/Task/Number-reversal-game/BBC-BASIC/number-reversal-game.bbc new file mode 100644 index 0000000000..47ca6b4455 --- /dev/null +++ b/Task/Number-reversal-game/BBC-BASIC/number-reversal-game.bbc @@ -0,0 +1,32 @@ + DIM list%(8), done%(8), test%(8) + list%() = 1, 2, 3, 4, 5, 6, 7, 8, 9 + done%() = list%() + + REM Shuffle: + REPEAT + FOR i% = 9 TO 2 STEP -1 + SWAP list%(i%-1), list%(RND(i%)-1) + NEXT + test%() = list%() - done%() + UNTIL MOD(test%()) <> 0 + + REM Run the game: + tries% = 0 + REPEAT + tries% += 1 + FOR i% = 0 TO 8 : PRINT ; list%(i%) " " ; : NEXT + INPUT ": Reverse how many", n% + PROCreverse(list%(), n%) + test%() = list%() - done%() + UNTIL MOD(test%()) = 0 + PRINT "You took " ; tries% " attempts." + END + + DEF PROCreverse(a%(), n%) + IF n% < 2 ENDPROC + LOCAL i% + n% -= 1 + FOR i% = 0 TO n% DIV 2 + SWAP a%(i%), a%(n%-i%) + NEXT + ENDPROC diff --git a/Task/Number-reversal-game/Brat/number-reversal-game.brat b/Task/Number-reversal-game/Brat/number-reversal-game.brat new file mode 100644 index 0000000000..f8466a1e40 --- /dev/null +++ b/Task/Number-reversal-game/Brat/number-reversal-game.brat @@ -0,0 +1,19 @@ +sorted = 1.to 9 +length = sorted.length +numbers = sorted.shuffle + +#Make certain numbers are shuffled +true? numbers == sorted + { while { sorted == numbers.shuffle! } } + +turns = 0 + +while { numbers != sorted } { + print "#{numbers} - How many to reverse? " + num = g.to_i + numbers = numbers[0, num - 1].reverse + numbers[num, length] + turns = turns + 1 +} + +p numbers +p "It took #{turns} turns to sort numbers." diff --git a/Task/Number-reversal-game/C++/number-reversal-game-1.cpp b/Task/Number-reversal-game/C++/number-reversal-game-1.cpp new file mode 100644 index 0000000000..c00a915431 --- /dev/null +++ b/Task/Number-reversal-game/C++/number-reversal-game-1.cpp @@ -0,0 +1,34 @@ +void number_reversal_game() +{ + cout << "Number Reversal Game. Type a number to flip the first n numbers."; + cout << "You win by sorting the numbers in ascending order."; + cout << "Anything besides numbers are ignored.\n"; + cout << "\t |1__2__3__4__5__6__7__8__9|\n"; + int list[9] = {1,2,3,4,5,6,7,8,9}; + do + { + shuffle_list(list,9); + } while(check_array(list, 9)); + + int tries=0; + unsigned int i; + int input; + + while(!check_array(list, 9)) + { + cout << "Round " << tries << ((tries<10) ? " : " : " : "); + for(i=0;i<9;i++)cout << list[i] << " "; + cout << " Gimme that number:"; + while(1) + { + cin >> input; + if(input>1&&input<10) + break; + + cout << "\nPlease enter a number between 2 and 9:"; + } + tries++; + do_flip(list, 9, input); + } + cout << "Hurray! You solved it in %d moves!\n"; +} diff --git a/Task/Number-reversal-game/C++/number-reversal-game-2.cpp b/Task/Number-reversal-game/C++/number-reversal-game-2.cpp new file mode 100644 index 0000000000..ec04673852 --- /dev/null +++ b/Task/Number-reversal-game/C++/number-reversal-game-2.cpp @@ -0,0 +1,50 @@ +#include +#include +#include +#include +#include +#include + +template + bool is_sorted(T (&array)[size]) +{ + return std::adjacent_find(array, array+size, std::greater()) + == array+size; +} + +int main() +{ + std::srand(std::time(0)); + + int list[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + + do + { + std::random_shuffle(list, list+9); + } while (is_sorted(list)); + + int score = 0; + + do + { + std::cout << "Current list: "; + std::copy(list, list+9, std::ostream_iterator(std::cout, " ")); + + int rev; + while (true) + { + std::cout << "\nDigits to reverse? "; + std::cin >> rev; + if (rev > 1 && rev < 10) + break; + std::cout << "Please enter a value between 2 and 9."; + } + + ++score; + std::reverse(list, list + rev); + } while (!is_sorted(list)); + + std::cout << "Congratulations, you sorted the list.\n" + << "You needed " << score << " reversals." << std::endl; + return 0; +} diff --git a/Task/Number-reversal-game/C/number-reversal-game-1.c b/Task/Number-reversal-game/C/number-reversal-game-1.c new file mode 100644 index 0000000000..560f1d99c7 --- /dev/null +++ b/Task/Number-reversal-game/C/number-reversal-game-1.c @@ -0,0 +1,32 @@ +void number_reversal_game() +{ + printf("Number Reversal Game. Type a number to flip the first n numbers."); + printf("Win by sorting the numbers in ascending order.\n"); + printf("Anything besides numbers are ignored.\n"); + printf("\t |1__2__3__4__5__6__7__8__9|\n"); + int list[9] = {1,2,3,4,5,6,7,8,9}; + shuffle_list(list,9); + + int tries=0; + unsigned int i; + int input; + + while(!check_array(list, 9)) + { + ((tries<10) ? printf("Round %d : ", tries) : printf("Round %d : ", tries)); + for(i=0;i<9;i++)printf("%d ",list[i]); + printf(" Gimme that number:"); + while(1) + { + //Just keep asking for proper input + scanf("%d", &input); + if(input>1&&input<10) + break; + + printf("\n%d - Please enter a number between 2 and 9:", (int)input); + } + tries++; + do_flip(list, 9, input); + } + printf("Hurray! You solved it in %d moves!\n", tries); +} diff --git a/Task/Number-reversal-game/C/number-reversal-game-2.c b/Task/Number-reversal-game/C/number-reversal-game-2.c new file mode 100644 index 0000000000..ae235ae98e --- /dev/null +++ b/Task/Number-reversal-game/C/number-reversal-game-2.c @@ -0,0 +1,44 @@ +void shuffle_list(int *list, int len) +{ + //We'll just be swapping 100 times. Could be more/less. Doesn't matter much. + int n=100; + int a=0; + int b=0; + int buf = 0; + //Random enough for common day use.. + srand(time(NULL)); + while(n--) + { + //Get random locations and swap + a = rand()%len; + b = rand()%len; + buf = list[a]; + list[a] = list[b]; + list[b] = buf; + } + // "shuffled to ordered state" fix: + if (check_array(list, len)) shuffle_list (list, len); +} + +void do_flip(int *list, int length, int num) +{ + //Flip a part on an array + int swap; + int i=0; + for(i;i<--num;i++) + { + swap=list[i]; + list[i]=list[num]; + list[num]=swap; + } +} + +int check_array(int *arr, int len) +{ + while(--len) + { + if(arr[len]!=(arr[len-1]+1)) + return 0; + } + return 1; +} diff --git a/Task/Number-reversal-game/Clojure/number-reversal-game.clj b/Task/Number-reversal-game/Clojure/number-reversal-game.clj new file mode 100644 index 0000000000..e58f917f6d --- /dev/null +++ b/Task/Number-reversal-game/Clojure/number-reversal-game.clj @@ -0,0 +1,16 @@ +(defn flip-at [n coll] + (let [[x y] (split-at n coll)] + (concat (reverse x) y ))) + +(def sorted '(1 2 3 4 5 6 7 8 9)) ; i.e. (range 1 10) +(def unsorted? #(not= % sorted)) + +(loop [unsorted (first (filter unsorted? (iterate shuffle sorted))), steps 0] + (if (= unsorted sorted) + (printf "Done! That took you %d steps%n" steps) + (do + (println unsorted) + (printf "Reverse how many? ") + (flush) + (let [flipcount (read)] + (recur (flip-at flipcount unsorted), (inc steps)))))) diff --git a/Task/Number-reversal-game/Common-Lisp/number-reversal-game.lisp b/Task/Number-reversal-game/Common-Lisp/number-reversal-game.lisp new file mode 100644 index 0000000000..075f97b180 --- /dev/null +++ b/Task/Number-reversal-game/Common-Lisp/number-reversal-game.lisp @@ -0,0 +1,32 @@ +(defun shuffle! (vector) + (loop for i from (1- (length vector)) downto 1 + do (rotatef (aref vector i) + (aref vector (random i))))) + +(defun slice (vector start &optional end) + (let ((end (or end (length vector)))) + (make-array (- end start) + :element-type (array-element-type vector) + :displaced-to vector + :displaced-index-offset start))) + +(defun orderedp (seq) + (apply #'<= (coerce seq 'list))) + +(defun prompt-integer (prompt) + (format t "~A: " prompt) + (finish-output) + (clear-input) + (parse-integer (read-line))) + +(defun game () + (let ((numbers (vector 1 2 3 4 5 6 7 8 9))) + (shuffle! numbers) + (let ((score + (do ((score 0 (1+ score))) + ((orderedp numbers) score) + (format t "~A~%" numbers) + (let* ((n (prompt-integer "How many numbers to reverse")) + (slice (slice numbers 0 n))) + (replace slice (nreverse slice)))))) + (format t "~A~%Congratulations, you did it in ~D reversals!~%" numbers score)))) diff --git a/Task/Number-reversal-game/D/number-reversal-game.d b/Task/Number-reversal-game/D/number-reversal-game.d new file mode 100644 index 0000000000..9037386310 --- /dev/null +++ b/Task/Number-reversal-game/D/number-reversal-game.d @@ -0,0 +1,15 @@ +import std.stdio, std.random, std.string, std.conv, std.algorithm, + std.range; + +void main() { + auto data = iota(1, 10).array(); + do data.randomShuffle(); + while (data.isSorted()); + + int trial; + while (!data.isSorted()) { + writef("%d: %s How many numbers to flip? ", ++trial, data); + data[0 .. readln().strip().to!size_t()].reverse(); + } + writefln("\nYou took %d attempts.", trial); +} diff --git a/Task/Number-reversal-game/Euphoria/number-reversal-game.euphoria b/Task/Number-reversal-game/Euphoria/number-reversal-game.euphoria new file mode 100644 index 0000000000..24b913314c --- /dev/null +++ b/Task/Number-reversal-game/Euphoria/number-reversal-game.euphoria @@ -0,0 +1,55 @@ +include get.e + +function accending(sequence s) + for i = 1 to length(s)-1 do + if s[i]>s[i+1] then + return 0 + end if + end for + return 1 +end function + +puts(1,"Given a jumbled list of the numbers 1 to 9,\n") +puts(1,"you must select how many digits from the left to reverse.\n") +puts(1,"Your goal is to get the digits in order with 1 on the left and 9 on the right.\n") + +sequence nums +nums = repeat(0,9) +integer n,flp,tries,temp + +-- initial values +for i = 1 to 9 do + nums[i] = i +end for + +while accending(nums) do -- shuffle + for i = 1 to 9 do + n = rand(9) + temp = nums[n] + nums[n] = nums[i] + nums[i] = temp + end for +end while + +tries = 0 +while 1 do + printf(1,"%2d : ",tries) + for i = 1 to 9 do + printf(1,"%d ",nums[i]) + end for + + if accending(nums) then + exit + end if + + flp = prompt_number(" -- How many numbers should be flipped? ",{1,9}) + for i = 1 to flp/2 do + temp = nums[i] + nums[i] = nums[flp-i+1] + nums[flp-i+1] = temp + end for + + tries += 1 +end while + +printf(1,"\nYou took %d tries to put the digits in order.", tries) diff --git a/Task/Number-reversal-game/Factor/number-reversal-game.factor b/Task/Number-reversal-game/Factor/number-reversal-game.factor new file mode 100644 index 0000000000..bdcc770c27 --- /dev/null +++ b/Task/Number-reversal-game/Factor/number-reversal-game.factor @@ -0,0 +1,30 @@ +USING: formatting io kernel math math.parser math.ranges +namespaces random sequences strings ; +IN: rosetta.number-reversal + +: make-jumbled-array ( -- sorted jumbled ) + CHAR: 1 CHAR: 9 [a,b] [ 1string ] map dup clone randomize + [ 2dup = ] [ randomize ] while ; + +SYMBOL: trials + +: prompt ( jumbled -- n ) + trials get "#%2d: " printf + ", " join write + " Flip how many? " write flush + readln string>number ; + +: game-loop ( sorted jumbled -- ) + 2dup = [ + 2drop trials get + "\nYou took %d attempts to put the digits in order!\n" printf + flush + ] [ + trials [ 1 + ] change + dup dup prompt head-slice reverse! drop + game-loop + ] if ; + +: play ( -- ) + 0 trials set + make-jumbled-array game-loop ; diff --git a/Task/Number-reversal-game/Forth/number-reversal-game.fth b/Task/Number-reversal-game/Forth/number-reversal-game.fth new file mode 100644 index 0000000000..3c64426a83 --- /dev/null +++ b/Task/Number-reversal-game/Forth/number-reversal-game.fth @@ -0,0 +1,49 @@ +include random.fs + +variable flips +create nums 9 cells allot + +: .array ( addr len -- ) 0 ?do dup @ . cell+ loop drop ; + +: shuffle ( addr len -- ) + 2 swap do + dup i random cells + + over @ over @ swap + rot ! over ! + cell+ + -1 +loop drop ; + +: sorted? ( addr len -- ) + 1- cells bounds ?do + i 2@ < if unloop false exit then + cell +loop true ; + +: init + 0 flips ! + nums 10 1 do + i over ! cell+ + loop drop + begin nums 9 shuffle nums 9 sorted? 0= until + cr nums 9 .array ; + +: reverse ( addr len -- ) + 1- cells bounds + begin 2dup > + while over @ over @ >r over ! over r> swap ! + cell+ swap 1 cells - swap + repeat 2drop ; + +: flip ( n -- ) + dup 2 10 within 0= if . ." must be within 2 to 9" exit then + nums swap reverse + 1 flips +! + nums 9 sorted? if + cr ." Got it in " flips @ . ." tries!" + else + cr nums 9 .array + then ; + +init +1 2 8 5 7 6 9 4 3 ok +7 flip +9 6 7 5 8 2 1 4 3 ok diff --git a/Task/Number-reversal-game/Fortran/number-reversal-game.f b/Task/Number-reversal-game/Fortran/number-reversal-game.f new file mode 100644 index 0000000000..7c86f1bbc3 --- /dev/null +++ b/Task/Number-reversal-game/Fortran/number-reversal-game.f @@ -0,0 +1,54 @@ +program Reversal_game + implicit none + + integer :: list(9) = (/ 1, 2, 3, 4, 5, 6, 7, 8, 9 /) + integer :: pos, attempts = 0 + + call random_seed + do while (sorted(list)) + call Shuffle(list) + end do + write(*, "(9i5)") list + write(*,*) + do while (.not. Sorted(list)) + write(*, "(a)", advance="no") "How many numbers from the left do you want to reverse? : " + read*, pos + attempts = attempts + 1 + list(1:pos) = list(pos:1:-1) + write(*, "(9i5)") list + write(*,*) + end do + write(*,*) + write(*, "(a,i0,a)") "Congratulations! Solved in ", attempts, " attempts" + +contains + +subroutine Shuffle(a) + integer, intent(inout) :: a(:) + integer :: i, randpos, temp + real :: r + + do i = size(a), 2, -1 + call random_number(r) + randpos = int(r * i) + 1 + temp = a(randpos) + a(randpos) = a(i) + a(i) = temp + end do +end subroutine + +function Sorted(a) + logical :: Sorted + integer, intent(in) :: a(:) + integer :: i + + do i = 1, size(a)-1 + if(list(i+1) /= list(i)+1) then + Sorted = .false. + return + end if + end do + Sorted = .true. +end function + +end program diff --git a/Task/Number-reversal-game/Go/number-reversal-game.go b/Task/Number-reversal-game/Go/number-reversal-game.go new file mode 100644 index 0000000000..365ec68c78 --- /dev/null +++ b/Task/Number-reversal-game/Go/number-reversal-game.go @@ -0,0 +1,43 @@ +package main + +import ( + "fmt" + "math/rand" + "sort" + "time" +) + +func main() { + rand.Seed(time.Now().UnixNano()) + var k []int + for { + k = rand.Perm(9) + for i, r := range k { + if r == 0 { + k[i] = 9 + } + } + if !sort.IntsAreSorted(k) { + break + } + } + fmt.Println("Sort digits by reversing a number of digits on the left.") + var n, score int + for { + fmt.Print("Digits: ", k, ". How many to reverse? ") + i, _ := fmt.Scanln(&n) + score++ + if i == 0 || n < 2 || n > 9 { + fmt.Println("\n(Enter a number from 2 to 9)") + continue + } + for l, r := 0, n-1; l < r; l, r = l+1, r-1 { + k[l], k[r] = k[r], k[l] + } + if sort.IntsAreSorted(k) { + fmt.Print("Digits: ", k, ".\n") + fmt.Print("Your score: ", score, ". Good job.\n") + return + } + } +} diff --git a/Task/Number-reversal-game/Groovy/number-reversal-game.groovy b/Task/Number-reversal-game/Groovy/number-reversal-game.groovy new file mode 100644 index 0000000000..5f6329362b --- /dev/null +++ b/Task/Number-reversal-game/Groovy/number-reversal-game.groovy @@ -0,0 +1,15 @@ +sorted = [*(1..9)] +arr = sorted.clone() + +void flipstart(n) { arr[0.. digits($) ! $ = left side index + IF( SUM(temp) == 8 ) RETURN + ENDDO +END diff --git a/Task/Number-reversal-game/Icon/number-reversal-game.icon b/Task/Number-reversal-game/Icon/number-reversal-game.icon new file mode 100644 index 0000000000..c04a9536ae --- /dev/null +++ b/Task/Number-reversal-game/Icon/number-reversal-game.icon @@ -0,0 +1,68 @@ +procedure main(cq) # Number Reversal Game +local x,nums,R,flips + +$define PROTECT ["WIN","ASK"] +$define MAGIC ["xyzzy","abracadabra","hocus","pocus","presto","changeo","open","sesame","irs"] + +put(cq,"game") # start command queue - use command line +rule := string(&digits--'0') # ruler and move commands +every put(protected := [], map(!PROTECT)) # protected commands +every put(magic := [], !MAGIC) + +while x := get(cq) | "MOVE" do { # command from queue or ask for move + case x of { + "help" | "h" | "?" : # --- start of user facing commands --- + write("Input a position. The list will be flipped left to right at that point.\n", + "You win when the list is sorted.\n", + "Commands:\n", + " help, h, ? - shows this\n", + " new, g - new game\n", + " ruler, r - shows a ruler\n", + " show, s - shows the list\n", + " - flips the list at ruler position n\n", + " quit, q - quit\n", + "and various magic words.\n" + ) & put(cq,"rule") + "game" | "g" | "new" : { + put(cq,"help") + flips := 0 + nums := rule + until nums ~== rule do + every !nums :=: ?nums # shuffle + } + "rule" | "ruler" | "r" : + put(cq,"show") & every writes(" " || " " | !(if /mirror then rule else reverse(rule)) | "\n") + "show" | "s" : + every writes(" " || "=" | !nums | " =\n") + !rule : { # 0 - 9 for flipping + if /mirror then nums[1+:x] := reverse(nums[1+:x]) + else nums[0-:x] := reverse(nums[0-:x]) + flips +:= 1 + put(cq,if nums == rule then "WIN" else "show") + } + "quit" | "q" : + break write("Goodbye.") + !magic: # --- start of magic + write("That has no power here. Try again!") + "magic" | "mirror" | "m" : { + mirror := if /mirror then 1 else &null + write("Wait! What is this? The writing has reversed.") + } + !protected: # --- Start of internal (upper case) and protected commands + put(cq,?rule) & write("Tisk, Tisk, don't try and cheat. Take a random penalty flip!") + "MOVE" : + put(cq,ask("Command? : ") ) + "WIN" : + put(cq,"ASK") & write("Congratulations you won in ",flips," flips!") + "ASK" : + put(cq,case ask("Play another game? : ") of { "y"|"yes" : "game"; "n"|"no" : "quit"; default : "ASK" } ) + default: # --- say what? + write("Sorry I don't know that command, try help?") + } + } +end + +procedure ask(s) #: ask for input with prompt s and return the 1st word in lower case +writes(\s) +map(trim(read())) ? return tab(upto(' ')|0) +end diff --git a/Task/Number-reversal-game/Inform-7/number-reversal-game.inf b/Task/Number-reversal-game/Inform-7/number-reversal-game.inf new file mode 100644 index 0000000000..b4be14e35b --- /dev/null +++ b/Task/Number-reversal-game/Inform-7/number-reversal-game.inf @@ -0,0 +1,40 @@ +Number Reversal Game is a room. + +The current list is a list of numbers that varies. + +When play begins: + now the current list is a shuffled list from 1 to 9; + now the command prompt is "Current list: [current list in brace notation].[line break]How many items to flip? ". + +Definition: a list of numbers (called L) is sorted: + repeat with N running from 1 to the number of entries in L: + if entry N in L is not N, no; + yes. + +To decide which list of numbers is a shuffled list from (min - number) to (max - number): + let result be a list of numbers; + repeat with N running from min to max: + add N to result; + while true is true: + sort result in random order; + if result is not sorted, decide on result. + +Flipping is an action applying to one number. Understand "[number]" as flipping. + +Carry out flipping: + let N be the number understood; + let L be the current list; + truncate the current list to the first N entries; + reverse the current list; + truncate L to the last (number of entries in L minus N) entries; + add L to the current list. + +Report flipping: say "". + +Every turn: + if the current list is sorted, end the story saying "You have won". + +This is the new print final score rule: + say "It took you [turn count] flip[s] to sort the list." + +The new print final score rule is listed instead of the print final score rule in the for printing the player's obituary rules. diff --git a/Task/Number-reversal-game/Io/number-reversal-game.io b/Task/Number-reversal-game/Io/number-reversal-game.io new file mode 100644 index 0000000000..55d5f46596 --- /dev/null +++ b/Task/Number-reversal-game/Io/number-reversal-game.io @@ -0,0 +1,19 @@ +withRange := method( a, z, + Range clone setRange(a,z) +) +sorted := withRange(1,9) asList +numbers := sorted clone shuffle +while( numbers==sorted, numbers = numbers shuffle) + +steps :=0 +stdin := File standardInput +while( numbers != sorted, + writeln(numbers join(" ")) + write("Reverse how many? ") + flipcount := stdin readLine asNumber + withRange(0, ((flipcount-1)/2) floor) foreach( i, + numbers swapIndices(i,flipcount-1-i) + ) + steps = steps+1 +) +writeln("Done! That took you ", steps, " steps") diff --git a/Task/Number-reversal-game/J/number-reversal-game-1.j b/Task/Number-reversal-game/J/number-reversal-game-1.j new file mode 100644 index 0000000000..90e5ebcb12 --- /dev/null +++ b/Task/Number-reversal-game/J/number-reversal-game-1.j @@ -0,0 +1,22 @@ +require 'misc' NB. for the verb prompt + +INTRO=: noun define +Number Reversal Game +Flip groups of numbers from the left of the list until +the numbers are sorted in ascending order. +) + +reversegame=: verb define + whilst. (-: /:~)nums do. + nums=. 1+9?9 NB. 1-9 in random order + end. + score=. 0 + smoutput INTRO NB. Display instructions + while. -.(-: /:~)nums do. + score=. 1+ score NB. increment score + nnum=. 0".prompt (":score),': ',(":nums),' How many numbers to flip?: ' + if. 0 = #nnum do. return. end. NB. exit on ENTER without number + nums=. (C.i.-nnum) C. nums NB. reverse first nnum numbers + end. + 'You took ',(": score), ' attempts to put the numbers in order.' +) diff --git a/Task/Number-reversal-game/J/number-reversal-game-2.j b/Task/Number-reversal-game/J/number-reversal-game-2.j new file mode 100644 index 0000000000..ae0a0264e1 --- /dev/null +++ b/Task/Number-reversal-game/J/number-reversal-game-2.j @@ -0,0 +1,17 @@ + reversegame'' +Number Reversal Game +Sort the numbers in ascending order by repeatedly +flipping sets of numbers from the left. + +1: 4 7 5 6 9 1 2 8 3 How many numbers to flip?: 5 +2: 9 6 5 7 4 1 2 8 3 How many numbers to flip?: 9 +3: 3 8 2 1 4 7 5 6 9 How many numbers to flip?: 2 +4: 8 3 2 1 4 7 5 6 9 How many numbers to flip?: 8 +5: 6 5 7 4 1 2 3 8 9 How many numbers to flip?: 3 +6: 7 5 6 4 1 2 3 8 9 How many numbers to flip?: 7 +7: 3 2 1 4 6 5 7 8 9 How many numbers to flip?: 5 +8: 6 4 1 2 3 5 7 8 9 How many numbers to flip?: 6 +9: 5 3 2 1 4 6 7 8 9 How many numbers to flip?: 5 +10: 4 1 2 3 5 6 7 8 9 How many numbers to flip?: 4 +11: 3 2 1 4 5 6 7 8 9 How many numbers to flip?: 3 +You took 11 attempts to put the numbers in order. diff --git a/Task/Number-reversal-game/Java/number-reversal-game.java b/Task/Number-reversal-game/Java/number-reversal-game.java new file mode 100644 index 0000000000..da8df1c7f3 --- /dev/null +++ b/Task/Number-reversal-game/Java/number-reversal-game.java @@ -0,0 +1,73 @@ +import java.util.List; +import java.util.ArrayList; +import java.util.Scanner; +import java.util.Collections; + + +public class ReversalGame { + private List gameList; + + public ReversalGame() { + initialize(); + } + + public void play() throws Exception { + int i = 0; + int moveCount = 0; + Scanner scanner = new Scanner(System.in); + while (true) { + System.out.println(gameList); + System.out.println("Please enter a index to reverse from 2 to 9. Enter 99 to quit"); + i = scanner.nextInt(); + if (i == 99) { + break; + } + if (i < 2 || i > 9) { + System.out.println("Invalid input"); + } else { + moveCount++; + reverse(i); + if (isSorted()) { + System.out.println("Congratulations you solved this in " + moveCount + " moves!"); + break; + } + } + + } + scanner.close(); + } + + private void reverse(int position) { + Collections.reverse(gameList.subList(0, position)); + } + + private boolean isSorted() { + for (int i=0; i < gameList.size() - 1; ++i) { + if (gameList.get(i).compareTo(gameList.get(i + 1)) > 0) { + return false; + } + } + return true; + } + + private void initialize() { + this.gameList = new ArrayList(9); + for (int i=1; i < 10; ++i) { + gameList.add(i); + } + while (isSorted()) { + Collections.shuffle(gameList); + } + } + + + public static void main(String[] args) { + try { + ReversalGame game = new ReversalGame(); + game.play(); + } catch (Exception e) { + System.out.println(e.getMessage()); + e.printStackTrace(); + } + } +} diff --git a/Task/Number-reversal-game/JavaScript/number-reversal-game-1.js b/Task/Number-reversal-game/JavaScript/number-reversal-game-1.js new file mode 100644 index 0000000000..768ec56ebf --- /dev/null +++ b/Task/Number-reversal-game/JavaScript/number-reversal-game-1.js @@ -0,0 +1,10 @@ + + + Number Reversal Game + + + +
+
+
+ + + diff --git a/Task/Number-reversal-game/Mathematica/number-reversal-game.math b/Task/Number-reversal-game/Mathematica/number-reversal-game.math new file mode 100644 index 0000000000..4cfe0a5de3 --- /dev/null +++ b/Task/Number-reversal-game/Mathematica/number-reversal-game.math @@ -0,0 +1,6 @@ +Module[{array = Range@9, score = 0}, + While[array == Range@9, array = RandomSample@Range@9]; + While[array != Range@9, + Print@array; (array[[;; #]] = Reverse@array[[;; #]]) &@ + Input["How many digits would you like to reverse?"]; score++]; + Print@array; Print["Your score:", score]] diff --git a/Task/Number-reversal-game/OCaml/number-reversal-game-1.ocaml b/Task/Number-reversal-game/OCaml/number-reversal-game-1.ocaml new file mode 100644 index 0000000000..831067549e --- /dev/null +++ b/Task/Number-reversal-game/OCaml/number-reversal-game-1.ocaml @@ -0,0 +1,48 @@ +let swap ar i j = + let tmp = ar.(i) in + ar.(i) <- ar.(j); + ar.(j) <- tmp + +let shuffle ar = + for i = pred(Array.length ar) downto 1 do + let j = Random.int (i + 1) in + swap ar i j + done + +let reversal ar n = + for i = 0 to pred(n/2) do + let j = (pred n) - i in + swap ar i j + done + +let sorted ar = + try + let prev = ref ar.(0) in + for i = 1 to pred(Array.length ar) do + if ar.(i) < !prev then raise Exit; + prev := ar.(i) + done; + (true) + with Exit -> + (false) + +let () = + print_endline "\ + Number Reversal Game + Sort the numbers in ascending order by repeatedly + flipping sets of numbers from the left."; + Random.self_init(); + let nums = Array.init 9 (fun i -> succ i) in + while sorted nums do shuffle nums done; + let n = ref 1 in + while not(sorted nums) do + Printf.printf "#%2d: " !n; + Array.iter (Printf.printf " %d") nums; + print_newline(); + let r = read_int() in + reversal nums r; + incr n; + done; + print_endline "Congratulations!"; + Printf.printf "You took %d attempts to put the digits in order.\n" !n; +;; diff --git a/Task/Number-reversal-game/OCaml/number-reversal-game-2.ocaml b/Task/Number-reversal-game/OCaml/number-reversal-game-2.ocaml new file mode 100644 index 0000000000..10831d7b59 --- /dev/null +++ b/Task/Number-reversal-game/OCaml/number-reversal-game-2.ocaml @@ -0,0 +1,49 @@ +let revert li n = + let rec aux acc i = function + | [] -> acc + | xs when i <= 0 -> acc @ xs + | x::xs -> aux (x::acc) (pred i) xs + in + aux [] n li + +let take li n = + let rec aux acc i = function + | x::xs when i = n -> (x, List.rev_append acc xs) + | x::xs -> aux (x::acc) (succ i) xs + | _ -> invalid_arg "take" + in + aux [] 0 li + +let shuffle li = + let rec aux acc len = function + | [] -> acc + | li -> + let x, xs = take li (Random.int len) in + aux (x::acc) (pred len) xs + in + aux [] (List.length li) li + +let rec sorted = function + | [] -> (true) + | x::y::_ when x > y -> (false) + | x::xs -> sorted xs + +let () = + print_endline "\ + Number Reversal Game + Sort the numbers in ascending order by repeatedly + flipping sets of numbers from the left."; + Random.self_init(); + let li = shuffle [1; 2; 3; 4; 5; 6; 7; 8; 9] in + let rec loop n li = + Printf.printf "#%2d: " n; + List.iter (Printf.printf " %d") li; + Printf.printf " ? %!"; + let r = read_int() in + let li = revert li r in + if not(sorted li) + then loop (succ n) li + else Printf.printf "You took %d attempts to put the digits in order.\n" n; + in + loop 1 li +;; diff --git a/Task/Number-reversal-game/Oz/number-reversal-game.oz b/Task/Number-reversal-game/Oz/number-reversal-game.oz new file mode 100644 index 0000000000..17aa1cbdbe --- /dev/null +++ b/Task/Number-reversal-game/Oz/number-reversal-game.oz @@ -0,0 +1,59 @@ +declare + proc {Main} + proc {Loop N Xs} + if {Not {IsSorted Xs}} then + Num NewXs + in + {System.printInfo N#": "} + {System.print Xs} + {System.printInfo " -- Reverse how many? "} + Num = {String.toInt {ReadLine}} + NewXs = {Append + {Reverse {List.take Xs Num}} + {List.drop Xs Num}} + {Loop N+1 NewXs} + else + {System.showInfo "You took "#N#" tries to put the digits in order."} + end + end + fun {EnsureShuffled Xs} + Ys = {Shuffle Xs} + in + if {Not {IsSorted Ys}} then Ys + else {EnsureShuffled Xs} + end + end + in + {Loop 0 {EnsureShuffled {List.number 1 9 1}}} + end + + fun {IsSorted Xs} + {Sort Xs Value.'<'} == Xs + end + + local + class TextFile from Open.file Open.text end + StdIn = {New TextFile init(name:stdin)} + in + fun {ReadLine} + {StdIn getS($)} + end + end + + fun {Shuffle Xs} + {FoldL Xs + fun {$ Z _} + {Pick {Diff Xs Z}}|Z + end + nil} + end + + fun {Pick Xs} + {Nth Xs {OS.rand} mod {Length Xs} + 1} + end + + fun {Diff Xs Ys} + {FoldL Ys List.subtract Xs} + end +in + {Main} diff --git a/Task/Number-reversal-game/PARI-GP/number-reversal-game.pari b/Task/Number-reversal-game/PARI-GP/number-reversal-game.pari new file mode 100644 index 0000000000..41818288d1 --- /dev/null +++ b/Task/Number-reversal-game/PARI-GP/number-reversal-game.pari @@ -0,0 +1,14 @@ +game()={ + my(v=numtoperm(9,random(9!-1)),score,in,t); \\ Create vector with 1..9, excluding the one sorted in ascending order + while(v!=vecsort(v), + print(concat(concat([""],v))); + in=input(); + for(i=0,in\2-1, + t=v[9-i]; + v[9-i]=v[10-in+i]; + v[10-in+i]=t + ); + score++ + ); + score +}; diff --git a/Task/Number-reversal-game/PL-I/number-reversal-game.pli b/Task/Number-reversal-game/PL-I/number-reversal-game.pli new file mode 100644 index 0000000000..c8306f148e --- /dev/null +++ b/Task/Number-reversal-game/PL-I/number-reversal-game.pli @@ -0,0 +1,33 @@ +digits: procedure options (main); /* 23 April 2010 */ + declare s character (9) varying; + declare i fixed binary; + declare digit character (1); + +restart: + put skip list ('In this game, you are given a group of digits.'); + put skip list ('You will specify one of those digits.'); + put skip list ('The computer will then reverse the digits up to the one you nominate.'); + put skip list ('Your task is to repeat this process a number of times until all the digits'); + put skip list ('are in order, left to right, 1 to 9.'); + put skip list ('Here are your digits'); + +redo: + s = ''; + do until (length(s) = 9); + digit = trim ( fixed(trunc (1+random()*9) ) ); + if index(s, digit) = 0 then s = s || digit; + end; + if s = '123456789' then go to redo; + +loop: + do forever; + put skip list (s); + if s = '123456789' then leave; + get edit (digit) (a(1)); + i = index(s, digit); + if i = 0 then do; put skip list ('invalid request'); iterate loop; end; + s = reverse( substr(s, 1, i) ) || substr(s, i+1, length(s)-i); + end; + put skip list ('Congratulations'); + go to restart; +end digits; diff --git a/Task/Number-reversal-game/Perl-6/number-reversal-game.pl6 b/Task/Number-reversal-game/Perl-6/number-reversal-game.pl6 new file mode 100644 index 0000000000..31f39dfe64 --- /dev/null +++ b/Task/Number-reversal-game/Perl-6/number-reversal-game.pl6 @@ -0,0 +1,15 @@ +repeat while [<] my @jumbled-list { + @jumbled-list = (1..9).pick(*) +} + +my $turn = 0; +repeat until [<] @jumbled-list { + my $d = prompt $turn.=succ.fmt('%2d: ') ~ + @jumbled-list ~ + " - Flip how many digits? " + or exit; + @jumbled-list[^$d] .= reverse; +} + +say " @jumbled-list[]"; +say "You won in $turn turns."; diff --git a/Task/Number-reversal-game/Perl/number-reversal-game.pl b/Task/Number-reversal-game/Perl/number-reversal-game.pl new file mode 100644 index 0000000000..d6dadd6789 --- /dev/null +++ b/Task/Number-reversal-game/Perl/number-reversal-game.pl @@ -0,0 +1,20 @@ +use List::Util qw(shuffle); + +my $turn = 0; +my @jumble = shuffle 1..9; + +while ( join('', @jumble) eq '123456789' ) { + @jumble = shuffle 1..9; +} + +until ( join('', @jumble) eq '123456789' ) { + $turn++; + printf "%2d: @jumble - Flip how many digits ? ", $turn; + + my $d = <>; + + @jumble[0..$d-1] = reverse @jumble[0..$d-1]; +} + +print " @jumble\n"; +print "You won in $turn turns.\n"; diff --git a/Task/Number-reversal-game/PicoLisp/number-reversal-game.l b/Task/Number-reversal-game/PicoLisp/number-reversal-game.l new file mode 100644 index 0000000000..e73f2b7e31 --- /dev/null +++ b/Task/Number-reversal-game/PicoLisp/number-reversal-game.l @@ -0,0 +1,12 @@ +(load "@lib/simul.l") + +(de reversalGame () + (let (Lst (shuffle (range 1 9)) Cnt 0) + (while (apply < Lst) + (setq Lst (shuffle Lst)) ) + (loop + (printsp Lst) + (T (apply < Lst) Cnt) + (NIL (num? (read))) + (setq Lst (flip Lst @)) + (inc 'Cnt) ) ) ) diff --git a/Task/Number-reversal-game/PureBasic/number-reversal-game.purebasic b/Task/Number-reversal-game/PureBasic/number-reversal-game.purebasic new file mode 100644 index 0000000000..fd647de010 --- /dev/null +++ b/Task/Number-reversal-game/PureBasic/number-reversal-game.purebasic @@ -0,0 +1,47 @@ +Dim MyList(9) + +Declare is_list_sorted() + +If OpenConsole() + Define score, indata, i, txt$ + + For i=1 To 9 ;- Initiate the list + MyList(i)=i + Next + While is_list_sorted() + For i=1 To 9 ;- Do a Fisher–Yates shuffle + Swap MyList(i), MyList(Random(i)+1) + Next + Wend + + ;- Start the Game + Repeat + score+1 + txt$=RSet(str(score), 3)+": " ;- Show current list + For i=1 To 9 + txt$+str(MyList(i))+" " + Next + Repeat ;- Get input & swap + Print(txt$+"| How many numbers should be flipped? "): indata=Val(Input()) + Until indata>=1 And indata<=9 ;- Verify the input + For i=1 To (indata/2) + Swap MyList(i),MyList(indata-i+1) + Next + Until is_list_sorted() + + ;- Present result & wait for users input before closing down + PrintN(#CRLF$+"You did it in "+str(score)+" moves") + Print("Press ENTER to exit"): Input() + CloseConsole() +EndIf + +Procedure is_list_sorted() + Protected i + Shared MyList() + For i=1 To 9 + If MyList(i)<>i + ProcedureReturn #False + EndIf + Next + ProcedureReturn #True +EndProcedure diff --git a/Task/Number-reversal-game/Python/number-reversal-game.py b/Task/Number-reversal-game/Python/number-reversal-game.py new file mode 100644 index 0000000000..b313d59161 --- /dev/null +++ b/Task/Number-reversal-game/Python/number-reversal-game.py @@ -0,0 +1,22 @@ +''' +number reversal game + Given a jumbled list of the numbers 1 to 9 + Show the list. + Ask the player how many digits from the left to reverse. + Reverse those digits then ask again. + until all the digits end up in ascending order. + +''' + +import random + +print(__doc__) +data, trials = list('123456789'), 0 +while data == sorted(data): + random.shuffle(data) +while data != sorted(data): + trials += 1 + flip = int(input('#%2i: LIST: %r Flip how many?: ' % (trials, ' '.join(data)))) + data[:flip] = reversed(data[:flip]) + +print('\nYou took %2i attempts to put the digits in order!' % trials) diff --git a/Task/Number-reversal-game/R/number-reversal-game-1.r b/Task/Number-reversal-game/R/number-reversal-game-1.r new file mode 100644 index 0000000000..6b463b4397 --- /dev/null +++ b/Task/Number-reversal-game/R/number-reversal-game-1.r @@ -0,0 +1,24 @@ +reversalGame <- function(){ + cat("Welcome to the Number Reversal Game! \n") + cat("Sort the numbers into ascending order by repeatedly \n", + "reversing the first n digits, where you specify n. \n \n", sep="") + + # Generate a list that's definitely not in ascending order, per instuctions + data <- sample(1:9, 9) + while (all(data == 1:9)){ + cat("What were the chances...? \n") + data <- sample(1:9, 9) + } + trials <- 0 + + # Play the game + while (any(data != 1:9)){ + trials <- trials + 1 + cat("Trial", sprintf("%02d", trials), " # ", data, " # ") + answer <- readline(paste("Flip how many? ")) + data[1:answer] <- data[answer:1] + } + + # Victory! + cat("Well done. You needed", trials, "flips. \n") +} diff --git a/Task/Number-reversal-game/R/number-reversal-game-2.r b/Task/Number-reversal-game/R/number-reversal-game-2.r new file mode 100644 index 0000000000..17b9ca66f4 --- /dev/null +++ b/Task/Number-reversal-game/R/number-reversal-game-2.r @@ -0,0 +1,10 @@ +>reversalGame() +Welcome to the Number Reversal Game! +Sort the numbers into ascending order by repeatedly +reversing the first n digits, where you specify n. + +Trial 01 # 4 3 2 1 7 9 8 5 6 # Flip how many? 7 +Trial 02 # 8 9 7 1 2 3 4 5 6 # Flip how many? 2 +Trial 03 # 9 8 7 1 2 3 4 5 6 # Flip how many? 9 +Trial 04 # 6 5 4 3 2 1 7 8 9 # Flip how many? 6 +Well done. You needed 4 flips. diff --git a/Task/Number-reversal-game/REXX/number-reversal-game.rexx b/Task/Number-reversal-game/REXX/number-reversal-game.rexx new file mode 100644 index 0000000000..d215c6cc66 --- /dev/null +++ b/Task/Number-reversal-game/REXX/number-reversal-game.rexx @@ -0,0 +1,22 @@ +/*REXX program game: reverse a jumbled set of numerals until in order.*/ + +say "This game will show you nine random unique digits (1 ──► 9 inclusive), and" +say "you'll enter one of those digits which will reverse the digits up to (and" +say "including) that digit. The game's objective is to get all the digits in" +say "ascending order with the fewest tries. Here're your digits:"; say +$='' + do until length($)==9 /*generate random numeric string.*/ + _=random(1,9); if pos(_,$)\==0 then iterate /*no repeats.*/ + $=$ || _ + end /*until*/ + + do score=1 until $==123456789 /*keep truckin' until all ordered*/ + say $ left('',30) 'please enter a digit:' /*issue a prompt to user.*/ + parse pull ? 2 . /*get one digit from the gamer. */ + g=pos(?,$) /*full validation of input digit.*/ + if g==0 then say 'oops, invalid digit!' ? + else $=reverse(left($,g))substr($,g+1) + end /*score*/ + +say center(' Congratulations! ',79,"═"); say 'Your score was' score + /*stick a fork in it, we're done.*/ diff --git a/Task/Number-reversal-game/Rascal/number-reversal-game.rascal b/Task/Number-reversal-game/Rascal/number-reversal-game.rascal new file mode 100644 index 0000000000..d4427f156e --- /dev/null +++ b/Task/Number-reversal-game/Rascal/number-reversal-game.rascal @@ -0,0 +1,37 @@ +import Prelude; +import vis::Figure; +import vis::Render; + +public void NumberReversalGame(){ + + //generate randomlist + L = [1..9]; + score = 0; + randomlist = []; + while (L != []){ + temp = takeOneFrom(L); + randomlist += temp[0]; + L = temp[1]; + } + + // user interaction + score = 0; + text1 = ""; + figure = + box(vcat([ + box(text(str(){ + return "";})), + box(textfield("Insert number of digits you would like to reverse here.", + void(str s){ + score += 1; + n = toInt(s); + spliced = slice(randomlist, 0, n); + randomlist = reverse(spliced) + (randomlist - spliced); + }, + fillColor("lightblue"))), + box(text(str(){ + return ((randomlist == [1 .. 9]) ? "Well done! Your score: ." : "Keep going!");})) + ])); + + render(figure); +} diff --git a/Task/Number-reversal-game/Ruby/number-reversal-game.rb b/Task/Number-reversal-game/Ruby/number-reversal-game.rb new file mode 100644 index 0000000000..b7e3771d8b --- /dev/null +++ b/Task/Number-reversal-game/Ruby/number-reversal-game.rb @@ -0,0 +1,11 @@ +ary = (1..9).to_a +ary.shuffle! while ary == ary.sort +score = 0 +until ary == ary.sort + print "#{ary.inspect} -- How many digits to reverse? " + num = gets.to_i # should validate input + ary[0, num] = ary[0, num].reverse + score += 1 +end +p ary +puts "Your score: #{score}" diff --git a/Task/Number-reversal-game/Run-BASIC/number-reversal-game.run b/Task/Number-reversal-game/Run-BASIC/number-reversal-game.run new file mode 100644 index 0000000000..43e8bea20a --- /dev/null +++ b/Task/Number-reversal-game/Run-BASIC/number-reversal-game.run @@ -0,0 +1,40 @@ +for i = 1 to 9 ' get numbers 1 to 9 + n(i) = i +next i +numShuffles = 3 +' ---------------------------------- +' shuffle numbers +' ---------------------------------- +for i = 1 to 9 * numShuffles + i1 = int(rnd(1)*9) + 1 + i2 = int(rnd(1)*9) + 1 + h2 = n(i1) + n(i1) = n(i2) + n(i2) = h2 +next i + +for i = 1 to 9 + a$ = a$ + str$(n(i)) + " " +next i +count = 0 + +[loop] + count = count + 1 + print count;" : ";a$ + for i = 1 to 9 ' check if in sequence + j = i * 2 + if mid$(a$,j-1,1) > mid$(a$,j,1) then goto [notOrdered] + next i + print "It took ";count;" tries" +end + +[notOrdered] +input "How many numbers to flip:";i +i = ((i-1) * 2) + 1 +b$ = "" +for j = i to 1 step -2 + b$ = b$ + mid$(a$,j,2) +next j +a$ = b$ + mid$(a$,i + 2) +goto [loop] +end diff --git a/Task/Number-reversal-game/TUSCRIPT/number-reversal-game.tuscript b/Task/Number-reversal-game/TUSCRIPT/number-reversal-game.tuscript new file mode 100644 index 0000000000..b487ae752a --- /dev/null +++ b/Task/Number-reversal-game/TUSCRIPT/number-reversal-game.tuscript @@ -0,0 +1,37 @@ +$$ MODE TUSCRIPT +numbers=RANDOM_NUMBERS (1,9,9),nr=0 + +SECTION check +LOOP o,n=numbers + IF (n!=o) THEN + DO PRINT + EXIT + ELSEIF (n==9&&o==9) THEN + DO PRINT + PRINT " You made it ... in round ",r + STOP + ELSE + CYCLE + ENDIF +ENDLOOP +ENDSECTION + +SECTION print + PRINT numbers +ENDSECTION + + +DO PRINT +LOOP r=1,14 +IF (nr>=0&&nr<10) THEN + ASK "Reverse - how many?": nr="" + i="" + LOOP n=1,nr + i=APPEND(i,n) + ENDLOOP + numbers =SPLIT (numbers) + reverse_nr=SELECT (numbers,#i,keep_nr), reverse_nr=REVERSE(reverse_nr) + numbers =APPEND (reverse_nr,keep_nr), numbers =JOIN (numbers) + DO check +ENDIF +ENDLOOP diff --git a/Task/Number-reversal-game/Tcl/number-reversal-game.tcl b/Task/Number-reversal-game/Tcl/number-reversal-game.tcl new file mode 100644 index 0000000000..a5316bbaf7 --- /dev/null +++ b/Task/Number-reversal-game/Tcl/number-reversal-game.tcl @@ -0,0 +1,43 @@ +package require Tcl 8.5 +# Simple shuffler, not very efficient but good enough for here +proc shuffle list { + set result {} + while {[llength $list]} { + set i [expr {int([llength $list] * rand())}] + lappend result [lindex $list $i] + set list [lreplace $list $i $i] + } + return $result +} +# Returns the list with the prefix of it reversed +proc flipfirst {list n} { + concat [lreverse [lrange $list 0 $n-1]] [lrange $list $n end] +} + +# Core game engine; list to play with is optional argument +proc nrgame {{target "1 2 3 4 5 6 7 8 9"}} { + set nums $target + while {$nums eq $target} {set nums [shuffle $nums]} + set goes 0 + while {$nums ne $target} { + incr goes + puts -nonewline "#${goes}: List is '[join $nums {, }]', how many to reverse? " + flush stdout + gets stdin n + if {$n eq "q"} {return quit} + # Input validation would go here + set nums [flipfirst $nums $n] + } + return $goes +} + +# Print some instructions and wait for the user to win +puts "Welcome to the Number Reversal Game!" +puts "------------------------------------" +puts "I'll show you a list of numbers, you need to reverse prefixes of them" +puts "to get the whole list in ascending order. A 'q' will quit early.\n" +puts "" +set outcome [nrgame] +if {$outcome ne "quit"} { + puts "\nYou took $outcome attempts to put the digits in order." +} diff --git a/Task/Number-reversal-game/UNIX-Shell/number-reversal-game.sh b/Task/Number-reversal-game/UNIX-Shell/number-reversal-game.sh new file mode 100644 index 0000000000..c602af5713 --- /dev/null +++ b/Task/Number-reversal-game/UNIX-Shell/number-reversal-game.sh @@ -0,0 +1,100 @@ +print "\nWelcome to the number reversal game!\n" + +print "You must put the numbers in order from 1 to 9." +print "Your only moves are to reverse groups of numbers" +print "on the left side of the list." + +integer list score + +# start a new game +function newgame { + integer i j t + + # score = number of moves + ((score = 0)) + + # list = array of numbers + set -A list 1 2 3 4 5 6 7 8 9 + while true; do + # Knuth shuffle + ((i = 9)) + while ((i > 1)); do + # get random j from 0 to i - 1 + ((j = RANDOM)) + ((j < 32768 % i)) && continue + ((j %= i)) + + # decrement i, swap list[i] with list[j] + ((i -= 1)) + ((t = list[i])) + ((list[i] = list[j])) + ((list[j] = t)) + done + win || break + done +} + +# numbers in order? +function win { + integer i + + # check if list[0] == 1, list[1] == 2, ... + ((i = 0)) + while ((i < 9)); do + ((list[i] != i + 1)) && return 1 + ((i += 1)) + done + return 0 +} + +# reverse first $1 elements of list +function reverse { + integer left right t + + ((left = 0)) + ((right = $1 - 1)) + while ((right > left)); do + ((t = list[left])) + ((list[left] = list[right])) + ((list[right] = t)) + ((left += 1)) + ((right -= 1)) + done +} + + +integer i + +newgame +while true; do + print -n "\nYour list: " + ((i = 0)) + while ((i < 8)); do + printf "%d, " ${list[i]} + ((i += 1)) + done + printf "%d\n" ${list[8]} + + if win; then + print "YOU WIN!" + printf "Your score is %d moves.\n" $score + print -n "Would you like to play again (y/n)? " + + if read again && [[ $again = @(y|Y)* ]]; then + newgame + else + print "\n\nBye!" + exit + fi + else + print -n "How many numbers to reverse? " + + if read i; then + ((score += 1)) + reverse $i + else + print "\n\nBye!" + exit + fi + fi +done diff --git a/Task/Number-reversal-game/XPL0/number-reversal-game.xpl0 b/Task/Number-reversal-game/XPL0/number-reversal-game.xpl0 new file mode 100644 index 0000000000..6b269865aa --- /dev/null +++ b/Task/Number-reversal-game/XPL0/number-reversal-game.xpl0 @@ -0,0 +1,24 @@ +int Taken, I, Digit, Num, Score, Rev, Temp; +char List(9); +include c:\cxpl\codes; + \make jumbled list of digits 1 to 9 +[loop [Taken:= 0; \bit array indicates which digits are taken + for I:= 0 to 9-1 do + [repeat Digit:= Ran(9)+1 until (Taken & 1< List(I+1) then quit; +]; \quit loop when digits are not in ascending order +Score:= 0; +loop [for I:= 0 to 9-1 do [IntOut(0, List(I)); ChOut(0, ^ )]; + Num:= 0; for I:= 0 to 9-1 do Num:= Num*10 + List(I); + if Num = 123456789 then quit; + Text(0, "^M^JReverse how many digits? "); Rev:= IntIn(0); + for I:= 0 to Rev/2-1 do + [Temp:= List(I); List(I):= List(Rev-1-I); List(Rev-1-I):= Temp]; + Score:= Score+1; + ]; +Text(0, "^M^JCongrats! You did it in "); IntOut(0, Score); +Text(0, " moves!!^M^J"); +] diff --git a/Task/Numeric-error-propagation/0DESCRIPTION b/Task/Numeric-error-propagation/0DESCRIPTION new file mode 100644 index 0000000000..adffba66cc --- /dev/null +++ b/Task/Numeric-error-propagation/0DESCRIPTION @@ -0,0 +1,27 @@ +If f, a, and b are values with uncertainties σf, σa, and σb. and c is a constant; then if f is derived from a, b, and c in the following ways, then σf can be calculated as follows: + +:;Addition/Subtraction +:* If f = a ± c, or f = c ± a then '''σf = σa''' +:* If f = a ± b then '''σf2 = σa2 + σb2''' + +:;Multiplication/Division +:* If f = ca or f = ac then '''σf = |cσa|''' +:* If f = ab or f = a / b then '''σf2 = f2( (σa / a)2 + (σb / b)2)''' + +:;Exponentiation +:* If f = ac then '''σf = |fc(σa / a)|''' + +:Caution: +::This implementation of error propagation does not address issues of dependent and independent values. It is assumed that a and b are independent and so the formula for multiplication should not be applied to a*a for exam[ple. See [[Talk:Numeric_error_propagation|the talk page]] for some of the implications of this issue. + +;Task details: +# Add an uncertain number type to your language that can support addition, subtraction, multiplication, division, and exponentiation between numbers with an associated error term together with 'normal' floating point numbers without an associated error term.
Implement enough functionality to perform the following calculations. +# Given coordinates and their errors:
x1 = 100 ± 1.1
y1 = 50 ± 1.2
x2 = 200 ± 2.2
y2 = 100 ± 2.3
if point p1 is located at (x1, y1) and p2 is at (x2, y2); calculate the distance between the two points using the classic pythagorean formula:
'''d = √((x1 - x2)2 + (y1 - y2)2)''' +# Print and display both '''d''' and its error. + +;References: +* [http://casa.colorado.edu/~benderan/teaching/astr3510/stats.pdf A Guide to Error Propagation] B. Keeney, 2005. +* [[wp:Propagation of uncertainty|Propagation of uncertainty]] Wikipedia. + +;Cf.: +* [[Quaternion type]] diff --git a/Task/Numeric-error-propagation/Ada/numeric-error-propagation-1.ada b/Task/Numeric-error-propagation/Ada/numeric-error-propagation-1.ada new file mode 100644 index 0000000000..ac04a050c3 --- /dev/null +++ b/Task/Numeric-error-propagation/Ada/numeric-error-propagation-1.ada @@ -0,0 +1,48 @@ +generic + type Real is digits <>; + with function Sqrt(X: Real) return Real; + with function "**"(X: Real; Y: Real) return Real; +package Approximation is + + type Number is private; + + -- create an approximation + function Approx(Value: Real; Sigma: Real) return Number; + + -- unary operations and conversion Real to Number + function "+"(X: Real) return Number; + function "-"(X: Real) return Number; + function "+"(X: Number) return Number; + function "-"(X: Number) return Number; + + -- addition / subtraction + function "+"(X: Number; Y: Number) return Number; + function "-"(X: Number; Y: Number) return Number; + + -- multiplication / division + function "*"(X: Number; Y: Number) return Number; + function "/"(X: Number; Y: Number) return Number; + + -- exponentiation + function "**"(X: Number; Y: Positive) return Number; + function "**"(X: Number; Y: Real) return Number; + + -- Output to Standard IO (wrapper for Ada.Text_IO and Ada.Text_IO.Float_IO) + procedure Put_Line(Message: String; + Item: Number; + Value_Fore: Natural := 7; + Sigma_Fore: Natural := 4; + Aft: Natural := 2; + Exp: Natural := 0); + procedure Put(Item: Number; + Value_Fore: Natural := 7; + Sigma_Fore: Natural := 3; + Aft: Natural := 2; + Exp: Natural := 0); + +private + type Number is record + Value: Real; + Sigma: Real; + end record; +end Approximation; diff --git a/Task/Numeric-error-propagation/Ada/numeric-error-propagation-2.ada b/Task/Numeric-error-propagation/Ada/numeric-error-propagation-2.ada new file mode 100644 index 0000000000..3b6bf209fc --- /dev/null +++ b/Task/Numeric-error-propagation/Ada/numeric-error-propagation-2.ada @@ -0,0 +1,119 @@ +with Ada.Text_IO; + +package body Approximation is + + package RIO is new Ada.Text_IO.Float_IO(Real); + + -- create an approximation + + function Approx(Value: Real; Sigma: Real) return Number is + begin + return (Value, Sigma); + end Approx; + + -- unary operations and conversion Real to Number + + function "+"(X: Real) return Number is + begin + return Approx(X, 0.0); + end "+"; + + function "-"(X: Real) return Number is + begin + return Approx(-X, 0.0); + end "-"; + + function "+"(X: Number) return Number is + begin + return X; + end "+"; + + function "-"(X: Number) return Number is + begin + return Approx(-X.Value, X.Sigma); + end "-"; + + -- addition / subtraction + + function "+"(X: Number; Y: Number) return Number is + Z: Number; + begin + Z.Value := X.Value + Y.Value; + Z.Sigma := Sqrt(X.Sigma*X.Sigma + Y.Sigma*Y.Sigma); + return Z; + end "+"; + + function "-"(X: Number; Y: Number) return Number is + begin + return X + (-Y); + end "-"; + + -- multiplication / division + + function "*"(X: Number; Y: Number) return Number is + Z: Number; + begin + Z.Value := X.Value * Y.Value; + Z.Sigma := Z.Value * Sqrt((X.Sigma/X.Value)**2 + (Y.Sigma/Y.Value)**2); + return Z; + end "*"; + + function "/"(X: Number; Y: Number) return Number is + Z: Number; + begin + Z.Value := X.Value / Y.Value; + Z.Sigma := Z.Value * Sqrt((X.Sigma/X.Value)**2 + (Y.Sigma/Y.Value)**2); + return Z; + end "/"; + + -- exponentiation + + function "**"(X: Number; Y: Positive) return Number is + Z: Number; + begin + Z.Value := X.Value ** Y ; + Z.Sigma := Z.Value * Real(Y) * (X.Sigma/X.Value); + if Z.Sigma < 0.0 then + Z.Sigma := - Z.Sigma; + end if; + return Z; + end "**"; + + function "**"(X: Number; Y: Real) return Number is + Z: Number; + begin + Z.Value := X.Value ** Y ; + Z.Sigma := Z.Value * Y * (X.Sigma/X.Value); + if Z.Sigma < 0.0 then + Z.Sigma := - Z.Sigma; + end if; + return Z; + end "**"; + + -- Output to Standard IO (wrapper for Ada.Text_IO.Float_IO) + + procedure Put_Line(Message: String; + Item: Number; + Value_Fore: Natural := 7; + Sigma_Fore: Natural := 4; + Aft: Natural := 2; + Exp: Natural := 0) is + begin + Ada.Text_IO.Put(Message); + Put(Item, Value_Fore, Sigma_Fore, Aft, Exp); + Ada.Text_IO.New_Line; + end Put_Line; + + procedure Put(Item: Number; + Value_Fore: Natural := 7; + Sigma_Fore: Natural := 3; + Aft: Natural := 2; + Exp: Natural := 0) is + begin + RIO.Put(Item.Value, Value_Fore, Aft, Exp); + Ada.Text_IO.Put(" (+-"); + RIO.Put(Item.Sigma, Sigma_Fore, Aft, Exp); + Ada.Text_IO.Put(")"); + end Put; + +end Approximation; diff --git a/Task/Numeric-error-propagation/Ada/numeric-error-propagation-3.ada b/Task/Numeric-error-propagation/Ada/numeric-error-propagation-3.ada new file mode 100644 index 0000000000..1ef6103adc --- /dev/null +++ b/Task/Numeric-error-propagation/Ada/numeric-error-propagation-3.ada @@ -0,0 +1,17 @@ +with Approximation, Ada.Numerics.Elementary_Functions; + +procedure Test_Approximations is + package A is new Approximation(Float, + Ada.Numerics.Elementary_Functions.Sqrt, + Ada.Numerics.Elementary_Functions."**"); + use type A.Number; + X1: A.Number := A.Approx(100.0, 1.1); + Y1: A.Number := A.Approx( 50.0, 1.2); + X2: A.Number := A.Approx(200.0, 2.2); + Y2: A.Number := A.Approx(100.0, 2.3); + +begin + A.Put_Line("Distance:", + ((X1-X2)**2 + (Y1 - Y2)**2)**0.5, + Sigma_Fore => 1); +end Test_Approximations; diff --git a/Task/Numeric-error-propagation/C/numeric-error-propagation.c b/Task/Numeric-error-propagation/C/numeric-error-propagation.c new file mode 100644 index 0000000000..2a3eb896e0 --- /dev/null +++ b/Task/Numeric-error-propagation/C/numeric-error-propagation.c @@ -0,0 +1,52 @@ +#include +#include + +struct imprecise { + double value; + double delta; +}; + +#define SQR(x) ((x) * (x)) +struct imprecise imprecise_add(struct imprecise a, struct imprecise b) +{ + struct imprecise ret; + ret.value = a.value + b.value; + ret.delta = sqrt(SQR(a.delta) + SQR(b.delta)); + return ret; +} + +struct imprecise imprecise_mul(struct imprecise a, struct imprecise b) +{ + struct imprecise ret; + ret.value = a.value * b.value; + ret.delta = sqrt(SQR(a.value * b.delta) + SQR(b.value * a.delta)); + return ret; +} + +struct imprecise imprecise_div(struct imprecise a, struct imprecise b) +{ + struct imprecise ret; + ret.value = a.value / b.value; + ret.delta = sqrt(SQR(a.value * b.delta) + SQR(b.value * a.delta)) / SQR(b.value); + return ret; +} + +struct imprecise imprecise_pow(struct imprecise a, double c) +{ + struct imprecise ret; + ret.value = pow(a.value, c); + ret.delta = fabs(ret.value * c * a.delta / a.value); + return ret; +} + +int main(void) { + struct imprecise x1 = {100, 1.1}; + struct imprecise y1 = {50, 1.2}; + struct imprecise x2 = {-200, 2.2}; + struct imprecise y2 = {-100, 2.3}; + struct imprecise d; + + d = imprecise_pow(imprecise_add(imprecise_pow(imprecise_add(x1, x2), 2),imprecise_pow(imprecise_add(y1, y2), 2)), 0.5); + printf("d = %f \\pm %f\n", d.value, d.delta); + return 0; +} diff --git a/Task/Numeric-error-propagation/D/numeric-error-propagation.d b/Task/Numeric-error-propagation/D/numeric-error-propagation.d new file mode 100644 index 0000000000..3d2b60ef88 --- /dev/null +++ b/Task/Numeric-error-propagation/D/numeric-error-propagation.d @@ -0,0 +1,103 @@ +import std.stdio, std.math, std.string, std.typecons, std.traits; + +const struct Imprecise { + private const double value, delta; + + this(in double v, in double d) pure nothrow { + this.value = v; + this.delta = abs(d); + } + + template IsImprecise(T) { + enum IsImprecise = is(Unqual!T == Unqual!(typeof(this))); + } + + I reciprocal() const pure nothrow { + return I(1.0 / value, delta / (value ^^ 2)); + } + + string toString() const { + return format("I(value=%g, delta=%g)", value, delta); + } + + I opUnary(string op:"-")() const pure nothrow { + return I(-this.value, this.delta); + } + + I opBinary(string op:"+", T)(in T other) const pure nothrow + if (isNumeric!T || IsImprecise!T) { + static if (IsImprecise!T) + return I(this.value + other.value, + (this.delta ^^ 2 + other.delta ^^ 2) ^^ 0.5); + else + return I(this.value + other, this.delta); + } + + I opBinaryRight(string op:"+", T)(in T other) const pure nothrow + if (isNumeric!T) { + return I(this.value + other, this.delta); + } + + I opBinary(string op:"-", T)(in T other) const pure nothrow + if (isNumeric!T || IsImprecise!T) { + return this + (-other); + } + + I opBinaryRight(string op:"-", T)(in T other) const pure nothrow + if (isNumeric!T) { + return this - other; + } + + I opBinary(string op:"*", T)(in T other) const pure nothrow + if (isNumeric!T || IsImprecise!T) { + static if (IsImprecise!T) { + auto f = this.value * other.value; + return I(f, f * ((delta / value) ^^ 2 + + (other.delta / other.value) ^^ 2) ^^ 0.5); + } else + return I(this.value * other, this.delta * other); + } + + I opBinaryRight(string op:"*", T)(in T other) const pure nothrow + if (isNumeric!T) { + return this * other; + } + + I opBinary(string op:"/", T)(in T other) const pure nothrow + if (isNumeric!T || IsImprecise!T) { + static if (IsImprecise!T) + return this * other.reciprocal(); + else + return I(this.value / other, this.delta / other); + } + + I opBinaryRight(string op:"/", T)(in T other) const pure nothrow + if (isNumeric!T) { + return this / other; + } + + I opBinary(string op:"^^", T)(in T other) const pure nothrow + if (isNumeric!T) { + auto f = this.value ^^ other; + return I(f, f * other * (this.delta / this.value)); + } +} + +alias Imprecise I; + +auto distance(T1, T2)(in T1 p1, in T2 p2) pure nothrow { + return ((p1[0] - p2[0]) ^^ 2 + (p1[1] - p2[1]) ^^ 2) ^^ 0.5; +} + +void main() { + immutable x1 = I(100, 1.1); + immutable x2 = I(200, 2.2); + immutable y1 = I( 50, 1.2); + immutable y2 = I(100, 2.3); + + immutable p1 = tuple(x1, y1); + immutable p2 = tuple(x2, y2); + writefln("Point p1: (%s, %s)", p1[0], p1[1]); + writefln("Point p2: (%s, %s)", p2[0], p2[1]); + writeln("Distance(p1, p2): ", distance(p1, p2)); +} diff --git a/Task/Numeric-error-propagation/Go/numeric-error-propagation.go b/Task/Numeric-error-propagation/Go/numeric-error-propagation.go new file mode 100644 index 0000000000..60d0b22fd9 --- /dev/null +++ b/Task/Numeric-error-propagation/Go/numeric-error-propagation.go @@ -0,0 +1,101 @@ +package main + +import ( + "fmt" + "math" +) + +// "uncertain number type" +// a little optimization is to represent the error term with its square. +// this saves some taking of square roots in various places. +type unc struct { + n float64 // the number + s float64 // *square* of one sigma error term +} + +// constructor, nice to have so it can handle squaring of error term +func newUnc(n, s float64) *unc { + return &unc{n, s * s} +} + +// error term accessor method, nice to have so it can handle recovering +// (non-squared) error term from internal (squared) representation +func (z *unc) errorTerm() float64 { + return math.Sqrt(z.s) +} + +// Arithmetic methods are modeled on the Go big number package. +// The basic scheme is to pass all operands as method arguments, compute +// the result into the method receiver, and then return the receiver as +// the result of the method. This has an advantage of letting the programer +// determine allocation and use of temporary objects, reducing garbage; +// and has the convenience and efficiency of allowing operations to be chained. + +// addition/subtraction +func (z *unc) addC(a *unc, c float64) *unc { + *z = *a + z.n += c + return z +} + +func (z *unc) subC(a *unc, c float64) *unc { + *z = *a + z.n -= c + return z +} + +func (z *unc) addU(a, b *unc) *unc { + z.n = a.n + b.n + z.s = a.s + b.s + return z +} +func (z *unc) subU(a, b *unc) *unc { + z.n = a.n - b.n + z.s = a.s + b.s + return z +} + +// multiplication/division +func (z *unc) mulC(a *unc, c float64) *unc { + z.n = a.n * c + z.s = a.s * c * c + return z +} + +func (z *unc) divC(a *unc, c float64) *unc { + z.n = a.n / c + z.s = a.s / (c * c) + return z +} + +func (z *unc) mulU(a, b *unc) *unc { + prod := a.n * b.n + z.n, z.s = prod, prod*prod*(a.s/(a.n*a.n)+b.s/(b.n*b.n)) + return z +} + +func (z *unc) divU(a, b *unc) *unc { + quot := a.n / b.n + z.n, z.s = quot, quot*quot*(a.s/(a.n*a.n)+b.s/(b.n*b.n)) + return z +} + +// exponentiation +func (z *unc) expC(a *unc, c float64) *unc { + f := math.Pow(a.n, c) + g := f * c / a.n + z.n = f + z.s = a.s * g * g + return z +} + +func main() { + x1 := newUnc(100, 1.1) + x2 := newUnc(200, 2.2) + y1 := newUnc(50, 1.2) + y2 := newUnc(100, 2.3) + var d, d2 unc + d.expC(d.addU(d.expC(d.subU(x1, x2), 2), d2.expC(d2.subU(y1, y2), 2)), .5) + fmt.Println("d: ", d.n) + fmt.Println("error:", d.errorTerm()) +} diff --git a/Task/Numeric-error-propagation/Haskell/numeric-error-propagation.hs b/Task/Numeric-error-propagation/Haskell/numeric-error-propagation.hs new file mode 100644 index 0000000000..af4ce5dd14 --- /dev/null +++ b/Task/Numeric-error-propagation/Haskell/numeric-error-propagation.hs @@ -0,0 +1,20 @@ +data Error a = Error {value :: a, uncertainty :: a} deriving (Eq, Show) + +instance (Floating a) => Num (Error a) where + Error a ua + Error b ub = Error (a + b) (sqrt (ua ^ 2 + ub ^ 2)) + negate (Error a ua) = Error (negate a) ua + Error a ua * Error b ub = Error (a * b) (abs (a * b * sqrt ((ua / a) ^ 2 + (ub / b) ^ 2))) -- I've factored out the f^2 from the square root + fromInteger a = Error (fromInteger a) 0 + +instance (Floating a) => Fractional (Error a) where + fromRational a = Error (fromRational a) 0 + Error a ua / Error b ub = Error (a / b) (abs (a / b * sqrt ((ua / a) ^ 2 + (ub / b) ^ 2))) -- I've factored out the f^2 from the square root + +instance (Floating a) => Floating (Error a) where + Error a ua ** Error c 0 = Error (a ** c) (abs (ua * c * a**c / a)) + +main = print (sqrt ((x1 - x2) ** 2 + (y1 - y2) ** 2)) where -- using (^) for exponentiation would calculate a*a, which the problem specifically said was calculated wrong + x1 = Error 100 1.1 + y1 = Error 50 1.2 + x2 = Error 200 2.2 + y2 = Error 100 2.3 diff --git a/Task/Numeric-error-propagation/J/numeric-error-propagation-1.j b/Task/Numeric-error-propagation/J/numeric-error-propagation-1.j new file mode 100644 index 0000000000..deccfd31f3 --- /dev/null +++ b/Task/Numeric-error-propagation/J/numeric-error-propagation-1.j @@ -0,0 +1,3 @@ +num=: {."1 +unc=: {:@}."1 : ,. +dist=: +/&.:*: diff --git a/Task/Numeric-error-propagation/J/numeric-error-propagation-2.j b/Task/Numeric-error-propagation/J/numeric-error-propagation-2.j new file mode 100644 index 0000000000..369e23f098 --- /dev/null +++ b/Task/Numeric-error-propagation/J/numeric-error-propagation-2.j @@ -0,0 +1,5 @@ +x1=: 100 unc 1.1 +y1=: 50 unc 1.2 + +x2=: 200 unc 2.2 +y2=: 100 unc 2.3 diff --git a/Task/Numeric-error-propagation/J/numeric-error-propagation-3.j b/Task/Numeric-error-propagation/J/numeric-error-propagation-3.j new file mode 100644 index 0000000000..6d36b1bc77 --- /dev/null +++ b/Task/Numeric-error-propagation/J/numeric-error-propagation-3.j @@ -0,0 +1,4 @@ + num x1 +100 + unc x1 +1.1 diff --git a/Task/Numeric-error-propagation/J/numeric-error-propagation-4.j b/Task/Numeric-error-propagation/J/numeric-error-propagation-4.j new file mode 100644 index 0000000000..1a73f6f1ac --- /dev/null +++ b/Task/Numeric-error-propagation/J/numeric-error-propagation-4.j @@ -0,0 +1,4 @@ + num 100 +100 + unc 100 +0 diff --git a/Task/Numeric-error-propagation/J/numeric-error-propagation-5.j b/Task/Numeric-error-propagation/J/numeric-error-propagation-5.j new file mode 100644 index 0000000000..010b2918c0 --- /dev/null +++ b/Task/Numeric-error-propagation/J/numeric-error-propagation-5.j @@ -0,0 +1,2 @@ + 3 dist 4 +5 diff --git a/Task/Numeric-error-propagation/J/numeric-error-propagation-6.j b/Task/Numeric-error-propagation/J/numeric-error-propagation-6.j new file mode 100644 index 0000000000..b29eebbcd4 --- /dev/null +++ b/Task/Numeric-error-propagation/J/numeric-error-propagation-6.j @@ -0,0 +1,5 @@ +add=: +&num unc dist&unc +sub=: -&num unc dist&unc +mul=: *&num unc |@(*&num * dist&(unc%num)) +div=: %&num unc |@(%&num * dist&(unc%num)) +exp=: ^&num unc |@(^&num * dist&(unc%num)) diff --git a/Task/Numeric-error-propagation/J/numeric-error-propagation-7.j b/Task/Numeric-error-propagation/J/numeric-error-propagation-7.j new file mode 100644 index 0000000000..463c6a257d --- /dev/null +++ b/Task/Numeric-error-propagation/J/numeric-error-propagation-7.j @@ -0,0 +1,2 @@ + exp&0.5 (x1 sub x2) add&(exp&2) y1 sub y2 +111.803 2.48717 diff --git a/Task/Numeric-error-propagation/Mathematica/numeric-error-propagation-1.math b/Task/Numeric-error-propagation/Mathematica/numeric-error-propagation-1.math new file mode 100644 index 0000000000..2e039e1672 --- /dev/null +++ b/Task/Numeric-error-propagation/Mathematica/numeric-error-propagation-1.math @@ -0,0 +1,5 @@ +PlusMinus /: a_ ± σa_ + c_?NumericQ := N[(a + c) ± σa]; +PlusMinus /: a_ ± σa_ + b_ ± σb_ := N[(a + b) ± Norm@{σa, σb}]; +PlusMinus /: c_?NumericQ (a_ ± σa_) := N[c a ± Abs[c σa]]; +PlusMinus /: (a_ ± σa_) (b_ ± σb_) := N[a b ± (a b Norm@{σa/a, σb/b})^2]; +PlusMinus /: (a_ ± σa_)^c_?NumericQ := N[a^c ± Abs[a^c σa/a]]; diff --git a/Task/Numeric-error-propagation/Mathematica/numeric-error-propagation-2.math b/Task/Numeric-error-propagation/Mathematica/numeric-error-propagation-2.math new file mode 100644 index 0000000000..20c51889b8 --- /dev/null +++ b/Task/Numeric-error-propagation/Mathematica/numeric-error-propagation-2.math @@ -0,0 +1,5 @@ +x1 = 100 ± 1.1; +y1 = 50 ± 1.2; +x2 = 200 ± 2.2; +y2 = 100 ± 2.3; +d = Sqrt[(x1 - x2)^2 + (y1 - y2)^2] diff --git a/Task/Numeric-error-propagation/Perl-6/numeric-error-propagation.pl6 b/Task/Numeric-error-propagation/Perl-6/numeric-error-propagation.pl6 new file mode 100644 index 0000000000..29c27396fd --- /dev/null +++ b/Task/Numeric-error-propagation/Perl-6/numeric-error-propagation.pl6 @@ -0,0 +1,100 @@ +# cache of independent sources so we can make them all the same length. +# (Because Perl 6 does not yet have a longest-zip metaoperator.) +my @INDEP; + +class Approx does Numeric { + has Real $.x; # The mean. + has $.c; # The components of error. + + multi method Str { sprintf "%g±%.3g", $!x, $.σ } + multi method Bool { abs($!x) > $.σ } + + method variance { [+] @.c X** 2 } + method σ { sqrt self.variance } +} + +multi approx($x,$c) { Approx.new: :$x, :$c } +multi approx($x) { Approx.new: :$x, :c[0 xx +@INDEP] } + +# Each ± gets its own source slot. +multi infix:<±>($a, $b) { + .push: 0 for @INDEP; # lengthen older component lists + my $c = [ 0 xx @INDEP, $b ]; + @INDEP.push: $c; # add new component list + + approx $a, $c; +} + +multi prefix:<->(Approx $a) { approx -$a.x, [$a.c.map: -*] } + +multi infix:<+>($a, Approx $b) { approx($a) + $b } +multi infix:<+>(Approx $a, $b) { $a + approx($b) } +multi infix:<+>(Approx $a, Approx $b) { approx $a.x + $b.x, [$a.c Z+ $b.c] } + +multi infix:<->($a, Approx $b) { approx($a) - $b } +multi infix:<->(Approx $a, $b) { $a - approx($b) } +multi infix:<->(Approx $a, Approx $b) { approx $a.x - $b.x, [$a.c Z- $b.c] } + +multi covariance(Real $a, Real $b) { 0 } +multi covariance(Approx $a, Approx $b) { [+] $a.c Z* $b.c } + +multi infix:«<=>»(Approx $a, Approx $b) { $a.x <=> $b.x } +multi infix:(Approx $a, Approx $b) { $a.x <=> $b.x } + +multi infix:<*>($a, Approx $b) { approx($a) * $b } +multi infix:<*>(Approx $a, $b) { $a * approx($b) } +multi infix:<*>(Approx $a, Approx $b) { + approx $a.x * $b.x, + [$a.c.map({$b.x * $_}) Z+ $b.c.map({$a.x * $_})]; +} + +multi infix:($a, Approx $b) { approx($a) / $b } +multi infix:(Approx $a, $b) { $a / approx($b) } +multi infix:(Approx $a, Approx $b) { + approx $a.x / $b.x, + [ $a.c.map({ $_ / $b.x }) Z+ $b.c.map({ $a.x * $_ / $b.x / $b.x }) ]; +} + +multi sqrt(Approx $a) { + my $x = sqrt($a.x); + approx $x, [ $a.c.map: { $_ / 2 / $x } ]; +} + +multi infix:<**>(Approx $a, Real $b) { $a ** approx($b) } +multi infix:<**>(Approx $a is copy, Approx $b) { + my $ax = $a.x; + my $bx = $b.x; + my $fbx = floor $b.x; + if $ax < 0 { + if $fbx != $bx or $fbx +& 1 { + die "Can't take power of negative number $ax"; + } + $a = -$a; + } + exp($b * log $a); +} + +multi exp(Approx $a) { + my $x = exp($a.x); + approx $x, [ $a.c.map: { $x * $_ } ]; +} + +multi log(Approx $a) { + my $x0 = $a.x; + approx log($x0), [ $a.c.map: { $_ / $x0 }]; +} + +# Each ± sets up an independent source component. +my $x1 = 100 ± 1.1; +my $x2 = 200 ± 2.2; +my $y1 = 50 ± 1.2; +my $y2 = 100 ± 2.3; + +# The standard task. +my $z1 = sqrt(($x1 - $x2) ** 2 + ($y1 - $y2) ** 2); +say "distance: $z1\n"; + +# Just showing off. +my $a = $x1 + $x2; +my $b = $y1 - 2 * $x2; +say "covariance between $a and $b: ", covariance($a,$b); diff --git a/Task/Numeric-error-propagation/Perl/numeric-error-propagation-1.pl b/Task/Numeric-error-propagation/Perl/numeric-error-propagation-1.pl new file mode 100644 index 0000000000..809cf3a2fe --- /dev/null +++ b/Task/Numeric-error-propagation/Perl/numeric-error-propagation-1.pl @@ -0,0 +1,186 @@ +use utf8; +package ErrVar; +use strict; + +# helper function, apply f to pairs (a, b) from listX and listY +sub zip(&$$) { + my ($f, $x, $y) = @_; + my $l = $#$x; + if ($l < $#$y) { $l = $#$y }; + + my @out; + for (0 .. $l) { + local $a = $x->[$_]; + local $b = $y->[$_]; + push @out, $f->(); + } + \@out +} + +use overload + '""' => \&_str, + '+' => \&_add, + '-' => \&_sub, + '*' => \&_mul, + '/' => \&_div, + 'bool' => \&_bool, + '<=>' => \&_ncmp, + 'neg' => \&_neg, + + 'sqrt' => \&_sqrt, + 'log' => \&_log, + 'exp' => \&_exp, + '**' => \&_pow, +; + +# make a variable with mean value and a list of coefficient to +# variables providing independent errors +sub make { + my $x = shift; + bless [$x, [@{+shift}]] +} + +sub _str { sprintf "%g±%.3g", $_[0][0], sigma($_[0]) } + +# mean value of the var, or just the input if it's not of this class +sub mean { + my $x = shift; + ref($x) && $x->isa(__PACKAGE__) ? $x->[0] : $x +} + +# return variance index array +sub vlist { + my $x = shift; + ref($x) && $x->isa(__PACKAGE__) ? $x->[1] : []; +} + +sub variance { + my $x = shift; + return 0 unless ref($x) and $x->isa(__PACKAGE__); + my $s; + $s += $_ * $_ for (@{$x->[1]}); + $s +} + +sub covariance { + my ($x, $y) = @_; + return 0 unless ref($x) && $x->isa(__PACKAGE__); + return 0 unless ref($y) && $y->isa(__PACKAGE__); + + my $s; + zip { $s += $a * $b } vlist($x), vlist($y); + $s +} + +sub sigma { sqrt variance(shift) } + +# to determine if a var is probably zero. we use 1σ here +sub _bool { + my $x = shift; + return abs(mean($x)) > sigma($x); +} + +sub _ncmp { + my $x = shift() - shift() or return 0; + return mean($x) > 0 ? 1 : -1; +} + +sub _neg { + my $x = shift; + bless [ -mean($x), [map(-$_, @{vlist($x)}) ] ]; +} + +sub _add { + my ($x, $y) = @_; + my ($x0, $y0) = (mean($x), mean($y)); + my ($xv, $yv) = (vlist($x), vlist($y)); + bless [$x0 + $y0, zip {$a + $b} $xv, $yv]; +} + +sub _sub { + my ($x, $y, $swap) = @_; + if ($swap) { ($x, $y) = ($y, $x) } + my ($x0, $y0) = (mean($x), mean($y)); + my ($xv, $yv) = (vlist($x), vlist($y)); + bless [$x0 - $y0, zip {$a - $b} $xv, $yv]; +} + +sub _mul { + my ($x, $y) = @_; + my ($x0, $y0) = (mean($x), mean($y)); + my ($xv, $yv) = (vlist($x), vlist($y)); + + $xv = [ map($y0 * $_, @$xv) ]; + $yv = [ map($x0 * $_, @$yv) ]; + + bless [$x0 * $y0, zip {$a + $b} $xv, $yv]; +} + +sub _div { + my ($x, $y, $swap) = @_; + if ($swap) { ($x, $y) = ($y, $x) } + + my ($x0, $y0) = (mean($x), mean($y)); + my ($xv, $yv) = (vlist($x), vlist($y)); + + $xv = [ map($_/$y0, @$xv) ]; + $yv = [ map($x0 * $_/$y0/$y0, @$yv) ]; + + bless [$x0 / $y0, zip {$a + $b} $xv, $yv]; +} + +sub _sqrt { + my $x = shift; + my $x0 = mean($x); + my $xv = vlist($x); + $x0 = sqrt($x0); + $xv = [ map($_ / 2 / $x0, @$xv) ]; + bless [$x0, $xv] +} + +sub _pow { + my ($x, $y, $swap) = @_; + if ($swap) { ($x, $y) = ($y, $x) } + if ($x < 0) { + if (int($y) != $y || ($y & 1)) { + die "Can't take pow of negative number $x"; + } + $x = -$x; + } + exp($y * log $x) +} + +sub _exp { + my $x = shift; + my $x0 = exp(mean($x)); + my $xv = vlist($x); + bless [ $x0, [map($x0 * $_, @$xv) ] ] +} + +sub _log { + my $x = shift; + my $x0 = mean($x); + my $xv = vlist($x); + bless [ log($x0), [ map($_ / $x0, @$xv) ] ] +} + +"If this package were to be in its own file, you need some truth value to end it like this."; + +package main; + +sub e { ErrVar::make @_ }; + +# x1 is of mean value 100, containing error 1.1 from source 1, etc. +# all error sources are independent. +my $x1 = e 100, [1.1, 0, 0, 0 ]; +my $x2 = e 200, [0, 2.2, 0, 0 ]; +my $y1 = e 50, [0, 0, 1.2, 0 ]; +my $y2 = e 100, [0, 0, 0, 2.3]; + +my $z1 = sqrt(($x1 - $x2) ** 2 + ($y1 - $y2) ** 2); +print "distance: $z1\n\n"; + +# this is not for task requirement +my $a = $x1 + $x2; +my $b = $y1 - 2 * $x2; +print "covariance between $a and $b: ", $a->covariance($b), "\n"; diff --git a/Task/Numeric-error-propagation/Perl/numeric-error-propagation-2.pl b/Task/Numeric-error-propagation/Perl/numeric-error-propagation-2.pl new file mode 100644 index 0000000000..411cbab3da --- /dev/null +++ b/Task/Numeric-error-propagation/Perl/numeric-error-propagation-2.pl @@ -0,0 +1,3 @@ +distance: 111.803±2.49 + +covariance between 300±2.46 and -350±4.56: -9.68 diff --git a/Task/Numeric-error-propagation/PicoLisp/numeric-error-propagation-1.l b/Task/Numeric-error-propagation/PicoLisp/numeric-error-propagation-1.l new file mode 100644 index 0000000000..cfd0e3376e --- /dev/null +++ b/Task/Numeric-error-propagation/PicoLisp/numeric-error-propagation-1.l @@ -0,0 +1,94 @@ +(scl 12) +(load "@lib/math.l") + +# Overload arithmetic operators +, -, *, / and ** +(redef + @ + (let R (next) + (while (args) + (let N (next) + (setq R + (if2 (atom R) (atom N) + (+ R N) # c + c + (cons (+ R (car N)) (cdr N)) # c + a + (cons (+ (car R) N) (cdr R)) # a + c + (cons # a + b + (+ (car R) (car N)) + (+ (cdr R) (cdr N)) ) ) ) ) ) + R ) ) + +(redef - @ + (let R (next) + (ifn (args) + (- R) + (while (args) + (let N (next) + (setq R + (if2 (atom R) (atom N) + (- R N) # c - c + (cons (- R (car N)) (cdr N)) # c - a + (cons (- (car R) N) (cdr R)) # a - c + (cons # a - b + (- (car R) (car N)) + (+ (cdr R) (cdr N)) ) ) ) ) ) + R ) ) ) + +(redef * @ + (let R (next) + (while (args) + (let N (next) + (setq R + (if2 (atom R) (atom N) + (* R N) # c * c + (cons # c * a + (*/ R (car N) 1.0) + (mul2div2 (cdr N) R 1.0) ) + (cons # a * c + (*/ (car R) N 1.0) + (mul2div2 (cdr R) N 1.0) ) + (uncMul (*/ (car R) (car N) 1.0) R N) ) ) ) ) # a * b + R ) ) + +(redef / @ + (let R (next) + (while (args) + (let N (next) + (setq R + (if2 (atom R) (atom N) + (/ R N) # c / c + (cons # c / a + (*/ R 1.0 (car N)) + (mul2div2 (cdr N) R 1.0) ) + (cons # a / c + (*/ (car R) 1.0 N) + (mul2div2 (cdr R) N 1.0) ) + (uncMul (*/ (car R) 1.0 (car N)) R N) ) ) ) ) # a / b + R ) ) + +(redef ** (A C) + (if (atom A) + (** A C) + (let F (pow (car A) C) + (cons F + (mul2div2 (cdr A) (*/ F C (car A)) 1.0) ) ) ) ) + +# Utilities +(de mul2div2 (A B C) + (*/ A B B (* C C)) ) + +(de uncMul (F R N) + (cons F + (mul2div2 + (+ + (mul2div2 (cdr R) 1.0 (car R)) + (mul2div2 (cdr N) 1.0 (car N)) ) + F + 1.0 ) ) ) + +# I/O conversion +(de unc (N U) + (if U + (cons N (*/ U U 1.0)) + (pack + (round (car N) 10) + " ± " + (round (sqrt (* 1.0 (cdr N))) 8) ) ) ) diff --git a/Task/Numeric-error-propagation/PicoLisp/numeric-error-propagation-2.l b/Task/Numeric-error-propagation/PicoLisp/numeric-error-propagation-2.l new file mode 100644 index 0000000000..de97087bc8 --- /dev/null +++ b/Task/Numeric-error-propagation/PicoLisp/numeric-error-propagation-2.l @@ -0,0 +1,12 @@ +(de distance (X1 Y1 X2 Y2) + (** + (+ (** (- X1 X2) 2.0) (** (- Y1 Y2) 2.0)) + 0.5 ) ) + +(prinl "Distance: " + (unc + (distance + (unc 100. 1.1) + (unc 50. 1.2) + (unc 200. 2.2) + (unc 100. 2.3) ) ) ) diff --git a/Task/Numeric-error-propagation/Python/numeric-error-propagation.py b/Task/Numeric-error-propagation/Python/numeric-error-propagation.py new file mode 100644 index 0000000000..49a5fca7f1 --- /dev/null +++ b/Task/Numeric-error-propagation/Python/numeric-error-propagation.py @@ -0,0 +1,93 @@ +from collections import namedtuple +import math + +class I(namedtuple('Imprecise', 'value, delta')): + 'Imprecise type: I(value=0.0, delta=0.0)' + + __slots__ = () + + def __new__(_cls, value=0.0, delta=0.0): + 'Defaults to 0.0 ± delta' + return super().__new__(_cls, float(value), abs(float(delta))) + + def reciprocal(self): + return I(1. / self.value, self.delta / (self.value**2)) + + def __str__(self): + 'Shorter form of Imprecise as string' + return 'I(%g, %g)' % self + + def __neg__(self): + return I(-self.value, self.delta) + + def __add__(self, other): + if type(other) == I: + return I( self.value + other.value, (self.delta**2 + other.delta**2)**0.5 ) + try: + c = float(other) + except: + return NotImplemented + return I(self.value + c, self.delta) + + def __sub__(self, other): + return self + (-other) + + def __radd__(self, other): + return I.__add__(self, other) + + def __mul__(self, other): + if type(other) == I: + #if id(self) == id(other): + # return self ** 2 + a1,b1 = self + a2,b2 = other + f = a1 * a2 + return I( f, f * ( (b1 / a1)**2 + (b2 / a2)**2 )**0.5 ) + try: + c = float(other) + except: + return NotImplemented + return I(self.value * c, self.delta * c) + + def __pow__(self, other): + if type(other) == I: + return NotImplemented + try: + c = float(other) + except: + return NotImplemented + f = self.value ** c + return I(f, f * c * (self.delta / self.value)) + + def __rmul__(self, other): + return I.__mul__(self, other) + + def __truediv__(self, other): + if type(other) == I: + return self.__mul__(other.reciprocal()) + try: + c = float(other) + except: + return NotImplemented + return I(self.value / c, self.delta / c) + + def __rtruediv__(self, other): + return other * self.reciprocal() + + __div__, __rdiv__ = __truediv__, __rtruediv__ + +Imprecise = I + +def distance(p1, p2): + x1, y1 = p1 + x2, y2 = p2 + return ((x1 - x2)**2 + (y1 - y2)**2)**0.5 + +x1 = I(100, 1.1) +x2 = I(200, 2.2) +y1 = I( 50, 1.2) +y2 = I(100, 2.3) + +p1, p2 = (x1, y1), (x2, y2) +print("Distance between points\n p1: %s\n and p2: %s\n = %r" % ( + p1, p2, distance(p1, p2))) diff --git a/Task/Numeric-error-propagation/Ruby/numeric-error-propagation.rb b/Task/Numeric-error-propagation/Ruby/numeric-error-propagation.rb new file mode 100644 index 0000000000..987c6eebed --- /dev/null +++ b/Task/Numeric-error-propagation/Ruby/numeric-error-propagation.rb @@ -0,0 +1,64 @@ +class NumberWithUncertainty + def initialize(number, error) + @num = number + @err = error.abs + end + attr_reader :num, :err + + def +(other) + if other.kind_of?(self.class) + self.class.new(num + other.num, Math::hypot(err, other.err)) + else + self.class.new(num + other, err) + end + end + + def -(other) + if other.kind_of?(self.class) + self.class.new(num - other.num, Math::hypot(err, other.err)) + else + self.class.new(num - other, err) + end + end + + def *(other) + if other.kind_of?(self.class) + prod = num * other.num + e = Math::hypot((prod * err / num), (prod * other.err / other.num)) + self.class.new(prod, e) + else + self.class.new(num * other, (err * other).abs) + end + end + + def /(other) + if other.kind_of?(self.class) + quo = num / other.num + e = Math::hypot((quo * err / num), (quo * other.err / other.num)) + self.class.new(quo, e) + else + self.class.new(num / other, (err * other).abs) + end + end + + def **(exponent) + Float(exponent) rescue raise ArgumentError, "not an number: #{exponent}" + prod = num ** exponent + self.class.new(prod, (prod * exponent * err / num).abs) + end + + def sqrt + self ** 0.5 + end + + def to_s + "#{num} \u00b1 #{err}" + end +end + +x1 = NumberWithUncertainty.new(100, 1.1) +y1 = NumberWithUncertainty.new( 50, 1.2) +x2 = NumberWithUncertainty.new(200, 2.2) +y2 = NumberWithUncertainty.new(100, 2.3) + +puts ((x1 - x2) ** 2 + (y1 - y2) ** 2).sqrt diff --git a/Task/Numeric-error-propagation/Tcl/numeric-error-propagation-1.tcl b/Task/Numeric-error-propagation/Tcl/numeric-error-propagation-1.tcl new file mode 100644 index 0000000000..8287c85f47 --- /dev/null +++ b/Task/Numeric-error-propagation/Tcl/numeric-error-propagation-1.tcl @@ -0,0 +1,54 @@ +package require Tcl 8.6 +oo::class create RAII-support { + constructor {} { + upvar 1 { end } end + lappend end [self] + trace add variable end unset [namespace code {my DieNicely}] + } + destructor { + catch { + upvar 1 { end } end + trace remove variable end unset [namespace code {my DieNicely}] + } + } + method return {{level 1}} { + incr level + upvar 1 { end } end + upvar $level { end } parent + trace remove variable end unset [namespace code {my DieNicely}] + lappend parent [self] + trace add variable parent unset [namespace code {my DieNicely}] + return -level $level [self] + } + # Swallows arguments + method DieNicely args {tailcall my destroy} +} +oo::class create RAII-class { + superclass oo::class + method return args { + [my new {*}$args] return 2 + } + method unknown {m args} { + if {[string is double -strict $m]} { + return [tailcall my new $m {*}$args] + } + next $m {*}$args + } + unexport create unknown + self method create args { + set c [next {*}$args] + oo::define $c superclass {*}[info class superclass $c] RAII-support + return $c + } +} +# Makes a convenient scope for limiting RAII lifetimes +proc scope {script} { + foreach v [info global] { + if {[array exists ::$v] || [string match { * } $v]} continue + lappend vars $v + lappend vals [set ::$v] + } + tailcall apply [list $vars [list \ + try $script on ok msg {$msg return} + ] [uplevel 1 {namespace current}]] {*}$vals +} diff --git a/Task/Numeric-error-propagation/Tcl/numeric-error-propagation-2.tcl b/Task/Numeric-error-propagation/Tcl/numeric-error-propagation-2.tcl new file mode 100644 index 0000000000..32d70bfb91 --- /dev/null +++ b/Task/Numeric-error-propagation/Tcl/numeric-error-propagation-2.tcl @@ -0,0 +1,51 @@ +RAII-class create Err { + variable N E + constructor {number {error 0.0}} { + next + namespace import ::tcl::mathfunc::* ::tcl::mathop::* + variable N $number E [abs $error] + } + method p {} { + return "$N \u00b1 $E" + } + + method n {} { return $N } + method e {} { return $E } + + method + e { + if {[info object isa object $e]} { + Err return [+ $N [$e n]] [hypot $E [$e e]] + } else { + Err return [+ $N $e] $E + } + } + method - e { + if {[info object isa object $e]} { + Err return [- $N [$e n]] [hypot $E [$e e]] + } else { + Err return [- $N $e] $E + } + } + method * e { + if {[info object isa object $e]} { + set f [* $n [$E n]] + Err return $f [expr {hypot($E*$f/$N, [$e e]*$f/[$e n])}] + } else { + Err return [* $N $e] [abs [* $E $e]] + } + } + method / e { + if {[info object isa object $e]} { + set f [/ $n [$E n]] + Err return $f [expr {hypot($E*$f/$N, [$e e]*$f/[$e n])}] + } else { + Err return [/ $N $e] [abs [/ $E $e]] + } + } + method ** c { + set f [** $N $c] + Err return $f [abs [* $f $c [/ $E $N]]] + } + + export + - * / ** +} diff --git a/Task/Numeric-error-propagation/Tcl/numeric-error-propagation-3.tcl b/Task/Numeric-error-propagation/Tcl/numeric-error-propagation-3.tcl new file mode 100644 index 0000000000..7323d8d303 --- /dev/null +++ b/Task/Numeric-error-propagation/Tcl/numeric-error-propagation-3.tcl @@ -0,0 +1,9 @@ +set x1 [Err 100 1.1] +set x2 [Err 200 2.2] +set y1 [Err 50 1.2] +set y2 [Err 100 2.3] +# Evaluate in a local context to clean up intermediate objects +set d [scope { + [[[$x1 - $x2] ** 2] + [[$y1 - $y2] ** 2]] ** 0.5 +}] +puts "d = [$d p]" diff --git a/Task/Numerical-integration-Gauss-Legendre-Quadrature/0DESCRIPTION b/Task/Numerical-integration-Gauss-Legendre-Quadrature/0DESCRIPTION new file mode 100644 index 0000000000..0fe8843f6b --- /dev/null +++ b/Task/Numerical-integration-Gauss-Legendre-Quadrature/0DESCRIPTION @@ -0,0 +1,42 @@ +{|border=1 cellspacing=0 cellpadding=3 +|In a general [[wp:Gaussian quadrature|Gaussian quadrature]] rule, an definite integral of f(x) is first approximated over the interval [-1,1] by a polynomial approximable function g(x) and a known weighting function W(x). +|\int_{-1}^1 f(x) \, dx = \int_{-1}^1 W(x) g(x) \, dx +|- +|Those are then approximated by a sum of function values at specified points x_i multiplied by some weights w_i: +|\int_{-1}^1 W(x) g(x) \, dx \approx \sum_{i=1}^n w_i g(x_i) +|- +|In the case of Gauss-Legendre quadrature, the weighting function W(x) = 1, so we can approximate an integral of f(x) with: +|\int_{-1}^1 f(x)\,dx \approx \sum_{i=1}^n w_i f(x_i) +|} + +For this, we first need to calculate the nodes and the weights, but after we have them, we can reuse them for numerious integral evaluations, which greatly speeds up the calculation compared to more [[Numerical Integration|simple numerical integration methods]]. + +{|border=1 cellspacing=0 cellpadding=3 +|The n evaluation points x_i for a n-point rule, also called "nodes", are roots of n-th order [[wp:Legendre Polynomials|Legendre Polynomials]] P_n(x). Legendre polynomials are defined by the following recursive rule: +|P_0(x) = 1
+P_1(x) = x
+nP_{n}(x) = (2n-1)xP_{n-1}(x)-(n-1)P_{n-2}(x) +|- +|There is also a recursive equation for their derivative: +|P_{n}'(x) = \frac{n}{x^2-1} \left( x P_n(x) - P_{n-1}(x) \right) +|- +|The roots of those polynomials are in general not analytically solvable, so they have to be approximated numerically, for example by [[wp:Newton's method|Newton-Raphson iteration]]: +|x_{n+1} = x_n - \frac{f(x_n)}{f'(x_n)} +|- +|The first guess x_0 for the i-th root of a n-order polynomial P_n can be given by +|x_0 = \cos \left( \pi \, \frac{i - \frac{1}{4}}{n+\frac{1}{2}} \right) +|- +|After we get the nodes x_i, we compute the appropriate weights by: +|w_i = \frac{2}{\left( 1-x_i^2 \right) [P'_n(x_i)]^2} +|- +|After we have the nodes and the weights for a n-point quadrature rule, we can approximate an integral over any interval [a,b] by +|\int_a^b f(x)\,dx \approx \frac{b-a}{2} \sum_{i=1}^n w_i f\left(\frac{b-a}{2}x_i + \frac{a+b}{2}\right) +|} + +'''Task description''' + +Similar to the task [[Numerical Integration]], the task here is to calculate the definite integral of a function f(x), but by applying an n-point Gauss-Legendre quadrature rule, as described [[wp:Gaussian Quadrature|here]], for example. The input values should be an function f to integrate, the bounds of the integration interval a and b, and the number of gaussian evaluation points n. An reference implementation in Common Lisp is provided for comparison. + +To demonstrate the calculation, compute the weights and nodes for an 5-point quadrature rule and then use them to compute + +::\int_{-3}^{3} \exp(x) \, dx \approx \sum_{i=1}^5 w_i \; \exp(x_i) \approx 20.036 diff --git a/Task/Numerical-integration-Gauss-Legendre-Quadrature/1META.yaml b/Task/Numerical-integration-Gauss-Legendre-Quadrature/1META.yaml new file mode 100644 index 0000000000..ecaf39d2a5 --- /dev/null +++ b/Task/Numerical-integration-Gauss-Legendre-Quadrature/1META.yaml @@ -0,0 +1,5 @@ +--- +category: +- Arithmetic +- Mathematics +note: Arithmetic operations diff --git a/Task/Numerical-integration-Gauss-Legendre-Quadrature/C/numerical-integration-gauss-legendre-quadrature.c b/Task/Numerical-integration-Gauss-Legendre-Quadrature/C/numerical-integration-gauss-legendre-quadrature.c new file mode 100644 index 0000000000..f983070920 --- /dev/null +++ b/Task/Numerical-integration-Gauss-Legendre-Quadrature/C/numerical-integration-gauss-legendre-quadrature.c @@ -0,0 +1,84 @@ +#include +#include + +#define N 5 +double Pi; +double lroots[N]; +double weight[N]; +double lcoef[N + 1][N + 1] = {{0}}; + +void lege_coef() +{ + int n, i; + lcoef[0][0] = lcoef[1][1] = 1; + for (n = 2; n <= N; n++) { + lcoef[n][0] = -(n - 1) * lcoef[n - 2][0] / n; + for (i = 1; i <= n; i++) + lcoef[n][i] = ((2 * n - 1) * lcoef[n - 1][i - 1] + - (n - 1) * lcoef[n - 2][i] ) / n; + } +} + +double lege_eval(int n, double x) +{ + int i; + double s = lcoef[n][n]; + for (i = n; i; i--) + s = s * x + lcoef[n][i - 1]; + return s; +} + +double lege_diff(int n, double x) +{ + return n * (x * lege_eval(n, x) - lege_eval(n - 1, x)) / (x * x - 1); +} + +void lege_roots() +{ + int i; + double x, x1; + for (i = 1; i <= N; i++) { + x = cos(Pi * (i - .25) / (N + .5)); + do { + x1 = x; + x -= lege_eval(N, x) / lege_diff(N, x); + } while (x != x1); + /* x != x1 is normally a no-no, but this task happens to be + * well behaved. */ + lroots[i - 1] = x; + + x1 = lege_diff(N, x); + weight[i - 1] = 2 / ((1 - x * x) * x1 * x1); + } +} + +double lege_inte(double (*f)(double), double a, double b) +{ + double c1 = (b - a) / 2, c2 = (b + a) / 2, sum = 0; + int i; + for (i = 0; i < N; i++) + sum += weight[i] * f(c1 * lroots[i] + c2); + return c1 * sum; +} + +int main() +{ + int i; + Pi = atan2(1, 1) * 4; + + lege_coef(); + lege_roots(); + + printf("Roots: "); + for (i = 0; i < N; i++) + printf(" %g", lroots[i]); + + printf("\nWeight:"); + for (i = 0; i < N; i++) + printf(" %g", weight[i]); + + printf("\nintegrating Exp(x) over [-3, 3]:\n\t%10.8f,\n" + "compred to actual\n\t%10.8f\n", + lege_inte(exp, -3, 3), exp(3) - exp(-3)); + return 0; +} diff --git a/Task/Numerical-integration-Gauss-Legendre-Quadrature/Common-Lisp/numerical-integration-gauss-legendre-quadrature-1.lisp b/Task/Numerical-integration-Gauss-Legendre-Quadrature/Common-Lisp/numerical-integration-gauss-legendre-quadrature-1.lisp new file mode 100644 index 0000000000..2e61e6cab9 --- /dev/null +++ b/Task/Numerical-integration-Gauss-Legendre-Quadrature/Common-Lisp/numerical-integration-gauss-legendre-quadrature-1.lisp @@ -0,0 +1,63 @@ +;; Computes the initial guess for the root i of a n-order Legendre polynomial. +(defun guess (n i) + (cos (* pi + (/ (- i 0.25d0) + (+ n 0.5d0))))) + +;; Computes and evaluates the n-order Legendre polynomial at the point x. +(defun legpoly (n x) + (let ((pa 1.0d0) + (pb x) + (pn)) + (cond ((= n 0) pa) + ((= n 1) pb) + (t (loop for i from 2 to n do + (setf pn (- (* (/ (- (* 2 i) 1) i) x pb) + (* (/ (- i 1) i) pa))) + (setf pa pb) + (setf pb pn) + finally (return pn)))))) + +;; Computes and evaluates the derivative of an n-order Legendre polynomial at point x. +(defun legdiff (n x) + (* (/ n (- (* x x) 1)) + (- (* x (legpoly n x)) + (legpoly (- n 1) x)))) + +;; Computes the n nodes for an n-point quadrature rule. (i.e. n roots of a n-order polynomial) +(defun nodes (n) + (let ((x (make-array n :initial-element 0.0d0))) + (loop for i from 0 to (- n 1) do + (let ((val (guess n (+ i 1))) ;Nullstellen-Schätzwert. + (itermax 5)) + (dotimes (j itermax) + (setf val (- val + (/ (legpoly n val) + (legdiff n val))))) + (setf (aref x i) val))) + x)) + +;; Computes the weight for an n-order polynomial at the point (node) x. +(defun legwts (n x) + (/ 2 + (* (- 1 (* x x)) + (expt (legdiff n x) 2)))) + +;; Takes a array of nodes x and computes an array of corresponding weights w. +(defun weights (x) + (let* ((n (car (array-dimensions x))) + (w (make-array n :initial-element 0.0d0))) + (loop for i from 0 to (- n 1) do + (setf (aref w i) (legwts n (aref x i)))) + w)) + +;; Integrates a function f with a n-point Gauss-Legendre quadrature rule over the interval [a,b]. +(defun int (f n a b) + (let* ((x (nodes n)) + (w (weights x))) + (* (/ (- b a) 2.0d0) + (loop for i from 0 to (- n 1) + sum (* (aref w i) + (funcall f (+ (* (/ (- b a) 2.0d0) + (aref x i)) + (/ (+ a b) 2.0d0)))))))) diff --git a/Task/Numerical-integration-Gauss-Legendre-Quadrature/Common-Lisp/numerical-integration-gauss-legendre-quadrature-2.lisp b/Task/Numerical-integration-Gauss-Legendre-Quadrature/Common-Lisp/numerical-integration-gauss-legendre-quadrature-2.lisp new file mode 100644 index 0000000000..8cc0ce7294 --- /dev/null +++ b/Task/Numerical-integration-Gauss-Legendre-Quadrature/Common-Lisp/numerical-integration-gauss-legendre-quadrature-2.lisp @@ -0,0 +1,8 @@ +(nodes 5) +#(0.906179845938664d0 0.5384693101056831d0 2.996272867003007d-95 -0.5384693101056831d0 -0.906179845938664d0) + +(weights (nodes 5)) +#(0.23692688505618917d0 0.47862867049936647d0 0.5688888888888889d0 0.47862867049936647d0 0.23692688505618917d0) + +(int #'exp 5 -3 3) +20.035577718385568d0 diff --git a/Task/Numerical-integration-Gauss-Legendre-Quadrature/Common-Lisp/numerical-integration-gauss-legendre-quadrature-3.lisp b/Task/Numerical-integration-Gauss-Legendre-Quadrature/Common-Lisp/numerical-integration-gauss-legendre-quadrature-3.lisp new file mode 100644 index 0000000000..ef6822426c --- /dev/null +++ b/Task/Numerical-integration-Gauss-Legendre-Quadrature/Common-Lisp/numerical-integration-gauss-legendre-quadrature-3.lisp @@ -0,0 +1,11 @@ +(int #'(lambda (x) (expt x 3)) 5 0 1) +0.24999999999999997d0 + +(int #'(lambda (x) (/ 1 x)) 5 1 100) +4.059147508941519d0 + +(int #'(lambda (x) x) 5 0 5000) +1.25d7 + +(int #'(lambda (x) x) 5 0 6000) +1.8000000000000004d7 diff --git a/Task/Numerical-integration-Gauss-Legendre-Quadrature/D/numerical-integration-gauss-legendre-quadrature.d b/Task/Numerical-integration-Gauss-Legendre-Quadrature/D/numerical-integration-gauss-legendre-quadrature.d new file mode 100644 index 0000000000..9ed4c90d77 --- /dev/null +++ b/Task/Numerical-integration-Gauss-Legendre-Quadrature/D/numerical-integration-gauss-legendre-quadrature.d @@ -0,0 +1,75 @@ +import std.stdio, std.math; + +immutable struct GaussLegendreQuadrature(size_t N, FP=double, + size_t NBITS=50) { + __gshared static double[N] lroots, weight; + alias FP[N + 1][N + 1] CoefMat; + + /*pure*/ nothrow static this() { + CoefMat lcoef = 0.0; + legendreCoefInit(/*ref*/ lcoef); + legendreRoots(lcoef); + } + + static private void legendreCoefInit(ref CoefMat lcoef) + pure nothrow { + lcoef[0][0] = lcoef[1][1] = 1; + foreach (int n; 2 .. N + 1) { // n must be signed. + lcoef[n][0] = -(n - 1) * lcoef[n - 2][0] / n; + foreach (i; 1 .. n + 1) + lcoef[n][i] = ((2 * n - 1) * lcoef[n - 1][i - 1] - + (n - 1) * lcoef[n - 2][i]) / n; + } + } + + private static void legendreRoots(in ref CoefMat lcoef) + /*pure*/ nothrow { + static FP legendreEval(in ref FP[N + 1][N + 1] lcoef, + in int n, in FP x) pure nothrow { + FP s = lcoef[n][n]; + foreach_reverse (i; 1 .. n+1) + s = s * x + lcoef[n][i - 1]; + return s; + } + + static FP legendreDiff(in ref CoefMat lcoef, + in int n, in FP x) pure nothrow { + return n * (x * legendreEval(lcoef, n, x) - + legendreEval(lcoef, n - 1, x)) / + (x ^^ 2 - 1); + } + + foreach (i; 1 .. N + 1) { + FP x = cos(PI * (i - 0.25) / (N + 0.5)); + FP x1; + do { + x1 = x; + x -= legendreEval(lcoef, N, x) / + legendreDiff(lcoef, N, x); + } while (feqrel(x, x1) < NBITS); + lroots[i - 1] = x; + x1 = legendreDiff(lcoef, N, x); + weight[i - 1] = 2 / ((1 - x ^^ 2) * (x1 ^^ 2)); + } + } + + static public FP integrate(in FP function(FP x) f, + in FP a, in FP b) { + immutable FP c1 = (b - a) / 2; + immutable FP c2 = (b + a) / 2; + FP sum = 0.0; + foreach (i; 0 .. N) + sum += weight[i] * f(c1 * lroots[i] + c2); + return c1 * sum; + } +} + +void main() { + GaussLegendreQuadrature!(5, real) glq; + writeln("Roots: ", glq.lroots); + writeln("Weight: ", glq.weight); + writefln("Integrating exp(x) over [-3, 3]: %10.12f", + glq.integrate(&exp, -3, 3)); + writefln("Compred to actual: %10.12f", + exp(3.0) - exp(-3.0)); +} diff --git a/Task/Numerical-integration-Gauss-Legendre-Quadrature/Go/numerical-integration-gauss-legendre-quadrature.go b/Task/Numerical-integration-Gauss-Legendre-Quadrature/Go/numerical-integration-gauss-legendre-quadrature.go new file mode 100644 index 0000000000..81a9f1219f --- /dev/null +++ b/Task/Numerical-integration-Gauss-Legendre-Quadrature/Go/numerical-integration-gauss-legendre-quadrature.go @@ -0,0 +1,96 @@ +package main + +import ( + "fmt" + "math" +) + +// cFunc for continuous function. A type definition for convenience. +type cFunc func(float64) float64 + +func main() { + fmt.Println("integral:", glq(math.Exp, -3, 3, 5)) +} + +// glq integrates f from a to b by Guass-Legendre quadrature using n nodes. +// For the task, it also shows the intermediate values determining the nodes: +// the n roots of the order n Legendre polynomal and the corresponding n +// weights used for the integration. +func glq(f cFunc, a, b float64, n int) float64 { + x, w := glqNodes(n, f) + show := func(label string, vs []float64) { + fmt.Printf("%8s: ", label) + for _, v := range vs { + fmt.Printf("%8.5f ", v) + } + fmt.Println() + } + show("nodes", x) + show("weights", w) + var sum float64 + bma2 := (b - a) * .5 + bpa2 := (b + a) * .5 + for i, xi := range x { + sum += w[i] * f(bma2*xi+bpa2) + } + return bma2 * sum +} + +// glqNodes computes both nodes and weights for a Gauss-Legendre +// Quadrature integration. Parameters are n, the number of nodes +// to compute and f, a continuous function to integrate. Return +// values have len n. +func glqNodes(n int, f cFunc) (node []float64, weight []float64) { + p := legendrePoly(n) + pn := p[n] + n64 := float64(n) + dn := func(x float64) float64 { + return (x*pn(x) - p[n-1](x)) * n64 / (x*x - 1) + } + node = make([]float64, n) + for i := range node { + x0 := math.Cos(math.Pi * (float64(i+1) - .25) / (n64 + .5)) + node[i] = newtonRaphson(pn, dn, x0) + } + weight = make([]float64, n) + for i, x := range node { + dnx := dn(x) + weight[i] = 2 / ((1 - x*x) * dnx * dnx) + } + return +} + +// legendrePoly constructs functions that implement Lengendre polynomials. +// This is done by function composition by recurrence relation (Bonnet's.) +// For given n, n+1 functions are returned, computing P0 through Pn. +func legendrePoly(n int) []cFunc { + r := make([]cFunc, n+1) + r[0] = func(float64) float64 { return 1 } + r[1] = func(x float64) float64 { return x } + for i := 2; i <= n; i++ { + i2m1 := float64(i*2 - 1) + im1 := float64(i - 1) + rm1 := r[i-1] + rm2 := r[i-2] + invi := 1 / float64(i) + r[i] = func(x float64) float64 { + return (i2m1*x*rm1(x) - im1*rm2(x)) * invi + } + } + return r +} + +// newtonRaphson is general purpose, although totally primitive, simply +// panicking after a fixed number of iterations without convergence to +// a fixed error. Parameter f must be a continuous function, +// df its derivative, x0 an initial guess. +func newtonRaphson(f, df cFunc, x0 float64) float64 { + for i := 0; i < 30; i++ { + x1 := x0 - f(x0)/df(x0) + if math.Abs(x1-x0) <= math.Abs(x0*1e-15) { + return x1 + } + x0 = x1 + } + panic("no convergence") +} diff --git a/Task/Numerical-integration-Gauss-Legendre-Quadrature/J/numerical-integration-gauss-legendre-quadrature-1.j b/Task/Numerical-integration-Gauss-Legendre-Quadrature/J/numerical-integration-gauss-legendre-quadrature-1.j new file mode 100644 index 0000000000..b7feaaae7a --- /dev/null +++ b/Task/Numerical-integration-Gauss-Legendre-Quadrature/J/numerical-integration-gauss-legendre-quadrature-1.j @@ -0,0 +1,16 @@ +P =: 3 :0 NB. list of coefficients for yth Legendre polynomial + if. y<:1 do. 1{.~->:y return. end. + y%~ (<:(,~+:)y) -/@:* (0,P<:y),:(P y-2) +) + +getpoints =: 3 :0 NB. points,:weights for y points + x=. 1{:: p. p=.P y + w=. 2% (-.*:x)**:(p..p)p.x + x,:w +) + +GaussLegendre =: 1 :0 NB. npoints function GaussLegendre (a,b) +: + 'x w'=.getpoints x + -:(-~/y)* +/w* u -:((+/,-~/)y)p.x +) diff --git a/Task/Numerical-integration-Gauss-Legendre-Quadrature/J/numerical-integration-gauss-legendre-quadrature-2.j b/Task/Numerical-integration-Gauss-Legendre-Quadrature/J/numerical-integration-gauss-legendre-quadrature-2.j new file mode 100644 index 0000000000..2f97afd3d8 --- /dev/null +++ b/Task/Numerical-integration-Gauss-Legendre-Quadrature/J/numerical-integration-gauss-legendre-quadrature-2.j @@ -0,0 +1,2 @@ + 5 ^ GaussLegendre _3 3 +20.0356 diff --git a/Task/Numerical-integration-Gauss-Legendre-Quadrature/Mathematica/numerical-integration-gauss-legendre-quadrature.math b/Task/Numerical-integration-Gauss-Legendre-Quadrature/Mathematica/numerical-integration-gauss-legendre-quadrature.math new file mode 100644 index 0000000000..a22191d6b9 --- /dev/null +++ b/Task/Numerical-integration-Gauss-Legendre-Quadrature/Mathematica/numerical-integration-gauss-legendre-quadrature.math @@ -0,0 +1,7 @@ +gaussLegendreQuadrature[func_, {a_, b_}, degree_: 5] := +Block[{nodes, x, weights}, + nodes = Cases[NSolve[LegendreP[degree, x] == 0, x], _?NumericQ, Infinity]; + weights = 2 (1 - nodes^2)/(degree LegendreP[degree - 1, nodes])^2; + (b - a)/2 weights.func[(b - a)/2 nodes + (b + a)/2]] + +gaussLegendreQuadrature[Exp, {-3, 3}] diff --git a/Task/Numerical-integration-Gauss-Legendre-Quadrature/Maxima/numerical-integration-gauss-legendre-quadrature.maxima b/Task/Numerical-integration-Gauss-Legendre-Quadrature/Maxima/numerical-integration-gauss-legendre-quadrature.maxima new file mode 100644 index 0000000000..2dbf7b0854 --- /dev/null +++ b/Task/Numerical-integration-Gauss-Legendre-Quadrature/Maxima/numerical-integration-gauss-legendre-quadrature.maxima @@ -0,0 +1,31 @@ +gauss_coeff(n) := block([p, q, v, w], + p: expand(legendre_p(n, x)), + q: expand(n/2*diff(p, x)*legendre_p(n - 1, x)), + v: map(rhs, bfallroots(p)), + w: map(lambda([z], 1/subst([x = z], q)), v), + [map(bfloat, v), map(bfloat, w)])$ + +gauss_int(f, a, b, n) := block([u, x, w, c, h], + u: gauss_coeff(n), + x: u[1], + w: u[2], + c: bfloat((a + b)/2), + h: bfloat((b - a)/2), + h*sum(w[i]*bfloat(f(c + x[i]*h)), i, 1, n))$ + + +fpprec: 40$ + + +gauss_int(lambda([x], 4/(1 + x^2)), 0, 1, 20); +/* 3.141592653589793238462643379852215927697b0 */ + +% - bfloat(%pi); +/* -3.427286956499858315999116083264403489053b-27 */ + + +gauss_int(exp, -3, 3, 5); +/* 2.003557771838556215392853572527509393154b1 */ + +% - bfloat(integrate(exp(x), x, -3, 3)); +/* -1.721364342416440206515136565621888185351b-4 */ diff --git a/Task/Numerical-integration-Gauss-Legendre-Quadrature/OCaml/numerical-integration-gauss-legendre-quadrature-1.ocaml b/Task/Numerical-integration-Gauss-Legendre-Quadrature/OCaml/numerical-integration-gauss-legendre-quadrature-1.ocaml new file mode 100644 index 0000000000..b880d930ea --- /dev/null +++ b/Task/Numerical-integration-Gauss-Legendre-Quadrature/OCaml/numerical-integration-gauss-legendre-quadrature-1.ocaml @@ -0,0 +1,36 @@ +let rec leg n x = match n with (* Evaluate Legendre polynomial *) + | 0 -> 1.0 + | 1 -> x + | k -> let u = 1.0 -. 1.0 /. float k in + (1.0+.u)*.x*.(leg (k-1) x) -. u*.(leg (k-2) x);; + +let leg' n x = match n with (* derivative *) + | 0 -> 0.0 + | 1 -> 1.0 + | _ -> ((leg (n-1) x) -. x*.(leg n x)) *. (float n)/.(1.0-.x*.x);; + +let approx_root k n = (* Reversed Francesco Tricomi: 1 <= k <= n *) + let pi = acos (-1.0) and s = float(2*n) + and t = 1.0 +. float(1-4*k)/.float(4*n+2) in + (1.0 -. (float (n-1))/.(s*.s*.s))*.cos(pi*.t);; + +let rec refine r n = (* Newton-Raphson *) + let r1 = r -. (leg n r)/.(leg' n r) in + if abs_float (r-.r1) < 2e-16 then r1 else refine r1 n;; + +let root k n = refine (approx_root k n) n;; + +let node k n = (* Abscissa and weight *) + let r = root k n in + let deriv = leg' n r in + let w = 2.0/.((1.0-.r*.r)*.(deriv*.deriv)) in + (r,w);; + +let nodes n = + let rec aux k = if k > n then [] else node k n :: aux (k+1) + in aux 1;; + +let quadrature n f a b = + let f1 x = f ((x*.(b-.a) +. a +. b)*.0.5) in + let eval s (x,w) = s +. w*.(f1 x) in + 0.5*.(b-.a)*.(List.fold_left eval 0.0 (nodes n));; diff --git a/Task/Numerical-integration-Gauss-Legendre-Quadrature/OCaml/numerical-integration-gauss-legendre-quadrature-2.ocaml b/Task/Numerical-integration-Gauss-Legendre-Quadrature/OCaml/numerical-integration-gauss-legendre-quadrature-2.ocaml new file mode 100644 index 0000000000..da6403b8bd --- /dev/null +++ b/Task/Numerical-integration-Gauss-Legendre-Quadrature/OCaml/numerical-integration-gauss-legendre-quadrature-2.ocaml @@ -0,0 +1,9 @@ +let calc n = + Printf.printf + "Gauss-Legendre %2d-point quadrature for exp over [-3..3] = %.16f\n" + n (quadrature n exp (-3.0) 3.0);; + +calc 5;; +calc 10;; +calc 15;; +calc 20;; diff --git a/Task/Numerical-integration-Gauss-Legendre-Quadrature/OCaml/numerical-integration-gauss-legendre-quadrature-3.ocaml b/Task/Numerical-integration-Gauss-Legendre-Quadrature/OCaml/numerical-integration-gauss-legendre-quadrature-3.ocaml new file mode 100644 index 0000000000..4430cccaa2 --- /dev/null +++ b/Task/Numerical-integration-Gauss-Legendre-Quadrature/OCaml/numerical-integration-gauss-legendre-quadrature-3.ocaml @@ -0,0 +1,2 @@ +Printf.printf "%.16f\n" ((exp 3.0) -.(exp (-3.0)));; +20.0357498548198052 diff --git a/Task/Numerical-integration-Gauss-Legendre-Quadrature/PARI-GP/numerical-integration-gauss-legendre-quadrature.pari b/Task/Numerical-integration-Gauss-Legendre-Quadrature/PARI-GP/numerical-integration-gauss-legendre-quadrature.pari new file mode 100644 index 0000000000..a0a8d60391 --- /dev/null +++ b/Task/Numerical-integration-Gauss-Legendre-Quadrature/PARI-GP/numerical-integration-gauss-legendre-quadrature.pari @@ -0,0 +1,6 @@ +GLq(f,a,b,n)={ + my(P=pollegendre(n),Pp=P',x=polroots(P)); + (b-a)*sum(i=1,n,f((b-a)*x[i]/2+(a+b)/2)/(1-x[i]^2)/subst(Pp,'x,x[i])^2) +}; +# \\ Turn on timer +GLq(x->exp(x), -3, 3, 5) \\ As of version 2.4.4, this can be written GLq(exp, -3, 3, 5) diff --git a/Task/Numerical-integration-Gauss-Legendre-Quadrature/Perl-6/numerical-integration-gauss-legendre-quadrature.pl6 b/Task/Numerical-integration-Gauss-Legendre-Quadrature/Perl-6/numerical-integration-gauss-legendre-quadrature.pl6 new file mode 100644 index 0000000000..afcbfc2353 --- /dev/null +++ b/Task/Numerical-integration-Gauss-Legendre-Quadrature/Perl-6/numerical-integration-gauss-legendre-quadrature.pl6 @@ -0,0 +1,55 @@ +multi legendre-pair( 1 , $x) { $x, 1 } +multi legendre-pair(Int $n, $x) { + my ($m1, $m2) = legendre-pair($n - 1, $x); + my \u = 1 - 1 / $n; + (1 + u) * $x * $m1 - u * $m2, $m1; +} + +multi legendre( 0 , $ ) { 1 } +multi legendre(Int $n, $x) { legendre-pair($n, $x)[0] } + +multi legendre-prime( 0 , $ ) { 0 } +multi legendre-prime( 1 , $ ) { 1 } +multi legendre-prime(Int $n, $x) { + my ($m0, $m1) = legendre-pair($n, $x); + ($m1 - $x * $m0) * $n / (1 - $x**2); +} + +sub approximate-legendre-root(Int $n, Int $k) { + # Approximation due to Francesco Tricomi + my \t = (4*$k - 1) / (4*$n + 2); + (1 - ($n - 1) / (8 * $n**3)) * cos(pi * t); +} + +sub newton-raphson(&f, &f-prime, $r is copy, :$eps = 2e-16) { + while abs(my \dr = - f($r) / f-prime($r)) >= $eps { + $r += dr; + } + $r; +} + +sub legendre-root(Int $n, Int $k) { + newton-raphson(&legendre.assuming($n), &legendre-prime.assuming($n), + approximate-legendre-root($n, $k)); +} + +sub weight(Int $n, $r) { 2 / ((1 - $r**2) * legendre-prime($n, $r)**2) } + +sub nodes(Int $n) { + gather { + take 0 => weight($n, 0) if $n !%% 2; + for 1 .. $n div 2 { + my $r = legendre-root($n, $_); + my $w = weight($n, $r); + take $r => $w, -$r => $w; + } + } +} + +sub quadrature(Int $n, &f, $a, $b, :@nodes = nodes($n)) { + sub scale($x) { ($x * ($b - $a) + $a + $b) / 2 } + ($b - $a) / 2 * [+] @nodes.map: { .value * f(scale(.key)) } +} + +say "Gauss-Legendre $_.fmt('%2d')-point quadrature ∫₋₃⁺³ exp(x) dx ≈ ", + quadrature($_, &exp, -3, +3) for 5 .. 10, 20; diff --git a/Task/Numerical-integration-Gauss-Legendre-Quadrature/Python/numerical-integration-gauss-legendre-quadrature.py b/Task/Numerical-integration-Gauss-Legendre-Quadrature/Python/numerical-integration-gauss-legendre-quadrature.py new file mode 100644 index 0000000000..a7c41e93f6 --- /dev/null +++ b/Task/Numerical-integration-Gauss-Legendre-Quadrature/Python/numerical-integration-gauss-legendre-quadrature.py @@ -0,0 +1,97 @@ +from numpy import * + +################################################################## +# Recursive generation of the Legendre polynomial of order n +def Legendre(n,x): + x=array(x) + if (n==0): + return x*0+1.0 + elif (n==1): + return x + else: + return ((2.0*n-1.0)*x*Legendre(n-1,x)-(n-1)*Legendre(n-2,x))/n + +################################################################## +# Derivative of the Legendre polynomials +def DLegendre(n,x): + x=array(x) + if (n==0): + return x*0 + elif (n==1): + return x*0+1.0 + else: + return (n/(x**2-1.0))*(x*Legendre(n,x)-Legendre(n-1,x)) +################################################################## +# Roots of the polynomial obtained using Newton-Raphson method +def LegendreRoots(polyorder,tolerance=1e-20): + if polyorder<2: + err=1 # bad polyorder no roots can be found + else: + roots=[] + # The polynomials are alternately even and odd functions. So we evaluate only half the number of roots. + for i in range(1,int(polyorder)/2 +1): + x=cos(pi*(i-0.25)/(polyorder+0.5)) + error=10*tolerance + iters=0 + while (error>tolerance) and (iters<1000): + dx=-Legendre(polyorder,x)/DLegendre(polyorder,x) + x=x+dx + iters=iters+1 + error=abs(dx) + roots.append(x) + # Use symmetry to get the other roots + roots=array(roots) + if polyorder%2==0: + roots=concatenate( (-1.0*roots, roots[::-1]) ) + else: + roots=concatenate( (-1.0*roots, [0.0], roots[::-1]) ) + err=0 # successfully determined roots + return [roots, err] +################################################################## +# Weight coefficients +def GaussLegendreWeights(polyorder): + W=[] + [xis,err]=LegendreRoots(polyorder) + if err==0: + W=2.0/( (1.0-xis**2)*(DLegendre(polyorder,xis)**2) ) + err=0 + else: + err=1 # could not determine roots - so no weights + return [W, xis, err] +################################################################## +# The integral value +# func : the integrand +# a, b : lower and upper limits of the integral +# polyorder : order of the Legendre polynomial to be used +# +def GaussLegendreQuadrature(func, polyorder, a, b): + [Ws,xs, err]= GaussLegendreWeights(polyorder) + if err==0: + ans=(b-a)*0.5*sum( Ws*func( (b-a)*0.5*xs+ (b+a)*0.5 ) ) + else: + # (in case of error) + err=1 + ans=None + return [ans,err] +################################################################## +# The integrand - change as required +def func(x): + return exp(x) +################################################################## +# + +order=5 +[Ws,xs,err]=GaussLegendreWeights(order) +if err==0: + print "Order : ", order + print "Roots : ", xs + print "Weights : ", Ws +else: + print "Roots/Weights evaluation failed" + +# Integrating the function +[ans,err]=GaussLegendreQuadrature(func , order, -3,3) +if err==0: + print "Integral : ", ans +else: + print "Integral evaluation failed" diff --git a/Task/Numerical-integration-Gauss-Legendre-Quadrature/Tcl/numerical-integration-gauss-legendre-quadrature-1.tcl b/Task/Numerical-integration-Gauss-Legendre-Quadrature/Tcl/numerical-integration-gauss-legendre-quadrature-1.tcl new file mode 100644 index 0000000000..9d39759fcc --- /dev/null +++ b/Task/Numerical-integration-Gauss-Legendre-Quadrature/Tcl/numerical-integration-gauss-legendre-quadrature-1.tcl @@ -0,0 +1,63 @@ +package require Tcl 8.5 +package require math::special +package require math::polynomials +package require math::constants +math::constants::constants pi + +# Computes the initial guess for the root i of a n-order Legendre polynomial +proc guess {n i} { + global pi + expr { cos($pi * ($i - 0.25) / ($n + 0.5)) } +} + +# Computes and evaluates the n-order Legendre polynomial at the point x +proc legpoly {n x} { + math::polynomials::evalPolyn [math::special::legendre $n] $x +} + +# Computes and evaluates the derivative of an n-order Legendre polynomial at point x +proc legdiff {n x} { + expr {$n / ($x**2 - 1) * ($x * [legpoly $n $x] - [legpoly [incr n -1] $x])} +} + +# Computes the n nodes for an n-point quadrature rule. (i.e. n roots of a n-order polynomial) +proc nodes n { + set x [lrepeat $n 0.0] + for {set i 0} {$i < $n} {incr i} { + set val [guess $n [expr {$i + 1}]] + foreach . {1 2 3 4 5} { + set val [expr {$val - [legpoly $n $val] / [legdiff $n $val]}] + } + lset x $i $val + } + return $x +} + +# Computes the weight for an n-order polynomial at the point (node) x +proc legwts {n x} { + expr {2.0 / (1 - $x**2) / [legdiff $n $x]**2} +} + +# Takes a array of nodes x and computes an array of corresponding weights w +proc weights x { + set n [llength $x] + set w {} + foreach xi $x { + lappend w [legwts $n $xi] + } + return $w +} + +# Integrates a lambda term f with a n-point Gauss-Legendre quadrature rule over the interval [a,b] +proc gausslegendreintegrate {f n a b} { + set x [nodes $n] + set w [weights $x] + set rangesize2 [expr {($b - $a)/2}] + set rangesum2 [expr {($a + $b)/2}] + set sum 0.0 + foreach xi $x wi $w { + set y [expr {$rangesize2*$xi + $rangesum2}] + set sum [expr {$sum + $wi*[apply $f $y]}] + } + expr {$sum * $rangesize2} +} diff --git a/Task/Numerical-integration-Gauss-Legendre-Quadrature/Tcl/numerical-integration-gauss-legendre-quadrature-2.tcl b/Task/Numerical-integration-Gauss-Legendre-Quadrature/Tcl/numerical-integration-gauss-legendre-quadrature-2.tcl new file mode 100644 index 0000000000..0fd1a9271c --- /dev/null +++ b/Task/Numerical-integration-Gauss-Legendre-Quadrature/Tcl/numerical-integration-gauss-legendre-quadrature-2.tcl @@ -0,0 +1,4 @@ +puts "nodes(5) = [nodes 5]" +puts "weights(5) = [weights [nodes 5]]" +set exp {x {expr {exp($x)}}} +puts "int(exp,-3,3) = [gausslegendreintegrate $exp 5 -3 3]" diff --git a/Task/Numerical-integration-Gauss-Legendre-Quadrature/Ursala/numerical-integration-gauss-legendre-quadrature-1.ursala b/Task/Numerical-integration-Gauss-Legendre-Quadrature/Ursala/numerical-integration-gauss-legendre-quadrature-1.ursala new file mode 100644 index 0000000000..22fa85f699 --- /dev/null +++ b/Task/Numerical-integration-Gauss-Legendre-Quadrature/Ursala/numerical-integration-gauss-legendre-quadrature-1.ursala @@ -0,0 +1,34 @@ +#import std +#import nat + +legendre = # takes n to the pair of functions (P_n,P'_n), where P_n is the Legendre polynomial of order n + +~&?\(1E0!,0E0!)! -+ + ^|/~& //mp..vid^ mp..sub\1E0+ mp..sqr, + ~~ "c". ~&\1E0; ~&\"c"; ~&ar^?\0E0! mp..add^/mp..mul@alrPrhPX ^|R/~& ^|\~&t ^/~&l mp..mul, + @iiXNX ~&rZ->r @l ^/^|(~&tt+ sum@NNiCCiX+ successor,~&) both~&g&&~&+ -+ + ~* mp..zero_p?/~& (&&~&r ~&EZ+ ~~ mp..prec)^/~& ^(~&,..shr\8); mp..equ^|(~&,..gro\8)->l @r ^/~& ..shr\8, + ^(~&rl,mp..mul*lrrPD)^/..nat2mp@r -+ + ^(~&l,mp..sub*+ zipp0E0^|\~& :/0E0)+ ~&rrt->lhthPX ^( + ^lrNCC\~&lh mp..vid^*D/..nat2mp@rl -+ + mp..sub*+ zipp0E0^|\~& :/0E0, + mp..mul~*brlD^|bbI/~&hthPX @l ..nat2mp~~+ predecessor~~NiCiX+-, + @r ^|/successor predecessor), + ^|(mp..grow/1E0; @iNC ^lrNCC\~& :/0E0,~&/2)+-+-+- + +nodes = # takes precision and order (p,n) to a list of nodes and weights <(x_1,w_1)..(x_n,w_n)> + +-+ + ^H( + @lrr *+ ^/~&+ mp..div/( ..nat2mp 2)++ mp..mul^/(mp..sqr; //mp..sub ..nat2mp 1)+ mp..sqr+, + mp..shr^*DrlXS/~&ll ^|H\~& *+ @NiX+ ->l^|(~&lZ!|+ not+ //mp..eq,@r+ ^/~&+ mp..sub^/~&+ mp..div^)), + ^/^|(~&,legendre) mp..cos*+ mp..mul^*D( + mp..div^|/mp..pi@NiC mp..add/5E-1+ ..nat2mp, + @r mp..bus/*2.5E-1+ ..nat2mp*+ nrange/1)+- + +integral = # takes precision and order (p,n) to a function taking a function and interval (f,(a,b)) + +("p","n"). -+ + mp..shrink^/~& difference\"p"+ mp..prec, + mp..mul^|/~& mp..add:-0E0+ * mp..mul^/~&rr ^H/~&ll mp..add^\~&lrr mp..mul@lrPrXl, + ^(~&rl,-*nodes("p","n"))^|/~& mp..vid~~G/2E0+ ^/mp..bus mp..add+- diff --git a/Task/Numerical-integration-Gauss-Legendre-Quadrature/Ursala/numerical-integration-gauss-legendre-quadrature-2.ursala b/Task/Numerical-integration-Gauss-Legendre-Quadrature/Ursala/numerical-integration-gauss-legendre-quadrature-2.ursala new file mode 100644 index 0000000000..b5d318a290 --- /dev/null +++ b/Task/Numerical-integration-Gauss-Legendre-Quadrature/Ursala/numerical-integration-gauss-legendre-quadrature-2.ursala @@ -0,0 +1,7 @@ +#show+ + +demo = + +~&lNrCT ( + ^|lNrCT(:/'nodes:',:/'weights:')@lSrSX ..mp2str~~* nodes/160 5, + :/'integral:' ~&iNC ..mp2str integral(160,5) (mp..exp,-3E0,3E0)) diff --git a/Task/Numerical-integration/0DESCRIPTION b/Task/Numerical-integration/0DESCRIPTION new file mode 100644 index 0000000000..6b1f454070 --- /dev/null +++ b/Task/Numerical-integration/0DESCRIPTION @@ -0,0 +1,24 @@ +Write functions to calculate the definite integral of a function (''f(x)'') using [[wp:Rectangle_method|rectangular]] (left, right, and midpoint), [[wp:Trapezoidal_rule|trapezium]], and [[wp:Simpson%27s_rule|Simpson's]] methods. Your functions should take in the upper and lower bounds (''a'' and ''b'') and the number of approximations to make in that range (''n''). Assume that your example already has a function that gives values for ''f(x)''. + +Simpson's method is defined by the following pseudocode: +
+h := (b - a) / n
+sum1 := f(a + h/2)
+sum2 := 0
+
+loop on i from 1 to (n - 1)
+    sum1 := sum1 + f(a + h * i + h/2)
+    sum2 := sum2 + f(a + h * i)
+
+answer := (h / 6) * (f(a) + f(b) + 4*sum1 + 2*sum2)
+
+ +Demonstrate your function by showing the results for: +* f(x) = x^3, where x is [0,1], with 100 approximations. The exact result is 1/4, or 0.25. +* f(x) = 1/x, where x is [1,100], with 1,000 approximations. The exact result is the natural log of 100, or about 4.605170 +* f(x) = x, where x is [0,5000], with 5,000,000 approximations. The exact result is 12,500,000. +* f(x) = x, where x is [0,6000], with 6,000,000 approximations. The exact result is 18,000,000. + +'''See also''' +* [[Active object]] for integrating a function of real time. +* [[Numerical integration/Gauss-Legendre Quadrature]] for another integration method. diff --git a/Task/Numerical-integration/1META.yaml b/Task/Numerical-integration/1META.yaml new file mode 100644 index 0000000000..8644b2ad9b --- /dev/null +++ b/Task/Numerical-integration/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Arithmetic operations diff --git a/Task/Numerical-integration/ALGOL-68/numerical-integration.alg b/Task/Numerical-integration/ALGOL-68/numerical-integration.alg new file mode 100644 index 0000000000..dfe4e3a434 --- /dev/null +++ b/Task/Numerical-integration/ALGOL-68/numerical-integration.alg @@ -0,0 +1,85 @@ +MODE F = PROC(LONG REAL)LONG REAL; + +############### +## left rect ## +############### + +PROC left rect = (F f, LONG REAL a, b, INT n) LONG REAL: +BEGIN + LONG REAL h= (b - a) / n; + LONG REAL sum:= 0; + LONG REAL x:= a; + WHILE x <= b - h DO + sum := sum + (h * f(x)); + x +:= h + OD; + sum +END # left rect #; + +################# +## right rect ## +################# + +PROC right rect = (F f, LONG REAL a, b, INT n) LONG REAL: +BEGIN + LONG REAL h= (b - a) / n; + LONG REAL sum:= 0; + LONG REAL x:= a + h; + WHILE x <= b DO + sum := sum + (h * f(x)); + x +:= h + OD; + sum +END # right rect #; + +############### +## mid rect ## +############### + +PROC mid rect = (F f, LONG REAL a, b, INT n) LONG REAL: +BEGIN + LONG REAL h= (b - a) / n; + LONG REAL sum:= 0; + LONG REAL x:= a; + WHILE x <= b - h DO + sum := sum + h * f(x + h / 2); + x +:= h + OD; + sum +END # mid rect #; + +############### +## trapezium ## +############### + +PROC trapezium = (F f, LONG REAL a, b, INT n) LONG REAL: +BEGIN + LONG REAL h= (b - a) / n; + LONG REAL sum:= f(a) + f(b); + LONG REAL x:= 1; + WHILE x <= n - 1 DO + sum := sum + 2 * f(a + x * h ); + x +:= 1 + OD; + (b - a) / (2 * n) * sum +END # trapezium #; + +############# +## simpson ## +############# + +PROC simpson = (F f, LONG REAL a, b, INT n) LONG REAL: +BEGIN + LONG REAL h= (b - a) / n; + LONG REAL sum1:= 0; + LONG REAL sum2:= 0; + INT limit:= n - 1; + FOR i FROM 0 TO limit DO + sum1 := sum1 + f(a + h * LONG REAL(i) + h / 2) + OD; + FOR i FROM 1 TO limit DO + sum2 +:= f(a + h * LONG REAL(i)) + OD; + h / 6 * (f(a) + f(b) + 4 * sum1 + 2 * sum2) +END # simpson #; +SKIP diff --git a/Task/Numerical-integration/ActionScript/numerical-integration-1.as b/Task/Numerical-integration/ActionScript/numerical-integration-1.as new file mode 100644 index 0000000000..8b1eefae99 --- /dev/null +++ b/Task/Numerical-integration/ActionScript/numerical-integration-1.as @@ -0,0 +1,51 @@ +function leftRect(f:Function, a:Number, b:Number, n:uint):Number +{ + var sum:Number = 0; + var dx:Number = (b-a)/n; + for (var x:Number = a; n > 0; n--, x += dx) + sum += f(x); + return sum * dx; +} + +function rightRect(f:Function, a:Number, b:Number, n:uint):Number +{ + var sum:Number = 0; + var dx:Number = (b-a)/n; + for (var x:Number = a + dx; n > 0; n--, x += dx) + sum += f(x); + return sum * dx; +} + +function midRect(f:Function, a:Number, b:Number, n:uint):Number +{ + var sum:Number = 0; + var dx:Number = (b-a)/n; + for (var x:Number = a + (dx / 2); n > 0; n--, x += dx) + sum += f(x); + return sum * dx; +} +function trapezium(f:Function, a:Number, b:Number, n:uint):Number +{ + var dx:Number = (b-a)/n; + var x:Number = a; + var sum:Number = f(a); + for(var i:uint = 1; i < n; i++) + { + a += dx; + sum += f(a)*2; + } + sum += f(b); + return 0.5 * dx * sum; +} +function simpson(f:Function, a:Number, b:Number, n:uint):Number +{ + var dx:Number = (b-a)/n; + var sum1:Number = f(a + dx/2); + var sum2:Number = 0; + for(var i:uint = 1; i < n; i++) + { + sum1 += f(a + dx*i + dx/2); + sum2 += f(a + dx*i); + } + return (dx/6) * (f(a) + f(b) + 4*sum1 + 2*sum2); +} diff --git a/Task/Numerical-integration/ActionScript/numerical-integration-2.as b/Task/Numerical-integration/ActionScript/numerical-integration-2.as new file mode 100644 index 0000000000..908b1cba31 --- /dev/null +++ b/Task/Numerical-integration/ActionScript/numerical-integration-2.as @@ -0,0 +1,8 @@ +function f1(n:Number):Number { + return (2/(1+ 4*(n*n))); +} +trace(leftRect(f1, -1, 2, 4)); +trace(rightRect(f1, -1, 2, 4)); +trace(midRect(f1, -1, 2, 4)); +trace(trapezium(f1, -1, 2 ,4 )); +trace(simpson(f1, -1, 2 ,4 )); diff --git a/Task/Numerical-integration/Ada/numerical-integration-1.ada b/Task/Numerical-integration/Ada/numerical-integration-1.ada new file mode 100644 index 0000000000..f7bec1ae3d --- /dev/null +++ b/Task/Numerical-integration/Ada/numerical-integration-1.ada @@ -0,0 +1,10 @@ +generic + type Scalar is digits <>; + with function F (X : Scalar) return Scalar; +package Integrate is + function Left_Rectangular (A, B : Scalar; N : Positive) return Scalar; + function Right_Rectangular (A, B : Scalar; N : Positive) return Scalar; + function Midpoint_Rectangular (A, B : Scalar; N : Positive) return Scalar; + function Trapezium (A, B : Scalar; N : Positive) return Scalar; + function Simpsons (A, B : Scalar; N : Positive) return Scalar; +end Integrate; diff --git a/Task/Numerical-integration/Ada/numerical-integration-2.ada b/Task/Numerical-integration/Ada/numerical-integration-2.ada new file mode 100644 index 0000000000..17da41a2bb --- /dev/null +++ b/Task/Numerical-integration/Ada/numerical-integration-2.ada @@ -0,0 +1,61 @@ +package body Integrate is + function Left_Rectangular (A, B : Scalar; N : Positive) return Scalar is + H : constant Scalar := (B - A) / Scalar (N); + Sum : Scalar := 0.0; + X : Scalar; + begin + for I in 0 .. N - 1 loop + X := A + Scalar (I) * H; + Sum := Sum + H * F (X); + end loop; + return Sum; + end Left_Rectangular; + + function Right_Rectangular (A, B : Scalar; N : Positive) return Scalar is + H : constant Scalar := (B - A) / Scalar (N); + Sum : Scalar := 0.0; + X : Scalar; + begin + for I in 1 .. N loop + X := A + Scalar (I) * H; + Sum := Sum + H * F (X); + end loop; + return Sum; + end Right_Rectangular; + + function Midpoint_Rectangular (A, B : Scalar; N : Positive) return Scalar is + H : constant Scalar := (B - A) / Scalar (N); + Sum : Scalar := 0.0; + X : Scalar; + begin + for I in 1 .. N loop + X := A + Scalar (I) * H - 0.5 * H; + Sum := Sum + H * F (X); + end loop; + return Sum; + end Midpoint_Rectangular; + + function Trapezium (A, B : Scalar; N : Positive) return Scalar is + H : constant Scalar := (B - A) / Scalar (N); + Sum : Scalar := F(A) + F(B); + X : Scalar := 1.0; + begin + while X <= Scalar (N) - 1.0 loop + Sum := Sum + 2.0 * F (A + X * (B - A) / Scalar (N)); + X := X + 1.0; + end loop; + return (B - A) / (2.0 * Scalar (N)) * Sum; + end Trapezium; + + function Simpsons (A, B : Scalar; N : Positive) return Scalar is + H : constant Scalar := (B - A) / Scalar (N); + Sum_1 : Scalar := 0.0; + Sum_2 : Scalar := 0.0; + begin + for I in 0 .. N - 1 loop + Sum_1 := Sum_1 + F (A + H * Scalar (I) + 0.5 * H); + Sum_2 := Sum_2 + F (A + H * Scalar (I)); + end loop; + return H / 6.0 * (F (A) + F (B) + 4.0 * Sum_1 + 2.0 * Sum_2); + end Simpsons; +end Integrate; diff --git a/Task/Numerical-integration/Ada/numerical-integration-3.ada b/Task/Numerical-integration/Ada/numerical-integration-3.ada new file mode 100644 index 0000000000..1980253ea6 --- /dev/null +++ b/Task/Numerical-integration/Ada/numerical-integration-3.ada @@ -0,0 +1,104 @@ +with Ada.Text_IO, Ada.Integer_Text_IO; +with Integrate; + +procedure Numerical_Integration is + type Scalar is digits 18; + package Scalar_Text_IO is new Ada.Text_IO.Float_IO (Scalar); + + generic + with function F (X : Scalar) return Scalar; + Name : String; + From, To : Scalar; + Steps : Positive; + procedure Test; + + procedure Test is + package Integrate_Scalar_F is new Integrate (Scalar, F); + use Ada.Text_IO, Ada.Integer_Text_IO, Integrate_Scalar_F, Scalar_Text_IO; + begin + Put (Name & " integrated from "); + Put (From); + Put (" to "); + Put (To); + Put (" in "); + Put (Steps); + Put_Line (" steps:"); + + Put ("Rectangular (left): "); + Put (Left_Rectangular (From, To, Steps)); + New_Line; + + Put ("Rectangular (right): "); + Put (Right_Rectangular (From, To, Steps)); + New_Line; + + Put ("Rectangular (midpoint): "); + Put (Midpoint_Rectangular (From, To, Steps)); + New_Line; + + Put ("Trapezium: "); + Put (Trapezium (From, To, Steps)); + New_Line; + + Put ("Simpson's: "); + Put (Simpsons (From, To, Steps)); + New_Line; + + New_Line; + end Test; +begin + Ada.Integer_Text_IO.Default_Width := 0; + Scalar_Text_IO.Default_Fore := 0; + Scalar_Text_IO.Default_Exp := 0; + +Cubed: + declare + function F (X : Scalar) return Scalar is + begin + return X ** 3; + end F; + procedure Run is new Test (F => F, + Name => "x^3", + From => 0.0, + To => 1.0, + Steps => 100); + begin + Run; + end Cubed; + +One_Over_X: + declare + function F (X : Scalar) return Scalar is + begin + return 1.0 / X; + end F; + procedure Run is new Test (F => F, + Name => "1/x", + From => 1.0, + To => 100.0, + Steps => 1_000); + begin + Run; + end One_Over_X; + +X: + declare + function F (X : Scalar) return Scalar is + begin + return X; + end F; + procedure Run_1 is new Test (F => F, + Name => "x", + From => 0.0, + To => 5_000.0, + Steps => 5_000_000); + procedure Run_2 is new Test (F => F, + Name => "x", + From => 0.0, + To => 6_000.0, + Steps => 6_000_000); + begin + Run_1; + Run_2; + end X; +end Numerical_Integration; diff --git a/Task/Numerical-integration/AutoHotkey/numerical-integration.ahk b/Task/Numerical-integration/AutoHotkey/numerical-integration.ahk new file mode 100644 index 0000000000..753fc26710 --- /dev/null +++ b/Task/Numerical-integration/AutoHotkey/numerical-integration.ahk @@ -0,0 +1,35 @@ +MsgBox % Rect("fun", 0, 1, 10,-1) ; 0.45 left +MsgBox % Rect("fun", 0, 1, 10) ; 0.50 mid +MsgBox % Rect("fun", 0, 1, 10, 1) ; 0.55 right +MsgBox % Trapez("fun", 0, 1, 10) ; 0.50 +MsgBox % Simpson("fun", 0, 1, 10) ; 0.50 + +Rect(f,a,b,n,side=0) { ; side: -1=left, 0=midpoint, 1=right + h := (b - a) / n + sum := 0, a += (side-1)*h/2 + Loop %n% + sum += %f%(a + h*A_Index) + Return h*sum +} + +Trapez(f,a,b,n) { + h := (b - a) / n + sum := 0 + Loop % n-1 + sum += %f%(a + h*A_Index) + Return h/2 * (%f%(a) + %f%(b) + 2*sum) +} + +Simpson(f,a,b,n) { + h := (b - a) / n + sum1 := sum2 := 0, ah := a - h/2 + Loop %n% + sum1 += %f%(ah + h*A_Index) + Loop % n-1 + sum2 += %f%(a + h*A_Index) + Return h/6 * (%f%(a) + %f%(b) + 4*sum1 + 2*sum2) +} + +fun(x) { ; linear test function + Return x +} diff --git a/Task/Numerical-integration/BASIC/numerical-integration.basic b/Task/Numerical-integration/BASIC/numerical-integration.basic new file mode 100644 index 0000000000..0d4f493b97 --- /dev/null +++ b/Task/Numerical-integration/BASIC/numerical-integration.basic @@ -0,0 +1,51 @@ +FUNCTION leftRect(a, b, n) + h = (b - a) / n + sum = 0 + FOR x = a TO b - h STEP h + sum = sum + h * (f(x)) + NEXT x + leftRect = sum +END FUNCTION + +FUNCTION rightRect(a, b, n) + h = (b - a) / n + sum = 0 + FOR x = a + h TO b STEP h + sum = sum + h * (f(x)) + NEXT x + rightRect = sum +END FUNCTION + +FUNCTION midRect(a, b, n) + h = (b - a) / n + sum = 0 + FOR x = a TO b - h STEP h + sum = sum + (h / 2) * (f(x) + f(x + h)) + NEXT x + midRect = sum +END FUNCTION + +FUNCTION trap(a, b, n) + h = (b - a) / n + sum = f(a) + f(b) + FOR i = 1 TO n-1 + sum = sum + 2 * f((a + i * h)) + NEXT i + trap = h / 2 * sum +END FUNCTION + +FUNCTION simpson(a, b, n) + h = (b - a) / n + sum1 = 0 + sum2 = 0 + + FOR i = 0 TO n-1 + sum1 = sum + f(a + h * i + h / 2) + NEXT i + + FOR i = 1 TO n - 1 + sum2 = sum2 + f(a + h * i) + NEXT i + + simpson = h / 6 * (f(a) + f(b) + 4 * sum1 + 2 * sum2) +END FUNCTION diff --git a/Task/Numerical-integration/BBC-BASIC/numerical-integration.bbc b/Task/Numerical-integration/BBC-BASIC/numerical-integration.bbc new file mode 100644 index 0000000000..4f4accd507 --- /dev/null +++ b/Task/Numerical-integration/BBC-BASIC/numerical-integration.bbc @@ -0,0 +1,71 @@ + *FLOAT64 + @% = 12 : REM Column width + + PRINT "Function Range L-Rect R-Rect M-Rect Trapeze Simpson" + FOR func% = 1 TO 4 + READ x$, l, h, s% + PRINT x$, ; l " - " ; h, FNlrect(x$, l, h, s%) FNrrect(x$, l, h, s%) ; + PRINT FNmrect(x$, l, h, s%) FNtrapeze(x$, l, h, s%) FNsimpson(x$, l, h, s%) + NEXT + END + + DATA "x^3", 0, 1, 100 + DATA "1/x", 1, 100, 1000 + DATA "x", 0, 5000, 5000000 + DATA "x", 0, 6000, 6000000 + + DEF FNlrect(x$, a, b, n%) + LOCAL i%, d, s, x + d = (b - a) / n% + x = a + FOR i% = 1 TO n% + s += d * EVAL(x$) + x += d + NEXT + = s + + DEF FNrrect(x$, a, b, n%) + LOCAL i%, d, s, x + d = (b - a) / n% + x = a + FOR i% = 1 TO n% + x += d + s += d * EVAL(x$) + NEXT + = s + + DEF FNmrect(x$, a, b, n%) + LOCAL i%, d, s, x + d = (b - a) / n% + x = a + FOR i% = 1 TO n% + x += d/2 + s += d * EVAL(x$) + x += d/2 + NEXT + = s + + DEF FNtrapeze(x$, a, b, n%) + LOCAL i%, d, f, s, x + d = (b - a) / n% + x = b : f = EVAL(x$) + x = a : s = d * (f + EVAL(x$)) / 2 + FOR i% = 1 TO n%-1 + x += d + s += d * EVAL(x$) + NEXT + = s + + DEF FNsimpson(x$, a, b, n%) + LOCAL i%, d, f, s1, s2, x + d = (b - a) / n% + x = b : f = EVAL(x$) + x = a + d/2 : s1 = EVAL(x$) + FOR i% = 1 TO n%-1 + x += d/2 + s2 += EVAL(x$) + x += d/2 + s1 += EVAL(x$) + NEXT + x = a + = (d / 6) * (f + EVAL(x$) + 4 * s1 + 2 * s2) diff --git a/Task/Numerical-integration/C++/numerical-integration.cpp b/Task/Numerical-integration/C++/numerical-integration.cpp new file mode 100644 index 0000000000..e85b45b4bf --- /dev/null +++ b/Task/Numerical-integration/C++/numerical-integration.cpp @@ -0,0 +1,63 @@ +// the integration routine +template + double integrate(F f, Float a, Float b, int steps, Method m) +{ + double s = 0; + double h = (b-a)/steps; + for (int i = 0; i < steps; ++i) + s += m(f, a + h*i, h); + return h*s; +} + +// methods +class rectangular +{ +public: + enum position_type { left, middle, right }; + rectangular(position_type pos): position(pos) {} + template + double operator()(F f, Float x, Float h) const + { + switch(position) + { + case left: + return f(x); + case middle: + return f(x+h/2); + case right: + return f(x+h); + } + } +private: + const position_type position; +}; + +class trapezium +{ +public: + template + double operator()(F f, Float x, Float h) const + { + return (f(x) + f(x+h))/2; + } +}; + +class simpson +{ +public: + template + double operator()(F f, Float x, Float h) const + { + return (f(x) + 4*f(x+h/2) + f(x+h))/6; + } +}; + +// sample usage +double f(double x) { return x*x; ) + +// inside a function somewhere: +double rl = integrate(f, 0.0, 1.0, 10, rectangular(rectangular::left)); +double rm = integrate(f, 0.0, 1.0, 10, rectangular(rectangular::middle)); +double rr = integrate(f, 0.0, 1.0, 10, rectangular(rectangular::right)); +double t = integrate(f, 0.0, 1.0, 10, trapezium()); +double s = integrate(f, 0.0, 1.0, 10, simpson()); diff --git a/Task/Numerical-integration/C/numerical-integration-1.c b/Task/Numerical-integration/C/numerical-integration-1.c new file mode 100644 index 0000000000..0fbde61fde --- /dev/null +++ b/Task/Numerical-integration/C/numerical-integration-1.c @@ -0,0 +1,58 @@ +#include +#include +#include + +double int_leftrect(double from, double to, double n, double (*func)()) +{ + double h = (to-from)/n; + double sum = 0.0, x; + for(x=from; x <= (to-h); x += h) + sum += func(x); + return h*sum; +} + +double int_rightrect(double from, double to, double n, double (*func)()) +{ + double h = (to-from)/n; + double sum = 0.0, x; + for(x=from; x <= (to-h); x += h) + sum += func(x+h); + return h*sum; +} + +double int_midrect(double from, double to, double n, double (*func)()) +{ + double h = (to-from)/n; + double sum = 0.0, x; + for(x=from; x <= (to-h); x += h) + sum += func(x+h/2.0); + return h*sum; +} + +double int_trapezium(double from, double to, double n, double (*func)()) +{ + double h = (to - from) / n; + double sum = func(from) + func(to); + int i; + for(i = 1;i < n;i++) + sum += 2.0*func(from + i * h); + return h * sum / 2.0; +} + +double int_simpson(double from, double to, double n, double (*func)()) +{ + double h = (to - from) / n; + double sum1 = 0.0; + double sum2 = 0.0; + int i; + + double x; + + for(i = 0;i < n;i++) + sum1 += func(from + h * i + h / 2.0); + + for(i = 1;i < n;i++) + sum2 += func(from + h * i); + + return h / 6.0 * (func(from) + func(to) + 4.0 * sum1 + 2.0 * sum2); +} diff --git a/Task/Numerical-integration/C/numerical-integration-2.c b/Task/Numerical-integration/C/numerical-integration-2.c new file mode 100644 index 0000000000..87be8263bb --- /dev/null +++ b/Task/Numerical-integration/C/numerical-integration-2.c @@ -0,0 +1,71 @@ +/* test */ +double f3(double x) +{ + return x; +} + +double f3a(double x) +{ + return x*x/2.0; +} + +double f2(double x) +{ + return 1.0/x; +} + +double f2a(double x) +{ + return log(x); +} + +double f1(double x) +{ + return x*x*x; +} + +double f1a(double x) +{ + return x*x*x*x/4.0; +} + +typedef double (*pfunc)(double, double, double, double (*)()); +typedef double (*rfunc)(double); + +#define INTG(F,A,B) (F((B))-F((A))) + +int main() +{ + int i, j; + double ic; + + pfunc f[5] = { + int_leftrect, int_rightrect, + int_midrect, int_trapezium, + int_simpson + }; + const char *names[5] = { + "leftrect", "rightrect", "midrect", + "trapezium", "simpson" + }; + rfunc rf[] = { f1, f2, f3, f3 }; + rfunc If[] = { f1a, f2a, f3a, f3a }; + double ivals[] = { + 0.0, 1.0, + 1.0, 100.0, + 0.0, 5000.0, + 0.0, 6000.0 + }; + double approx[] = { 100.0, 1000.0, 5000000.0, 6000000.0 }; + + for(j=0; j < (sizeof(rf) / sizeof(rfunc)); j++) + { + for(i=0; i < 5 ; i++) + { + ic = (*f[i])(ivals[2*j], ivals[2*j+1], approx[j], rf[j]); + printf("%10s [ 0,1] num: %+lf, an: %lf\n", + names[i], ic, INTG((*If[j]), ivals[2*j], ivals[2*j+1])); + } + printf("\n"); + } +} diff --git a/Task/Numerical-integration/CoffeeScript/numerical-integration-1.coffeescript b/Task/Numerical-integration/CoffeeScript/numerical-integration-1.coffeescript new file mode 100644 index 0000000000..3005dbee65 --- /dev/null +++ b/Task/Numerical-integration/CoffeeScript/numerical-integration-1.coffeescript @@ -0,0 +1,33 @@ +rules = + left_rect: (f, x, h) -> f(x) + mid_rect: (f, x, h) -> f(x+h/2) + right_rect: (f, x, h) -> f(x+h) + trapezium: (f, x, h) -> (f(x) + f(x+h)) / 2 + simpson: (f, x, h) -> (f(x) + 4 * f(x + h/2) + f(x+h)) / 6 + +functions = + cube: (x) -> x*x*x + reciprocal: (x) -> 1/x + identity: (x) -> x + +sum = (list) -> list.reduce ((a, b) -> a+b), 0 + +integrate = (f, a, b, steps, meth) -> + h = (b-a) / steps + h * sum(meth(f, a+i*h, h) for i in [0...steps]) + +# Tests +tests = [ + [0, 1, 100, 'cube'] + [1, 100, 1000, 'reciprocal'] + [0, 5000, 5000000, 'identity'] + [0, 6000, 6000000, 'identity'] +] + +for test in tests + [a, b, steps, func_name] = test + func = functions[func_name] + console.log "-- tests for #{func_name} with #{steps} steps from #{a} to #{b}" + for rule_name, rule of rules + result = integrate func, a, b, steps, rule + console.log rule_name, result diff --git a/Task/Numerical-integration/CoffeeScript/numerical-integration-2.coffeescript b/Task/Numerical-integration/CoffeeScript/numerical-integration-2.coffeescript new file mode 100644 index 0000000000..1fec5c3356 --- /dev/null +++ b/Task/Numerical-integration/CoffeeScript/numerical-integration-2.coffeescript @@ -0,0 +1,25 @@ +> coffee numerical_integration.coffee +-- tests for cube with 100 steps from 0 to 1 +left_rect 0.24502500000000005 +mid_rect 0.24998750000000006 +right_rect 0.25502500000000006 +trapezium 0.250025 +simpson 0.25 +-- tests for reciprocal with 1000 steps from 1 to 100 +left_rect 4.65499105751468 +mid_rect 4.604762548678376 +right_rect 4.55698105751468 +trapezium 4.605986057514676 +simpson 4.605170384957133 +-- tests for identity with 5000000 steps from 0 to 5000 +left_rect 12499997.5 +mid_rect 12500000 +right_rect 12500002.5 +trapezium 12500000 +simpson 12500000 +-- tests for identity with 6000000 steps from 0 to 6000 +left_rect 17999997.000000004 +mid_rect 17999999.999999993 +right_rect 18000003.000000004 +trapezium 17999999.999999993 +simpson 17999999.999999993 diff --git a/Task/Numerical-integration/Common-Lisp/numerical-integration.lisp b/Task/Numerical-integration/Common-Lisp/numerical-integration.lisp new file mode 100644 index 0000000000..497f934080 --- /dev/null +++ b/Task/Numerical-integration/Common-Lisp/numerical-integration.lisp @@ -0,0 +1,27 @@ +(defun left-rectangle (f a b n &aux (d (/ (- b a) n))) + (* d (loop for x from a below b by d summing (funcall f x)))) + +(defun right-rectangle (f a b n &aux (d (/ (- b a) n))) + (* d (loop for x from b above a by d summing (funcall f x)))) + +(defun midpoint-rectangle (f a b n &aux (d (/ (- b a) n))) + (* d (loop for x from (+ a (/ d 2)) below b by d summing (funcall f x)))) + +(defun trapezium (f a b n &aux (d (/ (- b a) n))) + (* (/ d 2) + (+ (funcall f a) + (* 2 (loop for x from (+ a d) below b by d summing (funcall f x))) + (funcall f b)))) + +(defun simpson (f a b n) + (loop with h = (/ (- b a) n) + with sum1 = (funcall f (+ a (/ h 2))) + with sum2 = 0 + for i from 1 below n + do (incf sum1 (funcall f (+ a (* h i) (/ h 2)))) + do (incf sum2 (funcall f (+ a (* h i)))) + finally (return (* (/ h 6) + (+ (funcall f a) + (funcall f b) + (* 4 sum1) + (* 2 sum2)))))) diff --git a/Task/Numerical-integration/D/numerical-integration-1.d b/Task/Numerical-integration/D/numerical-integration-1.d new file mode 100644 index 0000000000..1f3f1ddaa0 --- /dev/null +++ b/Task/Numerical-integration/D/numerical-integration-1.d @@ -0,0 +1,63 @@ +import std.stdio, std.typecons, std.typetuple; + +template integrate(alias method) { + double integrate(F, Float)(in F f, in Float a, + in Float b, in int steps) { + double s = 0.0; + immutable double h = (b - a) / steps; + foreach (i; 0 .. steps) + s += method(f, a + h * i, h); + return h * s; + } +} + +double rectangularLeft(F, Float)(in F f, in Float x, in Float h) +pure nothrow { + return f(x); +} + +double rectangularMiddle(F, Float)(in F f, in Float x, in Float h) +pure nothrow { + return f(x + h / 2); +} + +double rectangularRight(F, Float)(in F f, in Float x, in Float h) +pure nothrow { + return f(x + h); +} + +double trapezium(F, Float)(in F f, in Float x, in Float h) +pure nothrow { + return (f(x) + f(x + h)) / 2; +} + +double simpson(F, Float)(in F f, in Float x, in Float h) +pure nothrow { + return (f(x) + 4 * f(x + h / 2) + f(x + h)) / 6; +} + +void main() { + immutable args = [ + tuple((double x) => x ^^ 3, 0.0, 1.0, 10), + tuple((double x) => 1 / x, 1.0, 100.0, 1000), + tuple((double x) => x, 0.0, 5_000.0, 5_000_000), + tuple((double x) => x, 0.0, 6_000.0, 6_000_000)]; + + alias TypeTuple!(integrate!rectangularLeft, + integrate!rectangularMiddle, + integrate!rectangularRight, + integrate!trapezium, + integrate!simpson) ints; + + alias TypeTuple!("rectangular left: ", + "rectangular middle: ", + "rectangular right: ", + "trapezium: ", + "simpson: ") names; + + foreach (a; args) { + foreach (i, n; names) + writefln("%s %f", n, ints[i](a.tupleof)); + writeln(); + } +} diff --git a/Task/Numerical-integration/D/numerical-integration-2.d b/Task/Numerical-integration/D/numerical-integration-2.d new file mode 100644 index 0000000000..4e0897b3dd --- /dev/null +++ b/Task/Numerical-integration/D/numerical-integration-2.d @@ -0,0 +1,71 @@ +import std.stdio, std.typecons, std.typetuple; + +template integrate(alias method) { + template integrate(alias f) { + double integrate(Float)(in Float a, in Float b, + in int steps) pure nothrow { + Float s = 0.0; + immutable Float h = (b - a) / steps; + foreach (i; 0 .. steps) + s += method!(f, Float)(a + h * i, h); + return h * s; + } + } +} + +double rectangularLeft(alias f, Float)(in Float x, in Float h) +pure nothrow { + return f(x); +} + +double rectangularMiddle(alias f, Float)(in Float x, in Float h) +pure nothrow { + return f(x + h / 2); +} + +double rectangularRight(alias f, Float)(in Float x, in Float h) +pure nothrow { + return f(x + h); +} + +double trapezium(alias f, Float)(in Float x, in Float h) +pure nothrow { + return (f(x) + f(x + h)) / 2; +} + +double simpson(alias f, Float)(in Float x, in Float h) +pure nothrow { + return (f(x) + 4 * f(x + h / 2) + f(x + h)) / 6; +} + +void main() { + static double f1(in double x) pure nothrow { return x ^^ 3; } + static double f2(in double x) pure nothrow { return 1 / x; } + static double f3(in double x) pure nothrow { return x; } + alias TypeTuple!(f1, f2, f3, f3) funcs; + + alias TypeTuple!("rectangular left: ", + "rectangular middle: ", + "rectangular right: ", + "trapezium: ", + "simpson: ") names; + + alias TypeTuple!(integrate!rectangularLeft, + integrate!rectangularMiddle, + integrate!rectangularRight, + integrate!trapezium, + integrate!simpson) ints; + + immutable args = [tuple(0.0, 1.0, 10), + tuple(1.0, 100.0, 1_000), + tuple(0.0, 5_000.0, 5_000_000), + tuple(0.0, 6_000.0, 6_000_000)]; + + foreach (i, f; funcs) { + foreach (j, n; names) { + alias ints[j] integ; + writefln("%s %f", n, integ!f(args[i].tupleof)); + } + writeln(); + } +} diff --git a/Task/Numerical-integration/E/numerical-integration-1.e b/Task/Numerical-integration/E/numerical-integration-1.e new file mode 100644 index 0000000000..9dfb013dc6 --- /dev/null +++ b/Task/Numerical-integration/E/numerical-integration-1.e @@ -0,0 +1,26 @@ +pragma.enable("accumulator") + +def leftRect(f, x, h) { + return f(x) +} + +def midRect(f, x, h) { + return f(x + h/2) +} + +def rightRect(f, x, h) { + return f(x + h) +} + +def trapezium(f, x, h) { + return (f(x) + f(x+h)) / 2 +} + +def simpson(f, x, h) { + return (f(x) + 4 * f(x + h / 2) + f(x+h)) / 6 +} + +def integrate(f, a, b, steps, meth) { + def h := (b-a) / steps + return h * accum 0 for i in 0..!steps { _ + meth(f, a+i*h, h) } +} diff --git a/Task/Numerical-integration/E/numerical-integration-2.e b/Task/Numerical-integration/E/numerical-integration-2.e new file mode 100644 index 0000000000..2924744a8c --- /dev/null +++ b/Task/Numerical-integration/E/numerical-integration-2.e @@ -0,0 +1,5 @@ +? integrate(fn x { x ** 2 }, 3.0, 7.0, 30, simpson) +# value: 105.33333333333334 + +? integrate(fn x { x ** 9 }, 0, 1, 300, simpson) +# value: 0.10000000002160479 diff --git a/Task/Numerical-integration/Euphoria/numerical-integration.euphoria b/Task/Numerical-integration/Euphoria/numerical-integration.euphoria new file mode 100644 index 0000000000..4133e1b9eb --- /dev/null +++ b/Task/Numerical-integration/Euphoria/numerical-integration.euphoria @@ -0,0 +1,79 @@ +function int_leftrect(sequence bounds, integer n, integer func_id) + atom h, sum + h = (bounds[2]-bounds[1])/n + sum = 0 + for x = bounds[1] to bounds[2]-h by h do + sum += call_func(func_id, {x}) + end for + return h*sum +end function + +function int_rightrect(sequence bounds, integer n, integer func_id) + atom h, sum + h = (bounds[2]-bounds[1])/n + sum = 0 + for x = bounds[1] to bounds[2]-h by h do + sum += call_func(func_id, {x+h}) + end for + return h*sum +end function + +function int_midrect(sequence bounds, integer n, integer func_id) + atom h, sum + h = (bounds[2]-bounds[1])/n + sum = 0 + for x = bounds[1] to bounds[2]-h by h do + sum += call_func(func_id, {x+h/2}) + end for + return h*sum +end function + +function int_trapezium(sequence bounds, integer n, integer func_id) + atom h, sum + h = (bounds[2]-bounds[1])/n + sum = call_func(func_id, {bounds[1]}) + call_func(func_id, {bounds[2]}) + for x = bounds[1] to bounds[2]-h by h do + sum += 2*call_func(func_id, {x}) + end for + return h * sum / 2 +end function + +function int_simpson(sequence bounds, integer n, integer func_id) + atom h, sum1, sum2 + h = (bounds[2]-bounds[1])/n + sum1 = call_func(func_id, {bounds[1] + h/2}) + sum2 = 0 + for i = 1 to n-1 do + sum1 += call_func(func_id, {bounds[1] + h * i + h / 2}) + sum2 += call_func(func_id, {bounds[1] + h * i}) + end for + return h/6 * (call_func(func_id, {bounds[1]}) + + call_func(func_id, {bounds[2]}) + 4*sum1 + 2*sum2) +end function + +function xp2d2(atom x) + return x*x/2 +end function + +function logx(atom x) + return log(x) +end function + +function x(atom x) + return x +end function + +? int_leftrect({-1,1},1000,routine_id("xp2d2")) +? int_rightrect({-1,1},1000,routine_id("xp2d2")) +? int_midrect({-1,1},1000,routine_id("xp2d2")) +? int_simpson({-1,1},1000,routine_id("xp2d2")) +puts(1,'\n') +? int_leftrect({1,2},1000,routine_id("logx")) +? int_rightrect({1,2},1000,routine_id("logx")) +? int_midrect({1,2},1000,routine_id("logx")) +? int_simpson({1,2},1000,routine_id("logx")) +puts(1,'\n') +? int_leftrect({0,10},1000,routine_id("x")) +? int_rightrect({0,10},1000,routine_id("x")) +? int_midrect({0,10},1000,routine_id("x")) +? int_simpson({0,10},1000,routine_id("x")) diff --git a/Task/Numerical-integration/Forth/numerical-integration.fth b/Task/Numerical-integration/Forth/numerical-integration.fth new file mode 100644 index 0000000000..562f920ca1 --- /dev/null +++ b/Task/Numerical-integration/Forth/numerical-integration.fth @@ -0,0 +1,40 @@ +fvariable step + +defer method ( fn F: x -- fn[x] ) + +: left execute ; +: right step f@ f+ execute ; +: mid step f@ 2e f/ f+ execute ; +: trap + dup fdup left + fswap right f+ 2e f/ ; +: simpson + dup fdup left + dup fover mid 4e f* f+ + fswap right f+ 6e f/ ; + +: set-step ( n F: a b -- n F: a ) + fover f- dup 0 d>f f/ step f! ; + +: integrate ( xt n F: a b -- F: sigma ) + set-step + 0e + 0 do + dup fover method f+ + fswap step f@ f+ fswap + loop + drop fnip + step f@ f* ; + \ testing similar to the D example +: test + ' is method ' 4 -1e 2e integrate f. ; + +: fn1 fsincos f+ ; +: fn2 fdup f* 4e f* 1e f+ 2e fswap f/ ; + +7 set-precision +test left fn2 \ 2.456897 +test right fn2 \ 2.245132 +test mid fn2 \ 2.496091 +test trap fn2 \ 2.351014 +test simpson fn2 \ 2.447732 diff --git a/Task/Numerical-integration/Fortran/numerical-integration-1.f b/Task/Numerical-integration/Fortran/numerical-integration-1.f new file mode 100644 index 0000000000..330fe535f4 --- /dev/null +++ b/Task/Numerical-integration/Fortran/numerical-integration-1.f @@ -0,0 +1,4 @@ +elemental function elemf(x) + real :: elemf, x + elemf = f(x) +end function elemf diff --git a/Task/Numerical-integration/Fortran/numerical-integration-2.f b/Task/Numerical-integration/Fortran/numerical-integration-2.f new file mode 100644 index 0000000000..73fbde1c9c --- /dev/null +++ b/Task/Numerical-integration/Fortran/numerical-integration-2.f @@ -0,0 +1,75 @@ +module Integration + implicit none + +contains + + ! function, lower limit, upper limit, steps, method + function integrate(f, a, b, in, method) + real :: integrate + real, intent(in) :: a, b + integer, optional, intent(in) :: in + character(len=*), intent(in), optional :: method + interface + elemental function f(ra) + real :: f + real, intent(in) :: ra + end function f + end interface + + integer :: n, i, m + real :: h + real, dimension(:), allocatable :: xpoints + real, dimension(:), target, allocatable :: fpoints + real, dimension(:), pointer :: fleft, fmid, fright + + if ( present(in) ) then + n = in + else + n = 20 + end if + + if ( present(method) ) then + select case (method) + case ('leftrect') + m = 1 + case ('midrect') + m = 2 + case ('rightrect') + m = 3 + case ( 'trapezoid' ) + m = 4 + case default + m = 0 + end select + else + m = 0 + end if + + h = (b - a) / n + + allocate(xpoints(0:2*n), fpoints(0:2*n)) + + xpoints = (/ (a + h*i/2, i = 0,2*n) /) + + fpoints = f(xpoints) + fleft => fpoints(0 : 2*n-2 : 2) + fmid => fpoints(1 : 2*n-1 : 2) + fright => fpoints(2 : 2*n : 2) + + select case (m) + case (0) ! simpson + integrate = h / 6.0 * sum(fleft + fright + 4.0*fmid) + case (1) ! leftrect + integrate = h * sum(fleft) + case (2) ! midrect + integrate = h * sum(fmid) + case (3) ! rightrect + integrate = h * sum(fright) + case (4) ! trapezoid + integrate = h * sum(fleft + fright) / 2 + end select + + deallocate(xpoints, fpoints) + end function integrate + +end module Integration diff --git a/Task/Numerical-integration/Fortran/numerical-integration-3.f b/Task/Numerical-integration/Fortran/numerical-integration-3.f new file mode 100644 index 0000000000..2a33cda1e3 --- /dev/null +++ b/Task/Numerical-integration/Fortran/numerical-integration-3.f @@ -0,0 +1,12 @@ +program IntegrationTest + use Integration + use FunctionHolder + implicit none + + print *, integrate(afun, 0., 3**(1/3.), method='simpson') + print *, integrate(afun, 0., 3**(1/3.), method='leftrect') + print *, integrate(afun, 0., 3**(1/3.), method='midrect') + print *, integrate(afun, 0., 3**(1/3.), method='rightrect') + print *, integrate(afun, 0., 3**(1/3.), method='trapezoid') + +end program IntegrationTest diff --git a/Task/Numerical-integration/Fortran/numerical-integration-4.f b/Task/Numerical-integration/Fortran/numerical-integration-4.f new file mode 100644 index 0000000000..8e30a5903c --- /dev/null +++ b/Task/Numerical-integration/Fortran/numerical-integration-4.f @@ -0,0 +1,13 @@ +module FunctionHolder + implicit none + +contains + + pure function afun(x) + real :: afun + real, intent(in) :: x + + afun = x**2 + end function afun + +end module FunctionHolder diff --git a/Task/Numerical-integration/Go/numerical-integration.go b/Task/Numerical-integration/Go/numerical-integration.go new file mode 100644 index 0000000000..b0b8b7b1c3 --- /dev/null +++ b/Task/Numerical-integration/Go/numerical-integration.go @@ -0,0 +1,172 @@ +package main + +import ( + "fmt" + "math" +) + +// specification for an integration +type spec struct { + lower, upper float64 // bounds for integration + n int // number of parts + exact float64 // expected answer + fs string // mathematical description of function + f func(float64) float64 // function to integrate +} + +// test cases per task description +var data = []spec{ + spec{0, 1, 100, .25, "x^3", func(x float64) float64 { return x * x * x }}, + spec{1, 100, 1000, float64(math.Log(100)), "1/x", + func(x float64) float64 { return 1 / x }}, + spec{0, 5000, 5e5, 12.5e6, "x", func(x float64) float64 { return x }}, + spec{0, 6000, 6e6, 18e6, "x", func(x float64) float64 { return x }}, +} + +// object for associating a printable function name with an integration method +type method struct { + name string + integrate func(spec) float64 +} + +// integration methods implemented per task description +var methods = []method{ + method{"Rectangular (left) ", rectLeft}, + method{"Rectangular (right) ", rectRight}, + method{"Rectangular (midpoint)", rectMid}, + method{"Trapezium ", trap}, + method{"Simpson's ", simpson}, +} + +func rectLeft(t spec) float64 { + parts := make([]float64, t.n) + r := t.upper - t.lower + nf := float64(t.n) + x0 := t.lower + for i := range parts { + x1 := t.lower + float64(i+1)*r/nf + // x1-x0 better than r/nf. + // (with r/nf, the represenation error accumulates) + parts[i] = t.f(x0) * (x1 - x0) + x0 = x1 + } + return sum(parts) +} + +func rectRight(t spec) float64 { + parts := make([]float64, t.n) + r := t.upper - t.lower + nf := float64(t.n) + x0 := t.lower + for i := range parts { + x1 := t.lower + float64(i+1)*r/nf + parts[i] = t.f(x1) * (x1 - x0) + x0 = x1 + } + return sum(parts) +} + +func rectMid(t spec) float64 { + parts := make([]float64, t.n) + r := t.upper - t.lower + nf := float64(t.n) + // there's a tiny gloss in the x1-x0 trick here. the correct way + // would be to compute x's at division boundaries, but we don't need + // those x's for anything else. (the function is evaluated on x's + // at division midpoints rather than division boundaries.) so, we + // reuse the midpoint x's, knowing that they will average out just + // as well. we just need one extra point, so we use lower-.5. + x0 := t.lower - .5*r/nf + for i := range parts { + x1 := t.lower + (float64(i)+.5)*r/nf + parts[i] = t.f(x1) * (x1 - x0) + x0 = x1 + } + return sum(parts) +} + +func trap(t spec) float64 { + parts := make([]float64, t.n) + r := t.upper - t.lower + nf := float64(t.n) + x0 := t.lower + f0 := t.f(x0) + for i := range parts { + x1 := t.lower + float64(i+1)*r/nf + f1 := t.f(x1) + parts[i] = (f0 + f1) * .5 * (x1 - x0) + x0, f0 = x1, f1 + } + return sum(parts) +} + +func simpson(t spec) float64 { + parts := make([]float64, 2*t.n+1) + r := t.upper - t.lower + nf := float64(t.n) + // similar to the rectangle midpoint logic explained above, + // we play a little loose with the values used for dx and dx0. + dx0 := r / nf + parts[0] = t.f(t.lower) * dx0 + parts[1] = t.f(t.lower+dx0*.5) * dx0 * 4 + x0 := t.lower + dx0 + for i := 1; i < t.n; i++ { + x1 := t.lower + float64(i+1)*r/nf + xmid := (x0 + x1) * .5 + dx := x1 - x0 + parts[2*i] = t.f(x0) * dx * 2 + parts[2*i+1] = t.f(xmid) * dx * 4 + x0 = x1 + } + parts[2*t.n] = t.f(t.upper) * dx0 + return sum(parts) / 6 +} + +// sum a list of numbers avoiding loss of precision +func sum(v []float64) float64 { + if len(v) == 0 { + return 0 + } + var parts []float64 + for _, x := range v { + var i int + for _, p := range parts { + sum := p + x + var err float64 + if math.Abs(x) < math.Abs(p) { + err = x - (sum - p) + } else { + err = p - (sum - x) + } + if err != 0 { + parts[i] = err + i++ + } + x = sum + } + parts = append(parts[:i], x) + } + var sum float64 + for _, x := range parts { + sum += x + } + return sum +} + +func main() { + for _, t := range data { + fmt.Println("Test case: f(x) =", t.fs) + fmt.Println("Integration from", t.lower, "to", t.upper, + "in", t.n, "parts") + fmt.Printf("Exact result %.7e Error\n", t.exact) + for _, m := range methods { + a := m.integrate(t) + e := a - t.exact + if e < 0 { + e = -e + } + fmt.Printf("%s %.7e %.7e\n", m.name, a, e) + } + fmt.Println("") + } +} diff --git a/Task/Numerical-integration/Groovy/numerical-integration-1.groovy b/Task/Numerical-integration/Groovy/numerical-integration-1.groovy new file mode 100644 index 0000000000..b75a009c48 --- /dev/null +++ b/Task/Numerical-integration/Groovy/numerical-integration-1.groovy @@ -0,0 +1,44 @@ +def assertBounds = { List bounds, int nRect -> + assert (bounds.size() == 2) && (bounds[0] instanceof Double) && (bounds[1] instanceof Double) && (nRect > 0) +} + +def integral = { List bounds, int nRectangles, Closure f, List pointGuide, Closure integralCalculator-> + double a = bounds[0], b = bounds[1], h = (b - a)/nRectangles + def xPoints = pointGuide.collect { double it -> a + it*h } + def fPoints = xPoints.collect { x -> f(x) } + integralCalculator(h, fPoints) +} + +def leftRectIntegral = { List bounds, int nRect, Closure f -> + assertBounds(bounds, nRect) + integral(bounds, nRect, f, (0.. h*fPoints.sum() } +} + +def rightRectIntegral = { List bounds, int nRect, Closure f -> + assertBounds(bounds, nRect) + integral(bounds, nRect, f, (1..nRect)) { h, fPoints -> h*fPoints.sum() } +} + +def midRectIntegral = { List bounds, int nRect, Closure f -> + assertBounds(bounds, nRect) + integral(bounds, nRect, f, ((0.5d)..nRect)) { h, fPoints -> h*fPoints.sum() } +} + +def trapezoidIntegral = { List bounds, int nRect, Closure f -> + assertBounds(bounds, nRect) + integral(bounds, nRect, f, (0..nRect)) { h, fPoints -> + def fLeft = fPoints[0.. + assertBounds(bounds, nSimpRect) + integral(bounds, nSimpRect*2, f, (0..(nSimpRect*2))) { h, fPoints -> + def fLeft = fPoints[(0.. a -> [a] -> (a -> a) -> a -> a -> Int -> a +integrateOpen v vs f a b n = approx f xs ws * h / v where + m = fromIntegral (length vs) * n + h = (b-a) / fromIntegral m + ws = concat $ replicate n vs + c = a + h/2 + xs = [c + h * fromIntegral i | i <- [0..m-1]] diff --git a/Task/Numerical-integration/Haskell/numerical-integration-3.hs b/Task/Numerical-integration/Haskell/numerical-integration-3.hs new file mode 100644 index 0000000000..dc52dc9552 --- /dev/null +++ b/Task/Numerical-integration/Haskell/numerical-integration-3.hs @@ -0,0 +1,14 @@ +integrateClosed :: Fractional a => a -> [a] -> (a -> a) -> a -> a -> Int -> a +integrateClosed v vs f a b n = approx f xs ws * h / v where + m = fromIntegral (length vs - 1) * n + h = (b-a) / fromIntegral m + ws = overlap n vs + xs = [a + h * fromIntegral i | i <- [0..m]] + +overlap :: Num a => Int -> [a] -> [a] +overlap n [] = [] +overlap n (x:xs) = x : inter n xs where + inter 1 ys = ys + inter n [] = x : inter (n-1) xs + inter n [y] = (x+y) : inter (n-1) xs + inter n (y:ys) = y : inter n ys diff --git a/Task/Numerical-integration/Haskell/numerical-integration-4.hs b/Task/Numerical-integration/Haskell/numerical-integration-4.hs new file mode 100644 index 0000000000..8425211da7 --- /dev/null +++ b/Task/Numerical-integration/Haskell/numerical-integration-4.hs @@ -0,0 +1,5 @@ +intLeftRect = integrateClosed 1 [1,0] +intRightRect = integrateClosed 1 [0,1] +intMidRect = integrateOpen 1 [1] +intTrapezium = integrateClosed 2 [1,1] +intSimpson = integrateClosed 3 [1,4,1] diff --git a/Task/Numerical-integration/Haskell/numerical-integration-5.hs b/Task/Numerical-integration/Haskell/numerical-integration-5.hs new file mode 100644 index 0000000000..abefcf7e47 --- /dev/null +++ b/Task/Numerical-integration/Haskell/numerical-integration-5.hs @@ -0,0 +1,3 @@ +intMilne = integrateClosed 45 [14,64,24,64,14] +intOpen1 = integrateOpen 2 [3,3] +intOpen2 = integrateOpen 3 [8,-4,8] diff --git a/Task/Numerical-integration/Haskell/numerical-integration-6.hs b/Task/Numerical-integration/Haskell/numerical-integration-6.hs new file mode 100644 index 0000000000..c5e5fe2b77 --- /dev/null +++ b/Task/Numerical-integration/Haskell/numerical-integration-6.hs @@ -0,0 +1,70 @@ +approx f xs ws = sum [w * f x | (x,w) <- zip xs ws] + +integrateOpen :: Fractional a => a -> [a] -> (a -> a) -> a -> a -> Int -> a +integrateOpen v vs f a b n = approx f xs ws * h / v where + m = fromIntegral (length vs) * n + h = (b-a) / fromIntegral m + ws = concat $ replicate n vs + c = a + h/2 + xs = [c + h * fromIntegral i | i <- [0..m-1]] + +integrateClosed :: Fractional a => a -> [a] -> (a -> a) -> a -> a -> Int -> a +integrateClosed v vs f a b n = approx f xs ws * h / v where + m = fromIntegral (length vs - 1) * n + h = (b-a) / fromIntegral m + ws = overlap n vs + xs = [a + h * fromIntegral i | i <- [0..m]] + +overlap :: Num a => Int -> [a] -> [a] +overlap n [] = [] +overlap n (x:xs) = x : inter n xs where + inter 1 ys = ys + inter n [] = x : inter (n-1) xs + inter n [y] = (x+y) : inter (n-1) xs + inter n (y:ys) = y : inter n ys + +intLeftRect = integrateClosed 1 [1,0] +intMidRect = integrateOpen 1 [1] +intRightRect = integrateClosed 1 [0,1] +intTrapezium = integrateClosed 2 [1,1] +intSimpson = integrateClosed 3 [1,4,1] + +uncurry4 f ~(a, b, c, d) = f a b c d + +main = do + let m1 = "rectangular left: " + let m2 = "rectangular middle: " + let m3 = "rectangular right: " + let m4 = "trapezium: " + let m5 = "simpson: " + + let arg1 = ((\x -> x ^ 3), 0, 1, 100) + putStrLn $ m1 ++ (show $ uncurry4 intLeftRect arg1) + putStrLn $ m2 ++ (show $ uncurry4 intMidRect arg1) + putStrLn $ m3 ++ (show $ uncurry4 intRightRect arg1) + putStrLn $ m4 ++ (show $ uncurry4 intTrapezium arg1) + putStrLn $ m5 ++ (show $ uncurry4 intSimpson arg1) + putStrLn "" + + let arg2 = ((\x -> 1 / x), 1, 100, 1000) + putStrLn $ m1 ++ (show $ uncurry4 intLeftRect arg2) + putStrLn $ m2 ++ (show $ uncurry4 intMidRect arg2) + putStrLn $ m3 ++ (show $ uncurry4 intRightRect arg2) + putStrLn $ m4 ++ (show $ uncurry4 intTrapezium arg2) + putStrLn $ m5 ++ (show $ uncurry4 intSimpson arg2) + putStrLn "" + + let arg3 = ((\x -> x), 0, 5000, 5000000) + putStrLn $ m1 ++ (show $ uncurry4 intLeftRect arg3) + putStrLn $ m2 ++ (show $ uncurry4 intMidRect arg3) + putStrLn $ m3 ++ (show $ uncurry4 intRightRect arg3) + putStrLn $ m4 ++ (show $ uncurry4 intTrapezium arg3) + putStrLn $ m5 ++ (show $ uncurry4 intSimpson arg3) + putStrLn "" + + let arg4 = ((\x -> x), 0, 6000, 6000000) + putStrLn $ m1 ++ (show $ uncurry4 intLeftRect arg4) + putStrLn $ m2 ++ (show $ uncurry4 intMidRect arg4) + putStrLn $ m3 ++ (show $ uncurry4 intRightRect arg4) + putStrLn $ m4 ++ (show $ uncurry4 intTrapezium arg4) + putStrLn $ m5 ++ (show $ uncurry4 intSimpson arg4) diff --git a/Task/Numerical-integration/J/numerical-integration-1.j b/Task/Numerical-integration/J/numerical-integration-1.j new file mode 100644 index 0000000000..b341f316d2 --- /dev/null +++ b/Task/Numerical-integration/J/numerical-integration-1.j @@ -0,0 +1,11 @@ +integrate=: adverb define + 'a b steps'=. 3{.y,128 + size=. (b - a)%steps + size * +/ u |: 2 ]\ a + size * i.>:steps +) + +rectangle=: adverb def 'u -: +/ y' + +trapezium=: adverb def '-: +/ u y' + +simpson =: adverb def '6 %~ +/ 1 1 4 * u y, -:+/y' diff --git a/Task/Numerical-integration/J/numerical-integration-2.j b/Task/Numerical-integration/J/numerical-integration-2.j new file mode 100644 index 0000000000..c300806102 --- /dev/null +++ b/Task/Numerical-integration/J/numerical-integration-2.j @@ -0,0 +1,28 @@ + Ir=: rectangle integrate + It=: trapezium integrate + Is=: simpson integrate + + ^&3 Ir 0 1 100 +0.249987 + ^&3 It 0 1 100 +0.250025 + ^&3 Is 0 1 100 +0.25 + % Ir 1 100 1000 +4.60476 + % It 1 100 1000 +4.60599 + % Is 1 100 1000 +4.60517 + ] Ir 0 5000 5e6 +1.25e7 + ] It 0 5000 5e6 +1.25e7 + ] Is 0 5000 5e6 +1.25e7 + ] Ir 0 6000 6e6 +1.8e7 + ] It 0 6000 6e6 +1.8e7 + ] Is 0 6000 6e6 +1.8e7 diff --git a/Task/Numerical-integration/J/numerical-integration-3.j b/Task/Numerical-integration/J/numerical-integration-3.j new file mode 100644 index 0000000000..e91cbe15b7 --- /dev/null +++ b/Task/Numerical-integration/J/numerical-integration-3.j @@ -0,0 +1,6 @@ + *: rectangle integrate 0 1p1 10 +10.3095869962 + *: trapezium integrate 0 1p1 10 +10.3871026879 + *: simpson integrate 0 1p1 10 +10.3354255601 diff --git a/Task/Numerical-integration/J/numerical-integration-4.j b/Task/Numerical-integration/J/numerical-integration-4.j new file mode 100644 index 0000000000..d6f2f8afa4 --- /dev/null +++ b/Task/Numerical-integration/J/numerical-integration-4.j @@ -0,0 +1,7 @@ + sin=: 1&o. + sin rectangle integrate 0 1p1 10 +2.00824840791 + sin trapezium integrate 0 1p1 10 +1.98352353751 + sin simpson integrate 0 1p1 10 +2.00000678444 diff --git a/Task/Numerical-integration/J/numerical-integration-5.j b/Task/Numerical-integration/J/numerical-integration-5.j new file mode 100644 index 0000000000..5c6f5924d9 --- /dev/null +++ b/Task/Numerical-integration/J/numerical-integration-5.j @@ -0,0 +1,4 @@ + 0 p.. 0 0 1 +0 0 0 0.333333333333 + 0 p.. 0 0 1x NB. or using rationals +0 0 0 1r3 diff --git a/Task/Numerical-integration/J/numerical-integration-6.j b/Task/Numerical-integration/J/numerical-integration-6.j new file mode 100644 index 0000000000..1e831845ca --- /dev/null +++ b/Task/Numerical-integration/J/numerical-integration-6.j @@ -0,0 +1,2 @@ + 0 0 1 (0&p..@[ -~/@:p. ]) 0 1p1 +10.3354255601 diff --git a/Task/Numerical-integration/J/numerical-integration-7.j b/Task/Numerical-integration/J/numerical-integration-7.j new file mode 100644 index 0000000000..57833d47bc --- /dev/null +++ b/Task/Numerical-integration/J/numerical-integration-7.j @@ -0,0 +1,2 @@ + *:d._1]1p1 +10.3354 diff --git a/Task/Numerical-integration/Java/numerical-integration.java b/Task/Numerical-integration/Java/numerical-integration.java new file mode 100644 index 0000000000..d9931e7735 --- /dev/null +++ b/Task/Numerical-integration/Java/numerical-integration.java @@ -0,0 +1,123 @@ +class NumericalIntegration +{ + + interface FPFunction + { + double eval(double n); + } + + public static double rectangularLeft(double a, double b, int n, FPFunction f) + { + return rectangular(a, b, n, f, 0); + } + + public static double rectangularMidpoint(double a, double b, int n, FPFunction f) + { + return rectangular(a, b, n, f, 1); + } + + public static double rectangularRight(double a, double b, int n, FPFunction f) + { + return rectangular(a, b, n, f, 2); + } + + public static double trapezium(double a, double b, int n, FPFunction f) + { + double range = checkParamsGetRange(a, b, n); + double nFloat = (double)n; + double sum = 0.0; + for (int i = 1; i < n; i++) + { + double x = a + range * (double)i / nFloat; + sum += f.eval(x); + } + sum += (f.eval(a) + f.eval(b)) / 2.0; + return sum * range / nFloat; + } + + public static double simpsons(double a, double b, int n, FPFunction f) + { + double range = checkParamsGetRange(a, b, n); + double nFloat = (double)n; + double sum1 = f.eval(a + range / (nFloat * 2.0)); + double sum2 = 0.0; + for (int i = 1; i < n; i++) + { + double x1 = a + range * ((double)i + 0.5) / nFloat; + sum1 += f.eval(x1); + double x2 = a + range * (double)i / nFloat; + sum2 += f.eval(x2); + } + return (f.eval(a) + f.eval(b) + sum1 * 4.0 + sum2 * 2.0) * range / (nFloat * 6.0); + } + + private static double rectangular(double a, double b, int n, FPFunction f, int mode) + { + double range = checkParamsGetRange(a, b, n); + double modeOffset = (double)mode / 2.0; + double nFloat = (double)n; + double sum = 0.0; + for (int i = 0; i < n; i++) + { + double x = a + range * ((double)i + modeOffset) / nFloat; + sum += f.eval(x); + } + return sum * range / nFloat; + } + + private static double checkParamsGetRange(double a, double b, int n) + { + if (n <= 0) + throw new IllegalArgumentException("Invalid value of n"); + double range = b - a; + if (range <= 0) + throw new IllegalArgumentException("Invalid range"); + return range; + } + + + private static void testFunction(String fname, double a, double b, int n, FPFunction f) + { + System.out.println("Testing function \"" + fname + "\", a=" + a + ", b=" + b + ", n=" + n); + System.out.println("rectangularLeft: " + rectangularLeft(a, b, n, f)); + System.out.println("rectangularMidpoint: " + rectangularMidpoint(a, b, n, f)); + System.out.println("rectangularRight: " + rectangularRight(a, b, n, f)); + System.out.println("trapezium: " + trapezium(a, b, n, f)); + System.out.println("simpsons: " + simpsons(a, b, n, f)); + System.out.println(); + return; + } + + public static void main(String[] args) + { + testFunction("x^3", 0.0, 1.0, 100, new FPFunction() { + public double eval(double n) { + return n * n * n; + } + } + ); + + testFunction("1/x", 1.0, 100.0, 1000, new FPFunction() { + public double eval(double n) { + return 1.0 / n; + } + } + ); + + testFunction("x", 0.0, 5000.0, 5000000, new FPFunction() { + public double eval(double n) { + return n; + } + } + ); + + testFunction("x", 0.0, 6000.0, 6000000, new FPFunction() { + public double eval(double n) { + return n; + } + } + ); + + return; + } +} diff --git a/Task/Numerical-integration/Liberty-BASIC/numerical-integration.liberty b/Task/Numerical-integration/Liberty-BASIC/numerical-integration.liberty new file mode 100644 index 0000000000..e9fc37af38 --- /dev/null +++ b/Task/Numerical-integration/Liberty-BASIC/numerical-integration.liberty @@ -0,0 +1,117 @@ +while 1 + read x$ + if x$ ="end" then print "**Over**": end + + read a, b, N, knownValue + + print " Function y ="; x$; " from "; a; " to "; b; " in "; N; " steps" + print " Known exact value ="; knownValue + + areaLR = IntegralByLeftRectangle( x$, a, b, N) + areaRR = IntegralByRightRectangle( x$, a, b, N) + areaMR = IntegralByMiddleRectangle( x$, a, b, N) + areaTr = IntegralByTrapezium( x$, a, b, N) + areaSi = IntegralBySimpsonRule( x$, a, b, N) + + print "Left rectangle method "; using( "##########.##########", areaLR); " diff "; knownValue-areaLR; tab(70); (knownValue-areaLR)/knownValue*100;" %" + print "Right rectangle method "; using( "##########.##########", areaRR); " diff "; knownValue-areaRR; tab(70); (knownValue-areaRR)/knownValue*100;" %" + print "Middle rectangle method "; using( "##########.##########", areaMR); " diff "; knownValue-areaMR; tab(70); (knownValue-areaMR)/knownValue*100;" %" + print "Trapezium method "; using( "##########.##########", areaTr); " diff "; knownValue-areaTr; tab(70); (knownValue-areaTr)/knownValue*100;" %" + print "Simpson's Rule "; using( "##########.##########", areaSi); " diff "; knownValue-areaSi; tab(70); (knownValue-areaSi)/knownValue*100;" %" + + print + +wend + +end + +'------------------------------------------------------ + 'we have N sizes, that gives us N+1 points + 'point 0 is a + 'point N is b + 'point i is xi =a +i *h + 'Often, precision is (sharper?) then single step area + 'So there should be EXACT number of steps, hence loop by integer i. + +function IntegralByLeftRectangle( x$, a, b, N) + h = ( b -a) /N + s = 0 + for i = 0 to N -1 + x = a +i *h + s = s + h *eval( x$) + next + IntegralByLeftRectangle = s +end function + +function IntegralByRightRectangle( x$, a, b, N) + h =( b -a) /N + s = 0 + for i =1 to N + x = a +i *h + s = s + h *eval( x$) + next + IntegralByRightRectangle = s +end function + +function IntegralByMiddleRectangle( x$, a, b, N) + h =( b -a) /N + s = 0 + for i =0 to N -1 + x = a +i *h +h /2 + s = s + h *eval( x$) + next + IntegralByMiddleRectangle = s +end function + +function IntegralByTrapezium( x$, a, b, N) +'Formula is h*((f(a)+f(b))/2 + sum_{i=1}^{N-1} (f(x_i))) + h =( b -a) /N + x = a + fa =eval( x$) + x =b + fb =eval( x$) + s = h *( fa +fb) /2 + for i =1 to N -1 + x = a +i *h + s = s + h *eval( x$) + next + IntegralByTrapezium = s +end function + +function IntegralBySimpsonRule( x$, a, b, N) + 'Simpson + 'N should be even. + if N mod 2 then N =N +1 + 'It really doesn't look right to double number of points from N to 2N - + ' - this method is most accurate of all presented! + 'So we use NN as N/2, and N will be 2NN + 'Formula is h/6*( f(a)+f(b) + 4*(f(x_1)+f(x_3)+...+f(x_{2NN-1})+ 2*(f(x_2)+f(x_4)+...+f(x_{2NN-2})) ) + 'Somehow I messed up h/6, h/3 and what is h, regarding "n=number of double intervals of size 2h" + NN =N /2 + + h =( b -a) /N + x =a + fa =eval (x$) + x =b + fb =eval( x$) + s = h /3 *( fa +fb) + for i =1 to 2 *NN -1 step 2 + x = a +i *h + s = s + h /3 *4 *eval( x$) 'odd points + next + for i =2 to 2 *NN -2 step 2 + x = a +i *h + s = s + h /3 *2 *eval( x$) 'even points + next + + IntegralBySimpsonRule = s +end function + +'======================================================= +data "x^3", 0, 1, 100, 0.25 +data "x^-1", 1, 100, 1000, 4.605170 +data "x", 0, 5000, 1000, 12500000.0 ' should use 5 000 000 steps +data "x", 0, 6000, 1000, 18000000.0 ' should use 6 000 000 steps +data "end" + +end diff --git a/Task/Numerical-integration/Logo/numerical-integration.logo b/Task/Numerical-integration/Logo/numerical-integration.logo new file mode 100644 index 0000000000..261a265aef --- /dev/null +++ b/Task/Numerical-integration/Logo/numerical-integration.logo @@ -0,0 +1,36 @@ +to i.left :fn :x :step + output invoke :fn :x +end +to i.right :fn :x :step + output invoke :fn :x + :step +end +to i.mid :fn :x :step + output invoke :fn :x + :step/2 +end +to i.trapezium :fn :x :step + output ((i.left :fn :x :step) + (i.right :fn :x :step)) / 2 +end +to i.simpsons :fn :x :step + output ( (i.left :fn :x :step) + + (i.mid :fn :x :step) * 4 + + (i.right :fn :x :step) ) / 6 +end + +to integrate :method :fn :steps :a :b + localmake "step (:b - :a) / :steps + localmake "sigma 0 + ; for [x :a :b-:step :step] [make "sigma :sigma + apply :method (list :fn :x :step)] + repeat :steps [ + make "sigma :sigma + (invoke :method :fn :a :step) + make "a :a + :step ] + output :sigma * :step +end + +to fn2 :x + output 2 / (1 + 4 * :x * :x) +end +print integrate "i.left "fn2 4 -1 2 ; 2.456897 +print integrate "i.right "fn2 4 -1 2 ; 2.245132 +print integrate "i.mid "fn2 4 -1 2 ; 2.496091 +print integrate "i.trapezium "fn2 4 -1 2 ; 2.351014 +print integrate "i.simpsons "fn2 4 -1 2 ; 2.447732 diff --git a/Task/Numerical-integration/Lua/numerical-integration.lua b/Task/Numerical-integration/Lua/numerical-integration.lua new file mode 100644 index 0000000000..518fa85c31 --- /dev/null +++ b/Task/Numerical-integration/Lua/numerical-integration.lua @@ -0,0 +1,73 @@ +function leftRect( f, a, b, n ) + local h = (b - a) / n + local x = a + local sum = 0 + + for i = 1, 100 do + sum = sum + a + f(x) + x = x + h + end + + return sum * h +end + +function rightRect( f, a, b, n ) + local h = (b - a) / n + local x = b + local sum = 0 + + for i = 1, 100 do + sum = sum + a + f(x) + x = x - h + end + + return sum * h +end + +function midRect( f, a, b, n ) + local h = (b - a) / n + local x = a + h/2 + local sum = 0 + + for i = 1, 100 do + sum = sum + a + f(x) + x = x + h + end + + return sum * h +end + +function trapezium( f, a, b, n ) + local h = (b - a) / n + local x = a + local sum = 0 + + for i = 1, 100 do + sum = sum + f(x)*2 + x = x + h + end + + return (b - a) * sum / (2 * n) +end + +function simpson( f, a, b, n ) + local h = (b - a) / n + local sum1 = f(a + h/2) + local sum2 = 0 + + for i = 1, n-1 do + sum1 = sum1 + f(a + h * i + h/2) + sum2 = sum2 + f(a + h * i) + end + + return (h/6) * (f(a) + f(b) + 4*sum1 + 2*sum2) +end + + +int_methods = { leftRect, rightRect, midRect, trapezium, simpson } +for i = 1, 5 do + print( int_methods[i]( function(x) return x^3 end, 0, 1, 100 ) ) + print( int_methods[i]( function(x) return 1/x end, 1, 100, 1000 ) ) + print( int_methods[i]( function(x) return x end, 0, 5000, 5000000 ) ) + print( int_methods[i]( function(x) return x end, 0, 6000, 6000000 ) ) +end diff --git a/Task/Numerical-integration/MATLAB/numerical-integration-1.m b/Task/Numerical-integration/MATLAB/numerical-integration-1.m new file mode 100644 index 0000000000..9d0d283172 --- /dev/null +++ b/Task/Numerical-integration/MATLAB/numerical-integration-1.m @@ -0,0 +1,8 @@ +function integral = leftRectIntegration(f,a,b,n) + + format long; + width = (b-a)/n; %calculate the width of each devision + x = linspace(a,b,n); %define x-axis + integral = width * sum( f(x(1:n-1)) ); + +end diff --git a/Task/Numerical-integration/MATLAB/numerical-integration-2.m b/Task/Numerical-integration/MATLAB/numerical-integration-2.m new file mode 100644 index 0000000000..81ce4786b9 --- /dev/null +++ b/Task/Numerical-integration/MATLAB/numerical-integration-2.m @@ -0,0 +1,8 @@ +function integral = rightRectIntegration(f,a,b,n) + + format long; + width = (b-a)/n; %calculate the width of each devision + x = linspace(a,b,n); %define x-axis + integral = width * sum( f(x(2:n)) ); + +end diff --git a/Task/Numerical-integration/MATLAB/numerical-integration-3.m b/Task/Numerical-integration/MATLAB/numerical-integration-3.m new file mode 100644 index 0000000000..30b2a5e399 --- /dev/null +++ b/Task/Numerical-integration/MATLAB/numerical-integration-3.m @@ -0,0 +1,8 @@ +function integral = midPointRectIntegration(f,a,b,n) + + format long; + width = (b-a)/n; %calculate the width of each devision + x = linspace(a,b,n); %define x-axis + integral = width * sum( f( (x(1:n-1)+x(2:n))/2 ) ); + +end diff --git a/Task/Numerical-integration/MATLAB/numerical-integration-4.m b/Task/Numerical-integration/MATLAB/numerical-integration-4.m new file mode 100644 index 0000000000..a784a26a3e --- /dev/null +++ b/Task/Numerical-integration/MATLAB/numerical-integration-4.m @@ -0,0 +1,7 @@ +function integral = trapezoidalIntegration(f,a,b,n) + + format long; + x = linspace(a,b,n); %define x-axis + integral = trapz( x,f(x) ); + +end diff --git a/Task/Numerical-integration/MATLAB/numerical-integration-5.m b/Task/Numerical-integration/MATLAB/numerical-integration-5.m new file mode 100644 index 0000000000..d7237c4db6 --- /dev/null +++ b/Task/Numerical-integration/MATLAB/numerical-integration-5.m @@ -0,0 +1 @@ +integral = quad(f,a,b,tol) diff --git a/Task/Numerical-integration/MATLAB/numerical-integration-6.m b/Task/Numerical-integration/MATLAB/numerical-integration-6.m new file mode 100644 index 0000000000..c123e5ab1f --- /dev/null +++ b/Task/Numerical-integration/MATLAB/numerical-integration-6.m @@ -0,0 +1,5 @@ +trapezoidalIntegration(@(x)( exp(-(x.^2)) ),0,10,100000) + +ans = + + 0.886226925452753 diff --git a/Task/Numerical-integration/MATLAB/numerical-integration-7.m b/Task/Numerical-integration/MATLAB/numerical-integration-7.m new file mode 100644 index 0000000000..c2e4fb8c5f --- /dev/null +++ b/Task/Numerical-integration/MATLAB/numerical-integration-7.m @@ -0,0 +1,5 @@ +quad(@sin,0,pi,1/1000000000000) + +ans = + + 2.000000000000000 diff --git a/Task/Numerical-integration/MATLAB/numerical-integration-8.m b/Task/Numerical-integration/MATLAB/numerical-integration-8.m new file mode 100644 index 0000000000..b1ba655278 --- /dev/null +++ b/Task/Numerical-integration/MATLAB/numerical-integration-8.m @@ -0,0 +1,4 @@ +function answer = fermiDirac(x) + k = 8.617343e-5; %Boltazmann's Constant in eV/K + answer = 1./( 1+exp( (x)/(k*2000) ) ); %Fermi-Dirac distribution with mu = 0 and T = 2000K +end diff --git a/Task/Numerical-integration/MATLAB/numerical-integration-9.m b/Task/Numerical-integration/MATLAB/numerical-integration-9.m new file mode 100644 index 0000000000..108e863b58 --- /dev/null +++ b/Task/Numerical-integration/MATLAB/numerical-integration-9.m @@ -0,0 +1,5 @@ + rightRectIntegration(@fermiDirac,-1,1,1000000) + +ans = + + 0.999998006023282 diff --git a/Task/Numerical-integration/Mathematica/numerical-integration.math b/Task/Numerical-integration/Mathematica/numerical-integration.math new file mode 100644 index 0000000000..a149dceb2d --- /dev/null +++ b/Task/Numerical-integration/Mathematica/numerical-integration.math @@ -0,0 +1,26 @@ +leftRect[f_, a_Real, b_Real, N_Integer] := + Module[{sum = 0, dx = (b - a)/N, x = a, n = N} , + For[n = N, n > 0, n--, x += dx; sum += f[x];]; + Return [ sum*dx ]] + +rightRect[f_, a_Real, b_Real, N_Integer] := + Module[{sum = 0, dx = (b - a)/N, x = a + (b - a)/N, n = N} , + For[n = N, n > 0, n--, x += dx; sum += f[x];]; + Return [ sum*dx ]] + +midRect[f_, a_Real, b_Real, N_Integer] := + Module[{sum = 0, dx = (b - a)/N, x = a + (b - a)/(2 N), n = N} , + For[n = N, n > 0, n--, x += dx; sum += f[x];]; + Return [ sum*dx ]] + +trapezium[f_, a_Real, b_Real, N_Integer] := + Module[{sum = f[a], dx = (b - a)/N, x = a, n = N} , + For[n = 1, n < N, n++, x += dx; sum += 2 f[x];]; + sum += f[b]; + Return [ 0.5*sum*dx ]] + +simpson[f_, a_Real, b_Real, N_Integer] := + Module[{sum1 = f[a + (b - a)/(2 N)], sum2 = 0, dx = (b - a)/N, x = a, n = N} , + For[n = 1, n < N, n++, sum1 += f[a + dx*n + dx/2]; + sum2 += f[a + dx*n];]; + Return [(dx/6)*(f[a] + f[b] + 4*sum1 + 2*sum2)]] diff --git a/Task/Numerical-integration/Maxima/numerical-integration.maxima b/Task/Numerical-integration/Maxima/numerical-integration.maxima new file mode 100644 index 0000000000..9ec83757a1 --- /dev/null +++ b/Task/Numerical-integration/Maxima/numerical-integration.maxima @@ -0,0 +1,27 @@ +right_rect(e, x, a, b, n) := block([h: (b - a) / n, s: 0], + for i from 1 thru n do s: s + subst(x = a + i * h, e), + s * h)$ + +left_rect(e, x, a, b, n) := block([h: (b - a) / n, s: 0], + for i from 1 thru n do s: s + subst(x = a + (i - 1) * h, e), + s * h)$ + +mid_rect(e, x, a, b, n) := block([h: (b - a) / n, s: 0], + for i from 1 thru n do s: s + subst(x = a + (i - 1/2) * h, e), + s * h)$ + +trapezium(e, x, a, b, n) := block([h: (b - a) / n, s: 0], + for i from 1 thru n - 1 do s: s + subst(x = a + i * h, e), + ((subst(x = a, e) + subst(x = b, e)) / 2 + s) * h)$ + +simpson(e, x, a, b, n) := block([h: (b - a) / n, s: 0], + for i from 1 thru n do + s: s + subst(x = a + i * h, e) + 2 * subst(x = a + (i - 1/2) * h, e), + (subst(x = a, e) - subst(x = b, e) + 2 * s) * h / 6)$ + +/* some tests */ + +simpson(log(x), x, 1, 2, 20), bfloat; +2 * log(2) - 1 - %, bfloat; + +trapezium(1/x, x, 1, 100, 10000) - log(100), bfloat; diff --git a/Task/Numerical-integration/OCaml/numerical-integration-1.ocaml b/Task/Numerical-integration/OCaml/numerical-integration-1.ocaml new file mode 100644 index 0000000000..9c6af7085d --- /dev/null +++ b/Task/Numerical-integration/OCaml/numerical-integration-1.ocaml @@ -0,0 +1,7 @@ +let integrate f a b steps meth = + let h = (b -. a) /. float_of_int steps in + let rec helper i s = + if i >= steps then s + else helper (succ i) (s +. meth f (a +. h *. float_of_int i) h) + in + h *. helper 0 0. diff --git a/Task/Numerical-integration/OCaml/numerical-integration-2.ocaml b/Task/Numerical-integration/OCaml/numerical-integration-2.ocaml new file mode 100644 index 0000000000..2f96deb674 --- /dev/null +++ b/Task/Numerical-integration/OCaml/numerical-integration-2.ocaml @@ -0,0 +1,7 @@ +let methods = [ + ( "rect_l", fun f x _ -> f x); + ( "rect_m", fun f x h -> f (x +. h /. 2.) ); + ( "rect_r", fun f x h -> f (x +. h) ); + ( "trap", fun f x h -> (f x +. f (x +. h)) /. 2. ); + ( "simp", fun f x h -> (f x +. 4. *. f (x +. h /. 2.) +. f (x +. h)) /. 6. ) +] diff --git a/Task/Numerical-integration/OCaml/numerical-integration-3.ocaml b/Task/Numerical-integration/OCaml/numerical-integration-3.ocaml new file mode 100644 index 0000000000..c33cded4a4 --- /dev/null +++ b/Task/Numerical-integration/OCaml/numerical-integration-3.ocaml @@ -0,0 +1,6 @@ +let functions = [ + ( "cubic", (fun x -> x*.x*.x), 0.0, 1.0, 100); + ( "recip", (fun x -> 1.0/.x), 1.0, 100.0, 1000); + ( "x to 5e3", (fun x -> x), 0.0, 5000.0, 5_000_000); + ( "x to 6e3", (fun x -> x), 0.0, 6000.0, 6_000_000) +] diff --git a/Task/Numerical-integration/OCaml/numerical-integration-4.ocaml b/Task/Numerical-integration/OCaml/numerical-integration-4.ocaml new file mode 100644 index 0000000000..f775c42b02 --- /dev/null +++ b/Task/Numerical-integration/OCaml/numerical-integration-4.ocaml @@ -0,0 +1,7 @@ +let () = + List.iter (fun (s,f,lo,hi,n) -> + Printf.printf "Testing function %s:\n" s; + List.iter (fun (name,meth) -> + Printf.printf " method %s gives %.15g\n" name (integrate f lo hi n meth) + ) methods + ) functions diff --git a/Task/Numerical-integration/PARI-GP/numerical-integration.pari b/Task/Numerical-integration/PARI-GP/numerical-integration.pari new file mode 100644 index 0000000000..da9a123d6e --- /dev/null +++ b/Task/Numerical-integration/PARI-GP/numerical-integration.pari @@ -0,0 +1,29 @@ +rectLeft(f, a, b, n)={ + sum(i=0,n-1,f(a+(b-a)*i/n), 0.)*(b-a)/n +}; +rectMid(f, a, b, n)={ + sum(i=1,n,f(a+(b-a)*(i-.5)/n), 0.)*(b-a)/n +}; +rectRight(f, a, b, n)={ + sum(i=1,n,f(a+(b-a)*i/n), 0.)*(b-a)/n +}; +trapezoidal(f, a, b, n)={ + sum(i=1,n-1,f(a+(b-a)*i/n), f(a)/2+f(b)/2.)*(b-a)/n +}; +Simpson(f, a, b, n)={ + my(h=(b - a)/n, s); + s = 2*sum(i=1,n-1, + 2*f(a + h * (i+1/2)) + f(a + h * i) + , 0.) + 4*f(a + h/2) + f(a) + f(b); + s * h / 6 +}; +test(f, a, b, n)={ + my(v=[rectLeft, rectMid, rectRight, trapezoidal, Simpson]); + print("Testing function "f" on ",[a,b]," with "n" intervals:"); + for(i=1,#v, print("\t"v[i](f, a, b, n))) +}; +# \\ Turn on timer +test(x->x^3, 0, 1, 100) +test(x->1/x, 1, 100, 1000) +test(x->x, 0, 5000, 5000000) +test(x->x, 0, 6000, 6000000) diff --git a/Task/Numerical-integration/PL-I/numerical-integration.pli b/Task/Numerical-integration/PL-I/numerical-integration.pli new file mode 100644 index 0000000000..67b2f0c525 --- /dev/null +++ b/Task/Numerical-integration/PL-I/numerical-integration.pli @@ -0,0 +1,43 @@ +integrals: procedure options (main); + +/* The function to be integrated */ +f: procedure (x) returns (float); + declare x float; + return (3*x**2 + 2*x); +end f; + + declare (a, b) float; + declare (rect_area, trap_area, Simpson) float; + declare (d, dx) fixed decimal (10,2); + declare (l, r) float; + declare (S1, S2) float; + + l = 0; r = 5; + a = 0; b = 5; /* bounds of integration */ + dx = 0.05; + + /* Rectangle method */ + rect_area = 0; + do d = a to b by dx; + rect_area = rect_area + dx*f(d); + end; + put skip data (rect_area); + + /* trapezoid method */ + trap_area = 0; + do d = a to b by dx; + trap_area = trap_area + dx*(f(d) + f(d+dx))/2; + end; + put skip data (trap_area); + + /* Simpson's */ + S1 = f(a+dx/2); + S2 = 0; + do d = a to b by dx; + S1 = S1 + f(d+dx+dx/2); + S2 = S2 + f(d+dx); + end; + Simpson = dx * (f(a) + f(b) + 4*S1 + 2*S2) / 6; + put skip data (Simpson); + +end integrals; diff --git a/Task/Numerical-integration/Pascal/numerical-integration.pascal b/Task/Numerical-integration/Pascal/numerical-integration.pascal new file mode 100644 index 0000000000..fe7005a78e --- /dev/null +++ b/Task/Numerical-integration/Pascal/numerical-integration.pascal @@ -0,0 +1,41 @@ +function RectLeft(function f(x: real): real; xl, xr: real): real; + begin + RectLeft := f(xl) + end; + +function RectMid(function f(x: real): real; xl, xr: real) : real; + begin + RectMid := f((xl+xr)/2) + end; + +function RectRight(function f(x: real): real; xl, xr: real): real; + begin + RectRight := f(xr) + end; + +function Trapezium(function f(x: real): real; xl, xr: real): real; + begin + Trapezium := (f(xl) + f(xr))/2 + end; + +function Simpson(function f(x: real): real; xl, xr: real): real; + begin + Simpson := (f(xl) + 4*f((xl+xr)/2) + f(xr))/6 + end; + +function integrate(function method(function f(x: real): real; xl, xr: real): real; + function f(x: real): real; + a, b: real; + n: integer); + var + integral, h: real; + k: integer; + begin + integral := 0; + h := (b-a)/n; + for k := 0 to n-1 do + begin + integral := integral + method(f, a + k*h, a + (k+1)*h) + end; + integrate := integral + end; diff --git a/Task/Numerical-integration/Perl-6/numerical-integration-1.pl6 b/Task/Numerical-integration/Perl-6/numerical-integration-1.pl6 new file mode 100644 index 0000000000..5ddbfe73ed --- /dev/null +++ b/Task/Numerical-integration/Perl-6/numerical-integration-1.pl6 @@ -0,0 +1,51 @@ +sub leftrect(&f, $a, $b, $n) { + my $h = ($b - $a) / $n; + $h * [+] do f($_) for $a, *+$h ... $b-$h; +} + +sub rightrect(&f, $a, $b, $n) { + my $h = ($b - $a) / $n; + $h * [+] do f($_) for $a+$h, *+$h ... $b; +} + +sub midrect(&f, $a, $b, $n) { + my $h = ($b - $a) / $n; + $h * [+] do f($_) for $a+$h/2, *+$h ... $b-$h/2; +} + +sub trapez(&f, $a, $b, $n) { + my $h = ($b - $a) / $n; + $h / 2 * [+] f($a), f($b), do f($_) * 2 for $a+$h, *+$h ... $b-$h; +} + +sub simpsons(&f, $a, $b, $n) { + my $h = ($b - $a) / $n; + my $h2 = $h/2; + my $sum1 = f($a + $h2); + my $sum2 = 0; + + for $a+$h, *+$h ... $b-$h { + $sum1 += f($_ + $h2); + $sum2 += f($_); + } + ($h / 6) * (f($a) + f($b) + 4*$sum1 + 2*$sum2); +} + +sub tryem($f, $a, $b, $n, $exact) { + say "\n$f\n in [$a..$b] / $n"; + eval "my &f = $f; + say ' exact result: ', $exact; + say ' rectangle method left: ', leftrect &f, $a, $b, $n; + say ' rectangle method right: ', rightrect &f, $a, $b, $n; + say ' rectangle method mid: ', midrect &f, $a, $b, $n; + say 'composite trapezoidal rule: ', trapez &f, $a, $b, $n; + say ' quadratic simpsons rule: ', simpsons &f, $a, $b, $n;" +} + +tryem '{ $_ ** 3 }', 0, 1, 100, 0.25; + +tryem '1 / *', 1, 100, 1000, log(100); + +tryem '{$_}', 0, 5_000, 10_000, 12_500_000; + +tryem '{$_}', 0, 6_000, 12_000, 18_000_000; diff --git a/Task/Numerical-integration/Perl-6/numerical-integration-2.pl6 b/Task/Numerical-integration/Perl-6/numerical-integration-2.pl6 new file mode 100644 index 0000000000..3bce51a0b3 --- /dev/null +++ b/Task/Numerical-integration/Perl-6/numerical-integration-2.pl6 @@ -0,0 +1,35 @@ +{ $_ ** 3 } + in [0..1] / 100 + exact result: 0.25 + rectangle method left: 0.245025 + rectangle method right: 0.255025 + rectangle method mid: 0.2499875 +composite trapezoidal rule: 0.250025 + quadratic simpsons rule: 0.25 + +1 / * + in [1..100] / 1000 + exact result: 4.60517018598809 + rectangle method left: 4.65499105751468 + rectangle method right: 4.55698105751468 + rectangle method mid: 4.60476254867838 +composite trapezoidal rule: 4.60598605751468 + quadratic simpsons rule: 4.60517038495714 + +{$_} + in [0..5000] / 10000 + exact result: 12500000 + rectangle method left: 12498750 + rectangle method right: 12501250 + rectangle method mid: 12500000 +composite trapezoidal rule: 12500000 + quadratic simpsons rule: 12500000 + +{$_} + in [0..6000] / 12000 + exact result: 18000000 + rectangle method left: 17998500 + rectangle method right: 18001500 + rectangle method mid: 18000000 +composite trapezoidal rule: 18000000 + quadratic simpsons rule: 18000000 diff --git a/Task/Numerical-integration/PicoLisp/numerical-integration.l b/Task/Numerical-integration/PicoLisp/numerical-integration.l new file mode 100644 index 0000000000..1f18806ab9 --- /dev/null +++ b/Task/Numerical-integration/PicoLisp/numerical-integration.l @@ -0,0 +1,32 @@ +(scl 6) + +(de leftRect (Fun X) + (Fun X) ) + +(de rightRect (Fun X H) + (Fun (+ X H)) ) + +(de midRect (Fun X H) + (Fun (+ X (/ H 2))) ) + +(de trapezium (Fun X H) + (/ (+ (Fun X) (Fun (+ X H))) 2) ) + +(de simpson (Fun X H) + (*/ + (+ + (Fun X) + (* 4 (Fun (+ X (/ H 2)))) + (Fun (+ X H)) ) + 6 ) ) + +(de square (X) + (*/ X X 1.0) ) + +(de integrate (Fun From To Steps Meth) + (let (H (/ (- To From) Steps) Sum 0) + (for (X From (>= (- To H) X) (+ X H)) + (inc 'Sum (Meth Fun X H)) ) + (*/ H Sum 1.0) ) ) + +(prinl (round (integrate square 3.0 7.0 30 simpson))) diff --git a/Task/Numerical-integration/PureBasic/numerical-integration.purebasic b/Task/Numerical-integration/PureBasic/numerical-integration.purebasic new file mode 100644 index 0000000000..e7d60141fc --- /dev/null +++ b/Task/Numerical-integration/PureBasic/numerical-integration.purebasic @@ -0,0 +1,102 @@ +Prototype.d TestFunction(Arg.d) + +Procedure.d LeftIntegral(Start, Stop, Steps, *func.TestFunction) + Protected.d n=(Stop-Start)/Steps, sum, x=Start + While x <= Stop-n + sum + n * *func(x) + x + n + Wend + ProcedureReturn sum +EndProcedure + +Procedure.d MidIntegral(Start, Stop, Steps, *func.TestFunction) + Protected.d n=(Stop-Start)/Steps, sum, x=Start + While x <= Stop-n + sum + n * *func(x+n/2) + x + n + Wend + ProcedureReturn sum +EndProcedure + +Procedure.d RightIntegral(Start, Stop, Steps, *func.TestFunction) + Protected.d n=(Stop-Start)/Steps, sum, x=Start + While x < Stop + x + n + sum + n * *func(x) + Wend + ProcedureReturn sum +EndProcedure + +Procedure.d Trapezium(Start, Stop, Steps, *func.TestFunction) + Protected.d n=(Stop-Start)/Steps, sum, x=Start + While x<=Stop + sum + n * (*func(x) + *func(x+n))/2 + x+n + Wend + ProcedureReturn sum +EndProcedure + +Procedure.d Simpson(Start, Stop, Steps, *func.TestFunction) + Protected.d n=(Stop-Start)/Steps, sum1, sum2, x=Start + Protected i + For i=0 To steps-1 + sum1+ *func(Start+n*i+n/2) + Next + For i=1 To Steps-1 + sum2+ *func(Start+n*i) + Next + ProcedureReturn n * (*func(Start)+ *func(Stop)+4*sum1+2*sum2) / 6 +EndProcedure + +;- Set up functions to integrate +Procedure.d Test1(n.d) + ProcedureReturn n*n*n +EndProcedure + +Procedure.d Test2(n.d) + ProcedureReturn 1/n +EndProcedure + +; This function should be integrated as a integer function, but for +; comparably this will stay as a float. +Procedure.d Test3(n.d) + ProcedureReturn n +EndProcedure + +;- Test the code & present the results +CompilerIf #PB_Compiler_Debugger + MessageRequester("Notice!","Running this program in Debug-mode will be slow") +CompilerEndIf + +; = 0.25 +Define Answer$ +Answer$="Left ="+StrD(LeftIntegral (0,1,100,@Test1()))+#CRLF$ +Answer$+"Mid ="+StrD(MidIntegral (0,1,100,@Test1()))+#CRLF$ +Answer$+"Right ="+StrD(RightIntegral(0,1,100,@Test1()))+#CRLF$ +Answer$+"Trapezium="+StrD(Trapezium (0,1,100,@Test1()))+#CRLF$ +Answer$+"Simpson ="+StrD(Simpson (0,1,100,@Test1())) +MessageRequester("Answer should be 1/4",Answer$) + +; = Ln(100) e.g. ~4.60517019... +Answer$="Left ="+StrD(LeftIntegral (1,100,1000,@Test2()))+#CRLF$ +Answer$+"Mid ="+StrD(MidIntegral (1,100,1000,@Test2()))+#CRLF$ +Answer$+"Right ="+StrD(RightIntegral (1,100,1000,@Test2()))+#CRLF$ +Answer$+"Trapezium="+StrD(Trapezium (1,100,1000,@Test2()))+#CRLF$ +Answer$+"Simpson ="+StrD(Simpson (1,100,1000,@Test2())) +MessageRequester("Answer should be Ln(100), e.g. ~4.60517019",Answer$) + +; 12,500,000 +Answer$="Left ="+StrD(LeftIntegral (0,5000,5000000,@Test3()))+#CRLF$ +Answer$+"Mid ="+StrD(MidIntegral (0,5000,5000000,@Test3()))+#CRLF$ +Answer$+"Right ="+StrD(RightIntegral (0,5000,5000000,@Test3()))+#CRLF$ +Answer$+"Trapezium="+StrD(Trapezium (0,5000,5000000,@Test3()))+#CRLF$ +Answer$+"Simpson ="+StrD(Simpson (0,5000,5000000,@Test3())) +MessageRequester("Answer should be 12,500,000",Answer$) + +; 18,000,000 +Answer$="Left ="+StrD(LeftIntegral (0,6000,6000000,@Test3()))+#CRLF$ +Answer$+"Mid ="+StrD(MidIntegral (0,6000,6000000,@Test3()))+#CRLF$ +Answer$+"Right ="+StrD(RightIntegral (0,6000,6000000,@Test3()))+#CRLF$ +Answer$+"Trapezium="+StrD(Trapezium (0,6000,6000000,@Test3()))+#CRLF$ +Answer$+"Simpson ="+StrD(Simpson (0,6000,6000000,@Test3())) +MessageRequester("Answer should be 18,000,000",Answer$) diff --git a/Task/Numerical-integration/Python/numerical-integration-1.py b/Task/Numerical-integration/Python/numerical-integration-1.py new file mode 100644 index 0000000000..c976a2c871 --- /dev/null +++ b/Task/Numerical-integration/Python/numerical-integration-1.py @@ -0,0 +1,55 @@ +from fractions import Fraction + +def left_rect(f,x,h): + return f(x) + +def mid_rect(f,x,h): + return f(x + h/2) + +def right_rect(f,x,h): + return f(x+h) + +def trapezium(f,x,h): + return (f(x) + f(x+h))/2.0 + +def simpson(f,x,h): + return (f(x) + 4*f(x + h/2) + f(x+h))/6.0 + +def cube(x): + return x*x*x + +def reciprocal(x): + return 1/x + +def identity(x): + return x + +def integrate( f, a, b, steps, meth): + h = (b-a)/steps + ival = h * sum(meth(f, a+i*h, h) for i in range(steps)) + return ival + +# Tests +for a, b, steps, func in ((0., 1., 100, cube), (1., 100., 1000, reciprocal)): + for rule in (left_rect, mid_rect, right_rect, trapezium, simpson): + print('%s integrated using %s\n from %r to %r (%i steps) = %r' % + (func.__name__, rule.__name__, a, b, steps, + integrate( func, a, b, steps, rule))) + a, b = Fraction.from_float(a), Fraction.from_float(b) + for rule in (left_rect, mid_rect, right_rect, trapezium, simpson): + print('%s integrated using %s\n from %r to %r (%i steps and fractions) = %r' % + (func.__name__, rule.__name__, a, b, steps, + float(integrate( func, a, b, steps, rule)))) + +# Extra tests (compute intensive) +for a, b, steps, func in ((0., 5000., 5000000, identity), + (0., 6000., 6000000, identity)): + for rule in (left_rect, mid_rect, right_rect, trapezium, simpson): + print('%s integrated using %s\n from %r to %r (%i steps) = %r' % + (func.__name__, rule.__name__, a, b, steps, + integrate( func, a, b, steps, rule))) + a, b = Fraction.from_float(a), Fraction.from_float(b) + for rule in (left_rect, mid_rect, right_rect, trapezium, simpson): + print('%s integrated using %s\n from %r to %r (%i steps and fractions) = %r' % + (func.__name__, rule.__name__, a, b, steps, + float(integrate( func, a, b, steps, rule)))) diff --git a/Task/Numerical-integration/Python/numerical-integration-2.py b/Task/Numerical-integration/Python/numerical-integration-2.py new file mode 100644 index 0000000000..44832ff930 --- /dev/null +++ b/Task/Numerical-integration/Python/numerical-integration-2.py @@ -0,0 +1,23 @@ +for a, b, steps, func in ((0., 1., 100, cube), (1., 100., 1000, reciprocal)): + for rule in (left_rect, mid_rect, right_rect, trapezium, simpson): + print('%s integrated using %s\n from %r to %r (%i steps) = %r' % + (func.__name__, rule.__name__, a, b, steps, + integrate( func, a, b, steps, rule))) + a, b = Fraction.from_float(a), Fraction.from_float(b) + for rule in (left_rect, mid_rect, right_rect, trapezium, simpson): + print('%s integrated using %s\n from %r to %r (%i steps and fractions) = %r' % + (func.__name__, rule.__name__, a, b, steps, + float(integrate( func, a, b, steps, rule)))) + +# Extra tests (compute intensive) +for a, b, steps, func in ((1., 5000., 5000000, identity), + (1., 6000., 6000000, identity)): + for rule in (left_rect, mid_rect, right_rect, trapezium, simpson): + print('%s integrated using %s\n from %r to %r (%i steps) = %r' % + (func.__name__, rule.__name__, a, b, steps, + integrate( func, a, b, steps, rule))) + a, b = Fraction.from_float(a), Fraction.from_float(b) + for rule in (left_rect, mid_rect, right_rect, trapezium, simpson): + print('%s integrated using %s\n from %r to %r (%i steps and fractions) = %r' % + (func.__name__, rule.__name__, a, b, steps, + float(integrate( func, a, b, steps, rule)))) diff --git a/Task/Numerical-integration/Python/numerical-integration-3.py b/Task/Numerical-integration/Python/numerical-integration-3.py new file mode 100644 index 0000000000..45983eb2ee --- /dev/null +++ b/Task/Numerical-integration/Python/numerical-integration-3.py @@ -0,0 +1,6 @@ +def faster_simpson(f, a, b, steps): + h = (b-a)/steps + a1 = a+h/2 + s1 = sum( f(a1+i*h) for i in range(0,steps)) + s2 = sum( f(a+i*h) for i in range(1,steps)) + return (h/6.0)*(f(a)+f(b)+4.0*s1+2.0*s2) diff --git a/Task/Numerical-integration/R/numerical-integration.r b/Task/Numerical-integration/R/numerical-integration.r new file mode 100644 index 0000000000..7ed1885b7f --- /dev/null +++ b/Task/Numerical-integration/R/numerical-integration.r @@ -0,0 +1,36 @@ +integrate.rect <- function(f, a, b, n, k=0) { + #k = 0 for left, 1 for right, 0.5 for midpoint + h <- (b-a)/n + x <- seq(a, b, len=n+1) + sum(f(x[-1]-h*(1-k)))*h +} + +integrate.trapezoid <- function(f, a, b, n) { + h <- (b-a)/n + x <- seq(a, b, len=n+1) + fx <- f(x) + sum(fx[-1] + fx[-length(x)])*h/2 +} + +integrate.simpsons <- function(f, a, b, n) { + h <- (b-a)/n + x <- seq(a, b, len=n+1) + fx <- f(x) + sum(fx[-length(x)] + 4*f(x[-1]-h/2) + fx[-1]) * h/6 +} + +f1 <- (function(x) {x^3}) +f2 <- (function(x) {1/x}) +f3 <- (function(x) {x}) +f4 <- (function(x) {x}) + +integrate.simpsons(f1,0,1,100) #0.25 +integrate.simpsons(f2,1,100,1000) # 4.60517 +integrate.simpsons(f3,0,5000,5000000) # 12500000 +integrate.simpsons(f4,0,6000,6000000) # 1.8e+07 + +integrate.rect(f1,0,1,100,0) #TopLeft 0.245025 +integrate.rect(f1,0,1,100,0.5) #Mid 0.2499875 +integrate.rect(f1,0,1,100,1) #TopRight 0.255025 + +integrate.trapezoid(f1,0,1,100) # 0.250025 diff --git a/Task/Numerical-integration/REXX/numerical-integration.rexx b/Task/Numerical-integration/REXX/numerical-integration.rexx new file mode 100644 index 0000000000..7fb449e055 --- /dev/null +++ b/Task/Numerical-integration/REXX/numerical-integration.rexx @@ -0,0 +1,60 @@ +/*REXX program numerically integrates using five different methods. */ +numeric digits 20 /*use twenty digits precision. */ + + do test=1 for 4 /*perform the test suite. */ + if test==1 then do; L=0; H= 1; i= 100; end + if test==2 then do; L=1; H= 100; i= 1000; end + if test==3 then do; L=0; H=5000; i=5000000; end + if test==4 then do; L=0; H=6000; i=5000000; end + say + say center('test' test,79,'─') /*display a header for the test. */ + say ' left_rectangular('L","H','i") = " left_rect(L,H,i) + say ' midpoint_rectangular('L","H','i") = " midpoint_rect(L,H,i) + say ' right_rectangular('L","H','i") = " right_rect(L,H,i) + say ' simpson('L","H','i") = " simpson(L,H,i) + say ' trapezoid('L","H','i") = " trapezoid(L,H,i) + end /*test*/ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────LEFT_RECT subroutine────────────────*/ +left_rect: procedure expose test; parse arg a,b,n; h=(b-a)/n +sum=0 + do x=a by h for n + sum=sum+f(x) + end +return sum*h +/*──────────────────────────────────MIDPOINT_RECT subroutine────────────*/ +midpoint_rect: procedure expose test; parse arg a,b,n; h=(b-a)/n +sum=0 + do x=a+h/2 by h for n + sum=sum+f(x) + end +return sum*h +/*──────────────────────────────────RIGHT_RECT subroutine───────────────*/ +right_rect: procedure expose test; parse arg a,b,n; h=(b-a)/n +sum=0 + do x=a+h by h for n + sum=sum+f(x) + end +return sum*h +/*──────────────────────────────────SIMPSON subroutine──────────────────*/ +simpson: procedure expose test; parse arg a,b,n; h=(b-a)/n +sum1=f(a+h/2) +sum2=0 + do x=1 to n-1 + sum1=sum1+f(a+h*x+h*.5) + sum2=sum2+f(a+x*h) + end + +return h*(f(a)+f(b)+4*sum1+2*sum2)/6 +/*──────────────────────────────────TRAPEZOID subroutine────────────────*/ +trapezoid: procedure expose test; parse arg a,b,n; h=(b-a)/n +sum=0 + do x=a to b by h + sum=sum+h*(f(x)+f(x+h))*.5 + end +return sum +/*──────────────────────────────────F subroutine────────────────────────*/ +f: procedure expose test; parse arg z +if test==1 then return z**3 +if test==2 then return 1/z + return z diff --git a/Task/Numerical-integration/Ruby/numerical-integration.rb b/Task/Numerical-integration/Ruby/numerical-integration.rb new file mode 100644 index 0000000000..7b28360fb4 --- /dev/null +++ b/Task/Numerical-integration/Ruby/numerical-integration.rb @@ -0,0 +1,58 @@ +def leftrect(f, left, right) + f.call(left) +end + +def midrect(f, left, right) + f.call((left+right)/2.0) +end + +def rightrect(f, left, right) + f.call(right) +end + +def trapezium(f, left, right) + (f.call(left) + f.call(right)) / 2.0 +end + +def simpson(f, left, right) + (f.call(left) + 4*f.call((left+right)/2.0) + f.call(right)) / 6.0 +end + +def integrate(f, a, b, steps, method) + delta = 1.0 * (b - a) / steps + total = 0.0 + steps.times do |i| + left = a + i*delta + right = left + delta + total += delta * send(method, f, left, right) + end + total +end + +def square(x) + x**2 +end + +def def_int(f, a, b) + l = case f.to_s + when /sin>/ + lambda {|x| -Math.cos(x)} + when /square>/ + lambda {|x| (x**3)/3.0} + end + l.call(b) - l.call(a) +end + +a = 0 +b = Math::PI +steps = 10 + +for func in [method(:square), Math.method(:sin)] + puts "integral of #{func} from #{a} to #{b} in #{steps} steps" + actual = def_int(func, a, b) + for method in [:leftrect, :midrect, :rightrect, :trapezium, :simpson] + int = integrate(func, a, b, steps, method) + diff = (int - actual) * 100.0 / actual + printf " %-10s %s\t(%.1f%%)\n", method, int, diff + end +end diff --git a/Task/Numerical-integration/Scala/numerical-integration.scala b/Task/Numerical-integration/Scala/numerical-integration.scala new file mode 100644 index 0000000000..08793aa988 --- /dev/null +++ b/Task/Numerical-integration/Scala/numerical-integration.scala @@ -0,0 +1,35 @@ +object NumericalIntegration { + def leftRect(f:Double=>Double, a:Double, b:Double)=f(a) + def midRect(f:Double=>Double, a:Double, b:Double)=f((a+b)/2) + def rightRect(f:Double=>Double, a:Double, b:Double)=f(b) + def trapezoid(f:Double=>Double, a:Double, b:Double)=(f(a)+f(b))/2 + def simpson(f:Double=>Double, a:Double, b:Double)=(f(a)+4*f((a+b)/2)+f(b))/6; + + def fn1(x:Double)=x*x*x + def fn2(x:Double)=1/x + def fn3(x:Double)=x + + type Method = (Double=>Double, Double, Double) => Double + def integrate(f:Double=>Double, a:Double, b:Double, steps:Double, m:Method)={ + val delta:Double=(b-a)/steps + delta*(a until b by delta).foldLeft(0.0)((s,x) => s+m(f, x, x+delta)) + } + + def print(f:Double=>Double, a:Double, b:Double, steps:Double)={ + println("rectangular left : %f".format(integrate(f, a, b, steps, leftRect))) + println("rectangular middle : %f".format(integrate(f, a, b, steps, midRect))) + println("rectangular right : %f".format(integrate(f, a, b, steps, rightRect))) + println("trapezoid : %f".format(integrate(f, a, b, steps, trapezoid))) + println("simpson : %f".format(integrate(f, a, b, steps, simpson))) + } + + def main(args: Array[String]): Unit = { + print(fn1, 0, 1, 100) + println("------") + print(fn2, 1, 100, 1000) + println("------") + print(fn3, 0, 5000, 5000000) + println("------") + print(fn3, 0, 6000, 6000000) + } +} diff --git a/Task/Numerical-integration/Scheme/numerical-integration.ss b/Task/Numerical-integration/Scheme/numerical-integration.ss new file mode 100644 index 0000000000..6953769ab8 --- /dev/null +++ b/Task/Numerical-integration/Scheme/numerical-integration.ss @@ -0,0 +1,21 @@ +(define (integrate f a b steps meth) + (define h (/ (- b a) steps)) + (* h + (let loop ((i 0) (s 0)) + (if (>= i steps) + s + (loop (+ i 1) (+ s (meth f (+ a (* h i)) h))))))) + +(define (left-rect f x h) (f x)) +(define (mid-rect f x h) (f (+ x (/ h 2)))) +(define (right-rect f x h) (f (+ x h))) +(define (trapezium f x h) (/ (+ (f x) (f (+ x h))) 2)) +(define (simpson f x h) (/ (+ (f x) (* 4 (f (+ x (/ h 2)))) (f (+ x h))) 6)) + +(define (square x) (* x x)) + +(define rl (integrate square 0 1 10 left-rect)) +(define rm (integrate square 0 1 10 mid-rect)) +(define rr (integrate square 0 1 10 right-rect)) +(define t (integrate square 0 1 10 trapezium)) +(define s (integrate square 0 1 10 simpson)) diff --git a/Task/Numerical-integration/Standard-ML/numerical-integration.ml b/Task/Numerical-integration/Standard-ML/numerical-integration.ml new file mode 100644 index 0000000000..b2207a7cb7 --- /dev/null +++ b/Task/Numerical-integration/Standard-ML/numerical-integration.ml @@ -0,0 +1,23 @@ +fun integrate (f, a, b, steps, meth) = let + val h = (b - a) / real steps + fun helper (i, s) = + if i >= steps then s + else helper (i+1, s + meth (f, a + h * real i, h)) +in + h * helper (0, 0.0) +end + +fun leftRect (f, x, _) = f x +fun midRect (f, x, h) = f (x + h / 2.0) +fun rightRect (f, x, h) = f (x + h) +fun trapezium (f, x, h) = (f x + f (x + h)) / 2.0 +fun simpson (f, x, h) = (f x + 4.0 * f (x + h / 2.0) + f (x + h)) / 6.0 + +fun square x = x * x + + +val rl = integrate (square, 0.0, 1.0, 10, left_rect ) +val rm = integrate (square, 0.0, 1.0, 10, mid_rect ) +val rr = integrate (square, 0.0, 1.0, 10, right_rect) +val t = integrate (square, 0.0, 1.0, 10, trapezium ) +val s = integrate (square, 0.0, 1.0, 10, simpson ) diff --git a/Task/Numerical-integration/Tcl/numerical-integration.tcl b/Task/Numerical-integration/Tcl/numerical-integration.tcl new file mode 100644 index 0000000000..bd29c4aed3 --- /dev/null +++ b/Task/Numerical-integration/Tcl/numerical-integration.tcl @@ -0,0 +1,54 @@ +package require Tcl 8.5 + +proc leftrect {f left right} { + $f $left +} +proc midrect {f left right} { + set mid [expr {($left + $right) / 2.0}] + $f $mid +} +proc rightrect {f left right} { + $f $right +} +proc trapezium {f left right} { + expr {([$f $left] + [$f $right]) / 2.0} +} +proc simpson {f left right} { + set mid [expr {($left + $right) / 2.0}] + expr {([$f $left] + 4*[$f $mid] + [$f $right]) / 6.0} +} + +proc integrate {f a b steps method} { + set delta [expr {1.0 * ($b - $a) / $steps}] + set total 0.0 + for {set i 0} {$i < $steps} {incr i} { + set left [expr {$a + $i * $delta}] + set right [expr {$left + $delta}] + set total [expr {$total + $delta * [$method $f $left $right]}] + } + return $total +} + +interp alias {} sin {} ::tcl::mathfunc::sin +proc square x {expr {$x*$x}} +proc def_int {f a b} { + switch -- $f { + sin {set lambda {x {expr {-cos($x)}}}} + square {set lambda {x {expr {$x**3/3.0}}}} + } + return [expr {[apply $lambda $b] - [apply $lambda $a]}] +} + +set a 0 +set b [expr {4*atan(1)}] +set steps 10 + +foreach func {square sin} { + puts "integral of ${func}(x) from $a to $b in $steps steps" + set actual [def_int $func $a $b] + foreach method {leftrect midrect rightrect trapezium simpson} { + set int [integrate $func $a $b $steps $method] + set diff [expr {($int - $actual) * 100.0 / $actual}] + puts [format " %-10s %s\t(%.1f%%)" $method $int $diff] + } +} diff --git a/Task/Numerical-integration/Ursala/numerical-integration-1.ursala b/Task/Numerical-integration/Ursala/numerical-integration-1.ursala new file mode 100644 index 0000000000..438aca24bc --- /dev/null +++ b/Task/Numerical-integration/Ursala/numerical-integration-1.ursala @@ -0,0 +1,7 @@ +#import std +#import nat +#import flo + +(integral_by "m") ("f","a","b","n") = + +iprod ^(* ! div\float"n" minus/"b" "a",~&) ("m" "f")*ytp (ari successor "n")/"a" "b" diff --git a/Task/Numerical-integration/Ursala/numerical-integration-2.ursala b/Task/Numerical-integration/Ursala/numerical-integration-2.ursala new file mode 100644 index 0000000000..ac0da05eab --- /dev/null +++ b/Task/Numerical-integration/Ursala/numerical-integration-2.ursala @@ -0,0 +1,3 @@ +(integral_by "m") ("f","a","b","n") = + +iprod ^(* ! div\float"n" minus/"b" "a",~&) ^H(*+ "m"+ -:"f"+ * ^/~& "f",~&ytp) (ari successor "n")/"a" "b" diff --git a/Task/Numerical-integration/Ursala/numerical-integration-3.ursala b/Task/Numerical-integration/Ursala/numerical-integration-3.ursala new file mode 100644 index 0000000000..985bbca354 --- /dev/null +++ b/Task/Numerical-integration/Ursala/numerical-integration-3.ursala @@ -0,0 +1,5 @@ +left = integral_by "f". ("l","r"). "f" "l" +right = integral_by "f". ("l","r"). "f" "r" +midpoint = integral_by "f". ("l","r"). "f" div\2. plus/"l" "r" +trapezium = integral_by "f". ("l","r"). div\2. plus "f"~~/"l" "r" +simpson = integral_by "f". ("l","r"). div\6. plus:-0. <"f" "l",times/4. "f" div\2. plus/"l" "r","f" "r"> diff --git a/Task/Numerical-integration/Ursala/numerical-integration-4.ursala b/Task/Numerical-integration/Ursala/numerical-integration-4.ursala new file mode 100644 index 0000000000..f56d8fa5b1 --- /dev/null +++ b/Task/Numerical-integration/Ursala/numerical-integration-4.ursala @@ -0,0 +1,3 @@ +#cast %eL + +examples = <.left,midpoint,rignt,trapezium,simpson> (sqr,0.,pi,10) diff --git a/Task/Numerical-integration/XPL0/numerical-integration.xpl0 b/Task/Numerical-integration/XPL0/numerical-integration.xpl0 new file mode 100644 index 0000000000..4b1205476b --- /dev/null +++ b/Task/Numerical-integration/XPL0/numerical-integration.xpl0 @@ -0,0 +1,47 @@ +include c:\cxpl\codes; \intrinsic 'code' declarations + +func real Func(FN, X); \Return F(X) for function number FN +int FN; real X; +[case FN of + 1: return X*X*X; + 2: return 1.0/X; + 3: return X +other return 0.0; +]; + +func Integrate(A, B, FN, N); \Display area under curve for function FN +real A, B; int FN, N; \limits A, B, and number of slices N +real DX, X, Area; \delta X +int I; +[DX:= (B-A)/float(N); +X:= A; Area:= 0.0; \rectangular left +for I:= 1 to N do + [Area:= Area + Func(FN,X)*DX; X:= X+DX]; +RlOut(0, Area); +X:= A; Area:= 0.0; \rectangular right +for I:= 1 to N do + [X:= X+DX; Area:= Area + Func(FN,X)*DX]; +RlOut(0, Area); +X:= A+DX/2.0; Area:= 0.0; \rectangular mid point +for I:= 1 to N do + [Area:= Area + Func(FN,X)*DX; X:= X+DX]; +RlOut(0, Area); +X:= A; Area:= 0.0; \trapezium +for I:= 1 to N do + [Area:= Area + (Func(FN,X)+Func(FN,X+DX))/2.0*DX; X:= X+DX]; +RlOut(0, Area); +X:= A; Area:= 0.0; \Simpson's rule +for I:= 1 to N do + [Area:= Area + + DX/6.0*(Func(FN,X) + 4.0*Func(FN,(X+X+DX)/2.0) + Func(FN,X+DX)); + X:= X+DX]; +RlOut(0, Area); +CrLf(0); +]; + +[Format(9,6); +Integrate(0.0, 1.0, 1, 100); +Integrate(1.0, 100.0, 2, 1000); +Integrate(0.0, 5000.0, 3, 5_000_000); +Integrate(0.0, 6000.0, 3, 6_000_000); +] diff --git a/Task/OLE-Automation/0DESCRIPTION b/Task/OLE-Automation/0DESCRIPTION new file mode 100644 index 0000000000..f6404abc92 --- /dev/null +++ b/Task/OLE-Automation/0DESCRIPTION @@ -0,0 +1,4 @@ +[http://en.wikipedia.org/wiki/OLE_Automation OLE Automation] is an inter-process communication mechanism based on [http://en.wikipedia.org/wiki/Component_Object_Model Component Object Model] (COM) on Microsoft Windows. + +Provide an automation server implementing objects that can be accessed by a client running in a separate process. The client gets a proxy-object that can call methods on the object. +The communication should be able to handle conversions of [http://en.wikipedia.org/wiki/Variant_type variants] to and from the native value types. diff --git a/Task/OLE-Automation/1META.yaml b/Task/OLE-Automation/1META.yaml new file mode 100644 index 0000000000..2c16891d8b --- /dev/null +++ b/Task/OLE-Automation/1META.yaml @@ -0,0 +1,2 @@ +--- +note: OLE Automation Client and Server diff --git a/Task/OLE-Automation/AutoHotkey/ole-automation-1.ahk b/Task/OLE-Automation/AutoHotkey/ole-automation-1.ahk new file mode 100644 index 0000000000..80a7adcc53 --- /dev/null +++ b/Task/OLE-Automation/AutoHotkey/ole-automation-1.ahk @@ -0,0 +1,5 @@ +ahk := comobjactive("ahkdemo.ahk") +ahk.hello("hello world") +py := ComObjActive("python.server") +py.write("hello") +return diff --git a/Task/OLE-Automation/AutoHotkey/ole-automation-2.ahk b/Task/OLE-Automation/AutoHotkey/ole-automation-2.ahk new file mode 100644 index 0000000000..a2914d4f0d --- /dev/null +++ b/Task/OLE-Automation/AutoHotkey/ole-automation-2.ahk @@ -0,0 +1,56 @@ +#Persistent +CLSID_ThisScript := "{38A3EB13-D0C4-478b-9720-4D0B2D361DB9}" +APPID_ThisScript := "ahkdemo.ahk" +funcs := ["aRegisterIDs", "aGetObject", "aCallFunc", "hello"] +server := ahkComServer(CLSID_ThisScript, APPID_ThisScript, funcs) +return + +aRegisterIDs(this, CLSID, APPID){ +RegisterIDs(CLSID, APPID) +} + +hello(this, message){ +msgbox % message +} +aGetObject(this, name){ +global +return %name% +} + +aCallFunc(this, func, args){ +return %func%(args) +} + +;; ahkcomserver() +ahkComServer(CLSID_ThisScript, APPID_ThisScript, funcs) +{ +global serverReady +server := object() + ; CLSID_ThisScript := "{38A3EB13-D0C4-478b-9720-4D0B2D361DB9}" + ; APPID_ThisScript := "Garglet.QueryServer" + + RegisterIDs(CLSID_ThisScript, APPID_ThisScript) +for i, func in funcs +{ +str .= func . ", " +} +str := SubStr(str, 1, strlen(str) - 2) + + myObj := ComDispatch("", str) +; Expose it + if !(hRemote := ComRemote(myObj, CLSID_ThisScript)) + { + MsgBox, 16, %A_ScriptName%, Can't remote the object! + ExitApp + } +server.CLSID := CLSID_ThisScript +server.APPID := APPID_ThisScript +server.hRemote := hRemote +serverReady := 1 + return server +} + +#Include ComRemote.ahk +#include lib\ComDispTable.ahk +#include lib\ComDispatch.ahk +#include lib\ComVar.ahk diff --git a/Task/OLE-Automation/Python/ole-automation-1.py b/Task/OLE-Automation/Python/ole-automation-1.py new file mode 100644 index 0000000000..5253c14a44 --- /dev/null +++ b/Task/OLE-Automation/Python/ole-automation-1.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import win32com.client +from win32com.server.util import wrap, unwrap +from win32com.server.dispatcher import DefaultDebugDispatcher +from ctypes import * +import commands +import pythoncom +import winerror +from win32com.server.exception import Exception + +clsid = "{55C2F76F-5136-4614-A397-12214CC011E5}" +iid = pythoncom.MakeIID(clsid) +appid = "python.server" + +class VeryPermissive: + def __init__(self): + self.data = [] + self.handle = 0 + self.dobjects = {} + def __del__(self): + pythoncom.RevokeActiveObject(self.handle) + def _dynamic_(self, name, lcid, wFlags, args): + if wFlags & pythoncom.DISPATCH_METHOD: + return getattr(self,name)(*args) + if wFlags & pythoncom.DISPATCH_PROPERTYGET: + try: + # to avoid problems with byref param handling, tuple results are converted to lists. + ret = self.__dict__[name] + if type(ret)==type(()): + ret = list(ret) + return ret + except KeyError: # Probably a method request. + raise Exception(scode=winerror.DISP_E_MEMBERNOTFOUND) + if wFlags & (pythoncom.DISPATCH_PROPERTYPUT | pythoncom.DISPATCH_PROPERTYPUTREF): + setattr(self, name, args[0]) + return + raise Exception(scode=winerror.E_INVALIDARG, desc="invalid wFlags") + def write(self, x): + print x + return 0 +import win32com.server.util, win32com.server.policy +child = VeryPermissive() +ob = win32com.server.util.wrap(child, usePolicy=win32com.server.policy.DynamicPolicy) +try: + handle = pythoncom.RegisterActiveObject(ob, iid, 0) +except pythoncom.com_error, details: + print "Warning - could not register the object in the ROT:", details + handle = None +child.handle = handle + +ahk = win32com.client.Dispatch("ahkdemo.ahk") +ahk.aRegisterIDs(clsid, appid) +# autohotkey.exe ahkside.ahk +# python /c/Python26/Scripts/ipython.py -wthread -i pythonside.py +# must use -wthread otherwise calling com client hangs diff --git a/Task/OLE-Automation/Python/ole-automation-2.py b/Task/OLE-Automation/Python/ole-automation-2.py new file mode 100644 index 0000000000..44a59204db --- /dev/null +++ b/Task/OLE-Automation/Python/ole-automation-2.py @@ -0,0 +1,3 @@ +import win32com.client +client = win32com.client.Dispatch("python.server") +client.write("hello world") diff --git a/Task/Object-serialization/0DESCRIPTION b/Task/Object-serialization/0DESCRIPTION new file mode 100644 index 0000000000..97e17ad32d --- /dev/null +++ b/Task/Object-serialization/0DESCRIPTION @@ -0,0 +1 @@ +Create a set of data types based upon [[inheritance]]. Each data type or class should have a print command that displays the contents of an instance of that class to standard output. Create instances of each class in your inheritance hierarchy and display them to standard output. Write each of the objects to a file named ''objects.dat'' in binary form using serialization or marshalling. Read the file ''objects.dat'' and print the contents of each serialized object. diff --git a/Task/Object-serialization/1META.yaml b/Task/Object-serialization/1META.yaml new file mode 100644 index 0000000000..43afe9a8b6 --- /dev/null +++ b/Task/Object-serialization/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Object oriented diff --git a/Task/Object-serialization/ALGOL-68/object-serialization.alg b/Task/Object-serialization/ALGOL-68/object-serialization.alg new file mode 100644 index 0000000000..17897cb4a0 --- /dev/null +++ b/Task/Object-serialization/ALGOL-68/object-serialization.alg @@ -0,0 +1,29 @@ +MODE ENTITY = STRUCT([6]CHAR name, INT creation); +FORMAT entity repr = $"Name: "g", Created:"g$; +MODE PERSON = STRUCT(ENTITY entity, STRING email); +FORMAT person repr = $f(entity repr)", Email: "g$; + +PERSON instance1 := PERSON(ENTITY("Cletus", 20080808), "test+1@localhost.localdomain"); +print((name OF entity OF instance1, new line)); + +ENTITY instance2 := ENTITY("Entity",20111111); +print((name OF instance2, new line)); + +FILE target; +INT errno := open(target, "rows.dat", stand back channel); # open file # + +# Serialise # +put(target,(instance1, new line, instance2, new line)); +printf(($"Serialised..."l$)); + +close(target); # flush file stream # +errno := open(target, "rows.dat", stand back channel); # load again # + +# Unserialise # +PERSON i1; +ENTITY i2; +get(target,(i1, new line, i2, new line)); +printf(($"Unserialised..."l$)); + +printf((person repr, i1, $l$)); +printf((entity repr, i2, $l$)) diff --git a/Task/Object-serialization/Ada/object-serialization-1.ada b/Task/Object-serialization/Ada/object-serialization-1.ada new file mode 100644 index 0000000000..4f07035594 --- /dev/null +++ b/Task/Object-serialization/Ada/object-serialization-1.ada @@ -0,0 +1,25 @@ +with Ada.Calendar; use Ada.Calendar; + +package Messages is + type Message is tagged record + Timestamp : Time; + end record; + + procedure Print(Item : Message); + procedure Display(Item : Message'Class); + + type Sensor_Message is new Message with record + Sensor_Id : Integer; + Reading : Float; + end record; + + procedure Print(Item : Sensor_Message); + + type Control_Message is new Message with record + Actuator_Id : Integer; + Command : Float; + end record; + + procedure Print(Item : Control_Message); + +end Messages; diff --git a/Task/Object-serialization/Ada/object-serialization-2.ada b/Task/Object-serialization/Ada/object-serialization-2.ada new file mode 100644 index 0000000000..43c24a4ffe --- /dev/null +++ b/Task/Object-serialization/Ada/object-serialization-2.ada @@ -0,0 +1,68 @@ +with Ada.Text_Io; use Ada.Text_Io; +with Ada.Integer_Text_Io; use Ada.Integer_Text_Io; +with Ada.Float_Text_IO; use Ada.Float_Text_IO; + +package body Messages is + + ----------- + -- Print -- + ----------- + + procedure Print (Item : Message) is + The_Year : Year_Number; + The_Month : Month_Number; + The_Day : Day_Number; + Seconds : Day_Duration; + begin + Split(Date => Item.Timestamp, Year => The_Year, + Month => The_Month, Day => The_Day, Seconds => Seconds); + + Put("Time Stamp:"); + Put(Item => The_Year, Width => 4); + Put("-"); + Put(Item => The_Month, Width => 1); + Put("-"); + Put(Item => The_Day, Width => 1); + New_Line; + end Print; + + ----------- + -- Print -- + ----------- + + procedure Print (Item : Sensor_Message) is + begin + Print(Message(Item)); + Put("Sensor Id: "); + Put(Item => Item.Sensor_Id, Width => 1); + New_Line; + Put("Reading: "); + Put(Item => Item.Reading, Fore => 1, Aft => 4, Exp => 0); + New_Line; + end Print; + + ----------- + -- Print -- + ----------- + + procedure Print (Item : Control_Message) is + begin + Print(Message(Item)); + Put("Actuator Id: "); + Put(Item => Item.Actuator_Id, Width => 1); + New_Line; + Put("Command: "); + Put(Item => Item.Command, Fore => 1, Aft => 4, Exp => 0); + New_Line; + end Print; + + ------------- + ---Display -- + ------------- + + procedure Display(Item : Message'Class) is + begin + Print(Item); + end Display; + +end Messages; diff --git a/Task/Object-serialization/Ada/object-serialization-3.ada b/Task/Object-serialization/Ada/object-serialization-3.ada new file mode 100644 index 0000000000..020cf78446 --- /dev/null +++ b/Task/Object-serialization/Ada/object-serialization-3.ada @@ -0,0 +1,40 @@ +with Messages; use Messages; +with Ada.Streams.Stream_Io; use Ada.Streams.Stream_Io; +with Ada.Calendar; use Ada.Calendar; +with Ada.Text_Io; + +procedure Streams_Example is + S1 : Sensor_Message; + M1 : Message; + C1 : Control_Message; + Now : Time := Clock; + The_File : Ada.Streams.Stream_Io.File_Type; + The_Stream : Ada.Streams.Stream_IO.Stream_Access; +begin + S1 := (Now, 1234, 0.025); + M1.Timestamp := Now; + C1 := (Now, 15, 0.334); + Display(S1); + Display(M1); + Display(C1); + begin + Open(File => The_File, Mode => Out_File, + Name => "Messages.dat"); + exception + when others => + Create(File => The_File, Name => "Messages.dat"); + end; + The_Stream := Stream(The_File); + Sensor_Message'Class'Output(The_Stream, S1); + Message'Class'Output(The_Stream, M1); + Control_Message'Class'Output(The_Stream, C1); + Close(The_File); + Open(File => The_File, Mode => In_File, + Name => "Messages.dat"); + The_Stream := Stream(The_File); + Ada.Text_Io.New_Line(2); + while not End_Of_File(The_File) loop + Display(Message'Class'Input(The_Stream)); + end loop; + Close(The_File); +end Streams_Example; diff --git a/Task/Object-serialization/C++/object-serialization.cpp b/Task/Object-serialization/C++/object-serialization.cpp new file mode 100644 index 0000000000..b0c9bb597d --- /dev/null +++ b/Task/Object-serialization/C++/object-serialization.cpp @@ -0,0 +1,118 @@ +#include +#include +#include +#include +#include +#include +#include + +class Employee { +public : + Employee( ) { } + + Employee ( const std::string &dep , const std::string &namen ) + : department( dep ) , name( namen ) { + my_id = count++ ; + } + + std::string getName( ) const { + return name ; + } + + std::string getDepartment( ) const { + return department ; + } + + int getId( ) const { + return my_id ; + } + + void setDepartment( const std::string &dep ) { + department.assign( dep ) ; + } + + virtual void print( ) { + std::cout << "Name: " << name << '\n' ; + std::cout << "Id: " << my_id << '\n' ; + std::cout << "Department: " << department << '\n' ; + } + + virtual ~Employee( ) { } + static int count ; +private : + std::string name ; + std::string department ; + int my_id ; + friend class boost::serialization::access ; + + template + void serialize( Archive &ar, const unsigned int version ) { + ar & my_id ; + ar & name ; + ar & department ; + } + +} ; + +class Worker : public Employee { +public : + Worker( const std::string & dep, const std::string &namen , + double hourlyPay ) : Employee( dep , namen ) , salary( hourlyPay) { } + + Worker( ) { } + + double getSalary( ) { + return salary ; + } + + void setSalary( double pay ) { + if ( pay > 0 ) + salary = pay ; + } + + virtual void print( ) { + Employee::print( ) ; + std::cout << "wage per hour: " << salary << '\n' ; + } +private : + double salary ; + friend class boost::serialization::access ; + template + void serialize ( Archive & ar, const unsigned int version ) { + ar & boost::serialization::base_object( *this ) ; + ar & salary ; + } +} ; + +int Employee::count = 0 ; + +int main( ) { + std::ofstream storefile( "/home/ulrich/objects.dat" ) ; //creating objects of base class + const Employee emp1( "maintenance" , "Fritz Schmalstieg" ) ; + const Employee emp2( "maintenance" , "John Berry" ) ; + const Employee emp3( "repair" , "Pawel Lichatschow" ) ; + const Employee emp4( "IT" , "Marian Niculescu" ) ; + const Worker worker1( "maintenance" , "Laurent Le Chef" , 20 ) ;//creating objects of derived class + const Worker worker2 ( "IT" , "Srinivan Taraman" , 55.35 ) ; + boost::archive::text_oarchive oar ( storefile ) ;//starting serialization into designated file + oar << emp1 ; + oar << emp2 ; + oar << emp3 ; + oar << emp4 ; + oar << worker1 ; + oar << worker2 ; + storefile.close( ) ; + std::cout << "Reading out the data again\n" ; + Employee e1 , e2 , e3 , e4 ; //creating instances of base class objects for deserialization + Worker w1, w2 ; // same for objects of derived class + std::ifstream sourcefile( "/home/ulrich/objects.dat" ) ; + boost::archive::text_iarchive iar( sourcefile ) ;//starting deserialization + iar >> e1 >> e2 >> e3 >> e4 ; + iar >> w1 >> w2 ; + sourcefile.close( ) ; + std::cout << "And here are the data after deserialization!( abridged):\n" ; + e1.print( ) ; + e3.print( ) ; + w2.print( ) ; + return 0 ; +} diff --git a/Task/Object-serialization/Common-Lisp/object-serialization-1.lisp b/Task/Object-serialization/Common-Lisp/object-serialization-1.lisp new file mode 100644 index 0000000000..afe24bb0de --- /dev/null +++ b/Task/Object-serialization/Common-Lisp/object-serialization-1.lisp @@ -0,0 +1,12 @@ +(defmacro with-serialization-to-file ((stream pathname) &body body) + `(with-open-file (,stream ,pathname + :element-type '(unsigned-byte 8) + :direction :output + :if-exists :supersede) + ,@body)) + +(defclass entity () + ((name :initarg :name :initform "Some entity"))) + +(defclass person (entity) + ((name :initarg :name :initform "The Nameless One"))) diff --git a/Task/Object-serialization/Common-Lisp/object-serialization-2.lisp b/Task/Object-serialization/Common-Lisp/object-serialization-2.lisp new file mode 100644 index 0000000000..90fd40764c --- /dev/null +++ b/Task/Object-serialization/Common-Lisp/object-serialization-2.lisp @@ -0,0 +1,35 @@ +CL-USER> (list (make-instance 'entity) + (make-instance 'person)) + +(# #) +CL-USER> (mapc #'describe *) +# + [standard-object] + +Slots with :INSTANCE allocation: + NAME = "Some entity" +# + [standard-object] + +Slots with :INSTANCE allocation: + NAME = "The Nameless One" +(# #) +CL-USER> (with-serialization-to-file (stream "/tmp/objects.dat") + (cl-serializer:serialize * :output stream) + ;; SERIALIZE shows an octet-vector as its return value + (values)) +; No value +CL-USER> (mapc #'describe (with-open-file (stream "/tmp/objects.dat" + :element-type '(unsigned-byte 8)) + (cl-serializer:deserialize stream))) +# + [standard-object] + +Slots with :INSTANCE allocation: + NAME = "Some entity" +# + [standard-object] + +Slots with :INSTANCE allocation: + NAME = "The Nameless One" +(# #) diff --git a/Task/Object-serialization/D/object-serialization.d b/Task/Object-serialization/D/object-serialization.d new file mode 100644 index 0000000000..ea6d1b9ed4 --- /dev/null +++ b/Task/Object-serialization/D/object-serialization.d @@ -0,0 +1,35 @@ +import test1; +import std.stdio; +import std.file; +class full2:base2 { + this(byte[]manip,bool isroot=true) {super(manip,isroot);} + this(){super();} + void print() { + foreach(item;rep) { + writefln(item.i32); + } + } +} + +void main() { + full2 base = new full2(); + base1 tmp = new base1; + tmp.i32 = 34; + base.add_rep(tmp); + tmp = new base1; + tmp.i32 = 32; + base.add_rep(tmp); + tmp = new base1; + tmp.i32 = 33; + base.add_rep(tmp); + tmp = new base1; + tmp.i32 = 36; + base.add_rep(tmp); + writefln("Input data:"); + base.print; + write("objects.dat",base.Serialize()); + byte[]filedata = cast(byte[])read("objects.dat"); + base = new full2(filedata); + writefln("Output data:"); + base.print; +} diff --git a/Task/Object-serialization/E/object-serialization-1.e b/Task/Object-serialization/E/object-serialization-1.e new file mode 100644 index 0000000000..9fd0b18727 --- /dev/null +++ b/Task/Object-serialization/E/object-serialization-1.e @@ -0,0 +1,21 @@ +def makeEvent(time :int) { + return def event { + to __printOn(out) { out.print(`@@$time`) } + to __optUncall() { return [makeEvent, "run", [time]] } + to getTime() { return time } + } +} + +def makeArrival(time :int, what :any, position :int) { + return def arrival extends makeEvent(time) { + to __printOn(out) { + out.print(`$what to $position $super`) + } + to __optUncall() { + return [makeArrival, "run", [time, what, position]] + } + + to getWhat() { return what } + to getPosition() { return position } + } +} diff --git a/Task/Object-serialization/E/object-serialization-2.e b/Task/Object-serialization/E/object-serialization-2.e new file mode 100644 index 0000000000..11100749e1 --- /dev/null +++ b/Task/Object-serialization/E/object-serialization-2.e @@ -0,0 +1,3 @@ +def surgeon := ().diverge() +surgeon.addExit(makeEvent, "makeEvent") +surgeon.addExit(makeArrival, "makeArrival") diff --git a/Task/Object-serialization/E/object-serialization-3.e b/Task/Object-serialization/E/object-serialization-3.e new file mode 100644 index 0000000000..8409819fcd --- /dev/null +++ b/Task/Object-serialization/E/object-serialization-3.e @@ -0,0 +1,6 @@ +def objs := [makeEvent(timer.now()), + makeArrival(timer.now(), "Smith", 7)] + +stdout.println(objs) +.setBytes(surgeon.serialize(objs)) +stdout.println(surgeon.unserialize(.getBytes())) diff --git a/Task/Object-serialization/Go/object-serialization.go b/Task/Object-serialization/Go/object-serialization.go new file mode 100644 index 0000000000..fedd589b50 --- /dev/null +++ b/Task/Object-serialization/Go/object-serialization.go @@ -0,0 +1,154 @@ +package main + +import ( + "encoding/gob" + "fmt" + "os" +) + +type printable interface { + print() +} + +func main() { + // create instances + animals := []printable{ + &Animal{Alive: true}, + &Cat{}, + &Lab{ + Dog: Dog{Animal: Animal{Alive: true}}, + Color: "yellow", + }, + &Collie{Dog: Dog{ + Animal: Animal{Alive: true}, + ObedienceTrained: true, + }}, + } + + // display + fmt.Println("created:") + for _, a := range animals { + a.print() + } + + // serialize + f, err := os.Create("objects.dat") + if err != nil { + fmt.Println(err) + return + } + for _, a := range animals { + gob.Register(a) + } + err = gob.NewEncoder(f).Encode(animals) + if err != nil { + fmt.Println(err) + return + } + f.Close() + + // read + f, err = os.Open("objects.dat") + if err != nil { + fmt.Println(err) + return + } + var clones []printable + gob.NewDecoder(f).Decode(&clones) + if err != nil { + fmt.Println(err) + return + } + + // display + fmt.Println("\nloaded from objects.dat:") + for _, c := range clones { + c.print() + } +} + +type Animal struct { + Alive bool +} + +func (a *Animal) print() { + if a.Alive { + fmt.Println(" live animal, unspecified type") + } else { + fmt.Println(" dead animal, unspecified type") + } +} + +type Dog struct { + Animal + ObedienceTrained bool +} + +func (d *Dog) print() { + switch { + case !d.Alive: + fmt.Println(" dead dog") + case d.ObedienceTrained: + fmt.Println(" trained dog") + default: + fmt.Println(" dog, not trained") + } +} + +type Cat struct { + Animal + LitterBoxTrained bool +} + +func (c *Cat) print() { + switch { + case !c.Alive: + fmt.Println(" dead cat") + case c.LitterBoxTrained: + fmt.Println(" litter box trained cat") + default: + fmt.Println(" cat, not litter box trained") + } +} + +type Lab struct { + Dog + Color string +} + +func (l *Lab) print() { + var r string + if l.Color == "" { + r = "lab, color unspecified" + } else { + r = l.Color + " lab" + } + switch { + case !l.Alive: + fmt.Println(" dead", r) + case l.ObedienceTrained: + fmt.Println(" trained", r) + default: + fmt.Printf(" %s, not trained\n", r) + } +} + +type Collie struct { + Dog + CatchesFrisbee bool +} + +func (c *Collie) print() { + switch { + case !c.Alive: + fmt.Println(" dead collie") + case c.ObedienceTrained && c.CatchesFrisbee: + fmt.Println(" trained collie, catches frisbee") + case c.ObedienceTrained && !c.CatchesFrisbee: + fmt.Println(" trained collie, but doesn't catch frisbee") + case !c.ObedienceTrained && c.CatchesFrisbee: + fmt.Println(" collie, not trained, but catches frisbee") + case !c.ObedienceTrained && !c.CatchesFrisbee: + fmt.Println(" collie, not trained, doesn't catch frisbee") + } +} diff --git a/Task/Object-serialization/Groovy/object-serialization-1.groovy b/Task/Object-serialization/Groovy/object-serialization-1.groovy new file mode 100644 index 0000000000..fe0f3159f1 --- /dev/null +++ b/Task/Object-serialization/Groovy/object-serialization-1.groovy @@ -0,0 +1,11 @@ +class Entity implements Serializable { + static final serialVersionUID = 3504465751164822571L + String name = 'Thingamabob' + public String toString() { return name } +} + +class Person extends Entity implements Serializable { + static final serialVersionUID = -9170445713373959735L + Person() { name = 'Clement' } + Person(name) { this.name = name } +} diff --git a/Task/Object-serialization/Groovy/object-serialization-2.groovy b/Task/Object-serialization/Groovy/object-serialization-2.groovy new file mode 100644 index 0000000000..b69b9fc0b5 --- /dev/null +++ b/Task/Object-serialization/Groovy/object-serialization-2.groovy @@ -0,0 +1,19 @@ +File objectStore = new File('objectStore.ser') +if (objectStore.exists()) { objectStore.delete() } +assert ! objectStore.exists() +def os +try { + os = objectStore.newObjectOutputStream() + os << new Person() + os << 10.5 + os << new Person('Cletus') + os << new Date() + os << new Person('Pious') + os << java.awt.Color.RED + os << new Person('Linus') + os << 'just random garbage' + os << new Person('Lucy') + os << ['lists', 'are', 'serializable'] + os << new Person('Schroeder') +} catch (e) { throw new Exception(e) } finally { os?.close() } +assert objectStore.exists() diff --git a/Task/Object-serialization/Groovy/object-serialization-3.groovy b/Task/Object-serialization/Groovy/object-serialization-3.groovy new file mode 100644 index 0000000000..ab3ec5881a --- /dev/null +++ b/Task/Object-serialization/Groovy/object-serialization-3.groovy @@ -0,0 +1,8 @@ +def is +try { + is = objectStore.newObjectInputStream(this.class.classLoader) + is.eachObject { println it } +} catch (e) { throw new Exception(e) } finally { is?.close() } + +objectStore.delete() +assert ! objectStore.exists() diff --git a/Task/Object-serialization/J/object-serialization-1.j b/Task/Object-serialization/J/object-serialization-1.j new file mode 100644 index 0000000000..f40b98a25a --- /dev/null +++ b/Task/Object-serialization/J/object-serialization-1.j @@ -0,0 +1,41 @@ +lin_z_=:5!:5 +serializeObject=:3 :0 + p=. copath y + d=. ;LF;"1(,'=:';lin__y)"0 nl__y i.4 + '(',(5!:5<'p'),')(copath[cocurrent@])cocreate ''''',,d,LF +) + +deserializeObject=:3 :0 + o=.conl 1 + 0!:100 y + (conl 1)-.o +) + +coclass'room' + create=:3 :'size=:y' + print=:3 :'''room size '',":size' + +coclass'kitchen' + coinsert'room' + print=:3 :'''kitchen size '',":size' + +coclass'kitchenWithSink' + coinsert'kitchen' + print=:3 :'''kitchen with sink size '',":size' + +cocurrent'base' + +R=:'small' conew 'room' +K=:'medium' conew 'kitchen' +S=:'large' conew 'kitchenWithSink' +print__R'' +print__K'' +print__S'' + + +(;<@serializeObject"0 R,K,S) 1!:2 <'objects.dat' + +'r1 k1 s1'=: <"0 deserializeObject 1!:1<'objects.dat' +print__r1'' +print__k1'' +print__s1'' diff --git a/Task/Object-serialization/J/object-serialization-2.j b/Task/Object-serialization/J/object-serialization-2.j new file mode 100644 index 0000000000..7a0f180a86 --- /dev/null +++ b/Task/Object-serialization/J/object-serialization-2.j @@ -0,0 +1,17 @@ + print__R'' +room size small + print__K'' +kitchen size medium + print__S'' +kitchen with sink size large + + + (;<@serializeObject"0 R,K,S) 1!:2 <'objects.dat' + + 'r1 k1 s1'=: <"0 deserializeObject 1!:1<'objects.dat' + print__r1'' +room size small + print__k1'' +kitchen size medium + print__s1'' +kitchen with sink size large diff --git a/Task/Object-serialization/Java/object-serialization.java b/Task/Object-serialization/Java/object-serialization.java new file mode 100644 index 0000000000..4f07423b8d --- /dev/null +++ b/Task/Object-serialization/Java/object-serialization.java @@ -0,0 +1,60 @@ +import java.io.*; + +// classes must implement java.io.Serializable in order to be serializable +class Entity implements Serializable { + // it is recommended to hard-code serialVersionUID so changes to class + // will not invalidate previously serialized objects + static final long serialVersionUID = 3504465751164822571L; + String name = "Entity"; + public String toString() { return name; } +} + +class Person extends Entity implements Serializable { + static final long serialVersionUID = -9170445713373959735L; + Person() { name = "Cletus"; } +} + +public class SerializationTest { + public static void main(String[] args) { + Person instance1 = new Person(); + System.out.println(instance1); + + Entity instance2 = new Entity(); + System.out.println(instance2); + + // Serialize + try { + ObjectOutput out = new ObjectOutputStream(new FileOutputStream("objects.dat")); // open ObjectOutputStream + + out.writeObject(instance1); // serialize "instance1" and "instance2" to "out" + out.writeObject(instance2); + out.close(); + System.out.println("Serialized..."); + } catch (IOException e) { + System.err.println("Something screwed up while serializing"); + e.printStackTrace(); + System.exit(1); + } + + // Deserialize + try { + ObjectInput in = new ObjectInputStream(new FileInputStream("objects.dat")); // open ObjectInputStream + + Object readObject1 = in.readObject(); // read two objects from "in" + Object readObject2 = in.readObject(); // you may want to cast them to the appropriate types + in.close(); + System.out.println("Deserialized..."); + + System.out.println(readObject1); + System.out.println(readObject2); + } catch (IOException e) { + System.err.println("Something screwed up while deserializing"); + e.printStackTrace(); + System.exit(1); + } catch (ClassNotFoundException e) { + System.err.println("Unknown class for deserialized object"); + e.printStackTrace(); + System.exit(1); + } + } +} diff --git a/Task/Object-serialization/OCaml/object-serialization.ocaml b/Task/Object-serialization/OCaml/object-serialization.ocaml new file mode 100644 index 0000000000..516a3c0148 --- /dev/null +++ b/Task/Object-serialization/OCaml/object-serialization.ocaml @@ -0,0 +1,23 @@ +type entity = { name : string } + +let create_entity () = { name = "Entity" } +let print_entity x = print_endline x.name +let create_person () = { name = "Cletus" } + +let instance1 = create_person () +let instance2 = create_entity () + +(* Serialize *) +let out_chan = open_out_bin "objects.dat";; +output_value out_chan instance1;; +output_value out_chan instance2;; +close_out out_chan;; + +(* Deserialize *) +let in_chan = open_in_bin "objects.dat";; +let result1 : entity = input_value in_chan;; +let result2 : entity = input_value in_chan;; +close_in in_chan;; + +print_entity result1;; +print_entity result2;; diff --git a/Task/Object-serialization/Objeck/object-serialization.objeck b/Task/Object-serialization/Objeck/object-serialization.objeck new file mode 100644 index 0000000000..308a4b04b3 --- /dev/null +++ b/Task/Object-serialization/Objeck/object-serialization.objeck @@ -0,0 +1,50 @@ +bundle Default { + class Thingy { + @id : Int; + + New(id : Int) { + @id := id; + } + + method : public : Print() ~ Nil { + @id->PrintLine(); + } + } + + class Person from Thingy { + @name : String; + + New(id : Int, name : String) { + Parent(id); + @name := name; + } + + method : public : Print() ~ Nil { + @id->PrintLine(); + @name->PrintLine(); + } + } + + class Serial { + function : Main(args : String[]) ~ Nil { + t := Thingy->New(7); + p := Person->New(13, "Bush"); + + s := IO.Serializer->New(); + s->Write(t->As(Base)); + s->Write(p->As(Base)); + + writer := IO.FileWriter->New("objects.dat"); + writer->WriteBuffer(s->Serialize()); + writer->Close(); + + buffer := IO.FileReader->ReadBinaryFile("objects.dat"); + d := IO.Deserializer->New(buffer); + + t2 := d->ReadObject()->As(Thingy); + t2->Print(); + p2 := d->ReadObject()->As(Person); + p2->Print(); + } + } +} diff --git a/Task/Object-serialization/Objective-C/object-serialization.m b/Task/Object-serialization/Objective-C/object-serialization.m new file mode 100644 index 0000000000..679b23ad86 --- /dev/null +++ b/Task/Object-serialization/Objective-C/object-serialization.m @@ -0,0 +1,185 @@ +#import + +// a fantasy two level hierarchy +@interface Animal : NSObject +{ + NSString *animalName; + int numberOfLegs; +} +- (id) initWithName: (NSString*)name andLegs: (NSInteger)legs; +- (void) dump; +// the following allows "(de)archiving" of the object +- (void) encodeWithCoder: (NSCoder*)coder; +- (id) initWithCoder: (NSCoder*)coder; +@end + +@implementation Animal +- (id) initWithName: (NSString*)name andLegs: (NSInteger)legs +{ + if ((self = [super init])) { + animalName = [name retain]; + numberOfLegs = legs; + } + return self; +} +- (void) dealloc +{ + [animalName release]; + [super dealloc]; +} +- (void) dump +{ + NSLog(@"%@ has %d legs", animalName, numberOfLegs); +} +// ======== +- (void) encodeWithCoder: (NSCoder*)coder +{ + [coder encodeObject: animalName forKey: @"Animal.name"]; + [coder encodeInt: numberOfLegs forKey: @"Animal.legs"]; +} +- (id) initWithCoder: (NSCoder*)coder +{ + if ((self = [super init])) { + animalName = [[coder decodeObjectForKey: @"Animal.name"] retain]; + numberOfLegs = [coder decodeIntForKey: @"Animal.legs"]; + } + return self; +} +@end + +@interface Mammal : Animal +{ + BOOL hasFur; + NSMutableArray *eatenList; +} +- (id) initWithName: (NSString*)name hasFur: (BOOL)fur; +- (void) addEatenThing: (NSString*)thing; +- (void) dump; +// for archiving / dearchiving: +- (void) encodeWithCoder: (NSCoder*)coder; +- (id) initWithCoder: (NSCoder*)coder; +@end + +@implementation Mammal +- (id) init +{ + if ((self = [super init])) { + hasFur = NO; + eatenList = [[NSMutableArray alloc] initWithCapacity: 10]; + } + return self; +} +- (id) initWithName: (NSString*)name hasFur: (BOOL)fur +{ + if ((self = [super initWithName: name andLegs: 4])) { + hasFur = fur; + eatenList = [[NSMutableArray alloc] initWithCapacity: 10]; + } + return self; +} +- (void) addEatenThing: (NSString*)thing +{ + [eatenList addObject: thing]; +} +- (void) dealloc +{ + [eatenList release]; + [super dealloc]; +} +- (void) dump +{ + [super dump]; + NSLog(@"has fur? %@", (hasFur) ? @"yes" : @"no" ); + // fast enum not implemented yet in gcc 4.3, at least + // without a patch that it seems to exist... + NSEnumerator *en = [eatenList objectEnumerator]; + id element; + NSLog(@"it has eaten %d things:", [eatenList count]); + while( (element = [en nextObject]) != nil ) + NSLog(@"it has eaten a %@", element); + NSLog(@"end of eaten things list"); +} +// ========= de/archiving +- (void) encodeWithCoder: (NSCoder*)coder +{ + [super encodeWithCoder: coder]; + [coder encodeBool: numberOfLegs forKey: @"Mammal.hasFur"]; + [coder encodeObject: eatenList forKey: @"Mammal.eaten"]; +} +- (id) initWithCoder: (NSCoder*)coder +{ + if ((self = [super initWithCoder: coder])) { + hasFur = [coder decodeBoolForKey: @"Mammal.hasFur"]; + eatenList = [[coder decodeObjectForKey: @"Mammal.eaten"] retain]; + } + return self; +} +@end + + +int main() +{ + Mammal *aMammal; + Animal *anAnimal; + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + // let us create a fantasy animal + anAnimal = [[Animal alloc] + initWithName: @"Eptohippos" + andLegs: 7 + ]; + // for some reason an Eptohippos is not an horse with 7 legs, + // and it is not a mammal, of course... + + // let us create a fantasy mammal (which is an animal too) + aMammal = [[Mammal alloc] + initWithName: @"Mammaluc" + hasFur: YES + ]; + // let us add some eaten stuff... + [aMammal addEatenThing: @"lamb"]; + [aMammal addEatenThing: @"table"]; + [aMammal addEatenThing: @"web page"]; + + // dump anAnimal + NSLog(@"----- original Animal -----"); + [anAnimal dump]; + + // dump aMammal... + NSLog(@"----- original Mammal -----"); + [aMammal dump]; + + // now let us store the objects... + NSMutableData *data = [[NSMutableData alloc] init]; + NSKeyedArchiver *arch = [[NSKeyedArchiver alloc] + initForWritingWithMutableData: data]; + [arch encodeObject: anAnimal forKey: @"Eptohippos"]; + [arch encodeObject: aMammal forKey: @"Mammaluc"]; + [anAnimal release]; + [aMammal release]; + [arch finishEncoding]; + [arch release]; + [data writeToFile: @"objects.dat" atomically: YES]; + [data release]; + + // now we want to retrieve the saved objects... + NSData *ldata = [[NSData alloc] + initWithContentsOfFile: @"objects.dat"]; + NSKeyedUnarchived *darch = [[NSKeyedUnarchiver alloc] + initForReadingWithData: ldata]; + Animal *archivedAnimal = [darch decodeObjectForKey: @"Eptohippos"]; + Mammal *archivedMammal = [darch decodeObjectForKey: @"Mammaluc"]; + [darch finishDecoding]; + [ldata release]; + [darch release]; + + // now let's dump/print the objects... + NSLog(@"\n"); + NSLog(@"----- the archived Animal -----"); + [archivedAnimal dump]; + NSLog(@"----- the archived Mammal -----"); + [archivedMammal dump]; + + [pool release]; + return EXIT_SUCCESS; +} diff --git a/Task/Object-serialization/PHP/object-serialization.php b/Task/Object-serialization/PHP/object-serialization.php new file mode 100644 index 0000000000..3be6bb10c2 --- /dev/null +++ b/Task/Object-serialization/PHP/object-serialization.php @@ -0,0 +1,2 @@ +$myObj = new Object(); +$serializedObj = serialize($myObj); diff --git a/Task/Object-serialization/Perl/object-serialization-1.pl b/Task/Object-serialization/Perl/object-serialization-1.pl new file mode 100644 index 0000000000..883f45f5e1 --- /dev/null +++ b/Task/Object-serialization/Perl/object-serialization-1.pl @@ -0,0 +1,35 @@ +{ + package Greeting; + sub new { + my $v = "Hello world!\n"; + bless \$v, shift; + }; + sub stringify { + ${shift()}; + }; +}; +{ + package Son::of::Greeting; + use base qw(Greeting); # inherit methods + sub new { # overwrite method of super class + my $v = "Hello world from Junior!\n"; + bless \$v, shift; + }; +}; +{ + use Storable qw(store retrieve); + package main; + my $g1 = Greeting->new; + my $s1 = Son::of::Greeting->new; + print $g1->stringify; + print $s1->stringify; + + store $g1, 'objects.dat'; + my $g2 = retrieve 'objects.dat'; + + store $s1, 'objects.dat'; + my $s2 = retrieve 'objects.dat'; + + print $g2->stringify; + print $s2->stringify; +}; diff --git a/Task/Object-serialization/Perl/object-serialization-2.pl b/Task/Object-serialization/Perl/object-serialization-2.pl new file mode 100644 index 0000000000..e50cf05bb9 --- /dev/null +++ b/Task/Object-serialization/Perl/object-serialization-2.pl @@ -0,0 +1,25 @@ +use MooseX::Declare; + +class Greeting { + use MooseX::Storage; + with Storage('format' => 'JSON', io => 'File'); + has string => (is => 'ro', default => "Hello world!\n"); +} +class Son::Of::Greeting extends Greeting { + has string => (is => 'ro', default => "Hello from Junior!\n"); +} + +my $g1 = Greeting->new; +my $s1 = Son::Of::Greeting->new; + +print $g1->string; +print $s1->string; + +$g1->store('object1.json'); +my $g2 = Greeting->load('object1.json'); + +$s1->store('object2.json'); +my $s2 = Son::Of::Greeting->load('object2.json'); + +print $g2->string; +print $s2->string; diff --git a/Task/Object-serialization/PicoLisp/object-serialization-1.l b/Task/Object-serialization/PicoLisp/object-serialization-1.l new file mode 100644 index 0000000000..3e5de1a9e2 --- /dev/null +++ b/Task/Object-serialization/PicoLisp/object-serialization-1.l @@ -0,0 +1,30 @@ +(class +Point) +# x y + +(dm T (X Y) + (=: x (or X 0)) + (=: y (or Y 0)) ) + +(dm print> () + (prinl "Point " (: x) "," (: y)) ) + +(class +Circle +Point) +# r + +(dm T (X Y R) + (super X Y) + (=: r (or R 0)) ) + +(dm print> () + (prinl "Circle " (: x) "," (: y) "," (: r)) ) + +(setq + P (new '(+Point) 3 4) + C (new '(+Circle) 10 10 5) ) + +(print> P) +(print> C) + +(out "objects.dat" + (pr (val P) (getl P)) + (pr (val C) (getl C)) ) diff --git a/Task/Object-serialization/PicoLisp/object-serialization-2.l b/Task/Object-serialization/PicoLisp/object-serialization-2.l new file mode 100644 index 0000000000..1e9e561bbc --- /dev/null +++ b/Task/Object-serialization/PicoLisp/object-serialization-2.l @@ -0,0 +1,6 @@ +(in "objects.dat" + (putl (setq A (box (rd))) (rd)) + (putl (setq B (box (rd))) (rd)) ) + +(print> A) +(print> B) diff --git a/Task/Object-serialization/Python/object-serialization.py b/Task/Object-serialization/Python/object-serialization.py new file mode 100644 index 0000000000..4ad7458567 --- /dev/null +++ b/Task/Object-serialization/Python/object-serialization.py @@ -0,0 +1,37 @@ +# Object Serialization in Python +# serialization in python is accomplished via the Pickle module. +# Alternatively, one can use the cPickle module if speed is the key, +# everything else in this example remains the same. + +import pickle + +class Entity: + def __init__(self): + self.name = "Entity" + def printName(self): + print self.name + +class Person(Entity): #OldMan inherits from Entity + def __init__(self): #override constructor + self.name = "Cletus" + +instance1 = Person() +instance1.printName() + +instance2 = Entity() +instance2.printName() + +target = file("objects.dat", "w") # open file + +# Serialize +pickle.dump((instance1, instance2), target) # serialize `instance1` and `instance2`to `target` +target.close() # flush file stream +print "Serialized..." + +# Unserialize +target = file("objects.dat") # load again +i1, i2 = pickle.load(target) +print "Unserialized..." + +i1.printName() +i2.printName() diff --git a/Task/Object-serialization/Ruby/object-serialization.rb b/Task/Object-serialization/Ruby/object-serialization.rb new file mode 100644 index 0000000000..f7ef711f6d --- /dev/null +++ b/Task/Object-serialization/Ruby/object-serialization.rb @@ -0,0 +1,70 @@ +class Being + def initialize(specialty=nil) + @specialty=specialty + end + def to_s + "(object_id = #{object_id})\n"+"(#{self.class}):".ljust(12)+to_s4Being+(@specialty ? "\n"+" "*12+@specialty : "") + end + def to_s4Being + "I am a collection of cooperative molecules with a talent for self-preservation." + end +end + +class Earthling < Being + def to_s4Being + "I originate from a blue planet.\n"+" "*12+to_s4Earthling + end +end + +class Mammal < Earthling + def initialize(type) + @type=type + end + def to_s4Earthling + "I am champion in taking care of my offspring and eating everything I can find, except mammals of type #{@type}." + end +end + +class Fish < Earthling + def initialize(iq) + @iq=(iq>1 ? :instrustableValue : iq) + end + def to_s4Earthling + "Although I think I can think, I can't resist biting in hooks." + end +end + +class Moonling < Being + def to_s4Being + "My name is Janneke Maan, and apparently some Earthlings will pay me a visit." + end +end + +diverseCollection=[] +diverseCollection << (marsian=Being.new("I come from Mars and like playing hide and seek.")) +diverseCollection << (me=Mammal.new(:human)) +diverseCollection << (nemo=Fish.new(0.99)) +diverseCollection << (jannakeMaan=Moonling.new) + +puts "BEGIN ORIGINAL DIVERSE COLLECTION" +diverseCollection.each do |being| + puts "",being.to_s +end +puts "END ORIGINAL DIVERSE COLLECTION" +puts "\n"+"*"*50+"\n\n" + +#Marshal the diverse Array of beings +File.open('diverseCollection.bin','w') do |fo| + fo << Marshal.dump(diverseCollection) +end + +#load the Array of diverse beings +sameDiverseCollection=Marshal.load(File.read('diverseCollection.bin')) + +puts "BEGIN LOADED DIVERSE COLLECTION" +puts( + sameDiverseCollection.collect do |being| + being.to_s + end.join("\n\n") + ) +puts "END LOADED DIVERSE COLLECTION" diff --git a/Task/Object-serialization/Tcl/object-serialization.tcl b/Task/Object-serialization/Tcl/object-serialization.tcl new file mode 100644 index 0000000000..dc93dce66d --- /dev/null +++ b/Task/Object-serialization/Tcl/object-serialization.tcl @@ -0,0 +1,52 @@ +package require Tcl 8.6 +package require TclOO::serializer 0.1 + +# These classes are inspired by the Perl example +oo::class create Greeting { + superclass oo::serializable + variable v + constructor {} { + set v "Hello world!" + } + method get {} { + return $v + } +} +oo::class create SubGreeting { + superclass Greeting oo::serializable + variable v + constructor {} { + set v "Hello world from Junior!" + } +} +oo::class create GreetingsHolder { + superclass oo::serializable + variable o1 o2 + constructor {greeting1 greeting2} { + set o1 $greeting1 + set o2 $greeting2 + } + method printGreetings {} { + puts [$o1 get] + puts [$o2 get] + } + destructor { + $o1 destroy + $o2 destroy + } +} + +# Make some objects and store them +GreetingsHolder create holder [Greeting new] [SubGreeting new] +set f [open "objects.dat" w] +puts $f [oo::serialize holder] +close $f + +# Delete the objects +holder destroy + +# Recreate the objects from the file and show that they work +set f [open "objects.dat" r] +set obj [oo::deserialize [read $f]] +close $f +$obj printGreetings diff --git a/Task/One-dimensional-cellular-automata/0DESCRIPTION b/Task/One-dimensional-cellular-automata/0DESCRIPTION new file mode 100644 index 0000000000..5f77481137 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/0DESCRIPTION @@ -0,0 +1,13 @@ +Assume an array of cells with an initial distribution of live and dead cells, and imaginary cells off the end of the array having fixed values. + +Cells in the next generation of the array are calculated based on the value of the cell and its left and right nearest neighbours in the current generation. +If, in the following table, a live cell is represented by 1 and a dead cell by 0 then to generate the value of the cell at a particular index in the array of cellular values you use the following table: + + 0'''0'''0 -> 0 # + 0'''0'''1 -> 0 # + 0'''1'''0 -> 0 # Dies without enough neighbours + 0'''1'''1 -> 1 # Needs one neighbour to survive + 1'''0'''0 -> 0 # + 1'''0'''1 -> 1 # Two neighbours giving birth + 1'''1'''0 -> 1 # Needs one neighbour to survive + 1'''1'''1 -> 0 # Starved to death. diff --git a/Task/One-dimensional-cellular-automata/1META.yaml b/Task/One-dimensional-cellular-automata/1META.yaml new file mode 100644 index 0000000000..fe8c0bdcea --- /dev/null +++ b/Task/One-dimensional-cellular-automata/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Cellular automata +note: Games diff --git a/Task/One-dimensional-cellular-automata/ACL2/one-dimensional-cellular-automata.acl2 b/Task/One-dimensional-cellular-automata/ACL2/one-dimensional-cellular-automata.acl2 new file mode 100644 index 0000000000..1ea2d6c930 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/ACL2/one-dimensional-cellular-automata.acl2 @@ -0,0 +1,33 @@ +(defun rc-step-r (cells) + (if (endp (rest cells)) + nil + (cons (if (second cells) + (xor (first cells) (third cells)) + (and (first cells) (third cells))) + (rc-step-r (rest cells))))) + +(defun rc-step (cells) + (cons (and (first cells) (second cells)) + (rc-step-r cells))) + +(defun rc-steps-r (cells n prev) + (declare (xargs :measure (nfix n))) + (if (or (zp n) (equal cells prev)) + nil + (let ((new (rc-step cells))) + (cons new (rc-steps-r new (1- n) cells))))) + +(defun rc-steps (cells n) + (cons cells (rc-steps-r cells n nil))) + +(defun pretty-row (row) + (if (endp row) + (cw "~%") + (prog2$ (cw (if (first row) "#" "-")) + (pretty-row (rest row))))) + +(defun pretty-output (out) + (if (endp out) + nil + (prog2$ (pretty-row (first out)) + (pretty-output (rest out))))) diff --git a/Task/One-dimensional-cellular-automata/ALGOL-68/one-dimensional-cellular-automata-1.alg b/Task/One-dimensional-cellular-automata/ALGOL-68/one-dimensional-cellular-automata-1.alg new file mode 100644 index 0000000000..d98da0f3d1 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/ALGOL-68/one-dimensional-cellular-automata-1.alg @@ -0,0 +1,43 @@ +INT stop generation = 9; +INT universe width = 20; +FORMAT alive or dead = $b("#","_")$; + +BITS universe := 2r01110110101010100100; + # universe := BIN ( ENTIER ( random * max int ) ); # +INT upb universe = bits width; +INT lwb universe = bits width - universe width + 1; + +PROC couple = (BITS parent, INT lwb, upb)BOOL: ( + SHORT INT sum := 0; + FOR bit FROM lwb TO upb DO + sum +:= ABS (bit ELEM parent) + OD; + sum = 2 +); + +FOR generation FROM 0 WHILE + printf(($"Generation "d": "$, generation, + $f(alive or dead)$, []BOOL(universe)[lwb universe:upb universe], + $l$)); +# WHILE # generation < stop generation DO + BITS next universe := 2r0; + + # process the first event horizon manually # + IF couple(universe,lwb universe,lwb universe + 1) THEN + next universe := 2r10 + FI; + + # process the middle kingdom in a loop # + FOR bit FROM lwb universe + 1 TO upb universe - 1 DO + IF couple(universe,bit-1,bit+1) THEN + next universe := next universe OR 2r1 + FI; + next universe := next universe SHL 1 + OD; + + # process the last event horizon manually # + IF couple(universe, upb universe - 1, upb universe) THEN + next universe := next universe OR 2r1 + FI; + universe := next universe +OD diff --git a/Task/One-dimensional-cellular-automata/ALGOL-68/one-dimensional-cellular-automata-2.alg b/Task/One-dimensional-cellular-automata/ALGOL-68/one-dimensional-cellular-automata-2.alg new file mode 100644 index 0000000000..cd180288e6 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/ALGOL-68/one-dimensional-cellular-automata-2.alg @@ -0,0 +1,36 @@ +INT stop generation = 9; +INT stop generation = 9; +INT upb universe = 20; +FORMAT alive or dead = $b("#","_")$; + +BITS bits universe := 2r01110110101010100100; + # bits universe := BIN ( ENTIER ( random * max int ) ); # +[upb universe] BOOL universe := []BOOL(bits universe)[bits width - upb universe + 1:]; + +PROC couple = (REF[]BOOL parent)BOOL: ( + SHORT INT sum := 0; + FOR bit FROM LWB parent TO UPB parent DO + sum +:= ABS (parent[bit]) + OD; + sum = 2 +); + +FOR generation FROM 0 WHILE + printf(($"Generation "d": "$, generation, + $f(alive or dead)$, universe, + $l$)); +# WHILE # generation < stop generation DO + [UPB universe]BOOL next universe; + + # process the first event horizon manually # + next universe[1] := couple(universe[:2]); + + # process the middle kingdom in a loop # + FOR bit FROM LWB universe + 1 TO UPB universe - 1 DO + next universe[bit] := couple(universe[bit-1:bit+1]) + OD; + + # process the last event horizon manually # + next universe[UPB universe] := couple(universe[UPB universe - 1: ]); + universe := next universe +OD diff --git a/Task/One-dimensional-cellular-automata/AWK/one-dimensional-cellular-automata.awk b/Task/One-dimensional-cellular-automata/AWK/one-dimensional-cellular-automata.awk new file mode 100644 index 0000000000..4d02ef5169 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/AWK/one-dimensional-cellular-automata.awk @@ -0,0 +1,69 @@ +#!/usr/bin/awk -f +BEGIN { + edge = 1 + ruleNum = 104 # 01101000 + maxGen = 9 + mark = "@" + space = "." + initialState = ".@@@.@@.@.@.@.@..@.." + width = length(initialState) + delete rules + delete state + + initRules(ruleNum) + initState(initialState, mark) + for (g = 0; g < maxGen; g++) { + showState(g, mark, space) + nextState() + } + showState(g, mark, space) +} + +function nextState( newState, i, n) { + delete newState + for (i = 1; i < width - 1; i++) { + n = getRuleNum(i) + newState[i] = rules[n] + } + for (i = 0; i < width; i++) { # copy, can't assign arrays + state[i] = newState[i] + } +} + +# Convert a three cell neighborhood from binary to decimal +function getRuleNum(i, rn, j, p) { + rn = 0 + for (j = -1; j < 2; j++) { + p = i + j + rn = rn * 2 + (p < 0 || p > width ? edge : state[p]) + } + return rn +} + +function showState(gen, mark, space, i) { + printf("%3d: ", gen) + for (i = 1; i <= width; i++) { + printf(" %s", (state[i] ? mark : space)) + } + print "" +} + +# Make state transition lookup table from rule number. +function initRules(ruleNum, i, r) { + delete rules; + r = ruleNum + for (i = 0; i < 8; i++) { + rules[i] = r % 2 + r = int(r / 2) + } +} + +function initState(init, mark, i) { + delete state + srand() + for (i = 0; i < width; i++) { + state[i] = (substr(init, i, 1) == mark ? 1 : 0) # Given an initial string. + # state[int(width/2)] = '@' # middle cell + # state[i] = int(rand() * 100) < 30 ? 1 : 0 # 30% of cells + } +} diff --git a/Task/One-dimensional-cellular-automata/Ada/one-dimensional-cellular-automata.ada b/Task/One-dimensional-cellular-automata/Ada/one-dimensional-cellular-automata.ada new file mode 100644 index 0000000000..628d062e8c --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Ada/one-dimensional-cellular-automata.ada @@ -0,0 +1,42 @@ +with Ada.Text_IO; use Ada.Text_IO; + +procedure Cellular_Automata is + type Petri_Dish is array (Positive range <>) of Boolean; + + procedure Step (Culture : in out Petri_Dish) is + Left : Boolean := False; + This : Boolean; + Right : Boolean; + begin + for Index in Culture'First..Culture'Last - 1 loop + Right := Culture (Index + 1); + This := Culture (Index); + Culture (Index) := (This and (Left xor Right)) or (not This and Left and Right); + Left := This; + end loop; + Culture (Culture'Last) := Culture (Culture'Last) and not Left; + end Step; + + procedure Put (Culture : Petri_Dish) is + begin + for Index in Culture'Range loop + if Culture (Index) then + Put ('#'); + else + Put ('_'); + end if; + end loop; + end Put; + + Culture : Petri_Dish := + ( False, True, True, True, False, True, True, False, True, False, True, + False, True, False, True, False, False, True, False, False + ); +begin + for Generation in 0..9 loop + Put ("Generation" & Integer'Image (Generation) & ' '); + Put (Culture); + New_Line; + Step (Culture); + end loop; +end Cellular_Automata; diff --git a/Task/One-dimensional-cellular-automata/AutoHotkey/one-dimensional-cellular-automata.ahk b/Task/One-dimensional-cellular-automata/AutoHotkey/one-dimensional-cellular-automata.ahk new file mode 100644 index 0000000000..e5e38a2524 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/AutoHotkey/one-dimensional-cellular-automata.ahk @@ -0,0 +1,23 @@ +n := 22, n1 := n+1, v0 := v%n1% := 0 ; set grid dimensions, and fixed cells + +Loop % n { ; draw a line of checkboxes + v%A_Index% := 0 + Gui Add, CheckBox, % "y10 w17 h17 gCheck x" A_Index*17-5 " vv" A_Index +} +Gui Add, Button, x+5 y6, step ; button to step to next generation +Gui Show +Return + +Check: + GuiControlGet %A_GuiControl% ; set cells by the mouse +Return + +ButtonStep: ; move to next generation + Loop % n + i := A_Index-1, j := i+2, w%A_Index% := v%i%+v%A_Index%+v%j% = 2 + Loop % n + GuiControl,,v%A_Index%, % v%A_Index% := w%A_Index% +Return + +GuiClose: ; exit when GUI is closed +ExitApp diff --git a/Task/One-dimensional-cellular-automata/BASIC/one-dimensional-cellular-automata.basic b/Task/One-dimensional-cellular-automata/BASIC/one-dimensional-cellular-automata.basic new file mode 100644 index 0000000000..deb3358297 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/BASIC/one-dimensional-cellular-automata.basic @@ -0,0 +1,53 @@ +DECLARE FUNCTION life$ (lastGen$) +DECLARE FUNCTION getNeighbors! (group$) +CLS +start$ = "_###_##_#_#_#_#__#__" +numGens = 10 +FOR i = 0 TO numGens - 1 + PRINT "Generation"; i; ": "; start$ + start$ = life$(start$) +NEXT i + +FUNCTION getNeighbors (group$) + ans = 0 + IF (MID$(group$, 1, 1) = "#") THEN ans = ans + 1 + IF (MID$(group$, 3, 1) = "#") THEN ans = ans + 1 + getNeighbors = ans +END FUNCTION + +FUNCTION life$ (lastGen$) + newGen$ = "" + FOR i = 1 TO LEN(lastGen$) + neighbors = 0 + IF (i = 1) THEN 'left edge + IF MID$(lastGen$, 2, 1) = "#" THEN + neighbors = 1 + ELSE + neighbors = 0 + END IF + ELSEIF (i = LEN(lastGen$)) THEN 'right edge + IF MID$(lastGen$, LEN(lastGen$) - 1, 1) = "#" THEN + neighbors = 1 + ELSE + neighbors = 0 + END IF + ELSE 'middle + neighbors = getNeighbors(MID$(lastGen$, i - 1, 3)) + END IF + + IF (neighbors = 0) THEN 'dies or stays dead with no neighbors + newGen$ = newGen$ + "_" + END IF + IF (neighbors = 1) THEN 'stays with one neighbor + newGen$ = newGen$ + MID$(lastGen$, i, 1) + END IF + IF (neighbors = 2) THEN 'flips with two neighbors + IF MID$(lastGen$, i, 1) = "#" THEN + newGen$ = newGen$ + "_" + ELSE + newGen$ = newGen$ + "#" + END IF + END IF + NEXT i + life$ = newGen$ +END FUNCTION diff --git a/Task/One-dimensional-cellular-automata/BBC-BASIC/one-dimensional-cellular-automata.bbc b/Task/One-dimensional-cellular-automata/BBC-BASIC/one-dimensional-cellular-automata.bbc new file mode 100644 index 0000000000..26532abaaf --- /dev/null +++ b/Task/One-dimensional-cellular-automata/BBC-BASIC/one-dimensional-cellular-automata.bbc @@ -0,0 +1,13 @@ + DIM rule$(7) + rule$() = "0", "0", "0", "1", "0", "1", "1", "0" + + now$ = "01110110101010100100" + + FOR generation% = 0 TO 9 + PRINT "Generation " ; generation% ":", now$ + next$ = "" + FOR cell% = 1 TO LEN(now$) + next$ += rule$(EVAL("%"+MID$("0"+now$+"0", cell%, 3))) + NEXT cell% + SWAP now$, next$ + NEXT generation% diff --git a/Task/One-dimensional-cellular-automata/Befunge/one-dimensional-cellular-automata.bf b/Task/One-dimensional-cellular-automata/Befunge/one-dimensional-cellular-automata.bf new file mode 100644 index 0000000000..0479d9d979 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Befunge/one-dimensional-cellular-automata.bf @@ -0,0 +1,16 @@ +v + " !!! !! ! ! ! ! ! " ,*25 110p3>:1-10gg" "-4* \:10gg" "-2* \:1+10gg" "-\:54*1+`#v_20p++ :2`#v_ >:4`#v_> >$" "v + >:3`#^_v>:6`| + ^ >$$$$320p10g1+:9`v > >$"!"> 20g10g1+p 20g1+:20p + ^ v_10p10g + > ^ diff --git a/Task/One-dimensional-cellular-automata/Bracmat/one-dimensional-cellular-automata.bracmat b/Task/One-dimensional-cellular-automata/Bracmat/one-dimensional-cellular-automata.bracmat new file mode 100644 index 0000000000..3b28a9b1cf --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Bracmat/one-dimensional-cellular-automata.bracmat @@ -0,0 +1,30 @@ + ( ( evolve + = n z + . @( !arg + : %?n ? @?z + : ? + ( ( ( 000 + | 001 + | 010 + | 100 + | 111 + ) + & 0 !n:?n + | (011|101|110) + & 1 !n:?n + ) + & ~` + ) + ? + ) + | rev$(str$(!z !n)) + ) + & 11101101010101001001:?S + & :?seen + & whl + ' ( ~(!seen:? !S ?) + & out$!S + & !S !seen:?seen + & evolve$!S:?S + ) + ); diff --git a/Task/One-dimensional-cellular-automata/C++/one-dimensional-cellular-automata.cpp b/Task/One-dimensional-cellular-automata/C++/one-dimensional-cellular-automata.cpp new file mode 100644 index 0000000000..15a4bc8ecd --- /dev/null +++ b/Task/One-dimensional-cellular-automata/C++/one-dimensional-cellular-automata.cpp @@ -0,0 +1,29 @@ +#include +#include +#include + +const int ArraySize = 20; +const int NumGenerations = 10; +const std::string Initial = "0011101101010101001000"; + +int main() +{ + // + 2 for the fixed ends of the array + std::bitset array(Initial); + + for(int j = 0; j < NumGenerations; ++j) + { + std::bitset tmpArray(array); + for(int i = ArraySize; i >= 1 ; --i) + { + if(array[i]) + std::cout << "#"; + else + std::cout << "_"; + int val = (int)array[i-1] << 2 | (int)array[i] << 1 | (int)array[i+1]; + tmpArray[i] = (val == 3 || val == 5 || val == 6); + } + array = tmpArray; + std::cout << std::endl; + } +} diff --git a/Task/One-dimensional-cellular-automata/C-sharp/one-dimensional-cellular-automata.cs b/Task/One-dimensional-cellular-automata/C-sharp/one-dimensional-cellular-automata.cs new file mode 100644 index 0000000000..11a8529641 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/C-sharp/one-dimensional-cellular-automata.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; + +namespace prog +{ + class MainClass + { + const int n_iter = 10; + static int[] f = { 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0 }; + + public static void Main (string[] args) + { + for( int i=0; i +#include + +char trans[] = "___#_##_"; + +#define v(i) (cell[i] != '_') +int evolve(char cell[], char backup[], int len) +{ + int i, diff = 0; + + for (i = 0; i < len; i++) { + /* use left, self, right as binary number bits for table index */ + backup[i] = trans[ v(i-1) * 4 + v(i) * 2 + v(i + 1) ]; + diff += (backup[i] != cell[i]); + } + + strcpy(cell, backup); + return diff; +} + +int main() +{ + char c[] = "_###_##_#_#_#_#__#__\n", + b[] = "____________________\n"; + + do { printf(c + 1); } while (evolve(c + 1, b + 1, sizeof(c) - 3)); + return 0; +} diff --git a/Task/One-dimensional-cellular-automata/C/one-dimensional-cellular-automata-2.c b/Task/One-dimensional-cellular-automata/C/one-dimensional-cellular-automata-2.c new file mode 100644 index 0000000000..a4519be85b --- /dev/null +++ b/Task/One-dimensional-cellular-automata/C/one-dimensional-cellular-automata-2.c @@ -0,0 +1,27 @@ +#include + +char trans[] = "___#_##_"; + +int evolve(char c[], int len) +{ + int i, diff = 0; +# define v(i) ((c[i] & 15) == 1) +# define each for (i = 0; i < len; i++) + + each c[i] = (c[i] == '#'); + each c[i] |= (trans[(v(i-1)*4 + v(i)*2 + v(i+1))] == '#') << 4; + each diff += (c[i] & 0xf) ^ (c[i] >> 4); + each c[i] = (c[i] >> 4) ? '#' : '_'; + +# undef each +# undef v + return diff; +} + +int main() +{ + char c[] = "_###_##_#_#_#_#__#__\n"; + + do { printf(c + 1); } while (evolve(c + 1, sizeof(c) - 3)); + return 0; +} diff --git a/Task/One-dimensional-cellular-automata/COBOL/one-dimensional-cellular-automata.cobol b/Task/One-dimensional-cellular-automata/COBOL/one-dimensional-cellular-automata.cobol new file mode 100644 index 0000000000..3ee9d4890b --- /dev/null +++ b/Task/One-dimensional-cellular-automata/COBOL/one-dimensional-cellular-automata.cobol @@ -0,0 +1,90 @@ +Identification division. +Program-id. rc-1d-cell. + +Data division. +Working-storage section. + +* "Constants." +01 max-gens pic 999 value 9. +01 state-width pic 99 value 20. +01 state-table-init pic x(20) value ".@@@.@@.@.@.@..@..". +01 alive pic x value "@". +01 dead pic x value ".". + +* The current state. +01 state-gen pic 999 value 0. +01 state-row. + 05 state-row-gen pic zz9. + 05 filler pic xx value ": ". + 05 state-table. + 10 state-cells pic x occurs 20 times. + +* The new state. +01 new-state-table. + 05 new-state-cells pic x occurs 20 times. + +* Pointer into cell table during generational production. +01 cell-index pic 99. + 88 at-beginning value 1. + 88 is-inside values 2 thru 19. + 88 at-end value 20. + +* The cell's neighborhood. +01 neighbor-count pic 9. + 88 is-comfy value 1. + 88 is-ripe value 2. + +Procedure division. + Perform Init-state-table. + Perform max-gens times + perform Display-row + perform Next-state + end-perform. + Perform Display-row. + Stop run. + +Display-row. + Move state-gen to state-row-gen. + Display state-row. + +* Determine who lives and who dies. +Next-state. + Add 1 to state-gen. + Move state-table to new-state-table. + Perform with test after + varying cell-index from 1 by 1 + until at-end + perform Count-neighbors + perform Die-off + perform New-births + end-perform. + move new-state-table to state-table. + +* Living cell with wrong number of neighbors... +Die-off. + if state-cells(cell-index) = alive and not is-comfy + then move dead to new-state-cells(cell-index). + +* Empty cell with exactly two neighbors are... +New-births. + if state-cells(cell-index) = dead and is-ripe + then move alive to new-state-cells(cell-index). + +* How many living neighbors does a cell have? +Count-neighbors. + Move 0 to neighbor-count. + if at-beginning or at-end then + add 1 to neighbor-count. + if is-inside and state-cells(cell-index - 1) = alive then + add 1 to neighbor-count. + if is-inside and state-cells(cell-index + 1) = alive then + add 1 to neighbor-count. + +* String is easier to enter, but table is easier to work with, +* so move each character of the initialization string to the state-table. +Init-state-table. + Perform with test after + varying cell-index from 1 by 1 + until at-end + move state-table-init(cell-index:1) to state-cells(cell-index) + end-perform. diff --git a/Task/One-dimensional-cellular-automata/Clojure/one-dimensional-cellular-automata-1.clj b/Task/One-dimensional-cellular-automata/Clojure/one-dimensional-cellular-automata-1.clj new file mode 100644 index 0000000000..b751c2e0ea --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Clojure/one-dimensional-cellular-automata-1.clj @@ -0,0 +1,15 @@ +(ns one-dimensional-cellular-automata + (:require (clojure.contrib (string :as s)))) + +(defn next-gen [cells] + (loop [cs cells ncs (s/take 1 cells)] + (let [f3 (s/take 3 cs)] + (if (= 3 (count f3)) + (recur (s/drop 1 cs) + (str ncs (if (= 2 (count (filter #(= \# %) f3))) "#" "_"))) + (str ncs (s/drop 1 cs)))))) + +(defn generate [n cells] + (if (= n 0) + '() + (cons cells (generate (dec n) (next-gen cells))))) diff --git a/Task/One-dimensional-cellular-automata/Clojure/one-dimensional-cellular-automata-2.clj b/Task/One-dimensional-cellular-automata/Clojure/one-dimensional-cellular-automata-2.clj new file mode 100644 index 0000000000..9248fdc878 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Clojure/one-dimensional-cellular-automata-2.clj @@ -0,0 +1,12 @@ +one-dimensional-cellular-automata> (doseq [cells (generate 9 "_###_##_#_#_#_#__#__")] + (println cells)) +_###_##_#_#_#_#__#__ +_#_#####_#_#_#______ +__##___##_#_#_______ +__##___###_#________ +__##___#_##_________ +__##____###_________ +__##____#_#_________ +__##_____#__________ +__##________________ +nil diff --git a/Task/One-dimensional-cellular-automata/CoffeeScript/one-dimensional-cellular-automata-1.coffeescript b/Task/One-dimensional-cellular-automata/CoffeeScript/one-dimensional-cellular-automata-1.coffeescript new file mode 100644 index 0000000000..417d619935 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/CoffeeScript/one-dimensional-cellular-automata-1.coffeescript @@ -0,0 +1,32 @@ +# We could cheat and count the bits, but let's keep this general. +# . = dead, # = alive, middle cells survives iff one of the configurations +# below is satisified. +survival_scenarios = [ + '.##' # happy neighbors + '#.#' # birth + '##.' # happy neighbors +] + +b2c = (b) -> if b then '#' else '.' + +cell_next_gen = (left_alive, me_alive, right_alive) -> + fingerprint = b2c(left_alive) + b2c(me_alive) + b2c(right_alive) + fingerprint in survival_scenarios + +cells_for_next_gen = (cells) -> + # This function assumes a finite array, i.e. cells can't be born outside + # the original array. + (cell_next_gen(cells[i-1], cells[i], cells[i+1]) for i in [0...cells.length]) + +display = (cells) -> + (b2c(is_alive) for is_alive in cells).join '' + +simulate = (cells) -> + while true + console.log display cells + new_cells = cells_for_next_gen cells + break if display(cells) == display(new_cells) + cells = new_cells + console.log "equilibrium achieved" + +simulate (c == '#' for c in ".###.##.#.#.#.#..#..") diff --git a/Task/One-dimensional-cellular-automata/CoffeeScript/one-dimensional-cellular-automata-2.coffeescript b/Task/One-dimensional-cellular-automata/CoffeeScript/one-dimensional-cellular-automata-2.coffeescript new file mode 100644 index 0000000000..d3ad75ccb0 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/CoffeeScript/one-dimensional-cellular-automata-2.coffeescript @@ -0,0 +1,11 @@ +> coffee cellular_automata.coffee +.###.##.#.#.#.#..#.. +.#.#####.#.#.#...... +..##...##.#.#....... +..##...###.#........ +..##...#.##......... +..##....###......... +..##....#.#......... +..##.....#.......... +..##................ +equilibrium achieved diff --git a/Task/One-dimensional-cellular-automata/Common-Lisp/one-dimensional-cellular-automata-1.lisp b/Task/One-dimensional-cellular-automata/Common-Lisp/one-dimensional-cellular-automata-1.lisp new file mode 100644 index 0000000000..3d2437253a --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Common-Lisp/one-dimensional-cellular-automata-1.lisp @@ -0,0 +1,28 @@ +(defun value (x) + (assert (> (length x) 1)) + (coerce x 'simple-bit-vector)) + +(defun count-neighbors-and-self (value i) + (flet ((ref (i) + (if (array-in-bounds-p value i) + (bit value i) + 0))) + (declare (inline ref)) + (+ (ref (1- i)) + (ref i) + (ref (1+ i))))) + +(defun next-cycle (value) + (let ((new-value (make-array (length value) :element-type 'bit))) + (loop for i below (length value) + do (setf (bit new-value i) + (if (= 2 (count-neighbors-and-self value i)) + 1 + 0))) + new-value)) + +(defun print-world (value &optional (stream *standard-output*)) + (loop for i below (length value) + do (princ (if (zerop (bit value i)) #\. #\#) + stream)) + (terpri stream)) diff --git a/Task/One-dimensional-cellular-automata/Common-Lisp/one-dimensional-cellular-automata-2.lisp b/Task/One-dimensional-cellular-automata/Common-Lisp/one-dimensional-cellular-automata-2.lisp new file mode 100644 index 0000000000..28fbcb0a81 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Common-Lisp/one-dimensional-cellular-automata-2.lisp @@ -0,0 +1,13 @@ +CL-USER> (loop for previous-value = nil then value + for value = #*01110110101010100100 then (next-cycle value) + until (equalp value previous-value) + do (print-world value)) +.###.##.#.#.#.#..#.. +.#.#####.#.#.#...... +..##...##.#.#....... +..##...###.#........ +..##...#.##......... +..##....###......... +..##....#.#......... +..##.....#.......... +..##................ diff --git a/Task/One-dimensional-cellular-automata/D/one-dimensional-cellular-automata.d b/Task/One-dimensional-cellular-automata/D/one-dimensional-cellular-automata.d new file mode 100644 index 0000000000..f479ef84ce --- /dev/null +++ b/Task/One-dimensional-cellular-automata/D/one-dimensional-cellular-automata.d @@ -0,0 +1,19 @@ +import std.stdio, std.algorithm; + +void main() { + enum ngenerations = 10; + enum initial = "0011101101010101001000"; + enum table = "00010110"; + + char[initial.length + 2] A = '0', B = '0'; + A[1 .. $-1] = initial; + foreach (_; 0 .. ngenerations) { + foreach (i; 1 .. A.length-1) { + write(A[i] == '0' ? '_' : '#'); + int val = (A[i-1]-'0' << 2) | (A[i]-'0' << 1) | (A[i+1]-'0'); + B[i] = table[val]; + } + swap(A, B); + writeln(); + } +} diff --git a/Task/One-dimensional-cellular-automata/DWScript/one-dimensional-cellular-automata.dwscript b/Task/One-dimensional-cellular-automata/DWScript/one-dimensional-cellular-automata.dwscript new file mode 100644 index 0000000000..1add98c4e0 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/DWScript/one-dimensional-cellular-automata.dwscript @@ -0,0 +1,20 @@ +const ngenerations = 10; +const table = [0, 0, 0, 1, 0, 1, 1, 0]; + +var a := [0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0]; +var b := a; + +var i, j : Integer; +for i := 1 to ngenerations do begin + for j := a.low+1 to a.high-1 do begin + if a[j] = 0 then + Print('_') + else Print('#'); + var val := (a[j-1] shl 2) or (a[j] shl 1) or a[j+1]; + b[j] := table[val]; + end; + var tmp := a; + a := b; + b := tmp; + PrintLn(''); +end; diff --git a/Task/One-dimensional-cellular-automata/E/one-dimensional-cellular-automata-1.e b/Task/One-dimensional-cellular-automata/E/one-dimensional-cellular-automata-1.e new file mode 100644 index 0000000000..10f5f6dbb8 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/E/one-dimensional-cellular-automata-1.e @@ -0,0 +1,18 @@ +def step(state, rule) { + var result := state(0, 1) # fixed left cell + for i in 1..(state.size() - 2) { + # Rule function receives the substring which is the neighborhood + result += E.toString(rule(state(i-1, i+2))) + } + result += state(state.size() - 1) # fixed right cell + return result +} + +def play(var state, rule, count, out) { + out.print(`0 | $state$\n`) + for i in 1..count { + state := step(state, rosettaRule) + out.print(`$i | $state$\n`) + } + return state +} diff --git a/Task/One-dimensional-cellular-automata/E/one-dimensional-cellular-automata-2.e b/Task/One-dimensional-cellular-automata/E/one-dimensional-cellular-automata-2.e new file mode 100644 index 0000000000..cf101e5dcf --- /dev/null +++ b/Task/One-dimensional-cellular-automata/E/one-dimensional-cellular-automata-2.e @@ -0,0 +1,23 @@ +def rosettaRule := [ + " " => " ", + " #" => " ", + " # " => " ", + " ##" => "#", + "# " => " ", + "# #" => "#", + "## " => "#", + "###" => " ", +].get + +? play(" ### ## # # # # # ", rosettaRule, 9, stdout) +0 | ### ## # # # # # +1 | # ##### # # # +2 | ## ## # # +3 | ## ### # +4 | ## # ## +5 | ## ### +6 | ## # # +7 | ## # +8 | ## +9 | ## +# value: " ## " diff --git a/Task/One-dimensional-cellular-automata/Erlang/one-dimensional-cellular-automata-1.erl b/Task/One-dimensional-cellular-automata/Erlang/one-dimensional-cellular-automata-1.erl new file mode 100644 index 0000000000..fb53e0eaf6 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Erlang/one-dimensional-cellular-automata-1.erl @@ -0,0 +1,48 @@ +-module(ca). +-compile(export_all). + +run(N,G) -> + run(N,G,0). + +run(GN,G,GN) -> + io:fwrite("~B: ",[GN]), + print(G); +run(N,G,GN) -> + io:fwrite("~B: ",[GN]), + print(G), + run(N,next(G),GN+1). + +print([]) -> + io:fwrite("~n"); +print([0|T]) -> + io:fwrite("_"), + print(T); +print([1|T]) -> + io:fwrite("#"), + print(T). + +next([]) -> + []; +next([_]) -> + [0]; +next([H,1|_]=G) -> + next(G,[H]); +next([_|_]=G) -> + next(G,[0]). + +next([],Acc) -> + lists:reverse(Acc); +next([0,_],Acc) -> + next([],[0|Acc]); +next([1,X],Acc) -> + next([],[X|Acc]); +next([0,X,0|T],Acc) -> + next([X,0|T],[0|Acc]); +next([1,X,0|T],Acc) -> + next([X,0|T],[X|Acc]); +next([0,X,1|T],Acc) -> + next([X,1|T],[X|Acc]); +next([1,0,1|T],Acc) -> + next([0,1|T],[1|Acc]); +next([1,1,1|T],Acc) -> + next([1,1|T],[0|Acc]). diff --git a/Task/One-dimensional-cellular-automata/Erlang/one-dimensional-cellular-automata-2.erl b/Task/One-dimensional-cellular-automata/Erlang/one-dimensional-cellular-automata-2.erl new file mode 100644 index 0000000000..fce8360203 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Erlang/one-dimensional-cellular-automata-2.erl @@ -0,0 +1,11 @@ +44> ca:run(9,[0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0]). +0: __###_##_#_#_#_#__#___ +1: __#_#####_#_#_#_______ +2: ___##___##_#_#________ +3: ___##___###_#_________ +4: ___##___#_##__________ +5: ___##____###__________ +6: ___##____#_#__________ +7: ___##_____#___________ +8: ___##_________________ +9: ___##_________________ diff --git a/Task/One-dimensional-cellular-automata/Euphoria/one-dimensional-cellular-automata.euphoria b/Task/One-dimensional-cellular-automata/Euphoria/one-dimensional-cellular-automata.euphoria new file mode 100644 index 0000000000..57b04ac62d --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Euphoria/one-dimensional-cellular-automata.euphoria @@ -0,0 +1,46 @@ +include machine.e + +function rules(integer tri) + return tri = 3 or tri = 5 or tri = 6 +end function + +function next_gen(atom gen) + atom new, bit + new = rules(and_bits(gen,3)*2) -- work with the first bit separately + bit = 2 + while gen > 0 do + new += bit*rules(and_bits(gen,7)) + gen = floor(gen/2) -- shift right + bit *= 2 -- shift left + end while + return new +end function + +constant char_clear = '_', char_filled = '#' + +procedure print_gen(atom gen) + puts(1, int_to_bits(gen,32) * (char_filled - char_clear) + char_clear) + puts(1,'\n') +end procedure + +function s_to_gen(sequence s) + s -= char_clear + return bits_to_int(s) +end function + +atom gen, prev +integer n + +n = 0 +prev = 0 +gen = bits_to_int(rand(repeat(2,32))-1) +while gen != prev do + printf(1,"Generation %d: ",n) + print_gen(gen) + prev = gen + gen = next_gen(gen) + n += 1 +end while + +printf(1,"Generation %d: ",n) +print_gen(gen) diff --git a/Task/One-dimensional-cellular-automata/Factor/one-dimensional-cellular-automata.factor b/Task/One-dimensional-cellular-automata/Factor/one-dimensional-cellular-automata.factor new file mode 100644 index 0000000000..3837141d44 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Factor/one-dimensional-cellular-automata.factor @@ -0,0 +1,21 @@ +USING: bit-arrays io kernel locals math sequences ; +IN: cellular + +: bool-sum ( bool1 bool2 -- sum ) + [ [ 2 ] [ 1 ] if ] + [ [ 1 ] [ 0 ] if ] if ; +:: neighbours ( index world -- # ) + index [ 1 - ] [ 1 + ] bi [ world ?nth ] bi@ bool-sum ; +: count-neighbours ( world -- neighbours ) + [ length iota ] keep [ neighbours ] curry map ; + +: life-law ( alive? neighbours -- alive? ) + swap [ 1 = ] [ 2 = ] if ; +: step ( world -- world' ) + dup count-neighbours [ life-law ] ?{ } 2map-as ; +: print-cellular ( world -- ) + [ CHAR: # CHAR: _ ? ] "" map-as print ; +: main-cellular ( -- ) + ?{ f t t t f t t f t f t f t f t f f t f f } + 10 [ dup print-cellular step ] times print-cellular ; +MAIN: main-cellular diff --git a/Task/One-dimensional-cellular-automata/Fantom/one-dimensional-cellular-automata.fantom b/Task/One-dimensional-cellular-automata/Fantom/one-dimensional-cellular-automata.fantom new file mode 100644 index 0000000000..92e2660864 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Fantom/one-dimensional-cellular-automata.fantom @@ -0,0 +1,30 @@ +class Automaton +{ + static Int[] evolve (Int[] array) + { + return array.map |Int x, Int i -> Int| + { + if (i == 0) + return ( (x + array[1] == 2) ? 1 : 0) + else if (i == array.size-1) + return ( (x + array[-2] == 2) ? 1 : 0) + else if (x + array[i-1] + array[i+1] == 2) + return 1 + else + return 0 + } + } + + public static Void main () + { + Int[] array := [0,1,1,1,0,1,1,0,1,0,1,0,1,0,1,0,0,1,0,0] + echo (array.join("")) + Int[] newArray := evolve(array) + while (newArray != array) + { + echo (newArray.join("")) + array = newArray + newArray = evolve(array) + } + } +} diff --git a/Task/One-dimensional-cellular-automata/Forth/one-dimensional-cellular-automata.fth b/Task/One-dimensional-cellular-automata/Forth/one-dimensional-cellular-automata.fth new file mode 100644 index 0000000000..e923e5c38d --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Forth/one-dimensional-cellular-automata.fth @@ -0,0 +1,25 @@ +: init ( bits count -- ) + 0 do dup 1 and c, 2/ loop drop ; + +20 constant size +create state $2556e size init 0 c, + +: .state + cr size 0 do + state i + c@ if ." #" else space then + loop ; + +: ctable create does> + c@ ; +ctable rules $68 8 init + +: gen + state c@ ( window ) + size 0 do + 2* state i + 1+ c@ or 7 and + dup rules state i + c! + loop drop ; + +: life1d ( n -- ) + .state 1 do gen .state loop ; + +10 life1d diff --git a/Task/One-dimensional-cellular-automata/Fortran/one-dimensional-cellular-automata.f b/Task/One-dimensional-cellular-automata/Fortran/one-dimensional-cellular-automata.f new file mode 100644 index 0000000000..e46f08ef2e --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Fortran/one-dimensional-cellular-automata.f @@ -0,0 +1,50 @@ +PROGRAM LIFE_1D + + IMPLICIT NONE + + LOGICAL :: cells(20) = (/ .FALSE., .TRUE., .TRUE., .TRUE., .FALSE., .TRUE., .TRUE., .FALSE., .TRUE., .FALSE., & + .TRUE., .FALSE., .TRUE., .FALSE., .TRUE., .FALSE., .FALSE., .TRUE., .FALSE., .FALSE. /) + INTEGER :: i + + DO i = 0, 9 + WRITE(*, "(A,I0,A)", ADVANCE = "NO") "Generation ", i, ": " + CALL Drawgen(cells) + CALL Nextgen(cells) + END DO + +CONTAINS + + SUBROUTINE Nextgen(cells) + LOGICAL, INTENT (IN OUT) :: cells(:) + LOGICAL :: left, centre, right + INTEGER :: i + + left = .FALSE. + DO i = 1, SIZE(cells)-1 + centre = cells(i) + right = cells(i+1) + IF (left .AND. right) THEN + cells(i) = .NOT. cells(i) + ELSE IF (.NOT. left .AND. .NOT. right) THEN + cells(i) = .FALSE. + END IF + left = centre + END DO + cells(SIZE(cells)) = left .AND. right + END SUBROUTINE Nextgen + + SUBROUTINE Drawgen(cells) + LOGICAL, INTENT (IN OUT) :: cells(:) + INTEGER :: i + + DO i = 1, SIZE(cells) + IF (cells(i)) THEN + WRITE(*, "(A)", ADVANCE = "NO") "#" + ELSE + WRITE(*, "(A)", ADVANCE = "NO") "_" + END IF + END DO + WRITE(*,*) + END SUBROUTINE Drawgen + +END PROGRAM LIFE_1D diff --git a/Task/One-dimensional-cellular-automata/Go/one-dimensional-cellular-automata.go b/Task/One-dimensional-cellular-automata/Go/one-dimensional-cellular-automata.go new file mode 100644 index 0000000000..be1e4b6f1a --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Go/one-dimensional-cellular-automata.go @@ -0,0 +1,26 @@ +package main + +import "fmt" + +const start = "_###_##_#_#_#_#__#__" + +func main() { + g0 := []byte(start) + g1 := []byte(start) + fmt.Println(string(g0)) + last := len(g0) - 1 + for g := 0; g < 10; g++ { + for i := 1; i < last; i++ { + switch { + case g0[i-1] != g0[i+1]: + g1[i] = g0[i] + case g0[i] == '_': + g1[i] = g0[i-1] + default: + g1[i] = '_' + } + } + fmt.Println(string(g1)) + copy(g0, g1) + } +} diff --git a/Task/One-dimensional-cellular-automata/Groovy/one-dimensional-cellular-automata-1.groovy b/Task/One-dimensional-cellular-automata/Groovy/one-dimensional-cellular-automata-1.groovy new file mode 100644 index 0000000000..876897ea4d --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Groovy/one-dimensional-cellular-automata-1.groovy @@ -0,0 +1,5 @@ +def life1D = { self -> + def right = self[1..-1] + [false] + def left = [false] + self[0..-2] + [left, self, right].transpose().collect { hood -> hood.count { it } == 2 } +} diff --git a/Task/One-dimensional-cellular-automata/Groovy/one-dimensional-cellular-automata-2.groovy b/Task/One-dimensional-cellular-automata/Groovy/one-dimensional-cellular-automata-2.groovy new file mode 100644 index 0000000000..bbc8761ec4 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Groovy/one-dimensional-cellular-automata-2.groovy @@ -0,0 +1,6 @@ +def cells = ('_###_##_#_#_#_#__#__' as List).collect { it == '#' } +println "Generation 0: ${cells.collect { g -> g ? '#' : '_' }.join()}" +(1..9).each { + cells = life1D(cells) + println "Generation ${it}: ${cells.collect { g -> g ? '#' : '_' }.join()}" +} diff --git a/Task/One-dimensional-cellular-automata/Haskell/one-dimensional-cellular-automata-1.hs b/Task/One-dimensional-cellular-automata/Haskell/one-dimensional-cellular-automata-1.hs new file mode 100644 index 0000000000..45d6ccfa21 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Haskell/one-dimensional-cellular-automata-1.hs @@ -0,0 +1,24 @@ +module Life1D where + +import Data.List +import System.Random +import Control.Monad +import Control.Arrow + +bnd :: [Char] -> Char +bnd bs = + case bs of + "_##" -> '#' + "#_#" -> '#' + "##_" -> '#' + _ -> '_' + +donxt xs = unfoldr(\xs -> case xs of [_,_] -> Nothing ; + _ -> Just (bnd $ take 3 xs, drop 1 xs)) $ '_':xs++"_" + +lahmahgaan xs = init.until (liftM2 (==) last (last. init)) (ap (++)(return. donxt. last)) $ [xs, donxt xs] + +main = do + g <- newStdGen + let oersoep = map ("_#"!!). take 36 $ randomRs(0,1) g + mapM_ print . lahmahgaan $ oersoep diff --git a/Task/One-dimensional-cellular-automata/Haskell/one-dimensional-cellular-automata-2.hs b/Task/One-dimensional-cellular-automata/Haskell/one-dimensional-cellular-automata-2.hs new file mode 100644 index 0000000000..d95a637e46 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Haskell/one-dimensional-cellular-automata-2.hs @@ -0,0 +1,19 @@ +*Life1D> mapM_ print . lahmahgaan $ "_###_##_#_#_#_#__#__" +"_###_##_#_#_#_#__#__" +"_#_#####_#_#_#______" +"__##___##_#_#_______" +"__##___###_#________" +"__##___#_##_________" +"__##____###_________" +"__##____#_#_________" +"__##_____#__________" +"__##________________" + +*Life1D> main +"__##_##__#____###__#__#_______#_#_##" +"__#####_______#_#______________#_###" +"__#___#________#________________##_#" +"________________________________###_" +"________________________________#_#_" +"_________________________________#__" +"____________________________________" diff --git a/Task/One-dimensional-cellular-automata/Icon/one-dimensional-cellular-automata-1.icon b/Task/One-dimensional-cellular-automata/Icon/one-dimensional-cellular-automata-1.icon new file mode 100644 index 0000000000..e102ed9274 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Icon/one-dimensional-cellular-automata-1.icon @@ -0,0 +1,36 @@ +# One dimensional Cellular automaton +record Automaton(size, cells) + +procedure make_automaton (size, items) + automaton := Automaton (size, items) + while (*items < size) do push (automaton.cells, 0) + return automaton +end + +procedure automaton_display (automaton) + every (write ! automaton.cells) +end + +procedure automaton_evolve (automaton) + revised := make_automaton (automaton.size, []) + # do the left-most cell + if ((automaton.cells[1] + automaton.cells[2]) = 2) then + revised.cells[1] := 1 + # do the right-most cell + if ((automaton.cells[automaton.size] + automaton.cells[automaton.size-1]) = 2) then + revised.cells[revised.size] := 1 + # do the intermediate cells + every (i := 2 to (automaton.size-1)) do { + if ((automaton.cells[i-1] + automaton.cells[i] + automaton.cells[i+1]) = 2) then + revised.cells[i] := 1 + } + return revised +end + +procedure main () + automaton := make_automaton (20, [0,1,1,1,0,1,1,0,1,0,1,0,1,0,1,0,0,1,0,0]) + every (1 to 10) do { # generations + automaton_display (automaton) + automaton := automaton_evolve (automaton) + } +end diff --git a/Task/One-dimensional-cellular-automata/Icon/one-dimensional-cellular-automata-2.icon b/Task/One-dimensional-cellular-automata/Icon/one-dimensional-cellular-automata-2.icon new file mode 100644 index 0000000000..ee95a8dec8 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Icon/one-dimensional-cellular-automata-2.icon @@ -0,0 +1,16 @@ +procedure main(A) + A := if *A = 0 then ["01110110101010100100"] + CA := show("0"||A[1]||"0") # add always dead border cells + every CA := show(|evolve(CA)\10) # limit to max of 10 generations +end + +procedure show(ca) + write(ca[2:-1]) # omit border cells + return ca +end + +procedure evolve(CA) + newCA := repl("0",*CA) + every newCA[i := 2 to (*CA-1)] := (CA[i-1]+CA[i]+CA[i+1] = 2, "1") + return CA ~== newCA # fail if no change +end diff --git a/Task/One-dimensional-cellular-automata/J/one-dimensional-cellular-automata-1.j b/Task/One-dimensional-cellular-automata/J/one-dimensional-cellular-automata-1.j new file mode 100644 index 0000000000..7e9dab6035 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/J/one-dimensional-cellular-automata-1.j @@ -0,0 +1 @@ +life1d=: '_#'{~ (2 = 3+/\ 0,],0:)^:a: diff --git a/Task/One-dimensional-cellular-automata/J/one-dimensional-cellular-automata-2.j b/Task/One-dimensional-cellular-automata/J/one-dimensional-cellular-automata-2.j new file mode 100644 index 0000000000..094d38eab1 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/J/one-dimensional-cellular-automata-2.j @@ -0,0 +1,10 @@ + life1d ? 20 # 2 +_###_##_#_#_#_#__#__ +_#_#####_#_#_#______ +__##___##_#_#_______ +__##___###_#________ +__##___#_##_________ +__##____###_________ +__##____#_#_________ +__##_____#__________ +__##________________ diff --git a/Task/One-dimensional-cellular-automata/J/one-dimensional-cellular-automata-3.j b/Task/One-dimensional-cellular-automata/J/one-dimensional-cellular-automata-3.j new file mode 100644 index 0000000000..4269d51d69 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/J/one-dimensional-cellular-automata-3.j @@ -0,0 +1,3 @@ +Rule=:2 :0 NB. , m: number of generations, n: rule number + '_#'{~ (3 ((|.n#:~8#2) {~ #.)\ 0,],0:)^:(i.m) +) diff --git a/Task/One-dimensional-cellular-automata/J/one-dimensional-cellular-automata-4.j b/Task/One-dimensional-cellular-automata/J/one-dimensional-cellular-automata-4.j new file mode 100644 index 0000000000..9c685ad44f --- /dev/null +++ b/Task/One-dimensional-cellular-automata/J/one-dimensional-cellular-automata-4.j @@ -0,0 +1,10 @@ + 9 Rule 104 '#'='_###_##_#_#_#_#__#__' +_###_##_#_#_#_#__#__ +_#_#####_#_#_#______ +__##___##_#_#_______ +__##___###_#________ +__##___#_##_________ +__##____###_________ +__##____#_#_________ +__##_____#__________ +__##________________ diff --git a/Task/One-dimensional-cellular-automata/Java/one-dimensional-cellular-automata-1.java b/Task/One-dimensional-cellular-automata/Java/one-dimensional-cellular-automata-1.java new file mode 100644 index 0000000000..02a72f5a5f --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Java/one-dimensional-cellular-automata-1.java @@ -0,0 +1,42 @@ +public class Life{ + public static void main(String[] args) throws Exception{ + String start= "_###_##_#_#_#_#__#__"; + int numGens = 10; + for(int i= 0; i < numGens; i++){ + System.out.println("Generation " + i + ": " + start); + start= life(start); + } + } + + public static String life(String lastGen){ + String newGen= ""; + for(int i= 0; i < lastGen.length(); i++){ + int neighbors= 0; + if (i == 0){//left edge + neighbors= lastGen.charAt(1) == '#' ? 1 : 0; + } else if (i == lastGen.length() - 1){//right edge + neighbors= lastGen.charAt(i - 1) == '#' ? 1 : 0; + } else{//middle + neighbors= getNeighbors(lastGen.substring(i - 1, i + 2)); + } + + if (neighbors == 0){//dies or stays dead with no neighbors + newGen+= "_"; + } + if (neighbors == 1){//stays with one neighbor + newGen+= lastGen.charAt(i); + } + if (neighbors == 2){//flips with two neighbors + newGen+= lastGen.charAt(i) == '#' ? "_" : "#"; + } + } + return newGen; + } + + public static int getNeighbors(String group){ + int ans= 0; + if (group.charAt(0) == '#') ans++; + if (group.charAt(2) == '#') ans++; + return ans; + } +} diff --git a/Task/One-dimensional-cellular-automata/Java/one-dimensional-cellular-automata-2.java b/Task/One-dimensional-cellular-automata/Java/one-dimensional-cellular-automata-2.java new file mode 100644 index 0000000000..0529b1b4ca --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Java/one-dimensional-cellular-automata-2.java @@ -0,0 +1,31 @@ +public class Life{ + private static char[] trans = "___#_##_".toCharArray(); + + private static int v(StringBuilder cell, int i){ + return (cell.charAt(i) != '_') ? 1 : 0; + } + + public static boolean evolve(StringBuilder cell){ + boolean diff = false; + StringBuilder backup = new StringBuilder(cell.toString()); + + for(int i = 1; i < cell.length() - 3; i++){ + /* use left, self, right as binary number bits for table index */ + backup.setCharAt(i, trans[v(cell, i - 1) * 4 + v(cell, i) * 2 + + v(cell, i + 1)]); + diff = diff || (backup.charAt(i) != cell.charAt(i)); + } + + cell.delete(0, cell.length());//clear the buffer + cell.append(backup);//replace it with the new generation + return diff; + } + + public static void main(String[] args){ + StringBuilder c = new StringBuilder("_###_##_#_#_#_#__#__\n"); + + do{ + System.out.printf(c.substring(1)); + }while(evolve(c)); + } +} diff --git a/Task/One-dimensional-cellular-automata/JavaScript/one-dimensional-cellular-automata-1.js b/Task/One-dimensional-cellular-automata/JavaScript/one-dimensional-cellular-automata-1.js new file mode 100644 index 0000000000..1f5adaa914 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/JavaScript/one-dimensional-cellular-automata-1.js @@ -0,0 +1,13 @@ +function caStep(old) { + var old = [0].concat(old, [0]); // Surround with dead cells. + var state = []; // The new state. + + for (var i=1; i0,{0,1,0}->0,{0,1,1}->1,{1,0,0}->0,{1,0,1}->1,{1,1,0}->1,{1,1,1}->0},{{1,1,1,0,1,1,0,1,0,1,0,1,0,1,0,0,1},0},12] +Print @@@ (% /. {1 -> "#", 0 -> "."}); diff --git a/Task/One-dimensional-cellular-automata/Mathematica/one-dimensional-cellular-automata-2.math b/Task/One-dimensional-cellular-automata/Mathematica/one-dimensional-cellular-automata-2.math new file mode 100644 index 0000000000..364c35a0ce --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Mathematica/one-dimensional-cellular-automata-2.math @@ -0,0 +1,13 @@ +###.##.#.#.#.#..# +#.#####.#.#.#.... +.##...##.#.#..... +.##...###.#...... +.##...#.##....... +.##....###....... +.##....#.#....... +.##.....#........ +.##.............. +.##.............. +.##.............. +.##.............. +.##.............. diff --git a/Task/One-dimensional-cellular-automata/Modula-3/one-dimensional-cellular-automata.mod3 b/Task/One-dimensional-cellular-automata/Modula-3/one-dimensional-cellular-automata.mod3 new file mode 100644 index 0000000000..23324ad24f --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Modula-3/one-dimensional-cellular-automata.mod3 @@ -0,0 +1,43 @@ +MODULE Cell EXPORTS Main; + +IMPORT IO, Fmt, Word; + +VAR culture := ARRAY [0..19] OF INTEGER {0, 1, 1, 1, + 0, 1, 1, 0, + 1, 0, 1, 0, + 1, 0, 1, 0, + 0, 1, 0, 0}; + +PROCEDURE Step(VAR culture: ARRAY OF INTEGER) = + VAR left: INTEGER := 0; + this, right: INTEGER; + BEGIN + FOR i := FIRST(culture) TO LAST(culture) - 1 DO + right := culture[i + 1]; + this := culture[i]; + culture[i] := + Word.Or(Word.And(this, Word.Xor(left, right)), Word.And(Word.Not(this), Word.And(left, right))); + left := this; + END; + culture[LAST(culture)] := Word.And(culture[LAST(culture)], Word.Not(left)); + END Step; + +PROCEDURE Put(VAR culture: ARRAY OF INTEGER) = + BEGIN + FOR i := FIRST(culture) TO LAST(culture) DO + IF culture[i] = 1 THEN + IO.PutChar('#'); + ELSE + IO.PutChar('_'); + END; + END; + END Put; + +BEGIN + FOR i := 0 TO 9 DO + IO.Put("Generation " & Fmt.Int(i) & " "); + Put(culture); + IO.Put("\n"); + Step(culture); + END; +END Cell. diff --git a/Task/One-dimensional-cellular-automata/Nial/one-dimensional-cellular-automata-1.nial b/Task/One-dimensional-cellular-automata/Nial/one-dimensional-cellular-automata-1.nial new file mode 100644 index 0000000000..17a3b40b70 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Nial/one-dimensional-cellular-automata-1.nial @@ -0,0 +1,10 @@ +% we need a way to write a values and pass the same back +wi is rest link [write, pass] +% calculate the neighbors by rotating the array left and right and joining them +neighbors is pack [pass, sum [-1 rotate, 1 rotate]] +% calculate the individual birth and death of a single array element +igen is fork [ = [ + [first, second], 3 first], 0 first, = [ + [first, second], 2 first], 1 first, 0 first ] +% apply that to the array +nextgen is each igen neighbors +% 42 +life is fork [ > [sum pass, 0 first], life nextgen wi, pass ] diff --git a/Task/One-dimensional-cellular-automata/Nial/one-dimensional-cellular-automata-2.nial b/Task/One-dimensional-cellular-automata/Nial/one-dimensional-cellular-automata-2.nial new file mode 100644 index 0000000000..eca19a5229 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Nial/one-dimensional-cellular-automata-2.nial @@ -0,0 +1,3 @@ +|loaddefs 'life.nial' +|I := [0,1,1,1,0,1,1,0,1,0,1,0,1,0,1,0,0,1,0,0] +|life I diff --git a/Task/One-dimensional-cellular-automata/Nimrod/one-dimensional-cellular-automata.nimrod b/Task/One-dimensional-cellular-automata/Nimrod/one-dimensional-cellular-automata.nimrod new file mode 100644 index 0000000000..5a1f8e2481 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Nimrod/one-dimensional-cellular-automata.nimrod @@ -0,0 +1,61 @@ +import math +randomize() + +type + TBoolArray = array[0..30, bool] # an array that is indexed with 0..10 + TSymbols = tuple[on: char , off: char] + +const + num_turns = 20 + symbols:TSymbols = ('#',' ') + +proc `==` (x:TBoolArray,y:TBoolArray): bool = + if len(x) != len(y): + return False + for i in 0..(len(x)-1): + if x[i] != y[i]: + return False + return True + +proc count_neighbours(map:TBoolArray , tile:int):int = + result = 0 + if tile != len(map)-1 and map[tile+1]: + result += 1 + if tile != 0 and map[tile-1]: + result += 1 + +proc print_map(map:TBoolArray, symbols:TSymbols) = + for i in map: + if i: + write(stdout,symbols[0]) + else: + write(stdout,symbols[1]) + write(stdout,"\n") + +proc random_map(): TBoolArray = + var map = [False,False,False,False,False,False,False,False,False,False,False, + False,False,False,False,False,False,False,False,False,False,False, + False,False,False,False,False,False,False,False,False] + for i in 0..(len(map)-1): + map[i] = bool(random(2)) + return map + +#make the map +var map:TBoolArray +map = random_map() +print_map(map,symbols) +for i in 0..num_turns: + var new_map = map + for j in 0..(len(map)-1): + if map[j]: + if count_neighbours(map, j) == 2 or + count_neighbours(map, j) == 0: + new_map[j] = False + else: + if count_neighbours(map, j) == 2: + new_map[j] = True + if new_map == map: + print_map(map,symbols) + break + map = new_map + print_map(map,symbols) diff --git a/Task/One-dimensional-cellular-automata/OCaml/one-dimensional-cellular-automata.ocaml b/Task/One-dimensional-cellular-automata/OCaml/one-dimensional-cellular-automata.ocaml new file mode 100644 index 0000000000..46722d4b57 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/OCaml/one-dimensional-cellular-automata.ocaml @@ -0,0 +1,29 @@ +let get g i = + try g.(i) + with _ -> 0 + +let next_cell g i = + match get g (i-1), get g (i), get g (i+1) with + | 0, 0, 0 -> 0 + | 0, 0, 1 -> 0 + | 0, 1, 0 -> 0 + | 0, 1, 1 -> 1 + | 1, 0, 0 -> 0 + | 1, 0, 1 -> 1 + | 1, 1, 0 -> 1 + | 1, 1, 1 -> 0 + | _ -> assert(false) + +let next g = + let old_g = Array.copy g in + for i = 0 to pred(Array.length g) do + g.(i) <- (next_cell old_g i) + done + +let print_g g = + for i = 0 to pred(Array.length g) do + if g.(i) = 0 + then print_char '_' + else print_char '#' + done; + print_newline() diff --git a/Task/One-dimensional-cellular-automata/Oz/one-dimensional-cellular-automata.oz b/Task/One-dimensional-cellular-automata/Oz/one-dimensional-cellular-automata.oz new file mode 100644 index 0000000000..1de0310ad1 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Oz/one-dimensional-cellular-automata.oz @@ -0,0 +1,36 @@ +declare + A0 = {List.toTuple unit "_###_##_#_#_#_#__#__"} + + MaxGenerations = 9 + + Rules = unit('___':&_ + '__#':&_ + '_#_':&_ + '_##':&# + '#__':&_ + '#_#':&# + '##_':&# + '###':&_) + + fun {Evolve A} + {Record.mapInd A + fun {$ I V} + Left = {CondSelect A I-1 &_} + Right = {CondSelect A I+1 &_} + Env = {String.toAtom [Left V Right]} + in + Rules.Env + end + } + end + + fun lazy {Iterate X F} + X|{Iterate {F X} F} + end +in + for + I in 0..MaxGenerations + A in {Iterate A0 Evolve} + do + {System.showInfo "Gen. "#I#": "#{Record.toList A}} + end diff --git a/Task/One-dimensional-cellular-automata/PARI-GP/one-dimensional-cellular-automata.pari b/Task/One-dimensional-cellular-automata/PARI-GP/one-dimensional-cellular-automata.pari new file mode 100644 index 0000000000..1341a91c15 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/PARI-GP/one-dimensional-cellular-automata.pari @@ -0,0 +1 @@ +step(v)=my(u=vector(#v),k);u[1]=v[1]&v[2];u[#u]=v[#v]&v[#v-1];for(i=2,#v-1,k=v[i-1]+v[i+1];u[i]=if(v[i],k==1,k==2));u; diff --git a/Task/One-dimensional-cellular-automata/Perl-6/one-dimensional-cellular-automata.pl6 b/Task/One-dimensional-cellular-automata/Perl-6/one-dimensional-cellular-automata.pl6 new file mode 100644 index 0000000000..4fc4924ef9 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Perl-6/one-dimensional-cellular-automata.pl6 @@ -0,0 +1,7 @@ +my @c = <_ #>; +my @array = '_###_##_#_#_#_#__#__'.comb.map: { $_ eq '#' }; + +repeat until @array eqv my @prev { + say @c[@prev = @array]; + @array = ((@array Z+ @array.rotate(1)) Z+ @array.rotate(-1)) X== 2; +} diff --git a/Task/One-dimensional-cellular-automata/Perl/one-dimensional-cellular-automata-1.pl b/Task/One-dimensional-cellular-automata/Perl/one-dimensional-cellular-automata-1.pl new file mode 100644 index 0000000000..5753bd0dc7 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Perl/one-dimensional-cellular-automata-1.pl @@ -0,0 +1,7 @@ +$_="_###_##_#_#_#_#__#__\n"; +do { + y/01/_#/; + print; + y/_#/01/; + s/(?<=(.))(.)(?=(.))/$1 == $3 ? $1 ? 1-$2 : 0 : $2/eg; +} while ($x ne $_ and $x=$_); diff --git a/Task/One-dimensional-cellular-automata/Perl/one-dimensional-cellular-automata-2.pl b/Task/One-dimensional-cellular-automata/Perl/one-dimensional-cellular-automata-2.pl new file mode 100644 index 0000000000..60d19d8544 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Perl/one-dimensional-cellular-automata-2.pl @@ -0,0 +1,6 @@ +$_="_###_##_#_#_#_#__#__\n"; +%h=qw(# _ _ #); +do { + print; + s/(?<=(.))(.)(?=(.))/$1 eq $3 ? $1 eq "_" ? "_" : $h{$2} : $2/eg; +} while ($x ne $_ and $x=$_); diff --git a/Task/One-dimensional-cellular-automata/PicoLisp/one-dimensional-cellular-automata.l b/Task/One-dimensional-cellular-automata/PicoLisp/one-dimensional-cellular-automata.l new file mode 100644 index 0000000000..4725a03c96 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/PicoLisp/one-dimensional-cellular-automata.l @@ -0,0 +1,15 @@ +(let Cells (chop "_###_##_#_#_#_#__#__") + (do 10 + (prinl Cells) + (setq Cells + (make + (link "_") + (map + '((L) + (case (head 3 L) + (`(mapcar chop '("___" "__#" "_#_" "#__" "###")) + (link "_") ) + (`(mapcar chop '("_##" "#_#" "##_")) + (link "#") ) ) ) + Cells ) + (link "_") ) ) ) ) diff --git a/Task/One-dimensional-cellular-automata/Prolog/one-dimensional-cellular-automata.pro b/Task/One-dimensional-cellular-automata/Prolog/one-dimensional-cellular-automata.pro new file mode 100644 index 0000000000..a2ee05e30f --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Prolog/one-dimensional-cellular-automata.pro @@ -0,0 +1,52 @@ +one_dimensional_cellular_automata(L) :- + maplist(my_write, L), nl, + length(L, N), + length(LN, N), + % there is a 0 before the beginning + compute_next([0 |L], LN), + ( L \= LN -> one_dimensional_cellular_automata(LN); true). + +% All the possibilites +compute_next([0, 0, 0 | R], [0 | R1]) :- + compute_next([0, 0 | R], R1). + +compute_next([0, 0, 1 | R], [0 | R1]) :- + compute_next([0, 1 | R], R1). + +compute_next([0, 1, 0 | R], [0 | R1]) :- + compute_next([1, 0 | R], R1). + +compute_next([0, 1, 1 | R], [1 | R1]) :- + compute_next([1, 1 | R], R1). + +compute_next([1, 0, 0 | R], [0 | R1]) :- + compute_next([0, 0 | R], R1). + +compute_next([1, 0, 1 | R], [1 | R1]) :- + compute_next([0, 1 | R], R1). + +compute_next([1, 1, 0 | R], [1 | R1]) :- + compute_next([1, 0 | R], R1). + +compute_next([1, 1, 1 | R], [0 | R1]) :- + compute_next([1, 1 | R], R1). + +% the last four possibilies => +% we consider that there is à 0 after the end +compute_next([0, 0], [0]). + +compute_next([1, 0], [0]). + +compute_next([0, 1], [0]). + +compute_next([1, 1], [1]). + +my_write(0) :- + write(.). + +my_write(1) :- + write(#). + +one_dimensional_cellular_automata :- + L = [0,1,1,1,0,1,1,0,1,0,1,0,1,0,1,0,0,1,0,0], + one_dimensional_cellular_automata(L). diff --git a/Task/One-dimensional-cellular-automata/PureBasic/one-dimensional-cellular-automata.purebasic b/Task/One-dimensional-cellular-automata/PureBasic/one-dimensional-cellular-automata.purebasic new file mode 100644 index 0000000000..3d79f77f06 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/PureBasic/one-dimensional-cellular-automata.purebasic @@ -0,0 +1,31 @@ +EnableExplicit +Dim cG.i(21) +Dim nG.i(21) +Define.i n, Gen + +DataSection + Data.i 0,1,1,1,0,1,1,0,1,0,1,0,1,0,1,0,0,1,0,0 +EndDataSection +For n=1 To 20 + Read.i cG(n) +Next + +OpenConsole() +Repeat + Print("Generation "+Str(Gen)+": ") + For n=1 To 20 + Print(Chr(95-cG(n)*60)) + Next + Gen +1 + PrintN("") + For n=1 To 20 + If (cG(n) And (cG(n-1) XOr cg(n+1))) Or (Not cG(n) And (cG(n-1) And cg(n+1))) + nG(n)=1 + Else + nG(n)=0 + EndIf + Next + Swap cG() , nG() +Until Gen > 9 + +PrintN("Press any key to exit"): Repeat: Until Inkey() <> "" diff --git a/Task/One-dimensional-cellular-automata/Python/one-dimensional-cellular-automata-1.py b/Task/One-dimensional-cellular-automata/Python/one-dimensional-cellular-automata-1.py new file mode 100644 index 0000000000..c9a729978c --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Python/one-dimensional-cellular-automata-1.py @@ -0,0 +1,25 @@ +import random + +printdead, printlive = '_#' +maxgenerations = 10 +cellcount = 20 +offendvalue = '0' + +universe = ''.join(random.choice('01') for i in range(cellcount)) + +neighbours2newstate = { + '000': '0', + '001': '0', + '010': '0', + '011': '1', + '100': '0', + '101': '1', + '110': '1', + '111': '0', + } + +for i in range(maxgenerations): + print "Generation %3i: %s" % ( i, + universe.replace('0', printdead).replace('1', printlive) ) + universe = offendvalue + universe + offendvalue + universe = ''.join(neighbours2newstate[universe[i:i+3]] for i in range(cellcount)) diff --git a/Task/One-dimensional-cellular-automata/Python/one-dimensional-cellular-automata-2.py b/Task/One-dimensional-cellular-automata/Python/one-dimensional-cellular-automata-2.py new file mode 100644 index 0000000000..3738bed869 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Python/one-dimensional-cellular-automata-2.py @@ -0,0 +1,16 @@ +import random + +nquads = 5 +maxgenerations = 10 +fmt = '%%0%ix'%nquads +nbits = 4*nquads +a = random.getrandbits(nbits) << 1 +#a = int('01110110101010100100', 2) << 1 +endmask = (2<>1))))) + a |= endvals + a = ((a&((a<<1) | (a>>1))) ^ ((a<<1)&(a>>1))) & endmask diff --git a/Task/One-dimensional-cellular-automata/R/one-dimensional-cellular-automata.r b/Task/One-dimensional-cellular-automata/R/one-dimensional-cellular-automata.r new file mode 100644 index 0000000000..d21de71a21 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/R/one-dimensional-cellular-automata.r @@ -0,0 +1,33 @@ +set.seed(15797, kind="Mersenne-Twister") + +maxgenerations = 10 +cellcount = 20 +offendvalue = FALSE + +## Cells are alive if TRUE, dead if FALSE +universe <- c(offendvalue, + sample( c(TRUE, FALSE), cellcount, replace=TRUE), + offendvalue) + +## List of patterns in which the cell stays alive +stayingAlive <- lapply(list(c(1,1,0), + c(1,0,1), + c(0,1,0)), as.logical) + +## x : length 3 logical vector +## map: list of length 3 logical vectors that map to patterns +## in which x stays alive +deadOrAlive <- function(x, map) list(x) %in% map + +cellularAutomata <- function(x, map) { + c(x[1], apply(embed(x, 3), 1, deadOrAlive, map=map), x[length(x)]) +} + +deadOrAlive2string <- function(x) { + paste(ifelse(x, '#', '_'), collapse="") +} + +for (i in 1:maxgenerations) { + universe <- cellularAutomata(universe, stayingAlive) + cat(format(i, width=3), deadOrAlive2string(universe), "\n") +} diff --git a/Task/One-dimensional-cellular-automata/Retro/one-dimensional-cellular-automata.retro b/Task/One-dimensional-cellular-automata/Retro/one-dimensional-cellular-automata.retro new file mode 100644 index 0000000000..9bd8dba1ed --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Retro/one-dimensional-cellular-automata.retro @@ -0,0 +1,33 @@ +{{ + : $, ( $- ) withLength [ @+ , ] times @ , ; + create this ".###.##.#.#.#.#..#.." $, + create next this getLength allot + create group "..." $, + variable neighbours + + : reset 0 !neighbours ; + : hasNeighbour? @ '# = [ neighbours ++ ] ifTrue ; + : countNeighboursOnEdge '# = [ 1 ] [ 0 ] if !neighbours ; + : flip dup this + @ '# = [ '. ] [ '# ] if ; + : extract dup this + 1- group 3 copy ; + + : count + ( left ) [ 0 = ] [ @this countNeighboursOnEdge ] when + ( right ) [ 19 = ] [ this 19 + @ countNeighboursOnEdge ] when + ( middle ) reset extract group dup 2 + 2hasNeighbour? ; + + : process + reset count @neighbours + [ 0 = ] [ drop dup next + '. swap ! ] when + [ 1 = ] [ drop dup this + @ over next + ! ] when + [ 2 = ] [ drop flip over next + ! ] when + drop ; + + : generation + 0 this getLength + [ process 1+ ] times drop + next this withLength copy ; +---reveal--- + : generations + cr 0 swap [ [ this swap "%d %s\n" puts ] sip generation 1+ ] times drop ; +}} diff --git a/Task/One-dimensional-cellular-automata/Ruby/one-dimensional-cellular-automata.rb b/Task/One-dimensional-cellular-automata/Ruby/one-dimensional-cellular-automata.rb new file mode 100644 index 0000000000..7e29677849 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Ruby/one-dimensional-cellular-automata.rb @@ -0,0 +1,21 @@ +def evolve(ary) + new = Array.new(ary.length) + new[0] = (ary[0] == 1 and ary[1] == 1) ? 1 : 0 + (1..new.length - 2).each {|i| new[i] = ary[i-1] + ary[i] + ary[i+1] == 2 ? 1 : 0} + new[-1] = (ary[-2] == 1 and ary[-1] == 1) ? 1 : 0 + new +end + +def printit(ary) + s = ary.join("") + s.gsub!(/1/,"#") + s.gsub!(/0/,".") + puts s +end + +ary = [0,1,1,1,0,1,1,0,1,0,1,0,1,0,1,0,0,1,0,0] +printit ary +while ary != new=evolve(ary) + printit new + ary = new +end diff --git a/Task/One-dimensional-cellular-automata/Scala/one-dimensional-cellular-automata.scala b/Task/One-dimensional-cellular-automata/Scala/one-dimensional-cellular-automata.scala new file mode 100644 index 0000000000..b6655822d9 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Scala/one-dimensional-cellular-automata.scala @@ -0,0 +1,11 @@ +def cellularAutomata(s: String) = { + def it = Iterator.iterate(s) ( generation => + ("_%s_" format generation).iterator + sliding 3 + map (_ count (_ == '#')) + map Map(2 -> "#").withDefaultValue("_") + mkString + ) + + (it drop 1) zip it takeWhile Function.tupled(_ != _) map (_._2) foreach println +} diff --git a/Task/One-dimensional-cellular-automata/Scheme/one-dimensional-cellular-automata.ss b/Task/One-dimensional-cellular-automata/Scheme/one-dimensional-cellular-automata.ss new file mode 100644 index 0000000000..217ccb76b0 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Scheme/one-dimensional-cellular-automata.ss @@ -0,0 +1,21 @@ +(define (next-generation left petri-dish right) + (if (null? petri-dish) + (list) + (cons (if (= (+ left + (car petri-dish) + (if (null? (cdr petri-dish)) + right + (cadr petri-dish))) + 2) + 1 + 0) + (next-generation (car petri-dish) (cdr petri-dish) right)))) + +(define (display-evolution petri-dish generations) + (if (not (zero? generations)) + (begin (display petri-dish) + (newline) + (display-evolution (next-generation 0 petri-dish 0) + (- generations 1))))) + +(display-evolution (list 1 1 1 0 1 1 0 1 0 1 0 1 0 1 0 0 1 0) 10) diff --git a/Task/One-dimensional-cellular-automata/Seed7/one-dimensional-cellular-automata.seed7 b/Task/One-dimensional-cellular-automata/Seed7/one-dimensional-cellular-automata.seed7 new file mode 100644 index 0000000000..defb30e28b --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Seed7/one-dimensional-cellular-automata.seed7 @@ -0,0 +1,26 @@ +$ include "seed7_05.s7i"; + +const string: start is "_###_##_#_#_#_#__#__"; + +const proc: main is func + local + var string: g0 is start; + var string: g1 is start; + var integer: generation is 0; + var integer: i is 0; + begin + writeln(g0); + for generation range 0 to 9 do + for i range 2 to pred(length(g0)) do + if g0[i-1] <> g0[i+1] then + g1 @:= [i] g0[i]; + elsif g0[i] = '_' then + g1 @:= [i] g0[i-1]; + else + g1 @:= [i] '_' + end if; + end for; + writeln(g1); + g0 := g1; + end for; + end func; diff --git a/Task/One-dimensional-cellular-automata/Tcl/one-dimensional-cellular-automata.tcl b/Task/One-dimensional-cellular-automata/Tcl/one-dimensional-cellular-automata.tcl new file mode 100644 index 0000000000..945f31aab5 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Tcl/one-dimensional-cellular-automata.tcl @@ -0,0 +1,36 @@ +proc evolve {a} { + set new [list] + for {set i 0} {$i < [llength $a]} {incr i} { + lappend new [fate $a $i] + } + return $new +} + +proc fate {a i} { + return [expr {[sum $a $i] == 2}] +} + +proc sum {a i} { + set sum 0 + set start [expr {$i - 1 < 0 ? 0 : $i - 1}] + set end [expr {$i + 1 >= [llength $a] ? $i : $i + 1}] + for {set j $start} {$j <= $end} {incr j} { + incr sum [lindex $a $j] + } + return $sum +} + +proc print {a} { + puts [string map {0 _ 1 #} [join $a ""]] +} + +proc parse {s} { + return [split [string map {_ 0 # 1} $s] ""] +} + +set array [parse "_###_##_#_#_#_#__#__"] +print $array +while {[set new [evolve $array]] ne $array} { + set array $new + print $array +} diff --git a/Task/One-dimensional-cellular-automata/Ursala/one-dimensional-cellular-automata.ursala b/Task/One-dimensional-cellular-automata/Ursala/one-dimensional-cellular-automata.ursala new file mode 100644 index 0000000000..63b4fa2e79 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Ursala/one-dimensional-cellular-automata.ursala @@ -0,0 +1,12 @@ +#import std +#import nat + +rule = -$<0,0,0,&,0,&,&,0>@rSS zipp0*ziD iota8 + +step = rule*+ swin3+ :/0+ --<0> + +evolve "n" = @iNC ~&x+ rep"n" ^C/step@h ~& + +#show+ + +example = ~&?(`#!,`.!)** evolve10 <0,&,&,&,0,&,&,0,&,0,&,0,&,0,0,&,0,0> diff --git a/Task/One-dimensional-cellular-automata/Vedit-macro-language/one-dimensional-cellular-automata-1.vedit b/Task/One-dimensional-cellular-automata/Vedit-macro-language/one-dimensional-cellular-automata-1.vedit new file mode 100644 index 0000000000..6ddf95a6f7 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Vedit-macro-language/one-dimensional-cellular-automata-1.vedit @@ -0,0 +1,18 @@ +IT("Gen 0: ..###.##.#.#.#.#..#.....") // initial pattern +#9 = Cur_Col + +for (#8 = 1; #8 < 10; #8++) { // 10 generations + Goto_Col(7) + Reg_Empty(20) + while (Cur_Col < #9-1) { + if (Match("|{##|!#,#.#,|!###}")==0) { + Reg_Set(20, "#", APPEND) + } else { + Reg_Set(20, ".", APPEND) + } + Char + } + EOL IN + IT("Gen ") Num_Ins(#8, LEFT+NOCR) IT(": ") + Reg_Ins(20) +} diff --git a/Task/One-dimensional-cellular-automata/Vedit-macro-language/one-dimensional-cellular-automata-2.vedit b/Task/One-dimensional-cellular-automata/Vedit-macro-language/one-dimensional-cellular-automata-2.vedit new file mode 100644 index 0000000000..120c8ffd44 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Vedit-macro-language/one-dimensional-cellular-automata-2.vedit @@ -0,0 +1,10 @@ +Gen 0: ..###.##.#.#.#.#..#..... +Gen 1: ..#.#####.#.#.#......... +Gen 2: ...##...##.#.#.......... +Gen 3: ...##...###.#........... +Gen 4: ...##...#.##............ +Gen 5: ...##....###............ +Gen 6: ...##....#.#............ +Gen 7: ...##.....#............. +Gen 8: ...##................... +Gen 9: ...##................... diff --git a/Task/One-dimensional-cellular-automata/Visual-Basic-.NET/one-dimensional-cellular-automata.visual b/Task/One-dimensional-cellular-automata/Visual-Basic-.NET/one-dimensional-cellular-automata.visual new file mode 100644 index 0000000000..8362a6e745 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/Visual-Basic-.NET/one-dimensional-cellular-automata.visual @@ -0,0 +1,105 @@ +Imports System.Text + +Module CellularAutomata + + Private Enum PetriStatus + Active + Stable + Dead + End Enum + + Function Main(ByVal cmdArgs() As String) As Integer + If cmdArgs.Length = 0 Or cmdArgs.Length > 1 Then + Console.WriteLine("Command requires string of either 1s and 0s or #s and _s.") + Return 1 + End If + + Dim petriDish As BitArray + + Try + petriDish = InitialisePetriDish(cmdArgs(0)) + Catch ex As Exception + Console.WriteLine(ex.Message) + Return 1 + End Try + + Dim generation As Integer = 0 + Dim ps As PetriStatus = PetriStatus.Active + + Do While True + If ps = PetriStatus.Stable Then + Console.WriteLine("Sample stable after {0} generations.", generation - 1) + Exit Do + Else + Console.WriteLine("{0}: {1}", generation.ToString("D3"), BuildDishString(petriDish)) + If ps = PetriStatus.Dead Then + Console.WriteLine("Sample dead after {0} generations.", generation) + Exit Do + End If + End If + + ps = GetNextGeneration(petriDish) + generation += 1 + Loop + + Return 0 + End Function + + Private Function InitialisePetriDish(ByVal Sample As String) As BitArray + Dim PetriDish As New BitArray(Sample.Length) + Dim dead As Boolean = True + + For i As Integer = 0 To Sample.Length - 1 + Select Case Sample.Substring(i, 1) + Case "1", "#" + PetriDish(i) = True + dead = False + Case "0", "_" + PetriDish(i) = False + Case Else + Throw New Exception("Illegal value in string position " & i) + Return Nothing + End Select + Next + + If dead Then + Throw New Exception("Entered sample is dead.") + Return Nothing + End If + + Return PetriDish + End Function + + Private Function GetNextGeneration(ByRef PetriDish As BitArray) As PetriStatus + Dim petriCache = New BitArray(PetriDish.Length) + Dim neighbours As Integer + Dim stable As Boolean = True + Dim dead As Boolean = True + + For i As Integer = 0 To PetriDish.Length - 1 + neighbours = 0 + If i > 0 AndAlso PetriDish(i - 1) Then neighbours += 1 + If i < PetriDish.Length - 1 AndAlso PetriDish(i + 1) Then neighbours += 1 + + petriCache(i) = (PetriDish(i) And neighbours = 1) OrElse (Not PetriDish(i) And neighbours = 2) + If PetriDish(i) <> petriCache(i) Then stable = False + If petriCache(i) Then dead = False + Next + + PetriDish = petriCache + + If dead Then Return PetriStatus.Dead + If stable Then Return PetriStatus.Stable + Return PetriStatus.Active + + End Function + + Private Function BuildDishString(ByVal PetriDish As BitArray) As String + Dim sw As New StringBuilder() + For Each b As Boolean In PetriDish + sw.Append(IIf(b, "#", "_")) + Next + + Return sw.ToString() + End Function +End Module diff --git a/Task/One-dimensional-cellular-automata/XPL0/one-dimensional-cellular-automata.xpl0 b/Task/One-dimensional-cellular-automata/XPL0/one-dimensional-cellular-automata.xpl0 new file mode 100644 index 0000000000..7e9db79748 --- /dev/null +++ b/Task/One-dimensional-cellular-automata/XPL0/one-dimensional-cellular-automata.xpl0 @@ -0,0 +1,12 @@ +code ChOut=8, CrLf=9; +int Gen, Now, New, I; +[Now:= $076A_A400; +for Gen:= 1 to 10 do + [for I:= 31 downto 0 do ChOut(0, if Now & 1<>(I-1) & 7 of %011, %101, %110: New:= New ! 1<one_of_n that given n, the number of actual lines in a file, follows the algorithm above to return an integer - the line number of the line chosen from the file.
The number returned can vary, randomly, in each run. +# Use one_of_n in a ''simulation'' to find what woud be the chosen line of a 10 line file simulated 1,000,000 times. +# Print and show how many times each of the 10 lines is chosen as a rough measure of how well the algorithm works. + +Note: You may choose a smaller number of repetitions if necessary, but mention this up-front. diff --git a/Task/One-of-n-lines-in-a-file/Ada/one-of-n-lines-in-a-file.ada b/Task/One-of-n-lines-in-a-file/Ada/one-of-n-lines-in-a-file.ada new file mode 100644 index 0000000000..c025d44d30 --- /dev/null +++ b/Task/One-of-n-lines-in-a-file/Ada/one-of-n-lines-in-a-file.ada @@ -0,0 +1,34 @@ +with Ada.Text_IO, Ada.Numerics.Float_Random; + +procedure One_Of_N is + + Num_Of_Lines: constant Positive := 10; + + package Rnd renames Ada.Numerics.Float_Random; + Gen: Rnd.Generator; -- used globally + + function Choose_One_Of_N(Last_Line_Number: Positive) return Natural is + Current_Choice: Natural := 0; + begin + for Line_Number in 1 .. Last_Line_Number loop + if (Rnd.Random(Gen) * Float(Line_Number) <= 1.0) then + Current_Choice := Line_Number; + end if; + end loop; + return Current_Choice; + end Choose_One_Of_N; + + Results: array(1 .. Num_Of_Lines) of Natural := (others => 0); + Index: Integer range 1 .. Num_Of_Lines; + +begin + Rnd.Reset(Gen); + for I in 1 .. 1_000_000 loop -- compute results + Index := Choose_One_Of_N(Num_Of_Lines); + Results(Index) := Results(Index) + 1; + end loop; + + for R in Results'Range loop -- output results + Ada.Text_IO.Put(Integer'Image(Results(R))); + end loop; +end One_Of_N; diff --git a/Task/One-of-n-lines-in-a-file/AutoHotkey/one-of-n-lines-in-a-file.ahk b/Task/One-of-n-lines-in-a-file/AutoHotkey/one-of-n-lines-in-a-file.ahk new file mode 100644 index 0000000000..cace222154 --- /dev/null +++ b/Task/One-of-n-lines-in-a-file/AutoHotkey/one-of-n-lines-in-a-file.ahk @@ -0,0 +1,22 @@ +one_of_n(n){ + ; One based line numbers + choice = 1 + Loop % n-1 + { + Random, rnd, 1, % A_Index+1 + If rnd = 1 + choice := A_Index+1 + } + return choice +} +one_of_n_test(n=10, trials=100000){ + bins := [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + Loop % trials + bins[one_of_n(n)] += 1 + return bins +} + +b := one_of_n_test() +Loop 10 + out .= A_Index ": " b[A_Index] "`n" +MsgBox % out diff --git a/Task/One-of-n-lines-in-a-file/BASIC/one-of-n-lines-in-a-file.basic b/Task/One-of-n-lines-in-a-file/BASIC/one-of-n-lines-in-a-file.basic new file mode 100644 index 0000000000..507ad839b1 --- /dev/null +++ b/Task/One-of-n-lines-in-a-file/BASIC/one-of-n-lines-in-a-file.basic @@ -0,0 +1,24 @@ +DECLARE FUNCTION oneofN& (n AS LONG) + +DIM L0 AS LONG, c AS LONG +DIM chosen(1 TO 10) AS LONG + +RANDOMIZE TIMER + +FOR L0 = 1 TO 1000000 + c = oneofN&(10) + chosen(c) = chosen(c) + 1 +NEXT + +FOR L0 = 1 TO 10 + PRINT L0, chosen(L0) +NEXT + +FUNCTION oneofN& (n AS LONG) + 'assumes first line is 1 + DIM L1 AS LONG, choice AS LONG + FOR L1 = 1 TO n + IF INT(RND * L1) = 0 THEN choice = L1 + NEXT + oneofN& = choice +END FUNCTION diff --git a/Task/One-of-n-lines-in-a-file/BBC-BASIC/one-of-n-lines-in-a-file.bbc b/Task/One-of-n-lines-in-a-file/BBC-BASIC/one-of-n-lines-in-a-file.bbc new file mode 100644 index 0000000000..f7cdafa152 --- /dev/null +++ b/Task/One-of-n-lines-in-a-file/BBC-BASIC/one-of-n-lines-in-a-file.bbc @@ -0,0 +1,17 @@ + @% = 7 : REM Column width + DIM cnt%(10) + FOR test% = 1 TO 1000000 + cnt%(FNone_of_n(10)) += 1 + NEXT + FOR i% = 1 TO 10 + PRINT cnt%(i%); + NEXT + PRINT + END + + DEF FNone_of_n(n%) + LOCAL i%, l% + FOR i% = 1 TO n% + IF RND(1) <= 1/i% l% = i% + NEXT + = l% diff --git a/Task/One-of-n-lines-in-a-file/C++/one-of-n-lines-in-a-file.cpp b/Task/One-of-n-lines-in-a-file/C++/one-of-n-lines-in-a-file.cpp new file mode 100644 index 0000000000..c74e417dc1 --- /dev/null +++ b/Task/One-of-n-lines-in-a-file/C++/one-of-n-lines-in-a-file.cpp @@ -0,0 +1,27 @@ +#include +#include +#include +#include +using namespace std; + +mt19937 engine; //mersenne twister + +unsigned int one_of_n(unsigned int n) { + unsigned int choice; + for(unsigned int i = 0; i < n; ++i) { + uniform_int_distribution distribution(0, i); + if(!distribution(engine)) + choice = i; + } + return choice; +} + +int main() { + engine = mt19937(random_device()()); //seed random generator from system + unsigned int results[10] = {0}; + for(unsigned int i = 0; i < 1000000; ++i) + results[one_of_n(10)]++; + ostream_iterator out_it(cout, " "); + copy(results, results+10, out_it); + cout << '\n'; +} diff --git a/Task/One-of-n-lines-in-a-file/C/one-of-n-lines-in-a-file.c b/Task/One-of-n-lines-in-a-file/C/one-of-n-lines-in-a-file.c new file mode 100644 index 0000000000..27f77dac60 --- /dev/null +++ b/Task/One-of-n-lines-in-a-file/C/one-of-n-lines-in-a-file.c @@ -0,0 +1,27 @@ +#include +#include + +inline int irand(int n) +{ + int r, randmax = RAND_MAX/n * n; + while ((r = rand()) >= randmax); + return r / (randmax / n); +} + +inline int one_of_n(int n) +{ + int i, r = 0; + for (i = 1; i < n; i++) if (!irand(i + 1)) r = i; + return r; +} + +int main(void) +{ + int i, r[10] = {0}; + + for (i = 0; i < 1000000; i++, r[one_of_n(10)]++); + for (i = 0; i < 10; i++) + printf("%d%c", r[i], i == 9 ? '\n':' '); + + return 0; +} diff --git a/Task/One-of-n-lines-in-a-file/D/one-of-n-lines-in-a-file.d b/Task/One-of-n-lines-in-a-file/D/one-of-n-lines-in-a-file.d new file mode 100644 index 0000000000..c2ba2bc0df --- /dev/null +++ b/Task/One-of-n-lines-in-a-file/D/one-of-n-lines-in-a-file.d @@ -0,0 +1,19 @@ +import std.stdio, std.random, std.algorithm; + +// Zero-based line numbers. +int oneOfN(in int n) { + int choice = 0; + foreach (i; 1 .. n) + if (!uniform(0, i + 1)) + choice = i; + return choice; +} + +void main() { + int[10] bins; + foreach (i; 0 .. 1_000_000) + bins[oneOfN(10)]++; + + writeln(bins); + writeln("Total of bins: ", reduce!q{a + b}(bins[])); +} diff --git a/Task/One-of-n-lines-in-a-file/Euphoria/one-of-n-lines-in-a-file.euphoria b/Task/One-of-n-lines-in-a-file/Euphoria/one-of-n-lines-in-a-file.euphoria new file mode 100644 index 0000000000..5be664c2e5 --- /dev/null +++ b/Task/One-of-n-lines-in-a-file/Euphoria/one-of-n-lines-in-a-file.euphoria @@ -0,0 +1,27 @@ +-- One of n lines in a file +include std/rand.e +include std/math.e + +function one_of_n(integer n) + integer line_num = 1 + for i = 2 to n do + if rnd() < 1 / i then + line_num = i + end if + end for + return line_num +end function + +procedure main() + integer num_reps = 1000000, num_lines_in_file = 10 + sequence lines = repeat(0,num_lines_in_file) + for i = 1 to num_reps do + lines[one_of_n(num_lines_in_file)] += 1 + end for + for i = 1 to num_lines_in_file do + printf(1,"Number of times line %d was selected: %g\n", {i,lines[i]}) + end for + printf(1,"Total number selected: %d\n", sum(lines) ) +end procedure + +main() diff --git a/Task/One-of-n-lines-in-a-file/Factor/one-of-n-lines-in-a-file-1.factor b/Task/One-of-n-lines-in-a-file/Factor/one-of-n-lines-in-a-file-1.factor new file mode 100644 index 0000000000..a347008266 --- /dev/null +++ b/Task/One-of-n-lines-in-a-file/Factor/one-of-n-lines-in-a-file-1.factor @@ -0,0 +1,11 @@ +! rosettacode/random-line/random-line.factor +USING: io kernel locals math random ; +IN: rosettacode.random-line + +:: random-line ( -- line ) + readln :> choice! 1 :> count! + [ readln dup ] + [ count 1 + dup count! random zero? + [ choice! ] [ drop ] if + ] while drop + choice ; diff --git a/Task/One-of-n-lines-in-a-file/Factor/one-of-n-lines-in-a-file-2.factor b/Task/One-of-n-lines-in-a-file/Factor/one-of-n-lines-in-a-file-2.factor new file mode 100644 index 0000000000..efe4402f5f --- /dev/null +++ b/Task/One-of-n-lines-in-a-file/Factor/one-of-n-lines-in-a-file-2.factor @@ -0,0 +1,31 @@ +! rosettacode/one-of-n/one-of-n.factor +USING: accessors io kernel math rosettacode.random-line ; +IN: rosettacode.one-of-n + + ( n -- stream ) + mock-stream new 0 >>count swap >>last ; +M: mock-stream stream-readln ! stream -- line + dup [ count>> ] [ last>> ] bi < + [ [ 1 + ] change-count count>> ] + [ drop f ] if ; +PRIVATE> + +: one-of-n ( n -- line ) + [ random-line ] with-input-stream* ; + +USING: assocs formatting locals sequences sorting ; +0 ( object/f -- object/0 ) + dup [ drop 0 ] unless ; +:: test-one-of-n ( -- ) + H{ } clone :> chosen + 1000000 [ + 10 one-of-n chosen [ f>0 1 + ] change-at + ] times + chosen keys natural-sort [ + dup chosen at "%d chosen %d times\n" printf + ] each ; +PRIVATE> +MAIN: test-one-of-n diff --git a/Task/One-of-n-lines-in-a-file/Go/one-of-n-lines-in-a-file.go b/Task/One-of-n-lines-in-a-file/Go/one-of-n-lines-in-a-file.go new file mode 100644 index 0000000000..3bf1a57966 --- /dev/null +++ b/Task/One-of-n-lines-in-a-file/Go/one-of-n-lines-in-a-file.go @@ -0,0 +1,82 @@ +package main + +import ( + "bufio" + "fmt" + "io" + "math/rand" + "time" +) + +// choseLineRandomly implements the method described in the task. +// input is a an io.Reader, which could be an os.File, for example. +// Or, to implement a simulation, it could be anything else that implements +// io.Reader. The method as described suggests saving and returning +// lines, but the rest of the task requires line numbers. This function +// thus returns both. +func choseLineRandomly(r io.Reader) (s string, ln int, err error) { + br := bufio.NewReader(r) + s, err = br.ReadString('\n') + if err != nil { + return + } + ln = 1 + lnLast := 1. + var sLast string + for { + // note bufio.ReadString used here. This effectively defines a + // line of the file as zero or more bytes followed by a newline. + sLast, err = br.ReadString('\n') + if err == io.EOF { + return s, ln, nil // normal return + } + if err != nil { + break + } + lnLast++ + if rand.Float64() < 1/lnLast { + s = sLast + ln = int(lnLast) + } + } + return // error return +} + +// oneOfN function required for task item 1. Specified to take a number +// n, the number of lines in a file, but the method (above) specified to +// to be used does not need n, but rather the file itself. This function +// thus takes both, ignoring n and passing the file to choseLineRandomly. +func oneOfN(n int, file io.Reader) int { + _, ln, err := choseLineRandomly(file) + if err != nil { + panic(err) + } + return ln +} + +// simulated file reader for task item 2 +type simReader int + +func (r *simReader) Read(b []byte) (int, error) { + if *r <= 0 { + return 0, io.EOF + } + b[0] = '\n' + *r-- + return 1, nil +} + +func main() { + // task item 2 simulation consists of accumulating frequency statistic + // on 1,000,000 calls of oneOfN on simulated file. + n := 10 + freq := make([]int, n) + rand.Seed(time.Now().UnixNano()) + for times := 0; times < 1e6; times++ { + sr := simReader(n) + freq[oneOfN(n, &sr)-1]++ + } + + // task item 3. show frequencies. + fmt.Println(freq) +} diff --git a/Task/One-of-n-lines-in-a-file/Haskell/one-of-n-lines-in-a-file.hs b/Task/One-of-n-lines-in-a-file/Haskell/one-of-n-lines-in-a-file.hs new file mode 100644 index 0000000000..252456c9e8 --- /dev/null +++ b/Task/One-of-n-lines-in-a-file/Haskell/one-of-n-lines-in-a-file.hs @@ -0,0 +1,33 @@ +import qualified Data.Map as M +import System.Random +import Data.List +import Control.Monad +import System.Environment + +testFile = [1..10] + +selItem g xs = foldl' f (head xs, 1, 2, g) $ tail xs + where f :: RandomGen a => (b, Int, Int, a) -> b -> (b, Int, Int, a) + f (c, cn, n, gen) l | v == 1 = (l, n, n+1, ngen) + | otherwise = (c, cn, n+1, ngen) + where (v, ngen) = randomR (1, n) gen + +oneOfN a = do + g <- newStdGen + let (r, _, _, _) = selItem g a + return r + +test = do + x <- replicateM 1000000 (oneOfN testFile) + let f m l = M.insertWith (+) l 1 m + let results = foldl' f M.empty x + forM_ (M.toList results) $ \(x, y) -> putStrLn $ "Line number " ++ show x ++ + " had count :" ++ show y + +main = do + a <- getArgs + g <- newStdGen + if null a then test + else putStrLn.(\(l, n, _, _) -> "Line " ++ + show n ++ ": " ++ l) + .selItem g.lines =<< (readFile $ head a) diff --git a/Task/One-of-n-lines-in-a-file/Icon/one-of-n-lines-in-a-file.icon b/Task/One-of-n-lines-in-a-file/Icon/one-of-n-lines-in-a-file.icon new file mode 100644 index 0000000000..b76f76ba97 --- /dev/null +++ b/Task/One-of-n-lines-in-a-file/Icon/one-of-n-lines-in-a-file.icon @@ -0,0 +1,17 @@ +procedure main() # one of n + one_of_n_test(10,1000000) +end + +procedure one_of_n(n) + every i := 1 to n do + choice := (?0 < 1. / i, i) + return \choice | fail +end + +procedure one_of_n_test(n,trials) + bins := table(0) + every i := 1 to trials do + bins[one_of_n(n)] +:= 1 + every writes(bins[i := 1 to n]," ") + return bins +end diff --git a/Task/One-of-n-lines-in-a-file/J/one-of-n-lines-in-a-file-1.j b/Task/One-of-n-lines-in-a-file/J/one-of-n-lines-in-a-file-1.j new file mode 100644 index 0000000000..e04a8d081a --- /dev/null +++ b/Task/One-of-n-lines-in-a-file/J/one-of-n-lines-in-a-file-1.j @@ -0,0 +1,20 @@ +randLineBig=:3 :0 + file=. boxopen y + r=. '' + n=. 1 + size=. fsize file + blocksize=. 1e7 + buffer=. '' + for_block. |: blocksize -~/\@(] <. [ * 0 1 +/i.@>.@%~) size do. + buffer=. buffer, fread file,= n then r else + if Random.int (i + 1) = 0 + then aux (succ i) i + else aux (succ i) r + in + aux 1 0 + +let test ~n ~trials = + let ar = Array.make n 0 in + for i = 1 to trials do + let d = one_of_n n in + ar.(d) <- succ ar.(d) + done; + Array.iter (Printf.printf " %d") ar; + print_newline () + +let () = + Random.self_init (); + test ~n:10 ~trials:1_000_000 diff --git a/Task/One-of-n-lines-in-a-file/Pascal/one-of-n-lines-in-a-file.pascal b/Task/One-of-n-lines-in-a-file/Pascal/one-of-n-lines-in-a-file.pascal new file mode 100644 index 0000000000..135a3bd63a --- /dev/null +++ b/Task/One-of-n-lines-in-a-file/Pascal/one-of-n-lines-in-a-file.pascal @@ -0,0 +1,39 @@ +Program OneOfNLines (Output); + +function one_of_n(n: longint): longint; + var + i: longint; + begin + one_of_n := 1; + for i := 2 to n do + if random < 1.0 / i then + one_of_n := i; + end; + +function sum(a: array of longint): longint; + var + i: integer; + begin + sum := 0; + for i := low(a) to high(a) do + sum := sum + a[i]; + end; + +const + num_reps = 1000000; + num_lines_in_file = 10; + +var + lines: array[1..num_reps] of longint; + i: longint; + +begin + randomize; + for i := 1 to num_reps do + lines[i] := 0; + for i := 1 to num_reps do + inc(lines[one_of_n(num_lines_in_file)]); + for i := 1 to num_lines_in_file do + writeln('Number of times line ', i, ' was selected: ', lines[i]); + writeln('Total number selected: ', sum(lines)); +end. diff --git a/Task/One-of-n-lines-in-a-file/Perl-6/one-of-n-lines-in-a-file.pl6 b/Task/One-of-n-lines-in-a-file/Perl-6/one-of-n-lines-in-a-file.pl6 new file mode 100644 index 0000000000..1898e2efbd --- /dev/null +++ b/Task/One-of-n-lines-in-a-file/Perl-6/one-of-n-lines-in-a-file.pl6 @@ -0,0 +1,13 @@ +sub one_of_n($n) { + my $choice; + $choice = $_ if .rand < 1 for 1 .. $n; + $choice - 1; +} + +sub one_of_n_test($n = 10, $trials = 1000000) { + my @bins; + @bins[one_of_n($n)]++ for ^$trials; + @bins; +} + +say one_of_n_test(); diff --git a/Task/One-of-n-lines-in-a-file/PicoLisp/one-of-n-lines-in-a-file.l b/Task/One-of-n-lines-in-a-file/PicoLisp/one-of-n-lines-in-a-file.l new file mode 100644 index 0000000000..0770a7d6e3 --- /dev/null +++ b/Task/One-of-n-lines-in-a-file/PicoLisp/one-of-n-lines-in-a-file.l @@ -0,0 +1,11 @@ +(de one-of-n (N) + (let R 1 + (for I N + (when (= 1 (rand 1 I)) + (setq R I) ) ) + R ) ) + +(let L (need 10 0) + (do 1000000 + (inc (nth L (one-of-n 10))) ) + L ) diff --git a/Task/One-of-n-lines-in-a-file/PureBasic/one-of-n-lines-in-a-file.purebasic b/Task/One-of-n-lines-in-a-file/PureBasic/one-of-n-lines-in-a-file.purebasic new file mode 100644 index 0000000000..c7fe617d69 --- /dev/null +++ b/Task/One-of-n-lines-in-a-file/PureBasic/one-of-n-lines-in-a-file.purebasic @@ -0,0 +1,33 @@ +Procedure.f randomFloat() + ProcedureReturn Random(1000000) / 1000000 +EndProcedure + +Procedure one_of_n(n) + Protected linesRead, lineChosen + While linesRead < n + linesRead + 1 + If randomFloat() <= (1.0 / (linesRead)) + lineChosen = linesRead + EndIf + Wend + ProcedureReturn lineChosen +EndProcedure + +If OpenConsole() + #testFileLineCount = 10 + #simulationCount = 1000000 + Define i + Dim a(#testFileLineCount) ;index 0 is not used + For i = 1 To #simulationCount + x = one_of_n(#testFileLineCount) + a(x) + 1 + Next + + For i = 1 To #testFileLineCount + Print(Str(a(i)) + " ") + Next + PrintN("") + + Print(#CRLF$ + #CRLF$ + "Press ENTER to exit"): Input() + CloseConsole() +EndIf diff --git a/Task/One-of-n-lines-in-a-file/Python/one-of-n-lines-in-a-file.py b/Task/One-of-n-lines-in-a-file/Python/one-of-n-lines-in-a-file.py new file mode 100644 index 0000000000..cc42f0d46d --- /dev/null +++ b/Task/One-of-n-lines-in-a-file/Python/one-of-n-lines-in-a-file.py @@ -0,0 +1,20 @@ +from random import randrange +try: + range = xrange +except: pass + +def one_of_n(lines): # lines is any iterable + choice = None + for i, line in enumerate(lines): + if randrange(i+1) == 0: + choice = line + return choice + +def one_of_n_test(n=10, trials=1000000): + bins = [0] * n + if n: + for i in range(trials): + bins[one_of_n(range(n))] += 1 + return bins + +print(one_of_n_test()) diff --git a/Task/One-of-n-lines-in-a-file/REXX/one-of-n-lines-in-a-file.rexx b/Task/One-of-n-lines-in-a-file/REXX/one-of-n-lines-in-a-file.rexx new file mode 100644 index 0000000000..a640e0dd62 --- /dev/null +++ b/Task/One-of-n-lines-in-a-file/REXX/one-of-n-lines-in-a-file.rexx @@ -0,0 +1,15 @@ +/*REXX pgm simulates reading a ten-line file and make randomness counts.*/ +N=10 /*number of lines in pseudo-file.*/ +#.=0 /*zero all the (ten) buckets. */ + do 1000000 /*perform one million trials. */ + ?=1 + do k=1 for N /*N is the # of lines in the file*/ + if random(0,99999)/100000<1/k then ?=k /*the critera.*/ + end /*k*/ + #.?=#.?+1 /*add it to the bucket counters. */ + end /*1000000*/ + + do j=1 for N /*display the randomness counts. */ + say "number of times line" right(j,2) "was selected:" right(#.j,9) + end /*j*/ + /*stick a fork in it, we're done.*/ diff --git a/Task/One-of-n-lines-in-a-file/Ruby/one-of-n-lines-in-a-file.rb b/Task/One-of-n-lines-in-a-file/Ruby/one-of-n-lines-in-a-file.rb new file mode 100644 index 0000000000..36ca6f6117 --- /dev/null +++ b/Task/One-of-n-lines-in-a-file/Ruby/one-of-n-lines-in-a-file.rb @@ -0,0 +1,29 @@ +# Returns a random line from _io_, or nil if _io_ has no lines. +# # Get a random line from /etc/passwd +# line = open("/etc/passwd") {|f| random_line(f) } +def random_line(io) + choice = io.gets; count = 1 + while line = io.gets + rand(count += 1).zero? and choice = line + end + choice +end + +def one_of_n(n) + # Create a mock IO that provides line numbers instead of lines. + # Assumes that #random_line calls #gets. + (mock_io = Object.new).instance_eval do + @count = 0 + @last = n + def self.gets + (@count < @last) ? (@count += 1) : nil + end + end + random_line(mock_io) +end + +chosen = Hash.new(0) +1_000_000.times { chosen[one_of_n(10)] += 1 } +chosen.keys.sort.each do |key| + puts "#{key} chosen #{chosen[key]} times" +end diff --git a/Task/One-of-n-lines-in-a-file/Run-BASIC/one-of-n-lines-in-a-file.run b/Task/One-of-n-lines-in-a-file/Run-BASIC/one-of-n-lines-in-a-file.run new file mode 100644 index 0000000000..7f306e5858 --- /dev/null +++ b/Task/One-of-n-lines-in-a-file/Run-BASIC/one-of-n-lines-in-a-file.run @@ -0,0 +1,15 @@ +for i1 = 1 to 1000000 + c = oneOfN(10) + chosen(c) = chosen(c) + 1 +next + +for i1 = 1 to 10 + print i1;" ";chosen(i1) +next + +FUNCTION oneOfN(n) + for i2 = 1 to n + IF int(rnd(1) * i2) = 0 then choice = i2 + next + oneOfN = choice +END FUNCTION diff --git a/Task/One-of-n-lines-in-a-file/Seed7/one-of-n-lines-in-a-file.seed7 b/Task/One-of-n-lines-in-a-file/Seed7/one-of-n-lines-in-a-file.seed7 new file mode 100644 index 0000000000..5b993f4afb --- /dev/null +++ b/Task/One-of-n-lines-in-a-file/Seed7/one-of-n-lines-in-a-file.seed7 @@ -0,0 +1,28 @@ +$ include "seed7_05.s7i"; + +const func integer: one_of_n (in integer: n) is func + result + var integer: r is 1; + local + var integer: i is 0; + begin + for i range 2 to n do + if rand(1, i) = 1 then + r := i; + end if; + end for; + end func; + +const proc: main is func + local + var array integer: r is 10 times 0; + var integer: i is 0; + begin + for i range 1 to 1000000 do + incr(r[one_of_n(10)]); + end for; + for i range 1 to 10 do + write(r[i] <& " "); + end for; + writeln; + end func; diff --git a/Task/One-of-n-lines-in-a-file/Tcl/one-of-n-lines-in-a-file.tcl b/Task/One-of-n-lines-in-a-file/Tcl/one-of-n-lines-in-a-file.tcl new file mode 100644 index 0000000000..f5d4b2f10b --- /dev/null +++ b/Task/One-of-n-lines-in-a-file/Tcl/one-of-n-lines-in-a-file.tcl @@ -0,0 +1,14 @@ +package require Tcl 8.5 +proc 1ofN {n} { + for {set line 1} {$line <= $n} {incr line} { + if {rand() < 1.0/[incr fraction]} { + set result $line + } + } + return $result +} + +for {set i 0} {$i < 1000000} {incr i} { + incr count([1ofN 10]) +} +parray count; # Alphabetic order, but convenient diff --git a/Task/OpenGL/0DESCRIPTION b/Task/OpenGL/0DESCRIPTION new file mode 100644 index 0000000000..b2ebcb5245 --- /dev/null +++ b/Task/OpenGL/0DESCRIPTION @@ -0,0 +1,3 @@ +In this task, the goal is to display a smooth shaded triangle with OpenGL. + +[[image:Triangle.png|right|thumb|150px|Triangle created using C example compiled with [[GCC]] 4.1.2 and [[freeglut3]].]] diff --git a/Task/OpenGL/1META.yaml b/Task/OpenGL/1META.yaml new file mode 100644 index 0000000000..e48ce5b924 --- /dev/null +++ b/Task/OpenGL/1META.yaml @@ -0,0 +1,7 @@ +--- +category: +- GUI +- Temporal media +note: 3D +requires: +- Graphics diff --git a/Task/OpenGL/Ada/opengl.ada b/Task/OpenGL/Ada/opengl.ada new file mode 100644 index 0000000000..177783cc90 --- /dev/null +++ b/Task/OpenGL/Ada/opengl.ada @@ -0,0 +1,121 @@ +with Lumen.Window; +with Lumen.Events; +with Lumen.Events.Animate; +with GL; +with GLU; + +procedure OpenGL is + + The_Window : Lumen.Window.Handle; + + Program_Exit : Exception; + + -- simply exit this program + procedure Quit_Handler (Event : in Lumen.Events.Event_Data) is + begin + raise Program_Exit; + end; + + -- Resize the scene + procedure Resize_Scene (Width, Height : in Natural) is + use GL; + use GLU; + begin + -- reset current viewport + glViewport (0, 0, GLsizei (Width), GLsizei (Height)); + + -- select projection matrix and reset it + glMatrixMode (GL_PROJECTION); + glLoadIdentity; + + -- calculate aspect ratio + gluPerspective (45.0, GLdouble (Width) / GLdouble (Height), 0.1, 100.0); + + -- select modelview matrix and reset it + glMatrixMode (GL_MODELVIEW); + glLoadIdentity; + end Resize_Scene; + + procedure Init_GL is + use GL; + use GLU; + begin + -- smooth shading + glShadeModel (GL_SMOOTH); + + -- black background + glClearColor (0.0, 0.0, 0.0, 0.0); + + -- depth buffer setup + glClearDepth (1.0); + -- enable depth testing + glEnable (GL_DEPTH_TEST); + -- type of depth test + glDepthFunc (GL_LEQUAL); + + glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); + end Init_GL; + + -- Resize and Initialize the GL window + procedure Resize_Handler (Event : in Lumen.Events.Event_Data) is + Height : Natural := Event.Resize_Data.Height; + Width : Natural := Event.Resize_Data.Width; + begin + -- prevent div by zero + if Height = 0 then + Height := 1; + end if; + + Resize_Scene (Width, Height); + end; + + procedure Draw is + use GL; + begin + -- clear screen and depth buffer + glClear (GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); + -- reset current modelview matrix + glLoadIdentity; + + -- draw triangle + glBegin (GL_TRIANGLES); + glColor3f (1.0, 0.0, 0.0); + glVertex3f ( 0.0, 1.0, 0.0); + glColor3f (0.0, 1.0, 0.0); + glVertex3f (-1.0, -1.0, 0.0); + glColor3f (0.0, 0.0, 1.0); + glVertex3f ( 1.0, -1.0, 0.0); + glEnd; + end Draw; + + procedure Frame_Handler (Frame_Delta : in Duration) is + begin + Draw; + Lumen.Window.Swap (The_Window); + end Frame_Handler; + +begin + + Lumen.Window.Create (Win => The_Window, + Name => "OpenGL Demo", + Width => 640, + Height => 480, + Events => (Lumen.Window.Want_Key_Press => True, + Lumen.Window.Want_Exposure => True, + others => False)); + + Resize_Scene (640, 480); + Init_GL; + + Lumen.Events.Animate.Select_Events + (Win => The_Window, + FPS => Lumen.Events.Animate.Flat_Out, + Frame => Frame_Handler'Unrestricted_Access, + Calls => (Lumen.Events.Resized => Resize_Handler'Unrestricted_Access, + Lumen.Events.Close_Window => Quit_Handler'Unrestricted_Access, + others => Lumen.Events.No_Callback)); + +exception + when Program_Exit => + null; -- normal termination +end OpenGL; diff --git a/Task/OpenGL/AutoHotkey/opengl.ahk b/Task/OpenGL/AutoHotkey/opengl.ahk new file mode 100644 index 0000000000..00e01bc2ff --- /dev/null +++ b/Task/OpenGL/AutoHotkey/opengl.ahk @@ -0,0 +1,61 @@ +hOpenGL32 := DllCall("LoadLibrary", "Str", "opengl32") +Gui, +LastFound +Resize +hDC := DllCall("GetDC", "uInt", WinExist()) + +VarSetCapacity(pfd, 40, 0) +NumPut(40, pfd, 0, "uShort") +NumPut(1, pfd, 2, "uShort") +NumPut(37, pfd, 4, "uInt") +NumPut(24, pfd, 9, "uChar") +NumPut(16, pfd, 23, "uChar") +DllCall("SetPixelFormat", "uInt", hDC, "uInt", DllCall("ChoosePixelFormat", "uInt", hDC, "uInt", &pfd), "uInt", &pfd) + +hRC := DllCall("opengl32\wglCreateContext", "uInt", hDC) +DllCall("opengl32\wglMakeCurrent", "uInt", hDC, "uInt", hRC) +Gui, Show, w640 h480, Triangle +OnExit, ExitSub +SetTimer, Paint, 50 +return + + +Paint: +DllCall("opengl32\glClearColor", "Float", 0.3, "Float", 0.3, "Float", 0.3, "Float", 0) +DllCall("opengl32\glClear", "uInt", 0x4100) ;GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT + +DllCall("opengl32\glShadeModel", "uInt", 0x1D01) ;GL_SMOOTH + +DllCall("opengl32\glLoadIdentity") +DllCall("opengl32\glTranslatef", "Float", -15, "Float", -15, "Float", 0) + +DllCall("opengl32\glBegin", "uInt", 0x0004) ;GL_TRIANGLES +DllCall("opengl32\glColor3f", "Float", 1, "Float", 0, "Float", 0) +DllCall("opengl32\glVertex2f", "Float", 0, "Float", 0) +DllCall("opengl32\glColor3f", "Float", 0, "Float", 1, "Float", 0) +DllCall("opengl32\glVertex2f", "Float", 30, "Float", 0) +DllCall("opengl32\glColor3f", "Float", 0, "Float", 0, "Float", 1) +DllCall("opengl32\glVertex2f", "Float", 0, "Float", 30) +DllCall("opengl32\glEnd") + +DllCall("SwapBuffers", "uInt", hDC) +return + + +GuiSize: +DllCall("opengl32\glViewport", "Int", 0, "Int", 0, "Int", A_GuiWidth, "Int", A_GuiHeight) +DllCall("opengl32\glMatrixMode", "uInt", 0x1701) ;GL_PROJECTION +DllCall("opengl32\glLoadIdentity") +DllCall("opengl32\glOrtho", "Double", -30, "Double", 30, "Double", -30, "Double", 30, "Double", -30, "Double", 30) +DllCall("opengl32\glMatrixMode", "uInt", 0x1700) ;GL_MODELVIEW +return + + +GuiClose: +ExitApp + + +ExitSub: +DllCall("opengl32\wglMakeCurrent", "uInt", 0, "uInt", 0) +DllCall("opengl32\wglDeleteContext", "uInt", hRC) +DllCall("ReleaseDC", "uInt", hDC) +DllCall("FreeLibrary", "uInt", hOpenGL32) +ExitApp diff --git a/Task/OpenGL/BBC-BASIC/opengl.bbc b/Task/OpenGL/BBC-BASIC/opengl.bbc new file mode 100644 index 0000000000..69866fae81 --- /dev/null +++ b/Task/OpenGL/BBC-BASIC/opengl.bbc @@ -0,0 +1,82 @@ + *FLOAT64 + + SYS "LoadLibrary", "OPENGL32.DLL" TO opengl% + SYS "GetProcAddress", opengl%, "wglCreateContext" TO `wglCreateContext` + SYS "GetProcAddress", opengl%, "wglDeleteContext" TO `wglDeleteContext` + SYS "GetProcAddress", opengl%, "wglMakeCurrent" TO `wglMakeCurrent` + SYS "GetProcAddress", opengl%, "glMatrixMode" TO `glMatrixMode` + SYS "GetProcAddress", opengl%, "glClear" TO `glClear` + SYS "GetProcAddress", opengl%, "glBegin" TO `glBegin` + SYS "GetProcAddress", opengl%, "glColor3dv" TO `glColor3dv` + SYS "GetProcAddress", opengl%, "glVertex2dv" TO `glVertex2dv` + SYS "GetProcAddress", opengl%, "glEnd" TO `glEnd` + + MODE 8 + + PFD_MAIN_PLANE = 0 + PFD_TYPE_RGBA = 0 + PFD_DOUBLEBUFFER = 1 + PFD_DRAW_TO_WINDOW = 4 + PFD_SUPPORT_OPENGL = &20 + + GL_MODELVIEW = &1700 + GL_TRIANGLES = 4 + GL_DEPTH_BUFFER_BIT = &00000100 + GL_COLOR_BUFFER_BIT = &00004000 + + ON CLOSE PROCcleanup : QUIT + ON ERROR PROCcleanup : SYS "MessageBox", @hwnd%, REPORT$, 0, 48 : QUIT + + DIM GLcolor{r, g, b}, GLvertex{x, y} + DIM pfd{nSize{l&,h&}, nVersion{l&,h&}, dwFlags%, iPixelType&, cColorBits&, \ + \ cRedBits&, cRedShift&, cGreenBits&, cGreenShift&, cBlueBits&, cBlueShift&, \ + \ cAlphaBits&, cAlphaShift&, cAccumBits&, cAccumRedBits&, cAccumGreenBits&, \ + \ cAccumBlueBits&, cAccumAlphaBits&, cDepthBits&, cStencilBits&, cAuxBuffers&, \ + \ iLayerType&, bReserved&, dwLayerMask%, dwVisibleMask%, dwDamageMask%} + + pfd.nSize.l& = DIM(pfd{}) + pfd.nVersion.l& = 1 + pfd.dwFlags% = PFD_DRAW_TO_WINDOW OR PFD_SUPPORT_OPENGL OR PFD_DOUBLEBUFFER + pfd.dwLayerMask% = PFD_MAIN_PLANE + pfd.iPixelType& = PFD_TYPE_RGBA + pfd.cColorBits& = 24 + pfd.cDepthBits& = 16 + + SYS "GetDC", @hwnd% TO ghDC% + + SYS "ChoosePixelFormat", ghDC%, pfd{} TO pixelformat% + IF pixelformat% = 0 ERROR 100, "ChoosePixelFormat failed" + + SYS "SetPixelFormat", ghDC%, pixelformat%, pfd{} TO res% + IF res% = 0 ERROR 100, "SetPixelFormat failed" + + SYS `wglCreateContext`, ghDC% TO ghRC% + SYS `wglMakeCurrent`, ghDC%, ghRC% + SYS `glMatrixMode`, GL_MODELVIEW + + REPEAT + WAIT 2 + SYS `glClear`, GL_COLOR_BUFFER_BIT OR GL_DEPTH_BUFFER_BIT + SYS `glBegin`, GL_TRIANGLES + GLcolor.r = 1.0 : GLcolor.g = 0.0 : GLcolor.b = 0.0 + SYS `glColor3dv`, GLcolor{} + GLvertex.x = 0.0 : GLvertex.y = 0.8 + SYS `glVertex2dv`, GLvertex{} + GLcolor.r = 0.0 : GLcolor.g = 1.0 : GLcolor.b = 0.0 + SYS `glColor3dv`, GLcolor{} + GLvertex.x = 0.8 : GLvertex.y = -0.8 + SYS `glVertex2dv`, GLvertex{} + GLcolor.r = 0.0 : GLcolor.g = 0.0 : GLcolor.b = 1.0 + SYS `glColor3dv`, GLcolor{} + GLvertex.x = -0.8 : GLvertex.y = -0.8 + SYS `glVertex2dv`, GLvertex{} + SYS `glEnd` + SYS "SwapBuffers", ghDC% + UNTIL FALSE + END + + DEF PROCcleanup + ON ERROR OFF + ghRC% += 0 : IF ghRC% SYS `wglDeleteContext`, ghRC% : ghRC% = 0 + ghDC% += 0 : IF ghDC% SYS "ReleaseDC", @hwnd%, ghDC% : ghDC% = 0 + ENDPROC diff --git a/Task/OpenGL/C/opengl.c b/Task/OpenGL/C/opengl.c new file mode 100644 index 0000000000..baf0118de6 --- /dev/null +++ b/Task/OpenGL/C/opengl.c @@ -0,0 +1,48 @@ +#include +#include +#include + +void paint(void) +{ + glClearColor(0.3,0.3,0.3,0.0); + glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + + glShadeModel(GL_SMOOTH); + + glLoadIdentity(); + glTranslatef(-15.0, -15.0, 0.0); + + glBegin(GL_TRIANGLES); + glColor3f(1.0, 0.0, 0.0); + glVertex2f(0.0, 0.0); + glColor3f(0.0, 1.0, 0.0); + glVertex2f(30.0, 0.0); + glColor3f(0.0, 0.0, 1.0); + glVertex2f(0.0, 30.0); + glEnd(); + + glFlush(); +} + +void reshape(int width, int height) +{ + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0); + glMatrixMode(GL_MODELVIEW); +} + +int main(int argc, char *argv[]) +{ + glutInit(&argc, argv); + glutInitWindowSize(640, 480); + glutCreateWindow("Triangle"); + + glutDisplayFunc(paint); + glutReshapeFunc(reshape); + + glutMainLoop(); + + return EXIT_SUCCESS; +} diff --git a/Task/OpenGL/Clojure/opengl.clj b/Task/OpenGL/Clojure/opengl.clj new file mode 100644 index 0000000000..12acdb6051 --- /dev/null +++ b/Task/OpenGL/Clojure/opengl.clj @@ -0,0 +1,22 @@ +(use 'penumbra.opengl) +(require '[penumbra.app :as app]) + +(defn init [state] + (app/title! "Triangle") + (clear-color 0.3 0.3 0.3 0) + (shade-model :smooth) + state) + +(defn reshape [[x y w h] state] + (ortho-view -30 30 -30 30 -30 30) + (load-identity) + (translate -15 -15) + state) + +(defn display [[dt time] state] + (draw-triangles + (color 1 0 0) (vertex 0 0) + (color 0 1 0) (vertex 30 0) + (color 0 0 1) (vertex 0 30))) + +(app/start {:display display, :reshape reshape, :init init} {}) diff --git a/Task/OpenGL/D/opengl.d b/Task/OpenGL/D/opengl.d new file mode 100644 index 0000000000..6230dab757 --- /dev/null +++ b/Task/OpenGL/D/opengl.d @@ -0,0 +1,32 @@ +module opengl_sample; // file name + directory +import dglut.core, dglut.window, dglut.opengl; + +void main() { + with (new Canvas) { + setName("Triangle"); + map; + + onResize = (Canvas self) { // A delegate literal that takes a parameter. + with (self) glViewport(0, 0, width, height); + MatrixMode.Projection.Identity; // For functions without parameters, the () can be omitted. + glOrtho(-30, 30, -30, 30, -30, 30); + MatrixMode.Modelview; + }; + + onDisplay=(Canvas self) { + scope(exit) self.swap; // Scope guards ease exception-safe programming + glClearColor(0.3f, 0.3f, 0.3f, 0f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glLoadIdentity; + // A convenience wrapper around glTranslatef. Supports numbers, arrays and vectors. + Translate(-15, -15, 0); + // This is a delegate literal as well. Triangles is a wrapper around glBegin and glEnd. + Triangles = { + Color(1f, 0f, 0f); Vertex(0, 0); + Color(0f, 1f, 0f); Vertex(30, 0); + Color(0f, 0f, 1f); Vertex(0, 30); + }; + }; + } + loop; +} diff --git a/Task/OpenGL/Factor/opengl.factor b/Task/OpenGL/Factor/opengl.factor new file mode 100644 index 0000000000..f735f54f21 --- /dev/null +++ b/Task/OpenGL/Factor/opengl.factor @@ -0,0 +1,33 @@ +USING: kernel math math.rectangles opengl.gl sequences ui +ui.gadgets ui.render ; +IN: rosettacode.opengl + +TUPLE: triangle-gadget < gadget ; + +: reshape ( width height -- ) + [ 0 0 ] 2dip glViewport + GL_PROJECTION glMatrixMode + glLoadIdentity + -30.0 30.0 -30.0 30.0 -30.0 30.0 glOrtho + GL_MODELVIEW glMatrixMode ; + +: paint ( -- ) + 0.3 0.3 0.3 0.0 glClearColor + GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT bitor glClear + GL_SMOOTH glShadeModel + glLoadIdentity + -15.0 -15.0 0.0 glTranslatef + GL_TRIANGLES glBegin + 1.0 0.0 0.0 glColor3f 0.0 0.0 glVertex2f + 0.0 1.0 0.0 glColor3f 30.0 0.0 glVertex2f + 0.0 0.0 1.0 glColor3f 0.0 30.0 glVertex2f + glEnd + glFlush ; + +M: triangle-gadget pref-dim* drop { 640 480 } ; +M: triangle-gadget draw-gadget* + rect-bounds nip first2 reshape paint ; + +: triangle-window ( -- ) + [ triangle-gadget new "Triangle" open-window ] with-ui ; +MAIN: triangle-window diff --git a/Task/OpenGL/Forth/opengl-1.fth b/Task/OpenGL/Forth/opengl-1.fth new file mode 100644 index 0000000000..bf3ea15133 --- /dev/null +++ b/Task/OpenGL/Forth/opengl-1.fth @@ -0,0 +1,2 @@ +import glconst import float +glconst also float also opengl also diff --git a/Task/OpenGL/Forth/opengl-2.fth b/Task/OpenGL/Forth/opengl-2.fth new file mode 100644 index 0000000000..4fa0bf2cbf --- /dev/null +++ b/Task/OpenGL/Forth/opengl-2.fth @@ -0,0 +1,54 @@ +#! xbigforth +\ automatic generated code +\ do not edit + +also editor also minos also forth + +include triangle.fs +component class triangle +public: + early widget + early open + early dialog + early open-app + ( [varstart] ) ( [varend] ) +how: + : open new DF[ 0 ]DF s" Triangle" open-component ; + : dialog new DF[ 0 ]DF s" Triangle" open-dialog ; + : open-app new DF[ 0 ]DF s" Triangle" open-application ; +class; + +triangle implements + ( [methodstart] ) ( [methodend] ) + : widget ( [dumpstart] ) + GL[ ^ glcanvas with +0 0 w @ h @ glViewport +GL_PROJECTION glMatrixMode +glLoadIdentity +-30e 30e -30e 30e -30e 30e glOrtho +GL_MODELVIEW glMatrixMode +0.3e 0.3e 0.3e 0.0e glClearColor +GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT or glClear +GL_SMOOTH glShadeModel +glLoadIdentity +-15e -15e 0e glTranslatef +GL_TRIANGLES glBegin +1e 0e 0e glColor3f +0e 0e glVertex2f +0e 1e 0e glColor3f +30e 0e glVertex2f +0e 0e 1e glColor3f +0e 30e glVertex2f +glEnd +glFlush +endwith ]GL ( MINOS ) ^^ CK[ ( x y b n -- ) 2drop 2drop ]CK ( MINOS ) $280 $1 *hfil $1E0 $1 *vfil glcanvas new + &1 vabox new + ( [dumpend] ) ; + : init ^>^^ assign widget 1 :: init ; +class; + +: main + triangle open-app + $1 0 ?DO stop LOOP bye ; +script? [IF] main [THEN] +previous previous previous diff --git a/Task/OpenGL/Haskell/opengl.hs b/Task/OpenGL/Haskell/opengl.hs new file mode 100644 index 0000000000..78b061d2dd --- /dev/null +++ b/Task/OpenGL/Haskell/opengl.hs @@ -0,0 +1,25 @@ +import Graphics.Rendering.OpenGL +import Graphics.UI.GLUT + +main = do + getArgsAndInitialize + createWindow "Triangle" + displayCallback $= display + + matrixMode $= Projection + loadIdentity + ortho2D 0 30 0 30 + matrixMode $= Modelview 0 + + mainLoop + +display = do + clear [ColorBuffer] + renderPrimitive Triangles $ do + corner 1 0 0 5 5 + corner 0 1 0 25 5 + corner 0 0 1 5 25 + swapBuffers + +corner r g b x y = do color (Color3 r g b :: Color3 GLfloat) + vertex (Vertex2 x y :: Vertex2 GLfloat) diff --git a/Task/OpenGL/J/opengl.j b/Task/OpenGL/J/opengl.j new file mode 100644 index 0000000000..2a639f01de --- /dev/null +++ b/Task/OpenGL/J/opengl.j @@ -0,0 +1,31 @@ +coclass 'example' +(coinsert[require) 'jzopengl' + +create=:3 :0 + ogl=: ''conew'jzopengl' + wd 'pc p;cc c isigraph opengl rightmove bottommove;pas 0 0;pshow;' +) + +p_close=: destroy=:3 :0 + destroy__ogl'' + wd'pclose' + codestroy'' +) + +corner=:4 :0 + glColor3d x + glVertex2d y +) + +p_c_paint=:3 :0 + rc__ogl'' + glClear GL_COLOR_BUFFER_BIT + glBegin GL_TRIANGLES + 1 0 0 corner 0 0-0.5 + 0 1 0 corner 1 0-0.5 + 0 0 1 corner 0 1-0.5 + glEnd'' + show__ogl'' +) + +conew~'example' diff --git a/Task/OpenGL/Java/opengl.java b/Task/OpenGL/Java/opengl.java new file mode 100644 index 0000000000..9952958b88 --- /dev/null +++ b/Task/OpenGL/Java/opengl.java @@ -0,0 +1,57 @@ +import org.lwjgl.LWJGLException; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.DisplayMode; +import static org.lwjgl.opengl.GL11.*; + + +public class OpenGlExample { + + public void run() throws LWJGLException { + Display.setDisplayMode(new DisplayMode(640, 480)); + Display.create(); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-30, 30, -30, 30, -30, 30); + glMatrixMode(GL_MODELVIEW); + + while(!Display.isCloseRequested()) { + render(); + + Display.update(); + } + + Display.destroy(); + } + + public void render() { + + glClearColor(0.3f, 0.3f, 0.3f, 0.0f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glShadeModel(GL_SMOOTH); + + glLoadIdentity(); + glTranslatef(-15.0f, -15.0f, 0.0f); + + glBegin(GL_TRIANGLES); + glColor3f(1.0f, 0.0f, 0.0f); + glVertex2f(0.0f, 0.0f); + glColor3f(0.0f, 1.0f, 0.0f); + glVertex2f(30f, 0.0f); + glColor3f(0.0f, 0.0f, 1.0f); + glVertex2f(0.0f, 30.0f); + glEnd(); + + } + + public static void main(String[] args) { + OpenGlExample openGlExmpl = new OpenGlExample(); + try { + openGlExmpl.run(); + } catch(LWJGLException e) { + System.err.println(e); + } + } + +} diff --git a/Task/OpenGL/JavaScript/opengl.js b/Task/OpenGL/JavaScript/opengl.js new file mode 100644 index 0000000000..936fe47283 --- /dev/null +++ b/Task/OpenGL/JavaScript/opengl.js @@ -0,0 +1,116 @@ + + + Minimal WebGL Example + + + + + + + + + + diff --git a/Task/OpenGL/Liberty-BASIC/opengl.liberty b/Task/OpenGL/Liberty-BASIC/opengl.liberty new file mode 100644 index 0000000000..acdc2b69db --- /dev/null +++ b/Task/OpenGL/Liberty-BASIC/opengl.liberty @@ -0,0 +1,51 @@ +nomainwin + struct rect, x as long, y as long, x2 as long, y2 as long + struct PFD, Size as word, Version as word, Flags as long,_ + PixelType as char[1], ColorBits as char[1], RedBits as char[1],_ + RedShift as char[1], GreenBits as char[1], GreenShift as char[1],_ + BlueBits as char[1], BlueShift as char[1], AlphaBits as char[1],_ + AlphaShift as char[1],AccumBits as char[1], AccumRedBits as char[1],_ + AccumGreenBits as char[1], AccumBlueBits as char[1], AccumAlphaBits as char[1],_ + DepthBits as char[1], StencilBits as char[1], AuxBuffers as char[1],_ + LayerType as char[1], Reserved as char[1], LayerMask as long,_ + VisibleMask as long, DamageMask as long + PFD.Version.struct=1 + PFD.ColorBits.struct=24 + PFD.DepthBits.struct=16 + PFD.Size.struct=len(PFD.struct) + PFD.Flags.struct=37 + GlColorBufferBit=16384 + open "opengl32.dll" for dll as #gl + open "glu32.dll" for dll as #glu + WindowWidth=500 + WindowHeight=500 + UpperLeftX=1 + UpperLeftY=1 + open "Triangle" for window_nf as #main + print #main,"trapclose [quit]" + MainH=hwnd(#main) + calldll #user32,"GetDC", MainH as ulong, MainDC as ulong + calldll #gdi32,"ChoosePixelFormat", MainDC as ulong, PFD as struct, ret as long + calldll #gdi32, "SetPixelFormat", MainDC as ulong, ret as long, PFD as struct, t as long + calldll #gl,"wglCreateContext", MainDC as ulong, GLContext as ulong + calldll #gl,"wglMakeCurrent", MainDC as ulong, GLContext as ulong, ret as long + calldll #gl,"glClear", GlColorBufferBit as long, ret as long + calldll #gl,"glRotated", 0 as double, 0 as double, 0 as double, 0 as double, ret as long + calldll #gl,"glBegin", 4 as long, ret as long + calldll #gl,"glColor3d", 0 as double, 0 as double, 255 as double, ret as long + calldll #gl,"glVertex3i", -1 as long, -1 as long, 0 as long, ret as long + calldll #gl,"glColor3d", 255 as double, 0 as double, 0 as double, ret as long + calldll #gl,"glVertex3i", 0 as long, 1 as long, 0 as long, ret as long + calldll #gl,"glColor3d", 0 as double, 255 as double, 0 as double, ret as long + calldll #gl,"glVertex3i", 1 as long, -1 as long, 0 as long, ret as long + calldll #gl,"glEnd", ret as void + calldll #gdi32,"SwapBuffers", MainDC as ulong, ret as long + wait +[quit] + calldll #gl,"wglMakeCurrent", 0 as ulong, 0 as ulong, ret as long + calldll #gl,"wglDeleteContext", GLContext as ulong, ret as long + calldll #user32, "ReleaseDC", MainH as ulong, MainDC as ulong,ret as long + close #main + close #glu + close #gl + end diff --git a/Task/OpenGL/Lua/opengl.lua b/Task/OpenGL/Lua/opengl.lua new file mode 100644 index 0000000000..31deae0f70 --- /dev/null +++ b/Task/OpenGL/Lua/opengl.lua @@ -0,0 +1,42 @@ +local gl = require "luagl" +local iup = require "iuplua" +require "iupluagl" + +local function paint() + gl.ClearColor(0.3,0.3,0.3,0.0) + gl.Clear"COLOR_BUFFER_BIT,DEPTH_BUFFER_BIT" + + gl.ShadeModel"SMOOTH" + + gl.LoadIdentity() + gl.Translate(-15.0, -15.0, 0.0) + + gl.Begin"TRIANGLES" + gl.Color(1.0, 0.0, 0.0) + gl.Vertex(0.0, 0.0) + gl.Color(0.0, 1.0, 0.0) + gl.Vertex(30.0, 0.0) + gl.Color(0.0, 0.0, 1.0) + gl.Vertex(0.0, 30.0) + gl.End() + + gl.Flush() +end + +local function reshape(width, height) + gl.Viewport(0, 0, width, height) + gl.MatrixMode"PROJECTION" + gl.LoadIdentity() + gl.Ortho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0) + gl.MatrixMode"MODELVIEW" +end + +local glc = iup.glcanvas{rastersize="640x480"} +function glc:action() paint() end +function glc:resize_cb(w,h) reshape(w,h) end +function glc:map_cb() iup.GLMakeCurrent(self) end + +local dlg = iup.dialog{title="Triangle", shrink="yes"; glc} +dlg:show() + +iup.MainLoop() diff --git a/Task/OpenGL/MAXScript/opengl.maxscript b/Task/OpenGL/MAXScript/opengl.maxscript new file mode 100644 index 0000000000..bb09b53c0b --- /dev/null +++ b/Task/OpenGL/MAXScript/opengl.maxscript @@ -0,0 +1,11 @@ +newMesh = mesh numVerts:3 numFaces:1 +setMesh newMesh vertices:#([-100, -100, 0], [100, -100, 0], [-100, 100, 0]) faces:#([1, 2, 3]) +defaultVCFaces newMesh +setVertColor newMesh 1 red +setVertColor newMesh 2 green +setVertColor newMesh 3 blue +setCVertMode newMesh true +update newMesh +viewport.setType #view_top +max tool maximize +viewport.SetRenderLevel #smoothhighlights diff --git a/Task/OpenGL/Mercury/opengl.mercury b/Task/OpenGL/Mercury/opengl.mercury new file mode 100644 index 0000000000..13f1ac6a29 --- /dev/null +++ b/Task/OpenGL/Mercury/opengl.mercury @@ -0,0 +1,46 @@ +:- module opengl. +:- interface. + +:- import_module io. +:- pred main(io::di, io::uo) is det. + +:- implementation. +:- import_module list, glut, glut.callback, glut.window, mogl. + +main(!IO) :- + glut.init_window_size(640, 480, !IO), + glut.window.create("Triangle", !IO), + glut.callback.display_func(opengl.paint, !IO), + glut.callback.reshape_func(opengl.reshape, !IO), + glut.main_loop(!IO). + +:- pred paint(io::di, io::uo) is det. + +paint(!IO) :- + mogl.clear_color(0.3, 0.3, 0.3 , 0.0, !IO), + mogl.clear([color, depth], !IO), + + mogl.shade_model(smooth, !IO), + + mogl.load_identity(!IO), + mogl.translate(-15.0, -15.0, 0.0, !IO), + + mogl.begin(triangles, !IO), + mogl.color3(1.0, 0.0, 0.0, !IO), + mogl.vertex2(0.0, 0.0, !IO), + mogl.color3(0.0, 1.0, 0.0, !IO), + mogl.vertex2(30.0, 0.0, !IO), + mogl.color3(0.0, 0.0, 1.0, !IO), + mogl.vertex2(0.0, 30.0, !IO), + mogl.end(!IO), + + mogl.flush(!IO). + +:- pred reshape(int::in, int::in, io::di, io::uo) is det. + +reshape(Width, Height, !IO) :- + mogl.viewport(0, 0, Width, Height, !IO), + mogl.matrix_mode(projection, !IO), + mogl.load_identity(!IO), + mogl.ortho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0, !IO), + mogl.matrix_mode(modelview, !IO). diff --git a/Task/OpenGL/OCaml/opengl.ocaml b/Task/OpenGL/OCaml/opengl.ocaml new file mode 100644 index 0000000000..caf7aabb9f --- /dev/null +++ b/Task/OpenGL/OCaml/opengl.ocaml @@ -0,0 +1,42 @@ +open GL +open Glut + +let display() = + glClearColor 0.3 0.3 0.3 0.0; + glClear[GL_COLOR_BUFFER_BIT; GL_DEPTH_BUFFER_BIT]; + + glShadeModel GL_SMOOTH; + + glLoadIdentity(); + glTranslate (-15.0) (-15.0) (0.0); + + glBegin GL_TRIANGLES; + glColor3 1.0 0.0 0.0; + glVertex2 0.0 0.0; + glColor3 0.0 1.0 0.0; + glVertex2 30.0 0.0; + glColor3 0.0 0.0 1.0; + glVertex2 0.0 30.0; + glEnd(); + + glFlush(); +;; + +let reshape ~width ~height = + glViewport 0 0 width height; + glMatrixMode GL_PROJECTION; + glLoadIdentity(); + glOrtho(-30.0) 30.0 (-30.0) 30.0 (-30.0) 30.0; + glMatrixMode GL_MODELVIEW; +;; + +let () = + ignore(glutInit Sys.argv); + glutInitWindowSize 640 480; + ignore(glutCreateWindow "Triangle"); + + glutDisplayFunc ~display; + glutReshapeFunc ~reshape; + + glutMainLoop(); +;; diff --git a/Task/OpenGL/OxygenBasic/opengl.oxy b/Task/OpenGL/OxygenBasic/opengl.oxy new file mode 100644 index 0000000000..07ae19347a --- /dev/null +++ b/Task/OpenGL/OxygenBasic/opengl.oxy @@ -0,0 +1,41 @@ + title="Rotating Triangle" + include "OpenglSceneFrame.inc" + + + sub Initialize(sys hWnd) + '======================= + SetTimer hWnd,1,10,NULL + end sub + ' + sub Scene(sys hWnd) + '================== + ' + static single ang1,angi1=1 + ' + glClearColor 0.3, 0.3, 0.5, 0 + glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT + ' + glLoadIdentity + ' + ' + gltranslatef 0.0, 0.0, -4.0 + glrotatef ang1, 0.0, 0.0, 1.0 + ' + glBegin GL_TRIANGLES + glColor3f 1.0, 0.0, 0.0 : glVertex3f 0.0, 1.0, 0.0 + glColor3f 0.0, 1.0, 0.0 : glVertex3f -1.0, -1.0, 0.0 + glColor3f 0.0, 0.0, 1.0 : glVertex3f 1.0, -1.0, 0.0 + glEnd + ' + 'UPDATE ROTATION ANGLES + ' + ang1+=angi1 + if ang1>360 then ang1-=360 + ' + end sub + + + sub Release(sys hwnd) + '==================== + killTimer hwnd, 1 + end sub diff --git a/Task/OpenGL/Pascal/opengl.pascal b/Task/OpenGL/Pascal/opengl.pascal new file mode 100644 index 0000000000..795751ddb7 --- /dev/null +++ b/Task/OpenGL/Pascal/opengl.pascal @@ -0,0 +1,49 @@ +Program OpenGLDemo; + +uses + SysUtils, + ctypes, + gl, + Glut; + +procedure paint; cdecl; +begin + glClearColor(0.3,0.3,0.3,0.0); + glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); + + glShadeModel(GL_SMOOTH); + + glLoadIdentity(); + glTranslatef(-15.0, -15.0, 0.0); + + glBegin(GL_TRIANGLES); + glColor3f(1.0, 0.0, 0.0); + glVertex2f(0.0, 0.0); + glColor3f(0.0, 1.0, 0.0); + glVertex2f(30.0, 0.0); + glColor3f(0.0, 0.0, 1.0); + glVertex2f(0.0, 30.0); + glEnd(); + + glFlush(); +end; + +procedure reshape(width, height: cint); cdecl; +begin + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0); + glMatrixMode(GL_MODELVIEW); +end; + +begin + glutInit(@argc, @argv); + glutInitWindowSize(640, 480); + glutCreateWindow('Triangle'); + + glutDisplayFunc(@paint); + glutReshapeFunc(@reshape); + + glutMainLoop(); +end. diff --git a/Task/OpenGL/Perl/opengl-1.pl b/Task/OpenGL/Perl/opengl-1.pl new file mode 100644 index 0000000000..b7a90d3395 --- /dev/null +++ b/Task/OpenGL/Perl/opengl-1.pl @@ -0,0 +1,24 @@ +use OpenGL; + +sub triangle { + glBegin GL_TRIANGLES; + glColor3f 1.0, 0.0, 0.0; + glVertex2f 5.0, 5.0; + glColor3f 0.0, 1.0, 0.0; + glVertex2f 25.0, 5.0; + glColor3f 0.0, 0.0, 1.0; + glVertex2f 5.0, 25.0; + glEnd; +}; + +glpOpenWindow; +glMatrixMode GL_PROJECTION; +glLoadIdentity; +gluOrtho2D 0.0, 30.0, 0.0, 30.0; +glMatrixMode GL_MODELVIEW; + +glClear GL_COLOR_BUFFER_BIT; +triangle; +glpFlush; + +glpMainLoop; diff --git a/Task/OpenGL/Perl/opengl-2.pl b/Task/OpenGL/Perl/opengl-2.pl new file mode 100644 index 0000000000..9ee9cf8f2d --- /dev/null +++ b/Task/OpenGL/Perl/opengl-2.pl @@ -0,0 +1,29 @@ +use SDL::App; +use SDL::Event; +use SDL::OpenGL; + +$app = SDL::App->new( + -gl => 1, +); + +sub triangle { + glBegin(GL_TRIANGLES); + glColor(1.0, 0.0, 0.0); + glVertex(5.0, 5.0); + glColor(0.0, 1.0, 0.0); + glVertex(25.0, 5.0); + glColor(0.0, 0.0, 1.0); + glVertex(5.0, 25.0); + glEnd(); +} + +glMatrixMode(GL_PROJECTION); +glLoadIdentity(); +gluOrtho2D(0.0, 30.0, 0.0, 30.0); +glMatrixMode(GL_MODELVIEW); +glClear(GL_COLOR_BUFFER_BIT); +triangle(); +$app->sync; +$app->loop ({ + SDL_QUIT() => sub { exit; }, +}); diff --git a/Task/OpenGL/PicoLisp/opengl.l b/Task/OpenGL/PicoLisp/opengl.l new file mode 100644 index 0000000000..e667459894 --- /dev/null +++ b/Task/OpenGL/PicoLisp/opengl.l @@ -0,0 +1,34 @@ +(load "@lib/openGl.l") + +(glutInit) +(glutInitWindowSize 400 300) +(glutCreateWindow "Triangle") + +(displayPrg + (glClearColor 0.3 0.3 0.3 0.0) + (glClear (| GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT)) + (glShadeModel GL_SMOOTH) + (glLoadIdentity) + (glTranslatef -15.0 -15.0 0.0) + (glBegin GL_TRIANGLES) + (glColor3f 1.0 0.0 0.0) + (glVertex2f 0.0 0.0) + (glColor3f 0.0 1.0 0.0) + (glVertex2f 30.0 0.0) + (glColor3f 0.0 0.0 1.0) + (glVertex2f 0.0 30.0) + (glEnd) + (glFlush) ) + +(reshapeFunc + '((Width Height) + (glViewport 0 0 Width Height) + (glMatrixMode GL_PROJECTION) + (glLoadIdentity) + (glOrtho -30.0 30.0 -30.0 30.0 -30.0 30.0) + (glMatrixMode GL_MODELVIEW) ) ) + +# Exit upon mouse click +(mouseFunc '((Btn State X Y) (bye))) + +(glutMainLoop) diff --git a/Task/OpenGL/Pike/opengl.pike b/Task/OpenGL/Pike/opengl.pike new file mode 100644 index 0000000000..d20c2adb9e --- /dev/null +++ b/Task/OpenGL/Pike/opengl.pike @@ -0,0 +1,37 @@ +int main() { + GLUE.init(([ + "fullscreen": 0, + "resolution": ({ 640, 480 }), + ])); + + while (1) { + GL.glViewport(0, 0, 640, 480); + GL.glMatrixMode(GL.GL_PROJECTION); + GL.glLoadIdentity(); + GL.glOrtho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0); + GL.glMatrixMode(GL.GL_MODELVIEW); + + GL.glClearColor(0.3,0.3,0.3,0.0); + GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + + GL.glShadeModel(GL.GL_SMOOTH); + + GL.glLoadIdentity(); + GL.glTranslate(-15.0, -15.0, 0.0); + + GL.glBegin(GL.GL_TRIANGLES); + GL.glColor(1.0, 0.0, 0.0); + GL.glVertex(0.0, 0.0); + GL.glColor(0.0, 1.0, 0.0); + GL.glVertex(30.0, 0.0); + GL.glColor(0.0, 0.0, 1.0); + GL.glVertex(0.0, 30.0); + GL.glEnd(); + + GL.glFlush(); + + GLUE.swap_buffers(); + Pike.DefaultBackend(0.0); + sleep(0.01); + } +} diff --git a/Task/OpenGL/PureBasic/opengl.purebasic b/Task/OpenGL/PureBasic/opengl.purebasic new file mode 100644 index 0000000000..e3c8af70b0 --- /dev/null +++ b/Task/OpenGL/PureBasic/opengl.purebasic @@ -0,0 +1,41 @@ +XIncludeFile "OpenGL.pbi" +pfd.PIXELFORMATDESCRIPTOR +FlatMode = 0 ; Enable Or disable the 'Flat' rendering +WindowWidth = 800 ; The window & GLViewport dimensions +WindowHeight = 600 +hWnd = OpenWindow(0, 0, 0, WindowWidth, WindowHeight, "OpenGL Triangle", #PB_Window_SystemMenu) +hdc = GetDC_(hWnd) +pfd\nSize = SizeOf(PIXELFORMATDESCRIPTOR) +pfd\nVersion = 1 +pfd\dwFlags = #PFD_SUPPORT_OPENGL | #PFD_DOUBLEBUFFER | #PFD_DRAW_TO_WINDOW +pfd\dwLayerMask = #PFD_MAIN_PLANE +pfd\iPixelType = #PFD_TYPE_RGBA +pfd\cColorBits = 24 +pfd\cDepthBits = 16 +pixformat = ChoosePixelFormat_(hdc, pfd) +SetPixelFormat_(hdc, pixformat, pfd) +hrc = wglCreateContext_(hdc) +wglMakeCurrent_(hdc,hrc) +glViewport_ (0, 0, WindowWidth-30, WindowHeight-30) +glPushMatrix_() +glMatrixMode_(#GL_MODELVIEW) +glBegin_(#GL_TRIANGLES ); +glColor3f_(1.0, 0.0, 0.0 ) +glVertex2f_( 0.0, 1.0 ) +glColor3f_( 0.0, 1.0, 0.0 ) +glVertex2f_( 0.87, -0.5 ); +glColor3f_( 0.0, 0.0, 1.0 ) +glVertex2f_( -0.87, -0.5 ); +glEnd_() +glPopMatrix_() +glFinish_() +SwapBuffers_(hdc) +While Quit = 0 + Repeat + EventID = WindowEvent() + Select EventID + Case #PB_Event_CloseWindow + Quit = 1 + EndSelect + Until EventID = 0 +Wend diff --git a/Task/OpenGL/Python/opengl.py b/Task/OpenGL/Python/opengl.py new file mode 100644 index 0000000000..940bdbf90e --- /dev/null +++ b/Task/OpenGL/Python/opengl.py @@ -0,0 +1,41 @@ +#-*- coding: utf8 -*- + +from OpenGL.GL import * +from OpenGL.GLUT import * + +def paint(): + glClearColor(0.3,0.3,0.3,0.0) + glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) + + glShadeModel(GL_SMOOTH) + + glLoadIdentity() + glTranslatef(-15.0, -15.0, 0.0) + + glBegin(GL_TRIANGLES) + glColor3f(1.0, 0.0, 0.0) + glVertex2f(0.0, 0.0) + glColor3f(0.0, 1.0, 0.0) + glVertex2f(30.0, 0.0) + glColor3f(0.0, 0.0, 1.0) + glVertex2f(0.0, 30.0) + glEnd() + + glFlush() + +def reshape(width, height): + glViewport(0, 0, width, height) + glMatrixMode(GL_PROJECTION) + glLoadIdentity() + glOrtho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0) + glMatrixMode(GL_MODELVIEW) + +if __name__ == '__main__': + glutInit(1, 1) + glutInitWindowSize(640, 480) + glutCreateWindow("Triangle") + + glutDisplayFunc(paint) + glutReshapeFunc(reshape) + + glutMainLoop() diff --git a/Task/OpenGL/R/opengl.r b/Task/OpenGL/R/opengl.r new file mode 100644 index 0000000000..9c792a3b2d --- /dev/null +++ b/Task/OpenGL/R/opengl.r @@ -0,0 +1,7 @@ +library(rgl) +x <- c(-1, -1, 1) +y <- c(0, -1, -1) +z <- c(0, 0, 0) +M <- cbind(x,y,z) +rgl.bg(color="gray15") +triangles3d(M, col=rainbow(8)) diff --git a/Task/OpenGL/Racket/opengl.rkt b/Task/OpenGL/Racket/opengl.rkt new file mode 100644 index 0000000000..7c43c2f773 --- /dev/null +++ b/Task/OpenGL/Racket/opengl.rkt @@ -0,0 +1,49 @@ + #lang racket/gui +(require sgl/gl) + +(define (resize w h) + (glViewport 0 0 w h)) + +(define (draw-opengl) + (glClearColor 0.0 0.0 0.0 0.0) + (glClear GL_COLOR_BUFFER_BIT) + + (glShadeModel GL_SMOOTH) + + (glMatrixMode GL_PROJECTION) + (glLoadIdentity) + (glOrtho 0.0 1.0 0.0 1.0 -1.0 1.0) + (glMatrixMode GL_MODELVIEW) + (glLoadIdentity) + + (glBegin GL_TRIANGLES) + (glColor3f 1 0 0) + (glVertex3d 0.25 0.25 0.0) + (glColor3f 0 1 0) + (glVertex3d 0.75 0.25 0.0) + (glColor3f 0 0 1) + (glVertex3d 0.75 0.75 0.0) + (glEnd)) + + +(define my-canvas% + (class* canvas% () + (inherit with-gl-context swap-gl-buffers) + + (define/override (on-paint) + (with-gl-context + (lambda () + (draw-opengl) + (swap-gl-buffers)))) + + (define/override (on-size width height) + (with-gl-context + (lambda () + (resize width height)))) + + (super-instantiate () (style '(gl))))) + +(define win (new frame% (label "Racket Rosetta Code OpenGL example") (min-width 200) (min-height 200))) +(define gl (new my-canvas% (parent win))) + +(send win show #t) diff --git a/Task/OpenGL/Ruby/opengl.rb b/Task/OpenGL/Ruby/opengl.rb new file mode 100644 index 0000000000..f0f9a7f1d3 --- /dev/null +++ b/Task/OpenGL/Ruby/opengl.rb @@ -0,0 +1,44 @@ +require 'rubygems' +require 'gl' +require 'glut' + +include Gl +include Glut + +paint = lambda do + glClearColor(0.3,0.3,0.3,0.0) + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) + + glShadeModel(GL_SMOOTH) + + glLoadIdentity + glTranslatef(-15.0, -15.0, 0.0) + + glBegin(GL_TRIANGLES) + glColor3f(1.0, 0.0, 0.0) + glVertex2f(0.0, 0.0) + glColor3f(0.0, 1.0, 0.0) + glVertex2f(30.0, 0.0) + glColor3f(0.0, 0.0, 1.0) + glVertex2f(0.0, 30.0) + glEnd + + glFlush +end + +reshape = lambda do |width, height| + glViewport(0, 0, width, height) + glMatrixMode(GL_PROJECTION) + glLoadIdentity + glOrtho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0) + glMatrixMode(GL_MODELVIEW) +end + +glutInit +glutInitWindowSize(640, 480) +glutCreateWindow("Triangle") + +glutDisplayFunc(paint) +glutReshapeFunc(reshape) + +glutMainLoop diff --git a/Task/OpenGL/Tcl/opengl.tcl b/Task/OpenGL/Tcl/opengl.tcl new file mode 100644 index 0000000000..74c7f522c8 --- /dev/null +++ b/Task/OpenGL/Tcl/opengl.tcl @@ -0,0 +1,30 @@ +package require Tk +package require tcl3d + +proc resizedWin {win w h} { + glViewport 0 0 $w $h + glMatrixMode GL_PROJECTION + glLoadIdentity + glOrtho -30.0 30.0 -30.0 30.0 -30.0 30.0 + glMatrixMode GL_MODELVIEW +} +proc paintShape {win} { + glClearColor 0.0 0.0 0.0 0.5 + glClear [expr {$::GL_COLOR_BUFFER_BIT+$::GL_DEPTH_BUFFER_BIT}] + glShadeModel GL_SMOOTH + glLoadIdentity + glTranslatef -15.0 -15.0 0.0 + glBegin GL_TRIANGLES + glColor3f 1.0 0.0 0.0 + glVertex2f 5.0 5.0 + glColor3f 0.0 1.0 0.0 + glVertex2f 25.0 5.0 + glColor3f 0.0 0.0 1.0 + glVertex2f 5.0 25.0 + glEnd + $win swapbuffers +} + +togl .surface -width 640 -height 480 -double true -depth true \ + -displayproc paintShape -reshapeproc resizedWin +pack .surface -fill both -expand 1 diff --git a/Task/Operator-precedence/0DESCRIPTION b/Task/Operator-precedence/0DESCRIPTION new file mode 100644 index 0000000000..7af115e570 --- /dev/null +++ b/Task/Operator-precedence/0DESCRIPTION @@ -0,0 +1,4 @@ +{{wikipedia|Operators in C and C++}} + +Provide a list of [[wp:order of operations|precedence]] and [[wp:operator associativity|associativity]] of all the operators and constructs that the language utilizes in descending order of precedence such that an operator which is listed on some row will be evaluated prior to any operator that is listed on a row further below it. Operators that are in the same cell (there may be several rows of operators listed in a cell) are evaluated with the same level of precedence, in the given direction. +Stating whether arguments are passed by value or by reference diff --git a/Task/Operator-precedence/REXX/operator-precedence.rexx b/Task/Operator-precedence/REXX/operator-precedence.rexx new file mode 100644 index 0000000000..f592e4c5cc --- /dev/null +++ b/Task/Operator-precedence/REXX/operator-precedence.rexx @@ -0,0 +1,90 @@ +/* + ╔══════════════════════════════════════════════════════════════════════╗ + ║ ║ + ║ The following is a table that lists the precedence and associativity ║ + ║ of all the operators in the (classic) REXX language. ║ + ║ ║ + ║ 1 is the highest precedence. ║ + ║ ║ + ╠══════════╤════════╤══════════════════════════════════════════════════╣ + ║ │ │ ║ + ║precedence│operator│ description ║ + ║ │ │ ║ + ╟──────────┼────────┼──────────────────────────────────────────────────╢ + ║ 1 │ - │ unary minus ║ + ║ │ + │ unary plus ║ + ║ │ \ │ logical not ║ + ║ │ ├──(the following aren't supported by all REXXes)──╢ + ║ │ ¬ │ logical not ║ + ║ │ ~ │ logical not ║ + ║ │ ^ │ logical not ║ + ╟──────────┼────────┼──────────────────────────────────────────────────╢ + ║ 2 │ ** │ exponentiation (integer power) ║ + ╟──────────┼────────┼──────────────────────────────────────────────────╢ + ║ 3 │ * │ multiplication ║ + ║ │ / │ division ║ + ║ │ % │ integer division ║ + ║ │ // │ modulus (remainder division, sign of dividend)║ + ║ │ / / │ modulus (any 2 or 3 character operators may ║ + ║ │ │ have whitespace between characters.) ║ + ╟──────────┼────────┼──────────────────────────────────────────────────╢ + ║ 4 │ + │ addition ║ + ║ │ - │ subtraction ║ + ╟──────────┼────────┼──────────────────────────────────────────────────╢ + ║ 5 │ || │ concatenation ║ + ╟──────────┼────────┼──────────────────────────────────────────────────╢ + ║ 6 │ & │ logical AND ║ + ║ │ | │ logical OR (inclusive OR) ║ + ║ │ && │ logical XOR (exclusive OR) ║ + ╟──────────┼────────┼──────────────────────────────────────────────────╢ + ║ 7 │[blank] │ concatenation ║ + ║ │abuttal │ concatenation ║ + ╟──────────┼────────┼──────────────────────────────────────────────────╢ + ║ 8 │ = │ equal to ║ + ║ │ == │ exactly equal to (also, strictly equal to) ║ + ║ │ \= │ not equal to ║ + ║ │ <> │ not equal to (also, less than or greater than) ║ + ║ │ >< │ not equal to (also, greater than or less than) ║ + ║ │ > │ greater than ║ + ║ │ >= │ greater than or equal to ║ + ║ │ < │ less than ║ + ║ │ <= │ less than or equal to ║ + ║ │ >> │ exactly greater than ║ + ║ │ << │ exactly less than ║ + ║ │ <<= │ exactly less than or equal to ║ + ║ │ >>= │ exactly greater than or equal to ║ + ║ │ ├──(the following aren't supported by all REXXes)──╢ + ║ │ /= │ not equal to ║ + ║ │ ¬= │ not equal to ║ + ║ │ ~= │ not equal to ║ + ║ │ ^= │ not equal to ║ + ║ │ /== │ not exactly equal to ║ + ║ │ \== │ not exactly equal to ║ + ║ │ ¬== │ not exactly equal to ║ + ║ │ ~== │ not exactly equal to ║ + ║ │ ^== │ not exactly equal to ║ + ║ │ /< │ not less than ║ + ║ │ ~< │ not less than ║ + ║ │ ¬< │ not less than ║ + ║ │ ^< │ not less than ║ + ║ │ /> │ not greater than ║ + ║ │ ¬> │ not greater than ║ + ║ │ ~> │ not greater than ║ + ║ │ ^> │ not greater than ║ + ║ │ /<= │ not less than or equal to ║ + ║ │ ¬<= │ not less than or equal to ║ + ║ │ ~<= │ not less than or equal to ║ + ║ │ ^<= │ not less than or equal to ║ + ║ │ />= │ not greater than or equal to ║ + ║ │ ¬>= │ not greater than or equal to ║ + ║ │ ~>= │ not greater than or equal to ║ + ║ │ ^>= │ not greater than or equal to ║ + ║ │ \>> │ not exactly greater than ║ + ║ │ ¬>> │ not exactly greater than ║ + ║ │ ~>> │ not exactly greater than ║ + ║ │ ^>> │ not exactly greater than ║ + ║ │ \<< │ not exactly less than ║ + ║ │ ¬<< │ not exactly less than ║ + ║ │ ~<< │ not exactly less than ║ + ║ │ ^<< │ not exactly less than ║ + ╚══════════╧════════╧══════════════════════════════════════════════════╝ */ diff --git a/Task/Optional-parameters/0DESCRIPTION b/Task/Optional-parameters/0DESCRIPTION new file mode 100644 index 0000000000..70534fd7d2 --- /dev/null +++ b/Task/Optional-parameters/0DESCRIPTION @@ -0,0 +1,19 @@ +Define a function/method/subroutine which sorts a sequence ("table") of sequences ("rows") of strings ("cells"), by one of the strings. Besides the input to be sorted, it shall have the following optional parameters: +:{| +| +---- +; ordering +: A function specifying the ordering of strings; lexicographic by default. +; column +: An integer specifying which string of each row to compare; the first by default. +; reverse +: Reverses the ordering. +---- +|} + +This task should be considered to include both positional and named optional parameters, as well as overloading on argument count as in Java or selector name as in Smalltalk, or, in the extreme, using different function names. Provide these variations of sorting '''in whatever way is most natural to your language'''. If the language supports both methods naturally, you are encouraged to describe both. + +Do not implement a sorting algorithm; this task is about the interface. If you can't use a built-in sort routine, just omit the implementation (with a comment). + +See also: +* [[Named Arguments]] diff --git a/Task/Optional-parameters/1META.yaml b/Task/Optional-parameters/1META.yaml new file mode 100644 index 0000000000..659c8686af --- /dev/null +++ b/Task/Optional-parameters/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Basic language learning diff --git a/Task/Optional-parameters/Ada/optional-parameters-1.ada b/Task/Optional-parameters/Ada/optional-parameters-1.ada new file mode 100644 index 0000000000..6b82b2d538 --- /dev/null +++ b/Task/Optional-parameters/Ada/optional-parameters-1.ada @@ -0,0 +1,14 @@ +package Tables is + + type Table is private; + + type Ordering is (Lexicographic, Psionic, ...); -- add others + + procedure Sort (It : in out Table; + Order_By : in Ordering := Lexicographic; + Column : in Positive := 1; + Reverse_Ordering : in Boolean := False); + +private + ... -- implementation specific +end Tables; diff --git a/Task/Optional-parameters/Ada/optional-parameters-2.ada b/Task/Optional-parameters/Ada/optional-parameters-2.ada new file mode 100644 index 0000000000..dd56cf6d05 --- /dev/null +++ b/Task/Optional-parameters/Ada/optional-parameters-2.ada @@ -0,0 +1,10 @@ +with Tables; +procedure Table_Test is + My_Table : Tables.Table; +begin + ... -- insert stuff in table + Sort (My_Table); -- use default sorting + Sort (My_Table, Psionic, 5, True); -- use psionic sorting by 5th column in reverse order + Sort (It => My_Table, Reverse_Ordering => True); -- use default sorting in reverse order + ... -- other stuff +end Table_Test; diff --git a/Task/Optional-parameters/AppleScript/optional-parameters-1.applescript b/Task/Optional-parameters/AppleScript/optional-parameters-1.applescript new file mode 100644 index 0000000000..d45fa513ee --- /dev/null +++ b/Task/Optional-parameters/AppleScript/optional-parameters-1.applescript @@ -0,0 +1,20 @@ +on sortTable(x) + set {sortOrdering, sortColumn, sortReverse} to {sort_lexicographic, 1, false} + try + set sortOrdering to x's ordering + end try + try + set sortColumn to x's column + end try + try + set sortReverse to x's reverse + end try + return sortOrdering's sort(x's sequence, sortColumn, sortReverse) +end sortTable + +script sort_lexicographic + on sort(table, column, reverse) + -- Implement lexicographic Sorting process here. + return table + end sort +end script diff --git a/Task/Optional-parameters/AppleScript/optional-parameters-2.applescript b/Task/Optional-parameters/AppleScript/optional-parameters-2.applescript new file mode 100644 index 0000000000..d05e68d8ae --- /dev/null +++ b/Task/Optional-parameters/AppleScript/optional-parameters-2.applescript @@ -0,0 +1,15 @@ +-- Another sort function. +script sort_colex + on sort(table, column, reverse) + -- Implement colexicographic Sorting process here. + return table + end sort +end script + +-- Populate a table (list) with data. +set table to {{1,2},{3,4}} + +sortTable({sequence:table, ordering:sort_lexicographic, column:1, reverse:false}) +sortTable({sequence:table, ordering:sort_colex, column:2, reverse:true}) +sortTable({sequence:table, reverse:true}) +sortTable({sequence:table}) diff --git a/Task/Optional-parameters/AutoHotkey/optional-parameters.ahk b/Task/Optional-parameters/AutoHotkey/optional-parameters.ahk new file mode 100644 index 0000000000..5c39101089 --- /dev/null +++ b/Task/Optional-parameters/AutoHotkey/optional-parameters.ahk @@ -0,0 +1,33 @@ +Gosub start ; create and show the gui +sort_table("Text", column := 2, reverse := 1) ; lexicographic sort +Sleep, 2000 +sort_table("Integer", column := 2, reverse := 1) ; numerical sort +Return + +start: + Gui, Add, ListView, r20 w200, 1|2|3 + data = + ( + 1,2,3 + b,q,z + c,z,z + ) + Loop, Parse, data, `n + { + StringSplit, row, A_LoopField, `, + LV_Add(row, row1, row2, row3) + } + LV_ModifyCol(50) ; Auto-size columns + Gui, Show +Return + +; The function supporting named, defaulted arguments +sort_table(ordering = "Text", column = 0, reverse = 0) +{ + If reverse + desc = desc + LV_ModifyCol(column, "sort" . desc . " " . ordering) +} + +GuiClose: + ExitApp diff --git a/Task/Optional-parameters/BBC-BASIC/optional-parameters.bbc b/Task/Optional-parameters/BBC-BASIC/optional-parameters.bbc new file mode 100644 index 0000000000..f1f738c373 --- /dev/null +++ b/Task/Optional-parameters/BBC-BASIC/optional-parameters.bbc @@ -0,0 +1,10 @@ + DIM table$(100,100) + PROCsort_default(table$()) + PROCsort_options(table$(), TRUE, 1, FALSE) + END + + DEF PROCsort_options(table$(), ordering%, column%, reverse%) + DEF PROCsort_default(table$()) : LOCAL ordering%, column%, reverse% + REM The sort goes here, controlled by the options + REM Zero/FALSE values for the options shall select the defaults + ENDPROC diff --git a/Task/Optional-parameters/C++/optional-parameters.cpp b/Task/Optional-parameters/C++/optional-parameters.cpp new file mode 100644 index 0000000000..591af2f686 --- /dev/null +++ b/Task/Optional-parameters/C++/optional-parameters.cpp @@ -0,0 +1,91 @@ +#include +#include +#include + +// helper comparator that is passed to std::sort() +template +struct sort_table_functor { + typedef bool (*CompFun)(const T &, const T &); + const CompFun ordering; + const int column; + const bool reverse; + sort_table_functor(CompFun o, int c, bool r) : + ordering(o), column(c), reverse(r) { } + bool operator()(const std::vector &x, const std::vector &y) const { + const T &a = x[column], + &b = y[column]; + return reverse ? ordering(b, a) + : ordering(a, b); + } +}; + +// natural-order less-than comparator +template +bool myLess(const T &x, const T &y) { return x < y; } + +// this is the function we call, which takes optional parameters +template +void sort_table(std::vector > &table, + int column = 0, bool reverse = false, + bool (*ordering)(const T &, const T &) = myLess) { + std::sort(table.begin(), table.end(), + sort_table_functor(ordering, column, reverse)); +} + +#include + +// helper function to print our 3x3 matrix +template +void print_matrix(std::vector > &data) { + for () { + for (int j = 0; j < 3; j++) + std::cout << data[i][j] << "\t"; + std::cout << std::endl; + } +} + +// order in descending length +bool desc_len_comparator(const std::string &x, const std::string &y) { + return x.length() > y.length(); +} + +int main() { + + std::string data_array[3][3] = + { + {"a", "b", "c"}, + {"", "q", "z"}, + {"zap", "zip", "Zot"} + }; + + std::vector > data_orig; + for (int i = 0; i < 3; i++) { + std::vector row; + for (int j = 0; j < 3; j++) + row.push_back(data_array[i][j]); + data_orig.push_back(row); + } + print_matrix(data_orig); + + std::vector > data = data_orig; + sort_table(data); + print_matrix(data); + + data = data_orig; + sort_table(data, 2); + print_matrix(data); + + data = data_orig; + sort_table(data, 1); + print_matrix(data); + + data = data_orig; + sort_table(data, 1, true); + print_matrix(data); + + data = data_orig; + sort_table(data, 0, false, desc_len_comparator); + print_matrix(data); + + return 0; +} diff --git a/Task/Optional-parameters/C/optional-parameters.c b/Task/Optional-parameters/C/optional-parameters.c new file mode 100644 index 0000000000..5da69a17b3 --- /dev/null +++ b/Task/Optional-parameters/C/optional-parameters.c @@ -0,0 +1,167 @@ +#include +#include +#include +#include +#include + +typedef const char * String; +typedef struct sTable { + String * *rows; + int n_rows,n_cols; +} *Table; + +typedef int (*CompareFctn)(String a, String b); + +struct { + CompareFctn compare; + int column; + int reversed; +} sortSpec; + +int CmprRows( const void *aa, const void *bb) +{ + String *rA = *(String **)aa; + String *rB = *(String **)bb; + int sortCol = sortSpec.column; + + String left = sortSpec.reversed ? rB[sortCol] : rA[sortCol]; + String right = sortSpec.reversed ? rA[sortCol] : rB[sortCol]; + return sortSpec.compare( left, right ); +} + +/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * tbl parameter is a table of rows of strings + * argSpec is a string containing zero or more of the letters o,c,r + * if o is present - the corresponding optional argument is a function which + * determines the ordering of the strings. + * if c is present - the corresponding optional argument is an integer that + * specifies the column to sort on. + * if r is present - the corresponding optional argument is either + * true(nonzero) or false(zero) and if true, the sort will b in reverse order + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +int sortTable(Table tbl, const char* argSpec,... ) +{ + va_list vl; + const char *p; + int c; + sortSpec.compare = &strcmp; + sortSpec.column = 0; + sortSpec.reversed = 0; + + va_start(vl, argSpec); + if (argSpec) + for (p=argSpec; *p; p++) { + switch (*p) { + case 'o': + sortSpec.compare = va_arg(vl,CompareFctn); + break; + case 'c': + c = va_arg(vl,int); + if ( 0<=c && cn_cols) + sortSpec.column = c; + break; + case 'r': + sortSpec.reversed = (0!=va_arg(vl,int)); + break; + } + } + va_end(vl); + qsort( tbl->rows, tbl->n_rows, sizeof(String *), &CmprRows); + return 0; +} + +void printTable( Table tbl, FILE *fout, const char *colFmts[]) +{ + int row, col; + + for (row=0; rown_rows; row++) { + fprintf(fout, " "); + for(col=0; coln_cols; col++) { + fprintf(fout, colFmts[col], tbl->rows[row][col]); + } + fprintf(fout, "\n"); + } + fprintf(fout, "\n"); +} + +int ord(char v) +{ + return v-'0'; +} + +/* an alternative comparison function */ +int cmprStrgs(String s1, String s2) +{ + const char *p1 = s1; + const char *p2 = s2; + const char *mrk1, *mrk2; + while ((tolower(*p1) == tolower(*p2)) && *p1) { + p1++; p2++; + } + if (isdigit(*p1) && isdigit(*p2)) { + long v1, v2; + if ((*p1 == '0') ||(*p2 == '0')) { + while (p1 > s1) { + p1--; p2--; + if (*p1 != '0') break; + } + if (!isdigit(*p1)) { + p1++; p2++; + } + } + mrk1 = p1; mrk2 = p2; + v1 = 0; + while(isdigit(*p1)) { + v1 = 10*v1+ord(*p1); + p1++; + } + v2 = 0; + while(isdigit(*p2)) { + v2 = 10*v2+ord(*p2); + p2++; + } + if (v1 == v2) + return(p2-mrk2)-(p1-mrk1); + return v1 - v2; + } + if (tolower(*p1) != tolower(*p2)) + return (tolower(*p1) - tolower(*p2)); + for(p1=s1, p2=s2; (*p1 == *p2) && *p1; p1++, p2++); + return (*p1 -*p2); +} + +int main() +{ + const char *colFmts[] = {" %-5.5s"," %-5.5s"," %-9.9s"}; + String r1[] = { "a101", "red", "Java" }; + String r2[] = { "ab40", "gren", "Smalltalk" }; + String r3[] = { "ab9", "blue", "Fortran" }; + String r4[] = { "ab09", "ylow", "Python" }; + String r5[] = { "ab1a", "blak", "Factor" }; + String r6[] = { "ab1b", "brwn", "C Sharp" }; + String r7[] = { "Ab1b", "pink", "Ruby" }; + String r8[] = { "ab1", "orng", "Scheme" }; + + String *rows[] = { r1, r2, r3, r4, r5, r6, r7, r8 }; + struct sTable table; + table.rows = rows; + table.n_rows = 8; + table.n_cols = 3; + + sortTable(&table, ""); + printf("sort on col 0, ascending\n"); + printTable(&table, stdout, colFmts); + + sortTable(&table, "ro", 1, &cmprStrgs); + printf("sort on col 0, reverse.special\n"); + printTable(&table, stdout, colFmts); + + sortTable(&table, "c", 1); + printf("sort on col 1, ascending\n"); + printTable(&table, stdout, colFmts); + + sortTable(&table, "cr", 2, 1); + printf("sort on col 2, reverse\n"); + printTable(&table, stdout, colFmts); + return 0; +} diff --git a/Task/Optional-parameters/Clojure/optional-parameters.clj b/Task/Optional-parameters/Clojure/optional-parameters.clj new file mode 100644 index 0000000000..16d3194099 --- /dev/null +++ b/Task/Optional-parameters/Clojure/optional-parameters.clj @@ -0,0 +1,6 @@ +(defn sort [table & {:keys [ordering column reverse?] + :or {ordering :lex, column 1}}] + (println table ordering column reverse?)) + +(sort [1 8 3] :reverse? true) +[1 8 3] :lex 1 true diff --git a/Task/Optional-parameters/Common-Lisp/optional-parameters-1.lisp b/Task/Optional-parameters/Common-Lisp/optional-parameters-1.lisp new file mode 100644 index 0000000000..a6a5700f37 --- /dev/null +++ b/Task/Optional-parameters/Common-Lisp/optional-parameters-1.lisp @@ -0,0 +1,7 @@ +(defun sort-table (table &key (ordering #'string<) + (column 0) + reverse) + (sort table (if reverse + (complement ordering) + ordering) + :key (lambda (row) (elt row column)))) diff --git a/Task/Optional-parameters/Common-Lisp/optional-parameters-2.lisp b/Task/Optional-parameters/Common-Lisp/optional-parameters-2.lisp new file mode 100644 index 0000000000..e467a48bd0 --- /dev/null +++ b/Task/Optional-parameters/Common-Lisp/optional-parameters-2.lisp @@ -0,0 +1,17 @@ +CL-USER> (defparameter *data* '(("a" "b" "c") ("" "q" "z") ("zap" "zip" "Zot"))) +*DATA* + +CL-USER> (sort-table *data*) +(("" "q" "z") ("a" "b" "c") ("zap" "zip" "Zot")) + +CL-USER> (sort-table *data* :column 2) +(("zap" "zip" "Zot") ("a" "b" "c") ("" "q" "z")) + +CL-USER> (sort-table *data* :column 1) +(("a" "b" "c") ("" "q" "z") ("zap" "zip" "Zot")) + +CL-USER> (sort-table *data* :column 1 :reverse t) +(("zap" "zip" "Zot") ("" "q" "z") ("a" "b" "c")) + +CL-USER> (sort-table *data* :ordering (lambda (a b) (> (length a) (length b)))) +(("zap" "zip" "Zot") ("a" "b" "c") ("" "q" "z")) diff --git a/Task/Optional-parameters/D/optional-parameters.d b/Task/Optional-parameters/D/optional-parameters.d new file mode 100644 index 0000000000..2a645e0780 --- /dev/null +++ b/Task/Optional-parameters/D/optional-parameters.d @@ -0,0 +1,28 @@ +import std.stdio, std.algorithm, std.functional; + +string[][] sortTable(string[][] table, + in bool function(string[],string[]) ordering=null, + in int column = 0, + in bool reverse = false) { + if (ordering is null) + table.schwartzSort!(row => row[column])(); + else + table.sort!ordering(); + if (reverse) + table.reverse(); + return table; +} + +void main() { + auto data = [["a", "b", "c"], + ["", "q", "z"], + ["zap", "zip", "Zot"]]; + + alias show = curry!(writefln, "%-(%s\n%)\n"); + show(data); + show(sortTable(data)); + show(sortTable(data, null, 2)); + show(sortTable(data, null, 1)); + show(sortTable(data, null, 1, true)); + show(sortTable(data, (a,b) => b.length > a.length)); +} diff --git a/Task/Optional-parameters/E/optional-parameters.e b/Task/Optional-parameters/E/optional-parameters.e new file mode 100644 index 0000000000..31ac38a1c1 --- /dev/null +++ b/Task/Optional-parameters/E/optional-parameters.e @@ -0,0 +1,22 @@ +def defaultOrdering(a, b) { return a.op__cmp(b) } + +def sort { + + to run(table) { + return sort(table, 0, false, defaultOrdering) + } + to run(table, column) { + return sort(table, column, false, defaultOrdering) + } + to run(table, column, reverse) { + return sort(table, column, reverse, defaultOrdering) + } + + to run(table :List[List[String]], column :int, reverse :boolean, ordering) { + return table.sort(fn a, b { + def ord := ordering(a[column], b[column]) + if (reverse) { -ord } else { ord } + }) + } + +} diff --git a/Task/Optional-parameters/Fortran/optional-parameters-1.f b/Task/Optional-parameters/Fortran/optional-parameters-1.f new file mode 100644 index 0000000000..a22956ba19 --- /dev/null +++ b/Task/Optional-parameters/Fortran/optional-parameters-1.f @@ -0,0 +1,69 @@ +module ExampleOptionalParameter + ! use any module needed for the sort function(s) + ! and all the interfaces needed to make the code work + implicit none +contains + + subroutine sort_table(table, ordering, column, reverse) + type(table_type), intent(inout) :: table + integer, optional :: column + logical, optional :: reverse + optional :: ordering + interface + integer function ordering(a, b) + type(table_element), intent(in) :: a, b + end function ordering + end interface + + integer :: the_column, i + logical :: reversing + type(table_row) :: rowA, rowB + + if ( present(column) ) then + if ( column > get_num_of_columns(table) ) then + ! raise an error? + else + the_column = column + end if + else + the_column = 1 ! a default value, de facto + end if + + reversing = .false. ! default value + if ( present(reverse) ) reversing = reverse + + do + ! loops over the rows to sort... at some point, we need + ! comparing an element (cell) of the row, with the element + ! in another row; ... let us suppose rowA and rowB are + ! the two rows we are considering + ea = get_element(rowA, the_column) + eb = get_element(rowB, the_column) + if ( present(ordering) ) then + if ( .not. reversing ) then + if ( ordering(ea, eb) > 0 ) then + ! swap the rowA with the rowB + end if + else ! < instead of > + if ( ordering(ea, eb) < 0 ) then + ! swap the rowA with the rowB + end if + end if + else + if ( .not. reversing ) then + if ( lexinternal(ea, eb) > 0 ) then + ! swap the rowA with the rowB + end if + else ! < instead of > + if ( lexinternal(ea, eb) < 0 ) then + ! swap the rowA with the rowB + end if + end if + end if + ! ... more of the sorting algo ... + ! ... and rows traversing ... (and an exit condition of course!) + end do + + end subroutine sort_table + +end module ExampleOptionalParameter diff --git a/Task/Optional-parameters/Fortran/optional-parameters-2.f b/Task/Optional-parameters/Fortran/optional-parameters-2.f new file mode 100644 index 0000000000..d0aa93dc80 --- /dev/null +++ b/Task/Optional-parameters/Fortran/optional-parameters-2.f @@ -0,0 +1,36 @@ +program UsingTest + use ExampleOptionalParameter + implicit none + + type(table_type) :: table + + ! create the table... + + ! sorting taking from column 1, not reversed, using internal + ! default comparator + call sort_table(table) + + ! the same as above, but in reversed order; we MUST specify + ! the name of the argument since it is not given in the same + ! order of the subroutine spec + call sort_table(table, reverse=.true.) + + ! sort the table using a custom comparator + call sort_table(table, my_cmp) + ! or + call sort_table(table, ordering=my_cmp) + + ! as above, but taking from column 2 + call sort_table(table, my_cmp, 2) + ! or (swapping the order of args for fun) + call sort_table(table, column=2, ordering=my_cmp) + + ! with custom comparator, column 2 and reversing... + call sort_table(table, my_cmp, 2, .true.) + ! of course we can swap the order of optional args + ! by prefixing them with the name of the arg + + ! sort from column 2, with internal comparator + call sort_table(table, column=2) + +end program UsingTest diff --git a/Task/Optional-parameters/Go/optional-parameters-1.go b/Task/Optional-parameters/Go/optional-parameters-1.go new file mode 100644 index 0000000000..7fbf9dc68f --- /dev/null +++ b/Task/Optional-parameters/Go/optional-parameters-1.go @@ -0,0 +1,5 @@ +type spec struct { + ordering func(cell, cell) bool + column int + reverse bool +} diff --git a/Task/Optional-parameters/Go/optional-parameters-2.go b/Task/Optional-parameters/Go/optional-parameters-2.go new file mode 100644 index 0000000000..903d12efe0 --- /dev/null +++ b/Task/Optional-parameters/Go/optional-parameters-2.go @@ -0,0 +1 @@ +spec{reverse: true} diff --git a/Task/Optional-parameters/Go/optional-parameters-3.go b/Task/Optional-parameters/Go/optional-parameters-3.go new file mode 100644 index 0000000000..504aee76d4 --- /dev/null +++ b/Task/Optional-parameters/Go/optional-parameters-3.go @@ -0,0 +1,93 @@ +package main + +import ( + "fmt" + "sort" +) + +type cell string +type row []cell +type table struct { + rows []row + column int + less func(cell, cell) bool +} + +func (c cell) String() string { + return fmt.Sprintf("%q", string(c)) +} + +func (t table) printRows(heading string) { + fmt.Println("--", heading) + for _, row := range t.rows { + fmt.Println(row) + } + fmt.Println() +} + +// sort.Interface +func (t table) Len() int { return len(t.rows) } +func (t table) Swap(i, j int) { t.rows[i], t.rows[j] = t.rows[j], t.rows[i] } +func (t table) Less(i, j int) bool { + return t.less(t.rows[i][t.column], t.rows[j][t.column]) +} + +// struct implements named parameter-like capability +type spec struct { + ordering func(cell, cell) bool + column int + reverse bool +} + + +func (t *table) sort(s spec) { + // set up column and comparison function for sort + t.column = s.column + switch { + case s.ordering != nil: + t.less = s.ordering + case s.reverse: + t.less = func(a, b cell) bool { return a > b } + default: + t.less = func(a, b cell) bool { return a < b } + } + + // sort + sort.Sort(t) + + // reverse if necessary + if s.ordering == nil || !s.reverse { + return + } + last := len(t.rows) - 1 + for i := last / 2; i >= 0; i-- { + t.rows[i], t.rows[last-i] = t.rows[last-i], t.rows[i] + } +} + +func main() { + t := table{rows: []row{ + {"pail", "food"}, + {"pillbox", "nurse maids"}, + {"suitcase", "airedales"}, + {"bathtub", "chocolate"}, + {"schooner", "ice cream sodas"}, + }} + + t.printRows("song") + + // no "parameters" + t.sort(spec{}) + t.printRows("sorted on first column") + + // "named parameter" reverse. + t.sort(spec{reverse: true}) + t.printRows("reverse sorted on first column") + + // "named parameters" column and ordering + t.sort(spec{ + column: 1, + ordering: func(a, b cell) bool { return len(a) > len(b) }, + }) + t.printRows("sorted by descending string length on second column") +} diff --git a/Task/Optional-parameters/Icon/optional-parameters.icon b/Task/Optional-parameters/Icon/optional-parameters.icon new file mode 100644 index 0000000000..6cb9dfef06 --- /dev/null +++ b/Task/Optional-parameters/Icon/optional-parameters.icon @@ -0,0 +1,20 @@ +procedure main() + X := [ [1,2,3], [2,3,1], [3,1,2]) # A list of lists + Sort(X) # vanilla sort + Sort(X,"ordering","numeric","column",2,"reverse") # using optional parameters +end + +procedure Sort(X,A[]) # A[] provides for a variable number of arguments + while a := get(A) do { + case a of { + "ordering" : op := case get(A) | runerr(205,a) of { + "lexicographic"|"string": "<<" + "numeric": "<" + default: runerr(205,op) + } + "column" : col := 0 < integer(col := get(A)) | runerr(205,col) + "reverse" : reverseorder := reverse + default: runerr(205,a) + } + return (\reverseorder|1)(bubblesortf(X,\c|1,\op|"<<")) # reverse or return the sorted list +end diff --git a/Task/Optional-parameters/J/optional-parameters-1.j b/Task/Optional-parameters/J/optional-parameters-1.j new file mode 100644 index 0000000000..db3b5d8819 --- /dev/null +++ b/Task/Optional-parameters/J/optional-parameters-1.j @@ -0,0 +1,6 @@ +srtbl=: verb define + '' srtbl y +: + '`ordering column reverse'=. x , (#x)}. ]`0:`0: + |.^:reverse y /: ordering (column {"1 ])y +) diff --git a/Task/Optional-parameters/J/optional-parameters-2.j b/Task/Optional-parameters/J/optional-parameters-2.j new file mode 100644 index 0000000000..b5ad6e093d --- /dev/null +++ b/Task/Optional-parameters/J/optional-parameters-2.j @@ -0,0 +1,40 @@ + ]Table=: ('a';'b';'c'),('';'q';'z'),:'zip';'zap';'Zot' +┌───┬───┬───┐ +│a │b │c │ +├───┼───┼───┤ +│ │q │z │ +├───┼───┼───┤ +│zip│zap│Zot│ +└───┴───┴───┘ + srtbl Table NB. default sort +┌───┬───┬───┐ +│ │q │z │ +├───┼───┼───┤ +│a │b │c │ +├───┼───┼───┤ +│zip│zap│Zot│ +└───┴───┴───┘ + ]`1: srtbl Table NB. sort by column 1 +┌───┬───┬───┐ +│a │b │c │ +├───┼───┼───┤ +│ │q │z │ +├───┼───┼───┤ +│zip│zap│Zot│ +└───┴───┴───┘ + ]`2:`1: srtbl Table NB. reverse sort by column 2 +┌───┬───┬───┐ +│zip│zap│Zot│ +├───┼───┼───┤ +│ │q │z │ +├───┼───┼───┤ +│a │b │c │ +└───┴───┴───┘ + #&>`0: srtbl Table NB. sort by length +┌───┬───┬───┐ +│ │q │z │ +├───┼───┼───┤ +│a │b │c │ +├───┼───┼───┤ +│zip│zap│Zot│ +└───┴───┴───┘ diff --git a/Task/Optional-parameters/Java/optional-parameters.java b/Task/Optional-parameters/Java/optional-parameters.java new file mode 100644 index 0000000000..050c8febb0 --- /dev/null +++ b/Task/Optional-parameters/Java/optional-parameters.java @@ -0,0 +1,73 @@ +import java.util.*; + +public class OptionalParams { + // "natural ordering" comparator + static > Comparator naturalOrdering() { + return Collections.reverseOrder(Collections.reverseOrder()); + } + + public static > void + sortTable(T[][] table) { + sortTable(table, 0); + } + public static > void + sortTable(T[][] table, + int column) { + sortTable(table, column, false); + } + public static > void + sortTable(T[][] table, + int column, boolean reverse) { + sortTable(table, column, reverse, OptionalParams.naturalOrdering()); + } + public static void sortTable(T[][] table, + final int column, + final boolean reverse, + final Comparator ordering) { + Comparator myCmp = new Comparator() { + public int compare(T[] x, T[] y) { + return (reverse ? -1 : 1) * + ordering.compare(x[column], y[column]); + } + }; + Arrays.sort(table, myCmp); + } + + public static void main(String[] args) { + String[][] data0 = {{"a", "b", "c"}, + {"", "q", "z"}, + {"zap", "zip", "Zot"}}; + System.out.println(Arrays.deepToString(data0)); + // prints: [[a, b, c], [, q, z], [zap, zip, Zot]] + + // we copy it so that we don't change the original copy + String[][] data = data0.clone(); + sortTable(data); + System.out.println(Arrays.deepToString(data)); + // prints: [[, q, z], [a, b, c], [zap, zip, Zot]] + + data = data0.clone(); + sortTable(data, 2); + System.out.println(Arrays.deepToString(data)); + // prints: [[zap, zip, Zot], [a, b, c], [, q, z]] + + data = data0.clone(); + sortTable(data, 1); + System.out.println(Arrays.deepToString(data)); + // prints: [[a, b, c], [, q, z], [zap, zip, Zot]] + + data = data0.clone(); + sortTable(data, 1, true); + System.out.println(Arrays.deepToString(data)); + // prints: [[zap, zip, Zot], [, q, z], [a, b, c]] + + data = data0.clone(); + sortTable(data, 0, false, new Comparator() { + public int compare(String a, String b) { + return b.length() - a.length(); + } + }); + System.out.println(Arrays.deepToString(data)); + // prints: [[zap, zip, Zot], [a, b, c], [, q, z]] + } +} diff --git a/Task/Optional-parameters/JavaScript/optional-parameters.js b/Task/Optional-parameters/JavaScript/optional-parameters.js new file mode 100644 index 0000000000..97d7aa78cc --- /dev/null +++ b/Task/Optional-parameters/JavaScript/optional-parameters.js @@ -0,0 +1,10 @@ +function sorter(table, options) { + opts = {} + opts.ordering = options.ordering || 'lexicographic'; + opts.column = options.column || 0; + opts.reverse = options.reverse || false; + + // ... +} + +sorter(the_data, {reverse: true, ordering: 'numeric'}); diff --git a/Task/Optional-parameters/Logo/optional-parameters-1.logo b/Task/Optional-parameters/Logo/optional-parameters-1.logo new file mode 100644 index 0000000000..ce1b464f3a --- /dev/null +++ b/Task/Optional-parameters/Logo/optional-parameters-1.logo @@ -0,0 +1,3 @@ +to sort :table [:column 1] [:ordering "before?] [:reverse "false] + ; ... +end diff --git a/Task/Optional-parameters/Logo/optional-parameters-2.logo b/Task/Optional-parameters/Logo/optional-parameters-2.logo new file mode 100644 index 0000000000..18d7133366 --- /dev/null +++ b/Task/Optional-parameters/Logo/optional-parameters-2.logo @@ -0,0 +1,3 @@ +sort :table +(sort :table 2) +(sort :table 3 "less? "true) diff --git a/Task/Optional-parameters/Mathematica/optional-parameters.math b/Task/Optional-parameters/Mathematica/optional-parameters.math new file mode 100644 index 0000000000..04ca276d2b --- /dev/null +++ b/Task/Optional-parameters/Mathematica/optional-parameters.math @@ -0,0 +1,10 @@ +Options[OptionalSort]={ordering->lexicographic,column->1,reverse-> False}; +OptionalSort[x_List,OptionsPattern[]]:=If[OptionValue[reverse]==True, +SortBy[x ,#[[OptionValue[column]]]&]//Reverse, +SortBy[x,#[[OptionValue[column]]]&] ] + +OptionalSort[{{"a" ,"b", "c"}, {"", "q", "z"},{"zap" ,"zip", "Zot"}} ] +->{{,q,z},{a,b,c},{zap,zip,Zot}} + +OptionalSort[{{"a" ,"b", "c"}, {"", "q", "z"},{"zap" ,"zip", "Zot"}},{ordering->lexicographic,column->2,reverse-> True} ] +->{{zap,zip,Zot},{,q,z},{a,b,c}} diff --git a/Task/Optional-parameters/Nemerle/optional-parameters.nemerle b/Task/Optional-parameters/Nemerle/optional-parameters.nemerle new file mode 100644 index 0000000000..36da06588f --- /dev/null +++ b/Task/Optional-parameters/Nemerle/optional-parameters.nemerle @@ -0,0 +1,4 @@ +Sorter (table : list[list[string]], ordering = "lexicographic", column = 0, reverse = false) : list[list[string]] +{ + // implementation goes here +} diff --git a/Task/Optional-parameters/OCaml/optional-parameters-1.ocaml b/Task/Optional-parameters/OCaml/optional-parameters-1.ocaml new file mode 100644 index 0000000000..640cad458d --- /dev/null +++ b/Task/Optional-parameters/OCaml/optional-parameters-1.ocaml @@ -0,0 +1,3 @@ +let sort_table ?(ordering = compare) ?(column = 0) ?(reverse = false) table = + let cmp x y = ordering (List.nth x column) (List.nth y column) * (if reverse then -1 else 1) in + List.sort cmp table diff --git a/Task/Optional-parameters/OCaml/optional-parameters-2.ocaml b/Task/Optional-parameters/OCaml/optional-parameters-2.ocaml new file mode 100644 index 0000000000..50948340d9 --- /dev/null +++ b/Task/Optional-parameters/OCaml/optional-parameters-2.ocaml @@ -0,0 +1,18 @@ +# let data = [["a"; "b"; "c"]; [""; "q"; "z"]; ["zap"; "zip"; "Zot"]];; +val data : string list list = + [["a"; "b"; "c"]; [""; "q"; "z"]; ["zap"; "zip"; "Zot"]] +# sort_table data;; +- : string list list = +[[""; "q"; "z"]; ["a"; "b"; "c"]; ["zap"; "zip"; "Zot"]] +# sort_table ~column:2 data;; +- : string list list = +[["zap"; "zip"; "Zot"]; ["a"; "b"; "c"]; [""; "q"; "z"]] +# sort_table ~column:1 data;; +- : string list list = +[["a"; "b"; "c"]; [""; "q"; "z"]; ["zap"; "zip"; "Zot"]] +# sort_table ~column:1 ~reverse:true data;; +- : string list list = +[["zap"; "zip"; "Zot"]; [""; "q"; "z"]; ["a"; "b"; "c"]] +# sort_table ~ordering:(fun a b -> compare (String.length b) (String.length a)) data;; +- : string list list = +[["zap"; "zip"; "Zot"]; ["a"; "b"; "c"]; [""; "q"; "z"]] diff --git a/Task/Optional-parameters/Objective-C/optional-parameters.m b/Task/Optional-parameters/Objective-C/optional-parameters.m new file mode 100644 index 0000000000..afacb886eb --- /dev/null +++ b/Task/Optional-parameters/Objective-C/optional-parameters.m @@ -0,0 +1,25 @@ +typedef enum { kOrdNone, kOrdLex, kOrdByAddress, kOrdNumeric } SortOrder; + +@interface MyArray : NSObject {} +// . . . +@end + +@implementation MyArray + +- (void)sort { + [self sortWithOrdering:kOrdLex onColumn:0 reversed:NO]; +} + +- (void)sortWithOrdering:(SortOrder)ord { + [self sortWithOrdering:ord onColumn:0 reversed:NO]; +} + +- (void)sortWithOrdering:(SortOrder)ord onColumn:(int)col { + [self sortWithOrdering:ord onColumn:col reversed:NO]; +} + +- (void)sortWithOrdering:(SortOrder)ord onColumn:(int)col reversed:(BOOL)rev { + // . . . Actual sort goes here . . . +} + +@end diff --git a/Task/Optional-parameters/Oz/optional-parameters.oz b/Task/Optional-parameters/Oz/optional-parameters.oz new file mode 100644 index 0000000000..7ac66bdb75 --- /dev/null +++ b/Task/Optional-parameters/Oz/optional-parameters.oz @@ -0,0 +1,30 @@ +declare + class Table + attr + rows + + meth init(Rows) + rows := Rows + end + + meth sort(ordering:O<=Lexicographic column:C<=1 reverse:R<=false) + fun {Predicate Row1 Row2} + Res = {O {Nth Row1 C} {Nth Row2 C}} + in + if R then {Not Res} else Res end + end + in + rows := {Sort @rows Predicate} + end + end + + fun {Lexicographic As Bs} %% omitted for brevity + end + + T = {New Table init([["a" "b" "c"] ["" "q" "z"] ["zap" "zip" "Zot"]])} +in + {T sort} + {T sort(column:3)} + {T sort(column:2)} + {T sort(column:2 reverse:true)} + {T sort(ordering:fun {$ A B} {Length B} < {Length A} end)} diff --git a/Task/Optional-parameters/PARI-GP/optional-parameters-1.pari b/Task/Optional-parameters/PARI-GP/optional-parameters-1.pari new file mode 100644 index 0000000000..cc35c5bfd1 --- /dev/null +++ b/Task/Optional-parameters/PARI-GP/optional-parameters-1.pari @@ -0,0 +1 @@ +sort(v, ordering=0, column=0, reverse=0) diff --git a/Task/Optional-parameters/PARI-GP/optional-parameters-2.pari b/Task/Optional-parameters/PARI-GP/optional-parameters-2.pari new file mode 100644 index 0000000000..4cba6175a3 --- /dev/null +++ b/Task/Optional-parameters/PARI-GP/optional-parameters-2.pari @@ -0,0 +1,10 @@ +/* +GP;install("test_func", "vDG", "test", "path/to/test.gp.so"); +*/ +void +test_func(GEN x) { + if (x == NULL) + pari_printf("Argument omitted.\n"); + else + pari_printf("Argument was: %Ps\n", x); +} diff --git a/Task/Optional-parameters/Perl-6/optional-parameters.pl6 b/Task/Optional-parameters/Perl-6/optional-parameters.pl6 new file mode 100644 index 0000000000..d922bf6070 --- /dev/null +++ b/Task/Optional-parameters/Perl-6/optional-parameters.pl6 @@ -0,0 +1,4 @@ +method sorttable(:$column = 0, :$reverse, :&ordering = &infix:) { + my @result = self»[$column].sort: &ordering; + return $reverse ?? @result.reverse !! @result; +} diff --git a/Task/Optional-parameters/Perl/optional-parameters-1.pl b/Task/Optional-parameters/Perl/optional-parameters-1.pl new file mode 100644 index 0000000000..8c36119131 --- /dev/null +++ b/Task/Optional-parameters/Perl/optional-parameters-1.pl @@ -0,0 +1,10 @@ +sub sorttable + {my @table = @{shift()}; + my %opt = + (ordering => sub {$_[0] cmp $_[1]}, column => 0, reverse => 0, @_); + my $col = $opt{column}; + my $func = $opt{ordering}; + my @result = sort + {$func->($a->[$col], $b->[$col])} + @table; + return ($opt{reverse} ? [reverse @result] : \@result);} diff --git a/Task/Optional-parameters/Perl/optional-parameters-2.pl b/Task/Optional-parameters/Perl/optional-parameters-2.pl new file mode 100644 index 0000000000..84f7c9f67e --- /dev/null +++ b/Task/Optional-parameters/Perl/optional-parameters-2.pl @@ -0,0 +1,5 @@ +my $a = [["a", "b", "c"], ["", "q", "z"], ["zap", "zip", "Zot"]]; +foreach (@{sorttable $a, column => 1, reverse => 1}) + {foreach (@$_) + {printf "%-5s", $_;} + print "\n";} diff --git a/Task/Optional-parameters/PicoLisp/optional-parameters.l b/Task/Optional-parameters/PicoLisp/optional-parameters.l new file mode 100644 index 0000000000..26c24ca5d1 --- /dev/null +++ b/Task/Optional-parameters/PicoLisp/optional-parameters.l @@ -0,0 +1,8 @@ +(de sortTable (Tbl . @) + (let (Ordering prog Column 1 Reverse NIL) # Set defaults + (bind (rest) # Bind optional params + (setq Tbl + (by '((L) (Ordering (get L Column))) + sort + Tbl ) ) + (if Reverse (flip Tbl) Tbl) ) ) ) diff --git a/Task/Optional-parameters/Python/optional-parameters.py b/Task/Optional-parameters/Python/optional-parameters.py new file mode 100644 index 0000000000..31cab171e4 --- /dev/null +++ b/Task/Optional-parameters/Python/optional-parameters.py @@ -0,0 +1,35 @@ +>>> def printtable(data): + for row in data: + print ' '.join('%-5s' % ('"%s"' % cell) for cell in row) + + +>>> import operator +>>> def sorttable(table, ordering=None, column=0, reverse=False): + return sorted(table, cmp=ordering, key=operator.itemgetter(column), reverse=reverse) + +>>> data = [["a", "b", "c"], ["", "q", "z"], ["zap", "zip", "Zot"]] +>>> printtable(data) +"a" "b" "c" +"" "q" "z" +"zap" "zip" "Zot" +>>> printtable( sorttable(data) ) +"" "q" "z" +"a" "b" "c" +"zap" "zip" "Zot" +>>> printtable( sorttable(data, column=2) ) +"zap" "zip" "Zot" +"a" "b" "c" +"" "q" "z" +>>> printtable( sorttable(data, column=1) ) +"a" "b" "c" +"" "q" "z" +"zap" "zip" "Zot" +>>> printtable( sorttable(data, column=1, reverse=True) ) +"zap" "zip" "Zot" +"" "q" "z" +"a" "b" "c" +>>> printtable( sorttable(data, ordering=lambda a,b: cmp(len(b),len(a))) ) +"zap" "zip" "Zot" +"a" "b" "c" +"" "q" "z" +>>> diff --git a/Task/Optional-parameters/R/optional-parameters.r b/Task/Optional-parameters/R/optional-parameters.r new file mode 100644 index 0000000000..b20351e5c7 --- /dev/null +++ b/Task/Optional-parameters/R/optional-parameters.r @@ -0,0 +1,7 @@ +tablesort <- function(x, ordering="lexicographic", column=1, reverse=false) +{ + # Implementation +} + +# Usage is e.g. +tablesort(mytable, column=3) diff --git a/Task/Optional-parameters/Racket/optional-parameters.rkt b/Task/Optional-parameters/Racket/optional-parameters.rkt new file mode 100644 index 0000000000..63e97696a8 --- /dev/null +++ b/Task/Optional-parameters/Racket/optional-parameters.rkt @@ -0,0 +1,10 @@ +#lang racket + +(define (sort-table table + [ordering string<=?] + [column 0] + [reverse? #f]) + (sort table (if reverse? + (negate ordering) + ordering) + #:key (λ (row) (list-ref row column)))) diff --git a/Task/Optional-parameters/Ruby/optional-parameters-1.rb b/Task/Optional-parameters/Ruby/optional-parameters-1.rb new file mode 100644 index 0000000000..2d487bc50f --- /dev/null +++ b/Task/Optional-parameters/Ruby/optional-parameters-1.rb @@ -0,0 +1,2 @@ +def table_sort(table, ordering=:<=>, column=0, reverse=false) + # ... diff --git a/Task/Optional-parameters/Ruby/optional-parameters-2.rb b/Task/Optional-parameters/Ruby/optional-parameters-2.rb new file mode 100644 index 0000000000..eb4a3b47f3 --- /dev/null +++ b/Task/Optional-parameters/Ruby/optional-parameters-2.rb @@ -0,0 +1,16 @@ +def table_sort(table, ordering: :<=>, column: 0, reverse: false) + p = ordering.to_proc + if reverse + table.sort {|a, b| p.(b[column], a[column])} + else + table.sort {|a, b| p.(a[column], b[column])} + end +end + +# Quick example: +table = [ + ["Ottowa", "Canada"], + ["Washington", "USA"], + ["Mexico City", "Mexico"], +] +p table_sort(table, column: 1) diff --git a/Task/Optional-parameters/Ruby/optional-parameters-3.rb b/Task/Optional-parameters/Ruby/optional-parameters-3.rb new file mode 100644 index 0000000000..4a98d22e18 --- /dev/null +++ b/Task/Optional-parameters/Ruby/optional-parameters-3.rb @@ -0,0 +1,12 @@ +def table_sort(table, opts = {}) + defaults = {:ordering => :<=>, :column => 0, :reverse => false} + opts = defaults.merge(opts) + + c = opts[:column] + p = opts[:ordering].to_proc + if opts[:reverse] + table.sort {|a, b| p.call(b[c], a[c])} + else + table.sort {|a, b| p.call(a[c], b[c])} + end +end diff --git a/Task/Optional-parameters/Scala/optional-parameters-1.scala b/Task/Optional-parameters/Scala/optional-parameters-1.scala new file mode 100644 index 0000000000..e82e97ccbb --- /dev/null +++ b/Task/Optional-parameters/Scala/optional-parameters-1.scala @@ -0,0 +1,5 @@ +def sortTable(data:List[List[String]], ordering:(String, String)=>Boolean =(_<_), + column:Int =0, reverse:Boolean =false)={ + val result=data.sortWith((a, b)=> ordering(a(column), b(column))) + if(reverse) result.reverse else result +} diff --git a/Task/Optional-parameters/Scala/optional-parameters-2.scala b/Task/Optional-parameters/Scala/optional-parameters-2.scala new file mode 100644 index 0000000000..d3e0666790 --- /dev/null +++ b/Task/Optional-parameters/Scala/optional-parameters-2.scala @@ -0,0 +1,11 @@ +val data=List(List("a","b","c"), List("","q","z"), List("zap","zip","Zot")) +println(data) + //-> List(List(a, b, c), List(, q, z), List(zap, zip, Zot)) +println(sortTable(data)) + //-> List(List(, q, z), List(a, b, c), List(zap, zip, Zot)) +println(sortTable(data, reverse=true)) + //-> List(List(zap, zip, Zot), List(a, b, c), List(, q, z)) +println(sortTable(data, column=2)) + //-> List(List(zap, zip, Zot), List(a, b, c), List(, q, z)) +println(sortTable(data, ((a, b)=> b.size List(List(zap, zip, Zot), List(a, b, c), List(, q, z)) diff --git a/Task/Optional-parameters/Slate/optional-parameters.slate b/Task/Optional-parameters/Slate/optional-parameters.slate new file mode 100644 index 0000000000..54ea01b2ea --- /dev/null +++ b/Task/Optional-parameters/Slate/optional-parameters.slate @@ -0,0 +1,8 @@ +s@(Sequence traits) tableSort &column: column &sortBy: sortBlock &reverse: reverse +[ + column `defaultsTo: 0. + sortBlock `defaultsTo: [| :a :b | (a lexicographicallyCompare: b) isNegative]. + (reverse `defaultsTo: False) + ifTrue: [sortBlock := [| :a :b | (sortBlock applyTo: {a. b}) not]]. + s sortBy: [| :a :b | sortBlock applyTo: {a at: column. b at: column}] +]. diff --git a/Task/Optional-parameters/TIScript/optional-parameters.tiscript b/Task/Optional-parameters/TIScript/optional-parameters.tiscript new file mode 100644 index 0000000000..ebe0dd7ffa --- /dev/null +++ b/Task/Optional-parameters/TIScript/optional-parameters.tiscript @@ -0,0 +1,5 @@ +function sorter(table, ordering = "lexicographic", column = 0, reverse = false) { + // ... +} + +sorter(the_data,"numeric"); diff --git a/Task/Optional-parameters/Tcl/optional-parameters-1.tcl b/Task/Optional-parameters/Tcl/optional-parameters-1.tcl new file mode 100644 index 0000000000..44920fa4f5 --- /dev/null +++ b/Task/Optional-parameters/Tcl/optional-parameters-1.tcl @@ -0,0 +1,15 @@ +proc tablesort {table {ordering ""} {column 0} {reverse 0}} { + set direction [expr {$reverse ? "-decreasing" : "-increasing"}] + if {$ordering ne ""} { + lsort -command $ordering $direction -index $column $table + } else { + lsort $direction -index $column $table + } +} + +puts [tablesort $data] +puts [tablesort $data "" 1] +puts [tablesort $data "" 0 1] +puts [tablesort $data { + apply {{a b} {expr {[string length $a]-[string length $b]}}} +}] diff --git a/Task/Optional-parameters/Tcl/optional-parameters-2.tcl b/Task/Optional-parameters/Tcl/optional-parameters-2.tcl new file mode 100644 index 0000000000..9485225c87 --- /dev/null +++ b/Task/Optional-parameters/Tcl/optional-parameters-2.tcl @@ -0,0 +1,18 @@ +package require Tcl 8.5; # Only for the list expansion syntax + +proc tablesort {table args} { + array set opt {ordering "" column 0 reverse 0} + array set opt $args + set pars [list -index $opt(column)] + if {$opt(reverse)} {lappend pars -decreasing} + if {$opt(ordering) ne ""} {lappend pars -command $opt(ordering)} + lsort {*}$pars $table +} + +puts [tablesort $data] +puts [tablesort $data column 1] +puts [tablesort $data column 0] +puts [tablesort $data column 0 reverse 1] +puts [tablesort $data ordering { + apply {{a b} {expr {[string length $b]-[string length $a]}}} +}] diff --git a/Task/Optional-parameters/Ursala/optional-parameters-1.ursala b/Task/Optional-parameters/Ursala/optional-parameters-1.ursala new file mode 100644 index 0000000000..59e659dbbc --- /dev/null +++ b/Task/Optional-parameters/Ursala/optional-parameters-1.ursala @@ -0,0 +1,10 @@ +#import std +#import nat + +ss :: + +ordering %fZ ~ordering||lleq! +column %n ~column||1! +reversed %b + +sorter = +^(~reversed?/~&x! ~&!,-<+ +^/~ordering ~~+ ~&h++ //skip+ predecessor+ ~column) diff --git a/Task/Optional-parameters/Ursala/optional-parameters-2.ursala b/Task/Optional-parameters/Ursala/optional-parameters-2.ursala new file mode 100644 index 0000000000..3f1e537038 --- /dev/null +++ b/Task/Optional-parameters/Ursala/optional-parameters-2.ursala @@ -0,0 +1,17 @@ +example_table = + +< + <'foo','b '>, + <'barr','a '>, + <'bazzz','c'>> + +#cast %sLLL + +examples = + +< + (sorter ss&) example_table, # default sorting algorithm + (sorter ss[ordering: leql]) example_table, # sort by field lengths but otherwise default + (sorter ss[column: 2]) example_table, # etc. + (sorter ss[reversed: true]) example_table, + (sorter ss[reversed: true,column: 2]) example_table> diff --git a/Task/Optional-parameters/XSLT/optional-parameters.xslt b/Task/Optional-parameters/XSLT/optional-parameters.xslt new file mode 100644 index 0000000000..82053016ac --- /dev/null +++ b/Task/Optional-parameters/XSLT/optional-parameters.xslt @@ -0,0 +1,7 @@ + + + + + + ... + diff --git a/Task/Order-two-numerical-lists/0DESCRIPTION b/Task/Order-two-numerical-lists/0DESCRIPTION new file mode 100644 index 0000000000..29caaae7db --- /dev/null +++ b/Task/Order-two-numerical-lists/0DESCRIPTION @@ -0,0 +1,4 @@ +Write function that orders two lists or arrays filled with numbers. +The function should accept two lists as arguments and return true if the first list should be ordered before the second, and false otherwise. + +The order is determined by [[wp:Lexicographical order#Ordering of sequences of various lengths|lexicographic order]]: Comparing the first element of each list. If the first elements are equal, then the second elements should be compared, and so on, until one of the list has no more elements. If the first list runs out of elements the result is true. if the second list or both run out of elements the result is false. diff --git a/Task/Order-two-numerical-lists/1META.yaml b/Task/Order-two-numerical-lists/1META.yaml new file mode 100644 index 0000000000..556e45905d --- /dev/null +++ b/Task/Order-two-numerical-lists/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Sorting diff --git a/Task/Order-two-numerical-lists/Ada/order-two-numerical-lists.ada b/Task/Order-two-numerical-lists/Ada/order-two-numerical-lists.ada new file mode 100644 index 0000000000..6e911208fb --- /dev/null +++ b/Task/Order-two-numerical-lists/Ada/order-two-numerical-lists.ada @@ -0,0 +1,22 @@ +with Ada.Text_IO; use Ada.Text_IO; +procedure Order is + + type IntArray is array (Positive range <>) of Integer; + List1 : IntArray := (1, 2, 3, 4, 5); + List2 : IntArray := (1, 2, 1, 5, 2, 2); + List3 : IntArray := (1, 2, 1, 5, 2); + List4 : IntArray := (1, 2, 1, 5, 2); + + type Animal is (Rat, Cat, Elephant); + type AnimalArray is array (Positive range <>) of Animal; + List5 : AnimalArray := (Cat, Elephant, Rat, Cat); + List6 : AnimalArray := (Cat, Elephant, Rat); + List7 : AnimalArray := (Cat, Cat, Elephant); + +begin + Put_Line (Boolean'Image (List1 > List2)); -- True + Put_Line (Boolean'Image (List2 > List3)); -- True + Put_Line (Boolean'Image (List3 > List4)); -- False, equal + Put_Line (Boolean'Image (List5 > List6)); -- True + Put_Line (Boolean'Image (List6 > List7)); -- True +end Order; diff --git a/Task/Order-two-numerical-lists/AutoHotkey/order-two-numerical-lists.ahk b/Task/Order-two-numerical-lists/AutoHotkey/order-two-numerical-lists.ahk new file mode 100644 index 0000000000..ff55592f6a --- /dev/null +++ b/Task/Order-two-numerical-lists/AutoHotkey/order-two-numerical-lists.ahk @@ -0,0 +1,7 @@ +List1 := [1,2,1,3,2] +List2 := [1,2,0,4,4,0,0,0] +MsgBox % order(List1, List2) + +order(L1, L2){ + return L1.MaxIndex() < L2.MaxIndex() +} diff --git a/Task/Order-two-numerical-lists/BBC-BASIC/order-two-numerical-lists.bbc b/Task/Order-two-numerical-lists/BBC-BASIC/order-two-numerical-lists.bbc new file mode 100644 index 0000000000..091671df67 --- /dev/null +++ b/Task/Order-two-numerical-lists/BBC-BASIC/order-two-numerical-lists.bbc @@ -0,0 +1,19 @@ + DIM list1(4) : list1() = 1, 2, 1, 5, 2 + DIM list2(5) : list2() = 1, 2, 1, 5, 2, 2 + DIM list3(4) : list3() = 1, 2, 3, 4, 5 + DIM list4(4) : list4() = 1, 2, 3, 4, 5 + + IF FNorder(list1(), list2()) PRINT "list1=list2" + IF FNorder(list2(), list3()) PRINT "list2=list3" + IF FNorder(list3(), list4()) PRINT "list3=list4" + END + + DEF FNorder(list1(), list2()) + LOCAL i%, l1%, l2% + l1% = DIM(list1(),1) : l2% = DIM(list2(),1) + WHILE list1(i%) = list2(i%) AND i% < l1% AND i% < l2% + i% += 1 + ENDWHILE + IF list1(i%) < list2(i%) THEN = TRUE + IF list1(i%) > list2(i%) THEN = FALSE + = l1% < l2% diff --git a/Task/Order-two-numerical-lists/Bracmat/order-two-numerical-lists.bracmat b/Task/Order-two-numerical-lists/Bracmat/order-two-numerical-lists.bracmat new file mode 100644 index 0000000000..22df266283 --- /dev/null +++ b/Task/Order-two-numerical-lists/Bracmat/order-two-numerical-lists.bracmat @@ -0,0 +1,24 @@ +( 1 2 3 4 5:?List1 +& 1 2 1 5 2 2:?List2 +& 1 2 1 5 2:?List3 +& 1 2 1 5 2:?List4 +& Cat Elephant Rat Cat:?List5 +& Cat Elephant Rat:?List6 +& Cat Cat Elephant:?List7 +& ( gt + = first second + . !arg:(?first,?second) + & out + $ ( (.!first)+(.!second) + : ((.!first)+(.!second)|2*(.!first)) + & FALSE + | TRUE + ) + ) +& gt$(!List1,!List2) +& gt$(!List2,!List3) +& gt$(!List3,!List4) +& gt$(!List4,!List5) +& gt$(!List5,!List6) +& gt$(!List6,!List7) +); diff --git a/Task/Order-two-numerical-lists/C++/order-two-numerical-lists.cpp b/Task/Order-two-numerical-lists/C++/order-two-numerical-lists.cpp new file mode 100644 index 0000000000..cfc95db82c --- /dev/null +++ b/Task/Order-two-numerical-lists/C++/order-two-numerical-lists.cpp @@ -0,0 +1,23 @@ +#include +#include + +int main() { + std::vector a; + a.push_back(1); + a.push_back(2); + a.push_back(1); + a.push_back(3); + a.push_back(2); + std::vector b; + b.push_back(1); + b.push_back(2); + b.push_back(0); + b.push_back(4); + b.push_back(4); + b.push_back(0); + b.push_back(0); + b.push_back(0); + + std::cout << std::boolalpha << (a < b) << std::endl; // prints "false" + return 0; +} diff --git a/Task/Order-two-numerical-lists/C/order-two-numerical-lists-1.c b/Task/Order-two-numerical-lists/C/order-two-numerical-lists-1.c new file mode 100644 index 0000000000..5adabc22f5 --- /dev/null +++ b/Task/Order-two-numerical-lists/C/order-two-numerical-lists-1.c @@ -0,0 +1,11 @@ +int list_cmp(int *a, int la, int *b, int lb) +{ + int i, l = la; + if (l > lb) l = lb; + for (i = 0; i < l; i++) { + if (a[i] == b[i]) continue; + return (a[i] > b[i]) ? 1 : -1; + } + if (la == lb) return 0; + return la > lb ? 1 : -1; +} diff --git a/Task/Order-two-numerical-lists/C/order-two-numerical-lists-2.c b/Task/Order-two-numerical-lists/C/order-two-numerical-lists-2.c new file mode 100644 index 0000000000..dd7213f8e6 --- /dev/null +++ b/Task/Order-two-numerical-lists/C/order-two-numerical-lists-2.c @@ -0,0 +1 @@ +#define list_less_or_eq(a,b,c,d) (list_cmp(a,b,c,d) != 1) diff --git a/Task/Order-two-numerical-lists/Common-Lisp/order-two-numerical-lists-1.lisp b/Task/Order-two-numerical-lists/Common-Lisp/order-two-numerical-lists-1.lisp new file mode 100644 index 0000000000..5e87120557 --- /dev/null +++ b/Task/Order-two-numerical-lists/Common-Lisp/order-two-numerical-lists-1.lisp @@ -0,0 +1,6 @@ +(defun list< (a b) + (cond ((not b) nil) + ((not a) t) + ((= (first a) (first b)) + (list< (rest a) (rest b))) + (t (< (first a) (first b))))) diff --git a/Task/Order-two-numerical-lists/Common-Lisp/order-two-numerical-lists-2.lisp b/Task/Order-two-numerical-lists/Common-Lisp/order-two-numerical-lists-2.lisp new file mode 100644 index 0000000000..ce7a74a47a --- /dev/null +++ b/Task/Order-two-numerical-lists/Common-Lisp/order-two-numerical-lists-2.lisp @@ -0,0 +1,3 @@ +(defun list< (a b) + (let ((x (find-if-not #'zerop (mapcar #'- a b)))) + (if x (minusp x) (< (length a) (length b))))) diff --git a/Task/Order-two-numerical-lists/D/order-two-numerical-lists.d b/Task/Order-two-numerical-lists/D/order-two-numerical-lists.d new file mode 100644 index 0000000000..1e86f5f27c --- /dev/null +++ b/Task/Order-two-numerical-lists/D/order-two-numerical-lists.d @@ -0,0 +1,3 @@ +void main() { + assert([1,2,1,3,2] >= [1,2,0,4,4,0,0,0]); +} diff --git a/Task/Order-two-numerical-lists/Ela/order-two-numerical-lists.ela b/Task/Order-two-numerical-lists/Ela/order-two-numerical-lists.ela new file mode 100644 index 0000000000..7163e31f64 --- /dev/null +++ b/Task/Order-two-numerical-lists/Ela/order-two-numerical-lists.ela @@ -0,0 +1,6 @@ +[] <. _ = true +_ <. [] = false +(x::xs) <. (y::ys) | x == y = xs <. ys + | else = x < y + +[1,2,1,3,2] <. [1,2,0,4,4,0,0,0] diff --git a/Task/Order-two-numerical-lists/Go/order-two-numerical-lists.go b/Task/Order-two-numerical-lists/Go/order-two-numerical-lists.go new file mode 100644 index 0000000000..459213ea3b --- /dev/null +++ b/Task/Order-two-numerical-lists/Go/order-two-numerical-lists.go @@ -0,0 +1,73 @@ +package main + +import "fmt" + +// If your numbers happen to be in the range of Unicode code points (0 to 0x10ffff), this function +// satisfies the task: +func lessRune(a, b []rune) bool { + return string(a) < string(b) // see also bytes.Compare +} + +// Otherwise, the following function satisfies the task for all integer +// and floating point types, by changing the type definition appropriately. +type numericType int + +func lessNT(a, b []numericType) bool { + l := len(a) + if len(b) < l { + l = len(b) + } + for i := 0; i < l; i++ { + if a[i] != b[i] { + return a[i] < b[i] + } + } + return l < len(b) +} + +var testCases = [][][]numericType{ + {{0}, {}}, + {{}, {}}, + {{}, {0}}, + + {{-1}, {0}}, + {{0}, {0}}, + {{0}, {-1}}, + + {{0}, {0, -1}}, + {{0}, {0, 0}}, + {{0}, {0, 1}}, + {{0, -1}, {0}}, + {{0, 0}, {0}}, + {{0, 0}, {1}}, +} + +func main() { + // demonstrate the general function + for _, tc := range testCases { + fmt.Printf("order %6s before %6s : %t\n", + fmt.Sprintf("%v", tc[0]), + fmt.Sprintf("%v", tc[1]), + lessNT(tc[0], tc[1])) + } + fmt.Println() + + // demonstrate that the byte specific function gives identical results + // by offsetting test data to a printable range of characters. + for _, tc := range testCases { + a := toByte(tc[0]) + b := toByte(tc[1]) + fmt.Printf("order %6q before %6q : %t\n", + string(a), + string(b), + lessByte(a, b)) + } +} + +func toByte(a []numericType) []byte { + b := make([]byte, len(a)) + for i, n := range a { + b[i] = 'b' + byte(n) + } + return b +} diff --git a/Task/Order-two-numerical-lists/Groovy/order-two-numerical-lists-1.groovy b/Task/Order-two-numerical-lists/Groovy/order-two-numerical-lists-1.groovy new file mode 100644 index 0000000000..9138ae3c42 --- /dev/null +++ b/Task/Order-two-numerical-lists/Groovy/order-two-numerical-lists-1.groovy @@ -0,0 +1,10 @@ +class CList extends ArrayList implements Comparable { + CList() { } + CList(Collection c) { super(c) } + int compareTo(Object that) { + assert that instanceof List + def n = [this.size(), that.size()].min() + def comp = [this[0.. comp[1] : this.size() <=> that.size() + } +} diff --git a/Task/Order-two-numerical-lists/Groovy/order-two-numerical-lists-2.groovy b/Task/Order-two-numerical-lists/Groovy/order-two-numerical-lists-2.groovy new file mode 100644 index 0000000000..d13b6d9e5e --- /dev/null +++ b/Task/Order-two-numerical-lists/Groovy/order-two-numerical-lists-2.groovy @@ -0,0 +1,9 @@ +CList a, b; (a, b) = [[], []]; assert ! (a < b) +b = [1] as CList; assert (a < b) +a = [1] as CList; assert ! (a < b) +b = [2] as CList; assert (a < b) +a = [2, -1, 0] as CList; assert ! (a < b) +b = [2, -1] as CList; assert ! (a < b) +b = [2, -1, 0] as CList; assert ! (a < b) +b = [2, -1, 0, -17] as CList; assert (a < b) +a = [2, 8, 0] as CList; assert ! (a < b) diff --git a/Task/Order-two-numerical-lists/Haskell/order-two-numerical-lists.hs b/Task/Order-two-numerical-lists/Haskell/order-two-numerical-lists.hs new file mode 100644 index 0000000000..1557ea6fcf --- /dev/null +++ b/Task/Order-two-numerical-lists/Haskell/order-two-numerical-lists.hs @@ -0,0 +1,2 @@ +Prelude> [1,2,1,3,2] < [1,2,0,4,4,0,0,0] +False diff --git a/Task/Order-two-numerical-lists/Icon/order-two-numerical-lists.icon b/Task/Order-two-numerical-lists/Icon/order-two-numerical-lists.icon new file mode 100644 index 0000000000..d4b41cd18a --- /dev/null +++ b/Task/Order-two-numerical-lists/Icon/order-two-numerical-lists.icon @@ -0,0 +1,11 @@ +procedure main() + write( if list_llt([1,2,1,3,2],[1,2,0,4,4,0,0,0]) then "true" else "false" ) +end + + +procedure list_llt(L1,L2) #: returns L2 if L1 lexically lt L2 or fails +every i := 1 to min(*L1,*L2) do + if L1[i] << L2[i] then return L2 + else if L1[i] >> L2[i] then fail +if *L1 < *L2 then return L2 +end diff --git a/Task/Order-two-numerical-lists/J/order-two-numerical-lists-1.j b/Task/Order-two-numerical-lists/J/order-two-numerical-lists-1.j new file mode 100644 index 0000000000..a3160918b4 --- /dev/null +++ b/Task/Order-two-numerical-lists/J/order-two-numerical-lists-1.j @@ -0,0 +1 @@ +before=: -.@(-: /:~)@,&<~ diff --git a/Task/Order-two-numerical-lists/J/order-two-numerical-lists-2.j b/Task/Order-two-numerical-lists/J/order-two-numerical-lists-2.j new file mode 100644 index 0000000000..2fec517edd --- /dev/null +++ b/Task/Order-two-numerical-lists/J/order-two-numerical-lists-2.j @@ -0,0 +1,49 @@ + (,0) before '' +0 + '' before '' +0 + '' before ,0 +1 + (,_1) before ,0 +1 + (,0) before ,0 +0 + (,0) before ,_1 +0 + (,0) before 0 _1 +1 + (,0) before 0 0 +1 + (,0) before 0 1 +1 + 0 _1 before ,0 +0 + 0 0 before ,0 +0 + 0 0 before ,1 +1 + + (,'b') before '' +0 + '' before '' +0 + '' before ,'b' +1 + (,'a') before ,'b' +1 + (,'b') before ,'b' +0 + (,'b') before ,'a' +0 + (,'b') before 'ba' +1 + (,'b') before 'bb' +1 + (,'b') before 'bc' +1 + 'ba' before ,'b' +0 + 'bb' before ,'b' +0 + 'bb' before ,'c' +1 diff --git a/Task/Order-two-numerical-lists/Java/order-two-numerical-lists.java b/Task/Order-two-numerical-lists/Java/order-two-numerical-lists.java new file mode 100644 index 0000000000..6c16660d08 --- /dev/null +++ b/Task/Order-two-numerical-lists/Java/order-two-numerical-lists.java @@ -0,0 +1,34 @@ +import java.util.Arrays; +import java.util.List; + +public class ListOrder{ + public static boolean ordered(double[] first, double[] second){ + if(first.length == 0) return true; + if(second.length == 0) return false; + if(first[0] == second[0]) + return ordered(Arrays.copyOfRange(first, 1, first.length), + Arrays.copyOfRange(second, 1, second.length)); + return first[0] < second[0]; + } + + public static > boolean ordered(List first, List second){ + int i = 0; + for(; i < first.size() && i < second.size();i++){ + int cmp = first.get(i).compareTo(second.get(i)); + if(cmp == 0) continue; + if(cmp < 0) return true; + return false; + } + return i == first.size(); + } + + public static boolean ordered2(double[] first, double[] second){ + int i = 0; + for(; i < first.length && i < second.length;i++){ + if(first[i] == second[i]) continue; + if(first[i] < second[i]) return true; + return false; + } + return i == first.length; + } +} diff --git a/Task/Order-two-numerical-lists/Joy/order-two-numerical-lists.joy b/Task/Order-two-numerical-lists/Joy/order-two-numerical-lists.joy new file mode 100644 index 0000000000..92a4f57064 --- /dev/null +++ b/Task/Order-two-numerical-lists/Joy/order-two-numerical-lists.joy @@ -0,0 +1,4 @@ +DEFINE order == +[equal] [false] +[[[[size] dip size <=] [[<=] mapr2 true [and] fold]] [i] map i and] +ifte. diff --git a/Task/Order-two-numerical-lists/Lhogho/order-two-numerical-lists-1.lhogho b/Task/Order-two-numerical-lists/Lhogho/order-two-numerical-lists-1.lhogho new file mode 100644 index 0000000000..6add278e87 --- /dev/null +++ b/Task/Order-two-numerical-lists/Lhogho/order-two-numerical-lists-1.lhogho @@ -0,0 +1,8 @@ +print [1 2] = [1 2] +print [1 2] = [1 2 3] +print [1 3] = [1 2] +print [1 2 3] = [1 2] + +make "list1 [1 2 3 4 5 6] +make "list2 [1 2 3 4 5 7] +print :list1 = :list2 diff --git a/Task/Order-two-numerical-lists/Lhogho/order-two-numerical-lists-2.lhogho b/Task/Order-two-numerical-lists/Lhogho/order-two-numerical-lists-2.lhogho new file mode 100644 index 0000000000..fdb51012d9 --- /dev/null +++ b/Task/Order-two-numerical-lists/Lhogho/order-two-numerical-lists-2.lhogho @@ -0,0 +1,5 @@ +true +false +false +false +false diff --git a/Task/Order-two-numerical-lists/Mathematica/order-two-numerical-lists.math b/Task/Order-two-numerical-lists/Mathematica/order-two-numerical-lists.math new file mode 100644 index 0000000000..a62b502ef6 --- /dev/null +++ b/Task/Order-two-numerical-lists/Mathematica/order-two-numerical-lists.math @@ -0,0 +1,8 @@ +order[List1_, List2_] := With[{ + L1 = List1[[1 ;; Min @@ Length /@ {List1, List2}]], + L2 = List2[[1 ;; Min @@ Length /@ {List1, List2}]] +}, + If [Thread[Order[L1, L2]] == 0, + Length[List1] < Length[List2], + Thread[Order[L1, L2]] == 1 + ]] diff --git a/Task/Order-two-numerical-lists/Maxima/order-two-numerical-lists.maxima b/Task/Order-two-numerical-lists/Maxima/order-two-numerical-lists.maxima new file mode 100644 index 0000000000..f2ec86db7b --- /dev/null +++ b/Task/Order-two-numerical-lists/Maxima/order-two-numerical-lists.maxima @@ -0,0 +1,13 @@ +"<<"(a,b):=block([n:min(length(a),length(b))], +catch(for i thru n do (if a[i]#b[i] then throw(is(a[i] + io.write(A), io.write_string(" < "), io.write(B), + io.write_string(" : "), io.write_string(S), io.nl, + { A < B -> S = "yes" ; S = "no" }. diff --git a/Task/Order-two-numerical-lists/OCaml/order-two-numerical-lists-1.ocaml b/Task/Order-two-numerical-lists/OCaml/order-two-numerical-lists-1.ocaml new file mode 100644 index 0000000000..3f8331660a --- /dev/null +++ b/Task/Order-two-numerical-lists/OCaml/order-two-numerical-lists-1.ocaml @@ -0,0 +1,2 @@ +# [1;2;1;3;2] < [1;2;0;4;4;0;0;0];; +- : bool = false diff --git a/Task/Order-two-numerical-lists/OCaml/order-two-numerical-lists-2.ocaml b/Task/Order-two-numerical-lists/OCaml/order-two-numerical-lists-2.ocaml new file mode 100644 index 0000000000..ea0311db2a --- /dev/null +++ b/Task/Order-two-numerical-lists/OCaml/order-two-numerical-lists-2.ocaml @@ -0,0 +1,8 @@ +let rec ordered_lists = function + | x1::tl1, x2::tl2 -> + (match compare x1 x2 with + | 0 -> ordered_lists (tl1, tl2) + | 1 -> false + | _ -> true) + | [], _ -> true + | _ -> false diff --git a/Task/Order-two-numerical-lists/OCaml/order-two-numerical-lists-3.ocaml b/Task/Order-two-numerical-lists/OCaml/order-two-numerical-lists-3.ocaml new file mode 100644 index 0000000000..aa68337432 --- /dev/null +++ b/Task/Order-two-numerical-lists/OCaml/order-two-numerical-lists-3.ocaml @@ -0,0 +1,20 @@ +(* copy-paste the code of ordered_lists here *) + +let make_num_list p n = + let rec aux acc = + if Random.int p = 0 then acc + else aux (Random.int n :: acc) + in + aux [] + +let print_num_list lst = + List.iter (Printf.printf " %d") lst; + print_newline() + +let () = + Random.self_init(); + let lst1 = make_num_list 8 5 in + let lst2 = make_num_list 8 5 in + print_num_list lst1; + print_num_list lst2; + Printf.printf "ordered: %B\n" (ordered_lists (lst1, lst2)) diff --git a/Task/Order-two-numerical-lists/OCaml/order-two-numerical-lists-4.ocaml b/Task/Order-two-numerical-lists/OCaml/order-two-numerical-lists-4.ocaml new file mode 100644 index 0000000000..5155e1f36d --- /dev/null +++ b/Task/Order-two-numerical-lists/OCaml/order-two-numerical-lists-4.ocaml @@ -0,0 +1 @@ +val ordered_lists : 'a list * 'a list -> bool diff --git a/Task/Order-two-numerical-lists/PARI-GP/order-two-numerical-lists.pari b/Task/Order-two-numerical-lists/PARI-GP/order-two-numerical-lists.pari new file mode 100644 index 0000000000..e45147d267 --- /dev/null +++ b/Task/Order-two-numerical-lists/PARI-GP/order-two-numerical-lists.pari @@ -0,0 +1 @@ +lex(u,v)<1 diff --git a/Task/Order-two-numerical-lists/Perl-6/order-two-numerical-lists.pl6 b/Task/Order-two-numerical-lists/Perl-6/order-two-numerical-lists.pl6 new file mode 100644 index 0000000000..8789069768 --- /dev/null +++ b/Task/Order-two-numerical-lists/Perl-6/order-two-numerical-lists.pl6 @@ -0,0 +1,17 @@ +my @a = <1 2 4>; +my @b = <1 2 4>; +say @a," before ",@b," = ", @a before @b; + +@a = <1 2 4>; +@b = <1 2>; +say @a," before ",@b," = ", @a before @b; + +@a = <1 2>; +@b = <1 2 4>; +say @a," before ",@b," = ", @a before @b; + +for 1..10 { + my @a = (^100).roll((2..3).pick); + my @b = @a.map: { Bool.pick ?? $_ !! (^100).roll((0..2).pick) } + say @a," before ",@b," = ", @a before @b; +} diff --git a/Task/Order-two-numerical-lists/Perl/order-two-numerical-lists.pl b/Task/Order-two-numerical-lists/Perl/order-two-numerical-lists.pl new file mode 100644 index 0000000000..eb5ece4143 --- /dev/null +++ b/Task/Order-two-numerical-lists/Perl/order-two-numerical-lists.pl @@ -0,0 +1,36 @@ +#!/usr/bin/perl -w +use strict ; + +sub orderlists { + my $firstlist = shift ; + my $secondlist = shift ; + my $first = shift @{$firstlist } if @{$firstlist} ; + my $second ; +#keep stripping elements from the first list as long as there are any +#or until the second list is used up! + while ( @{$firstlist} ) { + if ( @{$secondlist} ) { #second list is not used up yet! + $second = shift @{$secondlist} ; + if ( $first < $second ) { + return 1 ; + } + if ( $first > $second ) { + return 0 ; + } + } + else { #second list used up, defined to return false + return 0 ; + } + $first = shift @{$firstlist} ; + } + return 0 ; #in all remaining cases return false +} + +my @firstnumbers = ( 43 , 33 , 2 ) ; +my @secondnumbers = ( 45 ) ; +if ( orderlists( \@firstnumbers , \@secondnumbers ) ) { + print "The first list comes before the second list!\n" ; +} +else { + print "The first list does not come before the second list!\n" ; +} diff --git a/Task/Order-two-numerical-lists/PicoLisp/order-two-numerical-lists.l b/Task/Order-two-numerical-lists/PicoLisp/order-two-numerical-lists.l new file mode 100644 index 0000000000..8bc391ba11 --- /dev/null +++ b/Task/Order-two-numerical-lists/PicoLisp/order-two-numerical-lists.l @@ -0,0 +1,2 @@ +: (> (1 2 0 4 4 0 0 0) (1 2 1 3 2)) +-> NIL diff --git a/Task/Order-two-numerical-lists/Pike/order-two-numerical-lists-1.pike b/Task/Order-two-numerical-lists/Pike/order-two-numerical-lists-1.pike new file mode 100644 index 0000000000..90b4e5d162 --- /dev/null +++ b/Task/Order-two-numerical-lists/Pike/order-two-numerical-lists-1.pike @@ -0,0 +1,8 @@ +int(0..1) order_array(array a, array b) +{ + if (!sizeof(a)) return true; + if (!sizeof(b)) return false; + if (a[0] == b[0]) + return order_array(a[1..], b[1..]); + return a[0] < b[0]; +} diff --git a/Task/Order-two-numerical-lists/Pike/order-two-numerical-lists-2.pike b/Task/Order-two-numerical-lists/Pike/order-two-numerical-lists-2.pike new file mode 100644 index 0000000000..1de03de551 --- /dev/null +++ b/Task/Order-two-numerical-lists/Pike/order-two-numerical-lists-2.pike @@ -0,0 +1 @@ +(string)a < (string)b; diff --git a/Task/Order-two-numerical-lists/PureBasic/order-two-numerical-lists.purebasic b/Task/Order-two-numerical-lists/PureBasic/order-two-numerical-lists.purebasic new file mode 100644 index 0000000000..45458618bb --- /dev/null +++ b/Task/Order-two-numerical-lists/PureBasic/order-two-numerical-lists.purebasic @@ -0,0 +1,70 @@ +DataSection + Array_1: + Data.i 5 ;element count + Data.i 1, 2, 3, 4, 5 ;element data + Array_2: + Data.i 6 + Data.i 1, 2, 1, 5, 2, 2 + Array_3: + Data.i 5 + Data.i 1, 2, 1, 5, 2 + Array_4: + Data.i 5 + Data.i 1, 2, 1, 5, 2 + Array_5: + Data.i 4 + Data.i 1, 2, 1, 6 + Array_6: + Data.i 5 + Data.i 1, 2, 1, 6, 2 +EndDataSection + +#False = 0 +#True = 1 + +;helper subrountine to initialize a dataset, *dataPtr points to the elementcount followed by the element data +Procedure initArrayData(Array a(1), *dataPtr) + Protected elementCount = PeekI(*dataPtr) + + Dim a(elementCount - 1) + For i = 0 To elementCount - 1 + *dataPtr + SizeOf(Integer) + a(i) = PeekI(*dataPtr) + Next +EndProcedure + +;helper subroutine that returns 'True' or 'False' for a boolean input +Procedure.s booleanText(b) + If b: ProcedureReturn "True": EndIf + ProcedureReturn "False" +EndProcedure + +Procedure order(Array a(1), Array b(1)) + Protected len_a = ArraySize(a()), len_b = ArraySize(b()), elementIndex + + While elementIndex <= len_a And elementIndex <= len_b And a(elementIndex) = b(elementIndex) + elementIndex + 1 + Wend + + If (elementIndex > len_a And elementIndex <= len_b) Or (elementIndex <= len_b And a(elementIndex) <= b(elementIndex)) + ProcedureReturn #True + EndIf +EndProcedure + +Dim A_1(0): initArrayData(A_1(), ?Array_1) +Dim A_2(0): initArrayData(A_2(), ?Array_2) +Dim A_3(0): initArrayData(A_3(), ?Array_3) +Dim A_4(0): initArrayData(A_4(), ?Array_4) +Dim A_5(0): initArrayData(A_5(), ?Array_5) +Dim A_6(0): initArrayData(A_6(), ?Array_6) + +If OpenConsole() + PrintN(booleanText(order(A_1(), A_2()))) ;False + PrintN(booleanText(order(A_2(), A_3()))) ;False + PrintN(booleanText(order(A_3(), A_4()))) ;False + PrintN(booleanText(order(A_4(), A_5()))) ;True + PrintN(booleanText(order(A_5(), A_6()))) ;True + + Print(#crlf$ + #crlf$ + "Press ENTER to exit"): Input() + CloseConsole() +EndIf diff --git a/Task/Order-two-numerical-lists/Python/order-two-numerical-lists.py b/Task/Order-two-numerical-lists/Python/order-two-numerical-lists.py new file mode 100644 index 0000000000..2bd1d4b868 --- /dev/null +++ b/Task/Order-two-numerical-lists/Python/order-two-numerical-lists.py @@ -0,0 +1,2 @@ +>>> [1,2,1,3,2] < [1,2,0,4,4,0,0,0] +False diff --git a/Task/Order-two-numerical-lists/Rascal/order-two-numerical-lists.rascal b/Task/Order-two-numerical-lists/Rascal/order-two-numerical-lists.rascal new file mode 100644 index 0000000000..d3a51aeadf --- /dev/null +++ b/Task/Order-two-numerical-lists/Rascal/order-two-numerical-lists.rascal @@ -0,0 +1,2 @@ +rascal>[2,1,3] < [5,2,1,3] +bool: true diff --git a/Task/Order-two-numerical-lists/Ruby/order-two-numerical-lists.rb b/Task/Order-two-numerical-lists/Ruby/order-two-numerical-lists.rb new file mode 100644 index 0000000000..c060836eb0 --- /dev/null +++ b/Task/Order-two-numerical-lists/Ruby/order-two-numerical-lists.rb @@ -0,0 +1,2 @@ +>> ([1,2,1,3,2] <=> [1,2,0,4,4,0,0,0]) < 0 +=> false diff --git a/Task/Order-two-numerical-lists/Scheme/order-two-numerical-lists.ss b/Task/Order-two-numerical-lists/Scheme/order-two-numerical-lists.ss new file mode 100644 index 0000000000..5330700c0f --- /dev/null +++ b/Task/Order-two-numerical-lists/Scheme/order-two-numerical-lists.ss @@ -0,0 +1,5 @@ +(define (lex$b} { + return 0 + } + } + return 0 +} diff --git a/Task/Ordered-Partitions/0DESCRIPTION b/Task/Ordered-Partitions/0DESCRIPTION new file mode 100644 index 0000000000..6ec99c23ee --- /dev/null +++ b/Task/Ordered-Partitions/0DESCRIPTION @@ -0,0 +1,38 @@ +In this task we want to find the ordered partitions into fixed-size blocks. This task is related to [[Combinations]] in that it has to do with discrete mathematics and moreover a helper function to compute combinations is (probably) needed to solve this task. + +partitions(\mathit{arg}_1,\mathit{arg}_2,...,\mathit{arg}_n) should generate all distributions of the elements in \{1,...,\Sigma_{i=1}^n\mathit{arg}_i\} into n blocks of respective size \mathit{arg}_1,\mathit{arg}_2,...,\mathit{arg}_n. + +Example 1: partitions(2,0,2) would create: + +
+{({1, 2}, {}, {3, 4}),
+ ({1, 3}, {}, {2, 4}),
+ ({1, 4}, {}, {2, 3}),
+ ({2, 3}, {}, {1, 4}),
+ ({2, 4}, {}, {1, 3}),
+ ({3, 4}, {}, {1, 2})}
+
+ +Example 2: partitions(1,1,1) would create: + +
+{({1}, {2}, {3}),
+ ({1}, {3}, {2}),
+ ({2}, {1}, {3}),
+ ({2}, {3}, {1}),
+ ({3}, {1}, {2}),
+ ({3}, {2}, {1})}
+
+ +Note that the number of elements in the list is +:{\mathit{arg}_1+\mathit{arg}_2+...+\mathit{arg}_n \choose \mathit{arg}_1} \cdot {\mathit{arg}_2+\mathit{arg}_3+...+\mathit{arg}_n \choose \mathit{arg}_2} \cdot \ldots \cdot {\mathit{arg}_n \choose \mathit{arg}_n} +(see [http://en.wikipedia.org/wiki/Binomial_coefficient the definition of the binomial coefficient] if you are not familiar with this notation) and the number of elements remains the same regardless of how the argument is permuted +(i.e. the [http://en.wikipedia.org/wiki/Multinomial_coefficient multinomial coefficient]). Also, partitions(1,1,1) creates the permutations of \{1,2,3\} and thus there would be 3! = 6 elements in the list. + +Note: Do not use functions that are not in the standard library of the programming language you use. Your file should be written so that it can be executed on the command line and by default outputs the result of partitions(2,0,2). If the programming language does not support polyvariadic functions pass a list as an argument. + +'''Notation''' + +Remarks on the used notation for the task in order to understand it easierly. + +\{1, \ldots, n\} denotes the set of consecutive numbers from 1 to n, e.g. \{1,2,3\} if n = 3. \Sigma is the mathematical notation for summation, e.g. \Sigma_{i=1}^3 i = 6 (see also [http://en.wikipedia.org/wiki/Summation#Capital-sigma_notation]). \mathit{arg}_1,\mathit{arg}_2,...,\mathit{arg}_n are the arguments — natural numbers — that the sought function receives. diff --git a/Task/Ordered-Partitions/1META.yaml b/Task/Ordered-Partitions/1META.yaml new file mode 100644 index 0000000000..9e130e8a7b --- /dev/null +++ b/Task/Ordered-Partitions/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Discrete math diff --git a/Task/Ordered-Partitions/Ada/ordered-partitions-1.ada b/Task/Ordered-Partitions/Ada/ordered-partitions-1.ada new file mode 100644 index 0000000000..b4cde7bfe9 --- /dev/null +++ b/Task/Ordered-Partitions/Ada/ordered-partitions-1.ada @@ -0,0 +1,13 @@ +with Ada.Containers.Indefinite_Ordered_Sets; +with Ada.Containers.Ordered_Sets; +package Partitions is + -- Argument type for Create_Partitions: Array of Numbers + type Arguments is array (Positive range <>) of Natural; + package Number_Sets is new Ada.Containers.Ordered_Sets + (Natural); + type Partition is array (Positive range <>) of Number_Sets.Set; + function "<" (Left, Right : Partition) return Boolean; + package Partition_Sets is new Ada.Containers.Indefinite_Ordered_Sets + (Partition); + function Create_Partitions (Args : Arguments) return Partition_Sets.Set; +end Partitions; diff --git a/Task/Ordered-Partitions/Ada/ordered-partitions-2.ada b/Task/Ordered-Partitions/Ada/ordered-partitions-2.ada new file mode 100644 index 0000000000..b803c46cdc --- /dev/null +++ b/Task/Ordered-Partitions/Ada/ordered-partitions-2.ada @@ -0,0 +1,148 @@ +package body Partitions is + -- compare number sets (not provided) + function "<" (Left, Right : Number_Sets.Set) return Boolean is + use type Ada.Containers.Count_Type; + use Number_Sets; + Left_Pos : Cursor := Left.First; + Right_Pos : Cursor := Right.First; + begin + -- compare each element, until one or both lists finishes + while Left_Pos /= No_Element and then Right_Pos /= No_Element loop + -- compare elements + if Element (Left_Pos) < Element (Right_Pos) then + return True; + elsif Element (Left_Pos) > Element (Right_Pos) then + return False; + end if; + -- increase iterator + Next (Left_Pos); + Next (Right_Pos); + end loop; + -- Right is longer + if Right_Pos /= No_Element then + return True; + else + -- Left is longer, or Left and Right are identical. + return False; + end if; + end "<"; + -- compare two Partitions + function "<" (Left, Right : Partition) return Boolean is + use type Ada.Containers.Count_Type; + use type Number_Sets.Set; + begin + -- check length + if Left'Length < Right'Length then + return True; + elsif Left'Length > Right'Length then + return False; + end if; + -- same length + if Left'Length > 0 then + for I in Left'Range loop + if Left (I) < Right (I) then + return True; + elsif Left (I) /= Right (I) then + return False; + end if; + end loop; + end if; + -- length = 0 are always smallest + return False; + end "<"; + -- create partitions (as the task describes) + function Create_Partitions (Args : Arguments) return Partition_Sets.Set is + -- permutations needed + type Permutation is array (Positive range <>) of Natural; + -- exception to be thrown after last permutation reached + No_More_Permutations : exception; + -- get initial permutation (ordered small->big) + function Initial_Permutation (Max : Natural) return Permutation is + Result : Permutation (1 .. Max); + begin + for I in 1 .. Max loop + Result (I) := I; + end loop; + return Result; + end Initial_Permutation; + -- get next permutation + function Next_Permutation (Current : Permutation) return Permutation is + K : Natural := Current'Last - 1; + L : Positive := Current'Last; + Result : Permutation := Current; + begin + -- 1. Find the largest index k such that a[k] < a[k + 1]. + while K /= 0 and then Current (K) > Current (K + 1) loop + K := K - 1; + end loop; + -- If no such index exists, the permutation is the last permutation. + if K = 0 then + raise No_More_Permutations; + end if; + -- 2. Find the largest index l such that a[k] < a[l]. + -- Since k + 1 is such an index, l is well defined + -- and satisfies k < l. + while Current (K) > Current (L) loop + L := L - 1; + end loop; + -- 3. Swap a[k] with a[l]. + Result (K) := Current (L); + Result (L) := Current (K); + -- 4. Reverse the sequence from a[k + 1] up to and including the + -- final element a[n]. + for I in 1 .. (Result'Last - K) / 2 loop + declare + Temp : constant Natural := Result (K + I); + begin + Result (K + I) := Result (Result'Last - I + 1); + Result (Result'Last - I + 1) := Temp; + end; + end loop; + return Result; + end Next_Permutation; + Result : Partition_Sets.Set; + Sum : Natural := 0; + begin + -- get number of elements + for I in Args'Range loop + Sum := Sum + Args (I); + end loop; + declare + -- initial permutation + Current_Permutation : Permutation := Initial_Permutation (Sum); + begin + -- loop through permutations + loop + -- create Partition (same count of Number_Sets.Set as Args) + declare + Item : Natural := Current_Permutation'First; + Current_Partition : Partition (Args'Range); + begin + -- loop each partition + for I in Args'Range loop + -- fill in the number of elements requested + for J in 1 .. Args (I) loop + Current_Partition (I).Insert + (New_Item => Current_Permutation (Item)); + Item := Item + 1; + end loop; + end loop; + -- insert partition into result set + Result.Insert (New_Item => Current_Partition); + exception + when Constraint_Error => + -- partition was already inserted, ignore it. + -- this happens when one of the args > 1. + null; + end; + -- create next permutation + Current_Permutation := Next_Permutation (Current_Permutation); + end loop; + exception + when No_More_Permutations => + -- no more permutations, we are finished + null; + end; + return Result; + end Create_Partitions; +end Partitions; diff --git a/Task/Ordered-Partitions/Ada/ordered-partitions-3.ada b/Task/Ordered-Partitions/Ada/ordered-partitions-3.ada new file mode 100644 index 0000000000..a8573cd949 --- /dev/null +++ b/Task/Ordered-Partitions/Ada/ordered-partitions-3.ada @@ -0,0 +1,61 @@ +with Ada.Text_IO; +with Partitions; +procedure Main is + package Natural_IO is new Ada.Text_IO.Integer_IO (Natural); + Example_Partitions : Partitions.Partition_Sets.Set; +begin + Ada.Text_IO.Put_Line ("Partitions for (2, 0, 2):"); + -- create partition + Example_Partitions := Partitions.Create_Partitions (Args => (2, 0, 2)); + -- pretty print the result + declare + use type Partitions.Partition_Sets.Cursor; + Position : Partitions.Partition_Sets.Cursor := Example_Partitions.First; + begin + Ada.Text_IO.Put ('{'); + while Position /= Partitions.Partition_Sets.No_Element loop + if Position /= Example_Partitions.First then + Ada.Text_IO.Put (' '); + end if; + declare + Current_Partition : constant Partitions.Partition := + Partitions.Partition_Sets.Element (Position); + begin + Ada.Text_IO.Put ('('); + for I in Current_Partition'Range loop + Ada.Text_IO.Put ('{'); + declare + use type Partitions.Number_Sets.Cursor; + Current_Number : Partitions.Number_Sets.Cursor := + Current_Partition (I).First; + begin + while Current_Number /= Partitions.Number_Sets.No_Element + loop + Natural_IO.Put + (Item => + Partitions.Number_Sets.Element (Current_Number), + Width => 1); + Partitions.Number_Sets.Next (Current_Number); + if Current_Number /= + Partitions.Number_Sets.No_Element then + Ada.Text_IO.Put (','); + end if; + end loop; + end; + Ada.Text_IO.Put ('}'); + if I /= Current_Partition'Last then + Ada.Text_IO.Put (", "); + end if; + end loop; + end; + Ada.Text_IO.Put (')'); + Partitions.Partition_Sets.Next (Position); + if Position /= Partitions.Partition_Sets.No_Element then + Ada.Text_IO.Put (','); + Ada.Text_IO.New_Line; + end if; + end loop; + Ada.Text_IO.Put ('}'); + Ada.Text_IO.New_Line; + end; +end Main; diff --git a/Task/Ordered-Partitions/BBC-BASIC/ordered-partitions.bbc b/Task/Ordered-Partitions/BBC-BASIC/ordered-partitions.bbc new file mode 100644 index 0000000000..abb536b61d --- /dev/null +++ b/Task/Ordered-Partitions/BBC-BASIC/ordered-partitions.bbc @@ -0,0 +1,52 @@ + DIM list1%(2) : list1%() = 2, 0, 2 + PRINT "partitions(2,0,2):" + PRINT FNpartitions(list1%()) + DIM list2%(2) : list2%() = 1, 1, 1 + PRINT "partitions(1,1,1):" + PRINT FNpartitions(list2%()) + DIM list3%(3) : list3%() = 1, 2, 0, 1 + PRINT "partitions(1,2,0,1):" + PRINT FNpartitions(list3%()) + END + + DEF FNpartitions(list%()) + LOCAL i%, j%, n%, p%, o$, x%() + n% = DIM(list%(),1) + DIM x%(SUM(list%())-1) + FOR i% = 0 TO n% + IF list%(i%) THEN + FOR j% = 1 TO list%(i%) + x%(p%) = i% + p% += 1 + NEXT + ENDIF + NEXT i% + REPEAT + FOR i% = 0 TO n% + o$ += " ( " + FOR j% = 0 TO DIM(x%(),1) + IF x%(j%) = i% o$ += STR$(j%+1) + " " + NEXT + o$ += ")" + NEXT i% + o$ += CHR$13 + CHR$10 + UNTIL NOT FNperm(x%()) + = o$ + + DEF FNperm(x%()) + LOCAL i%, j% + FOR i% = DIM(x%(),1)-1 TO 0 STEP -1 + IF x%(i%) < x%(i%+1) EXIT FOR + NEXT + IF i% < 0 THEN = FALSE + j% = DIM(x%(),1) + WHILE x%(j%) <= x%(i%) j% -= 1 : ENDWHILE + SWAP x%(i%), x%(j%) + i% += 1 + j% = DIM(x%(),1) + WHILE i% < j% + SWAP x%(i%), x%(j%) + i% += 1 + j% -= 1 + ENDWHILE + = TRUE diff --git a/Task/Ordered-Partitions/C/ordered-partitions-1.c b/Task/Ordered-Partitions/C/ordered-partitions-1.c new file mode 100644 index 0000000000..7127423ce8 --- /dev/null +++ b/Task/Ordered-Partitions/C/ordered-partitions-1.c @@ -0,0 +1,51 @@ +#include + +int next_perm(int size, int * nums) +{ + int *l, *k, tmp; + + for (k = nums + size - 2; k >= nums && k[0] >= k[1]; k--) {}; + if (k < nums) return 0; + + for (l = nums + size - 1; *l <= *k; l--) {}; + tmp = *k; *k = *l; *l = tmp; + + for (l = nums + size - 1, k++; k < l; k++, l--) { + tmp = *k; *k = *l; *l = tmp; + } + + return 1; +} + +void make_part(int n, int * sizes) +{ + int x[1024], i, j, *ptr, len = 0; + + for (ptr = x, i = 0; i < n; i++) + for (j = 0, len += sizes[i]; j < sizes[i]; j++, *(ptr++) = i); + + do { + for (i = 0; i < n; i++) { + printf(" { "); + for (j = 0; j < len; j++) + if (x[j] == i) printf("%d ", j); + + printf("}"); + } + printf("\n"); + } while (next_perm(len, x)); +} + +int main() +{ + int s1[] = {2, 0, 2}; + int s2[] = {1, 2, 3, 4}; + + printf("Part 2 0 2:\n"); + make_part(3, s1); + + printf("\nPart 1 2 3 4:\n"); + make_part(4, s2); + + return 1; +} diff --git a/Task/Ordered-Partitions/C/ordered-partitions-2.c b/Task/Ordered-Partitions/C/ordered-partitions-2.c new file mode 100644 index 0000000000..5f2df77aec --- /dev/null +++ b/Task/Ordered-Partitions/C/ordered-partitions-2.c @@ -0,0 +1,51 @@ +#include + +typedef unsigned int uint; + +int parts[] = {2, 1, 2}; +#define n_parts sizeof(parts)/sizeof(parts[0]) +int bits[n_parts]; + +void show_part(uint x) +{ + uint i; + putchar('{'); + for (i = 0; (1 << i) <= x; i ++) + if (x & (1 << i)) printf(" %d", i + 1); + + printf("%s", " } "); +} + +void gen_bits(uint mask, uint all, uint res, int n, int pid) +{ + uint i; + while (!n) { + bits[pid++] = res; + if (pid == n_parts) { + for (i = 0; i < n_parts; i++) + show_part(bits[i]); + putchar('\n'); + return; + } + mask = all &= ~res; + res = 0; + n = parts[pid]; + } + + while (mask) { + mask &= ~(i = mask & -(int)mask); + gen_bits(mask, all, res | i, n - 1, pid); + } +} + +int main(void) +{ + uint i, m; + for (m = 1, i = 0; i < n_parts; i++) + m <<= parts[i]; + m--; + + gen_bits(m, m, 0, parts[0], 0); + + return 0; +} diff --git a/Task/Ordered-Partitions/Common-Lisp/ordered-partitions.lisp b/Task/Ordered-Partitions/Common-Lisp/ordered-partitions.lisp new file mode 100644 index 0000000000..a988312d21 --- /dev/null +++ b/Task/Ordered-Partitions/Common-Lisp/ordered-partitions.lisp @@ -0,0 +1,46 @@ +(defun fill-part (x i j l) + (let ((e (elt x i))) + (loop for c in l do + (loop while (>= j (length e)) do + (setf j 0 e (elt x (incf i)))) + (setf (elt e j) c) + (incf j)))) + +;;; take a list of lists and return next partitioning +;;; it's caller's responsibility to ensure each sublist is sorted +(defun next-part (list cmp) + (let* ((l (coerce list 'vector)) + (i (1- (length l))) + (e (elt l i))) + (loop while (<= 0 (decf i)) do + ;; e holds all the right most elements + (let ((p (elt l i)) (q (car (last e)))) + ;; find the right-most list that has an element that's smaller + ;; than _something_ in later lists + (when (and p (funcall cmp (first p) q)) + ;; find largest element that can be increased + (loop for j from (1- (length p)) downto 0 do + (when (funcall cmp (elt p j) q) + ;; find the smallest element that's larger than + ;; that largest + (loop for x from 0 to (1- (length e)) do + (when (funcall cmp (elt p j) (elt e x)) + (rotatef (elt p j) (elt e x)) + (loop while (< (incf j) (length p)) do + (setf (elt p j) (elt e (incf x)) + (elt e x) nil)) + (fill-part l i j (remove nil e)) + (return-from next-part l)))) + (setf e (append e (list (elt p j)))))) + (setf e (append e p)))))) + +(let ((a '#((1 2) () (3 4)))) + (loop while a do + (format t "~a~%" a) + (setf a (next-part a #'<)))) + +(write-line "with dupe elements:") +(let ((a '#((a c) (c c d)))) + (loop while a do + (format t "~a~%" a) + (setf a (next-part a #'string<)))) diff --git a/Task/Ordered-Partitions/D/ordered-partitions.d b/Task/Ordered-Partitions/D/ordered-partitions.d new file mode 100644 index 0000000000..4158d5997d --- /dev/null +++ b/Task/Ordered-Partitions/D/ordered-partitions.d @@ -0,0 +1,34 @@ +import std.stdio, std.algorithm, std.range, std.array, std.conv; +// http://rosettacode.org/wiki/Combinations#D +import combinations4: Comb; + +alias int[] iRNG; + +iRNG setDiff(iRNG s, iRNG c) { + return setDifference(s, c).array(); +} + +iRNG[][] orderPart(iRNG blockSize...) { + iRNG sum = iota(1, 1 + blockSize.reduce!q{a + b}()).array(); + + iRNG[][] p(iRNG s, in iRNG b) { + if (b.length == 0) + return [[]]; + iRNG[][] res; + foreach (c; Comb.On(s, b[0])) + foreach (r; p(setDiff(s, c), b[1 .. $])) + res ~= c.dup ~ r; + return res; + } + + return p(sum, blockSize); +} + +void main(string[] args) { + auto b = args.length > 1 ? + args[1 .. $].map!(to!int)().array() : + [2, 0, 2]; + + foreach (p; orderPart(b)) + writeln(p); +} diff --git a/Task/Ordered-Partitions/GAP/ordered-partitions.gap b/Task/Ordered-Partitions/GAP/ordered-partitions.gap new file mode 100644 index 0000000000..e8741d352c --- /dev/null +++ b/Task/Ordered-Partitions/GAP/ordered-partitions.gap @@ -0,0 +1,28 @@ +FixedPartitions := function(arg) + local aux; + aux := function(i, u) + local r, v, w; + if i = Size(arg) then + return [[u]]; + else + r := [ ]; + for v in Combinations(u, arg[i]) do + for w in aux(i + 1, Difference(u, v)) do + Add(r, Concatenation([v], w)); + od; + od; + return r; + fi; + end; + return aux(1, [1 .. Sum(arg)]); +end; + + +FixedPartitions(2, 0, 2); +# [ [ [ 1, 2 ], [ ], [ 3, 4 ] ], [ [ 1, 3 ], [ ], [ 2, 4 ] ], +# [ [ 1, 4 ], [ ], [ 2, 3 ] ], [ [ 2, 3 ], [ ], [ 1, 4 ] ], +# [ [ 2, 4 ], [ ], [ 1, 3 ] ], [ [ 3, 4 ], [ ], [ 1, 2 ] ] ] + +FixedPartitions(1, 1, 1); +# [ [ [ 1 ], [ 2 ], [ 3 ] ], [ [ 1 ], [ 3 ], [ 2 ] ], [ [ 2 ], [ 1 ], [ 3 ] ], +# [ [ 2 ], [ 3 ], [ 1 ] ], [ [ 3 ], [ 1 ], [ 2 ] ], [ [ 3 ], [ 2 ], [ 1 ] ] ] diff --git a/Task/Ordered-Partitions/Go/ordered-partitions.go b/Task/Ordered-Partitions/Go/ordered-partitions.go new file mode 100644 index 0000000000..772975d8f4 --- /dev/null +++ b/Task/Ordered-Partitions/Go/ordered-partitions.go @@ -0,0 +1,60 @@ +package main + +import ( + "fmt" + "os" + "strconv" +) + +func gen_part(n, res []int, pos int) { + if pos == len(res) { + x := make([][]int, len(n)) + for i, c := range res { + x[c] = append(x[c], i+1) + } + + fmt.Println(x) + return + } + + for i := range n { + if n[i] == 0 { + continue + } + n[i], res[pos] = n[i]-1, i + gen_part(n, res, pos+1) + n[i]++ + } +} + +func ordered_part(n_parts []int) { + fmt.Println("Ordered", n_parts) + + sum := 0 + for _, c := range n_parts { + sum += c + } + + gen_part(n_parts, make([]int, sum), 0) +} + +func main() { + if len(os.Args) < 2 { + ordered_part([]int{2, 0, 2}) + return + } + n := make([]int, len(os.Args)-1) + var err error + for i, a := range os.Args[1:] { + n[i], err = strconv.Atoi(a) + if err != nil { + fmt.Println(err) + return + } + if n[i] < 0 { + fmt.Println("negative partition size not meaningful") + return + } + } + ordered_part(n) +} diff --git a/Task/Ordered-Partitions/Groovy/ordered-partitions-1.groovy b/Task/Ordered-Partitions/Groovy/ordered-partitions-1.groovy new file mode 100644 index 0000000000..1ecb219280 --- /dev/null +++ b/Task/Ordered-Partitions/Groovy/ordered-partitions-1.groovy @@ -0,0 +1,13 @@ +def partitions = { int... sizes -> + int n = (sizes as List).sum() + def perms = n == 0 ? [[]] : (1..n).permutations() + Set parts = perms.collect { p -> sizes.collect { s -> (0.. + if (!a) return 0 + def comp = [a,b].transpose().find { it[0] != it[1] } + if (!comp) return 0 + def recomp = comp.collect{ it as List }.transpose().find { it[0] != it[1] } + if (!recomp) return 0 + return recomp[0] <=> recomp[1] + } +} diff --git a/Task/Ordered-Partitions/Groovy/ordered-partitions-2.groovy b/Task/Ordered-Partitions/Groovy/ordered-partitions-2.groovy new file mode 100644 index 0000000000..4620f82084 --- /dev/null +++ b/Task/Ordered-Partitions/Groovy/ordered-partitions-2.groovy @@ -0,0 +1,3 @@ +partitions(2, 0, 2).each { + println it +} diff --git a/Task/Ordered-Partitions/Haskell/ordered-partitions-1.hs b/Task/Ordered-Partitions/Haskell/ordered-partitions-1.hs new file mode 100644 index 0000000000..97c9307219 --- /dev/null +++ b/Task/Ordered-Partitions/Haskell/ordered-partitions-1.hs @@ -0,0 +1,13 @@ +import Data.List ((\\)) + +comb :: Int -> [a] -> [[a]] +comb 0 _ = [[]] +comb _ [] = [] +comb k (x:xs) = map (x:) (comb (k-1) xs) ++ comb k xs + +partitions :: [Int] -> [[[Int]]] +partitions xs = p [1..sum xs] xs + where p _ [] = [[]] + p xs (k:ks) = [ cs:rs | cs <- comb k xs, rs <- p (xs \\ cs) ks ] + +main = print $ partitions [2,0,2] diff --git a/Task/Ordered-Partitions/Haskell/ordered-partitions-2.hs b/Task/Ordered-Partitions/Haskell/ordered-partitions-2.hs new file mode 100644 index 0000000000..7ef297e0ab --- /dev/null +++ b/Task/Ordered-Partitions/Haskell/ordered-partitions-2.hs @@ -0,0 +1,12 @@ +comb :: Int -> [a] -> [([a],[a])] +comb 0 xs = [([],xs)] +comb _ [] = [] +comb k (x:xs) = [ (x:cs,zs) | (cs,zs) <- comb (k-1) xs ] ++ + [ (cs,x:zs) | (cs,zs) <- comb k xs ] + +partitions :: [Int] -> [[[Int]]] +partitions xs = p [1..sum xs] xs + where p _ [] = [[]] + p xs (k:ks) = [ cs:rs | (cs,zs) <- comb k xs, rs <- p zs ks ] + +main = print $ partitions [2,0,2] diff --git a/Task/Ordered-Partitions/Haskell/ordered-partitions-3.hs b/Task/Ordered-Partitions/Haskell/ordered-partitions-3.hs new file mode 100644 index 0000000000..583e074fb7 --- /dev/null +++ b/Task/Ordered-Partitions/Haskell/ordered-partitions-3.hs @@ -0,0 +1,15 @@ +-- choose m out of n items, return tuple of chosen and the rest +choose aa _ 0 = [([], aa)] +choose aa@(a:as) n m + | n == m = [(aa, [])] + | otherwise = map (\(x,y) -> (a:x, y)) (choose as (n-1) (m-1)) ++ + map (\(x,y) -> (x, a:y)) (choose as (n-1) m) + +partitions x = combos [1..n] n x where + n = sum x + combos _ _ [] = [[]] + combos s n (x:xs) = [ l : r | (l,rest) <- choose s n x, + r <- combos rest (n - x) xs] + + +main = mapM_ print $ partitions [5,5,5] diff --git a/Task/Ordered-Partitions/J/ordered-partitions-1.j b/Task/Ordered-Partitions/J/ordered-partitions-1.j new file mode 100644 index 0000000000..2c25d9c379 --- /dev/null +++ b/Task/Ordered-Partitions/J/ordered-partitions-1.j @@ -0,0 +1,2 @@ +require'stats' +partitions=: ([,] {L:0 (i.@#@, -. [)&;)/"1@>@,@{@({@comb&.> +/\.) diff --git a/Task/Ordered-Partitions/J/ordered-partitions-2.j b/Task/Ordered-Partitions/J/ordered-partitions-2.j new file mode 100644 index 0000000000..1748e5d87b --- /dev/null +++ b/Task/Ordered-Partitions/J/ordered-partitions-2.j @@ -0,0 +1,39 @@ + partitions 2 0 2 +┌───┬┬───┐ +│0 1││2 3│ +├───┼┼───┤ +│0 2││1 3│ +├───┼┼───┤ +│0 3││1 2│ +├───┼┼───┤ +│1 2││0 3│ +├───┼┼───┤ +│1 3││0 2│ +├───┼┼───┤ +│2 3││0 1│ +└───┴┴───┘ + partitions 1 1 1 +┌─┬─┬─┐ +│0│1│2│ +├─┼─┼─┤ +│0│2│1│ +├─┼─┼─┤ +│1│0│2│ +├─┼─┼─┤ +│1│2│0│ +├─┼─┼─┤ +│2│0│1│ +├─┼─┼─┤ +│2│1│0│ +└─┴─┴─┘ + #partitions 2 3 5 +2520 + #partitions 5 7 11 +|out of memory: partitions +| # partitions 5 7 11 + */ (! +/\.)5 7 11 +1070845776 + #partitions 3 5 7 +360360 + */ (! +/\.)3 5 7 +360360 diff --git a/Task/Ordered-Partitions/Lua/ordered-partitions.lua b/Task/Ordered-Partitions/Lua/ordered-partitions.lua new file mode 100644 index 0000000000..721197c0e4 --- /dev/null +++ b/Task/Ordered-Partitions/Lua/ordered-partitions.lua @@ -0,0 +1,89 @@ +--- Create a list {1,...,n}. +local function range(n) + local res = {} + for i=1,n do + res[i] = i + end + return res +end + +--- Return true if the element x is in t. +local function isin(t, x) + for _,x_t in ipairs(t) do + if x_t == x then return true end + end + return false +end + +--- Return the sublist from index u to o (inclusive) from t. +local function slice(t, u, o) + local res = {} + for i=u,o do + res[#res+1] = t[i] + end + return res +end + +--- Compute the sum of the elements in t. +-- Assume that t is a list of numbers. +local function sum(t) + local s = 0 + for _,x in ipairs(t) do + s = s + x + end + return s +end + +--- Generate all combinations of t of length k (optional, default is #t). +local function combinations(m, r) + local function combgen(m, n) + if n == 0 then coroutine.yield({}) end + for i=1,#m do + if n == 1 then coroutine.yield({m[i]}) + else + for m0 in coroutine.wrap(function() combgen(slice(m, i+1, #m), n-1) end) do + coroutine.yield({m[i], unpack(m0)}) + end + end + end + end + return coroutine.wrap(function() combgen(m, r) end) +end + +--- Generate a list of partitions into fized-size blocks. +local function partitions(...) + local function helper(s, ...) + local args = {...} + if #args == 0 then return {% templatetag openvariable %}{% templatetag closevariable %} end + local res = {} + for c in combinations(s, args[1]) do + local s0 = {} + for _,x in ipairs(s) do if not isin(c, x) then s0[#s0+1] = x end end + for _,r in ipairs(helper(s0, unpack(slice(args, 2, #args)))) do + res[#res+1] = {{unpack(c)}, unpack(r)} + end + end + return res + end + return helper(range(sum({...})), ...) +end + +-- Print the solution +io.write "[" +local parts = partitions(2,0,2) +for i,tuple in ipairs(parts) do + io.write "(" + for j,set in ipairs(tuple) do + io.write "{" + for k,element in ipairs(set) do + io.write(element) + if k ~= #set then io.write(", ") end + end + io.write "}" + if j ~= #tuple then io.write(", ") end + end + io.write ")" + if i ~= #parts then io.write(", ") end +end +io.write "]" +io.write "\n" diff --git a/Task/Ordered-Partitions/Mathematica/ordered-partitions-1.math b/Task/Ordered-Partitions/Mathematica/ordered-partitions-1.math new file mode 100644 index 0000000000..eddc23c052 --- /dev/null +++ b/Task/Ordered-Partitions/Mathematica/ordered-partitions-1.math @@ -0,0 +1,4 @@ +w[partitions_]:=Module[{s={},t=Total@partitions,list=partitions,k}, n=Length[list]; + While[n>0,s=Join[s,{Take[t,(k=First[list])]}];t=Drop[t,k];list=Rest[list];n--]; s] + +m[p_]:=(Sort/@#)&/@(w[#,p]&/@Permutations[Range@Total[p]])//Union diff --git a/Task/Ordered-Partitions/Mathematica/ordered-partitions-2.math b/Task/Ordered-Partitions/Mathematica/ordered-partitions-2.math new file mode 100644 index 0000000000..efce744056 --- /dev/null +++ b/Task/Ordered-Partitions/Mathematica/ordered-partitions-2.math @@ -0,0 +1,3 @@ +Grid@m[{2, 0, 2}] + +Grid@m[{1, 1, 1}] diff --git a/Task/Ordered-Partitions/Perl-6/ordered-partitions.pl6 b/Task/Ordered-Partitions/Perl-6/ordered-partitions.pl6 new file mode 100644 index 0000000000..76cbc2a50e --- /dev/null +++ b/Task/Ordered-Partitions/Perl-6/ordered-partitions.pl6 @@ -0,0 +1,10 @@ +sub partition(@mask is copy) { + my $last = [+] @mask or return [[] xx @mask]; + sort gather for @mask.kv -> $k,$v { + next unless $v; + temp @mask[$k] -= 1; + for partition @mask { .take.[$k].push($last) } + } +} + +.perl.say for partition [2,0,2]; diff --git a/Task/Ordered-Partitions/Perl/ordered-partitions-1.pl b/Task/Ordered-Partitions/Perl/ordered-partitions-1.pl new file mode 100644 index 0000000000..573e9bbdc3 --- /dev/null +++ b/Task/Ordered-Partitions/Perl/ordered-partitions-1.pl @@ -0,0 +1,43 @@ +use Thread 'async'; +use Thread::Queue; + +sub make_slices { + my ($n, @avail) = (shift, @{ +shift }); + + my ($q, @part, $gen); + $gen = sub { + my $pos = shift; # where to start in the list + if (@part == $n) { + # we accumulated enough for a partition, emit them and + # wait for main thread to pick them up, then back up + $q->enqueue(\@part, \@avail); + return; + } + + # obviously not enough elements left to make a partition, back up + return if (@part + @avail < $n); + + for my $i ($pos .. @avail - 1) { # try each in turn + push @part, splice @avail, $i, 1; # take one + $gen->($i); # go deeper + splice @avail, $i, 0, pop @part; # put it back + } + }; + + $q = new Thread::Queue; + (async{ &$gen; # start the main work load + $q->enqueue(undef) # signal that there's no more data + })->detach; # let the thread clean up after itself, not my problem + + return $q; +} + +my $qa = make_slices(4, [ 0 .. 9 ]); +while (my $a = $qa->dequeue) { + my $qb = make_slices(2, $qa->dequeue); + + while (my $b = $qb->dequeue) { + my $rb = $qb->dequeue; + print "@$a | @$b | @$rb\n"; + } +} diff --git a/Task/Ordered-Partitions/Perl/ordered-partitions-2.pl b/Task/Ordered-Partitions/Perl/ordered-partitions-2.pl new file mode 100644 index 0000000000..c73b4463af --- /dev/null +++ b/Task/Ordered-Partitions/Perl/ordered-partitions-2.pl @@ -0,0 +1,48 @@ +sub partitions { + my $sum = 0; + $sum += $_ for @_; # total number of elements + make_part ( $_[-1], # desired partition size + 0, # initial trial position + [ (0) x $sum ], # table recording of used element + [], # current pick for current partition + [ $#_, # total number of partitions + \@_, # partition sizes + [] # for output, each partition's elements + ] # Note: last group of args wrapped in array ref + ); # to reduce argument passing overhead +} + +sub make_part { + my ($n, $pos, $used, $picked, $more) = @_; + return if $pos > @$used; + + # the making-next-partition part + if (!$n) { + my ($part_idx, $sizes, $q) = @$more; + push @$q, $picked; + if ($part_idx > 1) { + make_part($sizes->[$part_idx-1], 0, $used, [], + [ $part_idx-1, $sizes, $q]); + } else { + my @x = grep { !$used->[$_] } 0 .. (@$used-1); + print "[ @$_ ]" for @$q; + print "[ @x ]\n"; + } + pop @$q; + return; + } + + # the picking-element-to-make-partition part + for my $i ($pos .. @$used - 1) { + next if $used->[$i]; + push @$picked, $i; + $used->[$i] = 1; + + make_part($n - 1, $i + 1, $used, $picked, $more); + + $used->[$i] = 0; + pop @$picked; + } +} + +partitions(4, 2, 4); diff --git a/Task/Ordered-Partitions/PicoLisp/ordered-partitions.l b/Task/Ordered-Partitions/PicoLisp/ordered-partitions.l new file mode 100644 index 0000000000..5bb5adc795 --- /dev/null +++ b/Task/Ordered-Partitions/PicoLisp/ordered-partitions.l @@ -0,0 +1,11 @@ +(de partitions (Args) + (let Lst (range 1 (apply + Args)) + (recur (Args Lst) + (ifn Args + '(NIL) + (mapcan + '((L) + (mapcar + '((R) (cons L R)) + (recurse (cdr Args) (diff Lst L)) ) ) + (comb (car Args) Lst) ) ) ) ) ) diff --git a/Task/Ordered-Partitions/Python/ordered-partitions-1.py b/Task/Ordered-Partitions/Python/ordered-partitions-1.py new file mode 100644 index 0000000000..562a2b6173 --- /dev/null +++ b/Task/Ordered-Partitions/Python/ordered-partitions-1.py @@ -0,0 +1,15 @@ +from itertools import combinations + +def partitions(*args): + def p(s, *args): + if not args: return [[]] + res = [] + for c in combinations(s, args[0]): + s0 = [x for x in s if x not in c] + for r in p(s0, *args[1:]): + res.append([c] + r) + return res + s = range(sum(args)) + return p(s, *args) + +print partitions(2, 0, 2) diff --git a/Task/Ordered-Partitions/Python/ordered-partitions-2.py b/Task/Ordered-Partitions/Python/ordered-partitions-2.py new file mode 100644 index 0000000000..17d55f9680 --- /dev/null +++ b/Task/Ordered-Partitions/Python/ordered-partitions-2.py @@ -0,0 +1,10 @@ +from itertools import combinations as comb + +def partitions(*args): + def minus(s1, s2): return [x for x in s1 if x not in s2] + def p(s, *args): + if not args: return [[]] + return [[c] + r for c in comb(s, args[0]) for r in p(minus(s, c), *args[1:])] + return p(range(1, sum(args) + 1), *args) + +print partitions(2, 0, 2) diff --git a/Task/Ordered-Partitions/Tcl/ordered-partitions-1.tcl b/Task/Ordered-Partitions/Tcl/ordered-partitions-1.tcl new file mode 100644 index 0000000000..4909f01ff4 --- /dev/null +++ b/Task/Ordered-Partitions/Tcl/ordered-partitions-1.tcl @@ -0,0 +1,52 @@ +package require Tcl 8.5 +package require struct::set + +# Selects all k-sized combinations from a list. +# "Borrowed" from elsewhere on RC +proc selectCombinationsFrom {k l} { + if {$k == 0} {return {}} elseif {$k == [llength $l]} {return [list $l]} + set all {} + set n [expr {[llength $l] - [incr k -1]}] + for {set i 0} {$i < $n} {} { + set first [lindex $l $i] + incr i + if {$k == 0} { + lappend all $first + } else { + foreach s [selectCombinationsFrom $k [lrange $l $i end]] { + lappend all [list $first {*}$s] + } + } + } + return $all +} + +# Construct the partitioning of a given list +proc buildPartitions {lst n args} { + # Base case when we have no further partitions to process + if {[llength $args] == 0} { + return [list [list $lst]] + } + set result {} + set c [selectCombinationsFrom $n $lst] + if {[llength $c] == 0} {set c [list $c]} + foreach comb $c { + # Sort necessary for "nice" order + set rest [lsort -integer [struct::set difference $lst $comb]] + foreach p [buildPartitions $rest {*}$args] { + lappend result [list $comb {*}$p] + } + } + return $result +} + +# Wrapper that assembles the initial list and calls the partitioner +proc partitions args { + set sum [tcl::mathop::+ {*}$args] + set startingSet {} + for {set i 1} {$i <= $sum} {incr i} { + lappend startingSet $i + } + + return [buildPartitions $startingSet {*}$args] +} diff --git a/Task/Ordered-Partitions/Tcl/ordered-partitions-2.tcl b/Task/Ordered-Partitions/Tcl/ordered-partitions-2.tcl new file mode 100644 index 0000000000..4fc3036609 --- /dev/null +++ b/Task/Ordered-Partitions/Tcl/ordered-partitions-2.tcl @@ -0,0 +1,4 @@ +puts [partitions 1 1 1] +puts [partitions 2 2] +puts [partitions 2 0 2] +puts [partitions 2 2 0] diff --git a/Task/Ordered-Partitions/Ursala/ordered-partitions-1.ursala b/Task/Ordered-Partitions/Ursala/ordered-partitions-1.ursala new file mode 100644 index 0000000000..ec81bab415 --- /dev/null +++ b/Task/Ordered-Partitions/Ursala/ordered-partitions-1.ursala @@ -0,0 +1,8 @@ +#import std +#import nat + +opart = + +-+ + ~&art^?\~&alNCNC ^|JalSPfarSPMplrDSL/~& ^DrlPrrPlXXS/~&rt ^DrlrjXS/~&l choices@lrhPX, + ^\~& nrange/1+ sum:-0+- diff --git a/Task/Ordered-Partitions/Ursala/ordered-partitions-2.ursala b/Task/Ordered-Partitions/Ursala/ordered-partitions-2.ursala new file mode 100644 index 0000000000..35ba1f262f --- /dev/null +++ b/Task/Ordered-Partitions/Ursala/ordered-partitions-2.ursala @@ -0,0 +1,3 @@ +#cast %nLLL + +test = opart <2,0,2> diff --git a/Task/Palindrome-detection/0DESCRIPTION b/Task/Palindrome-detection/0DESCRIPTION new file mode 100644 index 0000000000..71c074a06a --- /dev/null +++ b/Task/Palindrome-detection/0DESCRIPTION @@ -0,0 +1,30 @@ +Write at least one function/method (or whatever it is called in your preferred +language) to check if a sequence of characters (or bytes) is +a [[wp:Palindrome|palindrome]] or not. The ''function'' must return +a boolean value (or something that can be used as boolean value, like an +integer). + +It is not mandatory to write also an example code that uses the ''function'', +unless its usage could be not clear (e.g. the provided recursive C solution +needs explanation on how to call the function). + +It is not mandatory to handle properly encodings (see [[String length]]), +i.e. it is admissible that the function does not recognize 'salàlas' as +palindrome. + +The function must not ignore spaces and punctuations. The compliance to the +aforementioned, strict or not, requirements completes the task. + +'''Example'''
+An example of a Latin palindrome is the sentence +"''In girum imus nocte et consumimur igni''", +roughly translated as: we walk around in the night and we are burnt by the +fire (of love). To do your test with it, you must make it all the same case and +strip spaces. + +'''Notes'''
+* It might be useful for this task to know how to [[Reversing a string|reverse a string]]. +* This task's entries might also form the subjects of the task [[Test a function]]. + +;Cf. +* [[Semordnilap]] diff --git a/Task/Palindrome-detection/1META.yaml b/Task/Palindrome-detection/1META.yaml new file mode 100644 index 0000000000..448dce149a --- /dev/null +++ b/Task/Palindrome-detection/1META.yaml @@ -0,0 +1,5 @@ +--- +category: +- Recursion +- Classic CS problems and programs +note: Text processing diff --git a/Task/Palindrome-detection/ACL2/palindrome-detection.acl2 b/Task/Palindrome-detection/ACL2/palindrome-detection.acl2 new file mode 100644 index 0000000000..09b941d8e5 --- /dev/null +++ b/Task/Palindrome-detection/ACL2/palindrome-detection.acl2 @@ -0,0 +1,17 @@ +(defun reverse-split-at-r (xs i ys) + (if (zp i) + (mv xs ys) + (reverse-split-at-r (rest xs) (1- i) + (cons (first xs) ys)))) + +(defun reverse-split-at (xs i) + (reverse-split-at-r xs i nil)) + +(defun is-palindrome (str) + (let* ((lngth (length str)) + (idx (floor lngth 2))) + (mv-let (xs ys) + (reverse-split-at (coerce str 'list) idx) + (if (= (mod lngth 2) 1) + (equal (rest xs) ys) + (equal xs ys))))) diff --git a/Task/Palindrome-detection/ALGOL-68/palindrome-detection.alg b/Task/Palindrome-detection/ALGOL-68/palindrome-detection.alg new file mode 100644 index 0000000000..2d4a286146 --- /dev/null +++ b/Task/Palindrome-detection/ALGOL-68/palindrome-detection.alg @@ -0,0 +1,26 @@ +# Iterative # +PROC palindrome = (STRING s)BOOL:( + FOR i TO UPB s OVER 2 DO + IF s[i] /= s[UPB s-i+1] THEN GO TO return false FI + OD; + else: TRUE EXIT + return false: FALSE +); + +# Recursive # +PROC palindrome r = (STRING s)BOOL: + IF LWB s >= UPB s THEN TRUE + ELIF s[LWB s] /= s[UPB s] THEN FALSE + ELSE palindrome r(s[LWB s+1:UPB s-1]) + FI +; + +# Test # +main: +( + STRING t = "ingirumimusnocteetconsumimurigni"; + FORMAT template = $"sequence """g""" "b("is","isnt")" a palindrome"l$; + + printf((template, t, palindrome(t))); + printf((template, t, palindrome r(t))) +) diff --git a/Task/Palindrome-detection/AWK/palindrome-detection-1.awk b/Task/Palindrome-detection/AWK/palindrome-detection-1.awk new file mode 100644 index 0000000000..d55fa23f85 --- /dev/null +++ b/Task/Palindrome-detection/AWK/palindrome-detection-1.awk @@ -0,0 +1,5 @@ +function is_palindro(s) +{ + if ( s == reverse(s) ) return 1; + return 0 +} diff --git a/Task/Palindrome-detection/AWK/palindrome-detection-2.awk b/Task/Palindrome-detection/AWK/palindrome-detection-2.awk new file mode 100644 index 0000000000..0741449adf --- /dev/null +++ b/Task/Palindrome-detection/AWK/palindrome-detection-2.awk @@ -0,0 +1,6 @@ +function is_palindro_r(s) +{ + if ( length(s) < 2 ) return 1; + if ( substr(s, 1, 1) != substr(s, length(s), 1) ) return 0; + return is_palindro_r(substr(s, 2, length(s)-2)) +} diff --git a/Task/Palindrome-detection/AWK/palindrome-detection-3.awk b/Task/Palindrome-detection/AWK/palindrome-detection-3.awk new file mode 100644 index 0000000000..17a662b1ff --- /dev/null +++ b/Task/Palindrome-detection/AWK/palindrome-detection-3.awk @@ -0,0 +1,5 @@ +BEGIN { + pal = "ingirumimusnocteetconsumimurigni" + print is_palindro(pal) + print is_palindro_r(pal) +} diff --git a/Task/Palindrome-detection/ActionScript/palindrome-detection.as b/Task/Palindrome-detection/ActionScript/palindrome-detection.as new file mode 100644 index 0000000000..73ae7962f7 --- /dev/null +++ b/Task/Palindrome-detection/ActionScript/palindrome-detection.as @@ -0,0 +1,6 @@ +function isPalindrome(str:String):Boolean +{ + for(var first:uint = 0, second:uint = str.length - 1; first < second; first++, second--) + if(str.charAt(first) != str.charAt(second)) return false; + return true; +} diff --git a/Task/Palindrome-detection/Ada/palindrome-detection.ada b/Task/Palindrome-detection/Ada/palindrome-detection.ada new file mode 100644 index 0000000000..61c5f9c79a --- /dev/null +++ b/Task/Palindrome-detection/Ada/palindrome-detection.ada @@ -0,0 +1,9 @@ +function Palindrome (Text : String) return Boolean is +begin + for Offset in 0..Text'Length / 2 - 1 loop + if Text (Text'First + Offset) /= Text (Text'Last - Offset) then + return False; + end if; + end loop; + return True; +end Palindrome; diff --git a/Task/Palindrome-detection/AutoHotkey/palindrome-detection.ahk b/Task/Palindrome-detection/AutoHotkey/palindrome-detection.ahk new file mode 100644 index 0000000000..ac92476218 --- /dev/null +++ b/Task/Palindrome-detection/AutoHotkey/palindrome-detection.ahk @@ -0,0 +1,7 @@ +IsPalindrome( Str ){ + StringLower, str, str + str := (RegexReplace(str,"\W+" )) + Loop, Parse, Str + reversedStr := A_LoopField . ReversedStr + Return ( ReversedStr = Str ) +} diff --git a/Task/Palindrome-detection/AutoIt/palindrome-detection.autoit b/Task/Palindrome-detection/AutoIt/palindrome-detection.autoit new file mode 100644 index 0000000000..804ee56798 --- /dev/null +++ b/Task/Palindrome-detection/AutoIt/palindrome-detection.autoit @@ -0,0 +1,52 @@ +;AutoIt Version: 3.2.10.0 + +$mystring="In girum imus nocte, et consumimur igni" +MsgBox(0, "Palindrome", $mystring & " is palindrome: " & isPalindrome($mystring)) +;output is: "In girum imus nocte, et consumimur igni is palindrome: True" +$mystring="Madam, I'm Adam." +MsgBox(0, "Palindrome", $mystring & " is palindrome: " & isPalindrome($mystring)) +;output is: "Madam, I'm Adam. is palindrome: True" +$mystring="no salàlas no" +MsgBox(0, "Palindrome", $mystring & " is palindrome: " & isPalindrome($mystring)) +;output is: "no salàlas no is palindrome: False" + +Func isPalindrome($Str_palindrome) + $palindrome="False" + $Str_palindrome=StringLower($Str_palindrome) + $str_length = StringLen($Str_palindrome) + $new_str="" ;to rebuild string with only alphanumeric characters + + For $i = 1 to $str_length + $nth_chr = StringTrimRight(StringRight($Str_palindrome, $i),$i-1) + if StringIsAlpha($nth_chr) Then + $new_str=$new_str & $nth_chr ; add in string if alphabet + EndIf + if StringIsAlNum($nth_chr) Then + $new_str=$new_str & $nth_chr ; add in string if numeric + EndIf + + Next + $Str_palindrome=$new_str ;string without punctuations and spaces + $Str_reverse=reverse($Str_palindrome) ;reverse this string + + ;compare characters from both strings until half string is compared + For $i=1 to $str_length/2 + $First=StringLeft($Str_palindrome, 1) + $Last=StringLeft($Str_reverse, 1) + If $First == $Last Then + $palindrome="True" + EndIf + Next + + Return $palindrome +EndFunc + +; returns reverse of input string +Func reverse($string) + $str_length = StringLen($string) + $rev_str = "" + For $i = 1 to $str_length + $rev_str = $rev_str & StringTrimRight(StringRight($string, $i), $i-1) + Next + Return $rev_str +EndFunc diff --git a/Task/Palindrome-detection/BASIC/palindrome-detection.basic b/Task/Palindrome-detection/BASIC/palindrome-detection.basic new file mode 100644 index 0000000000..146ec8b885 --- /dev/null +++ b/Task/Palindrome-detection/BASIC/palindrome-detection.basic @@ -0,0 +1,32 @@ +DECLARE FUNCTION isPalindrome% (what AS STRING) + +DATA "My dog has fleas", "Madam, I'm Adam.", "1 on 1", "In girum imus nocte et consumimur igni" + +DIM L1 AS INTEGER, w AS STRING +FOR L1 = 1 TO 4 + READ w + IF isPalindrome(w) THEN + PRINT CHR$(34); w; CHR$(34); " is a palindrome" + ELSE + PRINT CHR$(34); w; CHR$(34); " is not a palindrome" + END IF +NEXT + +FUNCTION isPalindrome% (what AS STRING) + DIM whatcopy AS STRING, chk AS STRING, tmp AS STRING * 1, L0 AS INTEGER + + FOR L0 = 1 TO LEN(what) + tmp = UCASE$(MID$(what, L0, 1)) + SELECT CASE tmp + CASE "A" TO "Z" + whatcopy = whatcopy + tmp + chk = tmp + chk + CASE "0" TO "9" + PRINT "Numbers are cheating! ("; CHR$(34); what; CHR$(34); ")" + isPalindrome = 0 + EXIT FUNCTION + END SELECT + NEXT + + isPalindrome = ((whatcopy) = chk) +END FUNCTION diff --git a/Task/Palindrome-detection/BBC-BASIC/palindrome-detection.bbc b/Task/Palindrome-detection/BBC-BASIC/palindrome-detection.bbc new file mode 100644 index 0000000000..d75a7d390a --- /dev/null +++ b/Task/Palindrome-detection/BBC-BASIC/palindrome-detection.bbc @@ -0,0 +1,27 @@ + test$ = "A man, a plan, a canal: Panama!" + PRINT """" test$ """" ; + IF FNpalindrome(FNletters(test$)) THEN + PRINT " is a palindrome" + ELSE + PRINT " is not a palindrome" + ENDIF + END + + DEF FNpalindrome(A$) = (A$ = FNreverse(A$)) + + DEF FNreverse(A$) + LOCAL B$, P% + FOR P% = LEN(A$) TO 1 STEP -1 + B$ += MID$(A$,P%,1) + NEXT + = B$ + + DEF FNletters(A$) + LOCAL B$, C%, P% + FOR P% = 1 TO LEN(A$) + C% = ASC(MID$(A$,P%)) + IF C% > 64 AND C% < 91 OR C% > 96 AND C% < 123 THEN + B$ += CHR$(C% AND &5F) + ENDIF + NEXT + = B$ diff --git a/Task/Palindrome-detection/Befunge/palindrome-detection-1.bf b/Task/Palindrome-detection/Befunge/palindrome-detection-1.bf new file mode 100644 index 0000000000..a05505eb1a --- /dev/null +++ b/Task/Palindrome-detection/Befunge/palindrome-detection-1.bf @@ -0,0 +1,4 @@ +v_$0:8p>:#v_:18p08g1-08p >:08g`!v +~->p5p ^ 0v1p80-1g80vj!-g5g80g5_0'ev +:a^80+1:g8<>8g1+:18pv>0"eslaF">:#,_@ +[[relet]]-2010------>003-x -^"Tru"< diff --git a/Task/Palindrome-detection/Befunge/palindrome-detection-2.bf b/Task/Palindrome-detection/Befunge/palindrome-detection-2.bf new file mode 100644 index 0000000000..f4f1adb7a9 --- /dev/null +++ b/Task/Palindrome-detection/Befunge/palindrome-detection-2.bf @@ -0,0 +1,18 @@ +v> "emordnilap a toN",,,,,,,,,,,,,,,,@,,,,,,,,,,,,,,,"Is a palindrome" < +2^ < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < +4 ^_v ^_v ^_v ^_v ^_v ^_v ^_v ^_v ^_v ^_v ^_v ^_v +8 ^_v # ^_v # ^_v # ^_v # ^_v # ^_v # ^_v # ^_v # ^_v # ^_v # ^_v # ^_v # ^_v +*^_v ^_v ^_v ^_v ^_v ^_v ^_v ^_v ^_v ^_v ^_v ^_v ^_v ++ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +>"dennis sinned" v + " 2 + """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 0 +> ^- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9 + _^ v_^ v_^ v_^ v_^ v_^ v_^ v_^ v_^ v_^ v_^ v_^ v_^ p + v_^ # v_^ # v_^ # v_^ # v_^ # v_^ # v_^ # v_^ # v_^ # v_^ # v_^ # v_^ # v_^ + v_^ v_^ v_^ v_^ v_^ v_^ v_^ v_^ v_^ v_^ v_^ v_^ + ^< < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < + >09g8p09g1+09pv + |: < < +^< diff --git a/Task/Palindrome-detection/Burlesque/palindrome-detection.blq b/Task/Palindrome-detection/Burlesque/palindrome-detection.blq new file mode 100644 index 0000000000..9900f4918d --- /dev/null +++ b/Task/Palindrome-detection/Burlesque/palindrome-detection.blq @@ -0,0 +1 @@ +zz{ri}f[^^<-== diff --git a/Task/Palindrome-detection/C++/palindrome-detection-1.cpp b/Task/Palindrome-detection/C++/palindrome-detection-1.cpp new file mode 100644 index 0000000000..37270111f9 --- /dev/null +++ b/Task/Palindrome-detection/C++/palindrome-detection-1.cpp @@ -0,0 +1,7 @@ +#include +#include + +bool is_palindrome(std::string const& s) +{ + return std::equal(s.begin(), s.end(), s.rbegin()); +} diff --git a/Task/Palindrome-detection/C++/palindrome-detection-2.cpp b/Task/Palindrome-detection/C++/palindrome-detection-2.cpp new file mode 100644 index 0000000000..7bba61be26 --- /dev/null +++ b/Task/Palindrome-detection/C++/palindrome-detection-2.cpp @@ -0,0 +1,7 @@ +#include +#include + +bool is_palindrome(std::string const& s) +{ + return std::equal(s.begin(), s.begin()+s.length()/2, s.rbegin()); +} diff --git a/Task/Palindrome-detection/C/palindrome-detection-1.c b/Task/Palindrome-detection/C/palindrome-detection-1.c new file mode 100644 index 0000000000..1cdbd49c6d --- /dev/null +++ b/Task/Palindrome-detection/C/palindrome-detection-1.c @@ -0,0 +1,12 @@ +#include + +int palindrome(const char *s) +{ + int i,l; + l = strlen(s); + for(i=0; i +#include +/* testing */ +int main() +{ + const char *t = "ingirumimusnocteetconsumimurigni"; + const char *template = "sequence \"%s\" is%s palindrome\n"; + int l = strlen(t); + + printf(template, + t, palindrome(t) ? "" : "n't"); + printf(template, + t, palindrome_r(t, 0, l) ? "" : "n't"); + return 0; +} diff --git a/Task/Palindrome-detection/Clojure/palindrome-detection-1.clj b/Task/Palindrome-detection/Clojure/palindrome-detection-1.clj new file mode 100644 index 0000000000..93452c3a69 --- /dev/null +++ b/Task/Palindrome-detection/Clojure/palindrome-detection-1.clj @@ -0,0 +1,2 @@ +(defn palindrome? [s] + (= s (apply str (reverse s)))) diff --git a/Task/Palindrome-detection/Clojure/palindrome-detection-2.clj b/Task/Palindrome-detection/Clojure/palindrome-detection-2.clj new file mode 100644 index 0000000000..449f583712 --- /dev/null +++ b/Task/Palindrome-detection/Clojure/palindrome-detection-2.clj @@ -0,0 +1,7 @@ +(defn palindrome? [s] + (loop [i 0 + j (dec (. s length))] + (cond (>= i j) true + (= (get s i) (get s j)) + (recur (inc i) (dec j)) + :else false))) diff --git a/Task/Palindrome-detection/CoffeeScript/palindrome-detection-1.coffeescript b/Task/Palindrome-detection/CoffeeScript/palindrome-detection-1.coffeescript new file mode 100644 index 0000000000..c7f27f6ae1 --- /dev/null +++ b/Task/Palindrome-detection/CoffeeScript/palindrome-detection-1.coffeescript @@ -0,0 +1,3 @@ +isPalindrome = (str) -> + stripped = str.toLowerCase().replace /\W/g, "" + stripped == (stripped.split "").reverse().join "" diff --git a/Task/Palindrome-detection/CoffeeScript/palindrome-detection-2.coffeescript b/Task/Palindrome-detection/CoffeeScript/palindrome-detection-2.coffeescript new file mode 100644 index 0000000000..9a32fbb1ad --- /dev/null +++ b/Task/Palindrome-detection/CoffeeScript/palindrome-detection-2.coffeescript @@ -0,0 +1,7 @@ +strings = [ + "In girum imus nocte et consumimur igni" + "A man, a plan, a canal: Panama!" + "There is no spoon." +] + +console.log "'#{str}' : #{isPalindrome str}" for str in strings diff --git a/Task/Palindrome-detection/Common-Lisp/palindrome-detection.lisp b/Task/Palindrome-detection/Common-Lisp/palindrome-detection.lisp new file mode 100644 index 0000000000..30e5283b66 --- /dev/null +++ b/Task/Palindrome-detection/Common-Lisp/palindrome-detection.lisp @@ -0,0 +1,2 @@ +(defun palindrome-p (s) + (string= s (reverse s))) diff --git a/Task/Palindrome-detection/D/palindrome-detection-1.d b/Task/Palindrome-detection/D/palindrome-detection-1.d new file mode 100644 index 0000000000..88c120a307 --- /dev/null +++ b/Task/Palindrome-detection/D/palindrome-detection-1.d @@ -0,0 +1,22 @@ +import std.traits, std.algorithm; + +bool isPalindrome1(C)(in C[] s) pure /*nothrow*/ +if (isSomeChar!C) { + auto s2 = s.dup; // not nothrow + s2.reverse(); // works on Unicode too, not nothrow + return s == s2; +} + +void main() { + alias isPalindrome1 pali; + assert(pali("")); + assert(pali("z")); + assert(pali("aha")); + assert(pali("sees")); + assert(!pali("oofoe")); + assert(pali("deified")); + assert(!pali("Deified")); + assert(pali("amanaplanacanalpanama")); + assert(pali("ingirumimusnocteetconsumimurigni")); + assert(pali("salàlas")); +} diff --git a/Task/Palindrome-detection/D/palindrome-detection-2.d b/Task/Palindrome-detection/D/palindrome-detection-2.d new file mode 100644 index 0000000000..d380116509 --- /dev/null +++ b/Task/Palindrome-detection/D/palindrome-detection-2.d @@ -0,0 +1,26 @@ +import std.traits; + +bool isPalindrome2(C)(in C[] s) pure if (isSomeChar!C) { + dchar[] dstr; + foreach (dchar c; s) // not nothrow + dstr ~= c; + + for (int i; i < dstr.length / 2; i++) + if (dstr[i] != dstr[$ - i - 1]) + return false; + return true; +} + +void main() { + alias isPalindrome2 pali; + assert(pali("")); + assert(pali("z")); + assert(pali("aha")); + assert(pali("sees")); + assert(!pali("oofoe")); + assert(pali("deified")); + assert(!pali("Deified")); + assert(pali("amanaplanacanalpanama")); + assert(pali("ingirumimusnocteetconsumimurigni")); + assert(pali("salàlas")); +} diff --git a/Task/Palindrome-detection/D/palindrome-detection-3.d b/Task/Palindrome-detection/D/palindrome-detection-3.d new file mode 100644 index 0000000000..cdfc34a347 --- /dev/null +++ b/Task/Palindrome-detection/D/palindrome-detection-3.d @@ -0,0 +1,39 @@ +import std.stdio, core.exception, std.traits; + +// assume alloca() to be pure for this program +extern(C) pure nothrow void* alloca(in size_t size); + +bool isPalindrome3(C)(in C[] s) pure if (isSomeChar!C) { + auto p = cast(dchar*)alloca(s.length * 4); + if (p == null) + // no fallback heap allocation used + throw new OutOfMemoryError(); + dchar[] dstr = p[0 .. s.length]; + + // use std.utf.stride for an even lower level version + int i = 0; + foreach (dchar c; s) { // not nothrow + dstr[i] = c; + i++; + } + dstr = dstr[0 .. i]; + + foreach (j; 0 .. dstr.length / 2) + if (dstr[j] != dstr[$ - j - 1]) + return false; + return true; +} + +void main() { + alias isPalindrome3 pali; + assert(pali("")); + assert(pali("z")); + assert(pali("aha")); + assert(pali("sees")); + assert(!pali("oofoe")); + assert(pali("deified")); + assert(!pali("Deified")); + assert(pali("amanaplanacanalpanama")); + assert(pali("ingirumimusnocteetconsumimurigni")); + assert(pali("salàlas")); +} diff --git a/Task/Palindrome-detection/D/palindrome-detection-4.d b/Task/Palindrome-detection/D/palindrome-detection-4.d new file mode 100644 index 0000000000..99d62f468b --- /dev/null +++ b/Task/Palindrome-detection/D/palindrome-detection-4.d @@ -0,0 +1,23 @@ +bool isPalindrome4(in string str) pure nothrow { + if (str.length == 0) return true; + immutable(char)* s = str.ptr; + immutable(char)* t = &(str[$ - 1]); + while (s < t) + if (*s++ != *t--) // ugly + return false; + return true; +} + +void main() { + alias isPalindrome4 pali; + assert(pali("")); + assert(pali("z")); + assert(pali("aha")); + assert(pali("sees")); + assert(!pali("oofoe")); + assert(pali("deified")); + assert(!pali("Deified")); + assert(pali("amanaplanacanalpanama")); + assert(pali("ingirumimusnocteetconsumimurigni")); + //assert(pali("salàlas")); +} diff --git a/Task/Palindrome-detection/Delphi/palindrome-detection.delphi b/Task/Palindrome-detection/Delphi/palindrome-detection.delphi new file mode 100644 index 0000000000..2b575bf1a3 --- /dev/null +++ b/Task/Palindrome-detection/Delphi/palindrome-detection.delphi @@ -0,0 +1,7 @@ +uses + SysUtils, StrUtils; + +function IsPalindrome(const aSrcString: string): Boolean; +begin + Result := SameText(aSrcString, ReverseString(aSrcString)); +end; diff --git a/Task/Palindrome-detection/E/palindrome-detection.e b/Task/Palindrome-detection/E/palindrome-detection.e new file mode 100644 index 0000000000..9161b0614c --- /dev/null +++ b/Task/Palindrome-detection/E/palindrome-detection.e @@ -0,0 +1,8 @@ +def isPalindrome(string :String) { + def upper := string.toUpperCase() + def last := upper.size() - 1 + for i => c ? (upper[last - i] != c) in upper(0, upper.size() // 2) { + return false + } + return true +} diff --git a/Task/Palindrome-detection/Ela/palindrome-detection-1.ela b/Task/Palindrome-detection/Ela/palindrome-detection-1.ela new file mode 100644 index 0000000000..c4076aee14 --- /dev/null +++ b/Task/Palindrome-detection/Ela/palindrome-detection-1.ela @@ -0,0 +1,4 @@ +open list string + +isPalindrome xs = xs == reverse xs +isPalindrome <| string.toList "ingirumimusnocteetconsumimurigni" diff --git a/Task/Palindrome-detection/Ela/palindrome-detection-2.ela b/Task/Palindrome-detection/Ela/palindrome-detection-2.ela new file mode 100644 index 0000000000..5d52b66684 --- /dev/null +++ b/Task/Palindrome-detection/Ela/palindrome-detection-2.ela @@ -0,0 +1,4 @@ +reverse = foldl (flip (::)) (nil xs) + +foldl f z (x::xs) = foldl f (f z x) xs +foldl _ z [] = z diff --git a/Task/Palindrome-detection/Erlang/palindrome-detection.erl b/Task/Palindrome-detection/Erlang/palindrome-detection.erl new file mode 100644 index 0000000000..61e87de4e1 --- /dev/null +++ b/Task/Palindrome-detection/Erlang/palindrome-detection.erl @@ -0,0 +1,2 @@ +is_palindrome(String) -> + String == lists:reverse(String). diff --git a/Task/Palindrome-detection/Euphoria/palindrome-detection.euphoria b/Task/Palindrome-detection/Euphoria/palindrome-detection.euphoria new file mode 100644 index 0000000000..4c65a2e9d0 --- /dev/null +++ b/Task/Palindrome-detection/Euphoria/palindrome-detection.euphoria @@ -0,0 +1,8 @@ +function isPalindrome(sequence s) + for i = 1 to length(s)/2 do + if s[i] != s[$-i+1] then + return 0 + end if + end for + return 1 +end function diff --git a/Task/Palindrome-detection/Factor/palindrome-detection.factor b/Task/Palindrome-detection/Factor/palindrome-detection.factor new file mode 100644 index 0000000000..420f2a92fc --- /dev/null +++ b/Task/Palindrome-detection/Factor/palindrome-detection.factor @@ -0,0 +1,2 @@ +USING: kernel sequences ; +: palindrome? ( str -- ? ) dup reverse = ; diff --git a/Task/Palindrome-detection/Fantom/palindrome-detection.fantom b/Task/Palindrome-detection/Fantom/palindrome-detection.fantom new file mode 100644 index 0000000000..9fd7cb379e --- /dev/null +++ b/Task/Palindrome-detection/Fantom/palindrome-detection.fantom @@ -0,0 +1,20 @@ +class Palindrome +{ + // Function to test if given string is a palindrome + public static Bool isPalindrome (Str str) + { + str == str.reverse + } + + // Give it a test run + public static Void main () + { + echo (isPalindrome("")) + echo (isPalindrome("a")) + echo (isPalindrome("aa")) + echo (isPalindrome("aba")) + echo (isPalindrome("abb")) + echo (isPalindrome("salàlas")) + echo (isPalindrome("In girum imus nocte et consumimur igni".lower.replace(" ",""))) + } +} diff --git a/Task/Palindrome-detection/Forth/palindrome-detection.fth b/Task/Palindrome-detection/Forth/palindrome-detection.fth new file mode 100644 index 0000000000..d5d7614232 --- /dev/null +++ b/Task/Palindrome-detection/Forth/palindrome-detection.fth @@ -0,0 +1,8 @@ +: first over c@ ; +: last >r 2dup + 1- c@ r> swap ; +: palindrome? ( c-addr u -- f ) + begin + dup 1 <= if 2drop true exit then + first last <> if 2drop false exit then + 1 /string 1- + again ; diff --git a/Task/Palindrome-detection/Fortran/palindrome-detection-1.f b/Task/Palindrome-detection/Fortran/palindrome-detection-1.f new file mode 100644 index 0000000000..2221a9e2e4 --- /dev/null +++ b/Task/Palindrome-detection/Fortran/palindrome-detection-1.f @@ -0,0 +1,14 @@ +program palindro + + implicit none + + character(len=*), parameter :: p = "ingirumimusnocteetconsumimurigni" + + print *, is_palindro_r(p) + print *, is_palindro_r("anothertest") + print *, is_palindro2(p) + print *, is_palindro2("test") + print *, is_palindro(p) + print *, is_palindro("last test") + +contains diff --git a/Task/Palindrome-detection/Fortran/palindrome-detection-2.f b/Task/Palindrome-detection/Fortran/palindrome-detection-2.f new file mode 100644 index 0000000000..648762715d --- /dev/null +++ b/Task/Palindrome-detection/Fortran/palindrome-detection-2.f @@ -0,0 +1,26 @@ +! non-recursive +function is_palindro(t) + logical :: is_palindro + character(len=*), intent(in) :: t + + integer :: i, l + + l = len(t) + is_palindro = .false. + do i=1, l/2 + if ( t(i:i) /= t(l-i+1:l-i+1) ) return + end do + is_palindro = .true. +end function is_palindro + +! non-recursive 2 +function is_palindro2(t) result(isp) + logical :: isp + character(len=*), intent(in) :: t + + character(len=len(t)) :: s + integer :: i + + forall(i=1:len(t)) s(len(t)-i+1:len(t)-i+1) = t(i:i) + isp = ( s == t ) +end function is_palindro2 diff --git a/Task/Palindrome-detection/Fortran/palindrome-detection-3.f b/Task/Palindrome-detection/Fortran/palindrome-detection-3.f new file mode 100644 index 0000000000..e89871930e --- /dev/null +++ b/Task/Palindrome-detection/Fortran/palindrome-detection-3.f @@ -0,0 +1,9 @@ + recursive function is_palindro_r (t) result (isp) + + implicit none + character (*), intent (in) :: t + logical :: isp + + isp = len (t) == 0 .or. t (: 1) == t (len (t) :) .and. is_palindro_r (t (2 : len (t) - 1)) + + end function is_palindro_r diff --git a/Task/Palindrome-detection/Fortran/palindrome-detection-4.f b/Task/Palindrome-detection/Fortran/palindrome-detection-4.f new file mode 100644 index 0000000000..f20b03c084 --- /dev/null +++ b/Task/Palindrome-detection/Fortran/palindrome-detection-4.f @@ -0,0 +1 @@ +end program palindro diff --git a/Task/Palindrome-detection/GAP/palindrome-detection.gap b/Task/Palindrome-detection/GAP/palindrome-detection.gap new file mode 100644 index 0000000000..90f9c34ef7 --- /dev/null +++ b/Task/Palindrome-detection/GAP/palindrome-detection.gap @@ -0,0 +1,27 @@ +ZapGremlins := function(s) + local upper, lower, c, i, n, t; + upper := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + lower := "abcdefghijklmnopqrstuvwxyz"; + t := [ ]; + i := 1; + for c in s do + n := Position(upper, c); + if n <> fail then + t[i] := lower[n]; + i := i + 1; + else + n := Position(lower, c); + if n <> fail then + t[i] := c; + i := i + 1; + fi; + fi; + od; + return t; +end; + +IsPalindrome := function(s) + local t; + t := ZapGremlins(s); + return t = Reversed(t); +end; diff --git a/Task/Palindrome-detection/GML/palindrome-detection.gml b/Task/Palindrome-detection/GML/palindrome-detection.gml new file mode 100644 index 0000000000..08a6d0115c --- /dev/null +++ b/Task/Palindrome-detection/GML/palindrome-detection.gml @@ -0,0 +1,13 @@ +//Setting a var from an argument passed to the script +str=argument0 +//Takes out all spaces/anything that is not a letter or a number and turns uppercase letters to lowercase +str=string_lettersdigits(string_lower(string_replace(str,' ',''))); +inv=''; +//for loop that reverses the sequence +for (i=0;i + s == s?.reverse() +} diff --git a/Task/Palindrome-detection/Groovy/palindrome-detection-2.groovy b/Task/Palindrome-detection/Groovy/palindrome-detection-2.groovy new file mode 100644 index 0000000000..37bbc8299a --- /dev/null +++ b/Task/Palindrome-detection/Groovy/palindrome-detection-2.groovy @@ -0,0 +1,5 @@ +println isPalindrome("") +println isPalindrome("a") +println isPalindrome("abcdefgfedcba") +println isPalindrome("abcdeffedcba") +println isPalindrome("abcedfgfedcb") diff --git a/Task/Palindrome-detection/Groovy/palindrome-detection-3.groovy b/Task/Palindrome-detection/Groovy/palindrome-detection-3.groovy new file mode 100644 index 0000000000..46185faa11 --- /dev/null +++ b/Task/Palindrome-detection/Groovy/palindrome-detection-3.groovy @@ -0,0 +1,4 @@ +def isPalindrome = { String s -> + def n = s.size() + n < 2 || s[0.. + def n = s.size() + n < 2 || (s[0] == s[n-1] && isPalindrome(s[1..<(n-1)])) +} diff --git a/Task/Palindrome-detection/Haskell/palindrome-detection-1.hs b/Task/Palindrome-detection/Haskell/palindrome-detection-1.hs new file mode 100644 index 0000000000..87f3c48748 --- /dev/null +++ b/Task/Palindrome-detection/Haskell/palindrome-detection-1.hs @@ -0,0 +1 @@ +is_palindrome x = x == reverse x diff --git a/Task/Palindrome-detection/Haskell/palindrome-detection-2.hs b/Task/Palindrome-detection/Haskell/palindrome-detection-2.hs new file mode 100644 index 0000000000..32fb6b472c --- /dev/null +++ b/Task/Palindrome-detection/Haskell/palindrome-detection-2.hs @@ -0,0 +1,3 @@ +is_palindrome_r x | length x <= 1 = True + | head x == last x = is_palindrome_r . tail. init $ x + | otherwise = False diff --git a/Task/Palindrome-detection/HicEst/palindrome-detection.hicest b/Task/Palindrome-detection/HicEst/palindrome-detection.hicest new file mode 100644 index 0000000000..5cabb91a27 --- /dev/null +++ b/Task/Palindrome-detection/HicEst/palindrome-detection.hicest @@ -0,0 +1,17 @@ + result = Palindrome( "In girum imus nocte et consumimur igni" ) ! returns 1 +END + +FUNCTION Palindrome(string) + CHARACTER string, CopyOfString + + L = LEN(string) + ALLOCATE(CopyOfString, L) + CopyOfString = string + EDIT(Text=CopyOfString, UpperCase=L) + L = L - EDIT(Text=CopyOfString, End, Left=' ', Delete, DO=L) ! EDIT returns number of deleted spaces + + DO i = 1, L/2 + Palindrome = CopyOfString(i) == CopyOfString(L - i + 1) + IF( Palindrome == 0 ) RETURN + ENDDO +END diff --git a/Task/Palindrome-detection/Icon/palindrome-detection-1.icon b/Task/Palindrome-detection/Icon/palindrome-detection-1.icon new file mode 100644 index 0000000000..7b21d62cad --- /dev/null +++ b/Task/Palindrome-detection/Icon/palindrome-detection-1.icon @@ -0,0 +1,3 @@ +procedure main(arglist) +every writes(s := !arglist) do write( if palindrome(s) then " is " else " is not", " a palindrome.") +end diff --git a/Task/Palindrome-detection/Icon/palindrome-detection-2.icon b/Task/Palindrome-detection/Icon/palindrome-detection-2.icon new file mode 100644 index 0000000000..fee4d0b81f --- /dev/null +++ b/Task/Palindrome-detection/Icon/palindrome-detection-2.icon @@ -0,0 +1,3 @@ +procedure palindrome(s) #: return s if s is a palindrome +return s == reverse(s) +end diff --git a/Task/Palindrome-detection/Icon/palindrome-detection-3.icon b/Task/Palindrome-detection/Icon/palindrome-detection-3.icon new file mode 100644 index 0000000000..914ca63b6b --- /dev/null +++ b/Task/Palindrome-detection/Icon/palindrome-detection-3.icon @@ -0,0 +1,5 @@ +procedure palindrome(x) #: return x if s is x palindrome +local i +every if x[i := 1 to (*x+ 1)/2] ~== x[-i] then fail +return x +end diff --git a/Task/Palindrome-detection/Ioke/palindrome-detection.ioke b/Task/Palindrome-detection/Ioke/palindrome-detection.ioke new file mode 100644 index 0000000000..8058daec18 --- /dev/null +++ b/Task/Palindrome-detection/Ioke/palindrome-detection.ioke @@ -0,0 +1 @@ +Text isPalindrome? = method(self chars == self chars reverse) diff --git a/Task/Palindrome-detection/J/palindrome-detection-1.j b/Task/Palindrome-detection/J/palindrome-detection-1.j new file mode 100644 index 0000000000..33cb6febf2 --- /dev/null +++ b/Task/Palindrome-detection/J/palindrome-detection-1.j @@ -0,0 +1 @@ +isPalin0=: -: |. diff --git a/Task/Palindrome-detection/J/palindrome-detection-2.j b/Task/Palindrome-detection/J/palindrome-detection-2.j new file mode 100644 index 0000000000..76f0ba371b --- /dev/null +++ b/Task/Palindrome-detection/J/palindrome-detection-2.j @@ -0,0 +1,4 @@ + isPalin0 'ABBA' +1 + isPalin0 -.&' ' tolower 'In girum imus nocte et consumimur igni' +1 diff --git a/Task/Palindrome-detection/J/palindrome-detection-3.j b/Task/Palindrome-detection/J/palindrome-detection-3.j new file mode 100644 index 0000000000..12b980a3df --- /dev/null +++ b/Task/Palindrome-detection/J/palindrome-detection-3.j @@ -0,0 +1,6 @@ +isPalin1=: 0:`($:@(}.@}:))@.({.={:)`1:@.(1>:#) + +isPalin2=: monad define + if. 1>:#y do. 1 return. end. + if. ({.={:)y do. isPalin2 }.}:y else. 0 end. +) diff --git a/Task/Palindrome-detection/J/palindrome-detection-4.j b/Task/Palindrome-detection/J/palindrome-detection-4.j new file mode 100644 index 0000000000..0ab78f3f7c --- /dev/null +++ b/Task/Palindrome-detection/J/palindrome-detection-4.j @@ -0,0 +1,12 @@ + foo=: foo,|.foo=:2000$a. + ts=:6!:2,7!:2 NB. time and space required to execute sentence + ts 'isPalin0 foo' +2.73778e_5 5184 + ts 'isPalin1 foo' +0.0306667 6.0368e6 + ts 'isPalin2 foo' +0.104391 1.37965e7 + 'isPalin1 foo' %&ts 'isPalin0 foo' +1599.09 1164.23 + 'isPalin2 foo' %&ts 'isPalin0 foo' +3967.53 2627.04 diff --git a/Task/Palindrome-detection/Java/palindrome-detection-1.java b/Task/Palindrome-detection/Java/palindrome-detection-1.java new file mode 100644 index 0000000000..36f63aec7e --- /dev/null +++ b/Task/Palindrome-detection/Java/palindrome-detection-1.java @@ -0,0 +1,4 @@ +public static boolean pali(String testMe){ + StringBuilder sb = new StringBuilder(testMe); + return testMe.equalsIgnoreCase(sb.reverse().toString()); +} diff --git a/Task/Palindrome-detection/Java/palindrome-detection-2.java b/Task/Palindrome-detection/Java/palindrome-detection-2.java new file mode 100644 index 0000000000..7b65261384 --- /dev/null +++ b/Task/Palindrome-detection/Java/palindrome-detection-2.java @@ -0,0 +1,9 @@ +public static boolean rPali(String testMe){ + if(testMe.length()<=1){ + return true; + } + if(!(testMe.charAt(0)+"").equalsIgnoreCase(testMe.charAt(testMe.length()-1)+"")){ + return false; + } + return rPali(testMe.substring(1, testMe.length()-1)); +} diff --git a/Task/Palindrome-detection/Java/palindrome-detection-3.java b/Task/Palindrome-detection/Java/palindrome-detection-3.java new file mode 100644 index 0000000000..7c52cbb7e1 --- /dev/null +++ b/Task/Palindrome-detection/Java/palindrome-detection-3.java @@ -0,0 +1,3 @@ +public static boolean pali(String testMe){ + return testMe.matches("|(?:(.)(?<=(?=^.*?(\\1\\2?)$).*))+(?<=(?=^\\2$).*)"); +} diff --git a/Task/Palindrome-detection/JavaScript/palindrome-detection-1.js b/Task/Palindrome-detection/JavaScript/palindrome-detection-1.js new file mode 100644 index 0000000000..2333520a1c --- /dev/null +++ b/Task/Palindrome-detection/JavaScript/palindrome-detection-1.js @@ -0,0 +1,5 @@ +String.prototype.reverse = function(){ return this.split("").reverse().join(""); } + +function palindrome(str) { return str == str.reverse(); } + +alert(palindrome("ingirumimusnocteetconsumimurigni")); diff --git a/Task/Palindrome-detection/JavaScript/palindrome-detection-2.js b/Task/Palindrome-detection/JavaScript/palindrome-detection-2.js new file mode 100644 index 0000000000..36c29a353d --- /dev/null +++ b/Task/Palindrome-detection/JavaScript/palindrome-detection-2.js @@ -0,0 +1,15 @@ +String.prototype.reverse = function () { + return this.split('').reverse().join(''); +}; + +String.prototype.isPalindrome = function () { + var s = this.toLowerCase().replace(/[^a-z]/g, ''); + return (s.reverse() === s); +}; + +('A man, a plan, a canoe, pasta, heros, rajahs, ' + +'a coloratura, maps, snipe, percale, macaroni, ' + +'a gag, a banana bag, a tan, a tag, ' + +'a banana bag again (or a camel), a crepe, pins, ' + +'Spam, a rut, a Rolo, cash, a jar, sore hats, ' + +'a peon, a canal – Panama!').isPalindrome(); diff --git a/Task/Palindrome-detection/Liberty-BASIC/palindrome-detection.liberty b/Task/Palindrome-detection/Liberty-BASIC/palindrome-detection.liberty new file mode 100644 index 0000000000..cb2a660453 --- /dev/null +++ b/Task/Palindrome-detection/Liberty-BASIC/palindrome-detection.liberty @@ -0,0 +1,22 @@ +Print isPalindrome("In girum imus nocte et consumimur igni") +Print isPalindrome("atta") + +Function isPalindrome(string$) + string$ = Lower$(removeSpaces$(string$)) + reverseString$ = reverseString$(string$) + If string$ = reverseString$ Then isPalindrome = 1 +End Function + +Function reverseString$(string$) + For i = Len(string$) To 1 Step -1 + reverseString$ = reverseString$ + Mid$(string$, i, 1) + Next i +End Function + +Function removeSpaces$(string$) + For i = 1 To Len(string$) + If Mid$(string$, i, 1) <> " " Then + removeSpaces$ = removeSpaces$ + Mid$(string$, i, 1) + End If + Next i +End Function diff --git a/Task/Palindrome-detection/Logo/palindrome-detection.logo b/Task/Palindrome-detection/Logo/palindrome-detection.logo new file mode 100644 index 0000000000..057dab9403 --- /dev/null +++ b/Task/Palindrome-detection/Logo/palindrome-detection.logo @@ -0,0 +1,3 @@ +to palindrome? :w + output equal? :w reverse :w +end diff --git a/Task/Palindrome-detection/Lua/palindrome-detection.lua b/Task/Palindrome-detection/Lua/palindrome-detection.lua new file mode 100644 index 0000000000..d9e4877be6 --- /dev/null +++ b/Task/Palindrome-detection/Lua/palindrome-detection.lua @@ -0,0 +1 @@ +function ispalindrome(s) return s == string.reverse(s) end diff --git a/Task/Palindrome-detection/M4/palindrome-detection-1.m4 b/Task/Palindrome-detection/M4/palindrome-detection-1.m4 new file mode 100644 index 0000000000..a408e226f3 --- /dev/null +++ b/Task/Palindrome-detection/M4/palindrome-detection-1.m4 @@ -0,0 +1,3 @@ +define(`palindrorev',`ifelse(`$1',invert(`$1'),`yes',`no')')dnl +palindrorev(`ingirumimusnocteetconsumimurigni') +palindrorev(`this is not palindrome') diff --git a/Task/Palindrome-detection/M4/palindrome-detection-2.m4 b/Task/Palindrome-detection/M4/palindrome-detection-2.m4 new file mode 100644 index 0000000000..a51ee45120 --- /dev/null +++ b/Task/Palindrome-detection/M4/palindrome-detection-2.m4 @@ -0,0 +1,7 @@ +define(`striptwo',`substr(`$1',1,eval(len(`$1')-2))')dnl +define(`cmplast',`ifelse(`striptwo(`$1')',,`yes',dnl +substr(`$1',0,1),substr(`$1',eval(len(`$1')-1),1),`yes',`no')')dnl +define(`palindro',`dnl +ifelse(eval(len(`$1')<1),1,`yes',cmplast(`$1'),`yes',`palindro(striptwo(`$1'))',`no')')dnl +palindro(`ingirumimusnocteetconsumimurigni') +palindro(`this is not palindrome') diff --git a/Task/Palindrome-detection/MATLAB/palindrome-detection-1.m b/Task/Palindrome-detection/MATLAB/palindrome-detection-1.m new file mode 100644 index 0000000000..05cdbb1597 --- /dev/null +++ b/Task/Palindrome-detection/MATLAB/palindrome-detection-1.m @@ -0,0 +1,15 @@ +function trueFalse = isPalindrome(string) + + trueFalse = all(string == fliplr(string)); %See if flipping the string produces the original string + + if not(trueFalse) %If not a palindrome + string = lower(string); %Lower case everything + trueFalse = all(string == fliplr(string)); %Test again + end + + if not(trueFalse) %If still not a palindrome + string(isspace(string)) = []; %Strip all space characters out + trueFalse = all(string == fliplr(string)); %Test one last time + end + +end diff --git a/Task/Palindrome-detection/MATLAB/palindrome-detection-2.m b/Task/Palindrome-detection/MATLAB/palindrome-detection-2.m new file mode 100644 index 0000000000..f4c8322761 --- /dev/null +++ b/Task/Palindrome-detection/MATLAB/palindrome-detection-2.m @@ -0,0 +1,5 @@ +>> isPalindrome('In girum imus nocte et consumimur igni') + +ans = + + 1 diff --git a/Task/Palindrome-detection/MAXScript/palindrome-detection-1.maxscript b/Task/Palindrome-detection/MAXScript/palindrome-detection-1.maxscript new file mode 100644 index 0000000000..d8b906f233 --- /dev/null +++ b/Task/Palindrome-detection/MAXScript/palindrome-detection-1.maxscript @@ -0,0 +1,6 @@ +fn isPalindrome s = +( + local reversed = "" + for i in s.count to 1 by -1 do reversed += s[i] + return reversed == s +) diff --git a/Task/Palindrome-detection/MAXScript/palindrome-detection-2.maxscript b/Task/Palindrome-detection/MAXScript/palindrome-detection-2.maxscript new file mode 100644 index 0000000000..b29b7ff90c --- /dev/null +++ b/Task/Palindrome-detection/MAXScript/palindrome-detection-2.maxscript @@ -0,0 +1,15 @@ +fn isPalindrome_r s = +( + if s.count <= 1 then + ( + true + ) + else + ( + if s[1] != s[s.count] then + ( + return false + ) + isPalindrome_r (substring s 2 (s.count-2)) + ) +) diff --git a/Task/Palindrome-detection/MAXScript/palindrome-detection-3.maxscript b/Task/Palindrome-detection/MAXScript/palindrome-detection-3.maxscript new file mode 100644 index 0000000000..3bf503ff43 --- /dev/null +++ b/Task/Palindrome-detection/MAXScript/palindrome-detection-3.maxscript @@ -0,0 +1,3 @@ +local p = "ingirumimusnocteetconsumimurigni" +format ("'%' is a palindrome? %\n") p (isPalindrome p) +format ("'%' is a palindrome? %\n") p (isPalindrome_r p) diff --git a/Task/Palindrome-detection/MMIX/palindrome-detection.mmix b/Task/Palindrome-detection/MMIX/palindrome-detection.mmix new file mode 100644 index 0000000000..d4cae2719b --- /dev/null +++ b/Task/Palindrome-detection/MMIX/palindrome-detection.mmix @@ -0,0 +1,68 @@ +argc IS $0 +argv IS $1 + + LOC Data_Segment +DataSeg GREG @ + + LOC @+1000 +ItsPalStr IS @-Data_Segment + BYTE "It's palindrome",10,0 + LOC @+(8-@)&7 +NoPalStr IS @-Data_Segment + BYTE "It is not palindrome",10,0 + + LOC #100 + GREG @ +% input: $255 points to where the string to be checked is +% returns $255 0 if not palindrome, not zero otherwise +% trashs: $0,$1,$2,$3 +% return address $4 +DetectPalindrome LOC @ + ADDU $1,$255,0 % $1 = $255 +2H LDB $0,$1,0 % get byte at $1 + BZ $0,1F % if zero, end (length) + INCL $1,1 % $1++ + JMP 2B % loop +1H SUBU $1,$1,1 % ptr last char of string + ADDU $0,DataSeg,0 % $0 to data seg. +3H CMP $3,$1,$255 % is $0 == $255? + BZ $3,4F % then jump + LDB $3,$1,0 % otherwise get the byte + STB $3,$0,0 % and copy it + INCL $0,1 % $0++ + SUB $1,$1,1 % $1-- + JMP 3B +4H LDB $3,$1,0 + STB $3,$0,0 % copy the last byte +% now let us compare reversed string and straight string + XOR $0,$0,$0 % index + ADDU $1,DataSeg,0 +6H LDB $2,$1,$0 % pick char from rev str + LDB $3,$255,$0 % pick char from straight str + BZ $3,PaliOk % finished as palindrome + CMP $2,$2,$3 % == ? + BNZ $2,5F % if not, exit + INCL $0,1 % $0++ + JMP 6B +5H XOR $255,$255,$255 + GO $4,$4,0 % return false +PaliOk NEG $255,0,1 + GO $4,$4,0 % return true + +% The Main for testing the function +% run from the command line +% $ mmix ./palindrome.mmo ingirumimusnocteetconsumimurigni +Main CMP argc,argc,2 % argc > 2? + BN argc,3F % no -> not enough arg + ADDU $1,$1,8 % argv+1 + LDOU $255,$1,0 % argv[1] + GO $4,DetectPalindrome + BZ $255,2F % if not palindrome, jmp + SETL $0,ItsPalStr % pal string + ADDU $255,DataSeg,$0 + JMP 1F +2H SETL $0,NoPalStr % no pal string + ADDU $255,DataSeg,$0 +1H TRAP 0,Fputs,StdOut % print +3H XOR $255,$255,$255 + TRAP 0,Halt,0 % exit(0) diff --git a/Task/Palindrome-detection/Mathematica/palindrome-detection.math b/Task/Palindrome-detection/Mathematica/palindrome-detection.math new file mode 100644 index 0000000000..fb8a44d34d --- /dev/null +++ b/Task/Palindrome-detection/Mathematica/palindrome-detection.math @@ -0,0 +1 @@ +PalindromeQ[i_String] := StringReverse[i] == i diff --git a/Task/Palindrome-detection/Maxima/palindrome-detection.maxima b/Task/Palindrome-detection/Maxima/palindrome-detection.maxima new file mode 100644 index 0000000000..6c0d0f5743 --- /dev/null +++ b/Task/Palindrome-detection/Maxima/palindrome-detection.maxima @@ -0,0 +1,3 @@ +palindromep(s) := block([t], t: sremove(" ", sdowncase(s)), sequal(t, sreverse(t)))$ + +palindromep("Sator arepo tenet opera rotas"); /* true */ diff --git a/Task/Palindrome-detection/Mirah/palindrome-detection.mirah b/Task/Palindrome-detection/Mirah/palindrome-detection.mirah new file mode 100644 index 0000000000..c454d8b7ae --- /dev/null +++ b/Task/Palindrome-detection/Mirah/palindrome-detection.mirah @@ -0,0 +1,12 @@ +def reverse(s:string) + StringBuilder.new(s).reverse.toString() +end + +def palindrome?(s:string) + s.equals(reverse(s)) +end + +puts palindrome?("anna") # ==> true +puts palindrome?("Erik") # ==> false +puts palindrome?("palindroom-moordnilap") # ==> true +puts nil # ==> null diff --git a/Task/Palindrome-detection/Modula-3/palindrome-detection.mod3 b/Task/Palindrome-detection/Modula-3/palindrome-detection.mod3 new file mode 100644 index 0000000000..1eb9a36093 --- /dev/null +++ b/Task/Palindrome-detection/Modula-3/palindrome-detection.mod3 @@ -0,0 +1,15 @@ +MODULE Palindrome; + +IMPORT Text; + +PROCEDURE isPalindrome(string: TEXT): BOOLEAN = + VAR len := Text.Length(string); + BEGIN + FOR i := 0 TO len DIV 2 - 1 DO + IF Text.GetChar(string, i) # Text.GetChar(string, (len - i - 1)) THEN + RETURN FALSE; + END; + END; + RETURN TRUE; + END isPalindrome; +END Palindrome. diff --git a/Task/Palindrome-detection/Nemerle/palindrome-detection-1.nemerle b/Task/Palindrome-detection/Nemerle/palindrome-detection-1.nemerle new file mode 100644 index 0000000000..c4832f7ea2 --- /dev/null +++ b/Task/Palindrome-detection/Nemerle/palindrome-detection-1.nemerle @@ -0,0 +1,16 @@ +using System; +using System.Console; +using Nemerle.Utility.NString; //contains methods Explode() and Implode() which convert string -> list[char] and back + +module Palindrome +{ + IsPalindrome( text : string) : bool + { + Implode(Explode(text).Reverse()) == text; + } + + Main() : void + { + WriteLine("radar is a palindrome: {0}", IsPalindrome("radar")); + } +} diff --git a/Task/Palindrome-detection/Nemerle/palindrome-detection-2.nemerle b/Task/Palindrome-detection/Nemerle/palindrome-detection-2.nemerle new file mode 100644 index 0000000000..69d7932ffe --- /dev/null +++ b/Task/Palindrome-detection/Nemerle/palindrome-detection-2.nemerle @@ -0,0 +1,5 @@ +Clean( text : string ) : string +{ + def sepchars = Explode(",.;:-?!()' "); + Concat( "", Split(text, sepchars)).ToLower() +} diff --git a/Task/Palindrome-detection/NetRexx/palindrome-detection.netrexx b/Task/Palindrome-detection/NetRexx/palindrome-detection.netrexx new file mode 100644 index 0000000000..5465dd390d --- /dev/null +++ b/Task/Palindrome-detection/NetRexx/palindrome-detection.netrexx @@ -0,0 +1,16 @@ +y='In girum imus nocte et consumimur igni' + +-- translation: We walk around in the night and +-- we are burnt by the fire (of love) +say +say 'string = 'y +say + +pal=isPal(y) + +if pal==0 then say "The string isn't palindromic." + else say 'The string is palindromic.' + +method isPal(x) static + x=x.upper().space(0) /* removes all blanks (spaces). */ + return x==x.reverse() /* returns 1 if exactly equal, */ diff --git a/Task/Palindrome-detection/OCaml/palindrome-detection-1.ocaml b/Task/Palindrome-detection/OCaml/palindrome-detection-1.ocaml new file mode 100644 index 0000000000..b54b038ce6 --- /dev/null +++ b/Task/Palindrome-detection/OCaml/palindrome-detection-1.ocaml @@ -0,0 +1,10 @@ +let is_palindrome str = + let last = String.length str - 1 in + try + for i = 0 to last / 2 do + let j = last - i in + if str.[i] <> str.[j] then raise Exit + done; + (true) + with Exit -> + (false) diff --git a/Task/Palindrome-detection/OCaml/palindrome-detection-2.ocaml b/Task/Palindrome-detection/OCaml/palindrome-detection-2.ocaml new file mode 100644 index 0000000000..0ee848531b --- /dev/null +++ b/Task/Palindrome-detection/OCaml/palindrome-detection-2.ocaml @@ -0,0 +1,14 @@ +let rem_space str = + let len = String.length str in + let res = String.create len in + let rec aux i j = + if i >= len + then (String.sub res 0 j) + else match str.[i] with + | ' ' | '\n' | '\t' | '\r' -> + aux (i+1) (j) + | _ -> + res.[j] <- str.[i]; + aux (i+1) (j+1) + in + aux 0 0 diff --git a/Task/Palindrome-detection/Objeck/palindrome-detection.objeck b/Task/Palindrome-detection/Objeck/palindrome-detection.objeck new file mode 100644 index 0000000000..72f3416560 --- /dev/null +++ b/Task/Palindrome-detection/Objeck/palindrome-detection.objeck @@ -0,0 +1,20 @@ +bundle Default { + class Test { + function : Main(args : String[]) ~ Nil { + IsPalindrome("aasa")->PrintLine(); + IsPalindrome("acbca")->PrintLine(); + IsPalindrome("xx")->PrintLine(); + } + + function : native : IsPalindrome(s : String) ~ Bool { + l := s->Size(); + for(i := 0; i < l / 2; i += 1;) { + if(s->Get(i) <> s->Get(l - i - 1)) { + return false; + }; + }; + + return true; + } + } +} diff --git a/Task/Palindrome-detection/Octave/palindrome-detection-1.octave b/Task/Palindrome-detection/Octave/palindrome-detection-1.octave new file mode 100644 index 0000000000..edf517f8c4 --- /dev/null +++ b/Task/Palindrome-detection/Octave/palindrome-detection-1.octave @@ -0,0 +1,14 @@ +function v = palindro_r(s) + if ( length(s) == 1 ) + v = true; + return; + elseif ( length(s) == 2 ) + v = s(1) == s(2); + return; + endif + if ( s(1) == s(length(s)) ) + v = palindro_r(s(2:length(s)-1)); + else + v = false; + endif +endfunction diff --git a/Task/Palindrome-detection/Octave/palindrome-detection-2.octave b/Task/Palindrome-detection/Octave/palindrome-detection-2.octave new file mode 100644 index 0000000000..6d12565225 --- /dev/null +++ b/Task/Palindrome-detection/Octave/palindrome-detection-2.octave @@ -0,0 +1,3 @@ +function v = palindro(s) + v = all( (s == s(length(s):-1:1)) == 1); +endfunction diff --git a/Task/Palindrome-detection/Octave/palindrome-detection-3.octave b/Task/Palindrome-detection/Octave/palindrome-detection-3.octave new file mode 100644 index 0000000000..84695a00d1 --- /dev/null +++ b/Task/Palindrome-detection/Octave/palindrome-detection-3.octave @@ -0,0 +1,2 @@ +palindro_r("ingirumimusnocteetconsumimurigni") +palindro("satorarepotenetoperarotas") diff --git a/Task/Palindrome-detection/Oz/palindrome-detection.oz b/Task/Palindrome-detection/Oz/palindrome-detection.oz new file mode 100644 index 0000000000..36f47d5f45 --- /dev/null +++ b/Task/Palindrome-detection/Oz/palindrome-detection.oz @@ -0,0 +1,3 @@ +fun {IsPalindrome S} + {Reverse S} == S +end diff --git a/Task/Palindrome-detection/PARI-GP/palindrome-detection.pari b/Task/Palindrome-detection/PARI-GP/palindrome-detection.pari new file mode 100644 index 0000000000..a59b93abd5 --- /dev/null +++ b/Task/Palindrome-detection/PARI-GP/palindrome-detection.pari @@ -0,0 +1,7 @@ +ispal(s)={ + s=Vec(s); + for(i=1,#v\2, + if(v[i]!=v[#v-i+1],return(0)) + ); + 1 +}; diff --git a/Task/Palindrome-detection/PHP/palindrome-detection-1.php b/Task/Palindrome-detection/PHP/palindrome-detection-1.php new file mode 100644 index 0000000000..4e6173515b --- /dev/null +++ b/Task/Palindrome-detection/PHP/palindrome-detection-1.php @@ -0,0 +1,5 @@ + diff --git a/Task/Palindrome-detection/PHP/palindrome-detection-2.php b/Task/Palindrome-detection/PHP/palindrome-detection-2.php new file mode 100644 index 0000000000..b214f85c8d --- /dev/null +++ b/Task/Palindrome-detection/PHP/palindrome-detection-2.php @@ -0,0 +1,5 @@ + diff --git a/Task/Palindrome-detection/PL-I/palindrome-detection.pli b/Task/Palindrome-detection/PL-I/palindrome-detection.pli new file mode 100644 index 0000000000..b6c60eca3a --- /dev/null +++ b/Task/Palindrome-detection/PL-I/palindrome-detection.pli @@ -0,0 +1,18 @@ +is_palindrome: procedure (text) returns (bit(1)); + declare text character (*) varying; + + text = remove_blanks(text); + text = lowercase(text); + return (text = reverse(text)); + +remove_blanks: procedure (text); + declare text character (*) varying; + declare (i, j) fixed binary (31); + j = 0; + do i = 1 to length(text); + if substr(text, i, 1) = ' ' then + do; j = j + 1; substr(text, j, 1) = substr(text, i, 1); end; + end; + return (substr(text, 1, j)); +end remove_blanks; +end is_palindrome; diff --git a/Task/Palindrome-detection/Pascal/palindrome-detection-1.pascal b/Task/Palindrome-detection/Pascal/palindrome-detection-1.pascal new file mode 100644 index 0000000000..406588bf57 --- /dev/null +++ b/Task/Palindrome-detection/Pascal/palindrome-detection-1.pascal @@ -0,0 +1,23 @@ +program Palindro; + +{ RECURSIVE } +function is_palindro_r(s : String) : Boolean; +begin + if length(s) <= 1 then + is_palindro_r := true + else begin + if s[1] = s[length(s)] then + is_palindro_r := is_palindro_r(copy(s, 2, length(s)-2)) + else + is_palindro_r := false + end +end; { is_palindro_r } + +{ NON RECURSIVE; see [[Reversing a string]] for "reverse" } +function is_palindro(s : String) : Boolean; +begin + if s = reverse(s) then + is_palindro := true + else + is_palindro := false +end; diff --git a/Task/Palindrome-detection/Pascal/palindrome-detection-2.pascal b/Task/Palindrome-detection/Pascal/palindrome-detection-2.pascal new file mode 100644 index 0000000000..a16b80af9d --- /dev/null +++ b/Task/Palindrome-detection/Pascal/palindrome-detection-2.pascal @@ -0,0 +1,19 @@ +procedure test_r(s : String; r : Boolean); +begin + write('"', s, '" is '); + if ( not r ) then + write('not '); + writeln('palindrome') +end; + +var + s1, s2 : String; + +begin + s1 := 'ingirumimusnocteetconsumimurigni'; + s2 := 'in girum imus nocte'; + test_r(s1, is_palindro_r(s1)); + test_r(s2, is_palindro_r(s2)); + test_r(s1, is_palindro(s1)); + test_r(s2, is_palindro(s2)) +end. diff --git a/Task/Palindrome-detection/Perl-6/palindrome-detection.pl6 b/Task/Palindrome-detection/Perl-6/palindrome-detection.pl6 new file mode 100644 index 0000000000..c6f747327a --- /dev/null +++ b/Task/Palindrome-detection/Perl-6/palindrome-detection.pl6 @@ -0,0 +1,16 @@ +sub palin(Str $s --> Bool) { + my @chars = $s.lc.comb(/\w/); + while @chars > 1 { + return False unless @chars.shift eq @chars.pop; + } + return True; +} + +my @tests = + "A man, a plan, a canal: Panama.", + "My dog has fleas", + "Madam, I'm Adam.", + "1 on 1", + "In girum imus nocte et consumimur igni"; + +for @tests { say (palin($_) ?? "Yes" !! "No"),"\t",$_ }; diff --git a/Task/Palindrome-detection/Perl/palindrome-detection-1.pl b/Task/Palindrome-detection/Perl/palindrome-detection-1.pl new file mode 100644 index 0000000000..ddf68c3921 --- /dev/null +++ b/Task/Palindrome-detection/Perl/palindrome-detection-1.pl @@ -0,0 +1,37 @@ +# Palindrome.pm +package Palindrome; + +use strict; +use warnings; + +use Exporter 'import'; +our @EXPORT = qw(palindrome palindrome_c palindrome_r palindrome_e); + +sub palindrome +{ + my $s = (@_ ? shift : $_); + return $s eq reverse $s; +} + +sub palindrome_c +{ + my $s = (@_ ? shift : $_); + for my $i (0 .. length($s) >> 1) + { + return 0 unless substr($s, $i, 1) eq substr($s, -1 - $i, 1); + } + return 1; +} + +sub palindrome_r +{ + my $s = (@_ ? shift : $_); + if (length $s <= 1) { return 1; } + elsif (substr($s, 0, 1) ne substr($s, -1, 1)) { return 0; } + else { return palindrome_r(substr($s, 1, -1)); } +} + +sub palindrome_e +{ + (@_ ? shift : $_) =~ /^(.?|(.)(?1)\2)$/ + 0 +} diff --git a/Task/Palindrome-detection/Perl/palindrome-detection-2.pl b/Task/Palindrome-detection/Perl/palindrome-detection-2.pl new file mode 100644 index 0000000000..7a135726a6 --- /dev/null +++ b/Task/Palindrome-detection/Perl/palindrome-detection-2.pl @@ -0,0 +1,23 @@ +# pbench.pl +use strict; +use warnings; + +use Benchmark qw(cmpthese); +use Palindrome; + +printf("%d, %d, %d, %d: %s\n", + palindrome, palindrome_c, palindrome_r, palindrome_e, $_) +for + qw/a aa ab abba aBbA abca abba1 1abba + ingirumimusnocteetconsumimurigni/, + 'ab cc ba', 'ab ccb a'; + +printf "\n"; + +my $latin = "ingirumimusnocteetconsumimurigni"; +cmpthese(100_000, { + palindrome => sub { palindrome $latin }, + palindrome_c => sub { palindrome_c $latin }, + palindrome_r => sub { palindrome_r $latin }, + palindrome_e => sub { palindrome_e $latin }, +}); diff --git a/Task/Palindrome-detection/PicoLisp/palindrome-detection.l b/Task/Palindrome-detection/PicoLisp/palindrome-detection.l new file mode 100644 index 0000000000..42b6dfc44b --- /dev/null +++ b/Task/Palindrome-detection/PicoLisp/palindrome-detection.l @@ -0,0 +1,2 @@ +(de palindrome? (S) + (= (setq S (chop S)) (reverse S)) ) diff --git a/Task/Palindrome-detection/Pike/palindrome-detection.pike b/Task/Palindrome-detection/Pike/palindrome-detection.pike new file mode 100644 index 0000000000..4cddaf25e6 --- /dev/null +++ b/Task/Palindrome-detection/Pike/palindrome-detection.pike @@ -0,0 +1,16 @@ +int main(){ + if(pal("rotator")){ + write("palindrome!\n"); + } + if(!pal("asdf")){ + write("asdf isn't a palindrome.\n"); + } +} + +int pal(string input){ + if( reverse(input) == input ){ + return 1; + } else { + return 0; + } +} diff --git a/Task/Palindrome-detection/PowerBASIC/palindrome-detection.powerbasic b/Task/Palindrome-detection/PowerBASIC/palindrome-detection.powerbasic new file mode 100644 index 0000000000..f35bb5433e --- /dev/null +++ b/Task/Palindrome-detection/PowerBASIC/palindrome-detection.powerbasic @@ -0,0 +1,32 @@ +FUNCTION isPalindrome (what AS STRING) AS LONG + DIM whatcopy AS STRING, chk AS STRING, tmp AS STRING * 1, L0 AS LONG + + FOR L0 = 1 TO LEN(what) + tmp = UCASE$(MID$(what, L0, 1)) + SELECT CASE tmp + CASE "A" TO "Z" + whatcopy = whatcopy & tmp + chk = tmp & chk + CASE "0" TO "9" + MSGBOX "Numbers are cheating! (""" & what & """)" + FUNCTION = 0 + EXIT FUNCTION + END SELECT + NEXT + + FUNCTION = ISTRUE((whatcopy) = chk) +END FUNCTION + + +FUNCTION PBMAIN () AS LONG + DATA "My dog has fleas", "Madam, I'm Adam.", "1 on 1", "In girum imus nocte et consumimur igni" + DIM L1 AS LONG, w AS STRING + FOR L1 = 1 TO DATACOUNT + w = READ$(L1) + IF ISTRUE(isPalindrome(w)) THEN + MSGBOX $DQ & w & """ is a palindrome" + ELSE + MSGBOX $DQ & w & """ is not a palindrome" + END IF + NEXT +END FUNCTION diff --git a/Task/Palindrome-detection/Prolog/palindrome-detection-1.pro b/Task/Palindrome-detection/Prolog/palindrome-detection-1.pro new file mode 100644 index 0000000000..3d94f13b14 --- /dev/null +++ b/Task/Palindrome-detection/Prolog/palindrome-detection-1.pro @@ -0,0 +1 @@ +palindrome(Word) :- name(Word,List), reverse(List,List). diff --git a/Task/Palindrome-detection/Prolog/palindrome-detection-2.pro b/Task/Palindrome-detection/Prolog/palindrome-detection-2.pro new file mode 100644 index 0000000000..43b7146581 --- /dev/null +++ b/Task/Palindrome-detection/Prolog/palindrome-detection-2.pro @@ -0,0 +1,2 @@ +pali(Str) :- sub_string(Str, 0, 1, _, X), string_concat(Str2, X, Str), string_concat(X, Mid, Str2), pali(Mid). +pali(Str) :- string_length(Str, Len), Len < 2. diff --git a/Task/Palindrome-detection/Prolog/palindrome-detection-3.pro b/Task/Palindrome-detection/Prolog/palindrome-detection-3.pro new file mode 100644 index 0000000000..ee3fc76a73 --- /dev/null +++ b/Task/Palindrome-detection/Prolog/palindrome-detection-3.pro @@ -0,0 +1,2 @@ +pali(Str) :- sub_atom(Str, 0, 1, _, X), atom_concat(Str2, X, Str), atom_concat(X, Mid, Str2), pali(Mid). +pali(Str) :- atom_length(Str, Len), Len < 2. diff --git a/Task/Palindrome-detection/PureBasic/palindrome-detection.purebasic b/Task/Palindrome-detection/PureBasic/palindrome-detection.purebasic new file mode 100644 index 0000000000..d6e359da87 --- /dev/null +++ b/Task/Palindrome-detection/PureBasic/palindrome-detection.purebasic @@ -0,0 +1,7 @@ +Procedure IsPalindrome(StringToTest.s) + If StringToTest=ReverseString(StringToTest) + ProcedureReturn 1 + Else + ProcedureReturn 0 + EndIf +EndProcedure diff --git a/Task/Palindrome-detection/Python/palindrome-detection-1.py b/Task/Palindrome-detection/Python/palindrome-detection-1.py new file mode 100644 index 0000000000..21e899b9a3 --- /dev/null +++ b/Task/Palindrome-detection/Python/palindrome-detection-1.py @@ -0,0 +1,2 @@ +def is_palindrome(s): + return s == s[::-1] diff --git a/Task/Palindrome-detection/Python/palindrome-detection-2.py b/Task/Palindrome-detection/Python/palindrome-detection-2.py new file mode 100644 index 0000000000..2e5275cf73 --- /dev/null +++ b/Task/Palindrome-detection/Python/palindrome-detection-2.py @@ -0,0 +1,7 @@ +def is_palindrome_r(s): + if len(s) <= 1: + return True + elif s[0] != s[-1]: + return False + else: + return is_palindrome_r(s[1:-1]) diff --git a/Task/Palindrome-detection/Python/palindrome-detection-3.py b/Task/Palindrome-detection/Python/palindrome-detection-3.py new file mode 100644 index 0000000000..94ce9c3c7e --- /dev/null +++ b/Task/Palindrome-detection/Python/palindrome-detection-3.py @@ -0,0 +1,2 @@ +def is_palindrome_r2(s): + return not s or s[0] == s[-1] and is_palindrome_r2(s[1:-1]) diff --git a/Task/Palindrome-detection/Python/palindrome-detection-4.py b/Task/Palindrome-detection/Python/palindrome-detection-4.py new file mode 100644 index 0000000000..8a5bfe7d81 --- /dev/null +++ b/Task/Palindrome-detection/Python/palindrome-detection-4.py @@ -0,0 +1,9 @@ +def test(f, good, bad): + assert all(f(x) for x in good) + assert not any(f(x) for x in bad) + print '%s passed all %d tests' % (f.__name__, len(good)+len(bad)) + +pals = ('', 'a', 'aa', 'aba', 'abba') +notpals = ('aA', 'abA', 'abxBa', 'abxxBa') +for ispal in is_palindrome, is_palindrome_r, is_palindrome_r2: + test(ispal, pals, notpals) diff --git a/Task/Palindrome-detection/R/palindrome-detection-1.r b/Task/Palindrome-detection/R/palindrome-detection-1.r new file mode 100644 index 0000000000..15a2661a4a --- /dev/null +++ b/Task/Palindrome-detection/R/palindrome-detection-1.r @@ -0,0 +1,13 @@ +palindro <- function(p) { + if ( nchar(p) == 1 ) { + return(TRUE) + } else if ( nchar(p) == 2 ) { + return(substr(p,1,1) == substr(p,2,2)) + } else { + if ( substr(p,1,1) == substr(p, nchar(p), nchar(p)) ) { + return(palindro(substr(p, 2, nchar(p)-1))) + } else { + return(FALSE) + } + } +} diff --git a/Task/Palindrome-detection/R/palindrome-detection-2.r b/Task/Palindrome-detection/R/palindrome-detection-2.r new file mode 100644 index 0000000000..6724751335 --- /dev/null +++ b/Task/Palindrome-detection/R/palindrome-detection-2.r @@ -0,0 +1,7 @@ +palindroi <- function(p) { + for(i in 1:floor(nchar(p)/2) ) { + r <- nchar(p) - i + 1 + if ( substr(p, i, i) != substr(p, r, r) ) return(FALSE) + } + TRUE +} diff --git a/Task/Palindrome-detection/R/palindrome-detection-3.r b/Task/Palindrome-detection/R/palindrome-detection-3.r new file mode 100644 index 0000000000..f0fc3cf3f6 --- /dev/null +++ b/Task/Palindrome-detection/R/palindrome-detection-3.r @@ -0,0 +1,8 @@ +revstring <- function(stringtorev) { + return( + paste( + strsplit(stringtorev,"")[[1]][nchar(stringtorev):1] + ,collapse="") + ) +} +palindroc <- function(p) {return(revstring(p)==p)} diff --git a/Task/Palindrome-detection/REBOL/palindrome-detection.rebol b/Task/Palindrome-detection/REBOL/palindrome-detection.rebol new file mode 100644 index 0000000000..56bbaccf31 --- /dev/null +++ b/Task/Palindrome-detection/REBOL/palindrome-detection.rebol @@ -0,0 +1,31 @@ +REBOL [ + Title: "Palindrome Recognizer" + Date: 2010-01-03 + Author: oofoe + URL: http://rosettacode.org/wiki/Palindrome +] + +; In order to compete with all the one-liners, the operation is +; compressed: parens force left hand side to evaluate first, where I +; copy the phrase, then uppercase it and assign it to 'p'. Now the +; right hand side is evaluated: p is copied, then reversed in place; +; the comparison is made and implicitely returned. + +palindrome?: func [ + phrase [string!] "Potentially palindromatic prose." + /local p +][(p: uppercase copy phrase) = reverse copy p] + +; Teeny Tiny Test Suite + +assert: func [code][print [either do code [" ok"]["FAIL"] mold code]] + +print "Simple palindromes, with an exception for variety:" +repeat phrase ["z" "aha" "sees" "oofoe" "Deified"][ + assert compose [palindrome? (phrase)]] + +print [crlf "According to the problem statement, these should fail:"] +assert [palindrome? "A man, a plan, a canal, Panama."] ; Punctuation not ignored. +assert [palindrome? "In girum imus nocte et consumimur igni"] ; Spaces not removed. + +; I know we're doing palindromes, not alliteration, but who could resist...? diff --git a/Task/Palindrome-detection/REXX/palindrome-detection.rexx b/Task/Palindrome-detection/REXX/palindrome-detection.rexx new file mode 100644 index 0000000000..d796068e5b --- /dev/null +++ b/Task/Palindrome-detection/REXX/palindrome-detection.rexx @@ -0,0 +1,17 @@ +/*REXX program checks to see if a phrase is palindromic. */ + +y = 'In girum imus nocte et consumimur igni' + + /*translation: We walk around in the night and */ + /* we are burnt by the fire (of love). */ +say 'string = ' y +say +if isPal(y) then say 'The string is palindromic.' + else say "The string isn't palindromic." +exit /*stick a fork in it, we're done.*/ + +/*──────────────────────────────────ISPAL subroutine────────────────────*/ +isPal: procedure; arg x /*uppercases the value of arg X. */ +x = space(x,0) /*removes all blanks (spaces). */ +return x==reverse(x) /*returns 1 if exactly equal, */ + /* " 0 if not equal. */ diff --git a/Task/Palindrome-detection/Racket/palindrome-detection.rkt b/Task/Palindrome-detection/Racket/palindrome-detection.rkt new file mode 100644 index 0000000000..a6b9adb5c4 --- /dev/null +++ b/Task/Palindrome-detection/Racket/palindrome-detection.rkt @@ -0,0 +1,14 @@ +(define (palindromb str) + (let* ([lst (string->list (string-downcase str))] + [slst (remove* '(#\space) lst)]) + (string=? (list->string (reverse slst)) (list->string slst)))) + +;;example output + +> (palindromb "able was i ere i saw elba") +#t +> (palindromb "waht the hey") +#f +> (palindromb "In girum imus nocte et consumimur igni") +#t +> diff --git a/Task/Palindrome-detection/Rascal/palindrome-detection-1.rascal b/Task/Palindrome-detection/Rascal/palindrome-detection-1.rascal new file mode 100644 index 0000000000..cfefb190b7 --- /dev/null +++ b/Task/Palindrome-detection/Rascal/palindrome-detection-1.rascal @@ -0,0 +1,3 @@ +import String; + +public bool palindrome(str text) = toLowerCase(text) == reverse(text); diff --git a/Task/Palindrome-detection/Rascal/palindrome-detection-2.rascal b/Task/Palindrome-detection/Rascal/palindrome-detection-2.rascal new file mode 100644 index 0000000000..c205882ad9 --- /dev/null +++ b/Task/Palindrome-detection/Rascal/palindrome-detection-2.rascal @@ -0,0 +1,6 @@ +import String; + +public bool palindrome(str text){ + text = replaceAll(toLowerCase(text), " ", ""); + return text == reverse(text); +} diff --git a/Task/Palindrome-detection/Rascal/palindrome-detection-3.rascal b/Task/Palindrome-detection/Rascal/palindrome-detection-3.rascal new file mode 100644 index 0000000000..2c1fed04e0 --- /dev/null +++ b/Task/Palindrome-detection/Rascal/palindrome-detection-3.rascal @@ -0,0 +1,2 @@ +rascal>palindrome("In girum imus nocte et consumimur igni") +bool: true diff --git a/Task/Palindrome-detection/Retro/palindrome-detection.retro b/Task/Palindrome-detection/Retro/palindrome-detection.retro new file mode 100644 index 0000000000..0e90d6e9d8 --- /dev/null +++ b/Task/Palindrome-detection/Retro/palindrome-detection.retro @@ -0,0 +1,4 @@ +needs hash' +: palindrome? ( $-f ) dup ^hash'hash [ ^strings'reverse ^hash'hash ] dip = ; + +"ingirumimusnocteetconsumimurigni" palindrome? putn diff --git a/Task/Palindrome-detection/Ruby/palindrome-detection-1.rb b/Task/Palindrome-detection/Ruby/palindrome-detection-1.rb new file mode 100644 index 0000000000..dd705131cd --- /dev/null +++ b/Task/Palindrome-detection/Ruby/palindrome-detection-1.rb @@ -0,0 +1,3 @@ +def is_palindrome(s) + s == s.reverse +end diff --git a/Task/Palindrome-detection/Ruby/palindrome-detection-2.rb b/Task/Palindrome-detection/Ruby/palindrome-detection-2.rb new file mode 100644 index 0000000000..72aabd7b1a --- /dev/null +++ b/Task/Palindrome-detection/Ruby/palindrome-detection-2.rb @@ -0,0 +1,9 @@ +def is_palindrome_r(s) + if s.length <= 1 + true + elsif s[0] != s[-1] + false + else + is_palindrome_r(s[1..-2]) + end +end diff --git a/Task/Palindrome-detection/Ruby/palindrome-detection-3.rb b/Task/Palindrome-detection/Ruby/palindrome-detection-3.rb new file mode 100644 index 0000000000..d8d8e368c8 --- /dev/null +++ b/Task/Palindrome-detection/Ruby/palindrome-detection-3.rb @@ -0,0 +1,9 @@ +str = "A man, a plan, a caret, [...2110 chars deleted...] a canal--Panama.".downcase.delete('^a-z') +puts is_palindrome(str) # => true +puts is_palindrome_r(str) # => true + +require 'benchmark' +Benchmark.bm do |b| + b.report('iterative') {10000.times {is_palindrome(str)}} + b.report('recursive') {10000.times {is_palindrome_r(str)}} +end diff --git a/Task/Palindrome-detection/Run-BASIC/palindrome-detection.run b/Task/Palindrome-detection/Run-BASIC/palindrome-detection.run new file mode 100644 index 0000000000..d582d8c5b4 --- /dev/null +++ b/Task/Palindrome-detection/Run-BASIC/palindrome-detection.run @@ -0,0 +1,13 @@ +data "My dog has fleas", "Madam, I'm Adam.", "1 on 1", "In girum imus nocte et consumimur igni" + +for i = 1 to 4 + read w$ + print w$;" is ";isPalindrome$(w$);" Palindrome" +next + +FUNCTION isPalindrome$(str$) +for i = 1 to len(str$) + a$ = upper$(mid$(str$,i,1)) + if (a$ >= "A" and a$ <= "Z") or (a$ >= "0" and a$ <= "9") then b$ = b$ + a$: c$ = a$ + c$ +next i +if b$ <> c$ then isPalindrome$ = "not" diff --git a/Task/Palindrome-detection/SNOBOL4/palindrome-detection.sno b/Task/Palindrome-detection/SNOBOL4/palindrome-detection.sno new file mode 100644 index 0000000000..df5b859b4d --- /dev/null +++ b/Task/Palindrome-detection/SNOBOL4/palindrome-detection.sno @@ -0,0 +1,17 @@ + define('pal(str)') :(pal_end) +pal str notany(&ucase &lcase) = :s(pal) + str = replace(str,&ucase,&lcase) + leq(str,reverse(str)) :s(return)f(freturn) +pal_end + + define('palchk(str)tf') :(palchk_end) +palchk output = str; + tf = 'False'; tf = pal(str) 'True' + output = 'Palindrome: ' tf :(return) +palchk_end + +* # Test and display + palchk('Able was I ere I saw Elba') + palchk('In girum imus nocte et consumimur igni') + palchk('The quick brown fox jumped over the lazy dogs') +end diff --git a/Task/Palindrome-detection/Scala/palindrome-detection-1.scala b/Task/Palindrome-detection/Scala/palindrome-detection-1.scala new file mode 100644 index 0000000000..c9728879f2 --- /dev/null +++ b/Task/Palindrome-detection/Scala/palindrome-detection-1.scala @@ -0,0 +1 @@ +def isPalindrome(s: String) = s == s.reverse diff --git a/Task/Palindrome-detection/Scala/palindrome-detection-2.scala b/Task/Palindrome-detection/Scala/palindrome-detection-2.scala new file mode 100644 index 0000000000..e38a10f165 --- /dev/null +++ b/Task/Palindrome-detection/Scala/palindrome-detection-2.scala @@ -0,0 +1,8 @@ +scala> isPalindrome("amanaplanacanalpanama") +res0: Boolean = true + +scala> isPalindrome("Test 1,2,3") +res1: Boolean = false + +scala> isPalindrome("1 2 1") +res2: Boolean = true diff --git a/Task/Palindrome-detection/Scala/palindrome-detection-3.scala b/Task/Palindrome-detection/Scala/palindrome-detection-3.scala new file mode 100644 index 0000000000..88b492228e --- /dev/null +++ b/Task/Palindrome-detection/Scala/palindrome-detection-3.scala @@ -0,0 +1 @@ +def isPalindromeSentence(s: String) = { val p = s.replaceAll("[^\\p{L}]", "").toLowerCase; p == p.reverse } diff --git a/Task/Palindrome-detection/Scala/palindrome-detection-4.scala b/Task/Palindrome-detection/Scala/palindrome-detection-4.scala new file mode 100644 index 0000000000..78a0c13289 --- /dev/null +++ b/Task/Palindrome-detection/Scala/palindrome-detection-4.scala @@ -0,0 +1,2 @@ +scala> isPalindromeSentence("A man a plan a canal Panama.") +res3: Boolean = true diff --git a/Task/Palindrome-detection/Scala/palindrome-detection-5.scala b/Task/Palindrome-detection/Scala/palindrome-detection-5.scala new file mode 100644 index 0000000000..1a63921a01 --- /dev/null +++ b/Task/Palindrome-detection/Scala/palindrome-detection-5.scala @@ -0,0 +1,4 @@ +def isPalindrome(s : String) : Boolean = s match { + case s if s.length > 1 => (s.head == s.last) && isPalindrome(s.slice(1, s.length-1)) + case _ => true +} diff --git a/Task/Palindrome-detection/Scheme/palindrome-detection-1.ss b/Task/Palindrome-detection/Scheme/palindrome-detection-1.ss new file mode 100644 index 0000000000..0927081675 --- /dev/null +++ b/Task/Palindrome-detection/Scheme/palindrome-detection-1.ss @@ -0,0 +1,3 @@ +(define (palindrome? s) + (let ((chars (string->list s))) + (equal? chars (reverse chars)))) diff --git a/Task/Palindrome-detection/Scheme/palindrome-detection-2.ss b/Task/Palindrome-detection/Scheme/palindrome-detection-2.ss new file mode 100644 index 0000000000..1665831b13 --- /dev/null +++ b/Task/Palindrome-detection/Scheme/palindrome-detection-2.ss @@ -0,0 +1,20 @@ +(define (palindrome? s) + (let loop ((i 0) + (j (- (string-length s) 1))) + (or (>= i j) + (and (char=? (string-ref s i) (string-ref s j)) + (loop (+ i 1) (- j 1)))))) + +;; Or: +(define (palindrome? s) + (let loop ((s (string->list s)) + (r (reverse (string->list s)))) + (or (null? s) + (and (char=? (car s) (car r)) + (loop (cdr s) (cdr r)))))) + +> (palindrome? "ingirumimusnocteetconsumimurigni") +#t +> (palindrome? "This is not a palindrome") +#f +> diff --git a/Task/Palindrome-detection/Seed7/palindrome-detection-1.seed7 b/Task/Palindrome-detection/Seed7/palindrome-detection-1.seed7 new file mode 100644 index 0000000000..992dbac3a9 --- /dev/null +++ b/Task/Palindrome-detection/Seed7/palindrome-detection-1.seed7 @@ -0,0 +1,14 @@ +const func boolean: palindrome (in string: stri) is func + result + var boolean: isPalindrome is TRUE; + local + var integer: index is 0; + var integer: length is 0; + begin + length := length(stri); + for index range 1 to length div 2 do + if stri[index] <> stri[length - index + 1] then + isPalindrome := FALSE; + end if; + end for; + end func; diff --git a/Task/Palindrome-detection/Seed7/palindrome-detection-2.seed7 b/Task/Palindrome-detection/Seed7/palindrome-detection-2.seed7 new file mode 100644 index 0000000000..9209693ec5 --- /dev/null +++ b/Task/Palindrome-detection/Seed7/palindrome-detection-2.seed7 @@ -0,0 +1 @@ +palindrome(replace("in girum imus nocte et consumimur igni", " ", "")) diff --git a/Task/Palindrome-detection/Slate/palindrome-detection-1.slate b/Task/Palindrome-detection/Slate/palindrome-detection-1.slate new file mode 100644 index 0000000000..d979410597 --- /dev/null +++ b/Task/Palindrome-detection/Slate/palindrome-detection-1.slate @@ -0,0 +1,4 @@ +s@(String traits) isPalindrome +[ + (s lexicographicallyCompare: s reversed) isZero +]. diff --git a/Task/Palindrome-detection/Slate/palindrome-detection-2.slate b/Task/Palindrome-detection/Slate/palindrome-detection-2.slate new file mode 100644 index 0000000000..30637acba5 --- /dev/null +++ b/Task/Palindrome-detection/Slate/palindrome-detection-2.slate @@ -0,0 +1,6 @@ +s@(Sequence traits) isPalindrome +[ + s isEmpty + ifTrue: [True] + ifFalse: [(s first = s last) /\ [(s sliceFrom: 1 to: s indexLast - 1) isPalindrome]] +]. diff --git a/Task/Palindrome-detection/Slate/palindrome-detection-3.slate b/Task/Palindrome-detection/Slate/palindrome-detection-3.slate new file mode 100644 index 0000000000..e7ecaf68ac --- /dev/null +++ b/Task/Palindrome-detection/Slate/palindrome-detection-3.slate @@ -0,0 +1,2 @@ +define: #p -> 'ingirumimusnocteetconsumimurigni'. +inform: 'sequence ' ; p ; ' is ' ; (p isPalindrome ifTrue: [''] ifFalse: ['not ']) ; 'a palindrome.'. diff --git a/Task/Palindrome-detection/Smalltalk/palindrome-detection-1.st b/Task/Palindrome-detection/Smalltalk/palindrome-detection-1.st new file mode 100644 index 0000000000..4d070374ce --- /dev/null +++ b/Task/Palindrome-detection/Smalltalk/palindrome-detection-1.st @@ -0,0 +1,4 @@ +isPalindrome := [:aString | + str := (aString select: [:chr| chr isAlphaNumeric]) collect: [:chr | chr asLowercase]. + str = str reversed. + ]. diff --git a/Task/Palindrome-detection/Smalltalk/palindrome-detection-2.st b/Task/Palindrome-detection/Smalltalk/palindrome-detection-2.st new file mode 100644 index 0000000000..e9dfc00648 --- /dev/null +++ b/Task/Palindrome-detection/Smalltalk/palindrome-detection-2.st @@ -0,0 +1,14 @@ +String extend [ + palindro [ "Non-recursive" + ^ self = (self reverse) + ] + palindroR [ "Recursive" + (self size) <= 1 ifTrue: [ ^true ] + ifFalse: [ |o i f| o := self asOrderedCollection. + i := o removeFirst. + f := o removeLast. + i = f ifTrue: [ ^ (o asString) palindroR ] + ifFalse: [ ^false ] + ] + ] +]. diff --git a/Task/Palindrome-detection/Smalltalk/palindrome-detection-3.st b/Task/Palindrome-detection/Smalltalk/palindrome-detection-3.st new file mode 100644 index 0000000000..bc97620cc9 --- /dev/null +++ b/Task/Palindrome-detection/Smalltalk/palindrome-detection-3.st @@ -0,0 +1,4 @@ +('hello' palindro) printNl. +('hello' palindroR) printNl. +('ingirumimusnocteetconsumimurigni' palindro) printNl. +('ingirumimusnocteetconsumimurigni' palindroR) printNl. diff --git a/Task/Palindrome-detection/Smalltalk/palindrome-detection-4.st b/Task/Palindrome-detection/Smalltalk/palindrome-detection-4.st new file mode 100644 index 0000000000..056c88275f --- /dev/null +++ b/Task/Palindrome-detection/Smalltalk/palindrome-detection-4.st @@ -0,0 +1,2 @@ +SequenceableCollection>>isPalindrome + ^self reverse = self diff --git a/Task/Palindrome-detection/TUSCRIPT/palindrome-detection.tuscript b/Task/Palindrome-detection/TUSCRIPT/palindrome-detection.tuscript new file mode 100644 index 0000000000..1e1e05d2ef --- /dev/null +++ b/Task/Palindrome-detection/TUSCRIPT/palindrome-detection.tuscript @@ -0,0 +1,9 @@ +$$ MODE TUSCRIPT +pal ="ingirumimusnocteetconsumimurigni" +pal_r=TURN(pal) +SELECT pal +CASE $pal_r +PRINT "true" +DEFAULT +PRINT/ERROR "untrue" +ENDSELECT diff --git a/Task/Palindrome-detection/Tcl/palindrome-detection-1.tcl b/Task/Palindrome-detection/Tcl/palindrome-detection-1.tcl new file mode 100644 index 0000000000..ef0be642ee --- /dev/null +++ b/Task/Palindrome-detection/Tcl/palindrome-detection-1.tcl @@ -0,0 +1,4 @@ +package require Tcl 8.5 +proc palindrome {s} { + return [expr {$s eq [string reverse $s]}] +} diff --git a/Task/Palindrome-detection/Tcl/palindrome-detection-2.tcl b/Task/Palindrome-detection/Tcl/palindrome-detection-2.tcl new file mode 100644 index 0000000000..1525c47161 --- /dev/null +++ b/Task/Palindrome-detection/Tcl/palindrome-detection-2.tcl @@ -0,0 +1,9 @@ +proc palindrome_r {s} { + if {[string length $s] <= 1} { + return true + } elseif {[string index $s 0] ne [string index $s end]} { + return false + } else { + return [palindrome_r [string range $s 1 end-1]] + } +} diff --git a/Task/Palindrome-detection/Tcl/palindrome-detection-3.tcl b/Task/Palindrome-detection/Tcl/palindrome-detection-3.tcl new file mode 100644 index 0000000000..513e50d249 --- /dev/null +++ b/Task/Palindrome-detection/Tcl/palindrome-detection-3.tcl @@ -0,0 +1,3 @@ +set p ingirumimusnocteetconsumimurigni +puts "'$p' is palindrome? [palindrome $p]" +puts "'$p' is palindrome? [palindrome_r $p]" diff --git a/Task/Palindrome-detection/Ursala/palindrome-detection-1.ursala b/Task/Palindrome-detection/Ursala/palindrome-detection-1.ursala new file mode 100644 index 0000000000..10a5f5d607 --- /dev/null +++ b/Task/Palindrome-detection/Ursala/palindrome-detection-1.ursala @@ -0,0 +1,3 @@ +#import std + +palindrome = ~&cixE\letters+ * -:~& ~=`A-~rlp letters diff --git a/Task/Palindrome-detection/Ursala/palindrome-detection-2.ursala b/Task/Palindrome-detection/Ursala/palindrome-detection-2.ursala new file mode 100644 index 0000000000..f2a93d21f3 --- /dev/null +++ b/Task/Palindrome-detection/Ursala/palindrome-detection-2.ursala @@ -0,0 +1,3 @@ +#cast %bL + +examples = palindrome* <'abccba','foo ba rra bo of','notone'> diff --git a/Task/Palindrome-detection/VBA/palindrome-detection.vba b/Task/Palindrome-detection/VBA/palindrome-detection.vba new file mode 100644 index 0000000000..bb616d17c8 --- /dev/null +++ b/Task/Palindrome-detection/VBA/palindrome-detection.vba @@ -0,0 +1,5 @@ +Public Function isPalindrome(aString as string) as Boolean +dim tempstring as string + tempstring = Lcase(Replace(aString, " ", "")) + isPalindrome = (tempstring = Reverse(tempstring)) +End Function diff --git a/Task/Palindrome-detection/VBScript/palindrome-detection-1.vbscript b/Task/Palindrome-detection/VBScript/palindrome-detection-1.vbscript new file mode 100644 index 0000000000..ded8b8e4f3 --- /dev/null +++ b/Task/Palindrome-detection/VBScript/palindrome-detection-1.vbscript @@ -0,0 +1,18 @@ +function Squish( s1 ) + dim sRes + sRes = vbNullString + dim i, c + for i = 1 to len( s1 ) + c = lcase( mid( s1, i, 1 )) + if instr( "abcdefghijklmnopqrstuvwxyz0123456789", c ) then + sRes = sRes & c + end if + next + Squish = sRes +end function + +function isPalindrome( s1 ) + dim squished + squished = Squish( s1 ) + isPalindrome = ( squished = StrReverse( squished ) ) +end function diff --git a/Task/Palindrome-detection/VBScript/palindrome-detection-2.vbscript b/Task/Palindrome-detection/VBScript/palindrome-detection-2.vbscript new file mode 100644 index 0000000000..57ba85d62a --- /dev/null +++ b/Task/Palindrome-detection/VBScript/palindrome-detection-2.vbscript @@ -0,0 +1,4 @@ +wscript.echo isPalindrome( "My dog has fleas") +wscript.echo isPalindrome( "Madam, I'm Adam.") +wscript.echo isPalindrome( "1 on 1") +wscript.echo isPalindrome( "In girum imus nocte et consumimur igni") diff --git a/Task/Palindrome-detection/VBScript/palindrome-detection-3.vbscript b/Task/Palindrome-detection/VBScript/palindrome-detection-3.vbscript new file mode 100644 index 0000000000..1d208904c3 --- /dev/null +++ b/Task/Palindrome-detection/VBScript/palindrome-detection-3.vbscript @@ -0,0 +1,4 @@ +0 +-1 +0 +-1 diff --git a/Task/Palindrome-detection/Vedit-macro-language/palindrome-detection-1.vedit b/Task/Palindrome-detection/Vedit-macro-language/palindrome-detection-1.vedit new file mode 100644 index 0000000000..8f1fd1c111 --- /dev/null +++ b/Task/Palindrome-detection/Vedit-macro-language/palindrome-detection-1.vedit @@ -0,0 +1,7 @@ +:PALINDROME: +EOL #2 = Cur_Col-2 +BOL +for (#1 = 0; #1 <= #2/2; #1++) { + if (CC(#1) != CC(#2-#1)) { Return(0) } +} +Return(1) diff --git a/Task/Palindrome-detection/Vedit-macro-language/palindrome-detection-2.vedit b/Task/Palindrome-detection/Vedit-macro-language/palindrome-detection-2.vedit new file mode 100644 index 0000000000..5fd56c4a7f --- /dev/null +++ b/Task/Palindrome-detection/Vedit-macro-language/palindrome-detection-2.vedit @@ -0,0 +1,7 @@ +Call("PALINDROME") +if (Return_Value) { + Statline_Message("Yes") +} else { + Statline_Message("No") +} +Return diff --git a/Task/Palindrome-detection/XPL0/palindrome-detection.xpl0 b/Task/Palindrome-detection/XPL0/palindrome-detection.xpl0 new file mode 100644 index 0000000000..2828115a98 --- /dev/null +++ b/Task/Palindrome-detection/XPL0/palindrome-detection.xpl0 @@ -0,0 +1,26 @@ +include c:\cxpl\codes; \intrinsic 'code' declarations +string 0; \use zero-terminated strings + +func StrLen(Str); \Return number of characters in an ASCIIZ string +char Str; +int I; +for I:= 0 to -1>>1-1 do + if Str(I) = 0 then return I; + +func Palindrome(S); \Return 'true' if S is a palindrome +char S; +int L, I; +[L:= StrLen(S); +for I:= 0 to L/2-1 do + if S(I) # S(L-1-I) then return false; +return true; +]; \Palindrome + +int Word, I; +[Word:= + ["otto", "mary", "ablewasiereisawelba", "ingirumimusnocteetconsumimurigni"]; +for I:= 0 to 4-1 do + [Text(0, if Palindrome(Word(I)) then "yes" else "no"); + CrLf(0); + ]; +] diff --git a/Task/Palindrome-detection/Yorick/palindrome-detection.yorick b/Task/Palindrome-detection/Yorick/palindrome-detection.yorick new file mode 100644 index 0000000000..0d70e72852 --- /dev/null +++ b/Task/Palindrome-detection/Yorick/palindrome-detection.yorick @@ -0,0 +1,10 @@ +func is_palindrome(str) { + s = strchar(str)(:-1); + return allof(s == s(::-1)); +} + +func prep_palindrome(str) { + s = strchar(strlower(str)); + w = where(s >= 'a' & s <= 'z'); + return strchar(s(w)); +} diff --git a/Task/Pangram-checker/0DESCRIPTION b/Task/Pangram-checker/0DESCRIPTION new file mode 100644 index 0000000000..82cb2a4ce4 --- /dev/null +++ b/Task/Pangram-checker/0DESCRIPTION @@ -0,0 +1,3 @@ +Write a function or method to check a sentence to see if it is a [[wp:Pangram|pangram]] or not and show its use. + +A pangram is a sentence that contains all the letters of the English alphabet at least once, for example: ''The quick brown fox jumps over the lazy dog''. diff --git a/Task/Pangram-checker/ACL2/pangram-checker.acl2 b/Task/Pangram-checker/ACL2/pangram-checker.acl2 new file mode 100644 index 0000000000..7229e721a0 --- /dev/null +++ b/Task/Pangram-checker/ACL2/pangram-checker.acl2 @@ -0,0 +1,9 @@ +(defun contains-each (needles haystack) + (if (endp needles) + t + (and (member (first needles) haystack) + (contains-each (rest needles) haystack)))) + +(defun pangramp (str) + (contains-each (coerce "abcdefghijklmnopqrstuvwxyz" 'list) + (coerce (string-downcase str) 'list))) diff --git a/Task/Pangram-checker/ALGOL-68/pangram-checker.alg b/Task/Pangram-checker/ALGOL-68/pangram-checker.alg new file mode 100644 index 0000000000..7c93d00bbf --- /dev/null +++ b/Task/Pangram-checker/ALGOL-68/pangram-checker.alg @@ -0,0 +1,36 @@ +# init pangram: # +INT la = ABS "a", lz = ABS "z"; +INT ua = ABS "A", uz = ABS "Z"; +IF lz-la+1 > bits width THEN + put(stand error, "Exception: insufficient bits in word for task"); + stop +FI; + +PROC is a pangram = (STRING test)BOOL: ( + BITS a2z := BIN(ABS(2r1 SHL (lz-la))-1); # assume: ASCII & Binary # + FOR i TO UPB test WHILE + INT c = ABS test[i]; + IF la <= c AND c <= lz THEN + a2z := a2z AND NOT(2r1 SHL (c-la)) + ELIF ua <= c AND c <= uz THEN + a2z := a2z AND NOT(2r1 SHL (c-ua)) + FI; +# WHILE # a2z /= 2r0 DO + SKIP + OD; + a2z = 2r0 +); + +main:( + []STRING test list = ( + "Big fjiords vex quick waltz nymph", + "The quick brown fox jumps over a lazy dog", + "A quick brown fox jumps over a lazy dog" + ); + FOR key TO UPB test list DO + STRING test = test list[key]; + IF is a pangram(test) THEN + print(("""",test,""" is a pangram!", new line)) + FI + OD +) diff --git a/Task/Pangram-checker/APL/pangram-checker.apl b/Task/Pangram-checker/APL/pangram-checker.apl new file mode 100644 index 0000000000..64fe912117 --- /dev/null +++ b/Task/Pangram-checker/APL/pangram-checker.apl @@ -0,0 +1,8 @@ + a←'abcdefghijklmnopqrstuvwxyz' + A←'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + + Panagram←{∧/ ∨⌿ 2 26⍴(a,A) ∊ ⍵} + Panagram 'This should fail' +0 + Panagram 'The quick brown fox jumps over the lazy dog' +1 diff --git a/Task/Pangram-checker/AWK/pangram-checker.awk b/Task/Pangram-checker/AWK/pangram-checker.awk new file mode 100644 index 0000000000..68722c7737 --- /dev/null +++ b/Task/Pangram-checker/AWK/pangram-checker.awk @@ -0,0 +1,17 @@ +#!/usr/bin/awk -f +BEGIN { + convert="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + print isPangram("The quick brown fox jumps over the lazy dog."); + print isPangram("The quick brown fo."); +} + +function isPangram(string) { + delete X; + for (k=1; k= 65 IF C% <= 90 MID$(A$,A%,1) = CHR$(C%+32) + NEXT + = A$ diff --git a/Task/Pangram-checker/Bracmat/pangram-checker.bracmat b/Task/Pangram-checker/Bracmat/pangram-checker.bracmat new file mode 100644 index 0000000000..9bb13a0771 --- /dev/null +++ b/Task/Pangram-checker/Bracmat/pangram-checker.bracmat @@ -0,0 +1,11 @@ +(isPangram= + k +. low$!arg:?arg + & a:?k + & whl + ' ( @(!arg:? !k ?) + & chr$(1+asc$!k):?k:~>z + ) + & !k:>z + & +); diff --git a/Task/Pangram-checker/Brat/pangram-checker-1.brat b/Task/Pangram-checker/Brat/pangram-checker-1.brat new file mode 100644 index 0000000000..ebf5c2c08d --- /dev/null +++ b/Task/Pangram-checker/Brat/pangram-checker-1.brat @@ -0,0 +1,15 @@ +pangram? = { sentence | + letters = [:a :b :c :d :e :f :g :h :i :j :k :l :m + :n :o :p :q :r :s :t :u :v :w :x :y :z] + + sentence.downcase! + + letters.reject! { l | + sentence.include? l + } + + letters.empty? +} + +p pangram? 'The quick brown fox jumps over the lazy dog.' #Prints true +p pangram? 'Probably not a pangram.' #Prints false diff --git a/Task/Pangram-checker/Brat/pangram-checker-2.brat b/Task/Pangram-checker/Brat/pangram-checker-2.brat new file mode 100644 index 0000000000..ab74d2e482 --- /dev/null +++ b/Task/Pangram-checker/Brat/pangram-checker-2.brat @@ -0,0 +1,3 @@ +pangram? = { sentence | + sentence.downcase.dice.unique.select(:alpha?).length == 26 +} diff --git a/Task/Pangram-checker/C++/pangram-checker.cpp b/Task/Pangram-checker/C++/pangram-checker.cpp new file mode 100644 index 0000000000..ccec311543 --- /dev/null +++ b/Task/Pangram-checker/C++/pangram-checker.cpp @@ -0,0 +1,16 @@ +#include +#include +#include +using namespace std; + +const string alphabet("abcdefghijklmnopqrstuvwxyz"); // sorted, no duplicates + +bool is_pangram(string s) { + // Convert to lower case. + transform(s.begin(), s.end(), s.begin(), ::tolower); + // Convert to a sorted sequence of (not necessarily unique) characters. + sort(s.begin(), s.end()); + // Is the second sequence a subset of the first sequence? + // Repeated letters in "s" are okay, since it still "includes" the single letter + return includes(s.begin(), s.end(), alphabet.begin(), alphabet.end()); +} diff --git a/Task/Pangram-checker/C/pangram-checker-1.c b/Task/Pangram-checker/C/pangram-checker-1.c new file mode 100644 index 0000000000..8ceb662607 --- /dev/null +++ b/Task/Pangram-checker/C/pangram-checker-1.c @@ -0,0 +1,36 @@ +#include + +int isPangram(const char *string) +{ + char ch, wasused[26] = {0}; + int total = 0; + + while ((ch = *string++)) { + int index; + + if('A'<=ch&&ch<='Z') + index = ch-'A'; + else if('a'<=ch&&ch<='z') + index = ch-'a'; + else + continue; + + total += !wasused[index]; + wasused[index] = 1; + } + return (total==26); +} + +int main() +{ + int i; + const char *tests[] = { + "The quick brown fox jumps over the lazy dog.", + "The qu1ck brown fox jumps over the lazy d0g." + }; + + for (i = 0; i < 2; i++) + printf("\"%s\" is %sa pangram\n", + tests[i], isPangram(tests[i])?"":"not "); + return 0; +} diff --git a/Task/Pangram-checker/C/pangram-checker-2.c b/Task/Pangram-checker/C/pangram-checker-2.c new file mode 100644 index 0000000000..36793a0e1f --- /dev/null +++ b/Task/Pangram-checker/C/pangram-checker-2.c @@ -0,0 +1,23 @@ +#include + +int pangram(const char *s) +{ + int c, mask = (1 << 26) - 1; + while ((c = (*s++)) != '\0') /* 0x20 converts lowercase to upper */ + if ((c &= ~0x20) <= 'Z' && c >= 'A') + mask &= ~(1 << (c - 'A')); + + return !mask; +} + +int main() +{ + int i; + const char *s[] = { "The quick brown fox jumps over lazy dogs.", + "The five boxing wizards dump quickly.", }; + + for (i = 0; i < 2; i++) + printf("%s: %s\n", pangram(s[i]) ? "yes" : "no ", s[i]); + + return 0; +} diff --git a/Task/Pangram-checker/Clojure/pangram-checker.clj b/Task/Pangram-checker/Clojure/pangram-checker.clj new file mode 100644 index 0000000000..d123c4487b --- /dev/null +++ b/Task/Pangram-checker/Clojure/pangram-checker.clj @@ -0,0 +1,3 @@ +(defn pangram? [s] + (let [letters (into #{} "abcdefghijklmnopqrstuvwxyz")] + (= (->> s .toLowerCase (filter letters) (into #{})) letters))) diff --git a/Task/Pangram-checker/CoffeeScript/pangram-checker.coffeescript b/Task/Pangram-checker/CoffeeScript/pangram-checker.coffeescript new file mode 100644 index 0000000000..d0f1ba04e3 --- /dev/null +++ b/Task/Pangram-checker/CoffeeScript/pangram-checker.coffeescript @@ -0,0 +1,34 @@ +is_pangram = (s) -> + # This is optimized for longish strings--as soon as all 26 letters + # are encountered, we will be done. Our worst case scenario is a really + # long non-pangram, or a really long pangram with at least one letter + # only appearing toward the end of the string. + a_code = 'a'.charCodeAt(0) + required_letters = {} + for i in [a_code...a_code+26] + required_letters[String.fromCharCode(i)] = true + + cnt = 0 + for c in s + c = c.toLowerCase() + if required_letters[c] + cnt += 1 + return true if cnt == 26 + delete required_letters[c] + false + +do -> + tests = [ + ["is this a pangram", false] + ["The quick brown fox jumps over the lazy dog", true] + ] + + for test in tests + [s, exp_value] = test + throw Error("fail") if is_pangram(s) != exp_value + # try long strings + long_str = '' + for i in [1..500000] + long_str += s + throw Error("fail") if is_pangram(long_str) != exp_value + console.log "Passed tests: #{s}" diff --git a/Task/Pangram-checker/Common-Lisp/pangram-checker.lisp b/Task/Pangram-checker/Common-Lisp/pangram-checker.lisp new file mode 100644 index 0000000000..ac80982cfc --- /dev/null +++ b/Task/Pangram-checker/Common-Lisp/pangram-checker.lisp @@ -0,0 +1,4 @@ +(defun pangramp (s) + (null (set-difference + (loop for c from (char-code #\A) upto (char-code #\Z) collect (code-char c)) + (coerce (string-upcase s) 'list)))) diff --git a/Task/Pangram-checker/D/pangram-checker-1.d b/Task/Pangram-checker/D/pangram-checker-1.d new file mode 100644 index 0000000000..dd8d298378 --- /dev/null +++ b/Task/Pangram-checker/D/pangram-checker-1.d @@ -0,0 +1,19 @@ +bool isPangram(in string text) pure nothrow { + uint bitset; + + foreach (c; text) { + if (c >= 'a' && c <= 'z') + bitset |= (1u << (c - 'a')); + else if (c >= 'A' && c <= 'Z') + bitset |= (1u << (c - 'A')); + } + + return bitset == 0b11_11111111_11111111_11111111; +} + +void main() { + assert(isPangram("the quick brown fox jumps over the lazy dog")); + assert(!isPangram("ABCDEFGHIJKLMNOPQSTUVWXYZ")); + assert(!isPangram("ABCDEFGHIJKL.NOPQRSTUVWXYZ")); + assert(isPangram("ABC.D.E.FGHI*J/KL-M+NO*PQ R\nSTUVWXYZ")); +} diff --git a/Task/Pangram-checker/D/pangram-checker-2.d b/Task/Pangram-checker/D/pangram-checker-2.d new file mode 100644 index 0000000000..9a8c645851 --- /dev/null +++ b/Task/Pangram-checker/D/pangram-checker-2.d @@ -0,0 +1,22 @@ +import std.string, std.traits, std.uni; + +// Do not compile with -g (debug info). +enum Alphabet : dstring { + DE = "abcdefghijklmnopqrstuvwxyzßäöü", + EN = "abcdefghijklmnopqrstuvwxyz", + SV = "abcdefghijklmnopqrstuvwxyzåäö" +} + +bool isPangram(S)(in S s, dstring alpha = Alphabet.EN) +pure /*nothrow*/ if (isSomeString!S) { + foreach (dchar c; alpha) + if (indexOf(s, c) == -1 && indexOf(s, std.uni.toUpper(c)) == -1) + return false; + return true; +} + +void main() { + assert(isPangram("the quick brown fox jumps over the lazy dog".dup, Alphabet.EN)); + assert(isPangram("Falsches Üben von Xylophonmusik quält jeden größeren Zwerg"d, Alphabet.DE)); + assert(isPangram("Yxskaftbud, ge vår wczonmö iqhjälp"w, Alphabet.SV)); +} diff --git a/Task/Pangram-checker/Delphi/pangram-checker.delphi b/Task/Pangram-checker/Delphi/pangram-checker.delphi new file mode 100644 index 0000000000..34469f1200 --- /dev/null +++ b/Task/Pangram-checker/Delphi/pangram-checker.delphi @@ -0,0 +1,21 @@ +program PangramChecker; + +{$APPTYPE CONSOLE} + +uses StrUtils; + +function IsPangram(const aString: string): Boolean; +var + c: char; +begin + for c := 'a' to 'z' do + if not ContainsText(aString, c) then + Exit(False); + + Result := True; +end; + +begin + Writeln(IsPangram('The quick brown fox jumps over the lazy dog')); // true + Writeln(IsPangram('Not a panagram')); // false +end. diff --git a/Task/Pangram-checker/E/pangram-checker.e b/Task/Pangram-checker/E/pangram-checker.e new file mode 100644 index 0000000000..1b85fd9ea4 --- /dev/null +++ b/Task/Pangram-checker/E/pangram-checker.e @@ -0,0 +1,3 @@ +def isPangram(sentence :String) { + return ("abcdefghijklmnopqrstuvwxyz".asSet() &! sentence.toLowerCase().asSet()).size() == 0 +} diff --git a/Task/Pangram-checker/Erlang/pangram-checker.erl b/Task/Pangram-checker/Erlang/pangram-checker.erl new file mode 100644 index 0000000000..865628596d --- /dev/null +++ b/Task/Pangram-checker/Erlang/pangram-checker.erl @@ -0,0 +1,5 @@ +-module(pangram). +-export([is_pangram/1]). + +is_pangram(String) -> + ordsets:is_subset(lists:seq($a, $z), ordsets:from_list(string:to_lower(String))). diff --git a/Task/Pangram-checker/Factor/pangram-checker.factor b/Task/Pangram-checker/Factor/pangram-checker.factor new file mode 100644 index 0000000000..1278b0e7eb --- /dev/null +++ b/Task/Pangram-checker/Factor/pangram-checker.factor @@ -0,0 +1,4 @@ +: pangram? ( str -- ? ) + [ "abcdefghijklmnopqrstuvwxyz" ] dip >lower diff length 0 = ; + +"How razorback-jumping frogs can level six piqued gymnasts!" pangram? . diff --git a/Task/Pangram-checker/Forth/pangram-checker.fth b/Task/Pangram-checker/Forth/pangram-checker.fth new file mode 100644 index 0000000000..4902dd7f69 --- /dev/null +++ b/Task/Pangram-checker/Forth/pangram-checker.fth @@ -0,0 +1,10 @@ +: pangram? ( addr len -- ? ) + 0 -rot bounds do + i c@ 32 or [char] a - + dup 0 26 within if + 1 swap lshift or + else drop then + loop + 1 26 lshift 1- = ; + +s" The five boxing wizards jump quickly." pangram? . \ -1 diff --git a/Task/Pangram-checker/Fortran/pangram-checker-1.f b/Task/Pangram-checker/Fortran/pangram-checker-1.f new file mode 100644 index 0000000000..4eb1707c12 --- /dev/null +++ b/Task/Pangram-checker/Fortran/pangram-checker-1.f @@ -0,0 +1,48 @@ +module pangram + + implicit none + private + public :: is_pangram + character (*), parameter :: lower_case = 'abcdefghijklmnopqrstuvwxyz' + character (*), parameter :: upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + +contains + + function to_lower_case (input) result (output) + + implicit none + character (*), intent (in) :: input + character (len (input)) :: output + integer :: i + integer :: j + + output = input + do i = 1, len (output) + j = index (upper_case, output (i : i)) + if (j /= 0) then + output (i : i) = lower_case (j : j) + end if + end do + + end function to_lower_case + + function is_pangram (input) result (output) + + implicit none + character (*), intent (in) :: input + character (len (input)) :: lower_case_input + logical :: output + integer :: i + + lower_case_input = to_lower_case (input) + output = .true. + do i = 1, len (lower_case) + if (index (lower_case_input, lower_case (i : i)) == 0) then + output = .false. + exit + end if + end do + + end function is_pangram + +end module pangram diff --git a/Task/Pangram-checker/Fortran/pangram-checker-2.f b/Task/Pangram-checker/Fortran/pangram-checker-2.f new file mode 100644 index 0000000000..02b7cb6bfb --- /dev/null +++ b/Task/Pangram-checker/Fortran/pangram-checker-2.f @@ -0,0 +1,15 @@ +program test + + use pangram, only: is_pangram + + implicit none + character (256) :: string + + string = 'This is a sentence.' + write (*, '(a)') trim (string) + write (*, '(l1)') is_pangram (string) + string = 'The five boxing wizards jumped quickly.' + write (*, '(a)') trim (string) + write (*, '(l1)') is_pangram (string) + +end program test diff --git a/Task/Pangram-checker/Go/pangram-checker.go b/Task/Pangram-checker/Go/pangram-checker.go new file mode 100644 index 0000000000..a3447fdc3c --- /dev/null +++ b/Task/Pangram-checker/Go/pangram-checker.go @@ -0,0 +1,43 @@ +package main + +import "fmt" + +func main() { + for _, s := range []string{ + "The quick brown fox jumps over the lazy dog.", + `Watch "Jeopardy!", Alex Trebek's fun TV quiz game.`, + "Not a pangram.", + } { + if pangram(s) { + fmt.Println("Yes:", s) + } else { + fmt.Println("No: ", s) + } + } +} + +func pangram(s string) bool { + var rep [26]bool + var count int + for _, c := range s { + if c >= 'a' { + if c > 'z' { + continue + } + c -= 'a' + } else { + if c < 'A' || c > 'Z' { + continue + } + c -= 'A' + } + if !rep[c] { + if count == 25 { + return true + } + rep[c] = true + count++ + } + } + return false +} diff --git a/Task/Pangram-checker/Haskell/pangram-checker.hs b/Task/Pangram-checker/Haskell/pangram-checker.hs new file mode 100644 index 0000000000..81d595b64a --- /dev/null +++ b/Task/Pangram-checker/Haskell/pangram-checker.hs @@ -0,0 +1,7 @@ +import Data.Char (toLower) +import Data.List ((\\)) + +pangram :: String -> Bool +pangram = null . (['a' .. 'z'] \\) . map toLower + +main = print $ pangram "How razorback-jumping frogs can level six piqued gymnasts!" diff --git a/Task/Pangram-checker/HicEst/pangram-checker.hicest b/Task/Pangram-checker/HicEst/pangram-checker.hicest new file mode 100644 index 0000000000..93f52f6da1 --- /dev/null +++ b/Task/Pangram-checker/HicEst/pangram-checker.hicest @@ -0,0 +1,8 @@ +PangramBrokenAt("This is a Pangram.") ! => 2 (b is missing) +PangramBrokenAt("The quick Brown Fox jumps over the Lazy Dog") ! => 0 (OK) + +FUNCTION PangramBrokenAt(string) + CHARACTER string, Alfabet="abcdefghijklmnopqrstuvwxyz" + PangramBrokenAt = INDEX(Alfabet, string, 64) + ! option 64: verify = 1st letter of string not in Alfabet +END diff --git a/Task/Pangram-checker/Icon/pangram-checker-1.icon b/Task/Pangram-checker/Icon/pangram-checker-1.icon new file mode 100644 index 0000000000..89ef85276b --- /dev/null +++ b/Task/Pangram-checker/Icon/pangram-checker-1.icon @@ -0,0 +1,3 @@ +procedure panagram(s) #: return s if s is a panagram and fail otherwise +if (map(s) ** &lcase) === &lcase then return s +end diff --git a/Task/Pangram-checker/Icon/pangram-checker-2.icon b/Task/Pangram-checker/Icon/pangram-checker-2.icon new file mode 100644 index 0000000000..419e141273 --- /dev/null +++ b/Task/Pangram-checker/Icon/pangram-checker-2.icon @@ -0,0 +1,11 @@ +procedure main(arglist) + +if *arglist > 0 then + every ( s := "" ) ||:= !arglist || " " +else + s := "The quick brown fox jumps over the lazy dog." + +writes(image(s), " -- is") +writes(if not panagram(s) then "n't") +write(" a panagram.") +end diff --git a/Task/Pangram-checker/Ioke/pangram-checker-1.ioke b/Task/Pangram-checker/Ioke/pangram-checker-1.ioke new file mode 100644 index 0000000000..22607deab0 --- /dev/null +++ b/Task/Pangram-checker/Ioke/pangram-checker-1.ioke @@ -0,0 +1,5 @@ +Text isPangram? = method( + letters = "abcdefghijklmnopqrstuvwxyz" chars + text = self lower chars + letters map(x, text include?(x)) reduce(&&) +) diff --git a/Task/Pangram-checker/Ioke/pangram-checker-2.ioke b/Task/Pangram-checker/Ioke/pangram-checker-2.ioke new file mode 100644 index 0000000000..f5907d69d4 --- /dev/null +++ b/Task/Pangram-checker/Ioke/pangram-checker-2.ioke @@ -0,0 +1,7 @@ +iik> "The quick brown fox jumps over the lazy dog" isPangram? +"The quick brown fox jumps over the lazy dog" isPangram? ++> true + +iik> "The quick brown fox jumps over the" isPangram? +"The quick brown fox jumps over the" isPangram? ++> false diff --git a/Task/Pangram-checker/J/pangram-checker-1.j b/Task/Pangram-checker/J/pangram-checker-1.j new file mode 100644 index 0000000000..696d7d8826 --- /dev/null +++ b/Task/Pangram-checker/J/pangram-checker-1.j @@ -0,0 +1,2 @@ +require 'strings' +isPangram=: (a. {~ 97+i.26) */@e. tolower diff --git a/Task/Pangram-checker/J/pangram-checker-2.j b/Task/Pangram-checker/J/pangram-checker-2.j new file mode 100644 index 0000000000..ec1c2da291 --- /dev/null +++ b/Task/Pangram-checker/J/pangram-checker-2.j @@ -0,0 +1,4 @@ + isPangram 'The quick brown fox jumps over the lazy dog.' +1 + isPangram 'The quick brown fox falls over the lazy dog.' +0 diff --git a/Task/Pangram-checker/Java/pangram-checker.java b/Task/Pangram-checker/Java/pangram-checker.java new file mode 100644 index 0000000000..627ab54aa0 --- /dev/null +++ b/Task/Pangram-checker/Java/pangram-checker.java @@ -0,0 +1,18 @@ +public class Pangram { + public static boolean isPangram(String test){ + for (char a = 'A'; a <= 'Z'; a++) + if ((test.indexOf(a) < 0) && (test.indexOf((char)(a + 32)) < 0)) + return false; + return true; + } + + public static void main(String[] args){ + System.out.println(isPangram("the quick brown fox jumps over the lazy dog"));//true + System.out.println(isPangram("the quick brown fox jumped over the lazy dog"));//false, no s + System.out.println(isPangram("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));//true + System.out.println(isPangram("ABCDEFGHIJKLMNOPQSTUVWXYZ"));//false, no r + System.out.println(isPangram("ABCDEFGHIJKL.NOPQRSTUVWXYZ"));//false, no m + System.out.println(isPangram("ABC.D.E.FGHI*J/KL-M+NO*PQ R\nSTUVWXYZ"));//true + System.out.println(isPangram(""));//false + } +} diff --git a/Task/Pangram-checker/JavaScript/pangram-checker.js b/Task/Pangram-checker/JavaScript/pangram-checker.js new file mode 100644 index 0000000000..433e331cce --- /dev/null +++ b/Task/Pangram-checker/JavaScript/pangram-checker.js @@ -0,0 +1,12 @@ +function is_pangram(str) { + var s = str.toLowerCase(); + // sorted by frequency ascending (http://en.wikipedia.org/wiki/Letter_frequency) + var letters = "zqxjkvbpygfwmucldrhsnioate"; + for (var i = 0; i < 26; i++) + if (s.indexOf(letters.charAt(i)) == -1) + return false; + return true; +} + +print(is_pangram("is this a pangram")); // false +print(is_pangram("The quick brown fox jumps over the lazy dog")); // true diff --git a/Task/Pangram-checker/K/pangram-checker-1.k b/Task/Pangram-checker/K/pangram-checker-1.k new file mode 100644 index 0000000000..351ecf9658 --- /dev/null +++ b/Task/Pangram-checker/K/pangram-checker-1.k @@ -0,0 +1,4 @@ +lcase : _ci 97+!26 +ucase : _ci 65+!26 +tolower : {@[x;p;:;lcase@n@p:&26>n:ucase?/:x]} +panagram: {&/lcase _lin tolower x} diff --git a/Task/Pangram-checker/K/pangram-checker-2.k b/Task/Pangram-checker/K/pangram-checker-2.k new file mode 100644 index 0000000000..7e1d16b511 --- /dev/null +++ b/Task/Pangram-checker/K/pangram-checker-2.k @@ -0,0 +1,4 @@ + panagram "The quick brown fox jumps over the lazy dog" +1 + panagram "Panagram test" +0 diff --git a/Task/Pangram-checker/Liberty-BASIC/pangram-checker.liberty b/Task/Pangram-checker/Liberty-BASIC/pangram-checker.liberty new file mode 100644 index 0000000000..e5c9340938 --- /dev/null +++ b/Task/Pangram-checker/Liberty-BASIC/pangram-checker.liberty @@ -0,0 +1,12 @@ +'Returns 0 if the string is NOT a pangram or >0 if it IS a pangram +string$ = "The quick brown fox jumps over the lazy dog." + +Print isPangram(string$) + +Function isPangram(string$) + string$ = Lower$(string$) + For i = Asc("a") To Asc("z") + isPangram = Instr(string$, chr$(i)) + If isPangram = 0 Then Exit Function + Next i +End Function diff --git a/Task/Pangram-checker/Logo/pangram-checker.logo b/Task/Pangram-checker/Logo/pangram-checker.logo new file mode 100644 index 0000000000..dfc4341bb0 --- /dev/null +++ b/Task/Pangram-checker/Logo/pangram-checker.logo @@ -0,0 +1,10 @@ +to remove.all :s :set + if empty? :s [output :set] + if word? :s [output remove.all butfirst :s remove first :s :set] + output remove.all butfirst :s remove.all first :s :set +end +to pangram? :s + output empty? remove.all :s "abcdefghijklmnopqrstuvwxyz +end + +show pangram? [The five boxing wizards jump quickly.] ; true diff --git a/Task/Pangram-checker/Lua/pangram-checker.lua b/Task/Pangram-checker/Lua/pangram-checker.lua new file mode 100644 index 0000000000..16a1f4ad56 --- /dev/null +++ b/Task/Pangram-checker/Lua/pangram-checker.lua @@ -0,0 +1,9 @@ +require"lpeg" +S, C = lpeg.S, lpeg.C +function ispangram(s) + return #(C(S(s)^0):match"abcdefghijklmnopqrstuvwxyz") == 26 +end + +print(ispangram"waltz, bad nymph, for quick jigs vex") +print(ispangram"bobby") +print(ispangram"long sentence") diff --git a/Task/Pangram-checker/MATLAB/pangram-checker-1.m b/Task/Pangram-checker/MATLAB/pangram-checker-1.m new file mode 100644 index 0000000000..ee840c0a83 --- /dev/null +++ b/Task/Pangram-checker/MATLAB/pangram-checker-1.m @@ -0,0 +1,12 @@ +function trueFalse = isPangram(string) + + %This works by histogramming the ascii character codes for lower case + %letters contained in the string (which is first converted to all + %lower case letters). Then it finds the index of the first letter that + %is not contained in the string (this is faster than using the find + %without the second parameter). If the find returns an empty array then + %the original string is a pangram, if not then it isn't. + + trueFalse = isempty(find( histc(lower(string),(97:122))==0,1 )); + +end diff --git a/Task/Pangram-checker/MATLAB/pangram-checker-2.m b/Task/Pangram-checker/MATLAB/pangram-checker-2.m new file mode 100644 index 0000000000..9e69004216 --- /dev/null +++ b/Task/Pangram-checker/MATLAB/pangram-checker-2.m @@ -0,0 +1,5 @@ +isPangram('The quick brown fox jumps over the lazy dog.') + +ans = + + 1 diff --git a/Task/Pangram-checker/MATLAB/pangram-checker.m b/Task/Pangram-checker/MATLAB/pangram-checker.m new file mode 100644 index 0000000000..3222d45fc3 --- /dev/null +++ b/Task/Pangram-checker/MATLAB/pangram-checker.m @@ -0,0 +1,5 @@ +function trueFalse = isPangram(string) + % X is a histogram of letters + X = sparse(abs(lower(string)),1,1,128,1); + trueFalse = full(all(X('a':'z') > 0)); +end diff --git a/Task/Pangram-checker/Mathematica/pangram-checker.math b/Task/Pangram-checker/Mathematica/pangram-checker.math new file mode 100644 index 0000000000..cd4d4e9b81 --- /dev/null +++ b/Task/Pangram-checker/Mathematica/pangram-checker.math @@ -0,0 +1 @@ +pangramQ[msg_]:=Complement[CharacterRange["a", "z"], Characters[ToLowerCase[msg]]]=== {} diff --git a/Task/Pangram-checker/NetRexx/pangram-checker.netrexx b/Task/Pangram-checker/NetRexx/pangram-checker.netrexx new file mode 100644 index 0000000000..d4894e0f4d --- /dev/null +++ b/Task/Pangram-checker/NetRexx/pangram-checker.netrexx @@ -0,0 +1,29 @@ +/* NetRexx */ +options replace format comments java crossref savelog symbols nobinary + +A2Z = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + +pangrams = create_samples + +loop p_ = 1 to pangrams[0] + pangram = pangrams[p_] + q_ = A2Z.verify(pangram.upper) -- <= it basically all happens in this function call! + say pangram.left(64)'\-' + if q_ == 0 then - + say ' [OK, a pangram]' + else - + say ' [Not a pangram. Missing:' A2Z.substr(q_, 1)']' + end p_ + +method create_samples public static returns Rexx + + pangrams = '' + + x_ = 0 + x_ = x_ + 1; pangrams[0] = x_; pangrams[x_] = 'The quick brown fox jumps over a lazy dog.' -- best/shortest pangram + x_ = x_ + 1; pangrams[0] = x_; pangrams[x_] = 'The quick brown fox jumps over the lazy dog.' -- not as short but at least it's still a pangram + x_ = x_ + 1; pangrams[0] = x_; pangrams[x_] = 'The quick brown fox jumped over the lazy dog.' -- common misquote; not a pangram + x_ = x_ + 1; pangrams[0] = x_; pangrams[x_] = 'The quick onyx goblin jumps over the lazy dwarf.' + x_ = x_ + 1; pangrams[0] = x_; pangrams[x_] = 'Bored? Craving a pub quiz fix? Why, just come to the Royal Oak!' -- (Used to advertise a pub quiz in Bowness-on-Windermere) + + return pangrams diff --git a/Task/Pangram-checker/OCaml/pangram-checker-1.ocaml b/Task/Pangram-checker/OCaml/pangram-checker-1.ocaml new file mode 100644 index 0000000000..295796f999 --- /dev/null +++ b/Task/Pangram-checker/OCaml/pangram-checker-1.ocaml @@ -0,0 +1,7 @@ +let pangram str = + let ar = Array.make 26 false in + String.iter (function + | 'a'..'z' as c -> ar.(Char.code c - Char.code 'a') <- true + | _ -> () + ) (String.lowercase str); + Array.fold_left ( && ) true ar diff --git a/Task/Pangram-checker/OCaml/pangram-checker-2.ocaml b/Task/Pangram-checker/OCaml/pangram-checker-2.ocaml new file mode 100644 index 0000000000..db6b7b94ac --- /dev/null +++ b/Task/Pangram-checker/OCaml/pangram-checker-2.ocaml @@ -0,0 +1,7 @@ +let check str = + Printf.printf " %b -- %s\n" (pangram str) str + +let () = + check "this is a sentence"; + check "The quick brown fox jumps over the lazy dog."; +;; diff --git a/Task/Pangram-checker/Objeck/pangram-checker.objeck b/Task/Pangram-checker/Objeck/pangram-checker.objeck new file mode 100644 index 0000000000..ba0e30df04 --- /dev/null +++ b/Task/Pangram-checker/Objeck/pangram-checker.objeck @@ -0,0 +1,23 @@ +bundle Default { + class Pangram { + function : native : IsPangram(test : String) ~ Bool { + for(a := 'A'; a <= 'Z'; a += 1;) { + if(test->Find(a) < 0 & test->Find(a->ToLower()) < 0) { + return false; + }; + }; + + return true; + } + + function : Main(args : String[]) ~ Nil { + IsPangram("the quick brown fox jumps over the lazy dog")->PrintLine(); # true + IsPangram("the quick brown fox jumped over the lazy dog")->PrintLine(); # false, no s + IsPangram("ABCDEFGHIJKLMNOPQRSTUVWXYZ")->PrintLine(); # true + IsPangram("ABCDEFGHIJKLMNOPQSTUVWXYZ")->PrintLine(); # false, no r + IsPangram("ABCDEFGHIJKL.NOPQRSTUVWXYZ")->PrintLine(); # false, no m + IsPangram("ABC.D.E.FGHI*J/KL-M+NO*PQ R\nSTUVWXYZ")->PrintLine(); # true + IsPangram("")->PrintLine(); # false + } + } +} diff --git a/Task/Pangram-checker/Oz/pangram-checker.oz b/Task/Pangram-checker/Oz/pangram-checker.oz new file mode 100644 index 0000000000..75f03760b8 --- /dev/null +++ b/Task/Pangram-checker/Oz/pangram-checker.oz @@ -0,0 +1,8 @@ +declare + fun {IsPangram Xs} + {List.sub + {List.number &a &z 1} + {Sort {Map Xs Char.toLower} Value.'<'}} + end +in + {Show {IsPangram "The quick brown fox jumps over the lazy dog."}} diff --git a/Task/Pangram-checker/PARI-GP/pangram-checker.pari b/Task/Pangram-checker/PARI-GP/pangram-checker.pari new file mode 100644 index 0000000000..160e413868 --- /dev/null +++ b/Task/Pangram-checker/PARI-GP/pangram-checker.pari @@ -0,0 +1,12 @@ +pangram(s)={ + s=vecsort(Vec(s),,8); + for(i=97,122, + if(!setsearch(s,Strchr(i)) && !setsearch(s,Strchr(i-32)), + return(0) + ) + ); + 1 +}; + +pangram("The quick brown fox jumps over the lazy dog.") +pangram("The quick brown fox jumps over the lazy doe.") diff --git a/Task/Pangram-checker/PHP/pangram-checker.php b/Task/Pangram-checker/PHP/pangram-checker.php new file mode 100644 index 0000000000..0234c70ad2 --- /dev/null +++ b/Task/Pangram-checker/PHP/pangram-checker.php @@ -0,0 +1,20 @@ +function isPangram($text) { + foreach (str_split($text) as $c) { + if ($c >= 'a' && $c <= 'z') + $bitset |= (1 << (ord($c) - ord('a'))); + else if ($c >= 'A' && $c <= 'Z') + $bitset |= (1 << (ord($c) - ord('A'))); + } + return $bitset == 0x3ffffff; +} + +$test = array( + "the quick brown fox jumps over the lazy dog", + "the quick brown fox jumped over the lazy dog", + "ABCDEFGHIJKLMNOPQSTUVWXYZ", + "ABCDEFGHIJKL.NOPQRSTUVWXYZ", + "ABC.D.E.FGHI*J/KL-M+NO*PQ R\nSTUVWXYZ" +); + +foreach ($test as $str) + echo "$str : ", isPangram($str) ? 'T' : 'F', '
'; diff --git a/Task/Pangram-checker/PL-I/pangram-checker.pli b/Task/Pangram-checker/PL-I/pangram-checker.pli new file mode 100644 index 0000000000..81eb5bf0ec --- /dev/null +++ b/Task/Pangram-checker/PL-I/pangram-checker.pli @@ -0,0 +1,28 @@ +test_pangram: procedure options (main); + +is_pangram: procedure() returns (bit(1) aligned); + + declare text character (200) varying; + declare c character (1); + + get edit (text) (L); + put skip list (text); + + text = lowercase(text); + + do c = 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', + 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', + 'v', 'w', 'x', 'y', 'z'; + if index(text, c) = 0 then return ('0'b); + end; + return ('1'b); +end is_pangram; + + put skip list ('Please type a sentence'); + + if is_pangram() then + put skip list ('The sentence is a pangram.'); + else + put skip list ('The sentence is not a pangram.'); + +end test_pangram; diff --git a/Task/Pangram-checker/Perl-6/pangram-checker.pl6 b/Task/Pangram-checker/Perl-6/pangram-checker.pl6 new file mode 100644 index 0000000000..de211120b5 --- /dev/null +++ b/Task/Pangram-checker/Perl-6/pangram-checker.pl6 @@ -0,0 +1,13 @@ +constant Eng = set 'a' .. 'z'; +constant Cyr = set <а б в г д е ж з и й к л м н о п р с т у ф х ц ч ш щ ъ ы ь э ю я ё>; +constant Hex = set 'a' .. 'f'; + +sub pangram($str, Set $alpha = Eng) { + $alpha ⊆ $str.lc.comb; +} + +say pangram("The quick brown fox jumps over the lazy dog."); +say pangram("My dog has fleas."); +say pangram("My dog has fleas.", Hex); +say pangram("My dog backs fleas.", Hex); +say pangram "Съешь же ещё этих мягких французских булок, да выпей чаю", Cyr; diff --git a/Task/Pangram-checker/Perl/pangram-checker.pl b/Task/Pangram-checker/Perl/pangram-checker.pl new file mode 100644 index 0000000000..3cc6a8f715 --- /dev/null +++ b/Task/Pangram-checker/Perl/pangram-checker.pl @@ -0,0 +1,5 @@ +use List::MoreUtils 'all'; + +sub pangram {all {$_[0] =~ /$_/i} 'a' .. 'z';} + +print "Yes.\n" if pangram 'Cozy lummox gives smart squid who asks for job pen.'; diff --git a/Task/Pangram-checker/PicoLisp/pangram-checker.l b/Task/Pangram-checker/PicoLisp/pangram-checker.l new file mode 100644 index 0000000000..c0572de976 --- /dev/null +++ b/Task/Pangram-checker/PicoLisp/pangram-checker.l @@ -0,0 +1,5 @@ +(de isPangram (Str) + (not + (diff + '`(chop "abcdefghijklmnopqrstuvwxyz") + (chop (lowc Str)) ) ) ) diff --git a/Task/Pangram-checker/Prolog/pangram-checker.pro b/Task/Pangram-checker/Prolog/pangram-checker.pro new file mode 100644 index 0000000000..e286f00a2b --- /dev/null +++ b/Task/Pangram-checker/Prolog/pangram-checker.pro @@ -0,0 +1,12 @@ +pangram(L) :- + numlist(0'a, 0'z, Alphabet), + forall(member(C, Alphabet), member(C, L)). + +pangram_example :- + L1 = "the quick brown fox jumps over the lazy dog", + ( pangram(L1) -> R1= ok; R1 = ko), + format('~s --> ~w ~n', [L1,R1]), + + L2 = "the quick brown fox jumped over the lazy dog", + ( pangram(L2) -> R2 = ok; R2 = ko), + format('~s --> ~w ~n', [L2, R2]). diff --git a/Task/Pangram-checker/PureBasic/pangram-checker.purebasic b/Task/Pangram-checker/PureBasic/pangram-checker.purebasic new file mode 100644 index 0000000000..20eb6b36fe --- /dev/null +++ b/Task/Pangram-checker/PureBasic/pangram-checker.purebasic @@ -0,0 +1,31 @@ +Procedure IsPangram_fast(String$) + String$ = LCase(string$) + char_a=Asc("a") + ; sets bits in a variable if a letter is found, reads string only once + For a = 1 To Len(string$) + char$ = Mid(String$, a, 1) + pos = Asc(char$) - char_a + check.l | 1 << pos + Next + If check & $3FFFFFF = $3FFFFFF + ProcedureReturn 1 + EndIf + ProcedureReturn 0 +EndProcedure + +Procedure IsPangram_simple(String$) + String$ = LCase(string$) + found = 1 + For a = Asc("a") To Asc("z") + ; searches for every letter in whole string + If FindString(String$, Chr(a), 0) = 0 + found = 0 + EndIf + Next + ProcedureReturn found +EndProcedure + +Debug IsPangram_fast("The quick brown fox jumps over lazy dogs.") +Debug IsPangram_simple("The quick brown fox jumps over lazy dogs.") +Debug IsPangram_fast("No pangram") +Debug IsPangram_simple("No pangram") diff --git a/Task/Pangram-checker/Python/pangram-checker.py b/Task/Pangram-checker/Python/pangram-checker.py new file mode 100644 index 0000000000..e927688871 --- /dev/null +++ b/Task/Pangram-checker/Python/pangram-checker.py @@ -0,0 +1,9 @@ +import string, sys +if sys.version_info[0] < 3: + input = raw_input + +def ispangram(sentence, alphabet=string.ascii_lowercase): + alphaset = set(alphabet) + return alphaset <= set(sentence.lower()) + +print ( ispangram(input('Sentence: ')) ) diff --git a/Task/Pangram-checker/R/pangram-checker.r b/Task/Pangram-checker/R/pangram-checker.r new file mode 100644 index 0000000000..1b4bada6d3 --- /dev/null +++ b/Task/Pangram-checker/R/pangram-checker.r @@ -0,0 +1,10 @@ +checkPangram <- function(sentence){ + my.letters <- tolower(unlist(strsplit(sentence, ""))) + is.pangram <- all(letters %in% my.letters) + + if (is.pangram){ + cat("\"", sentence, "\" is a pangram! \n", sep="") + } else { + cat("\"", sentence, "\" is not a pangram! \n", sep="") + } +} diff --git a/Task/Pangram-checker/REXX/pangram-checker.rexx b/Task/Pangram-checker/REXX/pangram-checker.rexx new file mode 100644 index 0000000000..80e9c1a15c --- /dev/null +++ b/Task/Pangram-checker/REXX/pangram-checker.rexx @@ -0,0 +1,16 @@ +/*REXX program to check if an entered string (sentence) is a pangram. */ +abc='ABCDEFGHIJKLMNOPQRSTUVWXYZ' + + do forever /*keep prompting until a null or blank(s). */ + say; say '───── Please enter a pangramic sentence:'; say + pull y /*this also uppercases the Y variable. */ + if y='' then leave /*if nothing entered, then we're done. */ + ?=verify(abc,y) /*see if all (Latin) letters are present. */ + + if ?==0 then say 'Sentence is a pangram.' + else say "Sentence isn't a pangram, missing:" substr(abc,?,1) + say + end /*forever*/ + +say '───── PANGRAM program ended. ─────' + /*stick a fork in it, we're done.*/ diff --git a/Task/Pangram-checker/Retro/pangram-checker.retro b/Task/Pangram-checker/Retro/pangram-checker.retro new file mode 100644 index 0000000000..d5e061c0a0 --- /dev/null +++ b/Task/Pangram-checker/Retro/pangram-checker.retro @@ -0,0 +1,5 @@ +: isPangram? ( $-f ) + ^strings'toLower + heap [ 27 allot ] preserve + [ @ 'a - dup 0 25 within [ [ 'a + ] [ here + ] bi ! ] &drop if ] + ^types'STRING each@ here "abcdefghijklmnopqrstuvwxyz" compare ; diff --git a/Task/Pangram-checker/Ruby/pangram-checker.rb b/Task/Pangram-checker/Ruby/pangram-checker.rb new file mode 100644 index 0000000000..a5b86c6e77 --- /dev/null +++ b/Task/Pangram-checker/Ruby/pangram-checker.rb @@ -0,0 +1,7 @@ +def pangram?(sentence) + unused_letters = ('a'..'z').to_a - sentence.downcase.chars.to_a + unused_letters.empty? +end + +p pangram?('this is a sentence') # ==> false +p pangram?('The quick brown fox jumps over the lazy dog.') # ==> true diff --git a/Task/Pangram-checker/Run-BASIC/pangram-checker.run b/Task/Pangram-checker/Run-BASIC/pangram-checker.run new file mode 100644 index 0000000000..cd7054bae2 --- /dev/null +++ b/Task/Pangram-checker/Run-BASIC/pangram-checker.run @@ -0,0 +1,13 @@ +s$ = "The quick brown fox jumps over the lazy dog." +Print pangram(s$);" ";s$ + +s$ = "My dog has fleas." +Print pangram(s$);" ";s$ + +function pangram(str$) + str$ = lower$(str$) + for i = asc("a") to asc("z") + pangram = pangram + (instr(str$, chr$(i)) <> 0) + next i +pangram = (pangram = 26) +end function diff --git a/Task/Pangram-checker/SNOBOL4/pangram-checker.sno b/Task/Pangram-checker/SNOBOL4/pangram-checker.sno new file mode 100644 index 0000000000..b31a3aa978 --- /dev/null +++ b/Task/Pangram-checker/SNOBOL4/pangram-checker.sno @@ -0,0 +1,18 @@ + define('pangram(str)alfa,c') :(pangram_end) +pangram str = replace(str,&ucase,&lcase) + alfa = &lcase +pgr_1 alfa len(1) . c = :f(return) + str c :s(pgr_1)f(freturn) +pangram_end + + define('panchk(str)tf') :(panchk_end) +panchk output = str + tf = 'False'; tf = pangram(str) 'True' + output = 'Pangram: ' tf :(return) +panchk_end + +* # Test and display + panchk("The quick brown fox jumped over the lazy dogs.") + panchk("My girl wove six dozen plaid jackets before she quit.") + panchk("This 41-character string: it's a pangram!") +end diff --git a/Task/Pangram-checker/Scala/pangram-checker-1.scala b/Task/Pangram-checker/Scala/pangram-checker-1.scala new file mode 100644 index 0000000000..93f2c8efc2 --- /dev/null +++ b/Task/Pangram-checker/Scala/pangram-checker-1.scala @@ -0,0 +1 @@ +def is_pangram(sentence: String) = sentence.toLowerCase.filter(c => c >= 'a' && c <= 'z').toSet.size == 26 diff --git a/Task/Pangram-checker/Scala/pangram-checker-2.scala b/Task/Pangram-checker/Scala/pangram-checker-2.scala new file mode 100644 index 0000000000..2097bcd7a9 --- /dev/null +++ b/Task/Pangram-checker/Scala/pangram-checker-2.scala @@ -0,0 +1,5 @@ +scala> is_pangram("This is a sentence") +res0: Boolean = false + +scala> is_pangram("The quick brown fox jumps over the lazy dog") +res1: Boolean = true diff --git a/Task/Pangram-checker/Seed7/pangram-checker.seed7 b/Task/Pangram-checker/Seed7/pangram-checker.seed7 new file mode 100644 index 0000000000..da02782021 --- /dev/null +++ b/Task/Pangram-checker/Seed7/pangram-checker.seed7 @@ -0,0 +1,24 @@ +$ include "seed7_05.s7i"; + +const func boolean: isPangram (in string: stri) is func + result + var boolean: isPangram is FALSE; + local + var char: ch is ' '; + var set of char: usedChars is (set of char).value; + begin + for ch range lower(stri) do + if ch in {'a' .. 'z'} then + incl(usedChars, ch); + end if; + end for; + isPangram := usedChars = {'a' .. 'z'}; + end func; + +const proc: main is func + begin + writeln(isPangram("This is a test")); + writeln(isPangram("The quick brown fox jumps over the lazy dog")); + writeln(isPangram("NOPQRSTUVWXYZ abcdefghijklm")); + writeln(isPangram("abcdefghijklopqrstuvwxyz")); # Missing m, n + end func; diff --git a/Task/Pangram-checker/Smalltalk/pangram-checker-1.st b/Task/Pangram-checker/Smalltalk/pangram-checker-1.st new file mode 100644 index 0000000000..0e0d0f4385 --- /dev/null +++ b/Task/Pangram-checker/Smalltalk/pangram-checker-1.st @@ -0,0 +1,3 @@ +!String methodsFor: 'testing'! +isPangram + ^((self collect: [:c | c asUppercase]) select: [:c | c >= $A and: [c <= $Z]]) asSet size = 26 diff --git a/Task/Pangram-checker/Smalltalk/pangram-checker-2.st b/Task/Pangram-checker/Smalltalk/pangram-checker-2.st new file mode 100644 index 0000000000..28c8fea154 --- /dev/null +++ b/Task/Pangram-checker/Smalltalk/pangram-checker-2.st @@ -0,0 +1 @@ +'The quick brown fox jumps over the lazy dog.' isPangram diff --git a/Task/Pangram-checker/TUSCRIPT/pangram-checker.tuscript b/Task/Pangram-checker/TUSCRIPT/pangram-checker.tuscript new file mode 100644 index 0000000000..5ce64e7c67 --- /dev/null +++ b/Task/Pangram-checker/TUSCRIPT/pangram-checker.tuscript @@ -0,0 +1,13 @@ +$$ MODE TUSCRIPT,{} +alfabet="abcdefghijklmnopqrstuvwxyz" +sentences = * +DATA The quick brown fox jumps over the lazy dog +DATA the quick brown fox falls over the lazy dog +LOOP s=sentences + getchars =STRINGS (s," {&a} ") + sortchars =ALPHA_SORT (getchars) + reducechars =REDUCE (sortchars) + chars_in_s =EXCHANGE (reducechars," ' ") + IF (chars_in_s==alfabet) PRINT " pangram: ",s + IF (chars_in_s!=alfabet) PRINT "no pangram: ",s +ENDLOOP diff --git a/Task/Pangram-checker/TXR/pangram-checker.txr b/Task/Pangram-checker/TXR/pangram-checker.txr new file mode 100644 index 0000000000..ba3122590c --- /dev/null +++ b/Task/Pangram-checker/TXR/pangram-checker.txr @@ -0,0 +1,7 @@ +@/.*[Aa].*&.*[Bb].*&.*[Cc].*&.*[Dd].*& \ + .*[Ee].*&.*[Ff].*&.*[Gg].*&.*[Hh].*& \ + .*[Ii].*&.*[Jj].*&.*[Kk].*&.*[Ll].*& \ + .*[Mm].*&.*[Nn].*&.*[Oo].*&.*[Pp].*& \ + .*[Qq].*&.*[Rr].*&.*[Ss].*&.*[Tt].*& \ + .*[Uu].*&.*[Vv].*&.*[Ww].*&.*[Xx].*& \ + .*[Yy].*&.*[Zz].*/ diff --git a/Task/Pangram-checker/Tcl/pangram-checker.tcl b/Task/Pangram-checker/Tcl/pangram-checker.tcl new file mode 100644 index 0000000000..2a81912bf7 --- /dev/null +++ b/Task/Pangram-checker/Tcl/pangram-checker.tcl @@ -0,0 +1,9 @@ +proc pangram? {sentence} { + set letters [regexp -all -inline {[a-z]} [string tolower $sentence]] + expr { + [llength [lsort -unique $letters]] == 26 + } +} + +puts [pangram? "This is a sentence"]; # ==> false +puts [pangram? "The quick brown fox jumps over the lazy dog."]; # ==> true diff --git a/Task/Pangram-checker/UNIX-Shell/pangram-checker.sh b/Task/Pangram-checker/UNIX-Shell/pangram-checker.sh new file mode 100644 index 0000000000..aeaa028fb0 --- /dev/null +++ b/Task/Pangram-checker/UNIX-Shell/pangram-checker.sh @@ -0,0 +1,11 @@ +function pangram? { + local alphabet=abcdefghijklmnopqrstuvwxyz + local string="$*" + string="${string,,}" + while [[ -n "$string" && -n "$alphabet" ]]; do + local ch="${string%%${string#?}}" + string="${string#?}" + alphabet="${alphabet/$ch}" + done + [[ -z "$alphabet" ]] +} diff --git a/Task/Pangram-checker/Ursala/pangram-checker-1.ursala b/Task/Pangram-checker/Ursala/pangram-checker-1.ursala new file mode 100644 index 0000000000..e53efddd6e --- /dev/null +++ b/Task/Pangram-checker/Ursala/pangram-checker-1.ursala @@ -0,0 +1,3 @@ +#import std + +is_pangram = ^jZ^(!@l,*+ @rlp -:~&) ~=`A-~ letters diff --git a/Task/Pangram-checker/Ursala/pangram-checker-2.ursala b/Task/Pangram-checker/Ursala/pangram-checker-2.ursala new file mode 100644 index 0000000000..f1975a1780 --- /dev/null +++ b/Task/Pangram-checker/Ursala/pangram-checker-2.ursala @@ -0,0 +1,7 @@ +#cast %bL + +test = + +is_pangram* < + 'The quick brown fox jumps over the lazy dog', + 'this is not a pangram'> diff --git a/Task/Pangram-checker/VBA/pangram-checker.vba b/Task/Pangram-checker/VBA/pangram-checker.vba new file mode 100644 index 0000000000..ed47c9e62a --- /dev/null +++ b/Task/Pangram-checker/VBA/pangram-checker.vba @@ -0,0 +1,14 @@ +Function pangram2(s As String) As Boolean + Const sKey As String = "abcdefghijklmnopqrstuvwxyz" + Dim sLow As String + Dim i As Integer + + sLow = LCase(s) + For i = 1 To 26 + If InStr(sLow, Mid(sKey, i, 1)) = 0 Then + pangram2 = False + Exit Function + End If + Next + pangram2 = True +End Function diff --git a/Task/Pangram-checker/VBScript/pangram-checker-1.vbscript b/Task/Pangram-checker/VBScript/pangram-checker-1.vbscript new file mode 100644 index 0000000000..e5e798e246 --- /dev/null +++ b/Task/Pangram-checker/VBScript/pangram-checker-1.vbscript @@ -0,0 +1,29 @@ +function pangram( s ) + dim i + dim sKey + dim sChar + dim nOffset + sKey = "abcdefghijklmnopqrstuvwxyz" + for i = 1 to len( s ) + sChar = lcase(mid(s,i,1)) + if sChar <> " " then + if instr(sKey, sChar) then + nOffset = asc( sChar ) - asc("a") + 1 + if nOffset > 1 then + sKey = left(sKey, nOffset - 1) & " " & mid( sKey, nOffset + 1) + else + sKey = " " & mid( sKey, nOffset + 1) + end if + end if + end if + next + pangram = ( ltrim(sKey) = vbnullstring ) +end function + +function eef( bCond, exp1, exp2 ) + if bCond then + eef = exp1 + else + eef = exp2 + end if +end function diff --git a/Task/Pangram-checker/VBScript/pangram-checker-2.vbscript b/Task/Pangram-checker/VBScript/pangram-checker-2.vbscript new file mode 100644 index 0000000000..eb623796bc --- /dev/null +++ b/Task/Pangram-checker/VBScript/pangram-checker-2.vbscript @@ -0,0 +1,2 @@ +wscript.echo eef(pangram("a quick brown fox jumps over the lazy dog"), "is a pangram", "is not a pangram") +wscript.echo eef(pangram(""), "is a pangram", "is not a pangram")" diff --git a/Task/Pangram-checker/XPL0/pangram-checker.xpl0 b/Task/Pangram-checker/XPL0/pangram-checker.xpl0 new file mode 100644 index 0000000000..ab935a80d9 --- /dev/null +++ b/Task/Pangram-checker/XPL0/pangram-checker.xpl0 @@ -0,0 +1,31 @@ +include c:\cxpl\codes; \intrinsic 'code' declarations +string 0; \use zero-terminated strings + +func StrLen(Str); \Return number of characters in an ASCIIZ string +char Str; +int I; +for I:= 0 to -1>>1-1 do + if Str(I) = 0 then return I; + +func Pangram(S); +char S; +int A, I, C; +[A:= 0; +for I:= 0 to StrLen(S)-1 do + [C:= S(I); + if C>=^A & C<=^Z then C:= C or $20; + if C>=^a & C<=^z then [C:= C - ^a; A:= A or 1<; + with function "+" (X, Y : Number) return Number is <>; + with function "/" (X, Y : Number) return Number is <>; + with function "mod" (X, Y : Number) return Number is <>; + with function ">=" (X, Y : Number) return Boolean is <>; +package Prime_Numbers is + type Number_List is array (Positive range <>) of Number; + + procedure Put (List : Number_List); + + task type Calculate_Factors is + entry Start (The_Number : in Number); + entry Get_Size (Size : out Natural); + entry Get_Result (List : out Number_List); + end Calculate_Factors; + +end Prime_Numbers; diff --git a/Task/Parallel-calculations/Ada/parallel-calculations-2.ada b/Task/Parallel-calculations/Ada/parallel-calculations-2.ada new file mode 100644 index 0000000000..c04ffc864b --- /dev/null +++ b/Task/Parallel-calculations/Ada/parallel-calculations-2.ada @@ -0,0 +1,50 @@ +with Ada.Text_IO; +package body Prime_Numbers is + + procedure Put (List : Number_List) is + begin + for Index in List'Range loop + Ada.Text_IO.Put (Image (List (Index))); + end loop; + end Put; + + task body Calculate_Factors is + Size : Natural := 0; + N : Number; + M : Number; + K : Number := Two; + begin + accept Start (The_Number : in Number) do + N := The_Number; + M := N; + end Start; + -- Estimation of the result length from above + while M >= Two loop + M := (M + One) / Two; + 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 Zero = (M mod K) loop -- While divides + Result (Index) := K; + Index := Index + 1; + M := M / K; + end loop; + K := K + One; + end loop; + Index := Index - 1; + accept Get_Size (Size : out Natural) do + Size := Index; + end Get_Size; + accept Get_Result (List : out Number_List) do + List (1 .. Index) := Result (1 .. Index); + end Get_Result; + end; + end Calculate_Factors; + +end Prime_Numbers; diff --git a/Task/Parallel-calculations/Ada/parallel-calculations-3.ada b/Task/Parallel-calculations/Ada/parallel-calculations-3.ada new file mode 100644 index 0000000000..c849663a9e --- /dev/null +++ b/Task/Parallel-calculations/Ada/parallel-calculations-3.ada @@ -0,0 +1,54 @@ +with Ada.Text_IO; +with Prime_Numbers; +procedure Parallel is + package Integer_Primes is new Prime_Numbers ( + Number => Integer, -- use Large_Integer for longer numbers + Zero => 0, + One => 1, + Two => 2, + Image => Integer'Image); + + My_List : Integer_Primes.Number_List := + ( 12757923, + 12878611, + 12757923, + 15808973, + 15780709, + 197622519); + + Decomposers : array (My_List'Range) of Integer_Primes.Calculate_Factors; + Lengths : array (My_List'Range) of Natural; + Max_Length : Natural := 0; +begin + for I in My_List'Range loop + -- starts the tasks + Decomposers (I).Start (My_List (I)); + end loop; + for I in My_List'Range loop + -- wait until task has reached Get_Size entry + Decomposers (I).Get_Size (Lengths (I)); + if Lengths (I) > Max_Length then + Max_Length := Lengths (I); + end if; + end loop; + declare + Results : + array (My_List'Range) of Integer_Primes.Number_List (1 .. Max_Length); + Largest_Minimal_Factor : Integer := 0; + Winning_Index : Positive; + begin + for I in My_List'Range loop + -- after Get_Result, the tasks terminate + Decomposers (I).Get_Result (Results (I)); + if Results (I) (1) > Largest_Minimal_Factor then + Largest_Minimal_Factor := Results (I) (1); + Winning_Index := I; + end if; + end loop; + Ada.Text_IO.Put_Line + ("Number" & Integer'Image (My_List (Winning_Index)) & + " has largest minimal factor:"); + Integer_Primes.Put (Results (Winning_Index) (1 .. Lengths (Winning_Index))); + Ada.Text_IO.New_Line; + end; +end Parallel; diff --git a/Task/Parallel-calculations/C++/parallel-calculations.cpp b/Task/Parallel-calculations/C++/parallel-calculations.cpp new file mode 100644 index 0000000000..a966d91ebf --- /dev/null +++ b/Task/Parallel-calculations/C++/parallel-calculations.cpp @@ -0,0 +1,57 @@ +#include +#include +#include +#include // MSVC++ +#include // MSVC++ + +struct Factors +{ + int number; + std::vector primes; +}; + +const int data[] = +{ + 12757923, 12878611, 12878893, 12757923, 15808973, 15780709, 197622519 +}; + +int main() +{ + // concurrency-safe container replaces std::vector<> + Concurrency::concurrent_vector results; + + // parallel algorithm replaces std::for_each() + Concurrency::parallel_for_each(std::begin(data), std::end(data), [&](int n) + { + Factors factors; + factors.number = n; + for (int f = 2; n > 1; ++f) + { + while (n % f == 0) + { + factors.primes.push_back(f); + n /= f; + } + } + results.push_back(factors); // add factorization to results + }); + // end of parallel calculations + + // find largest minimal prime factor in results + auto max = std::max_element(results.begin(), results.end(), [](const Factors &a, const Factors &b) + { + return a.primes.front() < b.primes.front(); + }); + + // print number(s) and factorization + std::for_each(results.begin(), results.end(), [&](const Factors &f) + { + if (f.primes.front() == max->primes.front()) + { + std::cout << f.number << " = [ "; + std::copy(f.primes.begin(), f.primes.end(), std::ostream_iterator(std::cout, " ")); + std::cout << "]\n"; + } + }); + return 0; +} diff --git a/Task/Parallel-calculations/C/parallel-calculations.c b/Task/Parallel-calculations/C/parallel-calculations.c new file mode 100644 index 0000000000..55712bc9b8 --- /dev/null +++ b/Task/Parallel-calculations/C/parallel-calculations.c @@ -0,0 +1,33 @@ +#include +#include + +int main() +{ + int data[] = {12757923, 12878611, 12878893, 12757923, 15808973, 15780709, 197622519}; + int largest, largest_factor = 0; + + omp_set_num_threads(4); + /* "omp parallel for" turns the for loop multithreaded by making each thread + * iterating only a part of the loop variable, in this case i; variables declared + * as "shared" will be implicitly locked on access + */ + #pragma omp parallel for shared(largest_factor, largest) + for (int i = 0; i < 7; i++) { + int p, n = data[i]; + + for (p = 3; p * p <= n && n % p; p += 2); + if (p * p > n) p = n; + if (p > largest_factor) { + largest_factor = p; + largest = n; + printf("thread %d: found larger: %d of %d\n", + omp_get_thread_num(), p, n); + } else { + printf("thread %d: not larger: %d of %d\n", + omp_get_thread_num(), p, n); + } + } + + printf("Largest factor: %d of %d\n", largest_factor, largest); + return 0; +} diff --git a/Task/Parallel-calculations/Clojure/parallel-calculations.clj b/Task/Parallel-calculations/Clojure/parallel-calculations.clj new file mode 100644 index 0000000000..3ebca5fe45 --- /dev/null +++ b/Task/Parallel-calculations/Clojure/parallel-calculations.clj @@ -0,0 +1,14 @@ +(use '[clojure.contrib.lazy-seqs :only [primes]]) + +(defn lpf [n] + [n (or (last + (for [p (take-while #(<= (* % %) n) primes) + :when (zero? (rem n p))] + p)) + 1)]) + +(->> (range 2 100000) + (pmap lpf) + (apply max-key second) + println + time) diff --git a/Task/Parallel-calculations/D/parallel-calculations-1.d b/Task/Parallel-calculations/D/parallel-calculations-1.d new file mode 100644 index 0000000000..a9dfdd1e5b --- /dev/null +++ b/Task/Parallel-calculations/D/parallel-calculations-1.d @@ -0,0 +1,16 @@ +import std.stdio, std.algorithm, std.parallelism, std.typecons; + +void main() { + immutable ulong[] data = [ + 2UL^^59-1, 2UL^^59-1, 2UL^^59-1, 112_272_537_195_293UL, + 115_284_584_522_153, 115_280_098_190_773, + 115_797_840_077_099, 112_582_718_962_171, + 112_272_537_095_293, 1_099_726_829_285_419]; + + //auto factors = taskPool.amap!(n => tuple(decompose(n), n))(data); + static genPair(ulong n) pure { return tuple(decompose(n), n); } + auto factors = taskPool.amap!genPair(data); + + auto pairs = map!(p => tuple(reduce!min(p[0]), p[1]))(factors); + writeln("N. with largest min factor: ", reduce!max(pairs)[1]); +} diff --git a/Task/Parallel-calculations/D/parallel-calculations-2.d b/Task/Parallel-calculations/D/parallel-calculations-2.d new file mode 100644 index 0000000000..0ce26090c7 --- /dev/null +++ b/Task/Parallel-calculations/D/parallel-calculations-2.d @@ -0,0 +1,83 @@ +import std.stdio, std.math, std.algorithm, std.typecons, + core.thread, core.stdc.time; + +final class MinFactor: Thread { + private immutable ulong num; + private ulong[] fac; + private ulong minFac; + + this(in ulong n) /*pure nothrow*/ { + super(&run); + num = n; + fac = new ulong[0]; + } + + @property ulong number() const pure nothrow { + return num; + } + + @property const(ulong[]) factors() const pure nothrow { + return fac; + } + + @property ulong minFactor() const pure nothrow { + return minFac; + } + + private void run() { + immutable clock_t begin = clock(); + switch (num) { + case 0: fac = []; break; + + case 1: fac = [1]; break; + + default: + uint limit = cast(uint)(1 + sqrt(cast(double)num)); + ulong n = num; + for (ulong divi = 3; divi < limit; divi += 2) { + if (n == 1) + break; + if ((n % divi) == 0) { + while ((n > 1) && ((n % divi) == 0)) { + fac ~= divi; + n /= divi; + } + limit = cast(uint)(1 + sqrt(cast(double)n)); + } + } + if (n > 1) + fac ~= n; + } + minFac = reduce!min(fac); + immutable clock_t end = clock(); + writefln("num: %20d --> min. factor: %20d ticks(%7d -> %7d)", + num, minFac, begin, end); + } +} + +void main() { + immutable ulong[] numbers = [ + 2UL^^59-1, 2UL^^59-1, 2UL^^59-1, 112_272_537_195_293UL, + 115_284_584_522_153, 115_280_098_190_773, + 115_797_840_077_099, 112_582_718_962_171, + 112_272_537_095_293, 1_099_726_829_285_419]; + + auto tGroup = new ThreadGroup; + foreach (n; numbers) + tGroup.add(new MinFactor(n)); + + writeln("Minimum factors for respective numbers are:"); + foreach (t; tGroup) + t.start(); + tGroup.joinAll(); + + auto maxMin = tuple(0UL, [0UL], 0UL); + foreach (thread; tGroup) { + auto s = cast(MinFactor)thread; + if (s !is null && maxMin[2] < s.minFactor) + maxMin = tuple(s.number, s.factors.dup, s.minFactor); + } + + writefln("Number with largest min. factor is %16d," ~ + " with factors:\n\t%s", maxMin.tupleof); +} diff --git a/Task/Parallel-calculations/Go/parallel-calculations.go b/Task/Parallel-calculations/Go/parallel-calculations.go new file mode 100644 index 0000000000..8fbd38adb0 --- /dev/null +++ b/Task/Parallel-calculations/Go/parallel-calculations.go @@ -0,0 +1,96 @@ +package main + +import ( + "fmt" + "math/big" +) + +// collection of numbers. A slice is used for the collection. +// The elements are big integers, since that's what the function Primes +// uses (as was specified by the Prime decomposition task.) +var numbers = []*big.Int{ + big.NewInt(12757923), + big.NewInt(12878611), + big.NewInt(12878893), + big.NewInt(12757923), + big.NewInt(15808973), + big.NewInt(15780709), +} + +// main just calls the function specified by the task description and +// prints results. note it allows for multiple numbers with the largest +// minimal factor. the task didn't specify to handle this, but obviously +// it's possible. +func main() { + rs := lmf(numbers) + fmt.Println("largest minimal factor:", rs[0].decomp[0]) + for _, r := range rs { + fmt.Println(r.number, "->", r.decomp) + } +} + +// this type associates a number with it's prime decomposition. +// the type is neccessary so that they can be sent together over +// a Go channel, but it turns out to be convenient as well for +// the return type of lmf. +type result struct { + number *big.Int + decomp []*big.Int +} + +// the function specified by the task description, "largest minimal factor." +func lmf([]*big.Int) []result { + // construct result channel and start a goroutine to decompose each number. + // goroutines run in parallel as CPU cores are available. + rCh := make(chan result) + for _, n := range numbers { + go decomp(n, rCh) + } + + // collect results. <-rCh returns a single result from the result channel. + // we know how many results to expect so code here collects exactly that + // many results, and accumulates a list of those with the largest + // minimal factor. + rs := []result{<-rCh} + for i := 1; i < len(numbers); i++ { + switch r := <-rCh; r.decomp[0].Cmp(rs[0].decomp[0]) { + case 1: + rs = rs[:1] + rs[0] = r + case 0: + rs = append(rs, r) + } + } + return rs +} + +// decomp is the function run as a goroutine. multiple instances of this +// function will run concurrently, one for each number being decomposed. +// it acts as a driver for Primes, calling Primes as needed, packaging +// the result, and sending the packaged result on the channel. +// "as needed" turns out to mean sending Primes a copy of n, as Primes +// as written is destructive on its argument. +func decomp(n *big.Int, rCh chan result) { + rCh <- result{n, Primes(new(big.Int).Set(n))} +} + +// code below copied from Prime decomposition task +var ( + ZERO = big.NewInt(0) + ONE = big.NewInt(1) +) + +func Primes(n *big.Int) []*big.Int { + res := []*big.Int{} + mod, div := new(big.Int), new(big.Int) + for i := big.NewInt(2); i.Cmp(n) != 1; { + div.DivMod(n, i, mod) + for mod.Cmp(ZERO) == 0 { + res = append(res, new(big.Int).Set(i)) + n.Set(div) + div.DivMod(n, i, mod) + } + i.Add(i, ONE) + } + return res +} diff --git a/Task/Parallel-calculations/J/parallel-calculations.j b/Task/Parallel-calculations/J/parallel-calculations.j new file mode 100644 index 0000000000..d36a945e26 --- /dev/null +++ b/Task/Parallel-calculations/J/parallel-calculations.j @@ -0,0 +1,7 @@ + numbers =. 12757923 12878611 12878893 12757923 15808973 15780709 197622519 + factors =. q:&.> parallelize 2 numbers NB. q: is parallelized here + ind =. (i. >./) <./@> factors + ind { numbers ;"_1 factors +┌────────┬───────────┐ +│12878611│47 101 2713│ +└────────┴───────────┘ diff --git a/Task/Parallel-calculations/JavaScript/parallel-calculations-1.js b/Task/Parallel-calculations/JavaScript/parallel-calculations-1.js new file mode 100644 index 0000000000..7af85fa977 --- /dev/null +++ b/Task/Parallel-calculations/JavaScript/parallel-calculations-1.js @@ -0,0 +1,16 @@ +var onmessage = function(event) { + postMessage({"n" : event.data.n, + "factors" : factor(event.data.n), + "id" : event.data.id}); +}; + +function factor(n) { + var factors = []; + for(p = 2; p <= n; p++) { + if((n % p) == 0) { + factors[factors.length] = p; + n /= p; + } + } + return factors; +} diff --git a/Task/Parallel-calculations/JavaScript/parallel-calculations-2.js b/Task/Parallel-calculations/JavaScript/parallel-calculations-2.js new file mode 100644 index 0000000000..dbaee0ed6a --- /dev/null +++ b/Task/Parallel-calculations/JavaScript/parallel-calculations-2.js @@ -0,0 +1,38 @@ +var numbers = [12757923, 12878611, 12757923, 15808973, 15780709, 197622519]; +var workers = []; +var worker_count = 0; + +var results = []; + +for(var i = 0; i < numbers.length; i++) { + worker_count++; + workers[i] = new Worker("parallel_worker.js"); + workers[i].onmessage = accumulate; + workers[i].postMessage({n: numbers[i], id: i}); +} + +function accumulate(event) { + n = event.data.n; + factors = event.data.factors; + id = event.data.id; + console.log(n + " : " + factors); + results[id] = {n:n, factors:factors}; + // Cleanup - kill the worker and countdown until all work is done + workers[id].terminate(); + worker_count--; + if(worker_count == 0) + reduce(); +} + +function reduce() { + answer = 0; + for(i = 1; i < results.length; i++) { + min = results[i].factors[0]; + largest_min = results[answer].factors[0]; + if(min > largest_min) + answer = i; + } + n = results[answer].n; + factors = results[answer].factors; + console.log("The number with the relatively largest factors is: " + n + " : " + factors); +} diff --git a/Task/Parallel-calculations/Mathematica/parallel-calculations.math b/Task/Parallel-calculations/Mathematica/parallel-calculations.math new file mode 100644 index 0000000000..3654c1066c --- /dev/null +++ b/Task/Parallel-calculations/Mathematica/parallel-calculations.math @@ -0,0 +1 @@ +hasSmallestFactor[data_List]:=Sort[Transpose[{ParallelTable[FactorInteger[x][[1, 1]], {x, data}],data}]][[1, 2]] diff --git a/Task/Parallel-calculations/OxygenBasic/parallel-calculations.oxy b/Task/Parallel-calculations/OxygenBasic/parallel-calculations.oxy new file mode 100644 index 0000000000..7aef385db8 --- /dev/null +++ b/Task/Parallel-calculations/OxygenBasic/parallel-calculations.oxy @@ -0,0 +1,181 @@ +'CONFIGURATION +'============= + +% max 8192 'Maximum amount of Prime Numbers (must be 2^n) (excluding 1 and 2) +% cores 4 'CPU cores available (limited to 4 here) +% share 2048 'Amount of numbers allocated to each core + +'SETUP +'===== + +'SOURCE DATA BUFFERS + +sys primes[max] +sys numbers[max] + +'RESULT BUFFER + +double pp[max] 'main thread + + +'MULTITHREADING AND TIMING API +'============================= + +extern lib "kernel32.dll" +' +void QueryPerformanceCounter(quad*c) +void QueryPerformanceFrequency(quad*freq) +sys CreateThread (sys lpThreadAttributes, dwStackSize, lpStartAddress, lpParameter, dwCreationFlags, *lpThreadId) +dword WaitForMultipleObjects(sys nCount,*lpHandles, bWaitAll, dwMilliseconds) +bool CloseHandle(sys hObject) +void Sleep(sys dwMilliSeconds) +' +quad freq,t1,t2 +QueryPerformanceFrequency freq + + +'MACROS AND FUNCTIONS +'==================== + + +macro FindPrimes(p) +'================== +finit +sys n=1 +sys c,k +do + n+=2 + if c>=max then exit do + ' + 'IS IT DIVISIBLE BE ANY PREVIOUS PRIME + ' + for k=1 to c + if frac(n/p[k])=0 then exit for + next + ' + if k>c then + c++ + p[c]=n 'STORE PRIME + end if +end do +end macro + + +macro ProcessNumbers(p,bb) +'========================= +finit +sys i,b,e +b=bb*share +e=b+share +sys v,w +for i=b+1 to e + v=numbers(i) + for j=max to 1 step -1 + w=primes(j) + if w0 then + WaitForMultipleObjects Threads, hThread, 1, INFINITE +end if + +for i=1 to Threads + CloseHandle hThread(i) +next + +'CAPTURE NUMBER WITH HIGHEST PRIME FACTOR + +sys n,f +for i=1 to max + if pp(i)>f then f=pp(i) : n=i +next + +'STOP TIMER + +QueryPerformanceCounter t2 + +print str((t2-t1)/freq,3) " secs " numbers(n) " " f 'number with highest prime factor diff --git a/Task/Parallel-calculations/PARI-GP/parallel-calculations.pari b/Task/Parallel-calculations/PARI-GP/parallel-calculations.pari new file mode 100644 index 0000000000..a635414450 --- /dev/null +++ b/Task/Parallel-calculations/PARI-GP/parallel-calculations.pari @@ -0,0 +1,2 @@ +v=pareval(vector(1000,i,()->factor(2^i+1)[1,1])); +vecmin(v) diff --git a/Task/Parallel-calculations/Perl-6/parallel-calculations.pl6 b/Task/Parallel-calculations/Perl-6/parallel-calculations.pl6 new file mode 100644 index 0000000000..ee472bfb0e --- /dev/null +++ b/Task/Parallel-calculations/Perl-6/parallel-calculations.pl6 @@ -0,0 +1,5 @@ +my @nums = 12757923, 12878611, 123456789, 15808973, 15780709, 197622519; + +my @factories; +@factories[$_] := factors(@nums[$_]) for ^@nums; +my $gmf = ([max] @factories»[0] »=>« @nums).value; diff --git a/Task/Parallel-calculations/PicoLisp/parallel-calculations.l b/Task/Parallel-calculations/PicoLisp/parallel-calculations.l new file mode 100644 index 0000000000..272fa803f4 --- /dev/null +++ b/Task/Parallel-calculations/PicoLisp/parallel-calculations.l @@ -0,0 +1,20 @@ +(let Lst + (mapcan + '((N) + (later (cons) # When done, + (cons N (factor N)) ) ) # return the number and its factors + (quote + 188573867500151328137405845301 # Process a collection of 12 numbers + 3326500147448018653351160281 + 979950537738920439376739947 + 2297143294659738998811251 + 136725986940237175592672413 + 3922278474227311428906119 + 839038954347805828784081 + 42834604813424961061749793 + 2651919914968647665159621 + 967022047408233232418982157 + 2532817738450130259664889 + 122811709478644363796375689 ) ) + (wait NIL (full Lst)) # Wait until all computations are done + (maxi '((L) (apply min L)) Lst) ) # Result: Number in CAR, factors in CDR diff --git a/Task/Parallel-calculations/Prolog/parallel-calculations.pro b/Task/Parallel-calculations/Prolog/parallel-calculations.pro new file mode 100644 index 0000000000..47a595909e --- /dev/null +++ b/Task/Parallel-calculations/Prolog/parallel-calculations.pro @@ -0,0 +1,31 @@ +threaded_decomp(Number,ID):- + thread_create( + (prime_decomp(Number,Y), + thread_exit((Number,Y))) + ,ID,[]). + +threaded_decomp_list(List,Erg):- + maplist(threaded_decomp,List,IDs), + maplist(thread_join,IDs,Results), + maplist(pack_exit_out,Results,Smallest_Factors_List), + largest_min_factor(Smallest_Factors_List,Erg). + +pack_exit_out(exited(X),X). +%Note that here some error handling should happen. + +largest_min_factor([(N,Facs)|A],(N2,Fs2)):- + min_list(Facs,MF), + largest_min_factor(A,(N,MF,Facs),(N2,_,Fs2)). + +largest_min_factor([],Acc,Acc). +largest_min_factor([(N1,Facs1)|Rest],(N2,MF2,Facs2),Goal):- + min_list(Facs1, MF1), + (MF1 > MF2-> + largest_min_factor(Rest,(N1,MF1,Facs1),Goal); + largest_min_factor(Rest,(N2,MF2,Facs2),Goal)). + + +format_it(List):- + threaded_decomp_list(List,(Number,Factors)), + format('Number with largest minimal Factor is ~w\nFactors are ~w\n', + [Number,Factors]). diff --git a/Task/Parallel-calculations/PureBasic/parallel-calculations.purebasic b/Task/Parallel-calculations/PureBasic/parallel-calculations.purebasic new file mode 100644 index 0000000000..d2b1f9d534 --- /dev/null +++ b/Task/Parallel-calculations/PureBasic/parallel-calculations.purebasic @@ -0,0 +1,87 @@ +Structure IO_block + ThreadID.i + StartSeamaphore.i + Value.q + MinimumFactor.i + List Factors.i() +EndStructure +;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ + +Declare Factorize(*IO.IO_block) +Declare main() +;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ + +Main() +End +;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ + +Procedure Main() + Protected AvailableCpu, MainSemaphore + Protected i, j, qData.q, Title$, Message$ + NewList T.IO_block() + ; + AvailableCpu = Val(GetEnvironmentVariable("NUMBER_OF_PROCESSORS")) + If AvailableCpu<1: AvailableCpu=1: EndIf + MainSemaphore = CreateSemaphore(AvailableCpu) + ; + Restore Start_of_data + For i=1 To (?end_of_data-?Start_of_data) / SizeOf(Quad) + ; Start all threads at ones, they will then be let to + ; self-oganize according to the availiable Cores. + AddElement(T()) + Read.q qData + T()\Value = qData + T()\StartSeamaphore = MainSemaphore + T()\ThreadID = CreateThread(@Factorize(), @T()) + Next + ; + ForEach T() + ; Wait for all threads to complete their work and + ; find the smallest factor from eact task. + WaitThread(T()\ThreadID) + Next + ; + i = OffsetOf(IO_block\MinimumFactor) + SortStructuredList(T(), #PB_Sort_Integer, i, #PB_Sort_Descending) + FirstElement(T()) + Title$="Info" + Message$="Number "+Str(T()\Value)+" has largest minimal factor:"+#CRLF$ + ForEach T()\Factors() + Message$ + Str(T()\Factors())+" " + Next + MessageRequester(Title$, Message$) +EndProcedure + +ProcedureDLL Factorize(*IO.IO_block) ; Fill list Factors() with the factor parts of Number + ;Based on http://rosettacode.org/wiki/Prime_decomposition#PureBasic + With *IO + Protected Value.q=\Value + WaitSemaphore(\StartSeamaphore) + Protected I = 3 + ClearList(\Factors()) + While Value % 2 = 0 + AddElement(\Factors()) + \Factors() = 2 + Value / 2 + Wend + Protected Max = Value + While I <= Max And Value > 1 + While Value % I = 0 + AddElement(\Factors()) + \Factors() = I + Value / I + Wend + I + 2 + Wend + SortList(\Factors(), #PB_Sort_Ascending) + FirstElement(\Factors()) + \MinimumFactor=\Factors() + SignalSemaphore(\StartSeamaphore) + EndWith ;*IO +EndProcedure + +DataSection + Start_of_data: ; Same numbers as Ada + Data.q 12757923, 12878611, 12757923, 15808973, 15780709, 197622519 + end_of_data: +EndDataSection diff --git a/Task/Parallel-calculations/Python/parallel-calculations.py b/Task/Parallel-calculations/Python/parallel-calculations.py new file mode 100644 index 0000000000..f55878547a --- /dev/null +++ b/Task/Parallel-calculations/Python/parallel-calculations.py @@ -0,0 +1,45 @@ +from concurrent import futures +from math import floor, sqrt + +NUMBERS = [ + 112272537195293, + 112582718962171, + 112272537095293, + 115280098190773, + 115797840077099, + 1099726829285419] +# NUMBERS = [33, 44, 55, 275] + +def lowest_factor(n, _start=3): + if n % 2 == 0: + return 2 + search_max = int(floor(sqrt(n))) + 1 + for i in range(_start, search_max, 2): + if n % i == 0: + return i + return n + +def prime_factors(n, lowest): + pf = [] + while n > 1: + pf.append(lowest) + n //= lowest + lowest = lowest_factor(n, max(lowest, 3)) + return pf + +def prime_factors_of_number_with_lowest_prime_factor(NUMBERS): + with futures.ProcessPoolExecutor() as executor: + low_factor, number = max( (l, f) for l, f in zip(executor.map(lowest_factor, NUMBERS), NUMBERS) ) + all_factors = prime_factors(number, low_factor) + return number, all_factors + + +def main(): + print( 'For these numbers:\n ' + '\n '.join(str(p) for p in NUMBERS) ) + number, all_factors = prime_factors_of_number_with_lowest_prime_factor(NUMBERS) + print(' The one with the largest minimum prime factor is %i:' % number) + print(' All its prime factors in order are: %s' % all_factors) + + +if __name__ == '__main__': + main() diff --git a/Task/Parallel-calculations/Tcl/parallel-calculations-1.tcl b/Task/Parallel-calculations/Tcl/parallel-calculations-1.tcl new file mode 100644 index 0000000000..b75de2e20d --- /dev/null +++ b/Task/Parallel-calculations/Tcl/parallel-calculations-1.tcl @@ -0,0 +1,42 @@ +package require Tcl 8.6 +package require Thread + +# Pooled computation engine; runs event loop internally +namespace eval pooled { + variable poolSize 3; # Needs to be tuned to system size + + proc computation {computationDefinition entryPoint values} { + variable result + variable poolSize + # Add communication shim + append computationDefinition [subst -nocommands { + proc poolcompute {value target} { + set outcome [$entryPoint \$value] + set msg [list set ::pooled::result(\$value) \$outcome] + thread::send -async \$target \$msg + } + }] + + # Set up the pool + set pool [tpool::create -initcmd $computationDefinition \ + -maxworkers $poolSize] + + # Prepare to receive results + unset -nocomplain result + array set result {} + + # Dispatch the computations + foreach value $values { + tpool::post $pool [list poolcompute $value [thread::id]] + } + + # Wait for results + while {[array size result] < [llength $values]} {vwait pooled::result} + + # Dispose of the pool + tpool::release $pool + + # Return the results + return [array get result] + } +} diff --git a/Task/Parallel-calculations/Tcl/parallel-calculations-2.tcl b/Task/Parallel-calculations/Tcl/parallel-calculations-2.tcl new file mode 100644 index 0000000000..a0efa532d8 --- /dev/null +++ b/Task/Parallel-calculations/Tcl/parallel-calculations-2.tcl @@ -0,0 +1,67 @@ +# Code for computing the prime factors of a number +set computationCode { + 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 + } + } +} + +# The values to be factored +set values { + 188573867500151328137405845301 + 3326500147448018653351160281 + 979950537738920439376739947 + 2297143294659738998811251 + 136725986940237175592672413 + 3922278474227311428906119 + 839038954347805828784081 + 42834604813424961061749793 + 2651919914968647665159621 + 967022047408233232418982157 + 2532817738450130259664889 + 122811709478644363796375689 +} diff --git a/Task/Parallel-calculations/Tcl/parallel-calculations-3.tcl b/Task/Parallel-calculations/Tcl/parallel-calculations-3.tcl new file mode 100644 index 0000000000..9af297587a --- /dev/null +++ b/Task/Parallel-calculations/Tcl/parallel-calculations-3.tcl @@ -0,0 +1,15 @@ +# Do the computation, getting back a dictionary that maps +# values to its results (itself an ordered dictionary) +set results [pooled::computation $computationCode prime::factors $values] + +# Find the maximum minimum factor with sorting magic +set best [lindex [lsort -integer -stride 2 -index {1 0} $results] end-1] + +# Print in human-readable form +proc renderFactors {factorDict} { + dict for {factor times} $factorDict { + lappend v {*}[lrepeat $times $factor] + } + return [join $v "*"] +} +puts "$best = [renderFactors [dict get $results $best]]" diff --git a/Task/Parametric-polymorphism/0DESCRIPTION b/Task/Parametric-polymorphism/0DESCRIPTION new file mode 100644 index 0000000000..3d5c777449 --- /dev/null +++ b/Task/Parametric-polymorphism/0DESCRIPTION @@ -0,0 +1,5 @@ +[[wp:Parametric Polymorphism|Parametric Polymorphism]] is a way to define types or functions that are generic over other types. The genericity can be expressed by using ''type variables'' for the parameter type, and by a mechanism to explicitly or implicitly replace the type variables with concrete types when necessary. + +Write a small example for a type declaration that is parametric over another type, together with a short bit of code (and its type signature) that uses it. A good example is a container type, let's say a binary tree, together with some function that traverses the tree, say, a ''map''-function that operates on every element of the tree. + +This language feature only applies to statically-typed languages. diff --git a/Task/Parametric-polymorphism/1META.yaml b/Task/Parametric-polymorphism/1META.yaml new file mode 100644 index 0000000000..77d4ea9670 --- /dev/null +++ b/Task/Parametric-polymorphism/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Type System +note: Basic language learning diff --git a/Task/Parametric-polymorphism/Ada/parametric-polymorphism-1.ada b/Task/Parametric-polymorphism/Ada/parametric-polymorphism-1.ada new file mode 100644 index 0000000000..3eea5dfce6 --- /dev/null +++ b/Task/Parametric-polymorphism/Ada/parametric-polymorphism-1.ada @@ -0,0 +1,14 @@ +generic + type Element_Type is private; +package Container is + type Tree is tagged private; + procedure Replace_All(The_Tree : in out Tree; New_Value : Element_Type); +private + type Node; + type Node_Access is access Node; + type Tree tagged record + Value : Element_type; + Left : Node_Access := null; + Right : Node_Access := null; + end record; +end Container; diff --git a/Task/Parametric-polymorphism/Ada/parametric-polymorphism-2.ada b/Task/Parametric-polymorphism/Ada/parametric-polymorphism-2.ada new file mode 100644 index 0000000000..c697231294 --- /dev/null +++ b/Task/Parametric-polymorphism/Ada/parametric-polymorphism-2.ada @@ -0,0 +1,12 @@ +package body Container is + procedure Replace_All(The_Tree : in out Tree; New_Value : Element_Type) is + begin + The_Tree.Value := New_Value; + If The_Tree.Left /= null then + The_Tree.Left.all.Replace_All(New_Value); + end if; + if The_tree.Right /= null then + The_Tree.Right.all.Replace_All(New_Value); + end if; + end Replace_All; +end Container; diff --git a/Task/Parametric-polymorphism/C++/parametric-polymorphism-1.cpp b/Task/Parametric-polymorphism/C++/parametric-polymorphism-1.cpp new file mode 100644 index 0000000000..b811bb31e5 --- /dev/null +++ b/Task/Parametric-polymorphism/C++/parametric-polymorphism-1.cpp @@ -0,0 +1,9 @@ +template +class tree +{ + T value; + tree *left; + tree *right; +public: + void replace_all (T new_value); +}; diff --git a/Task/Parametric-polymorphism/C++/parametric-polymorphism-2.cpp b/Task/Parametric-polymorphism/C++/parametric-polymorphism-2.cpp new file mode 100644 index 0000000000..29e2f031e9 --- /dev/null +++ b/Task/Parametric-polymorphism/C++/parametric-polymorphism-2.cpp @@ -0,0 +1,7 @@ +template +void tree::replace_all (T new_value) +{ + value = new_value; + left->replace_all (new_value); + right->replace_all (new_value); +} diff --git a/Task/Parametric-polymorphism/C/parametric-polymorphism.c b/Task/Parametric-polymorphism/C/parametric-polymorphism.c new file mode 100644 index 0000000000..769ef2c890 --- /dev/null +++ b/Task/Parametric-polymorphism/C/parametric-polymorphism.c @@ -0,0 +1,47 @@ +#include +#include + +#define decl_tree_type(T) \ + typedef struct node_##T##_t node_##T##_t, *node_##T; \ + struct node_##T##_t { node_##T left, right; T value; }; \ + \ + node_##T node_##T##_new(T v) { \ + node_##T node = malloc(sizeof(node_##T##_t)); \ + node->value = v; \ + node->left = node->right = 0; \ + return node; \ + } \ + node_##T node_##T##_insert(node_##T root, T v) { \ + node_##T n = node_##T##_new(v); \ + while (root) { \ + if (root->value < n->value) \ + if (!root->left) return root->left = n; \ + else root = root->left; \ + else \ + if (!root->right) return root->right = n; \ + else root = root->right; \ + } \ + return 0; \ + } + +#define tree_node(T) node_##T +#define node_insert(T, r, x) node_##T##_insert(r, x) +#define node_new(T, x) node_##T##_new(x) + +decl_tree_type(double); +decl_tree_type(int); + +int main() +{ + int i; + tree_node(double) root_d = node_new(double, (double)rand() / RAND_MAX); + + for (i = 0; i < 10000; i++) + node_insert(double, root_d, (double)rand() / RAND_MAX); + + tree_node(int) root_i = node_new(int, rand()); + for (i = 0; i < 10000; i++) + node_insert(int, root_i, rand()); + + return 0; +} diff --git a/Task/Parametric-polymorphism/Clean/parametric-polymorphism-1.clean b/Task/Parametric-polymorphism/Clean/parametric-polymorphism-1.clean new file mode 100644 index 0000000000..a98b0436f0 --- /dev/null +++ b/Task/Parametric-polymorphism/Clean/parametric-polymorphism-1.clean @@ -0,0 +1,5 @@ +::Tree a = Empty | Node a (Tree a) (Tree a) + +mapTree :: (a -> b) (Tree a) -> (Tree b) +mapTree f Empty = Empty +mapTree f (Node x l r) = Node (f x) (mapTree f l) (mapTree f r) diff --git a/Task/Parametric-polymorphism/Clean/parametric-polymorphism-2.clean b/Task/Parametric-polymorphism/Clean/parametric-polymorphism-2.clean new file mode 100644 index 0000000000..735f57fece --- /dev/null +++ b/Task/Parametric-polymorphism/Clean/parametric-polymorphism-2.clean @@ -0,0 +1,3 @@ +instance Functor Tree where + fmap f Empty = Empty + fmap f (Node x l r) = Node (f x) (fmap f l) (fmap f r) diff --git a/Task/Parametric-polymorphism/Clean/parametric-polymorphism-3.clean b/Task/Parametric-polymorphism/Clean/parametric-polymorphism-3.clean new file mode 100644 index 0000000000..83dc835ded --- /dev/null +++ b/Task/Parametric-polymorphism/Clean/parametric-polymorphism-3.clean @@ -0,0 +1,2 @@ +add1Everywhere :: (f a) -> (f a) | Functor f & Num a +add1Everywhere nums = fmap (\x = x + 1) nums diff --git a/Task/Parametric-polymorphism/Common-Lisp/parametric-polymorphism.lisp b/Task/Parametric-polymorphism/Common-Lisp/parametric-polymorphism.lisp new file mode 100644 index 0000000000..bc74963029 --- /dev/null +++ b/Task/Parametric-polymorphism/Common-Lisp/parametric-polymorphism.lisp @@ -0,0 +1,2 @@ +(deftype pair (&key (car 't) (cdr 't)) + `(cons ,car ,cdr)) diff --git a/Task/Parametric-polymorphism/D/parametric-polymorphism.d b/Task/Parametric-polymorphism/D/parametric-polymorphism.d new file mode 100644 index 0000000000..7459ca9fd3 --- /dev/null +++ b/Task/Parametric-polymorphism/D/parametric-polymorphism.d @@ -0,0 +1,46 @@ +class ArrayTree(T, uint N) { + T[N] data; + typeof(this) left, right; + + this(T initValue) { this.data[] = initValue; } + + void tmap(const void delegate(ref typeof(data)) dg) { + dg(this.data); + if (left) left.tmap(dg); + if (right) right.tmap(dg); + } +} + +void main() { // Demo code. + import std.stdio; + + // Instantiate the template ArrayTree of three doubles. + alias AT3 = ArrayTree!(double, 3); + + // Allocate the tree root. + auto root = new AT3(1.00); + + // Add some nodes. + root.left = new AT3(1.10); + root.left.left = new AT3(1.11); + root.left.right = new AT3(1.12); + + root.right = new AT3(1.20); + root.right.left = new AT3(1.21); + root.right.right = new AT3(1.22); + + // Now the tree has seven nodes. + + // Show the arrays of the whole tree. + //root.tmap(x => writefln("%(%.2f %)", x)); + root.tmap((ref x) => writefln("%(%.2f %)", x)); + + // Modify the arrays of the whole tree. + //root.tmap((x){ x[] += 10; }); + root.tmap((ref x){ x[] += 10; }); + + // Show the arrays of the whole tree again. + writeln(); + //root.tmap(x => writefln("%(%.2f %)", x)); + root.tmap((ref x) => writefln("%(%.2f %)", x)); +} diff --git a/Task/Parametric-polymorphism/E/parametric-polymorphism-1.e b/Task/Parametric-polymorphism/E/parametric-polymorphism-1.e new file mode 100644 index 0000000000..0014d54b2f --- /dev/null +++ b/Task/Parametric-polymorphism/E/parametric-polymorphism-1.e @@ -0,0 +1,31 @@ +interface TreeAny guards TreeStamp {} +def Tree { + to get(Value) { + def Tree1 { + to coerce(specimen, ejector) { + def tree := TreeAny.coerce(specimen, ejector) + if (tree.valueType() != Value) { + throw.eject(ejector, "Tree value type mismatch") + } + return tree + } + } + return Tree1 + } +} + +def makeTree(T, var value :T, left :nullOk[Tree[T]], right :nullOk[Tree[T]]) { + def tree implements TreeStamp { + to valueType() { return T } + to map(f) { + value := f(value) # the declaration of value causes this to be checked + if (left != null) { + left.map(f) + } + if (right != null) { + right.map(f) + } + } + } + return tree +} diff --git a/Task/Parametric-polymorphism/E/parametric-polymorphism-2.e b/Task/Parametric-polymorphism/E/parametric-polymorphism-2.e new file mode 100644 index 0000000000..3ac89ada7b --- /dev/null +++ b/Task/Parametric-polymorphism/E/parametric-polymorphism-2.e @@ -0,0 +1,11 @@ +? def t := makeTree(int, 0, null, null) +# value: + +? t :Tree[String] +# problem: Tree value type mismatch + +? t :Tree[Int] +# problem: Failed: Undefined variable: Int + +? t :Tree[int] +# value: diff --git a/Task/Parametric-polymorphism/Go/parametric-polymorphism.go b/Task/Parametric-polymorphism/Go/parametric-polymorphism.go new file mode 100644 index 0000000000..89928cc59d --- /dev/null +++ b/Task/Parametric-polymorphism/Go/parametric-polymorphism.go @@ -0,0 +1,53 @@ +package main + +import "fmt" + +func average(c intCollection) float64 { + var sum, count int + c.mapElements(func(n int) { + sum += n + count++ + }) + return float64(sum) / float64(count) +} + +func main() { + t1 := new(binaryTree) + t2 := new(bTree) + a1 := average(t1) + a2 := average(t2) + fmt.Println("binary tree average:", a1) + fmt.Println("b-tree average:", a2) +} + +type intCollection interface { + mapElements(func(int)) +} + +type binaryTree struct { + // dummy representation details + left, right bool +} + +func (t *binaryTree) mapElements(visit func(int)) { + // dummy implementation + if t.left == t.right { + visit(3) + visit(1) + visit(4) + } +} + +type bTree struct { + // dummy representation details + buckets int +} + +func (t *bTree) mapElements(visit func(int)) { + // dummy implementation + if t.buckets >= 0 { + visit(1) + visit(5) + visit(9) + } +} diff --git a/Task/Parametric-polymorphism/Haskell/parametric-polymorphism-1.hs b/Task/Parametric-polymorphism/Haskell/parametric-polymorphism-1.hs new file mode 100644 index 0000000000..c041a2414b --- /dev/null +++ b/Task/Parametric-polymorphism/Haskell/parametric-polymorphism-1.hs @@ -0,0 +1,5 @@ +data Tree a = Empty | Node a (Tree a) (Tree a) + +mapTree :: (a -> b) -> Tree a -> Tree b +mapTree f Empty = Empty +mapTree f (Node x l r) = Node (f x) (mapTree f l) (mapTree f r) diff --git a/Task/Parametric-polymorphism/Haskell/parametric-polymorphism-2.hs b/Task/Parametric-polymorphism/Haskell/parametric-polymorphism-2.hs new file mode 100644 index 0000000000..735f57fece --- /dev/null +++ b/Task/Parametric-polymorphism/Haskell/parametric-polymorphism-2.hs @@ -0,0 +1,3 @@ +instance Functor Tree where + fmap f Empty = Empty + fmap f (Node x l r) = Node (f x) (fmap f l) (fmap f r) diff --git a/Task/Parametric-polymorphism/Haskell/parametric-polymorphism-3.hs b/Task/Parametric-polymorphism/Haskell/parametric-polymorphism-3.hs new file mode 100644 index 0000000000..1c6215a717 --- /dev/null +++ b/Task/Parametric-polymorphism/Haskell/parametric-polymorphism-3.hs @@ -0,0 +1,2 @@ +add1Everywhere :: (Functor f, Num a) => f a -> f a +add1Everywhere nums = fmap (\x -> x + 1) nums diff --git a/Task/Parametric-polymorphism/Inform-7/parametric-polymorphism-1.inf b/Task/Parametric-polymorphism/Inform-7/parametric-polymorphism-1.inf new file mode 100644 index 0000000000..af8bcdb33a --- /dev/null +++ b/Task/Parametric-polymorphism/Inform-7/parametric-polymorphism-1.inf @@ -0,0 +1,13 @@ +Polymorphism is a room. + +To find (V - K) in (L - list of values of kind K): + repeat with N running from 1 to the number of entries in L: + if entry N in L is V: + say "Found [V] at entry [N] in [L]."; + stop; + say "Did not find [V] in [L]." + +When play begins: + find "needle" in {"parrot", "needle", "rutabaga"}; + find 6 in {2, 3, 4}; + end the story. diff --git a/Task/Parametric-polymorphism/Inform-7/parametric-polymorphism-2.inf b/Task/Parametric-polymorphism/Inform-7/parametric-polymorphism-2.inf new file mode 100644 index 0000000000..7ed8d98f44 --- /dev/null +++ b/Task/Parametric-polymorphism/Inform-7/parametric-polymorphism-2.inf @@ -0,0 +1,8 @@ +list of numbers +relation of texts to rooms +object based rulebook producing a number +description of things +activity on things +number valued property +text valued table column +phrase (text, text) -> number diff --git a/Task/Parametric-polymorphism/Java/parametric-polymorphism.java b/Task/Parametric-polymorphism/Java/parametric-polymorphism.java new file mode 100644 index 0000000000..622230f709 --- /dev/null +++ b/Task/Parametric-polymorphism/Java/parametric-polymorphism.java @@ -0,0 +1,13 @@ +public class Tree{ + private T value; + private Tree left; + private Tree right; + + public void replaceAll(T value){ + this.value = value; + if(left != null) + left.replaceAll(value); + if(right != null) + right.replaceAll(value); + } +} diff --git a/Task/Parametric-polymorphism/OCaml/parametric-polymorphism.ocaml b/Task/Parametric-polymorphism/OCaml/parametric-polymorphism.ocaml new file mode 100644 index 0000000000..afb7195839 --- /dev/null +++ b/Task/Parametric-polymorphism/OCaml/parametric-polymorphism.ocaml @@ -0,0 +1,6 @@ +type 'a tree = Empty | Node of 'a * 'a tree * 'a tree + +(** val map_tree : ('a -> 'b) -> 'a tree -> 'b tree *) +let rec map_tree f = function + | Empty -> Empty + | Node (x,l,r) -> Node (f x, map_tree f l, map_tree f r) diff --git a/Task/Parametric-polymorphism/Perl-6/parametric-polymorphism.pl6 b/Task/Parametric-polymorphism/Perl-6/parametric-polymorphism.pl6 new file mode 100644 index 0000000000..a98b49ccda --- /dev/null +++ b/Task/Parametric-polymorphism/Perl-6/parametric-polymorphism.pl6 @@ -0,0 +1,20 @@ +role BinaryTree[::T] { + has T $!value; + has BinaryTree[T] $.left; + has BinaryTree[T] $.right; + + method replace-all(T $value) { + $!value = $value; + $.left.?replace-all($value); + $.right.?replace-all($value); + } +} + +class IntTree does BinaryTree[Int] { } + +my IntTree $it .= new(value => 1, + left => IntTree.new(value => 2), + right => IntTree.new(value => 3)); + +$it.replace-all(42); +say $it.perl; diff --git a/Task/Parametric-polymorphism/PicoLisp/parametric-polymorphism.l b/Task/Parametric-polymorphism/PicoLisp/parametric-polymorphism.l new file mode 100644 index 0000000000..25ed06b147 --- /dev/null +++ b/Task/Parametric-polymorphism/PicoLisp/parametric-polymorphism.l @@ -0,0 +1,4 @@ +(de mapTree (Tree Fun) + (set Tree (Fun (car Tree))) + (and (cadr Tree) (mapTree @ Fun)) + (and (cddr Tree) (mapTree @ Fun)) ) diff --git a/Task/Parametric-polymorphism/Racket/parametric-polymorphism.rkt b/Task/Parametric-polymorphism/Racket/parametric-polymorphism.rkt new file mode 100644 index 0000000000..5c40ec0048 --- /dev/null +++ b/Task/Parametric-polymorphism/Racket/parametric-polymorphism.rkt @@ -0,0 +1,20 @@ +#lang typed/racket + +(define-type (Tree A) (U False (Node A))) + +(struct: (A) Node + ([val : A] [left : (Tree A)] [right : (Tree A)]) + #:transparent) + +(: tree-map (All (A B) (A -> B) (Tree A) -> (Tree B))) +(define (tree-map f tree) + (match tree + [#f #f] + [(Node val left right) + (Node (f val) (tree-map f left) (tree-map f right))])) + +;; unit tests +(require typed/rackunit) +(check-equal? + (tree-map add1 (Node 5 (Node 3 #f #f) #f)) + (Node 6 (Node 4 #f #f) #f)) diff --git a/Task/Parametric-polymorphism/Scala/parametric-polymorphism-1.scala b/Task/Parametric-polymorphism/Scala/parametric-polymorphism-1.scala new file mode 100644 index 0000000000..75e62d7bc4 --- /dev/null +++ b/Task/Parametric-polymorphism/Scala/parametric-polymorphism-1.scala @@ -0,0 +1,4 @@ +case class Tree[+A](value: A, left: Option[Tree[A]], right: Option[Tree[A]]) { + def map[B](f: A => B): Tree[B] = + Tree(f(value), left map (_.map(f)), right map (_.map(f))) +} diff --git a/Task/Parametric-polymorphism/Scala/parametric-polymorphism-2.scala b/Task/Parametric-polymorphism/Scala/parametric-polymorphism-2.scala new file mode 100644 index 0000000000..3175d1c627 --- /dev/null +++ b/Task/Parametric-polymorphism/Scala/parametric-polymorphism-2.scala @@ -0,0 +1,5 @@ +class Employee(val name: String) +class Manager(name: String) extends Employee(name) + +val t = Tree(new Manager("PHB"), None, None) +val t2: Tree[Employee] = t diff --git a/Task/Parametric-polymorphism/Scala/parametric-polymorphism-3.scala b/Task/Parametric-polymorphism/Scala/parametric-polymorphism-3.scala new file mode 100644 index 0000000000..fcd99b3915 --- /dev/null +++ b/Task/Parametric-polymorphism/Scala/parametric-polymorphism-3.scala @@ -0,0 +1,2 @@ +def toName(e: Employee) = e.name +val treeOfNames = t.map(toName) diff --git a/Task/Parametric-polymorphism/Scala/parametric-polymorphism-4.scala b/Task/Parametric-polymorphism/Scala/parametric-polymorphism-4.scala new file mode 100644 index 0000000000..901d2ed046 --- /dev/null +++ b/Task/Parametric-polymorphism/Scala/parametric-polymorphism-4.scala @@ -0,0 +1 @@ +trait Function1[-T1, +R] diff --git a/Task/Parametric-polymorphism/Scala/parametric-polymorphism-5.scala b/Task/Parametric-polymorphism/Scala/parametric-polymorphism-5.scala new file mode 100644 index 0000000000..972143409c --- /dev/null +++ b/Task/Parametric-polymorphism/Scala/parametric-polymorphism-5.scala @@ -0,0 +1,6 @@ +case class Tree[+A](value: A, left: Option[Tree[A]], right: Option[Tree[A]]) { + def map[B](f: A => B): Tree[B] = + Tree(f(value), left map (_.map(f)), right map (_.map(f))) + def find[B >: A](what: B): Boolean = + (value == what) || left.map(_.find(what)).getOrElse(false) || right.map(_.find(what)).getOrElse(false) +} diff --git a/Task/Parametric-polymorphism/Scala/parametric-polymorphism-6.scala b/Task/Parametric-polymorphism/Scala/parametric-polymorphism-6.scala new file mode 100644 index 0000000000..efac462e64 --- /dev/null +++ b/Task/Parametric-polymorphism/Scala/parametric-polymorphism-6.scala @@ -0,0 +1,2 @@ +if (t2.find(new Employee("Dilbert"))) + println("Call Catbert!") diff --git a/Task/Parametric-polymorphism/Scala/parametric-polymorphism-7.scala b/Task/Parametric-polymorphism/Scala/parametric-polymorphism-7.scala new file mode 100644 index 0000000000..d86d1b3be8 --- /dev/null +++ b/Task/Parametric-polymorphism/Scala/parametric-polymorphism-7.scala @@ -0,0 +1,4 @@ +trait DFA { + type Element + val map = new collection.mutable.HashMap[Element, DFA]() +} diff --git a/Task/Parametric-polymorphism/Seed7/parametric-polymorphism.seed7 b/Task/Parametric-polymorphism/Seed7/parametric-polymorphism.seed7 new file mode 100644 index 0000000000..2caf5401b7 --- /dev/null +++ b/Task/Parametric-polymorphism/Seed7/parametric-polymorphism.seed7 @@ -0,0 +1,37 @@ +$ include "seed7_05.s7i"; + +const func type: container (in type: elemType) is func + result + var type: container is void; + begin + container := array elemType; + + global + + const func container: map (in container: aContainer, + inout elemType: aVariable, ref func elemType: aFunc) is func + result + var container: mapResult is container.value; + begin + for aVariable range aContainer do + mapResult &:= aFunc; + end for; + end func; + + end global; + end func; + +const type: intContainer is container(integer); +var intContainer: container1 is [] (1, 2, 4, 6, 10, 12, 16, 18, 22); +var intContainer: container2 is 0 times 0; + +const proc: main is func + local + var integer: num is 0; + begin + container2 := map(container1, num, num + 1); + for num range container2 do + write(num <& " "); + end for; + writeln; + end func; diff --git a/Task/Parametric-polymorphism/Standard-ML/parametric-polymorphism.ml b/Task/Parametric-polymorphism/Standard-ML/parametric-polymorphism.ml new file mode 100644 index 0000000000..04579621ce --- /dev/null +++ b/Task/Parametric-polymorphism/Standard-ML/parametric-polymorphism.ml @@ -0,0 +1,5 @@ +datatype 'a tree = Empty | Node of 'a * 'a tree * 'a tree + +(** val map_tree = fn : ('a -> 'b) -> 'a tree -> 'b tree *) +fun map_tree f Empty = Empty + | map_tree f (Node (x,l,r)) = Node (f x, map_tree f l, map_tree f r) diff --git a/Task/Parametric-polymorphism/Ursala/parametric-polymorphism-1.ursala b/Task/Parametric-polymorphism/Ursala/parametric-polymorphism-1.ursala new file mode 100644 index 0000000000..514fb34bbd --- /dev/null +++ b/Task/Parametric-polymorphism/Ursala/parametric-polymorphism-1.ursala @@ -0,0 +1 @@ +binary_tree_of "node-type" = "node-type"%hhhhWZAZ diff --git a/Task/Parametric-polymorphism/Ursala/parametric-polymorphism-2.ursala b/Task/Parametric-polymorphism/Ursala/parametric-polymorphism-2.ursala new file mode 100644 index 0000000000..a6845629ea --- /dev/null +++ b/Task/Parametric-polymorphism/Ursala/parametric-polymorphism-2.ursala @@ -0,0 +1,5 @@ +#import tag + +#fix general_type_fixer 1 + +binary_tree_of "node-type" = ("node-type",(binary_tree_of "node-type")%Z)%drWZwlwAZ diff --git a/Task/Parametric-polymorphism/Ursala/parametric-polymorphism-3.ursala b/Task/Parametric-polymorphism/Ursala/parametric-polymorphism-3.ursala new file mode 100644 index 0000000000..c398dd6e7a --- /dev/null +++ b/Task/Parametric-polymorphism/Ursala/parametric-polymorphism-3.ursala @@ -0,0 +1 @@ +binary_tree_of = %-hhhhWZAZ diff --git a/Task/Parametric-polymorphism/Ursala/parametric-polymorphism-4.ursala b/Task/Parametric-polymorphism/Ursala/parametric-polymorphism-4.ursala new file mode 100644 index 0000000000..bbf0614aed --- /dev/null +++ b/Task/Parametric-polymorphism/Ursala/parametric-polymorphism-4.ursala @@ -0,0 +1 @@ +binary_tree_map "f" = ~&a^& ^A/"f"@an ~&amPfamPWB diff --git a/Task/Parametric-polymorphism/Ursala/parametric-polymorphism-5.ursala b/Task/Parametric-polymorphism/Ursala/parametric-polymorphism-5.ursala new file mode 100644 index 0000000000..7f9a605172 --- /dev/null +++ b/Task/Parametric-polymorphism/Ursala/parametric-polymorphism-5.ursala @@ -0,0 +1 @@ +binary_tree_map = ~&a^&+ ^A\~&amPfamPWB+ @an diff --git a/Task/Parametric-polymorphism/Ursala/parametric-polymorphism-6.ursala b/Task/Parametric-polymorphism/Ursala/parametric-polymorphism-6.ursala new file mode 100644 index 0000000000..979bd65147 --- /dev/null +++ b/Task/Parametric-polymorphism/Ursala/parametric-polymorphism-6.ursala @@ -0,0 +1,7 @@ +string_tree = binary_tree_of %s + +x = 'foo': ('bar': (),'baz': ()) + +#cast string_tree + +example = (binary_tree_map "s". "s"--"s") x diff --git a/Task/Parametrized-SQL-statement/0DESCRIPTION b/Task/Parametrized-SQL-statement/0DESCRIPTION new file mode 100644 index 0000000000..a9bc8ac98b --- /dev/null +++ b/Task/Parametrized-SQL-statement/0DESCRIPTION @@ -0,0 +1,7 @@ +Parameterized SQL statements are an easy way to avoid [[wp:SQL injection|SQL injection]] attacks. SQL drivers and libraries will automatically "sanitize" input to parameterized SQL statements to avoid these catastrophic database attacks. + +Using a SQL update statement like this one (spacing is optional): +UPDATE players + SET name = 'Smith, Steve', score = 42, active = true + WHERE jerseyNum = 99 +show how to make a parameterized SQL statement, set the parameters to the values given above, and execute the statement. diff --git a/Task/Parametrized-SQL-statement/1META.yaml b/Task/Parametrized-SQL-statement/1META.yaml new file mode 100644 index 0000000000..7fec23b86a --- /dev/null +++ b/Task/Parametrized-SQL-statement/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Database operations diff --git a/Task/Parametrized-SQL-statement/Ada/parametrized-sql-statement.ada b/Task/Parametrized-SQL-statement/Ada/parametrized-sql-statement.ada new file mode 100644 index 0000000000..ab767e4d88 --- /dev/null +++ b/Task/Parametrized-SQL-statement/Ada/parametrized-sql-statement.ada @@ -0,0 +1,38 @@ +-- Version for sqlite +with GNATCOLL.SQL_Impl; use GNATCOLL.SQL_Impl; +with GNATCOLL.SQL.Exec; use GNATCOLL.SQL.Exec; +with GNATCOLL.SQL.Sqlite; use GNATCOLL.SQL; + +procedure Prepared_Query is + + DB_Descr : Database_Description; + Conn : Database_Connection; + Query : Prepared_Statement; + --sqlite does not support boolean fields + True_Str : aliased String := "TRUE"; + Param : SQL_Parameters (1 .. 4) := + (1 => (Parameter_Text, null), + 2 => (Parameter_Integer, 0), + 3 => (Parameter_Text, null), + 4 => (Parameter_Integer, 0)); +begin + -- Allocate and initialize the description of the connection + Setup_Database (DB_Descr, "rosetta.db", "", "", "", DBMS_Sqlite); + -- Allocate the connection + Conn := Sqlite.Build_Sqlite_Connection (DB_Descr); + -- Initialize the connection + Reset_Connection (DB_Descr, Conn); + Query := + Prepare + ("UPDATE players SET name = ?, score = ?, active = ? " & + " WHERE jerseyNum = ?"); + declare + Name : aliased String := "Smith, Steve"; + begin + Param := ("+" (Name'Access), "+" (42), "+" (True_Str'Access), "+" (99)); + Execute (Conn, Query, Param); + end; + Commit_Or_Rollback (Conn); + Free (Conn); + Free (DB_Descr); +end Prepared_Query; diff --git a/Task/Parametrized-SQL-statement/Java/parametrized-sql-statement.java b/Task/Parametrized-SQL-statement/Java/parametrized-sql-statement.java new file mode 100644 index 0000000000..2faf2c4f1a --- /dev/null +++ b/Task/Parametrized-SQL-statement/Java/parametrized-sql-statement.java @@ -0,0 +1,28 @@ +import java.sql.DriverManager; +import java.sql.Connection; +import java.sql.PreparedStatement; + +public class DBDemo{ + private String protocol; //set this to some connection protocol like "jdbc:sqlserver://" + private String dbName; //set this to the name of your database + private String username; + private String password; + + Connection conn = DriverManager.getConnection(protocol + dbName, username, password); + PreparedStatement query; + + public int setUpAndExecPS(){ + query = conn.prepareStatement( + "UPDATE players SET name = ?, score = ?, active = ? WHERE jerseyNum = ?"); + + query.setString(1, "Smith, Steve");//automatically sanitizes and adds quotes + query.setInt(2, 42); + query.setBoolean(3, true); + query.setInt(4, 99); + //there are similar methods for other SQL types in PerparedStatement + + return query.executeUpdate();//returns the number of rows changed + //PreparedStatement.executeQuery() will return a java.sql.ResultSet, + //execute() will simply return a boolean saying whether it succeeded or not + } +} diff --git a/Task/Parametrized-SQL-statement/Mathematica/parametrized-sql-statement.math b/Task/Parametrized-SQL-statement/Mathematica/parametrized-sql-statement.math new file mode 100644 index 0000000000..45769a1b5f --- /dev/null +++ b/Task/Parametrized-SQL-statement/Mathematica/parametrized-sql-statement.math @@ -0,0 +1,4 @@ +Needs["DatabaseLink`"]; +conn=OpenSQLConnection[JDBC["ODBC(DSN)", "testdb"], "Username" -> "John", "Password" -> "JohnsPassword"]; +SQLUpdate[conn,"players",{"name","score","active"},{"Smith, Steve", 42,"TRUE"},SQLColumn["jerseyNum"] = 99]; +CloseSQLConnection[conn]; diff --git a/Task/Parametrized-SQL-statement/NetRexx/parametrized-sql-statement.netrexx b/Task/Parametrized-SQL-statement/NetRexx/parametrized-sql-statement.netrexx new file mode 100644 index 0000000000..d782913ce9 --- /dev/null +++ b/Task/Parametrized-SQL-statement/NetRexx/parametrized-sql-statement.netrexx @@ -0,0 +1,139 @@ +/* NetRexx */ +options replace format comments java crossref symbols nobinary + +import java.sql. + +-- ============================================================================= +class RParameterizedSQLSimple public + + properties indirect + connexion = Connection + + properties inheritable constant + DRIVER = "org.apache.derby.jdbc.EmbeddedDriver" + DBURL = "jdbc:derby:" + DBNAME = "/workspace/DB.DerbySamples/DB/TEAMS01" + DBMODE_CREATE = ";create=true" + DBMODE_NOCREATE = ";create=false" + DBMODE_SHUTDOWN = ";shutdown=true" + +-- ============================================================================= +method RParameterizedSQLSimple() + setConnexion(null) + return + +-- ============================================================================= +method createConnexion() inheritable returns Connection signals ClassNotFoundException, InstantiationException, IllegalAccessException + if getConnexion() = null then do + props = Properties() + props.put("user", "user1") + props.put("password", "user1") + + xURL = String DBURL || DBNAME || DBMODE_CREATE + loadDriver(DRIVER) + setConnexion(DriverManager.getConnection(xURL, props)) + end + + return getConnexion() + +-- ============================================================================= +method shutdownConnexion() inheritable returns boolean signals SQLException + + dbState = boolean + xURL = String DBURL || DBNAME || DBMODE_SHUTDOWN + + do + DriverManager.getConnection(xURL) + dbState = isTrue + + catch se = SQLException + if (se.getErrorCode() = 50000) & ("XJ015".equals(se.getSQLState())) then do + say "Derby shut down normally" + dbState = isTrue + end + else if (se.getErrorCode() = 45000) & ("08006".equals(se.getSQLState())) then do + say "Derby database shut down normally" + dbState = isTrue + end + else do + say "Derby did not shut down normally" + dbState = isFalse + signal se + end + end + + return dbState + +-- ============================================================================= +method loadDriver(xdriver = String) inheritable static signals ClassNotFoundException, InstantiationException, IllegalAccessException + + do + Class.forName(xdriver).newInstance() + say "Loaded the appropriate driver" + + catch cnfe = ClassNotFoundException + say "Unable to load the JDBC driver" xdriver + say "Please check your CLASSPATH." + signal cnfe + + catch ie = InstantiationException + say "Unable to instantiate the JDBC driver" xdriver + signal ie + + catch iae = IllegalAccessException + say "Not allowed to access the JDBC driver" xdriver + signal iae + + end + + return + +-- ============================================================================= +method updatePlayer(jerseyNum = int, name = String, score = int, active = boolean) binary inheritable returns int signals SQLException + + updateSQL = "" - + || "UPDATE TEAM.PLAYERS" - + || " SET NAME = ?, SCORE = ?, ACTIVE = ?" - + || " WHERE JERSEYNUM = ?" + + rowCt = int + ix = int 0 + + ps = getConnexion().prepareStatement(updateSQL) + ix = ix + 1; ps.setString(ix, name) + ix = ix + 1; ps.setInt(ix, score) + ix = ix + 1; ps.setBoolean(ix, active) + ix = ix + 1; ps.setInt(ix, jerseyNum) + rowCt = ps.executeUpdate() + + return rowCt + +-- ============================================================================= +method main(args = String[]) public static + + do + tda = RParameterizedSQLSimple() + tda.createConnexion() + + if tda.getConnexion() \= null then do + updated = tda.updatePlayer(99, "Smith, Steve", 42, isTrue) + if updated > 0 then say "Update successful" + else say "Update failed" + + finally + tda.shutdownConnexion() + end + + catch ex = Exception + ex.printStackTrace + end + + return + +-- ============================================================================= +method isTrue() public static returns boolean + return 1 == 1 + +-- ============================================================================= +method isFalse() public static returns boolean + return \isTrue diff --git a/Task/Parametrized-SQL-statement/Objeck/parametrized-sql-statement.objeck b/Task/Parametrized-SQL-statement/Objeck/parametrized-sql-statement.objeck new file mode 100644 index 0000000000..3f43bb27a9 --- /dev/null +++ b/Task/Parametrized-SQL-statement/Objeck/parametrized-sql-statement.objeck @@ -0,0 +1,19 @@ +use IO; +use ODBC; + +bundle Default { + class Sql { + function : Main(args : String[]) ~ Nil { + conn := Connection->New("ds", "user", "password"); + if(conn <> Nil) { + sql := "UPDATE players SET name = ?, score = ?, active = ? WHERE jerseyNum = ?"; + pstmt := conn->CreateParameterStatement(sql); + pstmt->SetVarchar(1, "Smith, Steve"); + pstmt->SetInt(2, 42); + pstmt->SetBit(3, true); + pstmt->SetInt(4, 99); + pstmt->Update()->PrintLine(); + conn->Close(); + }; + } +} diff --git a/Task/Parametrized-SQL-statement/PHP/parametrized-sql-statement.php b/Task/Parametrized-SQL-statement/PHP/parametrized-sql-statement.php new file mode 100644 index 0000000000..526f840d1d --- /dev/null +++ b/Task/Parametrized-SQL-statement/PHP/parametrized-sql-statement.php @@ -0,0 +1,16 @@ +$updatePlayers = "UPDATE `players` SET `name` = ?, `score` = ?, `active` = ?\n". + "WHERE `jerseyNum` = ?"; +$dbh = new PDO( "mysql:dbname=db;host=localhost", "username", "password" ); + +$updateStatement = $dbh->prepare( $updatePlayers ); + +$updateStatement->bindValue( 1, "Smith, Steve", PDO::PARAM_STR ); +$updateStatement->bindValue( 2, 42, PDO::PARAM_INT ); +$updateStatement->bindValue( 3, 1, PDO::PARAM_INT ); +$updateStatement->bindValue( 4, 99, PDO::PARAM_INT ); + +$updateStatement->execute(); + +// alternatively pass parameters as an array to the execute method +$updateStatement = $dbh->prepare( $updatePlayers ); +$updateStatement->execute( array( "Smith, Steve", 42, 1, 99 ) ); diff --git a/Task/Parametrized-SQL-statement/Perl/parametrized-sql-statement.pl b/Task/Parametrized-SQL-statement/Perl/parametrized-sql-statement.pl new file mode 100644 index 0000000000..31834d533a --- /dev/null +++ b/Task/Parametrized-SQL-statement/Perl/parametrized-sql-statement.pl @@ -0,0 +1,7 @@ +use DBI; + +my $db = DBI->connect('DBI:mysql:mydatabase:host','login','password'); + +$statment = $db->prepare("UPDATE players SET name = ?, score = ?, active = ? WHERE jerseyNum = ?"); + +$rows_affected = $statment->execute("Smith, Steve",42,'true',99); diff --git a/Task/Parametrized-SQL-statement/PicoLisp/parametrized-sql-statement.l b/Task/Parametrized-SQL-statement/PicoLisp/parametrized-sql-statement.l new file mode 100644 index 0000000000..11aa26cc74 --- /dev/null +++ b/Task/Parametrized-SQL-statement/PicoLisp/parametrized-sql-statement.l @@ -0,0 +1,4 @@ +(for P (collect 'jerseyNum '+Players 99) + (put!> P 'name "Smith, Steve") + (put!> P 'score 42) + (put!> P 'active T) ) diff --git a/Task/Parametrized-SQL-statement/PureBasic/parametrized-sql-statement.purebasic b/Task/Parametrized-SQL-statement/PureBasic/parametrized-sql-statement.purebasic new file mode 100644 index 0000000000..3b311732ce --- /dev/null +++ b/Task/Parametrized-SQL-statement/PureBasic/parametrized-sql-statement.purebasic @@ -0,0 +1,19 @@ +UseSQLiteDatabase() + +DatabaseFile$ = GetTemporaryDirectory()+"/Batadase.sqt" +; all kind of variables for the given case + table$ = "players" + name$ = "Smith, Steve" + score.w = 42 + active$ ="TRUE" + jerseynum.w =99 + + If OpenDatabase(0, DatabaseFile$, "", "") + Result = DatabaseUpdate((0, "UPDATE "+table$+" SET name = '"+name$+"', score = '"+Str(score)+"', active = '"+active$+"' WHERE jerseyNum = "+Str(num)+";") + If Result = 0 + Debug DatabaseError() + EndIf + CloseDatabase(0) + Else + Debug "Can't open database !" + EndIf diff --git a/Task/Parametrized-SQL-statement/Python/parametrized-sql-statement.py b/Task/Parametrized-SQL-statement/Python/parametrized-sql-statement.py new file mode 100644 index 0000000000..10e426f528 --- /dev/null +++ b/Task/Parametrized-SQL-statement/Python/parametrized-sql-statement.py @@ -0,0 +1,25 @@ +import sqlite3 + +db = sqlite3.connect(':memory:') + +# setup +db.execute('create temp table players (name, score, active, jerseyNum)') +db.execute('insert into players values ("name",0,"false",99)') +db.execute('insert into players values ("name",0,"false",100)') + +# demonstrate parameterized SQL + +# example 1 -- simple placeholders +db.execute('update players set name=?, score=?, active=? where jerseyNum=?', ('Smith, Steve', 42, True, 99)) + +# example 2 -- named placeholders +db.execute('update players set name=:name, score=:score, active=:active where jerseyNum=:num', + {'num': 100, + 'name': 'John Doe', + 'active': False, + 'score': -1} +) + +# and show the results +for row in db.execute('select * from players'): + print(row) diff --git a/Task/Parametrized-SQL-statement/Ruby/parametrized-sql-statement.rb b/Task/Parametrized-SQL-statement/Ruby/parametrized-sql-statement.rb new file mode 100644 index 0000000000..b5185ba27d --- /dev/null +++ b/Task/Parametrized-SQL-statement/Ruby/parametrized-sql-statement.rb @@ -0,0 +1,33 @@ +require 'sqlite3' + +db = SQLite3::Database.new(":memory:") + +# setup +db.execute('create temp table players (name, score, active, jerseyNum)') +db.execute('insert into players values ("name",0,"false",99)') +db.execute('insert into players values ("name",0,"false",100)') +db.execute('insert into players values ("name",0,"false",101)') + +# demonstrate parameterized SQL + +# example 1 -- simple placeholders +db.execute('update players set name=?, score=?, active=? where jerseyNum=?', 'Smith, Steve', 42, true, 99) + +# example 2 -- named placeholders +db.execute('update players set name=:name, score=:score, active=:active where jerseyNum=:num', + :num => 100, + :name => 'John Doe', + :active => false, + :score => -1 +) + +# example 3 -- numbered placeholders +stmt = db.prepare('update players set name=?4, score=?3, active=?2 where jerseyNum=?1') +stmt.bind_param(1, 101) +stmt.bind_param(2, true) +stmt.bind_param(3, 3) +stmt.bind_param(4, "Robert'; DROP TABLE players--") +stmt.execute + +# and show the results +db.execute2('select * from players') {|row| p row} diff --git a/Task/Parametrized-SQL-statement/Tcl/parametrized-sql-statement.tcl b/Task/Parametrized-SQL-statement/Tcl/parametrized-sql-statement.tcl new file mode 100644 index 0000000000..7cf4581765 --- /dev/null +++ b/Task/Parametrized-SQL-statement/Tcl/parametrized-sql-statement.tcl @@ -0,0 +1,22 @@ +package require Tcl 8.6 + +# These next two lines are the only ones specific to SQLite +package require tdbc::sqlite3 +set db [tdbc::sqlite3::connection new /path/to/database.sql] + +# Use a helper procedure to make a scope +proc setPlayer {db jersey -> playerName playerScore playerActive} { + # Note that the '->' above is just syntactic noise for readability + $db allrows { + UPDATE players + SET name = :playerName, score = :playerScore, active = :playerActive + WHERE jerseyNum = :jersey + } + # The named parameters are bound to local variables by default +} + +# How to use... +setPlayer $db 99 -> "Smith, Steve" 42 true +# With apologies to http://xkcd.com/327/ +setPlayer $db 76 -> "Robert'; DROP TABLE players--" 0 false +$db close diff --git a/Task/Parsing-RPN-calculator-algorithm/0DESCRIPTION b/Task/Parsing-RPN-calculator-algorithm/0DESCRIPTION new file mode 100644 index 0000000000..2c785bb46a --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/0DESCRIPTION @@ -0,0 +1,14 @@ +Create a stack-based evaluator for an expression in [[wp:Reverse Polish notation|reverse Polish notation]] that also shows the changes in the stack +as each individual token is processed ''as a table''. + +* Assume an input of a correct, space separated, string of tokens of an RPN expression +* Test with the RPN expression generated from the [[Parsing/Shunting-yard algorithm]] task '3 4 2 * 1 5 - 2 3 ^ ^ / +' then print and display the output here. + +;Note: +* '^' means exponentiation in the expression above. + +;See also: +* [[Parsing/Shunting-yard algorithm]] for a method of generating an RPN from an infix expression. +* Several solutions to [[24 game/Solve]] make use of RPN evaluators (although tracing how they work is not a part of that task). +* [[Parsing/RPN to infix conversion]]. +* [[Arithmetic evaluation]]. diff --git a/Task/Parsing-RPN-calculator-algorithm/ANTLR/parsing-rpn-calculator-algorithm.antlr b/Task/Parsing-RPN-calculator-algorithm/ANTLR/parsing-rpn-calculator-algorithm.antlr new file mode 100644 index 0000000000..beddef18b5 --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/ANTLR/parsing-rpn-calculator-algorithm.antlr @@ -0,0 +1,19 @@ +grammar rpnC ; +// +// rpn Calculator +// +// Nigel Galloway - April 7th., 2012 +// +@members { +Stack s = new Stack(); +} +rpn : (WS* (num|op) (WS | WS* NEWLINE {System.out.println(s.pop());}))*; +num : '-'? Digit+ ('.' Digit+)? {s.push(Double.parseDouble($num.text));}; +Digit : '0'..'9'; +op : '-' {double x = s.pop(); s.push(s.pop() - x);} + | '/' {double x = s.pop(); s.push(s.pop() / x);} + | '*' {s.push(s.pop() * s.pop());} + | '^' {double x = s.pop(); s.push(Math.pow(s.pop(), x));} + | '+' {s.push(s.pop() + s.pop());}; +WS : (' ' | '\t'){skip()}; +NEWLINE : '\r'? '\n'; diff --git a/Task/Parsing-RPN-calculator-algorithm/Ada/parsing-rpn-calculator-algorithm.ada b/Task/Parsing-RPN-calculator-algorithm/Ada/parsing-rpn-calculator-algorithm.ada new file mode 100644 index 0000000000..39827e90e3 --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/Ada/parsing-rpn-calculator-algorithm.ada @@ -0,0 +1,68 @@ +with Ada.Text_IO, Ada.Containers.Vectors; + +procedure RPN_Calculator is + + package IIO is new Ada.Text_IO.Float_IO(Float); + + package Float_Vec is new Ada.Containers.Vectors + (Index_Type => Positive, Element_Type => Float); + Stack: Float_Vec.Vector; + + Input: String := Ada.Text_IO.Get_Line; + Cursor: Positive := Input'First; + New_Cursor: Positive; + +begin + loop + -- read spaces + while Cursor <= Input'Last and then Input(Cursor)=' ' loop + Cursor := Cursor + 1; + end loop; + + exit when Cursor > Input'Last; + + New_Cursor := Cursor; + while New_Cursor <= Input'Last and then Input(New_Cursor) /= ' ' loop + New_Cursor := New_Cursor + 1; + end loop; + + -- try to read a number and push it to the stack + declare + Last: Positive; + Value: Float; + X, Y: Float; + begin + IIO.Get(From => Input(Cursor .. New_Cursor - 1), + Item => Value, + Last => Last); + Stack.Append(Value); + Cursor := New_Cursor; + + exception -- if reading the number fails, try to read an operator token + when others => + Y := Stack.Last_Element; Stack.Delete_Last; -- pick two elements + X := Stack.Last_Element; Stack.Delete_Last; -- from the stack + case Input(Cursor) is + when '+' => Stack.Append(X+Y); + when '-' => Stack.Append(X-Y); + when '*' => Stack.Append(X*Y); + when '/' => Stack.Append(X/Y); + when '^' => Stack.Append(X ** Integer(Float'Rounding(Y))); + when others => raise Program_Error with "unecpected token '" + & Input(Cursor) & "' at column" & Integer'Image(Cursor); + end case; + Cursor := New_Cursor; + end; + + for I in Stack.First_Index .. Stack.Last_Index loop + Ada.Text_IO.Put(" "); + IIO.Put(Stack.Element(I), Aft => 5, Exp => 0); + end loop; + Ada.Text_IO.New_Line; + end loop; + + Ada.Text_IO.Put("Result = "); + IIO.Put(Item => Stack.Last_Element, Aft => 5, Exp => 0); + + +end RPN_Calculator; diff --git a/Task/Parsing-RPN-calculator-algorithm/AutoHotkey/parsing-rpn-calculator-algorithm.ahk b/Task/Parsing-RPN-calculator-algorithm/AutoHotkey/parsing-rpn-calculator-algorithm.ahk new file mode 100644 index 0000000000..938f852a9b --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/AutoHotkey/parsing-rpn-calculator-algorithm.ahk @@ -0,0 +1,35 @@ +evalRPN("3 4 2 * 1 5 - 2 3 ^ ^ / +") +evalRPN(s){ + stack := [] + out := "For RPN expression: '" s "'`r`n`r`nTOKEN`t`tACTION`t`t`tSTACK`r`n" + Loop Parse, s + If A_LoopField is number + t .= A_LoopField + else + { + If t + stack.Insert(t) + , out .= t "`tPush num onto top of stack`t" stackShow(stack) "`r`n" + , t := "" + If InStr("+-/*^", l := A_LoopField) + { + a := stack.Remove(), b := stack.Remove() + stack.Insert( l = "+" ? b + a + :l = "-" ? b - a + :l = "*" ? b * a + :l = "/" ? b / a + :l = "^" ? b **a + :0 ) + out .= l "`tApply op " l " to top of stack`t" stackShow(stack) "`r`n" + } + } + r := stack.Remove() + out .= "`r`n The final output value is: '" r "'" + clipboard := out + return r +} +StackShow(stack){ + for each, value in stack + out .= A_Space value + return subStr(out, 2) +} diff --git a/Task/Parsing-RPN-calculator-algorithm/BBC-BASIC/parsing-rpn-calculator-algorithm.bbc b/Task/Parsing-RPN-calculator-algorithm/BBC-BASIC/parsing-rpn-calculator-algorithm.bbc new file mode 100644 index 0000000000..82708a7c64 --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/BBC-BASIC/parsing-rpn-calculator-algorithm.bbc @@ -0,0 +1,38 @@ + @% = &60B + RPN$ = "3 4 2 * 1 5 - 2 3 ^ ^ / +" + + DIM Stack(1000) + SP% = 0 + + FOR i% = 1 TO LEN(RPN$) + Token$ = MID$(RPN$,i%,1) + IF Token$ <> " " THEN + PRINT Token$ " :"; + CASE Token$ OF + WHEN "+": PROCpush(FNpop + FNpop) + WHEN "-": PROCpush(-FNpop + FNpop) + WHEN "*": PROCpush(FNpop * FNpop) + WHEN "/": n = FNpop : PROCpush(FNpop / n) + WHEN "^": n = FNpop : PROCpush(FNpop ^ n) + WHEN "0","1","2","3","4","5","6","7","8","9": + PROCpush(VALMID$(RPN$,i%)) + WHILE ASCMID$(RPN$,i%)>=48 AND ASCMID$(RPN$,1)<=57 + i% += 1 + ENDWHILE + ENDCASE + FOR j% = SP%-1 TO 0 STEP -1 : PRINT Stack(j%); : NEXT + PRINT + ENDIF + NEXT i% + END + + DEF PROCpush(n) + IF SP% > DIM(Stack(),1) ERROR 100, "Stack full" + Stack(SP%) = n + SP% += 1 + ENDPROC + + DEF FNpop + IF SP% = 0 ERROR 100, "Stack empty" + SP% -= 1 + = Stack(SP%) diff --git a/Task/Parsing-RPN-calculator-algorithm/C++/parsing-rpn-calculator-algorithm.cpp b/Task/Parsing-RPN-calculator-algorithm/C++/parsing-rpn-calculator-algorithm.cpp new file mode 100644 index 0000000000..1c363fb68b --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/C++/parsing-rpn-calculator-algorithm.cpp @@ -0,0 +1,53 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +double rpn(const std::string &expr){ + std::istringstream iss(expr); + std::vector stack; + std::cout << "Input\tOperation\tStack after" << std::endl; + std::string token; + while (iss >> token) { + std::cout << token << "\t"; + double tokenNum; + if (std::istringstream(token) >> tokenNum) { + std::cout << "Push\t\t"; + stack.push_back(tokenNum); + } else { + std::cout << "Operate\t\t"; + double secondOperand = stack.back(); + stack.pop_back(); + double firstOperand = stack.back(); + stack.pop_back(); + if (token == "*") + stack.push_back(firstOperand * secondOperand); + else if (token == "/") + stack.push_back(firstOperand / secondOperand); + else if (token == "-") + stack.push_back(firstOperand - secondOperand); + else if (token == "+") + stack.push_back(firstOperand + secondOperand); + else if (token == "^") + stack.push_back(std::pow(firstOperand, secondOperand)); + else { //just in case + std::cerr << "Error" << std::endl; + std::exit(1); + } + } + std::copy(stack.begin(), stack.end(), std::ostream_iterator(std::cout, " ")); + std::cout << std::endl; + } + return stack.back(); +} + +int main() { + std::string s = " 3 4 2 * 1 5 - 2 3 ^ ^ / + "; + std::cout << "Final answer: " << rpn(s) << std::endl; + + return 0; +} diff --git a/Task/Parsing-RPN-calculator-algorithm/C/parsing-rpn-calculator-algorithm-1.c b/Task/Parsing-RPN-calculator-algorithm/C/parsing-rpn-calculator-algorithm-1.c new file mode 100644 index 0000000000..9337a455d7 --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/C/parsing-rpn-calculator-algorithm-1.c @@ -0,0 +1,62 @@ +#include +#include +#include +#include + +void die(const char *msg) +{ + fprintf(stderr, "%s", msg); + abort(); +} + +#define MAX_D 256 +double stack[MAX_D]; +int depth; + +void push(double v) +{ + if (depth >= MAX_D) die("stack overflow\n"); + stack[depth++] = v; +} + +double pop() +{ + if (!depth) die("stack underflow\n"); + return stack[--depth]; +} + +double rpn(char *s) +{ + double a, b; + int i; + char *e, *w = " \t\n\r\f"; + + for (s = strtok(s, w); s; s = strtok(0, w)) { + a = strtod(s, &e); + if (e > s) printf(" :"), push(a); +#define binop(x) printf("%c:", *s), b = pop(), a = pop(), push(x) + else if (*s == '+') binop(a + b); + else if (*s == '-') binop(a - b); + else if (*s == '*') binop(a * b); + else if (*s == '/') binop(a / b); + else if (*s == '^') binop(pow(a, b)); +#undef binop + else { + fprintf(stderr, "'%c': ", *s); + die("unknown oeprator\n"); + } + for (i = depth; i-- || 0 * putchar('\n'); ) + printf(" %g", stack[i]); + } + + if (depth != 1) die("stack leftover\n"); + + return pop(); +} + +int main(void) +{ + char s[] = " 3 4 2 * 1 5 - 2 3 ^ ^ / + "; + printf("%g\n", rpn(s)); + return 0; +} diff --git a/Task/Parsing-RPN-calculator-algorithm/C/parsing-rpn-calculator-algorithm-2.c b/Task/Parsing-RPN-calculator-algorithm/C/parsing-rpn-calculator-algorithm-2.c new file mode 100644 index 0000000000..1bd2a7fb9b --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/C/parsing-rpn-calculator-algorithm-2.c @@ -0,0 +1,53 @@ +#include +#include +#include +#include +#include + +#define die(msg) fprintf(stderr, msg"\n"), abort(); +double get(const char *s, const char *e, char **new_e) +{ + const char *t; + double a, b; + + for (e--; e >= s && isspace(*e); e--); + for (t = e; t > s && !isspace(t[-1]); t--); + + if (t < s) die("underflow"); + +#define get2(expr) b = get(s, t, (char **)&t), a = get(s, t, (char **)&t), a = expr + a = strtod(t, (char **)&e); + if (e <= t) { + if (t[0] == '+') get2(a + b); + else if (t[0] == '-') get2(a - b); + else if (t[0] == '*') get2(a * b); + else if (t[0] == '/') get2(a / b); + else if (t[0] == '^') get2(pow(a, b)); + else { + fprintf(stderr, "'%c': ", t[0]); + die("unknown token"); + } + } +#undef get2 + + *(const char **)new_e = t; + return a; +} + +double rpn(const char *s) +{ + const char *e = s + strlen(s); + double v = get(s, e, (char**)&e); + + while (e > s && isspace(e[-1])) e--; + if (e == s) return v; + + fprintf(stderr, "\"%.*s\": ", e - s, s); + die("front garbage"); +} + +int main(void) +{ + printf("%g\n", rpn("3 4 2 * 1 5 - 2 3 ^ ^ / +")); + return 0; +} diff --git a/Task/Parsing-RPN-calculator-algorithm/Clojure/parsing-rpn-calculator-algorithm.clj b/Task/Parsing-RPN-calculator-algorithm/Clojure/parsing-rpn-calculator-algorithm.clj new file mode 100644 index 0000000000..6c38c61dd1 --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/Clojure/parsing-rpn-calculator-algorithm.clj @@ -0,0 +1,29 @@ +(ns rosettacode.parsing-rpn-calculator-algorithm + (:require clojure.math.numeric-tower + clojure.string + clojure.pprint)) + +(def operators + "the only allowable operators for our calculator" + {"+" + + "-" - + "*" * + "/" / + "^" clojure.math.numeric-tower/expt}) + +(defn rpn + "takes a string and returns a lazy-seq of all the stacks" + [string] + (letfn [(rpn-reducer [stack item] ; this takes a stack and one item and makes a new stack + (if (contains? operators item) + (let [operand-1 (peek stack) ; if we used lists instead of vectors, we could use destructuring, but stacks would look backwards + stack-1 (pop stack)] ;we're assuming that all the operators are binary + (conj (pop stack-1) + ((operators item) (peek stack-1) operand-1))) + (conj stack (Long. item))))] ; if it wasn't an operator, we'll assume it's a long. Could choose bigint, or even read-line + (reductions rpn-reducer [] (clojure.string/split string #"\s+")))) ;reductions is like reduce only shows all the intermediate steps + +(let [stacks (rpn "3 4 2 * 1 5 - 2 3 ^ ^ / +")] ;bind it so we can output the answer separately. + (println "stacks: ") + (clojure.pprint/pprint stacks) + (print "answer:" (->> stacks last first))) diff --git a/Task/Parsing-RPN-calculator-algorithm/D/parsing-rpn-calculator-algorithm.d b/Task/Parsing-RPN-calculator-algorithm/D/parsing-rpn-calculator-algorithm.d new file mode 100644 index 0000000000..12467b1b1a --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/D/parsing-rpn-calculator-algorithm.d @@ -0,0 +1,26 @@ +import std.stdio, std.string, std.conv, std.typetuple; + +void main() { + auto input = "3 4 2 * 1 5 - 2 3 ^ ^ / +"; + writeln("For postfix expression: ", input); + writeln("\nToken Action Stack"); + real[] stack; + foreach (tok; input.split()) { + auto action = "Apply op to top of stack"; + switch (tok) { + foreach (o; TypeTuple!("+", "-", "*", "/", "^")) { + case o: + mixin("stack[$ - 2]" ~ + (o == "^" ? "^^" : o) ~ "=stack[$ - 1];"); + stack.length--; + break; + } + break; + default: + action = "Push num onto top of stack"; + stack ~= to!real(tok); + } + writefln("%3s %-26s %s", tok, action, stack); + } + writeln("\nThe final value is ", stack[0]); +} diff --git a/Task/Parsing-RPN-calculator-algorithm/Ela/parsing-rpn-calculator-algorithm.ela b/Task/Parsing-RPN-calculator-algorithm/Ela/parsing-rpn-calculator-algorithm.ela new file mode 100644 index 0000000000..8a0bba2342 --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/Ela/parsing-rpn-calculator-algorithm.ela @@ -0,0 +1,21 @@ +open string console list format read + +eval str = writen "Input\tOperation\tStack after" $ + eval' (split " " str) [] + where eval' [] (s::_) = printfn "Result: {0}" s + eval' (x::xs) sta | "+"? = eval' xs <| op (+) + | "-"? = eval' xs <| op (-) + | "^"? = eval' xs <| op (**) + | "/"? = eval' xs <| op (/) + | "*"? = eval' xs <| op (*) + | else = eval' xs <| conv x + where c? = x == c + op (^) = out "Operate" st' $ st' + where st' = (head ss ^ s) :: tail ss + conv x = out "Push" st' $ st' + where st' = readStr x :: sta + (s,ss) | sta == [] = ((),[]) + | else = (head sta,tail sta) + out op st' = printfn "{0}\t{1}\t\t{2}" x op st' + +eval "3 4 2 * 1 5 - 2 3 ^ ^ / +" diff --git a/Task/Parsing-RPN-calculator-algorithm/Go/parsing-rpn-calculator-algorithm.go b/Task/Parsing-RPN-calculator-algorithm/Go/parsing-rpn-calculator-algorithm.go new file mode 100644 index 0000000000..6fc146f2c0 --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/Go/parsing-rpn-calculator-algorithm.go @@ -0,0 +1,43 @@ +package main + +import ( + "fmt" + "math" + "strconv" + "strings" +) + +var input = "3 4 2 * 1 5 - 2 3 ^ ^ / +" + +func main() { + fmt.Printf("For postfix %q\n", input) + fmt.Println("\nToken Action Stack") + var stack []float64 + for _, tok := range strings.Fields(input) { + action := "Apply op to top of stack" + switch tok { + case "+": + stack[len(stack)-2] += stack[len(stack)-1] + stack = stack[:len(stack)-1] + case "-": + stack[len(stack)-2] -= stack[len(stack)-1] + stack = stack[:len(stack)-1] + case "*": + stack[len(stack)-2] *= stack[len(stack)-1] + stack = stack[:len(stack)-1] + case "/": + stack[len(stack)-2] /= stack[len(stack)-1] + stack = stack[:len(stack)-1] + case "^": + stack[len(stack)-2] = + math.Pow(stack[len(stack)-2], stack[len(stack)-1]) + stack = stack[:len(stack)-1] + default: + action = "Push num onto top of stack" + f, _ := strconv.ParseFloat(tok, 64) + stack = append(stack, f) + } + fmt.Printf("%3s %-26s %v\n", tok, action, stack) + } + fmt.Println("\nThe final value is", stack[0]) +} diff --git a/Task/Parsing-RPN-calculator-algorithm/Groovy/parsing-rpn-calculator-algorithm-1.groovy b/Task/Parsing-RPN-calculator-algorithm/Groovy/parsing-rpn-calculator-algorithm-1.groovy new file mode 100644 index 0000000000..1826676f94 --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/Groovy/parsing-rpn-calculator-algorithm-1.groovy @@ -0,0 +1,19 @@ +def evaluateRPN(expression) { + def stack = [] as Stack + def binaryOp = { action -> return { action.call(stack.pop(), stack.pop()) } } + def actions = [ + '+': binaryOp { a, b -> b + a }, + '-': binaryOp { a, b -> b - a }, + '*': binaryOp { a, b -> b * a }, + '/': binaryOp { a, b -> b / a }, + '^': binaryOp { a, b -> b ** a } + ] + expression.split(' ').each { item -> + def action = actions[item] ?: { item as BigDecimal } + stack.push(action.call()) + + println "$item: $stack" + } + assert stack.size() == 1 : "Unbalanced Expression: $expression ($stack)" + stack.pop() +} diff --git a/Task/Parsing-RPN-calculator-algorithm/Groovy/parsing-rpn-calculator-algorithm-2.groovy b/Task/Parsing-RPN-calculator-algorithm/Groovy/parsing-rpn-calculator-algorithm-2.groovy new file mode 100644 index 0000000000..8ff1d930f1 --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/Groovy/parsing-rpn-calculator-algorithm-2.groovy @@ -0,0 +1 @@ +println evaluateRPN('3 4 2 * 1 5 - 2 3 ^ ^ / +') diff --git a/Task/Parsing-RPN-calculator-algorithm/Haskell/parsing-rpn-calculator-algorithm.hs b/Task/Parsing-RPN-calculator-algorithm/Haskell/parsing-rpn-calculator-algorithm.hs new file mode 100644 index 0000000000..5e1b6759a4 --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/Haskell/parsing-rpn-calculator-algorithm.hs @@ -0,0 +1,15 @@ +import Data.List (elemIndex) + +-- Show results +main = mapM_ (\(x, y) -> putStrLn $ x ++ " ==> " ++ show y) $ reverse $ zip b (a:c) + where (a, b, c) = solve "3 4 2 * 1 5 - 2 3 ^ ^ / +" + +-- Solve and report RPN +solve = foldl reduce ([], [], []) . words +reduce (xs, ps, st) w = + if i == Nothing + then (read w:xs, ("Pushing " ++ w):ps, xs:st) + else (([(*),(+),(-),(/),(**)]!!o) a b:zs, ("Performing " ++ w):ps, xs:st) + where i = elemIndex (head w) "*+-/^" + Just o = i + (b:a:zs) = xs diff --git a/Task/Parsing-RPN-calculator-algorithm/Icon/parsing-rpn-calculator-algorithm.icon b/Task/Parsing-RPN-calculator-algorithm/Icon/parsing-rpn-calculator-algorithm.icon new file mode 100644 index 0000000000..1e7eeb2f52 --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/Icon/parsing-rpn-calculator-algorithm.icon @@ -0,0 +1,33 @@ +procedure main() + EvalRPN("3 4 2 * 1 5 - 2 3 ^ ^ / +") +end + +link printf +invocable all + +procedure EvalRPN(expr) #: evaluate (and trace stack) an RPN string + + stack := [] + expr ? until pos(0) do { + tab(many(' ')) # consume previous seperator + token := tab(upto(' ')|0) # get token + if token := numeric(token) then { # ... numeric + push(stack,token) + printf("pushed numeric %i : %s\n",token,list2string(stack)) + } + else { # ... operator + every b|a := pop(stack) # pop & reverse operands + case token of { + "+"|"-"|"*"|"^" : push(stack,token(a,b)) + "/" : push(stack,token(real(a),b)) + default : runerr(205,token) + } + printf("applied operator %s : %s\n",token,list2string(stack)) + } + } +end + +procedure list2string(L) #: format list as a string + every (s := "[ ") ||:= !L || " " + return s || "]" +end diff --git a/Task/Parsing-RPN-calculator-algorithm/J/parsing-rpn-calculator-algorithm-1.j b/Task/Parsing-RPN-calculator-algorithm/J/parsing-rpn-calculator-algorithm-1.j new file mode 100644 index 0000000000..8d2dbdda7e --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/J/parsing-rpn-calculator-algorithm-1.j @@ -0,0 +1,4 @@ + a: , <;._1 ' ' , '3 4 2 * 1 5 - 2 3 ^ ^ / +' +┌┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┐ +││3│4│2│*│1│5│-│2│3│^│^│/│+│ +└┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┘ diff --git a/Task/Parsing-RPN-calculator-algorithm/J/parsing-rpn-calculator-algorithm-2.j b/Task/Parsing-RPN-calculator-algorithm/J/parsing-rpn-calculator-algorithm-2.j new file mode 100644 index 0000000000..db9cefaed5 --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/J/parsing-rpn-calculator-algorithm-2.j @@ -0,0 +1,32 @@ + isOp=: '_+-*/^' e.~ {.@>@{. + mo=: 1 :'(}: , u@{:) @ [' + dy=: 1 :'(_2&}. , u/@(_2&{.)) @ [' + dispatch=: (-mo)`(+dy)`(-dy)`(*dy)`(%dy)`(^dy)@.('_+-*/^' i. {.@>@]) + doShift=: (<@, ".@>@{.) , }.@] + doApply=: }.@] ,~ [ <@dispatch {.@] + consume=: [: ([ smoutput@>@{.) >@{. doShift`doApply@.(isOp@]) }. + consume ^: (<:@#) a: , <;._1 ' ' , '3 4 2 * 1 5 - 2 3 ^ ^ / +' +3 +3 4 +3 4 2 +3 8 +3 8 1 +3 8 1 5 +3 8 _4 +3 8 _4 2 +3 8 _4 2 3 +3 8 _4 8 +3 8 65536 +3 0.00012207 +3.00012 +┌───────┐ +│3.00012│ +└───────┘ + consume ^: (<:@#) a: , <;._1 ' ' , '3 _ 4 +' +3 +_3 +_3 4 +1 +┌─┐ +│1│ +└─┘ diff --git a/Task/Parsing-RPN-calculator-algorithm/Java/parsing-rpn-calculator-algorithm.java b/Task/Parsing-RPN-calculator-algorithm/Java/parsing-rpn-calculator-algorithm.java new file mode 100644 index 0000000000..81761c2247 --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/Java/parsing-rpn-calculator-algorithm.java @@ -0,0 +1,59 @@ +import java.util.LinkedList; + +public class RPN{ + public static void evalRPN(String expr){ + String cleanExpr = cleanExpr(expr); + LinkedList stack = new LinkedList(); + System.out.println("Input\tOperation\tStack after"); + for(String token:cleanExpr.split("\\s")){ + System.out.print(token+"\t"); + Double tokenNum = null; + try{ + tokenNum = Double.parseDouble(token); + }catch(NumberFormatException e){} + if(tokenNum != null){ + System.out.print("Push\t\t"); + stack.push(Double.parseDouble(token+"")); + }else if(token.equals("*")){ + System.out.print("Operate\t\t"); + double secondOperand = stack.pop(); + double firstOperand = stack.pop(); + stack.push(firstOperand * secondOperand); + }else if(token.equals("/")){ + System.out.print("Operate\t\t"); + double secondOperand = stack.pop(); + double firstOperand = stack.pop(); + stack.push(firstOperand / secondOperand); + }else if(token.equals("-")){ + System.out.print("Operate\t\t"); + double secondOperand = stack.pop(); + double firstOperand = stack.pop(); + stack.push(firstOperand - secondOperand); + }else if(token.equals("+")){ + System.out.print("Operate\t\t"); + double secondOperand = stack.pop(); + double firstOperand = stack.pop(); + stack.push(firstOperand + secondOperand); + }else if(token.equals("^")){ + System.out.print("Operate\t\t"); + double secondOperand = stack.pop(); + double firstOperand = stack.pop(); + stack.push(Math.pow(firstOperand, secondOperand)); + }else{//just in case + System.out.println("Error"); + return; + } + System.out.println(stack); + } + System.out.println("Final answer: " + stack.pop()); + } + + private static String cleanExpr(String expr){ + //remove all non-operators, non-whitespace, and non digit chars + return expr.replaceAll("[^\\^\\*\\+\\-\\d/\\s]", ""); + } + + public static void main(String[] args){ + evalRPN("3 4 2 * 1 5 - 2 3 ^ ^ / +"); + } +} diff --git a/Task/Parsing-RPN-calculator-algorithm/NetRexx/parsing-rpn-calculator-algorithm.netrexx b/Task/Parsing-RPN-calculator-algorithm/NetRexx/parsing-rpn-calculator-algorithm.netrexx new file mode 100644 index 0000000000..842a8ab57b --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/NetRexx/parsing-rpn-calculator-algorithm.netrexx @@ -0,0 +1,88 @@ +/* NetRexx */ +options replace format comments java crossref symbols nobinary + +numeric digits 20 + +rpnDefaultExpression = '3 4 2 * 1 5 - 2 3 ^ ^ / +' +EODAD = '.*' + +parse arg rpnString + +if rpnString = '.' then rpnString = rpnDefaultExpression +if rpnString = '' then do + say 'Enter numbers or operators [to stop enter' EODAD']:' + loop label rpnloop forever + rpnval = ask + if rpnval == EODAD then leave rpnloop + rpnString = rpnString rpnval + end rpnloop + end + +rpnString = rpnString.space(1) +say rpnString':' evaluateRPN(rpnString) + +return + +-- ----------------------------------------------------------------------------- +method evaluateRPN(rpnString) public static returns Rexx + + stack = LinkedList() + op = 0 + L = 'L' + R = 'R' + rpnString = rpnString.strip('b') + say 'Input\tOperation\tStack after' + loop label rpn while rpnString.length > 0 + parse rpnString token rest + rpnString = rest.strip('b') + say token || '\t\-' + select label tox case token + when '*' then do + say 'Operate\t\t\-' + op[R] = Rexx stack.pop() + op[L] = Rexx stack.pop() + stack.push(op[L] * op[R]) + end + when '/' then do + say 'Operate\t\t\-' + op[R] = Rexx stack.pop() + op[L] = Rexx stack.pop() + stack.push(op[L] / op[R]) + end + when '+' then do + say 'Operate\t\t\-' + op[R] = Rexx stack.pop() + op[L] = Rexx stack.pop() + stack.push(op[L] + op[R]) + end + when '-' then do + say 'Operate\t\t\-' + op[R] = Rexx stack.pop() + op[L] = Rexx stack.pop() + stack.push(op[L] - op[R]) + end + when '^' then do + say 'Operate\t\t\-' + op[R] = Rexx stack.pop() + op[L] = Rexx stack.pop() + -- If exponent is a whole number use Rexx built-in exponentiation operation, otherwise use Math.pow() + op[R] = op[R] + 0 + if op[R].datatype('w') then stack.push(op[L] ** op[R]) + else stack.push(Rexx Math.pow(op[L], op[R])) + end + otherwise do + if token.datatype('n') then do + say 'Push\t\t\-' + stack.push(token) + end + else do + say 'Error\t\t\-' + end + end + end tox + calc = Rexx + say stack.toString + end rpn + say + calc = stack.toString + return calc diff --git a/Task/Parsing-RPN-calculator-algorithm/Objeck/parsing-rpn-calculator-algorithm.objeck b/Task/Parsing-RPN-calculator-algorithm/Objeck/parsing-rpn-calculator-algorithm.objeck new file mode 100644 index 0000000000..e24a98ea23 --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/Objeck/parsing-rpn-calculator-algorithm.objeck @@ -0,0 +1,63 @@ +use IO; +use Struct; + +bundle Default { + class RpnCalc { + function : Main(args : String[]) ~ Nil { + Caculate("3 4 2 * 1 5 - 2 3 ^ ^ / +"); + } + + function : native : Caculate(rpn : String) ~ Nil { + rpn->PrintLine(); + + tokens := rpn->Split(" "); + stack := FloatVector->New(); + each(i : tokens) { + token := tokens[i]->Trim(); + if(token->Size() > 0) { + if(token->Get(0)->IsDigit()) { + stack->AddBack(token->ToFloat()); + } + else { + right := stack->Get(stack->Size() - 1); stack->RemoveBack(); + left := stack->Get(stack->Size() - 1); stack->RemoveBack(); + select(token->Get(0)) { + label '+': { + stack->AddBack(left + right); + } + + label '-': { + stack->AddBack(left - right); + } + + label '*': { + stack->AddBack(left * right); + } + + label '/': { + stack->AddBack(left / right); + } + + label '^': { + stack->AddBack(right->Power(left)); + } + }; + }; + PrintStack(stack); + }; + }; + Console->Print("result: ")->PrintLine(stack->Get(0)); + } + + function : PrintStack(stack : FloatVector) ~ Nil { + " ["->Print(); + each(i : stack) { + stack->Get(i)->Print(); + if(i + 1< stack->Size()) { + ", "->Print(); + }; + }; + ']'->PrintLine(); + } + } +} diff --git a/Task/Parsing-RPN-calculator-algorithm/PHP/parsing-rpn-calculator-algorithm.php b/Task/Parsing-RPN-calculator-algorithm/PHP/parsing-rpn-calculator-algorithm.php new file mode 100644 index 0000000000..cae1b721e6 --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/PHP/parsing-rpn-calculator-algorithm.php @@ -0,0 +1,24 @@ + diff --git a/Task/Parsing-RPN-calculator-algorithm/PL-I/parsing-rpn-calculator-algorithm.pli b/Task/Parsing-RPN-calculator-algorithm/PL-I/parsing-rpn-calculator-algorithm.pli new file mode 100644 index 0000000000..be95fc9db1 --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/PL-I/parsing-rpn-calculator-algorithm.pli @@ -0,0 +1,32 @@ +Calculator: procedure options (main); /* 14 Sept. 2012 */ + declare expression character (100) varying initial (''); + declare ch character (1); + declare (stack controlled, operand) float (18); + declare in file input; + + open file (in) title ('/CALCULAT.DAT,type(text),recsize(100)'); + on endfile (in) go to done; + + put ('Stack contents:'); +main_loop: + do forever; + get file (in) edit (ch) (a(1)); + expression = expression || ch; + if ch = ' ' then iterate; + select (ch); + when ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9') + do; allocate stack; stack = ch; iterate main_loop; end; + when ('+') do; operand = stack; free stack; stack = stack + operand; end; + when ('-') do; operand = stack; free stack; stack = stack - operand; end; + when ('*') do; operand = stack; free stack; stack = stack * operand; end; + when ('/') do; operand = stack; free stack; stack = stack / operand; end; + when ('^') do; operand = stack; free stack; stack = stack ** operand; end; + end; + call show_stack; + end; + +done: + put skip list ('The reverse polish expression = ' || expression); + put skip list ('The evaluated expression = ' || stack); + +end Calculator; diff --git a/Task/Parsing-RPN-calculator-algorithm/Perl-6/parsing-rpn-calculator-algorithm.pl6 b/Task/Parsing-RPN-calculator-algorithm/Perl-6/parsing-rpn-calculator-algorithm.pl6 new file mode 100644 index 0000000000..2e9d5f4341 --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/Perl-6/parsing-rpn-calculator-algorithm.pl6 @@ -0,0 +1,22 @@ +my $proggie = '3 4 2 * 1 5 - 2 3 ^ ^ / +'; + +class RPN is Array { + + method binop(&infix:) { self.push: self.pop Rop self.pop } + + method run($p) { + for $p.words { + say "$_ ({self})"; + when /\d/ { self.push: $_ } + when '+' { self.binop: &[+] } + when '-' { self.binop: &[-] } + when '*' { self.binop: &[*] } + when '/' { self.binop: &[/] } + when '^' { self.binop: &[**] } + default { die "$_ is bogus" } + } + say self; + } +} + +RPN.new.run($proggie); diff --git a/Task/Parsing-RPN-calculator-algorithm/Perl/parsing-rpn-calculator-algorithm.pl b/Task/Parsing-RPN-calculator-algorithm/Perl/parsing-rpn-calculator-algorithm.pl new file mode 100644 index 0000000000..d134ae6056 --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/Perl/parsing-rpn-calculator-algorithm.pl @@ -0,0 +1,17 @@ +# RPN calculator +# +# Nigel Galloway April 2nd., 2012 +# +$WSb = '(?:^|\s+)'; +$WSa = '(?:\s+|$)'; +$num = '([+-/]?(?:\.\d+|\d+(?:\.\d*)?))'; +$op = '([-+*/^])'; +sub myE { + my $a = '('.$1.')'.$3.'('.$2.')'; + $a =~ s/\^/**/; + return eval($a); +} +while (<>) { + while (s/$WSb$num\s+$num\s+$op$WSa/' '.myE().' '/e) {} + print ($_, "\n"); +} diff --git a/Task/Parsing-RPN-calculator-algorithm/PicoLisp/parsing-rpn-calculator-algorithm-1.l b/Task/Parsing-RPN-calculator-algorithm/PicoLisp/parsing-rpn-calculator-algorithm-1.l new file mode 100644 index 0000000000..dbfe353958 --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/PicoLisp/parsing-rpn-calculator-algorithm-1.l @@ -0,0 +1,12 @@ +(de rpnCalculator (Str) + (let (^ ** Stack) # Define '^' from the built-in '**' + (prinl "Token Stack") + (for Token (str Str "*+-/\^") + (if (num? Token) + (push 'Stack @) + (set (cdr Stack) + ((intern Token) (cadr Stack) (pop 'Stack)) ) ) + (prin Token) + (space 6) + (println Stack) ) + (println (car Stack)) ) ) diff --git a/Task/Parsing-RPN-calculator-algorithm/PicoLisp/parsing-rpn-calculator-algorithm-2.l b/Task/Parsing-RPN-calculator-algorithm/PicoLisp/parsing-rpn-calculator-algorithm-2.l new file mode 100644 index 0000000000..3cccf2c85e --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/PicoLisp/parsing-rpn-calculator-algorithm-2.l @@ -0,0 +1,17 @@ +: (rpnCalculator "3 4 2 * 1 5 - 2 3 \^ \^ / +") +Token Stack +3 (3) +4 (4 3) +2 (2 4 3) +* (8 3) +1 (1 8 3) +5 (5 1 8 3) +- (-4 8 3) +2 (2 -4 8 3) +3 (3 2 -4 8 3) +^ (8 -4 8 3) +^ (65536 8 3) +/ (0 3) ++ (3) +3 +-> 3 diff --git a/Task/Parsing-RPN-calculator-algorithm/Prolog/parsing-rpn-calculator-algorithm.pro b/Task/Parsing-RPN-calculator-algorithm/Prolog/parsing-rpn-calculator-algorithm.pro new file mode 100644 index 0000000000..aab4219a4c --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/Prolog/parsing-rpn-calculator-algorithm.pro @@ -0,0 +1,47 @@ +rpn(L) :- + writeln('Token Action Stack'), + parse(L, [],[X] ,[]), + format('~nThe final output value is ~w~n', [X]). + +% skip spaces +parse([X|L], St) --> + {char_type(X, white)}, + parse(L, St). + +% detect operators +parse([Op|L], [Y, X | St]) --> + { is_op(Op, X, Y, V), + writef(' %s', [[Op]]), + with_output_to(atom(Str2), writef('Apply %s on top of stack', [[Op]])), + writef(' %35l', [Str2]), + writef('%w\n', [[V | St]])}, + parse(L, [V | St]). + +% detect number +parse([N|L], St) --> + {char_type(N, digit)}, + parse_number(L, [N], St). + +% string is finished +parse([], St) --> St. + +% compute numbers +parse_number([N|L], NC, St) --> + {char_type(N, digit)}, + parse_number(L, [N|NC], St). + +parse_number(S, NC, St) --> + { reverse(NC, RNC), + number_chars(V, RNC), + writef('%5r', [V]), + with_output_to(atom(Str2), writef('Push num %w on top of stack', [V])), + writef(' %35l', [Str2]), + writef('%w\n', [[V | St]])}, + parse(S, [V|St]). + +% defining operations +is_op(42, X, Y, V) :- V is X*Y. +is_op(43, X, Y, V) :- V is X+Y. +is_op(45, X, Y, V) :- V is X-Y. +is_op(47, X, Y, V) :- V is X/Y. +is_op(94, X, Y, V) :- V is X**Y. diff --git a/Task/Parsing-RPN-calculator-algorithm/Python/parsing-rpn-calculator-algorithm.py b/Task/Parsing-RPN-calculator-algorithm/Python/parsing-rpn-calculator-algorithm.py new file mode 100644 index 0000000000..138c37da8b --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/Python/parsing-rpn-calculator-algorithm.py @@ -0,0 +1,59 @@ +def op_pow(stack): + b = stack.pop(); a = stack.pop() + stack.append( a ** b ) +def op_mul(stack): + b = stack.pop(); a = stack.pop() + stack.append( a * b ) +def op_div(stack): + b = stack.pop(); a = stack.pop() + stack.append( a / b ) +def op_add(stack): + b = stack.pop(); a = stack.pop() + stack.append( a + b ) +def op_sub(stack): + b = stack.pop(); a = stack.pop() + stack.append( a - b ) +def op_num(stack, num): + stack.append( num ) + +ops = { + '^': op_pow, + '*': op_mul, + '/': op_div, + '+': op_add, + '-': op_sub, + } + +def get_input(inp = None): + 'Inputs an expression and returns list of tokens' + + if inp is None: + inp = input('expression: ') + tokens = inp.strip().split() + return tokens + +def rpn_calc(tokens): + stack = [] + table = ['TOKEN,ACTION,STACK'.split(',')] + for token in tokens: + if token in ops: + action = 'Apply op to top of stack' + ops[token](stack) + table.append( (token, action, ' '.join(str(s) for s in stack)) ) + else: + action = 'Push num onto top of stack' + op_num(stack, eval(token)) + table.append( (token, action, ' '.join(str(s) for s in stack)) ) + return table + +if __name__ == '__main__': + rpn = '3 4 2 * 1 5 - 2 3 ^ ^ / +' + print( 'For RPN expression: %r\n' % rpn ) + rp = rpn_calc(get_input(rpn)) + maxcolwidths = [max(len(y) for y in x) for x in zip(*rp)] + row = rp[0] + print( ' '.join('{cell:^{width}}'.format(width=width, cell=cell) for (width, cell) in zip(maxcolwidths, row))) + for row in rp[1:]: + print( ' '.join('{cell:<{width}}'.format(width=width, cell=cell) for (width, cell) in zip(maxcolwidths, row))) + + print('\n The final output value is: %r' % rp[-1][2]) diff --git a/Task/Parsing-RPN-calculator-algorithm/REXX/parsing-rpn-calculator-algorithm-1.rexx b/Task/Parsing-RPN-calculator-algorithm/REXX/parsing-rpn-calculator-algorithm-1.rexx new file mode 100644 index 0000000000..4008910ebc --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/REXX/parsing-rpn-calculator-algorithm-1.rexx @@ -0,0 +1,53 @@ +/* REXX *************************************************************** +* 09.11.2012 Walter Pachl translates from PL/I +**********************************************************************/ +fid='rpl.txt' +ex=linein(fid) +Say 'Input:' ex +/* ex=' 3 4 2 * 1 5 - 2 3 ^ ^ / +' */ +Numeric Digits 15 +expr='' +st.=0 +Say 'Stack contents:' +do While ex<>'' + Parse Var ex ch +1 ex + expr=expr||ch; + if ch<>' ' then do + select + When pos(ch,'0123456789')>0 Then Do + Call stack ch + Iterate + End + when ch='+' Then do; operand=getstack(); st.sti = st.sti + operand; end; + when ch='-' Then do; operand=getstack(); st.sti = st.sti - operand; end; + when ch='*' Then do; operand=getstack(); st.sti = st.sti * operand; end; + when ch='/' Then do; operand=getstack(); st.sti = st.sti / operand; end; + when ch='^' Then do; operand=getstack(); st.sti = st.sti ** operand; end; + end; + call show_stack + end + end +Say 'The reverse polish expression = 'expr +Say 'The evaluated expression = 'st.1 +Exit +stack: Procedure Expose st. +/* put the argument on top of the stack */ + z=st.0+1 + st.z=arg(1) + st.0=z + Return +getstack: Procedure Expose st. sti +/* remove and return the stack's top element */ + z=st.0 + stk=st.z + st.0=st.0-1 + sti=st.0 + Return stk +show_stack: procedure Expose st. +/* show the stack's contents */ + ol='' + do i=1 To st.0 + ol=ol format(st.i,5,10) + End + Say ol + Return diff --git a/Task/Parsing-RPN-calculator-algorithm/REXX/parsing-rpn-calculator-algorithm-2.rexx b/Task/Parsing-RPN-calculator-algorithm/REXX/parsing-rpn-calculator-algorithm-2.rexx new file mode 100644 index 0000000000..17482cd7fc --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/REXX/parsing-rpn-calculator-algorithm-2.rexx @@ -0,0 +1,27 @@ +/*REXX program evaluates a Reverse Polish notation (RPN) expression.*/ +parse arg x; if x='' then x = '3 4 2 * 1 5 - 2 3 ^ ^ / +'; ox=x +showSteps=1 /*set to 0 (zero) if working steps not wanted.*/ +x=space(x); tokens=words(x) + do i=1 for tokens; @.i=word(x,i); end /*i*/ /*assign input tokens*/ +L=max(20,length(x)) /*use 20 for the min show width. */ +numeric digits L /*ensure enough digits for answer*/ +say center('operand',L,'─') center('stack',L*2,'─'); e='***error!***' +op='- + / * ^'; add2s='add to───►stack'; z=; stack= + + do #=1 for tokens; ?=@.#; ??=? /*process each token from @. list*/ + w=words(stack) /*stack count (# entries).*/ + if datatype(?,'N') then do; stack=stack ?; call show add2s; iterate; end + if ?=='^' then ??="**" /*REXXify ^ ──► ** (make legal)*/ + interpret 'y=' word(stack,w-1) ?? word(stack,w) /*compute.*/ + if datatype(y,'W') then y=y/1 /*normalize the number with ÷ */ + _=subword(stack,1,w-2); stack=_ y /*rebuild the stack with answer. */ + call show ? + end /*#*/ + +z=space(z stack) /*append any residual entries. */ +say; say ' RPN input:' ox; say ' answer──►' z /*show input & ans.*/ +parse source upper . y . /*invoked via C.L. or REXX pgm?*/ +if y=='COMMAND' | \datatype(z,'W') then exit /*stick a fork in it, done.*/ + else return z /*RESULT ──► invoker.*/ +/*──────────────────────────────────SHOW subroutine─────────────────────*/ +show: if showSteps then say center(arg(1),L) left(space(stack),L); return diff --git a/Task/Parsing-RPN-calculator-algorithm/REXX/parsing-rpn-calculator-algorithm-3.rexx b/Task/Parsing-RPN-calculator-algorithm/REXX/parsing-rpn-calculator-algorithm-3.rexx new file mode 100644 index 0000000000..aa7ba69871 --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/REXX/parsing-rpn-calculator-algorithm-3.rexx @@ -0,0 +1,42 @@ +/*REXX program evaluates a Reverse Polish notation (RPN) expression.*/ +parse arg x; if x='' then x = '3 4 2 * 1 5 - 2 3 ^ ^ / +'; ox=x +showSteps=1 /*set to 0 (zero) if working steps not wanted.*/ +x=space(x); tokens=words(x) /*elide extra blanks;count tokens*/ + do i=1 for tokens; @.i=word(x,i); end /*i*/ /*assign input tokens*/ +L=max(20,length(x)) /*use 20 for the min show width. */ +numeric digits L /*ensure enough digits for answer*/ +say center('operand',L,'─') center('stack',L*2,'─'); e='***error!***' +add2s='add to───►stack'; z=; stack= +dop='/ // % ÷'; bop='& | &&' /*division ops; binary operands*/ +aop='- + * ^ **' dop bop; lop=aop '||' /*arithmetic ops; legal operands*/ + + do #=1 for tokens; ?=@.#; ??=? /*process each token from @. list*/ + w=words(stack); b=word(stack,max(1,w)) /*stack count; last entry.*/ + a=word(stack,max(1,w-1)) /*stack's "first" operand.*/ + division =wordpos(?,dop)\==0 /*flag: doing a division.*/ + arith =wordpos(?,aop)\==0 /*flag: doing arithmetic.*/ + bitOp =wordpos(?,bop)\==0 /*flag: doing binary math*/ + if datatype(?,'N') then do; stack=stack ?; call show add2s; iterate; end + if wordpos(?,lop)==0 then do; z=e 'illegal operator:' ?; leave; end + if w<2 then do; z=e 'illegal RPN expression.'; leave; end + if ?=='^' then ??="**" /*REXXify ^ ──► ** (make legal)*/ + if ?=='÷' then ??="/" /*REXXify ÷ ──► / (make legal)*/ + if division & b=0 then do; z=e 'division by zero: ' b; leave; end + if bitOp & \isBit(a) then do; z=e "token isn't logical: " a; leave; end + if bitOp & \isBit(b) then do; z=e "token isn't logical: " b; leave; end + interpret 'y=' a ?? b /*compute with two stack operands*/ + if datatype(y,'W') then y=y/1 /*normalize number with ÷ by 1.*/ + _=subword(stack,1,w-2); stack=_ y /*rebuild the stack with answer. */ + call show ? + end /*#*/ + +if word(z,1)==e then stack= /*handle special case of errors. */ +z=space(z stack) /*append any residual entries. */ +say; say ' RPN input:' ox; say ' answer──►' z /*show input & ans.*/ +parse source upper . how . /*invoked via C.L. or REXX pgm?*/ +if how=='COMMAND' | , + \datatype(z,'W') then exit /*stick a fork in it, we're done.*/ +return z /*return Z ──► invoker (RESULT).*/ +/*──────────────────────────────────subroutines─────────────────────────*/ +isBit: return arg(1)==0 | arg(1)==1 /*returns 1 if arg1 is bin bit.*/ +show: if showSteps then say center(arg(1),L) left(space(stack),L); return diff --git a/Task/Parsing-RPN-calculator-algorithm/Ruby/parsing-rpn-calculator-algorithm.rb b/Task/Parsing-RPN-calculator-algorithm/Ruby/parsing-rpn-calculator-algorithm.rb new file mode 100644 index 0000000000..5701ed27fd --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/Ruby/parsing-rpn-calculator-algorithm.rb @@ -0,0 +1,2 @@ +rpn = RPNExpression("3 4 2 * 1 5 - 2 3 ^ ^ / +") +value = rpn.eval diff --git a/Task/Parsing-RPN-calculator-algorithm/Run-BASIC/parsing-rpn-calculator-algorithm.run b/Task/Parsing-RPN-calculator-algorithm/Run-BASIC/parsing-rpn-calculator-algorithm.run new file mode 100644 index 0000000000..5463de575d --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/Run-BASIC/parsing-rpn-calculator-algorithm.run @@ -0,0 +1,34 @@ +prn$ = "3 4 2 * 1 5 - 2 3 ^ ^ / + " + +j = 0 +while word$(prn$,i + 1," ") <> "" +i = i + 1 + n$ = word$(prn$,i," ") + if n$ < "0" or n$ > "9" then + num1 = val(word$(stack$,s," ")) + num2 = val(word$(stack$,s-1," ")) + n = op(n$,num2,num1) + s = s - 1 + stack$ = stk$(stack$,s -1,str$(n)) + print "Push Opr ";n$;" to stack: ";stack$ + else + s = s + 1 + stack$ = stack$ + n$ + " " + print "Push Num ";n$;" to stack: ";stack$ +end if +wend + +function stk$(stack$,s,a$) +for i = 1 to s + stk$ = stk$ + word$(stack$,i," ") + " " +next i +stk$ = stk$ + a$ + " " +end function + +FUNCTION op(op$,a,b) +if op$ = "*" then op = a * b +if op$ = "/" then op = a / b +if op$ = "^" then op = a ^ b +if op$ = "+" then op = a + b +if op$ = "-" then op = a - b +end function diff --git a/Task/Parsing-RPN-calculator-algorithm/Tcl/parsing-rpn-calculator-algorithm.tcl b/Task/Parsing-RPN-calculator-algorithm/Tcl/parsing-rpn-calculator-algorithm.tcl new file mode 100644 index 0000000000..ae108b3c42 --- /dev/null +++ b/Task/Parsing-RPN-calculator-algorithm/Tcl/parsing-rpn-calculator-algorithm.tcl @@ -0,0 +1,49 @@ +# Helper +proc pop stk { + upvar 1 $stk s + set val [lindex $s end] + set s [lreplace $s end end] + return $val +} + +proc evaluate rpn { + set stack {} + foreach token $rpn { + set act "apply" + switch $token { + "^" { + # Non-commutative operation + set a [pop stack] + lappend stack [expr {[pop stack] ** $a}] + } + "/" { + # Non-commutative, special float handling + set a [pop stack] + set b [expr {[pop stack] / double($a)}] + if {$b == round($b)} {set b [expr {round($b)}]} + lappend stack $b + } + "*" { + # Commutative operation + lappend stack [expr {[pop stack] * [pop stack]}] + } + "-" { + # Non-commutative operation + set a [pop stack] + lappend stack [expr {[pop stack] - $a}] + } + "+" { + # Commutative operation + lappend stack [expr {[pop stack] + [pop stack]}] + } + default { + set act "push" + lappend stack $token + } + } + puts "$token\t$act\t$stack" + } + return [lindex $stack end] +} + +puts [evaluate {3 4 2 * 1 5 - 2 3 ^ ^ / +}] diff --git a/Task/Parsing-RPN-to-infix-conversion/0DESCRIPTION b/Task/Parsing-RPN-to-infix-conversion/0DESCRIPTION new file mode 100644 index 0000000000..8cc2375406 --- /dev/null +++ b/Task/Parsing-RPN-to-infix-conversion/0DESCRIPTION @@ -0,0 +1,37 @@ +Create a program that takes an [[wp:Reverse Polish notation|RPN]] representation of an expression formatted as a space separated sequence of tokens and generates the equivalent expression in [[wp:Infix notation|infix notation]]. + +* Assume an input of a correct, space separated, string of tokens +* Generate a space separated output string representing the same expression in infix notation +* Show how the major datastructure of your algorithm changes with each new token parsed. +* Test with the following input RPN strings then print and display the output here. +:{| class="wikitable" +! RPN input !! sample output +|- || align="center" +| 3 4 2 * 1 5 - 2 3 ^ ^ / +|| 3 + 4 * 2 / ( 1 - 5 ) ^ 2 ^ 3 +|- || align="center" +| 1 2 + 3 4 + ^ 5 6 + ^|| ( ( 1 + 2 ) ^ ( 3 + 4 ) ) ^ ( 5 + 6 ) +|} + +* Operator precedence is given in this table: +:{| class="wikitable" + +! operator !! [[wp:Order_of_operations|precedence]] !! [[wp:Operator_associativity|associativity]] +|- || align="center" +| ^ || 4 || Right +|- || align="center" +| * || 3 || Left +|- || align="center" +| / || 3 || Left +|- || align="center" +| + || 2 || Left +|- || align="center" +| - || 2 || Left +|} + +;Note: +* '^' means exponentiation. + +;See also: +* [[Parsing/Shunting-yard algorithm]] for a method of generating an RPN from an infix expression. +* [[Parsing/RPN calculator algorithm]] for a method of calculating a final value from this output RPN expression. +* [http://www.rubyquiz.com/quiz148.html Postfix to infix] from the RubyQuiz site. diff --git a/Task/Parsing-RPN-to-infix-conversion/AWK/parsing-rpn-to-infix-conversion.awk b/Task/Parsing-RPN-to-infix-conversion/AWK/parsing-rpn-to-infix-conversion.awk new file mode 100644 index 0000000000..693cb0c876 --- /dev/null +++ b/Task/Parsing-RPN-to-infix-conversion/AWK/parsing-rpn-to-infix-conversion.awk @@ -0,0 +1,102 @@ +#!/usr/bin/awk -f + +BEGIN { + initStack() + initOpers() + print "Infix: " toInfix("3 4 2 * 1 5 - 2 3 ^ ^ / +") + print "" + print "Infix: " toInfix("1 2 + 3 4 + ^ 5 6 + ^") + print "" + print "Infix: " toInfix("moon stars mud + * fire soup * ^") + exit +} + +function initStack() { + delete stack + stackPtr = 0 +} + +function initOpers() { + VALPREC = "9" + LEFT = "l" + RIGHT = "r" + operToks = "+" "-" "/" "*" "^" + operPrec = "2" "2" "3" "3" "4" + operAssoc = LEFT LEFT LEFT LEFT RIGHT +} + +function toInfix(rpn, t, toks, tok, a, ap, b, bp, tp, ta) { + print "Postfix: " rpn + split(rpn, toks, / +/) + for (t = 1; t <= length(toks); t++) { + tok = toks[t] + if (!isOper(tok)) { + push(VALPREC tok) + } + else { + b = pop() + bp = prec(b) + b = tail(b) + a = pop() + ap = prec(a) + a = tail(a) + tp = tokPrec(tok) + ta = tokAssoc(tok) + if (ap < tp || (ap == tp && ta == RIGHT)) { + a = "(" a ")" + } + if (bp < tp || (bp == tp && ta == LEFT)) { + b = "(" b ")" + } + push(tp a " " tok " " b) + } + print " " tok " -> " stackToStr() + } + return tail(pop()) +} + +function push(expr) { + stack[stackPtr] = expr + stackPtr++ +} + +function pop() { + stackPtr-- + return stack[stackPtr] +} + +function isOper(tok) { + return index(operToks, tok) != 0 +} + +function prec(expr) { + return substr(expr, 1, 1) +} + +function tokPrec(tok) { + return substr(operPrec, operIdx(tok), 1) +} + +function tokAssoc(tok) { + return substr(operAssoc, operIdx(tok), 1) +} + +function operIdx(tok) { + return index(operToks, tok) +} + +function tail(s) { + return substr(s, 2) +} + +function stackToStr( s, i, t, p) { + s = "" + for (i = 0; i < stackPtr; i++) { + t = stack[i] + p = prec(t) + if (index(t, " ")) t = "{" tail(t) "}" + else t = tail(t) + s = s "{" p " " t "} " + } + return s +} diff --git a/Task/Parsing-RPN-to-infix-conversion/Ada/parsing-rpn-to-infix-conversion-1.ada b/Task/Parsing-RPN-to-infix-conversion/Ada/parsing-rpn-to-infix-conversion-1.ada new file mode 100644 index 0000000000..caf69a732d --- /dev/null +++ b/Task/Parsing-RPN-to-infix-conversion/Ada/parsing-rpn-to-infix-conversion-1.ada @@ -0,0 +1,82 @@ + type Priority is range 1..4; + type Infix is record + Precedence : Priority; + Expression : Unbounded_String; + end record; + package Expression_Stack is new Generic_Stack (Infix); + use Expression_Stack; + + function Convert (RPN : String) return String is + Arguments : Stack; + procedure Pop + ( Operation : Character; + Precedence : Priority; + Association : Priority + ) is + Right, Left : Infix; + Result : Infix; + begin + Pop (Right, Arguments); + Pop (Left, Arguments); + Result.Precedence := Association; + if Left.Precedence < Precedence then + Append (Result.Expression, '('); + Append (Result.Expression, Left.Expression); + Append (Result.Expression, ')'); + else + Append (Result.Expression, Left.Expression); + end if; + Append (Result.Expression, ' '); + Append (Result.Expression, Operation); + Append (Result.Expression, ' '); + if Right.Precedence < Precedence then + Append (Result.Expression, '('); + Append (Result.Expression, Right.Expression); + Append (Result.Expression, ')'); + else + Append (Result.Expression, Right.Expression); + end if; + Push (Result, Arguments); + end Pop; + Pointer : Integer := RPN'First; + begin + while Pointer <= RPN'Last loop + case RPN (Pointer) is + when ' ' => + Pointer := Pointer + 1; + when '0'..'9' => + declare + Start : constant Integer := Pointer; + begin + loop + Pointer := Pointer + 1; + exit when Pointer > RPN'Last + or else RPN (Pointer) not in '0'..'9'; + end loop; + Push + ( ( 4, + To_Unbounded_String (RPN (Start..Pointer - 1)) + ), + Arguments + ); + end; + when '+' | '-' => + Pop (RPN (Pointer), 1, 1); + Pointer := Pointer + 1; + when '*' | '/' => + Pop (RPN (Pointer), 2, 2); + Pointer := Pointer + 1; + when '^' => + Pop (RPN (Pointer), 4, 3); + Pointer := Pointer + 1; + when others => + raise Constraint_Error with "Syntax"; + end case; + end loop; + declare + Result : Infix; + begin + Pop (Result, Arguments); + return To_String (Result.Expression); + end; + end Convert; diff --git a/Task/Parsing-RPN-to-infix-conversion/Ada/parsing-rpn-to-infix-conversion-2.ada b/Task/Parsing-RPN-to-infix-conversion/Ada/parsing-rpn-to-infix-conversion-2.ada new file mode 100644 index 0000000000..fca06773f9 --- /dev/null +++ b/Task/Parsing-RPN-to-infix-conversion/Ada/parsing-rpn-to-infix-conversion-2.ada @@ -0,0 +1,12 @@ +with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; +with Ada.Text_IO; use Ada.Text_IO; +with Generic_Stack; + +procedure RPN_to_Infix is + -- The code above +begin + Put_Line ("3 4 2 * 1 5 - 2 3 ^ ^ / + = "); + Put_Line (Convert ("3 4 2 * 1 5 - 2 3 ^ ^ / +")); + Put_Line ("1 2 + 3 4 + ^ 5 6 + ^ = "); + Put_Line (Convert ("1 2 + 3 4 + ^ 5 6 + ^")); +end RPN_to_Infix; diff --git a/Task/Parsing-RPN-to-infix-conversion/AutoHotkey/parsing-rpn-to-infix-conversion.ahk b/Task/Parsing-RPN-to-infix-conversion/AutoHotkey/parsing-rpn-to-infix-conversion.ahk new file mode 100644 index 0000000000..c7fbd3c491 --- /dev/null +++ b/Task/Parsing-RPN-to-infix-conversion/AutoHotkey/parsing-rpn-to-infix-conversion.ahk @@ -0,0 +1,46 @@ +expr := "3 4 2 * 1 5 - 2 3 ^ ^ / +" + +stack := {push: func("ObjInsert"), pop: func("ObjRemove")} +out := "TOKEN`tACTION STACK (comma separated)`r`n" +Loop Parse, expr, %A_Space% +{ + token := A_LoopField + if token is number + stack.push([0, token]) + if isOp(token) + { + b := stack.pop(), a := stack.pop(), p := b.1 > a.1 ? b.1 : a.1 + p := Precedence(token) > p ? precedence(token) : p + if (a.1 < b.1) and isRight(token) + stack.push([p, "( " . a.2 " ) " token " " b.2]) + else if (a.1 > b.1) and isLeft(token) + stack.push([p, a.2 token " ( " b.2 " ) "]) + else + stack.push([p, a.2 . " " . token . " " . b.2]) + } + out .= token "`t" (isOp(token) ? "Push Partial expression " + : "Push num" space(16)) disp(stack) "`r`n" +} +out .= "`r`n The final output infix expression is: '" disp(stack) "'" +clipboard := out +isOp(t){ + return (!!InStr("+-*/^", t) && t) +} +IsLeft(o){ + return !!InStr("*/+-", o) +} +IsRight(o){ + return o = "^" +} +Precedence(o){ + return (InStr("+-/*^", o)+3)//2 +} +Disp(obj){ + for each, val in obj + if val[2] + o .= ", " val[2] + return SubStr(o,3) +} +Space(n){ + return n>0 ? A_Space Space(n-1) : "" +} diff --git a/Task/Parsing-RPN-to-infix-conversion/D/parsing-rpn-to-infix-conversion.d b/Task/Parsing-RPN-to-infix-conversion/D/parsing-rpn-to-infix-conversion.d new file mode 100644 index 0000000000..aa08cce6b3 --- /dev/null +++ b/Task/Parsing-RPN-to-infix-conversion/D/parsing-rpn-to-infix-conversion.d @@ -0,0 +1,43 @@ +import std.stdio, std.string, std.array; + +void parseRPN(in string e) { + enum nPrec = 9; + static struct Info { int prec; bool rAssoc; } + immutable /*static*/ opa = ["^": Info(4, true), + "*": Info(3, false), + "/": Info(3, false), + "+": Info(2, false), + "-": Info(2, false)]; + + writeln("\nPostfix input: ", e); + static struct Sf { int prec; string expr; } + Sf[] stack; + foreach (immutable tok; e.split()) { + writeln("Token: ", tok); + if (tok in opa) { + immutable op = opa[tok]; + immutable rhs = stack.back; + stack.popBack(); + auto lhs = &stack.back; + if (lhs.prec < op.prec || + (lhs.prec == op.prec && op.rAssoc)) + lhs.expr = "(" ~ lhs.expr ~ ")"; + lhs.expr ~= " " ~ tok ~ " "; + lhs.expr ~= (rhs.prec < op.prec || + (rhs.prec == op.prec && !op.rAssoc)) ? + "(" ~ rhs.expr ~ ")" : + rhs.expr; + lhs.prec = op.prec; + } else + stack ~= Sf(nPrec, tok); + foreach (immutable f; stack) + writefln(` %d "%s"`, f.prec, f.expr); + } + writeln("Infix result: ", stack[0].expr); +} + +void main() { + foreach (immutable test; ["3 4 2 * 1 5 - 2 3 ^ ^ / +", + "1 2 + 3 4 + ^ 5 6 + ^"]) + parseRPN(test); +} diff --git a/Task/Parsing-RPN-to-infix-conversion/Go/parsing-rpn-to-infix-conversion.go b/Task/Parsing-RPN-to-infix-conversion/Go/parsing-rpn-to-infix-conversion.go new file mode 100644 index 0000000000..7fb23e444e --- /dev/null +++ b/Task/Parsing-RPN-to-infix-conversion/Go/parsing-rpn-to-infix-conversion.go @@ -0,0 +1,63 @@ +package main + +import ( + "fmt" + "strings" +) + +var tests = []string{ + "3 4 2 * 1 5 - 2 3 ^ ^ / +", + "1 2 + 3 4 + ^ 5 6 + ^", +} + +var opa = map[string]struct { + prec int + rAssoc bool +}{ + "^": {4, true}, + "*": {3, false}, + "/": {3, false}, + "+": {2, false}, + "-": {2, false}, +} + +const nPrec = 9 + +func main() { + for _, t := range tests { + parseRPN(t) + } +} + +func parseRPN(e string) { + fmt.Println("\npostfix:", e) + type sf struct { + prec int + expr string + } + var stack []sf + for _, tok := range strings.Fields(e) { + fmt.Println("token:", tok) + if op, isOp := opa[tok]; isOp { + rhs := &stack[len(stack)-1] + stack = stack[:len(stack)-1] + lhs := &stack[len(stack)-1] + if lhs.prec < op.prec || (lhs.prec == op.prec && op.rAssoc) { + lhs.expr = "(" + lhs.expr + ")" + } + lhs.expr += " " + tok + " " + if rhs.prec < op.prec || (rhs.prec == op.prec && !op.rAssoc) { + lhs.expr += "(" + rhs.expr + ")" + } else { + lhs.expr += rhs.expr + } + lhs.prec = op.prec + } else { + stack = append(stack, sf{nPrec, tok}) + } + for _, f := range stack { + fmt.Printf(" %d %q\n", f.prec, f.expr) + } + } + fmt.Println("infix:", stack[0].expr) +} diff --git a/Task/Parsing-RPN-to-infix-conversion/Icon/parsing-rpn-to-infix-conversion.icon b/Task/Parsing-RPN-to-infix-conversion/Icon/parsing-rpn-to-infix-conversion.icon new file mode 100644 index 0000000000..902f05137b --- /dev/null +++ b/Task/Parsing-RPN-to-infix-conversion/Icon/parsing-rpn-to-infix-conversion.icon @@ -0,0 +1,58 @@ +procedure main() +every rpn := ![ + "3 4 2 * 1 5 - 2 3 ^ ^ / +", # reqd + "1 2 + 3 4 + 5 6 + ^ ^", + "1 2 + 3 4 + 5 6 + ^ ^", + "1 2 + 3 4 + ^ 5 6 + ^" # reqd + ] do { + printf("\nRPN = %i\n",rpn) + printf("infix = %i\n",RPN2Infix(rpn,show)) + show := 1 # turn off inner working display + } +end + +link printf + +procedure RPN2Infix(expr,show) #: RPN to Infix conversion +static oi +initial { + oi := table([9,"'"]) # precedence & associativity + every oi[!"+-"] := [2,"l"] # 2L + every oi[!"*/"] := [3,"l"] # 3L + oi["^"] := [4,"r"] # 4R + } + + show := if /show then printf else 1 # to show inner workings or not + stack := [] + expr ? until pos(0) do { # Reformat as a tree + tab(many(' ')) # consume previous seperator + token := tab(upto(' ')|0) # get token + if token := numeric(token) then { # ... numeric + push(stack,oi[token]|||[token]) + show("pushed numeric %i : %s\n",token,list2string(stack)) + } + else { # ... operator + every b|a := pop(stack) # pop & reverse operands + pr := oi[token,1] + as := oi[token,2] + if a[1] < pr | (a[1] = pr & oi[token,2] == "r") then + a[3] := sprintf("( %s )",a[3]) + if b[1] < pr | (b[1] == pr & oi[token,2] == "l") then + b[3] := sprintf("( %s )",b[3]) + s := sprintf("%s %s %s",a[3],token,b[3]) + push(stack,[pr,as,s]) # stack [prec, assoc, expr] + show("applied operator %s : %s\n",token,list2string(stack)) + } + } + + if *stack ~= 1 then stop("Parser failure") + return stack[1,3] +end + +procedure list2string(L) #: format list as a string + s := "[ " + every x := !L do + s ||:= ( if type(x) == "list" then list2string(x) + else x) || " " + return s || "]" +end diff --git a/Task/Parsing-RPN-to-infix-conversion/J/parsing-rpn-to-infix-conversion-1.j b/Task/Parsing-RPN-to-infix-conversion/J/parsing-rpn-to-infix-conversion-1.j new file mode 100644 index 0000000000..f896ef5a4f --- /dev/null +++ b/Task/Parsing-RPN-to-infix-conversion/J/parsing-rpn-to-infix-conversion-1.j @@ -0,0 +1,36 @@ +tokenize=: ' ' <;._1@, deb + +ops=: ;:'+ - * / ^' +doOp=: plus`minus`times`divide`exponent`push@.(ops&i.) +parse=:3 :0 + stack=: i.0 2 + for_token.tokenize y do.doOp token end. + 1{:: ,stack +) + +parens=:4 :0 + if. y do. '( ',x,' )' else. x end. +) + +NB. m: precedence, n: is right associative, y: token +op=:2 :0 + L=. m - n + R=. m - -.n + smoutput;'operation: ';y + 'Lprec left Rprec right'=. ,_2{.stack + expr=. ;(left parens L > Lprec);' ';y,' ';right parens R > Rprec + stack=: (_2}.stack),m;expr + smoutput stack +) + +plus=: 2 op 0 +minus=: 2 op 0 +times=: 3 op 0 +divide=: 3 op 0 +exponent=: 4 op 1 + +push=:3 :0 + smoutput;'pushing: ';y + stack=: stack,_;y + smoutput stack +) diff --git a/Task/Parsing-RPN-to-infix-conversion/J/parsing-rpn-to-infix-conversion-2.j b/Task/Parsing-RPN-to-infix-conversion/J/parsing-rpn-to-infix-conversion-2.j new file mode 100644 index 0000000000..89b9ddc911 --- /dev/null +++ b/Task/Parsing-RPN-to-infix-conversion/J/parsing-rpn-to-infix-conversion-2.j @@ -0,0 +1,102 @@ + parse '3 4 2 * 1 5 - 2 3 ^ ^ / +' +pushing: 3 ++-+-+ +|_|3| ++-+-+ +pushing: 4 ++-+-+ +|_|3| ++-+-+ +|_|4| ++-+-+ +pushing: 2 ++-+-+ +|_|3| ++-+-+ +|_|4| ++-+-+ +|_|2| ++-+-+ +operation: * ++-+-----+ +|_|3 | ++-+-----+ +|3|4 * 2| ++-+-----+ +pushing: 1 ++-+-----+ +|_|3 | ++-+-----+ +|3|4 * 2| ++-+-----+ +|_|1 | ++-+-----+ +pushing: 5 ++-+-----+ +|_|3 | ++-+-----+ +|3|4 * 2| ++-+-----+ +|_|1 | ++-+-----+ +|_|5 | ++-+-----+ +operation: - ++-+-----+ +|_|3 | ++-+-----+ +|3|4 * 2| ++-+-----+ +|2|1 - 5| ++-+-----+ +pushing: 2 ++-+-----+ +|_|3 | ++-+-----+ +|3|4 * 2| ++-+-----+ +|2|1 - 5| ++-+-----+ +|_|2 | ++-+-----+ +pushing: 3 ++-+-----+ +|_|3 | ++-+-----+ +|3|4 * 2| ++-+-----+ +|2|1 - 5| ++-+-----+ +|_|2 | ++-+-----+ +|_|3 | ++-+-----+ +operation: ^ ++-+-----+ +|_|3 | ++-+-----+ +|3|4 * 2| ++-+-----+ +|2|1 - 5| ++-+-----+ +|4|2 ^ 3| ++-+-----+ +operation: ^ ++-+-----------------+ +|_|3 | ++-+-----------------+ +|3|4 * 2 | ++-+-----------------+ +|4|( 1 - 5 ) ^ 2 ^ 3| ++-+-----------------+ +operation: / ++-+-------------------------+ +|_|3 | ++-+-------------------------+ +|3|4 * 2 / ( 1 - 5 ) ^ 2 ^ 3| ++-+-------------------------+ +operation: + ++-+-----------------------------+ +|2|3 + 4 * 2 / ( 1 - 5 ) ^ 2 ^ 3| ++-+-----------------------------+ +3 + 4 * 2 / ( 1 - 5 ) ^ 2 ^ 3 diff --git a/Task/Parsing-RPN-to-infix-conversion/PL-I/parsing-rpn-to-infix-conversion.pli b/Task/Parsing-RPN-to-infix-conversion/PL-I/parsing-rpn-to-infix-conversion.pli new file mode 100644 index 0000000000..d0c9df4818 --- /dev/null +++ b/Task/Parsing-RPN-to-infix-conversion/PL-I/parsing-rpn-to-infix-conversion.pli @@ -0,0 +1,54 @@ +/* Uses a push-down pop-up stack for the stack (instead of array) */ +cvt: procedure options (main); /* 10 Sept. 2012 */ + declare (true initial ('1'b), false initial ('0'b) ) bit (1); + declare list character (1) controlled, written bit (1) controlled; + declare (RPN, out) character (100) varying; + declare s character (1); + declare input_priority (5) fixed (1) static initial (1, 1, 2, 2, 3); + declare stack_priority (5) fixed (1) static initial (1, 1, 2, 2, 4); + declare (i, ki, kl) fixed binary; + + put ('Convert a Reverse Polish expression to orthodox.'); + put skip list ('Enclose the expression in apostrophes:'); + get list (RPN); + put skip list ('The original Reverse Polish expression = ' || RPN); + out = ''; + + allocate list, written; + list = substr(RPN, length(RPN), 1); written = false; + +translation: + do i = length (RPN)-1 to 1 by -1; + s = substr(RPN, i, 1); + if s = ' ' then iterate; + ki = index('+-*/^', s); + kl = index('+-*/^', list); + if ki > 0 then /* we have an operator */ + do; + if input_priority (ki) < stack_priority (kl) then + do; /* transfer ')' to list, then operator. */ + allocate list, written; + list = '('; written = false; + out = ')' || out; + end; + allocate list, written; + list = s; written = false; + end; + else /* It's a variable name */ + do; + out = s || out; +next_list: + if allocation(list) > 0 then if written then free written, list; + if allocation(list) > 0 then if list = '(' then + do; out = list || out; free written, list; end; + if allocation (list) = 0 then leave translation; + if written then go to next_list; + written = true; + out = list || out; /* Output an operator. */ + end; + put skip edit ('INPUT=' || s) (a); call show_stack; + put edit (' OUTPUT=', out) (col(30), 2 a); + end; + put skip list ('ALGEBRAIC EXPRESSION=', out); + +end cvt; diff --git a/Task/Parsing-RPN-to-infix-conversion/Perl-6/parsing-rpn-to-infix-conversion.pl6 b/Task/Parsing-RPN-to-infix-conversion/Perl-6/parsing-rpn-to-infix-conversion.pl6 new file mode 100644 index 0000000000..7e1dd6d3c6 --- /dev/null +++ b/Task/Parsing-RPN-to-infix-conversion/Perl-6/parsing-rpn-to-infix-conversion.pl6 @@ -0,0 +1,23 @@ +my @tests = '3 4 2 * 1 5 - 2 3 ^ ^ / +', + '1 2 + 3 4 + ^ 5 6 + ^'; + +say rpm-to-infix($_) for @tests; + +sub p ($pair, $prec) { + $pair.key < $prec ?? "( $pair.value() )" !! $pair.value +} +sub rpm-to-infix($string) { + say "=================\n$string"; + my @stack; + for $string.words { + when /\d/ { @stack.push: 9 => $_ } + my $y = @stack.pop; + my $x = @stack.pop; + when '^' { @stack.push: 4 => ~(p($x,5), $_, p($y,4)) } + when '*' | '/' { @stack.push: 3 => ~(p($x,3), $_, p($y,3)) } + when '+' | '-' { @stack.push: 2 => ~(p($x,2), $_, p($y,2)) } + LEAVE { say @stack } + } + say "-----------------"; + @stack».value; +} diff --git a/Task/Parsing-RPN-to-infix-conversion/Perl/parsing-rpn-to-infix-conversion.pl b/Task/Parsing-RPN-to-infix-conversion/Perl/parsing-rpn-to-infix-conversion.pl new file mode 100644 index 0000000000..789a3a45a6 --- /dev/null +++ b/Task/Parsing-RPN-to-infix-conversion/Perl/parsing-rpn-to-infix-conversion.pl @@ -0,0 +1,14 @@ +# RPN to infix conversion +# +# Nigel Galloway April 1st., 2012 +# +$WSb = '(?:^|\s+)'; +$WSa = '(?:\s+|$)'; +$num = '([+-/$]?(?:\.\d+|\d+(?:\.\d*)?))'; +$op = '([-+*/^])'; +while (<>) { + $n = -1; + while (s/$WSb$num\s+$num\s+$op$WSa/' '.('$'.++$n).' '/e) {@elems[$n] = '('.$1.$3.$2.')';} + while (s!(\$)(\d+)!@elems[$2]!e) {} + print(substr($_,2,-2)."\n"); +} diff --git a/Task/Parsing-RPN-to-infix-conversion/PicoLisp/parsing-rpn-to-infix-conversion-1.l b/Task/Parsing-RPN-to-infix-conversion/PicoLisp/parsing-rpn-to-infix-conversion-1.l new file mode 100644 index 0000000000..ba2e0ae6a6 --- /dev/null +++ b/Task/Parsing-RPN-to-infix-conversion/PicoLisp/parsing-rpn-to-infix-conversion-1.l @@ -0,0 +1,33 @@ +(de leftAssoc (Op) + (member Op '("*" "/" "+" "-")) ) + +(de precedence (Op) + (case Op + ("\^" 4) + (("*" "/") 3) + (("+" "-") 2) ) ) + +(de rpnToInfix (Str) + (let Stack NIL + (prinl "Token Stack") + (for Token (str Str "_") + (cond + ((num? Token) (push 'Stack (cons 9 @))) # Highest precedence + ((not (cdr Stack)) (quit "Stack empty")) + (T + (let (X (pop 'Stack) P (precedence Token)) + (set Stack + (cons P + (pack + (if ((if (leftAssoc Token) < <=) (caar Stack) P) + (pack "(" (cdar Stack) ")") + (cdar Stack) ) + " " Token " " + (if ((if (leftAssoc Token) <= <) (car X) P) + (pack "(" (cdr X) ")") + (cdr X) ) ) ) ) ) ) ) + (prin Token) + (space 6) + (println Stack) ) + (prog1 (cdr (pop 'Stack)) + (and Stack (quit "Garbage remained on stack")) ) ) ) diff --git a/Task/Parsing-RPN-to-infix-conversion/PicoLisp/parsing-rpn-to-infix-conversion-2.l b/Task/Parsing-RPN-to-infix-conversion/PicoLisp/parsing-rpn-to-infix-conversion-2.l new file mode 100644 index 0000000000..c7446b92d4 --- /dev/null +++ b/Task/Parsing-RPN-to-infix-conversion/PicoLisp/parsing-rpn-to-infix-conversion-2.l @@ -0,0 +1,31 @@ +: (rpnToInfix "3 4 2 * 1 5 - 2 3 \^ \^ / +") +Token Stack +3 ((9 . 3)) +4 ((9 . 4) (9 . 3)) +2 ((9 . 2) (9 . 4) (9 . 3)) +* ((3 . "4 * 2") (9 . 3)) +1 ((9 . 1) (3 . "4 * 2") (9 . 3)) +5 ((9 . 5) (9 . 1) (3 . "4 * 2") (9 . 3)) +- ((2 . "1 - 5") (3 . "4 * 2") (9 . 3)) +2 ((9 . 2) (2 . "1 - 5") (3 . "4 * 2") (9 . 3)) +3 ((9 . 3) (9 . 2) (2 . "1 - 5") (3 . "4 * 2") (9 . 3)) +^ ((4 . "2 \^ 3") (2 . "1 - 5") (3 . "4 * 2") (9 . 3)) +^ ((4 . "(1 - 5) \^ 2 \^ 3") (3 . "4 * 2") (9 . 3)) +/ ((3 . "4 * 2 / (1 - 5) \^ 2 \^ 3") (9 . 3)) ++ ((2 . "3 + 4 * 2 / (1 - 5) \^ 2 \^ 3")) +-> "3 + 4 * 2 / (1 - 5) \^ 2 \^ 3" + +: (rpnToInfix "1 2 + 3 4 + \^ 5 6 + \^") +Token Stack +1 ((9 . 1)) +2 ((9 . 2) (9 . 1)) ++ ((2 . "1 + 2")) +3 ((9 . 3) (2 . "1 + 2")) +4 ((9 . 4) (9 . 3) (2 . "1 + 2")) ++ ((2 . "3 + 4") (2 . "1 + 2")) +^ ((4 . "(1 + 2) \^ (3 + 4)")) +5 ((9 . 5) (4 . "(1 + 2) \^ (3 + 4)")) +6 ((9 . 6) (9 . 5) (4 . "(1 + 2) \^ (3 + 4)")) ++ ((2 . "5 + 6") (4 . "(1 + 2) \^ (3 + 4)")) +^ ((4 . "((1 + 2) \^ (3 + 4)) \^ (5 + 6)")) +-> "((1 + 2) \^ (3 + 4)) \^ (5 + 6)" diff --git a/Task/Parsing-RPN-to-infix-conversion/Python/parsing-rpn-to-infix-conversion.py b/Task/Parsing-RPN-to-infix-conversion/Python/parsing-rpn-to-infix-conversion.py new file mode 100644 index 0000000000..f6ce592586 --- /dev/null +++ b/Task/Parsing-RPN-to-infix-conversion/Python/parsing-rpn-to-infix-conversion.py @@ -0,0 +1,223 @@ +from math import log as ln +from math import sqrt, log, exp, sin, cos, tan, pi, e + +""" +>>> # EXAMPLE USAGE +>>> result = rpn_to_infix('3 4 2 * 1 -5 - ln 2 3 ** ** / +', VERBOSE=True) +TOKEN STACK +3 ['3'] +4 ['3', '4'] +2 ['3', '4', '2'] +* ['3', Node('2','*','4')] +1 ['3', Node('2','*','4'), '1'] +-5 ['3', Node('2','*','4'), '1', '-5'] +- ['3', Node('2','*','4'), Node('-5','-','1')] +ln ['3', Node('2','*','4'), Node(Node('-5','-','1'),'ln',None)] +2 ['3', Node('2','*','4'), Node(Node('-5','-','1'),'ln',None), '2'] +3 ['3', Node('2','*','4'), Node(Node('-5','-','1'),'ln',None), '2', '3'] +** ['3', Node('2','*','4'), Node(Node('-5','-','1'),'ln',None), Node('3','**','2')] +** ['3', Node('2','*','4'), Node(Node('3','**','2'),'**',Node(Node('-5','-','1'),'ln',None))] +/ ['3', Node(Node(Node('3','**','2'),'**',Node(Node('-5','-','1'),'ln',None)),'/',Node('2','*','4'))] ++ [Node(Node(Node(Node('3','**','2'),'**',Node(Node('-5','-','1'),'ln',None)),'/',Node('2','*','4')),'+','3')] +>>> result +""" + +prec_dict = {'abs':5, 'sqrt':5, 'exp':5, 'log':5, 'ln':5, + 'sin':5, 'cos':5, 'tan':5, + '**':4, '*':3, '/':3, '+':2, '-':2} +assoc_dict = {'abs':0, 'sqrt':0, 'exp':0, 'log':0, 'ln':0, + 'sin':0, 'cos':0, 'tan':0, + '**':1, '*':0, '/':0, '+':0, '-':0} +arity_dict = {'abs':1, 'sqrt':1, 'exp':1, 'log':1, 'ln':1, + 'sin':1, 'cos':1, 'tan':1, + '**':2, '*':2, '/':2, '+':2, '-':2} + +class Node: + def __init__(self,x,op,y=None): + global prec_dict,assoc_dict,arity_dict + + self.precedence = prec_dict[op] + self.assocright = assoc_dict[op] + self.arity = arity_dict[op] + self.op = op + + if not self.assocright and self > x and \ + isinstance(x, Node) and self.arity == 2: + self.x = x.x + self.y = Node(x.y, x.op, y) + else: + self.x,self.y = x,y + + def __str__(self): + """ + Building an infix string that evaluates correctly is easy. + Building an infix string that looks pretty and evaluates + correctly requires more effort. + """ + + # easy case, Node is unary + if self.y == None: + return '%s(%s)'%(self.op,str(self.x)) + + # determine left side string + str_y = str(self.y) + if self.y < self or \ + (self.y == self and self.assocright) or \ + (str_y[0] is '-' and self.assocright): + + str_y = '(%s)'%str_y + + # determine right side string and operator + str_x = str(self.x) + str_op = self.op + if self.op is '+' and not isinstance(self.x, Node) and str_x[0] is '-': + str_x = str_x[1:] + str_op = '-' + elif self.op is '-' and not isinstance(self.x, Node) and str_x[0] is '-': + str_x = str_x[1:] + str_op = '+' + elif self.x < self or \ + (self.x == self and not self.assocright and \ + getattr(self.x, 'op', 1) != getattr(self, 'op', 2)): + + str_x = '(%s)'%str_x + + return ' '.join([str_y, str_op, str_x]) + + def __repr__(self): + """ + >>> repr(Node('3','+','4')) == repr(eval(repr(Node('3','+','4')))) + True + """ + return 'Node(%s,%s,%s)'%(repr(self.x), repr(self.op), repr(self.y)) + + def __cmp__(self, other): + """ + polymorphic comparisons to determine precedence + + >>> Node('3','+','4') < Node('6','*','7') < Node('3','**','4') + True + >>> Node('3','+','4') == Node('6','+','7') + True + >>> Node('3','+','4') == '-' + True + >>> Node('3','**','4') < '1' + True + """ + if isinstance(other, Node): + return cmp(self.precedence, other.precedence) + return cmp(self.precedence, prec_dict.get(other,9)) + + +def rpn_to_infix(s, VERBOSE=False): + """ + converts rpn notation to infix notation for string s + + "^" are replaced with "**" + + >>> rpn_to_infix('5 4 +') + '5 + 4' + >>> rpn_to_infix('5 -4 +') + '5 - 4' + >>> rpn_to_infix('5 -4 -') + '5 + 4' + >>> rpn_to_infix('5 -4.2 +') + '5 - 4.2' + >>> rpn_to_infix('-4 2 **') + '(-4) ** 2' + >>> rpn_to_infix('x y +') + 'x + y' + >>> rpn_to_infix('x -y +') + 'x - y' + >>> rpn_to_infix('5 4 3 2 ** ** **') + '5 ** 4 ** 3 ** 2' + >>> rpn_to_infix('5 6 ** 7 **') + '(5 ** 6) ** 7' + >>> rpn_to_infix('1 2 3 + -') + '1 - (2 + 3)' + >>> rpn_to_infix('4 3 2 + +') + '4 + 3 + 2' + >>> rpn_to_infix('5 4 3 2 + + +') + '5 + 4 + 3 + 2' + >>> rpn_to_infix('5 4 3 2 * * *') + '5 * 4 * 3 * 2' + >>> rpn_to_infix('5 4 3 2 + - +') + '5 + (4 - (3 + 2))' + >>> rpn_to_infix('3 4 5 * -') + '3 - 4 * 5' + >>> rpn_to_infix('3 4 5 - *') + '(3 - 4) * 5' + >>> rpn_to_infix('4 2 * 1 5 - +') + '4 * 2 + (1 - 5)' + >>> rpn_to_infix('4 2 * 1 5 - 2 ** /') + '4 * 2 / (1 - 5) ** 2' + >>> rpn_to_infix('3 4 2 * 1 5 - 2 3 ** ** / +') + '3 + 4 * 2 / (1 - 5) ** 2 ** 3' + >>> rpn_to_infix('1 2 + 3 4 + ** 5 6 + **') + '((1 + 2) ** (3 + 4)) ** (5 + 6)' + >>> rpn_to_infix('x sin') + 'sin(x)' + >>> rpn_to_infix('5 4 3 2 + sqrt - +') + '5 + (4 - sqrt(3 + 2))' + >>> rpn_to_infix('5 4 3 2 + sqrt ln - +') + '5 + (4 - ln(sqrt(3 + 2)))' + >>> rpn_to_infix('5 sin 4 cos *') + 'sin(5) * cos(4)' + >>> rpn_to_infix('5 4 cos * sin') + 'sin(5 * cos(4))' + >>> rpn_to_infix('3 4 2 * 1 -5 - ln 2 3 ** ** / +') + '3 + 4 * 2 / ln(1 + 5) ** 2 ** 3' + """ + global prec_dict, arity_dict + + if VERBOSE : print('TOKEN STACK') + + stack=[] + for token in s.replace('^','**').split(): + if token in prec_dict: + if arity_dict[token] == 1: + stack.append(Node(stack.pop(),token)) + elif arity_dict[token] == 2: + stack.append(Node(stack.pop(),token,stack.pop())) + else: + stack.append(token) + + # can't use \t in order to make global docstring pass doctest + if VERBOSE : print(token+' '*(7-len(token))+repr(stack)) + + return str(stack[0]) + +def rpn_eval(s): + """ + computes the value of an rpn string + + >>> rpn_eval('5 4 +') == eval(rpn_to_infix('5 4 +')) + True + >>> rpn_eval('-4 2 **') == eval(rpn_to_infix('-4 2 **')) + True + >>> round(rpn_eval('3 4 2 * 1 -5 - ln 2 3 ** ** / +'),7) == \ + round(eval(rpn_to_infix('3 4 2 * 1 -5 - ln 2 3 ** ** / +')),7) + True + >>> round(rpn_eval('5 4 3 2 + sqrt ln - +'),7) == \ + round(eval(rpn_to_infix('5 4 3 2 + sqrt ln - +')),7) + True + """ + + global prec_dict, arity_dict + + stack=[] + for token in s.replace('^','**').split(): + if token in prec_dict: + if arity_dict[token] == 1: + stack.append(eval('%s(%s)'%(token,stack.pop()))) + elif arity_dict[token] == 2: + x,y=stack.pop(),stack.pop() + stack.append(eval('(%s) %s %s'%(y,token,x))) + else: + stack.append(token) + + return stack[0] + +if __name__ == "__main__": + import doctest + doctest.testmod() diff --git a/Task/Parsing-RPN-to-infix-conversion/REXX/parsing-rpn-to-infix-conversion.rexx b/Task/Parsing-RPN-to-infix-conversion/REXX/parsing-rpn-to-infix-conversion.rexx new file mode 100644 index 0000000000..1dfa62eacd --- /dev/null +++ b/Task/Parsing-RPN-to-infix-conversion/REXX/parsing-rpn-to-infix-conversion.rexx @@ -0,0 +1,36 @@ +/*REXX program converts Reverse Polish Notation (RPN) ──► infix notation*/ +showAction = 1 /* 0 if no showActions wanted. */ + # = 0 /*initialize stack pointer to 0. */ + oS = '+ - / * ^' /*operator symbols. */ + oP = '2 2 3 3 4' /*operator priorities. */ + oA = '◄ ◄ ◄ ◄ ►' /*operator associations. */ +say "infix: " toInfix( "3 4 2 * 1 5 - 2 3 ^ ^ / +" ) +say "infix: " toInfix( "1 2 + 3 4 + ^ 5 6 + ^" ) /* [↓] Deutsch.*/ +say "infix: " toInfix( "Mond Sterne Schlamm + * Feur Suppe * ^" ) +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────────────────────────────────────────*/ +pop: pop=#; #=#-1; return @.pop +push: #=#+1; @.#=arg(1); return +/*──────────────────────────────────────────────────────────────────────*/ +stack2str: $=; do j=1 for #; _ = @.j; y=left(_,1) + if pos(' ',_)==0 then _ = '{'strip(substr(_,2))"}" + else _ = substr(_,2) + $=$ '{'strip(y _)"}" + end /*j*/ +return space($) +/*──────────────────────────────────────────────────────────────────────*/ +toInfix: parse arg rpn; say copies('─',80-1); say 'RPN: ' space(rpn) + + do N=1 to words(RPN); ?=word(RPN,N) /*process each of the RPN tokens.*/ + if pos(?,oS)==0 then call push '¥' ? /*when in doubt, add a Yen to it.*/ + else do; g=pop(); gp=left(g,1); g=substr(g,2) + h=pop(); hp=left(h,1); h=substr(h,2) + tp=substr(oP,pos(?,oS),1);ta=substr(oA,pos(?,oS),1) + if hp $stack" + } + return [lindex $stack end 1] +} + +puts [rpn2infix {3 4 2 * 1 5 - 2 3 ^ ^ / +}] +puts [rpn2infix {1 2 + 3 4 + ^ 5 6 + ^}] diff --git a/Task/Parsing-Shunting-yard-algorithm/0DESCRIPTION b/Task/Parsing-Shunting-yard-algorithm/0DESCRIPTION new file mode 100644 index 0000000000..994acfc880 --- /dev/null +++ b/Task/Parsing-Shunting-yard-algorithm/0DESCRIPTION @@ -0,0 +1,32 @@ +Given the operator characteristics and input from the [[wp:Shunting-yard_algorithm|Shunting-yard algorithm]] page and tables +Use the algorithm to show the changes in the operator stack and RPN output +as each individual token is processed. + +* Assume an input of a correct, space separated, string of tokens representing an infix expression +* Generate a space separated output string representing the RPN +* Test with the input string '3 + 4 * 2 / ( 1 - 5 ) ^ 2 ^ 3' then print and display the output here. +* Operator precedence is given in this table: +:{| class="wikitable" + +! operator !! precedence !! associativity +|- || align="center" +| ^ || 4 || Right +|- || align="center" +| * || 3 || Left +|- || align="center" +| / || 3 || Left +|- || align="center" +| + || 2 || Left +|- || align="center" +| - || 2 || Left +|} + +;Extra credit: +* Add extra text explaining the actions and an optional comment for the action on receipt of each token. + +;Note: +* the handling of functions and arguments is not required. + +;See also: +* [[Parsing/RPN calculator algorithm]] for a method of calculating a final value from this output RPN expression. +* [[Parsing/RPN to infix conversion]]. diff --git a/Task/Parsing-Shunting-yard-algorithm/AutoHotkey/parsing-shunting-yard-algorithm.ahk b/Task/Parsing-Shunting-yard-algorithm/AutoHotkey/parsing-shunting-yard-algorithm.ahk new file mode 100644 index 0000000000..6ffe8ac421 --- /dev/null +++ b/Task/Parsing-Shunting-yard-algorithm/AutoHotkey/parsing-shunting-yard-algorithm.ahk @@ -0,0 +1,70 @@ +SetBatchLines -1 +#NoEnv + +expr := "3 + 4 * 2 / ( 1 - 5 ) ^ 2 ^ 3" + +output := "Testing string '" expr "'`r`n`r`nToken`tOutput Queue" + . Space(StrLen(expr)-StrLen("Output Queue")+2) "OP Stack" + +; define a stack with semantic .push() and .pop() funcs +stack := {push: func("ObjInsert"), pop: func("ObjRemove"), peek: func("Peek")} + +Loop Parse, expr, %A_Space% +{ + token := A_LoopField + if token is number + Q .= token A_Space + if isOp(token){ + o1 := token + while isOp(o2 := stack.peek()) + and ((isLeft(o1) and Precedence(o1) <= Precedence(o2)) + or (isRight(o1) and Precedence(o1) < Precedence(o2))) + Q .= stack.pop() A_Space + stack.push(o1) + } + If ( token = "(" ) + stack.push(token) + If ( token = ")" ) + { + While ((t := stack.pop()) != "(") && (t != "") + Q .= t A_Space + if (t = "") + throw Exception("Unmatched parenthesis. " + . "Character number " A_Index) + } + output .= "`r`n" token Space(7) Q Space(StrLen(expr)+2-StrLen(Q)) + . Disp(stack) +} +output .= "`r`n(empty stack to output)" +While (t := stack.pop()) != "" + if InStr("()", t) + throw Exception("Unmatched parenthesis.") + else Q .= t A_Space, output .= "`r`n" Space(8) Q + . Space(StrLen(expr)+2-StrLen(Q)) Disp(stack) +output .= "`r`n`r`nFinal string: '" Q "'" +clipboard := output + +isOp(t){ + return (!!InStr("+-*/^", t) && t) +} +Peek(this){ + r := this.Remove(), this.Insert(r) + return r +} +IsLeft(o){ + return !!InStr("*/+-", o) +} +IsRight(o){ + return o = "^" +} +Precedence(o){ + return (InStr("+-/*^", o)+3)//2 +} +Disp(obj){ + for each, val in obj + o := val . o + return o +} +Space(n){ + return n>0 ? A_Space Space(n-1) : "" +} diff --git a/Task/Parsing-Shunting-yard-algorithm/C/parsing-shunting-yard-algorithm.c b/Task/Parsing-Shunting-yard-algorithm/C/parsing-shunting-yard-algorithm.c new file mode 100644 index 0000000000..fc04d9a945 --- /dev/null +++ b/Task/Parsing-Shunting-yard-algorithm/C/parsing-shunting-yard-algorithm.c @@ -0,0 +1,181 @@ +#include +#include +#include + +typedef struct { + const char *s; + int len, prec, assoc; +} str_tok_t; + +typedef struct { + const char * str; + int assoc, prec; + regex_t re; +} pat_t; + +enum assoc { A_NONE, A_L, A_R }; +pat_t pat_eos = {"", A_NONE, 0}; + +pat_t pat_ops[] = { + {"^\\)", A_NONE, -1}, + {"^\\*\\*", A_R, 3}, + {"^\\^", A_R, 3}, + {"^\\*", A_L, 2}, + {"^/", A_L, 2}, + {"^\\+", A_L, 1}, + {"^-", A_L, 1}, + {0} +}; + +pat_t pat_arg[] = { + {"^[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?"}, + {"^[a-zA-Z_][a-zA-Z_0-9]*"}, + {"^\\(", A_L, -1}, + {0} +}; + +str_tok_t stack[256]; /* assume these are big enough */ +str_tok_t queue[256]; +int l_queue, l_stack; +#define qpush(x) queue[l_queue++] = x +#define spush(x) stack[l_stack++] = x +#define spop() stack[--l_stack] + +void display(const char *s) +{ + int i; + printf("\033[1;1H\033[JText | %s", s); + printf("\nStack| "); + for (i = 0; i < l_stack; i++) + printf("%.*s ", stack[i].len, stack[i].s); // uses C99 format strings + printf("\nQueue| "); + for (i = 0; i < l_queue; i++) + printf("%.*s ", queue[i].len, queue[i].s); + puts("\n\n"); + getchar(); +} + +int prec_booster; + +#define fail(s1, s2) {fprintf(stderr, "[Error %s] %s\n", s1, s2); return 0;} + +int init(void) +{ + int i; + pat_t *p; + + for (i = 0, p = pat_ops; p[i].str; i++) + if (regcomp(&(p[i].re), p[i].str, REG_NEWLINE|REG_EXTENDED)) + fail("comp", p[i].str); + + for (i = 0, p = pat_arg; p[i].str; i++) + if (regcomp(&(p[i].re), p[i].str, REG_NEWLINE|REG_EXTENDED)) + fail("comp", p[i].str); + + return 1; +} + +pat_t* match(const char *s, pat_t *p, str_tok_t * t, const char **e) +{ + int i; + regmatch_t m; + + while (*s == ' ') s++; + *e = s; + + if (!*s) return &pat_eos; + + for (i = 0; p[i].str; i++) { + if (regexec(&(p[i].re), s, 1, &m, REG_NOTEOL)) + continue; + t->s = s; + *e = s + (t->len = m.rm_eo - m.rm_so); + return p + i; + } + return 0; +} + +int parse(const char *s) { + pat_t *p; + str_tok_t *t, tok; + + prec_booster = l_queue = 0; + display(s); + while (*s) { + p = match(s, pat_arg, &tok, &s); + if (!p || p == &pat_eos) fail("parse arg", s); + + /* Odd logic here. Don't actually stack the parens: don't need to. */ + if (p->prec == -1) { + prec_booster += 100; + continue; + } + qpush(tok); + display(s); + +re_op: p = match(s, pat_ops, &tok, &s); + if (!p) fail("parse op", s); + + tok.assoc = p->assoc; + tok.prec = p->prec; + + if (p->prec > 0) + tok.prec = p->prec + prec_booster; + else if (p->prec == -1) { + if (prec_booster < 100) + fail("unmatched )", s); + tok.prec = prec_booster; + } + + while (l_stack) { + t = stack + l_stack - 1; + if (!(t->prec == tok.prec && t->assoc == A_L) + && t->prec <= tok.prec) + break; + qpush(spop()); + display(s); + } + + if (p->prec == -1) { + prec_booster -= 100; + goto re_op; + } + + if (!p->prec) { + display(s); + if (prec_booster) + fail("unmatched (", s); + return 1; + } + + spush(tok); + display(s); + } + + return 1; +} + +int main() +{ + int i; + const char *tests[] = { + "3 + 4 * 2 / ( 1 - 5 ) ^ 2 ^ 3", /* RC mandated: OK */ + "123", /* OK */ + "3+4 * 2 / ( 1 - 5 ) ^ 2 ^ 3.14", /* OK */ + "(((((((1+2+3**(4 + 5))))))", /* bad parens */ + "a^(b + c/d * .1e5)!", /* unknown op */ + "(1**2)**3", /* OK */ + 0 + }; + + if (!init()) return 1; + for (i = 0; tests[i]; i++) { + printf("Testing string `%s' \n", tests[i]); + getchar(); + + printf("string `%s': %s\n\n", tests[i], + parse(tests[i]) ? "Ok" : "Error"); + } + + return 0; +} diff --git a/Task/Parsing-Shunting-yard-algorithm/Go/parsing-shunting-yard-algorithm.go b/Task/Parsing-Shunting-yard-algorithm/Go/parsing-shunting-yard-algorithm.go new file mode 100644 index 0000000000..0f200c72e4 --- /dev/null +++ b/Task/Parsing-Shunting-yard-algorithm/Go/parsing-shunting-yard-algorithm.go @@ -0,0 +1,72 @@ +package main + +import ( + "fmt" + "strings" +) + +var input = "3 + 4 * 2 / ( 1 - 5 ) ^ 2 ^ 3" + +var opa = map[string]struct { + prec int + rAssoc bool +}{ + "^": {4, true}, + "*": {3, false}, + "/": {3, false}, + "+": {2, false}, + "-": {2, false}, +} + +func main() { + fmt.Println("infix: ", input) + fmt.Println("postfix:", parseInfix(input)) +} + +func parseInfix(e string) (rpn string) { + var stack []string // holds operators and left parenthesis + for _, tok := range strings.Fields(e) { + switch tok { + case "(": + stack = append(stack, tok) // push "(" to stack + case ")": + var op string + for { + // pop item ("(" or operator) from stack + op, stack = stack[len(stack)-1], stack[:len(stack)-1] + if op == "(" { + break // discard "(" + } + rpn += " " + op // add operator to result + } + default: + if o1, isOp := opa[tok]; isOp { + // token is an operator + for len(stack) > 0 { + // consider top item on stack + op := stack[len(stack)-1] + if o2, isOp := opa[op]; !isOp || o1.prec > o2.prec || + o1.prec == o2.prec && o1.rAssoc { + break + } + // top item is an operator that needs to come off + stack = stack[:len(stack)-1] // pop it + rpn += " " + op // add it to result + } + // push operator (the new one) to stack + stack = append(stack, tok) + } else { // token is an operand + if rpn > "" { + rpn += " " + } + rpn += tok // add operand to result + } + } + } + // drain stack to result + for len(stack) > 0 { + rpn += " " + stack[len(stack)-1] + stack = stack[:len(stack)-1] + } + return +} diff --git a/Task/Parsing-Shunting-yard-algorithm/Haskell/parsing-shunting-yard-algorithm.hs b/Task/Parsing-Shunting-yard-algorithm/Haskell/parsing-shunting-yard-algorithm.hs new file mode 100644 index 0000000000..8c5fe0bea6 --- /dev/null +++ b/Task/Parsing-Shunting-yard-algorithm/Haskell/parsing-shunting-yard-algorithm.hs @@ -0,0 +1,53 @@ +import qualified Data.Map as M +import Text.Printf +import Data.List +import System.Environment + +data Assoc = L | R deriving (Eq, Show) +data Op = Op Assoc Int + +ops = M.fromList [("^", Op R 4) + ,("*", Op L 3),("/", Op L 3) + ,("+", Op L 2),("-", Op L 2)] + +assoc t = case M.lookup t ops of + Just (Op a p) -> a + Nothing -> error "Bad lookup (assoc)" + +prec t = case M.lookup t ops of + Just (Op a p) -> p + Nothing -> error "Bad lookup (prec)" + +isDouble t = case reads t :: [(Double, String)] of + [(_, "")] -> True + _ -> False + +finish (vs, fs, xs, _) = ((reverse fs ++ vs), [], xs, "Finished") + +eval xs = (intermediates ++ [(finish $ last intermediates)]) + where intermediates = scanl f ([], [], words xs, "").words $ xs + f (vs, fs, ts, msg) t | isDouble t = ((t:vs), fs, tail ts, "Writing '" + ++ t) + | t `M.member` ops = pushOp t (vs, fs, ts, msg) + | t == "(" = (vs, (t:fs), tail ts, "Pushing '('") + | t == ")" = (((takeWhile (/="(") fs) ++ vs), + (tail $ dropWhile (/="(") fs), + tail ts, "Writing ops till ')'") + +pushOp op1 (vs, fs, ts, msg) = if op2isOp && + ((assoc op1 == L && prec op1 <= prec op2) || + (prec op1 < prec op2)) + then ((op2:vs), (op1:tail fs), tail ts, + "Writing '" ++ op2 ++ + "', pushing " ++ op1) + else (vs, (op1:fs), tail ts, "Pushing '" ++ op1 ++ "'") + where (op2isOp, op2) = ((not $ null fs) && (op2 `M.member` ops), head fs) + +showData (vs, fs, xs, msg) = concat [printf "%30s" (intercalate " " (reverse vs)) , " " + ,printf "%10s" (intercalate " " fs) , " " + ,printf "%35s" (intercalate " " xs) , " " + ,printf "%s" msg] + +showAll xs = intercalate "\n" $ map showData xs + +main = do putStrLn.showAll.eval $ "3 + 4 * 2 / ( 1 - 5 ) ^ 2 ^ 3" diff --git a/Task/Parsing-Shunting-yard-algorithm/Icon/parsing-shunting-yard-algorithm.icon b/Task/Parsing-Shunting-yard-algorithm/Icon/parsing-shunting-yard-algorithm.icon new file mode 100644 index 0000000000..0af7e2024e --- /dev/null +++ b/Task/Parsing-Shunting-yard-algorithm/Icon/parsing-shunting-yard-algorithm.icon @@ -0,0 +1,64 @@ +procedure main() + infix := "3 + 4 * 2 / ( 1 - 5 ) ^ 2 ^ 3" + printf("Infix = %i\n",infix) + printf("RPN = %i\n",Infix2RPN(infix)) +end + +link printf + +record op_info(pr,as) # p=precedence, a=associativity (left=null) + +procedure Infix2RPN(expr) #: Infix to RPN parser - shunting yard +static oi +initial { + oi := table() # precedence & associativity + every oi[!"+-"] := op_info(2) # 2L + every oi[!"*/"] := op_info(3) # 3L + oi["^"] := op_info(4,1) # 4R + } + + ostack := [] # operator stack + rpn := "" # rpn + + pat := sprintf("%%5s : %%-%ds : %%s\n",*expr) # fmt + printf(pat,"Token","Output","Op Stack") # header + + expr ? until pos(0) do { # while tokens + tab(many(' ')) # consume any seperator + token := tab(upto(' ')|0) # get token + printf(pat,token,rpn,list2string(ostack)) # report + if token := numeric(token) then # ... numeric + rpn ||:= token || " " + else + if member(oi,token) then { # ... operator + while member(oi,op2 := ostack[1]) & + ( /oi[token].as & oi[token].pr <= oi[op2].pr ) | + ( \oi[token].as & oi[token].pr < oi[op2].pr ) do + rpn ||:= pop(ostack) || " " + push(ostack,token) + } + else # ... parenthesis + if token == "(" then + push(ostack,token) + else if token == ")" then { + until ostack[1] == "(" do + rpn ||:= pop(ostack) || " " | + stop("Unbalanced parenthesis") + pop(ostack) # discard "(" + } + } + + while token := pop(ostack) do # ... input exhausted + if token == ("("|")") then stop("Unbalanced parenthesis") + else { + rpn ||:= token || " " + printf(pat,"",rpn,list2string(ostack)) + } + + return rpn +end + +procedure list2string(L) #: format list as a string + every (s := "[ ") ||:= !L || " " + return s || "]" +end diff --git a/Task/Parsing-Shunting-yard-algorithm/J/parsing-shunting-yard-algorithm-1.j b/Task/Parsing-Shunting-yard-algorithm/J/parsing-shunting-yard-algorithm-1.j new file mode 100644 index 0000000000..b261e87bbd --- /dev/null +++ b/Task/Parsing-Shunting-yard-algorithm/J/parsing-shunting-yard-algorithm-1.j @@ -0,0 +1,144 @@ +NB. j does not have a verb based precedence. +NB. j evaluates verb noun sequences from right to left. +NB. Seriously. 18 precedence levels in C++ . + +display=: ([: : (smoutput@:(, [: ; ' '&,&.>@:{:@:|:))) :: empty + +Display=: adverb define +: +m display^:(0 -.@:-: x)y +) + +NB. Queue, Stack, Pop: m literal name of vector to use. verbose unless x is 0. +NB. Implementation includes display, group push and pop not available in the RC FIFO & LIFO pages +NB. As adverbs, these definitions work with any global variable. +NB. Pop needs the feature, and it helps with display as well. +Queue=: adverb define NB. enqueue y +('m'~)=: y ,~ (m~) +EMPTY +: +x (m,' queue')Display y +m Queue y +) + +Stack=: adverb define NB. Stack y +('m'~)=: (|.y) , (m~) +EMPTY +: +x (m,' stack')Display y +m Stack y +) + +Pop=: adverb define NB. Pop y items +0 m Pop y +: +y=. 0 {:@:, y NB. if y is empty use 0 instead +rv=. y {. (m~) +('m'~)=: y }. (m~) +x (m,' pop') Display rv +rv +) + +NB. tests +TEST=: '' +'TEST'Stack'abc' +'TEST'Stack'de' +assert 'edc' -: 'TEST'Pop 3 +assert 'ba' -: 'TEST'Pop 2 +assert 0 (= #) TEST +'TEST'Queue'abc' +'TEST'Queue'de' +assert 'ab' -: 'TEST'Pop 2 +assert 'cde' -: 'TEST'Pop 3 +assert 0 (= #) TEST + +any=: +./ + +DIGITS=: a. {~ 48+i.10 NB. ASCII 48--57 +precedence_oppression=: <;._1' +- */ ^ ( ) ',DIGITS +associativity=: 'xLLRxxL' + +classify=: {:@:I.@:(1 , any@e.&>)&precedence_oppression + +NB. The required tokens are also tokens in j. +NB. Use the default sequential machine ;: for lexical analysis. +rclex=: (;~ classify)"0@:;: + + +NB. numbers can be treated as highest precedence operators +number=: Q Queue NB. put numbers onto the output queue +left=: S Stack NB. push left paren onto the stack + +NB. Until the token at the top of the stack is (, pop +NB. operators off the stack onto the output queue. +NB. Pop the left parenthesis from the stack, but not onto the output queue. +right=: 4 : 0 NB. If the token is a right parenthesis: +i=. (S~) (i. rclex) '(' +if. i (= #) S~ do. + smoutput'Check your parens!' + throw. +end. +x Q Queue x S Pop i +x S Pop 1 +EMPTY +) + +NB. If the token is an operator, o1, then: +NB. +NB. while there is an operator token, o2, at the top of the stack, and +NB. either o1 is [[left-associative and its precedence is less than or +NB. equal to that of o2]]"L*.<:", or o1 is [[right-associative and its precedence +NB. is less than that of o2]]"R*.<", pop o2 off the stack, onto the output queue; +NB. [[the tally of adjacent leading truths]]"NCT" +NB. +NB. push o1 onto the stack. +o=: 4 : 0 +P=. 0 0 {:: y +L=. 'L' = P { associativity +operators=. ({.~ i.&(rclex'(')) S~ +NB. NCT L*.<: or R*.< +i=. (+/@:(*./\)@:((L *. P&<:) +. ((-.L) *. P&<))@:(0&{::"1)) :: 0: operators +x Q Queue x S Pop i +x (S Stack) y +EMPTY +) + +NB. terminating version of invalid +invalid=: 4 : 0 +smoutput 'invalid token ',0 1 {:: y +throw. +) + +NB. demonstrated invalid +invalid=: [: smoutput 'discarding invalid token ' , 0 1 {:: ] + +NB. shunt_yard is a verb to implement shunt-yard parsing. +NB. verbose defaults to 0. (quiet) +NB. use: verbosity shunt_yard_parse algebraic_string +shunt_yard_parse=: 0&$: : (4 : 0) + +NB. j's data structure is array. Rank 1 arrays (vectors) +NB. are just right for the stack and output queue. + +'S Q'=: ;: 'OPERATOR OUTPUT' +('S'~)=:('Q'~)=: i.0 2 + +NB. Follow agenda for all tokens, result saved on global OUTPUT variable +x (invalid`o`o`o`left`right`number@.(0 0 {:: ])"2 ,:"1@:rclex) y +NB. x (invalid`o`o`o`left`right`o@.(0 0 {:: ])"2 ,:"1@:rclex) y NB. numbers can be treated as operators +NB. check for junk on stack +if. (rclex'(') e. S~ do. + smoutput'Check your other parens!' + throw. +end. + +NB. shift remaining operators onto the output queue +x Q Queue x S Pop # S~ + +NB. return the output queue +Q~ +) + +algebra_to_rpn=: {:@:|:@:shunt_yard_parse + +fulfill_requirement=: ;@:(' '&,&.>)@:algebra_to_rpn diff --git a/Task/Parsing-Shunting-yard-algorithm/J/parsing-shunting-yard-algorithm-2.j b/Task/Parsing-Shunting-yard-algorithm/J/parsing-shunting-yard-algorithm-2.j new file mode 100644 index 0000000000..54fe493ca8 --- /dev/null +++ b/Task/Parsing-Shunting-yard-algorithm/J/parsing-shunting-yard-algorithm-2.j @@ -0,0 +1,55 @@ + fulfill_requirement '3+4*2/(1-5)^2^3' + 3 4 2 * 1 5 - 2 3 ^ ^ / + + + shunt_yard_parse'3*)2+4)' +Check your parens! + + shunt_yard_parse'3*(2+4' +Check your other parens! + + algebra_to_rpn'1+x*(3+x)' +discarding invalid token x +discarding invalid token x +┌─┬─┬─┬─┬─┐ +│1│3│+│*│+│ +└─┴─┴─┴─┴─┘ + + NB. Boxed form useful for evaluation + algebra_to_rpn'0+666*(1+666*(2+666*(3)))' NB. polynomial evaluation. +┌─┬───┬─┬───┬─┬───┬─┬─┬─┬─┬─┬─┬─┐ +│0│666│1│666│2│666│3│*│+│*│+│*│+│ +└─┴───┴─┴───┴─┴───┴─┴─┴─┴─┴─┴─┴─┘ + + 1 fulfill_requirement'3 + 4 * 2 / ( 1 - 5 ) ^ 2 ^ 3' +OUTPUT queue 3 +OPERATOR pop +OUTPUT queue +OPERATOR stack + +OUTPUT queue 4 +OPERATOR pop +OUTPUT queue +OPERATOR stack * +OUTPUT queue 2 +OPERATOR pop * +OUTPUT queue * +OPERATOR stack / +OPERATOR stack ( +OUTPUT queue 1 +OPERATOR pop +OUTPUT queue +OPERATOR stack - +OUTPUT queue 5 +OPERATOR pop - +OUTPUT queue - +OPERATOR pop ( +OPERATOR pop +OUTPUT queue +OPERATOR stack ^ +OUTPUT queue 2 +OPERATOR pop +OUTPUT queue +OPERATOR stack ^ +OUTPUT queue 3 +OPERATOR pop ^ ^ / + +OUTPUT queue ^ ^ / + + 3 4 2 * 1 5 - 2 3 ^ ^ / + diff --git a/Task/Parsing-Shunting-yard-algorithm/PL-I/parsing-shunting-yard-algorithm-1.pli b/Task/Parsing-Shunting-yard-algorithm/PL-I/parsing-shunting-yard-algorithm-1.pli new file mode 100644 index 0000000000..fac6a9fab2 --- /dev/null +++ b/Task/Parsing-Shunting-yard-algorithm/PL-I/parsing-shunting-yard-algorithm-1.pli @@ -0,0 +1,82 @@ +cvt: procedure options (main); /* 15 January 2012. */ + declare (in, stack, out) character (100) varying; + declare (ch, chs) character (1); + declare display bit (1) static initial ('0'b); + + in = '3 + 4 * 2 / ( 1 - 5 ) ^ 2 ^ 3'; + + in = '(' || in || ' ) '; /* Initialize with parentheses */ + + put skip edit ('INPUT', 'STACK', 'OUTPUT') (a, col(37), a, col(47), a); + + stack = ' '; out = ''; /* Initialize */ + do while (length (in) > 0); + ch = substr(in, 1, 1); + select (ch); + when (' ') ; + + when ('+', '-', '*', '/', '^') + do; + /* Copy any equal or higher-priority operators from the stack */ + /* to the output string */ + chs = substr(stack, 1, 1); + do while ((spriority(chs) >= priority(ch)) & ( chs ^= ')' ) ); + if display then put skip list ('unstacking: ' || chs); + out = out || ' ' || chs; + stack = substr(stack, 2); + chs = substr(stack, 1, 1); + end; + /* Now copy the input to the TOS. */ + if display then put skip list ('copying ' || ch || ' to TOS'); + stack = ch || stack; + end; + when ( '(' ) + do; + stack = '(' || stack; + if display then put skip list ('stacking the (' ); + end; + when ( ')' ) + do; /* copy all operators from the stack to the output, */ + /* until a '(' is encountered. */ + chs = substr(stack, 1, 1); + do while (chs ^= '(' ); + if display then put skip list ('copying stack ' || chs || ' to output'); + put skip edit (stack, out) (col(37), a, col(47), a); + out = out || ' ' || chs; + stack = substr(stack, 2); + chs = substr(stack, 1, 1); + end; + /* Now delete the '(' from the input and */ + /* the ')' from the top of the stack. */ + if display then put skip edit ('Deleting ( from TOS') (col(30), a); + stack = substr(stack, 2); + /* The '(' on the input is removed at the end of the loop. */ + end; + otherwise /* it's an operand. */ + do; + out = out || ' '; + do while (ch ^= ' '); + if display then put skip list ('copying ' || ch || ' to output'); + out = out || ch; + in = substr(in, 2); + ch = substr(in, 1, 1); + end; + end; + end; + in = substr(in, 2); /* Remove one character from the input */ + put skip edit (in, stack, out) (a, col(37), a, col(47), a); + end; + +priority: procedure (ch) returns (character(1)); + declare ch character (1); + + return ( translate(ch, '1122335', '()+-*/^' ) ); +end priority; + +spriority: procedure (ch) returns (character(1)); + declare ch character (1); + + return ( translate(ch, '1122334', '()+-*/^' ) ); +end spriority; + +end cvt; diff --git a/Task/Parsing-Shunting-yard-algorithm/PL-I/parsing-shunting-yard-algorithm-2.pli b/Task/Parsing-Shunting-yard-algorithm/PL-I/parsing-shunting-yard-algorithm-2.pli new file mode 100644 index 0000000000..9ac4a4e096 --- /dev/null +++ b/Task/Parsing-Shunting-yard-algorithm/PL-I/parsing-shunting-yard-algorithm-2.pli @@ -0,0 +1,32 @@ +INPUT STACK OUTPUT +3 + 4 * 2 / ( 1 - 5 ) ^ 2 ^ 3 ) ( ++ 4 * 2 / ( 1 - 5 ) ^ 2 ^ 3 ) ( 3 + 4 * 2 / ( 1 - 5 ) ^ 2 ^ 3 ) +( 3 +4 * 2 / ( 1 - 5 ) ^ 2 ^ 3 ) +( 3 +* 2 / ( 1 - 5 ) ^ 2 ^ 3 ) +( 3 4 + 2 / ( 1 - 5 ) ^ 2 ^ 3 ) *+( 3 4 +2 / ( 1 - 5 ) ^ 2 ^ 3 ) *+( 3 4 +/ ( 1 - 5 ) ^ 2 ^ 3 ) *+( 3 4 2 + ( 1 - 5 ) ^ 2 ^ 3 ) /+( 3 4 2 * +( 1 - 5 ) ^ 2 ^ 3 ) /+( 3 4 2 * + 1 - 5 ) ^ 2 ^ 3 ) (/+( 3 4 2 * +1 - 5 ) ^ 2 ^ 3 ) (/+( 3 4 2 * +- 5 ) ^ 2 ^ 3 ) (/+( 3 4 2 * 1 + 5 ) ^ 2 ^ 3 ) -(/+( 3 4 2 * 1 +5 ) ^ 2 ^ 3 ) -(/+( 3 4 2 * 1 +) ^ 2 ^ 3 ) -(/+( 3 4 2 * 1 5 + -(/+( 3 4 2 * 1 5 + ^ 2 ^ 3 ) /+( 3 4 2 * 1 5 - +^ 2 ^ 3 ) /+( 3 4 2 * 1 5 - + 2 ^ 3 ) ^/+( 3 4 2 * 1 5 - +2 ^ 3 ) ^/+( 3 4 2 * 1 5 - +^ 3 ) ^/+( 3 4 2 * 1 5 - 2 + 3 ) ^^/+( 3 4 2 * 1 5 - 2 +3 ) ^^/+( 3 4 2 * 1 5 - 2 +) ^^/+( 3 4 2 * 1 5 - 2 3 + ^^/+( 3 4 2 * 1 5 - 2 3 + ^/+( 3 4 2 * 1 5 - 2 3 ^ + /+( 3 4 2 * 1 5 - 2 3 ^ ^ + +( 3 4 2 * 1 5 - 2 3 ^ ^ / + 3 4 2 * 1 5 - 2 3 ^ ^ / + + 3 4 2 * 1 5 - 2 3 ^ ^ / + diff --git a/Task/Parsing-Shunting-yard-algorithm/PicoLisp/parsing-shunting-yard-algorithm-1.l b/Task/Parsing-Shunting-yard-algorithm/PicoLisp/parsing-shunting-yard-algorithm-1.l new file mode 100644 index 0000000000..a123e5cca2 --- /dev/null +++ b/Task/Parsing-Shunting-yard-algorithm/PicoLisp/parsing-shunting-yard-algorithm-1.l @@ -0,0 +1,41 @@ +(de operator (Op) + (member Op '("\^" "*" "/" "+" "-")) ) + +(de leftAssoc (Op) + (member Op '("*" "/" "+" "-")) ) + +(de precedence (Op) + (case Op + ("\^" 4) + (("*" "/") 3) + (("+" "-") 2) ) ) + +(de shuntingYard (Str) + (make + (let (Fmt (-7 -30 -4) Stack) + (tab Fmt "Token" "Output" "Stack") + (for Token (str Str "_") + (cond + ((num? Token) (link @)) + ((= "(" Token) (push 'Stack Token)) + ((= ")" Token) + (until (= "(" (car Stack)) + (unless Stack + (quit "Unbalanced Stack") ) + (link (pop 'Stack)) ) + (pop 'Stack) ) + (T + (while + (and + (operator (car Stack)) + ((if (leftAssoc (car Stack)) <= <) + (precedence Token) + (precedence (car Stack)) ) ) + (link (pop 'Stack)) ) + (push 'Stack Token) ) ) + (tab Fmt Token (glue " " (made)) Stack) ) + (while Stack + (when (= "(" (car Stack)) + (quit "Unbalanced Stack") ) + (link (pop 'Stack)) + (tab Fmt NIL (glue " " (made)) Stack) ) ) ) ) diff --git a/Task/Parsing-Shunting-yard-algorithm/PicoLisp/parsing-shunting-yard-algorithm-2.l b/Task/Parsing-Shunting-yard-algorithm/PicoLisp/parsing-shunting-yard-algorithm-2.l new file mode 100644 index 0000000000..42110c4d25 --- /dev/null +++ b/Task/Parsing-Shunting-yard-algorithm/PicoLisp/parsing-shunting-yard-algorithm-2.l @@ -0,0 +1,22 @@ +: (shuntingYard "3 + 4 * 2 / (1 - 5) \^ 2 \^ 3") +Token Output Stack +3 3 ++ 3 + +4 3 4 + +* 3 4 *+ +2 3 4 2 *+ +/ 3 4 2 * /+ +( 3 4 2 * (/+ +1 3 4 2 * 1 (/+ +- 3 4 2 * 1 -(/+ +5 3 4 2 * 1 5 -(/+ +) 3 4 2 * 1 5 - /+ +^ 3 4 2 * 1 5 - ^/+ +2 3 4 2 * 1 5 - 2 ^/+ +^ 3 4 2 * 1 5 - 2 ^^/+ +3 3 4 2 * 1 5 - 2 3 ^^/+ + 3 4 2 * 1 5 - 2 3 ^ ^/+ + 3 4 2 * 1 5 - 2 3 ^ ^ /+ + 3 4 2 * 1 5 - 2 3 ^ ^ / + + 3 4 2 * 1 5 - 2 3 ^ ^ / + +-> (3 4 2 "*" 1 5 "-" 2 3 "\^" "\^" "/" "+") diff --git a/Task/Parsing-Shunting-yard-algorithm/Python/parsing-shunting-yard-algorithm.py b/Task/Parsing-Shunting-yard-algorithm/Python/parsing-shunting-yard-algorithm.py new file mode 100644 index 0000000000..a04b77ef2b --- /dev/null +++ b/Task/Parsing-Shunting-yard-algorithm/Python/parsing-shunting-yard-algorithm.py @@ -0,0 +1,103 @@ +from collections import namedtuple +from pprint import pprint as pp + +OpInfo = namedtuple('OpInfo', 'prec assoc') +L, R = 'Left Right'.split() + +ops = { + '^': OpInfo(prec=4, assoc=R), + '*': OpInfo(prec=3, assoc=L), + '/': OpInfo(prec=3, assoc=L), + '+': OpInfo(prec=2, assoc=L), + '-': OpInfo(prec=2, assoc=L), + '(': OpInfo(prec=9, assoc=L), + ')': OpInfo(prec=0, assoc=L), + } + +NUM, LPAREN, RPAREN = 'NUMBER ( )'.split() + + +def get_input(inp = None): + 'Inputs an expression and returns list of (TOKENTYPE, tokenvalue)' + + if inp is None: + inp = input('expression: ') + tokens = inp.strip().split() + tokenvals = [] + for token in tokens: + if token in ops: + tokenvals.append((token, ops[token])) + #elif token in (LPAREN, RPAREN): + # tokenvals.append((token, token)) + else: + tokenvals.append((NUM, token)) + return tokenvals + +def shunting(tokenvals): + outq, stack = [], [] + table = ['TOKEN,ACTION,RPN OUTPUT,OP STACK,NOTES'.split(',')] + for token, val in tokenvals: + note = action = '' + if token is NUM: + action = 'Add number to output' + outq.append(val) + table.append( (val, action, ' '.join(outq), ' '.join(s[0] for s in stack), note) ) + elif token in ops: + t1, (p1, a1) = token, val + v = t1 + note = 'Pop ops from stack to output' + while stack: + t2, (p2, a2) = stack[-1] + if (a1 == L and p1 <= p2) or (a1 == R and p1 < p2): + if t1 != RPAREN: + if t2 != LPAREN: + stack.pop() + action = '(Pop op)' + outq.append(t2) + else: + break + else: + if t2 != LPAREN: + stack.pop() + action = '(Pop op)' + outq.append(t2) + else: + stack.pop() + action = '(Pop & discard "(")' + table.append( (v, action, ' '.join(outq), ' '.join(s[0] for s in stack), note) ) + break + table.append( (v, action, ' '.join(outq), ' '.join(s[0] for s in stack), note) ) + v = note = '' + else: + note = '' + break + note = '' + note = '' + if t1 != RPAREN: + stack.append((token, val)) + action = 'Push op token to stack' + else: + action = 'Discard ")"' + table.append( (v, action, ' '.join(outq), ' '.join(s[0] for s in stack), note) ) + note = 'Drain stack to output' + while stack: + v = '' + t2, (p2, a2) = stack[-1] + action = '(Pop op)' + stack.pop() + outq.append(t2) + table.append( (v, action, ' '.join(outq), ' '.join(s[0] for s in stack), note) ) + v = note = '' + return table + +if __name__ == '__main__': + infix = '3 + 4 * 2 / ( 1 - 5 ) ^ 2 ^ 3' + print( 'For infix expression: %r\n' % infix ) + rp = shunting(get_input(infix)) + maxcolwidths = [len(max(x, key=len)) for x in zip(*rp)] + row = rp[0] + print( ' '.join('{cell:^{width}}'.format(width=width, cell=cell) for (width, cell) in zip(maxcolwidths, row))) + for row in rp[1:]: + print( ' '.join('{cell:<{width}}'.format(width=width, cell=cell) for (width, cell) in zip(maxcolwidths, row))) + + print('\n The final output RPN is: %r' % rp[-1][2]) diff --git a/Task/Parsing-Shunting-yard-algorithm/REXX/parsing-shunting-yard-algorithm-1.rexx b/Task/Parsing-Shunting-yard-algorithm/REXX/parsing-shunting-yard-algorithm-1.rexx new file mode 100644 index 0000000000..9265dac551 --- /dev/null +++ b/Task/Parsing-Shunting-yard-algorithm/REXX/parsing-shunting-yard-algorithm-1.rexx @@ -0,0 +1,48 @@ +/*REXX pgm converts infix arith. expressions to Reverse Polish notation.*/ +parse arg x; if x='' then x = '3 + 4 * 2 / ( 1 - 5 ) ^ 2 ^ 3'; ox=x +showSteps=1 /*set to 0 (zero) if working steps not wanted.*/ +x='(' space(x) ') '; tokens=words(x) /*force stacking for expression. */ + do i=1 for tokens; @.i=word(x,i); end /*i*/ /*assign input tokens*/ +L=max(20,length(x)) /*use 20 for the min show width. */ +say 'token' center('input',L,'─') center('stack',L%2,'─') center('output',L,'─') center('action',L,'─') +pad=left('',5); op=')(-+/*^'; rOp=substr(op,3); p.=; s.=; n=length(op); RPN=; stack= + + do i=1 for n; _=substr(op,i,1); s._=(i+1)%2; p._=s._+(i==n); end /*i*/ + /*[↑] assign operator priorities.*/ + do #=1 for tokens; ?=@.# /*process each token from @. list*/ + select /*@.# is: (, operator, ), operand*/ + when ?=='(' then do; stack='(' stack; call show 'moving' ? "──► stack"; end + when isOp(?) then do /*is token an operator?*/ + !=word(stack,1) /*get token from stack.*/ + do while !\==')' & s.!>=p.?; RPN=RPN ! /*add*/ + stack=subword(stack,2); /*del token from stack.*/ + call show 'unstacking:' ! + !=word(stack,1) /*get token from stack.*/ + end /*while ···)*/ + stack=? stack /*add token to stack.*/ + call show 'moving' ? "──► stack" + end + when ?==')' then do; !=word(stack,1) /*get token from stack.*/ + do while !\=='('; RPN=RPN ! /*add to RPN.*/ + stack=subword(stack,2) /*del token from stack.*/ + !=word(stack,1) /*get token from stack.*/ + call show 'moving stack' ! '──► RPN' + end /*while ···( */ + stack=subword(stack,2) /*del token from stack.*/ + call show 'deleting ( from the stack' + end + otherwise RPN=RPN ? /*add operand to RPN. */ + call show 'moving' ? '──► RPN' + end /*select*/ + end /*#*/ + +RPN=space(RPN stack) +say; say 'input:' ox; say 'RPN──►' RPN /*show input and the RPN.*/ +parse source upper . y . /*invoked via C.L. or REXX pgm?*/ +if y=='COMMAND' then exit /*stick a fork in it, we're done.*/ + else return RPN /*return RPN to invoker (RESULT).*/ +/*──────────────────────────────────ISOP subroutine─────────────────────*/ +isOp: return pos(arg(1),rOp)\==0 /*is argument1 a "real" operator?*/ +/*──────────────────────────────────SHOW subroutine─────────────────────*/ +show: if showSteps then say center(?,length(pad)) left(subword(x,#),L), + left(stack,L%2) left(space(RPN),L) arg(1); return diff --git a/Task/Parsing-Shunting-yard-algorithm/REXX/parsing-shunting-yard-algorithm-2.rexx b/Task/Parsing-Shunting-yard-algorithm/REXX/parsing-shunting-yard-algorithm-2.rexx new file mode 100644 index 0000000000..fdcee619df --- /dev/null +++ b/Task/Parsing-Shunting-yard-algorithm/REXX/parsing-shunting-yard-algorithm-2.rexx @@ -0,0 +1,57 @@ +/*REXX pgm converts infix arith. expressions to Reverse Polish notation.*/ +parse arg x; if x='' then x = '3 + 4 * 2 / ( ( 1 - 5 ) ) ^ 2 ^ 3'; ox=x +g=0 /* G is a counter of ( and ) */ + do p=1 for words(x); _=word(x,p) /*catches unbalanced () and )( */ + if _=='(' then g=g+1 + else if _==')' then do; g=g-1; if g<0 then g=-1e9; end + end /*p*/ +good=(g==0) /*indicate expression is good | ¬*/ +showSteps=1 /* 0: action steps not wanted.*/ +x='(' space(x) ') '; tokens=words(x) /*force stacking for expression. */ + do i=1 for tokens; @.i=word(x,i); end /*i*/ /*assign input tokens*/ +L=max(20,length(x)) /*use 20 for the min show width. */ +if good then say 'token' center('input' ,L,'─') center('stack' ,L%2,'─'), + center('output',L,'─') center('action',L ,'─') +pad=left('',5); op=')(-+/*^'; rOp=substr(op,3); stack= + p.=; n=length(op); s.=; RPN= + + do i=1 for n; _=substr(op,i,1); s._=(i+1)%2; p._=s._+(i==n); end /*i*/ + /*[↑] assign operator priorities.*/ + do #=1 for tokens*good; ?=@.# /*process each token from @. list*/ + select /*@.# is: (, operator, ), operand*/ + when ?=='(' then do; stack='(' stack; call show 'moving' ? "──► stack"; end + when isOp(?) then do /*is token an operator?*/ + !=word(stack,1) /*get token from stack.*/ + do while !\==')' & s.!>=p.?; RPN=RPN ! /*add*/ + stack=subword(stack,2); /*del token from stack.*/ + call show 'unstacking:' ! + !=word(stack,1) /*get token from stack.*/ + end /*while ···)*/ + stack=? stack /*add token to stack.*/ + call show 'moving' ? "──► stack" + end + when ?==')' then do; !=word(stack,1) /*get token from stack.*/ + do while !\=='('; RPN=RPN ! /*add to RPN.*/ + stack=subword(stack,2) /*del token from stack.*/ + !=word(stack,1) /*get token from stack.*/ + call show 'moving stack' ! '──► RPN' + end /*while ···( */ + stack=subword(stack,2) /*del token from stack.*/ + call show 'deleting ( from the stack' + end + otherwise RPN=RPN ? /*add operand to RPN. */ + call show 'moving' ? '──► RPN' + end /*select*/ + end /*#*/ + +RPN=space(RPN stack) +if \good then RPN = '─────── error in expression ───────' +say; say ' input:' ox; say ' RPN──►' RPN /*show input and the RPN.*/ +parse source upper . y . /*invoked via C.L. or REXX pgm?*/ +if y=='COMMAND' then exit /*stick a fork in it, we're done.*/ + else return RPN /*return RPN to invoker (RESULT).*/ +/*──────────────────────────────────ISOP subroutine─────────────────────*/ +isOp: return pos(arg(1),rOp)\==0 /*is argument1 a "real" operator?*/ +/*──────────────────────────────────SHOW subroutine─────────────────────*/ +show: if showSteps then say center(?,length(pad)) left(subword(x,#),L), + left(stack,L%2) left(space(RPN),L) arg(1); return diff --git a/Task/Parsing-Shunting-yard-algorithm/Ruby/parsing-shunting-yard-algorithm.rb b/Task/Parsing-Shunting-yard-algorithm/Ruby/parsing-shunting-yard-algorithm.rb new file mode 100644 index 0000000000..011b4c54e9 --- /dev/null +++ b/Task/Parsing-Shunting-yard-algorithm/Ruby/parsing-shunting-yard-algorithm.rb @@ -0,0 +1 @@ +rpn = RPNExpression.from_infix("3 + 4 * 2 / ( 1 - 5 ) ^ 2 ^ 3") diff --git a/Task/Parsing-Shunting-yard-algorithm/Tcl/parsing-shunting-yard-algorithm.tcl b/Task/Parsing-Shunting-yard-algorithm/Tcl/parsing-shunting-yard-algorithm.tcl new file mode 100644 index 0000000000..c308ac744c --- /dev/null +++ b/Task/Parsing-Shunting-yard-algorithm/Tcl/parsing-shunting-yard-algorithm.tcl @@ -0,0 +1,58 @@ +package require Tcl 8.5 + +# Helpers +proc tokenize {str} { + regexp -all -inline {[\d.]+|[-*^+/()]} $str +} +proc precedence op { + dict get {^ 4 * 3 / 3 + 2 - 2} $op +} +proc associativity op { + if {$op eq "^"} {return "right"} else {return "left"} +} + +proc shunting {expression} { + set stack {} + foreach token [tokenize $expression] { + if {[string is double $token]} { + puts "add to output: $token" + lappend output $token + } elseif {$token eq "("} { + puts "push parenthesis" + lappend stack $token + } elseif {$token eq ")"} { + puts "popping to parenthesis" + while {[lindex $stack end] ne "("} { + lappend output [lindex $stack end] + set stack [lreplace $stack end end] + puts "...popped [lindex $output end] to output" + } + set stack [lreplace $stack end end] + puts "...found parenthesis" + } else { + puts "adding operator: $token" + set p [precedence $token] + set a [associativity $token] + while {[llength $stack]} { + set o2 [lindex $stack end] + if { + $o2 ne "(" && + (($a eq "left" && $p <= [precedence $o2]) || + ($a eq "right" && $p < [precedence $o2])) + } then { + puts "...popped operator $o2 to output" + lappend output $o2 + set stack [lreplace $stack end end] + } else { + break + } + } + lappend stack $token + } + puts "\t\tOutput:\t$output\n\t\tStack:\t$stack" + } + puts "transferring tokens from stack to output" + lappend output {*}[lreverse $stack] +} + +puts [shunting "3 + 4 * 2 / ( 1 - 5 ) ^ 2 ^ 3"] diff --git a/Task/Partial-function-application/0DESCRIPTION b/Task/Partial-function-application/0DESCRIPTION new file mode 100644 index 0000000000..802d176e06 --- /dev/null +++ b/Task/Partial-function-application/0DESCRIPTION @@ -0,0 +1,27 @@ +[[wp:Partial application|Partial function application]] is the ability to take a function of many +parameters and apply arguments to some of the parameters to create a new +function that needs only the application of the remaining arguments to +produce the equivalent of applying all arguments to the original function. + +E.g: +: Given values v1, v2 +: Given f(param1, param2) +: Then partial(f, param1=v1) returns f'(param2) +: And f(param1=v1, param2=v2) == f'(param2=v2) (for any value v2) + +Note that in the partial application of a parameter, (in the above case param1), other parameters are not explicitly mentioned. This is a recurring feature of partial function application. + +;Task +* Create a function fs( f, s ) that takes a function, f( n ), of one value and a sequence of values s.
Function fs should return an ordered sequence of the result of applying function f to every value of s in turn. + +* Create function f1 that takes a value and returns it multiplied by 2. +* Create function f2 that takes a value and returns it squared. + +* Partially apply f1 to fs to form function fsf1( s ) +* Partially apply f2 to fs to form function fsf2( s ) + +* Test fsf1 and fsf2 by evaluating them with s being the sequence of integers from 0 to 3 inclusive and then the sequence of even integers from 2 to 8 inclusive. + +;Notes +* In partially applying the functions f1 or f2 to fs, there should be no ''explicit'' mention of any other parameters to fs, although introspection of fs within the partial applicator to find its parameters ''is'' allowed. +* This task is more about ''how'' results are generated rather than just getting results. diff --git a/Task/Partial-function-application/1META.yaml b/Task/Partial-function-application/1META.yaml new file mode 100644 index 0000000000..c78e2d9a80 --- /dev/null +++ b/Task/Partial-function-application/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Programming language concepts diff --git a/Task/Partial-function-application/ALGOL-68/partial-function-application.alg b/Task/Partial-function-application/ALGOL-68/partial-function-application.alg new file mode 100644 index 0000000000..7c1dbf124f --- /dev/null +++ b/Task/Partial-function-application/ALGOL-68/partial-function-application.alg @@ -0,0 +1,27 @@ +MODE SET = FLEX[0]INT; + +MODE F = PROC(INT)INT, + FS = PROC(SET)SET; + +PROC fs = (F f, SET set)SET: ( + [LWB set:UPB set]INT out; + FOR i FROM LWB set TO UPB set DO out[i]:=f(set[i]) OD; + out +); + +PROC f1 = (INT value)INT: value * 2, + f2 = (INT value)INT: value ** 2; + +FS fsf1 = fs(f1,), + fsf2 = fs(f2,); + +[4]INT set; +FORMAT set fmt = $"("n(UPB set-LWB set)(g(0)", ")g(0)")"l$; + +set := (0, 1, 2, 3); + printf((set fmt, fsf1((0, 1, 2, 3)))); # prints (0, 2, 4, 6) # + printf((set fmt, fsf2((0, 1, 2, 3)))); # prints (0, 1, 4, 9) # + +set := (2, 4, 6, 8); + printf((set fmt, fsf1((2, 4, 6, 8)))); # prints (4, 8, 12, 16) # + printf((set fmt, fsf2((2, 4, 6, 8)))) # prints (4, 16, 36, 64) # diff --git a/Task/Partial-function-application/Ada/partial-function-application.ada b/Task/Partial-function-application/Ada/partial-function-application.ada new file mode 100644 index 0000000000..566bef2439 --- /dev/null +++ b/Task/Partial-function-application/Ada/partial-function-application.ada @@ -0,0 +1,50 @@ +with Ada.Text_IO; + +procedure Partial_Function_Application is + + type Sequence is array(Positive range <>) of Integer; + + -- declare a function FS with a generic parameter F and a normal parameter S + generic + with function F(I: Integer) return Integer; -- generic parameter + function FS (S: Sequence) return Sequence; + + -- define FS + function FS (S: Sequence) return Sequence is + Result: Sequence(S'First .. S'Last); + begin + for Idx in S'Range loop + Result(Idx) := F(S(Idx)); + end loop; + return Result; + end FS; + + -- define functions F1 and F2 + function F1(I: Integer) return Integer is + begin + return 2*I; + end F1; + + function F2(I: Integer) return Integer is + begin + return I**2; + end F2; + + -- instantiate the function FS by F1 and F2 (partially apply F1 and F2 to FS) + function FSF1 is new FS(F1); + function FSF2 is new FS(F2); + + procedure Print(S: Sequence) is + begin + for Idx in S'Range loop + Ada.Text_IO.Put(Integer'Image(S(Idx))); + end loop; + Ada.Text_IO.New_Line; + end Print; + +begin + Print(FSF1((0,1,2,3))); + Print(FSF2((0,1,2,3))); + Print(FSF1((2,4,6,8))); + Print(FSF2((2,4,6,8))); +end Partial_Function_Application; diff --git a/Task/Partial-function-application/BBC-BASIC/partial-function-application.bbc b/Task/Partial-function-application/BBC-BASIC/partial-function-application.bbc new file mode 100644 index 0000000000..abda9f1a22 --- /dev/null +++ b/Task/Partial-function-application/BBC-BASIC/partial-function-application.bbc @@ -0,0 +1,39 @@ + fsf1 = FNpartial(PROCfs(), FNf1()) + fsf2 = FNpartial(PROCfs(), FNf2()) + + DIM seq(3) + PRINT "Calling function fsf1 with sequence 1:" + seq() = 0, 1, 2, 3 : PROC(fsf1)(seq()) + FOR i% = 0 TO 3 : PRINT seq(i%); : NEXT : PRINT + PRINT "Calling function fsf1 with sequence 2:" + seq() = 2, 4, 6, 8 : PROC(fsf1)(seq()) + FOR i% = 0 TO 3 : PRINT seq(i%); : NEXT : PRINT + PRINT "Calling function fsf2 with sequence 1:" + seq() = 0, 1, 2, 3 : PROC(fsf2)(seq()) + FOR i% = 0 TO 3 : PRINT seq(i%); : NEXT : PRINT + PRINT "Calling function fsf2 with sequence 2:" + seq() = 2, 4, 6, 8 : PROC(fsf2)(seq()) + FOR i% = 0 TO 3 : PRINT seq(i%); : NEXT : PRINT + END + + REM Create a partial function: + DEF FNpartial(RETURN f1%, RETURN f2%) + LOCAL f$, p% + DIM p% 7 : p%!0 = f1% : p%!4 = f2% + f$ = "(s())" + CHR$&F2 + "(&" + STR$~p% + ")(" + \ + \ CHR$&A4 + "(&" + STR$~(p%+4) + ")(),s()):" + CHR$&E1 + DIM p% LEN(f$) + 4 + $(p%+4) = f$ : !p% = p%+4 + = p% + + REM Replaces the input sequence with the output sequence: + DEF PROCfs(RETURN f%, seq()) + LOCAL i% + FOR i% = 0 TO DIM(seq(),1) + seq(i%) = FN(^f%)(seq(i%)) + NEXT + ENDPROC + + DEF FNf1(n) = n * 2 + + DEF FNf2(n) = n ^ 2 diff --git a/Task/Partial-function-application/C++/partial-function-application.cpp b/Task/Partial-function-application/C++/partial-function-application.cpp new file mode 100644 index 0000000000..80310741b9 --- /dev/null +++ b/Task/Partial-function-application/C++/partial-function-application.cpp @@ -0,0 +1,71 @@ +#include // For declval. +#include +#include +#include +#include + +/* Partial application helper. */ +template< class F, class Arg > +struct PApply +{ + F f; + Arg arg; + + tempalte< class F_, class Arg_ > + PApply( F_&& f, Arg_&& arg ) + : f(std::forward(f)), arg(std::forward(arg)) + { + } + + /* + * The return type of F only gets deduced based on the number of arguments + * supplied. PApply otherwise has no idea whether f takes 1 or 10 args. + */ + template< class ... Args > + auto operator() ( Args&& ...args ) + -> decltype( f(arg,std::declval()...) ) + { + return f( arg, std::forward(args)... ); + } +}; + +template< class F, class Arg > +PApply papply( F&& f, Arg&& arg ) +{ + return PApply( std::forward(f), std::forward(arg) ); +} + +/* Apply f to cont. */ +template< class F > +std::array fs( F&& f, std::array cont ) +{ + std::transform( std::begin(cont), std::end(cont), std::begin(cont), + std::forward(f) ); + return cont; +} + +std::ostream& operator << ( std::ostream& out, const std::array& c ) +{ + std::copy( std::begin(c), std::end(c), + std::ostream_iterator(out, ", ") ); + return out; +} + +int f1( int x ) { return x * 2; } +int f2( int x ) { return x * x; } + +int main() +{ + std::array xs = {{ 0, 1, 2, 3 }}; + std::array ys = {{ 2, 4, 6, 8 }}; + + auto fsf1 = papply( fs, f1 ); + auto fsf2 = papply( fs, f2 ); + + std::cout << "xs:\n" + << "\tfsf1: " << fsf1(xs) << '\n' + << "\tfsf2: " << fsf2(xs) << "\n\n" + << "ys:\n" + << "\tfsf1: " << fsf1(ys) << '\n' + << "\tfsf2: " << fsf2(ys) << '\n'; +} diff --git a/Task/Partial-function-application/C-sharp/partial-function-application.cs b/Task/Partial-function-application/C-sharp/partial-function-application.cs new file mode 100644 index 0000000000..53895e8bd7 --- /dev/null +++ b/Task/Partial-function-application/C-sharp/partial-function-application.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +class PartialFunctionApplication +{ + static Func PartiallyApply(Func function, T2 argument2) + { + return argument1 => function(argument1, argument2); + } + + static void Main() + { + var fs = (Func, Func, IEnumerable>)Enumerable.Select; + var f1 = (Func)(n => n * 2); + var f2 = (Func)(n => n * n); + var fsf1 = PartiallyApply(fs, f1); + var fsf2 = PartiallyApply(fs, f2); + + var s = new[] { 0, 1, 2, 3 }; + Console.WriteLine(string.Join(", ", fsf1(s))); + Console.WriteLine(string.Join(", ", fsf2(s))); + + s = new[] { 2, 4, 6, 8 }; + Console.WriteLine(string.Join(", ", fsf1(s))); + Console.WriteLine(string.Join(", ", fsf2(s))); + } +} diff --git a/Task/Partial-function-application/C/partial-function-application-1.c b/Task/Partial-function-application/C/partial-function-application-1.c new file mode 100644 index 0000000000..749a67d15b --- /dev/null +++ b/Task/Partial-function-application/C/partial-function-application-1.c @@ -0,0 +1,58 @@ +#include +#include +#include +#include +#include +#include + +typedef int (*intfunc)(int); +typedef void (*pfunc)(int*, int); + +pfunc partial(intfunc fin) +{ + pfunc f; + static int idx = 0; + char cc[256], lib[256]; + FILE *fp; + sprintf(lib, "/tmp/stuff%d.so", ++idx); + sprintf(cc, "cc -pipe -x c -shared -o %s -", lib); + + fp = popen(cc, "w"); + fprintf(fp, "#define t typedef\xat int _i,*i;t _i(*__)(_i);__ p =(__)%p;" + "void _(i _1, _i l){while(--l>-1)l[_1]=p(l[_1]);}", fin); + fclose(fp); + + *(void **)(&f) = dlsym(dlopen(lib, RTLD_LAZY), "_"); + unlink(lib); + return f; +} + +int square(int a) +{ + return a * a; +} + +int dbl(int a) +{ + return a + a; +} + +int main() +{ + int x[] = { 1, 2, 3, 4 }; + int y[] = { 1, 2, 3, 4 }; + int i; + + pfunc f = partial(square); + pfunc g = partial(dbl); + + printf("partial square:\n"); + f(x, 4); + for (i = 0; i < 4; i++) printf("%d\n", x[i]); + + printf("partial double:\n"); + g(y, 4); + for (i = 0; i < 4; i++) printf("%d\n", y[i]); + + return 0; +} diff --git a/Task/Partial-function-application/C/partial-function-application-2.c b/Task/Partial-function-application/C/partial-function-application-2.c new file mode 100644 index 0000000000..6680bd379b --- /dev/null +++ b/Task/Partial-function-application/C/partial-function-application-2.c @@ -0,0 +1,10 @@ +partial square: +1 +4 +9 +16 +partial double: +2 +4 +6 +8 diff --git a/Task/Partial-function-application/Clojure/partial-function-application.clj b/Task/Partial-function-application/Clojure/partial-function-application.clj new file mode 100644 index 0000000000..c685e2c700 --- /dev/null +++ b/Task/Partial-function-application/Clojure/partial-function-application.clj @@ -0,0 +1,10 @@ +(defn fs [f s] (map f s)) +(defn f1 [x] (* 2 x)) +(defn f2 [x] (* x x)) +(def fsf1 (partial fs f1)) +(def fsf2 (partial fs f2)) + +(doseq [s [(range 4) (range 2 9 2)]] + (println "seq: " s) + (println " fsf1: " (fsf1 s)) + (println " fsf2: " (fsf2 s))) diff --git a/Task/Partial-function-application/CoffeeScript/partial-function-application-1.coffeescript b/Task/Partial-function-application/CoffeeScript/partial-function-application-1.coffeescript new file mode 100644 index 0000000000..f0bf38bd91 --- /dev/null +++ b/Task/Partial-function-application/CoffeeScript/partial-function-application-1.coffeescript @@ -0,0 +1,13 @@ +partial = (f, g) -> + (s) -> f(g, s) + +fs = (f, s) -> (f(a) for a in s) +f1 = (a) -> a * 2 +f2 = (a) -> a * a +fsf1 = partial(fs, f1) +fsf2 = partial(fs, f2) + +do -> + for seq in [[0..3], [2,4,6,8]] + console.log fsf1 seq + console.log fsf2 seq diff --git a/Task/Partial-function-application/CoffeeScript/partial-function-application-2.coffeescript b/Task/Partial-function-application/CoffeeScript/partial-function-application-2.coffeescript new file mode 100644 index 0000000000..c9756f1637 --- /dev/null +++ b/Task/Partial-function-application/CoffeeScript/partial-function-application-2.coffeescript @@ -0,0 +1,5 @@ +> coffee partials.coffee +[ 0, 2, 4, 6 ] +[ 0, 1, 4, 9 ] +[ 4, 8, 12, 16 ] +[ 4, 16, 36, 64 ] diff --git a/Task/Partial-function-application/Common-Lisp/partial-function-application.lisp b/Task/Partial-function-application/Common-Lisp/partial-function-application.lisp new file mode 100644 index 0000000000..2a7119565d --- /dev/null +++ b/Task/Partial-function-application/Common-Lisp/partial-function-application.lisp @@ -0,0 +1,12 @@ +(defun fs (f s) (mapcar f s)) +(defun f1 (i) (* i 2)) +(defun f2 (i) (expt i 2)) + +(defun partial (func &rest args1) + (lambda (&rest args2) (apply func (append args1 args2)))) +(defvar fsf1 (partial #'fs #'f1)) +(defvar fsf2 (partial #'fs #'f2)) + +(dolist (seq '((0 1 2 3) (2 4 6 8))) + (format t "~%seq: ~A~% fsf1 seq: ~A~% fsf2 seq: ~A" + seq (funcall fsf1 seq) (funcall fsf2 seq))) diff --git a/Task/Partial-function-application/D/partial-function-application.d b/Task/Partial-function-application/D/partial-function-application.d new file mode 100644 index 0000000000..070630bc38 --- /dev/null +++ b/Task/Partial-function-application/D/partial-function-application.d @@ -0,0 +1,19 @@ +import std.stdio, std.algorithm, std.traits; + +auto fs(alias f)(in int[] s) /*pure nothrow*/ +if (isCallable!f && ParameterTypeTuple!f.length == 1) { + return map!f(s); +} + +int f1(in int x) pure nothrow { return x * 2; } +int f2(in int x) pure nothrow { return x ^^ 2; } + +alias fs!f1 fsf1; +alias fs!f2 fsf2; + +void main() { + foreach (d; [[0, 1, 2, 3], [2, 4, 6, 8]]) { + writeln(fsf1(d)); + writeln(fsf2(d)); + } +} diff --git a/Task/Partial-function-application/E/partial-function-application.e b/Task/Partial-function-application/E/partial-function-application.e new file mode 100644 index 0000000000..109d4a5865 --- /dev/null +++ b/Task/Partial-function-application/E/partial-function-application.e @@ -0,0 +1,26 @@ +def pa(f, args1) { + return def partial { + match [`run`, args2] { + E.call(f, "run", args1 + args2) + } + } +} + +def fs(f, s) { + var r := [] + for n in s { + r with= f(n) + } + return r +} + +def f1(n) { return n * 2 } +def f2(n) { return n ** 2 } + +def fsf1 := pa(fs, [f1]) +def fsf2 := pa(fs, [f2]) +for s in [0..3, [2, 4, 6, 8]] { + for f in [fsf1, fsf2] { + println(f(s)) + } +} diff --git a/Task/Partial-function-application/Haskell/partial-function-application.hs b/Task/Partial-function-application/Haskell/partial-function-application.hs new file mode 100644 index 0000000000..86750e6cf1 --- /dev/null +++ b/Task/Partial-function-application/Haskell/partial-function-application.hs @@ -0,0 +1,13 @@ +fs f s = map f s +f1 value = value * 2 +f2 value = value ^ 2 + +fsf1 = fs f1 +fsf2 = fs f2 + +main :: IO () +main = do + print $ fsf1 [0, 1, 2, 3] -- prints [0, 2, 4, 6] + print $ fsf2 [0, 1, 2, 3] -- prints [0, 1, 4, 9] + print $ fsf1 [2, 4, 6, 8] -- prints [4, 8, 12, 16] + print $ fsf2 [2, 4, 6, 8] -- prints [4, 16, 36, 64] diff --git a/Task/Partial-function-application/Icon/partial-function-application.icon b/Task/Partial-function-application/Icon/partial-function-application.icon new file mode 100644 index 0000000000..52699b5320 --- /dev/null +++ b/Task/Partial-function-application/Icon/partial-function-application.icon @@ -0,0 +1,39 @@ +link printf + +procedure main() + fsf1 := partial(fs,f1) + fsf2 := partial(fs,f2) + every s := [ 0, 1, 2, 3 ] | + [ 2, 4, 6, 8 ] do { + printf("\ns := %s\n",list2string(s)) + printf("fsf1(s) := %s\n",list2string(fsf1(s))) + printf("fsf2(s) := %s\n",list2string(fsf2(s))) + } +end + +procedure partial(f,g) #: partial application of f & g + @( p := create repeat { + s := (r@&source)[1] # return r / get argument s + r := f(g,s) # apply f(g,...) + } + ) # create and activate procedure p + return p +end + +procedure fs(f,s) #: return list where f is applied to each element of s + every put(r := [], f(!s)) + return r +end + +procedure f1(n) # double + return n * 2 +end + +procedure f2(n) #: square + return n ^ 2 +end + +procedure list2string(L) #: format list as a string + every (s := "[ ") ||:= !L || " " + return s || "]" +end diff --git a/Task/Partial-function-application/J/partial-function-application-1.j b/Task/Partial-function-application/J/partial-function-application-1.j new file mode 100644 index 0000000000..48d04ef79c --- /dev/null +++ b/Task/Partial-function-application/J/partial-function-application-1.j @@ -0,0 +1,5 @@ +fs=:1 :'u"0 y' +f1=:*&2 +f2=:^&2 +fsf1=:f1 fs +fsf2=:f2 fs diff --git a/Task/Partial-function-application/J/partial-function-application-2.j b/Task/Partial-function-application/J/partial-function-application-2.j new file mode 100644 index 0000000000..3f4ed36e5f --- /dev/null +++ b/Task/Partial-function-application/J/partial-function-application-2.j @@ -0,0 +1,8 @@ + fsf1 i.4 +0 2 4 6 + fsf2 i.4 +0 1 4 9 + fsf1 fsf1 1+i.4 +4 8 12 16 + fsf2 fsf1 1+i.4 +4 16 36 64 diff --git a/Task/Partial-function-application/J/partial-function-application-3.j b/Task/Partial-function-application/J/partial-function-application-3.j new file mode 100644 index 0000000000..4731d2907a --- /dev/null +++ b/Task/Partial-function-application/J/partial-function-application-3.j @@ -0,0 +1,8 @@ + f1 i.4 +0 2 4 6 + f2 i.4 +0 1 4 9 + f1 1+i.4 +2 4 6 8 + f2 f1 1+i.4 +4 16 36 64 diff --git a/Task/Partial-function-application/J/partial-function-application-4.j b/Task/Partial-function-application/J/partial-function-application-4.j new file mode 100644 index 0000000000..ff1cb96499 --- /dev/null +++ b/Task/Partial-function-application/J/partial-function-application-4.j @@ -0,0 +1,9 @@ +crippled=:1 :0 + assert.1=#y + u y +) + +F1=: f1 crippled +F2=: f2 crippled +fsF1=: F1 fs +fsF2=: F2 fs diff --git a/Task/Partial-function-application/J/partial-function-application-5.j b/Task/Partial-function-application/J/partial-function-application-5.j new file mode 100644 index 0000000000..31c7159dd9 --- /dev/null +++ b/Task/Partial-function-application/J/partial-function-application-5.j @@ -0,0 +1,6 @@ + F1 i.4 +|assertion failure: F1 +| 1=#y + fsF1 i.4 +0 2 4 6 +NB. and so on... diff --git a/Task/Partial-function-application/Java/partial-function-application-1.java b/Task/Partial-function-application/Java/partial-function-application-1.java new file mode 100644 index 0000000000..0142747381 --- /dev/null +++ b/Task/Partial-function-application/Java/partial-function-application-1.java @@ -0,0 +1,63 @@ +import java.util.Arrays; + +public class PartialApplication { + interface IntegerFunction { + int call(int arg); + } + + // Original method fs(f, s). + static int[] fs(IntegerFunction f, int[] s) { + int[] r = new int[s.length]; + for (int i = 0; i < s.length; i++) + r[i] = f.call(s[i]); + return r; + } + + interface SequenceFunction { + int[] call(int[] arg); + } + + // Curried method fs(f).call(s), + // necessary for partial application. + static SequenceFunction fs(final IntegerFunction f) { + return new SequenceFunction() { + public int[] call(int[] s) { + // Call original method. + return fs(f, s); + } + }; + } + + static IntegerFunction f1 = new IntegerFunction() { + public int call(int i) { + return i * 2; + } + }; + + static IntegerFunction f2 = new IntegerFunction() { + public int call(int i) { + return i * i; + } + }; + + static SequenceFunction fsf1 = fs(f1); // Partial application. + + static SequenceFunction fsf2 = fs(f2); + + public static void main(String[] args) { + int[][] sequences = { + { 0, 1, 2, 3 }, + { 2, 4, 6, 8 }, + }; + + for (int[] array : sequences) { + System.out.printf( + "array: %s\n" + + " fsf1(array): %s\n" + + " fsf2(array): %s\n", + Arrays.toString(array), + Arrays.toString(fsf1.call(array)), + Arrays.toString(fsf2.call(array))); + } + } +} diff --git a/Task/Partial-function-application/Java/partial-function-application-2.java b/Task/Partial-function-application/Java/partial-function-application-2.java new file mode 100644 index 0000000000..866f24121e --- /dev/null +++ b/Task/Partial-function-application/Java/partial-function-application-2.java @@ -0,0 +1,43 @@ +import java.util.Arrays; +import java.util.function.Function; + +public class PartialApplication { + // Original method fs(f, s). + static Integer[] fs(Function f, Integer[] s) { + Integer[] r = new Integer[s.length]; + for (int i = 0; i < s.length; i++) + r[i] = f.apply(s[i]); + return r; + } + + // Curried method fs(f).apply(s), + // necessary for partial application. + static Function fs(Function f) { + return s -> fs(f, s); + } + + static Function f1 = i -> i * 2; + + static Function f2 = i -> i * i; + + static Function fsf1 = fs(f1); // Partial application. + + static Function fsf2 = fs(f2); + + public static void main(String[] args) { + Integer[][] sequences = { + { 0, 1, 2, 3 }, + { 2, 4, 6, 8 }, + }; + + for (Integer[] array : sequences) { + System.out.printf( + "array: %s\n" + + " fsf1(array): %s\n" + + " fsf2(array): %s\n", + Arrays.toString(array), + Arrays.toString(fsf1.apply(array)), + Arrays.toString(fsf2.apply(array))); + } + } +} diff --git a/Task/Partial-function-application/Mathematica/partial-function-application.math b/Task/Partial-function-application/Mathematica/partial-function-application.math new file mode 100644 index 0000000000..58d52ab9bc --- /dev/null +++ b/Task/Partial-function-application/Mathematica/partial-function-application.math @@ -0,0 +1,5 @@ +fs[f_, s_] := Map[f, s] +f1 [n_] := n*2 +f2 [n_] := n^2 +fsf1[s_] := fs[f1, s] +fsf2[s_] := fs[f2, s] diff --git a/Task/Partial-function-application/Mercury/partial-function-application.mercury b/Task/Partial-function-application/Mercury/partial-function-application.mercury new file mode 100644 index 0000000000..da0ba30fdd --- /dev/null +++ b/Task/Partial-function-application/Mercury/partial-function-application.mercury @@ -0,0 +1,36 @@ +:- module partial_function_application. +:- interface. + +:- import_module io. + +:- pred main(io::di, io::uo) is det. + +:- implementation. +:- import_module int, list. + +main(!IO) :- + io.write((fsf1)([0, 1, 2, 3]), !IO), io.nl(!IO), + io.write((fsf2)([0, 1, 2, 3]), !IO), io.nl(!IO), + io.write((fsf1)([2, 4, 6, 8]), !IO), io.nl(!IO), + io.write((fsf2)([2, 4, 6, 8]), !IO), io.nl(!IO). + +:- func fs(func(V) = V, list(V)) = list(V). + +fs(_, []) = []. +fs(F, [V | Vs]) = [F(V) | fs(F, Vs)]. + +:- func f1(int) = int. + +f1(V) = V * 2. + +:- func f2(int) = int. + +f2(V) = V * V. + +:- func fsf1 = (func(list(int)) = list(int)). + +fsf1 = fs(f1). + +:- func fsf2 = (func(list(int)) = list(int)). + +fsf2 = fs(f2). diff --git a/Task/Partial-function-application/Nemerle/partial-function-application.nemerle b/Task/Partial-function-application/Nemerle/partial-function-application.nemerle new file mode 100644 index 0000000000..3d6a027cc1 --- /dev/null +++ b/Task/Partial-function-application/Nemerle/partial-function-application.nemerle @@ -0,0 +1,45 @@ +using System; +using System.Console; + +module Partial +{ + fs[T] (f : T -> T, s : list[T]) : list[T] + { + $[f(x)| x in s] + } + + f1 (x : int) : int + { + x * 2 + } + + f2 (x : int) : int + { + x * x + } + + curry[T, U, V] (f : T * U -> V, x : T) : U -> V + { + f(x, _) + } + + // curryr() isn't actually used in this task, I just include it for symmetry + curryr[T, U, V] (f : T * U -> V, x : U) : T -> V + { + f(_, x) + } + + Main() : void + { + def fsf1 = curry(fs, f1); + def fsf2 = curry(fs, f2); + def test1 = $[0 .. 3]; + def test2 = $[x | x in [2 .. 8], x % 2 == 0]; + + WriteLine (fsf1(test1)); + WriteLine (fsf1(test2)); + WriteLine (fsf2(test1)); + WriteLine (fsf2(test2)); + + } +} diff --git a/Task/Partial-function-application/OCaml/partial-function-application.ocaml b/Task/Partial-function-application/OCaml/partial-function-application.ocaml new file mode 100644 index 0000000000..fce64c4ba9 --- /dev/null +++ b/Task/Partial-function-application/OCaml/partial-function-application.ocaml @@ -0,0 +1,22 @@ +# +let fs f s = List.map f s +let f1 value = value * 2 +let f2 value = value * value + +let fsf1 = fs f1 +let fsf2 = fs f2 +;; +val fs : ('a -> 'b) -> 'a list -> 'b list = +val f1 : int -> int = +val f2 : int -> int = +val fsf1 : int list -> int list = +val fsf2 : int list -> int list = + +# fsf1 [0; 1; 2; 3];; +- : int list = [0; 2; 4; 6] +# fsf2 [0; 1; 2; 3];; +- : int list = [0; 1; 4; 9] +# fsf1 [2; 4; 6; 8];; +- : int list = [4; 8; 12; 16] +# fsf2 [2; 4; 6; 8];; +- : int list = [4; 16; 36; 64] diff --git a/Task/Partial-function-application/Order/partial-function-application.order b/Task/Partial-function-application/Order/partial-function-application.order new file mode 100644 index 0000000000..a04906c00a --- /dev/null +++ b/Task/Partial-function-application/Order/partial-function-application.order @@ -0,0 +1,16 @@ +#include + +#define ORDER_PP_DEF_8fs ORDER_PP_FN( 8fn(8F, 8S, 8seq_map(8F, 8S)) ) + +#define ORDER_PP_DEF_8f1 ORDER_PP_FN( 8fn(8V, 8times(8V, 2)) ) + +#define ORDER_PP_DEF_8f2 ORDER_PP_FN( 8fn(8V, 8times(8V, 8V)) ) + +ORDER_PP( + 8let((8F, 8fs(8f1)) + (8G, 8fs(8f2)), + 8do( + 8print(8ap(8F, 8seq(0, 1, 2, 3)) 8comma 8space), + 8print(8ap(8G, 8seq(0, 1, 2, 3)) 8comma 8space), + 8print(8ap(8F, 8seq(2, 4, 6, 8)) 8comma 8space), + 8print(8ap(8G, 8seq(2, 4, 6, 8))))) ) diff --git a/Task/Partial-function-application/Perl-6/partial-function-application.pl6 b/Task/Partial-function-application/Perl-6/partial-function-application.pl6 new file mode 100644 index 0000000000..542d72f1b9 --- /dev/null +++ b/Task/Partial-function-application/Perl-6/partial-function-application.pl6 @@ -0,0 +1,11 @@ +sub fs ( Code $f, @s ) { @s.map: { .$f } } + +sub f1 ( $n ) { $n * 2 } +sub f2 ( $n ) { $n ** 2 } + +my &fsf1 := &fs.assuming: f => &f1; +my &fsf2 := &fs.assuming: f => &f2; + +for [1..3], [2, *+2 ... 8] X &fsf1, &fsf2 -> $s, $f { + say ~ $f.($s); +} diff --git a/Task/Partial-function-application/Perl/partial-function-application.pl b/Task/Partial-function-application/Perl/partial-function-application.pl new file mode 100644 index 0000000000..f3149df990 --- /dev/null +++ b/Task/Partial-function-application/Perl/partial-function-application.pl @@ -0,0 +1,18 @@ +sub fs(&) { + my $func = shift; + sub { map $func->($_), @_ } +} + +sub double($) { shift() * 2 } +sub square($) { shift() ** 2 } + +my $fs_double = fs(\&double); +my $fs_square = fs(\&square); + +my @s = 0 .. 3; +print "fs_double(@s): @{[ $fs_double->(@s) ]}\n"; +print "fs_square(@s): @{[ $fs_square->(@s) ]}\n"; + +@s = (2, 4, 6, 8); +print "fs_double(@s): @{[ $fs_double->(@s) ]}\n"; +print "fs_square(@s): @{[ $fs_square->(@s) ]}\n"; diff --git a/Task/Partial-function-application/PicoLisp/partial-function-application.l b/Task/Partial-function-application/PicoLisp/partial-function-application.l new file mode 100644 index 0000000000..9a9cf7fd73 --- /dev/null +++ b/Task/Partial-function-application/PicoLisp/partial-function-application.l @@ -0,0 +1,14 @@ +(def 'fs mapcar) +(de f1 (N) (* 2 N)) +(de f2 (N) (* N N)) + +(de partial (F1 F2) + (curry (F1 F2) @ + (pass F1 F2) ) ) + +(def 'fsf1 (partial fs f1)) +(def 'fsf2 (partial fs f2)) + +(for S '((0 1 2 3) (2 4 6 8)) + (println (fsf1 S)) + (println (fsf2 S)) ) diff --git a/Task/Partial-function-application/Prolog/partial-function-application.pro b/Task/Partial-function-application/Prolog/partial-function-application.pro new file mode 100644 index 0000000000..9a892628e4 --- /dev/null +++ b/Task/Partial-function-application/Prolog/partial-function-application.pro @@ -0,0 +1,25 @@ +fs(P, S, S1) :- + maplist(P, S, S1). + +f1(X, Y) :- + Y is 2 * X. + +f2(X, Y) :- + Y is X * X. + +create_partial(P, fs(P)). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +fs :- + % partial functions + create_partial(f1, FSF1), + create_partial(f2, FSF2), + + S1 = [0,1,2,3], + call(FSF1,S1, S11), format('~w : ~w ==> ~w~n',[FSF1, S1, S11]), + call(FSF1,S1, S12), format('~w : ~w ==> ~w~n',[FSF2, S1, S12]), + + S2 = [2,4,6,8], + call(FSF1,S2, S21), format('~w : ~w ==> ~w~n',[FSF2, S2, S21]), + call(FSF2,S2, S22), format('~w : ~w ==> ~w~n',[FSF1, S2, S22]). diff --git a/Task/Partial-function-application/Python/partial-function-application-1.py b/Task/Partial-function-application/Python/partial-function-application-1.py new file mode 100644 index 0000000000..c6c051384f --- /dev/null +++ b/Task/Partial-function-application/Python/partial-function-application-1.py @@ -0,0 +1,18 @@ +from functools import partial + +def fs(f, s): return [f(value) for value in s] + +def f1(value): return value * 2 + +def f2(value): return value ** 2 + +fsf1 = partial(fs, f1) +fsf2 = partial(fs, f2) + +s = [0, 1, 2, 3] +assert fs(f1, s) == fsf1(s) # == [0, 2, 4, 6] +assert fs(f2, s) == fsf2(s) # == [0, 1, 4, 9] + +s = [2, 4, 6, 8] +assert fs(f1, s) == fsf1(s) # == [4, 8, 12, 16] +assert fs(f2, s) == fsf2(s) # == [4, 16, 36, 64] diff --git a/Task/Partial-function-application/Python/partial-function-application-2.py b/Task/Partial-function-application/Python/partial-function-application-2.py new file mode 100644 index 0000000000..c4a429fa32 --- /dev/null +++ b/Task/Partial-function-application/Python/partial-function-application-2.py @@ -0,0 +1,13 @@ +def partial(f, g): + def fg(*x): return f(g, *x) + return fg + +def fs(f, *x): return [ f(a) for a in x] +def f1(a): return a * 2 +def f2(a): return a * a + +fsf1 = partial(fs, f1) +fsf2 = partial(fs, f2) + +print fsf1(1, 2, 3, 4) +print fsf2(1, 2, 3, 4) diff --git a/Task/Partial-function-application/R/partial-function-application.r b/Task/Partial-function-application/R/partial-function-application.r new file mode 100644 index 0000000000..37b2800cac --- /dev/null +++ b/Task/Partial-function-application/R/partial-function-application.r @@ -0,0 +1,18 @@ +partially.apply <- function(f, ...) { + capture <- list(...) + function(...) { + do.call(f, c(capture, list(...))) + } +} + +fs <- function(f, ...) sapply(list(...), f) +f1 <- function(x) 2*x +f2 <- function(x) x^2 + +fsf1 <- partially.apply(fs, f1) +fsf2 <- partially.apply(fs, f2) + +fsf1(0:3) +fsf2(0:3) +fsf1(seq(2,8,2)) +fsf2(seq(2,8,2)) diff --git a/Task/Partial-function-application/Racket/partial-function-application.rkt b/Task/Partial-function-application/Racket/partial-function-application.rkt new file mode 100644 index 0000000000..73f3a6b259 --- /dev/null +++ b/Task/Partial-function-application/Racket/partial-function-application.rkt @@ -0,0 +1,13 @@ +#lang racket + +(define (fs f s) (map f s)) +(define (f1 n) (* n 2)) +(define (f2 n) (* n n)) + +(define fsf1 (curry fs f1)) +(define fsf2 (curry fs f2)) + +(fsf1 '(0 1 2 3)) +(fsf1 '(2 4 6 8)) +(fsf2 '(0 1 2 3)) +(fsf2 '(2 4 6 8)) diff --git a/Task/Partial-function-application/Ruby/partial-function-application.rb b/Task/Partial-function-application/Ruby/partial-function-application.rb new file mode 100644 index 0000000000..16a8cf0e7c --- /dev/null +++ b/Task/Partial-function-application/Ruby/partial-function-application.rb @@ -0,0 +1,10 @@ +fs = proc { |f, s| s.map &f } +f1 = proc { |n| n * 2 } +f2 = proc { |n| n ** 2 } +fsf1 = fs.curry[f1] +fsf2 = fs.curry[f2] + +[0..3, (2..8).step(2)].each do |e| + p fsf1[e] + p fsf2[e] +end diff --git a/Task/Partial-function-application/Scala/partial-function-application.scala b/Task/Partial-function-application/Scala/partial-function-application.scala new file mode 100644 index 0000000000..9cbb2d66d6 --- /dev/null +++ b/Task/Partial-function-application/Scala/partial-function-application.scala @@ -0,0 +1,11 @@ +def fs(f:Int=>Int, s:List[Int])=s map f +def f1(x:Int)=x*2 +def f2(x:Int)=x*x + +def fsf1=fs(f1,_:List[Int]) +def fsf2=fs(f2,_:List[Int]) + +println(fsf1(List(0,1,2,3))) +println(fsf1(List(2,4,6,8))) +println(fsf2(List(0,1,2,3))) +println(fsf2(List(2,4,6,8))) diff --git a/Task/Partial-function-application/Smalltalk/partial-function-application.st b/Task/Partial-function-application/Smalltalk/partial-function-application.st new file mode 100644 index 0000000000..678d9927eb --- /dev/null +++ b/Task/Partial-function-application/Smalltalk/partial-function-application.st @@ -0,0 +1,19 @@ +| f1 f2 fs fsf1 fsf2 partial | + +partial := [ :afs :af | [ :s | afs value: af value: s ] ]. + +fs := [ :f :s | s collect: [ :x | f value: x ]]. +f1 := [ :x | x * 2 ]. +f2:= [ :x | x * x ]. +fsf1 := partial value: fs value: f1. +fsf2 := partial value: fs value: f2. + +fsf1 value: (0 to: 3). +" #(0 2 4 6)" +fsf2 value: (0 to: 3). +" #(0 1 4 9)" + +fsf1 value: #(2 4 6 8). +" #(4 8 12 16)" +fsf2 value: #(2 4 6 8). +" #(4 16 36 64)" diff --git a/Task/Partial-function-application/Tcl/partial-function-application-1.tcl b/Task/Partial-function-application/Tcl/partial-function-application-1.tcl new file mode 100644 index 0000000000..f632894af8 --- /dev/null +++ b/Task/Partial-function-application/Tcl/partial-function-application-1.tcl @@ -0,0 +1,9 @@ +package require Tcl 8.6 +proc partial {f1 f2} { + variable ctr + coroutine __curry[incr ctr] apply {{f1 f2} { + for {set x [info coroutine]} 1 {} { + set x [{*}$f1 $f2 [yield $x]] + } + }} $f1 $f2 +} diff --git a/Task/Partial-function-application/Tcl/partial-function-application-2.tcl b/Task/Partial-function-application/Tcl/partial-function-application-2.tcl new file mode 100644 index 0000000000..25b70199d1 --- /dev/null +++ b/Task/Partial-function-application/Tcl/partial-function-application-2.tcl @@ -0,0 +1,15 @@ +proc fs {f s} { + set r {} + foreach n $s { + lappend r [{*}$f $n] + } + return $r +} +proc f1 x {expr {$x * 2}} +proc f2 x {expr {$x ** 2}} +set fsf1 [partial fs f1] +set fsf2 [partial fs f2] +foreach s {{0 1 2 3} {2 4 6 8}} { + puts "$s ==f1==> [$fsf1 $s]" + puts "$s ==f2==> [$fsf2 $s]" +} diff --git a/Task/Pascals-triangle-Puzzle/0DESCRIPTION b/Task/Pascals-triangle-Puzzle/0DESCRIPTION new file mode 100644 index 0000000000..f139af2c12 --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/0DESCRIPTION @@ -0,0 +1,12 @@ +This puzzle involves a [http://xunor.free.fr/en/riddles/auto/pyramidnb.php Pascals Triangle], also known as a [http://xunor.free.fr/en/riddles/auto/pyramidnb.php Pyramid of Numbers]. +
+           [ 151]
+          [  ][  ]
+        [40][  ][  ]
+      [  ][  ][  ][  ]
+    [ X][11][ Y][ 4][ Z]
+
+Each brick of the pyramid is the sum of the two bricks situated below it.
+Of the three missing numbers at the base of the pyramid, the middle one is the sum of the other two (that is, Y = X + Z). + +Write a program to find a solution to this puzzle. diff --git a/Task/Pascals-triangle-Puzzle/ALGOL-68/pascals-triangle-puzzle.alg b/Task/Pascals-triangle-Puzzle/ALGOL-68/pascals-triangle-puzzle.alg new file mode 100644 index 0000000000..59b7da5f05 --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/ALGOL-68/pascals-triangle-puzzle.alg @@ -0,0 +1,96 @@ +MODE + FIELD = REAL, + VEC = [0]REAL, + MAT = [0,0]REAL; +MODE BRICK = UNION(INT, CHAR); + +FLEX[][]BRICK puzzle = ( + ( 151), + ( " ", " "), + ( 40, " ", " "), + ( " ", " ", " ", " "), + ( "x", 11, "y", 4, "z") +); + +PROC mat col = (INT row, col)INT: row*(row-1)OVER 2 + col; +INT col x = mat col(5,1), + col y = mat col(5,3), + col z = mat col(5,5); + +OP INIT = (REF VEC vec)VOID: FOR elem FROM LWB vec TO UPB vec DO vec[elem]:=0 OD; +OP INIT = (REF MAT mat)VOID: FOR row FROM LWB mat TO UPB mat DO INIT mat[row,] OD; + +OP / = (MAT a, MAT b)MAT:( # matrix division # + [LWB b:UPB b]INT p ; + INT sign; + [,]FIELD lu = lu decomp(b, p, sign); + [LWB a:UPB a, 1 LWB a:2 UPB a]FIELD out; + FOR col FROM 2 LWB a TO 2 UPB a DO out[,col] := lu solve(b, lu, p, a[,col]) OD; + out +); + +OP / = (VEC a, MAT b)VEC: ( # vector division # + [LWB a:UPB a,1]FIELD transpose a; + transpose a[,1]:=a; + (transpose a/b)[,LWB a] +); + +INT upb mat = mat col(UPB puzzle, UPB puzzle); +[upb mat, upb mat] REAL mat; INIT mat; +[upb mat] REAL vec; INIT vec; + +INT mat row := LWB mat; +INT known row := UPB mat - UPB puzzle + 1; + +# build the simultaneous equation to solve # +FOR row FROM LWB puzzle TO UPB puzzle DO + FOR col FROM LWB puzzle[row] TO UPB puzzle[row] DO + IF row < UPB puzzle THEN + mat[mat row, mat col(row, col)] := 1; + mat[mat row, mat col(row+1, col)] := -1; + mat[mat row, mat col(row+1, col+1)] := -1; + mat row +:= 1 + FI; + CASE puzzle[row][col] IN + (INT value):( + mat[known row, mat col(row, col)] := 1; + vec[known row] := value; + known row +:= 1 + ), + (CHAR variable):SKIP + ESAC + OD +OD; + +# finally add x - y + z = 0 # +mat[known row, col x] := 1; +mat[known row, col y] := -1; +mat[known row, col z] := 1; + +FORMAT real repr = $g(-5,2)$; + +CO # print details of the simultaneous equation being solved # +FORMAT + vec repr = $"("n(2 UPB mat-1)(f(real repr)", ")f(real repr)")"$, + mat repr = $"("n(1 UPB mat-1)(f(vec repr)", "lx)f(vec repr)")"$; + +printf(($"Vec: "l$,vec repr, vec, $l$)); +printf(($"Mat: "l$,mat repr, mat, $l$)); +END CO + +# finally actually solve the equation # +VEC solution vec = vec/mat; + +# and wrap up by printing the solution # +FLEX[UPB puzzle]FLEX[0]REAL solution; +FOR row FROM LWB puzzle TO UPB puzzle DO + solution[row] := LOC[row]REAL; + FOR col FROM LWB puzzle[row] TO UPB puzzle[row] DO + solution[row][col] := solution vec[mat col(row, col)] + OD; + printf(($n(UPB puzzle-row)(4x)$, $x"("f(real repr)")"$, solution[row], $l$)) +OD; + +FOR var FROM 1 BY 2 TO 5 DO + printf(($5x$,$g$,puzzle[UPB puzzle][var],"=", real repr, solution[UPB puzzle][var])) +OD diff --git a/Task/Pascals-triangle-Puzzle/Ada/pascals-triangle-puzzle.ada b/Task/Pascals-triangle-Puzzle/Ada/pascals-triangle-puzzle.ada new file mode 100644 index 0000000000..a4c02c1163 --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/Ada/pascals-triangle-puzzle.ada @@ -0,0 +1,69 @@ +with Ada.Text_IO; use Ada.Text_IO; + +procedure Pyramid_of_Numbers is + + B_X, B_Y, B_Z : Integer := 0; -- Unknown variables + + type Block_Value is record + Known : Integer := 0; + X, Y, Z : Integer := 0; + end record; + X : constant Block_Value := (0, 1, 0, 0); + Y : constant Block_Value := (0, 0, 1, 0); + Z : constant Block_Value := (0, 0, 0, 1); + procedure Add (L : in out Block_Value; R : Block_Value) is + begin -- Symbolically adds one block to another + L.Known := L.Known + R.Known; + L.X := L.X + R.X - R.Z; -- Z is excluded as n(Y - X - Z) = 0 + L.Y := L.Y + R.Y + R.Z; + end Add; + procedure Add (L : in out Block_Value; R : Integer) is + begin -- Symbolically adds a value to the block + L.Known := L.Known + R; + end Add; + + function Image (N : Block_Value) return String is + begin -- The block value, when X,Y,Z are known + return Integer'Image (N.Known + N.X * B_X + N.Y * B_Y + N.Z * B_Z); + end Image; + + procedure Solve_2x2 (A11, A12, B1, A21, A22, B2 : Integer) is + begin -- Don't care about things, supposing an integer solution exists + if A22 = 0 then + B_X := B2 / A21; + B_Y := (B1 - A11*B_X) / A12; + else + B_X := (B1*A22 - B2*A12) / (A11*A22 - A21*A12); + B_Y := (B1 - A11*B_X) / A12; + end if; + B_Z := B_Y - B_X; + end Solve_2x2; + + B : array (1..5, 1..5) of Block_Value; -- The lower triangle contains blocks + +begin + -- The bottom blocks + Add (B(5,1),X); Add (B(5,2),11); Add (B(5,3),Y); Add (B(5,4),4); Add (B(5,5),Z); + + -- Upward run + for Row in reverse 1..4 loop + for Column in 1..Row loop + Add (B (Row, Column), B (Row + 1, Column)); + Add (B (Row, Column), B (Row + 1, Column + 1)); + end loop; + end loop; + + -- Now have known blocks 40=(3,1), 151=(1,1) and Y=X+Z to determine X,Y,Z + Solve_2x2 + ( B(1,1).X, B(1,1).Y, 151 - B(1,1).Known, + B(3,1).X, B(3,1).Y, 40 - B(3,1).Known + ); + + -- Print the results + for Row in 1..5 loop + New_Line; + for Column in 1..Row loop + Put (Image (B(Row,Column))); + end loop; + end loop; +end Pyramid_of_Numbers; diff --git a/Task/Pascals-triangle-Puzzle/AutoHotkey/pascals-triangle-puzzle-1.ahk b/Task/Pascals-triangle-Puzzle/AutoHotkey/pascals-triangle-puzzle-1.ahk new file mode 100644 index 0000000000..5331577fc8 --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/AutoHotkey/pascals-triangle-puzzle-1.ahk @@ -0,0 +1,4 @@ +N1 := 11, N2 := 4, N3 := 40, N4 := 151 +Z := (2*N4 - 7*N3 - 8*N2 + 6*N1) / 7 +X := (N3 - 2*N1 - Z) / 2 +MsgBox,, Pascal's Triangle, %X%`n%Z% diff --git a/Task/Pascals-triangle-Puzzle/AutoHotkey/pascals-triangle-puzzle-2.ahk b/Task/Pascals-triangle-Puzzle/AutoHotkey/pascals-triangle-puzzle-2.ahk new file mode 100644 index 0000000000..c02a175040 --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/AutoHotkey/pascals-triangle-puzzle-2.ahk @@ -0,0 +1,274 @@ +;--------------------------------------------------------------------------- +; Pascal's triangle.ahk +; by wolf_II +;--------------------------------------------------------------------------- +; http://rosettacode.org/wiki/Pascal's_triangle/Puzzle +;--------------------------------------------------------------------------- + + + +;--------------------------------------------------------------------------- +AutoExecute: ; auto-execute section of the script +;--------------------------------------------------------------------------- + #SingleInstance, Force ; only one instance allowed + #NoEnv ; don't check empty variables + ;----------------------------------------------------------------------- + AppName := "Pascal's triangle" + N1 := 11, N2 := 4, N3 := 40, N4 := 151 + + ; monitor MouseMove events + OnMessage(0x0200, "WM_MOUSEMOVE") + + ; GUI + Gosub, GuiCreate + Gui, Show,, %AppName% + +Return + + + +;--------------------------------------------------------------------------- +GuiCreate: ; create the GUI +;--------------------------------------------------------------------------- + Gui, -MinimizeBox + Gui, Margin, 8, 8 + + ; 15 edit controls + Loop, 5 + Loop, % Row := A_Index { + xx := 208 + (A_Index - 5) * 50 - (Row - 5) * 25 + yy := 8 + (Row - 1) * 22 + vv := Row "_" A_Index + Gui, Add, Edit, x%xx% y%yy% w50 v%vv% Center ReadOnly -TabStop + } + GuiControl, -WantReturn, Edit11 + GuiControl, -WantReturn, Edit15 + + ; buttons (2 hidden) + Gui, Add, Button, x8 w78, &Restart + Gui, Add, Button, x+8 wp, &Solve + Gui, Add, Button, x+8 wp, &Check + Gui, Add, Button, x8 wp, Cle&ar + Gui, Add, Button, xp wp Hidden, &Cancel + Gui, Add, Button, x+8 wp, &New + Gui, Add, Button, xp wp Hidden, &Apply + Gui, Add, Button, x+8 wp, E&xit + + ; status bar + Gui, Add, StatusBar + + ; blue font + Gui, Font, bold cBlue + GuiControl, Font, Edit11 + GuiControl, Font, Edit15 + ; falling through + +;--------------------------------------------------------------------------- +ButtonRestart: ; restart retaining the blue clues +;--------------------------------------------------------------------------- + Controls(True) ; enable controls + Loop, 15 + If A_Index Not In 1,4,11,12,14,15 + GuiControl,, Edit%A_Index% ; clear + GuiControl,, Edit1, %N4% + GuiControl,, Edit4, %N3% + GuiControl,, Edit12, %N1% + GuiControl,, Edit14, %N2% + GuiControl,, Edit11, %X% + GuiControl,, Edit15, %Z% + GreenFont: + Gui, Font, bold cGreen + GuiControl, Font, Edit1 + GuiControl, Font, Edit4 + GuiControl, Font, Edit12 + GuiControl, Font, Edit14 + +Return + + + +;--------------------------------------------------------------------------- +ButtonSolve: ; calculate solution +;--------------------------------------------------------------------------- + ; N1 := 11 N2 := 4 N3 := 40 N4 := 151 + ;----------------------------------------------------------------------- + ; Y = X + Z + ; 40 = (11+X) + (11+Y) + ; A = (11+Y) + (Y+4) + ; B = (4+Y) + (4+Z) + ; 151 = (40+A) + (A+B) + ;----------------------------------------------------------------------- + Gosub, GreenFont + GuiControl,, Edit15, % Z := Round( (2*N4 - 7*N3 - 8*N2 + 6*N1) / 7 ) + GuiControl,, Edit11, % X := Round( (N3 - 2*N1 - Z) / 2 ) + ; falling through + +;--------------------------------------------------------------------------- +ButtonCheck: ; check the [entry|solution] for errors +;--------------------------------------------------------------------------- + Controls(False) ; disable controls + Gui, Submit, NoHide + X := 5_1, Z := 5_5 + Loop, 5 + Loop, % Row := A_Index + If (%Row%_%A_Index% = "") + %Row%_%A_Index% := 0 + GuiControl,, Edit13, % 5_3 := 5_1 + 5_5 + GuiControl,, Edit10, % 4_4 := 5_4 + 5_5 + GuiControl,, Edit9, % 4_3 := 5_3 + 5_4 + GuiControl,, Edit8, % 4_2 := 5_2 + 5_3 + GuiControl,, Edit7, % 4_1 := 5_1 + 5_2 + GuiControl,, Edit6, % 3_3 := 4_4 + 4_3 + GuiControl,, Edit5, % 3_2 := 4_3 + 4_2 + GuiControl,, Edit4, % 3_1 := 4_2 + 4_1 + GuiControl,, Edit3, % 2_2 := 3_3 + 3_2 + GuiControl,, Edit2, % 2_1 := 3_2 + 3_1 + GuiControl,, Edit1, % 1_1 := 2_2 + 2_1 + Gui, Font, bold cRed + If Not 3_1 = N3 + GuiControl, Font, Edit4 + If Not 1_1 = N4 + GuiControl, Font, Edit1 + +Return + + + +;--------------------------------------------------------------------------- +ButtonClear: ; restart without the blue clues +;--------------------------------------------------------------------------- + X := Z := "" + Gosub, ButtonRestart + +Return + + + +;--------------------------------------------------------------------------- +ButtonNew: ; enter new numbers for the puzzle +;--------------------------------------------------------------------------- + Gosub, GreenFont + Loop, 15 + If A_Index Not In 1,4,12,14 + GuiControl,, Edit%A_Index% ; clear + Controls(False) ; disable controls + NewContr(True) ; enable controls for new numbers + +Return + + + +;--------------------------------------------------------------------------- +ButtonApply: ; remember the new numbers +;--------------------------------------------------------------------------- + Gui, Submit, NoHide + N1 := 5_2, N2 := 5_4, N3 := 3_1, N4 := 1_1 + NewContr(False) ; disable controls for new numbers + Controls(True) ; enable controls + +Return + + + +;--------------------------------------------------------------------------- +ButtonCancel: ; restore the old numbers +;--------------------------------------------------------------------------- + GuiControl,, Edit1, %N4% + GuiControl,, Edit4, %N3% + GuiControl,, Edit12, %N1% + GuiControl,, Edit14, %N2% + NewContr(False) ; disable controls for new numbers + Controls(True) ; enable controls + +Return + + + +;--------------------------------------------------------------------------- +GuiClose: +;--------------------------------------------------------------------------- +GuiEscape: +;--------------------------------------------------------------------------- +ButtonExit: +;--------------------------------------------------------------------------- + ; common action + ExitApp + +Return + + + +;--------------------------------------------------------------------------- +Controls(Bool) { ; [dis|re-en]able some controls +;--------------------------------------------------------------------------- + Enable := Bool ? "+" : "-" + Disable := Bool ? "-" : "+" + + GuiControl, %Disable%ReadOnly, Edit11 + GuiControl, %Disable%ReadOnly, Edit15 + GuiControl, %Enable%TabStop, Edit11 + GuiControl, %Enable%TabStop, Edit15 + + GuiControl, %Disable%Default, &Restart + GuiControl, %Enable%Default, &Check + GuiControl, %Disable%Disabled, &Check + GuiControl, %Enable%Disabled, &Restart +} + + + +;--------------------------------------------------------------------------- +NewContr(Bool) { ; [dis|re-en]able control for new numbers +;--------------------------------------------------------------------------- + Enable := Bool ? "+" : "-" + Disable := Bool ? "-" : "+" + + GuiControl, %Disable%ReadOnly, Edit1 + GuiControl, %Disable%ReadOnly, Edit4 + GuiControl, %Disable%ReadOnly, Edit12 + GuiControl, %Disable%ReadOnly, Edit14 + + GuiControl, %Enable%TabStop, Edit1 + GuiControl, %Enable%TabStop, Edit4 + GuiControl, %Enable%TabStop, Edit12 + GuiControl, %Enable%TabStop, Edit14 + + GuiControl, %Enable%Hidden, Button1 + GuiControl, %Enable%Hidden, Button2 + GuiControl, %Enable%Hidden, Button3 + GuiControl, %Enable%Hidden, Button4 + GuiControl, %Disable%Hidden, Button5 + GuiControl, %Enable%Hidden, Button6 + GuiControl, %Disable%Hidden, Button7 + GuiControl, %Enable%Hidden, Button8 + +} + + + +;--------------------------------------------------------------------------- +WM_MOUSEMOVE() { ; monitor MouseMove events +;--------------------------------------------------------------------------- + ; display quick help in StatusBar + ;----------------------------------------------------------------------- + global AppName + CurrControl := A_GuiControl + IfEqual True,, MsgBox ; dummy + + ; mouse is over buttons + Else If (CurrControl = "&Restart") + SB_SetText("restart retaining the blue clues") + Else If (CurrControl = "&Solve") + SB_SetText("calculate solution") + Else If (CurrControl = "&Check") + SB_SetText("check if the entries are correct") + Else If (CurrControl = "Cle&ar") + SB_SetText("restart without the blue clues") + Else If (CurrControl = "&New") + SB_SetText("enter new numbers for the puzzle") + Else If (CurrControl = "E&xit") + SB_SetText("exit " AppName) + + ; delete status bar text + Else SB_SetText("") +} diff --git a/Task/Pascals-triangle-Puzzle/BBC-BASIC/pascals-triangle-puzzle.bbc b/Task/Pascals-triangle-Puzzle/BBC-BASIC/pascals-triangle-puzzle.bbc new file mode 100644 index 0000000000..11ede1f53d --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/BBC-BASIC/pascals-triangle-puzzle.bbc @@ -0,0 +1,39 @@ + INSTALL @lib$ + "ARRAYLIB" + + REM Describe the puzzle as a set of simultaneous equations: + REM a + b = 151 + REM a - c = 40 + REM -b + c + d = 0 + REM e + f = 40 + REM -c + f + g = 0 + REM -d + g + h = 0 + REM e - x = 11 + REM f - y = 11 + REM g - y = 4 + REM h - z = 4 + REM x - y + z = 0 + REM So we have 11 equations in 11 unknowns. + + REM We can represent these equations as a matrix and a vector: + DIM matrix(10,10), vector(10) + matrix() = \ a, b, c, d, e, f, g, h, x, y, z + \ 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + \ 1, 0,-1, 0, 0, 0, 0, 0, 0, 0, 0, \ + \ 0,-1, 1, 1, 0, 0, 0, 0, 0, 0, 0, \ + \ 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, \ + \ 0, 0,-1, 0, 0, 1, 1, 0, 0, 0, 0, \ + \ 0, 0, 0,-1, 0, 0, 1, 1, 0, 0, 0, \ + \ 0, 0, 0, 0, 1, 0, 0, 0,-1, 0, 0, \ + \ 0, 0, 0, 0, 0, 1, 0, 0, 0,-1, 0, \ + \ 0, 0, 0, 0, 0, 0, 1, 0, 0,-1, 0, \ + \ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,-1, \ + \ 0, 0, 0, 0, 0, 0, 0, 0, 1,-1, 1 + vector() = 151, 40, 0, 40, 0, 0, 11, 11, 4, 4, 0 + + REM Now solve the simultaneous equations: + PROC_invert(matrix()) + vector() = matrix().vector() + + PRINT "X = " ; vector(8) + PRINT "Y = " ; vector(9) + PRINT "Z = " ; vector(10) diff --git a/Task/Pascals-triangle-Puzzle/C/pascals-triangle-puzzle-1.c b/Task/Pascals-triangle-Puzzle/C/pascals-triangle-puzzle-1.c new file mode 100644 index 0000000000..82d0e59f7c --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/C/pascals-triangle-puzzle-1.c @@ -0,0 +1,39 @@ +/* Pascal's pyramid solver + * + * [top] + * [ ] [ ] + * [mid] [ ] [ ] + * [ ] [ ] [ ] [ ] + * [ x ] [ a ] [ y ] [ b ] [ z ] + * x + z = y + * + * This solution makes use of a little bit of mathematical observation, + * such as the fact that top = 4(a+b) + 7(x+z) and mid = 2x + 2a + z. + */ + +#include +#include + +void pascal(int a, int b, int mid, int top, int* x, int* y, int* z) +{ + double ytemp = (top - 4 * (a + b)) / 7.; + if(fmod(ytemp, 1.) >= 0.0001) + { + x = 0; + return; + } + *y = ytemp; + *x = mid - 2 * a - *y; + *z = *y - *x; +} +int main() +{ + int a = 11, b = 4, mid = 40, top = 151; + int x, y, z; + pascal(a, b, mid, top, &x, &y, &z); + if(x != 0) + printf("x: %d, y: %d, z: %d\n", x, y, z); + else printf("No solution\n"); + + return 0; +} diff --git a/Task/Pascals-triangle-Puzzle/C/pascals-triangle-puzzle-2.c b/Task/Pascals-triangle-Puzzle/C/pascals-triangle-puzzle-2.c new file mode 100644 index 0000000000..e62b2d48bb --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/C/pascals-triangle-puzzle-2.c @@ -0,0 +1,73 @@ +#include +#include + +void show(int *x) { + int i, j; + + for (i = 0; i < 5; i++) + for (j = 0; j <= i; j++) + printf("%4d%c", *(x++), j < i ? ' ' : '\n'); +} + +inline int sign(int i) +{ + return i < 0 ? -1 : i > 0; +} + +int iter(int *v, int *diff) { + int sum, i, j, e = 0; + +# define E(x, row, col) x[(row) * ((row) + 1) / 2 + (col)] + /* enforce boundary conditions */ + E(v, 0, 0) = 151; + E(v, 2, 0) = 40; + E(v, 4, 1) = 11; + E(v, 4, 3) = 4; + + /* calculate difference from equilibrium */ + for (i = 1; i < 5; i++) { + for (j = 0; j <= i; j++) { + E(diff, i, j) = 0; + if (j < i) + E(diff, i, j) += E(v, i - 1, j) - + E(v, i, j + 1) - + E(v, i, j); + if (j) + E(diff, i, j) += E(v, i - 1, j - 1) - + E(v, i, j - 1) - + E(v, i, j); + } + } + + for (i = 0; i < 4; i++) + for (j = 0; j < i; j++) + E(diff, i, j) += E(v, i + 1, j) + + E(v, i + 1, j + 1) - + E(v, i, j); + + E(diff, 4, 2) += E(v, 4, 0) + E(v, 4, 4) - E(v, 4, 2); +# undef E + + /* Do feedback, check if we are done. */ + for (i = sum = 0; i < 15; i++) { + sum += !!sign(e = diff[i]); + + /* 1/5-ish feedback strength on average. These numbers are highly + magical, depending on nodes' connectivities. */ + if (e >= 4 || e <= -4) v[i] += e/5; + else if (rand() < RAND_MAX/4) v[i] += sign(e); + } + return sum; +} + +int main() { + int v[15] = { 0 }, diff[15] = { 0 }, i, s; + + for (i = s = 1; s; i++) { + s = iter(v, diff); + printf("pass %d: %d\n", i, s); + } + show(v); + + return 0; +} diff --git a/Task/Pascals-triangle-Puzzle/C/pascals-triangle-puzzle-3.c b/Task/Pascals-triangle-Puzzle/C/pascals-triangle-puzzle-3.c new file mode 100644 index 0000000000..bf9df70b5a --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/C/pascals-triangle-puzzle-3.c @@ -0,0 +1,13 @@ +pass 1: 12 +pass 2: 12 +pass 3: 14 +pass 4: 14 +... +pass 113: 4 +pass 114: 7 +pass 115: 0 + 151 + 81 70 + 40 41 29 + 16 24 17 12 + 5 11 13 4 8 diff --git a/Task/Pascals-triangle-Puzzle/Clojure/pascals-triangle-puzzle-1.clj b/Task/Pascals-triangle-Puzzle/Clojure/pascals-triangle-puzzle-1.clj new file mode 100644 index 0000000000..256e465e52 --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/Clojure/pascals-triangle-puzzle-1.clj @@ -0,0 +1,9 @@ +(def bottom [ [0 1 0], [11 0 0], [0 1 1], [4 0 0], [0 0 1] ]) + +(defn plus [v1 v2] (vec (map + v1 v2))) +(defn minus [v1 v2] (vec (map - v1 v2))) +(defn scale [n v] (vec (map #(* n %) v ))) + +(defn above [row] (map #(apply plus %) (partition 2 1 row))) + +(def rows (reverse (take 5 (iterate above bottom)))) diff --git a/Task/Pascals-triangle-Puzzle/Clojure/pascals-triangle-puzzle-2.clj b/Task/Pascals-triangle-Puzzle/Clojure/pascals-triangle-puzzle-2.clj new file mode 100644 index 0000000000..f24ece3266 --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/Clojure/pascals-triangle-puzzle-2.clj @@ -0,0 +1,5 @@ +(def c00 (get-in rows [0 0])) +(def c20 (get-in rows [2 0])) + +(def eqn0 (minus c00 [151 0 0])) +(def eqn1 (minus c20 [ 40 0 0])) diff --git a/Task/Pascals-triangle-Puzzle/Clojure/pascals-triangle-puzzle-3.clj b/Task/Pascals-triangle-Puzzle/Clojure/pascals-triangle-puzzle-3.clj new file mode 100644 index 0000000000..0f4cb6d4fb --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/Clojure/pascals-triangle-puzzle-3.clj @@ -0,0 +1,11 @@ +(defn solve [m] + (assert (<= 1 m 2)) + (let [n (- 3 m) + v0 (scale (eqn1 n) eqn0) + v1 (scale (eqn0 n) eqn1) + vd (minus v0 v1)] + (assert (zero? (vd n))) + (/ (- (vd 0)) (vd m)))) + +(let [x (solve 1), z (solve 2), y (+ x z)] + (println "x =" x ", y =" y ", z =" z)) diff --git a/Task/Pascals-triangle-Puzzle/Clojure/pascals-triangle-puzzle-4.clj b/Task/Pascals-triangle-Puzzle/Clojure/pascals-triangle-puzzle-4.clj new file mode 100644 index 0000000000..c67d476b56 --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/Clojure/pascals-triangle-puzzle-4.clj @@ -0,0 +1,5 @@ +(defn dot [v1 v2] (reduce + (map * v1 v2))) + +(defn show-pyramid [x z] + (doseq [row rows] + (println (map #(dot [1 x z] %) row))) diff --git a/Task/Pascals-triangle-Puzzle/D/pascals-triangle-puzzle.d b/Task/Pascals-triangle-Puzzle/D/pascals-triangle-puzzle.d new file mode 100644 index 0000000000..a8accd613c --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/D/pascals-triangle-puzzle.d @@ -0,0 +1,69 @@ +import std.stdio, std.algorithm; + +void iterate(bool doPrint=true)(double[] v, double[] diff) { + static ref T E(T)(T[] x, in size_t row, in size_t col) + pure nothrow { + return x[row * (row + 1) / 2 + col]; + } + + double sum = 0.0; + do { + // enforce boundary conditions + E(v, 0, 0) = 151; + E(v, 2, 0) = 40; + E(v, 4, 1) = 11; + E(v, 4, 3) = 4; + + // calculate difference from equilibrium + foreach (i; 1 .. 5) { + foreach (j; 0 .. i + 1) { + E(diff, i, j) = 0; + if (j < i) + E(diff, i, j) += E(v, i - 1, j) - + E(v, i, j + 1) - + E(v, i, j); + if (j) + E(diff, i, j) += E(v, i - 1, j - 1) - + E(v, i, j - 1) - + E(v, i, j); + } + } + + foreach (i; 1 .. 4) + foreach (j; 0 .. i) + E(diff, i, j) += E(v, i + 1, j) + + E(v, i + 1, j + 1) - + E(v, i, j); + + E(diff, 4, 2) += E(v, 4, 0) + E(v, 4, 4) - E(v, 4, 2); + + // do feedback, check if we are close enough + // 4: scale down the feedback to avoid oscillations + v[] += diff[] / 4; + sum = reduce!q{a + b ^^ 2}(0.0, diff); + + static if (doPrint) + writeln("dev: ", sum); + + // sum(dx^2) < 0.1 means each cell is no more than 0.5 away + // from equilibrium. It takes about 50 iterations. After + // 700 iterations sum is < 1e-25, but that's overkill. + } while (sum >= 0.1); +} + +void main() { + static void show(in double[] x) { + int idx; + foreach (i; 0 .. 5) + foreach (j; 0 .. i+1) { + printf("%4d%c", cast(int)(0.5 + x[idx]), + j < i ? ' ' : '\n'); + idx++; + } + } + + double[15] v = 0.0; + double[15] diff = 0.0; + iterate(v, diff); + show(v); +} diff --git a/Task/Pascals-triangle-Puzzle/Go/pascals-triangle-puzzle.go b/Task/Pascals-triangle-Puzzle/Go/pascals-triangle-puzzle.go new file mode 100644 index 0000000000..da2f00c1ce --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/Go/pascals-triangle-puzzle.go @@ -0,0 +1,134 @@ +package main + +import "fmt" + +// representation of an expression in x, y, and z +type expr struct { + x, y, z float64 // coefficients + c float64 // constant term +} + +// add two expressions +func addExpr(a, b expr) expr { + return expr{a.x + b.x, a.y + b.y, a.z + b.z, a.c + b.c} +} + +// subtract two expressions +func subExpr(a, b expr) expr { + return expr{a.x - b.x, a.y - b.y, a.z - b.z, a.c - b.c} +} + +// multiply expression by a constant +func mulExpr(a expr, c float64) expr { + return expr{a.x * c, a.y * c, a.z * c, a.c * c} +} + +// given a row of expressions, produce the next row up, by the given +// sum relation between blocks +func addRow(l []expr) []expr { + if len(l) == 0 { + panic("wrong") + } + r := make([]expr, len(l)-1) + for i := range r { + r[i] = addExpr(l[i], l[i+1]) + } + return r +} + +// given expression b in a variable, and expression a, +// take b == 0 and substitute to remove that variable from a. +func substX(a, b expr) expr { + if b.x == 0 { + panic("wrong") + } + return subExpr(a, mulExpr(b, a.x/b.x)) +} + +func substY(a, b expr) expr { + if b.y == 0 { + panic("wrong") + } + return subExpr(a, mulExpr(b, a.y/b.y)) +} + +func substZ(a, b expr) expr { + if b.z == 0 { + panic("wrong") + } + return subExpr(a, mulExpr(b, a.z/b.z)) +} + +// given an expression in a single variable, return value of that variable +func solveX(a expr) float64 { + if a.x == 0 || a.y != 0 || a.z != 0 { + panic("wrong") + } + return -a.c / a.x +} + +func solveY(a expr) float64 { + if a.x != 0 || a.y == 0 || a.z != 0 { + panic("wrong") + } + return -a.c / a.y +} + +func solveZ(a expr) float64 { + if a.x != 0 || a.y != 0 || a.z == 0 { + panic("wrong") + } + return -a.c / a.z +} + +func main() { + // representation of given information for bottom row + r5 := []expr{{x: 1}, {c: 11}, {y: 1}, {c: 4}, {z: 1}} + fmt.Println("bottom row:", r5) + + // given definition of brick sum relation + r4 := addRow(r5) + fmt.Println("next row up:", r4) + r3 := addRow(r4) + fmt.Println("middle row:", r3) + + // given relation y = x + z + xyz := subExpr(expr{y: 1}, expr{x: 1, z: 1}) + fmt.Println("xyz relation:", xyz) + // remove z from third cell using xyz relation + r3[2] = substZ(r3[2], xyz) + fmt.Println("middle row after substituting for z:", r3) + + // given cell = 40, + b := expr{c: 40} + // this gives an xy relation + xy := subExpr(r3[0], b) + fmt.Println("xy relation:", xy) + // substitute 40 for cell + r3[0] = b + + // remove x from third cell using xy relation + r3[2] = substX(r3[2], xy) + fmt.Println("middle row after substituting for x:", r3) + + // continue applying brick sum relation to get top cell + r2 := addRow(r3) + fmt.Println("next row up:", r2) + r1 := addRow(r2) + fmt.Println("top row:", r1) + + // given top cell = 151, we have an equation in y + y := subExpr(r1[0], expr{c: 151}) + fmt.Println("y relation:", y) + // using xy relation, we get an equation in x + x := substY(xy, y) + fmt.Println("x relation:", x) + // using xyz relation, we get an equation in z + z := substX(substY(xyz, y), x) + fmt.Println("z relation:", z) + + // show final answers + fmt.Println("x =", solveX(x)) + fmt.Println("y =", solveY(y)) + fmt.Println("z =", solveZ(z)) +} diff --git a/Task/Pascals-triangle-Puzzle/Haskell/pascals-triangle-puzzle-1.hs b/Task/Pascals-triangle-Puzzle/Haskell/pascals-triangle-puzzle-1.hs new file mode 100644 index 0000000000..e3959a1d4b --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/Haskell/pascals-triangle-puzzle-1.hs @@ -0,0 +1 @@ +puzzle = [["151"],["",""],["40","",""],["","","",""],["X","11","Y","4","Z"]] diff --git a/Task/Pascals-triangle-Puzzle/Haskell/pascals-triangle-puzzle-2.hs b/Task/Pascals-triangle-Puzzle/Haskell/pascals-triangle-puzzle-2.hs new file mode 100644 index 0000000000..f5d4b3ab0c --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/Haskell/pascals-triangle-puzzle-2.hs @@ -0,0 +1,29 @@ +triangle n = n * (n+1) `div` 2 + +coeff xys x = maybe 0 id $ lookup x xys + +row n cs = [coeff cs k | k <- [1..n]] + +eqXYZ n = [(0, 1:(-1):1:replicate n 0)] + +eqPyramid n h = do + a <- [1..h-1] + x <- [triangle (a-1) + 1 .. triangle a] + let y = x+a + return $ (0, 0:0:0:row n [(x,-1),(y,1),(y+1,1)]) + +eqConst n fields = do + (k,s) <- zip [1..] fields + guard $ not $ null s + return $ case s of + "X" - (0, 1:0:0:row n [(k,-1)]) + "Y" - (0, 0:1:0:row n [(k,-1)]) + "Z" - (0, 0:0:1:row n [(k,-1)]) + _ - (fromInteger $ read s, 0:0:0:row n [(k,1)]) + +equations :: [[String]] - ([Rational], [[Rational]]) +equations puzzle = unzip eqs where + fields = concat puzzle + eqs = eqXYZ n ++ eqPyramid n h ++ eqConst n fields + h = length puzzle + n = length fields diff --git a/Task/Pascals-triangle-Puzzle/Haskell/pascals-triangle-puzzle-3.hs b/Task/Pascals-triangle-Puzzle/Haskell/pascals-triangle-puzzle-3.hs new file mode 100644 index 0000000000..2e8b8f8bd2 --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/Haskell/pascals-triangle-puzzle-3.hs @@ -0,0 +1,10 @@ +normalize :: [Rational] - [Integer] +normalize xs = [numerator (x * v) | x <- xs] where + v = fromInteger $ foldr1 lcm $ map denominator $ xs + +run puzzle = map (normalize . drop 3) $ answer where + (a, m) = equations puzzle + lr = decompose 0 m + answer = case solve 0 lr a of + Nothing - [] + Just x - x : kernel lr diff --git a/Task/Pascals-triangle-Puzzle/Haskell/pascals-triangle-puzzle-4.hs b/Task/Pascals-triangle-Puzzle/Haskell/pascals-triangle-puzzle-4.hs new file mode 100644 index 0000000000..10b196f155 --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/Haskell/pascals-triangle-puzzle-4.hs @@ -0,0 +1,4 @@ +*Main run puzzle +[[151,81,70,40,41,29,16,24,17,12,5,11,13,4,8]] +*Main run [[""],["2",""],["X","Y","Z"]] +[[3,2,1,1,1,0],[3,0,3,-1,1,2]] diff --git a/Task/Pascals-triangle-Puzzle/J/pascals-triangle-puzzle-1.j b/Task/Pascals-triangle-Puzzle/J/pascals-triangle-puzzle-1.j new file mode 100644 index 0000000000..22cd8b6b11 --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/J/pascals-triangle-puzzle-1.j @@ -0,0 +1 @@ +chk=:40 151&-:@(2 4{{."1) diff --git a/Task/Pascals-triangle-Puzzle/J/pascals-triangle-puzzle-2.j b/Task/Pascals-triangle-Puzzle/J/pascals-triangle-puzzle-2.j new file mode 100644 index 0000000000..24e1621fcc --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/J/pascals-triangle-puzzle-2.j @@ -0,0 +1 @@ +base=: [,11,+,4,] diff --git a/Task/Pascals-triangle-Puzzle/J/pascals-triangle-puzzle-3.j b/Task/Pascals-triangle-Puzzle/J/pascals-triangle-puzzle-3.j new file mode 100644 index 0000000000..c198ab2515 --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/J/pascals-triangle-puzzle-3.j @@ -0,0 +1 @@ +ord=:5 diff --git a/Task/Pascals-triangle-Puzzle/J/pascals-triangle-puzzle-4.j b/Task/Pascals-triangle-Puzzle/J/pascals-triangle-puzzle-4.j new file mode 100644 index 0000000000..f21f1df3d4 --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/J/pascals-triangle-puzzle-4.j @@ -0,0 +1 @@ + |."2(#~chk"2) 2(+/\)^:(,{ ;~i:28 diff --git a/Task/Pascals-triangle-Puzzle/J/pascals-triangle-puzzle-5.j b/Task/Pascals-triangle-Puzzle/J/pascals-triangle-puzzle-5.j new file mode 100644 index 0000000000..b1f1843453 --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/J/pascals-triangle-puzzle-5.j @@ -0,0 +1 @@ +,.(1+i.5)<@{."0 1{.|."2(#~chk"2) 2(+/\)^:(,{ ;~i:28 diff --git a/Task/Pascals-triangle-Puzzle/J/pascals-triangle-puzzle-6.j b/Task/Pascals-triangle-Puzzle/J/pascals-triangle-puzzle-6.j new file mode 100644 index 0000000000..530265f6b8 --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/J/pascals-triangle-puzzle-6.j @@ -0,0 +1 @@ +,.(<@{."0 1~1+i.@#){.|."2(#~chk"2) 2(+/\)^:(,{ ;~i:28 diff --git a/Task/Pascals-triangle-Puzzle/Mathematica/pascals-triangle-puzzle-1.math b/Task/Pascals-triangle-Puzzle/Mathematica/pascals-triangle-puzzle-1.math new file mode 100644 index 0000000000..2c842899cf --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/Mathematica/pascals-triangle-puzzle-1.math @@ -0,0 +1,11 @@ +b+c==a +d+e==b +e+f==c +g+h==d +h+i==e +i+j==f +l+X==g +l+Y==h +n+Y==i +n+Z==j +X+Z==Y diff --git a/Task/Pascals-triangle-Puzzle/Mathematica/pascals-triangle-puzzle-2.math b/Task/Pascals-triangle-Puzzle/Mathematica/pascals-triangle-puzzle-2.math new file mode 100644 index 0000000000..bbeacc576b --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/Mathematica/pascals-triangle-puzzle-2.math @@ -0,0 +1,4 @@ +a->151 +d->40 +l->11 +n->4 diff --git a/Task/Pascals-triangle-Puzzle/Mathematica/pascals-triangle-puzzle-3.math b/Task/Pascals-triangle-Puzzle/Mathematica/pascals-triangle-puzzle-3.math new file mode 100644 index 0000000000..11ae174692 --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/Mathematica/pascals-triangle-puzzle-3.math @@ -0,0 +1,3 @@ +eqs={a==b+c,d+e==b,e+f==c,g+h==d,h+i==e,i+j==f,l+X==g,l+Y==h,n+Y==i,n+Z==j,Y==X+Z}; +knowns={a->151,d->40,l->11,n->4}; +Solve[eqs/.knowns,{b,c,e,f,g,h,i,j,X,Y,Z}] diff --git a/Task/Pascals-triangle-Puzzle/Mathematica/pascals-triangle-puzzle-4.math b/Task/Pascals-triangle-Puzzle/Mathematica/pascals-triangle-puzzle-4.math new file mode 100644 index 0000000000..38a2f91b01 --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/Mathematica/pascals-triangle-puzzle-4.math @@ -0,0 +1 @@ +{{b -> 81, c -> 70, e -> 41, f -> 29, g -> 16, h -> 24, i -> 17, j -> 12, X -> 5, Y -> 13, Z -> 8}} diff --git a/Task/Pascals-triangle-Puzzle/Mathematica/pascals-triangle-puzzle-5.math b/Task/Pascals-triangle-Puzzle/Mathematica/pascals-triangle-puzzle-5.math new file mode 100644 index 0000000000..ef08543c17 --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/Mathematica/pascals-triangle-puzzle-5.math @@ -0,0 +1,5 @@ + 151 + 81 70 + 40 41 29 + 16 24 17 12 +5 11 13 4 8 diff --git a/Task/Pascals-triangle-Puzzle/Oz/pascals-triangle-puzzle.oz b/Task/Pascals-triangle-Puzzle/Oz/pascals-triangle-puzzle.oz new file mode 100644 index 0000000000..139b0c727b --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/Oz/pascals-triangle-puzzle.oz @@ -0,0 +1,69 @@ +%% to compile : ozc -x +functor + +import + System Application FD Search +define + + proc{Quest Root Rules} + + proc{Limit Rc Ls} + case Ls of nil then skip + [] X|Xs then + {Limit Rc Xs} + case X of N#V then + Rc.N =: V + [] N1#N2#N3 then + Rc.N1 =: Rc.N2 + Rc.N3 + end + end + end + + proc {Pyramid R} + {FD.tuple solution 15 0#FD.sup R} %% non-negative integers domain + %% 01 , pyramid format + %% 02 03 + %% 04 05 06 + %% 07 08 09 10 + %% 11 12 13 14 15 + R.1 =: R.2 + R.3 %% constraints of Pyramid of numbers + R.2 =: R.4 + R.5 + R.3 =: R.5 + R.6 + R.4 =: R.7 + R.8 + R.5 =: R.8 + R.9 + R.6 =: R.9 + R.10 + R.7 =: R.11 + R.12 + R.8 =: R.12 + R.13 + R.9 =: R.13 + R.14 + R.10 =: R.14 + R.15 + + {Limit R Rules} %% additional constraints + + {FD.distribute ff R} + end + in + {Search.base.one Pyramid Root} %% search for solution + end + + local + Root R + in + {Quest Root [1#151 4#40 12#11 14#4 13#11#15]} %% supply additional constraint rules + if {Length Root} >= 1 then + R = Root.1 + {For 1 15 1 + proc{$ I} + if {Member I [1 3 6 10]} then + {System.printInfo R.I#'\n'} + else + {System.printInfo R.I#' '} + end + end + } + else + {System.showInfo 'No solution found.'} + end + end + + {Application.exit 0} +end diff --git a/Task/Pascals-triangle-Puzzle/PARI-GP/pascals-triangle-puzzle.pari b/Task/Pascals-triangle-Puzzle/PARI-GP/pascals-triangle-puzzle.pari new file mode 100644 index 0000000000..87e6c1b38e --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/PARI-GP/pascals-triangle-puzzle.pari @@ -0,0 +1,5 @@ +Pascals_triangle_puzzle(topvalue=151,leftsidevalue=40,bottomvalue1=11,bottomvalue2=4) = { +y=(topvalue-(4*(bottomvalue1+bottomvalue2)))/7; +x=leftsidevalue-(y+2*bottomvalue1); +z=y-x; +print(x","y","z); } diff --git a/Task/Pascals-triangle-Puzzle/PicoLisp/pascals-triangle-puzzle.l b/Task/Pascals-triangle-Puzzle/PicoLisp/pascals-triangle-puzzle.l new file mode 100644 index 0000000000..59edc8419d --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/PicoLisp/pascals-triangle-puzzle.l @@ -0,0 +1,43 @@ +(be number (@N @Max) + (@C box 0) + (repeat) + (or + ((@ >= (val (-> @C)) (-> @Max)) T (fail)) + ((@N inc (-> @C))) ) ) + +(be + (@A @B @Sum) + (@ -> @A) + (@ -> @B) + (@Sum + (-> @A) (-> @B)) ) + +(be + (@A @B @Sum) + (@ -> @A) + (@ -> @Sum) + (@B - (-> @Sum) (-> @A)) + T + (@ ge0 (-> @B)) ) + +(be + (@A @B @Sum) + (number @A @Sum) + (@B - (-> @Sum) (-> @A)) ) + +#{ + 151 + A B + 40 C D + E F G H + X 11 Y 4 Z +}# + +(be puzzle (@X @Y @Z) + (+ @A @B 151) + (+ 40 @C @A) + (+ @C @D @B) + (+ @E @F 40) + (+ @F @G @C) + (+ @G @H @D) + (+ @X 11 @E) + (+ 11 @Y @F) + (+ @Y 4 @G) + (+ 4 @Z @H) + (+ @X @Z @Y) ) diff --git a/Task/Pascals-triangle-Puzzle/Prolog/pascals-triangle-puzzle.pro b/Task/Pascals-triangle-Puzzle/Prolog/pascals-triangle-puzzle.pro new file mode 100644 index 0000000000..f6a65f5634 --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/Prolog/pascals-triangle-puzzle.pro @@ -0,0 +1,19 @@ +:- use_module(library(clpfd)). + +puzzle(Ts, X, Y, Z) :- + Ts = [ [151], + [_, _], + [40, _, _], + [_, _, _, _], + [X, 11, Y, 4, Z]], + Y #= X + Z, triangle(Ts), append(Ts, Vs), Vs ins 0..sup, label(Vs). + +triangle([T|Ts]) :- ( Ts = [N|_] -> triangle_(T, N), triangle(Ts) ; true ). + +triangle_([], _). +triangle_([T|Ts], [A,B|Rest]) :- T #= A + B, triangle_(Ts, [B|Rest]). + +% ?- puzzle(_,X,Y,Z). +% X = 5, +% Y = 13, +% Z = 8 ; diff --git a/Task/Pascals-triangle-Puzzle/PureBasic/pascals-triangle-puzzle.purebasic b/Task/Pascals-triangle-Puzzle/PureBasic/pascals-triangle-puzzle.purebasic new file mode 100644 index 0000000000..86de95cbf2 --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/PureBasic/pascals-triangle-puzzle.purebasic @@ -0,0 +1,31 @@ +; Known; +; A. +; [ 151] +; [a ][b ] +; [40][c ][d ] +; [e ][f ][g ][h ] +; [ X][11][ Y][ 4][ Z] +; +; B. +; Y = X + Z + +Procedure.i SolveForZ(x) + Protected a,b,c,d,e,f,g,h,z + For z=0 To 20 + e=x+11: f=11+(x+z): g=(x+z)+4: h=4+z + If e+f=40 + c=f+g : d=g+h: a=40+c: b=c+d + If a+b=151 + ProcedureReturn z + EndIf + EndIf + Next z + ProcedureReturn -1 +EndProcedure + +Define x=-1, z=0, title$="Pascal's triangle/Puzzle in PureBasic" +Repeat + x+1 + z=SolveForZ(x) +Until z>=0 +MessageRequester(title$,"X="+Str(x)+#CRLF$+"Y="+Str(x+z)+#CRLF$+"Z="+Str(z)) diff --git a/Task/Pascals-triangle-Puzzle/Python/pascals-triangle-puzzle-1.py b/Task/Pascals-triangle-Puzzle/Python/pascals-triangle-puzzle-1.py new file mode 100644 index 0000000000..792f25a3cf --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/Python/pascals-triangle-puzzle-1.py @@ -0,0 +1,122 @@ +# Pyramid solver +# [151] +# [ ] [ ] +# [ 40] [ ] [ ] +# [ ] [ ] [ ] [ ] +#[ X ] [ 11] [ Y ] [ 4 ] [ Z ] +# X -Y + Z = 0 + +def combine( snl, snr ): + + cl = {} + if isinstance(snl, int): + cl['1'] = snl + elif isinstance(snl, string): + cl[snl] = 1 + else: + cl.update( snl) + + if isinstance(snr, int): + n = cl.get('1', 0) + cl['1'] = n + snr + elif isinstance(snr, string): + n = cl.get(snr, 0) + cl[snr] = n + 1 + else: + for k,v in snr.items(): + n = cl.get(k, 0) + cl[k] = n+v + return cl + + +def constrain(nsum, vn ): + nn = {} + nn.update(vn) + n = nn.get('1', 0) + nn['1'] = n - nsum + return nn + +def makeMatrix( constraints ): + vmap = set() + for c in constraints: + vmap.update( c.keys()) + vmap.remove('1') + nvars = len(vmap) + vmap = sorted(vmap) # sort here so output is in sorted order + mtx = [] + for c in constraints: + row = [] + for vv in vmap: + row.append(float(c.get(vv, 0))) + row.append(-float(c.get('1',0))) + mtx.append(row) + + if len(constraints) == nvars: + print 'System appears solvable' + elif len(constraints) < nvars: + print 'System is not solvable - needs more constraints.' + return mtx, vmap + + +def SolvePyramid( vl, cnstr ): + + vl.reverse() + constraints = [cnstr] + lvls = len(vl) + for lvln in range(1,lvls): + lvd = vl[lvln] + for k in range(lvls - lvln): + sn = lvd[k] + ll = vl[lvln-1] + vn = combine(ll[k], ll[k+1]) + if sn is None: + lvd[k] = vn + else: + constraints.append(constrain( sn, vn )) + + print 'Constraint Equations:' + for cstr in constraints: + fset = ('%d*%s'%(v,k) for k,v in cstr.items() ) + print ' + '.join(fset), ' = 0' + + mtx,vmap = makeMatrix(constraints) + + MtxSolve(mtx) + + d = len(vmap) + for j in range(d): + print vmap[j],'=', mtx[j][d] + + +def MtxSolve(mtx): + # Simple Matrix solver... + + mDim = len(mtx) # dimension--- + for j in range(mDim): + rw0= mtx[j] + f = 1.0/rw0[j] + for k in range(j, mDim+1): + rw0[k] *= f + + for l in range(1+j,mDim): + rwl = mtx[l] + f = -rwl[j] + for k in range(j, mDim+1): + rwl[k] += f * rw0[k] + + # backsolve part --- + for j1 in range(1,mDim): + j = mDim - j1 + rw0= mtx[j] + for l in range(0, j): + rwl = mtx[l] + f = -rwl[j] + rwl[j] += f * rw0[j] + rwl[mDim] += f * rw0[mDim] + + return mtx + + +p = [ [151], [None,None], [40,None,None], [None,None,None,None], ['X', 11, 'Y', 4, 'Z'] ] +addlConstraint = { 'X':1, 'Y':-1, 'Z':1, '1':0 } +SolvePyramid( p, addlConstraint) diff --git a/Task/Pascals-triangle-Puzzle/Python/pascals-triangle-puzzle-2.py b/Task/Pascals-triangle-Puzzle/Python/pascals-triangle-puzzle-2.py new file mode 100644 index 0000000000..3f04f7ad51 --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/Python/pascals-triangle-puzzle-2.py @@ -0,0 +1,19 @@ +from csp import Problem + +p = Problem() +pvars = "R2 R3 R5 R6 R7 R8 R9 R10 X Y Z".split() +# 0-151 is the possible finite range of the variables +p.addvars(pvars, xrange(152)) +p.addrule("R7 == X + 11") +p.addrule("R8 == Y + 11") +p.addrule("R9 == Y + 4") +p.addrule("R10 == Z + 4") +p.addrule("R7 + R8 == 40") +p.addrule("R5 == R8 + R9") +p.addrule("R6 == R9 + R10") +p.addrule("R2 == 40 + R5") +p.addrule("R3 == R5 + R6") +p.addrule("R2 + R3 == 151") +p.addrule("Y == X + Z") +for sol in p.xsolutions(): + print [sol[k] for k in "XYZ"] diff --git a/Task/Pascals-triangle-Puzzle/Python/pascals-triangle-puzzle-3.py b/Task/Pascals-triangle-Puzzle/Python/pascals-triangle-puzzle-3.py new file mode 100644 index 0000000000..f44a9f6929 --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/Python/pascals-triangle-puzzle-3.py @@ -0,0 +1 @@ +[5, 13, 8] diff --git a/Task/Pascals-triangle-Puzzle/REXX/pascals-triangle-puzzle.rexx b/Task/Pascals-triangle-Puzzle/REXX/pascals-triangle-puzzle.rexx new file mode 100644 index 0000000000..8a1e5ac53f --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/REXX/pascals-triangle-puzzle.rexx @@ -0,0 +1,33 @@ +/*REXX program solves a "Pyramid of Numbers" puzzle given four values.*/ + /*┌──────────────────────────────────────────────┐ + ┌─┘ └─┐ + │ answer │ + │ mid / │ + │ \ / │ + │ \ 151 │ + │ \ ααα ααα │ + │ 40 ααα ααα │ + │ ααα ααα ααα ααα │ + │ x 11 y 4 z │ + │ / \ │ + │ / \ │ + │ / \ │ + │ B D │ + └─┐ ┌─┘ + └──────────────────────────────────────────────┘*/ +parse arg x b y d z mid answer . /*get some values, others, just X*/ + pad=left('',15) /*for inserting spaces in output.*/ + top=answer - 4*b - 4*d /*calculate the top # - constants*/ +middle=mid - 2*b /*calculate the mod # - constants*/ + + do x =-top to top + do y=-top to top + if x+y\==middle then iterate /*40 = x+2B+Y -or- 40-2*11 =x+y*/ + y6=y*6 /*calculate a short cut. */ + do z=-top to top + if z\==y-x then iterate /*z has to equal y-x (y=x+z) */ + if x+y6+z==top then say pad 'x = ' x pad "y = " y pad 'z = ' z + end /*z*/ + end /*y*/ + end /*x*/ + /*stick a fork in it, we're done.*/ diff --git a/Task/Pascals-triangle-Puzzle/Ruby/pascals-triangle-puzzle.rb b/Task/Pascals-triangle-Puzzle/Ruby/pascals-triangle-puzzle.rb new file mode 100644 index 0000000000..cedcb37129 --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/Ruby/pascals-triangle-puzzle.rb @@ -0,0 +1,59 @@ +require 'rref' + +pyramid = [ + [ 151], + [nil,nil], + [40,nil,nil], + [nil,nil,nil,nil], + ["x", 11,"y", 4,"z"] +] +p pyramid +equations = [[1,-1,1,0]] # y = x + z + +def parse_equation(str) + eqn = [0] * 4 + lhs, rhs = str.split("=") + eqn[3] = rhs.to_i + for term in lhs.split("+") + case term + when "x": eqn[0] += 1 + when "y": eqn[1] += 1 + when "z": eqn[2] += 1 + else eqn[3] -= term.to_i + end + end + eqn +end + +-2.downto(-5) do |row| + pyramid[row].each_index do |col| + val = pyramid[row][col] + sum = "%s+%s" % [pyramid[row+1][col].to_s, pyramid[row+1][col+1].to_s] + if val.nil? + pyramid[row][col] = sum + else + equations << parse_equation(sum + "=#{val}") + end + end +end + +reduced = convert_to(reduced_row_echelon_form(equations), :to_i) + +for eqn in reduced + if eqn[0] + eqn[1] + eqn[2] != 1 + fail "no unique solution! #{equations.inspect} ==> #{reduced.inspect}" + elsif eqn[0] == 1: x = eqn[3] + elsif eqn[1] == 1: y = eqn[3] + elsif eqn[2] == 1: z = eqn[3] + end +end + +puts "x == #{x}" +puts "y == #{y}" +puts "z == #{z}" + +answer = [] +for row in pyramid + answer << row.collect {|cell| eval cell.to_s} +end +p answer diff --git a/Task/Pascals-triangle-Puzzle/SystemVerilog/pascals-triangle-puzzle.v b/Task/Pascals-triangle-Puzzle/SystemVerilog/pascals-triangle-puzzle.v new file mode 100644 index 0000000000..4a69a6d73c --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/SystemVerilog/pascals-triangle-puzzle.v @@ -0,0 +1,38 @@ +program main; + + class Triangle; + rand bit [7:0] a,b,c,d,e,f,g,h,X,Y,Z; + + function new(); + randomize; + $display(" [%0d]", 151); + $display(" [%0d][%0d]", a, b); + $display(" [%0d][%0d][%0d]", 40,c,d); + $display(" [%0d][%0d][%0d][%0d]", e,f,g,h); + $display(" [%0d][%0d][%0d][%0d][%0d]",X,11,Y,4,Z); + endfunction + + constraint structure { + 151 == a + b; + + a == 40 + c; + b == c + d; + + 40 == e + f; + c == f + g; + d == g + h; + + e == X + 11; + f == 11 + Y; + g == Y + 4; + h == 4 + Z; + }; + + constraint extra { + Y == X + Z; + }; + + endclass + + Triangle answer = new; +endprogram diff --git a/Task/Pascals-triangle-Puzzle/Tcl/pascals-triangle-puzzle.tcl b/Task/Pascals-triangle-Puzzle/Tcl/pascals-triangle-puzzle.tcl new file mode 100644 index 0000000000..5b9860da67 --- /dev/null +++ b/Task/Pascals-triangle-Puzzle/Tcl/pascals-triangle-puzzle.tcl @@ -0,0 +1,68 @@ +package require Tcl 8.5 +namespace path ::tcl::mathop + +set pyramid { + {151.0 "" "" "" ""} + {"" "" "" "" ""} + {40.0 "" "" "" ""} + {"" "" "" "" ""} + {x 11.0 y 4.0 z} +} + +set equations {{1 -1 1 0}} + +proc simplify {terms val} { + set vars {0 0 0} + set x 0 + set y 1 + set z 2 + foreach term $terms { + switch -exact -- $term { + x - y - z { + lset vars [set $term] [+ 1 [lindex $vars [set $term]]] + } + default { + set val [- $val $term] + } + } + } + return [concat $vars $val] +} + +for {set row [+ [llength $pyramid] -2]} {$row >= 0} {incr row -1} { + for {set cell 0} {$cell <= $row} {incr cell } { + set sum [concat [lindex $pyramid [+ 1 $row] $cell] [lindex $pyramid [+ 1 $row] [+ 1 $cell]]] + if {[set val [lindex $pyramid $row $cell]] ne ""} { + lappend equations [simplify $sum $val] + } else { + lset pyramid $row $cell $sum + } + } +} + +set solution [toRREF $equations] +foreach row $solution { + lassign $row a b c d + if {$a + $b + $c > 1} { + error "problem does not have a unique solution" + } + if {$a} {set x $d} + if {$b} {set y $d} + if {$c} {set z $d} +} +puts "x=$x" +puts "y=$y" +puts "z=$z" + +foreach row $pyramid { + set newrow {} + foreach cell $row { + if {$cell eq ""} { + lappend newrow "" + } else { + lappend newrow [expr [join [string map [list x $x y $y z $z] $cell] +]] + } + } + lappend solved $newrow +} +print_matrix $solved diff --git a/Task/Pascals-triangle/0DESCRIPTION b/Task/Pascals-triangle/0DESCRIPTION new file mode 100644 index 0000000000..f1c19926e7 --- /dev/null +++ b/Task/Pascals-triangle/0DESCRIPTION @@ -0,0 +1,8 @@ +[[wp:Pascal's triangle|Pascal's triangle]] is an arithmetic and geometric figure first imagined by [[wp:Blaise Pascal|Blaise Pascal]]. Its first few rows look like this: + 1 + 1 1 + 1 2 1 + 1 3 3 1 +where each element of each row is either 1 or the sum of the two elements right above it. For example, the next row would be 1 (since the first element of each row doesn't have two elements above it), 4 (1 + 3), 6 (3 + 3), 4 (3 + 1), and 1 (since the last element of each row doesn't have two elements above it). Each row n (starting with row 0 at the top) shows the coefficients of the binomial expansion of (x + y)n. + +Write a function that prints out the first n rows of the triangle (with f(1) yielding the row consisting of only the element 1). This can be done either by summing elements from the previous rows or using a binary coefficient or combination function. Behavior for n <= 0 does not need to be uniform, but should be noted. diff --git a/Task/Pascals-triangle/1META.yaml b/Task/Pascals-triangle/1META.yaml new file mode 100644 index 0000000000..8644b2ad9b --- /dev/null +++ b/Task/Pascals-triangle/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Arithmetic operations diff --git a/Task/Pascals-triangle/ALGOL-68/pascals-triangle.alg b/Task/Pascals-triangle/ALGOL-68/pascals-triangle.alg new file mode 100644 index 0000000000..6d3526ed50 --- /dev/null +++ b/Task/Pascals-triangle/ALGOL-68/pascals-triangle.alg @@ -0,0 +1,19 @@ +PRIO MINLWB = 8, MAXUPB = 8; +OP MINLWB = ([]INT a,b)INT: (LWB aUPB b|UPB a|UPB b); + +OP + = ([]INT a,b)[]INT:( + [a MINLWB b:a MAXUPB b]INT out; FOR i FROM LWB out TO UPB out DO out[i]:= 0 OD; + out[LWB a:UPB a] := a; FOR i FROM LWB b TO UPB b DO out[i]+:= b[i] OD; + out +); + +INT width = 4, stop = 9; +FORMAT centre = $n((stop-UPB row+1)*width OVER 2)(q)$; + +FLEX[1]INT row := 1; # example of rowing # +FOR i WHILE + printf((centre, $g(-width)$, row, $l$)); +# WHILE # i < stop DO + row := row[AT 1] + row[AT 2] +OD diff --git a/Task/Pascals-triangle/APL/pascals-triangle-1.apl b/Task/Pascals-triangle/APL/pascals-triangle-1.apl new file mode 100644 index 0000000000..15929106b6 --- /dev/null +++ b/Task/Pascals-triangle/APL/pascals-triangle-1.apl @@ -0,0 +1 @@ +{A←0,⍳⍵ ⋄ ⍉A∘.!A} diff --git a/Task/Pascals-triangle/APL/pascals-triangle-2.apl b/Task/Pascals-triangle/APL/pascals-triangle-2.apl new file mode 100644 index 0000000000..269d839fa4 --- /dev/null +++ b/Task/Pascals-triangle/APL/pascals-triangle-2.apl @@ -0,0 +1 @@ +{A←0,⍳⍵ ⋄ ⍉A∘.!A} 3 diff --git a/Task/Pascals-triangle/AWK/pascals-triangle.awk b/Task/Pascals-triangle/AWK/pascals-triangle.awk new file mode 100644 index 0000000000..de7b2ae6ca --- /dev/null +++ b/Task/Pascals-triangle/AWK/pascals-triangle.awk @@ -0,0 +1,7 @@ +$ awk 'BEGIN{for(i=0;i<6;i++){c=1;r=c;for(j=0;j) of Integer; + type Row_Access is access Row; + type Triangle is array(Positive range <>) of Row_Access; + function General_Triangle(Depth : Positive) return Triangle is + Result : Triangle(1..Depth); + begin + for I in Result'range loop + Result(I) := new Row(1..I); + for J in 1..I loop + if J = Result(I)'First or else J = Result(I)'Last then + Result(I)(J) := 1; + else + Result(I)(J) := Result(I - 1)(J - 1) + Result(I - 1)(J); + end if; + end loop; + end loop; + return Result; + end General_Triangle; + procedure Print(Item : Triangle) is + begin + for I in Item'range loop + for J in 1..I loop + Put(Item => Item(I)(J), Width => 3); + end loop; + New_Line; + end loop; + end Print; +begin + Print(General_Triangle(7)); +end Pascals_Triangle; diff --git a/Task/Pascals-triangle/AutoHotkey/pascals-triangle.ahk b/Task/Pascals-triangle/AutoHotkey/pascals-triangle.ahk new file mode 100644 index 0000000000..fd7edafb3e --- /dev/null +++ b/Task/Pascals-triangle/AutoHotkey/pascals-triangle.ahk @@ -0,0 +1,22 @@ +n := 8, p0 := "1" ; 1+n rows of Pascal's triangle +Loop %n% { + p := "p" A_Index, %p% := v := 1, q := "p" A_Index-1 + Loop Parse, %q%, %A_Space% + If (A_Index > 1) + %p% .= " " v+A_LoopField, v := A_LoopField + %p% .= " 1" +} + ; Triangular Formatted output +VarSetCapacity(tabs,n,Asc("`t")) +t .= tabs "`t1" +Loop %n% { + t .= "`n" SubStr(tabs,A_Index) + Loop Parse, p%A_Index%, %A_Space% + t .= A_LoopField "`t`t" +} +Gui Add, Text,, %t% ; Show result in a GUI +Gui Show +Return + +GuiClose: + ExitApp diff --git a/Task/Pascals-triangle/BASIC/pascals-triangle.basic b/Task/Pascals-triangle/BASIC/pascals-triangle.basic new file mode 100644 index 0000000000..10b0d4204e --- /dev/null +++ b/Task/Pascals-triangle/BASIC/pascals-triangle.basic @@ -0,0 +1,16 @@ +DIM i AS Integer +DIM row AS Integer +DIM nrows AS Integer +DIM values(100) AS Integer + +INPUT "Number of rows: "; nrows +values(1) = 1 +PRINT TAB((nrows)*3);" 1" +FOR row = 2 TO nrows + PRINT TAB((nrows-row)*3+1); + FOR i = row TO 1 STEP -1 + values(i) = values(i) + values(i-1) + PRINT USING "##### "; values(i); + NEXT i + PRINT +NEXT row diff --git a/Task/Pascals-triangle/BBC-BASIC/pascals-triangle.bbc b/Task/Pascals-triangle/BBC-BASIC/pascals-triangle.bbc new file mode 100644 index 0000000000..39427e0ca2 --- /dev/null +++ b/Task/Pascals-triangle/BBC-BASIC/pascals-triangle.bbc @@ -0,0 +1,13 @@ + nrows% = 10 + + colwidth% = 4 + @% = colwidth% : REM Set column width + FOR row% = 1 TO nrows% + PRINT SPC(colwidth%*(nrows% - row%)/2); + acc% = 1 + FOR element% = 1 TO row% + PRINT acc%; + acc% = acc% * (row% - element%) / element% + 0.5 + NEXT + PRINT + NEXT row% diff --git a/Task/Pascals-triangle/Bracmat/pascals-triangle.bracmat b/Task/Pascals-triangle/Bracmat/pascals-triangle.bracmat new file mode 100644 index 0000000000..85e0aaaece --- /dev/null +++ b/Task/Pascals-triangle/Bracmat/pascals-triangle.bracmat @@ -0,0 +1,18 @@ +( out$"Number of rows? " +& get':?R +& -1:?I +& whl + ' ( 1+!I:0:?tabs&put$\t) + & whl + ' ( 1+!K:~>!I:?K + & put$(!C \t\t) + & !C*(!I+-1*!K)*(!K+1)^-1:?C + ) + & put$\n + ) +& +) diff --git a/Task/Pascals-triangle/Burlesque/pascals-triangle.blq b/Task/Pascals-triangle/Burlesque/pascals-triangle.blq new file mode 100644 index 0000000000..1cc51ea3ba --- /dev/null +++ b/Task/Pascals-triangle/Burlesque/pascals-triangle.blq @@ -0,0 +1,18 @@ +blsq ) {1}{1 1}{^^2CO{p^?+}m[1+]1[+}15E!#s<-spbx#S +1 +1 1 +1 2 1 +1 3 3 1 +1 4 6 4 1 +1 5 10 10 5 1 +1 6 15 20 15 6 1 +1 7 21 35 35 21 7 1 +1 8 28 56 70 56 28 8 1 +1 9 36 84 126 126 84 36 9 1 +1 10 45 120 210 252 210 120 45 10 1 +1 11 55 165 330 462 462 330 165 55 11 1 +1 12 66 220 495 792 924 792 495 220 66 12 1 +1 13 78 286 715 1287 1716 1716 1287 715 286 78 13 1 +1 14 91 364 1001 2002 3003 3432 3003 2002 1001 364 91 14 1 +1 15 105 455 1365 3003 5005 6435 6435 5005 3003 1365 455 105 15 1 +1 16 120 560 1820 4368 8008 11440 12870 11440 8008 4368 1820 560 120 16 1 diff --git a/Task/Pascals-triangle/C++/pascals-triangle.cpp b/Task/Pascals-triangle/C++/pascals-triangle.cpp new file mode 100644 index 0000000000..3b81d11cae --- /dev/null +++ b/Task/Pascals-triangle/C++/pascals-triangle.cpp @@ -0,0 +1,26 @@ +#include +#include +#include +#include + +void genPyrN(int rows) { + if (rows < 0) return; + // save the last row here + std::vector last(1, 1); + std::cout << last[0] << std::endl; + + for (int i = 1; i <= rows; i++) { + // work on the next row + std::vector thisRow; + thisRow.reserve(i+1); + thisRow.push_back(last.front()); // beginning of row + std::transform(last.begin(), last.end()-1, last.begin()+1, std::back_inserter(thisRow), std::plus()); // middle of row + thisRow.push_back(last.back()); // end of row + + for (int j = 0; j <= i; j++) + std::cout << thisRow[j] << " "; + std::cout << std::endl; + + last.swap(thisRow); + } +} diff --git a/Task/Pascals-triangle/C/pascals-triangle-1.c b/Task/Pascals-triangle/C/pascals-triangle-1.c new file mode 100644 index 0000000000..df016c9efe --- /dev/null +++ b/Task/Pascals-triangle/C/pascals-triangle-1.c @@ -0,0 +1,22 @@ +#include + +void pascaltriangle(unsigned int n) +{ + unsigned int c, i, j, k; + + for(i=0; i < n; i++) { + c = 1; + for(j=1; j <= 2*(n-1-i); j++) printf(" "); + for(k=0; k <= i; k++) { + printf("%3d ", c); + c = c * (i-k)/(k+1); + } + printf("\n"); + } +} + +int main() +{ + pascaltriangle(8); + return 0; +} diff --git a/Task/Pascals-triangle/C/pascals-triangle-2.c b/Task/Pascals-triangle/C/pascals-triangle-2.c new file mode 100644 index 0000000000..a286eba43e --- /dev/null +++ b/Task/Pascals-triangle/C/pascals-triangle-2.c @@ -0,0 +1,18 @@ +#include + +#define D 32 +int pascals(int *x, int *y, int d) +{ + int i; + for (i = 1; i < d; i++) + printf("%d%c", y[i] = x[i - 1] + x[i], + i < d - 1 ? ' ' : '\n'); + + return D > d ? pascals(y, x, d + 1) : 0; +} + +int main() +{ + int x[D] = {0, 1, 0}, y[D] = {0}; + return pascals(x, y, 0); +} diff --git a/Task/Pascals-triangle/C/pascals-triangle-3.c b/Task/Pascals-triangle/C/pascals-triangle-3.c new file mode 100644 index 0000000000..b9822de288 --- /dev/null +++ b/Task/Pascals-triangle/C/pascals-triangle-3.c @@ -0,0 +1,16 @@ +void triangleC(int nRows) { + if (nRows <= 0) return; + int *prevRow = NULL; + for (int r = 1; r <= nRows; r++) { + int *currRow = malloc(r * sizeof(int)); + for (int i = 0; i < r; i++) { + int val = i==0 || i==r-1 ? 1 : prevRow[i-1] + prevRow[i]; + currRow[i] = val; + printf(" %4d", val); + } + printf("\n"); + free(prevRow); + prevRow = currRow; + } + free(prevRow); +} diff --git a/Task/Pascals-triangle/Clojure/pascals-triangle-1.clj b/Task/Pascals-triangle/Clojure/pascals-triangle-1.clj new file mode 100644 index 0000000000..cfe040e9a8 --- /dev/null +++ b/Task/Pascals-triangle/Clojure/pascals-triangle-1.clj @@ -0,0 +1,12 @@ +(defn pascal [n] + (let [newrow (fn newrow [lst ret] + (if lst + (recur (rest lst) + (conj ret (+ (first lst) (or (second lst) 0)))) + ret)) + genrow (fn genrow [n lst] + (when (< 0 n) + (do (println lst) + (recur (dec n) (conj (newrow lst []) 1)))))] + (genrow n [1]))) +(pascal 4) diff --git a/Task/Pascals-triangle/Clojure/pascals-triangle-2.clj b/Task/Pascals-triangle/Clojure/pascals-triangle-2.clj new file mode 100644 index 0000000000..d4cf330c07 --- /dev/null +++ b/Task/Pascals-triangle/Clojure/pascals-triangle-2.clj @@ -0,0 +1,8 @@ +(defn nextrow [row] + (vec (concat [1] (map #(apply + %) (partition 2 1 row)) [1] ))) + +(defn pascal [n] + (assert (and (integer? n) (pos? n))) + (let [triangle (take n (iterate nextrow [1]))] + (doseq [row triangle] + (println row)))) diff --git a/Task/Pascals-triangle/Clojure/pascals-triangle-3.clj b/Task/Pascals-triangle/Clojure/pascals-triangle-3.clj new file mode 100644 index 0000000000..cd699630d8 --- /dev/null +++ b/Task/Pascals-triangle/Clojure/pascals-triangle-3.clj @@ -0,0 +1,7 @@ +(def pascal + (iterate + (fn [prev-row] + (->> + (concat [[(first prev-row)]] (partition 2 1 prev-row) [[(last prev-row)]]) + (map (partial apply +) ,,,))) + [1])) diff --git a/Task/Pascals-triangle/CoffeeScript/pascals-triangle.coffeescript b/Task/Pascals-triangle/CoffeeScript/pascals-triangle.coffeescript new file mode 100644 index 0000000000..47841909ec --- /dev/null +++ b/Task/Pascals-triangle/CoffeeScript/pascals-triangle.coffeescript @@ -0,0 +1,28 @@ +pascal = (n) -> + width = 6 + for r in [1..n] + s = ws (width/2) * (n-r) # center row + output = (n) -> s += pad width, n + cell = 1 + output cell + # Compute binomial coefficients as you go + # across the row. + for c in [1...r] + cell *= (r-c) / c + output cell + console.log s + +ws = (n) -> + s = '' + s += ' ' for i in [0...n] + s + +pad = (cnt, n) -> + s = n.toString() + # There is probably a better way to do this. + cnt -= s.length + right = Math.floor(cnt / 2) + left = cnt - right + ws(left) + s + ws(right) + +pascal(7) diff --git a/Task/Pascals-triangle/Common-Lisp/pascals-triangle.lisp b/Task/Pascals-triangle/Common-Lisp/pascals-triangle.lisp new file mode 100644 index 0000000000..ed02b0fcfd --- /dev/null +++ b/Task/Pascals-triangle/Common-Lisp/pascals-triangle.lisp @@ -0,0 +1,12 @@ +(defun pascal (n) + (genrow n '(1))) + +(defun genrow (n l) + (when (< 0 n) + (print l) + (genrow (1- n) (cons 1 (newrow l))))) + +(defun newrow (l) + (if (> 2 (length l)) + '(1) + (cons (+ (car l) (cadr l)) (newrow (cdr l))))) diff --git a/Task/Pascals-triangle/D/pascals-triangle-1.d b/Task/Pascals-triangle/D/pascals-triangle-1.d new file mode 100644 index 0000000000..d6d0f42129 --- /dev/null +++ b/Task/Pascals-triangle/D/pascals-triangle-1.d @@ -0,0 +1,25 @@ +int[][] pascalsTriangle(in int rows) pure nothrow { + auto tri = new int[][rows]; + foreach (r; 0 .. rows) { + int v = 1; + foreach (c; 0 .. r+1) { + tri[r] ~= v; + v = (v * (r - c)) / (c + 1); + } + } + return tri; +} + +void main() { + immutable t = pascalsTriangle(10); + assert(t == [[1], + [1, 1], + [1, 2, 1], + [1, 3, 3, 1], + [1, 4, 6, 4, 1], + [1, 5, 10, 10, 5, 1], + [1, 6, 15, 20, 15, 6, 1], + [1, 7, 21, 35, 35, 21, 7, 1], + [1, 8, 28, 56, 70, 56, 28, 8, 1], + [1, 9, 36, 84, 126, 126, 84, 36, 9, 1]]); +} diff --git a/Task/Pascals-triangle/D/pascals-triangle-2.d b/Task/Pascals-triangle/D/pascals-triangle-2.d new file mode 100644 index 0000000000..0cad996a60 --- /dev/null +++ b/Task/Pascals-triangle/D/pascals-triangle-2.d @@ -0,0 +1,12 @@ +import std.stdio, std.algorithm, std.range; + +auto pascal(in int n) /*pure nothrow*/ { + auto p = [[1]]; + foreach (_; 1 .. n) + p ~= zip(p[$-1] ~ 0, 0 ~ p[$-1]).map!q{a[0] + a[1]}().array(); + return p; +} + +void main() { + writeln(pascal(5)); +} diff --git a/Task/Pascals-triangle/D/pascals-triangle-3.d b/Task/Pascals-triangle/D/pascals-triangle-3.d new file mode 100644 index 0000000000..74585252e4 --- /dev/null +++ b/Task/Pascals-triangle/D/pascals-triangle-3.d @@ -0,0 +1,42 @@ +import std.stdio, std.string, std.array, std.format; + +string Pascal(alias dg, T, T initValue)(int n) { + string output; + + void append(in T[] l) { + output ~= " ".replicate((n - l.length + 1) * 2); + foreach (e; l) + output ~= format("%4s", format("%4s", e)); + output ~= "\n"; + } + + if (n > 0) { + T[][] lines = [[initValue]]; + append(lines[0]); + foreach (i; 1 .. n) { + lines ~= lines[i - 1] ~ initValue; // length + 1 + foreach (int j; 1 .. lines[i-1].length) + lines[i][j] = dg(lines[i-1][j], lines[i-1][j-1]); + append(lines[i]); + } + } + return output; +} + +string delegate(int n) genericPascal(alias dg, T, T initValue)() { + mixin Pascal!(dg, T, initValue); + return &Pascal; +} + +void main() { + auto pascal = genericPascal!((int a, int b) => a + b, int, 1)(); + static char xor(char a, char b) { return a == b ? '_' : '*'; } + auto sierpinski = genericPascal!(xor, char, '*')(); + + foreach (i; [1, 5, 9]) + writef(pascal(i)); + // an order 4 sierpinski triangle is a 2^4 lines generic + // Pascal triangle with xor operation + foreach (i; [16]) + writef(sierpinski(i)); +} diff --git a/Task/Pascals-triangle/DWScript/pascals-triangle.dwscript b/Task/Pascals-triangle/DWScript/pascals-triangle.dwscript new file mode 100644 index 0000000000..8744d68bf1 --- /dev/null +++ b/Task/Pascals-triangle/DWScript/pascals-triangle.dwscript @@ -0,0 +1,15 @@ +procedure Pascal(r : Integer); +var + i, c, k : Integer; +begin + for i:=0 to r-1 do begin + c:=1; + for k:=0 to i do begin + Print(Format('%4d', [c])); + c:=(c*(i-k)) div (k+1); + end; + PrintLn(''); + end; +end; + +Pascal(9); diff --git a/Task/Pascals-triangle/E/pascals-triangle-1.e b/Task/Pascals-triangle/E/pascals-triangle-1.e new file mode 100644 index 0000000000..9b3b82d5a5 --- /dev/null +++ b/Task/Pascals-triangle/E/pascals-triangle-1.e @@ -0,0 +1,20 @@ +def pascalsTriangle(n, out) { + def row := [].diverge(int) + out.print("") + for y in 1..n { + out.print("") + row.push(1) + def skip := n - y + if (skip > 0) { + out.print(``) + } + for x => v in row { + out.print(``) + } + for i in (1..!y).descending() { + row[i] += row[i - 1] + } + out.println("") + } + out.print("
$v
") +} diff --git a/Task/Pascals-triangle/E/pascals-triangle-2.e b/Task/Pascals-triangle/E/pascals-triangle-2.e new file mode 100644 index 0000000000..6680277a17 --- /dev/null +++ b/Task/Pascals-triangle/E/pascals-triangle-2.e @@ -0,0 +1,7 @@ +def out := .textWriter() +try { + pascalsTriangle(15, out) +} finally { + out.close() +} +makeCommand("yourFavoriteWebBrowser")("triangle.html") diff --git a/Task/Pascals-triangle/Erlang/pascals-triangle.erl b/Task/Pascals-triangle/Erlang/pascals-triangle.erl new file mode 100644 index 0000000000..9c6e479b43 --- /dev/null +++ b/Task/Pascals-triangle/Erlang/pascals-triangle.erl @@ -0,0 +1,8 @@ +-import(lists). +-export([pascal/1]). + +pascal(1)-> [[1]]; +pascal(N) -> + L = pascal(N-1), + [H|_] = L, + [lists:zipwith(fun(X,Y)->X+Y end,[0]++H,H++[0])|L]. diff --git a/Task/Pascals-triangle/Euphoria/pascals-triangle.euphoria b/Task/Pascals-triangle/Euphoria/pascals-triangle.euphoria new file mode 100644 index 0000000000..91a8581c34 --- /dev/null +++ b/Task/Pascals-triangle/Euphoria/pascals-triangle.euphoria @@ -0,0 +1,10 @@ +sequence row +row = {} +for m = 1 to 10 do + row = row & 1 + for n = length(row)-1 to 2 by -1 do + row[n] += row[n-1] + end for + print(1,row) + puts(1,'\n') +end for diff --git a/Task/Pascals-triangle/Factor/pascals-triangle-1.factor b/Task/Pascals-triangle/Factor/pascals-triangle-1.factor new file mode 100644 index 0000000000..a012f1ba26 --- /dev/null +++ b/Task/Pascals-triangle/Factor/pascals-triangle-1.factor @@ -0,0 +1,7 @@ +USING: grouping kernel math sequences ; + +: (pascal) ( seq -- newseq ) + dup last 0 prefix 0 suffix 2 [ sum ] map suffix ; + +: pascal ( n -- seq ) + 1 - { { 1 } } swap [ (pascal) ] times ; diff --git a/Task/Pascals-triangle/Factor/pascals-triangle-2.factor b/Task/Pascals-triangle/Factor/pascals-triangle-2.factor new file mode 100644 index 0000000000..9b9bf2014f --- /dev/null +++ b/Task/Pascals-triangle/Factor/pascals-triangle-2.factor @@ -0,0 +1,2 @@ +5 pascal . +{ { 1 } { 1 1 } { 1 2 1 } { 1 3 3 1 } { 1 4 6 4 1 } } diff --git a/Task/Pascals-triangle/Fantom/pascals-triangle.fantom b/Task/Pascals-triangle/Fantom/pascals-triangle.fantom new file mode 100644 index 0000000000..d1083546cb --- /dev/null +++ b/Task/Pascals-triangle/Fantom/pascals-triangle.fantom @@ -0,0 +1,29 @@ +class Main +{ + Int[] next_row (Int[] row) + { + new_row := [1] + (row.size-1).times |i| + { + new_row.add (row[i] + row[i+1]) + } + new_row.add (1) + + return new_row + } + + Void print_pascal (Int n) // no output for n <= 0 + { + current_row := [1] + n.times + { + echo (current_row.join(" ")) + current_row = next_row (current_row) + } + } + + Void main () + { + print_pascal (10) + } +} diff --git a/Task/Pascals-triangle/Forth/pascals-triangle-1.fth b/Task/Pascals-triangle/Forth/pascals-triangle-1.fth new file mode 100644 index 0000000000..2cf3a74f4b --- /dev/null +++ b/Task/Pascals-triangle/Forth/pascals-triangle-1.fth @@ -0,0 +1,11 @@ +: init ( n -- ) + here swap cells erase 1 here ! ; +: .line ( n -- ) + cr here swap 0 do dup @ . cell+ loop drop ; +: next ( n -- ) + here swap 1- cells here + do + i @ i cell+ +! + -1 cells +loop ; +: pascal ( n -- ) + dup init 1 .line + 1 ?do i next i 1+ .line loop ; diff --git a/Task/Pascals-triangle/Forth/pascals-triangle-2.fth b/Task/Pascals-triangle/Forth/pascals-triangle-2.fth new file mode 100644 index 0000000000..25bfb43260 --- /dev/null +++ b/Task/Pascals-triangle/Forth/pascals-triangle-2.fth @@ -0,0 +1,8 @@ +: PascTriangle + cr dup 0 + ?do + 1 over 1- i - 2* spaces i 1+ 0 ?do dup 4 .r j i - * i 1+ / loop cr drop + loop drop +; + +13 PascTriangle diff --git a/Task/Pascals-triangle/Fortran/pascals-triangle.f b/Task/Pascals-triangle/Fortran/pascals-triangle.f new file mode 100644 index 0000000000..7264af6365 --- /dev/null +++ b/Task/Pascals-triangle/Fortran/pascals-triangle.f @@ -0,0 +1,26 @@ +PROGRAM Pascals_Triangle + + CALL Print_Triangle(8) + +END PROGRAM Pascals_Triangle + +SUBROUTINE Print_Triangle(n) + + IMPLICIT NONE + INTEGER, INTENT(IN) :: n + INTEGER :: c, i, j, k, spaces + + DO i = 0, n-1 + c = 1 + spaces = 3 * (n - 1 - i) + DO j = 1, spaces + WRITE(*,"(A)", ADVANCE="NO") " " + END DO + DO k = 0, i + WRITE(*,"(I6)", ADVANCE="NO") c + c = c * (i - k) / (k + 1) + END DO + WRITE(*,*) + END DO + +END SUBROUTINE Print_Triangle diff --git a/Task/Pascals-triangle/GAP/pascals-triangle.gap b/Task/Pascals-triangle/GAP/pascals-triangle.gap new file mode 100644 index 0000000000..f257bbe0d6 --- /dev/null +++ b/Task/Pascals-triangle/GAP/pascals-triangle.gap @@ -0,0 +1,19 @@ +Pascal := function(n) + local i, v; + v := [1]; + for i in [1 .. n] do + Display(v); + v := Concatenation([0], v) + Concatenation(v, [0]); + od; +end; + +Pascal(9); +# [ 1 ] +# [ 1, 1 ] +# [ 1, 2, 1 ] +# [ 1, 3, 3, 1 ] +# [ 1, 4, 6, 4, 1 ] +# [ 1, 5, 10, 10, 5, 1 ] +# [ 1, 6, 15, 20, 15, 6, 1 ] +# [ 1, 7, 21, 35, 35, 21, 7, 1 ] +# [ 1, 8, 28, 56, 70, 56, 28, 8, 1 ] diff --git a/Task/Pascals-triangle/GW-BASIC/pascals-triangle.gw-basic b/Task/Pascals-triangle/GW-BASIC/pascals-triangle.gw-basic new file mode 100644 index 0000000000..89b4c76659 --- /dev/null +++ b/Task/Pascals-triangle/GW-BASIC/pascals-triangle.gw-basic @@ -0,0 +1,9 @@ +10 INPUT "Number of rows? ",R +20 FOR I=0 TO R-1 +30 C=1 +40 FOR K=0 TO I +50 PRINT USING "####";C; +60 C=C*(I-K)/(K+1) +70 NEXT +80 PRINT +90 NEXT diff --git a/Task/Pascals-triangle/Go/pascals-triangle.go b/Task/Pascals-triangle/Go/pascals-triangle.go new file mode 100644 index 0000000000..ea32247b72 --- /dev/null +++ b/Task/Pascals-triangle/Go/pascals-triangle.go @@ -0,0 +1,42 @@ +package main + +import "fmt" + +func printTriangle(n int) { + // degenerate cases + if n <= 0 { + return + } + fmt.Println(1) + if n == 1 { + return + } + // iterate over rows, zero based + a := make([]int, (n+1)/2) + a[0] = 1 + for row, middle := 1, 0; row < n; row++ { + // generate new row + even := row&1 == 0 + if even { + a[middle+1] = a[middle] * 2 + } + for i := middle; i > 0; i-- { + a[i] += a[i-1] + } + // print row + for i := 0; i <= middle; i++ { + fmt.Print(a[i], " ") + } + if even { + middle++ + } + for i := middle; i >= 0; i-- { + fmt.Print(a[i], " ") + } + fmt.Println("") + } +} + +func main() { + printTriangle(4) +} diff --git a/Task/Pascals-triangle/Groovy/pascals-triangle-1.groovy b/Task/Pascals-triangle/Groovy/pascals-triangle-1.groovy new file mode 100644 index 0000000000..761b3f9fd3 --- /dev/null +++ b/Task/Pascals-triangle/Groovy/pascals-triangle-1.groovy @@ -0,0 +1 @@ +def pascal = { n -> (n <= 1) ? [1] : GroovyCollections.transpose([[0] + pascal(n - 1), pascal(n - 1) + [0]]).collect { it.sum() } } diff --git a/Task/Pascals-triangle/Groovy/pascals-triangle-2.groovy b/Task/Pascals-triangle/Groovy/pascals-triangle-2.groovy new file mode 100644 index 0000000000..396e5ccbba --- /dev/null +++ b/Task/Pascals-triangle/Groovy/pascals-triangle-2.groovy @@ -0,0 +1,4 @@ +def count = 15 +(1..count).each { n -> + printf ("%2d:", n); (0..(count-n)).each { print " " }; pascal(n).each{ printf("%6d ", it) }; println "" +} diff --git a/Task/Pascals-triangle/Haskell/pascals-triangle-1.hs b/Task/Pascals-triangle/Haskell/pascals-triangle-1.hs new file mode 100644 index 0000000000..ac3332ce7c --- /dev/null +++ b/Task/Pascals-triangle/Haskell/pascals-triangle-1.hs @@ -0,0 +1,4 @@ +zapWith :: (a -> a -> a) -> [a] -> [a] -> [a] +zapWith f xs [] = xs +zapWith f [] ys = ys +zapWith f (x:xs) (y:ys) = f x y : zapWith f xs ys diff --git a/Task/Pascals-triangle/Haskell/pascals-triangle-2.hs b/Task/Pascals-triangle/Haskell/pascals-triangle-2.hs new file mode 100644 index 0000000000..34e10f5398 --- /dev/null +++ b/Task/Pascals-triangle/Haskell/pascals-triangle-2.hs @@ -0,0 +1,2 @@ +extendWith f [] = [] +extendWith f xs@(x:ys) = x : zapWith f xs ys diff --git a/Task/Pascals-triangle/Haskell/pascals-triangle-3.hs b/Task/Pascals-triangle/Haskell/pascals-triangle-3.hs new file mode 100644 index 0000000000..163e4724e8 --- /dev/null +++ b/Task/Pascals-triangle/Haskell/pascals-triangle-3.hs @@ -0,0 +1 @@ +pascal = iterate (extendWith (+)) [1] diff --git a/Task/Pascals-triangle/Haskell/pascals-triangle-4.hs b/Task/Pascals-triangle/Haskell/pascals-triangle-4.hs new file mode 100644 index 0000000000..daf4216194 --- /dev/null +++ b/Task/Pascals-triangle/Haskell/pascals-triangle-4.hs @@ -0,0 +1,2 @@ +*Main> take 6 pascal +[[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1],[1,5,10,10,5,1]] diff --git a/Task/Pascals-triangle/Haskell/pascals-triangle-5.hs b/Task/Pascals-triangle/Haskell/pascals-triangle-5.hs new file mode 100644 index 0000000000..cc01b2a6e9 --- /dev/null +++ b/Task/Pascals-triangle/Haskell/pascals-triangle-5.hs @@ -0,0 +1,5 @@ +-- generate next row from current row +nextRow row = zipWith (+) ([0] ++ row) (row ++ [0]) + +-- returns the first n rows +pascal = iterate nextRow [1] diff --git a/Task/Pascals-triangle/Haskell/pascals-triangle-6.hs b/Task/Pascals-triangle/Haskell/pascals-triangle-6.hs new file mode 100644 index 0000000000..e62970e79f --- /dev/null +++ b/Task/Pascals-triangle/Haskell/pascals-triangle-6.hs @@ -0,0 +1,5 @@ +fac = product . enumFromTo 1 + +binCoef n k = (fac n) `div` ((fac k) * (fac $ n - k)) + +pascal n = map (binCoef $ n - 1) [0..n-1] diff --git a/Task/Pascals-triangle/Haskell/pascals-triangle-7.hs b/Task/Pascals-triangle/Haskell/pascals-triangle-7.hs new file mode 100644 index 0000000000..ad74065521 --- /dev/null +++ b/Task/Pascals-triangle/Haskell/pascals-triangle-7.hs @@ -0,0 +1,11 @@ +*Main> putStr $ unlines $ map unwords $ map (map show) $ pascal 10 +1 +1 1 +1 2 1 +1 3 3 1 +1 4 6 4 1 +1 5 10 10 5 1 +1 6 15 20 15 6 1 +1 7 21 35 35 21 7 1 +1 8 28 56 70 56 28 8 1 +1 9 36 84 126 126 84 36 9 1 diff --git a/Task/Pascals-triangle/HicEst/pascals-triangle.hicest b/Task/Pascals-triangle/HicEst/pascals-triangle.hicest new file mode 100644 index 0000000000..36c742eb04 --- /dev/null +++ b/Task/Pascals-triangle/HicEst/pascals-triangle.hicest @@ -0,0 +1,15 @@ + CALL Pascal(30) + +SUBROUTINE Pascal(rows) + CHARACTER fmt*6 + WRITE(Text=fmt, Format='"i", i5.5') 1+rows/4 + + DO row = 0, rows-1 + n = 1 + DO k = 0, row + col = rows*(rows-row+2*k)/4 + WRITE(Row=row+1, Column=col, F=fmt) n + n = n * (row - k) / (k + 1) + ENDDO + ENDDO +END diff --git a/Task/Pascals-triangle/IDL/pascals-triangle.idl b/Task/Pascals-triangle/IDL/pascals-triangle.idl new file mode 100644 index 0000000000..e066eec043 --- /dev/null +++ b/Task/Pascals-triangle/IDL/pascals-triangle.idl @@ -0,0 +1,17 @@ +Pro Pascal, n +;n is the number of lines of the triangle to be displayed + r=[1] + print, r + for i=0, (n-2) do begin + pascalrow,r + endfor +End + +Pro PascalRow, r + for i=0,(n_elements(r)-2) do begin + r[i]=r[i]+r[i+1] + endfor +r= [1, r] +print, r + +End diff --git a/Task/Pascals-triangle/Icon/pascals-triangle.icon b/Task/Pascals-triangle/Icon/pascals-triangle.icon new file mode 100644 index 0000000000..e3530fadcd --- /dev/null +++ b/Task/Pascals-triangle/Icon/pascals-triangle.icon @@ -0,0 +1,20 @@ +link math + +procedure main(A) +every n := !A do { # for each command line argument + n := integer(\n) | &null + pascal(n) + } +end + +procedure pascal(n) #: Pascal triangle + /n := 16 + write("width=", n, " height=", n) # carpet header + fw := *(2 ^ n)+1 + every i := 0 to n - 1 do { + writes(repl(" ",fw*(n-i)/2)) + every j := 0 to n - 1 do + writes(center(binocoef(i, j),fw) | break) + write() + } +end diff --git a/Task/Pascals-triangle/J/pascals-triangle-1.j b/Task/Pascals-triangle/J/pascals-triangle-1.j new file mode 100644 index 0000000000..4e07dcfc0c --- /dev/null +++ b/Task/Pascals-triangle/J/pascals-triangle-1.j @@ -0,0 +1,6 @@ + !~/~ i.5 +1 0 0 0 0 +1 1 0 0 0 +1 2 1 0 0 +1 3 3 1 0 +1 4 6 4 1 diff --git a/Task/Pascals-triangle/J/pascals-triangle-2.j b/Task/Pascals-triangle/J/pascals-triangle-2.j new file mode 100644 index 0000000000..1f2f0eae9f --- /dev/null +++ b/Task/Pascals-triangle/J/pascals-triangle-2.j @@ -0,0 +1,6 @@ + ([: ":@-.&0"1 !~/~)@i. 5 +1 +1 1 +1 2 1 +1 3 3 1 +1 4 6 4 1 diff --git a/Task/Pascals-triangle/J/pascals-triangle-3.j b/Task/Pascals-triangle/J/pascals-triangle-3.j new file mode 100644 index 0000000000..4eb495aa91 --- /dev/null +++ b/Task/Pascals-triangle/J/pascals-triangle-3.j @@ -0,0 +1,6 @@ + (-@|. |."_1 [: ":@-.&0"1 !~/~)@i. 5 + 1 + 1 1 + 1 2 1 + 1 3 3 1 + 1 4 6 4 1 diff --git a/Task/Pascals-triangle/Java/pascals-triangle-1.java b/Task/Pascals-triangle/Java/pascals-triangle-1.java new file mode 100644 index 0000000000..d9f77bec05 --- /dev/null +++ b/Task/Pascals-triangle/Java/pascals-triangle-1.java @@ -0,0 +1,21 @@ +import java.util.ArrayList; +...//class definition, etc. +public static void genPyrN(int rows){ + if(rows < 0) return; + //save the last row here + ArrayList last = new ArrayList(); + last.add(1); + System.out.println(last); + for(int i= 1;i <= rows;++i){ + //work on the next row + ArrayList thisRow= new ArrayList(); + thisRow.add(last.get(0)); //beginning + for(int j= 1;j < i;++j){//loop the number of elements in this row + //sum from the last row + thisRow.add(last.get(j - 1) + last.get(j)); + } + thisRow.add(last.get(0)); //end + last= thisRow;//save this row + System.out.println(thisRow); + } +} diff --git a/Task/Pascals-triangle/Java/pascals-triangle-2.java b/Task/Pascals-triangle/Java/pascals-triangle-2.java new file mode 100644 index 0000000000..e596812e47 --- /dev/null +++ b/Task/Pascals-triangle/Java/pascals-triangle-2.java @@ -0,0 +1,27 @@ +public class Pas{ + public static void main(String[] args){ + //usage + pas(20); + } + + public static void pas(int rows){ + for(int i = 0; i < rows; i++){ + for(int j = 0; j <= i; j++){ + System.out.print(ncr(i, j) + " "); + } + System.out.println(); + } + } + + public static long ncr(int n, int r){ + return fact(n) / (fact(r) * fact(n - r)); + } + + public static long fact(int n){ + long ans = 1; + for(int i = 2; i <= n; i++){ + ans *= i; + } + return ans; + } +} diff --git a/Task/Pascals-triangle/Java/pascals-triangle-3.java b/Task/Pascals-triangle/Java/pascals-triangle-3.java new file mode 100644 index 0000000000..5886fe6a89 --- /dev/null +++ b/Task/Pascals-triangle/Java/pascals-triangle-3.java @@ -0,0 +1,19 @@ +public class Pascal { + private static void printPascalLine (int n) { + if (n < 1) + return; + int m = 1; + System.out.print("1 "); + for (int j=1; j= 1) { + d++; + n /= b; + } + return d; + } + + // Calculate max spaces needed + var spacing = digits(this.triangle[this.rows-1][Math.round(this.rows/2)],base); + + // Private method to add spacing between numbers + var insertSpaces = function(s) { + var buf = ""; + while (s > 0) { + s--; + buf += " "; + } + return buf; + } + + // Print the triangle line by line + for (var r = 0; r < this.triangle.length; r++) { + var l = ""; + for (var s = 0; s < Math.round(this.rows-1-r); s++) { + l += insertSpaces(spacing); + } + for (var i = 0; i < this.triangle[r].length; i++) { + if (i != 0) + l += insertSpaces(spacing-Math.ceil(digits(this.triangle[r][i],base)/2)); + l += this.triangle[r][i].toString(base); + if (i < this.triangle[r].length-1) + l += insertSpaces(spacing-Math.floor(digits(this.triangle[r][i],base)/2)); + } + print(l); + } + } + +} + +// Display 4 row triangle in base 10 +var tri = new pascalTriangle(4); +tri.print(); +// Display 8 row triangle in base 16 +tri = new pascalTriangle(8); +tri.print(16); diff --git a/Task/Pascals-triangle/K/pascals-triangle.k b/Task/Pascals-triangle/K/pascals-triangle.k new file mode 100644 index 0000000000..61e91a77fb --- /dev/null +++ b/Task/Pascals-triangle/K/pascals-triangle.k @@ -0,0 +1,9 @@ + pascal:{(x-1){+':0,x,0}\1} + + pascal 6 +(1 + 1 1 + 1 2 1 + 1 3 3 1 + 1 4 6 4 1 + 1 5 10 10 5 1) diff --git a/Task/Pascals-triangle/Liberty-BASIC/pascals-triangle.liberty b/Task/Pascals-triangle/Liberty-BASIC/pascals-triangle.liberty new file mode 100644 index 0000000000..5b6b7b45f8 --- /dev/null +++ b/Task/Pascals-triangle/Liberty-BASIC/pascals-triangle.liberty @@ -0,0 +1,19 @@ +input "How much rows would you like? "; n +dim a$(n) + +for i= 0 to n + c = 1 + o$ ="" + for k =0 to i + o$ =o$ ; c; " " + c =c *(i-k)/(k+1) + next k + a$(i)=o$ +next i + +maxLen = len(a$(n)) +for i= 0 to n + print space$((maxLen-len(a$(i)))/2);a$(i) +next i + +end diff --git a/Task/Pascals-triangle/Locomotive-Basic/pascals-triangle.locomotive b/Task/Pascals-triangle/Locomotive-Basic/pascals-triangle.locomotive new file mode 100644 index 0000000000..de14811ed3 --- /dev/null +++ b/Task/Pascals-triangle/Locomotive-Basic/pascals-triangle.locomotive @@ -0,0 +1,12 @@ +10 CLS +20 INPUT "Number of rows? ", rows:GOSUB 40 +30 END +40 FOR i=0 TO rows-1 +50 c=1 +60 FOR k=0 TO i +70 PRINT USING "####";c; +80 c=c*(i-k)/(k+1) +90 NEXT +100 PRINT +110 NEXT +120 RETURN diff --git a/Task/Pascals-triangle/Logo/pascals-triangle.logo b/Task/Pascals-triangle/Logo/pascals-triangle.logo new file mode 100644 index 0000000000..2498089211 --- /dev/null +++ b/Task/Pascals-triangle/Logo/pascals-triangle.logo @@ -0,0 +1,7 @@ +to pascal :n + if :n = 1 [output [1]] + localmake "a pascal :n-1 + output (sentence first :a (map "sum butfirst :a butlast :a) last :a) +end + +for [i 1 10] [print pascal :i] diff --git a/Task/Pascals-triangle/Lua/pascals-triangle.lua b/Task/Pascals-triangle/Lua/pascals-triangle.lua new file mode 100644 index 0000000000..6ff5769ae8 --- /dev/null +++ b/Task/Pascals-triangle/Lua/pascals-triangle.lua @@ -0,0 +1,14 @@ +function nextrow(t) + local ret = {} + t[0], t[#t+1] = 0, 0 + for i = 1, #t do ret[i] = t[i-1] + t[i] end + return ret +end + +function triangle(n) + t = {1} + for i = 1, n do + print(unpack(t)) + t = nextrow(t) + end +end diff --git a/Task/Pascals-triangle/MATLAB/pascals-triangle-1.m b/Task/Pascals-triangle/MATLAB/pascals-triangle-1.m new file mode 100644 index 0000000000..5d2d9c3a4b --- /dev/null +++ b/Task/Pascals-triangle/MATLAB/pascals-triangle-1.m @@ -0,0 +1 @@ +pascal(n); diff --git a/Task/Pascals-triangle/MATLAB/pascals-triangle-2.m b/Task/Pascals-triangle/MATLAB/pascals-triangle-2.m new file mode 100644 index 0000000000..da3e35b813 --- /dev/null +++ b/Task/Pascals-triangle/MATLAB/pascals-triangle-2.m @@ -0,0 +1 @@ + binomCoeff = diag(rot90(pascal(n)))', diff --git a/Task/Pascals-triangle/Mathematica/pascals-triangle.math b/Task/Pascals-triangle/Mathematica/pascals-triangle.math new file mode 100644 index 0000000000..798f3bd81b --- /dev/null +++ b/Task/Pascals-triangle/Mathematica/pascals-triangle.math @@ -0,0 +1,2 @@ +Column[StringReplace[ToString /@ Replace[MatrixExp[SparseArray[ +{Band[{2,1}] -> Range[n-1]},{n,n}]],{x__,0..}->{x},2] ,{"{"|"}"|","->" "}], Center] diff --git a/Task/Pascals-triangle/Maxima/pascals-triangle.maxima b/Task/Pascals-triangle/Maxima/pascals-triangle.maxima new file mode 100644 index 0000000000..a18dd8f424 --- /dev/null +++ b/Task/Pascals-triangle/Maxima/pascals-triangle.maxima @@ -0,0 +1,12 @@ +sjoin(v, j) := apply(sconcat, rest(join(makelist(j, length(v)), v)))$ + +display_pascal_triangle(n) := for i from 0 thru 6 do disp(sjoin(makelist(binomial(i, j), j, 0, i), " ")); + +display_pascal_triangle(6); +/* "1" + "1 1" + "1 2 1" + "1 3 3 1" + "1 4 6 4 1" + "1 5 10 10 5 1" + "1 6 15 20 15 6 1" */ diff --git a/Task/Pascals-triangle/Metafont/pascals-triangle.metafont b/Task/Pascals-triangle/Metafont/pascals-triangle.metafont new file mode 100644 index 0000000000..4781313d86 --- /dev/null +++ b/Task/Pascals-triangle/Metafont/pascals-triangle.metafont @@ -0,0 +1,18 @@ +vardef bincoeff(expr n, k) = +save ?; +? := (1 for i=(max(k,n-k)+1) upto n: * i endfor ) + / (1 for i=2 upto min(k, n-k): * i endfor); ? +enddef; + +def pascaltr expr c = + string s_; + for i := 0 upto (c-1): + s_ := "" for k=0 upto (c-i): & " " endfor; + s_ := s_ for k=0 upto i: & decimal(bincoeff(i,k)) + & " " if bincoeff(i,k)<9: & " " fi endfor; + message s_; + endfor +enddef; + +pascaltr(4); +end diff --git a/Task/Pascals-triangle/Nial/pascals-triangle-1.nial b/Task/Pascals-triangle/Nial/pascals-triangle-1.nial new file mode 100644 index 0000000000..982e795ada --- /dev/null +++ b/Task/Pascals-triangle/Nial/pascals-triangle-1.nial @@ -0,0 +1,5 @@ +factorial is recur [ 0 =, 1 first, pass, product, -1 +] +combination is fork [ > [first, second], 0 first, + / [factorial second, * [factorial - [second, first], factorial first] ] +] +pascal is transpose each combination cart [pass, pass] tell diff --git a/Task/Pascals-triangle/Nial/pascals-triangle-2.nial b/Task/Pascals-triangle/Nial/pascals-triangle-2.nial new file mode 100644 index 0000000000..330ad57fc6 --- /dev/null +++ b/Task/Pascals-triangle/Nial/pascals-triangle-2.nial @@ -0,0 +1,2 @@ +|loaddefs 'pascal.nial' +|pascal 5 diff --git a/Task/Pascals-triangle/OCaml/pascals-triangle.ocaml b/Task/Pascals-triangle/OCaml/pascals-triangle.ocaml new file mode 100644 index 0000000000..f40ab3a693 --- /dev/null +++ b/Task/Pascals-triangle/OCaml/pascals-triangle.ocaml @@ -0,0 +1,10 @@ +(* generate next row from current row *) +let next_row row = + List.map2 (+) ([0] @ row) (row @ [0]) + +(* returns the first n rows *) +let pascal n = + let rec loop i row = + if i = n then [] + else row :: loop (i+1) (next_row row) + in loop 0 [1] diff --git a/Task/Pascals-triangle/Octave/pascals-triangle.octave b/Task/Pascals-triangle/Octave/pascals-triangle.octave new file mode 100644 index 0000000000..1fe07b773d --- /dev/null +++ b/Task/Pascals-triangle/Octave/pascals-triangle.octave @@ -0,0 +1,13 @@ +function pascaltriangle(h) + for i = 0:h-1 + for k = 0:h-i + printf(" "); + endfor + for j = 0:i + printf("%3d ", bincoeff(i, j)); + endfor + printf("\n"); + endfor +endfunction + +pascaltriangle(4); diff --git a/Task/Pascals-triangle/Oz/pascals-triangle.oz b/Task/Pascals-triangle/Oz/pascals-triangle.oz new file mode 100644 index 0000000000..966735345c --- /dev/null +++ b/Task/Pascals-triangle/Oz/pascals-triangle.oz @@ -0,0 +1,31 @@ +declare + fun {NextLine Xs} + {List.zip 0|Xs {Append Xs [0]} + fun {$ Left Right} + Left + Right + end} + end + + fun {Triangle N} + {List.take {Iterate [1] NextLine} N} + end + + fun lazy {Iterate I F} + I|{Iterate {F I} F} + end + + %% Only works nicely for N =< 5. + proc {PrintTriangle T} + N = {Length T} + in + for + Line in T + Indent in N-1..0;~1 + do + for _ in 1..Indent do {System.printInfo " "} end + for L in Line do {System.printInfo L#" "} end + {System.printInfo "\n"} + end + end +in + {PrintTriangle {Triangle 5}} diff --git a/Task/Pascals-triangle/PARI-GP/pascals-triangle.pari b/Task/Pascals-triangle/PARI-GP/pascals-triangle.pari new file mode 100644 index 0000000000..81a8c1a795 --- /dev/null +++ b/Task/Pascals-triangle/PARI-GP/pascals-triangle.pari @@ -0,0 +1,15 @@ +pascals_triangle(N)= { +my(row=[],prevrow=[]); +for(x=1,N, + if(x>5,break(1)); + row=eval(Vec(Str(11^(x-1)))); + print(row)); +prevrow=row; +for(y=6,N, + for(p=2,#prevrow, + row[p]=prevrow[p-1]+prevrow[p]); + row=concat(row,1); + prevrow=row; + print(row); + ); +} diff --git a/Task/Pascals-triangle/PHP/pascals-triangle.php b/Task/Pascals-triangle/PHP/pascals-triangle.php new file mode 100644 index 0000000000..95c5c87e09 --- /dev/null +++ b/Task/Pascals-triangle/PHP/pascals-triangle.php @@ -0,0 +1,23 @@ +function pascalsTriangle($num){ + $c = 1; + $triangle = Array(); + for($i=0;$i<=$num;$i++){ + $triangle[$i] = Array(); + if(!isset($triangle[$i-1])){ + $triangle[$i][] = $c; + }else{ + for($j=0;$j'; +} diff --git a/Task/Pascals-triangle/PL-I/pascals-triangle-1.pli b/Task/Pascals-triangle/PL-I/pascals-triangle-1.pli new file mode 100644 index 0000000000..e258e4c6e3 --- /dev/null +++ b/Task/Pascals-triangle/PL-I/pascals-triangle-1.pli @@ -0,0 +1,15 @@ +declare (t, u)(40) fixed binary; +declare (i, n) fixed binary; + +t,u = 0; +get (n); +if n <= 0 then return; + +do n = 1 to n; + u(1) = 1; + do i = 1 to n; + u(i+1) = t(i) + t(i+1); + end; + put skip edit ((u(i) do i = 1 to n)) (col(40-2*n), (n+1) f(4)); + t = u; +end; diff --git a/Task/Pascals-triangle/PL-I/pascals-triangle-2.pli b/Task/Pascals-triangle/PL-I/pascals-triangle-2.pli new file mode 100644 index 0000000000..b1f3798d11 --- /dev/null +++ b/Task/Pascals-triangle/PL-I/pascals-triangle-2.pli @@ -0,0 +1,11 @@ + 1 + 1 1 + 1 2 1 + 1 3 3 1 + 1 4 6 4 1 + 1 5 10 10 5 1 + 1 6 15 20 15 6 1 + 1 7 21 35 35 21 7 1 + 1 8 28 56 70 56 28 8 1 + 1 9 36 84 126 126 84 36 9 1 + 1 10 45 120 210 252 210 120 45 10 1 diff --git a/Task/Pascals-triangle/Pascal/pascals-triangle.pascal b/Task/Pascals-triangle/Pascal/pascals-triangle.pascal new file mode 100644 index 0000000000..55913b93be --- /dev/null +++ b/Task/Pascals-triangle/Pascal/pascals-triangle.pascal @@ -0,0 +1,21 @@ +Program PascalsTriangle(output); + +procedure Pascal(r : Integer); + var + i, c, k : Integer; + begin + for i := 0 to r-1 do + begin + c := 1; + for k := 0 to i do + begin + write(c:3); + c := (c * (i-k)) div (k+1); + end; + writeln; + end; +end; + +begin + Pascal(9) +end. diff --git a/Task/Pascals-triangle/Perl-6/pascals-triangle-1.pl6 b/Task/Pascals-triangle/Perl-6/pascals-triangle-1.pl6 new file mode 100644 index 0000000000..83b2981248 --- /dev/null +++ b/Task/Pascals-triangle/Perl-6/pascals-triangle-1.pl6 @@ -0,0 +1,7 @@ +multi pascal (1) { [1] } +multi pascal (Int $n where 2..*) { + my @rows = pascal $n - 1; + @rows, [0, @rows[*-1][] Z+ @rows[*-1][], 0 )]; +} + +say .perl for pascal 10; diff --git a/Task/Pascals-triangle/Perl-6/pascals-triangle-2.pl6 b/Task/Pascals-triangle/Perl-6/pascals-triangle-2.pl6 new file mode 100644 index 0000000000..2ce8abccb1 --- /dev/null +++ b/Task/Pascals-triangle/Perl-6/pascals-triangle-2.pl6 @@ -0,0 +1,8 @@ +sub pascal ($n where $n >= 1) { + # Prints out $n rows of Pascal's triangle. + say my @last = 1; + for 1 .. $n - 1 -> $row { + my @this = map { @last[$_] + @last[$_ + 1] }, 0 .. $row - 2; + say @last = 1, @this, 1; + } +} diff --git a/Task/Pascals-triangle/Perl-6/pascals-triangle-3.pl6 b/Task/Pascals-triangle/Perl-6/pascals-triangle-3.pl6 new file mode 100644 index 0000000000..cab239edde --- /dev/null +++ b/Task/Pascals-triangle/Perl-6/pascals-triangle-3.pl6 @@ -0,0 +1,3 @@ +sub pascal { [1], -> @p { [0, @p Z+ @p, 0] } ... * } + +.say for pascal[^10]; diff --git a/Task/Pascals-triangle/Perl-6/pascals-triangle-4.pl6 b/Task/Pascals-triangle/Perl-6/pascals-triangle-4.pl6 new file mode 100644 index 0000000000..7f464d8c7a --- /dev/null +++ b/Task/Pascals-triangle/Perl-6/pascals-triangle-4.pl6 @@ -0,0 +1,3 @@ +constant Pascal = [1], -> @p { [0, @p Z+ @p, 0] } ... *; + +.say for Pascal[^10]; diff --git a/Task/Pascals-triangle/Perl/pascals-triangle-1.pl b/Task/Pascals-triangle/Perl/pascals-triangle-1.pl new file mode 100644 index 0000000000..c5eefc362b --- /dev/null +++ b/Task/Pascals-triangle/Perl/pascals-triangle-1.pl @@ -0,0 +1,13 @@ +sub pascal +# Prints out $n rows of Pascal's triangle. It returns undef for +# failure and 1 for success. + {my $n = shift; + $n < 1 and return undef; + print "1\n"; + $n == 1 and return 1; + my @last = (1); + foreach my $row (1 .. $n - 1) + {my @this = map {$last[$_] + $last[$_ + 1]} 0 .. $row - 2; + @last = (1, @this, 1); + print join(' ', @last), "\n";} + return 1;} diff --git a/Task/Pascals-triangle/Perl/pascals-triangle-2.pl b/Task/Pascals-triangle/Perl/pascals-triangle-2.pl new file mode 100644 index 0000000000..d9b21064c3 --- /dev/null +++ b/Task/Pascals-triangle/Perl/pascals-triangle-2.pl @@ -0,0 +1,3 @@ +use bignum; +sub pascal { $_[0] ? unpack "A(A6)*", 1000001**$_[0] : 1 } +print "@{[map -+-$_, pascal $_]}\n" for 0..22; diff --git a/Task/Pascals-triangle/PicoLisp/pascals-triangle.l b/Task/Pascals-triangle/PicoLisp/pascals-triangle.l new file mode 100644 index 0000000000..4462deb8ad --- /dev/null +++ b/Task/Pascals-triangle/PicoLisp/pascals-triangle.l @@ -0,0 +1,8 @@ +(de pascalTriangle (N) + (for I N + (space (* 2 (- N I))) + (let C 1 + (for K I + (prin (align 3 C) " ") + (setq C (*/ C (- I K) K)) ) ) + (prinl) ) ) diff --git a/Task/Pascals-triangle/PowerShell/pascals-triangle.psh b/Task/Pascals-triangle/PowerShell/pascals-triangle.psh new file mode 100644 index 0000000000..b483f5836c --- /dev/null +++ b/Task/Pascals-triangle/PowerShell/pascals-triangle.psh @@ -0,0 +1,64 @@ +$Infinity = 1 +$NewNumbers = $null +$Numbers = $null +$Result = $null +$Number = $null +$Power = $args[0] + +Write-Host $Power + +For( + $i=0; + $i -lt $Infinity; + $i++ + ) + { + $Numbers = New-Object Object[] 1 + $Numbers[0] = $Power + For( + $k=0; + $k -lt $NewNumbers.Length; + $k++ + ) + { + $Numbers = $Numbers + $NewNumbers[$k] + } + If( + $i -eq 0 + ) + { + $Numbers = $Numbers + $Power + } + $NewNumbers = New-Object Object[] 0 + Try + { + For( + $j=0; + $j -lt $Numbers.Length; + $j++ + ) + { + $Result = $Numbers[$j] + $Numbers[$j+1] + $NewNumbers = $NewNumbers + $Result + } + } + Catch [System.Management.Automation.RuntimeException] + { + Write-Warning "Value was too large for a Decimal. Script aborted." + Break; + } + Foreach( + $Number in $Numbers + ) + { + If( + $Number.ToString() -eq "+unendlich" + ) + { + Write-Warning "Value was too large for a Decimal. Script aborted." + Exit + } + } + Write-Host $Numbers + $Infinity++ + } diff --git a/Task/Pascals-triangle/Prolog/pascals-triangle-1.pro b/Task/Pascals-triangle/Prolog/pascals-triangle-1.pro new file mode 100644 index 0000000000..91c8f606cb --- /dev/null +++ b/Task/Pascals-triangle/Prolog/pascals-triangle-1.pro @@ -0,0 +1,36 @@ +pascal(N) :- + pascal(1, N, [1], [[1]|X]-X, L), + maplist(my_format, L). + +pascal(Max, Max, L, LC, LF) :- + !, + make_new_line(L, NL), + append_dl(LC, [NL|X]-X, LF-[]). + +pascal(N, Max, L, NC, LF) :- + build_new_line(L, NL), + append_dl(NC, [NL|X]-X, NC1), + N1 is N+1, + pascal(N1, Max, NL, NC1, LF). + +build_new_line(L, R) :- + build(L, 0, X-X, R). + +build([], V, RC, RF) :- + append_dl(RC, [V|Y]-Y, RF-[]). + +build([H|T], V, RC, R) :- + V1 is V+H, + append_dl(RC, [V1|Y]-Y, RC1), + build(T, H, RC1, R). + +append_dl(X1-X2, X2-X3, X1-X3). + +% to have a correct output ! +my_format([H|T]) :- + write(H), + maplist(my_writef, T), + nl. + +my_writef(X) :- + writef(' %5r', [X]). diff --git a/Task/Pascals-triangle/Prolog/pascals-triangle-2.pro b/Task/Pascals-triangle/Prolog/pascals-triangle-2.pro new file mode 100644 index 0000000000..c7c958ed11 --- /dev/null +++ b/Task/Pascals-triangle/Prolog/pascals-triangle-2.pro @@ -0,0 +1,18 @@ + ?- pascal(15). +1 +1 1 +1 2 1 +1 3 3 1 +1 4 6 4 1 +1 5 10 10 5 1 +1 6 15 20 15 6 1 +1 7 21 35 35 21 7 1 +1 8 28 56 70 56 28 8 1 +1 9 36 84 126 126 84 36 9 1 +1 10 45 120 210 252 210 120 45 10 1 +1 11 55 165 330 462 462 330 165 55 11 1 +1 12 66 220 495 792 924 792 495 220 66 12 1 +1 13 78 286 715 1287 1716 1716 1287 715 286 78 13 1 +1 14 91 364 1001 2002 3003 3432 3003 2002 1001 364 91 14 1 +1 15 105 455 1365 3003 5005 6435 6435 5005 3003 1365 455 105 15 1 +true. diff --git a/Task/Pascals-triangle/PureBasic/pascals-triangle.purebasic b/Task/Pascals-triangle/PureBasic/pascals-triangle.purebasic new file mode 100644 index 0000000000..30e9d87850 --- /dev/null +++ b/Task/Pascals-triangle/PureBasic/pascals-triangle.purebasic @@ -0,0 +1,17 @@ +Procedure pascaltriangle( n.i) + + For i= 0 To n + c = 1 + For k=0 To i + Print(Str( c)+" ") + c = c * (i-k)/(k+1); + Next ;k + PrintN(" "); nächste zeile + Next ;i + +EndProcedure + +OpenConsole() +Parameter.i = Val(ProgramParameter(0)) +pascaltriangle(Parameter); +Input() diff --git a/Task/Pascals-triangle/Python/pascals-triangle-1.py b/Task/Pascals-triangle/Python/pascals-triangle-1.py new file mode 100644 index 0000000000..5d4abb6a44 --- /dev/null +++ b/Task/Pascals-triangle/Python/pascals-triangle-1.py @@ -0,0 +1,9 @@ +def pascal(n): + """Prints out n rows of Pascal's triangle. + It returns False for failure and True for success.""" + row = [1] + k = [0] + for x in range(max(n,0)): + print row + row=[l+r for l,r in zip(row+k,k+row)] + return n>=1 diff --git a/Task/Pascals-triangle/Python/pascals-triangle-2.py b/Task/Pascals-triangle/Python/pascals-triangle-2.py new file mode 100644 index 0000000000..9c7a620773 --- /dev/null +++ b/Task/Pascals-triangle/Python/pascals-triangle-2.py @@ -0,0 +1,17 @@ +def scan(op, seq, it): + a = [] + result = it + a.append(it) + for x in seq: + result = op(result, x) + a.append(result) + return a + +def pascal(n): + def nextrow(row, x): + return [l+r for l,r in zip(row+[0,],[0,]+row)] + + return scan(nextrow, range(n-1), [1,]) + +for row in pascal(4): + print(row) diff --git a/Task/Pascals-triangle/Qi/pascals-triangle.qi b/Task/Pascals-triangle/Qi/pascals-triangle.qi new file mode 100644 index 0000000000..55a7e83672 --- /dev/null +++ b/Task/Pascals-triangle/Qi/pascals-triangle.qi @@ -0,0 +1,9 @@ +(define iterate + _ _ 0 -> [] + F V N -> [V|(iterate F (F V) (1- N))]) + +(define next-row + R -> (MAPCAR + [0|R] (append R [0]))) + +(define pascal + N -> (iterate next-row [1] N)) diff --git a/Task/Pascals-triangle/R/pascals-triangle-1.r b/Task/Pascals-triangle/R/pascals-triangle-1.r new file mode 100644 index 0000000000..f33b7221b0 --- /dev/null +++ b/Task/Pascals-triangle/R/pascals-triangle-1.r @@ -0,0 +1,10 @@ +pascalTriangle <- function(h) { + for(i in 0:(h-1)) { + s <- "" + for(k in 0:(h-i)) s <- paste(s, " ", sep="") + for(j in 0:i) { + s <- paste(s, sprintf("%3d ", choose(i, j)), sep="") + } + print(s) + } +} diff --git a/Task/Pascals-triangle/R/pascals-triangle-2.r b/Task/Pascals-triangle/R/pascals-triangle-2.r new file mode 100644 index 0000000000..03f76598dd --- /dev/null +++ b/Task/Pascals-triangle/R/pascals-triangle-2.r @@ -0,0 +1,3 @@ +pascalTriangle <- function(h) { + lapply(0:h, function(i) choose(i, 0:i)) +} diff --git a/Task/Pascals-triangle/REXX/pascals-triangle.rexx b/Task/Pascals-triangle/REXX/pascals-triangle.rexx new file mode 100644 index 0000000000..72da471edc --- /dev/null +++ b/Task/Pascals-triangle/REXX/pascals-triangle.rexx @@ -0,0 +1,28 @@ +/*REXX program to display Pascal's triangle, neatly centered/formatted.*/ +/*AKA: Yang Hui's ▲, Khayyam-Pascal ▲, Kyayyam ▲, Tartaglia's ▲ */ +numeric digits 1000 /*let's be able to handle big ▲. */ +arg nn .; if nn=='' then nn=10; n=abs(nn) +a. = 1 /*if NN < 0, output is to a file.*/ +mx = !(n-1) / !(n%2) / !(n-1-n%2) /*MX =biggest number in triangle.*/ +w = length(mx) /* W =width of biggest number. */ +line. = 1 + + do row=1 for n; prev=row-1 + a.row.1 = 1 + do j=2 to row-1; jm=j-1 + a.row.j = a.prev.jm + a.prev.j + line.row = line.row right(a.row.j,w) + end /*j*/ + + if row\==1 then line.row=line.row right(1,w) /*append the last "1".*/ + end /*row*/ + +width=length(line.n) /*width of last line in triangle.*/ + + do L=1 for n /*show lines in Pascal's triangle*/ + if nn>0 then say center(line.L,width) /*either SAY or write.*/ + else call lineout 'PASCALS.'n, center(line.L,width) + end /*L*/ +exit /*stick a fork in it, we're done.*/ +/*─────────────────────────────────────! (factorial) subroutine─────────*/ +!: procedure; arg x;!=1;do j=2 to x;!=!*j;end;return ! /*calc. factorial*/ diff --git a/Task/Pascals-triangle/Racket/pascals-triangle.rkt b/Task/Pascals-triangle/Racket/pascals-triangle.rkt new file mode 100644 index 0000000000..e898c6f78a --- /dev/null +++ b/Task/Pascals-triangle/Racket/pascals-triangle.rkt @@ -0,0 +1,14 @@ +#lang racket + +(define (pascal n) + (define (next-row current-row) + (map + (cons 0 current-row) + (append current-row '(0)))) + (let-values + ([(previous-rows final-row) + (for/fold ([triangle null] + [row '(1)]) + ([row-number (in-range 1 n)]) + (values (cons row triangle) + (next-row row)))]) + (reverse (cons final-row previous-rows)))) diff --git a/Task/Pascals-triangle/RapidQ/pascals-triangle-1.rapidq b/Task/Pascals-triangle/RapidQ/pascals-triangle-1.rapidq new file mode 100644 index 0000000000..8fcfe8c111 --- /dev/null +++ b/Task/Pascals-triangle/RapidQ/pascals-triangle-1.rapidq @@ -0,0 +1,12 @@ +DEFINT values(100) = {0,1} + +INPUT "Number of rows: "; nrows +PRINT SPACE$((nrows)*3);" 1" +FOR row = 2 TO nrows + PRINT SPACE$((nrows-row)*3+1); + FOR i = row TO 1 STEP -1 + values(i) = values(i) + values(i-1) + PRINT FORMAT$("%5d ", values(i)); + NEXT i + PRINT +NEXT row diff --git a/Task/Pascals-triangle/RapidQ/pascals-triangle-2.rapidq b/Task/Pascals-triangle/RapidQ/pascals-triangle-2.rapidq new file mode 100644 index 0000000000..1a9f994081 --- /dev/null +++ b/Task/Pascals-triangle/RapidQ/pascals-triangle-2.rapidq @@ -0,0 +1,10 @@ +INPUT "Number of rows: "; nrows +FOR row = 0 TO nrows-1 + c = 1 + PRINT SPACE$((nrows-row)*3); + FOR i = 0 TO row + PRINT FORMAT$("%5d ", c); + c = c * (row - i) / (i+1) + NEXT i + PRINT +NEXT row diff --git a/Task/Pascals-triangle/Retro/pascals-triangle.retro b/Task/Pascals-triangle/Retro/pascals-triangle.retro new file mode 100644 index 0000000000..5d0dc85c77 --- /dev/null +++ b/Task/Pascals-triangle/Retro/pascals-triangle.retro @@ -0,0 +1,6 @@ +2 elements i j +: pascalTriangle + cr dup + [ dup !j 1 swap 1+ [ !i dup putn space @j @i - * @i 1+ / ] iter cr drop ] iter drop +; +13 pascalTriangle diff --git a/Task/Pascals-triangle/Ruby/pascals-triangle-1.rb b/Task/Pascals-triangle/Ruby/pascals-triangle-1.rb new file mode 100644 index 0000000000..235aa70da1 --- /dev/null +++ b/Task/Pascals-triangle/Ruby/pascals-triangle-1.rb @@ -0,0 +1,27 @@ +def pascal(n = 1) + + return if n < 1 + + # set up a new array of arrays with the first value + p = [[1]] + + # for n - 1 number of times, + (n - 1).times do |i| + + # inject a new array starting with [1] + p << p[i].inject([1]) do |result, elem| + + # if we've reached the end, tack on a 1. + # else, tack on current elem + previous elem + if p[i].length == result.length + result << 1 + else + result << elem + p[i][result.length] + end + end + end + + # and return the triangle. + p + +end diff --git a/Task/Pascals-triangle/Ruby/pascals-triangle-2.rb b/Task/Pascals-triangle/Ruby/pascals-triangle-2.rb new file mode 100644 index 0000000000..cdaf7791be --- /dev/null +++ b/Task/Pascals-triangle/Ruby/pascals-triangle-2.rb @@ -0,0 +1,3 @@ +def next_row row ; ([0] + row).zip(row + [0]).collect {|l,r| l + r }; end + +def pascal n ; ([nil] * n).inject([1]) {|x,y| y = next_row x } ; end diff --git a/Task/Pascals-triangle/Run-BASIC/pascals-triangle.run b/Task/Pascals-triangle/Run-BASIC/pascals-triangle.run new file mode 100644 index 0000000000..d51ffeb874 --- /dev/null +++ b/Task/Pascals-triangle/Run-BASIC/pascals-triangle.run @@ -0,0 +1,10 @@ +input "number of rows? ";r +for i = 0 to r - 1 + c = 1 + print left$(" ",(r*2)-(i*2)); + for k = 0 to i + print using("####",c); + c = c*(i-k)/(k+1) + next + print +next diff --git a/Task/Pascals-triangle/Scala/pascals-triangle-1.scala b/Task/Pascals-triangle/Scala/pascals-triangle-1.scala new file mode 100644 index 0000000000..8aa9596950 --- /dev/null +++ b/Task/Pascals-triangle/Scala/pascals-triangle-1.scala @@ -0,0 +1,5 @@ +def tri(row:Int):List[Int] = { row match { + case 1 => List(1) + case n:Int => List(1) ::: ((tri(n-1) zip tri(n-1).tail) map {case (a,b) => a+b}) ::: List(1) + } +} diff --git a/Task/Pascals-triangle/Scala/pascals-triangle-2.scala b/Task/Pascals-triangle/Scala/pascals-triangle-2.scala new file mode 100644 index 0000000000..9ed22218e5 --- /dev/null +++ b/Task/Pascals-triangle/Scala/pascals-triangle-2.scala @@ -0,0 +1,2 @@ +def prettytri(n:Int) = (1 to n) foreach {i=>print(" "*(n-i)); tri(i) map (c=>print(c+" ")); println} +prettytri(5) diff --git a/Task/Pascals-triangle/Scheme/pascals-triangle-1.ss b/Task/Pascals-triangle/Scheme/pascals-triangle-1.ss new file mode 100644 index 0000000000..eaa75c023e --- /dev/null +++ b/Task/Pascals-triangle/Scheme/pascals-triangle-1.ss @@ -0,0 +1,9 @@ +(define (next-row row) + (map + (cons 0 row) (append row '(0)))) + +(define (triangle row rows) + (if (= rows 0) + '() + (cons row (triangle (next-row row) (- rows 1))))) + +(triangle (list 1) 5) diff --git a/Task/Pascals-triangle/Scheme/pascals-triangle-2.ss b/Task/Pascals-triangle/Scheme/pascals-triangle-2.ss new file mode 100644 index 0000000000..e64d1e2c94 --- /dev/null +++ b/Task/Pascals-triangle/Scheme/pascals-triangle-2.ss @@ -0,0 +1 @@ +((1) (1 1) (1 2 1) (1 3 3 1) (1 4 6 4 1)) diff --git a/Task/Pascals-triangle/Seed7/pascals-triangle.seed7 b/Task/Pascals-triangle/Seed7/pascals-triangle.seed7 new file mode 100644 index 0000000000..8b70e990ac --- /dev/null +++ b/Task/Pascals-triangle/Seed7/pascals-triangle.seed7 @@ -0,0 +1,22 @@ +$ include "seed7_05.s7i"; + +const proc: main is func + local + var integer: numRows is 0; + var array integer: values is [] (0, 1); + var integer: row is 0; + var integer: index is 0; + begin + write("Number of rows: "); + readln(numRows); + writeln("1" lpad succ(numRows) * 3); + for row range 2 to numRows do + write("" lpad (numRows - row) * 3); + values &:= [] 0; + for index range succ(row) downto 2 do + values[index] +:= values[pred(index)]; + write(" " <& values[index] lpad 5); + end for; + writeln; + end for; + end func; diff --git a/Task/Pascals-triangle/Tcl/pascals-triangle-1.tcl b/Task/Pascals-triangle/Tcl/pascals-triangle-1.tcl new file mode 100644 index 0000000000..ade9b76f40 --- /dev/null +++ b/Task/Pascals-triangle/Tcl/pascals-triangle-1.tcl @@ -0,0 +1,18 @@ +proc pascal_iterative n { + if {$n < 1} {error "undefined behaviour for n < 1"} + set row [list 1] + lappend rows $row + set i 1 + while {[incr i] <= $n} { + set prev $row + set row [list 1] + for {set j 1} {$j < [llength $prev]} {incr j} { + lappend row [expr {[lindex $prev [expr {$j - 1}]] + [lindex $prev $j]}] + } + lappend row 1 + lappend rows $row + } + return $rows +} + +puts [join [pascal_iterative 6] \n] diff --git a/Task/Pascals-triangle/Tcl/pascals-triangle-2.tcl b/Task/Pascals-triangle/Tcl/pascals-triangle-2.tcl new file mode 100644 index 0000000000..7e7aedb201 --- /dev/null +++ b/Task/Pascals-triangle/Tcl/pascals-triangle-2.tcl @@ -0,0 +1,15 @@ +proc pascal_coefficients n { + if {$n < 1} {error "undefined behaviour for n < 1"} + for {set i 0} {$i < $n} {incr i} { + set c 1 + set row [list $c] + for {set j 0} {$j < $i} {incr j} { + set c [expr {$c * ($i - $j) / ($j + 1)}] + lappend row $c + } + lappend rows $row + } + return $rows +} + +puts [join [pascal_coefficients 6] \n] diff --git a/Task/Pascals-triangle/Tcl/pascals-triangle-3.tcl b/Task/Pascals-triangle/Tcl/pascals-triangle-3.tcl new file mode 100644 index 0000000000..83cb8a4c43 --- /dev/null +++ b/Task/Pascals-triangle/Tcl/pascals-triangle-3.tcl @@ -0,0 +1,35 @@ +package require Tcl 8.5 + +proc pascal_combinations n { + if {$n < 1} {error "undefined behaviour for n < 1"} + for {set i 0} {$i < $n} {incr i} { + set row [list] + for {set j 0} {$j <= $i} {incr j} { + lappend row [C $i $j] + } + lappend rows $row + } + return $rows +} + +proc C {n k} { + expr {[ifact $n] / ([ifact $k] * [ifact [expr {$n - $k}]])} +} + +set fact_cache {1 1} +proc ifact n { + global fact_cache + if {$n < [llength $fact_cache]} { + return [lindex $fact_cache $n] + } + set i [expr {[llength $fact_cache] - 1}] + set sum [lindex $fact_cache $i] + while {$i < $n} { + incr i + set sum [expr {$sum * $i}] + lappend fact_cache $sum + } + return $sum +} + +puts [join [pascal_combinations 6] \n] diff --git a/Task/Pascals-triangle/Tcl/pascals-triangle-4.tcl b/Task/Pascals-triangle/Tcl/pascals-triangle-4.tcl new file mode 100644 index 0000000000..27f7415c8f --- /dev/null +++ b/Task/Pascals-triangle/Tcl/pascals-triangle-4.tcl @@ -0,0 +1,5 @@ +set n 100 +puts "calculate $n rows:" +foreach proc {pascal_iterative pascal_coefficients pascal_combinations} { + puts "$proc: [time [list $proc $n] 100]" +} diff --git a/Task/Pascals-triangle/Turing/pascals-triangle.turing b/Task/Pascals-triangle/Turing/pascals-triangle.turing new file mode 100644 index 0000000000..0fae500b7b --- /dev/null +++ b/Task/Pascals-triangle/Turing/pascals-triangle.turing @@ -0,0 +1,13 @@ +procedure pascal (n : int) + for i : 0 .. n + var c : int + c := 1 + for k : 0 .. i + put intstr(c) + " " .. + c := c * (i - k) div (k + 1) + end for + put "" + end for +end pascal + +pascal(5) diff --git a/Task/Pascals-triangle/Ursala/pascals-triangle-1.ursala b/Task/Pascals-triangle/Ursala/pascals-triangle-1.ursala new file mode 100644 index 0000000000..a8aeb13bb7 --- /dev/null +++ b/Task/Pascals-triangle/Ursala/pascals-triangle-1.ursala @@ -0,0 +1,4 @@ +#import std +#import nat + +pascal = choose**ziDS+ iota*t+ iota+ successor diff --git a/Task/Pascals-triangle/Ursala/pascals-triangle-2.ursala b/Task/Pascals-triangle/Ursala/pascals-triangle-2.ursala new file mode 100644 index 0000000000..a5d4d29190 --- /dev/null +++ b/Task/Pascals-triangle/Ursala/pascals-triangle-2.ursala @@ -0,0 +1,4 @@ +#import std +#import nat + +pascal "n" = (next"n" sum*NiCixp) <1> diff --git a/Task/Pascals-triangle/Ursala/pascals-triangle-3.ursala b/Task/Pascals-triangle/Ursala/pascals-triangle-3.ursala new file mode 100644 index 0000000000..9945d05ab9 --- /dev/null +++ b/Task/Pascals-triangle/Ursala/pascals-triangle-3.ursala @@ -0,0 +1,3 @@ +#cast %nLL + +example = pascal 10 diff --git a/Task/Pascals-triangle/Vedit-macro-language/pascals-triangle-1.vedit b/Task/Pascals-triangle/Vedit-macro-language/pascals-triangle-1.vedit new file mode 100644 index 0000000000..9a37c33819 --- /dev/null +++ b/Task/Pascals-triangle/Vedit-macro-language/pascals-triangle-1.vedit @@ -0,0 +1,13 @@ +#100 = Get_Num("Number of rows: ", STATLINE) +#0=0; #1=1 +Ins_Char(' ', COUNT, #100*3-2) Num_Ins(1) +for (#99 = 2; #99 <= #100; #99++) { + Ins_Char(' ', COUNT, (#100-#99)*3) + #@99 = 0 + for (#98 = #99; #98 > 0; #98--) { + #97 = #98-1 + #@98 += #@97 + Num_Ins(#@98, COUNT, 6) + } + Ins_Newline +} diff --git a/Task/Pascals-triangle/Vedit-macro-language/pascals-triangle-2.vedit b/Task/Pascals-triangle/Vedit-macro-language/pascals-triangle-2.vedit new file mode 100644 index 0000000000..d002b0b312 --- /dev/null +++ b/Task/Pascals-triangle/Vedit-macro-language/pascals-triangle-2.vedit @@ -0,0 +1,10 @@ +#1 = Get_Num("Number of rows: ", STATLINE) +for (#2 = 0; #2 < #1; #2++) { + #3 = 1 + Ins_Char(' ', COUNT, (#1-#2-1)*3) + for (#4 = 0; #4 <= #2; #4++) { + Num_Ins(#3, COUNT, 6) + #3 = #3 * (#2-#4) / (#4+1) + } + Ins_Newline +} diff --git a/Task/Pascals-triangle/XPL0/pascals-triangle.xpl0 b/Task/Pascals-triangle/XPL0/pascals-triangle.xpl0 new file mode 100644 index 0000000000..0d2e4f146d --- /dev/null +++ b/Task/Pascals-triangle/XPL0/pascals-triangle.xpl0 @@ -0,0 +1,22 @@ +include c:\cxpl\codes; + +proc Pascal(N); \Display the first N rows of Pascal's triangle +int N; \if N<=0 then nothing is displayed +int Row, I, Old(40), New(40); +[for Row:= 0 to N-1 do + [New(0):= 1; + for I:= 1 to Row do New(I):= Old(I-1) + Old(I); + for I:= 1 to (N-Row-1)*2 do ChOut(0, ^ ); + for I:= 0 to Row do + [if New(I)<100 then ChOut(0, ^ ); + IntOut(0, New(I)); + if New(I)<10 then ChOut(0, ^ ); + ChOut(0, ^ ); + ]; + New(Row+1):= 0; + I:= Old; Old:= New; New:= I; + CrLf(0); + ]; +]; + +Pascal(13) diff --git a/Task/Pattern-matching/0DESCRIPTION b/Task/Pattern-matching/0DESCRIPTION new file mode 100644 index 0000000000..7d59f784d4 --- /dev/null +++ b/Task/Pattern-matching/0DESCRIPTION @@ -0,0 +1,5 @@ +{{omit from|BBC BASIC}} + +Some languages offer direct support for [[wp:Algebraic_data_type|algebraic data types]] and pattern matching on them. While this of course can always be simulated with manual tagging and conditionals, it allows for terse code which is easy to read, and can represent the algorithm directly. + +As an example, implement insertion in a [[wp:Red_Black_Tree|red-black-tree]]. A red-black-tree is a binary tree where each internal node has a color attribute ''red'' or ''black''. Moreover, no red node can have a red child, and every path from the root to an empty node must contain the same number of black nodes. As a consequence, the tree is balanced, and must be re-balanced after an insertion. diff --git a/Task/Pattern-matching/1META.yaml b/Task/Pattern-matching/1META.yaml new file mode 100644 index 0000000000..32d20151af --- /dev/null +++ b/Task/Pattern-matching/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Data Structures diff --git a/Task/Pattern-matching/Bracmat/pattern-matching-1.bracmat b/Task/Pattern-matching/Bracmat/pattern-matching-1.bracmat new file mode 100644 index 0000000000..fa25d8776d --- /dev/null +++ b/Task/Pattern-matching/Bracmat/pattern-matching-1.bracmat @@ -0,0 +1,47 @@ + ( balance + = a x b y c zd + . !arg + : ( B + . ( ( R + . ((R.?a,?x,?b),?y,?c) + | (?a,?x,(R.?b,?y,?c)) + ) + , ?zd + ) + | ( ?a + , ?x + , ( R + . ((R.?b,?y,?c),?zd) + | (?b,?y,(R.?c,?zd)) + ) + ) + ) + & (R.(B.!a,!x,!b),!y,(B.!c,!zd)) + | !arg + ) +& ( ins + = X tree a m z + . !arg:(?X.?tree) + & !tree:(?C.?a,?m,?z) + & ( !X:!m + & balance$(!C.!a,!m,ins$(!X.!z)) + | !tree + ) + | (R.,!X,) + ) +& ( insert + = X tree + . !arg:(?X.?tree) + & ins$(!X.!tree):(?.?X) + & (B.!X) + ) +& ( insertMany + = L R tree + . !arg:(%?L_%?R.?tree) + & insertMany$(!L.!tree):?tree + & insertMany$(!R.!tree) + | insert$!arg + ) +; diff --git a/Task/Pattern-matching/Bracmat/pattern-matching-2.bracmat b/Task/Pattern-matching/Bracmat/pattern-matching-2.bracmat new file mode 100644 index 0000000000..c332c17f9a --- /dev/null +++ b/Task/Pattern-matching/Bracmat/pattern-matching-2.bracmat @@ -0,0 +1,8 @@ + ( it allows for terse code which is easy to read + , and can represent the algorithm directly + . + ) + : ?values +& insertMany$(!values.):?tree +& out$!tree +& done; diff --git a/Task/Pattern-matching/Bracmat/pattern-matching-3.bracmat b/Task/Pattern-matching/Bracmat/pattern-matching-3.bracmat new file mode 100644 index 0000000000..3361cdf5ed --- /dev/null +++ b/Task/Pattern-matching/Bracmat/pattern-matching-3.bracmat @@ -0,0 +1,20 @@ + B +. ( B + . (R.(B.,,),algorithm,(B.,allows,)) + , and + , (B.,can,) + ) + , code + , ( R + . ( B + . (B.(R.,directly,),easy,) + , for + , (B.(R.,is,),it,) + ) + , read + , ( B + . (B.,represent,) + , terse + , (R.(B.,the,),to,(B.,which,)) + ) + ) diff --git a/Task/Pattern-matching/Common-Lisp/pattern-matching.lisp b/Task/Pattern-matching/Common-Lisp/pattern-matching.lisp new file mode 100644 index 0000000000..0b69a67a02 --- /dev/null +++ b/Task/Pattern-matching/Common-Lisp/pattern-matching.lisp @@ -0,0 +1,39 @@ +(mapc #'use-package '(#:toadstool #:toadstool-system)) +(defstruct (red-black-tree (:constructor tree (color left val right))) + color left val right) + +(defcomponent tree (operator macro-mixin)) +(defexpand tree (color left val right) + `(class red-black-tree red-black-tree-color ,color + red-black-tree-left ,left + red-black-tree-val ,val + red-black-tree-right ,right)) +(pushnew 'tree *used-components*) + +(defun balance (color left val right) + (toad-ecase (color left val right) + (('black (tree 'red (tree 'red a x b) y c) z d) + (tree 'red (tree 'black a x b) y + (tree 'black c z d))) + (('black (tree 'red a x (tree 'red b y c)) z d) + (tree 'red (tree 'black a x b) y (tree 'black c z d))) + (('black a x (tree 'red (tree 'red b y c) z d)) + (tree 'red (tree 'black a x b) y (tree 'black c z d))) + (('black a x (tree 'red b y (tree 'red c z d))) + (tree 'red (tree 'black a x b) y (tree 'black c z d))) + ((color a x b) + (tree color a x b)))) + +(defun %insert (x s) + (toad-ecase1 s + (nil (tree 'red nil x nil)) + ((tree color a y b) + (cond ((< x y) + (balance color (%insert x a) y b)) + ((> x y) + (balance color a y (%insert x b))) + (t s))))) + +(defun insert (x s) + (toad-ecase1 (%insert x s) + ((tree t a y b) (tree 'black a y b)))) diff --git a/Task/Pattern-matching/Haskell/pattern-matching.hs b/Task/Pattern-matching/Haskell/pattern-matching.hs new file mode 100644 index 0000000000..db8a0d08bb --- /dev/null +++ b/Task/Pattern-matching/Haskell/pattern-matching.hs @@ -0,0 +1,18 @@ +data Color = R | B +data Tree a = E | T Color (Tree a) a (Tree a) + +balance :: Color -> Tree a -> a -> Tree a -> Tree a +balance B (T R (T R a x b) y c ) z d = T R (T B a x b) y (T B c z d) +balance B (T R a x (T R b y c)) z d = T R (T B a x b) y (T B c z d) +balance B a x (T R (T R b y c) z d ) = T R (T B a x b) y (T B c z d) +balance B a x (T R b y (T R c z d)) = T R (T B a x b) y (T B c z d) +balance col a x b = T col a x b + +insert :: Ord a => a -> Tree a -> Tree a +insert x s = T B a y b where + ins E = T R E x E + ins s@(T col a y b) + | x < y = balance col (ins a) y b + | x > y = balance col a y (ins b) + | otherwise = s + T _ a y b = ins s diff --git a/Task/Pattern-matching/J/pattern-matching-1.j b/Task/Pattern-matching/J/pattern-matching-1.j new file mode 100644 index 0000000000..16b6ca35c2 --- /dev/null +++ b/Task/Pattern-matching/J/pattern-matching-1.j @@ -0,0 +1,196 @@ +help=: noun define +red-black tree +Store dictionary in red-black tree. The keys can be any noun. + +Reference: +Left-leaning Red-Black Trees +Robert Sedgewick +Department of Computer Science +Princeton University + +verbs: +insert key;value Inserts item into tree +delete key Deletes item with key from tree + Deletion via the Sedgewick method is fairly simple. + However, I elected to remove the KEY;VALUE pair + rather than change the tree. +find key Returns the associated definition or EMPTY +items any_noun Returns all the items as a rank 1 array of KEY;VALUE pairs +keys any_noun Returns all the keys as a rank 1 array of boxes +values any_noun Returns all the values as a rank 1 array of boxes + +J stores all data as arrays. +I chose to use array indexes to implement pointers. +An "index" is a rank 0 length 1 array. + +Internal data structure: + +T This rank 2 array stores indexes of left and right at each branch point. +C rank 1 array of node color. +H rank 1 array of the hash value of each key. +R rank 0 array stores the root index. +D rank 1 array of boxes. In each box is a rank 2 array of key value + pairs associated with the hash value. Hash collision invokes direct + lookup by key among the keys having same hash. + +Additional test idea (done): + Changing the hash to 0: or 2&| rapidly tests + hash collision code for integer keys. +) + +bitand=: (#. 1 0 0 0 1)b. +bitxor=: (#. 1 0 1 1 0)b. +hash=: [: ((4294967295) bitand (bitxor 1201&*))/ 846661 ,~ ,@:(a.&i.)@:": +NB. hash=: ] [ 1&bitand NB. can choose simple hash functions for tests + +setup=: 3 : 0 +T=: i. 0 2 NB. Tree +H=: D=: C=: i. 0 NB. Hashes, Data, Color +R=: _ NB. Root +'BLACK RED'=: i. 2 +EMPTY +) + +setup'' + +flipColors=: monad def 'C=: -.@:{`[`]}&C (, {&T) y' + +3 : 0 'test flipColors' +DD=.D=: ,/<@:(;3j1&":)"0 i.3 +TT=.T=: _ _,0 2,:_ _ +CC=.C=: 1 0 1 +RR=.R=: 1 +HH=.H=: i.3 +flipColors R +assert C -: -. CC +assert HH -: H +assert TT -: T +assert DD -: D +assert RR -: R +) + +getColor=: monad def 'C ({~ :: (BLACK"_))"_ 0 y' NB. y the node + +rotateTree=: dyad define NB. x left or right, y node +I=. x <@:(, -.)~ y +X=. I { T NB. x = root.otherside +J=. X <@:, x +T=: (J { T) I} T +T=: y J} T +C=: y (RED ,~ {)`(X , [)`]} C +X +) + +3 : 0 'test rotateTree' +DD=.D=:,/<@:(;3j1&":)"0 i.5 +TT=.T=:_ _,0 2,_ _,1 4,:_ _ +CC=.C=:0 1 0 0 0 +R=:3 +HH=.H=:i.5 +assert R = rotateTree/0 1 , R +assert DD -: D +assert CC -: C +assert HH -: H +assert TT -: T +) + +setup'' + +insert_privately=: adverb define +: +ROOT=. m +HASH=. x +ITEM=. y +if. _ -: ROOT do. NB. new key + ROOT=. # H + H=: H , HASH + T=: T , _ _ + D=: D , < ,: , ITEM + C=: C , RED +elseif. HASH = ROOT { H do. NB. change a value or hash collision + STACK=. ROOT >@:{ D + I=. STACK i.&:({."1) ITEM + STACK=. ITEM <@:(I}`,@.(I = #@])) STACK + D=: STACK ROOT } D +elseif. do. NB. Follow tree + NB. if both children are red then flipColors ROOT + flipColors^:((,~ RED) -: getColor@:({&T)) ROOT + I=. <@:(, HASH > {&H) ROOT + TEMP=. HASH (I { T) insert_privately y + T=: TEMP I } T + NB.if (isRed(h.right) && !isRed(h.left)) h = rotateLeft(h) + ROOT=. 0&rotateTree^:((BLACK,RED) -: getColor@:({&T)) ROOT + NB.if (isRed(h.left) && isRed(h.left.left)) h = rotateRight(h) + if. RED -: getColor {. ROOT { T do. + if. (RED -: (getColor@:(([: {&T <@:,&0)^:2) :: (BLACK"_))) ROOT do. + ROOT=. 1 rotateTree ROOT + end. + end. +end. +ROOT +) + +insert=: monad define"1 +assert 'boxed' -: datatype y +R=: (R insert_privately~ hash@:(0&{::)) y +C=: BLACK R } C +y +) + +find_hash_index=: monad define NB. y is the hash +if. 0 = # T do. '' return. end. NB. follow the tree +I=. R NB. instead of +while. y ~: I { H do. NB. direct search + J=. <@:(, y > {&H) I + if. _ > II=. J { T do. I=. II else. '' return. end. +end. +) + +find=: monad define +if. '' -: I=. find_hash_index hash y do. EMPTY return. end. +LIST=. I {:: D +K=. {. |: LIST +LIST {::~ ::empty 1 ,~ K i. < y +) + +delete=: 3 : 0 +if. '' -: I=. find_hash_index hash y do. EMPTY return. end. +LIST=. I {:: D +K=. {. |: LIST +J=. K i. < y +RESULT=. J ({::~ ,&1)~ LIST +STACK=. J <@:({. , (}.~ >:)~) LIST +D=. LIST I } D +RESULT +) + +getPathsToLeaves=: a:&$: : (4 : 0) NB. PATH getPathsToLeaves ROOT use: getPathsToLeaves R +if. 0 = # y do. getPathsToLeaves R return. end. +PATH=. x ,&.> y +if. _ -: y do. return. end. +PATH getPathsToLeaves"0 y { T +) + +check=: 3 : 0 +COLORS=. getColor"0&.> a: -.~ ~. , getPathsToLeaves '' +result=. EMPTY +if. 0&e.@:(= {.) +/@:(BLACK&=)@>COLORS do. result=. result,<'mismatched black count' end. +if. 1 e. 1&e.@:(*. (= 1&|.))@:(RED&=)@>COLORS do. result=. result,<'successive reds' end. +>result +) + +getPath=: 3 : 0 NB. get path to y, the key +if. 0 = # H do. EMPTY return. end. +HASH=. hash y +PATH=. , I=. R +while. HASH ~: I { H do. + J=. <@:(, HASH > {&H) I + PATH=. PATH , II=. J { T + if. _ > II do. I=. II else. EMPTY return. end. +end. +PATH +) + +items=: 3 :';D' +keys=: 3 :'0{"1 items y' +values=: 3 :'1{"1 items y' diff --git a/Task/Pattern-matching/J/pattern-matching-2.j b/Task/Pattern-matching/J/pattern-matching-2.j new file mode 100644 index 0000000000..9b9a01de09 --- /dev/null +++ b/Task/Pattern-matching/J/pattern-matching-2.j @@ -0,0 +1,11 @@ + load'rb.ijs' + NB. populate dictionary in random order with 999 key value pairs + insert@:(; 6j1&":)"0@:?~ 999 + find 'the' NB. 'the' has no entry. + find 239 NB. entry 239 has the anticipated formatted string value. + 239.0 + find 823823 NB. also no such entry + NB. + NB. tree passes the "no consecutive red" and "same number of black" + NB. nodes to and including NULL leaves. + check'' diff --git a/Task/Pattern-matching/OCaml/pattern-matching.ocaml b/Task/Pattern-matching/OCaml/pattern-matching.ocaml new file mode 100644 index 0000000000..0eb6c2d7ee --- /dev/null +++ b/Task/Pattern-matching/OCaml/pattern-matching.ocaml @@ -0,0 +1,24 @@ +type color = R | B +type 'a tree = E | T of color * 'a tree * 'a * 'a tree + +(** val balance : color * 'a tree * 'a * 'a tree -> 'a tree *) +let balance = function + | B, T (R, T (R,a,x,b), y, c), z, d + | B, T (R, a, x, T (R,b,y,c)), z, d + | B, a, x, T (R, T (R,b,y,c), z, d) + | B, a, x, T (R, b, y, T (R,c,z,d)) -> T (R, T (B,a,x,b), y, T (B,c,z,d)) + | col, a, x, b -> T (col, a, x, b) + +(** val insert : 'a -> 'a tree -> 'a tree *) +let insert x s = + let rec ins = function + | E -> T (R,E,x,E) + | T (col,a,y,b) as s -> + if x < y then + balance (col, ins a, y, b) + else if x > y then + balance (col, a, y, ins b) + else + s + in let T (_,a,y,b) = ins s + in T (B,a,y,b) diff --git a/Task/Pattern-matching/Oz/pattern-matching.oz b/Task/Pattern-matching/Oz/pattern-matching.oz new file mode 100644 index 0000000000..4be89a4efe --- /dev/null +++ b/Task/Pattern-matching/Oz/pattern-matching.oz @@ -0,0 +1,24 @@ +fun {Balance Col A X B} + case Col#A#X#B + of b#t(r t(r A X B) Y C )#Z#D then t(r t(b A X B) Y t(b C Z D)) + [] b#t(r A X t(r B Y C))#Z#D then t(r t(b A X B) Y t(b C Z D)) + [] b#A #X#t(r t(r B Y C) Z D) then t(r t(b A X B) Y t(b C Z D)) + [] b#A #X#t(r B Y t(r C Z D)) then t(r t(b A X B) Y t(b C Z D)) + else t(Col A X B) + end +end + +fun {Insert X S} + fun {Ins S} + case S of e then t(r e X e) + [] t(Col A Y B) then + if X < Y then {Balance Col {Ins A} Y B} + elseif X > Y then {Balance Col A Y {Ins B}} + else S + end + end + end + t(_ A Y B) = {Ins S} +in + t(b A Y B) +end diff --git a/Task/Pattern-matching/Perl-6/pattern-matching.pl6 b/Task/Pattern-matching/Perl-6/pattern-matching.pl6 new file mode 100644 index 0000000000..463b963033 --- /dev/null +++ b/Task/Pattern-matching/Perl-6/pattern-matching.pl6 @@ -0,0 +1,25 @@ +enum RedBlack ; + +multi balance(B,[R,[R,$a,$x,$b],$y,$c],$z,$d) { [R,[B,$a,$x,$b],$y,[B,$c,$z,$d]] } +multi balance(B,[R,$a,$x,[R,$b,$y,$c]],$z,$d) { [R,[B,$a,$x,$b],$y,[B,$c,$z,$d]] } +multi balance(B,$a,$x,[R,[R,$b,$y,$c],$z,$d]) { [R,[B,$a,$x,$b],$y,[B,$c,$z,$d]] } +multi balance(B,$a,$x,[R,$b,$y,[R,$c,$z,$d]]) { [R,[B,$a,$x,$b],$y,[B,$c,$z,$d]] } + +multi balance($col, $a, $x, $b) { [$col, $a, $x, $b] } + +multi ins( $x, @s [$col, $a, $y, $b] ) { + when $x before $y { balance $col, ins($x, $a), $y, $b } + when $x after $y { balance $col, $a, $y, ins($x, $b) } + default { @s } +} +multi ins( $x, Any:U ) { [R, Any, $x, Any] } + +multi insert( $x, $s ) { + [B, ins($x,$s)[1..3]]; +} + +sub MAIN { + my $t = Any; + $t = insert($_, $t) for (1..10).pick(*); + say $t.perl; +} diff --git a/Task/Pattern-matching/PicoLisp/pattern-matching-1.l b/Task/Pattern-matching/PicoLisp/pattern-matching-1.l new file mode 100644 index 0000000000..2006330b6f --- /dev/null +++ b/Task/Pattern-matching/PicoLisp/pattern-matching-1.l @@ -0,0 +1,35 @@ +(be color (R)) +(be color (B)) + +(be tree (@ E)) +(be tree (@P (T @C @L @X @R)) + (color @C) + (tree @P @L) + (call @P @X) + (tree @P @R) ) + +(be bal (B (T R (T R @A @X @B) @Y @C) @Z @D (T R (T B @A @X @B) @Y (T B @C @Z @D)))) +(be bal (B (T R @A @X (T R @B @Y @C)) @Z @D (T R (T B @A @X @B) @Y (T B @C @Z @D)))) +(be bal (B @A @X (T R (T R @B @Y @C) @Z @D) (T R (T B @A @X @B) @Y (T B @C @Z @D)))) +(be bal (B @A @X (T R @B @Y (T R @C @Z @D)) (T R (T B @A @X @B) @Y (T B @C @Z @D)))) + +(be balance (@C @A @X @B @S) + (bal @C @A @X @B @S) + T ) +(be balance (@C @A @X @B (T @C @A @X @B))) + +(be ins (@X E (T R E @X E))) +(be ins (@X (T @C @A @Y @B) @R) + (@ < (-> @X) (-> @Y)) + (ins @X @A @Ao) + (balance @C @Ao @Y @B @R) + T ) +(be ins (@X (T @C @A @Y @B) @R) + (@ > (-> @X) (-> @Y)) + (ins @X @B @Bo) + (balance @C @A @Y @Bo @R) + T ) +(be ins (@X (T @C @A @Y @B) (T @C @A @Y @B))) + +(be insert (@X @S (T B @A @Y @B)) + (ins @X @S (T @ @A @Y @B)) ) diff --git a/Task/Pattern-matching/PicoLisp/pattern-matching-2.l b/Task/Pattern-matching/PicoLisp/pattern-matching-2.l new file mode 100644 index 0000000000..ac9b2ab0a4 --- /dev/null +++ b/Task/Pattern-matching/PicoLisp/pattern-matching-2.l @@ -0,0 +1,3 @@ +: (? (insert 2 E @A) (insert 1 @A @B) (insert 3 @B @C)) + @A=(T B E 2 E) @B=(T B (T R E 1 E) 2 E) @C=(T B (T R E 1 E) 2 (T R E 3 E)) +-> NIL diff --git a/Task/Pattern-matching/Racket/pattern-matching.rkt b/Task/Pattern-matching/Racket/pattern-matching.rkt new file mode 100644 index 0000000000..72aed6ecfe --- /dev/null +++ b/Task/Pattern-matching/Racket/pattern-matching.rkt @@ -0,0 +1,28 @@ +#lang racket + +(struct t-node (color t-left value t-right)) + +(define (balance t) + (match t + [(t-node 'black (t-node 'red (t-node 'red a x b) y c) z d) + (t-node 'red (t-node 'black a x b) y (t-node 'black c z d))] + [(t-node 'black (t-node 'red a x (t-node 'red b y c)) z d) + (t-node 'red (t-node 'black a x b) y (t-node 'black c z d))] + [(t-node 'black a x (t-node 'red (t-node 'red b y c) z d)) + (t-node 'red (t-node 'black a x b) y (t-node 'black c z d))] + [(t-node 'black a x (t-node 'red b y (t-node 'red c z d))) + (t-node 'red (t-node 'black a x b) y (t-node 'black c z d))] + [else t])) + +(define (insert x s) + (define (ins t) + (match t + ['empty (t-node 'red 'empty x 'empty)] + [(t-node c a y b) + (cond [(< x y) + (balance (t-node c (ins a) y b))] + [(> x y) + (balance (t-node c a y (ins b)))] + [else t])])) + (match (ins s) + [(t-node _ a y b) (t-node 'black a y b)])) diff --git a/Task/Pattern-matching/Rascal/pattern-matching-1.rascal b/Task/Pattern-matching/Rascal/pattern-matching-1.rascal new file mode 100644 index 0000000000..ffbf1faa3b --- /dev/null +++ b/Task/Pattern-matching/Rascal/pattern-matching-1.rascal @@ -0,0 +1,65 @@ +// Literal +rascal>123 := 123 +bool: true + +// VariableDeclaration +rascal>if(str S := "abc") +>>>>>>> println("Match succeeds, S == \"\""); +Match succeeds, S == "abc" +ok + +// MultiVariable +rascal>if([10, N*, 50] := [10, 20, 30, 40, 50]) +>>>>>>> println("Match succeeds, N == "); +Match succeeds, N == [20,30,40] +ok + +// Variable +rascal>N = 10; +int: 10 +rascal>N := 10; +bool: true +rascal>N := 20; +bool: false + +// Set and List +rascal>if({10, set[int] S, 50} := {50, 40, 30, 20, 10}) +>>>>>>> println("Match succeeded, S = "); +Match succeeded, S = {30,40,20} +ok + +rascal>for([L1*, L2*] := [10, 20, 30, 40, 50]) +>>>>>>> println(" and "); +[] and [10,20,30,40,50] +[10] and [20,30,40,50] +[10,20] and [30,40,50] +[10,20,30] and [40,50] +[10,20,30,40] and [50] +[10,20,30,40,50] and [] +list[void]: [] + +// Descendant +rascal>T = red(red(black(leaf(1), leaf(2)), black(leaf(3), leaf(4))), black(leaf(5), leaf(4))); +rascal>for(/black(_,leaf(4)) := T) +>>>>>>> println("Match!"); +Match! +Match! +list[void]: [] + +rascal>for(/black(_,leaf(int N)) := T) +>>>>>>> println("Match "); +Match 2 +Match 4 +Match 4 +list[void]: [] + +rascal>for(/int N := T) +>>>>>>> append N; +list[int]: [1,2,3,4,5,4] + +// Labelled +rascal>for(/M:black(_,leaf(4)) := T) +>>>>>>> println("Match "); +Match black(leaf(3),leaf(4)) +Match black(leaf(5),leaf(4)) +list[void]: [] diff --git a/Task/Pattern-matching/Rascal/pattern-matching-2.rascal b/Task/Pattern-matching/Rascal/pattern-matching-2.rascal new file mode 100644 index 0000000000..722d1b4e19 --- /dev/null +++ b/Task/Pattern-matching/Rascal/pattern-matching-2.rascal @@ -0,0 +1,8 @@ +// Quoted pattern +` Token1 Token2 ... Tokenn ` +// A typed quoted pattern +(Symbol) ` Token1 Token2 ... TokenN ` +// A typed variable pattern + +// A variable pattern + diff --git a/Task/Pattern-matching/Rascal/pattern-matching-3.rascal b/Task/Pattern-matching/Rascal/pattern-matching-3.rascal new file mode 100644 index 0000000000..a3f1a1d47f --- /dev/null +++ b/Task/Pattern-matching/Rascal/pattern-matching-3.rascal @@ -0,0 +1,40 @@ +// Define ColoredTrees with red and black nodes and integer leaves +data ColoredTree = leaf(int N) + | red(ColoredTree left, ColoredTree right) + | black(ColoredTree left, ColoredTree right); + +// Count the number of black nodes +public int cntBlack(ColoredTree t){ + int c = 0; + visit(t) { + case black(_,_): c += 1; + }; + return c; +} + +// Returns if a tree is balanced +public bool balance(ColoredTree t){ + visit(t){ + case black(a,b): if (cntBlack(a) == cntBlack(b)) true; else return false; + case red(a,b): if (cntBlack(a) == cntBlack(b)) true; else return false; + } + return true; +} +// Compute the sum of all integer leaves +public int addLeaves(ColoredTree t){ + int c = 0; + visit(t) { + case leaf(int N): c += N; + }; + return c; +} + +// Add green nodes to ColoredTree +data ColoredTree = green(ColoredTree left, ColoredTree right); + +// Transform red nodes into green nodes +public ColoredTree makeGreen(ColoredTree t){ + return visit(t) { + case red(l, r) => green(l, r) + }; +} diff --git a/Task/Pattern-matching/Rascal/pattern-matching-4.rascal b/Task/Pattern-matching/Rascal/pattern-matching-4.rascal new file mode 100644 index 0000000000..7b77cc3484 --- /dev/null +++ b/Task/Pattern-matching/Rascal/pattern-matching-4.rascal @@ -0,0 +1,4 @@ +rascal>/XX/i := "some xx"; +bool: true +rascal>/a.c/ := "abc"; +bool: true diff --git a/Task/Pattern-matching/Scala/pattern-matching.scala b/Task/Pattern-matching/Scala/pattern-matching.scala new file mode 100644 index 0000000000..c9c8711cf3 --- /dev/null +++ b/Task/Pattern-matching/Scala/pattern-matching.scala @@ -0,0 +1,33 @@ +class RedBlackTree[A](implicit ord: Ordering[A]) { + sealed abstract class Color + case object R extends Color + case object B extends Color + + sealed abstract class Tree { + def insert(x: A): Tree = ins(x) match { + case T(_, a, y, b) => T(B, a, y, b) + case E => E + } + def ins(x: A): Tree + } + + case object E extends Tree { + override def ins(x: A): Tree = T(R, E, x, E) + } + + case class T(c: Color, left: Tree, a: A, right: Tree) extends Tree { + private def balance: Tree = (c, left, a, right) match { + case (B, T(R, T(R, a, x, b), y, c), z, d ) => T(R, T(B, a, x, b), y, T(B, c, z, d)) + case (B, T(R, a, x, T(R, b, y, c)), z, d ) => T(R, T(B, a, x, b), y, T(B, c, z, d)) + case (B, a, x, T(R, T(R, b, y, c), z, d )) => T(R, T(B, a, x, b), y, T(B, c, z, d)) + case (B, a, x, T(R, b, y, T(R, c, z, d))) => T(R, T(B, a, x, b), y, T(B, c, z, d)) + case _ => this + } + + override def ins(x: A): Tree = ord.compare(x, a) match { + case -1 => T(c, left ins x, a, right ).balance + case 1 => T(c, left, a, right ins x).balance + case 0 => this + } + } +} diff --git a/Task/Pattern-matching/Standard-ML/pattern-matching.ml b/Task/Pattern-matching/Standard-ML/pattern-matching.ml new file mode 100644 index 0000000000..359cb160eb --- /dev/null +++ b/Task/Pattern-matching/Standard-ML/pattern-matching.ml @@ -0,0 +1,24 @@ +datatype color = R | B +datatype 'a tree = E | T of color * 'a tree * 'a * 'a tree + +(** val balance = fn : color * 'a tree * 'a * 'a tree -> 'a tree *) +fun balance (B, T (R, T (R,a,x,b), y, c), z, d) = T (R, T (B,a,x,b), y, T (B,c,z,d)) + | balance (B, T (R, a, x, T (R,b,y,c)), z, d) = T (R, T (B,a,x,b), y, T (B,c,z,d)) + | balance (B, a, x, T (R, T (R,b,y,c), z, d)) = T (R, T (B,a,x,b), y, T (B,c,z,d)) + | balance (B, a, x, T (R, b, y, T (R,c,z,d))) = T (R, T (B,a,x,b), y, T (B,c,z,d)) + | balance (col, a, x, b) = T (col, a, x, b) + +(** val insert = fn : int -> int tree -> int tree *) +fun insert x s = let + fun ins E = T (R,E,x,E) + | ins (s as T (col,a,y,b)) = + if x < y then + balance (col, ins a, y, b) + else if x > y then + balance (col, a, y, ins b) + else + s + val T (_,a,y,b) = ins s +in + T (B,a,y,b) +end diff --git a/Task/Pattern-matching/Tcl/pattern-matching-1.tcl b/Task/Pattern-matching/Tcl/pattern-matching-1.tcl new file mode 100644 index 0000000000..42db2f29d5 --- /dev/null +++ b/Task/Pattern-matching/Tcl/pattern-matching-1.tcl @@ -0,0 +1,70 @@ +# From http://wiki.tcl.tk/9547 +package require Tcl 8.5 +package provide datatype 0.1 + +namespace eval ::datatype { + namespace export define match matches + namespace ensemble create + + # Datatype definitions + proc define {type = args} { + set ns [uplevel 1 { namespace current }] + foreach cons [split [join $args] |] { + set name [lindex $cons 0] + set args [lrange $cons 1 end] + proc $ns\::$name $args [format { + lreplace [info level 0] 0 0 %s + } [list $name]] + } + return $type + } + + # Pattern matching + # matches pattern value envVar -- + # Returns 1 if value matches pattern, else 0 + # Binds match variables in envVar + proc matches {pattern value envVar} { + upvar 1 $envVar env + if {[var? $pattern]} { return [bind env $pattern $value] } + if {[llength $pattern] != [llength $value]} { return 0 } + if {[lindex $pattern 0] ne [lindex $value 0]} { return 0 } + foreach pat [lrange $pattern 1 end] val [lrange $value 1 end] { + if {![matches $pat $val env]} { return 0 } + } + return 1 + } + # A variable starts with lower-case letter or _. _ is a wildcard. + proc var? term { string match {[a-z_]*} $term } + proc bind {envVar var value} { + upvar 1 $envVar env + if {![info exists env]} { set env [dict create] } + if {$var eq "_"} { return 1 } + dict set env $var $value + return 1 + } + proc match args { + #puts "MATCH: $args" + set values [lrange $args 0 end-1] + set choices [lindex $args end] + append choices \n [list return -code error -level 2 "no match for $values"] + set f [list values $choices [namespace current]] + lassign [apply $f $values] env body + #puts "RESULT: $env -> $body" + dict for {k v} $env { upvar 1 $k var; set var $v } + catch { uplevel 1 $body } msg opts + dict incr opts -level + return -options $opts $msg + } + proc case args { + upvar 1 values values + set patterns [lrange $args 0 end-2] + set body [lindex $args end] + set env [dict create] + if {[llength $patterns] != [llength $values]} { return } + foreach pattern $patterns value $values { + if {![matches $pattern $value env]} { return } + } + return -code return [list $env $body] + } + proc default body { return -code return [list {} $body] } +} diff --git a/Task/Pattern-matching/Tcl/pattern-matching-2.tcl b/Task/Pattern-matching/Tcl/pattern-matching-2.tcl new file mode 100644 index 0000000000..b5696e9995 --- /dev/null +++ b/Task/Pattern-matching/Tcl/pattern-matching-2.tcl @@ -0,0 +1,30 @@ +datatype define Color = R | B +datatype define Tree = E | T color left val right + +# balance :: Color -> Tree a -> a -> Tree a -> Tree a +proc balance {color left val right} { + datatype match $color $left $val $right { + case B [T R [T R a x b] y c] z d -> { T R [T B $a $x $b] $y [T B $c $z $d] } + case B [T R a x [T R b y c]] z d -> { T R [T B $a $x $b] $y [T B $c $z $d] } + case B a x [T R [T R b y c] z d] -> { T R [T B $a $x $b] $y [T B $c $z $d] } + case B a x [T R b y [T R c z d]] -> { T R [T B $a $x $b] $y [T B $c $z $d] } + case col a x b -> { T $col $a $x $b } + } +} +# insert :: Ord a => a -> Tree a -> Tree a +proc insert {x s} { + datatype match [ins $x $s] { + case [T _ a y b] -> { T B $a $y $b } + } +} +# ins :: Ord a => a -> Tree a -> Tree a +proc ins {x s} { + datatype match $s { + case E -> { T R E $x E } + case [T col a y b] -> { + if {$x < $y} { return [balance $col [ins $x $a] $y $b] } + if {$x > $y} { return [balance $col $a $y [ins $x $b]] } + return $s + } + } +} diff --git a/Task/Percentage-difference-between-images/0DESCRIPTION b/Task/Percentage-difference-between-images/0DESCRIPTION new file mode 100644 index 0000000000..6343cda08d --- /dev/null +++ b/Task/Percentage-difference-between-images/0DESCRIPTION @@ -0,0 +1,19 @@ +Compute the percentage of difference between 2 JPEG images of the same size. Alternatively, compare two bitmaps as defined in [[basic bitmap storage]]. + +Useful for comparing two JPEG images saved with a different compression ratios. + +You can use these pictures for testing (use the full-size version of each): + +{| +|- +!50% quality JPEG +!100% quality JPEG +|- +|[[Image:Lenna50.jpg|200px]] +|[[Image:Lenna100.jpg|200px]] +|- +|[http://rosettacode.org/mw/images/3/3c/Lenna50.jpg link to full size 50% image] +|[http://rosettacode.org/mw/images/b/b6/Lenna100.jpg link to full size 100% image] +|} + +The expected difference for these two images is 1.62125% diff --git a/Task/Percentage-difference-between-images/1META.yaml b/Task/Percentage-difference-between-images/1META.yaml new file mode 100644 index 0000000000..58807afa1b --- /dev/null +++ b/Task/Percentage-difference-between-images/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Image processing diff --git a/Task/Percentage-difference-between-images/Ada/percentage-difference-between-images-1.ada b/Task/Percentage-difference-between-images/Ada/percentage-difference-between-images-1.ada new file mode 100644 index 0000000000..cf96087a7e --- /dev/null +++ b/Task/Percentage-difference-between-images/Ada/percentage-difference-between-images-1.ada @@ -0,0 +1 @@ +type Count is mod 2**64; diff --git a/Task/Percentage-difference-between-images/Ada/percentage-difference-between-images-2.ada b/Task/Percentage-difference-between-images/Ada/percentage-difference-between-images-2.ada new file mode 100644 index 0000000000..4acabd8b08 --- /dev/null +++ b/Task/Percentage-difference-between-images/Ada/percentage-difference-between-images-2.ada @@ -0,0 +1,8 @@ +function "-" (Left, Right : Luminance) return Count is +begin + if Left > Right then + return Count (Left) - Count (Right); + else + return Count (Right) - Count (Left); + end if; +end "-"; diff --git a/Task/Percentage-difference-between-images/Ada/percentage-difference-between-images-3.ada b/Task/Percentage-difference-between-images/Ada/percentage-difference-between-images-3.ada new file mode 100644 index 0000000000..41b6d6249b --- /dev/null +++ b/Task/Percentage-difference-between-images/Ada/percentage-difference-between-images-3.ada @@ -0,0 +1,4 @@ +function "-" (Left, Right : Pixel) return Count is +begin + return (Left.R - Right.R) + (Left.G - Left.G) + (Left.B - Right.B); +end "-"; diff --git a/Task/Percentage-difference-between-images/Ada/percentage-difference-between-images-4.ada b/Task/Percentage-difference-between-images/Ada/percentage-difference-between-images-4.ada new file mode 100644 index 0000000000..75c77278e1 --- /dev/null +++ b/Task/Percentage-difference-between-images/Ada/percentage-difference-between-images-4.ada @@ -0,0 +1,15 @@ +function Diff (Left, Right : Image) return Float is + Offs_I : constant Integer := Right'First (1) - Left'First (1); + Offs_J : constant Integer := Right'First (2) - Left'First (2); + Sum : Count := 0; +begin + if Left'Length (1) /= Right'Length (1) or else Left'Length (2) /= Right'Length (2) then + raise Constraint_Error; + end if; + for I in Left'Range (1) loop + for J in Left'Range (2) loop + Sum := Sum + (Left (I, J) - Right (I + Offs_I, J + Offs_J)); + end loop; + end loop; + return Float (Sum) / (3.0 * Float (Left'Length (1) * Left'Length (2))); +end Diff; diff --git a/Task/Percentage-difference-between-images/Ada/percentage-difference-between-images-5.ada b/Task/Percentage-difference-between-images/Ada/percentage-difference-between-images-5.ada new file mode 100644 index 0000000000..52c06ed39a --- /dev/null +++ b/Task/Percentage-difference-between-images/Ada/percentage-difference-between-images-5.ada @@ -0,0 +1,7 @@ + F1, F2 : File_Type; +begin + Open (F1, In_File, "city.ppm"); + Open (F2, In_File, "city_emboss.ppm"); + Ada.Text_IO.Put_Line ("Diff" & Float'Image (Diff (Get_PPM (F1), Get_PPM (F2)))); + Close (F1); + Close (F2); diff --git a/Task/Percentage-difference-between-images/AutoHotkey/percentage-difference-between-images.ahk b/Task/Percentage-difference-between-images/AutoHotkey/percentage-difference-between-images.ahk new file mode 100644 index 0000000000..70e25eb648 --- /dev/null +++ b/Task/Percentage-difference-between-images/AutoHotkey/percentage-difference-between-images.ahk @@ -0,0 +1,85 @@ +startup() +dibSection := getPixels("lenna100.jpg") +dibSection2 := getPixels("lenna50.jpg") ; ("File-Lenna100.jpg") +pixels := dibSection.pBits +pixels2 := dibSection2.pBits +z := 0 +loop % dibSection.width * dibSection.height * 4 +{ +x := numget(pixels - 1, A_Index, "uchar") +y := numget(pixels2 - 1, A_Index, "uchar") +z += abs(y - x) +} +msgbox % z / (dibSection.width * dibSection.height * 3 * 255 / 100 ) ; 1.626 +return + +CreateDIBSection2(hDC, nW, nH, bpp = 32, ByRef pBits = "") +{ +dib := object() + NumPut(VarSetCapacity(bi, 40, 0), bi) + NumPut(nW, bi, 4) + NumPut(nH, bi, 8) + NumPut(bpp, NumPut(1, bi, 12, "UShort"), 0, "Ushort") + NumPut(0, bi,16) +hbm := DllCall("gdi32\CreateDIBSection", "Uint", hDC, "Uint", &bi, "Uint", 0, "UintP", pBits, "Uint", 0, "Uint", 0) + +dib.hbm := hbm +dib.pBits := pBits +dib.width := nW +dib.height := nH +dib.bpp := bpp +dib.header := header + Return dib +} + + + +startup() +{ +global disposables +disposables := object() +disposables.pBitmaps := object() +disposables.hBitmaps := object() + +If !(disposables.pToken := Gdip_Startup()) +{ + MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system + ExitApp +} + OnExit, gdipExit +} + + +gdipExit: +loop % disposables.hBitmaps._maxindex() +DllCall("DeleteObject", "Uint", disposables.hBitmaps[A_Index]) +Gdip_Shutdown(disposables.pToken) +ExitApp + +getPixels(imageFile) +{ +global disposables ; hBitmap will be disposed later +pBitmapFile1 := Gdip_CreateBitmapFromFile(imageFile) +hbmi := Gdip_CreateHBITMAPFromBitmap(pBitmapFile1) +width := Gdip_GetImageWidth(pBitmapFile1) +height := Gdip_GetImageHeight(pBitmapFile1) + + mDCo := DllCall("CreateCompatibleDC", "Uint", 0) + mDCi := DllCall("CreateCompatibleDC", "Uint", 0) + dibSection := CreateDIBSection2(mDCo, width, height) + hBMo := dibSection.hbm + + oBM := DllCall("SelectObject", "Uint", mDCo, "Uint", hBMo) + iBM := DllCall("SelectObject", "Uint", mDCi, "Uint", hbmi) + + DllCall("BitBlt", "Uint", mDCo, "int", 0, "int", 0, "int", width, "int", height, "Uint", mDCi, "int", 0, "int", 0, "Uint", 0x40000000 | 0x00CC0020) + + DllCall("SelectObject", "Uint", mDCo, "Uint", oBM) +DllCall("ReleaseDC", "Uint", 0, "Uint", mDCi) +DllCall("ReleaseDC", "Uint", 0, "Uint", mDCo) +Gdip_DisposeImage(pBitmapFile1) +DllCall("DeleteObject", "Uint", hBMi) +disposables.hBitmaps._insert(hBMo) +return dibSection +} +#Include Gdip.ahk ; Thanks to tic (Tariq Porter) for his GDI+ Library diff --git a/Task/Percentage-difference-between-images/BBC-BASIC/percentage-difference-between-images.bbc b/Task/Percentage-difference-between-images/BBC-BASIC/percentage-difference-between-images.bbc new file mode 100644 index 0000000000..d828c9a9a8 --- /dev/null +++ b/Task/Percentage-difference-between-images/BBC-BASIC/percentage-difference-between-images.bbc @@ -0,0 +1,48 @@ + hbm1% = FNloadimage("C:lenna50.jpg") + hbm2% = FNloadimage("C:lenna100.jpg") + + SYS "CreateCompatibleDC", @memhdc% TO hdc1% + SYS "CreateCompatibleDC", @memhdc% TO hdc2% + + SYS "SelectObject", hdc1%, hbm1% + SYS "SelectObject", hdc2%, hbm2% + + diff% = 0 + FOR y% = 0 TO 511 + FOR x% = 0 TO 511 + SYS "GetPixel", hdc1%, x%, y% TO rgb1% + SYS "GetPixel", hdc2%, x%, y% TO rgb2% + diff% += ABS((rgb1% AND &FF) - (rgb2% AND &FF)) + diff% += ABS((rgb1% >> 8 AND &FF) - (rgb2% >> 8 AND &FF)) + diff% += ABS((rgb1% >> 16) - (rgb2% >> 16)) + NEXT + NEXT y% + PRINT "Image difference = "; 100 * diff% / 512^2 / 3 / 255 " %" + + SYS "DeleteDC", hdc1% + SYS "DeleteDC", hdc2% + SYS "DeleteObject", hbm1% + SYS "DeleteObject", hbm2% + END + + DEF FNloadimage(file$) + LOCAL iid{}, hbm%, pic%, ole%, olpp%, text% + DIM iid{a%,b%,c%,d%}, text% LOCAL 513 + + iid.a% = &7BF80980 : REM. 128-bit iid + iid.b% = &101ABF32 + iid.c% = &AA00BB8B + iid.d% = &AB0C3000 + + SYS "MultiByteToWideChar", 0, 0, file$, -1, text%, 256 + + SYS "LoadLibrary", "OLEAUT32.DLL" TO ole% + SYS "GetProcAddress", ole%, "OleLoadPicturePath" TO olpp% + IF olpp%=0 THEN = 0 + + SYS olpp%, text%, 0, 0, 0, iid{}, ^pic% : REM. OleLoadPicturePath + IF pic%=0 THEN = 0 + + SYS !(!pic%+12), pic%, ^hbm% : REM. IPicture::get_Handle + SYS "FreeLibrary", ole% + = hbm% diff --git a/Task/Percentage-difference-between-images/C++/percentage-difference-between-images.cpp b/Task/Percentage-difference-between-images/C++/percentage-difference-between-images.cpp new file mode 100644 index 0000000000..2e9e930cfd --- /dev/null +++ b/Task/Percentage-difference-between-images/C++/percentage-difference-between-images.cpp @@ -0,0 +1,43 @@ +#include +#include +#include +#include + +int main( int argc , char *argv[ ] ) { + if ( argc != 3 ) { + std::cout << "Call this with imagecompare " + << " \n" ; + return 1 ; + } + QImage firstImage ( argv[ 1 ] ) ; + QImage secondImage ( argv[ 2 ] ) ; + double totaldiff = 0.0 ; //holds the number of different pixels + int h = firstImage.height( ) ; + int w = firstImage.width( ) ; + int hsecond = secondImage.height( ) ; + int wsecond = secondImage.width( ) ; + if ( w != wsecond || h != hsecond ) { + std::cerr << "Error, pictures must have identical dimensions!\n" ; + return 2 ; + } + for ( int y = 0 ; y < h ; y++ ) { + uint *firstLine = ( uint* )firstImage.scanLine( y ) ; + uint *secondLine = ( uint* )secondImage.scanLine( y ) ; + for ( int x = 0 ; x < w ; x++ ) { + uint pixelFirst = firstLine[ x ] ; + int rFirst = qRed( pixelFirst ) ; + int gFirst = qGreen( pixelFirst ) ; + int bFirst = qBlue( pixelFirst ) ; + uint pixelSecond = secondLine[ x ] ; + int rSecond = qRed( pixelSecond ) ; + int gSecond = qGreen( pixelSecond ) ; + int bSecond = qBlue( pixelSecond ) ; + totaldiff += std::abs( rFirst - rSecond ) / 255.0 ; + totaldiff += std::abs( gFirst - gSecond ) / 255.0 ; + totaldiff += std::abs( bFirst -bSecond ) / 255.0 ; + } + } + std::cout << "The difference of the two pictures is " << + (totaldiff * 100) / (w * h * 3) << " % !\n" ; + return 0 ; +} diff --git a/Task/Percentage-difference-between-images/C/percentage-difference-between-images.c b/Task/Percentage-difference-between-images/C/percentage-difference-between-images.c new file mode 100644 index 0000000000..89d5ecbfb3 --- /dev/null +++ b/Task/Percentage-difference-between-images/C/percentage-difference-between-images.c @@ -0,0 +1,45 @@ +#include +#include +#include +/* #include "imglib.h" */ + +#define RED_C 0 +#define GREEN_C 1 +#define BLUE_C 2 +#define GET_PIXEL(IMG, X, Y) ((IMG)->buf[ (Y) * (IMG)->width + (X) ]) + +int main(int argc, char **argv) +{ + image im1, im2; + double totalDiff = 0.0; + unsigned int x, y; + + if ( argc < 3 ) + { + fprintf(stderr, "usage:\n%s FILE1 FILE2\n", argv[0]); + exit(1); + } + im1 = read_image(argv[1]); + if ( im1 == NULL ) exit(1); + im2 = read_image(argv[2]); + if ( im2 == NULL ) { free_img(im1); exit(1); } + if ( (im1->width != im2->width) || (im1->height != im2->height) ) + { + fprintf(stderr, "width/height of the images must match!\n"); + } else { + /* BODY: the "real" part! */ + for(x=0; x < im1->width; x++) + { + for(y=0; y < im1->width; y++) + { + totalDiff += fabs( GET_PIXEL(im1, x, y)[RED_C] - GET_PIXEL(im2, x, y)[RED_C] ) / 255.0; + totalDiff += fabs( GET_PIXEL(im1, x, y)[GREEN_C] - GET_PIXEL(im2, x, y)[GREEN_C] ) / 255.0; + totalDiff += fabs( GET_PIXEL(im1, x, y)[BLUE_C] - GET_PIXEL(im2, x, y)[BLUE_C] ) / 255.0; + } + } + printf("%lf\n", 100.0 * totalDiff / (double)(im1->width * im1->height * 3) ); + /* BODY ends */ + } + free_img(im1); + free_img(im2); +} diff --git a/Task/Percentage-difference-between-images/Common-Lisp/percentage-difference-between-images.lisp b/Task/Percentage-difference-between-images/Common-Lisp/percentage-difference-between-images.lisp new file mode 100644 index 0000000000..f93cd72221 --- /dev/null +++ b/Task/Percentage-difference-between-images/Common-Lisp/percentage-difference-between-images.lisp @@ -0,0 +1,14 @@ +(require 'cl-jpeg) +;;; the JPEG library uses simple-vectors to store data. this is insane! +(defun compare-images (file1 file2) + (declare (optimize (speed 3) (safety 0) (debug 0))) + (multiple-value-bind (image1 height width) (jpeg:decode-image file1) + (let ((image2 (jpeg:decode-image file2))) + (loop for i of-type (unsigned-byte 8) across (the simple-vector image1) + for j of-type (unsigned-byte 8) across (the simple-vector image2) + sum (the fixnum (abs (- i j))) into difference of-type fixnum + finally (return (coerce (/ difference width height #.(* 3 255)) + 'double-float)))))) + + CL-USER> (* 100 (compare-images "Lenna50.jpg" "Lenna100.jpg")) + 1.774856467652165d0 diff --git a/Task/Percentage-difference-between-images/D/percentage-difference-between-images.d b/Task/Percentage-difference-between-images/D/percentage-difference-between-images.d new file mode 100644 index 0000000000..b463549a77 --- /dev/null +++ b/Task/Percentage-difference-between-images/D/percentage-difference-between-images.d @@ -0,0 +1,17 @@ +import std.stdio, std.exception, std.range, std.math, bitmap; + +void main() { + Image!RGB i1, i2; + i1.loadPPM6("Lenna50.ppm"); + i2.loadPPM6("Lenna100.ppm"); + + enforce(i1.nx == i2.nx && i1.ny == i2.ny, "Different sizes."); + + real dif = 0.0; + foreach (p, q; zip(i1.image, i2.image)) + dif += abs(p.r - q.r) + abs(p.g - q.g) + abs(p.b - q.b); + + immutable nData = i1.nx * i1.ny * 3; + writeln("Difference (percentage): ", + (dif / 255.0 * 100) / nData); +} diff --git a/Task/Percentage-difference-between-images/E/percentage-difference-between-images.e b/Task/Percentage-difference-between-images/E/percentage-difference-between-images.e new file mode 100644 index 0000000000..bfed2208b4 --- /dev/null +++ b/Task/Percentage-difference-between-images/E/percentage-difference-between-images.e @@ -0,0 +1,29 @@ +def imageDifference(a, b) { + require(a.width() == b.width()) + require(a.height() == b.height()) + def X := 0..!(a.width()) + def Y := 0..!(a.height()) + + var sumByteDiff := 0 + for y in Y { + for x in X { + def ca := a[x, y] + def cb := b[x, y] + sumByteDiff += (ca.rb() - cb.rb()).abs() \ + + (ca.gb() - cb.gb()).abs() \ + + (ca.bb() - cb.bb()).abs() + } + println(y) + } + return sumByteDiff / (255 * 3 * a.width() * a.height()) +} + +def imageDifferenceTask() { + println("Read 1...") + def a := readPPM(()) + println("Read 2...") + def b := readPPM(()) + println("Compare...") + def d := imageDifference(a, b) + println(`${d * 100}% different.`) +} diff --git a/Task/Percentage-difference-between-images/Forth/percentage-difference-between-images.fth b/Task/Percentage-difference-between-images/Forth/percentage-difference-between-images.fth new file mode 100644 index 0000000000..fb8056717d --- /dev/null +++ b/Task/Percentage-difference-between-images/Forth/percentage-difference-between-images.fth @@ -0,0 +1,17 @@ +: pixel-diff ( pixel1 pixel2 -- n ) + over 255 and over 255 and - abs >r 8 rshift swap 8 rshift + over 255 and over 255 and - abs >r 8 rshift swap 8 rshift + - abs r> + r> + ; +: bdiff ( bmp1 bmp2 -- fdiff ) + 2dup bdim rot bdim d<> abort" images not comparable" + 0e ( F: total diff ) + dup bdim * >r ( R: total pixels ) + bdata swap bdata + r@ 0 do + over @ over @ pixel-diff 0 d>f f+ + cell+ swap cell+ + loop 2drop + r> 3 * 255 * 0 d>f f/ ; + +: .bdiff ( bmp1 bmp2 -- ) + cr bdiff 100e f* f. ." percent different" ; diff --git a/Task/Percentage-difference-between-images/Fortran/percentage-difference-between-images.f b/Task/Percentage-difference-between-images/Fortran/percentage-difference-between-images.f new file mode 100644 index 0000000000..9c8b4f5846 --- /dev/null +++ b/Task/Percentage-difference-between-images/Fortran/percentage-difference-between-images.f @@ -0,0 +1,32 @@ +program ImageDifference + + use RCImageBasic + use RCImageIO + + implicit none + + integer, parameter :: input1_u = 20, & + input2_u = 21 + + type(rgbimage) :: lenna1, lenna2 + real :: totaldiff + + + open(input1_u, file="Lenna100.ppm", action="read") + open(input2_u, file="Lenna50.ppm", action="read") + call read_ppm(input1_u, lenna1) + call read_ppm(input2_u, lenna2) + close(input1_u) + close(input2_u) + + totaldiff = sum( (abs(lenna1%red - lenna2%red) + & + abs(lenna1%green - lenna2%green) + & + abs(lenna1%blue - lenna2%blue)) / 255.0 ) + + + print *, 100.0 * totaldiff / (lenna1%width * lenna1%height * 3.0) + + call free_img(lenna1) + call free_img(lenna2) + +end program ImageDifference diff --git a/Task/Percentage-difference-between-images/Go/percentage-difference-between-images-1.go b/Task/Percentage-difference-between-images/Go/percentage-difference-between-images-1.go new file mode 100644 index 0000000000..524a3026ea --- /dev/null +++ b/Task/Percentage-difference-between-images/Go/percentage-difference-between-images-1.go @@ -0,0 +1,65 @@ +package main + +import ( + "fmt" + "image/jpeg" + "os" +) + +func main() { + f, err := os.Open("Lenna50.jpg") + if err != nil { + fmt.Println(err) + return + } + defer f.Close() + i50, err := jpeg.Decode(f) + if err != nil { + fmt.Println(err) + return + } + if f, err = os.Open("Lenna100.jpg"); err != nil { + fmt.Println(err) + return + } + defer f.Close() + i100, err := jpeg.Decode(f) + if err != nil { + fmt.Println(err) + return + } + if i50.ColorModel() != i100.ColorModel() { + fmt.Println("different color models") + return + } + b := i50.Bounds() + if !b.Eq(i100.Bounds()) { + fmt.Println("different image sizes") + return + } + var sum int64 + for y := b.Min.Y; y < b.Max.Y; y++ { + for x := b.Min.X; x < b.Max.X; x++ { + r1, g1, b1, _ := i50.At(x, y).RGBA() + r2, g2, b2, _ := i100.At(x, y).RGBA() + if r1 > r2 { + sum += int64(r1 - r2) + } else { + sum += int64(r2 - r1) + } + if g1 > g2 { + sum += int64(g1 - g2) + } else { + sum += int64(g2 - g1) + } + if b1 > b2 { + sum += int64(b1 - b2) + } else { + sum += int64(b2 - b1) + } + } + } + nPixels := (b.Max.X - b.Min.X) * (b.Max.Y - b.Min.Y) + fmt.Printf("Image difference: %f%%\n", + float64(sum*100)/(float64(nPixels)*0xffff*3)) +} diff --git a/Task/Percentage-difference-between-images/Go/percentage-difference-between-images-2.go b/Task/Percentage-difference-between-images/Go/percentage-difference-between-images-2.go new file mode 100644 index 0000000000..28bc69d0d0 --- /dev/null +++ b/Task/Percentage-difference-between-images/Go/percentage-difference-between-images-2.go @@ -0,0 +1,72 @@ +package main + +// Files required to build supporting package raster are found in: +// * Bitmap +// * Read a PPM file + +import ( + "fmt" + "io" + "os/exec" + "raster" +) + +func readJpeg(j string) (b *raster.Bitmap, err error) { + c := exec.Command("convert", j, "ppm:-") + var pipe io.Reader + pipe, err = c.StdoutPipe() + if err != nil { + return + } + err = c.Start() + if err != nil { + return + } + return raster.ReadPpmFrom(pipe) +} + +func main() { + b1, err := readJpeg("Lenna50.jpg") + if err != nil { + fmt.Println(err) + return + } + b2, err := readJpeg("Lenna100.jpg") + if err != nil { + fmt.Println(err) + return + } + b1c, b1r := b1.Extent() + b2c, b2r := b2.Extent() + if b1c != b2c || b1r != b2r { + fmt.Println("image extents not the same") + return + } + var sum int64 + for y := 0; y < b1r; y++ { + for x := 0; x < b1c; x++ { + p1, _ := b1.GetPx(x, y) + p2, _ := b2.GetPx(x, y) + d := int64(p1.R) - int64(p2.R) + if d < 0 { + sum -= d + } else { + sum += d + } + d = int64(p1.G) - int64(p2.G) + if d < 0 { + sum -= d + } else { + sum += d + } + d = int64(p1.B) - int64(p2.B) + if d < 0 { + sum -= d + } else { + sum += d + } + } + } + fmt.Printf("Image difference: %f%%\n", + float64(sum)*100/(float64(b1c*b1r)*255*3)) +} diff --git a/Task/Percentage-difference-between-images/Go/percentage-difference-between-images-3.go b/Task/Percentage-difference-between-images/Go/percentage-difference-between-images-3.go new file mode 100644 index 0000000000..601dd08995 --- /dev/null +++ b/Task/Percentage-difference-between-images/Go/percentage-difference-between-images-3.go @@ -0,0 +1,26 @@ +import Bitmap +import Bitmap.Netpbm +import Bitmap.RGB + +import Control.Monad +import Control.Monad.ST +import System.Environment (getArgs) + +main = do + [path1, path2] <- getArgs + image1 <- readNetpbm path1 + image2 <- readNetpbm path2 + diff <- stToIO $ imageDiff image1 image2 + putStrLn $ "Difference: " ++ show (100 * diff) ++ "%" + +imageDiff :: Image s RGB -> Image s RGB -> ST s Double +imageDiff image1 image2 = do + i1 <- getPixels image1 + i2 <- getPixels image2 + unless (length i1 == length i2) $ + fail "imageDiff: Images are of different sizes" + return $ + toEnum (sum $ zipWith minus i1 i2) / + toEnum (3 * 255 * length i1) + where (RGB (r1, g1, b1)) `minus` (RGB (r2, g2, b2)) = + abs (r1 - r2) + abs (g1 - g2) + abs (b1 - b2) diff --git a/Task/Percentage-difference-between-images/Icon/percentage-difference-between-images.icon b/Task/Percentage-difference-between-images/Icon/percentage-difference-between-images.icon new file mode 100644 index 0000000000..6085353d2d --- /dev/null +++ b/Task/Percentage-difference-between-images/Icon/percentage-difference-between-images.icon @@ -0,0 +1,34 @@ +link printf # for main only + +procedure main() # % difference between images + fn1 := "Lenna100.jpg" + fn2 := "Lenna50.jpg" + printf("%%difference of files %i & %i = %r\n",fn1,fn2,ImageDiff(fn1,fn2)) +end + +procedure ImageDiff(fn1,fn2) #: return % difference of two images + img1 := open(1,"g","canvas=hidden","image="||fn1) | stop("Open failed ",fn1) + img2 := open(2,"g","canvas=hidden","image="||fn2) | stop("Open failed ",fn2) + + if WAttrib(img1,"width") ~= WAttrib(img2,"width") | + WAttrib(img1,"height") ~= WAttrib(img2,"height") then + stop("Images must be the same size") + + pix1 := create Pixel(img1) # access pixels one at a time + pix2 := create Pixel(img2) # ... facilitate interleaved access + + sum := pix := 0 + while pix +:= 1 & p1 := csv2l(@pix1) & p2 := csv2l(@pix2) do + every sum +:= abs(p1[i := 1 to *p1] - p2[i]) + every close(img1|img2) + return sum / (pix * 3 * 65535 / 100. ) +end + +procedure csv2l(p) #: return a list from a comma separated string +L := [] +p ? until pos(0) do { + put(L,tab(find(",")|0)) + move(1) + } +return L +end diff --git a/Task/Percentage-difference-between-images/J/percentage-difference-between-images.j b/Task/Percentage-difference-between-images/J/percentage-difference-between-images.j new file mode 100644 index 0000000000..f912b4769b --- /dev/null +++ b/Task/Percentage-difference-between-images/J/percentage-difference-between-images.j @@ -0,0 +1,3 @@ + require 'media/image3' + 'Lenna50.jpg' (+/@,@:|@:- % 2.55 * */@$@])&read_image 'Lenna100.jpg' +1.62559 diff --git a/Task/Percentage-difference-between-images/Java/percentage-difference-between-images.java b/Task/Percentage-difference-between-images/Java/percentage-difference-between-images.java new file mode 100644 index 0000000000..a0c62adad9 --- /dev/null +++ b/Task/Percentage-difference-between-images/Java/percentage-difference-between-images.java @@ -0,0 +1,48 @@ +import java.awt.image.BufferedImage; +import javax.imageio.ImageIO; +import java.io.IOException; +import java.net.URL; + +public class ImgDiffPercent +{ + public static void main(String args[]) + { + BufferedImage img1 = null; + BufferedImage img2 = null; + try { + URL url1 = new URL("http://rosettacode.org/mw/images/3/3c/Lenna50.jpg"); + URL url2 = new URL("http://rosettacode.org/mw/images/b/b6/Lenna100.jpg"); + img1 = ImageIO.read(url1); + img2 = ImageIO.read(url2); + } catch (IOException e) { + e.printStackTrace(); + } + int width1 = img1.getWidth(null); + int width2 = img2.getWidth(null); + int height1 = img1.getHeight(null); + int height2 = img2.getHeight(null); + if ((width1 != width2) || (height1 != height2)) { + System.err.println("Error: Images dimensions mismatch"); + System.exit(1); + } + long diff = 0; + for (int i = 0; i < height1; i++) { + for (int j = 0; j < width1; j++) { + int rgb1 = img1.getRGB(i, j); + int rgb2 = img2.getRGB(i, j); + int r1 = (rgb1 >> 16) & 0xff; + int g1 = (rgb1 >> 8) & 0xff; + int b1 = (rgb1 ) & 0xff; + int r2 = (rgb2 >> 16) & 0xff; + int g2 = (rgb2 >> 8) & 0xff; + int b2 = (rgb2 ) & 0xff; + diff += Math.abs(r1 - r2); + diff += Math.abs(g1 - g2); + diff += Math.abs(b1 - b2); + } + } + double n = width1 * height1 * 3; + double p = diff / n / 255.0; + System.out.println("diff percent: " + (p * 100.0)); + } +} diff --git a/Task/Percentage-difference-between-images/Liberty-BASIC/percentage-difference-between-images.liberty b/Task/Percentage-difference-between-images/Liberty-BASIC/percentage-difference-between-images.liberty new file mode 100644 index 0000000000..5cb118bbe4 --- /dev/null +++ b/Task/Percentage-difference-between-images/Liberty-BASIC/percentage-difference-between-images.liberty @@ -0,0 +1,81 @@ +now =time$( "seconds") +nomainwin + +WindowWidth = 1620 +WindowHeight = 660 + +open "jpeg.dll" for dll as #j ' "JPEG.DLL copyright Alyce Watson, 2003. " + +open "RC Image Comparison- difference shown as 20 times abs( pixel_difference." for graphics_nf_nsb as #1 + #1 "trapclose [quit]" + #1 "down ; fill black" + + hW =hwnd( #1) + calldll #user32,"GetDC", hW as ulong, hdc as ulong + + jname1$ ="Lenna50.jpg" + hPic1 =LoadImageFile( hW, jname1$) + if hPic1 =0 then notice "Function failed.": wait + loadbmp "demo1", hPic1 + hDemo1 =hbmp( "demo1") + #1 "drawbmp demo1 10 10 ; flush" + + jname2$ ="Lenna100.jpg" + hPic2 =LoadImageFile( hW, jname2$) + if hPic2 =0 then notice "Function failed.": wait + loadbmp "demo2", hPic2 + hDemo1 =hbmp( "demo2") + #1 "drawbmp demo2 550 10 ; flush" + + c1 =16777216 + c2 = 65536 + c3 = 256 + x1 =10 + y1 =10 + x2 =550 + y2 =10 + + for y =0 to 511 + for x =0 to 511 + pixel1 =( GetPixel( hdc, x1 +x, y1 +y) + c1) mod c1 + b1 = int( pixel1 /c2) + g1 = int(( pixel1 -b1 *c2) /c3) + r1 = int( pixel1 -b1 *c2 -g1 *c3) + + pixel2 =( GetPixel( hdc, x2 +x, y2 +y) + c1) mod c1 + b2 = int( pixel2 /c2) + g2 = int(( pixel2 -b2 *c2) /c3) + r2 = int( pixel2 -b2 *c2 -g2 *c3) + + totalDiff =totalDiff +abs( r1 -r2) +abs( g1 -g2)+ abs( b1 -b2) + + #1 "color "; 20 *abs( r2 -r1); " "; 20 *abs( g2 -g1); " "; 20 *abs( b2 -b1) + #1 "set "; 1090 +x; " "; 10 +y + scan + next x + next y + + #1 "place 90 575 ; color white ; backcolor black" + #1 "font courier 9 bold" + #1 "\"; " Difference between images ="; using( "#.#####", 100.0 *totalDiff / 512 /512 /3 /255); "%." + #1 "\"; " Rosetta Code for these two images =1.62125%."; " Time taken ="; time$( "seconds") -now; " seconds." + #1 "flush" + +wait + +function LoadImageFile( hWnd, file$) + calldll #j, "LoadImageFile", hWnd as ulong, file$ as ptr, LoadImageFile as ulong +end function + +function GetPixel( hDC, x, y) + calldll #gdi32, "GetPixel", hDC As uLong, x As long, y As long, GetPixel As long +end function + +[quit] + if hPic1 <>0 then calldll #gdi32, "DeleteObject", hPic1 as long, re as long + if hPic2 <>0 then calldll #gdi32, "DeleteObject", hPic2 as long, re as long + if hDemo1 <>0 then unloadbmp "demo1" + if hDemo2 <>0 then unloadbmp "demo2" + close #1 + close #j + end diff --git a/Task/Percentage-difference-between-images/MAXScript/percentage-difference-between-images.maxscript b/Task/Percentage-difference-between-images/MAXScript/percentage-difference-between-images.maxscript new file mode 100644 index 0000000000..931745125e --- /dev/null +++ b/Task/Percentage-difference-between-images/MAXScript/percentage-difference-between-images.maxscript @@ -0,0 +1,19 @@ +fn diffImages = +( + local img1 = selectBitmap caption:"Select Image 1" + local img2 = selectBitmap caption:"Select Image 2" + local totalDiff = 0 + for i in 0 to (img1.height-1) do + ( + local img1Row = getPixels img1 [0, i] img1.width + local img2Row = getPixels img2 [0, i] img2.width + + for j in 1 to img1.width do + ( + totalDiff += (abs (img1Row[j].r - img2Row[j].r)) / 255.0 + totalDiff += (abs (img1Row[j].g - img2Row[j].g)) / 255.0 + totalDiff += (abs (img1Row[j].b - img2Row[j].b)) / 255.0 + ) + ) + format "Diff: %\%\n" (totalDiff / ((img1.width * img1.height * 3) as float) * 100) +) diff --git a/Task/Percentage-difference-between-images/Mathematica/percentage-difference-between-images.math b/Task/Percentage-difference-between-images/Mathematica/percentage-difference-between-images.math new file mode 100644 index 0000000000..94fbf56497 --- /dev/null +++ b/Task/Percentage-difference-between-images/Mathematica/percentage-difference-between-images.math @@ -0,0 +1,5 @@ +img50 = ImageData@Import[NotebookDirectory[] <> "Lenna50.jpg"]; +img100 = ImageData@Import[NotebookDirectory[] <> "Lenna100.jpg"]; +diff = img50 - img100; +Print["Total Difference between both Lenas = ", + Total@Abs@Flatten@diff/Times @@ Dimensions@img50*100, "%"] diff --git a/Task/Percentage-difference-between-images/OCaml/percentage-difference-between-images.ocaml b/Task/Percentage-difference-between-images/OCaml/percentage-difference-between-images.ocaml new file mode 100644 index 0000000000..dda6a0769d --- /dev/null +++ b/Task/Percentage-difference-between-images/OCaml/percentage-difference-between-images.ocaml @@ -0,0 +1,36 @@ +#! /usr/bin/env ocaml +#directory "+glMLite/" +#load "jpeg_loader.cma" +#load "bigarray.cma" +open Jpeg_loader + +let () = + let img1, width1, height1, col_comp1, color_space1 = load_img (Filename Sys.argv.(1)) + and img2, width2, height2, col_comp2, color_space2 = load_img (Filename Sys.argv.(2)) in + + assert(width1 = width2); + assert(height1 = height2); + assert(col_comp1 = col_comp2); (* number of color components *) + assert(color_space1 = color_space2); + + let img1 = Bigarray.array3_of_genarray img1 + and img2 = Bigarray.array3_of_genarray img2 in + + let sum = ref 0.0 + and num = ref 0 in + + for x=0 to pred width1 do + for y=0 to pred height1 do + for c=0 to pred col_comp1 do + let v1 = float img1.{x,y,c} + and v2 = float img2.{x,y,c} in + let diff = (abs_float (v1 -. v2)) /. 255. in + sum := diff +. !sum; + incr num; + done; + done; + done; + + let diff_percent = !sum /. float !num in + Printf.printf " diff: %f percent\n" diff_percent; +;; diff --git a/Task/Percentage-difference-between-images/PicoLisp/percentage-difference-between-images.l b/Task/Percentage-difference-between-images/PicoLisp/percentage-difference-between-images.l new file mode 100644 index 0000000000..e82b1d77cc --- /dev/null +++ b/Task/Percentage-difference-between-images/PicoLisp/percentage-difference-between-images.l @@ -0,0 +1,14 @@ +(call "convert" "Lenna50.jpg" (tmp "Lenna50.ppm")) +(call "convert" "Lenna100.jpg" (tmp "Lenna100.ppm")) + +(let (Total 0 Diff 0) + (in (tmp "Lenna50.ppm") + (in (tmp "Lenna100.ppm") + (while (rd 1) + (inc 'Diff + (*/ + (abs (- @ (in -1 (rd 1)))) + 1000000 + 255 ) ) + (inc 'Total) ) ) ) + (prinl "Difference is " (format (*/ Diff Total) 4) " percent") ) diff --git a/Task/Percentage-difference-between-images/PureBasic/percentage-difference-between-images.purebasic b/Task/Percentage-difference-between-images/PureBasic/percentage-difference-between-images.purebasic new file mode 100644 index 0000000000..774f3f94bd --- /dev/null +++ b/Task/Percentage-difference-between-images/PureBasic/percentage-difference-between-images.purebasic @@ -0,0 +1,52 @@ +#URL1="http://rosettacode.org/mw/images/3/3c/Lenna50.jpg" +#URL2="http://rosettacode.org/mw/images/b/b6/Lenna100.jpg" + +Procedure.s GetTempFileName(basename$="",Extension$=".tmp") + Protected file$, i + Repeat: file$=GetTemporaryDirectory()+basename$+"_"+Str(i)+Extension$: i+1 + Until FileSize(file$) = -1 ; E.g. File not found + ProcedureReturn file$ +EndProcedure + +Procedure ImageToMatrix(Image,Array P(2)) + Protected Width=ImageWidth(0)-1, Height=ImageHeight(0)-1, x, y + ; Scaling down Width & Height by -1 to compensate for using 0-based arrays + Dim P(Width,Height) + StartDrawing(ImageOutput(Image)) + For x=0 To Width + For y=0 To Height + P(x,y)=Point(x,y) + Next y + Next x + StopDrawing() +EndProcedure + +Define File1$, File2$, totalDiff, x, y, w, h + +; Load the pictures from RoettaCode +InitNetwork() +File1$=GetTempFileName("",".jpg"): ReceiveHTTPFile(#URL1,File1$) +File2$=GetTempFileName("",".jpg"): ReceiveHTTPFile(#URL2,File2$) + +; Decode the images & clean up temporary files +UseJPEGImageDecoder() +LoadImage(0,File1$):LoadImage(1,File2$) +DeleteFile(File1$): DeleteFile(File2$) + +; Make two 2D arrays to hold the data +Dim Pic1(0,0): Dim Pic2(0,0) + +;Load the image data into the matrixes +ImageToMatrix(0,Pic1()): ImageToMatrix(1,Pic2()) + +; Compare the data +w=ArraySize(pic1()): h=ArraySize(pic1(),2) +For x=0 To w + For y=0 To h + totalDiff+ Abs( Red(Pic1(x,y)) - Red(Pic2(x,y))) + totalDiff+ Abs(Green(Pic1(x,y)) - Green(Pic2(x,y))) + totalDiff+ Abs( Blue(Pic1(x,y)) - Blue(Pic2(x,y))) + Next y +Next x + +MessageRequester("Result","Diff= "+StrD(100*totalDiff/(255*w*h*3),3)+" %") diff --git a/Task/Percentage-difference-between-images/Python/percentage-difference-between-images.py b/Task/Percentage-difference-between-images/Python/percentage-difference-between-images.py new file mode 100644 index 0000000000..91ef8185b8 --- /dev/null +++ b/Task/Percentage-difference-between-images/Python/percentage-difference-between-images.py @@ -0,0 +1,17 @@ +from itertools import izip +import Image + +i1 = Image.open("image1.jpg") +i2 = Image.open("image2.jpg") +assert i1.mode == i2.mode, "Different kinds of images." +assert i1.size == i2.size, "Different sizes." + +pairs = izip(i1.getdata(), i2.getdata()) +if len(i1.getbands()) == 1: + # for gray-scale jpegs + dif = sum(abs(p1-p2) for p1,p2 in pairs) +else: + dif = sum(abs(c1-c2) for p1,p2 in pairs for c1,c2 in zip(p1,p2)) + +ncomponents = i1.size[0] * i1.size[1] * 3 +print "Difference (percentage):", (dif / 255.0 * 100) / ncomponents diff --git a/Task/Percentage-difference-between-images/REBOL/percentage-difference-between-images.rebol b/Task/Percentage-difference-between-images/REBOL/percentage-difference-between-images.rebol new file mode 100644 index 0000000000..9b5fac5221 --- /dev/null +++ b/Task/Percentage-difference-between-images/REBOL/percentage-difference-between-images.rebol @@ -0,0 +1,52 @@ +REBOL [ + Title: "Percent Image Difference" + Author: oofoe + Date: 2009-12-31 + URL: http://rosettacode.org/wiki/Percentage_of_difference_between_2_images +] + +; Load from local storage. Un/comment as preferred. +; a: load-image %lenna50.jpg +; b: load-image %lenna100.jpg + +; Download from rosettacode.org. +a: load-image http://rosettacode.org/mw/images/3/3c/Lenna50.jpg +b: load-image http://rosettacode.org/mw/images/b/b6/Lenna100.jpg + +if a/size <> b/size [print "Image dimensions must match." halt] + +; Compute difference. REBOL has built-in image processing as part of +; its GUI package that I can take advantage of here: + +diff: to-image layout/tight [image a effect [difference b]] + +; Calculate deviation. I use 'repeat' to rip through the image pixels +; (it knows how to deal with images) and sum, then average. Note that +; I can treat the image like an array to get number of pixels. + +t: 0 +repeat p diff [t: t + p/1 + p/2 + p/3] +print rejoin ["Difference: " 100 * t / (255 * 3 * length? diff) "%"] + +; Optional: Since I now have a difference image, I may as well show +; it. Use the buttons or keys 'a', 'b' and 'd' to switch between the +; various images. + +flip: func [ + "Change to new image and label." + name [word!] "Image to switch to." +][x/text: rejoin ["Image " name] x/image: get name show x] + +; Because the differences between the images are very small, I enhance +; the diff with a high contrast to make the result easier to +; see. Comment this out for the "pure" image. + +diff: to-image layout/tight [image diff effect [contrast 100]] + +view l: layout [ + x: image diff + across + button "a" #"a" [flip 'a] + button "b" #"b" [flip 'b] + button "difference" #"d" [flip 'diff] +] diff --git a/Task/Percentage-difference-between-images/Ruby/percentage-difference-between-images.rb b/Task/Percentage-difference-between-images/Ruby/percentage-difference-between-images.rb new file mode 100644 index 0000000000..4218039d1a --- /dev/null +++ b/Task/Percentage-difference-between-images/Ruby/percentage-difference-between-images.rb @@ -0,0 +1,27 @@ +require 'raster_graphics' + +class RGBColour + # the difference between two colours + def -(a_colour) + (@red - a_colour.red).abs + + (@green - a_colour.green).abs + + (@blue - a_colour.blue).abs + end +end + +class Pixmap + # the difference between two images + def -(a_pixmap) + if @width != a_pixmap.width or @height != a_pixmap.height + raise ArgumentError, "can't compare images with different sizes" + end + sum = 0 + each_pixel {|x,y| sum += self[x,y] - a_pixmap[x,y]} + Float(sum) / (@width * @height * 255 * 3) + end +end + +lenna50 = Pixmap.open_from_jpeg('Lenna50.jpg') +lenna100 = Pixmap.open_from_jpeg('Lenna100.jpg') + +puts "difference: %.5f%%" % (100.0 * (lenna50 - lenna100)) diff --git a/Task/Percentage-difference-between-images/Tcl/percentage-difference-between-images.tcl b/Task/Percentage-difference-between-images/Tcl/percentage-difference-between-images.tcl new file mode 100644 index 0000000000..c3294d04c6 --- /dev/null +++ b/Task/Percentage-difference-between-images/Tcl/percentage-difference-between-images.tcl @@ -0,0 +1,26 @@ +package require Tk + +proc imageDifference {img1 img2} { + if { + [image width $img1] != [image width $img2] || + [image height $img1] != [image height $img2] + } then { + return -code error "images are different size" + } + set diff 0 + for {set x 0} {$x<[image width $img1]} {incr x} { + for {set y 0} {$y<[image height $img1]} {incr y} { + lassign [$img1 get $x $y] r1 g1 b1 + lassign [$img2 get $x $y] r2 g2 b2 + incr diff [expr {abs($r1-$r2)+abs($g1-$g2)+abs($b1-$b2)}] + } + } + expr {$diff/double($x*$y*3*255)} +} + +# Package only used for JPEG loader +package require Img +image create photo lenna50 -file lenna50.jpg +image create photo lenna100 -file lenna100.jpg +puts "difference is [expr {[imageDifference lenna50 lenna100]*100.}]%" +exit ;# Need explicit exit here; don't want a GUI diff --git a/Task/Percentage-difference-between-images/Vedit-macro-language/percentage-difference-between-images.vedit b/Task/Percentage-difference-between-images/Vedit-macro-language/percentage-difference-between-images.vedit new file mode 100644 index 0000000000..8c2a2a8394 --- /dev/null +++ b/Task/Percentage-difference-between-images/Vedit-macro-language/percentage-difference-between-images.vedit @@ -0,0 +1,30 @@ +Chdir("|(USER_MACRO)\Rosetta\data") +File_Open("Lenna50.bmp", BROWSE) +#10 = Buf_Num // #10 = buffer for 1st image +File_Open("Lenna100.bmp", BROWSE) +#20 = Buf_Num // #20 = buffer for 2nd image + +Goto_Pos(10) // offset to pixel data +Goto_Pos(Cur_Char + Cur_Char(1)*256) +Buf_Switch(#10) +Goto_Pos(10) +Goto_Pos(Cur_Char + Cur_Char(1)*256) + +#15 = 0 // #15 = difference +#16 = 0 // #16 = total number of samples +While(!At_EOF) { + #11 = Cur_Char; Char + Buf_Switch(#20) + #21 = Cur_Char; Char + #15 += abs(#11-#21) + #16++ + Buf_Switch(#10) +} + +#19 = #15 / (#16*256/100000) +M("Sum of diff: ") NT(#15) +M("Total bytes: ") NT(#16) +M("Difference: ") NT(#19/1000,LEFT+NOCR) M(".") NT(#19%1000,LEFT+NOCR) M("%\n") + +Buf_Switch(#10) Buf_Quit(OK) +Buf_Switch(#20) Buf_Quit(OK) diff --git a/Task/Perfect-numbers/0DESCRIPTION b/Task/Perfect-numbers/0DESCRIPTION new file mode 100644 index 0000000000..2f0e3b668f --- /dev/null +++ b/Task/Perfect-numbers/0DESCRIPTION @@ -0,0 +1,9 @@ +Write a function which says whether a number is perfect. + +[[wp:Perfect_numbers|A perfect number]] is a positive integer that is the sum of its proper positive divisors excluding the number itself. Equivalently, a perfect number is a number that is half the sum of all of its positive divisors (including itself). + +Note: The faster [[Lucas-Lehmer test]] is used to find primes of the form 2''n''-1, all ''known'' perfect numbers can be derived from these primes using the formula (2''n'' - 1) × 2''n'' - 1. It is not known if there are any odd perfect numbers. + +'''See also''' +* [[Rational Arithmetic]] +*[[oeis:A000396|Perfect numbers on OEIS]] diff --git a/Task/Perfect-numbers/1META.yaml b/Task/Perfect-numbers/1META.yaml new file mode 100644 index 0000000000..9e130e8a7b --- /dev/null +++ b/Task/Perfect-numbers/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Discrete math diff --git a/Task/Perfect-numbers/ALGOL-68/perfect-numbers.alg b/Task/Perfect-numbers/ALGOL-68/perfect-numbers.alg new file mode 100644 index 0000000000..f31a7f0419 --- /dev/null +++ b/Task/Perfect-numbers/ALGOL-68/perfect-numbers.alg @@ -0,0 +1,21 @@ +PROC is perfect = (INT candidate)BOOL: ( + INT sum :=1; + FOR f1 FROM 2 TO ENTIER ( sqrt(candidate)*(1+2*small real) ) WHILE + IF candidate MOD f1 = 0 THEN + sum +:= f1; + INT f2 = candidate OVER f1; + IF f2 > f1 THEN + sum +:= f2 + FI + FI; +# WHILE # sum <= candidate DO + SKIP + OD; + sum=candidate +); + +test:( + FOR i FROM 2 TO 33550336 DO + IF is perfect(i) THEN print((i, new line)) FI + OD +) diff --git a/Task/Perfect-numbers/AWK/perfect-numbers.awk b/Task/Perfect-numbers/AWK/perfect-numbers.awk new file mode 100644 index 0000000000..b1d602dd3a --- /dev/null +++ b/Task/Perfect-numbers/AWK/perfect-numbers.awk @@ -0,0 +1,6 @@ +$ awk 'func perf(n){s=0;for(i=1;i 1 && !Mod(N, A_Index)) + Return false + Return true +} diff --git a/Task/Perfect-numbers/Axiom/perfect-numbers-1.axiom b/Task/Perfect-numbers/Axiom/perfect-numbers-1.axiom new file mode 100644 index 0000000000..9b94ca13eb --- /dev/null +++ b/Task/Perfect-numbers/Axiom/perfect-numbers-1.axiom @@ -0,0 +1 @@ +perfect?(n:Integer):Boolean == reduce(+,divisors n) = 2*n diff --git a/Task/Perfect-numbers/Axiom/perfect-numbers-2.axiom b/Task/Perfect-numbers/Axiom/perfect-numbers-2.axiom new file mode 100644 index 0000000000..f73ae05941 --- /dev/null +++ b/Task/Perfect-numbers/Axiom/perfect-numbers-2.axiom @@ -0,0 +1,7 @@ +)abbrev package TESTP TestPackage +TestPackage() : with + perfect?: Integer -> Boolean + == + add + import IntegerNumberTheoryFunctions + perfect? n == reduce("+",divisors n) = 2*n diff --git a/Task/Perfect-numbers/Axiom/perfect-numbers-3.axiom b/Task/Perfect-numbers/Axiom/perfect-numbers-3.axiom new file mode 100644 index 0000000000..32553efb67 --- /dev/null +++ b/Task/Perfect-numbers/Axiom/perfect-numbers-3.axiom @@ -0,0 +1,3 @@ +perfect? 496 +perfect? 128 +[i for i in 1..10000 | perfect? i] diff --git a/Task/Perfect-numbers/Axiom/perfect-numbers-4.axiom b/Task/Perfect-numbers/Axiom/perfect-numbers-4.axiom new file mode 100644 index 0000000000..2f2b4acdf5 --- /dev/null +++ b/Task/Perfect-numbers/Axiom/perfect-numbers-4.axiom @@ -0,0 +1,3 @@ +true +false +[6,28,496,8128] diff --git a/Task/Perfect-numbers/BASIC/perfect-numbers.basic b/Task/Perfect-numbers/BASIC/perfect-numbers.basic new file mode 100644 index 0000000000..8ddb3c6dfe --- /dev/null +++ b/Task/Perfect-numbers/BASIC/perfect-numbers.basic @@ -0,0 +1,13 @@ +FUNCTION perf(n) + sum = 0 + for i = 1 to n - 1 + IF n MOD i = 0 THEN + sum = sum + i + END IF + NEXT i + IF sum = n THEN + perf = 1 + ELSE + perf = 0 + END IF +END FUNCTION diff --git a/Task/Perfect-numbers/BBC-BASIC/perfect-numbers-1.bbc b/Task/Perfect-numbers/BBC-BASIC/perfect-numbers-1.bbc new file mode 100644 index 0000000000..0a340cf23d --- /dev/null +++ b/Task/Perfect-numbers/BBC-BASIC/perfect-numbers-1.bbc @@ -0,0 +1,13 @@ + FOR n% = 2 TO 10000 STEP 2 + IF FNperfect(n%) PRINT n% + NEXT + END + + DEF FNperfect(N%) + LOCAL I%, S% + S% = 1 + FOR I% = 2 TO SQR(N%)-1 + IF N% MOD I% = 0 S% += I% + N% DIV I% + NEXT + IF I% = SQR(N%) S% += I% + = (N% = S%) diff --git a/Task/Perfect-numbers/BBC-BASIC/perfect-numbers-2.bbc b/Task/Perfect-numbers/BBC-BASIC/perfect-numbers-2.bbc new file mode 100644 index 0000000000..1602614fd9 --- /dev/null +++ b/Task/Perfect-numbers/BBC-BASIC/perfect-numbers-2.bbc @@ -0,0 +1,10 @@ + DIM P% 100 + [OPT 2 :.S% xor edi,edi + .perloop mov eax,ebx : cdq : div ecx : or edx,edx : loopnz perloop : inc ecx + add edi,ecx : add edi,eax : loop perloop : mov eax,edi : shr eax,1 : ret : ] + + FOR B% = 2 TO 35000000 STEP 2 + C% = SQRB% + IF B% = USRS% PRINT B% + NEXT + END diff --git a/Task/Perfect-numbers/Bracmat/perfect-numbers.bracmat b/Task/Perfect-numbers/Bracmat/perfect-numbers.bracmat new file mode 100644 index 0000000000..50ef3befe9 --- /dev/null +++ b/Task/Perfect-numbers/Bracmat/perfect-numbers.bracmat @@ -0,0 +1,18 @@ +( ( perf + = sum i + . 0:?sum + & 0:?i + & whl + ' ( !i+1:10000:?n + & (perf$!n&out$!n|) + ) +); diff --git a/Task/Perfect-numbers/C++/perfect-numbers.cpp b/Task/Perfect-numbers/C++/perfect-numbers.cpp new file mode 100644 index 0000000000..07cc2d7ddc --- /dev/null +++ b/Task/Perfect-numbers/C++/perfect-numbers.cpp @@ -0,0 +1,21 @@ +#include +using namespace std ; + +bool is_perfect( int ) ; + +int main( ) { + cout << "Perfect numbers from 1 to 33550337:\n" ; + for ( int num = 1 ; num < 33550337 ; num++ ) { + if ( is_perfect( num ) ) + cout << num << '\n' ; + } + return 0 ; +} + +bool is_perfect( int number ) { + int sum = 0 ; + for ( int i = 1 ; i < number ; i++ ) + if ( number % i == 0 ) + sum += i ; + return sum == number ; +} diff --git a/Task/Perfect-numbers/C/perfect-numbers-1.c b/Task/Perfect-numbers/C/perfect-numbers-1.c new file mode 100644 index 0000000000..8d5a231b6c --- /dev/null +++ b/Task/Perfect-numbers/C/perfect-numbers-1.c @@ -0,0 +1,27 @@ +#include "stdio.h" +#include "math.h" + +int perfect(int n) { + int max = (int)sqrt((double)n) + 1; + int tot = 1; + int i; + + for (i = 2; i < max; i++) + if ( (n % i) == 0 ) { + tot += i; + int q = n / i; + if (q > i) + tot += q; + } + + return tot == n; +} + +int main() { + int n; + for (n = 2; n < 33550337; n++) + if (perfect(n)) + printf("%d\n", n); + + return 0; +} diff --git a/Task/Perfect-numbers/C/perfect-numbers-2.c b/Task/Perfect-numbers/C/perfect-numbers-2.c new file mode 100644 index 0000000000..2965db14d0 --- /dev/null +++ b/Task/Perfect-numbers/C/perfect-numbers-2.c @@ -0,0 +1,15 @@ +int main() +{ + int j; + ulong fac[10000], n, sum; + + sieve(); + + for (n = 2; n < 33550337; n++) { + j = get_factors(n, fac) - 1; + for (sum = 0; j && sum <= n; sum += fac[--j]); + if (sum == n) printf("%lu\n", n); + } + + return 0; +} diff --git a/Task/Perfect-numbers/Clojure/perfect-numbers-1.clj b/Task/Perfect-numbers/Clojure/perfect-numbers-1.clj new file mode 100644 index 0000000000..98ebb804cf --- /dev/null +++ b/Task/Perfect-numbers/Clojure/perfect-numbers-1.clj @@ -0,0 +1,8 @@ +(defn proper-divisors [n] + (if (< n 4) + '(1) + (cons 1 (filter #(zero? (rem n %)) (range 2 (inc (quot n 2)))))) +) +(defn perfect? [n] + (== (reduce + (proper-divisors n)) n) +) diff --git a/Task/Perfect-numbers/Clojure/perfect-numbers-2.clj b/Task/Perfect-numbers/Clojure/perfect-numbers-2.clj new file mode 100644 index 0000000000..bef650e943 --- /dev/null +++ b/Task/Perfect-numbers/Clojure/perfect-numbers-2.clj @@ -0,0 +1,2 @@ +(defn perfect? [n] + (= n (reduce + (for [i (range 1 n) :when (= 0 (mod n i))] i)))) diff --git a/Task/Perfect-numbers/CoffeeScript/perfect-numbers.coffeescript b/Task/Perfect-numbers/CoffeeScript/perfect-numbers.coffeescript new file mode 100644 index 0000000000..9292cd3e1b --- /dev/null +++ b/Task/Perfect-numbers/CoffeeScript/perfect-numbers.coffeescript @@ -0,0 +1,49 @@ +is_perfect_number = (n) -> + do_factors_add_up_to n, 2*n + +do_factors_add_up_to = (n, desired_sum) -> + # We mildly optimize here, by taking advantage of + # the fact that the sum_of_factors( (p^m) * x) + # is (1 + ... + p^m-1 + p^m) * sum_factors(x) when + # x is not itself a multiple of p. + + p = smallest_prime_factor(n) + if p == n + return desired_sum == p + 1 + + # ok, now sum up all powers of p that + # divide n + sum_powers = 1 + curr_power = 1 + while n % p == 0 + curr_power *= p + sum_powers += curr_power + n /= p + + # if desired_sum does not divide sum_powers, we + # can short circuit quickly + return false unless desired_sum % sum_powers == 0 + + # otherwise, recurse + do_factors_add_up_to n, desired_sum / sum_powers + +smallest_prime_factor = (n) -> + for i in [2..n] + return n if i*i > n + return i if n % i == 0 + +# tests +do -> + # This is pretty fast... + for n in [2..100000] + console.log n if is_perfect_number n + + # For big numbers, let's just sanity check the known ones. + known_perfects = [ + 33550336 + 8589869056 + 137438691328 + ] + for n in known_perfects + throw Error("fail") unless is_perfect_number(n) + throw Error("fail") if is_perfect_number(n+1) diff --git a/Task/Perfect-numbers/Common-Lisp/perfect-numbers.lisp b/Task/Perfect-numbers/Common-Lisp/perfect-numbers.lisp new file mode 100644 index 0000000000..49c66d9dc8 --- /dev/null +++ b/Task/Perfect-numbers/Common-Lisp/perfect-numbers.lisp @@ -0,0 +1,2 @@ +(defun perfectp (n) + (= n (loop for i from 1 below n when (= 0 (mod n i)) sum i))) diff --git a/Task/Perfect-numbers/D/perfect-numbers-1.d b/Task/Perfect-numbers/D/perfect-numbers-1.d new file mode 100644 index 0000000000..6539a1ce8e --- /dev/null +++ b/Task/Perfect-numbers/D/perfect-numbers-1.d @@ -0,0 +1,21 @@ +import std.stdio, std.math, std.range, std.algorithm; + +bool isPerfectNumber(in int n) pure nothrow { + if (n < 2) + return false; + + int sum = 1; + foreach (i; 2 .. cast(int)sqrt(cast(real)n) + 1) + if (n % i == 0) { + immutable int q = n / i; + sum += i; + if (q > i) + sum += q; + } + + return sum == n; +} + +void main() { + iota(10_000).filter!isPerfectNumber().writeln(); +} diff --git a/Task/Perfect-numbers/D/perfect-numbers-2.d b/Task/Perfect-numbers/D/perfect-numbers-2.d new file mode 100644 index 0000000000..dce33aca15 --- /dev/null +++ b/Task/Perfect-numbers/D/perfect-numbers-2.d @@ -0,0 +1,9 @@ +import std.stdio, std.algorithm, std.range; + +bool isPerfect(in int n) /*pure nothrow*/ { + return n == iota(1, n - 1).reduce!((s, i) => n % i ? s : s + i)(); +} + +void main() { + iota(3, 10_000).filter!isPerfect().writeln(); +} diff --git a/Task/Perfect-numbers/E/perfect-numbers.e b/Task/Perfect-numbers/E/perfect-numbers.e new file mode 100644 index 0000000000..ae8cc01b23 --- /dev/null +++ b/Task/Perfect-numbers/E/perfect-numbers.e @@ -0,0 +1,9 @@ +pragma.enable("accumulator") +def isPerfectNumber(x :int) { + var sum := 0 + for d ? (x % d <=> 0) in 1..!x { + sum += d + if (sum > x) { return false } + } + return sum <=> x +} diff --git a/Task/Perfect-numbers/Erlang/perfect-numbers.erl b/Task/Perfect-numbers/Erlang/perfect-numbers.erl new file mode 100644 index 0000000000..18b364e5a5 --- /dev/null +++ b/Task/Perfect-numbers/Erlang/perfect-numbers.erl @@ -0,0 +1,2 @@ +is_perfect(X) -> + X == lists:sum([N || N <- lists:seq(1,X-1), X rem N == 0]). diff --git a/Task/Perfect-numbers/FALSE/perfect-numbers.false b/Task/Perfect-numbers/FALSE/perfect-numbers.false new file mode 100644 index 0000000000..f6af9149a2 --- /dev/null +++ b/Task/Perfect-numbers/FALSE/perfect-numbers.false @@ -0,0 +1,2 @@ +[0\1[\$@$@-][\$@$@$@$@\/*=[@\$@+@@]?1+]#%=]p: +45p;!." "28p;!. { 0 -1 } diff --git a/Task/Perfect-numbers/Factor/perfect-numbers.factor b/Task/Perfect-numbers/Factor/perfect-numbers.factor new file mode 100644 index 0000000000..83276f1cab --- /dev/null +++ b/Task/Perfect-numbers/Factor/perfect-numbers.factor @@ -0,0 +1,4 @@ +USING: kernel math math.primes.factors sequences ; +IN: rosettacode.perfect-numbers + +: perfect? ( n -- ? ) [ divisors sum ] [ 2 * ] bi = ; diff --git a/Task/Perfect-numbers/Forth/perfect-numbers.fth b/Task/Perfect-numbers/Forth/perfect-numbers.fth new file mode 100644 index 0000000000..7e2d557bba --- /dev/null +++ b/Task/Perfect-numbers/Forth/perfect-numbers.fth @@ -0,0 +1,6 @@ +: perfect? ( n -- ? ) + 1 + over 2/ 1+ 2 ?do + over i mod 0= if i + then + loop + = ; diff --git a/Task/Perfect-numbers/Fortran/perfect-numbers.f b/Task/Perfect-numbers/Fortran/perfect-numbers.f new file mode 100644 index 0000000000..9cba187468 --- /dev/null +++ b/Task/Perfect-numbers/Fortran/perfect-numbers.f @@ -0,0 +1,12 @@ +FUNCTION isPerfect(n) + LOGICAL :: isPerfect + INTEGER, INTENT(IN) :: n + INTEGER :: i, factorsum + + isPerfect = .FALSE. + factorsum = 1 + DO i = 2, INT(SQRT(REAL(n))) + IF(MOD(n, i) == 0) factorsum = factorsum + i + (n / i) + END DO + IF (factorsum == n) isPerfect = .TRUE. +END FUNCTION isPerfect diff --git a/Task/Perfect-numbers/GAP/perfect-numbers.gap b/Task/Perfect-numbers/GAP/perfect-numbers.gap new file mode 100644 index 0000000000..b6ddef1a8b --- /dev/null +++ b/Task/Perfect-numbers/GAP/perfect-numbers.gap @@ -0,0 +1,2 @@ +Filtered([1 .. 10000], n -> Sum(DivisorsInt(n)) = 2*n); +# [ 6, 28, 496, 8128 ] diff --git a/Task/Perfect-numbers/Go/perfect-numbers.go b/Task/Perfect-numbers/Go/perfect-numbers.go new file mode 100644 index 0000000000..6b733b04b7 --- /dev/null +++ b/Task/Perfect-numbers/Go/perfect-numbers.go @@ -0,0 +1,36 @@ +package main + +import "fmt" + +// following function satisfies the task, returning true for all +// perfect numbers representable in the argument type +func isPerfect(n int64) bool { + switch n { + case 6, 28, 496, 8128, 33550336, 8589869056, + 137438691328, 2305843008139952128: + return true + } + return false +} + +// validation +func main() { + for n := int64(1); ; n++ { + if isPerfect(n) != computePerfect(n) { + panic("bug") + } + if n%1e3 == 0 { + fmt.Println("tested", n) + } + } +} + +func computePerfect(n int64) bool { + var sum int64 + for i := int64(1); i < n; i++ { + if n%i == 0 { + sum += i + } + } + return sum == n +} diff --git a/Task/Perfect-numbers/Groovy/perfect-numbers-1.groovy b/Task/Perfect-numbers/Groovy/perfect-numbers-1.groovy new file mode 100644 index 0000000000..af2c8332ae --- /dev/null +++ b/Task/Perfect-numbers/Groovy/perfect-numbers-1.groovy @@ -0,0 +1,3 @@ +def isPerfect = { n -> + n > 4 && (n == (2..Math.sqrt(n)).findAll { n % it == 0 }.inject(1) { factorSum, i -> factorSum += i + n/i }) +} diff --git a/Task/Perfect-numbers/Groovy/perfect-numbers-2.groovy b/Task/Perfect-numbers/Groovy/perfect-numbers-2.groovy new file mode 100644 index 0000000000..bdc7888b4e --- /dev/null +++ b/Task/Perfect-numbers/Groovy/perfect-numbers-2.groovy @@ -0,0 +1 @@ +(0..10000).findAll { isPerfect(it) }.each { println it } diff --git a/Task/Perfect-numbers/Haskell/perfect-numbers-1.hs b/Task/Perfect-numbers/Haskell/perfect-numbers-1.hs new file mode 100644 index 0000000000..b98d7d3c99 --- /dev/null +++ b/Task/Perfect-numbers/Haskell/perfect-numbers-1.hs @@ -0,0 +1 @@ +perf n = n == sum [i | i <- [1..n-1], n `mod` i == 0] diff --git a/Task/Perfect-numbers/Haskell/perfect-numbers-2.hs b/Task/Perfect-numbers/Haskell/perfect-numbers-2.hs new file mode 100644 index 0000000000..df87da5507 --- /dev/null +++ b/Task/Perfect-numbers/Haskell/perfect-numbers-2.hs @@ -0,0 +1,15 @@ +perfect = map (\x -> (2^x - 1) * (2^(x - 1))) $ + filter (\x -> isPrime x && isPrime (2^x - 1)) maybe_prime where + maybe_prime = scanl1 (+) (2:1:cycle [2,2,4,2,4,2,4,6]) + isPrime n = all ((/=0).(n`mod`)) $ + takeWhile (\x -> x*x <= n) maybe_prime + +isPerfect n = f n perfect where + f n (p:ps) = case compare n p of + EQ -> True + LT -> False + GT -> f n ps + +main = do + mapM_ print $ take 10 perfect + mapM_ print $ map (\x -> (x, isPerfect x)) [6,27,28,29,496,8128,8129] diff --git a/Task/Perfect-numbers/HicEst/perfect-numbers.hicest b/Task/Perfect-numbers/HicEst/perfect-numbers.hicest new file mode 100644 index 0000000000..29e995f475 --- /dev/null +++ b/Task/Perfect-numbers/HicEst/perfect-numbers.hicest @@ -0,0 +1,12 @@ + DO i = 1, 1E4 + IF( perfect(i) ) WRITE() i + ENDDO +END ! end of "main" + +FUNCTION perfect(n) + sum = 1 + DO i = 2, n^0.5 + sum = sum + (MOD(n, i) == 0) * (i + INT(n/i)) + ENDDO + perfect = sum == n +END diff --git a/Task/Perfect-numbers/Icon/perfect-numbers.icon b/Task/Perfect-numbers/Icon/perfect-numbers.icon new file mode 100644 index 0000000000..74d06ca088 --- /dev/null +++ b/Task/Perfect-numbers/Icon/perfect-numbers.icon @@ -0,0 +1,15 @@ +procedure main(arglist) +limit := \arglist[1] | 100000 +write("Perfect numbers from 1 to ",limit,":") +every write(isperfect(1 to limit)) +write("Done.") +end + +procedure isperfect(n) #: returns n if n is perfect +local sum,i + +every (sum := 0) +:= (n ~= divisors(n)) +if sum = n then return n +end + +link factors diff --git a/Task/Perfect-numbers/J/perfect-numbers-1.j b/Task/Perfect-numbers/J/perfect-numbers-1.j new file mode 100644 index 0000000000..4f461b21e9 --- /dev/null +++ b/Task/Perfect-numbers/J/perfect-numbers-1.j @@ -0,0 +1 @@ +is_perfect=: = [: +/ ((0=]|[)i.) # i. diff --git a/Task/Perfect-numbers/J/perfect-numbers-2.j b/Task/Perfect-numbers/J/perfect-numbers-2.j new file mode 100644 index 0000000000..137e2095cd --- /dev/null +++ b/Task/Perfect-numbers/J/perfect-numbers-2.j @@ -0,0 +1,14 @@ + is_perfect 33550336 +1 + }.I. is_perfect"0 i. 10000 +6 28 496 8128 + + ] zero_through_twentynine =. i. 3 10 + 0 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 + is_pos_int=: 0&< *. ]=>. + (is_perfect"0 *. is_pos_int) zero_through_twentynine +0 0 0 0 0 0 1 0 0 0 +0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 1 0 diff --git a/Task/Perfect-numbers/Java/perfect-numbers-1.java b/Task/Perfect-numbers/Java/perfect-numbers-1.java new file mode 100644 index 0000000000..7b9a510390 --- /dev/null +++ b/Task/Perfect-numbers/Java/perfect-numbers-1.java @@ -0,0 +1,9 @@ +public static boolean perf(int n){ + int sum= 0; + for(int i= 1;i < n;i++){ + if(n % i == 0){ + sum+= i; + } + } + return sum == n; +} diff --git a/Task/Perfect-numbers/Java/perfect-numbers-2.java b/Task/Perfect-numbers/Java/perfect-numbers-2.java new file mode 100644 index 0000000000..e48a64275c --- /dev/null +++ b/Task/Perfect-numbers/Java/perfect-numbers-2.java @@ -0,0 +1,12 @@ +import java.math.BigInteger; + +public static boolean perf(BigInteger n){ + BigInteger sum= BigInteger.ZERO; + for(BigInteger i= BigInteger.ONE; + i.compareTo(n) < 0;i=i.add(BigInteger.ONE)){ + if(n.mod(i).equals(BigInteger.ZERO)){ + sum= sum.add(i); + } + } + return sum.equals(n); +} diff --git a/Task/Perfect-numbers/JavaScript/perfect-numbers.js b/Task/Perfect-numbers/JavaScript/perfect-numbers.js new file mode 100644 index 0000000000..5722138a8f --- /dev/null +++ b/Task/Perfect-numbers/JavaScript/perfect-numbers.js @@ -0,0 +1,21 @@ +function is_perfect(n) +{ + var sum = 1, i, sqrt=Math.floor(Math.sqrt(n)); + for (i = sqrt-1; i>1; i--) + { + if (n % i == 0) { + sum += i + n/i; + } + } + if(n % sqrt == 0) + sum += sqrt + (sqrt*sqrt == n ? 0 : n/sqrt); + return sum === n; +} + + +var i; +for (i = 1; i < 10000; i++) +{ + if (is_perfect(i)) + print(i); +} diff --git a/Task/Perfect-numbers/Julia/perfect-numbers.julia b/Task/Perfect-numbers/Julia/perfect-numbers.julia new file mode 100644 index 0000000000..1832759b48 --- /dev/null +++ b/Task/Perfect-numbers/Julia/perfect-numbers.julia @@ -0,0 +1,20 @@ +julia> function isperfect(n) + n == sum([n % i == 0 ? i : 0 for i = 1:n-1]) +end +# method added to generic function isperfect + +julia> function perfects(n) + a = ref(Int64) + for i = 1:n + isperfect(i) && push!(a,i) + end + return a +end +# method added to generic function perfects + +julia> perfects(10000) +4-element Int64 Array: + 6 + 28 + 496 + 8128 diff --git a/Task/Perfect-numbers/K/perfect-numbers.k b/Task/Perfect-numbers/K/perfect-numbers.k new file mode 100644 index 0000000000..ba773c64f1 --- /dev/null +++ b/Task/Perfect-numbers/K/perfect-numbers.k @@ -0,0 +1,16 @@ + perfect:{(x>2)&x=+/-1_{d:&~x!'!1+_sqrt x;d,_ x%|d}x} + perfect 33550336 +1 + + a@&perfect'a:!10000 +6 28 496 8128 + + m:3 10#!30 +(0 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) + + perfect'/: m +(0 0 0 0 0 0 1 0 0 0 + 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 1 0) diff --git a/Task/Perfect-numbers/Liberty-BASIC/perfect-numbers.liberty b/Task/Perfect-numbers/Liberty-BASIC/perfect-numbers.liberty new file mode 100644 index 0000000000..efd350924a --- /dev/null +++ b/Task/Perfect-numbers/Liberty-BASIC/perfect-numbers.liberty @@ -0,0 +1,19 @@ +for n =1 to 10000 + if perfect( n) =1 then print n; " is perfect." +next n + +end + +function perfect( n) + sum =0 + for i =1 TO n /2 + if n mod i =0 then + sum =sum +i + end if + next i + if sum =n then + perfect= 1 + else + perfect =0 + end if +end function diff --git a/Task/Perfect-numbers/Logo/perfect-numbers.logo b/Task/Perfect-numbers/Logo/perfect-numbers.logo new file mode 100644 index 0000000000..f1600a2a84 --- /dev/null +++ b/Task/Perfect-numbers/Logo/perfect-numbers.logo @@ -0,0 +1,3 @@ +to perfect? :n + output equal? :n apply "sum filter [equal? 0 modulo :n ?] iseq 1 :n/2 +end diff --git a/Task/Perfect-numbers/Lua/perfect-numbers.lua b/Task/Perfect-numbers/Lua/perfect-numbers.lua new file mode 100644 index 0000000000..e973646a58 --- /dev/null +++ b/Task/Perfect-numbers/Lua/perfect-numbers.lua @@ -0,0 +1,7 @@ +function isPerfect(x) + local sum = 0 + for i = 1, x-1 do + sum = (x % i) == 0 and sum + i or sum + end + return sum == x +end diff --git a/Task/Perfect-numbers/M4/perfect-numbers.m4 b/Task/Perfect-numbers/M4/perfect-numbers.m4 new file mode 100644 index 0000000000..a7b6d9d67d --- /dev/null +++ b/Task/Perfect-numbers/M4/perfect-numbers.m4 @@ -0,0 +1,19 @@ +define(`for', + `ifelse($#,0,``$0'', + `ifelse(eval($2<=$3),1, + `pushdef(`$1',$2)$4`'popdef(`$1')$0(`$1',incr($2),$3,`$4')')')')dnl + +define(`ispart', + `ifelse(eval($2*$2<=$1),1, + `ifelse(eval($1%$2==0),1, + `ifelse(eval($2*$2==$1),1, + `ispart($1,incr($2),eval($3+$2))', + `ispart($1,incr($2),eval($3+$2+$1/$2))')', + `ispart($1,incr($2),$3)')', + $3)') +define(`isperfect', + `eval(ispart($1,2,1)==$1)') + +for(`x',`2',`33550336', + `ifelse(isperfect(x),1,`x +')') diff --git a/Task/Perfect-numbers/MAXScript/perfect-numbers.maxscript b/Task/Perfect-numbers/MAXScript/perfect-numbers.maxscript new file mode 100644 index 0000000000..4d239182ec --- /dev/null +++ b/Task/Perfect-numbers/MAXScript/perfect-numbers.maxscript @@ -0,0 +1,12 @@ +fn isPerfect n = +( + local sum = 0 + for i in 1 to (n-1) do + ( + if mod n i == 0 then + ( + sum += i + ) + ) + sum == n +) diff --git a/Task/Perfect-numbers/Mathematica/perfect-numbers-1.math b/Task/Perfect-numbers/Mathematica/perfect-numbers-1.math new file mode 100644 index 0000000000..2777461acc --- /dev/null +++ b/Task/Perfect-numbers/Mathematica/perfect-numbers-1.math @@ -0,0 +1 @@ +PerfectQ[i_Integer] := Total[Divisors[i]] == 2 i diff --git a/Task/Perfect-numbers/Mathematica/perfect-numbers-2.math b/Task/Perfect-numbers/Mathematica/perfect-numbers-2.math new file mode 100644 index 0000000000..4b1cb1071d --- /dev/null +++ b/Task/Perfect-numbers/Mathematica/perfect-numbers-2.math @@ -0,0 +1,3 @@ +PerfectQ[496] +PerfectQ[128] +Flatten[PerfectQ/@Range[10000]//Position[#,True]&] diff --git a/Task/Perfect-numbers/Mathematica/perfect-numbers-3.math b/Task/Perfect-numbers/Mathematica/perfect-numbers-3.math new file mode 100644 index 0000000000..a55b137e7e --- /dev/null +++ b/Task/Perfect-numbers/Mathematica/perfect-numbers-3.math @@ -0,0 +1,3 @@ +True +False +{6,28,496,8128} diff --git a/Task/Perfect-numbers/Maxima/perfect-numbers.maxima b/Task/Perfect-numbers/Maxima/perfect-numbers.maxima new file mode 100644 index 0000000000..b4513db189 --- /dev/null +++ b/Task/Perfect-numbers/Maxima/perfect-numbers.maxima @@ -0,0 +1,7 @@ +".."(a, b) := makelist(i, i, a, b)$ +infix("..")$ + +perfectp(n) := is(divsum(n) = 2*n)$ + +sublist(1 .. 10000, perfectp); +/* [6, 28, 496, 8128] */ diff --git a/Task/Perfect-numbers/OCaml/perfect-numbers-1.ocaml b/Task/Perfect-numbers/OCaml/perfect-numbers-1.ocaml new file mode 100644 index 0000000000..0207cc72b7 --- /dev/null +++ b/Task/Perfect-numbers/OCaml/perfect-numbers-1.ocaml @@ -0,0 +1,7 @@ +let perf n = + let sum = ref 0 in + for i = 1 to n-1 do + if n mod i = 0 then + sum := !sum + i + done; + !sum = n diff --git a/Task/Perfect-numbers/OCaml/perfect-numbers-2.ocaml b/Task/Perfect-numbers/OCaml/perfect-numbers-2.ocaml new file mode 100644 index 0000000000..9828333217 --- /dev/null +++ b/Task/Perfect-numbers/OCaml/perfect-numbers-2.ocaml @@ -0,0 +1,8 @@ +(* range operator *) +let rec (--) a b = + if a > b then + [] + else + a :: (a+1) -- b + +let perf n = n = List.fold_left (+) 0 (List.filter (fun i -> n mod i = 0) (1 -- (n-1))) diff --git a/Task/Perfect-numbers/Objeck/perfect-numbers.objeck b/Task/Perfect-numbers/Objeck/perfect-numbers.objeck new file mode 100644 index 0000000000..32998132f0 --- /dev/null +++ b/Task/Perfect-numbers/Objeck/perfect-numbers.objeck @@ -0,0 +1,23 @@ +bundle Default { + class Test { + function : Main(args : String[]) ~ Nil { + "Perfect numbers from 1 to 33550337:"->PrintLine(); + for(num := 1 ; num < 33550337; num += 1;) { + if(IsPerfect(num)) { + num->PrintLine(); + }; + }; + } + + function : native : IsPerfect(number : Int) ~ Bool { + sum := 0 ; + for(i := 1; i < number; i += 1;) { + if (number % i = 0) { + sum += i; + }; + }; + + return sum = number; + } + } +} diff --git a/Task/Perfect-numbers/Oz/perfect-numbers.oz b/Task/Perfect-numbers/Oz/perfect-numbers.oz new file mode 100644 index 0000000000..3bdddda97d --- /dev/null +++ b/Task/Perfect-numbers/Oz/perfect-numbers.oz @@ -0,0 +1,12 @@ +declare + fun {IsPerfect N} + fun {IsNFactor I} N mod I == 0 end + Factors = {Filter {List.number 1 N-1 1} IsNFactor} + in + {Sum Factors} == N + end + + fun {Sum Xs} {FoldL Xs Number.'+' 0} end +in + {Show {Filter {List.number 1 10000 1} IsPerfect}} + {Show {IsPerfect 33550336}} diff --git a/Task/Perfect-numbers/PARI-GP/perfect-numbers-1.pari b/Task/Perfect-numbers/PARI-GP/perfect-numbers-1.pari new file mode 100644 index 0000000000..7f9e99dfc5 --- /dev/null +++ b/Task/Perfect-numbers/PARI-GP/perfect-numbers-1.pari @@ -0,0 +1 @@ +isPerfect(n)=sigma(n,-1)==2 diff --git a/Task/Perfect-numbers/PARI-GP/perfect-numbers-2.pari b/Task/Perfect-numbers/PARI-GP/perfect-numbers-2.pari new file mode 100644 index 0000000000..98b4c200e9 --- /dev/null +++ b/Task/Perfect-numbers/PARI-GP/perfect-numbers-2.pari @@ -0,0 +1,3 @@ +forprime(p=2, 2281, + if(isprime(2^p-1), + print(p"\t",(2^p-1)*2^(p-1)))) diff --git a/Task/Perfect-numbers/PARI-GP/perfect-numbers-3.pari b/Task/Perfect-numbers/PARI-GP/perfect-numbers-3.pari new file mode 100644 index 0000000000..a13925abc6 --- /dev/null +++ b/Task/Perfect-numbers/PARI-GP/perfect-numbers-3.pari @@ -0,0 +1,9 @@ +p=2;n=3;n1=2; +while(p<2281, + if(isprime(p), + s=Mod(4,n); + for(i=3,p, + s=s*s-2); + if(s==0 || p==2, + print("(2^"p"-1)2^("p"-1)=\t"n1*n"\n"))); + p++; n1=n+1; n=2*n+1) diff --git a/Task/Perfect-numbers/PHP/perfect-numbers.php b/Task/Perfect-numbers/PHP/perfect-numbers.php new file mode 100644 index 0000000000..dd26b0d3d6 --- /dev/null +++ b/Task/Perfect-numbers/PHP/perfect-numbers.php @@ -0,0 +1,17 @@ +function is_perfect($number) +{ + $sum = 0; + for($i = 1; $i < $number; $i++) + { + if($number % $i == 0) + $sum += $i; + } + return $sum == $number; +} + +echo "Perfect numbers from 1 to 33550337:" . PHP_EOL; +for($num = 1; $num < 33550337; $num++) +{ + if(is_perfect($num)) + echo $num . PHP_EOL; +} diff --git a/Task/Perfect-numbers/PL-I/perfect-numbers.pli b/Task/Perfect-numbers/PL-I/perfect-numbers.pli new file mode 100644 index 0000000000..95cf6d17b2 --- /dev/null +++ b/Task/Perfect-numbers/PL-I/perfect-numbers.pli @@ -0,0 +1,11 @@ +perfect: procedure (n) returns (bit(1)); + declare n fixed; + declare sum fixed; + declare i fixed binary; + + sum = 0; + do i = 1 to n-1; + if mod(n, i) = 0 then sum = sum + i; + end; + return (sum=n); +end perfect; diff --git a/Task/Perfect-numbers/Pascal/perfect-numbers.pascal b/Task/Perfect-numbers/Pascal/perfect-numbers.pascal new file mode 100644 index 0000000000..2531f06d82 --- /dev/null +++ b/Task/Perfect-numbers/Pascal/perfect-numbers.pascal @@ -0,0 +1,23 @@ +program PerfectNumbers; + + function isPerfect(number: longint): boolean; + var + i, sum: longint; + + begin + sum := 1; + for i := 2 to round(sqrt(real(number))) do + if (number mod i = 0) then + sum := sum + i + (number div i); + isPerfect := (sum = number); + end; + +var + candidate: longint; + +begin + writeln('Perfect numbers from 1 to 33550337:'); + for candidate := 2 to 33550337 do + if isPerfect(candidate) then + writeln (candidate, ' is a perfect number.'); +end. diff --git a/Task/Perfect-numbers/Perl-6/perfect-numbers.pl6 b/Task/Perfect-numbers/Perl-6/perfect-numbers.pl6 new file mode 100644 index 0000000000..80433532f6 --- /dev/null +++ b/Task/Perfect-numbers/Perl-6/perfect-numbers.pl6 @@ -0,0 +1 @@ +sub perf($n) { $n == [+] grep $n %% *, 1 .. $n div 2 } diff --git a/Task/Perfect-numbers/Perl/perfect-numbers-1.pl b/Task/Perfect-numbers/Perl/perfect-numbers-1.pl new file mode 100644 index 0000000000..5f61e309cf --- /dev/null +++ b/Task/Perfect-numbers/Perl/perfect-numbers-1.pl @@ -0,0 +1,10 @@ +sub perf { + my $n = shift; + my $sum = 0; + foreach my $i (1..$n-1) { + if ($n % $i == 0) { + $sum += $i; + } + } + return $sum == $n; +} diff --git a/Task/Perfect-numbers/Perl/perfect-numbers-2.pl b/Task/Perfect-numbers/Perl/perfect-numbers-2.pl new file mode 100644 index 0000000000..8352abc345 --- /dev/null +++ b/Task/Perfect-numbers/Perl/perfect-numbers-2.pl @@ -0,0 +1,6 @@ +use List::Util qw(sum); + +sub perf { + my $n = shift; + $n == sum(0, grep {$n % $_ == 0} 1..$n-1); +} diff --git a/Task/Perfect-numbers/PicoLisp/perfect-numbers.l b/Task/Perfect-numbers/PicoLisp/perfect-numbers.l new file mode 100644 index 0000000000..614564bc2a --- /dev/null +++ b/Task/Perfect-numbers/PicoLisp/perfect-numbers.l @@ -0,0 +1,5 @@ +(de perfect (N) + (let C 0 + (for I (/ N 2) + (and (=0 (% N I)) (inc 'C I)) ) + (= C N) ) ) diff --git a/Task/Perfect-numbers/PowerShell/perfect-numbers.psh b/Task/Perfect-numbers/PowerShell/perfect-numbers.psh new file mode 100644 index 0000000000..d74405f21b --- /dev/null +++ b/Task/Perfect-numbers/PowerShell/perfect-numbers.psh @@ -0,0 +1,14 @@ +Function IsPerfect($n) +{ +$sum=0 + for($i=1;$i-lt$n;$i++) + { + if($n%$i -eq 0) + { + $sum += $i + } + } +return $sum -eq $n +} + +Returns "True" if the given number is perfect and "False" if it's not. diff --git a/Task/Perfect-numbers/Prolog/perfect-numbers-1.pro b/Task/Perfect-numbers/Prolog/perfect-numbers-1.pro new file mode 100644 index 0000000000..59ce8f28e5 --- /dev/null +++ b/Task/Perfect-numbers/Prolog/perfect-numbers-1.pro @@ -0,0 +1,14 @@ +tt_divisors(X, N, TT) :- + Q is X / N, + ( 0 is X mod N -> (Q = N -> TT1 is N + TT; + TT1 is N + Q + TT); + TT = TT1), + ( sqrt(X) > N + 1 -> N1 is N+1, tt_divisors(X, N1, TT1); + TT1 = X). + +perfect(X) :- + tt_divisors(X, 2, 1). + +perfect_numbers(N, L) :- + numlist(2, N, LN), + include(perfect, LN, L). diff --git a/Task/Perfect-numbers/Prolog/perfect-numbers-2.pro b/Task/Perfect-numbers/Prolog/perfect-numbers-2.pro new file mode 100644 index 0000000000..c1ef518895 --- /dev/null +++ b/Task/Perfect-numbers/Prolog/perfect-numbers-2.pro @@ -0,0 +1,37 @@ +:- use_module(library(lambda)). + +is_divisor(V, N) :- + 0 =:= V mod N. + +is_perfect(N) :- + N1 is floor(N/2), + numlist(1, N1, L), + f_compose_1(foldl((\X^Y^Z^(Z is X+Y)), 0), filter(is_divisor(N)), F), + call(F, L, N). + +f_perfect_numbers(N, L) :- + numlist(2, N, LN), + filter(is_perfect, LN, L). + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% functionnal predicates + +%% foldl(Pred, Init, List, R). +% +foldl(_Pred, Val, [], Val). +foldl(Pred, Val, [H | T], Res) :- + call(Pred, Val, H, Val1), + foldl(Pred, Val1, T, Res). + +%% filter(Pred, LstIn, LstOut) +% +filter(_Pre, [], []). + +filter(Pred, [H|T], L) :- + filter(Pred, T, L1), + ( call(Pred,H) -> L = [H|L1]; L = L1). + +%% f_compose_1(Pred1, Pred2, Pred1(Pred2)). +% +f_compose_1(F,G, \X^Z^(call(G,X,Y), call(F,Y,Z))). diff --git a/Task/Perfect-numbers/PureBasic/perfect-numbers.purebasic b/Task/Perfect-numbers/PureBasic/perfect-numbers.purebasic new file mode 100644 index 0000000000..8f75d5da37 --- /dev/null +++ b/Task/Perfect-numbers/PureBasic/perfect-numbers.purebasic @@ -0,0 +1,13 @@ +Procedure is_Perfect_number(n) + Protected summa, i=1, result=#False + Repeat + If Not n%i + summa+i + EndIf + i+1 + Until i>=n + If summa=n + result=#True + EndIf + ProcedureReturn result +EndProcedure diff --git a/Task/Perfect-numbers/Python/perfect-numbers-1.py b/Task/Perfect-numbers/Python/perfect-numbers-1.py new file mode 100644 index 0000000000..bc2a04d7e8 --- /dev/null +++ b/Task/Perfect-numbers/Python/perfect-numbers-1.py @@ -0,0 +1,6 @@ +def perf(n): + sum = 0 + for i in xrange(1, n): + if n % i == 0: + sum += i + return sum == n diff --git a/Task/Perfect-numbers/Python/perfect-numbers-2.py b/Task/Perfect-numbers/Python/perfect-numbers-2.py new file mode 100644 index 0000000000..7381179b17 --- /dev/null +++ b/Task/Perfect-numbers/Python/perfect-numbers-2.py @@ -0,0 +1 @@ +perf = lambda n: n == sum(i for i in xrange(1, n) if n % i == 0) diff --git a/Task/Perfect-numbers/R/perfect-numbers.r b/Task/Perfect-numbers/R/perfect-numbers.r new file mode 100644 index 0000000000..f4ad1103e9 --- /dev/null +++ b/Task/Perfect-numbers/R/perfect-numbers.r @@ -0,0 +1,11 @@ +is.perf <- function(n){ + if (n==0|n==1) return(FALSE) + s <- seq (1,n-1) + x <- n %% s + m <- data.frame(s,x) + out <- with(m, s[x==0]) + return(sum(out)==n) +} +# Usage - Warning High Memory Usage +is.perf(28) +sapply(c(6,28,496,8128,33550336),is.perf) diff --git a/Task/Perfect-numbers/REBOL/perfect-numbers.rebol b/Task/Perfect-numbers/REBOL/perfect-numbers.rebol new file mode 100644 index 0000000000..b2a4bd46ac --- /dev/null +++ b/Task/Perfect-numbers/REBOL/perfect-numbers.rebol @@ -0,0 +1,9 @@ +perfect?: func [n [integer!] /local sum] [ + sum: 0 + repeat i (n - 1) [ + if zero? remainder n i [ + sum: sum + i + ] + ] + sum = n +] diff --git a/Task/Perfect-numbers/REXX/perfect-numbers-1.rexx b/Task/Perfect-numbers/REXX/perfect-numbers-1.rexx new file mode 100644 index 0000000000..fe2df39dd8 --- /dev/null +++ b/Task/Perfect-numbers/REXX/perfect-numbers-1.rexx @@ -0,0 +1,22 @@ +/*REXX program tests if a number (or a range of numbers) is/are perfect.*/ +parse arg low high . /*obtain the specified number(s).*/ +if high=='' & low=='' then high=34000000 /*if no args, use a range.*/ +if low=='' then low=1 /*if no LOW, then assume unity.*/ +if high=='' then high=low /*if no HIGH, then assume LOW. */ +w=length(high) /*use W for formatting output. */ +numeric digits max(9,w+2) /*ensure enough digits to handle#*/ + + do i=low to high /*process the single # or range. */ + if isperfect(i) then say right(i,w) 'is a perfect number.' + end /*i*/ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────ISPERFECT subroutine────────────────*/ +isperfect: procedure; parse arg x /*get the number to be tested. */ +if x<6 then return 0 /*perfect numbers can't be < six.*/ +sum=1 /*the first factor of X. */ + do j=2 while j*j<=x /*starting at 2, find factors ≤√X*/ + if x//j\==0 then iterate /*J divides X evenly, so ... */ + sum=sum+j+x%j /*... add it and the other factor*/ + if sum>x then return 0 /*Sum too big? It ain't perfect.*/ + end /*j*/ /*(above) is marginally faster. */ +return sum==x /*if the sum matches X, perfect! */ diff --git a/Task/Perfect-numbers/REXX/perfect-numbers-2.rexx b/Task/Perfect-numbers/REXX/perfect-numbers-2.rexx new file mode 100644 index 0000000000..efd160faa1 --- /dev/null +++ b/Task/Perfect-numbers/REXX/perfect-numbers-2.rexx @@ -0,0 +1,33 @@ +/*REXX program tests if a number (or a range of numbers) is/are perfect.*/ +parse arg low high . /*obtain the specified number(s).*/ +if high=='' & low=='' then high=34000000 /*if no args, use a range.*/ +if low=='' then low=1 /*if no LOW, then assume unity.*/ +if high=='' then high=low /*if no HIGH, then assume LOW. */ +w=length(high) /*use W for formatting output. */ +numeric digits max(9,w+2) /*ensure enough digits to handle#*/ +@.=0; @.1=2 /*highest magic # and its index.*/ + do i=low to high /*process the single # or range. */ + if isperfect(i) then say right(i,w) 'is a perfect number.' + end /*i*/ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────ISPERFECT subroutine────────────────*/ +isperfect: procedure expose @.; parse arg x /*get the # to be tested.*/ +if x//2==1 then return 0 /*if it's an odd number, it ain't*/ + /*Lucas-Lehmer know that perfect */ + /* numbers can be expressed as: */ + /* [2**n - 1] * [2** (n-1) ] */ + +if @.0x then return 0 /*Sum too big? It ain't perfect.*/ + end /*j*/ /*(above) is marginally faster. */ +return sum==x /*if the sum matches X, perfect! */ diff --git a/Task/Perfect-numbers/Ruby/perfect-numbers-1.rb b/Task/Perfect-numbers/Ruby/perfect-numbers-1.rb new file mode 100644 index 0000000000..9b1621e2dd --- /dev/null +++ b/Task/Perfect-numbers/Ruby/perfect-numbers-1.rb @@ -0,0 +1,9 @@ +def perf(n) + sum = 0 + for i in 1...n + if n % i == 0 + sum += i + end + end + return sum == n +end diff --git a/Task/Perfect-numbers/Ruby/perfect-numbers-2.rb b/Task/Perfect-numbers/Ruby/perfect-numbers-2.rb new file mode 100644 index 0000000000..c82de6f678 --- /dev/null +++ b/Task/Perfect-numbers/Ruby/perfect-numbers-2.rb @@ -0,0 +1,3 @@ +def perf(n) + n == (1...n).select {|i| n % i == 0}.inject(:+) +end diff --git a/Task/Perfect-numbers/Run-BASIC/perfect-numbers.run b/Task/Perfect-numbers/Run-BASIC/perfect-numbers.run new file mode 100644 index 0000000000..d20a91829b --- /dev/null +++ b/Task/Perfect-numbers/Run-BASIC/perfect-numbers.run @@ -0,0 +1,10 @@ +for i = 1 to 10000 + if perf(i) then print i;" "; +next i + +FUNCTION perf(n) +for i = 1 TO n - 1 + IF n MOD i = 0 THEN sum = sum + i +next i +IF sum = n THEN perf = 1 +END FUNCTION diff --git a/Task/Perfect-numbers/Scala/perfect-numbers.scala b/Task/Perfect-numbers/Scala/perfect-numbers.scala new file mode 100644 index 0000000000..f94cb8cae1 --- /dev/null +++ b/Task/Perfect-numbers/Scala/perfect-numbers.scala @@ -0,0 +1 @@ +def perfectInt(input: Int) = ((2 to sqrt(input).toInt).collect {case x if input % x == 0 => x + input / x}).sum == input - 1 diff --git a/Task/Perfect-numbers/Scheme/perfect-numbers.ss b/Task/Perfect-numbers/Scheme/perfect-numbers.ss new file mode 100644 index 0000000000..657aaeb57e --- /dev/null +++ b/Task/Perfect-numbers/Scheme/perfect-numbers.ss @@ -0,0 +1,9 @@ +(define (perf n) + (let loop ((i 1) + (sum 0)) + (cond ((= i n) + (= sum n)) + ((= 0 (modulo n i)) + (loop (+ i 1) (+ sum i))) + (else + (loop (+ i 1) sum))))) diff --git a/Task/Perfect-numbers/Seed7/perfect-numbers.seed7 b/Task/Perfect-numbers/Seed7/perfect-numbers.seed7 new file mode 100644 index 0000000000..1f4203507f --- /dev/null +++ b/Task/Perfect-numbers/Seed7/perfect-numbers.seed7 @@ -0,0 +1,32 @@ +$ include "seed7_05.s7i"; + +const func boolean: isPerfect (in integer: n) is func + result + var boolean: isPerfect is FALSE; + local + var integer: i is 0; + var integer: sum is 1; + var integer: q is 0; + begin + for i range 2 to sqrt(n) do + if n rem i = 0 then + sum +:= i; + q := n div i; + if q > i then + sum +:= q; + end if; + end if; + end for; + isPerfect := sum = n; + end func; + +const proc: main is func + local + var integer: n is 0; + begin + for n range 2 to 33550336 do + if isPerfect(n) then + writeln(n); + end if; + end for; + end func; diff --git a/Task/Perfect-numbers/Slate/perfect-numbers.slate b/Task/Perfect-numbers/Slate/perfect-numbers.slate new file mode 100644 index 0000000000..157b932303 --- /dev/null +++ b/Task/Perfect-numbers/Slate/perfect-numbers.slate @@ -0,0 +1,5 @@ +n@(Integer traits) isPerfect +[ + (((2 to: n // 2 + 1) select: [| :m | (n rem: m) isZero]) + inject: 1 into: #+ `er) = n +]. diff --git a/Task/Perfect-numbers/Smalltalk/perfect-numbers-1.st b/Task/Perfect-numbers/Smalltalk/perfect-numbers-1.st new file mode 100644 index 0000000000..25b01733e7 --- /dev/null +++ b/Task/Perfect-numbers/Smalltalk/perfect-numbers-1.st @@ -0,0 +1,21 @@ +Integer extend [ + + "Translation of the C version; this is faster..." + isPerfectC [ |tot| tot := 1. + (2 to: (self sqrt) + 1) do: [ :i | + (self rem: i) = 0 + ifTrue: [ |q| + tot := tot + i. + q := self // i. + q > i ifTrue: [ tot := tot + q ] + ] + ]. + ^ tot = self + ] + + "... but this seems more idiomatic" + isPerfect [ + ^ ( ( ( 2 to: self // 2 + 1) select: [ :a | (self rem: a) = 0 ] ) + inject: 1 into: [ :a :b | a + b ] ) = self + ] +]. diff --git a/Task/Perfect-numbers/Smalltalk/perfect-numbers-2.st b/Task/Perfect-numbers/Smalltalk/perfect-numbers-2.st new file mode 100644 index 0000000000..45948767f2 --- /dev/null +++ b/Task/Perfect-numbers/Smalltalk/perfect-numbers-2.st @@ -0,0 +1 @@ +1 to: 9000 do: [ :p | (p isPerfect) ifTrue: [ p printNl ] ] diff --git a/Task/Perfect-numbers/Tcl/perfect-numbers.tcl b/Task/Perfect-numbers/Tcl/perfect-numbers.tcl new file mode 100644 index 0000000000..e7b8e1cb83 --- /dev/null +++ b/Task/Perfect-numbers/Tcl/perfect-numbers.tcl @@ -0,0 +1,7 @@ +proc perfect n { + set sum 0 + for {set i 1} {$i <= $n} {incr i} { + if {$n % $i == 0} {incr sum $i} + } + expr {$sum == 2*$n} +} diff --git a/Task/Perfect-numbers/Ursala/perfect-numbers-1.ursala b/Task/Perfect-numbers/Ursala/perfect-numbers-1.ursala new file mode 100644 index 0000000000..d9cee8bb53 --- /dev/null +++ b/Task/Perfect-numbers/Ursala/perfect-numbers-1.ursala @@ -0,0 +1,4 @@ +#import std +#import nat + +is_perfect = ~&itB&& ^(~&,~&t+ iota); ^E/~&l sum:-0+ ~| not remainder diff --git a/Task/Perfect-numbers/Ursala/perfect-numbers-2.ursala b/Task/Perfect-numbers/Ursala/perfect-numbers-2.ursala new file mode 100644 index 0000000000..3d31783f86 --- /dev/null +++ b/Task/Perfect-numbers/Ursala/perfect-numbers-2.ursala @@ -0,0 +1,3 @@ +#cast %nL + +examples = is_perfect*~ iota 500 diff --git a/Task/Permutation-test/0DESCRIPTION b/Task/Permutation-test/0DESCRIPTION new file mode 100644 index 0000000000..0f048f9d01 --- /dev/null +++ b/Task/Permutation-test/0DESCRIPTION @@ -0,0 +1,49 @@ +A new medical treatment was tested on a population of n + m +volunteers, with each volunteer randomly assigned either to a group of +n treatment subjects, or to a group of m control subjects. Members of +the treatment group were given the treatment, and members of the +control group were given a placebo. The effect of the treatment or +placebo on each volunteer was measured and reported in this table. + +{| style="text-align: left; width: 50%;" border="4" cellpadding="2" cellspacing="2" +|+ Table of experimental results +|- style="background-color: rgb(255, 204, 255);" +! Treatment group !! Control group +|- +| 85 || 68 +|- +| 88 || 41 +|- +| 75 || 10 +|- +| 66 || 49 +|- +| 25 || 16 +|- +| 29 || 65 +|- +| 83 || 32 +|- +| 39 || 92 +|- +| 97 || 28 +|- +| || 98 +|} +Write a program that performs a +[[wp:Permutation_test#Permutation_tests|permutation test]] to judge +whether the treatment had a significantly stronger effect than the +placebo. + +* Do this by considering every possible alternative assignment from the same pool of volunteers to a treatment group of size n and a control group of size m (i.e., the same group sizes used in the actual experiment but with the group members chosen differently), while assuming that each volunteer's effect remains constant regardless. +* Note that the number of alternatives will be the [[wp:Binomial_coefficient|binomial coefficient]] \tbinom{n+m}{n}. +* Compute the mean effect for each group and the difference in means between the groups in every case by subtracting the mean of the control group from the mean of the treatment group. +* Report the percentage of alternative groupings for which the difference in means is less or equal to the actual experimentally observed difference in means, and the percentage for which it is greater. +* Note that they should sum to 100%. + +Extremely dissimilar values are evidence of an effect not entirely due +to chance, but your program need not draw any conclusions. + +You may assume the experimental data are known at compile time if +that's easier than loading them at run time. Test your solution on the +data given above. diff --git a/Task/Permutation-test/1META.yaml b/Task/Permutation-test/1META.yaml new file mode 100644 index 0000000000..29aeacfd2a --- /dev/null +++ b/Task/Permutation-test/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Probability and statistics diff --git a/Task/Permutation-test/Ada/permutation-test-1.ada b/Task/Permutation-test/Ada/permutation-test-1.ada new file mode 100644 index 0000000000..2d72522d29 --- /dev/null +++ b/Task/Permutation-test/Ada/permutation-test-1.ada @@ -0,0 +1,62 @@ +with Ada.Text_IO; with Iterate_Subsets; + +procedure Permutation_Test is + + type Group_Type is array(Positive range <>) of Positive; + + Treat_Group: constant Group_Type := (85, 88, 75, 66, 25, 29, 83, 39, 97); + Ctrl_Group: constant Group_Type := (68, 41, 10, 49, 16, 65, 32, 92, 28, 98); + + package Iter is new Iterate_Subsets(Treat_Group'Length, Ctrl_Group'Length); + + Full_Group: constant Group_Type(1 .. Iter.All_Elements) + := Treat_Group & Ctrl_Group; + + function Mean(S: Iter.Subset) return Float is + Sum: Natural := 0; + begin + for I in S'Range loop + Sum := Sum + Full_Group(S(I)); + end loop; + return Float(Sum)/Float(S'Length); + end Mean; + + package FIO is new Ada.Text_IO.Float_IO(Float); + + T_Avg: Float := Mean(Iter.First); + S_Avg: Float; + S: Iter.Subset := Iter.First; + Equal: Positive := 1; -- Mean(Iter'First) = Mean(Iter'First) + Higher: Natural := 0; + Lower: Natural := 0; + +begin -- Permutation_Test; + -- first, count the subsets with a higher, an equal or a lower mean + loop + Iter.Next(S); + S_Avg := Mean(S); + if S_Avg = T_Avg then + Equal := Equal + 1; + elsif S_Avg >= T_Avg then + Higher := Higher + 1; + else + Lower := Lower + 1; + end if; + exit when Iter.Last(S); + end loop; + + -- second, output the results + declare + use Ada.Text_IO; + Sum: Float := Float(Higher + Equal + Lower); + begin + Put("Less or Equal: "); + FIO.Put(100.0*Float(Lower+Equal) / Sum, Fore=>3, Aft=>1, Exp=>0); + Put(Integer'Image(Lower+Equal)); + New_Line; + Put("More: "); + FIO.Put(100.0*Float(Higher) / Sum, Fore=>3, Aft=>1, Exp=>0); + Put(Integer'Image(Higher)); + New_Line; + end; +end Permutation_Test; diff --git a/Task/Permutation-test/Ada/permutation-test-2.ada b/Task/Permutation-test/Ada/permutation-test-2.ada new file mode 100644 index 0000000000..e90f278483 --- /dev/null +++ b/Task/Permutation-test/Ada/permutation-test-2.ada @@ -0,0 +1,16 @@ +generic + Subset_Size, More_Elements: Positive; +package Iterate_Subsets is + + All_Elements: Positive := Subset_Size + More_Elements; + subtype Index is Integer range 1 .. All_Elements; + type Subset is array (1..Subset_Size) of Index; + + -- iterate over all subsets of size Subset_Size + -- from the set {1, 2, ..., All_Element} + + function First return Subset; + procedure Next(S: in out Subset); + function Last(S: Subset) return Boolean; + +end Iterate_Subsets; diff --git a/Task/Permutation-test/Ada/permutation-test-3.ada b/Task/Permutation-test/Ada/permutation-test-3.ada new file mode 100644 index 0000000000..3c334a1ca8 --- /dev/null +++ b/Task/Permutation-test/Ada/permutation-test-3.ada @@ -0,0 +1,34 @@ +package body Iterate_Subsets is + + function First return Subset is + S: Subset; + begin + for I in S'Range loop + S(I) := I; + end loop; + return S; + end First; + + procedure Next(S: in out Subset) is + I: Natural := S'Last; + begin + if S(I) < Index'Last then + S(I) := S(I) + 1; + else + while S(I-1)+1 = S(I) loop + I := I - 1; + end loop; + S(I-1) := S(I-1) + 1; + for J in I .. S'Last loop + S(J) := S(J-1) + 1; + end loop; + end if; + return; + end Next; + + function Last(S: Subset) return Boolean is + begin + return S(S'First) = Index'Last-S'Length+1; + end Last; + +end Iterate_Subsets; diff --git a/Task/Permutation-test/BBC-BASIC/permutation-test.bbc b/Task/Permutation-test/BBC-BASIC/permutation-test.bbc new file mode 100644 index 0000000000..8e6246fbdd --- /dev/null +++ b/Task/Permutation-test/BBC-BASIC/permutation-test.bbc @@ -0,0 +1,38 @@ + ntreated% = 9 + nplacebo% = 10 + DIM results%(ntreated% + nplacebo% - 1) + results%() = 85, 88, 75, 66, 25, 29, 83, 39, 97, \ REM treated group + \ 68, 41, 10, 49, 16, 65, 32, 92, 28, 98 : REM placebo group + + greater% = 0 + FOR comb% = 0 TO 2^(ntreated%+nplacebo%)-1 + IF FNnbits(comb%) = ntreated% THEN + tsum% = 0 : psum% = 0 + FOR b% = 0 TO ntreated%+nplacebo%-1 + IF comb% AND 2^b% THEN + tsum% += results%(b%) + ELSE + psum% += results%(b%) + ENDIF + NEXT + meandiff = tsum%/ntreated% - psum%/nplacebo% + IF comb% = 2^ntreated% - 1 THEN + actual = meandiff + ELSE + greater% -= meandiff > actual + groups% += 1 + ENDIF + ENDIF + NEXT + + percent = 100 * greater%/groups% + PRINT "Percentage groupings <= actual experiment: "; 100 - percent + PRINT "Percentage groupings > actual experiment: "; percent + END + + DEF FNnbits(N%) + N% -= N% >>> 1 AND &55555555 + N% = (N% AND &33333333) + (N% >>> 2 AND &33333333) + N% = (N% + (N% >>> 4)) AND &0F0F0F0F + N% += N% >>> 8 : N% += N% >>> 16 + = N% AND &7F diff --git a/Task/Permutation-test/C/permutation-test-1.c b/Task/Permutation-test/C/permutation-test-1.c new file mode 100644 index 0000000000..10452925eb --- /dev/null +++ b/Task/Permutation-test/C/permutation-test-1.c @@ -0,0 +1,29 @@ +#include + +int data[] = { 85, 88, 75, 66, 25, 29, 83, 39, 97, + 68, 41, 10, 49, 16, 65, 32, 92, 28, 98 }; + +int pick(int at, int remain, int accu, int treat) +{ + if (!remain) return (accu > treat) ? 1 : 0; + + return pick(at - 1, remain - 1, accu + data[at - 1], treat) + + ( at > remain ? pick(at - 1, remain, accu, treat) : 0 ); +} + +int main() +{ + int treat = 0, i; + int le, gt; + double total = 1; + for (i = 0; i < 9; i++) treat += data[i]; + for (i = 19; i > 10; i--) total *= i; + for (i = 9; i > 0; i--) total /= i; + + gt = pick(19, 9, 0, treat); + le = total - gt; + + printf("<= : %f%% %d\n > : %f%% %d\n", + 100 * le / total, le, 100 * gt / total, gt); + return 0; +} diff --git a/Task/Permutation-test/C/permutation-test-2.c b/Task/Permutation-test/C/permutation-test-2.c new file mode 100644 index 0000000000..75ef1d984f --- /dev/null +++ b/Task/Permutation-test/C/permutation-test-2.c @@ -0,0 +1,2 @@ +<= : 87.197168% 80551 + > : 12.802832% 11827 diff --git a/Task/Permutation-test/Common-Lisp/permutation-test-1.lisp b/Task/Permutation-test/Common-Lisp/permutation-test-1.lisp new file mode 100644 index 0000000000..a470f6f348 --- /dev/null +++ b/Task/Permutation-test/Common-Lisp/permutation-test-1.lisp @@ -0,0 +1,24 @@ +(defun perm-test (s1 s2) + (let ((more 0) (leq 0) + (all-data (append s1 s2)) + (thresh (apply #'+ s1))) + (labels + ((recur (data sum need avail) + (cond ((zerop need) (if (>= sum thresh) + (incf more) + (incf leq))) + ((>= avail need) + (recur (cdr data) sum need (1- avail)) + (recur (cdr data) (+ sum (car data)) (1- need) (1- avail)))))) + + (recur all-data 0 (length s1) (length all-data)) + (cons more leq)))) + +(let* ((a (perm-test '(68 41 10 49 16 65 32 92 28 98) + '(85 88 75 66 25 29 83 39 97))) + (x (car a)) + (y (cdr a)) + (s (+ x y))) + (format t "<=: ~a ~6f%~% >: ~a ~6f%~%" + x (* 100e0 (/ x s)) + y (* 100e0 (/ y s)))) diff --git a/Task/Permutation-test/Common-Lisp/permutation-test-2.lisp b/Task/Permutation-test/Common-Lisp/permutation-test-2.lisp new file mode 100644 index 0000000000..2dd83b8e1c --- /dev/null +++ b/Task/Permutation-test/Common-Lisp/permutation-test-2.lisp @@ -0,0 +1,2 @@ +<=: 80551 87.197% + >: 11827 12.803% diff --git a/Task/Permutation-test/D/permutation-test.d b/Task/Permutation-test/D/permutation-test.d new file mode 100644 index 0000000000..a692a88297 --- /dev/null +++ b/Task/Permutation-test/D/permutation-test.d @@ -0,0 +1,32 @@ +import std.stdio, std.algorithm, std.array; +// http://rosettacode.org/wiki/Combinations#D +import combinations3: combinations; + +auto permTest(T)(T[] a, T[] b, in int precisionAdjust=100) { + alias reduce!q{a + b} sum; // statistic can be degenerate to sum + + auto ab = a ~ b; + ab[] *= precisionAdjust; // scale up magnitude + auto tObs = sum(ab[0 .. a.length]); + auto comb = combinations!false(ab, a.length); + + // combinations() isn't a Range yet + //immutable int under = comb.count!(c => stat(c) <= tObs)(); + int under = 0; + foreach (c; comb) + if (sum(c) <= tObs) + under++; + + return 1.0L * under / comb.length; +} + +void main() { + auto treatment = [0.85, 0.88, 0.75, 0.66, 0.25, 0.29, + 0.83, 0.39, 0.97]; + auto control = [0.68, 0.41, 0.10, 0.49, 0.16, 0.65, + 0.32, 0.92, 0.28, 0.98]; + + auto r = permTest(treatment, control); + writefln("under =%6.2f%%\nover =%6.2f%%", + r * 100.0, (1 - r) * 100.0); +} diff --git a/Task/Permutation-test/GAP/permutation-test.gap b/Task/Permutation-test/GAP/permutation-test.gap new file mode 100644 index 0000000000..e750e7b37c --- /dev/null +++ b/Task/Permutation-test/GAP/permutation-test.gap @@ -0,0 +1,51 @@ +a := [85, 88, 75, 66, 25, 29, 83, 39, 97]; +b := [68, 41, 10, 49, 16, 65, 32, 92, 28, 98]; + +# Compute a decimal approximation of a rational +Approx := function(x, d) + local neg, a, b, n, m, s; + if x < 0 then + x := -x; + neg := true; + else + neg := false; + fi; + a := NumeratorRat(x); + b := DenominatorRat(x); + n := QuoInt(a, b); + a := RemInt(a, b); + m := 10^d; + s := ""; + if neg then + Append(s, "-"); + fi; + Append(s, String(n)); + n := Size(s) + 1; + Append(s, String(m + QuoInt(a*m, b))); + s[n] := '.'; + return s; +end; + +PermTest := function(a, b) + local c, d, p, q, u, v, m, n, k, diff, all; + p := Size(a); + q := Size(b); + v := Concatenation(a, b); + n := p + q; + m := Binomial(n, p); + diff := Sum(a)/p - Sum(b)/q; + all := [1 .. n]; + k := 0; + for u in Combinations(all, p) do + c := List(u, i -> v[i]); + d := List(Difference(all, u), i -> v[i]); + if Sum(c)/p - Sum(d)/q > diff then + k := k + 1; + fi; + od; + return [Approx((1 - k/m)*100, 3), Approx(k/m*100, 3)]; +end; + +# in order, % less or greater than original diff +PermTest(a, b); +[ "87.197", "12.802" ] diff --git a/Task/Permutation-test/Go/permutation-test.go b/Task/Permutation-test/Go/permutation-test.go new file mode 100644 index 0000000000..cfbb939932 --- /dev/null +++ b/Task/Permutation-test/Go/permutation-test.go @@ -0,0 +1,72 @@ +package main + +import "fmt" + +var tr = []int{85, 88, 75, 66, 25, 29, 83, 39, 97} +var ct = []int{68, 41, 10, 49, 16, 65, 32, 92, 28, 98} + +func main() { + // collect all results in a single list + all := make([]int, len(tr)+len(ct)) + copy(all, tr) + copy(all[len(tr):], ct) + + // compute sum of all data, useful as intermediate result + var sumAll int + for _, r := range all { + sumAll += r + } + + // closure for computing scaled difference. + // compute results scaled by len(tr)*len(ct). + // this allows all math to be done in integers. + sd := func(trc []int) int { + var sumTr int + for _, x := range trc { + sumTr += all[x] + } + return sumTr*len(ct) - (sumAll-sumTr)*len(tr) + } + + // compute observed difference, as an intermediate result + a := make([]int, len(tr)) + for i, _ := range a { + a[i] = i + } + sdObs := sd(a) + + // iterate over all combinations. for each, compute (scaled) + // difference and tally whether leq or gt observed difference. + var nLe, nGt int + comb(len(all), len(tr), func(c []int) { + if sd(c) > sdObs { + nGt++ + } else { + nLe++ + } + }) + + // print results as percentage + pc := 100 / float64(nLe+nGt) + fmt.Printf("differences <= observed: %f%%\n", float64(nLe)*pc) + fmt.Printf("differences > observed: %f%%\n", float64(nGt)*pc) +} + +// combination generator, copied from combination task +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/Permutation-test/Haskell/permutation-test-1.hs b/Task/Permutation-test/Haskell/permutation-test-1.hs new file mode 100644 index 0000000000..837771afd6 --- /dev/null +++ b/Task/Permutation-test/Haskell/permutation-test-1.hs @@ -0,0 +1,21 @@ +binomial n m = (f !! n) `div` (f !! m) `div` (f !! (n - m)) + where f = scanl (*) 1 [1..] + +permtest treat ctrl = (fromIntegral less) / (fromIntegral total) * 100 + where + total = binomial (length avail) (length treat) + less = combos (sum treat) (length treat) avail + avail = ctrl ++ treat + combos total n a@(x:xs) + | total < 0 = binomial (length a) n + | n == 0 = 0 + | n > length a = 0 + | n == length a = fromEnum (total < sum a) + | otherwise = combos (total - x) (n - 1) xs + + combos total n xs + +main = let r = permtest + [85, 88, 75, 66, 25, 29, 83, 39, 97] + [68, 41, 10, 49, 16, 65, 32, 92, 28, 98] + in do putStr "> : "; print r + putStr "<=: "; print $ 100 - r diff --git a/Task/Permutation-test/Haskell/permutation-test-2.hs b/Task/Permutation-test/Haskell/permutation-test-2.hs new file mode 100644 index 0000000000..3e347ec1b2 --- /dev/null +++ b/Task/Permutation-test/Haskell/permutation-test-2.hs @@ -0,0 +1,19 @@ +binomial n m = (f !! n) `div` (f !! m) `div` (f !! (n - m)) + where f = scanl (*) 1 [1..] + +perms treat ctrl = (less,total) where + total = binomial (length ctrl + length treat) (length treat) + less = length $ filter (<= sum treat) + $ sums (treat ++ ctrl) (length treat) + sums x n + | l < n || n < 0 = [] + | n == 0 = [0] + | l == n = [sum x] + | otherwise = [a + b | i <- [0..n], a <- sums left i, b <- sums right (n - i)] + where (l, l1) = (length x, l `div` 2) + (left, right) = splitAt l1 x + +main = print $ (lt, 100 - lt) where + (a, b) = perms [85, 88, 75, 66, 25, 29, 83, 39, 97] + [68, 41, 10, 49, 16, 65, 32, 92, 28, 98] + lt = (fromIntegral a) / (fromIntegral b) * 100 diff --git a/Task/Permutation-test/Haskell/permutation-test-3.hs b/Task/Permutation-test/Haskell/permutation-test-3.hs new file mode 100644 index 0000000000..191becf878 --- /dev/null +++ b/Task/Permutation-test/Haskell/permutation-test-3.hs @@ -0,0 +1,26 @@ +combs maxsum len x = foldl f [(0,0,1)] x where + f a n = merge a (map (addNum n) $ filter (\(l,_,_) -> l < len) a) + addNum n (a,s,c) + -- anything larger than maxsum is as good as infinity + | s + n > maxsum = (a+1, maxsum + 1, c) + | otherwise = (a+1, s+n, c) + + merge a [] = a + merge [] a = a + merge a@((a1,a2,a3):as) b@((b1,b2,b3):bs) + | a1 == b1 && a2 == b2 = (a1,a2,a3+b3):merge as bs + | a1 < b1 || (a1 == b1 && a2 < b2) = (a1,a2,a3):merge as b + | otherwise = (b1,b2,b3):merge a bs + +permtest a b = (lt, ge) where + lt = sum $ map (\(a,b,c) -> if a == la && b < sa then c else 0) + $ combs sa la (a++b) + ge = (binomial (la + lb) la) - lt + (sa, la, lb) = (sum a, length a, length b) + +binomial n m = (f !! n) `div` (f !! m) `div` (f !! (n - m)) + where f = scanl (*) 1 [1..] + +-- how many combinations are less than current sum +main = print$ permtest [85, 88, 75, 66, 25, 29, 83, 39, 97] + [68, 41, 10, 49, 16, 65, 32, 92, 28, 98] diff --git a/Task/Permutation-test/J/permutation-test-1.j b/Task/Permutation-test/J/permutation-test-1.j new file mode 100644 index 0000000000..84aa2f01d2 --- /dev/null +++ b/Task/Permutation-test/J/permutation-test-1.j @@ -0,0 +1,8 @@ +require'stats' +trmt=: 0.85 0.88 0.75 0.66 0.25 0.29 0.83 0.39 0.97 +ctrl=: 0.68 0.41 0.1 0.49 0.16 0.65 0.32 0.92 0.28 0.98 +difm=: -&mean +result=: trmt difm ctrl +all=: trmt(#@[ ({. difm }.) |:@([ (comb ~.@,"1 i.@])&# ,) { ,) ctrl +smoutput 'under: ','%',~":100*mean all <: result +smoutput 'over: ','%',~":100*mean all > result diff --git a/Task/Permutation-test/J/permutation-test-2.j b/Task/Permutation-test/J/permutation-test-2.j new file mode 100644 index 0000000000..06ceba3698 --- /dev/null +++ b/Task/Permutation-test/J/permutation-test-2.j @@ -0,0 +1,2 @@ +under: 87.1972% +over: 12.8028% diff --git a/Task/Permutation-test/Mathematica/permutation-test.math b/Task/Permutation-test/Mathematica/permutation-test.math new file mode 100644 index 0000000000..0b2858961e --- /dev/null +++ b/Task/Permutation-test/Mathematica/permutation-test.math @@ -0,0 +1,6 @@ +"<=: " <> ToString[#1] <> " " <> ToString[100. #1/#2] <> "%\n >: " <> + ToString[#2 - #1] <> " " <> ToString[100. (1 - #1/#2)] <> "%" &[ + Count[Total /@ Subsets[Join[#1, #2], {Length@#1}], + n_ /; n <= Total@#1], + Binomial[Length@#1 + Length@#2, Length@#1]] &[{85, 88, 75, 66, 25, + 29, 83, 39, 97}, {68, 41, 10, 49, 16, 65, 32, 92, 28, 98}] diff --git a/Task/Permutation-test/PicoLisp/permutation-test.l b/Task/Permutation-test/PicoLisp/permutation-test.l new file mode 100644 index 0000000000..77e83a81c6 --- /dev/null +++ b/Task/Permutation-test/PicoLisp/permutation-test.l @@ -0,0 +1,32 @@ +(load "@lib/simul.l") # For 'subsets' + +(scl 2) + +(de _stat (A) + (let (LenA (length A) SumA (apply + A)) + (- + (*/ SumA LenA) + (*/ (- SumAB SumA) (- LenAB LenA)) ) ) ) + +(de permutationTest (A B) + (let + (AB (append A B) + SumAB (apply + AB) + LenAB (length AB) + Tobs (_stat A) + Count 0 ) + (*/ + (sum + '((Perm) + (inc 'Count) + (and (>= Tobs (_stat Perm)) 1) ) + (subsets (length A) AB) ) + 100.0 + Count ) ) ) + +(setq + *TreatmentGroup (0.85 0.88 0.75 0.66 0.25 0.29 0.83 0.39 0.97) + *ControlGroup (0.68 0.41 0.10 0.49 0.16 0.65 0.32 0.92 0.28 0.98) ) + +(let N (permutationTest *TreatmentGroup *ControlGroup) + (prinl "under = " (round N) "%, over = " (round (- 100.0 N)) "%") ) diff --git a/Task/Permutation-test/PureBasic/permutation-test.purebasic b/Task/Permutation-test/PureBasic/permutation-test.purebasic new file mode 100644 index 0000000000..e007eec191 --- /dev/null +++ b/Task/Permutation-test/PureBasic/permutation-test.purebasic @@ -0,0 +1,90 @@ +Define.f meanTreated,meanControl,diffInMeans +Define.f actualmeanTreated,actualmeanControl,actualdiffInMeans + +Dim poolA(19) + +poolA(1) =85 ; first 9 the treated +poolA(2) =88 +poolA(3) =75 +poolA(4) =66 +poolA(5) =25 +poolA(6) =29 +poolA(7) =83 +poolA(8) =39 +poolA(9) =97 + +poolA(10) =68 ; last 10 the control +poolA(11) =41 +poolA(12) =10 +poolA(13) =49 +poolA(14) =16 +poolA(15) =65 +poolA(16) =32 +poolA(17) =92 +poolA(18) =28 +poolA(19) =98 + +Procedure.i IsValidBitString(x,pool,treated) +Protected c,i +For i=1 to pool +mask=1<<(i-1) +If mask&x:c+1:EndIf +Next +If c=treated :ProcedureReturn x +Else :ProcedureReturn 0 +EndIf +EndProcedure + +treated=9 +control=10 + +pool =treated+control + +; actual Experimentally observed difference in means + +For i=1 to Treated +sumTreated+poolA(i) +Next +For i=Treated+1 to Treated+Control +sumControl+poolA(i) +Next + +actualmeanTreated=sumTreated /Treated +actualmeanControl=sumControl /Control +actualdiffInMeans=actualmeanTreated-actualmeanControl + +; exhaust the possibilites +For x=1 to 1< permutation.test(c(85, 88, 75, 66, 25, 29, 83, 39, 97), ++ c(68, 41, 10, 49, 16, 65, 32, 92, 28, 98)) + under over +0.8719717 0.1280283 diff --git a/Task/Permutation-test/REXX/permutation-test.rexx b/Task/Permutation-test/REXX/permutation-test.rexx new file mode 100644 index 0000000000..0be5c7145f --- /dev/null +++ b/Task/Permutation-test/REXX/permutation-test.rexx @@ -0,0 +1,30 @@ +/*REXX program does a permutation test on N + M subjects (volunteers):*/ +/* ↑ ↑ */ +/* │ │ */ +/* │ └─────control population*/ +/* └────────treatment population*/ +n=9 +data=85 88 75 66 25 29 83 39 97 68 41 10 49 16 65 32 92 28 98 +w=words(data); m=w-n +say 'volunteer population given treatment:' right(n,length(w)) +say ' control population given a placebo:' right(m,length(w)) +say +say 'treatment population efficacy % (percentages):' subword(data,1,n) +say ' control population placebo % (percentages):' subword(data,n+1) +say + do v= 0 for w ; #.v=word(data,v+1) ; end +treat=0; do i= 0 to n-1 ; treat=treat+#.i ; end +total=1; do j=19 to m+1 by -1 ; total=total*j ; end + do k= 9 to 1 by -1 ; total=total/k ; end +gt=pick(n+m, n, 0) +le=total-gt +say "<= " format(100*le/total,,3)'%' le /*show 3 decimal places.*/ +say " > " format(100*gt/total,,3)'%' gt +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────PICK subroutine─────────────────────*/ +pick: procedure expose #. treat; parse arg it,rest,eff +if rest==0 then return eff>treat +if it>rest then q=pick(it-1, rest, eff) + else q=0 +itP=it-1 +return pick(itP, rest-1, eff+#.itP) + q diff --git a/Task/Permutation-test/Tcl/permutation-test-1.tcl b/Task/Permutation-test/Tcl/permutation-test-1.tcl new file mode 100644 index 0000000000..69e20e0a39 --- /dev/null +++ b/Task/Permutation-test/Tcl/permutation-test-1.tcl @@ -0,0 +1,47 @@ +package require Tcl 8.5 + +# Difference of means; note that the first list must be the concatenation of +# the two lists (because this is cheaper to work with). +proc statistic {AB A} { + set sumAB [tcl::mathop::+ {*}$AB] + set sumA [tcl::mathop::+ {*}$A] + expr { + $sumA / double([llength $A]) - + ($sumAB - $sumA) / double([llength $AB] - [llength $A]) + } +} + +# Selects all k-sized combinations from a list. +proc selectCombinationsFrom {k l} { + if {$k == 0} {return {}} elseif {$k == [llength $l]} {return [list $l]} + set all {} + set n [expr {[llength $l] - [incr k -1]}] + for {set i 0} {$i < $n} {} { + set first [lindex $l $i] + incr i + if {$k == 0} { + lappend all $first + } else { + foreach s [selectCombinationsFrom $k [lrange $l $i end]] { + lappend all [list $first {*}$s] + } + } + } + return $all +} + +# Compute the permutation test value and its complement. +proc permutationTest {A B} { + set whole [concat $A $B] + set Tobs [statistic $whole $A] + set undercount 0 + set overcount 0 + set count 0 + foreach perm [selectCombinationsFrom [llength $A] $whole] { + set t [statistic $whole $perm] + incr count + if {$t <= $Tobs} {incr undercount} else {incr overcount} + } + set count [tcl::mathfunc::double $count] + list [expr {$overcount / $count}] [expr {$undercount / $count}] +} diff --git a/Task/Permutation-test/Tcl/permutation-test-2.tcl b/Task/Permutation-test/Tcl/permutation-test-2.tcl new file mode 100644 index 0000000000..9d3f7798e5 --- /dev/null +++ b/Task/Permutation-test/Tcl/permutation-test-2.tcl @@ -0,0 +1,4 @@ +set treatmentGroup {0.85 0.88 0.75 0.66 0.25 0.29 0.83 0.39 0.97} +set controlGroup {0.68 0.41 0.10 0.49 0.16 0.65 0.32 0.92 0.28 0.98} +lassign [permutationTest $treatmentGroup $controlGroup] over under +puts [format "under=%.2f%%, over=%.2f%%" [expr {$under*100}] [expr {$over*100}]] diff --git a/Task/Permutation-test/Ursala/permutation-test.ursala b/Task/Permutation-test/Ursala/permutation-test.ursala new file mode 100644 index 0000000000..180943829c --- /dev/null +++ b/Task/Permutation-test/Ursala/permutation-test.ursala @@ -0,0 +1,16 @@ +#import std +#import nat +#import flo + +treatment_group = <85,88,75,66,25,29,83,39,97> +control_group = <68,41,10,49,16,65,32,92,28,98> + +f = # returns the fractions of alternative mean differences above and below the actual + +float~*; -+ + vid^~G(plus,~&)+ (not fleq@rlX)*|@htX; ~~ float+ length, + minus*+ mean^~*C/~& ^DrlrjXS(~&l,choices)^/-- length@l+- + +#show+ + +t = --* *-'%'@lrNCC printf/$'%0.2f' times/$100. f(treatment_group,control_group) diff --git a/Task/Permutations-Derangements/0DESCRIPTION b/Task/Permutations-Derangements/0DESCRIPTION new file mode 100644 index 0000000000..ba81150663 --- /dev/null +++ b/Task/Permutations-Derangements/0DESCRIPTION @@ -0,0 +1,19 @@ +A [http://mathworld.wolfram.com/Derangement.html derangement] is a permutation of the order of distinct items in which ''no item appears in its original place''. + +For example, the only two derangements of the three items (0, 1, 2) are (1, 2, 0), and (2, 0, 1). + +The number of derangements of ''n'' distinct items is known as the subfactorial of ''n'', sometimes written as !''n''. There are various ways to [[wp:Derangement#Counting_derangements|calculate]] !''n''. + +;Task +The task is to: +# Create a named function/method/subroutine/... to generate derangements of the integers ''0..n-1'', (or ''1..n'' if you prefer). +# Generate ''and show'' all the derangements of 4 integers using the above routine. +# Create a function that calculates the subfactorial of ''n'', !''n''. +# Print and show a table of the ''counted'' number of derangements of ''n'' vs. the calculated !''n'' for n from 0..9 inclusive. + +As an optional stretch goal: +:* Calculate !''20''. + +;Cf. +* [[Anagrams/Deranged anagrams]] +* [[Best shuffle]] diff --git a/Task/Permutations-Derangements/Ada/permutations-derangements.ada b/Task/Permutations-Derangements/Ada/permutations-derangements.ada new file mode 100644 index 0000000000..7f92c27b00 --- /dev/null +++ b/Task/Permutations-Derangements/Ada/permutations-derangements.ada @@ -0,0 +1,54 @@ +with Ada.Text_IO; use Ada.Text_IO; +procedure DePermute is + type U64 is mod 2**64; + type Num is range 0 .. 20; + type NumList is array (Natural range <>) of Num; + type PtNumList is access all NumList; + package IO is new Ada.Text_IO.Integer_IO (Num); + package UIO is new Ada.Text_IO.Modular_IO (U64); + + function deranged (depth : Natural; list : PtNumList; + show : Boolean) return U64 is + tmp : Num; count : U64 := 0; + begin + if depth = list'Length then + if show then + for i in list'Range loop IO.Put (list (i), 2); end loop; + New_Line; + end if; return 1; + end if; + for i in reverse depth .. list'Last loop + if Num (i + 1) /= list (depth) then + tmp := list (i); list (i) := list (depth); list (depth) := tmp; + count := count + deranged (depth + 1, list, show); + tmp := list (i); list (i) := list (depth); list (depth) := tmp; + end if; + end loop; + return count; + end deranged; + + function gen_n (len : Natural; show : Boolean) return U64 is + list : PtNumList; + begin + list := new NumList (0 .. len - 1); + for i in list'Range loop list (i) := Num (i + 1); end loop; + return deranged (0, list, show); + end gen_n; + + function sub_fact (n : Natural) return U64 is begin + if n < 2 then return U64 (1 - n); + else return (sub_fact (n - 1) + sub_fact (n - 2)) * U64 (n - 1); + end if; + end sub_fact; + + count : U64; +begin + Put_Line ("Deranged 4:"); + count := gen_n (4, True); + Put_Line ("List vs. calc:"); + for i in Natural range 0 .. 9 loop + IO.Put (Num (i), 1); UIO.Put (gen_n (i, False), 7); + UIO.Put (sub_fact (i), 7); New_Line; + end loop; + Put_Line ("!20 = " & U64'Image (sub_fact (20))); +end DePermute; diff --git a/Task/Permutations-Derangements/AutoHotkey/permutations-derangements.ahk b/Task/Permutations-Derangements/AutoHotkey/permutations-derangements.ahk new file mode 100644 index 0000000000..ac79d37340 --- /dev/null +++ b/Task/Permutations-Derangements/AutoHotkey/permutations-derangements.ahk @@ -0,0 +1,96 @@ +#NoEnv +SetBatchLines -1 +Process, Priority,, high + +output := "Derangements for 1, 2, 3, 4:`n" + +obj := [1, 2, 3, 4], objS := obj.Clone() +Loop ; permute 4 +{ + obj := perm_NextObj(Obj) + If !obj + break + For k, v in obj + if ( objS[k] = v ) + continue 2 + output .= ObjDisp(obj) "`n" +} +output .= "`nTable of n, counted, calculated derangements:`n" + +Loop 10 ; Count !n +{ + obj := [] + count := 0 + output .= A_Tab . (i := A_Index-1) . A_Tab + Loop % i + obj[A_Index] := A_Index + objS := obj.Clone() + Loop + { + obj := perm_NextObj(Obj) + If !obj + break + For k, v in obj + if ( objS[k] = v ) + continue 2 + count++ + } + output .= count . A_Tab . cd(i) . "`n" +} +output .= "`nApproximation of !20: " . cd(20) +MsgBox % Clipboard := output + +perm_NextObj(obj){ ; next lexicographic permutation + p := 0, objM := ObjMaxIndex(obj) + Loop % objM + { + If A_Index=1 + continue + t := obj[objM+1-A_Index] + n := obj[objM+2-A_Index] + If ( t < n ) + { + p := objM+1-A_Index, pC := obj[p] + break + } + } + If !p + return false + Loop + { + t := obj[objM+1-A_Index] + If ( t > pC ) + { + n := objM+1-A_Index, nC := obj[n] + break + } + } + + obj[n] := pC, obj[p] := nC + return ObjReverse(obj, objM-p) +} + +ObjReverse(Obj, tail){ + o := ObjClone(Obj), ObjM := ObjMaxIndex(O) + Loop % tail + o[ObjM-A_Index+1] := Obj[ObjM+A_Index-tail] + return o +} + +ObjDisp(obj){ + For k, v in obj + s .= v ", " + return SubStr(s, 1, strLen(s)-2) +} + + +cd(n){ ; Count Derangements + static e := 2.71828182845904523536028747135 + return n ? floor(ft(n)/e + 1/2) : 1 +} +ft(n){ ; FacTorial + a := 1 + Loop % n + a *= A_Index + return a +} diff --git a/Task/Permutations-Derangements/BBC-BASIC/permutations-derangements-1.bbc b/Task/Permutations-Derangements/BBC-BASIC/permutations-derangements-1.bbc new file mode 100644 index 0000000000..6579260bdb --- /dev/null +++ b/Task/Permutations-Derangements/BBC-BASIC/permutations-derangements-1.bbc @@ -0,0 +1,75 @@ + PRINT"Derangements for the numbers 0,1,2,3 are:" + Count% = FN_Derangement_Generate(4,TRUE) + + PRINT'"Table of n, counted derangements, calculated derangements :" + + FOR I% = 0 TO 9 + PRINT I%, FN_Derangement_Generate(I%,FALSE), FN_SubFactorial(I%) + NEXT + + PRINT'"There is no long int in BBC BASIC!" + PRINT"!20 = ";FN_SubFactorial(20) + + END + + DEF FN_Derangement_Generate(N%, fPrintOut) + LOCAL A%(), O%(), C%, D%, I%, J% + IF N% = 0 THEN = 1 + DIM A%(N%-1), O%(N%-1) + FOR I% = 0 TO N%-1 : A%(I%) = I% : NEXT + O%() = A%() + FOR I% = 0 TO FN_Factorial(DIM(A%(),1)+1)-1 + PROC_NextPermutation(A%()) + D% = TRUE + FOR J%=0 TO N%-1 + IF A%(J%) = O%(J%) THEN D% = FALSE + NEXT + IF D% THEN + C% += 1 + IF fPrintOut THEN + FOR K% = 0 TO N%-1 + PRINT ;A%(K%);" "; + NEXT + PRINT + ENDIF + ENDIF + NEXT + = C% + + DEF PROC_NextPermutation(A%()) + LOCAL first, last, elementcount, pos + elementcount = DIM(A%(),1) + IF elementcount < 1 THEN ENDPROC + pos = elementcount-1 + WHILE A%(pos) >= A%(pos+1) + pos -= 1 + IF pos < 0 THEN + PROC_Permutation_Reverse(A%(), 0, elementcount) + ENDPROC + ENDIF + ENDWHILE + last = elementcount + WHILE A%(last) <= A%(pos) + last -= 1 + ENDWHILE + SWAP A%(pos), A%(last) + PROC_Permutation_Reverse(A%(), pos+1, elementcount) + ENDPROC + + DEF PROC_Permutation_Reverse(A%(), firstindex, lastindex) + LOCAL first, last + first = firstindex + last = lastindex + WHILE first < last + SWAP A%(first), A%(last) + first += 1 + last -= 1 + ENDWHILE + ENDPROC + + DEF FN_Factorial(N) : IF (N = 1) OR (N = 0) THEN =1 ELSE = N * FN_Factorial(N-1) + + DEF FN_SubFactorial(N) : IF N=0 THEN =1 ELSE =N*FN_SubFactorial(N-1)+-1^N + + REM Or you could use: + REM DEF FN_SubFactorial(N) : IF N<1 THEN =1 ELSE =(N-1)*(FN_SubFactorial(N-1)+FN_SubFactorial(N-2)) diff --git a/Task/Permutations-Derangements/BBC-BASIC/permutations-derangements-2.bbc b/Task/Permutations-Derangements/BBC-BASIC/permutations-derangements-2.bbc new file mode 100644 index 0000000000..af47ed865d --- /dev/null +++ b/Task/Permutations-Derangements/BBC-BASIC/permutations-derangements-2.bbc @@ -0,0 +1,26 @@ +Derangements for the numbers 0,1,2,3 are: +1 0 3 2 +1 2 3 0 +1 3 0 2 +2 0 3 1 +2 3 0 1 +2 3 1 0 +3 0 1 2 +3 2 0 1 +3 2 1 0 + +Table of n, counted derangements, calculated derangements : + 0 1 1 + 1 0 0 + 2 1 1 + 3 2 2 + 4 9 9 + 5 44 44 + 6 265 265 + 7 1854 1854 + 8 14833 14833 + 9 133496 133496 + +There is no long int in BBC BASIC! +!20 = 8.95014632E17 +> diff --git a/Task/Permutations-Derangements/C/permutations-derangements.c b/Task/Permutations-Derangements/C/permutations-derangements.c new file mode 100644 index 0000000000..42e61d3c5e --- /dev/null +++ b/Task/Permutations-Derangements/C/permutations-derangements.c @@ -0,0 +1,57 @@ +#include +typedef unsigned long long LONG; + +LONG deranged(int depth, int len, int *d, int show) +{ + int i; + char tmp; + LONG count = 0; + + if (depth == len) { + if (show) { + for (i = 0; i < len; i++) putchar(d[i] + 'a'); + putchar('\n'); + } + return 1; + } + for (i = len - 1; i >= depth; i--) { + if (i == d[depth]) continue; + + tmp = d[i]; d[i] = d[depth]; d[depth] = tmp; + count += deranged(depth + 1, len, d, show); + tmp = d[i]; d[i] = d[depth]; d[depth] = tmp; + } + return count; +} + +LONG gen_n(int n, int show) +{ + LONG i; + int a[1024]; /* 1024 ought to be big enough for anybody */ + + for (i = 0; i < n; i++) a[i] = i; + return deranged(0, n, a, show); +} + +LONG sub_fact(int n) +{ + return n < 2 ? 1 - n : (sub_fact(n - 1) + sub_fact(n - 2)) * (n - 1); +} + +int main() +{ + int i; + + printf("Deranged Four:\n"); + gen_n(4, 1); + + printf("\nCompare list vs calc:\n"); + for (i = 0; i < 10; i++) + printf("%d:\t%llu\t%llu\n", i, gen_n(i, 0), sub_fact(i)); + + printf("\nfurther calc:\n"); + for (i = 10; i <= 20; i++) + printf("%d: %llu\n", i, sub_fact(i)); + + return 0; +} diff --git a/Task/Permutations-Derangements/D/permutations-derangements-1.d b/Task/Permutations-Derangements/D/permutations-derangements-1.d new file mode 100644 index 0000000000..57ca50a784 --- /dev/null +++ b/Task/Permutations-Derangements/D/permutations-derangements-1.d @@ -0,0 +1,65 @@ +import std.stdio, std.algorithm, std.typecons, std.array, + std.conv, std.range, std.traits; + +auto derangements(in size_t n, in bool countOnly=false) +/*pure nothrow*/ { + size_t[] seq = iota(n).array(); + auto ori = seq.idup; + size_t[][] all; + size_t cnt = n == 0; + + foreach (tot; 0 .. fact(n)-1) { + size_t j = n - 2; + while (seq[j] > seq[j + 1]) + j--; + size_t k = n - 1; + while (seq[j] > seq[k]) + k--; + swap(seq[k], seq[j]); + + size_t r = n - 1; + size_t s = j + 1; + while (r > s) { + swap(seq[s], seq[r]); + r--; + s++; + } + + j = 0; + while (j < n && seq[j] != ori[j]) + j++; + if (j == n) { + if (countOnly) + cnt++; + else + all ~= seq.dup; + } + } + + return tuple(all, cnt); +} + +T fact(T)(in T n) pure nothrow { + Unqual!T result = 1; + for (Unqual!T i = 2; i <= n; i++) + result *= i; + return result; +} + +T subfact(T)(in T n) pure nothrow { + if (0 <= n && n <= 2) + return n != 1; + return (n - 1) * (subfact(n - 1) + subfact(n - 2)); +} + +void main() { + writeln("derangements for n = 4\n"); + foreach (d; derangements(4)[0]) + writeln(d); + + writeln("\ntable of n vs counted vs calculated derangements\n"); + foreach (i; 0 .. 10) + writefln("%s %-7s%-7s", i, derangements(i, 1)[1], subfact(i)); + + writefln("\n!20 = %s", subfact(20L)); +} diff --git a/Task/Permutations-Derangements/D/permutations-derangements-2.d b/Task/Permutations-Derangements/D/permutations-derangements-2.d new file mode 100644 index 0000000000..0709f036d7 --- /dev/null +++ b/Task/Permutations-Derangements/D/permutations-derangements-2.d @@ -0,0 +1,47 @@ +import std.stdio, std.algorithm, std.typecons, std.array, + std.conv, std.range, std.traits; + +auto derangementsR(in size_t n, in bool countOnly=false) { + auto seq = iota(n).array(); + immutable ori = seq.idup; + const(size_t[])[] res; + size_t cnt; + + void perms(in size_t[] s, in size_t[] pre=null) nothrow { + if (s.length) { + foreach (i, c; s) + perms(s[0 .. i] ~ s[i + 1 .. $], pre ~ c); + } else if (mismatch!q{a != b}(pre, ori)[0].length == 0) { + if (countOnly) cnt++; + else res ~= pre; + } + } + + perms(seq); + return tuple(res, cnt); +} + +T fact(T)(in T n) pure nothrow { + Unqual!T result = 1; + for (Unqual!T i = 2; i <= n; i++) + result *= i; + return result; +} + +T subfact(T)(in T n) pure nothrow { + if (0 <= n && n <= 2) + return n != 1; + return (n - 1) * (subfact(n - 1) + subfact(n - 2)); +} + +void main() { + writeln("derangements for n = 4\n"); + foreach (const d; derangementsR(4)[0]) + writeln(d); + + writeln("\ntable of n vs counted vs calculated derangements\n"); + foreach (i; 0 .. 10) + writefln("%s %-7s%-7s", i, derangementsR(i,1)[1], subfact(i)); + + writefln("\n!20 = %s", subfact(20L)); +} diff --git a/Task/Permutations-Derangements/GAP/permutations-derangements.gap b/Task/Permutations-Derangements/GAP/permutations-derangements.gap new file mode 100644 index 0000000000..2d8631fd30 --- /dev/null +++ b/Task/Permutations-Derangements/GAP/permutations-derangements.gap @@ -0,0 +1,35 @@ +# All of this is built-in +Derangements([1 .. 4]); +# [ [ 2, 1, 4, 3 ], [ 2, 3, 4, 1 ], [ 2, 4, 1, 3 ], [ 3, 1, 4, 2 ], [ 3, 4, 1, 2 ], [ 3, 4, 2, 1 ], +# [ 4, 1, 2, 3 ], [ 4, 3, 1, 2 ], [ 4, 3, 2, 1 ] ] +Size(last); +# 9 + +NrDerangements([1 .. 4]); +# 9 + +# An implementation using formula D(n + 1) = n*(D(n) + D(n - 1)) +NrDerangementsAlt_memo := [1, 0]; +NrDerangementsAlt := function(n) + if not IsBound(NrDerangementsAlt_memo[n + 1]) then + NrDerangementsAlt_memo[n + 1] := (n - 1)*(NrDerangementsAlt(n - 1) + NrDerangementsAlt(n - 2)); + fi; + return NrDerangementsAlt_memo[n + 1]; +end; + +L := List([0 .. 9]); + +PrintArray(TransposedMat([L, + List(L, n -> Size(Derangements([1 .. n]))), + List(L, n -> NrDerangements([1 .. n])), + List(L, NrDerangementsAlt)])); +# [ [ 0, 1, 1, 1 ], +# [ 1, 0, 0, 0 ], +# [ 2, 1, 1, 1 ], +# [ 3, 2, 2, 2 ], +# [ 4, 9, 9, 9 ], +# [ 5, 44, 44, 44 ], +# [ 6, 265, 265, 265 ], +# [ 7, 1854, 1854, 1854 ], +# [ 8, 14833, 14833, 14833 ], +# [ 9, 133496, 133496, 133496 ] ] diff --git a/Task/Permutations-Derangements/Go/permutations-derangements.go b/Task/Permutations-Derangements/Go/permutations-derangements.go new file mode 100644 index 0000000000..b71174f0fd --- /dev/null +++ b/Task/Permutations-Derangements/Go/permutations-derangements.go @@ -0,0 +1,71 @@ +package main + +import ( + "fmt" + "math/big" +) + +// task 1: function returns list of derangements of n integers +func dList(n int) (r [][]int) { + a := make([]int, n) + for i := range a { + a[i] = i + } + // recursive closure permutes a + var recurse func(last int) + recurse = func(last int) { + if last == 0 { + // bottom of recursion. you get here once for each permutation. + // test if permutation is deranged. + for j, v := range a { + if j == v { + return // no, ignore it + } + } + // yes, save a copy + r = append(r, append([]int{}, a...)) + return + } + for i := last; i >= 0; i-- { + a[i], a[last] = a[last], a[i] + recurse(last - 1) + a[i], a[last] = a[last], a[i] + } + } + recurse(n - 1) + return +} + +// task 3: function computes subfactorial of n +func subFact(n int) *big.Int { + if n == 0 { + return big.NewInt(1) + } else if n == 1 { + return big.NewInt(0) + } + d0 := big.NewInt(1) + d1 := big.NewInt(0) + f := new(big.Int) + for i, n64 := int64(1), int64(n); i < n64; i++ { + d0, d1 = d1, d0.Mul(f.SetInt64(i), d0.Add(d0, d1)) + } + return d1 +} + +func main() { + // task 2: + fmt.Println("Derangements of 4 integers") + for _, d := range dList(4) { + fmt.Println(d) + } + + // task 4: + fmt.Println("\nNumber of derangements") + fmt.Println("N Counted Calculated") + for n := 0; n <= 9; n++ { + fmt.Printf("%d %8d %11s\n", n, len(dList(n)), subFact(n).String()) + } + + // stretch (sic) + fmt.Println("\n!20 =", subFact(20)) +} diff --git a/Task/Permutations-Derangements/Groovy/permutations-derangements-1.groovy b/Task/Permutations-Derangements/Groovy/permutations-derangements-1.groovy new file mode 100644 index 0000000000..b5c0ba81e0 --- /dev/null +++ b/Task/Permutations-Derangements/Groovy/permutations-derangements-1.groovy @@ -0,0 +1,9 @@ +def fact = { n -> [1,(1..<(n+1)).inject(1) { prod, i -> prod * i }].max() } +def subfact +subfact = { BigInteger n -> (n == 0) ? 1 : (n == 1) ? 0 : ((n-1) * (subfact(n-1) + subfact(n-2))) } + +def derangement = { List l -> + def d = [] + l.eachPermutation { p -> if ([p,l].transpose().every{ it[0] != it[1] }) d << p } + d +} diff --git a/Task/Permutations-Derangements/Groovy/permutations-derangements-2.groovy b/Task/Permutations-Derangements/Groovy/permutations-derangements-2.groovy new file mode 100644 index 0000000000..038f242fef --- /dev/null +++ b/Task/Permutations-Derangements/Groovy/permutations-derangements-2.groovy @@ -0,0 +1,16 @@ +def d = derangement([1,2,3,4]) +assert d.size() == subfact(4) +d.each { println it } + +println """ +n # derangements subfactorial += ============== ============""" +(0..9). each { n -> + def dr = derangement((1..<(n+1)) as List) + def sf = subfact(n) + printf('%1d %14d %12d\n', n, dr.size(), sf) +} + +println """ +!20 == ${subfact(20)} +""" diff --git a/Task/Permutations-Derangements/Haskell/permutations-derangements-1.hs b/Task/Permutations-Derangements/Haskell/permutations-derangements-1.hs new file mode 100644 index 0000000000..7938bbc119 --- /dev/null +++ b/Task/Permutations-Derangements/Haskell/permutations-derangements-1.hs @@ -0,0 +1,25 @@ +import Control.Monad +import Data.List + +-- Compute all derangements of a list +derangements xs = filter (and . zipWith (/=) xs) $ permutations xs + +-- Compute the number of derangements of n elements +subfactorial 0 = 0 +subfactorial 1 = 0 +subfactorial 2 = 1 +subfactorial n = (n-1) * (subfactorial (n-1) + subfactorial (n-2)) + +main = do + -- Generate and show all the derangements of four integers + print $ derangements [1..4] + putStrLn "" + + -- Print the count of derangements vs subfactorial + forM_ [1..9] $ \i -> + putStrLn $ show (length (derangements [1..i])) ++ " " ++ + show (subfactorial i) + putStrLn "" + + -- Print the number of derangements in a list of 20 items + print $ subfactorial 20 diff --git a/Task/Permutations-Derangements/Haskell/permutations-derangements-2.hs b/Task/Permutations-Derangements/Haskell/permutations-derangements-2.hs new file mode 100644 index 0000000000..1923c13b31 --- /dev/null +++ b/Task/Permutations-Derangements/Haskell/permutations-derangements-2.hs @@ -0,0 +1,3 @@ +derangements xs = loop xs xs + where loop [] [] = [[]] + loop (h:hs) xs = [x:ys | x <- xs, x /= h, ys <- loop hs (delete x xs)] diff --git a/Task/Permutations-Derangements/J/permutations-derangements-1.j b/Task/Permutations-Derangements/J/permutations-derangements-1.j new file mode 100644 index 0000000000..7e9a39e3f4 --- /dev/null +++ b/Task/Permutations-Derangements/J/permutations-derangements-1.j @@ -0,0 +1,2 @@ +derangement=: (A.&i.~ !)~ (*/ .~: # [) i. NB. task item 1 +subfactorial=: ! * +/@(_1&^ % !)@i.@>: NB. task item 3 diff --git a/Task/Permutations-Derangements/J/permutations-derangements-2.j b/Task/Permutations-Derangements/J/permutations-derangements-2.j new file mode 100644 index 0000000000..2e32222965 --- /dev/null +++ b/Task/Permutations-Derangements/J/permutations-derangements-2.j @@ -0,0 +1,25 @@ + derangement 4 NB. task item 2 +1 0 3 2 +1 2 3 0 +1 3 0 2 +2 0 3 1 +2 3 0 1 +2 3 1 0 +3 0 1 2 +3 2 0 1 +3 2 1 0 + (,subfactorial,#@derangement)"0 i.10 NB. task item 4 +0 1 1 +1 0 0 +2 1 1 +3 2 2 +4 9 9 +5 44 44 +6 265 265 +7 1854 1854 +8 14833 14833 +9 133496 133496 + subfactorial 20 NB. stretch task +8.95015e17 + subfactorial 20x NB. using extended precision +895014631192902121 diff --git a/Task/Permutations-Derangements/Java/permutations-derangements.java b/Task/Permutations-Derangements/Java/permutations-derangements.java new file mode 100644 index 0000000000..5058c4ab94 --- /dev/null +++ b/Task/Permutations-Derangements/Java/permutations-derangements.java @@ -0,0 +1,95 @@ +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class Derangement { + + public static void main(String[] args) { + System.out.println("derangements for n = 4\n"); + for (Object d : (ArrayList)(derangements(4, false)[0])) { + System.out.println(Arrays.toString((int[])d)); + } + + System.out.println("\ntable of n vs counted vs calculated derangements\n"); + for (int i = 0; i < 10; i++) { + int d = ((Integer)derangements(i, true)[1]).intValue(); + System.out.printf("%d %-7d %-7d\n", i, d, subfact(i)); + } + + System.out.printf ("\n!20 = %20d\n", subfact(20L)); + } + + static Object[] derangements(int n, boolean countOnly) { + int[] seq = iota(n); + int[] ori = Arrays.copyOf(seq, n); + long tot = fact(n); + + List all = new ArrayList(); + int cnt = n == 0 ? 1 : 0; + + while (--tot > 0) { + int j = n - 2; + while (seq[j] > seq[j + 1]) { + j--; + } + int k = n - 1; + while (seq[j] > seq[k]) { + k--; + } + swap(seq, k, j); + + int r = n - 1; + int s = j + 1; + while (r > s) { + swap(seq, s, r); + r--; + s++; + } + + j = 0; + while (j < n && seq[j] != ori[j]) { + j++; + } + if (j == n) { + if (countOnly) { + cnt++; + } else { + all.add(Arrays.copyOf(seq, n)); + } + } + } + return new Object[]{all, cnt}; + } + + static long fact(long n) { + long result = 1; + for (long i = 2; i <= n; i++) { + result *= i; + } + return result; + } + + static long subfact(long n) { + if (0 <= n && n <= 2) { + return n != 1 ? 1 : 0; + } + return (n - 1) * (subfact(n - 1) + subfact(n - 2)); + } + + static void swap(int[] arr, int lhs, int rhs) { + int tmp = arr[lhs]; + arr[lhs] = arr[rhs]; + arr[rhs] = tmp; + } + + static int[] iota(int n) { + if (n < 0) { + throw new IllegalArgumentException("iota cannot accept < 0"); + } + int[] r = new int[n]; + for (int i = 0; i < n; i++) { + r[i] = i; + } + return r; + } +} diff --git a/Task/Permutations-Derangements/Mathematica/permutations-derangements.math b/Task/Permutations-Derangements/Mathematica/permutations-derangements.math new file mode 100644 index 0000000000..1d3b02a33f --- /dev/null +++ b/Task/Permutations-Derangements/Mathematica/permutations-derangements.math @@ -0,0 +1,5 @@ +Needs["Combinatorica`"] +derangements[n_] := Derangements[Range[n]] +derangements[4] +Table[{NumberOfDerangements[i], Subfactorial[i]}, {i, 9}] // TableForm +Subfactorial[20] diff --git a/Task/Permutations-Derangements/PARI-GP/permutations-derangements.pari b/Task/Permutations-Derangements/PARI-GP/permutations-derangements.pari new file mode 100644 index 0000000000..c1a945d1dc --- /dev/null +++ b/Task/Permutations-Derangements/PARI-GP/permutations-derangements.pari @@ -0,0 +1,19 @@ +derangements(n)=if(n,round(n!/exp(1)),1); +derange(n)={ + my(v=[[]],tmp); + for(level=1,n, + tmp=List(); + for(i=1,#v, + for(k=1,n, + if(k==level, next); + for(j=1,level-1,if(v[i][j]==k, next(2))); + listput(tmp, concat(v[i],k)) + ) + ); + v=Vec(tmp) + ); + v +}; +derange(4) +for(n=0,9,print("!"n" = "#derange(n)" = "derangements(n))) +derangements(20) diff --git a/Task/Permutations-Derangements/Perl-6/permutations-derangements.pl6 b/Task/Permutations-Derangements/Perl-6/permutations-derangements.pl6 new file mode 100644 index 0000000000..2d7b9145c2 --- /dev/null +++ b/Task/Permutations-Derangements/Perl-6/permutations-derangements.pl6 @@ -0,0 +1,32 @@ +sub derange (@result, @avail) { + if not @avail { @result.item } + else { + map { + derange([ @result, @avail[$_] ], + @avail[0 .. $_-1, $_+1 ..^ @avail ]) + }, grep { @avail[$_] != @result }, 0 .. @avail-1; + } +} + +constant factorial = 1, [\*] 1...*; + +# choose k among n, i.e. n! / k! (n-k)! +sub choose ($n, $k) { factorial[$n] div factorial[$k] div factorial[$n - $k] } + +sub sub-factorial ($n) { + (state @)[$n] //= + factorial[$n] - [+] gather for 1 .. $n -> $k { + take choose($n, $k) * sub-factorial($n - $k); + } +} + +say "Derangements for 4 elements:"; +for derange([], 0 .. 3).kv -> $i, @d { + say $i+1, ': ', @d; +} + +say "\nCompare list length and calculated table"; +say "$_\t{+derange([], ^$_)}\t{sub-factorial($_)}" for 0 .. 9; + +say "\nNumber of derangements:"; +say "$_:\t{sub-factorial($_)}" for 1 .. 20; diff --git a/Task/Permutations-Derangements/Perl/permutations-derangements.pl b/Task/Permutations-Derangements/Perl/permutations-derangements.pl new file mode 100644 index 0000000000..1ee43ebe80 --- /dev/null +++ b/Task/Permutations-Derangements/Perl/permutations-derangements.pl @@ -0,0 +1,66 @@ +sub d { + # compare this with the deranged() sub to see how to turn procedural + # code into functional one ('functional' as not in 'understandable') + $#_ ? map d([ @{$_[0]}, $_[$_] ], @_[1 .. $_-1, $_+1 .. $#_ ]), + grep { $_[$_] != @{$_[0]} } 1 .. $#_ + : $_[0] +} + +sub deranged { # same as sub d above, just a readable version to explain method + my ($result, @avail) = @_; + return $result if !@avail; # no more elements to pick from, done + + my @list; # list of permutations to return + for my $i (0 .. $#avail) { # try to add each element to result in turn + next if $avail[$i] == @$result; # element n at n-th position, no-no + my $e = splice @avail, $i, 1; # move the n-th element from available to result + push @list, deranged([ @$result, $e ], @avail); + # and recurse down, keep what's returned + splice @avail, $i, 0, $e; # put that element back, try next + } + return @list; +} + +sub choose { # choose k among n, i.e. n! / k! (n-k)! + my ($n, $k) = @_; + factorial($n) / factorial($k) / factorial($n - $k) +} + +my @fact = (1); +sub factorial { + # //= : standard caching technique. If cached value available, + # return it; else compute, cache and return. + # For this specific task not really necessary. + $fact[ $_[0] ] //= $_[0] * factorial($_[0] - 1) +} + +my @subfact; +sub sub_factorial { + my $n = shift; + $subfact[$n] //= do # same caching stuff, try comment out this line + { + # computes deranged without formula, using recursion + my $total = factorial($n); # total permutations + for my $k (1 .. $n) { + # minus the permutations where k items are fixed + # to original location, and the rest deranged + $total -= choose($n, $k) * sub_factorial($n - $k) + } + $total + } +} + +print "Derangements for 4 elements:\n"; +my @deranged = d([], 0 .. 3); +for (1 .. @deranged) { + print "$_: @{$deranged[$_-1]}\n" +} + +print "\nCompare list length and calculated table\n"; +for (0 .. 9) { + my @x = d([], 0 .. $_-1); + print $_, "\t", scalar(@x), "\t", sub_factorial($_), "\n" +} + +print "\nNumber of derangements:\n"; +print "$_:\t", sub_factorial($_), "\n" for 1 .. 20; diff --git a/Task/Permutations-Derangements/PicoLisp/permutations-derangements.l b/Task/Permutations-Derangements/PicoLisp/permutations-derangements.l new file mode 100644 index 0000000000..2a99a3e94f --- /dev/null +++ b/Task/Permutations-Derangements/PicoLisp/permutations-derangements.l @@ -0,0 +1,13 @@ +(load "@lib/simul.l") # For 'permute' + +(de derangements (Lst) + (filter + '((L) (not (find = L Lst))) + (permute Lst) ) ) + +(de subfact (N) + (if (>= 2 N) + (if (= 1 N) 0 1) + (* + (dec N) + (+ (subfact (dec N)) (subfact (- N 2))) ) ) ) diff --git a/Task/Permutations-Derangements/PureBasic/permutations-derangements-1.purebasic b/Task/Permutations-Derangements/PureBasic/permutations-derangements-1.purebasic new file mode 100644 index 0000000000..99f8ee133c --- /dev/null +++ b/Task/Permutations-Derangements/PureBasic/permutations-derangements-1.purebasic @@ -0,0 +1,123 @@ +Procedure.q perm(n) +if n=0:ProcedureReturn 1:endif +if n=1:ProcedureReturn 0:endif +ProcedureReturn (perm(n-1)+perm(n-2))*(n-1) +EndProcedure + +factFile.s="factorials.txt" +tempFile.s="temp.txt" +drngFile.s="derangements.txt" +DeleteFile(factFile.s) +DeleteFile(tempFile.s) +DeleteFile(drngFile.s) + +n=4 + +; create our storage file +f.s=factFile.s +If CreateFile(2113,f.s) +WriteStringN(2113,"1.2") +WriteStringN(2113,"2.1") +CloseFile(2113) +Else +Debug "not createfile :"+f.s +EndIf + +showfactorial=#FALSE + +if showfactorial +; cw("nfactorial n ="+str(n)) +Debug "nfactorial n ="+str(n) +endif + +; build up the factorial combinations +for l=1 to n-2 +gosub nfactorial +next + +; extract the derangements +; cw("derangements["+str(perm(n))+"] for n="+str(n)) +Debug "derangements["+str(perm(n))+"] for n="+str(n) +gosub derangements +; cw("") +Debug "" + +; show the first 20 derangements +for i=0 to 20 +; cw("derangements["+str(perm(i))+"] for n="+str(i)) +Debug "derangements["+str(perm(i))+"] for n="+str(i) +next +end + +derangements: +x=0 +If ReadFile(2112,factFile.s) and CreateFile(2113,drngFile.s) +repeat +r.s = ReadString(2112) +cs=CountString(r.s,".") +if cs +hit=0 +t.s="" +; scan for numbers at their index +for i=1 to cs+1 +s.s=StringField(r.s,i,".") +t.s+s.s+"." +if val(s.s)=i:hit+1:endif +next +t.s=rtrim(t.s,".") +; show only those which are valid +if not hit +x+1 +; cw(t.s+" "+str(x)) +Debug t.s+" "+str(x) +WriteStringN(2113,t.s+" "+str(x)) +endif +endif +until eof(2112) +CloseFile(2112) +CloseFile(2113) +Else +Debug "not readfile :"+factFile.s +Debug "not createfile :"+drngFile.s +EndIf +; cw("") +Debug "" +return + +nfactorial: +x=0 +If ReadFile(2112,factFile.s) and CreateFile(2113,tempFile.s) +repeat +r.s = ReadString(2112) +cs=CountString(r.s,".") +if cs +for j=1 to cs+2 +t.s="" +for i=1 to cs+1 +s.s=StringField(r.s,i,".") +if i=j +t.s+"."+str(cs+2)+"."+s.s +else +t.s+"."+s.s +endif +next +if j=cs+2:t.s+"."+str(cs+2):endif +t.s=trim(t.s,".") +x+1 +if cs+2=n and showfactorial +; cw(t.s+" "+str(x)) +Debug t.s+" "+str(x) +endif +WriteStringN(2113,t.s) +next +endif +until eof(2112) +CloseFile(2112) +CloseFile(2113) +Else +Debug "not readfile :"+factFile.s +Debug "not createfile :"+tempFile.s +EndIf +CopyFile(tempFile.s,factFile.s) +DeleteFile(tempFile.s) +return diff --git a/Task/Permutations-Derangements/PureBasic/permutations-derangements-2.purebasic b/Task/Permutations-Derangements/PureBasic/permutations-derangements-2.purebasic new file mode 100644 index 0000000000..73b5f67e78 --- /dev/null +++ b/Task/Permutations-Derangements/PureBasic/permutations-derangements-2.purebasic @@ -0,0 +1,57 @@ +Procedure.i deranged(depth,lenn,array d(1),show) +Protected count.l,tmp,i + if (depth = lenn) + if (show) + ; for i = 0 to lenn-1:so(chr(d(i) + 'a')):next + for i = 0 to lenn-1:Debug chr(d(i) + 'a'):next + ; cw("") + Debug "" + endif + ProcedureReturn 1 + endif + + for i = lenn - 1 to depth step -1 + if i = d(depth) :continue:endif + + tmp = d(i): d(i) = d(depth): d(depth) = tmp + count + deranged(depth + 1, lenn, d(), show) + tmp = d(i): d(i) = d(depth): d(depth) = tmp + next + +ProcedureReturn count +EndProcedure + +Procedure.q sub_fact(n) +if n=0:ProcedureReturn 1:endif +if n=1:ProcedureReturn 0:endif +ProcedureReturn (sub_fact(n-1)+sub_fact(n-2))*(n-1) +EndProcedure + +Procedure.i gen_n(n,show) +Protected r.i +global dim a(1024) +for i=0 to n-1:a(i)=i:next +ProcedureReturn deranged(0, n, a(), show) +EndProcedure + + ; cw("Deranged Four:") + Debug "Deranged Four:" + gen_n(4, 1) + ; cw("") + Debug "" + + ; cw("Compare list vs calc:") + Debug "Compare list vs calc:" + for i = 0 to 9 + ; cw(str(i)+" "+str(gen_n(i, 0))+" "+str(sub_fact(i))) + Debug str(i)+" "+str(gen_n(i, 0))+" "+str(sub_fact(i)) + next + ; cw("") + Debug "" + + ; cw("further calc:") + Debug "further calc:" + for i = 10 to 20 + ; cw(str(i)+" "+str(sub_fact(i))) + Debug str(i)+" "+str(sub_fact(i)) + next diff --git a/Task/Permutations-Derangements/Python/permutations-derangements.py b/Task/Permutations-Derangements/Python/permutations-derangements.py new file mode 100644 index 0000000000..fc46a3b308 --- /dev/null +++ b/Task/Permutations-Derangements/Python/permutations-derangements.py @@ -0,0 +1,41 @@ +from itertools import permutations +import math + + +def derangements(n): + 'All deranged permutations of the integers 0..n-1 inclusive' + return ( perm for perm in permutations(range(n)) + if all(indx != p for indx, p in enumerate(perm)) ) + +def subfact(n): + if n == 2 or n == 0: + return 1 + elif n == 1: + return 0 + elif 1 <= n <=18: + return round(math.factorial(n) / math.e) + elif n.imag == 0 and n.real == int(n.real) and n > 0: + return (n-1) * ( subfact(n - 1) + subfact(n - 2) ) + else: + raise ValueError() + +def _iterlen(iter): + 'length of an iterator without taking much memory' + l = 0 + for x in iter: + l += 1 + return l + +if __name__ == '__main__': + n = 4 + print("Derangements of %s" % (tuple(range(n)),)) + for d in derangements(n): + print(" %s" % (d,)) + + print("\nTable of n vs counted vs calculated derangements") + for n in range(10): + print("%2i %-5i %-5i" % + (n, _iterlen(derangements(n)), subfact(n))) + + n = 20 + print("\n!%i = %i" % (n, subfact(n))) diff --git a/Task/Permutations-Derangements/REXX/permutations-derangements.rexx b/Task/Permutations-Derangements/REXX/permutations-derangements.rexx new file mode 100644 index 0000000000..7d28817bc0 --- /dev/null +++ b/Task/Permutations-Derangements/REXX/permutations-derangements.rexx @@ -0,0 +1,43 @@ +/*REXX pgm generates all permutations of N derangements & subfactorial #*/ +numeric digits 1000 /*be able to handle big subfacts.*/ +parse arg N .; if N=='' then N=4 /*Not specified? Assume default*/ +d=derangementsSet(N) /*go & build the derangements set*/ +say d 'derangements for' N "items are:" +say + do i=1 for d /*show derangements for N items.*/ + say right('derangement',22) right(i,length(d)) '───►' $.i + end /*i*/ +say /* [↓] count and calculate !L. */ + do L=0 to 9; d=derangementsSet(L) + say L 'items: derangement count='right(d,6)", !"L'='right(!s(L),6) + end /*L*/ +say +say right('!20=' , 40) !s( 20) +say right('!100=', 40) !s(100) +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────!S subroutine───────────────────────*/ +!s: _=1; do j=1 for arg(1);if j//2 then _=-1+j*_;else _=1+j*_;end;return _ +/*──────────────────────────────────DERANGEMENTSSET subroutine──────────*/ +derangementsSet: procedure expose $.; parse arg x; $.=; #=0; p=x-1 +if x==0 then return 1; if x==1 then return 0 + /*populate the first derangement.*/ +@.1=2; @.2=1; do i=3 to x; @.i=i; end +parse value @.p @.x with @.x @.p; call .buildD x /*swap & build.*/ + /*build others.*/ + do while .nextD(x,0); call .buildD x; end +return # +/*──────────────────────────────────.BUILDD subroutine──────────────────*/ +.buildD: do j=1 for arg(1); if @.j==j then return; end +#=#+1; do j=1 for arg(1); $.#=$.# @.j; end; return +/*──────────────────────────────────.NEXTD subroutine───────────────────*/ +.nextD: procedure expose @.; parse arg n,i; nm=n-1 + + do k=nm by -1 for nm; kp=k+1; if @.k<@.kp then do; i=k; leave; end + end /*k*/ + + do j=i+1 while jABSp%(i%-1) IF ABSp%(i%)>ABSp%(k%) k% = i% + NEXT + FOR i% = 1 TO n%-1 + IF p%(i%)>0 IF ABSp%(i%)>ABSp%(i%+1) IF ABSp%(i%)>ABSp%(k%) k% = i% + NEXT + IF k% THEN + FOR i% = 1 TO n% + IF ABSp%(i%)>ABSp%(k%) p%(i%) *= -1 + NEXT + i% = k%+SGNp%(k%) + SWAP p%(k%),p%(i%) + s% = -s% + ENDIF + UNTIL k% = 0 + ENDPROC diff --git a/Task/Permutations-by-swapping/D/permutations-by-swapping-1.d b/Task/Permutations-by-swapping/D/permutations-by-swapping-1.d new file mode 100644 index 0000000000..39c7b95d2a --- /dev/null +++ b/Task/Permutations-by-swapping/D/permutations-by-swapping-1.d @@ -0,0 +1,91 @@ +import std.algorithm, std.array, std.typecons, std.range; + +struct Spermutations(bool doCopy=true) { + private immutable uint n; + alias TResult = Tuple!(int[], int); + + int opApply(in int delegate(in ref TResult) dg) { + int result; + + int sign = 1; + alias Int2 = Tuple!(int, int); + auto p = iota(n).map!(i => Int2(i, i ? -1 : 0))().array(); + TResult aux; + + if (doCopy) { + aux[0] = p.map!(pp => pp[0])().array(); + } else { + aux[0] = new int[n]; + foreach (immutable i, immutable pp; p) + aux[0][i] = pp[0]; + } + aux[1] = sign; + result = dg(aux); + if (result) + goto END; + + while (p.canFind!(pp => pp[1])()) { + // Failed to use std.algorithm here, too much complex. + auto largest = Int2(-100, -100); + int i1 = -1; + foreach (immutable i, immutable pp; p) { + if (pp[1]) { + if (pp[0] > largest[0]) { + i1 = i; + largest = pp; + } + } + } + immutable n1 = largest[0], d1 = largest[1]; + + sign *= -1; + int i2; + if (d1 == -1) { + i2 = i1 - 1; + swap(p[i1], p[i2]); + if (i2 == 0 || p[i2 - 1][0] > n1) + p[i2][1] = 0; + } else if (d1 == 1) { + i2 = i1 + 1; + swap(p[i1], p[i2]); + if (i2 == n - 1 || p[i2 + 1][0] > n1) + p[i2][1] = 0; + } + + if (doCopy) { + aux[0] = p.map!(pp => pp[0])().array(); + } else { + foreach (immutable i, immutable pp; p) + aux[0][i] = pp[0]; + } + aux[1] = sign; + result = dg(aux); + if (result) + goto END; + + foreach (immutable i3, ref pp; p) { + immutable n3 = pp[0], d3 = pp[1]; + if (n3 > n1) + pp[1] = (i3 < i2) ? 1 : -1; + } + } + + END: return result; + } +} + +Spermutations!doCopy spermutations(bool doCopy=true)(in uint n) { + return typeof(return)(n); +} + + +version (permutations_by_swapping1) { + void main() { + import std.stdio; + foreach (n; [3, 4]) { + writefln("\nPermutations and sign of %d items", n); + foreach (tp; spermutations(n)) + writefln("Perm: %s Sign: %2d", tp.tupleof); + } + } +} diff --git a/Task/Permutations-by-swapping/D/permutations-by-swapping-2.d b/Task/Permutations-by-swapping/D/permutations-by-swapping-2.d new file mode 100644 index 0000000000..5630e7bf4e --- /dev/null +++ b/Task/Permutations-by-swapping/D/permutations-by-swapping-2.d @@ -0,0 +1,34 @@ +import std.algorithm, std.array, std.typecons, std.range; + +Tuple!(int[], int)[] sPermutations(in int n) /*pure nothrow*/ { + static int[][] sPermu(in int items) /*pure nothrow*/ { + if (items <= 0) + return [[]]; + typeof(return) r; + foreach (i, item; sPermu(items - 1)) { + if (i % 2) + r ~= iota(cast(int)item.length, -1, -1) + .map!(i => item[0..i] ~ (items-1) ~ item[i..$])() + .array(); + else + r ~= iota(item.length + 1) + .map!(i => item[0..i] ~ (items-1) ~ item[i..$])() + .array(); + } + return r; + } + + auto r = sPermu(n); + return iota(r.length) + .map!(i => tuple(r[i], i % 2 ? -1 : 1))() + .array(); +} + +void main() { + import std.stdio; + foreach (n; [3, 4]) { + writefln("\nPermutations and sign of %d items", n); + foreach (tp; sPermutations(n)) + writefln("Perm: %s Sign: %2d", tp.tupleof); + } +} diff --git a/Task/Permutations-by-swapping/Haskell/permutations-by-swapping.hs b/Task/Permutations-by-swapping/Haskell/permutations-by-swapping.hs new file mode 100644 index 0000000000..f5913a4a54 --- /dev/null +++ b/Task/Permutations-by-swapping/Haskell/permutations-by-swapping.hs @@ -0,0 +1,18 @@ +insertEverywhere :: a -> [a] -> [[a]] +insertEverywhere x [] = [[x]] +insertEverywhere x l@(y:ys) = (x:l) : map (y:) (insertEverywhere x ys) + +s_perm :: [a] -> [[a]] +s_perm = foldl aux [[]] + where aux items x = do (f, item) <- zip (cycle [reverse, id]) items + f (insertEverywhere x item) + +s_permutations :: [a] -> [([a], Int)] +s_permutations = flip zip (cycle [1, -1]) . s_perm + +main :: IO () +main = do + putStrLn "3 items:" + mapM_ print $ s_permutations [0..2] + putStrLn "4 items:" + mapM_ print $ s_permutations [0..3] diff --git a/Task/Permutations-by-swapping/J/permutations-by-swapping-1.j b/Task/Permutations-by-swapping/J/permutations-by-swapping-1.j new file mode 100644 index 0000000000..14eebb5caa --- /dev/null +++ b/Task/Permutations-by-swapping/J/permutations-by-swapping-1.j @@ -0,0 +1,4 @@ +bfsjt0=: _1 - i. +lookingat=: 0 >. <:@# <. i.@# + * +next=: | >./@:* | > | {~ lookingat +bfsjtn=: (((] <@, ] + *@{~) | i. next) C. ] * _1 ^ next < |)^:(*@next) diff --git a/Task/Permutations-by-swapping/J/permutations-by-swapping-2.j b/Task/Permutations-by-swapping/J/permutations-by-swapping-2.j new file mode 100644 index 0000000000..3dd98c94cf --- /dev/null +++ b/Task/Permutations-by-swapping/J/permutations-by-swapping-2.j @@ -0,0 +1,16 @@ + bfsjtn^:(i.!3) bfjt0 3 +_1 _2 _3 +_1 _3 _2 +_3 _1 _2 + 3 _2 _1 +_2 3 _1 +_2 _1 3 + <:@| bfsjtn^:(i.!3) bfjt0 3 +0 1 2 +0 2 1 +2 0 1 +2 1 0 +1 2 0 +1 0 2 + A. <:@| bfsjtn^:(i.!3) bfjt0 3 +0 1 4 5 3 2 diff --git a/Task/Permutations-by-swapping/J/permutations-by-swapping-3.j b/Task/Permutations-by-swapping/J/permutations-by-swapping-3.j new file mode 100644 index 0000000000..e89df2e55a --- /dev/null +++ b/Task/Permutations-by-swapping/J/permutations-by-swapping-3.j @@ -0,0 +1,7 @@ + (_1^2|i.!3),. bfsjtn^:(i.!3) bfjt0 3 + 1 _1 _2 _3 +_1 _1 _3 _2 + 1 _3 _1 _2 +_1 3 _2 _1 + 1 _2 3 _1 +_1 _2 _1 3 diff --git a/Task/Permutations-by-swapping/J/permutations-by-swapping-4.j b/Task/Permutations-by-swapping/J/permutations-by-swapping-4.j new file mode 100644 index 0000000000..efe9a4b8ce --- /dev/null +++ b/Task/Permutations-by-swapping/J/permutations-by-swapping-4.j @@ -0,0 +1,7 @@ + (,.~C.!.2)<:| bfsjtn^:(i.!3) bfjt0 3 + 1 0 1 2 +_1 0 2 1 + 1 2 0 1 +_1 2 1 0 + 1 1 2 0 +_1 1 0 2 diff --git a/Task/Permutations-by-swapping/J/permutations-by-swapping-5.j b/Task/Permutations-by-swapping/J/permutations-by-swapping-5.j new file mode 100644 index 0000000000..9774e25c58 --- /dev/null +++ b/Task/Permutations-by-swapping/J/permutations-by-swapping-5.j @@ -0,0 +1,5 @@ +rsjt=: 3 :0 + if. 2>y do. i.2#y + else. ((!y)$(,~|.)-.=i.y)#inv!.(y-1)"1 y#rsjt y-1 + end. +) diff --git a/Task/Permutations-by-swapping/J/permutations-by-swapping-6.j b/Task/Permutations-by-swapping/J/permutations-by-swapping-6.j new file mode 100644 index 0000000000..0499878c65 --- /dev/null +++ b/Task/Permutations-by-swapping/J/permutations-by-swapping-6.j @@ -0,0 +1,7 @@ + (,.~ C.!.2) rsjt 3 + 1 0 1 2 +_1 0 2 1 + 1 2 0 1 +_1 2 1 0 + 1 1 2 0 +_1 1 0 2 diff --git a/Task/Permutations-by-swapping/Mathematica/permutations-by-swapping-1.math b/Task/Permutations-by-swapping/Mathematica/permutations-by-swapping-1.math new file mode 100644 index 0000000000..5130da088f --- /dev/null +++ b/Task/Permutations-by-swapping/Mathematica/permutations-by-swapping-1.math @@ -0,0 +1,5 @@ +perms[0] = {{{}, 1}}; +perms[n_] := + Flatten[If[#2 == 1, Reverse, # &]@ + Table[{Insert[#1, n, i], (-1)^(n + i) #2}, {i, n}] & @@@ + perms[n - 1], 1]; diff --git a/Task/Permutations-by-swapping/Mathematica/permutations-by-swapping-2.math b/Task/Permutations-by-swapping/Mathematica/permutations-by-swapping-2.math new file mode 100644 index 0000000000..e4a30471b7 --- /dev/null +++ b/Task/Permutations-by-swapping/Mathematica/permutations-by-swapping-2.math @@ -0,0 +1 @@ +Print["Perm: ", #[[1]], " Sign: ", #[[2]]] & /@ perms@4; diff --git a/Task/Permutations-by-swapping/Perl-6/permutations-by-swapping.pl6 b/Task/Permutations-by-swapping/Perl-6/permutations-by-swapping.pl6 new file mode 100644 index 0000000000..0d0afdecb0 --- /dev/null +++ b/Task/Permutations-by-swapping/Perl-6/permutations-by-swapping.pl6 @@ -0,0 +1,12 @@ +sub insert($x, @xs) { [@xs[0..$_-1], $x, @xs[$_..*]] for 0..+@xs } +sub order($sg, @xs) { $sg > 0 ?? @xs !! @xs.reverse } + +multi perms([]) { + [] => +1 +} + +multi perms([$x, *@xs]) { + perms(@xs).map({ order($_.value, insert($x, $_.key)) }) Z=> (+1,-1) xx * +} + +.say for perms([0..2]); diff --git a/Task/Permutations-by-swapping/Python/permutations-by-swapping-1.py b/Task/Permutations-by-swapping/Python/permutations-by-swapping-1.py new file mode 100644 index 0000000000..99a3e22418 --- /dev/null +++ b/Task/Permutations-by-swapping/Python/permutations-by-swapping-1.py @@ -0,0 +1,60 @@ +from operator import itemgetter + +DEBUG = False # like the built-in __debug__ + +def spermutations(n): + """permutations by swapping. Yields: perm, sign""" + sign = 1 + p = [[i, 0 if i == 0 else -1] # [num, direction] + for i in range(n)] + + if DEBUG: print ' #', p + yield tuple(pp[0] for pp in p), sign + + while any(pp[1] for pp in p): # moving + i1, (n1, d1) = max(((i, pp) for i, pp in enumerate(p) if pp[1]), + key=itemgetter(1)) + sign *= -1 + if d1 == -1: + # Swap down + i2 = i1 - 1 + p[i1], p[i2] = p[i2], p[i1] + # If this causes the chosen element to reach the First or last + # position within the permutation, or if the next element in the + # same direction is larger than the chosen element: + if i2 == 0 or p[i2 - 1][0] > n1: + # The direction of the chosen element is set to zero + p[i2][1] = 0 + elif d1 == 1: + # Swap up + i2 = i1 + 1 + p[i1], p[i2] = p[i2], p[i1] + # If this causes the chosen element to reach the first or Last + # position within the permutation, or if the next element in the + # same direction is larger than the chosen element: + if i2 == n - 1 or p[i2 + 1][0] > n1: + # The direction of the chosen element is set to zero + p[i2][1] = 0 + if DEBUG: print ' #', p + yield tuple(pp[0] for pp in p), sign + + for i3, pp in enumerate(p): + n3, d3 = pp + if n3 > n1: + pp[1] = 1 if i3 < i2 else -1 + if DEBUG: print ' # Set Moving' + + +if __name__ == '__main__': + from itertools import permutations + + for n in (3, 4): + print '\nPermutations and sign of %i items' % n + sp = set() + for i in spermutations(n): + sp.add(i[0]) + print('Perm: %r Sign: %2i' % i) + #if DEBUG: raw_input('?') + # Test + p = set(permutations(range(n))) + assert sp == p, 'Two methods of generating permutations do not agree' diff --git a/Task/Permutations-by-swapping/Python/permutations-by-swapping-2.py b/Task/Permutations-by-swapping/Python/permutations-by-swapping-2.py new file mode 100644 index 0000000000..62be6af990 --- /dev/null +++ b/Task/Permutations-by-swapping/Python/permutations-by-swapping-2.py @@ -0,0 +1,19 @@ +def s_permutations(seq): + def s_perm(seq): + if not seq: + return [[]] + else: + new_items = [] + for i, item in enumerate(s_perm(seq[:-1])): + if i % 2: + # step up + new_items += [item[:i] + seq[-1:] + item[i:] + for i in range(len(item) + 1)] + else: + # step down + new_items += [item[:i] + seq[-1:] + item[i:] + for i in range(len(item), -1, -1)] + return new_items + + return [(tuple(item), -1 if i % 2 else 1) + for i, item in enumerate(s_perm(seq))] diff --git a/Task/Permutations-by-swapping/Python/permutations-by-swapping-3.py b/Task/Permutations-by-swapping/Python/permutations-by-swapping-3.py new file mode 100644 index 0000000000..e142cf54f0 --- /dev/null +++ b/Task/Permutations-by-swapping/Python/permutations-by-swapping-3.py @@ -0,0 +1,17 @@ +def s_permutations(seq): + items = [[]] + for j in seq: + new_items = [] + for i, item in enumerate(items): + if i % 2: + # step up + new_items += [item[:i] + [j] + item[i:] + for i in range(len(item) + 1)] + else: + # step down + new_items += [item[:i] + [j] + item[i:] + for i in range(len(item), -1, -1)] + items = new_items + + return [(tuple(item), -1 if i % 2 else 1) + for i, item in enumerate(items)] diff --git a/Task/Permutations-by-swapping/Tcl/permutations-by-swapping-1.tcl b/Task/Permutations-by-swapping/Tcl/permutations-by-swapping-1.tcl new file mode 100644 index 0000000000..53099db0d3 --- /dev/null +++ b/Task/Permutations-by-swapping/Tcl/permutations-by-swapping-1.tcl @@ -0,0 +1,50 @@ +# A simple swap operation +proc swap {listvar i1 i2} { + upvar 1 $listvar l + set tmp [lindex $l $i1] + lset l $i1 [lindex $l $i2] + lset l $i2 $tmp +} + +proc permswap {n v1 v2 body} { + upvar 1 $v1 perm $v2 sign + + # Initialize + set sign -1 + for {set i 0} {$i < $n} {incr i} { + lappend items $i + lappend dirs -1 + } + + while 1 { + # Report via callback + set perm $items + set sign [expr {-$sign}] + uplevel 1 $body + + # Find the largest mobile integer (lmi) and its index (idx) + set i [set idx -1] + foreach item $items dir $dirs { + set j [expr {[incr i] + $dir}] + if {$j < 0 || $j >= [llength $items]} continue + if {$item > [lindex $items $j] && ($idx == -1 || $item > $lmi)} { + set lmi $item + set idx $i + } + } + + # If none, we're done + if {$idx == -1} break + + # Swap the largest mobile integer with "what it is looking at" + set nextIdx [expr {$idx + [lindex $dirs $idx]}] + swap items $idx $nextIdx + swap dirs $idx $nextIdx + + # Reverse directions on larger integers + set i -1 + foreach item $items dir $dirs { + lset dirs [incr i] [expr {$item > $lmi ? -$dir : $dir}] + } + } +} diff --git a/Task/Permutations-by-swapping/Tcl/permutations-by-swapping-2.tcl b/Task/Permutations-by-swapping/Tcl/permutations-by-swapping-2.tcl new file mode 100644 index 0000000000..f6073b5566 --- /dev/null +++ b/Task/Permutations-by-swapping/Tcl/permutations-by-swapping-2.tcl @@ -0,0 +1,3 @@ +permswap 4 p s { + puts "$s\t$p" +} diff --git a/Task/Permutations-by-swapping/XPL0/permutations-by-swapping.xpl0 b/Task/Permutations-by-swapping/XPL0/permutations-by-swapping.xpl0 new file mode 100644 index 0000000000..7a4fd3e843 --- /dev/null +++ b/Task/Permutations-by-swapping/XPL0/permutations-by-swapping.xpl0 @@ -0,0 +1,36 @@ +include c:\cxpl\codes; + +proc PERMS(N); +int N; \number of elements +int I, K, S, T, P; +[P:= Reserve((N+1)*4); +for I:= 0 to N do P(I):= -I; \initialize facing left (also set P(0)=0) +S:= 1; +repeat Text(0, "Perm: [ "); + for I:= 1 to N do + [IntOut(0, abs(P(I))); ChOut(0, ^ )]; + Text(0, "] Sign: "); IntOut(0, S); CrLf(0); + + K:= 0; \find largest mobile element + for I:= 2 to N do \for left-facing elements + if P(I) < 0 and + abs(P(I)) > abs(P(I-1)) and \ greater than neighbor + abs(P(I)) > abs(P(K)) then K:= I; \ get largest element + for I:= 1 to N-1 do \for right-facing elements + if P(I) > 0 and + abs(P(I)) > abs(P(I+1)) and \ greater than neighbor + abs(P(I)) > abs(P(K)) then K:= I; \ get largest element + if K # 0 then \mobile element found + [for I:= 1 to N do \reverse elements > K + if abs(P(I)) > abs(P(K)) then P(I):= P(I)*-1; + I:= K + (if P(K)<0 then -1 else 1); + T:= P(K); P(K):= P(I); P(I):= T; \swap K with element looked at + S:= -S; \alternate signs + ]; +until K = 0; \no mobile element remains +]; + +[PERMS(3); +CrLf(0); +PERMS(4); +] diff --git a/Task/Permutations/0DESCRIPTION b/Task/Permutations/0DESCRIPTION new file mode 100644 index 0000000000..d4dcc2b6b9 --- /dev/null +++ b/Task/Permutations/0DESCRIPTION @@ -0,0 +1,4 @@ +Write a program that generates all [[wp:Permutation|permutations]] of '''n''' different objects. (Practically numerals!) +;Cf. +* [[Find the missing permutation]] +* [[Permutations/Derangements]] diff --git a/Task/Permutations/1META.yaml b/Task/Permutations/1META.yaml new file mode 100644 index 0000000000..9e130e8a7b --- /dev/null +++ b/Task/Permutations/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Discrete math diff --git a/Task/Permutations/ABAP/permutations.abap b/Task/Permutations/ABAP/permutations.abap new file mode 100644 index 0000000000..61d69a89b1 --- /dev/null +++ b/Task/Permutations/ABAP/permutations.abap @@ -0,0 +1,100 @@ +data: lv_flag type c, + lv_number type i, + lt_numbers type table of i. + +append 1 to lt_numbers. +append 2 to lt_numbers. +append 3 to lt_numbers. + +do. + perform permute using lt_numbers changing lv_flag. + if lv_flag = 'X'. + exit. + endif. + loop at lt_numbers into lv_number. + write (1) lv_number no-gap left-justified. + if sy-tabix <> '3'. + write ', '. + endif. + endloop. + skip. +enddo. + +" Permutation function - this is used to permute: +" Can be used for an unbounded size set. +form permute using iv_set like lt_numbers + changing ev_last type c. + data: lv_len type i, + lv_first type i, + lv_third type i, + lv_count type i, + lv_temp type i, + lv_temp_2 type i, + lv_second type i, + lv_changed type c, + lv_perm type i. + describe table iv_set lines lv_len. + + lv_perm = lv_len - 1. + lv_changed = ' '. + " Loop backwards through the table, attempting to find elements which + " can be permuted. If we find one, break out of the table and set the + " flag indicating a switch. + do. + if lv_perm <= 0. + exit. + endif. + " Read the elements. + read table iv_set index lv_perm into lv_first. + add 1 to lv_perm. + read table iv_set index lv_perm into lv_second. + subtract 1 from lv_perm. + if lv_first < lv_second. + lv_changed = 'X'. + exit. + endif. + subtract 1 from lv_perm. + enddo. + + " Last permutation. + if lv_changed <> 'X'. + ev_last = 'X'. + exit. + endif. + + " Swap tail decresing to get a tail increasing. + lv_count = lv_perm + 1. + do. + lv_first = lv_len + lv_perm - lv_count + 1. + if lv_count >= lv_first. + exit. + endif. + + read table iv_set index lv_count into lv_temp. + read table iv_set index lv_first into lv_temp_2. + modify iv_set index lv_count from lv_temp_2. + modify iv_set index lv_first from lv_temp. + add 1 to lv_count. + enddo. + + lv_count = lv_len - 1. + do. + if lv_count <= lv_perm. + exit. + endif. + + read table iv_set index lv_count into lv_first. + read table iv_set index lv_perm into lv_second. + read table iv_set index lv_len into lv_third. + if ( lv_first < lv_third ) and ( lv_first > lv_second ). + lv_len = lv_count. + endif. + + subtract 1 from lv_count. + enddo. + + read table iv_set index lv_perm into lv_temp. + read table iv_set index lv_len into lv_temp_2. + modify iv_set index lv_perm from lv_temp_2. + modify iv_set index lv_len from lv_temp. +endform. diff --git a/Task/Permutations/ALGOL-68/permutations-1.alg b/Task/Permutations/ALGOL-68/permutations-1.alg new file mode 100644 index 0000000000..53b680d214 --- /dev/null +++ b/Task/Permutations/ALGOL-68/permutations-1.alg @@ -0,0 +1,61 @@ +# Document prelude template usage: +TEMPLATE( + INT upb values := 4; + MODE VALUE = INT; + FORMAT value fmt := $g(0)$ +); # + +MODE + VALVALUES = [upb values]VALUE, VALUES = REF VALVALUES, + YIELDVALUES = PROC(VALUES)VOID; + +FORMAT + values fmt := $"("n(upb values-1)(f(value fmt)", ")f(value fmt)")"$; + +# Generate permutations of the input values of valueues # +PROC gen values permutations = (VALUES values, YIELDVALUES yield)VOID: ( +# Warning: this routine does not correctly handle duplicate elements # + IF LWB values = UPB values THEN + yield(values) + ELSE + FOR elem FROM LWB values TO UPB values DO + VALUE first = values[elem]; + values[LWB values+1:elem] := values[:elem-1]; + values[LWB values] := first; + # FOR VALUES next values IN # gen values permutations(values[LWB values+1:] # ) DO #, + ## (VALUES next)VOID:( + yield(values) + # OD #)); + values[:elem-1] := values[LWB values+1:elem]; + values[elem] := first + OD + FI +); + +############################################ +# Define some additional utility OPerators # +############################################ +PRIO P = 7; # OP to calculate number of permutations # +OP P = (INT n, k)INT: ( # n! OVER (n-k)! # + # ( n>k | n * ((n-1) P k) | n ); # + INT out := k; + FOR i FROM k+1 TO n DO out *:= i OD; + out +); + +# Define an operator for doing iterations over permutations # +PRIO DOPERM = 1; +OP (VALUES, YIELDVALUES)VOID DOPERM = gen values permutations; + +# Return an a matrix of permutations # +OP PERM = (VALUES in values)[, ]VALUE: ( + [(UPB in values-LWB in values+1) P 1, LWB in values:UPB in values]VALUE out; + INT elem := LWB out; + +# FOR VALUES values IN # in values DOPERM ( +## (VALUES values)VOID:( + out[elem, ] := values; + elem +:= 1 +# OD #)); + out +); diff --git a/Task/Permutations/ALGOL-68/permutations-2.alg b/Task/Permutations/ALGOL-68/permutations-2.alg new file mode 100644 index 0000000000..6303d83d8e --- /dev/null +++ b/Task/Permutations/ALGOL-68/permutations-2.alg @@ -0,0 +1,23 @@ +#!/usr/local/bin/a68g --script # + +PR READ "Template_Permutations.a68" PR # n.b. READ is nonstandard # +# USING( # + INT upb values := 4; + MODE VALUE = INT; # user defined # + FORMAT value fmt := $g(0)$ +# ) #; + +main:( + VALVALUES test case := (1, 22, 333, 44444); + print(("Number of permutations: ", UPB test case P 1, new line)); + +COMMENT # Use the generator: # + # FOR ARRAY values IN # test case DOPERM ( + ## (ARRAY values)VOID:( + printf((values fmt, values, $l$)) + # OD #)); +END COMMENT + +# or simply the operator: # + printf(($f(values fmt)l$, PERM test case)) +) diff --git a/Task/Permutations/Ada/permutations.ada b/Task/Permutations/Ada/permutations.ada new file mode 100644 index 0000000000..dd6c491a1c --- /dev/null +++ b/Task/Permutations/Ada/permutations.ada @@ -0,0 +1,113 @@ +-- perm.adb +-- print all permutations of 1 .. n +-- where n is given as a command line argument +-- to compile with GNAT : gnat make perm.adb +-- to call on command line : perm n +with Ada.Text_IO, Ada.Command_Line; + +procedure Perm is + use Ada.Text_IO, Ada.Command_Line; + N : Integer; +begin + if Argument_Count /= 1 + then + Put_Line (Command_Name & " n (with n >= 1)"); + return; + else + N := Integer'Value (Argument (1)); + end if; + declare + subtype Element is Integer range 1 .. N; + type Permutation is array (Element'Range) of Element; + P : Permutation; + Is_Last : Boolean := False; + + procedure Swap (A, B : in out Integer) is + C : Integer := A; + begin + A := B; + B := C; + end; + + -- compute next permutation in lexicographic order + -- iterative algorithm : + -- find longest tail-decreasing sequence in p + -- the elements from this tail cannot be permuted to get a new permutation, so + -- reverse this tail, to start from an increaing sequence, and + -- exchange the element x preceding the tail, with the minimum value in the tail, + -- that is also greater than x + procedure Next is + I, J, K : Element; + begin + -- find longest tail decreasing sequence + -- after the loop, this sequence is i+1 .. n, + -- and the ith element will be exchanged later + -- with some element of the tail + Is_Last := True; + I := N - 1; + loop + if P (I) < P (I+1) + then + Is_Last := False; + exit; + end if; + + -- next instruction will raise an exception if i = 1, so + -- exit now (this is the last permutation) + exit when I = 1; + I := I - 1; + end loop; + + -- if all the elements of the permutation are in + -- decreasing order, this is the last one + if Is_Last then + return; + end if; + + -- sort the tail, i.e. reverse it, since it is in decreasing order + J := I + 1; + K := N; + while J < K loop + Swap (P (J), P (K)); + J := J + 1; + K := K - 1; + end loop; + + -- find lowest element in the tail greater than the ith element + J := N; + while P (J) > P (I) loop + J := J - 1; + end loop; + J := J + 1; + + -- exchange them + -- this will give the next permutation in lexicographic order, + -- since every element from ith to the last is minimum + Swap (P (I), P (J)); + end next; + + procedure Print is + begin + for I in Element'Range loop + Put (Integer'Image (P (I))); + end loop; + New_Line; + end Print; + + -- initialize the permutation + procedure Init is + begin + for I in Element'Range loop + P (I) := I; + end loop; + end Init; + + begin + Init; + while not Is_Last loop + Print; + Next; + end loop; + end; + +end Perm; diff --git a/Task/Permutations/AutoHotkey/permutations.ahk b/Task/Permutations/AutoHotkey/permutations.ahk new file mode 100644 index 0000000000..e3702e1194 --- /dev/null +++ b/Task/Permutations/AutoHotkey/permutations.ahk @@ -0,0 +1,49 @@ +#NoEnv +StringCaseSense On + +o := str := "Hello" + +Loop +{ + str := perm_next(str) + If !str + { + MsgBox % clipboard := o + break + } + o.= "`n" . str +} + +perm_Next(str){ + p := 0, sLen := StrLen(str) + Loop % sLen + { + If A_Index=1 + continue + t := SubStr(str, sLen+1-A_Index, 1) + n := SubStr(str, sLen+2-A_Index, 1) + If ( t < n ) + { + p := sLen+1-A_Index, pC := SubStr(str, p, 1) + break + } + } + If !p + return false + Loop + { + t := SubStr(str, sLen+1-A_Index, 1) + If ( t > pC ) + { + n := sLen+1-A_Index, nC := SubStr(str, n, 1) + break + } + } + return SubStr(str, 1, p-1) . nC . Reverse(SubStr(str, p+1, n-p-1) . pC . SubStr(str, n+1)) +} + +Reverse(s){ + Loop Parse, s + o := A_LoopField o + return o +} diff --git a/Task/Permutations/BBC-BASIC/permutations.bbc b/Task/Permutations/BBC-BASIC/permutations.bbc new file mode 100644 index 0000000000..58615d322b --- /dev/null +++ b/Task/Permutations/BBC-BASIC/permutations.bbc @@ -0,0 +1,38 @@ + DIM List%(3) + List%() = 1, 2, 3, 4 + FOR perm% = 1 TO 24 + FOR i% = 0 TO DIM(List%(),1) + PRINT List%(i%); + NEXT + PRINT + PROC_NextPermutation(List%()) + NEXT + END + + DEF PROC_NextPermutation(A%()) + LOCAL first, last, elementcount, pos + elementcount = DIM(A%(),1) + IF elementcount < 1 THEN ENDPROC + pos = elementcount-1 + WHILE A%(pos) >= A%(pos+1) + pos -= 1 + IF pos < 0 THEN + PROC_Permutation_Reverse(A%(), 0, elementcount) + ENDPROC + ENDIF + ENDWHILE + last = elementcount + WHILE A%(last) <= A%(pos) + last -= 1 + ENDWHILE + SWAP A%(pos), A%(last) + PROC_Permutation_Reverse(A%(), pos+1, elementcount) + ENDPROC + + DEF PROC_Permutation_Reverse(A%(), first, last) + WHILE first < last + SWAP A%(first), A%(last) + first += 1 + last -= 1 + ENDWHILE + ENDPROC diff --git a/Task/Permutations/Bracmat/permutations.bracmat b/Task/Permutations/Bracmat/permutations.bracmat new file mode 100644 index 0000000000..2bb8c5653b --- /dev/null +++ b/Task/Permutations/Bracmat/permutations.bracmat @@ -0,0 +1,13 @@ + ( perm + = prefix List result original A Z + . !arg:(?.) + | !arg:(?prefix.?List:?original) + & :?result + & whl + ' ( !List:%?A ?Z + & !result perm$(!prefix !A.!Z):?result + & !Z !A:~!original:?List + ) + & !result + ) +& out$(perm$(.a 2 "]" u+z); diff --git a/Task/Permutations/C++/permutations.cpp b/Task/Permutations/C++/permutations.cpp new file mode 100644 index 0000000000..94cfdaff0f --- /dev/null +++ b/Task/Permutations/C++/permutations.cpp @@ -0,0 +1,40 @@ +#include +#include +#include +#include + +template +void print(const std::vector &vec) +{ + for (typename std::vector::const_iterator i = vec.begin(); i != vec.end(); ++i) + { + std::cout << *i; + if ((i + 1) != vec.end()) + std::cout << ","; + } + std::cout << std::endl; +} + +int main() +{ + //Permutations for strings + std::string example("Hello"); + std::sort(example.begin(), example.end()); + do { + std::cout << example << '\n'; + } while (std::next_permutation(example.begin(), example.end())); + + // And for vectors + std::vector another; + another.push_back(1234); + another.push_back(4321); + another.push_back(1234); + another.push_back(9999); + + std::sort(another.begin(), another.end()); + do { + print(another); + } while (std::next_permutation(another.begin(), another.end())); + + return 0; +} diff --git a/Task/Permutations/C/permutations.c b/Task/Permutations/C/permutations.c new file mode 100644 index 0000000000..771af27207 --- /dev/null +++ b/Task/Permutations/C/permutations.c @@ -0,0 +1,100 @@ +#include +#include + +/* print a list of ints */ +int show(int *x, int len) +{ + int i; + for (i = 0; i < len; i++) + printf("%d%c", x[i], i == len - 1 ? '\n' : ' '); + return 1; +} + +/* next lexicographical permutation */ +int next_lex_perm(int *a, int n) { +# define swap(i, j) {t = a[i]; a[i] = a[j]; a[j] = t;} + int k, l, t; + + /* 1. Find the largest index k such that a[k] < a[k + 1]. If no such + index exists, the permutation is the last permutation. */ + for (k = n - 1; k && a[k - 1] >= a[k]; k--); + if (!k--) return 0; + + /* 2. Find the largest index l such that a[k] < a[l]. Since k + 1 is + such an index, l is well defined */ + for (l = n - 1; a[l] <= a[k]; l--); + + /* 3. Swap a[k] with a[l] */ + swap(k, l); + + /* 4. Reverse the sequence from a[k + 1] to the end */ + for (k++, l = n - 1; l > k; l--, k++) + swap(k, l); + return 1; +# undef swap +} + +void perm1(int *x, int n, int callback(int *, int)) +{ + do { + if (callback) callback(x, n); + } while (next_lex_perm(x, n)); +} + +/* Boothroyd method; exactly N! swaps, about as fast as it gets */ +void boothroyd(int *x, int n, int nn, int callback(int *, int)) +{ + int c = 0, i, t; + while (1) { + if (n > 2) boothroyd(x, n - 1, nn, callback); + if (c >= n - 1) return; + + i = (n & 1) ? 0 : c; + c++; + t = x[n - 1], x[n - 1] = x[i], x[i] = t; + if (callback) callback(x, nn); + } +} + +/* entry for Boothroyd method */ +void perm2(int *x, int n, int callback(int*, int)) +{ + if (callback) callback(x, n); + boothroyd(x, n, n, callback); +} + +/* same as perm2, but flattened recursions into iterations */ +void perm3(int *x, int n, int callback(int*, int)) +{ + /* calloc isn't strictly necessary, int c[32] would suffice + for most practical purposes */ + int d, i, t, *c = calloc(n, sizeof(int)); + + /* curiously, with GCC 4.6.1 -O3, removing next line makes + it ~25% slower */ + if (callback) callback(x, n); + for (d = 1; ; c[d]++) { + while (d > 1) c[--d] = 0; + while (c[d] >= d) + if (++d >= n) goto done; + + t = x[ i = (d & 1) ? c[d] : 0 ], x[i] = x[d], x[d] = t; + if (callback) callback(x, n); + } +done: free(c); +} + +#define N 4 + +int main() +{ + int i, x[N]; + for (i = 0; i < N; i++) x[i] = i + 1; + + /* three different methods */ + perm1(x, N, show); + perm2(x, N, show); + perm3(x, N, show); + + return 0; +} diff --git a/Task/Permutations/Clojure/permutations.clj b/Task/Permutations/Clojure/permutations.clj new file mode 100644 index 0000000000..208db6d79f --- /dev/null +++ b/Task/Permutations/Clojure/permutations.clj @@ -0,0 +1,4 @@ +user=> (require 'clojure.contrib.combinatorics) +nil +user=> (clojure.contrib.combinatorics/permutations [1 2 3]) +((1 2 3) (1 3 2) (2 1 3) (2 3 1) (3 1 2) (3 2 1)) diff --git a/Task/Permutations/CoffeeScript/permutations-1.coffeescript b/Task/Permutations/CoffeeScript/permutations-1.coffeescript new file mode 100644 index 0000000000..eceab0f53e --- /dev/null +++ b/Task/Permutations/CoffeeScript/permutations-1.coffeescript @@ -0,0 +1,18 @@ +# Returns a copy of an array with the element at a specific position +# removed from it. +arrayExcept = (arr, idx) -> + res = arr[0..] + res.splice idx, 1 + res + +# The actual function which returns the permutations of an array-like +# object (or a proper array). +permute = (arr) -> + arr = Array::slice.call arr, 0 + return [[]] if arr.length == 0 + + permutations = (for value,idx in arr + [value].concat perm for perm in permute arrayExcept arr, idx) + + # Flatten the array before returning it. + [].concat permutations... diff --git a/Task/Permutations/CoffeeScript/permutations-2.coffeescript b/Task/Permutations/CoffeeScript/permutations-2.coffeescript new file mode 100644 index 0000000000..5848004d08 --- /dev/null +++ b/Task/Permutations/CoffeeScript/permutations-2.coffeescript @@ -0,0 +1,7 @@ +coffee> console.log (permute "123").join "\n" +1,2,3 +1,3,2 +2,1,3 +2,3,1 +3,1,2 +3,2,1 diff --git a/Task/Permutations/Common-Lisp/permutations-1.lisp b/Task/Permutations/Common-Lisp/permutations-1.lisp new file mode 100644 index 0000000000..acd2e169dd --- /dev/null +++ b/Task/Permutations/Common-Lisp/permutations-1.lisp @@ -0,0 +1,9 @@ +(defun permute (list) + (if list + (mapcan #'(lambda (x) + (mapcar #'(lambda (y) (cons x y)) + (permute (remove x list)))) + list) + '(()))) ; else + +(print (permute '(A B Z))) diff --git a/Task/Permutations/Common-Lisp/permutations-2.lisp b/Task/Permutations/Common-Lisp/permutations-2.lisp new file mode 100644 index 0000000000..3a736dd730 --- /dev/null +++ b/Task/Permutations/Common-Lisp/permutations-2.lisp @@ -0,0 +1,18 @@ +(defun next-perm (vec cmp) ; modify vector + (declare (type (simple-array * (*)) vec)) + (macrolet ((el (i) `(aref vec ,i)) + (cmp (i j) `(funcall cmp (el ,i) (el ,j)))) + (loop with len = (1- (length vec)) + for i from (1- len) downto 0 + when (cmp i (1+ i)) do + (loop for k from len downto i + when (cmp i k) do + (rotatef (el i) (el k)) + (setf k (1+ len)) + (loop while (< (incf i) (decf k)) do + (rotatef (el i) (el k))) + (return-from next-perm vec))))) + +;;; test code +(loop for a = "1234" then (next-perm a #'char<) while a do + (write-line a)) diff --git a/Task/Permutations/D/permutations-1.d b/Task/Permutations/D/permutations-1.d new file mode 100644 index 0000000000..78a76353f6 --- /dev/null +++ b/Task/Permutations/D/permutations-1.d @@ -0,0 +1,21 @@ +import std.stdio: writeln; + +T[][] permutations(T)(T[] items) { + T[][] result; + + void perms(T[] s, T[] prefix=[]) { + if (s.length) + foreach (i, c; s) + perms(s[0 .. i] ~ s[i+1 .. $], prefix ~ c); + else + result ~= prefix; + } + + perms(items); + return result; +} + +void main() { + foreach (p; permutations([1, 2, 3])) + writeln(p); +} diff --git a/Task/Permutations/D/permutations-2.d b/Task/Permutations/D/permutations-2.d new file mode 100644 index 0000000000..36916354f8 --- /dev/null +++ b/Task/Permutations/D/permutations-2.d @@ -0,0 +1,86 @@ +import std.algorithm, std.conv, std.traits; + +struct Permutations(bool doCopy=true, T) if (isMutable!T) { + private immutable size_t num; + private T[] items; + private uint[31] indexes; + private ulong tot; + + this (/*in*/ T[] items) /*pure nothrow*/ + in { + static enum string L = text(indexes.length); // impure + assert(items.length >= 0 && items.length <= indexes.length, + "Permutations: items.length must be >= 0 && < " ~ L); + } body { + static ulong factorial(in uint n) pure nothrow { + ulong result = 1; + foreach (i; 2 .. n + 1) + result *= i; + return result; + } + + this.num = items.length; + this.items = items.dup; + foreach (i; 0 .. cast(typeof(indexes[0]))this.num) + this.indexes[i] = i; + this.tot = factorial(this.num); + } + + @property T[] front() pure nothrow { + static if (doCopy) { + //return items.dup; // Not nothrow. + auto items2 = new T[items.length]; + items2[] = items[]; + return items2; + } else + return items; + } + + @property bool empty() const pure nothrow { + return tot == 0; + } + + void popFront() pure nothrow { + tot--; + if (tot > 0) { + size_t j = num - 2; + + while (indexes[j] > indexes[j + 1]) + j--; + size_t k = num - 1; + while (indexes[j] > indexes[k]) + k--; + swap(indexes[k], indexes[j]); + swap(items[k], items[j]); + + size_t r = num - 1; + size_t s = j + 1; + while (r > s) { + swap(indexes[s], indexes[r]); + swap(items[s], items[r]); + r--; + s++; + } + } + } +} + +Permutations!(doCopy,T) permutations(bool doCopy=true, T) + (/*in*/ T[] items) +/*pure nothrow*/ if (isMutable!T) { + return Permutations!(doCopy, T)(items); +} unittest { + import std.bigint; + foreach (p; permutations([BigInt(1), BigInt(2), BigInt(3)])) + assert((p[0] + 1) > 0); +} + +version (permutations2_main) { + void main() { + import std.stdio, std.bigint; + foreach (p; permutations!false([1, 2, 3])) + writeln(p); + alias BigInt B; + foreach (p; permutations!false([B(1), B(2), B(3)])) {} + } +} diff --git a/Task/Permutations/D/permutations-3.d b/Task/Permutations/D/permutations-3.d new file mode 100644 index 0000000000..a799b7c060 --- /dev/null +++ b/Task/Permutations/D/permutations-3.d @@ -0,0 +1,8 @@ +import std.stdio, std.algorithm; + +void main() { + auto items = [1, 2, 3]; + do + writeln(items); + while (items.nextPermutation()); +} diff --git a/Task/Permutations/Delphi/permutations.delphi b/Task/Permutations/Delphi/permutations.delphi new file mode 100644 index 0000000000..055ff8a566 --- /dev/null +++ b/Task/Permutations/Delphi/permutations.delphi @@ -0,0 +1,58 @@ +program TestPermutations; + +{$APPTYPE CONSOLE} + +type + TItem = Integer; // declare ordinal type for array item + TArray = array[0..3] of TItem; + +const + Source: TArray = (1, 2, 3, 4); + +procedure Permutation(K: Integer; var A: TArray); +var + I, J: Integer; + Tmp: TItem; + +begin + for I:= Low(A) + 1 to High(A) + 1 do begin + J:= K mod I; + Tmp:= A[J]; + A[J]:= A[I - 1]; + A[I - 1]:= Tmp; + K:= K div I; + end; +end; + +var + A: TArray; + I, K, Count: Integer; + S, S1, S2: ShortString; + +begin + Count:= 1; + I:= Length(A); + while I > 1 do begin + Count:= Count * I; + Dec(I); + end; + + S:= ''; + for K:= 0 to Count - 1 do begin + A:= Source; + Permutation(K, A); + S1:= ''; + for I:= Low(A) to High(A) do begin + Str(A[I]:1, S2); + S1:= S1 + S2; + end; + S:= S + ' ' + S1; + if Length(S) > 40 then begin + Writeln(S); + S:= ''; + end; + end; + + if Length(S) > 0 then Writeln(S); + Readln; +end. diff --git a/Task/Permutations/Erlang/permutations-1.erl b/Task/Permutations/Erlang/permutations-1.erl new file mode 100644 index 0000000000..b9fd5ef4b7 --- /dev/null +++ b/Task/Permutations/Erlang/permutations-1.erl @@ -0,0 +1,5 @@ +-module(permute). +-export([permute/1]). + +permute([]) -> [[]]; +permute(L) -> [[X|Y] || X<-L, Y<-permute(L--[X])]. diff --git a/Task/Permutations/Erlang/permutations-2.erl b/Task/Permutations/Erlang/permutations-2.erl new file mode 100644 index 0000000000..74bae199f4 --- /dev/null +++ b/Task/Permutations/Erlang/permutations-2.erl @@ -0,0 +1 @@ +F = fun(L) -> G = fun(_, []) -> [[]]; (F, L) -> [[X|Y] || X<-L, Y<-F(F, L--[X])] end, G(G, L) end. diff --git a/Task/Permutations/Erlang/permutations-3.erl b/Task/Permutations/Erlang/permutations-3.erl new file mode 100644 index 0000000000..5efbd00079 --- /dev/null +++ b/Task/Permutations/Erlang/permutations-3.erl @@ -0,0 +1,18 @@ +-module(permute). + +-export([permute/1]). + +permute([]) -> [[]]; +permute(L) -> zipper(L, [], []). + +% Use zipper to pick up first element of permutation +zipper([], _, Acc) -> lists:reverse(Acc); +zipper([H|T], R, Acc) -> + % place current member in front of all permutations + % of rest of set - both sides of zipper + prepend(H, permute(lists:reverse(R, T)), + % pass zipper state for continuation + T, [H|R], Acc). + +prepend(_, [], T, R, Acc) -> zipper(T, R, Acc); % continue in zipper +prepend(X, [H|T], ZT, ZR, Acc) -> prepend(X, T, ZT, ZR, [[X|H]|Acc]). diff --git a/Task/Permutations/Erlang/permutations-4.erl b/Task/Permutations/Erlang/permutations-4.erl new file mode 100644 index 0000000000..05d8e5a0ee --- /dev/null +++ b/Task/Permutations/Erlang/permutations-4.erl @@ -0,0 +1 @@ +main(_) -> io:fwrite("~p~n", [permute:permute([1,2,3])]). diff --git a/Task/Permutations/Euphoria/permutations.euphoria b/Task/Permutations/Euphoria/permutations.euphoria new file mode 100644 index 0000000000..df4f2377d7 --- /dev/null +++ b/Task/Permutations/Euphoria/permutations.euphoria @@ -0,0 +1,48 @@ +function reverse(sequence s, integer first, integer last) + object x + while first < last do + x = s[first] + s[first] = s[last] + s[last] = x + first += 1 + last -= 1 + end while + return s +end function + +function nextPermutation(sequence s) + integer pos, last + object x + if length(s) < 1 then + return 0 + end if + + pos = length(s)-1 + while compare(s[pos], s[pos+1]) >= 0 do + pos -= 1 + if pos < 1 then + return -1 + end if + end while + + last = length(s) + while compare(s[last], s[pos]) <= 0 do + last -= 1 + end while + x = s[pos] + s[pos] = s[last] + s[last] = x + + return reverse(s, pos+1, length(s)) +end function + +object s +s = "abcd" +puts(1, s & '\t') +while 1 do + s = nextPermutation(s) + if atom(s) then + exit + end if + puts(1, s & '\t') +end while diff --git a/Task/Permutations/Fortran/permutations-1.f b/Task/Permutations/Fortran/permutations-1.f new file mode 100644 index 0000000000..f297b77458 --- /dev/null +++ b/Task/Permutations/Fortran/permutations-1.f @@ -0,0 +1,33 @@ +program permutations + + implicit none + integer, parameter :: value_min = 1 + integer, parameter :: value_max = 3 + integer, parameter :: position_min = value_min + integer, parameter :: position_max = value_max + integer, dimension (position_min : position_max) :: permutation + + call generate (position_min) + +contains + + recursive subroutine generate (position) + + implicit none + integer, intent (in) :: position + integer :: value + + if (position > position_max) then + write (*, *) permutation + else + do value = value_min, value_max + if (.not. any (permutation (: position - 1) == value)) then + permutation (position) = value + call generate (position + 1) + end if + end do + end if + + end subroutine generate + +end program permutations diff --git a/Task/Permutations/Fortran/permutations-2.f b/Task/Permutations/Fortran/permutations-2.f new file mode 100644 index 0000000000..9aca8ed593 --- /dev/null +++ b/Task/Permutations/Fortran/permutations-2.f @@ -0,0 +1,41 @@ + program nptest + integer n,i,a + logical nextp + external nextp + parameter(n=4) + dimension a(n) + do i=1,n + a(i)=i + enddo + 10 print *,(a(i),i=1,n) + if(nextp(n,a)) go to 10 + end + + function nextp(n,a) + integer n,a,i,j,k,t + logical nextp + dimension a(n) + i=n-1 + 10 if(a(i).lt.a(i+1)) go to 20 + i=i-1 + if(i.eq.0) go to 20 + go to 10 + 20 j=i+1 + k=n + 30 t=a(j) + a(j)=a(k) + a(k)=t + j=j+1 + k=k-1 + if(j.lt.k) go to 30 + j=i + if(j.ne.0) go to 40 + nextp=.false. + return + 40 j=j+1 + if(a(j).lt.a(i)) go to 40 + t=a(i) + a(i)=a(j) + a(j)=t + nextp=.true. + end diff --git a/Task/Permutations/GAP/permutations-1.gap b/Task/Permutations/GAP/permutations-1.gap new file mode 100644 index 0000000000..65d7bf8b94 --- /dev/null +++ b/Task/Permutations/GAP/permutations-1.gap @@ -0,0 +1,6 @@ +gap>perms := n -> List(SymmetricGroup(n), p -> List([1..n], x -> x^p)); +perms(4); +[ [ 1, 2, 3, 4 ], [ 4, 2, 3, 1 ], [ 2, 4, 3, 1 ], [ 3, 2, 4, 1 ], [ 1, 4, 3, 2 ], [ 4, 1, 3, 2 ], [ 2, 1, 3, 4 ], + [ 3, 1, 4, 2 ], [ 1, 3, 4, 2 ], [ 4, 3, 1, 2 ], [ 2, 3, 1, 4 ], [ 3, 4, 1, 2 ], [ 1, 2, 4, 3 ], [ 4, 2, 1, 3 ], + [ 2, 4, 1, 3 ], [ 3, 2, 1, 4 ], [ 1, 4, 2, 3 ], [ 4, 1, 2, 3 ], [ 2, 1, 4, 3 ], [ 3, 1, 2, 4 ], [ 1, 3, 2, 4 ], + [ 4, 3, 2, 1 ], [ 2, 3, 4, 1 ], [ 3, 4, 2, 1 ] ] diff --git a/Task/Permutations/GAP/permutations-2.gap b/Task/Permutations/GAP/permutations-2.gap new file mode 100644 index 0000000000..e13d8cd5bf --- /dev/null +++ b/Task/Permutations/GAP/permutations-2.gap @@ -0,0 +1,4 @@ +# All arrangements of 4 elements in 1..4 +Arrangements([1..4], 4); +# All permutations of 1..4 +PermutationsList([1..4]); diff --git a/Task/Permutations/GAP/permutations-3.gap b/Task/Permutations/GAP/permutations-3.gap new file mode 100644 index 0000000000..3432a9446f --- /dev/null +++ b/Task/Permutations/GAP/permutations-3.gap @@ -0,0 +1,44 @@ +NextPermutation := function(a) + local i, j, k, n, t; + n := Length(a); + i := n - 1; + while i > 0 and a[i] > a[i + 1] do + i := i - 1; + od; + j := i + 1; + k := n; + while j < k do + t := a[j]; + a[j] := a[k]; + a[k] := t; + j := j + 1; + k := k - 1; + od; + if i = 0 then + return false; + else + j := i + 1; + while a[j] < a[i] do + j := j + 1; + od; + t := a[i]; + a[i] := a[j]; + a[j] := t; + return true; + fi; +end; + +Permutations := function(n) + local a, L; + a := List([1 .. n], x -> x); + L := [ ]; + repeat + Add(L, ShallowCopy(a)); + until not NextPermutation(a); + return L; +end; + +Permutations(3); +[ [ 1, 2, 3 ], [ 1, 3, 2 ], + [ 2, 1, 3 ], [ 2, 3, 1 ], + [ 3, 1, 2 ], [ 3, 2, 1 ] ] diff --git a/Task/Permutations/Go/permutations.go b/Task/Permutations/Go/permutations.go new file mode 100644 index 0000000000..1ab5f10d5c --- /dev/null +++ b/Task/Permutations/Go/permutations.go @@ -0,0 +1,52 @@ +package main + +import "fmt" + +func main() { + demoPerm(3) +} + +func demoPerm(n int) { + // create a set to permute. for demo, use the integers 1..n. + s := make([]int, n) + for i := range s { + s[i] = i + 1 + } + // permute them, calling a function for each permutation. + // for demo, function just prints the permutation. + permute(s, func(p []int) { fmt.Println(p) }) +} + +// permute function. takes a set to permute and a function +// to call for each generated permutation. +func permute(s []int, emit func([]int)) { + if len(s) == 0 { + emit(s) + return + } + // Steinhaus, implemented with a recursive closure. + // arg is number of positions left to permute. + // pass in len(s) to start generation. + // on each call, weave element at pp through the elements 0..np-2, + // then restore array to the way it was. + var rc func(int) + rc = func(np int) { + if np == 1 { + emit(s) + return + } + np1 := np - 1 + pp := len(s) - np1 + // weave + rc(np1) + for i := pp; i > 0; i-- { + s[i], s[i-1] = s[i-1], s[i] + rc(np1) + } + // restore + w := s[0] + copy(s, s[1:pp+1]) + s[pp] = w + } + rc(len(s)) +} diff --git a/Task/Permutations/Groovy/permutations-1.groovy b/Task/Permutations/Groovy/permutations-1.groovy new file mode 100644 index 0000000000..8ad640745e --- /dev/null +++ b/Task/Permutations/Groovy/permutations-1.groovy @@ -0,0 +1 @@ +def makePermutations = { l -> l.permutations() } diff --git a/Task/Permutations/Groovy/permutations-2.groovy b/Task/Permutations/Groovy/permutations-2.groovy new file mode 100644 index 0000000000..1c210efdaa --- /dev/null +++ b/Task/Permutations/Groovy/permutations-2.groovy @@ -0,0 +1,4 @@ +def list = ['Crosby', 'Stills', 'Nash', 'Young'] +def permutations = makePermutations(list) +assert permutations.size() == (1..<(list.size()+1)).inject(1) { prod, i -> prod*i } +permutations.each { println it } diff --git a/Task/Permutations/Haskell/permutations-1.hs b/Task/Permutations/Haskell/permutations-1.hs new file mode 100644 index 0000000000..6a8126759b --- /dev/null +++ b/Task/Permutations/Haskell/permutations-1.hs @@ -0,0 +1,3 @@ +import Data.List (permutations) + +main = mapM_ print (permutations [1,2,3]) diff --git a/Task/Permutations/Haskell/permutations-2.hs b/Task/Permutations/Haskell/permutations-2.hs new file mode 100644 index 0000000000..6738f2bb20 --- /dev/null +++ b/Task/Permutations/Haskell/permutations-2.hs @@ -0,0 +1,5 @@ +import Data.List (delete) + +permutations :: Eq a -> [a] -> [[a]] +permutations [] = [[]] +permutations xs = [ x:ys | x <- xs, ys <- permutations (delete x xs)] diff --git a/Task/Permutations/Haskell/permutations-3.hs b/Task/Permutations/Haskell/permutations-3.hs new file mode 100644 index 0000000000..63f9c1a41f --- /dev/null +++ b/Task/Permutations/Haskell/permutations-3.hs @@ -0,0 +1,5 @@ +permutations :: [a] -> [[a]] +permutations [] = [[]] +permutations xs = [ y:zs | (y,ys) <- select xs, zs <- permutations ys] + where select [] = [] + select (x:xs) = (x,xs) : [ (y,x:ys) | (y,ys) <- select xs ] diff --git a/Task/Permutations/Haskell/permutations-4.hs b/Task/Permutations/Haskell/permutations-4.hs new file mode 100644 index 0000000000..8f575fe872 --- /dev/null +++ b/Task/Permutations/Haskell/permutations-4.hs @@ -0,0 +1,5 @@ +permutations :: [a] -> [[a]] +permutations = foldr (concatMap . insertEverywhere) [[]] + where insertEverywhere :: a -> [a] -> [[a]] + insertEverywhere x [] = [[x]] + insertEverywhere x l@(y:ys) = (x:l) : map (y:) (insertEverywhere x ys) diff --git a/Task/Permutations/Icon/permutations.icon b/Task/Permutations/Icon/permutations.icon new file mode 100644 index 0000000000..2a21565585 --- /dev/null +++ b/Task/Permutations/Icon/permutations.icon @@ -0,0 +1,8 @@ +procedure main(A) + every p := permute(A) do every writes((!p||" ")|"\n") +end + +procedure permute(A) + if *A <= 1 then return A + suspend [(A[1]<->A[i := 1 to *A])] ||| permute(A[2:0]) +end diff --git a/Task/Permutations/J/permutations-1.j b/Task/Permutations/J/permutations-1.j new file mode 100644 index 0000000000..dbad3069a5 --- /dev/null +++ b/Task/Permutations/J/permutations-1.j @@ -0,0 +1 @@ +perms=: A.&i.~ ! diff --git a/Task/Permutations/J/permutations-2.j b/Task/Permutations/J/permutations-2.j new file mode 100644 index 0000000000..8c6690f44c --- /dev/null +++ b/Task/Permutations/J/permutations-2.j @@ -0,0 +1,10 @@ + perms 2 +0 1 +1 0 + ({~ perms@#)&.;: 'some random text' +some random text +some text random +random some text +random text some +text some random +text random some diff --git a/Task/Permutations/Java/permutations-1.java b/Task/Permutations/Java/permutations-1.java new file mode 100644 index 0000000000..57a9d20075 --- /dev/null +++ b/Task/Permutations/Java/permutations-1.java @@ -0,0 +1,83 @@ +public class PermutationGenerator { + private int[] array; + private int firstNum; + private boolean firstReady = false; + + public PermutationGenerator(int n, int firstNum_) { + if (n < 1) { + throw new IllegalArgumentException("The n must be min. 1"); + } + firstNum = firstNum_; + array = new int[n]; + reset(); + } + + public void reset() { + for (int i = 0; i < array.length; i++) { + array[i] = i + firstNum; + } + firstReady = false; + } + + public boolean hasMore() { + boolean end = firstReady; + for (int i = 1; i < array.length; i++) { + end = end && array[i] < array[i-1]; + } + return !end; + } + + public int[] getNext() { + + if (!firstReady) { + firstReady = true; + return array; + } + + int temp; + int j = array.length - 2; + int k = array.length - 1; + + // Find largest index j with a[j] < a[j+1] + + for (;array[j] > array[j+1]; j--); + + // Find index k such that a[k] is smallest integer + // greater than a[j] to the right of a[j] + + for (;array[j] > array[k]; k--); + + // Interchange a[j] and a[k] + + temp = array[k]; + array[k] = array[j]; + array[j] = temp; + + // Put tail end of permutation after jth position in increasing order + + int r = array.length - 1; + int s = j + 1; + + while (r > s) { + temp = array[s]; + array[s++] = array[r]; + array[r--] = temp; + } + + return array; + } // getNext() + + // For testing of the PermutationGenerator class + public static void main(String[] args) { + PermutationGenerator pg = new PermutationGenerator(3, 1); + + while (pg.hasMore()) { + int[] temp = pg.getNext(); + for (int i = 0; i < temp.length; i++) { + System.out.print(temp[i] + " "); + } + System.out.println(); + } + } + +} // class diff --git a/Task/Permutations/Java/permutations-2.java b/Task/Permutations/Java/permutations-2.java new file mode 100644 index 0000000000..7c335419a4 --- /dev/null +++ b/Task/Permutations/Java/permutations-2.java @@ -0,0 +1,5 @@ +public class Permutations { + public static void main(String[] args) { + System.out.println(Utils.Permutations(Utils.mRange(1, 3))); + } +} diff --git a/Task/Permutations/JavaScript/permutations.js b/Task/Permutations/JavaScript/permutations.js new file mode 100644 index 0000000000..30c6578a01 --- /dev/null +++ b/Task/Permutations/JavaScript/permutations.js @@ -0,0 +1,23 @@ +Permutations +

+
diff --git a/Task/Permutations/K/permutations.k b/Task/Permutations/K/permutations.k
new file mode 100644
index 0000000000..a8d45ed54b
--- /dev/null
+++ b/Task/Permutations/K/permutations.k
@@ -0,0 +1,12 @@
+   perm:{:[1:'(x,x)#1,x#0)[;0,'1+_f x-1];,!x]}
+   perm 2
+(0 1
+ 1 0)
+
+   `0:{1_,/" ",/:x}'r@perm@#r:("some";"random";"text")
+some random text
+some text random
+random some text
+random text some
+text some random
+text random some
diff --git a/Task/Permutations/Logtalk/permutations-1.logtalk b/Task/Permutations/Logtalk/permutations-1.logtalk
new file mode 100644
index 0000000000..cca4e1e4cb
--- /dev/null
+++ b/Task/Permutations/Logtalk/permutations-1.logtalk
@@ -0,0 +1,22 @@
+:- object(list).
+
+    :- public(permutation/2).
+
+    permutation(List, Permutation) :-
+        same_length(List, Permutation),
+        permutation2(List, Permutation).
+
+    permutation2([], []).
+    permutation2(List, [Head| Tail]) :-
+        select(Head, List, Remaining),
+        permutation2(Remaining, Tail).
+
+    same_length([], []).
+    same_length([_| Tail1], [_| Tail2]) :-
+        same_length(Tail1, Tail2).
+
+    select(Head, [Head| Tail], Tail).
+    select(Head, [Head2| Tail], [Head2| Tail2]) :-
+        select(Head, Tail, Tail2).
+
+:- end_object.
diff --git a/Task/Permutations/Logtalk/permutations-2.logtalk b/Task/Permutations/Logtalk/permutations-2.logtalk
new file mode 100644
index 0000000000..7620228683
--- /dev/null
+++ b/Task/Permutations/Logtalk/permutations-2.logtalk
@@ -0,0 +1,9 @@
+| ?- forall(list::permutation([1, 2, 3], Permutation), (write(Permutation), nl)).
+
+[1,2,3]
+[1,3,2]
+[2,1,3]
+[2,3,1]
+[3,1,2]
+[3,2,1]
+yes
diff --git a/Task/Permutations/Lua/permutations.lua b/Task/Permutations/Lua/permutations.lua
new file mode 100644
index 0000000000..0bf7dbee0e
--- /dev/null
+++ b/Task/Permutations/Lua/permutations.lua
@@ -0,0 +1,17 @@
+local function permutation(a, n, cb)
+	if n == 0 then
+		cb(a)
+	else
+		for i = 1, n do
+			a[i], a[n] = a[n], a[i]
+			permutation(a, n - 1, cb)
+			a[i], a[n] = a[n], a[i]
+		end
+	end
+end
+
+--Usage
+local function callback(a)
+	print('{'..table.concat(a, ', ')..'}')
+end
+permutation({1,2,3}, 3, callback)
diff --git a/Task/Permutations/Maple/permutations.maple b/Task/Permutations/Maple/permutations.maple
new file mode 100644
index 0000000000..143807af2d
--- /dev/null
+++ b/Task/Permutations/Maple/permutations.maple
@@ -0,0 +1,5 @@
+> combinat:-permute( 3 );
+   [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
+
+> combinat:-permute( [a,b,c] );
+   [[a, b, c], [a, c, b], [b, a, c], [b, c, a], [c, a, b], [c, b, a]]
diff --git a/Task/Permutations/Mathematica/permutations.math b/Task/Permutations/Mathematica/permutations.math
new file mode 100644
index 0000000000..5e4580c752
--- /dev/null
+++ b/Task/Permutations/Mathematica/permutations.math
@@ -0,0 +1 @@
+Permutations[{1,2,3,4}]
diff --git a/Task/Permutations/Maxima/permutations-1.maxima b/Task/Permutations/Maxima/permutations-1.maxima
new file mode 100644
index 0000000000..a83212b686
--- /dev/null
+++ b/Task/Permutations/Maxima/permutations-1.maxima
@@ -0,0 +1,24 @@
+next_permutation(v) := block([n, i, j, k, t],
+   n: length(v), i: 0,
+   for k: n - 1 thru 1 step -1 do (if v[k] < v[k + 1] then (i: k, return())),
+   j: i + 1, k: n,
+   while j < k do (t: v[j], v[j]: v[k], v[k]: t, j: j + 1, k: k - 1),
+   if i = 0 then return(false),
+   j: i + 1,
+   while v[j] < v[i] do j: j + 1,
+   t: v[j], v[j]: v[i], v[i]: t,
+   true
+)$
+
+print_perm(n) := block([v: makelist(i, i, 1, n)],
+   disp(v),
+   while next_permutation(v) do disp(v)
+)$
+
+print_perm(3);
+/* [1, 2, 3]
+   [1, 3, 2]
+   [2, 1, 3]
+   [2, 3, 1]
+   [3, 1, 2]
+   [3, 2, 1] */
diff --git a/Task/Permutations/Maxima/permutations-2.maxima b/Task/Permutations/Maxima/permutations-2.maxima
new file mode 100644
index 0000000000..5831b034bc
--- /dev/null
+++ b/Task/Permutations/Maxima/permutations-2.maxima
@@ -0,0 +1,2 @@
+(%i1) permutations([1, 2, 3]);
+(%o1) {[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]}
diff --git a/Task/Permutations/OCaml/permutations-1.ocaml b/Task/Permutations/OCaml/permutations-1.ocaml
new file mode 100644
index 0000000000..0595b57eea
--- /dev/null
+++ b/Task/Permutations/OCaml/permutations-1.ocaml
@@ -0,0 +1,45 @@
+(* Iterative, though loops are implemented as auxiliary recursive functions.
+   Translation of Ada version. *)
+let next_perm p =
+	let n = Array.length p in
+	let i = let rec aux i =
+		if (i < 0) || (p.(i) < p.(i+1)) then i
+		else aux (i - 1) in aux (n - 2) in
+	let rec aux j k = if j < k then
+		let t = p.(j) in
+			p.(j) <- p.(k);
+			p.(k) <- t;
+			aux (j + 1) (k - 1)
+	else () in aux (i + 1) (n - 1);
+	if i < 0 then false else
+		let j = let rec aux j =
+			if p.(j) > p.(i) then j
+			else aux (j + 1) in aux (i + 1) in
+		let t = p.(i) in
+			p.(i) <- p.(j);
+			p.(j) <- t;
+			true;;
+
+let print_perm p =
+	let n = Array.length p in
+	for i = 0 to n - 2 do
+		print_int p.(i);
+		print_string " "
+	done;
+	print_int p.(n - 1);
+	print_newline ();;
+
+let print_all_perm n =
+	let p = Array.init n (function i -> i + 1) in
+	print_perm p;
+	while next_perm p do
+		print_perm p
+	done;;
+
+print_all_perm 3;;
+(* 1 2 3
+   1 3 2
+   2 1 3
+   2 3 1
+   3 1 2
+   3 2 1 *)
diff --git a/Task/Permutations/OCaml/permutations-2.ocaml b/Task/Permutations/OCaml/permutations-2.ocaml
new file mode 100644
index 0000000000..19b76e9552
--- /dev/null
+++ b/Task/Permutations/OCaml/permutations-2.ocaml
@@ -0,0 +1,15 @@
+let rec permutations l =
+   let n = List.length l in
+   if n = 1 then [l] else
+   let rec sub e = function
+      | [] -> failwith "sub"
+      | h :: t -> if h = e then t else h :: sub e t in
+   let rec aux k =
+      let e = List.nth l k in
+      let subperms = permutations (sub e l) in
+      let t = List.map (fun a -> e::a) subperms in
+      if k < n-1 then List.rev_append t (aux (k+1)) else t in
+   aux 0;;
+
+let print l = List.iter (Printf.printf " %d") l; print_newline() in
+List.iter print (permutations [1;2;3;4])
diff --git a/Task/Permutations/OCaml/permutations-3.ocaml b/Task/Permutations/OCaml/permutations-3.ocaml
new file mode 100644
index 0000000000..56bcadb2b5
--- /dev/null
+++ b/Task/Permutations/OCaml/permutations-3.ocaml
@@ -0,0 +1,17 @@
+let rec pr_perm k n l =
+   let a, b = let c = k/n in c, k-(n*c) in
+   let e = List.nth l b in
+   let rec sub e = function
+      | [] -> failwith "sub"
+      | h :: t -> if h = e then t else h :: sub e t in
+   (Printf.printf " %d" e; if n > 1 then pr_perm a (n-1) (sub e l))
+
+let show_perms l =
+   let n = List.length l in
+   let rec fact n = if n < 3 then n else n * fact (n-1) in
+   for i = 0 to (fact n)-1 do
+      pr_perm i n l;
+      print_newline()
+   done
+
+let () = show_perms [1;2;3;4]
diff --git a/Task/Permutations/PARI-GP/permutations.pari b/Task/Permutations/PARI-GP/permutations.pari
new file mode 100644
index 0000000000..28aa61da83
--- /dev/null
+++ b/Task/Permutations/PARI-GP/permutations.pari
@@ -0,0 +1 @@
+vector(n!,k,numtoperm(n,k))
diff --git a/Task/Permutations/Pascal/permutations.pascal b/Task/Permutations/Pascal/permutations.pascal
new file mode 100644
index 0000000000..195c1d319e
--- /dev/null
+++ b/Task/Permutations/Pascal/permutations.pascal
@@ -0,0 +1,71 @@
+program perm;
+
+var
+	p: array[1 .. 12] of integer;
+	is_last: boolean;
+	n: integer;
+
+procedure next;
+var i, j, k, t: integer;
+begin
+is_last := true;
+i := n - 1;
+while i > 0 do
+	begin
+	if p[i] < p[i + 1] then
+		begin
+		is_last := false;
+		break;
+		end;
+	i := i - 1;
+	end;
+
+if not is_last then
+	begin
+	j := i + 1;
+	k := n;
+	while j < k do
+		begin
+		t := p[j];
+		p[j] := p[k];
+		p[k] := t;
+		j := j + 1;
+		k := k - 1;
+		end;
+		
+	j := n;
+	while p[j] > p[i] do j := j - 1;
+	j := j + 1;
+
+	t := p[i];
+	p[i] := p[j];
+	p[j] := t;
+	end;
+end;
+
+procedure print;
+var i: integer;
+begin
+for i := 1 to n do write(p[i], ' ');
+writeln;
+end;
+
+procedure init;
+var i: integer;
+begin
+n := 0;
+while (n < 1) or (n > 10) do
+	begin
+	write('Enter n (1 <= n <= 10): ');
+	readln(n);
+	end;
+for i := 1 to n do p[i] := i;
+end;
+
+begin
+init;
+repeat
+	print;
+	next;
+until is_last;
+end.
diff --git a/Task/Permutations/Perl-6/permutations-1.pl6 b/Task/Permutations/Perl-6/permutations-1.pl6
new file mode 100644
index 0000000000..656677f74d
--- /dev/null
+++ b/Task/Permutations/Perl-6/permutations-1.pl6
@@ -0,0 +1,8 @@
+sub postfix:(@a) {
+    @a == 1 ?? [@a] !!
+    gather for @a -> $a {
+        take [ $a, @$_ ] for @a.grep(none $a)!
+    }
+}
+
+.say for 
! diff --git a/Task/Permutations/Perl-6/permutations-2.pl6 b/Task/Permutations/Perl-6/permutations-2.pl6 new file mode 100644 index 0000000000..3d53900fee --- /dev/null +++ b/Task/Permutations/Perl-6/permutations-2.pl6 @@ -0,0 +1,16 @@ +sub next_perm ( @a is copy ) { + my $j = @a.end - 1; + return Nil if --$j < 0 while @a[$j] after @a[$j+1]; + + my $aj = @a[$j]; + my $k = @a.end; + $k-- while $aj after @a[$k]; + @a[ $j, $k ] .= reverse; + + my $r = @a.end; + my $s = $j + 1; + @a[ $r--, $s++ ] .= reverse while $r > $s; + return $(@a); +} + +.say for [], &next_perm ...^ !*; diff --git a/Task/Permutations/Perl/permutations.pl b/Task/Permutations/Perl/permutations.pl new file mode 100644 index 0000000000..f8b8ea4319 --- /dev/null +++ b/Task/Permutations/Perl/permutations.pl @@ -0,0 +1,8 @@ +# quick and dirty recursion +sub permutation(){ + my ($perm,@set) = @_; + print "$perm\n" || return unless (@set); + &permutation($perm.$set[$_],@set[0..$_-1],@set[$_+1..$#set]) foreach (0..$#set); +} +@input = (a,2,c,4); +&permutation('',@input); diff --git a/Task/Permutations/PicoLisp/permutations.l b/Task/Permutations/PicoLisp/permutations.l new file mode 100644 index 0000000000..6b5c24e5bf --- /dev/null +++ b/Task/Permutations/PicoLisp/permutations.l @@ -0,0 +1,3 @@ +(load "@lib/simul.l") + +(permute (1 2 3)) diff --git a/Task/Permutations/PowerBASIC/permutations.powerbasic b/Task/Permutations/PowerBASIC/permutations.powerbasic new file mode 100644 index 0000000000..615eeb87c6 --- /dev/null +++ b/Task/Permutations/PowerBASIC/permutations.powerbasic @@ -0,0 +1,26 @@ +defint a-z +option base 1 +input "n=",n +dim a(n) +for i=1 to n: a(i)=i: next +do + for i=1 to n: print a(i);: next: print + i=n + do + decr i + loop until i=0 or a(i)0 then + j=i+1 + while a(j)= cur(pos + 1) + pos - 1 + If pos < 0 + reverse(0, elementCount) + ProcedureReturn #False ;no higher lexicographic permutations left, return lowest one instead + EndIf + Wend + + ;Swap [pos] with the highest positional value that is larger than [pos] + last = elementCount + While cur(last) <= cur(pos) + last - 1 + Wend + Swap cur(pos), cur(last) + + ;Reverse the order of the elements in the higher positions + reverse(pos + 1, elementCount) + ProcedureReturn #True ;next lexicographic permutation found +EndProcedure + +Procedure display(Array a(1)) + Protected i, fin = ArraySize(a()) + For i = 0 To fin + Print(Str(a(i))) + If i = fin: Continue: EndIf + Print(", ") + Next + PrintN("") +EndProcedure + +If OpenConsole() + Dim a(2) + a(0) = 1: a(1) = 2: a(2) = 3 + display(a()) + While nextPermutation(a()): display(a()): Wend + + Print(#CRLF$ + #CRLF$ + "Press ENTER to exit"): Input() + CloseConsole() +EndIf diff --git a/Task/Permutations/Python/permutations.py b/Task/Permutations/Python/permutations.py new file mode 100644 index 0000000000..7ec9832c0d --- /dev/null +++ b/Task/Permutations/Python/permutations.py @@ -0,0 +1,3 @@ +import itertools +for values in itertools.permutations([1,2,3]): + print (values) diff --git a/Task/Permutations/Qi/permutations.qi b/Task/Permutations/Qi/permutations.qi new file mode 100644 index 0000000000..81de06643c --- /dev/null +++ b/Task/Permutations/Qi/permutations.qi @@ -0,0 +1,19 @@ +(define insert + L 0 E -> [E|L] + [L|Ls] N E -> [L|(insert Ls (- N 1) E)]) + +(define seq + Start Start -> [Start] + Start End -> [Start|(seq (+ Start 1) End)]) + +(define append-lists + [] -> [] + [A|B] -> (append A (append-lists B))) + +(define permutate + [] -> [[]] + [H|T] -> (append-lists (map (/. P + (map (/. N + (insert P N H)) + (seq 0 (length P)))) + (permute T)))) diff --git a/Task/Permutations/R/permutations.r b/Task/Permutations/R/permutations.r new file mode 100644 index 0000000000..52b6245e00 --- /dev/null +++ b/Task/Permutations/R/permutations.r @@ -0,0 +1,48 @@ +next.perm <- function(p) { + n <- length(p) + i <- n - 1 + r = TRUE + for(i in (n-1):1) { + if(p[i] < p[i+1]) { + r = FALSE + break + } + } + + j <- i + 1 + k <- n + while(j < k) { + x <- p[j] + p[j] <- p[k] + p[k] <- x + j <- j + 1 + k <- k - 1 + } + + if(r) return(NULL) + + j <- n + while(p[j] > p[i]) j <- j - 1 + j <- j + 1 + + x <- p[i] + p[i] <- p[j] + p[j] <- x + return(p) +} + +print.perms <- function(n) { + p <- 1:n + while(!is.null(p)) { + cat(p,"\n") + p <- next.perm(p) + } +} + +print.perms(3) +# 1 2 3 +# 1 3 2 +# 2 1 3 +# 2 3 1 +# 3 1 2 +# 3 2 1 diff --git a/Task/Permutations/REXX/permutations-1.rexx b/Task/Permutations/REXX/permutations-1.rexx new file mode 100644 index 0000000000..5cb27250d5 --- /dev/null +++ b/Task/Permutations/REXX/permutations-1.rexx @@ -0,0 +1,34 @@ +/*REXX program generates all permutations of N different objects. */ +parse arg things bunch inbetweenChars names + + /* inbetweenChars (optional) defaults to a [null]. */ + /* names (optional) defaults to digits (and letters). */ + +call permSets things,bunch,inbetweenChars,names +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────.PERMSET subroutine─────────────────*/ +.permset: procedure expose (list); parse arg ? +if ?>y then do; _=@.1; do j=2 to y; _=_||between||@.j; end; say _; end + else do q=1 for x /*build permutation recursively. */ + do k=1 for ?-1; if @.k==$.q then iterate q; end /*k*/ + @.?=$.q; call .permset ?+1 + end /*q*/ +return +/*──────────────────────────────────PERMSETS subroutine─────────────────*/ +permSets: procedure; parse arg x,y,between,uSyms /*X things Y at a time.*/ +@.=; sep= /*X can't be > length(@0abcs). */ +@abc = 'abcdefghijklmnopqrstuvwxyz'; @abcU=@abc; upper @abcU +@abcS = @abcU || @abc; @0abcS=123456789 || @abcS + + do k=1 for x /*build a list of (perm) symbols.*/ + _=p(word(uSyms,k) p(substr(@0abcS,k,1) k)) /*get|generate a symbol.*/ + if length(_)\==1 then sep='_' /*if not 1st char, then use sep. */ + $.k=_ /*append it to the symbol list. */ + end + +if between=='' then between=sep /*use the appropriate separator. */ +list='$. @. between x y' +call .permset 1 +return +/*──────────────────────────────────P subroutine (Pick one)─────────────*/ +p: return word(arg(1),1) diff --git a/Task/Permutations/REXX/permutations-2.rexx b/Task/Permutations/REXX/permutations-2.rexx new file mode 100644 index 0000000000..3e4eef2f40 --- /dev/null +++ b/Task/Permutations/REXX/permutations-2.rexx @@ -0,0 +1,22 @@ +/*REXX program shows permutations of '''N''' number of objects (1,2,3, ...).*/ +parse arg n .; if n=='' then n=3 /*Not specified? Assume default*/ + /*populate the first permutation.*/ + do pop=1 for n; @.pop=pop ; end; call tell n + + do while nextperm(n,0); call tell n; end +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────NEXTPERM subroutine─────────────────*/ +nextperm: procedure expose @.; parse arg n,i; nm=n-1 + + do k=nm by -1 for nm; kp=k+1 + if @.k<@.kp then do; i=k; leave; end + end /*k*/ + + do j=i+1 while j 0 && copy[j] >= copy[j+1] + if copy[j] < copy[j+1] + l = size - 1 + l -= 1 while copy[j] >= copy[l] + copy[j] , copy[l] = copy[l] , copy[j] + copy[j+1..-1] = copy[j+1..-1].reverse + yield copy.dup + else + break + end + end + end +end + +permutations = [] +[1,1,2].distinct_permutation do |p| permutations << p end +p permutations +# => [[1, 1, 2], [1, 2, 1], [2, 1, 1]] + +if RUBY_VERSION >= "1.8.7" + p [1,1,2].distinct_permutation.to_a + # => [[1, 1, 2], [1, 2, 1], [2, 1, 1]] +end diff --git a/Task/Permutations/Run-BASIC/permutations.run b/Task/Permutations/Run-BASIC/permutations.run new file mode 100644 index 0000000000..4d96f9b7b5 --- /dev/null +++ b/Task/Permutations/Run-BASIC/permutations.run @@ -0,0 +1,25 @@ +list$ = "h,e,l,l,o" ' supply list seperated with comma's + +while word$(list$,d+1,",") <> "" 'Count how many in the list +d = d + 1 +wend + +dim theList$(d) ' place list in array +for i = 1 to d + theList$(i) = word$(list$,i,",") +next i + +for i = 1 to d ' print the Permutations + for j = 2 to d + perm$ = "" + for k = 1 to d + perm$ = perm$ + theList$(k) + next k + if instr(perms$,perm$+",") = 0 then print perm$ ' only list 1 time + perms$ = perms$ + perm$ + "," + h$ = theList$(j) + theList$(j) = theList$(j - 1) + theList$(j-1) = h$ + next j +next i +end diff --git a/Task/Permutations/SAS/permutations.sas b/Task/Permutations/SAS/permutations.sas new file mode 100644 index 0000000000..5d0ae588b2 --- /dev/null +++ b/Task/Permutations/SAS/permutations.sas @@ -0,0 +1,42 @@ +/* Store permutations in a SAS dataset. Translation of Fortran 77 */ +data perm; +n=6; +array a{6} p1-p6; +do i=1 to n; +a(i)=i; +end; +L1: +output; +link L2; +if next then goto L1; +stop; +L2: +next=0; +i=n-1; +L10: +if a(i) (vector-ref p j) (vector-ref p i)) j (aux (+ j 1))))) + #t)))) + +(define (print-perm p) +(let ((n (vector-length p))) +(do ((i 0 (+ i 1))) ((= i n)) (display (vector-ref p i)) (display " ")) +(newline))) + +(define (print-all-perm n) +(let ((p (make-vector n))) +(do ((i 0 (+ i 1))) ((= i n)) (vector-set! p i i)) +(print-perm p) +(do ( ) ((not (next-perm p))) (print-perm p)))) + +(print-all-perm 3) +; 0 1 2 +; 0 2 1 +; 1 0 2 +; 1 2 0 +; 2 0 1 +; 2 1 0 + +;a more recursive implementation +(define (permute p i) +(let ((n (vector-length p))) +(if (= i (- n 1)) (print-perm p) +(begin + (do ((j i (+ j 1))) ((= j n)) + (vector-swap! p i j) + (permute p (+ i 1))) + (do ((j (- n 1) (- j 1))) ((< j i)) + (vector-swap! p i j)))))) + + +(define (print-all-perm-rec n) +(let ((p (make-vector n))) +(do ((i 0 (+ i 1))) ((= i n)) (vector-set! p i i)) +(permute p 0))) + +(print-all-perm-rec 3) +; 0 1 2 +; 0 2 1 +; 1 0 2 +; 1 2 0 +; 2 0 1 +; 2 1 0 diff --git a/Task/Permutations/Scheme/permutations-3.ss b/Task/Permutations/Scheme/permutations-3.ss new file mode 100644 index 0000000000..dedbab771e --- /dev/null +++ b/Task/Permutations/Scheme/permutations-3.ss @@ -0,0 +1,11 @@ +(define (perm s) + (cond ((null? s) '()) + ((null? (cdr s)) (list s)) + (else ;; extract each item in list in turn and perm the rest + (let splice ((l '()) (m (car s)) (r (cdr s))) + (append + (map (lambda (x) (cons m x)) (perm (append l r))) + (if (null? r) '() + (splice (cons m l) (car r) (cdr r)))))))) + +(display (perm '(1 2 3))) diff --git a/Task/Permutations/Seed7/permutations.seed7 b/Task/Permutations/Seed7/permutations.seed7 new file mode 100644 index 0000000000..66137c4568 --- /dev/null +++ b/Task/Permutations/Seed7/permutations.seed7 @@ -0,0 +1,37 @@ +$ include "seed7_05.s7i"; + +const type: permutations is array array integer; + +const func permutations: permutations (in array integer: items) is func + result + var permutations: permsList is 0 times 0 times 0; + local + const proc: perms (in array integer: sequence, in array integer: prefix) is func + local + var integer: element is 0; + var integer: index is 0; + begin + if length(sequence) <> 0 then + for element key index range sequence do + perms(sequence[.. pred(index)] & sequence[succ(index) ..], prefix & [] (element)); + end for; + else + permsList &:= prefix; + end if; + end func; + begin + perms(items, 0 times 0); + end func; + +const proc: main is func + local + var array integer: perm is 0 times 0; + var integer: element is 0; + begin + for perm range permutations([] (1, 2, 3)) do + for element range perm do + write(element <& " "); + end for; + writeln; + end for; + end func; diff --git a/Task/Permutations/Smalltalk/permutations.st b/Task/Permutations/Smalltalk/permutations.st new file mode 100644 index 0000000000..8c69edd2e0 --- /dev/null +++ b/Task/Permutations/Smalltalk/permutations.st @@ -0,0 +1,2 @@ +(1 to: 4) permutationsDo: [ :x | + Transcript show: x printString; cr ]. diff --git a/Task/Permutations/Tcl/permutations.tcl b/Task/Permutations/Tcl/permutations.tcl new file mode 100644 index 0000000000..41e96bd8f2 --- /dev/null +++ b/Task/Permutations/Tcl/permutations.tcl @@ -0,0 +1,10 @@ +package require struct::list + +# Make the sequence of digits to be permuted +set n [lindex $argv 0] +for {set i 1} {$i <= $n} {incr i} {lappend sequence $i} + +# Iterate over the permutations, printing as we go +struct::list foreachperm p $sequence { + puts $p +} diff --git a/Task/Permutations/Ursala/permutations-1.ursala b/Task/Permutations/Ursala/permutations-1.ursala new file mode 100644 index 0000000000..94d38629a5 --- /dev/null +++ b/Task/Permutations/Ursala/permutations-1.ursala @@ -0,0 +1,9 @@ +#import std + +permutations = + +~&itB^?a( # are both the input argument list and its tail non-empty? + @ahPfatPRD *= refer ^C( # yes, recursively generate all permutations of the tail, and for each one + ~&a, # insert the head at the first position + ~&ar&& ~&arh2falrtPXPRD), # if the rest is non-empty, recursively insert at all subsequent positions + ~&aNC) # no, return the singleton list of the argument diff --git a/Task/Permutations/Ursala/permutations-2.ursala b/Task/Permutations/Ursala/permutations-2.ursala new file mode 100644 index 0000000000..c5cba80647 --- /dev/null +++ b/Task/Permutations/Ursala/permutations-2.ursala @@ -0,0 +1,3 @@ +#cast %nLL + +test = permutations <1,2,3> diff --git a/Task/Permutations/VBA/permutations.vba b/Task/Permutations/VBA/permutations.vba new file mode 100644 index 0000000000..3c50f54c3f --- /dev/null +++ b/Task/Permutations/VBA/permutations.vba @@ -0,0 +1,64 @@ +Public Sub Permute(n As Integer, Optional printem As Boolean = True) +'generate, count and print (if printem is not false) all permutations of first n integers + +Dim P() As Integer +Dim count As Long +dim Last as boolean +Dim t, i, j, k As Integer + +If n <= 1 Then + Debug.Print "give a number greater than 1!" + Exit Sub +End If + +'initialize +ReDim P(n) +For i = 1 To n: P(i) = i: Next +count = 0 +Last = False + +Do While Not Last + 'print? + If printem Then + For t = 1 To n: Debug.Print P(t);: Next + Debug.Print + End If + count = count + 1 + + Last = True + i = n - 1 + Do While i > 0 + If P(i) < P(i + 1) Then + Last = False + Exit Do + End If + i = i - 1 + Loop + + If Not Last Then + j = i + 1 + k = n + While j < k + ' swap p(j) and p(k) + t = P(j) + P(j) = P(k) + P(k) = t + j = j + 1 + k = k - 1 + Wend + j = n + While P(j) > P(i) + j = j - 1 + Wend + j = j + 1 + 'swap p(i) and p(j) + t = P(i) + P(i) = P(j) + P(j) = t + End If 'not last + +Loop 'while not last + +Debug.Print "Number of permutations: "; count + +End Sub diff --git a/Task/Permutations/XPL0/permutations.xpl0 b/Task/Permutations/XPL0/permutations.xpl0 new file mode 100644 index 0000000000..824cdfedeb --- /dev/null +++ b/Task/Permutations/XPL0/permutations.xpl0 @@ -0,0 +1,25 @@ +code ChOut=8, CrLf=9; +def N=4; \number of objects (letters) +char S0, S1(N); + +proc Permute(D); \Display all permutations of letters in S0 +int D; \depth of recursion +int I, J; +[if D=N then + [for I:= 0 to N-1 do ChOut(0, S1(I)); + CrLf(0); + return; + ]; +for I:= 0 to N-1 do + [for J:= 0 to D-1 do \check if object (letter) already used + if S1(J) = S0(I) then J:=100; + if J<100 then + [S1(D):= S0(I); \object (letter) not used so append it + Permute(D+1); \recurse next level deeper + ]; + ]; +]; + +[S0:= "rose "; \N different objects (letters) +Permute(0); \(space char avoids MSb termination) +] diff --git a/Task/Pick-random-element/0DESCRIPTION b/Task/Pick-random-element/0DESCRIPTION new file mode 100644 index 0000000000..cf0d673f8b --- /dev/null +++ b/Task/Pick-random-element/0DESCRIPTION @@ -0,0 +1 @@ +Demonstrate how to pick a random element from a list. diff --git a/Task/Pick-random-element/1META.yaml b/Task/Pick-random-element/1META.yaml new file mode 100644 index 0000000000..659c8686af --- /dev/null +++ b/Task/Pick-random-element/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Basic language learning diff --git a/Task/Pick-random-element/ACL2/pick-random-element.acl2 b/Task/Pick-random-element/ACL2/pick-random-element.acl2 new file mode 100644 index 0000000000..bf9302d0d7 --- /dev/null +++ b/Task/Pick-random-element/ACL2/pick-random-element.acl2 @@ -0,0 +1,6 @@ +:set-state-ok t + +(defun pick-random-element (xs state) + (mv-let (idx state) + (random$ (len xs) state) + (mv (nth idx xs) state))) diff --git a/Task/Pick-random-element/Ada/pick-random-element.ada b/Task/Pick-random-element/Ada/pick-random-element.ada new file mode 100644 index 0000000000..08f5509da2 --- /dev/null +++ b/Task/Pick-random-element/Ada/pick-random-element.ada @@ -0,0 +1,30 @@ +with Ada.Text_IO, Ada.Numerics.Float_Random; + +procedure Pick_Random_Element is + + package Rnd renames Ada.Numerics.Float_Random; + Gen: Rnd.Generator; -- used globally + + type Char_Arr is array (Natural range <>) of Character; + + function Pick_Random(A: Char_Arr) return Character is + -- Chooses one of the characters of A (uniformly distributed) + begin + return A(A'First + Natural(Rnd.Random(Gen) * Float(A'Last))); + end Pick_Random; + + Vowels : Char_Arr := ('a', 'e', 'i', 'o', 'u'); + Consonants: Char_Arr := ('t', 'n', 's', 'h', 'r', 'd', 'l'); + Specials : Char_Arr := (',', '.', '?', '!'); + +begin + Rnd.Reset(Gen); + for J in 1 .. 3 loop + for I in 1 .. 10 loop + Ada.Text_IO.Put(Pick_Random(Consonants)); + Ada.Text_IO.Put(Pick_Random(Vowels)); + end loop; + Ada.Text_IO.Put(Pick_Random(Specials) & " "); + end loop; + Ada.Text_IO.New_Line; +end Pick_Random_Element; diff --git a/Task/Pick-random-element/Aime/pick-random-element.aime b/Task/Pick-random-element/Aime/pick-random-element.aime new file mode 100644 index 0000000000..d9bfdd1380 --- /dev/null +++ b/Task/Pick-random-element/Aime/pick-random-element.aime @@ -0,0 +1,11 @@ +list l; + +l_append(l, 'a'); +l_append(l, 'b'); +l_append(l, 'c'); +l_append(l, 'd'); +l_append(l, 'e'); +l_append(l, 'f'); + +o_byte(l_query(l, drand(5))); +o_byte('\n'); diff --git a/Task/Pick-random-element/AutoHotkey/pick-random-element-1.ahk b/Task/Pick-random-element/AutoHotkey/pick-random-element-1.ahk new file mode 100644 index 0000000000..391f763b94 --- /dev/null +++ b/Task/Pick-random-element/AutoHotkey/pick-random-element-1.ahk @@ -0,0 +1,3 @@ +list := ["abc", "def", "gh", "ijklmnop", "hello", "world"] +Random, randint, 1, % list.MaxIndex() +MsgBox % List[randint] diff --git a/Task/Pick-random-element/AutoHotkey/pick-random-element-2.ahk b/Task/Pick-random-element/AutoHotkey/pick-random-element-2.ahk new file mode 100644 index 0000000000..d4759f87f8 --- /dev/null +++ b/Task/Pick-random-element/AutoHotkey/pick-random-element-2.ahk @@ -0,0 +1,4 @@ +list := "abc,def,gh,ijklmnop,hello,world" +StringSplit list, list, `, +Random, randint, 1, %list0% +MsgBox % List%randint% diff --git a/Task/Pick-random-element/BASIC/pick-random-element.basic b/Task/Pick-random-element/BASIC/pick-random-element.basic new file mode 100644 index 0000000000..719d68c4d8 --- /dev/null +++ b/Task/Pick-random-element/BASIC/pick-random-element.basic @@ -0,0 +1,13 @@ +'setup +DIM foo(10) AS LONG +DIM n AS LONG, x AS LONG +FOR n = LBOUND(foo) TO UBOUND(foo) + foo(n) = INT(RND*99999) +NEXT +RANDOMIZE TIMER + +'random selection +x = INT(RND * ((UBOUND(foo) - LBOUND(foo)) + 1)) + +'output +PRINT x, foo(x) diff --git a/Task/Pick-random-element/BBC-BASIC/pick-random-element.bbc b/Task/Pick-random-element/BBC-BASIC/pick-random-element.bbc new file mode 100644 index 0000000000..ce5c280c63 --- /dev/null +++ b/Task/Pick-random-element/BBC-BASIC/pick-random-element.bbc @@ -0,0 +1,4 @@ + DIM list$(5) + list$() = "The", "five", "boxing", "wizards", "jump", "quickly" + chosen% = RND(6) + PRINT "Item " ; chosen% " was chosen which is '" list$(chosen%-1) "'" diff --git a/Task/Pick-random-element/Burlesque/pick-random-element.blq b/Task/Pick-random-element/Burlesque/pick-random-element.blq new file mode 100644 index 0000000000..4e8d39a618 --- /dev/null +++ b/Task/Pick-random-element/Burlesque/pick-random-element.blq @@ -0,0 +1,2 @@ +blsq ) "ABCDEFG"123456 0 6rn-]!! +'G diff --git a/Task/Pick-random-element/C/pick-random-element.c b/Task/Pick-random-element/C/pick-random-element.c new file mode 100644 index 0000000000..e0d130354b --- /dev/null +++ b/Task/Pick-random-element/C/pick-random-element.c @@ -0,0 +1,13 @@ +#include +#include +#include + +int main(){ + char array[] = { 'a', 'b', 'c' }; + + srand( time( 0 ) ); + + printf( "%c\n", array[ rand() % 3 ] ); + + return 0; +} diff --git a/Task/Pick-random-element/Clojure/pick-random-element-1.clj b/Task/Pick-random-element/Clojure/pick-random-element-1.clj new file mode 100644 index 0000000000..14f39a2a70 --- /dev/null +++ b/Task/Pick-random-element/Clojure/pick-random-element-1.clj @@ -0,0 +1 @@ +(rand-nth coll) diff --git a/Task/Pick-random-element/Clojure/pick-random-element-2.clj b/Task/Pick-random-element/Clojure/pick-random-element-2.clj new file mode 100644 index 0000000000..20b05979d7 --- /dev/null +++ b/Task/Pick-random-element/Clojure/pick-random-element-2.clj @@ -0,0 +1 @@ +(nth coll (rand-int (count coll))) diff --git a/Task/Pick-random-element/CoffeeScript/pick-random-element.coffeescript b/Task/Pick-random-element/CoffeeScript/pick-random-element.coffeescript new file mode 100644 index 0000000000..f441d4baf8 --- /dev/null +++ b/Task/Pick-random-element/CoffeeScript/pick-random-element.coffeescript @@ -0,0 +1,2 @@ +array = [1,2,3] +console.log array[Math.floor(Math.random() * array.length)] diff --git a/Task/Pick-random-element/D/pick-random-element.d b/Task/Pick-random-element/D/pick-random-element.d new file mode 100644 index 0000000000..0a25baf4f7 --- /dev/null +++ b/Task/Pick-random-element/D/pick-random-element.d @@ -0,0 +1,7 @@ +import std.stdio, std.random; + +void main() { + auto items = ["foo", "bar", "baz"]; + auto r = items[uniform(0, $)]; + writeln(r); +} diff --git a/Task/Pick-random-element/Deja-Vu/pick-random-element.djv b/Task/Pick-random-element/Deja-Vu/pick-random-element.djv new file mode 100644 index 0000000000..e70ffd767b --- /dev/null +++ b/Task/Pick-random-element/Deja-Vu/pick-random-element.djv @@ -0,0 +1 @@ +print choose [ "one" "two" "chicken" ] diff --git a/Task/Pick-random-element/Euphoria/pick-random-element.euphoria b/Task/Pick-random-element/Euphoria/pick-random-element.euphoria new file mode 100644 index 0000000000..d7f1fe2467 --- /dev/null +++ b/Task/Pick-random-element/Euphoria/pick-random-element.euphoria @@ -0,0 +1,2 @@ +constant s = {'a', 'b', 'c'} +puts(1,s[rand($)]) diff --git a/Task/Pick-random-element/Factor/pick-random-element.factor b/Task/Pick-random-element/Factor/pick-random-element.factor new file mode 100644 index 0000000000..0c69f824ce --- /dev/null +++ b/Task/Pick-random-element/Factor/pick-random-element.factor @@ -0,0 +1,2 @@ +( scratchpad ) { "a" "b" "c" "d" "e" "f" } random . +"a" diff --git a/Task/Pick-random-element/Go/pick-random-element.go b/Task/Pick-random-element/Go/pick-random-element.go new file mode 100644 index 0000000000..ea4d7d0029 --- /dev/null +++ b/Task/Pick-random-element/Go/pick-random-element.go @@ -0,0 +1,14 @@ +package main + +import ( + "fmt" + "math/rand" + "time" +) + +var list = []string{"bleen", "fuligin", "garrow", "grue", "hooloovoo"} + +func main() { + rand.Seed(time.Now().UnixNano()) + fmt.Println(list[rand.Intn(len(list))]) +} diff --git a/Task/Pick-random-element/Groovy/pick-random-element.groovy b/Task/Pick-random-element/Groovy/pick-random-element.groovy new file mode 100644 index 0000000000..0ebc0506b4 --- /dev/null +++ b/Task/Pick-random-element/Groovy/pick-random-element.groovy @@ -0,0 +1,7 @@ +def list = [25, 30, 1, 450, 3, 78] +def random = new Random(); + +(0..3).each { + def i = random.nextInt(list.size()) + println "list[${i}] == ${list[i]}" +} diff --git a/Task/Pick-random-element/Haskell/pick-random-element-1.hs b/Task/Pick-random-element/Haskell/pick-random-element-1.hs new file mode 100644 index 0000000000..0e2f1337d7 --- /dev/null +++ b/Task/Pick-random-element/Haskell/pick-random-element-1.hs @@ -0,0 +1,6 @@ +import Random (randomRIO) + +pick :: [a] -> IO a +pick xs = randomRIO (0, length xs - 1) >>= return . (xs !!) + +x <- pick [1 2 3] diff --git a/Task/Pick-random-element/Haskell/pick-random-element-2.hs b/Task/Pick-random-element/Haskell/pick-random-element-2.hs new file mode 100644 index 0000000000..0a663f8928 --- /dev/null +++ b/Task/Pick-random-element/Haskell/pick-random-element-2.hs @@ -0,0 +1,5 @@ +import Data.Random +import Data.Random.Source.DevRandom +import Data.Random.Extras + +x <- runRVar (choice [1 2 3]) DevRandom diff --git a/Task/Pick-random-element/Icon/pick-random-element.icon b/Task/Pick-random-element/Icon/pick-random-element.icon new file mode 100644 index 0000000000..458a6a7f19 --- /dev/null +++ b/Task/Pick-random-element/Icon/pick-random-element.icon @@ -0,0 +1,4 @@ +procedure main() + L := [1,2,3] # a list + x := ?L # random element +end diff --git a/Task/Pick-random-element/J/pick-random-element.j b/Task/Pick-random-element/J/pick-random-element.j new file mode 100644 index 0000000000..d1277d13c4 --- /dev/null +++ b/Task/Pick-random-element/J/pick-random-element.j @@ -0,0 +1,2 @@ + ({~ ?@#) 'abcdef' +b diff --git a/Task/Pick-random-element/Java/pick-random-element.java b/Task/Pick-random-element/Java/pick-random-element.java new file mode 100644 index 0000000000..47c96db80a --- /dev/null +++ b/Task/Pick-random-element/Java/pick-random-element.java @@ -0,0 +1,4 @@ +import java.util.Random; +... +int[] array = {1,2,3}; +return array[new Random().nextInt(array.length)]; // if done multiple times, the Random object should be re-used diff --git a/Task/Pick-random-element/JavaScript/pick-random-element.js b/Task/Pick-random-element/JavaScript/pick-random-element.js new file mode 100644 index 0000000000..1d6f7a808a --- /dev/null +++ b/Task/Pick-random-element/JavaScript/pick-random-element.js @@ -0,0 +1,2 @@ +var array = [1,2,3]; +return array[Math.floor(Math.random() * array.length)]; diff --git a/Task/Pick-random-element/K/pick-random-element.k b/Task/Pick-random-element/K/pick-random-element.k new file mode 100644 index 0000000000..829fce3c65 --- /dev/null +++ b/Task/Pick-random-element/K/pick-random-element.k @@ -0,0 +1,2 @@ + 1?"abcdefg" +,"e" diff --git a/Task/Pick-random-element/Liberty-BASIC/pick-random-element.liberty b/Task/Pick-random-element/Liberty-BASIC/pick-random-element.liberty new file mode 100644 index 0000000000..bad8ba2be9 --- /dev/null +++ b/Task/Pick-random-element/Liberty-BASIC/pick-random-element.liberty @@ -0,0 +1,3 @@ +list$ ="John Paul George Ringo Peter Paul Mary Obama Putin" +wantedTerm =int( 10 *rnd( 1)) +print "Selecting term "; wantedTerm; " in the list, which was "; word$( list$, wantedTerm, " ") diff --git a/Task/Pick-random-element/Logo/pick-random-element.logo b/Task/Pick-random-element/Logo/pick-random-element.logo new file mode 100644 index 0000000000..ac373f2106 --- /dev/null +++ b/Task/Pick-random-element/Logo/pick-random-element.logo @@ -0,0 +1 @@ +pick [1 2 3] diff --git a/Task/Pick-random-element/Lua/pick-random-element.lua b/Task/Pick-random-element/Lua/pick-random-element.lua new file mode 100644 index 0000000000..da02e925de --- /dev/null +++ b/Task/Pick-random-element/Lua/pick-random-element.lua @@ -0,0 +1,3 @@ +math.randomseed(os.time()) +local a = {1,2,3} +print(a[math.random(1,#a)]) diff --git a/Task/Pick-random-element/MATLAB/pick-random-element-1.m b/Task/Pick-random-element/MATLAB/pick-random-element-1.m new file mode 100644 index 0000000000..caa28d0669 --- /dev/null +++ b/Task/Pick-random-element/MATLAB/pick-random-element-1.m @@ -0,0 +1,2 @@ + list = {'a','b','c'}; + list{ceil(rand(1)*length(list))} diff --git a/Task/Pick-random-element/MATLAB/pick-random-element-2.m b/Task/Pick-random-element/MATLAB/pick-random-element-2.m new file mode 100644 index 0000000000..ee33feaf83 --- /dev/null +++ b/Task/Pick-random-element/MATLAB/pick-random-element-2.m @@ -0,0 +1,2 @@ + list = 1:1000; + list(ceil(rand(1)*length(list))) diff --git a/Task/Pick-random-element/Mathematica/pick-random-element.math b/Task/Pick-random-element/Mathematica/pick-random-element.math new file mode 100644 index 0000000000..6012c71f65 --- /dev/null +++ b/Task/Pick-random-element/Mathematica/pick-random-element.math @@ -0,0 +1,2 @@ +RandomChoice[{a, b, c}] +->c diff --git a/Task/Pick-random-element/NetLogo/pick-random-element.netlogo b/Task/Pick-random-element/NetLogo/pick-random-element.netlogo new file mode 100644 index 0000000000..d83823c7aa --- /dev/null +++ b/Task/Pick-random-element/NetLogo/pick-random-element.netlogo @@ -0,0 +1,4 @@ +;; from list containnig only literals and literal constants +user-message one-of [ 1 3 "rooster" blue ] +;; from list containing variables and reporters +user-message one-of (list (red + 2) turtles (patch 0 0) ) diff --git a/Task/Pick-random-element/NetRexx/pick-random-element.netrexx b/Task/Pick-random-element/NetRexx/pick-random-element.netrexx new file mode 100644 index 0000000000..2e5609288a --- /dev/null +++ b/Task/Pick-random-element/NetRexx/pick-random-element.netrexx @@ -0,0 +1,13 @@ +/* NetRexx */ +options replace format comments java crossref savelog symbols nobinary + +iArray = [ 1, 2, 3, 4, 5 ] -- a traditional array +iList = Arrays.asList(iArray) -- a Java Collection "List" object +iWords = '1 2 3 4 5' -- a list as a string of space delimited words + + +v1 = iArray[Random().nextInt(iArray.length)] +v2 = iList.get(Random().nextInt(iList.size())) +v3 = iWords.word(Random().nextInt(iWords.words()) + 1) -- the index for word() starts at one + +say v1 v2 v3 diff --git a/Task/Pick-random-element/OCaml/pick-random-element-1.ocaml b/Task/Pick-random-element/OCaml/pick-random-element-1.ocaml new file mode 100644 index 0000000000..26ab00ad1d --- /dev/null +++ b/Task/Pick-random-element/OCaml/pick-random-element-1.ocaml @@ -0,0 +1,3 @@ +let list_rand lst = + let len = List.length lst in + List.nth lst (Random.int len) diff --git a/Task/Pick-random-element/OCaml/pick-random-element-2.ocaml b/Task/Pick-random-element/OCaml/pick-random-element-2.ocaml new file mode 100644 index 0000000000..cb9986b277 --- /dev/null +++ b/Task/Pick-random-element/OCaml/pick-random-element-2.ocaml @@ -0,0 +1,3 @@ +let array_rand ary = + let len = Array.length ary in + ary.(Random.int len) diff --git a/Task/Pick-random-element/Objeck/pick-random-element.objeck b/Task/Pick-random-element/Objeck/pick-random-element.objeck new file mode 100644 index 0000000000..638f2a4356 --- /dev/null +++ b/Task/Pick-random-element/Objeck/pick-random-element.objeck @@ -0,0 +1,2 @@ +values := [1, 2, 3]; +value := values[(Float->Random() * 100.0)->As(Int) % values->Size()]; diff --git a/Task/Pick-random-element/PARI-GP/pick-random-element.pari b/Task/Pick-random-element/PARI-GP/pick-random-element.pari new file mode 100644 index 0000000000..09c33806bb --- /dev/null +++ b/Task/Pick-random-element/PARI-GP/pick-random-element.pari @@ -0,0 +1 @@ +pick(v)=v[random(#v)+1] diff --git a/Task/Pick-random-element/PHP/pick-random-element.php b/Task/Pick-random-element/PHP/pick-random-element.php new file mode 100644 index 0000000000..3fcbfccfd4 --- /dev/null +++ b/Task/Pick-random-element/PHP/pick-random-element.php @@ -0,0 +1,2 @@ +$arr = array('foo', 'bar', 'baz'); +$x = $arr[array_rand($arr)]; diff --git a/Task/Pick-random-element/PL-I/pick-random-element.pli b/Task/Pick-random-element/PL-I/pick-random-element.pli new file mode 100644 index 0000000000..68bad273bc --- /dev/null +++ b/Task/Pick-random-element/PL-I/pick-random-element.pli @@ -0,0 +1,3 @@ + declare t(0:9) character (1) static initial + ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'); + put ( t(10*random()) ); diff --git a/Task/Pick-random-element/Pascal/pick-random-element.pascal b/Task/Pick-random-element/Pascal/pick-random-element.pascal new file mode 100644 index 0000000000..70be950d5b --- /dev/null +++ b/Task/Pick-random-element/Pascal/pick-random-element.pascal @@ -0,0 +1,9 @@ +Program PickRandomElement (output); + +const + s: array [1..5] of string = ('1234', 'ABCDE', 'Charlie', 'XB56ds', 'lala'); + +begin + randomize; + writeln(s[low(s) + random(length(s))]); +end. diff --git a/Task/Pick-random-element/Perl-6/pick-random-element-1.pl6 b/Task/Pick-random-element/Perl-6/pick-random-element-1.pl6 new file mode 100644 index 0000000000..5654731e2e --- /dev/null +++ b/Task/Pick-random-element/Perl-6/pick-random-element-1.pl6 @@ -0,0 +1,3 @@ +(1..6).roll; # return 1 random value in the range 1 through 6 +(1..6).roll(3); # return a list of 3 random values in the range 1 through 6 +(1..6).roll(*); # return a lazy infinite list of random values in the range 1 through 6 diff --git a/Task/Pick-random-element/Perl-6/pick-random-element-2.pl6 b/Task/Pick-random-element/Perl-6/pick-random-element-2.pl6 new file mode 100644 index 0000000000..ebdf90d652 --- /dev/null +++ b/Task/Pick-random-element/Perl-6/pick-random-element-2.pl6 @@ -0,0 +1,5 @@ +# define the deck +constant deck = 2..9, X~ <♠ ♣ ♥ ♦>; +deck.pick; # Pick a card +deck.pick(5); # Draw 5 +deck.pick(*); # Get a shuffled deck diff --git a/Task/Pick-random-element/Perl-6/pick-random-element-3.pl6 b/Task/Pick-random-element/Perl-6/pick-random-element-3.pl6 new file mode 100644 index 0000000000..6a758f28b2 --- /dev/null +++ b/Task/Pick-random-element/Perl-6/pick-random-element-3.pl6 @@ -0,0 +1 @@ +@array[@array * rand] diff --git a/Task/Pick-random-element/Perl-6/pick-random-element-4.pl6 b/Task/Pick-random-element/Perl-6/pick-random-element-4.pl6 new file mode 100644 index 0000000000..d6737ba8f7 --- /dev/null +++ b/Task/Pick-random-element/Perl-6/pick-random-element-4.pl6 @@ -0,0 +1 @@ +say Bool.pick; # returns either True or False diff --git a/Task/Pick-random-element/Perl/pick-random-element.pl b/Task/Pick-random-element/Perl/pick-random-element.pl new file mode 100644 index 0000000000..df80d05471 --- /dev/null +++ b/Task/Pick-random-element/Perl/pick-random-element.pl @@ -0,0 +1,2 @@ +my @array = qw(a b c); +print $array[ rand @array ]; diff --git a/Task/Pick-random-element/PicoLisp/pick-random-element.l b/Task/Pick-random-element/PicoLisp/pick-random-element.l new file mode 100644 index 0000000000..d60f0444af --- /dev/null +++ b/Task/Pick-random-element/PicoLisp/pick-random-element.l @@ -0,0 +1 @@ +(get Lst (rand 1 (length Lst))) diff --git a/Task/Pick-random-element/PureBasic/pick-random-element.purebasic b/Task/Pick-random-element/PureBasic/pick-random-element.purebasic new file mode 100644 index 0000000000..acf4eeab63 --- /dev/null +++ b/Task/Pick-random-element/PureBasic/pick-random-element.purebasic @@ -0,0 +1,40 @@ +Procedure.s pickRandomElement(List source.s()) + Protected x = ListSize(source()) + + If x > 0 + SelectElement(source(), Random(x - 1)) ;element numbering is zero - based + ProcedureReturn source() + EndIf +EndProcedure + +;initialize list elements +DataSection + elements: + Data.s "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten" +EndDataSection + +#elementCount = 10 +NewList item.s() + +Restore elements +Define i +For i = 1 To #elementCount + AddElement(item()) + Read.s item() +Next + +If OpenConsole() + Print("Source list: ") + ForEach item() + Print(item() + " ") + Next + PrintN(#CRLF$) + + Print("Random picks from list: ") + For i = 1 To 10 + Print(pickRandomElement(item()) + " ") + Next + + Print(#CRLF$ + #CRLF$ + "Press ENTER to exit"): Input() + CloseConsole() +EndIf diff --git a/Task/Pick-random-element/Python/pick-random-element.py b/Task/Pick-random-element/Python/pick-random-element.py new file mode 100644 index 0000000000..ee6bf13852 --- /dev/null +++ b/Task/Pick-random-element/Python/pick-random-element.py @@ -0,0 +1,3 @@ +>>> import random +>>> random.choice(['foo', 'bar', 'baz']) +'baz' diff --git a/Task/Pick-random-element/R/pick-random-element.r b/Task/Pick-random-element/R/pick-random-element.r new file mode 100644 index 0000000000..f076b44034 --- /dev/null +++ b/Task/Pick-random-element/R/pick-random-element.r @@ -0,0 +1,12 @@ +# a vector (letters are builtin) +letters +# [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" +# [20] "t" "u" "v" "w" "x" "y" "z" + +# picking one element +sample(letters, 1) +# [1] "n" + +# picking some elements with repetition, and concatenating to get a word +paste(sample(letters, 10, rep=T), collapse="") +# [1] "episxgcgmt" diff --git a/Task/Pick-random-element/REXX/pick-random-element-1.rexx b/Task/Pick-random-element/REXX/pick-random-element-1.rexx new file mode 100644 index 0000000000..62bf330ee9 --- /dev/null +++ b/Task/Pick-random-element/REXX/pick-random-element-1.rexx @@ -0,0 +1,21 @@ +/*REXX program to pick a random element from a list (tongue in cheek). */ + +_= 'hydrogen helium lithium beryllium boron carbon nitrogen oxygen' +_=_ 'fluorine neon sodium magnesium aluminum silicon phosphorous sulfur' +_=_ 'chlorine argon potassium calcium scandium titanium vanadium chromium' +_=_ 'manganese iron cobalt nickel copper zinc gallium germanium arsenic' +_=_ 'selenium bromine krypton rubidium strontium yttrium zirconium' +_=_ 'niobium molybdenum technetium ruthenium rhodium palladium silver' +_=_ 'cadmium indium tin antimony tellurium iodine xenon cesium barium' +_=_ 'lanthanum cerium praseodymium neodymium promethium samarium europium' +_=_ 'gadolinium terbium dysprosium holmium erbium thulium ytterbium' +_=_ 'lutetium hafnium tantalum tungsten rhenium osmium irdium platinum' +_=_ 'gold mercury thallium lead bismuth polonium astatine radon francium' +_=_ 'radium actinium thorium protactinium uranium neptunium plutonium' +_=_ 'americium curium berkelium californium einsteinum fermium mendelevium' +_=_ 'nobelium lawrencium rutherfordium dubnium seaborgium bohrium hassium' +_=_ 'meitnerium darmstadtium roentgenium copernicium Ununtrium' + +w=words(_) +say 'random element =' word(_,random(1,w)) + /*stick a fork in it, we're done.*/ diff --git a/Task/Pick-random-element/REXX/pick-random-element-2.rexx b/Task/Pick-random-element/REXX/pick-random-element-2.rexx new file mode 100644 index 0000000000..a3ed509d12 --- /dev/null +++ b/Task/Pick-random-element/REXX/pick-random-element-2.rexx @@ -0,0 +1,9 @@ +/* REXX *************************************************************** +* 18.10.2012 Walter Pachl Not only the list of elements shortened:-) +**********************************************************************/ +wl='hydrogen helium lithium beryllium boron carbon nitrogen oxygen', + 'fluorine neon sodium magnesium aluminum silicon phosphorous sulfur', + '...', + 'meitnerium darmstadtium roentgenium copernicium Ununtrium' + +Say word(wl,random(1,words(wl))) diff --git a/Task/Pick-random-element/Ruby/pick-random-element-1.rb b/Task/Pick-random-element/Ruby/pick-random-element-1.rb new file mode 100644 index 0000000000..ccab5f1694 --- /dev/null +++ b/Task/Pick-random-element/Ruby/pick-random-element-1.rb @@ -0,0 +1,4 @@ +irb(main):001:0> %w(north east south west).sample +=> "west" +irb(main):002:0> (1..100).to_a.sample(2) +=> [17, 79] diff --git a/Task/Pick-random-element/Ruby/pick-random-element-2.rb b/Task/Pick-random-element/Ruby/pick-random-element-2.rb new file mode 100644 index 0000000000..b8c1285213 --- /dev/null +++ b/Task/Pick-random-element/Ruby/pick-random-element-2.rb @@ -0,0 +1,2 @@ +irb(main):001:0> %w(north east south west).choice +=> "south" diff --git a/Task/Pick-random-element/Run-BASIC/pick-random-element.run b/Task/Pick-random-element/Run-BASIC/pick-random-element.run new file mode 100644 index 0000000000..56af4c28b9 --- /dev/null +++ b/Task/Pick-random-element/Run-BASIC/pick-random-element.run @@ -0,0 +1,3 @@ +list$ = "a,b,c,d,e,f,g,h,i,j" +letter = rnd(1) * 10 +print "Selected letter:"; word$(list$,letter,",") diff --git a/Task/Pick-random-element/Seed7/pick-random-element.seed7 b/Task/Pick-random-element/Seed7/pick-random-element.seed7 new file mode 100644 index 0000000000..ecb1d537d5 --- /dev/null +++ b/Task/Pick-random-element/Seed7/pick-random-element.seed7 @@ -0,0 +1,6 @@ +$ include "seed7_05.s7i"; + +const proc: main is func + begin + writeln(rand([] ("foo", "bar", "baz"))); + end func; diff --git a/Task/Pick-random-element/Smalltalk/pick-random-element.st b/Task/Pick-random-element/Smalltalk/pick-random-element.st new file mode 100644 index 0000000000..137073aae3 --- /dev/null +++ b/Task/Pick-random-element/Smalltalk/pick-random-element.st @@ -0,0 +1 @@ +x := #(1 2 3) atRandom. diff --git a/Task/Pick-random-element/TUSCRIPT/pick-random-element.tuscript b/Task/Pick-random-element/TUSCRIPT/pick-random-element.tuscript new file mode 100644 index 0000000000..34038bbdb4 --- /dev/null +++ b/Task/Pick-random-element/TUSCRIPT/pick-random-element.tuscript @@ -0,0 +1,6 @@ +$$ MODE TUSCRIPT +list="John'Paul'George'Ringo'Peter'Paul'Mary'Obama'Putin" +sizeList=SIZE(list) +selectedNr=RANDOM_NUMBERS (1,sizeList,1) +selectedItem=SELECT(list,#selectednr) +PRINT "Selecting term ",selectedNr," in the list, which was ",selectedItem diff --git a/Task/Pick-random-element/TXR/pick-random-element.txr b/Task/Pick-random-element/TXR/pick-random-element.txr new file mode 100644 index 0000000000..69a0893ec4 --- /dev/null +++ b/Task/Pick-random-element/TXR/pick-random-element.txr @@ -0,0 +1,3 @@ +@(do (defun randelem (vec) + (vecref vec (random nil (length vec))))) +@(bind x @(randelem #("a" "b" "c" "d"))) diff --git a/Task/Pick-random-element/Tcl/pick-random-element.tcl b/Task/Pick-random-element/Tcl/pick-random-element.tcl new file mode 100644 index 0000000000..5792692303 --- /dev/null +++ b/Task/Pick-random-element/Tcl/pick-random-element.tcl @@ -0,0 +1,4 @@ +proc randelem {list} { + lindex $list [expr {int(rand()*[llength $list])}] +} +set x [randelem {1 2 3 4 5}] diff --git a/Task/Pick-random-element/XPL0/pick-random-element.xpl0 b/Task/Pick-random-element/XPL0/pick-random-element.xpl0 new file mode 100644 index 0000000000..bfd5e6d784 --- /dev/null +++ b/Task/Pick-random-element/XPL0/pick-random-element.xpl0 @@ -0,0 +1,5 @@ +code Ran=1, Text=12; +int List; +[List:= ["hydrogen", "helium", "lithium", "beryllium", "boron"]; \(Thanks REXX) +Text(0, List(Ran(5))); +] diff --git a/Task/Pig-the-dice-game-Player/0DESCRIPTION b/Task/Pig-the-dice-game-Player/0DESCRIPTION new file mode 100644 index 0000000000..c54b0904ba --- /dev/null +++ b/Task/Pig-the-dice-game-Player/0DESCRIPTION @@ -0,0 +1,18 @@ +__FORCETOC__ +The task is to create a dice simulator and scorer of [[Pig the dice game]] and add to it the ability to play the game to at least one strategy. +* State here the play strategies involved. +* Show play during a game here. + +As a stretch goal: +* Simulate playing the game a number of times with two players of given strategies and report here summary statistics such as, but not restricted to, the influence of going first or which strategy seems stronger. + +;Game Rules: +The game of Pig is a multiplayer game played with a single six-sided die. The +object of the game is to reach 100 points or more. +Play is taken in turns. On each person's turn that person has the option of either + +# '''Rolling the dice''': where a roll of two to six is added to their score for that turn and the player's turn continues as the player is given the same choice again; or a roll of 1 loses the player's total points ''for that turn'' and their turn finishes with play passing to the next player. +# '''Holding''': The player's score for that round is added to their total and becomes safe from the effects of throwing a one. The player's turn finishes with play passing to the next player. + +;Reference +* [[wp:Pig (dice)|Pig (dice)]] diff --git a/Task/Pig-the-dice-game-Player/Ada/pig-the-dice-game-player.ada b/Task/Pig-the-dice-game-Player/Ada/pig-the-dice-game-player.ada new file mode 100644 index 0000000000..e5b0724acf --- /dev/null +++ b/Task/Pig-the-dice-game-Player/Ada/pig-the-dice-game-player.ada @@ -0,0 +1,37 @@ +with Pig; with Ada.Text_IO; with Ada.Command_Line; + +procedure automatic_Pig is + + use Pig; + + type Robot is new Actor with record + Bound: Natural := 20; + Final_Run: Natural := 0; + end record; + function Roll_More(A: Robot; Self, Opponent: Player'Class) return Boolean; + + function Roll_More(A: Robot; Self, Opponent: Player'Class) return Boolean is + ((Self.All_Recent < A.Bound) or + else (Opponent.Score-100 > A.Final_Run)); + + function Arg(Position: Positive; Default: Natural) return Natural is + package ACL renames Ada.Command_Line; + begin + return Natural'Value(ACL.Argument(Position)); + exception + when Constraint_Error => return Default; + end Arg; + + T: Robot := (Bound => Arg(2, 35), Final_Run => Arg(3, 0)); + F: Robot := (Bound => Arg(4, 20), Final_Run => Arg(5, 30)); + + T_Wins: Boolean; + Win_Count: array(Boolean) of Natural := (True=> 0, False => 0); +begin + for I in 1 .. Arg(1, 1000) loop + Play(T, F, T_Wins); + Win_Count(T_Wins) := Win_Count(T_Wins) + 1; + end loop; + Ada.Text_IO.Put_Line(Natural'Image(Win_Count(True)) & + Natural'Image(Win_Count(False))); +end Automatic_Pig; diff --git a/Task/Pig-the-dice-game-Player/Go/pig-the-dice-game-player.go b/Task/Pig-the-dice-game-Player/Go/pig-the-dice-game-player.go new file mode 100644 index 0000000000..ad307ded54 --- /dev/null +++ b/Task/Pig-the-dice-game-Player/Go/pig-the-dice-game-player.go @@ -0,0 +1,191 @@ +package pig + +import ( + "fmt" + "math/rand" + "time" +) + +type ( + PlayerID int + MessageID int + StrategyID int + + PigGameData struct { + player PlayerID + turnCount int + turnRollCount int + turnScore int + lastRoll int + scores [2]int + verbose bool + } +) + +const ( + // Status messages + gameOver = iota + piggedOut + rolls + pointSpending + holds + turn + gameOverSummary + // Players + player1 = PlayerID(0) + player2 = PlayerID(1) + noPlayer = PlayerID(-1) + // Max score + maxScore = 100 + // Strategies + scoreChaseStrat = iota + rollCountStrat +) + +// Returns "s" if n != 1 +func pluralS(n int) string { + if n != 1 { + return "s" + } + return "" +} + +// Creates an intializes a new PigGameData structure, returns a *PigGameData +func New() *PigGameData { + return &PigGameData{0, 0, 0, 0, 0, [2]int{0, 0}, false} +} + +// Create a status message for a given message ID +func (pg *PigGameData) statusMessage(id MessageID) string { + var msg string + switch id { + case gameOver: + msg = fmt.Sprintf("Game is over after %d turns", pg.turnCount) + case piggedOut: + msg = fmt.Sprintf(" Pigged out after %d roll%s", pg.turnRollCount, pluralS(pg.turnRollCount)) + case rolls: + msg = fmt.Sprintf(" Rolls %d", pg.lastRoll) + case pointSpending: + msg = fmt.Sprintf(" %d point%s pending", pg.turnScore, pluralS(pg.turnScore)) + case holds: + msg = fmt.Sprintf(" Holds after %d turns, adding %d points for a total of %d", pg.turnRollCount, pg.turnScore, pg.PlayerScore(noPlayer)) + case turn: + msg = fmt.Sprintf("Player %d's turn:", pg.player+1) + case gameOverSummary: + msg = fmt.Sprintf("Game over after %d turns\n player 1 %d\n player 2 %d\n", pg.turnCount, pg.PlayerScore(player1), pg.PlayerScore(player2)) + } + return msg +} + +// Print a status message, if pg.Verbose is true +func (pg *PigGameData) PrintStatus(id MessageID) { + if pg.verbose { + fmt.Println(pg.statusMessage(id)) + } +} + +// Play a given strategy +func (pg *PigGameData) Play(id StrategyID) (keepPlaying bool) { + if pg.GameOver() { + pg.PrintStatus(gameOver) + return false + } + + if pg.turnCount == 0 { + pg.player = player2 + pg.NextPlayer() + } + + pg.lastRoll = rand.Intn(6) + 1 + pg.PrintStatus(rolls) + pg.turnRollCount++ + if pg.lastRoll == 1 { + pg.PrintStatus(piggedOut) + pg.NextPlayer() + } else { + pg.turnScore += pg.lastRoll + pg.PrintStatus(pointSpending) + success := false + switch id { + case scoreChaseStrat: + success = pg.scoreChaseStrategy() + case rollCountStrat: + success = pg.rollCountStrategy() + } + if success { + pg.Hold() + pg.NextPlayer() + } + } + return true +} + +// Get the score for a given player +func (pg *PigGameData) PlayerScore(id PlayerID) int { + if id == noPlayer { + return pg.scores[pg.player] + } + return pg.scores[id] +} + +// Check if the game is over +func (pg *PigGameData) GameOver() bool { + return pg.scores[player1] >= maxScore || pg.scores[player2] >= maxScore +} + +// Returns the Player ID if there is a winner, or -1 +func (pg *PigGameData) Winner() PlayerID { + for index, score := range pg.scores { + if score >= maxScore { + return PlayerID(index) + } + } + return noPlayer +} + +// Get the ID of the other player +func (pg *PigGameData) otherPlayer() PlayerID { + // 0 becomes 1, 1 becomes 0 + return 1 - pg.player +} + +func (pg *PigGameData) Hold() { + pg.scores[pg.player] += pg.turnScore + pg.PrintStatus(holds) + pg.turnRollCount, pg.turnScore = 0, 0 +} + +func (pg *PigGameData) NextPlayer() { + pg.turnCount++ + pg.turnRollCount, pg.turnScore = 0, 0 + pg.player = pg.otherPlayer() + pg.PrintStatus(turn) +} + +func (pg *PigGameData) rollCountStrategy() bool { + return pg.turnRollCount >= 3 +} + +func (pg *PigGameData) scoreChaseStrategy() bool { + myScore := pg.PlayerScore(pg.player) + otherScore := pg.PlayerScore(pg.otherPlayer()) + myPendingScore := pg.turnScore + myScore + return myPendingScore >= maxScore || myPendingScore > otherScore || pg.turnRollCount >= 5 +} + +// Run the simulation +func main() { + // Seed the random number generator + rand.Seed(time.Now().UnixNano()) + + // Start a new game + pg := New() + pg.verbose = true + strategies := [2]StrategyID{scoreChaseStrat, rollCountStrat} + + // Play until game over + for !pg.GameOver() { + pg.Play(strategies[pg.player]) + } + pg.PrintStatus(gameOverSummary) +} diff --git a/Task/Pig-the-dice-game-Player/J/pig-the-dice-game-player-1.j b/Task/Pig-the-dice-game-Player/J/pig-the-dice-game-player-1.j new file mode 100644 index 0000000000..ae2c127582 --- /dev/null +++ b/Task/Pig-the-dice-game-Player/J/pig-the-dice-game-player-1.j @@ -0,0 +1,3 @@ +pigval=:4 :0 + (+/%#)(-x),}.(1+i.6)<.100-y+x +) diff --git a/Task/Pig-the-dice-game-Player/J/pig-the-dice-game-player-2.j b/Task/Pig-the-dice-game-Player/J/pig-the-dice-game-player-2.j new file mode 100644 index 0000000000..d9f7ae7d24 --- /dev/null +++ b/Task/Pig-the-dice-game-Player/J/pig-the-dice-game-player-2.j @@ -0,0 +1,2 @@ + 10 pigval 90 +_1.66667 diff --git a/Task/Pig-the-dice-game-Player/J/pig-the-dice-game-player-3.j b/Task/Pig-the-dice-game-Player/J/pig-the-dice-game-player-3.j new file mode 100644 index 0000000000..2212750244 --- /dev/null +++ b/Task/Pig-the-dice-game-Player/J/pig-the-dice-game-player-3.j @@ -0,0 +1,6 @@ + 0 5 10 15 20 pigval"0/60 65 70 75 80 85 90 95 100 + 3.33333 3.33333 3.33333 3.33333 3.33333 3.33333 3.33333 3.16667 0 + 2.5 2.5 2.5 2.5 2.5 2.5 2.33333 _0.833333 _5 + 1.66667 1.66667 1.66667 1.66667 1.66667 1.5 _1.66667 _5.83333 _10 +0.833333 0.833333 0.833333 0.833333 0.666667 _2.5 _6.66667 _10.8333 _15 + 0 0 0 _0.166667 _3.33333 _7.5 _11.6667 _15.8333 _20 diff --git a/Task/Pig-the-dice-game-Player/J/pig-the-dice-game-player-4.j b/Task/Pig-the-dice-game-Player/J/pig-the-dice-game-player-4.j new file mode 100644 index 0000000000..ba3d75f21d --- /dev/null +++ b/Task/Pig-the-dice-game-Player/J/pig-the-dice-game-player-4.j @@ -0,0 +1,3 @@ + (1+i.19) ([,:1+i:~) +/ 0 < pigval"0/~ 1+i.100 + 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 +98 97 96 95 93 92 91 90 89 87 86 85 84 82 81 80 78 77 75 diff --git a/Task/Pig-the-dice-game-Player/Python/pig-the-dice-game-player.py b/Task/Pig-the-dice-game-Player/Python/pig-the-dice-game-player.py new file mode 100644 index 0000000000..b230b341d7 --- /dev/null +++ b/Task/Pig-the-dice-game-Player/Python/pig-the-dice-game-player.py @@ -0,0 +1,127 @@ +#!/usr/bin/python3 + +''' +See: http://en.wikipedia.org/wiki/Pig_(dice) + +This program scores, throws the dice, and plays for an N player game of Pig. + +''' + +from random import randint +from collections import namedtuple +import random +from pprint import pprint as pp +from collections import Counter + + +playercount = 2 +maxscore = 100 +maxgames = 100000 + + +Game = namedtuple('Game', 'players, maxscore, rounds') +Round = namedtuple('Round', 'who, start, scores, safe') + + +class Player(): + def __init__(self, player_index): + self.player_index = player_index + + def __repr__(self): + return '%s(%i)' % (self.__class__.__name__, self.player_index) + + def __call__(self, safescore, scores, game): + 'Returns boolean True to roll again' + pass + +class RandPlay(Player): + def __call__(self, safe, scores, game): + 'Returns random boolean choice of whether to roll again' + return bool(random.randint(0, 1)) + +class RollTo20(Player): + def __call__(self, safe, scores, game): + 'Roll again if this rounds score < 20' + return (((sum(scores) + safe[self.player_index]) < maxscore) # Haven't won yet + and(sum(scores) < 20)) # Not at 20 this round + +class Desparat(Player): + def __call__(self, safe, scores, game): + 'Roll again if this rounds score < 20 or someone is within 20 of winning' + return (((sum(scores) + safe[self.player_index]) < maxscore) # Haven't won yet + and( (sum(scores) < 20) # Not at 20 this round + or max(safe) >= (maxscore - 20))) # Someone's close + + +def game__str__(self): + 'Pretty printer for Game class' + return ("Game(players=%r, maxscore=%i,\n rounds=[\n %s\n ])" + % (self.players, self.maxscore, + ',\n '.join(repr(round) for round in self.rounds))) +Game.__str__ = game__str__ + + +def winningorder(players, safescores): + 'Return (players in winning order, their scores)' + return tuple(zip(*sorted(zip(players, safescores), + key=lambda x: x[1], reverse=True))) + +def playpig(game): + ''' + Plays the game of pig returning the players in winning order + and their scores whilst updating argument game with the details of play. + ''' + players, maxscore, rounds = game + playercount = len(players) + safescore = [0] * playercount # Safe scores for each player + player = 0 # Who plays this round + scores=[] # Individual scores this round + + while max(safescore) < maxscore: + startscore = safescore[player] + rolling = players[player](safescore, scores, game) + if rolling: + rolled = randint(1, 6) + scores.append(rolled) + if rolled == 1: + # Bust! + round = Round(who=players[player], + start=startscore, + scores=scores, + safe=safescore[player]) + rounds.append(round) + scores, player = [], (player + 1) % playercount + else: + # Stick + safescore[player] += sum(scores) + round = Round(who=players[player], + start=startscore, + scores=scores, + safe=safescore[player]) + rounds.append(round) + if safescore[player] >= maxscore: + break + scores, player = [], (player + 1) % playercount + + # return players in winning order and all scores + return winningorder(players, safescore) + +if __name__ == '__main__': + game = Game(players=tuple(RandPlay(i) for i in range(playercount)), + maxscore=20, + rounds=[]) + print('ONE GAME') + print('Winning order: %r; Respective scores: %r\n' % playpig(game)) + print(game) + game = Game(players=tuple(RandPlay(i) for i in range(playercount)), + maxscore=maxscore, + rounds=[]) + algos = (RollTo20, RandPlay, Desparat) + print('\n\nMULTIPLE STATISTICS using %r\n for %i GAMES' + % (', '.join(p.__name__ for p in algos), maxgames,)) + winners = Counter(repr(playpig(game._replace(players=tuple(random.choice(algos)(i) + for i in range(playercount)), + rounds=[]))[0]) + for i in range(maxgames)) + print(' Players(position) winning on left; occurrences on right:\n %s' + % ',\n '.join(str(w) for w in winners.most_common())) diff --git a/Task/Pig-the-dice-game-Player/REXX/pig-the-dice-game-player.rexx b/Task/Pig-the-dice-game-Player/REXX/pig-the-dice-game-player.rexx new file mode 100644 index 0000000000..83cf5fa485 --- /dev/null +++ b/Task/Pig-the-dice-game-Player/REXX/pig-the-dice-game-player.rexx @@ -0,0 +1,89 @@ +/*REXX program plays pig (the dice game) with at least one human player.*/ +signal on syntax; signal on novalue /*handle REXX program errors. */ +sw=80-1 /*the LINESIZE bif would be nicer*/ +parse arg hp cp win die _ . '(' names ")" /*obtain optional arguments.*/ +if _\=='' then call err 'too many arguments were specified: ' _ +@nhp = 'number of human players' ; hp = scrutinize( hp, @nhp ,0, 0) +@ncp = 'number of computer players'; cp = scrutinize( cp, @ncp ,0, 0) +@sn2w = 'score needed to win' ; win = scrutinize(win, @sn2w ,1,100) +@nsid = 'number of sides in die' ; die = scrutinize(die, @nsid ,2, 6) +if hp==0 & cp==0 then cp=2 /*if both counts are zero, 2 HALs*/ +if hp==1 & cp==0 then cp=1 /*if one human, then use 1 HAL.*/ +L=0 /*maximum length of a player name*/ + do i=1 for hp+cp /*get the player's names, maybe. */ + if i>hp then @='HAL_'i"_the_computer" /*use this for default.*/ + else @='player_'i /* " " " " */ + name.i = translate( word( strip( word(names,i)) @, 1),,'_') + L=max(L, length(name.i)) /*use L for nice name formatting.*/ + end /*i*/ /*underscores are changed─�blanks*/ + +hpn=hp; if hpn==0 then hpn='no' /*use normal English for display.*/ +cpn=cp; if cpn==0 then cpn="no" /* " " " " " */ +say 'Pig (the dice game) is being played with' + if cpn\==0 then say right(cpn,9) 'computer player's(cp) + if hpn\==0 then say right(hpn,9) 'human player's(hp) +say 'and the' @sn2w "is: " win ' (or greater).' +!.=; dieNames='ace duece trey square nickle boxcar' /*die face names.*/ + /*note: snake eyes is for 2 aces.*/ + do i=1 for 6; !.i=' ['word(dieNames,i)"] "; end /*i*/ +s.=0 /*set all player's scores to zero*/ +@=copies('─',9) /*an eyecatcher (for prompting). */ +@jra='just rolled a '; @ati=', and the inning' /*nice literals to have.*/ +/*──────────────────────────────────────────────────let's play some pig.*/ + do game=1; in.=0 /*set each inning's score to zero*/ + say; say copies('█',sw) /*display a fence for da eyeballs*/ + + do k=1 for hp+cp /*display the scores (as a recap)*/ + say 'The score for' left(name.k,L) "is " right(s.k,length(win))'.' + end /*k*/ + + say copies('█',sw) /*display a fence for da eyeballs*/ + + do j=1 for hp+cp /*let each player roll their dice*/ + say; say copies('─',sw); /*display a fence for da eyeballs*/ + it=word('You It', 1 + (j>hp)) /*pronoun choice: You or It */ + say name.j', your total score (so far) in this pig game is:' s.j"." + + do until stopped /*keep prompting/rolling 'til not*/ + r=random(1,die); !=space(r !.r) /*for color, use a die-face name.*/ + in.j=in.j+r + if r==1 then do; say it @jra ! || @ati "is a bust."; leave; end + say it @jra ! || @ati "total is:" in.j + stopped=what2do(j) /*determine|ask to stop rolling.*/ + if j>hp & stopped then say ' and' name.j "elected to stop rolling." + end /*until stopped*/ + + if r\==1 then s.j=s.j+in.j /*if not a bust, then add inning.*/ + if s.j>=win then leave game /*we have a winner, so game ends.*/ + end /*j*/ /*that's the end of the players. */ + end /*game*/ + +say; say; say; say; say center(''name.j "won! ",sw,'═'); say; say; exit +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────S subroutine────────────────────────*/ +s: if arg(1)==1 then return arg(3); return word(arg(2) 's',1) /*plural?*/ +/*──────────────────────────────────SCRUTINIZE subroutine───────────────*/ +scrutinize: parse arg ?,what,minimum /*? is the number, or maybe not. */ +if ?=='' | ?==',' then return arg(4) +if \datatype(?,'N') then call err what "isn't numeric: " ?; ?=?/1 +if \datatype(?,'W') then call err what "isn't an integer: " ? +if ?==0 & minimum>0 then call err what "can't be zero." +if ?hp & r+in.j>=win) then return 1 /*an easy choice for HAL.*/ +if (j>hp & in.j>=win%4) then return 1 /*a simple stategy for HAL.*/ +if j>hp then return 0 /*HAL says, keep truckin'! */ +say @ name.who', what do you want to do? (a QUIT will stop the game),' +say @ 'press ENTER to roll again, or anything else to STOP rolling.' +pull action; action=space(action) /*remove any superfluous blanks. */ +if \abbrev('QUIT',action,1) then return action\=='' +say; say; say; say center(' quitting. ',sw,'─'); say; say; say; exit +/*───────────────────────────────error handling subroutines and others.─*/ +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) diff --git a/Task/Pig-the-dice-game-Player/Tcl/pig-the-dice-game-player-1.tcl b/Task/Pig-the-dice-game-Player/Tcl/pig-the-dice-game-player-1.tcl new file mode 100644 index 0000000000..97b224f10d --- /dev/null +++ b/Task/Pig-the-dice-game-Player/Tcl/pig-the-dice-game-player-1.tcl @@ -0,0 +1,107 @@ +package require TclOO + +oo::class create Player { + variable me + constructor {name} { + set me $name + } + method name {} { + return $me + } + + method wantToRoll {safeScore roundScore} {} + + method rolled {who what} { + if {$who ne [self]} { + #puts "[$who name] rolled a $what" + } + } + method turnend {who score} { + if {$who ne [self]} { + #puts "End of turn for [$who name] on $score" + } + } + method winner {who score} { + if {$who ne [self]} { + #puts "[$who name] is a winner, on $score" + } + } +} + +oo::class create HumanPlayer { + variable me + superclass Player + method wantToRoll {safeScore roundScore} { + while 1 { + puts -nonewline "$me (on $safeScore+$roundScore) do you want to roll? (Y/n)" + flush stdout + if {[gets stdin line] < 0} { + # EOF detected + puts "" + exit + } + if {$line eq "" || $line eq "y" || $line eq "Y"} { + return 1 + } + if {$line eq "n" || $line eq "N"} { + return 0 + } + } + } + method stuck {score} { + puts "$me sticks with score $score" + } + method busted {score} { + puts "Busted! ($me still on score $score)" + } + method won {score} { + puts "$me has won! (Score: $score)" + } +} + +proc rollDie {} { + expr {1+int(rand() * 6)} +} +proc rotateList {var} { + upvar 1 $var l + set l [list {*}[lrange $l 1 end] [lindex $l 0]] +} +proc broadcast {players message score} { + set p0 [lindex $players 0] + foreach p $players { + $p $message $p0 $score + } +} + +proc pig {args} { + set players $args + set scores [lrepeat [llength $args] 0] + while 1 { + set player [lindex $players 0] + set safe [lindex $scores 0] + set s 0 + while 1 { + if {$safe + $s >= 100} { + incr safe $s + $player won $safe + broadcast $players winner $safe + return $player + } + if {![$player wantToRoll $safe $s]} { + lset scores 0 [incr safe $s] + $player stuck $safe + break + } + set roll [rollDie] + broadcast $players rolled $roll + if {$roll == 1} { + $player busted $safe + break + } + incr s $roll + } + broadcast $players turnend $safe + rotateList players + rotateList scores + } +} diff --git a/Task/Pig-the-dice-game-Player/Tcl/pig-the-dice-game-player-2.tcl b/Task/Pig-the-dice-game-Player/Tcl/pig-the-dice-game-player-2.tcl new file mode 100644 index 0000000000..c9f6583d0c --- /dev/null +++ b/Task/Pig-the-dice-game-Player/Tcl/pig-the-dice-game-player-2.tcl @@ -0,0 +1,61 @@ +oo::class create RoboPlayer { + superclass Player + variable me + constructor {name} { + # Add a symbol to the name to mark a robot... + next "$name\u00ae" + } + method wantToRoll {safeScore roundScore} { + puts -nonewline "$me has ($safeScore,$roundScore)... " + set decision [my Decide $safeScore $roundScore] + puts [lindex {stick roll} $decision] + return $decision + } + method stuck {score} { + puts "$me sticks with score $score" + } + method busted {score} { + puts "Busted! ($me still on score $score)" + } + method won {score} { + puts "$me has won! (Score: $score)" + } +} + +# Just takes a random decision as to what to play +oo::class create RandomPlayer { + superclass RoboPlayer + constructor {} {next "Random"} + method Decide {a b} {expr {rand() < 0.5}} +} + +# Rolls until it scores at least 20 from a round or goes bust +oo::class create To20Player { + superclass RoboPlayer + constructor {} {next "To20"} + method Decide {safeScore roundScore} {expr {$roundScore < 20}} +} + +# Like To20, but will roll desperately once another player reaches 80 +oo::class create Desperate { + superclass RoboPlayer + variable me scores + constructor {} { + next "Desperate" + set scores {} + } + + method Decide {safeScore roundScore} { + dict for {who val} $scores { + if {$who ne [self] && $val >= 80} { + return 1 + } + } + return [expr {$roundScore < 20}] + } + # Keep an eye on other players + method turnend {who score} { + next $who $score + dict set scores $who $score + } +} diff --git a/Task/Pig-the-dice-game-Player/Tcl/pig-the-dice-game-player-3.tcl b/Task/Pig-the-dice-game-Player/Tcl/pig-the-dice-game-player-3.tcl new file mode 100644 index 0000000000..520848ba7d --- /dev/null +++ b/Task/Pig-the-dice-game-Player/Tcl/pig-the-dice-game-player-3.tcl @@ -0,0 +1 @@ +pig [RandomPlayer new] [To20Player new] [Desperate new] diff --git a/Task/Pig-the-dice-game/0DESCRIPTION b/Task/Pig-the-dice-game/0DESCRIPTION new file mode 100644 index 0000000000..95c70b39a4 --- /dev/null +++ b/Task/Pig-the-dice-game/0DESCRIPTION @@ -0,0 +1,12 @@ +The [[wp:Pig (dice)|game of Pig]] is a multiplayer game played with a single six-sided die. The +object of the game is to reach 100 points or more. +Play is taken in turns. On each person's turn that person has the option of either + +# '''Rolling the dice''': where a roll of two to six is added to their score for that turn and the player's turn continues as the player is given the same choice again; or a roll of 1 loses the player's total points ''for that turn'' and their turn finishes with play passing to the next player. +# '''Holding''': The player's score for that round is added to their total and becomes safe from the effects of throwing a one. The player's turn finishes with play passing to the next player. + +;Task goal: +The goal of this task is to create a program to score for, and simulate dice throws for, a two-person game. + +;Cf: +* [[Pig the dice game/Player]] diff --git a/Task/Pig-the-dice-game/Ada/pig-the-dice-game-1.ada b/Task/Pig-the-dice-game/Ada/pig-the-dice-game-1.ada new file mode 100644 index 0000000000..ed543efbf6 --- /dev/null +++ b/Task/Pig-the-dice-game/Ada/pig-the-dice-game-1.ada @@ -0,0 +1,23 @@ +package Pig is + + type Dice_Score is range 1 .. 6; + + type Player is tagged private; + function Recent(P: Player) return Natural; + function All_Recent(P: Player) return Natural; + function Score(P: Player) return Natural; + + type Actor is abstract tagged null record; + function Roll_More(A: Actor; Self, Opponent: Player'Class) + return Boolean is abstract; + + procedure Play(First, Second: Actor'Class; First_Wins: out Boolean); + +private + type Player is tagged record + Score: Natural := 0; + All_Recent: Natural := 0; + Recent_Roll: Dice_Score := 1; + end record; + +end Pig; diff --git a/Task/Pig-the-dice-game/Ada/pig-the-dice-game-2.ada b/Task/Pig-the-dice-game/Ada/pig-the-dice-game-2.ada new file mode 100644 index 0000000000..ff98a48a29 --- /dev/null +++ b/Task/Pig-the-dice-game/Ada/pig-the-dice-game-2.ada @@ -0,0 +1,51 @@ +with Ada.Numerics.Discrete_Random; +package body Pig is + + function Score(P: Player) return Natural is (P.Score); + function All_Recent(P: Player) return Natural is (P.All_Recent); + function Recent(P: Player) return Natural is (Natural(P.Recent_Roll)); + function Has_Won(P: Player) return Boolean is (P.Score >= 100); + + package RND is new Ada.Numerics.Discrete_Random(Dice_Score); + Gen: RND.Generator; + + procedure Roll(P: in out Player) is + begin + P.Recent_Roll := RND.Random(Gen); + if P.Recent = 1 then + P.All_Recent := 0; + else + P.All_Recent := P.All_Recent + P.Recent; + end if; + end Roll; + + procedure Add_To_Score(P: in out Player) is + begin + P.Score := P.Score + P.All_Recent; + P.All_Recent := 0; + end Add_To_Score; + + procedure Play(First, Second: Actor'Class; + First_Wins: out Boolean) is + P1, P2: Player; + begin + loop + Roll(P1); + while First.Roll_More(P1, P2) and then P1.Recent > 1 loop + Roll(P1); + end loop; + Add_To_Score(P1); + exit when P1.Score >= 100; + Roll(P2); + while Second.Roll_More(P2, P1) and then P2.Recent > 1 loop + Roll(P2); + end loop; + Add_To_Score(P2); + exit when P2.Score >= 100; + end loop; + First_Wins := P1.Score >= 100; + end Play; + +begin + RND.Reset(Gen); +end Pig; diff --git a/Task/Pig-the-dice-game/Ada/pig-the-dice-game-3.ada b/Task/Pig-the-dice-game/Ada/pig-the-dice-game-3.ada new file mode 100644 index 0000000000..f87d3b96f5 --- /dev/null +++ b/Task/Pig-the-dice-game/Ada/pig-the-dice-game-3.ada @@ -0,0 +1,32 @@ +with Pig, Ada.Text_IO; + +procedure Play_Pig is + + use Pig; + + type Hand is new Actor with record + Name: String(1 .. 5); + end record; + function Roll_More(A: Hand; Self, Opponent: Player'Class) return Boolean; + + function Roll_More(A: Hand; Self, Opponent: Player'Class) return Boolean is + Ch: Character := ' '; + use Ada.Text_IO; + begin + Put(A.Name & " you:" & Natural'Image(Self.Score) & + " (opponent:" & Natural'Image(Opponent.Score) & + ") this round:" & Natural'Image(Self.All_Recent) & + " this roll:" & Natural'Image(Self.Recent) & + "; add to score(+)?"); + Get(Ch); + return Ch /= '+'; + end Roll_More; + + A1: Hand := (Name => "Alice"); + A2: Hand := (Name => "Bob "); + + Alice: Boolean; +begin + Play(A1, A2, Alice); + Ada.Text_IO.Put_Line("Winner = " & (if Alice then "Alice!" else "Bob!")); +end Play_Pig; diff --git a/Task/Pig-the-dice-game/Common-Lisp/pig-the-dice-game.lisp b/Task/Pig-the-dice-game/Common-Lisp/pig-the-dice-game.lisp new file mode 100644 index 0000000000..30224c01d1 --- /dev/null +++ b/Task/Pig-the-dice-game/Common-Lisp/pig-the-dice-game.lisp @@ -0,0 +1,32 @@ +(defconstant +max-score+ 100) +(defconstant +n-of-players+ 2) + +(let ((scores (make-list +n-of-players+ :initial-element 0)) + (current-player 0) + (round-score 0)) + (loop + (format t "Player ~d: (~d, ~d). Rolling? (Y)" + current-player + (nth current-player scores) + round-score) + (if (member (read-line) '("y" "yes" "") :test #'string=) + (let ((roll (1+ (random 6)))) + (format t "~tRolled ~d~%" roll) + (if (= roll 1) + (progn + (format t + "~tBust! you lose ~d but still keep your previous ~d~%" + round-score (nth current-player scores)) + (setf round-score 0) + (setf current-player + (mod (1+ current-player) +n-of-players+))) + (incf round-score roll))) + (progn + (incf (nth current-player scores) round-score) + (setf round-score 0) + (when (>= (apply #'max scores) 100) + (return)) + (format t "~tSticking with ~d~%" (nth current-player scores)) + (setf current-player (mod (1+ current-player) +n-of-players+))))) + (format t "~%Player ~d wins with a score of ~d~%" current-player + (nth current-player scores))) diff --git a/Task/Pig-the-dice-game/D/pig-the-dice-game.d b/Task/Pig-the-dice-game/D/pig-the-dice-game.d new file mode 100644 index 0000000000..f6c0c38c12 --- /dev/null +++ b/Task/Pig-the-dice-game/D/pig-the-dice-game.d @@ -0,0 +1,38 @@ +import std.stdio, std.string, std.algorithm, std.random; + +void main() { + enum maxScore = 100; + enum playerCount = 2; + immutable confirmations = ["yes", "y", ""]; + + int[playerCount] safeScore; + int player, score; + + while (true) { + writef(" Player %d: (%d, %d). Rolling? (y/n) ", player, + safeScore[player], score); + if (safeScore[player] + score < maxScore && + confirmations.canFind(readln().strip().toLower())) { + immutable int rolled = uniform(1, 7); + writefln(" Rolled %d", rolled); + if (rolled == 1) { + writefln(" Bust! You lose %d but keep %d\n", + score, safeScore[player]); + } else { + score += rolled; + continue; + } + } else { + safeScore[player] += score; + if (safeScore[player] >= maxScore) + break; + writefln(" Sticking with %d\n", safeScore[player]); + } + + score = 0; + player = (player + 1) % playerCount; + } + + writefln("\n\nPlayer %d wins with a score of %d", + player, safeScore[player]); +} diff --git a/Task/Pig-the-dice-game/Forth/pig-the-dice-game.fth b/Task/Pig-the-dice-game/Forth/pig-the-dice-game.fth new file mode 100644 index 0000000000..10243d1b6d --- /dev/null +++ b/Task/Pig-the-dice-game/Forth/pig-the-dice-game.fth @@ -0,0 +1,21 @@ +include lib/choose.4th +include lib/yesorno.4th + +: turn ( n1 -- n2) + ." Player " . ." is up" cr \ which player is up + 0 begin \ nothing so far + s" Rolling" yes/no? \ stand or roll? + while \ now roll the dice + 6 choose 1+ dup ." Rolling " . dup 1 = + if drop drop 0 else + ." (" dup 0 .r ." )" then cr dup 0= + until \ until player stands or 1 is rolled +; + +: pigthedice ( --) + 2 0 1 over \ setup players + begin over turn + dup ." Total score: " . cr cr dup 100 < while 2swap repeat + ." Player " swap . ." won with " . ." points." cr + ." Player " swap . ." lost with " . ." points." cr +; \ show the results + +pigthedice diff --git a/Task/Pig-the-dice-game/Groovy/pig-the-dice-game.groovy b/Task/Pig-the-dice-game/Groovy/pig-the-dice-game.groovy new file mode 100644 index 0000000000..d24edba167 --- /dev/null +++ b/Task/Pig-the-dice-game/Groovy/pig-the-dice-game.groovy @@ -0,0 +1,94 @@ +class PigDice { + + final static int maxScore = 100; + final static yesses = ["yes", "y", "", "Y", "YES"] + + static main(args) { + def playersCount = 2 + Scanner sc = new Scanner(System.in) + Map scores = [:] + def current = 0 + def player = 0 + def gameOver = false + def firstThrow = true + Random rnd = new Random() + + // Initialise the players' scores + (0..(playersCount-1)).each{ it-> + scores[it] = 0 + } + + // Game starts + while (!gameOver) { + def nextPlayer = false + String ln + + // Automatic rolls for the first dice roll + if (firstThrow){ + println "player ${player+1} Auto Rolling... " + ln = 'y' + firstThrow = false + } else { + println "player ${player+1} Rolling? Yes(y) or No(n) " + ln = sc.nextLine() + } + + if (ln in yesses){ + // if yes then roll the dice + int rolled = rnd.nextInt(6) + 1 + print "The Roll was $rolled --- " + + if (rolled == 1) { + println " Bust! Player ${player+1} loses $current but keep ${scores[player]}" + current = 0 + nextPlayer = true + firstThrow = true + } else { + // dice rolls 2 to 6 + current = current + rolled + if ((current + scores[player]) > maxScore){ + gameOver = true + }else{ + // as a session score gets larger the message returned changes + switch (current){ + case 6..15: + print "Good. " + break + case 15..29: + print "lucky! " + break + case 29..39: + print "Great! " + break + default: + print "Amazing " + } + println "Player ${player+1} now has $current this session (possible score of ${current + scores[player]})" + } + } + } else{ + // if no then bank the session score + nextPlayer = true + firstThrow = true + scores[player] = scores[player] + current + current = 0 + println "chicken! player ${player+1} now has ${scores[player]} and $gameOver" + println "Current scores :" + for (i in scores){ + println "player ${i.key + 1}| ${i.value} " + } + println "------------------------------" + + } + println "" + + if (nextPlayer) { + player = (player+1)%playersCount + println "** Next player is ${player+1}" + } + } + + // Game ends + println "Player ${player+1} wins" + } +} diff --git a/Task/Pig-the-dice-game/J/pig-the-dice-game-1.j b/Task/Pig-the-dice-game/J/pig-the-dice-game-1.j new file mode 100644 index 0000000000..cf4bb41164 --- /dev/null +++ b/Task/Pig-the-dice-game/J/pig-the-dice-game-1.j @@ -0,0 +1,41 @@ +require'misc' + +status=:3 :0 + 'pid cur tot'=. y + player=. 'player ',":pid + potential=. ' potential: ',":cur + total=. ' total: ',":tot + smoutput player,potential,total +) + +getmove=:3 :0 + whilst.1~:+/choice do. + choice=.'HRQ' e. prompt ' Roll the dice or Hold or Quit? [R or H or Q]: ' + end. + choice#'HRQ' +) + +NB. simulate an y player game of pig +pigsim=:3 :0 + smoutput (":y),' player game of pig' + scores=.y#0 + while.100>>./scores do. + for_player.=i.y do. + pid=.1+I.player + smoutput 'begining of turn for player ',":pid + current=. 0 + whilst. (1 ~: roll) *. 'R' = move do. + status pid, current, player+/ .*scores + move=. getmove'' + roll=. 1+?6 + if.'R'=move do. + smoutput 'rolled a ',":roll + current=. (1~:roll)*current+roll + end. + end. + scores=. scores+(current*player)+100*('Q'e.move)*-.player + smoutput 'player scores now: ',":scores + end. + end. + smoutput 'player ',(":1+I.scores>:100),' wins' +) diff --git a/Task/Pig-the-dice-game/J/pig-the-dice-game-2.j b/Task/Pig-the-dice-game/J/pig-the-dice-game-2.j new file mode 100644 index 0000000000..b5d783fdc7 --- /dev/null +++ b/Task/Pig-the-dice-game/J/pig-the-dice-game-2.j @@ -0,0 +1,62 @@ + pigsim 2 +2 player game of pig +begining of turn for player 1 +player 1 potential: 0 total: 0 + Roll the dice or Hold or Quit? [R or H or Q]: R +rolled a 3 +player 1 potential: 3 total: 0 + Roll the dice or Hold or Quit? [R or H or Q]: R +rolled a 6 +player 1 potential: 9 total: 0 + Roll the dice or Hold or Quit? [R or H or Q]: R +rolled a 4 +player 1 potential: 13 total: 0 + Roll the dice or Hold or Quit? [R or H or Q]: R +rolled a 6 +player 1 potential: 19 total: 0 + Roll the dice or Hold or Quit? [R or H or Q]: R +rolled a 2 +player 1 potential: 21 total: 0 + Roll the dice or Hold or Quit? [R or H or Q]: H +player scores now: 21 0 +begining of turn for player 2 +player 2 potential: 0 total: 0 + Roll the dice or Hold or Quit? [R or H or Q]: R +rolled a 3 +player 2 potential: 3 total: 0 + Roll the dice or Hold or Quit? [R or H or Q]: R +rolled a 6 +player 2 potential: 9 total: 0 + Roll the dice or Hold or Quit? [R or H or Q]: R +rolled a 4 +player 2 potential: 13 total: 0 + Roll the dice or Hold or Quit? [R or H or Q]: R +rolled a 6 +player 2 potential: 19 total: 0 + Roll the dice or Hold or Quit? [R or H or Q]: R +rolled a 3 +player 2 potential: 22 total: 0 + Roll the dice or Hold or Quit? [R or H or Q]: H +player scores now: 21 22 +begining of turn for player 1 +player 1 potential: 0 total: 21 + Roll the dice or Hold or Quit? [R or H or Q]: R + +... + + Roll the dice or Hold or Quit? [R or H or Q]: R +rolled a 6 +player 1 potential: 22 total: 62 + Roll the dice or Hold or Quit? [R or H or Q]: H +player scores now: 84 90 +begining of turn for player 2 +player 2 potential: 0 total: 90 + Roll the dice or Hold or Quit? [R or H or Q]: R +rolled a 6 +player 2 potential: 6 total: 90 + Roll the dice or Hold or Quit? [R or H or Q]: R +rolled a 6 +player 2 potential: 12 total: 90 + Roll the dice or Hold or Quit? [R or H or Q]: H +player scores now: 84 102 +player 2 wins diff --git a/Task/Pig-the-dice-game/Java/pig-the-dice-game.java b/Task/Pig-the-dice-game/Java/pig-the-dice-game.java new file mode 100644 index 0000000000..6160fa4caa --- /dev/null +++ b/Task/Pig-the-dice-game/Java/pig-the-dice-game.java @@ -0,0 +1,42 @@ +import java.util.*; + +public class PigDice { + + public static void main(String[] args) { + final int maxScore = 100; + final int playerCount = 2; + final String[] yesses = {"y", "Y", ""}; + + int[] safeScore = new int[2]; + int player = 0, score = 0; + + Scanner sc = new Scanner(System.in); + Random rnd = new Random(); + + while (true) { + System.out.printf(" Player %d: (%d, %d) Rolling? (y/n) ", player, + safeScore[player], score); + if (safeScore[player] + score < maxScore + && Arrays.asList(yesses).contains(sc.nextLine())) { + final int rolled = rnd.nextInt(6) + 1; + System.out.printf(" Rolled %d\n", rolled); + if (rolled == 1) { + System.out.printf(" Bust! You lose %d but keep %d\n\n", + score, safeScore[player]); + } else { + score += rolled; + continue; + } + } else { + safeScore[player] += score; + if (safeScore[player] >= maxScore) + break; + System.out.printf(" Sticking with %d\n\n", safeScore[player]); + } + score = 0; + player = (player + 1) % playerCount; + } + System.out.printf("\n\nPlayer %d wins with a score of %d", + player, safeScore[player]); + } +} diff --git a/Task/Pig-the-dice-game/Mathematica/pig-the-dice-game.math b/Task/Pig-the-dice-game/Mathematica/pig-the-dice-game.math new file mode 100644 index 0000000000..fd8bb98855 --- /dev/null +++ b/Task/Pig-the-dice-game/Mathematica/pig-the-dice-game.math @@ -0,0 +1,18 @@ +DynamicModule[{score, players = {1, 2}, roundscore = 0, + roll}, (score@# = 0) & /@ players; + Panel@Dynamic@ + Column@{Grid[ + Prepend[{#, score@#} & /@ players, {"Player", "Score"}], + Background -> {None, 2 -> Gray}], roundscore, + If[ValueQ@roll, Row@{"Rolled ", roll}, ""], + If[IntegerQ@roundscore, + Row@{Button["Roll", roll = RandomInteger[{1, 6}]; + If[roll == 1, roundscore = 0; players = RotateLeft@players, + roundscore += roll]], + Button["Hold", score[players[[1]]] += roundscore; + roundscore = 0; + If[score[players[[1]]] >= 100, roll =.; + roundscore = Row@{players[[1]], " wins."}, + players = RotateLeft@players]]}, + Button["Play again.", + roundscore = 0; (score@# = 0) & /@ players]]}] diff --git a/Task/Pig-the-dice-game/PHP/pig-the-dice-game.php b/Task/Pig-the-dice-game/PHP/pig-the-dice-game.php new file mode 100644 index 0000000000..fe7518321e --- /dev/null +++ b/Task/Pig-the-dice-game/PHP/pig-the-dice-game.php @@ -0,0 +1,32 @@ +error_reporting(E_ALL & ~ ( E_NOTICE | E_WARNING )); + +define('MAXSCORE', 100); +define('PLAYERCOUNT', 2); + +$confirm = array('Y', 'y', ''); + +while (true) { + printf(' Player %d: (%d, %d) Rolling? (Yn) ', $player, + $safeScore[$player], $score); + if ($safeScore[$player] + $score < MAXSCORE && + in_array(trim(fgets(STDIN)), $confirm)) { + $rolled = rand(1, 6); + echo " Rolled $rolled \n"; + if ($rolled == 1) { + printf(' Bust! You lose %d but keep %d \n\n', + $score, $safeScore[$player]); + } else { + $score += $rolled; + continue; + } + } else { + $safeScore[$player] += $score; + if ($safeScore[$player] >= MAXSCORE) + break; + echo ' Sticking with ', $safeScore[$player], '\n\n'; + } + $score = 0; + $player = ($player + 1) % PLAYERCOUNT; +} +printf('\n\nPlayer %d wins with a score of %d ', + $player, $safeScore[$player]); diff --git a/Task/Pig-the-dice-game/Perl-6/pig-the-dice-game.pl6 b/Task/Pig-the-dice-game/Perl-6/pig-the-dice-game.pl6 new file mode 100644 index 0000000000..44d868f642 --- /dev/null +++ b/Task/Pig-the-dice-game/Perl-6/pig-the-dice-game.pl6 @@ -0,0 +1,32 @@ +constant DIE = 1..6; + +sub MAIN (Int :$players = 2, Int :$goal = 100) { + my @safe = 0 xx $players; + for ^$players xx * -> $player { + say "\nOK, player #$player is up now."; + my $safe = @safe[$player]; + my $ante = 0; + until $safe + $ante >= $goal or + prompt("#$player, you have $safe + $ante = {$safe+$ante}. Roll? [Yn] ") ~~ /:i ^n/ + { + given DIE.roll { + say " You rolled a $_."; + when 1 { + say " Bust! You lose $ante but keep your previous $safe."; + $ante = 0; + last; + } + when 2..* { + $ante += $_; + } + } + } + $safe += $ante; + if $safe >= $goal { + say "\nPlayer #$player wins with a score of $safe!"; + last; + } + @safe[$player] = $safe; + say " Sticking with $safe." if $ante; + } +} diff --git a/Task/Pig-the-dice-game/Python/pig-the-dice-game.py b/Task/Pig-the-dice-game/Python/pig-the-dice-game.py new file mode 100644 index 0000000000..f238b8a169 --- /dev/null +++ b/Task/Pig-the-dice-game/Python/pig-the-dice-game.py @@ -0,0 +1,37 @@ +#!/usr/bin/python3 + +''' +See: http://en.wikipedia.org/wiki/Pig_(dice) + +This program scores and throws the dice for a two player game of Pig + +''' + +from random import randint + +playercount = 2 +maxscore = 100 +safescore = [0] * playercount +player = 0 +score=0 + +while max(safescore) < maxscore: + rolling = input("Player %i: (%i, %i) Rolling? (Y) " + % (player, safescore[player], score)).strip().lower() in {'yes', 'y', ''} + if rolling: + rolled = randint(1, 6) + print(' Rolled %i' % rolled) + if rolled == 1: + print(' Bust! you lose %i but still keep your previous %i' + % (score, safescore[player])) + score, player = 0, (player + 1) % playercount + else: + score += rolled + else: + safescore[player] += score + if safescore[player] >= maxscore: + break + print(' Sticking with %i' % safescore[player]) + score, player = 0, (player + 1) % playercount + +print('\nPlayer %i wins with a score of %i' %(player, safescore[player])) diff --git a/Task/Pig-the-dice-game/REXX/pig-the-dice-game.rexx b/Task/Pig-the-dice-game/REXX/pig-the-dice-game.rexx new file mode 100644 index 0000000000..83cf5fa485 --- /dev/null +++ b/Task/Pig-the-dice-game/REXX/pig-the-dice-game.rexx @@ -0,0 +1,89 @@ +/*REXX program plays pig (the dice game) with at least one human player.*/ +signal on syntax; signal on novalue /*handle REXX program errors. */ +sw=80-1 /*the LINESIZE bif would be nicer*/ +parse arg hp cp win die _ . '(' names ")" /*obtain optional arguments.*/ +if _\=='' then call err 'too many arguments were specified: ' _ +@nhp = 'number of human players' ; hp = scrutinize( hp, @nhp ,0, 0) +@ncp = 'number of computer players'; cp = scrutinize( cp, @ncp ,0, 0) +@sn2w = 'score needed to win' ; win = scrutinize(win, @sn2w ,1,100) +@nsid = 'number of sides in die' ; die = scrutinize(die, @nsid ,2, 6) +if hp==0 & cp==0 then cp=2 /*if both counts are zero, 2 HALs*/ +if hp==1 & cp==0 then cp=1 /*if one human, then use 1 HAL.*/ +L=0 /*maximum length of a player name*/ + do i=1 for hp+cp /*get the player's names, maybe. */ + if i>hp then @='HAL_'i"_the_computer" /*use this for default.*/ + else @='player_'i /* " " " " */ + name.i = translate( word( strip( word(names,i)) @, 1),,'_') + L=max(L, length(name.i)) /*use L for nice name formatting.*/ + end /*i*/ /*underscores are changed─�blanks*/ + +hpn=hp; if hpn==0 then hpn='no' /*use normal English for display.*/ +cpn=cp; if cpn==0 then cpn="no" /* " " " " " */ +say 'Pig (the dice game) is being played with' + if cpn\==0 then say right(cpn,9) 'computer player's(cp) + if hpn\==0 then say right(hpn,9) 'human player's(hp) +say 'and the' @sn2w "is: " win ' (or greater).' +!.=; dieNames='ace duece trey square nickle boxcar' /*die face names.*/ + /*note: snake eyes is for 2 aces.*/ + do i=1 for 6; !.i=' ['word(dieNames,i)"] "; end /*i*/ +s.=0 /*set all player's scores to zero*/ +@=copies('─',9) /*an eyecatcher (for prompting). */ +@jra='just rolled a '; @ati=', and the inning' /*nice literals to have.*/ +/*──────────────────────────────────────────────────let's play some pig.*/ + do game=1; in.=0 /*set each inning's score to zero*/ + say; say copies('█',sw) /*display a fence for da eyeballs*/ + + do k=1 for hp+cp /*display the scores (as a recap)*/ + say 'The score for' left(name.k,L) "is " right(s.k,length(win))'.' + end /*k*/ + + say copies('█',sw) /*display a fence for da eyeballs*/ + + do j=1 for hp+cp /*let each player roll their dice*/ + say; say copies('─',sw); /*display a fence for da eyeballs*/ + it=word('You It', 1 + (j>hp)) /*pronoun choice: You or It */ + say name.j', your total score (so far) in this pig game is:' s.j"." + + do until stopped /*keep prompting/rolling 'til not*/ + r=random(1,die); !=space(r !.r) /*for color, use a die-face name.*/ + in.j=in.j+r + if r==1 then do; say it @jra ! || @ati "is a bust."; leave; end + say it @jra ! || @ati "total is:" in.j + stopped=what2do(j) /*determine|ask to stop rolling.*/ + if j>hp & stopped then say ' and' name.j "elected to stop rolling." + end /*until stopped*/ + + if r\==1 then s.j=s.j+in.j /*if not a bust, then add inning.*/ + if s.j>=win then leave game /*we have a winner, so game ends.*/ + end /*j*/ /*that's the end of the players. */ + end /*game*/ + +say; say; say; say; say center(''name.j "won! ",sw,'═'); say; say; exit +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────S subroutine────────────────────────*/ +s: if arg(1)==1 then return arg(3); return word(arg(2) 's',1) /*plural?*/ +/*──────────────────────────────────SCRUTINIZE subroutine───────────────*/ +scrutinize: parse arg ?,what,minimum /*? is the number, or maybe not. */ +if ?=='' | ?==',' then return arg(4) +if \datatype(?,'N') then call err what "isn't numeric: " ?; ?=?/1 +if \datatype(?,'W') then call err what "isn't an integer: " ? +if ?==0 & minimum>0 then call err what "can't be zero." +if ?hp & r+in.j>=win) then return 1 /*an easy choice for HAL.*/ +if (j>hp & in.j>=win%4) then return 1 /*a simple stategy for HAL.*/ +if j>hp then return 0 /*HAL says, keep truckin'! */ +say @ name.who', what do you want to do? (a QUIT will stop the game),' +say @ 'press ENTER to roll again, or anything else to STOP rolling.' +pull action; action=space(action) /*remove any superfluous blanks. */ +if \abbrev('QUIT',action,1) then return action\=='' +say; say; say; say center(' quitting. ',sw,'─'); say; say; say; exit +/*───────────────────────────────error handling subroutines and others.─*/ +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) diff --git a/Task/Pig-the-dice-game/Ruby/pig-the-dice-game.rb b/Task/Pig-the-dice-game/Ruby/pig-the-dice-game.rb new file mode 100644 index 0000000000..d6557cf47c --- /dev/null +++ b/Task/Pig-the-dice-game/Ruby/pig-the-dice-game.rb @@ -0,0 +1,36 @@ +class PigGame + Player = Struct.new(:name, :safescore, :score) do + def bust!() self.score = safescore end + def stay!() self.safescore = score end + def roll!(die_sides) rand(1..die_sides) end + def wants_to_roll? + print("#{name} (#{safescore}, #{score})", ": Roll? (Y) ") + ['Y','y',''].include?(gets.chomp) + end + end + + def bust?(roll) roll==1 ? (puts("Busted!",'') || true) : false end + + def play(names, maxscore=100, die_sides=6) + rotation = names.map {|name| Player.new(name,0,0) }.cycle + + while player = rotation.next + loop do + if player.wants_to_roll? + puts "Rolled: #{roll=player.roll!(die_sides)}" + if bust?( roll ) + player.bust! && break + else + player.score += roll + return player if player.score >= maxscore + end + else + player.stay! && puts("Staying with #{player.safescore}!", '') + break + end + end + end + end +end + +print PigGame.new.play( %w|Samuel Elizabeth| ).name, " wins!" diff --git a/Task/Pig-the-dice-game/Run-BASIC/pig-the-dice-game.run b/Task/Pig-the-dice-game/Run-BASIC/pig-the-dice-game.run new file mode 100644 index 0000000000..66aa13ec95 --- /dev/null +++ b/Task/Pig-the-dice-game/Run-BASIC/pig-the-dice-game.run @@ -0,0 +1,26 @@ +numPlayers = 2 +maxScore = 100 +dim safeScore(numPlayers) + +[loop] +for player = 1 to numPlayers + score = 0 + + while safeScore(player) < maxScore + input "Player ";player;" Rolling? (Y) ";rolling$ + if upper$(rolling$) = "Y" then + rolled = int(rnd(0) * 5) + 1 + print "Player ";player;" rolled ";rolled + if rolled = 1 then + print "Bust! you lose player ";player;" but still keep your previous score of ";safeScore(plater) + exit while + end if + score = score + rolled + else + safeScore(player) = safeScore(player) + score + end if + wend +next player +goto [loop] +[winner] +print "Player ";plater;" wins with a score of ";safeScore(player) diff --git a/Task/Pig-the-dice-game/Tcl/pig-the-dice-game-1.tcl b/Task/Pig-the-dice-game/Tcl/pig-the-dice-game-1.tcl new file mode 100644 index 0000000000..257eb52fec --- /dev/null +++ b/Task/Pig-the-dice-game/Tcl/pig-the-dice-game-1.tcl @@ -0,0 +1,79 @@ +package require TclOO + +oo::class create Player { + variable me + constructor {name} { + set me $name + } + method name {} { + return $me + } + + method wantToRoll {safeScore roundScore} {} + method stuck {score} {} + method busted {score} {} + method won {score} {} + + method rolled {who what} { + if {$who ne [self]} { + #puts "[$who name] rolled a $what" + } + } + method turnend {who score} { + if {$who ne [self]} { + puts "End of turn for [$who name] on $score" + } + } + method winner {who score} { + if {$who ne [self]} { + puts "[$who name] is a winner, on $score" + } + } +} + +proc rollDie {} { + expr {1+int(rand() * 6)} +} +proc rotateList {var} { + upvar 1 $var l + set l [list {*}[lrange $l 1 end] [lindex $l 0]] +} +proc broadcast {players message score} { + set p0 [lindex $players 0] + foreach p $players { + $p $message $p0 $score + } +} + +proc pig {args} { + set players $args + set scores [lrepeat [llength $args] 0] + while 1 { + set player [lindex $players 0] + set safe [lindex $scores 0] + set s 0 + while 1 { + if {$safe + $s >= 100} { + incr safe $s + $player won $safe + broadcast $players winner $safe + return $player + } + if {![$player wantToRoll $safe $s]} { + lset scores 0 [incr safe $s] + $player stuck $safe + break + } + set roll [rollDie] + broadcast $players rolled $roll + if {$roll == 1} { + $player busted $safe + break + } + incr s $roll + } + broadcast $players turnend $safe + rotateList players + rotateList scores + } +} diff --git a/Task/Pig-the-dice-game/Tcl/pig-the-dice-game-2.tcl b/Task/Pig-the-dice-game/Tcl/pig-the-dice-game-2.tcl new file mode 100644 index 0000000000..7aa7708587 --- /dev/null +++ b/Task/Pig-the-dice-game/Tcl/pig-the-dice-game-2.tcl @@ -0,0 +1,32 @@ +oo::class create HumanPlayer { + variable me + superclass Player + method wantToRoll {safeScore roundScore} { + while 1 { + puts -nonewline "$me (on $safeScore+$roundScore) do you want to roll? (Y/n)" + flush stdout + if {[gets stdin line] < 0} { + # EOF detected + puts "" + exit + } + if {$line eq "" || $line eq "y" || $line eq "Y"} { + return 1 + } + if {$line eq "n" || $line eq "N"} { + return 0 + } + } + } + method stuck {score} { + puts "$me sticks with score $score" + } + method busted {score} { + puts "Busted! ($me still on score $score)" + } + method won {score} { + puts "$me has won! (Score: $score)" + } +} + +pig [HumanPlayer new "Alex"] [HumanPlayer new "Bert"] diff --git a/Task/Pig-the-dice-game/XPL0/pig-the-dice-game.xpl0 b/Task/Pig-the-dice-game/XPL0/pig-the-dice-game.xpl0 new file mode 100644 index 0000000000..c0210cf3bb --- /dev/null +++ b/Task/Pig-the-dice-game/XPL0/pig-the-dice-game.xpl0 @@ -0,0 +1,25 @@ +include c:\cxpl\codes; \intrinsic 'code' declarations +integer Player, Die, Points, Score(2); +[Score(0):= 0; Score(1):= 0; \starting scores for each player +Player:= 1; \second player +repeat Player:= if Player = 1 then 0 else 1; \next player + Points:= 0; \points for current turn + loop [Text(0, "Player "); IntOut(0, Player+1); + Text(0, " is up. Roll or hold (r/h)? "); + OpenI(0); \discard any chars in keyboard buffer (like CR) + if ChIn(0) = ^h then quit \default is 'r' to roll + else [Die:= Ran(6)+1; \roll the die + Text(0, "You get "); IntOut(0, Die); CrLf(0); + if Die = 1 then [Points:= 0; quit]; + Points:= Points + Die; \add up points for turn + Text(0, "Total points are "); IntOut(0, Points); + Text(0, " for a tentative score of "); + IntOut(0, Score(Player)+Points); CrLf(0); + ]; + ]; + Score(Player):= Score(Player) + Points; \show scores + Text(0, "Player 1 has "); IntOut(0, Score(0)); + Text(0, " and player 2 has "); IntOut(0, Score(1)); CrLf(0); +until Score(Player) >= 100; +Text(0, "Player "); IntOut(0, Player+1); Text(0, " WINS!!!"); +] diff --git a/Task/Pinstripe-Display/0DESCRIPTION b/Task/Pinstripe-Display/0DESCRIPTION new file mode 100644 index 0000000000..0b81f427be --- /dev/null +++ b/Task/Pinstripe-Display/0DESCRIPTION @@ -0,0 +1,6 @@ +[[File:Pinstripe-mono-unicon.gif|thumb|right|Sample image]] +The task is to demonstrate the creation of a series of 1 pixel wide vertical pinstripes across the entire width of the display. The pinstripes should alternate one pixel white, one pixel black. + +Quarter of the way down the display, we can switch to a wider 2 pixel wide vertical pinstripe pattern, alternating two pixels white, two pixels black. Half way down the display, we switch to 3 pixels wide, and for the lower quarter of the display we use 4 pixels. + +c.f. [[Colour_pinstripe/Display]] diff --git a/Task/Pinstripe-Display/1META.yaml b/Task/Pinstripe-Display/1META.yaml new file mode 100644 index 0000000000..7268acefb9 --- /dev/null +++ b/Task/Pinstripe-Display/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Test card diff --git a/Task/Pinstripe-Display/AutoHotkey/pinstripe-display.ahk b/Task/Pinstripe-Display/AutoHotkey/pinstripe-display.ahk new file mode 100644 index 0000000000..7c78a8f5ed --- /dev/null +++ b/Task/Pinstripe-Display/AutoHotkey/pinstripe-display.ahk @@ -0,0 +1,40 @@ +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() + +pBrushB := Gdip_BrushCreateSolid(0xFF000000) +pBrushW := Gdip_BrushCreateSolid(0xFFFFFFFF) +Loop 4 +{ + n := A_Index + Loop % w + BorW := A_Index & 1 ? "B" : "W" + ,Gdip_FillRectangle(G, pBrush%BorW% + , A_Index*n-n, (n-1)*h/4, n, h/4) +} + +UpdateLayeredWindow(hwnd, hdc, 0, 0, W, H) + +Gdip_DeleteBrush(pBrushB) +Gdip_DeleteBrush(pBrushW) + +SelectObject(hdc, obm) +DeleteObject(hbm) +DeleteDC(hdc) +Gdip_DeleteGraphics(G) +Return + +Escape:: +Exit: +Gdip_Shutdown(pToken) +ExitApp diff --git a/Task/Pinstripe-Display/BBC-BASIC/pinstripe-display.bbc b/Task/Pinstripe-Display/BBC-BASIC/pinstripe-display.bbc new file mode 100644 index 0000000000..3e0223ac30 --- /dev/null +++ b/Task/Pinstripe-Display/BBC-BASIC/pinstripe-display.bbc @@ -0,0 +1,25 @@ + GWL_STYLE = -16 + HWND_TOPMOST = -1 + WS_VISIBLE = &10000000 + WS_CLIPCHILDREN = &2000000 + WS_CLIPSIBLINGS = &4000000 + + SYS "GetSystemMetrics", 0 TO xscreen% + SYS "GetSystemMetrics", 1 TO yscreen% + SYS "SetWindowLong", @hwnd%, GWL_STYLE, WS_VISIBLE + \ + \ WS_CLIPCHILDREN + WS_CLIPSIBLINGS + SYS "SetWindowPos", @hwnd%, HWND_TOPMOST, 0, 0, xscreen%, yscreen%, 0 + VDU 26 + + FOR X% = 0 TO xscreen%*4-4 STEP 4 + RECTANGLE FILL X%,yscreen%*3/2,2,yscreen%/2 + NEXT + FOR X% = 0 TO xscreen%*4-8 STEP 8 + RECTANGLE FILL X%,yscreen%*2/2,4,yscreen%/2 + NEXT + FOR X% = 0 TO xscreen%*4-12 STEP 12 + RECTANGLE FILL X%,yscreen%*1/2,6,yscreen%/2 + NEXT + FOR X% = 0 TO xscreen%*4-16 STEP 16 + RECTANGLE FILL X%,yscreen%*0/2,8,yscreen%/2 + NEXT diff --git a/Task/Pinstripe-Display/Icon/pinstripe-display.icon b/Task/Pinstripe-Display/Icon/pinstripe-display.icon new file mode 100644 index 0000000000..21dd9821bc --- /dev/null +++ b/Task/Pinstripe-Display/Icon/pinstripe-display.icon @@ -0,0 +1,23 @@ +link graphics + +procedure main() # pinstripe + + WOpen("canvas=hidden") # hide for query + height := WAttrib("displayheight") - 45 # adjust for ... + width := WAttrib("displaywidth") - 20 # ... window 7 borders + WClose(&window) + + W := WOpen("size="||width||","||height,"bg=black","fg=white") | + stop("Unable to open window") + + maxbands := 4 # bands to draw + bandheight := height / maxbands # height of each band + every bands := 1 to maxbands do { # for each band + top := 1 + bandheight * (bands-1) # .. top of band + step := 2^bands # .. number of steps (width) + lines := step / 2 # .. number (width) of stripes + every c := 1 to width by step & l := 0 to lines-1 do + DrawLine(c+l,top,c+l,top+bandheight-1) + } + WDone(W) # q to exit +end diff --git a/Task/Pinstripe-Display/J/pinstripe-display.j b/Task/Pinstripe-Display/J/pinstripe-display.j new file mode 100644 index 0000000000..5b8af8e730 --- /dev/null +++ b/Task/Pinstripe-Display/J/pinstripe-display.j @@ -0,0 +1,4 @@ + load'viewmat' + size=.2{.".wd'qm' NB. J6 + size=. getscreenwh_jgtk_ '' NB. J7 + 'rgb'viewmat- (4<.@%~{:size)# ({.size) $&> 1 2 3 4#&.> <0 1 diff --git a/Task/Pinstripe-Display/Locomotive-Basic/pinstripe-display.locomotive b/Task/Pinstripe-Display/Locomotive-Basic/pinstripe-display.locomotive new file mode 100644 index 0000000000..f692645394 --- /dev/null +++ b/Task/Pinstripe-Display/Locomotive-Basic/pinstripe-display.locomotive @@ -0,0 +1,20 @@ +10 MODE 2 ' finest resolution +20 sh=400 ' screen height +30 sw=640 ' screen width +40 INK 0,26 ' white ink for background pen (0) +50 INK 1,0 ' black ink for foreground pen (1) +60 FOR sn=1 TO 4 ' four sections +70 bh=INT (sh/4) ' bar height +80 bb=(4-sn)*bh ' bar baseline +90 dw=0 ' currently drawn bar width +100 dc=0 ' current drawing colour +110 FOR l=0 TO sw -1 ' pan width for each section +120 PLOT l,bb,dc +130 DRAWR 0,bh-1,dc ' subtract 1 pixel (already plotted) +140 dw=dw+1 +150 ' section number corresponds to maximum bar width +160 ' change bar colour, if maximum bar width exceeded +170 IF dw>sn THEN dw=0:dc=dc+1 ' next colour +180 IF dc>1 THEN dc=0 +190 NEXT l +200 NEXT sn diff --git a/Task/Pinstripe-Display/PicoLisp/pinstripe-display.l b/Task/Pinstripe-Display/PicoLisp/pinstripe-display.l new file mode 100644 index 0000000000..a151550097 --- /dev/null +++ b/Task/Pinstripe-Display/PicoLisp/pinstripe-display.l @@ -0,0 +1,14 @@ +(let Pbm # Create PBM of 384 x 288 pixels + (make + (for N 4 + (let + (C 0 + L (make + (do (/ 384 N) + (do N (link C)) + (setq C (x| 1 C)) ) ) ) + (do 72 (link L)) ) ) ) + (out '(display) # Pipe to ImageMagick + (prinl "P1") + (prinl (length (car Pbm)) " " (length Pbm)) + (mapc prinl Pbm) ) ) diff --git a/Task/Pinstripe-Display/PureBasic/pinstripe-display.purebasic b/Task/Pinstripe-Display/PureBasic/pinstripe-display.purebasic new file mode 100644 index 0000000000..caeb5c13a7 --- /dev/null +++ b/Task/Pinstripe-Display/PureBasic/pinstripe-display.purebasic @@ -0,0 +1,30 @@ +#White = $FFFFFF ;color + +;Create a Pinstripe image +Procedure PinstripeDisplay(width, height) + Protected x, imgID, psHeight = height / 4, psWidth = 1, psTop, horzBand + imgID = CreateImage(#PB_Any, width, height) + If imgID + StartDrawing(ImageOutput(imgID)) + Repeat + x = 0 + Repeat + Box(x, psTop, psWidth, psHeight, #White) + x + 2 * psWidth + Until x >= width + psWidth + 1 + horzBand + 1 + psTop = horzBand * height / 4 ;move to the top of next horizontal band of image + Until psTop >= height + StopDrawing() + EndIf + ProcedureReturn imgID +EndProcedure + +;Open a window and display the pinstripe +If OpenWindow(0, 0, 0, 1, 1,"PureBasic Pinstripe", #PB_Window_Maximize | #PB_Window_SystemMenu) + PicID = PinstripeDisplay(WindowWidth(0), WindowHeight(0)) + ImageGadget(0, 0, 0, WindowWidth(0), WindowHeight(0), ImageID(PicID)) + While WaitWindowEvent() <> #PB_Event_CloseWindow + Wend +EndIf diff --git a/Task/Pinstripe-Display/Tcl/pinstripe-display.tcl b/Task/Pinstripe-Display/Tcl/pinstripe-display.tcl new file mode 100644 index 0000000000..1b06ccfe92 --- /dev/null +++ b/Task/Pinstripe-Display/Tcl/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 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/Pinstripe-Display/XPL0/pinstripe-display.xpl0 b/Task/Pinstripe-Display/XPL0/pinstripe-display.xpl0 new file mode 100644 index 0000000000..26d6406d7a --- /dev/null +++ b/Task/Pinstripe-Display/XPL0/pinstripe-display.xpl0 @@ -0,0 +1,14 @@ +include c:\cxpl\codes; \include 'code' declarations +int X, Y, W, C; +[SetVid($13); \320x200x8 graphics +for Y:= 0 to 200-1 do \for all the scan lines... + [W:= Y/50 + 1; \width of stripe = 1, 2, 3, 4 + C:= 0; \set color to black so first pixel becomes white + for X:= 0 to 320-1 do \for all the pixels on a scan line... + [if rem(X/W) = 0 then C:= C xor $0F; \alternate B&W + Point(X, Y, C); \set pixel at X,Y to color C + ]; + ]; +X:= ChIn(1); \wait for keystroke +SetVid(3); \restore normal text display +] diff --git a/Task/Pinstripe-Printer/0DESCRIPTION b/Task/Pinstripe-Printer/0DESCRIPTION new file mode 100644 index 0000000000..3c0d8d827e --- /dev/null +++ b/Task/Pinstripe-Printer/0DESCRIPTION @@ -0,0 +1,7 @@ +The task is to demonstrate the creation of a series of 1 point wide vertical pinstripes with a sufficient number of pinstripes to span the entire width of the printed page (except for the last pinstripe). The pinstripes should alternate one point white, one point black. (Where the printer does not support producing graphics in terms of points, pixels may be substituted in this task.) + +After the first inch of printing, we switch to a wider 2 point wide vertical pinstripe pattern. alternating two points white, two points black. We then switch to 3 points wide for the next inch, and then 4 points 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/Pinstripe-Printer/1META.yaml b/Task/Pinstripe-Printer/1META.yaml new file mode 100644 index 0000000000..44ab78a9c6 --- /dev/null +++ b/Task/Pinstripe-Printer/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Test card +- Printer diff --git a/Task/Pinstripe-Printer/BBC-BASIC/pinstripe-printer.bbc b/Task/Pinstripe-Printer/BBC-BASIC/pinstripe-printer.bbc new file mode 100644 index 0000000000..a9477f232d --- /dev/null +++ b/Task/Pinstripe-Printer/BBC-BASIC/pinstripe-printer.bbc @@ -0,0 +1,37 @@ + 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%} + SYS "CreateSolidBrush", 0 TO brush% + + VDU 2,1,32,3 + pitch% = 2 + FOR y% = 0 TO dy% STEP dpi% + FOR x% = 0 TO dx%-pitch% STEP pitch% + rc.l% = x% : rc.r% = x% + pitch%/2 + rc.t% = y% : rc.b% = y% + dpi% + SYS "FillRect", @prthdc%, rc{}, brush% + NEXT + pitch% += 2 + NEXT y% + VDU 2,1,12,3 diff --git a/Task/Pinstripe-Printer/Liberty-BASIC/pinstripe-printer.liberty b/Task/Pinstripe-Printer/Liberty-BASIC/pinstripe-printer.liberty new file mode 100644 index 0000000000..3fbe637b89 --- /dev/null +++ b/Task/Pinstripe-Printer/Liberty-BASIC/pinstripe-printer.liberty @@ -0,0 +1,49 @@ +nomainwin + +'paperW = 8.5 ' for US letter paper +'paperH = 11 + +paperW = 8.2677165 ' for A4 paper +paperH = 11.6929134 + +dpi= 300 + +prompt "Enter your printer DPI" +chr$( 13) + "(300 is OK for laser one, 360 likely for inkjet)"; dpi + +w = paperW *dpi 'pixel size of paper +h = paperH *dpi + +graphicbox #main.gr, 0, 0, 300, 300 'picture could be bigger + +open "Pinstripe/Printer" for window as #main + +#main "trapclose [quit]" +#main.gr "autoresize" 'now we can maximize window with picture +#main.gr "down" +#main.gr "horizscrollbar on 0 "; w -300 'so we can scroll it +#main.gr "vertscrollbar on 0 "; h -300 +#main.gr "place 0 0" +#main.gr "color white" +#main.gr "boxfilled "; w; " ";h +#main.gr "color black" +#main.gr "backcolor black" + +for i = 0 to int( paperH) + ww = i + 1 + yy =( i + 1) * dpi + if yy > h then yy = h + for x = ww to w step ww * 2 'start with white strip + x1 = x + ww + if x1 >= w then x1 = w + #main.gr "place "; x; " "; i * dpi + #main.gr "boxfilled "; x1; " "; yy + next +next + +#main.gr "flush" +#main.gr "print "; w + +wait +[quit] +close #main +end diff --git a/Task/Pinstripe-Printer/PicoLisp/pinstripe-printer.l b/Task/Pinstripe-Printer/PicoLisp/pinstripe-printer.l new file mode 100644 index 0000000000..4f35cf4cfa --- /dev/null +++ b/Task/Pinstripe-Printer/PicoLisp/pinstripe-printer.l @@ -0,0 +1,9 @@ +(load "@lib/ps.l") + +(call 'lpr + (pdf "pinstripes" + (a4) # 595 x 842 dots + (for X 595 + (gray (if (bit? 1 X) 0 100) + (vline X 0 842) ) ) + (page) ) ) diff --git a/Task/Pinstripe-Printer/Tcl/pinstripe-printer.tcl b/Task/Pinstripe-Printer/Tcl/pinstripe-printer.tcl new file mode 100644 index 0000000000..4fb2c8dbd0 --- /dev/null +++ b/Task/Pinstripe-Printer/Tcl/pinstripe-printer.tcl @@ -0,0 +1,14 @@ +package require Tk +# Allocate a temporary drawing surface +canvas .c +# 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;set c [expr {!$c}]} { + .c create rectangle $x $y [expr {$x+$dx+1}] [expr {$y+73}] \ + -fill [lindex {black white} $c] -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/Play-recorded-sounds/0DESCRIPTION b/Task/Play-recorded-sounds/0DESCRIPTION new file mode 100644 index 0000000000..dcc143449e --- /dev/null +++ b/Task/Play-recorded-sounds/0DESCRIPTION @@ -0,0 +1,15 @@ +Load at least two prerecorded sounds, and demonstrate as many of these features as you can: +* playing them individually and simultaneously +* stopping before the end of the sound +* looping (preferably glitch-free) +* setting the volume of each sound +* stereo or 3D positional mixing +* performing other actions when marked times in the sound arrive +Describe: +* The supported audio formats, briefly. +* Whether it is suitable for game sound effects (low-latency start, resource efficiency, supports many simultaneous sounds, etc.) +* Whether it is suitable for playing music (long duration ). + +[Note: If it seems to be a good idea, this task may be revised to specify a particular timeline rather than just 'demonstrate these features'.] + +Where applicable, please categorize examples primarily by the audio facility used (library/API/program/platform) rather than the language if the language is incidental (e.g. "Mac OS X CoreAudio" or "mplayer" rather than "C" or "bash"). diff --git a/Task/Play-recorded-sounds/1META.yaml b/Task/Play-recorded-sounds/1META.yaml new file mode 100644 index 0000000000..464842a662 --- /dev/null +++ b/Task/Play-recorded-sounds/1META.yaml @@ -0,0 +1,6 @@ +--- +category: +- Games +note: Temporal media +requires: +- Sound diff --git a/Task/Play-recorded-sounds/AutoHotkey/play-recorded-sounds.ahk b/Task/Play-recorded-sounds/AutoHotkey/play-recorded-sounds.ahk new file mode 100644 index 0000000000..2ac23a9da5 --- /dev/null +++ b/Task/Play-recorded-sounds/AutoHotkey/play-recorded-sounds.ahk @@ -0,0 +1,11 @@ +SoundPlay, %A_WinDir%\Media\tada.wav, wait +SoundPlay, %A_WinDir%\Media\Windows XP Startup.wav, wait + +; simulaneous play may require a second script + +SoundPlay, %A_WinDir%\Media\tada.wav +SoundPlay, Nonexistent ; stop before finishing + +SoundSet +10 ; increase volume by 10% +Loop, 2 + SoundPlay, %A_WinDir%\Media\tada.wav, wait diff --git a/Task/Play-recorded-sounds/BBC-BASIC/play-recorded-sounds.bbc b/Task/Play-recorded-sounds/BBC-BASIC/play-recorded-sounds.bbc new file mode 100644 index 0000000000..ace559b789 --- /dev/null +++ b/Task/Play-recorded-sounds/BBC-BASIC/play-recorded-sounds.bbc @@ -0,0 +1,41 @@ + SND_LOOP = 8 + SND_ASYNC = 1 + SND_FILENAME = &20000 + + PRINT "Playing a MIDI file..." + *PLAY C:\windows\media\canyon.mid + + WAIT 300 + PRINT "Playing the Windows TADA sound quietly..." + wave$ = "\windows\media\tada.wav" + volume% = 10000 + SYS "waveOutSetVolume", -1, volume% + (volume% << 16) + SYS "PlaySound", wave$, 0, SND_FILENAME + SND_ASYNC + + WAIT 300 + PRINT "Playing the Windows TADA sound loudly on the left channel..." + volume% = 65535 + SYS "waveOutSetVolume", -1, volume% + SYS "PlaySound", wave$, 0, SND_FILENAME + SND_ASYNC + + WAIT 300 + PRINT "Playing the Windows TADA sound loudly on the right channel..." + volume% = 65535 + SYS "waveOutSetVolume", -1, volume% << 16 + SYS "PlaySound", wave$, 0, SND_FILENAME + SND_ASYNC + + WAIT 300 + PRINT "Looping the Windows TADA sound on both channels..." + volume% = 65535 + SYS "waveOutSetVolume", -1, volume% + (volume% << 16) + SYS "PlaySound", wave$, 0, SND_FILENAME + SND_ASYNC + SND_LOOP + + WAIT 300 + SYS "PlaySound", 0, 0, 0 + PRINT "Stopped looping..." + + WAIT 300 + SOUND OFF + PRINT "Stopped MIDI." + + END diff --git a/Task/Play-recorded-sounds/Delphi/play-recorded-sounds.delphi b/Task/Play-recorded-sounds/Delphi/play-recorded-sounds.delphi new file mode 100644 index 0000000000..2809317271 --- /dev/null +++ b/Task/Play-recorded-sounds/Delphi/play-recorded-sounds.delphi @@ -0,0 +1,9 @@ +program PlayRecordedSounds; + +{$APPTYPE CONSOLE} + +uses MMSystem; + +begin + sndPlaySound('SoundFile.wav', SND_NODEFAULT OR SND_ASYNC); +end. diff --git a/Task/Play-recorded-sounds/GUISS/play-recorded-sounds.guiss b/Task/Play-recorded-sounds/GUISS/play-recorded-sounds.guiss new file mode 100644 index 0000000000..8e4486fff4 --- /dev/null +++ b/Task/Play-recorded-sounds/GUISS/play-recorded-sounds.guiss @@ -0,0 +1,2 @@ +Start,Programs,Accessories,Media Player,Menu:File,Open, +Doubleclick:Icon:Sound.WAV,Button:OK,Button:Play diff --git a/Task/Play-recorded-sounds/Liberty-BASIC/play-recorded-sounds.liberty b/Task/Play-recorded-sounds/Liberty-BASIC/play-recorded-sounds.liberty new file mode 100644 index 0000000000..5f420e67cf --- /dev/null +++ b/Task/Play-recorded-sounds/Liberty-BASIC/play-recorded-sounds.liberty @@ -0,0 +1,41 @@ +'Supports .mid and .wav natively +'Midi may be played simultaneously +'with .wav but only one .wav voice +'is supported. Multiple voices can +'be achieved via API or Dlls such +'as FMOD or Wavemix + +'to play a .mid and return its length +playmidi "my.mid", midiLength + +'check where we are in .mid +if midipos() + +cat $1 >> /dev/audio # Write file $1 to the speaker's Character Special (/dev/audio). diff --git a/Task/Play-recorded-sounds/VBA/play-recorded-sounds.vba b/Task/Play-recorded-sounds/VBA/play-recorded-sounds.vba new file mode 100644 index 0000000000..4709a6c781 --- /dev/null +++ b/Task/Play-recorded-sounds/VBA/play-recorded-sounds.vba @@ -0,0 +1,6 @@ +Declare Function libPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _ + (ByVal filename As String, ByVal Flags As Long) As Long + +Sub PlaySound(sWav As String) + Call libPlaySound(sWav, 1) '1 to play asynchronously +End Sub diff --git a/Task/Playing-cards/0DESCRIPTION b/Task/Playing-cards/0DESCRIPTION new file mode 100644 index 0000000000..68ed7a0c44 --- /dev/null +++ b/Task/Playing-cards/0DESCRIPTION @@ -0,0 +1 @@ +Create a data structure and the associated methods to define and manipulate a deck of [[wp:Playing-cards#Anglo-American-French|playing cards]]. The deck should contain 52 unique cards. The methods must include the ability to make a new deck, shuffle (randomize) the deck, deal from the deck, and print the current contents of a deck. Each card must have a pip value and a suit value which constitute the unique value of the card. diff --git a/Task/Playing-cards/1META.yaml b/Task/Playing-cards/1META.yaml new file mode 100644 index 0000000000..a2413d963b --- /dev/null +++ b/Task/Playing-cards/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Games diff --git a/Task/Playing-cards/ACL2/playing-cards.acl2 b/Task/Playing-cards/ACL2/playing-cards.acl2 new file mode 100644 index 0000000000..e02c34f67b --- /dev/null +++ b/Task/Playing-cards/ACL2/playing-cards.acl2 @@ -0,0 +1,52 @@ +(defun remove-nth (i xs) + (if (or (zp i) (endp (rest xs))) + (rest xs) + (cons (first xs) + (remove-nth (1- i) (rest xs))))) + +(defthm remove-nth-shortens + (implies (consp xs) + (< (len (remove-nth i xs)) (len xs)))) + +:set-state-ok t + +(defun shuffle-r (xs ys state) + (declare (xargs :measure (len xs))) + (if (endp xs) + (mv ys state) + (mv-let (idx state) + (random$ (len xs) state) + (shuffle-r (remove-nth idx xs) + (cons (nth idx xs) ys) + state)))) + +(defun shuffle (xs state) + (shuffle-r xs nil state)) + +(defun cross-r (x ys) + (if (endp ys) + nil + (cons (cons x (first ys)) + (cross-r x (rest ys))))) + +(defun cross (xs ys) + (if (or (endp xs) (endp ys)) + nil + (append (cross-r (first xs) ys) + (cross (rest xs) ys)))) + +(defun make-deck () + (cross '(ace 2 3 4 5 6 7 8 9 10 jack queen king) + '(hearts diamonds clubs spades))) + +(defun print-card (card) + (cw "~x0 of ~x1~%" (car card) (cdr card))) + +(defun print-deck (deck) + (if (endp deck) + nil + (progn$ (print-card (first deck)) + (print-deck (rest deck))))) + +(defun draw-from-deck (deck) + (mv (first deck) (rest deck))) diff --git a/Task/Playing-cards/ALGOL-68/playing-cards.alg b/Task/Playing-cards/ALGOL-68/playing-cards.alg new file mode 100644 index 0000000000..5d2a424e73 --- /dev/null +++ b/Task/Playing-cards/ALGOL-68/playing-cards.alg @@ -0,0 +1,75 @@ +MODE CARD = STRUCT(STRING pip, suit); # instance attributes # + +# class members & attributes # +STRUCT( + PROC(REF CARD, STRING, STRING)VOID init, + FORMAT format, + PROC(REF CARD)STRING repr, + []STRING suits, pips +) class card = ( +# PROC init = # (REF CARD self, STRING pip, suit)VOID:( + pip OF self:=pip; + suit OF self :=suit + ), +# format = # $"("g" OF "g")"$, +# PROC repr = # (REF CARD self)STRING: ( + HEAP STRING out; putf(BOOK out,(format OF class card,self)); out + ), +# suits = # ("Clubs","Hearts","Spades","Diamonds"), +# pips = # ("2","3","4","5","6","7","8","9","10","Jack","Queen","King","Ace") +); + +MODE DECK = STRUCT(REF[]CARD deck); # instance attributes # + +# class members & attributes # +STRUCT( + PROC(REF DECK)VOID init, shuffle, + PROC(REF DECK)STRING repr, + PROC(REF DECK)CARD deal +) class deck = ( + +# PROC init = # (REF DECK self)VOID:( + HEAP[ UPB suits OF class card * UPB pips OF class card ]CARD new; + FOR suit TO UPB suits OF class card DO + FOR pip TO UPB pips OF class card DO + new[(suit-1)*UPB pips OF class card + pip] := + ((pips OF class card)[pip], (suits OF class card)[suit]) + OD + OD; + deck OF self := new + ), + +# PROC shuffle = # (REF DECK self)VOID: + FOR card TO UPB deck OF self DO + CARD this card = (deck OF self)[card]; + INT random card = random int(LWB deck OF self,UPB deck OF self); + (deck OF self)[card] := (deck OF self)[random card]; + (deck OF self)[random card] := this card + OD, + +# PROC repr = # (REF DECK self)STRING: ( + FORMAT format = $"("n(UPB deck OF self-1)(f(format OF class card)", ")f(format OF class card)")"$; + HEAP STRING out; putf(BOOK out,(format, deck OF self)); out + ), + +# PROC deal = # (REF DECK self)CARD: ( + (shuffle OF class deck)(self); + (deck OF self)[UPB deck OF self] + ) +); + +# associate a STRING with a FILE for easy text manipulation # +OP BOOK = (REF STRING string)REF FILE:( + HEAP FILE book; + associate(book, string); + book +); + +# Pick a random integer between from [lwb..upb] # +PROC random int = (INT lwb, upb)INT: + ENTIER(random * (upb - lwb + 1) + lwb); + +DECK deck; +(init OF class deck)(deck); +(shuffle OF class deck)(deck); +print (((repr OF class deck)(deck), new line)) diff --git a/Task/Playing-cards/AutoHotkey/playing-cards.ahk b/Task/Playing-cards/AutoHotkey/playing-cards.ahk new file mode 100644 index 0000000000..9487e146e8 --- /dev/null +++ b/Task/Playing-cards/AutoHotkey/playing-cards.ahk @@ -0,0 +1,30 @@ +Loop, 52 +{ + Random, card%A_Index%, 1, 52 + While card%A_Index% + Random, card%A_Index%, 1, 52 + card%A_Index% := Mod(card%A_Index%, 12) . " of " . ((card%A_Index% <= 12) + ? "diamonds" : ((card%A_Index%) <= 24) + ? "hearts" : ((card%A_Index% <= 36) + ? "clubs" + : "spades"))) + allcards .= card%A_Index% . "`n" +} +currentcard = 1 +Gui, Add, Text, vcard w500 +Gui, Add, Button, w500 gNew, New Deck (Shuffle) +Gui, Add, Button, w500 gDeal, Deal Next Card +Gui, Add, Button, w500 gReveal, Reveal Entire Deck +Gui, Show,, Playing Cards +Return +New: +Reload +GuiClose: +ExitApp +Deal: +GuiControl,, card, % card%currentcard% +currentcard++ +Return +Reveal: +GuiControl,, card, % allcards +Return diff --git a/Task/Playing-cards/BASIC/playing-cards.basic b/Task/Playing-cards/BASIC/playing-cards.basic new file mode 100644 index 0000000000..7dc968cab2 --- /dev/null +++ b/Task/Playing-cards/BASIC/playing-cards.basic @@ -0,0 +1,64 @@ +DECLARE SUB setInitialValues (deck() AS STRING * 2) +DECLARE SUB shuffle (deck() AS STRING * 2) +DECLARE SUB showDeck (deck() AS STRING * 2) +DECLARE FUNCTION deal$ (deck() AS STRING * 2) + +DATA "AS", "2S", "3S", "4S", "5S", "6S", "7S", "8S", "9S", "TS", "JS", "QS", "KS" +DATA "AH", "2H", "3H", "4H", "5H", "6H", "7H", "8H", "9H", "TH", "JH", "QH", "KH" +DATA "AC", "2C", "3C", "4C", "5C", "6C", "7C", "8C", "9C", "TC", "JC", "QC", "KC" +DATA "AD", "2D", "3D", "4D", "5D", "6D", "7D", "8D", "9D", "TD", "JD", "QD", "KD" + +RANDOMIZE TIMER + +REDIM cards(51) AS STRING * 2 +REDIM cards2(51) AS STRING * 2 + +setInitialValues cards() +setInitialValues cards2() +shuffle cards() +PRINT "Dealt: "; deal$(cards()) +PRINT "Dealt: "; deal$(cards()) +PRINT "Dealt: "; deal$(cards()) +PRINT "Dealt: "; deal$(cards()) +showDeck cards() +showDeck cards2() + +FUNCTION deal$ (deck() AS STRING * 2) + 'technically dealing from the BOTTOM of the deck... whatever + DIM c AS STRING * 2 + c = deck(UBOUND(deck)) + REDIM PRESERVE deck(LBOUND(deck) TO UBOUND(deck) - 1) AS STRING * 2 + deal$ = c +END FUNCTION + +SUB setInitialValues (deck() AS STRING * 2) + DIM L0 AS INTEGER + + RESTORE + FOR L0 = 0 TO 51 + READ deck(L0) + NEXT +END SUB + +SUB showDeck (deck() AS STRING * 2) + FOR L% = LBOUND(deck) TO UBOUND(deck) + PRINT deck(L%); " "; + NEXT + PRINT +END SUB + +SUB shuffle (deck() AS STRING * 2) + DIM w AS INTEGER + DIM shuffled(51) AS STRING * 2 + DIM L0 AS INTEGER + + FOR L0 = 51 TO 0 STEP -1 + w = INT(RND * (L0 + 1)) + shuffled(L0) = deck(w) + IF w <> L0 THEN deck(w) = deck(L0) + NEXT + + FOR L0 = 0 TO 51 + deck(L0) = shuffled(L0) + NEXT +END SUB diff --git a/Task/Playing-cards/BBC-BASIC/playing-cards.bbc b/Task/Playing-cards/BBC-BASIC/playing-cards.bbc new file mode 100644 index 0000000000..c0142e93ba --- /dev/null +++ b/Task/Playing-cards/BBC-BASIC/playing-cards.bbc @@ -0,0 +1,47 @@ + DIM Deck{ncards%, card&(51)}, Suit$(3), Rank$(12) + Suit$() = "Clubs", "Diamonds", "Hearts", "Spades" + Rank$() = "Ace", "Two", "Three", "Four", "Five", "Six", "Seven", \ + \ "Eight", "Nine", "Ten", "Jack", "Queen", "King" + + PRINT "Creating a new deck..." + PROCnewdeck(deck1{}) + PRINT "Shuffling the deck..." + PROCshuffle(deck1{}) + PRINT "The first few cards are:" + FOR card% = 1 TO 8 + PRINT FNcardname(deck1.card&(card%)) + NEXT + PRINT "Dealing three cards from the deck:" + FOR card% = 1 TO 3 + PRINT FNcardname(FNdeal(deck1{})) + NEXT + PRINT "Number of cards remaining in the deck = " ; deck1.ncards% + END + + REM Make a new deck: + DEF PROCnewdeck(RETURN deck{}) + LOCAL N% + DIM deck{} = Deck{} + FOR N% = 0 TO 51 + deck.card&(N%) = N% + deck.ncards% += 1 + NEXT + ENDPROC + + REM Shuffle a deck: + DEF PROCshuffle(deck{}) + LOCAL N% + FOR N% = 52 TO 2 STEP -1 + SWAP deck.card&(N%-1), deck.card&(RND(N%)-1) + NEXT + ENDPROC + + REM Deal from the 'bottom' of the deck: + DEF FNdeal(deck{}) + IF deck.ncards% = 0 THEN ERROR 100, "Deck is empty" + deck.ncards% -= 1 + = deck.card&(deck.ncards%) + + REM Return the name of a card: + DEF FNcardname(card&) + = Rank$(card& >> 2) + " of " + Suit$(card& AND 3) diff --git a/Task/Playing-cards/C++/playing-cards.cpp b/Task/Playing-cards/C++/playing-cards.cpp new file mode 100644 index 0000000000..c107bc91a9 --- /dev/null +++ b/Task/Playing-cards/C++/playing-cards.cpp @@ -0,0 +1,93 @@ +#ifndef CARDS_H_INC +#define CARDS_H_INC + +#include +#include +#include +#include + +namespace cards +{ + class card + { + public: + enum pip_type { two, three, four, five, six, seven, eight, nine, ten, + jack, queen, king, ace }; + enum suite_type { hearts, spades, diamonds, clubs }; + + // construct a card of a given suite and pip + card(suite_type s, pip_type p): value(s + 4*p) {} + + // construct a card directly from its value + card(unsigned char v = 0): value(v) {} + + // return the pip of the card + pip_type pip() { return pip_type(value/4); } + + // return the suit of the card + suite_type suite() { return suite_type(value%4); } + + private: + // there are only 52 cards, therefore unsigned char suffices + unsigned char value; + }; + + char const* const pip_names[] = + { "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", + "jack", "queen", "king", "ace" }; + + // output a pip + std::ostream& operator<<(std::ostream& os, card::pip_type pip) + { + return os << pip_names[pip]; + }; + + char const* const suite_names[] = + { "hearts", "spades", "diamonds", "clubs" }; + + // output a suite + std::ostream& operator<<(std::ostream& os, card::suite_type suite) + { + return os << suite_names[suite]; + } + + // output a card + std::ostream& operator<<(std::ostream& os, card c) + { + return os << c.pip() << " of " << c.suite(); + } + + class deck + { + public: + // default constructor: construct a default-ordered deck + deck() + { + for (int i = 0; i < 52; ++i) + cards.push_back(card(i)); + } + + // shuffle the deck + void shuffle() { std::random_shuffle(cards.begin(), cards.end()); } + + // deal a card from the top + card deal() { card c = cards.front(); cards.pop_front(); return c; } + + // iterators (only reading access is allowed) + typedef std::deque::const_iterator const_iterator; + const_iterator begin() const { return cards.begin(); } + const_iterator end() const { return cards.end(); } + private: + // the cards + std::deque cards; + }; + + // output the deck + inline std::ostream& operator<<(std::ostream& os, deck const& d) + { + std::copy(d.begin(), d.end(), std::ostream_iterator(os, "\n")); + return os; + } +} + +#endif diff --git a/Task/Playing-cards/C/playing-cards.c b/Task/Playing-cards/C/playing-cards.c new file mode 100644 index 0000000000..6cf5ede60f --- /dev/null +++ b/Task/Playing-cards/C/playing-cards.c @@ -0,0 +1,94 @@ +#include +#include +#include + +int locale_ok = 0; + +wchar_t s_suits[] = L"♠♥♦♣"; +/* if your file can't contain unicode, use the next line instead */ +//wchar_t s_suits[] = L"\x2660\x2665\x2666\x2663"; + +const char *s_suits_ascii[] = { "S", "H", "D", "C" }; +const char *s_nums[] = { "WHAT", + "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", + "OVERFLOW" +}; + +typedef struct { int suit, number, _s; } card_t, *card; +typedef struct { int n; card_t cards[52]; } deck_t, *deck; + +void show_card(card c) +{ + if (locale_ok) + printf(" %lc%s", s_suits[c->suit], s_nums[c->number]); + else + printf(" %s%s", s_suits_ascii[c->suit], s_nums[c->number]); +} + +deck new_deck() +{ + int i, j, k; + deck d = malloc(sizeof(deck_t)); + d->n = 52; + for (i = k = 0; i < 4; i++) + for (j = 1; j <= 13; j++, k++) { + d->cards[k].suit = i; + d->cards[k].number = j; + } + return d; +} + +void show_deck(deck d) +{ + int i; + printf("%d cards:", d->n); + for (i = 0; i < d->n; i++) + show_card(d->cards + i); + printf("\n"); +} + +int cmp_card(const void *a, const void *b) +{ + int x = ((card)a)->_s, y = ((card)b)->_s; + return x < y ? -1 : x > y; +} + +card deal_card(deck d) +{ + if (!d->n) return 0; + return d->cards + --d->n; +} + +void shuffle_deck(deck d) +{ + int i; + for (i = 0; i < d->n; i++) + d->cards[i]._s = rand(); + qsort(d->cards, d->n, sizeof(card_t), cmp_card); +} + +int main() +{ + int i, j; + deck d = new_deck(); + + locale_ok = (0 != setlocale(LC_CTYPE, "")); + + printf("New deck, "); show_deck(d); + + printf("\nShuffle and deal to three players:\n"); + shuffle_deck(d); + for (i = 0; i < 3; i++) { + for (j = 0; j < 5; j++) + show_card(deal_card(d)); + printf("\n"); + } + printf("Left in deck "); show_deck(d); + + /* freeing the data struct requires just free(), but it depends on the + * situation: there might be cards dealt out somewhere, which is not + * in the scope of this task. + */ + //free(d); + return 0; +} diff --git a/Task/Playing-cards/Clojure/playing-cards.clj b/Task/Playing-cards/Clojure/playing-cards.clj new file mode 100644 index 0000000000..03ba736ced --- /dev/null +++ b/Task/Playing-cards/Clojure/playing-cards.clj @@ -0,0 +1,21 @@ +(defrecord Card [pip suit] + Object + (toString [this] (str pip " of " suit))) + +(defprotocol pDeck + (deal [this n]) + (shuffle [this]) + (newDeck [this]) + (print [this])) + +(deftype Deck [cards] + pDeck + (deal [this n] [(take n cards) (Deck. (drop n cards))]) + (shuffle [this] (Deck. (shuffle cards))) + (newDeck [this] (Deck. (for [suit ["Clubs" "Hearts" "Spades" "Diamonds"] + pip ["2" "3" "4" "5" "6" "7" "8" "9" "10" "Jack" "Queen" "King" "Ace"]] + (Card. pip suit)))) + (print [this] (dorun (map (comp println str) cards)) this)) + +(defn new-deck [] + (.newDeck (Deck. nil))) diff --git a/Task/Playing-cards/Common-Lisp/playing-cards.lisp b/Task/Playing-cards/Common-Lisp/playing-cards.lisp new file mode 100644 index 0000000000..d980286cd1 --- /dev/null +++ b/Task/Playing-cards/Common-Lisp/playing-cards.lisp @@ -0,0 +1,22 @@ +(defconstant +suits+ + '(club diamond heart spade) + "Card suits are the symbols club, diamond, heart, and spade.") + +(defconstant +pips+ + '(ace 2 3 4 5 6 7 8 9 10 jack queen king) + "Card pips are the numbers 2 through 10, and the symbols ace, jack, +queen and king.") + +(defun make-deck (&aux (deck '())) + "Returns a list of cards, where each card is a cons whose car is a +suit and whose cdr is a pip." + (dolist (suit +suits+ deck) + (dolist (pip +pips+) + (push (cons suit pip) deck)))) + +(defun shuffle (list) + "Returns a shuffling of list, by sorting it with a random +predicate. List may be modified." + (sort list #'(lambda (x y) + (declare (ignore x y)) + (zerop (random 2))))) diff --git a/Task/Playing-cards/D/playing-cards-1.d b/Task/Playing-cards/D/playing-cards-1.d new file mode 100644 index 0000000000..714e106da5 --- /dev/null +++ b/Task/Playing-cards/D/playing-cards-1.d @@ -0,0 +1,43 @@ +import std.stdio, std.random, std.string, std.array; + +struct Card { + enum suits = ["Clubs", "Hearts", "Spades", "Diamonds"]; + enum pips = ["2", "3", "4", "5", "6", "7", "8", "9", "10", + "Jack", "Queen", "King", "Ace"]; + string pip, suit; + + string toString() { + return pip ~ " of " ~ suit; + } +} + +class Deck { + Card[] deck; + + this() { + foreach (suit; Card.suits) + foreach (pip; Card.pips) + deck ~= Card(pip, suit); + } + + void shuffle() { + deck.randomShuffle(); + } + + Card deal() { + auto card = deck.back; + deck.popBack(); + return card; + } + + override string toString() { + return format("%(%s\n%)", deck); + } +} + +void main() { + auto deck = new Deck; // Make A new deck. + deck.shuffle(); // Shuffle the deck. + writeln("Card: ", deck.deal()); // Deal from the deck. + writeln(deck); // Print the current contents of the deck. +} diff --git a/Task/Playing-cards/D/playing-cards-2.d b/Task/Playing-cards/D/playing-cards-2.d new file mode 100644 index 0000000000..71e28d45cf --- /dev/null +++ b/Task/Playing-cards/D/playing-cards-2.d @@ -0,0 +1,111 @@ +import std.stdio, std.random, std.algorithm, std.string, std.conv; + +struct Card { + static immutable suits = ["Club", "Heart", "Diamond", "Spade"]; + static immutable pips = "Ace 2 3 4 5 6 7 8 9 10 J Q K".split(); + enum nPack = suits.length * pips.length; + + static bool rankAceTop = true; + /*const*/ int pip, suit; + + string toString() const { + return format("%3s of %-7s", pips[pip], suits[suit]). + rightJustify(15); + } + + @property int order() const nothrow { + immutable pipOrder = (!rankAceTop) ? + pip : + (pip ? pip - 1 : 12); + return pipOrder * suits.length + suit; + } + + bool opEqual(in Card rhs) const pure nothrow { + return pip == rhs.pip && suit == rhs.suit; + } + + int opCmp(in Card rhs) const nothrow { + return order - rhs.order; + } +} + +final class Deck { + private Card[] cards; + + this(in bool initShuffle = true, in int pack = 0) { + cards.length = 0; + foreach (immutable p; 0 .. pack) + foreach (immutable c; 0 .. Card.nPack) + cards ~= Card((c / Card.suits.length) % + Card.pips.length, + c % Card.suits.length); + + if (initShuffle) + cards.randomShuffle(); + } + + @property size_t length() const pure nothrow { + return cards.length; + } + + Deck add(in Card c) pure nothrow { + cards ~= c; + return this; + } + + Deck deal(in int loc, Deck toDeck = null) pure nothrow { + if (toDeck !is null) + toDeck.add(cards[loc]); + cards = cards[0 .. loc] ~ cards[loc + 1 .. $]; + return this; + } + + Deck dealTop(Deck toDeck = null) pure nothrow { + return deal(length - 1, toDeck); + } + + Card opIndex(in int loc) const pure nothrow { + return cards[loc]; + } + + alias opIndex peek; + + Deck showDeck() { + writeln(this); + return this; + } + + Deck shuffle() { + cards.randomShuffle(); + return this; + } + + Deck sortDeck() { + sort!q{a > b}(cards); + return this; + } + + override string toString() const { + return format("%(%(%s%)\n%)", std.range.chunks(cards, 4)); + } +} + +void main() { + Deck[4] guests; + foreach (ref g; guests) + g = new Deck; // Empty deck. + + auto host = new Deck(false, 1); + writeln("Host"); + host.shuffle().showDeck(); + + while (host.length > 0) + foreach (ref g; guests) + if (host.length > 0) + host.dealTop(g); + + foreach (immutable i, g; guests) { + writefln("Player #%d", i + 1); + g.sortDeck().showDeck(); + } +} diff --git a/Task/Playing-cards/Delphi/playing-cards.delphi b/Task/Playing-cards/Delphi/playing-cards.delphi new file mode 100644 index 0000000000..8cd6de54b6 --- /dev/null +++ b/Task/Playing-cards/Delphi/playing-cards.delphi @@ -0,0 +1,125 @@ +program Cards; + +{$APPTYPE CONSOLE} + +uses + SysUtils, Classes; + +type + TPip = (pTwo, pThree, pFour, pFive, pSix, pSeven, pEight, pNine, pTen, pJack, pQueen, pKing, pAce); + TSuite = (sDiamonds, sSpades, sHearts, sClubs); + +const + cPipNames: array[TPip] of string = ('2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A'); + cSuiteNames: array[TSuite] of string = ('Diamonds', 'Spades', 'Hearts', 'Clubs'); + +type + TCard = class + private + FSuite: TSuite; + FPip: TPip; + public + constructor Create(aSuite: TSuite; aPip: TPip); + function ToString: string; override; + + property Pip: TPip read FPip; + property Suite: TSuite read FSuite; + end; + + TDeck = class + private + FCards: TList; + public + constructor Create; + destructor Destroy; override; + procedure Shuffle; + function Deal: TCard; + function ToString: string; override; + end; + +{ TCard } + +constructor TCard.Create(aSuite: TSuite; aPip: TPip); +begin + FSuite := aSuite; + FPip := aPip; +end; + +function TCard.ToString: string; +begin + Result := Format('%s of %s', [cPipNames[Pip], cSuiteNames[Suite]]) +end; + +{ TDeck } + +constructor TDeck.Create; +var + pip: TPip; + suite: TSuite; +begin + FCards := TList.Create; + for suite := Low(TSuite) to High(TSuite) do + for pip := Low(TPip) to High(TPip) do + FCards.Add(TCard.Create(suite, pip)); +end; + +function TDeck.Deal: TCard; +begin + Result := FCards[0]; + FCards.Delete(0); +end; + +destructor TDeck.Destroy; +var + i: Integer; + c: TCard; +begin + for i := FCards.Count - 1 downto 0 do begin + c := FCards[i]; + FCards.Delete(i); + c.Free; + end; + FCards.Free; + inherited; +end; + +procedure TDeck.Shuffle; +var + i, j: Integer; + temp: TCard; +begin + Randomize; + for i := FCards.Count - 1 downto 0 do begin + j := Random(FCards.Count); + temp := FCards[j]; + FCards.Delete(j); + FCards.Add(temp); + end; +end; + +function TDeck.ToString: string; +var + i: Integer; +begin + for i := 0 to FCards.Count - 1 do + Writeln(TCard(FCards[i]).ToString); +end; + +begin + with TDeck.Create do + try + Shuffle; + ToString; + Writeln; + with Deal do + try + Writeln(ToString); + finally + Free; + end; + finally + Free; + end; + + Readln; +end. diff --git a/Task/Playing-cards/Fantom/playing-cards.fantom b/Task/Playing-cards/Fantom/playing-cards.fantom new file mode 100644 index 0000000000..851594893b --- /dev/null +++ b/Task/Playing-cards/Fantom/playing-cards.fantom @@ -0,0 +1,66 @@ +enum class Suit { clubs, diamonds, hearts, spades } +enum class Pips { ace, two, three, four, five, + six, seven, eight, nine, ten, jack, queen, king +} + +class Card +{ + readonly Suit suit + readonly Pips pips + + new make (Suit suit, Pips pips) + { + this.suit = suit + this.pips = pips + } + + override Str toStr () + { + "card: $pips of $suit" + } +} + +class Deck +{ + Card[] deck := [,] + + new make () + { + Suit.vals.each |val| + { + Pips.vals.each |pip| { deck.add (Card(val, pip)) } + } + } + + Void shuffle (Int swaps := 50) + { + swaps.times { deck.swap(Int.random(0..deck.size-1), Int.random(0..deck.size-1)) } + } + + Card[] deal (Int cards := 1) + { + if (cards > deck.size) throw ArgErr("$cards is larger than ${deck.size}") + Card[] result := [,] + cards.times { result.push (deck.removeAt (0)) } + return result + } + + Void show () + { + deck.each |card| { echo (card.toStr) } + } +} + +class PlayingCards +{ + public static Void main () + { + deck := Deck() + deck.shuffle + Card[] hand := deck.deal (7) + echo ("Dealt hand is:") + hand.each |card| { echo (card.toStr) } + echo ("Remaining deck is:") + deck.show + } +} diff --git a/Task/Playing-cards/Forth/playing-cards.fth b/Task/Playing-cards/Forth/playing-cards.fth new file mode 100644 index 0000000000..ee045bada4 --- /dev/null +++ b/Task/Playing-cards/Forth/playing-cards.fth @@ -0,0 +1,32 @@ +require random.fs \ RANDOM ( n -- 0..n-1 ) is called CHOOSE in other Forths + +create pips s" A23456789TJQK" mem, +create suits s" DHCS" mem, \ diamonds, hearts, clubs, spades +: .card ( c -- ) + 13 /mod swap + pips + c@ emit + suits + c@ emit ; + +create deck 52 allot +variable dealt + +: new-deck + 52 0 do i deck i + c! loop 0 dealt ! ; +: .deck + 52 dealt @ ?do deck i + c@ .card space loop cr ; +: shuffle + 51 0 do + 52 i - random i + ( rand-index ) deck + + deck i + c@ over c@ + deck i + c! swap c! + loop ; +: cards-left ( -- n ) 52 dealt @ - ; +: deal-card ( -- c ) + cards-left 0= abort" Deck empty!" + deck dealt @ + c@ 1 dealt +! ; +: .hand ( n -- ) + 0 do deal-card .card space loop cr ; + +new-deck shuffle .deck +5 .hand +cards-left . \ 47 diff --git a/Task/Playing-cards/Fortran/playing-cards-1.f b/Task/Playing-cards/Fortran/playing-cards-1.f new file mode 100644 index 0000000000..61c73437ef --- /dev/null +++ b/Task/Playing-cards/Fortran/playing-cards-1.f @@ -0,0 +1,66 @@ +MODULE Cards + +IMPLICIT NONE + + TYPE Card + CHARACTER(5) :: value + CHARACTER(8) :: suit + END TYPE Card + + TYPE(Card) :: deck(52), hand(52) + TYPE(Card) :: temp + + CHARACTER(5) :: pip(13) = (/"Two ", "Three", "Four ", "Five ", "Six ", "Seven", "Eight", "Nine ", "Ten ", & + "Jack ", "Queen", "King ", "Ace "/) + CHARACTER(8) :: suits(4) = (/"Clubs ", "Diamonds", "Hearts ", "Spades "/) + INTEGER :: i, j, n, rand, dealt = 0 + REAL :: x + +CONTAINS + + SUBROUTINE Init_deck + ! Create deck + DO i = 1, 4 + DO j = 1, 13 + deck((i-1)*13+j) = Card(pip(j), suits(i)) + END DO + END DO + END SUBROUTINE Init_deck + + SUBROUTINE Shuffle_deck + ! Shuffle deck using Fisher-Yates algorithm + DO i = 52-dealt, 1, -1 + CALL RANDOM_NUMBER(x) + rand = INT(x * i) + 1 + temp = deck(rand) + deck(rand) = deck(i) + deck(i) = temp + END DO + END SUBROUTINE Shuffle_deck + + SUBROUTINE Deal_hand(number) + ! Deal from deck to hand + INTEGER :: number + DO i = 1, number + hand(i) = deck(dealt+1) + dealt = dealt + 1 + END DO + END SUBROUTINE + + SUBROUTINE Print_hand + ! Print cards in hand + DO i = 1, dealt + WRITE (*, "(3A)") TRIM(deck(i)%value), " of ", TRIM(deck(i)%suit) + END DO + WRITE(*,*) + END SUBROUTINE Print_hand + + SUBROUTINE Print_deck + ! Print cards in deck + DO i = dealt+1, 52 + WRITE (*, "(3A)") TRIM(deck(i)%value), " of ", TRIM(deck(i)%suit) + END DO + WRITE(*,*) + END SUBROUTINE Print_deck + +END MODULE Cards diff --git a/Task/Playing-cards/Fortran/playing-cards-2.f b/Task/Playing-cards/Fortran/playing-cards-2.f new file mode 100644 index 0000000000..7319d37297 --- /dev/null +++ b/Task/Playing-cards/Fortran/playing-cards-2.f @@ -0,0 +1,11 @@ +PROGRAM Playing_Cards + + USE Cards + + CALL Init_deck + CALL Shuffle_deck + CALL Deal_hand(5) + CALL Print_hand + CALL Print_deck + +END PROGRAM diff --git a/Task/Playing-cards/Go/playing-cards.go b/Task/Playing-cards/Go/playing-cards.go new file mode 100644 index 0000000000..8bd964f184 --- /dev/null +++ b/Task/Playing-cards/Go/playing-cards.go @@ -0,0 +1,125 @@ +package main + +import ( + "fmt" + "math/rand" + "time" +) + +func main() { + rand.Seed(time.Now().UnixNano()) + d := newDeck() + fmt.Println("fresh deck") + fmt.Println(d) + + d.shuffle() + fmt.Println("\nshuffled") + fmt.Println(d) + + h := d.deal(5) + fmt.Println("\n5 cards delt") + fmt.Println(h) + + fmt.Println("\npip, suit values of cards in hand:") + fmt.Println("pip suit") + for _, c := range h { + fmt.Printf("%3d %3d\n", c.pip(), c.suit()) + } + fmt.Print("\n", len(d), " cards left in deck\n") + fmt.Println(d) +} + +// card type. (deck type defined later) +// valid range is 0..51. this facilititates computations. +type card int + +// zero-based pip/suit functions. useful for computations. +// (or maybe just reference for computations, since they are trivial) +func (c card) pip0() int { + return int(c % 13) +} + +func (c card) suit0() int { + return int(c / 13) +} + +func (c card) pipSuit0() (int, int) { + return int(c % 13), int(c / 13) +} + +// one-base pip/suit functions. meaningful for output. +// ("pip" does really mean the identifying number of spots on the card) +func (c card) pip() int { + return int(c%13) + 1 +} + +func (c card) suit() int { + return int(c/13) + 1 +} + +func (c card) pipSuit() (int, int) { + return int(c%13) + 1, int(c/13) + 1 +} + +// string representation +const pipS = "A23456789TJQK" +const suitS = "CDHS" + +func (c card) String() string { + px, sx := c.pipSuit0() + return pipS[px:px+1] + suitS[sx:sx+1] +} + +// deck type +type deck []card + +// "constructor" returns pointer to new deck object +func newDeck() deck { + d := make(deck, 52) + for i := range d { + /lang> + +Example (first 4 cards of a shuffled deck): + d[i] = card(i) + } + return d +} + +// string representation: 13 cards to a line, up to four lines. +// lines separated with newline character. empty deck is empty string. +func (d deck) String() string { + if len(d) == 0 { + return "" + } + r := d[0].String() + for i, c := range d[1:] { + if i%13 == 12 { + r += "\n" + } else { + r += " " + } + r += c.String() + } + return r +} + +// shuffle in place (although using extra memory) +func (d deck) shuffle() { + d2 := make(deck, len(d)) + copy(d2, d) + for i, s := range rand.Perm(len(d)) { + d[i] = d2[s] + } +} + +// return requested number of cards as new deck object. +// the deck being delt from (the method reciever) is resliced. +func (d *deck) deal(n int) deck { + if n > len(*d) { + return nil + } + r := make(deck, n) + copy(r, *d) + *d = (*d)[n:] + return r +} diff --git a/Task/Playing-cards/Groovy/playing-cards-1.groovy b/Task/Playing-cards/Groovy/playing-cards-1.groovy new file mode 100644 index 0000000000..49a2cfab8f --- /dev/null +++ b/Task/Playing-cards/Groovy/playing-cards-1.groovy @@ -0,0 +1,37 @@ +import groovy.transform.TupleConstructor + +enum Pip { + ACE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING +} +enum Suit { + DIAMONDS, SPADES, HEARTS, CLUBS +} + +@TupleConstructor +class Card { + final Pip pip + final Suit suit + + String toString() { "$pip of $suit" } +} + +class Deck { + private LinkedList cards = [] + + Deck() { reset() } + + void reset() { + cards = [] + Suit.values().each { suit -> + Pip.values().each { pip -> + cards << new Card(pip, suit) + } + } + } + + Card deal() { cards.poll() } + + void shuffle() { Collections.shuffle cards } + + String toString() { cards.isEmpty() ? "Empty Deck" : "Deck $cards" } +} diff --git a/Task/Playing-cards/Groovy/playing-cards-2.groovy b/Task/Playing-cards/Groovy/playing-cards-2.groovy new file mode 100644 index 0000000000..bfa1e1b08b --- /dev/null +++ b/Task/Playing-cards/Groovy/playing-cards-2.groovy @@ -0,0 +1,3 @@ +Deck deck = new Deck() +deck.shuffle() +(0..<5).each { println deck.deal() } diff --git a/Task/Playing-cards/Haskell/playing-cards.hs b/Task/Playing-cards/Haskell/playing-cards.hs new file mode 100644 index 0000000000..959094c0e5 --- /dev/null +++ b/Task/Playing-cards/Haskell/playing-cards.hs @@ -0,0 +1,27 @@ +import System.Random + +data Pip = Two | Three | Four | Five | Six | Seven | Eight | Nine | Ten | + Jack | Queen | King | Ace + deriving (Ord, Enum, Bounded, Eq, Show) + +data Suit = Diamonds | Spades | Hearts | Clubs + deriving (Ord, Enum, Bounded, Eq, Show) + +type Card = (Pip, Suit) + +fullRange :: (Bounded a, Enum a) => [a] +fullRange = [minBound..maxBound] + +fullDeck :: [Card] +fullDeck = [(pip, suit) | pip <- fullRange, suit <- fullRange] + +insertAt :: Int -> a -> [a] -> [a] +insertAt 0 x ys = x:ys +insertAt n _ [] = error "insertAt: list too short" +insertAt n x (y:ys) = y : insertAt (n-1) x ys + +shuffle :: RandomGen g => g -> [a] -> [a] +shuffle g xs = shuffle' g xs 0 [] where + shuffle' g [] _ ys = ys + shuffle' g (x:xs) n ys = shuffle' g' xs (n+1) (insertAt k x ys) where + (k,g') = randomR (0,n) g diff --git a/Task/Playing-cards/Icon/playing-cards.icon b/Task/Playing-cards/Icon/playing-cards.icon new file mode 100644 index 0000000000..70865717c2 --- /dev/null +++ b/Task/Playing-cards/Icon/playing-cards.icon @@ -0,0 +1,53 @@ +procedure main(arglist) + + cards := 2 # cards per hand + players := 5 # players to deal to + + write("New deck : ", showcards(D := newcarddeck())) # create and show a new deck + write("Shuffled : ", showcards(D := shufflecards(D))) # shuffle it + + H := list(players) + every H[1 to players] := [] # hands for each player + + every ( c := 1 to cards ) & ( p := 1 to players ) do + put(H[p], dealcard(D)) # deal #players hands of #cards + + every write("Player #",p := 1 to players,"'s hand : ",showcards(H[p])) + write("Remaining: ",showcards(D)) # show the rest of the deck +end + +record card(suit,pip) #: datatype for a card suit x pip + +procedure newcarddeck() #: return a new standard deck +local D + + every put(D := [], card(suits(),pips())) + return D +end + +procedure suits() #: generate suits + suspend !["H","S","D","C"] +end + +procedure pips() #: generate pips + suspend !["2","3","4","5","6","7","8","9","10","J","Q","K","A"] +end + +procedure shufflecards(D) #: shuffle a list of cards + every !D :=: ?D # see INL#9 + return D +end + +procedure dealcard(D) #: deal a card (from the top) + return get(D) +end + +procedure showcards(D) #: return a string of all cards in the given list (deck/hand/etc.) +local s + every (s := "") ||:= card2string(!D) || " " + return s +end + +procedure card2string(x) #: return a string version of a card + return x.pip || x.suit +end diff --git a/Task/Playing-cards/J/playing-cards-1.j b/Task/Playing-cards/J/playing-cards-1.j new file mode 100644 index 0000000000..aee5c2e281 --- /dev/null +++ b/Task/Playing-cards/J/playing-cards-1.j @@ -0,0 +1,42 @@ +NB. playingcards.ijs +NB. Defines a Rosetta Code playing cards class +NB. Multiple decks may be used, one for each instance of this class. + +coclass 'rcpc' NB. Rosetta Code playing cards class + +NB. Class objects +Ranks=: _2 ]\ ' A 2 3 4 5 6 7 8 910 J Q K' +Suits=: ucp '♦♣♥♠' +DeckPrototype=: (] #: i.@:*/)Ranks ,&# Suits + +NB. Class methods +create=: monad define + 1: TheDeck=: DeckPrototype +) + +destroy=: codestroy + +sayCards=: ({&Ranks@{. , {&Suits@{:)"1 + +shuffle=: monad define + 1: TheDeck=: ({~ ?~@#) TheDeck +) + +NB.*dealCards v Deals y cards [to x players] +NB. x is: optional number of players, defaults to one +NB. Used monadically, the player-axis is omitted from output. +dealCards=: verb define + {. 1 dealCards y +: + 'Too few cards in deck' assert (# TheDeck) >: ToBeDealt=. x*y + CardsOffTop=. ToBeDealt {. TheDeck + TheDeck =: ToBeDealt }. TheDeck + (x,y)$ CardsOffTop +) + +NB.*pcc v "Print" current contents of the deck. +pcc=: monad define + sayCards TheDeck +) + +newDeck_z_=: conew&'rcpc' diff --git a/Task/Playing-cards/J/playing-cards-2.j b/Task/Playing-cards/J/playing-cards-2.j new file mode 100644 index 0000000000..923354c052 --- /dev/null +++ b/Task/Playing-cards/J/playing-cards-2.j @@ -0,0 +1,23 @@ + load '~user/playingcards.ijs' + coinsert 'rcpc' NB. insert rcpc class in the path of current locale + pc=: newDeck '' + $TheDeck__pc +52 2 + shuffle__pc '' +1 + sayCards 2 dealCards__pc 5 NB. deal two hands of five cards + 3♦ + 4♦ + K♠ + A♦ + K♦ + + 5♠ +10♣ + Q♥ + 2♣ + 9♣ + $TheDeck__pc NB. deck size has been reduced by the ten cards dealt +42 2 + destroy__pc '' +1 diff --git a/Task/Playing-cards/Java/playing-cards-1.java b/Task/Playing-cards/Java/playing-cards-1.java new file mode 100644 index 0000000000..ed74f0116c --- /dev/null +++ b/Task/Playing-cards/Java/playing-cards-1.java @@ -0,0 +1,2 @@ +public enum Pip { Two, Three, Four, Five, Six, Seven, + Eight, Nine, Ten, Jack, Queen, King, Ace } diff --git a/Task/Playing-cards/Java/playing-cards-2.java b/Task/Playing-cards/Java/playing-cards-2.java new file mode 100644 index 0000000000..6ca350caed --- /dev/null +++ b/Task/Playing-cards/Java/playing-cards-2.java @@ -0,0 +1 @@ +public enum Suit { Diamonds, Spades, Hearts, Clubs } diff --git a/Task/Playing-cards/Java/playing-cards-3.java b/Task/Playing-cards/Java/playing-cards-3.java new file mode 100644 index 0000000000..9258b10136 --- /dev/null +++ b/Task/Playing-cards/Java/playing-cards-3.java @@ -0,0 +1,13 @@ +public class Card { + private final Suit suit; + private final Pip value; + + public Card(Suit s, Pip v) { + suit = s; + value = v; + } + + public String toString() { + return value + " of " + suit; + } +} diff --git a/Task/Playing-cards/Java/playing-cards-4.java b/Task/Playing-cards/Java/playing-cards-4.java new file mode 100644 index 0000000000..8b393cddc5 --- /dev/null +++ b/Task/Playing-cards/Java/playing-cards-4.java @@ -0,0 +1,24 @@ +import java.util.Collections; +import java.util.LinkedList; + +public class Deck { + private final LinkedList deck= new LinkedList(); + + public Deck() { + for (Suit s : Suit.values()) + for (Pip v : Pip.values()) + deck.add(new Card(s, v)); + } + + public Card deal() { + return deck.poll(); + } + + public void shuffle() { + Collections.shuffle(deck); // I'm such a cheater + } + + public String toString(){ + return deck.toString(); + } +} diff --git a/Task/Playing-cards/JavaScript/playing-cards.js b/Task/Playing-cards/JavaScript/playing-cards.js new file mode 100644 index 0000000000..fc92acf112 --- /dev/null +++ b/Task/Playing-cards/JavaScript/playing-cards.js @@ -0,0 +1,31 @@ +function Card(pip, suit) { + this.pip = pip; + this.suit = suit; + + this.toString = function () { + return this.pip + ' ' + this.suit; + }; +} + +function Deck() { + var pips = '2 3 4 5 6 7 8 9 10 Jack Queen King Ace'.split(' '); + var suits = 'Clubs Hearts Spades Diamonds'.split(' '); + this.deck = []; + for (var i = 0; i < suits.length; i++) + for (var j = 0; j < pips.length; j++) + this.deck.push(new Card(pips[j], suits[i])); + + this.toString = function () { + return '[' + this.deck.join(', ') + ']'; + }; + + this.shuffle = function () { + for (var i = 0; i < this.deck.length; i++) + this.deck[i] = this.deck.splice( + parseInt(this.deck.length * Math.random()), 1, this.deck[i])[0]; + }; + + this.deal = function () { + return this.deck.shift(); + }; +} diff --git a/Task/Playing-cards/K/playing-cards-1.k b/Task/Playing-cards/K/playing-cards-1.k new file mode 100644 index 0000000000..590abc24ae --- /dev/null +++ b/Task/Playing-cards/K/playing-cards-1.k @@ -0,0 +1,6 @@ + v:"A23456789TJQK" / values + s:"SHCD" / suites + + / create a new deck + newdeck:{deck::,/s,'\:v} + newdeck(); diff --git a/Task/Playing-cards/K/playing-cards-2.k b/Task/Playing-cards/K/playing-cards-2.k new file mode 100644 index 0000000000..c7aae396a8 --- /dev/null +++ b/Task/Playing-cards/K/playing-cards-2.k @@ -0,0 +1,4 @@ + show:{`0:$,/-3$$deck} + + show() +SA S2 S3 S4 S5 S6 S7 S8 S9 ST SJ SQ SK HA H2 H3 H4 H5 H6 H7 H8 H9 HT HJ HQ HK CA C2 C3 C4 C5 C6 C7 C8 C9 CT CJ CQ CK DA D2 D3 D4 D5 D6 D7 D8 D9 DT DJ DQ DK diff --git a/Task/Playing-cards/K/playing-cards-3.k b/Task/Playing-cards/K/playing-cards-3.k new file mode 100644 index 0000000000..4c28fc7184 --- /dev/null +++ b/Task/Playing-cards/K/playing-cards-3.k @@ -0,0 +1,4 @@ + shuffle:{deck::(-#deck)?deck} + + shuffle();show() +S8 CA D5 D2 SJ D6 DJ H7 S4 S9 SQ SK S5 D8 C4 HT DA H3 S6 S2 DT HA C2 C5 D9 ST C7 DK S3 HQ D7 DQ C8 D3 SA CJ CQ CT H4 H2 CK H9 H5 C3 C6 H6 D4 HJ C9 S7 HK H8 diff --git a/Task/Playing-cards/K/playing-cards-4.k b/Task/Playing-cards/K/playing-cards-4.k new file mode 100644 index 0000000000..e457b2965a --- /dev/null +++ b/Task/Playing-cards/K/playing-cards-4.k @@ -0,0 +1,12 @@ + deal1:{|((#deck)-x)_|deck} + deal:{c:deal1[x];deck::(deck _dvl c);c} + + deal[5] +("S8" + "CA" + "D5" + "D2" + "SJ") + + #deck / 5 cards are removed +47 diff --git a/Task/Playing-cards/K/playing-cards-5.k b/Task/Playing-cards/K/playing-cards-5.k new file mode 100644 index 0000000000..5cf5e228b3 --- /dev/null +++ b/Task/Playing-cards/K/playing-cards-5.k @@ -0,0 +1,16 @@ + {deal@5}'!3 +(("D6" + "DJ" + "H7" + "S4" + "S9") + ("SQ" + "SK" + "S5" + "D8" + "C4") + ("HT" + "DA" + "H3" + "S6" + "S2")) diff --git a/Task/Playing-cards/K/playing-cards-6.k b/Task/Playing-cards/K/playing-cards-6.k new file mode 100644 index 0000000000..2d419e983a --- /dev/null +++ b/Task/Playing-cards/K/playing-cards-6.k @@ -0,0 +1,4 @@ + #deck +32 + show() +DT HA C2 C5 D9 ST C7 DK S3 HQ D7 DQ C8 D3 SA CJ CQ CT H4 H2 CK H9 H5 C3 C6 H6 D4 HJ C9 S7 HK H8 diff --git a/Task/Playing-cards/Liberty-BASIC/playing-cards.liberty b/Task/Playing-cards/Liberty-BASIC/playing-cards.liberty new file mode 100644 index 0000000000..84aa16e64a --- /dev/null +++ b/Task/Playing-cards/Liberty-BASIC/playing-cards.liberty @@ -0,0 +1,92 @@ + Dim deckCards(52) + Dim holdCards(1, 1) +Print "The Sorted Deck" + Call sortDeck + Call dealDeck +Print: Print +Print "The Shuffled Deck" + Call shuffleDeck + Call dealDeck +Print: Print + nPlayers = 4 + nCards = 5 + ct = 0 + Redim holdCards(nPlayers, nCards) +Print "Dealing ";nCards;" cards to ";nPlayers;" players" + For i = 1 to nPlayers + Print "Player #";i,, + Next i + Print + For i = 1 to nCards + For j = 1 to nPlayers + ct = ct + 1 + holdCards(j, i) = deckCards(ct) + card = deckCards(ct) + value = value(card) + suit$ = suit$(card) + pip$ = pip$(value) + Print card;": ";pip$;" of ";suit$, + Next j + Print + Next i +Print: Print + Print "The cards in memory / array" + For i = 1 to nPlayers + Print "Player #";i;" is holding" + For j = 1 to nCards + card = holdCards(i, j) + value = value(card) + suit$ = suit$(card) + pip$ = pip$(value) + Print card;": ";pip$;" of ";suit$ + Next j + Print + Next i + +End + +Sub dealDeck + For i = 1 to 52 + card = deckCards(i) + value = value(card) + suit$ = suit$(card) + pip$ = pip$(value) + Print i, card, value, pip$;" of ";suit$ + Next i +End Sub + +Sub sortDeck + For i = 1 to 52 + deckCards(i) = i + Next i +End Sub + +Sub shuffleDeck + For i = 52 to 1 Step -1 + x = Int(Rnd(1) * i) + 1 + temp = deckCards(x) + deckCards(x) = deckCards(i) + deckCards(i) = temp + Next i +End Sub + +Function suit$(deckValue) + cardSuit$ = "Spades Hearts Clubs Diamonds" + suit = Int(deckValue / 13) + If deckValue Mod 13 = 0 Then + suit = suit - 1 + End If + suit$ = Word$(cardSuit$, suit + 1) +End Function + +Function value(deckValue) + value = deckValue Mod 13 + If value = 0 Then + value = 13 + End If +End Function + +Function pip$(faceValue) + pipLabel$ = "Ace Deuce Three Four Five Six Seven Eight Nine Ten Jack Queen King" + pip$ = Word$(pipLabel$, faceValue) +End Function diff --git a/Task/Playing-cards/Logo/playing-cards.logo b/Task/Playing-cards/Logo/playing-cards.logo new file mode 100644 index 0000000000..b4fdce8d4f --- /dev/null +++ b/Task/Playing-cards/Logo/playing-cards.logo @@ -0,0 +1,33 @@ +make "suits {Diamonds Hearts Clubs Spades} +make "pips {Ace Two Three Four Five Six Seven Eight Nine Ten Jack Queen King} + +to card :n + output (sentence item 1 + modulo :n 13 :pips "of item 1 + int quotient :n 13 :suits) +end + +to new.deck + make "deck listtoarray iseq 0 51 + make "top 1 +end + +to swap :i :j :a + localmake "t item :i :a + setitem :i :a item :j :a + setitem :j :a :t +end +to shuffle.deck + for [i [count :deck] 2] [swap 1 + random :i :i :deck] +end + +to show.deck + for [i :top [count :deck]] [show card item :i :deck] +end + +to deal.card + show card item :top :deck + make "top :top + 1 +end + +new.deck +shuffle.deck +repeat 5 [deal.card] diff --git a/Task/Playing-cards/Lua/playing-cards.lua b/Task/Playing-cards/Lua/playing-cards.lua new file mode 100644 index 0000000000..655fd08af1 --- /dev/null +++ b/Task/Playing-cards/Lua/playing-cards.lua @@ -0,0 +1,64 @@ +suits = {"Clubs", "Diamonds", "Hearts", "Spades"} +faces = {2,3,4,5,6,7,8,9,10,"Jack","Queen","King","Ace"} +--a stack is a set of cards. a stack of length 1 acts as a card; the stack constructor only creates decks. + +stack = setmetatable({ +--shuffles a stack +__unm = function(z) + local ret = {} + for i = #z, 1, -1 do + ret[#ret + 1] = table.remove(z,math.random(i)) + end + return setmetatable(ret, stack) +end, +--puts two stacks together +__add = function(z, z2) + for i = 1, #z2 do + z[#z+1] = table.remove(z2) + end + return z +end, +--removes n cards from a stack and returns a stack of those cards +__sub = function(z, n) + local ret = {} + for i = 1, n do + ret[i] = table.remove(z) + end + return setmetatable(ret, stack) +end, +--breaks a stack into n equally sized stacks and returns them all +deal = function(z, n) + local ret = {} + for i = 1, #z/n do + ret[i] = table.remove(z) + end + if n > 1 then return setmetatable(ret, stack), stack.deal(z,n-1) + else return setmetatable(ret, stack) + end +end, +--returns a and b as strings, concatenated together. Simple enough, right? +__concat = function(a, b) + if getmetatable(a) == stack then + return stack.stackstring(a) .. b + else + return a .. stack.stackstring(b) + end +end, +stackstring = function(st, ind) + ind = ind or 1 + if not st[ind] then return "" end + return st[ind] and (faces[math.ceil(st[ind]/4)] .. " of " .. suits[st[ind]%4+1] .. "\n" .. stack.stackstring(st, ind+1)) or "" +end}, { +--creates a deck +__call = function(z) + local ret = {} + for i = 1, 52 do ret[i] = i end + return -setmetatable(ret,z) +end}) + +print(stack() .. "\n") +a, b, c, d = stack.deal(stack(), 4) +print(a .. "\n\n\n") +print(b + c .. "\n\n\n") +print(d - 4 .. "") +print(-b .. "") diff --git a/Task/Playing-cards/M4/playing-cards.m4 b/Task/Playing-cards/M4/playing-cards.m4 new file mode 100644 index 0000000000..e02d6d3fe3 --- /dev/null +++ b/Task/Playing-cards/M4/playing-cards.m4 @@ -0,0 +1,40 @@ +define(`randSeed',141592653)dnl +define(`setRand', + `define(`randSeed',ifelse(eval($1<10000),1,`eval(20000-$1)',`$1'))')dnl +define(`rand_t',`eval(randSeed^(randSeed>>13))')dnl +define(`random', + `define(`randSeed',eval((rand_t^(rand_t<<18))&0x7fffffff))randSeed')dnl +define(`for', + `ifelse($#,0,``$0'', + `ifelse(eval($2<=$3),1, + `pushdef(`$1',$2)$4`'popdef(`$1')$0(`$1',incr($2),$3,`$4')')')')dnl +define(`foreach', `pushdef(`$1')_foreach($@)popdef(`$1')')dnl +define(`_arg1', `$1')dnl +define(`_foreach', `ifelse(`$2', `()', `', + `define(`$1', _arg1$2)$3`'$0(`$1', (shift$2), `$3')')')dnl +define(`new',`define(`$1[size]',0)')dnl +define(`append', + `define(`$1[size]',incr(defn(`$1[size]')))`'define($1[defn($1[size])],$2)') +define(`deck', + `new($1)foreach(`x',(Ace,2,3,4,5,6,7,8,9,10,Jack,Queen,King), + `foreach(`y',(Clubs,Diamonds,Hearts,Spades), + `append(`$1',`x of y')')')')dnl +define(`show', + `for(`x',1,defn($1[size]),`defn($1[x])ifelse(x,defn($1[size]),`',`, ')')')dnl +define(`swap',`define($1[$2],defn($1[$4]))define($1[$4],$3)')dnl +define(`shuffle', + `for(`x',1,defn($1[size]), + `swap($1,x,defn($1[x]),eval(1+random%defn($1[size])))')')dnl +define(`deal', + `ifelse($#,0,``$0'', + `ifelse(defn($1[size]),0, + `NULL', + defn($1[defn($1[size])])define($1[size],decr(defn($1[size]))))')')dnl +dnl +deck(`b') +show(`b') +shuffling shuffle(`b') +show(`b') +deal deal(`b') +deal deal(`b') +show(`b') diff --git a/Task/Playing-cards/Mathematica/playing-cards.math b/Task/Playing-cards/Mathematica/playing-cards.math new file mode 100644 index 0000000000..0bd5f6159d --- /dev/null +++ b/Task/Playing-cards/Mathematica/playing-cards.math @@ -0,0 +1,3 @@ +MakeDeck[] := Tuples[{{"Ace ", 2, 3 , 4 , 5, 6 , 7 , 8 , 9 , 10, "Jack" , "Queen", "King"}, {♦ , ♣, ♥ , ♠}}] +DeckShuffle[deck_] := RandomSample[deck, Length@deck] +DealFromDeck[] := (Print@First@deck; deck = deck[[2 ;; All]];) diff --git a/Task/Playing-cards/OCaml/playing-cards.ocaml b/Task/Playing-cards/OCaml/playing-cards.ocaml new file mode 100644 index 0000000000..31a7ce7e1e --- /dev/null +++ b/Task/Playing-cards/OCaml/playing-cards.ocaml @@ -0,0 +1,21 @@ +type pip = Two | Three | Four | Five | Six | Seven | Eight | Nine | Ten | + Jack | Queen | King | Ace +let pips = [Two; Three; Four; Five; Six; Seven; Eight; Nine; Ten; + Jack; Queen; King; Ace] + +type suit = Diamonds | Spades | Hearts | Clubs +let suits = [Diamonds; Spades; Hearts; Clubs] + +type card = pip * suit + +let full_deck = Array.of_list (List.concat (List.map (fun pip -> List.map (fun suit -> (pip, suit)) suits) pips)) + +(* Fisher-Yates shuffle *) +let shuffle deck = + for i = Array.length deck - 1 downto 1 do + let j = Random.int (i+1) in + (* swap deck.(i) and deck.(j) *) + let temp = deck.(i) in + deck.(i) <- deck.(j); + deck.(j) <- temp + done diff --git a/Task/Playing-cards/PARI-GP/playing-cards.pari b/Task/Playing-cards/PARI-GP/playing-cards.pari new file mode 100644 index 0000000000..1c2ea04639 --- /dev/null +++ b/Task/Playing-cards/PARI-GP/playing-cards.pari @@ -0,0 +1,20 @@ +name(n)=Str(["A",2,3,4,5,6,7,8,9,10,"J","Q","K"][(n+3)>>2],["h","d","s","c"][n%4+1]); +newdeck()={ + v=vector(52,i,i); +}; +deal()={ + my(n=name(v[1])); + v=vecextract(v,2^#v-2); + n +}; +printdeck(){ + apply(name,v) +}; +shuffle()={ + forstep(n=#v,2,-1, + my(i=random(n)+1,t=v[i]); + v[i]=v[n]; + v[n]=t + ); + v +}; diff --git a/Task/Playing-cards/PHP/playing-cards-1.php b/Task/Playing-cards/PHP/playing-cards-1.php new file mode 100644 index 0000000000..53697df6f0 --- /dev/null +++ b/Task/Playing-cards/PHP/playing-cards-1.php @@ -0,0 +1,276 @@ +class Card +{ + // if unable to save as UTF-8, use other, non-UTF-8, symbols here + protected static $suits = array( '♠', '♥', '♦', '♣' ); + + protected static $pips = array( '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A' ); + + protected $suit; + + protected $suitOrder; + + protected $pip; + + protected $pipOrder; + + protected $order; + + public function __construct( $suit, $pip ) + { + if( !in_array( $suit, self::$suits ) ) + { + throw new InvalidArgumentException( 'Invalid suit' ); + } + if( !in_array( $pip, self::$pips ) ) + { + throw new InvalidArgumentException( 'Invalid pip' ); + } + + $this->suit = $suit; + $this->pip = $pip; + } + + public function getSuit() + { + return $this->suit; + } + + public function getPip() + { + return $this->pip; + } + + public function getSuitOrder() + { + // lazy evaluate suit order + if( !isset( $this->suitOrder ) ) + { + // cache suit order + $this->suitOrder = array_search( $this->suit, self::$suits ); + } + + return $this->suitOrder; + } + + public function getPipOrder() + { + // lazy evaluate pip order + if( !isset( $this->pipOrder ) ) + { + // cache pip order + $this->pipOrder = array_search( $this->pip, self::$pips ); + } + + return $this->pipOrder; + } + + public function getOrder() + { + // lazy evaluate order + if( !isset( $this->order ) ) + { + $suitOrder = $this->getSuitOrder(); + $pipOrder = $this->getPipOrder(); + // cache order + $this->order = $pipOrder * count( self::$suits ) + $suitOrder; + } + + return $this->order; + } + + public function compareSuit( Card $other ) + { + return $this->getSuitOrder() - $other->getSuitOrder(); + } + + public function comparePip( Card $other ) + { + return $this->getPipOrder() - $other->getPipOrder(); + } + + public function compare( Card $other ) + { + return $this->getOrder() - $other->getOrder(); + } + + public function __toString() + { + return $this->suit . $this->pip; + } + + public static function getSuits() + { + return self::$suits; + } + + public static function getPips() + { + return self::$pips; + } +} + +class CardCollection + implements Countable, Iterator +{ + protected $cards = array(); + + protected function __construct( array $cards = array() ) + { + foreach( $cards as $card ) + { + $this->addCard( $card ); + } + } + + /** + * Countable::count() implementation + */ + public function count() + { + return count( $this->cards ); + } + + /** + * Iterator::key() implementation + */ + public function key() + { + return key( $this->cards ); + } + + /** + * Iterator::valid() implementation + */ + public function valid() + { + return null !== $this->key(); + } + + /** + * Iterator::next() implementation + */ + public function next() + { + next( $this->cards ); + } + + /** + * Iterator::current() implementation + */ + public function current() + { + return current( $this->cards ); + } + + /** + * Iterator::rewind() implementation + */ + public function rewind() + { + reset( $this->cards ); + } + + public function sort( $comparer = null ) + { + $comparer = $comparer ?: function( $a, $b ) { + return $a->compare( $b ); + }; + + if( !is_callable( $comparer ) ) + { + throw new InvalidArgumentException( 'Invalid comparer; comparer should be callable' ); + } + + usort( $this->cards, $comparer ); + return $this; + } + + public function toString() + { + return implode( ' ', $this->cards ); + } + + public function __toString() + { + return $this->toString(); + } + + protected function addCard( Card $card ) + { + if( in_array( $card, $this->cards ) ) + { + throw new DomainException( 'Card is already present in this collection' ); + } + + $this->cards[] = $card; + } +} + +class Deck + extends CardCollection +{ + public function __construct( $shuffled = false ) + { + foreach( Card::getSuits() as $suit ) + { + foreach( Card::getPips() as $pip ) + { + $this->addCard( new Card( $suit, $pip ) ); + } + } + + if( $shuffled ) + { + $this->shuffle(); + } + } + + public function deal( $amount = 1, CardCollection $cardCollection = null ) + { + if( !is_int( $amount ) || $amount < 1 ) + { + throw new InvalidArgumentException( 'Invalid amount; amount should be an integer, larger than 0' ); + } + + if( $amount > count( $this->cards ) ) + { + throw new RangeException( 'Invalid amount; requested amount is larger than the amount of available cards' ); + } + + $cards = array_splice( $this->cards, 0, $amount ); + + $cardCollection = $cardCollection ?: new CardCollection; + + foreach( $cards as $card ) + { + $cardCollection->addCard( $card ); + } + + return $cardCollection; + } + + public function shuffle() + { + shuffle( $this->cards ); + } +} + +class Hand + extends CardCollection +{ + // override CardCollection __constructor + // to allow public instantiation + // but disallow instantiation with cards + public function __construct() {} + + public function play( $position ) + { + if( !isset( $this->cards[ $position ] ) ) + { + throw new OutOfBoundsException( 'Invalid position; position is not present in this hand' ); + } + + $result = array_splice( $this->cards, $position, 1 ); + return $result[ 0 ]; + } +} diff --git a/Task/Playing-cards/PHP/playing-cards-2.php b/Task/Playing-cards/PHP/playing-cards-2.php new file mode 100644 index 0000000000..e13bd4ef2f --- /dev/null +++ b/Task/Playing-cards/PHP/playing-cards-2.php @@ -0,0 +1,57 @@ +// if viewing in a browser, lets output a text/plain header with utf-8 charset +header( 'Content-Type: text/plain; charset=utf-8' ); + +// create a new Deck +$deck = new Deck(); + +// show the cards in the new deck +echo count( $deck ) . ' cards in the new deck: ' . PHP_EOL . $deck . PHP_EOL; + +// sort the deck, default sort +$deck->sort(); + +// show the cards in the sorted deck +echo PHP_EOL . count( $deck ) . ' cards in the new deck, default sort: ' . PHP_EOL . $deck . PHP_EOL; + +// sort the deck, custom sort +$deck->sort( function( $a, $b ) { + return $a->compareSuit( $b ) ?: $a->comparePip( $b ); +} ); + +// show the cards in the sorted deck +echo PHP_EOL . count( $deck ) . ' cards in the new deck, custom sort: ' . PHP_EOL . $deck . PHP_EOL; + +// shuffle the deck +$deck->shuffle(); + +// show the cards in the shuffled deck +echo PHP_EOL . count( $deck ) . ' cards in the new deck, shuffled: ' . PHP_EOL . $deck . PHP_EOL . PHP_EOL; + +// intialize four player hands +$players = array( + new Hand, + new Hand, + new Hand, + new Hand +); + +// three deal rounds, with amounts: 2, 2, 3 +foreach( array( 2, 2, 3 ) as $amount ) +{ + // deal this rounds amount to player + foreach( $players as $hand ) + { + $deck->deal( $amount, $hand ); + } +} + +foreach( $players as $p => $hand ) +{ + // sort player cards, default sort + $hand->sort(); + // show player cards + echo 'Player ' . ( $p + 1 ) . ' got dealt the following ' . count( $hand ) . ' cards (sorted): ' . $hand . PHP_EOL; +} + +// show the remaining cards in the deck +echo PHP_EOL . count( $deck ) . ' cards remaining in the deck: ' . PHP_EOL . $deck . PHP_EOL; diff --git a/Task/Playing-cards/Perl-6/playing-cards.pl6 b/Task/Playing-cards/Perl-6/playing-cards.pl6 new file mode 100644 index 0000000000..ddf151e519 --- /dev/null +++ b/Task/Playing-cards/Perl-6/playing-cards.pl6 @@ -0,0 +1,30 @@ +enum Pip ; +enum Suit <♦ ♣ ♥ ♠>; + +class Card { + has Pip $.pip; + has Suit $.suit; + + method Str { $!pip ~ $!suit } +} + +class Deck { + has Card @.cards = pick *, + map { Card.new(:$^pip, :$^suit) }, (Pip.pick(*) X Suit.pick(*)); + + method shuffle { @!cards .= pick: * } + + method deal { shift @!cards } + + method Str { ~@!cards } + method gist { ~@!cards } +} + +my Deck $d = Deck.new; +say "Deck: $d"; + +my $top = $d.deal; +say "Top card: $top"; + +$d.shuffle; +say "Deck, re-shuffled: ", $d; diff --git a/Task/Playing-cards/Perl/playing-cards-1.pl b/Task/Playing-cards/Perl/playing-cards-1.pl new file mode 100644 index 0000000000..47ffe4033d --- /dev/null +++ b/Task/Playing-cards/Perl/playing-cards-1.pl @@ -0,0 +1,42 @@ +package Playing_Card_Deck; + +use strict; + +@Playing_Card_Deck::suits = qw + [Diamonds Clubs Hearts Spades]; +@Playing_Card_Deck::pips = qw + [Two Three Four Five Six Seven Eight Nine Ten + Jack King Queen Ace]; +# I choose to fully qualify these names rather than declare them +# with "our" to keep them from escaping into the scope of other +# packages in the same file. Another possible solution is to use +# "our" or "my", but to enclose this entire package in a bare block. + +sub new +# Creates a new deck-object. The cards are initially neatly ordered. + {my $invocant = shift; + my $class = ref($invocant) || $invocant; + my @cards = (); + foreach my $suit (@Playing_Card_Deck::suits) + {foreach my $pip (@Playing_Card_Deck::pips) + {push(@cards, {suit => $suit, pip => $pip});}} + return bless([@cards], $class);} + +sub deal +# Removes the top card of the given deck and returns it as a hash +# with the keys "suit" and "pip". + {return %{ shift( @{shift(@_)} ) };} + +sub shuffle +# Randomly permutes the cards in the deck. It uses the algorithm +# described at: +# http://en.wikipedia.org/wiki/Fisher-Yates_shuffle#The_modern_algorithm + {our @deck; local *deck = shift; + # @deck is now an alias of the invocant's referent. + for (my $n = $#deck ; $n ; --$n) + {my $k = int rand($n + 1); + @deck[$k, $n] = @deck[$n, $k] if $k != $n;}} + +sub print_cards +# Prints out a description of every card in the deck, in order. + {print "$_->{pip} of $_->{suit}\n" foreach @{shift(@_)};} diff --git a/Task/Playing-cards/Perl/playing-cards-2.pl b/Task/Playing-cards/Perl/playing-cards-2.pl new file mode 100644 index 0000000000..27db55b733 --- /dev/null +++ b/Task/Playing-cards/Perl/playing-cards-2.pl @@ -0,0 +1,5 @@ +my $deck = new Playing_Card_Deck; +$deck->shuffle; +my %card = $deck->deal; +print uc("$card{pip} OF $card{suit}\n"); +$deck->print_cards; diff --git a/Task/Playing-cards/PicoLisp/playing-cards.l b/Task/Playing-cards/PicoLisp/playing-cards.l new file mode 100644 index 0000000000..293a470690 --- /dev/null +++ b/Task/Playing-cards/PicoLisp/playing-cards.l @@ -0,0 +1,13 @@ +(de *Suits + Club Diamond Heart Spade ) + +(de *Pips + Ace 2 3 4 5 6 7 8 9 10 Jack Queen King ) + +(de mkDeck () + (mapcan + '((Pip) (mapcar cons *Suits (circ Pip))) + *Pips ) ) + +(de shuffle (Lst) + (by '(NIL (rand)) sort Lst) ) diff --git a/Task/Playing-cards/Prolog/playing-cards.pro b/Task/Playing-cards/Prolog/playing-cards.pro new file mode 100644 index 0000000000..edf6fa0ba6 --- /dev/null +++ b/Task/Playing-cards/Prolog/playing-cards.pro @@ -0,0 +1,38 @@ +/** Cards + + A card is represented by the term "card(Pip, Suit)". + A deck is represented internally as a list of cards. + + Usage: + new_deck(D0), deck_shuffle(D0, D1), deck_deal(D1, C, D2). +*/ +:- module(cards, [ new_deck/1, % -Deck + deck_shuffle/2, % +Deck, -NewDeck + deck_deal/3, % +Deck, -Card, -NewDeck + print_deck/1 % +Deck + ]). + +%% new_deck(-Deck) +new_deck(Deck) :- + Suits = [clubs, hearts, spades, diamonds], + Pips = [2, 3, 4, 5, 6, 7, 8, 9, 10, jack, queen, king, ace], + setof(card(Pip, Suit), (member(Suit, Suits), member(Pip, Pips)), Deck). + +%% deck_shuffle(+Deck, -NewDeck) +deck_shuffle(Deck, NewDeck) :- + length(Deck, NumCards), + findall(X, (between(1, NumCards, _I), X is random(1000)), Ord), + pairs_keys_values(Pairs, Ord, Deck), + keysort(Pairs, OrdPairs), + pairs_values(OrdPairs, NewDeck). + +%% deck_deal(+Deck, -Card, -NewDeck) +deck_deal([Card|Cards], Card, Cards). + +%% print_deck(+Deck) +print_deck(Deck) :- + maplist(print_card, Deck). + +% print_card(+Card) +print_card(card(Pip, Suit)) :- + format('~a of ~a~n', [Pip, Suit]). diff --git a/Task/Playing-cards/PureBasic/playing-cards.purebasic b/Task/Playing-cards/PureBasic/playing-cards.purebasic new file mode 100644 index 0000000000..38ce265f24 --- /dev/null +++ b/Task/Playing-cards/PureBasic/playing-cards.purebasic @@ -0,0 +1,134 @@ +#MaxCards = 52 ;Max Cards in a deck +Structure card + pip.s + suit.s +EndStructure + +Structure _membersDeckClass + *vtable.i + size.i ;zero based count of cards present + cards.card[#MaxCards] ;deck content +EndStructure + +Interface deckObject + Init() + shuffle() + deal.s(isAbbr = #True) + show(isAbbr = #True) +EndInterface + +Procedure.s _formatCardInfo(*card.card, isAbbr = #True) + ;isAbbr determines if the card information is abbrieviated to 2 characters + Static pips.s = "2 3 4 5 6 7 8 9 10 Jack Queen King Ace" + Static suits.s = "Diamonds Clubs Hearts Spades" + Protected c.s + + If isAbbr + c = *card\pip + *card\suit + Else + c = StringField(pips,FindString("23456789TJQKA", *card\pip, 1), " ") + " of " + c + StringField(suits,FindString("DCHS", *card\suit, 1)," ") + EndIf + ProcedureReturn c +EndProcedure + +Procedure setInitialValues(*this._membersDeckClass) + Protected i, c.s + + Restore cardDat + For i = 0 To #MaxCards - 1 + Read.s c + *this\cards[i]\pip = Left(c, 1) + *this\cards[i]\suit = Right(c, 1) + Next +EndProcedure + +Procedure.s dealCard(*this._membersDeckClass, isAbbr) + ;isAbbr is #True if the card dealt is abbrieviated to 2 characters + Protected c.card + If *this\size < 0 + ;deck is empty + ProcedureReturn "" + Else + c = *this\cards[*this\size] + *this\size - 1 + ProcedureReturn _formatCardInfo(@c, isAbbr) + EndIf +EndProcedure + +Procedure showDeck(*this._membersDeckClass, isAbbr) + ;isAbbr determines if cards are shown with 2 character abbrieviations + Protected i + + For i = 0 To *this\size + Print(_formatCardInfo(@*this\cards[i], isAbbr)) + If i <> *this\size: Print(", "): EndIf + Next + PrintN("") +EndProcedure + +Procedure shuffle(*this._membersDeckClass) + ;works with decks of any size + Protected w, i + Dim shuffled.card(*this\size) + + For i = *this\size To 0 Step -1 + w = Random(i) + shuffled(i) = *this\cards[w] + If w <> i + *this\cards[w] = *this\cards[i] + EndIf + + Next + + For i = 0 To *this\size + *this\cards[i] = shuffled(i) + Next +EndProcedure + +Procedure newDeck() + Protected *newDeck._membersDeckClass = AllocateMemory(SizeOf(_membersDeckClass)) + If *newDeck + *newDeck\vtable = ?vTable_deckClass + *newDeck\size = #MaxCards - 1 + setInitialValues(*newDeck) + EndIf + ProcedureReturn *newDeck +EndProcedure + +DataSection + vTable_deckClass: + Data.i @setInitialValues() + Data.i @shuffle() + Data.i @dealCard() + Data.i @showDeck() + + cardDat: + Data.s "2D", "3D", "4D", "5D", "6D", "7D", "8D", "9D", "TD", "JD", "QD", "KD", "AD" + Data.s "2C", "3C", "4C", "5C", "6C", "7C", "8C", "9C", "TC", "JC", "QC", "KC", "AC" + Data.s "2H", "3H", "4H", "5H", "6H", "7H", "8H", "9H", "TH", "JH", "QH", "KH", "AH" + Data.s "2S", "3S", "4S", "5S", "6S", "7S", "8S", "9S", "TS", "JS", "QS", "KS", "AS" +EndDataSection + +If OpenConsole() + + Define deck.deckObject = newDeck() + Define deck2.deckObject = newDeck() + + If deck = 0 Or deck2 = 0 + PrintN("Unable to create decks") + End + EndIf + + deck\shuffle() + PrintN("Dealt: " + deck\deal(#False)) + PrintN("Dealt: " + deck\deal(#False)) + PrintN("Dealt: " + deck\deal(#False)) + PrintN("Dealt: " + deck\deal(#False)) + deck\show() + deck2\show() + + Print(#CRLF$ + #CRLF$ + "Press ENTER to exit") + Input() + CloseConsole() +EndIf diff --git a/Task/Playing-cards/Python/playing-cards.py b/Task/Playing-cards/Python/playing-cards.py new file mode 100644 index 0000000000..712febd615 --- /dev/null +++ b/Task/Playing-cards/Python/playing-cards.py @@ -0,0 +1,26 @@ +import random + +class Card(object): + suits = ("Clubs","Hearts","Spades","Diamonds") + pips = ("2","3","4","5","6","7","8","9","10","Jack","Queen","King","Ace") + + def __init__(self, pip,suit): + self.pip=pip + self.suit=suit + + def __str__(self): + return "%s %s"%(self.pip,self.suit) + +class Deck(object): + def __init__(self): + self.deck = [Card(pip,suit) for suit in Card.suits for pip in Card.pips] + + def __str__(self): + return "[%s]"%", ".join( (str(card) for card in self.deck)) + + def shuffle(self): + random.shuffle(self.deck) + + def deal(self): + self.shuffle() # Can't tell what is next from self.deck + return self.deck.pop(0) diff --git a/Task/Playing-cards/R/playing-cards.r b/Task/Playing-cards/R/playing-cards.r new file mode 100644 index 0000000000..59d9772594 --- /dev/null +++ b/Task/Playing-cards/R/playing-cards.r @@ -0,0 +1,25 @@ +pips <- c("2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace") +suit <- c("Clubs", "Diamonds", "Hearts", "Spades") +# Create a deck +deck <- data.frame(pips=rep(pips, 4), suit=rep(suit, each=13)) + +shuffle <- function(deck) +{ + n <- nrow(deck) + ord <- sample(seq_len(n), size=n) + deck[ord,] +} + +deal <- function(deck, fromtop=TRUE) +{ + index <- ifelse(fromtop, 1, nrow(deck)) + print(paste("Dealt the", deck[index, "pips"], "of", deck[index, "suit"])) + deck[-index,] +} + +# Usage +deck <- shuffle(deck) +deck +deck <- deal(deck) +# While no-one is looking, sneakily deal a card from the bottom of the pack +deck <- deal(deck, FALSE) diff --git a/Task/Playing-cards/REXX/playing-cards-1.rexx b/Task/Playing-cards/REXX/playing-cards-1.rexx new file mode 100644 index 0000000000..a08a5a9b3f --- /dev/null +++ b/Task/Playing-cards/REXX/playing-cards-1.rexx @@ -0,0 +1,50 @@ +/* REXX *************************************************************** +* 1) Build ordered Card deck +* 2) Create shuffled stack +* 3) Deal 5 cards to 4 players each +* 4) show what cards have been dealt and what's left on the stack +* 05.07.2012 Walter Pachl +**********************************************************************/ +colors='S H C D' +ranks ='A 2 3 4 5 6 7 8 9 T J Q K' +i=0 +cards='' +ss='' +Do c=1 To 4 + Do r=1 To 13 + i=i+1 + card.i=word(colors,c)word(ranks,r) + cards=cards card.i + End + End +n=52 /* number of cards on deck */ +Do si=1 To 51 /* pick 51 cards */ + x=random(0,n-1)+1 /* take card x (in 1...n) */ + s.si=card.x /* card on shuffled stack */ + ss=ss s.si /* string of shuffled stack */ + card.x=card.n /* replace card taken */ + n=n-1 /* decrement nr of cards */ + End +s.52=card.1 /* pick the last card left */ +ss=ss s.52 /* add it to the string */ +Say 'Ordered deck:' +Say ' 'subword(cards,1,26) +Say ' 'subword(cards,27,52) +Say 'Shuffled stack:' +Say ' 'subword(ss,1,26) +Say ' 'subword(ss,27,52) +si=52 +deck.='' +Do ci=1 To 5 /* 5 cards each */ + Do pli=1 To 4 /* 4 players */ + deck.pli.ci=s.si /* take top of shuffled deck */ + si=si-1 /* decrement number */ + deck.pli=deck.pli deck.pli.ci /* pli's cards as string */ + End + End +Do pli=1 To 4 /* show the 4 dealt ... */ + Say pli':' deck.pli + End +Say 'Left on shuffled stack:' +Say ' 'subword(ss,1,26) /* and what's left on stack */ +Say ' 'subword(ss,27,6) diff --git a/Task/Playing-cards/REXX/playing-cards-2.rexx b/Task/Playing-cards/REXX/playing-cards-2.rexx new file mode 100644 index 0000000000..92f3fb6326 --- /dev/null +++ b/Task/Playing-cards/REXX/playing-cards-2.rexx @@ -0,0 +1,36 @@ +/*REXX pgm shows methods (subroutines) to build/shuffle/deal a card deck*/ +call buildDeck ; say ' new deck:' newDeck /*new 52-card deck*/ +call shuffleDeck; say 'shuffled deck:' theDeck /*shuffled deck. */ +call dealHands 5,4 /*5 cards, 4 hands*/ +say; say; say right('[north]' hand.1,50) + say; say '[west]' hand.4 right('[east]' hand.2,60) + say; say right('[south]' hand.3,50) +say; say; say; say 'remainder of deck:' theDeck +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────BUILDDECK subroutine────────────────*/ +buildDeck: _=''; ranks='A 2 3 4 5 6 7 8 9 10 J Q K' /*ranks. */ +if 1=='f1'x then suits='h d c s' /*EBCDIC?*/ + else suits='♥ ♦ ♣ ♠' /*ASCII. */ + do s=1 for words(suits) + do r=1 for words(ranks) + _=_ word(ranks,r)word(suits,s) + end /*dealR*/ + end; /*dealS*/ newDeck=_ +return +/*──────────────────────────────────SHUFFLEDECK subroutine──────────────*/ +shuffleDeck: theDeck=''; _=newDeck; #cards=words(_) + do shuffler=1 for #cards /*shuffle all the cards in deck. */ + r=random(1,#cards+1-shuffler) /*random # decreases each time. */ + theDeck=theDeck word(_,r) /*sufffled deck, 1 card at-a-time*/ + _=delword(_,r,1) /*delete the just-chosen card. */ + end /*shuffler*/ +return +/*──────────────────────────────────DEALHANDS subroutine────────────────*/ +dealHands: parse arg numberOfCards,hands; hand.='' + do numberOfCards /*deal the hand to the players. */ + do player=1 for hands /*deal a card to the players. */ + hand.player=hand.player subword(theDeck,1,1) /*deal top card.*/ + theDeck=subword(theDeck,2 ) /*diminish deck, remove one card.*/ + end /*player*/ + end /*numberOfCards*/ +return diff --git a/Task/Playing-cards/Racket/playing-cards.rkt b/Task/Playing-cards/Racket/playing-cards.rkt new file mode 100644 index 0000000000..c4cfb077e7 --- /dev/null +++ b/Task/Playing-cards/Racket/playing-cards.rkt @@ -0,0 +1,34 @@ +#lang racket + +;; suits: +(define suits '(club heart diamond spade)) + +;; ranks +(define ranks '(1 2 3 4 5 6 7 8 9 10 jack queen king)) + +;; cards +(define cards + (for*/list ([suit suits] [rank ranks]) + (list suit rank))) + +;; a deck is a box containing a list of cards. +(define (new-deck) + (box cards)) + +;; shuffle the cards in a deck +(define (deck-shuffle deck) + (set-box! deck (shuffle (unbox deck)))) + +;; deal a card from tA 2 3 4 5 6 7 8 9 10 J Q K>; +enum Suit he deck: +(define (deck-deal deck) + (begin0 (first (unbox deck)) + (set-box! deck (rest (unbox deck))))) + + +;; TRY IT OUT: +(define my-deck (new-deck)) +(deck-shuffle my-deck) +(deck-deal my-deck) +(deck-deal my-deck) +(length (unbox my-deck)) diff --git a/Task/Playing-cards/Ruby/playing-cards.rb b/Task/Playing-cards/Ruby/playing-cards.rb new file mode 100644 index 0000000000..0162624fb6 --- /dev/null +++ b/Task/Playing-cards/Ruby/playing-cards.rb @@ -0,0 +1,56 @@ +class Card + # class constants + Suits = ["Clubs","Hearts","Spades","Diamonds"] + Pips = ["2","3","4","5","6","7","8","9","10","Jack","Queen","King","Ace"] + + # class variables (private) + @@suit_value = Hash[ Suits.each_with_index.to_a ] + @@pip_value = Hash[ Pips.each_with_index.to_a ] + + attr_reader :pip, :suit + + def initialize(pip,suit) + @pip = pip + @suit = suit + end + + def to_s + "#{@pip} #{@suit}" + end + + # allow sorting an array of Cards: first by suit, then by value + def <=>(card) + (@@suit_value[@suit] <=> @@suit_value[card.suit]).nonzero? or \ + @@pip_value[@pip] <=> @@pip_value[card.pip] + end +end + +class Deck + def initialize + @deck = [] + for suit in Card::Suits + for pip in Card::Pips + @deck << Card.new(pip,suit) + end + end + end + + def to_s + "[#{@deck.join(", ")}]" + end + + def shuffle! + @deck.shuffle! + self + end + + def deal(*args) + @deck.shift(*args) + end +end + +deck = Deck.new.shuffle! +puts card = deck.deal +hand = deck.deal(5) +puts hand.join(", ") +puts hand.sort.join(", ") diff --git a/Task/Playing-cards/Run-BASIC/playing-cards.run b/Task/Playing-cards/Run-BASIC/playing-cards.run new file mode 100644 index 0000000000..8770b52b1b --- /dev/null +++ b/Task/Playing-cards/Run-BASIC/playing-cards.run @@ -0,0 +1,25 @@ +suite$ = "C,D,H,S" ' Club,Diamond,Hart,Spaces +card$ = "A,2,3,4,5,6,7,8,9,T,J,Q,K" ' Cards Ace to King + +dim n(55) ' make ordered deck +for i = 1 to 52 ' of 52 cards + n(i) = i +next i + +for i = 1 to 52 * 3 ' shuffle deck 3 times + i1 = int(rnd(1)*52) + 1 + i2 = int(rnd(1)*52) + 1 + h2 = n(i1) + n(i1) = n(i2) + n(i2) = h2 +next i + +for hand = 1 to 4 ' 4 hands +for deal = 1 to 13 ' deal each 13 cards + card = card + 1 ' next card in deck + s = (n(card) mod 4) + 1 ' determine suite + c = (n(card) mod 13) + 1 ' determine card + print word$(card$,c,",");word$(suite$,s,",");" "; ' show the card + next deal +print +next hand diff --git a/Task/Playing-cards/Scheme/playing-cards-1.ss b/Task/Playing-cards/Scheme/playing-cards-1.ss new file mode 100644 index 0000000000..ed725b0469 --- /dev/null +++ b/Task/Playing-cards/Scheme/playing-cards-1.ss @@ -0,0 +1,28 @@ +(define ranks + (quote (ace 2 3 4 5 6 7 8 9 10 jack queen king))) + +(define suits + (quote (clubs diamonds hearts spades))) + +(define new-deck + (apply append + (map (lambda (suit) + (map (lambda (rank) + (cons rank suit)) + ranks)) + suits))) + +(define (shuffle deck) + (define (remove-card deck index) + (if (zero? index) + (cdr deck) + (cons (car deck) (remove-card (cdr deck) (- index 1))))) + (if (null? deck) + (list) + (let ((index (random (length deck)))) + (cons (list-ref deck index) (shuffle (remove-card deck index)))))) + +(define-syntax deal! + (syntax-rules () + ((deal! deck hand) + (begin (set! hand (cons (car deck) hand)) (set! deck (cdr deck)))))) diff --git a/Task/Playing-cards/Scheme/playing-cards-2.ss b/Task/Playing-cards/Scheme/playing-cards-2.ss new file mode 100644 index 0000000000..d7b9360b08 --- /dev/null +++ b/Task/Playing-cards/Scheme/playing-cards-2.ss @@ -0,0 +1,14 @@ +(define deck + (shuffle new-deck)) + +(define hand + (list)) + +(deal! deck hand) +(deal! deck hand) +(deal! deck hand) +(deal! deck hand) +(deal! deck hand) + +(display hand) +(newline) diff --git a/Task/Playing-cards/Smalltalk/playing-cards.st b/Task/Playing-cards/Smalltalk/playing-cards.st new file mode 100644 index 0000000000..295294de5f --- /dev/null +++ b/Task/Playing-cards/Smalltalk/playing-cards.st @@ -0,0 +1,103 @@ +Object subclass: #Card + instanceVariableNames: 'thePip theSuit' + classVariableNames: 'pips suits' + poolDictionaries: '' + category: nil ! + +!Card class methods! +initialize + suits ifNil: [ suits := 'clubs,hearts,spades,diamonds' subStrings: $, ]. + pips ifNil: [ pips := '2,3,4,5,6,7,8,9,10,jack,queen,king,ace' subStrings: $, ] +! +new + | o | + o := super new. + ^o +! +new: card + | o | + o := self new. + o initWithPip: (card at: 1) andSuit: (card at: 2). + ^o +!! + +!Card class methods ! +pips + Card initialize. + ^pips +! +suits + Card initialize. + ^suits +!! + +!Card methods! +initWithPip: aPip andSuit: aSuit + ( (pips includes: aPip asLowercase) & + (suits includes: aSuit asLowercase) ) + ifTrue: [ + thePip := aPip copy. + theSuit := aSuit copy + ] ifFalse: [ 'Unknown pip or suit' displayOn: stderr . + Character nl displayOn: stderr ]. + ^self +! +asString + ^('(%1,%2)' % { thePip . theSuit }) +! +display + self asString display +! +displayNl + self display. + Character nl display +!! + + +Object subclass: #Deck + instanceVariableNames: 'deck' + classVariableNames: '' + poolDictionaries: '' + category: nil ! + +!Deck class methods ! +new + |d| + d := super new. + d init. + ^d +!! + +!Deck methods ! +init + deck := OrderedCollection new. + Card suits do: [ :suit | + Card pips do: [ :pip | + deck add: (Card new: { pip . suit }) + ] + ] +! +deck + ^deck +! +shuffle + 1 to: self deck size do: [ :i | + |r2 o| + r2 := Random between: 1 and: self deck size. + o := self deck at: i. + self deck at: i put: (self deck at: r2). + self deck at: r2 put: o + ]. + ^self +! +display + self deck do: [ :card | + card displayNl + ] +! +deal + ^self deck removeFirst +!! + +"create a deck, shuffle it, remove the first card and display it" +Deck new shuffle deal displayNl. diff --git a/Task/Playing-cards/Tcl/playing-cards.tcl b/Task/Playing-cards/Tcl/playing-cards.tcl new file mode 100644 index 0000000000..c1f83aaf2b --- /dev/null +++ b/Task/Playing-cards/Tcl/playing-cards.tcl @@ -0,0 +1,66 @@ +package require Tcl 8.5 + +namespace eval playing_cards { + variable deck + #variable suits {C D H S} + variable suits {\u2663 \u2662 \u2661 \u2660} + variable pips {2 3 4 5 6 7 8 9 10 J Q K A} + + proc new_deck {} { + variable deck + set deck [list] + for {set i 0} {$i < 52} {incr i} { + lappend deck $i + } + } + + proc shuffle {} { + variable deck + # shuffle in place + for {set i 51} {$i > 0} {incr i -1} { + set n [expr {int($i * rand())}] + set card [lindex $deck $n] + lset deck $n [lindex $deck $i] + lset deck $i $card + } + } + + proc deal {{num 1}} { + variable deck + incr num -1 + set cards [lrange $deck 0 $num] + set deck [lreplace $deck 0 $num] + return $cards + } + + proc card2string {card} { + variable suits + variable pips + set suit [expr {$card / 13}] + set pip [expr {$card % 13}] + return [format "%2s %s" [lindex $pips $pip] [lindex $suits $suit]] + } + + proc print {cards args} { + array set opts [concat -sort false $args] + if {$opts(-sort)} { + set cards [lsort -integer $cards] + } + foreach card $cards { + puts [card2string $card] + } + } + + proc print_deck {} { + variable deck + print $deck + } +} + +playing_cards::new_deck +playing_cards::shuffle +set hand [playing_cards::deal 5] +puts "my hand:" +playing_cards::print $hand -sort true +puts "\nthe deck:" +playing_cards::print_deck diff --git a/Task/Playing-cards/VBScript/playing-cards-1.vbscript b/Task/Playing-cards/VBScript/playing-cards-1.vbscript new file mode 100644 index 0000000000..f280eefe4b --- /dev/null +++ b/Task/Playing-cards/VBScript/playing-cards-1.vbscript @@ -0,0 +1,66 @@ +class playingcard + dim suit + dim pips +end class + +class carddeck + private suitnames + private pipnames + private cardno + private deck(52) + private nTop + + sub class_initialize + dim suit + dim pips + suitnames = split("H,D,C,S",",") + pipnames = split("A,2,3,4,5,6,7,8,9,10,J,Q,K",",") + cardno = 0 + + for suit = 1 to 4 + for pips = 1 to 13 + set deck(cardno) = new playingcard + deck(cardno).suit = suitnames(suit-1) + deck(cardno).pips = pipnames(pips-1) + cardno = cardno + 1 + next + next + nTop = 0 + end sub + + public sub showdeck + dim a + redim a(51-nTop) + for i = nTop to 51 + a(i) = deck(i).pips & deck(i).suit + next + wscript.echo join( a, ", ") + end sub + + public sub shuffle + dim r + randomize timer + for i = nTop to 51 + r = int( rnd * ( 52 - nTop ) ) + if r <> i then + objswap deck(i),deck(r) + end if + next + end sub + + public function deal() + set deal = deck( nTop ) + nTop = nTop + 1 + end function + + public property get cardsRemaining + cardsRemaining = 52 - nTop + end property + + private sub objswap( a, b ) + dim tmp + set tmp = a + set a = b + set b = tmp + end sub +end class diff --git a/Task/Playing-cards/VBScript/playing-cards-2.vbscript b/Task/Playing-cards/VBScript/playing-cards-2.vbscript new file mode 100644 index 0000000000..83f93408fa --- /dev/null +++ b/Task/Playing-cards/VBScript/playing-cards-2.vbscript @@ -0,0 +1,17 @@ +dim pack +set pack = new carddeck +wscript.echo "--before shuffle" +pack.showdeck +pack.shuffle +wscript.echo "--after shuffle" +pack.showdeck + +dim card +for i = 1 to 52 + set card = pack.deal +next +wscript.echo "--dealt a card, it's the", card.pips, "of", card.suit +wscript.echo "--", pack.cardsRemaining, "cards remaining" +if pack.cardsRemaining <> 0 then + pack.showdeck +end if diff --git a/Task/Playing-cards/Vedit-macro-language/playing-cards.vedit b/Task/Playing-cards/Vedit-macro-language/playing-cards.vedit new file mode 100644 index 0000000000..f2742c72bc --- /dev/null +++ b/Task/Playing-cards/Vedit-macro-language/playing-cards.vedit @@ -0,0 +1,83 @@ +// Playing Cards, main program + +Call("CREATE_DECK") +Call("SHUFFLE_DECK") +#21 = Buf_Switch(Buf_Free) // #21 = players hand, 1st player +#1 = 5; Call("DEAL_CARDS") // deal 5 cards to player 1 +#22 = Buf_Switch(Buf_Free) // #22 = players hand, 2nd player +#1 = 5; Call("DEAL_CARDS") // deal 5 cards to player 2 +Buf_Switch(#10) BOF // display the deck +Return + +/////////////////////////////////////////////////////////////////////////// +// +// Create a deck into a new edit buffer. One text line for each card. +// +:CREATE_DECK: +#10 = Buf_Switch(Buf_Free) // Buffer @(#10) = the deck + +RS(1, "Diamonds") +RS(2, "Spades") +RS(3, "Hearts") +RS(4, "Clubs") + +RS(11, " Jack") +RS(12, "Queen") +RS(13, " King") +RS(14, " Ace") + +for (#1=1; #1<5; #1++) { + for (#2=2; #2<15; #2++) { + if (#2 < 11) { + Num_Ins(#2, NOCR) // pip (2 to 10) as numeric + } else { + IT(@(#2)) // pip (11 to 14) as a word + } + IT(" of ") + IT(@(#1)) IN // suit + } +} +Return + +/////////////////////////////////////////////////////////////////////////// +// +// Shuffle the deck using Fisher-Yates algorithm +// +:SHUFFLE_DECK: +Buf_Switch(#10) // the deck +#90 = Time_Tick // seed for random number generator +#91 = 51 // random numbers in range 0 to 50 +for (#1=1; #1<52; #1++) { + Call("RANDOM") + Goto_Line(Return_Value+1) + Block_Copy(#1, #1, LINESET+DELETE) + Reg_Copy(9, 1, DELETE) + Goto_Line(#1) + Reg_Ins(9) +} +Return + +//-------------------------------------------------------------- +// Generate random numbers in range 0 <= Return_Value < #91 +// #90 = Seed (0 to 0x7fffffff) +// #91 = Scaling (0 to 0x10000) + +:RANDOM: +#92 = 0x7fffffff / 48271 +#93 = 0x7fffffff % 48271 +#90 = (48271 * (#90 % #92) - #93 * (#90 / #92)) & 0x7fffffff +Return ((#90 & 0xffff) * #91 / 0x10000) + + +/////////////////////////////////////////////////////////////////////////// +// +// Deal #1 cards: move the cards from deck to current edit buffer +// +:DEAL_CARDS: +#11 = Buf_Num // this buffer (players hand) +Buf_Switch(#10) // the deck +BOF +Reg_Copy(9, #1, DELETE) // pull the first #1 cards from the deck +Buf_Switch(#11) // players hand +Reg_ins(9) // insert the cards here +Return diff --git a/Task/Plot-coordinate-pairs/0DESCRIPTION b/Task/Plot-coordinate-pairs/0DESCRIPTION new file mode 100644 index 0000000000..47c830ffc3 --- /dev/null +++ b/Task/Plot-coordinate-pairs/0DESCRIPTION @@ -0,0 +1,7 @@ +Plot a function represented as `x', `y' numerical arrays. + +Post link to your resulting image for input arrays (see [[Query Performance|'''Example''' section for Python language on ''Query Performance'' page]]): + x = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + y = {2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0}; + +This task is intended as a subtask for [[Measure relative performance of sorting algorithms implementations]]. diff --git a/Task/Plot-coordinate-pairs/ALGOL-68/plot-coordinate-pairs.alg b/Task/Plot-coordinate-pairs/ALGOL-68/plot-coordinate-pairs.alg new file mode 100644 index 0000000000..1622b6ee15 --- /dev/null +++ b/Task/Plot-coordinate-pairs/ALGOL-68/plot-coordinate-pairs.alg @@ -0,0 +1,37 @@ +#!/usr/bin/algol68g-full --script # +# -*- coding: utf-8 -*- # + +PR READ "prelude/errata.a68" PR; +PR READ "prelude/exception.a68" PR; +PR READ "prelude/math_lib.a68" PR; + +CO REQUIRED BY "prelude/graph_2d.a68" CO + MODE GREAL= REAL; # single precision # + FORMAT greal repr = $g(-3,0)$; +PR READ "prelude/graph_2d.a68" PR; + +[]REAL x = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9); +[]REAL y = (2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0); + +test:( + REF GRAPHDD test graph = INIT LOC GRAPHDD; + type OF window OF test graph := "gif"; # or gif, ps, X, pnm etc # + + title OF test graph := "Plot coordinate pairs"; + sub title OF test graph := "Algol68"; + + interval OF (axis OF test graph)[x axis] := (0, 8); + label OF (axis OF test graph)[x axis] := "X axis"; + + interval OF (axis OF test graph)[y axis] := (0, 200); + label OF (axis OF test graph)[y axis] := "Y axis"; + + PROC curve = (POINTYIELD yield)VOID: + FOR i TO UPB x DO yield((x[i],y[i])) OD; + + (begin curve OF (METHODOF test graph))(~); + (add curve OF (METHODOF test graph))(curve, (red,solid)); + (end curve OF (METHODOF test graph))(~) +); + +PR READ "postlude/exception.a68" PR diff --git a/Task/Plot-coordinate-pairs/Ada/plot-coordinate-pairs.ada b/Task/Plot-coordinate-pairs/Ada/plot-coordinate-pairs.ada new file mode 100644 index 0000000000..c2578d8c12 --- /dev/null +++ b/Task/Plot-coordinate-pairs/Ada/plot-coordinate-pairs.ada @@ -0,0 +1,46 @@ +with Gtk.Main; +with Gtk.Window; use Gtk.Window; +with Gtk.Widget; use Gtk.Widget; +with Gtk.Handlers; use Gtk.Handlers; +with Glib; use Glib; +with Gtk.Extra.Plot; use Gtk.Extra.Plot; +with Gtk.Extra.Plot_Data; use Gtk.Extra.Plot_Data; +with Gtk.Extra.Plot_Canvas; use Gtk.Extra.Plot_Canvas; +with Gtk.Extra.Plot_Canvas.Plot; use Gtk.Extra.Plot_Canvas.Plot; + +procedure PlotCoords is + package Handler is new Callback (Gtk_Widget_Record); + + Window : Gtk_Window; + Plot : Gtk_Plot; + PCP : Gtk_Plot_Canvas_Plot; + Canvas : Gtk_Plot_Canvas; + PlotData : Gtk_Plot_Data; + x, y, dx, dy : Gdouble_Array_Access; + + procedure ExitMain (Object : access Gtk_Widget_Record'Class) is + begin + Destroy (Object); Gtk.Main.Main_Quit; + end ExitMain; + +begin + x := new Gdouble_Array'(0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0); + y := new Gdouble_Array'(2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0); + Gtk.Main.Init; + Gtk_New (Window); + Set_Title (Window, "Plot coordinate pairs with GtkAda"); + Gtk_New (PlotData); + Set_Points (PlotData, x, y, dx, dy); + Gtk_New (Plot); + Add_Data (Plot, PlotData); + Autoscale (Plot); Show (PlotData); + Hide_Legends (Plot); + Gtk_New (PCP, Plot); Show (Plot); + Gtk_New (Canvas, 500, 500); Show (Canvas); + Put_Child (Canvas, PCP, 0.15, 0.15, 0.85, 0.85); + Add (Window, Canvas); + Show_All (Window); + Handler.Connect (Window, "destroy", + Handler.To_Marshaller (ExitMain'Access)); + Gtk.Main.Main; +end PlotCoords; diff --git a/Task/Plot-coordinate-pairs/BBC-BASIC/plot-coordinate-pairs.bbc b/Task/Plot-coordinate-pairs/BBC-BASIC/plot-coordinate-pairs.bbc new file mode 100644 index 0000000000..b16b7f4557 --- /dev/null +++ b/Task/Plot-coordinate-pairs/BBC-BASIC/plot-coordinate-pairs.bbc @@ -0,0 +1,29 @@ + DIM x(9), y(9) + x() = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 + y() = 2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0 + + ORIGIN 100,100 + VDU 23,23,2;0;0;0; + VDU 5 + + FOR x = 1 TO 9 + GCOL 7 : LINE 100*x,720,100*x,0 + GCOL 0 : PLOT 0,-10,-4 : PRINT ; x ; + NEXT + + FOR y = 20 TO 180 STEP 20 + GCOL 7 : LINE 900,4*y,0,4*y + GCOL 0 : PLOT 0,-212,20 : PRINT y ; + NEXT + + LINE 0,0,0,720 + LINE 0,0,900,0 + + GCOL 4 + FOR i% = 0 TO 9 + IF i%=0 THEN + MOVE 100*x(i%),4*y(i%) + ELSE + DRAW 100*x(i%),4*y(i%) + ENDIF + NEXT diff --git a/Task/Plot-coordinate-pairs/C/plot-coordinate-pairs-1.c b/Task/Plot-coordinate-pairs/C/plot-coordinate-pairs-1.c new file mode 100644 index 0000000000..c2e83a90ac --- /dev/null +++ b/Task/Plot-coordinate-pairs/C/plot-coordinate-pairs-1.c @@ -0,0 +1,117 @@ +#include +#include +#include +#include + +#define NP 10 +double x[NP] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; +double y[NP] = {2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0}; + +void minmax(double *x, double *y, + double *minx, double *maxx, + double *miny, double *maxy, int n) +{ + int i; + + *minx = *maxx = x[0]; + *miny = *maxy = y[0]; + for(i=1; i < n; i++) { + if ( x[i] < *minx ) *minx = x[i]; + if ( x[i] > *maxx ) *maxx = x[i]; + if ( y[i] < *miny ) *miny = y[i]; + if ( y[i] > *maxy ) *maxy = y[i]; + } +} + +/* likely we must play with this parameter to make the plot looks better + when using different set of data */ +#define YLAB_HEIGHT_F 0.1 +#define XLAB_WIDTH_F 0.2 +#define XDIV (NP*1.0) +#define YDIV (NP*1.0) +#define EXTRA_W 0.01 +#define EXTRA_H 0.01 +#define DOTSCALE (1.0/150.0) + +#define MAXLABLEN 32 + +#define PUSHSCALE(X,Y) pl_fscale((X),(Y)) +#define POPSCALE(X,Y) pl_fscale(1.0/(X), 1.0/(Y)) +#define FMOVESCALE(X,Y) pl_fmove((X)/sx, (Y)/sy) + +int main() +{ + int plotter, i; + double minx, miny, maxx, maxy; + double lx, ly; + double xticstep, yticstep, nx, ny; + double sx, sy; + + char labs[MAXLABLEN+1]; + + plotter = pl_newpl("png", NULL, stdout, NULL); + if ( plotter < 0 ) exit(1); + pl_selectpl(plotter); + if ( pl_openpl() < 0 ) exit(1); + + /* determines minx, miny, maxx, maxy */ + minmax(x, y, &minx, &maxx, &miny, &maxy, NP); + + lx = maxx - minx; + ly = maxy - miny; + pl_fspace(floor(minx) - XLAB_WIDTH_F * lx, floor(miny) - YLAB_HEIGHT_F * ly, + ceil(maxx) + EXTRA_W * lx, ceil(maxy) + EXTRA_H * ly); + + /* compute x,y-ticstep */ + xticstep = (ceil(maxx) - floor(minx)) / XDIV; + yticstep = (ceil(maxy) - floor(miny)) / YDIV; + + pl_flinewidth(0.25); + + /* compute scale factors to adjust aspect */ + if ( lx < ly ) { + sx = lx/ly; + sy = 1.0; + } else { + sx = 1.0; + sy = ly/lx; + } + + pl_erase(); + + /* a frame... */ + pl_fbox(floor(minx), floor(miny), + ceil(maxx), ceil(maxy)); + + /* labels and "tics" */ + pl_fontname("HersheySerif"); + for(ny=floor(miny); ny < ceil(maxy); ny += yticstep) { + pl_fline(floor(minx), ny, ceil(maxx), ny); + snprintf(labs, MAXLABLEN, "%6.2lf", ny); + FMOVESCALE(floor(minx) - XLAB_WIDTH_F * lx, ny); + PUSHSCALE(sx,sy); + pl_label(labs); + POPSCALE(sx,sy); + } + for(nx=floor(minx); nx < ceil(maxx); nx += xticstep) { + pl_fline(nx, floor(miny), nx, ceil(maxy)); + snprintf(labs, MAXLABLEN, "%6.2lf", nx); + FMOVESCALE(nx, floor(miny)); + PUSHSCALE(sx,sy); + pl_ftextangle(-90); + pl_alabel('l', 'b', labs); + POPSCALE(sx,sy); + } + + /* plot data "point" */ + pl_fillcolorname("red"); + pl_filltype(1); + for(i=0; i < NP; i++) + { + pl_fbox(x[i] - lx * DOTSCALE, y[i] - ly * DOTSCALE, + x[i] + lx * DOTSCALE, y[i] + ly * DOTSCALE); + } + + pl_flushpl(); + pl_closepl(); +} diff --git a/Task/Plot-coordinate-pairs/C/plot-coordinate-pairs-2.c b/Task/Plot-coordinate-pairs/C/plot-coordinate-pairs-2.c new file mode 100644 index 0000000000..06e5f1190b --- /dev/null +++ b/Task/Plot-coordinate-pairs/C/plot-coordinate-pairs-2.c @@ -0,0 +1,131 @@ +#include +#include +#include + +#define N 40 +double x[N], y[N]; + +void minmax(double x[], int len, double *base, double *step, int *nstep) +{ + int i; + double diff, minv, maxv; + *step = 1; + + minv = maxv = x[0]; + for (i = 1; i < len; i++) { + if (minv > x[i]) minv = x[i]; + if (maxv < x[i]) maxv = x[i]; + } + if (minv == maxv) { + minv = floor(minv); + maxv = ceil(maxv); + if (minv == maxv) { + minv--; + maxv++; + } + } else { + diff = maxv - minv; + while (*step < diff) *step *= 10; + while (*step > diff) *step /= 10; + if (*step > diff / 2) *step /= 5; + else if (*step > diff / 5) *step /= 2; + } + + *base = floor(minv / *step) * *step; + *nstep = ceil(maxv / *step) - floor(minv / *step); +} + +/* writes an eps with 400 x 300 dimention, using 12 pt font */ +#define CHARH 12 +#define CHARW 6 +#define DIMX 398 +#define DIMY (300 - CHARH) +#define BOTY 20. +int plot(double x[], double y[], int len, char *spec) +{ + int nx, ny, i; + double sx, sy, x0, y0; + char buf[100]; + int dx, dy, lx, ly; + double ofs_x, ofs_y, grid_x; + + minmax(x, len, &x0, &sx, &nx); + minmax(y, len, &y0, &sy, &ny); + + dx = -log10(sx); + dy = -log10(sy); + + ly = 0; + for (i = 0; i <= ny; i++) { + sprintf(buf, "%g\n", y0 + i * sy); + if (strlen(buf) > ly) ly = strlen(buf); + } + ofs_x = ly * CHARW; + + printf("%%!PS-Adobe-3.0\n%%%%BoundingBox: 0 0 400 300\n" + "/TimesRoman findfont %d scalefont setfont\n" + "/rl{rlineto}def /l{lineto}def /s{setrgbcolor}def " + "/rm{rmoveto}def /m{moveto}def /st{stroke}def\n", + CHARH); + for (i = 0; i <= ny; i++) { + ofs_y = BOTY + (DIMY - BOTY) / ny * i; + printf("0 %g m (%*.*f) show\n", + ofs_y - 4, ly, dy, y0 + i * sy); + if (i) printf("%g %g m 7 0 rl st\n", + ofs_x, ofs_y); + } + printf("%g %g m %g %g l st\n", ofs_x, BOTY, ofs_x, ofs_y); + + for (i = 0; i <= nx; i++) { + sprintf(buf, "%g", x0 + i * sx); + lx = strlen(buf); + grid_x = ofs_x + (DIMX - ofs_x) / nx * i; + + printf("%g %g m (%s) show\n", grid_x - CHARW * lx / 2, + BOTY - 12, buf); + if (i) printf("%g %g m 0 7 rl st\n", grid_x, BOTY); + } + printf("%g %g m %g %g l st\n", ofs_x, BOTY, grid_x, BOTY); + + if (strchr(spec, 'r')) printf("1 0 0 s\n"); + else if (strchr(spec, 'b')) printf("0 0 1 s\n"); + else if (strchr(spec, 'g')) printf("0 1 0 s\n"); + else if (strchr(spec, 'm')) printf("1 0 1 s\n"); + + if (strchr(spec, 'o')) + printf("/o { m 0 3 rm 3 -3 rl -3 -3 rl -3 3 rl closepath st} def " + ".5 setlinewidth\n"); + + if (strchr(spec, '-')) { + for (i = 0; i < len; i++) { + printf("%g %g %s ", + (x[i] - x0) / (sx * nx) * (DIMX - ofs_x) + ofs_x, + (y[i] - y0) / (sy * ny) * (DIMY - BOTY) + BOTY, + i ? "l" : "m"); + } + printf("st\n"); + } + + if (strchr(spec, 'o')) + for (i = 0; i < len; i++) { + printf("%g %g o ", + (x[i] - x0) / (sx * nx) * (DIMX - ofs_x) + ofs_x, + (y[i] - y0) / (sy * ny) * (DIMY - BOTY) + BOTY); + } + + printf("showpage\n%%EOF"); + + return 0; +} + +int main() +{ + int i; + for (i = 0; i < N; i++) { + x[i] = (double)i / N * 3.14159 * 6; + y[i] = -1337 + (exp(x[i] / 10) + cos(x[i])) / 100; + } + /* string parts: any of "rgbm": color; "-": draw line; "o": draw symbol */ + plot(x, y, N, "r-o"); + return 0; +} diff --git a/Task/Plot-coordinate-pairs/Groovy/plot-coordinate-pairs.groovy b/Task/Plot-coordinate-pairs/Groovy/plot-coordinate-pairs.groovy new file mode 100644 index 0000000000..0fff7f6f78 --- /dev/null +++ b/Task/Plot-coordinate-pairs/Groovy/plot-coordinate-pairs.groovy @@ -0,0 +1,28 @@ +import groovy.swing.SwingBuilder +import javax.swing.JFrame +import org.jfree.chart.ChartFactory +import org.jfree.chart.ChartPanel +import org.jfree.data.xy.XYSeries +import org.jfree.data.xy.XYSeriesCollection +import org.jfree.chart.plot.PlotOrientation + +def chart = { + x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + y = [2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0] + + def series = new XYSeries('plots') + [x, y].transpose().each { x, y -> series.add x, y } + + def labels = ["Plot Demo", "X", "Y"] + def data = new XYSeriesCollection(series) + def options = [false, true, false] + + def chart = ChartFactory.createXYLineChart(*labels, data, PlotOrientation.VERTICAL, *options) + new ChartPanel(chart) +} + +new SwingBuilder().edt { + frame(title:'Plot coordinate pairs', defaultCloseOperation:JFrame.EXIT_ON_CLOSE, pack:true, show:true) { + widget(chart()) + } +} diff --git a/Task/Plot-coordinate-pairs/Haskell/plot-coordinate-pairs.hs b/Task/Plot-coordinate-pairs/Haskell/plot-coordinate-pairs.hs new file mode 100644 index 0000000000..2d169da81b --- /dev/null +++ b/Task/Plot-coordinate-pairs/Haskell/plot-coordinate-pairs.hs @@ -0,0 +1,6 @@ +import Graphics.Gnuplot.Simple + +pnts = [2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0] + +doPlot = plotPathStyle [ ( Title "plotting dots" )] + (PlotStyle Points (CustomStyle [])) (zip [0..] pnts) diff --git a/Task/Plot-coordinate-pairs/HicEst/plot-coordinate-pairs.hicest b/Task/Plot-coordinate-pairs/HicEst/plot-coordinate-pairs.hicest new file mode 100644 index 0000000000..832643fae7 --- /dev/null +++ b/Task/Plot-coordinate-pairs/HicEst/plot-coordinate-pairs.hicest @@ -0,0 +1,8 @@ +REAL :: n=10, x(n), y(n) + +x = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) +y = (2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0) + +WINDOW(WINdowhandle=wh, Width=-300, Height=-300, X=1, TItle='Rosetta') +AXIS(WINdowhandle=wh, Title='x values', Yaxis, Title='y values') +LINE(X=x, Y=y, SymbolDiameter=2) diff --git a/Task/Plot-coordinate-pairs/Icon/plot-coordinate-pairs.icon b/Task/Plot-coordinate-pairs/Icon/plot-coordinate-pairs.icon new file mode 100644 index 0000000000..2ab402fea0 --- /dev/null +++ b/Task/Plot-coordinate-pairs/Icon/plot-coordinate-pairs.icon @@ -0,0 +1,86 @@ +link printf,numbers + +procedure main() +x := [0., 1., 2., 3., 4., 5., 6., 7., 8., 9.] +y := [2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0] +Plot(x,y,600,400) +end + +$define POINTR 2 # Point Radius +$define POINTC "red" # Point Colour +$define GRIDC "grey" # grid colour +$define AXISC "black" # axis/label colour +$define BORDER 60 # per side border +$define TICKS 5. # grid ticks per axis +$define AXISFH 20 # font height for axis labels + +procedure Plot(x,y,cw,ch) + + /cw := 700 # default dimensions + /ch := 400 + uw := cw-BORDER*2 # usable dimensions + uh := ch-BORDER*2 + + wparms := ["Plot","g", + sprintf("size=%d,%d",cw,ch), + "bg=white"] # base window parms + + dx := sprintf("dx=%d",BORDER) # grid origin + dy := sprintf("dy=%d",BORDER) + + &window := open!wparms | stop("Unable to open window") + X := scale(x,uw) # scale data to usable space + Y := scale(y,uh,"invert") + + WAttrib(dx,dy) # set origin=grid & draw grid + every x := (X.tickfrom to X.tickto by X.tick) * X.tickscale do { + if x = 0 then Fg(AXISC) else Fg(GRIDC) + DrawLine(x,Y.tickfrom*Y.tickscale,x,Y.tickto*Y.tickscale) + } + every y := (Y.tickfrom to Y.tickto by Y.tick) * Y.tickscale do { + if y = uh then Fg(AXISC) else Fg(GRIDC) + DrawLine(X.tickfrom*X.tickscale,y,X.tickto*X.tickscale,y) + } + + Fg(POINTC) # draw data points .... + every i := 1 to *X.scaled do + FillCircle(X.scaled[i],Y.scaled[i],POINTR) + + Fg(AXISC) # label grid + WAttrib(dx,"dy=0") # label X axis + Font(sprintf("Helvetica,%d",AXISFH)) + ytxt := ch-BORDER+1+(WAttrib("ascent") - WAttrib("descent"))/2 + + every x := X.tickscale * (xv := X.tickfrom to X.tickto by X.tick) do + DrawString(x - TextWidth(xv)/2, ytxt + integer(AXISFH*1.5),xv) + + WAttrib("dx=0",dy) # label Y axis + every y := Y.tickscale * (yv := Y.tickfrom to Y.tickto by Y.tick) do + DrawString(BORDER/2 - TextWidth(yv)/2, ytxt - BORDER - y,yv) + + WriteImage(sprintf("PlotPoints-%d.gif",&now)) # save image + + WAttrib("dx=0","dy=0") # close off nicely + Font("Helvetica,10") + DrawString(10,ch-5,"Right click to exit") + until Event() == &rpress # wait for left mouse button + close(&window) +end + +record scaledata(low,high,range,pix,raw,scaled,tick,tickfrom,tickto,tickscale) + +procedure scale(data,pix,opts[]) + P :=scaledata( pmin := min!data, pmax := max!data, + prange := real(pmax-pmin), pix, + data,q :=[]) + + /ticks := TICKS + P.tick := ceil(prange/(10^(k:=floor(log(prange,10))))*(10^k)/ticks) + P.tickfrom := P.tick*floor(pmin/P.tick) + P.tickto := P.tick*ceil(pmax/P.tick) + P.tickscale := real(pix)/(P.tickto-P.tickfrom) + every put(q,integer((!data-P.tickfrom)*P.tickscale)) + if !opts == "invert" then # invert is for y + every q[i := 1 to *q] := pix - q[i] + return P +end diff --git a/Task/Plot-coordinate-pairs/J/plot-coordinate-pairs.j b/Task/Plot-coordinate-pairs/J/plot-coordinate-pairs.j new file mode 100644 index 0000000000..5b6b67f551 --- /dev/null +++ b/Task/Plot-coordinate-pairs/J/plot-coordinate-pairs.j @@ -0,0 +1,4 @@ +require 'plot' +X=: i.10 +Y=: 2.7 2.8 31.4 38.1 58.0 76.2 100.5 130.0 149.3 180.0 +'dot; pensize 2.4' plot X;Y diff --git a/Task/Plot-coordinate-pairs/Java/plot-coordinate-pairs.java b/Task/Plot-coordinate-pairs/Java/plot-coordinate-pairs.java new file mode 100644 index 0000000000..bc7ee94912 --- /dev/null +++ b/Task/Plot-coordinate-pairs/Java/plot-coordinate-pairs.java @@ -0,0 +1,89 @@ +import java.awt.*; + import java.awt.event.*; + import java.awt.geom.*; + import javax.swing.JApplet; + import javax.swing.JFrame; + public class Plot2d extends JApplet { + double[] xi; + double[] yi; + public Plot2d(double[] x, double[] y) { + this.xi = x; + this.yi = y; + } + public static double max(double[] t) { + double maximum = t[0]; + for (int i = 1; i < t.length; i++) { + if (t[i] > maximum) { + maximum = t[i]; + } + } + return maximum; + } + public static double min(double[] t) { + double minimum = t[0]; + for (int i = 1; i < t.length; i++) { + if (t[i] < minimum) { + minimum = t[i]; + } + } + return minimum; + } + public void init() { + setBackground(Color.white); + setForeground(Color.white); + } + public void paint(Graphics g) { + Graphics2D g2 = (Graphics2D) g; + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + g2.setPaint(Color.black); + int x0 = 70; + int y0 = 10; + int xm = 670; + int ym = 410; + int xspan = xm - x0; + int yspan = ym - y0; + double xmax = max(xi); + double xmin = min(xi); + double ymax = max(yi); + double ymin = min(yi); + g2.draw(new Line2D.Double(x0, ym, xm, ym)); + g2.draw(new Line2D.Double(x0, ym, x0, y0)); + for (int j = 0; j < 5; j++) { + int interv = 4; + g2.drawString("" + (j * (xmax - xmin) / interv + xmin), j * xspan / interv + x0 - 10, ym + 20); + g2.drawString("" + (j * (ymax - ymin) / interv + ymin), x0 - 20 - (int) (9 * Math.log10(ymax)), + ym - j * yspan / interv + y0 - 5); + g2.draw(new Line2D.Double(j * xspan / interv + x0, ym, j * xspan / interv + x0, ym + 5)); + g2.draw(new Line2D.Double(x0 - 5, j * yspan / interv + y0, x0, j * yspan / interv + y0)); + } + for (int i = 0; i < xi.length; i++) { + int f = (int) ((xi[i] - xmin) * xspan / (xmax - xmin)); + int h = (int) (((ymax - ymin) - (yi[i] - ymin)) * yspan / (ymax - ymin)); + g2.drawString("o", x0 + f - 3, h + 14); + } + for (int i = 0; i < xi.length - 1; i++) { + int f = (int) ((xi[i] - xmin) * xspan / (xmax - xmin)); + int f2 = (int) ((xi[i + 1] - xmin) * xspan / (xmax - xmin)); + int h = (int) (((ymax - ymin) - (yi[i] - ymin)) * yspan / (ymax - ymin)); + int h2 = (int) (((ymax - ymin) - (yi[i + 1] - ymin)) * yspan / (ymax - ymin)); + g2.draw(new Line2D.Double(f + x0, h + y0, f2 + x0, h2 + y0)); + } + } + public static void main(String args[]) { + JFrame f = new JFrame("ShapesDemo2D"); + f.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + System.exit(0); + } + }); + double[] r = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + double[] t = {2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.09}; + JApplet applet = new Plot2d(r, t); + f.getContentPane().add("Center", applet); + applet.init(); + f.pack(); + f.setSize(new Dimension(720, 480)); + f.show(); + } + } diff --git a/Task/Plot-coordinate-pairs/Liberty-BASIC/plot-coordinate-pairs-1.liberty b/Task/Plot-coordinate-pairs/Liberty-BASIC/plot-coordinate-pairs-1.liberty new file mode 100644 index 0000000000..c3c6827fd0 --- /dev/null +++ b/Task/Plot-coordinate-pairs/Liberty-BASIC/plot-coordinate-pairs-1.liberty @@ -0,0 +1,34 @@ + 'Plotting coordinate pairs MainWin - Style +For i = 0 To 9 + x(i) = i +Next i + +y(0) = 2.7 +y(1) = 2.8 +y(2) = 31.4 +y(3) = 38.1 +y(4) = 58.0 +y(5) = 76.2 +y(6) = 100.5 +y(7) = 130.0 +y(8) = 149.3 +y(9) = 180.0 + +Locate 4, 22 +For i = 0 To 9 + Locate ((i * 4) + 2), 22 + Print i +Next i + +For i = 0 To 20 Step 2 + Locate 0, (21 - i) + Print (i * 10) +Next i + + +For i = 0 To 9 + Locate (x(i) * 4) + 2, (21 - (y(i)/ 10)) + Print "." +Next i + +End diff --git a/Task/Plot-coordinate-pairs/Liberty-BASIC/plot-coordinate-pairs-2.liberty b/Task/Plot-coordinate-pairs/Liberty-BASIC/plot-coordinate-pairs-2.liberty new file mode 100644 index 0000000000..924648a50a --- /dev/null +++ b/Task/Plot-coordinate-pairs/Liberty-BASIC/plot-coordinate-pairs-2.liberty @@ -0,0 +1,63 @@ +nomainwin + +DATA 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 +DATA 2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0 + +For i = 0 To 9 + READ tmp: x( i) = tmp +Next i + +For i = 0 To 9 + READ tmp: y( i) = tmp +Next i + +'Plotting coordinate pairs +WindowHeight = 500 +WindowWidth = 430 +Open "Plot coordinate pairs" For Graphics_nsb_nf As #gwin +#gwin "trapclose [quit.gwin]" +#gwin "Color Black; Down" + +'25, 418 is 0,0 +global offsetX, offsetY, scaleX, scaleY +offsetX = 25: offsetY = 418 +scaleX = 40: scaleY = 2 +maxX = 9: maxY = 200 + +#gwin "line "; sx( maxX);" "; sy( 0);" "; sx( 0); " "; sy( 0) +#gwin "goto "; sx( 0); " "; sy( maxY) + +For x = 0 To 9 + #gwin "place ";sx(x);" ";sy(0) + #gwin "Go -18" + #gwin "|"; x +Next + +#gwin "turn 90" +For y = 0 To 200 Step 20 + #gwin "place ";sx(0);" ";sy(y) + #gwin "Go -5" + #gwin "place ";0;" ";sy(y) + #gwin "|"; y +Next + +#gwin "size 3" +For i = 0 To 9 + #gwin "set ";sx(x(i));" ";sy(y(i)) +Next i + +#gwin "Flush" +Wait + +[quit.gwin] + Close #gwin + End + +'x, y to screen x, y +function sx(x) + sx = offsetX +x*scaleX +end function + +function sy(y) + sy = offsetY-y*scaleY 'y is inverted +end function diff --git a/Task/Plot-coordinate-pairs/MATLAB/plot-coordinate-pairs.m b/Task/Plot-coordinate-pairs/MATLAB/plot-coordinate-pairs.m new file mode 100644 index 0000000000..a797cd4b85 --- /dev/null +++ b/Task/Plot-coordinate-pairs/MATLAB/plot-coordinate-pairs.m @@ -0,0 +1,3 @@ +>> x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; +>> y = [2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0]; +>> plot(x,y,'.-') diff --git a/Task/Plot-coordinate-pairs/Mathematica/plot-coordinate-pairs.math b/Task/Plot-coordinate-pairs/Mathematica/plot-coordinate-pairs.math new file mode 100644 index 0000000000..d3619d1567 --- /dev/null +++ b/Task/Plot-coordinate-pairs/Mathematica/plot-coordinate-pairs.math @@ -0,0 +1,3 @@ +x={0,1,2,3,4,5,6,7,8,9}; +y={2.7,2.8,31.4,38.1,58.0,76.2,100.5,130.0,149.3,180.0}; +ListPlot[{x, y} // Transpose] diff --git a/Task/Plot-coordinate-pairs/Maxima/plot-coordinate-pairs.maxima b/Task/Plot-coordinate-pairs/Maxima/plot-coordinate-pairs.maxima new file mode 100644 index 0000000000..8ade9c490e --- /dev/null +++ b/Task/Plot-coordinate-pairs/Maxima/plot-coordinate-pairs.maxima @@ -0,0 +1,3 @@ +(%i1) ".." (m, n) := makelist (i, i, m, n); infix ("..")$ +(%i2) x: 0 .. 9$ y:[2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0]$ +(%i3) plot2d(['discrete, x, y], [style, [points,5,1,1]], [gnuplot_term, png], [gnuplot_out_file, "qsort-range-10-9.png"])$ diff --git a/Task/Plot-coordinate-pairs/OCaml/plot-coordinate-pairs-1.ocaml b/Task/Plot-coordinate-pairs/OCaml/plot-coordinate-pairs-1.ocaml new file mode 100644 index 0000000000..e251ee1e19 --- /dev/null +++ b/Task/Plot-coordinate-pairs/OCaml/plot-coordinate-pairs-1.ocaml @@ -0,0 +1,20 @@ +#load "graphics.cma" +open Graphics + +let round x = int_of_float (floor(x +. 0.5)) + +let x = [0; 1; 2; 3; 4; 5; 6; 7; 8; 9] +and y = [2.7; 2.8; 31.4; 38.1; 58.0; 76.2; 100.5; 130.0; 149.3; 180.0] + +let () = + open_graph ""; + List.iter2 + (fun x y -> + (* scale to fit in the window *) + let _x = x * 30 + and _y = round(y *. 2.0) in + plot _x _y) + x y; + ignore(wait_next_event [Key_pressed]); + close_graph(); +;; diff --git a/Task/Plot-coordinate-pairs/OCaml/plot-coordinate-pairs-2.ocaml b/Task/Plot-coordinate-pairs/OCaml/plot-coordinate-pairs-2.ocaml new file mode 100644 index 0000000000..aefaab82c4 --- /dev/null +++ b/Task/Plot-coordinate-pairs/OCaml/plot-coordinate-pairs-2.ocaml @@ -0,0 +1,10 @@ +module A = Archimedes + +let y = [|2.7; 2.8; 31.4; 38.1; 58.0; 76.2; 100.5; 130.0; 149.3; 180.0|] + +let () = + let vp = A.init [] in + A.Axes.box vp; + A.set_color vp A.Color.red; + A.Array.y vp y; + A.close vp diff --git a/Task/Plot-coordinate-pairs/Octave/plot-coordinate-pairs.octave b/Task/Plot-coordinate-pairs/Octave/plot-coordinate-pairs.octave new file mode 100644 index 0000000000..bebbc0f10f --- /dev/null +++ b/Task/Plot-coordinate-pairs/Octave/plot-coordinate-pairs.octave @@ -0,0 +1,4 @@ +x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; +y = [2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0]; +plot(x,y,"o"); +pause; diff --git a/Task/Plot-coordinate-pairs/PARI-GP/plot-coordinate-pairs.pari b/Task/Plot-coordinate-pairs/PARI-GP/plot-coordinate-pairs.pari new file mode 100644 index 0000000000..9e91a3d764 --- /dev/null +++ b/Task/Plot-coordinate-pairs/PARI-GP/plot-coordinate-pairs.pari @@ -0,0 +1 @@ +plothraw(vx, vy) diff --git a/Task/Plot-coordinate-pairs/Perl-6/plot-coordinate-pairs.pl6 b/Task/Plot-coordinate-pairs/Perl-6/plot-coordinate-pairs.pl6 new file mode 100644 index 0000000000..0e52516f4b --- /dev/null +++ b/Task/Plot-coordinate-pairs/Perl-6/plot-coordinate-pairs.pl6 @@ -0,0 +1,16 @@ +use SVG; +use SVG::Plot; + +my @x = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9); +my @y = (2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0); + +my $svg = SVG::Plot.new( + width => 512, + height => 512, + x => @x, + x-tick-step => { 1 }, + values => [@y], + title => 'Coordinate Pairs', +).plot(:xy-lines); + +say SVG.serialize($svg); diff --git a/Task/Plot-coordinate-pairs/Perl/plot-coordinate-pairs-1.pl b/Task/Plot-coordinate-pairs/Perl/plot-coordinate-pairs-1.pl new file mode 100644 index 0000000000..6f877b1ac0 --- /dev/null +++ b/Task/Plot-coordinate-pairs/Perl/plot-coordinate-pairs-1.pl @@ -0,0 +1,15 @@ +use GD::Graph::points; + +@data = ( + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], + [2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0], +); +$graph = GD::Graph::points->new(400, 300); +$gd = $graph->plot(\@data) or die $graph->error; + +# Save as image. +$format = $graph->export_format; +open(OUF, ">qsort-range-10-9.$format"); +binmode OUF; +print OUF $gd->$format(); +close(OUF); diff --git a/Task/Plot-coordinate-pairs/Perl/plot-coordinate-pairs-2.pl b/Task/Plot-coordinate-pairs/Perl/plot-coordinate-pairs-2.pl new file mode 100644 index 0000000000..887bb27351 --- /dev/null +++ b/Task/Plot-coordinate-pairs/Perl/plot-coordinate-pairs-2.pl @@ -0,0 +1,28 @@ +use Imager; +use Imager::Plot; + +@x = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9); +@y = (2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0); +$plot = Imager::Plot->new( + Width => 400, + Height => 300, + GlobalFont => 'PATH_TO_TTF_FONT', +); +$plot->AddDataSet( + X => \@x, + Y => \@y, + style => { + marker => { + size => 2, + symbol => 'circle', + color => Imager::Color->new('red'), + }, + }, +); +$img = Imager->new( + xsize => 500, + ysize => 400, +); +$img->box(filled => 1, color => 'white'); +$plot->Render(Image => $img, Xoff => 50, Yoff => 350); +$img->write(file => 'qsort-range-10-9.png'); diff --git a/Task/Plot-coordinate-pairs/PicoLisp/plot-coordinate-pairs.l b/Task/Plot-coordinate-pairs/PicoLisp/plot-coordinate-pairs.l new file mode 100644 index 0000000000..7eb2e554b5 --- /dev/null +++ b/Task/Plot-coordinate-pairs/PicoLisp/plot-coordinate-pairs.l @@ -0,0 +1,35 @@ +(load "@lib/ps.l") + +(scl 1) + +(de plot (PsFile DX DY Lst) + (let (SX (length Lst) SY (apply max Lst) N 0 Val) + (out PsFile + (psHead (+ DX 20) (+ DY 40)) + (font (9 . "Helvetica")) + (if (or (=0 SX) (=0 SY)) + (window 60 12 DX DY + (font 24 ,"Not enough Data") ) + (setq Lst # Build coordinates + (let X -1 + (mapcar + '((Y) + (cons + (*/ (inc 'X) DX SX) + (- DY (*/ Y DY SY)) ) ) + Lst ) ) ) + (color 55 95 55 # Background color + (let (X (+ DX 40) Y (+ DY 40)) + (poly T 0 0 X 0 X Y 0 Y 0 0) ) ) + (window 20 20 DX DY # Plot coordinates + (poly NIL 0 0 0 DY (- DX 20) DY) + (color 76 24 24 + (poly NIL (caar Lst) (cdar Lst) (cdr Lst)) ) ) + (window 4 4 60 12 (ps (format SY *Scl))) + (for X SX + (window (+ 6 (*/ (dec X) DX SX)) (+ 24 DY) 30 12 + (ps (format (dec X)) 0) ) ) ) + (page) ) ) ) + +(plot "plot.ps" 300 200 (2.7 2.8 31.4 38.1 58.0 76.2 100.5 130.0 149.3 180.0)) +(call 'display "plot.ps") diff --git a/Task/Plot-coordinate-pairs/PostScript/plot-coordinate-pairs.ps b/Task/Plot-coordinate-pairs/PostScript/plot-coordinate-pairs.ps new file mode 100644 index 0000000000..a16d97566a --- /dev/null +++ b/Task/Plot-coordinate-pairs/PostScript/plot-coordinate-pairs.ps @@ -0,0 +1,11 @@ +/x [0 1 2 3 4 5 6 7 8 9] def +/y [2.7 2.8 31.4 38.1 58.0 76.2 100.5 130.0 149.3 180.0] def +/i 1 def + +newpath +x 0 get y 0 get moveto +x length 1 sub{ +x i get y i get lineto +/i i 1 add def +}repeat +stroke diff --git a/Task/Plot-coordinate-pairs/PureBasic/plot-coordinate-pairs.purebasic b/Task/Plot-coordinate-pairs/PureBasic/plot-coordinate-pairs.purebasic new file mode 100644 index 0000000000..604d056a7e --- /dev/null +++ b/Task/Plot-coordinate-pairs/PureBasic/plot-coordinate-pairs.purebasic @@ -0,0 +1,89 @@ +Structure PlotData + x.i + y.f +EndStructure + +Global i, x, y.f, max_x, max_y, min_x = #MAXLONG, min_y = Infinity() +Define count = (?serie_y - ?serie_x) / SizeOf(Integer) - 1 +Global Dim MyData.PlotData(count) + +Restore serie_x +For i = 0 To count + Read.i x + MyData(i)\x = x + If x > max_x: max_x = x: EndIf + If x < min_x: min_x = x: EndIf +Next +Restore serie_y +For i = 0 To count + Read.f y + MyData(i)\y = y + If y > max_y: max_y = y: EndIf + If y < min_y: min_y = y: EndIf +Next + +Procedure UpdatePlot(Win, w, h) + Static gblm = 20, gtrm = 5 ;graph's bottom-left and top-right margin + + Protected count = ArraySize(MyData()) + If w > gblm And h > gblm And count > 0 + SetWindowTitle(Win, "PureBasic Plot " + Str(w) + "x" + Str(h)) + Protected gw = w - gblm, gh = h - gblm ;graph's width and height + Protected i, yf.f, xf.f + yf = (gh - gtrm) / max_y + xf = (gw - gtrm) / max_x + + CreateImage(0, w, h) + Protected OutputID = ImageOutput(0) + StartDrawing(OutputID) + DrawingMode(#PB_2DDrawing_Transparent) + ;- Draw grid + For i = 0 To count + y = gh - max_y * i / count * yf + LineXY(gblm, y, w - gtrm, y, $467E3E) + ; Y-scale + DrawText(1, y - 5, RSet(StrD(i / count * max_y, 1), 5)) + x = gblm + max_x * i / count * xf + y = gh + ; X-Scale + LineXY(x, y, x, gtrm, $467E3E) + If i: DrawText(x - 5, y + 2, Str(i)): EndIf + Next + + ;- Draw curve + Protected ox = gblm, oy = gh, x, y + For i = 0 To count + x = gblm + MyData(i)\x * xf + y = gh - MyData(i)\y * yf + LineXY(ox, oy, x, y, $0133EE) + ox = x: oy = y + Next + StopDrawing() + ImageGadget(0, 0, 0, w, h, ImageID(0)) + EndIf +EndProcedure + +Define Win = OpenWindow(#PB_Any, 0, 0, 600, 400,"", #PB_Window_SystemMenu | #PB_Window_SizeGadget) +If Win + SmartWindowRefresh(Win, 1) + UpdatePlot(Win, WindowWidth(Win), WindowHeight(Win)) + Repeat + Define event = WaitWindowEvent() + Select event + Case #PB_Event_SizeWindow + UpdatePlot(Win, WindowWidth(Win), WindowHeight(Win)) + EndSelect + Until event = #PB_Event_CloseWindow + + ; Save the plot if the user wants to + If MessageRequester("Question", "Save it?", #PB_MessageRequester_YesNo) = #PB_MessageRequester_Yes + Define File$=SaveFileRequester("Save as", "PB.png", "PNG (*.png)|*.png", 0) + UsePNGImageEncoder() + SaveImage(0, File$, #PB_ImagePlugin_PNG) + EndIf +EndIf + +DataSection + serie_x: Data.i 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 + serie_y: Data.f 2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0 +EndDataSection diff --git a/Task/Plot-coordinate-pairs/Python/plot-coordinate-pairs.py b/Task/Plot-coordinate-pairs/Python/plot-coordinate-pairs.py new file mode 100644 index 0000000000..a30cc3fc73 --- /dev/null +++ b/Task/Plot-coordinate-pairs/Python/plot-coordinate-pairs.py @@ -0,0 +1,6 @@ +>>> x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] +>>> y = [2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0] + +>>> import pylab +>>> pylab.plot(x, y, 'bo') +>>> pylab.savefig('qsort-range-10-9.png') diff --git a/Task/Plot-coordinate-pairs/R/plot-coordinate-pairs-1.r b/Task/Plot-coordinate-pairs/R/plot-coordinate-pairs-1.r new file mode 100644 index 0000000000..ebfde37b87 --- /dev/null +++ b/Task/Plot-coordinate-pairs/R/plot-coordinate-pairs-1.r @@ -0,0 +1,2 @@ +x <- c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) +y <- c(2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0) diff --git a/Task/Plot-coordinate-pairs/R/plot-coordinate-pairs-2.r b/Task/Plot-coordinate-pairs/R/plot-coordinate-pairs-2.r new file mode 100644 index 0000000000..344aa37a93 --- /dev/null +++ b/Task/Plot-coordinate-pairs/R/plot-coordinate-pairs-2.r @@ -0,0 +1 @@ +plot(x,y) diff --git a/Task/Plot-coordinate-pairs/R/plot-coordinate-pairs-3.r b/Task/Plot-coordinate-pairs/R/plot-coordinate-pairs-3.r new file mode 100644 index 0000000000..319b0c73fe --- /dev/null +++ b/Task/Plot-coordinate-pairs/R/plot-coordinate-pairs-3.r @@ -0,0 +1,2 @@ +library(lattice) +xyplot(y~x) diff --git a/Task/Plot-coordinate-pairs/R/plot-coordinate-pairs-4.r b/Task/Plot-coordinate-pairs/R/plot-coordinate-pairs-4.r new file mode 100644 index 0000000000..e03906a67b --- /dev/null +++ b/Task/Plot-coordinate-pairs/R/plot-coordinate-pairs-4.r @@ -0,0 +1,2 @@ +library(ggplot2) +qplot(x,y) diff --git a/Task/Plot-coordinate-pairs/Ruby/plot-coordinate-pairs.rb b/Task/Plot-coordinate-pairs/Ruby/plot-coordinate-pairs.rb new file mode 100644 index 0000000000..bbecf5ac85 --- /dev/null +++ b/Task/Plot-coordinate-pairs/Ruby/plot-coordinate-pairs.rb @@ -0,0 +1,12 @@ +require 'gnuplot' + +x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] +y = [2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0] +Gnuplot.open do |gp| + Gnuplot::Plot.new( gp ) do |plot| + plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds| + ds.with = "linespoints" + ds.notitle + end + end +end diff --git a/Task/Plot-coordinate-pairs/Scala/plot-coordinate-pairs.scala b/Task/Plot-coordinate-pairs/Scala/plot-coordinate-pairs.scala new file mode 100644 index 0000000000..35c40d237a --- /dev/null +++ b/Task/Plot-coordinate-pairs/Scala/plot-coordinate-pairs.scala @@ -0,0 +1,94 @@ +import scala.swing._ +import scala.swing.Swing._ +import scala.swing.{MainFrame, Panel, SimpleGUIApplication} +import scala.swing.event._ +import java.awt.{Color, Dimension, Graphics, Graphics2D, Point, geom} + +object PlotCoordPairs extends SimpleSwingApplication { + + //min/max of display-x resp. y + val dx0 = 70 + val dy0 = 30 + val dxm = 670 + val dym = 430 + + val prefSizeX = 720 + val prefSizeY = 480 + + lazy val ui = new Panel { + background = Color.white + preferredSize = (prefSizeX, prefSizeY) + + import math._ + val xmax = { + val f1 = pow(10,log10(xs.max).toInt) + val f2 = if (f1<10) 10 else round(xs.max/f1)*f1 + if (f2 >= xs.max) f2 else (round(xs.max/f1)+1)*f1 + } + val ymax = { + val f1 = pow(10,log10(ys.max).toInt) + val f2 = if (f1<10) 10 else round(ys.max/f1)*f1 + if (f2 >= ys.max) f2 else (round(ys.max/f1)+1)*f1 + } + val xinterv = xmax/xs.size + val yinterv = ymax/xs.size + + case class Coord(x: Double, y: Double) { + val dx = (x/xmax*(dxm-dx0)+dx0).toInt + val dy = (dym-y/ymax*(dym-dy0)).toInt + } + + val pcentre = Coord(0,0) + val pxmax = Coord(xmax,0) + val pymax = Coord(0, ymax) + + //axes: + var a_path = new geom.GeneralPath + a_path.moveTo(pcentre.dx, pcentre.dy) + a_path.lineTo(pxmax.dx, pxmax.dy) //x-axis + a_path.moveTo(pcentre.dx, pcentre.dy) + a_path.lineTo(pymax.dx, pymax.dy) //y-axis + // interval signs: + (0 to xs.size-1).map(i=>Coord(i*xinterv, 0)).map(p=>{a_path.moveTo(p.dx,p.dy);a_path.lineTo(p.dx,p.dy+5)}) + (0 to xs.size-1).map(i=>Coord(0, i*yinterv)).map(p=>{a_path.moveTo(p.dx,p.dy);a_path.lineTo(p.dx-5,p.dy)}) + + //grid: + var g_path = new geom.GeneralPath + (1 to xs.size).map(i=>Coord(i*xinterv, 0)).map(p=>{g_path.moveTo(p.dx,p.dy);g_path.lineTo(Coord(p.x,ymax).dx,Coord(p.x,ymax).dy)}) + (1 to xs.size).map(i=>Coord(0, i*yinterv)).map(p=>{g_path.moveTo(p.dx,p.dy);g_path.lineTo(Coord(xmax,p.y).dx,Coord(xmax,p.y).dy)}) + + //labeling: + val xlabels = (0 to xs.size).map(i=>{val p=Coord(i*xinterv,0); Triple(p.x.toInt.toString,p.dx-3,p.dy+20)}) + val ylabels = (0 to xs.size).map(i=>{val p=Coord(0,i*yinterv); Triple(p.y.toInt.toString,p.dx-30,p.dy+5)}) + + //curve: + var path = new geom.GeneralPath + val curve = (0 to xs.size-1).map(i=>Coord(xs(i),ys(i))) + path.moveTo(curve(0).dx,curve(0).dy) + curve.map(p=>path.lineTo(p.dx,p.dy)) + //...flag all function values: + val rects = curve.map(p=>new Rectangle(p.dx-3, p.dy-3, 6, 6)) + + override def paintComponent(g: Graphics2D) = { + super.paintComponent(g) + + g.setColor(Color.lightGray) + g.draw(g_path) + g.setColor(Color.black) + g.draw(a_path) + xlabels.map(t=>g.drawString(t._1,t._2,t._3)) + ylabels.map(t=>g.drawString(t._1,t._2,t._3)) + g.draw(path) + rects.map(g.draw(_)) + } + } + + val xs = List(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) + val ys = List(2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0) + + def top = new MainFrame { + title = "Rosetta Code >>> Task: Plot coordinate pairs | Language: Scala" + contents = ui + } + +} diff --git a/Task/Plot-coordinate-pairs/TI-89-BASIC/plot-coordinate-pairs.ti-89 b/Task/Plot-coordinate-pairs/TI-89-BASIC/plot-coordinate-pairs.ti-89 new file mode 100644 index 0000000000..c8b962b1c6 --- /dev/null +++ b/Task/Plot-coordinate-pairs/TI-89-BASIC/plot-coordinate-pairs.ti-89 @@ -0,0 +1,4 @@ +FnOff +PlotsOff +NewPlot 1, 1, x, y +ZoomData diff --git a/Task/Plot-coordinate-pairs/Tcl/plot-coordinate-pairs.tcl b/Task/Plot-coordinate-pairs/Tcl/plot-coordinate-pairs.tcl new file mode 100644 index 0000000000..9b608ac88f --- /dev/null +++ b/Task/Plot-coordinate-pairs/Tcl/plot-coordinate-pairs.tcl @@ -0,0 +1,56 @@ +package require Tk + +# The actual plotting engine +proc plotxy {canvas xs ys} { + global xfac yfac + set maxx [tcl::mathfunc::max {*}$xs] + set maxy [tcl::mathfunc::max {*}$ys] + set xfac [expr {[winfo width $canvas] * 0.8/$maxx}] + set yfac [expr {[winfo height $canvas] * 0.8/$maxy}] + scale $canvas x 0 $maxx $xfac + scale $canvas y 0 $maxy $yfac + foreach x $xs y $ys { + dot $canvas [expr {$x*$xfac}] [expr {$y*$yfac}] -fill red + } +} +# Rescales the contents of the given canvas +proc scale {canvas direction from to fac} { + set f [expr {$from*$fac}] + set t [expr {$to*$fac}] + switch -- $direction { + x { + set f [expr {$from * $fac}] + set t [expr {$to * $fac}] + $canvas create line $f 0 $t 0 + $canvas create text $f 0 -anchor nw -text $from + $canvas create text $t 0 -anchor n -text $to + + } + y { + set f [expr {$from * -$fac}] + set t [expr {$to * -$fac}] + $canvas create line 0 $f 0 $t + $canvas create text 0 $f -anchor se -text $from + $canvas create text 0 $t -anchor e -text $to + } + } +} +# 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 +} + +pack [canvas .c -background white] +update +set xs {0 1 2 3 4 5 6 7 8 9} +set ys {2.7 2.8 31.4 38.1 58.0 76.2 100.5 130.0 149.3 180.0} +plotxy .c $xs $ys +.c config -scrollregion [.c bbox all] +.c move all 20 20 + +# Save image (this is the only part that requires an external library) +package require Img +set im [image create photo -data .c] +$im write plotxy.png -format PNG diff --git a/Task/Plot-coordinate-pairs/Ursala/plot-coordinate-pairs-1.ursala b/Task/Plot-coordinate-pairs/Ursala/plot-coordinate-pairs-1.ursala new file mode 100644 index 0000000000..f777a47a9c --- /dev/null +++ b/Task/Plot-coordinate-pairs/Ursala/plot-coordinate-pairs-1.ursala @@ -0,0 +1,11 @@ +#import std +#import flo +#import fit +#import plo + +x = <0., 1., 2., 3., 4., 5., 6., 7., 8., 9.> +y = <2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0> + +#output dot'tex' latex_document+ plot + +main = visualization[curves: ] diff --git a/Task/Plot-coordinate-pairs/Ursala/plot-coordinate-pairs-2.ursala b/Task/Plot-coordinate-pairs/Ursala/plot-coordinate-pairs-2.ursala new file mode 100644 index 0000000000..cc7d97931c --- /dev/null +++ b/Task/Plot-coordinate-pairs/Ursala/plot-coordinate-pairs-2.ursala @@ -0,0 +1,17 @@ +main = + +visualization[ + abscissa: axis[ + variable: 'problem size', + hats: printf/*'%0.0f' ari10/0. 9.], + ordinates: ~&iNC axis[ + variable: 'execution time ($\mu$s)', + hats: printf/*'%0.1f' ari6/0. 180.], + curves: < + curve[ + points: ^(~&,chord_fit0@p/x y)* ari200/0. 9., + attributes: {'linecolor': 'lightgray'}], + curve[ + scattered: true, + points: ~&p/x y, + attributes: {'linecolor': 'black'}]>] diff --git a/Task/Plot-coordinate-pairs/XPL0/plot-coordinate-pairs.xpl0 b/Task/Plot-coordinate-pairs/XPL0/plot-coordinate-pairs.xpl0 new file mode 100644 index 0000000000..2d879c7c67 --- /dev/null +++ b/Task/Plot-coordinate-pairs/XPL0/plot-coordinate-pairs.xpl0 @@ -0,0 +1,34 @@ +include c:\cxpl\codes; \intrinsic 'code' declarations + +def ScrW=640, ScrH=480, VidMode=$101; +def Sx = ScrW/10, \pixels per horz grid line + Sy = ScrH/10, \pixels per vert grid line + Ox = (3+1+1)*8+2, \offset for horz grid: allow room for "180.0" + Oy = ScrH-20; \offset for vert grid: allow room for labels +int X, DataX; +real Y, DataY, Gain; +def Brown=6, LCyan=11; + +[DataX:= [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + DataY:= [2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0]; + +SetVid(VidMode); +for X:= 0 to 9 do \draw grid + [Move(X*Sx+Ox, Oy); Line(X*Sx+Ox, Oy-9*Sy, Brown); \vert lines + Move(Ox, Oy-X*Sy); Line(9*Sx+Ox, Oy-X*Sy, Brown); \horz lines + ]; +Format(3,1); Attrib(LCyan); \label grid +Y:= 0.0; +for X:= 0 to 9 do + [Move(X*Sx+Ox-3, Oy+6); IntOut(6, X); \X axis + Move(0, Oy-X*Sy-7); RlOut(6, Y); \Y axis + Y:= Y + 20.0; + ]; +Gain:= float(Sy)/20.0; +Move(DataX(0)*Sx+Ox, Oy-Fix(DataY(0)*Gain)); \plot points +for X:= 1 to 9 do + Line(DataX(X)*Sx+Ox, Oy-Fix(DataY(X)*Gain), LCyan); + +if ChIn(1) then []; \wait for key +SetVid(3); \restore text +] diff --git a/Task/Plot-coordinate-pairs/Yorick/plot-coordinate-pairs.yorick b/Task/Plot-coordinate-pairs/Yorick/plot-coordinate-pairs.yorick new file mode 100644 index 0000000000..0093366625 --- /dev/null +++ b/Task/Plot-coordinate-pairs/Yorick/plot-coordinate-pairs.yorick @@ -0,0 +1,6 @@ +x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; +y = [2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0]; +window, 0; +plmk, y, x; +window, 1; +plg, y, x, marks=0; diff --git a/Task/Pointers-and-references/0DESCRIPTION b/Task/Pointers-and-references/0DESCRIPTION new file mode 100644 index 0000000000..b8450541e7 --- /dev/null +++ b/Task/Pointers-and-references/0DESCRIPTION @@ -0,0 +1 @@ +{{basic data operation}}In this task, the goal is to demonstrate common operations on pointers and references. diff --git a/Task/Pointers-and-references/1META.yaml b/Task/Pointers-and-references/1META.yaml new file mode 100644 index 0000000000..a16ddc894f --- /dev/null +++ b/Task/Pointers-and-references/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Basic Data Operations diff --git a/Task/Pointers-and-references/ALGOL-68/pointers-and-references-1.alg b/Task/Pointers-and-references/ALGOL-68/pointers-and-references-1.alg new file mode 100644 index 0000000000..8b26c2afa6 --- /dev/null +++ b/Task/Pointers-and-references/ALGOL-68/pointers-and-references-1.alg @@ -0,0 +1,2 @@ +INT var := 3; +REF INT pointer := var; diff --git a/Task/Pointers-and-references/ALGOL-68/pointers-and-references-10.alg b/Task/Pointers-and-references/ALGOL-68/pointers-and-references-10.alg new file mode 100644 index 0000000000..7640b842b6 --- /dev/null +++ b/Task/Pointers-and-references/ALGOL-68/pointers-and-references-10.alg @@ -0,0 +1,3 @@ +[9,9]INT sudoku; +REF [,]INT middle; +middle := sudoku[4:6,4:6]; diff --git a/Task/Pointers-and-references/ALGOL-68/pointers-and-references-11.alg b/Task/Pointers-and-references/ALGOL-68/pointers-and-references-11.alg new file mode 100644 index 0000000000..fbc605afea --- /dev/null +++ b/Task/Pointers-and-references/ALGOL-68/pointers-and-references-11.alg @@ -0,0 +1,4 @@ +[30]CHAR hay stack := "straw straw needle straw straw"; +REF[]CHAR needle = hay stack[13:18]; +needle[2:3] := "oo"; +print((hay stack)) diff --git a/Task/Pointers-and-references/ALGOL-68/pointers-and-references-2.alg b/Task/Pointers-and-references/ALGOL-68/pointers-and-references-2.alg new file mode 100644 index 0000000000..cfedb711d7 --- /dev/null +++ b/Task/Pointers-and-references/ALGOL-68/pointers-and-references-2.alg @@ -0,0 +1,2 @@ +INT v = pointer; # sets v to the value of var (i.e. 3) # +REF INT(pointer) := 42; # sets var to 42 # diff --git a/Task/Pointers-and-references/ALGOL-68/pointers-and-references-3.alg b/Task/Pointers-and-references/ALGOL-68/pointers-and-references-3.alg new file mode 100644 index 0000000000..ffedc7c3ab --- /dev/null +++ b/Task/Pointers-and-references/ALGOL-68/pointers-and-references-3.alg @@ -0,0 +1,2 @@ +INT othervar; +pointer := othervar; diff --git a/Task/Pointers-and-references/ALGOL-68/pointers-and-references-4.alg b/Task/Pointers-and-references/ALGOL-68/pointers-and-references-4.alg new file mode 100644 index 0000000000..32ed22be60 --- /dev/null +++ b/Task/Pointers-and-references/ALGOL-68/pointers-and-references-4.alg @@ -0,0 +1 @@ +pointer := NIL; # 0 cannot be cast to NIL # diff --git a/Task/Pointers-and-references/ALGOL-68/pointers-and-references-5.alg b/Task/Pointers-and-references/ALGOL-68/pointers-and-references-5.alg new file mode 100644 index 0000000000..f3f3aab813 --- /dev/null +++ b/Task/Pointers-and-references/ALGOL-68/pointers-and-references-5.alg @@ -0,0 +1,2 @@ +[9]INT array; +pointer := array[LWB array]; diff --git a/Task/Pointers-and-references/ALGOL-68/pointers-and-references-6.alg b/Task/Pointers-and-references/ALGOL-68/pointers-and-references-6.alg new file mode 100644 index 0000000000..350c5ac9bd --- /dev/null +++ b/Task/Pointers-and-references/ALGOL-68/pointers-and-references-6.alg @@ -0,0 +1 @@ +REF INT alias = var; diff --git a/Task/Pointers-and-references/ALGOL-68/pointers-and-references-7.alg b/Task/Pointers-and-references/ALGOL-68/pointers-and-references-7.alg new file mode 100644 index 0000000000..cdd86e5a10 --- /dev/null +++ b/Task/Pointers-and-references/ALGOL-68/pointers-and-references-7.alg @@ -0,0 +1,2 @@ +INT v2 = alias; # sets v2 to the value of var, that is, 3 # +alias := 42; # sets var to 42 # diff --git a/Task/Pointers-and-references/ALGOL-68/pointers-and-references-8.alg b/Task/Pointers-and-references/ALGOL-68/pointers-and-references-8.alg new file mode 100644 index 0000000000..46b1644f3a --- /dev/null +++ b/Task/Pointers-and-references/ALGOL-68/pointers-and-references-8.alg @@ -0,0 +1 @@ +printf(($"alias "b("IS","ISNT")" var!"l$, alias IS var)); diff --git a/Task/Pointers-and-references/ALGOL-68/pointers-and-references-9.alg b/Task/Pointers-and-references/ALGOL-68/pointers-and-references-9.alg new file mode 100644 index 0000000000..f3a3e508c0 --- /dev/null +++ b/Task/Pointers-and-references/ALGOL-68/pointers-and-references-9.alg @@ -0,0 +1,2 @@ +[9]INT array2; +REF INT ref3 = array2[LWB array2]; diff --git a/Task/Pointers-and-references/Ada/pointers-and-references-1.ada b/Task/Pointers-and-references/Ada/pointers-and-references-1.ada new file mode 100644 index 0000000000..1bd6f830c5 --- /dev/null +++ b/Task/Pointers-and-references/Ada/pointers-and-references-1.ada @@ -0,0 +1,2 @@ +type Int_Access is access Integer; +Int_Acc : Int_Access := new Integer'(5); diff --git a/Task/Pointers-and-references/Ada/pointers-and-references-2.ada b/Task/Pointers-and-references/Ada/pointers-and-references-2.ada new file mode 100644 index 0000000000..321730c425 --- /dev/null +++ b/Task/Pointers-and-references/Ada/pointers-and-references-2.ada @@ -0,0 +1 @@ +type Safe_Int_Access is not null access Integer; diff --git a/Task/Pointers-and-references/Ada/pointers-and-references-3.ada b/Task/Pointers-and-references/Ada/pointers-and-references-3.ada new file mode 100644 index 0000000000..a919f24af3 --- /dev/null +++ b/Task/Pointers-and-references/Ada/pointers-and-references-3.ada @@ -0,0 +1,7 @@ +declare + type Int_Ptr is access all Integer; + Ref : Int_Ptr; + Var : aliased Integer := 3; + Val : Integer := Var; +begin + Ref := Var'Access; -- "Ref := Val'Access;" would be a syntax error diff --git a/Task/Pointers-and-references/Ada/pointers-and-references-4.ada b/Task/Pointers-and-references/Ada/pointers-and-references-4.ada new file mode 100644 index 0000000000..11647075f3 --- /dev/null +++ b/Task/Pointers-and-references/Ada/pointers-and-references-4.ada @@ -0,0 +1 @@ +type Safe_Int_Ptr is not null access all Integer; diff --git a/Task/Pointers-and-references/Ada/pointers-and-references-5.ada b/Task/Pointers-and-references/Ada/pointers-and-references-5.ada new file mode 100644 index 0000000000..8a013ae71b --- /dev/null +++ b/Task/Pointers-and-references/Ada/pointers-and-references-5.ada @@ -0,0 +1,2 @@ +Var : Integer; +Var_Address : Address := Var'Address; diff --git a/Task/Pointers-and-references/Ada/pointers-and-references-6.ada b/Task/Pointers-and-references/Ada/pointers-and-references-6.ada new file mode 100644 index 0000000000..6318636236 --- /dev/null +++ b/Task/Pointers-and-references/Ada/pointers-and-references-6.ada @@ -0,0 +1,5 @@ +-- Demonstrate the overlay of one object on another +A : Integer; +B : Integer; +for B'Address use A'Address; +-- A and B start at the same address diff --git a/Task/Pointers-and-references/Ada/pointers-and-references-7.ada b/Task/Pointers-and-references/Ada/pointers-and-references-7.ada new file mode 100644 index 0000000000..3254ebff26 --- /dev/null +++ b/Task/Pointers-and-references/Ada/pointers-and-references-7.ada @@ -0,0 +1,8 @@ +type Container is array (Positive range <>) of Element; +for I in Container'Range loop + declare + Item : Element renames Container (I); + begin + Do_Something(Item); -- Here Item is a reference to Container (I) + end; +end loop; diff --git a/Task/Pointers-and-references/Ada/pointers-and-references-8.ada b/Task/Pointers-and-references/Ada/pointers-and-references-8.ada new file mode 100644 index 0000000000..327f58aae8 --- /dev/null +++ b/Task/Pointers-and-references/Ada/pointers-and-references-8.ada @@ -0,0 +1,4 @@ +type Container is array (Positive range <>) of Element; +for Item of Container loop + Do_Something(Item); +end loop; diff --git a/Task/Pointers-and-references/AutoHotkey/pointers-and-references.ahk b/Task/Pointers-and-references/AutoHotkey/pointers-and-references.ahk new file mode 100644 index 0000000000..bdc681d6f5 --- /dev/null +++ b/Task/Pointers-and-references/AutoHotkey/pointers-and-references.ahk @@ -0,0 +1,5 @@ +VarSetCapacity(var, 100) ; allocate memory +NumPut(87, var, 0, "Char") ; store 87 at offset 0 +MsgBox % NumGet(var, 0, "Char") ; get character at offset 0 (87) +MsgBox % &var ; address of contents pointed to by var structure +MsgBox % *&var ; integer at address of var contents (87) diff --git a/Task/Pointers-and-references/BBC-BASIC/pointers-and-references.bbc b/Task/Pointers-and-references/BBC-BASIC/pointers-and-references.bbc new file mode 100644 index 0000000000..6ee54b587e --- /dev/null +++ b/Task/Pointers-and-references/BBC-BASIC/pointers-and-references.bbc @@ -0,0 +1,26 @@ + REM Pointer to integer variable: + pointer_to_varA = ^varA% + !pointer_to_varA = 123456 + PRINT !pointer_to_varA + + REM Pointer to variant variable: + pointer_to_varB = ^varB + |pointer_to_varB = PI + PRINT |pointer_to_varB + + REM Pointer to procedure: + PROCmyproc : REM conventional call to initialise + pointer_to_myproc = ^PROCmyproc + PROC(pointer_to_myproc) + + REM Pointer to function: + pointer_to_myfunc = ^FNmyfunc + PRINT FN(pointer_to_myfunc) + END + + DEF PROCmyproc + PRINT "Executing myproc" + ENDPROC + + DEF FNmyfunc + = "Returned from myfunc" diff --git a/Task/Pointers-and-references/D/pointers-and-references-1.d b/Task/Pointers-and-references/D/pointers-and-references-1.d new file mode 100644 index 0000000000..dddc372490 --- /dev/null +++ b/Task/Pointers-and-references/D/pointers-and-references-1.d @@ -0,0 +1,2 @@ +int var; +int* ptr = &var; diff --git a/Task/Pointers-and-references/D/pointers-and-references-2.d b/Task/Pointers-and-references/D/pointers-and-references-2.d new file mode 100644 index 0000000000..f6b639e38c --- /dev/null +++ b/Task/Pointers-and-references/D/pointers-and-references-2.d @@ -0,0 +1,9 @@ +struct S{} +class C{} + +void foo(S s){} // pass by value +void foo(C c){} // pass by reference +void foo(int i){} // pass by value +void foo(int[4] i){} // pass by value +void foo(int[] i){} // pass by reference +void foo(ref T t){} // pass by reference regardless of what type T really is diff --git a/Task/Pointers-and-references/Fortran/pointers-and-references-1.f b/Task/Pointers-and-references/Fortran/pointers-and-references-1.f new file mode 100644 index 0000000000..97c56b95d9 --- /dev/null +++ b/Task/Pointers-and-references/Fortran/pointers-and-references-1.f @@ -0,0 +1 @@ +real, pointer :: pointertoreal diff --git a/Task/Pointers-and-references/Fortran/pointers-and-references-10.f b/Task/Pointers-and-references/Fortran/pointers-and-references-10.f new file mode 100644 index 0000000000..194e2fe4cd --- /dev/null +++ b/Task/Pointers-and-references/Fortran/pointers-and-references-10.f @@ -0,0 +1,6 @@ +type intpointer + integer, pointer :: p +end type intpointer + +!... + type(intpointer), dimension(100) :: parray diff --git a/Task/Pointers-and-references/Fortran/pointers-and-references-2.f b/Task/Pointers-and-references/Fortran/pointers-and-references-2.f new file mode 100644 index 0000000000..0a4328efab --- /dev/null +++ b/Task/Pointers-and-references/Fortran/pointers-and-references-2.f @@ -0,0 +1 @@ +nullify(pointertoreal) diff --git a/Task/Pointers-and-references/Fortran/pointers-and-references-3.f b/Task/Pointers-and-references/Fortran/pointers-and-references-3.f new file mode 100644 index 0000000000..b135cc9fc9 --- /dev/null +++ b/Task/Pointers-and-references/Fortran/pointers-and-references-3.f @@ -0,0 +1 @@ +real, pointer :: apointer => NULL() diff --git a/Task/Pointers-and-references/Fortran/pointers-and-references-4.f b/Task/Pointers-and-references/Fortran/pointers-and-references-4.f new file mode 100644 index 0000000000..b87dabf92c --- /dev/null +++ b/Task/Pointers-and-references/Fortran/pointers-and-references-4.f @@ -0,0 +1,2 @@ +real, target :: areal + pointertoreal => areal diff --git a/Task/Pointers-and-references/Fortran/pointers-and-references-5.f b/Task/Pointers-and-references/Fortran/pointers-and-references-5.f new file mode 100644 index 0000000000..a781c515be --- /dev/null +++ b/Task/Pointers-and-references/Fortran/pointers-and-references-5.f @@ -0,0 +1 @@ +if ( associated(pointertoreal) ) !... diff --git a/Task/Pointers-and-references/Fortran/pointers-and-references-6.f b/Task/Pointers-and-references/Fortran/pointers-and-references-6.f new file mode 100644 index 0000000000..a5dc6f52ec --- /dev/null +++ b/Task/Pointers-and-references/Fortran/pointers-and-references-6.f @@ -0,0 +1,2 @@ +integer, dimension(:), pointer :: array + allocate(array(100)) diff --git a/Task/Pointers-and-references/Fortran/pointers-and-references-7.f b/Task/Pointers-and-references/Fortran/pointers-and-references-7.f new file mode 100644 index 0000000000..9b10c95aa3 --- /dev/null +++ b/Task/Pointers-and-references/Fortran/pointers-and-references-7.f @@ -0,0 +1,4 @@ +integer, target :: i +integer, pointer :: pi +!... ... +if ( associated(pi, target=i) ) !... diff --git a/Task/Pointers-and-references/Fortran/pointers-and-references-8.f b/Task/Pointers-and-references/Fortran/pointers-and-references-8.f new file mode 100644 index 0000000000..e12e59d8cd --- /dev/null +++ b/Task/Pointers-and-references/Fortran/pointers-and-references-8.f @@ -0,0 +1,8 @@ +real, dimension(20), target :: a +real, dimension(20,20), target :: b +real, dimension(:), pointer :: p + +p => a(5:20) +! p(1) == a(5), p(2) == a(6) ... +p => b(10,1:20) +! p(1) == b(10,1), p(2) == b(10,2) ... diff --git a/Task/Pointers-and-references/Fortran/pointers-and-references-9.f b/Task/Pointers-and-references/Fortran/pointers-and-references-9.f new file mode 100644 index 0000000000..51d4a75576 --- /dev/null +++ b/Task/Pointers-and-references/Fortran/pointers-and-references-9.f @@ -0,0 +1,4 @@ +real, dimension(20) :: a +real, dimension(16) :: p + +p = a(5:20) diff --git a/Task/Pointers-and-references/Go/pointers-and-references-1.go b/Task/Pointers-and-references/Go/pointers-and-references-1.go new file mode 100644 index 0000000000..e778f93bf2 --- /dev/null +++ b/Task/Pointers-and-references/Go/pointers-and-references-1.go @@ -0,0 +1,2 @@ +var p *int // declare p to be a pointer to an int +i = &p // assign i to be the int value pointed to by p diff --git a/Task/Pointers-and-references/Go/pointers-and-references-2.go b/Task/Pointers-and-references/Go/pointers-and-references-2.go new file mode 100644 index 0000000000..0364b92f89 --- /dev/null +++ b/Task/Pointers-and-references/Go/pointers-and-references-2.go @@ -0,0 +1 @@ +var m map[string]int diff --git a/Task/Pointers-and-references/Go/pointers-and-references-3.go b/Task/Pointers-and-references/Go/pointers-and-references-3.go new file mode 100644 index 0000000000..ee5665e4a6 --- /dev/null +++ b/Task/Pointers-and-references/Go/pointers-and-references-3.go @@ -0,0 +1 @@ +m := make(map[string]int) diff --git a/Task/Pointers-and-references/Go/pointers-and-references-4.go b/Task/Pointers-and-references/Go/pointers-and-references-4.go new file mode 100644 index 0000000000..cc5dee8d8a --- /dev/null +++ b/Task/Pointers-and-references/Go/pointers-and-references-4.go @@ -0,0 +1,4 @@ +b := []byte(“hello world”) +c := b +c[0] = 'H' +fmt.Println(string(b)) diff --git a/Task/Pointers-and-references/Go/pointers-and-references-5.go b/Task/Pointers-and-references/Go/pointers-and-references-5.go new file mode 100644 index 0000000000..683be6fa6e --- /dev/null +++ b/Task/Pointers-and-references/Go/pointers-and-references-5.go @@ -0,0 +1,4 @@ +func three() *int { + i := 3 + return &i // valid. no worry, no crash. +} diff --git a/Task/Pointers-and-references/Go/pointers-and-references-6.go b/Task/Pointers-and-references/Go/pointers-and-references-6.go new file mode 100644 index 0000000000..3dc3a089cb --- /dev/null +++ b/Task/Pointers-and-references/Go/pointers-and-references-6.go @@ -0,0 +1,5 @@ +type pt struct { + x, y int +} + +return &pt{22, 79} // allocates a pt object and returns a pointer to it. diff --git a/Task/Pointers-and-references/Haskell/pointers-and-references.hs b/Task/Pointers-and-references/Haskell/pointers-and-references.hs new file mode 100644 index 0000000000..6e5a50c19f --- /dev/null +++ b/Task/Pointers-and-references/Haskell/pointers-and-references.hs @@ -0,0 +1,7 @@ +import Data.STRef + +example :: ST s () +example = do + p <- newSTRef 1 + k <- readSTRef p + writeSTRef p (k+1) diff --git a/Task/Pointers-and-references/Java/pointers-and-references.java b/Task/Pointers-and-references/Java/pointers-and-references.java new file mode 100644 index 0000000000..39b97dbd7d --- /dev/null +++ b/Task/Pointers-and-references/Java/pointers-and-references.java @@ -0,0 +1,9 @@ + public class Foo { public int x = 0; } + + void somefunction() { + Foo a; // this declares a reference to Foo object; if this is a class field, it is initialized to null + a = new Foo(); // this assigns a to point to a new Foo object + Foo b = a; // this declares another reference to point to the same object that "a" points to + a.x = 5; // this modifies the "x" field of the object pointed to by "a" + System.out.println(b.x); // this prints 5, because "b" points to the same object as "a" + } diff --git a/Task/Pointers-and-references/Modula-3/pointers-and-references-1.mod3 b/Task/Pointers-and-references/Modula-3/pointers-and-references-1.mod3 new file mode 100644 index 0000000000..b2f106cd21 --- /dev/null +++ b/Task/Pointers-and-references/Modula-3/pointers-and-references-1.mod3 @@ -0,0 +1,5 @@ +TYPE IntRef = REF INTEGER; + +VAR intref := NEW(IntRef); + +intref^ := 10 diff --git a/Task/Pointers-and-references/Modula-3/pointers-and-references-2.mod3 b/Task/Pointers-and-references/Modula-3/pointers-and-references-2.mod3 new file mode 100644 index 0000000000..14ee842d3c --- /dev/null +++ b/Task/Pointers-and-references/Modula-3/pointers-and-references-2.mod3 @@ -0,0 +1,2 @@ +VAR any: REFANY; +any := NEW(REF INTEGER); (* Modula-3 knows that any is now REF INTEGER with a tag added by NEW. *) diff --git a/Task/Pointers-and-references/Modula-3/pointers-and-references-3.mod3 b/Task/Pointers-and-references/Modula-3/pointers-and-references-3.mod3 new file mode 100644 index 0000000000..2947a1c46f --- /dev/null +++ b/Task/Pointers-and-references/Modula-3/pointers-and-references-3.mod3 @@ -0,0 +1,13 @@ +PROCEDURE Sum(READONLY a: ARRAY OF REFANY): REAL = + VAR sum := 0.0; + BEGIN + FOR i := FIRST(a) TO LAST(a) DO + TYPECASE a[i] OF + | NULL => (* skip *) + | REF INTEGER (e) => sum := sum + FLOAT(e^); + | REF REAL(e) => sum := sum + e^; + ELSE (* skip *) + END; + END; + RETURN sum; + END Sum; diff --git a/Task/Pointers-and-references/OCaml/pointers-and-references.ocaml b/Task/Pointers-and-references/OCaml/pointers-and-references.ocaml new file mode 100644 index 0000000000..315a376cc7 --- /dev/null +++ b/Task/Pointers-and-references/OCaml/pointers-and-references.ocaml @@ -0,0 +1,3 @@ +let p = ref 1;; (* create a new "reference" data structure with initial value 1 *) +let k = !p;; (* "dereference" the reference, returning the value inside *) +p := k + 1;; (* set the value inside to a new value *) diff --git a/Task/Pointers-and-references/PARI-GP/pointers-and-references.pari b/Task/Pointers-and-references/PARI-GP/pointers-and-references.pari new file mode 100644 index 0000000000..6e0676e69a --- /dev/null +++ b/Task/Pointers-and-references/PARI-GP/pointers-and-references.pari @@ -0,0 +1,3 @@ +n=1; +issquare(9,&n); +print(n); \\ prints 3 diff --git a/Task/Pointers-and-references/PHP/pointers-and-references.php b/Task/Pointers-and-references/PHP/pointers-and-references.php new file mode 100644 index 0000000000..bec15dd9d7 --- /dev/null +++ b/Task/Pointers-and-references/PHP/pointers-and-references.php @@ -0,0 +1,28 @@ + diff --git a/Task/Pointers-and-references/Perl-6/pointers-and-references.pl6 b/Task/Pointers-and-references/Perl-6/pointers-and-references.pl6 new file mode 100644 index 0000000000..3fa7a6c443 --- /dev/null +++ b/Task/Pointers-and-references/Perl-6/pointers-and-references.pl6 @@ -0,0 +1,13 @@ +my $foo = 42; # place a reference to 42 in $foo's item container +$foo++; # deref $foo name, then increment the container's contents to 43 +$foo.say; # deref $foo name, then $foo's container, and call a method on 43. + +$foo := 42; # bind a direct ref to 42 +$foo++; # ERROR, cannot modify immutable value + +my @bar = 1,2,3; # deref @bar name to array container, then set its values +@bar»++; # deref @bar name to array container, then increment each value with a hyper +@bar.say; # deref @bar name to array container, then call say on that, giving 2 3 4 + +@bar := (1,2,3); # bind name directly to a Parcel +@bar»++; # ERROR, parcels are not mutable diff --git a/Task/Pointers-and-references/Perl/pointers-and-references-1.pl b/Task/Pointers-and-references/Perl/pointers-and-references-1.pl new file mode 100644 index 0000000000..6ecd1e98be --- /dev/null +++ b/Task/Pointers-and-references/Perl/pointers-and-references-1.pl @@ -0,0 +1,9 @@ + # start with some var definitions + my $scalar = 'a string'; + my @array = ('an', 'array'); + my %hash = ( firstkey => 'a', secondkey => 'hash' ); + + # make references + my $scalarref = \$scalar; + my $arrayref = \@array; + my $hashref = \%hash; diff --git a/Task/Pointers-and-references/Perl/pointers-and-references-2.pl b/Task/Pointers-and-references/Perl/pointers-and-references-2.pl new file mode 100644 index 0000000000..36ab87ea77 --- /dev/null +++ b/Task/Pointers-and-references/Perl/pointers-and-references-2.pl @@ -0,0 +1,9 @@ + # printing the value + print ${$scalar}; + print $arrayref->[1]; # this would print "array" + print $hashref->{'secondkey'}; # this would print "hash" + + # changing the value + ${$scalar} = 'a new string'; # would change $scalar as well + $arrayref->[0] = 'an altered'; # would change the first value of @array as well + $hashref->{'firstkey'} = 'a good'; # would change the value of the firstkey name value pair in %hash diff --git a/Task/Pointers-and-references/Perl/pointers-and-references-3.pl b/Task/Pointers-and-references/Perl/pointers-and-references-3.pl new file mode 100644 index 0000000000..5a7a15470f --- /dev/null +++ b/Task/Pointers-and-references/Perl/pointers-and-references-3.pl @@ -0,0 +1,3 @@ + my $scalarref = \'a scalar'; + my $arrayref = ['an', 'array']; + my $hashref = { firstkey => 'a', secondkey => 'hash' } diff --git a/Task/Pointers-and-references/PicoLisp/pointers-and-references.l b/Task/Pointers-and-references/PicoLisp/pointers-and-references.l new file mode 100644 index 0000000000..773fd58b48 --- /dev/null +++ b/Task/Pointers-and-references/PicoLisp/pointers-and-references.l @@ -0,0 +1,11 @@ +: (setq L (1 a 2 b 3 c)) # Create a list of 6 items in 'L' +-> (1 a 2 b 3 c) + +: (nth L 4) # Get a pointer to the 4th item +-> (b 3 c) + +: (set (nth L 4) "Hello") # Store "Hello" in that location +-> "Hello" + +: L # Look at the modified list in 'L' +-> (1 a 2 "Hello" 3 c) diff --git a/Task/Pointers-and-references/PureBasic/pointers-and-references-1.purebasic b/Task/Pointers-and-references/PureBasic/pointers-and-references-1.purebasic new file mode 100644 index 0000000000..8fe2d34a19 --- /dev/null +++ b/Task/Pointers-and-references/PureBasic/pointers-and-references-1.purebasic @@ -0,0 +1,4 @@ +Define varA.i = 5, varB.i = 0, *myInteger.Integer + +*myInteger = @varA ;set pointer to address of an integer variable +varB = *myInteger\i + 3 ;set variable to the 3 + value of dereferenced pointer, i.e varB = 8 diff --git a/Task/Pointers-and-references/PureBasic/pointers-and-references-2.purebasic b/Task/Pointers-and-references/PureBasic/pointers-and-references-2.purebasic new file mode 100644 index 0000000000..457351f950 --- /dev/null +++ b/Task/Pointers-and-references/PureBasic/pointers-and-references-2.purebasic @@ -0,0 +1,2 @@ +Define varC.i = 12 +*myInteger = @varC diff --git a/Task/Pointers-and-references/PureBasic/pointers-and-references-3.purebasic b/Task/Pointers-and-references/PureBasic/pointers-and-references-3.purebasic new file mode 100644 index 0000000000..95c0ce99ce --- /dev/null +++ b/Task/Pointers-and-references/PureBasic/pointers-and-references-3.purebasic @@ -0,0 +1 @@ +*myInteger = #Null ;or anything evaluating to zero diff --git a/Task/Pointers-and-references/PureBasic/pointers-and-references-4.purebasic b/Task/Pointers-and-references/PureBasic/pointers-and-references-4.purebasic new file mode 100644 index 0000000000..2b8ff07308 --- /dev/null +++ b/Task/Pointers-and-references/PureBasic/pointers-and-references-4.purebasic @@ -0,0 +1,6 @@ +Dim myArray(10) +*myInteger = myArray() +;Or alternatively: +*myInteger = @myArray(0) +;any specific element +*myInteger = @myArray(4) ;element 4 diff --git a/Task/Pointers-and-references/PureBasic/pointers-and-references-5.purebasic b/Task/Pointers-and-references/PureBasic/pointers-and-references-5.purebasic new file mode 100644 index 0000000000..284bbddb39 --- /dev/null +++ b/Task/Pointers-and-references/PureBasic/pointers-and-references-5.purebasic @@ -0,0 +1,2 @@ +*myInteger + 3 * SizeOf(Integer) ;pointer now points to myArray(3) +*myInteger - 2 * SizeOf(Integer) ;pointer now points to myArray(1) diff --git a/Task/Pointers-and-references/PureBasic/pointers-and-references-6.purebasic b/Task/Pointers-and-references/PureBasic/pointers-and-references-6.purebasic new file mode 100644 index 0000000000..64bd397a16 --- /dev/null +++ b/Task/Pointers-and-references/PureBasic/pointers-and-references-6.purebasic @@ -0,0 +1,10 @@ +Structure employee + id.i + name.s + jobs.s[20] ;array of job descriptions +EndStructure + +Dim employees.employee(10) ;an array of employee's + +;set a string pointer to the 6th job of the 4th employee +*myString.String = @employees(3) + OffsetOf(employee\jobs) + 5 * SizeOf(String) diff --git a/Task/Pointers-and-references/PureBasic/pointers-and-references-7.purebasic b/Task/Pointers-and-references/PureBasic/pointers-and-references-7.purebasic new file mode 100644 index 0000000000..3e64f673da --- /dev/null +++ b/Task/Pointers-and-references/PureBasic/pointers-and-references-7.purebasic @@ -0,0 +1,2 @@ +*pointer = @varA +*pointer = @myFunction() diff --git a/Task/Pointers-and-references/PureBasic/pointers-and-references-8.purebasic b/Task/Pointers-and-references/PureBasic/pointers-and-references-8.purebasic new file mode 100644 index 0000000000..8290d8c003 --- /dev/null +++ b/Task/Pointers-and-references/PureBasic/pointers-and-references-8.purebasic @@ -0,0 +1,20 @@ +; Getting the address of a lable in the code +text$="'Lab' is at address "+Str(?lab) +MessageRequester("Info",text$) + +; Using lables to calculate size +text$="Size of the datasetion is "+Str(?lab2-?lab)+" bytes." +MessageRequester("Info",text$) + +; Using above to copy specific datas +Define individes=(?lab2-?lab1)/SizeOf(Integer) +Dim Stuff(individes-1) ; As PureBasic uses 0-based arrays +CopyMemory(?lab1,@Stuff(),?lab2-?lab1) + +DataSection + lab: + Data.s "Foo", "Fuu" + lab1: + Data.i 3,1,4,5,9,2,1,6 + lab2: +EndDataSection diff --git a/Task/Pointers-and-references/Python/pointers-and-references.py b/Task/Pointers-and-references/Python/pointers-and-references.py new file mode 100644 index 0000000000..68d0149f03 --- /dev/null +++ b/Task/Pointers-and-references/Python/pointers-and-references.py @@ -0,0 +1,32 @@ + # Bind a literal string object to a name: + a = "foo" + # Bind an empty list to another name: + b = [] + # Classes are "factories" for creating new objects: invoke class name as a function: + class Foo(object): + pass + c = Foo() + # Again, but with optional initialization: + class Bar(object): + def __init__(self, initializer = None) + # "initializer is an arbitrary identifier, and "None" is an arbitrary default value + if initializer is not None: + self.value = initializer + d = Bar(10) + print d.value + # Test if two names are references to the same object: + if a is b: pass + # Alternatively: + if id(a) == id(b): pass + # Re-bind a previous used name to a function: + def a(fmt, *args): + if fmt is None: + fmt = "%s" + print fmt % (args) + # Append reference to a list: + b.append(a) + # Unbind a reference: + del(a) + # Call (anymous function object) from inside a list + b[0]("foo") # Note that the function object we original bound to the name "a" continues to exist + # even if its name is unbound or rebound to some other object. diff --git a/Task/Pointers-and-references/SAS/pointers-and-references.sas b/Task/Pointers-and-references/SAS/pointers-and-references.sas new file mode 100644 index 0000000000..f812cb6e17 --- /dev/null +++ b/Task/Pointers-and-references/SAS/pointers-and-references.sas @@ -0,0 +1,13 @@ +/* Using ADDR to get memory address, and PEEKC / POKE. There is also PEEK for numeric values. */ +data _null_; +length a b c $4; +adr_a=addr(a); +adr_b=addr(b); +adr_c=addr(c); +a="ABCD"; +b="EFGH"; +c="IJKL"; +b=peekc(adr_a,1); +call poke(b,adr_c,1); +put a b c; +run; diff --git a/Task/Pointers-and-references/Standard-ML/pointers-and-references.ml b/Task/Pointers-and-references/Standard-ML/pointers-and-references.ml new file mode 100644 index 0000000000..c186592b9b --- /dev/null +++ b/Task/Pointers-and-references/Standard-ML/pointers-and-references.ml @@ -0,0 +1,3 @@ +val p = ref 1; (* create a new "reference" data structure with initial value 1 *) +val k = !p; (* "dereference" the reference, returning the value inside *) +p := k + 1; (* set the value inside to a new value *) diff --git a/Task/Pointers-and-references/Tcl/pointers-and-references-1.tcl b/Task/Pointers-and-references/Tcl/pointers-and-references-1.tcl new file mode 100644 index 0000000000..a4bf358ba8 --- /dev/null +++ b/Task/Pointers-and-references/Tcl/pointers-and-references-1.tcl @@ -0,0 +1,5 @@ +set var 3 +set pointer var; # assign name "var" not value 3 +set pointer; # returns "var" +set $pointer; # returns 3 +set $pointer 42; # variable var now has value 42 diff --git a/Task/Pointers-and-references/Tcl/pointers-and-references-2.tcl b/Task/Pointers-and-references/Tcl/pointers-and-references-2.tcl new file mode 100644 index 0000000000..9902a626e9 --- /dev/null +++ b/Task/Pointers-and-references/Tcl/pointers-and-references-2.tcl @@ -0,0 +1,9 @@ +set arr(var) 3 +set pointer var +set arr($pointer); # returns 3 +set arr($pointer) 42; # arr(var) now has value 42 + +set var 3 +set pointer var +upvar 0 $pointer varAlias; # varAlias is now the same variable as var +set varAlias 42; # var now has value 42 diff --git a/Task/Pointers-and-references/XPL0/pointers-and-references.xpl0 b/Task/Pointers-and-references/XPL0/pointers-and-references.xpl0 new file mode 100644 index 0000000000..5940881a2d --- /dev/null +++ b/Task/Pointers-and-references/XPL0/pointers-and-references.xpl0 @@ -0,0 +1,32 @@ +\Paraphrasing the C example: +\This creates a pointer to an integer variable: +int Var, Ptr, V; +Ptr:= @Var; + +\Access the integer variable through the pointer: +Var:= 3; +V:= Ptr(0); \set V to the value of Var, i.e. 3 +Ptr(0):= 42; \set Var to 42 + +\Change the pointer to refer to another integer variable: +int OtherVar; +Ptr:= @OtherVar; + +\Change the pointer to not point to anything: +Ptr:= 0; \or any integer expression that evaluates to 0 + +\Set the pointer to the first item of an array: +int Array(10); +Ptr:= Array; +\Or alternatively: +Ptr:= @Array(0); + +\Move the pointer to another item in the array: +def IntSize = 4; \number of bytes in an integer +Ptr:= Ptr + 3*IntSize; \pointer now points to Array(3) +Ptr:= Ptr - 2*IntSize; \pointer now points to Array(1) + +\Access an item in the array using the pointer: +V:= Ptr(3); \get third item after Array(1), i.e. Array(4) +V:= Ptr(-1); \get item immediately preceding Array(1), i.e. Array(0) +] diff --git a/Task/Polymorphic-copy/0DESCRIPTION b/Task/Polymorphic-copy/0DESCRIPTION new file mode 100644 index 0000000000..b97ab4f7b4 --- /dev/null +++ b/Task/Polymorphic-copy/0DESCRIPTION @@ -0,0 +1,8 @@ +An object is [[polymorphism|polymorphic]] when its specific type may vary. The types a specific value may take, is called ''class''. + +It is trivial to copy an object if its type is known: +int x; +int y = x; +Here x is not polymorphic, so y is declared of same type (''int'') as x. But if the specific type of x were unknown, then y could not be declared of any specific type. + +The task: let a polymorphic object contain an instance of some specific type S derived from a type T. The type T is known. The type S is possibly unknown until [[run time]]. The objective is to create an exact copy of such polymorphic object (not to create a [[reference]], nor a pointer to). Let further the type T have a method overridden by S. This method is to be called on the copy to demonstrate that the specific type of the copy is indeed S. diff --git a/Task/Polymorphic-copy/1META.yaml b/Task/Polymorphic-copy/1META.yaml new file mode 100644 index 0000000000..43afe9a8b6 --- /dev/null +++ b/Task/Polymorphic-copy/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Object oriented diff --git a/Task/Polymorphic-copy/Ada/polymorphic-copy.ada b/Task/Polymorphic-copy/Ada/polymorphic-copy.ada new file mode 100644 index 0000000000..3ff1d6ae7f --- /dev/null +++ b/Task/Polymorphic-copy/Ada/polymorphic-copy.ada @@ -0,0 +1,42 @@ +with Ada.Text_IO; use Ada.Text_IO; + +procedure Test_Polymorphic_Copy is + package Base is + type T is tagged null record; + function Name (X : T) return String; + end Base; + use Base; + + package body Base is + function Name (X : T) return String is + begin + return "T"; + end Name; + end Base; + + -- The procedure knows nothing about S + procedure Copier (X : T'Class) is + Duplicate : T'Class := X; -- A copy of X + begin + Put_Line ("Copied " & Duplicate.Name); -- Check the copy + end Copier; + + package Derived is + type S is new T with null record; + overriding function Name (X : S) return String; + end Derived; + use Derived; + + package body Derived is + function Name (X : S) return String is + begin + return "S"; + end Name; + end Derived; + + Object_1 : T; + Object_2 : S; +begin + Copier (Object_1); + Copier (Object_2); +end Test_Polymorphic_Copy; diff --git a/Task/Polymorphic-copy/Aikido/polymorphic-copy.aikido b/Task/Polymorphic-copy/Aikido/polymorphic-copy.aikido new file mode 100644 index 0000000000..c3ecb1cc2c --- /dev/null +++ b/Task/Polymorphic-copy/Aikido/polymorphic-copy.aikido @@ -0,0 +1,23 @@ +class T { + public function print { + println ("class T") + } +} + +class S extends T { + public function print { + println ("class S") + } +} + +var t = new T() +var s = new S() +println ("before copy") +t.print() +s.print() + +var tcopy = clone (t, false) +var scopy = clone (s, false) +println ("after copy") +tcopy.print() +scopy.print() diff --git a/Task/Polymorphic-copy/BBC-BASIC/polymorphic-copy.bbc b/Task/Polymorphic-copy/BBC-BASIC/polymorphic-copy.bbc new file mode 100644 index 0000000000..3ca47ae179 --- /dev/null +++ b/Task/Polymorphic-copy/BBC-BASIC/polymorphic-copy.bbc @@ -0,0 +1,28 @@ + INSTALL @lib$ + "CLASSLIB" + + REM Create parent class T: + DIM classT{array#(0), setval, retval} + DEF classT.setval (n%,v) classT.array#(n%) = v : ENDPROC + DEF classT.retval (n%) = classT.array#(n%) + PROC_class(classT{}) + + REM Create class S derived from T, known only at run-time: + RunTimeSize% = RND(100) + DIM classS{array#(RunTimeSize%)} + PROC_inherit(classS{}, classT{}) + DEF classS.retval (n%) = classS.array#(n%) ^ 2 : REM Overridden method + PROC_class(classS{}) + + REM Create an instance of class S: + PROC_new(myobject{}, classS{}) + + REM Now make a copy of the instance: + DIM mycopy{} = myobject{} + mycopy{} = myobject{} + PROC_discard(myobject{}) + + REM Test the copy (should print 123^2): + PROC(mycopy.setval)(RunTimeSize%, 123) + result% = FN(mycopy.retval)(RunTimeSize%) + PRINT result% + END diff --git a/Task/Polymorphic-copy/C++/polymorphic-copy.cpp b/Task/Polymorphic-copy/C++/polymorphic-copy.cpp new file mode 100644 index 0000000000..ef6db141d0 --- /dev/null +++ b/Task/Polymorphic-copy/C++/polymorphic-copy.cpp @@ -0,0 +1,50 @@ +#include + +class T +{ +public: + virtual void identify() { std::cout << "I am a genuine T" << std::endl; } + virtual T* clone() { return new T(*this); } + virtual ~T() {} +}; + +class S: public T +{ +public: + virtual void identify() { std::cout << "I am an S" << std::endl; } + virtual S* clone() { return new S(*this); } +}; + +class X // the class of the object which contains a T or S +{ +public: + // by getting the object through a pointer to T, X cannot know if it's an S or a T + X(T* t): member(t) {} + + // copy constructor + X(X const& other): member(other.member->clone()) {} + + // copy assignment operator + X& operator=(X const& other) + { + T* new_member = other.member->clone(); + delete member; + member = new_member; + } + + // destructor + ~X() { delete member; } + + // check what sort of object it contains + void identify_member() { member->identify(); } + +private: + T* member; +}; + +int main() +{ + X original(new S); // construct an X and give it an S, + X copy = original; // copy it, + copy.identify_member(); // and check what type of member it contains +} diff --git a/Task/Polymorphic-copy/C/polymorphic-copy.c b/Task/Polymorphic-copy/C/polymorphic-copy.c new file mode 100644 index 0000000000..2067ca89ad --- /dev/null +++ b/Task/Polymorphic-copy/C/polymorphic-copy.c @@ -0,0 +1,202 @@ +#include +#include +#include + +typedef struct object *BaseObj; +typedef struct sclass *Class; +typedef void (*CloneFctn)(BaseObj s, BaseObj clo); +typedef const char * (*SpeakFctn)(BaseObj s); +typedef void (*DestroyFctn)(BaseObj s); + +typedef struct sclass { + size_t csize; /* size of the class instance */ + const char *cname; /* name of the class */ + Class parent; /* parent class */ + + CloneFctn clone; /* clone function */ + SpeakFctn speak; /* speak function */ + DestroyFctn del; /* delete the object */ +} sClass; + +typedef struct object { + Class class; +} SObject; + +static +BaseObj obj_copy( BaseObj s, Class c ) +{ + BaseObj clo; + if (c->parent) + clo = obj_copy( s, c->parent); + else + clo = malloc( s->class->csize ); + + if (clo) + c->clone( s, clo ); + return clo; +} + +static +void obj_del( BaseObj s, Class c ) +{ + if (c->del) + c->del(s); + if (c->parent) + obj_del( s, c->parent); + else + free(s); +} + +BaseObj ObjClone( BaseObj s ) +{ return obj_copy( s, s->class ); } + +const char * ObjSpeak( BaseObj s ) +{ + return s->class->speak(s); +} + +void ObjDestroy( BaseObj s ) +{ if (s) obj_del( s, s->class ); } + +/* * * * * * */ +static +void baseClone( BaseObj s, BaseObj clone) +{ + clone->class = s->class; +} + +static +const char *baseSpeak(BaseObj s) +{ + return "Hello, I'm base object"; +} + +sClass boc = { sizeof(SObject), "BaseObj", NULL, + &baseClone, &baseSpeak, NULL }; +Class BaseObjClass = &boc; + +/* * * * * * */ +/* Dog - a derived class */ + +typedef struct sDogPart { + double weight; + char color[32]; + char name[24]; +} DogPart; + +typedef struct sDog *Dog; + +struct sDog { + Class class; // parent structure + DogPart dog; +}; + +static +void dogClone( BaseObj s, BaseObj c) +{ + Dog src = (Dog)s; + Dog clone = (Dog)c; + clone->dog = src->dog; /* no pointers so strncpys not needed */ +} + +static +const char *dogSpeak( BaseObj s) +{ + Dog d = (Dog)s; + static char response[90]; + sprintf(response, "woof! woof! My name is %s. I'm a %s %s", + d->dog.name, d->dog.color, d->class->cname); + return response; +} + + +sClass dogc = { sizeof(struct sDog), "Dog", &boc, + &dogClone, &dogSpeak, NULL }; +Class DogClass = &dogc; + +BaseObj NewDog( const char *name, const char *color, double weight ) +{ + Dog dog = malloc(DogClass->csize); + if (dog) { + DogPart *dogp = &dog->dog; + dog->class = DogClass; + dogp->weight = weight; + strncpy(dogp->name, name, 23); + strncpy(dogp->color, color, 31); + } + return (BaseObj)dog; +} + +/* * * * * * * * * */ +/* Ferret - a derived class */ + +typedef struct sFerretPart { + char color[32]; + char name[24]; + int age; +} FerretPart; + +typedef struct sFerret *Ferret; + +struct sFerret { + Class class; // parent structure + FerretPart ferret; +}; + +static +void ferretClone( BaseObj s, BaseObj c) +{ + Ferret src = (Ferret)s; + Ferret clone = (Ferret)c; + clone->ferret = src->ferret; /* no pointers so strncpys not needed */ +} + +static +const char *ferretSpeak(BaseObj s) +{ + Ferret f = (Ferret)s; + static char response[90]; + sprintf(response, "My name is %s. I'm a %d mo. old %s wiley %s", + f->ferret.name, f->ferret.age, f->ferret.color, + f->class->cname); + return response; +} + +sClass ferretc = { sizeof(struct sFerret), "Ferret", &boc, + &ferretClone, &ferretSpeak, NULL }; +Class FerretClass = &ferretc; + +BaseObj NewFerret( const char *name, const char *color, int age ) +{ + Ferret ferret = malloc(FerretClass->csize); + if (ferret) { + FerretPart *ferretp = &(ferret->ferret); + ferret->class = FerretClass; + strncpy(ferretp->name, name, 23); + strncpy(ferretp->color, color, 31); + ferretp->age = age; + } + return (BaseObj)ferret; +} + +/* * Now you really understand why Bjarne created C++ * */ + +int main() +{ + BaseObj o1; + BaseObj kara = NewFerret( "Kara", "grey", 15 ); + BaseObj bruce = NewDog("Bruce", "yellow", 85.0 ); + printf("Ok created things\n"); + + o1 = ObjClone(kara ); + printf("Karol says %s\n", ObjSpeak(o1)); + printf("Kara says %s\n", ObjSpeak(kara)); + ObjDestroy(o1); + + o1 = ObjClone(bruce ); + strncpy(((Dog)o1)->dog.name, "Donald", 23); + printf("Don says %s\n", ObjSpeak(o1)); + printf("Bruce says %s\n", ObjSpeak(bruce)); + ObjDestroy(o1); + return 0; +} diff --git a/Task/Polymorphic-copy/Common-Lisp/polymorphic-copy-1.lisp b/Task/Polymorphic-copy/Common-Lisp/polymorphic-copy-1.lisp new file mode 100644 index 0000000000..b370dcfcdb --- /dev/null +++ b/Task/Polymorphic-copy/Common-Lisp/polymorphic-copy-1.lisp @@ -0,0 +1,12 @@ +(defstruct super foo) + +(defstruct (sub (:include super)) bar) + +(defgeneric frob (thing)) + +(defmethod frob ((super super)) + (format t "~&Super has foo = ~w." (super-foo super))) + +(defmethod frob ((sub sub)) + (format t "~&Sub has foo = ~w, bar = ~w." + (sub-foo sub) (sub-bar sub))) diff --git a/Task/Polymorphic-copy/Common-Lisp/polymorphic-copy-2.lisp b/Task/Polymorphic-copy/Common-Lisp/polymorphic-copy-2.lisp new file mode 100644 index 0000000000..4242eadb23 --- /dev/null +++ b/Task/Polymorphic-copy/Common-Lisp/polymorphic-copy-2.lisp @@ -0,0 +1,5 @@ +(defmethod frob ((sequence sequence)) + (format t "~&sequence has ~w elements" (length sequence))) + +(defmethod frob ((string string)) + (format t "~&the string has ~w elements" (length string))) diff --git a/Task/Polymorphic-copy/D/polymorphic-copy-1.d b/Task/Polymorphic-copy/D/polymorphic-copy-1.d new file mode 100644 index 0000000000..da21391758 --- /dev/null +++ b/Task/Polymorphic-copy/D/polymorphic-copy-1.d @@ -0,0 +1,19 @@ +class T { + override string toString() { return "I'm the instance of T"; } + T duplicate() { return new T; } +} + +class S : T { + override string toString() { return "I'm the instance of S"; } + + override T duplicate() { return new S; } +} + +void main () { + import std.stdio; + T orig = new S; + T copy = orig.duplicate(); + + writeln(orig); + writeln(copy); +} diff --git a/Task/Polymorphic-copy/D/polymorphic-copy-2.d b/Task/Polymorphic-copy/D/polymorphic-copy-2.d new file mode 100644 index 0000000000..ec6cfb1d9d --- /dev/null +++ b/Task/Polymorphic-copy/D/polymorphic-copy-2.d @@ -0,0 +1,46 @@ +class T { + this(T t = null) {} // Constructor that will be used for copying. + + override string toString() { return "I'm the instance of T"; } + + T duplicate() { return new T(this); } + + bool custom(char c) { return false; } +} + +class S : T { + char[] str; + + this(S s = null) { + super(s); + if (s is null) + str = ['1', '2', '3']; // All newly created will get that. + else + str = s.str.dup; // Do the deep-copy. + } + + override string toString() { + return "I'm the instance of S p: " ~ cast(string)str; + } + + override T duplicate() { return new S(this); } + + // Additional procedure, just to test deep-copy. + override bool custom(char c) { + if (str !is null) + str[0] = c; + return str is null; + } +} + +void main () { + import std.stdio; + T orig = new S; + orig.custom('X'); + + T copy = orig.duplicate(); + orig.custom('Y'); + + writeln(orig); + writeln(copy); // Should have 'X' at the beginning. +} diff --git a/Task/Polymorphic-copy/E/polymorphic-copy-1.e b/Task/Polymorphic-copy/E/polymorphic-copy-1.e new file mode 100644 index 0000000000..a066fe43d2 --- /dev/null +++ b/Task/Polymorphic-copy/E/polymorphic-copy-1.e @@ -0,0 +1,5 @@ +def deSubgraphKit := + +def copy(object) { + return deSubgraphKit.recognize(object, deSubgraphKit.makeBuilder()) +} diff --git a/Task/Polymorphic-copy/E/polymorphic-copy-2.e b/Task/Polymorphic-copy/E/polymorphic-copy-2.e new file mode 100644 index 0000000000..0f32778836 --- /dev/null +++ b/Task/Polymorphic-copy/E/polymorphic-copy-2.e @@ -0,0 +1,12 @@ +? def a := [1].diverge() +# value: [1].diverge() + +? def b := copy(a) +# value: [1].diverge() + +? b.push(2) +? a +# value: [1].diverge() + +? b +# value: [1, 2].diverge() diff --git a/Task/Polymorphic-copy/Factor/polymorphic-copy.factor b/Task/Polymorphic-copy/Factor/polymorphic-copy.factor new file mode 100644 index 0000000000..b23834f726 --- /dev/null +++ b/Task/Polymorphic-copy/Factor/polymorphic-copy.factor @@ -0,0 +1,8 @@ +USING: classes kernel prettyprint serialize ; +TUPLE: A ; +TUPLE: C < A ; +: serial-clone ( obj -- obj' ) object>bytes bytes>object ; + +C new +[ clone ] +[ serial-clone ] bi [ class . ] bi@ diff --git a/Task/Polymorphic-copy/Forth/polymorphic-copy.fth b/Task/Polymorphic-copy/Forth/polymorphic-copy.fth new file mode 100644 index 0000000000..c4f396eb6b --- /dev/null +++ b/Task/Polymorphic-copy/Forth/polymorphic-copy.fth @@ -0,0 +1,36 @@ +include lib/memcell.4th +include 4pp/lib/foos.4pp + ( a1 -- a2) +:token fork dup allocated dup (~~alloc) swap >r swap over r> smove ; + \ allocate an empty object +:: T() \ super class T + class + method: print \ print message + method: clone \ clone yourself + end-class { + \ implementing methods + :method { ." class T" cr } ; defines print + fork defines clone ( -- addr) + } +; + +:: S() \ class S + extends T() \ derived from T + end-extends { \ print message + :method { ." class S" cr } ; defines print + } \ clone yourself +; + +new T() t \ create a new object t +new S() s \ create a new object s + +." before copy" cr +t => print \ use "print" methods +s => print + +t => clone to tcopy \ cloning t, spawning tcopy +s => clone to scopy \ cloning s, spawning scopy + +." after copy" cr +tcopy => print \ use "print" methods +scopy => print diff --git a/Task/Polymorphic-copy/Go/polymorphic-copy.go b/Task/Polymorphic-copy/Go/polymorphic-copy.go new file mode 100644 index 0000000000..d8529afbb4 --- /dev/null +++ b/Task/Polymorphic-copy/Go/polymorphic-copy.go @@ -0,0 +1,84 @@ +package main + +import ( + "fmt" + "reflect" +) + +// interface types provide polymorphism, but not inheritance. +type i interface { + identify() string +} + +// "base" type +type t float64 + +// "derived" type. in Go terminology, it is simply a struct with an +// anonymous field. fields and methods of anonymous fields however, +// can be accessed without additional qualification and so are +// "inherited" in a sense. +type s struct { + t + kōan string +} + +// another type with an "embedded" t field. (t is the *type*, this field +// has no *name*.) +type r struct { + t + ch chan int +} + +// a method on t. this method makes t satisfy interface i. +// since a t is embedded in types s and r, they automatically "inherit" +// the method. +func (x t) identify() string { + return "I'm a t!" +} + +// the same method on s. although s already satisfied i, calls to identify +// will now find this method rather than the one defined on t. in a sense +// it "overrides" the method of the "base class." +func (x s) identify() string { + return "I'm an s!" +} + +func main() { + // three variables with different types, initialized from literals. + var t1 t = 5 + var s1 s = s{6, "one"} + var r1 r = r{t: 7} + + // variables declared with the same type. initial value is nil. + var i1, i2, i3 i + fmt.Println("Initial (zero) values of interface variables:") + fmt.Println("i1:", i1) + fmt.Println("i2:", i2) + fmt.Println("i3:", i3) + + // in the terminology of the Go language reference, i1, i2, and i3 + // still have static type i, but now have different dynamic types. + i1, i2, i3 = t1, s1, r1 + fmt.Println("\nPolymorphic:") + fmt.Println("i1:", i1, "/", i1.identify(), "/", reflect.TypeOf(i1)) + fmt.Println("i2:", i2, "/", i2.identify(), "/", reflect.TypeOf(i2)) + fmt.Println("i3:", i3, "/", i3.identify(), "/", reflect.TypeOf(i3)) + + // copy: declare and assign in one step using "short declaration." + i1c, i2c, i3c := i1, i2, i3 + + // modify first set of polymorphic variables. + i1, i2, i3 = s{3, "dog"}, r{t: 1}, t(2) + + // demonstrate that copies are distinct from first set + // and that types are preserved. + fmt.Println("\nFirst set now modified:") + fmt.Println("i1:", i1, "/", i1.identify(), "/", reflect.TypeOf(i1)) + fmt.Println("i2:", i2, "/", i2.identify(), "/", reflect.TypeOf(i2)) + fmt.Println("i3:", i3, "/", i3.identify(), "/", reflect.TypeOf(i3)) + + fmt.Println("\nCopies made before modifications:") + fmt.Println("i1c:", i1c, "/", i1c.identify(), "/", reflect.TypeOf(i1c)) + fmt.Println("i2c:", i2c, "/", i2c.identify(), "/", reflect.TypeOf(i2c)) + fmt.Println("i3c:", i3c, "/", i3c.identify(), "/", reflect.TypeOf(i3c)) +} diff --git a/Task/Polymorphic-copy/Java/polymorphic-copy.java b/Task/Polymorphic-copy/Java/polymorphic-copy.java new file mode 100644 index 0000000000..38e42d924a --- /dev/null +++ b/Task/Polymorphic-copy/Java/polymorphic-copy.java @@ -0,0 +1,24 @@ +class T implements Cloneable { + public String name() { return "T"; } + public T copy() { + try { + return (T)super.clone(); + } catch (CloneNotSupportedException e) { + return null; + } + } +} + +class S extends T { + public String name() { return "S"; } +} + +public class PolymorphicCopy { + public static T copier(T x) { return x.copy(); } + public static void main(String[] args) { + T obj1 = new T(); + S obj2 = new S(); + System.out.println(copier(obj1).name()); // prints "T" + System.out.println(copier(obj2).name()); // prints "S" + } +} diff --git a/Task/Polymorphic-copy/JavaScript/polymorphic-copy.js b/Task/Polymorphic-copy/JavaScript/polymorphic-copy.js new file mode 100644 index 0000000000..191c54a308 --- /dev/null +++ b/Task/Polymorphic-copy/JavaScript/polymorphic-copy.js @@ -0,0 +1,9 @@ +function clone(obj){ + if (obj == null || typeof(obj) != 'object') + return obj; + + var temp = {}; + for (var key in obj) + temp[key] = clone(obj[key]); + return temp; +} diff --git a/Task/Polymorphic-copy/NetRexx/polymorphic-copy.netrexx b/Task/Polymorphic-copy/NetRexx/polymorphic-copy.netrexx new file mode 100644 index 0000000000..995037ce9f --- /dev/null +++ b/Task/Polymorphic-copy/NetRexx/polymorphic-copy.netrexx @@ -0,0 +1,38 @@ +/* NetRexx */ +options replace format comments java crossref savelog symbols binary + +-- ----------------------------------------------------------------------------- +class RCPolymorphicCopy public + +method copier(x = T) public static returns T + return x.copy + +method main(args = String[]) public constant + obj1 = T() + obj2 = S() + System.out.println(copier(obj1).name) -- prints "T" + System.out.println(copier(obj2).name) -- prints "S" + return + +-- ----------------------------------------------------------------------------- +class RCPolymorphicCopy.T public implements Cloneable + +method name returns String + return T.class.getSimpleName + +method copy public returns T + dup = T + + do + dup = T super.clone + catch ex = CloneNotSupportedException + ex.printStackTrace + end + + return dup + +-- ----------------------------------------------------------------------------- +class RCPolymorphicCopy.S public extends RCPolymorphicCopy.T + +method name returns String + return S.class.getSimpleName diff --git a/Task/Polymorphic-copy/OCaml/polymorphic-copy.ocaml b/Task/Polymorphic-copy/OCaml/polymorphic-copy.ocaml new file mode 100644 index 0000000000..2b4c75b65d --- /dev/null +++ b/Task/Polymorphic-copy/OCaml/polymorphic-copy.ocaml @@ -0,0 +1,13 @@ +let obj1 = + object + method name = "T" + end + +let obj2 = + object + method name = "S" + end + +let () = + print_endline (Oo.copy obj1)#name; (* prints "T" *) + print_endline (Oo.copy obj2)#name; (* prints "S" *) diff --git a/Task/Polymorphic-copy/Objective-C/polymorphic-copy.m b/Task/Polymorphic-copy/Objective-C/polymorphic-copy.m new file mode 100644 index 0000000000..ff31acdb69 --- /dev/null +++ b/Task/Polymorphic-copy/Objective-C/polymorphic-copy.m @@ -0,0 +1,39 @@ +@interface T : NSObject +{ } +- (void)identify; +@end + +@implementation T +- (void)identify { + NSLog(@"I am a genuine T"); +} +- (id)copyWithZone:(NSZone *)zone { + T *copy = [[[self class] allocWithZone:zone] init]; // call an appropriate constructor here + // then copy data into it as appropriate here + // make sure to use "[[self class] alloc..." and + // not "[T alloc..." to make it polymorphic + return copy; +} +@end + +@interface S : T +{ } +@end + +@implementation S +- (void)identify +{ + NSLog(@"I am an S"); +} +@end + +int main() +{ + T *original = [[S alloc] init]; + T *another = [original copy]; + [another identify]; // logs "I am an S" + + [another release]; // like "alloc", the object returned by "copy" is "owned" by the caller, so we are responsible for releasing it + [original release]; + return 0; +} diff --git a/Task/Polymorphic-copy/OxygenBasic/polymorphic-copy.oxy b/Task/Polymorphic-copy/OxygenBasic/polymorphic-copy.oxy new file mode 100644 index 0000000000..5b99faa40f --- /dev/null +++ b/Task/Polymorphic-copy/OxygenBasic/polymorphic-copy.oxy @@ -0,0 +1,37 @@ +'====== +class T +'====== + +float vv + +method constructor(float a=0) {vv=a} +method destructor {} +method copy as T {new T ob : ob<=vv : return ob} +method mA() as float {return vv*2} +method mB() as float {return vv*3} + +end class + + +'====== +class S +'====== + +has T + +method mB() as float {return vv*4} 'ovveride + +end class + +'==== +'TEST +'==== + +new T objA(10.5) + +let objB = cast S objA.copy + +print objA.mb 'result 31.5 +print objB.mb 'result 42 + +del objA : del objB diff --git a/Task/Polymorphic-copy/Oz/polymorphic-copy.oz b/Task/Polymorphic-copy/Oz/polymorphic-copy.oz new file mode 100644 index 0000000000..c6e35e6596 --- /dev/null +++ b/Task/Polymorphic-copy/Oz/polymorphic-copy.oz @@ -0,0 +1,41 @@ +declare + class T from ObjectSupport.reflect + meth init + skip + end + + meth name($) + 'T' + end + end + + class S from T + attr a + feat f + + meth name($) + 'S' + end + + meth getA($) @a end + meth setA(V) a := V end + end + + Obj = {New S init} + Copy = {Obj clone($)} +in + %% Some assertions: + + %% Copy is really an S: + {Copy name($)} = 'S' + + %% Copy is not just a reference to the same object: + {System.eq Obj Copy} = false + + %% Not a deep copy. Feature f has the same identity for both objects: + {System.eq Obj.f Copy.f} = true + + %% However, both have their own distinct attributes: + {Obj setA(13)} + {Copy setA(14)} + {Obj getA($)} \= {Copy getA($)} = true diff --git a/Task/Polymorphic-copy/PHP/polymorphic-copy.php b/Task/Polymorphic-copy/PHP/polymorphic-copy.php new file mode 100644 index 0000000000..0140ef3e82 --- /dev/null +++ b/Task/Polymorphic-copy/PHP/polymorphic-copy.php @@ -0,0 +1,16 @@ +name(), "\n"; // prints "T" +echo $obj4->name(), "\n"; // prints "S" +?> diff --git a/Task/Polymorphic-copy/Perl-6/polymorphic-copy.pl6 b/Task/Polymorphic-copy/Perl-6/polymorphic-copy.pl6 new file mode 100644 index 0000000000..4cec2f07d7 --- /dev/null +++ b/Task/Polymorphic-copy/Perl-6/polymorphic-copy.pl6 @@ -0,0 +1,3 @@ +my Cool $x = 22/7 but role Fink { method brag { say "I'm a cool {self.WHAT.perl}!" }} +my Cool $y = $x.clone; +$y.brag; diff --git a/Task/Polymorphic-copy/Perl/polymorphic-copy.pl b/Task/Polymorphic-copy/Perl/polymorphic-copy.pl new file mode 100644 index 0000000000..922deda8be --- /dev/null +++ b/Task/Polymorphic-copy/Perl/polymorphic-copy.pl @@ -0,0 +1,53 @@ +package T; +sub new { + my $cls = shift; + bless [ @_ ], $cls +} + +sub set_data { + my $self = shift; + @$self = @_; +} + +sub copy { + my $self = shift; + bless [ @$self ], ref $self; +} + +sub manifest { + my $self = shift; + print "type T, content: @$self\n\n"; +} + +package S; +our @ISA = 'T'; +# S is inheriting from T. +# 'manifest' method is overriden, while 'new', 'copy' and +# 'set_data' are all inherited. +sub manifest { + my $self = shift; + print "type S, content: @$self\n\n"; +} + +package main; + +print "# creating \$t as a T\n"; +my $t = T->new('abc'); +$t->manifest; + +print "# creating \$s as an S\n"; +my $s = S->new('SPQR'); +$s->manifest; + +print "# make var \$x as a copy of \$t\n"; +my $x = $t->copy; +$x->manifest; + +print "# now as a copy of \$s\n"; +$x = $s->copy; +$x->manifest; + +print "# show that this copy is indeed a separate entity\n"; +$x->set_data('totally different'); +print "\$x is: "; +$x->manifest; diff --git a/Task/Polymorphic-copy/PicoLisp/polymorphic-copy-1.l b/Task/Polymorphic-copy/PicoLisp/polymorphic-copy-1.l new file mode 100644 index 0000000000..9697d3acf9 --- /dev/null +++ b/Task/Polymorphic-copy/PicoLisp/polymorphic-copy-1.l @@ -0,0 +1,10 @@ +: (setq A (new '(+Cls1 +Cls2) 'attr1 123 'attr2 "def" 'attr3 (4 2 0) 'attr4 T)) +-> $385603635 + +: (show A) +$385603635 (+Cls1 +Cls2) + attr4 + attr3 (4 2 0) + attr2 "def" + attr1 123 +-> $385603635 diff --git a/Task/Polymorphic-copy/PicoLisp/polymorphic-copy-2.l b/Task/Polymorphic-copy/PicoLisp/polymorphic-copy-2.l new file mode 100644 index 0000000000..5a7c09441b --- /dev/null +++ b/Task/Polymorphic-copy/PicoLisp/polymorphic-copy-2.l @@ -0,0 +1 @@ +(putl (setq B (new (val A))) (getl A)) diff --git a/Task/Polymorphic-copy/PicoLisp/polymorphic-copy-3.l b/Task/Polymorphic-copy/PicoLisp/polymorphic-copy-3.l new file mode 100644 index 0000000000..10b9064817 --- /dev/null +++ b/Task/Polymorphic-copy/PicoLisp/polymorphic-copy-3.l @@ -0,0 +1,7 @@ +: (show B) +$385346595 (+Cls1 +Cls2) + attr1 123 + attr2 "def" + attr3 (4 2 0) + attr4 +-> $385346595 diff --git a/Task/Polymorphic-copy/Python/polymorphic-copy-1.py b/Task/Polymorphic-copy/Python/polymorphic-copy-1.py new file mode 100644 index 0000000000..95ae2f971b --- /dev/null +++ b/Task/Polymorphic-copy/Python/polymorphic-copy-1.py @@ -0,0 +1,54 @@ +import copy + +class T: + def classname(self): + return self.__class__.__name__ + + def __init__(self): + self.myValue = "I'm a T." + + def speak(self): + print self.classname(), 'Hello', self.myValue + + def clone(self): + return copy.copy(self) + +class S1(T): + def speak(self): + print self.classname(),"Meow", self.myValue + +class S2(T): + def speak(self): + print self.classname(),"Woof", self.myValue + + +print "creating initial objects of types S1, S2, and T" +a = S1() +a.myValue = 'Green' +a.speak() + +b = S2() +b.myValue = 'Blue' +b.speak() + +u = T() +u.myValue = 'Purple' +u.speak() + +print "Making copy of a as u, colors and types should match" +u = a.clone() +u.speak() +a.speak() +print "Assigning new color to u, A's color should be unchanged." +u.myValue = "Orange" +u.speak() +a.speak() + +print "Assigning u to reference same object as b, colors and types should match" +u = b +u.speak() +b.speak() +print "Assigning new color to u. Since u,b references same object b's color changes as well" +u.myValue = "Yellow" +u.speak() +b.speak() diff --git a/Task/Polymorphic-copy/Python/polymorphic-copy-2.py b/Task/Polymorphic-copy/Python/polymorphic-copy-2.py new file mode 100644 index 0000000000..8c35c94841 --- /dev/null +++ b/Task/Polymorphic-copy/Python/polymorphic-copy-2.py @@ -0,0 +1,7 @@ +import cPickle as pickle + +source = {'a': [1, 2.0, 3, 4+6j], + 'b': ('string', u'Unicode string'), + 'c': None} + +target = pickle.loads(pickle.dumps(source)) diff --git a/Task/Polymorphic-copy/Python/polymorphic-copy-3.py b/Task/Polymorphic-copy/Python/polymorphic-copy-3.py new file mode 100644 index 0000000000..0a138bbc3d --- /dev/null +++ b/Task/Polymorphic-copy/Python/polymorphic-copy-3.py @@ -0,0 +1,8 @@ +target = source.__class__() # Create an object of the same type +if hasattr(source, 'items') and callable(source.items): + for key,value in source.items: + target[key] = value +elif hasattr(source, '__len__'): + target = source[:] +else: # Following is not recommended. (see below). + target = source diff --git a/Task/Polymorphic-copy/Ruby/polymorphic-copy.rb b/Task/Polymorphic-copy/Ruby/polymorphic-copy.rb new file mode 100644 index 0000000000..b92dd50705 --- /dev/null +++ b/Task/Polymorphic-copy/Ruby/polymorphic-copy.rb @@ -0,0 +1,16 @@ +class T + def name + "T" + end +end + +class S + def name + "S" + end +end + +obj1 = T.new +obj2 = S.new +puts obj1.dup.name # prints "T" +puts obj2.dup.name # prints "S" diff --git a/Task/Polymorphic-copy/Slate/polymorphic-copy.slate b/Task/Polymorphic-copy/Slate/polymorphic-copy.slate new file mode 100644 index 0000000000..7c4f963e80 --- /dev/null +++ b/Task/Polymorphic-copy/Slate/polymorphic-copy.slate @@ -0,0 +1,9 @@ +define: #T &parents: {Cloneable}. + +define: #S &parents: {Cloneable}. + +define: #obj1 -> T clone. +define: #obj2 -> S clone. + +obj1 printName. +obj2 printName. diff --git a/Task/Polymorphic-copy/Tcl/polymorphic-copy-1.tcl b/Task/Polymorphic-copy/Tcl/polymorphic-copy-1.tcl new file mode 100644 index 0000000000..14cd95d779 --- /dev/null +++ b/Task/Polymorphic-copy/Tcl/polymorphic-copy-1.tcl @@ -0,0 +1 @@ +set varCopy $varOriginal diff --git a/Task/Polymorphic-copy/Tcl/polymorphic-copy-2.tcl b/Task/Polymorphic-copy/Tcl/polymorphic-copy-2.tcl new file mode 100644 index 0000000000..b05d4be7ce --- /dev/null +++ b/Task/Polymorphic-copy/Tcl/polymorphic-copy-2.tcl @@ -0,0 +1,42 @@ +oo::class create CanClone { + method clone {{name {}}} { + # Make a bare, optionally named, copy of the object + set new [oo::copy [self] {*}[expr {$name eq "" ? {} : [list $name]}]] + + # Reproduce the basic variable state of the object + set newns [info object namespace $new] + foreach v [info object vars [self]] { + namespace upvar [namespace current] $v v1 + namespace upvar $newns $v v2 + if {[array exists v1]} { + array set v2 [array get v1] + } else { + set v2 $v1 + } + } + # Other object state is possible like open file handles. Cloning that is + # properly left to subclasses, of course. + + return $new + } +} + +# Now a demonstration +oo::class create Example { + superclass CanClone + variable Count Name + constructor {name} {set Name $name;set Count 0} + method step {} {incr Count;return} + method print {} {puts "this is $Name in [self], stepped $Count times"} + method rename {newName} {set Name $newName} +} +set obj1 [Example new "Abracadabra"] +$obj1 step +$obj1 step +$obj1 print +set obj2 [$obj1 clone] +$obj2 step +$obj2 print +$obj2 rename "Hocus Pocus" +$obj2 print +$obj1 print diff --git a/Task/Polymorphism/0DESCRIPTION b/Task/Polymorphism/0DESCRIPTION new file mode 100644 index 0000000000..fdd5887cff --- /dev/null +++ b/Task/Polymorphism/0DESCRIPTION @@ -0,0 +1 @@ +Create two classes Point(x,y) and Circle(x,y,r) with a polymorphic function print, accessors for (x,y,r), copy constructor, assignment and destructor and every possible default constructors diff --git a/Task/Polymorphism/1META.yaml b/Task/Polymorphism/1META.yaml new file mode 100644 index 0000000000..5a45e65601 --- /dev/null +++ b/Task/Polymorphism/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Object oriented +note: Basic language learning diff --git a/Task/Polymorphism/ActionScript/polymorphism-1.as b/Task/Polymorphism/ActionScript/polymorphism-1.as new file mode 100644 index 0000000000..e6efc17326 --- /dev/null +++ b/Task/Polymorphism/ActionScript/polymorphism-1.as @@ -0,0 +1,39 @@ +package +{ + public class Point + { + protected var _x:Number; + protected var _y:Number; + + public function Point(x:Number = 0, y:Number = 0) + { + _x = x; + _y = y; + } + + public function getX():Number + { + return _x; + } + + public function setX(x:Number):void + { + _x = x; + } + + public function getY():Number + { + return _y; + } + + public function setY(y:Number):void + { + _x = y; + } + + public function print():void + { + trace("Point"); + } + } +} diff --git a/Task/Polymorphism/ActionScript/polymorphism-2.as b/Task/Polymorphism/ActionScript/polymorphism-2.as new file mode 100644 index 0000000000..b34c28ce65 --- /dev/null +++ b/Task/Polymorphism/ActionScript/polymorphism-2.as @@ -0,0 +1,27 @@ +package { + public class Circle extends Point + { + private var r:Number; + + public function Circle(x:Number=0, y:Number=0, r:Number=0) + { + super(x, y); + this.r = r; + } + + public function getR():Number + { + return r; + } + + public function setR(r:Number):void + { + this.r = r; + } + + public override function print():void + { + trace("Circle"); + } + } +} diff --git a/Task/Polymorphism/Ada/polymorphism-1.ada b/Task/Polymorphism/Ada/polymorphism-1.ada new file mode 100644 index 0000000000..726d54ea09 --- /dev/null +++ b/Task/Polymorphism/Ada/polymorphism-1.ada @@ -0,0 +1,17 @@ +package Shapes is + type Point is tagged private; + procedure Print(Item : in Point); + function Setx(Item : in Point; Val : Integer) return Point; + function Sety(Item : in Point; Val : Integer) return Point; + function Getx(Item : in Point) return Integer; + function Gety(Item : in Point) return Integer; + function Create return Point; + function Create(X : Integer) return Point; + function Create(X, Y : Integer) return Point; + +private + type Point is tagged record + X : Integer := 0; + Y : Integer := 0; + end record; +end Shapes; diff --git a/Task/Polymorphism/Ada/polymorphism-2.ada b/Task/Polymorphism/Ada/polymorphism-2.ada new file mode 100644 index 0000000000..a2f698bcf5 --- /dev/null +++ b/Task/Polymorphism/Ada/polymorphism-2.ada @@ -0,0 +1,77 @@ +with Ada.Text_Io; use Ada.Text_Io; + +package body Shapes is + + ----------- + -- Print -- + ----------- + + procedure Print (Item : in Point) is + begin + Put_line("Point"); + end Print; + + ---------- + -- Setx -- + ---------- + + function Setx (Item : in Point; Val : Integer) return Point is + begin + return (Val, Item.Y); + end Setx; + + ---------- + -- Sety -- + ---------- + + function Sety (Item : in Point; Val : Integer) return Point is + begin + return (Item.X, Val); + end Sety; + + ---------- + -- Getx -- + ---------- + + function Getx (Item : in Point) return Integer is + begin + return Item.X; + end Getx; + + ---------- + -- Gety -- + ---------- + + function Gety (Item : in Point) return Integer is + begin + return Item.Y; + end Gety; + + ------------ + -- Create -- + ------------ + + function Create return Point is + begin + return (0, 0); + end Create; + + ------------ + -- Create -- + ------------ + + function Create (X : Integer) return Point is + begin + return (X, 0); + end Create; + + ------------ + -- Create -- + ------------ + + function Create (X, Y : Integer) return Point is + begin + return (X, Y); + end Create; + +end Shapes; diff --git a/Task/Polymorphism/Ada/polymorphism-3.ada b/Task/Polymorphism/Ada/polymorphism-3.ada new file mode 100644 index 0000000000..a24aa89587 --- /dev/null +++ b/Task/Polymorphism/Ada/polymorphism-3.ada @@ -0,0 +1,18 @@ +package Shapes.Circles is + type Circle is new Point with private; + procedure Print(Item : Circle); + function Setx(Item : Circle; Val : Integer) return Circle; + function Sety(Item : Circle; Val : Integer) return Circle; + function Setr(Item : Circle; Val : Integer) return Circle; + function Getr(Item : Circle) return Integer; + function Create(P : Point) return Circle; + function Create(P : Point; R : Integer) return Circle; + function Create(X : Integer) return Circle; + function Create(X : Integer; Y : Integer) return Circle; + function Create(X : Integer; Y : Integer; R : Integer) return Circle; + function Create return Circle; +private + type Circle is new Point with record + R : Integer := 0; + end record; +end Shapes.Circles; diff --git a/Task/Polymorphism/Ada/polymorphism-4.ada b/Task/Polymorphism/Ada/polymorphism-4.ada new file mode 100644 index 0000000000..45abbbeb26 --- /dev/null +++ b/Task/Polymorphism/Ada/polymorphism-4.ada @@ -0,0 +1,106 @@ +with Ada.Text_Io; use Ada.Text_IO; + +package body Shapes.Circles is + + ----------- + -- Print -- + ----------- + + procedure Print (Item : Circle) is + begin + Put_line("Circle"); + end Print; + + ---------- + -- Setx -- + ---------- + + function Setx (Item : Circle; Val : Integer) return Circle is + begin + return (Val, Item.Y, Item.R); + end Setx; + + ---------- + -- Sety -- + ---------- + + function Sety (Item : Circle; Val : Integer) return Circle is + Temp : Circle := Item; + begin + Temp.Y := Val; + return Temp; + end Sety; + + ---------- + -- Setr -- + ---------- + + function Setr (Item : Circle; Val : Integer) return Circle is + begin + return (Item.X, Item.Y, Val); + end Setr; + + ---------- + -- Getr -- + ---------- + + function Getr (Item : Circle) return Integer is + begin + return Item.R; + end Getr; + + ------------ + -- Create -- + ------------ + + function Create (P : Point) return Circle is + begin + return (P.X, P.Y, 0); + end Create; + + ------------ + -- Create -- + ------------ + + function Create (P : Point; R : Integer) return Circle is + begin + return (P.X, P.Y, R); + end Create; + + ------------ + -- Create -- + ------------ + + function Create (X : Integer) return Circle is + begin + return (X, 0, 0); + end Create; + + ------------ + -- Create -- + ------------ + + function Create (X : Integer; Y : Integer) return Circle is + begin + return (X, Y, 0); + end Create; + + ------------ + -- Create -- + ------------ + + function Create (X : Integer; Y : Integer; R : Integer) return Circle is + begin + return (X, Y, R); + end Create; + + ------------ + -- Create -- + ------------ + + function Create return Circle is + begin + return (0, 0, 0); + end Create; + +end Shapes.Circles; diff --git a/Task/Polymorphism/Ada/polymorphism-5.ada b/Task/Polymorphism/Ada/polymorphism-5.ada new file mode 100644 index 0000000000..eaa0a997f8 --- /dev/null +++ b/Task/Polymorphism/Ada/polymorphism-5.ada @@ -0,0 +1,10 @@ +with Shapes.Circles; use Shapes.Circles; +use Shapes; + +procedure Shapes_Main is + P : Point; + C : Circle; +begin + P.Print; + C.Print; +end Shapes_Main; diff --git a/Task/Polymorphism/Aikido/polymorphism.aikido b/Task/Polymorphism/Aikido/polymorphism.aikido new file mode 100644 index 0000000000..2c119014cf --- /dev/null +++ b/Task/Polymorphism/Aikido/polymorphism.aikido @@ -0,0 +1,25 @@ +class Point (protected x=0.0, protected y=0.0) { + public function print { + println ("Point") + } + + public function getX { return x } + public function getY { return y } + + public function setX(nx) { x = nx } + public function setY(ny) { y = ny } +} + +class Circle (x=0.0, y=0.0, r=0.0) extends Point (x, y) { + public function print { + println ("Circle") + } + + public function getR { return r } + public function setR(nr) { r = nr } +} + +var p = new Point (1, 2) +var c = new Circle (1, 2, 3) +p.print() +c.print() diff --git a/Task/Polymorphism/BBC-BASIC/polymorphism.bbc b/Task/Polymorphism/BBC-BASIC/polymorphism.bbc new file mode 100644 index 0000000000..fbda7ab67b --- /dev/null +++ b/Task/Polymorphism/BBC-BASIC/polymorphism.bbc @@ -0,0 +1,38 @@ + INSTALL @lib$ + "CLASSLIB" + + REM Create parent class with void 'doprint' method: + DIM PrintableShape{doprint} + PROC_class(PrintableShape{}) + + REM Create derived class for Point: + DIM Point{x#, y#, setxy, retx, rety, @constructor, @@destructor} + PROC_inherit(Point{}, PrintableShape{}) + DEF Point.setxy (x,y) : Point.x# = x : Point.y# = y : ENDPROC + DEF Point.retx = Point.x# + DEF Point.rety = Point.y# + DEF Point.@constructor Point.x# = 1.23 : Point.y# = 4.56 : ENDPROC + DEF Point.@@destructor : ENDPROC + DEF Point.doprint : PRINT Point.x#, Point.y# : ENDPROC + PROC_class(Point{}) + + REM Create derived class for Circle: + DIM Circle{x#, y#, r#, setxy, setr, retx, rety, retr, @con, @@des} + PROC_inherit(Circle{}, PrintableShape{}) + DEF Circle.setxy (x,y) : Circle.x# = x : Circle.y# = y : ENDPROC + DEF Circle.setr (r) : Circle.r# = r : ENDPROC + DEF Circle.retx = Circle.x# + DEF Circle.rety = Circle.y# + DEF Circle.retr = Circle.r# + DEF Circle.@con Circle.x# = 3.2 : Circle.y# = 6.5 : Circle.r# = 7 : ENDPROC + DEF Circle.@@des : ENDPROC + DEF Circle.doprint : PRINT Circle.x#, Circle.y#, Circle.r# : ENDPROC + PROC_class(Circle{}) + + REM Test the polymorphic 'doprint' function: + PROC_new(mypoint{}, Point{}) + PROC(mypoint.doprint) + PROC_discard(mypoint{}) + PROC_new(mycircle{}, Circle{}) + PROC(mycircle.doprint) + PROC_discard(mycircle{}) + END diff --git a/Task/Polymorphism/C++/polymorphism-1.cpp b/Task/Polymorphism/C++/polymorphism-1.cpp new file mode 100644 index 0000000000..9b2e5821d8 --- /dev/null +++ b/Task/Polymorphism/C++/polymorphism-1.cpp @@ -0,0 +1,55 @@ +class Point +{ + protected: + int x, y; + public: + Point(int x0 = 0, int y0 = 0) : x(x0), y(y0) {} + Point(const Point& p) : x(p.x), y(p.y) {} + virtual ~Point() {} + const Point& operator=(const Point& p) + { + if(this != &p) + { + x = p.x; + y = p.y; + } + return *this; + } + int getX() { return x; } + int getY() { return y; } + int setX(int x0) { x = x0; } + int setY(int y0) { y = y0; } + virtual void print() { printf("Point\n"); } +}; + +class Circle : public Point +{ + private: + int r; + public: + Circle(Point p, int r0 = 0) : Point(p), r(r0) {} + Circle(int x0 = 0, int y0 = 0, int r0 = 0) : Point(x0, y0), r(r0) {} + virtual ~Circle() {} + const Circle& operator=(const Circle& c) + { + if(this != &c) + { + x = c.x; + y = c.y; + r = c.r; + } + return *this; + } + int getR() { return r; } + int setR(int r0) { r = r0; } + virtual void print() { printf("Circle\n"); } +}; + +int main() +{ + Point* p = new Point(); + Point* c = new Circle(); + p->print(); + c->print(); + return 0; +} diff --git a/Task/Polymorphism/C++/polymorphism-2.cpp b/Task/Polymorphism/C++/polymorphism-2.cpp new file mode 100644 index 0000000000..55640702d4 --- /dev/null +++ b/Task/Polymorphism/C++/polymorphism-2.cpp @@ -0,0 +1,67 @@ +// CRTP: Curiously Recurring Template Pattern +template +class PointShape +{ +protected: + int x, y; +public: + PointShape(int x0, int y0) : x(x0), y(y0) { } + ~PointShape() { } + int getX() { return x; } + int getY() { return y; } + int setX(int x0) { x = x0; } + int setY(int y0) { y = y0; } + + // compile-time virtual function + void print() { reinterpret_cast(this)->printType(); } +}; + +class Point : public PointShape +{ +public: + Point(int x0 = 0, int y0 = 0) : PointShape(x0, y0) { } + Point(const Point& p) : PointShape(p.x, p.y) { } + ~Point() {} + const Point& operator=(const Point& p) + { + if(this != &p) + { + x = p.x; + y = p.y; + } + return *this; + } + void printType() { printf("Point\n"); } +}; + +class Circle : public PointShape +{ +private: + int r; +public: + Circle(int x0 = 0, int y0 = 0, int r0 = 0) : PointShape(x0, y0), r(r0) { } + Circle(Point p, int r0 = 0) : PointShape(p.x, p.y), r(r0) { } + ~Circle() {} + const Circle& operator=(const Circle& c) + { + if(this != &c) + { + x = c.x; + y = c.y; + r = c.r; + } + return *this; + } + int getR() { return r; } + int setR(int r0) { r = r0; } + void printType() { printf("Circle\n"); } +}; + +int main() +{ + Point* p = new Point(); + Point* c = new Circle(); + p->print(); + c->print(); + return 0; +} diff --git a/Task/Polymorphism/Clojure/polymorphism.clj b/Task/Polymorphism/Clojure/polymorphism.clj new file mode 100644 index 0000000000..baeac25605 --- /dev/null +++ b/Task/Polymorphism/Clojure/polymorphism.clj @@ -0,0 +1,18 @@ +(defprotocol Printable + (print-it [this] "Prints out the Printable.")) + +(deftype Point [x y] + Printable + (print-it [this] (println (str "Point: " x " " y)))) + +(defn create-point + "Redundant constructor function." + [x y] (Point. x y)) + +(deftype Circle [x y r] + Printable + (print-it [this] (println (str "Circle: " x " " y " " r)))) + +(defn create-circle + "Redundant consturctor function." + [x y r] (Circle. x y r)) diff --git a/Task/Polymorphism/Common-Lisp/polymorphism.lisp b/Task/Polymorphism/Common-Lisp/polymorphism.lisp new file mode 100644 index 0000000000..d177dfb731 --- /dev/null +++ b/Task/Polymorphism/Common-Lisp/polymorphism.lisp @@ -0,0 +1,23 @@ +(defclass point () + ((x :initarg :x :initform 0 :accessor x) + (y :initarg :y :initform 0 :accessor y))) + +(defclass circle (point) + ((radius :initarg :radius :initform 0 :accessor radius))) + +(defgeneric shallow-copy (object)) +(defmethod shallow-copy ((p point)) + (make-instance 'point :x (x p) :y (y p))) +(defmethod shallow-copy ((c circle)) + (make-instance 'circle :x (x c) :y (y c) :radius (radius c))) + +(defgeneric print-shape (shape)) +(defmethod print-shape ((p point)) + (print 'point)) +(defmethod print-shape ((c circle)) + (print 'circle)) + +(let ((p (make-instance 'point :x 10)) + (c (make-instance 'circle :radius 5))) + (print-shape p) + (print-shape c)) diff --git a/Task/Polymorphism/D/polymorphism.d b/Task/Polymorphism/D/polymorphism.d new file mode 100644 index 0000000000..f2577a4e99 --- /dev/null +++ b/Task/Polymorphism/D/polymorphism.d @@ -0,0 +1,36 @@ +import std.stdio: writeln; + +class Point { + private int x, y; + this(int x_=0, int y_=0) { x = x_; y = y_; } + this(Point p_) { x = p_.getX(); y = p_.getY(); } + int getX() { return x; } + void setX(int x_) { this.x = x_; } + int getY() { return y; } + void setY(int y_) { this.y = y_; } +} + +class Circle : Point { + private int r; + this(int x_=0, int y_=0, int r_=0) { + super(x_, y_); + r = r_; + } + this(Point p, int r_=0) { + super(p); + r = r_; + } + this(Circle c_) { + super(c_.getX(), c_.getY()); + r = c_.getR(); + } + int getR() { return r; } + void setR(int r0) { this.r = r0; } +} + +void main() { + auto p = new Point(); + auto c = new Circle(); + writeln(p); + writeln(c); +} diff --git a/Task/Polymorphism/Delphi/polymorphism-1.delphi b/Task/Polymorphism/Delphi/polymorphism-1.delphi new file mode 100644 index 0000000000..c90a8454b6 --- /dev/null +++ b/Task/Polymorphism/Delphi/polymorphism-1.delphi @@ -0,0 +1,107 @@ +type + { TPoint } + + TMyPoint = class + private + FX: Integer; + FY: Integer; + public + constructor Create; overload; + constructor Create(X0: Integer; Y0: Integer); overload; + constructor Create(MyPoint: TMyPoint); overload; + destructor Destroy; override; + + procedure Print; virtual; + + property X: Integer read FX write FX; + property Y: Integer read FY write FY; + end; + + { TCircle } + + TCircle = class(TMyPoint) + private + FR: Integer; + public + constructor Create(X0: Integer; Y0: Integer; R0: Integer); overload; + constructor Create(MyPoint: TMyPoint; R0: Integer); overload; + constructor Create(Circle: TCircle); overload; + destructor Destroy; override; + + procedure Print; override; + + property R: Integer read FR write FR; + end; + +implementation + +uses Dialogs; + +{ TCircle } + +constructor TCircle.Create(X0: Integer; Y0: Integer; R0: Integer); +begin + inherited Create(X0, Y0); + FR := R0; +end; + +constructor TCircle.Create(MyPoint: TMyPoint; R0: Integer); +begin + inherited Create(MyPoint); + FR := R0; +end; + +constructor TCircle.Create(Circle: TCircle); +begin + Create; + if not(Circle = Self) then + begin + FX := Circle.X; + FY := Circle.Y; + FR := Circle.R; + end; +end; + +destructor TCircle.Destroy; +begin + inherited Destroy; +end; + +procedure TCircle.Print; +begin + ShowMessage('Circle'); +end; + +{ TMyPoint } + +constructor TMyPoint.Create; +begin + inherited Create; +end; + +constructor TMyPoint.Create(X0: Integer; Y0: Integer); +begin + Create; + FX := X0; + FY := Y0; +end; + +constructor TMyPoint.Create(MyPoint: TMyPoint); +begin + Create; + if not(MyPoint = Self) then + begin + FX := MyPoint.X; + FY := MyPoint.Y; + end; +end; + +destructor TMyPoint.Destroy; +begin + inherited Destroy; +end; + +procedure TMyPoint.Print; +begin + ShowMessage('MyPoint'); +end; diff --git a/Task/Polymorphism/Delphi/polymorphism-2.delphi b/Task/Polymorphism/Delphi/polymorphism-2.delphi new file mode 100644 index 0000000000..785009dc60 --- /dev/null +++ b/Task/Polymorphism/Delphi/polymorphism-2.delphi @@ -0,0 +1,17 @@ +var + MyPoint: TMyPoint; + Circle: TCircle; +begin + MyPoint := TMyPoint.Create; + try + MyPoint.Print; + Circle := TCircle.Create; + try + Circle.Print; + finally + FreeAndNil(Circle); + end; + finally + FreeAndNil(MyPoint); + end; +end; diff --git a/Task/Polymorphism/E/polymorphism-1.e b/Task/Polymorphism/E/polymorphism-1.e new file mode 100644 index 0000000000..5644e4deb1 --- /dev/null +++ b/Task/Polymorphism/E/polymorphism-1.e @@ -0,0 +1,23 @@ +def makePoint(x, y) { + def point implements pbc { + to __printOn(out) { out.print(``) } + to __optUncall() { return [makePoint, "run", [x, y]] } + to x() { return x } + to y() { return y } + to withX(new) { return makePoint(new, y) } + to withY(new) { return makePoint(x, new) } + } + return point +} + +def makeCircle(x, y, r) { + def circle extends makePoint(x, y) implements pbc { + to __printOn(out) { out.print(``) } + to __optUncall() { return [makeCircle, "run", [x, y, r]] } + to r() { return r } + to withX(new) { return makeCircle(new, y, r) } + to withY(new) { return makeCircle(x, new, r) } + to withR(new) { return makeCircle(x, y, new) } + } + return circle +} diff --git a/Task/Polymorphism/E/polymorphism-2.e b/Task/Polymorphism/E/polymorphism-2.e new file mode 100644 index 0000000000..3df152857f --- /dev/null +++ b/Task/Polymorphism/E/polymorphism-2.e @@ -0,0 +1,4 @@ +def p := makePoint(0.5, 0.5) +def c := makeCircle(1, 1, 2) +println(p) +println(c) diff --git a/Task/Polymorphism/Eiffel/polymorphism-1.e b/Task/Polymorphism/Eiffel/polymorphism-1.e new file mode 100644 index 0000000000..0277373a6e --- /dev/null +++ b/Task/Polymorphism/Eiffel/polymorphism-1.e @@ -0,0 +1,64 @@ +class + POINT +inherit + ANY + redefine + out + end +create + make, make_origin + +feature -- Initialization + + make (a_x, a_y: INTEGER) + -- Create with values `a_x' and `a_y' + do + set_x (a_x) + set_y (a_y) + ensure + x_set: x = a_x + y_set: y = a_y + end + + make_origin + -- Create at origin + do + ensure + x_set: x = 0 + y_set: y = 0 + end + +feature -- Access + + x: INTEGER assign set_x + -- Horizontal axis coordinate + + y: INTEGER assign set_y + -- Vertical axis coordinate + +feature -- Element change + + set_x (a_x: INTEGER) + -- Set `x' coordinate to `a_x' + do + x := a_x + ensure + x_set: x = a_x + end + + set_y (a_y: INTEGER) + -- Set `y' coordinate to `a_y' + do + y := a_y + ensure + y_set: y = a_y + end + +feature -- Output + + out: STRING + -- Display as string + do + Result := "Point: x = " + x.out + " y = " + y.out + end +end diff --git a/Task/Polymorphism/Eiffel/polymorphism-2.e b/Task/Polymorphism/Eiffel/polymorphism-2.e new file mode 100644 index 0000000000..405c1db38b --- /dev/null +++ b/Task/Polymorphism/Eiffel/polymorphism-2.e @@ -0,0 +1,81 @@ +class + CIRCLE + +inherit + POINT + rename + make as point_make + redefine + make_origin, + out + end +create + make, make_origin, make_from_point + +feature -- Initialization + + make (a_x, a_y, a_r: INTEGER) + -- Create with values `a_x' and `a_y' and `a_r' + require + non_negative_radius_argument: a_r >= 0 + do + point_make (a_x, a_y) + set_r (a_r) + ensure + x_set: x = a_x + y_set: y = a_y + r_set: r = a_r + end + + make_origin + -- Create at origin with zero radius + do + Precursor + ensure then + r_set: r = 0 + end + + make_from_point (a_p: POINT; a_r: INTEGER) + -- Initialize from `a_r' with radius `a_r'. + require + non_negative_radius_argument: a_r >= 0 + do + set_x (a_p.x) + set_y (a_p.y) + set_r (a_r) + ensure + x_set: x = a_p.x + y_set: y = a_p.y + r_set: r = a_r + end + +feature -- Access + + r: INTEGER assign set_r + -- Radius + +feature -- Element change + + set_r (a_r: INTEGER) + -- Set radius (`r') to `a_r' + require + non_negative_radius_argument: a_r >= 0 + do + r := a_r + ensure + r_set: r = a_r + end + +feature -- Output + + out: STRING + -- Display as string + do + Result := "Circle: x = " + x.out + " y = " + y.out + " r = " + r.out + end + +invariant + + non_negative_radius: r >= 0 + +end diff --git a/Task/Polymorphism/Eiffel/polymorphism-3.e b/Task/Polymorphism/Eiffel/polymorphism-3.e new file mode 100644 index 0000000000..5e8b2f1c83 --- /dev/null +++ b/Task/Polymorphism/Eiffel/polymorphism-3.e @@ -0,0 +1,34 @@ +class + APPLICATION + +create + make + +feature {NONE} -- Initialization + + make + -- Run application. + local + my_point: POINT + my_circle: CIRCLE + do + create my_point.make_origin + print (my_point.out + "%N") + + create {CIRCLE} my_point.make_origin + print (my_point.out + "%N") + + create my_point.make (10, 15) + print (my_point.out + "%N") + + create {CIRCLE} my_point.make (20, 25, 5) + print (my_point.out + "%N") + + create my_circle.make (30, 35, 10) + print (my_circle.out + "%N") + + create my_circle.make_from_point (my_point, 35) + print (my_circle.out + "%N") + end + +end diff --git a/Task/Polymorphism/Eiffel/polymorphism-4.e b/Task/Polymorphism/Eiffel/polymorphism-4.e new file mode 100644 index 0000000000..52e7954a8e --- /dev/null +++ b/Task/Polymorphism/Eiffel/polymorphism-4.e @@ -0,0 +1,6 @@ +Point: x = 0 y = 0 +Circle: x = 0 y = 0 r = 0 +Point: x = 10 y = 15 +Circle: x = 20 y = 25 r = 5 +Circle: x = 30 y = 35 r = 10 +Circle: x = 20 y = 25 r = 35 diff --git a/Task/Polymorphism/Ela/polymorphism-1.ela b/Task/Polymorphism/Ela/polymorphism-1.ela new file mode 100644 index 0000000000..ca2aa32630 --- /dev/null +++ b/Task/Polymorphism/Ela/polymorphism-1.ela @@ -0,0 +1,45 @@ +type Point = Point x y + +instance Show Point where + showf _ (Point x y) = "Point " ++ (show x) ++ " " ++ (show y) + +instance Name Point where + getField nm (Point x y) + | nm == "x" = x + | nm == "y" = y + | else = fail "Undefined name." + isField nm _ = nm == "x" or nm == "y" + +pointX = flip Point 0 + +pointY = Point 0 + +pointEmpty = Point 0 0 + +type Circle = Circle x y z + +instance Show Circle where + showf _ (Circle x y z) = + "Circle " ++ (show x) ++ " " ++ (show y) ++ " " ++ (show z) + +instance Name Circle where + getField nm (Circle x y z) + | nm == "x" = x + | nm == "y" = y + | nm == "z" = z + | else = fail "Undefined name." + isField nm _ = nm == "x" or nm == "y" or nm == "z" + +circleXZ = flip Circle 0 + +circleX x = Circle x 0 0 + +circleYZ = Circle 0 + +circleY y = Circle 0 y 0 + +circleZ = Circle 0 0 + +circleEmpty = Circle 0 0 0 + +circleX 1 2 diff --git a/Task/Polymorphism/Ela/polymorphism-2.ela b/Task/Polymorphism/Ela/polymorphism-2.ela new file mode 100644 index 0000000000..9eb870e68c --- /dev/null +++ b/Task/Polymorphism/Ela/polymorphism-2.ela @@ -0,0 +1,2 @@ +c = circleX 12 +c.x //Evaluates to 12 diff --git a/Task/Polymorphism/Factor/polymorphism.factor b/Task/Polymorphism/Factor/polymorphism.factor new file mode 100644 index 0000000000..e48e363f17 --- /dev/null +++ b/Task/Polymorphism/Factor/polymorphism.factor @@ -0,0 +1,13 @@ +QUALIFIED: io ! there already is print in io + +GENERIC: print ( shape -- ) + +TUPLE: point x y ; +C: point ! shorthand constructor definition + +M: point print drop "Point" io:print ; + +TUPLE: circle radius x y ; +C: circle + +M: circle print drop "Circle" io:print ; diff --git a/Task/Polymorphism/Forth/polymorphism.fth b/Task/Polymorphism/Forth/polymorphism.fth new file mode 100644 index 0000000000..d9f7d22fc8 --- /dev/null +++ b/Task/Polymorphism/Forth/polymorphism.fth @@ -0,0 +1,89 @@ +include lib/memcell.4th +include 4pp/lib/foos.4pp + +:: Point ( xn n a--) + class + field: x \ x coordinate + field: y \ y coordinate + method: print \ print routine + method: setx \ set x coordinate + method: sety \ set y coordinate + method: getx \ get x coordinate + method: gety \ get y coordinate + end-class { + \ bind the methods immediately + :method { this -> x ! } ; defines setx + :method { this -> y ! } ; defines sety + :method { this -> x @ } ; defines getx + :method { this -> y @ } ; defines gety + \ because we'll use them immediately + :method { \ e.g. in this print routine + ." Point(" this => getx 0 .r ." ," this => gety 0 .r ." )" cr + } ; defines print \ and this initialization + \ object or argument count + dup type@ this type@ = \ if it is an object, a point + if \ get the coordinates and set them + dup => getx this => setx + => gety this => sety + else \ otherwise initialize it + 0 dup this => setx this => sety + case \ and check the argument count + 1 of this => setx endof \ one argument : x only + 2 of this => setx \ two arguments: x and y + this => sety endof + endcase + then + + private{ x y } \ make x and y private + } +; + +:: Circle ( xn n a --) + over >r ( arg-count object-addr) + extends Point \ save the argument count!! + field: r \ radius + method: getr \ get radius + method: setr \ set radius + end-extends r> swap { \ retrieve count + \ bind the methods immediately + :method { this -> r ! } ; defines setr + :method { this -> r @ } ; defines getr + \ because we'll use them immediately + :method { \ e.g. in this print routine + ." Circle(" this => getx 0 .r ." ," + this => gety 0 .r ." ," + this => getr 0 .r ." )" cr + } ; defines print \ and this initialization + \ object or argument count + dup type@ this type@ = \ if it is an object, a circle + if \ get the coordinates and set them + dup => getx this => setx + dup => gety this => sety + => getr this => setr + else \ otherwise initialize it + 0 this => setr + case \ and check the argument count + 3 of this => setr \ three arguments: x, y and r + this => sety \ note the rest is already set + this => setx endof \ by "Point" and r was left on + endcase \ the stack! + then + + private{ r } + } +; + +0 new Point Point1 +Point1 => print +45 23 2 new Point Point2 +Point2 => print +Point2 new Point Point3 +Point3 => print +78 1 new Point Point4 +Point4 => print +10 45 23 3 new Circle Circle1 +Circle1 => print +Point2 new Circle Circle2 +Circle2 => print +Circle1 new Circle Circle3 +Circle3 => print diff --git a/Task/Polymorphism/Fortran/polymorphism.f b/Task/Polymorphism/Fortran/polymorphism.f new file mode 100644 index 0000000000..8ae4e8648b --- /dev/null +++ b/Task/Polymorphism/Fortran/polymorphism.f @@ -0,0 +1,81 @@ +module geom + + type point + real(8), private :: x = 0 + real(8), private :: y = 0 + contains + procedure, public :: get_x + procedure, public :: get_y + procedure, public :: set_x + procedure, public :: set_y + procedure, public :: print => print_point + end type point + + type, extends(point) :: circle + real(8), private :: r = 0 + contains + procedure, public :: get_r + procedure, public :: set_r + procedure, public :: print => print_circle + end type circle + +contains + + real(8) function get_x(this) + class(point), intent(in) :: this + get_x = this%x + end function get_x + + real(8) function get_y(this) + class(point), intent(in) :: this + get_y = this%y + end function get_y + + subroutine set_x(this, val) + class(point), intent(inout) :: this + real(8), intent(in) :: val + this%x = val + end subroutine set_x + + subroutine set_y(this, val) + class(point), intent(inout) :: this + real(8), intent(in) :: val + this%y = val + end subroutine set_y + + subroutine print_point(this) + class(point), intent(in) :: this + write(*,'(2(a,f0.4),a)') 'Point(',this%x,', ',this%y,')' + end subroutine print_point + + real(8) function get_r(this) + class(circle), intent(in) :: this + get_r = this%r + end function get_r + + subroutine set_r(this, val) + class(circle), intent(inout) :: this + real(8), intent(in) :: val + this%r = val + end subroutine set_r + + subroutine print_circle(this) + class(circle), intent(in) :: this + write(*,'(3(a,f0.4),a)') 'Circle(',this%x,', ',this%y,'; ',this%r,')' + end subroutine print_circle + +end module geom + +program inh + use geom + + type(point) :: p + type(circle) :: c + + p = point(2.0d0, 3.0d0) + call p%print + + c = circle(3.0d0, 4.0d0, 5.0d0) + call c%print + +end program inh diff --git a/Task/Polymorphism/Go/polymorphism.go b/Task/Polymorphism/Go/polymorphism.go new file mode 100644 index 0000000000..745d977fbc --- /dev/null +++ b/Task/Polymorphism/Go/polymorphism.go @@ -0,0 +1,81 @@ +package main + +import "fmt" + +type point struct { + x, y float64 +} + +type circle struct { + x, y, r float64 +} + +type printer interface { + print() +} + +func (p *point) print() { + fmt.Println(p.x, p.y) +} + +func (c *circle) print() { + fmt.Println(c.x, c.y, c.r) +} + +func main() { + var i printer // polymorphic variable + i = newPoint(3, 4) // assign one type + i.print() // call polymorphic function + i = newCircle(5, 12, 13) // assign different type to same variable + i.print() // same call accesses different method now. +} + +// Above is a sort of polymorphism: both types implement the printer +// interface. The print function can be called through a variable +// of type printer, without knowing the underlying type. + +// Below is other stuff the task asks for. Note that none of it is +// needed for cases as simple as this task, and it is not idomatic +// to write any of these functions in these simple cases. + +// Accessors are not idiomatic in Go. Instead, simply access struct +// fields directly. To allow access from another package, you "export" +// the field by capitalizing the field name. +func (p *point) getX() float64 { return p.x } +func (p *point) getY() float64 { return p.y } +func (p *point) setX(v float64) { p.x = v } +func (p *point) setY(v float64) { p.y = v } + +func (c *circle) getX() float64 { return c.x } +func (c *circle) getY() float64 { return c.y } +func (c *circle) getR() float64 { return c.r } +func (c *circle) setX(v float64) { c.x = v } +func (c *circle) setY(v float64) { c.y = v } +func (c *circle) setR(v float64) { c.r = v } + +// Copy constructors, not idiomatic. Structs are assignable so +// you can simply declare and assign them as needed. +func (p *point) clone() *point { r := *p; return &r } +func (c *circle) clone() *circle { r := *c; return &r } + +// Assignment methods, not idiomatic. Just use the assignment operator. +func (p *point) set(q *point) { *p = *q } +func (c *circle) set(d *circle) { *c = *d } + +// Constructors are idiomatic only when construction involves something +// more than just assigning initial values. By default, structs +// are created as "zero values," that is, with all fields zero, +// empty, or nil. The struct literal synax allows for all fields to +// initialized, or for any subset of fields to be initialized by name. +// These feautures take the place of trivial default constructors. +// When additional initialization is needed, it is conventional to +// name a function New, New, or within a package, new +// as shown here. +func newPoint(x, y float64) *point { + return &point{x, y} +} +func newCircle(x, y, r float64) *circle { + return &circle{x, y, r} +} + +// Destructors are never used in Go. Objects are garbage collected. diff --git a/Task/Polymorphism/Haskell/polymorphism-1.hs b/Task/Polymorphism/Haskell/polymorphism-1.hs new file mode 100644 index 0000000000..c4f4b912b7 --- /dev/null +++ b/Task/Polymorphism/Haskell/polymorphism-1.hs @@ -0,0 +1,31 @@ +data Point = Point Integer Integer +instance Show Point where + show (Point x y) = "Point at "++(show x)++","++(show y) + +-- Constructor that sets y to 0 +ponXAxis = flip Point 0 + +-- Constructor that sets x to 0 +ponYAxis = Point 0 + +-- Constructor that sets x and y to 0 +porigin = Point 0 0 + +data Circle = Circle Integer Integer Integer +instance Show Circle where + show (Circle x y r) = "Circle at "++(show x)++","++(show y)++" with radius "++(show r) + +-- Constructor that sets y to 0 +conXAxis = flip Circle 0 + +-- Constructor that sets x to 0 +conYAxis = Circle 0 + +-- Constructor that sets x and y to 0 +catOrigin = Circle 0 0 + +--Constructor that sets y and r to 0 +c0OnXAxis = flip (flip Circle 0) 0 + +--Constructor that sets x and r to 0 +c0OnYAxis = flip (Circle 0) 0 diff --git a/Task/Polymorphism/Haskell/polymorphism-2.hs b/Task/Polymorphism/Haskell/polymorphism-2.hs new file mode 100644 index 0000000000..186801ad4b --- /dev/null +++ b/Task/Polymorphism/Haskell/polymorphism-2.hs @@ -0,0 +1,63 @@ +class Circle (x, y, r) + # make a new copy of this instance + method copy () + return Circle (x, y, r) + end + + # print a representation of this instance + method print () + write ("Circle (" || x || ", " || y || ", " || r || ")") + end + + # called during instance construction, to pass in field values + initially (x, y, r) + self.x := if /x then 0 else x # set to 0 if argument not present + self.y := if /y then 0 else y + self.r := if /r then 0 else r + +end + +class Point (x, y) + # make a new copy of this instance + method copy () + return Point (x, y) + end + + # print a representation of this instance + method print () + write ("Point (" || x || ", " || y || ")") + end + + # called during instance construction, to pass in field values + initially (x, y) + self.x := if /x then 0 else x # set to 0 if argument not present + self.y := if /y then 0 else y + +end + +procedure main () + p1 := Point () + p2 := Point (1) + p3 := Point (1,2) + p4 := p3.copy () + + write ("Points:") + p1.print () + p2.print () + p3.print () + p4.print () + # demonstrate field mutator/accessor + p3.x := 3 + write ("p3 value of x is: " || p3.x) + + c1 := Circle () + c2 := Circle (1) + c3 := Circle (1,2) + c4 := Circle (1,2,3) + + write ("Circles:") + c1.print () + c2.print () + c3.print () + c4.print () +end diff --git a/Task/Polymorphism/Inform-7/polymorphism.inf b/Task/Polymorphism/Inform-7/polymorphism.inf new file mode 100644 index 0000000000..1485e3d8f7 --- /dev/null +++ b/Task/Polymorphism/Inform-7/polymorphism.inf @@ -0,0 +1,19 @@ +Space is a room. + +A point is a kind of thing. +A point has a number called X position. +A point has a number called Y position. + +A circle is a kind of point. +A circle has a number called radius. + +To print (P - point): say "Point: [X position of P], [Y position of P]." +To print (C - circle): say "Circle: [X position of C], [Y position of C] radius [radius of C]." + +The origin is a point with X position 0 and Y position 0. +The circle of power is a circle with X position 100, Y position 25, radius 7. + +When play begins: + print the origin; + print the circle of power; + end the story. diff --git a/Task/Polymorphism/J/polymorphism-1.j b/Task/Polymorphism/J/polymorphism-1.j new file mode 100644 index 0000000000..7a720e8b72 --- /dev/null +++ b/Task/Polymorphism/J/polymorphism-1.j @@ -0,0 +1,12 @@ +coclass 'Point' +create=: monad define + 'X Y'=:2{.y +) +getX=: monad def 'X' +getY=: monad def 'Y' +setX=: monad def 'X=:y' +setY=: monad def 'Y=:y' +print=: monad define + smoutput 'Point ',":X,Y +) +destroy=: codestroy diff --git a/Task/Polymorphism/J/polymorphism-2.j b/Task/Polymorphism/J/polymorphism-2.j new file mode 100644 index 0000000000..35d1ba0267 --- /dev/null +++ b/Task/Polymorphism/J/polymorphism-2.j @@ -0,0 +1,10 @@ +coclass 'Circle' +coinsert 'Point' +create=: monad define + 'X Y R'=: 3{.y +) +getR=: monad def 'R' +setR=: monad def 'R=:y' +print=: monad define + smoutput 'Circle ',":X,Y,R +) diff --git a/Task/Polymorphism/Java/polymorphism.java b/Task/Polymorphism/Java/polymorphism.java new file mode 100644 index 0000000000..6a4655dd7b --- /dev/null +++ b/Task/Polymorphism/Java/polymorphism.java @@ -0,0 +1,33 @@ +class Point { + protected 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 Point(Point p) { this(p.x, p.y); } + public int getX() { return x; } + public int getY() { return y; } + public int setX(int x0) { x = x0; } + public int setY(int y0) { y = y0; } + public void print() { System.out.println("Point"); } +} + +public class Circle extends Point { + private int r; + public Circle(Point p) { this(p, 0); } + public Circle(Point p, int r0) { super(p); r = r0; } + public Circle() { this(0); } + public Circle(int x0) { this(x0, 0); } + public Circle(int x0, int y0) { this(x0, y0, 0); } + public Circle(int x0, int y0, int r0) { super(x0, y0); r = r0; } + public Circle(Circle c) { this(c.x, c.y, c.r); } + public int getR() { return r; } + public int setR(int r0) { r = r0; } + public void print() { System.out.println("Circle"); } + + public static void main(String args[]) { + Point p = new Point(); + Point c = new Circle(); + p.print(); + c.print(); + } +} diff --git a/Task/Polymorphism/JavaScript/polymorphism.js b/Task/Polymorphism/JavaScript/polymorphism.js new file mode 100644 index 0000000000..1af306e0ad --- /dev/null +++ b/Task/Polymorphism/JavaScript/polymorphism.js @@ -0,0 +1,63 @@ +/* create new Point in one of these ways: + * var p = new Point(x,y); + * var p = new Point(a_point); + * default value for x,y is 0 + */ +function Point() { + var arg1 = arguments[0]; + var arg2 = arguments[1]; + + if (arg1 instanceof Point) { + this.x = arg1.x; + this.y = arg1.y; + } + else { + this.x = arg1 == null ? 0 : arg1; + this.y = arg2 == null ? 0 : arg1; + } + + this.set_x = function(_x) {this.x = _x;} + this.set_y = function(_y) {this.y = _y;} +} + +Point.prototype.print = function() { + var out = "Point(" + this.x + "," + this.y + ")"; + print(out); +} + +/* create new Circle in one of these ways: + * var c = new Circle(x,y,r); + * var c = new Circle(a_circle); + * var c = new Circle(a_point,r); + * default value for x,y,r is 0 + */ +function Circle() { + var arg1 = arguments[0]; + var arg2 = arguments[1]; + var arg3 = arguments[2]; + + if (arg1 instanceof Circle) { + this.x = arg1.x; + this.y = arg1.y; + this.r = arg1.r; + } + else if (arg1 instanceof Point) { + this.x = arg1.x; + this.y = arg1.y; + this.r = arg2 == null ? 0 : arg2; + } + else { + this.x = arg1 == null ? 0 : arg1; + this.y = arg2 == null ? 0 : arg2; + this.r = arg3 == null ? 0 : arg3; + } + + this.set_x = function(_x) {this.x = _x;} + this.set_y = function(_y) {this.y = _y;} + this.set_r = function(_r) {this.r = _r;} +} + +Circle.prototype.print = function() { + var out = "Circle(" + this.x + "," + this.y + "," + this.r + ")"; + print(out); +} diff --git a/Task/Polymorphism/Lua/polymorphism.lua b/Task/Polymorphism/Lua/polymorphism.lua new file mode 100644 index 0000000000..72724b8818 --- /dev/null +++ b/Task/Polymorphism/Lua/polymorphism.lua @@ -0,0 +1,29 @@ +-- Point +local Point = {x = 0, y = 0} + +function Point:new(o) + o = o or {} + setmetatable(o, self) + self.__index = self + return o +end + +function Point:print() + print("Point(" .. self.x .. ", " .. self.y .. ")") +end + +function Point:copy() + return Point:new{x = self.x, y = self.y} +end + +-- Circle +local Circle = Point:new() +Circle.r = 0 + +function Circle:print() + print("Circle(" .. self.x .. ", " .. self.y .. ", " .. self.r .. ")") +end + +function Circle:copy() + return Circle:new{x = self.x, y = self.y, r = self.r} +end diff --git a/Task/Polymorphism/NetRexx/polymorphism.netrexx b/Task/Polymorphism/NetRexx/polymorphism.netrexx new file mode 100644 index 0000000000..7bdcf91655 --- /dev/null +++ b/Task/Polymorphism/NetRexx/polymorphism.netrexx @@ -0,0 +1,104 @@ +/* NetRexx */ + +options replace format comments java crossref savelog symbols binary + +-- ----------------------------------------------------------------------------- +class RCPolymorphism public final + +method main(args = String[]) public constant + + parry = [Point - + Point() - + , Point(1.0) - + , Point(1.0, 2.0) - + , Point(Point(0.3, 0.2)) - + , Circle() - + , Circle(2.0, 2.0) - + , Circle(5.0, 6.0, 7.0) - + , Circle(Point(8.0, 9.0)) - + , Circle(Point(8.0, 9.0), 4.0) - + , Circle(Circle(1.5, 1.4, 1.3)) - + ] + + loop pp = 0 to parry.length - 1 + parry[pp].print + end pp + + return + +-- ----------------------------------------------------------------------------- +class RCPolymorphism.Point public binary + +properties private + x = double + y = double + className = Point.class.getSimpleName + +method Point(x_ = double 0.0, y_ = double 0.0) + setX(x_) + setY(y_) + return + +method Point(p = Point) + this(p.getX, p.getY) + return + +method display public returns String + hx = '@'Rexx(Integer.toHexString(hashCode())).right(8, 0) + str = Rexx(className).left(10)':'hx': (x,y) = (' || - + Rexx(getX()).format(null, 3)',' - + Rexx(getY()).format(null, 3)')' + return str + +method getX public returns double + return x + +method getY public returns double + return y + +method setX(x_ = double 0.0) inheritable + x = x_ + return + +method setY(y_ = double 0.0) inheritable + y = y_ + return + +method print inheritable + say display + return + +-- ----------------------------------------------------------------------------- +class RCPolymorphism.Circle public extends RCPolymorphism.Point binary + +properties private + r = double + className = Circle.class.getSimpleName + +method Circle(x_ = double 0.0, y_ = double 0.0, r_ = double 0.0) + super(x_, y_) + setR(r_) + return + +method Circle(p_ = RCPolymorphism.Point, r_ = double 0.0) + this(p_.getX, p_.getY, r_) + return + +method Circle(c_ = Circle) + this(c_.getX, c_.getY, c_.getR) + return + +method getR public returns double + return r + +method setR(r_ = double 0.0) inheritable + r = r_ + return + +method display public returns String + hx = '@'Rexx(Integer.toHexString(hashCode())).right(8, 0) + str = Rexx(className).left(10)':'hx': (x,y,r) = (' || - + Rexx(getX()).format(null, 3)',' - + Rexx(getY()).format(null, 3)',' - + Rexx(getR()).format(null, 3)')' + return str diff --git a/Task/Polymorphism/OCaml/polymorphism.ocaml b/Task/Polymorphism/OCaml/polymorphism.ocaml new file mode 100644 index 0000000000..3934ae27fb --- /dev/null +++ b/Task/Polymorphism/OCaml/polymorphism.ocaml @@ -0,0 +1,33 @@ +class point ?(x=0.0) ?(y=0.0) () = (* extra () used to erase the optional parameters *) +object (self) + val mutable x = x + val mutable y = y + + method x = x + method y = y + method set_x x' = x <- x' + method set_y y' = y <- y' + method print = Printf.sprintf "Point (%f, %f)" x y + method copy = {< >} +end + +class circle ?(r=1.0) ?(x=0.0) ?(y=0.0) () = +object (self) + inherit point ~x:x ~y:y () + val mutable r = r + + method r = r + method set_r r' = r <- r' + method print = Printf.sprintf "Circle (%f, %f, %f)" r x y +end + +let print x = print_endline x#print + +let () = + let p = new point () in + let c = new circle () in + print c; + print p; + c#set_x 10.0; + print c; + print (new point ~y:2.1 ()) diff --git a/Task/Polymorphism/Objeck/polymorphism.objeck b/Task/Polymorphism/Objeck/polymorphism.objeck new file mode 100644 index 0000000000..e7b84e5e42 --- /dev/null +++ b/Task/Polymorphism/Objeck/polymorphism.objeck @@ -0,0 +1,82 @@ +bundle Default { + class Point { + @x : Int; + @y : Int; + + New() { + @x := 0; + @y := 0; + } + + New(x : Int, y : Int) { + @x := x; + @y := y; + } + + New(p : Point) { + @x := p->GetX(); + @y := p->GetY(); + } + + method : public : GetX() ~ Int { + return @x; + } + + method : public : GetY() ~ Int { + return @y; + } + + method : public : SetX(x : Int) ~ Nil { + @x := x; + } + + method : public : SetY(y : Int) ~ Nil { + @y := y; + } + + method : public : Print() ~ Nil { + "Point"->PrintLine(); + } + } + + + class Circle from Point { + @r : Int; + + New() { + Parent(); + @r := 0; + } + + New(p : Point) { + Parent(p); + @r := 0; + } + + New(c : Circle) { + Parent(c->GetX(), c->GetY()); + @r := c->GetR(); + } + + method : public : GetR() ~ Int { + return @r; + } + + method : public : SetR(r : Int) ~ Nil { + @r := r; + } + + method : public : Print() ~ Nil { + "Circle"->PrintLine(); + } + } + + class Poly { + function : Main(args : String[]) ~ Nil { + p := Point->New(); + c := Circle->New(); + p->Print(); + c->Print(); + } + } +} diff --git a/Task/Polymorphism/Objective-C/polymorphism.m b/Task/Polymorphism/Objective-C/polymorphism.m new file mode 100644 index 0000000000..5d3c193911 --- /dev/null +++ b/Task/Polymorphism/Objective-C/polymorphism.m @@ -0,0 +1,73 @@ +#import + +@interface RCPoint : NSObject { + int x, y; +} +-(id)initWithX:(int)x0; +-(id)initWithX:(int)x0 andY:(int)y0; +-(id)initWithPoint:(RCPoint *)p; +@property (nonatomic) int x; +@property (nonatomic) int y; +@end + +@implementation RCPoint +@synthesize x, y; +-(id)initWithX:(int)x0 { return [self initWithX:x0 andY:0]; } +-(id)initWithX:(int)x0 andY:(int)y0 { + if ((self = [super init])) { + x = x0; + y = y0; + } + return self; +} +-(id)initWithPoint:(RCPoint *)p { return [self initWithX:p.x andY:p.y]; } +-(NSString *)description { return [NSString stringWithFormat:@"", self, x, y]; } +@end + +@interface RCCircle : RCPoint { + int r; +} +-(id)initWithCenter:(RCPoint *)p andRadius:(int)r0; +-(id)initWithX:(int)x0 andY:(int)y0 andRadius:(int)r0; +-(id)initWithCircle:(RCCircle *)c; +@property (nonatomic) int r; +@end + +@implementation RCCircle +@synthesize r; +-(id)initWithCenter:(RCPoint *)p andRadius:(int)r0 { + if ((self = [super initWithPoint:p])) { + r = r0; + } + return self; +} +-(id)initWithX:(int)x0 andY:(int)y0 andRadius:(int)r0 { + if ((self = [super initWithX:x0 andY:y0])) { + r = r0; + } + return self; +} +-(id)initWithCircle:(RCCircle *)c { return [self initWithX:c.x andY:c.y andRadius:c.r]; } +-(NSString *)description { return [NSString stringWithFormat:@"", self, x, y, r]; } +@end + +int main(int argc, const char *argv[]) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + NSLog(@"%@", [[[RCPoint alloc] init] autorelease]); + NSLog(@"%@", [[[RCPoint alloc] initWithX:3] autorelease]); + NSLog(@"%@", [[[RCPoint alloc] initWithX:3 andY:4] autorelease]); + NSLog(@"%@", [[[RCCircle alloc] init] autorelease]); + NSLog(@"%@", [[[RCCircle alloc] initWithX:3] autorelease]); + NSLog(@"%@", [[[RCCircle alloc] initWithX:3 andY:4] autorelease]); + NSLog(@"%@", [[[RCCircle alloc] initWithX:3 andY:4 andRadius:7] autorelease]); + RCPoint *p = [[[RCPoint alloc] initWithX:1 andY:2] autorelease]; + NSLog(@"%@", [[[RCCircle alloc] initWithPoint:p] autorelease]); + NSLog(@"%@", [[[RCCircle alloc] initWithCenter:p andRadius:7] autorelease]); + NSLog(@"%d", p.x); // 1 + p.x = 8; + NSLog(@"%d", p.x); // 8 + + [pool release]; + return 0; +} diff --git a/Task/Polymorphism/OxygenBasic/polymorphism.oxy b/Task/Polymorphism/OxygenBasic/polymorphism.oxy new file mode 100644 index 0000000000..5e87ac607c --- /dev/null +++ b/Task/Polymorphism/OxygenBasic/polymorphism.oxy @@ -0,0 +1,56 @@ +type tpoint float xx,yy +type tcircle float xx,yy,rr + +'========== +class point +'========== +' +has tpoint +' +method constructor (float x=0,y=0){this<=x,y} +method destructor {} +method V() as point {return @this} +method V(tpoint*a) {this<=a.xx,a.yy} +method V(point *a) {this<=a.xx,a.yy} +method X() as float {return xx} +method Y() as float {return yy} +method X(float a) {xx=a} +method Y(float a) {yy=a} +method clear() {this<=.0,.0} +method show() as string {return "x=" xx ", y=" yy } +' +end class + + +'=========== +class circle +'=========== +' +has point +float rr +' +method constructor (float x=.0,y=.0,r=1.0){this<=x,y,r} +method V(tcircle*a) {this<=a.xx,a.yy,a.rr} +method V(circle *a) {this<=a.xx,a.yy,a.rr} +method R() as float {return rr} +method R(float a) {rr=a} +method clear() {this<=.0,.0,.0} +method show() as string {return "x=" xx ", y=" yy ", r=" rr } +' +end class + +'===== +'TESTS +'===== + +new circle ca (r=.5) +new circle cb (x=10,y=10) +new circle cc (10,10,0.5) + +cb.r="7.5" 'will convert a string value + +cb.y=20 + +print cb.show 'result x=10, y=20 ,r=7.5 + +del ca : del cb : del cc diff --git a/Task/Polymorphism/Oz/polymorphism.oz b/Task/Polymorphism/Oz/polymorphism.oz new file mode 100644 index 0000000000..ef9a4bbddf --- /dev/null +++ b/Task/Polymorphism/Oz/polymorphism.oz @@ -0,0 +1,38 @@ +class Point + feat + x + y + + meth init(x:X<=0.0 y:Y<=0.0) + self.x = X + self.y = Y + end + + meth print + {System.showInfo + "Point("# + "x:"#self.x# + ", y:"#self.y# + ")"} + end +end + +class Circle + feat + center + r + + meth init(center:C<={New Point init} r:R<=1.0) + self.center = C + self.r = R + end + + meth print + {System.showInfo + "Circle("# + "x:"#self.center.x# + ", y:"#self.center.y# + ", r:"#self.r# + ")"} + end +end diff --git a/Task/Polymorphism/PHP/polymorphism-1.php b/Task/Polymorphism/PHP/polymorphism-1.php new file mode 100644 index 0000000000..92fb098d9e --- /dev/null +++ b/Task/Polymorphism/PHP/polymorphism-1.php @@ -0,0 +1,71 @@ +class Point +{ + protected $_x; + + protected $_y; + + public function __construct() + { + switch( func_num_args() ) + { + case 1: + $point = func_get_arg( 0 ); + $this->setFromPoint( $point ); + break; + case 2: + $x = func_get_arg( 0 ); + $y = func_get_arg( 1 ); + $this->setX( $x ); + $this->setY( $y ); + break; + default: + throw new InvalidArgumentException( 'expecting one (Point) argument or two (numeric x and y) arguments' ); + } + } + + public function setFromPoint( Point $point ) + { + $this->setX( $point->getX() ); + $this->setY( $point->getY() ); + } + + public function getX() + { + return $this->_x; + } + + public function setX( $x ) + { + if( !is_numeric( $x ) ) + { + throw new InvalidArgumentException( 'expecting numeric value' ); + } + + $this->_x = (float) $x; + } + + public function getY() + { + return $this->_y; + } + + public function setY( $y ) + { + if( !is_numeric( $y ) ) + { + throw new InvalidArgumentException( 'expecting numeric value' ); + } + + $this->_y = (float) $y; + } + + public function output() + { + echo $this->__toString(); + } + + public function __toString() + { + return 'Point [x:' . $this->_x . ',y:' . $this->_y . ']'; + } +} diff --git a/Task/Polymorphism/PHP/polymorphism-2.php b/Task/Polymorphism/PHP/polymorphism-2.php new file mode 100644 index 0000000000..79be39a7e2 --- /dev/null +++ b/Task/Polymorphism/PHP/polymorphism-2.php @@ -0,0 +1,63 @@ +class Circle extends Point +{ + private $_radius; + + public function __construct() + { + switch( func_num_args() ) + { + case 1: + $circle = func_get_arg( 0 ); + $this->setFromCircle( $circle ); + break; + case 2: + $point = func_get_arg( 0 ); + $radius = func_get_arg( 1 ); + $this->setFromPoint( $point ); + $this->setRadius( $radius ); + break; + case 3: + $x = func_get_arg( 0 ); + $y = func_get_arg( 1 ); + $radius = func_get_arg( 2 ); + $this->setX( $x ); + $this->setY( $y ); + $this->setRadius( $radius ); + break; + default: + throw new InvalidArgumentException( 'expecting one (Circle) argument or two (Point and numeric radius) or three (numeric x, y and radius) arguments' ); + } + } + + public function setFromCircle( Circle $circle ) + { + $this->setX( $circle->getX() ); + $this->setY( $circle->getY() ); + $this->setRadius( $circle->getRadius() ); + } + + public function getPoint() + { + return new Point( $this->getX(), $this->getY() ); + } + + public function getRadius() + { + return $this->_radius; + } + + public function setRadius( $radius ) + { + if( !is_numeric( $radius ) ) + { + throw new InvalidArgumentException( 'expecting numeric value' ); + } + + $this->_radius = (float) $radius; + } + + public function __toString() + { + return 'Circle [' . $this->getPoint() . ',radius:' . $this->_radius . ']'; + } +} diff --git a/Task/Polymorphism/PHP/polymorphism-3.php b/Task/Polymorphism/PHP/polymorphism-3.php new file mode 100644 index 0000000000..9b0434677e --- /dev/null +++ b/Task/Polymorphism/PHP/polymorphism-3.php @@ -0,0 +1,12 @@ +$point = new Point( 1, 5 ); +$circle = new Circle( 1, 5, 6 ); + +$point->output(); +// or +echo $point; + +echo "\n"; + +$circle->output(); +// or +echo $circle; diff --git a/Task/Polymorphism/Perl-6/polymorphism-1.pl6 b/Task/Polymorphism/Perl-6/polymorphism-1.pl6 new file mode 100644 index 0000000000..7b3cc3e189 --- /dev/null +++ b/Task/Polymorphism/Perl-6/polymorphism-1.pl6 @@ -0,0 +1,18 @@ +class Point { + has Num $.x is rw = 0; + has Num $.y is rw = 0; + method Str { $.perl } +} + +class Circle { + has Point $.p is rw = Point.new; + has Num $.r is rw = 0; + method Str { $.perl } +} + +my $c = Circle.new(Point.new(x => 1, y => 2), r => 3); +say $c; +$c.p.x = (-10..10).pick; +$c.p.y = (-10..10).pick; +$c.r = (0..10).pick; +say $c; diff --git a/Task/Polymorphism/Perl-6/polymorphism-2.pl6 b/Task/Polymorphism/Perl-6/polymorphism-2.pl6 new file mode 100644 index 0000000000..e4986cc571 --- /dev/null +++ b/Task/Polymorphism/Perl-6/polymorphism-2.pl6 @@ -0,0 +1,2 @@ +multi print (Point $p) { $p.perl.print } +multi print (Circle $c) { $c.perl.print } diff --git a/Task/Polymorphism/Perl/polymorphism.pl b/Task/Polymorphism/Perl/polymorphism.pl new file mode 100644 index 0000000000..26e344ac2c --- /dev/null +++ b/Task/Polymorphism/Perl/polymorphism.pl @@ -0,0 +1,86 @@ +{ + package Point; + use Class::Spiffy -base; + use Clone qw(clone); + + sub _print { + my %self = %{shift()}; + while (my ($k,$v) = each %self) { + print "$k: $v\n"; + } + } + + sub members { + no strict; + grep { + 1 == length and defined *$_{CODE} + } keys %{*{__PACKAGE__."\::"}}; + } + + sub new { + my $class = shift; + my %param = @_; + $param{$_} = 0 for grep {!defined $param{$_}} members; + bless \%param, $class; + } + + sub copy_constructor { + clone shift; + } + + sub copy_assignment { + my $self = shift; + my $from = shift; + $self->$_($from->$_) for $from->members; + } + + field 'x'; + field 'y'; +} + +{ + package Circle; + use base qw(Point); + field 'r'; +} + +{ + package main; + $_->_print, print "\n" for ( + Point->new, + Point->new(x => 2), + Point->new(y => 3), + Point->new(x => 8, y => -5), + ); + my $p1 = Point->new(x => 8, y => -5); + + my $p2 = $p1->copy_constructor; + print "we are really different objects, not just references ". + "to the same instance\n" unless \$p1 eq \$p2; + + # accessors autogenerated + $p1->x(1); + $p1->y(2); + print $p1->x, "\n"; + print $p1->y, "\n"; + + $p2->copy_assignment($p1); + print $p2->x, "\n"; + print $p2->y, "\n"; + print "we now have the same values, but we are still ". + "different objects\n" unless \$p1 eq \$p2; + + $_->_print, print "\n" for ( + Circle->new, + Circle->new(x => 1), + Circle->new(y => 2), + Circle->new(r => 3), + Circle->new(x => 4, y => 5), + Circle->new(x => 6, r => 7), + Circle->new(y => 8, r => 9), + Circle->new(x => 1, y => 2, r => 3), + ); + + my $c = Circle->new(r => 4); + print $c->r, "\n"; # accessor autogenerated +} diff --git a/Task/Polymorphism/PicoLisp/polymorphism-1.l b/Task/Polymorphism/PicoLisp/polymorphism-1.l new file mode 100644 index 0000000000..4e7a01f287 --- /dev/null +++ b/Task/Polymorphism/PicoLisp/polymorphism-1.l @@ -0,0 +1,19 @@ +(class +Point) +# x y + +(dm T (X Y) + (=: x (or X 0)) + (=: y (or Y 0)) ) + +(dm print> () + (prinl "Point " (: x) "," (: y)) ) + +(class +Circle +Point) +# r + +(dm T (X Y R) + (super X Y) + (=: r (or R 0)) ) + +(dm print> () + (prinl "Circle " (: x) "," (: y) "," (: r)) ) diff --git a/Task/Polymorphism/PicoLisp/polymorphism-2.l b/Task/Polymorphism/PicoLisp/polymorphism-2.l new file mode 100644 index 0000000000..a890f93d88 --- /dev/null +++ b/Task/Polymorphism/PicoLisp/polymorphism-2.l @@ -0,0 +1,6 @@ +(setq + P (new '(+Point) 3 4) + C (new '(+Circle) 10 10 5) ) + +(print> P) +(print> C) diff --git a/Task/Polymorphism/Pop11/polymorphism-1.pop11 b/Task/Polymorphism/Pop11/polymorphism-1.pop11 new file mode 100644 index 0000000000..bc38e96a95 --- /dev/null +++ b/Task/Polymorphism/Pop11/polymorphism-1.pop11 @@ -0,0 +1,19 @@ +uses objectclass; +define :class Point; + slot x = 0; + slot y = 0; +enddefine; + +define :class Circle; + slot x = 0; + slot y = 0; + slot r = 1; +enddefine; + +define :method print(p : Point); + printf('Point(' >< x(p) >< ', ' >< y(p) >< ')\n'); +enddefine; + +define :method print(p : Circle); + printf('Circle(' >< x(p) >< ', ' >< y(p) >< ', ' >< r(p) >< ')\n'); +enddefine; diff --git a/Task/Polymorphism/Pop11/polymorphism-2.pop11 b/Task/Polymorphism/Pop11/polymorphism-2.pop11 new file mode 100644 index 0000000000..671b9cf613 --- /dev/null +++ b/Task/Polymorphism/Pop11/polymorphism-2.pop11 @@ -0,0 +1,6 @@ +;;; Initialize variables using default constructors +lvars instance1 = newPoint(); +lvars instance2 = newCircle(); +;;; Use print method +print(instance1); +print(instance2); diff --git a/Task/Polymorphism/PureBasic/polymorphism-1.purebasic b/Task/Polymorphism/PureBasic/polymorphism-1.purebasic new file mode 100644 index 0000000000..17224eb274 --- /dev/null +++ b/Task/Polymorphism/PureBasic/polymorphism-1.purebasic @@ -0,0 +1,59 @@ +Class MyPoint + + BeginProtect + x.i + y.i + EndProtect + + Public Method GetX() + MethodReturn This\X + EndMethod + + Public Method GetY() + MethodReturn This\Y + EndMethod + + Public Method SetX(n) + This\X=n + EndMethod + + Public Method SetY(n) + This\Y=n + EndMethod + + Public Method Print() + PrintN("Point") + EndMethod + + Public Method Init(x=0,y=0) + This\x=x + This\y=y + EndMethod +EndClass + +Class Circle Extends MyPoint + + Protect Radie.i + + Public Method Circel(x=0, y=0, r=0) + This\X = x + This\y = y + This\Radie=r + EndMethod + + Public Method GetRadie() + MethodReturn This\Radie + EndMethod + + Public Method SetRadie(n) + This\Radie = n + EndMethod + + Public Method Print() + PrintN("Circle: "+ _ + " X= "+Str(This\X)+ _ + " Y= "+Str(This\Y)+ _ + " R= "+Str(This\Radie)) + EndMethod + +EndClass diff --git a/Task/Polymorphism/PureBasic/polymorphism-2.purebasic b/Task/Polymorphism/PureBasic/polymorphism-2.purebasic new file mode 100644 index 0000000000..dc816b6b3d --- /dev/null +++ b/Task/Polymorphism/PureBasic/polymorphism-2.purebasic @@ -0,0 +1,9 @@ +*point.MyPoint = NewObject.MyPoint +*circle.Circle = NewObject.Circle + +If OpenConsole() + *point\Print() + *circle\SetX(3) + *circle\Print() + CloseConsole() +EndIf diff --git a/Task/Polymorphism/Python/polymorphism-1.py b/Task/Polymorphism/Python/polymorphism-1.py new file mode 100644 index 0000000000..34a597f25d --- /dev/null +++ b/Task/Polymorphism/Python/polymorphism-1.py @@ -0,0 +1,14 @@ +class Point(object): + def __init__(self, x=0.0, y=0.0): + self.x = x + self.y = y + def __repr__(self): + return '' % (id(self), self.x, self.y) + +class Circle(object): + def __init__(self, center=None, radius=1.0): + self.center = center or Point() + self.radius = radius + def __repr__(self): + return '' % ( + id(self), self.center.x, self.center.y, self.radius) diff --git a/Task/Polymorphism/Python/polymorphism-2.py b/Task/Polymorphism/Python/polymorphism-2.py new file mode 100644 index 0000000000..5926e9467e --- /dev/null +++ b/Task/Polymorphism/Python/polymorphism-2.py @@ -0,0 +1,14 @@ +class Point(object): + def __init__(self, x=0.0, y=0.0): + self.x = x + self.y = y + def __repr__(self): + return '' % (id(self), self.x, self.y) + +class Circle(Point): + def __init__(self, x=0.0, y=0.0, radius=1.0): + Point.__init__(self, x, y) + self.radius = radius + def __repr__(self): + return '' % ( + id(self), self.x, self.y, self.radius) diff --git a/Task/Polymorphism/Python/polymorphism-3.py b/Task/Polymorphism/Python/polymorphism-3.py new file mode 100644 index 0000000000..a6644fc394 --- /dev/null +++ b/Task/Polymorphism/Python/polymorphism-3.py @@ -0,0 +1,24 @@ +>>> from collections import namedtuple +>>> class Point(namedtuple('Point', 'x y')): + def __new__( _cls, x=0, y=0 ): + return super().__new__(_cls, x, y) + + +>>> class Circle(namedtuple('Circle', 'x y r')): + def __new__( _cls, x=0, y=0, r=0 ): + return super().__new__(_cls, x, y, r) + + +>>> Point(), Point(x=1), Point(y=2), Point(3, 4) +(Point(x=0, y=0), Point(x=1, y=0), Point(x=0, y=2), Point(x=3, y=4)) +>>> Circle(), Circle(r=2), Circle(1, 2, 3) +(Circle(x=0, y=0, r=0), Circle(x=0, y=0, r=2), Circle(x=1, y=2, r=3)) +>>> p = Point(1.25, 3.87) +>>> p +Point(x=1.25, y=3.87) +>>> p.x = 10.81 +Traceback (most recent call last): + File "", line 1, in + p.x = 10.81 +AttributeError: can't set attribute +>>> diff --git a/Task/Polymorphism/Python/polymorphism-4.py b/Task/Polymorphism/Python/polymorphism-4.py new file mode 100644 index 0000000000..b95a34c033 --- /dev/null +++ b/Task/Polymorphism/Python/polymorphism-4.py @@ -0,0 +1,7 @@ +>>> Point = namedtuple('Point', 'x y') +>>> Circle = namedtuple('Circle', 'x y r') +>>> Point(3, 4) +Point(x=3, y=4) +>>> Circle(x=1, y=2, r=3) +Circle(x=1, y=2, r=3) +>>> diff --git a/Task/Polymorphism/R/polymorphism.r b/Task/Polymorphism/R/polymorphism.r new file mode 100644 index 0000000000..b966d2159c --- /dev/null +++ b/Task/Polymorphism/R/polymorphism.r @@ -0,0 +1,39 @@ +setClass("point", + representation( + x="numeric", + y="numeric"), + prototype( + x=0, + y=0)) + +# Instantiate class with some arguments +p1 <- new("point", x=3) +# Access some values +p1@x # 3 +# Define a print method +setMethod("print", signature("point"), + function(x, ...) + { + cat("This is a point, with location, (", x@x, ",", x@y, ").\n") + }) +print(p1) + +# Define a circle class +setClass("circle", + representation( + centre="point", + r="numeric"), + prototype( + centre=new("point"), + r=1)) +circS4 <- new("circle", r=5.5) +# Access some values +circS4@r # 5.5 +circS4@centre@x # 0 +# Define a print method +setMethod("print", signature("circle"), + function(x, ...) + { + cat("This is a circle, with radius", x@r, "and centre (", x@centre@x, ",", x@centre@y, ").\n") + }) +print(circS4) diff --git a/Task/Polymorphism/Ruby/polymorphism.rb b/Task/Polymorphism/Ruby/polymorphism.rb new file mode 100644 index 0000000000..f15255194d --- /dev/null +++ b/Task/Polymorphism/Ruby/polymorphism.rb @@ -0,0 +1,22 @@ +class Point + attr_accessor :x,:y + def initialize(x=0,y=0) + self.x=x + self.y=y + end + def to_s + "Point at #{x},#{y}" + end +end + +class Circle + attr_accessor :x,:y,:r + def initialize(x=0,y=0,r=0) + self.x=x + self.y=y + self.r=r + end + def to_s + "Circle at #{x},#{y} with radius #{r}" + end +end diff --git a/Task/Polymorphism/SIMPOL/polymorphism.simpol b/Task/Polymorphism/SIMPOL/polymorphism.simpol new file mode 100644 index 0000000000..3167746ba0 --- /dev/null +++ b/Task/Polymorphism/SIMPOL/polymorphism.simpol @@ -0,0 +1,73 @@ +type mypoint(mypoint) embed export + embed + integer x + integer y + + reference + function copy + function print +end type + + +function mypoint.new(mypoint me, integer x=0, integer y=0) + me.x = x + me.y = y +end function me + + +function mypoint.copy(mypoint me) + mypoint p + + p =@ mypoint.new(me.x, me.y) +end function p + + +function mypoint.print(mypoint me) +end function "mypoint" + + +type circle(mypoint) embed export + reference + mypoint midpoint resolve + + embed + integer radius + + reference + function copy + function print +end type + + +function circle.new(circle me, integer x=0, integer y=0, integer radius=0, mypoint midpoint) + if midpoint =@= .nul + me.midpoint =@ mypoint.new(x, y) + else + me.x = midpoint.x + me.y = midpoint.y + end if + + me.radius = radius +end function me + + +function circle.copy(circle me) + circle c + + c =@ circle.new(radius=me.radius, midpoint=me.midpoint) +end function c + + +function circle.print(circle me) +end function "circle" + + +function main() + type(mypoint) p, c + string result + + p =@ mypoint.new() + c =@ circle.new() + + result = p.print() + "{d}{a}" + c.print() + "{d}{a}" +end function result diff --git a/Task/Polymorphism/Smalltalk/polymorphism.st b/Task/Polymorphism/Smalltalk/polymorphism.st new file mode 100644 index 0000000000..c11de31883 --- /dev/null +++ b/Task/Polymorphism/Smalltalk/polymorphism.st @@ -0,0 +1,75 @@ +!Object subclass: #Point + instanceVariableNames: 'x y' + classVariableNames: '' + poolDictionaries: '' + category: 'polymorphism' ! + +!Point class methodsFor: 'instance creation'! +new + ^self newBasic x := 0; y := 0 ! ! + +!Point class methodsFor: 'instance creation'! +x: x y: y + ^self newBasic x := x; y := y ! ! + +!Point methodsFor: 'member access'! +x + ^x ! ! + +!Point methodsFor: 'member access'! +y + ^y ! ! + +!Point methodsFor: 'member access'! +x: x + ^self x := x ! ! + +!Point methodsFor: 'member access'! +y: y + ^self y := y ! ! + +!Point methodsFor: 'member access'! +x: x y: y + ^self x := x; y := y ! ! + +!Point methodsFor: 'polymorphism test'! +print + Transcript show: x; space; show: y ! ! + +!Object subclass: #Circle + instanceVariableNames: 'center r' + classVariableNames: '' + poolDictionaries: '' + category: 'polymorphism' ! + +!Circle class methodsFor: 'instance creation'! +new + ^self newBasic center := Point new; r := 0 ! ! + +!Circle class methodsFor: 'instance creation'! +radius: radius + ^self newBasic center := Point new; r := radius ! ! + +!Circle class methodsFor: 'instance creation'! +at: point radius: r + ^self newBasic center := point; r := r ! ! + +!Circle methodsFor: 'member access'! +center + ^center ! ! + +!Circle methodsFor: 'member access'! +x: x y: y + ^self center x: x y: y ! ! + +!Circle methodsFor: 'member access'! +radius + ^r ! ! + +!Circle methodsFor: 'member access'! +radius: radius + ^self r := radius ! ! + +!Circle methodsFor: 'polymorphism test'! +print + Transcript show: center; space; show: radius ! ! diff --git a/Task/Polymorphism/Tcl/polymorphism.tcl b/Task/Polymorphism/Tcl/polymorphism.tcl new file mode 100644 index 0000000000..3afb6906a5 --- /dev/null +++ b/Task/Polymorphism/Tcl/polymorphism.tcl @@ -0,0 +1,53 @@ +package require TclOO +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 print {} { + puts "Point($X,$Y)" + } + method copy {} { + set copy [oo::copy [self]] + $copy x $X + $copy y $Y + return $copy + } +} +oo::class create Circle { + superclass Point + variable R + constructor {x y radius} { + next $x $y + set R $radius + } + method radius args { + set R {*}$args + } + method print {} { + puts "Circle([my x],[my y],$R)" + } + method copy {} { + set copy [next] + $copy radius $R + return $copy + } +} +# No destructors: unneeded by these classes + +set p [Point new 1.0 2.0] +set c [Circle new 3.0 4.0 5.0] +set cCopy [$c copy] +puts "$p is at ([$p x],[$p y])" +$c radius 1.5 +set objects [list $p $c $cCopy] +foreach o $objects { + $o print +} diff --git a/Task/Polynomial-long-division/0DESCRIPTION b/Task/Polynomial-long-division/0DESCRIPTION new file mode 100644 index 0000000000..765b9809e7 --- /dev/null +++ b/Task/Polynomial-long-division/0DESCRIPTION @@ -0,0 +1,93 @@ +{{Wikipedia}} +:In algebra, [[wp:Polynomial long division|polynomial long division]] is an algorithm for dividing a polynomial by another polynomial of the same or lower degree. + +Let us suppose a polynomial is represented by a vector, x (i.e., an ordered collection of [[wp:Coefficient|coefficients]]) so that the ith element keeps the coefficient of x^i, and the multiplication by a monomial is a ''shift'' of the vector's elements "towards right" (injecting zeros from left) followed by a multiplication of each element by the coefficient of the monomial. + +Then a pseudocode for the polynomial long division using the conventions described above could be: + + degree('''P'''): + '''return''' the index of the last non-zero element of '''P'''; + if all elements are 0, return -∞ + + polynomial_long_division('''N''', '''D''') ''returns'' ('''q''', '''r'''): + // '''N''', '''D''', '''q''', '''r''' are vectors + '''if''' degree('''D''') < 0 '''then''' ''error'' + '''if''' degree('''N''') ≥ degree('''D''') '''then''' + '''q''' ← '''0''' + '''while''' degree('''N''') ≥ degree('''D''') + '''d''' ← '''D''' ''shifted right'' ''by'' (degree('''N''') - degree('''D''')) + '''q'''(degree('''N''') - degree('''D''')) ← '''N'''(degree('''N''')) / '''d'''(degree('''d''')) + // by construction, degree('''d''') = degree('''N''') of course + '''d''' ← '''d''' * '''q'''(degree('''N''') - degree('''D''')) + '''N''' ← '''N''' - '''d''' + '''endwhile''' + '''r''' ← '''N''' + '''else''' + '''q''' ← '''0''' + '''r''' ← '''N''' + '''endif''' + '''return''' ('''q''', '''r''') + +'''Note''': vector * scalar multiplies each element of the vector by the scalar; vectorA - vectorB subtracts each element of the vectorB from the element of the vectorA with "the same index". The vectors in the pseudocode are zero-based. + +* Error handling (for allocations or for wrong inputs) is not mandatory. +* Conventions can be different; in particular, note that if the first coefficient in the vector is the highest power of x for the polynomial represented by the vector, then the algorithm becomes simpler. + +'''Example for clarification''' +
+This example is from Wikipedia, but changed to show how the given pseudocode works. + + 0 1 2 3 + ---------------------- + N: -42 0 -12 1 degree = 3 + D: -3 1 0 0 degree = 1 + + d(N) - d(D) = 2, so let's shift D towards right by 2: + + N: -42 0 -12 1 + d: 0 0 -3 1 + + N(3)/d(3) = 1, so d is unchanged. Now remember that "shifting by 2" + is like multiplying by x2, and the final multiplication + (here by 1) is the coefficient of this monomial. Let's store this + into q: + 0 1 2 + --------------- + q: 0 0 1 + + now compute N - d, and let it be the "new" N, and let's loop + + N: -42 0 -9 0 degree = 2 + D: -3 1 0 0 degree = 1 + + d(N) - d(D) = 1, right shift D by 1 and let it be d + + N: -42 0 -9 0 + d: 0 -3 1 0 * -9/1 = -9 + + q: 0 -9 1 + + d: 0 27 -9 0 + + N ← N - d + + N: -42 -27 0 0 degree = 1 + D: -3 1 0 0 degree = 1 + + looping again... d(N)-d(D)=0, so no shift is needed; we + multiply D by -27 (= -27/1) storing the result in d, then + + q: -27 -9 1 + + and + + N: -42 -27 0 0 - + d: 81 -27 0 0 = + N: -123 0 0 0 (last N) + + d(N) < d(D), so now r ← N, and the result is: + + 0 1 2 + ------------- + q: -27 -9 1 → x2 - 9x - 27 + r: -123 0 0 → -123 diff --git a/Task/Polynomial-long-division/1META.yaml b/Task/Polynomial-long-division/1META.yaml new file mode 100644 index 0000000000..f407ff9d83 --- /dev/null +++ b/Task/Polynomial-long-division/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Classic CS problems and programs diff --git a/Task/Polynomial-long-division/Ada/polynomial-long-division.ada b/Task/Polynomial-long-division/Ada/polynomial-long-division.ada new file mode 100644 index 0000000000..55ee7930be --- /dev/null +++ b/Task/Polynomial-long-division/Ada/polynomial-long-division.ada @@ -0,0 +1,110 @@ +with Ada.Text_IO; use Ada.Text_IO; + +procedure Long_Division is + package Int_IO is new Ada.Text_IO.Integer_IO (Integer); + use Int_IO; + + type Degrees is range -1 .. Integer'Last; + subtype Valid_Degrees is Degrees range 0 .. Degrees'Last; + type Polynom is array (Valid_Degrees range <>) of Integer; + + function Degree (P : Polynom) return Degrees is + begin + for I in reverse P'Range loop + if P (I) /= 0 then + return I; + end if; + end loop; + return -1; + end Degree; + + function Shift_Right (P : Polynom; D : Valid_Degrees) return Polynom is + Result : Polynom (0 .. P'Last + D) := (others => 0); + begin + Result (Result'Last - P'Length + 1 .. Result'Last) := P; + return Result; + end Shift_Right; + + function "*" (Left : Polynom; Right : Integer) return Polynom is + Result : Polynom (Left'Range); + begin + for I in Result'Range loop + Result (I) := Left (I) * Right; + end loop; + return Result; + end "*"; + + function "-" (Left, Right : Polynom) return Polynom is + Result : Polynom (Left'Range); + begin + for I in Result'Range loop + if I in Right'Range then + Result (I) := Left (I) - Right (I); + else + Result (I) := Left (I); + end if; + end loop; + return Result; + end "-"; + + procedure Poly_Long_Division (Num, Denom : Polynom; Q, R : out Polynom) is + N : Polynom := Num; + D : Polynom := Denom; + begin + if Degree (D) < 0 then + raise Constraint_Error; + end if; + Q := (others => 0); + while Degree (N) >= Degree (D) loop + declare + T : Polynom := Shift_Right (D, Degree (N) - Degree (D)); + begin + Q (Degree (N) - Degree (D)) := N (Degree (N)) / T (Degree (T)); + T := T * Q (Degree (N) - Degree (D)); + N := N - T; + end; + end loop; + R := N; + end Poly_Long_Division; + + procedure Output (P : Polynom) is + First : Boolean := True; + begin + for I in reverse P'Range loop + if P (I) /= 0 then + if First then + First := False; + else + Put (" + "); + end if; + if I > 0 then + if P (I) /= 1 then + Put (P (I), 0); + Put ("*"); + end if; + Put ("x"); + if I > 1 then + Put ("^"); + Put (Integer (I), 0); + end if; + elsif P (I) /= 0 then + Put (P (I), 0); + end if; + end if; + end loop; + New_Line; + end Output; + + Test_N : constant Polynom := (0 => -42, 1 => 0, 2 => -12, 3 => 1); + Test_D : constant Polynom := (0 => -3, 1 => 1); + Test_Q : Polynom (Test_N'Range); + Test_R : Polynom (Test_N'Range); +begin + Poly_Long_Division (Test_N, Test_D, Test_Q, Test_R); + Put_Line ("Dividing Polynoms:"); + Put ("N: "); Output (Test_N); + Put ("D: "); Output (Test_D); + Put_Line ("-------------------------"); + Put ("Q: "); Output (Test_Q); + Put ("R: "); Output (Test_R); +end Long_Division; diff --git a/Task/Polynomial-long-division/BBC-BASIC/polynomial-long-division.bbc b/Task/Polynomial-long-division/BBC-BASIC/polynomial-long-division.bbc new file mode 100644 index 0000000000..0b319dcd9f --- /dev/null +++ b/Task/Polynomial-long-division/BBC-BASIC/polynomial-long-division.bbc @@ -0,0 +1,44 @@ + DIM N%(3) : N%() = -42, 0, -12, 1 + DIM D%(3) : D%() = -3, 1, 0, 0 + DIM q%(3), r%(3) + PROC_poly_long_div(N%(), D%(), q%(), r%()) + PRINT "Quotient = "; FNcoeff(q%(2)) "x^2" FNcoeff(q%(1)) "x" FNcoeff(q%(0)) + PRINT "Remainder = " ; r%(0) + END + + DEF PROC_poly_long_div(N%(), D%(), q%(), r%()) + LOCAL d%(), i%, s% + DIM d%(DIM(N%(),1)) + s% = FNdegree(N%()) - FNdegree(D%()) + IF s% >= 0 THEN + q%() = 0 + WHILE s% >= 0 + FOR i% = 0 TO DIM(d%(),1) - s% + d%(i%+s%) = D%(i%) + NEXT + q%(s%) = N%(FNdegree(N%())) DIV d%(FNdegree(d%())) + d%() = d%() * q%(s%) + N%() -= d%() + s% = FNdegree(N%()) - FNdegree(D%()) + ENDWHILE + r%() = N%() + ELSE + q%() = 0 + r%() = N%() + ENDIF + ENDPROC + + DEF FNdegree(a%()) + LOCAL i% + i% = DIM(a%(),1) + WHILE a%(i%)=0 + i% -= 1 + IF i%<0 EXIT WHILE + ENDWHILE + = i% + + DEF FNcoeff(n%) + IF n%=0 THEN = "" + IF n%<0 THEN = " - " + STR$(-n%) + IF n%=1 THEN = " + " + = " + " + STR$(n%) diff --git a/Task/Polynomial-long-division/C++/polynomial-long-division-1.cpp b/Task/Polynomial-long-division/C++/polynomial-long-division-1.cpp new file mode 100644 index 0000000000..885c01175c --- /dev/null +++ b/Task/Polynomial-long-division/C++/polynomial-long-division-1.cpp @@ -0,0 +1,16 @@ +#include +#include + +using namespace std; + +// does: prints all members of vector +// input: c - ASCII char with the name of the vector +// d - degree of vector +// A - pointer to vector +void Print(char c, int d, double* A) { + int i; + + for (i=0; i < d+1; i++) + cout << c << "[" << i << "]= " << A[i] << endl; + cout << "Degree of " << c << ": " << d << endl << endl; +} diff --git a/Task/Polynomial-long-division/C++/polynomial-long-division-2.cpp b/Task/Polynomial-long-division/C++/polynomial-long-division-2.cpp new file mode 100644 index 0000000000..2718707e56 --- /dev/null +++ b/Task/Polynomial-long-division/C++/polynomial-long-division-2.cpp @@ -0,0 +1,106 @@ +int main() { + double *N,*D,*d,*q,*r; // vectors - N / D = q N % D = r + int dN, dD, dd, dq, dr; // degrees of vectors + int i; // iterators + +// setting the degrees of vectors + cout << "Enter the degree of N:"; + cin >> dN; + cout << "Enter the degree of D:"; + cin >> dD; + dq = dN-dD; + dr = dN-dD; + + +// allocation and initialization of vectors + N=new double [dN+1]; + cout << "Enter the coefficients of N:"<= dD ) { + while(dN >= dD) { +// d equals D shifted right + for( i = 0 ; i < dN + 1 ; i++ ) { + d[i] = 0; + } + for( i = 0 ; i < dD + 1 ; i++ ) { + d[i+dN-dD] = D[i]; + } + dd = dN; + + Print( 'd', dd, d ); + +// calculating one element of q + q[dN-dD] = N[dN]/d[dd]; + + Print( 'q', dq, q ); + +// d equals d * q[dN-dD] + for( i = 0 ; i < dq + 1 ; i++ ) { + d[i] = d[i] * q[dN-dD]; + } + + Print( 'd', dd, d ); + +// N equals N - d + for( i = 0 ; i < dN + 1 ; i++ ) { + N[i] = N[i] - d[i]; + } + dN--; + + Print( 'N', dN, N ); + cout << "-----------------------" << endl << endl; + + } + + } + +// r equals N + for( i = 0 ; i < dN + 1 ; i++ ) { + r[i] = N[i]; + } + dr = dN; + + cout << "=========================" << endl << endl; + cout << "-- Result --" << endl << endl; + + Print( 'q', dq, q ); + Print( 'r', dr, r ); + +// dealocation + delete [] N; + delete [] D; + delete [] d; + delete [] q; + delete [] r; +} diff --git a/Task/Polynomial-long-division/C/polynomial-long-division-1.c b/Task/Polynomial-long-division/C/polynomial-long-division-1.c new file mode 100644 index 0000000000..9ecd573fae --- /dev/null +++ b/Task/Polynomial-long-division/C/polynomial-long-division-1.c @@ -0,0 +1,107 @@ +#include +#include +#include +#include +#include + +#define MAX(A,B) (((A)>(B))?(A):(B)) + +void reoshift(gsl_vector *v, int h) +{ + if ( h > 0 ) { + gsl_vector *temp = gsl_vector_alloc(v->size); + gsl_vector_view p = gsl_vector_subvector(v, 0, v->size - h); + gsl_vector_view p1 = gsl_vector_subvector(temp, h, v->size - h); + gsl_vector_memcpy(&p1.vector, &p.vector); + p = gsl_vector_subvector(temp, 0, h); + gsl_vector_set_zero(&p.vector); + gsl_vector_memcpy(v, temp); + gsl_vector_free(temp); + } +} + +gsl_vector *poly_long_div(gsl_vector *n, gsl_vector *d, gsl_vector **r) +{ + gsl_vector *nt = NULL, *dt = NULL, *rt = NULL, *d2 = NULL, *q = NULL; + int gn, gt, gd; + + if ( (n->size >= d->size) && (d->size > 0) && (n->size > 0) ) { + nt = gsl_vector_alloc(n->size); assert(nt != NULL); + dt = gsl_vector_alloc(n->size); assert(dt != NULL); + rt = gsl_vector_alloc(n->size); assert(rt != NULL); + d2 = gsl_vector_alloc(n->size); assert(d2 != NULL); + gsl_vector_memcpy(nt, n); + gsl_vector_set_zero(dt); gsl_vector_set_zero(rt); + gsl_vector_view p = gsl_vector_subvector(dt, 0, d->size); + gsl_vector_memcpy(&p.vector, d); + gsl_vector_memcpy(d2, dt); + gn = n->size - 1; + gd = d->size - 1; + gt = 0; + + while( gsl_vector_get(d, gd) == 0 ) gd--; + + while ( gn >= gd ) { + reoshift(dt, gn-gd); + double v = gsl_vector_get(nt, gn)/gsl_vector_get(dt, gn); + gsl_vector_set(rt, gn-gd, v); + gsl_vector_scale(dt, v); + gsl_vector_sub(nt, dt); + gt = MAX(gt, gn-gd); + while( (gn>=0) && (gsl_vector_get(nt, gn) == 0.0) ) gn--; + gsl_vector_memcpy(dt, d2); + } + + q = gsl_vector_alloc(gt+1); assert(q != NULL); + p = gsl_vector_subvector(rt, 0, gt+1); + gsl_vector_memcpy(q, &p.vector); + if ( r != NULL ) { + if ( (gn+1) > 0 ) { + *r = gsl_vector_alloc(gn+1); assert( *r != NULL ); + p = gsl_vector_subvector(nt, 0, gn+1); + gsl_vector_memcpy(*r, &p.vector); + } else { + *r = gsl_vector_alloc(1); assert( *r != NULL ); + gsl_vector_set_zero(*r); + } + } + gsl_vector_free(nt); gsl_vector_free(dt); + gsl_vector_free(rt); gsl_vector_free(d2); + return q; + } else { + q = gsl_vector_alloc(1); assert( q != NULL ); + gsl_vector_set_zero(q); + if ( r != NULL ) { + *r = gsl_vector_alloc(n->size); assert( *r != NULL ); + gsl_vector_memcpy(*r, n); + } + return q; + } +} + +void poly_print(gsl_vector *p) +{ + int i; + for(i=p->size-1; i >= 0; i--) { + if ( i > 0 ) + printf("%lfx^%d + ", + gsl_vector_get(p, i), i); + else + printf("%lf\n", gsl_vector_get(p, i)); + } +} + +gsl_vector *create_poly(int d, ...) +{ + va_list al; + int i; + gsl_vector *r = NULL; + + va_start(al, d); + r = gsl_vector_alloc(d); assert( r != NULL ); + + for(i=0; i < d; i++) + gsl_vector_set(r, i, va_arg(al, double)); + + return r; +} diff --git a/Task/Polynomial-long-division/C/polynomial-long-division-2.c b/Task/Polynomial-long-division/C/polynomial-long-division-2.c new file mode 100644 index 0000000000..59e86174b2 --- /dev/null +++ b/Task/Polynomial-long-division/C/polynomial-long-division-2.c @@ -0,0 +1,23 @@ +int main() +{ + int i; + gsl_vector *q, *r; + gsl_vector *nv, *dv; + + //nv = create_poly(4, -42., 0., -12., 1.); + //dv = create_poly(2, -3., 1.); + //nv = create_poly(3, 2., 3., 1.); + //dv = create_poly(2, 1., 1.); + nv = create_poly(4, -42., 0., -12., 1.); + dv = create_poly(3, -3., 1., 1.); + + q = poly_long_div(nv, dv, &r); + + poly_print(q); + poly_print(r); + + gsl_vector_free(q); + gsl_vector_free(r); + + return 0; +} diff --git a/Task/Polynomial-long-division/C/polynomial-long-division-3.c b/Task/Polynomial-long-division/C/polynomial-long-division-3.c new file mode 100644 index 0000000000..fffd21f3a7 --- /dev/null +++ b/Task/Polynomial-long-division/C/polynomial-long-division-3.c @@ -0,0 +1,104 @@ +#include +#include +#include +#include + +typedef struct { + int power; + double * coef; +} poly_t, *poly; + +#define E(x, i) (x)->coef[i] + +/* passing in negative power to have a zeroed poly */ +poly p_new(int power, ...) +{ + int i, zeroed = 0; + va_list ap; + + if (power < 0) { + power = -power; + zeroed = 1; + } + + poly p = malloc(sizeof(poly_t)); + p->power = power; + p->coef = malloc(sizeof(double) * ++power); + + if (zeroed) + for (i = 0; i < power; i++) p->coef[i] = 0; + else { + va_start(ap, power); + for (i = 0; i < power; i++) + E(p, i) = va_arg(ap, double); + va_end(ap); + } + + return p; +} + +void p_del(poly p) +{ + free(p->coef); + free(p); +} + +void p_print(poly p) +{ + int i; + for (i = 0; i <= p->power; i++) + printf("%g ", E(p, i)); + printf("\n"); +} + +poly p_copy(poly p) +{ + poly q = p_new(-p->power); + memcpy(q->coef, p->coef, sizeof(double) * (1 + p->power)); + return q; +} + +/* p: poly; d: divisor; r: remainder; returns quotient */ +poly p_div(poly p, poly d, poly* r) +{ + poly q; + int i, j; + int power = p->power - d->power; + double ratio; + + if (power < 0) return 0; + + q = p_new(-power); + *r= p_copy(p); + + for (i = p->power; i >= d->power; i--) { + E(q, i - d->power) = ratio = E(*r, i) / E(d, d->power); + E(*r ,i) = 0; + + for (j = 0; j < d->power; j++) + E(*r, i - d->power + j) -= E(d, j) * ratio; + } + while (! E(*r, --(*r)->power)); + + return q; +} + +int main() +{ + poly p = p_new(3, 1., 2., 3., 4.); + poly d = p_new(2, 1., 2., 1.); + poly r; + poly q = p_div(p, d, &r); + + printf("poly: "); p_print(p); + printf("div: "); p_print(d); + printf("quot: "); p_print(q); + printf("rem: "); p_print(r); + + p_del(p); + p_del(q); + p_del(r); + p_del(d); + + return 0; +} diff --git a/Task/Polynomial-long-division/Common-Lisp/polynomial-long-division-1.lisp b/Task/Polynomial-long-division/Common-Lisp/polynomial-long-division-1.lisp new file mode 100644 index 0000000000..785a23f578 --- /dev/null +++ b/Task/Polynomial-long-division/Common-Lisp/polynomial-long-division-1.lisp @@ -0,0 +1,41 @@ +(defun add (p1 p2) + (do ((sum '())) ((and (endp p1) (endp p2)) (nreverse sum)) + (let ((pd1 (if (endp p1) -1 (caar p1))) + (pd2 (if (endp p2) -1 (caar p2)))) + (multiple-value-bind (c1 c2) + (cond + ((> pd1 pd2) (values (cdr (pop p1)) 0)) + ((< pd1 pd2) (values 0 (cdr (pop p2)))) + (t (values (cdr (pop p1)) (cdr (pop p2))))) + (let ((csum (+ c1 c2))) + (unless (zerop csum) + (setf sum (acons (max pd1 pd2) csum sum)))))))) + +(defun multiply (p1 p2) + (flet ((*p2 (p) + (destructuring-bind (d . c) p + (loop for (pd . pc) in p2 + collecting (cons (+ d pd) (* c pc)))))) + (reduce 'add (mapcar #'*p2 p1) :initial-value '()))) + +(defun subtract (p1 p2) + (add p1 (multiply '((0 . -1)) p2))) + +(defun divide (dividend divisor &aux (sum '())) + (assert (not (endp divisor)) (divisor) + 'division-by-zero + :operation 'divide + :operands (list dividend divisor)) + (flet ((floor1 (dividend divisor) + (if (endp dividend) (values '() ()) + (destructuring-bind (d1 . c1) (first dividend) + (destructuring-bind (d2 . c2) (first divisor) + (if (> d2 d1) (values '() dividend) + (let* ((quot (list (cons (- d1 d2) (/ c1 c2)))) + (rem (subtract dividend (multiply divisor quot)))) + (values quot rem)))))))) + (loop (multiple-value-bind (quotient remainder) + (floor1 dividend divisor) + (if (endp quotient) (return (values sum remainder)) + (setf dividend remainder + sum (add quotient sum))))))) diff --git a/Task/Polynomial-long-division/Common-Lisp/polynomial-long-division-2.lisp b/Task/Polynomial-long-division/Common-Lisp/polynomial-long-division-2.lisp new file mode 100644 index 0000000000..ce3dabb120 --- /dev/null +++ b/Task/Polynomial-long-division/Common-Lisp/polynomial-long-division-2.lisp @@ -0,0 +1,4 @@ +> (divide '((3 . 1) (2 . -12) (0 . -42)) ; x^3 - 12x^2 - 42 + '((1 . 1) (0 . -3))) ; x - 3 +((2 . 1) (1 . -9) (0 . -27)) ; x^2 - 9x - 27 +((0 . -123)) ; -123 diff --git a/Task/Polynomial-long-division/D/polynomial-long-division.d b/Task/Polynomial-long-division/D/polynomial-long-division.d new file mode 100644 index 0000000000..26c8c98348 --- /dev/null +++ b/Task/Polynomial-long-division/D/polynomial-long-division.d @@ -0,0 +1,38 @@ +import std.stdio, std.range, std.algorithm, std.typecons; + +Tuple!(double[],double[]) polyDiv(in double[] inN, in double[] inD) +/*pure nothrow*/ { + // code smell: a function that does two things + static int trimAndDegree(T)(ref T[] poly) /*nothrow pure*/ { + poly.length -= poly.retro().countUntil!q{a != 0}(); + return (cast(int)poly.length) - 1; + } + + double[] N = inN.dup; + const(double)[] D = inD; + const dD = trimAndDegree(D); + auto dN = trimAndDegree(N); + double[] q, r; + if (dD < 0) + throw new Exception("ZeroDivisionError"); + if (dN >= dD) { + q = repeat(0.0).take(dN).array(); + while (dN >= dD) { + auto d = repeat(0.0).take(dN - dD).array() ~ D; + const mult = q[dN - dD] = N[$ - 1] / d[$ - 1]; + d[] *= mult; + N[] -= d[]; + dN = trimAndDegree(N); + } + } else { + q = [0.0]; + } + r = N; + return tuple(q, r); +} + +void main() { + immutable N = [-42.0, 0.0, -12.0, 1.0]; + immutable D = [-3.0, 1.0, 0.0, 0.0]; + writefln("%s / %s = %s remainder %s", N, D, polyDiv(N,D).tupleof); +} diff --git a/Task/Polynomial-long-division/E/polynomial-long-division.e b/Task/Polynomial-long-division/E/polynomial-long-division.e new file mode 100644 index 0000000000..443a47afcd --- /dev/null +++ b/Task/Polynomial-long-division/E/polynomial-long-division.e @@ -0,0 +1,7 @@ +def n := makePolynomial([-42, 0, -12, 1]) +def d := makePolynomial([-3, 1]) +println("Numerator: ", n) +println("Denominator: ", d) +def [q, r] := n.quotRem(d, stdout) +println("Quotient: ", q) +println("Remainder: ", r) diff --git a/Task/Polynomial-long-division/Fortran/polynomial-long-division-1.f b/Task/Polynomial-long-division/Fortran/polynomial-long-division-1.f new file mode 100644 index 0000000000..115c780c54 --- /dev/null +++ b/Task/Polynomial-long-division/Fortran/polynomial-long-division-1.f @@ -0,0 +1,80 @@ +module Polynom + implicit none + +contains + + subroutine poly_long_div(n, d, q, r) + real, dimension(:), intent(in) :: n, d + real, dimension(:), intent(out), allocatable :: q + real, dimension(:), intent(out), allocatable, optional :: r + + real, dimension(:), allocatable :: nt, dt, rt + integer :: gn, gt, gd + + if ( (size(n) >= size(d)) .and. (size(d) > 0) .and. (size(n) > 0) ) then + allocate(nt(size(n)), dt(size(n)), rt(size(n))) + + nt = n + dt = 0 + dt(1:size(d)) = d + rt = 0 + gn = size(n)-1 + gd = size(d)-1 + gt = 0 + + do while ( d(gd+1) == 0 ) + gd = gd - 1 + end do + + do while( gn >= gd ) + dt = eoshift(dt, -(gn-gd)) + rt(gn-gd+1) = nt(gn+1) / dt(gn+1) + nt = nt - dt * rt(gn-gd+1) + gt = max(gt, gn-gd) + do + gn = gn - 1 + if ( nt(gn+1) /= 0 ) exit + end do + dt = 0 + dt(1:size(d)) = d + end do + + allocate(q(gt+1)) + q = rt(1:gt+1) + if ( present(r) ) then + if ( (gn+1) > 0 ) then + allocate(r(gn+1)) + r = nt(1:gn+1) + else + allocate(r(1)) + r = 0.0 + end if + end if + deallocate(nt, dt, rt) + else + allocate(q(1)) + q = 0 + if ( present(r) ) then + allocate(r(size(n))) + r = n + end if + end if + + end subroutine poly_long_div + + subroutine poly_print(p) + real, dimension(:), intent(in) :: p + + integer :: i + + do i = size(p), 1, -1 + if ( i > 1 ) then + write(*, '(F0.2,"x^",I0," + ")', advance="no") p(i), i-1 + else + write(*, '(F0.2)') p(i) + end if + end do + + end subroutine poly_print + +end module Polynom diff --git a/Task/Polynomial-long-division/Fortran/polynomial-long-division-2.f b/Task/Polynomial-long-division/Fortran/polynomial-long-division-2.f new file mode 100644 index 0000000000..3a28f0982c --- /dev/null +++ b/Task/Polynomial-long-division/Fortran/polynomial-long-division-2.f @@ -0,0 +1,18 @@ +program PolyDivTest + use Polynom + implicit none + + real, dimension(:), allocatable :: q + real, dimension(:), allocatable :: r + + !! three tests from Wikipedia, plus an extra + !call poly_long_div( (/ -3., 1. /), (/ -42., 0.0, -12., 1. /), q, r) + call poly_long_div( (/ -42., 0.0, -12., 1. /), (/ -3., 1. /), q, r) + !call poly_long_div( (/ -42., 0.0, -12., 1. /), (/ -3., 1., 1. /), q, r) + !call poly_long_div( (/ 2., 3., 1. /), (/ 1., 1. /), q, r) + + call poly_print(q) + call poly_print(r) + deallocate(q, r) + +end program PolyDivTest diff --git a/Task/Polynomial-long-division/GAP/polynomial-long-division.gap b/Task/Polynomial-long-division/GAP/polynomial-long-division.gap new file mode 100644 index 0000000000..d8e9727af1 --- /dev/null +++ b/Task/Polynomial-long-division/GAP/polynomial-long-division.gap @@ -0,0 +1,5 @@ +x := Indeterminate(Rationals, "x"); +p := x^11 + 3*x^8 + 7*x^2 + 3; +q := x^7 + 5*x^3 + 1; +QuotientRemainder(p, q); +# [ x^4+3*x-5, -16*x^4+25*x^3+7*x^2-3*x+8 ] diff --git a/Task/Polynomial-long-division/Go/polynomial-long-division.go b/Task/Polynomial-long-division/Go/polynomial-long-division.go new file mode 100644 index 0000000000..9f8dd4e2c7 --- /dev/null +++ b/Task/Polynomial-long-division/Go/polynomial-long-division.go @@ -0,0 +1,46 @@ +package main + +import "fmt" + +func main() { + n := []float64{-42, 0, -12, 1} + d := []float64{-3, 1} + fmt.Println("N:", n) + fmt.Println("D:", d) + q, r, ok := pld(n, d) + if ok { + fmt.Println("Q:", q) + fmt.Println("R:", r) + } else { + fmt.Println("error") + } +} + +func degree(p []float64) int { + for d := len(p) - 1; d >= 0; d-- { + if p[d] != 0 { + return d + } + } + return -1 +} + +func pld(nn, dd []float64) (q, r []float64, ok bool) { + if degree(dd) < 0 { + return + } + nn = append(r, nn...) + if degree(nn) >= degree(dd) { + q = make([]float64, degree(nn)-degree(dd)+1) + for degree(nn) >= degree(dd) { + d := make([]float64, degree(nn)+1) + copy(d[degree(nn)-degree(dd):], dd) + q[degree(nn)-degree(dd)] = nn[degree(nn)] / d[degree(d)] + for i := range d { + d[i] *= q[degree(nn)-degree(dd)] + nn[i] -= d[i] + } + } + } + return q, nn, true +} diff --git a/Task/Polynomial-long-division/Haskell/polynomial-long-division-1.hs b/Task/Polynomial-long-division/Haskell/polynomial-long-division-1.hs new file mode 100644 index 0000000000..b39c256faa --- /dev/null +++ b/Task/Polynomial-long-division/Haskell/polynomial-long-division-1.hs @@ -0,0 +1,22 @@ +import Data.List + +shift n l = l ++ replicate n 0 + +pad n l = replicate n 0 ++ l + +norm :: Fractional a => [a] -> [a] +norm = dropWhile (== 0) + +deg l = length (norm l) - 1 + +zipWith' op p q = zipWith op (pad (-d) p) (pad d q) + where d = (length p) - (length q) + +polydiv f g = aux (norm f) (norm g) [] + where aux f s q | ddif < 0 = (q, f) + | otherwise = aux f' s q' + where ddif = (deg f) - (deg s) + k = (head f) / (head s) + ks = map (* k) $ shift ddif s + q' = zipWith' (+) q $ shift ddif [k] + f' = norm $ tail $ zipWith' (-) f ks diff --git a/Task/Polynomial-long-division/Haskell/polynomial-long-division-2.hs b/Task/Polynomial-long-division/Haskell/polynomial-long-division-2.hs new file mode 100644 index 0000000000..0fcb40f4d7 --- /dev/null +++ b/Task/Polynomial-long-division/Haskell/polynomial-long-division-2.hs @@ -0,0 +1,11 @@ +str_poly l = intercalate " + " $ terms l + where term v 0 = show v + term 1 1 = "x" + term v 1 = (show v) ++ "x" + term 1 p = "x^" ++ (show p) + term v p = (show v) ++ "x^" ++ (show p) + + terms :: Fractional a => [a] -> [String] + terms [] = [] + terms (0:t) = terms t + terms (h:t) = (term h (length t)) : (terms t) diff --git a/Task/Polynomial-long-division/J/polynomial-long-division-1.j b/Task/Polynomial-long-division/J/polynomial-long-division-1.j new file mode 100644 index 0000000000..a89495f86c --- /dev/null +++ b/Task/Polynomial-long-division/J/polynomial-long-division-1.j @@ -0,0 +1 @@ +divmod=:[: (}: ; {:) ([ (] -/@,:&}. (* {:)) ] , %&{.~)^:(>:@-~&#)&.|.~ diff --git a/Task/Polynomial-long-division/J/polynomial-long-division-2.j b/Task/Polynomial-long-division/J/polynomial-long-division-2.j new file mode 100644 index 0000000000..bde4f0aeda --- /dev/null +++ b/Task/Polynomial-long-division/J/polynomial-long-division-2.j @@ -0,0 +1 @@ +_42 0 _12 1 divmod _3 1 diff --git a/Task/Polynomial-long-division/Maple/polynomial-long-division.maple b/Task/Polynomial-long-division/Maple/polynomial-long-division.maple new file mode 100644 index 0000000000..58a7c8d016 --- /dev/null +++ b/Task/Polynomial-long-division/Maple/polynomial-long-division.maple @@ -0,0 +1,19 @@ +> p := randpoly( x ); # pick a random polynomial in x + 5 4 3 2 + p := -56 - 7 x + 22 x - 55 x - 94 x + 87 x + +> rem( p, x^2 + 2, x, 'q' ); # remainder + 220 + 169 x + +> q; # quotient + 3 2 + -7 x + 22 x - 41 x - 138 + +> quo( p, x^2 + 2, x, 'r' ); # quotient + 3 2 + -7 x + 22 x - 41 x - 138 + +> r; # remainder + 220 + 169 x +> expand( (x^2+2)*q + r - p ); # check + 0 diff --git a/Task/Polynomial-long-division/Mathematica/polynomial-long-division.math b/Task/Polynomial-long-division/Mathematica/polynomial-long-division.math new file mode 100644 index 0000000000..e7c88698b8 --- /dev/null +++ b/Task/Polynomial-long-division/Mathematica/polynomial-long-division.math @@ -0,0 +1 @@ +PolynomialQuotientRemainder[x^3-12 x^2-42,x-3,x] diff --git a/Task/Polynomial-long-division/OCaml/polynomial-long-division-1.ocaml b/Task/Polynomial-long-division/OCaml/polynomial-long-division-1.ocaml new file mode 100644 index 0000000000..c71b2eda3c --- /dev/null +++ b/Task/Polynomial-long-division/OCaml/polynomial-long-division-1.ocaml @@ -0,0 +1,8 @@ +let rec shift n l = if n <= 0 then l else shift (pred n) (l @ [0.0]) +let rec pad n l = if n <= 0 then l else pad (pred n) (0.0 :: l) +let rec norm = function | 0.0 :: tl -> norm tl | x -> x +let deg l = List.length (norm l) - 1 + +let zip op p q = + let d = (List.length p) - (List.length q) in + List.map2 op (pad (-d) p) (pad d q) diff --git a/Task/Polynomial-long-division/OCaml/polynomial-long-division-2.ocaml b/Task/Polynomial-long-division/OCaml/polynomial-long-division-2.ocaml new file mode 100644 index 0000000000..befe0dee4a --- /dev/null +++ b/Task/Polynomial-long-division/OCaml/polynomial-long-division-2.ocaml @@ -0,0 +1,10 @@ +let polydiv f g = + let rec aux f s q = + let ddif = (deg f) - (deg s) in + if ddif < 0 then (q, f) else + let k = (List.hd f) /. (List.hd s) in + let ks = List.map (( *.) k) (shift ddif s) in + let q' = zip (+.) q (shift ddif [k]) + and f' = norm (List.tl (zip (-.) f ks)) in + aux f' s q' in + aux (norm f) (norm g) [] diff --git a/Task/Polynomial-long-division/OCaml/polynomial-long-division-3.ocaml b/Task/Polynomial-long-division/OCaml/polynomial-long-division-3.ocaml new file mode 100644 index 0000000000..934974725c --- /dev/null +++ b/Task/Polynomial-long-division/OCaml/polynomial-long-division-3.ocaml @@ -0,0 +1,12 @@ +let str_poly l = + let term v p = match (v, p) with + | ( _, 0) -> string_of_float v + | (1.0, 1) -> "x" + | ( _, 1) -> (string_of_float v) ^ "*x" + | (1.0, _) -> "x^" ^ (string_of_int p) + | _ -> (string_of_float v) ^ "*x^" ^ (string_of_int p) in + let rec terms = function + | [] -> [] + | h :: t -> + if h = 0.0 then (terms t) else (term h (List.length t)) :: (terms t) in + String.concat " + " (terms l) diff --git a/Task/Polynomial-long-division/OCaml/polynomial-long-division-4.ocaml b/Task/Polynomial-long-division/OCaml/polynomial-long-division-4.ocaml new file mode 100644 index 0000000000..4c0799f5d2 --- /dev/null +++ b/Task/Polynomial-long-division/OCaml/polynomial-long-division-4.ocaml @@ -0,0 +1,6 @@ +let _ = + let f = [1.0; -4.0; 6.0; 5.0; 3.0] and g = [1.0; 2.0; 1.0] in + let q, r = polydiv f g in + Printf.printf + " (%s) div (%s)\ngives\nquotient:\t(%s)\nremainder:\t(%s)\n" + (str_poly f) (str_poly g) (str_poly q) (str_poly r) diff --git a/Task/Polynomial-long-division/Octave/polynomial-long-division.octave b/Task/Polynomial-long-division/Octave/polynomial-long-division.octave new file mode 100644 index 0000000000..d562bc793e --- /dev/null +++ b/Task/Polynomial-long-division/Octave/polynomial-long-division.octave @@ -0,0 +1,37 @@ +function [q, r] = poly_long_div(n, d) + gd = length(d); + pv = zeros(1, length(n)); + pv(1:gd) = d; + if ( length(n) >= gd ) + q = []; + while ( length(n) >= gd ) + q = [q, n(1)/pv(1)]; + n = n - pv .* (n(1)/pv(1)); + n = shift(n, -1); % + tn = n(1:length(n)-1); % eat the higher power term + n = tn; % + tp = pv(1:length(pv)-1); + pv = tp; % make pv the same length of n + endwhile + r = n; + else + q = [0]; + r = n; + endif +endfunction + +[q, r] = poly_long_div([1,-12,0,-42], [1,-3]); +polyout(q, 'x'); +polyout(r, 'x'); +disp(""); +[q, r] = poly_long_div([1,-12,0,-42], [1,1,-3]); +polyout(q, 'x'); +polyout(r, 'x'); +disp(""); +[q, r] = poly_long_div([1,3,2], [1,1]); +polyout(q, 'x'); +polyout(r, 'x'); +disp(""); +[q, r] = poly_long_div([1,3], [1,-12,0,-42]); +polyout(q, 'x'); +polyout(r, 'x'); diff --git a/Task/Polynomial-long-division/PARI-GP/polynomial-long-division-1.pari b/Task/Polynomial-long-division/PARI-GP/polynomial-long-division-1.pari new file mode 100644 index 0000000000..603bbe1714 --- /dev/null +++ b/Task/Polynomial-long-division/PARI-GP/polynomial-long-division-1.pari @@ -0,0 +1,5 @@ +poldiv(a,b)={ + my(rem=a%b); + [(a - rem)/b, rem] +}; +poldiv(x^9+1, x^3+x-3) diff --git a/Task/Polynomial-long-division/PARI-GP/polynomial-long-division-2.pari b/Task/Polynomial-long-division/PARI-GP/polynomial-long-division-2.pari new file mode 100644 index 0000000000..900d624fd6 --- /dev/null +++ b/Task/Polynomial-long-division/PARI-GP/polynomial-long-division-2.pari @@ -0,0 +1 @@ +divrem(x^9+1, x^3+x-3)~ diff --git a/Task/Polynomial-long-division/Perl-6/polynomial-long-division.pl6 b/Task/Polynomial-long-division/Perl-6/polynomial-long-division.pl6 new file mode 100644 index 0000000000..a1d416e2ed --- /dev/null +++ b/Task/Polynomial-long-division/Perl-6/polynomial-long-division.pl6 @@ -0,0 +1,24 @@ +sub poly_long_div ( @n is copy, @d ) { + return [0], @n if +@n < +@d; + + my @q = gather while +@n >= +@d { + @n = @n Z- ( ( @d X* take ( @n[0] / @d[0] ) ), 0 xx * ); + @n.shift; + } + + return $(@q), $(@n); +} + +sub xP ( $power ) { $power>1 ?? "x^$power" !! $power==1 ?? 'x' !! '' } +sub poly_print ( @c ) { join ' + ', @c.kv.map: { $^v ~ xP( @c.end - $^k ) } } + +my @polys = [ [ 1, -12, 0, -42 ], [ 1, -3 ] ], + [ [ 1, -12, 0, -42 ], [ 1, 1, -3 ] ], + [ [ 1, 3, 2 ], [ 1, 1 ] ], + [ [ 1, -4, 6, 5, 3 ], [ 1, 2, 1 ] ]; + +say '\begin{array}{rr}'; +for @polys -> [ @a, @b ] { + printf "%s , & %s \\\\\n", poly_long_div( @a, @b ).map: { poly_print($_) }; +} +say '\end{array}'; diff --git a/Task/Polynomial-long-division/Perl/polynomial-long-division-1.pl b/Task/Polynomial-long-division/Perl/polynomial-long-division-1.pl new file mode 100644 index 0000000000..1bdd383918 --- /dev/null +++ b/Task/Polynomial-long-division/Perl/polynomial-long-division-1.pl @@ -0,0 +1,22 @@ +use strict; +use List::Util qw(min); + +sub poly_long_div +{ + my ($rn, $rd) = @_; + + my @n = @$rn; + my $gd = scalar(@$rd); + if ( scalar(@n) >= $gd ) { + my @q = (); + while ( scalar(@n) >= $gd ) { + my $piv = $n[0]/$rd->[0]; + push @q, $piv; + $n[$_] -= $rd->[$_] * $piv foreach ( 0 .. min(scalar(@n), $gd)-1 ); + shift @n; + } + return ( \@q, \@n ); + } else { + return ( [0], $rn ); + } +} diff --git a/Task/Polynomial-long-division/Perl/polynomial-long-division-2.pl b/Task/Polynomial-long-division/Perl/polynomial-long-division-2.pl new file mode 100644 index 0000000000..aa6921cbe5 --- /dev/null +++ b/Task/Polynomial-long-division/Perl/polynomial-long-division-2.pl @@ -0,0 +1,10 @@ +sub poly_print +{ + my @c = @_; + my $l = scalar(@c); + for(my $i=0; $i < $l; $i++) { + print $c[$i]; + print "x^" . ($l-$i-1) . " + " if ($i < ($l-1)); + } + print "\n"; +} diff --git a/Task/Polynomial-long-division/Perl/polynomial-long-division-3.pl b/Task/Polynomial-long-division/Perl/polynomial-long-division-3.pl new file mode 100644 index 0000000000..59f61daff8 --- /dev/null +++ b/Task/Polynomial-long-division/Perl/polynomial-long-division-3.pl @@ -0,0 +1,18 @@ +my ($q, $r); + +($q, $r) = poly_long_div([1, -12, 0, -42], [1, -3]); +poly_print(@$q); +poly_print(@$r); +print "\n"; +($q, $r) = poly_long_div([1,-12,0,-42], [1,1,-3]); +poly_print(@$q); +poly_print(@$r); +print "\n"; +($q, $r) = poly_long_div([1,3,2], [1,1]); +poly_print(@$q); +poly_print(@$r); +print "\n"; +# the example from the OCaml solution +($q, $r) = poly_long_div([1,-4,6,5,3], [1,2,1]); +poly_print(@$q); +poly_print(@$r); diff --git a/Task/Polynomial-long-division/PicoLisp/polynomial-long-division.l b/Task/Polynomial-long-division/PicoLisp/polynomial-long-division.l new file mode 100644 index 0000000000..78ba2829ef --- /dev/null +++ b/Task/Polynomial-long-division/PicoLisp/polynomial-long-division.l @@ -0,0 +1,18 @@ +(de degree (P) + (let I NIL + (for (N . C) P + (or (=0 C) (setq I N)) ) + (dec I) ) ) + +(de divPoly (N D) + (if (lt0 (degree D)) + (quit "Div/0" D) + (let (Q NIL Diff) + (while (ge0 (setq Diff (- (degree N) (degree D)))) + (setq Q (need (- -1 Diff) Q 0)) + (let E D + (do Diff (push 'E 0)) + (let F (/ (get N (inc (degree N))) (get E (inc (degree E)))) + (set (nth Q (inc Diff)) F) + (setq N (mapcar '((N E) (- N (* E F))) N E)) ) ) ) + (list Q N) ) ) ) diff --git a/Task/Polynomial-long-division/Python/polynomial-long-division.py b/Task/Polynomial-long-division/Python/polynomial-long-division.py new file mode 100644 index 0000000000..93c2f2d71f --- /dev/null +++ b/Task/Polynomial-long-division/Python/polynomial-long-division.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- + +from itertools import izip +from math import fabs + +def degree(poly): + while poly and poly[-1] == 0: + poly.pop() # normalize + return len(poly)-1 + +def poly_div(N, D): + dD = degree(D) + dN = degree(N) + if dD < 0: raise ZeroDivisionError + if dN >= dD: + q = [0] * dN + while dN >= dD: + d = [0]*(dN - dD) + D + mult = q[dN - dD] = N[-1] / float(d[-1]) + d = [coeff*mult for coeff in d] + N = [fabs ( coeffN - coeffd ) for coeffN, coeffd in izip(N, d)] + dN = degree(N) + r = N + else: + q = [0] + r = N + return q, r + +if __name__ == '__main__': + print "POLYNOMIAL LONG DIVISION" + N = [-42, 0, -12, 1] + D = [-3, 1, 0, 0] + print " %s / %s =" % (N,D), + print " %s remainder %s" % poly_div(N, D) diff --git a/Task/Polynomial-long-division/R/polynomial-long-division.r b/Task/Polynomial-long-division/R/polynomial-long-division.r new file mode 100644 index 0000000000..a4e60ab668 --- /dev/null +++ b/Task/Polynomial-long-division/R/polynomial-long-division.r @@ -0,0 +1,34 @@ +polylongdiv <- function(n,d) { + gd <- length(d) + pv <- vector("numeric", length(n)) + pv[1:gd] <- d + if ( length(n) >= gd ) { + q <- c() + while ( length(n) >= gd ) { + q <- c(q, n[1]/pv[1]) + n <- n - pv * (n[1]/pv[1]) + n <- n[2:length(n)] + pv <- pv[1:(length(pv)-1)] + } + list(q=q, r=n) + } else { + list(q=c(0), r=n) + } +} + +# an utility function to print polynomial +print.polynomial <- function(p) { + i <- length(p)-1 + for(a in p) { + if ( i == 0 ) { + cat(a, "\n") + } else { + cat(a, "x^", i, " + ", sep="") + } + i <- i - 1 + } +} + +r <- polylongdiv(c(1,-12,0,-42), c(1,-3)) +print.polynomial(r$q) +print.polynomial(r$r) diff --git a/Task/Polynomial-long-division/Ruby/polynomial-long-division-1.rb b/Task/Polynomial-long-division/Ruby/polynomial-long-division-1.rb new file mode 100644 index 0000000000..e90dbe238c --- /dev/null +++ b/Task/Polynomial-long-division/Ruby/polynomial-long-division-1.rb @@ -0,0 +1,46 @@ +def polynomial_long_division(numerator, denominator) + dd = degree(denominator) + raise ArgumentError, "denominator is zero" if dd < 0 + if dd == 0 + return [multiply(numerator, 1.0/denominator[0]), [0]*numerator.length] + end + + q = [0] * numerator.length + + while (dn = degree(numerator)) >= dd + d = shift_right(denominator, dn - dd) + q[dn-dd] = numerator[dn] / d[degree(d)] + d = multiply(d, q[dn-dd]) + numerator = subtract(numerator, d) + end + + [q, numerator] +end + +def degree(ary) + idx = ary.rindex {|x| x.nonzero?} + idx.nil? ? -1 : idx +end + +def shift_right(ary, n) + [0]*n + ary[0, ary.length - n] +end + +def subtract(a1, a2) + a1.zip(a2).collect {|v1,v2| v1 - v2} +end + +def multiply(ary, num) + ary.collect {|x| x * num} +end + +f = [-42, 0, -12, 1] +g = [-3, 1, 0, 0] +q, r = polynomial_long_division(f, g) +p [f, g, q, r] +# => [[-42, 0, -12, 1], [-3, 1, 0, 0], [-27, -9, 1, 0, 0], [-123, 0, 0, 0, 0]] + +g = [-3, 1, 1, 0] +q, r = polynomial_long_division(f, g) +p [f, g, q, r] +# => [[-42, 0, -12, 1], [-3, 1, 0, 0], [-13, 1, 0, 0, 0], [-81, 16, 0, 0, 0]] diff --git a/Task/Polynomial-long-division/Ruby/polynomial-long-division-2.rb b/Task/Polynomial-long-division/Ruby/polynomial-long-division-2.rb new file mode 100644 index 0000000000..f88e6c16b4 --- /dev/null +++ b/Task/Polynomial-long-division/Ruby/polynomial-long-division-2.rb @@ -0,0 +1,68 @@ +def polynomial_division(f, g) + if g.length == 0 or (g.length == 1 and g[0] == 0) + raise ArgumentError, "denominator is zero" + elsif g.length == 1 + [f.collect {|x| Float(x)/g[0]}, [0]] + elsif g.length == 2 + synthetic_division(f, g) + else + higher_degree_synthetic_division(f, g) + end +end + +def synthetic_division(f, g) + board = [f] << Array.new(f.length) << Array.new(f.length) + board[2][0] = board[0][0] + + 1.upto(f.length - 1).each do |i| + board[1][i] = board[2][i-1] * -g[1] + board[2][i] = board[0][i] + board[1][i] + end + + [board[2][0..-2], [board[2][-1]]] +end + +# an ugly mess of array index arithmetic +# http://en.wikipedia.org/wiki/Polynomial_long_division#Higher_degree_synthetic_division +def higher_degree_synthetic_division(f, g) + + # [use] the negative coefficients of the denominator following the leading term + lhs = g[1..-1].collect {|x| -x} + board = [f] + + q = [] + 1.upto(f.length - lhs.length).each do |i| + n = 2*i - 1 + + # underline the leading coefficient of the right-hand side, multiply it by + # the left-hand coefficients and write the products beneath the next columns + # on the right. + q << board[n-1][i-1] + board << Array.new(f.length).fill(0, i) # row n + (lhs.length).times do |j| + board[n][i+j] = q[-1]*lhs[j] + end + + # perform an addition + board << Array.new(f.length).fill(0, i) # row n+1 + (lhs.length + 1).times do |j| + board[n+1][i+j] = board[n-1][i+j] + board[n][i+j] if i+j < f.length + end + end + + # the remaining numbers in the bottom row correspond to the coefficients of the remainder + r = board[-1].compact + q = [0] if q.empty? + [q, r] +end + +f = [1, -12, 0, -42] +g = [1, -3] +q, r = polynomial_division(f, g) +p [f, g, q, r] +# => [[1, -12, 0, -42], [1, -3], [1, -9, -27], [-123]] + +g = [1, 1, -3] +q, r = polynomial_division(f, g) +p [f, g, q, r] +# => [[1, -12, 0, -42], [1, 1, -3], [1, -13], [16, -81]] diff --git a/Task/Polynomial-long-division/Ruby/polynomial-long-division-3.rb b/Task/Polynomial-long-division/Ruby/polynomial-long-division-3.rb new file mode 100644 index 0000000000..7288433dd0 --- /dev/null +++ b/Task/Polynomial-long-division/Ruby/polynomial-long-division-3.rb @@ -0,0 +1,30 @@ +def tcl_polynomial_division(f, g) + if g.length == 0 or (g.length == 1 and g[0] == 0) + raise ArgumentError, "denominator is zero" + end + return [[0], f] if f.length < g.length + + q = [] + n, d = f.dup, g + while n.length >= d.length + q << Float(n[0]) / d[0] + n[0, d.length].zip(d).each_with_index do |pair, i| + n[i] = Float(pair[0]) - q[-1] * pair[1] + end + n.shift + end + q = [0] if q.empty? + n = [0] if n.empty? + [q, n] +end + +f = [1, -12, 0, -42] +g = [1, -3] +q, r = polynomial_division(f, g) +p [f, g, q, r] +# => [[1, -12, 0, -42], [1, -3], [1, -9, -27], [-123]] + +g = [1, 1, -3] +q, r = polynomial_division(f, g) +p [f, g, q, r] +# => [[1, -12, 0, -42], [1, 1, -3], [1, -13], [16, -81]] diff --git a/Task/Polynomial-long-division/Slate/polynomial-long-division.slate b/Task/Polynomial-long-division/Slate/polynomial-long-division.slate new file mode 100644 index 0000000000..8b191184f7 --- /dev/null +++ b/Task/Polynomial-long-division/Slate/polynomial-long-division.slate @@ -0,0 +1,62 @@ +define: #Polynomial &parents: {Comparable} &slots: {#coefficients -> ExtensibleArray new}. + +p@(Polynomial traits) new &capacity: n +[ + p cloneSettingSlots: #(coefficients) to: {p coefficients new &capacity: n} +]. + +p@(Polynomial traits) newFrom: seq@(Sequence traits) +[ + p clone `>> [coefficients: (seq as: p coefficients). normalize. ] +]. + +p@(Polynomial traits) copy +[ + p cloneSettingSlots: #(coefficients) to: {p coefficients copy} +]. + +p1@(Polynomial traits) >= p2@(Polynomial traits) +[p1 degree >= p2 degree]. + +p@(Polynomial traits) degree +[p coefficients indexOfLastSatisfying: [| :n | n isZero not]]. + +p@(Polynomial traits) normalize +[ + [p degree isPositive /\ [p coefficients last isZero]] + whileTrue: [p coefficients removeLast] +]. + +p@(Polynomial traits) * n@(Number traits) +[ + p newFrom: (p coefficients collect: [| :x | x * n]) +]. + +p@(Polynomial traits) / n@(Number traits) +[ + p newFrom: (p coefficients collect: [| :x | x / n]) +]. + +p1@(Polynomial traits) minusCoefficients: p2@(Polynomial traits) +[ + p1 newFrom: (p1 coefficients with: p2 coefficients collect: #- `er) +]. + +p@(Polynomial traits) / denom@(Polynomial traits) +[ + p >= denom + ifTrue: + [| n q | + n: p copy. + q: p new. + [n >= denom] + whileTrue: + [| piv | + piv: p coefficients last / denom coefficients last. + q coefficients add: piv. + n: (n minusCoefficients: denom * piv). + n normalize]. + n coefficients isEmpty ifTrue: [n coefficients add: 0]. + {q. n}] + ifFalse: [{p newFrom: #(0). p copy}] +]. diff --git a/Task/Polynomial-long-division/Smalltalk/polynomial-long-division-1.st b/Task/Polynomial-long-division/Smalltalk/polynomial-long-division-1.st new file mode 100644 index 0000000000..af38b873df --- /dev/null +++ b/Task/Polynomial-long-division/Smalltalk/polynomial-long-division-1.st @@ -0,0 +1,68 @@ +Object subclass: Polynomial [ + |coeffs| + Polynomial class >> new [ ^ super basicNew init ] + init [ coeffs := OrderedCollection new. ^ self ] + Polynomial class >> newWithCoefficients: coefficients [ + |r| + r := super basicNew. + ^ r initWithCoefficients: coefficients + ] + initWithCoefficients: coefficients [ + coeffs := coefficients asOrderedCollection. + ^ self + ] + / denominator [ |n q| + n := self deepCopy. + self >= denominator + ifTrue: [ + q := Polynomial new. + [ n >= denominator ] + whileTrue: [ |piv| + piv := (n coeff: 0) / (denominator coeff: 0). + q addCoefficient: piv. + n := n - (denominator * piv). + n clean + ]. + ^ { q . (n degree) > 0 ifTrue: [ n ] ifFalse: [ n addCoefficient: 0. n ] } + ] + ifFalse: [ + ^ { Polynomial newWithCoefficients: #( 0 ) . self deepCopy } + ] + ] + * constant [ |r| r := self deepCopy. + 1 to: (coeffs size) do: [ :i | + r at: i put: ((r at: i) * constant) + ]. + ^ r + ] + at: index [ ^ coeffs at: index ] + at: index put: obj [ ^ coeffs at: index put: obj ] + >= anotherPoly [ + ^ (self degree) >= (anotherPoly degree) + ] + degree [ ^ coeffs size ] + - anotherPoly [ "This is not a real subtraction between Polynomial: it is an + internal method ..." + |a| + a := self deepCopy. + 1 to: ( (coeffs size) min: (anotherPoly degree) ) do: [ :i | + a at: i put: ( (a at: i) - (anotherPoly at: i) ) + ]. + ^ a + ] + coeff: index [ ^ coeffs at: (index + 1) ] + addCoefficient: coeff [ coeffs add: coeff ] + clean [ + [ (coeffs size) > 0 + ifTrue: [ (coeffs at: 1) = 0 ] ifFalse: [ false ] ] + whileTrue: [ coeffs removeFirst ]. + ] + display [ + 1 to: (coeffs size) do: [ :i | + (coeffs at: i) display. + i < (coeffs size) + ifTrue: [ ('x^%1 + ' % {(coeffs size) - i} ) display ] + ] + ] + displayNl [ self display. Character nl display ] +]. diff --git a/Task/Polynomial-long-division/Smalltalk/polynomial-long-division-2.st b/Task/Polynomial-long-division/Smalltalk/polynomial-long-division-2.st new file mode 100644 index 0000000000..90cefe9cba --- /dev/null +++ b/Task/Polynomial-long-division/Smalltalk/polynomial-long-division-2.st @@ -0,0 +1,11 @@ +|res| +res := OrderedCollection new. + +res add: ((Polynomial newWithCoefficients: #( 1 -12 0 -42) ) / + (Polynomial newWithCoefficients: #( 1 -3 ) )) ; + add: ((Polynomial newWithCoefficients: #( 1 -12 0 -42) ) / + (Polynomial newWithCoefficients: #( 1 1 -3 ) )). + +res do: [ :o | + (o at: 1) display. ' with rest: ' display. (o at: 2) displayNl +] diff --git a/Task/Polynomial-long-division/Tcl/polynomial-long-division.tcl b/Task/Polynomial-long-division/Tcl/polynomial-long-division.tcl new file mode 100644 index 0000000000..320a0974c2 --- /dev/null +++ b/Task/Polynomial-long-division/Tcl/polynomial-long-division.tcl @@ -0,0 +1,40 @@ +# poldiv - Divide two polynomials n and d. +# Result is a list of two polynomials, q and r, where n = qd + r +# and the degree of r is less than the degree of b. +# Polynomials are represented as lists, where element 0 is the +# x**0 coefficient, element 1 is the x**1 coefficient, and so on. + +proc poldiv {a b} { + # Toss out leading zero coefficients efficiently + while {[lindex $a end] == 0} {set a [lrange $a[set a {}] 0 end-1]} + while {[lindex $b end] == 0} {set b [lrange $b[set b {}] 0 end-1]} + if {[llength $a] < [llength $b]} { + return [list 0 $a] + } + + # Rearrange the terms to put highest powers first + set n [lreverse $a] + set d [lreverse $b] + + # Carry out classical long division, accumulating quotient coefficients + # in q, and replacing n with the remainder. + set q {} + while {[llength $n] >= [llength $d]} { + set qd [expr {[lindex $n 0] / [lindex $d 0]}] + set i 0 + foreach nd [lrange $n 0 [expr {[llength $d] - 1}]] dd $d { + lset n $i [expr {$nd - $qd * $dd}] + incr i + } + lappend q $qd + set n [lrange $n 1 end] + } + + # Return quotient and remainder, constant term first + return [list [lreverse $q] [lreverse $n]] +} + +# Demonstration +lassign [poldiv {-42. 0. -12. 1.} {-3. 1. 0. 0.}] Q R +puts [list Q = $Q] +puts [list R = $R] diff --git a/Task/Polynomial-long-division/Ursala/polynomial-long-division-1.ursala b/Task/Polynomial-long-division/Ursala/polynomial-long-division-1.ursala new file mode 100644 index 0000000000..7c5af0b8ca --- /dev/null +++ b/Task/Polynomial-long-division/Ursala/polynomial-long-division-1.ursala @@ -0,0 +1,9 @@ +#import std +#import flo + +polydiv = + +zeroid~-l~~; leql?rlX\~&NlX ^H\(@rNrNSPXlHDlS |\ :/0.) @NlX //=> ?( + @lrrPX ==!| zipp0.; @x not zeroid+ ==@h->hr ~&t, + (^lryPX/~&lrrl2C minus^*p/~&rrr times*lrlPD)^/div@bzPrrPlXO ~&, + @r ^|\~& ~&i&& :/0.) diff --git a/Task/Polynomial-long-division/Ursala/polynomial-long-division-2.ursala b/Task/Polynomial-long-division/Ursala/polynomial-long-division-2.ursala new file mode 100644 index 0000000000..0550d69629 --- /dev/null +++ b/Task/Polynomial-long-division/Ursala/polynomial-long-division-2.ursala @@ -0,0 +1,3 @@ +#cast %eLW + +example = polydiv(<-42.,0.,-12.,1.>,<-3.,1.,0.,0.>) diff --git a/Task/Polynomial-regression/0DESCRIPTION b/Task/Polynomial-regression/0DESCRIPTION new file mode 100644 index 0000000000..626f2cc997 --- /dev/null +++ b/Task/Polynomial-regression/0DESCRIPTION @@ -0,0 +1,11 @@ +Find an approximating polynom of known degree for a given data. + +Example: +For input data: + x = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + y = {1, 6, 17, 34, 57, 86, 121, 162, 209, 262, 321}; +The approximating polynom is: + 3 x2 + 2 x + 1 +Here, the polynom's coefficients are (3, 2, 1). + +This task is intended as a subtask for [[Measure relative performance of sorting algorithms implementations]]. diff --git a/Task/Polynomial-regression/1META.yaml b/Task/Polynomial-regression/1META.yaml new file mode 100644 index 0000000000..aeaae31164 --- /dev/null +++ b/Task/Polynomial-regression/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Mathematical operations|Matrices diff --git a/Task/Polynomial-regression/ALGOL-68/polynomial-regression.alg b/Task/Polynomial-regression/ALGOL-68/polynomial-regression.alg new file mode 100644 index 0000000000..96a7054429 --- /dev/null +++ b/Task/Polynomial-regression/ALGOL-68/polynomial-regression.alg @@ -0,0 +1,114 @@ +MODE FIELD = REAL; + +MODE + VEC = [0]FIELD, + MAT = [0,0]FIELD; + +PROC VOID raise index error := VOID: ( + print(("stop", new line)); + stop +); + +COMMENT from http://rosettacode.org/wiki/Matrix_Transpose#ALGOL_68 END COMMENT +OP ZIP = ([,]FIELD in)[,]FIELD:( + [2 LWB in:2 UPB in,1 LWB in:1UPB in]FIELD out; + FOR i FROM LWB in TO UPB in DO + out[,i]:=in[i,] + OD; + out +); + +COMMENT from http://rosettacode.org/wiki/Matrix_multiplication#ALGOL_68 END COMMENT +OP * = (VEC a,b)FIELD: ( # basically the dot product # + FIELD result:=0; + IF LWB a/=LWB b OR UPB a/=UPB b THEN raise index error FI; + FOR i FROM LWB a TO UPB a DO result+:= a[i]*b[i] OD; + result + ); + +OP * = (VEC a, MAT b)VEC: ( # overload vector times matrix # + [2 LWB b:2 UPB b]FIELD result; + IF LWB a/=LWB b OR UPB a/=UPB b THEN raise index error FI; + FOR j FROM 2 LWB b TO 2 UPB b DO result[j]:=a*b[,j] OD; + result + ); + +OP * = (MAT a, b)MAT: ( # overload matrix times matrix # + [LWB a:UPB a, 2 LWB b:2 UPB b]FIELD result; + IF 2 LWB a/=LWB b OR 2 UPB a/=UPB b THEN raise index error FI; + FOR k FROM LWB result TO UPB result DO result[k,]:=a[k,]*b OD; + result + ); + +COMMENT from http://rosettacode.org/wiki/Pyramid_of_numbers#ALGOL_68 END COMMENT +OP / = (VEC a, MAT b)VEC: ( # vector division # + [LWB a:UPB a,1]FIELD transpose a; + transpose a[,1]:=a; + (transpose a/b)[,1] +); + +OP / = (MAT a, MAT b)MAT:( # matrix division # + [LWB b:UPB b]INT p ; + INT sign; + [,]FIELD lu = lu decomp(b, p, sign); + [LWB a:UPB a, 2 LWB a:2 UPB a]FIELD out; + FOR col FROM 2 LWB a TO 2 UPB a DO + out[,col] := lu solve(b, lu, p, a[,col]) [@LWB out[,col]] + OD; + out +); + +FORMAT int repr = $g(0)$, + real repr = $g(-7,4)$; + +PROC fit = (VEC x, y, INT order)VEC: +BEGIN + [0:order, LWB x:UPB x]FIELD a; # the plane # + FOR i FROM 2 LWB a TO 2 UPB a DO + FOR j FROM LWB a TO UPB a DO + a [j, i] := x [i]**j + OD + OD; + ( y * ZIP a ) / ( a * ZIP a ) +END # fit #; + +PROC print polynomial = (VEC x)VOID: ( + BOOL empty := TRUE; + FOR i FROM UPB x BY -1 TO LWB x DO + IF x[i] NE 0 THEN + IF x[i] > 0 AND NOT empty THEN print ("+") FI; + empty := FALSE; + IF x[i] NE 1 OR i=0 THEN + IF ENTIER x[i] = x[i] THEN + printf((int repr, x[i])) + ELSE + printf((real repr, x[i])) + FI + FI; + CASE i+1 IN + SKIP,print(("x")) + OUT + printf(($"x**"g(0)$,i)) + ESAC + FI + OD; + IF empty THEN print("0") FI; + print(new line) +); + +fitting: BEGIN + VEC c = + fit + ( (0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0), + (1.0, 6.0, 17.0, 34.0, 57.0, 86.0, 121.0, 162.0, 209.0, 262.0, 321.0), + 2 + ); + print polynomial(c); + VEC d = + fit + ( (0, 1, 2, 3, 4, 5, 6, 7, 8, 9), + (2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0), + 2 + ); + print polynomial(d) +END # fitting # diff --git a/Task/Polynomial-regression/Ada/polynomial-regression-1.ada b/Task/Polynomial-regression/Ada/polynomial-regression-1.ada new file mode 100644 index 0000000000..e1a055dd42 --- /dev/null +++ b/Task/Polynomial-regression/Ada/polynomial-regression-1.ada @@ -0,0 +1,12 @@ +with Ada.Numerics.Real_Arrays; use Ada.Numerics.Real_Arrays; + +function Fit (X, Y : Real_Vector; N : Positive) return Real_Vector is + A : Real_Matrix (0..N, X'Range); -- The plane +begin + for I in A'Range (2) loop + for J in A'Range (1) loop + A (J, I) := X (I)**J; + end loop; + end loop; + return Solve (A * Transpose (A), A * Y); +end Fit; diff --git a/Task/Polynomial-regression/Ada/polynomial-regression-2.ada b/Task/Polynomial-regression/Ada/polynomial-regression-2.ada new file mode 100644 index 0000000000..e1a134024c --- /dev/null +++ b/Task/Polynomial-regression/Ada/polynomial-regression-2.ada @@ -0,0 +1,15 @@ +with Fit; +with Ada.Float_Text_IO; use Ada.Float_Text_IO; + +procedure Fitting is + C : constant Real_Vector := + Fit + ( (0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0), + (1.0, 6.0, 17.0, 34.0, 57.0, 86.0, 121.0, 162.0, 209.0, 262.0, 321.0), + 2 + ); +begin + Put (C (0), Aft => 3, Exp => 0); + Put (C (1), Aft => 3, Exp => 0); + Put (C (2), Aft => 3, Exp => 0); +end Fitting; diff --git a/Task/Polynomial-regression/BBC-BASIC/polynomial-regression.bbc b/Task/Polynomial-regression/BBC-BASIC/polynomial-regression.bbc new file mode 100644 index 0000000000..ef22df1459 --- /dev/null +++ b/Task/Polynomial-regression/BBC-BASIC/polynomial-regression.bbc @@ -0,0 +1,49 @@ + INSTALL @lib$+"ARRAYLIB" + + Max% = 10000 + DIM vector(5), matrix(5,5) + DIM x(Max%), x2(Max%), x3(Max%), x4(Max%), x5(Max%) + DIM x6(Max%), x7(Max%), x8(Max%), x9(Max%), x10(Max%) + DIM y(Max%), xy(Max%), x2y(Max%), x3y(Max%), x4y(Max%), x5y(Max%) + + npts% = 11 + x() = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 + y() = 1, 6, 17, 34, 57, 86, 121, 162, 209, 262, 321 + + sum_x = SUM(x()) + x2() = x() * x() : sum_x2 = SUM(x2()) + x3() = x() * x2() : sum_x3 = SUM(x3()) + x4() = x2() * x2() : sum_x4 = SUM(x4()) + x5() = x2() * x3() : sum_x5 = SUM(x5()) + x6() = x3() * x3() : sum_x6 = SUM(x6()) + x7() = x3() * x4() : sum_x7 = SUM(x7()) + x8() = x4() * x4() : sum_x8 = SUM(x8()) + x9() = x4() * x5() : sum_x9 = SUM(x9()) + x10() = x5() * x5() : sum_x10 = SUM(x10()) + + sum_y = SUM(y()) + xy() = x() * y() : sum_xy = SUM(xy()) + x2y() = x2() * y() : sum_x2y = SUM(x2y()) + x3y() = x3() * y() : sum_x3y = SUM(x3y()) + x4y() = x4() * y() : sum_x4y = SUM(x4y()) + x5y() = x5() * y() : sum_x5y = SUM(x5y()) + + matrix() = \ + \ npts%, sum_x, sum_x2, sum_x3, sum_x4, sum_x5, \ + \ sum_x, sum_x2, sum_x3, sum_x4, sum_x5, sum_x6, \ + \ sum_x2, sum_x3, sum_x4, sum_x5, sum_x6, sum_x7, \ + \ sum_x3, sum_x4, sum_x5, sum_x6, sum_x7, sum_x8, \ + \ sum_x4, sum_x5, sum_x6, sum_x7, sum_x8, sum_x9, \ + \ sum_x5, sum_x6, sum_x7, sum_x8, sum_x9, sum_x10 + + vector() = \ + \ sum_y, sum_xy, sum_x2y, sum_x3y, sum_x4y, sum_x5y + + PROC_invert(matrix()) + vector() = matrix().vector() + + @% = &2040A + PRINT "Polynomial coefficients = " + FOR term% = 5 TO 0 STEP -1 + PRINT ;vector(term%) " * x^" STR$(term%) + NEXT diff --git a/Task/Polynomial-regression/C-sharp/polynomial-regression-1.cs b/Task/Polynomial-regression/C-sharp/polynomial-regression-1.cs new file mode 100644 index 0000000000..4b8e419bb2 --- /dev/null +++ b/Task/Polynomial-regression/C-sharp/polynomial-regression-1.cs @@ -0,0 +1,15 @@ + public static double[] Polyfit(double[] x, double[] y, int degree) + { + // Vandermonde matrix + var v = new DenseMatrix(x.Length, degree + 1); + for (int i = 0; i < v.RowCount; i++) + for (int j = 0; j <= degree; j++) v[i, j] = Math.Pow(x[i], j); + var yv = new DenseVector(y).ToColumnMatrix(); + QR qr = v.QR(); + // Math.Net doesn't have an "economy" QR, so: + // cut R short to square upper triangle, then recompute Q + var r = qr.R.SubMatrix(0, degree + 1, 0, degree + 1); + var q = v.Multiply(r.Inverse()); + var p = r.Inverse().Multiply(q.TransposeThisAndMultiply(yv)); + return p.Column(0).ToArray(); + } diff --git a/Task/Polynomial-regression/C-sharp/polynomial-regression-2.cs b/Task/Polynomial-regression/C-sharp/polynomial-regression-2.cs new file mode 100644 index 0000000000..8f2614449c --- /dev/null +++ b/Task/Polynomial-regression/C-sharp/polynomial-regression-2.cs @@ -0,0 +1,12 @@ + static void Main(string[] args) + { + const int degree = 2; + var x = new[] {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}; + var y = new[] {1.0, 6.0, 17.0, 34.0, 57.0, 86.0, 121.0, 162.0, 209.0, 262.0, 321.0}; + var p = Polyfit(x, y, degree); + foreach (var d in p) Console.Write("{0} ",d); + Console.WriteLine(); + for (int i = 0; i < x.Length; i++ ) + Console.WriteLine("{0} => {1} diff {2}", x[i], Polyval(p,x[i]), y[i] - Polyval(p,x[i])); + Console.ReadKey(true); + } diff --git a/Task/Polynomial-regression/C/polynomial-regression-1.c b/Task/Polynomial-regression/C/polynomial-regression-1.c new file mode 100644 index 0000000000..e46b4c4a59 --- /dev/null +++ b/Task/Polynomial-regression/C/polynomial-regression-1.c @@ -0,0 +1,8 @@ +#ifndef _POLIFITGSL_H +#define _POLIFITGSL_H +#include +#include +#include +bool polynomialfit(int obs, int degree, + double *dx, double *dy, double *store); /* n, p */ +#endif diff --git a/Task/Polynomial-regression/C/polynomial-regression-2.c b/Task/Polynomial-regression/C/polynomial-regression-2.c new file mode 100644 index 0000000000..b4cb56acb0 --- /dev/null +++ b/Task/Polynomial-regression/C/polynomial-regression-2.c @@ -0,0 +1,42 @@ +#include "polifitgsl.h" + +bool polynomialfit(int obs, int degree, + double *dx, double *dy, double *store) /* n, p */ +{ + gsl_multifit_linear_workspace *ws; + gsl_matrix *cov, *X; + gsl_vector *y, *c; + double chisq; + + int i, j; + + X = gsl_matrix_alloc(obs, degree); + y = gsl_vector_alloc(obs); + c = gsl_vector_alloc(degree); + cov = gsl_matrix_alloc(degree, degree); + + for(i=0; i < obs; i++) { + gsl_matrix_set(X, i, 0, 1.0); + for(j=0; j < degree; j++) { + gsl_matrix_set(X, i, j, pow(dx[i], j)); + } + gsl_vector_set(y, i, dy[i]); + } + + ws = gsl_multifit_linear_alloc(obs, degree); + gsl_multifit_linear(X, y, c, cov, &chisq, ws); + + /* store result ... */ + for(i=0; i < degree; i++) + { + store[i] = gsl_vector_get(c, i); + } + + gsl_multifit_linear_free(ws); + gsl_matrix_free(X); + gsl_matrix_free(cov); + gsl_vector_free(y); + gsl_vector_free(c); + return true; /* we do not "analyse" the result (cov matrix mainly) + to know if the fit is "good" */ +} diff --git a/Task/Polynomial-regression/C/polynomial-regression-3.c b/Task/Polynomial-regression/C/polynomial-regression-3.c new file mode 100644 index 0000000000..527fdaa027 --- /dev/null +++ b/Task/Polynomial-regression/C/polynomial-regression-3.c @@ -0,0 +1,21 @@ +#include + +#include "polifitgsl.h" + +#define NP 11 +double x[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; +double y[] = {1, 6, 17, 34, 57, 86, 121, 162, 209, 262, 321}; + +#define DEGREE 3 +double coeff[DEGREE]; + +int main() +{ + int i; + + polynomialfit(NP, DEGREE, x, y, coeff); + for(i=0; i < DEGREE; i++) { + printf("%lf\n", coeff[i]); + } + return 0; +} diff --git a/Task/Polynomial-regression/Common-Lisp/polynomial-regression-1.lisp b/Task/Polynomial-regression/Common-Lisp/polynomial-regression-1.lisp new file mode 100644 index 0000000000..3e7d281a87 --- /dev/null +++ b/Task/Polynomial-regression/Common-Lisp/polynomial-regression-1.lisp @@ -0,0 +1,9 @@ +;; Least square fit of a polynomial of order n the x-y-curve. +(defun polyfit (x y n) + (let* ((m (cadr (array-dimensions x))) + (A (make-array `(,m ,(+ n 1)) :initial-element 0))) + (loop for i from 0 to (- m 1) do + (loop for j from 0 to n do + (setf (aref A i j) + (expt (aref x 0 i) j)))) + (lsqr A (mtp y)))) diff --git a/Task/Polynomial-regression/Common-Lisp/polynomial-regression-2.lisp b/Task/Polynomial-regression/Common-Lisp/polynomial-regression-2.lisp new file mode 100644 index 0000000000..3ebe64ebf7 --- /dev/null +++ b/Task/Polynomial-regression/Common-Lisp/polynomial-regression-2.lisp @@ -0,0 +1,5 @@ +(let ((x (make-array '(1 11) :initial-contents '((0 1 2 3 4 5 6 7 8 9 10)))) + (y (make-array '(1 11) :initial-contents '((1 6 17 34 57 86 121 162 209 262 321))))) + (polyfit x y 2)) + +#2A((0.9999999999999759d0) (2.000000000000005d0) (3.0d0)) diff --git a/Task/Polynomial-regression/Fortran/polynomial-regression-1.f b/Task/Polynomial-regression/Fortran/polynomial-regression-1.f new file mode 100644 index 0000000000..ffa627a10f --- /dev/null +++ b/Task/Polynomial-regression/Fortran/polynomial-regression-1.f @@ -0,0 +1,64 @@ +module fitting +contains + + function polyfit(vx, vy, d) + implicit none + integer, intent(in) :: d + integer, parameter :: dp = selected_real_kind(15, 307) + real(dp), dimension(d+1) :: polyfit + real(dp), dimension(:), intent(in) :: vx, vy + + real(dp), dimension(:,:), allocatable :: X + real(dp), dimension(:,:), allocatable :: XT + real(dp), dimension(:,:), allocatable :: XTX + + integer :: i, j + + integer :: n, lda, lwork + integer :: info + integer, dimension(:), allocatable :: ipiv + real(dp), dimension(:), allocatable :: work + + n = d+1 + lda = n + lwork = n + + allocate(ipiv(n)) + allocate(work(lwork)) + allocate(XT(n, size(vx))) + allocate(X(size(vx), n)) + allocate(XTX(n, n)) + + ! prepare the matrix + do i = 0, d + do j = 1, size(vx) + X(j, i+1) = vx(j)**i + end do + end do + + XT = transpose(X) + XTX = matmul(XT, X) + + ! calls to LAPACK subs DGETRF and DGETRI + call DGETRF(n, n, XTX, lda, ipiv, info) + if ( info /= 0 ) then + print *, "problem" + return + end if + call DGETRI(n, XTX, lda, ipiv, work, lwork, info) + if ( info /= 0 ) then + print *, "problem" + return + end if + + polyfit = matmul( matmul(XTX, XT), vy) + + deallocate(ipiv) + deallocate(work) + deallocate(X) + deallocate(XT) + deallocate(XTX) + + end function + +end module diff --git a/Task/Polynomial-regression/Fortran/polynomial-regression-2.f b/Task/Polynomial-regression/Fortran/polynomial-regression-2.f new file mode 100644 index 0000000000..de15da13d4 --- /dev/null +++ b/Task/Polynomial-regression/Fortran/polynomial-regression-2.f @@ -0,0 +1,19 @@ +program PolynomalFitting + use fitting + implicit none + + ! let us test it + integer, parameter :: degree = 2 + integer, parameter :: dp = selected_real_kind(15, 307) + integer :: i + real(dp), dimension(11) :: x = (/ (i,i=0,10) /) + real(dp), dimension(11) :: y = (/ 1, 6, 17, 34, & + 57, 86, 121, 162, & + 209, 262, 321 /) + real(dp), dimension(degree+1) :: a + + a = polyfit(x, y, degree) + + write (*, '(F9.4)') a + +end program diff --git a/Task/Polynomial-regression/GAP/polynomial-regression.gap b/Task/Polynomial-regression/GAP/polynomial-regression.gap new file mode 100644 index 0000000000..76a6f155ac --- /dev/null +++ b/Task/Polynomial-regression/GAP/polynomial-regression.gap @@ -0,0 +1,12 @@ +PolynomialRegression := function(x, y, n) + local a; + a := List([0 .. n], i -> List(x, s -> s^i)); + return TransposedMat((a * TransposedMat(a))^-1 * a * TransposedMat([y]))[1]; +end; + +x := [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; +y := [1, 6, 17, 34, 57, 86, 121, 162, 209, 262, 321]; + +# Return coefficients in ascending degree order +PolynomialRegression(x, y, 2); +# [ 1, 2, 3 ] diff --git a/Task/Polynomial-regression/Go/polynomial-regression.go b/Task/Polynomial-regression/Go/polynomial-regression.go new file mode 100644 index 0000000000..f1003df554 --- /dev/null +++ b/Task/Polynomial-regression/Go/polynomial-regression.go @@ -0,0 +1,40 @@ +package main + +import ( + "code.google.com/p/gomatrix/matrix" + "fmt" +) + +var xGiven = []float64{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10} +var yGiven = []float64{1, 6, 17, 34, 57, 86, 121, 162, 209, 262, 321} +var degree = 2 + +func main() { + m := len(yGiven) + n := degree + 1 + y := matrix.MakeDenseMatrix(yGiven, m, 1) + x := matrix.Zeros(m, n) + for i := 0; i < m; i++ { + ip := float64(1) + for j := 0; j < n; j++ { + x.Set(i, j, ip) + ip *= xGiven[i] + } + } + + q, r := x.QR() + qty, err := q.Transpose().Times(y) + if err != nil { + fmt.Println(err) + return + } + c := make([]float64, n) + for i := n - 1; i >= 0; i-- { + c[i] = qty.Get(i, 0) + for j := i + 1; j < n; j++ { + c[i] -= c[j] * r.Get(i, j) + } + c[i] /= r.Get(i, i) + } + fmt.Println(c) +} diff --git a/Task/Polynomial-regression/Haskell/polynomial-regression-1.hs b/Task/Polynomial-regression/Haskell/polynomial-regression-1.hs new file mode 100644 index 0000000000..01bc6417f7 --- /dev/null +++ b/Task/Polynomial-regression/Haskell/polynomial-regression-1.hs @@ -0,0 +1,11 @@ +import Data.List +import Data.Array +import Control.Monad +import Control.Arrow +import Matrix.LU + +ppoly p x = map (x**) p + +polyfit d ry = elems $ solve mat vec where + mat = listArray ((1,1), (d,d)) $ liftM2 concatMap ppoly id [0..fromIntegral $ pred d] + vec = listArray (1,d) $ take d ry diff --git a/Task/Polynomial-regression/Haskell/polynomial-regression-2.hs b/Task/Polynomial-regression/Haskell/polynomial-regression-2.hs new file mode 100644 index 0000000000..bd93f3dedf --- /dev/null +++ b/Task/Polynomial-regression/Haskell/polynomial-regression-2.hs @@ -0,0 +1,2 @@ +*Main> polyfit 3 [1,6,17,34,57,86,121,162,209,262,321] +[1.0,2.0,3.0] diff --git a/Task/Polynomial-regression/HicEst/polynomial-regression-1.hicest b/Task/Polynomial-regression/HicEst/polynomial-regression-1.hicest new file mode 100644 index 0000000000..e31c893157 --- /dev/null +++ b/Task/Polynomial-regression/HicEst/polynomial-regression-1.hicest @@ -0,0 +1,15 @@ +REAL :: n=10, x(n), y(n), m=3, p(m) + + x = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10) + y = (1, 6, 17, 34, 57, 86, 121, 162, 209, 262, 321) + + p = 2 ! initial guess for the polynom's coefficients + + SOLVE(NUL=Theory()-y(nr), Unknown=p, DataIdx=nr, Iters=iterations) + + WRITE(ClipBoard, Name) p, iterations + +FUNCTION Theory() + ! called by the solver of the SOLVE function. All variables are global + Theory = p(1)*x(nr)^2 + p(2)*x(nr) + p(3) + END diff --git a/Task/Polynomial-regression/HicEst/polynomial-regression-2.hicest b/Task/Polynomial-regression/HicEst/polynomial-regression-2.hicest new file mode 100644 index 0000000000..f52ff606fd --- /dev/null +++ b/Task/Polynomial-regression/HicEst/polynomial-regression-2.hicest @@ -0,0 +1,2 @@ +SOLVE performs a (nonlinear) least-square fit (Levenberg-Marquardt): +p(1)=2.997135145; p(2)=2.011348347; p(3)=0.9906627242; iterations=19; diff --git a/Task/Polynomial-regression/J/polynomial-regression-1.j b/Task/Polynomial-regression/J/polynomial-regression-1.j new file mode 100644 index 0000000000..0f965a09f8 --- /dev/null +++ b/Task/Polynomial-regression/J/polynomial-regression-1.j @@ -0,0 +1,3 @@ + X=:i.# Y=:1 6 17 34 57 86 121 162 209 262 321 + Y (%. (^/ x:@i.@#)) X +1 2 3 0 0 0 0 0 0 0 0 diff --git a/Task/Polynomial-regression/J/polynomial-regression-2.j b/Task/Polynomial-regression/J/polynomial-regression-2.j new file mode 100644 index 0000000000..ab3867b90d --- /dev/null +++ b/Task/Polynomial-regression/J/polynomial-regression-2.j @@ -0,0 +1,2 @@ + Y (%. (i.3) ^/~ ]) X +1 2 3 diff --git a/Task/Polynomial-regression/MATLAB/polynomial-regression.m b/Task/Polynomial-regression/MATLAB/polynomial-regression.m new file mode 100644 index 0000000000..092e52ce0d --- /dev/null +++ b/Task/Polynomial-regression/MATLAB/polynomial-regression.m @@ -0,0 +1,7 @@ +>> x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; +>> y = [1, 6, 17, 34, 57, 86, 121, 162, 209, 262, 321]; +>> polyfit(x,y,2) + +ans = + + 2.999999999999998 2.000000000000019 0.999999999999956 diff --git a/Task/Polynomial-regression/Mathematica/polynomial-regression.math b/Task/Polynomial-regression/Mathematica/polynomial-regression.math new file mode 100644 index 0000000000..03a69754c8 --- /dev/null +++ b/Task/Polynomial-regression/Mathematica/polynomial-regression.math @@ -0,0 +1,2 @@ +data = Transpose@{Range[0, 10], {1, 6, 17, 34, 57, 86, 121, 162, 209, 262, 321}}; +Fit[data, {1, x, x^2}, x] diff --git a/Task/Polynomial-regression/Octave/polynomial-regression.octave b/Task/Polynomial-regression/Octave/polynomial-regression.octave new file mode 100644 index 0000000000..a55c7d74aa --- /dev/null +++ b/Task/Polynomial-regression/Octave/polynomial-regression.octave @@ -0,0 +1,3 @@ +x = [0:10]; +y = [1, 6, 17, 34, 57, 86, 121, 162, 209, 262, 321]; +coeffs = polyfit(x, y, 2) diff --git a/Task/Polynomial-regression/PARI-GP/polynomial-regression-1.pari b/Task/Polynomial-regression/PARI-GP/polynomial-regression-1.pari new file mode 100644 index 0000000000..7343243017 --- /dev/null +++ b/Task/Polynomial-regression/PARI-GP/polynomial-regression-1.pari @@ -0,0 +1 @@ +polinterpolate([0,1,2,3,4,5,6,7,8,9,10],[1,6,17,34,57,86,121,162,209,262,321]) diff --git a/Task/Polynomial-regression/PARI-GP/polynomial-regression-2.pari b/Task/Polynomial-regression/PARI-GP/polynomial-regression-2.pari new file mode 100644 index 0000000000..3e764b0e14 --- /dev/null +++ b/Task/Polynomial-regression/PARI-GP/polynomial-regression-2.pari @@ -0,0 +1,2 @@ +V=[1,6,17,34,57,86,121,162,209,262,321]~; +M=matrix(#V,3,i,j,(i-1)^(j-1));Polrev(matsolve(M~*M,M~*V)) diff --git a/Task/Polynomial-regression/Python/polynomial-regression-1.py b/Task/Polynomial-regression/Python/polynomial-regression-1.py new file mode 100644 index 0000000000..3a1a0a79a5 --- /dev/null +++ b/Task/Polynomial-regression/Python/polynomial-regression-1.py @@ -0,0 +1,5 @@ +>>> x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] +>>> y = [1, 6, 17, 34, 57, 86, 121, 162, 209, 262, 321] +>>> coeffs = numpy.polyfit(x,y,deg=2) +>>> coeffs +array([ 3., 2., 1.]) diff --git a/Task/Polynomial-regression/Python/polynomial-regression-2.py b/Task/Polynomial-regression/Python/polynomial-regression-2.py new file mode 100644 index 0000000000..c76e3f1c43 --- /dev/null +++ b/Task/Polynomial-regression/Python/polynomial-regression-2.py @@ -0,0 +1,3 @@ +>>> yf = numpy.polyval(numpy.poly1d(coeffs), x) +>>> yf +array([ 1., 6., 17., 34., 57., 86., 121., 162., 209., 262., 321.]) diff --git a/Task/Polynomial-regression/Python/polynomial-regression-3.py b/Task/Polynomial-regression/Python/polynomial-regression-3.py new file mode 100644 index 0000000000..b5aa8cbabd --- /dev/null +++ b/Task/Polynomial-regression/Python/polynomial-regression-3.py @@ -0,0 +1,2 @@ +>>> '%.1g' % max(y-yf) +'1e-013' diff --git a/Task/Polynomial-regression/Python/polynomial-regression-4.py b/Task/Polynomial-regression/Python/polynomial-regression-4.py new file mode 100644 index 0000000000..bc243ede67 --- /dev/null +++ b/Task/Polynomial-regression/Python/polynomial-regression-4.py @@ -0,0 +1,2 @@ +>>> x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] +>>> y = [2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0] diff --git a/Task/Polynomial-regression/Python/polynomial-regression-5.py b/Task/Polynomial-regression/Python/polynomial-regression-5.py new file mode 100644 index 0000000000..96132988f4 --- /dev/null +++ b/Task/Polynomial-regression/Python/polynomial-regression-5.py @@ -0,0 +1,4 @@ +>>> p = numpy.poly1d(numpy.polyfit(x, y, deg=2), variable='N') +>>> print p + 2 +1.085 N + 10.36 N - 0.6164 diff --git a/Task/Polynomial-regression/R/polynomial-regression-1.r b/Task/Polynomial-regression/R/polynomial-regression-1.r new file mode 100644 index 0000000000..2a646e259f --- /dev/null +++ b/Task/Polynomial-regression/R/polynomial-regression-1.r @@ -0,0 +1,3 @@ +x <- c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10) +y <- c(1, 6, 17, 34, 57, 86, 121, 162, 209, 262, 321) +coef(lm(y ~ x + I(x^2))) diff --git a/Task/Polynomial-regression/R/polynomial-regression-2.r b/Task/Polynomial-regression/R/polynomial-regression-2.r new file mode 100644 index 0000000000..b26e1fc746 --- /dev/null +++ b/Task/Polynomial-regression/R/polynomial-regression-2.r @@ -0,0 +1,2 @@ +(Intercept) x I(x^2) + 1 2 3 diff --git a/Task/Polynomial-regression/Ruby/polynomial-regression-1.rb b/Task/Polynomial-regression/Ruby/polynomial-regression-1.rb new file mode 100644 index 0000000000..65e8020258 --- /dev/null +++ b/Task/Polynomial-regression/Ruby/polynomial-regression-1.rb @@ -0,0 +1,10 @@ +require 'matrix' + +def regress x, y, degree + x_data = x.map { |xi| (0..degree).map { |pow| (xi**pow).to_f } } + + mx = Matrix[*x_data] + my = Matrix.column_vector(y) + + ((mx.t * mx).inv * mx.t * my).transpose.to_a[0] +end diff --git a/Task/Polynomial-regression/Ruby/polynomial-regression-2.rb b/Task/Polynomial-regression/Ruby/polynomial-regression-2.rb new file mode 100644 index 0000000000..c742b60fa3 --- /dev/null +++ b/Task/Polynomial-regression/Ruby/polynomial-regression-2.rb @@ -0,0 +1,5 @@ +betas = regress [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], + [1, 6, 17, 34, 57, 86, 121, 162, 209, 262, 321], + 2 + +p betas diff --git a/Task/Polynomial-regression/TI-89-BASIC/polynomial-regression.ti-89 b/Task/Polynomial-regression/TI-89-BASIC/polynomial-regression.ti-89 new file mode 100644 index 0000000000..82270b6052 --- /dev/null +++ b/Task/Polynomial-regression/TI-89-BASIC/polynomial-regression.ti-89 @@ -0,0 +1,5 @@ +DelVar x +seq(x,x,0,10) → xs +{1,6,17,34,57,86,121,162,209,262,321} → ys +QuadReg xs,ys +Disp regeq(x) diff --git a/Task/Polynomial-regression/Tcl/polynomial-regression.tcl b/Task/Polynomial-regression/Tcl/polynomial-regression.tcl new file mode 100644 index 0000000000..658e7dc94e --- /dev/null +++ b/Task/Polynomial-regression/Tcl/polynomial-regression.tcl @@ -0,0 +1,49 @@ +package require math::linearalgebra + +proc build.matrix {xvec degree} { + set sums [llength $xvec] + for {set i 1} {$i <= 2*$degree} {incr i} { + set sum 0 + foreach x $xvec { + set sum [expr {$sum + pow($x,$i)}] + } + lappend sums $sum + } + + set order [expr {$degree + 1}] + set A [math::linearalgebra::mkMatrix $order $order 0] + for {set i 0} {$i <= $degree} {incr i} { + set A [math::linearalgebra::setrow A $i [lrange $sums $i $i+$degree]] + } + return $A +} + +proc build.vector {xvec yvec degree} { + set sums [list] + for {set i 0} {$i <= $degree} {incr i} { + set sum 0 + foreach x $xvec y $yvec { + set sum [expr {$sum + $y * pow($x,$i)}] + } + lappend sums $sum + } + + set x [math::linearalgebra::mkVector [expr {$degree + 1}] 0] + for {set i 0} {$i <= $degree} {incr i} { + set x [math::linearalgebra::setelem x $i [lindex $sums $i]] + } + return $x +} + +# Now, to solve the example from the top of this page +set x {0 1 2 3 4 5 6 7 8 9 10} +set y {1 6 17 34 57 86 121 162 209 262 321} + +# build the system A.x=b +set degree 2 +set A [build.matrix $x $degree] +set b [build.vector $x $y $degree] +# solve it +set coeffs [math::linearalgebra::solveGauss $A $b] +# show results +puts $coeffs diff --git a/Task/Polynomial-regression/Ursala/polynomial-regression-1.ursala b/Task/Polynomial-regression/Ursala/polynomial-regression-1.ursala new file mode 100644 index 0000000000..c3609acde1 --- /dev/null +++ b/Task/Polynomial-regression/Ursala/polynomial-regression-1.ursala @@ -0,0 +1,5 @@ +#import std +#import nat +#import flo + +(fit "n") ("x","y") = ..dgelsd\"y" (gang \/*pow float*x iota successor "n")* "x" diff --git a/Task/Polynomial-regression/Ursala/polynomial-regression-2.ursala b/Task/Polynomial-regression/Ursala/polynomial-regression-2.ursala new file mode 100644 index 0000000000..92086feef3 --- /dev/null +++ b/Task/Polynomial-regression/Ursala/polynomial-regression-2.ursala @@ -0,0 +1,6 @@ +x = <0.,1.,2.,3.,4.,5.,6.,7.,8.,9.,10.> +y = <1.,6.,17.,34.,57.,86.,121.,162.,209.,262.,321.> + +#cast %eL + +example = fit2(x,y) diff --git a/Task/Power-set/0DESCRIPTION b/Task/Power-set/0DESCRIPTION new file mode 100644 index 0000000000..63529df894 --- /dev/null +++ b/Task/Power-set/0DESCRIPTION @@ -0,0 +1,6 @@ +A [[set]] is a collection (container) of certain values, without any particular order, and no repeated values. It corresponds with a finite set in mathematics. A set can be implemented as an associative array (partial mapping) in which the value of each key-value pair is ignored. + +Given a set S, the [[wp:Power_set|power set]] (or powerset) of S, written P(S), or 2S, is the set of all subsets of S.
+'''Task : ''' By using a library or build-in set type, or defining a set type with necessary operations, write a function with a set S as input that yields a power set 2S of S. + +For example, the power set of {1,2,3,4} is {{}, {1}, {2}, {1,2}, {3}, {1,3}, {2,3}, {1,2,3}, {4}, {1,4}, {2,4}, {1,2,4}, {3,4}, {1,3,4}, {2,3,4}, {1,2,3,4}}. diff --git a/Task/Power-set/1META.yaml b/Task/Power-set/1META.yaml new file mode 100644 index 0000000000..9e130e8a7b --- /dev/null +++ b/Task/Power-set/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Discrete math diff --git a/Task/Power-set/ALGOL-68/power-set.alg b/Task/Power-set/ALGOL-68/power-set.alg new file mode 100644 index 0000000000..abfc38c648 --- /dev/null +++ b/Task/Power-set/ALGOL-68/power-set.alg @@ -0,0 +1,27 @@ +MODE MEMBER = INT; + +PROC power set = ([]MEMBER s)[][]MEMBER:( + [2**UPB s]FLEX[1:0]MEMBER r; + INT upb r := 0; + r[upb r +:= 1] := []MEMBER(()); + FOR i TO UPB s DO + MEMBER e = s[i]; + FOR j TO upb r DO + [UPB r[j] + 1]MEMBER x; + x[:UPB x-1] := r[j]; + x[UPB x] := e; # append to the end of x # + r[upb r +:= 1] := x # append to end of r # + OD + OD; + r[upb r] := s; + r +); +# Example: # +test:( + [][]MEMBER set = power set((1, 2, 4)); + FOR member TO UPB set DO + INT upb = UPB set[member]; + FORMAT repr set = $"("f( upb=0 | $$ | $n(upb-1)(d", ")d$ )");"$; + printf(($"set["d"] = "$,member, repr set, set[member],$l$)) + OD +) diff --git a/Task/Power-set/Ada/power-set.ada b/Task/Power-set/Ada/power-set.ada new file mode 100644 index 0000000000..428cb3091b --- /dev/null +++ b/Task/Power-set/Ada/power-set.ada @@ -0,0 +1,84 @@ +with Ada.Text_IO; use Ada.Text_IO; + +procedure Power_Set is + type Universe is (A,B,C,D,E); + + -- The type Set are subsets of Universe + type Set is array (Universe) of Boolean; + Empty : constant Set := (others => False); + function Cardinality (X : Set) return Natural is + N : Natural := 0; + begin + for I in X'Range loop + if X (I) then + N := N + 1; + end if; + end loop; + return N; + end Cardinality; + function Element (X : Set; Position : Positive) return Universe is + N : Natural := 0; + begin + for I in X'Range loop + if X (I) then + N := N + 1; + if N = Position then + return I; + end if; + end if; + end loop; + raise Constraint_Error; + end Element; + procedure Put (X : Set) is + Empty : Boolean := True; + begin + for I in X'Range loop + if X (I) then + if Empty then + Empty := False; + Put (Universe'Image (I)); + else + Put ("," & Universe'Image (I)); + end if; + end if; + end loop; + if Empty then + Put ("empty"); + end if; + end Put; + + -- Set_Of_Set are sets of subsets of Universe + type Set_Of_Sets is array (Positive range <>) of Set; + + function Power (X : Set) return Set_Of_Sets is + Length : constant Natural := Cardinality (X); + Index : array (1..Length) of Integer := (others => 0); + Result : Set_Of_Sets (1..2**Length) := (others => Empty); + begin + for N in Result'Range loop + for I in 1..Length loop -- Index determines the sample N + exit when Index (I) = 0; + Result (N) (Element (X, Index (I))) := True; + end loop; + Next : for I in 1..Length loop -- Computing the index of the following sample + if Index (I) < Length then + Index (I) := Index (I) + 1; + if I = 1 or else Index (I - 1) > Index (I) then + for J in reverse 2..I loop + Index (J - 1) := Index (J) + 1; + end loop; + exit Next; + end if; + end if; + end loop Next; + end loop; + return Result; + end Power; + + P : Set_Of_Sets := Power ((A|C|E => True, others => False)); +begin + for I in P'Range loop + New_Line; + Put (P (I)); + end loop; +end Power_Set; diff --git a/Task/Power-set/AutoHotkey/power-set.ahk b/Task/Power-set/AutoHotkey/power-set.ahk new file mode 100644 index 0000000000..ba395936fb --- /dev/null +++ b/Task/Power-set/AutoHotkey/power-set.ahk @@ -0,0 +1,11 @@ +a = 1,a,-- ; elements separated by commas +StringSplit a, a, `, ; a0 = #elements, a1,a2,... = elements of the set + +t = { +Loop % (1<>A_Index-1) & 1 ? a%A_Index% "," : "" + t .= "}`n{" ; new subsets in new lines +} +MsgBox % RegExReplace(SubStr(t,1,StrLen(t)-1),",}","}") diff --git a/Task/Power-set/BBC-BASIC/power-set.bbc b/Task/Power-set/BBC-BASIC/power-set.bbc new file mode 100644 index 0000000000..5820a73340 --- /dev/null +++ b/Task/Power-set/BBC-BASIC/power-set.bbc @@ -0,0 +1,17 @@ + DIM list$(3) : list$() = "1", "2", "3", "4" + PRINT FNpowerset(list$()) + END + + DEF FNpowerset(list$()) + IF DIM(list$(),1) > 31 ERROR 100, "Set too large to represent as integer" + LOCAL i%, j%, s$ + s$ = "{" + FOR i% = 0 TO (2 << DIM(list$(),1)) - 1 + s$ += "{" + FOR j% = 0 TO DIM(list$(),1) + IF i% AND (1 << j%) s$ += list$(j%) + "," + NEXT + IF RIGHT$(s$) = "," s$ = LEFT$(s$) + s$ += "}," + NEXT i% + = LEFT$(s$) + "}" diff --git a/Task/Power-set/Burlesque/power-set.blq b/Task/Power-set/Burlesque/power-set.blq new file mode 100644 index 0000000000..5ec7690c23 --- /dev/null +++ b/Task/Power-set/Burlesque/power-set.blq @@ -0,0 +1,2 @@ +blsq ) {1 2 3 4}R@ +{{} {1} {2} {1 2} {3} {1 3} {2 3} {1 2 3} {4} {1 4} {2 4} {1 2 4} {3 4} {1 3 4} {2 3 4} {1 2 3 4}} diff --git a/Task/Power-set/C++/power-set-1.cpp b/Task/Power-set/C++/power-set-1.cpp new file mode 100644 index 0000000000..c0f0fdb62a --- /dev/null +++ b/Task/Power-set/C++/power-set-1.cpp @@ -0,0 +1,78 @@ +#include +#include +#include +#include +#include +typedef std::set set_type; +typedef std::set powerset_type; + +powerset_type powerset(set_type const& set) +{ + typedef set_type::const_iterator set_iter; + typedef std::vector vec; + typedef vec::iterator vec_iter; + + struct local + { + static int dereference(set_iter v) { return *v; } + }; + + powerset_type result; + + vec elements; + do + { + set_type tmp; + std::transform(elements.begin(), elements.end(), + std::inserter(tmp, tmp.end()), + local::dereference); + result.insert(tmp); + if (!elements.empty() && ++elements.back() == set.end()) + { + elements.pop_back(); + } + else + { + set_iter iter; + if (elements.empty()) + { + iter = set.begin(); + } + else + { + iter = elements.back(); + ++iter; + } + for (; iter != set.end(); ++iter) + { + elements.push_back(iter); + } + } + } while (!elements.empty()); + + return result; +} + +int main() +{ + int values[4] = { 2, 3, 5, 7 }; + set_type test_set(values, values+4); + + powerset_type test_powerset = powerset(test_set); + + for (powerset_type::iterator iter = test_powerset.begin(); + iter != test_powerset.end(); + ++iter) + { + std::cout << "{ "; + char const* prefix = ""; + for (set_type::iterator iter2 = iter->begin(); + iter2 != iter->end(); + ++iter2) + { + std::cout << prefix << *iter2; + prefix = ", "; + } + std::cout << " }\n"; + } +} diff --git a/Task/Power-set/C++/power-set-2.cpp b/Task/Power-set/C++/power-set-2.cpp new file mode 100644 index 0000000000..d16caef8b4 --- /dev/null +++ b/Task/Power-set/C++/power-set-2.cpp @@ -0,0 +1,25 @@ +#include +#include + +template std::set powerset(const Set& s, size_t n) +{ + typedef typename Set::const_iterator SetCIt; + typedef typename std::set::const_iterator PowerSetCIt; + std::set res; + if(n > 0) { + std::set ps = powerset(s, n-1); + for(PowerSetCIt ss = ps.begin(); ss != ps.end(); ss++) + for(SetCIt el = s.begin(); el != s.end(); el++) { + Set subset(*ss); + subset.insert(*el); + res.insert(subset); + } + res.insert(ps.begin(), ps.end()); + } else + res.insert(Set()); + return res; +} +template std::set powerset(const Set& s) +{ + return powerset(s, s.size()); +} diff --git a/Task/Power-set/C/power-set-1.c b/Task/Power-set/C/power-set-1.c new file mode 100644 index 0000000000..10dabb8cb5 --- /dev/null +++ b/Task/Power-set/C/power-set-1.c @@ -0,0 +1,28 @@ +#include +#include +#include + +static void powerset(int argc, char** argv) +{ + unsigned int i, j, bits, i_max = 1U << argc; + + if (argc >= sizeof(i) * CHAR_BIT) { + fprintf(stderr, "Error: set too large\n"); + exit(1); + } + + for (i = 0; i < i_max ; ++i) { + printf("{"); + for (bits = i, j = 0; bits; bits >>= 1, ++j) { + if (bits & 1) + printf(bits > 1 ? "%s, " : "%s", argv[j]); + } + printf("}\n"); + } +} + +int main(int argc, char* argv[]) +{ + powerset(argc - 1, argv + 1); + return 0; +} diff --git a/Task/Power-set/C/power-set-2.c b/Task/Power-set/C/power-set-2.c new file mode 100644 index 0000000000..17c01ecac3 --- /dev/null +++ b/Task/Power-set/C/power-set-2.c @@ -0,0 +1,17 @@ +% ./a.out 1 2 3 4 +{} +{1} +{2} +{1, 2} +{3} +{1, 3} +{2, 3} +{1, 2, 3} +{4} +{1, 4} +{2, 4} +{1, 2, 4} +{3, 4} +{1, 3, 4} +{2, 3, 4} +{1, 2, 3, 4} diff --git a/Task/Power-set/Clojure/power-set.clj b/Task/Power-set/Clojure/power-set.clj new file mode 100644 index 0000000000..95cb24d980 --- /dev/null +++ b/Task/Power-set/Clojure/power-set.clj @@ -0,0 +1,6 @@ +(use '[clojure.contrib.combinatorics :only [subsets] ]) + +(def S #{1 2 3 4}) + +user> (subsets S) +(() (1) (2) (3) (4) (1 2) (1 3) (1 4) (2 3) (2 4) (3 4) (1 2 3) (1 2 4) (1 3 4) (2 3 4) (1 2 3 4)) diff --git a/Task/Power-set/CoffeeScript/power-set-1.coffeescript b/Task/Power-set/CoffeeScript/power-set-1.coffeescript new file mode 100644 index 0000000000..84e0c78ee2 --- /dev/null +++ b/Task/Power-set/CoffeeScript/power-set-1.coffeescript @@ -0,0 +1,28 @@ +print_power_set = (arr) -> + console.log "POWER SET of #{arr}" + for subset in power_set(arr) + console.log subset + +power_set = (arr) -> + result = [] + binary = (false for elem in arr) + n = arr.length + while binary.length <= n + result.push bin_to_arr binary, arr + i = 0 + while true + if binary[i] + binary[i] = false + i += 1 + else + binary[i] = true + break + binary[i] = true + result + +bin_to_arr = (binary, arr) -> + (arr[i] for i of binary when binary[arr.length - i - 1]) + +print_power_set [] +print_power_set [4, 2, 1] +print_power_set ['dog', 'c', 'b', 'a'] diff --git a/Task/Power-set/CoffeeScript/power-set-2.coffeescript b/Task/Power-set/CoffeeScript/power-set-2.coffeescript new file mode 100644 index 0000000000..d688234b0a --- /dev/null +++ b/Task/Power-set/CoffeeScript/power-set-2.coffeescript @@ -0,0 +1,29 @@ +> coffee power_set.coffee +POWER SET of +[] +POWER SET of 4,2,1 +[] +[ 1 ] +[ 2 ] +[ 2, 1 ] +[ 4 ] +[ 4, 1 ] +[ 4, 2 ] +[ 4, 2, 1 ] +POWER SET of dog,c,b,a +[] +[ 'a' ] +[ 'b' ] +[ 'b', 'a' ] +[ 'c' ] +[ 'c', 'a' ] +[ 'c', 'b' ] +[ 'c', 'b', 'a' ] +[ 'dog' ] +[ 'dog', 'a' ] +[ 'dog', 'b' ] +[ 'dog', 'b', 'a' ] +[ 'dog', 'c' ] +[ 'dog', 'c', 'a' ] +[ 'dog', 'c', 'b' ] +[ 'dog', 'c', 'b', 'a' ] diff --git a/Task/Power-set/ColdFusion/power-set.cfm b/Task/Power-set/ColdFusion/power-set.cfm new file mode 100644 index 0000000000..343ddc0c6f --- /dev/null +++ b/Task/Power-set/ColdFusion/power-set.cfm @@ -0,0 +1,18 @@ +public array function powerset(required array data) +{ + var ps = [""]; + var d = arguments.data; + var lenData = arrayLen(d); + var lenPS = 0; + for (var i=1; i LTE lenData; i++) + { + lenPS = arrayLen(ps); + for (var j = 1; j LTE lenPS; j++) + { + arrayAppend(ps, listAppend(ps[j], d[i])); + } + } + return ps; +} + +var res = powerset([1,2,3,4]); diff --git a/Task/Power-set/Common-Lisp/power-set-1.lisp b/Task/Power-set/Common-Lisp/power-set-1.lisp new file mode 100644 index 0000000000..189040c4f0 --- /dev/null +++ b/Task/Power-set/Common-Lisp/power-set-1.lisp @@ -0,0 +1,8 @@ +(defun power-set (s) + (reduce #'(lambda (item ps) + (append (mapcar #'(lambda (e) (cons item e)) + ps) + ps)) + s + :from-end t + :initial-value '(()))) diff --git a/Task/Power-set/Common-Lisp/power-set-2.lisp b/Task/Power-set/Common-Lisp/power-set-2.lisp new file mode 100644 index 0000000000..3c8dde6d8f --- /dev/null +++ b/Task/Power-set/Common-Lisp/power-set-2.lisp @@ -0,0 +1,6 @@ +(defun powerset (l) + (if (null l) + (list nil) + (let ((prev (powerset (cdr l)))) + (append (mapcar #'(lambda (elt) (cons (car l) elt)) prev) + prev)))) diff --git a/Task/Power-set/Common-Lisp/power-set-3.lisp b/Task/Power-set/Common-Lisp/power-set-3.lisp new file mode 100644 index 0000000000..a725ce72ea --- /dev/null +++ b/Task/Power-set/Common-Lisp/power-set-3.lisp @@ -0,0 +1,3 @@ +(defun powerset (xs) + (loop for i below (expt 2 (length xs)) collect + (loop for j below i for x in xs if (logbitp j i) collect x))) diff --git a/Task/Power-set/D/power-set.d b/Task/Power-set/D/power-set.d new file mode 100644 index 0000000000..650cc4d63a --- /dev/null +++ b/Task/Power-set/D/power-set.d @@ -0,0 +1,16 @@ +import std.stdio; + +T[][] powerSet(T)(in T[] s) pure nothrow { + auto r = new typeof(return)(1, 0); + foreach (e; s) { + typeof(return) rs; + foreach (x; r) + rs ~= x ~ [e]; + r ~= rs; + } + return r; +} + +void main() { + writeln(powerSet([1, 2, 3])); +} diff --git a/Task/Power-set/E/power-set.e b/Task/Power-set/E/power-set.e new file mode 100644 index 0000000000..7439670e7c --- /dev/null +++ b/Task/Power-set/E/power-set.e @@ -0,0 +1,9 @@ +pragma.enable("accumulator") + +def powerset(s) { + return accum [].asSet() for k in 0..!2**s.size() { + _.with(accum [].asSet() for i ? ((2**i & k) > 0) => elem in s { + _.with(elem) + }) + } +} diff --git a/Task/Power-set/Erlang/power-set-1.erl b/Task/Power-set/Erlang/power-set-1.erl new file mode 100644 index 0000000000..4a5e834edc --- /dev/null +++ b/Task/Power-set/Erlang/power-set-1.erl @@ -0,0 +1,5 @@ +powerset(Lst) -> + N = length(Lst), + Max = trunc(math:pow(2,N)), + [[lists:nth(Pos+1,Lst) || Pos <- lists:seq(0,N-1), I band (1 bsl Pos) =/= 0] + || I <- lists:seq(0,Max-1)]. diff --git a/Task/Power-set/Erlang/power-set-2.erl b/Task/Power-set/Erlang/power-set-2.erl new file mode 100644 index 0000000000..0315646d0c --- /dev/null +++ b/Task/Power-set/Erlang/power-set-2.erl @@ -0,0 +1,3 @@ +powerset([]) -> [[]]; +powerset([H|T]) -> PT = powerset(T), + [ [H|X] || X <- PT ] ++ PT. diff --git a/Task/Power-set/Erlang/power-set-3.erl b/Task/Power-set/Erlang/power-set-3.erl new file mode 100644 index 0000000000..91c6aaf747 --- /dev/null +++ b/Task/Power-set/Erlang/power-set-3.erl @@ -0,0 +1,6 @@ +powerset([]) -> [[]]; +powerset([H|T]) -> PT = powerset(T), + powerset(H, PT, PT). + +powerset(_, [], Acc) -> Acc; +powerset(X, [H|T], Acc) -> powerset(X, T, [[X|H]|Acc]). diff --git a/Task/Power-set/Factor/power-set-1.factor b/Task/Power-set/Factor/power-set-1.factor new file mode 100644 index 0000000000..8122180122 --- /dev/null +++ b/Task/Power-set/Factor/power-set-1.factor @@ -0,0 +1,5 @@ +USING: kernel prettyprint sequences arrays sets hash-sets ; +IN: powerset + +: add ( set elt -- newset ) 1array union ; +: powerset ( set -- newset ) members { HS{ } } [ dupd [ add ] curry map append ] reduce ; diff --git a/Task/Power-set/Factor/power-set-2.factor b/Task/Power-set/Factor/power-set-2.factor new file mode 100644 index 0000000000..a54f17e5c1 --- /dev/null +++ b/Task/Power-set/Factor/power-set-2.factor @@ -0,0 +1,19 @@ +( scratchpad ) HS{ 1 2 3 4 } powerset . +HS{ + HS{ 1 2 3 4 } + HS{ 1 2 } + HS{ 1 3 } + HS{ 2 3 } + HS{ 1 2 3 } + HS{ 1 4 } + HS{ 2 4 } + HS{ } + HS{ 1 } + HS{ 2 } + HS{ 3 } + HS{ 4 } + HS{ 1 2 4 } + HS{ 3 4 } + HS{ 1 3 4 } + HS{ 2 3 4 } +} diff --git a/Task/Power-set/Forth/power-set.fth b/Task/Power-set/Forth/power-set.fth new file mode 100644 index 0000000000..785cfa19e3 --- /dev/null +++ b/Task/Power-set/Forth/power-set.fth @@ -0,0 +1,8 @@ +: ?print dup 1 and if over args type space then ; +: .set begin dup while ?print >r 1+ r> 1 rshift repeat drop drop ; +: .powerset 0 do ." ( " 1 i .set ." )" cr loop ; +: check-none dup 2 < abort" Usage: powerset [val] .. [val]" ; +: check-size dup /cell 8 [*] >= abort" Set too large" ; +: powerset 1 argn check-none check-size 1- lshift .powerset ; + +powerset diff --git a/Task/Power-set/Frink/power-set.frink b/Task/Power-set/Frink/power-set.frink new file mode 100644 index 0000000000..bf3607e4fc --- /dev/null +++ b/Task/Power-set/Frink/power-set.frink @@ -0,0 +1,2 @@ +a = new set[1,2,3,4] +a.subsets[] diff --git a/Task/Power-set/GAP/power-set.gap b/Task/Power-set/GAP/power-set.gap new file mode 100644 index 0000000000..5edf5dbe42 --- /dev/null +++ b/Task/Power-set/GAP/power-set.gap @@ -0,0 +1,8 @@ +# Built-in +Combinations([1, 2, 3]); +# [ [ ], [ 1 ], [ 1, 2 ], [ 1, 2, 3 ], [ 1, 3 ], [ 2 ], [ 2, 3 ], [ 3 ] ] + +# Note that it handles duplicates +Combinations([1, 2, 3, 1]); +# [ [ ], [ 1 ], [ 1, 1 ], [ 1, 1, 2 ], [ 1, 1, 2, 3 ], [ 1, 1, 3 ], [ 1, 2 ], [ 1, 2, 3 ], [ 1, 3 ], +# [ 2 ], [ 2, 3 ], [ 3 ] ] diff --git a/Task/Power-set/Go/power-set.go b/Task/Power-set/Go/power-set.go new file mode 100644 index 0000000000..8b6435393a --- /dev/null +++ b/Task/Power-set/Go/power-set.go @@ -0,0 +1,106 @@ +package main + +import ( + "fmt" + "strconv" +) + +// types needed to implement general purpose sets are element and set + +// element is an interface, allowing different kinds of elements to be +// implemented and stored in sets. +type element interface { + // an element must be disinguishable from other elements to satisfy + // the mathematical definition of a set. a.eq(b) must give the same + // result as b.eq(a). + eq(element) bool + // String result is used only for printable output. Given a, b where + // a.eq(b), it is not required that a.String() == b.String(). + String() string +} + +// integer type satisfying element interface +type intEle int + +func (i intEle) eq(e element) bool { + if j, ok := e.(intEle); ok { + return i == j + } + return false +} + +func (i intEle) String() string { + return strconv.Itoa(int(i)) +} + +// set type implemented as a simple list. methods will be added to +// make it satisfy the element interface, allowing sets of sets. +type set []element + +// uniqueness of elements can be ensured by using add method +func (s *set) add(e element) { + for _, ex := range *s { + if e.eq(ex) { + return + } + } + *s = append(*s, e) +} + +// method to satify element interface +func (s set) eq(e element) bool { + t, ok := e.(set) + if !ok { + return false + } + if len(s) != len(t) { + return false + } +sLoop: + for _, se := range s { + for _, te := range t { + if se.eq(te) { + continue sLoop + } + return false + } + } + return true +} + +// method to satify element interface +func (s set) String() string { + r := "{" + for _, e := range s { + if len(r) > 1 { + r += " " + } + r += fmt.Sprint(e) + } + return r + "}" +} + +// method required for task +func (s set) powerSet() set { + r := set{set{}} + for _, es := range s { + var u set + for _, er := range r { + u = append(u, append(er.(set), es)) + } + r = append(r, u...) + } + return r +} + +func main() { + var s set + for _, i := range []int{1, 2, 2, 3, 4, 4, 4} { + s.add(intEle(i)) + } + fmt.Println(s) + fmt.Println("length =", len(s)) + ps := s.powerSet() + fmt.Println(ps) + fmt.Println("length =", len(ps)) +} diff --git a/Task/Power-set/Groovy/power-set-1.groovy b/Task/Power-set/Groovy/power-set-1.groovy new file mode 100644 index 0000000000..379ad0aea4 --- /dev/null +++ b/Task/Power-set/Groovy/power-set-1.groovy @@ -0,0 +1,14 @@ +def comb +comb = { m, List list -> + def n = list.size() + m == 0 ? + [[]] : + (0..(n-m)).inject([]) { newlist, k -> + def sublist = (k+1 == n) ? [] : list[(k+1).. + (0..(set.size())).inject([]){ list, i -> list + comb(i,set as List)}.collect { it as LinkedHashSet } as LinkedHashSet +} diff --git a/Task/Power-set/Groovy/power-set-2.groovy b/Task/Power-set/Groovy/power-set-2.groovy new file mode 100644 index 0000000000..37984ed947 --- /dev/null +++ b/Task/Power-set/Groovy/power-set-2.groovy @@ -0,0 +1,3 @@ +def vocalists = [ "C", "S", "N", "Y" ] as LinkedHashSet +println "${vocalists}" +println powerSet(vocalists) diff --git a/Task/Power-set/Haskell/power-set-1.hs b/Task/Power-set/Haskell/power-set-1.hs new file mode 100644 index 0000000000..c09ea4067d --- /dev/null +++ b/Task/Power-set/Haskell/power-set-1.hs @@ -0,0 +1,8 @@ +import Data.Set +import Control.Monad + +powerset :: Ord a => Set a -> Set (Set a) +powerset = fromList . fmap fromList . listPowerset . toList + +listPowerset :: [a] -> [[a]] +listPowerset = filterM (const [True, False]) diff --git a/Task/Power-set/Haskell/power-set-2.hs b/Task/Power-set/Haskell/power-set-2.hs new file mode 100644 index 0000000000..640f561638 --- /dev/null +++ b/Task/Power-set/Haskell/power-set-2.hs @@ -0,0 +1,2 @@ +powerset [] = [[]] +powerset (head:tail) = acc ++ map (head:) acc where acc = powerset tail diff --git a/Task/Power-set/Haskell/power-set-3.hs b/Task/Power-set/Haskell/power-set-3.hs new file mode 100644 index 0000000000..5e532572a9 --- /dev/null +++ b/Task/Power-set/Haskell/power-set-3.hs @@ -0,0 +1 @@ +powerset = foldr (\x acc -> acc ++ map (x:) acc) [[]] diff --git a/Task/Power-set/Haskell/power-set-4.hs b/Task/Power-set/Haskell/power-set-4.hs new file mode 100644 index 0000000000..e4c027f567 --- /dev/null +++ b/Task/Power-set/Haskell/power-set-4.hs @@ -0,0 +1,15 @@ +import qualified Data.Set as Set +type Set=Set.Set +unionAll :: (Ord a) => Set (Set a) -> Set a +unionAll = Set.fold Set.union Set.empty + +--slift is the analogue of liftA2 for sets. +slift :: (Ord a, Ord b, Ord c) => (a->b->c) -> Set a -> Set b -> Set c +slift f s0 s1 = unionAll (Set.map (\e->Set.map (f e) s1) s0) + +--a -> {{},{a}} +makeSet :: (Ord a) => a -> Set (Set a) +makeSet = (Set.insert Set.empty) . Set.singleton.Set.singleton + +powerSet :: (Ord a) => Set a -> Set (Set a) +powerSet = (Set.fold (slift Set.union) (Set.singleton Set.empty)) . Set.map makeSet diff --git a/Task/Power-set/Haskell/power-set-5.hs b/Task/Power-set/Haskell/power-set-5.hs new file mode 100644 index 0000000000..c34a0f14a8 --- /dev/null +++ b/Task/Power-set/Haskell/power-set-5.hs @@ -0,0 +1,2 @@ +Prelude Data.Set> powerSet fromList [1,2,3] +fromList [fromList [], fromList [1], fromList [1,2], fromList [1,2,3], fromList [1,3], fromList [2], fromList [2,3], fromList [3]] diff --git a/Task/Power-set/Icon/power-set-1.icon b/Task/Power-set/Icon/power-set-1.icon new file mode 100644 index 0000000000..a2502fa760 --- /dev/null +++ b/Task/Power-set/Icon/power-set-1.icon @@ -0,0 +1,14 @@ +procedure power_set (s) + result := set () + if *s = 0 + then insert (result, set ()) # empty set + else { + head := set(?s) # take a random element + # and find powerset of remaining part of set + tail_pset := power_set (x -- head) + result ++:= tail_pset # add powerset of remainder to results + every ps := !tail_pset do # and add head to each powerset from the remainder + insert (result, ps ++ head) + } + return result +end diff --git a/Task/Power-set/Icon/power-set-2.icon b/Task/Power-set/Icon/power-set-2.icon new file mode 100644 index 0000000000..fda8d9c822 --- /dev/null +++ b/Task/Power-set/Icon/power-set-2.icon @@ -0,0 +1,7 @@ +procedure main () + every s := !power_set (set(1,2,3,4)) do { # requires '!' to generate items in the result set + writes ("[ ") + every writes (!s || " ") + write ("]") + } +end diff --git a/Task/Power-set/Icon/power-set-3.icon b/Task/Power-set/Icon/power-set-3.icon new file mode 100644 index 0000000000..6741600d14 --- /dev/null +++ b/Task/Power-set/Icon/power-set-3.icon @@ -0,0 +1,19 @@ +procedure power_set (s) + if *s = 0 + then suspend set () + else { + head := set(?s) + every ps := power_set (s -- head) do { + suspend ps + suspend ps ++ head + } + } +end + +procedure main () + every s := power_set (set(1,2,3,4)) do { # power_set's values are generated by 'every' + writes ("[ ") + every writes (!s || " ") + write ("]") + } +end diff --git a/Task/Power-set/J/power-set-1.j b/Task/Power-set/J/power-set-1.j new file mode 100644 index 0000000000..f6baf1d467 --- /dev/null +++ b/Task/Power-set/J/power-set-1.j @@ -0,0 +1 @@ +ps =: #~ 2 #:@i.@^ # diff --git a/Task/Power-set/J/power-set-2.j b/Task/Power-set/J/power-set-2.j new file mode 100644 index 0000000000..54ee199700 --- /dev/null +++ b/Task/Power-set/J/power-set-2.j @@ -0,0 +1,9 @@ + ps 'ACE' + +E +C +CE +A +AE +AC +ACE diff --git a/Task/Power-set/J/power-set-3.j b/Task/Power-set/J/power-set-3.j new file mode 100644 index 0000000000..a6f1743bc7 --- /dev/null +++ b/Task/Power-set/J/power-set-3.j @@ -0,0 +1,6 @@ + ~.1 2 3 2 1 +1 2 3 + #ps 1 2 3 2 1 +32 + #ps ~.1 2 3 2 1 +8 diff --git a/Task/Power-set/Java/power-set-1.java b/Task/Power-set/Java/power-set-1.java new file mode 100644 index 0000000000..8b9f365407 --- /dev/null +++ b/Task/Power-set/Java/power-set-1.java @@ -0,0 +1,25 @@ +public static ArrayList getpowerset(int a[],int n,ArrayList ps) + { + if(n<0) + { + return null; + } + if(n==0) + { + if(ps==null) + ps=new ArrayList(); + ps.add(" "); + return ps; + } + ps=getpowerset(a, n-1, ps); + ArrayList tmp=new ArrayList(); + for(String s:ps) + { + if(s.equals(" ")) + tmp.add(""+a[n-1]); + else + tmp.add(s+a[n-1]); + } + ps.addAll(tmp); + return ps; + } diff --git a/Task/Power-set/Java/power-set-2.java b/Task/Power-set/Java/power-set-2.java new file mode 100644 index 0000000000..dc47fe6ffa --- /dev/null +++ b/Task/Power-set/Java/power-set-2.java @@ -0,0 +1,23 @@ +public static List> powerset(Collection list) { + List> ps = new ArrayList>(); + ps.add(new ArrayList()); // add the empty set + + // for every item in the original list + for (T item : list) { + List> newPs = new ArrayList>(); + + for (List subset : ps) { + // copy all of the current powerset's subsets + newPs.add(subset); + + // plus the subsets appended with the current item + List newSubset = new ArrayList(subset); + newSubset.add(item); + newPs.add(newSubset); + } + + // powerset is now powerset of list.subList(0, list.indexOf(item)+1) + ps = newPs; + } + return ps; +} diff --git a/Task/Power-set/Java/power-set-3.java b/Task/Power-set/Java/power-set-3.java new file mode 100644 index 0000000000..5efb15a167 --- /dev/null +++ b/Task/Power-set/Java/power-set-3.java @@ -0,0 +1,16 @@ +public static > LinkedList> BinPowSet( + LinkedList A){ + LinkedList> ans= new LinkedList>(); + int ansSize = (int)Math.pow(2, A.size()); + for(Integer i= 0;i< ansSize;++i){ + String bin= Integer.toString(i, 2); //convert to binary + while(bin.length() < A.size())bin = "0" + bin; //pad with 0's + LinkedList thisComb = new LinkedList(); //place to put one combination + for(int j= 0;j< A.size();++j){ + if(bin.charAt(j) == '1')thisComb.add(A.get(j)); + } + Collections.sort(thisComb); //sort it for easy checking + ans.add(thisComb); //put this set in the answer list + } + return ans; +} diff --git a/Task/Power-set/JavaScript/power-set.js b/Task/Power-set/JavaScript/power-set.js new file mode 100644 index 0000000000..9a8d308222 --- /dev/null +++ b/Task/Power-set/JavaScript/power-set.js @@ -0,0 +1,14 @@ +function powerset(ary) { + var ps = [[]]; + for (var i=0; i < ary.length; i++) { + for (var j = 0, len = ps.length; j < len; j++) { + ps.push(ps[j].concat(ary[i])); + } + } + return ps; +} + +var res = powerset([1,2,3,4]); + +load('json2.js'); +print(JSON.stringify(res)); diff --git a/Task/Power-set/K/power-set-1.k b/Task/Power-set/K/power-set-1.k new file mode 100644 index 0000000000..2dc20e99d9 --- /dev/null +++ b/Task/Power-set/K/power-set-1.k @@ -0,0 +1 @@ + ps:{x@&:'+2_vs!_2^#x} diff --git a/Task/Power-set/K/power-set-2.k b/Task/Power-set/K/power-set-2.k new file mode 100644 index 0000000000..1614e22b6c --- /dev/null +++ b/Task/Power-set/K/power-set-2.k @@ -0,0 +1,9 @@ + ps "ABC" +("" + ,"C" + ,"B" + "BC" + ,"A" + "AC" + "AB" + "ABC") diff --git a/Task/Power-set/Logo/power-set.logo b/Task/Power-set/Logo/power-set.logo new file mode 100644 index 0000000000..2d46fdae7e --- /dev/null +++ b/Task/Power-set/Logo/power-set.logo @@ -0,0 +1,8 @@ +to powerset :set + if empty? :set [output [[]]] + localmake "rest powerset butfirst :set + output sentence map [sentence first :set ?] :rest :rest +end + +show powerset [1 2 3] +[[1 2 3] [1 2] [1 3] [1] [2 3] [2] [3] []] diff --git a/Task/Power-set/Logtalk/power-set-1.logtalk b/Task/Power-set/Logtalk/power-set-1.logtalk new file mode 100644 index 0000000000..c49c0a1556 --- /dev/null +++ b/Task/Power-set/Logtalk/power-set-1.logtalk @@ -0,0 +1,25 @@ +:- object(set). + + :- public(powerset/2). + + powerset(Set, PowerSet) :- + reverse(Set, RSet), + powerset_1(RSet, [[]], PowerSet). + + powerset_1([], PowerSet, PowerSet). + powerset_1([X| Xs], Yss0, Yss) :- + powerset_2(Yss0, X, Yss1), + powerset_1(Xs, Yss1, Yss). + + powerset_2([], _, []). + powerset_2([Zs| Zss], X, [Zs, [X| Zs]| Yss]) :- + powerset_2(Zss, X, Yss). + + reverse(List, Reversed) :- + reverse(List, [], Reversed). + + reverse([], Reversed, Reversed). + reverse([Head| Tail], List, Reversed) :- + reverse(Tail, [Head| List], Reversed). + +:- end_object. diff --git a/Task/Power-set/Logtalk/power-set-2.logtalk b/Task/Power-set/Logtalk/power-set-2.logtalk new file mode 100644 index 0000000000..66085f5ec9 --- /dev/null +++ b/Task/Power-set/Logtalk/power-set-2.logtalk @@ -0,0 +1,4 @@ +| ?- set::powerset([1, 2, 3, 4], PowerSet). + +PowerSet = [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3],[4],[1,4],[2,4],[1,2,4],[3,4],[1,3,4],[2,3,4],[1,2,3,4]] +yes diff --git a/Task/Power-set/Lua/power-set.lua b/Task/Power-set/Lua/power-set.lua new file mode 100644 index 0000000000..611e62f30c --- /dev/null +++ b/Task/Power-set/Lua/power-set.lua @@ -0,0 +1,33 @@ +--returns the powerset of s, out of order. +function powerset(s, start) + start = start or 1 + if(start > #s) then return {{}} end + local ret = powerset(s, start + 1) + for i = 1, #ret do + ret[#ret + 1] = {s[start], unpack(ret[i])} + end + return ret +end + +--non-recurse implementation +function powerset(s) + local t = {{}} + for i = 1, #s do + for j = 1, #t do + t[#t+1] = {s[i],unpack(t[j])} + end + end + return t +end + +--alternative, copied from the Python implementation +function powerset2(s) + local ret = {{}} + for i = 1, #s do + local k = #ret + for j = 1, k do + ret[k + j] = {s[i], unpack(ret[j])} + end + end + return ret +end diff --git a/Task/Power-set/M4/power-set.m4 b/Task/Power-set/M4/power-set.m4 new file mode 100644 index 0000000000..dd7ca72a9a --- /dev/null +++ b/Task/Power-set/M4/power-set.m4 @@ -0,0 +1,22 @@ +define(`for', + `ifelse($#, 0, ``$0'', + eval($2 <= $3), 1, + `pushdef(`$1', `$2')$4`'popdef( + `$1')$0(`$1', incr($2), $3, `$4')')')dnl +define(`nth', + `ifelse($1, 1, $2, + `nth(decr($1), shift(shift($@)))')')dnl +define(`range', + `for(`x', eval($1 + 2), eval($2 + 2), + `nth(x, $@)`'ifelse(x, eval($2+2), `', `,')')')dnl +define(`powerpart', + `{range(2, incr($1), $@)}`'ifelse(incr($1), $#, `', + `for(`x', eval($1+2), $#, + `,powerpart(incr($1), ifelse( + eval(2 <= ($1 + 1)), 1, + `range(2,incr($1), $@), ')`'nth(x, $@)`'ifelse( + eval((x + 1) <= $#),1,`,range(incr(x), $#, $@)'))')')')dnl +define(`powerset', + `{powerpart(0, substr(`$1', 1, eval(len(`$1') - 2)))}')dnl +dnl +powerset(`{a,b,c}') diff --git a/Task/Power-set/MATLAB/power-set-1.m b/Task/Power-set/MATLAB/power-set-1.m new file mode 100644 index 0000000000..739c9f6303 --- /dev/null +++ b/Task/Power-set/MATLAB/power-set-1.m @@ -0,0 +1,18 @@ +function pset = powerset(theSet) + + pset = cell(size(theSet)); %Preallocate memory + + %Generate all numbers from 0 to 2^(num elements of the set)-1 + for i = ( 0:(2^numel(theSet))-1 ) + + %Convert i into binary, convert each digit in binary to a boolean + %and store that array of booleans + indicies = logical(bitget( i,(1:numel(theSet)) )); + + %Use the array of booleans to extract the members of the original + %set, and store the set containing these members in the powerset + pset(i+1) = {theSet(indicies)}; + + end + +end diff --git a/Task/Power-set/MATLAB/power-set-2.m b/Task/Power-set/MATLAB/power-set-2.m new file mode 100644 index 0000000000..223c450fb9 --- /dev/null +++ b/Task/Power-set/MATLAB/power-set-2.m @@ -0,0 +1,5 @@ +powerset({{}}) + +ans = + + {} {1x1 cell} %This is the same as { {},{{}} } diff --git a/Task/Power-set/MATLAB/power-set-3.m b/Task/Power-set/MATLAB/power-set-3.m new file mode 100644 index 0000000000..fa6f509aa5 --- /dev/null +++ b/Task/Power-set/MATLAB/power-set-3.m @@ -0,0 +1,5 @@ +powerset({{1,2},3}) + +ans = + + {1x0 cell} {1x1 cell} {1x1 cell} {1x2 cell} %This is the same as { {},{{1,2}},{3},{{1,2},3} } diff --git a/Task/Power-set/Mathematica/power-set-1.math b/Task/Power-set/Mathematica/power-set-1.math new file mode 100644 index 0000000000..cb0d66d08d --- /dev/null +++ b/Task/Power-set/Mathematica/power-set-1.math @@ -0,0 +1 @@ +Subsets[{a, b, c}] diff --git a/Task/Power-set/Mathematica/power-set-2.math b/Task/Power-set/Mathematica/power-set-2.math new file mode 100644 index 0000000000..e1fa611cda --- /dev/null +++ b/Task/Power-set/Mathematica/power-set-2.math @@ -0,0 +1 @@ +{{}, {a}, {b}, {c}, {a, b}, {a, c}, {b, c}, {a, b, c}} diff --git a/Task/Power-set/Maxima/power-set.maxima b/Task/Power-set/Maxima/power-set.maxima new file mode 100644 index 0000000000..737be46133 --- /dev/null +++ b/Task/Power-set/Maxima/power-set.maxima @@ -0,0 +1,3 @@ +powerset({1, 2, 3, 4}); +/* {{}, {1}, {1, 2}, {1, 2, 3}, {1, 2, 3, 4}, {1, 2, 4}, {1, 3}, {1, 3, 4}, + {1, 4}, {2}, {2, 3}, {2, 3, 4}, {2, 4}, {3}, {3, 4}, {4}} */ diff --git a/Task/Power-set/OCaml/power-set-1.ocaml b/Task/Power-set/OCaml/power-set-1.ocaml new file mode 100644 index 0000000000..79f9d7a345 --- /dev/null +++ b/Task/Power-set/OCaml/power-set-1.ocaml @@ -0,0 +1,17 @@ +module PowerSet(S: Set.S) = +struct + + include Set.Make (S) + + let map f s = + let work x r = add (f x) r in + fold work s empty + ;; + + let powerset s = + let base = singleton (S.empty) in + let work x r = union r (map (S.add x) r) in + S.fold work s base + ;; + +end;; (* PowerSet *) diff --git a/Task/Power-set/OCaml/power-set-2.ocaml b/Task/Power-set/OCaml/power-set-2.ocaml new file mode 100644 index 0000000000..3263a3c2b8 --- /dev/null +++ b/Task/Power-set/OCaml/power-set-2.ocaml @@ -0,0 +1 @@ +let subsets xs = List.fold_right (fun x rest -> rest @ List.map (fun ys -> x::ys) rest) xs [[]] diff --git a/Task/Power-set/Objective-C/power-set.m b/Task/Power-set/Objective-C/power-set.m new file mode 100644 index 0000000000..7fe7db7afb --- /dev/null +++ b/Task/Power-set/Objective-C/power-set.m @@ -0,0 +1,17 @@ +#import + ++ (NSArray *)powerSetForArray:(NSArray *)array { + UInt32 subsetCount = 1 << array.count; + NSMutableArray *subsets = [NSMutableArray arrayWithCapacity:subsetCount]; + for(int subsetIndex = 0; subsetIndex < subsetCount; subsetIndex++) { + NSMutableArray *subset = [[NSMutableArray alloc] init]; + for (int itemIndex = 0; itemIndex < array.count; itemIndex++) { + if((subsetIndex >> itemIndex) & 0x1) { + [subset addObject:[array objectAtIndex:itemIndex]]; + } + } + [subsets addObject:subset]; + [subset release]; + } + return subsets; +} diff --git a/Task/Power-set/Oz/power-set-1.oz b/Task/Power-set/Oz/power-set-1.oz new file mode 100644 index 0000000000..655f76f6e9 --- /dev/null +++ b/Task/Power-set/Oz/power-set-1.oz @@ -0,0 +1,16 @@ +declare + %% Given a set as a list, returns its powerset (again as a list) + fun {Powerset Set} + proc {Describe Root} + %% Describe sets by lower bound (nil) and upper bound (Set) + Root = {FS.var.bounds nil Set} + %% enumerate all possible sets + {FS.distribute naive [Root]} + end + AllSets = {SearchAll Describe} + in + %% convert to list representation + {Map AllSets FS.reflect.lowerBoundList} + end +in + {Inspect {Powerset [1 2 3 4]}} diff --git a/Task/Power-set/Oz/power-set-2.oz b/Task/Power-set/Oz/power-set-2.oz new file mode 100644 index 0000000000..9de078c9cd --- /dev/null +++ b/Task/Power-set/Oz/power-set-2.oz @@ -0,0 +1,8 @@ +fun {Powerset2 Set} + case Set of nil then [nil] + [] H|T thens + Acc = {Powerset2 T} + in + {Append Acc {Map Acc fun {$ A} H|A end}} + end +end diff --git a/Task/Power-set/PARI-GP/power-set.pari b/Task/Power-set/PARI-GP/power-set.pari new file mode 100644 index 0000000000..081986e26a --- /dev/null +++ b/Task/Power-set/PARI-GP/power-set.pari @@ -0,0 +1 @@ +vector(1<<#S,i,vecextract(S,i-1)) diff --git a/Task/Power-set/PHP/power-set-1.php b/Task/Power-set/PHP/power-set-1.php new file mode 100644 index 0000000000..990f484e0a --- /dev/null +++ b/Task/Power-set/PHP/power-set-1.php @@ -0,0 +1,59 @@ + 0) { + echo join(" ", $arr); + } else { + echo "(empty)"; + } + echo '
'; +} + +function print_power_sets($arr) { + echo "POWER SET of [" . join(", ", $arr) . "]
"; + foreach (power_set($arr) as $subset) { + print_array($subset); + } +} + +function power_set($arr) { + $binary = array(); + foreach (range(1, count($arr)) as $i) { + $binary[] = false; + } + $n = count($arr); + $powerset = array(); + + while (count($binary) <= count($arr)) { + $powerset[] = get_subset($binary, $arr); + $i = 0; + while (true) { + if ($binary[$i]) { + $binary[$i] = false; + $i += 1; + } else { + $binary[$i] = true; + break; + } + } + $binary[$i] = true; + } + + return $powerset; +} + +print_power_sets(array()); +print_power_sets(array('singleton')); +print_power_sets(array('dog', 'c', 'b', 'a')); +?> diff --git a/Task/Power-set/PHP/power-set-2.php b/Task/Power-set/PHP/power-set-2.php new file mode 100644 index 0000000000..e2461ae23a --- /dev/null +++ b/Task/Power-set/PHP/power-set-2.php @@ -0,0 +1,21 @@ +POWER SET of [] +POWER SET of [singleton] +(empty) +singleton +POWER SET of [dog, c, b, a] +(empty) +a +b +a b +c +a c +b c +a b c +dog +a dog +b dog +a b dog +c dog +a c dog +b c dog +a b c dog diff --git a/Task/Power-set/Perl-6/power-set.pl6 b/Task/Power-set/Perl-6/power-set.pl6 new file mode 100644 index 0000000000..667b5c22b6 --- /dev/null +++ b/Task/Power-set/Perl-6/power-set.pl6 @@ -0,0 +1,3 @@ +sub powerset ( *@list ) { + reduce( -> @L, $n { [ @L, @L.map({[ $_.list, $n ]}) ] }, [[]], @list ); +} diff --git a/Task/Power-set/Perl/power-set-1.pl b/Task/Power-set/Perl/power-set-1.pl new file mode 100644 index 0000000000..9a1d09f9bc --- /dev/null +++ b/Task/Power-set/Perl/power-set-1.pl @@ -0,0 +1 @@ +sub p{@_?map{$_,[$_[0],@$_]}p(@_[1..$#_]):[]} diff --git a/Task/Power-set/Perl/power-set-2.pl b/Task/Power-set/Perl/power-set-2.pl new file mode 100644 index 0000000000..fee44b1b34 --- /dev/null +++ b/Task/Power-set/Perl/power-set-2.pl @@ -0,0 +1,4 @@ +use List::Util qw(reduce); +sub powerset { + @{ (reduce { [@$a, map([@$_, $b], @$a)] } [[]], @_) } +} diff --git a/Task/Power-set/PicoLisp/power-set.l b/Task/Power-set/PicoLisp/power-set.l new file mode 100644 index 0000000000..894c211cdd --- /dev/null +++ b/Task/Power-set/PicoLisp/power-set.l @@ -0,0 +1,7 @@ +(de powerset (Lst) + (ifn Lst + (cons) + (let L (powerset (cdr Lst)) + (conc + (mapcar '((X) (cons (car Lst) X)) L) + L ) ) ) ) diff --git a/Task/Power-set/Prolog/power-set-1.pro b/Task/Power-set/Prolog/power-set-1.pro new file mode 100644 index 0000000000..10d8d761d4 --- /dev/null +++ b/Task/Power-set/Prolog/power-set-1.pro @@ -0,0 +1,9 @@ +power_set(T, PS) :- + bagof(PS1, power_set(T, [], PS1), PS). + +power_set(T, PS, PS1) :- + select(E, T, T1), !, + append(PS, [E], PST), + ( PST = PS1; power_set(T1, PS, PS1); power_set(T1, PST, PS1)). + +power_set([], [], []). diff --git a/Task/Power-set/Prolog/power-set-2.pro b/Task/Power-set/Prolog/power-set-2.pro new file mode 100644 index 0000000000..ac42e4e9c0 --- /dev/null +++ b/Task/Power-set/Prolog/power-set-2.pro @@ -0,0 +1,18 @@ +:- use_module(library(chr)). + +:- chr_constraint chr_power_set/2, chr_power_set/1, clean/0. + +clean @ clean \ chr_power_set(_) <=> true. +clean @ clean <=> true. + +only_one @ chr_power_set(A) \ chr_power_set(A) <=> true. + + +creation @ chr_power_set([H | T], A) <=> + append(A, [H], B), + chr_power_set(T, A), + chr_power_set(T, B), + chr_power_set(B). + + +empty_element @ chr_power_set([], _) <=> chr_power_set([]). diff --git a/Task/Power-set/PureBasic/power-set.purebasic b/Task/Power-set/PureBasic/power-set.purebasic new file mode 100644 index 0000000000..543243925f --- /dev/null +++ b/Task/Power-set/PureBasic/power-set.purebasic @@ -0,0 +1,25 @@ +If OpenConsole() + Define argc=CountProgramParameters() + If argc>=(SizeOf(Integer)*8) Or argc<1 + PrintN("Set out of range.") + End 1 + Else + Define i, j, text$ + Define.q bset=1<>> powersequence('STR') # String + ['', 'S', 'T', 'ST', 'R', 'SR', 'TR', 'STR'] + >>> powersequence([0,1,2]) # List + [[], [0], [1], [0, 1], [2], [0, 2], [1, 2], [0, 1, 2]] + >>> powersequence((3,4,5)) # Tuple + [(), (3,), (4,), (3, 4), (5,), (3, 5), (4, 5), (3, 4, 5)] + >>> + ''' + vtype = type(val); vlen = len(val); vrange = range(vlen) + return [ reduce( lambda x,y: x+y, (val[i:i+1] for i in vrange if 2**i & n), vtype()) + for n in range(2**vlen) ] + +def powerset(s): + ''' Generate the powerset of s + + Example: + >>> powerset(set([6,7,8])) + set([frozenset([7]), frozenset([8, 6, 7]), frozenset([6]), frozenset([6, 7]), frozenset([]), frozenset([8]), frozenset([8, 7]), frozenset([8, 6])]) + ''' + return set( frozenset(x) for x in powersequence(list(s)) ) diff --git a/Task/Power-set/Python/power-set-4.py b/Task/Power-set/Python/power-set-4.py new file mode 100644 index 0000000000..646ef85a32 --- /dev/null +++ b/Task/Power-set/Python/power-set-4.py @@ -0,0 +1,3 @@ +def p(l): + if not l: return [[]] + return p(l[1:]) + [[l[0]] + x for x in p(l[1:])] diff --git a/Task/Power-set/Qi/power-set.qi b/Task/Power-set/Qi/power-set.qi new file mode 100644 index 0000000000..a8cb5e23a2 --- /dev/null +++ b/Task/Power-set/Qi/power-set.qi @@ -0,0 +1,4 @@ +(define powerset + [] -> [[]] + [A|As] -> (append (map (cons A) (powerset As)) + (powerset As))) diff --git a/Task/Power-set/R/power-set-1.r b/Task/Power-set/R/power-set-1.r new file mode 100644 index 0000000000..1141e4d8b4 --- /dev/null +++ b/Task/Power-set/R/power-set-1.r @@ -0,0 +1 @@ +library(sets) diff --git a/Task/Power-set/R/power-set-2.r b/Task/Power-set/R/power-set-2.r new file mode 100644 index 0000000000..024c6da66a --- /dev/null +++ b/Task/Power-set/R/power-set-2.r @@ -0,0 +1,3 @@ +v <- (1:3)^2 +sv <- as.set(v) +2^sv diff --git a/Task/Power-set/R/power-set-3.r b/Task/Power-set/R/power-set-3.r new file mode 100644 index 0000000000..ea4537d1de --- /dev/null +++ b/Task/Power-set/R/power-set-3.r @@ -0,0 +1,3 @@ +l <- list(a=1, b="qwerty", c=list(d=TRUE, e=1:3)) +sl <- as.set(l) +2^sl diff --git a/Task/Power-set/REXX/power-set.rexx b/Task/Power-set/REXX/power-set.rexx new file mode 100644 index 0000000000..5b4f33cccf --- /dev/null +++ b/Task/Power-set/REXX/power-set.rexx @@ -0,0 +1,29 @@ +/*REXX program to display a power set, items may be anything (no blanks)*/ +parse arg S /*let user specify the set. */ +if S='' then S='one two three four' /*None specified? Use default*/ +N=words(S) /*number of items in the list.*/ +ps='{}' /*start with a null power set.*/ + do chunk=1 for N /*traipse through the items. */ + ps=ps combN(N,chunk) /*N items, a CHUNK at a time. */ + end /*chunk*/ +w=words(ps) + do k=1 for w /*show combinations, one/line.*/ + say right(k,length(w)) word(ps,k) + end /*k*/ +exit /*stick a fork in it, we done.*/ +/*─────────────────────────────────────$COMBN subroutine────────────────*/ +combN: procedure expose $ S; parse arg x,y; $= +!.=0; base=x+1; bbase=base-y; ym=y-1; do p=1 for y; !.p=p; end + do j=1; L= + do d=1 for y; _=!.d; L=L','word(S,_); end + $=$ '{'strip(L,'L',",")'}' + !.y=!.y+1; if !.y==base then if .combU(ym) then leave + end /*j*/ +return strip($) /*return with partial powerset*/ + +.combU: 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 .combU(u-1) + p=!.u + end /*u*/ +return 0 diff --git a/Task/Power-set/Racket/power-set.rkt b/Task/Power-set/Racket/power-set.rkt new file mode 100644 index 0000000000..b747ef39aa --- /dev/null +++ b/Task/Power-set/Racket/power-set.rkt @@ -0,0 +1,8 @@ +;;; Direct translation of 'functional' ruby method +(define (powerset s) + (for/fold ([outer-set (set(set))]) + ([element s]) + (set-union outer-set + (list->set (set-map + outer-set + (λ(inner-set)(set-add inner-set element))))))) diff --git a/Task/Power-set/Rascal/power-set-1.rascal b/Task/Power-set/Rascal/power-set-1.rascal new file mode 100644 index 0000000000..0a215dcfb6 --- /dev/null +++ b/Task/Power-set/Rascal/power-set-1.rascal @@ -0,0 +1,3 @@ +import Set; + +public set[set[&T]] PowerSet(set[&T] s) = power(s); diff --git a/Task/Power-set/Rascal/power-set-2.rascal b/Task/Power-set/Rascal/power-set-2.rascal new file mode 100644 index 0000000000..b8a809544c --- /dev/null +++ b/Task/Power-set/Rascal/power-set-2.rascal @@ -0,0 +1,19 @@ +rascal>PowerSet({1,2,3,4}) +set[set[int]]: { + {4,3}, + {4,2,1}, + {4,3,1}, + {4,2}, + {4,3,2}, + {4,1}, + {4,3,2,1}, + {4}, + {3}, + {2,1}, + {3,1}, + {2}, + {3,2}, + {1}, + {3,2,1}, + {} +} diff --git a/Task/Power-set/Ruby/power-set.rb b/Task/Power-set/Ruby/power-set.rb new file mode 100644 index 0000000000..5ba82ba29a --- /dev/null +++ b/Task/Power-set/Ruby/power-set.rb @@ -0,0 +1,48 @@ +# Based on http://johncarrino.net/blog/2006/08/11/powerset-in-ruby/ +# See the link if you want a shorter version. This was intended to show the reader how the method works. +class Array + # Adds a power_set method to every array, i.e.: [1, 2].power_set + def power_set + + # Injects into a blank array of arrays. + # acc is what we're injecting into + # you is each element of the array + inject([[]]) do |acc, you| + + # Set up a new array to add into + ret = [] + + # For each array in the injected array, + acc.each do |i| + + # Add itself into the new array + ret << i + + # Merge the array with a new array of the current element + ret << i + [you] + end + + # Return the array we're looking at to inject more. + ret + + end + + end + + # A more functional and even clearer variant. + def func_power_set + inject([[]]) { |ps,item| # for each item in the Array + ps + # take the powerset up to now and add + ps.map { |e| e + [item] } # it again, with the item appended to each element + } + end +end + +#A direct translation of the "power array" version above +class Set + def powerset + inject(Set[Set[]]) do |ps, item| + ps.union ps.map {|e| e.union (Set.new [item])} + end + end +end diff --git a/Task/Power-set/Scala/power-set.scala b/Task/Power-set/Scala/power-set.scala new file mode 100644 index 0000000000..a2ecb2a4a2 --- /dev/null +++ b/Task/Power-set/Scala/power-set.scala @@ -0,0 +1 @@ +def powerset[A](s: Set[A]) = s.foldLeft(Set(Set.empty[A])) { case (ss, el) => ss ++ ss.map(_ + el) } diff --git a/Task/Power-set/Scheme/power-set-1.ss b/Task/Power-set/Scheme/power-set-1.ss new file mode 100644 index 0000000000..e607060a5a --- /dev/null +++ b/Task/Power-set/Scheme/power-set-1.ss @@ -0,0 +1,13 @@ +(define (power-set set) + (if (null? set) + '(()) + (let ((rest (power-set (cdr set)))) + (append (map (lambda (element) (cons (car set) element)) + rest) + rest)))) + +(display (power-set (list 1 2 3))) +(newline) + +(display (power-set (list "A" "C" "E"))) +(newline) diff --git a/Task/Power-set/Scheme/power-set-2.ss b/Task/Power-set/Scheme/power-set-2.ss new file mode 100644 index 0000000000..545ebabfc6 --- /dev/null +++ b/Task/Power-set/Scheme/power-set-2.ss @@ -0,0 +1,23 @@ +(define (power-set lst) + (define (iter yield) + (let recur ((a '()) (b lst)) + (if (null? b) (set! yield + (call-with-current-continuation + (lambda (resume) + (set! iter resume) + (yield a)))) + (begin (recur (append a (list (car b))) (cdr b)) + (recur a (cdr b))))) + + ;; signal end of generation + (yield 'end-of-seq)) + + (lambda () (call-with-current-continuation iter))) + +(define x (power-set '(1 2 3))) +(let loop ((a (x))) + (if (eq? a 'end-of-seq) #f + (begin + (display a) + (newline) + (loop (x))))) diff --git a/Task/Power-set/Scheme/power-set-3.ss b/Task/Power-set/Scheme/power-set-3.ss new file mode 100644 index 0000000000..21be5907d4 --- /dev/null +++ b/Task/Power-set/Scheme/power-set-3.ss @@ -0,0 +1,7 @@ +(1 2) +(1 3) +(1) +(2 3) +(2) +(3) +() diff --git a/Task/Power-set/Seed7/power-set.seed7 b/Task/Power-set/Seed7/power-set.seed7 new file mode 100644 index 0000000000..8c0d970cc1 --- /dev/null +++ b/Task/Power-set/Seed7/power-set.seed7 @@ -0,0 +1,29 @@ +$ include "seed7_05.s7i"; + +const func array bitset: powerSet (in bitset: baseSet) is func + result + var array bitset: pwrSet is [] (bitset.value); + local + var integer: element is 0; + var integer: index is 0; + var bitset: aSet is bitset.value; + begin + for element range baseSet do + for key index range pwrSet do + aSet := pwrSet[index]; + if element not in aSet then + incl(aSet, element); + pwrSet &:= aSet; + end if; + end for; + end for; + end func; + +const proc: main is func + local + var bitset: aSet is bitset.value; + begin + for aSet range powerSet({1, 2, 3, 4}) do + writeln(aSet); + end for; + end func; diff --git a/Task/Power-set/Smalltalk/power-set-1.st b/Task/Power-set/Smalltalk/power-set-1.st new file mode 100644 index 0000000000..3471d28914 --- /dev/null +++ b/Task/Power-set/Smalltalk/power-set-1.st @@ -0,0 +1,7 @@ +Collection extend [ + power [ + ^(0 to: (1 bitShift: self size) - 1) readStream collect: [ :each || i | + i := 0. + self select: [ :elem | (each bitAt: (i := i + 1)) = 1 ] ] + ] +]. diff --git a/Task/Power-set/Smalltalk/power-set-2.st b/Task/Power-set/Smalltalk/power-set-2.st new file mode 100644 index 0000000000..2a7ac7d547 --- /dev/null +++ b/Task/Power-set/Smalltalk/power-set-2.st @@ -0,0 +1,5 @@ +#(1 2 4) power do: [ :each | + each asArray printNl ]. + +#( 'A' 'C' 'E' ) power do: [ :each | + each asArray printNl ]. diff --git a/Task/Power-set/Standard-ML/power-set.ml b/Task/Power-set/Standard-ML/power-set.ml new file mode 100644 index 0000000000..b6b0ab22d4 --- /dev/null +++ b/Task/Power-set/Standard-ML/power-set.ml @@ -0,0 +1 @@ +fun subsets xs = foldr (fn (x, rest) => rest @ map (fn ys => x::ys) rest) [[]] xs diff --git a/Task/Power-set/TXR/power-set.txr b/Task/Power-set/TXR/power-set.txr new file mode 100644 index 0000000000..c0681c0b60 --- /dev/null +++ b/Task/Power-set/TXR/power-set.txr @@ -0,0 +1,14 @@ +@(next :args) +@(do (defun power-set (s) + (reduce-right + (lambda (item ps) + (append (mapcar (lambda (e) (cons item e)) ps) ps)) s '(()) nil))) +@(collect :vars (arg)) +@arg +@(end) +@(bind pset @(power-set arg)) +@(output) +@ (repeat) +{@(rep)@pset, @(last)@pset@(empty)@(end)} +@ (end) +@(end) diff --git a/Task/Power-set/Tcl/power-set-1.tcl b/Task/Power-set/Tcl/power-set-1.tcl new file mode 100644 index 0000000000..112128b2c1 --- /dev/null +++ b/Task/Power-set/Tcl/power-set-1.tcl @@ -0,0 +1,8 @@ +proc subsets {l} { + set res [list [list]] + foreach e $l { + foreach subset $res {lappend res [lappend subset $e]} + } + return $res +} +puts [subsets {a b c d}] diff --git a/Task/Power-set/Tcl/power-set-2.tcl b/Task/Power-set/Tcl/power-set-2.tcl new file mode 100644 index 0000000000..0f79b21429 --- /dev/null +++ b/Task/Power-set/Tcl/power-set-2.tcl @@ -0,0 +1,12 @@ +proc powersetb set { + set res {} + for {set i 0} {$i < 2**[llength $set]} {incr i} { + set pos -1 + set pset {} + foreach el $set { + if {$i & 1<<[incr pos]} {lappend pset $el} + } + lappend res $pset + } + return $res +} diff --git a/Task/Power-set/UNIX-Shell/power-set-1.sh b/Task/Power-set/UNIX-Shell/power-set-1.sh new file mode 100644 index 0000000000..dbc18a59a2 --- /dev/null +++ b/Task/Power-set/UNIX-Shell/power-set-1.sh @@ -0,0 +1 @@ +p() { [ $# -eq 0 ] && echo || (shift; p "$@") | while read r ; do echo -e "$1 $r\n$r"; done } diff --git a/Task/Power-set/UNIX-Shell/power-set-2.sh b/Task/Power-set/UNIX-Shell/power-set-2.sh new file mode 100644 index 0000000000..43572a238f --- /dev/null +++ b/Task/Power-set/UNIX-Shell/power-set-2.sh @@ -0,0 +1,5 @@ +|p `cat` | sort | uniq +A +C +E +^D diff --git a/Task/Power-set/UnixPipes/power-set.unixpipes b/Task/Power-set/UnixPipes/power-set.unixpipes new file mode 100644 index 0000000000..0cd96a6a86 --- /dev/null +++ b/Task/Power-set/UnixPipes/power-set.unixpipes @@ -0,0 +1,22 @@ +| cat A +a +b +c + +| cat A |\ + xargs -n 1 ksh -c 'echo \{`cat A`\}' |\ + xargs |\ + sed -e 's; ;,;g' \ + -e 's;^;echo ;g' \ + -e 's;\},;}\\ ;g' |\ + ksh |unfold `wc -l A` |\ + xargs -n1 -I{} ksh -c 'echo {} |\ + unfold 1 |sort -u |xargs' |sort -u + +a +a b +a b c +a c +b +b c +c diff --git a/Task/Power-set/Ursala/power-set-1.ursala b/Task/Power-set/Ursala/power-set-1.ursala new file mode 100644 index 0000000000..6e051246b6 --- /dev/null +++ b/Task/Power-set/Ursala/power-set-1.ursala @@ -0,0 +1 @@ +powerset = ~&NiC+ ~&i&& ~&at^?\~&aNC ~&ahPfatPRXlNrCDrT diff --git a/Task/Power-set/Ursala/power-set-2.ursala b/Task/Power-set/Ursala/power-set-2.ursala new file mode 100644 index 0000000000..46323907b6 --- /dev/null +++ b/Task/Power-set/Ursala/power-set-2.ursala @@ -0,0 +1,3 @@ +#cast %sSS + +test = powerset {'a','b','c','d'} diff --git a/Task/Power-set/V/power-set-1.v b/Task/Power-set/V/power-set-1.v new file mode 100644 index 0000000000..37b3530a50 --- /dev/null +++ b/Task/Power-set/V/power-set-1.v @@ -0,0 +1,2 @@ +[A C E] powerlist +=[[A C E] [A C] [A E] [A] [C E] [C] [E] []] diff --git a/Task/Power-set/V/power-set-2.v b/Task/Power-set/V/power-set-2.v new file mode 100644 index 0000000000..de9ff4be65 --- /dev/null +++ b/Task/Power-set/V/power-set-2.v @@ -0,0 +1,6 @@ +[powerlist + [null?] + [unitlist] + [uncons] + [dup swapd [cons] map popd swoncat] + linrec]. diff --git a/Task/Pragmatic-directives/0DESCRIPTION b/Task/Pragmatic-directives/0DESCRIPTION new file mode 100644 index 0000000000..b617089d19 --- /dev/null +++ b/Task/Pragmatic-directives/0DESCRIPTION @@ -0,0 +1,3 @@ +Pragmatic directives cause the language to operate in a specific manner, allowing support for operational variances within the program code (possibly by the loading of specific or alternative modules). + +The task is to list any pragmatic directives supported by the language, demonstrate how to activate and deactivate the pragmatic directives and to describe or demonstate the scope of effect that the pragmatic directives have within a program. diff --git a/Task/Pragmatic-directives/1META.yaml b/Task/Pragmatic-directives/1META.yaml new file mode 100644 index 0000000000..d7ddcd3151 --- /dev/null +++ b/Task/Pragmatic-directives/1META.yaml @@ -0,0 +1,3 @@ +--- +category: +- Pragmatic directives diff --git a/Task/Pragmatic-directives/ALGOL-68/pragmatic-directives.alg b/Task/Pragmatic-directives/ALGOL-68/pragmatic-directives.alg new file mode 100644 index 0000000000..d742c43322 --- /dev/null +++ b/Task/Pragmatic-directives/ALGOL-68/pragmatic-directives.alg @@ -0,0 +1,12 @@ +#!/usr/local/bin/a68g --script # + +PRAGMAT portcheck PRAGMAT +PR portcheck PR + +BEGIN PR heap=256M PR # algol68g pragma # + ~ +END; + +PROC (REAL)REAL s = sin(); + +SKIP diff --git a/Task/Pragmatic-directives/BASIC/pragmatic-directives.basic b/Task/Pragmatic-directives/BASIC/pragmatic-directives.basic new file mode 100644 index 0000000000..2ff2732314 --- /dev/null +++ b/Task/Pragmatic-directives/BASIC/pragmatic-directives.basic @@ -0,0 +1,2 @@ +10 TRON: REM activate system trace pragma +20 TROFF: REM deactivate system trace pragma diff --git a/Task/Pragmatic-directives/Go/pragmatic-directives-1.go b/Task/Pragmatic-directives/Go/pragmatic-directives-1.go new file mode 100644 index 0000000000..77efa85305 --- /dev/null +++ b/Task/Pragmatic-directives/Go/pragmatic-directives-1.go @@ -0,0 +1 @@ +// +build diff --git a/Task/Pragmatic-directives/Go/pragmatic-directives-2.go b/Task/Pragmatic-directives/Go/pragmatic-directives-2.go new file mode 100644 index 0000000000..411f8f7bbf --- /dev/null +++ b/Task/Pragmatic-directives/Go/pragmatic-directives-2.go @@ -0,0 +1 @@ +// +build linux diff --git a/Task/Pragmatic-directives/Go/pragmatic-directives-3.go b/Task/Pragmatic-directives/Go/pragmatic-directives-3.go new file mode 100644 index 0000000000..319aa744ec --- /dev/null +++ b/Task/Pragmatic-directives/Go/pragmatic-directives-3.go @@ -0,0 +1 @@ +// +build Tuesday diff --git a/Task/Pragmatic-directives/Go/pragmatic-directives-4.go b/Task/Pragmatic-directives/Go/pragmatic-directives-4.go new file mode 100644 index 0000000000..701f83e18f --- /dev/null +++ b/Task/Pragmatic-directives/Go/pragmatic-directives-4.go @@ -0,0 +1 @@ +go install -tags `date +%A` diff --git a/Task/Pragmatic-directives/Icon/pragmatic-directives.icon b/Task/Pragmatic-directives/Icon/pragmatic-directives.icon new file mode 100644 index 0000000000..c55726ce52 --- /dev/null +++ b/Task/Pragmatic-directives/Icon/pragmatic-directives.icon @@ -0,0 +1,2 @@ +&trace # controls execution tracing +&error # controls error handling diff --git a/Task/Pragmatic-directives/J/pragmatic-directives-1.j b/Task/Pragmatic-directives/J/pragmatic-directives-1.j new file mode 100644 index 0000000000..89f8183491 --- /dev/null +++ b/Task/Pragmatic-directives/J/pragmatic-directives-1.j @@ -0,0 +1 @@ + 9!:25]1 diff --git a/Task/Pragmatic-directives/J/pragmatic-directives-2.j b/Task/Pragmatic-directives/J/pragmatic-directives-2.j new file mode 100644 index 0000000000..ac7fcc438a --- /dev/null +++ b/Task/Pragmatic-directives/J/pragmatic-directives-2.j @@ -0,0 +1,2 @@ + 3 :'y' 8 +8 diff --git a/Task/Pragmatic-directives/J/pragmatic-directives-3.j b/Task/Pragmatic-directives/J/pragmatic-directives-3.j new file mode 100644 index 0000000000..4f6989e7ff --- /dev/null +++ b/Task/Pragmatic-directives/J/pragmatic-directives-3.j @@ -0,0 +1,2 @@ + 3 :'y.' 8 +|spelling error diff --git a/Task/Pragmatic-directives/J/pragmatic-directives-4.j b/Task/Pragmatic-directives/J/pragmatic-directives-4.j new file mode 100644 index 0000000000..11880736ee --- /dev/null +++ b/Task/Pragmatic-directives/J/pragmatic-directives-4.j @@ -0,0 +1,7 @@ + 9!:49]1 + 3 :'y.' 8 +8 + 3 :'y.[y=.7' 8 +8 + 3 :'y.]y=.7' 8 +7 diff --git a/Task/Pragmatic-directives/NetRexx/pragmatic-directives-1.netrexx b/Task/Pragmatic-directives/NetRexx/pragmatic-directives-1.netrexx new file mode 100644 index 0000000000..627caec607 --- /dev/null +++ b/Task/Pragmatic-directives/NetRexx/pragmatic-directives-1.netrexx @@ -0,0 +1 @@ +options wordlist; diff --git a/Task/Pragmatic-directives/NetRexx/pragmatic-directives-2.netrexx b/Task/Pragmatic-directives/NetRexx/pragmatic-directives-2.netrexx new file mode 100644 index 0000000000..549394c2dd --- /dev/null +++ b/Task/Pragmatic-directives/NetRexx/pragmatic-directives-2.netrexx @@ -0,0 +1,3 @@ +options - + nobinary nocomments nocompact console crossref decimal nodiag noexplicit noformat java logo noreplace nosavelog nosourcedir - + nostrictargs nostrictassign nostrictcase nostrictimport nostrictprops nostrictsignal nosymbols trace2 noutf8 verbose3 diff --git a/Task/Pragmatic-directives/NetRexx/pragmatic-directives-3.netrexx b/Task/Pragmatic-directives/NetRexx/pragmatic-directives-3.netrexx new file mode 100644 index 0000000000..3f29a474e0 --- /dev/null +++ b/Task/Pragmatic-directives/NetRexx/pragmatic-directives-3.netrexx @@ -0,0 +1,2 @@ +numeric digits [exprd]; +numeric form [scientific | engineering]; diff --git a/Task/Pragmatic-directives/NetRexx/pragmatic-directives-4.netrexx b/Task/Pragmatic-directives/NetRexx/pragmatic-directives-4.netrexx new file mode 100644 index 0000000000..f3660c9bf0 --- /dev/null +++ b/Task/Pragmatic-directives/NetRexx/pragmatic-directives-4.netrexx @@ -0,0 +1,2 @@ +trace tracesetting +trace var [varlist] diff --git a/Task/Pragmatic-directives/Perl-6/pragmatic-directives.pl6 b/Task/Pragmatic-directives/Perl-6/pragmatic-directives.pl6 new file mode 100644 index 0000000000..0afe59d6f2 --- /dev/null +++ b/Task/Pragmatic-directives/Perl-6/pragmatic-directives.pl6 @@ -0,0 +1,4 @@ +use MONKEY_TYPING; +augment class Int { + method times (&what) { what() xx self } # pretend like we're Ruby +} diff --git a/Task/Pragmatic-directives/Perl/pragmatic-directives-1.pl b/Task/Pragmatic-directives/Perl/pragmatic-directives-1.pl new file mode 100644 index 0000000000..6a9351a5b2 --- /dev/null +++ b/Task/Pragmatic-directives/Perl/pragmatic-directives-1.pl @@ -0,0 +1,2 @@ +use warnings; # use warnings pragma module +use strict; # use strict pragma module diff --git a/Task/Pragmatic-directives/Perl/pragmatic-directives-2.pl b/Task/Pragmatic-directives/Perl/pragmatic-directives-2.pl new file mode 100644 index 0000000000..74c6b6f5a9 --- /dev/null +++ b/Task/Pragmatic-directives/Perl/pragmatic-directives-2.pl @@ -0,0 +1,2 @@ +no warnings; # disable warnings pragma module +no strict; # disable strict pragma module diff --git a/Task/Pragmatic-directives/Python/pragmatic-directives-1.py b/Task/Pragmatic-directives/Python/pragmatic-directives-1.py new file mode 100644 index 0000000000..d2af8e00be --- /dev/null +++ b/Task/Pragmatic-directives/Python/pragmatic-directives-1.py @@ -0,0 +1,6 @@ +Python 3.2 (r32:88445, Feb 20 2011, 21:30:00) [MSC v.1500 64 bit (AMD64)] on win32 +Type "copyright", "credits" or "license()" for more information. +>>> import __future__ +>>> __future__.all_feature_names +['nested_scopes', 'generators', 'division', 'absolute_import', 'with_statement', 'print_function', 'unicode_literals', 'barry_as_FLUFL'] +>>> diff --git a/Task/Pragmatic-directives/Python/pragmatic-directives-2.py b/Task/Pragmatic-directives/Python/pragmatic-directives-2.py new file mode 100644 index 0000000000..f7535ef42d --- /dev/null +++ b/Task/Pragmatic-directives/Python/pragmatic-directives-2.py @@ -0,0 +1,6 @@ +Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win32 +Type "copyright", "credits" or "license()" for more information. +>>> import __future__ +>>> __future__.all_feature_names +['nested_scopes', 'generators', 'division', 'absolute_import', 'with_statement', 'print_function', 'unicode_literals'] +>>> diff --git a/Task/Pragmatic-directives/UNIX-Shell/pragmatic-directives.sh b/Task/Pragmatic-directives/UNIX-Shell/pragmatic-directives.sh new file mode 100644 index 0000000000..cf95783a68 --- /dev/null +++ b/Task/Pragmatic-directives/UNIX-Shell/pragmatic-directives.sh @@ -0,0 +1,2 @@ +set -vx # Activate both script line output and command line arguments pragma +set +vx # Deactivate both pragmatic directives diff --git a/Task/Price-fraction/0DESCRIPTION b/Task/Price-fraction/0DESCRIPTION new file mode 100644 index 0000000000..f003a333b2 --- /dev/null +++ b/Task/Price-fraction/0DESCRIPTION @@ -0,0 +1,24 @@ +A friend of mine runs a pharmacy. He has a specialised function in his Dispensary application which receives a decimal value of currency and replaces it to a standard value. This value is regulated by a government department. + +Task: Given a floating point value between 0.00 and 1.00, rescale according to the following table: + + >= 0.00 < 0.06 := 0.10 + >= 0.06 < 0.11 := 0.18 + >= 0.11 < 0.16 := 0.26 + >= 0.16 < 0.21 := 0.32 + >= 0.21 < 0.26 := 0.38 + >= 0.26 < 0.31 := 0.44 + >= 0.31 < 0.36 := 0.50 + >= 0.36 < 0.41 := 0.54 + >= 0.41 < 0.46 := 0.58 + >= 0.46 < 0.51 := 0.62 + >= 0.51 < 0.56 := 0.66 + >= 0.56 < 0.61 := 0.70 + >= 0.61 < 0.66 := 0.74 + >= 0.66 < 0.71 := 0.78 + >= 0.71 < 0.76 := 0.82 + >= 0.76 < 0.81 := 0.86 + >= 0.81 < 0.86 := 0.90 + >= 0.86 < 0.91 := 0.94 + >= 0.91 < 0.96 := 0.98 + >= 0.96 < 1.01 := 1.00 diff --git a/Task/Price-fraction/1META.yaml b/Task/Price-fraction/1META.yaml new file mode 100644 index 0000000000..3d6a66b9cf --- /dev/null +++ b/Task/Price-fraction/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Financial operations diff --git a/Task/Price-fraction/ALGOL-68/price-fraction.alg b/Task/Price-fraction/ALGOL-68/price-fraction.alg new file mode 100644 index 0000000000..ddbf0ce466 --- /dev/null +++ b/Task/Price-fraction/ALGOL-68/price-fraction.alg @@ -0,0 +1,30 @@ +main: +( + # Just get a random price between 0 and 1 # + # srand(time(NIL)); # + REAL price := random; + REAL tops := 0.06; + REAL std val := 0.10; + + # Conditionals are a little odd here "(price-0.001 < tops AND + price+0.001 > tops)" is to check if they are equal. Stupid + C floats, right? :) # + WHILE ( price>tops OR (price-0.001 < tops AND price+0.001 > tops) ) AND tops<=1.01 + DO + tops+:=0.05; + + IF std val < 0.26 THEN + std val +:= 0.08 + ELIF std val < 0.50 THEN + std val +:= 0.06 + ELSE + std val +:= 0.04 + FI; + + IF std val > 0.98 THEN + std val := 1.0 + FI + OD; + + printf(($"Value : "z.2dl,"Converted to standard : "z.2dl$, price, std val)) +) diff --git a/Task/Price-fraction/AWK/price-fraction.awk b/Task/Price-fraction/AWK/price-fraction.awk new file mode 100644 index 0000000000..24a89f6417 --- /dev/null +++ b/Task/Price-fraction/AWK/price-fraction.awk @@ -0,0 +1,21 @@ +BEGIN { + O = ".06 .11 .16 .21 .26 .31 .36 .41 .46 .51 .56 .61 .66 .71 .76 .81 .86 .91 .96 1.01" + N = ".10 .18 .26 .32 .38 .44 .50 .54 .58 .62 .66 .70 .74 .78 .82 .86 .90 .94 .98 1.00" + fields = split(O,Oarr," ") # original values + split(N,Narr," ") # replacement values + for (i=-.01; i<=1.02; i+=.01) { # test + printf("%5.2f = %4.2f\n",i,lookup(i)) + } +} +function lookup(n, i) { + if (n < 0 || n > 1.01) { + return(0) # when input is out of range + } + for (i=1; i<=fields; i++) { + # +10 is used because .11 returned .18 instead of .26 + # under AWK95, GAWK, and MAWK; Thompson Automation's TAWK worked correctly + if (n+10 < Oarr[i]+10) { + return(Narr[i]) + } + } +} diff --git a/Task/Price-fraction/Ada/price-fraction-1.ada b/Task/Price-fraction/Ada/price-fraction-1.ada new file mode 100644 index 0000000000..b1bf93be09 --- /dev/null +++ b/Task/Price-fraction/Ada/price-fraction-1.ada @@ -0,0 +1,31 @@ +type Price is delta 0.01 digits 3 range 0.0..1.0; +function Scale (Value : Price) return Price is + X : constant array (1..19) of Price := + ( 0.06, 0.11, 0.16, 0.21, 0.26, 0.31, 0.36, 0.41, 0.46, 0.51, + 0.56, 0.61, 0.66, 0.71, 0.76, 0.81, 0.86, 0.91, 0.96 + ); + Y : constant array (1..20) of Price := + ( 0.10, 0.18, 0.26, 0.32, 0.38, 0.44, 0.50, 0.54, 0.58, 0.62, + 0.66, 0.70, 0.74, 0.78, 0.82, 0.86, 0.90, 0.94, 0.98, 1.0 + ); + Low : Natural := X'First; + High : Natural := X'Last; + Middle : Natural; +begin + loop + Middle := (Low + High) / 2; + if Value = X (Middle) then + return Y (Middle + 1); + elsif Value < X (Middle) then + if Low = Middle then + return Y (Low); + end if; + High := Middle - 1; + else + if High = Middle then + return Y (High + 1); + end if; + Low := Middle + 1; + end if; + end loop; +end Scale; diff --git a/Task/Price-fraction/Ada/price-fraction-2.ada b/Task/Price-fraction/Ada/price-fraction-2.ada new file mode 100644 index 0000000000..cfd3c1dca1 --- /dev/null +++ b/Task/Price-fraction/Ada/price-fraction-2.ada @@ -0,0 +1,11 @@ +with Ada.Text_IO; use Ada.Text_IO; +procedure Test_Price_Fraction is + -- Put the declarations here + Value : Price := Price'First; +begin + loop + Put_Line (Price'Image (Value) & "->" & Price'Image (Scale (Value))); + exit when Value = Price'Last; + Value := Price'Succ (Value); + end loop; +end Test_Price_Fraction; diff --git a/Task/Price-fraction/AutoHotkey/price-fraction.ahk b/Task/Price-fraction/AutoHotkey/price-fraction.ahk new file mode 100644 index 0000000000..b7062656fa --- /dev/null +++ b/Task/Price-fraction/AutoHotkey/price-fraction.ahk @@ -0,0 +1,34 @@ +; Submitted by MasterFocus --- http://tiny.cc/iTunis + +Loop +{ + InputBox, OutputVar, Price Fraction Example, Insert the value to be rounded.`n* [ 0 < value < 1 ]`n* Press ESC or Cancel to exit, , 200, 150 + If ErrorLevel + Break + MsgBox % "Input: " OutputVar "`nResult: " PriceFraction( OutputVar ) +} + +;----------------------------------------- + +PriceFraction( p_Input ) +{ + + If p_Input is not float ; returns 0 if input is not a float + Return 0 + + If ( ( p_Input <= 0 ) OR ( p_Input >= 1 ) ) ; returns 0 is input is out of range + Return 0 + + ; declaring the table (arbitrary delimiters in use are '§' and '|') + l_List := "0.06|0.10§0.11|0.18§0.16|0.26§0.21|0.32§0.26|0.38§0.31|0.44§0.36|0.50§0.41|0.54§0.46|0.58§0.51|0.62§0.56|0.66§0.61|0.70§0.66|0.74§0.71|0.78§0.76|0.82§0.81|0.86§0.86|0.90§0.91|0.94§0.96|0.98§1.01|1.00" + + Loop, Parse, l_List, § ; retrieves each field (delimited by '§') + { + StringSplit, l_Array, A_LoopField, | ; splits current field (using delimiter '|') + If ( p_Input <= l_Array1 ) + Return l_Array2 ; returns the second value if input <= first value + } + + Return 0 ; returns 0, indicating failure (shouldn't be reached though) + +} diff --git a/Task/Price-fraction/BASIC/price-fraction.basic b/Task/Price-fraction/BASIC/price-fraction.basic new file mode 100644 index 0000000000..213fa5c141 --- /dev/null +++ b/Task/Price-fraction/BASIC/price-fraction.basic @@ -0,0 +1,56 @@ +DECLARE FUNCTION PriceFraction! (price AS SINGLE) + +RANDOMIZE TIMER +DIM x AS SINGLE +x = RND +PRINT x, PriceFraction(x) + +FUNCTION PriceFraction! (price AS SINGLE) + 'returns price unchanged if invalid value + SELECT CASE price + CASE IS < 0! + PriceFraction! = price + CASE IS < .06 + PriceFraction! = .1 + CASE IS < .11 + PriceFraction! = .18 + CASE IS < .16 + PriceFraction! = .26 + CASE IS < .21 + PriceFraction! = .32 + CASE IS < .26 + PriceFraction! = .38 + CASE IS < .31 + PriceFraction! = .44 + CASE IS < .36 + PriceFraction! = .5 + CASE IS < .41 + PriceFraction! = .54 + CASE IS < .46 + PriceFraction! = .58 + CASE IS < .51 + PriceFraction! = .62 + CASE IS < .56 + PriceFraction! = .66 + CASE IS < .61 + PriceFraction! = .7 + CASE IS < .66 + PriceFraction! = .74 + CASE IS < .71 + PriceFraction! = .78 + CASE IS < .76 + PriceFraction! = .82 + CASE IS < .81 + PriceFraction! = .86 + CASE IS < .86 + PriceFraction! = .9 + CASE IS < .91 + PriceFraction! = .94 + CASE IS < .96 + PriceFraction! = .98 + CASE IS < 1.01 + PriceFraction! = 1! + CASE ELSE + PriceFraction! = price + END SELECT +END FUNCTION diff --git a/Task/Price-fraction/BBC-BASIC/price-fraction.bbc b/Task/Price-fraction/BBC-BASIC/price-fraction.bbc new file mode 100644 index 0000000000..8737ab6ee5 --- /dev/null +++ b/Task/Price-fraction/BBC-BASIC/price-fraction.bbc @@ -0,0 +1,24 @@ + PRINT FNpricefraction(0.5) + END + + DEF FNpricefraction(p) + IF p < 0.06 THEN = 0.10 + IF p < 0.11 THEN = 0.18 + IF p < 0.16 THEN = 0.26 + IF p < 0.21 THEN = 0.32 + IF p < 0.26 THEN = 0.38 + IF p < 0.31 THEN = 0.44 + IF p < 0.36 THEN = 0.50 + IF p < 0.41 THEN = 0.54 + IF p < 0.46 THEN = 0.58 + IF p < 0.51 THEN = 0.62 + IF p < 0.56 THEN = 0.66 + IF p < 0.61 THEN = 0.70 + IF p < 0.66 THEN = 0.74 + IF p < 0.71 THEN = 0.78 + IF p < 0.76 THEN = 0.82 + IF p < 0.81 THEN = 0.86 + IF p < 0.86 THEN = 0.90 + IF p < 0.91 THEN = 0.94 + IF p < 0.96 THEN = 0.98 + = 1.00 diff --git a/Task/Price-fraction/Bracmat/price-fraction.bracmat b/Task/Price-fraction/Bracmat/price-fraction.bracmat new file mode 100644 index 0000000000..2ec0985fcb --- /dev/null +++ b/Task/Price-fraction/Bracmat/price-fraction.bracmat @@ -0,0 +1,37 @@ +( ( convert + = + . ("0.06"."0.10") + ("0.11"."0.18") + ("0.16"."0.26") + ("0.21"."0.32") + ("0.26"."0.38") + ("0.31"."0.44") + ("0.36"."0.50") + ("0.41"."0.54") + ("0.46"."0.58") + ("0.51"."0.62") + ("0.56"."0.66") + ("0.61"."0.70") + ("0.66"."0.74") + ("0.71"."0.78") + ("0.76"."0.82") + ("0.81"."0.86") + ("0.86"."0.90") + ("0.91"."0.94") + ("0.96"."0.98") + ("1.01"."1.00") + : ? (>!arg.?arg) ? + & !arg + | "invalid input" + ) +& -1:?n +& whl + ' ( !n+1:?n:<103 + & ( @(!n:? [<2)&str$("0.0" !n):?a + | @(!n:? [<3)&str$("0." !n):?a + | @(!n:?ones [-3 ?decimals) + & str$(!ones "." !decimals):?a + ) + & out$(!a "-->" convert$!a) + ) +) diff --git a/Task/Price-fraction/C++/price-fraction.cpp b/Task/Price-fraction/C++/price-fraction.cpp new file mode 100644 index 0000000000..a0c76c640a --- /dev/null +++ b/Task/Price-fraction/C++/price-fraction.cpp @@ -0,0 +1,30 @@ +#include +#include + +int main( ) { + double froms[ ] = { 0.00 , 0.06 , 0.11 , 0.16 , 0.21 , 0.26 , + 0.31 , 0.36 , 0.41 , 0.46 , 0.51 , 0.56 , 0.61 , 0.66 , + 0.71 , 0.76 , 0.81 , 0.86 , 0.91 , 0.96 } ; + double tos[ ] = { 0.06 , 0.11 , 0.16 , 0.21 , 0.26 , 0.31 , + 0.36 , 0.41 , 0.46 , 0.51 , 0.56 , 0.61 , 0.66 , 0.71 , + 0.76 , 0.81 , 0.86 , 0.91 , 0.96 , 1.01 } ; + double replacements [] = { 0.10 , 0.18 , 0.26 , 0.32 , 0.38 , + 0.44 , 0.50 , 0.54 , 0.58 , 0.62 , 0.66 , 0.70 , 0.74 , + 0.78 , 0.82 , 0.86 , 0.90 , 0.94 , 0.98 , 1.00 } ; + double number = 0.1 ; + std::cout << "Enter a fractional number between 0 and 1 ( 0 to end )!\n" ; + std::cin >> number ; + while ( number != 0 ) { + if ( number < 0 || number > 1 ) { + std::cerr << "Error! Only positive values between 0 and 1 are allowed!\n" ; + return 1 ; + } + int n = 0 ; + while ( ! ( number >= froms[ n ] && number < tos[ n ] ) ) + n++ ; + std::cout << "-->" << replacements[ n ] << '\n' ; + std::cout << "Enter a fractional number ( 0 to end )!\n" ; + std::cin >> number ; + } + return 0 ; +} diff --git a/Task/Price-fraction/C/price-fraction.c b/Task/Price-fraction/C/price-fraction.c new file mode 100644 index 0000000000..79a84a386b --- /dev/null +++ b/Task/Price-fraction/C/price-fraction.c @@ -0,0 +1,28 @@ +#include + +double table[][2] = { + {0.06, 0.10}, {0.11, 0.18}, {0.16, 0.26}, {0.21, 0.32}, + {0.26, 0.38}, {0.31, 0.44}, {0.36, 0.50}, {0.41, 0.54}, + {0.46, 0.58}, {0.51, 0.62}, {0.56, 0.66}, {0.61, 0.70}, + {0.66, 0.74}, {0.71, 0.78}, {0.76, 0.82}, {0.81, 0.86}, + {0.86, 0.90}, {0.91, 0.94}, {0.96, 0.98}, {1.01, 1.00}, + {-1, 0}, /* guarding element */ +}; + +double price_fix(double x) +{ + int i; + for (i = 0; table[i][0] > 0; i++) + if (x < table[i][0]) return table[i][1]; + + abort(); /* what else to do? */ +} + +int main() +{ + int i; + for (i = 0; i <= 100; i++) + printf("%.2f %.2f\n", i / 100., price_fix(i / 100.)); + + return 0; +} diff --git a/Task/Price-fraction/Clipper/price-fraction-1.clipper b/Task/Price-fraction/Clipper/price-fraction-1.clipper new file mode 100644 index 0000000000..2b0c464c16 --- /dev/null +++ b/Task/Price-fraction/Clipper/price-fraction-1.clipper @@ -0,0 +1,33 @@ +FUNCTION PriceFraction( npQuantDispensed ) + LOCAL aPriceFraction := { {0,.06,.1},; + {.06,.11,.18}, ; + {.11,.16,.26}, ; + {.16,.21,.32}, ; + {.21,.26,.38}, ; + {.26,.31,.44}, ; + {.31,.36,.5}, ; + {.36,.41,.54}, ; + {.41,.46,.58}, ; + {.46,.51,.62}, ; + {.51,.56,.66}, ; + {.56,.61,.7}, ; + {.61,.66,.74}, ; + {.66,.71,.78}, ; + {.71,.76,.82}, ; + {.76,.81,.86}, ; + {.81,.86,.9}, ; + {.86,.91,.94}, ; + {.91,.96,.98} } + LOCAL nResult + LOCAL nScan + IF npQuantDispensed = 0 + nResult = 0 + ELSEIF npQuantDispensed >= .96 + nResult = 1 + ELSE + nScan := ASCAN( aPriceFraction, ; + { |aItem| npQuantDispensed >= aItem[ 1 ] .AND.; + npQuantDispensed < aItem[ 2 ] } ) + nResult := aPriceFraction[ nScan ][ 3 ] + END IF + RETURN nResult diff --git a/Task/Price-fraction/Clipper/price-fraction-2.clipper b/Task/Price-fraction/Clipper/price-fraction-2.clipper new file mode 100644 index 0000000000..9fc78a0f94 --- /dev/null +++ b/Task/Price-fraction/Clipper/price-fraction-2.clipper @@ -0,0 +1,44 @@ +Procedure Main() + Local i + For i := -0.02 to 1.02 STEP 0.03 + ? i, "->", PriceFraction(i), i+0.02, "->", PriceFraction(i+0.02) + Next +Return + + +Static Function PriceFraction( nValue ) + Local nResult + Local n + // Function is only defined for values 0 to 1.00 + // Return NIL for anything else + // Table of values {V1, V2} = {Threshhold, Standard value} + #define TV_THRESHHOLD 1 + #define TV_STD_VALUE 2 + Local aTable := { {0, NIL },; + {0.06, 0.10},; + {0.11, 0.18},; + {0.16, 0.26},; + {0.21, 0.32},; + {0.26, 0.38},; + {0.31, 0.44},; + {0.36, 0.50},; + {0.41, 0.54},; + {0.46, 0.58},; + {0.51, 0.62},; + {0.56, 0.66},; + {0.61, 0.70},; + {0.66, 0.74},; + {0.71, 0.78},; + {0.76, 0.82},; + {0.81, 0.86},; + {0.86, 0.90},; + {0.91, 0.94},; + {0.96, 0.98},; + {1.01, 1.00} } + n := AScan( aTable, {|x| nValue < x[TV_THRESHHOLD] }) + If n > 0 + nResult := aTable[n][TV_STD_VALUE] + Else + nResult := NIL + Endif +Return nResult diff --git a/Task/Price-fraction/D/price-fraction.d b/Task/Price-fraction/D/price-fraction.d new file mode 100644 index 0000000000..3066bbae36 --- /dev/null +++ b/Task/Price-fraction/D/price-fraction.d @@ -0,0 +1,20 @@ +import std.stdio; + +double priceRounder(in double price) pure nothrow +in { + assert(price >= 0 && price <= 1.0); +} body { + enum cin = [.06, .11, .16, .21, .26, .31, .36, .41, .46, .51, + .56, .61, .66, .71, .76, .81, .86, .91, .96, 1.01]; + enum cout = [.10, .18, .26, .32, .38, .44, .50, .54, .58, .62, + .66, .70, .74, .78, .82, .86, .90, .94, .98, 1.00]; + foreach (i, p; cin) + if (p >= price) + return cout[i]; + assert(0); +} + +void main() { + foreach (price; [0.7388727, 0.8593103, 0.826687, 0.3444635]) + writeln(priceRounder(price)); +} diff --git a/Task/Price-fraction/Erlang/price-fraction.erl b/Task/Price-fraction/Erlang/price-fraction.erl new file mode 100644 index 0000000000..5da9713778 --- /dev/null +++ b/Task/Price-fraction/Erlang/price-fraction.erl @@ -0,0 +1,22 @@ +priceFraction(N) when N < 0 orelse N > 1 -> + erlang:error('Values must be between 0 and 1.'); +priceFraction(N) when N < 0.06 -> 0.10; +priceFraction(N) when N < 0.11 -> 0.18; +priceFraction(N) when N < 0.16 -> 0.26; +priceFraction(N) when N < 0.21 -> 0.32; +priceFraction(N) when N < 0.26 -> 0.38; +priceFraction(N) when N < 0.31 -> 0.44; +priceFraction(N) when N < 0.36 -> 0.50; +priceFraction(N) when N < 0.41 -> 0.54; +priceFraction(N) when N < 0.46 -> 0.58; +priceFraction(N) when N < 0.51 -> 0.62; +priceFraction(N) when N < 0.56 -> 0.66; +priceFraction(N) when N < 0.61 -> 0.70; +priceFraction(N) when N < 0.66 -> 0.74; +priceFraction(N) when N < 0.71 -> 0.78; +priceFraction(N) when N < 0.76 -> 0.82; +priceFraction(N) when N < 0.81 -> 0.86; +priceFraction(N) when N < 0.86 -> 0.90; +priceFraction(N) when N < 0.91 -> 0.94; +priceFraction(N) when N < 0.96 -> 0.98; +priceFraction(N) -> 1.00. diff --git a/Task/Price-fraction/Euphoria/price-fraction.euphoria b/Task/Price-fraction/Euphoria/price-fraction.euphoria new file mode 100644 index 0000000000..f1cd56b0ac --- /dev/null +++ b/Task/Price-fraction/Euphoria/price-fraction.euphoria @@ -0,0 +1,20 @@ +constant table = { + {0.06, 0.10}, {0.11, 0.18}, {0.16, 0.26}, {0.21, 0.32}, + {0.26, 0.38}, {0.31, 0.44}, {0.36, 0.50}, {0.41, 0.54}, + {0.46, 0.58}, {0.51, 0.62}, {0.56, 0.66}, {0.61, 0.70}, + {0.66, 0.74}, {0.71, 0.78}, {0.76, 0.82}, {0.81, 0.86}, + {0.86, 0.90}, {0.91, 0.94}, {0.96, 0.98}, {1.01, 1.00} +} + +function price_fix(atom x) + for i = 1 to length(table) do + if x < table[i][1] then + return table[i][2] + end if + end for + return -1 +end function + +for i = 0 to 99 do + printf(1, "%.2f %.2f\n", { i/100, price_fix(i/100) }) +end for diff --git a/Task/Price-fraction/Fantom/price-fraction.fantom b/Task/Price-fraction/Fantom/price-fraction.fantom new file mode 100644 index 0000000000..726a8d6c7d --- /dev/null +++ b/Task/Price-fraction/Fantom/price-fraction.fantom @@ -0,0 +1,69 @@ +class Defn // to hold the three numbers from a 'row' in the table +{ + Float low + Float high + Float value + new make (Float low, Float high, Float value) + { + this.low = low + this.high = high + this.value = value + } +} + +class PriceConverter +{ + Defn[] defns := [,] + new make (Str table) // process given table and store numbers from each row in a defn + { + table.split('\n').each |Str line| + { + data := line.split + defns.add (Defn(Float.fromStr(data[1]), Float.fromStr(data[3]), Float.fromStr(data[5]))) + } + } + + public Float convert (Float price) // convert by looking through list of defns + { + Float result := price + defns.each |Defn defn| + { + if (price >= defn.low && price < defn.high) + result = defn.value + } + return result + } +} + +class Main +{ + public static Void main () + { + table := ">= 0.00 < 0.06 := 0.10 + >= 0.06 < 0.11 := 0.18 + >= 0.11 < 0.16 := 0.26 + >= 0.16 < 0.21 := 0.32 + >= 0.21 < 0.26 := 0.38 + >= 0.26 < 0.31 := 0.44 + >= 0.31 < 0.36 := 0.50 + >= 0.36 < 0.41 := 0.54 + >= 0.41 < 0.46 := 0.58 + >= 0.46 < 0.51 := 0.62 + >= 0.51 < 0.56 := 0.66 + >= 0.56 < 0.61 := 0.70 + >= 0.61 < 0.66 := 0.74 + >= 0.66 < 0.71 := 0.78 + >= 0.71 < 0.76 := 0.82 + >= 0.76 < 0.81 := 0.86 + >= 0.81 < 0.86 := 0.90 + >= 0.86 < 0.91 := 0.94 + >= 0.91 < 0.96 := 0.98 + >= 0.96 < 1.01 := 1.00" + converter := PriceConverter (table) + 10.times // simple test with random values + { + price := (0..100).random.toFloat / 100 + echo ("$price -> ${converter.convert (price)}") + } + } +} diff --git a/Task/Price-fraction/Forth/price-fraction.fth b/Task/Price-fraction/Forth/price-fraction.fth new file mode 100644 index 0000000000..dd6dbb6da8 --- /dev/null +++ b/Task/Price-fraction/Forth/price-fraction.fth @@ -0,0 +1,12 @@ +: as begin parse-word dup while evaluate , repeat 2drop ; + +create bounds as 96 91 86 81 76 71 66 61 56 51 46 41 36 31 26 21 16 11 6 0 +create official as 100 98 94 90 86 82 78 74 70 66 62 58 54 50 44 38 32 26 18 10 + +: official@ ( a-bounds -- +n ) + \ (a+n) - a + b = (a+n) + (b - a) = (b+n) + [ official bounds - ] literal + @ ; + +: round ( n-cents -- n-cents' ) + >r bounds begin dup @ r@ > while cell+ repeat + r> drop official@ ; diff --git a/Task/Price-fraction/Fortran/price-fraction-1.f b/Task/Price-fraction/Fortran/price-fraction-1.f new file mode 100644 index 0000000000..cdec01705e --- /dev/null +++ b/Task/Price-fraction/Fortran/price-fraction-1.f @@ -0,0 +1,19 @@ +program price_fraction + + implicit none + integer, parameter :: i_max = 10 + integer :: i + real, dimension (20), parameter :: in = & + & (/0.00, 0.06, 0.11, 0.16, 0.21, 0.26, 0.31, 0.36, 0.41, 0.46, & + & 0.51, 0.56, 0.61, 0.66, 0.71, 0.76, 0.81, 0.86, 0.91, 0.96/) + real, dimension (20), parameter :: out = & + & (/0.10, 0.18, 0.26, 0.32, 0.38, 0.44, 0.50, 0.54, 0.58, 0.62, & + & 0.66, 0.70, 0.74, 0.78, 0.82, 0.86, 0.90, 0.94, 0.98, 1.00/) + real :: r + + do i = 1, i_max + call random_number (r) + write (*, '(f8.6, 1x, f4.2)') r, out (maxloc (in, r >= in)) + end do + +end program price_fraction diff --git a/Task/Price-fraction/Fortran/price-fraction-2.f b/Task/Price-fraction/Fortran/price-fraction-2.f new file mode 100644 index 0000000000..85495b2d0e --- /dev/null +++ b/Task/Price-fraction/Fortran/price-fraction-2.f @@ -0,0 +1,10 @@ +0.997560 1.00 +0.566825 0.70 +0.965915 1.00 +0.747928 0.82 +0.367391 0.54 +0.480637 0.62 +0.073754 0.18 +0.005355 0.10 +0.347081 0.50 +0.342244 0.50 diff --git a/Task/Price-fraction/Go/price-fraction.go b/Task/Price-fraction/Go/price-fraction.go new file mode 100644 index 0000000000..31a028d425 --- /dev/null +++ b/Task/Price-fraction/Go/price-fraction.go @@ -0,0 +1,24 @@ +func pf(v float64) float64 { + switch { + case v < .06: return .10 + case v < .11: return .18 + case v < .16: return .26 + case v < .21: return .32 + case v < .26: return .38 + case v < .31: return .44 + case v < .36: return .50 + case v < .41: return .54 + case v < .46: return .58 + case v < .51: return .62 + case v < .56: return .66 + case v < .61: return .70 + case v < .66: return .74 + case v < .71: return .78 + case v < .76: return .82 + case v < .81: return .86 + case v < .86: return .90 + case v < .91: return .94 + case v < .96: return .98 + } + return 1 +} diff --git a/Task/Price-fraction/Groovy/price-fraction.groovy b/Task/Price-fraction/Groovy/price-fraction.groovy new file mode 100644 index 0000000000..19da1de616 --- /dev/null +++ b/Task/Price-fraction/Groovy/price-fraction.groovy @@ -0,0 +1,17 @@ +def priceFraction(value) { + assert value >= 0.0 && value <= 1.0 + + def priceMappings = [(0.06): 0.10, (0.11): 0.18, (0.16): 0.26, (0.21): 0.32, (0.26): 0.38, + (0.31): 0.44, (0.36): 0.50, (0.41): 0.54, (0.46): 0.58, (0.51): 0.62, + (0.56): 0.66, (0.61): 0.70, (0.66): 0.74, (0.71): 0.78, (0.76): 0.82, + (0.81): 0.86, (0.86): 0.90, (0.91): 0.94, (0.96): 0.98] + + for (price in priceMappings.keySet()) { + if (value < price) return priceMappings[price] + } + 1.00 +} + +for (def v = 0.00; v <= 1.00; v += 0.01) { + println "$v --> ${priceFraction(v)}" +} diff --git a/Task/Price-fraction/Haskell/price-fraction-1.hs b/Task/Price-fraction/Haskell/price-fraction-1.hs new file mode 100644 index 0000000000..e4f9cbaa0f --- /dev/null +++ b/Task/Price-fraction/Haskell/price-fraction-1.hs @@ -0,0 +1,22 @@ +price_fraction n + | n < 0 || n > 1 = error "Values must be between 0 and 1." + | n < 0.06 = 0.10 + | n < 0.11 = 0.18 + | n < 0.16 = 0.26 + | n < 0.21 = 0.32 + | n < 0.26 = 0.38 + | n < 0.31 = 0.44 + | n < 0.36 = 0.50 + | n < 0.41 = 0.54 + | n < 0.46 = 0.58 + | n < 0.51 = 0.62 + | n < 0.56 = 0.66 + | n < 0.61 = 0.70 + | n < 0.66 = 0.74 + | n < 0.71 = 0.78 + | n < 0.76 = 0.82 + | n < 0.81 = 0.86 + | n < 0.86 = 0.90 + | n < 0.91 = 0.94 + | n < 0.96 = 0.98 + | otherwise = 1.00 diff --git a/Task/Price-fraction/Haskell/price-fraction-2.hs b/Task/Price-fraction/Haskell/price-fraction-2.hs new file mode 100644 index 0000000000..5d8ceab1d1 --- /dev/null +++ b/Task/Price-fraction/Haskell/price-fraction-2.hs @@ -0,0 +1,10 @@ +table = [ + (0.06, 0.10), (0.11, 0.18), (0.16, 0.26), (0.21, 0.32), (0.26, 0.38), + (0.31, 0.44), (0.36, 0.50), (0.41, 0.54), (0.46, 0.58), (0.51, 0.62), + (0.56, 0.66), (0.61, 0.70), (0.66, 0.74), (0.71, 0.78), (0.76, 0.82), + (0.81, 0.86), (0.86, 0.90), (0.91, 0.94), (0.96, 0.98), (1.01, 1.00), + ] + +price_fraction n + | n < 0 || n > 1 = error "Values must be between 0 and 1." + | otherwise = snd $ head $ dropWhile ((<= n) . fst) table diff --git a/Task/Price-fraction/HicEst/price-fraction.hicest b/Task/Price-fraction/HicEst/price-fraction.hicest new file mode 100644 index 0000000000..5704a52350 --- /dev/null +++ b/Task/Price-fraction/HicEst/price-fraction.hicest @@ -0,0 +1,10 @@ +DIMENSION upperbound(20), rescaleTo(20), temp(20) +upperbound = (.06,.11,.16,.21,.26,.31,.36,.41,.46,.51,.56,.61,.66,.71,.76,.81,.86,.91,.96,1.01) +rescaleTo = (.10,.18,.26,.32,.38,.44,.50,.54,.58,.62,.66,.70,.74,.78,.82,.86,.90,.94,.98,1.00) + +DO test = 1, 10 + value = RAN(0.5, 0.5) + temp = value > upperbound + PriceFraction = rescaleTo( INDEX(temp, 0) ) + WRITE(Format="F8.6, F6.2") value, PriceFraction +ENDDO diff --git a/Task/Price-fraction/Icon/price-fraction.icon b/Task/Price-fraction/Icon/price-fraction.icon new file mode 100644 index 0000000000..f3bd70c499 --- /dev/null +++ b/Task/Price-fraction/Icon/price-fraction.icon @@ -0,0 +1,39 @@ +record Bounds(low,high,new) + +# rescale given value according to a list of bounds +procedure rescale (i, bounds) + every bound := !bounds do + if bound.low <= i < bound.high + then return bound.new + return fail # could not find i in bounds +end + +procedure main () + bounds := [ + Bounds(0.00, 0.06, 0.10), + Bounds(0.06, 0.11, 0.18), + Bounds(0.11, 0.16, 0.26), + Bounds(0.16, 0.21, 0.32), + Bounds(0.21, 0.26, 0.38), + Bounds(0.26, 0.31, 0.44), + Bounds(0.31, 0.36, 0.50), + Bounds(0.36, 0.41, 0.54), + Bounds(0.41, 0.46, 0.58), + Bounds(0.46, 0.51, 0.62), + Bounds(0.51, 0.56, 0.66), + Bounds(0.56, 0.61, 0.70), + Bounds(0.61, 0.66, 0.74), + Bounds(0.66, 0.71, 0.78), + Bounds(0.71, 0.76, 0.82), + Bounds(0.76, 0.81, 0.86), + Bounds(0.81, 0.86, 0.90), + Bounds(0.86, 0.91, 0.94), + Bounds(0.91, 0.96, 0.98), + Bounds(0.96, 1.01, 1.00) + ] + + # test the procedure + every i := 0.00 to 1.00 by 0.1 do { + write (i || " rescaled is " || rescale(i, bounds)) + } +end diff --git a/Task/Price-fraction/Inform-7/price-fraction.inf b/Task/Price-fraction/Inform-7/price-fraction.inf new file mode 100644 index 0000000000..bbd410415e --- /dev/null +++ b/Task/Price-fraction/Inform-7/price-fraction.inf @@ -0,0 +1,37 @@ +Home is a room. + +Price is a kind of value. 0.99 specifies a price. + +Table of Price Standardization +upper bound replacement +0.06 0.10 +0.11 0.18 +0.16 0.26 +0.21 0.32 +0.26 0.38 +0.31 0.44 +0.36 0.50 +0.41 0.54 +0.46 0.58 +0.51 0.62 +0.56 0.66 +0.61 0.70 +0.66 0.74 +0.71 0.78 +0.76 0.82 +0.81 0.86 +0.86 0.90 +0.91 0.94 +0.96 0.98 +1.01 1.00 + +To decide which price is the standardized value of (P - price): + repeat with N running from 1 to the number of rows in the Table of Price Standardization: + choose row N in the Table of Price Standardization; + if P is less than the upper bound entry, decide on the replacement entry. + +When play begins: + repeat with N running from 1 to 5: + let P be a random price between 0.00 and 1.00; + say "[P] -> [standardized value of P]."; + end the story. diff --git a/Task/Price-fraction/J/price-fraction-1.j b/Task/Price-fraction/J/price-fraction-1.j new file mode 100644 index 0000000000..94b53f7959 --- /dev/null +++ b/Task/Price-fraction/J/price-fraction-1.j @@ -0,0 +1,4 @@ +le =: -0.96 0.91 0.86 0.81 0.76 0.71 0.66 0.61 0.56 0.51 0.46 0.41 0.36 0.31 0.26 0.21 0.16 0.11 0.06 0.0 +out =: 1.00 0.98 0.94 0.90 0.86 0.82 0.78 0.74 0.70 0.66 0.62 0.58 0.54 0.50 0.44 0.38 0.32 0.26 0.18 0.1 + +priceFraction =: out {~ le I. - diff --git a/Task/Price-fraction/J/price-fraction-2.j b/Task/Price-fraction/J/price-fraction-2.j new file mode 100644 index 0000000000..23612a7f8f --- /dev/null +++ b/Task/Price-fraction/J/price-fraction-2.j @@ -0,0 +1,2 @@ + priceFraction 0.34 0.070145 0.06 0.05 0.50214 0.56 1 0.99 0 +0.5 0.18 0.18 0.1 0.62 0.7 1 1 0.1 diff --git a/Task/Price-fraction/Java/price-fraction.java b/Task/Price-fraction/Java/price-fraction.java new file mode 100644 index 0000000000..e48629a219 --- /dev/null +++ b/Task/Price-fraction/Java/price-fraction.java @@ -0,0 +1,35 @@ +import java.util.Random; + +public class Main { + private static float priceFraction(float f) { + if (0.00f <= f && f < 0.06f) return 0.10f; + else if (f < 0.11f) return 0.18f; + else if (f < 0.16f) return 0.26f; + else if (f < 0.21f) return 0.32f; + else if (f < 0.26f) return 0.38f; + else if (f < 0.31f) return 0.44f; + else if (f < 0.36f) return 0.50f; + else if (f < 0.41f) return 0.54f; + else if (f < 0.46f) return 0.58f; + else if (f < 0.51f) return 0.62f; + else if (f < 0.56f) return 0.66f; + else if (f < 0.61f) return 0.70f; + else if (f < 0.66f) return 0.74f; + else if (f < 0.71f) return 0.78f; + else if (f < 0.76f) return 0.82f; + else if (f < 0.81f) return 0.86f; + else if (f < 0.86f) return 0.90f; + else if (f < 0.91f) return 0.94f; + else if (f < 0.96f) return 0.98f; + else if (f < 1.01f) return 1.00f; + else throw new IllegalArgumentException(); + } + + public static void main(String[] args) { + Random rnd = new Random(); + for (int i = 0; i < 5; i++) { + float f = rnd.nextFloat(); + System.out.format("%8.6f -> %4.2f%n", f, priceFraction(f)); + } + } +} diff --git a/Task/Price-fraction/JavaScript/price-fraction.js b/Task/Price-fraction/JavaScript/price-fraction.js new file mode 100644 index 0000000000..6313132515 --- /dev/null +++ b/Task/Price-fraction/JavaScript/price-fraction.js @@ -0,0 +1,8 @@ +function getScaleFactor(v) { + + var values = ['0.10','0.18','0.26','0.32','0.38','0.44','0.50','0.54', + '0.58','0.62','0.66','0.70','0.74','0.78','0.82','0.86', + '0.90','0.94','0.98','1.00']; + + return values[(v * 100 - 1) / 5 | 0]; +} diff --git a/Task/Price-fraction/K/price-fraction-1.k b/Task/Price-fraction/K/price-fraction-1.k new file mode 100644 index 0000000000..68bf835d28 --- /dev/null +++ b/Task/Price-fraction/K/price-fraction-1.k @@ -0,0 +1,4 @@ +le:- 0.96 0.91 0.86 0.81 0.76 0.71 0.66 0.61 0.56 0.51 0.46 0.41 0.36 0.31 0.26 0.21 0.16 0.11 0.06 0.0 +out: 1.00 0.98 0.94 0.90 0.86 0.82 0.78 0.74 0.70 0.66 0.62 0.58 0.54 0.50 0.44 0.38 0.32 0.26 0.18 0.1 + +pf:{out@_bin[le;-x]}' diff --git a/Task/Price-fraction/K/price-fraction-2.k b/Task/Price-fraction/K/price-fraction-2.k new file mode 100644 index 0000000000..44d66b2ddf --- /dev/null +++ b/Task/Price-fraction/K/price-fraction-2.k @@ -0,0 +1,2 @@ + pf 0.6094701 0.5003597 0.8512954 0.08951883 0.6868076 +0.7 0.62 0.9 0.18 0.78 diff --git a/Task/Price-fraction/Liberty-BASIC/price-fraction.liberty b/Task/Price-fraction/Liberty-BASIC/price-fraction.liberty new file mode 100644 index 0000000000..77ccbe8b1e --- /dev/null +++ b/Task/Price-fraction/Liberty-BASIC/price-fraction.liberty @@ -0,0 +1,23 @@ +dim DR(38) 'decimal range +dim PF(38) 'corresponding price fraction +range$="0.06 0.11 0.16 0.21 0.26 0.31 0.36 0.41 0.46 0.51 0.56 0.61 0.66 0.71 0.76 0.81 0.86 0.91 0.96 0.01" +frac$="0.10 0.18 0.26 0.32 0.38 0.44 0.50 0.54 0.58 0.62 0.66 0.70 0.74 0.78 0.82 0.86 0.90 0.94 0.98 1.00" +for i = 1 to 38 + DR(i)=val(word$(range$,i)) + PF(i)=val(word$(frac$,i)) +next + +for i = 0 to .99 step 0.03 + print i;" -> ";PriceFraction(i) +next +end + +Function PriceFraction(n) + PriceFraction=n 'return original if outside test bounds + for i = 1 to 38 + if n<=DR(i) then + PriceFraction=PF(i) + exit for + end if + next + end function diff --git a/Task/Price-fraction/MATLAB/price-fraction.m b/Task/Price-fraction/MATLAB/price-fraction.m new file mode 100644 index 0000000000..73e1aa2ce4 --- /dev/null +++ b/Task/Price-fraction/MATLAB/price-fraction.m @@ -0,0 +1,13 @@ + function y = rescale(x) + + L = [0,.06:.05:1.02]; + V = [.1,.18,.26,.32,.38,.44,.50,.54,.58,.62,.66,.70,.74,.78,.82,.86,.9,.94,.98,1]; + + y = x; + for k=1:numel(x); + y(k) = V(sum(L<=x(k))); + end; + end; + + t=0:0.001:1; + plot(t,rescale(t)); diff --git a/Task/Price-fraction/MUMPS/price-fraction.mumps b/Task/Price-fraction/MUMPS/price-fraction.mumps new file mode 100644 index 0000000000..8c80e219be --- /dev/null +++ b/Task/Price-fraction/MUMPS/price-fraction.mumps @@ -0,0 +1,11 @@ +PRICFRAC(X) + ;Outputs a specified value dependent upon the input value + ;The non-inclusive upper limits are encoded in the PFMAX string, and the values + ;to convert to are encoded in the PFRES string. + NEW PFMAX,PFRES,I,RESULT + SET PFMAX=".06^.11^.16^.21^.26^.31^.36^.41^.46^.51^.56^.61^.66^.71^.76^.81^.86^.91^.96^1.01" + SET PFRES=".10^.18^.26^.32^.38^.44^.50^.54^.58^.62^.66^.70^.74^.78^.82^.86^.90^.94^.98^1.00" + Q:(X<0)!(X>1.01) "" + FOR I=1:1:$LENGTH(PFMAX,"^") Q:($DATA(RESULT)'=0) SET:X<$P(PFMAX,"^",I) RESULT=$P(PFRES,"^",I) + KILL PFMAX,PFRES,I + QUIT RESULT diff --git a/Task/Price-fraction/Mathematica/price-fraction.math b/Task/Price-fraction/Mathematica/price-fraction.math new file mode 100644 index 0000000000..ebc62ce7e1 --- /dev/null +++ b/Task/Price-fraction/Mathematica/price-fraction.math @@ -0,0 +1,5 @@ +PriceFraction[x_]:=Piecewise[{{.1, 0 <= x < 0.06}, {.18, x < .11}, {.26,x < 0.16}, +{.32, x < .21}, {.38, x < .26}, {.44, x < 0.31}, {.5, x < .36}, +{.54, x < .41}, {.58, x < .46}, {.62, x < .51}, {.66, x < .56}, +{.70, x < .61}, {.74, x < .66}, {.78, x < .71}, {.82, x < .76}, +{.86, x < .81}, {.90, x < .86}, {.94, x < .91}, {.98, x < .96}}, 1] diff --git a/Task/Price-fraction/Mercury/price-fraction-1.mercury b/Task/Price-fraction/Mercury/price-fraction-1.mercury new file mode 100644 index 0000000000..d746ac143c --- /dev/null +++ b/Task/Price-fraction/Mercury/price-fraction-1.mercury @@ -0,0 +1,44 @@ +:- module price. +:- interface. +:- import_module int. +:- type price == int. +:- func standard(price) = price. + +:- implementation. +:- import_module require, list. + +standard(P) = SP :- + require(P >= 0, "P must be positive"), + Cents = P `mod` 100, + P + adjust(Cents) = SP. + +:- func adjust(int) = int. +adjust(Cents) = adjust(Cents, rules). + +:- func adjust(int, list(price_rule)) = int. +adjust(_, []) = unexpected("price", "adjust/2", "exhausted rules"). +adjust(N, [rule(Low, High, To)|T]) = R :- + ( N >= Low, N < High -> To - N = R ; adjust(N, T) = R ). + +:- type price_rule ---> rule(int, int, int). +:- func rules = list(price_rule). +rules = [rule(00, 06, 10), + rule(06, 11, 18), + rule(11, 16, 26), + rule(16, 21, 32), + rule(21, 26, 38), + rule(26, 31, 44), + rule(31, 36, 50), + rule(36, 41, 54), + rule(41, 46, 58), + rule(46, 51, 62), + rule(51, 56, 66), + rule(56, 61, 70), + rule(61, 66, 74), + rule(66, 71, 78), + rule(71, 76, 82), + rule(76, 81, 86), + rule(81, 86, 90), + rule(86, 91, 94), + rule(91, 96, 98), + rule(96, 101, 100)]. diff --git a/Task/Price-fraction/Mercury/price-fraction-2.mercury b/Task/Price-fraction/Mercury/price-fraction-2.mercury new file mode 100644 index 0000000000..246560958d --- /dev/null +++ b/Task/Price-fraction/Mercury/price-fraction-2.mercury @@ -0,0 +1 @@ +adjust(Cents) = array.lookup(price_table, Cents). diff --git a/Task/Price-fraction/OCaml/price-fraction-1.ocaml b/Task/Price-fraction/OCaml/price-fraction-1.ocaml new file mode 100644 index 0000000000..4b03399cdb --- /dev/null +++ b/Task/Price-fraction/OCaml/price-fraction-1.ocaml @@ -0,0 +1,15 @@ +let price_fraction v = + if v < 0.0 || v >= 1.01 then + invalid_arg "price_fraction"; + let rec aux = function + | (x,r)::tl -> + if v < x then r + else aux tl + | [] -> assert false + in + aux [ + 0.06, 0.10; 0.11, 0.18; 0.16, 0.26; 0.21, 0.32; 0.26, 0.38; + 0.31, 0.44; 0.36, 0.50; 0.41, 0.54; 0.46, 0.58; 0.51, 0.62; + 0.56, 0.66; 0.61, 0.70; 0.66, 0.74; 0.71, 0.78; 0.76, 0.82; + 0.81, 0.86; 0.86, 0.90; 0.91, 0.94; 0.96, 0.98; 1.01, 1.00; + ] diff --git a/Task/Price-fraction/OCaml/price-fraction-2.ocaml b/Task/Price-fraction/OCaml/price-fraction-2.ocaml new file mode 100644 index 0000000000..51236cc167 --- /dev/null +++ b/Task/Price-fraction/OCaml/price-fraction-2.ocaml @@ -0,0 +1,18 @@ +let () = + let ok_tests = [ + (0.3793, 0.54); + (0.4425, 0.58); + (0.0746, 0.18); + (0.6918, 0.78); + (0.2993, 0.44); + (0.5486, 0.66); + (0.7848, 0.86); + (0.9383, 0.98); + (0.2292, 0.38); + ] in + Printf.printf " input res ok\n"; + List.iter (fun (v,ok) -> + let r = price_fraction v in + Printf.printf " %6g %g %b\n" v r (r = ok); + ) ok_tests; +;; diff --git a/Task/Price-fraction/Oz/price-fraction.oz b/Task/Price-fraction/Oz/price-fraction.oz new file mode 100644 index 0000000000..1130b2cb7b --- /dev/null +++ b/Task/Price-fraction/Oz/price-fraction.oz @@ -0,0 +1,15 @@ +fun {PriceFraction X} + OutOfRange = {Value.failed outOfRange(X)} +in + for Limit#Result in + [0.00#OutOfRange + 0.06#0.10 0.11#0.18 0.16#0.26 0.21#0.32 0.26#0.38 0.31#0.44 0.36#0.5 + 0.41#0.54 0.46#0.58 0.51#0.62 0.56#0.66 0.61#0.70 0.66#0.74 0.71#0.78 + 0.76#0.82 0.81#0.86 0.86#0.90 0.91#0.94 0.96#0.98 1.01#1.00 + ] + return:Return + default:OutOfRange + do + if X < Limit then {Return Result} end + end +end diff --git a/Task/Price-fraction/PARI-GP/price-fraction.pari b/Task/Price-fraction/PARI-GP/price-fraction.pari new file mode 100644 index 0000000000..dc5be19277 --- /dev/null +++ b/Task/Price-fraction/PARI-GP/price-fraction.pari @@ -0,0 +1,9 @@ +priceLookup=[6,11,16,21,26,31,41,46,51,56,61,66,71,76,81,86,91,96,101]; +priceReplace=[10,18,26,32,38,44,50,54,58,62,66,70,74,78,82,86,90,94,98,100]; +pf(x)={ + x*=100; + for(i=1,19, + if(x ', price[j+1]:4:2); + end; +end. diff --git a/Task/Price-fraction/Perl-6/price-fraction-1.pl6 b/Task/Price-fraction/Perl-6/price-fraction-1.pl6 new file mode 100644 index 0000000000..4313a6ed0f --- /dev/null +++ b/Task/Price-fraction/Perl-6/price-fraction-1.pl6 @@ -0,0 +1,35 @@ +my $table = " +>= 0.00 < 0.06 := 0.10 +>= 0.06 < 0.11 := 0.18 +>= 0.11 < 0.16 := 0.26 +>= 0.16 < 0.21 := 0.32 +>= 0.21 < 0.26 := 0.38 +>= 0.26 < 0.31 := 0.44 +>= 0.31 < 0.36 := 0.50 +>= 0.36 < 0.41 := 0.54 +>= 0.41 < 0.46 := 0.58 +>= 0.46 < 0.51 := 0.62 +>= 0.51 < 0.56 := 0.66 +>= 0.56 < 0.61 := 0.70 +>= 0.61 < 0.66 := 0.74 +>= 0.66 < 0.71 := 0.78 +>= 0.71 < 0.76 := 0.82 +>= 0.76 < 0.81 := 0.86 +>= 0.81 < 0.86 := 0.90 +>= 0.86 < 0.91 := 0.94 +>= 0.91 < 0.96 := 0.98 +>= 0.96 < 1.01 := 1.00 +"; + +my $value = 0.44; + +say price($value); + +sub price($value) +{ + for $table.lines -> $line { + $line ~~ / '>=' \s+ (\S+) \s+ '<' \s+ (\S+) \s+ ':=' \s+ (\S+)/; + return $2 if $0 <= $value < $1; + } + fail "Out of range"; +} diff --git a/Task/Price-fraction/Perl-6/price-fraction-2.pl6 b/Task/Price-fraction/Perl-6/price-fraction-2.pl6 new file mode 100644 index 0000000000..ea1995c26a --- /dev/null +++ b/Task/Price-fraction/Perl-6/price-fraction-2.pl6 @@ -0,0 +1,26 @@ +my @price = map *.value, + ( 0 ..^ 6 X=> 0.10), + ( 6 ..^ 11 X=> 0.18), + (11 ..^ 16 X=> 0.26), + (16 ..^ 21 X=> 0.32), + (21 ..^ 26 X=> 0.38), + (26 ..^ 31 X=> 0.44), + (31 ..^ 36 X=> 0.50), + (36 ..^ 41 X=> 0.54), + (41 ..^ 46 X=> 0.58), + (46 ..^ 51 X=> 0.62), + (51 ..^ 56 X=> 0.66), + (56 ..^ 61 X=> 0.70), + (61 ..^ 66 X=> 0.74), + (66 ..^ 71 X=> 0.78), + (71 ..^ 76 X=> 0.82), + (76 ..^ 81 X=> 0.86), + (81 ..^ 86 X=> 0.90), + (86 ..^ 91 X=> 0.94), + (91 ..^ 96 X=> 0.98), + (96 ..^101 X=> 1.00), +; + +while prompt("value: ") -> $value { + say @price[ $value * 100 ] // note "Out of range"; +} diff --git a/Task/Price-fraction/Perl-6/price-fraction-3.pl6 b/Task/Price-fraction/Perl-6/price-fraction-3.pl6 new file mode 100644 index 0000000000..41b1671142 --- /dev/null +++ b/Task/Price-fraction/Perl-6/price-fraction-3.pl6 @@ -0,0 +1,28 @@ +sub price_fraction ( Num $n where { $^n >= 0 and $^n <= 1 } ) { + ( $n < 0.06 ) ?? 0.10 + !! ( $n < 0.11 ) ?? 0.18 + !! ( $n < 0.16 ) ?? 0.26 + !! ( $n < 0.21 ) ?? 0.32 + !! ( $n < 0.26 ) ?? 0.38 + !! ( $n < 0.31 ) ?? 0.44 + !! ( $n < 0.36 ) ?? 0.50 + !! ( $n < 0.41 ) ?? 0.54 + !! ( $n < 0.46 ) ?? 0.58 + !! ( $n < 0.51 ) ?? 0.62 + !! ( $n < 0.56 ) ?? 0.66 + !! ( $n < 0.61 ) ?? 0.70 + !! ( $n < 0.66 ) ?? 0.74 + !! ( $n < 0.71 ) ?? 0.78 + !! ( $n < 0.76 ) ?? 0.82 + !! ( $n < 0.81 ) ?? 0.86 + !! ( $n < 0.86 ) ?? 0.90 + !! ( $n < 0.91 ) ?? 0.94 + !! ( $n < 0.96 ) ?? 0.98 + !! 1.00 + ; +} + +while prompt("value: ") -> $value { + last if $value ~~ /exit|quit/; + say price_fraction(+$value); +} diff --git a/Task/Price-fraction/Perl/price-fraction.pl b/Task/Price-fraction/Perl/price-fraction.pl new file mode 100644 index 0000000000..7bb5aefc77 --- /dev/null +++ b/Task/Price-fraction/Perl/price-fraction.pl @@ -0,0 +1,36 @@ +my @table = map [ /([\d\.]+)/g ], split "\n", <<'TBL'; +>= 0.00 < 0.06 := 0.10 +>= 0.06 < 0.11 := 0.18 +>= 0.11 < 0.16 := 0.26 +>= 0.16 < 0.21 := 0.32 +>= 0.21 < 0.26 := 0.38 +>= 0.26 < 0.31 := 0.44 +>= 0.31 < 0.36 := 0.50 +>= 0.36 < 0.41 := 0.54 +>= 0.41 < 0.46 := 0.58 +>= 0.46 < 0.51 := 0.62 +>= 0.51 < 0.56 := 0.66 +>= 0.56 < 0.61 := 0.70 +>= 0.61 < 0.66 := 0.74 +>= 0.66 < 0.71 := 0.78 +>= 0.71 < 0.76 := 0.82 +>= 0.76 < 0.81 := 0.86 +>= 0.81 < 0.86 := 0.90 +>= 0.86 < 0.91 := 0.94 +>= 0.91 < 0.96 := 0.98 +>= 0.96 < 1.01 := 1.00 +TBL + +sub convert { + my $money = shift; + for (@table) { + return $_->[2] if $_->[0] <= $money and $_->[1] > $money + } + die "Can't find currency conversion for $money. Counterfeit?" +} + +# try it out +for (1 .. 10) { + my $m = rand(1); + printf "%.3f -> %g\n", $m, convert($m); +} diff --git a/Task/Price-fraction/PicoLisp/price-fraction.l b/Task/Price-fraction/PicoLisp/price-fraction.l new file mode 100644 index 0000000000..512837ffef --- /dev/null +++ b/Task/Price-fraction/PicoLisp/price-fraction.l @@ -0,0 +1,31 @@ +(scl 2) + +(de price (Pr) + (format + (cdr + (rank Pr + (quote + (0.00 . 0.10) + (0.06 . 0.18) + (0.11 . 0.26) + (0.16 . 0.32) + (0.21 . 0.38) + (0.26 . 0.44) + (0.31 . 0.50) + (0.36 . 0.54) + (0.41 . 0.58) + (0.46 . 0.62) + (0.51 . 0.66) + (0.56 . 0.70) + (0.61 . 0.74) + (0.66 . 0.78) + (0.71 . 0.82) + (0.76 . 0.86) + (0.81 . 0.90) + (0.86 . 0.94) + (0.91 . 0.98) + (0.96 . 1.00) ) ) ) + *Scl ) ) + +(for N (0.3793 0.4425 0.0746 0.6918 0.2993 0.5486 0.7848 0.9383 0.2292) + (prinl (price N)) ) diff --git a/Task/Price-fraction/PureBasic/price-fraction.purebasic b/Task/Price-fraction/PureBasic/price-fraction.purebasic new file mode 100644 index 0000000000..9d34546cc0 --- /dev/null +++ b/Task/Price-fraction/PureBasic/price-fraction.purebasic @@ -0,0 +1,63 @@ +Procedure.f PriceFraction(price.f) + ;returns price unchanged if value is invalid + Protected fraction + Select price * 100 + Case 0 To 5 + fraction = 10 + Case 06 To 10 + fraction = 18 + Case 11 To 15 + fraction = 26 + Case 16 To 20 + fraction = 32 + Case 21 To 25 + fraction = 38 + Case 26 To 30 + fraction = 44 + Case 31 To 35 + fraction = 5 + Case 36 To 40 + fraction = 54 + Case 41 To 45 + fraction = 58 + Case 46 To 50 + fraction = 62 + Case 51 To 55 + fraction = 66 + Case 56 To 60 + fraction = 7 + Case 61 To 65 + fraction = 74 + Case 66 To 70 + fraction = 78 + Case 71 To 75 + fraction = 82 + Case 76 To 80 + fraction = 86 + Case 81 To 85 + fraction = 9 + Case 86 To 90 + fraction = 94 + Case 91 To 95 + fraction = 98 + Case 96 To 100 + fraction = 100 + Default + ProcedureReturn price + EndSelect + + ProcedureReturn fraction / 100 +EndProcedure + +If OpenConsole() + Define x.f, i + + For i = 1 To 10 + x = Random(10000)/10000 + PrintN(StrF(x, 4) + " -> " + StrF(PriceFraction(x), 2)) + Next + + Print(#CRLF$ + #CRLF$ + "Press ENTER to exit") + Input() + CloseConsole() +EndIf diff --git a/Task/Price-fraction/Python/price-fraction-1.py b/Task/Price-fraction/Python/price-fraction-1.py new file mode 100644 index 0000000000..fc85f4579f --- /dev/null +++ b/Task/Price-fraction/Python/price-fraction-1.py @@ -0,0 +1,5 @@ +>>> import bisect +>>> _cin = [.06, .11, .16, .21, .26, .31, .36, .41, .46, .51, .56, .61, .66, .71, .76, .81, .86, .91, .96, 1.01] +>>> _cout = [.10, .18, .26, .32, .38, .44, .50, .54, .58, .62, .66, .70, .74, .78, .82, .86, .90, .94, .98, 1.00] +>>> def pricerounder(pricein): + return _cout[ bisect.bisect_right(_cin, pricein) ] diff --git a/Task/Price-fraction/Python/price-fraction-2.py b/Task/Price-fraction/Python/price-fraction-2.py new file mode 100644 index 0000000000..da053cef8e --- /dev/null +++ b/Task/Price-fraction/Python/price-fraction-2.py @@ -0,0 +1,5 @@ +>>> import bisect +>>> _cin = [ 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71, 76, 81, 86, 91, 96, 101] +>>> _cout = [10, 18, 26, 32, 38, 44, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 98, 100] +>>> def centsrounder(centsin): + return _cout[ bisect.bisect_right(_cin, centsin) ] diff --git a/Task/Price-fraction/Python/price-fraction-3.py b/Task/Price-fraction/Python/price-fraction-3.py new file mode 100644 index 0000000000..f40efd5175 --- /dev/null +++ b/Task/Price-fraction/Python/price-fraction-3.py @@ -0,0 +1,20 @@ +def bisect_right(a, x, lo=0, hi=None): + """Return the index where to insert item x in list a, assuming a is sorted. + + The return value i is such that all e in a[:i] have e <= x, and all e in + a[i:] have e > x. So if x already appears in the list, a.insert(x) will + insert just after the rightmost x already there. + + Optional args lo (default 0) and hi (default len(a)) bound the + slice of a to be searched. + """ + + if lo < 0: + raise ValueError('lo must be non-negative') + if hi is None: + hi = len(a) + while lo < hi: + mid = (lo+hi)//2 + if x < a[mid]: hi = mid + else: lo = mid+1 + return lo diff --git a/Task/Price-fraction/R/price-fraction-1.r b/Task/Price-fraction/R/price-fraction-1.r new file mode 100644 index 0000000000..aa214eeacc --- /dev/null +++ b/Task/Price-fraction/R/price-fraction-1.r @@ -0,0 +1,11 @@ +price_fraction <- function(x) +{ + stopifnot(all(x >= 0 & x <= 1)) + breaks <- seq(0.06, 1.01, 0.05) + values <- c(.1, .18, .26, .32, .38, .44, .5, .54, .58, .62, .66, .7, .74, .78, .82, .86, .9, .94, .98, 1) + indices <- sapply(x, function(x) which(x < breaks)[1]) + values[indices] +} + +#Example usage: +price_fraction(c(0, .01, 0.06, 0.25, 1)) # 0.10 0.10 0.18 0.38 1.00 diff --git a/Task/Price-fraction/R/price-fraction-2.r b/Task/Price-fraction/R/price-fraction-2.r new file mode 100644 index 0000000000..490927ca40 --- /dev/null +++ b/Task/Price-fraction/R/price-fraction-2.r @@ -0,0 +1,23 @@ +dfr <- read.table(tc <- textConnection( +">= 0.00 < 0.06 := 0.10 +>= 0.06 < 0.11 := 0.18 +>= 0.11 < 0.16 := 0.26 +>= 0.16 < 0.21 := 0.32 +>= 0.21 < 0.26 := 0.38 +>= 0.26 < 0.31 := 0.44 +>= 0.31 < 0.36 := 0.50 +>= 0.36 < 0.41 := 0.54 +>= 0.41 < 0.46 := 0.58 +>= 0.46 < 0.51 := 0.62 +>= 0.51 < 0.56 := 0.66 +>= 0.56 < 0.61 := 0.70 +>= 0.61 < 0.66 := 0.74 +>= 0.66 < 0.71 := 0.78 +>= 0.71 < 0.76 := 0.82 +>= 0.76 < 0.81 := 0.86 +>= 0.81 < 0.86 := 0.90 +>= 0.86 < 0.91 := 0.94 +>= 0.91 < 0.96 := 0.98 +>= 0.96 < 1.01 := 1.00")); close(tc) +breaks <- dfr$V4 +values <- dfr$V6 diff --git a/Task/Price-fraction/REXX/price-fraction.rexx b/Task/Price-fraction/REXX/price-fraction.rexx new file mode 100644 index 0000000000..ba1e35c758 --- /dev/null +++ b/Task/Price-fraction/REXX/price-fraction.rexx @@ -0,0 +1,32 @@ +/*REXX program to rescale a (decimal fraction) price (0.99 ──► 1.00).*/ +pad=' ' /*for inserting spaces into msg. */ + do j=0 to 1 by .01; if j==0 then j=0.00 /*special case.*/ + say pad 'original price ──►' j pad adjPrice(j) " ◄── adjusted price" + end /*j*/ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────ADJPRICE subroutine─────────────────*/ +adjPrice: procedure; parse arg ? + select + when ?<0.06 then ?=0.10 + when ?<0.11 then ?=0.18 + when ?<0.16 then ?=0.26 + when ?<0.21 then ?=0.32 + when ?<0.26 then ?=0.38 + when ?<0.31 then ?=0.44 + when ?<0.36 then ?=0.50 + when ?<0.41 then ?=0.54 + when ?<0.46 then ?=0.58 + when ?<0.51 then ?=0.62 + when ?<0.56 then ?=0.66 + when ?<0.61 then ?=0.70 + when ?<0.66 then ?=0.74 + when ?<0.71 then ?=0.78 + when ?<0.76 then ?=0.82 + when ?<0.81 then ?=0.86 + when ?<0.86 then ?=0.90 + when ?<0.91 then ?=0.94 + when ?<0.96 then ?=0.98 + when ?<1.01 then ?=1.00 + otherwise nop + end /*select*/ +return ? diff --git a/Task/Price-fraction/Ruby/price-fraction-1.rb b/Task/Price-fraction/Ruby/price-fraction-1.rb new file mode 100644 index 0000000000..f8b845e7af --- /dev/null +++ b/Task/Price-fraction/Ruby/price-fraction-1.rb @@ -0,0 +1,24 @@ +def rescale_price_fraction(value) + raise ArgumentError, "value=#{value}, must have: 0 <= value < 1.01" if value < 0 || value >= 1.01 + if value < 0.06 then 0.10 + elsif value < 0.11 then 0.18 + elsif value < 0.16 then 0.26 + elsif value < 0.21 then 0.32 + elsif value < 0.26 then 0.38 + elsif value < 0.31 then 0.44 + elsif value < 0.36 then 0.50 + elsif value < 0.41 then 0.54 + elsif value < 0.46 then 0.58 + elsif value < 0.51 then 0.62 + elsif value < 0.56 then 0.66 + elsif value < 0.61 then 0.70 + elsif value < 0.66 then 0.74 + elsif value < 0.71 then 0.78 + elsif value < 0.76 then 0.82 + elsif value < 0.81 then 0.86 + elsif value < 0.86 then 0.90 + elsif value < 0.91 then 0.94 + elsif value < 0.96 then 0.98 + elsif value < 1.01 then 1.00 + end +end diff --git a/Task/Price-fraction/Ruby/price-fraction-2.rb b/Task/Price-fraction/Ruby/price-fraction-2.rb new file mode 100644 index 0000000000..1bea224bd3 --- /dev/null +++ b/Task/Price-fraction/Ruby/price-fraction-2.rb @@ -0,0 +1,48 @@ +class Price + ConversionTable = <<-END_OF_TABLE + >= 0.00 < 0.06 := 0.10 + >= 0.06 < 0.11 := 0.18 + >= 0.11 < 0.16 := 0.26 + >= 0.16 < 0.21 := 0.32 + >= 0.21 < 0.26 := 0.38 + >= 0.26 < 0.31 := 0.44 + >= 0.31 < 0.36 := 0.50 + >= 0.36 < 0.41 := 0.54 + >= 0.41 < 0.46 := 0.58 + >= 0.46 < 0.51 := 0.62 + >= 0.51 < 0.56 := 0.66 + >= 0.56 < 0.61 := 0.70 + >= 0.61 < 0.66 := 0.74 + >= 0.66 < 0.71 := 0.78 + >= 0.71 < 0.76 := 0.82 + >= 0.76 < 0.81 := 0.86 + >= 0.81 < 0.86 := 0.90 + >= 0.86 < 0.91 := 0.94 + >= 0.91 < 0.96 := 0.98 + >= 0.96 < 1.01 := 1.00 + END_OF_TABLE + + RE = %r{ ([<>=]+) \s* (\d\.\d\d) \s* ([<>=]+) \s* (\d\.\d\d) \D+ (\d\.\d\d) }x + + # extract the comparison operators and numbers from the table + CONVERSION_TABLE = ConversionTable.lines.inject([]) do |table, line| + m = line.match(RE) + if not m.nil? and m.length == 6 + table << [m[1], m[2].to_f, m[3], m[4].to_f, m[5].to_f] + end + table + end + + MIN_COMP, MIN = CONVERSION_TABLE[0][0..1] + MAX_COMP, MAX = CONVERSION_TABLE[-1][2..3] + + def initialize(value) + if (not value.send(MIN_COMP, MIN)) or (not value.send(MAX_COMP, MAX)) + raise ArgumentError, "value=#{value}, must have: #{MIN} #{MIN_COMP} value #{MAX_COMP} #{MAX}" + end + @standard_value = CONVERSION_TABLE.find do |comp1, lower, comp2, upper, standard| + value.send(comp1, lower) and value.send(comp2, upper) + end.last + end + attr_reader :standard_value +end diff --git a/Task/Price-fraction/Ruby/price-fraction-3.rb b/Task/Price-fraction/Ruby/price-fraction-3.rb new file mode 100644 index 0000000000..eba16b4bfc --- /dev/null +++ b/Task/Price-fraction/Ruby/price-fraction-3.rb @@ -0,0 +1,27 @@ +require 'test/unit' + +class PriceFractionTests < Test::Unit::TestCase + @@ok_tests = [ + [0.3793, 0.54], + [0.4425, 0.58], + [0.0746, 0.18], + [0.6918, 0.78], + [0.2993, 0.44], + [0.5486, 0.66], + [0.7848, 0.86], + [0.9383, 0.98], + [0.2292, 0.38], + ] + @@bad_tests = [1.02, -3] + + def test_ok + @@ok_tests.each do |val, exp| + assert_equal(exp, rescale_price_fraction(val)) + assert_equal(exp, Price.new(val).standard_value) + end + @@bad_tests.each do |val| + assert_raise(ArgumentError) {rescale_price_fraction(val)} + assert_raise(ArgumentError) {Price.new(val).standard_value} + end + end +end diff --git a/Task/Price-fraction/Run-BASIC/price-fraction.run b/Task/Price-fraction/Run-BASIC/price-fraction.run new file mode 100644 index 0000000000..585ca5e68c --- /dev/null +++ b/Task/Price-fraction/Run-BASIC/price-fraction.run @@ -0,0 +1,20 @@ +data .06, .1,.11,.18,.16,.26,.21,.32,.26,.38,.31,.44,.36,.50,.41,.54,.46,.58,.51,.62 +data .56,.66,.61,.70,.66,.74,.71,.78,.76,.82,.81,.86,.86,.90,.91,.94,.96,.98 + +dim od(100) +dim nd(100) +for i = 1 to 19 +read oldDec +read newDec +j = j + 1 +for j = j to oldDec * 100 + nd(j) = newDec +next j +next i + +[loop] +input "Gimme a number";numb +decm = val(using("##",(numb mod 1) * 100)) +print numb;" -->";nd(decm) + +goto [loop] diff --git a/Task/Price-fraction/Scala/price-fraction.scala b/Task/Price-fraction/Scala/price-fraction.scala new file mode 100644 index 0000000000..11c604cc07 --- /dev/null +++ b/Task/Price-fraction/Scala/price-fraction.scala @@ -0,0 +1,10 @@ +def priceFraction(x:Double)=x match { + case n if n>=0 && n<0.06 => 0.10 + case n if n<0.11 => 0.18 + case n if n<0.36 => ((((n*100).toInt-11)/5)*6+26)/100.toDouble + case n if n<0.96 => ((((n*100).toInt-31)/5)*4+50)/100.toDouble + case _ => 1.00 +} + +def testPriceFraction()= + for(n <- 0.00 to (1.00, 0.01)) println("%.2f %.2f".format(n, priceFraction(n))) diff --git a/Task/Price-fraction/Seed7/price-fraction-1.seed7 b/Task/Price-fraction/Seed7/price-fraction-1.seed7 new file mode 100644 index 0000000000..b72e87681d --- /dev/null +++ b/Task/Price-fraction/Seed7/price-fraction-1.seed7 @@ -0,0 +1,28 @@ +$ include "seed7_05.s7i"; + include "float.s7i"; + +const func float: computePrice (in float: x) is func + result + var float: price is 0.0; + begin + if x >= 0.0 and x < 0.06 then + price := 0.10; + elsif x < 0.11 then + price := 0.18; + elsif x < 0.36 then + price := flt(((trunc(x * 100.0) - 11) div 5) * 6 + 26) / 100.0; + elsif x < 0.96 then + price := flt(((trunc(x * 100.0) - 31) div 5) * 4 + 50) / 100.0; + else + price := 1.0; + end if; + end func; + +const proc: main is func + local + var integer: i is 0; + begin + for i range 0 to 100 do + writeln(flt(i) / 100.0 digits 2 <& " " <& computePrice(flt(i) / 100.0) digits 2); + end for; + end func; diff --git a/Task/Price-fraction/Seed7/price-fraction-2.seed7 b/Task/Price-fraction/Seed7/price-fraction-2.seed7 new file mode 100644 index 0000000000..7e46639188 --- /dev/null +++ b/Task/Price-fraction/Seed7/price-fraction-2.seed7 @@ -0,0 +1,21 @@ +const array array float: table is [] ( + [] (0.06, 0.10), [] (0.11, 0.18), [] (0.16, 0.26), [] (0.21, 0.32), [] (0.26, 0.38), + [] (0.31, 0.44), [] (0.36, 0.50), [] (0.41, 0.54), [] (0.46, 0.58), [] (0.51, 0.62), + [] (0.56, 0.66), [] (0.61, 0.70), [] (0.66, 0.74), [] (0.71, 0.78), [] (0.76, 0.82), + [] (0.81, 0.86), [] (0.86, 0.90), [] (0.91, 0.94), [] (0.96, 0.98), [] (1.01, 1.00)); + +const func float: computePrice (in float: x) is func + result + var float: price is 0.0; + local + var integer: index is 1; + begin + if x >= 0.0 then + while x >= table[index][1] do + incr(index); + end while; + price := table[index][2]; + else + raise RANGE_ERROR; + end if; + end func; diff --git a/Task/Price-fraction/Smalltalk/price-fraction.st b/Task/Price-fraction/Smalltalk/price-fraction.st new file mode 100644 index 0000000000..30a3e7abfb --- /dev/null +++ b/Task/Price-fraction/Smalltalk/price-fraction.st @@ -0,0 +1,49 @@ +"Table driven rescale" +Object subclass: PriceRescale [ + |table| + PriceRescale class >> new: theTable [ + ^ self basicNew initialize: theTable + ] + initialize: theTable [ + table := theTable asOrderedCollection. + ^self + ] + rescale: aPrice [ |v1 v2| + 1 to: (table size - 1) do: [:i| + v1 := table at: i. + v2 := table at: (i+1). + ((aPrice >= (v1 x)) & (aPrice < (v2 x))) + ifTrue: [ ^ v1 y ] + ]. + (aPrice < ((v1:=(table first)) x)) ifTrue: [ ^ v1 y ]. + (aPrice >= ((v1:=(table last)) x)) ifTrue: [ ^ v1 y ] + ] +]. + +|pr| +pr := PriceRescale + new: { 0.00@0.10 . + 0.06@0.18 . + 0.11@0.26 . + 0.16@0.32 . + 0.21@0.38 . + 0.26@0.44 . + 0.31@0.50 . + 0.36@0.54 . + 0.41@0.58 . + 0.46@0.62 . + 0.51@0.66 . + 0.56@0.70 . + 0.61@0.74 . + 0.66@0.78 . + 0.71@0.82 . + 0.76@0.86 . + 0.81@0.90 . + 0.86@0.94 . + 0.91@0.98 . + 0.96@1.00 . + 1.01@1.00 + }. + +"get a price" +(pr rescale: ( (Random between: 0 and: 100)/100 )) displayNl. diff --git a/Task/Price-fraction/Tcl/price-fraction-1.tcl b/Task/Price-fraction/Tcl/price-fraction-1.tcl new file mode 100644 index 0000000000..047ceaf188 --- /dev/null +++ b/Task/Price-fraction/Tcl/price-fraction-1.tcl @@ -0,0 +1,23 @@ +# Used once to turn the table into a "nice" form +proc parseTable table { + set map {} + set LINE_RE {^ *>= *([0-9.]+) *< *([0-9.]+) *:= *([0-9.]+) *$} + foreach line [split $table \n] { + if {[string trim $line] eq ""} continue + if {[regexp $LINE_RE $line -> min max target]} { + lappend map $min $max $target + } else { + error "invalid table format: $line" + } + } + return $map +} + +# How to apply the "nice" table to a particular value +proc priceFraction {map value} { + foreach {minimum maximum target} $map { + if {$value >= $minimum && $value < $maximum} {return $target} + } + # Failed to map; return the input + return $value +} diff --git a/Task/Price-fraction/Tcl/price-fraction-2.tcl b/Task/Price-fraction/Tcl/price-fraction-2.tcl new file mode 100644 index 0000000000..1bc025a92b --- /dev/null +++ b/Task/Price-fraction/Tcl/price-fraction-2.tcl @@ -0,0 +1,29 @@ +# Make the mapping +set inputTable { + >= 0.00 < 0.06 := 0.10 + >= 0.06 < 0.11 := 0.18 + >= 0.11 < 0.16 := 0.26 + >= 0.16 < 0.21 := 0.32 + >= 0.21 < 0.26 := 0.38 + >= 0.26 < 0.31 := 0.44 + >= 0.31 < 0.36 := 0.50 + >= 0.36 < 0.41 := 0.54 + >= 0.41 < 0.46 := 0.58 + >= 0.46 < 0.51 := 0.62 + >= 0.51 < 0.56 := 0.66 + >= 0.56 < 0.61 := 0.70 + >= 0.61 < 0.66 := 0.74 + >= 0.66 < 0.71 := 0.78 + >= 0.71 < 0.76 := 0.82 + >= 0.76 < 0.81 := 0.86 + >= 0.81 < 0.86 := 0.90 + >= 0.86 < 0.91 := 0.94 + >= 0.91 < 0.96 := 0.98 + >= 0.96 < 1.01 := 1.00 +} +set map [parseTable $inputTable] + +# Apply the mapping to some inputs (from the Oz example) +foreach example {.7388727 .8593103 .826687 .3444635 .0491907} { + puts "$example -> [priceFraction $map $example]" +} diff --git a/Task/Price-fraction/Ursala/price-fraction-1.ursala b/Task/Price-fraction/Ursala/price-fraction-1.ursala new file mode 100644 index 0000000000..b64370f16c --- /dev/null +++ b/Task/Price-fraction/Ursala/price-fraction-1.ursala @@ -0,0 +1,6 @@ +#import flo + +le = <0.06,.11,.16,.21,.26,.31,.36,.41,.46,.51,.56,.61,.66,.71,.76,.81,.86,.91,.96,1.01> +out = <0.10,.18,.26,.32,.38,.44,.50,.54,.58,.62,.66,.70,.74,.78,.82,.86,.90,.94,.98,1.> + +price_fraction = fleq@rlPlX*|rhr\~&p(le,out) diff --git a/Task/Price-fraction/Ursala/price-fraction-2.ursala b/Task/Price-fraction/Ursala/price-fraction-2.ursala new file mode 100644 index 0000000000..a3c0385592 --- /dev/null +++ b/Task/Price-fraction/Ursala/price-fraction-2.ursala @@ -0,0 +1,3 @@ +#cast %eL + +test = price_fraction* <0.34,0.070145,0.06,0.05,0.50214,0.56,1.,0.99,0.> diff --git a/Task/Price-fraction/XPL0/price-fraction.xpl0 b/Task/Price-fraction/XPL0/price-fraction.xpl0 new file mode 100644 index 0000000000..f81df92db0 --- /dev/null +++ b/Task/Price-fraction/XPL0/price-fraction.xpl0 @@ -0,0 +1,33 @@ +include c:\cxpl\codes; \intrinsic 'code' declarations + +func real Price(V); \Convert to standard value +real V; +[V:= V + 0.001; \avoids possible rounding error i.e. 0.059999999 +case of + V < 0.06: ret 0.10; + V < 0.11: ret 0.18; + V < 0.16: ret 0.26; + V < 0.21: ret 0.32; + V < 0.26: ret 0.38; + V < 0.31: ret 0.44; + V < 0.36: ret 0.50; + V < 0.41: ret 0.54; + V < 0.46: ret 0.58; + V < 0.51: ret 0.62; + V < 0.56: ret 0.66; + V < 0.61: ret 0.70; + V < 0.66: ret 0.74; + V < 0.71: ret 0.78; + V < 0.76: ret 0.82; + V < 0.81: ret 0.86; + V < 0.86: ret 0.90; + V < 0.91: ret 0.94; + V < 0.96: ret 0.98 +other ret 1.00; +]; + +[Format(1,2); +RlOut(0, Price(0.0599)); CrLf(0); +RlOut(0, Price(0.10)); CrLf(0); +RlOut(0, Price(1.0)); CrLf(0); +] diff --git a/Task/Primality-by-trial-division/0DESCRIPTION b/Task/Primality-by-trial-division/0DESCRIPTION new file mode 100644 index 0000000000..ff4dfbdaf7 --- /dev/null +++ b/Task/Primality-by-trial-division/0DESCRIPTION @@ -0,0 +1,5 @@ +Write a boolean function that tells whether a given integer is prime. Remember that 1 and all non-positive numbers are not prime. + +Use trial division. Even numbers over two may be eliminated right away. A loop from 3 to √n will suffice, but other loops are allowed. + +* Related task: [[Sieve of Eratosthenes]], [[Prime decomposition]]. diff --git a/Task/Primality-by-trial-division/1META.yaml b/Task/Primality-by-trial-division/1META.yaml new file mode 100644 index 0000000000..06b4f1f0c9 --- /dev/null +++ b/Task/Primality-by-trial-division/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Prime Numbers diff --git a/Task/Primality-by-trial-division/ACL2/primality-by-trial-division.acl2 b/Task/Primality-by-trial-division/ACL2/primality-by-trial-division.acl2 new file mode 100644 index 0000000000..ef10ea4f95 --- /dev/null +++ b/Task/Primality-by-trial-division/ACL2/primality-by-trial-division.acl2 @@ -0,0 +1,10 @@ +(defun is-prime-r (x i) + (declare (xargs :measure (nfix (- x i)))) + (if (zp (- (- x i) 1)) + t + (and (/= (mod x i) 0) + (is-prime-r x (1+ i))))) + +(defun is-prime (x) + (or (= x 2) + (is-prime-r x 2))) diff --git a/Task/Primality-by-trial-division/ALGOL-68/primality-by-trial-division.alg b/Task/Primality-by-trial-division/ALGOL-68/primality-by-trial-division.alg new file mode 100644 index 0000000000..c1d43c9374 --- /dev/null +++ b/Task/Primality-by-trial-division/ALGOL-68/primality-by-trial-division.alg @@ -0,0 +1,10 @@ +main:( + INT upb=100; + printf(($" The primes up to "g(-3)" are:"l$,upb)); + FOR i TO upb DO + IF is prime(i) THEN + printf(($g(-4)$,i)) + FI + OD; + printf($l$) +) diff --git a/Task/Primality-by-trial-division/AWK/primality-by-trial-division.awk b/Task/Primality-by-trial-division/AWK/primality-by-trial-division.awk new file mode 100644 index 0000000000..b496e443a0 --- /dev/null +++ b/Task/Primality-by-trial-division/AWK/primality-by-trial-division.awk @@ -0,0 +1,8 @@ +function prime(n) { + if (n <= 1) return 0 + for (d = 2; d <= sqrt(n); d++) + if (!(n % d)) return 0 + return 1 +} + +{print prime($1)} diff --git a/Task/Primality-by-trial-division/ActionScript/primality-by-trial-division.as b/Task/Primality-by-trial-division/ActionScript/primality-by-trial-division.as new file mode 100644 index 0000000000..4d7428eaee --- /dev/null +++ b/Task/Primality-by-trial-division/ActionScript/primality-by-trial-division.as @@ -0,0 +1,9 @@ +function isPrime(n:int):Boolean +{ + if(n < 2) return false; + if(n == 2) return true; + if((n & 1) == 0) return false; + for(var i:int = 3; i <= Math.sqrt(n); i+= 2) + if(n % i == 0) return false; + return true; +} diff --git a/Task/Primality-by-trial-division/Ada/primality-by-trial-division.ada b/Task/Primality-by-trial-division/Ada/primality-by-trial-division.ada new file mode 100644 index 0000000000..e60e666bd9 --- /dev/null +++ b/Task/Primality-by-trial-division/Ada/primality-by-trial-division.ada @@ -0,0 +1,18 @@ +function Is_Prime(Item : Positive) return Boolean is + Result : Boolean := True; + Test : Natural; +begin + if Item /= 2 and Item mod 2 = 0 then + Result := False; + else + Test := 3; + while Test < Integer(Sqrt(Float(Item))) loop + if Item mod Test = 0 then + Result := False; + exit; + end if; + Test := Test + 2; + end loop; + end if; + return Result; +end Is_Prime; diff --git a/Task/Primality-by-trial-division/AutoHotkey/primality-by-trial-division.ahk b/Task/Primality-by-trial-division/AutoHotkey/primality-by-trial-division.ahk new file mode 100644 index 0000000000..33b76b6a24 --- /dev/null +++ b/Task/Primality-by-trial-division/AutoHotkey/primality-by-trial-division.ahk @@ -0,0 +1,8 @@ +MsgBox % IsPrime(1995937) +Loop + MsgBox % A_Index-3 . " is " . (IsPrime(A_Index-3) ? "" : "not ") . "prime." + +IsPrime(n,k=2) { ; testing primality with trial divisors not multiple of 2,3,5, up to sqrt(n) + d := k+(k<7 ? 1+(k>2) : SubStr("6-----4---2-4---2-4---6-----2",Mod(k,30),1)) + Return n < 3 ? n>1 : Mod(n,k) ? (d*d <= n ? IsPrime(n,d) : 1) : 0 +} diff --git a/Task/Primality-by-trial-division/BASIC/primality-by-trial-division-1.basic b/Task/Primality-by-trial-division/BASIC/primality-by-trial-division-1.basic new file mode 100644 index 0000000000..34e4b476eb --- /dev/null +++ b/Task/Primality-by-trial-division/BASIC/primality-by-trial-division-1.basic @@ -0,0 +1,22 @@ +FUNCTION prime% (n!) + STATIC i AS INTEGER + IF n = 2 THEN + prime = 1 + ELSEIF n <= 1 OR n MOD 2 = 0 THEN + prime = 0 + ELSE + prime = 1 + FOR i = 3 TO INT(SQR(n)) STEP 2 + IF n MOD i = 0 THEN + prime = 0 + EXIT FUNCTION + END IF + NEXT i + END IF +END FUNCTION + +' Test and display primes 1 .. 50 +DECLARE FUNCTION prime% (n!) +FOR n = 1 TO 50 + IF prime(n) = 1 THEN PRINT n; +NEXT n diff --git a/Task/Primality-by-trial-division/BASIC/primality-by-trial-division-2.basic b/Task/Primality-by-trial-division/BASIC/primality-by-trial-division-2.basic new file mode 100644 index 0000000000..3726e7cc2e --- /dev/null +++ b/Task/Primality-by-trial-division/BASIC/primality-by-trial-division-2.basic @@ -0,0 +1,16 @@ +10 LET n=0: LET p=0 +20 INPUT "Enter number: ";n +30 GO SUB 1000 +40 IF p=0 THEN PRINT n;" is not prime!" +50 IF p<>0 THEN PRINT n;" is prime!" +60 GO TO 10 +1000 REM *************** +1001 REM * PRIME CHECK * +1002 REM *************** +1010 LET p=0 +1020 IF n/2=INT (n/2) THEN RETURN +1030 LET p=1 +1040 FOR i=3 TO SQR (n) STEP 2 +1050 IF n/i=INT (n/i) THEN LET p=0: LET i= SQR (n) +1060 NEXT i +1070 RETURN diff --git a/Task/Primality-by-trial-division/BBC-BASIC/primality-by-trial-division.bbc b/Task/Primality-by-trial-division/BBC-BASIC/primality-by-trial-division.bbc new file mode 100644 index 0000000000..182846cb81 --- /dev/null +++ b/Task/Primality-by-trial-division/BBC-BASIC/primality-by-trial-division.bbc @@ -0,0 +1,14 @@ + FOR i% = -1 TO 100 + IF FNisprime(i%) PRINT ; i% " is prime" + NEXT + END + + DEF FNisprime(n%) + IF n% <= 1 THEN = FALSE + IF n% <= 3 THEN = TRUE + IF (n% AND 1) = 0 THEN = FALSE + LOCAL t% + FOR t% = 3 TO SQR(n%) STEP 2 + IF n% MOD t% = 0 THEN = FALSE + NEXT + = TRUE diff --git a/Task/Primality-by-trial-division/Bracmat/primality-by-trial-division.bracmat b/Task/Primality-by-trial-division/Bracmat/primality-by-trial-division.bracmat new file mode 100644 index 0000000000..7e7e7eb6b2 --- /dev/null +++ b/Task/Primality-by-trial-division/Bracmat/primality-by-trial-division.bracmat @@ -0,0 +1,22 @@ + ( prime + = incs n I inc + . 4 2 4 2 4 6 2 6:?incs + & 2:?n + & 1 2 2 !incs:?I + & whl + ' ( !n*!n:~>!arg + & div$(!arg.!n)*!n:~!arg + & (!I:%?inc ?I|!incs:%?inc ?I) + & !n+!inc:?n + ) + & !n*!n:>!arg + ) +& 100000000000:?p +& whl + ' ( !p+1:<100000000100:?p + & ( prime$!p + & out$!p + | + ) + ) +& ; diff --git a/Task/Primality-by-trial-division/Burlesque/primality-by-trial-division-1.blq b/Task/Primality-by-trial-division/Burlesque/primality-by-trial-division-1.blq new file mode 100644 index 0000000000..1255ed131a --- /dev/null +++ b/Task/Primality-by-trial-division/Burlesque/primality-by-trial-division-1.blq @@ -0,0 +1 @@ +fcL[2== diff --git a/Task/Primality-by-trial-division/Burlesque/primality-by-trial-division-2.blq b/Task/Primality-by-trial-division/Burlesque/primality-by-trial-division-2.blq new file mode 100644 index 0000000000..0dd7cced68 --- /dev/null +++ b/Task/Primality-by-trial-division/Burlesque/primality-by-trial-division-2.blq @@ -0,0 +1,6 @@ +blsq ) 11^^2\/?dr@.%{0==}ayn! +1 +blsq ) 12^^2\/?dr@.%{0==}ayn! +0 +blsq ) 13^^2\/?dr@.%{0==}ayn! +1 diff --git a/Task/Primality-by-trial-division/C++/primality-by-trial-division.cpp b/Task/Primality-by-trial-division/C++/primality-by-trial-division.cpp new file mode 100644 index 0000000000..d4c75016c6 --- /dev/null +++ b/Task/Primality-by-trial-division/C++/primality-by-trial-division.cpp @@ -0,0 +1,13 @@ +#include + +bool is_prime(unsigned int n) +{ + if (n <= 1) + return false; + if (n == 2) + return true; + for (unsigned int i = 2; i <= sqrt(n); ++i) + if (n % i == 0) + return false; + return true; +} diff --git a/Task/Primality-by-trial-division/C/primality-by-trial-division.c b/Task/Primality-by-trial-division/C/primality-by-trial-division.c new file mode 100644 index 0000000000..d7a85060a0 --- /dev/null +++ b/Task/Primality-by-trial-division/C/primality-by-trial-division.c @@ -0,0 +1,10 @@ +int is_prime(unsigned int n) +{ + unsigned int p; + if (!(n & 1) || n < 2 ) return n == 2; + + /* comparing p*p <= n can overflow */ + for (p = 3; p <= n/p; p += 2) + if (!(n % p)) return 0; + return 1; +} diff --git a/Task/Primality-by-trial-division/CMake/primality-by-trial-division-1.cmake b/Task/Primality-by-trial-division/CMake/primality-by-trial-division-1.cmake new file mode 100644 index 0000000000..17babc1bdc --- /dev/null +++ b/Task/Primality-by-trial-division/CMake/primality-by-trial-division-1.cmake @@ -0,0 +1,31 @@ +# Prime predicate: does n be a prime number? Sets var to true or false. +function(primep var n) + if(n GREATER 2) + math(EXPR odd "${n} % 2") + if(odd) + # n > 2 and n is odd. + set(factor 3) + # Loop for odd factors from 3, while factor <= n / factor. + math(EXPR quot "${n} / ${factor}") + while(NOT factor GREATER quot) + math(EXPR rp "${n} % ${factor}") # Trial division + if(NOT rp) + # factor divides n, so n is not prime. + set(${var} false PARENT_SCOPE) + return() + endif() + math(EXPR factor "${factor} + 2") # Next odd factor + math(EXPR quot "${n} / ${factor}") + endwhile(NOT factor GREATER quot) + # Loop found no factor, so n is prime. + set(${var} true PARENT_SCOPE) + else() + # n > 2 and n is even, so n is not prime. + set(${var} false PARENT_SCOPE) + endif(odd) + elseif(n EQUAL 2) + set(${var} true PARENT_SCOPE) # 2 is prime. + else() + set(${var} false PARENT_SCOPE) # n < 2 is not prime. + endif() +endfunction(primep) diff --git a/Task/Primality-by-trial-division/CMake/primality-by-trial-division-2.cmake b/Task/Primality-by-trial-division/CMake/primality-by-trial-division-2.cmake new file mode 100644 index 0000000000..4190e4cadb --- /dev/null +++ b/Task/Primality-by-trial-division/CMake/primality-by-trial-division-2.cmake @@ -0,0 +1,9 @@ +# Quick example. +foreach(i -5 1 2 3 37 39) + primep(b ${i}) + if(b) + message(STATUS "${i} is prime.") + else() + message(STATUS "${i} is _not_ prime.") + endif(b) +endforeach(i) diff --git a/Task/Primality-by-trial-division/COBOL/primality-by-trial-division-1.cobol b/Task/Primality-by-trial-division/COBOL/primality-by-trial-division-1.cobol new file mode 100644 index 0000000000..eb7e15bd54 --- /dev/null +++ b/Task/Primality-by-trial-division/COBOL/primality-by-trial-division-1.cobol @@ -0,0 +1,44 @@ +Identification division. +Program-id. prime-div. + +Data division. +Working-storage section. + +* The number for which we are testing primality. +01 num pic 9(6) value 1. +01 out-num pic z(6). + +* Division-related stuff. +01 div pic 9(6). +01 div-lim pic 9(6). +01 rem pic 9(6). + 88 not-prime value 0. + +Procedure division. +Main. + Perform until num = 0 + perform get-a-num + perform is-prime + move num to out-num + if not-prime display out-num " is not prime." + else display out-num " is prime." + end-perform. + Stop run. + +Is-prime. + if num < 4 + move 1 to rem + else + compute div-lim = function sqrt(num) + 1 + perform + with test after + varying div from 2 by 1 + until div = div-lim or not-prime + compute rem = function mod(num, div) + end-perform + end-if. + +Get-a-num. + Display "Enter a possible prime number (0 to stop): " with no advancing. + Accept num. + If num = 0 stop run. diff --git a/Task/Primality-by-trial-division/COBOL/primality-by-trial-division-2.cobol b/Task/Primality-by-trial-division/COBOL/primality-by-trial-division-2.cobol new file mode 100644 index 0000000000..b4b0d6d163 --- /dev/null +++ b/Task/Primality-by-trial-division/COBOL/primality-by-trial-division-2.cobol @@ -0,0 +1,22 @@ +Identification division. +Program-id. prime-by-div-main. + +Data division. +Working-storage section. +01 num-out pic z(10). +01 num pic 9(10). +01 ans pic x. + 88 is-prime value "y". + +Procedure division. +Main. +Perform until 1 = 2 + display "Number: " with no advancing + accept num + move num to num-out + if num = 0 stop run end-if + call "prime-by-div-subr" using num by reference ans + if ans = "Y" display num-out " is prime." + else display num-out " is not prime." +end-perform. +Stop run. diff --git a/Task/Primality-by-trial-division/COBOL/primality-by-trial-division-3.cobol b/Task/Primality-by-trial-division/COBOL/primality-by-trial-division-3.cobol new file mode 100644 index 0000000000..f2ba131963 --- /dev/null +++ b/Task/Primality-by-trial-division/COBOL/primality-by-trial-division-3.cobol @@ -0,0 +1,27 @@ +Identification division. +Program-id. prime-by-div-subr. + +Data division. +Working-storage section. +01 div pic 9(10). +01 lim pic 9(10). +01 rem pic 9(10). + 88 is-not-prime value 0. + +Linkage section. +01 the-num pic 9(10). +01 the-ans pic x. + +Procedure division using the-num, the-ans. +Main. +Move "Y" to the-ans. +If the-num < 4 exit program. +Compute lim = Function sqrt(the-num) + 1. +Perform + with test after + varying div from 2 by 1 + until div > lim or is-not-prime + compute rem = function mod(the-num, div) +end-perform. +If is-not-prime move "N" to the-ans. +Exit program. diff --git a/Task/Primality-by-trial-division/Clojure/primality-by-trial-division.clj b/Task/Primality-by-trial-division/Clojure/primality-by-trial-division.clj new file mode 100644 index 0000000000..6547389e2f --- /dev/null +++ b/Task/Primality-by-trial-division/Clojure/primality-by-trial-division.clj @@ -0,0 +1,6 @@ +(defn divides? [k n] (= (rem n k) 0)) + +(defn prime? [n] + (if (< n 2) + false + (empty? (filter #(divides? % n) (take-while #(<= (* % %) n) (range 2 n)))))) diff --git a/Task/Primality-by-trial-division/CoffeeScript/primality-by-trial-division.coffeescript b/Task/Primality-by-trial-division/CoffeeScript/primality-by-trial-division.coffeescript new file mode 100644 index 0000000000..23b68cebaf --- /dev/null +++ b/Task/Primality-by-trial-division/CoffeeScript/primality-by-trial-division.coffeescript @@ -0,0 +1,12 @@ +is_prime = (n) -> + # simple prime detection using trial division, works + # for all integers + return false if n <= 1 # by definition + p = 2 + while p * p <= n + return false if n % p == 0 + p += 1 + true + +for i in [-1..100] + console.log i if is_prime i diff --git a/Task/Primality-by-trial-division/Common-Lisp/primality-by-trial-division-1.lisp b/Task/Primality-by-trial-division/Common-Lisp/primality-by-trial-division-1.lisp new file mode 100644 index 0000000000..54e14f34d9 --- /dev/null +++ b/Task/Primality-by-trial-division/Common-Lisp/primality-by-trial-division-1.lisp @@ -0,0 +1,7 @@ + (defun primep (a) + (cond ((= a 2) T) + ((or (<= a 1) (= (mod a 2) 0)) nil) + ((loop for i from 3 to (sqrt a) by 2 do + (if (= (mod a i) 0) + (return nil))) nil) + (T T))) diff --git a/Task/Primality-by-trial-division/Common-Lisp/primality-by-trial-division-2.lisp b/Task/Primality-by-trial-division/Common-Lisp/primality-by-trial-division-2.lisp new file mode 100644 index 0000000000..55b2ea2dcc --- /dev/null +++ b/Task/Primality-by-trial-division/Common-Lisp/primality-by-trial-division-2.lisp @@ -0,0 +1,6 @@ +(defun primep (n) + "Is N prime?" + (and (> n 1) + (or (= n 2) (oddp n)) + (loop for i from 3 to (isqrt n) by 2 + never (zerop (rem n i))))) diff --git a/Task/Primality-by-trial-division/D/primality-by-trial-division-1.d b/Task/Primality-by-trial-division/D/primality-by-trial-division-1.d new file mode 100644 index 0000000000..6f47335552 --- /dev/null +++ b/Task/Primality-by-trial-division/D/primality-by-trial-division-1.d @@ -0,0 +1,15 @@ +import std.stdio, std.algorithm, std.range, std.math; + +bool isPrime(in int n) pure nothrow { + if ((n & 1) == 0 || n <= 1) + return n == 2; + + for(int i = 3; i <= sqrt(cast(real)n); i += 2) + if (n % i == 0) + return false; + return true; +} + +void main() { // demo code + iota(2, 40).filter!isPrime().writeln(); +} diff --git a/Task/Primality-by-trial-division/D/primality-by-trial-division-2.d b/Task/Primality-by-trial-division/D/primality-by-trial-division-2.d new file mode 100644 index 0000000000..d1ba6bc25d --- /dev/null +++ b/Task/Primality-by-trial-division/D/primality-by-trial-division-2.d @@ -0,0 +1,27 @@ +import std.stdio, std.algorithm, std.range; + +bool isPrime2(Integer)(in Integer number) pure nothrow { + // Adapted from: http://www.devx.com/vb2themax/Tip/19051 + // manually test 1, 2, 3 and multiples of 2 and 3 + if (number == 2 || number == 3) + return true; + else if (number < 2 || number % 2 == 0 || number % 3 == 0) + return false; + + /* we can now avoid to consider multiples + * of 2 and 3. This can be done really simply + * by starting at 5 and incrementing by 2 and 4 + * alternatively, that is: + * 5, 7, 11, 13, 17, 19, 23, 25, 29, 31, 35, 37, ... + * we don't need to go higher than the square root of the number */ + for (Integer divisor = 5, increment = 2; divisor*divisor <= number; + divisor += increment, increment = 6 - increment) + if (number % divisor == 0) + return false; + + return true; // if we get here, the number is prime +} + +void main() { // demo code + iota(2, 40).filter!isPrime2().writeln(); +} diff --git a/Task/Primality-by-trial-division/D/primality-by-trial-division-3.d b/Task/Primality-by-trial-division/D/primality-by-trial-division-3.d new file mode 100644 index 0000000000..48bca92b85 --- /dev/null +++ b/Task/Primality-by-trial-division/D/primality-by-trial-division-3.d @@ -0,0 +1,15 @@ +import std.stdio, std.algorithm, std.range, std.math; + +bool isPrime3(T)(in T n) pure nothrow { + if (n % 2 == 0 || n <= 1) + return n == 2; + T head = 3, tail = (cast(T)sqrt(cast(real)n) / 2) * 2 + 1; + for ( ; head <= tail ; head +=2, tail -= 2) + if ((n % head) == 0 || (n % tail) == 0) + return false; + return true; +} + +void main() { // demo code + iota(2, 40).filter!isPrime3().writeln(); +} diff --git a/Task/Primality-by-trial-division/Delphi/primality-by-trial-division-1.delphi b/Task/Primality-by-trial-division/Delphi/primality-by-trial-division-1.delphi new file mode 100644 index 0000000000..56a2befd7a --- /dev/null +++ b/Task/Primality-by-trial-division/Delphi/primality-by-trial-division-1.delphi @@ -0,0 +1,18 @@ +function IsPrime(aNumber: Integer): Boolean; +var + I: Integer; +begin + Result:= True; + if(aNumber = 2) then Exit; + + Result:= not ((aNumber mod 2 = 0) or + (aNumber <= 1)); + if not Result then Exit; + + for I:=3 to Trunc(Sqrt(aNumber)) do + if(aNumber mod I = 0) then + begin + Result:= False; + Break; + end; +end; diff --git a/Task/Primality-by-trial-division/Delphi/primality-by-trial-division-2.delphi b/Task/Primality-by-trial-division/Delphi/primality-by-trial-division-2.delphi new file mode 100644 index 0000000000..85779c1f09 --- /dev/null +++ b/Task/Primality-by-trial-division/Delphi/primality-by-trial-division-2.delphi @@ -0,0 +1,15 @@ +function IsPrime(const x: integer): Boolean; +var + i: integer; +begin + i := 2; + repeat + if X mod i = 0 then + begin + Result := False; + Exit; + end; + Inc(i); + until i > Sqrt(x); + Result := True; +end; diff --git a/Task/Primality-by-trial-division/E/primality-by-trial-division.e b/Task/Primality-by-trial-division/E/primality-by-trial-division.e new file mode 100644 index 0000000000..528e304124 --- /dev/null +++ b/Task/Primality-by-trial-division/E/primality-by-trial-division.e @@ -0,0 +1,16 @@ +def isPrime(n :int) { + if (n == 2) { + return true + } else if (n <= 1 || n %% 2 == 0) { + return false + } else { + def limit := (n :float64).sqrt().ceil() + var divisor := 1 + while ((divisor += 2) <= limit) { + if (n %% divisor == 0) { + return false + } + } + return true + } +} diff --git a/Task/Primality-by-trial-division/Erlang/primality-by-trial-division.erl b/Task/Primality-by-trial-division/Erlang/primality-by-trial-division.erl new file mode 100644 index 0000000000..d87b6547dd --- /dev/null +++ b/Task/Primality-by-trial-division/Erlang/primality-by-trial-division.erl @@ -0,0 +1,7 @@ +is_prime(N) when N == 2 -> true; +is_prime(N) when N < 2 orelse N rem 2 == 0 -> false; +is_prime(N) -> is_prime(N,3). + +is_prime(N,K) when K*K > N -> true; +is_prime(N,K) when N rem K == 0 -> false; +is_prime(N,K) -> is_prime(N,K+2). diff --git a/Task/Primality-by-trial-division/Euphoria/primality-by-trial-division.euphoria b/Task/Primality-by-trial-division/Euphoria/primality-by-trial-division.euphoria new file mode 100644 index 0000000000..3e24c0e19a --- /dev/null +++ b/Task/Primality-by-trial-division/Euphoria/primality-by-trial-division.euphoria @@ -0,0 +1,12 @@ +function is_prime(integer n) + if n<=2 or remainder(n,2)=0 then + return 0 + else + for i=3 to sqrt(n) by 2 do + if remainder(n,i)=0 then + return 0 + end if + end for + return 1 + end if +end function diff --git a/Task/Primality-by-trial-division/FALSE/primality-by-trial-division.false b/Task/Primality-by-trial-division/FALSE/primality-by-trial-division.false new file mode 100644 index 0000000000..3a34cd02af --- /dev/null +++ b/Task/Primality-by-trial-division/FALSE/primality-by-trial-division.false @@ -0,0 +1,3 @@ +[0\$2=$[@~@@]?~[$$2>\1&&[\~\ + 3[\$@$@1+\$*>][\$@$@$@$@\/*=[%\~\$]?2+]#% +]?]?%]p: diff --git a/Task/Primality-by-trial-division/Factor/primality-by-trial-division.factor b/Task/Primality-by-trial-division/Factor/primality-by-trial-division.factor new file mode 100644 index 0000000000..21da6f45fa --- /dev/null +++ b/Task/Primality-by-trial-division/Factor/primality-by-trial-division.factor @@ -0,0 +1,8 @@ +USING: combinators kernel math math.functions math.ranges sequences ; + +: prime? ( n -- ? ) + { + { [ dup 2 < ] [ drop f ] } + { [ dup even? ] [ 2 = ] } + [ 3 over sqrt 2 [ mod 0 > ] with all? ] + } cond ; diff --git a/Task/Primality-by-trial-division/Forth/primality-by-trial-division.fth b/Task/Primality-by-trial-division/Forth/primality-by-trial-division.fth new file mode 100644 index 0000000000..2224952fd1 --- /dev/null +++ b/Task/Primality-by-trial-division/Forth/primality-by-trial-division.fth @@ -0,0 +1,11 @@ +: prime? ( n -- ? ) + dup 2 < if drop false + else dup 2 = if drop true + else dup 1 and 0= if drop false + else 3 + begin 2dup dup * >= + while 2dup mod 0= + if 2drop false exit + then 2 + + repeat 2drop true + then then then ; diff --git a/Task/Primality-by-trial-division/Fortran/primality-by-trial-division.f b/Task/Primality-by-trial-division/Fortran/primality-by-trial-division.f new file mode 100644 index 0000000000..06a2d5fc53 --- /dev/null +++ b/Task/Primality-by-trial-division/Fortran/primality-by-trial-division.f @@ -0,0 +1,19 @@ + FUNCTION isPrime(number) + LOGICAL :: isPrime + INTEGER, INTENT(IN) :: number + INTEGER :: i + + IF(number==2) THEN + isPrime = .TRUE. + ELSE IF(number < 2 .OR. MOD(number,2) == 0) THEN + isPRIME = .FALSE. + ELSE + isPrime = .TRUE. + DO i = 3, INT(SQRT(REAL(number))), 2 + IF(MOD(number,i) == 0) THEN + isPrime = .FALSE. + EXIT + END IF + END DO + END IF + END FUNCTION diff --git a/Task/Primality-by-trial-division/GAP/primality-by-trial-division.gap b/Task/Primality-by-trial-division/GAP/primality-by-trial-division.gap new file mode 100644 index 0000000000..947680283c --- /dev/null +++ b/Task/Primality-by-trial-division/GAP/primality-by-trial-division.gap @@ -0,0 +1,21 @@ +IsPrimeTrial := function(n) + local k, m; + if n < 5 then + return (n = 2) or (n = 3); + fi; + if RemInt(n, 2) = 0 then + return false; + fi; + m := RootInt(n); + k := 3; + while k <= m do + if RemInt(n, k) = 0 then + return false; + fi; + k := k + 2; + od; + return true; +end; + +Filtered([1 .. 100], IsPrimeTrial); +# [ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 ] diff --git a/Task/Primality-by-trial-division/Go/primality-by-trial-division.go b/Task/Primality-by-trial-division/Go/primality-by-trial-division.go new file mode 100644 index 0000000000..8a34cecc7d --- /dev/null +++ b/Task/Primality-by-trial-division/Go/primality-by-trial-division.go @@ -0,0 +1,9 @@ +func isPrime(p int) bool { + if p < 2 {return false} + if p % 2 == 0 { return false } + + for i := 3; i*i < p; i += 2 { + if p % i == 0 { return false } + } + return true +} diff --git a/Task/Primality-by-trial-division/Groovy/primality-by-trial-division.groovy b/Task/Primality-by-trial-division/Groovy/primality-by-trial-division.groovy new file mode 100644 index 0000000000..ebb04a0110 --- /dev/null +++ b/Task/Primality-by-trial-division/Groovy/primality-by-trial-division.groovy @@ -0,0 +1,7 @@ +def isPrime = { + it == 2 || + it > 1 && + (2..Math.max(2, (int) Math.sqrt(it))).every{ k -> it % k != 0 } +} + +(0..20).grep(isPrime) diff --git a/Task/Primality-by-trial-division/Haskell/primality-by-trial-division-1.hs b/Task/Primality-by-trial-division/Haskell/primality-by-trial-division-1.hs new file mode 100644 index 0000000000..f8507c2768 --- /dev/null +++ b/Task/Primality-by-trial-division/Haskell/primality-by-trial-division-1.hs @@ -0,0 +1 @@ +isPrime n = n==2 || n>2 && all ((> 0).rem n) (2:[3,5..floor.sqrt(fromIntegral n+1)]) diff --git a/Task/Primality-by-trial-division/Haskell/primality-by-trial-division-2.hs b/Task/Primality-by-trial-division/Haskell/primality-by-trial-division-2.hs new file mode 100644 index 0000000000..f8cba13222 --- /dev/null +++ b/Task/Primality-by-trial-division/Haskell/primality-by-trial-division-2.hs @@ -0,0 +1,6 @@ +noDivsBy factors n = foldr (\f r-> f*f>n || (rem n f /= 0 && r)) True factors + +-- primeNums = filter (noDivsBy [2..]) [2..] +primeNums = 2 : 3 : filter (noDivsBy $ tail primeNums) [5,7..] + +isPrime n = n > 1 && noDivsBy primeNums n diff --git a/Task/Primality-by-trial-division/Haskell/primality-by-trial-division-3.hs b/Task/Primality-by-trial-division/Haskell/primality-by-trial-division-3.hs new file mode 100644 index 0000000000..698797d55c --- /dev/null +++ b/Task/Primality-by-trial-division/Haskell/primality-by-trial-division-3.hs @@ -0,0 +1 @@ +primesFromTo n m = filter isPrime [n..m] diff --git a/Task/Primality-by-trial-division/Haskell/primality-by-trial-division-4.hs b/Task/Primality-by-trial-division/Haskell/primality-by-trial-division-4.hs new file mode 100644 index 0000000000..6cdb912623 --- /dev/null +++ b/Task/Primality-by-trial-division/Haskell/primality-by-trial-division-4.hs @@ -0,0 +1,2 @@ +primes = sieve [2..] where + sieve (p:xs) = p : sieve [x | x <- xs, rem x p /= 0] diff --git a/Task/Primality-by-trial-division/Haskell/primality-by-trial-division-5.hs b/Task/Primality-by-trial-division/Haskell/primality-by-trial-division-5.hs new file mode 100644 index 0000000000..c95d26c6ed --- /dev/null +++ b/Task/Primality-by-trial-division/Haskell/primality-by-trial-division-5.hs @@ -0,0 +1,3 @@ +primesTo m = 2 : sieve [3,5..m] where + sieve (p:xs) | p*p > m = p : xs + | otherwise = p : sieve [x | x <- xs, rem x p /= 0] diff --git a/Task/Primality-by-trial-division/Haskell/primality-by-trial-division-6.hs b/Task/Primality-by-trial-division/Haskell/primality-by-trial-division-6.hs new file mode 100644 index 0000000000..23d6538688 --- /dev/null +++ b/Task/Primality-by-trial-division/Haskell/primality-by-trial-division-6.hs @@ -0,0 +1,3 @@ +primesT = 2 : 3 : sieve [5,7..] 9 (tail primesT) where + sieve (x:xs) q ps@(p:t) | x < q = x : sieve xs q ps + | otherwise = sieve [x | x <- xs, rem x p /= 0] (head t^2) t diff --git a/Task/Primality-by-trial-division/Haskell/primality-by-trial-division-7.hs b/Task/Primality-by-trial-division/Haskell/primality-by-trial-division-7.hs new file mode 100644 index 0000000000..79cde39f76 --- /dev/null +++ b/Task/Primality-by-trial-division/Haskell/primality-by-trial-division-7.hs @@ -0,0 +1,4 @@ +primesST = 2 : 3 : sieve 5 9 (drop 2 primesST) 0 where + sieve x q ps k = let fs = take k (tail primesST) in + filter (\x-> all ((/=0).rem x) fs) [x,x+2..q-2] + ++ sieve (q+2) (head ps^2) (tail ps) (k+1) diff --git a/Task/Primality-by-trial-division/HicEst/primality-by-trial-division.hicest b/Task/Primality-by-trial-division/HicEst/primality-by-trial-division.hicest new file mode 100644 index 0000000000..57b4804869 --- /dev/null +++ b/Task/Primality-by-trial-division/HicEst/primality-by-trial-division.hicest @@ -0,0 +1,18 @@ + DO n = 1, 1E6 + Euler = n^2 + n + 41 + IF( Prime(Euler) == 0 ) WRITE(Messagebox) Euler, ' is NOT prime for n =', n + ENDDO ! e.g. 1681 = 40^2 + 40 + 41 is NOT prime +END + +FUNCTION Prime(number) + Prime = number == 2 + IF( (number > 2) * MOD(number,2) ) THEN + DO i = 3, number^0.5, 2 + IF(MOD(number,i) == 0) THEN + Prime = 0 + RETURN + ENDIF + ENDDO + Prime = 1 + ENDIF +END diff --git a/Task/Primality-by-trial-division/Icon/primality-by-trial-division.icon b/Task/Primality-by-trial-division/Icon/primality-by-trial-division.icon new file mode 100644 index 0000000000..61bb5be206 --- /dev/null +++ b/Task/Primality-by-trial-division/Icon/primality-by-trial-division.icon @@ -0,0 +1,5 @@ +procedure isprime(n) #: return n if prime (using trial division) or fail +if not n = integer(n) | n < 2 then fail # ensure n is an integer greater than 1 +every if 0 = (n % (2 to sqrt(n))) then fail +return n +end diff --git a/Task/Primality-by-trial-division/J/primality-by-trial-division.j b/Task/Primality-by-trial-division/J/primality-by-trial-division.j new file mode 100644 index 0000000000..d6f3d8fa10 --- /dev/null +++ b/Task/Primality-by-trial-division/J/primality-by-trial-division.j @@ -0,0 +1 @@ +isprime=: 3 : 'if. 3>:y do. 1] nullary [rem 0 >] dip and ] + [ succ ] + while + dup * < . diff --git a/Task/Primality-by-trial-division/K/primality-by-trial-division.k b/Task/Primality-by-trial-division/K/primality-by-trial-division.k new file mode 100644 index 0000000000..b18887f89c --- /dev/null +++ b/Task/Primality-by-trial-division/K/primality-by-trial-division.k @@ -0,0 +1,3 @@ + isprime:{(x>1)&&/x!'2_!1+_sqrt x} + &isprime'!100 +2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 diff --git a/Task/Primality-by-trial-division/LSE64/primality-by-trial-division.lse64 b/Task/Primality-by-trial-division/LSE64/primality-by-trial-division.lse64 new file mode 100644 index 0000000000..6c2f2ac3e7 --- /dev/null +++ b/Task/Primality-by-trial-division/LSE64/primality-by-trial-division.lse64 @@ -0,0 +1,15 @@ +over : 2 pick + 2dup : over over + even? : 1 & 0 = + + # trial n d yields "n d 0/1 false" or "n d+2 true" + trial : 2 + true + trial : 2dup % 0 = then 0 false + trial : 2dup dup * < then 1 false + trial-loop : trial &repeat + + # prime? n yields flag + prime? : 3 trial-loop >flag drop drop + prime? : dup even? then drop false + prime? : dup 2 = then drop true + prime? : dup 2 < then drop false diff --git a/Task/Primality-by-trial-division/Liberty-BASIC/primality-by-trial-division.liberty b/Task/Primality-by-trial-division/Liberty-BASIC/primality-by-trial-division.liberty new file mode 100644 index 0000000000..5301d9c1cb --- /dev/null +++ b/Task/Primality-by-trial-division/Liberty-BASIC/primality-by-trial-division.liberty @@ -0,0 +1,22 @@ +for n =1 to 50 + if prime( n) = 1 then print n; " is prime." +next n + +wait + +function prime( n) + if n =2 then + prime =1 + else + if ( n <=1) or ( n mod 2 =0) then + prime =0 + else + prime =1 + for i = 3 to int( sqr( n)) step 2 + if ( n MOD i) =0 then prime = 0: exit function + next i + end if + end if +end function + +end diff --git a/Task/Primality-by-trial-division/Logo/primality-by-trial-division.logo b/Task/Primality-by-trial-division/Logo/primality-by-trial-division.logo new file mode 100644 index 0000000000..102ddd9a5c --- /dev/null +++ b/Task/Primality-by-trial-division/Logo/primality-by-trial-division.logo @@ -0,0 +1,7 @@ +to prime? :n + if :n < 2 [output "false] + if :n = 2 [output "true] + if equal? 0 modulo :n 2 [output "false] + for [i 3 [sqrt :n] 2] [if equal? 0 modulo :n :i [output "false]] + output "true +end diff --git a/Task/Primality-by-trial-division/Lua/primality-by-trial-division.lua b/Task/Primality-by-trial-division/Lua/primality-by-trial-division.lua new file mode 100644 index 0000000000..ac607288aa --- /dev/null +++ b/Task/Primality-by-trial-division/Lua/primality-by-trial-division.lua @@ -0,0 +1,13 @@ +function IsPrime( n ) + if n <= 1 or ( n ~= 2 and n % 2 == 0 ) then + return false + end + + for i = 3, math.sqrt(n), 2 do + if n % i == 0 then + return false + end + end + + return true +end diff --git a/Task/Primality-by-trial-division/M4/primality-by-trial-division.m4 b/Task/Primality-by-trial-division/M4/primality-by-trial-division.m4 new file mode 100644 index 0000000000..e9f26f56ab --- /dev/null +++ b/Task/Primality-by-trial-division/M4/primality-by-trial-division.m4 @@ -0,0 +1,15 @@ +define(`testnext', + `ifelse(eval($2*$2>$1),1, + 1, + `ifelse(eval($1%$2==0),1, + 0, + `testnext($1,eval($2+2))')')') +define(`isprime', + `ifelse($1,2, + 1, + `ifelse(eval($1<=1 || $1%2==0),1, + 0, + `testnext($1,3)')')') + +isprime(9) +isprime(11) diff --git a/Task/Primality-by-trial-division/MATLAB/primality-by-trial-division-1.m b/Task/Primality-by-trial-division/MATLAB/primality-by-trial-division-1.m new file mode 100644 index 0000000000..b24775ad33 --- /dev/null +++ b/Task/Primality-by-trial-division/MATLAB/primality-by-trial-division-1.m @@ -0,0 +1,19 @@ +function isPrime = primalityByTrialDivision(n) + + if n == 2 + isPrime = true; + return + elseif (mod(n,2) == 0) || (n <= 1) + isPrime = false; + return + end + + %First n mod (3 to sqrt(n)) is taken. This will be a vector where the + %first element is equal to n mod 3 and the last element is equal to n + %mod sqrt(n). Then the all function is applied to that vector. If all + %of the elements of this vector are non-zero (meaning n is prime) then + %all() returns true. Otherwise, n is composite, so it returns false. + %This return value is then assigned to the variable isPrime. + isPrime = all(mod(n, (3:round(sqrt(n))) )); + +end diff --git a/Task/Primality-by-trial-division/MATLAB/primality-by-trial-division-2.m b/Task/Primality-by-trial-division/MATLAB/primality-by-trial-division-2.m new file mode 100644 index 0000000000..34a018cf1d --- /dev/null +++ b/Task/Primality-by-trial-division/MATLAB/primality-by-trial-division-2.m @@ -0,0 +1,5 @@ +>> arrayfun(@primalityByTrialDivision,(1:14)) + +ans = + + 0 1 1 0 1 0 1 0 0 0 1 0 1 0 diff --git a/Task/Primality-by-trial-division/MAXScript/primality-by-trial-division.maxscript b/Task/Primality-by-trial-division/MAXScript/primality-by-trial-division.maxscript new file mode 100644 index 0000000000..60d8f13231 --- /dev/null +++ b/Task/Primality-by-trial-division/MAXScript/primality-by-trial-division.maxscript @@ -0,0 +1,17 @@ + fn isPrime n = + ( + if n == 2 then + ( + return true + ) + else if (n <= 1) OR (mod n 2 == 0) then + ( + return false + ) + + for i in 3 to (sqrt n) by 2 do + ( + if mod n i == 0 then return false + ) + true + ) diff --git a/Task/Primality-by-trial-division/MUMPS/primality-by-trial-division.mumps b/Task/Primality-by-trial-division/MUMPS/primality-by-trial-division.mumps new file mode 100644 index 0000000000..c54c400ec9 --- /dev/null +++ b/Task/Primality-by-trial-division/MUMPS/primality-by-trial-division.mumps @@ -0,0 +1,7 @@ +ISPRIME(N) + QUIT:(N=2) 1 + NEW I,TP + SET TP=+'$PIECE((N/2),".",2) + IF 'TP FOR I=3:2:(N**.5) SET TP=+'$PIECE((N/I),".",2) Q:TP + KILL I + QUIT 'TP diff --git a/Task/Primality-by-trial-division/Maple/primality-by-trial-division-1.maple b/Task/Primality-by-trial-division/Maple/primality-by-trial-division-1.maple new file mode 100644 index 0000000000..400cfccbda --- /dev/null +++ b/Task/Primality-by-trial-division/Maple/primality-by-trial-division-1.maple @@ -0,0 +1,16 @@ +TrialDivision := proc( n :: integer ) + if n <= 1 then + false + elif n = 2 then + true + elif type( n, 'even' ) then + false + else + for local i from 3 by 2 while i * i <= n do + if irem( n, i ) = 0 then + return false + end if + end do; + true + end if +end proc: diff --git a/Task/Primality-by-trial-division/Maple/primality-by-trial-division-2.maple b/Task/Primality-by-trial-division/Maple/primality-by-trial-division-2.maple new file mode 100644 index 0000000000..28272370f2 --- /dev/null +++ b/Task/Primality-by-trial-division/Maple/primality-by-trial-division-2.maple @@ -0,0 +1,2 @@ +> select( TrialDivision, [seq]( 1 .. 30 ) ); + [2, 3, 5, 7, 11, 13, 17, 19, 23, 29] diff --git a/Task/Primality-by-trial-division/Maple/primality-by-trial-division-3.maple b/Task/Primality-by-trial-division/Maple/primality-by-trial-division-3.maple new file mode 100644 index 0000000000..0d54805fda --- /dev/null +++ b/Task/Primality-by-trial-division/Maple/primality-by-trial-division-3.maple @@ -0,0 +1,2 @@ +> N := 10000: evalb( select( TrialDivision, [seq]( 1 .. N ) ) = select( isprime, [seq]( 1 .. N ) ) ); + true diff --git a/Task/Primality-by-trial-division/Mathematica/primality-by-trial-division.math b/Task/Primality-by-trial-division/Mathematica/primality-by-trial-division.math new file mode 100644 index 0000000000..2885b1cdf8 --- /dev/null +++ b/Task/Primality-by-trial-division/Mathematica/primality-by-trial-division.math @@ -0,0 +1,9 @@ +IsPrime[n_Integer] := + Module[{k = 2}, + If[n <= 1, Return False]; + If[n == 2, Return True]; + While[k <= Sqrt[n], + If[Mod[n, k] == 0, Return[False], k++] + ]; + Return[True] + ] diff --git a/Task/Primality-by-trial-division/NetRexx/primality-by-trial-division-1.netrexx b/Task/Primality-by-trial-division/NetRexx/primality-by-trial-division-1.netrexx new file mode 100644 index 0000000000..5aed1d6a94 --- /dev/null +++ b/Task/Primality-by-trial-division/NetRexx/primality-by-trial-division-1.netrexx @@ -0,0 +1,66 @@ +/* NetRexx */ + +options replace format comments java crossref savelog symbols nobinary + +parse arg nbr rangeBegin rangeEnd . + +if nbr = '' | nbr = '.' then do + if rangeBegin = '' | rangeBegin = '.' then rangeBegin = 1 + if rangeEnd = '' | rangeEnd = '.' then rangeEnd = 100 + if rangeEnd > rangeBegin then direction = 1 + else direction = -1 + + say 'List of prime numbers from' rangeBegin 'to' rangeEnd':' + primes = '' + loop nn = rangeBegin to rangeEnd by direction + if isPrime(nn) then primes = primes nn + end nn + primes = primes.strip + say ' 'primes.changestr(' ', ',') + say ' Total number of primes:' primes.words + end +else do + if isPrime(nbr) then say nbr.right(20) 'is prime' + else say nbr.right(20) 'is not prime' + end + +return + +method isPrime(nbr = long) public static binary returns boolean + + ip = boolean + + select + when nbr < 2 then do + ip = isFalse + end + when '2 3 5 7'.wordpos(Rexx(nbr)) \= 0 then do + -- crude shortcut ripped from the Rexx example + ip = isTrue + end + when nbr // 2 == 0 | nbr // 3 == 0 then do + -- another shortcut permitted by the one above + ip = isFalse + end + otherwise do + nn = long + nnStartTerm = long 3 -- a reasonable start term - nn <= 2 is never prime + nnEndTerm = long Math.ceil(Math.sqrt(nbr)) -- a reasonable end term + ip = isTrue -- prime the pump (pun intended) + loop nn = nnStartTerm to nnEndTerm by 2 + -- Note: in Rexx and NetRexx "//" is the 'remainder of division operator' (which is not the same as modulo) + if nbr // nn = 0 then do + ip = isFalse + leave nn + end + end nn + end + end + + return ip + +method isTrue public static returns boolean + return 1 == 1 + +method isFalse public static returns boolean + return \isTrue diff --git a/Task/Primality-by-trial-division/NetRexx/primality-by-trial-division-2.netrexx b/Task/Primality-by-trial-division/NetRexx/primality-by-trial-division-2.netrexx new file mode 100644 index 0000000000..42fec74800 --- /dev/null +++ b/Task/Primality-by-trial-division/NetRexx/primality-by-trial-division-2.netrexx @@ -0,0 +1,32 @@ +/* NetRexx */ + +options replace format comments java crossref savelog symbols nobinary + +/*REXX program tests for primality using (kinda smartish) trial division*/ + +parse arg n . /*let user choose how many, maybe*/ +if n=='' then n=10000 /*if not, then assume the default*/ +p=0 /*a count of primes (so far). */ + /*I like Heinz's 57 varieties... */ + loop j=-57 to n /*start in the cellar and work up*/ + if \isprime(j) then iterate /*if not prime, keep looking. */ + p=p+1 /*bump the jelly bean counter. */ + if j.length>2 then iterate /*only show two-digit primes. */ + say j.right(20) 'is prime.' /*Just blab about the wee primes.*/ + end + +say +say "there're" p "primes up to" n '(inclusive).' +exit + +/*-------------------------------------ISPRIME subroutine---------------*/ +method isprime(x) public static returns boolean +--isprime: procedure; arg x /*get the number in question*/ +if '2 3 5 7'.wordpos(x)\==0 then return 1 /*is it a teacher's pet? */ +if x<2 | x//2==0 | x//3==0 then return 0 /*weed out the riff-raff. */ + /*Note: // is modulus. */ + loop j=5 by 6 until j*j>x /*skips multiples of three. */ + if x//j==0 | x//(j+2)==0 then return 0 /*do a pair of divides (mod)*/ + end + +return 1 /*I'm exhausted, it's prime!*/ diff --git a/Task/Primality-by-trial-division/OCaml/primality-by-trial-division.ocaml b/Task/Primality-by-trial-division/OCaml/primality-by-trial-division.ocaml new file mode 100644 index 0000000000..d96671703b --- /dev/null +++ b/Task/Primality-by-trial-division/OCaml/primality-by-trial-division.ocaml @@ -0,0 +1,9 @@ +let is_prime n = + if n = 2 then true + else if n < 2 || n mod 2 = 0 then false + else + let rec loop k = + if k * k > n then true + else if n mod k = 0 then false + else loop (k+2) + in loop 3 diff --git a/Task/Primality-by-trial-division/Objeck/primality-by-trial-division.objeck b/Task/Primality-by-trial-division/Objeck/primality-by-trial-division.objeck new file mode 100644 index 0000000000..d97854f68d --- /dev/null +++ b/Task/Primality-by-trial-division/Objeck/primality-by-trial-division.objeck @@ -0,0 +1,13 @@ +function : IsPrime(n : Int) ~ Bool { + if(n <= 1) { + return false; + }; + + for(i := 2; i * i <= n; i += 1;) { + if(n % i = 0) { + return false; + }; + }; + + return true; +} diff --git a/Task/Primality-by-trial-division/Octave/primality-by-trial-division.octave b/Task/Primality-by-trial-division/Octave/primality-by-trial-division.octave new file mode 100644 index 0000000000..6a8de34adb --- /dev/null +++ b/Task/Primality-by-trial-division/Octave/primality-by-trial-division.octave @@ -0,0 +1,25 @@ +function b = isthisprime(n) + for r = 1:rows(n) + for c = 1:columns(n) + b(r,c) = false; + if ( n(r,c) == 2 ) + b(r,c) = true; + elseif ( (n(r,c) < 2) || (mod(n(r,c),2) == 0) ) + b(r,c) = false; + else + b(r,c) = true; + for i = 3:2:sqrt(n(r,c)) + if ( mod(n(r,c), i) == 0 ) + b(r,c) = false; + break; + endif + endfor + endif + endfor + endfor +endfunction + +% as test, print prime numbers from 1 to 100 +p = [1:100]; +pv = isthisprime(p); +disp(p( pv )); diff --git a/Task/Primality-by-trial-division/PARI-GP/primality-by-trial-division.pari b/Task/Primality-by-trial-division/PARI-GP/primality-by-trial-division.pari new file mode 100644 index 0000000000..cbe8ef15a4 --- /dev/null +++ b/Task/Primality-by-trial-division/PARI-GP/primality-by-trial-division.pari @@ -0,0 +1,7 @@ +trial(n)={ + if(n < 4, return(n > 1)); /* Handle negatives */ + forprime(p=2,sqrt(n), + if(n%p == 0, return(0)) + ); + 1 +}; diff --git a/Task/Primality-by-trial-division/PHP/primality-by-trial-division-1.php b/Task/Primality-by-trial-division/PHP/primality-by-trial-division-1.php new file mode 100644 index 0000000000..c81d3588f8 --- /dev/null +++ b/Task/Primality-by-trial-division/PHP/primality-by-trial-division-1.php @@ -0,0 +1,15 @@ + diff --git a/Task/Primality-by-trial-division/PHP/primality-by-trial-division-2.php b/Task/Primality-by-trial-division/PHP/primality-by-trial-division-2.php new file mode 100644 index 0000000000..d074c4c44c --- /dev/null +++ b/Task/Primality-by-trial-division/PHP/primality-by-trial-division-2.php @@ -0,0 +1,5 @@ + diff --git a/Task/Primality-by-trial-division/PL-I/primality-by-trial-division.pli b/Task/Primality-by-trial-division/PL-I/primality-by-trial-division.pli new file mode 100644 index 0000000000..f3be60f3ca --- /dev/null +++ b/Task/Primality-by-trial-division/PL-I/primality-by-trial-division.pli @@ -0,0 +1,13 @@ +is_prime: procedure (n) returns (bit(1)); + declare n fixed (15); + declare i fixed (10); + + if n < 2 then return ('0'b); + if n = 2 then return ('1'b); + if mod(n, 2) = 0 then return ('0'b); + + do i = 3 to sqrt(n) by 2; + if mod(n, i) = 0 then return ('0'b); + end; + return ('1'b); +end is_prime; diff --git a/Task/Primality-by-trial-division/Pascal/primality-by-trial-division.pascal b/Task/Primality-by-trial-division/Pascal/primality-by-trial-division.pascal new file mode 100644 index 0000000000..4a405dbd0a --- /dev/null +++ b/Task/Primality-by-trial-division/Pascal/primality-by-trial-division.pascal @@ -0,0 +1,29 @@ +program primes; + +function prime(n: integer): boolean; +var + i: integer; max: real; +begin + if n = 2 then + prime := true + else if (n <= 1) or (n mod 2 = 0) then + prime := false + else begin + prime := true; i := 3; max := sqrt(n); + while i <= max do begin + if n mod i = 0 then begin + prime := false; exit + end; + i := i + 2 + end + end +end; + +{ Test and display primes 0 .. 50 } +var + n: integer; +begin + for n := 0 to 50 do + if (prime(n)) then + write(n, ' '); +end. diff --git a/Task/Primality-by-trial-division/Perl-6/primality-by-trial-division-1.pl6 b/Task/Primality-by-trial-division/Perl-6/primality-by-trial-division-1.pl6 new file mode 100644 index 0000000000..e265878db9 --- /dev/null +++ b/Task/Primality-by-trial-division/Perl-6/primality-by-trial-division-1.pl6 @@ -0,0 +1,3 @@ +sub prime (Int $i --> Bool) { + $i > 1 and $i %% none 2, 3, *+2 ...^ * >= sqrt $i; +} diff --git a/Task/Primality-by-trial-division/Perl-6/primality-by-trial-division-2.pl6 b/Task/Primality-by-trial-division/Perl-6/primality-by-trial-division-2.pl6 new file mode 100644 index 0000000000..8a41783dbf --- /dev/null +++ b/Task/Primality-by-trial-division/Perl-6/primality-by-trial-division-2.pl6 @@ -0,0 +1,3 @@ +my @primes := 2, 3, 5, -> $p { ($p+2, $p+4 ... &prime)[*-1] } ... *; +my @isprime = False,False; # 0 and 1 are not prime by definition +sub prime($i) { @isprime[$i] //= ($i %% none @primes ...^ * > $_ given $i.sqrt.floor) } diff --git a/Task/Primality-by-trial-division/Perl-6/primality-by-trial-division-3.pl6 b/Task/Primality-by-trial-division/Perl-6/primality-by-trial-division-3.pl6 new file mode 100644 index 0000000000..ca4be43225 --- /dev/null +++ b/Task/Primality-by-trial-division/Perl-6/primality-by-trial-division-3.pl6 @@ -0,0 +1 @@ +say "$_ is{ "n't" x !prime($_) } prime." for 1 .. 100; diff --git a/Task/Primality-by-trial-division/Perl/primality-by-trial-division-1.pl b/Task/Primality-by-trial-division/Perl/primality-by-trial-division-1.pl new file mode 100644 index 0000000000..d852e633f8 --- /dev/null +++ b/Task/Primality-by-trial-division/Perl/primality-by-trial-division-1.pl @@ -0,0 +1,6 @@ +sub prime { my $n = shift || $_; + $n % $_ or return for 2 .. sqrt $n; + $n > 1 +} + +print join(', ' => grep prime, 1..100), "\n"; diff --git a/Task/Primality-by-trial-division/Perl/primality-by-trial-division-2.pl b/Task/Primality-by-trial-division/Perl/primality-by-trial-division-2.pl new file mode 100644 index 0000000000..7cd1a31460 --- /dev/null +++ b/Task/Primality-by-trial-division/Perl/primality-by-trial-division-2.pl @@ -0,0 +1,6 @@ +sub isprime { + ('1' x shift) !~ /^1?$|^(11+?)\1+$/ +} + +# A quick test +print join(', ', grep(isprime($_), 0..39)), "\n"; diff --git a/Task/Primality-by-trial-division/PicoLisp/primality-by-trial-division.l b/Task/Primality-by-trial-division/PicoLisp/primality-by-trial-division.l new file mode 100644 index 0000000000..957526da52 --- /dev/null +++ b/Task/Primality-by-trial-division/PicoLisp/primality-by-trial-division.l @@ -0,0 +1,9 @@ +(de prime? (N) + (or + (= N 2) + (and + (> N 1) + (bit? 1 N) + (for (D 3 T (+ D 2)) + (T (> D (sqrt N)) T) + (T (=0 (% N D)) NIL) ) ) ) ) diff --git a/Task/Primality-by-trial-division/PowerShell/primality-by-trial-division.psh b/Task/Primality-by-trial-division/PowerShell/primality-by-trial-division.psh new file mode 100644 index 0000000000..26adcd03d5 --- /dev/null +++ b/Task/Primality-by-trial-division/PowerShell/primality-by-trial-division.psh @@ -0,0 +1,7 @@ +function isPrime ($n) { + if ($n -eq 1) { + return $false + } else { + return (@(2..[Math]::Sqrt($n) | Where-Object { $n % $_ -eq 0 }).Length -eq 0) + } +} diff --git a/Task/Primality-by-trial-division/Prolog/primality-by-trial-division.pro b/Task/Primality-by-trial-division/Prolog/primality-by-trial-division.pro new file mode 100644 index 0000000000..171979f351 --- /dev/null +++ b/Task/Primality-by-trial-division/Prolog/primality-by-trial-division.pro @@ -0,0 +1,16 @@ +prime(2). +prime(N) :- integer(N), N > 1, + M is floor(sqrt(N+1)), % round-off paranoia + N mod 2 > 0, % is odd + check_by_odds(N, M, 3). + +check_by_odds(N, M, S) :- + M2 is (M-1) // 2, S2 is S // 2, + forall( between(S2,M2,X), N mod (2*X+1) > 0 ). + +/* +check_by_odds(N, M, F) :- F > M. +check_by_odds(N, M, F) :- F =< M, + N mod F > 0, + F1 is F + 2, % test by odds only + check_by_odds(N, M, F1).*/ diff --git a/Task/Primality-by-trial-division/PureBasic/primality-by-trial-division.purebasic b/Task/Primality-by-trial-division/PureBasic/primality-by-trial-division.purebasic new file mode 100644 index 0000000000..e76620630e --- /dev/null +++ b/Task/Primality-by-trial-division/PureBasic/primality-by-trial-division.purebasic @@ -0,0 +1,19 @@ +Procedure.i IsPrime(n) + Protected k + + If n = 2 + ProcedureReturn #True + EndIf + + If n <= 1 Or n % 2 = 0 + ProcedureReturn #False + EndIf + + For k = 3 To Int(Sqr(n)) Step 2 + If n % k = 0 + ProcedureReturn #False + EndIf + Next + + ProcedureReturn #True +EndProcedure diff --git a/Task/Primality-by-trial-division/Python/primality-by-trial-division-1.py b/Task/Primality-by-trial-division/Python/primality-by-trial-division-1.py new file mode 100644 index 0000000000..3bb7a29513 --- /dev/null +++ b/Task/Primality-by-trial-division/Python/primality-by-trial-division-1.py @@ -0,0 +1,2 @@ +def prime(a): + return not (a < 2 or any(a % x == 0 for x in xrange(2, int(a**0.5) + 1))) diff --git a/Task/Primality-by-trial-division/Python/primality-by-trial-division-2.py b/Task/Primality-by-trial-division/Python/primality-by-trial-division-2.py new file mode 100644 index 0000000000..5dc9209e52 --- /dev/null +++ b/Task/Primality-by-trial-division/Python/primality-by-trial-division-2.py @@ -0,0 +1,4 @@ +def prime2(a): + if a == 2: return True + if a < 2 or a % 2 == 0: return False + return not any(a % x == 0 for x in xrange(3, int(a**0.5) + 1, 2)) diff --git a/Task/Primality-by-trial-division/Python/primality-by-trial-division-3.py b/Task/Primality-by-trial-division/Python/primality-by-trial-division-3.py new file mode 100644 index 0000000000..27b1171cf8 --- /dev/null +++ b/Task/Primality-by-trial-division/Python/primality-by-trial-division-3.py @@ -0,0 +1,13 @@ +def prime3(a): + if a < 2: return False + if a == 2 or a == 3: return True # manually test 2 and 3 + if a % 2 == 0 or a % 3 == 0: return False # exclude multiples of 2 and 3 + + maxDivisor = a**0.5 + d, i = 5, 2 + while d <= maxDivisor: + if a % d == 0: return False + d += i + i = 6 - i # this modifies 2 into 4 and viceversa + + return True diff --git a/Task/Primality-by-trial-division/Python/primality-by-trial-division-4.py b/Task/Primality-by-trial-division/Python/primality-by-trial-division-4.py new file mode 100644 index 0000000000..e5910b90a2 --- /dev/null +++ b/Task/Primality-by-trial-division/Python/primality-by-trial-division-4.py @@ -0,0 +1,7 @@ +>>> import re +>>> def isprime(n): + return not re.match(r'^1?$|^(11+?)\1+$', '1' * n) + +>>> # A quick test +>>> [i for i in range(40) if isprime(i)] +[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37] diff --git a/Task/Primality-by-trial-division/Qi/primality-by-trial-division.qi b/Task/Primality-by-trial-division/Qi/primality-by-trial-division.qi new file mode 100644 index 0000000000..d744a6cd88 --- /dev/null +++ b/Task/Primality-by-trial-division/Qi/primality-by-trial-division.qi @@ -0,0 +1,10 @@ +(define prime?-0 + K N -> true where (> (* K K) N) + K N -> false where (= 0 (MOD N K)) + K N -> (prime?-0 (+ K 2) N)) + +(define prime? + 1 -> false + 2 -> true + N -> false where (= 0 (MOD N 2)) + N -> (prime?-0 3 N)) diff --git a/Task/Primality-by-trial-division/R/primality-by-trial-division-1.r b/Task/Primality-by-trial-division/R/primality-by-trial-division-1.r new file mode 100644 index 0000000000..8be81dbc7c --- /dev/null +++ b/Task/Primality-by-trial-division/R/primality-by-trial-division-1.r @@ -0,0 +1,8 @@ +isPrime <- function(n) { + if (n == 2) return(TRUE) + if ( (n <= 1) || ( n %% 2 == 0 ) ) return(FALSE) + for( i in 3:sqrt(n) ) { + if ( n %% i == 0 ) return(FALSE) + } + TRUE +} diff --git a/Task/Primality-by-trial-division/R/primality-by-trial-division-2.r b/Task/Primality-by-trial-division/R/primality-by-trial-division-2.r new file mode 100644 index 0000000000..f70e4089a1 --- /dev/null +++ b/Task/Primality-by-trial-division/R/primality-by-trial-division-2.r @@ -0,0 +1 @@ +print(lapply(1:100, isPrime)) diff --git a/Task/Primality-by-trial-division/REBOL/primality-by-trial-division-1.rebol b/Task/Primality-by-trial-division/REBOL/primality-by-trial-division-1.rebol new file mode 100644 index 0000000000..b6d6fc6761 --- /dev/null +++ b/Task/Primality-by-trial-division/REBOL/primality-by-trial-division-1.rebol @@ -0,0 +1,12 @@ +prime?: func [n] [ + case [ + n = 2 [ true ] + n <= 1 or (n // 2 = 0) [ false ] + true [ + for i 3 round square-root n 2 [ + if n // i = 0 [ return false ] + ] + true + ] + ] +] diff --git a/Task/Primality-by-trial-division/REBOL/primality-by-trial-division-2.rebol b/Task/Primality-by-trial-division/REBOL/primality-by-trial-division-2.rebol new file mode 100644 index 0000000000..ef25ccc23a --- /dev/null +++ b/Task/Primality-by-trial-division/REBOL/primality-by-trial-division-2.rebol @@ -0,0 +1 @@ +repeat i 100 [ print [i prime? i]] diff --git a/Task/Primality-by-trial-division/REXX/primality-by-trial-division-1.rexx b/Task/Primality-by-trial-division/REXX/primality-by-trial-division-1.rexx new file mode 100644 index 0000000000..a4b723eaea --- /dev/null +++ b/Task/Primality-by-trial-division/REXX/primality-by-trial-division-1.rexx @@ -0,0 +1,24 @@ +/*REXX program tests for primality using (kinda smartish) trial division*/ +parse arg n . /*let user choose how many, maybe*/ +if n=='' then n=10000 /*if not, then assume the default*/ +p=0 /*a count of primes (so far). */ + do j=-57 to n /*start in the cellar and work up*/ + if \isprime(j) then iterate /*if not prime, keep looking. */ + p=p+1 /*bump the jelly bean counter. */ + if j<99 then say right(j,20) 'is prime.' /*Just show wee primes.*/ + end /*j*/ +say +say "There are" p "primes up to" n '(inclusive).' +exit /*stick a fork in it, we're done.*/ + +/*──────────────────────────────────ISPRIME subroutine──────────────────*/ +isprime: procedure; parse arg x /*get the number in question*/ +if \datatype(x,'W') then return 0 /*X not an integer? ¬prime.*/ +if wordpos(x,'2 3 5 7')\==0 then return 1 /*is number a teacher's pet?*/ +if x<2 | x//2==0 | x//3==0 then return 0 /*weed out the riff-raff. */ + + do k=5 by 6 until k*k > x /*skips odd multiples of 3. */ + if x//k==0 | x//(k+2)==0 then return 0 /*do a pair of divides (mod)*/ + end /*k*/ + /*Note: // is modulus. */ +return 1 /*done dividing, it's prime.*/ diff --git a/Task/Primality-by-trial-division/REXX/primality-by-trial-division-2.rexx b/Task/Primality-by-trial-division/REXX/primality-by-trial-division-2.rexx new file mode 100644 index 0000000000..3e24e6bc59 --- /dev/null +++ b/Task/Primality-by-trial-division/REXX/primality-by-trial-division-2.rexx @@ -0,0 +1,26 @@ +/*REXX program tests for primality using (kinda smartish) trial division*/ +parse arg n . /*let user choose how many, maybe*/ +if n=='' then n=10000 /*if not, then assume the default*/ +p=0 /*a count of primes (so far). */ + do j=-57 to n /*start in the cellar and work up*/ + if \isprime(j) then iterate /*if not prime, then keep looking*/ + p=p+1 /*bump the jelly bean counter. */ + if j<99 then say right(j,20) 'is prime.' /*Just show wee primes.*/ + end /*j*/ + +say; say "There are" p "primes up to" n '(inclusive).' +exit /*stick a fork in it, we're done.*/ + +/*──────────────────────────────────ISPRIME subroutine──────────────────*/ +isprime: procedure; parse arg x /*get integer to be investigated.*/ +if \datatype(x,'W') then return 0 /*X isn't an integer? Not prime.*/ +if x<11 then return wordpos(x,'2 3 5 7')\==0 /*is it a wee prime? */ +if x//2==0 then return 0 /*eliminate the evens. */ +if x//3==0 then return 0 /* ··· and eliminate the triples.*/ + /*right dig test: faster than //.*/ + do k=5 by 6 until k*k > x /*this skips odd multiples of 3. */ + if x // k == 0 then return 0 /*perform a divide (modulus), */ + if x // (k+2) == 0 then return 0 /* ··· and the next umpty one. */ + end /*k*/ + /*Note: // is modulus. */ +return 1 /*did all divisions, it's prime. *// diff --git a/Task/Primality-by-trial-division/REXX/primality-by-trial-division-3.rexx b/Task/Primality-by-trial-division/REXX/primality-by-trial-division-3.rexx new file mode 100644 index 0000000000..7d83817a20 --- /dev/null +++ b/Task/Primality-by-trial-division/REXX/primality-by-trial-division-3.rexx @@ -0,0 +1,56 @@ +/*REXX program tests for primality using (kinda smartish) trial division*/ +parse arg n . /*let user choose how many, maybe*/ +if n=='' then n=10000 /*if not, then assume the default*/ +p=0 /*a count of primes (so far). */ + do j=-57 to n /*start in the cellar and work up*/ + if \isprime(j) then iterate /*if not prime, then keep looking*/ + p=p+1 /*bump the jelly bean counter. */ + if j<99 then say right(j,20) 'is prime.' /*Just show wee primes.*/ + end /*j*/ + +say; say "There are" p "primes up to" n '(inclusive).' +exit /*stick a fork in it, we're done.*/ + +/*──────────────────────────────────ISPRIME subroutine──────────────────*/ +isprime: procedure; parse arg x /*get integer to be investigated.*/ +if \datatype(x,'W') then return 0 /*X isn't an integer? Not prime.*/ +if x<107 then do /*test for (low) special cases. */ + _='2 3 5 7 11 13 17 19 23 29 31 37 41 43 47', /*list of ··*/ + '53 59 61 67 71 73 79 83 89 97 101 103' /*wee primes*/ + return wordpos(x,_)\==0 /*is it a wee prime? ··· or not?*/ + end + +if x// 2 ==0 then return 0 /*eliminate the evens. */ +if x// 3 ==0 then return 0 /* ··· and eliminate the triples.*/ +if right(x,1) == 5 then return 0 /* ··· and eliminate the nickels.*/ +if x// 7 ==0 then return 0 /* ··· and eliminate the luckies.*/ +if x//11 ==0 then return 0 +if x//13 ==0 then return 0 +if x//17 ==0 then return 0 +if x//19 ==0 then return 0 +if x//23 ==0 then return 0 +if x//29 ==0 then return 0 +if x//31 ==0 then return 0 +if x//37 ==0 then return 0 +if x//41 ==0 then return 0 +if x//43 ==0 then return 0 +if x//47 ==0 then return 0 +if x//53 ==0 then return 0 +if x//59 ==0 then return 0 +if x//61 ==0 then return 0 +if x//67 ==0 then return 0 +if x//71 ==0 then return 0 +if x//73 ==0 then return 0 +if x//79 ==0 then return 0 +if x//83 ==0 then return 0 +if x//89 ==0 then return 0 +if x//97 ==0 then return 0 +if x//101==0 then return 0 +if x//103==0 then return 0 + /*Note: // is modulus. */ + do k=107 by 6 while k*k<=x /*this skips odd multiples of 3. */ + if x // k == 0 then return 0 /*perform a divide (modulus), */ + if x // (k+2) == 0 then return 0 /* ··· and the next umpty one. */ + end /*k*/ + +return 1 /*after all that, ··· it's prime.*/ diff --git a/Task/Primality-by-trial-division/Ruby/primality-by-trial-division-1.rb b/Task/Primality-by-trial-division/Ruby/primality-by-trial-division-1.rb new file mode 100644 index 0000000000..36d39a158f --- /dev/null +++ b/Task/Primality-by-trial-division/Ruby/primality-by-trial-division-1.rb @@ -0,0 +1,11 @@ +def prime(a) + if a == 2 + true + elsif a <= 1 || a % 2 == 0 + false + else + divisors = Enumerable::Enumerator.new(3..Math.sqrt(a), :step, 2) + # this also creates an enumerable object: divisors = (3..Math.sqrt(a)).step(2) + !divisors.any? { |d| a % d == 0 } + end +end diff --git a/Task/Primality-by-trial-division/Ruby/primality-by-trial-division-2.rb b/Task/Primality-by-trial-division/Ruby/primality-by-trial-division-2.rb new file mode 100644 index 0000000000..21a87fed84 --- /dev/null +++ b/Task/Primality-by-trial-division/Ruby/primality-by-trial-division-2.rb @@ -0,0 +1,8 @@ + def prime?(value, generator = Prime::Generator23.new) + return false if value < 2 + for num in generator + q,r = value.divmod num + return true if q < num + return false if r == 0 + end + end diff --git a/Task/Primality-by-trial-division/Ruby/primality-by-trial-division-3.rb b/Task/Primality-by-trial-division/Ruby/primality-by-trial-division-3.rb new file mode 100644 index 0000000000..59ad3451d2 --- /dev/null +++ b/Task/Primality-by-trial-division/Ruby/primality-by-trial-division-3.rb @@ -0,0 +1,10 @@ +def primes(limit) + (enclose = lambda { |primes| + primes.last.succ.upto(limit) do |trial_pri| + if primes.find { |pri| (trial_pri % pri).zero? }.nil? + return enclose.call(primes << trial_pri) + end + end + primes + }).call([2]) +end diff --git a/Task/Primality-by-trial-division/Ruby/primality-by-trial-division-4.rb b/Task/Primality-by-trial-division/Ruby/primality-by-trial-division-4.rb new file mode 100644 index 0000000000..2db902d61d --- /dev/null +++ b/Task/Primality-by-trial-division/Ruby/primality-by-trial-division-4.rb @@ -0,0 +1,3 @@ +def isprime(n) + '1'*n !~ /^1?$|^(11+?)\1+$/ +end diff --git a/Task/Primality-by-trial-division/Run-BASIC/primality-by-trial-division.run b/Task/Primality-by-trial-division/Run-BASIC/primality-by-trial-division.run new file mode 100644 index 0000000000..1b3fe02ef8 --- /dev/null +++ b/Task/Primality-by-trial-division/Run-BASIC/primality-by-trial-division.run @@ -0,0 +1,15 @@ +' Test and display primes 1 .. 50 +for i = 1 TO 50 + if prime(i) <> 0 then print i;" "; +next i + +FUNCTION prime(n) +if n < 2 then prime = 0 : goto [exit] +if n = 2 then prime = 1 : goto [exit] +if n mod 2 = 0 then prime = 0 : goto [exit] +prime = 1 +for i = 3 to int(n^.5) step 2 + if n mod i = 0 then prime = 0 : goto [exit] +next i +[exit] +END FUNCTION diff --git a/Task/Primality-by-trial-division/SAS/primality-by-trial-division.sas b/Task/Primality-by-trial-division/SAS/primality-by-trial-division.sas new file mode 100644 index 0000000000..559af31da7 --- /dev/null +++ b/Task/Primality-by-trial-division/SAS/primality-by-trial-division.sas @@ -0,0 +1,21 @@ +data primes; +do n=1 to 1000; + link primep; + if primep then output; +end; +stop; + +primep: +if n < 4 then do; + primep=n=2 or n=3; + return; +end; +primep=0; +if mod(n,2)=0 then return; +do k=3 to sqrt(n) by 2; + if mod(n,k)=0 then return; +end; +primep=1; +return; +keep n; +run; diff --git a/Task/Primality-by-trial-division/SNOBOL4/primality-by-trial-division-1.sno b/Task/Primality-by-trial-division/SNOBOL4/primality-by-trial-division-1.sno new file mode 100644 index 0000000000..7b2396c551 --- /dev/null +++ b/Task/Primality-by-trial-division/SNOBOL4/primality-by-trial-division-1.sno @@ -0,0 +1,9 @@ +define('isprime(n)i,max') :(isprime_end) +isprime isprime = n + le(n,1) :s(freturn) + eq(n,2) :s(return) + eq(remdr(n,2),0) :s(freturn) + max = sqrt(n); i = 1 +isp1 i = le(i + 2,max) i + 2 :f(return) + eq(remdr(n,i),0) :s(freturn)f(isp1) +isprime_end diff --git a/Task/Primality-by-trial-division/SNOBOL4/primality-by-trial-division-2.sno b/Task/Primality-by-trial-division/SNOBOL4/primality-by-trial-division-2.sno new file mode 100644 index 0000000000..3ce85f13c3 --- /dev/null +++ b/Task/Primality-by-trial-division/SNOBOL4/primality-by-trial-division-2.sno @@ -0,0 +1,12 @@ + define('rprime(n)str,pat1,pat2,m1') :(end_rprime) +rprime str = dupl('1',n); rprime = n + pat1 = ('1' | '') + pat2 = ('11' arbno('1')) $ m1 (*m1 arbno(*m1)) + str pos(0) (pat1 | pat2) rpos(0) :s(freturn)f(return) +end_rprime + +* # Test and display primes 0 .. 50 +loop rprimes = rprimes rprime(n) ' ' + n = lt(n,50) n + 1 :s(loop) + output = rprimes +end diff --git a/Task/Primality-by-trial-division/Scala/primality-by-trial-division.scala b/Task/Primality-by-trial-division/Scala/primality-by-trial-division.scala new file mode 100644 index 0000000000..fc177798ce --- /dev/null +++ b/Task/Primality-by-trial-division/Scala/primality-by-trial-division.scala @@ -0,0 +1 @@ +def isPrime(n: Int) = n > 1 && (Iterator.from(2) takeWhile (d => d * d <= n) forall (n % _ != 0)) diff --git a/Task/Primality-by-trial-division/Scheme/primality-by-trial-division-1.ss b/Task/Primality-by-trial-division/Scheme/primality-by-trial-division-1.ss new file mode 100644 index 0000000000..4ece9bfd3b --- /dev/null +++ b/Task/Primality-by-trial-division/Scheme/primality-by-trial-division-1.ss @@ -0,0 +1,7 @@ +(define (prime? number) + (define (*prime? divisor) + (or (> (* divisor divisor) number) + (and (> (modulo number divisor) 0) + (*prime? (+ divisor 1))))) + (and (> number 1) + (*prime? 2))) diff --git a/Task/Primality-by-trial-division/Scheme/primality-by-trial-division-2.ss b/Task/Primality-by-trial-division/Scheme/primality-by-trial-division-2.ss new file mode 100644 index 0000000000..17ca6c3d46 --- /dev/null +++ b/Task/Primality-by-trial-division/Scheme/primality-by-trial-division-2.ss @@ -0,0 +1,8 @@ +; twice faster, testing only odd divisors +(define (prime? n) + (if (< n 4) (> n 1) + (and (odd? n) + (let loop ((k 3)) + (or (> (* k k) n) + (and (positive? (remainder n k)) + (loop (+ k 2)))))))) diff --git a/Task/Primality-by-trial-division/Seed7/primality-by-trial-division.seed7 b/Task/Primality-by-trial-division/Seed7/primality-by-trial-division.seed7 new file mode 100644 index 0000000000..99397bf068 --- /dev/null +++ b/Task/Primality-by-trial-division/Seed7/primality-by-trial-division.seed7 @@ -0,0 +1,19 @@ +const func boolean: is_prime (in integer: number) is func + result + var boolean: prime is FALSE; + local + var integer: upTo is 0; + var integer: testNum is 3; + begin + if number = 2 then + prime := TRUE; + elsif number rem 2 = 0 or number <= 1 then + prime := FALSE; + else + upTo := sqrt(number); + while number rem testNum <> 0 and testNum <= upTo do + testNum +:= 2; + end while; + prime := testNum > upTo; + end if; + end func; diff --git a/Task/Primality-by-trial-division/Standard-ML/primality-by-trial-division.ml b/Task/Primality-by-trial-division/Standard-ML/primality-by-trial-division.ml new file mode 100644 index 0000000000..c17511a13a --- /dev/null +++ b/Task/Primality-by-trial-division/Standard-ML/primality-by-trial-division.ml @@ -0,0 +1,10 @@ +fun is_prime n = + if n = 2 then true + else if n < 2 orelse n mod 2 = 0 then false + else let + fun loop k = + if k * k > n then true + else if n mod k = 0 then false + else loop (k+2) + in loop 3 + end diff --git a/Task/Primality-by-trial-division/Tcl/primality-by-trial-division.tcl b/Task/Primality-by-trial-division/Tcl/primality-by-trial-division.tcl new file mode 100644 index 0000000000..f36dc22bf8 --- /dev/null +++ b/Task/Primality-by-trial-division/Tcl/primality-by-trial-division.tcl @@ -0,0 +1,9 @@ +proc is_prime n { + if {$n <= 1} {return false} + if {$n == 2} {return true} + if {$n % 2 == 0} {return false} + for {set i 3} {$i <= sqrt($n)} {incr i 2} { + if {$n % $i == 0} {return false} + } + return true +} diff --git a/Task/Primality-by-trial-division/UNIX-Shell/primality-by-trial-division-1.sh b/Task/Primality-by-trial-division/UNIX-Shell/primality-by-trial-division-1.sh new file mode 100644 index 0000000000..261109f50f --- /dev/null +++ b/Task/Primality-by-trial-division/UNIX-Shell/primality-by-trial-division-1.sh @@ -0,0 +1,15 @@ +function primep { + typeset n=$1 p=3 + (( n == 2 )) && return 0 # 2 is prime. + (( n & 1 )) || return 1 # Other evens are not prime. + (( n >= 3 )) || return 1 + + # Loop for odd p from 3 to sqrt(n). + # Comparing p * p <= n can overflow. + while (( p <= n / p )); do + # If p divides n, then n is not prime. + (( n % p )) || return 1 + (( p += 2 )) + done + return 0 # Yes, n is prime. +} diff --git a/Task/Primality-by-trial-division/UNIX-Shell/primality-by-trial-division-2.sh b/Task/Primality-by-trial-division/UNIX-Shell/primality-by-trial-division-2.sh new file mode 100644 index 0000000000..997dbf5b50 --- /dev/null +++ b/Task/Primality-by-trial-division/UNIX-Shell/primality-by-trial-division-2.sh @@ -0,0 +1,15 @@ +primep() { + set -- "$1" 3 + test "$1" -eq 2 && return 0 # 2 is prime. + expr "$1" \% 2 >/dev/null || return 1 # Other evens are not prime. + test "$1" -ge 3 || return 1 + + # Loop for odd p from 3 to sqrt(n). + # Comparing p * p <= n can overflow. We use p <= n / p. + while expr $2 \<= "$1" / $2 >/dev/null; do + # If p divides n, then n is not prime. + expr "$1" % $2 >/dev/null || return 1 + set -- "$1" `expr $2 + 2` + done + return 0 # Yes, n is prime. +} diff --git a/Task/Primality-by-trial-division/Ursala/primality-by-trial-division-1.ursala b/Task/Primality-by-trial-division/Ursala/primality-by-trial-division-1.ursala new file mode 100644 index 0000000000..aaa0e9543f --- /dev/null +++ b/Task/Primality-by-trial-division/Ursala/primality-by-trial-division-1.ursala @@ -0,0 +1,4 @@ +#import std +#import nat + +prime = ~<{0,1}&& -={2,3}!| ~&h&& (all remainder)^Dtt/~& iota@K31 diff --git a/Task/Primality-by-trial-division/Ursala/primality-by-trial-division-2.ursala b/Task/Primality-by-trial-division/Ursala/primality-by-trial-division-2.ursala new file mode 100644 index 0000000000..f206d126b9 --- /dev/null +++ b/Task/Primality-by-trial-division/Ursala/primality-by-trial-division-2.ursala @@ -0,0 +1,3 @@ +#cast %bL + +test = prime* <5,6,7> diff --git a/Task/Primality-by-trial-division/V/primality-by-trial-division-1.v b/Task/Primality-by-trial-division/V/primality-by-trial-division-1.v new file mode 100644 index 0000000000..1814547110 --- /dev/null +++ b/Task/Primality-by-trial-division/V/primality-by-trial-division-1.v @@ -0,0 +1,6 @@ +[prime? + 2 + [[dup * >] [true] [false] ifte [% 0 >] dip and] + [succ] + while + dup * <]. diff --git a/Task/Primality-by-trial-division/V/primality-by-trial-division-2.v b/Task/Primality-by-trial-division/V/primality-by-trial-division-2.v new file mode 100644 index 0000000000..c3d48a1faf --- /dev/null +++ b/Task/Primality-by-trial-division/V/primality-by-trial-division-2.v @@ -0,0 +1,4 @@ +|11 prime? +=true +|4 prime? +=false diff --git a/Task/Primality-by-trial-division/XPL0/primality-by-trial-division.xpl0 b/Task/Primality-by-trial-division/XPL0/primality-by-trial-division.xpl0 new file mode 100644 index 0000000000..c7d8cb8dbf --- /dev/null +++ b/Task/Primality-by-trial-division/XPL0/primality-by-trial-division.xpl0 @@ -0,0 +1,16 @@ +include c:\cxpl\codes; \intrinsic 'code' declarations + +func Prime(N); \Return 'true' if N is a prime number +int N; +int I; +[if N <= 1 then return false; +for I:= 3 to sqrt(N) do + if rem(N/I) = 0 then return false; +return true; +]; \Prime + +int Num; +repeat Num:= IntIn(0); + Text(0, if Prime(Num) then "is " else "not "); + Text(0, "prime^M^J"); +until Num = 0 diff --git a/Task/Prime-decomposition/0DESCRIPTION b/Task/Prime-decomposition/0DESCRIPTION new file mode 100644 index 0000000000..277bde1d04 --- /dev/null +++ b/Task/Prime-decomposition/0DESCRIPTION @@ -0,0 +1,7 @@ +The prime decomposition of a number is defined as a list of prime numbers which when all multiplied together, are equal to that number. Example: 12 = 2 × 2 × 3, so its prime decomposition is {2, 2, 3} + +Write a function which returns an [[array]] or [[Collections|collection]] which contains the prime decomposition of a given number, n, greater than 1. If your language does not have an isPrime-like function available, you may assume that you have a function which determines whether a number is prime (note its name before your code). + +If you would like to test code from this task, you may use code from [[Primality by Trial Division|trial division]] or the [[Sieve of Eratosthenes]]. + +Note: The program must not be limited by the word size of your computer or some other artificial limit; it should work for any number regardless of size (ignoring the physical limits of RAM etc). diff --git a/Task/Prime-decomposition/1META.yaml b/Task/Prime-decomposition/1META.yaml new file mode 100644 index 0000000000..bbdc15808a --- /dev/null +++ b/Task/Prime-decomposition/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Arbitrary precision +note: Prime Numbers diff --git a/Task/Prime-decomposition/ABAP/prime-decomposition.abap b/Task/Prime-decomposition/ABAP/prime-decomposition.abap new file mode 100644 index 0000000000..3d7dcac852 --- /dev/null +++ b/Task/Prime-decomposition/ABAP/prime-decomposition.abap @@ -0,0 +1,53 @@ +class ZMLA_ROSETTA definition + public + create public . + + public section. + + types: + enumber TYPE N LENGTH 60, + listof_enumber TYPE TABLE OF enumber . + + class-methods FACTORS + importing + value(N) type ENUMBER + exporting + value(ORET) type LISTOF_ENUMBER . + protected section. + private section. +ENDCLASS. + + + +CLASS ZMLA_ROSETTA IMPLEMENTATION. + + +* ---------------------------------------------------------------------------------------+ +* | Static Public Method ZMLA_ROSETTA=>FACTORS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] N TYPE ENUMBER +* | [<---] ORET TYPE LISTOF_ENUMBER +* +-------------------------------------------------------------------------------------- + method FACTORS. + CLEAR oret. + WHILE n mod 2 = 0. + n = n / 2. + APPEND 2 to oret. + ENDWHILE. + DATA: lim type enumber, + i type enumber. + lim = sqrt( n ). + i = 3. + WHILE i <= lim. + WHILE n mod i = 0. + APPEND i to oret. + n = n / i. + lim = sqrt( n ). + ENDWHILE. + i = i + 2. + ENDWHILE. + IF n > 1. + APPEND n to oret. + ENDIF. + endmethod. +ENDCLASS. diff --git a/Task/Prime-decomposition/ACL2/prime-decomposition.acl2 b/Task/Prime-decomposition/ACL2/prime-decomposition.acl2 new file mode 100644 index 0000000000..a02f944aa0 --- /dev/null +++ b/Task/Prime-decomposition/ACL2/prime-decomposition.acl2 @@ -0,0 +1,13 @@ +(include-book "arithmetic-3/top" :dir :system) + +(defun prime-factors-r (n i) + (declare (xargs :mode :program)) + (cond ((or (zp n) (zp (- n i)) (zp i) (< i 2) (< n 2)) + (list n)) + ((= (mod n i) 0) + (cons i (prime-factors-r (floor n i) 2))) + (t (prime-factors-r n (1+ i))))) + +(defun prime-factors (n) + (declare (xargs :mode :program)) + (prime-factors-r n 2)) diff --git a/Task/Prime-decomposition/ALGOL-68/prime-decomposition.alg b/Task/Prime-decomposition/ALGOL-68/prime-decomposition.alg new file mode 100644 index 0000000000..6439ab4ba9 --- /dev/null +++ b/Task/Prime-decomposition/ALGOL-68/prime-decomposition.alg @@ -0,0 +1,103 @@ +#IF long int possible THEN # + +MODE LINT = LONG INT; +LINT lmax int = long max int; +OP LLENG = (INT i)LINT: LENG i, + LSHORTEN = (LINT i)INT: SHORTEN i; + +#ELSE + +MODE LINT = INT; +LINT lmax int = max int; +OP LLENG = (INT i)LINT: i, + LSHORTEN = (LINT i)INT: i; + +FI# + +OP LLONG = (INT i)LINT: LLENG i; + +MODE YIELDLINT = PROC(LINT)VOID; + +PROC (LINT, YIELDLINT)VOID gen decompose; + +INT upb cache = bits width; + +BITS cache := 2r0; +BITS cached := 2r0; + +PROC is prime = (LINT n)BOOL: ( + BOOL + has factor := FALSE, + out := TRUE; + # FOR LINT factor IN # gen decompose(n, # ) DO ( # + ## (LINT factor)VOID:( + IF has factor THEN out := FALSE; GO TO done FI; + has factor := TRUE + # OD # )); + done: out +); + +PROC is prime cached := (LINT n)BOOL: ( + LINT l half n = n OVER LLONG 2 - LLONG 1; + IF l half n <= LLENG upb cache THEN + INT half n = LSHORTEN l half n; + IF half n ELEM cached THEN + BOOL(half n ELEM cache) + ELSE + BOOL out = is prime(n); + BITS mask = 2r1 SHL (upb cache - half n); + cached := cached OR mask; + IF out THEN cache := cache OR mask FI; + out + FI + ELSE + is prime(n) # above useful cache limit # + FI +); + + +PROC gen primes := (YIELDLINT yield)VOID:( + yield(LLONG 2); + LINT n := LLONG 3; + WHILE n < l maxint - LLONG 2 DO + yield(n); + n +:= LLONG 2; + WHILE n < l maxint - LLONG 2 AND NOT is prime cached(n) DO + n +:= LLONG 2 + OD + OD +); + +# PROC # gen decompose := (LINT in n, YIELDLINT yield)VOID: ( + LINT n := in n; + # FOR LINT p IN # gen primes( # ) DO ( # + ## (LINT p)VOID: + IF p*p > n THEN + GO TO done + ELSE + WHILE n MOD p = LLONG 0 DO + yield(p); + n := n OVER p + OD + FI + # OD # ); + done: + IF n > LLONG 1 THEN + yield(n) + FI +); + +main:( +# FOR LINT m IN # gen primes( # ) DO ( # +## (LINT m)VOID:( + LINT p = LLONG 2 ** LSHORTEN m - LLONG 1; + print(("2**",whole(m,0),"-1 = ",whole(p,0),", with factors:")); + # FOR LINT factor IN # gen decompose(p, # ) DO ( # + ## (LINT factor)VOID: + print((" ",whole(factor,0))) + # OD # ); + print(new line); + IF m >= LLONG 59 THEN GO TO done FI +# OD # )); + done: EMPTY +) diff --git a/Task/Prime-decomposition/AWK/prime-decomposition.awk b/Task/Prime-decomposition/AWK/prime-decomposition.awk new file mode 100644 index 0000000000..d6321e48ef --- /dev/null +++ b/Task/Prime-decomposition/AWK/prime-decomposition.awk @@ -0,0 +1,14 @@ +function pfac(n, r, f){ + r = ""; f = 2 + while (f <= n) { + while(!(n % f)) { + n = n / f + r = r " " f + } + f = f + 2 - (f == 2) + } + return r +} + +# For each line of input, print the prime factors. +{ print pfac($1) } diff --git a/Task/Prime-decomposition/Ada/prime-decomposition.ada b/Task/Prime-decomposition/Ada/prime-decomposition.ada new file mode 100644 index 0000000000..a48b4b593d --- /dev/null +++ b/Task/Prime-decomposition/Ada/prime-decomposition.ada @@ -0,0 +1,60 @@ +with Ada.Text_IO; use Ada.Text_IO; + +procedure Test_Prime is + generic + type Number is private; + Zero : Number; + One : Number; + Two : Number; + with function Image (X : Number) return String is <>; + with function "+" (X, Y : Number) return Number is <>; + with function "/" (X, Y : Number) return Number is <>; + with function "mod" (X, Y : Number) return Number is <>; + with function ">=" (X, Y : Number) return Boolean is <>; + package Prime_Numbers is + type Number_List is array (Positive range <>) of Number; + function Decompose (N : Number) return Number_List; + procedure Put (List : Number_List); + end Prime_Numbers; + + package body Prime_Numbers is + function Decompose (N : Number) return Number_List is + Size : Natural := 0; + M : Number := N; + K : Number := Two; + begin + -- Estimation of the result length from above + while M >= Two loop + M := (M + One) / Two; + 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 Zero = (M mod K) loop -- While divides + Result (Index) := K; + Index := Index + 1; + M := M / K; + end loop; + K := K + One; + end loop; + return Result (1..Index - 1); + end; + end Decompose; + + procedure Put (List : Number_List) is + begin + for Index in List'Range loop + Put (Image (List (Index))); + end loop; + end Put; + end Prime_Numbers; + package Integer_Numbers is new Prime_Numbers (Natural, 0, 1, 2, Positive'Image); + use Integer_Numbers; +begin + Put (Decompose (12)); +end Test_Prime; diff --git a/Task/Prime-decomposition/AutoHotkey/prime-decomposition.ahk b/Task/Prime-decomposition/AutoHotkey/prime-decomposition.ahk new file mode 100644 index 0000000000..ae169a3cbe --- /dev/null +++ b/Task/Prime-decomposition/AutoHotkey/prime-decomposition.ahk @@ -0,0 +1,18 @@ +MsgBox % factor(8388607) ; 47 * 178481 + +factor(n) +{ + If (n = 1) + Return + f = 2 + While (f <= n) + { + If (Mod(n, f) = 0) + { + next := factor(n / f) + factors = %f%`n%next% + Return factors + } + f++ + } +} diff --git a/Task/Prime-decomposition/Befunge/prime-decomposition.bf b/Task/Prime-decomposition/Befunge/prime-decomposition.bf new file mode 100644 index 0000000000..a34c5b83ce --- /dev/null +++ b/Task/Prime-decomposition/Befunge/prime-decomposition.bf @@ -0,0 +1,4 @@ +& 211p > : 1 - #v_ 25*, @ > 11g:. / v + > : 11g %!| + > 11g 1+ 11p v + ^ < diff --git a/Task/Prime-decomposition/Burlesque/prime-decomposition.blq b/Task/Prime-decomposition/Burlesque/prime-decomposition.blq new file mode 100644 index 0000000000..20dc2737d2 --- /dev/null +++ b/Task/Prime-decomposition/Burlesque/prime-decomposition.blq @@ -0,0 +1,2 @@ +blsq ) 12fC +{2 2 3} diff --git a/Task/Prime-decomposition/C++/prime-decomposition.cpp b/Task/Prime-decomposition/C++/prime-decomposition.cpp new file mode 100644 index 0000000000..024eb3ed24 --- /dev/null +++ b/Task/Prime-decomposition/C++/prime-decomposition.cpp @@ -0,0 +1,85 @@ +#include +#include + +// This function template works for any type representing integers or +// nonnegative integers, and has the standard operator overloads for +// arithmetic and comparison operators, as well as explicit conversion +// from int. +// +// OutputIterator must be an output iterator with value_type Integer. +// It receives the prime factors. +template + void decompose(Integer n, OutputIterator out) +{ + Integer i(2); + + while (n != 1) + { + while (n % i == Integer(0)) + { + *out++ = i; + n /= i; + } + ++i; + } +} + +// this is an output iterator similar to std::ostream_iterator, except +// that it outputs the separation string *before* the value, but not +// before the first value (i.e. it produces an infix notation). +template class infix_ostream_iterator: + public std::iterator +{ + class Proxy; + friend class Proxy; + class Proxy + { + public: + Proxy(infix_ostream_iterator& iter): iterator(iter) {} + Proxy& operator=(T const& value) + { + if (!iterator.first) + { + iterator.stream << iterator.infix; + } + iterator.stream << value; + } + private: + infix_ostream_iterator& iterator; + }; +public: + infix_ostream_iterator(std::ostream& os, char const* inf): + stream(os), + first(true), + infix(inf) + { + } + infix_ostream_iterator& operator++() { first = false; return *this; } + infix_ostream_iterator operator++(int) + { + infix_ostream_iterator prev(*this); + ++*this; + return prev; + } + Proxy operator*() { return Proxy(*this); } +private: + std::ostream& stream; + bool first; + char const* infix; +}; + +int main() +{ + std::cout << "please enter a positive number: "; + mpz_class number; + std::cin >> number; + + if (number <= 0) + std::cout << "this number is not positive!\n;"; + else + { + std::cout << "decomposition: "; + decompose(number, infix_ostream_iterator(std::cout, " * ")); + std::cout << "\n"; + } +} diff --git a/Task/Prime-decomposition/C/prime-decomposition-1.c b/Task/Prime-decomposition/C/prime-decomposition-1.c new file mode 100644 index 0000000000..476a777a0e --- /dev/null +++ b/Task/Prime-decomposition/C/prime-decomposition-1.c @@ -0,0 +1,171 @@ +#include +#include +#include +#include +#include + +typedef uint32_t pint; +typedef uint64_t xint; +typedef unsigned int uint; +#define PRIuPINT PRIu32 /* printf macro for pint */ +#define PRIuXINT PRIu64 /* printf macro for xint */ +#define MAX_FACTORS 63 /* because 2^64 is too large for xint */ + +uint8_t *pbits; + +#define MAX_PRIME (~(pint)0) +#define MAX_PRIME_SQ 65535U +#define PBITS (MAX_PRIME / 30 + 1) + +pint next_prime(pint); +int is_prime(xint); +void sieve(pint); + +uint8_t bit_pos[30] = { + 0, 1<<0, 0, 0, 0, 0, + 0, 1<<1, 0, 0, 0, 1<<2, + 0, 1<<3, 0, 0, 0, 1<<4, + 0, 1<<5, 0, 0, 0, 1<<6, + 0, 0, 0, 0, 0, 1<<7, +}; + +uint8_t rem_num[] = { 1, 7, 11, 13, 17, 19, 23, 29 }; + +void init_primes() +{ + FILE *fp; + pint s, tgt = 4; + + if (!(pbits = malloc(PBITS))) { + perror("malloc"); + exit(1); + } + + if ((fp = fopen("primebits", "r"))) { + fread(pbits, 1, PBITS, fp); + fclose(fp); + return; + } + + memset(pbits, 255, PBITS); + for (s = 7; s <= MAX_PRIME_SQ; s = next_prime(s)) { + if (s > tgt) { + tgt *= 2; + fprintf(stderr, "sieve %"PRIuPINT"\n", s); + } + sieve(s); + } + fp = fopen("primebits", "w"); + fwrite(pbits, 1, PBITS, fp); + fclose(fp); +} + +int is_prime(xint x) +{ + pint p; + if (x > 5) { + if (x < MAX_PRIME) + return pbits[x/30] & bit_pos[x % 30]; + + for (p = 2; p && (xint)p * p <= x; p = next_prime(p)) + if (x % p == 0) return 0; + + return 1; + } + return x == 2 || x == 3 || x == 5; +} + +void sieve(pint p) +{ + unsigned char b[8]; + off_t ofs[8]; + int i, q; + + for (i = 0; i < 8; i++) { + q = rem_num[i] * p; + b[i] = ~bit_pos[q % 30]; + ofs[i] = q / 30; + } + + for (q = ofs[1], i = 7; i; i--) + ofs[i] -= ofs[i-1]; + + for (ofs[0] = p, i = 1; i < 8; i++) + ofs[0] -= ofs[i]; + + for (i = 1; q < PBITS; q += ofs[i = (i + 1) & 7]) + pbits[q] &= b[i]; +} + +pint next_prime(pint p) +{ + off_t addr; + uint8_t bits, rem; + + if (p > 5) { + addr = p / 30; + bits = bit_pos[ p % 30 ] << 1; + for (rem = 0; (1 << rem) < bits; rem++); + while (pbits[addr] < bits || !bits) { + if (++addr >= PBITS) return 0; + bits = 1; + rem = 0; + } + if (addr >= PBITS) return 0; + while (!(pbits[addr] & bits)) { + rem++; + bits <<= 1; + } + return p = addr * 30 + rem_num[rem]; + } + + switch(p) { + case 2: return 3; + case 3: return 5; + case 5: return 7; + } + return 2; +} + +int decompose(xint n, xint *f) +{ + pint p = 0; + int i = 0; + + /* check small primes: not strictly necessary */ + if (n <= MAX_PRIME && is_prime(n)) { + f[0] = n; + return 1; + } + + while (n >= (xint)p * p) { + if (!(p = next_prime(p))) break; + while (n % p == 0) { + n /= p; + f[i++] = p; + } + } + if (n > 1) f[i++] = n; + return i; +} + +int main() +{ + int i, len; + pint p = 0; + xint f[MAX_FACTORS], po; + + init_primes(); + + for (p = 1; p < 64; p++) { + po = (1LLU << p) - 1; + printf("2^%"PRIuPINT" - 1 = %"PRIuXINT, p, po); + fflush(stdout); + if ((len = decompose(po, f)) > 1) + for (i = 0; i < len; i++) + printf(" %c %"PRIuXINT, i?'x':'=', f[i]); + putchar('\n'); + } + + return 0; +} diff --git a/Task/Prime-decomposition/C/prime-decomposition-2.c b/Task/Prime-decomposition/C/prime-decomposition-2.c new file mode 100644 index 0000000000..b26031610a --- /dev/null +++ b/Task/Prime-decomposition/C/prime-decomposition-2.c @@ -0,0 +1,107 @@ +#include +#include +#include + +typedef enum{false=0, true=1}bool; +const int max_lint = LONG_MAX; + +typedef long long int lint; +#assert sizeof_long_long_int (LONG_MAX>=8) /* XXX */ + +/* the following line is the only time I have ever required "auto" */ +#define FOR(i,iterator) auto bool lambda(i); yield_init = (void *)λ iterator; bool lambda(i) +#define DO { +#define YIELD(x) if(!yield(x))return +#define BREAK return false +#define CONTINUE return true +#define OD CONTINUE; } +/* Warning: _Most_ FOR(,){ } loops _must_ have a CONTINUE as the last statement. + * Otherwise the lambda will return random value from stack, and may terminate early */ + +typedef void iterator, lint_iterator; /* hint at procedure purpose */ +static volatile void *yield_init; /* not thread safe */ +#define YIELDS(type) bool (*yield)(type) = yield_init + +typedef unsigned int bits; +#define ELEM(shift, bits) ( (bits >> shift) & 0b1 ) + +bits cache = 0b0, cached = 0b0; +const lint upb_cache = 8 * sizeof(cache); + +lint_iterator decompose(lint); /* forward declaration */ + +bool is_prime(lint n){ + bool has_factor = false, out = true; +/* for factor in decompose(n) do */ + FOR(lint factor, decompose(n)){ + if( has_factor ){ out = false; BREAK; } + has_factor = true; + CONTINUE; + } + return out; +} + +bool is_prime_cached (lint n){ + lint half_n = n / 2 - 2; + if( half_n <= upb_cache){ + /* dont cache the initial four, nor the even numbers */ + if (ELEM(half_n,cached)){ + return ELEM(half_n,cache); + } else { + bool out = is_prime(n); + cache = cache | out << half_n; + cached = cached | 0b1 << half_n; + return out; + } + } else { + return is_prime(n); + } +} + +lint_iterator primes (){ + YIELDS(lint); + YIELD(2); + lint n = 3; + while( n < max_lint - 2 ){ + YIELD(n); + n += 2; + while( n < max_lint - 2 && ! is_prime_cached(n) ){ + n += 2; + } + } +} + +lint_iterator decompose (lint in_n){ + YIELDS(lint); + lint n = in_n; + /* for p in primes do */ + FOR(lint p, primes()){ + if( p*p > n ){ + BREAK; + } else { + while( n % p == 0 ){ + YIELD(p); + n = n / p; + } + } + CONTINUE; + } + if( n > 1 ){ + YIELD(n); + } +} + +main(){ + FOR(lint m, primes()){ + lint p = powl(2, m) - 1; + printf("2**%lld-1 = %lld, with factors:",m,p); + FOR(lint factor, decompose(p)){ + printf(" %lld",factor); + fflush(stdout); + CONTINUE; + } + printf("\n",m); + if( m >= 59 )BREAK; + CONTINUE; + } +} diff --git a/Task/Prime-decomposition/C/prime-decomposition-3.c b/Task/Prime-decomposition/C/prime-decomposition-3.c new file mode 100644 index 0000000000..6f76d46355 --- /dev/null +++ b/Task/Prime-decomposition/C/prime-decomposition-3.c @@ -0,0 +1,73 @@ +#include +#include +#include + +typedef uint32_t pint; +typedef uint64_t xint; +typedef unsigned int uint; + +int is_prime(xint); + +inline int next_prime(pint p) +{ + if (p == 2) return 3; + for (p += 2; p > 1 && !is_prime(p); p += 2); + if (p == 1) return 0; + return p; +} + +int is_prime(xint n) +{ +# define NCACHE 256 +# define S (sizeof(uint) * 2) + static uint cache[NCACHE] = {0}; + + pint p = 2; + int ofs, bit = -1; + + if (n < NCACHE * S) { + ofs = n / S; + bit = 1 << ((n & (S - 1)) >> 1); + if (cache[ofs] & bit) return 1; + } + + do { + if (n % p == 0) return 0; + if (p * p > n) break; + } while ((p = next_prime(p))); + + if (bit != -1) cache[ofs] |= bit; + return 1; +} + +int decompose(xint n, pint *out) +{ + int i = 0; + pint p = 2; + while (n > p * p) { + while (n % p == 0) { + out[i++] = p; + n /= p; + } + if (!(p = next_prime(p))) break; + } + if (n > 1) out[i++] = n; + return i; +} + +int main() +{ + int i, j, len; + xint z; + pint out[100]; + for (i = 2; i < 64; i = next_prime(i)) { + z = (1ULL << i) - 1; + printf("2^%d - 1 = %llu = ", i, z); + fflush(stdout); + len = decompose(z, out); + for (j = 0; j < len; j++) + printf("%u%s", out[j], j < len - 1 ? " x " : "\n"); + } + + return 0; +} diff --git a/Task/Prime-decomposition/Clojure/prime-decomposition.clj b/Task/Prime-decomposition/Clojure/prime-decomposition.clj new file mode 100644 index 0000000000..cf27b7b270 --- /dev/null +++ b/Task/Prime-decomposition/Clojure/prime-decomposition.clj @@ -0,0 +1,11 @@ +;;; No stack consuming algorithm +(defn factors + "Return a list of factors of N." + ([n] + (factors n 2 ())) + ([n k acc] + (if (= 1 n) + acc + (if (= 0 (rem n k)) + (recur (quot n k) k (cons k acc)) + (recur n (inc k) acc))))) diff --git a/Task/Prime-decomposition/Common-Lisp/prime-decomposition.lisp b/Task/Prime-decomposition/Common-Lisp/prime-decomposition.lisp new file mode 100644 index 0000000000..b3b6ca260f --- /dev/null +++ b/Task/Prime-decomposition/Common-Lisp/prime-decomposition.lisp @@ -0,0 +1,8 @@ +;;; Recursive algorithm +(defun factor (n) + "Return a list of factors of N." + (when (> n 1) + (loop with max-d = (isqrt n) + for d = 2 then (if (evenp d) (+ d 1) (+ d 2)) do + (cond ((> d max-d) (return (list n))) ; n is prime + ((zerop (rem n d)) (return (cons d (factor (truncate n d))))))))) diff --git a/Task/Prime-decomposition/D/prime-decomposition.d b/Task/Prime-decomposition/D/prime-decomposition.d new file mode 100644 index 0000000000..73b055d288 --- /dev/null +++ b/Task/Prime-decomposition/D/prime-decomposition.d @@ -0,0 +1,37 @@ +import std.traits: Unqual; + +Unqual!T[] decompose(T)(T number) /*pure nothrow*/ +in { + assert(number > 1); +} body { + alias UT = Unqual!T; + typeof(return) result; + UT n = number; + + for (UT i = 2; n % i == 0;) { + result ~= i; + n /= i; + } + for (UT i = 3; n >= i * i; i += 2) { + while (n % i == 0) { + result ~= i; + n /= i; + } + } + + if (n != 1) + result ~= n; + return result; +} + +void main() { + import std.stdio, std.bigint, std.algorithm; + + foreach (immutable n; 2 .. 10) + writeln(decompose(n)); + + writeln(decompose(1023 * 1024)); + writeln(decompose(BigInt(2 * 3 * 5 * 7 * 11 * 11 * 13 * 17))); + writeln(decompose(BigInt(16860167264933UL) * 179951)); + writeln(group(decompose(BigInt(2) ^^ 100_000))); +} diff --git a/Task/Prime-decomposition/E/prime-decomposition.e b/Task/Prime-decomposition/E/prime-decomposition.e new file mode 100644 index 0000000000..d9b816f23f --- /dev/null +++ b/Task/Prime-decomposition/E/prime-decomposition.e @@ -0,0 +1,29 @@ +def primes := { + var primesCache := [2] + /** A collection of all prime numbers. */ + def primes { + to iterate(f) { + primesCache.iterate(f) + for x in (int > primesCache.last()) { + if (isPrime(x)) { + f(primesCache.size(), x) + primesCache with= x + } + } + } + } +} + +def primeDecomposition(var x :(int > 0)) { + var factors := [] + for p in primes { + while (x % p <=> 0) { + factors with= p + x //= p + } + if (x <=> 1) { + break + } + } + return factors +} diff --git a/Task/Prime-decomposition/Erlang/prime-decomposition.erl b/Task/Prime-decomposition/Erlang/prime-decomposition.erl new file mode 100644 index 0000000000..a826a4fb40 --- /dev/null +++ b/Task/Prime-decomposition/Erlang/prime-decomposition.erl @@ -0,0 +1,10 @@ +% no stack consuming version + +factors(N) -> + factors(N,2,[]). + +factors(1,_,Acc) -> Acc; +factors(N,K,Acc) when N rem K == 0 -> + factors(N div K,K, [K|Acc]); +factors(N,K,Acc) -> + factors(N,K+1,Acc). diff --git a/Task/Prime-decomposition/FALSE/prime-decomposition.false b/Task/Prime-decomposition/FALSE/prime-decomposition.false new file mode 100644 index 0000000000..e49bc6513c --- /dev/null +++ b/Task/Prime-decomposition/FALSE/prime-decomposition.false @@ -0,0 +1,2 @@ +[2[\$@$$*@>~][\$@$@$@$@\/*=$[%$." "$@\/\0~]?~[1+1|]?]#%.]d: +27720d;! {2 2 2 3 3 5 7 11} diff --git a/Task/Prime-decomposition/Factor/prime-decomposition.factor b/Task/Prime-decomposition/Factor/prime-decomposition.factor new file mode 100644 index 0000000000..6a6003d13f --- /dev/null +++ b/Task/Prime-decomposition/Factor/prime-decomposition.factor @@ -0,0 +1,5 @@ +USING: io kernel math math.parser math.primes.factors sequences ; + +27720 factors +[ number>string ] map +" " join print ; diff --git a/Task/Prime-decomposition/Forth/prime-decomposition.fth b/Task/Prime-decomposition/Forth/prime-decomposition.fth new file mode 100644 index 0000000000..24c3b347cc --- /dev/null +++ b/Task/Prime-decomposition/Forth/prime-decomposition.fth @@ -0,0 +1,9 @@ +: decomp ( n -- ) + 2 + begin 2dup dup * >= + while 2dup /mod swap + if drop 1+ 1 or \ next odd number + else -rot nip dup . + then + repeat + drop . ; diff --git a/Task/Prime-decomposition/Fortran/prime-decomposition-1.f b/Task/Prime-decomposition/Fortran/prime-decomposition-1.f new file mode 100644 index 0000000000..1779ff4aeb --- /dev/null +++ b/Task/Prime-decomposition/Fortran/prime-decomposition-1.f @@ -0,0 +1,31 @@ +module PrimeDecompose + implicit none + + integer, parameter :: huge = selected_int_kind(18) + ! => integer(8) ... more fails on my 32 bit machine with gfortran(gcc) 4.3.2 + +contains + + subroutine find_factors(n, d) + integer(huge), intent(in) :: n + integer, dimension(:), intent(out) :: d + + integer(huge) :: div, next, rest + integer :: i + + i = 1 + div = 2; next = 3; rest = n + + do while ( rest /= 1 ) + do while ( mod(rest, div) == 0 ) + d(i) = div + i = i + 1 + rest = rest / div + end do + div = next + next = next + 2 + end do + + end subroutine find_factors + +end module PrimeDecompose diff --git a/Task/Prime-decomposition/Fortran/prime-decomposition-2.f b/Task/Prime-decomposition/Fortran/prime-decomposition-2.f new file mode 100644 index 0000000000..053a056684 --- /dev/null +++ b/Task/Prime-decomposition/Fortran/prime-decomposition-2.f @@ -0,0 +1,17 @@ +program Primes + use PrimeDecompose + implicit none + + integer, dimension(100) :: outprimes + integer i + + outprimes = 0 + + call find_factors(12345649494449_huge, outprimes) + + do i = 1, 100 + if ( outprimes(i) == 0 ) exit + print *, outprimes(i) + end do + +end program Primes diff --git a/Task/Prime-decomposition/Frink/prime-decomposition.frink b/Task/Prime-decomposition/Frink/prime-decomposition.frink new file mode 100644 index 0000000000..3f9ab65dbb --- /dev/null +++ b/Task/Prime-decomposition/Frink/prime-decomposition.frink @@ -0,0 +1 @@ +println[factor[2^508-1]] diff --git a/Task/Prime-decomposition/GAP/prime-decomposition-1.gap b/Task/Prime-decomposition/GAP/prime-decomposition-1.gap new file mode 100644 index 0000000000..3263f8c646 --- /dev/null +++ b/Task/Prime-decomposition/GAP/prime-decomposition-1.gap @@ -0,0 +1,2 @@ +FactorsInt(2^67-1); +# [ 193707721, 761838257287 ] diff --git a/Task/Prime-decomposition/GAP/prime-decomposition-2.gap b/Task/Prime-decomposition/GAP/prime-decomposition-2.gap new file mode 100644 index 0000000000..193c67104c --- /dev/null +++ b/Task/Prime-decomposition/GAP/prime-decomposition-2.gap @@ -0,0 +1,2 @@ +FactInt(2^67-1); +# [ [ 193707721, 761838257287 ], [ ] ] diff --git a/Task/Prime-decomposition/Go/prime-decomposition.go b/Task/Prime-decomposition/Go/prime-decomposition.go new file mode 100644 index 0000000000..c9c97d431a --- /dev/null +++ b/Task/Prime-decomposition/Go/prime-decomposition.go @@ -0,0 +1,39 @@ +package main + +import ( + "fmt" + "math/big" +) + +var ( + ZERO = big.NewInt(0) + ONE = big.NewInt(1) +) + +func Primes(n *big.Int) []*big.Int { + res := []*big.Int{} + mod, div := new(big.Int), new(big.Int) + for i := big.NewInt(2); i.Cmp(n) != 1; { + div.DivMod(n, i, mod) + for mod.Cmp(ZERO) == 0 { + res = append(res, new(big.Int).Set(i)) + n.Set(div) + div.DivMod(n, i, mod) + } + i.Add(i, ONE) + } + return res +} + +func main() { + vals := []int64{ + 1 << 31, + 1234567, + 333333, + 987653, + 2 * 3 * 5 * 7 * 11 * 13 * 17, + } + for _, v := range vals { + fmt.Println(v, "->", Primes(big.NewInt(v))) + } +} diff --git a/Task/Prime-decomposition/Groovy/prime-decomposition-1.groovy b/Task/Prime-decomposition/Groovy/prime-decomposition-1.groovy new file mode 100644 index 0000000000..efc2dcccb5 --- /dev/null +++ b/Task/Prime-decomposition/Groovy/prime-decomposition-1.groovy @@ -0,0 +1,29 @@ +def factorize = { long target -> + + if (target == 1) return [1L] + + if (target < 4) return [1L, target] + + def targetSqrt = Math.sqrt(target) + def lowfactors = (2L..targetSqrt).findAll { (target % it) == 0 } + if (lowfactors == []) return [1L, target] + def nhalf = lowfactors.size() - ((lowfactors[-1]**2 == target) ? 1 : 0) + + [1] + lowfactors + (0.. + def factors = factorize(target) - [1] + def primeFactors = [] + factors.eachWithIndex { f, i -> + if (i==0 || factors[0.. 1 = concat [divs n p | p <- [2..n], isPrime p] + where + divs n p = if rem n p==0 then p:divs (quot n p) p else [] diff --git a/Task/Prime-decomposition/Haskell/prime-decomposition-2.hs b/Task/Prime-decomposition/Haskell/prime-decomposition-2.hs new file mode 100644 index 0000000000..d9b52d9cf0 --- /dev/null +++ b/Task/Prime-decomposition/Haskell/prime-decomposition-2.hs @@ -0,0 +1,8 @@ +factorize n | n > 1 = go n primesList + where + go n ds@(d:t) + | d*d > n = [n] + | r == 0 = d : go q ds + | otherwise = go n t + where + (q,r) = quotRem n d diff --git a/Task/Prime-decomposition/Icon/prime-decomposition.icon b/Task/Prime-decomposition/Icon/prime-decomposition.icon new file mode 100644 index 0000000000..8f749c8679 --- /dev/null +++ b/Task/Prime-decomposition/Icon/prime-decomposition.icon @@ -0,0 +1,18 @@ +procedure main() +factors := primedecomp(2^43-1) # a big int +end + +procedure primedecomp(n) #: return a list of factors +local F,o,x +F := [] + +every writes(o,n|(x := genfactors(n))) do { + \o := "*" + /o := "=" + put(F,x) # build a list of factors to satisfy the task + } +write() +return F +end + +link factors diff --git a/Task/Prime-decomposition/J/prime-decomposition-1.j b/Task/Prime-decomposition/J/prime-decomposition-1.j new file mode 100644 index 0000000000..7f74386238 --- /dev/null +++ b/Task/Prime-decomposition/J/prime-decomposition-1.j @@ -0,0 +1 @@ +q: diff --git a/Task/Prime-decomposition/J/prime-decomposition-2.j b/Task/Prime-decomposition/J/prime-decomposition-2.j new file mode 100644 index 0000000000..d3cc242e45 --- /dev/null +++ b/Task/Prime-decomposition/J/prime-decomposition-2.j @@ -0,0 +1,9 @@ +q: 3684 +2 2 3 307 + + _1+2^128x +340282366920938463463374607431768211455 + q: _1+2^128x +3 5 17 257 641 65537 274177 6700417 67280421310721 + */ q: _1+2^128x +340282366920938463463374607431768211455 diff --git a/Task/Prime-decomposition/Java/prime-decomposition-1.java b/Task/Prime-decomposition/Java/prime-decomposition-1.java new file mode 100644 index 0000000000..8cc6fb3479 --- /dev/null +++ b/Task/Prime-decomposition/Java/prime-decomposition-1.java @@ -0,0 +1 @@ +public boolean prime(BigInteger i); diff --git a/Task/Prime-decomposition/Java/prime-decomposition-2.java b/Task/Prime-decomposition/Java/prime-decomposition-2.java new file mode 100644 index 0000000000..f95d9f0f6e --- /dev/null +++ b/Task/Prime-decomposition/Java/prime-decomposition-2.java @@ -0,0 +1,12 @@ +public static List primeFactorBig(BigInteger a){ + List ans = new LinkedList(); + //loop until we test the number itself or the number is 1 + for (BigInteger i = BigInteger.valueOf(2); i.compareTo(a) <= 0 && !a.equals(BigInteger.ONE); + i = i.add(BigInteger.ONE)){ + while (a.remainder(i).equals(BigInteger.ZERO) && prime(i)) { //if we have a prime factor + ans.add(i); //put it in the list + a = a.divide(i); //factor it out of the number + } + } + return ans; +} diff --git a/Task/Prime-decomposition/Java/prime-decomposition-3.java b/Task/Prime-decomposition/Java/prime-decomposition-3.java new file mode 100644 index 0000000000..888737fefd --- /dev/null +++ b/Task/Prime-decomposition/Java/prime-decomposition-3.java @@ -0,0 +1,32 @@ +private static final BigInteger two = BigInteger.valueOf(2); + +public List primeDecomp(BigInteger a) { + // impossible for values lower than 2 + if (a.compareTo(two) < 0) { + return null; + } + + //quickly handle even values + List result = new ArrayList(); + while (a.and(BigInteger.ONE).equals(BigInteger.ZERO)) { + a = a.shiftRight(1); + result.add(two); + } + + //left with odd values + if (!a.equals(BigInteger.ONE)) { + BigInteger b = BigInteger.valueOf(3); + while (b.compareTo(a) < 0) { + if (b.isProbablePrime(10)) { + BigInteger[] dr = a.divideAndRemainder(b); + if (dr[1].equals(BigInteger.ZERO)) { + result.add(b); + a = dr[0]; + } + } + b = b.add(two); + } + result.add(b); //b will always be prime here... + } + return result; +} diff --git a/Task/Prime-decomposition/Java/prime-decomposition-4.java b/Task/Prime-decomposition/Java/prime-decomposition-4.java new file mode 100644 index 0000000000..cdf91616f3 --- /dev/null +++ b/Task/Prime-decomposition/Java/prime-decomposition-4.java @@ -0,0 +1,11 @@ +public static List primeFactorBig(BigInteger a){ + List ans = new LinkedList(); + + for(BigInteger divisor = BigInteger.valueOf(2); + a.compareTo(ONE) > 0; divisor = divisor.add(ONE)) + while(a.mod(divisor).equals(ZERO)){ + ans.add(divisor); + a = a.divide(divisor); + } + return ans; +} diff --git a/Task/Prime-decomposition/JavaScript/prime-decomposition-1.js b/Task/Prime-decomposition/JavaScript/prime-decomposition-1.js new file mode 100644 index 0000000000..7e886768da --- /dev/null +++ b/Task/Prime-decomposition/JavaScript/prime-decomposition-1.js @@ -0,0 +1,39 @@ +function run_factorize(input, output) { + var n = new BigInteger(input.value, 10); + var TWO = new BigInteger("2", 10); + var divisor = new BigInteger("3", 10); + var prod = false; + + if (n.compareTo(TWO) < 0) + return; + + output.value = ""; + + while (true) { + var qr = n.divideAndRemainder(TWO); + if (qr[1].equals(BigInteger.ZERO)) { + if (prod) + output.value += "*"; + else + prod = true; + output.value += "2"; + n = qr[0]; + } + else + break; + } + + while (!n.equals(BigInteger.ONE)) { + var qr = n.divideAndRemainder(divisor); + if (qr[1].equals(BigInteger.ZERO)) { + if (prod) + output.value += "*"; + else + prod = true; + output.value += divisor; + n = qr[0]; + } + else + divisor = divisor.add(TWO); + } +} diff --git a/Task/Prime-decomposition/JavaScript/prime-decomposition-2.js b/Task/Prime-decomposition/JavaScript/prime-decomposition-2.js new file mode 100644 index 0000000000..34d9b8792d --- /dev/null +++ b/Task/Prime-decomposition/JavaScript/prime-decomposition-2.js @@ -0,0 +1,41 @@ +function run_factorize(n) { + if (n <= 3) + return [n]; + + var ans = []; + var done = false; + while (!done) + { + if (n%2 === 0){ + ans.push(2); + n /= 2; + continue; + } + if (n%3 === 0){ + ans.push(3); + n /= 3; + continue; + } + if ( n === 1) + return ans; + var sr = Math.sqrt(n); + done = true; + // try to divide the checked number by all numbers till its square root. + for (var i=6; i<=sr; i+=6){ + if (n%(i-1) === 0){ // is n divisible by i-1? + ans.push( (i-1) ); + n /= (i-1); + done = false; + break; + } + if (n%(i+1) === 0){ // is n divisible by i+1? + ans.push( (i+1) ); + n /= (i+1); + done = false; + break; + } + } + } + ans.push( n ); + return ans; +} diff --git a/Task/Prime-decomposition/Logo/prime-decomposition.logo b/Task/Prime-decomposition/Logo/prime-decomposition.logo new file mode 100644 index 0000000000..1225dee84f --- /dev/null +++ b/Task/Prime-decomposition/Logo/prime-decomposition.logo @@ -0,0 +1,5 @@ +to decompose :n [:p 2] + if :p*:p > :n [output (list :n)] + if less? 0 modulo :n :p [output (decompose :n bitor 1 :p+1)] + output fput :p (decompose :n/:p :p) +end diff --git a/Task/Prime-decomposition/Lua/prime-decomposition.lua b/Task/Prime-decomposition/Lua/prime-decomposition.lua new file mode 100644 index 0000000000..9082637110 --- /dev/null +++ b/Task/Prime-decomposition/Lua/prime-decomposition.lua @@ -0,0 +1,22 @@ +function PrimeDecomposition( n ) + local f = {} + + if IsPrime( n ) then + f[1] = n + return f + end + + local i = 2 + repeat + while n % i == 0 do + f[#f+1] = i + n = n / i + end + + repeat + i = i + 1 + until IsPrime( i ) + until n == 1 + + return f +end diff --git a/Task/Prime-decomposition/MATLAB/prime-decomposition.m b/Task/Prime-decomposition/MATLAB/prime-decomposition.m new file mode 100644 index 0000000000..c84dd82dab --- /dev/null +++ b/Task/Prime-decomposition/MATLAB/prime-decomposition.m @@ -0,0 +1,2 @@ +function [outputPrimeDecomposition] = primedecomposition(inputValue) + outputPrimeDecomposition = factor(inputValue); diff --git a/Task/Prime-decomposition/MUMPS/prime-decomposition.mumps b/Task/Prime-decomposition/MUMPS/prime-decomposition.mumps new file mode 100644 index 0000000000..40b4b36929 --- /dev/null +++ b/Task/Prime-decomposition/MUMPS/prime-decomposition.mumps @@ -0,0 +1,22 @@ +ERATO1(HI) + SET HI=HI\1 + KILL ERATO1 ;Don't make it new - we want it to remain after the quit + NEW I,J,P + FOR I=2:1:(HI**.5)\1 DO + .FOR J=I*I:I:HI DO + ..SET P(J)=1 ;$SELECT($DATA(P(J))#10:P(J)+1,1:1) + ;WRITE !,"Prime numbers between 2 and ",HI,": " + FOR I=2:1:HI DO + .S:'$DATA(P(I)) ERATO1(I)=I ;WRITE $SELECT((I<3):"",1:", "),I + KILL I,J,P + QUIT +PRIMDECO(N) + ;Returns its results in the string PRIMDECO + ;Kill that before the first call to this recursive function + QUIT:N<=1 + IF $D(PRIMDECO)=1 SET PRIMDECO="" D ERATO1(N) + SET N=N\1,I=0 + FOR SET I=$O(ERATO1(I)) Q:+I<1 Q:'(N#I) + IF I>1 SET PRIMDECO=$S($L(PRIMDECO)>0:PRIMDECO_"^",1:"")_I D PRIMDECO(N/I) + ;that is, if I is a factor of N, add it to the string + QUIT diff --git a/Task/Prime-decomposition/Mathematica/prime-decomposition-1.math b/Task/Prime-decomposition/Mathematica/prime-decomposition-1.math new file mode 100644 index 0000000000..4e5a230d1d --- /dev/null +++ b/Task/Prime-decomposition/Mathematica/prime-decomposition-1.math @@ -0,0 +1 @@ + FactorInteger[2016] => {{2, 5}, {3, 2}, {7, 1}} diff --git a/Task/Prime-decomposition/Mathematica/prime-decomposition-2.math b/Task/Prime-decomposition/Mathematica/prime-decomposition-2.math new file mode 100644 index 0000000000..5923421ca1 --- /dev/null +++ b/Task/Prime-decomposition/Mathematica/prime-decomposition-2.math @@ -0,0 +1,2 @@ +supscript[x_,y_]:=If[y==1,x,Superscript[x,y]] +ShowPrimeDecomposition[input_Integer]:=Print@@{input," = ",Sequence@@Riffle[supscript@@@FactorInteger[input]," "]} diff --git a/Task/Prime-decomposition/Mathematica/prime-decomposition-3.math b/Task/Prime-decomposition/Mathematica/prime-decomposition-3.math new file mode 100644 index 0000000000..c585971461 --- /dev/null +++ b/Task/Prime-decomposition/Mathematica/prime-decomposition-3.math @@ -0,0 +1 @@ + ShowPrimeDecomposition[1337] diff --git a/Task/Prime-decomposition/Mathematica/prime-decomposition-4.math b/Task/Prime-decomposition/Mathematica/prime-decomposition-4.math new file mode 100644 index 0000000000..24041a598f --- /dev/null +++ b/Task/Prime-decomposition/Mathematica/prime-decomposition-4.math @@ -0,0 +1 @@ + 1337 = 7 191 diff --git a/Task/Prime-decomposition/Mathematica/prime-decomposition-5.math b/Task/Prime-decomposition/Mathematica/prime-decomposition-5.math new file mode 100644 index 0000000000..8f3e8d23a0 --- /dev/null +++ b/Task/Prime-decomposition/Mathematica/prime-decomposition-5.math @@ -0,0 +1 @@ + Table[AbsoluteTiming[ShowPrimeDecomposition[2^a-1]]//Print[#[[1]]," sec"]&,{a,50,150,10}]; diff --git a/Task/Prime-decomposition/Mathematica/prime-decomposition-6.math b/Task/Prime-decomposition/Mathematica/prime-decomposition-6.math new file mode 100644 index 0000000000..67cb2045eb --- /dev/null +++ b/Task/Prime-decomposition/Mathematica/prime-decomposition-6.math @@ -0,0 +1,22 @@ +1125899906842623 = 3 11 31 251 601 1801 4051 +0.000231 sec +1152921504606846975 = 3^2 5^2 7 11 13 31 41 61 151 331 1321 +0.000146 sec +1180591620717411303423 = 3 11 31 43 71 127 281 86171 122921 +0.001008 sec +1208925819614629174706175 = 3 5^2 11 17 31 41 257 61681 4278255361 +0.000340 sec +1237940039285380274899124223 = 3^3 7 11 19 31 73 151 331 631 23311 18837001 +0.000192 sec +1267650600228229401496703205375 = 3 5^3 11 31 41 101 251 601 1801 4051 8101 268501 +0.000156 sec +1298074214633706907132624082305023 = 3 11^2 23 31 89 683 881 2971 3191 201961 48912491 +0.001389 sec +1329227995784915872903807060280344575 = 3^2 5^2 7 11 13 17 31 41 61 151 241 331 1321 61681 4562284561 +0.000374 sec +1361129467683753853853498429727072845823 = 3 11 31 131 2731 8191 409891 7623851 145295143558111 +0.024249 sec +1393796574908163946345982392040522594123775 = 3 5^2 11 29 31 41 43 71 113 127 281 86171 122921 7416361 47392381 +0.009419 sec +1427247692705959881058285969449495136382746623 = 3^2 7 11 31 151 251 331 601 1801 4051 100801 10567201 1133836730401 +0.007705 sec diff --git a/Task/Prime-decomposition/Maxima/prime-decomposition-1.maxima b/Task/Prime-decomposition/Maxima/prime-decomposition-1.maxima new file mode 100644 index 0000000000..dd1731d1dd --- /dev/null +++ b/Task/Prime-decomposition/Maxima/prime-decomposition-1.maxima @@ -0,0 +1,3 @@ +(%i1) display2d: false$ /* disable rendering exponents as superscripts */ +(%i2) factor(2016); +(%o2) 2^5*3^2*7 diff --git a/Task/Prime-decomposition/Maxima/prime-decomposition-2.maxima b/Task/Prime-decomposition/Maxima/prime-decomposition-2.maxima new file mode 100644 index 0000000000..5b76e2edd6 --- /dev/null +++ b/Task/Prime-decomposition/Maxima/prime-decomposition-2.maxima @@ -0,0 +1,7 @@ +prime_dec(n) := apply(append, create_list(makelist(a[1], a[2]), a, ifactors(n)))$ + +/* or, slighlty more "functional" */ +prime_dec(n) := apply(append, map(lambda([a], apply(makelist, a)), ifactors(n)))$ + +prime_dec(2^4*3^5*5*7^2); +/* [2, 2, 2, 2, 3, 3, 3, 3, 3, 5, 7, 7] */ diff --git a/Task/Prime-decomposition/OCaml/prime-decomposition.ocaml b/Task/Prime-decomposition/OCaml/prime-decomposition.ocaml new file mode 100644 index 0000000000..d1455ec25e --- /dev/null +++ b/Task/Prime-decomposition/OCaml/prime-decomposition.ocaml @@ -0,0 +1,12 @@ +open Big_int;; + +let prime_decomposition x = + let rec inner c p = + if lt_big_int p (square_big_int c) then + [p] + else if eq_big_int (mod_big_int p c) zero_big_int then + c :: inner c (div_big_int p c) + else + inner (succ_big_int c) p + in + inner (succ_big_int (succ_big_int zero_big_int)) x;; diff --git a/Task/Prime-decomposition/Octave/prime-decomposition.octave b/Task/Prime-decomposition/Octave/prime-decomposition.octave new file mode 100644 index 0000000000..6429d1f3ec --- /dev/null +++ b/Task/Prime-decomposition/Octave/prime-decomposition.octave @@ -0,0 +1 @@ +r = factor(120202039393) diff --git a/Task/Prime-decomposition/PARI-GP/prime-decomposition.pari b/Task/Prime-decomposition/PARI-GP/prime-decomposition.pari new file mode 100644 index 0000000000..5bd5ebb26d --- /dev/null +++ b/Task/Prime-decomposition/PARI-GP/prime-decomposition.pari @@ -0,0 +1,9 @@ +pd(n)={ + my(f=factor(n),v=f[,1]~); + for(i=1,#v, + while(f[i,2]--, + v=concat(v,f[i,1]) + ) + ); + vecsort(v) +}; diff --git a/Task/Prime-decomposition/PL-I/prime-decomposition.pli b/Task/Prime-decomposition/PL-I/prime-decomposition.pli new file mode 100644 index 0000000000..a7b3dc6fe7 --- /dev/null +++ b/Task/Prime-decomposition/PL-I/prime-decomposition.pli @@ -0,0 +1,41 @@ +test: procedure options (main, reorder); + declare (n, i) fixed binary (31); + + get list (n); + + put edit ( n, '[' ) (x(1), a); + +restart: + if is_prime(n) then + do; + put edit (trim(n), ']' ) (x(1), a); + stop; + end; + + do i = n/2 to 2 by -1; + if is_prime(i) then + if (mod(n, i) = 0) then + do; + put edit ( trim(i) ) (x(1), a); + n = n / i; + go to restart; + end; + end; + put edit ( ' ]' ) (a); + + +is_prime: procedure (n) options (reorder) returns (bit(1)); + declare n fixed binary (31); + declare i fixed binary (31); + + if n < 2 then return ('0'b); + if n = 2 then return ('1'b); + if mod(n, 2) = 0 then return ('0'b); + + do i = 3 to sqrt(n) by 2; + if mod(n, i) = 0 then return ('0'b); + end; + return ('1'b); +end is_prime; + +end test; diff --git a/Task/Prime-decomposition/Pascal/prime-decomposition.pascal b/Task/Prime-decomposition/Pascal/prime-decomposition.pascal new file mode 100644 index 0000000000..6ec2406e78 --- /dev/null +++ b/Task/Prime-decomposition/Pascal/prime-decomposition.pascal @@ -0,0 +1,38 @@ +Program PrimeDecomposition(output); + +type + DynArray = array of integer; + +procedure findFactors(n: Int64; var d: DynArray); + var + divisor, next, rest: Int64; + i: integer; + begin + i := 0; + divisor := 2; + next := 3; + rest := n; + while (rest <> 1) do + begin + while (rest mod divisor = 0) do + begin + setlength(d, i+1); + d[i] := divisor; + inc(i); + rest := rest div divisor; + end; + divisor := next; + next := next + 2; + end; + end; + +var + factors: DynArray; + j: integer; + +begin + setlength(factors, 1); + findFactors(1023*1024, factors); + for j := low(factors) to high(factors) do + writeln (factors[j]); +end. diff --git a/Task/Prime-decomposition/Perl-6/prime-decomposition.pl6 b/Task/Prime-decomposition/Perl-6/prime-decomposition.pl6 new file mode 100644 index 0000000000..5619de2d9b --- /dev/null +++ b/Task/Prime-decomposition/Perl-6/prime-decomposition.pl6 @@ -0,0 +1,22 @@ +constant @primes = 2, 3, 5, -> $n is copy { + repeat { $n += 2 } until $n %% none @primes ... { $_ * $_ >= $n } + $n; +} ... *; + +sub factors(Int $remainder is copy) { + return 1 if $remainder <= 1; + gather for @primes -> $factor { + if $factor * $factor > $remainder { + take $remainder if $remainder > 1; + last; + } + + # How many times can we divide by this prime? + while $remainder %% $factor { + take $factor; + last if ($remainder div= $factor) === 1; + } + } +} + +say factors 536870911; diff --git a/Task/Prime-decomposition/Perl/prime-decomposition.pl b/Task/Prime-decomposition/Perl/prime-decomposition.pl new file mode 100644 index 0000000000..c4956eadc1 --- /dev/null +++ b/Task/Prime-decomposition/Perl/prime-decomposition.pl @@ -0,0 +1,9 @@ +sub prime_factors { + my ($n, $d, @out) = (shift, 1); + while ($n > 1 && $d++) { + $n /= $d, push @out, $d until $n % $d; + } + @out +} + +print "@{[prime_factors(1001)]}\n"; diff --git a/Task/Prime-decomposition/PicoLisp/prime-decomposition.l b/Task/Prime-decomposition/PicoLisp/prime-decomposition.l new file mode 100644 index 0000000000..d898d95b49 --- /dev/null +++ b/Task/Prime-decomposition/PicoLisp/prime-decomposition.l @@ -0,0 +1,10 @@ +(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) ) ) ) + +(factor 1361129467683753853853498429727072845823) diff --git a/Task/Prime-decomposition/Prolog/prime-decomposition-1.pro b/Task/Prime-decomposition/Prolog/prime-decomposition-1.pro new file mode 100644 index 0000000000..0d1bd2ea44 --- /dev/null +++ b/Task/Prime-decomposition/Prolog/prime-decomposition-1.pro @@ -0,0 +1,37 @@ +prime_decomp(N, L) :- + SN is sqrt(N), + prime_decomp_1(N, SN, 2, [], L). + + +prime_decomp_1(1, _, _, L, L) :- !. + +% Special case for 2, increment 1 +prime_decomp_1(N, SN, D, L, LF) :- + ( 0 is N mod D -> + Q is N / D, + SQ is sqrt(Q), + prime_decomp_1(Q, SQ, D, [D |L], LF) + ; + D1 is D+1, + ( D1 > SN -> + LF = [N |L] + ; + prime_decomp_2(N, SN, D1, L, LF) + ) + ). + +% General case, increment 2 +prime_decomp_2(1, _, _, L, L) :- !. + +prime_decomp_2(N, SN, D, L, LF) :- + ( 0 is N mod D -> + Q is N / D, + SQ is sqrt(Q), + prime_decomp_2(Q, SQ, D, [D |L], LF); + D1 is D+2, + ( D1 > SN -> + LF = [N |L] + ; + prime_decomp_2(N, SN, D1, L, LF) + ) + ). diff --git a/Task/Prime-decomposition/Prolog/prime-decomposition-2.pro b/Task/Prime-decomposition/Prolog/prime-decomposition-2.pro new file mode 100644 index 0000000000..12df430015 --- /dev/null +++ b/Task/Prime-decomposition/Prolog/prime-decomposition-2.pro @@ -0,0 +1,11 @@ + ?- time(prime_decomp(9007199254740991, L)). +% 138,882 inferences, 0.344 CPU in 0.357 seconds (96% CPU, 404020 Lips) +L = [20394401,69431,6361]. + + ?- time(prime_decomp(576460752303423487, L)). +% 2,684,734 inferences, 0.672 CPU in 0.671 seconds (100% CPU, 3995883 Lips) +L = [3203431780337,179951]. + + ?- time(prime_decomp(1361129467683753853853498429727072845823, L)). +% 18,080,807 inferences, 7.953 CPU in 7.973 seconds (100% CPU, 2273422 Lips) +L = [145295143558111,7623851,409891,8191,2731,131,31,11,3]. diff --git a/Task/Prime-decomposition/Pure/prime-decomposition.pure b/Task/Prime-decomposition/Pure/prime-decomposition.pure new file mode 100644 index 0000000000..568e251730 --- /dev/null +++ b/Task/Prime-decomposition/Pure/prime-decomposition.pure @@ -0,0 +1,6 @@ +factor n = factor 2 n with + factor k n = k : factor k (n div k) if n mod k == 0; + = if n>1 then [n] else [] if k*k>n; + = factor (k+1) n if k==2; + = factor (k+2) n otherwise; +end; diff --git a/Task/Prime-decomposition/PureBasic/prime-decomposition.purebasic b/Task/Prime-decomposition/PureBasic/prime-decomposition.purebasic new file mode 100644 index 0000000000..b4d7aa14d2 --- /dev/null +++ b/Task/Prime-decomposition/PureBasic/prime-decomposition.purebasic @@ -0,0 +1,34 @@ +CompilerIf #PB_Compiler_Debugger + CompilerError "Turn off the debugger if you want reasonable speed in this example." +CompilerEndIf + +Define.q + +Procedure Factor(Number, List Factors()) + Protected I = 3 + While Number % 2 = 0 + AddElement(Factors()) + Factors() = 2 + Number / 2 + Wend + Protected Max = Number + While I <= Max And Number > 1 + While Number % I = 0 + AddElement(Factors()) + Factors() = I + Number/I + Wend + I + 2 + Wend +EndProcedure + +Number = 9007199254740991 +NewList Factors() +time = ElapsedMilliseconds() +Factor(Number, Factors()) +time = ElapsedMilliseconds()-time +S.s = "Factored " + Str(Number) + " in " + StrD(time/1000, 2) + " seconds." +ForEach Factors() + S + #CRLF$ + Str(Factors()) +Next +MessageRequester("", S) diff --git a/Task/Prime-decomposition/Python/prime-decomposition-1.py b/Task/Prime-decomposition/Python/prime-decomposition-1.py new file mode 100644 index 0000000000..35811fa0a7 --- /dev/null +++ b/Task/Prime-decomposition/Python/prime-decomposition-1.py @@ -0,0 +1,47 @@ +import sys + +def is_prime(n): + return zip((True, False), decompose(n))[-1][0] + +class IsPrimeCached(dict): + def __missing__(self, n): + r = is_prime(n) + self[n] = r + return r + +is_prime_cached = IsPrimeCached() + +def primes(): + yield 2 + n = 3 + while n < sys.maxint - 2: + yield n + n += 2 + while n < sys.maxint - 2 and not is_prime_cached[n]: + n += 2 + +def decompose(n): + for p in primes(): + if p*p > n: break + while n % p == 0: + yield p + n /=p + if n > 1: + yield n + +if __name__ == '__main__': + # Example: calculate factors of Mersenne numbers to M59 # + + import time + + for m in primes(): + p = 2 ** m - 1 + print( "2**{0:d}-1 = {0:d}, with factors:".format(m, p) ) + start = time.time() + for factor in decompose(p): + print factor, + sys.stdout.flush() + + print( "=> {0:.2f}s".format( time.time()-start ) ) + if m >= 59: + break diff --git a/Task/Prime-decomposition/Python/prime-decomposition-2.py b/Task/Prime-decomposition/Python/prime-decomposition-2.py new file mode 100644 index 0000000000..f714b346e2 --- /dev/null +++ b/Task/Prime-decomposition/Python/prime-decomposition-2.py @@ -0,0 +1,18 @@ +primelist = [2,3] +def is_prime(n): + for y in primes(): + if not n % y: return False + if n > y * y: return True + +def primes(): + for n in primelist: yield n + + n = primelist[-1] + 2 + while True: + n += 2 + for x in primelist: + if not n % x: break + if x * x > n: + primelist.append(n) + yield n + break diff --git a/Task/Prime-decomposition/Python/prime-decomposition-3.py b/Task/Prime-decomposition/Python/prime-decomposition-3.py new file mode 100644 index 0000000000..d91a529cb5 --- /dev/null +++ b/Task/Prime-decomposition/Python/prime-decomposition-3.py @@ -0,0 +1,21 @@ +def fac(n): + step = lambda x: 1 + x*4 - (x/2)*2 + maxq = long(math.floor(math.sqrt(n))) + d = 1 + q = n % 2 == 0 and 2 or 3 + while q <= maxq and n % q != 0: + q = step(d) + d += 1 + res = [] + if q <= maxq: + res.extend(fac(n//q)) + res.extend(fac(q)) + else: res=[n] + return res + +if __name__ == '__main__': + import time + start = time.time() + tocalc = 2**59-1 + print "%s = %s" % (tocalc, fac(tocalc)) + print "Needed %ss" % (time.time() - start) diff --git a/Task/Prime-decomposition/R/prime-decomposition.r b/Task/Prime-decomposition/R/prime-decomposition.r new file mode 100644 index 0000000000..60bafc131b --- /dev/null +++ b/Task/Prime-decomposition/R/prime-decomposition.r @@ -0,0 +1,15 @@ +findfactors <- function(n) { + d <- c() + div <- 2; nxt <- 3; rest <- n + while( rest != 1 ) { + while( rest%%div == 0 ) { + d <- c(d, div) + rest <- floor(rest / div) + } + div <- nxt + nxt <- nxt + 2 + } + d +} + +print(findfactors(1005025)) diff --git a/Task/Prime-decomposition/REXX/prime-decomposition.rexx b/Task/Prime-decomposition/REXX/prime-decomposition.rexx new file mode 100644 index 0000000000..a6da45dd63 --- /dev/null +++ b/Task/Prime-decomposition/REXX/prime-decomposition.rexx @@ -0,0 +1,32 @@ +/*REXX program fins the prime factors of a (or some) positive integer(s)*/ +numeric digits 100 /*bump up precision of the nums. */ +parse arg low high . /*get the argument(s). */ +if low=='' then low=1 /*no LOW? Then make one up. */ +if high=='' then high=low /*no HIGH? Then make one up. */ +w=length(high) /*get max width for pretty tell. */ + do n=low to high /*process single number | a range*/ + say right(n,w) 'prime factors =' factr(n) + end /*n*/ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────FACTR subroutine────────────────────*/ +factr: procedure; parse arg x 1 z,,list /*sets X&Z to arg1, LIST to null*/ +if x <1 then return '' /*Too small? Then return null.*/ +if x==1 then return 1 /*special case for unity. */ + + do j=2 to 5; if j\==4 then call buildF; end /*fast builds for list.*/ +j=5 /*start were we left off (J=5). */ + 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 /*num. reduced to a small number?*/ + 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 return strip(list) /*if residual=unity, don't append*/ + return strip(list z) /*return list, append residual. */ +/*──────────────────────────────────BUILDF subroutine───────────────────*/ +buildF: do forever /*keep dividing until it hurts. */ + if z//j\==0 then return /*can't divide any more? */ + list=list j /*add number to the list (J). */ + z=z%j /*do an integer divide. */ + end /*forever*/ diff --git a/Task/Prime-decomposition/Ruby/prime-decomposition-1.rb b/Task/Prime-decomposition/Ruby/prime-decomposition-1.rb new file mode 100644 index 0000000000..c36ea2bd34 --- /dev/null +++ b/Task/Prime-decomposition/Ruby/prime-decomposition-1.rb @@ -0,0 +1,4 @@ +irb(main):001:0> require 'mathn' +=> true +irb(main):002:0> 2131447995319.prime_division +=> [[701, 1], [1123, 2], [2411, 1]] diff --git a/Task/Prime-decomposition/Ruby/prime-decomposition-2.rb b/Task/Prime-decomposition/Ruby/prime-decomposition-2.rb new file mode 100644 index 0000000000..df4329b2a5 --- /dev/null +++ b/Task/Prime-decomposition/Ruby/prime-decomposition-2.rb @@ -0,0 +1,4 @@ +irb(main):001:0> require 'prime' +=> true +irb(main):003:0> 2543821448263974486045199.prime_division +=> [[701, 1], [1123, 2], [2411, 1], [1092461, 2]] diff --git a/Task/Prime-decomposition/Ruby/prime-decomposition-3.rb b/Task/Prime-decomposition/Ruby/prime-decomposition-3.rb new file mode 100644 index 0000000000..ce41018e80 --- /dev/null +++ b/Task/Prime-decomposition/Ruby/prime-decomposition-3.rb @@ -0,0 +1,13 @@ +# Get prime decomposition of integer _i_. +# This routine is terribly inefficient, but elegance rules. +def prime_factors(i) + v = (2..i-1).detect{|j| i % j == 0} + v ? ([v] + prime_factors(i/v)) : [i] +end + +# Example: Decompose all possible Mersenne primes up to 2**31-1. +# This may take several minutes to show that 2**31-1 is prime. +(2..31).each do |i| + factors = prime_factors(2**i-1) + puts "2**#{i}-1 = #{2**i-1} = #{factors.join(' * ')}" +end diff --git a/Task/Prime-decomposition/Ruby/prime-decomposition-4.rb b/Task/Prime-decomposition/Ruby/prime-decomposition-4.rb new file mode 100644 index 0000000000..d4eef1c138 --- /dev/null +++ b/Task/Prime-decomposition/Ruby/prime-decomposition-4.rb @@ -0,0 +1,32 @@ +# Get prime decomposition of integer _i_. +# This routine is more efficient than prime_factors, +# and quite similar to Integer#prime_division of MRI 1.9. +def prime_factors_faster(i) + factors = [] + check = proc do |p| + while(q, r = i.divmod(p) + r.zero?) + factors << p + i = q + end + end + check[2] + check[3] + p = 5 + while p * p <= i + check[p] + p += 2 + check[p] + p += 4 # skip multiples of 2 and 3 + end + factors << i if i > 1 + factors +end + +# Example: Decompose all possible Mersenne primes up to 2**70-1. +# This may take several minutes to show that 2**61-1 is prime, +# but 2**62-1 and 2**67-1 are not prime. +(2..70).each do |i| + factors = prime_factors_faster(2**i-1) + puts "2**#{i}-1 = #{2**i-1} = #{factors.join(' * ')}" +end diff --git a/Task/Prime-decomposition/Ruby/prime-decomposition-5.rb b/Task/Prime-decomposition/Ruby/prime-decomposition-5.rb new file mode 100644 index 0000000000..edf0dedb33 --- /dev/null +++ b/Task/Prime-decomposition/Ruby/prime-decomposition-5.rb @@ -0,0 +1,10 @@ +require 'benchmark' +require 'mathn' +Benchmark.bm(24) do |x| + [2**25 - 6, 2**35 - 7].each do |i| + puts "#{i} = #{prime_factors_faster(i).join(' * ')}" + x.report(" prime_factors") { prime_factors(i) } + x.report(" prime_factors_faster") { prime_factors_faster(i) } + x.report(" Integer#prime_division") { i.prime_division } + end +end diff --git a/Task/Prime-decomposition/Scala/prime-decomposition-1.scala b/Task/Prime-decomposition/Scala/prime-decomposition-1.scala new file mode 100644 index 0000000000..76e4761b17 --- /dev/null +++ b/Task/Prime-decomposition/Scala/prime-decomposition-1.scala @@ -0,0 +1,33 @@ +class PrimeFactors(n: BigInt) extends Iterator[BigInt] { + val zero = BigInt(0) + val one = BigInt(1) + val two = BigInt(2) + def isPrime(n: BigInt) = n.isProbablePrime(10) + var currentN = n + var prime = two + + def nextPrime = + if (prime == two) { + prime += one + } else { + prime += two + while (!isPrime(prime)) { + prime += two + if (prime * prime > currentN) + prime = currentN + } + } + + def next = { + if (!hasNext) + throw new NoSuchElementException("next on empty iterator") + + while(currentN % prime != zero) { + nextPrime + } + currentN /= prime + prime + } + + def hasNext = currentN != one && currentN > zero +} diff --git a/Task/Prime-decomposition/Scala/prime-decomposition-2.scala b/Task/Prime-decomposition/Scala/prime-decomposition-2.scala new file mode 100644 index 0000000000..10860fb0f0 --- /dev/null +++ b/Task/Prime-decomposition/Scala/prime-decomposition-2.scala @@ -0,0 +1,25 @@ +class PrimeFactors[N](n: N)(implicit num: Integral[N]) extends Iterator[N] { + import num._ + val two = one + one + var currentN = n + var divisor = two + + def next = { + if (!hasNext) + throw new NoSuchElementException("next on empty iterator") + + while(currentN % divisor != zero) { + if (divisor == two) + divisor += one + else + divisor += two + + if (divisor * divisor > currentN) + divisor = currentN + } + currentN /= divisor + divisor + } + + def hasNext = currentN != one && currentN > zero +} diff --git a/Task/Prime-decomposition/Scala/prime-decomposition-3.scala b/Task/Prime-decomposition/Scala/prime-decomposition-3.scala new file mode 100644 index 0000000000..a7b089e881 --- /dev/null +++ b/Task/Prime-decomposition/Scala/prime-decomposition-3.scala @@ -0,0 +1,18 @@ +import scala.math.BigInt + +def primeStream(s: Stream[Int]): Stream[Int] = { + Stream.cons(s.head, primeStream(s.tail filter { _ % s.head != 0 })) +} + +// An infinite stream of primes +val primes = primeStream(Stream.from(2)) + + +def primeFactor(n:BigInt) = { primes.takeWhile(_ <= n).find(i => n % i == 0) } + +def decompose( n : BigInt ) : List[BigInt] = { + primeFactor(n) match { + case Some(a) => a.toInt :: decompose(n/a) + case None => Nil + } +} diff --git a/Task/Prime-decomposition/Scala/prime-decomposition-4.scala b/Task/Prime-decomposition/Scala/prime-decomposition-4.scala new file mode 100644 index 0000000000..459c6411ac --- /dev/null +++ b/Task/Prime-decomposition/Scala/prime-decomposition-4.scala @@ -0,0 +1,11 @@ +// A test +decompose(423) // Results: List(3,3,47) +decompose(423).product // Results: 423 + +// A BigInt test +decompose(BigInt("2535301200456458802993406410752")) + // Results: a list of (2)s +decompose(BigInt("2535301200456458802993406410752")).length + // Results: 101 +decompose(BigInt("2535301200456458802993406410752")).product + // Results: 2535301200456458802993406410752 diff --git a/Task/Prime-decomposition/Scheme/prime-decomposition.ss b/Task/Prime-decomposition/Scheme/prime-decomposition.ss new file mode 100644 index 0000000000..eba8fbde8c --- /dev/null +++ b/Task/Prime-decomposition/Scheme/prime-decomposition.ss @@ -0,0 +1,11 @@ +(define (factor number) + (define (*factor divisor number) + (if (> (* divisor divisor) number) + (list number) + (if (= (modulo number divisor) 0) + (cons divisor (*factor divisor (/ number divisor))) + (*factor (+ divisor 1) number)))) + (*factor 2 number)) + +(display (factor 111111111111)) +(newline) diff --git a/Task/Prime-decomposition/Seed7/prime-decomposition.seed7 b/Task/Prime-decomposition/Seed7/prime-decomposition.seed7 new file mode 100644 index 0000000000..27529b5225 --- /dev/null +++ b/Task/Prime-decomposition/Seed7/prime-decomposition.seed7 @@ -0,0 +1,18 @@ +const func array integer: factorise (in var integer: number) is func + result + var array integer: result is 0 times 0; + local + var integer: checker is 2; + begin + while checker * checker <= number do + if number rem checker = 0 then + result &:= [](checker); + number := number div checker; + else + incr(checker); + end if; + end while; + if number <> 1 then + result &:= [](number); + end if; + end func; diff --git a/Task/Prime-decomposition/Slate/prime-decomposition.slate b/Task/Prime-decomposition/Slate/prime-decomposition.slate new file mode 100644 index 0000000000..0c68dce72d --- /dev/null +++ b/Task/Prime-decomposition/Slate/prime-decomposition.slate @@ -0,0 +1,15 @@ +n@(Integer traits) primesDo: block +"Decomposes the Integer into primes, applying the block to each (in increasing +order)." +[| div next remaining | + div: 2. + next: 3. + remaining: n. + [[(remaining \\ div) isZero] + whileTrue: + [block applyTo: {div}. + remaining: remaining // div]. + remaining = 1] whileFalse: + [div: next. + next: next + 2] "Just look at the next odd integer." +]. diff --git a/Task/Prime-decomposition/Smalltalk/prime-decomposition.st b/Task/Prime-decomposition/Smalltalk/prime-decomposition.st new file mode 100644 index 0000000000..6f11b5ef27 --- /dev/null +++ b/Task/Prime-decomposition/Smalltalk/prime-decomposition.st @@ -0,0 +1,14 @@ +Integer extend [ + primesDo: aBlock [ + | div next rest | + div := 2. next := 3. + rest := self. + [ [ rest \\ div == 0 ] + whileTrue: [ + aBlock value: div. + rest := rest // div ]. + rest = 1] whileFalse: [ + div := next. next := next + 2 ] + ] +] +123456 primesDo: [ :each | each printNl ] diff --git a/Task/Prime-decomposition/TXR/prime-decomposition.txr b/Task/Prime-decomposition/TXR/prime-decomposition.txr new file mode 100644 index 0000000000..478b40d3b4 --- /dev/null +++ b/Task/Prime-decomposition/TXR/prime-decomposition.txr @@ -0,0 +1,16 @@ +@(next :args) +@(do + (defun factor (n) + (if (> n 1) + (for ((max-d (sqrt n)) + (d 2)) + (t) + ((set d (if (evenp d) (+ d 1) (+ d 2)))) + (cond ((> d max-d) (return (list n))) + ((zerop (mod n d)) + (return (cons d (factor (trunc n d)))))))))) +@{num /[0-9]+/} +@(bind factors @(factor (int-str num 10))) +@(output) +@num -> {@(rep)@factors, @(last)@factors@(end)} +@(end) diff --git a/Task/Prime-decomposition/Tcl/prime-decomposition-1.tcl b/Task/Prime-decomposition/Tcl/prime-decomposition-1.tcl new file mode 100644 index 0000000000..e3047bbbff --- /dev/null +++ b/Task/Prime-decomposition/Tcl/prime-decomposition-1.tcl @@ -0,0 +1,93 @@ +namespace eval primes {} + +proc primes::reset {} { + variable list [list] + variable current_index end +} + +namespace eval primes {reset} + +proc primes::restart {} { + variable list + variable current_index + if {[llength $list] > 0} { + set current_index 0 + } +} + +proc primes::is_prime {candidate} { + variable list + + if {$candidate in $list} {return true} + foreach prime $list { + if {$candidate % $prime == 0} { + return false + } + if {$prime * $prime > $candidate} { + return true + } + } + while true { + set largest [get_next_prime] + if {$largest * $largest >= $candidate} { + return [is_prime $candidate] + } + } +} + +proc primes::get_next_prime {} { + variable list + variable current_index + + if {$current_index ne "end"} { + set p [lindex $list $current_index] + if {[incr current_index] == [llength $list]} { + set current_index end + } + return $p + } + + switch -exact -- [llength $list] { + 0 {set candidate 2} + 1 {set candidate 3} + default { + set candidate [lindex $list end] + while true { + incr candidate 2 + if {[is_prime $candidate]} break + } + } + } + lappend list $candidate + return $candidate +} + +# return the prime factors of a number in a dictionary. +# The keys will be the factors, the value will be the number +# of times the factor divides the given number +# +# example: 120 = 2**3 * 3 * 5, so +# [primes::factors 120] returns 2 3 3 1 5 1 +# so: set prod 1 +# dict for {p e} [primes::factors 120] { +# set prod [expr {$prod * $p**$e}] +# } +# expr {$prod == 120} ;# ==> true +# +proc primes::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 +} diff --git a/Task/Prime-decomposition/Tcl/prime-decomposition-2.tcl b/Task/Prime-decomposition/Tcl/prime-decomposition-2.tcl new file mode 100644 index 0000000000..9dc3f7aacb --- /dev/null +++ b/Task/Prime-decomposition/Tcl/prime-decomposition-2.tcl @@ -0,0 +1,8 @@ +primes::reset +foreach m {2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59} { + set n [expr {2**$m - 1}] + catch {time {set f [dict create {*}[primes::factors $n]]} 1} tm + set primes [list] + dict for {p e} $f {lappend primes {*}[lrepeat $e $p]} + puts [format "2**%02d-1 = %-18s = %-22s => %s" $m $n [join $primes *] $tm] +} diff --git a/Task/Prime-decomposition/V/prime-decomposition-1.v b/Task/Prime-decomposition/V/prime-decomposition-1.v new file mode 100644 index 0000000000..154771c14c --- /dev/null +++ b/Task/Prime-decomposition/V/prime-decomposition-1.v @@ -0,0 +1,10 @@ +[prime-decomposition + [inner [c p] let + [c c * p >] + [p unit] + [ [p c % zero?] + [c c p c / inner cons] + [c 1 + p inner] + ifte] + ifte]. + 2 swap inner]. diff --git a/Task/Prime-decomposition/V/prime-decomposition-2.v b/Task/Prime-decomposition/V/prime-decomposition-2.v new file mode 100644 index 0000000000..e464382912 --- /dev/null +++ b/Task/Prime-decomposition/V/prime-decomposition-2.v @@ -0,0 +1,10 @@ +[prime-decomposition + [inner + [dup * <] + [pop unit] + [ [% zero?] + [ [p c : [c p c / c]] view i inner cons] + [succ inner] + ifte] + ifte]. + 2 inner]. diff --git a/Task/Prime-decomposition/V/prime-decomposition-3.v b/Task/Prime-decomposition/V/prime-decomposition-3.v new file mode 100644 index 0000000000..640155b604 --- /dev/null +++ b/Task/Prime-decomposition/V/prime-decomposition-3.v @@ -0,0 +1 @@ +|1221 prime-decomposition puts diff --git a/Task/Prime-decomposition/XSLT/prime-decomposition-1.xslt b/Task/Prime-decomposition/XSLT/prime-decomposition-1.xslt new file mode 100644 index 0000000000..89e6d145e5 --- /dev/null +++ b/Task/Prime-decomposition/XSLT/prime-decomposition-1.xslt @@ -0,0 +1,73 @@ + + + + + +
    + +
+ + +
+ + +
  • + Number: + + Factors: + +
  • +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    diff --git a/Task/Prime-decomposition/XSLT/prime-decomposition-2.xslt b/Task/Prime-decomposition/XSLT/prime-decomposition-2.xslt new file mode 100644 index 0000000000..4b133d3112 --- /dev/null +++ b/Task/Prime-decomposition/XSLT/prime-decomposition-2.xslt @@ -0,0 +1,8 @@ + + 1 + 2 + 4 + 8 + 9 + 255 + diff --git a/Task/Prime-decomposition/XSLT/prime-decomposition-3.xslt b/Task/Prime-decomposition/XSLT/prime-decomposition-3.xslt new file mode 100644 index 0000000000..eee98d3b94 --- /dev/null +++ b/Task/Prime-decomposition/XSLT/prime-decomposition-3.xslt @@ -0,0 +1,43 @@ + + +
      + +
    • + Number: + 1 + Factors: +
    • + +
    • + Number: + 2 + Factors: + 2
    • + +
    • + Number: + 4 + Factors: + 2 2
    • + +
    • + Number: + 8 + Factors: + 2 2 2
    • + +
    • + Number: + 9 + Factors: + 3 3
    • + +
    • + Number: + 255 + Factors: + 3 5 17
    • + +
    + + diff --git a/Task/Priority-queue/0DESCRIPTION b/Task/Priority-queue/0DESCRIPTION new file mode 100644 index 0000000000..c8bc74a690 --- /dev/null +++ b/Task/Priority-queue/0DESCRIPTION @@ -0,0 +1,17 @@ +A [[wp:Priority queue|priority queue]] is somewhat similar to a [[Queue|queue]], with an important distinction: each item is added to a priority queue with a priority level, and will be later removed from the queue with the highest priority element first. That is, the items are (conceptually) stored in the queue in priority order instead of in insertion order. + +'''Task:''' Create a priority queue. The queue must support at least two operations: +# Insertion. An element is added to the queue with a priority (a numeric value). +# Top item removal. Deletes the element or one of the elements with the current top priority and return it. + +Optionally, other operations may be defined, such as peeking (find what current top priority/top element is), merging (combining two priority queues into one), etc. + +To test your implementation, insert a number of elements into the queue, each with some random priority. Then dequeue them sequentially; now the elements should be sorted by priority. You can use the following task/priority items as input data: + '''Priority''' '''Task''' + 3 Clear drains + 4 Feed cat + 5 Make tea + 1 Solve RC tasks + 2 Tax return + +The implementation should try to be efficient. A typical implementation has O(log n) insertion and extraction time, where n is the number of items in the queue. You may choose to impose certain limits such as small range of allowed priority levels, limited capacity, etc. If so, discuss the reasons behind it. diff --git a/Task/Priority-queue/Ada/priority-queue.ada b/Task/Priority-queue/Ada/priority-queue.ada new file mode 100644 index 0000000000..3b63dc3e1d --- /dev/null +++ b/Task/Priority-queue/Ada/priority-queue.ada @@ -0,0 +1,42 @@ +with Ada.Containers.Synchronized_Queue_Interfaces; +with Ada.Containers.Unbounded_Priority_Queues; +with Ada.Strings.Unbounded; + +procedure Priority_Queues is + use Ada.Containers; + use Ada.Strings.Unbounded; + type Queue_Element is record + Priority : Natural; + Content : Unbounded_String; + end record; + function Get_Priority (Element : Queue_Element) return Natural is + begin + return Element.Priority; + end Get_Priority; + function Before (Left, Right : Natural) return Boolean is + begin + return Left > Right; + end Before; + package String_Queues is new Synchronized_Queue_Interfaces + (Element_Type => Queue_Element); + package String_Priority_Queues is new Unbounded_Priority_Queues + (Queue_Interfaces => String_Queues, + Queue_Priority => Natural); + + My_Queue : String_Priority_Queues.Queue; +begin + My_Queue.Enqueue (New_Item => (Priority => 3, Content => To_Unbounded_String ("Clear drains"))); + My_Queue.Enqueue (New_Item => (Priority => 4, Content => To_Unbounded_String ("Feed cat"))); + My_Queue.Enqueue (New_Item => (Priority => 5, Content => To_Unbounded_String ("Make tea"))); + My_Queue.Enqueue (New_Item => (Priority => 1, Content => To_Unbounded_String ("Solve RC tasks"))); + My_Queue.Enqueue (New_Item => (Priority => 2, Content => To_Unbounded_String ("Tax return"))); + + declare + Element : Queue_Element; + begin + while My_Queue.Current_Use > 0 loop + My_Queue.Dequeue (Element => Element); + Ada.Text_IO.Put_Line (Natural'Image (Element.Priority) & " => " & To_String (Element.Content)); + end loop; + end; +end Priority_Queues; diff --git a/Task/Priority-queue/Axiom/priority-queue-1.axiom b/Task/Priority-queue/Axiom/priority-queue-1.axiom new file mode 100644 index 0000000000..430ca79220 --- /dev/null +++ b/Task/Priority-queue/Axiom/priority-queue-1.axiom @@ -0,0 +1,27 @@ +)abbrev Domain ORDKE OrderedKeyEntry +OrderedKeyEntry(Key:OrderedSet,Entry:SetCategory): Exports == Implementation where + Exports == OrderedSet with + construct: (Key,Entry) -> % + elt: (%,"key") -> Key + elt: (%,"entry") -> Entry + Implementation == add + Rep := Record(k:Key,e:Entry) + x,y: % + construct(a,b) == construct(a,b)$Rep @ % + elt(x,"key"):Key == (x@Rep).k + elt(x,"entry"):Entry == (x@Rep).e + x < y == x.key < y.key + x = y == x.key = y.key + hash x == hash(x.key) + if Entry has CoercibleTo OutputForm then + coerce(x):OutputForm == bracket [(x.key)::OutputForm,(x.entry)::OutputForm] +)abbrev Domain PRIORITY PriorityQueue +S ==> OrderedKeyEntry(Key,Entry) +PriorityQueue(Key:OrderedSet,Entry:SetCategory): Exports == Implementation where + Exports == PriorityQueueAggregate S with + heap : List S -> % + setelt: (%,Key,Entry) -> Entry + Implementation == Heap(S) add + setelt(x:%,key:Key,entry:Entry) == + insert!(construct(key,entry)$S,x) + entry diff --git a/Task/Priority-queue/Axiom/priority-queue-2.axiom b/Task/Priority-queue/Axiom/priority-queue-2.axiom new file mode 100644 index 0000000000..b4960c1c58 --- /dev/null +++ b/Task/Priority-queue/Axiom/priority-queue-2.axiom @@ -0,0 +1,7 @@ +pq := empty()$PriorityQueue(Integer,String) +pq(3):="Clear drains"; +pq(4):="Feed cat"; +pq(5):="Make tea"; +pq(1):="Solve RC tasks"; +pq(2):="Tax return"; +[extract!(pq) for i in 1..#pq] diff --git a/Task/Priority-queue/Axiom/priority-queue-3.axiom b/Task/Priority-queue/Axiom/priority-queue-3.axiom new file mode 100644 index 0000000000..393f5b6c37 --- /dev/null +++ b/Task/Priority-queue/Axiom/priority-queue-3.axiom @@ -0,0 +1,3 @@ + [[5,"Make tea"], [4,"Feed cat"], [3,"Clear drains"], [2,"Tax return"], + [1,"Solve RC tasks"]] + Type: List(OrderedKeyEntry(Integer,String)) diff --git a/Task/Priority-queue/C++/priority-queue-1.cpp b/Task/Priority-queue/C++/priority-queue-1.cpp new file mode 100644 index 0000000000..8fc99590e1 --- /dev/null +++ b/Task/Priority-queue/C++/priority-queue-1.cpp @@ -0,0 +1,20 @@ +#include +#include +#include +#include + +int main() { + std::priority_queue > pq; + pq.push(std::make_pair(3, "Clear drains")); + pq.push(std::make_pair(4, "Feed cat")); + pq.push(std::make_pair(5, "Make tea")); + pq.push(std::make_pair(1, "Solve RC tasks")); + pq.push(std::make_pair(2, "Tax return")); + + while (!pq.empty()) { + std::cout << pq.top().first << ", " << pq.top().second << std::endl; + pq.pop(); + } + + return 0; +} diff --git a/Task/Priority-queue/C++/priority-queue-2.cpp b/Task/Priority-queue/C++/priority-queue-2.cpp new file mode 100644 index 0000000000..570fad9597 --- /dev/null +++ b/Task/Priority-queue/C++/priority-queue-2.cpp @@ -0,0 +1,30 @@ +#include +#include +#include +#include +#include + +int main() { + std::vector > pq; + pq.push_back(std::make_pair(3, "Clear drains")); + pq.push_back(std::make_pair(4, "Feed cat")); + pq.push_back(std::make_pair(5, "Make tea")); + pq.push_back(std::make_pair(1, "Solve RC tasks")); + + // heapify + std::make_heap(pq.begin(), pq.end()); + + // enqueue + pq.push_back(std::make_pair(2, "Tax return")); + std::push_heap(pq.begin(), pq.end()); + + while (!pq.empty()) { + // peek + std::cout << pq[0].first << ", " << pq[0].second << std::endl; + // dequeue + std::pop_heap(pq.begin(), pq.end()); + pq.pop_back(); + } + + return 0; +} diff --git a/Task/Priority-queue/C/priority-queue-1.c b/Task/Priority-queue/C/priority-queue-1.c new file mode 100644 index 0000000000..74c80eabbd --- /dev/null +++ b/Task/Priority-queue/C/priority-queue-1.c @@ -0,0 +1,131 @@ +#include +#include + +typedef struct { void * data; int pri; } q_elem_t; +typedef struct { q_elem_t *buf; int n, alloc; } pri_queue_t, *pri_queue; + +#define priq_purge(q) (q)->n = 1 +#define priq_size(q) ((q)->n - 1) +/* first element in array not used to simplify indices */ +pri_queue priq_new(int size) +{ + if (size < 4) size = 4; + + pri_queue q = malloc(sizeof(pri_queue_t)); + q->buf = malloc(sizeof(q_elem_t) * size); + q->alloc = size; + q->n = 1; + + return q; +} + +void priq_push(pri_queue q, void *data, int pri) +{ + q_elem_t *b; + int n, m; + + if (q->n >= q->alloc) { + q->alloc *= 2; + b = q->buf = realloc(q->buf, sizeof(q_elem_t) * q->alloc); + } else + b = q->buf; + + n = q->n++; + /* append at end, then up heap */ + while ((m = n / 2) && pri < b[m].pri) { + b[n] = b[m]; + n = m; + } + b[n].data = data; + b[n].pri = pri; +} + +/* remove top item. returns 0 if empty. *pri can be null. */ +void * priq_pop(pri_queue q, int *pri) +{ + void *out; + if (q->n == 1) return 0; + + q_elem_t *b = q->buf; + + out = b[1].data; + if (pri) *pri = b[1].pri; + + /* pull last item to top, then down heap. */ + --q->n; + + int n = 1, m; + while ((m = n * 2) < q->n) { + if (m + 1 < q->n && b[m].pri > b[m + 1].pri) m++; + + if (b[q->n].pri <= b[m].pri) break; + b[n] = b[m]; + n = m; + } + + b[n] = b[q->n]; + if (q->n < q->alloc / 2 && q->n >= 16) + q->buf = realloc(q->buf, (q->alloc /= 2) * sizeof(b[0])); + + return out; +} + +/* get the top element without removing it from queue */ +void* priq_top(pri_queue q, int *pri) +{ + if (q->n == 1) return 0; + if (pri) *pri = q->buf[1].pri; + return q->buf[1].data; +} + +/* this is O(n log n), but probably not the best */ +void priq_combine(pri_queue q, pri_queue q2) +{ + int i; + q_elem_t *e = q2->buf + 1; + + for (i = q2->n - 1; i >= 1; i--, e++) + priq_push(q, e->data, e->pri); + priq_purge(q2); +} + +int main() +{ + int i, p; + const char *c, *tasks[] ={ + "Clear drains", "Feed cat", "Make tea", "Solve RC tasks", "Tax return" }; + int pri[] = { 3, 4, 5, 1, 2 }; + + /* make two queues */ + pri_queue q = priq_new(0), q2 = priq_new(0); + + /* push all 5 tasks into q */ + for (i = 0; i < 5; i++) + priq_push(q, tasks[i], pri[i]); + + /* pop them and print one by one */ + while ((c = priq_pop(q, &p))) + printf("%d: %s\n", p, c); + + /* put a million random tasks in each queue */ + for (i = 0; i < 1 << 20; i++) { + p = rand() / ( RAND_MAX / 5 ); + priq_push(q, tasks[p], pri[p]); + + p = rand() / ( RAND_MAX / 5 ); + priq_push(q2, tasks[p], pri[p]); + } + + printf("\nq has %d items, q2 has %d items\n", priq_size(q), priq_size(q2)); + + /* merge q2 into q; q2 is empty */ + priq_combine(q, q2); + printf("After merge, q has %d items, q2 has %d items\n", + priq_size(q), priq_size(q2)); + + /* pop q until it's empty */ + for (i = 0; (c = priq_pop(q, 0)); i++); + printf("Popped %d items out of q\n", i); + + return 0; +} diff --git a/Task/Priority-queue/C/priority-queue-2.c b/Task/Priority-queue/C/priority-queue-2.c new file mode 100644 index 0000000000..61c2df986c --- /dev/null +++ b/Task/Priority-queue/C/priority-queue-2.c @@ -0,0 +1,9 @@ +1: Solve RC tasks +2: Tax return +3: Clear drains +4: Feed cat +5: Make tea + +q has 1048576 items, q2 has 1048576 items +After merge, q has 2097152 items, q2 has 0 items +Popped 2097152 items out of q diff --git a/Task/Priority-queue/CoffeeScript/priority-queue-1.coffeescript b/Task/Priority-queue/CoffeeScript/priority-queue-1.coffeescript new file mode 100644 index 0000000000..777a61212c --- /dev/null +++ b/Task/Priority-queue/CoffeeScript/priority-queue-1.coffeescript @@ -0,0 +1,78 @@ +PriorityQueue = -> + # Use closure style for object creation (so no "new" required). + # Private variables are toward top. + h = [] + + better = (a, b) -> + h[a].priority < h[b].priority + + swap = (a, b) -> + [h[a], h[b]] = [h[b], h[a]] + + sift_down = -> + max = h.length + n = 0 + while n < max + c1 = 2*n + 1 + c2 = c1 + 1 + best = n + best = c1 if c1 < max and better(c1, best) + best = c2 if c2 < max and better(c2, best) + return if best == n + swap n, best + n = best + + sift_up = -> + n = h.length - 1 + while n > 0 + parent = Math.floor((n-1) / 2) + return if better parent, n + swap n, parent + n = parent + + # now return the public interface, which is an object that only + # has functions on it + self = + size: -> + h.length + + push: (priority, value) -> + elem = + priority: priority + value: value + h.push elem + sift_up() + + pop: -> + throw Error("cannot pop from empty queue") if h.length == 0 + value = h[0].value + last = h.pop() + if h.length > 0 + h[0] = last + sift_down() + value + +# test +do -> + pq = PriorityQueue() + pq.push 3, "Clear drains" + pq.push 4, "Feed cat" + pq.push 5, "Make tea" + pq.push 1, "Solve RC tasks" + pq.push 2, "Tax return" + + while pq.size() > 0 + console.log pq.pop() + + # test high performance + for n in [1..100000] + priority = Math.random() + pq.push priority, priority + + v = pq.pop() + console.log "First random element was #{v}" + while pq.size() > 0 + new_v = pq.pop() + throw Error "Queue broken" if new_v < v + v = new_v + console.log "Final random element was #{v}" diff --git a/Task/Priority-queue/CoffeeScript/priority-queue-2.coffeescript b/Task/Priority-queue/CoffeeScript/priority-queue-2.coffeescript new file mode 100644 index 0000000000..69e6b537ac --- /dev/null +++ b/Task/Priority-queue/CoffeeScript/priority-queue-2.coffeescript @@ -0,0 +1,8 @@ +> coffee priority_queue.coffee +Solve RC tasks +Tax return +Clear drains +Feed cat +Make tea +First random element was 0.00002744467929005623 +Final random element was 0.9999718656763434 diff --git a/Task/Priority-queue/D/priority-queue.d b/Task/Priority-queue/D/priority-queue.d new file mode 100644 index 0000000000..0bd2c9a789 --- /dev/null +++ b/Task/Priority-queue/D/priority-queue.d @@ -0,0 +1,15 @@ +import std.stdio, std.container, std.array, std.typecons; + +void main() { + alias tuple T; + auto heap = heapify([T(3, "Clear drains"), + T(4, "Feed cat"), + T(5, "Make tea"), + T(1, "Solve RC tasks"), + T(2, "Tax return")]); + + while (!heap.empty) { + writeln(heap.front); + heap.removeFront(); + } +} diff --git a/Task/Priority-queue/Factor/priority-queue-1.factor b/Task/Priority-queue/Factor/priority-queue-1.factor new file mode 100644 index 0000000000..611de80be0 --- /dev/null +++ b/Task/Priority-queue/Factor/priority-queue-1.factor @@ -0,0 +1,10 @@ + [ { + { 3 "Clear drains" } + { 4 "Feed cat" } + { 5 "Make tea" } + { 1 "Solve RC tasks" } + { 2 "Tax return" } + } swap heap-push-all +] [ + [ print ] slurp-heap +] bi diff --git a/Task/Priority-queue/Factor/priority-queue-2.factor b/Task/Priority-queue/Factor/priority-queue-2.factor new file mode 100644 index 0000000000..933554cb4e --- /dev/null +++ b/Task/Priority-queue/Factor/priority-queue-2.factor @@ -0,0 +1,5 @@ +Solve RC tasks +Tax return +Clear drains +Feed cat +Make tea diff --git a/Task/Priority-queue/Go/priority-queue.go b/Task/Priority-queue/Go/priority-queue.go new file mode 100644 index 0000000000..54a2d309b7 --- /dev/null +++ b/Task/Priority-queue/Go/priority-queue.go @@ -0,0 +1,43 @@ +package main + +import ( + "fmt" + "container/heap" +) + +type Task struct { + priority int + name string +} + +type TaskPQ []Task + +func (self TaskPQ) Len() int { return len(self) } +func (self TaskPQ) Less(i, j int) bool { + return self[i].priority < self[j].priority +} +func (self TaskPQ) Swap(i, j int) { self[i], self[j] = self[j], self[i] } +func (self *TaskPQ) Push(x interface{}) { *self = append(*self, x.(Task)) } +func (self *TaskPQ) Pop() (popped interface{}) { + popped = (*self)[len(*self)-1] + *self = (*self)[:len(*self)-1] + return +} + +func main() { + pq := &TaskPQ{{3, "Clear drains"}, + {4, "Feed cat"}, + {5, "Make tea"}, + {1, "Solve RC tasks"}} + + // heapify + heap.Init(pq) + + // enqueue + heap.Push(pq, Task{2, "Tax return"}) + + for pq.Len() != 0 { + // dequeue + fmt.Println(heap.Pop(pq)) + } +} diff --git a/Task/Priority-queue/Haskell/priority-queue-1.hs b/Task/Priority-queue/Haskell/priority-queue-1.hs new file mode 100644 index 0000000000..2d8c7261d1 --- /dev/null +++ b/Task/Priority-queue/Haskell/priority-queue-1.hs @@ -0,0 +1,3 @@ +import Data.PQueue.Prio.Min + +main = print (toList (fromList [(3, "Clear drains"),(4, "Feed cat"),(5, "Make tea"),(1, "Solve RC tasks"), (2, "Tax return")])) diff --git a/Task/Priority-queue/Haskell/priority-queue-2.hs b/Task/Priority-queue/Haskell/priority-queue-2.hs new file mode 100644 index 0000000000..5af2976c9c --- /dev/null +++ b/Task/Priority-queue/Haskell/priority-queue-2.hs @@ -0,0 +1,44 @@ +data MinHeap a = Nil | MinHeap { v::a, cnt::Int, l::MinHeap a, r::MinHeap a } + deriving (Show, Eq) + +hPush :: (Ord a) => a -> MinHeap a -> MinHeap a +hPush x Nil = MinHeap {v = x, cnt = 1, l = Nil, r = Nil} +hPush x h = if x < vv -- insert element, try to keep the tree balanced + then if hLength (l h) <= hLength (r h) + then MinHeap { v=x, cnt=cc, l=hPush vv ll, r=rr } + else MinHeap { v=x, cnt=cc, l=ll, r=hPush vv rr } + else if hLength (l h) <= hLength (r h) + then MinHeap { v=vv, cnt=cc, l=hPush x ll, r=rr } + else MinHeap { v=vv, cnt=cc, l=ll, r=hPush x rr } + where (vv, cc, ll, rr) = (v h, 1 + cnt h, l h, r h) + +hPop :: (Ord a) => MinHeap a -> (a, MinHeap a) +hPop h = (v h, pq) where -- just pop, heed not the tree balance + pq | l h == Nil = r h + | r h == Nil = l h + | v (l h) <= v (r h) = let (vv,hh) = hPop (l h) in + MinHeap {v = vv, cnt = hLength hh + hLength (r h), + l = hh, r = r h} + | otherwise = let (vv,hh) = hPop (r h) in + MinHeap {v = vv, cnt = hLength hh + hLength (l h), + l = l h, r = hh} + +hLength :: (Ord a) => MinHeap a -> Int +hLength Nil = 0 +hLength h = cnt h + +hFromList :: (Ord a) => [a] -> MinHeap a +hFromList xs = hlist Nil xs where + hlist h [] = h + hlist h (x:xs) = hlist (hPush x h) xs + +hToList :: (Ord a) => MinHeap a -> [a] +hToList Nil = [] +hToList h = x:hToList hh where (x,hh) = hPop h + +main = mapM print $ (hToList (hFromList [ + (3, "Clear drains"), + (4, "Feed cat"), + (5, "Make tea"), + (1, "Solve RC tasks"), + (2, "Tax return")])) diff --git a/Task/Priority-queue/Icon/priority-queue.icon b/Task/Priority-queue/Icon/priority-queue.icon new file mode 100644 index 0000000000..6bb8dae255 --- /dev/null +++ b/Task/Priority-queue/Icon/priority-queue.icon @@ -0,0 +1,13 @@ +import Utils # For Closure class +import Collections # For Heap (dense priority queue) class + +procedure main() + pq := Heap(, Closure("[]",Arg,1) ) + pq.add([3, "Clear drains"]) + pq.add([4, "Feed cat"]) + pq.add([5, "Make tea"]) + pq.add([1, "Solve RC tasks"]) + pq.add([2, "Tax return"]) + + while task := pq.get() do write(task[1]," -> ",task[2]) +end diff --git a/Task/Priority-queue/J/priority-queue-1.j b/Task/Priority-queue/J/priority-queue-1.j new file mode 100644 index 0000000000..8afc3f06f6 --- /dev/null +++ b/Task/Priority-queue/J/priority-queue-1.j @@ -0,0 +1,23 @@ +coclass 'priorityQueue' + +PRI=: '' +QUE=: '' + +insert=:4 :0 + p=. PRI,x + q=. QUE,y + assert. p -:&$ q + assert. 1 = #$q + ord=: \: p + QUE=: ord { q + PRI=: ord { p + i.0 0 +) + +topN=:3 :0 + assert y<:#PRI + r=. y{.QUE + PRI=: y}.PRI + QUE=: y}.QUE + r +) diff --git a/Task/Priority-queue/J/priority-queue-2.j b/Task/Priority-queue/J/priority-queue-2.j new file mode 100644 index 0000000000..dd5a7f1487 --- /dev/null +++ b/Task/Priority-queue/J/priority-queue-2.j @@ -0,0 +1,9 @@ + Q=: conew'priorityQueue' + 3 4 5 1 2 insert__Q 'clear drains';'feed cat';'make tea';'solve rc task';'tax return' + >topN__Q 1 +make tea + >topN__Q 4 +feed cat +clear drains +tax return +solve rc task diff --git a/Task/Priority-queue/Java/priority-queue.java b/Task/Priority-queue/Java/priority-queue.java new file mode 100644 index 0000000000..382ed6b144 --- /dev/null +++ b/Task/Priority-queue/Java/priority-queue.java @@ -0,0 +1,31 @@ +import java.util.PriorityQueue; + +class Task implements Comparable { + final int priority; + final String name; + + public Task(int p, String n) { + priority = p; + name = n; + } + + public String toString() { + return priority + ", " + name; + } + + public int compareTo(Task other) { + return priority < other.priority ? -1 : priority > other.priority ? 1 : 0; + } + + public static final void main(String[] args) { + PriorityQueue pq = new PriorityQueue(); + pq.add(new Task(3, "Clear drains")); + pq.add(new Task(4, "Feed cat")); + pq.add(new Task(5, "Make tea")); + pq.add(new Task(1, "Solve RC tasks")); + pq.add(new Task(2, "Tax return")); + + while (!pq.isEmpty()) + System.out.println(pq.remove()); + } +} diff --git a/Task/Priority-queue/Mathematica/priority-queue-1.math b/Task/Priority-queue/Mathematica/priority-queue-1.math new file mode 100644 index 0000000000..fd04c55559 --- /dev/null +++ b/Task/Priority-queue/Mathematica/priority-queue-1.math @@ -0,0 +1,10 @@ +push = Function[{queue, priority, item}, + queue = SortBy[Append[queue, {priority, item}], First], HoldFirst]; +pop = Function[queue, + If[Length@queue == 0, Null, + With[{item = queue[[-1, 2]]}, queue = Most@queue; item]], + HoldFirst]; +peek = Function[queue, + If[Length@queue == 0, Null, Max[queue[[All, 1]]]], HoldFirst]; +merge = Function[{queue1, queue2}, + SortBy[Join[queue1, queue2], First], HoldAll]; diff --git a/Task/Priority-queue/Mathematica/priority-queue-2.math b/Task/Priority-queue/Mathematica/priority-queue-2.math new file mode 100644 index 0000000000..f216a13e87 --- /dev/null +++ b/Task/Priority-queue/Mathematica/priority-queue-2.math @@ -0,0 +1,11 @@ +queue = {}; +push[queue, 3, "Clear drains"]; +push[queue, 4, "Feed cat"]; +push[queue, 5, "Make tea"]; +push[queue, 1, "Solve RC tasks"]; +push[queue, 2, "Tax return"]; +Print[peek[queue]]; +Print[pop[queue]]; +queue1 = {}; +push[queue1, 6, "Drink tea"]; +Print[merge[queue, queue1]]; diff --git a/Task/Priority-queue/Maxima/priority-queue.maxima b/Task/Priority-queue/Maxima/priority-queue.maxima new file mode 100644 index 0000000000..fb0706d4f1 --- /dev/null +++ b/Task/Priority-queue/Maxima/priority-queue.maxima @@ -0,0 +1,82 @@ +/* Naive implementation using a sorted list of pairs [key, [item[1], ..., item[n]]]. +The key may be any number (integer or not). Items are extracted in FIFO order. */ + +defstruct(pqueue(q = []))$ + +/* Binary search */ + +find_key(q, p) := block( + [i: 1, j: length(q), k, c], + if j = 0 then false + elseif (c: q[i][1]) >= p then + (if c = p then i else false) + elseif (c: q[j][1]) <= p then + (if c = p then j else false) + else catch( + while j >= i do ( + k: quotient(i + j, 2), + if (c: q[k][1]) = p then throw(k) + elseif c < p then i: k + 1 else j: k - 1 + ), + false + ) +)$ + +pqueue_push(pq, x, p) := block( + [q: pq@q, k], + k: find_key(q, p), + if integerp(k) then q[k][2]: endcons(x, q[k][2]) + else pq@q: sort(cons([p, [x]], q)), + 'done +)$ + +pqueue_pop(pq) := block( + [q: pq@q, v, x], + if emptyp(q) then 'fail else ( + p: q[1][1], + v: q[1][2], + x: v[1], + if length(v) > 1 then q[1][2]: rest(v) else pq@q: rest(q), + x + ) +)$ + +pqueue_print(pq) := block([t], while (t: pqueue_pop(pq)) # 'fail do disp(t))$ + + +/* An example */ + +a: new(pqueue)$ + +pqueue_push(a, "take milk", 4)$ +pqueue_push(a, "take eggs", 4)$ +pqueue_push(a, "take wheat flour", 4)$ +pqueue_push(a, "take salt", 4)$ +pqueue_push(a, "take oil", 4)$ +pqueue_push(a, "carry out crepe recipe", 5)$ +pqueue_push(a, "savour !", 6)$ +pqueue_push(a, "add strawberry jam", 5 + 1/2)$ +pqueue_push(a, "call friends", 5 + 2/3)$ +pqueue_push(a, "go to the supermarket and buy food", 3)$ +pqueue_push(a, "take a shower", 2)$ +pqueue_push(a, "get dressed", 2)$ +pqueue_push(a, "wake up", 1)$ +pqueue_push(a, "serve cider", 5 + 3/4)$ +pqueue_push(a, "buy also cider", 3)$ + +pqueue_print(a); +"wake up" +"take a shower" +"get dressed" +"go to the supermarket and buy food" +"buy also cider" +"take milk" +"take butter" +"take flour" +"take salt" +"take oil" +"carry out recipe" +"add strawberry jam" +"call friends" +"serve cider" +"savour !" diff --git a/Task/Priority-queue/OCaml/priority-queue-1.ocaml b/Task/Priority-queue/OCaml/priority-queue-1.ocaml new file mode 100644 index 0000000000..ce2cc25c06 --- /dev/null +++ b/Task/Priority-queue/OCaml/priority-queue-1.ocaml @@ -0,0 +1,17 @@ +module PQ = Base.PriorityQueue + +let () = + let tasks = [ + 3, "Clear drains"; + 4, "Feed cat"; + 5, "Make tea"; + 1, "Solve RC tasks"; + 2, "Tax return"; + ] in + let pq = PQ.make (fun (prio1, _) (prio2, _) -> prio1 > prio2) in + List.iter (PQ.add pq) tasks; + while not (PQ.is_empty pq) do + let _, task = PQ.first pq in + PQ.remove_first pq; + print_endline task + done diff --git a/Task/Priority-queue/OCaml/priority-queue-2.ocaml b/Task/Priority-queue/OCaml/priority-queue-2.ocaml new file mode 100644 index 0000000000..d1857271fb --- /dev/null +++ b/Task/Priority-queue/OCaml/priority-queue-2.ocaml @@ -0,0 +1,22 @@ +module PQSet = Set.Make + (struct + type t = int * string (* pair of priority and task name *) + let compare = compare + end);; + +let () = + let tasks = [ + 3, "Clear drains"; + 4, "Feed cat"; + 5, "Make tea"; + 1, "Solve RC tasks"; + 2, "Tax return"; + ] in + let pq = List.fold_right PQSet.add tasks PQSet.empty in + let rec aux pq' = + if not (PQSet.is_empty pq') then begin + let prio, name as task = PQSet.min_elt pq' in + Printf.printf "%d, %s\n" prio name; + aux (PQSet.remove task pq') + end + in aux pq diff --git a/Task/Priority-queue/Objective-C/priority-queue.m b/Task/Priority-queue/Objective-C/priority-queue.m new file mode 100644 index 0000000000..d0c043b25b --- /dev/null +++ b/Task/Priority-queue/Objective-C/priority-queue.m @@ -0,0 +1,68 @@ +#import + +const void *PQRetain(CFAllocatorRef allocator, const void *ptr) { + return [(id)ptr retain]; +} +void PQRelease(CFAllocatorRef allocator, const void *ptr) { + [(id)ptr release]; +} +CFComparisonResult PQCompare(const void *ptr1, const void *ptr2, void *unused) { + return [(id)ptr1 compare:(id)ptr2]; +} + +@interface Task : NSObject { + int priority; + NSString *name; +} +- (id)initWithPriority:(int)p andName:(NSString *)n; +- (NSComparisonResult)compare:(Task *)other; +@end + +@implementation Task +- (id)initWithPriority:(int)p andName:(NSString *)n { + if ((self = [super init])) { + priority = p; + name = [n copy]; + } + return self; +} +- (void)dealloc { + [name release]; + [super dealloc]; +} +- (NSString *)description { + return [NSString stringWithFormat:@"%d, %@", priority, name]; +} +- (NSComparisonResult)compare:(Task *)other { + if (priority == other->priority) + return NSOrderedSame; + else if (priority < other->priority) + return NSOrderedAscending; + else + return NSOrderedDescending; +} +@end + +int main (int argc, const char *argv[]) { + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + + CFBinaryHeapCallBacks callBacks = {0, PQRetain, PQRelease, NULL, PQCompare}; + CFBinaryHeapRef pq = CFBinaryHeapCreate(NULL, 0, &callBacks, NULL); + + CFBinaryHeapAddValue(pq, [[[Task alloc] initWithPriority:3 andName:@"Clear drains"] autorelease]); + CFBinaryHeapAddValue(pq, [[[Task alloc] initWithPriority:4 andName:@"Feed cat"] autorelease]); + CFBinaryHeapAddValue(pq, [[[Task alloc] initWithPriority:5 andName:@"Make tea"] autorelease]); + CFBinaryHeapAddValue(pq, [[[Task alloc] initWithPriority:1 andName:@"Solve RC tasks"] autorelease]); + CFBinaryHeapAddValue(pq, [[[Task alloc] initWithPriority:2 andName:@"Tax return"] autorelease]); + + while (CFBinaryHeapGetCount(pq) != 0) { + Task *task = (id)CFBinaryHeapGetMinimum(pq); + NSLog(@"%@", task); + CFBinaryHeapRemoveMinimumValue(pq); + } + + CFRelease(pq); + + [pool drain]; + return 0; +} diff --git a/Task/Priority-queue/PHP/priority-queue-1.php b/Task/Priority-queue/PHP/priority-queue-1.php new file mode 100644 index 0000000000..4068f91dc8 --- /dev/null +++ b/Task/Priority-queue/PHP/priority-queue-1.php @@ -0,0 +1,17 @@ +insert('Clear drains', 3); +$pq->insert('Feed cat', 4); +$pq->insert('Make tea', 5); +$pq->insert('Solve RC tasks', 1); +$pq->insert('Tax return', 2); + +// This line causes extract() to return both the data and priority (in an associative array), +// Otherwise it would just return the data +$pq->setExtractFlags(SplPriorityQueue::EXTR_BOTH); + +while (!$pq->isEmpty()) { + print_r($pq->extract()); +} +?> diff --git a/Task/Priority-queue/PHP/priority-queue-2.php b/Task/Priority-queue/PHP/priority-queue-2.php new file mode 100644 index 0000000000..784a288693 --- /dev/null +++ b/Task/Priority-queue/PHP/priority-queue-2.php @@ -0,0 +1,13 @@ +insert(array(3, 'Clear drains')); +$pq->insert(array(4, 'Feed cat')); +$pq->insert(array(5, 'Make tea')); +$pq->insert(array(1, 'Solve RC tasks')); +$pq->insert(array(2, 'Tax return')); + +while (!$pq->isEmpty()) { + print_r($pq->extract()); +} +?> diff --git a/Task/Priority-queue/Perl-6/priority-queue.pl6 b/Task/Priority-queue/Perl-6/priority-queue.pl6 new file mode 100644 index 0000000000..fb0a8d2e03 --- /dev/null +++ b/Task/Priority-queue/Perl-6/priority-queue.pl6 @@ -0,0 +1,29 @@ +class PriorityQueue { + has @!tasks is rw; + + method insert ( Int $priority where { $priority >= 0 }, $task ) { + @!tasks[$priority] //= []; + @!tasks[$priority].push: $task; + } + + method get { @!tasks.first({$^_}).shift } + + method is_empty { !?@!tasks.first({$^_}) } +} + +my $pq = PriorityQueue.new; + +for ( + 3, 'Clear drains', + 4, 'Feed cat', + 5, 'Make tea', + 9, 'Sleep', + 3, 'Check email', + 1, 'Solve RC tasks', + 9, 'Exercise', + 2, 'Do taxes' +) -> $priority, $task { + $pq.insert( $priority, $task ); +} + +say $pq.get until $pq.is_empty; diff --git a/Task/Priority-queue/Perl/priority-queue-1.pl b/Task/Priority-queue/Perl/priority-queue-1.pl new file mode 100644 index 0000000000..fcd8704fd5 --- /dev/null +++ b/Task/Priority-queue/Perl/priority-queue-1.pl @@ -0,0 +1,14 @@ +use 5.10.0; +use strict; +use Heap::Priority; + +my $h = new Heap::Priority; + +$h->highest_first(); # higher or lower number is more important +$h->add(@$_) for ["Clear drains", 3], + ["Feed cat", 4], + ["Make tea", 5], + ["Solve RC tasks", 1], + ["Tax return", 2]; + +say while ($_ = $h->pop); diff --git a/Task/Priority-queue/Perl/priority-queue-2.pl b/Task/Priority-queue/Perl/priority-queue-2.pl new file mode 100644 index 0000000000..32ab5f6bd8 --- /dev/null +++ b/Task/Priority-queue/Perl/priority-queue-2.pl @@ -0,0 +1,5 @@ +Make tea +Feed cat +Clear drains +Tax return +Solve RC tasks diff --git a/Task/Priority-queue/PicoLisp/priority-queue-1.l b/Task/Priority-queue/PicoLisp/priority-queue-1.l new file mode 100644 index 0000000000..8362cf9c54 --- /dev/null +++ b/Task/Priority-queue/PicoLisp/priority-queue-1.l @@ -0,0 +1,18 @@ +# Insert item into priority queue +(de insertPQ (Queue Prio Item) + (idx Queue (cons Prio Item) T) ) + +# Remove and return top item from priority queue +(de removePQ (Queue) + (cdar (idx Queue (peekPQ Queue) NIL)) ) + +# Find top element in priority queue +(de peekPQ (Queue) + (let V (val Queue) + (while (cadr V) + (setq V @) ) + (car V) ) ) + +# Merge second queue into first +(de mergePQ (Queue1 Queue2) + (balance Queue1 (sort (conc (idx Queue1) (idx Queue2)))) ) diff --git a/Task/Priority-queue/PicoLisp/priority-queue-2.l b/Task/Priority-queue/PicoLisp/priority-queue-2.l new file mode 100644 index 0000000000..af28f52062 --- /dev/null +++ b/Task/Priority-queue/PicoLisp/priority-queue-2.l @@ -0,0 +1,18 @@ +# Two priority queues +(off Pq1 Pq2) + +# Insert into first queue +(insertPQ 'Pq1 3 '(Clear drains)) +(insertPQ 'Pq1 4 '(Feed cat)) + +# Insert into second queue +(insertPQ 'Pq2 5 '(Make tea)) +(insertPQ 'Pq2 1 '(Solve RC tasks)) +(insertPQ 'Pq2 2 '(Tax return)) + +# Merge second into first queue +(mergePQ 'Pq1 'Pq2) + +# Remove and print all items from first queue +(while Pq1 + (println (removePQ 'Pq1)) ) diff --git a/Task/Priority-queue/Prolog/priority-queue.pro b/Task/Priority-queue/Prolog/priority-queue.pro new file mode 100644 index 0000000000..3b177e627a --- /dev/null +++ b/Task/Priority-queue/Prolog/priority-queue.pro @@ -0,0 +1,28 @@ +priority-queue :- + TL0 = [3-'Clear drains', + 4-'Feed cat'], + + % we can create a priority queue from a list + list_to_heap(TL0, Heap0), + + % alternatively we can start from an empty queue + % get from empty_heap/1. + + % now we add the other elements + add_to_heap(Heap0, 5, 'Make tea', Heap1), + add_to_heap(Heap1, 1, 'Solve RC tasks', Heap2), + add_to_heap(Heap2, 2, 'Tax return', Heap3), + + % we list the content of the heap: + heap_to_list(Heap3, TL1), + writeln('Content of the queue'), maplist(writeln, TL1), + nl, + + % now we retrieve the minimum-priority pair + get_from_heap(Heap3, Priority, Key, Heap4), + format('Retrieve top of the queue : Priority ~w, Element ~w~n', [Priority, Key]), + nl, + + % we list the content of the heap: + heap_to_list(Heap4, TL2), + writeln('Content of the queue'), maplist(writeln, TL2). diff --git a/Task/Priority-queue/PureBasic/priority-queue.purebasic b/Task/Priority-queue/PureBasic/priority-queue.purebasic new file mode 100644 index 0000000000..7da843309f --- /dev/null +++ b/Task/Priority-queue/PureBasic/priority-queue.purebasic @@ -0,0 +1,119 @@ +Structure taskList + List description.s() ;implements FIFO queue +EndStructure + +Structure task + *tl.tList ;pointer to a list of task descriptions + Priority.i ;tasks priority, lower value has more priority +EndStructure + +Structure priorityQueue + maxHeapSize.i ;increases as needed + heapItemCount.i ;number of elements currently in heap + Array heap.task(0) ;elements hold FIFO queues ordered by priorities, lowest first + map heapMap.taskList() ;holds lists of tasks with the same priority that are FIFO queues +EndStructure + +Procedure insertPQ(*PQ.priorityQueue, description.s, p) + If FindMapElement(*PQ\heapMap(), Str(p)) + LastElement(*PQ\heapMap()\description()) + AddElement(*PQ\heapMap()\description()) + *PQ\heapMap()\description() = description + Else + Protected *tl.taskList = AddMapElement(*PQ\heapMap(), Str(p)) + AddElement(*tl\description()) + *tl\description() = description + + Protected pos = *PQ\heapItemCount + + *PQ\heapItemCount + 1 + If *PQ\heapItemCount > *PQ\maxHeapSize + Select *PQ\maxHeapSize + Case 0 + *PQ\maxHeapSize = 128 + Default + *PQ\maxHeapSize * 2 + EndSelect + Redim *PQ\heap.task(*PQ\maxHeapSize) + EndIf + + While pos > 0 And p < *PQ\heap((pos - 1) / 2)\Priority + *PQ\heap(pos) = *PQ\heap((pos - 1) / 2) + pos = (pos - 1) / 2 + Wend + + *PQ\heap(pos)\tl = *tl + *PQ\heap(pos)\Priority = p + EndIf +EndProcedure + +Procedure.s removePQ(*PQ.priorityQueue) + Protected *tl.taskList = *PQ\heap(0)\tl, description.s + FirstElement(*tl\description()) + description = *tl\description() + If ListSize(*tl\description()) > 1 + DeleteElement(*tl\description()) + Else + DeleteMapElement(*PQ\heapMap(), Str(*PQ\heap(0)\Priority)) + + *PQ\heapItemCount - 1 + *PQ\heap(0) = *PQ\heap(*PQ\heapItemCount) + + Protected pos + Repeat + Protected child1 = 2 * pos + 1 + Protected child2 = 2 * pos + 2 + If child1 >= *PQ\heapItemCount + Break + EndIf + + Protected smallestChild + If child2 >= *PQ\heapItemCount + smallestChild = child1 + ElseIf *PQ\heap(child1)\Priority <= *PQ\heap(child2)\Priority + smallestChild = child1 + Else + smallestChild = child2 + EndIf + + If (*PQ\heap(smallestChild)\Priority >= *PQ\heap(pos)\Priority) + Break + EndIf + Swap *PQ\heap(pos)\tl, *PQ\heap(smallestChild)\tl + Swap *PQ\heap(pos)\Priority, *PQ\heap(smallestChild)\Priority + pos = smallestChild + ForEver + EndIf + + ProcedureReturn description +EndProcedure + +Procedure isEmptyPQ(*PQ.priorityQueue) ;returns 1 if empty, otherwise returns 0 + If *PQ\heapItemCount + ProcedureReturn 0 + EndIf + ProcedureReturn 1 +EndProcedure + +If OpenConsole() + Define PQ.priorityQueue + insertPQ(PQ, "Clear drains", 3) + insertPQ(PQ, "Answer Phone 1", 8) + insertPQ(PQ, "Feed cat", 4) + insertPQ(PQ, "Answer Phone 2", 8) + insertPQ(PQ, "Make tea", 5) + insertPQ(PQ, "Sleep", 9) + insertPQ(PQ, "Check email", 3) + insertPQ(PQ, "Solve RC tasks", 1) + insertPQ(PQ, "Answer Phone 3", 8) + insertPQ(PQ, "Exercise", 9) + insertPQ(PQ, "Answer Phone 4", 8) + insertPQ(PQ, "Tax return", 2) + + While Not isEmptyPQ(PQ) + PrintN(removePQ(PQ)) + Wend + + Print(#CRLF$ + #CRLF$ + "Press ENTER to exit"): Input() + CloseConsole() +EndIf diff --git a/Task/Priority-queue/Python/priority-queue-1.py b/Task/Priority-queue/Python/priority-queue-1.py new file mode 100644 index 0000000000..ae72b9408b --- /dev/null +++ b/Task/Priority-queue/Python/priority-queue-1.py @@ -0,0 +1,16 @@ +>>> import queue +>>> pq = queue.PriorityQueue() +>>> for item in ((3, "Clear drains"), (4, "Feed cat"), (5, "Make tea"), (1, "Solve RC tasks"), (2, "Tax return")): + pq.put(item) + + +>>> while not pq.empty(): + print(pq.get_nowait()) + + +(1, 'Solve RC tasks') +(2, 'Tax return') +(3, 'Clear drains') +(4, 'Feed cat') +(5, 'Make tea') +>>> diff --git a/Task/Priority-queue/Python/priority-queue-2.py b/Task/Priority-queue/Python/priority-queue-2.py new file mode 100644 index 0000000000..c8df4c30da --- /dev/null +++ b/Task/Priority-queue/Python/priority-queue-2.py @@ -0,0 +1,107 @@ +>>> import queue +>>> help(queue.PriorityQueue) +Help on class PriorityQueue in module queue: + +class PriorityQueue(Queue) + | Variant of Queue that retrieves open entries in priority order (lowest first). + | + | Entries are typically tuples of the form: (priority number, data). + | + | Method resolution order: + | PriorityQueue + | Queue + | builtins.object + | + | Methods inherited from Queue: + | + | __init__(self, maxsize=0) + | + | empty(self) + | Return True if the queue is empty, False otherwise (not reliable!). + | + | This method is likely to be removed at some point. Use qsize() == 0 + | as a direct substitute, but be aware that either approach risks a race + | condition where a queue can grow before the result of empty() or + | qsize() can be used. + | + | To create code that needs to wait for all queued tasks to be + | completed, the preferred technique is to use the join() method. + | + | full(self) + | Return True if the queue is full, False otherwise (not reliable!). + | + | This method is likely to be removed at some point. Use qsize() >= n + | as a direct substitute, but be aware that either approach risks a race + | condition where a queue can shrink before the result of full() or + | qsize() can be used. + | + | get(self, block=True, timeout=None) + | Remove and return an item from the queue. + | + | If optional args 'block' is true and 'timeout' is None (the default), + | block if necessary until an item is available. If 'timeout' is + | a positive number, it blocks at most 'timeout' seconds and raises + | the Empty exception if no item was available within that time. + | Otherwise ('block' is false), return an item if one is immediately + | available, else raise the Empty exception ('timeout' is ignored + | in that case). + | + | get_nowait(self) + | Remove and return an item from the queue without blocking. + | + | Only get an item if one is immediately available. Otherwise + | raise the Empty exception. + | + | join(self) + | Blocks until all items in the Queue have been gotten and processed. + | + | The count of unfinished tasks goes up whenever an item is added to the + | queue. The count goes down whenever a consumer thread calls task_done() + | to indicate the item was retrieved and all work on it is complete. + | + | When the count of unfinished tasks drops to zero, join() unblocks. + | + | put(self, item, block=True, timeout=None) + | Put an item into the queue. + | + | If optional args 'block' is true and 'timeout' is None (the default), + | block if necessary until a free slot is available. If 'timeout' is + | a positive number, it blocks at most 'timeout' seconds and raises + | the Full exception if no free slot was available within that time. + | Otherwise ('block' is false), put an item on the queue if a free slot + | is immediately available, else raise the Full exception ('timeout' + | is ignored in that case). + | + | put_nowait(self, item) + | Put an item into the queue without blocking. + | + | Only enqueue the item if a free slot is immediately available. + | Otherwise raise the Full exception. + | + | qsize(self) + | Return the approximate size of the queue (not reliable!). + | + | task_done(self) + | Indicate that a formerly enqueued task is complete. + | + | Used by Queue consumer threads. For each get() used to fetch a task, + | a subsequent call to task_done() tells the queue that the processing + | on the task is complete. + | + | If a join() is currently blocking, it will resume when all items + | have been processed (meaning that a task_done() call was received + | for every item that had been put() into the queue). + | + | Raises a ValueError if called more times than there were items + | placed in the queue. + | + | ---------------------------------------------------------------------- + | Data descriptors inherited from Queue: + | + | __dict__ + | dictionary for instance variables (if defined) + | + | __weakref__ + | list of weak references to the object (if defined) + +>>> diff --git a/Task/Priority-queue/Python/priority-queue-3.py b/Task/Priority-queue/Python/priority-queue-3.py new file mode 100644 index 0000000000..3b6c92b085 --- /dev/null +++ b/Task/Priority-queue/Python/priority-queue-3.py @@ -0,0 +1,13 @@ +>>> from heapq import heappush, heappop, heapify +>>> items = [(3, "Clear drains"), (4, "Feed cat"), (5, "Make tea"), (1, "Solve RC tasks"), (2, "Tax return")] +>>> heapify(items) +>>> while items: + print(heappop(items)) + + +(1, 'Solve RC tasks') +(2, 'Tax return') +(3, 'Clear drains') +(4, 'Feed cat') +(5, 'Make tea') +>>> diff --git a/Task/Priority-queue/Python/priority-queue-4.py b/Task/Priority-queue/Python/priority-queue-4.py new file mode 100644 index 0000000000..b9b2fe8a62 --- /dev/null +++ b/Task/Priority-queue/Python/priority-queue-4.py @@ -0,0 +1,89 @@ +>>> help('heapq') +Help on module heapq: + +NAME + heapq - Heap queue algorithm (a.k.a. priority queue). + +DESCRIPTION + Heaps are arrays for which a[k] <= a[2*k+1] and a[k] <= a[2*k+2] for + all k, counting elements from 0. For the sake of comparison, + non-existing elements are considered to be infinite. The interesting + property of a heap is that a[0] is always its smallest element. + + Usage: + + heap = [] # creates an empty heap + heappush(heap, item) # pushes a new item on the heap + item = heappop(heap) # pops the smallest item from the heap + item = heap[0] # smallest item on the heap without popping it + heapify(x) # transforms list into a heap, in-place, in linear time + item = heapreplace(heap, item) # pops and returns smallest item, and adds + # new item; the heap size is unchanged + + Our API differs from textbook heap algorithms as follows: + + - We use 0-based indexing. This makes the relationship between the + index for a node and the indexes for its children slightly less + obvious, but is more suitable since Python uses 0-based indexing. + + - Our heappop() method returns the smallest item, not the largest. + + These two make it possible to view the heap as a regular Python list + without surprises: heap[0] is the smallest item, and heap.sort() + maintains the heap invariant! + +FUNCTIONS + heapify(...) + Transform list into a heap, in-place, in O(len(heap)) time. + + heappop(...) + Pop the smallest item off the heap, maintaining the heap invariant. + + heappush(...) + Push item onto heap, maintaining the heap invariant. + + heappushpop(...) + Push item on the heap, then pop and return the smallest item + from the heap. The combined action runs more efficiently than + heappush() followed by a separate call to heappop(). + + heapreplace(...) + Pop and return the current smallest value, and add the new item. + + This is more efficient than heappop() followed by heappush(), and can be + more appropriate when using a fixed-size heap. Note that the value + returned may be larger than item! That constrains reasonable uses of + this routine unless written as part of a conditional replacement: + + if item > heap[0]: + item = heapreplace(heap, item) + + merge(*iterables) + Merge multiple sorted inputs into a single sorted output. + + Similar to sorted(itertools.chain(*iterables)) but returns a generator, + does not pull the data into memory all at once, and assumes that each of + the input streams is already sorted (smallest to largest). + + >>> list(merge([1,3,5,7], [0,2,4,8], [5,10,15,20], [], [25])) + [0, 1, 2, 3, 4, 5, 5, 7, 8, 10, 15, 20, 25] + + nlargest(n, iterable, key=None) + Find the n largest elements in a dataset. + + Equivalent to: sorted(iterable, key=key, reverse=True)[:n] + + nsmallest(n, iterable, key=None) + Find the n smallest elements in a dataset. + + Equivalent to: sorted(iterable, key=key)[:n] + +DATA + __about__ = 'Heap queues\n\n[explanation by François Pinard]\n\nH... t... + __all__ = ['heappush', 'heappop', 'heapify', 'heapreplace', 'merge', '... + +FILE + c:\python32\lib\heapq.py + + +>>> diff --git a/Task/Priority-queue/R/priority-queue-1.r b/Task/Priority-queue/R/priority-queue-1.r new file mode 100644 index 0000000000..b46f02c265 --- /dev/null +++ b/Task/Priority-queue/R/priority-queue-1.r @@ -0,0 +1,27 @@ +PriorityQueue <- function() { + keys <<- values <<- NULL + insert <- function(key, value) { + temp <- c(keys, key) + ord <- order(temp) + keys <<- temp[ord] + values <<- c(values, list(value))[ord] + } + pop <- function() { + head <- values[[1]] + values <<- values[-1] + keys <<- keys[-1] + return(head) + } + empty <- function() length(keys) == 0 + list(insert = insert, pop = pop, empty = empty) +} + +pq <- PriorityQueue() +pq$insert(3, "Clear drains") +pq$insert(4, "Feed cat") +pq$insert(5, "Make tea") +pq$insert(1, "Solve RC tasks") +pq$insert(2, "Tax return") +while(!pq$empty()) { + print(pq$pop()) +} diff --git a/Task/Priority-queue/R/priority-queue-2.r b/Task/Priority-queue/R/priority-queue-2.r new file mode 100644 index 0000000000..4d5efd3d7d --- /dev/null +++ b/Task/Priority-queue/R/priority-queue-2.r @@ -0,0 +1,5 @@ +[1] "Solve RC tasks" +[1] "Tax return" +[1] "Clear drains" +[1] "Feed cat" +[1] "Make tea" diff --git a/Task/Priority-queue/R/priority-queue-3.r b/Task/Priority-queue/R/priority-queue-3.r new file mode 100644 index 0000000000..9022992158 --- /dev/null +++ b/Task/Priority-queue/R/priority-queue-3.r @@ -0,0 +1,18 @@ +PriorityQueue <- + setRefClass("PriorityQueue", + fields = list(keys = "numeric", values = "list"), + methods = list( + insert = function(key,value) { + temp <- c(keys,key) + ord <- order(temp) + keys <<- temp[ord] + values <<- c(values,list(value))[ord] + }, + pop = function() { + head <- values[[1]] + keys <<- keys[-1] + values <<- values[-1] + return(head) + }, + empty = function() length(keys) == 0 + )) diff --git a/Task/Priority-queue/R/priority-queue-4.r b/Task/Priority-queue/R/priority-queue-4.r new file mode 100644 index 0000000000..951e78095e --- /dev/null +++ b/Task/Priority-queue/R/priority-queue-4.r @@ -0,0 +1 @@ +pq <- PriorityQueue$new() diff --git a/Task/Priority-queue/Ruby/priority-queue.rb b/Task/Priority-queue/Ruby/priority-queue.rb new file mode 100644 index 0000000000..7617624fb1 --- /dev/null +++ b/Task/Priority-queue/Ruby/priority-queue.rb @@ -0,0 +1,51 @@ +class PriorityQueueNaive + def initialize + @q = Hash.new { |h, k| h[k] = []} + @priorities = [] + end + + def push(priority, item) + @q[priority] << item + @priorities = @q.keys.sort + end + + def pop + p = @priorities[0] + item = @q[p].shift + if @q[p].empty? + @q.delete(p) + @priorities.shift + end + item + end + + def peek + if not empty? + @q[@priorities[0]][0] + end + end + + def empty? + @priorities.empty? + end + + def inspect + @q.inspect + end +end + +test = [ + [6, "drink tea"], + [3, "Clear drains"], + [4, "Feed cat"], + [5, "Make tea"], + [6, "eat biscuit"], + [1, "Solve RC tasks"], + [2, "Tax return"], +] + +pq = PriorityQueueNaive.new +test.each {|pr, str| pq.push(pr, str) } +until pq.empty? + puts pq.pop +end diff --git a/Task/Priority-queue/Run-BASIC/priority-queue.run b/Task/Priority-queue/Run-BASIC/priority-queue.run new file mode 100644 index 0000000000..033e7f0b45 --- /dev/null +++ b/Task/Priority-queue/Run-BASIC/priority-queue.run @@ -0,0 +1,45 @@ +sqliteconnect #mem, ":memory:" +#mem execute("CREATE TABLE queue (priority float,descr text)") + +' -------------------------------------------------------------- +' Insert items into the que +' -------------------------------------------------------------- +#mem execute("INSERT INTO queue VALUES (3,'Clear drains')") +#mem execute("INSERT INTO queue VALUES (4,'Feed cat')") +#mem execute("INSERT INTO queue VALUES (5,'Make tea')") +#mem execute("INSERT INTO queue VALUES (1,'Solve RC tasks')") +#mem execute("INSERT INTO queue VALUES (2,'Tax return')") + +'--------------- insert priority between 4 and 5 ----------------- +#mem execute("INSERT INTO queue VALUES (4.5,'My Special Project')") + +what$ = " -------------- Find first priority ---------------------" +mem$ = "SELECT * FROM queue ORDER BY priority LIMIT 1" +gosub [getQueue] + +what$ = " -------------- Find last priority ---------------------" +mem$ = "SELECT * FROM queue ORDER BY priority desc LIMIT 1" +gosub [getQueue] + +what$ = " -------------- Delete Highest Priority ---------------------" +mem$ = "DELETE FROM queue WHERE priority = (select max(q.priority) FROM queue as q)" +#mem execute(mem$) + +what$ = " -------------- List Priority Sequence ---------------------" +mem$ = "SELECT * FROM queue ORDER BY priority" +gosub [getQueue] +end + + +[getQueue] +print what$ +#mem execute(mem$) +rows = #mem ROWCOUNT() +print "Priority Description" +for i = 1 to rows + #row = #mem #nextrow() + priority = #row priority() + descr$ = #row descr$() +print priority;" ";descr$ +next i +RETURN diff --git a/Task/Priority-queue/Scala/priority-queue-1.scala b/Task/Priority-queue/Scala/priority-queue-1.scala new file mode 100644 index 0000000000..eb271fabc0 --- /dev/null +++ b/Task/Priority-queue/Scala/priority-queue-1.scala @@ -0,0 +1,9 @@ +import scala.collection.mutable.PriorityQueue +case class Task(prio:Int, text:String) extends Ordered[Task] { + def compare(that: Task)=that.prio compare this.prio +} + +//test +var q=PriorityQueue[Task]() ++ Seq(Task(3, "Clear drains"), Task(4, "Feed cat"), + Task(5, "Make tea"), Task(1, "Solve RC tasks"), Task(2, "Tax return")) +while(q.nonEmpty) println(q dequeue) diff --git a/Task/Priority-queue/Scala/priority-queue-2.scala b/Task/Priority-queue/Scala/priority-queue-2.scala new file mode 100644 index 0000000000..6d7bc6b662 --- /dev/null +++ b/Task/Priority-queue/Scala/priority-queue-2.scala @@ -0,0 +1,4 @@ +case class Task(prio:Int, text:String) +implicit def taskOrdering=new Ordering[Task] { + def compare(t1:Task, t2:Task):Int=t2.prio compare t1.prio +} diff --git a/Task/Priority-queue/Standard-ML/priority-queue.ml b/Task/Priority-queue/Standard-ML/priority-queue.ml new file mode 100644 index 0000000000..75f49dd00c --- /dev/null +++ b/Task/Priority-queue/Standard-ML/priority-queue.ml @@ -0,0 +1,29 @@ +structure TaskPriority = struct + type priority = int + val compare = Int.compare + type item = int * string + val priority : item -> int = #1 +end + +structure PQ = LeftPriorityQFn (TaskPriority) +; + +let + val tasks = [ + (3, "Clear drains"), + (4, "Feed cat"), + (5, "Make tea"), + (1, "Solve RC tasks"), + (2, "Tax return")] + val pq = foldr PQ.insert PQ.empty tasks + (* or val pq = PQ.fromList tasks *) + fun aux pq' = + case PQ.next pq' of + NONE => () + | SOME ((prio, name), pq'') => ( + print (Int.toString prio ^ ", " ^ name ^ "\n"); + aux pq'' + ) +in + aux pq +end diff --git a/Task/Priority-queue/Tcl/priority-queue.tcl b/Task/Priority-queue/Tcl/priority-queue.tcl new file mode 100644 index 0000000000..50d4ee78d4 --- /dev/null +++ b/Task/Priority-queue/Tcl/priority-queue.tcl @@ -0,0 +1,18 @@ +package require struct::prioqueue + +set pq [struct::prioqueue] +foreach {priority task} { + 3 "Clear drains" + 4 "Feed cat" + 5 "Make tea" + 1 "Solve RC tasks" + 2 "Tax return" +} { + # Insert into the priority queue + $pq put $task $priority +} +# Drain the queue, in priority-sorted order +while {[$pq size]} { + # Remove the front-most item from the priority queue + puts [$pq get] +} diff --git a/Task/Probabilistic-choice/0DESCRIPTION b/Task/Probabilistic-choice/0DESCRIPTION new file mode 100644 index 0000000000..66e4a3748a --- /dev/null +++ b/Task/Probabilistic-choice/0DESCRIPTION @@ -0,0 +1,13 @@ +Given a mapping between items and their required probability of occurrence, generate a million items ''randomly'' subject to the given probabilities and compare the target probability of occurrence versus the generated values. + +The total of all the probabilities should equal one. (Because floating point arithmetic is involved this is subject to rounding errors). + +Use the following mapping to test your programs:
    +aleph   1/5.0
    +beth    1/6.0
    +gimel   1/7.0
    +daleth  1/8.0
    +he      1/9.0
    +waw     1/10.0
    +zayin   1/11.0
    +heth    1759/27720 # adjusted so that probabilities add to 1
    diff --git a/Task/Probabilistic-choice/1META.yaml b/Task/Probabilistic-choice/1META.yaml new file mode 100644 index 0000000000..29aeacfd2a --- /dev/null +++ b/Task/Probabilistic-choice/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Probability and statistics diff --git a/Task/Probabilistic-choice/ALGOL-68/probabilistic-choice.alg b/Task/Probabilistic-choice/ALGOL-68/probabilistic-choice.alg new file mode 100644 index 0000000000..64f4ea0cf7 --- /dev/null +++ b/Task/Probabilistic-choice/ALGOL-68/probabilistic-choice.alg @@ -0,0 +1,72 @@ +INT trials = 1 000 000; + +MODE LREAL = LONG REAL; + +MODE ITEM = STRUCT( + STRING name, + INT prob count, + LREAL expect, + mapping +); +INT col width = 9; +FORMAT real repr = $g(-col width+1, 6)$, + item repr = $"Name: "g", Prob count: "g(0)", Expect: "f(real repr)", Mapping: ", f(real repr)l$; + +[8]ITEM items := ( + ( "aleph", 0, ~, ~ ), + ( "beth", 0, ~, ~ ), + ( "gimel", 0, ~, ~ ), + ( "daleth", 0, ~, ~ ), + ( "he", 0, ~, ~ ), + ( "waw", 0, ~, ~ ), + ( "zayin", 0, ~, ~ ), + ( "heth", 0, ~, ~ ) +); + +main: +( + LREAL offset = 5; # const # + +# initialise items # + LREAL total sum := 0; + FOR i FROM LWB items TO UPB items - 1 DO + expect OF items[i] := 1/(i-1+offset); + total sum +:= expect OF items[i] + OD; + expect OF items[UPB items] := 1 - total sum; + + mapping OF items[LWB items] := expect OF items[LWB items]; + FOR i FROM LWB items + 1 TO UPB items DO + mapping OF items[i] := mapping OF items[i-1] + expect OF items[i] + OD; + + # printf((item repr, items)) # + +# perform the sampling # + PROC sample = (REF[]LREAL mapping)INT:( + INT out; + LREAL rand real = random; + FOR j FROM LWB items TO UPB items DO + IF rand real < mapping[j] THEN + out := j; + done + FI + OD; + done: out + ); + + FOR i TO trials DO + prob count OF items[sample(mapping OF items)] +:= 1 + OD; + + FORMAT indent = $17k$; + +# print the results # + printf(($"Trials: "g(0)l$, trials)); + printf(($"Items:"$,indent)); + FOR i FROM LWB items TO UPB items DO printf(($gn(col width)k" "$, name OF items[i])) OD; + printf(($l"Target prob.:"$, indent, $f(real repr)" "$, expect OF items)); + printf(($l"Attained prob.:"$, indent)); + FOR i FROM LWB items TO UPB items DO printf(($f(real repr)" "$, prob count OF items[i]/trials)) OD; + printf($l$) +) diff --git a/Task/Probabilistic-choice/AWK/probabilistic-choice.awk b/Task/Probabilistic-choice/AWK/probabilistic-choice.awk new file mode 100644 index 0000000000..1cef2d007a --- /dev/null +++ b/Task/Probabilistic-choice/AWK/probabilistic-choice.awk @@ -0,0 +1,72 @@ +#!/usr/bin/awk -f + +BEGIN { + ITERATIONS = 1000000 + delete symbMap + delete probMap + delete counts + initData(); + + for (i = 0; i < ITERATIONS; i++) { + distribute(rand()) + } + showDistributions() + + exit +} + +function distribute(rnd, cnt, symNum, sym, symPrb) { + cnt = length(symbMap) + for (symNum = 1; symNum <= cnt; symNum++) { + sym = symbMap[symNum]; + symPrb = probMap[sym]; + rnd -= symPrb; + if (rnd <= 0) { + counts[sym]++ + return; + } + } +} + +function showDistributions( s, sym, prb, actSum, expSum, totItr) { + actSum = 0.0 + expSum = 0.0 + totItr = 0 + printf "%-7s %-7s %-5s %-5s\n", "symb", "num.", "act.", "expt." + print "------- ------- ----- -----" + for (s = 1; s <= length(symbMap); s++) { + sym = symbMap[s] + prb = counts[sym]/ITERATIONS + actSum += prb + expSum += probMap[sym] + totItr += counts[sym] + printf "%-7s %7d %1.3f %1.3f\n", sym, counts[sym], prb, probMap[sym] + } + print "------- ------- ----- -----" + printf "Totals: %7d %1.3f %1.3f\n", totItr, actSum, expSum +} + +function initData( sym) { + srand() + + probMap["aleph"] = 1.0 / 5.0 + probMap["beth"] = 1.0 / 6.0 + probMap["gimel"] = 1.0 / 7.0 + probMap["daleth"] = 1.0 / 8.0 + probMap["he"] = 1.0 / 9.0 + probMap["waw"] = 1.0 / 10.0 + probMap["zyin"] = 1.0 / 11.0 + probMap["heth"] = 1759.0 / 27720.0 + + symbMap[1] = "aleph" + symbMap[2] = "beth" + symbMap[3] = "gimel" + symbMap[4] = "daleth" + symbMap[5] = "he" + symbMap[6] = "waw" + symbMap[7] = "zyin" + symbMap[8] = "heth" + + for (sym in probMap) + counts[sym] = 0; +} diff --git a/Task/Probabilistic-choice/Ada/probabilistic-choice.ada b/Task/Probabilistic-choice/Ada/probabilistic-choice.ada new file mode 100644 index 0000000000..e88db2ca4d --- /dev/null +++ b/Task/Probabilistic-choice/Ada/probabilistic-choice.ada @@ -0,0 +1,34 @@ +with Ada.Numerics.Float_Random; use Ada.Numerics.Float_Random; +with Ada.Text_IO; use Ada.Text_IO; + +procedure Random_Distribution is + Trials : constant := 1_000_000; + type Outcome is (Aleph, Beth, Gimel, Daleth, He, Waw, Zayin, Heth); + Pr : constant array (Outcome) of Uniformly_Distributed := + (1.0/5.0, 1.0/6.0, 1.0/7.0, 1.0/8.0, 1.0/9.0, 1.0/10.0, 1.0/11.0, 1.0); + Samples : array (Outcome) of Natural := (others => 0); + Value : Uniformly_Distributed; + Dice : Generator; +begin + for Try in 1..Trials loop + Value := Random (Dice); + for I in Pr'Range loop + if Value <= Pr (I) then + Samples (I) := Samples (I) + 1; + exit; + else + Value := Value - Pr (I); + end if; + end loop; + end loop; + -- Printing the results + for I in Pr'Range loop + Put (Outcome'Image (I) & Character'Val (9)); + Put (Float'Image (Float (Samples (I)) / Float (Trials)) & Character'Val (9)); + if I = Heth then + Put_Line (" rest"); + else + Put_Line (Uniformly_Distributed'Image (Pr (I))); + end if; + end loop; +end Random_Distribution; diff --git a/Task/Probabilistic-choice/AutoHotkey/probabilistic-choice.ahk b/Task/Probabilistic-choice/AutoHotkey/probabilistic-choice.ahk new file mode 100644 index 0000000000..172d58ab14 --- /dev/null +++ b/Task/Probabilistic-choice/AutoHotkey/probabilistic-choice.ahk @@ -0,0 +1,39 @@ +s1 := "aleph", p1 := 1/5.0 ; Input +s2 := "beth", p2 := 1/6.0 +s3 := "gimel", p3 := 1/7.0 +s4 := "daleth", p4 := 1/8.0 +s5 := "he", p5 := 1/9.0 +s6 := "waw", p6 := 1/10.0 +s7 := "zayin", p7 := 1/11.0 +s8 := "heth", p8 := 1-p1-p2-p3-p4-p5-p6-p7 +n := 8, r0 := 0, r%n% := 1 ; auxiliary data + +Loop % n-1 + i := A_Index-1, r%A_Index% := r%i% + p%A_Index% ; cummulative distribution + +Loop 1000000 { + Random R, 0, 1.0 + Loop %n% ; linear search + If (R < r%A_Index%) { + c%A_Index%++ + Break + } +} + ; Output +Loop %n% + t .= s%A_Index% "`t" p%A_Index% "`t" c%A_Index%*1.0e-6 "`n" +Msgbox %t% + +/* +output: +--------------------------- +aleph 0.200000 0.199960 +beth 0.166667 0.166146 +gimel 0.142857 0.142624 +daleth 0.125000 0.124924 +he 0.111111 0.111226 +waw 0.100000 0.100434 +zayin 0.090909 0.091344 +heth 0.063456 0.063342 +--------------------------- +*/ diff --git a/Task/Probabilistic-choice/BBC-BASIC/probabilistic-choice.bbc b/Task/Probabilistic-choice/BBC-BASIC/probabilistic-choice.bbc new file mode 100644 index 0000000000..1f1cf0268a --- /dev/null +++ b/Task/Probabilistic-choice/BBC-BASIC/probabilistic-choice.bbc @@ -0,0 +1,19 @@ + DIM item$(7), prob(7), cnt%(7) + item$() = "aleph","beth","gimel","daleth","he","waw","zayin","heth" + prob() = 1/5.0, 1/6.0, 1/7.0, 1/8.0, 1/9.0, 1/10.0, 1/11.0, 1759/27720 + IF ABS(SUM(prob())-1) > 1E-6 ERROR 100, "Probabilities don't sum to 1" + + FOR trial% = 1 TO 1E6 + r = RND(1) + p = 0 + FOR i% = 0 TO DIM(prob(),1) + p += prob(i%) + IF r < p cnt%(i%) += 1 : EXIT FOR + NEXT + NEXT + + @% = &2060A + PRINT "Item actual theoretical" + FOR i% = 0 TO DIM(item$(),1) + PRINT item$(i%), cnt%(i%)/1E6, prob(i%) + NEXT diff --git a/Task/Probabilistic-choice/C++/probabilistic-choice.cpp b/Task/Probabilistic-choice/C++/probabilistic-choice.cpp new file mode 100644 index 0000000000..e2d5eb8c04 --- /dev/null +++ b/Task/Probabilistic-choice/C++/probabilistic-choice.cpp @@ -0,0 +1,52 @@ +#include +#include +#include +#include +#include +#include +#include + +int main( ) { + typedef std::vector >::const_iterator SPI ; + typedef std::vector > ProbType ; + ProbType probabilities ; + probabilities.push_back( std::make_pair( "aleph" , 1/5.0 ) ) ; + probabilities.push_back( std::make_pair( "beth" , 1/6.0 ) ) ; + probabilities.push_back( std::make_pair( "gimel" , 1/7.0 ) ) ; + probabilities.push_back( std::make_pair( "daleth" , 1/8.0 ) ) ; + probabilities.push_back( std::make_pair( "he" , 1/9.0 ) ) ; + probabilities.push_back( std::make_pair( "waw" , 1/10.0 ) ) ; + probabilities.push_back( std::make_pair( "zayin" , 1/11.0 ) ) ; + probabilities.push_back( std::make_pair( "heth" , 1759/27720.0 ) ) ; + std::vector generated ; //for the strings that are generatod + std::vector decider ; //holds the numbers that determine the choice of letters + for ( int i = 0 ; i < probabilities.size( ) ; i++ ) { + if ( i == 0 ) { + decider.push_back( 27720 * (probabilities[ i ].second) ) ; + } + else { + int number = 0 ; + for ( int j = 0 ; j < i ; j++ ) { + number += 27720 * ( probabilities[ j ].second ) ; + } + number += 27720 * probabilities[ i ].second ; + decider.push_back( number ) ; + } + } + srand( time( 0 ) ) ; + for ( int i = 0 ; i < 1000000 ; i++ ) { + int randnumber = rand( ) % 27721 ; + int j = 0 ; + while ( randnumber > decider[ j ] ) + j++ ; + generated.push_back( ( probabilities[ j ]).first ) ; + } + std::cout << "letter frequency attained frequency expected\n" ; + for ( SPI i = probabilities.begin( ) ; i != probabilities.end( ) ; i++ ) { + std::cout << std::left << std::setw( 8 ) << i->first ; + int found = std::count ( generated.begin( ) , generated.end( ) , i->first ) ; + std::cout << std::left << std::setw( 21 ) << found / 1000000.0 ; + std::cout << std::left << std::setw( 17 ) << i->second << '\n' ; + } + return 0 ; +} diff --git a/Task/Probabilistic-choice/C/probabilistic-choice-1.c b/Task/Probabilistic-choice/C/probabilistic-choice-1.c new file mode 100644 index 0000000000..cb8ded4522 --- /dev/null +++ b/Task/Probabilistic-choice/C/probabilistic-choice-1.c @@ -0,0 +1,34 @@ +#include +#include + +/* pick a random index from 0 to n-1, according to probablities listed + in p[] which is assumed to have a sum of 1. The values in the probablity + list matters up to the point where the sum goes over 1 */ +int rand_idx(double *p, int n) +{ + double s = rand() / (RAND_MAX + 1.0); + int i; + for (i = 0; i < n - 1 && (s -= p[i]) >= 0; i++); + return i; +} + +#define LEN 8 +#define N 1000000 +int main() +{ + const char *names[LEN] = { "aleph", "beth", "gimel", "daleth", + "he", "waw", "zayin", "heth" }; + double s, p[LEN] = { 1./5, 1./6, 1./7, 1./8, 1./9, 1./10, 1./11, 1e300 }; + int i, count[LEN] = {0}; + + for (i = 0; i < N; i++) count[rand_idx(p, LEN)] ++; + + printf(" Name Count Ratio Expected\n"); + for (i = 0, s = 1; i < LEN; s -= p[i++]) + printf("%6s%7d %7.4f%% %7.4f%%\n", + names[i], count[i], + (double)count[i] / N * 100, + ((i < LEN - 1) ? p[i] : s) * 100); + + return 0; +} diff --git a/Task/Probabilistic-choice/C/probabilistic-choice-2.c b/Task/Probabilistic-choice/C/probabilistic-choice-2.c new file mode 100644 index 0000000000..021c713e3a --- /dev/null +++ b/Task/Probabilistic-choice/C/probabilistic-choice-2.c @@ -0,0 +1,9 @@ + Name Count Ratio Expected + aleph 199928 19.9928% 20.0000% + beth 166489 16.6489% 16.6667% + gimel 143211 14.3211% 14.2857% +daleth 125257 12.5257% 12.5000% + he 110849 11.0849% 11.1111% + waw 99935 9.9935% 10.0000% + zayin 91001 9.1001% 9.0909% + heth 63330 6.3330% 6.3456% diff --git a/Task/Probabilistic-choice/Clojure/probabilistic-choice.clj b/Task/Probabilistic-choice/Clojure/probabilistic-choice.clj new file mode 100644 index 0000000000..ad38d406fd --- /dev/null +++ b/Task/Probabilistic-choice/Clojure/probabilistic-choice.clj @@ -0,0 +1,22 @@ +(defn to-cdf [pdf] + (reduce + (fn [acc n] (conj acc (+ (or (last acc) 0) n))) + [] + pdf)) + +(defn choose [cdf] + (let [r (rand)] + (count + (filter (partial > r) cdf)))) + +(def *names* '[aleph beth gimel daleth he waw zayin heth]) +(def *pdf* (map double [1/5 1/6 1/7 1/8 1/9 1/10 1/11 1759/27720])) + +(let [num-trials 1000000 + cdf (to-cdf *pdf*) + indexes (range (count *names*)) ;; use integer key internally, not name + expected (into (sorted-map) (zipmap indexes *pdf*)) + actual (frequencies (repeatedly num-trials #(choose cdf)))] + (doseq [[idx exp] expected] + (println "Expected number of" (*names* idx) "was" + (* num-trials exp) "and actually got" (actual idx)))) diff --git a/Task/Probabilistic-choice/Common-Lisp/probabilistic-choice.lisp b/Task/Probabilistic-choice/Common-Lisp/probabilistic-choice.lisp new file mode 100644 index 0000000000..1debe0fc6f --- /dev/null +++ b/Task/Probabilistic-choice/Common-Lisp/probabilistic-choice.lisp @@ -0,0 +1,46 @@ +(defvar *probabilities* '((aleph 1/5) + (beth 1/6) + (gimel 1/7) + (daleth 1/8) + (he 1/9) + (waw 1/10) + (zayin 1/11) + (heth 1759/27720))) +(defun calculate-probabilities (choices &key (repetitions 1000000)) + (assert (= 1 (reduce #'+ choices :key #'second))) + (labels ((make-ranges () + (loop for (datum probability) in choices + sum (coerce probability 'double-float) into total + collect (list datum total))) + (pick (ranges) + (declare (optimize (speed 3) (safety 0) (debug 0))) + (loop with random = (random 1.0d0) + for (datum below) of-type (t double-float) in ranges + when (< random below) + do (return datum))) + (populate-hash (ranges) + (declare (optimize (speed 3) (safety 0) (debug 0))) + (loop repeat (the fixnum repetitions) + with hash = (make-hash-table) + do (incf (the fixnum (gethash (pick ranges) hash 0))) + finally (return hash))) + (make-table-data (hash) + (loop for (datum probability) in choices + collect (list datum + (float (/ (gethash datum hash) + repetitions)) + (float probability))))) + (format t "Datum~10,2TOccured~20,2TExpected~%") + (format t "~{~{~A~10,2T~F~20,2T~F~}~%~}" + (make-table-data (populate-hash (make-ranges)))))) + +CL-USER> (calculate-probabilities *probabilities*) +Datum Occured Expected +ALEPH 0.200156 0.2 +BETH 0.166521 0.16666667 +GIMEL 0.142936 0.14285715 +DALETH 0.124779 0.125 +HE 0.111601 0.11111111 +WAW 0.100068 0.1 +ZAYIN 0.090458 0.09090909 +HETH 0.063481 0.06345599 diff --git a/Task/Probabilistic-choice/D/probabilistic-choice-1.d b/Task/Probabilistic-choice/D/probabilistic-choice-1.d new file mode 100644 index 0000000000..e5b2de6a02 --- /dev/null +++ b/Task/Probabilistic-choice/D/probabilistic-choice-1.d @@ -0,0 +1,15 @@ +import std.stdio, std.random, std.string, std.range; + +void main() { + enum int nTrials = 1_000_000; + enum items = "aleph beth gimel daleth he waw zayin heth".split(); + enum pr = [1/5., 1/6., 1/7., 1/8., 1/9., 1/10., 1/11., 1759/27720.]; + + double[pr.length] counts = 0.0; + foreach (_; 0 .. nTrials) + counts[dice(pr)]++; + + writeln("Item Target prob Attained prob"); + foreach (name, p, co; zip(items, pr, counts[])) + writefln("%-7s %.8f %.8f", name, p, co / nTrials); +} diff --git a/Task/Probabilistic-choice/D/probabilistic-choice-2.d b/Task/Probabilistic-choice/D/probabilistic-choice-2.d new file mode 100644 index 0000000000..5ac74ef9b7 --- /dev/null +++ b/Task/Probabilistic-choice/D/probabilistic-choice-2.d @@ -0,0 +1,24 @@ +import std.stdio, std.random, std.algorithm, std.range; + +void main() { + enum int nTrials = 1_000_000; + auto items = "aleph beth gimel daleth he waw zayin heth".split(); + enum pr = [1/5., 1/6., 1/7., 1/8., 1/9., 1/10., 1/11., 1759/27720.]; + + double[pr.length] cumulatives = pr[]; + foreach (i, ref c; cumulatives[1 .. $ - 1]) + c += cumulatives[i]; + cumulatives[$ - 1] = 1.0; + + double[pr.length] counts = 0.0; + auto rnd = Xorshift(unpredictableSeed()); + foreach (_; 0 .. nTrials) { + double rnd01 = rnd.front / cast(double)rnd.max; + rnd.popFront(); + counts[cumulatives[].countUntil!(c => c >= rnd01)()]++; + } + + writeln("Item Target prob Attained prob"); + foreach (name, p, co; zip(items, pr, counts[])) + writefln("%-7s %.8f %.8f", name, p, co / nTrials); +} diff --git a/Task/Probabilistic-choice/E/probabilistic-choice-1.e b/Task/Probabilistic-choice/E/probabilistic-choice-1.e new file mode 100644 index 0000000000..33cd5dd3bc --- /dev/null +++ b/Task/Probabilistic-choice/E/probabilistic-choice-1.e @@ -0,0 +1 @@ +pragma.syntax("0.9") diff --git a/Task/Probabilistic-choice/E/probabilistic-choice-2.e b/Task/Probabilistic-choice/E/probabilistic-choice-2.e new file mode 100644 index 0000000000..382148ba38 --- /dev/null +++ b/Task/Probabilistic-choice/E/probabilistic-choice-2.e @@ -0,0 +1,55 @@ +/** Makes leaves of the binary tree */ +def leaf(value) { + return def leaf { + to run(_) { return value } + to __printOn(out) { out.print("=> ", value) } + } +} +/** Makes branches of the binary tree */ +def split(leastRight, left, right) { + return def tree { + to run(specimen) { + return if (specimen < leastRight) { + left(specimen) + } else { + right(specimen) + } + } + to __printOn(out) { + out.print(" ") + out.indent().print(left) + out.lnPrint("< ") + out.print(leastRight) + out.indent().lnPrint(right) + } + } +} +def makeIntervalTree(assocs :List[Tuple[any, float64]]) { + def size :int := assocs.size() + if (size > 1) { + def midpoint := size // 2 + return split(assocs[midpoint][1], makeIntervalTree(assocs.run(0, midpoint)), + makeIntervalTree(assocs.run(midpoint))) + } else { + def [[value, _]] := assocs + return leaf(value) + } +} +def setupProbabilisticChoice(entropy, table :Map[any, float64]) { + var cumulative := 0.0 + var intervalTable := [] + for value => probability in table { + intervalTable with= [value, cumulative] + cumulative += probability + } + def total := cumulative + def selector := makeIntervalTree(intervalTable) + return def probChoice { + # Multiplying by the total helps correct for any error in the sum of the inputs + to run() { return selector(entropy.nextDouble() * total) } + to __printOn(out) { + out.print("Probabilistic choice using tree:") + out.indent().lnPrint(selector) + } + } +} diff --git a/Task/Probabilistic-choice/E/probabilistic-choice-3.e b/Task/Probabilistic-choice/E/probabilistic-choice-3.e new file mode 100644 index 0000000000..f6e652ae6f --- /dev/null +++ b/Task/Probabilistic-choice/E/probabilistic-choice-3.e @@ -0,0 +1,22 @@ +def rosetta := setupProbabilisticChoice(entropy, def probTable := [ + "aleph" => 1/5, + "beth" => 1/6.0, + "gimel" => 1/7.0, + "daleth" => 1/8.0, + "he" => 1/9.0, + "waw" => 1/10.0, + "zayin" => 1/11.0, + "heth" => 0.063455988455988432, +]) + +var trials := 1000000 +var timesFound := [].asMap() +for i in 1..trials { + if (i % 1000 == 0) { print(`${i//1000} `) } + def value := rosetta() + timesFound with= (value, timesFound.fetch(value, fn { 0 }) + 1) +} +stdout.println() +for item in probTable.domain() { + stdout.print(item, "\t", timesFound[item] / trials, "\t", probTable[item], "\n") +} diff --git a/Task/Probabilistic-choice/Euphoria/probabilistic-choice.euphoria b/Task/Probabilistic-choice/Euphoria/probabilistic-choice.euphoria new file mode 100644 index 0000000000..98578e4487 --- /dev/null +++ b/Task/Probabilistic-choice/Euphoria/probabilistic-choice.euphoria @@ -0,0 +1,33 @@ +constant MAX = #3FFFFFFF +constant times = 1e6 +atom d,e +sequence Mapps +Mapps = { + { "aleph", 1/5, 0}, + { "beth", 1/6, 0}, + { "gimel", 1/7, 0}, + { "daleth", 1/8, 0}, + { "he", 1/9, 0}, + { "waw", 1/10, 0}, + { "zayin", 1/11, 0}, + { "heth", 1759/27720, 0} +} + +for i = 1 to times do + d = (rand(MAX)-1)/MAX + e = 0 + for j = 1 to length(Mapps) do + e += Mapps[j][2] + if d <= e then + Mapps[j][3] += 1 + exit + end if + end for +end for + +printf(1,"Sample times: %d\n",times) +for j = 1 to length(Mapps) do + d = Mapps[j][3]/times + printf(1,"%-7s should be %f is %f | Deviatation %6.3f%%\n", + {Mapps[j][1],Mapps[j][2],d,(1-Mapps[j][2]/d)*100}) +end for diff --git a/Task/Probabilistic-choice/Factor/probabilistic-choice-1.factor b/Task/Probabilistic-choice/Factor/probabilistic-choice-1.factor new file mode 100644 index 0000000000..6ebaa255d3 --- /dev/null +++ b/Task/Probabilistic-choice/Factor/probabilistic-choice-1.factor @@ -0,0 +1,37 @@ +USING: arrays assocs combinators.random io kernel macros math +math.statistics prettyprint quotations sequences sorting formatting ; +IN: rosettacode.proba + +CONSTANT: data +{ + { "aleph" 1/5.0 } + { "beth" 1/6.0 } + { "gimel" 1/7.0 } + { "daleth" 1/8.0 } + { "he" 1/9.0 } + { "waw" 1/10.0 } + { "zayin" 1/11.0 } + { "heth" f } +} + +MACRO: case-probas ( data -- case-probas ) + [ first2 [ swap 1quotation 2array ] [ 1quotation ] if* ] map 1quotation ; + +: expected ( name data -- float ) + 2dup at [ 2nip ] [ nip values sift sum 1 swap - ] if* ; +: generate ( # case-probas -- seq ) + H{ } clone + [ [ [ casep ] [ inc-at ] bi* ] 2curry times ] keep ; inline +: normalize ( seq # -- seq ) + [ clone ] dip [ /f ] curry assoc-map ; +: summarize1 ( name value data -- ) + [ over ] dip expected + "%6s: %10f %10f\n" printf ; +: summarize ( generated data -- ) + "Key" "Value" "expected" "%6s %10s %10s\n" printf + [ summarize1 ] curry assoc-each ; +: generate-normalized ( # proba -- seq ) + [ generate ] [ drop normalize ] 2bi ; inline +: example ( # data -- ) + [ case-probas generate-normalized ] + [ summarize ] bi ; inline diff --git a/Task/Probabilistic-choice/Factor/probabilistic-choice-2.factor b/Task/Probabilistic-choice/Factor/probabilistic-choice-2.factor new file mode 100644 index 0000000000..589488fce1 --- /dev/null +++ b/Task/Probabilistic-choice/Factor/probabilistic-choice-2.factor @@ -0,0 +1,2 @@ +USE: rosettacode.proba +1000000 data example diff --git a/Task/Probabilistic-choice/Factor/probabilistic-choice-3.factor b/Task/Probabilistic-choice/Factor/probabilistic-choice-3.factor new file mode 100644 index 0000000000..3dab0b87ee --- /dev/null +++ b/Task/Probabilistic-choice/Factor/probabilistic-choice-3.factor @@ -0,0 +1,9 @@ + Key Value expected + heth: 0.063469 0.063456 + waw: 0.100226 0.100000 +daleth: 0.125844 0.125000 + beth: 0.166264 0.166667 + zayin: 0.090806 0.090909 + he: 0.110562 0.111111 + aleph: 0.199868 0.200000 + gimel: 0.142961 0.142857 diff --git a/Task/Probabilistic-choice/Forth/probabilistic-choice.fth b/Task/Probabilistic-choice/Forth/probabilistic-choice.fth new file mode 100644 index 0000000000..f130e6ef7f --- /dev/null +++ b/Task/Probabilistic-choice/Forth/probabilistic-choice.fth @@ -0,0 +1,44 @@ +include random.fs + +\ common factors of desired probabilities (1/5 .. 1/11) +2 2 * 2 * 3 * 3 * 5 * 7 * 11 * constant denom \ 27720 + +\ represent each probability as the numerator with 27720 as the denominator +: ,numerators ( max min -- ) + do denom i / , loop ; + +\ final item is 27720 - sum(probs) +: ,remainder ( denom addr len -- ) + cells bounds do i @ - 1 cells +loop , ; + +create probs 12 5 ,numerators denom probs 7 ,remainder +create bins 8 cells allot + +: choose ( -- 0..7 ) + denom random + 8 0 do + probs i cells + @ - + dup 0< if drop i unloop exit then + loop + abort" can't get here" ; + +: trials ( n -- ) + 0 do 1 bins choose cells + +! loop ; + +: str-table + create ( c-str ... n -- ) 0 do , loop + does> ( n -- str len ) swap cells + @ count ; + +here ," heth" here ," zayin" here ," waw" here ," he" +here ," daleth" here ," gimel" here ," beth" here ," aleph" +8 str-table names + +: .header + cr ." Name" #tab emit ." Prob" #tab emit ." Actual" #tab emit ." Error" ; +: .result ( n -- ) + cr dup names type #tab emit + dup cells probs + @ s>f denom s>f f/ fdup f. #tab emit + dup cells bins + @ s>f 1e6 f/ fdup f. #tab emit + f- fabs fs. ; + +: .results .header 8 0 do i .result loop ; diff --git a/Task/Probabilistic-choice/Fortran/probabilistic-choice.f b/Task/Probabilistic-choice/Fortran/probabilistic-choice.f new file mode 100644 index 0000000000..a809d3875b --- /dev/null +++ b/Task/Probabilistic-choice/Fortran/probabilistic-choice.f @@ -0,0 +1,33 @@ +PROGRAM PROBS + + IMPLICIT NONE + + INTEGER, PARAMETER :: trials = 1000000 + INTEGER :: i, j, probcount(8) = 0 + REAL :: expected(8), mapping(8), rnum + CHARACTER(6) :: items(8) = (/ "aleph ", "beth ", "gimel ", "daleth", "he ", "waw ", "zayin ", "heth " /) + + expected(1:7) = (/ (1.0/i, i=5,11) /) + expected(8) = 1.0 - SUM(expected(1:7)) + mapping(1) = 1.0 / 5.0 + DO i = 2, 7 + mapping(i) = mapping(i-1) + 1.0/(i+4.0) + END DO + mapping(8) = 1.0 + + DO i = 1, trials + CALL RANDOM_NUMBER(rnum) + DO j = 1, 8 + IF (rnum < mapping(j)) THEN + probcount(j) = probcount(j) + 1 + EXIT + END IF + END DO + END DO + + WRITE(*, "(A,I10)") "Trials: ", trials + WRITE(*, "(A,8A10)") "Items: ", items + WRITE(*, "(A,8F10.6)") "Target Probability: ", expected + WRITE(*, "(A,8F10.6)") "Attained Probability:", REAL(probcount) / REAL(trials) + +ENDPROGRAM PROBS diff --git a/Task/Probabilistic-choice/Go/probabilistic-choice.go b/Task/Probabilistic-choice/Go/probabilistic-choice.go new file mode 100644 index 0000000000..8f542e43e9 --- /dev/null +++ b/Task/Probabilistic-choice/Go/probabilistic-choice.go @@ -0,0 +1,63 @@ +package main + +import ( + "fmt" + "math/rand" + "time" +) + +type mapping struct { + item string + pr float64 +} + +func main() { + // input mapping + m := []mapping{ + {"aleph", 1 / 5.}, + {"beth", 1 / 6.}, + {"gimel", 1 / 7.}, + {"daleth", 1 / 8.}, + {"he", 1 / 9.}, + {"waw", 1 / 10.}, + {"zayin", 1 / 11.}, + {"heth", 1759 / 27720.}} // adjusted so that probabilities add to 1 + + // cumulative probability + cpr := make([]float64, len(m)-1) + var c float64 + for i := 0; i < len(m)-1; i++ { + c += m[i].pr + cpr[i] = c + } + + // generate + const samples = 1e6 + occ := make([]int, len(m)) + rand.Seed(time.Now().UnixNano()) + for i := 0; i < samples; i++ { + r := rand.Float64() + for j := 0; ; j++ { + if r < cpr[j] { + occ[j]++ + break + } + if j == len(cpr)-1 { + occ[len(cpr)]++ + break + } + } + } + + // report + fmt.Println(" Item Target Generated") + var totalTarget, totalGenerated float64 + for i := 0; i < len(m); i++ { + target := m[i].pr + generated := float64(occ[i]) / samples + fmt.Printf("%6s %8.6f %8.6f\n", m[i].item, target, generated) + totalTarget += target + totalGenerated += generated + } + fmt.Printf("Totals %8.6f %8.6f\n", totalTarget, totalGenerated) +} diff --git a/Task/Probabilistic-choice/Haskell/probabilistic-choice.hs b/Task/Probabilistic-choice/Haskell/probabilistic-choice.hs new file mode 100644 index 0000000000..b0e706deb6 --- /dev/null +++ b/Task/Probabilistic-choice/Haskell/probabilistic-choice.hs @@ -0,0 +1,20 @@ +import System.Random +import Data.List +import Control.Monad +import Control.Arrow + +labels = ["aleph", "beth", "gimel", "daleth", "he", "waw", "zayin", "heth" ] +piv n = take n . (++ repeat ' ') + +main = do + g <- newStdGen + let rs,ps :: [Float] + rs = take 1000000 $ randomRs(0,1) g + ps = ap (++) (return. (1 -) .sum) $ map recip [5..11] + sps = scanl1 (+) ps + qs = (\xs -> map ((/1000000.0).fromIntegral.length. flip filter xs. (==))sps) + $ map (head . flip dropWhile sps . (>)) rs + putStrLn $ " expected actual" + mapM_ putStrLn $ zipWith3 + (\l s c-> (piv 7 l) ++ (piv 13 $ show $ s) + ++(piv 12 $ show $ c)) labels ps qs diff --git a/Task/Probabilistic-choice/HicEst/probabilistic-choice.hicest b/Task/Probabilistic-choice/HicEst/probabilistic-choice.hicest new file mode 100644 index 0000000000..6fa435d0d4 --- /dev/null +++ b/Task/Probabilistic-choice/HicEst/probabilistic-choice.hicest @@ -0,0 +1,17 @@ +REAL :: trials=1E6, n=8, map(n), limit(n), expected(n), outcome(n) + +expected = 1 / ($ + 4) +expected(n) = 1 - SUM(expected) + expected(n) + +map = expected +map = map($) + map($-1) + +DO i = 1, trials + random = RAN(1) + limit = random > map + item = INDEX(limit, 0) + outcome(item) = outcome(item) + 1 +ENDDO +outcome = outcome / trials + +DLG(Text=expected, Text=outcome, Y=0) diff --git a/Task/Probabilistic-choice/Icon/probabilistic-choice.icon b/Task/Probabilistic-choice/Icon/probabilistic-choice.icon new file mode 100644 index 0000000000..ac6a7ef8e1 --- /dev/null +++ b/Task/Probabilistic-choice/Icon/probabilistic-choice.icon @@ -0,0 +1,50 @@ +record Item(value, probability) + +procedure find_item (items, v) + sum := 0.0 + every item := !items do { + if v < sum+item.probability + then return item.value + else sum +:= item.probability + } + fail # v exceeded 1.0 +end + +# -- helper procedures + +# count the number of occurrences of i in list l, +# assuming the items are strings +procedure count (l, i) + result := 0.0 + every x := !l do + if x == i then result +:= 1 + return result +end + +procedure rand_float () + return ?1000/1000.0 +end + +# -- test the procedure +procedure main () + items := [ + Item("aleph", 1/5.0), + Item("beth", 1/6.0), + Item("gimel", 1/7.0), + Item("daleth", 1/8.0), + Item("he", 1/9.0), + Item("waw", 1/10.0), + Item("zayin", 1/11.0), + Item("heth", 1759/27720.0) + ] + + # collect a sample of results + sample := [] + every (1 to 1000000) do push (sample, find_item(items, rand_float ())) + + # return comparison of expected vs actual probability + every item := !items do + write (right(item.value, 7) || " " || + left(item.probability, 15) || " " || + left(count(sample, item.value)/*sample, 6)) +end diff --git a/Task/Probabilistic-choice/J/probabilistic-choice-1.j b/Task/Probabilistic-choice/J/probabilistic-choice-1.j new file mode 100644 index 0000000000..72439ac36b --- /dev/null +++ b/Task/Probabilistic-choice/J/probabilistic-choice-1.j @@ -0,0 +1,17 @@ +main=: verb define + hdr=. ' target actual ' + lbls=. ; ,:&.> ;:'aleph beth gimel daleth he waw zayin heth' + prtn=. +/\ pt=. (, 1-+/)1r1%5+i.7 + da=. prtn I. ?y # 0 + pa=. y%~ +/ da =/ i.8 + hdr, lbls,. 9j6 ": |: pt,:pa +) + +Note 'named abbreviations' + hdr (header) + lbls (labels) + pt (target proportions) + prtn (partitions corresponding to target proportions) + da (distribution of actual values among partitions) + pa (actual proportions) +) diff --git a/Task/Probabilistic-choice/J/probabilistic-choice-2.j b/Task/Probabilistic-choice/J/probabilistic-choice-2.j new file mode 100644 index 0000000000..81c0745aed --- /dev/null +++ b/Task/Probabilistic-choice/J/probabilistic-choice-2.j @@ -0,0 +1,10 @@ +main 1e6 + target actual +aleph 0.200000 0.200344 +beth 0.166667 0.166733 +gimel 0.142857 0.142611 +daleth 0.125000 0.124458 +he 0.111111 0.111455 +waw 0.100000 0.099751 +zayin 0.090909 0.091121 +heth 0.063456 0.063527 diff --git a/Task/Probabilistic-choice/J/probabilistic-choice-3.j b/Task/Probabilistic-choice/J/probabilistic-choice-3.j new file mode 100644 index 0000000000..15937911b6 --- /dev/null +++ b/Task/Probabilistic-choice/J/probabilistic-choice-3.j @@ -0,0 +1,5 @@ + pt=. (, 1-+/)1r1%5+i.7 + pt +1r5 1r6 1r7 1r8 1r9 1r10 1r11 1759r27720 + +/pt +1 diff --git a/Task/Probabilistic-choice/Java/probabilistic-choice-1.java b/Task/Probabilistic-choice/Java/probabilistic-choice-1.java new file mode 100644 index 0000000000..e419f27061 --- /dev/null +++ b/Task/Probabilistic-choice/Java/probabilistic-choice-1.java @@ -0,0 +1,67 @@ +public class Prob{ + static long TRIALS= 1000000; + + private static class Expv{ + public String name; + public int probcount; + public double expect; + public double mapping; + + public Expv(String name, int probcount, double expect, double mapping){ + this.name= name; + this.probcount= probcount; + this.expect= expect; + this.mapping= mapping; + } + } + + static Expv[] items= + {new Expv("aleph", 0, 0.0, 0.0), new Expv("beth", 0, 0.0, 0.0), + new Expv("gimel", 0, 0.0, 0.0), + new Expv("daleth", 0, 0.0, 0.0), + new Expv("he", 0, 0.0, 0.0), new Expv("waw", 0, 0.0, 0.0), + new Expv("zayin", 0, 0.0, 0.0), + new Expv("heth", 0, 0.0, 0.0)}; + + public static void main(String[] args){ + int i, j; + double rnum, tsum= 0.0; + + for(i= 0, rnum= 5.0;i < 7;i++, rnum+= 1.0){ + items[i].expect= 1.0 / rnum; + tsum+= items[i].expect; + } + items[7].expect= 1.0 - tsum; + + items[0].mapping= 1.0 / 5.0; + for(i= 1;i < 7;i++){ + items[i].mapping= items[i - 1].mapping + 1.0 / ((double)i + 5.0); + } + items[7].mapping= 1.0; + + + for(i= 0;i < TRIALS;i++){ + rnum= Math.random(); + for(j= 0;j < 8;j++){ + if(rnum < items[j].mapping){ + items[j].probcount++; + break; + } + } + } + + System.out.printf("Trials: %d\n", TRIALS); + System.out.printf("Items: "); + for(i= 0;i < 8;i++) + System.out.printf("%-8s ", items[i].name); + System.out.printf("\nTarget prob.: "); + for(i= 0;i < 8;i++) + System.out.printf("%8.6f ", items[i].expect); + System.out.printf("\nAttained prob.: "); + for(i= 0;i < 8;i++) + System.out.printf("%8.6f ", (double)(items[i].probcount) + / (double)TRIALS); + System.out.printf("\n"); + + } +} diff --git a/Task/Probabilistic-choice/Java/probabilistic-choice-2.java b/Task/Probabilistic-choice/Java/probabilistic-choice-2.java new file mode 100644 index 0000000000..b600d2eace --- /dev/null +++ b/Task/Probabilistic-choice/Java/probabilistic-choice-2.java @@ -0,0 +1,52 @@ +import java.util.EnumMap; + +public class Prob { + public static long TRIALS= 1000000; + public enum Glyph{ + ALEPH, BETH, GIMEL, DALETH, HE, WAW, ZAYIN, HETH; + } + + public static EnumMap probs = new EnumMap(Glyph.class){{ + put(Glyph.ALEPH, 1/5.0); + put(Glyph.BETH, 1/6.0); + put(Glyph.GIMEL, 1/7.0); + put(Glyph.DALETH, 1/8.0); + put(Glyph.HE, 1/9.0); + put(Glyph.WAW, 1/10.0); + put(Glyph.ZAYIN, 1/11.0); + put(Glyph.HETH, 1759./27720); + }}; + + public static EnumMap counts = new EnumMap(Glyph.class){{ + put(Glyph.ALEPH, 0.);put(Glyph.BETH, 0.); + put(Glyph.GIMEL, 0.);put(Glyph.DALETH, 0.); + put(Glyph.HE, 0.);put(Glyph.WAW, 0.); + put(Glyph.ZAYIN, 0.);put(Glyph.HETH, 0.); + }}; + + public static void main(String[] args){ + System.out.println("Target probabliities:\t" + probs); + for(long i = 0; i < TRIALS; i++){ + Glyph choice = getChoice(); + counts.put(choice, counts.get(choice) + 1); + } + + //correct the counts to probablities in (0..1] + for(Glyph glyph:counts.keySet()){ + counts.put(glyph, counts.get(glyph) / TRIALS); + } + + System.out.println("Actual probabliities:\t" + counts); + } + + private static Glyph getChoice() { + double rand = Math.random(); + for(Glyph item:Glyph.values()){ + if(rand < probs.get(item)){ + return item; + } + rand -= probs.get(item); + } + return null; + } +} diff --git a/Task/Probabilistic-choice/JavaScript/probabilistic-choice.js b/Task/Probabilistic-choice/JavaScript/probabilistic-choice.js new file mode 100644 index 0000000000..7a7ce0d7ce --- /dev/null +++ b/Task/Probabilistic-choice/JavaScript/probabilistic-choice.js @@ -0,0 +1,32 @@ +var probabilities = { + aleph: 1/5.0, + beth: 1/6.0, + gimel: 1/7.0, + daleth: 1/8.0, + he: 1/9.0, + waw: 1/10.0, + zayin: 1/11.0, + heth: 1759/27720 +}; + +var sum = 0; +var iterations = 1000000; +var cumulative = {}; +var randomly = {}; +for (var name in probabilities) { + sum += probabilities[name]; + cumulative[name] = sum; + randomly[name] = 0; +} +for (var i = 0; i < iterations; i++) { + var r = Math.random(); + for (var name in cumulative) { + if (r <= cumulative[name]) { + randomly[name]++; + break; + } + } +} +for (var name in probabilities) + // using WSH + WScript.Echo(name + "\t" + probabilities[name] + "\t" + randomly[name]/iterations); diff --git a/Task/Probabilistic-choice/Liberty-BASIC/probabilistic-choice.liberty b/Task/Probabilistic-choice/Liberty-BASIC/probabilistic-choice.liberty new file mode 100644 index 0000000000..8af8a814b5 --- /dev/null +++ b/Task/Probabilistic-choice/Liberty-BASIC/probabilistic-choice.liberty @@ -0,0 +1,24 @@ +names$="aleph beth gimel daleth he waw zayin heth" +dim sum(8) +dim counter(8) + +s = 0 +for i = 1 to 7 + s = s+1/(i+4) + sum(i)=s +next + +N =1000000 ' number of throws + +for i =1 to N + rand =rnd( 1) + for j = 1 to 7 + if sum(j)> rand then exit for + next + counter(j)=counter(j)+1 +next + +print "Observed", "Intended" +for i = 1 to 8 + print word$(names$, i), using( "#.#####", counter(i) /N), using( "#.#####", 1/(i+4)) +next diff --git a/Task/Probabilistic-choice/Lua/probabilistic-choice.lua b/Task/Probabilistic-choice/Lua/probabilistic-choice.lua new file mode 100644 index 0000000000..67d15ea410 --- /dev/null +++ b/Task/Probabilistic-choice/Lua/probabilistic-choice.lua @@ -0,0 +1,34 @@ +items = {} +items["aleph"] = 1/5.0 +items["beth"] = 1/6.0 +items["gimel"] = 1/7.0 +items["daleth"] = 1/8.0 +items["he"] = 1/9.0 +items["waw"] = 1/10.0 +items["zayin"] = 1/11.0 +items["heth"] = 1759/27720 + +num_trials = 1000000 + +samples = {} +for item, _ in pairs( items ) do + samples[item] = 0 +end + +math.randomseed( os.time() ) +for i = 1, num_trials do + z = math.random() + + for item, _ in pairs( items ) do + if z < items[item] then + samples[item] = samples[item] + 1 + break; + else + z = z - items[item] + end + end +end + +for item, _ in pairs( items ) do + print( item, samples[item]/num_trials, items[item] ) +end diff --git a/Task/Probabilistic-choice/Mathematica/probabilistic-choice-1.math b/Task/Probabilistic-choice/Mathematica/probabilistic-choice-1.math new file mode 100644 index 0000000000..7541b2d284 --- /dev/null +++ b/Task/Probabilistic-choice/Mathematica/probabilistic-choice-1.math @@ -0,0 +1,2 @@ +choices={{"aleph", 1/5},{"beth", 1/6},{"gimel", 1/7},{"daleth", 1/8},{"he", 1/9},{"waw", 1/10},{"zayin", 1/11},{"heth", 1759/27720}}; +data=RandomChoice[choices[[All,2]]->choices[[All,1]],10^6]; diff --git a/Task/Probabilistic-choice/Mathematica/probabilistic-choice-2.math b/Task/Probabilistic-choice/Mathematica/probabilistic-choice-2.math new file mode 100644 index 0000000000..2dac752d9d --- /dev/null +++ b/Task/Probabilistic-choice/Mathematica/probabilistic-choice-2.math @@ -0,0 +1 @@ +Grid[{#[[1]],N[Count[data,#[[1]]]/10^6],N[#[[2]]]}&/@choices] diff --git a/Task/Probabilistic-choice/OCaml/probabilistic-choice.ocaml b/Task/Probabilistic-choice/OCaml/probabilistic-choice.ocaml new file mode 100644 index 0000000000..de35bc2996 --- /dev/null +++ b/Task/Probabilistic-choice/OCaml/probabilistic-choice.ocaml @@ -0,0 +1,30 @@ +let p = [ + "Aleph", 1.0 /. 5.0; + "Beth", 1.0 /. 6.0; + "Gimel", 1.0 /. 7.0; + "Daleth", 1.0 /. 8.0; + "He", 1.0 /. 9.0; + "Waw", 1.0 /. 10.0; + "Zayin", 1.0 /. 11.0; + "Heth", 1759.0 /. 27720.0; + ] + +let rec take k = function + | (v, p)::tl -> if k < p then v else take (k -. p) tl + | _ -> invalid_arg "take" + +let () = + let n = 1_000_000 in + Random.self_init(); + let h = Hashtbl.create 3 in + List.iter (fun (v, _) -> Hashtbl.add h v 0) p; + let tot = List.fold_left (fun acc (_, p) -> acc +. p) 0.0 p in + for i = 1 to n do + let sel = take (Random.float tot) p in + let n = Hashtbl.find h sel in + Hashtbl.replace h sel (succ n) (* count the number of each item *) + done; + List.iter (fun (v, p) -> + let d = Hashtbl.find h v in + Printf.printf "%s \t %f %f\n" v p (float d /. float n) + ) p diff --git a/Task/Probabilistic-choice/PARI-GP/probabilistic-choice.pari b/Task/Probabilistic-choice/PARI-GP/probabilistic-choice.pari new file mode 100644 index 0000000000..49aeab8907 --- /dev/null +++ b/Task/Probabilistic-choice/PARI-GP/probabilistic-choice.pari @@ -0,0 +1,14 @@ +pc()={ + my(v=[5544,10164,14124,17589,20669,23441,25961,27720],u=vector(8),e); + for(i=1,1e6, + my(r=random(27720)); + for(j=1,8, + if(r 1/$^n}, (5 .. 11 Z )), + heth => 0 +); +%ps = 1 - [+] values %ps; + +&picker = prob_choice_picker %ps; +my %results; +++%results{picker} for ^TRIALS; + +say 'Event Occurred Expected Difference'; +for sort { .value }, %results { + printf "%-6s %f %f %f\n", + .key, .value/TRIALS, %ps{.key}, + abs( .value/TRIALS - %ps{.key} ); +} diff --git a/Task/Probabilistic-choice/Perl/probabilistic-choice.pl b/Task/Probabilistic-choice/Perl/probabilistic-choice.pl new file mode 100644 index 0000000000..ef6b90bb04 --- /dev/null +++ b/Task/Probabilistic-choice/Perl/probabilistic-choice.pl @@ -0,0 +1,38 @@ +use List::Util qw(first sum); +use constant TRIALS => 1e6; + +sub prob_choice_picker { + my %options = @_; + my ($n, @a) = 0; + while (my ($k,$v) = each %options) { + $n += $v; + push @a, [$n, $k]; + } + return sub { + my $r = rand; + ( first {$r <= $_->[0]} @a )->[1]; + }; +} + +my %ps = + (aleph => 1/5, + beth => 1/6, + gimel => 1/7, + daleth => 1/8, + he => 1/9, + waw => 1/10, + zayin => 1/11); +$ps{heth} = 1 - sum values %ps; + +my $picker = prob_choice_picker %ps; +my %results; +for (my $n = 0 ; $n < TRIALS ; ++$n) { + ++$results{$picker->()}; +} + +print "Event Occurred Expected Difference\n"; +foreach (sort {$results{$b} <=> $results{$a}} keys %results) { + printf "%-6s %f %f %f\n", + $_, $results{$_}/TRIALS, $ps{$_}, + abs($results{$_}/TRIALS - $ps{$_}); +} diff --git a/Task/Probabilistic-choice/PicoLisp/probabilistic-choice.l b/Task/Probabilistic-choice/PicoLisp/probabilistic-choice.l new file mode 100644 index 0000000000..ea7db13470 --- /dev/null +++ b/Task/Probabilistic-choice/PicoLisp/probabilistic-choice.l @@ -0,0 +1,17 @@ +(let (Count 1000000 Denom 27720 N Denom) + (let Probs + (mapcar + '((I S) + (prog1 (cons N (*/ Count I) 0 S) + (dec 'N (/ Denom I)) ) ) + (range 5 12) + '(aleph beth gimel daleth he waw zayin heth) ) + (do Count + (inc (cddr (rank (rand 1 Denom) Probs T))) ) + (let Fmt (-6 12 12) + (tab Fmt NIL "Probability" "Result") + (for X Probs + (tab Fmt + (cdddr X) + (format (cadr X) 6) + (format (caddr X) 6) ) ) ) ) ) diff --git a/Task/Probabilistic-choice/PureBasic/probabilistic-choice.purebasic b/Task/Probabilistic-choice/PureBasic/probabilistic-choice.purebasic new file mode 100644 index 0000000000..035304da1a --- /dev/null +++ b/Task/Probabilistic-choice/PureBasic/probabilistic-choice.purebasic @@ -0,0 +1,42 @@ +#times=1000000 + +Structure Item + name.s + prob.d + Amount.i +EndStructure + +If OpenConsole() + Define i, j, d.d, e.d, txt.s + Dim Mapps.Item(7) + Mapps(0)\name="aleph": Mapps(0)\prob=1/5.0 + Mapps(1)\name="beth": Mapps(1)\prob=1/6.0 + Mapps(2)\name="gimel": Mapps(2)\prob=1/7.0 + Mapps(3)\name="daleth":Mapps(3)\prob=1/8.0 + Mapps(4)\name="he": Mapps(4)\prob=1/9.0 + Mapps(5)\name="waw": Mapps(5)\prob=1/10.0 + Mapps(6)\name="zayin": Mapps(6)\prob=1/11.0 + Mapps(7)\name="heth": Mapps(7)\prob=1759/27720.0 + + For i=1 To #times + d=Random(#MAXLONG)/#MAXLONG ; Get a random number + e=0.0 + For j=0 To ArraySize(Mapps()) + e+Mapps(j)\prob ; Get span for current itme + If d<=e ; Check if it is within this span? + Mapps(j)\Amount+1 ; If so, count it. + Break + EndIf + Next j + Next i + + PrintN("Sample times: "+Str(#times)+#CRLF$) + For j=0 To ArraySize(Mapps()) + d=Mapps(j)\Amount/#times + txt=LSet(Mapps(j)\name,7)+" should be "+StrD(Mapps(j)\prob)+" is "+StrD(d) + PrintN(txt+" | Deviatation "+RSet(StrD(100.0-100.0*Mapps(j)\prob/d,3),6)+"%") + Next + + Print(#CRLF$+"Press ENTER to exit"):Input() + CloseConsole() +EndIf diff --git a/Task/Probabilistic-choice/Python/probabilistic-choice.py b/Task/Probabilistic-choice/Python/probabilistic-choice.py new file mode 100644 index 0000000000..f1ab798af5 --- /dev/null +++ b/Task/Probabilistic-choice/Python/probabilistic-choice.py @@ -0,0 +1,64 @@ +import random, bisect + +def probchoice(items, probs): + '''\ + Splits the interval 0.0-1.0 in proportion to probs + then finds where each random.random() choice lies + ''' + + prob_accumulator = 0 + accumulator = [] + for p in probs: + prob_accumulator += p + accumulator.append(prob_accumulator) + + while True: + r = random.random() + yield items[bisect.bisect(accumulator, r)] + +def probchoice2(items, probs, bincount=10000): + '''\ + Puts items in bins in proportion to probs + then uses random.choice() to select items. + + Larger bincount for more memory use but + higher accuracy (on avarage). + ''' + + bins = [] + for item,prob in zip(items, probs): + bins += [item]*int(bincount*prob) + while True: + yield random.choice(bins) + + +def tester(func=probchoice, items='good bad ugly'.split(), + probs=[0.5, 0.3, 0.2], + trials = 100000 + ): + def problist2string(probs): + '''\ + Turns a list of probabilities into a string + Also rounds FP values + ''' + return ",".join('%8.6f' % (p,) for p in probs) + + from collections import defaultdict + + counter = defaultdict(int) + it = func(items, probs) + for dummy in xrange(trials): + counter[it.next()] += 1 + print "\n##\n## %s\n##" % func.func_name.upper() + print "Trials: ", trials + print "Items: ", ' '.join(items) + print "Target probability: ", problist2string(probs) + print "Attained probability:", problist2string( + counter[x]/float(trials) for x in items) + +if __name__ == '__main__': + items = 'aleph beth gimel daleth he waw zayin heth'.split() + probs = [1/(float(n)+5) for n in range(len(items))] + probs[-1] = 1-sum(probs[:-1]) + tester(probchoice, items, probs, 1000000) + tester(probchoice2, items, probs, 1000000) diff --git a/Task/Probabilistic-choice/R/probabilistic-choice-1.r b/Task/Probabilistic-choice/R/probabilistic-choice-1.r new file mode 100644 index 0000000000..c087f9096c --- /dev/null +++ b/Task/Probabilistic-choice/R/probabilistic-choice-1.r @@ -0,0 +1,8 @@ +prob = c(aleph=1/5, beth=1/6, gimel=1/7, daleth=1/8, he=1/9, waw=1/10, zayin=1/11, heth=1759/27720) + # Note that R doesn't actually require the weights + # vector for rmultinom to sum to 1. +hebrew = c(rmultinom(1, 1e6, prob)) +d = data.frame( + Requested = prob, + Obtained = hebrew/sum(hebrew)) +print(d) diff --git a/Task/Probabilistic-choice/R/probabilistic-choice-2.r b/Task/Probabilistic-choice/R/probabilistic-choice-2.r new file mode 100644 index 0000000000..d3a11a2a7c --- /dev/null +++ b/Task/Probabilistic-choice/R/probabilistic-choice-2.r @@ -0,0 +1,2 @@ +library(ggplot2) +qplot(factor(names(prob), levels = names(prob)), hebrew, geom = "histogram") diff --git a/Task/Probabilistic-choice/REXX/probabilistic-choice.rexx b/Task/Probabilistic-choice/REXX/probabilistic-choice.rexx new file mode 100644 index 0000000000..b7b425d24f --- /dev/null +++ b/Task/Probabilistic-choice/REXX/probabilistic-choice.rexx @@ -0,0 +1,32 @@ +/*REXX pg shows results of probabilistic choices (gen rand#s per prob.) */ +parse arg trials digits seed . /*obtain some optional arguments.*/ +if trials=='' | trials==',' then trials=1000000 +if digits=='' | digits==',' then digits=15; digits=max(10,digits) +if seed\=='' then call random ,,seed /*for repeatability*/ +names='aleph beth gimel daleth he waw zayin heth ──totals───►' +cells=words(names) - 1; high=100000; s=0; !.=0 +_=4 + do n=1 for 7; _=_+1; prob.n=1/_; Hprob.n=prob.n*high; s=s+prob.n + end /*n*/ /* [↑] determine probabilities. */ + +prob.8=1759/27720; Hprob.8=prob.8*high; s=s+prob.8; prob.9=s; !.9=trials + + do j=1 for trials; r=random(1,high) /*generate X number of random #s.*/ + do k=1 for cells /*now, for each cell, compute %s.*/ + if r<=Hprob.k then !.k=!.k+1 /*for each range, bump da counter*/ + end /*k*/ + end /*j*/ + +w=digits+6; d=max(length(trials), length('count')) + 4 +say center('name',15,'─') center('count',d,'─') center('target %',w,'─'), + center('actual %',w,'─') /*display a formatted header line*/ + + do i=1 for cells+1 /*show for each cell and totals. */ + say ' ' left(word(names,i) , 12), + right(!.i , d-2) ' ', + left(format(prob.i *100, d), w-2), + left(format(!.i/trials*100, d), w-2) + if i==8 then say center('',15,'─') center('',d,'─'), + center('', w,'─') center('',w,'─') + end /*i*/ + /*stick a fork in it, we're done.*/ diff --git a/Task/Probabilistic-choice/Ruby/probabilistic-choice.rb b/Task/Probabilistic-choice/Ruby/probabilistic-choice.rb new file mode 100644 index 0000000000..01baac1726 --- /dev/null +++ b/Task/Probabilistic-choice/Ruby/probabilistic-choice.rb @@ -0,0 +1,35 @@ +ordered_keys = ["aleph", "beth", "gimel", "daleth", "he", "waw", "zayin", "heth"] +probabilities = { + "aleph" => 1/5.0, + "beth" => 1/6.0, + "gimel" => 1/7.0, + "daleth" => 1/8.0, + "he" => 1/9.0, + "waw" => 1/10.0, + "zayin" => 1/11.0, +} +probabilities["heth"] = probabilities.each_value.inject(1) {|heth, value| heth -= value} + +sums = {} +ordered_keys.each.inject(0) do |sum, key| + sum += probabilities[key] + sums[key] = sum +end + +actual = Hash.new(0) + +samples = 1_000_000 +samples.times do + r = rand + for k in ordered_keys + if r < sums[k] + actual[k] += 1 + break + end + end +end + +printf "%-6s %-19s %s\n", "key", "expected", "actual" +for k in ordered_keys + printf "%-6s %.17f %.6f\n", k, probabilities[k], Float(actual[k])/samples +end diff --git a/Task/Probabilistic-choice/Seed7/probabilistic-choice.seed7 b/Task/Probabilistic-choice/Seed7/probabilistic-choice.seed7 new file mode 100644 index 0000000000..05de9b8019 --- /dev/null +++ b/Task/Probabilistic-choice/Seed7/probabilistic-choice.seed7 @@ -0,0 +1,45 @@ +$ include "seed7_05.s7i"; + include "float.s7i"; + +const type: letter is new enum + aleph, beth, gimel, daleth, he, waw, zayin, heth + end enum; + +const func string: str (in letter: aLetter) is + return [] ("aleph", "beth", "gimel", "daleth", "he", "waw", "zayin", "heth") [succ(ord(aLetter))]; + +enable_output(letter); + +const array [letter] integer: table is [letter] ( + 5544, 4620, 3960, 3465, 3080, 2772, 2520, 1759); + +const func letter: randomLetter is func + result + var letter: resultLetter is aleph; + local + var integer: number is 0; + begin + number := rand(1, 27720); + while number > table[resultLetter] do + number -:= table[resultLetter]; + incr(resultLetter); + end while; + end func; + +const proc: main is func + local + var integer: count is 0; + var letter: aLetter is aleph; + var array [letter] integer: occurrence is letter times 0; + begin + for count range 1 to 1000000 do + aLetter := randomLetter; + incr(occurrence[aLetter]); + end for; + writeln("Name Count Ratio Expected"); + for aLetter range letter.first to letter.last do + writeln(aLetter rpad 7 <& occurrence[aLetter] lpad 6 <& + flt(occurrence[aLetter]) / 10000.9 digits 4 lpad 8 <& "%" <& + 100.0 * flt(table[aLetter]) / 27720.0 digits 4 lpad 8 <& "%"); + end for; + end func; diff --git a/Task/Probabilistic-choice/Tcl/probabilistic-choice.tcl b/Task/Probabilistic-choice/Tcl/probabilistic-choice.tcl new file mode 100644 index 0000000000..a9165f1878 --- /dev/null +++ b/Task/Probabilistic-choice/Tcl/probabilistic-choice.tcl @@ -0,0 +1,37 @@ +package require Tcl 8.5 + +set map [dict create] +set sum 0.0 + +foreach name {aleph beth gimel daleth he waw zayin} \ + prob {1/5.0 1/6.0 1/7.0 1/8.0 1/9.0 1/10.0 1/11.0} \ +{ + set prob [expr $prob] + set sum [expr {$sum + $prob}] + dict set map $name [dict create probability $prob limit $sum count 0] +} +dict set map heth [dict create probability [expr {1.0 - $sum}] limit 1.0 count 0] + +set samples 1000000 +for {set i 0} {$i < $samples} {incr i} { + set n [expr {rand()}] + foreach name [dict keys $map] { + if {$n <= [dict get $map $name limit]} { + set count [dict get $map $name count] + dict set map $name count [incr count] + break + } + } +} + +puts "using $samples samples:" +puts [format "%-10s %-21s %-9s %s" "" expected actual difference] + +dict for {name submap} $map { + dict with submap { + set actual [expr {$count * 1.0 / $samples}] + puts [format "%-10s %-21s %-9s %4.2f%%" $name $probability $actual \ + [expr {abs($actual - $probability)/$probability*100.0}] + ] + } +} diff --git a/Task/Probabilistic-choice/Ursala/probabilistic-choice.ursala b/Task/Probabilistic-choice/Ursala/probabilistic-choice.ursala new file mode 100644 index 0000000000..4837ee2f29 --- /dev/null +++ b/Task/Probabilistic-choice/Ursala/probabilistic-choice.ursala @@ -0,0 +1,18 @@ +#import std +#import nat +#import flo + +outcomes = <'aleph ','beth ','gimel ','daleth','he ','waw ','zayin ','heth '> +probabilities = ^lrNCT(~&,minus/1.+ plus:-0) div/*1. float* skip/5 iota12 + +simulation = + +^(~&rn,div+ float~~rmPlX)^*D/~& iota; ^A(~&h,length)*K2+ * stochasm@p/probabilities !* outcomes + +format = + +:/' frequency probability'+ * ^lrlrTPT/~&n (printf/'%12.8f')^~/~&m outcomes-$probabilities@n + +#show+ + +results = format simulation 1000000 diff --git a/Task/Probabilistic-choice/XPL0/probabilistic-choice.xpl0 b/Task/Probabilistic-choice/XPL0/probabilistic-choice.xpl0 new file mode 100644 index 0000000000..46037aaa6e --- /dev/null +++ b/Task/Probabilistic-choice/XPL0/probabilistic-choice.xpl0 @@ -0,0 +1,27 @@ +include c:\cxpl\codes; +def Size = 10_000_000; +int Tbl(12+1); +int I, J, N; +real X, S0, S1; +[for J:= 5 to 12 do Tbl(J):= 0; + for I:= 0 to 1_000_000-1 do \generate one million items + [N:= Ran(Size); + for J:= 5 to 11 do + [N:= N - Size/J; + if N < 0 then [Tbl(J):= Tbl(J)+1; J:= 100]; + ]; + if J=12 then Tbl(12):= Tbl(12)+1; + ]; +S0:= 0.0; S1:= 0.0; +for J:= 5 to 11 do + [X:= 1.0/float(J); RlOut(0, X); S0:= S0+X; + X:= float(Tbl(J)) / 1_000_000.0; RlOut(0, X); S1:= S1+X; + CrLf(0); + ]; +X:= 1759.0 / 27720.0; RlOut(0, X); S0:= S0+X; +X:= float(Tbl(12)) / 1_000_000.0; RlOut(0, X); S1:= S1+X; +CrLf(0); +Text(0, " ------- ------- +"); +RlOut(0, S0); RlOut(0, S1); +] diff --git a/Task/Problem-of-Apollonius/0DESCRIPTION b/Task/Problem-of-Apollonius/0DESCRIPTION new file mode 100644 index 0000000000..2740259c4f --- /dev/null +++ b/Task/Problem-of-Apollonius/0DESCRIPTION @@ -0,0 +1,3 @@ +Implement a solution to the Problem of Apollonius ([[wp:Problem_of_Apollonius|description on wikipedia]]) which is the problem of finding the circle that is tangent to three specified circles. There is an [[wp:Problem_of_Apollonius#Algebraic_solutions|algebraic solution]] which is pretty straightforward. The solutions to the example in the code are shown in the image (the red circle is "internally tangent" to all three black circles and the green circle is "externally tangent" to all three black circles). + +[[File:Apollonius.png|200px|Two solutions to the problem of apollonius]] diff --git a/Task/Problem-of-Apollonius/1META.yaml b/Task/Problem-of-Apollonius/1META.yaml new file mode 100644 index 0000000000..a82ad35a1a --- /dev/null +++ b/Task/Problem-of-Apollonius/1META.yaml @@ -0,0 +1,2 @@ +--- +note: arithmetic operations diff --git a/Task/Problem-of-Apollonius/Ada/problem-of-apollonius-1.ada b/Task/Problem-of-Apollonius/Ada/problem-of-apollonius-1.ada new file mode 100644 index 0000000000..075a55183c --- /dev/null +++ b/Task/Problem-of-Apollonius/Ada/problem-of-apollonius-1.ada @@ -0,0 +1,17 @@ +package Apollonius is + type Point is record + X, Y : Long_Float := 0.0; + end record; + + type Circle is record + Center : Point; + Radius : Long_Float := 0.0; + end record; + + type Tangentiality is (External, Internal); + + function Solve_CCC + (Circle_1, Circle_2, Circle_3 : Circle; + T1, T2, T3 : Tangentiality := External) + return Circle; +end Apollonius; diff --git a/Task/Problem-of-Apollonius/Ada/problem-of-apollonius-2.ada b/Task/Problem-of-Apollonius/Ada/problem-of-apollonius-2.ada new file mode 100644 index 0000000000..b601508226 --- /dev/null +++ b/Task/Problem-of-Apollonius/Ada/problem-of-apollonius-2.ada @@ -0,0 +1,86 @@ +with Ada.Numerics.Generic_Elementary_Functions; + +package body Apollonius is + package Math is new Ada.Numerics.Generic_Elementary_Functions + (Long_Float); + + function Solve_CCC + (Circle_1, Circle_2, Circle_3 : Circle; + T1, T2, T3 : Tangentiality := External) + return Circle + is + S1 : Long_Float := 1.0; + S2 : Long_Float := 1.0; + S3 : Long_Float := 1.0; + + X1 : Long_Float renames Circle_1.Center.X; + Y1 : Long_Float renames Circle_1.Center.Y; + R1 : Long_Float renames Circle_1.Radius; + + X2 : Long_Float renames Circle_2.Center.X; + Y2 : Long_Float renames Circle_2.Center.Y; + R2 : Long_Float renames Circle_2.Radius; + + X3 : Long_Float renames Circle_3.Center.X; + Y3 : Long_Float renames Circle_3.Center.Y; + R3 : Long_Float renames Circle_3.Radius; + begin + if T1 = Internal then + S1 := -S1; + end if; + if T2 = Internal then + S2 := -S2; + end if; + if T3 = Internal then + S3 := -S3; + end if; + + declare + V11 : constant Long_Float := 2.0 * X2 - 2.0 * X1; + V12 : constant Long_Float := 2.0 * Y2 - 2.0 * Y1; + V13 : constant Long_Float := + X1 * X1 - X2 * X2 + Y1 * Y1 - Y2 * Y2 - R1 * R1 + R2 * R2; + V14 : constant Long_Float := 2.0 * S2 * R2 - 2.0 * S1 * R1; + + V21 : constant Long_Float := 2.0 * X3 - 2.0 * X2; + V22 : constant Long_Float := 2.0 * Y3 - 2.0 * Y2; + V23 : constant Long_Float := + X2 * X2 - X3 * X3 + Y2 * Y2 - Y3 * Y3 - R2 * R2 + R3 * R3; + V24 : constant Long_Float := 2.0 * S3 * R3 - 2.0 * S2 * R2; + + W12 : constant Long_Float := V12 / V11; + W13 : constant Long_Float := V13 / V11; + W14 : constant Long_Float := V14 / V11; + + W22 : constant Long_Float := V22 / V21 - W12; + W23 : constant Long_Float := V23 / V21 - W13; + W24 : constant Long_Float := V24 / V21 - W14; + + P : constant Long_Float := -W23 / W22; + Q : constant Long_Float := W24 / W22; + M : constant Long_Float := -W12 * P - W13; + N : constant Long_Float := W14 - W12 * Q; + + A : constant Long_Float := N * N + Q * Q - 1.0; + B : constant Long_Float := + 2.0 * M * N - + 2.0 * N * X1 + + 2.0 * P * Q - + 2.0 * Q * Y1 + + 2.0 * S1 * R1; + C : constant Long_Float := + X1 * X1 + + M * M - + 2.0 * M * X1 + + P * P + + Y1 * Y1 - + 2.0 * P * Y1 - + R1 * R1; + + D : constant Long_Float := B * B - 4.0 * A * C; + RS : constant Long_Float := (-B - Math.Sqrt (D)) / (2.0 * A); + begin + return (Center => (X => M + N * RS, Y => P + Q * RS), Radius => RS); + end; + end Solve_CCC; +end Apollonius; diff --git a/Task/Problem-of-Apollonius/Ada/problem-of-apollonius-3.ada b/Task/Problem-of-Apollonius/Ada/problem-of-apollonius-3.ada new file mode 100644 index 0000000000..a6c69a90ea --- /dev/null +++ b/Task/Problem-of-Apollonius/Ada/problem-of-apollonius-3.ada @@ -0,0 +1,25 @@ +with Ada.Text_IO; +with Apollonius; + +procedure Test_Apollonius is + use Apollonius; + package Long_Float_IO is new Ada.Text_IO.Float_IO (Long_Float); + + C1 : constant Circle := (Center => (X => 0.0, Y => 0.0), Radius => 1.0); + C2 : constant Circle := (Center => (X => 4.0, Y => 0.0), Radius => 1.0); + C3 : constant Circle := (Center => (X => 2.0, Y => 4.0), Radius => 2.0); + + R1 : Circle := Solve_CCC (C1, C2, C3, External, External, External); + R2 : Circle := Solve_CCC (C1, C2, C3, Internal, Internal, Internal); +begin + Ada.Text_IO.Put_Line ("R1:"); + Long_Float_IO.Put (R1.Center.X, Aft => 3, Exp => 0); + Long_Float_IO.Put (R1.Center.Y, Aft => 3, Exp => 0); + Long_Float_IO.Put (R1.Radius, Aft => 3, Exp => 0); + Ada.Text_IO.New_Line; + Ada.Text_IO.Put_Line ("R2:"); + Long_Float_IO.Put (R2.Center.X, Aft => 3, Exp => 0); + Long_Float_IO.Put (R2.Center.Y, Aft => 3, Exp => 0); + Long_Float_IO.Put (R2.Radius, Aft => 3, Exp => 0); + Ada.Text_IO.New_Line; +end Test_Apollonius; diff --git a/Task/Problem-of-Apollonius/BBC-BASIC/problem-of-apollonius.bbc b/Task/Problem-of-Apollonius/BBC-BASIC/problem-of-apollonius.bbc new file mode 100644 index 0000000000..d5eb73418b --- /dev/null +++ b/Task/Problem-of-Apollonius/BBC-BASIC/problem-of-apollonius.bbc @@ -0,0 +1,37 @@ + DIM Circle{x, y, r} + DIM Circles{(2)} = Circle{} + Circles{(0)}.x = 0 : Circles{(0)}.y = 0 : Circles{(0)}.r = 1 + Circles{(1)}.x = 4 : Circles{(1)}.y = 0 : Circles{(1)}.r = 1 + Circles{(2)}.x = 2 : Circles{(2)}.y = 4 : Circles{(2)}.r = 2 + + @% = &2030A + REM Solution for internal circle: + PROCapollonius(Circle{}, Circles{()}, -1, -1, -1) + PRINT "Internal: x = ";Circle.x ", y = ";Circle.y ", r = ";Circle.r + REM Solution for external circle: + PROCapollonius(Circle{}, Circles{()}, 1, 1, 1) + PRINT "External: x = ";Circle.x ", y = ";Circle.y ", r = ";Circle.r + END + + DEF PROCapollonius(c{}, c{()}, s0, s1, s2) + LOCAL x0, x1, x2, y0, y1, y2, r0, r1, r2, a, b, c + LOCAL u(), v(), w() : DIM u(2), v(2), w(2) + x0 = c{(0)}.x : y0 = c{(0)}.y : r0 = c{(0)}.r + x1 = c{(1)}.x : y1 = c{(1)}.y : r1 = c{(1)}.r + x2 = c{(2)}.x : y2 = c{(2)}.y : r2 = c{(2)}.r + + u() = 2*y1-2*y0, x0*x0-x1*x1+y0*y0-y1*y1-r0*r0+r1*r1, 2*s1*r1-2*s0*r0 + v() = 2*y2-2*y1, x1*x1-x2*x2+y1*y1-y2*y2-r1*r1+r2*r2, 2*s2*r2-2*s1*r1 + w() = u() / (2*x1 - 2*x0) + u() = v() / (2*x2 - 2*x1) - w() + u() /= u(0) + w(1) -= w(0)*u(1) + w(2) -= w(0)*u(2) + a = w(2)*w(2) + u(2)*u(2) - 1 + b = -2*w(1)*w(2) - 2*w(2)*x1 - 2*u(1)*u(2) - 2*u(2)*y1 + 2*s1*r1 + c = x1*x1 + w(1)*w(1) + 2*w(1)*x1 + u(1)*u(1) + y1*y1 + 2*u(1)*y1 - r1*r1 + + c.r = (-b - SQR(b^2 - 4*a*c)) / (2*a) + c.x = c.r * w(2) - w(1) + c.y = c.r * u(2) - u(1) + ENDPROC diff --git a/Task/Problem-of-Apollonius/C/problem-of-apollonius.c b/Task/Problem-of-Apollonius/C/problem-of-apollonius.c new file mode 100644 index 0000000000..919de3ed4f --- /dev/null +++ b/Task/Problem-of-Apollonius/C/problem-of-apollonius.c @@ -0,0 +1,110 @@ +#include +#include + +#define VERBOSE 0 +#define for3 for(int i = 0; i < 3; i++) + +typedef complex double vec; +typedef struct { vec c; double r; } circ; + +#define re(x) creal(x) +#define im(x) cimag(x) +#define cp(x) re(x), im(x) +#define CPLX "(%6.3f,%6.3f)" +#define CPLX3 CPLX" "CPLX" "CPLX + +double cross(vec a, vec b) { return re(a) * im(b) - im(a) * re(b); } +double abs2(vec a) { return a * conj(a); } + +int apollonius_in(circ aa[], int ss[], int flip, int divert) +{ + vec n[3], x[3], t[3], a, b, center; + int s[3], iter = 0, res = 0; + double diff = 1, diff_old = -1, axb, d, r; + + for3 { + s[i] = ss[i] ? 1 : -1; + x[i] = aa[i].c; + } + + while (diff > 1e-20) { + a = x[0] - x[2], b = x[1] - x[2]; + diff = 0; + axb = -cross(a, b); + d = sqrt(abs2(a) * abs2(b) * abs2(a - b)); + + if (VERBOSE) { + const char *z = 1 + "-0+"; + printf("%c%c%c|%c%c|", + z[s[0]], z[s[1]], z[s[2]], z[flip], z[divert]); + printf(CPLX3, cp(x[0]), cp(x[1]), cp(x[2])); + } + + /* r and center represent an arc through points x[i]. Each step, + we'll deform this arc by pushing or pulling some point on it + towards the edge of each given circle. */ + r = fabs(d / (2 * axb)); + center = (abs2(a)*b - abs2(b)*a) / (2 * axb) * I + x[2]; + + /* maybe the "arc" is actually straight line; then we have two + choices in defining "push" and "pull", so try both */ + if (!axb && flip != -1 && !divert) { + if (!d) { /* generally means circle centers overlap */ + printf("Given conditions confused me.\n"); + return 0; + } + + if (VERBOSE) puts("\n[divert]"); + divert = 1; + res = apollonius_in(aa, ss, -1, 1); + } + + /* if straight line, push dir is its norm; else it's away from center */ + for3 n[i] = axb ? aa[i].c - center : a * I * flip; + for3 t[i] = aa[i].c + n[i] / cabs(n[i]) * aa[i].r * s[i]; + + /* diff: how much tangent points have moved since last iteration */ + for3 diff += abs2(t[i] - x[i]), x[i] = t[i]; + + if (VERBOSE) printf(" %g\n", diff); + + /* keep an eye on the total diff: failing to converge means no solution */ + if (diff >= diff_old && diff_old >= 0) + if (iter++ > 20) return res; + + diff_old = diff; + } + + printf("found: "); + if (axb) printf("circle "CPLX", r = %f\n", cp(center), r); + else printf("line "CPLX3"\n", cp(x[0]), cp(x[1]), cp(x[2])); + + return res + 1; +} + +int apollonius(circ aa[]) +{ + int s[3], i, sum = 0; + for (i = 0; i < 8; i++) { + s[0] = i & 1, s[1] = i & 2, s[2] = i & 4; + + /* internal or external results of a zero-radius circle are the same */ + if (s[0] && !aa[0].r) continue; + if (s[1] && !aa[1].r) continue; + if (s[2] && !aa[2].r) continue; + sum += apollonius_in(aa, s, 1, 0); + } + return sum; +} + +int main() +{ + circ a[3] = {{0, 1}, {4, 1}, {2 + 4 * I, 1}}; + circ b[3] = {{-3, 2}, {0, 1}, {3, 2}}; + circ c[3] = {{-2, 1}, {0, 1}, {2 * I, 1}}; + //circ c[3] = {{0, 1}, {0, 2}, {0, 3}}; <-- a fun one + + puts("set 1"); apollonius(a); + puts("set 2"); apollonius(b); + puts("set 3"); apollonius(c); +} diff --git a/Task/Problem-of-Apollonius/CoffeeScript/problem-of-apollonius-1.coffeescript b/Task/Problem-of-Apollonius/CoffeeScript/problem-of-apollonius-1.coffeescript new file mode 100644 index 0000000000..2be873c87a --- /dev/null +++ b/Task/Problem-of-Apollonius/CoffeeScript/problem-of-apollonius-1.coffeescript @@ -0,0 +1,51 @@ +class Circle + constructor: (@x, @y, @r) -> + +apollonius = (c1, c2, c3, s1=1, s2=1, s3=1) -> + [x1, y1, r1] = [c1.x, c1.y, c1.r] + [x2, y2, r2] = [c2.x, c2.y, c2.r] + [x3, y3, r3] = [c3.x, c3.y, c3.r] + + sq = (n) -> n*n + + v11 = 2*x2 - 2*x1 + v12 = 2*y2 - 2*y1 + v13 = sq(x1) - sq(x2) + sq(y1) - sq(y2) - sq(r1) + sq(r2) + v14 = 2*s2*r2 - 2*s1*r1 + + v21 = 2*x3 - 2*x2 + v22 = 2*y3 - 2*y2 + v23 = sq(x2) - sq(x3) + sq(y2) - sq(y3) - sq(r2) + sq(r3) + v24 = 2*s3*r3 - 2*s2*r2 + + w12 = v12/v11 + w13 = v13/v11 + w14 = v14/v11 + + w22 = v22/v21 - w12 + w23 = v23/v21 - w13 + w24 = v24/v21 - w14 + + p = -w23/w22 + q = w24/w22 + m = -w12*p - w13 + n = w14 - w12*q + + a = sq(n) + sq(q) - 1 + b = 2*m*n - 2*n*x1 + 2*p*q - 2*q*y1 + 2*s1*r1 + c = sq(x1) + sq(m) - 2*m*x1 + sq(p) + sq(y1) - 2*p*y1 - sq(r1) + + d = sq(b) - 4*a*c + rs = (-b - Math.sqrt(d)) / (2*a) + xs = m + n*rs + ys = p + q*rs + + new Circle(xs, ys, rs) + + +console.log c1 = new Circle(0, 0, 1) +console.log c2 = new Circle(2, 4, 2) +console.log c3 = new Circle(4, 0, 1) + +console.log apollonius(c1, c2, c3) +console.log apollonius(c1, c2, c3, -1, -1, -1) diff --git a/Task/Problem-of-Apollonius/CoffeeScript/problem-of-apollonius-2.coffeescript b/Task/Problem-of-Apollonius/CoffeeScript/problem-of-apollonius-2.coffeescript new file mode 100644 index 0000000000..5ed54eff1e --- /dev/null +++ b/Task/Problem-of-Apollonius/CoffeeScript/problem-of-apollonius-2.coffeescript @@ -0,0 +1,6 @@ +> coffee foo.coffee +{ x: 0, y: 0, r: 1 } +{ x: 2, y: 4, r: 2 } +{ x: 4, y: 0, r: 1 } +{ x: 2, y: 2.1, r: 3.9 } +{ x: 2, y: 0.8333333333333333, r: 1.1666666666666667 } diff --git a/Task/Problem-of-Apollonius/D/problem-of-apollonius.d b/Task/Problem-of-Apollonius/D/problem-of-apollonius.d new file mode 100644 index 0000000000..e53867e718 --- /dev/null +++ b/Task/Problem-of-Apollonius/D/problem-of-apollonius.d @@ -0,0 +1,80 @@ +import std.stdio, std.math; + +immutable struct Circle { double x, y, r; } +enum Tangent { externally, internally } + +/** +Solves the Problem of Apollonius (finding a circle tangent to three +other circles in the plane). + +Params: + c1 = First circle of the problem. + c2 = Second circle of the problem. + c3 = Third circle of the problem. + t1 = How is the solution tangent (externally or internally) to c1. + t2 = How is the solution tangent (externally or internally) to c2. + t3 = How is the solution tangent (externally or internally) to c3. + +Returns: The Circle that is tangent to c1, c2 and c3. +*/ +pure nothrow Circle +solveApollonius(in Circle c1, in Circle c2, in Circle c3, + in Tangent t1, in Tangent t2, in Tangent t3) { + alias immutable(double) imd; + imd s1 = (t1 == Tangent.externally) ? 1.0 : -1.0; + imd s2 = (t2 == Tangent.externally) ? 1.0 : -1.0; + imd s3 = (t3 == Tangent.externally) ? 1.0 : -1.0; + + imd v11 = 2 * c2.x - 2 * c1.x; + imd v12 = 2 * c2.y - 2 * c1.y; + imd v13 = c1.x ^^ 2 - c2.x ^^ 2 + + c1.y ^^ 2 - c2.y ^^ 2 - + c1.r ^^ 2 + c2.r ^^ 2; + imd v14 = 2 * s2 * c2.r - 2 * s1 * c1.r; + + imd v21 = 2 * c3.x - 2 * c2.x; + imd v22 = 2 * c3.y - 2 * c2.y; + imd v23 = c2.x ^^ 2 - c3.x ^^ 2 + + c2.y ^^ 2 - c3.y ^^ 2 - + c2.r ^^ 2 + c3.r ^^ 2; + imd v24 = 2 * s3 * c3.r - 2 * s2 * c2.r; + + imd w12 = v12 / v11; + imd w13 = v13 / v11; + imd w14 = v14 / v11; + + imd w22 = v22 / v21 - w12; + imd w23 = v23 / v21 - w13; + imd w24 = v24 / v21 - w14; + + imd P = -w23 / w22; + imd Q = w24 / w22; + imd M = -w12 * P - w13; + imd N = w14 - w12 * Q; + + imd a = N * N + Q ^^ 2 - 1; + imd b = 2 * M * N - 2 * N * c1.x + + 2 * P * Q - 2 * Q * c1.y + + 2 * s1 * c1.r; + imd c = c1.x ^^ 2 + M ^^ 2 - 2 * M * c1.x + + P ^^ 2 + c1.y ^^ 2 - 2 * P * c1.y - c1.r ^^ 2; + + // find a root of a quadratic equation. + // This requires the circle centers not to be e.g. colinear + imd D = b ^^ 2 - 4 * a * c; + imd rs = (-b - sqrt(D)) / (2 * a); + + return Circle(M + N * rs, P + Q * rs, rs); +} + +void main() { + immutable c1 = Circle(0.0, 0.0, 1.0); + immutable c2 = Circle(4.0, 0.0, 1.0); + immutable c3 = Circle(2.0, 4.0, 2.0); + + alias Tangent.externally te; + writeln(solveApollonius(c1, c2, c3, te, te, te)); + + alias Tangent.internally ti; + writeln(solveApollonius(c1, c2, c3, ti, ti, ti)); +} diff --git a/Task/Problem-of-Apollonius/Fortran/problem-of-apollonius.f b/Task/Problem-of-Apollonius/Fortran/problem-of-apollonius.f new file mode 100644 index 0000000000..4b0c72aec3 --- /dev/null +++ b/Task/Problem-of-Apollonius/Fortran/problem-of-apollonius.f @@ -0,0 +1,72 @@ +program Apollonius + implicit none + + integer, parameter :: dp = selected_real_kind(15) + + type circle + real(dp) :: x + real(dp) :: y + real(dp) :: radius + end type + + type(circle) :: c1 , c2, c3, r + + c1 = circle(0.0, 0.0, 1.0) + c2 = circle(4.0, 0.0, 1.0) + c3 = circle(2.0, 4.0, 2.0) + + write(*, "(a,3f12.8))") "External tangent:", SolveApollonius(c1, c2, c3, 1, 1, 1) + write(*, "(a,3f12.8))") "Internal tangent:", SolveApollonius(c1, c2, c3, -1, -1, -1) + +contains + +function SolveApollonius(c1, c2, c3, s1, s2, s3) result(res) + type(circle) :: res + type(circle), intent(in) :: c1, c2, c3 + integer, intent(in) :: s1, s2, s3 + + real(dp) :: x1, x2, x3, y1, y2, y3, r1, r2, r3 + real(dp) :: v11, v12, v13, v14 + real(dp) :: v21, v22, v23, v24 + real(dp) :: w12, w13, w14 + real(dp) :: w22, w23, w24 + real(dp) :: p, q, m, n, a, b, c, det + + x1 = c1%x; x2 = c2%x; x3 = c3%x + y1 = c1%y; y2 = c2%y; y3 = c3%y + r1 = c1%radius; r2 = c2%radius; r3 = c3%radius + + v11 = 2*x2 - 2*x1 + v12 = 2*y2 - 2*y1 + v13 = x1*x1 - x2*x2 + y1*y1 - y2*y2 - r1*r1 + r2*r2 + v14 = 2*s2*r2 - 2*s1*r1 + + v21 = 2*x3 - 2*x2 + v22 = 2*y3 - 2*y2 + v23 = x2*x2 - x3*x3 + y2*y2 - y3*y3 - r2*r2 + r3*r3 + v24 = 2*s3*r3 - 2*s2*r2 + + w12 = v12/v11 + w13 = v13/v11 + w14 = v14/v11 + + w22 = v22/v21-w12 + w23 = v23/v21-w13 + w24 = v24/v21-w14 + + p = -w23/w22 + q = w24/w22 + m = -w12*P - w13 + n = w14 - w12*q + + a = n*n + q*q - 1 + b = 2*m*n - 2*n*x1 + 2*p*q - 2*q*y1 + 2*s1*r1 + c = x1*x1 + m*m - 2*m*x1 + p*p + y1*y1 - 2*p*y1 - r1*r1 + + det = b*b - 4*a*c + res%radius = (-b-sqrt(det)) / (2*a) + res%x = m + n*res%radius + res%y = p + q*res%radius + +end function +end program diff --git a/Task/Problem-of-Apollonius/Go/problem-of-apollonius.go b/Task/Problem-of-Apollonius/Go/problem-of-apollonius.go new file mode 100644 index 0000000000..49b757a449 --- /dev/null +++ b/Task/Problem-of-Apollonius/Go/problem-of-apollonius.go @@ -0,0 +1,64 @@ +package main + +import ( + "fmt" + "math" +) + +type circle struct { + x, y, r float64 +} + +func main() { + c1 := circle{0, 0, 1} + c2 := circle{4, 0, 1} + c3 := circle{2, 4, 2} + fmt.Println(ap(c1, c2, c3, true)) + fmt.Println(ap(c1, c2, c3, false)) +} + +func ap(c1, c2, c3 circle, s bool) circle { + x1sq := c1.x * c1.x + y1sq := c1.y * c1.y + r1sq := c1.r * c1.r + x2sq := c2.x * c2.x + y2sq := c2.y * c2.y + r2sq := c2.r * c2.r + x3sq := c3.x * c3.x + y3sq := c3.y * c3.y + r3sq := c3.r * c3.r + v11 := 2 * (c2.x - c1.x) + v12 := 2 * (c2.y - c1.y) + v13 := x1sq - x2sq + y1sq - y2sq - r1sq + r2sq + v14 := 2 * (c2.r - c1.r) + v21 := 2 * (c3.x - c2.x) + v22 := 2 * (c3.y - c2.y) + v23 := x2sq - x3sq + y2sq - y3sq - r2sq + r3sq + v24 := 2 * (c3.r - c2.r) + if s { + v14 = -v14 + v24 = -v24 + } + w12 := v12 / v11 + w13 := v13 / v11 + w14 := v14 / v11 + w22 := v22/v21 - w12 + w23 := v23/v21 - w13 + w24 := v24/v21 - w14 + p := -w23 / w22 + q := w24 / w22 + m := -w12*p - w13 + n := w14 - w12*q + a := n*n + q*q - 1 + b := m*n - n*c1.x + p*q - q*c1.y + if s { + b -= c1.r + } else { + b += c1.r + } + b *= 2 + c := x1sq + m*m - 2*m*c1.x + p*p + y1sq - 2*p*c1.y - r1sq + d := b*b - 4*a*c + rs := (-b - math.Sqrt(d)) / (2 * a) + return circle{m + n*rs, p + q*rs, rs} +} diff --git a/Task/Problem-of-Apollonius/Haskell/problem-of-apollonius.hs b/Task/Problem-of-Apollonius/Haskell/problem-of-apollonius.hs new file mode 100644 index 0000000000..76f4de3724 --- /dev/null +++ b/Task/Problem-of-Apollonius/Haskell/problem-of-apollonius.hs @@ -0,0 +1,75 @@ +data Circle = Circle { x, y, r :: Double } deriving (Show, Eq) +data Tangent = Externally | Internally deriving Eq + +{-- +Solves the Problem of Apollonius (finding a circle tangent to three +other circles in the plane). + +Params: + c1 = First circle of the problem. + c2 = Second circle of the problem. + c3 = Third circle of the problem. + t1 = How is the solution tangent (externally or internally) to c1. + t2 = How is the solution tangent (externally or internally) to c2. + t3 = How is the solution tangent (externally or internally) to c3. + +Returns: The Circle that is tangent to c1, c2 and c3. +--} +solveApollonius :: Circle -> Circle -> Circle -> + Tangent -> Tangent -> Tangent -> + Circle +solveApollonius c1 c2 c3 t1 t2 t3 = + Circle (m + n * rs) (p + q * rs) rs + where + s1 = if t1 == Externally then 1.0 else -1.0 + s2 = if t2 == Externally then 1.0 else -1.0 + s3 = if t3 == Externally then 1.0 else -1.0 + + v11 = 2 * x c2 - 2 * x c1 + v12 = 2 * y c2 - 2 * y c1 + v13 = x c1 ^ 2 - x c2 ^ 2 + + y c1 ^ 2 - y c2 ^ 2 - + r c1 ^ 2 + r c2 ^ 2 + v14 = 2 * s2 * r c2 - 2 * s1 * r c1 + + v21 = 2 * x c3 - 2 * x c2 + v22 = 2 * y c3 - 2 * y c2 + v23 = x c2 ^ 2 - x c3 ^ 2 + + y c2 ^ 2 - y c3 ^ 2 - + r c2 ^ 2 + r c3 ^ 2; + v24 = 2 * s3 * r c3 - 2 * s2 * r c2 + + w12 = v12 / v11 + w13 = v13 / v11 + w14 = v14 / v11 + + w22 = v22 / v21 - w12 + w23 = v23 / v21 - w13 + w24 = v24 / v21 - w14 + + p = -w23 / w22 + q = w24 / w22 + m = -w12 * p - w13 + n = w14 - w12 * q + + a = n * n + q ^ 2 - 1 + b = 2 * m * n - 2 * n * x c1 + + 2 * p * q - 2 * q * y c1 + + 2 * s1 * r c1 + c = x c1 ^ 2 + m ^ 2 - 2 * m * x c1 + + p ^ 2 + y c1 ^ 2 - 2 * p * y c1 - r c1 ^ 2 + + -- Find a root of a quadratic equation. + -- This requires the circle centers not to be e.g. colinear. + d = b ^ 2 - 4 * a * c + rs = (-b - sqrt d) / (2 * a) + +main = do + let c1 = Circle 0.0 0.0 1.0 + let c2 = Circle 4.0 0.0 1.0 + let c3 = Circle 2.0 4.0 2.0 + let te = Externally + print $ solveApollonius c1 c2 c3 te te te + + let ti = Internally + print $ solveApollonius c1 c2 c3 ti ti ti diff --git a/Task/Problem-of-Apollonius/Icon/problem-of-apollonius.icon b/Task/Problem-of-Apollonius/Icon/problem-of-apollonius.icon new file mode 100644 index 0000000000..1ec13ee901 --- /dev/null +++ b/Task/Problem-of-Apollonius/Icon/problem-of-apollonius.icon @@ -0,0 +1,68 @@ +link graphics + +record circle(x,y,r) +global scale,xoffset,yoffset,yadjust + +procedure main() + +WOpen("size=400,400") | stop("Unable to open Window") +scale := 28 +xoffset := WAttrib("width") / 2 +yoffset := ( yadjust := WAttrib("height")) / 2 + + +WC(c1 := circle(0,0,1),"black") +WC(c2 := circle(4,0,1),"black") +WC(c3 := circle(2,4,2),"black") +WC(c4 := Apollonius(c1,c2,c3,1,1,1),"green") #/ Expects "Circle[x=2.00,y=2.10,r=3.90]" (green circle in image) +WC(c5 := Apollonius(c1,c2,c3,-1,-1,-1),"red") #/ Expects "Circle[x=2.00,y=0.83,r=1.17]" (red circle in image) + + +WAttrib("fg=blue") +DrawLine( 0*scale+xoffset, yadjust-(-1*scale+yoffset), 0*scale+xoffset, yadjust-(4*scale+yoffset) ) +DrawLine( -1*scale+xoffset, yadjust-(0*scale+yoffset), 4*scale+xoffset, yadjust-(0*scale+yoffset) ) +WDone() +end + +procedure WC(c,fg) # write and plot circle +WAttrib("fg="||fg) +DrawCircle(c.x*scale+xoffset, yadjust-(c.y*scale+yoffset), c.r*scale) +return write("Circle(x,y,r) := (",c.x,", ",c.y,", ",c.r,")") +end + +procedure Apollonius(c1,c2,c3,s1,s2,s3) # solve Apollonius + + v11 := 2.*(c2.x - c1.x) + v12 := 2.*(c2.y - c1.y) + v13 := c1.x^2 - c2.x^2 + c1.y^2 - c2.y^2 - c1.r^2 + c2.r^2 + v14 := 2.*(s2*c2.r - s1*c1.r) + + v21 := 2.*(c3.x - c2.x) + v22 := 2.*(c3.y - c2.y) + v23 := c2.x^2 - c3.x^2 + c2.y^2 - c3.y^2 - c2.r^2 + c3.r^2 + v24 := 2.*(s3*c3.r - s2*c2.r) + + w12 := v12/v11 + w13 := v13/v11 + w14 := v14/v11 + + w22 := v22/v21-w12 + w23 := v23/v21-w13 + w24 := v24/v21-w14 + + P := -w23/w22 + Q := w24/w22 + M := -w12*P-w13 + N := w14 - w12*Q + + a := N*N + Q*Q - 1 + b := 2*M*N - 2*N*c1.x + 2*P*Q - 2*Q*c1.y + 2*s1*c1.r + c := c1.x*c1.x + M*M - 2*M*c1.x + P*P + c1.y*c1.y - 2*P*c1.y - c1.r*c1.r + + #// Find a root of a quadratic equation. This requires the circle centers not to be e.g. colinear + D := b*b-4*a*c + rs := (-b-sqrt(D))/(2*a) + xs := M + N * rs + ys := P + Q * rs + return circle(xs,ys,rs) +end diff --git a/Task/Problem-of-Apollonius/J/problem-of-apollonius-1.j b/Task/Problem-of-Apollonius/J/problem-of-apollonius-1.j new file mode 100644 index 0000000000..5fc3cb2891 --- /dev/null +++ b/Task/Problem-of-Apollonius/J/problem-of-apollonius-1.j @@ -0,0 +1,19 @@ +require 'math/misc/amoeba' + +NB.*apollonius v solves Apollonius problems +NB. y is Cx0 Cy0 R0, Cx1 Cy1 R1,: Cx2 Cy2 R2 +NB. x are radius scale factors to control which circles are included +NB. in the common tangent circle. 1 to surround, _1 to exclude. +NB. returns Cxs Cys Rs +apollonius =: verb define"1 _ + 1 apollonius y +: + centers=. 2{."1 y + radii=. x * {:"1 y + goal=. 1e_20 NB. goal simplex volume + dist=. radii + [: +/"1&.:*: centers -"1 ] NB. distances to tangents + 'soln err'=. ([: +/@:*:@, -/~@dist) f. amoeba goal centers + if. err > 10 * goal do. '' return. end. NB. no solution found + avg=. +/ % # + (, avg@dist) soln +) diff --git a/Task/Problem-of-Apollonius/J/problem-of-apollonius-2.j b/Task/Problem-of-Apollonius/J/problem-of-apollonius-2.j new file mode 100644 index 0000000000..0599c4d542 --- /dev/null +++ b/Task/Problem-of-Apollonius/J/problem-of-apollonius-2.j @@ -0,0 +1,7 @@ + ]rctst=: 0 0 1,4 0 1,:2 4 2 NB. Task circles +0 0 1 +4 0 1 +2 4 2 + (_1 _1 _1 ,: 1 1 1) apollonius rctst NB. internally & externally tangent solutions +2 0.83333333 1.1666667 +2 2.1 3.9 diff --git a/Task/Problem-of-Apollonius/Java/problem-of-apollonius.java b/Task/Problem-of-Apollonius/Java/problem-of-apollonius.java new file mode 100644 index 0000000000..178c097604 --- /dev/null +++ b/Task/Problem-of-Apollonius/Java/problem-of-apollonius.java @@ -0,0 +1,93 @@ +public class Circle +{ + public double[] center; + public double radius; + public Circle(double[] center, double radius) + { + this.center = center; + this.radius = radius; + } + public String toString() + { + return String.format("Circle[x=%.2f,y=%.2f,r=%.2f]",center[0],center[1], + radius); + } +} + +public class ApolloniusSolver +{ +/** Solves the Problem of Apollonius (finding a circle tangent to three other + * circles in the plane). The method uses approximately 68 heavy operations + * (multiplication, division, square-roots). + * @param c1 One of the circles in the problem + * @param c2 One of the circles in the problem + * @param c3 One of the circles in the problem + * @param s1 An indication if the solution should be externally or internally + * tangent (+1/-1) to c1 + * @param s2 An indication if the solution should be externally or internally + * tangent (+1/-1) to c2 + * @param s3 An indication if the solution should be externally or internally + * tangent (+1/-1) to c3 + * @return The circle that is tangent to c1, c2 and c3. + */ + public static Circle solveApollonius(Circle c1, Circle c2, Circle c3, int s1, + int s2, int s3) + { + float x1 = c1.center[0]; + float y1 = c1.center[1]; + float r1 = c1.radius; + float x2 = c2.center[0]; + float y2 = c2.center[1]; + float r2 = c2.radius; + float x3 = c3.center[0]; + float y3 = c3.center[1]; + float r3 = c3.radius; + + //Currently optimized for fewest multiplications. Should be optimized for + //readability + float v11 = 2*x2 - 2*x1; + float v12 = 2*y2 - 2*y1; + float v13 = x1*x1 - x2*x2 + y1*y1 - y2*y2 - r1*r1 + r2*r2; + float v14 = 2*s2*r2 - 2*s1*r1; + + float v21 = 2*x3 - 2*x2; + float v22 = 2*y3 - 2*y2; + float v23 = x2*x2 - x3*x3 + y2*y2 - y3*y3 - r2*r2 + r3*r3; + float v24 = 2*s3*r3 - 2*s2*r2; + + float w12 = v12/v11; + float w13 = v13/v11; + float w14 = v14/v11; + + float w22 = v22/v21-w12; + float w23 = v23/v21-w13; + float w24 = v24/v21-w14; + + float P = -w23/w22; + float Q = w24/w22; + float M = -w12*P-w13; + float N = w14 - w12*Q; + + float a = N*N + Q*Q - 1; + float b = 2*M*N - 2*N*x1 + 2*P*Q - 2*Q*y1 + 2*s1*r1; + float c = x1*x1 + M*M - 2*M*x1 + P*P + y1*y1 - 2*P*y1 - r1*r1; + + // Find a root of a quadratic equation. This requires the circle centers not + // to be e.g. colinear + float D = b*b-4*a*c; + float rs = (-b-Math.sqrt(D))/(2*a); + float xs = M + N * rs; + float ys = P + Q * rs; + return new Circle(new double[]{xs,ys}, rs); + } + public static void main(final String[] args) + { + Circle c1 = new Circle(new double[]{0,0}, 1); + Circle c2 = new Circle(new double[]{4,0}, 1); + Circle c3 = new Circle(new double[]{2,4}, 2); + // Expects "Circle[x=2.00,y=2.10,r=3.90]" (green circle in image) + System.out.println(solveApollonius(c1,c2,c3,1,1,1)); + // Expects "Circle[x=2.00,y=0.83,r=1.17]" (red circle in image) + System.out.println(solveApollonius(c1,c2,c3,-1,-1,-1)); + } +} diff --git a/Task/Problem-of-Apollonius/Liberty-BASIC/problem-of-apollonius.liberty b/Task/Problem-of-Apollonius/Liberty-BASIC/problem-of-apollonius.liberty new file mode 100644 index 0000000000..ff7ab2ff98 --- /dev/null +++ b/Task/Problem-of-Apollonius/Liberty-BASIC/problem-of-apollonius.liberty @@ -0,0 +1,54 @@ + circle1$ =" 0.000, 0.000, 1.000" + circle2$ =" 4.000, 0.000, 1.000" + circle3$ =" 2.000, 4.000, 2.000" + + print " x_pos y_pos radius" + print circle1$ + print circle2$ + print circle3$ + print + print ApolloniusSolver$( circle1$, circle2$, circle3$, 1, 1, 1) + print ApolloniusSolver$( circle1$, circle2$, circle3$, -1, -1, -1) + + end + +function ApolloniusSolver$( c1$, c2$, c3$, s1, s2, s3) + x1 =val( word$( c1$, 1, ",")): y1 =val( word$( c1$, 2, ",")): r1 =val( word$( c1$, 3, ",")) + x2 =val( word$( c2$, 1, ",")): y2 =val( word$( c2$, 2, ",")): r2 =val( word$( c2$, 3, ",")) + x3 =val( word$( c3$, 1, ",")): y3 =val( word$( c3$, 2, ",")): r3 =val( word$( c3$, 3, ",")) + + v11 = 2 *x2 -2 *x1 + v12 = 2 *y2 -2*y1 + v13 = x1 *x1 - x2 *x2 + y1 *y1 - y2 *y2 -r1 *r1 +r2 *r2 + v14 = 2 *s2 *r2 -2 *s1 *r1 + + v21 = 2 *x3 -2 *x2 + v22 = 2 *y3 -2*y2 + v23 = x2 *x2 -x3 *x3 + y2 *y2 -y3 *y3 -r2 *r2 +r3 *r3 + v24 = 2 *s3 *r3 - 2 *s2 *r2 + + w12 = v12 /v11 + w13 = v13 /v11 + w14 = v14 /v11 + + w22 = v22 /v21 -w12 + w23 = v23 /v21 -w13 + w24 = v24 /v21 -w14 + + P = 0 -w23 /w22 + Q = w24 /w22 + M = 0 -w12 *P -w13 + N = w14 -w12 *Q + + a = N *N + Q *Q -1 + b = 2 *M *N -2 *N *x1 + 2 *P *Q -2 *Q *y1 +2 *s1 *r1 + c = x1 *x1 +M *M -2 *M *x1 +P *P +y1 *y1 -2 *P *y1 -r1 *r1 + + D = b *b -4 *a *c + + Radius =( 0 -b -Sqr( D)) /( 2 *a) + XPos =M +N *Radius + YPos =P +Q *Radius + + ApolloniusSolver$ =using( "###.###", XPos) +"," +using( "###.###", YPos) +using( "###.###", Radius) +end function diff --git a/Task/Problem-of-Apollonius/MUMPS/problem-of-apollonius.mumps b/Task/Problem-of-Apollonius/MUMPS/problem-of-apollonius.mumps new file mode 100644 index 0000000000..89c0572d6f --- /dev/null +++ b/Task/Problem-of-Apollonius/MUMPS/problem-of-apollonius.mumps @@ -0,0 +1,42 @@ +APOLLONIUS(CIR1,CIR2,CIR3,S1,S2,S3) + ;Circles are passed in as strings with three parts with a "^" separator in the order x^y^r + ;The three circles are CIR1, CIR2, and CIR3 + ;The S1, S2, and S3 parameters determine if the solution will be internally or externally + ;tangent to the circle. (+1 external, -1 internal) + ;CIRR is the circle returned in the same format as the input circles + ; + ;Xn, Yn, and Rn are the values for a circle n - following the precedents from the + ;other examples because doing $Pieces would make this confusing to read + NEW X1,X2,X3,Y1,Y2,Y3,R1,R2,R3,RS,V11,V12,V13,V14,V21,V22,V23,V24,W12,W13,W14,W22,W23,W24,P,M,N,Q,A,B,C,D + NEW CIRR + SET X1=$PIECE(CIR1,"^",1),X2=$PIECE(CIR2,"^",1),X3=$PIECE(CIR3,"^",1) + SET Y1=$PIECE(CIR1,"^",2),Y2=$PIECE(CIR2,"^",2),Y3=$PIECE(CIR3,"^",2) + SET R1=$PIECE(CIR1,"^",3),R2=$PIECE(CIR2,"^",3),R3=$PIECE(CIR3,"^",3) + SET V11=(2*X2)-(2*X1) + SET V12=(2*Y2)-(2*Y1) + SET V13=(X1*X1)-(X2*X2)+(Y1*Y1)-(Y2*Y2)-(R1*R1)+(R2*R2) + SET V14=(2*S2*R2)-(2*S1*R1) + SET V21=(2*X3)-(2*X2) + SET V22=(2*Y3)-(2*Y2) + SET V23=(X2*X2)-(X3*X3)+(Y2*Y2)-(Y3*Y3)-(R2*R2)+(R3*R3) + SET V24=(2*S3*R3)-(2*S2*R2) + SET W12=V12/V11 + SET W13=V13/V11 + SET W14=V14/V11 + SET W22=(V22/V21)-W12 ;Parentheses for insurance - MUMPS evaluates left to right + SET W23=(V23/V21)-W13 + SET W24=(V24/V21)-W14 + SET P=-W23/W22 + SET Q=W24/W22 + SET M=-(W12*P)-W13 + SET N=W14-(W12*Q) + SET A=(N*N)+(Q*Q)-1 + SET B=(2*M*N)-(2*N*X1)+(2*P*Q)-(2*Q*Y1)+(2*S1*R1) + SET C=(X1*X1)+(M*M)+(2*M*X1)+(P*P)+(Y1*Y1)-(2*P*Y1)-(R1*R1) + SET D=(B*B)-(4*A*C) + SET RS=(-B-(D**.5))/(2*A) + SET $PIECE(CIRR,"^",1)=M+(N*RS) + SET $PIECE(CIRR,"^",2)=P+(Q*RS) + SET $PIECE(CIRR,"^",3)=RS + KILL X1,X2,X3,Y1,Y2,Y3,R1,R2,R3,RS,V11,V12,V13,V14,V21,V22,V23,V24,W12,W13,W14,W22,W23,W24,P,M,N,Q,A,B,C,D + QUIT CIRR diff --git a/Task/Problem-of-Apollonius/Mathematica/problem-of-apollonius.math b/Task/Problem-of-Apollonius/Mathematica/problem-of-apollonius.math new file mode 100644 index 0000000000..9119216778 --- /dev/null +++ b/Task/Problem-of-Apollonius/Mathematica/problem-of-apollonius.math @@ -0,0 +1,27 @@ +Apolonius[a1_,b1_,c1_,a2_,b2_,c2_,a3_,b3_,c3_,S1_,S2_ ,S3_ ]:= +Module[{x1=a1,y1=b1,r1=c1,x2=a2,y2=b2,r2=c2,x3=a3,y3=b3,r3=c3,s1=S1,s2=S2,s3=S3}, +v11 = 2*x2 - 2*x1; v12 = 2*y2 - 2*y1; +v13 = x1^2 - x2^2 + y1^2 - y2^2 - r1^2 + r2^2; +v14 = 2*s2*r2 - 2*s1*r1; + +v21 = 2*x3-2*x2 ; v22 = 2*y3 - 2*y2; +v23 = x2^2 - x3^2 + y2^2 - y3^2 - r2^2 + r3^2; +v24 = 2*s3*r3 - 2*s2*r2; + +w12 = v12/v11; w13 = v13/v11; w14 = v14/v11; + +w22 = v22/v21 - w12; +w23 = v23/v21 - w13; +w24 = v24/v21 - w14; + +p = -w23/w22; q=w24/w22; +m = -w12*p - w13; n=w14 - w12*q; + +a = n^2 + q^2-1; +b = 2*m*n - 2*n*x1 + 2*p*q - 2*q*y1 + 2*s1*r1; +c = x1^2+m^2 - 2*m*x1 + p^2+y1^2 - 2*p*y1 - r1^2; + +d= b^2 - 4*a*c; +rs = (-b -Sqrt[d])/(2*a); +xs = m + n*rs; ys = p + q*rs; +Map[N,{xs, ys, rs} ]] diff --git a/Task/Problem-of-Apollonius/OCaml/problem-of-apollonius.ocaml b/Task/Problem-of-Apollonius/OCaml/problem-of-apollonius.ocaml new file mode 100644 index 0000000000..344cd445cf --- /dev/null +++ b/Task/Problem-of-Apollonius/OCaml/problem-of-apollonius.ocaml @@ -0,0 +1,76 @@ +type point = { x:float; y:float } +type circle = { + center: point; + radius: float; +} + +let new_circle ~x ~y ~r = + { center = { x=x; y=y }; + radius = r } + +let print_circle ~c = + Printf.printf "Circle(x=%.2f, y=%.2f, r=%.2f)\n" + c.center.x c.center.y c.radius + +let defxyr c = + (c.center.x, + c.center.y, + c.radius) + +let solve_apollonius ~c1 ~c2 ~c3 + ~s1 ~s2 ~s3 = + let ( * ) = ( *. ) in + let ( / ) = ( /. ) in + let ( + ) = ( +. ) in + let ( - ) = ( -. ) in + + let x1, y1, r1 = defxyr c1 + and x2, y2, r2 = defxyr c2 + and x3, y3, r3 = defxyr c3 in + + let v11 = 2.0 * x2 - 2.0 * x1 + and v12 = 2.0 * y2 - 2.0 * y1 + and v13 = x1*x1 - x2*x2 + y1*y1 - y2*y2 - r1*r1 + r2*r2 + and v14 = (2.0 * s2 * r2) - (2.0 * s1 * r1) + + and v21 = 2.0 * x3 - 2.0 * x2 + and v22 = 2.0 * y3 - 2.0 * y2 + and v23 = x2*x2 - x3*x3 + y2*y2 - y3*y3 - r2*r2 + r3*r3 + and v24 = (2.0 * s3 * r3) - (2.0 * s2 * r2) in + + let w12 = v12 / v11 + and w13 = v13 / v11 + and w14 = v14 / v11 in + + let w22 = v22 / v21 - w12 + and w23 = v23 / v21 - w13 + and w24 = v24 / v21 - w14 in + + let p = -. w23 / w22 + and q = w24 / w22 in + let m = -. w12 * p - w13 + and n = w14 - w12 * q in + + let a = n*n + q*q - 1.0 + and b = 2.0*m*n - 2.0*n*x1 + 2.0*p*q - 2.0*q*y1 + 2.0*s1*r1 + and c = x1*x1 + m*m - 2.0*m*x1 + p*p + y1*y1 - 2.0*p*y1 - r1*r1 in + + let d = b * b - 4.0 * a * c in + let rs = (-. b - (sqrt d)) / (2.0 * a) in + + let xs = m + n * rs + and ys = p + q * rs in + + (new_circle xs ys rs) + +let () = + let c1 = new_circle 0.0 0.0 1.0 + and c2 = new_circle 4.0 0.0 1.0 + and c3 = new_circle 2.0 4.0 2.0 in + + let r1 = solve_apollonius c1 c2 c3 1.0 1.0 1.0 in + print_circle r1; + + let r2 = solve_apollonius c1 c2 c3 (-1.) (-1.) (-1.) in + print_circle r2; +;; diff --git a/Task/Problem-of-Apollonius/Perl-6/problem-of-apollonius.pl6 b/Task/Problem-of-Apollonius/Perl-6/problem-of-apollonius.pl6 new file mode 100644 index 0000000000..4f5a39df6d --- /dev/null +++ b/Task/Problem-of-Apollonius/Perl-6/problem-of-apollonius.pl6 @@ -0,0 +1,53 @@ +class Circle { + has $.x; + has $.y; + has $.r; + method gist { "circle($!x, $!y, $!r)" } +} + +sub circle($x,$y,$r) { Circle.new: :$x, :$y, :$r } + +sub postfix:<²>($x) { $x * $x } + +sub solve-Apollonius([\c1, \c2, \c3], [\s1, \s2, \s3]) { + my \𝑣11 = 2 * c2.x - 2 * c1.x; + my \𝑣12 = 2 * c2.y - 2 * c1.y; + my \𝑣13 = c1.x² - c2.x² + c1.y² - c2.y² - c1.r² + c2.r²; + my \𝑣14 = 2 * s2 * c2.r - 2 * s1 * c1.r; + + my \𝑣21 = 2 * c3.x - 2 * c2.x; + my \𝑣22 = 2 * c3.y - 2 * c2.y; + my \𝑣23 = c2.x² - c3.x² + c2.y² - c3.y² - c2.r² + c3.r²; + my \𝑣24 = 2 * s3 * c3.r - 2 * s2 * c2.r; + + my \𝑤12 = 𝑣12 / 𝑣11; + my \𝑤13 = 𝑣13 / 𝑣11; + my \𝑤14 = 𝑣14 / 𝑣11; + + my \𝑤22 = 𝑣22 / 𝑣21 - 𝑤12; + my \𝑤23 = 𝑣23 / 𝑣21 - 𝑤13; + my \𝑤24 = 𝑣24 / 𝑣21 - 𝑤14; + + my \𝑃 = -𝑤23 / 𝑤22; + my \𝑄 = 𝑤24 / 𝑤22; + my \𝑀 = -𝑤12 * 𝑃 - 𝑤13; + my \𝑁 = 𝑤14 - 𝑤12 * 𝑄; + + my \𝑎 = 𝑁² + 𝑄² - 1; + my \𝑏 = 2 * 𝑀 * 𝑁 - 2 * 𝑁 * c1.x + 2 * 𝑃 * 𝑄 - 2 * 𝑄 * c1.y + 2 * s1 * c1.r; + my \𝑐 = c1.x² + 𝑀² - 2 * 𝑀 * c1.x + 𝑃² + c1.y² - 2 * 𝑃 * c1.y - c1.r²; + + my \𝐷 = 𝑏² - 4 * 𝑎 * 𝑐; + my \rs = (-𝑏 - sqrt 𝐷) / (2 * 𝑎); + + my \xs = 𝑀 + 𝑁 * rs; + my \ys = 𝑃 + 𝑄 * rs; + + circle(xs, ys, rs); +} + +sub MAIN { + my @c = circle(0, 0, 1), circle(4, 0, 1), circle(2, 4, 2); + say solve-Apollonius @c, <1 1 1>; + say solve-Apollonius @c, <-1 -1 -1>; +} diff --git a/Task/Problem-of-Apollonius/PureBasic/problem-of-apollonius.purebasic b/Task/Problem-of-Apollonius/PureBasic/problem-of-apollonius.purebasic new file mode 100644 index 0000000000..7036d7496c --- /dev/null +++ b/Task/Problem-of-Apollonius/PureBasic/problem-of-apollonius.purebasic @@ -0,0 +1,74 @@ +Structure Circle + XPos.f + YPos.f + Radius.f +EndStructure + +Procedure ApolloniusSolver(*c1.Circle,*c2.Circle,*c3.Circle, s1, s2, s3) + Define.f ; This tells the compiler that all non-specified new variables + ; should be of float type (.f). + x1=*c1\XPos: y1=*c1\YPos: r1=*c1\Radius + x2=*c2\XPos: y2=*c2\YPos: r2=*c2\Radius + x3=*c3\XPos: y3=*c3\YPos: r3=*c3\Radius + + v11 = 2*x2 - 2*x1 + v12 = 2*y2 - 2*y1 + v13 = x1*x1 - x2*x2 + y1*y1 - y2*y2 - r1*r1 + r2*r2 + v14 = 2*s2*r2 - 2*s1*r1 + + v21 = 2*x3 - 2*x2 + v22 = 2*y3 - 2*y2 + v23 = x2*x2 - x3*x3 + y2*y2 - y3*y3 - r2*r2 + r3*r3 + v24 = 2*s3*r3 - 2*s2*r2 + + w12 = v12/v11 + w13 = v13/v11 + w14 = v14/v11 + + w22 = v22/v21-w12 + w23 = v23/v21-w13 + w24 = v24/v21-w14 + + P = -w23/w22 + Q = w24/w22 + M = -w12*P-w13 + N = w14-w12*Q + + a = N*N + Q*Q - 1 + b = 2*M*N - 2*N*x1 + 2*P*Q - 2*Q*y1 + 2*s1*r1 + c = x1*x1 + M*M - 2*M*x1 + P*P + y1*y1 - 2*P*y1 - r1*r1 + + D= b*b - 4*a*c + + Define *result.Circle=AllocateMemory(SizeOf(Circle)) + ; Allocate memory for a returned Structure of type Circle. + ; This memory should be freed later but if not, PureBasic’s + ; internal framework will do so when the program shuts down. + If *result + *result\Radius=(-b-Sqr(D))/(2*a) + *result\XPos =M+N * *result\Radius + *result\YPos =P+Q * *result\Radius + EndIf + ProcedureReturn *result ; Sending back a pointer +EndProcedure + +If OpenConsole() + Define.Circle c1, c2, c3 + Define *c.Circle ; '*c' is defined as a pointer to a circle-structure. + c1\Radius=1 + c2\XPos=4: c2\Radius=1 + c3\XPos=2: c3\YPos=4: c3\Radius=2 + + *c=ApolloniusSolver(@c1, @c2, @c3, 1, 1, 1) + If *c ; Verify that *c got allocated + PrintN("Circle [x="+StrF(*c\XPos,2)+", y="+StrF(*c\YPos,2)+", r="+StrF(*c\Radius,2)+"]") + FreeMemory(*c) ; We are done with *c for the first calculation + EndIf + + *c=ApolloniusSolver(@c1, @c2, @c3,-1,-1,-1) + If *c + PrintN("Circle [x="+StrF(*c\XPos,2)+", y="+StrF(*c\YPos,2)+", r="+StrF(*c\Radius,2)+"]") + FreeMemory(*c) + EndIf + Print("Press ENTER to exit"): Input() +EndIf diff --git a/Task/Problem-of-Apollonius/Python/problem-of-apollonius.py b/Task/Problem-of-Apollonius/Python/problem-of-apollonius.py new file mode 100644 index 0000000000..a0f85a1da9 --- /dev/null +++ b/Task/Problem-of-Apollonius/Python/problem-of-apollonius.py @@ -0,0 +1,56 @@ +from collections import namedtuple +import math + +Circle = namedtuple('Circle', 'x, y, r') + +def solveApollonius(c1, c2, c3, s1, s2, s3): + ''' + >>> solveApollonius((0, 0, 1), (4, 0, 1), (2, 4, 2), 1,1,1) + Circle(x=2.0, y=2.1, r=3.9) + >>> solveApollonius((0, 0, 1), (4, 0, 1), (2, 4, 2), -1,-1,-1) + Circle(x=2.0, y=0.8333333333333333, r=1.1666666666666667) + ''' + x1, y1, r1 = c1 + x2, y2, r2 = c2 + x3, y3, r3 = c3 + + v11 = 2*x2 - 2*x1 + v12 = 2*y2 - 2*y1 + v13 = x1*x1 - x2*x2 + y1*y1 - y2*y2 - r1*r1 + r2*r2 + v14 = 2*s2*r2 - 2*s1*r1 + + v21 = 2*x3 - 2*x2 + v22 = 2*y3 - 2*y2 + v23 = x2*x2 - x3*x3 + y2*y2 - y3*y3 - r2*r2 + r3*r3 + v24 = 2*s3*r3 - 2*s2*r2 + + w12 = v12/v11 + w13 = v13/v11 + w14 = v14/v11 + + w22 = v22/v21-w12 + w23 = v23/v21-w13 + w24 = v24/v21-w14 + + P = -w23/w22 + Q = w24/w22 + M = -w12*P-w13 + N = w14 - w12*Q + + a = N*N + Q*Q - 1 + b = 2*M*N - 2*N*x1 + 2*P*Q - 2*Q*y1 + 2*s1*r1 + c = x1*x1 + M*M - 2*M*x1 + P*P + y1*y1 - 2*P*y1 - r1*r1 + + # Find a root of a quadratic equation. This requires the circle centers not to be e.g. colinear + D = b*b-4*a*c + rs = (-b-math.sqrt(D))/(2*a) + + xs = M+N*rs + ys = P+Q*rs + + return Circle(xs, ys, rs) + +if __name__ == '__main__': + c1, c2, c3 = Circle(0, 0, 1), Circle(4, 0, 1), Circle(2, 4, 2) + print(solveApollonius(c1, c2, c3, 1, 1, 1)) #Expects "Circle[x=2.00,y=2.10,r=3.90]" (green circle in image) + print(solveApollonius(c1, c2, c3, -1, -1, -1)) #Expects "Circle[x=2.00,y=0.83,r=1.17]" (red circle in image) diff --git a/Task/Problem-of-Apollonius/REXX/problem-of-apollonius.rexx b/Task/Problem-of-Apollonius/REXX/problem-of-apollonius.rexx new file mode 100644 index 0000000000..0877cda329 --- /dev/null +++ b/Task/Problem-of-Apollonius/REXX/problem-of-apollonius.rexx @@ -0,0 +1,44 @@ +/*REXX program to solve the problem of Apollonius, named after the */ +/* Greek, Apollonius of Perga [Pergaeus] (circa 262 BC ──► 190 BC).*/ + +w=15; numeric digits w /*width used to display numbers. */ +c1.x=0; c1.y=0; c1.r=1 +c2.x=4; c2.y=0; c2.r=1 +c3.x=2; c3.y=4; c3.r=2 +call tell 'external tangent:', solveApollonius( 1, 1, 1) +call tell 'internal tangent:', solveApollonius(-1,-1,-1) +exit /*stick a fork in it, we're done.*/ + +/*──────────────────────────────────SOLVEAPOLLONIUS subroutine──────────*/ +/*───────────────────this code should be covered with a very think tarp.*/ +solveApollonius: arg s1,s2,s3 /*internal or external tangent ? */ +numeric digits digits()*3 /*reduce rounding: use triple dig*/ +x1=c1.x; x2=c2.x; x3=c3.x +y1=c1.y; y2=c2.y; y3=c3.y +r1=c1.r; r2=c2.r; r3=c3.r +va=2*x2-2*x1; vb=2*y2-2*y1; vc=x1*x1-x2*x2+y1*y1-y2*y2-r1*r1+r2*r2 +vd=2*s2*r2-2*s1*r1; ve=2*x3-2*x2; vf=2*y3-2*y2 +vg=x2*x2-x3*x3+y2*y2-y3*y3-r2*r2+r3*r3; vh=2*s3*r3-2*s2*r2 +vj=vb/va; vk=vc/va; vm=vd/va +vn=vf/ve-vj; vp=vg/ve-vk; vr=vh/ve-vm; +p=-vp/vn +q= vr/vn +m=-vj*p-vk +n=vm-vj*q +a=n*n+q*q-1 +b=2*m*n-2*n*x1+2*p*q-2*q*y1+2*s1*r1 +c=x1*x1+m*m-2*m*x1+p*p+y1*y1-2*p*y1-r1*r1 +_=b*b-4*a*c; $.r=(-b-sqrt(_))/(a+a); $.x=m+n*$.r; $.y=p+q*$.r +return $.x $.y $.r /*return with the money. */ + +/*──────────────────────────────────SQRT subroutine──────────────────────────*/ +sqrt: procedure; parse arg x; if x=0 then return 0;d=digits();numeric digits 11 + g=.sqGuess(); 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 + +.sqGuess: if x<0 then say 'negative number' x; numeric form; m.=11 + p=d+d%4+2; parse value format(x,2,1,,0) 'E0' with g 'E' _ .; return g*.5'E'_%2 + +/*──────────────────────────────────TELL subroutine─────────────────────*/ +tell: parse arg _,a b c; say _ left(a/1,w) left(b/1,w) left(c/1,w); return + /*dividing by 1 reformats #s to W*/ diff --git a/Task/Problem-of-Apollonius/Ruby/problem-of-apollonius.rb b/Task/Problem-of-Apollonius/Ruby/problem-of-apollonius.rb new file mode 100644 index 0000000000..d473c86a71 --- /dev/null +++ b/Task/Problem-of-Apollonius/Ruby/problem-of-apollonius.rb @@ -0,0 +1,54 @@ +class Circle + def initialize(x, y, r) + @x, @y, @r = [x, y, r].map(&:to_f) + end + attr_reader :x, :y, :r + + def self.apollonius(c1, c2, c3, s1=1, s2=1, s3=1) + x1, y1, r1 = [c1.x, c1.y, c1.r] + x2, y2, r2 = [c2.x, c2.y, c2.r] + x3, y3, r3 = [c3.x, c3.y, c3.r] + + v11 = 2*x2 - 2*x1 + v12 = 2*y2 - 2*y1 + v13 = x1**2 - x2**2 + y1**2 - y2**2 - r1**2 + r2**2 + v14 = 2*s2*r2 - 2*s1*r1 + + v21 = 2*x3 - 2*x2 + v22 = 2*y3 - 2*y2 + v23 = x2**2 - x3**2 + y2**2 - y3**2 - r2**2 + r3**2 + v24 = 2*s3*r3 - 2*s2*r2 + + w12 = v12/v11 + w13 = v13/v11 + w14 = v14/v11 + + w22 = v22/v21 - w12 + w23 = v23/v21 - w13 + w24 = v24/v21 - w14 + + p = -w23/w22 + q = w24/w22 + m = -w12*p - w13 + n = w14 - w12*q + + a = n**2 + q**2 - 1 + b = 2*m*n - 2*n*x1 + 2*p*q - 2*q*y1 + 2*s1*r1 + c = x1**2 + m**2 - 2*m*x1 + p**2 + y1**2 - 2*p*y1 - r1**2 + + d = b**2 - 4*a*c + rs = (-b - Math.sqrt(d)) / (2*a) + xs = m + n*rs + ys = p + q*rs + + return self.new(xs, ys, rs) + end +end + + +p c1 = Circle.new(0, 0, 1) +p c2 = Circle.new(2, 4, 2) +p c3 = Circle.new(4, 0, 1) + +p Circle.apollonius(c1, c2, c3) +p Circle.apollonius(c1, c2, c3, -1, -1, -1) diff --git a/Task/Problem-of-Apollonius/Scala/problem-of-apollonius.scala b/Task/Problem-of-Apollonius/Scala/problem-of-apollonius.scala new file mode 100644 index 0000000000..789e612f42 --- /dev/null +++ b/Task/Problem-of-Apollonius/Scala/problem-of-apollonius.scala @@ -0,0 +1,81 @@ +object ApolloniusSolver extends App { + case class Circle(x: Double, y: Double, r: Double) + object Tangent extends Enumeration { + type Tangent = Value + val intern = Value(-1) + val extern = Value(1) + } + + import Tangent._ + import scala.Math._ + + val solveApollonius: (Circle, Circle, Circle, Triple[Tangent, Tangent, Tangent]) => Circle = (c1, c2, c3, tangents) => { + val fv: (Circle, Circle, Int, Int) => Tuple4[Double, Double, Double, Double] = (c1, c2, s1, s2) => { + val v11 = 2 * c2.x - 2 * c1.x + val v12 = 2 * c2.y - 2 * c1.y + val v13 = pow(c1.x, 2) - pow(c2.x, 2) + pow(c1.y, 2) - pow(c2.y, 2) - pow(c1.r, 2) + pow(c2.r, 2) + val v14 = 2 * s2 * c2.r - 2 * s1 * c1.r + Tuple4(v11, v12, v13, v14) + } + val (s1, s2, s3) = (tangents._1.id, tangents._2.id, tangents._3.id) + + val (v11, v12, v13, v14) = fv(c1, c2, s1, s2) + val (v21, v22, v23, v24) = fv(c2, c3, s2, s3) + + val w12 = v12 / v11 + val w13 = v13 / v11 + val w14 = v14 / v11 + + val w22 = v22 / v21 - w12 + val w23 = v23 / v21 - w13 + val w24 = v24 / v21 - w14 + + val P = -w23 / w22 + val Q = w24 / w22 + val M = -w12 * P - w13 + val N = w14 - w12 * Q + + val a = N*N + Q*Q - 1 + val b = 2*M*N - 2*N*c1.x + + 2*P*Q - 2*Q*c1.y + + 2*s1*c1.r + val c = pow(c1.x, 2) + M*M - 2*M*c1.x + + P*P + pow(c1.y, 2) - 2*P*c1.y - pow(c1.r, 2) + + // Find a root of a quadratic equation. This requires the circle centers not to be e.g. colinear + val D = b*b - 4*a*c + val rs = (-b - sqrt(D)) / (2*a) + + Circle(x=M + N*rs, y=P + Q*rs, r=rs) + } + + val c1 = Circle(x=0.0, y=0.0, r=1.0) + val c2 = Circle(x=4.0, y=0.0, r=1.0) + val c3 = Circle(x=2.0, y=4.0, r=2.0) + + println("c1: "+c1) + println("c2: "+c2) + println("c3: "+c3) + + println{ + val tangents = Triple(intern, intern, intern) + "red circle: tangents="+tangents+" cs=" + solveApollonius(c1, c2, c3, tangents) + } + println{ + val tangents = Triple(extern, extern, extern) + "green circle: tangents="+tangents+" cs=" + solveApollonius(c1, c2, c3, tangents) + } + + println("all combinations:") + for ( ti <- Tangent.values) + for ( tj <- Tangent.values) + for ( tk <- Tangent.values) { + println{ + val format: Circle => String = c => { + "Circle(x=%8.5f, y=%8.5f, r=%8.5f)".format(c.x, c.y, c.r) + } + val tangents = Triple(ti, tj, tk) + "tangents: " + tangents + " -> cs=" + format(solveApollonius(c1, c2, c3, tangents)) + } + } +} diff --git a/Task/Problem-of-Apollonius/Tcl/problem-of-apollonius-1.tcl b/Task/Problem-of-Apollonius/Tcl/problem-of-apollonius-1.tcl new file mode 100644 index 0000000000..b8d5109e83 --- /dev/null +++ b/Task/Problem-of-Apollonius/Tcl/problem-of-apollonius-1.tcl @@ -0,0 +1,56 @@ +package require TclOO; # Just so we can make a circle class + +oo::class create circle { + variable X Y Radius + constructor {x y radius} { + namespace import ::tcl::mathfunc::double + set X [double $x]; set Y [double $y]; set Radius [double $radius] + } + method values {} {list $X $Y $Radius} + method format {} { + format "Circle\[o=(%.2f,%.2f),r=%.2f\]" $X $Y $Radius + } +} + +proc solveApollonius {c1 c2 c3 {s1 1} {s2 1} {s3 1}} { + if {abs($s1)!=1||abs($s2)!=1||abs($s3)!=1} { + error "wrong sign; must be 1 or -1" + } + + lassign [$c1 values] x1 y1 r1 + lassign [$c2 values] x2 y2 r2 + lassign [$c3 values] x3 y3 r3 + + set v11 [expr {2*($x2 - $x1)}] + set v12 [expr {2*($y2 - $y1)}] + set v13 [expr {$x1**2 - $x2**2 + $y1**2 - $y2**2 - $r1**2 + $r2**2}] + set v14 [expr {2*($s2*$r2 - $s1*$r1)}] + + set v21 [expr {2*($x3 - $x2)}] + set v22 [expr {2*($y3 - $y2)}] + set v23 [expr {$x2**2 - $x3**2 + $y2**2 - $y3**2 - $r2**2 + $r3**2}] + set v24 [expr {2*($s3*$r3 - $s2*$r2)}] + + set w12 [expr {$v12 / $v11}] + set w13 [expr {$v13 / $v11}] + set w14 [expr {$v14 / $v11}] + + set w22 [expr {$v22 / $v21 - $w12}] + set w23 [expr {$v23 / $v21 - $w13}] + set w24 [expr {$v24 / $v21 - $w14}] + + set P [expr {-$w23 / $w22}] + set Q [expr {$w24 / $w22}] + set M [expr {-$w12 * $P - $w13}] + set N [expr {$w14 - $w12 * $Q}] + + set a [expr {$N**2 + $Q**2 - 1}] + set b [expr {2*($M*$N - $N*$x1 + $P*$Q - $Q*$y1 + $s1*$r1)}] + set c [expr {($x1-$M)**2 + ($y1-$P)**2 - $r1**2}] + + set rs [expr {(-$b - sqrt($b**2 - 4*$a*$c)) / (2*$a)}] + set xs [expr {$M + $N*$rs}] + set ys [expr {$P + $Q*$rs}] + + return [circle new $xs $ys $rs] +} diff --git a/Task/Problem-of-Apollonius/Tcl/problem-of-apollonius-2.tcl b/Task/Problem-of-Apollonius/Tcl/problem-of-apollonius-2.tcl new file mode 100644 index 0000000000..5636d68224 --- /dev/null +++ b/Task/Problem-of-Apollonius/Tcl/problem-of-apollonius-2.tcl @@ -0,0 +1,7 @@ +set c1 [circle new 0 0 1] +set c2 [circle new 4 0 1] +set c3 [circle new 2 4 2] +set sA [solveApollonius $c1 $c2 $c3] +set sB [solveApollonius $c1 $c2 $c3 -1 -1 -1] +puts [$sA format] +puts [$sB format] diff --git a/Task/Program-name/0DESCRIPTION b/Task/Program-name/0DESCRIPTION new file mode 100644 index 0000000000..e065377177 --- /dev/null +++ b/Task/Program-name/0DESCRIPTION @@ -0,0 +1,7 @@ +The task is to programmatically obtain the name used to invoke the program. (For example determine whether the user ran "python hello.py", or "python hellocaller.py", a program importing the code from "hello.py".) + +Sometimes a [[multiline shebang]] is necessary in order to provide the script name to a language's internal ARGV. + +See also [[Command-line arguments]] + +Examples from [https://github.com/mcandre/scriptname GitHub]. diff --git a/Task/Program-name/1META.yaml b/Task/Program-name/1META.yaml new file mode 100644 index 0000000000..88792fbb77 --- /dev/null +++ b/Task/Program-name/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Initialization +note: Basic language learning diff --git a/Task/Program-name/Ada/program-name.ada b/Task/Program-name/Ada/program-name.ada new file mode 100644 index 0000000000..8ab715d351 --- /dev/null +++ b/Task/Program-name/Ada/program-name.ada @@ -0,0 +1,6 @@ +with Ada.Command_Line, Ada.Text_IO; + +procedure Command_Name is +begin + Ada.Text_IO.Put_Line(Ada.Command_Line.Command_Name); +end Command_Name; diff --git a/Task/Program-name/AutoHotkey/program-name.ahk b/Task/Program-name/AutoHotkey/program-name.ahk new file mode 100644 index 0000000000..b57054ae46 --- /dev/null +++ b/Task/Program-name/AutoHotkey/program-name.ahk @@ -0,0 +1 @@ +MsgBox, % A_ScriptName diff --git a/Task/Program-name/BASIC/program-name-1.basic b/Task/Program-name/BASIC/program-name-1.basic new file mode 100644 index 0000000000..015ddad6ff --- /dev/null +++ b/Task/Program-name/BASIC/program-name-1.basic @@ -0,0 +1 @@ +appname = COMMAND$(0) diff --git a/Task/Program-name/BASIC/program-name-2.basic b/Task/Program-name/BASIC/program-name-2.basic new file mode 100644 index 0000000000..4f2e5c5c88 --- /dev/null +++ b/Task/Program-name/BASIC/program-name-2.basic @@ -0,0 +1 @@ +appname = *__FB_ARGV__(0) diff --git a/Task/Program-name/BBC-BASIC/program-name.bbc b/Task/Program-name/BBC-BASIC/program-name.bbc new file mode 100644 index 0000000000..7bded6eed5 --- /dev/null +++ b/Task/Program-name/BBC-BASIC/program-name.bbc @@ -0,0 +1,2 @@ + SYS "GetCommandLine" TO cl% + PRINT $$cl% diff --git a/Task/Program-name/C++/program-name.cpp b/Task/Program-name/C++/program-name.cpp new file mode 100644 index 0000000000..6e9cf41f53 --- /dev/null +++ b/Task/Program-name/C++/program-name.cpp @@ -0,0 +1,10 @@ +#include + +using namespace std; + +int main(int argc, char **argv) { + char *program = argv[0]; + cout << "Program: " << program << endl; + + return 0; +} diff --git a/Task/Program-name/C/program-name-1.c b/Task/Program-name/C/program-name-1.c new file mode 100644 index 0000000000..3d2f7d7463 --- /dev/null +++ b/Task/Program-name/C/program-name-1.c @@ -0,0 +1,7 @@ +#include + +int main(int argc, char **argv) { + printf("Executable: %s\n", argv[0]); + + return 0; +} diff --git a/Task/Program-name/C/program-name-2.c b/Task/Program-name/C/program-name-2.c new file mode 100644 index 0000000000..908cf38bbc --- /dev/null +++ b/Task/Program-name/C/program-name-2.c @@ -0,0 +1,8 @@ +#include + +int main() +{ + printf("This code was in file %s in function %s, at line %d\n",\ + __FILE__, __FUNCTION__, __LINE__); + return 0; +} diff --git a/Task/Program-name/C/program-name-3.c b/Task/Program-name/C/program-name-3.c new file mode 100644 index 0000000000..94755ba393 --- /dev/null +++ b/Task/Program-name/C/program-name-3.c @@ -0,0 +1,37 @@ +/* myname.c */ + +#include +#include /* struct kinfo_proc */ +#include +#include /* O_RDONLY */ +#include +#include /* _POSIX2_LINE_MAX */ +#include + +int +main(int argc, char **argv) { + extern char *__progname; /* from crt0.o */ + + struct kinfo_proc *procs; + kvm_t *kd; + int cnt; + char errbuf[_POSIX2_LINE_MAX]; + + printf("argv[0]: %s\n", argv[0]); + printf("__progname: %s\n", __progname); + + kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, errbuf); + if (kd == NULL) + errx(1, "%s", errbuf); + procs = kvm_getprocs(kd, KERN_PROC_PID, getpid(), + sizeof procs[0], &cnt); + if (procs == NULL) + errx(1, "%s", kvm_geterr(kd)); + if (cnt != 1) + errx(1, "impossible"); + + printf("p_comm: %s\n", procs[0].p_comm); + + kvm_close(kd); + return 0; +} diff --git a/Task/Program-name/C/program-name-4.c b/Task/Program-name/C/program-name-4.c new file mode 100644 index 0000000000..4778284154 --- /dev/null +++ b/Task/Program-name/C/program-name-4.c @@ -0,0 +1,57 @@ +#include +#include +#include + +/* + * Returns the path to the current executable file, in a newly + * allocated buffer. Use free() to free it. + */ +wchar_t * +exepath(void) +{ + wchar_t *buf, *newbuf; + long blen, flen; + + /* + * Most paths fit in MAX_PATH == 260 characters, but very + * long UNC paths might require a larger buffer. + */ + buf = NULL; + for (blen = MAX_PATH; 1; blen += MAX_PATH) { + /* Enlarge buffer. */ + newbuf = realloc(buf, blen * sizeof buf[0]); + if (newbuf == NULL) { + free(buf); + return NULL; + } + buf = newbuf; + + flen = GetModuleFileNameW(NULL, buf, blen); + if (flen == 0) { + free(buf); + return NULL; + } + if (flen < blen) + return buf; + } +} + +/* + * Print the path to this executable. + */ +int +main() +{ + wchar_t *path; + + path = exepath(); + if (path == NULL) { + wprintf(L"Sorry, an error occured.\n"); + return 1; + } + + wprintf(L"Path to executable: %ls\n", path); + + free(path); + return 0; +} diff --git a/Task/Program-name/Clojure/program-name.clj b/Task/Program-name/Clojure/program-name.clj new file mode 100644 index 0000000000..8f57f37a7c --- /dev/null +++ b/Task/Program-name/Clojure/program-name.clj @@ -0,0 +1,12 @@ +":";exec lein exec $0 ${1+"$@"} +":";exit + +(ns scriptname + (:gen-class)) + +(defn -main [& args] + (let [program (first *command-line-args*)] + (println "Program:" program))) + +(when (.contains (first *command-line-args*) *source-path*) + (apply -main (rest *command-line-args*))) diff --git a/Task/Program-name/Common-Lisp/program-name-1.lisp b/Task/Program-name/Common-Lisp/program-name-1.lisp new file mode 100644 index 0000000000..580129d898 --- /dev/null +++ b/Task/Program-name/Common-Lisp/program-name-1.lisp @@ -0,0 +1,6 @@ +;;; Play nice with shebangs +(set-dispatch-macro-character #\# #\! + (lambda (stream character n) + (declare (ignore character n)) + (read-line stream nil nil t) + nil)) diff --git a/Task/Program-name/Common-Lisp/program-name-2.lisp b/Task/Program-name/Common-Lisp/program-name-2.lisp new file mode 100644 index 0000000000..17ab9bbe1c --- /dev/null +++ b/Task/Program-name/Common-Lisp/program-name-2.lisp @@ -0,0 +1,30 @@ +#!/bin/sh +#| +exec clisp -q -q $0 $0 ${1+"$@"} +exit +|# + +;;; Usage: ./scriptname.lisp + +(defun main (args) + (let ((program (car args))) + (format t "Program: ~a~%" program) + (quit))) + +;;; With help from Francois-Rene Rideau +;;; http://tinyurl.com/cli-args +(let ((args + #+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* + )) + + (if (member (pathname-name *load-truename*) + args + :test #'(lambda (x y) (search x y :test #'equalp))) + (main args))) diff --git a/Task/Program-name/D/program-name-1.d b/Task/Program-name/D/program-name-1.d new file mode 100644 index 0000000000..44c8e34c3c --- /dev/null +++ b/Task/Program-name/D/program-name-1.d @@ -0,0 +1,7 @@ +#!/usr/bin/env rdmd + +import std.stdio; + +void main(in string[] args) { + writeln("Program: ", args[0]); +} diff --git a/Task/Program-name/D/program-name-2.d b/Task/Program-name/D/program-name-2.d new file mode 100644 index 0000000000..e6560e8202 --- /dev/null +++ b/Task/Program-name/D/program-name-2.d @@ -0,0 +1,3 @@ +$ dmd scriptname.d +$ ./scriptname +Program: ./scriptname diff --git a/Task/Program-name/D/program-name-3.d b/Task/Program-name/D/program-name-3.d new file mode 100644 index 0000000000..abb0ec6514 --- /dev/null +++ b/Task/Program-name/D/program-name-3.d @@ -0,0 +1,2 @@ +$ ./scriptname.d +Program: /tmp/.rdmd/Users/andrew/Desktop/src/scriptname/scriptname.d.D3B32385A31B968A3CF8CAF1E1426E5F diff --git a/Task/Program-name/Dart/program-name.dart b/Task/Program-name/Dart/program-name.dart new file mode 100644 index 0000000000..bd187d1468 --- /dev/null +++ b/Task/Program-name/Dart/program-name.dart @@ -0,0 +1,6 @@ +#!/usr/bin/env dart + +main() { + var program = new Options().script; + print("Program: ${program}"); +} diff --git a/Task/Program-name/Delphi/program-name.delphi b/Task/Program-name/Delphi/program-name.delphi new file mode 100644 index 0000000000..79b2a07eb6 --- /dev/null +++ b/Task/Program-name/Delphi/program-name.delphi @@ -0,0 +1,8 @@ +program ProgramName; + +{$APPTYPE CONSOLE} + +begin + Writeln('Program name: ' + ParamStr(0)); + Writeln('Command line: ' + CmdLine); +end. diff --git a/Task/Program-name/Emacs-Lisp/program-name.l b/Task/Program-name/Emacs-Lisp/program-name.l new file mode 100644 index 0000000000..f011764405 --- /dev/null +++ b/Task/Program-name/Emacs-Lisp/program-name.l @@ -0,0 +1,8 @@ +:;exec emacs -batch -l $0 -f main $* + +;;; Shebang from John Swaby +;;; http://www.emacswiki.org/emacs/EmacsScripts + +(defun main () + (let ((program (nth 2 command-line-args))) + (message "Program: %s" program))) diff --git a/Task/Program-name/Erlang/program-name.erl b/Task/Program-name/Erlang/program-name.erl new file mode 100644 index 0000000000..73deffc821 --- /dev/null +++ b/Task/Program-name/Erlang/program-name.erl @@ -0,0 +1,5 @@ +-module(scriptname). + +main(_) -> + Program = ?FILE, + io:format("Program: ~s~n", [Program]). diff --git a/Task/Program-name/Euphoria/program-name.euphoria b/Task/Program-name/Euphoria/program-name.euphoria new file mode 100644 index 0000000000..227c7518f7 --- /dev/null +++ b/Task/Program-name/Euphoria/program-name.euphoria @@ -0,0 +1,2 @@ +constant cmd = command_line() +puts(1,cmd[2]) diff --git a/Task/Program-name/Factor/program-name.factor b/Task/Program-name/Factor/program-name.factor new file mode 100644 index 0000000000..f50fc2d0b4 --- /dev/null +++ b/Task/Program-name/Factor/program-name.factor @@ -0,0 +1,8 @@ +#! /usr/bin/env factor + +USING: namespaces io command-line ; +IN: scriptname + +: main ( -- ) script get print ; + +MAIN: main diff --git a/Task/Program-name/Forth/program-name.fth b/Task/Program-name/Forth/program-name.fth new file mode 100644 index 0000000000..5522adfef2 --- /dev/null +++ b/Task/Program-name/Forth/program-name.fth @@ -0,0 +1,2 @@ +0 arg type cr \ gforth or gforth-fast, for example +1 arg type cr \ name of script diff --git a/Task/Program-name/Go/program-name.go b/Task/Program-name/Go/program-name.go new file mode 100644 index 0000000000..1f41720b22 --- /dev/null +++ b/Task/Program-name/Go/program-name.go @@ -0,0 +1,10 @@ +package main + +import ( + "fmt" + "os" +) + +func main() { + fmt.Println("Program:", os.Args[0]) +} diff --git a/Task/Program-name/Groovy/program-name-1.groovy b/Task/Program-name/Groovy/program-name-1.groovy new file mode 100644 index 0000000000..6a6cfc4055 --- /dev/null +++ b/Task/Program-name/Groovy/program-name-1.groovy @@ -0,0 +1,5 @@ +#!/usr/bin/env groovy + +def program = getClass().protectionDomain.codeSource.location.path + +println "Program: " + program diff --git a/Task/Program-name/Groovy/program-name-2.groovy b/Task/Program-name/Groovy/program-name-2.groovy new file mode 100644 index 0000000000..22495753ce --- /dev/null +++ b/Task/Program-name/Groovy/program-name-2.groovy @@ -0,0 +1 @@ +println this.class.getName() diff --git a/Task/Program-name/Haskell/program-name.hs b/Task/Program-name/Haskell/program-name.hs new file mode 100644 index 0000000000..d5c6272a1c --- /dev/null +++ b/Task/Program-name/Haskell/program-name.hs @@ -0,0 +1,4 @@ +import System (getProgName) + +main :: IO () +main = getProgName >>= putStrLn . ("Program: " ++) diff --git a/Task/Program-name/Icon/program-name.icon b/Task/Program-name/Icon/program-name.icon new file mode 100644 index 0000000000..d48cae0791 --- /dev/null +++ b/Task/Program-name/Icon/program-name.icon @@ -0,0 +1,3 @@ +procedure main() +write(&progname) # obtain and write out the program name from the keyword &progname +end diff --git a/Task/Program-name/Io/program-name.io b/Task/Program-name/Io/program-name.io new file mode 100644 index 0000000000..f3995d8b81 --- /dev/null +++ b/Task/Program-name/Io/program-name.io @@ -0,0 +1,9 @@ +#!/usr/bin/env io + +main := method( + program := System args at(0) + + ("Program: " .. program) println +) + +if (System args size > 0 and System args at(0) containsSeq("scriptname"), main) diff --git a/Task/Program-name/J/program-name.j b/Task/Program-name/J/program-name.j new file mode 100644 index 0000000000..3f539caf1e --- /dev/null +++ b/Task/Program-name/J/program-name.j @@ -0,0 +1,13 @@ +#!/usr/bin/env jconsole + +program =: monad : 0 + if. (#ARGV) > 1 do. + > 1 { ARGV + else. + 'Interpreted' + end. +) + +echo 'Program: ', program 0 + +exit '' diff --git a/Task/Program-name/Java/program-name-1.java b/Task/Program-name/Java/program-name-1.java new file mode 100644 index 0000000000..f43411b42b --- /dev/null +++ b/Task/Program-name/Java/program-name-1.java @@ -0,0 +1,6 @@ +public class ScriptName { + public static void main(String[] args) { + String program = System.getProperty("sun.java.command").split(" ")[0]; + System.out.println("Program: " + program); + } +} diff --git a/Task/Program-name/Java/program-name-2.java b/Task/Program-name/Java/program-name-2.java new file mode 100644 index 0000000000..348d7b7195 --- /dev/null +++ b/Task/Program-name/Java/program-name-2.java @@ -0,0 +1,6 @@ +public class ScriptName { + public static void main(String[] args) { + Class c = new Object(){}.getClass().getEnclosingClass(); + System.out.println("Program: " + c.getName()); + } +} diff --git a/Task/Program-name/Java/program-name-3.java b/Task/Program-name/Java/program-name-3.java new file mode 100644 index 0000000000..3ccd403b61 --- /dev/null +++ b/Task/Program-name/Java/program-name-3.java @@ -0,0 +1,6 @@ +public class ScriptName { + public static void main(String[] args) { + Class c = System.getSecurityManager().getClassContext()[0]; + System.out.println("Program: " + c.getName()); + } +} diff --git a/Task/Program-name/Java/program-name-4.java b/Task/Program-name/Java/program-name-4.java new file mode 100644 index 0000000000..bdc1ea57e9 --- /dev/null +++ b/Task/Program-name/Java/program-name-4.java @@ -0,0 +1,6 @@ +public class ScriptName { + public static void main(String[] args) { + String program = Thread.currentThread().getStackTrace()[1].getClassName(); + System.out.println("Program: " + program); + } +} diff --git a/Task/Program-name/JavaScript/program-name-1.js b/Task/Program-name/JavaScript/program-name-1.js new file mode 100644 index 0000000000..65194d2d09 --- /dev/null +++ b/Task/Program-name/JavaScript/program-name-1.js @@ -0,0 +1,3 @@ +function foo() { + return arguments.callee.name; +} diff --git a/Task/Program-name/JavaScript/program-name-2.js b/Task/Program-name/JavaScript/program-name-2.js new file mode 100644 index 0000000000..e06c79ae51 --- /dev/null +++ b/Task/Program-name/JavaScript/program-name-2.js @@ -0,0 +1 @@ +(function(){alert(arguments.callee.name);}()) diff --git a/Task/Program-name/JavaScript/program-name-3.js b/Task/Program-name/JavaScript/program-name-3.js new file mode 100644 index 0000000000..df0ad32d8e --- /dev/null +++ b/Task/Program-name/JavaScript/program-name-3.js @@ -0,0 +1,9 @@ +#!/usr/bin/env node +/*jslint nodejs:true */ + +function main() { + var program = __filename; + console.log("Program: " + program); +} + +if (!module.parent) { main(); } diff --git a/Task/Program-name/LLVM/program-name-1.llvm b/Task/Program-name/LLVM/program-name-1.llvm new file mode 100644 index 0000000000..543a80f2b5 --- /dev/null +++ b/Task/Program-name/LLVM/program-name-1.llvm @@ -0,0 +1,6 @@ +$ make +llvm-as scriptname.ll +llc -disable-cfi scriptname.bc +gcc -o scriptname scriptname.s +./scriptname +Program: ./scriptname diff --git a/Task/Program-name/LLVM/program-name-2.llvm b/Task/Program-name/LLVM/program-name-2.llvm new file mode 100644 index 0000000000..aab25afb09 --- /dev/null +++ b/Task/Program-name/LLVM/program-name-2.llvm @@ -0,0 +1,10 @@ +all: scriptname.ll + llvm-as scriptname.ll + llc scriptname.bc + gcc -o scriptname scriptname.s + ./scriptname + +clean: + -rm scriptname + -rm scriptname.s + -rm scriptname.bc diff --git a/Task/Program-name/LLVM/program-name-3.llvm b/Task/Program-name/LLVM/program-name-3.llvm new file mode 100644 index 0000000000..f175a87f5f --- /dev/null +++ b/Task/Program-name/LLVM/program-name-3.llvm @@ -0,0 +1,10 @@ +@msg_main = internal constant [13 x i8] c"Program: %s\0A\00" + +declare i32 @printf(i8* noalias nocapture, ...) + +define i32 @main(i32 %argc, i8** %argv) { + %program = load i8** %argv + call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([13 x i8]* @msg_main, i32 0, i32 0), i8* %program) + + ret i32 0 +} diff --git a/Task/Program-name/Lua/program-name.lua b/Task/Program-name/Lua/program-name.lua new file mode 100644 index 0000000000..f1ca17130e --- /dev/null +++ b/Task/Program-name/Lua/program-name.lua @@ -0,0 +1,12 @@ +#!/usr/bin/env lua + +function main(arg) + local program = arg[0] + print("Program: " .. program) +end + +if type(package.loaded[(...)]) ~= "userdata" then + main(arg) +else + module(..., package.seeall) +end diff --git a/Task/Program-name/Mathematica/program-name.math b/Task/Program-name/Mathematica/program-name.math new file mode 100644 index 0000000000..9438f9adc0 --- /dev/null +++ b/Task/Program-name/Mathematica/program-name.math @@ -0,0 +1,12 @@ +#!/usr/bin/env MathKernel -script + +ScriptName[] = Piecewise[ + { + {"Interpreted", Position[$CommandLine, "-script", 1] == {}} + }, + $CommandLine[[Position[$CommandLine, "-script", 1][[1,1]] + 1]] +] + +Program = ScriptName[]; + +Print["Program: " <> Program] diff --git a/Task/Program-name/NetRexx/program-name.netrexx b/Task/Program-name/NetRexx/program-name.netrexx new file mode 100644 index 0000000000..dd8b071676 --- /dev/null +++ b/Task/Program-name/NetRexx/program-name.netrexx @@ -0,0 +1,8 @@ +/* NetRexx */ +options replace format comments java crossref symbols nobinary + +package org.rosettacode.samples + +say 'Source: ' source +say 'Program:' System.getProperty('sun.java.command') +return diff --git a/Task/Program-name/OCaml/program-name.ocaml b/Task/Program-name/OCaml/program-name.ocaml new file mode 100644 index 0000000000..e82d099784 --- /dev/null +++ b/Task/Program-name/OCaml/program-name.ocaml @@ -0,0 +1,3 @@ +let () = + print_endline Sys.executable_name; + print_endline Sys.argv.(0) diff --git a/Task/Program-name/Objective-C/program-name-1.m b/Task/Program-name/Objective-C/program-name-1.m new file mode 100644 index 0000000000..3620035b51 --- /dev/null +++ b/Task/Program-name/Objective-C/program-name-1.m @@ -0,0 +1,16 @@ +#import + +int main(int argc, char **argv) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + char *program = argv[0]; + printf("Program: %s\n", program); + + // Alternatively: + NSString *program2 = [[NSProcessInfo processInfo] processName]; + NSLog(@"Program: %@\n", program2); + + [pool drain]; + + return 0; +} diff --git a/Task/Program-name/Objective-C/program-name-2.m b/Task/Program-name/Objective-C/program-name-2.m new file mode 100644 index 0000000000..4cfe7e9bf8 --- /dev/null +++ b/Task/Program-name/Objective-C/program-name-2.m @@ -0,0 +1,3 @@ +$ gcc -o scriptname -framework foundation scriptname.m +$ ./scriptname +Program: ./scriptname diff --git a/Task/Program-name/Octave/program-name.octave b/Task/Program-name/Octave/program-name.octave new file mode 100644 index 0000000000..30d3b9c199 --- /dev/null +++ b/Task/Program-name/Octave/program-name.octave @@ -0,0 +1,6 @@ +function main() + program = program_name(); + printf("Program: %s", program); +endfunction + +main(); diff --git a/Task/Program-name/Order/program-name.order b/Task/Program-name/Order/program-name.order new file mode 100644 index 0000000000..4815727d05 --- /dev/null +++ b/Task/Program-name/Order/program-name.order @@ -0,0 +1 @@ +__FILE__ diff --git a/Task/Program-name/PHP/program-name.php b/Task/Program-name/PHP/program-name.php new file mode 100644 index 0000000000..2b239d4ec6 --- /dev/null +++ b/Task/Program-name/PHP/program-name.php @@ -0,0 +1,4 @@ + diff --git a/Task/Program-name/Pascal/program-name.pascal b/Task/Program-name/Pascal/program-name.pascal new file mode 100644 index 0000000000..b3f1207f99 --- /dev/null +++ b/Task/Program-name/Pascal/program-name.pascal @@ -0,0 +1,8 @@ +program ScriptName; +var + prog : String; +begin + prog := ParamStr(0); + write('Program: '); + writeln(prog) +end. diff --git a/Task/Program-name/Perl-6/program-name.pl6 b/Task/Program-name/Perl-6/program-name.pl6 new file mode 100644 index 0000000000..7256e27b76 --- /dev/null +++ b/Task/Program-name/Perl-6/program-name.pl6 @@ -0,0 +1 @@ +say $*PROGRAM_NAME; diff --git a/Task/Program-name/Perl/program-name.pl b/Task/Program-name/Perl/program-name.pl new file mode 100644 index 0000000000..7f8a212c98 --- /dev/null +++ b/Task/Program-name/Perl/program-name.pl @@ -0,0 +1,11 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +sub main { + my $program = $0; + print "Program: $program\n"; +} + +unless(caller) { main; } diff --git a/Task/Program-name/PicoLisp/program-name.l b/Task/Program-name/PicoLisp/program-name.l new file mode 100644 index 0000000000..4f6e9fabda --- /dev/null +++ b/Task/Program-name/PicoLisp/program-name.l @@ -0,0 +1,2 @@ +: (cmd) +-> "/usr/bin/picolisp" diff --git a/Task/Program-name/PowerBASIC/program-name-1.powerbasic b/Task/Program-name/PowerBASIC/program-name-1.powerbasic new file mode 100644 index 0000000000..72ca5d2db5 --- /dev/null +++ b/Task/Program-name/PowerBASIC/program-name-1.powerbasic @@ -0,0 +1,9 @@ +#INCLUDE "Win32API.inc" +'[...] +DIM fullpath AS ASCIIZ * 260, appname AS STRING +GetModuleFileNameA 0, fullpath, 260 +IF INSTR(fullpath, "\") THEN + appname = MID$(fullpath, INSTR(-1, fullpath, "\") + 1) +ELSE + appname = fullpath +END IF diff --git a/Task/Program-name/PowerBASIC/program-name-2.powerbasic b/Task/Program-name/PowerBASIC/program-name-2.powerbasic new file mode 100644 index 0000000000..8e1dbc97ca --- /dev/null +++ b/Task/Program-name/PowerBASIC/program-name-2.powerbasic @@ -0,0 +1 @@ +appname = EXE.NAMEX$ diff --git a/Task/Program-name/PureBasic/program-name.purebasic b/Task/Program-name/PureBasic/program-name.purebasic new file mode 100644 index 0000000000..5dfb26a0b5 --- /dev/null +++ b/Task/Program-name/PureBasic/program-name.purebasic @@ -0,0 +1,6 @@ +If OpenConsole() + PrintN(ProgramFilename()) + + Print(#CRLF$ + #CRLF$ + "Press ENTER to exit"): Input() + CloseConsole() +EndIf diff --git a/Task/Program-name/Python/program-name-1.py b/Task/Program-name/Python/program-name-1.py new file mode 100644 index 0000000000..e8bf0531d7 --- /dev/null +++ b/Task/Program-name/Python/program-name-1.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python + +import sys + +def main(): + program = sys.argv[0] + print "Program: %s" % program + +if __name__=="__main__": + main() diff --git a/Task/Program-name/Python/program-name-2.py b/Task/Program-name/Python/program-name-2.py new file mode 100644 index 0000000000..5997f3e9d1 --- /dev/null +++ b/Task/Program-name/Python/program-name-2.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python + +import inspect + +def main(): + program = inspect.getfile(inspect.currentframe()) + print "Program: %s" % program + +if __name__=="__main__": + main() diff --git a/Task/Program-name/R/program-name.r b/Task/Program-name/R/program-name.r new file mode 100644 index 0000000000..478ec70a5b --- /dev/null +++ b/Task/Program-name/R/program-name.r @@ -0,0 +1,12 @@ +#!/usr/bin/env Rscript + +getProgram <- function(args) { + sub("--file=", "", args[grep("--file=", args)]) +} + +args <- commandArgs(trailingOnly = FALSE) +program <- getProgram(args) + +cat("Program: ", program, "\n") + +q("no") diff --git a/Task/Program-name/REXX/program-name-1.rexx b/Task/Program-name/REXX/program-name-1.rexx new file mode 100644 index 0000000000..4606b313b2 --- /dev/null +++ b/Task/Program-name/REXX/program-name-1.rexx @@ -0,0 +1,4 @@ +/* Rexx */ + +Parse source . . pgmPath +Say pgmPath diff --git a/Task/Program-name/REXX/program-name-2.rexx b/Task/Program-name/REXX/program-name-2.rexx new file mode 100644 index 0000000000..ef6f4c89e2 --- /dev/null +++ b/Task/Program-name/REXX/program-name-2.rexx @@ -0,0 +1,2 @@ +#!/bin/sh +rexxbit.rexx $0 $* diff --git a/Task/Program-name/REXX/program-name-3.rexx b/Task/Program-name/REXX/program-name-3.rexx new file mode 100644 index 0000000000..893d3dff45 --- /dev/null +++ b/Task/Program-name/REXX/program-name-3.rexx @@ -0,0 +1 @@ +say "The program is called " arg(1) diff --git a/Task/Program-name/REXX/program-name-4.rexx b/Task/Program-name/REXX/program-name-4.rexx new file mode 100644 index 0000000000..a5db41c1ac --- /dev/null +++ b/Task/Program-name/REXX/program-name-4.rexx @@ -0,0 +1,5 @@ +/*REXX program RANG1 in PDS N561985.PRIV.CLIST W. Pachl */ +Parse Source a b c +Say 'a='a +Say 'b='!!b +Say 'c='c diff --git a/Task/Program-name/REXX/program-name-5.rexx b/Task/Program-name/REXX/program-name-5.rexx new file mode 100644 index 0000000000..85739fa511 --- /dev/null +++ b/Task/Program-name/REXX/program-name-5.rexx @@ -0,0 +1,15 @@ +/*REXX pgm displays the name (& possible path) of the REXX program name.*/ +parse version _version +parse source _system _howInvoked _path + +say right(_version '◄──►' space(arg(1) arg(2)), 79, '─') /*show title.*/ +say " REXX's name of system being used:" _system +say ' how the REXX program was invoked:' _howInvoked +say ' name of the REXX program and path:' _path + +if arg()>1 then return 0 /*don't let this program recurse.*/ + /*Mama said that cursing is a sin*/ + /*invoke ourself with a 2nd arg.*/ +call prog_nam , 'subroutine' /*call ourself as a subroutine. */ +zz = prog_nam( , 'function') /* " " " " function. */ + /*stick a fork in it, we're done.*/ diff --git a/Task/Program-name/Racket/program-name.rkt b/Task/Program-name/Racket/program-name.rkt new file mode 100644 index 0000000000..8eb954bdbc --- /dev/null +++ b/Task/Program-name/Racket/program-name.rkt @@ -0,0 +1,6 @@ +#!/usr/bin/env racket +#lang racket + +(define (program) (find-system-path 'run-file)) + +(module+ main (printf "Program: ~a\n" (program))) diff --git a/Task/Program-name/Ruby/program-name.rb b/Task/Program-name/Ruby/program-name.rb new file mode 100644 index 0000000000..ffe047413e --- /dev/null +++ b/Task/Program-name/Ruby/program-name.rb @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby + +puts "Path: #{$0}" +puts "Name: #{File.basename $0}" diff --git a/Task/Program-name/Rust/program-name-1.rust b/Task/Program-name/Rust/program-name-1.rust new file mode 100644 index 0000000000..656a4dc024 --- /dev/null +++ b/Task/Program-name/Rust/program-name-1.rust @@ -0,0 +1,3 @@ +fn main() { + io::println(fmt!("Program: %s", os::args()[0])); +} diff --git a/Task/Program-name/Rust/program-name-2.rust b/Task/Program-name/Rust/program-name-2.rust new file mode 100644 index 0000000000..fa1e9422fe --- /dev/null +++ b/Task/Program-name/Rust/program-name-2.rust @@ -0,0 +1,3 @@ +$ rustc scriptname.rs +$ ./scriptname +Program: ./scriptname diff --git a/Task/Program-name/Scala/program-name-1.scala b/Task/Program-name/Scala/program-name-1.scala new file mode 100644 index 0000000000..9c69b75372 --- /dev/null +++ b/Task/Program-name/Scala/program-name-1.scala @@ -0,0 +1,19 @@ +$ scala ScriptName.scala +Program: ScriptName.scala + +$ scalac ScriptName.scala +$ scala -classpath . ScriptName +Program: ScriptName.scala + +$ scala +Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26). +Type in expressions to have them evaluated. +Type :help for more information. + +scala> :load ScriptName.scala +Loading ScriptName.scala... +import scala.util.matching.Regex.MatchIterator +defined module ScriptName + +scala> ScriptName.main(Array[String]()) +Program: diff --git a/Task/Program-name/Scala/program-name-2.scala b/Task/Program-name/Scala/program-name-2.scala new file mode 100644 index 0000000000..3dc52e2831 --- /dev/null +++ b/Task/Program-name/Scala/program-name-2.scala @@ -0,0 +1,18 @@ +import scala.util.matching.Regex.MatchIterator + +object ScriptName { + val program = { + val filenames = new RuntimeException("").getStackTrace.map { t => t.getFileName } + val scala = filenames.indexOf("NativeMethodAccessorImpl.java") + + if (scala == -1) + "" + else + filenames(scala - 1) + } + + def main(args: Array[String]) { + val prog = program + println("Program: " + prog) + } +} diff --git a/Task/Program-name/Scheme/program-name.ss b/Task/Program-name/Scheme/program-name.ss new file mode 100644 index 0000000000..90f19ab388 --- /dev/null +++ b/Task/Program-name/Scheme/program-name.ss @@ -0,0 +1,25 @@ +#!/bin/sh +#| +exec csi -ss $0 ${1+"$@"} +exit +|# + +(use posix) +(require-extension srfi-1) ; lists +(require-extension srfi-13) ; strings + +(define (main args) + (let ((prog (cdr (program)))) + (display (format "Program: ~a\n" prog)) + (exit))) + +(define (program) + (if (string=? (car (argv)) "csi") + (let ((s-index (list-index (lambda (x) (string-contains x "-s")) (argv)))) + (if (number? s-index) + (cons 'interpreted (list-ref (argv) (+ 1 s-index))) + (cons 'unknown ""))) + (cons 'compiled (car (argv))))) + +(if (equal? (car (program)) 'compiled) + (main (cdr (argv)))) diff --git a/Task/Program-name/Seed7/program-name.seed7 b/Task/Program-name/Seed7/program-name.seed7 new file mode 100644 index 0000000000..9b46627e8e --- /dev/null +++ b/Task/Program-name/Seed7/program-name.seed7 @@ -0,0 +1,10 @@ +$ include "seed7_05.s7i"; + +const proc: main is func + local + var integer: i is 0; + begin + writeln("Program path: " <& path(PROGRAM)); + writeln("Program directory: " <& dir(PROGRAM)); + writeln("Program file: " <& file(PROGRAM)); + end func; diff --git a/Task/Program-name/Smalltalk/program-name-1.st b/Task/Program-name/Smalltalk/program-name-1.st new file mode 100644 index 0000000000..a28d0c4035 --- /dev/null +++ b/Task/Program-name/Smalltalk/program-name-1.st @@ -0,0 +1,8 @@ +"exec" "gst" "-f" "$0" "$0" "$@" +"exit" + +| program | + +program := Smalltalk getArgv: 1. + +Transcript show: 'Program: ', program; cr. diff --git a/Task/Program-name/Smalltalk/program-name-2.st b/Task/Program-name/Smalltalk/program-name-2.st new file mode 100644 index 0000000000..51c0f693a7 --- /dev/null +++ b/Task/Program-name/Smalltalk/program-name-2.st @@ -0,0 +1,4 @@ +| program | + +program := Smalltalk commandLine first. +Transcript show: 'Program: ', program; cr. diff --git a/Task/Program-name/Standard-ML/program-name.ml b/Task/Program-name/Standard-ML/program-name.ml new file mode 100644 index 0000000000..39b712e08e --- /dev/null +++ b/Task/Program-name/Standard-ML/program-name.ml @@ -0,0 +1,7 @@ +#!/usr/bin/env sml + +let + val program = CommandLine.name () +in + print ("Program: " ^ program ^ "\n") +end; diff --git a/Task/Program-name/Tcl/program-name.tcl b/Task/Program-name/Tcl/program-name.tcl new file mode 100644 index 0000000000..6bb7ac1ebe --- /dev/null +++ b/Task/Program-name/Tcl/program-name.tcl @@ -0,0 +1,10 @@ +#!/usr/bin/env tclsh + +proc main {args} { + set program $::argv0 + puts "Program: $program" +} + +if {$::argv0 eq [info script]} { + main {*}$::argv +} diff --git a/Task/Program-name/UNIX-Shell/program-name.sh b/Task/Program-name/UNIX-Shell/program-name.sh new file mode 100644 index 0000000000..eb62fb28e9 --- /dev/null +++ b/Task/Program-name/UNIX-Shell/program-name.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "Program: $0" diff --git a/Task/Program-name/VBA/program-name.vba b/Task/Program-name/VBA/program-name.vba new file mode 100644 index 0000000000..1a73d64746 --- /dev/null +++ b/Task/Program-name/VBA/program-name.vba @@ -0,0 +1 @@ +Debug.Print Application.Name diff --git a/Task/Program-name/Vala/program-name.vala b/Task/Program-name/Vala/program-name.vala new file mode 100644 index 0000000000..a57a0e5630 --- /dev/null +++ b/Task/Program-name/Vala/program-name.vala @@ -0,0 +1,5 @@ +public static void main(string[] args){ + string command_name = args[0]; + + stdout.printf("%s\n", command_name); +} diff --git a/Task/Program-name/Visual-Basic/program-name-1.vb b/Task/Program-name/Visual-Basic/program-name-1.vb new file mode 100644 index 0000000000..6ef58b972d --- /dev/null +++ b/Task/Program-name/Visual-Basic/program-name-1.vb @@ -0,0 +1 @@ +appname = App.EXEName 'appname = "MyVBapp" diff --git a/Task/Program-name/Visual-Basic/program-name-2.vb b/Task/Program-name/Visual-Basic/program-name-2.vb new file mode 100644 index 0000000000..083c239dba --- /dev/null +++ b/Task/Program-name/Visual-Basic/program-name-2.vb @@ -0,0 +1,9 @@ +Declare Function GetModuleFileName Lib "kernel32" Alias "GetModuleFileNameA" (ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long +Dim fullpath As String * 260, appname As String, namelen As Long +namelen = GetModuleFileName (0, fullpath, 260) +fullpath = Left$(fullpath, namelen) +If InStr(fullpath, "\") Then + appname = Mid$(fullpath, InStrRev(fullpath, "\") + 1) +Else + appname = fullpath +End If diff --git a/Task/Program-termination/0DESCRIPTION b/Task/Program-termination/0DESCRIPTION new file mode 100644 index 0000000000..d657dcb630 --- /dev/null +++ b/Task/Program-termination/0DESCRIPTION @@ -0,0 +1,3 @@ +Show the syntax for a complete stoppage of a program inside a [[Conditional Structures|conditional]]. This includes all [[threads]]/[[processes]] which are part of your program. + +Explain the cleanup (or lack thereof) caused by the termination (allocated memory, database connections, open files, object finalizers/destructors, run-on-exit hooks, etc.). Unless otherwise described, no special cleanup outside that provided by the operating system is provided. diff --git a/Task/Program-termination/1META.yaml b/Task/Program-termination/1META.yaml new file mode 100644 index 0000000000..659c8686af --- /dev/null +++ b/Task/Program-termination/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Basic language learning diff --git a/Task/Program-termination/ALGOL-68/program-termination.alg b/Task/Program-termination/ALGOL-68/program-termination.alg new file mode 100644 index 0000000000..277e70a5d0 --- /dev/null +++ b/Task/Program-termination/ALGOL-68/program-termination.alg @@ -0,0 +1,3 @@ +IF problem = 1 THEN + stop +FI diff --git a/Task/Program-termination/AWK/program-termination.awk b/Task/Program-termination/AWK/program-termination.awk new file mode 100644 index 0000000000..715bd029c2 --- /dev/null +++ b/Task/Program-termination/AWK/program-termination.awk @@ -0,0 +1 @@ +if(problem)exit 1 diff --git a/Task/Program-termination/Ada/program-termination-1.ada b/Task/Program-termination/Ada/program-termination-1.ada new file mode 100644 index 0000000000..7fbdd62d8e --- /dev/null +++ b/Task/Program-termination/Ada/program-termination-1.ada @@ -0,0 +1,10 @@ +with Ada.Task_Identification; use Ada.Task_Identification; + +procedure Main is + -- Create as many task objects as your program needs +begin + -- whatever logic is required in your Main procedure + if some_condition then + Abort_Task (Current_Task); + end if; +end Main; diff --git a/Task/Program-termination/Ada/program-termination-2.ada b/Task/Program-termination/Ada/program-termination-2.ada new file mode 100644 index 0000000000..039358d4ab --- /dev/null +++ b/Task/Program-termination/Ada/program-termination-2.ada @@ -0,0 +1,11 @@ +procedure Main is + -- Create as many task objects as your program needs +begin + -- whatever logic is required in your Main procedure + if some_condition then + -- for each task created by the Main procedure + The_task.Stop; + -- end the Main procedure + return; -- actually, this is not needed + end if; +end Main; diff --git a/Task/Program-termination/Ada/program-termination-3.ada b/Task/Program-termination/Ada/program-termination-3.ada new file mode 100644 index 0000000000..f6a9a3d89c --- /dev/null +++ b/Task/Program-termination/Ada/program-termination-3.ada @@ -0,0 +1,14 @@ +task body Some_Task is +begin + loop + select + -- Some alternatives + ... + or accept Stop do + -- Some cleanup while holding the caller is here + end Stop; + -- A cleanup asynchronous to the caller is here + exit; -- We are through + end select + end loop; +end Some_Task; diff --git a/Task/Program-termination/Ada/program-termination-4.ada b/Task/Program-termination/Ada/program-termination-4.ada new file mode 100644 index 0000000000..34afb399ef --- /dev/null +++ b/Task/Program-termination/Ada/program-termination-4.ada @@ -0,0 +1,10 @@ +task body Some_Task is +begin + loop + select + -- Some alternatives + ... + or terminate; -- We are through + end select + end loop; +end Some_Task; diff --git a/Task/Program-termination/AppleScript/program-termination-1.applescript b/Task/Program-termination/AppleScript/program-termination-1.applescript new file mode 100644 index 0000000000..7775caac13 --- /dev/null +++ b/Task/Program-termination/AppleScript/program-termination-1.applescript @@ -0,0 +1,3 @@ +on run + If problem then return +end run diff --git a/Task/Program-termination/AppleScript/program-termination-2.applescript b/Task/Program-termination/AppleScript/program-termination-2.applescript new file mode 100644 index 0000000000..f92d164667 --- /dev/null +++ b/Task/Program-termination/AppleScript/program-termination-2.applescript @@ -0,0 +1,8 @@ +on run + f() + display dialog "This message will never be displayed." +end run + +on f() + error +end f diff --git a/Task/Program-termination/AutoHotkey/program-termination.ahk b/Task/Program-termination/AutoHotkey/program-termination.ahk new file mode 100644 index 0000000000..bce5ab2c1a --- /dev/null +++ b/Task/Program-termination/AutoHotkey/program-termination.ahk @@ -0,0 +1,2 @@ +If (problem) + ExitApp diff --git a/Task/Program-termination/AutoIt/program-termination.autoit b/Task/Program-termination/AutoIt/program-termination.autoit new file mode 100644 index 0000000000..37dc653cf1 --- /dev/null +++ b/Task/Program-termination/AutoIt/program-termination.autoit @@ -0,0 +1,3 @@ +If problem Then + Exit +Endif diff --git a/Task/Program-termination/BASIC/program-termination-1.basic b/Task/Program-termination/BASIC/program-termination-1.basic new file mode 100644 index 0000000000..2e09870077 --- /dev/null +++ b/Task/Program-termination/BASIC/program-termination-1.basic @@ -0,0 +1,3 @@ +if problem = 1 then + end +end if diff --git a/Task/Program-termination/BASIC/program-termination-2.basic b/Task/Program-termination/BASIC/program-termination-2.basic new file mode 100644 index 0000000000..cd28387177 --- /dev/null +++ b/Task/Program-termination/BASIC/program-termination-2.basic @@ -0,0 +1 @@ +10 IF 1 THEN STOP diff --git a/Task/Program-termination/BASIC/program-termination-3.basic b/Task/Program-termination/BASIC/program-termination-3.basic new file mode 100644 index 0000000000..cd09006ba0 --- /dev/null +++ b/Task/Program-termination/BASIC/program-termination-3.basic @@ -0,0 +1 @@ +10 IF 1 THEN END diff --git a/Task/Program-termination/BASIC/program-termination-4.basic b/Task/Program-termination/BASIC/program-termination-4.basic new file mode 100644 index 0000000000..e3c19a1a9e --- /dev/null +++ b/Task/Program-termination/BASIC/program-termination-4.basic @@ -0,0 +1,3 @@ +10 LET a = 1: LET b = 1 +20 IF a = b THEN GO TO 9995 +9995 STOP diff --git a/Task/Program-termination/BBC-BASIC/program-termination.bbc b/Task/Program-termination/BBC-BASIC/program-termination.bbc new file mode 100644 index 0000000000..e4fe830210 --- /dev/null +++ b/Task/Program-termination/BBC-BASIC/program-termination.bbc @@ -0,0 +1 @@ + IF condition% THEN QUIT diff --git a/Task/Program-termination/Batch-File/program-termination.bat b/Task/Program-termination/Batch-File/program-termination.bat new file mode 100644 index 0000000000..5b49f643e8 --- /dev/null +++ b/Task/Program-termination/Batch-File/program-termination.bat @@ -0,0 +1 @@ +if condition exit diff --git a/Task/Program-termination/C++/program-termination-1.cpp b/Task/Program-termination/C++/program-termination-1.cpp new file mode 100644 index 0000000000..6925977849 --- /dev/null +++ b/Task/Program-termination/C++/program-termination-1.cpp @@ -0,0 +1,6 @@ +#include + +void problem_occured() +{ + std::exit(EXIT_FAILURE); +} diff --git a/Task/Program-termination/C++/program-termination-2.cpp b/Task/Program-termination/C++/program-termination-2.cpp new file mode 100644 index 0000000000..9b5ef8a2ef --- /dev/null +++ b/Task/Program-termination/C++/program-termination-2.cpp @@ -0,0 +1,6 @@ +#include + +void problem_occured() +{ + std::abort(); +} diff --git a/Task/Program-termination/C++/program-termination-3.cpp b/Task/Program-termination/C++/program-termination-3.cpp new file mode 100644 index 0000000000..b2938feb35 --- /dev/null +++ b/Task/Program-termination/C++/program-termination-3.cpp @@ -0,0 +1,6 @@ +#include + +void problem_occured() +{ + std::terminate(); +} diff --git a/Task/Program-termination/C/program-termination-1.c b/Task/Program-termination/C/program-termination-1.c new file mode 100644 index 0000000000..aa324b2851 --- /dev/null +++ b/Task/Program-termination/C/program-termination-1.c @@ -0,0 +1,18 @@ +#include +/* More "natural" way of ending the program: finish all work and return + from main() */ +int main(int argc, char **argv) +{ + /* work work work */ + ... + return 0; /* the return value is the exit code. see below */ +} + +if(problem){ + exit(exit_code); + /* On unix, exit code 0 indicates success, but other OSes may follow + different conventions. It may be more portable to use symbols + EXIT_SUCCESS and EXIT_FAILURE; it all depends on what meaning + of codes are agreed upon. + */ +} diff --git a/Task/Program-termination/C/program-termination-2.c b/Task/Program-termination/C/program-termination-2.c new file mode 100644 index 0000000000..dbf738381f --- /dev/null +++ b/Task/Program-termination/C/program-termination-2.c @@ -0,0 +1,5 @@ +#include + +if(problem){ + abort(); +} diff --git a/Task/Program-termination/C/program-termination-3.c b/Task/Program-termination/C/program-termination-3.c new file mode 100644 index 0000000000..5c7070c051 --- /dev/null +++ b/Task/Program-termination/C/program-termination-3.c @@ -0,0 +1 @@ +exit_group(); diff --git a/Task/Program-termination/Clojure/program-termination-1.clj b/Task/Program-termination/Clojure/program-termination-1.clj new file mode 100644 index 0000000000..3ee3166921 --- /dev/null +++ b/Task/Program-termination/Clojure/program-termination-1.clj @@ -0,0 +1,6 @@ +(if problem + (. System exit integerErrorCode)) + ;conventionally, error code 0 is the code for "OK", + ; while anything else is an actual problem + ;optionally: (-> Runtime (. getRuntime) (. exit integerErrorCode)) +} diff --git a/Task/Program-termination/Clojure/program-termination-2.clj b/Task/Program-termination/Clojure/program-termination-2.clj new file mode 100644 index 0000000000..ff666ecff5 --- /dev/null +++ b/Task/Program-termination/Clojure/program-termination-2.clj @@ -0,0 +1,4 @@ +(if problem + (-> Runtime (. getRuntime) (. halt integerErrorCode))) + ; conventionally, error code 0 is the code for "OK", + ; while anything else is an actual problem diff --git a/Task/Program-termination/Common-Lisp/program-termination.lisp b/Task/Program-termination/Common-Lisp/program-termination.lisp new file mode 100644 index 0000000000..383f2d806d --- /dev/null +++ b/Task/Program-termination/Common-Lisp/program-termination.lisp @@ -0,0 +1,8 @@ +(defun terminate (status) + #+sbcl (sb-ext:quit :unix-status status) ; SBCL + #+ccl ( ccl:quit status) ; Clozure CL + #+clisp ( ext:quit status) ; GNU CLISP + #+cmu ( unix:unix-exit status) ; CMUCL + #+abcl ( ext:quit :status status) ; Armed Bear CL + #+allegro ( excl:exit status :quiet t) ; Allegro CL + (cl-user::quit)) ; Many implementations put QUIT in the sandbox CL-USER package. diff --git a/Task/Program-termination/Delphi/program-termination-1.delphi b/Task/Program-termination/Delphi/program-termination-1.delphi new file mode 100644 index 0000000000..814ca65bd1 --- /dev/null +++ b/Task/Program-termination/Delphi/program-termination-1.delphi @@ -0,0 +1 @@ +System.Halt; diff --git a/Task/Program-termination/Delphi/program-termination-2.delphi b/Task/Program-termination/Delphi/program-termination-2.delphi new file mode 100644 index 0000000000..3bef23259b --- /dev/null +++ b/Task/Program-termination/Delphi/program-termination-2.delphi @@ -0,0 +1 @@ +System.Halt(1); // Optional exit code diff --git a/Task/Program-termination/E/program-termination-1.e b/Task/Program-termination/E/program-termination-1.e new file mode 100644 index 0000000000..a3cc17af54 --- /dev/null +++ b/Task/Program-termination/E/program-termination-1.e @@ -0,0 +1,3 @@ +if (true) { + interp.exitAtTop() +} diff --git a/Task/Program-termination/E/program-termination-2.e b/Task/Program-termination/E/program-termination-2.e new file mode 100644 index 0000000000..e5bc90661c --- /dev/null +++ b/Task/Program-termination/E/program-termination-2.e @@ -0,0 +1,3 @@ +if (true) { + interp.exitAtTop("because the task said so") +} diff --git a/Task/Program-termination/Forth/program-termination.fth b/Task/Program-termination/Forth/program-termination.fth new file mode 100644 index 0000000000..a8a614b1fe --- /dev/null +++ b/Task/Program-termination/Forth/program-termination.fth @@ -0,0 +1,4 @@ +debug @ +if QUIT \ quit back to the interpreter +else BYE \ exit forth environment completely (e.g. end of a Forth shell script) +then diff --git a/Task/Program-termination/Fortran/program-termination.f b/Task/Program-termination/Fortran/program-termination.f new file mode 100644 index 0000000000..bf0de2e5bc --- /dev/null +++ b/Task/Program-termination/Fortran/program-termination.f @@ -0,0 +1,3 @@ +IF (condition) STOP [message] +! message is optional and is a character string. +! If present, the message is output to the standard output device. diff --git a/Task/Program-termination/GW-BASIC/program-termination.gw-basic b/Task/Program-termination/GW-BASIC/program-termination.gw-basic new file mode 100644 index 0000000000..adfaea50c6 --- /dev/null +++ b/Task/Program-termination/GW-BASIC/program-termination.gw-basic @@ -0,0 +1 @@ +10 IF 1 THEN STOP diff --git a/Task/Program-termination/Gema/program-termination.gema b/Task/Program-termination/Gema/program-termination.gema new file mode 100644 index 0000000000..abdfca17c6 --- /dev/null +++ b/Task/Program-termination/Gema/program-termination.gema @@ -0,0 +1 @@ +Star Trek=@err{found a Star Trek reference\n}@abort diff --git a/Task/Program-termination/Go/program-termination-1.go b/Task/Program-termination/Go/program-termination-1.go new file mode 100644 index 0000000000..a9110e78ab --- /dev/null +++ b/Task/Program-termination/Go/program-termination-1.go @@ -0,0 +1,5 @@ +func main() { + if problem { + return + } +} diff --git a/Task/Program-termination/Go/program-termination-2.go b/Task/Program-termination/Go/program-termination-2.go new file mode 100644 index 0000000000..7165855926 --- /dev/null +++ b/Task/Program-termination/Go/program-termination-2.go @@ -0,0 +1,46 @@ +package main + +import ( + "fmt" + "runtime" + "time" +) + +const problem = true + +func main() { + fmt.Println("main program start") + + // this will get run on exit + defer paperwork() + + // this will not run to completion + go pcj() + + // this will not get run on exit + rec := &requiresExternalCleanup{"external object"} + runtime.SetFinalizer(rec, cleanup) + + if problem { + fmt.Println("main program returning") + return + } +} + +func paperwork() { + fmt.Println("i's dotted, t's crossed") +} + +func pcj() { + fmt.Println("there's uncle Joe") + time.Sleep(1e10) + fmt.Println("movin kinda slow") +} + +type requiresExternalCleanup struct { + id string +} + +func cleanup(rec *requiresExternalCleanup) { + fmt.Println(rec.id, "cleanup") +} diff --git a/Task/Program-termination/Go/program-termination-3.go b/Task/Program-termination/Go/program-termination-3.go new file mode 100644 index 0000000000..11d3b493e0 --- /dev/null +++ b/Task/Program-termination/Go/program-termination-3.go @@ -0,0 +1,13 @@ +func main() { + fmt.Println("main program start") + + // this will not get run on os.Exit + defer func() { + fmt.Println("deferred function") + }() + + if problem { + fmt.Println("main program exiting") + os.Exit(-1) + } +} diff --git a/Task/Program-termination/Go/program-termination-4.go b/Task/Program-termination/Go/program-termination-4.go new file mode 100644 index 0000000000..154cbd284c --- /dev/null +++ b/Task/Program-termination/Go/program-termination-4.go @@ -0,0 +1,17 @@ +func pcj() { + fmt.Println("at the junction") + defer func() { + fmt.Println("deferred from pcj") + }() + panic(10) +} + +func main() { + fmt.Println("main program start") + defer func() { + fmt.Println("deferred from main") + }() + go pcj() + time.Sleep(1e9) + fmt.Println("main program done") +} diff --git a/Task/Program-termination/Groovy/program-termination-1.groovy b/Task/Program-termination/Groovy/program-termination-1.groovy new file mode 100644 index 0000000000..e0e6849093 --- /dev/null +++ b/Task/Program-termination/Groovy/program-termination-1.groovy @@ -0,0 +1 @@ +if (problem) System.exit(intExitCode) diff --git a/Task/Program-termination/Groovy/program-termination-2.groovy b/Task/Program-termination/Groovy/program-termination-2.groovy new file mode 100644 index 0000000000..712fd2fac5 --- /dev/null +++ b/Task/Program-termination/Groovy/program-termination-2.groovy @@ -0,0 +1 @@ +if (problem) Runtime.runtime.halt(intExitCode) diff --git a/Task/Program-termination/Haskell/program-termination.hs b/Task/Program-termination/Haskell/program-termination.hs new file mode 100644 index 0000000000..60bfb05b3f --- /dev/null +++ b/Task/Program-termination/Haskell/program-termination.hs @@ -0,0 +1,8 @@ +import Control.Monad +import System.Exit + +when problem do + exitWith ExitSuccess -- success + exitWith (ExitFailure integerErrorCode) -- some failure with code + exitSuccess -- success; in GHC 6.10+ + exitFailure -- generic failure diff --git a/Task/Program-termination/HicEst/program-termination.hicest b/Task/Program-termination/HicEst/program-termination.hicest new file mode 100644 index 0000000000..8bd8e2a507 --- /dev/null +++ b/Task/Program-termination/HicEst/program-termination.hicest @@ -0,0 +1 @@ +ALARM( 999 ) diff --git a/Task/Program-termination/Icon/program-termination.icon b/Task/Program-termination/Icon/program-termination.icon new file mode 100644 index 0000000000..d6b3a76d96 --- /dev/null +++ b/Task/Program-termination/Icon/program-termination.icon @@ -0,0 +1,3 @@ +exit(i) # terminates the program setting an exit code of i +stop(x1,x2,..) # terminates the program writing out x1,..; if any xi is a file writing switches to that file +runerr(i,x) # terminates the program with run time error 'i' for value 'x' diff --git a/Task/Program-termination/J/program-termination-1.j b/Task/Program-termination/J/program-termination-1.j new file mode 100644 index 0000000000..32fe26b59d --- /dev/null +++ b/Task/Program-termination/J/program-termination-1.j @@ -0,0 +1 @@ +2!:55^:] condition diff --git a/Task/Program-termination/J/program-termination-2.j b/Task/Program-termination/J/program-termination-2.j new file mode 100644 index 0000000000..19a4880698 --- /dev/null +++ b/Task/Program-termination/J/program-termination-2.j @@ -0,0 +1 @@ +3 : 'if. 0~: condition do. 2!:55 condition end.' diff --git a/Task/Program-termination/Java/program-termination-1.java b/Task/Program-termination/Java/program-termination-1.java new file mode 100644 index 0000000000..f2e63ce691 --- /dev/null +++ b/Task/Program-termination/Java/program-termination-1.java @@ -0,0 +1,6 @@ +if(problem){ + System.exit(integerErrorCode); + //conventionally, error code 0 is the code for "OK", + // while anything else is an actual problem + //optionally: Runtime.getRuntime().exit(integerErrorCode); +} diff --git a/Task/Program-termination/Java/program-termination-2.java b/Task/Program-termination/Java/program-termination-2.java new file mode 100644 index 0000000000..34fc6c1ae0 --- /dev/null +++ b/Task/Program-termination/Java/program-termination-2.java @@ -0,0 +1,5 @@ +if(problem){ + Runtime.getRuntime().halt(integerErrorCode); + //conventionally, error code 0 is the code for "OK", + // while anything else is an actual problem +} diff --git a/Task/Program-termination/JavaScript/program-termination.js b/Task/Program-termination/JavaScript/program-termination.js new file mode 100644 index 0000000000..eb199e677c --- /dev/null +++ b/Task/Program-termination/JavaScript/program-termination.js @@ -0,0 +1,2 @@ +if (some_condition) + quit(); diff --git a/Task/Program-termination/Liberty-BASIC/program-termination.liberty b/Task/Program-termination/Liberty-BASIC/program-termination.liberty new file mode 100644 index 0000000000..660ea642cf --- /dev/null +++ b/Task/Program-termination/Liberty-BASIC/program-termination.liberty @@ -0,0 +1 @@ +if 2 =2 then end diff --git a/Task/Program-termination/Logo/program-termination.logo b/Task/Program-termination/Logo/program-termination.logo new file mode 100644 index 0000000000..02e15d7fe2 --- /dev/null +++ b/Task/Program-termination/Logo/program-termination.logo @@ -0,0 +1,6 @@ +bye ; exits to shell + +throw "toplevel ; exits to interactive prompt + +pause ; escapes to interactive prompt for debugging +continue ; resumes after a PAUSE diff --git a/Task/Program-termination/Lua/program-termination.lua b/Task/Program-termination/Lua/program-termination.lua new file mode 100644 index 0000000000..7aa27af430 --- /dev/null +++ b/Task/Program-termination/Lua/program-termination.lua @@ -0,0 +1,3 @@ +if some_condition then + os.exit( number ) +end diff --git a/Task/Program-termination/M4/program-termination.m4 b/Task/Program-termination/M4/program-termination.m4 new file mode 100644 index 0000000000..50352a3595 --- /dev/null +++ b/Task/Program-termination/M4/program-termination.m4 @@ -0,0 +1,4 @@ +beginning +define(`problem',1) +ifelse(problem,1,`m4exit(1)') +ending diff --git a/Task/Program-termination/MATLAB/program-termination-1.m b/Task/Program-termination/MATLAB/program-termination-1.m new file mode 100644 index 0000000000..2b7591c2fb --- /dev/null +++ b/Task/Program-termination/MATLAB/program-termination-1.m @@ -0,0 +1,3 @@ +if condition + return +end diff --git a/Task/Program-termination/MATLAB/program-termination-2.m b/Task/Program-termination/MATLAB/program-termination-2.m new file mode 100644 index 0000000000..98de47c9b6 --- /dev/null +++ b/Task/Program-termination/MATLAB/program-termination-2.m @@ -0,0 +1,3 @@ +if condition + quit +end diff --git a/Task/Program-termination/Mathematica/program-termination.math b/Task/Program-termination/Mathematica/program-termination.math new file mode 100644 index 0000000000..4d388990d1 --- /dev/null +++ b/Task/Program-termination/Mathematica/program-termination.math @@ -0,0 +1 @@ +If[problem, Abort[]]; diff --git a/Task/Program-termination/Maxima/program-termination.maxima b/Task/Program-termination/Maxima/program-termination.maxima new file mode 100644 index 0000000000..f2c83b367b --- /dev/null +++ b/Task/Program-termination/Maxima/program-termination.maxima @@ -0,0 +1,6 @@ +/* Basically, it's simply quit() */ + +block([ans], loop, if (ans: read("Really quit ? (y, n)")) = 'y + then quit() + elseif ans = 'n then (print("Nice choice!"), 'done) + else (print("I dont' understand..."), go(loop))); diff --git a/Task/Program-termination/NetRexx/program-termination.netrexx b/Task/Program-termination/NetRexx/program-termination.netrexx new file mode 100644 index 0000000000..108db5681b --- /dev/null +++ b/Task/Program-termination/NetRexx/program-termination.netrexx @@ -0,0 +1,9 @@ +/* NetRexx */ +options replace format comments java crossref symbols nobinary + +extremePrejudice = (1 == 1) +if extremePrejudice then do + exit extremePrejudice + end + +return diff --git a/Task/Program-termination/Nimrod/program-termination.nimrod b/Task/Program-termination/Nimrod/program-termination.nimrod new file mode 100644 index 0000000000..5cf9eed599 --- /dev/null +++ b/Task/Program-termination/Nimrod/program-termination.nimrod @@ -0,0 +1,2 @@ +if problem: + quit(QuitFailure) diff --git a/Task/Program-termination/OCaml/program-termination.ocaml b/Task/Program-termination/OCaml/program-termination.ocaml new file mode 100644 index 0000000000..14fc8a8155 --- /dev/null +++ b/Task/Program-termination/OCaml/program-termination.ocaml @@ -0,0 +1,4 @@ +if problem then + exit integerErrorCode; + (* conventionally, error code 0 is the code for "OK", + while anything else is an actual problem *) diff --git a/Task/Program-termination/Objeck/program-termination.objeck b/Task/Program-termination/Objeck/program-termination.objeck new file mode 100644 index 0000000000..01889addb7 --- /dev/null +++ b/Task/Program-termination/Objeck/program-termination.objeck @@ -0,0 +1,3 @@ +if(problem) { + Runtime->Exit(1); +}; diff --git a/Task/Program-termination/Oz/program-termination.oz b/Task/Program-termination/Oz/program-termination.oz new file mode 100644 index 0000000000..9ac852d23f --- /dev/null +++ b/Task/Program-termination/Oz/program-termination.oz @@ -0,0 +1 @@ +if Problem then {Application.exit 0} end diff --git a/Task/Program-termination/PARI-GP/program-termination.pari b/Task/Program-termination/PARI-GP/program-termination.pari new file mode 100644 index 0000000000..b5ab3ad0d0 --- /dev/null +++ b/Task/Program-termination/PARI-GP/program-termination.pari @@ -0,0 +1 @@ +if(stuff, quit) diff --git a/Task/Program-termination/PHP/program-termination.php b/Task/Program-termination/PHP/program-termination.php new file mode 100644 index 0000000000..d009fad45c --- /dev/null +++ b/Task/Program-termination/PHP/program-termination.php @@ -0,0 +1,2 @@ +if (problem) + exit(1); diff --git a/Task/Program-termination/PL-I/program-termination-1.pli b/Task/Program-termination/PL-I/program-termination-1.pli new file mode 100644 index 0000000000..70a04aa458 --- /dev/null +++ b/Task/Program-termination/PL-I/program-termination-1.pli @@ -0,0 +1,2 @@ +STOP; /* terminates the entire program */ + /* PL/I does any required cleanup, such as closing files. */ diff --git a/Task/Program-termination/PL-I/program-termination-2.pli b/Task/Program-termination/PL-I/program-termination-2.pli new file mode 100644 index 0000000000..bf63400f40 --- /dev/null +++ b/Task/Program-termination/PL-I/program-termination-2.pli @@ -0,0 +1 @@ +STOP THREAD (tiger); /* terminates only thread "tiger". */ diff --git a/Task/Program-termination/PL-I/program-termination-3.pli b/Task/Program-termination/PL-I/program-termination-3.pli new file mode 100644 index 0000000000..02c820f2a7 --- /dev/null +++ b/Task/Program-termination/PL-I/program-termination-3.pli @@ -0,0 +1,3 @@ +SIGNAL FINISH; /* terminates the entire program. */ + /* PL/I does any required cleanup, */ + /* such as closing files. */ diff --git a/Task/Program-termination/Perl-6/program-termination.pl6 b/Task/Program-termination/Perl-6/program-termination.pl6 new file mode 100644 index 0000000000..99d3080965 --- /dev/null +++ b/Task/Program-termination/Perl-6/program-termination.pl6 @@ -0,0 +1 @@ +if $problem { exit $error-code } diff --git a/Task/Program-termination/Perl/program-termination.pl b/Task/Program-termination/Perl/program-termination.pl new file mode 100644 index 0000000000..89c38524e1 --- /dev/null +++ b/Task/Program-termination/Perl/program-termination.pl @@ -0,0 +1,6 @@ +if ($problem) { + exit integerErrorCode; + # conventionally, error code 0 is the code for "OK" + # (you can also omit the argument in this case) + # while anything else is an actual problem +} diff --git a/Task/Program-termination/PicoLisp/program-termination.l b/Task/Program-termination/PicoLisp/program-termination.l new file mode 100644 index 0000000000..58b9040712 --- /dev/null +++ b/Task/Program-termination/PicoLisp/program-termination.l @@ -0,0 +1,2 @@ +(push '*Bye '(prinl "Goodbye world!")) +(bye) diff --git a/Task/Program-termination/Pop11/program-termination.pop11 b/Task/Program-termination/Pop11/program-termination.pop11 new file mode 100644 index 0000000000..86ac178d9a --- /dev/null +++ b/Task/Program-termination/Pop11/program-termination.pop11 @@ -0,0 +1,3 @@ +if condition then + sysexit(); +endif; diff --git a/Task/Program-termination/PostScript/program-termination-1.ps b/Task/Program-termination/PostScript/program-termination-1.ps new file mode 100644 index 0000000000..2257a58846 --- /dev/null +++ b/Task/Program-termination/PostScript/program-termination-1.ps @@ -0,0 +1 @@ +condition {stop} if diff --git a/Task/Program-termination/PostScript/program-termination-2.ps b/Task/Program-termination/PostScript/program-termination-2.ps new file mode 100644 index 0000000000..85a05ea248 --- /dev/null +++ b/Task/Program-termination/PostScript/program-termination-2.ps @@ -0,0 +1 @@ +condition {quit} if diff --git a/Task/Program-termination/PowerShell/program-termination.psh b/Task/Program-termination/PowerShell/program-termination.psh new file mode 100644 index 0000000000..b255d66eda --- /dev/null +++ b/Task/Program-termination/PowerShell/program-termination.psh @@ -0,0 +1,3 @@ +if (somecondition) { + exit +} diff --git a/Task/Program-termination/Prolog/program-termination-1.pro b/Task/Program-termination/Prolog/program-termination-1.pro new file mode 100644 index 0000000000..3d140f9b6f --- /dev/null +++ b/Task/Program-termination/Prolog/program-termination-1.pro @@ -0,0 +1 @@ +halt. diff --git a/Task/Program-termination/Prolog/program-termination-2.pro b/Task/Program-termination/Prolog/program-termination-2.pro new file mode 100644 index 0000000000..64e1c9b402 --- /dev/null +++ b/Task/Program-termination/Prolog/program-termination-2.pro @@ -0,0 +1 @@ +abort. diff --git a/Task/Program-termination/PureBasic/program-termination.purebasic b/Task/Program-termination/PureBasic/program-termination.purebasic new file mode 100644 index 0000000000..c43129715d --- /dev/null +++ b/Task/Program-termination/PureBasic/program-termination.purebasic @@ -0,0 +1,3 @@ +If problem = 1 + End +EndIf diff --git a/Task/Program-termination/Python/program-termination-1.py b/Task/Program-termination/Python/program-termination-1.py new file mode 100644 index 0000000000..ef778d8d0a --- /dev/null +++ b/Task/Program-termination/Python/program-termination-1.py @@ -0,0 +1,3 @@ +import sys +if problem: + sys.exit(1) diff --git a/Task/Program-termination/Python/program-termination-2.py b/Task/Program-termination/Python/program-termination-2.py new file mode 100644 index 0000000000..7273d46262 --- /dev/null +++ b/Task/Program-termination/Python/program-termination-2.py @@ -0,0 +1,3 @@ +import os +if problem: + os.abort() diff --git a/Task/Program-termination/R/program-termination.r b/Task/Program-termination/R/program-termination.r new file mode 100644 index 0000000000..f2cb28bde4 --- /dev/null +++ b/Task/Program-termination/R/program-termination.r @@ -0,0 +1 @@ +if(problem) q(status=10) diff --git a/Task/Program-termination/REBOL/program-termination-1.rebol b/Task/Program-termination/REBOL/program-termination-1.rebol new file mode 100644 index 0000000000..51e0e14e1d --- /dev/null +++ b/Task/Program-termination/REBOL/program-termination-1.rebol @@ -0,0 +1 @@ +if error? try [6 / 0] [quit] diff --git a/Task/Program-termination/REBOL/program-termination-2.rebol b/Task/Program-termination/REBOL/program-termination-2.rebol new file mode 100644 index 0000000000..863dc264e1 --- /dev/null +++ b/Task/Program-termination/REBOL/program-termination-2.rebol @@ -0,0 +1 @@ +if error? try [dangerous-operation] [quit/return -12] diff --git a/Task/Program-termination/REBOL/program-termination-3.rebol b/Task/Program-termination/REBOL/program-termination-3.rebol new file mode 100644 index 0000000000..e27372bde9 --- /dev/null +++ b/Task/Program-termination/REBOL/program-termination-3.rebol @@ -0,0 +1 @@ +if error? try [something-silly] [q/return -12] diff --git a/Task/Program-termination/REBOL/program-termination-4.rebol b/Task/Program-termination/REBOL/program-termination-4.rebol new file mode 100644 index 0000000000..ab22eddfa6 --- /dev/null +++ b/Task/Program-termination/REBOL/program-termination-4.rebol @@ -0,0 +1 @@ +view layout [button "stopme" [halt]] diff --git a/Task/Program-termination/REXX/program-termination.rexx b/Task/Program-termination/REXX/program-termination.rexx new file mode 100644 index 0000000000..59f08ce6d3 --- /dev/null +++ b/Task/Program-termination/REXX/program-termination.rexx @@ -0,0 +1,29 @@ +/*REXX program showing five ways to perform a REXX program termination. */ + + /*─────1st way────────────────────────────────────────────────────────*/ +exit + + + /*─────2nd way────────────────────────────────────────────────────────*/ +exit (expression) /*Note: the "expression" doen't need parenthesis*/ + /*"expression" is any REXX expression. */ + + + /*─────3rd way────────────────────────────────────────────────────────*/ +return /*which returns to this program's invoker. If */ + /*this is the main body (and not a subroutine), */ + /*the REXX interpreter terminates the program. */ + + + /*─────4th way────────────────────────────────────────────────────────*/ +return (expression) /* [See the note above concerning parenthesis.] */ + + + /*─────5th way────────────────────────────────────────────────────────*/ + /*control*/ + /* │ */ /*if there is no EXIT and program control "falls */ + /* │ */ /*through" to the "bottom" (end) of the program, */ + /* │ */ /*an EXIT is simulated and the program is */ + /* │ */ /*terminated. */ + /* ↓ */ + /* e-o-f */ /* e-o-f = end-of-file. */ diff --git a/Task/Program-termination/Retro/program-termination.retro b/Task/Program-termination/Retro/program-termination.retro new file mode 100644 index 0000000000..24be77152a --- /dev/null +++ b/Task/Program-termination/Retro/program-termination.retro @@ -0,0 +1 @@ +problem? [ bye ] ifTrue diff --git a/Task/Program-termination/Ruby/program-termination-1.rb b/Task/Program-termination/Ruby/program-termination-1.rb new file mode 100644 index 0000000000..5d9fe7ce00 --- /dev/null +++ b/Task/Program-termination/Ruby/program-termination-1.rb @@ -0,0 +1,3 @@ +if problem + exit(1) +end diff --git a/Task/Program-termination/Ruby/program-termination-2.rb b/Task/Program-termination/Ruby/program-termination-2.rb new file mode 100644 index 0000000000..a44cbaff45 --- /dev/null +++ b/Task/Program-termination/Ruby/program-termination-2.rb @@ -0,0 +1,3 @@ +if problem + abort # equivalent to exit(1) +end diff --git a/Task/Program-termination/SNOBOL4/program-termination.sno b/Task/Program-termination/SNOBOL4/program-termination.sno new file mode 100644 index 0000000000..bad301e068 --- /dev/null +++ b/Task/Program-termination/SNOBOL4/program-termination.sno @@ -0,0 +1 @@ + &code = condition errlevel :s(end) diff --git a/Task/Program-termination/Scheme/program-termination-1.ss b/Task/Program-termination/Scheme/program-termination-1.ss new file mode 100644 index 0000000000..a102eb9ff9 --- /dev/null +++ b/Task/Program-termination/Scheme/program-termination-1.ss @@ -0,0 +1,2 @@ +(if problem + (exit)) ; exit successfully diff --git a/Task/Program-termination/Scheme/program-termination-2.ss b/Task/Program-termination/Scheme/program-termination-2.ss new file mode 100644 index 0000000000..9de5c43b63 --- /dev/null +++ b/Task/Program-termination/Scheme/program-termination-2.ss @@ -0,0 +1,2 @@ +(if problem + (exit #f)) ; exit unsuccessfully diff --git a/Task/Program-termination/Scheme/program-termination-3.ss b/Task/Program-termination/Scheme/program-termination-3.ss new file mode 100644 index 0000000000..072639f90b --- /dev/null +++ b/Task/Program-termination/Scheme/program-termination-3.ss @@ -0,0 +1,2 @@ +(if problem + (exit some-value)) ; converts "some-value" into an appropriate exit code for your system diff --git a/Task/Program-termination/Seed7/program-termination.seed7 b/Task/Program-termination/Seed7/program-termination.seed7 new file mode 100644 index 0000000000..4654d9fb4b --- /dev/null +++ b/Task/Program-termination/Seed7/program-termination.seed7 @@ -0,0 +1,9 @@ +$ include "seed7_05.s7i"; + +const proc: main is func + begin + # whatever logic is required in your main procedure + if some_condition then + exit(PROGRAM); + end if; + end func; diff --git a/Task/Program-termination/Slate/program-termination.slate b/Task/Program-termination/Slate/program-termination.slate new file mode 100644 index 0000000000..470de687e5 --- /dev/null +++ b/Task/Program-termination/Slate/program-termination.slate @@ -0,0 +1 @@ +problem ifTrue: [exit: 1]. diff --git a/Task/Program-termination/Standard-ML/program-termination.ml b/Task/Program-termination/Standard-ML/program-termination.ml new file mode 100644 index 0000000000..235607d494 --- /dev/null +++ b/Task/Program-termination/Standard-ML/program-termination.ml @@ -0,0 +1,5 @@ +if problem then + OS.Process.exit OS.Process.failure + (* valid status codes include OS.Process.success and OS.Process.failure *) +else + () diff --git a/Task/Program-termination/TI-83-BASIC/program-termination.ti-83 b/Task/Program-termination/TI-83-BASIC/program-termination.ti-83 new file mode 100644 index 0000000000..a48896b3ab --- /dev/null +++ b/Task/Program-termination/TI-83-BASIC/program-termination.ti-83 @@ -0,0 +1 @@ + :Stop diff --git a/Task/Program-termination/TI-89-BASIC/program-termination.ti-89 b/Task/Program-termination/TI-89-BASIC/program-termination.ti-89 new file mode 100644 index 0000000000..77b62a92d2 --- /dev/null +++ b/Task/Program-termination/TI-89-BASIC/program-termination.ti-89 @@ -0,0 +1,5 @@ +Prgm + ... + Stop + ... +EndPrgm diff --git a/Task/Program-termination/TUSCRIPT/program-termination.tuscript b/Task/Program-termination/TUSCRIPT/program-termination.tuscript new file mode 100644 index 0000000000..26f00dd760 --- /dev/null +++ b/Task/Program-termination/TUSCRIPT/program-termination.tuscript @@ -0,0 +1,4 @@ +$$ MODE TUSCRIPT +IF (condition==1) STOP +-> execution stops and message: +IF (condition==2) ERROR/STOP "condition ",condition, " Execution STOP " diff --git a/Task/Program-termination/Tcl/program-termination-1.tcl b/Task/Program-termination/Tcl/program-termination-1.tcl new file mode 100644 index 0000000000..00c44d104b --- /dev/null +++ b/Task/Program-termination/Tcl/program-termination-1.tcl @@ -0,0 +1,6 @@ +if {$problem} { + # Print a “friendly” message... + puts stderr "some problem occurred" + # Indicate to the caller of the program that there was a problem + exit 1 +} diff --git a/Task/Program-termination/Tcl/program-termination-2.tcl b/Task/Program-termination/Tcl/program-termination-2.tcl new file mode 100644 index 0000000000..c35d227f48 --- /dev/null +++ b/Task/Program-termination/Tcl/program-termination-2.tcl @@ -0,0 +1,3 @@ +if {$problem} { + error "some problem occurred" +} diff --git a/Task/Program-termination/UNIX-Shell/program-termination.sh b/Task/Program-termination/UNIX-Shell/program-termination.sh new file mode 100644 index 0000000000..fc73d87034 --- /dev/null +++ b/Task/Program-termination/UNIX-Shell/program-termination.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +a='1' +b='1' +if [ "$a" -eq "$b" ]; then + exit 239 # Unexpected error +fi +exit 0 # Program terminated normally diff --git a/Task/Program-termination/Unlambda/program-termination.unlambda b/Task/Program-termination/Unlambda/program-termination.unlambda new file mode 100644 index 0000000000..ab232b3874 --- /dev/null +++ b/Task/Program-termination/Unlambda/program-termination.unlambda @@ -0,0 +1 @@ +`ei diff --git a/Task/Program-termination/VBScript/program-termination.vbscript b/Task/Program-termination/VBScript/program-termination.vbscript new file mode 100644 index 0000000000..4f558b4a75 --- /dev/null +++ b/Task/Program-termination/VBScript/program-termination.vbscript @@ -0,0 +1,11 @@ +dim i, j +j = 0 +do + for i = 1 to 100 + while j < i + if i = 3 then + wscript.quit + end if + wend + next +loop diff --git a/Task/Program-termination/Vedit-macro-language/program-termination.vedit b/Task/Program-termination/Vedit-macro-language/program-termination.vedit new file mode 100644 index 0000000000..de340a8910 --- /dev/null +++ b/Task/Program-termination/Vedit-macro-language/program-termination.vedit @@ -0,0 +1,6 @@ +if (#99 == 1) { Return } // Exit current macro. Return to calling macro. +if (#99 == 2) { Break_Out() } // Stop all macro execution and return to command mode. +if (#99 == 3) { Exit } // Exit Vedit. Prompt for saving any changed files. +if (#99 == 4) { Exit(4) } // As above, but return specified value (instead of 0) to OS +if (#99 == 5) { Xall } // Exit Vedit. Save changed files without prompting. +if (#99 == 6) { Qall } // Exit Vedit. Do not save any files. diff --git a/Task/Program-termination/Visual-Basic/program-termination.vb b/Task/Program-termination/Visual-Basic/program-termination.vb new file mode 100644 index 0000000000..8afea52cf3 --- /dev/null +++ b/Task/Program-termination/Visual-Basic/program-termination.vb @@ -0,0 +1,10 @@ +Sub Main() + '... + If problem Then + For n& = Forms.Count To 0 Step -1 + Unload Forms(n&) + Next + Exit Sub + End If + '... +End Sub diff --git a/Task/Program-termination/XPL0/program-termination.xpl0 b/Task/Program-termination/XPL0/program-termination.xpl0 new file mode 100644 index 0000000000..f1150c3562 --- /dev/null +++ b/Task/Program-termination/XPL0/program-termination.xpl0 @@ -0,0 +1 @@ +if Problem then exit 1; diff --git a/Task/Pythagorean-triples/0DESCRIPTION b/Task/Pythagorean-triples/0DESCRIPTION new file mode 100644 index 0000000000..7bee6004a2 --- /dev/null +++ b/Task/Pythagorean-triples/0DESCRIPTION @@ -0,0 +1,12 @@ +A [[wp:Pythagorean_triple|Pythagorean triple]] is defined as three positive integers (a, b, c) where a < b < c, and a^2+b^2=c^2. They are called primitive triples if a, b, c are coprime, that is, if their pairwise greatest common divisors {\rm gcd}(a, b) = {\rm gcd}(a, c) = {\rm gcd}(b, c) = 1. Because of their relationship through the Pythagorean theorem, a, b, and c are coprime if a and b are coprime ({\rm gcd}(a, b) = 1). Each triple forms the length of the sides of a right triangle, whose perimeter is P=a+b+c. + +'''Task''' + +The task is to determine how many Pythagorean triples there are with a perimeter no larger than 100 and the number of these that are primitive. + +'''Extra credit:''' Deal with large values. Can your program handle a max perimeter of 1,000,000? What about 10,000,000? 100,000,000? + +Note: the extra credit is not for you to demonstrate how fast your language is compared to others; you need a proper algorithm to solve them in a timely manner. + +;Cf: +* [[List comprehensions]] diff --git a/Task/Pythagorean-triples/Ada/pythagorean-triples.ada b/Task/Pythagorean-triples/Ada/pythagorean-triples.ada new file mode 100644 index 0000000000..c991e2c99d --- /dev/null +++ b/Task/Pythagorean-triples/Ada/pythagorean-triples.ada @@ -0,0 +1,33 @@ +with Ada.Text_IO; + +procedure Pythagorean_Triples is + + type Large_Natural is range 0 .. 2**63-1; + -- this is the maximum for gnat + + procedure New_Triangle(A, B, C: Large_Natural; + Max_Perimeter: Large_Natural; + Total_Cnt, Primitive_Cnt: in out Large_Natural) is + Perimeter: constant Large_Natural := A + B + C; + begin + if Perimeter <= Max_Perimeter then + Primitive_Cnt := Primitive_Cnt + 1; + Total_Cnt := Total_Cnt + Max_Perimeter / Perimeter; + New_Triangle(A-2*B+2*C, 2*A-B+2*C, 2*A-2*B+3*C, Max_Perimeter, Total_Cnt, Primitive_Cnt); + New_Triangle(A+2*B+2*C, 2*A+B+2*C, 2*A+2*B+3*C, Max_Perimeter, Total_Cnt, Primitive_Cnt); + New_Triangle(2*B+2*C-A, B+2*C-2*A, 2*B+3*C-2*A, Max_Perimeter, Total_Cnt, Primitive_Cnt); + end if; + end New_Triangle; + + T_Cnt, P_Cnt: Large_Natural; + +begin + for I in 1 .. 9 loop + T_Cnt := 0; + P_Cnt := 0; + New_Triangle(3,4,5, 10**I, Total_Cnt => T_Cnt, Primitive_Cnt => P_Cnt); + Ada.Text_IO.Put_Line("Up to 10 **" & Integer'Image(I) & " :" & + Large_Natural'Image(T_Cnt) & " Triples," & + Large_Natural'Image(P_Cnt) & " Primitives"); + end loop; +end Pythagorean_Triples; diff --git a/Task/Pythagorean-triples/BBC-BASIC/pythagorean-triples.bbc b/Task/Pythagorean-triples/BBC-BASIC/pythagorean-triples.bbc new file mode 100644 index 0000000000..4a0f603a6d --- /dev/null +++ b/Task/Pythagorean-triples/BBC-BASIC/pythagorean-triples.bbc @@ -0,0 +1,27 @@ + DIM U0%(2,2), U1%(2,2), U2%(2,2), seed%(2) + U0%() = 1, -2, 2, 2, -1, 2, 2, -2, 3 + U1%() = 1, 2, 2, 2, 1, 2, 2, 2, 3 + U2%() = -1, 2, 2, -2, 1, 2, -2, 2, 3 + + seed%() = 3, 4, 5 + FOR power% = 1 TO 7 + all% = 0 : prim% = 0 + PROCtri(seed%(), 10^power%, all%, prim%) + PRINT "Up to 10^"; power%, ": " all% " triples" prim% " primitives" + NEXT + END + + DEF PROCtri(i%(), mp%, RETURN all%, RETURN prim%) + LOCAL t%() : DIM t%(2) + + IF SUM(i%()) > mp% ENDPROC + prim% += 1 + all% += mp% DIV SUM(i%()) + + t%() = U0%() . i%() + PROCtri(t%(), mp%, all%, prim%) + t%() = U1%() . i%() + PROCtri(t%(), mp%, all%, prim%) + t%() = U2%() . i%() + PROCtri(t%(), mp%, all%, prim%) + ENDPROC diff --git a/Task/Pythagorean-triples/Bracmat/pythagorean-triples-1.bracmat b/Task/Pythagorean-triples/Bracmat/pythagorean-triples-1.bracmat new file mode 100644 index 0000000000..53d584e4ed --- /dev/null +++ b/Task/Pythagorean-triples/Bracmat/pythagorean-triples-1.bracmat @@ -0,0 +1,53 @@ +(pythagoreanTriples= + total prim max-peri U +. (.(1,-2,2) (2,-1,2) (2,-2,3)) + (.(1,2,2) (2,1,2) (2,2,3)) + (.(-1,2,2) (-2,1,2) (-2,2,3)) + : ?U + & ( new-tri + = i t p Urows Urow Ucols + , a b c loop A B C + . !arg:(,?a,?b,?c) + & !a+!b+!c:~>!max-peri:?p + & 1+!prim:?prim + & div$(!max-peri.!p)+!total:?total + & !U:?Urows + & ( loop + = !Urows:(.?Urow) ?Urows + & !Urow:?Ucols + & :?t + & whl + ' ( !Ucols:(?A,?B,?C) ?Ucols + & (!t,!a*!A+!b*!B+!c*!C):?t + ) + & new-tri$!t + & !loop + ) + & !loop + | + ) + & ( Main + = seed + . (,3,4,5):?seed + & 10:?max-peri + & whl + ' ( 0:?total:?prim + & new-tri$!seed + & out + $ ( str + $ ( "Up to " + !max-peri + ": " + !total + " triples, " + !prim + " primitives." + ) + ) + & !max-peri*10:~>10000000:?max-peri + ) + ) + & Main$ +); + +pythagoreanTriples$; diff --git a/Task/Pythagorean-triples/Bracmat/pythagorean-triples-2.bracmat b/Task/Pythagorean-triples/Bracmat/pythagorean-triples-2.bracmat new file mode 100644 index 0000000000..3c6c9a3508 --- /dev/null +++ b/Task/Pythagorean-triples/Bracmat/pythagorean-triples-2.bracmat @@ -0,0 +1,54 @@ +(pythagoreanTriples= + total prim max-peri U stack +. (.(1,-2,2) (2,-1,2) (2,-2,3)) + (.(1,2,2) (2,1,2) (2,2,3)) + (.(-1,2,2) (-2,1,2) (-2,2,3)) + : ?U + & ( new-tri + = i t p Urows Urow Ucols Ucol + , a b c loop A B C + . !arg:(,?a,?b,?c) + & !a+!b+!c:~>!max-peri:?p + & 1+!prim:?prim + & div$(!max-peri.!p)+!total:?total + & !U:?Urows + & ( loop + = !Urows:(.?Urow) ?Urows + & !Urow:?Ucols + & :?t + & whl + ' ( !Ucols:(?A,?B,?C) ?Ucols + & (!t,!a*!A+!b*!B+!c*!C):?t + ) + & !t !stack:?stack + & !loop + ) + & !loop + | + ) + & ( Main + = seed + . 10:?max-peri + & whl + ' ( 0:?total:?prim + & (,3,4,5):?stack + & whl + ' (!stack:%?seed ?stack&new-tri$!seed) + & out + $ ( str + $ ( "Up to " + !max-peri + ": " + !total + " triples, " + !prim + " primitives." + ) + ) + & !max-peri*10:~>100000000:?max-peri + ) + ) + & Main$ +); + +pythagoreanTriples$; diff --git a/Task/Pythagorean-triples/C/pythagorean-triples-1.c b/Task/Pythagorean-triples/C/pythagorean-triples-1.c new file mode 100644 index 0000000000..2fc5d14db2 --- /dev/null +++ b/Task/Pythagorean-triples/C/pythagorean-triples-1.c @@ -0,0 +1,46 @@ +#include +#include + +typedef unsigned long long xint; +typedef unsigned long ulong; + +inline ulong gcd(ulong m, ulong n) +{ + ulong t; + while (n) { t = n; n = m % n; m = t; } + return m; +} + +int main() +{ + ulong a, b, c, pytha = 0, prim = 0, max_p = 100; + xint aa, bb, cc; + + for (a = 1; a <= max_p / 3; a++) { + aa = (xint)a * a; + printf("a = %lu\r", a); /* show that we are working */ + fflush(stdout); + + /* max_p/2: valid limit, because one side of triangle + * must be less than the sum of the other two + */ + for (b = a + 1; b < max_p/2; b++) { + bb = (xint)b * b; + for (c = b + 1; c < max_p/2; c++) { + cc = (xint)c * c; + if (aa + bb < cc) break; + if (a + b + c > max_p) break; + + if (aa + bb == cc) { + pytha++; + if (gcd(a, b) == 1) prim++; + } + } + } + } + + printf("Up to %lu, there are %lu triples, of which %lu are primitive\n", + max_p, pytha, prim); + + return 0; +} diff --git a/Task/Pythagorean-triples/C/pythagorean-triples-2.c b/Task/Pythagorean-triples/C/pythagorean-triples-2.c new file mode 100644 index 0000000000..87951d088a --- /dev/null +++ b/Task/Pythagorean-triples/C/pythagorean-triples-2.c @@ -0,0 +1 @@ +Up to 100, there are 17 triples, of which 7 are primitive diff --git a/Task/Pythagorean-triples/C/pythagorean-triples-3.c b/Task/Pythagorean-triples/C/pythagorean-triples-3.c new file mode 100644 index 0000000000..5b2c8c35ce --- /dev/null +++ b/Task/Pythagorean-triples/C/pythagorean-triples-3.c @@ -0,0 +1,48 @@ +#include +#include +#include + +/* should be 64-bit integers if going over 1 billion */ +typedef unsigned long xint; +#define FMT "%lu" + +xint total, prim, max_peri; +xint U[][9] = {{ 1, -2, 2, 2, -1, 2, 2, -2, 3}, + { 1, 2, 2, 2, 1, 2, 2, 2, 3}, + {-1, 2, 2, -2, 1, 2, -2, 2, 3}}; + +void new_tri(xint in[]) +{ + int i; + xint t[3], p = in[0] + in[1] + in[2]; + + if (p > max_peri) return; + + prim ++; + + /* for every primitive triangle, its multiples would be right-angled too; + * count them up to the max perimeter */ + total += max_peri / p; + + /* recursively produce next tier by multiplying the matrices */ + for (i = 0; i < 3; i++) { + t[0] = U[i][0] * in[0] + U[i][1] * in[1] + U[i][2] * in[2]; + t[1] = U[i][3] * in[0] + U[i][4] * in[1] + U[i][5] * in[2]; + t[2] = U[i][6] * in[0] + U[i][7] * in[1] + U[i][8] * in[2]; + new_tri(t); + } +} + +int main() +{ + xint seed[3] = {3, 4, 5}; + + for (max_peri = 10; max_peri <= 100000000; max_peri *= 10) { + total = prim = 0; + new_tri(seed); + + printf( "Up to "FMT": "FMT" triples, "FMT" primitives.\n", + max_peri, total, prim); + } + return 0; +} diff --git a/Task/Pythagorean-triples/C/pythagorean-triples-4.c b/Task/Pythagorean-triples/C/pythagorean-triples-4.c new file mode 100644 index 0000000000..e94ac2d3bd --- /dev/null +++ b/Task/Pythagorean-triples/C/pythagorean-triples-4.c @@ -0,0 +1,8 @@ +Up to 10: 0 triples, 0 primitives. +Up to 100: 17 triples, 7 primitives. +Up to 1000: 325 triples, 70 primitives. +Up to 10000: 4858 triples, 703 primitives. +Up to 100000: 64741 triples, 7026 primitives. +Up to 1000000: 808950 triples, 70229 primitives. +Up to 10000000: 9706567 triples, 702309 primitives. +Up to 100000000: 113236940 triples, 7023027 primitives. diff --git a/Task/Pythagorean-triples/C/pythagorean-triples-5.c b/Task/Pythagorean-triples/C/pythagorean-triples-5.c new file mode 100644 index 0000000000..f365882c1a --- /dev/null +++ b/Task/Pythagorean-triples/C/pythagorean-triples-5.c @@ -0,0 +1,51 @@ +#include +#include +#include + +/* should be 64-bit integers if going over 1 billion */ +typedef unsigned long xint; +#define FMT "%lu" + +xint total, prim, max_peri; + +void new_tri(xint in[]) +{ + int i; + xint t[3], p; + xint x = in[0], y = in[1], z = in[2]; + +recur: p = x + y + z; + if (p > max_peri) return; + + prim ++; + total += max_peri / p; + + t[0] = x - 2 * y + 2 * z; + t[1] = 2 * x - y + 2 * z; + t[2] = t[1] - y + z; + new_tri(t); + + t[0] += 4 * y; + t[1] += 2 * y; + t[2] += 4 * y; + new_tri(t); + + z = t[2] - 4 * x; + y = t[1] - 4 * x; + x = t[0] - 2 * x; + goto recur; +} + +int main() +{ + xint seed[3] = {3, 4, 5}; + + for (max_peri = 10; max_peri <= 100000000; max_peri *= 10) { + total = prim = 0; + new_tri(seed); + + printf( "Up to "FMT": "FMT" triples, "FMT" primitives.\n", + max_peri, total, prim); + } + return 0; +} diff --git a/Task/Pythagorean-triples/CoffeeScript/pythagorean-triples.coffeescript b/Task/Pythagorean-triples/CoffeeScript/pythagorean-triples.coffeescript new file mode 100644 index 0000000000..f9a72660a1 --- /dev/null +++ b/Task/Pythagorean-triples/CoffeeScript/pythagorean-triples.coffeescript @@ -0,0 +1,33 @@ +gcd = (x, y) -> + return x if y == 0 + gcd(y, x % y) + +# m,n generate primitive Pythag triples +# +# preconditions: +# m, n are integers of different parity +# m > n +# gcd(m,n) == 1 (coprime) +# +# m, n generate: [m*m - n*n, 2*m*n, m*m + n*n] +# perimeter is 2*m*m + 2*m*n = 2 * m * (m+n) +count_triples = (max_perim) -> + num_primitives = 0 + num_triples = 0 + m = 2 + upper_limit = Math.sqrt max_perim / 2 + while m <= upper_limit + n = m % 2 + 1 + p = 2*m*m + 2*m*n + delta = 4*m + while n < m and p <= max_perim + if gcd(m, n) == 1 + num_primitives += 1 + num_triples += Math.floor max_perim / p + n += 2 + p += delta + m += 1 + console.log num_primitives, num_triples + +max_perim = Math.pow 10, 9 # takes under a minute +count_triples(max_perim) diff --git a/Task/Pythagorean-triples/Common-Lisp/pythagorean-triples-1.lisp b/Task/Pythagorean-triples/Common-Lisp/pythagorean-triples-1.lisp new file mode 100644 index 0000000000..cc1b0ec5fe --- /dev/null +++ b/Task/Pythagorean-triples/Common-Lisp/pythagorean-triples-1.lisp @@ -0,0 +1,19 @@ +(defun mmul (a b) + (loop for x in a collect + (loop for y in x + for z in b sum (* y z)))) + +(defun count-tri (lim) + (let ((prim 0) (cnt 0)) + (labels ((count1 (tr) + (let ((peri (reduce #'+ tr))) + (when (<= peri lim) + (incf prim) + (incf cnt (truncate lim peri)) + (count1 (mmul '(( 1 -2 2) ( 2 -1 2) ( 2 -2 3)) tr)) + (count1 (mmul '(( 1 2 2) ( 2 1 2) ( 2 2 3)) tr)) + (count1 (mmul '((-1 2 2) (-2 1 2) (-2 2 3)) tr)))))) + (count1 '(3 4 5)) + (format t "~a: ~a prim, ~a all~%" lim prim cnt)))) + +(loop for p from 2 do (count-tri (expt 10 p))) diff --git a/Task/Pythagorean-triples/Common-Lisp/pythagorean-triples-2.lisp b/Task/Pythagorean-triples/Common-Lisp/pythagorean-triples-2.lisp new file mode 100644 index 0000000000..20123603c4 --- /dev/null +++ b/Task/Pythagorean-triples/Common-Lisp/pythagorean-triples-2.lisp @@ -0,0 +1,7 @@ +100: 7 prim, 17 all +1000: 70 prim, 325 all +10000: 703 prim, 4858 all +100000: 7026 prim, 64741 all +1000000: 70229 prim, 808950 all +10000000: 702309 prim, 9706567 all +... diff --git a/Task/Pythagorean-triples/D/pythagorean-triples-1.d b/Task/Pythagorean-triples/D/pythagorean-triples-1.d new file mode 100644 index 0000000000..80c8ac72df --- /dev/null +++ b/Task/Pythagorean-triples/D/pythagorean-triples-1.d @@ -0,0 +1,17 @@ +import std.stdio; + +ulong[2] tri(ulong lim, ulong a=3, ulong b=4, ulong c=5) { + immutable l = a + b + c; + if (l > lim) + return [0, 0]; + typeof(return) r = [1, lim / l]; + r[] += tri(lim, a - 2*b + 2*c, 2*a - b + 2*c, 2*a - 2*b + 3*c)[]; + r[] += tri(lim, a + 2*b + 2*c, 2*a + b + 2*c, 2*a + 2*b + 3*c)[]; + r[] += tri(lim, -a + 2*b + 2*c, -2*a + b + 2*c, -2*a + 2*b + 3*c)[]; + return r; +} + +void main() { + foreach (immutable p; 1 .. 8) + writeln(10 ^^ p, " ", tri(10 ^^ p)); +} diff --git a/Task/Pythagorean-triples/D/pythagorean-triples-2.d b/Task/Pythagorean-triples/D/pythagorean-triples-2.d new file mode 100644 index 0000000000..d4ef74dcc3 --- /dev/null +++ b/Task/Pythagorean-triples/D/pythagorean-triples-2.d @@ -0,0 +1,40 @@ +import std.stdio; + +alias uint xuint; // ulong if going over 1 billion. + +__gshared xuint nTriples, nPrimitives, limit; + +void countTriples(xuint x, xuint y, xuint z) nothrow { + while (true) { + immutable xuint p = x + y + z; + if (p > limit) + return; + + nPrimitives++; + nTriples += limit / p; + + xuint t0 = x - 2 * y + 2 * z; + xuint t1 = 2 * x - y + 2 * z; + xuint t2 = t1 - y + z; + countTriples(t0, t1, t2); + + t0 += 4 * y; + t1 += 2 * y; + t2 += 4 * y; + countTriples(t0, t1, t2); + + z = t2 - 4 * x; + y = t1 - 4 * x; + x = t0 - 2 * x; + } +} + +void main() { + foreach (p; 1 .. 9) { + limit = (cast(xuint)10) ^^ p; + nTriples = nPrimitives = 0; + countTriples(3, 4, 5); + writefln("Up to %11d: %11d triples, %9d primitives.", + limit, nTriples, nPrimitives); + } +} diff --git a/Task/Pythagorean-triples/Erlang/pythagorean-triples.erl b/Task/Pythagorean-triples/Erlang/pythagorean-triples.erl new file mode 100644 index 0000000000..6a86c839b8 --- /dev/null +++ b/Task/Pythagorean-triples/Erlang/pythagorean-triples.erl @@ -0,0 +1,45 @@ +%% +%% Pythagorian triples in Erlang, J.W. Luiten +%% +-module(triples). +-export([main/1]). + +%% Transformations t1, t2 and t3 to generate new triples +t1(A, B, C) -> + {A-2*B+2*C, 2*A-B+2*C, 2*A-2*B+3*C}. +t2(A, B, C) -> + {A+2*B+2*C, 2*A+B+2*C, 2*A+2*B+3*C}. +t3(A, B, C) -> + {2*B+2*C-A, B+2*C-2*A, 2*B+3*C-2*A}. + +%% Generation of triples +count_triples(A, B, C, Tot_acc, Cnt_acc, Max_perimeter) when (A+B+C) =< Max_perimeter -> + Tot1 = Tot_acc + Max_perimeter div (A+B+C), + {A1, B1, C1} = t1(A, B, C), + {Tot2, Cnt2} = count_triples(A1, B1, C1, Tot1, Cnt_acc+1, Max_perimeter), + + {A2, B2, C2} = t2(A, B, C), + {Tot3, Cnt3} = count_triples(A2, B2, C2, Tot2, Cnt2, Max_perimeter), + + {A3, B3, C3} = t3(A, B, C), + {Tot4, Cnt4} = count_triples(A3, B3, C3, Tot3, Cnt3, Max_perimeter), + {Tot4, Cnt4}; +count_triples(_A, _B, _C, Tot_acc, Cnt_acc, _Max_perimeter) -> + {Tot_acc, Cnt_acc}. + +count_triples(A, B, C, Pow) -> + Max = trunc(math:pow(10, Pow)), + {Tot, Prim} = count_triples(A, B, C, 0, 0, Max), + {Pow, Tot, Prim}. + +count_triples(Pow) -> + count_triples(3, 4, 5, Pow). + +%% Display a single result. +display_result({Pow, Tot, Prim}) -> + io:format("Up to 10 ** ~w : ~w triples, ~w primitives~n", [Pow, Tot, Prim]). + +main(Max) -> + L = lists:seq(1, Max), + Answer = lists:map(fun(X) -> count_triples(X) end, L), + lists:foreach(fun(Result) -> display_result(Result) end, Answer). diff --git a/Task/Pythagorean-triples/Euphoria/pythagorean-triples.euphoria b/Task/Pythagorean-triples/Euphoria/pythagorean-triples.euphoria new file mode 100644 index 0000000000..69823a7e57 --- /dev/null +++ b/Task/Pythagorean-triples/Euphoria/pythagorean-triples.euphoria @@ -0,0 +1,21 @@ +function tri(atom lim, sequence in) + sequence r + atom p + p = in[1] + in[2] + in[3] + if p > lim then + return {0, 0} + end if + r = {1, floor(lim / p)} + r += tri(lim, { in[1]-2*in[2]+2*in[3], 2*in[1]-in[2]+2*in[3], 2*in[1]-2*in[2]+3*in[3]}) + r += tri(lim, { in[1]+2*in[2]+2*in[3], 2*in[1]+in[2]+2*in[3], 2*in[1]+2*in[2]+3*in[3]}) + r += tri(lim, {-in[1]+2*in[2]+2*in[3], -2*in[1]+in[2]+2*in[3], -2*in[1]+2*in[2]+3*in[3]}) + return r +end function + +atom max_peri +max_peri = 10 +while max_peri <= 100000000 do + printf(1,"%d: ", max_peri) + ? tri(max_peri, {3, 4, 5}) + max_peri *= 10 +end while diff --git a/Task/Pythagorean-triples/Factor/pythagorean-triples.factor b/Task/Pythagorean-triples/Factor/pythagorean-triples.factor new file mode 100644 index 0000000000..e523370366 --- /dev/null +++ b/Task/Pythagorean-triples/Factor/pythagorean-triples.factor @@ -0,0 +1,43 @@ +USING: accessors arrays formatting kernel literals math +math.functions math.matrices math.ranges sequences ; +IN: rosettacode.pyth + +CONSTANT: T1 { + { 1 2 2 } + { -2 -1 -2 } + { 2 2 3 } +} +CONSTANT: T2 { + { 1 2 2 } + { 2 1 2 } + { 2 2 3 } +} +CONSTANT: T3 { + { -1 -2 -2 } + { 2 1 2 } + { 2 2 3 } +} + +CONSTANT: base { 3 4 5 } + +TUPLE: triplets-count primitives total ; +: <0-triplets-count> ( -- a ) 0 0 \ triplets-count boa ; +: next-triplet ( triplet T -- triplet' ) [ 1array ] [ m. ] bi* first ; +: candidates-triplets ( seed -- candidates ) + ${ T1 T2 T3 } [ next-triplet ] with map ; +: add-triplets ( current-triples limit triplet -- stop ) + sum 2dup > [ + /i [ + ] curry change-total + [ 1 + ] change-primitives drop t + ] [ 3drop f ] if ; +: all-triplets ( current-triples limit seed -- triplets ) + 3dup add-triplets [ + candidates-triplets [ all-triplets ] with swapd reduce + ] [ 2drop ] if ; +: count-triplets ( limit -- count ) + <0-triplets-count> swap base all-triplets ; +: pprint-triplet-count ( limit count -- ) + [ total>> ] [ primitives>> ] bi + "Up to %d: %d triples, %d primitives.\n" printf ; +: pyth ( -- ) + 8 [1,b] [ 10^ dup count-triplets pprint-triplet-count ] each ; diff --git a/Task/Pythagorean-triples/Forth/pythagorean-triples.fth b/Task/Pythagorean-triples/Forth/pythagorean-triples.fth new file mode 100644 index 0000000000..c4f6ac17b9 --- /dev/null +++ b/Task/Pythagorean-triples/Forth/pythagorean-triples.fth @@ -0,0 +1,169 @@ +\ Two methods to create Pythagorean Triples +\ this code has been tested using Win32Forth and gforth + +: pythag_fibo ( f1 f0 -- ) + \ Create Pythagorean Triples from 4 element Fibonacci series + \ this is called with the first two members of a 4 element Fibonacci series + \ Price and Burkhart have two good articles about this method + \ "Pythagorean Tree: A New Species" and + \ "Heron's Formula, Descartes Circles, and Pythagorean Triangles" + \ Horadam found out how to compute Pythagorean Triples from Fibonacci series + + \ compute the two other members of the Fibonacci series and put them in + \ local variables. I was unable to do this with out using locals + 2DUP + 2DUP + 2OVER 2DUP + 2DUP + + LOCALS| f3 f2 f1 f0 | + + wk_level @ 9 .r f0 8 .r f1 8 .r f2 8 .r f3 8 .r + + \ this block calculates the sides of the Pythagorean Triangle using single precision + \ f0 f3 * 14 .r \ side a (always odd) + \ 2 f1 * f2 * 10 .r \ side b (a multiple of 4) + \ f0 f2 * f1 f3 * + 10 .r \ side c, the hyponenuse, (always odd) + + \ this block calculates double precision values + f0 f3 um* 15 d.r \ side a (always odd) + 2 f1 * f2 um* 15 d.r \ side b (a multiple of 4) + f0 f2 um* f1 f3 um* d+ 17 d.r cr \ side c, the hypotenuse, (always odd) + + MAX_LEVEL @ wk_LEVEL @ U> IF \ TRUE if MAX_LEVEL > WK_LEVEL + wk_level @ 1+ wk_level ! + + \ this creates a teranary tree of Pythagorean triples + \ use a two of the members of the Fibonacci series as seeds for the + \ next level + \ It's the same tree created by Barning or Hall using matrix multiplication + f3 f1 recurse + f3 f2 recurse + f0 f2 recurse + + wk_level @ 1- wk_level ! + + else + then + + drop drop drop drop ; + +\ implements the Fibonacci series -- Pythagorean triple +\ the stack contents sets how many iteration levels there will be +: pf_test + \ the stack contents set up the maximum level + max_level ! + 0 wk_level ! + cr + + \ call the function with the first two elements of the base Fibonacci series + 1 1 pythag_fibo ; + +: gcd ( a b -- gcd ) + begin ?dup while tuck mod repeat ; + +\ this is the classical algorithm, known to Euclid, it is explained in many +\ books on Number Theory +\ this generates all primitive Pythagorean triples + +\ i -- inner loop index or current loop index +\ j -- outer loop index +\ stack contents is the upper limit for j +\ i and j can not both be odd +\ the gcd( i, j ) must be 1 +\ j is greater than i +\ the stack contains the upper limit of the j variable +: pythag_ancn ( limit -- ) + cr + 1 + 2 do + i 1 and if 2 else 1 then + \ this sets the start value of the inner loop so that + \ if the outer loop index is odd only even inner loop indices happen + \ if the outer loop index is even only odd inner loop indices happen + i swap do + i j gcd 1 - 0> if else \ do this if gcd( i, j ) is 1 + j 5 .r i 5 .r + + \ j j * i i * - 12 .r \ a side of Pythagorean triangle (always odd) + \ i j * 2 * 9 .r \ b side of Pythagorean triangle (multiple of 4) + \ i i * j j * + 9 .r \ hypotenuse of Pythagorean triangle (always odd) + + \ this block calculates double precision Pythagorean triple values + j j um* i i um* d- 15 d.r \ a side of Pythagorean triangle (always odd) + i j um* d2* 15 d.r \ b side of Pythagorean triangle (multiple of 4) + i i um* j j um* d+ 17 d.r \ hypotenuse of Pythagorean triangle (always odd) + + cr then 2 +loop \ keep i being all odd or all even + loop ; + + + +Current directory: C:\Forth ok +FLOAD 'C:\Forth\ancien_fibo_pythag.F' ok + ok + + ok + ok +3 pf_test + 0 1 1 2 3 3 4 5 + 1 3 1 4 5 15 8 17 + 2 5 1 6 7 35 12 37 + 3 7 1 8 9 63 16 65 + 3 7 6 13 19 133 156 205 + 3 5 6 11 17 85 132 157 + 2 5 4 9 13 65 72 97 + 3 13 4 17 21 273 136 305 + 3 13 9 22 31 403 396 565 + 3 5 9 14 23 115 252 277 + 2 3 4 7 11 33 56 65 + 3 11 4 15 19 209 120 241 + 3 11 7 18 25 275 252 373 + 3 3 7 10 17 51 140 149 + 1 3 2 5 7 21 20 29 + 2 7 2 9 11 77 36 85 + 3 11 2 13 15 165 52 173 + 3 11 9 20 29 319 360 481 + 3 7 9 16 25 175 288 337 + 2 7 5 12 17 119 120 169 + 3 17 5 22 27 459 220 509 + 3 17 12 29 41 697 696 985 + 3 7 12 19 31 217 456 505 + 2 3 5 8 13 39 80 89 + 3 13 5 18 23 299 180 349 + 3 13 8 21 29 377 336 505 + 3 3 8 11 19 57 176 185 + 1 1 2 3 5 5 12 13 + 2 5 2 7 9 45 28 53 + 3 9 2 11 13 117 44 125 + 3 9 7 16 23 207 224 305 + 3 5 7 12 19 95 168 193 + 2 5 3 8 11 55 48 73 + 3 11 3 14 17 187 84 205 + 3 11 8 19 27 297 304 425 + 3 5 8 13 21 105 208 233 + 2 1 3 4 7 7 24 25 + 3 7 3 10 13 91 60 109 + 3 7 4 11 15 105 88 137 + 3 1 4 5 9 9 40 41 + ok + ok +10 pythag_ancn + 2 1 3 4 5 + 3 2 5 12 13 + 4 1 15 8 17 + 4 3 7 24 25 + 5 2 21 20 29 + 5 4 9 40 41 + 6 1 35 12 37 + 6 5 11 60 61 + 7 2 45 28 53 + 7 4 33 56 65 + 7 6 13 84 85 + 8 1 63 16 65 + 8 3 55 48 73 + 8 5 39 80 89 + 8 7 15 112 113 + 9 2 77 36 85 + 9 4 65 72 97 + 9 8 17 144 145 + 10 1 99 20 101 + 10 3 91 60 109 + 10 7 51 140 149 + 10 9 19 180 181 + ok diff --git a/Task/Pythagorean-triples/Fortran/pythagorean-triples.f b/Task/Pythagorean-triples/Fortran/pythagorean-triples.f new file mode 100644 index 0000000000..f8377a3f97 --- /dev/null +++ b/Task/Pythagorean-triples/Fortran/pythagorean-triples.f @@ -0,0 +1,46 @@ +module triples + implicit none + + integer :: max_peri, prim, total + integer :: u(9,3) = reshape((/ 1, -2, 2, 2, -1, 2, 2, -2, 3, & + 1, 2, 2, 2, 1, 2, 2, 2, 3, & + -1, 2, 2, -2, 1, 2, -2, 2, 3 /), & + (/ 9, 3 /)) + +contains + +recursive subroutine new_tri(in) + integer, intent(in) :: in(:) + integer :: i + integer :: t(3), p + + p = sum(in) + if (p > max_peri) return + + prim = prim + 1 + total = total + max_peri / p + do i = 1, 3 + t(1) = sum(u(1:3, i) * in) + t(2) = sum(u(4:6, i) * in) + t(3) = sum(u(7:9, i) * in) + call new_tri(t); + end do +end subroutine new_tri +end module triples + +program Pythagorean + use triples + implicit none + + integer :: seed(3) = (/ 3, 4, 5 /) + + max_peri = 10 + do + total = 0 + prim = 0 + call new_tri(seed) + write(*, "(a, i10, 2(i10, a))") "Up to", max_peri, total, " triples", prim, " primitives" + if(max_peri == 100000000) exit + max_peri = max_peri * 10 + end do +end program Pythagorean diff --git a/Task/Pythagorean-triples/Go/pythagorean-triples.go b/Task/Pythagorean-triples/Go/pythagorean-triples.go new file mode 100644 index 0000000000..0f04f2a325 --- /dev/null +++ b/Task/Pythagorean-triples/Go/pythagorean-triples.go @@ -0,0 +1,25 @@ +package main + +import "fmt" + +var total, prim, maxPeri int64 + +func newTri(s0, s1, s2 int64) { + if p := s0 + s1 + s2; p <= maxPeri { + prim++ + total += maxPeri / p + newTri(+1*s0-2*s1+2*s2, +2*s0-1*s1+2*s2, +2*s0-2*s1+3*s2) + newTri(+1*s0+2*s1+2*s2, +2*s0+1*s1+2*s2, +2*s0+2*s1+3*s2) + newTri(-1*s0+2*s1+2*s2, -2*s0+1*s1+2*s2, -2*s0+2*s1+3*s2) + } +} + +func main() { + for maxPeri = 100; maxPeri <= 1e11; maxPeri *= 10 { + prim = 0 + total = 0 + newTri(3, 4, 5) + fmt.Printf("Up to %d: %d triples, %d primitives\n", + maxPeri, total, prim) + } +} diff --git a/Task/Pythagorean-triples/Haskell/pythagorean-triples-1.hs b/Task/Pythagorean-triples/Haskell/pythagorean-triples-1.hs new file mode 100644 index 0000000000..608f7c17ba --- /dev/null +++ b/Task/Pythagorean-triples/Haskell/pythagorean-triples-1.hs @@ -0,0 +1,5 @@ +pytr n = filter (\(_, a, b, c) -> a+b+c <= n) [(prim a b c, a, b, c) | a <- [1..n], b <- [1..n], c <- [1..n], a < b && b < c, a^2 + b^2 == c^2] + where prim a b _ = gcd a b == 1 + +main = putStrLn $ "Up to 100 there are " ++ (show $ length xs) ++ " triples, of which " ++ (show $ length $ filter (\(x,_,_,_) -> x == True) xs) ++ " are primitive." + where xs = pytr 100 diff --git a/Task/Pythagorean-triples/Haskell/pythagorean-triples-2.hs b/Task/Pythagorean-triples/Haskell/pythagorean-triples-2.hs new file mode 100644 index 0000000000..ed08a31726 --- /dev/null +++ b/Task/Pythagorean-triples/Haskell/pythagorean-triples-2.hs @@ -0,0 +1,15 @@ +triangles :: Int -> [[Int]] +triangles max_peri | max_peri < 12 = [] + | otherwise = concat tiers where + tiers = takeWhile (not.null) $ iterate tier [[3,4,5]] + tier = concatMap (filter ((<=max_peri).sum).tmul) + tmul t = map (map (sum . zipWith (*) t)) + [[[ 1,-2,2],[ 2,-1,2],[ 2,-2,3]], + [[ 1, 2,2],[ 2, 1,2],[ 2, 2,3]], + [[-1, 2,2],[-2, 1,2],[-2, 2,3]]] + +triangle_count max_p = (length t, sum $ map ((max_p `div`).sum) t) + where t = triangles max_p + +main = mapM_ putStrLn $ + map (\n -> show n ++ " " ++ show (triangle_count n)) $ map (10^) [1..] diff --git a/Task/Pythagorean-triples/Icon/pythagorean-triples.icon b/Task/Pythagorean-triples/Icon/pythagorean-triples.icon new file mode 100644 index 0000000000..15cb70cc51 --- /dev/null +++ b/Task/Pythagorean-triples/Icon/pythagorean-triples.icon @@ -0,0 +1,38 @@ +link numbers +link printf + +procedure main(A) # P-triples + + plimit := (0 < integer(\A[1])) | 100 # get perimiter limit + + nonprimitiveS := set() # record unique non-primitives triples + primitiveS := set() # record unique primitive triples + + u := 0 + while (g := (u +:= 1)^2) + 3 * u + 2 < plimit / 2 do { + every v := seq(1) do { + a := g + (i := 2*u*v) + b := (h := 2*v^2) + i + c := g + h + i + if (p := a + b + c) > plimit then break + + insert( (gcd(u,v)=1 & u%2=1, primitiveS) | nonprimitiveS, memo(a,b,c)) + every k := seq(2) do { # k is for larger non-primitives + if k*p > plimit then break + insert(nonprimitiveS,memo(a*k,b*k,c*k) ) + } + } + } + +printf("Under perimiter=%d: Pythagorean Triples=%d including primitives=%d\n", + plimit,*nonprimitiveS+*primitiveS,*primitiveS) + +every put(gcol := [] , &collections) +printf("Time=%d, Collections: total=%d string=%d block=%d",&time,gcol[1],gcol[3],gcol[4]) +end + + +procedure memo(x[]) #: return a csv string of arguments in sorted order +every (s := "") ||:= !sort(x) do s ||:= "," +return s[1:-1] +end diff --git a/Task/Pythagorean-triples/J/pythagorean-triples-1.j b/Task/Pythagorean-triples/J/pythagorean-triples-1.j new file mode 100644 index 0000000000..8a53d7d479 --- /dev/null +++ b/Task/Pythagorean-triples/J/pythagorean-triples-1.j @@ -0,0 +1,14 @@ +pytr=: 3 :0 + r=. i. 0 3 + for_a. 1 + i. <.(y-1)%3 do. + b=. 1 + a + i. <.(y%2)-3*a%2 + c=. a +&.*: b + keep=. (c = <.c) *. y >: a+b+c + if. 1 e. keep do. + r=. r, a,.b ,.&(keep&#) c + end. + end. + (,.~ prim"1)r +) + +prim=: 1 = 2 +./@{. |: diff --git a/Task/Pythagorean-triples/J/pythagorean-triples-2.j b/Task/Pythagorean-triples/J/pythagorean-triples-2.j new file mode 100644 index 0000000000..43fc5d5acb --- /dev/null +++ b/Task/Pythagorean-triples/J/pythagorean-triples-2.j @@ -0,0 +1,26 @@ + pytr 100 +1 3 4 5 +1 5 12 13 +0 6 8 10 +1 7 24 25 +1 8 15 17 +0 9 12 15 +1 9 40 41 +0 10 24 26 +0 12 16 20 +1 12 35 37 +0 15 20 25 +0 15 36 39 +0 16 30 34 +0 18 24 30 +1 20 21 29 +0 21 28 35 +0 24 32 40 + (# , [: {. +/) pytr 10 +0 0 + (# , [: {. +/) pytr 100 +17 7 + (# , [: {. +/) pytr 1000 +325 70 + (# , [: {. +/) pytr 10000 +4858 703 diff --git a/Task/Pythagorean-triples/J/pythagorean-triples-3.j b/Task/Pythagorean-triples/J/pythagorean-triples-3.j new file mode 100644 index 0000000000..540d4c3656 --- /dev/null +++ b/Task/Pythagorean-triples/J/pythagorean-triples-3.j @@ -0,0 +1,5 @@ +trips=:3 :0 + 'm n'=. |:(#~ 1 = 2 | +/"1)(#~ >/"1) ,/ ,"0/~ }. i. <. %: y + prim=. (#~ 1 = 2 +./@{. |:) (#~ y >: +/"1)m (-&*: ,. +:@* ,. +&*:) n + /:~ ; <@(,.~ # {. 1:)@(*/~ 1 + y i.@<.@% +/)"1 prim +) diff --git a/Task/Pythagorean-triples/J/pythagorean-triples-4.j b/Task/Pythagorean-triples/J/pythagorean-triples-4.j new file mode 100644 index 0000000000..38d123e7f8 --- /dev/null +++ b/Task/Pythagorean-triples/J/pythagorean-triples-4.j @@ -0,0 +1,14 @@ + (# , 1 {. +/) trips 10 +0 0 + (# , 1 {. +/) trips 100 +17 7 + (# , 1 {. +/) trips 1000 +325 70 + (# , 1 {. +/) trips 10000 +4858 703 + (# , 1 {. +/) trips 100000 +64741 7026 + (# , 1 {. +/) trips 1000000 +808950 70229 + (# , 1 {. +/) trips 10000000 +9706567 702309 diff --git a/Task/Pythagorean-triples/J/pythagorean-triples-5.j b/Task/Pythagorean-triples/J/pythagorean-triples-5.j new file mode 100644 index 0000000000..27e00eeff1 --- /dev/null +++ b/Task/Pythagorean-triples/J/pythagorean-triples-5.j @@ -0,0 +1,4 @@ +trc=:3 :0 + 'm n'=. |:(#~ 1 = 2 | +/"1)(#~ >/"1) ,/ ,"0/~ }. i. <. %: y + <.y%+/"1 (#~ 1 = 2 +./@{. |:) (#~ y >: +/"1)m (-&*: ,. +:@* ,. +&*:) n +) diff --git a/Task/Pythagorean-triples/J/pythagorean-triples-6.j b/Task/Pythagorean-triples/J/pythagorean-triples-6.j new file mode 100644 index 0000000000..f757c56a9f --- /dev/null +++ b/Task/Pythagorean-triples/J/pythagorean-triples-6.j @@ -0,0 +1,2 @@ + (#,+/)trc 1e8 +7023027 113236940 diff --git a/Task/Pythagorean-triples/Java/pythagorean-triples-1.java b/Task/Pythagorean-triples/Java/pythagorean-triples-1.java new file mode 100644 index 0000000000..988ae3d180 --- /dev/null +++ b/Task/Pythagorean-triples/Java/pythagorean-triples-1.java @@ -0,0 +1,51 @@ +import java.math.BigInteger; +import static java.math.BigInteger.ONE; + +public class PythTrip{ + + public static void main(String[] args){ + long tripCount = 0, primCount = 0; + + //change this to whatever perimeter limit you want;the RAM's the limit + BigInteger periLimit = BigInteger.valueOf(100), + peri2 = periLimit.divide(BigInteger.valueOf(2)), + peri3 = periLimit.divide(BigInteger.valueOf(3)); + + for(BigInteger a = ONE; a.compareTo(peri3) < 0; a = a.add(ONE)){ + BigInteger aa = a.multiply(a); + + for(BigInteger b = a.add(ONE); + b.compareTo(peri2) < 0; b = b.add(ONE)){ + BigInteger bb = b.multiply(b); + BigInteger ab = a.add(b); + BigInteger aabb = aa.add(bb); + + for(BigInteger c = b.add(ONE); + c.compareTo(peri2) < 0; c = c.add(ONE)){ + + int compare = aabb.compareTo(c.multiply(c)); + //if a+b+c > periLimit + if(ab.add(c).compareTo(periLimit) > 0){ + break; + } + //if a^2 + b^2 != c^2 + if(compare < 0){ + break; + }else if (compare == 0){ + tripCount++; + System.out.print(a + ", " + b + ", " + c); + + //does binary GCD under the hood + if(a.gcd(b).equals(ONE)){ + System.out.print(" primitive"); + primCount++; + } + System.out.println(); + } + } + } + } + System.out.println("Up to a perimeter of " + periLimit + ", there are " + + tripCount + " triples, of which " + primCount + " are primitive."); + } +} diff --git a/Task/Pythagorean-triples/Java/pythagorean-triples-2.java b/Task/Pythagorean-triples/Java/pythagorean-triples-2.java new file mode 100644 index 0000000000..be94ccdf07 --- /dev/null +++ b/Task/Pythagorean-triples/Java/pythagorean-triples-2.java @@ -0,0 +1,38 @@ +import java.math.BigInteger; + +public class Triples{ + public static BigInteger LIMIT; + public static final BigInteger TWO = BigInteger.valueOf(2); + public static final BigInteger THREE = BigInteger.valueOf(3); + public static final BigInteger FOUR = BigInteger.valueOf(4); + public static final BigInteger FIVE = BigInteger.valueOf(5); + public static long primCount = 0; + public static long tripCount = 0; + + //I don't know Japanese :p + public static void parChild(BigInteger a, BigInteger b, BigInteger c){ + BigInteger perim = a.add(b).add(c); + if(perim.compareTo(LIMIT) > 0) return; + primCount++; tripCount += LIMIT.divide(perim).longValue(); + BigInteger a2 = TWO.multiply(a), b2 = TWO.multiply(b), c2 = TWO.multiply(c), + c3 = THREE.multiply(c); + parChild(a.subtract(b2).add(c2), + a2.subtract(b).add(c2), + a2.subtract(b2).add(c3)); + parChild(a.add(b2).add(c2), + a2.add(b).add(c2), + a2.add(b2).add(c3)); + parChild(a.negate().add(b2).add(c2), + a2.negate().add(b).add(c2), + a2.negate().add(b2).add(c3)); + } + + public static void main(String[] args){ + for(long i = 100; i <= 10000000; i*=10){ + LIMIT = BigInteger.valueOf(i); + primCount = tripCount = 0; + parChild(THREE, FOUR, FIVE); + System.out.println(LIMIT + ": " + tripCount + " triples, " + primCount + " primitive."); + } + } +} diff --git a/Task/Pythagorean-triples/Liberty-BASIC/pythagorean-triples.liberty b/Task/Pythagorean-triples/Liberty-BASIC/pythagorean-triples.liberty new file mode 100644 index 0000000000..82da930ce0 --- /dev/null +++ b/Task/Pythagorean-triples/Liberty-BASIC/pythagorean-triples.liberty @@ -0,0 +1,44 @@ +print time$() + +for power =1 to 6 + perimeterLimit =10^power + upperBound =int( 1 +perimeterLimit^0.5) + primitives =0 + triples =0 + extras =0 ' will count the in-range multiples of any primitive + + for m =2 to upperBound + for n =1 +( m mod 2 =1) to m -1 step 2 + term1 =2 *m *n + term2 =m *m -n *n + term3 =m *m +n *n + perimeter =term1 +term2 +term3 + + if perimeter <=perimeterLimit then triples =triples +1 + + a =term1 + b =term2 + + do + r = a mod b + a =b + b =r + loop until r <=0 + + if ( a =1) and ( perimeter <=perimeterLimit) then 'we've found a primitive triple if a =1, since hcf =1. And it is inside perimeter range. Save it in an array + primitives =primitives +1 + if term1 >term2 then temp =term1: term1 =term2: term2 =temp 'swap so in increasing order of side length + nEx =int( perimeterLimit /perimeter) 'We have the primitive & removed any multiples. Now calculate ALL the multiples in range. + extras =extras +nEx + end if + + scan + next n + next m + + print " Number of primitives having perimeter below "; 10^power, " was "; primitives, " & "; extras, " non-primitive triples." + print time$() +next power + +print "End" +end diff --git a/Task/Pythagorean-triples/MATLAB/pythagorean-triples.m b/Task/Pythagorean-triples/MATLAB/pythagorean-triples.m new file mode 100644 index 0000000000..3d780f21a3 --- /dev/null +++ b/Task/Pythagorean-triples/MATLAB/pythagorean-triples.m @@ -0,0 +1,16 @@ +N= 100; + a = 1:N; + b = a(ones(N,1),:).^2; + b = b+b'; + b = sqrt(b); [y,x]=find(b==fix(b)); % test + % here some alternative tests + % b = b.^(1/k); [y,x]=find(b==fix(b)); % test 2 + % [y,x]=find(b==(fix(b.^(1/k)).^k)); % test 3 + % b=b.^(1/k); [y,x]=find(abs(b - round(b)) <= 4*eps*b); + + z = sqrt(x.^2+y.^2); + ix = (z+x+y<100) & (x < y) & (y < z); + p = find(gcd(x(ix),y(ix))==1); % find primitive triples + + printf('There are %i Pythagorean Triples and %i primitive triples with a perimeter smaller than %i.\n',... + sum(ix), length(p), N); diff --git a/Task/Pythagorean-triples/Mathematica/pythagorean-triples.math b/Task/Pythagorean-triples/Mathematica/pythagorean-triples.math new file mode 100644 index 0000000000..6600daeba9 --- /dev/null +++ b/Task/Pythagorean-triples/Mathematica/pythagorean-triples.math @@ -0,0 +1,3 @@ +pythag[n_] := Block[{soln = Solve[{a^2 + b^2 == c^2, a + b + c <= n, 0 < a < b < c}, {a, b, c}, Integers]}, + {Length[soln], Count[GCD[a, b] == GCD[b, c] == GCD[c, a] == 1 /. soln, True]} + ] diff --git a/Task/Pythagorean-triples/Modula-3/pythagorean-triples.mod3 b/Task/Pythagorean-triples/Modula-3/pythagorean-triples.mod3 new file mode 100644 index 0000000000..a578790d84 --- /dev/null +++ b/Task/Pythagorean-triples/Modula-3/pythagorean-triples.mod3 @@ -0,0 +1,31 @@ +MODULE PyTriple64 EXPORTS Main; + +IMPORT IO, Fmt; + +VAR tcnt, pcnt, max, i: INTEGER; + +PROCEDURE NewTriangle(a, b, c: INTEGER; VAR tcount, pcount: INTEGER) = + VAR perim := a + b + c; + BEGIN + IF perim <= max THEN + pcount := pcount + 1; + tcount := tcount + max DIV perim; + NewTriangle(a-2*b+2*c, 2*a-b+2*c, 2*a-2*b+3*c, tcount, pcount); + NewTriangle(a+2*b+2*c, 2*a+b+2*c, 2*a+2*b+3*c, tcount, pcount); + NewTriangle(2*b+2*c-a, b+2*c-2*a, 2*b+3*c-2*a, tcount, pcount); + END; + END NewTriangle; + +BEGIN + i := 100; + + REPEAT + max := i; + tcnt := 0; + pcnt := 0; + NewTriangle(3, 4, 5, tcnt, pcnt); + IO.Put(Fmt.Int(i) & ": " & Fmt.Int(tcnt) & " Triples, " & + Fmt.Int(pcnt) & " Primitives\n"); + i := i * 10; + UNTIL i = 10000000; +END PyTriple64. diff --git a/Task/Pythagorean-triples/OCaml/pythagorean-triples.ocaml b/Task/Pythagorean-triples/OCaml/pythagorean-triples.ocaml new file mode 100644 index 0000000000..d9e3a5b4f2 --- /dev/null +++ b/Task/Pythagorean-triples/OCaml/pythagorean-triples.ocaml @@ -0,0 +1,33 @@ +let isqrt n = + let rec iter t = + let d = n - t*t in + if (0 <= d) && (d < t+t+1) (* t*t <= n < (t+1)*(t+1) *) + then t else iter ((t+(n/t))/2) + in iter 1 + +let rec gcd a b = + let t = a mod b in + if t = 0 then b else gcd b t + +let coprime a b = gcd a b = 1 + +let num_to ms = + let ctr = ref 0 in + let prim_ctr = ref 0 in + let max_m = isqrt (ms/2) in + for m = 2 to max_m do + for j = 0 to (m/2) - 1 do + let n = m-(2*j+1) in + if coprime m n then + let s = 2*m*(m+n) in + if s <= ms then + (ctr := !ctr + (ms/s); incr prim_ctr) + done + done; + (!ctr, !prim_ctr) + +let show i = + let s, p = num_to i in + Printf.printf "For perimeters up to %d there are %d total and %d primitive\n%!" i s p;; + +List.iter show [ 100; 1000; 10000; 100000; 1000000; 10000000; 100000000 ] diff --git a/Task/Pythagorean-triples/PARI-GP/pythagorean-triples.pari b/Task/Pythagorean-triples/PARI-GP/pythagorean-triples.pari new file mode 100644 index 0000000000..c0fa24267d --- /dev/null +++ b/Task/Pythagorean-triples/PARI-GP/pythagorean-triples.pari @@ -0,0 +1,15 @@ +do(lim)={ + my(prim,total,P); + lim\=1; + for(m=2,sqrtint(lim\2), + forstep(n=1+m%2,min(sqrtint(lim-m^2),m-1),2, + P=2*m*(m+n); + if(gcd(m,n)==1 && P<=lim, + prim++; + total+=lim\P + ) + ) + ); + [prim,total] +}; +do(100) diff --git a/Task/Pythagorean-triples/Pascal/pythagorean-triples.pascal b/Task/Pythagorean-triples/Pascal/pythagorean-triples.pascal new file mode 100644 index 0000000000..27b5ba8253 --- /dev/null +++ b/Task/Pythagorean-triples/Pascal/pythagorean-triples.pascal @@ -0,0 +1,31 @@ +Program PythagoreanTriples (output); + +var + total, prim, maxPeri: int64; + +procedure newTri(s0, s1, s2: int64); + var + p: int64; + begin + p := s0 + s1 + s2; + if p <= maxPeri then + begin + inc(prim); + total := total + maxPeri div p; + newTri( s0 + 2*(-s1+s2), 2*( s0+s2) - s1, 2*( s0-s1+s2) + s2); + newTri( s0 + 2*( s1+s2), 2*( s0+s2) + s1, 2*( s0+s1+s2) + s2); + newTri(-s0 + 2*( s1+s2), 2*(-s0+s2) + s1, 2*(-s0+s1+s2) + s2); + end; + end; + +begin + maxPeri := 100; + while maxPeri <= 1e10 do + begin + prim := 0; + total := 0; + newTri(3, 4, 5); + writeln('Up to ', maxPeri, ': ', total, ' triples, ', prim, ' primitives.'); + maxPeri := maxPeri * 10; + end; +end. diff --git a/Task/Pythagorean-triples/Perl-6/pythagorean-triples-1.pl6 b/Task/Pythagorean-triples/Perl-6/pythagorean-triples-1.pl6 new file mode 100644 index 0000000000..9a28418386 --- /dev/null +++ b/Task/Pythagorean-triples/Perl-6/pythagorean-triples-1.pl6 @@ -0,0 +1,18 @@ +my %triples; +my $limit = 100; + +for 3 .. $limit/2 -> $c { + for 1 .. $c -> $a { + my $b = ($c * $c - $a * $a).sqrt; + last if $c + $a + $b > $limit; + last if $a > $b; + if $b == $b.Int { + my $key = "$a $b $c"; + %triples{$key} = ([gcd] $c, $a, $b.Int) > 1 ?? 0 !! 1; + say $key, %triples{$key} ?? ' - primitive' !! ''; + } + } +} + +say "There are {+%triples.keys} Pythagorean Triples with a perimeter <= $limit," + ~"\nof which {[+] %triples.values} are primitive."; diff --git a/Task/Pythagorean-triples/Perl-6/pythagorean-triples-2.pl6 b/Task/Pythagorean-triples/Perl-6/pythagorean-triples-2.pl6 new file mode 100644 index 0000000000..772591bfc4 --- /dev/null +++ b/Task/Pythagorean-triples/Perl-6/pythagorean-triples-2.pl6 @@ -0,0 +1,20 @@ +sub triples($limit) { + my $primitive = 0; + my $civilized = 0; + + sub oyako($a, $b, $c) { + my $perim = $a + $b + $c; + return if $perim > $limit; + ++$primitive; $civilized += $limit div $perim; + oyako( $a - 2*$b + 2*$c, 2*$a - $b + 2*$c, 2*$a - 2*$b + 3*$c); + oyako( $a + 2*$b + 2*$c, 2*$a + $b + 2*$c, 2*$a + 2*$b + 3*$c); + oyako(-$a + 2*$b + 2*$c, -2*$a + $b + 2*$c, -2*$a + 2*$b + 3*$c); + } + + oyako(3,4,5); + "$limit => ($primitive $civilized)"; +} + +for 10,100,1000 ... * -> $limit { + say triples $limit; +} diff --git a/Task/Pythagorean-triples/Perl-6/pythagorean-triples-3.pl6 b/Task/Pythagorean-triples/Perl-6/pythagorean-triples-3.pl6 new file mode 100644 index 0000000000..74b87c76ef --- /dev/null +++ b/Task/Pythagorean-triples/Perl-6/pythagorean-triples-3.pl6 @@ -0,0 +1,23 @@ +constant @coeff = [[+1, -2, +2], [+2, -1, +2], [+2, -2, +3]], + [[+1, +2, +2], [+2, +1, +2], [+2, +2, +3]], + [[-1, +2, +2], [-2, +1, +2], [-2, +2, +3]]; + +sub triples($limit) { + + sub oyako(@trippy) { + my $perim = [+] @trippy; + return if $perim > $limit; + take (1 + ($limit div $perim)i); + for @coeff -> @nine { + oyako (map -> @three { [+] @three »*« @trippy }, @nine); + } + return; + } + + my $complex = 0i + [+] gather oyako([3,4,5]); + "$limit => ({$complex.re, $complex.im})"; +} + +for 10,100,1000 ... * -> $limit { + say triples $limit; +} diff --git a/Task/Pythagorean-triples/PicoLisp/pythagorean-triples.l b/Task/Pythagorean-triples/PicoLisp/pythagorean-triples.l new file mode 100644 index 0000000000..48a0f06013 --- /dev/null +++ b/Task/Pythagorean-triples/PicoLisp/pythagorean-triples.l @@ -0,0 +1,15 @@ +(for (Max 10 (>= 100000000 Max) (* Max 10)) + (let (Total 0 Prim 0 In (3 4 5)) + (recur (In) + (let P (apply + In) + (when (>= Max P) + (inc 'Prim) + (inc 'Total (/ Max P)) + (for Row + (quote + (( 1 -2 2) ( 2 -1 2) ( 2 -2 3)) + (( 1 2 2) ( 2 1 2) ( 2 2 3)) + ((-1 2 2) (-2 1 2) (-2 2 3)) ) + (recurse + (mapcar '((U) (sum * U In)) Row) ) ) ) ) ) + (prinl "Up to " Max ": " Total " triples, " Prim " primitives.") ) ) diff --git a/Task/Pythagorean-triples/PureBasic/pythagorean-triples.purebasic b/Task/Pythagorean-triples/PureBasic/pythagorean-triples.purebasic new file mode 100644 index 0000000000..b61fc5a3ad --- /dev/null +++ b/Task/Pythagorean-triples/PureBasic/pythagorean-triples.purebasic @@ -0,0 +1,67 @@ +Procedure.i ConsoleWrite(t.s) ; compile using /CONSOLE option + OpenConsole() + PrintN (t.s) + CloseConsole() + ProcedureReturn 1 +EndProcedure + +Procedure.i StdOut(t.s) ; compile using /CONSOLE option + OpenConsole() + Print(t.s) + CloseConsole() + ProcedureReturn 1 +EndProcedure + +Procedure.i gcDiv(n,m) ; greatest common divisor +if n=0:ProcedureReturn m:endif +while m <> 0 + if n > m + n - m + else + m - n + endif +wend +ProcedureReturn n +EndProcedure + +st=ElapsedMilliseconds() + +nmax =10000 +power =8 + +dim primitiveA(power) +dim alltripleA(power) +dim pmaxA(power) + +x=1 +for i=1 to power + x*10:pmaxA(i)=x/2 +next + +for n=1 to nmax + for m=(n+1) to (nmax+1) step 2 ; assure m-n is odd + d=gcDiv(n,m) + p=m*m+m*n + for i=1 to power + if p<=pmaxA(i) + if d =1 + primitiveA(i)+1 ; right here we have the primitive perimeter "seed" 'p' + k=1:q=p*k ; set k to one to include p : use q as the 'p*k' + while q<=pmaxA(i) + alltripleA(i)+1 ; accumulate multiples of this perimeter while q <= pmaxA(i) + k+1:q=p*k + wend + endif + endif + next + next +next + +for i=1 to power + t.s="Up to "+str(pmaxA(i)*2)+": " + t.s+str(alltripleA(i))+" triples, " + t.s+str(primitiveA(i))+" primitives." + ConsoleWrite(t.s) +next +ConsoleWrite("") +et=ElapsedMilliseconds()-st:ConsoleWrite("Elapsed time = "+str(et)+" milliseconds") diff --git a/Task/Pythagorean-triples/Python/pythagorean-triples-1.py b/Task/Pythagorean-triples/Python/pythagorean-triples-1.py new file mode 100644 index 0000000000..2427cb4a0e --- /dev/null +++ b/Task/Pythagorean-triples/Python/pythagorean-triples-1.py @@ -0,0 +1,56 @@ +from fractions import gcd + + +def pt1(maxperimeter=100): + ''' +# Naive method + ''' + trips = [] + for a in range(1, maxperimeter): + aa = a*a + for b in range(a, maxperimeter-a+1): + bb = b*b + for c in range(b, maxperimeter-b-a+1): + cc = c*c + if a+b+c > maxperimeter or cc > aa + bb: break + if aa + bb == cc: + trips.append((a,b,c, gcd(a, b) == 1)) + return trips + +def pytrip(trip=(3,4,5),perim=100, prim=1): + a0, b0, c0 = a, b, c = sorted(trip) + t, firstprim = set(), prim>0 + while a + b + c <= perim: + t.add((a, b, c, firstprim>0)) + a, b, c, firstprim = a+a0, b+b0, c+c0, False + # + t2 = set() + for a, b, c, firstprim in t: + a2, a5, b2, b5, c2, c3, c7 = a*2, a*5, b*2, b*5, c*2, c*3, c*7 + if a5 - b5 + c7 <= perim: + t2 |= pytrip(( a - b2 + c2, a2 - b + c2, a2 - b2 + c3), perim, firstprim) + if a5 + b5 + c7 <= perim: + t2 |= pytrip(( a + b2 + c2, a2 + b + c2, a2 + b2 + c3), perim, firstprim) + if -a5 + b5 + c7 <= perim: + t2 |= pytrip((-a + b2 + c2, -a2 + b + c2, -a2 + b2 + c3), perim, firstprim) + return t | t2 + +def pt2(maxperimeter=100): + ''' +# Parent/child relationship method: +# http://en.wikipedia.org/wiki/Formulas_for_generating_Pythagorean_triples#XI. + ''' + trips = pytrip((3,4,5), maxperimeter, 1) + return trips + +def printit(maxperimeter=100, pt=pt1): + trips = pt(maxperimeter) + print(" Up to a perimeter of %i there are %i triples, of which %i are primitive" + % (maxperimeter, + len(trips), + len([prim for a,b,c,prim in trips if prim]))) + +for algo, mn, mx in ((pt1, 250, 2500), (pt2, 500, 20000)): + print(algo.__doc__) + for maxperimeter in range(mn, mx+1, mn): + printit(maxperimeter, algo) diff --git a/Task/Pythagorean-triples/Python/pythagorean-triples-2.py b/Task/Pythagorean-triples/Python/pythagorean-triples-2.py new file mode 100644 index 0000000000..8a0a6f222e --- /dev/null +++ b/Task/Pythagorean-triples/Python/pythagorean-triples-2.py @@ -0,0 +1,14 @@ +from sys import setrecursionlimit +setrecursionlimit(2000) # 2000 ought to be big enough for everybody + +def triples(lim, a = 3, b = 4, c = 5): + l = a + b + c + if l > lim: return (0, 0) + return reduce(lambda x, y: (x[0] + y[0], x[1] + y[1]), [ + (1, lim / l), + triples(lim, a - 2*b + 2*c, 2*a - b + 2*c, 2*a - 2*b + 3*c), + triples(lim, a + 2*b + 2*c, 2*a + b + 2*c, 2*a + 2*b + 3*c), + triples(lim, -a + 2*b + 2*c, -2*a + b + 2*c, -2*a + 2*b + 3*c) ]) + +for peri in [10 ** e for e in range(1, 8)]: + print peri, triples(peri) diff --git a/Task/Pythagorean-triples/Python/pythagorean-triples-3.py b/Task/Pythagorean-triples/Python/pythagorean-triples-3.py new file mode 100644 index 0000000000..1ade33b30e --- /dev/null +++ b/Task/Pythagorean-triples/Python/pythagorean-triples-3.py @@ -0,0 +1,7 @@ +10 (0, 0) +100 (7, 17) +1000 (70, 325) +10000 (703, 4858) +100000 (7026, 64741) +1000000 (70229, 808950) +10000000 (702309, 9706567) diff --git a/Task/Pythagorean-triples/REXX/pythagorean-triples-1.rexx b/Task/Pythagorean-triples/REXX/pythagorean-triples-1.rexx new file mode 100644 index 0000000000..72c4cb2afa --- /dev/null +++ b/Task/Pythagorean-triples/REXX/pythagorean-triples-1.rexx @@ -0,0 +1,28 @@ +/*REXX pgm counts number of Pythagorean triples that exist given a max */ +/* perimeter of N, and also counts how many of them are primitives.*/ +trips=0; prims=0 +parse arg N .; if N=='' then n=100 /*get "N". If none, then assume.*/ + + do a=3 to N%3; aa=a*a /*limit side to 1/3 of perimeter.*/ + + do b=a+1 /*triangle can't be isosceles. */ + ab=a+b /*compute partial perimeter. */ + if ab>=n then iterate a /*a+b>perimeter? Try different A*/ + aabb=aa+b*b /*compute sum of a² + b² (cheat)*/ + + do c=b+1; cc=c*c /*3rd side: also compute c² */ + if ab+c>n then iterate a /*a+b+c > perimeter? Try diff A.*/ + if cc>aabb then iterate b /*c² > a²+b² ? Try different B.*/ + if cc\==aabb then iterate /*c² ¬= a²+b² ? Try different C.*/ + trips=trips+1 /*eureka. */ + prims=prims+(gcd(a,b)==1) /*is this triple a primative ? */ + end /*a*/ + end /*b*/ + end /*c*/ + +say 'max perimeter = 'N, /*show a single line of output. */ + left('',7) "Pythagorean triples =" trips, /*left('',0) ≡ 7 blanks.*/ + left('',7) 'primitives =' prims +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────GCD subroutine──────────────────────*/ +gcd: procedure; arg x,y; do until _==0; _=x//y; x=y; y=_; end; return x diff --git a/Task/Pythagorean-triples/REXX/pythagorean-triples-2.rexx b/Task/Pythagorean-triples/REXX/pythagorean-triples-2.rexx new file mode 100644 index 0000000000..1ed4d94266 --- /dev/null +++ b/Task/Pythagorean-triples/REXX/pythagorean-triples-2.rexx @@ -0,0 +1,35 @@ +/*REXX pgm counts number of Pythagorean triples that exist given a max */ +/* perimeter of N, and also counts how many of them are primatives.*/ +@.=0; trips=0; prims=0 +parse arg N .; if N=='' then n=100 /*get "N". If none, then assume.*/ + + do a=3 to N%3; aa=a*a /*limit side to 1/3 of perimeter.*/ + aEven=a//2==0 + + do b=a+1 by 1+aEven /*triangle can't be isosceles. */ + ab=a+b /*compute partial perimeter. */ + if ab>=n then iterate a /*a+b>perimeter? Try different A*/ + aabb=aa+b*b /*compute sum of a² + b² (cheat)*/ + + do c=b+1; cc=c*c /*3rd side: also compute c² */ + if aEven then if c//2==0 then iterate + if ab+c>n then iterate a /*a+b+c > perimeter? Try diff A.*/ + if cc>aabb then iterate b /*c² > a²+b² ? Try different B.*/ + if cc\==aabb then iterate /*c² ¬= a²+b² ? Try different C.*/ + if @.a.b.c then iterate + trips=trips+1 /*eureka. */ + prims=prims+1 /*count this primitive triple. */ + + do m=2; !a=a*m; !b=b*m; !c=c*m /*gen non-primitives.*/ + if !a+!b+!c>N then leave /*is this multiple a triple ? */ + trips=trips+1 /*yuppers, then we found another.*/ + if m//2 then @.!a.!b.!c=1 /*don't mark if an even multiple.*/ + end /*m*/ + end /*d*/ + end /*b*/ + end /*a*/ + +say 'max perimeter = 'N, /*show a single line of output. */ + left('',7) "Pythagorean triples =" trips, /*left('',0) = 7 blanks.*/ + left('',7) 'primitives =' prims + /*stick a fork in it, we're done.*/ diff --git a/Task/Pythagorean-triples/Ruby/pythagorean-triples.rb b/Task/Pythagorean-triples/Ruby/pythagorean-triples.rb new file mode 100644 index 0000000000..093ebdde7f --- /dev/null +++ b/Task/Pythagorean-triples/Ruby/pythagorean-triples.rb @@ -0,0 +1,29 @@ +class PythagoranTriplesCounter + def initialize(limit) + @limit = limit + @total = 0 + @primatives = 0 + generate_triples(3, 4, 5) + end + attr_reader :total, :primatives + + private + def generate_triples(a, b, c) + perim = a + b + c + return if perim > @limit + + @primatives += 1 + @total += @limit / perim + + generate_triples( a-2*b+2*c, 2*a-b+2*c, 2*a-2*b+3*c) + generate_triples( a+2*b+2*c, 2*a+b+2*c, 2*a+2*b+3*c) + generate_triples(-a+2*b+2*c,-2*a+b+2*c,-2*a+2*b+3*c) + end +end + +perim = 10 +while perim <= 100_000_000 + c = PythagoranTriplesCounter.new perim + p [perim, c.total, c.primatives] + perim *= 10 +end diff --git a/Task/Pythagorean-triples/Seed7/pythagorean-triples.seed7 b/Task/Pythagorean-triples/Seed7/pythagorean-triples.seed7 new file mode 100644 index 0000000000..3f8d5a5562 --- /dev/null +++ b/Task/Pythagorean-triples/Seed7/pythagorean-triples.seed7 @@ -0,0 +1,31 @@ +$ include "seed7_05.s7i"; + include "bigint.s7i"; + +var bigInteger: total is 0_; +var bigInteger: prim is 0_; +var bigInteger: max_peri is 10_; + +const proc: new_tri (in bigInteger: a, in bigInteger: b, in bigInteger: c) is func + local + var bigInteger: p is 0_; + begin + p := a + b + c; + if p <= max_peri then + incr(prim); + total +:= max_peri div p; + new_tri( a - 2_*b + 2_*c, 2_*a - b + 2_*c, 2_*a - 2_*b + 3_*c); + new_tri( a + 2_*b + 2_*c, 2_*a + b + 2_*c, 2_*a + 2_*b + 3_*c); + new_tri(-a + 2_*b + 2_*c, -2_*a + b + 2_*c, -2_*a + 2_*b + 3_*c); + end if; + end func; + +const proc: main is func + begin + while max_peri <= 100000000_ do + total := 0_; + prim := 0_; + new_tri(3_, 4_, 5_); + writeln("Up to " <& max_peri <& ": " <& total <& " triples, " <& prim <& " primitives."); + max_peri *:= 10_; + end while; + end func; diff --git a/Task/Pythagorean-triples/Tcl/pythagorean-triples.tcl b/Task/Pythagorean-triples/Tcl/pythagorean-triples.tcl new file mode 100644 index 0000000000..83bc140337 --- /dev/null +++ b/Task/Pythagorean-triples/Tcl/pythagorean-triples.tcl @@ -0,0 +1,25 @@ +proc countPythagoreanTriples {limit} { + lappend q 3 4 5 + set idx [set count [set prim 0]] + while {$idx < [llength $q]} { + set a [lindex $q $idx] + set b [lindex $q [incr idx]] + set c [lindex $q [incr idx]] + incr idx + if {$a + $b + $c <= $limit} { + incr prim + for {set i 1} {$i*$a+$i*$b+$i*$c <= $limit} {incr i} { + incr count + } + lappend q \ + [expr {$a + 2*($c-$b)}] [expr {2*($a+$c) - $b}] [expr {2*($a-$b) + 3*$c}] \ + [expr {$a + 2*($b+$c)}] [expr {2*($a+$c) + $b}] [expr {2*($a+$b) + 3*$c}] \ + [expr {2*($b+$c) - $a}] [expr {2*($c-$a) + $b}] [expr {2*($b-$a) + 3*$c}] + } + } + return [list $count $prim] +} +for {set i 10} {$i <= 10000000} {set i [expr {$i*10}]} { + lassign [countPythagoreanTriples $i] count primitive + puts "perimeter limit $i => $count triples, $primitive primitive" +} diff --git a/Task/QR-decomposition/0DESCRIPTION b/Task/QR-decomposition/0DESCRIPTION new file mode 100644 index 0000000000..3c8c23f246 --- /dev/null +++ b/Task/QR-decomposition/0DESCRIPTION @@ -0,0 +1,95 @@ +Any rectangular m \times n matrix \mathit A can be decomposed to a product of a orthogonal matrix \mathit Q and a upper (right) triangular matrix \mathit R, as described in [[wp:QR decomposition|QR decomposition]]. + +'''Task''' + +Demonstrate the QR decomposition on the example matrix from the [[wp:QR_decomposition#Example_2|Wikipedia article]]: + +::A = \begin{pmatrix} +12 & -51 & 4 \\ +6 & 167 & -68 \\ +-4 & 24 & -41 \end{pmatrix} + +and the usage for linear least squares problems on the example from [[Polynomial_regression]]. The method of [[wp: Householder transformation|Householder reflections]] should be used: + +'''Method''' + +Multiplying a given vector \mathit a, for example the first column of matrix \mathit A, with the Householder matrix \mathit H, which is given as + +::H = I - \frac {2} {u^T u} u u^T + +reflects \mathit a about a plane given by its normal vector \mathit u. When the normal vector of the plane \mathit u is given as + +::u = a - \|a\|_2 \; e_1 + +then the transformation reflects \mathit a onto the first standard basis vector + +::e_1 = [1 \; 0 \; 0 \; ...]^T + +which means that all entries but the first become zero. To avoid numerical cancellation errors, we should take the opposite sign of a_1: + +::u = a + \textrm{sign}(a_1)\|a\|_2 \; e_1 + +and normalize with respect to the first element: + +::v = \frac{u}{u_1} + +The equation for H thus becomes: + +::H = I - \frac {2} {v^T v} v v^T + +or, in another form + +::H = I - \beta v v^T + +with +::\beta = \frac {2} {v^T v} + +Applying \mathit H on \mathit a then gives + +::H \; a = -\textrm{sign}(a_1) \; \|a\|_2 \; e_1 + +and applying \mathit H on the matrix \mathit A zeroes all subdiagonal elements of the first column: + +::H_1 \; A = \begin{pmatrix} +r_{11} & r_{12} & r_{13} \\ +0 & * & * \\ +0 & * & * \end{pmatrix} + +In the second step, the second column of \mathit A, we want to zero all elements but the first two, which means that we have to calculate \mathit H with the first column of the ''submatrix'' (denoted *), not on the whole second column of \mathit A. + +To get H_2, we then embed the new \mathit H into an m \times n identity: + +::H_2 = \begin{pmatrix} +1 & 0 & 0 \\ +0 & H & \\ +0 & & \end{pmatrix} + +This is how we can, column by column, remove all subdiagonal elements of \mathit A and thus transform it into \mathit R. + +::H_n \; ... \; H_3 H_2 H_1 A = R + +The product of all the Householder matrices \mathit H, for every column, in reverse order, will then yield the orthogonal matrix \mathit Q. + +::H_1 H_2 H_3 \; ... \; H_n = Q + +The QR decomposition should then be used to solve linear least squares ([[Multiple regression]]) problems \mathit A x = b by solving + +::R \; x = Q^T \; b + +When \mathit R is not square, i.e. m > n we have to cut off the \mathit m - n zero padded bottom rows. + +::R = +\begin{pmatrix} +R_1 \\ +0 \end{pmatrix} + +and the same for the RHS: + +::Q^T \; b = +\begin{pmatrix} +q_1 \\ +q_2 \end{pmatrix} + +Finally, solve the square upper triangular system by back substitution: + +::R_1 \; x = q_1 diff --git a/Task/QR-decomposition/1META.yaml b/Task/QR-decomposition/1META.yaml new file mode 100644 index 0000000000..09f25b3b78 --- /dev/null +++ b/Task/QR-decomposition/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Mathematics +note: Matrices diff --git a/Task/QR-decomposition/Ada/qr-decomposition.ada b/Task/QR-decomposition/Ada/qr-decomposition.ada new file mode 100644 index 0000000000..a99ea7c103 --- /dev/null +++ b/Task/QR-decomposition/Ada/qr-decomposition.ada @@ -0,0 +1,94 @@ +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Numerics.Real_Arrays; use Ada.Numerics.Real_Arrays; +with Ada.Numerics.Generic_Elementary_Functions; +procedure QR is + + procedure Show (mat : Real_Matrix) is + package FIO is new Ada.Text_IO.Float_IO (Float); + begin + for row in mat'Range (1) loop + for col in mat'Range (2) loop + FIO.Put (mat (row, col), Exp => 0, Aft => 4, Fore => 5); + end loop; New_Line; + end loop; + end Show; + + function GetCol (mat : Real_Matrix; n : Integer) return Real_Matrix is + column : Real_Matrix (mat'Range (1), 1 .. 1); + begin + for row in mat'Range (1) loop + column (row, 1) := mat (row, n); + end loop; + return column; + end GetCol; + + function Mag (mat : Real_Matrix) return Float is + sum : Real_Matrix := Transpose (mat) * mat; + package Math is new Ada.Numerics.Generic_Elementary_Functions + (Float); + begin + return Math.Sqrt (sum (1, 1)); + end Mag; + + function eVect (col : Real_Matrix; n : Integer) return Real_Matrix is + vect : Real_Matrix (col'Range (1), 1 .. 1); + begin + for row in col'Range (1) loop + if row /= n then vect (row, 1) := 0.0; + else vect (row, 1) := 1.0; end if; + end loop; + return vect; + end eVect; + + function Identity (n : Integer) return Real_Matrix is + mat : Real_Matrix (1 .. n, 1 .. n) := (1 .. n => (others => 0.0)); + begin + for i in Integer range 1 .. n loop mat (i, i) := 1.0; end loop; + return mat; + end Identity; + + function Chop (mat : Real_Matrix; n : Integer) return Real_Matrix is + small : Real_Matrix (n .. mat'Length (1), n .. mat'Length (2)); + begin + for row in small'Range (1) loop + for col in small'Range (2) loop + small (row, col) := mat (row, col); + end loop; + end loop; + return small; + end Chop; + + function H_n (inmat : Real_Matrix; n : Integer) + return Real_Matrix is + mat : Real_Matrix := Chop (inmat, n); + col : Real_Matrix := GetCol (mat, n); + colT : Real_Matrix (1 .. 1, mat'Range (1)); + H : Real_Matrix := Identity (mat'Length (1)); + Hall : Real_Matrix := Identity (inmat'Length (1)); + begin + col := col - Mag (col) * eVect (col, n); + col := col / Mag (col); + colT := Transpose (col); + H := H - 2.0 * (col * colT); + for row in H'Range (1) loop + for col in H'Range (2) loop + Hall (n - 1 + row, n - 1 + col) := H (row, col); + end loop; + end loop; + return Hall; + end H_n; + + A : constant Real_Matrix (1 .. 3, 1 .. 3) := ( + (12.0, -51.0, 4.0), + (6.0, 167.0, -68.0), + (-4.0, 24.0, -41.0)); + Q1, Q2, Q3, Q, R: Real_Matrix (1 .. 3, 1 .. 3); +begin + Q1 := H_n (A, 1); + Q2 := H_n (Q1 * A, 2); + Q3 := H_n (Q2 * Q1* A, 3); + Q := Transpose (Q1) * Transpose (Q2) * TransPose(Q3); + R := Q3 * Q2 * Q1 * A; + Put_Line ("Q:"); Show (Q); + Put_Line ("R:"); Show (R); +end QR; diff --git a/Task/QR-decomposition/Axiom/qr-decomposition-1.axiom b/Task/QR-decomposition/Axiom/qr-decomposition-1.axiom new file mode 100644 index 0000000000..c834c322c3 --- /dev/null +++ b/Task/QR-decomposition/Axiom/qr-decomposition-1.axiom @@ -0,0 +1,55 @@ +)abbrev package TESTP TestPackage +TestPackage(R:Join(Field,RadicalCategory)): with + unitVector: NonNegativeInteger -> Vector(R) + "/": (Vector(R),R) -> Vector(R) + "^": (Vector(R),NonNegativeInteger) -> Vector(R) + solveUpperTriangular: (Matrix(R),Vector(R)) -> Vector(R) + signValue: R -> R + householder: Vector(R) -> Matrix(R) + qr: Matrix(R) -> Record(q:Matrix(R),r:Matrix(R)) + lsqr: (Matrix(R),Vector(R)) -> Vector(R) + polyfit: (Vector(R),Vector(R),NonNegativeInteger) -> Vector(R) + == add + unitVector(dim) == + out := new(dim,0@R)$Vector(R) + out(1) := 1@R + out + v:Vector(R) / a:R == map((vi:R):R +-> vi/a, v)$Vector(R) + v:Vector(R) ^ n:NonNegativeInteger == map((vi:R):R +-> vi^n, v)$Vector(R) + solveUpperTriangular(r,b) == + n := ncols r + x := new(n,0@R)$Vector(R) + for k in n..1 by -1 repeat + index := min(n,k+1) + x(k) := (b(k)-reduce("+",subMatrix(r,k,k,index,n)*x.(index..n)))/r(k,k) + x + signValue(r) == + R has (sign: R -> Integer) => coerce(sign(r)$R)$R + zero? r => r + if sqrt(r*r) = r then 1 else -1 + householder(a) == + m := #a + u := a + length(a)*signValue(a(1))*unitVector(m) + v := u/u(1) + beta := (1+1)/dot(v,v) + scalarMatrix(m,1) - beta*transpose(outerProduct(v,v)) + qr(a) == + (m,n) := (nrows a, ncols a) + qm := scalarMatrix(m,1) + rm := copy a + for i in 1..(if m=n then n-1 else n) repeat + x := column(subMatrix(rm,i,m,i,i),1) + h := scalarMatrix(m,1) + setsubMatrix!(h,i,i,householder x) + qm := qm*h + rm := h*rm + [qm,rm] + lsqr(a,b) == + dc := qr a + n := ncols(dc.r) + solveUpperTriangular(subMatrix(dc.r,1,n,1,n),transpose(dc.q)*b) + polyfit(x,y,n) == + a := new(#x,n+1,0@R)$Matrix(R) + for j in 0..n repeat + setColumn!(a,j+1,x^j) + lsqr(a,y) diff --git a/Task/QR-decomposition/Axiom/qr-decomposition-2.axiom b/Task/QR-decomposition/Axiom/qr-decomposition-2.axiom new file mode 100644 index 0000000000..3350253461 --- /dev/null +++ b/Task/QR-decomposition/Axiom/qr-decomposition-2.axiom @@ -0,0 +1,5 @@ +m := matrix [[12, -51, 4], [6, 167, -68], [-4, 24, -41]]; +qr m +x := vector [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; +y := vector [1, 6, 17, 34, 57, 86, 121, 162, 209, 262, 321]; +polyfit(x, y, 2) diff --git a/Task/QR-decomposition/Axiom/qr-decomposition-3.axiom b/Task/QR-decomposition/Axiom/qr-decomposition-3.axiom new file mode 100644 index 0000000000..1cd3b7e098 --- /dev/null +++ b/Task/QR-decomposition/Axiom/qr-decomposition-3.axiom @@ -0,0 +1,20 @@ +qr m + + + 6 69 58 + + |- - --- --- | + | 7 175 175 | + | | +- 14 - 21 14 + + | 3 158 6 | | | + [q= |- - - --- - ---|,r= | 0 - 175 70 |] + | 7 175 175| | | + | | + 0 0 - 35+ + | 2 6 33 | + | - - -- -- | + + 7 35 35 + + + Type: Record(q: Matrix(AlgebraicNumber),r: Matrix(AlgebraicNumber)) + +polyfit(x, y, 2) + + [1,2,3] + Type: Vector(AlgebraicNumber) diff --git a/Task/QR-decomposition/BBC-BASIC/qr-decomposition.bbc b/Task/QR-decomposition/BBC-BASIC/qr-decomposition.bbc new file mode 100644 index 0000000000..84c55dc097 --- /dev/null +++ b/Task/QR-decomposition/BBC-BASIC/qr-decomposition.bbc @@ -0,0 +1,97 @@ + *FLOAT 64 + @% = &2040A + INSTALL @lib$+"ARRAYLIB" + + REM Test matrix for QR decomposition: + DIM A(2,2) + A() = 12, -51, 4, \ + \ 6, 167, -68, \ + \ -4, 24, -41 + + REM Do the QR decomposition: + DIM Q(2,2), R(2,2) + PROCqrdecompose(A(), Q(), R()) + PRINT "Q:" + PRINT Q(0,0), Q(0,1), Q(0,2) + PRINT Q(1,0), Q(1,1), Q(1,2) + PRINT Q(2,0), Q(2,1), Q(2,2) + PRINT "R:" + PRINT R(0,0), R(0,1), R(0,2) + PRINT R(1,0), R(1,1), R(1,2) + PRINT R(2,0), R(2,1), R(2,2) + + REM Test data for least-squares solution: + DIM x(10) : x() = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 + DIM y(10) : y() = 1, 6, 17, 34, 57, 86, 121, 162, 209, 262, 321 + + REM Do the least-squares solution: + DIM a(10,2), q(10,10), r(10,2), t(10,10), b(10), z(2) + FOR i% = 0 TO 10 + FOR j% = 0 TO 2 + a(i%,j%) = x(i%) ^ j% + NEXT + NEXT + PROCqrdecompose(a(), q(), r()) + PROC_transpose(q(),t()) + b() = t() . y() + FOR k% = 2 TO 0 STEP -1 + s = 0 + IF k% < 2 THEN + FOR j% = k%+1 TO 2 + s += r(k%,j%) * z(j%) + NEXT + ENDIF + z(k%) = (b(k%) - s) / r(k%,k%) + NEXT k% + PRINT '"Least-squares solution:" + PRINT z(0), z(1), z(2) + END + + DEF PROCqrdecompose(A(), Q(), R()) + LOCAL i%, k%, m%, n%, H() + m% = DIM(A(),1) : n% = DIM(A(),2) + DIM H(m%,m%) + FOR i% = 0 TO m% : Q(i%,i%) = 1 : NEXT + WHILE n% + PROCqrstep(n%, k%, A(), H()) + A() = H() . A() + Q() = Q() . H() + k% += 1 + m% -= 1 + n% -= 1 + ENDWHILE + R() = A() + ENDPROC + + DEF PROCqrstep(n%, k%, A(), H()) + LOCAL a(), h(), i%, j% + DIM a(n%,0), h(n%,n%) + FOR i% = 0 TO n% : a(i%,0) = A(i%+k%,k%) : NEXT + PROChouseholder(h(), a()) + H() = 0 : H(0,0) = 1 + FOR i% = 0 TO n% + FOR j% = 0 TO n% + H(i%+k%,j%+k%) = h(i%,j%) + NEXT + NEXT + ENDPROC + + REM Create the Householder matrix for the supplied column vector: + DEF PROChouseholder(H(), a()) + LOCAL e(), u(), v(), vt(), vvt(), I(), d() + LOCAL i%, n% : n% = DIM(a(),1) + REM Create the scaled standard basis vector e(): + DIM e(n%,0) : e(0,0) = SGN(a(0,0)) * MOD(a()) + REM Create the normal vector u(): + DIM u(n%,0) : u() = a() + e() + REM Normalise with respect to the first element: + DIM v(n%,0) : v() = u() / u(0,0) + REM Get the transpose of v() and its dot product with v(): + DIM vt(0,n%), d(0) : PROC_transpose(v(), vt()) : d() = vt() . v() + REM Get the product of v() and vt(): + DIM vvt(n%,n%) : vvt() = v() . vt() + REM Create an identity matrix I(): + DIM I(n%,n%) : FOR i% = 0 TO n% : I(i%,i%) = 1 : NEXT + REM Create the Householder matrix H() = I - 2/vt()v() v()vt(): + vvt() *= 2 / d(0) : H() = I() - vvt() + ENDPROC diff --git a/Task/QR-decomposition/C/qr-decomposition.c b/Task/QR-decomposition/C/qr-decomposition.c new file mode 100644 index 0000000000..9c212a315f --- /dev/null +++ b/Task/QR-decomposition/C/qr-decomposition.c @@ -0,0 +1,192 @@ +#include +#include +#include + +typedef struct { + int m, n; + double ** v; +} mat_t, *mat; + +mat matrix_new(int m, int n) +{ + mat x = malloc(sizeof(mat_t)); + x->v = malloc(sizeof(double) * m); + x->v[0] = calloc(sizeof(double), m * n); + for (int i = 0; i < m; i++) + x->v[i] = x->v[0] + n * i; + x->m = m; + x->n = n; + return x; +} + +void matrix_delete(mat m) +{ + free(m->v[0]); + free(m->v); + free(m); +} + +void matrix_transpose(mat m) +{ + for (int i = 0; i < m->m; i++) { + for (int j = 0; j < i; j++) { + double t = m->v[i][j]; + m->v[i][j] = m->v[j][i]; + m->v[j][i] = t; + } + } +} + +mat matrix_copy(int n;double a[][n], int m, int n) +{ + mat x = matrix_new(m, n); + for (int i = 0; i < m; i++) + for (int j = 0; j < n; j++) + x->v[i][j] = a[i][j]; + return x; +} + +mat matrix_mul(mat x, mat y) +{ + if (x->n != y->m) return 0; + mat r = matrix_new(x->m, y->n); + for (int i = 0; i < x->m; i++) + for (int j = 0; j < y->n; j++) + for (int k = 0; k < x->n; k++) + r->v[i][j] += x->v[i][k] * y->v[k][j]; + return r; +} + +mat matrix_minor(mat x, int d) +{ + mat m = matrix_new(x->m, x->n); + for (int i = 0; i < d; i++) + m->v[i][i] = 1; + for (int i = d; i < x->m; i++) + for (int j = d; j < x->n; j++) + m->v[i][j] = x->v[i][j]; + return m; +} + +/* c = a + b * s */ +double *vmadd(double a[], double b[], double s, double c[], int n) +{ + for (int i = 0; i < n; i++) + c[i] = a[i] + s * b[i]; + return c; +} + +/* m = I - v v^T */ +mat vmul(double v[], int n) +{ + mat x = matrix_new(n, n); + for (int i = 0; i < n; i++) + for (int j = 0; j < n; j++) + x->v[i][j] = -2 * v[i] * v[j]; + for (int i = 0; i < n; i++) + x->v[i][i] += 1; + + return x; +} + +/* ||x|| */ +double vnorm(double x[], int n) +{ + double sum = 0; + for (int i = 0; i < n; i++) sum += x[i] * x[i]; + return sqrt(sum); +} + +/* y = x / d */ +double* vdiv(double x[], double d, double y[], int n) +{ + for (int i = 0; i < n; i++) y[i] = x[i] / d; + return y; +} + +/* take c-th column of m, put in v */ +double* mcol(mat m, double *v, int c) +{ + for (int i = 0; i < m->m; i++) + v[i] = m->v[i][c]; + return v; +} + +void matrix_show(mat m) +{ + for(int i = 0; i < m->m; i++) { + for (int j = 0; j < m->n; j++) { + printf(" %8.3f", m->v[i][j]); + } + printf("\n"); + } + printf("\n"); +} + +void householder(mat m, mat *R, mat *Q) +{ + mat q[m->m]; + mat z = m, z1; + for (int k = 0; k < m->n && k < m->m - 1; k++) { + double e[m->m], x[m->m], a; + z1 = matrix_minor(z, k); + if (z != m) matrix_delete(z); + z = z1; + + mcol(z, x, k); + a = vnorm(x, m->m); + if (m->v[k][k] > 0) a = -a; + + for (int i = 0; i < m->m; i++) + e[i] = (i == k) ? 1 : 0; + + vmadd(x, e, a, e, m->m); + vdiv(e, vnorm(e, m->m), e, m->m); + q[k] = vmul(e, m->m); + z1 = matrix_mul(q[k], z); + if (z != m) matrix_delete(z); + z = z1; + } + matrix_delete(z); + *Q = q[0]; + *R = matrix_mul(q[0], m); + for (int i = 1; i < m->n && i < m->m - 1; i++) { + z1 = matrix_mul(q[i], *Q); + if (i > 1) matrix_delete(*Q); + *Q = z1; + matrix_delete(q[i]); + } + matrix_delete(q[0]); + z = matrix_mul(*Q, m); + matrix_delete(*R); + *R = z; + matrix_transpose(*Q); +} + +double in[][3] = { + { 12, -51, 4}, + { 6, 167, -68}, + { -4, 24, -41}, + { -1, 1, 0}, + { 2, 0, 3}, +}; + +int main() +{ + mat R, Q; + mat x = matrix_copy(in, 5, 3); + householder(x, &R, &Q); + + puts("Q"); matrix_show(Q); + puts("R"); matrix_show(R); + + // to show their product is the input matrix + mat m = matrix_mul(Q, R); + puts("Q * R"); matrix_show(m); + + matrix_delete(x); + matrix_delete(R); + matrix_delete(Q); + matrix_delete(m); + return 0; +} diff --git a/Task/QR-decomposition/Common-Lisp/qr-decomposition-1.lisp b/Task/QR-decomposition/Common-Lisp/qr-decomposition-1.lisp new file mode 100644 index 0000000000..cccd51b5d0 --- /dev/null +++ b/Task/QR-decomposition/Common-Lisp/qr-decomposition-1.lisp @@ -0,0 +1,54 @@ +(defun sign (x) + (if (zerop x) + x + (/ x (abs x)))) + +(defun norm (x) + (let ((len (car (array-dimensions x)))) + (sqrt (loop for i from 0 to (1- len) sum (expt (aref x i 0) 2))))) + +(defun make-unit-vector (dim) + (let ((vec (make-array `(,dim ,1) :initial-element 0.0d0))) + (setf (aref vec 0 0) 1.0d0) + vec)) + +;; Return a nxn identity matrix. +(defun eye (n) + (let ((I (make-array `(,n ,n) :initial-element 0))) + (loop for j from 0 to (- n 1) do + (setf (aref I j j) 1)) + I)) + +(defun array-range (A ma mb na nb) + (let* ((mm (1+ (- mb ma))) + (nn (1+ (- nb na))) + (B (make-array `(,mm ,nn) :initial-element 0.0d0))) + + (loop for i from 0 to (1- mm) do + (loop for j from 0 to (1- nn) do + (setf (aref B i j) + (aref A (+ ma i) (+ na j))))) + B)) + +(defun rows (A) (car (array-dimensions A))) +(defun cols (A) (cadr (array-dimensions A))) +(defun mcol (A n) (array-range A 0 (1- (rows A)) n n)) +(defun mrow (A n) (array-range A n n 0 (1- (cols A)))) + +(defun array-embed (A B row col) + (let* ((ma (rows A)) + (na (cols A)) + (mb (rows B)) + (nb (cols B)) + (C (make-array `(,ma ,na) :initial-element 0.0d0))) + + (loop for i from 0 to (1- ma) do + (loop for j from 0 to (1- na) do + (setf (aref C i j) (aref A i j)))) + + (loop for i from 0 to (1- mb) do + (loop for j from 0 to (1- nb) do + (setf (aref C (+ row i) (+ col j)) + (aref B i j)))) + + C)) diff --git a/Task/QR-decomposition/Common-Lisp/qr-decomposition-2.lisp b/Task/QR-decomposition/Common-Lisp/qr-decomposition-2.lisp new file mode 100644 index 0000000000..916e78314d --- /dev/null +++ b/Task/QR-decomposition/Common-Lisp/qr-decomposition-2.lisp @@ -0,0 +1,34 @@ +(defun make-householder (a) + (let* ((m (car (array-dimensions a))) + (s (sign (aref a 0 0))) + (e (make-unit-vector m)) + (u (m+ a (.* (* (norm a) s) e))) + (v (./ u (aref u 0 0))) + (beta (/ 2 (aref (mmul (mtp v) v) 0 0)))) + + (m- (eye m) + (.* beta (mmul v (mtp v)))))) + +(defun qr (A) + (let* ((m (car (array-dimensions A))) + (n (cadr (array-dimensions A))) + (Q (eye m))) + + ;; Work on n columns of A. + (loop for i from 0 to (if (= m n) (- n 2) (- n 1)) do + + ;; Select the i-th submatrix. For i=0 this means the original matrix A. + (let* ((B (array-range A i (1- m) i (1- n))) + ;; Take the first column of the current submatrix B. + (x (mcol B 0)) + ;; Create the Householder matrix for the column and embed it into an mxm identity. + (H (array-embed (eye m) (make-householder x) i i))) + + ;; The product of all H matrices from the right hand side is the orthogonal matrix Q. + (setf Q (mmul Q H)) + + ;; The product of all H matrices with A from the LHS is the upper triangular matrix R. + (setf A (mmul H A)))) + + ;; Return Q and R. + (values Q A))) diff --git a/Task/QR-decomposition/Common-Lisp/qr-decomposition-3.lisp b/Task/QR-decomposition/Common-Lisp/qr-decomposition-3.lisp new file mode 100644 index 0000000000..8afbf443ec --- /dev/null +++ b/Task/QR-decomposition/Common-Lisp/qr-decomposition-3.lisp @@ -0,0 +1,9 @@ +(qr #2A((12 -51 4) (6 167 -68) (-4 24 -41))) + +#2A((-0.85 0.39 0.33) + (-0.42 -0.90 -0.03) + ( 0.28 -0.17 0.94)) + +#2A((-14.0 -21.0 14.0) + ( 0.0 -175.0 70.0) + ( 0.0 0.0 -35.0)) diff --git a/Task/QR-decomposition/Common-Lisp/qr-decomposition-4.lisp b/Task/QR-decomposition/Common-Lisp/qr-decomposition-4.lisp new file mode 100644 index 0000000000..6112fa2406 --- /dev/null +++ b/Task/QR-decomposition/Common-Lisp/qr-decomposition-4.lisp @@ -0,0 +1,29 @@ +(defun polyfit (x y n) + (let* ((m (cadr (array-dimensions x))) + (A (make-array `(,m ,(+ n 1)) :initial-element 0))) + (loop for i from 0 to (- m 1) do + (loop for j from 0 to n do + (setf (aref A i j) + (expt (aref x 0 i) j)))) + (lsqr A (mtp y)))) + +;; Solve a linear least squares problem by QR decomposition. +(defun lsqr (A b) + (multiple-value-bind (Q R) (qr A) + (let* ((n (cadr (array-dimensions R)))) + (solve-upper-triangular (array-range R 0 (- n 1) 0 (- n 1)) + (array-range (mmul (mtp Q) b) 0 (- n 1) 0 0))))) + +;; Solve an upper triangular system by back substitution. +(defun solve-upper-triangular (R b) + (let* ((n (cadr (array-dimensions R))) + (x (make-array `(,n 1) :initial-element 0.0d0))) + + (loop for k from (- n 1) downto 0 + do (setf (aref x k 0) + (/ (- (aref b k 0) + (loop for j from (+ k 1) to (- n 1) + sum (* (aref R k j) + (aref x j 0)))) + (aref R k k)))) + x)) diff --git a/Task/QR-decomposition/Common-Lisp/qr-decomposition-5.lisp b/Task/QR-decomposition/Common-Lisp/qr-decomposition-5.lisp new file mode 100644 index 0000000000..a61e089470 --- /dev/null +++ b/Task/QR-decomposition/Common-Lisp/qr-decomposition-5.lisp @@ -0,0 +1,6 @@ +;; Finally use the data: +(let ((x #2A((0 1 2 3 4 5 6 7 8 9 10))) + (y #2A((1 6 17 34 57 86 121 162 209 262 321)))) + (polyfit x y 2)) + +#2A((0.999999966345088) (2.000000015144699) (2.99999999879804)) diff --git a/Task/QR-decomposition/D/qr-decomposition.d b/Task/QR-decomposition/D/qr-decomposition.d new file mode 100644 index 0000000000..045ec32cd4 --- /dev/null +++ b/Task/QR-decomposition/D/qr-decomposition.d @@ -0,0 +1,205 @@ +import std.stdio, std.math, std.algorithm, std.traits, + std.typecons, std.numeric, std.range, std.conv; + +T[][] elementwiseMat(string op, T, U)(in T[][] A, in U B) +pure /*nothrow*/ if (is(U == T) || is(U == T[][])) { + static if (is(U == T[][])) + assert(A.length == B.length); + if (A.empty) + return null; + auto R = new typeof(return)(A.length, A[0].length); + + foreach (immutable r, const row; A) + static if (is(U == T)) { + R[r][] = mixin("row[] " ~ op ~ "B"); + } else { + assert(row.length == B[r].length); + R[r][] = mixin("row[] " ~ op ~ "B[r][]"); + } + + return R; +} + +T[][] msum(T)(in T[][] A, in T[][] B) pure /*nothrow*/ { + return elementwiseMat!(q{ + }, T, T[][])(A, B); +} +T[][] msub(T)(in T[][] A, in T[][] B) pure /*nothrow*/ { + return elementwiseMat!(q{ - }, T, T[][])(A, B); +} +T[][] pmul(T)(in T[][] A, in T x) pure /*nothrow*/ { + return elementwiseMat!(q{ * }, T, T)(A, x); +} +T[][] pdiv(T)(in T[][] A, in T x) pure /*nothrow*/ { + return elementwiseMat!(q{ / }, T, T)(A, x); +} + +bool isRectangular(T)(in T[][] mat) /*pure nothrow*/ { + return mat.all!(r => r.length == mat[0].length); +} + +T[][] matMul(T)(in T[][] a, in T[][] b) /*pure nothrow*/ +in { + assert(a.isRectangular && b.isRectangular && + a[0].length == b.length); +} body { + auto result = new T[][](a.length, b[0].length); + auto aux = new T[b.length]; + foreach (immutable j; 0 .. b[0].length) { + foreach (immutable k; 0 .. b.length) + aux[k] = b[k][j]; + foreach (immutable i; 0 .. a.length) + result[i][j] = a[i].dotProduct(aux); + } + return result; +} + +Unqual!T[][] transpose(T)(in T[][] m) pure nothrow { + auto r = new Unqual!T[][](m[0].length, m.length); + foreach (immutable nr, const row; m) + foreach (immutable nc, immutable c; row) + r[nc][nr] = c; + return r; +} + +T norm(T)(in T[][] m) pure nothrow { + return reduce!q{ a + b ^^ 2 }(cast(T)0, transversal(m, 0)).sqrt; +} + +T[][] makeUnitVector(T)(in size_t dim) pure nothrow { + auto result = new T[][](dim, 1); + foreach (row; result) + row[] = 0; + result[0][0] = 1; + return result; +} + +/// Return a nxn identity matrix. +T[][] matId(T)(in size_t n) pure nothrow { + auto Id = new T[][](n, n); + foreach (immutable r, row; Id) { + row[] = 0; + row[r] = 1; + } + return Id; +} + +Unqual!T[][] slice2D(T)(in T[][] A, + in size_t ma, in size_t mb, + in size_t na, in size_t nb) pure nothrow { + auto B = new Unqual!T[][](mb - ma + 1, nb - na + 1); + foreach (immutable i, brow; B) + brow[] = A[ma + i][na .. na + brow.length]; + return B; +} + +size_t rows(T)(in T[][] A) pure nothrow { return A.length; } + +size_t cols(T)(in T[][] A) pure nothrow { + return A.length ? A[0].length : 0; +} + +T[][] mcol(T)(in T[][] A, in size_t n) pure nothrow { + return slice2D(A, 0, rows(A)-1, n, n); +} + +T[][] matEmbed(T)(in T[][] A, in T[][] B, + in size_t row, in size_t col) pure nothrow { + auto C = new T[][](rows(A), cols(A)); + foreach (immutable i, const arow; A) + C[i][] = arow[]; // some wasted copies + foreach (immutable i, const brow; B) + C[row + i][col .. col + brow.length] = brow[]; + return C; +} + +// Main routines --------------- + +T[][] makeHouseholder(T)(in T[][] a) { + immutable size_t m = rows(a); + immutable T s = sgn(a[0][0]); + immutable e = makeUnitVector!T(m); + immutable u = msum(a, pmul(e, norm(a) * s)); + immutable v = pdiv(u, u[0][0]); + immutable beta = 2.0 / matMul(transpose(v), v)[0][0]; + return msub(matId!T(m), pmul(matMul(v, transpose(v)), beta)); +} + +Tuple!(T[][],"Q", T[][],"R") QRdecomposition(T)(T[][] A) { + immutable m = rows(A); + immutable n = cols(A); + auto Q = matId!T(m); + + // Work on n columns of A. + foreach (immutable i; 0 .. (m == n ? n-1 : n)) { + // Select the i-th submatrix. For i=0 this means the original + // matrix A. + immutable B = slice2D(A, i, m-1, i, n-1); + + // Take the first column of the current submatrix B. + immutable x = mcol(B, 0); + + // Create the Householder matrix for the column and embed it + // into an mxm identity. + immutable H = matEmbed(matId!T(m), makeHouseholder(x), i, i); + + // The product of all H matrices from the right hand side is + // the orthogonal matrix Q. + Q = matMul(Q, H); + + // The product of all H matrices with A from the LHS is the + // upper triangular matrix R. + A = matMul(H, A); + } + + // Return Q and R. + return typeof(return)(Q, A); +} + +// Polynomial regression --------------- + +/// Solve an upper triangular system by back substitution. +T[][] solveUpperTriangular(T)(in T[][] R, in T[][] b) pure nothrow { + immutable size_t n = cols(R); + auto x = new T[][](n, 1); + + foreach_reverse (immutable k; 0 .. n) { + T tot = 0; + foreach (immutable j; k + 1 .. n) + tot += R[k][j] * x[j][0]; + x[k][0] = (b[k][0] - tot) / R[k][k]; + } + + return x; +} + +/// Solve a linear least squares problem by QR decomposition. +T[][] lsqr(T)(T[][] A, in T[][] b) { + const qr = QRdecomposition(A); + immutable size_t n = cols(qr.R); + return solveUpperTriangular( + slice2D(qr.R, 0, n-1, 0, n-1), + slice2D(matMul(transpose(qr.Q), b), 0, n-1, 0, 0)); +} + +Unqual!T[][] polyFit(T)(in T[][] x, in T[][] y, in size_t n) { + immutable size_t m = cols(x); + auto A = new Unqual!T[][](m, n + 1); + foreach (immutable i, row; A) + foreach (immutable j, ref item; row) + item = x[0][i] ^^ j; + return lsqr(A, transpose(y)); +} + +void main() { + // const (Q, R) = QRdecomposition( + const qr = QRdecomposition([[12.0, -51, 4], + [ 6.0, 167, -68], + [-4.0, 24, -41]]); + immutable string form = "[%([%(%2.3f, %)]%|,\n %)]\n"; + writefln(form, qr.Q); + writefln(form, qr.R); + + immutable x = [[0.0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]; + immutable y = [[1.0, 6, 17, 34, 57, 86, 121, 162, 209, 262, 321]]; + writeln(polyFit(x, y, 2)); +} diff --git a/Task/QR-decomposition/Go/qr-decomposition.go b/Task/QR-decomposition/Go/qr-decomposition.go new file mode 100644 index 0000000000..3959bda84c --- /dev/null +++ b/Task/QR-decomposition/Go/qr-decomposition.go @@ -0,0 +1,106 @@ +package main + +import ( + "code.google.com/p/gomatrix/matrix" + "fmt" + "math" +) + +func sign(s float64) float64 { + if s > 0 { + return 1 + } else if s < 0 { + return -1 + } + return 0 +} + +func unitVector(n int) *matrix.DenseMatrix { + vec := matrix.Zeros(n, 1) + vec.Set(0, 0, 1) + return vec +} + +func householder(a *matrix.DenseMatrix) *matrix.DenseMatrix { + m := a.Rows() + s := sign(a.Get(0, 0)) + e := unitVector(m) + u := matrix.Sum(a, matrix.Scaled(e, a.TwoNorm()*s)) + v := matrix.Scaled(u, 1/u.Get(0, 0)) + // (error checking skipped in this solution) + prod, _ := v.Transpose().TimesDense(v) + β := 2 / prod.Get(0, 0) + + prod, _ = v.TimesDense(v.Transpose()) + return matrix.Difference(matrix.Eye(m), matrix.Scaled(prod, β)) +} + +func qr(a *matrix.DenseMatrix) (q, r *matrix.DenseMatrix) { + m := a.Rows() + n := a.Cols() + q = matrix.Eye(m) + + last := n - 1 + if m == n { + last-- + } + for i := 0; i <= last; i++ { + // (copy is only for compatibility with an older version of gomatrix) + b := a.GetMatrix(i, i, m-i, n-i).Copy() + x := b.GetColVector(0) + h := matrix.Eye(m) + h.SetMatrix(i, i, householder(x)) + q, _ = q.TimesDense(h) + a, _ = h.TimesDense(a) + } + return q, a +} + +func main() { + // task 1: show qr decomp of wp example + a := matrix.MakeDenseMatrixStacked([][]float64{ + {12, -51, 4}, + {6, 167, -68}, + {-4, 24, -41}}) + q, r := qr(a) + fmt.Println("q:\n", q) + fmt.Println("r:\n", r) + + // task 2: use qr decomp for polynomial regression example + x := matrix.MakeDenseMatrixStacked([][]float64{ + {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}}) + y := matrix.MakeDenseMatrixStacked([][]float64{ + {1, 6, 17, 34, 57, 86, 121, 162, 209, 262, 321}}) + fmt.Println("\npolyfit:\n", polyfit(x, y, 2)) +} + +func polyfit(x, y *matrix.DenseMatrix, n int) *matrix.DenseMatrix { + m := x.Cols() + a := matrix.Zeros(m, n+1) + for i := 0; i < m; i++ { + for j := 0; j <= n; j++ { + a.Set(i, j, math.Pow(x.Get(0, i), float64(j))) + } + } + return lsqr(a, y.Transpose()) +} + +func lsqr(a, b *matrix.DenseMatrix) *matrix.DenseMatrix { + q, r := qr(a) + n := r.Cols() + prod, _ := q.Transpose().TimesDense(b) + return solveUT(r.GetMatrix(0, 0, n, n), prod.GetMatrix(0, 0, n, 1)) +} + +func solveUT(r, b *matrix.DenseMatrix) *matrix.DenseMatrix { + n := r.Cols() + x := matrix.Zeros(n, 1) + for k := n - 1; k >= 0; k-- { + sum := 0. + for j := k + 1; j < n; j++ { + sum += r.Get(k, j) * x.Get(j, 0) + } + x.Set(k, 0, (b.Get(k, 0)-sum)/r.Get(k, k)) + } + return x +} diff --git a/Task/QR-decomposition/J/qr-decomposition-1.j b/Task/QR-decomposition/J/qr-decomposition-1.j new file mode 100644 index 0000000000..36424a8cce --- /dev/null +++ b/Task/QR-decomposition/J/qr-decomposition-1.j @@ -0,0 +1,16 @@ +mp=: +/ . * NB. matrix product +h =: +@|: NB. conjugate transpose + +QR=: 3 : 0 + n=.{:$A=.y + if. 1>:n do. + A ((% {.@,) ; ]) %:(h A) mp A + else. + m =.>.n%2 + A0=.m{."1 A + A1=.m}."1 A + 'Q0 R0'=.QR A0 + 'Q1 R1'=.QR A1 - Q0 mp T=.(h Q0) mp A1 + (Q0,.Q1);(R0,.T),(-n){."1 R1 + end. +) diff --git a/Task/QR-decomposition/J/qr-decomposition-2.j b/Task/QR-decomposition/J/qr-decomposition-2.j new file mode 100644 index 0000000000..103e2256cb --- /dev/null +++ b/Task/QR-decomposition/J/qr-decomposition-2.j @@ -0,0 +1,6 @@ + QR x:12 _51 4,6 167 _68,:_4 24 _41 +┌────────────────────┬──────────┐ +│ 6r7 _69r175 _58r175│14 21 _14│ +│ 3r7 158r175 6r175│ 0 175 _70│ +│_2r7 6r35 _33r35│ 0 0 35│ +└────────────────────┴──────────┘ diff --git a/Task/QR-decomposition/J/qr-decomposition-3.j b/Task/QR-decomposition/J/qr-decomposition-3.j new file mode 100644 index 0000000000..7cefa21018 --- /dev/null +++ b/Task/QR-decomposition/J/qr-decomposition-3.j @@ -0,0 +1,4 @@ + X=:i.# Y=:1 6 17 34 57 86 121 162 209 262 321 + 'Q R'=: QR X ^/ i.3 + R %.~(|:Q)+/ .* Y +1 2 3 diff --git a/Task/QR-decomposition/MATLAB/qr-decomposition.m b/Task/QR-decomposition/MATLAB/qr-decomposition.m new file mode 100644 index 0000000000..dbd7b16230 --- /dev/null +++ b/Task/QR-decomposition/MATLAB/qr-decomposition.m @@ -0,0 +1,4 @@ + A = [12 -51 4 + 6 167 -68 + -4 24 -41]; + [Q,R]=qr(A) diff --git a/Task/QR-decomposition/Mathematica/qr-decomposition.math b/Task/QR-decomposition/Mathematica/qr-decomposition.math new file mode 100644 index 0000000000..d8e72012f4 --- /dev/null +++ b/Task/QR-decomposition/Mathematica/qr-decomposition.math @@ -0,0 +1,11 @@ +{q,r}=QRDecomposition[{{12, -51, 4}, {6, 167, -68}, {-4, 24, -41}}]; +q//MatrixForm + +-> 6/7 3/7 -(2/7) +-69/175 158/175 6/35 +-58/175 6/175 -33/35 + +r//MatrixForm +-> 14 21 -14 + 0 175 -70 + 0 0 35 diff --git a/Task/QR-decomposition/Maxima/qr-decomposition-1.maxima b/Task/QR-decomposition/Maxima/qr-decomposition-1.maxima new file mode 100644 index 0000000000..8f4f9e5f41 --- /dev/null +++ b/Task/QR-decomposition/Maxima/qr-decomposition-1.maxima @@ -0,0 +1,12 @@ +load(lapack)$ /* This may hang up in wxMaxima, if this happens, use xMaxima or plain MAxima in a terminal */ + +a: matrix([12, -51, 4], + [ 6, 167, -68], + [-4, 24, -41])$ + +[q, r]: dgeqrf(a)$ + +mat_norm(q . r - a, 1); +4.2632564145606011E-14 + +/* Note: the lapack package is a lisp translation of the fortran lapack library */ diff --git a/Task/QR-decomposition/Maxima/qr-decomposition-2.maxima b/Task/QR-decomposition/Maxima/qr-decomposition-2.maxima new file mode 100644 index 0000000000..5c8822b516 --- /dev/null +++ b/Task/QR-decomposition/Maxima/qr-decomposition-2.maxima @@ -0,0 +1,44 @@ +load("linearalgebra")$ +load("eigen")$ +unitVector(n) := ematrix(n,1,1,1,1); +signValue(r) := block([s:sign(r)], + if s='pos then 1 else if s='zero then 0 else -1); +householder(a) := block([m : length(a),u,v,beta], + u : a + sqrt(a . a)*signValue(a[1,1])*unitVector(m), + v : u / u[1,1], + beta : 2/(v . v), + diagmatrix(m,1) - beta*transpose(v . transpose(v))); +getSubmatrix(obj,i1,j1,i2,j2) := +genmatrix(lambda([i,j], obj[i+i1-1,j+j1-1]),i2-i1+1,j2-j1+1); +setSubmatrix(obj,i1,j1,subobj) := block([m,n], + [m,n] : matrix_size(subobj), + for i: 0 thru m-1 do + (for j: 0 thru n-1 do + obj[i1+i,j1+j] : subobj[i+1,j+1])); +qr(obj) := block([m,n,qm,rm,i], + [m,n] : matrix_size(obj), + qm : diagmatrix(m,1), + rm : copymatrix(obj), + for i: 1 thru (if m=n then n-1 else n) do + block([x,h], + x : getSubmatrix(rm,i,i,m,i), + h : diagmatrix(m,1), + setSubmatrix(h,i,i,householder(x)), + qm : qm . h, + rm : h . rm), + [qm,rm]); +solveUpperTriangular(r,b) := block([n,x,index,k], + n : second(matrix_size(r)), + x : genmatrix(lambda([a, b], 0), n, 1), + for k: n thru 1 step -1 do + (index : min(n,k+1), + x[k,1] : (b[k,1] - (getSubmatrix(r,k,index,k,n) . getSubmatrix(x,index,1,n,1)))/r[k,k]), + x); +lsqr(a,b) := block([q,r,n], + [q,r] : qr(a), + n : second(matrix_size(r)), + solveUpperTriangular(getSubmatrix(r,1,1,n,n), transpose(q) . b)); +polyfit(x,y,n) := block([a,j], + a : genmatrix(lambda([i,j], if j=1 then 1.0b0 else bfloat(x[i,1]^(j-1))), + length(x),n+1), + lsqr(a,y)); diff --git a/Task/QR-decomposition/Maxima/qr-decomposition-3.maxima b/Task/QR-decomposition/Maxima/qr-decomposition-3.maxima new file mode 100644 index 0000000000..9e3c8f472c --- /dev/null +++ b/Task/QR-decomposition/Maxima/qr-decomposition-3.maxima @@ -0,0 +1,29 @@ +(%i) [q,r] : qr(a); + + [ 6 69 58 ] + [ - - --- --- ] + [ 7 175 175 ] + [ ] [ - 14 - 21 14 ] + [ 3 158 6 ] [ ] +(%o) [[ - - - --- - --- ], [ 0 - 175 70 ]] + [ 7 175 175 ] [ ] + [ ] [ 0 0 - 35 ] + [ 2 6 33 ] + [ - - -- -- ] + [ 7 35 35 ] +(%i) mat_norm(q . r - a, 1); + +(%o) 0 +(%i) x : transpose(matrix([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]))$ + +(%i) y : transpose(matrix([1, 6, 17, 34, 57, 86, 121, 162, 209, 262, 321]))$ + +(%i) fpprec : 30$ + +(%i) polyfit(x, y, 2); + + [ 9.99999999999999999999999999996b-1 ] + [ ] +(%o) [ 2.00000000000000000000000000002b0 ] + [ ] + [ 3.0b0 ] diff --git a/Task/QR-decomposition/PARI-GP/qr-decomposition.pari b/Task/QR-decomposition/PARI-GP/qr-decomposition.pari new file mode 100644 index 0000000000..e317bbb407 --- /dev/null +++ b/Task/QR-decomposition/PARI-GP/qr-decomposition.pari @@ -0,0 +1 @@ +matqr(M) diff --git a/Task/QR-decomposition/R/qr-decomposition.r b/Task/QR-decomposition/R/qr-decomposition.r new file mode 100644 index 0000000000..0f116756f3 --- /dev/null +++ b/Task/QR-decomposition/R/qr-decomposition.r @@ -0,0 +1,23 @@ +# R has QR decomposition built-in (using LAPACK or LINPACK) + +a <- matrix(c(12, -51, 4, 6, 167, -68, -4, 24, -41), nrow=3, ncol=3, byrow=T) +d <- qr(a) +qr.Q(d) +qr.R(d) + +# now fitting a polynomial +x <- 0:10 +y <- 3*x^2 + 2*x + 1 + +# using QR decomposition directly +a <- cbind(1, x, x^2) +qr.coef(qr(a), y) + +# using least squares +a <- cbind(x, x^2) +lsfit(a, y)$coefficients + +# using a linear model +xx <- x*x +m <- lm(y ~ x + xx) +coef(m) diff --git a/Task/QR-decomposition/Rascal/qr-decomposition.rascal b/Task/QR-decomposition/Rascal/qr-decomposition.rascal new file mode 100644 index 0000000000..9da69ea751 --- /dev/null +++ b/Task/QR-decomposition/Rascal/qr-decomposition.rascal @@ -0,0 +1,93 @@ +import util::Math; +import Prelude; +import vis::Figure; +import vis::Render; + +public rel[real,real,real] QRdecomposition(rel[real x, real y, real v] matrix){ + //orthogonalcolumns + oc = domainR(matrix, {0.0}); + for (x <- sort(toList(domain(matrix)-{0.0}))){ + c = domainR(matrix, {x}); + o = domainR(oc, {x-1}); + + for (n <- [1.0 .. x]){ + o = domainR(oc, {n-1}); + c = matrixSubtract(c, matrixMultiplybyN(o, matrixDotproduct(o, c)/matrixDotproduct(o, o))); + } + + oc += c; + } + + Q = {}; + //from orthogonal to orthonormal columns + for (el <- oc){ + c = domainR(oc, {el[0]}); + Q += matrixNormalize({el}, c); + } + + //from Q to R + R= matrixMultiplication(matrixTranspose(Q), matrix); + R= { | <- R}; + + println("Q:"); + iprintlnExp(Q); + println(); + println("R:"); + return R; +} + +//a function that takes the transpose of a matrix, see also Rosetta Code problem "Matrix transposition" +public rel[real, real, real] matrixTranspose(rel[real x, real y, real v] matrix){ + return { | <- matrix}; +} + +//a function to normalize an element of a matrix by the normalization of a column +public rel[real,real,real] matrixNormalize(rel[real x, real y, real v] element, rel[real x, real y, real v] column){ + normalized = 1.0/nroot((0.0 | it + v*v | <- column), 2); + return matrixMultiplybyN(element, normalized); +} + +//a function that takes the dot product, see also Rosetta Code problem "Dot product" +public real matrixDotproduct(rel[real x, real y, real v] column1, rel[real x, real y, real v] column2){ + return (0.0 | it + v1*v2 | <- column1, <- column2, y1==y2); +} + +//a function to subtract two columns +public rel[real,real,real] matrixSubtract(rel[real x, real y, real v] column1, rel[real x, real y, real v] column2){ + return { | <- column1, <- column2, y1==y2}; +} + +//a function to multiply a column by a number +public rel[real,real,real] matrixMultiplybyN(rel[real x, real y, real v] column, real n){ + return { | <- column}; +} + +//a function to perform matrix multiplication, see also Rosetta Code problem "Matrix multiplication". +public rel[real, real, real] matrixMultiplication(rel[real x, real y, real v] matrix1, rel[real x, real y, real v] matrix2){ + if (max(matrix1.x) == max(matrix2.y)){ + p = { | <- matrix1, <- matrix2}; + + result = {}; + for (y <- matrix1.y){ + for (x <- matrix2.x){ + v = (0.0 | it + v | <- p, x==x2 && y==y1, x1==y2 && y2==x1); + result += ; + } + } + return result; + } + else throw "Matrix sizes do not match."; +} + +// a function to visualize the result +public void displayMatrix(rel[real x, real y, real v] matrix){ + points = [box(text(""), align(0.3333*(x+1),0.3333*(y+1)),shrink(0.25)) | <- matrix]; + render(overlay([*points], aspectRatio(1.0))); +} + +//a matrix, given by a relation of . +public rel[real x, real y, real v] matrixA = { +<0.0,0.0,12.0>, <0.0,1.0, 6.0>, <0.0,2.0,-4.0>, +<1.0,0.0,-51.0>, <1.0,1.0,167.0>, <1.0,2.0,24.0>, +<2.0,0.0,4.0>, <2.0,1.0,-68.0>, <2.0,2.0,-41.0> +}; diff --git a/Task/QR-decomposition/SAS/qr-decomposition.sas b/Task/QR-decomposition/SAS/qr-decomposition.sas new file mode 100644 index 0000000000..5bca34da98 --- /dev/null +++ b/Task/QR-decomposition/SAS/qr-decomposition.sas @@ -0,0 +1,32 @@ +/* See http://support.sas.com/documentation/cdl/en/imlug/63541/HTML/default/viewer.htm#imlug_langref_sect229.htm */ + +proc iml; +a={12 -51 4,6 167 -68,-4 24 -41}; +print(a); +call qr(q,r,p,d,a); +print(q); +print(r); +quit; + +/* + a + + 12 -51 4 + 6 167 -68 + -4 24 -41 + + + q + + -0.857143 0.3942857 -0.331429 + -0.428571 -0.902857 0.0342857 + 0.2857143 -0.171429 -0.942857 + + + r + + -14 -21 14 + 0 -175 70 + 0 0 35 + +*/ diff --git a/Task/QR-decomposition/Tcl/qr-decomposition-1.tcl b/Task/QR-decomposition/Tcl/qr-decomposition-1.tcl new file mode 100644 index 0000000000..78a4e6aad0 --- /dev/null +++ b/Task/QR-decomposition/Tcl/qr-decomposition-1.tcl @@ -0,0 +1,58 @@ +package require Tcl 8.5 +namespace path {::tcl::mathfunc ::tcl::mathop} +proc sign x {expr {$x == 0 ? 0 : $x < 0 ? -1 : 1}} +proc norm vec { + set s 0 + foreach x $vec {set s [expr {$s + $x**2}]} + return [sqrt $s] +} +proc unitvec n { + set v [lrepeat $n 0.0] + lset v 0 1.0 + return $v +} +proc I n { + set m [lrepeat $n [lrepeat $n 0.0]] + for {set i 0} {$i < $n} {incr i} {lset m $i $i 1.0} + return $m +} + +proc arrayEmbed {A B row col} { + # $A will be copied automatically; Tcl values are copy-on-write + lassign [size $B] mb nb + for {set i 0} {$i < $mb} {incr i} { + for {set j 0} {$j < $nb} {incr j} { + lset A [expr {$row + $i}] [expr {$col + $j}] [lindex $B $i $j] + } + } + return $A +} + +# Unlike the Common Lisp version, here we use a specialist subcolumn +# extraction function: like that, there's a lot less intermediate memory allocation +# and the code is actually clearer. +proc subcolumn {A size column} { + for {set i $column} {$i < $size} {incr i} {lappend x [lindex $A $i $column]} + return $x +} + +proc householder A { + lassign [size $A] m + set U [m+ $A [.* [unitvec $m] [expr {[norm $A] * [sign [lindex $A 0 0]]}]]] + set V [./ $U [lindex $U 0 0]] + set beta [expr {2.0 / [lindex [matrix_multiply [transpose $V] $V] 0 0]}] + return [m- [I $m] [.* [matrix_multiply $V [transpose $V]] $beta]] +} + +proc qrDecompose A { + lassign [size $A] m n + set Q [I $m] + for {set i 0} {$i < ($m==$n ? $n-1 : $n)} {incr i} { + # Construct the Householder matrix + set H [arrayEmbed [I $m] [householder [subcolumn $A $n $i]] $i $i] + # Apply to build the decomposition + set Q [matrix_multiply $Q $H] + set A [matrix_multiply $H $A] + } + return [list $Q $A] +} diff --git a/Task/QR-decomposition/Tcl/qr-decomposition-2.tcl b/Task/QR-decomposition/Tcl/qr-decomposition-2.tcl new file mode 100644 index 0000000000..52c869dfb2 --- /dev/null +++ b/Task/QR-decomposition/Tcl/qr-decomposition-2.tcl @@ -0,0 +1,5 @@ +set demo [qrDecompose {{12 -51 4} {6 167 -68} {-4 24 -41}}] +puts "==Q==" +print_matrix [lindex $demo 0] "%f" +puts "==R==" +print_matrix [lindex $demo 1] "%.1f" diff --git a/Task/Quaternion-type/0DESCRIPTION b/Task/Quaternion-type/0DESCRIPTION new file mode 100644 index 0000000000..d5f351843e --- /dev/null +++ b/Task/Quaternion-type/0DESCRIPTION @@ -0,0 +1,29 @@ +[[wp:Quaternion|Quaternions]] are an extension of the idea of [[Arithmetic/Complex|complex numbers]]. + +A complex number has a real and complex part written sometimes as a + bi, where a and b stand for real numbers and i stands for the square root of minus 1. An example of a complex number might be -3 + 2i, where the real part, a is -3.0 and the complex part, b is +2.0. + +A quaternion has one real part and ''three'' imaginary parts, i, j, and k. A quaternion might be written as a + bi + cj + dk. In this numbering system, ii = jj = kk = ijk = -1. The order of multiplication is important, as, in general, for two quaternions q1 and q2; q1q2 != q2q1. An example of a quaternion might be 1 +2i +3j +4k + +There is a list form of notation where just the numbers are shown and the imaginary multipliers i, j, and k are assumed by position. So the example above would be written as (1, 2, 3, 4) + +'''Task Description'''
    +Given the three quaternions and their components: + q = (1, 2, 3, 4) = (a, b, c, d ) + q1 = (2, 3, 4, 5) = (a1, b1, c1, d1) + q2 = (3, 4, 5, 6) = (a2, b2, c2, d2) +And a wholly real number r = 7. + +Your task is to create functions or classes to perform simple maths with quaternions including computing: +# The norm of a quaternion:
    = \sqrt{a^2 + b^2 + c^2 + d^2} +# The negative of a quaternion:
    =(-a, -b, -c, -d) +# The conjugate of a quaternion:
    =( a, -b, -c, -d) +# Addition of a real number r and a quaternion q:
    r + q = q + r = (a+r, b, c, d) +# Addition of two quaternions:
    q1 + q2 = (a1+a2, b1+b2, c1+c2, d1+d2) +# Multiplication of a real number and a quaternion:
    qr = rq = (ar, br, cr, dr) +# Multiplication of two quaternions q1 and q2 is given by:
    ( a1a2 − b1b2 − c1c2 − d1d2,
      a1b2 + b1a2 + c1d2 − d1c2,
      a1c2 − b1d2 + c1a2 + d1b2,
      a1d2 + b1c2 − c1b2 + d1a2 ) +# Show that, for the two quaternions q1 and q2:
    q1q2 != q2q1 +If your language has built-in support for quaternions then use it. + +C.f. +* [[Vector products]] +* [http://www.maths.tcd.ie/pub/HistMath/People/Hamilton/QLetter/QLetter.pdf On Quaternions]; or on a new System of Imaginaries in Algebra. By Sir William Rowan Hamilton LL.D, P.R.I.A., F.R.A.S., Hon. M. R. Soc. Ed. and Dub., Hon. or Corr. M. of the Royal or Imperial Academies of St. Petersburgh, Berlin, Turin and Paris, Member of the American Academy of Arts and Sciences, and of other Scientific Societies at Home and Abroad, Andrews' Prof. of Astronomy in the University of Dublin, and Royal Astronomer of Ireland. diff --git a/Task/Quaternion-type/ALGOL-68/quaternion-type.alg b/Task/Quaternion-type/ALGOL-68/quaternion-type.alg new file mode 100644 index 0000000000..68c68eda8b --- /dev/null +++ b/Task/Quaternion-type/ALGOL-68/quaternion-type.alg @@ -0,0 +1,220 @@ +MODE QUAT = STRUCT(REAL re, i, j, k); +MODE QUATERNION = QUAT; +MODE SUBQUAT = UNION(QUAT, #COMPL, # REAL#, INT, [4]REAL, [4]INT # ); + +MODE CLASSQUAT = STRUCT( + PROC (REF QUAT #new#, REAL #re#, REAL #i#, REAL #j#, REAL #k#)REF QUAT new, + PROC (REF QUAT #self#)QUAT conjugate, + PROC (REF QUAT #self#)REAL norm sq, + PROC (REF QUAT #self#)REAL norm, + PROC (REF QUAT #self#)QUAT reciprocal, + PROC (REF QUAT #self#)STRING repr, + PROC (REF QUAT #self#)QUAT neg, + PROC (REF QUAT #self#, SUBQUAT #other#)QUAT add, + PROC (REF QUAT #self#, SUBQUAT #other#)QUAT radd, + PROC (REF QUAT #self#, SUBQUAT #other#)QUAT sub, + PROC (REF QUAT #self#, SUBQUAT #other#)QUAT mul, + PROC (REF QUAT #self#, SUBQUAT #other#)QUAT rmul, + PROC (REF QUAT #self#, SUBQUAT #other#)QUAT div, + PROC (REF QUAT #self#, SUBQUAT #other#)QUAT rdiv, + PROC (REF QUAT #self#)QUAT exp +); + +CLASSQUAT class quat = ( + + # PROC new =#(REF QUAT new, REAL re, i, j, k)REF QUAT: ( + # 'Defaults all parts of quaternion to zero' # + IF new ISNT REF QUAT(NIL) THEN new ELSE HEAP QUAT FI := (re, i, j, k) + ), + + # PROC conjugate =#(REF QUAT self)QUAT: + (re OF self, -i OF self, -j OF self, -k OF self), + + # PROC norm sq =#(REF QUAT self)REAL: + re OF self**2 + i OF self**2 + j OF self**2 + k OF self**2, + + # PROC norm =#(REF QUAT self)REAL: + sqrt((norm sq OF class quat)(self)), + + # PROC reciprocal =#(REF QUAT self)QUAT:( + REAL n2 = (norm sq OF class quat)(self); + QUAT conj = (conjugate OF class quat)(self); + (re OF conj/n2, i OF conj/n2, j OF conj/n2, k OF conj/n2) + ), + + # PROC repr =#(REF QUAT self)STRING: ( + # 'Shorter form of Quaternion as string' # + FILE f; STRING s; associate(f, s); + putf(f, (squat fmt, re OF self>=0, re OF self, + i OF self>=0, i OF self, j OF self>=0, j OF self, k OF self>=0, k OF self)); + close(f); + s + ), + + # PROC neg =#(REF QUAT self)QUAT: + (-re OF self, -i OF self, -j OF self, -k OF self), + + # PROC add =#(REF QUAT self, SUBQUAT other)QUAT: + CASE other IN + (QUAT other): (re OF self + re OF other, i OF self + i OF other, j OF self + j OF other, k OF self + k OF other), + (REAL other): (re OF self + other, i OF self, j OF self, k OF self) + ESAC, + + # PROC radd =#(REF QUAT self, SUBQUAT other)QUAT: + (add OF class quat)(self, other), + + # PROC sub =#(REF QUAT self, SUBQUAT other)QUAT: + CASE other IN + (QUAT other): (re OF self - re OF other, i OF self - i OF other, j OF self - j OF other, k OF self - k OF other), + (REAL other): (re OF self - other, i OF self, j OF self, k OF self) + ESAC, + + # PROC mul =#(REF QUAT self, SUBQUAT other)QUAT: + CASE other IN + (QUAT other):( + re OF self*re OF other - i OF self*i OF other - j OF self*j OF other - k OF self*k OF other, + re OF self*i OF other + i OF self*re OF other + j OF self*k OF other - k OF self*j OF other, + re OF self*j OF other - i OF self*k OF other + j OF self*re OF other + k OF self*i OF other, + re OF self*k OF other + i OF self*j OF other - j OF self*i OF other + k OF self*re OF other + ), + (REAL other): ( re OF self * other, i OF self * other, j OF self * other, k OF self * other) + ESAC, + + # PROC rmul =#(REF QUAT self, SUBQUAT other)QUAT: + CASE other IN + (QUAT other): (mul OF class quat)(LOC QUAT := other, self), + (REAL other): (mul OF class quat)(self, other) + ESAC, + + # PROC div =#(REF QUAT self, SUBQUAT other)QUAT: + CASE other IN + (QUAT other): (mul OF class quat)(self, (reciprocal OF class quat)(LOC QUAT := other)), + (REAL other): (mul OF class quat)(self, 1/other) + ESAC, + + # PROC rdiv =#(REF QUAT self, SUBQUAT other)QUAT: + CASE other IN + (QUAT other): (div OF class quat)(LOC QUAT := other, self), + (REAL other): (div OF class quat)(LOC QUAT := (other, 0, 0, 0), self) + ESAC, + + # PROC exp =#(REF QUAT self)QUAT: ( + QUAT fac := self; + QUAT sum := 1.0 + fac; + FOR i FROM 2 WHILE ABS(fac + small real) /= small real DO + VOID(sum +:= (fac *:= self / REAL(i))) + OD; + sum + ) +); + +FORMAT real fmt = $g(-0, 4)$; +FORMAT signed fmt = $b("+", "")f(real fmt)$; + +FORMAT quat fmt = $f(real fmt)"+"f(real fmt)"i+"f(real fmt)"j+"f(real fmt)"k"$; +FORMAT squat fmt = $f(signed fmt)f(signed fmt)"i"f(signed fmt)"j"f(signed fmt)"k"$; + +PRIO INIT = 1; +OP INIT = (REF QUAT new)REF QUAT: new := (0, 0, 0, 0); +OP INIT = (REF QUAT new, []REAL rijk)REF QUAT: + (new OF class quat)(LOC QUAT := new, rijk[1], rijk[2], rijk[3], rijk[4]); + +OP + = (QUAT q)QUAT: q, + - = (QUAT q)QUAT: (neg OF class quat)(LOC QUAT := q), + CONJ = (QUAT q)QUAT: (conjugate OF class quat)(LOC QUAT := q), + ABS = (QUAT q)REAL: (norm OF class quat)(LOC QUAT := q), + REPR = (QUAT q)STRING: (repr OF class quat)(LOC QUAT := q); +# missing: Diadic: I, J, K END # + +OP +:= = (REF QUAT a, QUAT b)QUAT: a:=( add OF class quat)(a, b), + +:= = (REF QUAT a, REAL b)QUAT: a:=( add OF class quat)(a, b), + +=: = (QUAT a, REF QUAT b)QUAT: b:=(radd OF class quat)(b, a), + +=: = (REAL a, REF QUAT b)QUAT: b:=(radd OF class quat)(b, a); +# missing: Worthy PLUSAB, PLUSTO for SHORT/LONG INT REAL & COMPL # + +OP -:= = (REF QUAT a, QUAT b)QUAT: a:=( sub OF class quat)(a, b), + -:= = (REF QUAT a, REAL b)QUAT: a:=( sub OF class quat)(a, b); +# missing: Worthy MINUSAB for SHORT/LONG INT REAL & COMPL # + +PRIO *=: = 1, /=: = 1; +OP *:= = (REF QUAT a, QUAT b)QUAT: a:=( mul OF class quat)(a, b), + *:= = (REF QUAT a, REAL b)QUAT: a:=( mul OF class quat)(a, b), + *=: = (QUAT a, REF QUAT b)QUAT: b:=(rmul OF class quat)(b, a), + *=: = (REAL a, REF QUAT b)QUAT: b:=(rmul OF class quat)(b, a); +# missing: Worthy TIMESAB, TIMESTO for SHORT/LONG INT REAL & COMPL # + +OP /:= = (REF QUAT a, QUAT b)QUAT: a:=( div OF class quat)(a, b), + /:= = (REF QUAT a, REAL b)QUAT: a:=( div OF class quat)(a, b), + /=: = (QUAT a, REF QUAT b)QUAT: b:=(rdiv OF class quat)(b, a), + /=: = (REAL a, REF QUAT b)QUAT: b:=(rdiv OF class quat)(b, a); +# missing: Worthy OVERAB, OVERTO for SHORT/LONG INT REAL & COMPL # + +OP + = (QUAT a, b)QUAT: ( add OF class quat)(LOC QUAT := a, b), + + = (QUAT a, REAL b)QUAT: ( add OF class quat)(LOC QUAT := a, b), + + = (REAL a, QUAT b)QUAT: (radd OF class quat)(LOC QUAT := b, a); + +OP - = (QUAT a, b)QUAT: ( sub OF class quat)(LOC QUAT := a, b), + - = (QUAT a, REAL b)QUAT: ( sub OF class quat)(LOC QUAT := a, b), + - = (REAL a, QUAT b)QUAT:-( sub OF class quat)(LOC QUAT := b, a); + +OP * = (QUAT a, b)QUAT: ( mul OF class quat)(LOC QUAT := a, b), + * = (QUAT a, REAL b)QUAT: ( mul OF class quat)(LOC QUAT := a, b), + * = (REAL a, QUAT b)QUAT: (rmul OF class quat)(LOC QUAT := b, a); + +OP / = (QUAT a, b)QUAT: ( div OF class quat)(LOC QUAT := a, b), + / = (QUAT a, REAL b)QUAT: ( div OF class quat)(LOC QUAT := a, b), + / = (REAL a, QUAT b)QUAT: ( div OF class quat)(LOC QUAT := b, 1/a); + +PROC quat exp = (QUAT q)QUAT: (exp OF class quat)(LOC QUAT := q); +# missing: quat arc{sin, cos, tan}h, log, exp, ln etc END # + +test:( + REAL r = 7; + QUAT q = (1, 2, 3, 4), + q1 = (2, 3, 4, 5), + q2 = (3, 4, 5, 6); + + printf(( + $"r = " f(real fmt)l$, r, + $"q = " f(quat fmt)l$, q, + $"q1 = " f(quat fmt)l$, q1, + $"q2 = " f(quat fmt)l$, q2, + $"ABS q = " f(real fmt)", "$, ABS q, + $"ABS q1 = " f(real fmt)", "$, ABS q1, + $"ABS q2 = " f(real fmt)l$, ABS q2, + $"-q = " f(quat fmt)l$, -q, + $"CONJ q = " f(quat fmt)l$, CONJ q, + $"r + q = " f(quat fmt)l$, r + q, + $"q + r = " f(quat fmt)l$, q + r, + $"q1 + q2 = "f(quat fmt)l$, q1 + q2, + $"q2 + q1 = "f(quat fmt)l$, q2 + q1, + $"q * r = " f(quat fmt)l$, q * r, + $"r * q = " f(quat fmt)l$, r * q, + $"q1 * q2 = "f(quat fmt)l$, q1 * q2, + $"q2 * q1 = "f(quat fmt)l$, q2 * q1 + )); + +CO + $"ASSERT q1 * q2 != q2 * q1 = "f(quat fmt)l$, ASSERT q1 * q2 != q2 * q1, $l$); +END CO + + QUAT i=(0, 1, 0, 0), + j=(0, 0, 1, 0), + k=(0, 0, 0, 1); + + printf(( + $"i*i = " f(quat fmt)l$, i*i, + $"j*j = " f(quat fmt)l$, j*j, + $"k*k = " f(quat fmt)l$, k*k, + $"i*j*k = " f(quat fmt)l$, i*j*k, + $"q1 / q2 = " f(quat fmt)l$, q1 / q2, + $"q1 / q2 * q2 = "f(quat fmt)l$, q1 / q2 * q2, + $"q2 * q1 / q2 = "f(quat fmt)l$, q2 * q1 / q2, + $"1/q1 * q1 = " f(quat fmt)l$, 1.0/q1 * q1, + $"q1 / q1 = " f(quat fmt)l$, q1 / q1, + $"quat exp(pi * i) = " f(quat fmt)l$, quat exp(pi * i), + $"quat exp(pi * j) = " f(quat fmt)l$, quat exp(pi * j), + $"quat exp(pi * i) = " f(quat fmt)l$, quat exp(pi * k) + )); + print((REPR(-q1*q2), ", ", REPR(-q2*q1), new line)) +) diff --git a/Task/Quaternion-type/Ada/quaternion-type-1.ada b/Task/Quaternion-type/Ada/quaternion-type-1.ada new file mode 100644 index 0000000000..b1aa61bf2f --- /dev/null +++ b/Task/Quaternion-type/Ada/quaternion-type-1.ada @@ -0,0 +1,16 @@ +generic + type Real is digits <>; +package Quaternions is + type Quaternion is record + A, B, C, D : Real; + end record; + function "abs" (Left : Quaternion) return Real; + function Conj (Left : Quaternion) return Quaternion; + function "-" (Left : Quaternion) return Quaternion; + function "+" (Left, Right : Quaternion) return Quaternion; + function "-" (Left, Right : Quaternion) return Quaternion; + function "*" (Left : Quaternion; Right : Real) return Quaternion; + function "*" (Left : Real; Right : Quaternion) return Quaternion; + function "*" (Left, Right : Quaternion) return Quaternion; + function Image (Left : Quaternion) return String; +end Quaternions; diff --git a/Task/Quaternion-type/Ada/quaternion-type-2.ada b/Task/Quaternion-type/Ada/quaternion-type-2.ada new file mode 100644 index 0000000000..4b771c49e9 --- /dev/null +++ b/Task/Quaternion-type/Ada/quaternion-type-2.ada @@ -0,0 +1,59 @@ +with Ada.Numerics.Generic_Elementary_Functions; +package body Quaternions is + package Elementary_Functions is + new Ada.Numerics.Generic_Elementary_Functions (Real); + use Elementary_Functions; + function "abs" (Left : Quaternion) return Real is + begin + return Sqrt (Left.A**2 + Left.B**2 + Left.C**2 + Left.D**2); + end "abs"; + function Conj (Left : Quaternion) return Quaternion is + begin + return (A => Left.A, B => -Left.B, C => -Left.C, D => -Left.D); + end Conj; + function "-" (Left : Quaternion) return Quaternion is + begin + return (A => -Left.A, B => -Left.B, C => -Left.C, D => -Left.D); + end "-"; + function "+" (Left, Right : Quaternion) return Quaternion is + begin + return + ( A => Left.A + Right.A, B => Left.B + Right.B, + C => Left.C + Right.C, D => Left.D + Right.D + ); + end "+"; + function "-" (Left, Right : Quaternion) return Quaternion is + begin + return + ( A => Left.A - Right.A, B => Left.B - Right.B, + C => Left.C - Right.C, D => Left.D - Right.D + ); + end "-"; + function "*" (Left : Quaternion; Right : Real) return Quaternion is + begin + return + ( A => Left.A * Right, B => Left.B * Right, + C => Left.C * Right, D => Left.D * Right + ); + end "*"; + function "*" (Left : Real; Right : Quaternion) return Quaternion is + begin + return Right * Left; + end "*"; + function "*" (Left, Right : Quaternion) return Quaternion is + begin + return + ( A => Left.A * Right.A - Left.B * Right.B - Left.C * Right.C - Left.D * Right.D, + B => Left.A * Right.B + Left.B * Right.A + Left.C * Right.D - Left.D * Right.C, + C => Left.A * Right.C - Left.B * Right.D + Left.C * Right.A + Left.D * Right.B, + D => Left.A * Right.D + Left.B * Right.C - Left.C * Right.B + Left.D * Right.A + ); + end "*"; + function Image (Left : Quaternion) return String is + begin + return Real'Image (Left.A) & " +" & + Real'Image (Left.B) & "i +" & + Real'Image (Left.C) & "j +" & + Real'Image (Left.D) & "k"; + end Image; +end Quaternions; diff --git a/Task/Quaternion-type/Ada/quaternion-type-3.ada b/Task/Quaternion-type/Ada/quaternion-type-3.ada new file mode 100644 index 0000000000..014054dbce --- /dev/null +++ b/Task/Quaternion-type/Ada/quaternion-type-3.ada @@ -0,0 +1,26 @@ +with Ada.Text_IO; use Ada.Text_IO; +with Quaternions; +procedure Test_Quaternion is + package Float_Quaternion is new Quaternions (Float); + use Float_Quaternion; + q : Quaternion := (1.0, 2.0, 3.0, 4.0); + q1 : Quaternion := (2.0, 3.0, 4.0, 5.0); + q2 : Quaternion := (3.0, 4.0, 5.0, 6.0); + r : Float := 7.0; +begin + Put_Line ("q = " & Image (q)); + Put_Line ("q1 = " & Image (q1)); + Put_Line ("q2 = " & Image (q2)); + Put_Line ("r =" & Float'Image (r)); + Put_Line ("abs q =" & Float'Image (abs q)); + Put_Line ("abs q1 =" & Float' Image (abs q1)); + Put_Line ("abs q2 =" & Float' Image (abs q2)); + Put_Line ("-q = " & Image (-q)); + Put_Line ("conj q = " & Image (Conj (q))); + Put_Line ("q1 + q2 = " & Image (q1 + q2)); + Put_Line ("q2 + q1 = " & Image (q2 + q1)); + Put_Line ("q * r = " & Image (q * r)); + Put_Line ("r * q = " & Image (r * q)); + Put_Line ("q1 * q2 = " & Image (q1 * q2)); + Put_Line ("q2 * q1 = " & Image (q2 * q1)); +end Test_Quaternion; diff --git a/Task/Quaternion-type/BBC-BASIC/quaternion-type.bbc b/Task/Quaternion-type/BBC-BASIC/quaternion-type.bbc new file mode 100644 index 0000000000..b9922b7801 --- /dev/null +++ b/Task/Quaternion-type/BBC-BASIC/quaternion-type.bbc @@ -0,0 +1,42 @@ + DIM q(3), q1(3), q2(3), t(3) + q() = 1, 2, 3, 4 + q1() = 2, 3, 4, 5 + q2() = 3, 4, 5, 6 + r = 7 + + PRINT "q = " FNq_show(q()) + PRINT "q1 = " FNq_show(q1()) + PRINT "q2 = " FNq_show(q2()) + PRINT "r = "; r + PRINT "norm(q) = "; FNq_norm(q()) + t() = q() : PROCq_neg(t()) : PRINT "neg(q) = " FNq_show(t()) + t() = q() : PROCq_conj(t()) : PRINT "conjugate(q) = " FNq_show(t()) + t() = q() : PROCq_addreal(t(),r) : PRINT "q + r = " FNq_show(t()) + t() = q1() : PROCq_add(t(),q2()) : PRINT "q1 + q2 = " FNq_show(t()) + t() = q2() : PROCq_add(t(),q1()) : PRINT "q2 + q1 = " FNq_show(t()) + t() = q() : PROCq_mulreal(t(),r) : PRINT "qr = " FNq_show(t()) + t() = q1() : PROCq_mul(t(),q2()) : PRINT "q1q2 = " FNq_show(t()) + t() = q2() : PROCq_mul(t(),q1()) : PRINT "q2q1 = " FNq_show(t()) + END + + DEF FNq_norm(q()) = MOD(q()) + + DEF PROCq_neg(q()) : q() *= -1 : ENDPROC + + DEF PROCq_conj(q()) : q() *= -1 : q(0) *= -1 : ENDPROC + + DEF PROCq_addreal(q(), r) : q(0) += r : ENDPROC + + DEF PROCq_add(q(), r()) : q() += r() : ENDPROC + + DEF PROCq_mulreal(q(), r) : q() *= r : ENDPROC + + DEF PROCq_mul(q(), r()) : LOCAL s() : DIM s(3,3) + s() = r(0), -r(1), -r(2), -r(3), r(1), r(0), r(3), -r(2), \ + \ r(2), -r(3), r(0), r(1), r(3), r(2), -r(1), r(0) + q() = s() . q() + ENDPROC + + DEF FNq_show(q()) : LOCAL i%, a$ : a$ = "(" + FOR i% = 0 TO 3 : a$ += STR$(q(i%)) + ", " : NEXT + = LEFT$(LEFT$(a$)) + ")" diff --git a/Task/Quaternion-type/C++/quaternion-type-1.cpp b/Task/Quaternion-type/C++/quaternion-type-1.cpp new file mode 100644 index 0000000000..05f40baaaa --- /dev/null +++ b/Task/Quaternion-type/C++/quaternion-type-1.cpp @@ -0,0 +1,116 @@ +#include +using namespace std; + +template +class Quaternion +{ +public: + T w, x, y, z; + + // Numerical constructor + Quaternion(const T &w, const T &x, const T &y, const T &z): w(w), x(x), y(y), z(z) {}; + Quaternion(const T &x, const T &y, const T &z): w(T()), x(x), y(y), z(z) {}; // For 3-rotations + Quaternion(const T &r): w(r), x(T()), y(T()), z(T()) {}; + Quaternion(): w(T()), x(T()), y(T()), z(T()) {}; + + // Copy constructor and assignment + Quaternion(const Quaternion &q): w(q.w), x(q.x), y(q.y), z(q.z) {}; + Quaternion& operator=(const Quaternion &q) { w=q.w; x=q.x; y=q.y; z=q.z; return *this; } + + // Unary operators + Quaternion operator-() const { return Quaternion(-w, -x, -y, -z); } + Quaternion operator~() const { return Quaternion(w, -x, -y, -z); } // Conjugate + + // Norm-squared. SQRT would have to be made generic to be used here + T normSquared() const { return w*w + x*x + y*y + z*z; } + + // In-place operators + Quaternion& operator+=(const T &r) + { w += r; return *this; } + Quaternion& operator+=(const Quaternion &q) + { w += q.w; x += q.x; y += q.y; z += q.z; return *this; } + + Quaternion& operator-=(const T &r) + { w -= r; return *this; } + Quaternion& operator-=(const Quaternion &q) + { w -= q.w; x -= q.x; y -= q.y; z -= q.z; return *this; } + + Quaternion& operator*=(const T &r) + { w *= r; x *= r; y *= r; z *= r; return *this; } + Quaternion& operator*=(const Quaternion &q) + { + T oldW(w), oldX(x), oldY(y), oldZ(z); + w = oldW*q.w - oldX*q.x - oldY*q.y - oldZ*q.z; + x = oldW*q.x + oldX*q.w + oldY*q.z - oldZ*q.y; + y = oldW*q.y + oldY*q.w + oldZ*q.x - oldX*q.z; + z = oldW*q.z + oldZ*q.w + oldX*q.y - oldY*q.x; + return *this; + } + + Quaternion& operator/=(const T &r) + { w /= r; x /= r; y /= r; z /= r; return *this; } + Quaternion& operator/=(const Quaternion &q) + { + T oldW(w), oldX(x), oldY(y), oldZ(z), n(q.normSquared()); + w = (oldW*q.w + oldX*q.x + oldY*q.y + oldZ*q.z) / n; + x = (oldX*q.w - oldW*q.x + oldY*q.z - oldZ*q.y) / n; + y = (oldY*q.w - oldW*q.y + oldZ*q.x - oldX*q.z) / n; + z = (oldZ*q.w - oldW*q.z + oldX*q.y - oldY*q.x) / n; + return *this; + } + + // Binary operators based on in-place operators + Quaternion operator+(const T &r) const { return Quaternion(*this) += r; } + Quaternion operator+(const Quaternion &q) const { return Quaternion(*this) += q; } + Quaternion operator-(const T &r) const { return Quaternion(*this) -= r; } + Quaternion operator-(const Quaternion &q) const { return Quaternion(*this) -= q; } + Quaternion operator*(const T &r) const { return Quaternion(*this) *= r; } + Quaternion operator*(const Quaternion &q) const { return Quaternion(*this) *= q; } + Quaternion operator/(const T &r) const { return Quaternion(*this) /= r; } + Quaternion operator/(const Quaternion &q) const { return Quaternion(*this) /= q; } + + // Comparison operators, as much as they make sense + bool operator==(const Quaternion &q) const + { return (w == q.w) && (x == q.x) && (y == q.y) && (z == q.z); } + bool operator!=(const Quaternion &q) const { return !operator==(q); } + + // The operators above allow quaternion op real. These allow real op quaternion. + // Uses the above where appropriate. + template friend Quaternion operator+(const T &r, const Quaternion &q); + template friend Quaternion operator-(const T &r, const Quaternion &q); + template friend Quaternion operator*(const T &r, const Quaternion &q); + template friend Quaternion operator/(const T &r, const Quaternion &q); + + // Allows cout << q + template friend ostream& operator<<(ostream &io, const Quaternion &q); +}; + +// Friend functions need to be outside the actual class definition +template +Quaternion operator+(const T &r, const Quaternion &q) + { return q+r; } + +template +Quaternion operator-(const T &r, const Quaternion &q) + { return Quaternion(r-q.w, q.x, q.y, q.z); } + +template +Quaternion operator*(const T &r, const Quaternion &q) + { return q*r; } + +template +Quaternion operator/(const T &r, const Quaternion &q) +{ + T n(q.normSquared()); + return Quaternion(r*q.w/n, -r*q.x/n, -r*q.y/n, -r*q.z/n); +} + +template +ostream& operator<<(ostream &io, const Quaternion &q) +{ + io << q.w; + (q.x < T()) ? (io << " - " << (-q.x) << "i") : (io << " + " << q.x << "i"); + (q.y < T()) ? (io << " - " << (-q.y) << "j") : (io << " + " << q.y << "j"); + (q.z < T()) ? (io << " - " << (-q.z) << "k") : (io << " + " << q.z << "k"); + return io; +} diff --git a/Task/Quaternion-type/C++/quaternion-type-2.cpp b/Task/Quaternion-type/C++/quaternion-type-2.cpp new file mode 100644 index 0000000000..92dd8db61b --- /dev/null +++ b/Task/Quaternion-type/C++/quaternion-type-2.cpp @@ -0,0 +1,40 @@ +int main() +{ + Quaternion<> q0(1, 2, 3, 4); + Quaternion<> q1(2, 3, 4, 5); + Quaternion<> q2(3, 4, 5, 6); + double r = 7; + + cout << "q0: " << q0 << endl; + cout << "q1: " << q1 << endl; + cout << "q2: " << q2 << endl; + cout << "r: " << r << endl; + cout << endl; + cout << "-q0: " << -q0 << endl; + cout << "~q0: " << ~q0 << endl; + cout << endl; + cout << "r * q0: " << r*q0 << endl; + cout << "r + q0: " << r+q0 << endl; + cout << "q0 / r: " << q0/r << endl; + cout << "q0 - r: " << q0-r << endl; + cout << endl; + cout << "q0 + q1: " << q0+q1 << endl; + cout << "q0 - q1: " << q0-q1 << endl; + cout << "q0 * q1: " << q0*q1 << endl; + cout << "q0 / q1: " << q0/q1 << endl; + cout << endl; + cout << "q0 * ~q0: " << q0*~q0 << endl; + cout << "q0 + q1*q2: " << q0+q1*q2 << endl; + cout << "(q0 + q1)*q2: " << (q0+q1)*q2 << endl; + cout << "q0*q1*q2: " << q0*q1*q2 << endl; + cout << "(q0*q1)*q2: " << (q0*q1)*q2 << endl; + cout << "q0*(q1*q2): " << q0*(q1*q2) << endl; + cout << endl; + cout << "||q0||: " << sqrt(q0.normSquared()) << endl; + cout << endl; + cout << "q0*q1 - q1*q0: " << (q0*q1 - q1*q0) << endl; + + // Other base types + Quaternion q5(2), q6(3); + cout << endl << q5*q6 << endl; +} diff --git a/Task/Quaternion-type/C-sharp/quaternion-type-1.cs b/Task/Quaternion-type/C-sharp/quaternion-type-1.cs new file mode 100644 index 0000000000..ddfb4adab5 --- /dev/null +++ b/Task/Quaternion-type/C-sharp/quaternion-type-1.cs @@ -0,0 +1,90 @@ +using System; + +struct Quaternion : IEquatable +{ + public readonly double A, B, C, D; + + public Quaternion(double a, double b, double c, double d) + { + this.A = a; + this.B = b; + this.C = c; + this.D = d; + } + + public double Norm() + { + return Math.Sqrt(A * A + B * B + C * C + D * D); + } + + public static Quaternion operator -(Quaternion q) + { + return new Quaternion(-q.A, -q.B, -q.C, -q.D); + } + + public Quaternion Conjugate() + { + return new Quaternion(A, -B, -C, -D); + } + + // implicit conversion takes care of real*quaternion and real+quaternion + public static implicit operator Quaternion(double d) + { + return new Quaternion(d, 0, 0, 0); + } + + public static Quaternion operator +(Quaternion q1, Quaternion q2) + { + return new Quaternion(q1.A + q2.A, q1.B + q2.B, q1.C + q2.C, q1.D + q2.D); + } + + public static Quaternion operator *(Quaternion q1, Quaternion q2) + { + return new Quaternion( + q1.A * q2.A - q1.B * q2.B - q1.C * q2.C - q1.D * q2.D, + q1.A * q2.B + q1.B * q2.A + q1.C * q2.D - q1.D * q2.C, + q1.A * q2.C - q1.B * q2.D + q1.C * q2.A + q1.D * q2.B, + q1.A * q2.D + q1.B * q2.C - q1.C * q2.B + q1.D * q2.A); + } + + public static bool operator ==(Quaternion q1, Quaternion q2) + { + return q1.A == q2.A && q1.B == q2.B && q1.C == q2.C && q1.D == q2.D; + } + + public static bool operator !=(Quaternion q1, Quaternion q2) + { + return !(q1 == q2); + } + + #region Object Members + + public override bool Equals(object obj) + { + if (obj is Quaternion) + return Equals((Quaternion)obj); + + return false; + } + + public override int GetHashCode() + { + return A.GetHashCode() ^ B.GetHashCode() ^ C.GetHashCode() ^ D.GetHashCode(); + } + + public override string ToString() + { + return string.Format("Q({0}, {1}, {2}, {3})", A, B, C, D); + } + + #endregion + + #region IEquatable Members + + public bool Equals(Quaternion other) + { + return other == this; + } + + #endregion +} diff --git a/Task/Quaternion-type/C-sharp/quaternion-type-2.cs b/Task/Quaternion-type/C-sharp/quaternion-type-2.cs new file mode 100644 index 0000000000..a8b778f198 --- /dev/null +++ b/Task/Quaternion-type/C-sharp/quaternion-type-2.cs @@ -0,0 +1,34 @@ +using System; + +static class Program +{ + static void Main(string[] args) + { + Quaternion q = new Quaternion(1, 2, 3, 4); + Quaternion q1 = new Quaternion(2, 3, 4, 5); + Quaternion q2 = new Quaternion(3, 4, 5, 6); + double r = 7; + + Console.WriteLine("q = {0}", q); + Console.WriteLine("q1 = {0}", q1); + Console.WriteLine("q2 = {0}", q2); + Console.WriteLine("r = {0}", r); + + Console.WriteLine("q.Norm() = {0}", q.Norm()); + Console.WriteLine("q1.Norm() = {0}", q1.Norm()); + Console.WriteLine("q2.Norm() = {0}", q2.Norm()); + + Console.WriteLine("-q = {0}", -q); + Console.WriteLine("q.Conjugate() = {0}", q.Conjugate()); + + Console.WriteLine("q + r = {0}", q + r); + Console.WriteLine("q1 + q2 = {0}", q1 + q2); + Console.WriteLine("q2 + q1 = {0}", q2 + q1); + + Console.WriteLine("q * r = {0}", q * r); + Console.WriteLine("q1 * q2 = {0}", q1 * q2); + Console.WriteLine("q2 * q1 = {0}", q2 * q1); + + Console.WriteLine("q1*q2 {0} q2*q1", (q1 * q2) == (q2 * q1) ? "==" : "!="); + } +} diff --git a/Task/Quaternion-type/C/quaternion-type-1.c b/Task/Quaternion-type/C/quaternion-type-1.c new file mode 100644 index 0000000000..687daa95d8 --- /dev/null +++ b/Task/Quaternion-type/C/quaternion-type-1.c @@ -0,0 +1,131 @@ +#include +#include +#include +#include + +typedef struct quaternion +{ + double q[4]; +} quaternion_t; + + +quaternion_t *quaternion_new(void) +{ + return malloc(sizeof(quaternion_t)); +} + +quaternion_t *quaternion_new_set(double q1, + double q2, + double q3, + double q4) +{ + quaternion_t *q = malloc(sizeof(quaternion_t)); + if (q != NULL) { + q->q[0] = q1; q->q[1] = q2; q->q[2] = q3; q->q[3] = q4; + } + return q; +} + + +void quaternion_copy(quaternion_t *r, quaternion_t *q) +{ + size_t i; + + if (r == NULL || q == NULL) return; + for(i = 0; i < 4; i++) r->q[i] = q->q[i]; +} + + +double quaternion_norm(quaternion_t *q) +{ + size_t i; + double r = 0.0; + + if (q == NULL) { + fprintf(stderr, "NULL quaternion in norm\n"); + return 0.0; + } + + for(i = 0; i < 4; i++) r += q->q[i] * q->q[i]; + return sqrt(r); +} + + +void quaternion_neg(quaternion_t *r, quaternion_t *q) +{ + size_t i; + + if (q == NULL || r == NULL) return; + for(i = 0; i < 4; i++) r->q[i] = -q->q[i]; +} + + +void quaternion_conj(quaternion_t *r, quaternion_t *q) +{ + size_t i; + + if (q == NULL || r == NULL) return; + r->q[0] = q->q[0]; + for(i = 1; i < 4; i++) r->q[i] = -q->q[i]; +} + + +void quaternion_add_d(quaternion_t *r, quaternion_t *q, double d) +{ + if (q == NULL || r == NULL) return; + quaternion_copy(r, q); + r->q[0] += d; +} + + +void quaternion_add(quaternion_t *r, quaternion_t *a, quaternion_t *b) +{ + size_t i; + + if (r == NULL || a == NULL || b == NULL) return; + for(i = 0; i < 4; i++) r->q[i] = a->q[i] + b->q[i]; +} + + +void quaternion_mul_d(quaternion_t *r, quaternion_t *q, double d) +{ + size_t i; + + if (r == NULL || q == NULL) return; + for(i = 0; i < 4; i++) r->q[i] = q->q[i] * d; +} + +bool quaternion_equal(quaternion_t *a, quaternion_t *b) +{ + size_t i; + + for(i = 0; i < 4; i++) if (a->q[i] != b->q[i]) return false; + return true; +} + + +#define A(N) (a->q[(N)]) +#define B(N) (b->q[(N)]) +#define R(N) (r->q[(N)]) +void quaternion_mul(quaternion_t *r, quaternion_t *a, quaternion_t *b) +{ + size_t i; + double ri = 0.0; + + if (r == NULL || a == NULL || b == NULL) return; + R(0) = A(0)*B(0) - A(1)*B(1) - A(2)*B(2) - A(3)*B(3); + R(1) = A(0)*B(1) + A(1)*B(0) + A(2)*B(3) - A(3)*B(2); + R(2) = A(0)*B(2) - A(1)*B(3) + A(2)*B(0) + A(3)*B(1); + R(3) = A(0)*B(3) + A(1)*B(2) - A(2)*B(1) + A(3)*B(0); +} +#undef A +#undef B +#undef R + + +void quaternion_print(quaternion_t *q) +{ + if (q == NULL) return; + printf("(%lf, %lf, %lf, %lf)\n", + q->q[0], q->q[1], q->q[2], q->q[3]); +} diff --git a/Task/Quaternion-type/C/quaternion-type-2.c b/Task/Quaternion-type/C/quaternion-type-2.c new file mode 100644 index 0000000000..a836476150 --- /dev/null +++ b/Task/Quaternion-type/C/quaternion-type-2.c @@ -0,0 +1,58 @@ +int main() +{ + size_t i; + double d = 7.0; + quaternion_t *q[3]; + quaternion_t *r = quaternion_new(); + + quaternion_t *qd = quaternion_new_set(7.0, 0.0, 0.0, 0.0); + q[0] = quaternion_new_set(1.0, 2.0, 3.0, 4.0); + q[1] = quaternion_new_set(2.0, 3.0, 4.0, 5.0); + q[2] = quaternion_new_set(3.0, 4.0, 5.0, 6.0); + + printf("r = %lf\n", d); + + for(i = 0; i < 3; i++) { + printf("q[%u] = ", i); + quaternion_print(q[i]); + printf("abs q[%u] = %lf\n", i, quaternion_norm(q[i])); + } + + printf("-q[0] = "); + quaternion_neg(r, q[0]); + quaternion_print(r); + + printf("conj q[0] = "); + quaternion_conj(r, q[0]); + quaternion_print(r); + + printf("q[1] + q[2] = "); + quaternion_add(r, q[1], q[2]); + quaternion_print(r); + + printf("q[2] + q[1] = "); + quaternion_add(r, q[2], q[1]); + quaternion_print(r); + + + printf("q[0] * r = "); + quaternion_mul_d(r, q[0], d); + quaternion_print(r); + + printf("q[0] * (r, 0, 0, 0) = "); + quaternion_mul(r, q[0], qd); + quaternion_print(r); + + + printf("q[1] * q[2] = "); + quaternion_mul(r, q[1], q[2]); + quaternion_print(r); + + printf("q[2] * q[1] = "); + quaternion_mul(r, q[2], q[1]); + quaternion_print(r); + + + free(q[0]); free(q[1]); free(q[2]); free(r); + return EXIT_SUCCESS; +} diff --git a/Task/Quaternion-type/D/quaternion-type.d b/Task/Quaternion-type/D/quaternion-type.d new file mode 100644 index 0000000000..c679418f64 --- /dev/null +++ b/Task/Quaternion-type/D/quaternion-type.d @@ -0,0 +1,216 @@ +import std.math, std.numeric, std.traits, std.conv, std.complex; + + +struct Quat(T) if (isFloatingPoint!T) { + alias Complex!T CT; + + union { + struct { T re, i, j, k; } // Default init to NaN + struct { CT x, y; } + struct { T[4] vector; } + } + + string toString() const /*pure nothrow*/ { + return text(vector); + } + + @property T norm2() const pure nothrow { /// Norm squared + return re ^^ 2 + i ^^ 2 + j ^^ 2 + k ^^ 2; + } + + @property T abs() const pure nothrow { /// Norm + return sqrt(norm2); + } + + @property T arg() const pure nothrow { /// Theta + return acos(re / abs); // this may be incorrect... + } + + @property Quat!T conj() const pure nothrow { /// Conjugate + return Quat!T(re, -i, -j, -k); + } + + @property Quat!T recip() const pure nothrow { /// Reciprocal + return Quat!T(re / norm2, -i / norm2, -j / norm2, -k / norm2); + } + + @property Quat!T pureim() const pure nothrow { /// Pure imagery + return Quat!T(0, i, j, k); + } + + @property Quat!T versor() const pure nothrow { /// Unit versor + return this / abs; + } + + /// Unit versor of imagery part + @property Quat!T iversor() const pure nothrow { + return pureim / pureim.abs; + } + + /// Assignment + Quat!T opAssign(U : T)(Quat!U z) pure nothrow { + x = z.x; y = z.y; + return this; + } + + Quat!T opAssign(U : T)(Complex!U c) pure nothrow { + x = c; y = 0; + return this; + } + + Quat!T opAssign(U : T)(U r) pure nothrow if (isNumeric!U) { + re = r; i = 0; y = 0; + return this; + } + + /// Test for equal, not ordered so no opCmp + bool opEquals(U : T)(Quat!U z) const pure nothrow { + return re == z.re && i == z.i && j == z.j && k == z.k; + } + + bool opEquals(U : T)(Complex!U c) const pure nothrow { + return re == c.re && i == c.im && j == 0 && k == 0; + } + + bool opEquals(U : T)(U r) const pure nothrow if (isNumeric!U) { + return re == r && i == 0 && j == 0 && k == 0; + } + + /// Unary op + Quat!T opUnary(string op)() const pure nothrow if (op == "+") { + return this; + } + + Quat!T opUnary(string op)() const pure nothrow if (op == "-") { + return Quat!T(-re, -i, -j, -k); + } + + /// Binary op, Quaternion on left of op + Quat!(CommonType!(T,U)) opBinary(string op, U)(Quat!U z) + const pure nothrow { + alias typeof(return) C; + + static if (op == "+" ) { + return C(re + z.re, i + z.i, j + z.j, k + z.k); + } else static if (op == "-") { + return C(re - z.re, i - z.i, j - z.j, k - z.k); + } else static if (op == "*") { + return C(re * z.re - i * z.i - j * z.j - k * z.k, + re * z.i + i * z.re + j * z.k - k * z.j, + re * z.j - i * z.k + j * z.re + k * z.i, + re * z.k + i * z.j - j * z.i + k * z.re); + } else static if (op == "/") { + return this * z.recip; + } + } + + /// Extend complex to quaternion + Quat!(CommonType!(T,U)) opBinary(string op, U)(Complex!U c) + const pure nothrow { + return opBinary!op(typeof(return)(c.re, c.im, 0, 0)); + } + + /// For scalar + Quat!(CommonType!(T,U)) opBinary(string op, U)(U r) + const pure nothrow if (isNumeric!U) { + alias typeof(return) C; + + static if (op == "+" ) { + return C(re + r, i, j, k); + } else static if (op == "-") { + return C(re - r, i, j, k); + } else static if (op == "*") { + return C(re * r, i * r, j * r, k * r); + } else static if (op == "/") { + return C(re / r, i / r, j / r, k / r); + } else static if (op == "^^") { + return pow(r); + } + } + + /// Power function + Quat!(CommonType!(T,U)) pow(U)(U r) + const pure nothrow if (isNumeric!U) { + return (abs^^r) * exp(r * iversor * arg); + } + + /// Handle binary op if Quaternion on right of op and left is + /// not quaternion. + Quat!(CommonType!(T,U)) opBinaryRight(string op, U)(Complex!U c) + const pure nothrow { + alias typeof(return) C; + auto w = C(c.re, c.im, 0, 0); + return w.opBinary!(op)(this); + } + + Quat!(CommonType!(T,U)) opBinaryRight(string op, U)(U r) + const pure nothrow if (isNumeric!U) { + alias typeof(return) C; + + static if (op == "+" || op == "*") { + return opBinary!op(r); + } else static if (op == "-") { + return C(r - re , -i, -j, -k); + } else static if (op == "/") { + auto w = C(re, i, j, k); + return w.recip * r; + } + } +} + + +HT exp(HT)(HT z) pure nothrow if (is(HT T == Quat!T)) { + immutable inorm = z.pureim.abs; + return std.math.exp(z.re) * (cos(inorm) + z.iversor * sin(inorm)); +} + +HT log(HT)(HT z) pure nothrow if (is(HT T == Quat!T)) { + return std.math.log(z.abs) + z.iversor * acos(z.re / z.abs); +} + + +void main() { // Demo code + import std.stdio; + alias Quat!real QR; + immutable real r = 7; + + immutable QR q = QR(2, 3, 4, 5), + q1 = QR(2, 3, 4, 5), + q2 = QR(3, 4, 5, 6); + + writeln("1. q - norm: ", q.abs); + writeln("2. q - negative: ", -q); + writeln("3. q - conjugate: ", q.conj); + writeln("4. r + q: ", r + q); + writeln(" q + r: ", q + r); + writeln("5. q1 + q2: ", q1 + q2); + writeln("6. r * q: ", r * q); + writeln(" q * r: ", q * r); + writeln("7. q1 * q2: ", q1 * q2); + writeln(" q2 * q1: ", q2 * q1); + writeln("8. q1 * q2 != q2 * Q1 ? ", q1 * q2 != q2 * q1); + + immutable QR i = QR(0, 1, 0, 0), + j = QR(0, 0, 1, 0), + k = QR(0, 0, 0, 1); + writeln("9.1 i * i: ", i * i); + writeln(" J * j: ", j * j); + writeln(" k * k: ", k * k); + writeln(" i * j * k: ", i * j * k); + writeln("9.2 q1 / q2: ", q1 / q2); + writeln("9.3 q1 / q2 * q2: ", q1 / q2 * q2); + writeln(" q2 * q1 / q2: ", q2 * q1 / q2); + writeln("9.4 exp(pi * i): ", exp(PI * i)); + writeln(" exp(pi * j): ", exp(PI * j)); + writeln(" exp(pi * k): ", exp(PI * k)); + writeln(" exp(q): ", exp(q)); + writeln(" log(q): ", log(q)); + writeln(" exp(log(q)): ", exp(log(q))); + writeln(" log(exp(q)): ", log(exp(q))); + immutable s = log(exp(q)); + writeln("9.5 let s = log(exp(q)): ", s); + writeln(" exp(s): ", exp(s)); + writeln(" log(s): ", log(s)); + writeln(" exp(log(s)): ", exp(log(s))); + writeln(" log(exp(s)): ", log(exp(s))); +} diff --git a/Task/Quaternion-type/Delphi/quaternion-type-1.delphi b/Task/Quaternion-type/Delphi/quaternion-type-1.delphi new file mode 100644 index 0000000000..71a74694f2 --- /dev/null +++ b/Task/Quaternion-type/Delphi/quaternion-type-1.delphi @@ -0,0 +1,129 @@ +unit Quaternions; + +interface + +type + + TQuaternion = record + A, B, C, D: double; + + function Init (aA, aB, aC, aD : double): TQuaternion; + function Norm : double; + function Conjugate : TQuaternion; + function ToString : string; + + class operator Negative (Left : TQuaternion): TQuaternion; + class operator Positive (Left : TQuaternion): TQuaternion; + class operator Add (Left, Right : TQuaternion): TQuaternion; + class operator Add (Left : TQuaternion; Right : double): TQuaternion; overload; + class operator Add (Left : double; Right : TQuaternion): TQuaternion; overload; + class operator Subtract (Left, Right : TQuaternion): TQuaternion; + class operator Multiply (Left, Right : TQuaternion): TQuaternion; + class operator Multiply (Left : TQuaternion; Right : double): TQuaternion; overload; + class operator Multiply (Left : double; Right : TQuaternion): TQuaternion; overload; + end; + +implementation + +uses + SysUtils; + +{ TQuaternion } + +function TQuaternion.Init(aA, aB, aC, aD: double): TQuaternion; +begin + A := aA; + B := aB; + C := aC; + D := aD; + + result := Self; +end; + +function TQuaternion.Norm: double; +begin + result := sqrt(sqr(A) + sqr(B) + sqr(C) + sqr(D)); +end; + +function TQuaternion.Conjugate: TQuaternion; +begin + result.B := -B; + result.C := -C; + result.D := -D; +end; + +class operator TQuaternion.Negative(Left: TQuaternion): TQuaternion; +begin + result.A := -Left.A; + result.B := -Left.B; + result.C := -Left.C; + result.D := -Left.D; +end; + +class operator TQuaternion.Positive(Left: TQuaternion): TQuaternion; +begin + result := Left; +end; + +class operator TQuaternion.Add(Left, Right: TQuaternion): TQuaternion; +begin + result.A := Left.A + Right.A; + result.B := Left.B + Right.B; + result.C := Left.C + Right.C; + result.D := Left.D + Right.D; +end; + +class operator TQuaternion.Add(Left: TQuaternion; Right: double): TQuaternion; +begin + result.A := Left.A + Right; + result.B := Left.B; + result.C := Left.C; + result.D := Left.D; +end; + +class operator TQuaternion.Add(Left: double; Right: TQuaternion): TQuaternion; +begin + result.A := Left + Right.A; + result.B := Right.B; + result.C := Right.C; + result.D := Right.D; +end; + +class operator TQuaternion.Subtract(Left, Right: TQuaternion): TQuaternion; +begin + result.A := Left.A - Right.A; + result.B := Left.B - Right.B; + result.C := Left.C - Right.C; + result.D := Left.D - Right.D; +end; + +class operator TQuaternion.Multiply(Left, Right: TQuaternion): TQuaternion; +begin + result.A := Left.A * Right.A - Left.B * Right.B - Left.C * Right.C - Left.D * Right.D; + result.B := Left.A * Right.B + Left.B * Right.A + Left.C * Right.D - Left.D * Right.C; + result.C := Left.A * Right.C - Left.B * Right.D + Left.C * Right.A + Left.D * Right.B; + result.D := Left.A * Right.D + Left.B * Right.C - Left.C * Right.B + Left.D * Right.A; +end; + +class operator TQuaternion.Multiply(Left: double; Right: TQuaternion): TQuaternion; +begin + result.A := Left * Right.A; + result.B := Left * Right.B; + result.C := Left * Right.C; + result.D := Left * Right.D; +end; + +class operator TQuaternion.Multiply(Left: TQuaternion; Right: double): TQuaternion; +begin + result.A := Left.A * Right; + result.B := Left.B * Right; + result.C := Left.C * Right; + result.D := Left.D * Right; +end; + +function TQuaternion.ToString: string; +begin + result := Format('%f + %fi + %fj + %fk', [A, B, C, D]); +end; + +end. diff --git a/Task/Quaternion-type/Delphi/quaternion-type-2.delphi b/Task/Quaternion-type/Delphi/quaternion-type-2.delphi new file mode 100644 index 0000000000..eed3278a91 --- /dev/null +++ b/Task/Quaternion-type/Delphi/quaternion-type-2.delphi @@ -0,0 +1,32 @@ +program QuaternionTest; + +{$APPTYPE CONSOLE} + +uses + Quaternions in 'Quaternions.pas'; + +var + r : double; + q, q1, q2 : TQuaternion; +begin + r := 7; + q := q .Init(1, 2, 3, 4); + q1 := q1.Init(2, 3, 4, 5); + q2 := q2.Init(3, 4, 5, 6); + + writeln('q = ', q.ToString); + writeln('q1 = ', q1.ToString); + writeln('q2 = ', q2.ToString); + writeln('r = ', r); + writeln('Norm(q ) = ', q.Norm); + writeln('Norm(q1) = ', q1.Norm); + writeln('Norm(q2) = ', q2.Norm); + writeln('-q = ', (-q).ToString); + writeln('Conjugate q = ', q.Conjugate.ToString); + writeln('q1 + q2 = ', (q1 + q2).ToString); + writeln('q2 + q1 = ', (q2 + q1).ToString); + writeln('q * r = ', (q * r).ToString); + writeln('r * q = ', (r * q).ToString); + writeln('q1 * q2 = ', (q1 * q2).ToString); + writeln('q2 * q1 = ', (q2 * q1).ToString); +end. diff --git a/Task/Quaternion-type/E/quaternion-type-1.e b/Task/Quaternion-type/E/quaternion-type-1.e new file mode 100644 index 0000000000..44c87465c1 --- /dev/null +++ b/Task/Quaternion-type/E/quaternion-type-1.e @@ -0,0 +1,61 @@ +interface Quaternion guards QS {} +def makeQuaternion(a, b, c, d) { + return def quaternion implements QS { + + to __printOn(out) { + out.print("(", a, " + ", b, "i + ") + out.print(c, "j + ", d, "k)") + } + + # Task requirement 1 + to norm() { + return (a**2 + b**2 + c**2 + d**2).sqrt() + } + + # Task requirement 2 + to negate() { + return makeQuaternion(-a, -b, -c, -d) + } + + # Task requirement 3 + to conjugate() { + return makeQuaternion(a, -b, -c, -d) + } + + # Task requirement 4, 5 + # This implements q + r; r + q is deliberately prohibited by E + to add(other :any[Quaternion, int, float64]) { + switch (other) { + match q :Quaternion { + return makeQuaternion( + a+q.a(), b+q.b(), c+q.c(), d+q.d()) + } + match real { + return makeQuaternion(a+real, b, c, d) + } + } + } + + # Task requirement 6, 7 + # This implements q * r; r * q is deliberately prohibited by E + to multiply(other :any[Quaternion, int, float64]) { + switch (other) { + match q :Quaternion { + return makeQuaternion( + a*q.a() - b*q.b() - c*q.c() - d*q.d(), + a*q.b() + b*q.a() + c*q.d() - d*q.c(), + a*q.c() - b*q.d() + c*q.a() + d*q.b(), + a*q.d() + b*q.c() - c*q.b() + d*q.a()) + } + match real { + return makeQuaternion(real*a, real*b, real*c, real*d) + } + } + } + + to a() { return a } + to b() { return b } + to c() { return c } + to d() { return d } + } +} diff --git a/Task/Quaternion-type/E/quaternion-type-2.e b/Task/Quaternion-type/E/quaternion-type-2.e new file mode 100644 index 0000000000..2dfcf1d928 --- /dev/null +++ b/Task/Quaternion-type/E/quaternion-type-2.e @@ -0,0 +1,17 @@ +? def q1 := makeQuaternion(2,3,4,5) +# value: (2 + 3i + 4j + 5k) + +? def q2 := makeQuaternion(3,4,5,6) +# value: (3 + 4i + 5j + 6k) + +? q1+q2 +# value: (5 + 7i + 9j + 11k) + +? q1*q2 +# value: (-56 + 16i + 24j + 26k) + +? q2*q1 +# value: (-56 + 18i + 20j + 28k) + +? q1+(-2) +# value: (0 + 3i + 4j + 5k) diff --git a/Task/Quaternion-type/Euphoria/quaternion-type.euphoria b/Task/Quaternion-type/Euphoria/quaternion-type.euphoria new file mode 100644 index 0000000000..e2e19003ea --- /dev/null +++ b/Task/Quaternion-type/Euphoria/quaternion-type.euphoria @@ -0,0 +1,48 @@ +function norm(sequence q) + return sqrt(power(q[1],2)+power(q[2],2)+power(q[3],2)+power(q[4],2)) +end function + +function conj(sequence q) + q[2..4] = -q[2..4] + return q +end function + +function add(object q1, object q2) + if atom(q1) != atom(q2) then + if atom(q1) then + q1 = {q1,0,0,0} + else + q2 = {q2,0,0,0} + end if + end if + return q1+q2 +end function + +function mul(object q1, object q2) + if sequence(q1) and sequence(q2) then + return { q1[1]*q2[1] - q1[2]*q2[2] - q1[3]*q2[3] - q1[4]*q2[4], + q1[1]*q2[2] + q1[2]*q2[1] + q1[3]*q2[4] - q1[4]*q2[3], + q1[1]*q2[3] - q1[2]*q2[4] + q1[3]*q2[1] + q1[4]*q2[2], + q1[1]*q2[4] + q1[2]*q2[3] - q1[3]*q2[2] + q1[4]*q2[1] } + else + return q1*q2 + end if +end function + +function quats(sequence q) + return sprintf("%g + %gi + %gj + %gk",q) +end function + +constant + q = {1, 2, 3, 4}, + q1 = {2, 3, 4, 5}, + q2 = {5, 6, 7, 8}, + r = 7 + +printf(1, "norm(q) = %g\n", norm(q)) +printf(1, "-q = %s\n", {quats(-q)}) +printf(1, "conj(q) = %s\n", {quats(conj(q))}) +printf(1, "q + r = %s\n", {quats(add(q,r))}) +printf(1, "q1 + q2 = %s\n", {quats(add(q1,q2))}) +printf(1, "q1 * q2 = %s\n", {quats(mul(q1,q2))}) +printf(1, "q2 * q1 = %s\n", {quats(mul(q2,q1))}) diff --git a/Task/Quaternion-type/Forth/quaternion-type.fth b/Task/Quaternion-type/Forth/quaternion-type.fth new file mode 100644 index 0000000000..98f79e4b4c --- /dev/null +++ b/Task/Quaternion-type/Forth/quaternion-type.fth @@ -0,0 +1,77 @@ +: quaternions 4 * floats ; + +: qvariable create 1 quaternions allot ; + +: q! ( a b c d q -- ) + dup 3 floats + f! dup 2 floats + f! dup float+ f! f! ; + +: qcopy ( src dest -- ) 1 quaternions move ; + +: qnorm ( q -- f ) + 0e 4 0 do dup f@ fdup f* f+ float+ loop drop fsqrt ; + +: qf* ( q f -- ) + 4 0 do dup f@ fover f* dup f! float+ loop fdrop drop ; + +: qnegate ( q -- ) -1e qf* ; + +: qconj ( q -- ) + float+ 3 0 do dup f@ fnegate dup f! float+ loop drop ; + +: qf+ ( q f -- ) dup f@ f+ f! ; + +: q+ ( q1 q2 -- ) + 4 0 do over f@ dup f@ f+ dup f! float+ swap float+ swap loop 2drop ; + +\ access +: q.a f@ ; +: q.b float+ f@ ; +: q.c 2 floats + f@ ; +: q.d 3 floats + f@ ; + +: q* ( dest q1 q2 -- ) + over q.a dup q.d f* over q.b dup q.c f* f+ over q.c dup q.b f* f- over q.d dup q.a f* f+ + over q.a dup q.c f* over q.b dup q.d f* f- over q.c dup q.a f* f+ over q.d dup q.b f* f+ + over q.a dup q.b f* over q.b dup q.a f* f+ over q.c dup q.d f* f+ over q.d dup q.c f* f- + over q.a dup q.a f* over q.b dup q.b f* f- over q.c dup q.c f* f- over q.d dup q.d f* f- + 2drop 4 0 do dup f! float+ loop drop ; + +: q= ( q1 q2 -- ? ) + 4 0 do + over f@ dup f@ f<> if 2drop false unloop exit then + float+ swap float+ + loop + 2drop true ; + +\ testing + +: q. ( q -- ) + [char] ( emit space + 4 0 do dup f@ f. float+ loop drop + [char] ) emit space ; + +qvariable q 1e 2e 3e 4e q q! +qvariable q1 2e 3e 4e 5e q1 q! +create q2 3e f, 4e f, 5e f, 6e f, \ by hand + +qvariable tmp +qvariable m1 +qvariable m2 + +q qnorm f. \ 5.47722557505166 +q tmp qcopy tmp qnegate tmp q. \ ( -1. -2. -3. -4. ) +q tmp qcopy tmp qconj tmp q. \ ( 1. -2. -3. -4. ) + +q m1 qcopy m1 7e qf+ m1 q. \ ( 8. 2. 3. 4. ) +q m2 qcopy 7e m2 qf+ m2 q. \ ( 8. 2. 3. 4. ) +m1 m2 q= . \ -1 (true) + +q2 tmp qcopy q1 tmp q+ tmp q. \ ( 5. 7. 9. 11. ) + +q m1 qcopy m1 7e qf* m1 q. \ ( 7. 14. 21. 28. ) +q m2 qcopy 7e m2 qf* m2 q. \ ( 7. 14. 21. 28. ) +m1 m2 q= . \ -1 (true) + +m1 q1 q2 q* m1 q. \ ( -56. 16. 24. 26. ) +m2 q2 q1 q* m2 q. \ ( -56. 18. 20. 28. ) +m1 m2 q= . \ 0 (false) diff --git a/Task/Quaternion-type/Fortran/quaternion-type.f b/Task/Quaternion-type/Fortran/quaternion-type.f new file mode 100644 index 0000000000..1678539ac9 --- /dev/null +++ b/Task/Quaternion-type/Fortran/quaternion-type.f @@ -0,0 +1,161 @@ +module Q_mod + implicit none + + type quaternion + real :: a, b, c, d + end type + + public :: norm, neg, conj + public :: operator (+) + public :: operator (*) + + private :: q_plus_q, q_plus_r, r_plus_q, & + q_mult_q, q_mult_r, r_mult_q, & + norm_q, neg_q, conj_q + + interface norm + module procedure norm_q + end interface + + interface neg + module procedure neg_q + end interface + + interface conj + module procedure conj_q + end interface + + interface operator (+) + module procedure q_plus_q, q_plus_r, r_plus_q + end interface + + interface operator (*) + module procedure q_mult_q, q_mult_r, r_mult_q + end interface + +contains + +function norm_q(x) result(res) + real :: res + type (quaternion), intent (in) :: x + + res = sqrt(x%a*x%a + x%b*x%b + x%c*x%c + x%d*x%d) + +end function norm_q + +function neg_q(x) result(res) + type (quaternion) :: res + type (quaternion), intent (in) :: x + + res%a = -x%a + res%b = -x%b + res%c = -x%c + res%d = -x%d + +end function neg_q + +function conj_q(x) result(res) + type (quaternion) :: res + type (quaternion), intent (in) :: x + + res%a = x%a + res%b = -x%b + res%c = -x%c + res%d = -x%d + +end function conj_q + +function q_plus_q(x, y) result (res) + type (quaternion) :: res + type (quaternion), intent (in) :: x, y + + res%a = x%a + y%a + res%b = x%b + y%b + res%c = x%c + y%c + res%d = x%d + y%d + +end function q_plus_q + +function q_plus_r(x, r) result (res) + type (quaternion) :: res + type (quaternion), intent (in) :: x + real, intent(in) :: r + + res = x + res%a = x%a + r + +end function q_plus_r + +function r_plus_q(r, x) result (res) + type (quaternion) :: res + type (quaternion), intent (in) :: x + real, intent(in) :: r + + res = x + res%a = x%a + r + +end function r_plus_q + +function q_mult_q(x, y) result (res) + type (quaternion) :: res + type (quaternion), intent (in) :: x, y + + res%a = x%a*y%a - x%b*y%b - x%c*y%c - x%d*y%d + res%b = x%a*y%b + x%b*y%a + x%c*y%d - x%d*y%c + res%c = x%a*y%c - x%b*y%d + x%c*y%a + x%d*y%b + res%d = x%a*y%d + x%b*y%c - x%c*y%b + x%d*y%a + +end function q_mult_q + +function q_mult_r(x, r) result (res) + type (quaternion) :: res + type (quaternion), intent (in) :: x + real, intent(in) :: r + + res%a = x%a*r + res%b = x%b*r + res%c = x%c*r + res%d = x%d*r + +end function q_mult_r + +function r_mult_q(r, x) result (res) + type (quaternion) :: res + type (quaternion), intent (in) :: x + real, intent(in) :: r + + res%a = x%a*r + res%b = x%b*r + res%c = x%c*r + res%d = x%d*r + +end function r_mult_q +end module Q_mod + +program Quaternions + use Q_mod + implicit none + + real :: r = 7.0 + type(quaternion) :: q, q1, q2 + + q = quaternion(1, 2, 3, 4) + q1 = quaternion(2, 3, 4, 5) + q2 = quaternion(3, 4, 5, 6) + + write(*, "(a, 4f8.3)") " q = ", q + write(*, "(a, 4f8.3)") " q1 = ", q1 + write(*, "(a, 4f8.3)") " q2 = ", q2 + write(*, "(a, f8.3)") " r = ", r + write(*, "(a, f8.3)") " Norm of q = ", norm(q) + write(*, "(a, 4f8.3)") " Negative of q = ", neg(q) + write(*, "(a, 4f8.3)") "Conjugate of q = ", conj(q) + write(*, "(a, 4f8.3)") " q + r = ", q + r + write(*, "(a, 4f8.3)") " r + q = ", r + q + write(*, "(a, 4f8.3)") " q1 + q2 = ", q1 + q2 + write(*, "(a, 4f8.3)") " q * r = ", q * r + write(*, "(a, 4f8.3)") " r * q = ", r * q + write(*, "(a, 4f8.3)") " q1 * q2 = ", q1 * q2 + write(*, "(a, 4f8.3)") " q2 * q1 = ", q2 * q1 + +end program diff --git a/Task/Quaternion-type/GAP/quaternion-type.gap b/Task/Quaternion-type/GAP/quaternion-type.gap new file mode 100644 index 0000000000..2cad375014 --- /dev/null +++ b/Task/Quaternion-type/GAP/quaternion-type.gap @@ -0,0 +1,39 @@ +# GAP has built-in support for quaternions + +A := QuaternionAlgebra(Rationals); +# + +b := BasisVectors(Basis(A)); +# [ e, i, j, k ] + +q := [1, 2, 3, 4]*b; +# e+(2)*i+(3)*j+(4)*k + +# Computing norm may be difficult, since the result would be in a quadratic field (Sqrt exists in GAP, is quite unusual, see ?E in GAP, and the following example +Sqrt(5/3); +# 1/3*E(60)^7+1/3*E(60)^11-1/3*E(60)^19-1/3*E(60)^23-1/3*E(60)^31+1/3*E(60)^43-1/3*E(60)^47+1/3*E(60)^59 + +q1 := [2, 3, 4, 5]*b; +# (2)*e+(3)*i+(4)*j+(5)*k + +q2 := [3, 4, 5, 6]*b; +# (3)*e+(4)*i+(5)*j+(6)*k + +q1*q2 - q2*q1; +# (-2)*i+(4)*j+(-2)*k + +# Can't add directly to a rational, one must make a quaternion of it +r:=5/3*b[1]; +# (5/3)*e +r + q; +# (8/3)*e+(2)*i+(3)*j+(4)*k + +# For multiplication, no problem (we are in an algebra over rationals !) +r * q; +# (5/3)*e+(10/3)*i+(5)*j+(20/3)*k +5/3 * q; +# (5/3)*e+(10/3)*i+(5)*j+(20/3)*k + +# Negative +-q; +(-1)*e+(-2)*i+(-3)*j+(-4)*k diff --git a/Task/Quaternion-type/Go/quaternion-type.go b/Task/Quaternion-type/Go/quaternion-type.go new file mode 100644 index 0000000000..abb904adca --- /dev/null +++ b/Task/Quaternion-type/Go/quaternion-type.go @@ -0,0 +1,79 @@ +package main + +import ( + "fmt" + "math" +) + +type qtn struct { + r, i, j, k float64 +} + +var ( + q = &qtn{1, 2, 3, 4} + q1 = &qtn{2, 3, 4, 5} + q2 = &qtn{3, 4, 5, 6} + + r float64 = 7 +) + +func main() { + fmt.Println("Inputs") + fmt.Println("q:", q) + fmt.Println("q1:", q1) + fmt.Println("q2:", q2) + fmt.Println("r:", r) + + var qr qtn + fmt.Println("\nFunctions") + fmt.Println("q.norm():", q.norm()) + fmt.Println("neg(q):", qr.neg(q)) + fmt.Println("conj(q):", qr.conj(q)) + fmt.Println("addF(q, r):", qr.addF(q, r)) + fmt.Println("addQ(q1, q2):", qr.addQ(q1, q2)) + fmt.Println("mulF(q, r):", qr.mulF(q, r)) + fmt.Println("mulQ(q1, q2):", qr.mulQ(q1, q2)) + fmt.Println("mulQ(q2, q1):", qr.mulQ(q2, q1)) +} + +func (q *qtn) String() string { + return fmt.Sprintf("(%g, %g, %g, %g)", q.r, q.i, q.j, q.k) +} + +func (q *qtn) norm() float64 { + return math.Sqrt(q.r*q.r + q.i*q.i + q.j*q.j + q.k*q.k) +} + +func (z *qtn) neg(q *qtn) *qtn { + z.r, z.i, z.j, z.k = -q.r, -q.i, -q.j, -q.k + return z +} + +func (z *qtn) conj(q *qtn) *qtn { + z.r, z.i, z.j, z.k = q.r, -q.i, -q.j, -q.k + return z +} + +func (z *qtn) addF(q *qtn, r float64) *qtn { + z.r, z.i, z.j, z.k = q.r+r, q.i, q.j, q.k + return z +} + +func (z *qtn) addQ(q1, q2 *qtn) *qtn { + z.r, z.i, z.j, z.k = q1.r+q2.r, q1.i+q2.i, q1.j+q2.j, q1.k+q2.k + return z +} + +func (z *qtn) mulF(q *qtn, r float64) *qtn { + z.r, z.i, z.j, z.k = q.r*r, q.i*r, q.j*r, q.k*r + return z +} + +func (z *qtn) mulQ(q1, q2 *qtn) *qtn { + z.r, z.i, z.j, z.k = + q1.r*q2.r-q1.i*q2.i-q1.j*q2.j-q1.k*q2.k, + q1.r*q2.i+q1.i*q2.r+q1.j*q2.k-q1.k*q2.j, + q1.r*q2.j-q1.i*q2.k+q1.j*q2.r+q1.k*q2.i, + q1.r*q2.k+q1.i*q2.j-q1.j*q2.i+q1.k*q2.r + return z +} diff --git a/Task/Quaternion-type/Haskell/quaternion-type-1.hs b/Task/Quaternion-type/Haskell/quaternion-type-1.hs new file mode 100644 index 0000000000..6d1623e540 --- /dev/null +++ b/Task/Quaternion-type/Haskell/quaternion-type-1.hs @@ -0,0 +1,35 @@ +import Control.Monad +import Control.Arrow +import Data.List + +data Quaternion = Q Double Double Double Double + deriving (Show, Ord, Eq) + +realQ :: Quaternion -> Double +realQ (Q r _ _ _) = r + +imagQ :: Quaternion -> [Double] +imagQ (Q _ i j k) = [i, j, k] + +quaternionFromScalar s = Q s 0 0 0 + +listFromQ (Q a b c d) = [a,b,c,d] +quaternionFromList [a, b, c, d] = Q a b c d + +addQ, subQ, mulQ :: Quaternion -> Quaternion -> Quaternion +addQ (Q a b c d) (Q p q r s) = Q (a+p) (b+q) (c+r) (d+s) + +subQ (Q a b c d) (Q p q r s) = Q (a-p) (b-q) (c-r) (d-s) + +mulQ (Q a b c d) (Q p q r s) = + Q (a*p - b*q - c*r - d*s) + (a*q + b*p + c*s - d*r) + (a*r - b*s + c*p + d*q) + (a*s + b*r - c*q + d*p) + +normQ = sqrt. sum. join (zipWith (*)). listFromQ + +conjQ, negQ :: Quaternion -> Quaternion +conjQ (Q a b c d) = Q a (-b) (-c) (-d) + +negQ (Q a b c d) = Q (-a) (-b) (-c) (-d) diff --git a/Task/Quaternion-type/Haskell/quaternion-type-2.hs b/Task/Quaternion-type/Haskell/quaternion-type-2.hs new file mode 100644 index 0000000000..c88097d899 --- /dev/null +++ b/Task/Quaternion-type/Haskell/quaternion-type-2.hs @@ -0,0 +1,4 @@ +[q,q1,q2] = map quaternionFromList [[1..4],[2..5],[3..6]] +-- a*b == b*a +test :: Quaternion -> Quaternion -> Bool +test a b = a `mulQ` b == b `mulQ` a diff --git a/Task/Quaternion-type/Haskell/quaternion-type-3.hs b/Task/Quaternion-type/Haskell/quaternion-type-3.hs new file mode 100644 index 0000000000..967242e6e3 --- /dev/null +++ b/Task/Quaternion-type/Haskell/quaternion-type-3.hs @@ -0,0 +1,43 @@ +class Quaternion(a, b, c, d) + + method norm () + return sqrt (a*a + b*b + c*c + d*d) + end + + method negative () + return Quaternion(-a, -b, -c, -d) + end + + method conjugate () + return Quaternion(a, -b, -c, -d) + end + + method add (n) + if type(n) == "Quaternion__state" + then return Quaternion(a+n.a, b+n.b, c+n.c, d+n.d) + else return Quaternion(a+n, b, c, d) + end + + method multiply (n) + if type(n) == "Quaternion__state" + then return Quaternion(a*n.a - b*n.b - c*n.c - d*n.d, + a*n.b + b*n.a + c*n.d - d*n.c, + a*n.c - b*n.d + c*n.a + d*n.b, + a*n.d + b*n.c - c*n.b + d*n.a) + else return Quaternion(a*n, b*n, c*n, d*n) + end + + method sign (n) + return if n >= 0 then "+" else "-" + end + + method string () + return ("" || a || sign(b) || abs(b) || "i" || sign(c) || abs(c) || "j" || sign(d) || abs(d) || "k"); + end + + initially(a, b, c, d) + self.a := if /a then 0 else a + self.b := if /b then 0 else b + self.c := if /c then 0 else c + self.d := if /d then 0 else d +end diff --git a/Task/Quaternion-type/Haskell/quaternion-type-4.hs b/Task/Quaternion-type/Haskell/quaternion-type-4.hs new file mode 100644 index 0000000000..39c472f34f --- /dev/null +++ b/Task/Quaternion-type/Haskell/quaternion-type-4.hs @@ -0,0 +1,16 @@ +procedure main () + q := Quaternion (1,2,3,4) + q1 := Quaternion (2,3,4,5) + q2 := Quaternion (3,4,5,6) + r := 7 + + write ("The norm of " || q.string() || " is " || q.norm ()) + write ("The negative of " || q.string() || " is " || q.negative().string ()) + write ("The conjugate of " || q.string() || " is " || q.conjugate().string ()) + write ("Sum of " || q.string() || " and " || r || " is " || q.add(r).string ()) + write ("Sum of " || q.string() || " and " || q1.string() || " is " || q.add(q1).string ()) + write ("Product of " || q.string() || " and " || r || " is " || q.multiply(r).string ()) + write ("Product of " || q.string() || " and " || q1.string() || " is " || q.multiply(q1).string ()) + write ("q1*q2 = " || q1.multiply(q2).string ()) + write ("q2*q1 = " || q2.multiply(q1).string ()) +end diff --git a/Task/Quaternion-type/J/quaternion-type-1.j b/Task/Quaternion-type/J/quaternion-type-1.j new file mode 100644 index 0000000000..ca295741f5 --- /dev/null +++ b/Task/Quaternion-type/J/quaternion-type-1.j @@ -0,0 +1,11 @@ + NB. utilities + ip=: +/ .* NB. inner product + t4=. (_1^#:0 10 9 12)*0 7 16 23 A.=i.4 + toQ=: 4&{."1 :[: NB. real scalars -> quaternion + + NB. task + norm=: %:@ip~@toQ NB. | y + neg=: -&toQ NB. - y and x - y + conj=: 1 _1 _1 _1 * toQ NB. + y + add=: +&toQ NB. x + y + mul=: (ip t4 ip ])&toQ NB. x * y diff --git a/Task/Quaternion-type/J/quaternion-type-2.j b/Task/Quaternion-type/J/quaternion-type-2.j new file mode 100644 index 0000000000..15cca6a118 --- /dev/null +++ b/Task/Quaternion-type/J/quaternion-type-2.j @@ -0,0 +1,21 @@ + q=: 1 2 3 4 + q1=: 2 3 4 5 + q2=: 3 4 5 6 + r=: 7 + + norm q +5.47723 + neg q +_1 _2 _3 _4 + conj q +1 _2 _3 _4 + r add q +8 2 3 4 + q1 add q2 +5 7 9 11 + r mul q +7 14 21 28 + q1 mul q2 +_56 16 24 26 + q2 mul q1 +_56 18 20 28 diff --git a/Task/Quaternion-type/Java/quaternion-type.java b/Task/Quaternion-type/Java/quaternion-type.java new file mode 100644 index 0000000000..9298613ac2 --- /dev/null +++ b/Task/Quaternion-type/Java/quaternion-type.java @@ -0,0 +1,103 @@ +public class Quaternion { + private final double a, b, c, d; + + public Quaternion(double a, double b, double c, double d) { + this.a = a; + this.b = b; + this.c = c; + this.d = d; + } + public Quaternion(double r) { + this(r, 0.0, 0.0, 0.0); + } + + public double norm() { + return Math.sqrt(a * a + b * b + c * c + d * d); + } + + public Quaternion negative() { + return new Quaternion(-a, -b, -c, -d); + } + + public Quaternion conjugate() { + return new Quaternion(a, -b, -c, -d); + } + + public Quaternion add(double r) { + return new Quaternion(a + r, b, c, d); + } + public static Quaternion add(Quaternion q, double r) { + return q.add(r); + } + public static Quaternion add(double r, Quaternion q) { + return q.add(r); + } + public Quaternion add(Quaternion q) { + return new Quaternion(a + q.a, b + q.b, c + q.c, d + q.d); + } + public static Quaternion add(Quaternion q1, Quaternion q2) { + return q1.add(q2); + } + + public Quaternion times(double r) { + return new Quaternion(a * r, b * r, c * r, d * r); + } + public static Quaternion times(Quaternion q, double r) { + return q.times(r); + } + public static Quaternion times(double r, Quaternion q) { + return q.times(r); + } + public Quaternion times(Quaternion q) { + return new Quaternion( + a * q.a - b * q.b - c * q.c - d * q.d, + a * q.b + b * q.a + c * q.d - d * q.c, + a * q.c - b * q.d + c * q.a + d * q.b, + a * q.d + b * q.c - c * q.b + d * q.a + ); + } + public static Quaternion times(Quaternion q1, Quaternion q2) { + return q1.times(q2); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof Quaternion)) return false; + final Quaternion other = (Quaternion) obj; + if (Double.doubleToLongBits(this.a) != Double.doubleToLongBits(other.a)) return false; + if (Double.doubleToLongBits(this.b) != Double.doubleToLongBits(other.b)) return false; + if (Double.doubleToLongBits(this.c) != Double.doubleToLongBits(other.c)) return false; + if (Double.doubleToLongBits(this.d) != Double.doubleToLongBits(other.d)) return false; + return true; + } + @Override + public String toString() { + return String.format("%.2f + %.2fi + %.2fj + %.2fk", a, b, c, d).replaceAll("\\+ -", "- "); + } + + public String toQuadruple() { + return String.format("(%.2f, %.2f, %.2f, %.2f)", a, b, c, d); + } + + public static void main(String[] args) { + Quaternion q = new Quaternion(1.0, 2.0, 3.0, 4.0); + Quaternion q1 = new Quaternion(2.0, 3.0, 4.0, 5.0); + Quaternion q2 = new Quaternion(3.0, 4.0, 5.0, 6.0); + double r = 7.0; + System.out.format("q = %s%n", q); + System.out.format("q1 = %s%n", q1); + System.out.format("q2 = %s%n", q2); + System.out.format("r = %.2f%n%n", r); + System.out.format("\u2016q\u2016 = %.2f%n", q.norm()); + System.out.format("-q = %s%n", q.negative()); + System.out.format("q* = %s%n", q.conjugate()); + System.out.format("q + r = %s%n", q.add(r)); + System.out.format("q1 + q2 = %s%n", q1.add(q2)); + System.out.format("q \u00d7 r = %s%n", q.times(r)); + Quaternion q1q2 = q1.times(q2); + Quaternion q2q1 = q2.times(q1); + System.out.format("q1 \u00d7 q2 = %s%n", q1q2); + System.out.format("q2 \u00d7 q1 = %s%n", q2q1); + System.out.format("q1 \u00d7 q2 %s q2 \u00d7 q1%n", (q1q2.equals(q2q1) ? "=" : "\u2260")); + } +} diff --git a/Task/Quaternion-type/Liberty-BASIC/quaternion-type.liberty b/Task/Quaternion-type/Liberty-BASIC/quaternion-type.liberty new file mode 100644 index 0000000000..4f102b22d4 --- /dev/null +++ b/Task/Quaternion-type/Liberty-BASIC/quaternion-type.liberty @@ -0,0 +1,111 @@ + q$ = q$( 1 , 2 , 3 , 4 ) +q1$ = q$( 2 , 3 , 4 , 5 ) +q2$ = q$( 3 , 4 , 5 , 6 ) + +real = 7 + +print "q = " ; q$ +print "q1 = " ; q1$ +print "q2 = " ; q2$ + +print "real = " ; real + +print "length /norm q = " ; length( q$ ) ' =norm norm of q +print "negative (-q1) = " ; negative$( q1$ ) ' =negative negated q1 +print "conjugate q = " ; conjugate$( q$ ) ' conjugate conjugate q +print "real + q = " ; add1$( q$ , real ) ' real +quaternion real +q +print "q + q2 = " ; add2$( q$ , q2$ ) ' sum two quaternions q +q2 +print "real * q = " ; multiply1$( q$ , real ) ' real *quaternion real *q +print "q1 * q2 = " ; multiply2$( q1$ , q2$ ) ' product of two quaternions q1 & q2 +print "q2 * q1 = " ; multiply2$( q2$ , q1$ ) ' show q1 *q2 <> q2 *q1 + +end + +function q$( r , i , j , k ) + q$ = str$( r); " "; str$( i); " "; str$( j); " "; str$( k) +end function + +function length( q$ ) + r = val( word$( q$ , 1 ) ) + i = val( word$( q$ , 2 ) ) + j = val( word$( q$ , 3 ) ) + k = val( word$( q$ , 4 ) ) + length =sqr( r^2 +i^2 +j^2 +k^2) +end function + +function multiply1$( q$ , d ) + r = val( word$( q$ , 1 ) ) + i = val( word$( q$ , 2 ) ) + j = val( word$( q$ , 3 ) ) + k = val( word$( q$ , 4 ) ) + multiply1$ =q$( r*d, i*d, j*d, k*d) +end function + +function multiply2$( q$ , b$ ) + ar = val( word$( q$ , 1 ) ) 'a1 + ai = val( word$( q$ , 2 ) ) 'b1 + aj = val( word$( q$ , 3 ) ) 'c1 + ak = val( word$( q$ , 4 ) ) 'd1 + + br = val( word$( b$ , 1 ) ) 'a2 + bi = val( word$( b$ , 2 ) ) 'b2 + bj = val( word$( b$ , 3 ) ) 'c2 + bk = val( word$( b$ , 4 ) ) 'd2 + + multiply2$ =q$( _ + ar *br_ + +( 0 -ai) *bi_ + +( 0 -aj) *bj_ + +( 0 -ak) *bk _ + ,_ + ar *bi_ + +ai *br_ + +aj *bk_ + +( 0 -ak) *bj_ + ,_ + ar *bj_ + +( 0 -ai) *bk_ + +aj *br_ + +ak *bi_ + ,_ + ar *bk_ + +ai *bj_ + +( 0 -aj) *bi_ + +ak *br ) +end function + +function negative$( q$ ) + r = val( word$( q$ , 1 ) ) + i = val( word$( q$ , 2 ) ) + j = val( word$( q$ , 3 ) ) + k = val( word$( q$ , 4 ) ) + negative$ =q$( 0-r, 0-i, 0-j, 0-k) +end function + +function conjugate$( q$ ) + r = val( word$( q$ , 1 ) ) + i = val( word$( q$ , 2 ) ) + j = val( word$( q$ , 3 ) ) + k = val( word$( q$ , 4 ) ) + conjugate$ =q$( r, 0-i, 0-j, 0-k) +end function + +function add1$( q$ , real ) + r = val( word$( q$ , 1 ) ) + i = val( word$( q$ , 2 ) ) + j = val( word$( q$ , 3 ) ) + k = val( word$( q$ , 4 ) ) + add1$ =q$( r +real, i, j, k) +end function + +function add2$( q$ , b$ ) + ar = val( word$( q$ , 1 ) ) + ai = val( word$( q$ , 2 ) ) + aj = val( word$( q$ , 3 ) ) + ak = val( word$( q$ , 4 ) ) + br = val( word$( b$ , 1 ) ) + bi = val( word$( b$ , 2 ) ) + bj = val( word$( b$ , 3 ) ) + bk = val( word$( b$ , 4 ) ) + add2$ =q$( ar +br, ai +bi, aj +bj, ak +bk) +end function diff --git a/Task/Quaternion-type/Lua/quaternion-type-1.lua b/Task/Quaternion-type/Lua/quaternion-type-1.lua new file mode 100644 index 0000000000..7c86b591d8 --- /dev/null +++ b/Task/Quaternion-type/Lua/quaternion-type-1.lua @@ -0,0 +1,63 @@ +Quaternion = {} + +function Quaternion.new( a, b, c, d ) + local q = { a = a or 1, b = b or 0, c = c or 0, d = d or 0 } + + local metatab = {} + setmetatable( q, metatab ) + metatab.__add = Quaternion.add + metatab.__sub = Quaternion.sub + metatab.__unm = Quaternion.unm + metatab.__mul = Quaternion.mul + + return q +end + +function Quaternion.add( p, q ) + if type( p ) == "number" then + return Quaternion.new( p+q.a, q.b, q.c, q.d ) + elseif type( q ) == "number" then + return Quaternion.new( p.a+q, p.b, p.c, p.d ) + else + return Quaternion.new( p.a+q.a, p.b+q.b, p.c+q.c, p.d+q.d ) + end +end + +function Quaternion.sub( p, q ) + if type( p ) == "number" then + return Quaternion.new( p-q.a, q.b, q.c, q.d ) + elseif type( q ) == "number" then + return Quaternion.new( p.a-q, p.b, p.c, p.d ) + else + return Quaternion.new( p.a-q.a, p.b-q.b, p.c-q.c, p.d-q.d ) + end +end + +function Quaternion.unm( p ) + return Quaternion.new( -p.a, -p.b, -p.c, -p.d ) +end + +function Quaternion.mul( p, q ) + if type( p ) == "number" then + return Quaternion.new( p*q.a, p*q.b, p*q.c, p*q.d ) + elseif type( q ) == "number" then + return Quaternion.new( p.a*q, p.b*q, p.c*q, p.d*q ) + else + return Quaternion.new( p.a*q.a - p.b*q.b - p.c*q.c - p.d*q.d, + p.a*q.b + p.b*q.a + p.c*q.d - p.d*q.c, + p.a*q.c - p.b*q.d + p.c*q.a + p.d*q.b, + p.a*q.d + p.b*q.c - p.c*q.b + p.d*q.a ) + end +end + +function Quaternion.conj( p ) + return Quaternion.new( p.a, -p.b, -p.c, -p.d ) +end + +function Quaternion.norm( p ) + return math.sqrt( p.a^2 + p.b^2 + p.c^2 + p.d^2 ) +end + +function Quaternion.print( p ) + print( string.format( "%f + %fi + %fj + %fk\n", p.a, p.b, p.c, p.d ) ) +end diff --git a/Task/Quaternion-type/Lua/quaternion-type-2.lua b/Task/Quaternion-type/Lua/quaternion-type-2.lua new file mode 100644 index 0000000000..fc13bbc1fd --- /dev/null +++ b/Task/Quaternion-type/Lua/quaternion-type-2.lua @@ -0,0 +1,23 @@ +q1 = Quaternion.new( 1, 2, 3, 4 ) +q2 = Quaternion.new( 5, 6, 7, 8 ) +r = 12 + +print( "norm(q1) = ", Quaternion.norm( q1 ) ) +io.write( "-q1 = " ); Quaternion.print( -q1 ) +io.write( "conj(q1) = " ); Quaternion.print( Quaternion.conj( q1 ) ) +io.write( "r+q1 = " ); Quaternion.print( r+q1 ) +io.write( "q1+r = " ); Quaternion.print( q1+r ) +io.write( "r*q1 = " ); Quaternion.print( r*q1 ) +io.write( "q1*r = " ); Quaternion.print( q1*r ) +io.write( "q1*q2 = " ); Quaternion.print( q1*q2 ) +io.write( "q2*q1 = " ); Quaternion.print( q2*q1 ) +Output: +norm(q1) = 5.4772255750517 +-q1 = -1.000000 -2.000000i -3.000000j -4.000000k +conj(q1) = 1.000000 -2.000000i -3.000000j -4.000000k +r+q1 = 13.000000 + 2.000000i + 3.000000j + 4.000000k +q1+r = 13.000000 + 2.000000i + 3.000000j + 4.000000k +r*q1 = 12.000000 + 24.000000i + 36.000000j + 48.000000k +q1*r = 12.000000 + 24.000000i + 36.000000j + 48.000000k +q1*q2 = -60.000000 + 12.000000i + 30.000000j + 24.000000k +q2*q1 = -60.000000 + 20.000000i + 14.000000j + 32.000000k diff --git a/Task/Quaternion-type/Mathematica/quaternion-type.math b/Task/Quaternion-type/Mathematica/quaternion-type.math new file mode 100644 index 0000000000..dfb1ff39a6 --- /dev/null +++ b/Task/Quaternion-type/Mathematica/quaternion-type.math @@ -0,0 +1,26 @@ +<Quaternion[1,2,3,4] +->Quaternion[2,3,4,5] +->Quaternion[3,4,5,6] +->7 + +Norm[q] +->30 +-q +->Quaternion[-1,-2,-3,-4] +Conjugate[q] +->Quaternion[1,-2,-3,-4] +q1+q2 +->Quaternion[5,7,9,11] +q*r +->Quaternion[7,14,21,28] +r*q +->Quaternion[7,14,21,28] +q1**q2 +->Quaternion[-56,16,24,26] +q2**q1 +->Quaternion[-56,18,20,28] diff --git a/Task/Quaternion-type/OCaml/quaternion-type-1.ocaml b/Task/Quaternion-type/OCaml/quaternion-type-1.ocaml new file mode 100644 index 0000000000..9333faeb40 --- /dev/null +++ b/Task/Quaternion-type/OCaml/quaternion-type-1.ocaml @@ -0,0 +1,49 @@ +type quaternion = float * float * float * float + +let q a b c d = (a, b, c, d) + +let to_real (r, _, _, _) = r +let imag (_, i, j, k) = (i, j, k) + +let quaternion_of_scalar s = (s, 0.0, 0.0, 0.0) + +let to_list (a, b, c, d) = [a; b; c; d] +let of_list = function [a; b; c; d] -> (a, b, c, d) + | _ -> invalid_arg "of_list" + +let ( + ) = ( +. ) +let ( - ) = ( -. ) +let ( * ) = ( *. ) +let ( / ) = ( /. ) + +let addr (a, b, c, d) r = (a+r, b, c, d) +let mulr (a, b, c, d) r = (a*r, b*r, c*r, d*r) + +let add (a, b, c, d) (p, q, r, s) = (a+p, b+q, c+r, d+s) + +let sub (a, b, c, d) (p, q, r, s) = (a-p, b-q, c-r, d-s) + +let mul (a, b, c, d) (p, q, r, s) = + ( a*p - b*q - c*r - d*s, + a*q + b*p + c*s - d*r, + a*r - b*s + c*p + d*q, + a*s + b*r - c*q + d*p ) + +let norm2 (a, b, c, d) = + ( a * a + + b * b + + c * c + + d * d ) + +let norm q = sqrt(norm2 q) + +let conj (a, b, c, d) = (a, -. b, -. c, -. d) +let neg (a, b, c, d) = (-. a, -. b, -. c, -. d) + +let unit ((a, b, c, d) as q) = + let n = norm q in + (a/n, b/n, c/n, d/n) + +let reciprocal ((a, b, c, d) as q) = + let n2 = norm2 q in + (a/n2, b/n2, c/n2, d/n2) diff --git a/Task/Quaternion-type/OCaml/quaternion-type-2.ocaml b/Task/Quaternion-type/OCaml/quaternion-type-2.ocaml new file mode 100644 index 0000000000..f11050fa11 --- /dev/null +++ b/Task/Quaternion-type/OCaml/quaternion-type-2.ocaml @@ -0,0 +1,18 @@ +type quaternion = float * float * float * float + +val q : float -> float -> float -> float -> quaternion +val to_real : quaternion -> float +val imag : quaternion -> float * float * float +val quaternion_of_scalar : float -> quaternion +val to_list : quaternion -> float list +val of_list : float list -> quaternion +val addr : quaternion -> float -> quaternion +val mulr : quaternion -> float -> quaternion +val add : quaternion -> quaternion -> quaternion +val sub : quaternion -> quaternion -> quaternion +val mul : quaternion -> quaternion -> quaternion +val norm : quaternion -> float +val conj : quaternion -> quaternion +val neg : quaternion -> quaternion +val unit : quaternion -> quaternion +val reciprocal : quaternion -> quaternion diff --git a/Task/Quaternion-type/PARI-GP/quaternion-type-1.pari b/Task/Quaternion-type/PARI-GP/quaternion-type-1.pari new file mode 100644 index 0000000000..0a0f4485dc --- /dev/null +++ b/Task/Quaternion-type/PARI-GP/quaternion-type-1.pari @@ -0,0 +1,35 @@ +q.norm={ + if(type(q) != "t_VEC" || #q != 4, error("incorrect type")); + sqrt(q[1]^2+q[2]^2+q[3]^2+q[4]^2) +}; +q.conj={ + if(type(q) != "t_VEC" || #q != 4, error("incorrect type")); + -[-q[1],q[2],q[3],q[4]] +}; +q.add={ + if(type(q) != "t_VEC" || #q != 4, error("incorrect type")); + x->if(type(x) == "t_INT" || type(x) == t_REAL, + [q[1]+x,q[2],q[3],q[4]] + , + if(type(x) == "t_VEC" && #x == 4, + q+x + , + error("incorrect type") + ) + ) +}; +q.mult={ + if(type(q) != "t_VEC" || #q != 4, error("incorrect type")); + x->if(type(x) == "t_INT" || type(x) == t_REAL, + x*q + , + if(type(x) == "t_VEC" && #x == 4, + [q[1]*x[1] - q[2]*x[2] - q[3]*x[3] - q[4]*x[4], + q[1]*x[2] + q[2]*x[1] + q[3]*x[4] - q[4]*x[3], + q[1]*x[3] - q[2]*x[4] + q[3]*x[1] + q[4]*x[2], + q[1]*x[4] + q[2]*x[3] - q[3]*x[2] + q[4]*x[1]] + , + error("incorrect type") + ) + ) +}; diff --git a/Task/Quaternion-type/PARI-GP/quaternion-type-2.pari b/Task/Quaternion-type/PARI-GP/quaternion-type-2.pari new file mode 100644 index 0000000000..a9c990c848 --- /dev/null +++ b/Task/Quaternion-type/PARI-GP/quaternion-type-2.pari @@ -0,0 +1,10 @@ +r=7;q=[1,2,3,4];q1=[2,3,4,5];q2=[3,4,5,6]; +q.norm +-q +q.conj +q.add(r) +q1.add(q2) +q1.add(q2) \\ or q1+q2 +q.mult(r) \\ or r*q or q*r +q1.mult(q2) +q1.mult(q2) != q2.mult(q1) diff --git a/Task/Quaternion-type/Perl-6/quaternion-type.pl6 b/Task/Quaternion-type/Perl-6/quaternion-type.pl6 new file mode 100644 index 0000000000..9b5cd3f7b5 --- /dev/null +++ b/Task/Quaternion-type/Perl-6/quaternion-type.pl6 @@ -0,0 +1,43 @@ +class Quaternion { + has Real ( $.r, $.i, $.j, $.k ); + + multi method new ( Real $r, Real $i, Real $j, Real $k ) { + self.bless: *, :$r, :$i, :$j, :$k; + } + method Str ( ) { "$.r + {$.i}i + {$.j}j + {$.k}k" } + method reals ( ) { $.r, $.i, $.j, $.k } + method conj ( ) { self.new: $.r, -$.i, -$.j, -$.k } + method norm ( ) { sqrt [+] self.reals X** 2 } +} + +subset Qu of Quaternion; # Makes a short alias + +multi sub infix: ( Qu $a, Qu $b ) { [and] $a.reals Z== $b.reals } +multi sub infix:<+> ( Qu $a, Real $b ) { $a.new: $b+$a.r, $a.i, $a.j, $a.k } +multi sub infix:<+> ( Real $a, Qu $b ) { $b.new: $a+$b.r, $b.i, $b.j, $b.k } +multi sub infix:<+> ( Qu $a, Qu $b ) { $a.new: |( $a.reals Z+ $b.reals ) } +multi sub prefix:<-> ( Qu $a ) { $a.new: |( $a.reals X* -1 ) } +multi sub infix:<*> ( Qu $a, Real $b ) { $a.new: |( $a.reals X* $b ) } +multi sub infix:<*> ( Real $a, Qu $b ) { $b.new: |( $b.reals X* $a ) } +multi sub infix:<*> ( Qu $a, Qu $b ) { + my @a_rijk = $a.reals; + my ( $r, $i, $j, $k ) = $b.reals; + return $a.new: ( [+] @a_rijk Z* $r, -$i, -$j, -$k ), # real + ( [+] @a_rijk Z* $i, $r, $k, -$j ), # i + ( [+] @a_rijk Z* $j, -$k, $r, $i ), # j + ( [+] @a_rijk Z* $k, $j, -$i, $r ); # k +} + +my Quaternion $q .= new: 1, 2, 3, 4; +my Quaternion $q1 .= new: 2, 3, 4, 5; +my Quaternion $q2 .= new: 3, 4, 5, 6; +my $r = 7; + +say "1) q norm = {$q.norm}"; +say "2) -q = {-$q}"; +say "3) q conj = {$q.conj}"; +say "4) q + r = {$q + $r}"; +say "5) q1 + q2 = {$q1 + $q2}"; +say "6) q * r = {$q * $r}"; +say "7) q1 * q2 = {$q1 * $q2}"; +say "8) q1q2 { $q1 * $q2 eqv $q2 * $q1 ?? '==' !! '!=' } q2q1"; diff --git a/Task/Quaternion-type/Perl/quaternion-type.pl b/Task/Quaternion-type/Perl/quaternion-type.pl new file mode 100644 index 0000000000..1676713adf --- /dev/null +++ b/Task/Quaternion-type/Perl/quaternion-type.pl @@ -0,0 +1,70 @@ +package Quaternion; +use List::Util 'reduce'; +use List::MoreUtils 'pairwise'; + +sub make { + my $cls = shift; + if (@_ == 1) { return bless [ @_, 0, 0, 0 ] } + elsif (@_ == 4) { return bless [ @_ ] } + else { die "Bad number of components: @_" } +} + +sub _abs { sqrt reduce { $a + $b * $b } @{ +shift } } +sub _neg { bless [ map(-$_, @{+shift}) ] } +sub _str { "(@{+shift})" } + +sub _add { + my ($x, $y) = @_; + $y = [ $y, 0, 0, 0 ] unless ref $y; + bless [ pairwise { $a + $b } @$x, @$y ] +} + +sub _sub { + my ($x, $y, $swap) = @_; + $y = [ $y, 0, 0, 0 ] unless ref $y; + my @x = pairwise { $a - $b } @$x, @$y; + if ($swap) { $_ = -$_ for @x } + bless \@x; +} + +sub _mul { + my ($x, $y) = @_; + if (!ref $y) { return bless [ map($_ * $y, @$x) ] } + my ($a1, $b1, $c1, $d1) = @$x; + my ($a2, $b2, $c2, $d2) = @$y; + bless [ $a1 * $a2 - $b1 * $b2 - $c1 * $c2 - $d1 * $d2, + $a1 * $b2 + $b1 * $a2 + $c1 * $d2 - $d1 * $c2, + $a1 * $c2 - $b1 * $d2 + $c1 * $a2 + $d1 * $b2, + $a1 * $d2 + $b1 * $c2 - $c1 * $b2 + $d1 * $a2] +} + +sub conjugate { + my @a = map { -$_ } @{$_[0]}; + $a[0] = $_[0][0]; + bless \@a +} + +use overload ( + '""' => \&_str, + '+' => \&_add, + '-' => \&_sub, + '*' => \&_mul, + 'neg' => \&_neg, + 'abs' => \&_abs, +); + +package main; + +my $a = Quaternion->make(1, 2, 3, 4); +my $b = Quaternion->make(1, 1, 1, 1); + +print "a = $a\n"; +print "b = $b\n"; +print "|a| = ", abs($a), "\n"; +print "-a = ", -$a, "\n"; +print "a + 1 = ", $a + 1, "\n"; +print "a + b = ", $a + $b, "\n"; +print "a - b = ", $a - $b, "\n"; +print "a conjugate is ", $a->conjugate, "\n"; +print "a * b = ", $a * $b, "\n"; +print "b * a = ", $b * $a, "\n"; diff --git a/Task/Quaternion-type/PicoLisp/quaternion-type-1.l b/Task/Quaternion-type/PicoLisp/quaternion-type-1.l new file mode 100644 index 0000000000..cc6fde47a1 --- /dev/null +++ b/Task/Quaternion-type/PicoLisp/quaternion-type-1.l @@ -0,0 +1,33 @@ +(scl 6) + +(def 'quatCopy copy) + +(de quatNorm (Q) + (sqrt (sum * Q Q)) ) + +(de quatNeg (Q) + (mapcar - Q) ) + +(de quatConj (Q) + (cons (car Q) (mapcar - (cdr Q))) ) + +(de quatAddR (Q R) + (cons (+ R (car Q)) (cdr Q)) ) + +(de quatAdd (Q1 Q2) + (mapcar + Q1 Q2) ) + +(de quatMulR (Q R) + (mapcar */ (mapcar * Q (circ R)) (1.0 .)) ) + +(de quatMul (Q1 Q2) + (mapcar + '((Ops I) + (sum '((Op R I) (Op (*/ R (get Q2 I) 1.0))) Ops Q1 I) ) + '((+ - - -) (+ + + -) (+ - + +) (+ + - +)) + '((1 2 3 4) (2 1 4 3) (3 4 1 2) (4 3 2 1)) ) ) + +(de quatFmt (Q) + (mapcar '((R S) (pack (format R *Scl) S)) + Q + '(" + " "i + " "j + " "k") ) ) diff --git a/Task/Quaternion-type/PicoLisp/quaternion-type-2.l b/Task/Quaternion-type/PicoLisp/quaternion-type-2.l new file mode 100644 index 0000000000..3a8fe3e097 --- /dev/null +++ b/Task/Quaternion-type/PicoLisp/quaternion-type-2.l @@ -0,0 +1,22 @@ +(setq + Q (1.0 2.0 3.0 4.0) + Q1 (2.0 3.0 4.0 5.0) + Q2 (3.0 4.0 5.0 6.0) + R 7.0 ) + +(prinl "R = " (format R *Scl)) +(prinl "Q = " (quatFmt Q)) +(prinl "Q1 = " (quatFmt Q1)) +(prinl "Q2 = " (quatFmt Q2)) +(prinl) +(prinl "norm(Q) = " (format (quatNorm Q) *Scl)) +(prinl "norm(Q1) = " (format (quatNorm Q1) *Scl)) +(prinl "norm(Q2) = " (format (quatNorm Q2) *Scl)) +(prinl "neg(Q) = " (quatFmt (quatNeg Q))) +(prinl "conj(Q) = " (quatFmt (quatConj Q))) +(prinl "Q + R = " (quatFmt (quatAddR Q R))) +(prinl "Q1 + Q2 = " (quatFmt (quatAdd Q1 Q2))) +(prinl "Q * R = " (quatFmt (quatMulR Q R))) +(prinl "Q1 * Q2 = " (quatFmt (quatMul Q1 Q2))) +(prinl "Q2 * Q1 = " (quatFmt (quatMul Q2 Q1))) +(prinl (if (= (quatMul Q1 Q2) (quatMul Q2 Q1)) "Equal" "Not equal")) diff --git a/Task/Quaternion-type/PureBasic/quaternion-type-1.purebasic b/Task/Quaternion-type/PureBasic/quaternion-type-1.purebasic new file mode 100644 index 0000000000..1fab8edd2e --- /dev/null +++ b/Task/Quaternion-type/PureBasic/quaternion-type-1.purebasic @@ -0,0 +1,85 @@ +Structure Quaternion + a.f + b.f + c.f + d.f +EndStructure + +Procedure.f QNorm(*x.Quaternion) + ProcedureReturn Sqr(Pow(*x\a, 2) + Pow(*x\b, 2) + Pow(*x\c, 2) + Pow(*x\d, 2)) +EndProcedure + +;If supplied, the result is returned in the quaternion structure *res, +;otherwise a new quaternion is created. A pointer to the result is returned. +Procedure QNeg(*x.Quaternion, *res.Quaternion = 0) + If *res = 0: *res.Quaternion = AllocateMemory(SizeOf(Quaternion)): EndIf + If *res + *res\a = -*x\a + *res\b = -*x\b + *res\c = -*x\c + *res\d = -*x\d + EndIf + ProcedureReturn *res +EndProcedure + +Procedure QConj(*x.Quaternion, *res.Quaternion = 0) + If *res = 0: *res.Quaternion = AllocateMemory(SizeOf(Quaternion)): EndIf + If *res + *res\a = *x\a + *res\b = -*x\b + *res\c = -*x\c + *res\d = -*x\d + EndIf + ProcedureReturn *res +EndProcedure + +Procedure QAddReal(r.f, *x.Quaternion, *res.Quaternion = 0) + If *res = 0: *res.Quaternion = AllocateMemory(SizeOf(Quaternion)): EndIf + If *res + *res\a = *x\a + r + *res\b = *x\b + *res\c = *x\c + *res\d = *x\d + EndIf + ProcedureReturn *res +EndProcedure + +Procedure QAddQuaternion(*x.Quaternion, *y.Quaternion, *res.Quaternion = 0) + If *res = 0: *res.Quaternion = AllocateMemory(SizeOf(Quaternion)): EndIf + If *res + *res\a = *x\a + *y\a + *res\b = *x\b + *y\b + *res\c = *x\c + *y\c + *res\d = *x\d + *y\d + EndIf + ProcedureReturn *res +EndProcedure + +Procedure QMulReal_and_Quaternion(r.f, *x.Quaternion, *res.Quaternion = 0) + If *res = 0: *res.Quaternion = AllocateMemory(SizeOf(Quaternion)): EndIf + If *res + *res\a = *x\a * r + *res\b = *x\b * r + *res\c = *x\c * r + *res\d = *x\d * r + EndIf + ProcedureReturn *res +EndProcedure + +Procedure QMulQuaternion(*x.Quaternion, *y.Quaternion, *res.Quaternion = 0) + If *res = 0: *res.Quaternion = AllocateMemory(SizeOf(Quaternion)): EndIf + If *res + *res\a = *x\a * *y\a - *x\b * *y\b - *x\c * *y\c - *x\d * *y\d + *res\b = *x\a * *y\b + *x\b * *y\a + *x\c * *y\d - *x\d * *y\c + *res\c = *x\a * *y\c - *x\b * *y\d + *x\c * *y\a + *x\d * *y\b + *res\d = *x\a * *y\d + *x\b * *y\c - *x\c * *y\b + *x\d * *y\a + EndIf + ProcedureReturn *res +EndProcedure + +Procedure Q_areEqual(*x.Quaternion, *y.Quaternion) + If (*x\a <> *y\a) Or (*x\b <> *y\b) Or (*x\c <> *y\c) Or (*x\d <> *y\d) + ProcedureReturn 0 ;false + EndIf + ProcedureReturn 1 ;true +EndProcedure diff --git a/Task/Quaternion-type/PureBasic/quaternion-type-2.purebasic b/Task/Quaternion-type/PureBasic/quaternion-type-2.purebasic new file mode 100644 index 0000000000..fece7e2670 --- /dev/null +++ b/Task/Quaternion-type/PureBasic/quaternion-type-2.purebasic @@ -0,0 +1,29 @@ +Procedure.s ShowQ(*x.Quaternion, NN = 0) + ProcedureReturn "{" + StrF(*x\a, NN) + "," + StrF(*x\b, NN) + "," + StrF(*x\c, NN) + "," + StrF(*x\d, NN) + "}" +EndProcedure + +If OpenConsole() + Define.Quaternion Q0, Q1, Q2, res, res2 + Define.f r = 7 + + Q0\a = 1: Q0\b = 2: Q0\c = 3: Q0\d = 4 + Q1\a = 2: Q1\b = 3: Q1\c = 4: Q1\d = 5 + Q2\a = 3: Q2\b = 4: Q2\c = 5: Q2\d = 6 + + PrintN("Q0 = " + ShowQ(Q0, 0)) + PrintN("Q1 = " + ShowQ(Q1, 0)) + PrintN("Q2 = " + ShowQ(Q2, 0)) + + PrintN("Normal of Q0 = " + StrF(QNorm(Q0))) + PrintN("Neg(Q0) = " + ShowQ(QNeg(Q0, res))) + PrintN("Conj(Q0) = " + ShowQ(QConj(Q0, res))) + PrintN("r + Q0 = " + ShowQ(QAddReal(r, Q0, res))) + PrintN("Q0 + Q1 = " + ShowQ(QAddQuaternion(Q0, Q1, res))) + PrintN("Q1 + Q2 = " + ShowQ(QAddQuaternion(Q1, Q2, res))) + PrintN("Q1 * Q2 = " + ShowQ(QMulQuaternion(Q1, Q2, res))) + PrintN("Q2 * Q1 = " + ShowQ(QMulQuaternion(Q2, Q1, res2))) + Print( "Q1 * Q2"): If Q_areEqual(res, res2): Print(" = "): Else: Print(" <> "): EndIf: Print( "Q2 * Q1") + + Print(#CRLF$ + #CRLF$ + "Press ENTER to exit"): Input() + CloseConsole() +EndIf diff --git a/Task/Quaternion-type/Python/quaternion-type-1.py b/Task/Quaternion-type/Python/quaternion-type-1.py new file mode 100644 index 0000000000..9534c5ce0d --- /dev/null +++ b/Task/Quaternion-type/Python/quaternion-type-1.py @@ -0,0 +1,82 @@ +from collections import namedtuple +import math + +class Q(namedtuple('Quaternion', 'real, i, j, k')): + 'Quaternion type: Q(real=0.0, i=0.0, j=0.0, k=0.0)' + + __slots__ = () + + def __new__(_cls, real=0.0, i=0.0, j=0.0, k=0.0): + 'Defaults all parts of quaternion to zero' + return super().__new__(_cls, float(real), float(i), float(j), float(k)) + + def conjugate(self): + return Q(self.real, -self.i, -self.j, -self.k) + + def _norm2(self): + return sum( x*x for x in self) + + def norm(self): + return math.sqrt(self._norm2()) + + def reciprocal(self): + n2 = self._norm2() + return Q(*(x / n2 for x in self.conjugate())) + + def __str__(self): + 'Shorter form of Quaternion as string' + return 'Q(%g, %g, %g, %g)' % self + + def __neg__(self): + return Q(-self.real, -self.i, -self.j, -self.k) + + def __add__(self, other): + if type(other) == Q: + return Q( *(s+o for s,o in zip(self, other)) ) + try: + f = float(other) + except: + return NotImplemented + return Q(self.real + f, self.i, self.j, self.k) + + def __radd__(self, other): + return Q.__add__(self, other) + + def __mul__(self, other): + if type(other) == Q: + a1,b1,c1,d1 = self + a2,b2,c2,d2 = other + return Q( + a1*a2 - b1*b2 - c1*c2 - d1*d2, + a1*b2 + b1*a2 + c1*d2 - d1*c2, + a1*c2 - b1*d2 + c1*a2 + d1*b2, + a1*d2 + b1*c2 - c1*b2 + d1*a2 ) + try: + f = float(other) + except: + return NotImplemented + return Q(self.real * f, self.i * f, self.j * f, self.k * f) + + def __rmul__(self, other): + return Q.__mul__(self, other) + + def __truediv__(self, other): + if type(other) == Q: + return self.__mul__(other.reciprocal()) + try: + f = float(other) + except: + return NotImplemented + return Q(self.real / f, self.i / f, self.j / f, self.k / f) + + def __rtruediv__(self, other): + return other * self.reciprocal() + + __div__, __rdiv__ = __truediv__, __rtruediv__ + +Quaternion = Q + +q = Q(1, 2, 3, 4) +q1 = Q(2, 3, 4, 5) +q2 = Q(3, 4, 5, 6) +r = 7 diff --git a/Task/Quaternion-type/Python/quaternion-type-2.py b/Task/Quaternion-type/Python/quaternion-type-2.py new file mode 100644 index 0000000000..d9f411db3e --- /dev/null +++ b/Task/Quaternion-type/Python/quaternion-type-2.py @@ -0,0 +1,56 @@ +>>> q +Quaternion(real=1.0, i=2.0, j=3.0, k=4.0) +>>> q1 +Quaternion(real=2.0, i=3.0, j=4.0, k=5.0) +>>> q2 +Quaternion(real=3.0, i=4.0, j=5.0, k=6.0) +>>> r +7 +>>> q.norm() +5.477225575051661 +>>> q1.norm() +7.3484692283495345 +>>> q2.norm() +9.273618495495704 +>>> -q +Quaternion(real=-1.0, i=-2.0, j=-3.0, k=-4.0) +>>> q.conjugate() +Quaternion(real=1.0, i=-2.0, j=-3.0, k=-4.0) +>>> r + q +Quaternion(real=8.0, i=2.0, j=3.0, k=4.0) +>>> q + r +Quaternion(real=8.0, i=2.0, j=3.0, k=4.0) +>>> q1 + q2 +Quaternion(real=5.0, i=7.0, j=9.0, k=11.0) +>>> q2 + q1 +Quaternion(real=5.0, i=7.0, j=9.0, k=11.0) +>>> q * r +Quaternion(real=7.0, i=14.0, j=21.0, k=28.0) +>>> r * q +Quaternion(real=7.0, i=14.0, j=21.0, k=28.0) +>>> q1 * q2 +Quaternion(real=-56.0, i=16.0, j=24.0, k=26.0) +>>> q2 * q1 +Quaternion(real=-56.0, i=18.0, j=20.0, k=28.0) +>>> assert q1 * q2 != q2 * q1 +>>> +>>> i, j, k = Q(0,1,0,0), Q(0,0,1,0), Q(0,0,0,1) +>>> i*i +Quaternion(real=-1.0, i=0.0, j=0.0, k=0.0) +>>> j*j +Quaternion(real=-1.0, i=0.0, j=0.0, k=0.0) +>>> k*k +Quaternion(real=-1.0, i=0.0, j=0.0, k=0.0) +>>> i*j*k +Quaternion(real=-1.0, i=0.0, j=0.0, k=0.0) +>>> q1 / q2 +Quaternion(real=0.7906976744186047, i=0.023255813953488358, j=-2.7755575615628914e-17, k=0.046511627906976744) +>>> q1 / q2 * q2 +Quaternion(real=2.0000000000000004, i=3.0000000000000004, j=4.000000000000001, k=5.000000000000001) +>>> q2 * q1 / q2 +Quaternion(real=2.0, i=3.465116279069768, j=3.906976744186047, k=4.767441860465116) +>>> q1.reciprocal() * q1 +Quaternion(real=0.9999999999999999, i=0.0, j=0.0, k=0.0) +>>> q1 * q1.reciprocal() +Quaternion(real=0.9999999999999999, i=0.0, j=0.0, k=0.0) +>>> diff --git a/Task/Quaternion-type/R/quaternion-type.r b/Task/Quaternion-type/R/quaternion-type.r new file mode 100644 index 0000000000..dc46f9219a --- /dev/null +++ b/Task/Quaternion-type/R/quaternion-type.r @@ -0,0 +1,33 @@ +library(quaternions) + +q <- Q(1, 2, 3, 4) +q1 <- Q(2, 3, 4, 5) +q2 <- Q(3, 4, 5, 6) +r <- 7.0 + +display <- function(x){ + e <- deparse(substitute(x)) + res <- if(class(x) == "Q") paste(x$r, "+", x$i, "i+", x$j, "j+", x$k, "k", sep = "") else x + cat(noquote(paste(c(e, " = ", res, "\n"), collapse=""))) + invisible(res) +} + +display(norm(q)) +display(-q) +display(Conj(q)) +display(r + q) +display(q1 + q2) +display(r*q) +display(q*r) +if(display(q1*q2) == display(q2*q1)) cat("q1*q2 == q2*q1\n") else cat("q1*q2 != q2*q1\n") + +## norm(q) = 5.47722557505166 +## -q = -1+-2i+-3j+-4k +## Conj(q) = 1+-2i+-3j+-4k +## r + q = 8+2i+3j+4k +## q1 + q2 = 5+7i+9j+11k +## r * q = 7+14i+21j+28k +## q * r = 7+14i+21j+28k +## q1 * q2 = -56+16i+24j+26k +## q2 * q1 = -56+18i+20j+28k +## q1*q2 != q2*q1 diff --git a/Task/Quaternion-type/REXX/quaternion-type.rexx b/Task/Quaternion-type/REXX/quaternion-type.rexx new file mode 100644 index 0000000000..6e652d4654 --- /dev/null +++ b/Task/Quaternion-type/REXX/quaternion-type.rexx @@ -0,0 +1,48 @@ +/*REXX program to perform simple operations of quaternion type numbers.*/ + q = 1 2 3 4 ; q1 = 2 3 4 5 + r = 7 ; q2 = 3 4 5 6 +call quatShow q , 'q' +call quatShow q1 , 'q1' +call quatShow q2 , 'q2' +call quatShow r , 'r' +call quatShow quatNorm(q) , 'norm q' , "task 1:" +call quatShow quatNeg(q) , 'negative q' , "task 2:" +call quatShow quatConj(q) , 'conjugate q' , "task 3:" +call quatShow quatAdd( r, q ) , 'addition r+q' , "task 4:" +call quatShow quatAdd(q1, q2 ) , 'addition q1+q2' , "task 5:" +call quatShow quatMul( q, r ) , 'multiplication q*r' , "task 6:" +call quatShow quatMul(q1, q2 ) , 'multiplication q1*q2' , "task 7:" +call quatShow quatMul(q2, q1 ) , 'multiplication q2*q1' , "task 8:" +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────QUATADD─────────────────────────────*/ +quatAdd: procedure; parse arg x,y; call quatXY 2 +return x.1+y.1 x.2+y.2 x.3+y.3 x.4+y.4 +/*──────────────────────────────────QUATCONJ────────────────────────────*/ +quatConj: procedure; parse arg x; call quatXY +return x.1 (-x.2) (-x.3) (-x.4) +/*──────────────────────────────────QUATMUL─────────────────────────────*/ +quatMul: procedure; parse arg x,y; call quatXY y +return x.1*y.1-x.2*y.2-x.3*y.3-x.4*y.4 x.1*y.2+x.2*y.1+x.3*y.4-x.4*y.3, + x.1*y.3-x.2*y.4+x.3*y.1+x.4*y.2 x.1*y.4+x.2*y.3-x.3*y.2+x.4*y.1 +/*──────────────────────────────────QUATNEG─────────────────────────────*/ +quatNeg: procedure; parse arg x; call quatXY +return -x.1 (-x.2) (-x.3) (-x.4) +/*──────────────────────────────────QUATNORM────────────────────────────*/ +quatNorm: procedure; parse arg x; call quatXY +return sqrt(x.1**2 + x.2**2 + x.3**2 + x.4**2) +/*──────────────────────────────────QUATSHOW────────────────────────────*/ +quatShow: procedure; parse arg x; call quatXY; quat= + do m=1 for 4; _=x.m; if _==0 then iterate; if _ >=0 then _='+'_ + if m\==1 then _=_||substr('~ijk',m,1) ; quat=strip(quat || _,,'+') + end /*m*/ +say left(arg(3),9) right(arg(2),20) ' ──► ' quat +return quat +/*──────────────────────────────────QUATXY──────────────────────────────*/ +quatXY: do n=1 for 4; x.n=word(word(x,n) 0,1)/1; end /*n*/ +if arg()==1 then do m=1 for 4; y.m=word(word(y,m) 0,1)/1; end /*m*/ +return +/*──────────────────────────────────SQRT subroutine─────────────────────*/ +sqrt: procedure;parse arg x;if x=0 then return 0;d=digits();numeric digits 11 +m.=11;numeric form;p=d+d%4+2;parse value format(x,2,1,,0) 'E0' with g 'E' _ . +g=g*.5'E'_%2; 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 diff --git a/Task/Quaternion-type/Ruby/quaternion-type-1.rb b/Task/Quaternion-type/Ruby/quaternion-type-1.rb new file mode 100644 index 0000000000..8e9c423b96 --- /dev/null +++ b/Task/Quaternion-type/Ruby/quaternion-type-1.rb @@ -0,0 +1,58 @@ +require 'matrix' # For Vector#norm + +class Quaternion + def initialize(*parts) + raise "Invalid number of quaternion parts" unless parts.length == 4 + @parts, @vector = parts, Vector[*parts] + end + + def to_a; @parts; end + def to_s; "Quaternion#{to_a.to_s}" end + def complex_parts; [Complex(*to_a[0..1]), Complex(*to_a[2..3])]; end + def zip(other); to_a.zip(other.to_a); end + + def real; @parts.first; end + def imag; @parts[1..3]; end + def conj; Quaternion.new(real, *imag.map(&:-@)); end + def norm; @vector.norm; end # Or: Math.sqrt(to_a.reduce { |sum, e| sum + e**2 }) # In Rails: Math.sqrt(to_a.sum { e**2 }) + + def ==(other); to_a == other.to_a end + def -@; Quaternion.new(*to_a.map(&:-@)); end + def -(other); self + -other; end + + def +(other) + case other + when Numeric + Quaternion.new(real + other, *imag) + when Quaternion + Quaternion.new(*zip(other).map { |x,y| x + y }) # In Rails: zip(other).map(&:sum) # Or: (vector + other.vector).to_a + end + end + + def *(other) + case other + when Numeric + Quaternion.new(*to_a.map { |x| x * other }) # Or: (vector * other).to_a + when Quaternion + # Multiplication of quaternions in C x C space. See "Cayley-Dickson construction". + a, b, c, d = *complex_parts, *other.complex_parts + x, y = a*c - d.conj*b, a*d + b*c.conj + Quaternion.new(x.real, x.imag, y.real, y.imag) + end + end + + # Coerce is called by Ruby to return a compatible type/receiver when the called method/operation does not accept a Quaternion + def coerce(other) + case other + when Numeric then [Scalar.new(other), self] + else raise TypeError, "#{other.class} can't be coerced into #{self.class}" + end + end + + class Scalar + def initialize(val); @val = val; end + def +(other); other + @val; end + def *(other); other * @val; end + def -(other); Quaternion.new(@val, 0, 0, 0) - other; end + end +end diff --git a/Task/Quaternion-type/Ruby/quaternion-type-2.rb b/Task/Quaternion-type/Ruby/quaternion-type-2.rb new file mode 100644 index 0000000000..d99ddb584c --- /dev/null +++ b/Task/Quaternion-type/Ruby/quaternion-type-2.rb @@ -0,0 +1,38 @@ +irb(main):001:0> require 'quaternion' +=> true +irb(main):002:0> q = Quaternion.new(1,2,3,4) +=> Quaternion[1, 2, 3, 4] +irb(main):003:0> q1 = Quaternion.new(2,3,4,5) +=> Quaternion[2, 3, 4, 5] +irb(main):004:0> q2 = Quaternion.new(3,4,5,6) +=> Quaternion[3, 4, 5, 6] +irb(main):005:0> r = 7 +=> 7 +irb(main):006:0> q.norm +=> 5.477225575051661 +irb(main):007:0> q1.norm +=> 7.3484692283495345 +irb(main):008:0> q2.norm +=> 9.273618495495704 +irb(main):009:0> -q +=> Quaternion[-1, -2, -3, -4] +irb(main):010:0> q.conj +=> Quaternion[1, -2, -3, -4] +irb(main):011:0> q1 + q2 +=> Quaternion[5, 7, 9, 11] +irb(main):012:0> q2 + q1 +=> Quaternion[5, 7, 9, 11] +irb(main):013:0> q + r +=> Quaternion[8, 2, 3, 4] +irb(main):014:0> r + q +=> Quaternion[8, 2, 3, 4] +irb(main):015:0> q * r +=> Quaternion[7, 14, 21, 28] +irb(main):016:0> r * q +=> Quaternion[7, 14, 21, 28] +irb(main):017:0> q1 * q2 +=> Quaternion[-56, 16, 24, 26] +irb(main):018:0> q2 * q1 +=> Quaternion[-56, 18, 20, 28] +irb(main):019:0> q1 * q2 != q2 * q1 +=> true diff --git a/Task/Quaternion-type/Scala/quaternion-type-1.scala b/Task/Quaternion-type/Scala/quaternion-type-1.scala new file mode 100644 index 0000000000..8d912a8272 --- /dev/null +++ b/Task/Quaternion-type/Scala/quaternion-type-1.scala @@ -0,0 +1,36 @@ +case class Quaternion(re:Double =0.0, i:Double =0.0, j:Double =0.0, k:Double =0.0) { + lazy val im=(i, j, k) + private lazy val norm2=re*re + i*i + j*j + k*k + lazy val norm=math.sqrt(norm2) + + def negative=new Quaternion(-re, -i, -j, -k) + def conjugate=new Quaternion(re, -i, -j, -k) + def reciprocal=new Quaternion(re/norm2, -i/norm2, -j/norm2, -k/norm2) + + def +(q:Quaternion)=new Quaternion(re+q.re, i+q.i, j+q.j, k+q.k) + def -(q:Quaternion)=new Quaternion(re-q.re, i-q.i, j-q.j, k-q.k) + def *(q:Quaternion)=new Quaternion( + re*q.re - i*q.i - j*q.j - k*q.k, + re*q.i + i*q.re + j*q.k - k*q.j, + re*q.j - i*q.k + j*q.re + k*q.i, + re*q.k + i*q.j - j*q.i + k*q.re + ) + def /(q:Quaternion)=this*q.reciprocal + + def unary_- = negative + def unary_~ = conjugate + + override def equals(x:Any):Boolean=x match { + case Quaternion(re, i, j, k) => (Double.doubleToLongBits(this.re)==Double.doubleToLongBits(re)) && + Double.doubleToLongBits(this.i)==Double.doubleToLongBits(i) && + Double.doubleToLongBits(this.j)==Double.doubleToLongBits(j) && + Double.doubleToLongBits(this.k)==Double.doubleToLongBits(k) + case _ => false + } + + override def toString()="Q(%.2f, %.2fi, %.2fj, %.2fk)".formatLocal(Locale.ENGLISH, re,i,j,k) +} + +object Quaternion { + implicit def number2Quaternion[T <% Number](n:T):Quaternion = apply(n.doubleValue) +} diff --git a/Task/Quaternion-type/Scala/quaternion-type-2.scala b/Task/Quaternion-type/Scala/quaternion-type-2.scala new file mode 100644 index 0000000000..18c1d11132 --- /dev/null +++ b/Task/Quaternion-type/Scala/quaternion-type-2.scala @@ -0,0 +1,35 @@ +val q0=Quaternion(1.0, 2.0, 3.0, 4.0); +val q1=Quaternion(2.0, 3.0, 4.0, 5.0); +val q2=Quaternion(3.0, 4.0, 5.0, 6.0); +val r=7; + +println("q0 = "+ q0) +println("q1 = "+ q1) +println("q2 = "+ q2) +println("r = "+ r) +println() + +println("q0.re = "+ q0.re) +println("q0.im = "+ q0.im) +println("q0.norm = "+ q0.norm) +println("q0.negative = "+ q0.negative) +println("-q0 = "+ -q0) +println("q0.conjugate = "+ q0.conjugate) +println("~q0 = "+ ~q0) +println("q1+q2 = "+ (q1+q2)) +println("q2+q1 = "+ (q2+q1)) +println("q1+r = "+ (q1+r)) +println("r+q1 = "+ (r+q1)) +println("q1-q2 = "+ (q1-q2)) +println("q2-q1 = "+ (q2-q1)) +println("q1-r = "+ (q1-r)) +println("r-q1 = "+ (r-q1)) +println("q1*q2 = "+ q1*q2) +println("q2*q1 = "+ q2*q1) +println("q1*r = "+ q1*r) +println("r*q1 = "+ r*q1) +println("(q1*q2)!=(q2*q1) = "+ ((q1*q2)!=(q2*q1))) +println("q1/q2 = "+ q1/q2) +println("q2/q1 = "+ q2/q1) +println("q1/r = "+ q1/r) +println("r/q1 = "+ r/q1) diff --git a/Task/Quaternion-type/Tcl/quaternion-type-1.tcl b/Task/Quaternion-type/Tcl/quaternion-type-1.tcl new file mode 100644 index 0000000000..abdd891df4 --- /dev/null +++ b/Task/Quaternion-type/Tcl/quaternion-type-1.tcl @@ -0,0 +1,99 @@ +package require TclOO + +# Support class that provides C++-like RAII lifetimes +oo::class create RAII-support { + constructor {} { + upvar 1 { end } end + lappend end [self] + trace add variable end unset [namespace code {my destroy}] + } + destructor { + catch { + upvar 1 { end } end + trace remove variable end unset [namespace code {my destroy}] + } + } + method return {{level 1}} { + incr level + upvar 1 { end } end + upvar $level { end } parent + trace remove variable end unset [namespace code {my destroy}] + lappend parent [self] + trace add variable parent unset [namespace code {my destroy}] + return -level $level [self] + } +} + +# Class of quaternions +oo::class create Q { + superclass RAII-support + variable R I J K + constructor {{real 0} {i 0} {j 0} {k 0}} { + next + namespace import ::tcl::mathfunc::* ::tcl::mathop::* + variable R [double $real] I [double $i] J [double $j] K [double $k] + } + self method return args { + [my new {*}$args] return 2 + } + + method p {} { + return "Q($R,$I,$J,$K)" + } + method values {} { + list $R $I $J $K + } + + method Norm {} { + + [* $R $R] [* $I $I] [* $J $J] [* $K $K] + } + + method conjugate {} { + Q return $R [- $I] [- $J] [- $K] + } + method norm {} { + sqrt [my Norm] + } + method unit {} { + set n [my norm] + Q return [/ $R $n] [/ $I $n] [/ $J $n] [/ $K $n] + } + method reciprocal {} { + set n2 [my Norm] + Q return [/ $R $n2] [/ $I $n2] [/ $J $n2] [/ $K $n2] + } + method - {{q ""}} { + if {[llength [info level 0]] == 2} { + Q return [- $R] [- $I] [- $J] [- $K] + } + [my + [$q -]] return + } + method + q { + if {[info object isa object $q]} { + lassign [$q values] real i j k + Q return [+ $R $real] [+ $I $i] [+ $J $j] [+ $K $k] + } + Q return [+ $R [double $q]] $I $J $K + } + method * q { + if {[info object isa object $q]} { + lassign [my values] a1 b1 c1 d1 + lassign [$q values] a2 b2 c2 d2 + Q return [expr {$a1*$a2 - $b1*$b2 - $c1*$c2 - $d1*$d2}] \ + [expr {$a1*$b2 + $b1*$a2 + $c1*$d2 - $d1*$c2}] \ + [expr {$a1*$c2 - $b1*$d2 + $c1*$a2 + $d1*$b2}] \ + [expr {$a1*$d2 + $b1*$c2 - $c1*$b2 + $d1*$a2}] + } + set f [double $q] + Q return [* $R $f] [* $I $f] [* $J $f] [* $K $f] + } + method == q { + expr { + [info object isa object $q] + && [info object isa typeof $q [self class]] + && [my values] eq [$q values] + } + } + + export - + * == +} diff --git a/Task/Quaternion-type/Tcl/quaternion-type-2.tcl b/Task/Quaternion-type/Tcl/quaternion-type-2.tcl new file mode 100644 index 0000000000..883ead1dd2 --- /dev/null +++ b/Task/Quaternion-type/Tcl/quaternion-type-2.tcl @@ -0,0 +1,22 @@ +set q [Q new 1 2 3 4] +set q1 [Q new 2 3 4 5] +set q2 [Q new 3 4 5 6] +set r 7 + +puts "q = [$q p]" +puts "q1 = [$q1 p]" +puts "q2 = [$q2 p]" +puts "r = $r" +puts "q norm = [$q norm]" +puts "q1 norm = [$q1 norm]" +puts "q2 norm = [$q2 norm]" +puts "-q = [[$q -] p]" +puts "q conj = [[$q conjugate] p]" +puts "q + r = [[$q + $r] p]" +# Real numbers are not objects, so no extending operations for them +puts "q1 + q2 = [[$q1 + $q2] p]" +puts "q2 + q1 = [[$q2 + $q1] p]" +puts "q * r = [[$q * $r] p]" +puts "q1 * q2 = [[$q1 * $q2] p]" +puts "q2 * q1 = [[$q2 * $q1] p]" +puts "equal(q1*q2, q2*q1) = [[$q1 * $q2] == [$q2 * $q1]]" diff --git a/Task/Queue-Definition/0DESCRIPTION b/Task/Queue-Definition/0DESCRIPTION new file mode 100644 index 0000000000..7908d63f52 --- /dev/null +++ b/Task/Queue-Definition/0DESCRIPTION @@ -0,0 +1,13 @@ +{{Data structure}} +[[File:Fifo.gif|frame|right|Illustration of FIFO behavior]] +Implement a FIFO queue. Elements are added at one side and popped from the other in the order of insertion. + +Operations: +* push (aka ''enqueue'') - add element +* pop (aka ''dequeue'') - pop first element +* empty - return truth value when empty + +Errors: +* handle the error of trying to pop from an empty queue (behavior depends on the language and platform) + +See [[Queue/Usage]] for the built-in FIFO or queue of your language or standard library. diff --git a/Task/Queue-Definition/1META.yaml b/Task/Queue-Definition/1META.yaml new file mode 100644 index 0000000000..32d20151af --- /dev/null +++ b/Task/Queue-Definition/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Data Structures diff --git a/Task/Queue-Definition/ACL2/queue-definition.acl2 b/Task/Queue-Definition/ACL2/queue-definition.acl2 new file mode 100644 index 0000000000..5ac487b146 --- /dev/null +++ b/Task/Queue-Definition/ACL2/queue-definition.acl2 @@ -0,0 +1,14 @@ +(defun enqueue (x xs) + (cons x xs)) + +(defun dequeue (xs) + (declare (xargs :guard (and (consp xs) + (true-listp xs)))) + (if (or (endp xs) (endp (rest xs))) + (mv (first xs) nil) + (mv-let (x ys) + (dequeue (rest xs)) + (mv x (cons (first xs) ys))))) + +(defun empty (xs) + (endp xs)) diff --git a/Task/Queue-Definition/AWK/queue-definition.awk b/Task/Queue-Definition/AWK/queue-definition.awk new file mode 100644 index 0000000000..bf85aed6a5 --- /dev/null +++ b/Task/Queue-Definition/AWK/queue-definition.awk @@ -0,0 +1,32 @@ +#!/usr/bin/awk -f + +BEGIN { + delete q + print "empty? " emptyP() + print "push " push("a") + print "push " push("b") + print "empty? " emptyP() + print "pop " pop() + print "pop " pop() + print "empty? " emptyP() + print "pop " pop() +} + +function push(n) { + q[length(q)+1] = n + return n +} + +function pop() { + if (emptyP()) { + print "Popping from empty queue." + exit + } + r = q[length(q)] + delete q[length(q)] + return r +} + +function emptyP() { + return length(q) == 0 +} diff --git a/Task/Queue-Definition/Ada/queue-definition-1.ada b/Task/Queue-Definition/Ada/queue-definition-1.ada new file mode 100644 index 0000000000..7d7df10c0e --- /dev/null +++ b/Task/Queue-Definition/Ada/queue-definition-1.ada @@ -0,0 +1,20 @@ +generic + type Element_Type is private; +package Fifo is + type Fifo_Type is private; + procedure Push(List : in out Fifo_Type; Item : in Element_Type); + procedure Pop(List : in out Fifo_Type; Item : out Element_Type); + function Is_Empty(List : Fifo_Type) return Boolean; + Empty_Error : exception; +private + type Fifo_Element; + type Fifo_Ptr is access Fifo_Element; + type Fifo_Type is record + Head : Fifo_Ptr := null; + Tail : Fifo_Ptr := null; + end record; + type Fifo_Element is record + Value : Element_Type; + Next : Fifo_Ptr := null; + end record; +end Fifo; diff --git a/Task/Queue-Definition/Ada/queue-definition-10.ada b/Task/Queue-Definition/Ada/queue-definition-10.ada new file mode 100644 index 0000000000..d2a81eaebc --- /dev/null +++ b/Task/Queue-Definition/Ada/queue-definition-10.ada @@ -0,0 +1,11 @@ +generic + type Element_Type is private; +package Asynchronous_Fifo is + protected type Fifo is + procedure Push(Item : Element_Type); + entry Pop(Item : out Element_Type); + private + Value : Element_Type; + Valid : Boolean := False; + end Fifo; +end Asynchronous_Fifo; diff --git a/Task/Queue-Definition/Ada/queue-definition-11.ada b/Task/Queue-Definition/Ada/queue-definition-11.ada new file mode 100644 index 0000000000..15e6f5f53e --- /dev/null +++ b/Task/Queue-Definition/Ada/queue-definition-11.ada @@ -0,0 +1,30 @@ +package body Asynchronous_Fifo is + + ---------- + -- Fifo -- + ---------- + + protected body Fifo is + + ---------- + -- Push -- + ---------- + + procedure Push (Item : Element_Type) is + begin + Value := Item; + Valid := True; + end Push; + + --------- + -- Pop -- + --------- + + entry Pop (Item : out Element_Type) when Valid is + begin + Item := Value; + end Pop; + + end Fifo; + +end Asynchronous_Fifo; diff --git a/Task/Queue-Definition/Ada/queue-definition-12.ada b/Task/Queue-Definition/Ada/queue-definition-12.ada new file mode 100644 index 0000000000..e54fa26340 --- /dev/null +++ b/Task/Queue-Definition/Ada/queue-definition-12.ada @@ -0,0 +1,48 @@ +with Asynchronous_Fifo; +with Ada.Text_Io; use Ada.Text_Io; + + procedure Asynchronous_Fifo_Test is + package Int_Fifo is new Asynchronous_Fifo(Integer); + use Int_Fifo; + Buffer : Fifo; + + task Writer is + entry Stop; + end Writer; + + task body Writer is + Val : Positive := 1; + begin + loop + select + accept Stop; + exit; + else + Buffer.Push(Val); + Val := Val + 1; + end select; + end loop; + end Writer; + + task Reader is + entry Stop; + end Reader; + + task body Reader is + Val : Positive; + begin + loop + select + accept Stop; + exit; + else + Buffer.Pop(Val); + Put_Line(Integer'Image(Val)); + end select; + end loop; + end Reader; + begin + delay 0.1; + Writer.Stop; + Reader.Stop; + end Asynchronous_Fifo_Test; diff --git a/Task/Queue-Definition/Ada/queue-definition-2.ada b/Task/Queue-Definition/Ada/queue-definition-2.ada new file mode 100644 index 0000000000..76ffbc152a --- /dev/null +++ b/Task/Queue-Definition/Ada/queue-definition-2.ada @@ -0,0 +1,49 @@ +with Ada.Unchecked_Deallocation; + +package body Fifo is + + ---------- + -- Push -- + ---------- + + procedure Push (List : in out Fifo_Type; Item : in Element_Type) is + Temp : Fifo_Ptr := new Fifo_Element'(Item, null); + begin + if List.Tail = null then + List.Tail := Temp; + end if; + if List.Head /= null then + List.Head.Next := Temp; + end if; + List.Head := Temp; + end Push; + + --------- + -- Pop -- + --------- + + procedure Pop (List : in out Fifo_Type; Item : out Element_Type) is + procedure Free is new Ada.Unchecked_Deallocation(Fifo_Element, Fifo_Ptr); + Temp : Fifo_Ptr := List.Tail; + begin + if List.Head = null then + raise Empty_Error; + end if; + Item := List.Tail.Value; + List.Tail := List.Tail.Next; + if List.Tail = null then + List.Head := null; + end if; + Free(Temp); + end Pop; + + -------------- + -- Is_Empty -- + -------------- + + function Is_Empty (List : Fifo_Type) return Boolean is + begin + return List.Head = null; + end Is_Empty; + +end Fifo; diff --git a/Task/Queue-Definition/Ada/queue-definition-3.ada b/Task/Queue-Definition/Ada/queue-definition-3.ada new file mode 100644 index 0000000000..daa6974781 --- /dev/null +++ b/Task/Queue-Definition/Ada/queue-definition-3.ada @@ -0,0 +1,17 @@ +with Fifo; +with Ada.Text_Io; use Ada.Text_Io; + +procedure Fifo_Test is + package Int_Fifo is new Fifo(Integer); + use Int_Fifo; + My_Fifo : Fifo_Type; + Val : Integer; +begin + for I in 1..10 loop + Push(My_Fifo, I); + end loop; + while not Is_Empty(My_Fifo) loop + Pop(My_Fifo, Val); + Put_Line(Integer'Image(Val)); + end loop; +end Fifo_Test; diff --git a/Task/Queue-Definition/Ada/queue-definition-4.ada b/Task/Queue-Definition/Ada/queue-definition-4.ada new file mode 100644 index 0000000000..de3e5941e4 --- /dev/null +++ b/Task/Queue-Definition/Ada/queue-definition-4.ada @@ -0,0 +1,13 @@ + with Ada.Containers.Doubly_Linked_Lists; + generic + type Element_Type is private; + package Generic_Fifo is + type Fifo_Type is tagged private; + procedure Push(The_Fifo : in out Fifo_Type; Item : in Element_Type); + procedure Pop(The_Fifo : in out Fifo_Type; Item : out Element_Type); + Empty_Error : Exception; + private + package List_Pkg is new Ada.Containers.Doubly_Linked_Lists(Element_Type); + use List_Pkg; + Type Fifo_Type is new List with null record; + end Generic_Fifo; diff --git a/Task/Queue-Definition/Ada/queue-definition-5.ada b/Task/Queue-Definition/Ada/queue-definition-5.ada new file mode 100644 index 0000000000..3cb8fa9179 --- /dev/null +++ b/Task/Queue-Definition/Ada/queue-definition-5.ada @@ -0,0 +1,25 @@ + package body Generic_Fifo is + + ---------- + -- Push -- + ---------- + + procedure Push (The_Fifo : in out Fifo_Type; Item : in Element_Type) is + begin + The_Fifo.Prepend(Item); + end Push; + + --------- + -- Pop -- + --------- + + procedure Pop (The_Fifo : in out Fifo_Type; Item : out Element_Type) is + begin + if Is_Empty(The_Fifo) then + raise Empty_Error; + end if; + Item := The_Fifo.Last_Element; + The_Fifo.Delete_Last; + end Pop; + + end Generic_Fifo; diff --git a/Task/Queue-Definition/Ada/queue-definition-6.ada b/Task/Queue-Definition/Ada/queue-definition-6.ada new file mode 100644 index 0000000000..054ab54be7 --- /dev/null +++ b/Task/Queue-Definition/Ada/queue-definition-6.ada @@ -0,0 +1,17 @@ +with Generic_Fifo; +with Ada.Text_Io; use Ada.Text_Io; + +procedure Generic_Fifo_Test is + package Int_Fifo is new Generic_Fifo(Integer); + use Int_Fifo; + My_Fifo : Fifo_Type; + Val : Integer; +begin + for I in 1..10 loop + My_Fifo.Push(I); + end loop; + while not My_Fifo.Is_Empty loop + My_Fifo.Pop(Val); + Put_Line(Integer'Image(Val)); + end loop; +end Generic_Fifo_Test; diff --git a/Task/Queue-Definition/Ada/queue-definition-7.ada b/Task/Queue-Definition/Ada/queue-definition-7.ada new file mode 100644 index 0000000000..baa4255d5c --- /dev/null +++ b/Task/Queue-Definition/Ada/queue-definition-7.ada @@ -0,0 +1,11 @@ +generic + type Element_Type is private; +package Synchronous_Fifo is + protected type Fifo is + entry Push(Item : Element_Type); + entry Pop(Item : out Element_Type); + private + Value : Element_Type; + Is_New : Boolean := False; + end Fifo; +end Synchronous_Fifo; diff --git a/Task/Queue-Definition/Ada/queue-definition-8.ada b/Task/Queue-Definition/Ada/queue-definition-8.ada new file mode 100644 index 0000000000..843f75c35a --- /dev/null +++ b/Task/Queue-Definition/Ada/queue-definition-8.ada @@ -0,0 +1,31 @@ +package body Synchronous_Fifo is + + ---------- + -- Fifo -- + ---------- + + protected body Fifo is + + --------- + -- Push -- + --------- + + entry Push (Item : Element_Type) when not Is_New is + begin + Value := Item; + Is_New := True; + end Push; + + --------- + -- Pop -- + --------- + + entry Pop (Item : out Element_Type) when Is_New is + begin + Item := Value; + Is_New := False; + end Pop; + + end Fifo; + +end Synchronous_Fifo; diff --git a/Task/Queue-Definition/Ada/queue-definition-9.ada b/Task/Queue-Definition/Ada/queue-definition-9.ada new file mode 100644 index 0000000000..25ef455035 --- /dev/null +++ b/Task/Queue-Definition/Ada/queue-definition-9.ada @@ -0,0 +1,56 @@ +with Synchronous_Fifo; +with Ada.Text_Io; use Ada.Text_Io; + + procedure Synchronous_Fifo_Test is + package Int_Fifo is new Synchronous_Fifo(Integer); + use Int_Fifo; + Buffer : Fifo; + + task Writer is + entry Stop; + end Writer; + + task body Writer is + Val : Positive := 1; + begin + loop + select + accept Stop; + exit; + else + select + Buffer.Push(Val); + Val := Val + 1; + or + delay 1.0; + end select; + end select; + end loop; + end Writer; + + task Reader is + entry Stop; + end Reader; + + task body Reader is + Val : Positive; + begin + loop + select + accept Stop; + exit; + else + select + Buffer.Pop(Val); + Put_Line(Integer'Image(Val)); + or + delay 1.0; + end select; + end select; + end loop; + end Reader; + begin + delay 0.1; + Writer.Stop; + Reader.Stop; + end Synchronous_Fifo_Test; diff --git a/Task/Queue-Definition/AutoHotkey/queue-definition.ahk b/Task/Queue-Definition/AutoHotkey/queue-definition.ahk new file mode 100644 index 0000000000..6fc1bdc069 --- /dev/null +++ b/Task/Queue-Definition/AutoHotkey/queue-definition.ahk @@ -0,0 +1,31 @@ +push("qu", 2), push("qu", 44), push("qu", "xyz") ; TEST + +MsgBox % "Len = " len("qu") ; Number of entries +While !empty("qu") ; Repeat until queue is not empty + MsgBox % pop("qu") ; Print popped values (2, 44, xyz) +MsgBox Error = %ErrorLevel% ; ErrorLevel = 0: OK +MsgBox % pop("qu") ; Empty +MsgBox Error = %ErrorLevel% ; ErrorLevel = -1: popped too much +MsgBox % "Len = " len("qu") ; Number of entries + +push(queue,_) { ; push _ onto queue named "queue" (!=_), _ string not containing | + Global + %queue% .= %queue% = "" ? _ : "|" _ +} + +pop(queue) { ; pop value from queue named "queue" (!=_,_1,_2) + Global + RegExMatch(%queue%, "([^\|]*)\|?(.*)", _) + Return _1, ErrorLevel := -(%queue%=""), %queue% := _2 +} + +empty(queue) { ; check if queue named "queue" is empty + Global + Return %queue% = "" +} + +len(queue) { ; number of entries in "queue" + Global + StringReplace %queue%, %queue%, |, |, UseErrorLevel + Return %queue% = "" ? 0 : ErrorLevel+1 +} diff --git a/Task/Queue-Definition/BBC-BASIC/queue-definition.bbc b/Task/Queue-Definition/BBC-BASIC/queue-definition.bbc new file mode 100644 index 0000000000..a4cdba0721 --- /dev/null +++ b/Task/Queue-Definition/BBC-BASIC/queue-definition.bbc @@ -0,0 +1,31 @@ + FIFOSIZE = 1000 + + FOR n = 3 TO 5 + PRINT "Push ";n : PROCenqueue(n) + NEXT + PRINT "Pop " ; FNdequeue + PRINT "Push 6" : PROCenqueue(6) + REPEAT + PRINT "Pop " ; FNdequeue + UNTIL FNisempty + PRINT "Pop " ; FNdequeue + END + + DEF PROCenqueue(n) : LOCAL f% + DEF FNdequeue : LOCAL f% : f% = 1 + DEF FNisempty : LOCAL f% : f% = 2 + PRIVATE fifo(), rptr%, wptr% + DIM fifo(FIFOSIZE-1) + CASE f% OF + WHEN 0: + wptr% = (wptr% + 1) MOD FIFOSIZE + IF rptr% = wptr% ERROR 100, "Error: queue overflowed" + fifo(wptr%) = n + WHEN 1: + IF rptr% = wptr% ERROR 101, "Error: queue empty" + rptr% = (rptr% + 1) MOD FIFOSIZE + = fifo(rptr%) + WHEN 2: + = (rptr% = wptr%) + ENDCASE + ENDPROC diff --git a/Task/Queue-Definition/Batch-File/queue-definition.bat b/Task/Queue-Definition/Batch-File/queue-definition.bat new file mode 100644 index 0000000000..55c393943f --- /dev/null +++ b/Task/Queue-Definition/Batch-File/queue-definition.bat @@ -0,0 +1,69 @@ +@echo off +setlocal enableDelayedExpansion + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: FIFO queue usage + +:: Define the queue +call :newQueue myQ + +:: Populate the queue +for %%A in (value1 value2 value3) do call :enqueue myQ %%A + +:: Test if queue is empty by examining the tail "attribute" +if myQ.tail==0 (echo myQ is empty) else (echo myQ is NOT empty) + +:: Peek at the head of the queue +call:peekQueue myQ val && echo a peek at the head of myQueue shows !val! + +:: Process the first queue value +call :dequeue myQ val && echo dequeued myQ value=!val! + +:: Add some more values to the queue +for %%A in (value4 value5 value6) do call :enqueue myQ %%A + +:: Process the remainder of the queue +:processQueue +call :dequeue myQ val || goto :queueEmpty +echo dequeued myQ value=!val! +goto :processQueue +:queueEmpty + +:: Test if queue is empty using the empty "method"/"macro". Use of the +:: second IF statement serves to demonstrate the negation of the empty +:: "method". A single IF could have been used with an ELSE clause instead. +if %myQ.empty% echo myQ is empty +if not %myQ.empty% echo myQ is NOT empty +exit /b + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: FIFO queue definition + +:newQueue qName +set /a %~1.head=1, %~1.tail=0 +:: Define an empty "method" for this queue as a sort of macro +set "%~1.empty=^!%~1.tail^! == 0" +exit /b + +:enqueue qName value +set /a %~1.tail+=1 +set %~1.!%~1.tail!=%2 +exit /b + +:dequeue qName returnVar +:: Sets errorlevel to 0 if success +:: Sets errorlevel to 1 if failure because queue was empty +if !%~1.tail! equ 0 exit /b 1 +for %%N in (!%~1.head!) do ( + set %~2=!%~1.%%N! + set %~1.%%N= +) +if !%~1.head! == !%~1.tail! (set /a "%~1.head=1, %~1.tail=0") else set /a %~1.head+=1 +exit /b 0 + +:peekQueue qName returnVar +:: Sets errorlevel to 0 if success +:: Sets errorlevel to 1 if failure because queue was empty +if !%~1.tail! equ 0 exit /b 1 +for %%N in (!%~1.head!) do set %~2=!%~1.%%N! +exit /b 0 diff --git a/Task/Queue-Definition/C++/queue-definition.cpp b/Task/Queue-Definition/C++/queue-definition.cpp new file mode 100644 index 0000000000..e0e7f0e896 --- /dev/null +++ b/Task/Queue-Definition/C++/queue-definition.cpp @@ -0,0 +1,67 @@ +namespace rosettacode +{ + template class queue + { + public: + queue(); + ~queue(); + void push(T const& t); + T pop(); + bool empty(); + private: + void drop(); + struct node; + node* head; + node* tail; + }; + + template struct queue::node + { + T data; + node* next; + node(T const& t): data(t), next(0) {} + }; + + template + queue::queue(): + head(0) + { + } + + template + inline void queue::drop() + { + node* n = head; + head = head->next; + delete n; + } + + template + queue::~queue() + { + while (!empty()) + drop(); + } + + template + void queue::push(T const& t) + { + node*& next = head? tail->next : head; + next = new node(t); + tail = next; + } + + template + T queue::pop() + { + T tmp = head->data; + drop(); + return tmp; + } + + template + bool queue::empty() + { + return head == 0; + } +} diff --git a/Task/Queue-Definition/C-sharp/queue-definition.cs b/Task/Queue-Definition/C-sharp/queue-definition.cs new file mode 100644 index 0000000000..bb34ade504 --- /dev/null +++ b/Task/Queue-Definition/C-sharp/queue-definition.cs @@ -0,0 +1,38 @@ +public class FIFO +{ + class Node + { + public T Item { get; set; } + public Node Next { get; set; } + } + Node first = null; + Node last = null; + public void push(T item) + { + if (empty()) + { + //Uses object initializers to set fields of new node + first = new Node() { Item = item, Next = null }; + last = first; + } + else + { + last.Next = new Node() { Item = item, Next = null }; + last = last.Next; + } + } + public T pop() + { + if (first == null) + throw new System.Exception("No elements"); + if (last == first) + last = null; + T temp = first.Item; + first = first.Next; + return temp; + } + public bool empty() + { + return first == null; + } +} diff --git a/Task/Queue-Definition/C/queue-definition-1.c b/Task/Queue-Definition/C/queue-definition-1.c new file mode 100644 index 0000000000..fd4dd69a3f --- /dev/null +++ b/Task/Queue-Definition/C/queue-definition-1.c @@ -0,0 +1,50 @@ +#include +#include +#include + +typedef int DATA; /* type of data to store in queue */ +typedef struct { + DATA *buf; + size_t head, tail, alloc; +} queue_t, *queue; + +queue q_new() +{ + queue q = malloc(sizeof(queue_t)); + q->buf = malloc(sizeof(DATA) * (q->alloc = 4)); + q->head = q->tail = 0; + return q; +} + +int empty(queue q) +{ + return q->tail == q->head; +} + +void enqueue(queue q, DATA n) +{ + if (q->tail >= q->alloc) q->tail = 0; + q->buf[q->tail++] = n; + if (q->tail == q->head) { /* needs more room */ + q->buf = realloc(q->buf, sizeof(DATA) * q->alloc * 2); + if (q->head) { + memcpy(q->buf + q->head + q->alloc, q->buf + q->head, + sizeof(DATA) * (q->alloc - q->head)); + q->head += q->alloc; + } else + q->tail = q->alloc; + q->alloc *= 2; + } +} + +int dequeue(queue q, DATA *n) +{ + if (q->head == q->tail) return 0; + *n = q->buf[q->head++]; + if (q->head >= q->alloc) { /* reduce allocated storage no longer needed */ + q->head = 0; + if (q->alloc >= 512 && q->tail < q->alloc / 2) + q->buf = realloc(q->buf, sizeof(DATA) * (q->alloc/=2)); + } + return 1; +} diff --git a/Task/Queue-Definition/C/queue-definition-2.c b/Task/Queue-Definition/C/queue-definition-2.c new file mode 100644 index 0000000000..37aa06ad99 --- /dev/null +++ b/Task/Queue-Definition/C/queue-definition-2.c @@ -0,0 +1,43 @@ +#include +#include + +typedef struct node_t node_t, *node, *queue; +struct node_t { int val; node prev, next; }; + +#define HEAD(q) q->prev +#define TAIL(q) q->next +queue q_new() +{ + node q = malloc(sizeof(node_t)); + q->next = q->prev = 0; + return q; +} + +int empty(queue q) +{ + return !HEAD(q); +} + +void enqueue(queue q, int n) +{ + node nd = malloc(sizeof(node_t)); + nd->val = n; + if (!HEAD(q)) HEAD(q) = nd; + nd->prev = TAIL(q); + if (nd->prev) nd->prev->next = nd; + TAIL(q) = nd; + nd->next = 0; +} + +int dequeue(queue q, int *val) +{ + node tmp = HEAD(q); + if (!tmp) return 0; + *val = tmp->val; + + HEAD(q) = tmp->next; + if (TAIL(q) == tmp) TAIL(q) = 0; + free(tmp); + + return 1; +} diff --git a/Task/Queue-Definition/C/queue-definition-3.c b/Task/Queue-Definition/C/queue-definition-3.c new file mode 100644 index 0000000000..0fa1a53f80 --- /dev/null +++ b/Task/Queue-Definition/C/queue-definition-3.c @@ -0,0 +1,22 @@ +int main() +{ + int i, n; + queue q = q_new(); + + for (i = 0; i < 100000000; i++) { + n = rand(); + if (n > RAND_MAX / 2) { + // printf("+ %d\n", n); + enqueue(q, n); + } else { + if (!dequeue(q, &n)) { + // printf("empty\n"); + continue; + } + // printf("- %d\n", n); + } + } + while (dequeue(q, &n));// printf("- %d\n", n); + + return 0; +} diff --git a/Task/Queue-Definition/C/queue-definition-4.c b/Task/Queue-Definition/C/queue-definition-4.c new file mode 100644 index 0000000000..e8f307fe90 --- /dev/null +++ b/Task/Queue-Definition/C/queue-definition-4.c @@ -0,0 +1,47 @@ +#include +#include +#include + +#include + +struct entry { + int value; + TAILQ_ENTRY(entry) entries; +}; + +typedef struct entry entry_t; + +TAILQ_HEAD(FIFOList_s, entry); + +typedef struct FIFOList_s FIFOList; + + +bool m_enqueue(int v, FIFOList *l) +{ + entry_t *val; + val = malloc(sizeof(entry_t)); + if ( val != NULL ) { + val->value = v; + TAILQ_INSERT_TAIL(l, val, entries); + return true; + } + return false; +} + +bool m_dequeue(int *v, FIFOList *l) +{ + entry_t *e = l->tqh_first; + if ( e != NULL ) { + *v = e->value; + TAILQ_REMOVE(l, e, entries); + free(e); + return true; + } + return false; +} + +bool isQueueEmpty(FIFOList *l) +{ + if ( l->tqh_first == NULL ) return true; + return false; +} diff --git a/Task/Queue-Definition/Clojure/queue-definition.clj b/Task/Queue-Definition/Clojure/queue-definition.clj new file mode 100644 index 0000000000..e09687db7c --- /dev/null +++ b/Task/Queue-Definition/Clojure/queue-definition.clj @@ -0,0 +1,15 @@ +(defn make-queue [] + (atom [])) + +(defn enqueue [q x] + (swap! q conj x)) + +(defn dequeue [q] + (if (seq @q) + (let [x (first @q)] + (swap! q subvec 1) + x) + (throw (IllegalStateException. "Can't pop an empty queue.")))) + +(defn queue-empty? [q] + (empty? @q)) diff --git a/Task/Queue-Definition/CoffeeScript/queue-definition-1.coffeescript b/Task/Queue-Definition/CoffeeScript/queue-definition-1.coffeescript new file mode 100644 index 0000000000..46b538ac3c --- /dev/null +++ b/Task/Queue-Definition/CoffeeScript/queue-definition-1.coffeescript @@ -0,0 +1,38 @@ +# Implement a fifo as an array of arrays, to +# greatly amortize dequeue costs, at some expense of +# memory overhead and insertion time. The speedup +# depends on the underlying JS implementation, but +# it's significant on node.js. +Fifo = -> + max_chunk = 512 + arr = [] # array of arrays + count = 0 + + self = + enqueue: (elem) -> + if count == 0 or arr[arr.length-1].length >= max_chunk + arr.push [] + count += 1 + arr[arr.length-1].push elem + dequeue: (elem) -> + throw Error("queue is empty") if count == 0 + val = arr[0].shift() + count -= 1 + if arr[0].length == 0 + arr.shift() + val + is_empty: (elem) -> + count == 0 + +# test +do -> + max = 5000000 + q = Fifo() + for i in [1..max] + q.enqueue + number: i + + console.log q.dequeue() + while !q.is_empty() + v = q.dequeue() + console.log v diff --git a/Task/Queue-Definition/CoffeeScript/queue-definition-2.coffeescript b/Task/Queue-Definition/CoffeeScript/queue-definition-2.coffeescript new file mode 100644 index 0000000000..816f29aa77 --- /dev/null +++ b/Task/Queue-Definition/CoffeeScript/queue-definition-2.coffeescript @@ -0,0 +1,7 @@ +> time coffee fifo.coffee +{ number: 1 } +{ number: 5000000 } + +real 0m2.394s +user 0m2.089s +sys 0m0.265s diff --git a/Task/Queue-Definition/Common-Lisp/queue-definition.lisp b/Task/Queue-Definition/Common-Lisp/queue-definition.lisp new file mode 100644 index 0000000000..70238ca5df --- /dev/null +++ b/Task/Queue-Definition/Common-Lisp/queue-definition.lisp @@ -0,0 +1,26 @@ +(defstruct (queue (:constructor %make-queue)) + (items '() :type list) + (tail '() :type list)) + +(defun make-queue () + "Returns an empty queue." + (%make-queue)) + +(defun queue-empty-p (queue) + "Returns true if the queue is empty." + (endp (queue-items queue))) + +(defun enqueue (item queue) + "Enqueue item in queue. Returns the queue." + (prog1 queue + (if (queue-empty-p queue) + (setf (queue-items queue) (list item) + (queue-tail queue) (queue-items queue)) + (setf (cdr (queue-tail queue)) (list item) + (queue-tail queue) (cdr (queue-tail queue)))))) + +(defun dequeue (queue) + "Dequeues an item from queue. Signals an error if queue is empty." + (if (queue-empty-p queue) + (error "Cannot dequeue from empty queue.") + (pop (queue-items queue)))) diff --git a/Task/Queue-Definition/E/queue-definition.e b/Task/Queue-Definition/E/queue-definition.e new file mode 100644 index 0000000000..d4146bb8b0 --- /dev/null +++ b/Task/Queue-Definition/E/queue-definition.e @@ -0,0 +1,27 @@ +def makeQueue() { + def [var head, var tail] := Ref.promise() + + def writer { + to enqueue(value) { + def [nh, nt] := Ref.promise() + tail.resolve([value, nh]) + tail := nt + } + } + + def reader { + to empty() { return !Ref.isResolved(head) } + + to dequeue(whenEmpty) { + if (Ref.isResolved(head)) { + def [value, next] := head + head := next + return value + } else { + throw.eject(whenEmpty, "pop() of empty queue") + } + } + } + + return [reader, writer] +} diff --git a/Task/Queue-Definition/Elisa/queue-definition-1.elisa b/Task/Queue-Definition/Elisa/queue-definition-1.elisa new file mode 100644 index 0000000000..fbce757f72 --- /dev/null +++ b/Task/Queue-Definition/Elisa/queue-definition-1.elisa @@ -0,0 +1,23 @@ +component GenericQueue ( Queue, Element ); + type Queue; + Queue (MaxLength = integer) -> Queue; + Length( Queue ) -> integer; + Empty ( Queue ) -> boolean; + Full ( Queue ) -> boolean; + Push ( Queue, Element) -> nothing; + Pull ( Queue ) -> Element; +begin + Queue (MaxLength) = Queue:[ MaxLength; length:=0; list=alist(Element) ]; + Length ( queue ) = queue.length; + Empty ( queue ) = (queue.length <= 0); + Full ( queue ) = (queue.length >= queue.MaxLength); + + Push ( queue, element ) = + [ exception (Full(queue), "Queue Overflow"); + queue.length:= queue.length + 1; + add (queue.list, element)]; + Pull ( queue ) = + [ exception (Empty(queue), "Queue Underflow"); + queue.length:= queue.length - 1; + remove(first(queue.list))]; +end component GenericQueue; diff --git a/Task/Queue-Definition/Elisa/queue-definition-2.elisa b/Task/Queue-Definition/Elisa/queue-definition-2.elisa new file mode 100644 index 0000000000..66e9a8dd2b --- /dev/null +++ b/Task/Queue-Definition/Elisa/queue-definition-2.elisa @@ -0,0 +1,29 @@ +use GenericQueue (QueueofPersons, Person); +type Person = text; +Q = QueueofPersons(25); + +Push (Q, "Peter"); +Push (Q, "Alice"); +Push (Q, "Edward"); +Q? +QueueofPersons:[MaxLength = 25; + length = 3; + list = { "Peter", + "Alice", + "Edward"}] +Pull (Q)? +"Peter" + +Pull (Q)? +"Alice" + +Pull (Q)? +"Edward" + +Q? +QueueofPersons:[MaxLength = 25; + length = 0; + list = { }] + +Pull (Q)? +***** Exception: Queue Underflow diff --git a/Task/Queue-Definition/Erlang/queue-definition.erl b/Task/Queue-Definition/Erlang/queue-definition.erl new file mode 100644 index 0000000000..d85425de62 --- /dev/null +++ b/Task/Queue-Definition/Erlang/queue-definition.erl @@ -0,0 +1,13 @@ +-module(fifo). +-export([new/0, push/2, pop/1, empty/1]). + +new() -> {fifo, [], []}. + +push({fifo, In, Out}, X) -> {fifo, [X|In], Out}. + +pop({fifo, [], []}) -> erlang:error('empty fifo'); +pop({fifo, In, []}) -> pop({fifo, [], lists:reverse(In)}); +pop({fifo, In, [H|T]}) -> {H, {fifo, In, T}}. + +empty({fifo, [], []}) -> true; +empty({fifo, _, _}) -> false. diff --git a/Task/Queue-Definition/Fantom/queue-definition.fantom b/Task/Queue-Definition/Fantom/queue-definition.fantom new file mode 100644 index 0000000000..f623487134 --- /dev/null +++ b/Task/Queue-Definition/Fantom/queue-definition.fantom @@ -0,0 +1,24 @@ +class Queue +{ + List queue := [,] + + public Void push (Obj obj) + { + queue.add (obj) // add to right of list + } + + public Obj pop () + { + if (queue.isEmpty) + throw (Err("queue is empty")) + else + { + return queue.removeAt(0) // removes left-most item + } + } + + public Bool isEmpty () + { + queue.isEmpty + } +} diff --git a/Task/Queue-Definition/Forth/queue-definition.fth b/Task/Queue-Definition/Forth/queue-definition.fth new file mode 100644 index 0000000000..ab9879a421 --- /dev/null +++ b/Task/Queue-Definition/Forth/queue-definition.fth @@ -0,0 +1,22 @@ +1024 constant size +create buffer size cells allot +here constant end +variable head buffer head ! +variable tail buffer tail ! +variable used 0 used ! + +: empty? used @ 0= ; +: full? used @ size = ; + +: next ( ptr -- ptr ) + cell+ dup end = if drop buffer then ; + +: put ( n -- ) + full? abort" buffer full" + \ begin full? while pause repeat + tail @ ! tail @ next tail ! 1 used +! ; + +: get ( -- n ) + empty? abort" buffer empty" + \ begin empty? while pause repeat + head @ @ head @ next head ! -1 used +! ; diff --git a/Task/Queue-Definition/Fortran/queue-definition.f b/Task/Queue-Definition/Fortran/queue-definition.f new file mode 100644 index 0000000000..5963b3c880 --- /dev/null +++ b/Task/Queue-Definition/Fortran/queue-definition.f @@ -0,0 +1,69 @@ +module FIFO + use fifo_nodes +! fifo_nodes must define the type fifo_node, with the two field +! next and valid, for queue handling, while the field datum depends +! on the usage (see [[FIFO (usage)]] for an example) +! type fifo_node +! integer :: datum +! ! the next part is not variable and must be present +! type(fifo_node), pointer :: next +! logical :: valid +! end type fifo_node + + type fifo_head + type(fifo_node), pointer :: head, tail + end type fifo_head + +contains + + subroutine new_fifo(h) + type(fifo_head), intent(out) :: h + nullify(h%head) + nullify(h%tail) + end subroutine new_fifo + + subroutine fifo_enqueue(h, n) + type(fifo_head), intent(inout) :: h + type(fifo_node), intent(inout), target :: n + + if ( associated(h%tail) ) then + h%tail%next => n + h%tail => n + else + h%tail => n + h%head => n + end if + + nullify(n%next) + end subroutine fifo_enqueue + + subroutine fifo_dequeue(h, n) + type(fifo_head), intent(inout) :: h + type(fifo_node), intent(out), target :: n + + if ( associated(h%head) ) then + n = h%head + if ( associated(n%next) ) then + h%head => n%next + else + nullify(h%head) + nullify(h%tail) + end if + n%valid = .true. + else + n%valid = .false. + end if + nullify(n%next) + end subroutine fifo_dequeue + + function fifo_isempty(h) result(r) + logical :: r + type(fifo_head), intent(in) :: h + if ( associated(h%head) ) then + r = .false. + else + r = .true. + end if + end function fifo_isempty + +end module FIFO diff --git a/Task/Queue-Definition/GAP/queue-definition.gap b/Task/Queue-Definition/GAP/queue-definition.gap new file mode 100644 index 0000000000..59c46b3fa4 --- /dev/null +++ b/Task/Queue-Definition/GAP/queue-definition.gap @@ -0,0 +1,35 @@ +Enqueue := function(v, x) + Add(v[1], x); +end; + +Dequeue := function(v) + local n, x; + n := Size(v[2]); + if n = 0 then + v[2] := Reversed(v[1]); + v[1] := [ ]; + n := Size(v[2]); + if n = 0 then + return fail; + fi; + fi; + return Remove(v[2], n); +end; + +# a new queue +v := [[], []]; + +Enqueue(v, 3); +Enqueue(v, 4); +Enqueue(v, 5); +Dequeue(v); +# 3 +Enqueue(v, 6); +Dequeue(v); +# 4 +Dequeue(v); +# 5 +Dequeue(v); +# 6 +Dequeue(v); +# fail diff --git a/Task/Queue-Definition/Go/queue-definition.go b/Task/Queue-Definition/Go/queue-definition.go new file mode 100644 index 0000000000..e4e1570d38 --- /dev/null +++ b/Task/Queue-Definition/Go/queue-definition.go @@ -0,0 +1,55 @@ +package queue + +// int queue +// the zero object is a valid queue ready to be used. +// items are pushed at tail, popped at head. +// tail = -1 means queue is full +type Queue struct { + b []string + head, tail int +} + +func (q *Queue) Push(x string) { + switch { + // buffer full. reallocate. + case q.tail < 0: + next := len(q.b) + bigger := make([]string, 2*next) + copy(bigger[copy(bigger, q.b[q.head:]):], q.b[:q.head]) + bigger[next] = x + q.b, q.head, q.tail = bigger, 0, next+1 + // zero object. make initial allocation. + case len(q.b) == 0: + q.b, q.head, q.tail = make([]string, 4), 0 ,1 + q.b[0] = x + // normal case + default: + q.b[q.tail] = x + q.tail++ + if q.tail == len(q.b) { + q.tail = 0 + } + if q.tail == q.head { + q.tail = -1 + } + } +} + +func (q *Queue) Pop() (string, bool) { + if q.head == q.tail { + return "", false + } + r := q.b[q.head] + if q.tail == -1 { + q.tail = q.head + } + q.head++ + if q.head == len(q.b) { + q.head = 0 + } + return r, true +} + +func (q *Queue) Empty() bool { + return q.head == q.tail +} diff --git a/Task/Queue-Definition/Groovy/queue-definition-1.groovy b/Task/Queue-Definition/Groovy/queue-definition-1.groovy new file mode 100644 index 0000000000..f05a579c5c --- /dev/null +++ b/Task/Queue-Definition/Groovy/queue-definition-1.groovy @@ -0,0 +1,22 @@ +class Queue { + private List buffer + + public Queue(List buffer = new LinkedList()) { + assert buffer != null + assert buffer.empty + this.buffer = buffer + } + + def push (def item) { buffer << item } + final enqueue = this.&push + + def pop() { + if (this.empty) throw new NoSuchElementException('Empty Queue') + buffer.remove(0) + } + final dequeue = this.&pop + + def getEmpty() { buffer.empty } + + String toString() { "Queue:${buffer}" } +} diff --git a/Task/Queue-Definition/Groovy/queue-definition-2.groovy b/Task/Queue-Definition/Groovy/queue-definition-2.groovy new file mode 100644 index 0000000000..a0481951a8 --- /dev/null +++ b/Task/Queue-Definition/Groovy/queue-definition-2.groovy @@ -0,0 +1,27 @@ +def q = new Queue() +assert q.empty + +['Crosby', 'Stills'].each { q.push(it) } +assert !q.empty +['Nash', 'Young'].each { q.enqueue(it) } +println q +assert !q.empty +assert q.pop() == 'Crosby' +println q +assert !q.empty +assert q.dequeue() == 'Stills' +println q +assert !q.empty +assert q.pop() == 'Nash' +println q +assert !q.empty +q.push('Crazy Horse') +println q +assert q.dequeue() == 'Young' +println q +assert !q.empty +assert q.pop() == 'Crazy Horse' +println q +assert q.empty +try { q.pop() } catch (NoSuchElementException e) { println e } +try { q.dequeue() } catch (NoSuchElementException e) { println e } diff --git a/Task/Queue-Definition/Haskell/queue-definition-1.hs b/Task/Queue-Definition/Haskell/queue-definition-1.hs new file mode 100644 index 0000000000..16f3c2a181 --- /dev/null +++ b/Task/Queue-Definition/Haskell/queue-definition-1.hs @@ -0,0 +1,16 @@ +data Fifo a = F [a] [a] + +emptyFifo :: Fifo a +emptyFifo = F [] [] + +push :: Fifo a -> a -> Fifo a +push (F input output) item = F (item:input) output + +pop :: Fifo a -> (Maybe a, Fifo a) +pop (F input (item:output)) = (Just item, F input output) +pop (F [] [] ) = (Nothing, F [] []) +pop (F input [] ) = pop (F [] (reverse input)) + +isEmpty :: Fifo a -> Bool +isEmpty (F [] []) = True +isEmpty _ = False diff --git a/Task/Queue-Definition/Haskell/queue-definition-2.hs b/Task/Queue-Definition/Haskell/queue-definition-2.hs new file mode 100644 index 0000000000..d14e69c1e5 --- /dev/null +++ b/Task/Queue-Definition/Haskell/queue-definition-2.hs @@ -0,0 +1,34 @@ +# Use a record to hold a Queue, using a list as the concrete implementation +record Queue(items) + +procedure make_queue () + return Queue ([]) +end + +procedure queue_push (queue, item) + put (queue.items, item) +end + +# if the queue is empty, this will 'fail' and return nothing +procedure queue_pop (queue) + return pop (queue.items) +end + +procedure queue_empty (queue) + return *queue.items = 0 +end + +# procedure to test class +procedure main () + queue := make_queue() + + # add the numbers 1 to 5 + every (item := 1 to 5) do + queue_push (queue, item) + + # pop them in the added order, and show a message when queue is empty + every (1 to 6) do { + write ("Popped value: " || queue_pop (queue)) + if (queue_empty (queue)) then write ("empty queue") + } +end diff --git a/Task/Queue-Definition/Haskell/queue-definition-3.hs b/Task/Queue-Definition/Haskell/queue-definition-3.hs new file mode 100644 index 0000000000..7e8d29ba63 --- /dev/null +++ b/Task/Queue-Definition/Haskell/queue-definition-3.hs @@ -0,0 +1,30 @@ +# Use a class to hold a Queue, with a list as the concrete implementation +class Queue (items) + method push (item) + put (items, item) + end + + # if the queue is empty, this will 'fail' and return nothing + method take () + return pop (items) + end + + method is_empty () + return *items = 0 + end + + initially () # initialises the field on creating an instance + items := [] +end + +procedure main () + queue := Queue () + + every (item := 1 to 5) do + queue.push (item) + + every (1 to 6) do { + write ("Popped value: " || queue.take ()) + if queue.is_empty () then write ("empty queue") + } +end diff --git a/Task/Queue-Definition/J/queue-definition-1.j b/Task/Queue-Definition/J/queue-definition-1.j new file mode 100644 index 0000000000..ae9c11789a --- /dev/null +++ b/Task/Queue-Definition/J/queue-definition-1.j @@ -0,0 +1,16 @@ +queue_fifo_=: '' + +pop_fifo_=: verb define + r=. {. ::] queue + queue=: }.queue + r +) + +push_fifo_=: verb define + queue=: queue,y + y +) + +isEmpty_fifo_=: verb define + 0=#queue +) diff --git a/Task/Queue-Definition/J/queue-definition-2.j b/Task/Queue-Definition/J/queue-definition-2.j new file mode 100644 index 0000000000..f1261890da --- /dev/null +++ b/Task/Queue-Definition/J/queue-definition-2.j @@ -0,0 +1,10 @@ +pop =: ( {.^:notnull ; }. )@: > @: ] / +push =: ( '' ; ,~ )& > / +tell_atom =: >& {. +tell_queue =: >& {: +is_empty =: '' -: 1 tell_queue + +make_empty =: a: , a: [ ] +onto =: [ ; }.@] + +notnull =: 0 ~: # diff --git a/Task/Queue-Definition/Java/queue-definition.java b/Task/Queue-Definition/Java/queue-definition.java new file mode 100644 index 0000000000..835ee25cb8 --- /dev/null +++ b/Task/Queue-Definition/Java/queue-definition.java @@ -0,0 +1,40 @@ +public class Queue{ + Node head = null, tail = null; + + static class Node{ + E value; + Node next; + + Node(E value, Node next){ + this.value= value; + this.next= next; + } + + } + + public Queue(){ + } + + public void enqueue(E value){ //standard queue name for "push" + Node newNode= new Node(value, null); + if(empty()){ + head= newNode; + }else{ + tail.next = newNode; + } + tail= newNode; + } + + public E dequeue() throws java.util.NoSuchElementException{//standard queue name for "pop" + if(empty()){ + throw new java.util.NoSuchElementException("No more elements."); + } + E retVal= head.value; + head= head.next; + return retVal; + } + + public boolean empty(){ + return head == null; + } +} diff --git a/Task/Queue-Definition/JavaScript/queue-definition-1.js b/Task/Queue-Definition/JavaScript/queue-definition-1.js new file mode 100644 index 0000000000..65592aa44f --- /dev/null +++ b/Task/Queue-Definition/JavaScript/queue-definition-1.js @@ -0,0 +1,5 @@ +var fifo = []; +fifo.push(42); // Enqueue. +fifo.push(43); +var x = fifo.shift(); // Dequeue. +alert(x); // 42 diff --git a/Task/Queue-Definition/JavaScript/queue-definition-2.js b/Task/Queue-Definition/JavaScript/queue-definition-2.js new file mode 100644 index 0000000000..bf94c8174e --- /dev/null +++ b/Task/Queue-Definition/JavaScript/queue-definition-2.js @@ -0,0 +1,10 @@ +function FIFO() { + this.data = new Array(); + + this.push = function(element) {this.data.push(element)} + this.pop = function() {return this.data.shift()} + this.empty = function() {return this.data.length == 0} + + this.enqueue = this.push; + this.dequeue = this.pop; +} diff --git a/Task/Queue-Definition/Lua/queue-definition.lua b/Task/Queue-Definition/Lua/queue-definition.lua new file mode 100644 index 0000000000..4f7586ce8c --- /dev/null +++ b/Task/Queue-Definition/Lua/queue-definition.lua @@ -0,0 +1,25 @@ +Queue = {} + +function Queue.new() + return { first = 0, last = -1 } +end + +function Queue.push( queue, value ) + queue.last = queue.last + 1 + queue[queue.last] = value +end + +function Queue.pop( queue ) + if queue.first > queue.last then + return nil + end + + local val = queue[queue.first] + queue[queue.first] = nil + queue.first = queue.first + 1 + return val +end + +function Queue.empty( queue ) + return queue.first > queue.last +end diff --git a/Task/Queue-Definition/MATLAB/queue-definition-1.m b/Task/Queue-Definition/MATLAB/queue-definition-1.m new file mode 100644 index 0000000000..74d49a8bde --- /dev/null +++ b/Task/Queue-Definition/MATLAB/queue-definition-1.m @@ -0,0 +1,10 @@ +myfifo = {}; + +% push +myfifo{end+1} = x; + +% pop +x = myfifo{1}; myfifo{1} = []; + +% empty +isempty(myfifo) diff --git a/Task/Queue-Definition/MATLAB/queue-definition-2.m b/Task/Queue-Definition/MATLAB/queue-definition-2.m new file mode 100644 index 0000000000..a364b8a69c --- /dev/null +++ b/Task/Queue-Definition/MATLAB/queue-definition-2.m @@ -0,0 +1,82 @@ +%This class impliments a standard FIFO queue. +classdef FIFOQueue + + properties + queue + end + + methods + + %Class constructor + function theQueue = FIFOQueue(varargin) + + if isempty(varargin) %No input arguments + + %Initialize the queue state as empty + theQueue.queue = {}; + elseif (numel(varargin) > 1) %More than 1 input arg + + %Make the queue the list of input args + theQueue.queue = varargin; + elseif iscell(varargin{:}) %If the only input is a cell array + + %Make the contents of the cell array the elements in the queue + theQueue.queue = varargin{:}; + else %There is one input argument that is not a cell + + %Make that one arg the only element in the queue + theQueue.queue = varargin; + end + + end + + %push() - pushes a new element to the end of the queue + function push(theQueue,varargin) + + if isempty(varargin) + theQueue.queue(end+1) = {[]}; + elseif (numel(varargin) > 1) %More than 1 input arg + + %Make the queue the list of input args + theQueue.queue( end+1:end+numel(varargin) ) = varargin; + elseif iscell(varargin{:}) %If the only input is a cell array + + %Make the contents of the cell array the elements in the queue + theQueue.queue( end+1:end+numel(varargin{:}) ) = varargin{:}; + else %There is one input argument that is not a cell + + %Make that one arg the only element in the queue + theQueue.queue{end+1} = varargin{:}; + end + + %Makes changes to the queue permanent + assignin('caller',inputname(1),theQueue); + + end + + %pop() - pops the first element off the queue + function element = pop(theQueue) + + if empty(theQueue) + error 'The queue is empty' + else + %Returns the first element in the queue + element = theQueue.queue{1}; + + %Removes the first element from the queue + theQueue.queue(1) = []; + + %Makes changes to the queue permanent + assignin('caller',inputname(1),theQueue); + end + end + + %empty() - Returns true if the queue is empty + function trueFalse = empty(theQueue) + + trueFalse = isempty(theQueue.queue); + + end + + end %methods +end diff --git a/Task/Queue-Definition/MATLAB/queue-definition-3.m b/Task/Queue-Definition/MATLAB/queue-definition-3.m new file mode 100644 index 0000000000..9ee87003bc --- /dev/null +++ b/Task/Queue-Definition/MATLAB/queue-definition-3.m @@ -0,0 +1,22 @@ +>> myQueue = FIFOQueue({'hello'}) + +myQueue = + + FIFOQueue + +>> push(myQueue,'jello') +>> pop(myQueue) + +ans = + +hello + +>> pop(myQueue) + +ans = + +jello + +>> pop(myQueue) +??? Error using ==> FIFOQueue.FIFOQueue>FIFOQueue.pop at 61 +The queue is empty diff --git a/Task/Queue-Definition/Mathematica/queue-definition.math b/Task/Queue-Definition/Mathematica/queue-definition.math new file mode 100644 index 0000000000..1e47387fa3 --- /dev/null +++ b/Task/Queue-Definition/Mathematica/queue-definition.math @@ -0,0 +1,3 @@ +EmptyQ[a_] := Length[a] == 0 +SetAttributes[Push, HoldAll]; Push[a_, elem_] := AppendTo[a, elem] +SetAttributes[Pop, HoldAllComplete]; Pop[a_] := If[EmptyQ[a], False, b = First[a]; Set[a, Most[a]]; b] diff --git a/Task/Queue-Definition/Maxima/queue-definition.maxima b/Task/Queue-Definition/Maxima/queue-definition.maxima new file mode 100644 index 0000000000..a702f93d47 --- /dev/null +++ b/Task/Queue-Definition/Maxima/queue-definition.maxima @@ -0,0 +1,18 @@ +defstruct(queue(in=[], out=[]))$ + +enqueue(x, q) := (q@in: cons(x, q@in), done)$ + +dequeue(q) := (if not emptyp(q@out) then first([first(q@out), q@out: rest(q@out)]) +elseif emptyp(q@in) then 'fail +else (q@out: reverse(q@in), q@in: [], first([first(q@out), q@out: rest(q@out)])))$ + +q:new(queue); /* queue([], []) */ +enqueue(1, q)$ +enqueue(2, q)$ +enqueue(3, q)$ +dequeue(q); /* 1 */ +enqueue(4, q)$ +dequeue(q); /* 2 */ +dequeue(q); /* 3 */ +dequeue(q); /* 4 */ +dequeue(q); /* fail */ diff --git a/Task/Queue-Definition/NetRexx/queue-definition.netrexx b/Task/Queue-Definition/NetRexx/queue-definition.netrexx new file mode 100644 index 0000000000..f3aa430ea2 --- /dev/null +++ b/Task/Queue-Definition/NetRexx/queue-definition.netrexx @@ -0,0 +1,35 @@ +/* NetRexx */ +options replace format comments java crossref savelog symbols nobinary + +mqueue = ArrayDeque() + +viewQueue(mqueue) + +a = "Fred" +mqueue.push('') /* Puts an empty line onto the queue */ +mqueue.push(a 2) /* Puts "Fred 2" onto the queue */ +viewQueue(mqueue) + +a = "Toft" +mqueue.add(a 2) /* Enqueues "Toft 2" */ +mqueue.add('') /* Enqueues an empty line behind the last */ +viewQueue(mqueue) + +loop q_ = 1 while mqueue.size > 0 + parse mqueue.pop.toString line + say q_.right(3)':' line + end q_ +viewQueue(mqueue) + +return + +method viewQueue(mqueue = Deque) private static + + If mqueue.size = 0 then do + Say 'Queue is empty' + end + else do + Say 'There are' mqueue.size 'elements in the queue' + end + + return diff --git a/Task/Queue-Definition/OCaml/queue-definition-1.ocaml b/Task/Queue-Definition/OCaml/queue-definition-1.ocaml new file mode 100644 index 0000000000..dafa692f37 --- /dev/null +++ b/Task/Queue-Definition/OCaml/queue-definition-1.ocaml @@ -0,0 +1,20 @@ +module FIFO : sig + type 'a fifo + val empty: 'a fifo + val push: fifo:'a fifo -> item:'a -> 'a fifo + val pop: fifo:'a fifo -> 'a * 'a fifo + val is_empty: fifo:'a fifo -> bool +end = struct + type 'a fifo = 'a list * 'a list + let empty = [], [] + let push ~fifo:(input,output) ~item = (item::input,output) + let is_empty ~fifo = + match fifo with + | [], [] -> true + | _ -> false + let rec pop ~fifo = + match fifo with + | input, item :: output -> item, (input,output) + | [], [] -> failwith "empty fifo" + | input, [] -> pop ([], List.rev input) +end diff --git a/Task/Queue-Definition/OCaml/queue-definition-2.ocaml b/Task/Queue-Definition/OCaml/queue-definition-2.ocaml new file mode 100644 index 0000000000..07235ae4cf --- /dev/null +++ b/Task/Queue-Definition/OCaml/queue-definition-2.ocaml @@ -0,0 +1,28 @@ +# open FIFO;; +# let q = empty ;; +val q : '_a FIFO.fifo = +# is_empty q ;; +- : bool = true +# let q = push q 1 ;; +val q : int FIFO.fifo = +# is_empty q ;; +- : bool = false + +# let q = + List.fold_left push q [2;3;4] ;; +val q : int FIFO.fifo = + +# let v, q = pop q ;; +val v : int = 1 +val q : int FIFO.fifo = +# let v, q = pop q ;; +val v : int = 2 +val q : int FIFO.fifo = +# let v, q = pop q ;; +val v : int = 3 +val q : int FIFO.fifo = +# let v, q = pop q ;; +val v : int = 4 +val q : int FIFO.fifo = +# let v, q = pop q ;; +Exception: Failure "empty fifo". diff --git a/Task/Queue-Definition/OxygenBasic/queue-definition.oxy b/Task/Queue-Definition/OxygenBasic/queue-definition.oxy new file mode 100644 index 0000000000..86231f4eac --- /dev/null +++ b/Task/Queue-Definition/OxygenBasic/queue-definition.oxy @@ -0,0 +1,65 @@ +'FIRST IN FIRST OUT + +'========== +Class Queue +'========== + +string buf +sys bg,i,le + +method Encodelength(sys ls) +int p at (i+strptr buf) +p=ls +i+=sizeof int +end method + +method push(string s) +ls=len s +if i+ls+8>le then + buf+=nuls 8000+ls*2 : le=len buf 'expand buf +end if +EncodeLength ls +mid buf,i+1,s +i+=ls +'EncodeLength ls +end method + +method GetLength() as sys + if bg>=i then return -1 'buffer empty + int p at (bg+strptr buf) + bg+=sizeof int + return p +end method + +method pop(string *s) as sys +sys ls=GetLength +if ls<0 then s="" : return ls 'empty buffer +s=mid buf,bg+1,ls +bg+=ls +if bg>1e6 then + buf=mid buf,bg+1 : bg=0 : le=len buf : i-=bg 'shrink buf +end if +end method + +method clear() + buf="" : le="" : bg=0 : i=0 +end method + +end class + +'==== +'TEST +'==== + +Queue fifo +string s +' +fifo.push "HumptyDumpty" +fifo.push "Sat on a wall" +' +sys er +do + er=fifo.pop s + if er then print "(buffer empty)" : exit do + print s +end do diff --git a/Task/Queue-Definition/Oz/queue-definition.oz b/Task/Queue-Definition/Oz/queue-definition.oz new file mode 100644 index 0000000000..db8aaf30d9 --- /dev/null +++ b/Task/Queue-Definition/Oz/queue-definition.oz @@ -0,0 +1,34 @@ +declare + fun {NewQueue} + Stream + WritePort = {Port.new Stream} + ReadPos = {NewCell Stream} + in + WritePort#ReadPos + end + + proc {Push WritePort#_ Value} + {Port.send WritePort Value} + end + + fun {Empty _#ReadPos} + %% the queue is empty if the value at the current + %% read position is not determined + {Not {IsDet @ReadPos}} + end + + fun {Pop _#ReadPos} + %% blocks if empty + case @ReadPos of X|Xr then + ReadPos := Xr + X + end + end + + Q = {NewQueue} +in + {Show {Empty Q}} + {Push Q 42} + {Show {Empty Q}} + {Show {Pop Q}} + {Show {Empty Q}} diff --git a/Task/Queue-Definition/PHP/queue-definition-1.php b/Task/Queue-Definition/PHP/queue-definition-1.php new file mode 100644 index 0000000000..f9fa4517b2 --- /dev/null +++ b/Task/Queue-Definition/PHP/queue-definition-1.php @@ -0,0 +1,21 @@ +class Fifo { + private $data = array(); + public function push($element){ + array_push($this->data, $element); + } + public function pop(){ + if ($this->isEmpty()){ + throw new Exception('Attempt to pop from an empty queue'); + } + return array_shift($this->data); + } + + //Alias functions + public function enqueue($element) { $this->push($element); } + public function dequeue() { return $this->pop(); } + + //Note: PHP prevents a method name of 'empty' + public function isEmpty(){ + return empty($this->data); + } +} diff --git a/Task/Queue-Definition/PHP/queue-definition-2.php b/Task/Queue-Definition/PHP/queue-definition-2.php new file mode 100644 index 0000000000..459105292f --- /dev/null +++ b/Task/Queue-Definition/PHP/queue-definition-2.php @@ -0,0 +1,9 @@ +$foo = new Fifo(); +$foo->push('One'); +$foo->enqueue('Two'); +$foo->push('Three'); + +echo $foo->pop(); //Prints 'One' +echo $foo->dequeue(); //Prints 'Two' +echo $foo->pop(); //Prints 'Three' +echo $foo->pop(); //Throws an exception diff --git a/Task/Queue-Definition/PL-I/queue-definition.pli b/Task/Queue-Definition/PL-I/queue-definition.pli new file mode 100644 index 0000000000..474d8b250b --- /dev/null +++ b/Task/Queue-Definition/PL-I/queue-definition.pli @@ -0,0 +1,28 @@ +/* To push a node onto the end of the queue. */ +push: procedure (tail); + declare tail handle (node), t handle (node); + t = new(:node:); + get (t => value); + if tail ^= bind(:null, node:) then + tail => link = t; + /* If the queue was non-empty, points the tail of the queue */ + /* to the new node. */ + tail = t; /* Point "tail" at the end of the queue. */ + tail => link = bind(:node, null:); +end push; + +/* To pop a node from the head of the queue. */ +pop: procedure (head, val); + declare head handle (node), val fixed binary; + if head = bind(:node, null:) then signal error; + val = head => value; + head = head => pointer; /* pops the top node. */ + if head = bind(:node, null:) then tail = head; + /* (If the queue is now empty, make tail null also.) */ +end pop; + +/* Queue status: the EMPTY function, returns true for empty queue. */ +empty: procedure (h) returns (bit(1)); + declare h handle (Node); + return (h = bind(:Node, null:) ); +end empty; diff --git a/Task/Queue-Definition/Pascal/queue-definition.pascal b/Task/Queue-Definition/Pascal/queue-definition.pascal new file mode 100644 index 0000000000..285895bc74 --- /dev/null +++ b/Task/Queue-Definition/Pascal/queue-definition.pascal @@ -0,0 +1,101 @@ +program fifo(input, output); + +type + pNode = ^tNode; + tNode = record + value: integer; + next: pNode; + end; + + tFifo = record + first, last: pNode; + end; + +procedure initFifo(var fifo: tFifo); + begin + fifo.first := nil; + fifo.last := nil + end; + +procedure pushFifo(var fifo: tFifo; value: integer); + var + node: pNode; + begin + new(node); + node^.value := value; + node^.next := nil; + if fifo.first = nil + then + fifo.first := node + else + fifo.last^.next := node; + fifo.last := node + end; + +function popFifo(var fifo: tFifo; var value: integer): boolean; + var + node: pNode; + begin + if fifo.first = nil + then + popFifo := false + else + begin + node := fifo.first; + fifo.first := fifo.first^.next; + value := node^.value; + dispose(node); + popFifo := true + end + end; + +procedure testFifo; + var + fifo: tFifo; + procedure testpop(expectEmpty: boolean; expectedValue: integer); + var + i: integer; + begin + if popFifo(fifo, i) + then + if expectEmpty + then + writeln('Error! Expected empty, got ', i, '.') + else + if i = expectedValue + then + writeln('Ok, got ', i, '.') + else + writeln('Error! Expected ', expectedValue, ', got ', i, '.') + else + if expectEmpty + then + writeln('Ok, fifo is empty.') + else + writeln('Error! Expected ', expectedValue, ', found fifo empty.') + end; + begin + initFifo(fifo); + pushFifo(fifo, 2); + pushFifo(fifo, 3); + pushFifo(fifo, 5); + testpop(false, 2); + pushFifo(fifo, 7); + testpop(false, 3); + testpop(false, 5); + pushFifo(fifo, 11); + testpop(false, 7); + testpop(false, 11); + pushFifo(fifo, 13); + testpop(false, 13); + testpop(true, 0); + pushFifo(fifo, 17); + testpop(false, 17); + testpop(true, 0) + end; + +begin + writeln('Testing fifo implementation ...'); + testFifo; + writeln('Testing finished.') +end. diff --git a/Task/Queue-Definition/Perl-6/queue-definition-1.pl6 b/Task/Queue-Definition/Perl-6/queue-definition-1.pl6 new file mode 100644 index 0000000000..0ed42df2ec --- /dev/null +++ b/Task/Queue-Definition/Perl-6/queue-definition-1.pl6 @@ -0,0 +1,13 @@ +role FIFO { + method enqueue ( *@values ) { # Add values to queue, returns the number of values added. + self.push: @values; + return @values.elems; + } + method dequeue ( ) { # Remove and return the first value from the queue. + # Return Nil if queue is empty. + return self.elems ?? self.shift !! Nil; + } + method is-empty ( ) { # Check to see if queue is empty. Returns Boolean value. + return self.elems == 0; + } +} diff --git a/Task/Queue-Definition/Perl-6/queue-definition-2.pl6 b/Task/Queue-Definition/Perl-6/queue-definition-2.pl6 new file mode 100644 index 0000000000..bd40506f0a --- /dev/null +++ b/Task/Queue-Definition/Perl-6/queue-definition-2.pl6 @@ -0,0 +1,15 @@ +my @queue does FIFO; + +say @queue.is-empty; # -> Bool::True +say @queue.enqueue:
    ; # -> 3 +say @queue.enqueue: Any; # -> 1 +say @queue.enqueue: 7, 8; # -> 2 +say @queue.is-empty; # -> Bool::False +say @queue.dequeue; # -> A +say @queue.elems; # -> 5 +say @queue.dequeue; # -> B +say @queue.is-empty; # -> Bool::False +say @queue.enqueue('OHAI!'); # -> 1 +say @queue.dequeue until @queue.is-empty; # -> C \n Any() \n 7 \n 8 \n OHAI! +say @queue.is-empty; # -> Bool::True +say @queue.dequeue; # -> diff --git a/Task/Queue-Definition/Perl/queue-definition-1.pl b/Task/Queue-Definition/Perl/queue-definition-1.pl new file mode 100644 index 0000000000..a51a8b93b5 --- /dev/null +++ b/Task/Queue-Definition/Perl/queue-definition-1.pl @@ -0,0 +1,4 @@ +use Carp; +sub mypush (\@@) {my($list,@things)=@_; push @$list, @things} +sub mypop (\@) {my($list)=@_; @$list or croak "Empty"; shift @$list } +sub empty (@) {not @_} diff --git a/Task/Queue-Definition/Perl/queue-definition-2.pl b/Task/Queue-Definition/Perl/queue-definition-2.pl new file mode 100644 index 0000000000..d3d38b7dac --- /dev/null +++ b/Task/Queue-Definition/Perl/queue-definition-2.pl @@ -0,0 +1,5 @@ +my @fifo=qw(1 2 3 a b c); + +mypush @fifo, 44, 55, 66; +mypop @fifo for 1 .. 6+3; +mypop @fifo; #empty now diff --git a/Task/Queue-Definition/PicoLisp/queue-definition.l b/Task/Queue-Definition/PicoLisp/queue-definition.l new file mode 100644 index 0000000000..85706552c3 --- /dev/null +++ b/Task/Queue-Definition/PicoLisp/queue-definition.l @@ -0,0 +1,6 @@ +(off Queue) # Clear Queue +(fifo 'Queue 1) # Store number '1' +(fifo 'Queue 'abc) # an internal symbol 'abc' +(fifo 'Queue "abc") # a transient symbol "abc" +(fifo 'Queue '(a b c)) # and a list (a b c) +Queue # Show the queue diff --git a/Task/Queue-Definition/PostScript/queue-definition.ps b/Task/Queue-Definition/PostScript/queue-definition.ps new file mode 100644 index 0000000000..e6fbf9d170 --- /dev/null +++ b/Task/Queue-Definition/PostScript/queue-definition.ps @@ -0,0 +1,3 @@ +% our queue is just [] and empty? is already defined. +/push {exch tadd}. +/pop {uncons exch}. diff --git a/Task/Queue-Definition/Prolog/queue-definition.pro b/Task/Queue-Definition/Prolog/queue-definition.pro new file mode 100644 index 0000000000..806ddfba4f --- /dev/null +++ b/Task/Queue-Definition/Prolog/queue-definition.pro @@ -0,0 +1,11 @@ +empty(U-V) :- + unify_with_occurs_check(U, V). + +push(Queue, Value, NewQueue) :- + append_dl(Queue, [Value|X]-X, NewQueue). + +% when queue is empty pop fails. +pop([X|V]-U, X, V-U) :- + \+empty([X|V]-U). + +append_dl(X-Y, Y-Z, X-Z). diff --git a/Task/Queue-Definition/PureBasic/queue-definition.purebasic b/Task/Queue-Definition/PureBasic/queue-definition.purebasic new file mode 100644 index 0000000000..7bc33df2fb --- /dev/null +++ b/Task/Queue-Definition/PureBasic/queue-definition.purebasic @@ -0,0 +1,38 @@ +NewList MyStack() + +Procedure Push(n) + Shared MyStack() + LastElement(MyStack()) + AddElement(MyStack()) + MyStack()=n +EndProcedure + +Procedure Pop() + Shared MyStack() + Protected n + If FirstElement(MyStack()) ; e.g. Stack not empty + n=MyStack() + DeleteElement(MyStack(),1) + Else + Debug "Pop(), out of range. Error at line "+str(#PB_Compiler_Line) + EndIf + ProcedureReturn n +EndProcedure + +Procedure Empty() + Shared MyStack() + If ListSize(MyStack())=0 + ProcedureReturn #True + EndIf + ProcedureReturn #False +EndProcedure + +;---- Example of implementation ---- +Push(3) +Push(1) +Push(4) +While Not Empty() + Debug Pop() +Wend +;---- Now an extra Pop(), e.g. one to many ---- +Debug Pop() diff --git a/Task/Queue-Definition/Python/queue-definition-1.py b/Task/Queue-Definition/Python/queue-definition-1.py new file mode 100644 index 0000000000..7b5993714b --- /dev/null +++ b/Task/Queue-Definition/Python/queue-definition-1.py @@ -0,0 +1,45 @@ + class FIFO(object): + def __init__(self, *args): + self.contents = list(args) + def __call__(self): + return self.pop() + def __len__(self): + return len(self.contents) + def pop(self): + return self.contents.pop(0) + def push(self, item): + self.contents.append(item) + def extend(self,*itemlist): + self.contents += itemlist + def empty(self): + return bool(self.contents) + def __iter__(self): + return self + def next(self): + if self.empty(): + raise StopIteration + return self.pop() + +if __name__ == "__main__": + # Sample usage: + f = FIFO() + f.push(3) + f.push(2) + f.push(1) + while not f.empty(): + print f.pop(), + # >>> 3 2 1 + # Another simple example gives the same results: + f = FIFO(3,2,1) + while not f.empty(): + print f(), + # Another using the default "truth" value of the object + # (implicitly calls on the length() of the object after + # checking for a __nonzero__ method + f = FIFO(3,2,1) + while f: + print f(), + # Yet another, using more Pythonic iteration: + f = FIFO(3,2,1) + for i in f: + print i, diff --git a/Task/Queue-Definition/Python/queue-definition-2.py b/Task/Queue-Definition/Python/queue-definition-2.py new file mode 100644 index 0000000000..2f1bb31327 --- /dev/null +++ b/Task/Queue-Definition/Python/queue-definition-2.py @@ -0,0 +1,15 @@ +class FIFO: ## NOT a new-style class, must not derive from "object" + def __init__(self,*args): + self.contents = list(args) + def __call__(self): + return self.pop() + def empty(self): + return bool(self.contents) + def pop(self): + return self.contents.pop(0) + def __getattr__(self, attr): + return getattr(self.contents,attr) + def next(self): + if not self: + raise StopIteration + return self.pop() diff --git a/Task/Queue-Definition/Python/queue-definition-3.py b/Task/Queue-Definition/Python/queue-definition-3.py new file mode 100644 index 0000000000..fcabe1b2cd --- /dev/null +++ b/Task/Queue-Definition/Python/queue-definition-3.py @@ -0,0 +1,6 @@ +from collections import deque +fifo = deque() +fifo. appendleft(value) # push +value = fifo.pop() +not fifo # empty +fifo.pop() # raises IndexError when empty diff --git a/Task/Queue-Definition/R/queue-definition-1.r b/Task/Queue-Definition/R/queue-definition-1.r new file mode 100644 index 0000000000..b082373983 --- /dev/null +++ b/Task/Queue-Definition/R/queue-definition-1.r @@ -0,0 +1,48 @@ +empty <- function() length(l) == 0 +push <- function(x) +{ + l <<- c(l, list(x)) + print(l) + invisible() +} +pop <- function() +{ + if(empty()) stop("can't pop from an empty list") + l[[1]] <<- NULL + print(l) + invisible() +} +l <- list() +empty() +# [1] TRUE +push(3) +# [[1]] +# [1] 3 +push("abc") +# [[1]] +# [1] 3 +# [[2]] +# [1] "abc" +push(matrix(1:6, nrow=2)) +# [[1]] +# [1] 3 +# [[2]] +# [1] "abc" +# [[3]] +# [,1] [,2] [,3] +# [1,] 1 3 5 +# [2,] 2 4 6 +empty() +# [1] FALSE +pop() +# [[1]] +# [1] 3 +# [[2]] +# [1] "abc" +pop() +# [[1]] +# [1] 3 +pop() +# list() +pop() +# Error in pop() : can't pop from an empty list diff --git a/Task/Queue-Definition/R/queue-definition-2.r b/Task/Queue-Definition/R/queue-definition-2.r new file mode 100644 index 0000000000..ac01170826 --- /dev/null +++ b/Task/Queue-Definition/R/queue-definition-2.r @@ -0,0 +1,39 @@ +# The usual Scheme way : build a function that takes commands as parameters (it's like message passing oriented programming) +queue <- function() { + v <- list() + f <- function(cmd, val=NULL) { + if(cmd == "push") { + v <<- c(v, val) + invisible() + } else if(cmd == "pop") { + if(length(v) == 0) { + stop("empty queue") + } else { + x <- v[[1]] + v[[1]] <<- NULL + x + } + } else if(cmd == "length") { + length(v) + } else if(cmd == "empty") { + length(v) == 0 + } else { + stop("unknown command") + } + } + f +} + +# Create two queues +a <- queue() +b <- queue() +a("push", 1) +a("push", 2) +b("push", 3) +a("push", 4) +b("push", 5) + +a("pop") +# [1] 1 +b("pop") +# [1] 3 diff --git a/Task/Queue-Definition/R/queue-definition-3.r b/Task/Queue-Definition/R/queue-definition-3.r new file mode 100644 index 0000000000..dbf1fcc728 --- /dev/null +++ b/Task/Queue-Definition/R/queue-definition-3.r @@ -0,0 +1,30 @@ +library(proto) + +fifo <- proto(expr = { + l <- list() + empty <- function(.) length(.$l) == 0 + push <- function(., x) + { + .$l <- c(.$l, list(x)) + print(.$l) + invisible() + } + pop <- function(.) + { + if(.$empty()) stop("can't pop from an empty list") + .$l[[1]] <- NULL + print(.$l) + invisible() + } +}) + +#The following code provides output that is the same as the previous example. +fifo$empty() +fifo$push(3) +fifo$push("abc") +fifo$push(matrix(1:6, nrow=2)) +fifo$empty() +fifo$pop() +fifo$pop() +fifo$pop() +fifo$pop() diff --git a/Task/Queue-Definition/REBOL/queue-definition.rebol b/Task/Queue-Definition/REBOL/queue-definition.rebol new file mode 100644 index 0000000000..473aac6811 --- /dev/null +++ b/Task/Queue-Definition/REBOL/queue-definition.rebol @@ -0,0 +1,33 @@ +rebol [ + Title: "FIFO" + Author: oofoe + Date: 2009-12-11 + URL: http://rosettacode.org/wiki/FIFO +] + +; Define fifo class: + +fifo: make object! [ + queue: copy [] + push: func [x][append queue x] + pop: func [/local x][ ; Make 'x' local so it won't pollute global namespace. + if empty [return none] + x: first queue remove queue x] + empty: does [empty? queue] +] + +; Create and populate a FIFO: + +q: make fifo [] +q/push 'a +q/push 2 +q/push USD$12.34 ; Did I mention that REBOL has 'money!' datatype? +q/push [Athos Porthos Aramis] ; List elements pushed on one by one. +q/push [[Huey Dewey Lewey]] ; This list is preserved as a list. + +; Dump it out, with narrative: + +print rejoin ["Queue is " either q/empty [""]["not "] "empty."] +while [not q/empty][print [" " q/pop]] +print rejoin ["Queue is " either q/empty [""]["not "] "empty."] +print ["Trying to pop an empty queue yields:" q/pop] diff --git a/Task/Queue-Definition/REXX/queue-definition.rexx b/Task/Queue-Definition/REXX/queue-definition.rexx new file mode 100644 index 0000000000..8749537147 --- /dev/null +++ b/Task/Queue-Definition/REXX/queue-definition.rexx @@ -0,0 +1,20 @@ +/*REXX program to demonstrate FIFO queue usage by some simple operations*/ +call viewQueue +a="Fred" +push /*puts a "null" on top of queue.*/ +push a 2 /*puts "Fred 2" on top of queue.*/ +call viewQueue + +queue "Toft 2" /*put "Toft 2" on queue bottom.*/ +queue /*put a "null" on queue bottom.*/ +call viewQueue + do n=1 while queued()\==0 + parse pull xxx + say "queue entry" n': ' xxx + end /*n*/ +call viewQueue +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────viewQueue subroutine────────────────*/ +viewQueue: if queued()==0 then say 'Queue is empty' + else say 'There are' queued() 'elements in the queue' +return diff --git a/Task/Queue-Definition/Ruby/queue-definition-1.rb b/Task/Queue-Definition/Ruby/queue-definition-1.rb new file mode 100644 index 0000000000..3d4ab0a511 --- /dev/null +++ b/Task/Queue-Definition/Ruby/queue-definition-1.rb @@ -0,0 +1,57 @@ +require 'forwardable' + +# A FIFO queue contains elements in first-in, first-out order. +# FIFO#push adds new elements to the end of the queue; +# FIFO#pop or FIFO#shift removes elements from the front. +class FIFO + extend Forwardable + + # Creates a FIFO containing _objects_. + def self.[](*objects) + new.push(*objects) + end + + # Creates an empty FIFO. + def initialize; @ary = []; end + + # Appends _objects_ to the end of this FIFO. Returns self. + def push(*objects) + @ary.push(*objects) + self + end + alias << push + alias enqueue push + + ## + # :method: pop + # :call-seq: + # pop -> obj or nil + # pop(n) -> ary + # + # Removes an element from the front of this FIFO, and returns it. + # Returns nil if the FIFO is empty. + # + # If passing a number _n_, removes the first _n_ elements, and returns + # an Array of them. If this FIFO contains fewer than _n_ elements, + # returns them all. If this FIFO is empty, returns an empty Array. + def_delegator :@ary, :shift, :pop + alias shift pop + alias dequeue shift + + ## + # :method: empty? + # Returns true if this FIFO contains no elements. + def_delegator :@ary, :empty? + + ## + # :method: size + # Returns the number of elements in this FIFO. + def_delegator :@ary, :size + alias length size + + # Converts this FIFO to a String. + def to_s + "FIFO#{@ary.inspect}" + end + alias inspect to_s +end diff --git a/Task/Queue-Definition/Ruby/queue-definition-2.rb b/Task/Queue-Definition/Ruby/queue-definition-2.rb new file mode 100644 index 0000000000..653953f69a --- /dev/null +++ b/Task/Queue-Definition/Ruby/queue-definition-2.rb @@ -0,0 +1,16 @@ +f = FIFO.new +f.empty? # => true +f.pop # => nil +f.pop(2) # => [] +f.push(14) # => FIFO[14] +f << "foo" << [1,2,3] # => FIFO[14, "foo", [1, 2, 3]] +f.enqueue("bar", Hash.new, "baz") +# => FIFO[14, "foo", [1, 2, 3], "bar", {}, "baz"] +f.size # => 6 +f.pop(3) # => [14, "foo", [1, 2, 3]] +f.dequeue # => "bar" +f.empty? # => false +g = FIFO[:a, :b, :c] +g.pop(2) # => [:a, :b] +g.pop(2) # => [:c] +g.pop(2) # => [] diff --git a/Task/Queue-Definition/Scala/queue-definition-1.scala b/Task/Queue-Definition/Scala/queue-definition-1.scala new file mode 100644 index 0000000000..310673f9a5 --- /dev/null +++ b/Task/Queue-Definition/Scala/queue-definition-1.scala @@ -0,0 +1,34 @@ +class Queue[T] { + private[this] class Node[T](val value:T) { + var next:Option[Node[T]]=None + def append(n:Node[T])=next=Some(n) + } + private[this] var head:Option[Node[T]]=None + private[this] var tail:Option[Node[T]]=None + + def isEmpty=head.isEmpty + + def enqueue(item:T)={ + val n=new Node(item) + if(isEmpty) head=Some(n) else tail.get.append(n) + tail=Some(n) + } + + def dequeue:T=head match { + case Some(item) => head=item.next; item.value + case None => throw new java.util.NoSuchElementException() + } + + def front:T=head match { + case Some(item) => item.value + case None => throw new java.util.NoSuchElementException() + } + + def iterator: Iterator[T]=new Iterator[T]{ + private[this] var it=head; + override def hasNext=it.isDefined + override def next:T={val n=it.get; it=n.next; n.value} + } + + override def toString()=iterator.mkString("Queue(", ", ", ")") +} diff --git a/Task/Queue-Definition/Scala/queue-definition-2.scala b/Task/Queue-Definition/Scala/queue-definition-2.scala new file mode 100644 index 0000000000..d1e808689f --- /dev/null +++ b/Task/Queue-Definition/Scala/queue-definition-2.scala @@ -0,0 +1,11 @@ +val q=new Queue[Int]() +println("isEmpty = " + q.isEmpty) +try{q dequeue} catch{case _:java.util.NoSuchElementException => println("dequeue(empty) failed.")} +q enqueue 1 +q enqueue 2 +q enqueue 3 +println("queue = " + q) +println("front = " + q.front) +println("dequeue = " + q.dequeue) +println("dequeue = " + q.dequeue) +println("isEmpty = " + q.isEmpty) diff --git a/Task/Queue-Definition/Scheme/queue-definition-1.ss b/Task/Queue-Definition/Scheme/queue-definition-1.ss new file mode 100644 index 0000000000..511c7bad6f --- /dev/null +++ b/Task/Queue-Definition/Scheme/queue-definition-1.ss @@ -0,0 +1,15 @@ +(define (make-queue) + (make-vector 1 '())) + +(define (push a queue) + (vector-set! queue 0 (append (vector-ref queue 0) (list a)))) + +(define (empty? queue) + (null? (vector-ref queue 0))) + +(define (pop queue) + (if (empty? queue) + (error "can not pop an empty queue") + (let ((ret (car (vector-ref queue 0)))) + (vector-set! queue 0 (cdr (vector-ref queue 0))) + ret))) diff --git a/Task/Queue-Definition/Scheme/queue-definition-2.ss b/Task/Queue-Definition/Scheme/queue-definition-2.ss new file mode 100644 index 0000000000..21d6532bf4 --- /dev/null +++ b/Task/Queue-Definition/Scheme/queue-definition-2.ss @@ -0,0 +1,25 @@ +(define (make-queue) +(let ((q (cons '() '()))) +(lambda (cmd . arg) +(case cmd + ((empty?) (null? (car q))) + ((put) (let ((a (cons (car arg) '()))) + (if (null? (car q)) + (begin (set-car! q a) (set-cdr! q a)) + (begin (set-cdr! (cdr q) a) (set-cdr! q a))))) + ((get) (if (null? (car q)) 'empty + (let ((x (caar q))) + (set-car! q (cdar q)) + (if (null? (car q)) (set-cdr! q '())) + x))) +)))) + +(define q (make-queue)) +(q 'put 1) +(q 'put 6) +(q 'get) +; 1 +(q 'get) +; 6 +(q 'get) +; empty diff --git a/Task/Queue-Definition/Slate/queue-definition.slate b/Task/Queue-Definition/Slate/queue-definition.slate new file mode 100644 index 0000000000..60818c4d77 --- /dev/null +++ b/Task/Queue-Definition/Slate/queue-definition.slate @@ -0,0 +1,7 @@ +collections define: #Queue &parents: {ExtensibleArray}. + +q@(Queue traits) isEmpty [resend]. +q@(Queue traits) push: obj [q addLast: obj]. +q@(Queue traits) pop [q removeFirst]. +q@(Queue traits) pushAll: c [q addAllLast: c]. +q@(Queue traits) pop: n [q removeFirst: n]. diff --git a/Task/Queue-Definition/Smalltalk/queue-definition.st b/Task/Queue-Definition/Smalltalk/queue-definition.st new file mode 100644 index 0000000000..bc90994f72 --- /dev/null +++ b/Task/Queue-Definition/Smalltalk/queue-definition.st @@ -0,0 +1,20 @@ +OrderedCollection extend [ + push: obj [ ^(self add: obj) ] + pop [ + (self isEmpty) ifTrue: [ + SystemExceptions.NotFound signalOn: self + reason: 'queue empty' + ] ifFalse: [ + ^(self removeFirst) + ] + ] +] + +|f| +f := OrderedCollection new. +f push: 'example'; push: 'another'; push: 'last'. +f pop printNl. +f pop printNl. +f pop printNl. +f isEmpty printNl. +f pop. "queue empty error" diff --git a/Task/Queue-Definition/Standard-ML/queue-definition-1.ml b/Task/Queue-Definition/Standard-ML/queue-definition-1.ml new file mode 100644 index 0000000000..60ed288522 --- /dev/null +++ b/Task/Queue-Definition/Standard-ML/queue-definition-1.ml @@ -0,0 +1,12 @@ +signature QUEUE = +sig + type 'a queue + + val empty_queue: 'a queue + + exception Empty + + val enq: 'a queue -> 'a -> 'a queue + val deq: 'a queue -> ('a * 'a queue) + val empty: 'a queue -> bool +end; diff --git a/Task/Queue-Definition/Standard-ML/queue-definition-2.ml b/Task/Queue-Definition/Standard-ML/queue-definition-2.ml new file mode 100644 index 0000000000..75253212fe --- /dev/null +++ b/Task/Queue-Definition/Standard-ML/queue-definition-2.ml @@ -0,0 +1,16 @@ +structure Queue:> QUEUE = +struct + type 'a queue = 'a list + + val empty_queue = nil + + exception Empty + + fun enq q x = q @ [x] + + fun deq nil = raise Empty + | deq (x::q) = (x, q) + + fun empty nil = true + | empty _ = false +end; diff --git a/Task/Queue-Definition/Tcl/queue-definition-1.tcl b/Task/Queue-Definition/Tcl/queue-definition-1.tcl new file mode 100644 index 0000000000..2262ecae71 --- /dev/null +++ b/Task/Queue-Definition/Tcl/queue-definition-1.tcl @@ -0,0 +1,31 @@ +proc push {stackvar value} { + upvar 1 $stackvar stack + lappend stack $value +} +proc pop {stackvar} { + upvar 1 $stackvar stack + set value [lindex $stack 0] + set stack [lrange $stack 1 end] + return $value +} +proc size {stackvar} { + upvar 1 $stackvar stack + llength $stack +} +proc empty {stackvar} { + upvar 1 $stackvar stack + expr {[size stack] == 0} +} +proc peek {stackvar} { + upvar 1 $stackvar stack + lindex $stack 0 +} + +set Q [list] +empty Q ;# ==> 1 (true) +push Q foo +empty Q ;# ==> 0 (false) +push Q bar +peek Q ;# ==> foo +pop Q ;# ==> foo +peek Q ;# ==> bar diff --git a/Task/Queue-Definition/Tcl/queue-definition-2.tcl b/Task/Queue-Definition/Tcl/queue-definition-2.tcl new file mode 100644 index 0000000000..7306ccd9f1 --- /dev/null +++ b/Task/Queue-Definition/Tcl/queue-definition-2.tcl @@ -0,0 +1,10 @@ +package require struct::queue +struct::queue Q +Q size ;# ==> 0 +Q put a b c d e +Q size ;# ==> 5 +Q peek ;# ==> a +Q get ;# ==> a +Q peek ;# ==> b +Q pop 4 ;# ==> b c d e +Q size ;# ==> 0 diff --git a/Task/Queue-Definition/UnixPipes/queue-definition-1.unixpipes b/Task/Queue-Definition/UnixPipes/queue-definition-1.unixpipes new file mode 100644 index 0000000000..5627374a8e --- /dev/null +++ b/Task/Queue-Definition/UnixPipes/queue-definition-1.unixpipes @@ -0,0 +1,4 @@ +init() {echo > fifo} +push() {echo $1 >> fifo } +pop() {head -1 fifo ; (cat fifo | tail -n +2)|sponge fifo} +empty() {cat fifo | wc -l} diff --git a/Task/Queue-Definition/UnixPipes/queue-definition-2.unixpipes b/Task/Queue-Definition/UnixPipes/queue-definition-2.unixpipes new file mode 100644 index 0000000000..b6dd258eec --- /dev/null +++ b/Task/Queue-Definition/UnixPipes/queue-definition-2.unixpipes @@ -0,0 +1,6 @@ +push me; push you; push us; push them +|pop;pop;pop;pop +me +you +us +them diff --git a/Task/Queue-Definition/V/queue-definition-1.v b/Task/Queue-Definition/V/queue-definition-1.v new file mode 100644 index 0000000000..3a92e36f31 --- /dev/null +++ b/Task/Queue-Definition/V/queue-definition-1.v @@ -0,0 +1,4 @@ +[fifo_create []]. +[fifo_push swap cons]. +[fifo_pop [[*rest a] : [*rest] a] view]. +[fifo_empty? dup empty?]. diff --git a/Task/Queue-Definition/V/queue-definition-2.v b/Task/Queue-Definition/V/queue-definition-2.v new file mode 100644 index 0000000000..ee2596f3f5 --- /dev/null +++ b/Task/Queue-Definition/V/queue-definition-2.v @@ -0,0 +1,8 @@ +|fifo_create 3 fifo_push 4 fifo_push 5 fifo_push ?? +=[5 4 3] +|fifo_empty? puts +=false +|fifo_pop put fifo_pop put fifo_pop put +=3 4 5 +|fifo_empty? puts + =true diff --git a/Task/Queue-Definition/XPL0/queue-definition.xpl0 b/Task/Queue-Definition/XPL0/queue-definition.xpl0 new file mode 100644 index 0000000000..71c01453ed --- /dev/null +++ b/Task/Queue-Definition/XPL0/queue-definition.xpl0 @@ -0,0 +1,48 @@ +include c:\cxpl\codes; +def Size=8; +int Fifo(Size); +int In, Out; \fill and empty indexes into Fifo + +proc Push(A); \Add integer A to queue +int A; \(overflow not detected) +[Fifo(In):= A; +In:= In+1; +if In >= Size then In:= 0; +]; + +func Pop; \Return first integer in queue +int A; +[if Out=In then \if popping empty queue + [Text(0, "Error"); exit 1]; \ then exit program with error code 1 +A:= Fifo(Out); +Out:= Out+1; +if Out >= Size then Out:= 0; +return A; +]; + +func Empty; \Return 'true' if queue is empty +return In = Out; + +[In:= 0; Out:= 0; +Push(0); +Text(0, if Empty then "true" else "false"); CrLf(0); +IntOut(0, Pop); CrLf(0); +Push(1); +Push(2); +Push(3); +IntOut(0, Pop); CrLf(0); +IntOut(0, Pop); CrLf(0); +IntOut(0, Pop); CrLf(0); +Text(0, if Empty then "true" else "false"); CrLf(0); + +\A 256-byte queue is built in as device 8: +OpenI(8); OpenO(8); +ChOut(8, ^0); \push +ChOut(0, ChIn(8)); CrLf(0); \pop +ChOut(8, ^1); \push +ChOut(8, ^2); \push +ChOut(8, ^3); \push +ChOut(0, ChIn(8)); CrLf(0); \pop +ChOut(0, ChIn(8)); CrLf(0); \pop +ChOut(0, ChIn(8)); CrLf(0); \pop +] diff --git a/Task/Queue-Usage/0DESCRIPTION b/Task/Queue-Usage/0DESCRIPTION new file mode 100644 index 0000000000..70a4d872a4 --- /dev/null +++ b/Task/Queue-Usage/0DESCRIPTION @@ -0,0 +1,8 @@ +{{Data structure}} +[[File:Fifo.gif|frame|right|Illustration of FIFO behavior]] +Create a queue data structure and demonstrate its operations. (For implementations of queues, see the [[FIFO]] task.) + +Operations: +* push (aka ''enqueue'') - add element +* pop (aka ''dequeue'') - pop first element +* empty - return truth value when empty diff --git a/Task/Queue-Usage/1META.yaml b/Task/Queue-Usage/1META.yaml new file mode 100644 index 0000000000..32d20151af --- /dev/null +++ b/Task/Queue-Usage/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Data Structures diff --git a/Task/Queue-Usage/Ada/queue-usage.ada b/Task/Queue-Usage/Ada/queue-usage.ada new file mode 100644 index 0000000000..bba7558ea1 --- /dev/null +++ b/Task/Queue-Usage/Ada/queue-usage.ada @@ -0,0 +1,21 @@ +with FIFO; +with Ada.Text_Io; use Ada.Text_Io; + +procedure Queue_Test is + package Int_FIFO is new FIFO (Integer); + use Int_FIFO; + Queue : FIFO_Type; + Value : Integer; +begin + Push (Queue, 1); + Push (Queue, 2); + Push (Queue, 3); + Pop (Queue, Value); + Pop (Queue, Value); + Push (Queue, 4); + Pop (Queue, Value); + Pop (Queue, Value); + Push (Queue, 5); + Pop (Queue, Value); + Put_Line ("Is_Empty " & Boolean'Image (Is_Empty (Queue))); +end Queue_Test; diff --git a/Task/Queue-Usage/AppleScript/queue-usage.applescript b/Task/Queue-Usage/AppleScript/queue-usage.applescript new file mode 100644 index 0000000000..c323f653a0 --- /dev/null +++ b/Task/Queue-Usage/AppleScript/queue-usage.applescript @@ -0,0 +1,29 @@ +on push(StackRef, value) + set StackRef's contents to {value} & StackRef's contents + return StackRef +end push + +on pop(StackRef) + set R to missing value + if StackRef's contents ≠ {} then + set R to StackRef's contents's item 1 + set StackRef's contents to {} & rest of StackRef's contents + end if + return R +end pop + +on isStackEmpty(StackRef) + if StackRef's contents = {} then return true + return false +end isStackEmpty + + +set theStack to {} +repeat with i from 1 to 5 + push(a reference to theStack, i) + log result +end repeat +repeat until isStackEmpty(theStack) = true + pop(a reference to theStack) + log result +end repeat diff --git a/Task/Queue-Usage/AutoHotkey/queue-usage.ahk b/Task/Queue-Usage/AutoHotkey/queue-usage.ahk new file mode 100644 index 0000000000..6fc1bdc069 --- /dev/null +++ b/Task/Queue-Usage/AutoHotkey/queue-usage.ahk @@ -0,0 +1,31 @@ +push("qu", 2), push("qu", 44), push("qu", "xyz") ; TEST + +MsgBox % "Len = " len("qu") ; Number of entries +While !empty("qu") ; Repeat until queue is not empty + MsgBox % pop("qu") ; Print popped values (2, 44, xyz) +MsgBox Error = %ErrorLevel% ; ErrorLevel = 0: OK +MsgBox % pop("qu") ; Empty +MsgBox Error = %ErrorLevel% ; ErrorLevel = -1: popped too much +MsgBox % "Len = " len("qu") ; Number of entries + +push(queue,_) { ; push _ onto queue named "queue" (!=_), _ string not containing | + Global + %queue% .= %queue% = "" ? _ : "|" _ +} + +pop(queue) { ; pop value from queue named "queue" (!=_,_1,_2) + Global + RegExMatch(%queue%, "([^\|]*)\|?(.*)", _) + Return _1, ErrorLevel := -(%queue%=""), %queue% := _2 +} + +empty(queue) { ; check if queue named "queue" is empty + Global + Return %queue% = "" +} + +len(queue) { ; number of entries in "queue" + Global + StringReplace %queue%, %queue%, |, |, UseErrorLevel + Return %queue% = "" ? 0 : ErrorLevel+1 +} diff --git a/Task/Queue-Usage/BBC-BASIC/queue-usage.bbc b/Task/Queue-Usage/BBC-BASIC/queue-usage.bbc new file mode 100644 index 0000000000..a4cdba0721 --- /dev/null +++ b/Task/Queue-Usage/BBC-BASIC/queue-usage.bbc @@ -0,0 +1,31 @@ + FIFOSIZE = 1000 + + FOR n = 3 TO 5 + PRINT "Push ";n : PROCenqueue(n) + NEXT + PRINT "Pop " ; FNdequeue + PRINT "Push 6" : PROCenqueue(6) + REPEAT + PRINT "Pop " ; FNdequeue + UNTIL FNisempty + PRINT "Pop " ; FNdequeue + END + + DEF PROCenqueue(n) : LOCAL f% + DEF FNdequeue : LOCAL f% : f% = 1 + DEF FNisempty : LOCAL f% : f% = 2 + PRIVATE fifo(), rptr%, wptr% + DIM fifo(FIFOSIZE-1) + CASE f% OF + WHEN 0: + wptr% = (wptr% + 1) MOD FIFOSIZE + IF rptr% = wptr% ERROR 100, "Error: queue overflowed" + fifo(wptr%) = n + WHEN 1: + IF rptr% = wptr% ERROR 101, "Error: queue empty" + rptr% = (rptr% + 1) MOD FIFOSIZE + = fifo(rptr%) + WHEN 2: + = (rptr% = wptr%) + ENDCASE + ENDPROC diff --git a/Task/Queue-Usage/C++/queue-usage-1.cpp b/Task/Queue-Usage/C++/queue-usage-1.cpp new file mode 100644 index 0000000000..a3b32081b2 --- /dev/null +++ b/Task/Queue-Usage/C++/queue-usage-1.cpp @@ -0,0 +1,46 @@ +#include +#include // for run time assertions + +int main() +{ + std::queue q; + assert( q.empty() ); // initially the queue is empty + + q.push(1); // add an element + assert( !q.empty() ); // now the queue isn't empty any more + assert( q.front() == 1 ); // the first element is, of course, 1 + + q.push(2); // add another element + assert( !q.empty() ); // it's of course not empty again + assert( q.front() == 1 ); // the first element didn't change + + q.push(3); // add yet an other element + assert( !q.empty() ); // the queue is still not empty + assert( q.front() == 1 ); // and the first element is still 1 + + q.pop(); // remove the first element + assert( !q.empty() ); // the queue is not yet empty + assert( q.front() == 2); // the first element is now 2 (the 1 is gone) + + q.pop(); + assert( !q.empty() ); + assert( q.front() == 3); + + q.push(4); + assert( !q.empty() ); + assert( q.front() == 3); + + q.pop(); + assert( !q.empty() ); + assert( q.front() == 4); + + q.pop(); + assert( q.empty() ); + + q.push(5); + assert( !q.empty() ); + assert( q.front() == 5); + + q.pop(); + assert( q.empty() ); +} diff --git a/Task/Queue-Usage/C++/queue-usage-2.cpp b/Task/Queue-Usage/C++/queue-usage-2.cpp new file mode 100644 index 0000000000..5d133c15a3 --- /dev/null +++ b/Task/Queue-Usage/C++/queue-usage-2.cpp @@ -0,0 +1 @@ + std::queue > diff --git a/Task/Queue-Usage/C-sharp/queue-usage.cs b/Task/Queue-Usage/C-sharp/queue-usage.cs new file mode 100644 index 0000000000..2b829ce899 --- /dev/null +++ b/Task/Queue-Usage/C-sharp/queue-usage.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; + +namespace RosettaCode +{ + class Program + { + static void Main() + { + // Create a queue and "push" items into it + Queue queue = new Queue(); + queue.Enqueue(1); + queue.Enqueue(3); + queue.Enqueue(5); + + // "Pop" items from the queue in FIFO order + Console.WriteLine(queue.Dequeue()); // 1 + Console.WriteLine(queue.Dequeue()); // 3 + Console.WriteLine(queue.Dequeue()); // 5 + + // To tell if the queue is empty, we check the count + bool empty = queue.Count == 0; + Console.WriteLine(empty); // "True" + + // If we try to pop from an empty queue, an exception + // is thrown. + try + { + queue.Dequeue(); + } + catch (InvalidOperationException exception) + { + Console.WriteLine(exception.Message); // "Queue empty." + } + } + } +} diff --git a/Task/Queue-Usage/C/queue-usage.c b/Task/Queue-Usage/C/queue-usage.c new file mode 100644 index 0000000000..cf3869b6e7 --- /dev/null +++ b/Task/Queue-Usage/C/queue-usage.c @@ -0,0 +1,31 @@ +#include +#include +#include + +#include + +/* #include "fifolist.h" */ + +int main() +{ + int i; + FIFOList head; + + TAILQ_INIT(&head); + + /* insert 20 integer values */ + for(i=0; i < 20; i++) { + m_enqueue(i, &head); + } + + /* dequeue and print */ + while( m_dequeue(&i, &head) ) + printf("%d\n", i); + + fprintf(stderr, "FIFO list %s\n", + ( m_dequeue(&i, &head) ) ? + "had still an element" : + "is void!"); + + exit(0); +} diff --git a/Task/Queue-Usage/Clojure/queue-usage-1.clj b/Task/Queue-Usage/Clojure/queue-usage-1.clj new file mode 100644 index 0000000000..8bc126d4ee --- /dev/null +++ b/Task/Queue-Usage/Clojure/queue-usage-1.clj @@ -0,0 +1,11 @@ +(def q (make-queue)) + +(enqueue q 1) +(enqueue q 2) +(enqueue q 3) + +(dequeue q) ; 1 +(dequeue q) ; 2 +(dequeue q) ; 3 + +(queue-empty? q) ; true diff --git a/Task/Queue-Usage/Clojure/queue-usage-2.clj b/Task/Queue-Usage/Clojure/queue-usage-2.clj new file mode 100644 index 0000000000..c792af4fb4 --- /dev/null +++ b/Task/Queue-Usage/Clojure/queue-usage-2.clj @@ -0,0 +1,11 @@ +(def q (java.util.LinkedList.)) + +(.add q 1) +(.add q 2) +(.add q 3) + +(.remove q) ; 1 +(.remove q) ; 2 +(.remove q) ; 3 + +(.isEmpty q) ; true diff --git a/Task/Queue-Usage/CoffeeScript/queue-usage-1.coffeescript b/Task/Queue-Usage/CoffeeScript/queue-usage-1.coffeescript new file mode 100644 index 0000000000..43eec2ca9f --- /dev/null +++ b/Task/Queue-Usage/CoffeeScript/queue-usage-1.coffeescript @@ -0,0 +1,32 @@ +# We build a Queue on top of an ordinary JS array, which supports push +# and shift. For simple queues, it might make sense to just use arrays +# directly, but this code shows how to encapsulate the array behind a restricted +# API. For very large queues, you might want a more specialized data +# structure to implement the queue, in case arr.shift works in O(N) time, which +# is common for array implementations. On my laptop I start noticing delay +# after about 100,000 elements, using node.js. +Queue = -> + arr = [] + enqueue: (elem) -> + arr.push elem + dequeue: (elem) -> + throw Error("queue is empty") if arr.length == 0 + arr.shift elem + is_empty: (elem) -> + arr.length == 0 + +# test +do -> + q = Queue() + for i in [1..100000] + q.enqueue i + + console.log q.dequeue() # 1 + while !q.is_empty() + v = q.dequeue() + console.log v # 1000 + + try + q.dequeue() # throws Error + catch e + console.log "#{e}" diff --git a/Task/Queue-Usage/CoffeeScript/queue-usage-2.coffeescript b/Task/Queue-Usage/CoffeeScript/queue-usage-2.coffeescript new file mode 100644 index 0000000000..7381175705 --- /dev/null +++ b/Task/Queue-Usage/CoffeeScript/queue-usage-2.coffeescript @@ -0,0 +1,4 @@ +> coffee queue.coffee +1 +100000 +Error: queue is empty diff --git a/Task/Queue-Usage/Common-Lisp/queue-usage.lisp b/Task/Queue-Usage/Common-Lisp/queue-usage.lisp new file mode 100644 index 0000000000..d6e3ef6578 --- /dev/null +++ b/Task/Queue-Usage/Common-Lisp/queue-usage.lisp @@ -0,0 +1,7 @@ +(let ((queue (make-queue))) + (enqueue 38 queue) + (assert (not (queue-empty-p queue))) + (enqueue 23 queue) + (assert (eql 38 (dequeue queue))) + (assert (eql 23 (dequeue queue))) + (assert (queue-empty-p queue))) diff --git a/Task/Queue-Usage/D/queue-usage-1.d b/Task/Queue-Usage/D/queue-usage-1.d new file mode 100644 index 0000000000..3f26479856 --- /dev/null +++ b/Task/Queue-Usage/D/queue-usage-1.d @@ -0,0 +1,44 @@ +class LinkedQueue(T) { + private static struct Node { + T data; + Node* next; + } + + private Node* head, tail; + + bool empty() { return head is null; } + + void push(T item) { + if (empty()) + head = tail = new Node(item); + else { + tail.next = new Node(item); + tail = tail.next; + } + } + + T pop() { + if (empty()) + throw new Exception("Empty LinkedQueue."); + auto item = head.data; + head = head.next; + if (head is tail) // Is last one? + // Release tail reference so that GC can collect. + tail = null; + return item; + } + + alias push enqueue; + alias pop dequeue; +} + +void main() { + auto q = new LinkedQueue!int(); + q.push(10); + q.push(20); + q.push(30); + assert(q.pop() == 10); + assert(q.pop() == 20); + assert(q.pop() == 30); + assert(q.empty()); +} diff --git a/Task/Queue-Usage/D/queue-usage-2.d b/Task/Queue-Usage/D/queue-usage-2.d new file mode 100644 index 0000000000..69791d4537 --- /dev/null +++ b/Task/Queue-Usage/D/queue-usage-2.d @@ -0,0 +1,64 @@ +module queue_usage2; + +import std.traits: hasIndirections; + +struct GrowableCircularQueue(T) { + public size_t length; + private size_t head, tail; + private T[] A = [T.init]; + private uint power2 = 0; + + bool empty() const pure nothrow { + return length == 0; + } + + void push(immutable T item) pure nothrow { + if (length >= A.length) { // Double the queue. + const old = A; + A = new T[A.length * 2]; + A[0 .. (old.length - head)] = old[head .. $]; + if (head) + A[(old.length - head) .. old.length] = old[0 .. head]; + head = 0; + tail = length; + power2++; + } + A[tail] = item; + tail = (tail + 1) & ((cast(size_t)1 << power2) - 1); + length++; + } + + T pop() pure { + if (length == 0) + throw new Exception("GrowableCircularQueue is empty."); + auto saved = A[head]; + static if (hasIndirections!T) + A[head] = T.init; // Help for the GC. + head = (head + 1) & ((cast(size_t)1 << power2) - 1); + length--; + return saved; + } +} + +version (queue_usage2_main) { + unittest { + auto q = new GrowableCircularQueue!int(); + q.push(10); + q.push(20); + q.push(30); + assert(q.pop() == 10); + assert(q.pop() == 20); + assert(q.pop() == 30); + assert(q.empty()); + + uint count = 0; + foreach (immutable i; 1 .. 1_000) { + foreach (immutable j; 0 .. i) + q.push(count++); + foreach (immutable j; 0 .. i) + q.pop(); + } + } + + void main() {} +} diff --git a/Task/Queue-Usage/Delphi/queue-usage.delphi b/Task/Queue-Usage/Delphi/queue-usage.delphi new file mode 100644 index 0000000000..1e43ca884a --- /dev/null +++ b/Task/Queue-Usage/Delphi/queue-usage.delphi @@ -0,0 +1,25 @@ +program QueueUsage; + +{$APPTYPE CONSOLE} + +uses Generics.Collections; + +var + lStringQueue: TQueue; +begin + lStringQueue := TQueue.Create; + try + lStringQueue.Enqueue('First'); + lStringQueue.Enqueue('Second'); + lStringQueue.Enqueue('Third'); + + Writeln(lStringQueue.Dequeue); + Writeln(lStringQueue.Dequeue); + Writeln(lStringQueue.Dequeue); + + if lStringQueue.Count = 0 then + Writeln('Queue is empty.'); + finally + lStringQueue.Free; + end +end. diff --git a/Task/Queue-Usage/E/queue-usage.e b/Task/Queue-Usage/E/queue-usage.e new file mode 100644 index 0000000000..7ff7339b9c --- /dev/null +++ b/Task/Queue-Usage/E/queue-usage.e @@ -0,0 +1,9 @@ +def [reader, writer] := makeQueue() +require(escape empty { reader.dequeue(empty); false } catch _ { true }) +writer.enqueue(1) +writer.enqueue(2) +require(reader.dequeue(throw) == 1) +writer.enqueue(3) +require(reader.dequeue(throw) == 2) +require(reader.dequeue(throw) == 3) +require(escape empty { reader.dequeue(empty); false } catch _ { true }) diff --git a/Task/Queue-Usage/Erlang/queue-usage.erl b/Task/Queue-Usage/Erlang/queue-usage.erl new file mode 100644 index 0000000000..fefde4db09 --- /dev/null +++ b/Task/Queue-Usage/Erlang/queue-usage.erl @@ -0,0 +1,17 @@ +1> Q = fifo:new(). +{fifo,[],[]} +2> fifo:empty(Q). +true +3> Q2 = fifo:push(Q,1). +{fifo,[1],[]} +4> Q3 = fifo:push(Q2,2). +{fifo,[2,1],[]} +5> fifo:empty(Q3). +false +6> fifo:pop(Q3). +{1,{fifo,[],[2]}} +7> {Popped, Q} = fifo:pop(Q2). +{1,{fifo,[],[]}} +8> fifo:pop(fifo:new()). +** exception error: 'empty fifo' + in function fifo:pop/1 diff --git a/Task/Queue-Usage/Fantom/queue-usage.fantom b/Task/Queue-Usage/Fantom/queue-usage.fantom new file mode 100644 index 0000000000..e15c0bcba0 --- /dev/null +++ b/Task/Queue-Usage/Fantom/queue-usage.fantom @@ -0,0 +1,14 @@ +class Main +{ + public static Void main () + { + q := Queue() + q.push (1) + q.push ("a") + echo ("Is empty? " + q.isEmpty) + echo ("Element: " + q.pop) + echo ("Element: " + q.pop) + echo ("Is empty? " + q.isEmpty) + try { q.pop } catch (Err e) { echo (e.msg) } + } +} diff --git a/Task/Queue-Usage/Fortran/queue-usage.f b/Task/Queue-Usage/Fortran/queue-usage.f new file mode 100644 index 0000000000..b27845b545 --- /dev/null +++ b/Task/Queue-Usage/Fortran/queue-usage.f @@ -0,0 +1,33 @@ +module fifo_nodes + type fifo_node + integer :: datum + ! the next part is not variable and must be present + type(fifo_node), pointer :: next + logical :: valid + end type fifo_node +end module fifo_nodes + +program FIFOTest + use fifo + implicit none + + type(fifo_head) :: thehead + type(fifo_node), dimension(5) :: ex, xe + integer :: i + + call new_fifo(thehead) + + do i = 1, 5 + ex(i)%datum = i + call fifo_enqueue(thehead, ex(i)) + end do + + i = 1 + do + call fifo_dequeue(thehead, xe(i)) + print *, xe(i)%datum + i = i + 1 + if ( fifo_isempty(thehead) ) exit + end do + +end program FIFOTest diff --git a/Task/Queue-Usage/Go/queue-usage-1.go b/Task/Queue-Usage/Go/queue-usage-1.go new file mode 100644 index 0000000000..87b4257a6f --- /dev/null +++ b/Task/Queue-Usage/Go/queue-usage-1.go @@ -0,0 +1,39 @@ +package main + +import ( + "fmt" + "queue" +) + +func main() { + q := new(queue.Queue) + fmt.Println("empty?", q.Empty()) + + x := "black" + fmt.Println("push", x) + q.Push(x) + + fmt.Println("empty?", q.Empty()) + r, ok := q.Pop() + if ok { + fmt.Println(r, "popped") + } else { + fmt.Println("pop failed") + } + + var n int + for _, x := range []string{"blue", "red", "green"} { + fmt.Println("pushing", x) + q.Push(x) + n++ + } + + for i := 0; i < n; i++ { + r, ok := q.Pop() + if ok { + fmt.Println(r, "popped") + } else { + fmt.Println("pop failed") + } + } +} diff --git a/Task/Queue-Usage/Go/queue-usage-2.go b/Task/Queue-Usage/Go/queue-usage-2.go new file mode 100644 index 0000000000..5c166c4c22 --- /dev/null +++ b/Task/Queue-Usage/Go/queue-usage-2.go @@ -0,0 +1,36 @@ +package main + +import "fmt" + +func main() { + q := make(chan string, 3) + fmt.Println("empty?", len(q) == 0) + + x := "black" + fmt.Println("push", x) + q <- x + + fmt.Println("empty?", len(q) == 0) + select { + case r := <-q: + fmt.Println(r, "popped") + default: + fmt.Println("pop failed") + } + + var n int + for _, x := range []string{"blue", "red", "green"} { + fmt.Println("pushing", x) + q <- x + n++ + } + + for i := 0; i < n; i++ { + select { + case r := <-q: + fmt.Println(r, "popped") + default: + fmt.Println("pop failed") + } + } +} diff --git a/Task/Queue-Usage/Go/queue-usage-3.go b/Task/Queue-Usage/Go/queue-usage-3.go new file mode 100644 index 0000000000..2830f87ef2 --- /dev/null +++ b/Task/Queue-Usage/Go/queue-usage-3.go @@ -0,0 +1,39 @@ +package main + +import ( + "fmt" + "container/list" +) + +func main() { + q := list.New() + fmt.Println("empty?", q.Len() == 0) + + x := "black" + fmt.Println("push", x) + q.PushBack(x) + + fmt.Println("empty?", q.Len() == 0) + if e := q.Front(); e != nil { + r := q.Remove(e) + fmt.Println(r, "popped") + } else { + fmt.Println("pop failed") + } + + var n int + for _, x := range []string{"blue", "red", "green"} { + fmt.Println("pushing", x) + q.PushBack(x) + n++ + } + + for i := 0; i < n; i++ { + if e := q.Front(); e != nil { + r := q.Remove(e) + fmt.Println(r, "popped") + } else { + fmt.Println("pop failed") + } + } +} diff --git a/Task/Queue-Usage/Groovy/queue-usage-1.groovy b/Task/Queue-Usage/Groovy/queue-usage-1.groovy new file mode 100644 index 0000000000..7238cfa650 --- /dev/null +++ b/Task/Queue-Usage/Groovy/queue-usage-1.groovy @@ -0,0 +1 @@ +def q = new LinkedList() diff --git a/Task/Queue-Usage/Groovy/queue-usage-2.groovy b/Task/Queue-Usage/Groovy/queue-usage-2.groovy new file mode 100644 index 0000000000..9c4996e85d --- /dev/null +++ b/Task/Queue-Usage/Groovy/queue-usage-2.groovy @@ -0,0 +1,46 @@ +assert q.empty +println q +// "push" adds to end of "queue" list +q.push('Stuart') +println q +assert !q.empty +// "add" adds to end of "queue" list +q.add('Pete') +println q +assert !q.empty +// left shift operator ("<<") adds to end of "queue" list +q << 'John' +println q +assert !q.empty +// add assignment ("+=") adds the list elements +// to the end of the "queue" list in list order +q += ['Paul', 'George'] +println q +assert !q.empty +// "poll" removes and returns the first element in the +// "queue" list ("pop" exists for Groovy lists, but it +// removes and returns the LAST element for "Stack" +// semantics). "poll" only exists in objects that +// implement java.util.Queue, like java.util.LinkedList +assert q.poll() == 'Stuart' +println q +assert !q.empty +assert q.poll() == 'Pete' +println q +assert !q.empty +q << 'Ringo' +println q +assert !q.empty +assert q.poll() == 'John' +println q +assert !q.empty +assert q.poll() == 'Paul' +println q +assert !q.empty +assert q.poll() == 'George' +println q +assert !q.empty +assert q.poll() == 'Ringo' +println q +assert q.empty +assert q.poll() == null diff --git a/Task/Queue-Usage/Haskell/queue-usage.hs b/Task/Queue-Usage/Haskell/queue-usage.hs new file mode 100644 index 0000000000..2e58a9aebc --- /dev/null +++ b/Task/Queue-Usage/Haskell/queue-usage.hs @@ -0,0 +1,25 @@ +Prelude> :l fifo.hs +[1 of 1] Compiling Main ( fifo.hs, interpreted ) +Ok, modules loaded: Main. +*Main> let q = emptyFifo +*Main> isEmpty q +True +*Main> let q' = push q 1 +*Main> isEmpty q' +False +*Main> let q'' = foldl push q' [2..4] +*Main> let (v,q''') = pop q'' +*Main> v +Just 1 +*Main> let (v',q'''') = pop q''' +*Main> v' +Just 2 +*Main> let (v'',q''''') = pop q'''' +*Main> v'' +Just 3 +*Main> let (v''',q'''''') = pop q''''' +*Main> v''' +Just 4 +*Main> let (v'''',q''''''') = pop q'''''' +*Main> v'''' +Nothing diff --git a/Task/Queue-Usage/Icon/queue-usage.icon b/Task/Queue-Usage/Icon/queue-usage.icon new file mode 100644 index 0000000000..a03fafb967 --- /dev/null +++ b/Task/Queue-Usage/Icon/queue-usage.icon @@ -0,0 +1,18 @@ +procedure main(arglist) +queue := [] +write("Usage:\nqueue x x x - x - - - - -\n\t- pops elements\n\teverything else pushes") +write("Queue is:") +every x := !arglist do { + case x of { + "-" : pop(queue) | write("pop(empty) failed.") # pop if the next arglist[i] is a - + default : put(queue,x) # push arglist[i] + } + if empty(queue) then writes("empty") + else every writes(!queue," ") + write() + } +end + +procedure empty(X) #: fail if X is not empty +if *X = 0 then return +end diff --git a/Task/Queue-Usage/J/queue-usage-1.j b/Task/Queue-Usage/J/queue-usage-1.j new file mode 100644 index 0000000000..6d7c54369b --- /dev/null +++ b/Task/Queue-Usage/J/queue-usage-1.j @@ -0,0 +1,19 @@ + queue=: conew 'fifo' + isEmpty__queue '' +1 + push__queue 9 +9 + push__queue 8 +8 + push__queue 7 +7 + isEmpty__queue '' +0 + pop__queue '' +9 + pop__queue '' +8 + pop__queue '' +7 + isEmpty__queue '' +1 diff --git a/Task/Queue-Usage/J/queue-usage-2.j b/Task/Queue-Usage/J/queue-usage-2.j new file mode 100644 index 0000000000..3b23fa5f47 --- /dev/null +++ b/Task/Queue-Usage/J/queue-usage-2.j @@ -0,0 +1,17 @@ + is_empty make_empty _ +1 + first_named_state =: push 9 onto make_empty _ + newer_state =: push 8 onto first_named_state + this_state =: push 7 onto newer_state + is_empty this_state +0 + tell_queue this_state +9 8 7 + tell_atom pop this_state +9 + tell_atom pop pop this_state +8 + tell_atom pop pop pop this_state +7 + is_empty pop pop pop this_state +1 diff --git a/Task/Queue-Usage/Java/queue-usage-1.java b/Task/Queue-Usage/Java/queue-usage-1.java new file mode 100644 index 0000000000..62aceb6bdd --- /dev/null +++ b/Task/Queue-Usage/Java/queue-usage-1.java @@ -0,0 +1,13 @@ +import java.util.LinkedList; +import java.util.Queue; +... +Queue queue = new LinkedList(); +System.out.println(queue.isEmpty()); // empty test - true +// queue.remove(); // would throw NoSuchElementException +queue.add(1); +queue.add(2); +queue.add(3); +System.out.println(queue); // [1, 2, 3] +System.out.println(queue.remove()); // 1 +System.out.println(queue); // [2, 3] +System.out.println(queue.isEmpty()); // false diff --git a/Task/Queue-Usage/Java/queue-usage-2.java b/Task/Queue-Usage/Java/queue-usage-2.java new file mode 100644 index 0000000000..3e1f1da23a --- /dev/null +++ b/Task/Queue-Usage/Java/queue-usage-2.java @@ -0,0 +1,11 @@ +import java.util.LinkedList; +... +LinkedList queue = new LinkedList(); +System.out.println(queue.isEmpty()); // empty test - true +queue.add(new Integer(1)); +queue.add(new Integer(2)); +queue.add(new Integer(3)); +System.out.println(queue); // [1, 2, 3] +System.out.println(queue.removeFirst()); // 1 +System.out.println(queue); // [2, 3] +System.out.println(queue.isEmpty()); // false diff --git a/Task/Queue-Usage/JavaScript/queue-usage.js b/Task/Queue-Usage/JavaScript/queue-usage.js new file mode 100644 index 0000000000..deee08f3f9 --- /dev/null +++ b/Task/Queue-Usage/JavaScript/queue-usage.js @@ -0,0 +1,10 @@ +var f = new Array(); +print(f.length); +f.push(1,2); // can take multiple arguments +f.push(3); +f.shift(); +f.shift(); +print(f.length); +print(f.shift()) +print(f.length == 0); +print(f.shift()); diff --git a/Task/Queue-Usage/Logo/queue-usage.logo b/Task/Queue-Usage/Logo/queue-usage.logo new file mode 100644 index 0000000000..5ba095b7da --- /dev/null +++ b/Task/Queue-Usage/Logo/queue-usage.logo @@ -0,0 +1,9 @@ +make "fifo [] +print empty? :fifo ; true +queue "fifo 1 +queue "fifo 2 +queue "fifo 3 +show :fifo ; [1 2 3] +print dequeue "fifo ; 1 +show :fifo ; [2 3] +print empty? :fifo ; false diff --git a/Task/Queue-Usage/Lua/queue-usage.lua b/Task/Queue-Usage/Lua/queue-usage.lua new file mode 100644 index 0000000000..9d5b36804a --- /dev/null +++ b/Task/Queue-Usage/Lua/queue-usage.lua @@ -0,0 +1,7 @@ +q = Queue.new() +Queue.push( q, 5 ) +Queue.push( q, "abc" ) + +while not Queue.empty( q ) do + print( Queue.pop( q ) ) +end diff --git a/Task/Queue-Usage/Mathematica/queue-usage.math b/Task/Queue-Usage/Mathematica/queue-usage.math new file mode 100644 index 0000000000..0f11d419fd --- /dev/null +++ b/Task/Queue-Usage/Mathematica/queue-usage.math @@ -0,0 +1,16 @@ +Empty[a_] := If[Length[a] == 0, True, False] +SetAttributes[Push, HoldAll]; Push[a_, elem_] := AppendTo[a, elem] +SetAttributes[Pop, HoldAllComplete]; Pop[a_] := If[EmptyQ[a], False, b = First[a]; Set[a, Most[a]]; b] + +Queue = {} +-> {} +Empty[Queue] +-> True +Push[Queue, "1"] +-> {"1"} +EmptyQ[Queue] +->False +Pop[Queue] +->1 +Pop[Queue] +->False diff --git a/Task/Queue-Usage/NetRexx/queue-usage.netrexx b/Task/Queue-Usage/NetRexx/queue-usage.netrexx new file mode 100644 index 0000000000..73e1afc406 --- /dev/null +++ b/Task/Queue-Usage/NetRexx/queue-usage.netrexx @@ -0,0 +1,65 @@ +/* NetRexx */ +options replace format comments java crossref savelog symbols nobinary + +-- Queue Usage Demonstration Program ------------------------------------------- +method main(args = String[]) public constant + kew = RCQueueImpl() + do + say kew.pop() + catch ex = IndexOutOfBoundsException + say ex.getMessage + say + end + + melancholyDane = '' + melancholyDane[0] = 4 + melancholyDane[1] = 'To be' + melancholyDane[2] = 'or' + melancholyDane[3] = 'not to be?' + melancholyDane[4] = 'That is the question.' + + loop p_ = melancholyDane[0] to 1 by -1 + kew.push(melancholyDane[p_]) + end p_ + + loop while \kew.empty + popped = kew.pop + say popped '\-' + end + say; say + + -- demonstrate stowing something other than a text string in the queue + kew.push(melancholyDane) + md = kew.pop + loop l_ = 1 to md[0] + say md[l_] '\-' + end l_ + say + + return + +-- Queue implementation -------------------------------------------------------- +class RCQueueImpl + properties private + qqq = Deque + +method RCQueueImpl() public + qqq = ArrayDeque() + return + +method push(stuff) public + qqq.push(stuff) + return + +method pop() public returns Rexx signals IndexOutOfBoundsException + if qqq.isEmpty then signal IndexOutOfBoundsException('The queue is empty') + return Rexx qqq.pop() + +method empty() public binary returns boolean + return qqq.isEmpty + +method isTrue public constant binary returns boolean + return 1 == 1 + +method isFalse public constant binary returns boolean + return \isTrue diff --git a/Task/Queue-Usage/OCaml/queue-usage.ocaml b/Task/Queue-Usage/OCaml/queue-usage.ocaml new file mode 100644 index 0000000000..37af2c2551 --- /dev/null +++ b/Task/Queue-Usage/OCaml/queue-usage.ocaml @@ -0,0 +1,37 @@ +# let q = Queue.create ();; +val q : '_a Queue.t = +# Queue.is_empty q;; +- : bool = true +# Queue.add 1 q;; +- : unit = () +# Queue.is_empty q;; +- : bool = false +# Queue.add 2 q;; +- : unit = () +# Queue.add 3 q;; +- : unit = () +# Queue.peek q;; +- : int = 1 +# Queue.length q;; +- : int = 3 +# Queue.iter (Printf.printf "%d, ") q; print_newline ();; +1, 2, 3, +- : unit = () +# Queue.take q;; +- : int = 1 +# Queue.take q;; +- : int = 2 +# Queue.peek q;; +- : int = 3 +# Queue.length q;; +- : int = 1 +# Queue.add 4 q;; +- : unit = () +# Queue.take q;; +- : int = 3 +# Queue.peek q;; +- : int = 4 +# Queue.take q;; +- : int = 4 +# Queue.is_empty q;; +- : bool = true diff --git a/Task/Queue-Usage/Objeck/queue-usage.objeck b/Task/Queue-Usage/Objeck/queue-usage.objeck new file mode 100644 index 0000000000..3fefcb64cf --- /dev/null +++ b/Task/Queue-Usage/Objeck/queue-usage.objeck @@ -0,0 +1,14 @@ +class Test { + function : Main(args : String[]) ~ Nil { + q := Struct.IntQueue->New(); + q->Add(1); + q->Add(2); + q->Add(3); + + q->Remove()->PrintLine(); + q->Remove()->PrintLine(); + q->Remove()->PrintLine(); + + q->IsEmpty()->PrintLine(); + } +} diff --git a/Task/Queue-Usage/Oz/queue-usage.oz b/Task/Queue-Usage/Oz/queue-usage.oz new file mode 100644 index 0000000000..80e895cfeb --- /dev/null +++ b/Task/Queue-Usage/Oz/queue-usage.oz @@ -0,0 +1,12 @@ +declare + [Queue] = {Link ['x-oz://system/adt/Queue.ozf']} + MyQueue = {Queue.new} +in + {MyQueue.isEmpty} = true + {MyQueue.put foo} + {MyQueue.put bar} + {MyQueue.put baz} + {MyQueue.isEmpty} = false + {Show {MyQueue.get}} %% foo + {Show {MyQueue.get}} %% bar + {Show {MyQueue.get}} %% baz diff --git a/Task/Queue-Usage/PHP/queue-usage.php b/Task/Queue-Usage/PHP/queue-usage.php new file mode 100644 index 0000000000..dd021d324b --- /dev/null +++ b/Task/Queue-Usage/PHP/queue-usage.php @@ -0,0 +1,10 @@ +isEmpty() ? 'true' : 'false', "\n"; // empty test - returns true +// $queue->dequeue(); // would raise RuntimeException +$queue->enqueue(1); +$queue->enqueue(2); +$queue->enqueue(3); +echo $queue->dequeue(), "\n"; // returns 1 +echo $queue->isEmpty() ? 'true' : 'false', "\n"; // returns false +?> diff --git a/Task/Queue-Usage/PL-I/queue-usage-1.pli b/Task/Queue-Usage/PL-I/queue-usage-1.pli new file mode 100644 index 0000000000..86871f8e0a --- /dev/null +++ b/Task/Queue-Usage/PL-I/queue-usage-1.pli @@ -0,0 +1,40 @@ +test: proc options (main); + + + /* To implement a queue. */ + define structure + 1 node, + 2 value fixed, + 2 link handle(node); + declare (head, tail, t) handle (node); + declare null builtin; + declare i fixed binary; + + head, tail = bind(:node, null:); + + do i = 1 to 10; /* Add ten items to the tail of the queue. */ + if head = bind(:node, null:) then + do; + head,tail = new(:node:); + get list (head => value); + put skip list (head => value); + head => link = bind(:node, null:); /* A NULL link */ + end; + else + do; + t = new(:node:); + tail => link = t; /* Point the tail to the new node. */ + tail = t; + tail => link = bind(:node, null:); /* Set the tail link to NULL */ + get list (tail => value) copy; + put skip list (tail => value); + end; + end; + + /* Pop all the items in the queue. */ + put skip list ('The queue has:'); + do while (head ^= bind(:node, null:)); + put skip list (head => value); + head = head => link; + end; +end test; diff --git a/Task/Queue-Usage/PL-I/queue-usage-2.pli b/Task/Queue-Usage/PL-I/queue-usage-2.pli new file mode 100644 index 0000000000..c4f6657c5c --- /dev/null +++ b/Task/Queue-Usage/PL-I/queue-usage-2.pli @@ -0,0 +1,21 @@ + 1 + 3 + 5 + 7 + 9 + 11 + 13 + 15 + 17 + 19 +The queue has: + 1 + 3 + 5 + 7 + 9 + 11 + 13 + 15 + 17 + 19 diff --git a/Task/Queue-Usage/Perl-6/queue-usage-1.pl6 b/Task/Queue-Usage/Perl-6/queue-usage-1.pl6 new file mode 100644 index 0000000000..a89ecbf1bc --- /dev/null +++ b/Task/Queue-Usage/Perl-6/queue-usage-1.pl6 @@ -0,0 +1,3 @@ +push (aka enqueue) -- @list.push +pop (aka dequeue) -- @list.shift +empty -- !@list.elems diff --git a/Task/Queue-Usage/Perl-6/queue-usage-2.pl6 b/Task/Queue-Usage/Perl-6/queue-usage-2.pl6 new file mode 100644 index 0000000000..add21a7c94 --- /dev/null +++ b/Task/Queue-Usage/Perl-6/queue-usage-2.pl6 @@ -0,0 +1,12 @@ +my @queue = < a >; + +@queue.push('b', 'c'); # [ a, b, c ] + +say @queue.shift; # a +say @queue.pop; # c + +say @queue.perl; # [ b ] +say @queue.elems; # 1 + +@queue.unshift('A'); # [ A, b ] +@queue.push('C'); # [ A, b, C ] diff --git a/Task/Queue-Usage/Perl/queue-usage-1.pl b/Task/Queue-Usage/Perl/queue-usage-1.pl new file mode 100644 index 0000000000..dab6c16003 --- /dev/null +++ b/Task/Queue-Usage/Perl/queue-usage-1.pl @@ -0,0 +1,11 @@ +@queue = (); # we will simulate a queue in a array + +push @queue, (1..5); # enqueue numbers from 1 to 5 + +print shift @queue,"\n"; # dequeue + +print "array is empty\n" unless @queue; # is empty ? + +print $n while($n = shift @queue); # dequeue all +print "\n"; +print "array is empty\n" unless @queue; # is empty ? diff --git a/Task/Queue-Usage/Perl/queue-usage-2.pl b/Task/Queue-Usage/Perl/queue-usage-2.pl new file mode 100644 index 0000000000..a41f7b17b6 --- /dev/null +++ b/Task/Queue-Usage/Perl/queue-usage-2.pl @@ -0,0 +1,3 @@ +1 +2345 +array is empty diff --git a/Task/Queue-Usage/PicoLisp/queue-usage.l b/Task/Queue-Usage/PicoLisp/queue-usage.l new file mode 100644 index 0000000000..39718bb4e6 --- /dev/null +++ b/Task/Queue-Usage/PicoLisp/queue-usage.l @@ -0,0 +1,5 @@ +(println (fifo 'Queue)) # Retrieve the number '1' +(println (fifo 'Queue)) # Retrieve an internal symbol 'abc' +(println (fifo 'Queue)) # Retrieve a transient symbol "abc" +(println (fifo 'Queue)) # and a list (abc) +(println (fifo 'Queue)) # Queue is empty -> NIL diff --git a/Task/Queue-Usage/PostScript/queue-usage.ps b/Task/Queue-Usage/PostScript/queue-usage.ps new file mode 100644 index 0000000000..80787646b5 --- /dev/null +++ b/Task/Queue-Usage/PostScript/queue-usage.ps @@ -0,0 +1,6 @@ + [1 2 3 4 5] 6 exch tadd + = [1 2 3 4 5 6] + uncons + = 1 [2 3 4 5 6] + [] empty? + =true diff --git a/Task/Queue-Usage/Prolog/queue-usage.pro b/Task/Queue-Usage/Prolog/queue-usage.pro new file mode 100644 index 0000000000..62c2048fcb --- /dev/null +++ b/Task/Queue-Usage/Prolog/queue-usage.pro @@ -0,0 +1,48 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% definitions of queue +empty(U-V) :- + unify_with_occurs_check(U, V). + +push(Queue, Value, NewQueue) :- + append_dl(Queue, [Value|X]-X, NewQueue). + + +pop([X|V]-U, X, V-U) :- + \+empty([X|V]-U). + + + +append_dl(X-Y, Y-Z, X-Z). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% use of queue +queue :- + % create an empty queue + empty(Q), + format('Create queue ~w~n~n', [Q]), + + % add numbers 1 and 2 + write('Add numbers 1 and 2 : '), + push(Q, 1, Q1), + push(Q1, 2, Q2), + + % display queue + format('~w~n~n', [Q2]), + + % pop element + pop(Q2, V, Q3), + + % display results + format('Pop : Value ~w Queue : ~w~n~n', [V, Q3]), + + % test the queue + write('Test of the queue : '), + ( empty(Q3) -> writeln('Queue empy'); writeln('Queue not empty')), nl, + + % pop the elements + write('Pop the queue : '), + pop(Q3, V1, Q4), + format('Value ~w Queue : ~w~n~n', [V1, Q4]), + + write('Pop the queue : '), + pop(Q4, _V, _Q5). diff --git a/Task/Queue-Usage/PureBasic/queue-usage.purebasic b/Task/Queue-Usage/PureBasic/queue-usage.purebasic new file mode 100644 index 0000000000..7afba8126c --- /dev/null +++ b/Task/Queue-Usage/PureBasic/queue-usage.purebasic @@ -0,0 +1,36 @@ +NewList MyStack() + +Procedure Push(n) + Shared MyStack() + LastElement(MyStack()) + AddElement(MyStack()) + MyStack()=n +EndProcedure + +Procedure Pop() + Shared MyStack() + Protected n + If FirstElement(MyStack()) ; e.g. Stack not empty + n=MyStack() + DeleteElement(MyStack(),1) + EndIf + ProcedureReturn n +EndProcedure + +Procedure Empty() + Shared MyStack() + If ListSize(MyStack())=0 + ProcedureReturn #True + EndIf + ProcedureReturn #False +EndProcedure + +;---- Example of implementation ---- +Push(3) +Push(1) +Push(4) +Push(1) +Push(5) +While Not Empty() + Debug Pop() +Wend diff --git a/Task/Queue-Usage/Python/queue-usage.py b/Task/Queue-Usage/Python/queue-usage.py new file mode 100644 index 0000000000..ba13efcfee --- /dev/null +++ b/Task/Queue-Usage/Python/queue-usage.py @@ -0,0 +1,8 @@ +import Queue +my_queue = Queue.Queue() +my_queue.put("foo") +my_queue.put("bar") +my_queue.put("baz") +print my_queue.get() # foo +print my_queue.get() # bar +print my_queue.get() # baz diff --git a/Task/Queue-Usage/REBOL/queue-usage.rebol b/Task/Queue-Usage/REBOL/queue-usage.rebol new file mode 100644 index 0000000000..5f1bb7393c --- /dev/null +++ b/Task/Queue-Usage/REBOL/queue-usage.rebol @@ -0,0 +1,15 @@ +; Create and populate a FIFO: + +q: make fifo [] +q/push 'a +q/push 2 +q/push USD$12.34 ; Did I mention that REBOL has 'money!' datatype? +q/push [Athos Porthos Aramis] ; List elements pushed on one by one. +q/push [[Huey Dewey Lewey]] ; This list is preserved as a list. + +; Dump it out, with narrative: + +print rejoin ["Queue is " either q/empty [""]["not "] "empty."] +while [not q/empty][print [" " q/pop]] +print rejoin ["Queue is " either q/empty [""]["not "] "empty."] +print ["Trying to pop an empty queue yields:" q/pop] diff --git a/Task/Queue-Usage/REXX/queue-usage.rexx b/Task/Queue-Usage/REXX/queue-usage.rexx new file mode 100644 index 0000000000..61b4d4602c --- /dev/null +++ b/Task/Queue-Usage/REXX/queue-usage.rexx @@ -0,0 +1,20 @@ +/*REXX program demonstrates three queue operations: push, pop, queued. */ +say '══════════════════════════════════Pushing five values to the stack.' + do j=1 for 4 /*loop to PUSH four values. */ + call push j*10 /*PUSH (aka enqueue to stack). */ + say 'pushed value:' j*10 /*echo the pushed value. */ + if j\==3 then iterate /*also, insert a "null" entry. */ + call push /*PUSH (aka enqueue to stack). */ + say 'pushed a "null" value.' /*echo what was pushed. */ + end /*j*/ +say '══════════════════════════════════Popping all values from the stack.' + do m=1 while \empty() /*EMPTY (returns TRUE if empty). */ + call pop /*POP (aka dequeue from stack).*/ + say m': popped value=' result /*echo the popped value. */ + end /*m*/ +say '══════════════════════════════════The stack is now empty.' +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────subroutines/functions/operators. */ +push: queue arg(1); return /*REXX QUEUE is FIFO. */ +pop: procedure; pull x; return x /*REXX PULL removes a stack item*/ +empty: return queued()==0 /*returns the status of the stack*/ diff --git a/Task/Queue-Usage/Scala/queue-usage.scala b/Task/Queue-Usage/Scala/queue-usage.scala new file mode 100644 index 0000000000..027e718dbc --- /dev/null +++ b/Task/Queue-Usage/Scala/queue-usage.scala @@ -0,0 +1,11 @@ +val q=scala.collection.mutable.Queue[Int]() +println("isEmpty = " + q.isEmpty) +try{q dequeue} catch{case _:java.util.NoSuchElementException => println("dequeue(empty) failed.")} +q enqueue 1 +q enqueue 2 +q enqueue 3 +println("queue = " + q) +println("front = " + q.front) +println("dequeue = " + q.dequeue) +println("dequeue = " + q.dequeue) +println("isEmpty = " + q.isEmpty) diff --git a/Task/Queue-Usage/Standard-ML/queue-usage-1.ml b/Task/Queue-Usage/Standard-ML/queue-usage-1.ml new file mode 100644 index 0000000000..2ba3b7c19a --- /dev/null +++ b/Task/Queue-Usage/Standard-ML/queue-usage-1.ml @@ -0,0 +1,48 @@ +- open Fifo; +opening Fifo + datatype 'a fifo = ... + exception Dequeue + val empty : 'a fifo + val isEmpty : 'a fifo -> bool + val enqueue : 'a fifo * 'a -> 'a fifo + val dequeue : 'a fifo -> 'a fifo * 'a + val next : 'a fifo -> ('a * 'a fifo) option + val delete : 'a fifo * ('a -> bool) -> 'a fifo + val head : 'a fifo -> 'a + val peek : 'a fifo -> 'a option + val length : 'a fifo -> int + val contents : 'a fifo -> 'a list + val app : ('a -> unit) -> 'a fifo -> unit + val map : ('a -> 'b) -> 'a fifo -> 'b fifo + val foldl : ('a * 'b -> 'b) -> 'b -> 'a fifo -> 'b + val foldr : ('a * 'b -> 'b) -> 'b -> 'a fifo -> 'b +- val q = empty; +val q = Q {front=[],rear=[]} : 'a fifo +- isEmpty q; +val it = true : bool +- val q' = enqueue (q, 1); +val q' = Q {front=[],rear=[1]} : int fifo +- isEmpty q'; +val it = false : bool +- val q'' = List.foldl (fn (x, q) => enqueue (q, x)) q' [2, 3, 4]; +val q'' = Q {front=[],rear=[4,3,2,1]} : int fifo +- peek q''; +val it = SOME 1 : int option +- length q''; +val it = 4 : int +- contents q''; +val it = [1,2,3,4] : int list +- val (q''', v) = dequeue q''; +val q''' = Q {front=[2,3,4],rear=[]} : int fifo +val v = 1 : int +- val (q'''', v') = dequeue q'''; +val q'''' = Q {front=[3,4],rear=[]} : int fifo +val v' = 2 : int +- val (q''''', v'') = dequeue q''''; +val q''''' = Q {front=[4],rear=[]} : int fifo +val v'' = 3 : int +- val (q'''''', v''') = dequeue q'''''; +val q'''''' = Q {front=[],rear=[]} : int fifo +val v''' = 4 : int +- isEmpty q''''''; +val it = true : bool diff --git a/Task/Queue-Usage/Standard-ML/queue-usage-2.ml b/Task/Queue-Usage/Standard-ML/queue-usage-2.ml new file mode 100644 index 0000000000..b6e52a3585 --- /dev/null +++ b/Task/Queue-Usage/Standard-ML/queue-usage-2.ml @@ -0,0 +1,55 @@ +- open Queue; +opening Queue + type 'a queue + exception Dequeue + val mkQueue : unit -> 'a queue + val clear : 'a queue -> unit + val isEmpty : 'a queue -> bool + val enqueue : 'a queue * 'a -> unit + val dequeue : 'a queue -> 'a + val next : 'a queue -> 'a option + val delete : 'a queue * ('a -> bool) -> unit + val head : 'a queue -> 'a + val peek : 'a queue -> 'a option + val length : 'a queue -> int + val contents : 'a queue -> 'a list + val app : ('a -> unit) -> 'a queue -> unit + val map : ('a -> 'b) -> 'a queue -> 'b queue + val foldl : ('a * 'b -> 'b) -> 'b -> 'a queue -> 'b + val foldr : ('a * 'b -> 'b) -> 'b -> 'a queue -> 'b +- val q : int queue = mkQueue (); +val q = - : int queue +- isEmpty q; +val it = true : bool +- enqueue (q, 1); +val it = () : unit +- isEmpty q; +val it = false : bool +- enqueue (q, 2); +val it = () : unit +- enqueue (q, 3); +val it = () : unit +- peek q; +val it = SOME 1 : int option +- length q; +val it = 3 : int +- contents q; +val it = [1,2,3] : int list +- dequeue q; +val it = 1 : int +- dequeue q; +val it = 2 : int +- peek q; +val it = SOME 3 : int option +- length q; +val it = 1 : int +- enqueue (q, 4); +val it = () : unit +- dequeue q; +val it = 3 : int +- peek q; +val it = SOME 4 : int option +- dequeue q; +val it = 4 : int +- isEmpty q; +val it = true : bool diff --git a/Task/Queue-Usage/Tcl/queue-usage.tcl b/Task/Queue-Usage/Tcl/queue-usage.tcl new file mode 100644 index 0000000000..a27f47b17a --- /dev/null +++ b/Task/Queue-Usage/Tcl/queue-usage.tcl @@ -0,0 +1,8 @@ +set Q [list] +empty Q ;# ==> 1 (true) +push Q foo +empty Q ;# ==> 0 (false) +push Q bar +peek Q ;# ==> foo +pop Q ;# ==> foo +peek Q ;# ==> bar diff --git a/Task/Queue-Usage/XPL0/queue-usage.xpl0 b/Task/Queue-Usage/XPL0/queue-usage.xpl0 new file mode 100644 index 0000000000..71c01453ed --- /dev/null +++ b/Task/Queue-Usage/XPL0/queue-usage.xpl0 @@ -0,0 +1,48 @@ +include c:\cxpl\codes; +def Size=8; +int Fifo(Size); +int In, Out; \fill and empty indexes into Fifo + +proc Push(A); \Add integer A to queue +int A; \(overflow not detected) +[Fifo(In):= A; +In:= In+1; +if In >= Size then In:= 0; +]; + +func Pop; \Return first integer in queue +int A; +[if Out=In then \if popping empty queue + [Text(0, "Error"); exit 1]; \ then exit program with error code 1 +A:= Fifo(Out); +Out:= Out+1; +if Out >= Size then Out:= 0; +return A; +]; + +func Empty; \Return 'true' if queue is empty +return In = Out; + +[In:= 0; Out:= 0; +Push(0); +Text(0, if Empty then "true" else "false"); CrLf(0); +IntOut(0, Pop); CrLf(0); +Push(1); +Push(2); +Push(3); +IntOut(0, Pop); CrLf(0); +IntOut(0, Pop); CrLf(0); +IntOut(0, Pop); CrLf(0); +Text(0, if Empty then "true" else "false"); CrLf(0); + +\A 256-byte queue is built in as device 8: +OpenI(8); OpenO(8); +ChOut(8, ^0); \push +ChOut(0, ChIn(8)); CrLf(0); \pop +ChOut(8, ^1); \push +ChOut(8, ^2); \push +ChOut(8, ^3); \push +ChOut(0, ChIn(8)); CrLf(0); \pop +ChOut(0, ChIn(8)); CrLf(0); \pop +ChOut(0, ChIn(8)); CrLf(0); \pop +] diff --git a/Task/RCRPG/0DESCRIPTION b/Task/RCRPG/0DESCRIPTION new file mode 100644 index 0000000000..55779e0380 --- /dev/null +++ b/Task/RCRPG/0DESCRIPTION @@ -0,0 +1,10 @@ +Create a simple interactive game which incorporates the following features: + +* room-based navigation in three integer dimensions (x,y,z) +* player inventory +* three types of item: sledge, gold and ladder +* a goal coordinate + +Use of the sledge should be required to create a passage between rooms. The ladder should be present in a room (but not held by the player), in order for the player to access the room above him. The gold need not have a function. + +This project is based on [http://web.archive.org/web/20080212201605/http://shortcircuit.us/muddy-kinda-like-a-mud-but-single-player/ this blog post] by [[User:Short Circuit|Michael Mol]], and the Perl version comes from there. diff --git a/Task/RCRPG/1META.yaml b/Task/RCRPG/1META.yaml new file mode 100644 index 0000000000..a2413d963b --- /dev/null +++ b/Task/RCRPG/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Games diff --git a/Task/RIPEMD-160/0DESCRIPTION b/Task/RIPEMD-160/0DESCRIPTION new file mode 100644 index 0000000000..e638dc7c02 --- /dev/null +++ b/Task/RIPEMD-160/0DESCRIPTION @@ -0,0 +1,5 @@ +'''RIPEMD-160''' is another hash function; it computes a 160-bit message digest. + +There is a [http://homes.esat.kuleuven.be/~bosselae/ripemd160.html RIPEMD-160 home page], with test vectors and [http://www.esat.kuleuven.be/~bosselae/ripemd/rmd160.txt pseudocode for RIPEMD-160]. For padding the message, RIPEMD-160 acts like [[MD4]] (RFC 1320). + +Find the RIPEMD-160 message digest of a string of [[octet]]s. Use the ASCII encoded string “Rosetta Code”. You may either call an RIPEMD-160 library, or implement RIPEMD-160 in your language. diff --git a/Task/RIPEMD-160/1META.yaml b/Task/RIPEMD-160/1META.yaml new file mode 100644 index 0000000000..397ec18e01 --- /dev/null +++ b/Task/RIPEMD-160/1META.yaml @@ -0,0 +1,3 @@ +--- +category: +- Checksums diff --git a/Task/RIPEMD-160/D/ripemd-160.d b/Task/RIPEMD-160/D/ripemd-160.d new file mode 100644 index 0000000000..80105c3de5 --- /dev/null +++ b/Task/RIPEMD-160/D/ripemd-160.d @@ -0,0 +1,6 @@ +import std.stdio, std.digest.ripemd; + +void main() { + auto txt = "Rosetta Code"; + writeln("%-(%02x%)", txt.ripemd160Of()); +} diff --git a/Task/RIPEMD-160/Go/ripemd-160.go b/Task/RIPEMD-160/Go/ripemd-160.go new file mode 100644 index 0000000000..1b76aa5f3c --- /dev/null +++ b/Task/RIPEMD-160/Go/ripemd-160.go @@ -0,0 +1,12 @@ +package main + +import ( + "code.google.com/p/go.crypto/ripemd160" + "fmt" +) + +func main() { + h := ripemd160.New() + h.Write([]byte("Rosetta Code")) + fmt.Printf("%x\n", h.Sum(nil)) +} diff --git a/Task/RIPEMD-160/Java/ripemd-160.java b/Task/RIPEMD-160/Java/ripemd-160.java new file mode 100644 index 0000000000..7d0434ca22 --- /dev/null +++ b/Task/RIPEMD-160/Java/ripemd-160.java @@ -0,0 +1,16 @@ +import org.bouncycastle.crypto.digests.RIPEMD160Digest; +import org.bouncycastle.util.encoders.Hex; + +public class RosettaRIPEMD160 +{ + public static void main (String[] argv) throws Exception + { + byte[] r = "Rosetta Code".getBytes("US-ASCII"); + RIPEMD160Digest d = new RIPEMD160Digest(); + d.update (r, 0, r.length); + byte[] o = new byte[d.getDigestSize()]; + d.doFinal (o, 0); + Hex.encode (o, System.out); + System.out.println(); + } +} diff --git a/Task/RIPEMD-160/Objeck/ripemd-160.objeck b/Task/RIPEMD-160/Objeck/ripemd-160.objeck new file mode 100644 index 0000000000..56b7f0dbca --- /dev/null +++ b/Task/RIPEMD-160/Objeck/ripemd-160.objeck @@ -0,0 +1,7 @@ +class Hash { + function : Main(args : String[]) ~ Nil { + in := "Rosetta Code"->ToByteArray(); + hash := Encryption.Hash->RIPEMD160(in); + hash->ToHexString()->PrintLine(); + } +} diff --git a/Task/RIPEMD-160/Perl-6/ripemd-160.pl6 b/Task/RIPEMD-160/Perl-6/ripemd-160.pl6 new file mode 100644 index 0000000000..a58c0cb26e --- /dev/null +++ b/Task/RIPEMD-160/Perl-6/ripemd-160.pl6 @@ -0,0 +1,83 @@ +=begin CREDITS +Crypto-JS v2.0.0 +http:#code.google.com/p/crypto-js/ +Copyright (c) 2009, Jeff Mott. All rights reserved. +=end CREDITS + +sub rotl($n, $b) { $n +< $b +| $n +> (32 - $b) } +sub prefix: { +^$^x % 2**32 } +sub infix: { ($^x + $^y) % 2**32 } + +constant r1 = < + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + 7 4 13 1 10 6 15 3 12 0 9 5 2 14 11 8 + 3 10 14 4 9 15 8 1 2 7 0 6 13 11 5 12 + 1 9 11 10 0 8 12 4 13 3 7 15 14 5 6 2 + 4 0 5 9 7 12 2 10 14 1 3 8 11 6 15 13 +>; +constant r2 = < + 5 14 7 0 9 2 11 4 13 6 15 8 1 10 3 12 + 6 11 3 7 0 13 5 10 14 15 8 12 4 9 1 2 + 15 5 1 3 7 14 6 9 11 8 12 2 10 0 4 13 + 8 6 4 1 3 11 15 0 5 12 2 13 9 7 10 14 + 12 15 10 4 1 5 8 7 6 2 13 14 0 3 9 11 +>; +constant s1 = < + 11 14 15 12 5 8 7 9 11 13 14 15 6 7 9 8 + 7 6 8 13 11 9 7 15 7 12 15 9 11 7 13 12 + 11 13 6 7 14 9 13 15 14 8 13 6 5 12 7 5 + 11 12 14 15 14 15 9 8 9 14 5 6 8 6 5 12 + 9 15 5 11 6 8 13 12 5 12 13 14 11 8 5 6 +>; +constant s2 = < + 8 9 9 11 13 15 15 5 7 7 8 11 14 14 12 6 + 9 13 15 7 12 8 9 11 7 7 12 7 6 15 13 11 + 9 7 15 11 8 6 6 14 12 13 5 14 13 13 7 5 + 15 5 8 11 14 14 6 14 6 9 12 9 12 5 15 8 + 8 5 12 9 12 5 14 6 8 13 6 5 15 13 11 11 +>; +constant F = + * +^ * +^ *, + { ($^x +& $^y) +| (m^$^x +& $^z) }, + (* +| m^*) +^ *, + { ($^x +& $^z) +| ($^y +& m^$^z) }, + * +^ (* +| m^*), +; +constant K1 = <0x00000000 0x5a827999 0x6ed9eba1 0x8f1bbcdc 0xa953fd4e> »xx» 16; +constant K2 = <0x50a28be6 0x5c4dd124 0x6d703ef3 0x7a6d76e9 0x00000000> »xx» 16; + +our proto rmd160($) returns Buf {*} +multi rmd160(Str $s) { rmd160 $s.encode: 'ascii' } +multi rmd160(Buf $data) { + my @b = $data.list, 0x80; + push @b, 0 until (8*@b-448) %% 512; + my $len = 8 * $data.elems; + push @b, gather for ^8 { take $len % 256; $len div= 256 } + + my @word = gather for @b -> $a, $b, $c, $d { + take reduce * *256 + *, $d, $c, $b, $a; + } + + my @h = 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0; + loop (my $i = 0; $i < @word; $i += 16) { + my @X = my @Y = @h; + for ^80 -> $j { + my $T = rotl( + @X[0] m+ F[$j div 16](|@X[1..3]) m+ (@word[$i+r1[$j]] // 0) m+ K1[$j], + s1[$j] + ) m+ @X[4]; + @X = @X[4], $T, @X[1], rotl(@X[2], 10) % 2**32, @X[3]; + $T = rotl( + @Y[0] m+ F[(79-$j) div 16](|@Y[1..3]) m+ (@word[$i+r2[$j]] // 0) m+ K2[$j], + s2[$j] + ) m+ @Y[4]; + @Y = @Y[4], $T, @Y[1], rotl(@Y[2], 10) % 2**32, @Y[3]; + } + @h = @h[1..4,^1] Z[m+] @X[2..4,^2] Z[m+] @Y[3..4,^3]; + } + return Buf.new: gather for @h -> $word is rw { + for ^4 { take $word % 256; $word div= 256 } + } +} + +say rmd160 "Rosetta Code"; diff --git a/Task/RIPEMD-160/Python/ripemd-160.py b/Task/RIPEMD-160/Python/ripemd-160.py new file mode 100644 index 0000000000..8394fddffa --- /dev/null +++ b/Task/RIPEMD-160/Python/ripemd-160.py @@ -0,0 +1,8 @@ +Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:57:17) [MSC v.1600 64 bit (AMD64)] on win32 +Type "copyright", "credits" or "license()" for more information. +>>> import hashlib +>>> h = hashlib.new('ripemd160') +>>> h.update(b"Rosetta Code") +>>> h.hexdigest() +'b3be159860842cebaa7174c8fff0aa9e50a5199f' +>>> diff --git a/Task/RIPEMD-160/Ruby/ripemd-160-1.rb b/Task/RIPEMD-160/Ruby/ripemd-160-1.rb new file mode 100644 index 0000000000..667304f121 --- /dev/null +++ b/Task/RIPEMD-160/Ruby/ripemd-160-1.rb @@ -0,0 +1,2 @@ +require 'digest' +puts Digest::RMD160.hexdigest('Rosetta Code') diff --git a/Task/RIPEMD-160/Ruby/ripemd-160-2.rb b/Task/RIPEMD-160/Ruby/ripemd-160-2.rb new file mode 100644 index 0000000000..c678d6a7eb --- /dev/null +++ b/Task/RIPEMD-160/Ruby/ripemd-160-2.rb @@ -0,0 +1,2 @@ +require 'openssl' +puts OpenSSL::Digest::RIPEMD160.hexdigest('Rosetta Code') diff --git a/Task/RIPEMD-160/Ruby/ripemd-160-3.rb b/Task/RIPEMD-160/Ruby/ripemd-160-3.rb new file mode 100644 index 0000000000..9f1ebef13e --- /dev/null +++ b/Task/RIPEMD-160/Ruby/ripemd-160-3.rb @@ -0,0 +1,118 @@ +require 'stringio' + +module RMD160 + # functions and constants + MASK = (1 << 32) - 1 + F = [ + proc {|x, y, z| x ^ y ^ z}, + proc {|x, y, z| (x & y) | (x.^(MASK) & z)}, + proc {|x, y, z| (x | y.^(MASK)) ^ z}, + proc {|x, y, z| (x & z) | (y & z.^(MASK))}, + proc {|x, y, z| x ^ (y | z.^(MASK))}, + ].freeze + K = [0x00000000, 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e] + KK = [0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9, 0x00000000] + R = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, + 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, + 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, + 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13] + RR = [5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, + 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, + 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, + 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, + 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11] + S = [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, + 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, + 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, + 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, + 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6] + SS = [8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, + 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, + 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, + 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, + 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11] + + module_function + + def rol(value, shift) + (value << shift).&(MASK) | (value.&(MASK) >> (32 - shift)) + end + + # Calculates RIPEMD-160 message digest of _string_. Returns binary + # digest. For hexadecimal digest, use + # +*RMD160.rmd160(string).unpack('H*')+. + def rmd160(string) + # initial hash + h0 = 0x67452301 + h1 = 0xefcdab89 + h2 = 0x98badcfe + h3 = 0x10325476 + h4 = 0xc3d2e1f0 + + io = StringIO.new(string) + block = "" + term = false # appended "\x80" in second-last block? + last = false # last block? + until last + # Read next block of 16 words (64 bytes, 512 bits). + io.read(64, block) or ( + # Work around a bug in Rubinius 1.2.4. At eof, + # MRI and JRuby already replace block with "". + block.replace("") + ) + + # Unpack block into 32-bit words "V". + case len = block.length + when 64 + # Unpack 16 words. + x = block.unpack("V16") + when 56..63 + # Second-last block: append padding, unpack 16 words. + block.concat("\x80"); term = true + block.concat("\0" * (63 - len)) + x = block.unpack("V16") + when 0..55 + # Last block: append padding, unpack 14 words. + block.concat(term ? "\0" : "\x80") + block.concat("\0" * (55 - len)) + x = block.unpack("V14") + + # Append bit length, 2 words. + bit_len = string.length << 3 + x.push(bit_len & MASK, bit_len >> 32) + last = true + else + fail "impossible" + end + + # Process this block. + a, b, c, d, e = h0, h1, h2, h3, h4 + aa, bb, cc, dd, ee = h0, h1, h2, h3, h4 + j = 0 + 5.times {|ro| + f, ff = F[ro], F[4 - ro] + k, kk = K[ro], KK[ro] + 16.times { + a, e, d, c, b = e, d, rol(c, 10), b, + rol(a + f[b, c, d] + x[R[j]] + k, S[j]) + e + aa, ee, dd, cc, bb = ee, dd, rol(cc, 10), bb, + rol(aa + ff[bb, cc, dd] + x[RR[j]] + kk, SS[j]) + ee + j += 1 + } + } + h0, h1, h2, h3, h4 = + (h1 + c + dd) & MASK, (h2 + d + ee) & MASK, + (h3 + e + aa) & MASK, (h4 + a + bb) & MASK, + (h0 + b + cc) & MASK + end # until last + + [h0, h1, h2, h3, h4].pack("V5") + end +end + +if __FILE__ == $0 + # Print an example RIPEMD-160 digest. + str = 'Rosetta Code' + printf "%s:\n %s\n", str, *RMD160.rmd160(str).unpack('H*') +end diff --git a/Task/RIPEMD-160/Tcl/ripemd-160.tcl b/Task/RIPEMD-160/Tcl/ripemd-160.tcl new file mode 100644 index 0000000000..8ef6094c70 --- /dev/null +++ b/Task/RIPEMD-160/Tcl/ripemd-160.tcl @@ -0,0 +1,3 @@ +package require ripemd160 + +puts [ripemd::ripemd160 -hex "Rosetta Code"] diff --git a/Task/Random-number-generator--device-/0DESCRIPTION b/Task/Random-number-generator--device-/0DESCRIPTION new file mode 100644 index 0000000000..afef50913c --- /dev/null +++ b/Task/Random-number-generator--device-/0DESCRIPTION @@ -0,0 +1 @@ +If your system has a means to generate random numbers involving not only a software algorithm (like the [[wp:/dev/random|/dev/urandom]] devices in Unix), show how to obtain a random 32-bit number from that mechanism. diff --git a/Task/Random-number-generator--device-/1META.yaml b/Task/Random-number-generator--device-/1META.yaml new file mode 100644 index 0000000000..d307386e26 --- /dev/null +++ b/Task/Random-number-generator--device-/1META.yaml @@ -0,0 +1,3 @@ +--- +category: +- Input Output diff --git a/Task/Random-number-generator--device-/Ada/random-number-generator--device-.ada b/Task/Random-number-generator--device-/Ada/random-number-generator--device-.ada new file mode 100644 index 0000000000..94c5cb52de --- /dev/null +++ b/Task/Random-number-generator--device-/Ada/random-number-generator--device-.ada @@ -0,0 +1,13 @@ +with Ada.Streams.Stream_IO; +with Ada.Text_IO; +procedure Random is + Number : Integer; + Random_File : Ada.Streams.Stream_IO.File_Type; +begin + Ada.Streams.Stream_IO.Open (File => Random_File, + Mode => Ada.Streams.Stream_IO.In_File, + Name => "/dev/random"); + Integer'Read (Ada.Streams.Stream_IO.Stream (Random_File), Number); + Ada.Streams.Stream_IO.Close (Random_File); + Ada.Text_IO.Put_Line ("Number:" & Integer'Image (Number)); +end Random; diff --git a/Task/Random-number-generator--device-/BBC-BASIC/random-number-generator--device-.bbc b/Task/Random-number-generator--device-/BBC-BASIC/random-number-generator--device-.bbc new file mode 100644 index 0000000000..d66e5ce157 --- /dev/null +++ b/Task/Random-number-generator--device-/BBC-BASIC/random-number-generator--device-.bbc @@ -0,0 +1,2 @@ + SYS "SystemFunction036", ^random%, 4 + PRINT ~random% diff --git a/Task/Random-number-generator--device-/C-sharp/random-number-generator--device-.cs b/Task/Random-number-generator--device-/C-sharp/random-number-generator--device-.cs new file mode 100644 index 0000000000..10ca1495f6 --- /dev/null +++ b/Task/Random-number-generator--device-/C-sharp/random-number-generator--device-.cs @@ -0,0 +1,14 @@ +using System; +using System.Security.Cryptography; + +private static int GetRandomInt() +{ + int result = 0; + var rng = new RNGCryptoServiceProvider(); + var buffer = new byte[4]; + + rng.GetBytes(buffer); + result = BitConverter.ToInt32(buffer, 0); + + return result; +} diff --git a/Task/Random-number-generator--device-/C/random-number-generator--device--1.c b/Task/Random-number-generator--device-/C/random-number-generator--device--1.c new file mode 100644 index 0000000000..c7ee966414 --- /dev/null +++ b/Task/Random-number-generator--device-/C/random-number-generator--device--1.c @@ -0,0 +1,25 @@ +#include +#include +#include + +int main(int argc, char **argv) +{ + uint32_t v; + FILE *r = fopen("/dev/urandom", "r"); + if (r == NULL) + { + perror("/dev/urandom"); + return 1; + } + + size_t br = fread(&v, sizeof v, 1, r); + if (br < 1) + { + fputs("/dev/urandom: Not enough bytes\n", stderr); + return 1; + } + + printf("%" PRIu32 "\n", v); + fclose(r); + return 0; +} diff --git a/Task/Random-number-generator--device-/C/random-number-generator--device--2.c b/Task/Random-number-generator--device-/C/random-number-generator--device--2.c new file mode 100644 index 0000000000..e89e92b863 --- /dev/null +++ b/Task/Random-number-generator--device-/C/random-number-generator--device--2.c @@ -0,0 +1,10 @@ +#include /* PRIu32 */ +#include /* arc4random */ +#include /* printf */ + +int +main() +{ + printf("%" PRIu32 "\n", arc4random()); + return 0; +} diff --git a/Task/Random-number-generator--device-/C/random-number-generator--device--3.c b/Task/Random-number-generator--device-/C/random-number-generator--device--3.c new file mode 100644 index 0000000000..a31b0f4d4a --- /dev/null +++ b/Task/Random-number-generator--device-/C/random-number-generator--device--3.c @@ -0,0 +1,18 @@ +#include +#include + +#include +#include + +int +main() +{ + uint32_t v; + + if (RAND_bytes((unsigned char *)&v, sizeof v) == 0) { + ERR_print_errors_fp(stderr); + return 1; + } + printf("%" PRIu32 "\n", v); + return 0; +} diff --git a/Task/Random-number-generator--device-/C/random-number-generator--device--4.c b/Task/Random-number-generator--device-/C/random-number-generator--device--4.c new file mode 100644 index 0000000000..bee536d54b --- /dev/null +++ b/Task/Random-number-generator--device-/C/random-number-generator--device--4.c @@ -0,0 +1,23 @@ +#include /* printf */ +#include +#include /* CryptAcquireContext, CryptGenRandom */ + +int +main() +{ + HCRYPTPROV p; + ULONG i; + + if (CryptAcquireContext(&p, NULL, NULL, + PROV_RSA_FULL, CRYPT_VERIFYCONTEXT) == FALSE) { + fputs("CryptAcquireContext failed.\n", stderr); + return 1; + } + if (CryptGenRandom(p, sizeof i, (BYTE *)&i) == FALSE) { + fputs("CryptGenRandom failed.\n", stderr); + return 1; + } + printf("%lu\n", i); + CryptReleaseContext(p, 0); + return 0; +} diff --git a/Task/Random-number-generator--device-/Forth/random-number-generator--device-.fth b/Task/Random-number-generator--device-/Forth/random-number-generator--device-.fth new file mode 100644 index 0000000000..e02bf00419 --- /dev/null +++ b/Task/Random-number-generator--device-/Forth/random-number-generator--device-.fth @@ -0,0 +1,9 @@ +variable rnd + +: randoms ( n -- ) + s" /dev/random" r/o open-file throw + swap 0 do + dup rnd 1 cells rot read-file throw drop + rnd @ . + loop + close-file throw ; diff --git a/Task/Random-number-generator--device-/Go/random-number-generator--device-.go b/Task/Random-number-generator--device-/Go/random-number-generator--device-.go new file mode 100644 index 0000000000..8d2c16df30 --- /dev/null +++ b/Task/Random-number-generator--device-/Go/random-number-generator--device-.go @@ -0,0 +1,34 @@ +package main + +import ( + "crypto/rand" + "encoding/binary" + "fmt" + "io" + "os" +) + +func main() { + testRandom("crypto/rand", rand.Reader) + testRandom("dev/random", newDevRandom()) +} + +func newDevRandom() (f *os.File) { + var err error + if f, err = os.Open("/dev/random"); err != nil { + panic(err) + } + return +} + +func testRandom(label string, src io.Reader) { + fmt.Printf("%s:\n", label) + var r int32 + for i := 0; i < 10; i++ { + if err := binary.Read(src, binary.LittleEndian, &r); err != nil { + panic(err) + } + fmt.Print(r, " ") + } + fmt.Println() +} diff --git a/Task/Random-number-generator--device-/Groovy/random-number-generator--device--1.groovy b/Task/Random-number-generator--device-/Groovy/random-number-generator--device--1.groovy new file mode 100644 index 0000000000..ef97540ac8 --- /dev/null +++ b/Task/Random-number-generator--device-/Groovy/random-number-generator--device--1.groovy @@ -0,0 +1 @@ +def rng = new java.security.SecureRandom() diff --git a/Task/Random-number-generator--device-/Groovy/random-number-generator--device--2.groovy b/Task/Random-number-generator--device-/Groovy/random-number-generator--device--2.groovy new file mode 100644 index 0000000000..92975d791d --- /dev/null +++ b/Task/Random-number-generator--device-/Groovy/random-number-generator--device--2.groovy @@ -0,0 +1 @@ +(0..4).each { println rng.nextInt() } diff --git a/Task/Random-number-generator--device-/Haskell/random-number-generator--device-.hs b/Task/Random-number-generator--device-/Haskell/random-number-generator--device-.hs new file mode 100644 index 0000000000..c7e5078fe4 --- /dev/null +++ b/Task/Random-number-generator--device-/Haskell/random-number-generator--device-.hs @@ -0,0 +1,9 @@ +#!/usr/bin/runhaskell + +import System.Entropy +import Data.Binary.Get +import qualified Data.ByteString.Lazy as B + +main = do + bytes <- getEntropy 4 + print (runGet getWord32be $ B.fromChunks [bytes]) diff --git a/Task/Random-number-generator--device-/J/random-number-generator--device--1.j b/Task/Random-number-generator--device-/J/random-number-generator--device--1.j new file mode 100644 index 0000000000..2e69a77950 --- /dev/null +++ b/Task/Random-number-generator--device-/J/random-number-generator--device--1.j @@ -0,0 +1 @@ +256#.a.i.1!:11'/dev/urandom';0 4 diff --git a/Task/Random-number-generator--device-/J/random-number-generator--device--2.j b/Task/Random-number-generator--device-/J/random-number-generator--device--2.j new file mode 100644 index 0000000000..3c97869344 --- /dev/null +++ b/Task/Random-number-generator--device-/J/random-number-generator--device--2.j @@ -0,0 +1 @@ +256#.a.i.4{.host'dd if=/dev/urandom bs=4 count=1' diff --git a/Task/Random-number-generator--device-/Java/random-number-generator--device-.java b/Task/Random-number-generator--device-/Java/random-number-generator--device-.java new file mode 100644 index 0000000000..4488ccc251 --- /dev/null +++ b/Task/Random-number-generator--device-/Java/random-number-generator--device-.java @@ -0,0 +1,10 @@ +import java.security.SecureRandom; + +public class RandomExample { + public static void main(String[] args) { + SecureRandom rng = new SecureRandom(); + + /* Prints a random signed 32-bit integer. */ + System.out.println(rng.nextInt()); + } +} diff --git a/Task/Random-number-generator--device-/NetRexx/random-number-generator--device-.netrexx b/Task/Random-number-generator--device-/NetRexx/random-number-generator--device-.netrexx new file mode 100644 index 0000000000..e8b57ddf8d --- /dev/null +++ b/Task/Random-number-generator--device-/NetRexx/random-number-generator--device-.netrexx @@ -0,0 +1,32 @@ +/* NetRexx */ +options replace format comments java crossref savelog symbols binary + +import java.math.BigInteger + +randomDevNameFile = File +randomDevNameList = ['/dev/random', '/dev/urandom'] -- list of random data source devices +randomDevIStream = InputStream +do + loop dn = 0 to randomDevNameList.length - 1 + randomDevNameFile = File(randomDevNameList[dn]) + if randomDevNameFile.exists() then leave dn -- We're done! Use this device + randomDevNameFile = null -- ensure we don't use a non-existant device + end dn + if randomDevNameFile == null then signal FileNotFoundException('Cannot locate a random data source device on this system') + + -- read 8 bytes from the random data source device, convert it into a BigInteger then display the result + randomBytes = byte[8] + randomDevIStream = BufferedInputStream(FileInputStream(randomDevNameFile)) + randomDevIStream.read(randomBytes, 0, randomBytes.length) + randomDevIStream.close() + randomNum = BigInteger(randomBytes) + say Rexx(randomNum.longValue()).right(24) '0x'Rexx(Long.toHexString(randomNum.longValue())).right(16, 0) +catch ex = IOException + ex.printStackTrace() +end +return + +/* +To run the program in a loop 10 times from a bash shell prompt use: +for ((i=0; i<10; ++i)); do java ; done # Shell loop to run the command 10 times +*/ diff --git a/Task/Random-number-generator--device-/OCaml/random-number-generator--device--1.ocaml b/Task/Random-number-generator--device-/OCaml/random-number-generator--device--1.ocaml new file mode 100644 index 0000000000..ddd4f5c5f6 --- /dev/null +++ b/Task/Random-number-generator--device-/OCaml/random-number-generator--device--1.ocaml @@ -0,0 +1,13 @@ +let input_rand_int ic = + let i1 = int_of_char (input_char ic) + and i2 = int_of_char (input_char ic) + and i3 = int_of_char (input_char ic) + and i4 = int_of_char (input_char ic) in + i1 lor (i2 lsl 8) lor (i3 lsl 16) lor (i4 lsl 24) + +let () = + let ic = open_in "/dev/urandom" in + let ri31 = input_rand_int ic in + close_in ic; + Printf.printf "%d\n" ri31; +;; diff --git a/Task/Random-number-generator--device-/OCaml/random-number-generator--device--2.ocaml b/Task/Random-number-generator--device-/OCaml/random-number-generator--device--2.ocaml new file mode 100644 index 0000000000..7547fb377d --- /dev/null +++ b/Task/Random-number-generator--device-/OCaml/random-number-generator--device--2.ocaml @@ -0,0 +1,16 @@ +let input_rand_int32 ic = + let i1 = Int32.of_int (int_of_char (input_char ic)) + and i2 = Int32.of_int (int_of_char (input_char ic)) + and i3 = Int32.of_int (int_of_char (input_char ic)) + and i4 = Int32.of_int (int_of_char (input_char ic)) in + let i2 = Int32.shift_left i2 8 + and i3 = Int32.shift_left i3 16 + and i4 = Int32.shift_left i4 24 in + Int32.logor i1 (Int32.logor i2 (Int32.logor i3 i4)) + +let () = + let ic = open_in "/dev/urandom" in + let ri32 = input_rand_int32 ic in + close_in ic; + Printf.printf "%ld\n" ri32; +;; diff --git a/Task/Random-number-generator--device-/Pascal/random-number-generator--device-.pascal b/Task/Random-number-generator--device-/Pascal/random-number-generator--device-.pascal new file mode 100644 index 0000000000..28663ef092 --- /dev/null +++ b/Task/Random-number-generator--device-/Pascal/random-number-generator--device-.pascal @@ -0,0 +1,11 @@ +program RandomNumberDevice; +var + byteFile: file of byte; + randomByte: byte; +begin + assign(byteFile, '/dev/urandom'); + reset (byteFile); + read (byteFile, randomByte); + close (byteFile); + writeln('The random byte is: ', randomByte); +end. diff --git a/Task/Random-number-generator--device-/Perl-6/random-number-generator--device-.pl6 b/Task/Random-number-generator--device-/Perl-6/random-number-generator--device-.pl6 new file mode 100644 index 0000000000..5c7e0cb46c --- /dev/null +++ b/Task/Random-number-generator--device-/Perl-6/random-number-generator--device-.pl6 @@ -0,0 +1,4 @@ +my $UR = open("/dev/urandom", :bin) or die "Can't open /dev/urandom: $!"; +my @random-spigot := gather loop { take $UR.read(1024).unpack("L*") } + +.say for @random-spigot[^10]; diff --git a/Task/Random-number-generator--device-/Perl/random-number-generator--device-.pl b/Task/Random-number-generator--device-/Perl/random-number-generator--device-.pl new file mode 100644 index 0000000000..e1d9de8097 --- /dev/null +++ b/Task/Random-number-generator--device-/Perl/random-number-generator--device-.pl @@ -0,0 +1,10 @@ +sub read_random { + my $device = '/dev/urandom'; + open my $in, "<:raw", $device # :raw because it's not unicode string + or die "Can't open $device: $!"; + + sysread $in, my $rand, 4 * shift; + unpack('L*', $rand); +} + +print "$_\n" for read_random(10); diff --git a/Task/Random-number-generator--device-/PicoLisp/random-number-generator--device-.l b/Task/Random-number-generator--device-/PicoLisp/random-number-generator--device-.l new file mode 100644 index 0000000000..3a97ded807 --- /dev/null +++ b/Task/Random-number-generator--device-/PicoLisp/random-number-generator--device-.l @@ -0,0 +1,2 @@ +: (in "/dev/urandom" (rd 4)) +-> 2917110327 diff --git a/Task/Random-number-generator--device-/ProDOS/random-number-generator--device-.dos b/Task/Random-number-generator--device-/ProDOS/random-number-generator--device-.dos new file mode 100644 index 0000000000..18861b913b --- /dev/null +++ b/Task/Random-number-generator--device-/ProDOS/random-number-generator--device-.dos @@ -0,0 +1 @@ +printline -random- diff --git a/Task/Random-number-generator--device-/PureBasic/random-number-generator--device-.purebasic b/Task/Random-number-generator--device-/PureBasic/random-number-generator--device-.purebasic new file mode 100644 index 0000000000..05b5166b88 --- /dev/null +++ b/Task/Random-number-generator--device-/PureBasic/random-number-generator--device-.purebasic @@ -0,0 +1,4 @@ +If OpenCryptRandom() + MyRandom = CryptRandom(#MAXLONG) + CloseCryptRandom() +EndIf diff --git a/Task/Random-number-generator--device-/Python/random-number-generator--device-.py b/Task/Random-number-generator--device-/Python/random-number-generator--device-.py new file mode 100644 index 0000000000..bed67c279b --- /dev/null +++ b/Task/Random-number-generator--device-/Python/random-number-generator--device-.py @@ -0,0 +1,3 @@ +import random +rand = random.SystemRandom() +rand.randint(1,10) diff --git a/Task/Random-number-generator--device-/REXX/random-number-generator--device-.rexx b/Task/Random-number-generator--device-/REXX/random-number-generator--device-.rexx new file mode 100644 index 0000000000..78a1f6cf90 --- /dev/null +++ b/Task/Random-number-generator--device-/REXX/random-number-generator--device-.rexx @@ -0,0 +1,9 @@ +/*REXX program generates a random 32-bit number using the RANDOM bif.*/ +/*───────── The 32-bit random number is unsigned and constructed from */ +/*───────── two smaller 16-bit numbers, and it's expressed in decimal.*/ +/*───────── Note: the REXX random bif has a maximum range of 100,000.*/ + +numeric digits 10 /*ensure REXX has enough room. */ +_=2**16 /*a handy-dandy constant to have.*/ + +say random(0,_-1)*_+random(0,_-1) /*gen an unsigned 32-bit random #*/ diff --git a/Task/Random-number-generator--device-/Ruby/random-number-generator--device-.rb b/Task/Random-number-generator--device-/Ruby/random-number-generator--device-.rb new file mode 100644 index 0000000000..7e30d204e8 --- /dev/null +++ b/Task/Random-number-generator--device-/Ruby/random-number-generator--device-.rb @@ -0,0 +1,2 @@ +require 'securerandom' +SecureRandom.random_number(1 << 32) diff --git a/Task/Random-number-generator--device-/Tcl/random-number-generator--device--1.tcl b/Task/Random-number-generator--device-/Tcl/random-number-generator--device--1.tcl new file mode 100644 index 0000000000..0fb300b653 --- /dev/null +++ b/Task/Random-number-generator--device-/Tcl/random-number-generator--device--1.tcl @@ -0,0 +1,9 @@ +package require Tcl 8.5 + +# Allow override of device name +proc systemRandomInteger {{device "/dev/random"}} { + set f [open $device "rb"] + binary scan [read $f 4] "I" x + close $f + return $x +} diff --git a/Task/Random-number-generator--device-/Tcl/random-number-generator--device--2.tcl b/Task/Random-number-generator--device-/Tcl/random-number-generator--device--2.tcl new file mode 100644 index 0000000000..45e3d92aae --- /dev/null +++ b/Task/Random-number-generator--device-/Tcl/random-number-generator--device--2.tcl @@ -0,0 +1,2 @@ +% puts [systemRandomInteger] +636131349 diff --git a/Task/Random-number-generator--device-/XPL0/random-number-generator--device-.xpl0 b/Task/Random-number-generator--device-/XPL0/random-number-generator--device-.xpl0 new file mode 100644 index 0000000000..e735ae6926 --- /dev/null +++ b/Task/Random-number-generator--device-/XPL0/random-number-generator--device-.xpl0 @@ -0,0 +1,3 @@ +code Ran=1; +int R; +R:= Ran($7FFF_FFFF) diff --git a/Task/Random-number-generator--included-/0DESCRIPTION b/Task/Random-number-generator--included-/0DESCRIPTION new file mode 100644 index 0000000000..ac5f03ed61 --- /dev/null +++ b/Task/Random-number-generator--included-/0DESCRIPTION @@ -0,0 +1,9 @@ +The task is to: +: State the type of random number generator algorithm used in a languages built-in random number generator, or omit the language if no random number generator is given as part of the language or its immediate libraries.
    +: If possible, a link to a wider [[wp:List of random number generators|explanation]] of the algorithm used should be given. + +Note: the task is ''not'' to create an RNG, but to report on the languages in-built RNG that would be the most likely RNG used. + +The main types of pseudo-random number generator, ([[wp:PRNG|PRNG]]), that are in use are the [[linear congruential generator|Linear Congruential Generator]], ([[wp:Linear congruential generator|LCG]]), and the Generalized Feedback Shift Register, ([[wp:Generalised_feedback_shift_register#Non-binary_Galois_LFSR|GFSR]]), (of which the [[wp:Mersenne twister|Mersenne twister]] generator is a subclass). The last main type is where the output of one of the previous ones (typically a Mersenne twister) is fed through a [[cryptographic hash function]] to maximize unpredictability of individual bits. + +Note that LCGs nor GFSRs should be used for the most demanding applications (cryptography) without additional steps. diff --git a/Task/Random-number-generator--included-/ALGOL-68/random-number-generator--included--1.alg b/Task/Random-number-generator--included-/ALGOL-68/random-number-generator--included--1.alg new file mode 100644 index 0000000000..1f84f1b600 --- /dev/null +++ b/Task/Random-number-generator--included-/ALGOL-68/random-number-generator--included--1.alg @@ -0,0 +1,12 @@ +PROC ℒ next random = (REF ℒ INT a)ℒ REAL: ( a := +¢ the next pseudo-random ℒ integral value after 'a' from a +uniformly distributed sequence on the interval [ℒ 0,ℒ maxint] ¢; + +¢ the real value corresponding to 'a' according to some mapping of +integral values [ℒ 0, ℒ max int] into real values [ℒ 0, ℒ 1) +i.e. such that -0 <= x < 1 such that the sequence of real +values so produced preserves the properties of pseudo-randomness +and uniform distribution of the sequence of integral values ¢); + +INT ℒ last random := # some initial random number #; +PROC ℒ random = ℒ REAL: ℒ next random(ℒ last random); diff --git a/Task/Random-number-generator--included-/ALGOL-68/random-number-generator--included--2.alg b/Task/Random-number-generator--included-/ALGOL-68/random-number-generator--included--2.alg new file mode 100644 index 0000000000..ada0a9a75d --- /dev/null +++ b/Task/Random-number-generator--included-/ALGOL-68/random-number-generator--included--2.alg @@ -0,0 +1,3 @@ +PROC long next random = (REF LONG INT a)LONG REAL: # some suitable next random number #; +INT long last random := # some initial random number #; +PROC long random = LONG REAL: long next random(long last random); diff --git a/Task/Random-number-generator--included-/C/random-number-generator--included-.c b/Task/Random-number-generator--included-/C/random-number-generator--included-.c new file mode 100644 index 0000000000..0ab2a8184f --- /dev/null +++ b/Task/Random-number-generator--included-/C/random-number-generator--included-.c @@ -0,0 +1,13 @@ +#include +#include + +/* Flip a coin, 10 times. */ +int +main() +{ + int i; + srand(time(NULL)); + for (i = 0; i < 10; i++) + puts((rand() % 2) ? "heads" : "tails"); + return 0; +} diff --git a/Task/Random-number-generator--included-/CMake/random-number-generator--included-.cmake b/Task/Random-number-generator--included-/CMake/random-number-generator--included-.cmake new file mode 100644 index 0000000000..3f8a0db94c --- /dev/null +++ b/Task/Random-number-generator--included-/CMake/random-number-generator--included-.cmake @@ -0,0 +1,4 @@ +# Show random integer from 0 to 9999. +string(RANDOM LENGTH 4 ALPHABET 0123456789 number) +math(EXPR number "${number} + 0") # Remove extra leading 0s. +message(STATUS ${number}) diff --git a/Task/Random-number-generator--included-/Deja-Vu/random-number-generator--included-.djv b/Task/Random-number-generator--included-/Deja-Vu/random-number-generator--included-.djv new file mode 100644 index 0000000000..5e9a8005a9 --- /dev/null +++ b/Task/Random-number-generator--included-/Deja-Vu/random-number-generator--included-.djv @@ -0,0 +1 @@ +print rand 0 1 # prints a pseudo-random floating-point number between 0 and 1 diff --git a/Task/Random-number-generator--included-/Erlang/random-number-generator--included--1.erl b/Task/Random-number-generator--included-/Erlang/random-number-generator--included--1.erl new file mode 100644 index 0000000000..e82d7742a8 --- /dev/null +++ b/Task/Random-number-generator--included-/Erlang/random-number-generator--included--1.erl @@ -0,0 +1 @@ +random:seed(A1, A2, A3) diff --git a/Task/Random-number-generator--included-/Erlang/random-number-generator--included--2.erl b/Task/Random-number-generator--included-/Erlang/random-number-generator--included--2.erl new file mode 100644 index 0000000000..c2807a6746 --- /dev/null +++ b/Task/Random-number-generator--included-/Erlang/random-number-generator--included--2.erl @@ -0,0 +1,6 @@ +... +{A1,A2,A3} = now(), +random:seed(A1, A2, A3), +...sequence of randoms used +random:seed(A1, A2, A3), +...same sequence of randoms used diff --git a/Task/Random-number-generator--included-/Erlang/random-number-generator--included--3.erl b/Task/Random-number-generator--included-/Erlang/random-number-generator--included--3.erl new file mode 100644 index 0000000000..08309f5409 --- /dev/null +++ b/Task/Random-number-generator--included-/Erlang/random-number-generator--included--3.erl @@ -0,0 +1 @@ +Rfloat = uniform(), diff --git a/Task/Random-number-generator--included-/Erlang/random-number-generator--included--4.erl b/Task/Random-number-generator--included-/Erlang/random-number-generator--included--4.erl new file mode 100644 index 0000000000..aaeb681a9b --- /dev/null +++ b/Task/Random-number-generator--included-/Erlang/random-number-generator--included--4.erl @@ -0,0 +1 @@ +Rint = uniform(N), diff --git a/Task/Random-number-generator--included-/GAP/random-number-generator--included--1.gap b/Task/Random-number-generator--included-/GAP/random-number-generator--included--1.gap new file mode 100644 index 0000000000..c5ad823c64 --- /dev/null +++ b/Task/Random-number-generator--included-/GAP/random-number-generator--included--1.gap @@ -0,0 +1,8 @@ +# Creating a random source +rs := RandomSource(IsMersenneTwister); + +# Generate a random number between 1 and 10 +Random(rs, 1, 10); + +# Same with default random source +Random(1, 10); diff --git a/Task/Random-number-generator--included-/GAP/random-number-generator--included--2.gap b/Task/Random-number-generator--included-/GAP/random-number-generator--included--2.gap new file mode 100644 index 0000000000..90591621a7 --- /dev/null +++ b/Task/Random-number-generator--included-/GAP/random-number-generator--included--2.gap @@ -0,0 +1,7 @@ +Random([1, 10, 100]); + +# Random permutation of 1..200 +Random(SymmetricGroup(200)); + +# Random element of Z/23Z : +Random(Integers mod 23); diff --git a/Task/Random-number-generator--included-/PARI-GP/random-number-generator--included-.pari b/Task/Random-number-generator--included-/PARI-GP/random-number-generator--included-.pari new file mode 100644 index 0000000000..821758a711 --- /dev/null +++ b/Task/Random-number-generator--included-/PARI-GP/random-number-generator--included-.pari @@ -0,0 +1,4 @@ +setrand(3) +random(6)+1 +\\ chosen by fair dice roll. +\\ guaranteed to the random. diff --git a/Task/Random-number-generator--included-/PL-I/random-number-generator--included-.pli b/Task/Random-number-generator--included-/PL-I/random-number-generator--included-.pli new file mode 100644 index 0000000000..ee5f0be6d9 --- /dev/null +++ b/Task/Random-number-generator--included-/PL-I/random-number-generator--included-.pli @@ -0,0 +1,2 @@ +seed(x) = mod(950706376 * seed(x-1), 2147483647) +random(x) = seed(x) / 2147483647 diff --git a/Task/Random-number-generator--included-/PL-SQL/random-number-generator--included--1.sql b/Task/Random-number-generator--included-/PL-SQL/random-number-generator--included--1.sql new file mode 100644 index 0000000000..5a386aab4b --- /dev/null +++ b/Task/Random-number-generator--included-/PL-SQL/random-number-generator--included--1.sql @@ -0,0 +1,2 @@ +DBMS_RANDOM.RANDOM --produces integers in [-2^^31, 2^^31). +DBMS_RANDOM.VALUE --produces numbers in [0,1) with 38 digits of precision. diff --git a/Task/Random-number-generator--included-/PL-SQL/random-number-generator--included--2.sql b/Task/Random-number-generator--included-/PL-SQL/random-number-generator--included--2.sql new file mode 100644 index 0000000000..fad9ccf44f --- /dev/null +++ b/Task/Random-number-generator--included-/PL-SQL/random-number-generator--included--2.sql @@ -0,0 +1,3 @@ +DBMS_CRYPTO.RANDOMBYTES --returns RAW value +DBMS_CRYPTO.RANDOMINTEGER --produces integers in the BINARY_INTEGER datatype +DBMS_CRYPTO.RANDOMNUMBER --produces integer in the NUMBER datatype in the range of [0..2**128-1] diff --git a/Task/Random-number-generator--included-/R/random-number-generator--included-.r b/Task/Random-number-generator--included-/R/random-number-generator--included-.r new file mode 100644 index 0000000000..328e8a899c --- /dev/null +++ b/Task/Random-number-generator--included-/R/random-number-generator--included-.r @@ -0,0 +1,2 @@ +?RNG +help.search("Distribution", package="stats") diff --git a/Task/Random-number-generator--included-/Rascal/random-number-generator--included--1.rascal b/Task/Random-number-generator--included-/Rascal/random-number-generator--included--1.rascal new file mode 100644 index 0000000000..3ed38f4e2a --- /dev/null +++ b/Task/Random-number-generator--included-/Rascal/random-number-generator--included--1.rascal @@ -0,0 +1,5 @@ +import util::Math; +arbInt(int limit); // generates an arbitrary integer below limit +arbRat(int limit, int limit); // generates an arbitrary rational number between the limits +arbReal(); // generates an arbitrary real value in the interval [0.0, 1.0] +arbSeed(int seed); diff --git a/Task/Random-number-generator--included-/Rascal/random-number-generator--included--2.rascal b/Task/Random-number-generator--included-/Rascal/random-number-generator--included--2.rascal new file mode 100644 index 0000000000..8ab8ad53b3 --- /dev/null +++ b/Task/Random-number-generator--included-/Rascal/random-number-generator--included--2.rascal @@ -0,0 +1,4 @@ +rascal>import List; +ok +rascal>getOneFrom(["zebra", "elephant", "snake", "owl"]); +str: "owl" diff --git a/Task/Random-number-generator--included-/Run-BASIC/random-number-generator--included-.run b/Task/Random-number-generator--included-/Run-BASIC/random-number-generator--included-.run new file mode 100644 index 0000000000..a1b34033bf --- /dev/null +++ b/Task/Random-number-generator--included-/Run-BASIC/random-number-generator--included-.run @@ -0,0 +1 @@ +rmd(0) diff --git a/Task/Random-number-generator--included-/UNIX-Shell/random-number-generator--included-.sh b/Task/Random-number-generator--included-/UNIX-Shell/random-number-generator--included-.sh new file mode 100644 index 0000000000..a55a9efbc8 --- /dev/null +++ b/Task/Random-number-generator--included-/UNIX-Shell/random-number-generator--included-.sh @@ -0,0 +1 @@ +number=`awk 'BEGIN{print int(rand()*10+1)}'` # Get a random number diff --git a/Task/Random-number-generator--included-/XPL0/random-number-generator--included-.xpl0 b/Task/Random-number-generator--included-/XPL0/random-number-generator--included-.xpl0 new file mode 100644 index 0000000000..38275a7778 --- /dev/null +++ b/Task/Random-number-generator--included-/XPL0/random-number-generator--included-.xpl0 @@ -0,0 +1,6 @@ +include c:\cxpl\codes; \intrinsic 'code' declarations +int I; +[RanSeed(12345); \set random number generator seed to 12345 +for I:= 1 to 5 do + [IntOut(0, Ran(1_000_000)); CrLf(0)]; +] diff --git a/Task/Random-numbers/0DESCRIPTION b/Task/Random-numbers/0DESCRIPTION new file mode 100644 index 0000000000..ac09fcdf70 --- /dev/null +++ b/Task/Random-numbers/0DESCRIPTION @@ -0,0 +1,3 @@ +The goal of this task is to generate a collection filled with 1000 normally distributed random (or pseudorandom) numbers with a mean of 1.0 and a [[wp:Standard_deviation|standard deviation]] of 0.5 + +Many libraries only generate uniformly distributed random numbers. If so, use [[wp:Normal_distribution#Generating_values_from_normal_distribution|this formula]] to convert them to a normal distribution. diff --git a/Task/Random-numbers/1META.yaml b/Task/Random-numbers/1META.yaml new file mode 100644 index 0000000000..b643d1dd0b --- /dev/null +++ b/Task/Random-numbers/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Probability and statistics +note: Basic language learning diff --git a/Task/Random-numbers/ALGOL-68/random-numbers.alg b/Task/Random-numbers/ALGOL-68/random-numbers.alg new file mode 100644 index 0000000000..30184f0607 --- /dev/null +++ b/Task/Random-numbers/ALGOL-68/random-numbers.alg @@ -0,0 +1,13 @@ +PROC random normal = REAL: # normal distribution, centered on 0, std dev 1 # +( + sqrt(-2*log(random)) * cos(2*pi*random) +); + +test:( + [1000]REAL rands; + FOR i TO UPB rands DO + rands[i] := 1 + random normal/2 + OD; + INT limit=10; + printf(($"("n(limit-1)(-d.6d",")-d.5d" ... )"$, rands[:limit])) +) diff --git a/Task/Random-numbers/AWK/random-numbers.awk b/Task/Random-numbers/AWK/random-numbers.awk new file mode 100644 index 0000000000..2dba133748 --- /dev/null +++ b/Task/Random-numbers/AWK/random-numbers.awk @@ -0,0 +1 @@ +$ awk 'func r(){return sqrt(-2*log(rand()))*cos(6.2831853*rand())}BEGIN{for(i=0;i<1000;i++)s=s" "1+0.5*r();print s}' diff --git a/Task/Random-numbers/Ada/random-numbers.ada b/Task/Random-numbers/Ada/random-numbers.ada new file mode 100644 index 0000000000..bf0e8c618d --- /dev/null +++ b/Task/Random-numbers/Ada/random-numbers.ada @@ -0,0 +1,23 @@ +with Ada.Numerics; use Ada.Numerics; +with Ada.Numerics.Float_Random; use Ada.Numerics.Float_Random; +with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions; + +procedure Normal_Random is + function Normal_Distribution + ( Seed : Generator; + Mu : Float := 1.0; + Sigma : Float := 0.5 + ) return Float is + begin + return + Mu + (Sigma * Sqrt (-2.0 * Log (Random (Seed), 10.0)) * Cos (2.0 * Pi * Random (Seed))); + end Normal_Distribution; + + Seed : Generator; + Distribution : array (1..1_000) of Float; +begin + Reset (Seed); + for I in Distribution'Range loop + Distribution (I) := Normal_Distribution (Seed); + end loop; +end Normal_Random; diff --git a/Task/Random-numbers/AutoHotkey/random-numbers.ahk b/Task/Random-numbers/AutoHotkey/random-numbers.ahk new file mode 100644 index 0000000000..d3af1c9970 --- /dev/null +++ b/Task/Random-numbers/AutoHotkey/random-numbers.ahk @@ -0,0 +1,15 @@ +Loop 40 + R .= RandN(1,0.5) "`n" ; mean = 1.0, standard deviation = 0.5 +MsgBox %R% + +RandN(m,s) { ; Normally distributed random numbers of mean = m, std.dev = s by Box-Muller method + Static i, Y + If (i := !i) { ; every other call + Random U, 0, 1.0 + Random V, 0, 6.2831853071795862 + U := sqrt(-2*ln(U))*s + Y := m + U*sin(V) + Return m + U*cos(V) + } + Return Y +} diff --git a/Task/Random-numbers/BBC-BASIC/random-numbers.bbc b/Task/Random-numbers/BBC-BASIC/random-numbers.bbc new file mode 100644 index 0000000000..a931aba211 --- /dev/null +++ b/Task/Random-numbers/BBC-BASIC/random-numbers.bbc @@ -0,0 +1,11 @@ + DIM array(999) + FOR number% = 0 TO 999 + array(number%) = 1.0 + 0.5 * SQR(-2*LN(RND(1))) * COS(2*PI*RND(1)) + NEXT + + mean = SUM(array()) / (DIM(array(),1) + 1) + array() -= mean + stdev = MOD(array()) / SQR(DIM(array(),1) + 1) + + PRINT "Mean = " ; mean + PRINT "Standard deviation = " ; stdev diff --git a/Task/Random-numbers/C++/random-numbers-1.cpp b/Task/Random-numbers/C++/random-numbers-1.cpp new file mode 100644 index 0000000000..8469364303 --- /dev/null +++ b/Task/Random-numbers/C++/random-numbers-1.cpp @@ -0,0 +1,27 @@ +#include // for rand +#include // for atan, sqrt, log, cos +#include // for generate_n + +double const pi = 4*std::atan(1.0); + +// simple functor for normal distribution +class normal_distribution +{ +public: + normal_distribution(double m, double s): mu(m), sigma(s) {} + double operator() const // returns a single normally distributed number + { + double r1 = (std::rand() + 1.0)/(RAND_MAX + 1.0); // gives equal distribution in (0, 1] + double r2 = (std::rand() + 1.0)/(RAND_MAX + 1.0); + return mu + sigma * std::sqrt(-2*std::log(r1))*std::cos(2*pi*r2); + } +private: + const double mu, sigma; +}; + +int main() +{ + double array[1000]; + std::generate_n(array, 1000, normal_distribution(1.0, 0.5)); + return 0; +} diff --git a/Task/Random-numbers/C++/random-numbers-2.cpp b/Task/Random-numbers/C++/random-numbers-2.cpp new file mode 100644 index 0000000000..70e0a34fdb --- /dev/null +++ b/Task/Random-numbers/C++/random-numbers-2.cpp @@ -0,0 +1,20 @@ +#include +#include "boost/random.hpp" +#include "boost/generator_iterator.hpp" +#include +#include + +typedef boost::mt19937 RNGType; ///< mersenne twister generator + +int main() { + RNGType rng; + boost::normal_distribution<> rdist(1.0,0.5); /**< normal distribution + with mean of 1.0 and standard deviation of 0.5 */ + + boost::variate_generator< RNGType, boost::normal_distribution<> > + get_rand(rng, rdist); + + std::vector v(1000); + generate(v.begin(),v.end(),get_rand); + return 0; +} diff --git a/Task/Random-numbers/C++/random-numbers-3.cpp b/Task/Random-numbers/C++/random-numbers-3.cpp new file mode 100644 index 0000000000..64b928b041 --- /dev/null +++ b/Task/Random-numbers/C++/random-numbers-3.cpp @@ -0,0 +1,17 @@ +#include +#include +#include +#include +using namespace std; + +int main() +{ + random_device seed; + mt19937 engine(seed()); + normal_distribution<> dist(1.0, 0.5); + auto rnd = bind(dist, engine); + + vector v(1000); + generate(v.begin(), v.end(), rnd); + return 0; +} diff --git a/Task/Random-numbers/C-sharp/random-numbers-1.cs b/Task/Random-numbers/C-sharp/random-numbers-1.cs new file mode 100644 index 0000000000..b68a60367d --- /dev/null +++ b/Task/Random-numbers/C-sharp/random-numbers-1.cs @@ -0,0 +1,4 @@ +private static double randomNormal() +{ + return Math.Cos(2 * Math.PI * tRand.NextDouble()) * Math.Sqrt(-2 * Math.Log(tRand.NextDouble())); +} diff --git a/Task/Random-numbers/C-sharp/random-numbers-2.cs b/Task/Random-numbers/C-sharp/random-numbers-2.cs new file mode 100644 index 0000000000..78e727fafd --- /dev/null +++ b/Task/Random-numbers/C-sharp/random-numbers-2.cs @@ -0,0 +1,27 @@ +static Random tRand = new Random(); + +static void Main(string[] args) +{ + double[] a = new double[1000]; + + double tAvg = 0; + for (int x = 0; x < a.Length; x++) + { + a[x] = randomNormal() / 2 + 1; + tAvg += a[x]; + } + + tAvg /= a.Length; + Console.WriteLine("Average: " + tAvg.ToString()); + + double s = 0; + for (int x = 0; x < a.Length; x++) + { + s += Math.Pow((a[x] - tAvg), 2); + } + s = Math.Sqrt(s / 1000); + + Console.WriteLine("Standard Deviation: " + s.ToString()); + + Console.ReadLine(); +} diff --git a/Task/Random-numbers/C/random-numbers.c b/Task/Random-numbers/C/random-numbers.c new file mode 100644 index 0000000000..0c620c29f9 --- /dev/null +++ b/Task/Random-numbers/C/random-numbers.c @@ -0,0 +1,22 @@ +#include +#include +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +double drand() /* uniform distribution, (0..1] */ +{ + return (rand()+1.0)/(RAND_MAX+1.0); +} +double random_normal() /* normal distribution, centered on 0, std dev 1 */ +{ + return sqrt(-2*log(drand())) * cos(2*M_PI*drand()); +} +int main() +{ + int i; + double rands[1000]; + for (i=0; i<1000; i++) + rands[i] = 1.0 + 0.5*random_normal(); + return 0; +} diff --git a/Task/Random-numbers/Clojure/random-numbers.clj b/Task/Random-numbers/Clojure/random-numbers.clj new file mode 100644 index 0000000000..17ad809003 --- /dev/null +++ b/Task/Random-numbers/Clojure/random-numbers.clj @@ -0,0 +1,4 @@ +(import '(java.util Random)) +(def normals + (let [r (Random.)] + (take 1000 (repeatedly #(-> r .nextGaussian (* 0.5) (+ 1.0)))))) diff --git a/Task/Random-numbers/Common-Lisp/random-numbers.lisp b/Task/Random-numbers/Common-Lisp/random-numbers.lisp new file mode 100644 index 0000000000..82a1b4522c --- /dev/null +++ b/Task/Random-numbers/Common-Lisp/random-numbers.lisp @@ -0,0 +1,2 @@ +(loop for i from 1 to 1000 + collect (1+ (* (sqrt (* -2 (log (random 1.0)))) (cos (* 2 pi (random 1.0))) 0.5))) diff --git a/Task/Random-numbers/D/random-numbers-1.d b/Task/Random-numbers/D/random-numbers-1.d new file mode 100644 index 0000000000..298a4d0352 --- /dev/null +++ b/Task/Random-numbers/D/random-numbers-1.d @@ -0,0 +1,24 @@ +import std.stdio, std.random, std.math; + +struct NormalRandom { + double mean, stdDev; + + // needed because it also defines an opCall + this(in double mean_, in double stdDev_) pure nothrow { + this.mean = mean_; + this.stdDev = stdDev_; + } + + double opCall() const /*nothrow*/ { + immutable double r1 = uniform(0.0, 1.0); + immutable double r2 = uniform(0.0, 1.0); + return mean + stdDev * sqrt(-2 * log(r1)) * cos(2 * PI * r2); + } +} + +void main() { + double[1000] array; + auto nrnd = NormalRandom(1.0, 0.5); + foreach (ref x; array) + x = nrnd(); +} diff --git a/Task/Random-numbers/D/random-numbers-2.d b/Task/Random-numbers/D/random-numbers-2.d new file mode 100644 index 0000000000..e87846b904 --- /dev/null +++ b/Task/Random-numbers/D/random-numbers-2.d @@ -0,0 +1,10 @@ +import tango.math.random.Random; + +void main() { + double[1000] list; + auto r = new Random(); + foreach (ref l; list) { + r.normalSource!(double)()(l); + l = 1.0 + 0.5 * l; + } +} diff --git a/Task/Random-numbers/DWScript/random-numbers.dwscript b/Task/Random-numbers/DWScript/random-numbers.dwscript new file mode 100644 index 0000000000..653491f60e --- /dev/null +++ b/Task/Random-numbers/DWScript/random-numbers.dwscript @@ -0,0 +1,5 @@ +var values : array [0..999] of Float; +var i : Integer; + +for i := values.Low to values.High do + values := RandG(1, 0.5); diff --git a/Task/Random-numbers/Delphi/random-numbers.delphi b/Task/Random-numbers/Delphi/random-numbers.delphi new file mode 100644 index 0000000000..764e68c5cd --- /dev/null +++ b/Task/Random-numbers/Delphi/random-numbers.delphi @@ -0,0 +1,19 @@ +program Randoms; + +{$APPTYPE CONSOLE} + +uses + Math; + +var + Values: array[0..999] of Double; + I: Integer; + +begin +// Randomize; Commented to obtain reproducible results + for I:= Low(Values) to High(Values) do + Values[I]:= RandG(1.0, 0.5); // Mean = 1.0, StdDev = 0.5 + Writeln('Mean = ', Mean(Values):6:4); + Writeln('Std Deviation = ', StdDev(Values):6:4); + Readln; +end. diff --git a/Task/Random-numbers/E/random-numbers.e b/Task/Random-numbers/E/random-numbers.e new file mode 100644 index 0000000000..8d8becd1b2 --- /dev/null +++ b/Task/Random-numbers/E/random-numbers.e @@ -0,0 +1 @@ +accum [] for _ in 1..1000 { _.with(entropy.nextGaussian()) } diff --git a/Task/Random-numbers/Eiffel/random-numbers.e b/Task/Random-numbers/Eiffel/random-numbers.e new file mode 100644 index 0000000000..df4b120c52 --- /dev/null +++ b/Task/Random-numbers/Eiffel/random-numbers.e @@ -0,0 +1,95 @@ +class + APPLICATION + +inherit + ARGUMENTS + +create + make + +feature {NONE} -- Initialization + + l_time: TIME + l_seed: INTEGER + math:DOUBLE_MATH + rnd:RANDOM + Size:INTEGER + once + Result:= 1000 + end + + make + -- Run application. + local + ergebnis:ARRAY[DOUBLE] + tavg: DOUBLE + x: INTEGER + tmp: DOUBLE + text : STRING + + do + -- initialize random generator + create l_time.make_now + l_seed := l_time.hour + l_seed := l_seed * 60 + l_time.minute + l_seed := l_seed * 60 + l_time.second + l_seed := l_seed * 1000 + l_time.milli_second + create rnd.set_seed (l_seed) + + -- initialize random number container and math + create ergebnis.make_filled (0.0, 1, size) + tavg := 0; + create math + + from + x := 1 + until + x > ergebnis.count + loop + tmp := randomNormal / 2 + 1 + tavg := tavg + tmp + ergebnis.enter (tmp , x) + x := x + 1 + end + + tavg := tavg / ergebnis.count + text := "Average: " + text.append_double (tavg) + text.append ("%N") + print(text) + + tmp := 0 + from + x:= 1 + until + x > ergebnis.count + loop + tmp := tmp + (ergebnis.item (x) - tavg)^2 + x := x + 1 + end + + tmp := math.sqrt (tmp / ergebnis.count) + text := "Standard Deviation: " + text.append_double (tmp) + text.append ("%N") + print(text) + + end + + randomNormal:DOUBLE + + local + + first: DOUBLE + second: DOUBLE + + do + rnd.forth + first := rnd.double_item + rnd.forth + second := rnd.double_item + + Result := math.cosine (2 * math.pi * first) * math.sqrt (-2 * math.log (second)) + + end +end diff --git a/Task/Random-numbers/Erlang/random-numbers.erl b/Task/Random-numbers/Erlang/random-numbers.erl new file mode 100644 index 0000000000..a267838684 --- /dev/null +++ b/Task/Random-numbers/Erlang/random-numbers.erl @@ -0,0 +1,31 @@ +mean(Values) -> + mean(tl(Values), hd(Values), 1). + +mean([], Acc, Length) -> + Acc / Length; +mean(Values, Acc, Length) -> + mean(tl(Values), hd(Values)+Acc, Length+1). + +variance(Values) -> + Mean = mean(Values), + variance(Values, Mean, 0) / length(Values). + +variance([], _, Acc) -> + Acc; +variance(Values, Mean, Acc) -> + Diff = hd(Values) - Mean, + DiffSqr = Diff * Diff, + variance(tl(Values), Mean, Acc + DiffSqr). + +stddev(Values) -> + math:sqrt(variance(Values)). + +normal(Mean, StdDev) -> + U = random:uniform(), + V = random:uniform(), + Mean + StdDev * ( math:sqrt(-2 * math:log(U)) * math:cos(2 * math:pi() * V) ). % Erlang's math:log is the natural logarithm. + +main(_) -> + X = [ normal(1.0, 0.5) || _ <- lists:seq(1, 1000) ], + io:format("mean = ~w\n", [mean(X)]), + io:format("stddev = ~w\n", [stddev(X)]). diff --git a/Task/Random-numbers/Euler-Math-Toolbox/random-numbers.euler b/Task/Random-numbers/Euler-Math-Toolbox/random-numbers.euler new file mode 100644 index 0000000000..a9124f5ceb --- /dev/null +++ b/Task/Random-numbers/Euler-Math-Toolbox/random-numbers.euler @@ -0,0 +1,4 @@ +>v=normal(1,1000)*0.5+1; +>mean(v), dev(v) + 1.00291801071 + 0.498226876528 diff --git a/Task/Random-numbers/Euphoria/random-numbers.euphoria b/Task/Random-numbers/Euphoria/random-numbers.euphoria new file mode 100644 index 0000000000..408170df8d --- /dev/null +++ b/Task/Random-numbers/Euphoria/random-numbers.euphoria @@ -0,0 +1,15 @@ +include misc.e + +function RandomNormal() + atom x1, x2 + x1 = rand(999999) / 1000000 + x2 = rand(999999) / 1000000 + return sqrt(-2*log(x1)) * cos(2*PI*x2) +end function + +constant n = 1000 +sequence s +s = repeat(0,n) +for i = 1 to n do + s[i] = 1 + 0.5 * RandomNormal() +end for diff --git a/Task/Random-numbers/Factor/random-numbers.factor b/Task/Random-numbers/Factor/random-numbers.factor new file mode 100644 index 0000000000..c9bf94312d --- /dev/null +++ b/Task/Random-numbers/Factor/random-numbers.factor @@ -0,0 +1 @@ +1000 [ 1.0 0.5 normal-random-float ] replicate diff --git a/Task/Random-numbers/Fantom/random-numbers-1.fantom b/Task/Random-numbers/Fantom/random-numbers-1.fantom new file mode 100644 index 0000000000..75544249bc --- /dev/null +++ b/Task/Random-numbers/Fantom/random-numbers-1.fantom @@ -0,0 +1,17 @@ +class Main +{ + static const Float PI := 0.0f.acos * 2 // we need to precompute PI + + static Float randomNormal () + { + return (Float.random * PI * 2).cos * (Float.random.log * -2).sqrt + } + + public static Void main () + { + mean := 1.0f + sd := 0.5f + Float[] values := [,] // this is the collection to fill with random numbers + 1000.times { values.add (randomNormal * sd + mean) } + } +} diff --git a/Task/Random-numbers/Fantom/random-numbers-2.fantom b/Task/Random-numbers/Fantom/random-numbers-2.fantom new file mode 100644 index 0000000000..46f83239c1 --- /dev/null +++ b/Task/Random-numbers/Fantom/random-numbers-2.fantom @@ -0,0 +1,20 @@ +using [java] java.util::Random + +class Main +{ + Random generator := Random() + + Float randomNormal () + { + return generator.nextGaussian + } + + public static Void main () + { + rnd := Main() // create an instance of Main class, which holds the generator + mean := 1.0f + sd := 0.5f + Float[] values := [,] // this is the collection to fill with random numbers + 1000.times { values.add (rnd.randomNormal * sd + mean) } + } +} diff --git a/Task/Random-numbers/Forth/random-numbers.fth b/Task/Random-numbers/Forth/random-numbers.fth new file mode 100644 index 0000000000..8d8741348f --- /dev/null +++ b/Task/Random-numbers/Forth/random-numbers.fth @@ -0,0 +1,16 @@ +require random.fs +here to seed + +-1. 1 rshift 2constant MAX-D \ or s" MAX-D" ENVIRONMENT? drop + +: frnd ( -- f ) \ uniform distribution 0..1 + rnd rnd dabs d>f MAX-D d>f f/ ; + +: frnd-normal ( -- f ) \ centered on 0, std dev 1 + frnd pi f* 2e f* fcos + frnd fln -2e f* fsqrt f* ; + +: ,normals ( n -- ) \ store many, centered on 1, std dev 0.5 + 0 do frnd-normal 0.5e f* 1e f+ f, loop ; + +create rnd-array 1000 ,normals diff --git a/Task/Random-numbers/Fortran/random-numbers.f b/Task/Random-numbers/Fortran/random-numbers.f new file mode 100644 index 0000000000..b0b51a2535 --- /dev/null +++ b/Task/Random-numbers/Fortran/random-numbers.f @@ -0,0 +1,24 @@ +PROGRAM Random + + INTEGER, PARAMETER :: n = 1000 + INTEGER :: i + REAL :: array(n), pi, temp, mean = 1.0, sd = 0.5 + + pi = 4.0*ATAN(1.0) + CALL RANDOM_NUMBER(array) ! Uniform distribution + +! Now convert to normal distribution + DO i = 1, n-1, 2 + temp = sd * SQRT(-2.0*LOG(array(i))) * COS(2*pi*array(i+1)) + mean + array(i+1) = sd * SQRT(-2.0*LOG(array(i))) * SIN(2*pi*array(i+1)) + mean + array(i) = temp + END DO + +! Check mean and standard deviation + mean = SUM(array)/n + sd = SQRT(SUM((array - mean)**2)/n) + + WRITE(*, "(A,F8.6)") "Mean = ", mean + WRITE(*, "(A,F8.6)") "Standard Deviation = ", sd + +END PROGRAM Random diff --git a/Task/Random-numbers/Go/random-numbers.go b/Task/Random-numbers/Go/random-numbers.go new file mode 100644 index 0000000000..a939a0eb8d --- /dev/null +++ b/Task/Random-numbers/Go/random-numbers.go @@ -0,0 +1,17 @@ +package main + +import ( + "math/rand" + "time" +) + +const mean = 1.0 +const stdv = .5 + +func main() { + var list [1000]float64 + rand.Seed(time.Now().UnixNano()) + for i := range list { + list[i] = mean + stdv*rand.NormFloat64() + } +} diff --git a/Task/Random-numbers/Groovy/random-numbers.groovy b/Task/Random-numbers/Groovy/random-numbers.groovy new file mode 100644 index 0000000000..d5d62fa7ef --- /dev/null +++ b/Task/Random-numbers/Groovy/random-numbers.groovy @@ -0,0 +1,2 @@ +rnd = new Random() +result = (1..1000).inject([]) { r, i -> r << rnd.nextGaussian() } diff --git a/Task/Random-numbers/Haskell/random-numbers.hs b/Task/Random-numbers/Haskell/random-numbers.hs new file mode 100644 index 0000000000..9baa64fec0 --- /dev/null +++ b/Task/Random-numbers/Haskell/random-numbers.hs @@ -0,0 +1,14 @@ +import System.Random + +pairs :: [a] -> [(a,a)] +pairs (x:y:zs) = (x,y):pairs zs +pairs _ = [] + +gauss mu sigma (r1,r2) = + mu + sigma * sqrt (-2 * log r1) * cos (2 * pi * r2) + +gaussians :: (RandomGen g, Random a, Floating a) => Int -> g -> [a] +gaussians n g = take n $ map (gauss 1.0 0.5) $ pairs $ randoms g + +result :: IO [Double] +result = getStdGen >>= \g -> return $ gaussians 1000 g diff --git a/Task/Random-numbers/HicEst/random-numbers.hicest b/Task/Random-numbers/HicEst/random-numbers.hicest new file mode 100644 index 0000000000..9c4a4c5c00 --- /dev/null +++ b/Task/Random-numbers/HicEst/random-numbers.hicest @@ -0,0 +1,4 @@ +REAL :: n=1000, m=1, s=0.5, array(n) + +pi = 4 * ATAN(1) +array = s * (-2*LOG(RAN(1)))^0.5 * COS(2*pi*RAN(1)) + m diff --git a/Task/Random-numbers/IDL/random-numbers.idl b/Task/Random-numbers/IDL/random-numbers.idl new file mode 100644 index 0000000000..589c870698 --- /dev/null +++ b/Task/Random-numbers/IDL/random-numbers.idl @@ -0,0 +1 @@ +result = 1.0 + 0.5*randomn(seed,1000) diff --git a/Task/Random-numbers/Icon/random-numbers.icon b/Task/Random-numbers/Icon/random-numbers.icon new file mode 100644 index 0000000000..661335c6ad --- /dev/null +++ b/Task/Random-numbers/Icon/random-numbers.icon @@ -0,0 +1,7 @@ +procedure main() + local L + L := list(1000) + every L[1 to 1000] := 1.0 + 0.5 * sqrt(-2.0 * log(?0)) * cos(2.0 * &pi * ?0) + + every write(!L) +end diff --git a/Task/Random-numbers/J/random-numbers-1.j b/Task/Random-numbers/J/random-numbers-1.j new file mode 100644 index 0000000000..3c1259bc27 --- /dev/null +++ b/Task/Random-numbers/J/random-numbers-1.j @@ -0,0 +1,4 @@ +urand=: ?@$ 0: +zrand=: (2 o. 2p1 * urand) * [: %: _2 * [: ^. urand + +1 + 0.5 * zrand 100 diff --git a/Task/Random-numbers/J/random-numbers-2.j b/Task/Random-numbers/J/random-numbers-2.j new file mode 100644 index 0000000000..671d53b236 --- /dev/null +++ b/Task/Random-numbers/J/random-numbers-2.j @@ -0,0 +1,3 @@ + require 'stats/distribs/normal' + 1 0.5 rnorm 1000 +1.44868803 1.21548637 0.812460657 1.54295452 1.2470606 ... diff --git a/Task/Random-numbers/Java/random-numbers.java b/Task/Random-numbers/Java/random-numbers.java new file mode 100644 index 0000000000..6762c8a19a --- /dev/null +++ b/Task/Random-numbers/Java/random-numbers.java @@ -0,0 +1,6 @@ +double[] list = new double[1000]; +double mean = 1.0, std = 0.5; +Random rng = new Random(); +for(int i = 0;i= 1) + u = ( 2 * rand(sz) ) - 1; + v = ( 2 * rand(sz) ) - 1; + + radiusSquared = u.^2 + v.^2; + end + + scaleFactor = sqrt( ( -2*log(radiusSquared) )./ radiusSquared ); + randNum = (v .* scaleFactor .* chi2) + mu0; + +end diff --git a/Task/Random-numbers/MATLAB/random-numbers-4.m b/Task/Random-numbers/MATLAB/random-numbers-4.m new file mode 100644 index 0000000000..354ac44580 --- /dev/null +++ b/Task/Random-numbers/MATLAB/random-numbers-4.m @@ -0,0 +1,5 @@ +>> randNorm(1,.5, [1000,1]) + +ans = + + 0.693984121077029 diff --git a/Task/Random-numbers/MAXScript/random-numbers.maxscript b/Task/Random-numbers/MAXScript/random-numbers.maxscript new file mode 100644 index 0000000000..0854d72850 --- /dev/null +++ b/Task/Random-numbers/MAXScript/random-numbers.maxscript @@ -0,0 +1,8 @@ +arr = #() +for i in 1 to 1000 do +( + a = random 0.0 1.0 + b = random 0.0 1.0 + c = 1.0 + 0.5 * sqrt (-2*log a) * cos (360*b) -- Maxscript cos takes degrees + append arr c +) diff --git a/Task/Random-numbers/Mathematica/random-numbers.math b/Task/Random-numbers/Mathematica/random-numbers.math new file mode 100644 index 0000000000..5b86f553a6 --- /dev/null +++ b/Task/Random-numbers/Mathematica/random-numbers.math @@ -0,0 +1 @@ +RandomReal[NormalDistribution[1, 1/2], 1000] diff --git a/Task/Random-numbers/Maxima/random-numbers.maxima b/Task/Random-numbers/Maxima/random-numbers.maxima new file mode 100644 index 0000000000..1777501e98 --- /dev/null +++ b/Task/Random-numbers/Maxima/random-numbers.maxima @@ -0,0 +1,3 @@ +load(distrib)$ + +random_normal(1.0, 0.5, 1000); diff --git a/Task/Random-numbers/Metafont/random-numbers.metafont b/Task/Random-numbers/Metafont/random-numbers.metafont new file mode 100644 index 0000000000..031ebf6082 --- /dev/null +++ b/Task/Random-numbers/Metafont/random-numbers.metafont @@ -0,0 +1,19 @@ +numeric col[]; + +m := 0; % m holds the mean, for testing purposes +for i = 1 upto 1000: + col[i] := 1 + .5normaldeviate; + m := m + col[i]; +endfor + +% testing +m := m / 1000; % finalize the computation of the mean + +s := 0; % in s we compute the standard deviation +for i = 1 upto 1000: + s := s + (col[i] - m)**2; +endfor +s := sqrt(s / 1000); + +show m, s; % and let's show that really they get what we wanted +end diff --git a/Task/Random-numbers/Mirah/random-numbers.mirah b/Task/Random-numbers/Mirah/random-numbers.mirah new file mode 100644 index 0000000000..b985a21ff3 --- /dev/null +++ b/Task/Random-numbers/Mirah/random-numbers.mirah @@ -0,0 +1,9 @@ +import java.util.Random + +list = double[999] +mean = 1.0 +std = 0.5 +rng = Random.new +0.upto(998) do | i | + list[i] = mean + std * rng.nextGaussian +end diff --git a/Task/Random-numbers/Modula-3/random-numbers.mod3 b/Task/Random-numbers/Modula-3/random-numbers.mod3 new file mode 100644 index 0000000000..1ee92e4c33 --- /dev/null +++ b/Task/Random-numbers/Modula-3/random-numbers.mod3 @@ -0,0 +1,21 @@ +MODULE Rand EXPORTS Main; + +IMPORT Random; +FROM Math IMPORT log, cos, sqrt, Pi; + +VAR rands: ARRAY [1..1000] OF LONGREAL; + +(* Normal distribution. *) +PROCEDURE RandNorm(): LONGREAL = + BEGIN + WITH rand = NEW(Random.Default).init() DO + RETURN + sqrt(-2.0D0 * log(rand.longreal())) * cos(2.0D0 * Pi * rand.longreal()); + END; + END RandNorm; + +BEGIN + FOR i := FIRST(rands) TO LAST(rands) DO + rands[i] := 1.0D0 + 0.5D0 * RandNorm(); + END; +END Rand. diff --git a/Task/Random-numbers/NetRexx/random-numbers.netrexx b/Task/Random-numbers/NetRexx/random-numbers.netrexx new file mode 100644 index 0000000000..8646543e53 --- /dev/null +++ b/Task/Random-numbers/NetRexx/random-numbers.netrexx @@ -0,0 +1,55 @@ +/* NetRexx */ +options replace format comments java crossref symbols nobinary + +import java.math.BigDecimal +import java.math.MathContext + +-- prologue +numeric digits 20 + +-- get input, set defaults +parse arg dp mu sigma ec . +if mu = '' | mu = '.' then mean = 1.0; else mean = mu +if sigma = '' | sigma = '.' then stdDeviation = 0.5; else stdDeviation = sigma +if dp = '' | dp = '.' then displayPrecision = 1; else displayPrecision = dp +if ec = '' | ec = '.' then elements = 1000; else elements = ec + +-- set up +RNG = Random() +numberList = java.util.List +numberList = ArrayList() + +-- generate list of random numbers +loop for elements + rn = mean + stdDeviation * RNG.nextGaussian() + numberList.add(BigDecimal(rn, MathContext.DECIMAL128)) + end + +-- report +say "Mean: " mean +say "Standard Deviation:" stdDeviation +say "Precision: " displayPrecision +say +drawBellCurve(numberList, displayPrecision) + +return + +-- ----------------------------------------------------------------------------- +method drawBellCurve(numberList = java.util.List, precision) static + Collections.sort(numberList) + val = BigDecimal + lastN = '' + nextN = '' + loop val over numberList + nextN = Rexx(val.toPlainString()).format(5, precision) + select + when lastN = '' then nop + when lastN \= nextN then say lastN + otherwise nop + end + say '*\-' + lastN = nextN + end val + say lastN + + return diff --git a/Task/Random-numbers/NewLISP/random-numbers.newlisp b/Task/Random-numbers/NewLISP/random-numbers.newlisp new file mode 100644 index 0000000000..d18ec86cc3 --- /dev/null +++ b/Task/Random-numbers/NewLISP/random-numbers.newlisp @@ -0,0 +1 @@ +(normal 1 .5 1000) diff --git a/Task/Random-numbers/OCaml/random-numbers.ocaml b/Task/Random-numbers/OCaml/random-numbers.ocaml new file mode 100644 index 0000000000..8c6e134d84 --- /dev/null +++ b/Task/Random-numbers/OCaml/random-numbers.ocaml @@ -0,0 +1,4 @@ +let pi = 4. *. atan 1.;; +let random_gaussian () = + 1. +. sqrt (-2. *. log (Random.float 1.)) *. cos (2. *. pi *. Random.float 1.);; +let a = Array.init 1000 (fun _ -> random_gaussian ());; diff --git a/Task/Random-numbers/Objeck/random-numbers.objeck b/Task/Random-numbers/Objeck/random-numbers.objeck new file mode 100644 index 0000000000..07b10d5ace --- /dev/null +++ b/Task/Random-numbers/Objeck/random-numbers.objeck @@ -0,0 +1,18 @@ +bundle Default { + class RandomNumbers { + function : Main(args : String[]) ~ Nil { + rands := Float->New[1000]; + for(i := 0; i < rands->Size(); i += 1;) { + rands[i] := 1.0 + 0.5 * RandomNormal(); + }; + + each(i : rands) { + rands[i]->PrintLine(); + }; + } + + function : native : RandomNormal() ~ Float { + return (2 * Float->Pi() * Float->Random())->Cos() * (-2 * (Float->Random()->Log()))->SquareRoot(); + } + } +} diff --git a/Task/Random-numbers/Octave/random-numbers.octave b/Task/Random-numbers/Octave/random-numbers.octave new file mode 100644 index 0000000000..bfc29bd35b --- /dev/null +++ b/Task/Random-numbers/Octave/random-numbers.octave @@ -0,0 +1,3 @@ +p = normrnd(1.0, 0.5, 1000, 1); +disp(mean(p)); +disp(sqrt(sum((p - mean(p)).^2)/numel(p))); diff --git a/Task/Random-numbers/PARI-GP/random-numbers.pari b/Task/Random-numbers/PARI-GP/random-numbers.pari new file mode 100644 index 0000000000..ef35a5fd22 --- /dev/null +++ b/Task/Random-numbers/PARI-GP/random-numbers.pari @@ -0,0 +1,6 @@ +rnormal()={ + my(pr=32*ceil(default(realprecision)*log(10)/log(4294967296)),u1=random(2^pr)*1.>>pr,u2=random(2^pr)*1.>>pr); + sqrt(-2*log(u1))*cos(2*Pi*u1) + \\ Could easily be extended with a second normal at very little cost. +}; +vector(1000,unused,rnormal()/2+1) diff --git a/Task/Random-numbers/PHP/random-numbers.php b/Task/Random-numbers/PHP/random-numbers.php new file mode 100644 index 0000000000..25bc0e5c99 --- /dev/null +++ b/Task/Random-numbers/PHP/random-numbers.php @@ -0,0 +1,11 @@ +function random() { + return mt_rand() / mt_getrandmax(); +} + +$pi = pi(); // Set PI + +$a = array(); +for ($i = 0; $i < 1000; $i++) { + $a[$i] = 1.0 + ((sqrt(-2 * log(random())) * cos(2 * $pi * random())) * 0.5); + +} diff --git a/Task/Random-numbers/PL-I/random-numbers.pli b/Task/Random-numbers/PL-I/random-numbers.pli new file mode 100644 index 0000000000..4fe2d4f8d8 --- /dev/null +++ b/Task/Random-numbers/PL-I/random-numbers.pli @@ -0,0 +1,21 @@ +/* CONVERTED FROM WIKI FORTRAN */ +Normal_Random: procedure options (main); + declare (array(1000), pi, temp, + mean initial (1.0), sd initial (0.5)) float (18); + declare (i, n) fixed binary; + + n = hbound(array, 1); + pi = 4.0*ATAN(1.0); + array = random(); /* Uniform distribution */ + /* Now convert to normal distribution */ + DO i = 1 to n-1 by 2; + temp = sd * SQRT(-2.0*LOG(array(i))) * COS(2*pi*array(i+1)) + mean; + array(i+1) = sd * SQRT(-2.0*LOG(array(i))) * SIN(2*pi*array(i+1)) + mean; + array(i) = temp; + END; + /* Check mean and standard deviation */ + mean = SUM(array)/n; + sd = SQRT(SUM((array - mean)**2)/n); + put skip edit ( "Mean = ", mean ) (a, F(18,16) ); + put skip edit ( "Standard Deviation = ", sd) (a, F(18,16)); +END Normal_Random; diff --git a/Task/Random-numbers/PL-SQL/random-numbers.sql b/Task/Random-numbers/PL-SQL/random-numbers.sql new file mode 100644 index 0000000000..a4eefdddd6 --- /dev/null +++ b/Task/Random-numbers/PL-SQL/random-numbers.sql @@ -0,0 +1,24 @@ +create or replace +PROCEDURE PROCEDURE1 AS + TYPE numsColl is TABLE OF NUMBER; + nums numsColl; + + FUNCTION GenNums(n IN NUMBER) RETURN numsColl AS + PI NUMBER := ACOS (-1); + BEGIN + nums := numsColl(); + nums.extend(n); + + FOR i in 1 .. n LOOP + nums(i) := 1 + .5 * (sqrt(-2 * log(dbms_random.value, 10)) * cos(2 * PI * dbms_random.value)); + END LOOP; + + RETURN nums; + END GenNums; + +BEGIN + nums := GenNums(10); + FOR i in 1 .. 10 LOOP + DBMS_OUTPUT.PUT_LINE(nums(i)); + END LOOP; +END PROCEDURE1; diff --git a/Task/Random-numbers/Perl-6/random-numbers.pl6 b/Task/Random-numbers/Perl-6/random-numbers.pl6 new file mode 100644 index 0000000000..03b470453f --- /dev/null +++ b/Task/Random-numbers/Perl-6/random-numbers.pl6 @@ -0,0 +1,5 @@ +sub randnorm ($mean, $stddev) { + $mean + $stddev * sqrt(-2 * log rand) * cos(2 * pi * rand) +} + +my @nums = map { randnorm 1, 0.5 }, ^1000; diff --git a/Task/Random-numbers/Perl/random-numbers.pl b/Task/Random-numbers/Perl/random-numbers.pl new file mode 100644 index 0000000000..824035f915 --- /dev/null +++ b/Task/Random-numbers/Perl/random-numbers.pl @@ -0,0 +1,5 @@ +my $PI = 2 * atan2 1, 0; + +my @nums = map { + 1 + 0.5 * sqrt(-2 * log rand) * cos(2 * $PI * rand) +} 1..1000; diff --git a/Task/Random-numbers/PicoLisp/random-numbers.l b/Task/Random-numbers/PicoLisp/random-numbers.l new file mode 100644 index 0000000000..d6ec5c3804 --- /dev/null +++ b/Task/Random-numbers/PicoLisp/random-numbers.l @@ -0,0 +1,16 @@ +(load "@lib/math.l") + +(de randomNormal () # Normal distribution, centered on 0, std dev 1 + (*/ + (sqrt (* -2.0 (log (rand 0 1.0)))) + (cos (*/ 2.0 pi (rand 0 1.0) `(* 1.0 1.0))) + 1.0 ) ) + +(seed (time)) # Randomize + +(let Result + (make # Build list + (do 1000 # of 1000 elements + (link (+ 1.0 (/ (randomNormal) 2))) ) ) + (for N (head 7 Result) # Print first 7 results + (prin (format N *Scl) " ") ) ) diff --git a/Task/Random-numbers/Pop11/random-numbers.pop11 b/Task/Random-numbers/Pop11/random-numbers.pop11 new file mode 100644 index 0000000000..0554e63abf --- /dev/null +++ b/Task/Random-numbers/Pop11/random-numbers.pop11 @@ -0,0 +1,15 @@ +;;; Choose radians as arguments to trigonometic functions +true -> popradians; + +;;; procedure generating standard normal distribution +define random_normal() -> result; +lvars r1 = random0(1.0), r2 = random0(1.0); + cos(2*pi*r1)*sqrt(-2*log(r2)) -> result +enddefine; + +lvars array, i; + +;;; Put numbers on the stack +for i from 1 to 1000 do 1.0+0.5*random_normal() endfor; +;;; collect them into array +consvector(1000) -> array; diff --git a/Task/Random-numbers/PureBasic/random-numbers.purebasic b/Task/Random-numbers/PureBasic/random-numbers.purebasic new file mode 100644 index 0000000000..91cc46de77 --- /dev/null +++ b/Task/Random-numbers/PureBasic/random-numbers.purebasic @@ -0,0 +1,18 @@ +Procedure.f RandomNormal() + ; This procedure can return any real number. + Protected.f x1, x2 + + ; random numbers from the open interval ]0, 1[ + x1 = (Random(999998)+1) / 1000000 ; must be > 0 because of Log(x1) + x2 = (Random(999998)+1) / 1000000 + + ProcedureReturn Sqr(-2*Log(x1)) * Cos(2*#PI*x2) +EndProcedure + + +Define i, n=1000 + +Dim a.q(n-1) +For i = 0 To n-1 + a(i) = 1 + 0.5 * RandomNormal() +Next diff --git a/Task/Random-numbers/Python/random-numbers-1.py b/Task/Random-numbers/Python/random-numbers-1.py new file mode 100644 index 0000000000..81eea3a31f --- /dev/null +++ b/Task/Random-numbers/Python/random-numbers-1.py @@ -0,0 +1,3 @@ +import random +values = [random.gauss(1, .5) for i in range(1000)] +# or [ random.normalvariate(1, 0.5) for i in range(1000)] diff --git a/Task/Random-numbers/Python/random-numbers-2.py b/Task/Random-numbers/Python/random-numbers-2.py new file mode 100644 index 0000000000..13cdcd443d --- /dev/null +++ b/Task/Random-numbers/Python/random-numbers-2.py @@ -0,0 +1,4 @@ +>>> mean = sum(values)/1000 +>>> sdeviation = (sum((i - mean)**2 for i in values)/1000)**0.5 +>>> mean, sdeviation +(1.0127861555468178, 0.5006682783828207) diff --git a/Task/Random-numbers/R/random-numbers.r b/Task/Random-numbers/R/random-numbers.r new file mode 100644 index 0000000000..cb70f31cc0 --- /dev/null +++ b/Task/Random-numbers/R/random-numbers.r @@ -0,0 +1 @@ +result <- rnorm(1000, mean=1, sd=0.5) diff --git a/Task/Random-numbers/REXX/random-numbers.rexx b/Task/Random-numbers/REXX/random-numbers.rexx new file mode 100644 index 0000000000..7bf4ed0455 --- /dev/null +++ b/Task/Random-numbers/REXX/random-numbers.rexx @@ -0,0 +1,41 @@ +/*REXX pgm gens 1,000 normally distributed #s: mean=1, standard dev.=½. */ +call pi /*call subroutine to define pi. */ +parse arg n seed . /*allow specification of N | seed*/ +if n=='' | n==',' then n=1000 /* N is the size of the array. */ +if seed\=='' then call random ,,seed /*use seed for repeatable RANDOM#*/ +mean=1 /*desired new mean (arith. avg.) */ +sd=1/2 /*desired new standard deviation.*/ + do g=1 for n /*generate N uniform random nums.*/ + #.g=random(0,1e5)/1e5 /*REXX gens uniform rand integers*/ + end /*g*/ + +say ' old mean=' mean() +say 'old standard deviation=' stddev() +say + do j=1 to n-1 by 2 + m=j+1 + _=sd*sqrt(-2*ln(#.j))*cos(2*pi*#.m)+mean /*use Box-Muller method*/ + #.m=sd*sqrt(-2*ln(#.j))*sin(2*pi*#.m)+mean /*rand # must be 0──�1.*/ + #.j=_ + end /*j*/ +say ' new mean=' mean() +say 'new standard deviation=' stddev() +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────subroutines─────────────────────────*/ +mean: _=0; do k=1 for n; _=_+#.k; end; return _/n +stddev: _avg=mean(); _=0; do k=1 for n; _=_+(#.k-_avg)**2; end; return sqrt(_/n) +e: e=2.7182818284590452353602874713526624977572470936999595749669676277240766303535; return e +pi: pi=3.1415926535897932384626433832795028841971693993751058209749445923078164062862; return pi +r2r: return arg(1)//(2*pi()) +sqrt: procedure;parse arg x; if x=0 then return 0; d=digits(); numeric digits 11; g=.sqrtGuess() + do j=0 while p>9; m.j=p; p=p%2+1; end; do k=j+5 to 0 by -1; if m.k>11 then numeric digits m.k + g=.5*(g+x/g); end; numeric digits d; return g/1 +.sqrtGuess: numeric form; m.=11; p=d+d%4+2 + parse value format(x,2,1,,0) 'E0' with g 'E' _ .; return g*.5'E'_%2 +cos: procedure; arg x; x=r2r(x); a=abs(x); numeric fuzz min(9,digits()-9); if a=pi() then return -1 + if a=pi()/2|a=2*pi() then return 0;if a=pi()/3 then return .5;if a=2*pi()/3 then return -.5;return .sincos(1,1,-1) +sin: procedure; arg x; x=r2r(x); numeric fuzz min(5,digits()-3); if abs(x)=pi() then return 0; return .sincos(x,x,1) +.sincos:parse arg z,_,i; x=x*x; p=z; do k=2 by 2; _=-_*x/(k*(k+i)); z=z+_; if z=p then leave; p=z; end; return z +ln: procedure; parse arg x,f; call e; ig=x>1.5; is=1-2*(ig\==1); ii=0; xx=x; return .ln_comp() +.ln_comp: do while ig&xx>1.5|\ig&xx<.5;_=e;do k=-1;iz=xx*_**-is;if k>=0&(ig&iz<1|\ig&iz>.5) then leave;_=_*_;izz=iz;end + xx=izz;ii=ii+is*2**k;end;x=x*e**-ii-1;z=0;_=-1;p=z;do k=1;_=-_*x;z=z+_/k;if z=p then leave;p=z;end;return z+ii diff --git a/Task/Random-numbers/Ruby/random-numbers.rb b/Task/Random-numbers/Ruby/random-numbers.rb new file mode 100644 index 0000000000..f0494ca05d --- /dev/null +++ b/Task/Random-numbers/Ruby/random-numbers.rb @@ -0,0 +1 @@ +Array.new(1000) { 1 + Math.sqrt(-2 * Math.log(rand)) * Math.cos(2 * Math::PI * rand) } diff --git a/Task/Random-numbers/Run-BASIC/random-numbers.run b/Task/Random-numbers/Run-BASIC/random-numbers.run new file mode 100644 index 0000000000..115c55f885 --- /dev/null +++ b/Task/Random-numbers/Run-BASIC/random-numbers.run @@ -0,0 +1,5 @@ +dim a(1000) +pi = 22/7 +for i = 1 to 1000 + a( i) = 1 + .5 * (sqr(-2 * log(rnd(0))) * cos(2 * pi * rnd(0))) +next i diff --git a/Task/Random-numbers/Sather/random-numbers.sa b/Task/Random-numbers/Sather/random-numbers.sa new file mode 100644 index 0000000000..c2cb9746b9 --- /dev/null +++ b/Task/Random-numbers/Sather/random-numbers.sa @@ -0,0 +1,19 @@ +class MAIN is + main is + a:ARRAY{FLTD} := #(1000); + i:INT; + + RND::seed(2010); + loop i := 1.upto!(1000) - 1; + a[i] := 1.0d + 0.5d * RND::standard_normal; + end; + + -- testing the distribution + mean ::= a.reduce(bind(_.plus(_))) / a.size.fltd; + #OUT + "mean " + mean + "\n"; + a.map(bind(_.minus(mean))); + a.map(bind(_.pow(2.0d))); + dev ::= (a.reduce(bind(_.plus(_))) / a.size.fltd).sqrt; + #OUT + "dev " + dev + "\n"; + end; +end; diff --git a/Task/Random-numbers/Scala/random-numbers.scala b/Task/Random-numbers/Scala/random-numbers.scala new file mode 100644 index 0000000000..0483fa3122 --- /dev/null +++ b/Task/Random-numbers/Scala/random-numbers.scala @@ -0,0 +1 @@ +List.fill(1000)(1.0 + 0.5 * scala.util.Random.nextGaussian) diff --git a/Task/Random-numbers/Scheme/random-numbers.ss b/Task/Random-numbers/Scheme/random-numbers.ss new file mode 100644 index 0000000000..3b682bd99f --- /dev/null +++ b/Task/Random-numbers/Scheme/random-numbers.ss @@ -0,0 +1,47 @@ +; linear congruential generator given in C99 section 7.20.2.1 +(define ((c-rand seed)) (set! seed (remainder (+ (* 1103515245 seed) 12345) 2147483648)) (quotient seed 65536)) + +; uniform real numbers in open interval (0, 1) +(define (unif-rand seed) (let ((r (c-rand seed))) (lambda () (/ (+ (r) 1) 32769.0)))) + +; Box-Muller method to generate normal distribution +(define (normal-rand unif m s) +(let ((? #t) (! 0.0) (twopi (* 2.0 (acos -1.0)))) +(lambda () + (set! ? (not ?)) + (if ? ! + (let ((a (sqrt (* -2.0 (log (unif))))) (b (* twopi (unif)))) + (set! ! (+ m (* s a (sin b)))) + (+ m (* s a (cos b)))))))) + +(define rnorm (normal-rand (unif-rand 0) 1.0 0.5)) + +; auxiliary function to get a list of 'n random numbers from generator 'r +(define (rand-list r n) = (if (zero? n) '() (cons (r) (rand-list r (- n 1))))) + +(define v (rand-list rnorm 1000)) + +v +#| +(-0.27965824722565835 + -0.8870860825789542 + 0.6499618744638194 + 0.31336141955110863 + ... + 0.5648743998193049 + 0.8282656735558756 + 0.6399951934564637 + 0.7699535302478072) +|# + +; check mean and standard deviation +(define (mean-sdev v) +(let loop ((v v) (a 0) (b 0) (n 0)) +(if (null? v) + (let ((mean (/ a n))) + (list mean (sqrt (/ (- b (* n mean mean)) (- n 1))))) + (let ((x (car v))) + (loop (cdr v) (+ a x) (+ b (* x x)) (+ n 1)))))) + +(mean-sdev v) +; (0.9562156817697293 0.5097087109575911) diff --git a/Task/Random-numbers/Seed7/random-numbers.seed7 b/Task/Random-numbers/Seed7/random-numbers.seed7 new file mode 100644 index 0000000000..fce404b67f --- /dev/null +++ b/Task/Random-numbers/Seed7/random-numbers.seed7 @@ -0,0 +1,25 @@ +$ include "seed7_05.s7i"; + include "float.s7i"; + include "math.s7i"; + +const func float: frand is func # Uniform distribution, (0..1] + result + var float: frand is 0.0; + begin + repeat + frand := rand(0.0, 1.0); + until frand <> 0.0; + end func; + +const func float: randomNormal is # Normal distribution, centered on 0, std dev 1 + return sqrt(-2.0 * log(frand)) * cos(2.0 * PI * frand); + +const proc: main is func + local + var integer: i is 0; + var array float: rands is 1000 times 0.0; + begin + for i range 1 to length(rands) do + rands[i] := 1.0 + 0.5 * randomNormal; + end for; + end func; diff --git a/Task/Random-numbers/Standard-ML/random-numbers-1.ml b/Task/Random-numbers/Standard-ML/random-numbers-1.ml new file mode 100644 index 0000000000..47d1a885e7 --- /dev/null +++ b/Task/Random-numbers/Standard-ML/random-numbers-1.ml @@ -0,0 +1,5 @@ +val seed = 0w42; +val gen = Rand.mkRandom seed; +fun random_gaussian () = + 1.0 + Math.sqrt (~2.0 * Math.ln (Rand.norm (gen ()))) * Math.cos (2.0 * Math.pi * Rand.norm (gen ())); +val a = List.tabulate (1000, fn _ => random_gaussian ()); diff --git a/Task/Random-numbers/Standard-ML/random-numbers-2.ml b/Task/Random-numbers/Standard-ML/random-numbers-2.ml new file mode 100644 index 0000000000..93dc79e931 --- /dev/null +++ b/Task/Random-numbers/Standard-ML/random-numbers-2.ml @@ -0,0 +1,5 @@ +val seed = (47,42); +val gen = Random.rand seed; +fun random_gaussian () = + 1.0 + Math.sqrt (~2.0 * Math.ln (Random.randReal gen)) * Math.cos (2.0 * Math.pi * Random.randReal gen); +val a = List.tabulate (1000, fn _ => random_gaussian ()); diff --git a/Task/Random-numbers/Tcl/random-numbers.tcl b/Task/Random-numbers/Tcl/random-numbers.tcl new file mode 100644 index 0000000000..e87d66fb98 --- /dev/null +++ b/Task/Random-numbers/Tcl/random-numbers.tcl @@ -0,0 +1,11 @@ +package require Tcl 8.5 +variable ::pi [expr acos(0)] +proc ::tcl::mathfunc::nrand {} { + expr {sqrt(-2*log(rand())) * cos(2*$::pi*rand())} +} + +set mean 1.0 +set stddev 0.5 +for {set i 0} {$i < 1000} {incr i} { + lappend result [expr {$mean + $stddev*nrand()}] +} diff --git a/Task/Random-numbers/Ursala/random-numbers.ursala b/Task/Random-numbers/Ursala/random-numbers.ursala new file mode 100644 index 0000000000..591be2eba6 --- /dev/null +++ b/Task/Random-numbers/Ursala/random-numbers.ursala @@ -0,0 +1,14 @@ +#import nat +#import flo + +pop_stats("mu","sigma") = plus/*"mu"+ times/*"sigma"+ Z*+ iota + +sample_stats("mu","sigma") = plus^*D(minus/"mu"+ mean,~&)+ vid^*D(div\"sigma"+ stdev,~&)+ Z*+ iota + +#cast %eWL + +test = + +^(mean,stdev)* < + pop_stats(1.,0.5) 1000, + sample_stats(1.,0.5) 1000> diff --git a/Task/Random-numbers/Yorick/random-numbers.yorick b/Task/Random-numbers/Yorick/random-numbers.yorick new file mode 100644 index 0000000000..9d2e2d1614 --- /dev/null +++ b/Task/Random-numbers/Yorick/random-numbers.yorick @@ -0,0 +1,3 @@ +func random_normal(count) { + return sqrt(-2*log(random(count))) * cos(2*pi*random(count)); +} diff --git a/Task/Random-numbers/ZX-Spectrum-Basic/random-numbers.zx b/Task/Random-numbers/ZX-Spectrum-Basic/random-numbers.zx new file mode 100644 index 0000000000..c1dc7c9b8a --- /dev/null +++ b/Task/Random-numbers/ZX-Spectrum-Basic/random-numbers.zx @@ -0,0 +1,6 @@ +10 RANDOMIZE 0 : REM seeds random number generator based on uptime +20 DIM a(1000) +30 CLS +40 FOR i = 1 TO 1000 +50 LET a(i) = 1 + SQR(-2 * LN(RND)) * COS(2 * PI * RND) +60 NEXT i diff --git a/Task/Range-expansion/0DESCRIPTION b/Task/Range-expansion/0DESCRIPTION new file mode 100644 index 0000000000..933e0b8069 --- /dev/null +++ b/Task/Range-expansion/0DESCRIPTION @@ -0,0 +1,8 @@ +{{:Range extraction/Format}} + +;The task +Expand the range description: +: -6,-3--1,3-5,7-11,14,15,17-20 +Note that the second element above, is the '''range from minus 3 to ''minus'' 1'''. + +C.f. [[Range extraction]] diff --git a/Task/Range-expansion/ALGOL-68/range-expansion.alg b/Task/Range-expansion/ALGOL-68/range-expansion.alg new file mode 100644 index 0000000000..a188b531f9 --- /dev/null +++ b/Task/Range-expansion/ALGOL-68/range-expansion.alg @@ -0,0 +1,39 @@ +MODE YIELDINT = PROC(INT)VOID; + +MODE RANGE = STRUCT(INT lwb, upb); +MODE RANGEINT = UNION(RANGE, INT); + +OP SIZEOF = ([]RANGEINT list)INT: ( +# determine the length of the output array # + INT upb := LWB list - 1; + FOR key FROM LWB list TO UPB list DO + CASE list[key] IN + (RANGE value): upb +:= upb OF value - lwb OF value + 1, + (INT): upb +:= 1 + ESAC + OD; + upb +); + +PROC gen range expand = ([]RANGEINT list, YIELDINT yield)VOID: + FOR key FROM LWB list TO UPB list DO + CASE list[key] IN + (RANGE range): FOR value FROM lwb OF range TO upb OF range DO yield(value) OD, + (INT int): yield(int) + ESAC + OD; + +PROC range expand = ([]RANGEINT list)[]INT: ( + [LWB list: LWB list + SIZEOF list - 1]INT out; + INT upb := LWB out - 1; +# FOR INT value IN # gen range expand(list, # ) DO # +## (INT value)VOID: + out[upb +:= 1] := value +# OD #); + out +); + +test:( + []RANGEINT list = (-6, RANGE(-3, -1), RANGE(3, 5), RANGE(7, 11), 14, 15, RANGE(17, 20)); + print((range expand(list), new line)) +) diff --git a/Task/Range-expansion/Ada/range-expansion.ada b/Task/Range-expansion/Ada/range-expansion.ada new file mode 100644 index 0000000000..d256af25e3 --- /dev/null +++ b/Task/Range-expansion/Ada/range-expansion.ada @@ -0,0 +1,66 @@ +with Ada.Text_IO; use Ada.Text_IO; +procedure Test_Range_Expansion is + type Sequence is array (Positive range <>) of Integer; + function Expand (Text : String) return Sequence is + To : Integer := Text'First; + Count : Natural := 0; + Low : Integer; + function Get return Integer is + From : Integer := To; + begin + if Text (To) = '-' then + To := To + 1; + end if; + while To <= Text'Last loop + case Text (To) is + when ',' | '-' => exit; + when others => To := To + 1; + end case; + end loop; + return Integer'Value (Text (From..To - 1)); + end Get; + begin + while To <= Text'Last loop -- Counting items of the list + Low := Get; + if To > Text'Last or else Text (To) = ',' then + Count := Count + 1; + else + To := To + 1; + Count := Count + Get - Low + 1; + end if; + To := To + 1; + end loop; + return Result : Sequence (1..Count) do + Count := 0; + To := Text'First; + while To <= Text'Last loop -- Filling the list + Low := Get; + if To > Text'Last or else Text (To) = ',' then + Count := Count + 1; + Result (Count) := Low; + else + To := To + 1; + for Item in Low..Get loop + Count := Count + 1; + Result (Count) := Item; + end loop; + end if; + To := To + 1; + end loop; + end return; + end Expand; + procedure Put (S : Sequence) is + First : Boolean := True; + begin + for I in S'Range loop + if First then + First := False; + else + Put (','); + end if; + Put (Integer'Image (S (I))); + end loop; + end Put; +begin + Put (Expand ("-6,-3--1,3-5,7-11,14,15,17-20")); +end Test_Range_Expansion; diff --git a/Task/Range-expansion/AutoHotkey/range-expansion.ahk b/Task/Range-expansion/AutoHotkey/range-expansion.ahk new file mode 100644 index 0000000000..146a28290d --- /dev/null +++ b/Task/Range-expansion/AutoHotkey/range-expansion.ahk @@ -0,0 +1,9 @@ +msgbox % expand("-6,-3--1,3-5,7-11,14,15,17-20") + +expand( range ) { + p := 0 + while p := RegExMatch(range, "\s*(-?\d++)(?:\s*-\s*(-?\d++))?", f, p+1+StrLen(f)) + loop % (f2 ? f2-f1 : 0) + 1 + ret .= "," (A_Index-1) + f1 + return SubStr(ret, 2) +} diff --git a/Task/Range-expansion/BBC-BASIC/range-expansion.bbc b/Task/Range-expansion/BBC-BASIC/range-expansion.bbc new file mode 100644 index 0000000000..f116256f8c --- /dev/null +++ b/Task/Range-expansion/BBC-BASIC/range-expansion.bbc @@ -0,0 +1,23 @@ + PRINT FNrangeexpand("-6,-3--1,3-5,7-11,14,15,17-20") + END + + DEF FNrangeexpand(r$) + LOCAL i%, j%, k%, t$ + REPEAT + i% = INSTR(r$, "-", i%+1) + IF i% THEN + j% = i% + WHILE MID$(r$,j%-1,1)<>"," AND j%<>1 + j% -= 1 + ENDWHILE + IF i%>j% IF MID$(r$,j%,i%-j%)<>STRING$(i%-j%," ") THEN + t$ = "" + FOR k% = VALMID$(r$,j%) TO VALMID$(r$,i%+1)-1 + t$ += STR$(k%) + "," + NEXT + r$ = LEFT$(r$,j%-1) + t$ + MID$(r$,i%+1) + i% = j% + LEN(t$) + 2 + ENDIF + ENDIF + UNTIL i% = 0 + = r$ diff --git a/Task/Range-expansion/Bracmat/range-expansion.bracmat b/Task/Range-expansion/Bracmat/range-expansion.bracmat new file mode 100644 index 0000000000..dd7425cc48 --- /dev/null +++ b/Task/Range-expansion/Bracmat/range-expansion.bracmat @@ -0,0 +1,15 @@ + ( expandRanges + = a b L + . @( !arg + : (#(?a:?b)|#?a "-" #?b) + (:?L|"," [%(expandRanges$!sjt:?L)) + ) + & whl + ' ( (!L:&!b|(!b,!L)) + : ?L + & -1+!b:~ +#include +#include +#include +#include + +// parse a list of numbers with ranges +// +// arguments: +// is: the stream to parse +// out: the output iterator the parsed list is written to. +// +// returns true if the parse was successful. false otherwise +template + bool parse_number_list_with_ranges(std::istream& is, OutIter out) +{ + int number; + // the list always has to start with a number + while (is >> number) + { + *out++ = number; + + char c; + if (is >> c) + switch(c) + { + case ',': + continue; + case '-': + { + int number2; + if (is >> number2) + { + if (number2 < number) + return false; + while (number < number2) + *out++ = ++number; + char c2; + if (is >> c2) + if (c2 == ',') + continue; + else + return false; + else + return is.eof(); + } + else + return false; + } + default: + return is.eof(); + } + else + return is.eof(); + } + // if we get here, something went wrong (otherwise we would have + // returned from inside the loop) + return false; +} + +int main() +{ + std::istringstream example("-6,-3--1,3-5,7-11,14,15,17-20"); + std::deque v; + bool success = parse_number_list_with_ranges(example, std::back_inserter(v)); + if (success) + { + std::copy(v.begin(), v.end()-1, + std::ostream_iterator(std::cout, ",")); + std::cout << v.back() << "\n"; + } + else + std::cout << "an error occured."; +} diff --git a/Task/Range-expansion/C/range-expansion.c b/Task/Range-expansion/C/range-expansion.c new file mode 100644 index 0000000000..9b869e288a --- /dev/null +++ b/Task/Range-expansion/C/range-expansion.c @@ -0,0 +1,78 @@ +#include +#include +#include + +/* BNFesque + rangelist := (range | number) [',' rangelist] + range := number '-' number */ + +int get_list(const char *, char **); +int get_rnge(const char *, char **); + +/* parser only parses; what to do with parsed items is up to +* the add_number and and_range functions */ +void add_number(int x); +int add_range(int x, int y); + +#define skip_space while(isspace(*s)) s++ +#define get_number(x, s, e) (x = strtol(s, e, 10), *e != s) +int get_list(const char *s, char **e) +{ + int x; + while (1) { + skip_space; + if (!get_rnge(s, e) && !get_number(x, s, e)) break; + s = *e; + + skip_space; + if ((*s) == '\0') { putchar('\n'); return 1; } + if ((*s) == ',') { s++; continue; } + break; + } + *(const char **)e = s; + printf("\nSyntax error at %s\n", s); + return 0; +} + +int get_rnge(const char *s, char **e) +{ + int x, y; + char *ee; + if (!get_number(x, s, &ee)) return 0; + s = ee; + + skip_space; + if (*s != '-') { + *(const char **)e = s; + return 0; + } + s++; + if(!get_number(y, s, e)) return 0; + return add_range(x, y); +} + +void add_number(int x) +{ + printf("%d ", x); +} + +int add_range(int x, int y) +{ + if (y <= x) return 0; + while (x <= y) printf("%d ", x++); + return 1; +} + +int main() +{ + char *end; + + /* this is correct */ + if (get_list("-6,-3--1,3-5,7-11,14,15,17-20", &end)) puts("Ok"); + + /* this is not. note the subtle error: "-6 -3" is parsed + * as range(-6, 3), so synax error comes after that */ + get_list("-6 -3--1,3-5,7-11,14,15,17-20", &end); + + return 0; +} diff --git a/Task/Range-expansion/Clojure/range-expansion.clj b/Task/Range-expansion/Clojure/range-expansion.clj new file mode 100644 index 0000000000..d77149bcce --- /dev/null +++ b/Task/Range-expansion/Clojure/range-expansion.clj @@ -0,0 +1,24 @@ +(defn split [s sep] + (defn skipFirst [[x & xs :as s]] + (cond (empty? s) [nil nil] + (= x sep) [x xs] + true [nil s])) + (loop [lst '(), s s] + (if (empty? s) (reverse lst) + (let [[hd trunc] (skipFirst s) + [word news] (split-with #(not= % sep) trunc) + cWord (cons hd word)] + (recur (cons (apply str cWord) lst) + (apply str (rest news))))))) + +(defn parseRange [[x & xs :as s]] + (if (some #(= % \-) xs) + (let [[r0 r1] (split s \-)] + (range (read-string r0) (inc (read-string r1)))) + (list (read-string (str s)))))) + +(defn rangeexpand [s] + (flatten (map parseRange (split s \,)))) + +> (rangeexpand "-6,-3--1,3-5,7-11,14,15,17-20") +(-6 -3 -2 -1 3 4 5 7 8 9 10 11 14 15 17 18 19 20) diff --git a/Task/Range-expansion/Common-Lisp/range-expansion.lisp b/Task/Range-expansion/Common-Lisp/range-expansion.lisp new file mode 100644 index 0000000000..5138fbe956 --- /dev/null +++ b/Task/Range-expansion/Common-Lisp/range-expansion.lisp @@ -0,0 +1,23 @@ +(defun expand-ranges (string) + (loop + with prevnum = nil + for idx = 0 then (1+ nextidx) + for (number nextidx) = (multiple-value-list + (parse-integer string + :start idx :junk-allowed t)) + append (cond + (prevnum + (prog1 + (loop for i from prevnum to number + collect i) + (setf prevnum nil))) + ((and (< nextidx (length string)) + (char= (aref string nextidx) #\-)) + (setf prevnum number) + nil) + (t + (list number))) + while (< nextidx (length string)))) + +CL-USER> (expand-ranges "-6,-3--1,3-5,7-11,14,15,17-20") +(-6 -3 -2 -1 3 4 5 7 8 9 10 11 14 15 17 18 19 20) diff --git a/Task/Range-expansion/D/range-expansion.d b/Task/Range-expansion/D/range-expansion.d new file mode 100644 index 0000000000..add4b55202 --- /dev/null +++ b/Task/Range-expansion/D/range-expansion.d @@ -0,0 +1,16 @@ +import std.stdio, std.regex, std.string, std.conv, std.range; + +int[] rangeExpand(in string txt) /*pure nothrow*/ { + typeof(return) result; + + foreach (r; std.string.split(txt, ",")) { + const m = r.match(r"^(-?\d+)(-?(-?\d+))?$").captures.array; + result ~= m[2].empty ? [m[1].to!int] : + iota(m[1].to!int, m[3].to!int + 1).array; + } + return result; +} + +void main() { + "-6,-3--1,3-5,7-11,14,15,17-20".rangeExpand.writeln; +} diff --git a/Task/Range-expansion/Go/range-expansion.go b/Task/Range-expansion/Go/range-expansion.go new file mode 100644 index 0000000000..206b04204d --- /dev/null +++ b/Task/Range-expansion/Go/range-expansion.go @@ -0,0 +1,64 @@ +package main + +import ( + "fmt" + "strconv" + "strings" +) + +const input = "-6,-3--1,3-5,7-11,14,15,17-20" + +func main() { + fmt.Println("range:", input) + var r []int + var last int + for _, part := range strings.Split(input, ",") { + if i := strings.Index(part[1:], "-"); i == -1 { + n, err := strconv.Atoi(part) + if err != nil { + fmt.Println(err) + return + } + if len(r) > 0 { + if last == n { + fmt.Println("duplicate value:", n) + return + } else if last > n { + fmt.Println("values not ordered:", last, ">", n) + return + } + } + r = append(r, n) + last = n + } else { + n1, err := strconv.Atoi(part[:i+1]) + if err != nil { + fmt.Println(err) + return + } + n2, err := strconv.Atoi(part[i+2:]) + if err != nil { + fmt.Println(err) + return + } + if n2 < n1+2 { + fmt.Println("invalid range:", part) + return + } + if len(r) > 0 { + if last == n1 { + fmt.Println("duplicate value:", n1) + return + } else if last > n1 { + fmt.Println("values not ordered:", last, ">", n1) + return + } + } + for i = n1; i <= n2; i++ { + r = append(r, i) + } + last = n2 + } + } + fmt.Println("expanded:", r) +} diff --git a/Task/Range-expansion/Groovy/range-expansion-1.groovy b/Task/Range-expansion/Groovy/range-expansion-1.groovy new file mode 100644 index 0000000000..2a2efa2db7 --- /dev/null +++ b/Task/Range-expansion/Groovy/range-expansion-1.groovy @@ -0,0 +1,3 @@ +def expandRanges = { compressed -> + Eval.me('['+compressed.replaceAll(~/(\d)-/, '$1..')+']').flatten().toString()[1..-2] +} diff --git a/Task/Range-expansion/Groovy/range-expansion-2.groovy b/Task/Range-expansion/Groovy/range-expansion-2.groovy new file mode 100644 index 0000000000..b7526db049 --- /dev/null +++ b/Task/Range-expansion/Groovy/range-expansion-2.groovy @@ -0,0 +1,2 @@ +def s = '-6,-3--1,3-5,7-11,14,15,17-20' +println (expandRanges(s)) diff --git a/Task/Range-expansion/Haskell/range-expansion-1.hs b/Task/Range-expansion/Haskell/range-expansion-1.hs new file mode 100644 index 0000000000..fd53b9548a --- /dev/null +++ b/Task/Range-expansion/Haskell/range-expansion-1.hs @@ -0,0 +1,2 @@ +> expandRange "-6,-3--1,3-5,7-11,14,15,17-20" +[-6,-3,-2,-1,3,4,5,7,8,9,10,11,14,15,17,18,19,20] diff --git a/Task/Range-expansion/Haskell/range-expansion-2.hs b/Task/Range-expansion/Haskell/range-expansion-2.hs new file mode 100644 index 0000000000..4f435f0054 --- /dev/null +++ b/Task/Range-expansion/Haskell/range-expansion-2.hs @@ -0,0 +1,10 @@ +expandRange :: String -> [Int] +expandRange = concatMap f . split ',' + where f str@(c : cs) | '-' `elem` cs = [read (c : a) .. read b] + | otherwise = [read str] + where (a, _ : b) = break (== '-') cs + +split :: Eq a => a -> [a] -> [[a]] +split delim [] = [] +split delim l = a : split delim (dropWhile (== delim) b) + where (a, b) = break (== delim) l diff --git a/Task/Range-expansion/Haskell/range-expansion-3.hs b/Task/Range-expansion/Haskell/range-expansion-3.hs new file mode 100644 index 0000000000..3f95890d05 --- /dev/null +++ b/Task/Range-expansion/Haskell/range-expansion-3.hs @@ -0,0 +1,16 @@ +import Control.Monad +import Text.ParserCombinators.Parsec + +expandRange :: String -> [Int] +expandRange s = case parse rangeParser "" s of Right l -> l + +rangeParser :: Parser [Int] +rangeParser = liftM concat $ item `sepBy` char ',' + where item = do + n1 <- num + n2 <- option n1 $ char '-' >> num + return [n1 .. n2] + num :: Parser Int + num = liftM read $ liftM2 (++) + (option "" $ string "-") + (many1 digit) diff --git a/Task/Range-expansion/Icon/range-expansion.icon b/Task/Range-expansion/Icon/range-expansion.icon new file mode 100644 index 0000000000..f2e9626847 --- /dev/null +++ b/Task/Range-expansion/Icon/range-expansion.icon @@ -0,0 +1,25 @@ +procedure main() +s := "-6,-3--1,3-5,7-11,14,15,17-20" +write("Input string := ",s) +write("Expanded list := ", list2string(range_expand(s)) | "FAILED") +end + +procedure range_expand(s) #: return list of integers extracted from an ordered string representation +local R,low,high +R := [] + +s ? until pos(0) do { + put(R,low := integer(tab(upto(',-')|0))| fail) # get lower bound + if ="-" || (high := integer(tab(find(",")|0))|fail) then + until low = high do put(R,low +:= 1) # find range + ="," + } +return R +end + +procedure list2string(L) #: helper function to convert a list to a string +local s + + every (s := "[ ") ||:= !L || " " + return s || "]" +end diff --git a/Task/Range-expansion/J/range-expansion-1.j b/Task/Range-expansion/J/range-expansion-1.j new file mode 100644 index 0000000000..ffac8067e9 --- /dev/null +++ b/Task/Range-expansion/J/range-expansion-1.j @@ -0,0 +1,6 @@ +require'strings' +to=: [ + i.@>:@-~ +num=: _&". +normaliz=: rplc&(',-';',_';'--';'-_')@,~&',' +subranges=:<@(to/)@(num;._2)@,&'-';._1 +rngexp=: ;@subranges@normaliz diff --git a/Task/Range-expansion/J/range-expansion-2.j b/Task/Range-expansion/J/range-expansion-2.j new file mode 100644 index 0000000000..47a0247fc0 --- /dev/null +++ b/Task/Range-expansion/J/range-expansion-2.j @@ -0,0 +1,2 @@ + rngexp '-6,-3--1,3-5,7-11,14,15,17-20' +_6 _3 _2 _1 3 4 5 7 8 9 10 11 14 15 17 18 19 20 diff --git a/Task/Range-expansion/Java/range-expansion.java b/Task/Range-expansion/Java/range-expansion.java new file mode 100644 index 0000000000..13ef108949 --- /dev/null +++ b/Task/Range-expansion/Java/range-expansion.java @@ -0,0 +1,66 @@ +import java.util.*; +import java.util.regex.*; + +class Range implements Enumeration { + private int clower, cupper; + private int value; + private boolean inrange; + private Scanner ps = null; + private String ss; + + private static String del = "\\s*,\\s*"; + + public Range(String s) { + ss = s; + reset(); + } + + public boolean hasMoreElements() { + return (inrange && (value >= clower && value <= cupper)) || ps.hasNext(); + } + + public Object nextElement() throws NoSuchElementException { + if (!hasMoreElements()) + throw new NoSuchElementException(); + if (inrange && (value >= clower && value <= cupper)) { + value++; + return value-1; + } + inrange = false; + String n = ps.next(); + if (n.matches("[+-]?\\d+-[+-]?\\d+")) { + Scanner ls = new Scanner(n); + ls.findInLine("([+-]?\\d+)-([+-]?\\d+)"); + MatchResult r = ls.match(); + clower = Integer.parseInt(r.group(1)); + cupper = Integer.parseInt(r.group(2)); + value = clower+1; + inrange = true; + ls.close(); + return clower; + } + return Integer.parseInt(n); + } + + public void reset() { + if (ps != null) + ps.close(); + ps = new Scanner(ss).useDelimiter(del); + inrange = false; + } + + protected void finalize() throws Throwable { + ps.close(); + super.finalize(); + } +} + +class rangexp { + public static void main(String[] args) { + Range r = new Range("-6,-3--1,3-5,7-11,14,15,17-20"); + while (r.hasMoreElements()) { + System.out.print(r.nextElement() + " "); + } + System.out.println(); + } +} diff --git a/Task/Range-expansion/JavaScript/range-expansion.js b/Task/Range-expansion/JavaScript/range-expansion.js new file mode 100644 index 0000000000..16adf06892 --- /dev/null +++ b/Task/Range-expansion/JavaScript/range-expansion.js @@ -0,0 +1,34 @@ +#!/usr/bin/env js + +function main() { + print(rangeExpand('-6,-3--1,3-5,7-11,14,15,17-20')); +} + +function rangeExpand(rangeExpr) { + + function getFactors(term) { + var matches = term.match(/(-?[0-9]+)-(-?[0-9]+)/); + if (!matches) return {first:Number(term)}; + return {first:Number(matches[1]), last:Number(matches[2])}; + } + + function expandTerm(term) { + var factors = getFactors(term); + if (factors.length < 2) return [factors.first]; + var range = []; + for (var n = factors.first; n <= factors.last; n++) { + range.push(n); + } + return range; + } + + var result = []; + var terms = rangeExpr.split(/,/); + for (var t in terms) { + result = result.concat(expandTerm(terms[t])); + } + + return result; +} + +main(); diff --git a/Task/Range-expansion/K/range-expansion-1.k b/Task/Range-expansion/K/range-expansion-1.k new file mode 100644 index 0000000000..304c4b8cd4 --- /dev/null +++ b/Task/Range-expansion/K/range-expansion-1.k @@ -0,0 +1,5 @@ +grp : {1_'(&x=*x)_ x:",",x} +pos : {:[3=l:#p:&"-"=x;0,p@1;2=l;p;0=*p;,0;0,p]} +conv: 0${(x;1_ y)}/'{(pos x)_ x}' +expd: {,/@[x;&2=#:'x;{(*x)+!1+,/-':x}]} +rnge: {expd@conv grp x} diff --git a/Task/Range-expansion/K/range-expansion-2.k b/Task/Range-expansion/K/range-expansion-2.k new file mode 100644 index 0000000000..d9c59b20b4 --- /dev/null +++ b/Task/Range-expansion/K/range-expansion-2.k @@ -0,0 +1,2 @@ + rnge "-6,-3--1,3-5,7-11,14,15,17-20" +-6 -3 -2 -1 3 4 5 7 8 9 10 11 14 15 17 18 19 20 diff --git a/Task/Range-expansion/Liberty-BASIC/range-expansion.liberty b/Task/Range-expansion/Liberty-BASIC/range-expansion.liberty new file mode 100644 index 0000000000..21351f6f7b --- /dev/null +++ b/Task/Range-expansion/Liberty-BASIC/range-expansion.liberty @@ -0,0 +1,23 @@ +print ExpandRange$( "-6,-3--1,3-5,7-11,14,15,17-20") +end + +function ExpandRange$( compressed$) + for i = 1 to ItemCount( compressed$, ",") + item$ = word$( compressed$, i, ",") + dash = instr( item$, "-", 2) 'dash that is not the first character, is a separator + if dash then + for k = val( left$( item$, dash - 1)) to val( mid$( item$, dash + 1)) + ExpandRange$ = ExpandRange$ + str$( k) + "," + next k + else + ExpandRange$ = ExpandRange$ + item$ + "," + end if + next i + ExpandRange$ = left$( ExpandRange$, len( ExpandRange$) - 1) +end function + +function ItemCount( list$, separator$) + while word$(list$, ItemCount + 1, separator$) <> "" + ItemCount = ItemCount + 1 + wend +end function diff --git a/Task/Range-expansion/MUMPS/range-expansion.mumps b/Task/Range-expansion/MUMPS/range-expansion.mumps new file mode 100644 index 0000000000..16fd1b93bb --- /dev/null +++ b/Task/Range-expansion/MUMPS/range-expansion.mumps @@ -0,0 +1,10 @@ +RANGEXP(X) ;Integer range expansion + NEW Y,I,J,X1,H SET Y="" + FOR I=1:1:$LENGTH(X,",") DO + .S X1=$PIECE(X,",",I) FOR Q:$EXTRACT(X1)'=" " S X1=$EXTRACT(X1,2,$LENGTH(X1)) ;clean up leading spaces + .SET H=$FIND(X1,"-")-1 + .IF H=1 SET H=$FIND(X1,"-",(H+1))-1 ;If the first value is negative ignore that "-" + .IF H<0 SET Y=$SELECT($LENGTH(Y)=0:Y_X1,1:Y_","_X1) + .IF '(H<0) FOR J=+$EXTRACT(X1,1,(H-1)):1:+$EXTRACT(X1,(H+1),$LENGTH(X1)) SET Y=$SELECT($LENGTH(Y)=0:J,1:Y_","_J) + KILL I,J,X1,H + QUIT Y diff --git a/Task/Range-expansion/Maple/range-expansion-1.maple b/Task/Range-expansion/Maple/range-expansion-1.maple new file mode 100644 index 0000000000..df238515f8 --- /dev/null +++ b/Task/Range-expansion/Maple/range-expansion-1.maple @@ -0,0 +1,37 @@ +ExpandRanges := proc( s :: string ) + uses StringTools; + local DoOne := proc( input ) + uses StringTools; + local lo, hi, pos; + if IsDigit( input ) or input[ 1 ] = "-" + and IsDigit( input[ 2 .. -1 ] ) then + parse( input ) + else + pos := Search( "--", input ); + if pos > 0 then + lo := input[ 1 .. pos - 1 ]; + hi := input[ 1 + pos .. -1 ]; + elif input[ 1 ] = "-" then + pos := FirstFromLeft( "-", input[ 2 .. -1 ] ); + if pos = 0 then + lo := input; + hi := lo + else + lo := input[ 1 .. pos ]; + hi := input[ 2 + pos .. -1 ]; + end if; + else + pos := FirstFromLeft( "-", input ); + if pos = 0 then + error "incorrect syntax" + end if; + lo := input[ 1 .. pos - 1 ]; + hi := input[ 1 + pos .. -1 ]; + end if; + lo := parse( lo ); + hi := parse( hi ); + seq( lo .. hi ) + end if + end proc: + map( DoOne, map( Trim, Split( s, "," ) ) ) +end proc: diff --git a/Task/Range-expansion/Maple/range-expansion-2.maple b/Task/Range-expansion/Maple/range-expansion-2.maple new file mode 100644 index 0000000000..3d313ce7a7 --- /dev/null +++ b/Task/Range-expansion/Maple/range-expansion-2.maple @@ -0,0 +1,3 @@ +> rng := "-6,-3--1,3-5,7-11,14,15,17-20": +> ExpandRanges( rng ); + [-6, -3, -2, -1, 3, 4, 5, 7, 8, 9, 10, 11, 14, 15, 17, 18, 19, 20] diff --git a/Task/Range-expansion/Maple/range-expansion-3.maple b/Task/Range-expansion/Maple/range-expansion-3.maple new file mode 100644 index 0000000000..c17ba55077 --- /dev/null +++ b/Task/Range-expansion/Maple/range-expansion-3.maple @@ -0,0 +1,3 @@ +> rng := "-6,-3-1,3-5,7-11,14,15,17-20": +> ExpandRanges( rng ); +[-6, -3, -2, -1, 0, 1, 3, 4, 5, 7, 8, 9, 10, 11, 14, 15, 17, 18, 19, 20] diff --git a/Task/Range-expansion/Mathematica/range-expansion.math b/Task/Range-expansion/Mathematica/range-expansion.math new file mode 100644 index 0000000000..7bc06bcbeb --- /dev/null +++ b/Task/Range-expansion/Mathematica/range-expansion.math @@ -0,0 +1,3 @@ +rangeexpand[ rng_ ] := Module[ { step1 }, +step1 = StringSplit[StringReplacePart[rng,"S",StringPosition[ rng,DigitCharacter~~"-"] /. {x_,y_} -> {y,y}],","]; +Flatten@ToExpression/@Quiet@StringReplace[step1,x__~~"S"~~y__->"Range["<>x<>","<>y<>"]"] ] diff --git a/Task/Range-expansion/NetRexx/range-expansion.netrexx b/Task/Range-expansion/NetRexx/range-expansion.netrexx new file mode 100644 index 0000000000..6a789108a1 --- /dev/null +++ b/Task/Range-expansion/NetRexx/range-expansion.netrexx @@ -0,0 +1,30 @@ +/*NetRexx program to expand a range of integers into a list. ************* +* 09.08.2012 Walter Pachl derived from my Rexx version +* Changes: translate(old,' ',',') -> old.translate(' ',',') +* dashpos=pos('-',x,2) -> dashpos=x.pos('-',2) +* Do -> Loop +* Parse Var a x a -> Parse a x a +* Parse Var x ... -> Parse x ... +**********************************************************************/ + + old='-6,-3--1,3-5,7-11,14,15,17-20' /*original list of nums/ranges */ + + Say 'old='old /*show old list of nums/ranges. */ + a=old.translate(' ',',') /*translate commas to blanks */ + new='' /*new list of numbers (so far). */ + + comma='' + Loop While a<>'' /* as long as there is input */ + Parse a x a /* get one element */ + dashpos=x.pos('-',2) /* find position of dash, if any */ + If dashpos>0 Then Do /* element is low-high */ + Parse x low =(dashpos) +1 high /* split the element */ + Loop j=low To high /* output all numbers in range */ + new=new||comma||j /* with separating commas */ + End + End + Else /* element is a number */ + new=new||comma||x /* append (with comma) */ + comma=',' /* from now on use comma */ + End + Say 'new='new /*show the expanded list */ diff --git a/Task/Range-expansion/OCaml/range-expansion.ocaml b/Task/Range-expansion/OCaml/range-expansion.ocaml new file mode 100644 index 0000000000..a0132f3df1 --- /dev/null +++ b/Task/Range-expansion/OCaml/range-expansion.ocaml @@ -0,0 +1,23 @@ +#load "str.cma" + +let range a b = + if b < a then invalid_arg "range"; + let rec aux i acc = + if i = b then List.rev(i::acc) + else aux (succ i) (i::acc) + in + aux a [] + +let parse_piece s = + try Scanf.sscanf s "%d-%d" (fun a b -> range a b) + with _ -> [int_of_string s] + +let range_expand rng = + let ps = Str.split (Str.regexp_string ",") rng in + List.flatten (List.map parse_piece ps) + +let () = + let rng = "-6,-3--1,3-5,7-11,14,15,17-20" in + let exp = range_expand rng in + List.iter (Printf.printf " %d") exp; + print_newline() diff --git a/Task/Range-expansion/Oberon-2/range-expansion.oberon-2 b/Task/Range-expansion/Oberon-2/range-expansion.oberon-2 new file mode 100644 index 0000000000..5c5f0a72a3 --- /dev/null +++ b/Task/Range-expansion/Oberon-2/range-expansion.oberon-2 @@ -0,0 +1,235 @@ +MODULE LIVector; +IMPORT SYSTEM; +TYPE + LIPool = POINTER TO ARRAY OF LONGINT; + LIVector*= POINTER TO LIVectorDesc; + LIVectorDesc = RECORD + cap-: INTEGER; + len-: INTEGER; + LIPool: LIPool; + END; + + PROCEDURE (v: LIVector) Init*(cap: INTEGER); + BEGIN + v.cap := cap; + v.len := 0; + NEW(v.LIPool,cap); + END Init; + + PROCEDURE (v: LIVector) Add*(x: LONGINT); + VAR + newLIPool: LIPool; + BEGIN + IF v.len = LEN(v.LIPool^) THEN + (* run out of space *) + v.cap := v.cap + (v.cap DIV 2); + NEW(newLIPool,v.cap); + SYSTEM.MOVE(SYSTEM.ADR(v.LIPool^),SYSTEM.ADR(newLIPool^),v.cap * SIZE(LONGINT)); + v.LIPool := newLIPool + END; + v.LIPool[v.len] := x; + INC(v.len) + END Add; + + PROCEDURE (v: LIVector) At*(idx: INTEGER): LONGINT; + BEGIN + RETURN v.LIPool[idx]; + END At; +END LIVector. + +MODULE LIRange; +IMPORT Out, LIV := LIVector; + +TYPE + Range* = POINTER TO RangeDesc; + RangeDesc = RECORD + l,r: POINTER TO ARRAY 1 OF LONGINT; + END; + + PROCEDURE (r: Range) Init*(); + BEGIN + r.l := NIL; + r.r := NIL; + END Init; + + PROCEDURE (r: Range) IsEmpty*(): BOOLEAN; + BEGIN + RETURN (r.l = NIL) & (r.l = NIL); + END IsEmpty; + + PROCEDURE (r: Range) SetLeft*(v: LONGINT); + BEGIN + IF r.l = NIL THEN NEW(r.l) END; + r.l[0] := v; + END SetLeft; + + PROCEDURE (r: Range) SetRight*(v : LONGINT); + BEGIN + IF r.r = NIL THEN NEW(r.r) END; + r.r[0] := v; + END SetRight; + + PROCEDURE (r: Range) LeftPart*(): BOOLEAN; + BEGIN + RETURN r.l # NIL; + END LeftPart; + + PROCEDURE (r: Range) GetLeft(): LONGINT; + BEGIN + RETURN r.l[0]; + END GetLeft; + + PROCEDURE (r: Range) RightPart*(): BOOLEAN; + BEGIN + RETURN r.l # NIL; + END RightPart; + + PROCEDURE (r: Range) GetRight*(): LONGINT; + BEGIN + RETURN r.r[0]; + END GetRight; + + PROCEDURE (r: Range) Show*(); + BEGIN + Out.Char('('); + IF r.l # NIL THEN Out.LongInt(r.l[0],10) END; + Out.String(" - "); + IF r.r # NIL THEN Out.LongInt(r.r[0],10); END; + Out.Char(')');Out.Ln + END Show; + + PROCEDURE (r: Range) Expand*(VAR liv: LIV.LIVector); + VAR + from, to : LONGINT; + BEGIN + IF r.l # NIL THEN from := r.l[0] ELSE from := 0 END; + IF r.r # NIL THEN to := r.r[0] ELSE to := from END; + WHILE (from <= to) DO + liv.Add(from);INC(from) + END + END Expand; +END LIRange. + +MODULE Splitter; +TYPE + Splitter* = POINTER TO SplitterDesc; + SplitterDesc = RECORD + from: INTEGER; + c: CHAR; + s: POINTER TO ARRAY OF CHAR; + END; + + PROCEDURE (s: Splitter) Init*; + BEGIN + s.c := ','; + s.from := 0; + s.s := NIL; + END Init; + + PROCEDURE (s: Splitter) On*(str: ARRAY OF CHAR); + BEGIN + s.from := 0; + NEW(s.s,LEN(str)); + COPY(str,s.s^) + END On; + + PROCEDURE (s: Splitter) OnWithChar*(str: ARRAY OF CHAR;c: CHAR); + BEGIN + s.from := 0; + s.c := c; + NEW(s.s,LEN(str)); + COPY(str,s.s^) + END OnWithChar; + + PROCEDURE (s: Splitter) Next*(VAR str: ARRAY OF CHAR); + VAR + k : INTEGER; + BEGIN + k := 0; + IF (s.from < LEN(s.s^) - 1) & (s.s[s.from] = 0X) THEN str[0] := 0X END; + WHILE (k < LEN(str) - 1) & (s.from < LEN(s.s^) - 1) & (s.s[s.from] # s.c) DO + str[k] := s.s[s.from]; + INC(k);INC(s.from) + END; + IF k < LEN(str) - 1 THEN str[k] := 0X ELSE str[LEN(str) - 1] := 0X END; + WHILE (s.from < LEN(s.s^) - 1) & (s.s[s.from] # s.c) DO INC(s.from) END; + INC(s.from) + END Next; +END Splitter. + +MODULE ExpandRange; +IMPORT Out, LIV := LIVector, LIR := LIRange, S := Splitter; + +PROCEDURE GetNumberFrom(s: ARRAY OF CHAR; VAR from: INTEGER; VAR done: BOOLEAN): LONGINT; +VAR + d,i: INTEGER; + num,sign: LONGINT; +BEGIN + i := from; num := 0;sign := 1; + CASE s[i] OF + '-': sign := -1;INC(i) + |'+': INC(i); + ELSE + END; + WHILE (i < LEN(s) - 1) & (s[i] >= '0') & (s[i] <= '9') DO + d := ORD(s[i]) - ORD('0'); + num := d + num * 10; + INC(i); + END; + IF i = from THEN done := FALSE ELSE done := TRUE; from := i END; + RETURN sign * num +END GetNumberFrom; + +PROCEDURE GetRange(s: ARRAY OF CHAR): LIR.Range; +VAR + r: LIR.Range; + i: INTEGER; + num: LONGINT; + done: BOOLEAN; +BEGIN + i := 0;NEW(r);r.Init(); + WHILE (i < LEN(s) - 1) & (s[i] = 20X) DO INC(i) END; + (* Left value *) + done := FALSE; + num := GetNumberFrom(s,i,done); + IF ~done THEN RETURN r END; + r.SetLeft(num); + + WHILE (i < LEN(s) - 1) & (s[i] = 20X) DO INC(i) END; + CASE s[i] OF + '-' : INC(i); + | 0X : RETURN r; + ELSE + END; + WHILE (i < LEN(s) - 1) & (s[i] = 20X) DO INC(i) END; + + (* Right Value *) + done := FALSE; + num := GetNumberFrom(s,i,done); + IF ~done THEN RETURN r END; + r.SetRight(num); + RETURN r; +END GetRange; + +VAR + i: INTEGER; + r: LIR.Range; + sp: S.Splitter; + p : ARRAY 128 OF CHAR; + liv: LIV.LIVector; +BEGIN + NEW(sp);sp.Init(); + NEW(liv);liv.Init(128); + + sp.On("-6,-3--1,3-5,7-11,14,15,17-20"); + sp.Next(p); + WHILE (p[0] # 0X) DO + r := GetRange(p); + r.Expand(liv); + sp.Next(p); + END; + FOR i := 0 TO liv.len - 2 DO + Out.LongInt(liv.At(i),3);Out.Char(','); + END; + Out.LongInt(liv.At(liv.len - 1),3);Out.Ln; +END ExpandRange. diff --git a/Task/Range-expansion/Oz/range-expansion-1.oz b/Task/Range-expansion/Oz/range-expansion-1.oz new file mode 100644 index 0000000000..6b4d7cb77a --- /dev/null +++ b/Task/Range-expansion/Oz/range-expansion-1.oz @@ -0,0 +1,30 @@ +declare + fun {Expand RangeDesc} + {Flatten + {Map {ParseDesc RangeDesc} + ExpandRange}} + end + + fun {ParseDesc Txt} + {Map {String.tokens Txt &,} ParseRange} + end + + fun {ParseRange R} + if {Member &- R.2} then + First Second + in + {String.token R.2 &- ?First ?Second} + {String.toInt R.1|First}#{String.toInt Second} + else + Singleton = {String.toInt R} + in + Singleton#Singleton + end + end + + fun {ExpandRange From#To} + {List.number From To 1} + end +in + {System.showInfo + {Value.toVirtualString {Expand "-6,-3--1,3-5,7-11,14,15,17-20"} 100 100}} diff --git a/Task/Range-expansion/Oz/range-expansion-2.oz b/Task/Range-expansion/Oz/range-expansion-2.oz new file mode 100644 index 0000000000..2351ca74c1 --- /dev/null +++ b/Task/Range-expansion/Oz/range-expansion-2.oz @@ -0,0 +1 @@ +[~6 ~3 ~2 ~1 3 4 5 7 8 9 10 11 14 15 17 18 19 20] diff --git a/Task/Range-expansion/PHP/range-expansion.php b/Task/Range-expansion/PHP/range-expansion.php new file mode 100644 index 0000000000..8c3afa8aa4 --- /dev/null +++ b/Task/Range-expansion/PHP/range-expansion.php @@ -0,0 +1,12 @@ +function rangex($str) { + $lst = array(); + foreach (explode(',', $str) as $e) { + if (strpos($e, '-', 1) !== FALSE) { + list($a, $b) = explode('-', substr($e, 1), 2); + $lst = array_merge($lst, range($e[0] . $a, $b)); + } else { + $lst[] = (int) $e; + } + } + return $lst; +} diff --git a/Task/Range-expansion/PL-I/range-expansion.pli b/Task/Range-expansion/PL-I/range-expansion.pli new file mode 100644 index 0000000000..6c53417ac1 --- /dev/null +++ b/Task/Range-expansion/PL-I/range-expansion.pli @@ -0,0 +1,51 @@ +range_expansion: + procedure options (main); + +get_number: + procedure (Number, c, eof); + declare number fixed binary (31), c character (1), eof bit (1) aligned; + declare neg fixed binary (1); + + number = 0; eof = false; + do until (c ^= ' '); + get edit (c) (a(1)); + end; + if c = '-' then do; get edit (c) (a(1)); neg = -1; end; else neg = 1; + do forever; + select (c); + when ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9') + number = number*10 + c; + when (',', '-') do; number = neg*number; return; end; + otherwise signal error; + end; + on endfile (sysin) go to exit; + get edit (c) (a(1)); + end; +exit: + number = neg*number; + eof = true; +end get_Number; + + declare c character, (i, range_start, range_end) fixed binary (31); + declare eof bit (1) aligned; + declare true bit (1) value ('1'b), false bit (1) value ('0'b); + declare delimiter character (1) initial (' '); + declare out file output; + + open file (out) output title ('/out, type(text),recsize(80)'); + do while (^eof); + call get_number(range_start, c, eof); + if c = '-' then /* we have a range */ + do; + call get_number (range_end, c, eof); + do i = range_start to range_end; + put file (out) edit (delimiter, i) (a, f(3)); + end; + end; + else + do; + put file (out) edit (delimiter, range_start) (a, f(3)); + end; + delimiter = ','; + end; +end range_expansion; diff --git a/Task/Range-expansion/Perl-6/range-expansion.pl6 b/Task/Range-expansion/Perl-6/range-expansion.pl6 new file mode 100644 index 0000000000..a3c54846ba --- /dev/null +++ b/Task/Range-expansion/Perl-6/range-expansion.pl6 @@ -0,0 +1,7 @@ +sub range-expansion (Str $range-description) { + my $range-pattern = rx/ ( '-'? \d+ ) '-' ( '-'? \d+) /; + my &expand = -> $term { $term ~~ $range-pattern ?? +$0..+$1 !! $term }; + return $range-description.split(',').map(&expand) +} + +say range-expansion('-6,-3--1,3-5,7-11,14,15,17-20').join(', '); diff --git a/Task/Range-expansion/Perl/range-expansion-1.pl b/Task/Range-expansion/Perl/range-expansion-1.pl new file mode 100644 index 0000000000..fc7be59ad1 --- /dev/null +++ b/Task/Range-expansion/Perl/range-expansion-1.pl @@ -0,0 +1,6 @@ +sub rangex { + map { /^(.*\d)-(.+)$/ ? $1..$2 : $_ } split /,/, shift +} + +# Test and display +print join(',', rangex('-6,-3--1,3-5,7-11,14,15,17-20')), "\n"; diff --git a/Task/Range-expansion/Perl/range-expansion-2.pl b/Task/Range-expansion/Perl/range-expansion-2.pl new file mode 100644 index 0000000000..0460ef0fd0 --- /dev/null +++ b/Task/Range-expansion/Perl/range-expansion-2.pl @@ -0,0 +1,4 @@ +sub rangex { + (my $range = shift) =~ s/(?<=\d)-/../g; + eval $range; +} diff --git a/Task/Range-expansion/PicoLisp/range-expansion.l b/Task/Range-expansion/PicoLisp/range-expansion.l new file mode 100644 index 0000000000..d261e8c6c7 --- /dev/null +++ b/Task/Range-expansion/PicoLisp/range-expansion.l @@ -0,0 +1,9 @@ +(de rangeexpand (Str) + (make + (for S (split (chop Str) ",") + (if (index "-" (cdr S)) + (chain + (range + (format (head @ S)) + (format (tail (- -1 @) S)) ) ) + (link (format S)) ) ) ) ) diff --git a/Task/Range-expansion/Prolog/range-expansion.pro b/Task/Range-expansion/Prolog/range-expansion.pro new file mode 100644 index 0000000000..a87d61d845 --- /dev/null +++ b/Task/Range-expansion/Prolog/range-expansion.pro @@ -0,0 +1,81 @@ +range_expand :- + L = '-6,-3--1,3-5,7-11,14,15,17-20', + writeln(L), + atom_chars(L, LA), + extract_Range(LA, R), + maplist(study_Range, R, LR), + pack_Range(LX, LR), + writeln(LX). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% extract_Range(?In, ?Out) +% In : '-6,-3--1,3-5,7-11,14,15,17-20' +% Out : [-6], [-3--1], [3-5],[7-11], [14],[15], [17-20] +% +extract_Range([], []). + +extract_Range(X , [Range | Y1]) :- + get_Range(X, U-U, Range, X1), + extract_Range(X1, Y1). + +get_Range([], Range-[], Range, []). +get_Range([','|B], Range-[], Range, B) :- !. + +get_Range([A | B], EC, Range, R) :- + append_dl(EC, [A | U]-U, NEC), + get_Range(B, NEC, Range, R). + + +append_dl(X-Y, Y-Z, X-Z). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% study Range(?In, ?Out) +% In : [-6] +% Out : [-6,-6] +% +% In : [-3--1] +% Out : [-3, -1] +% +study_Range(Range1, [Deb, Deb]) :- + catch(number_chars(Deb, Range1), Deb, false). + +study_Range(Range1, [Deb, Fin]) :- + append(A, ['-'|B], Range1), + A \= [], + number_chars(Deb, A), + number_chars(Fin, B). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +:- use_module(library(clpfd)). +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Pack Range(?In, ?Out) +% In : -6, +% Out : [-6] +% +% In : -3, -2,-1 +% Out : [-3,-1] +% +pack_Range([],[]). + +pack_Range([X|Rest],[[X | V]|Packed]):- + run(X,Rest, [X|V], RRest), + pack_Range(RRest,Packed). + + +run(Fin,[Other|RRest], [Deb, Fin],[Other|RRest]):- + Fin #\= Deb, + Fin #\= Deb + 1, + Other #\= Fin+1. + +run(Fin,[],[_Var, Fin],[]). + +run(Var,[Var1|LRest],[Deb, Fin], RRest):- + Fin #\= Deb, + Fin #\= Deb + 1, + Var1 #= Var + 1, + run(Var1,LRest,[Deb, Fin], RRest). + +run(Val,[Other|RRest], [Val, Val],[Other|RRest]). diff --git a/Task/Range-expansion/PureBasic/range-expansion.purebasic b/Task/Range-expansion/PureBasic/range-expansion.purebasic new file mode 100644 index 0000000000..552fd4c7fc --- /dev/null +++ b/Task/Range-expansion/PureBasic/range-expansion.purebasic @@ -0,0 +1,46 @@ +Procedure rangeexpand(txt.s, List outputList()) + Protected rangesCount = CountString(txt, ",") + 1 + Protected subTxt.s, r, rangeMarker, rangeStart, rangeFinish, rangeIncrement, i + + LastElement(outputList()) + For r = 1 To rangesCount + subTxt = StringField(txt, r, ",") + rangeMarker = FindString(subTxt, "-", 2) + If rangeMarker + rangeStart = Val(Mid(subTxt, 1, rangeMarker - 1)) + rangeFinish = Val(Mid(subTxt, rangeMarker + 1)) + + If rangeStart > rangeFinish + rangeIncrement = -1 + Else + rangeIncrement = 1 + EndIf + + i = rangeStart - rangeIncrement + Repeat + i + rangeIncrement + AddElement(outputList()): outputList() = i + Until i = rangeFinish + Else + AddElement(outputList()): outputList() = Val(subTxt) + EndIf + Next +EndProcedure + +Procedure outputListValues(List values()) + Print("[ ") + ForEach values() + Print(Str(values()) + " ") + Next + PrintN("]") +EndProcedure + +If OpenConsole() + NewList values() + rangeexpand("-6,-3--1,3-5,7-11,14,15,17-20", values()) + outputListValues(values()) + + Print(#CRLF$ + #CRLF$ + "Press ENTER to exit") + Input() + CloseConsole() +EndIf diff --git a/Task/Range-expansion/Python/range-expansion-1.py b/Task/Range-expansion/Python/range-expansion-1.py new file mode 100644 index 0000000000..1d5385d107 --- /dev/null +++ b/Task/Range-expansion/Python/range-expansion-1.py @@ -0,0 +1,11 @@ +def rangeexpand(txt): + lst = [] + for r in txt.split(','): + if '-' in r[1:]: + r0, r1 = r[1:].split('-', 1) + lst += range(int(r[0] + r0), int(r1) + 1) + else: + lst.append(int(r)) + return lst + +print(rangeexpand('-6,-3--1,3-5,7-11,14,15,17-20')) diff --git a/Task/Range-expansion/Python/range-expansion-2.py b/Task/Range-expansion/Python/range-expansion-2.py new file mode 100644 index 0000000000..727d89b863 --- /dev/null +++ b/Task/Range-expansion/Python/range-expansion-2.py @@ -0,0 +1,11 @@ +import re + +def rangeexpand(txt): + lst = [] + for rng in txt.split(','): + start,end = re.match('^(-?\d+)(?:-(-?\d+))?$', rng).groups() + if end: + lst.extend(xrange(int(start),int(end)+1)) + else: + lst.append(int(start)) + return lst diff --git a/Task/Range-expansion/R/range-expansion-1.r b/Task/Range-expansion/R/range-expansion-1.r new file mode 100644 index 0000000000..8e16856742 --- /dev/null +++ b/Task/Range-expansion/R/range-expansion-1.r @@ -0,0 +1,9 @@ +rangeExpand <- function(text) { + x <- unlist(strsplit(text, ",")) # split the string on commas + x <- gsub("(\\d)-", "\\1:", x) # substitute dashes following a digit with a colon + lst <- list(mode = "list", length = length(x)) # an empty list to hold evaluated elements + for (i in 1:length(x)) { # evaluate each element and add to the list + lst[[i]] <- eval(parse(text = x[i])) + } + unlist(lst, use.names = FALSE) # return the expanded integers +} diff --git a/Task/Range-expansion/R/range-expansion-2.r b/Task/Range-expansion/R/range-expansion-2.r new file mode 100644 index 0000000000..7b9aaf3f5b --- /dev/null +++ b/Task/Range-expansion/R/range-expansion-2.r @@ -0,0 +1,2 @@ +rangeExpand("-6,-3--1,3-5,7-11,14,15,17-20") + [1] -6 -3 -2 -1 3 4 5 7 8 9 10 11 14 15 17 18 19 20 diff --git a/Task/Range-expansion/REXX/range-expansion-1.rexx b/Task/Range-expansion/REXX/range-expansion-1.rexx new file mode 100644 index 0000000000..d0edf78475 --- /dev/null +++ b/Task/Range-expansion/REXX/range-expansion-1.rexx @@ -0,0 +1,18 @@ +/*REXX program expands an ordered list of integers into an expanded list*/ +new= /*new list of numbers (so far). */ +old='-6,-3--1, 3-5, 7-11,14,15, 17-20' /*orig integers/ranges,*/ + /*blanks were added for comparing*/ +a=translate(old,,',') /*translate commas (,) to blanks.*/ + + do until a==''; parse var a X a /*obtain the next integer|range. */ + _=pos('-',X,2) /*find location of a dash (maybe)*/ + if _\==0 then do k=left(X,_-1) to substr(X,_+1) /*Dash? Process range*/ + new=new k /*append single integer at a time*/ + end /*k*/ + else new=new X /*append X to the new list. */ + end /*until*/ + +new=translate( strip(new), ',' ," ") /*remove first blank, add commas.*/ +say 'old list =' old /*show old list of numbers/ranges*/ +say 'new list =' new /*show the new list of numbers.*/ + /*stick a fork in it, we're done.*/ diff --git a/Task/Range-expansion/REXX/range-expansion-2.rexx b/Task/Range-expansion/REXX/range-expansion-2.rexx new file mode 100644 index 0000000000..d4f9988a52 --- /dev/null +++ b/Task/Range-expansion/REXX/range-expansion-2.rexx @@ -0,0 +1,25 @@ +/*REXX program to expand a range of integers into a list. ************* +* 09.08.2012 Walter Pachl +**********************************************************************/ + + old='-6,-3--1,3-5,7-11,14,15,17-20' /*original list of nums/ranges */ + + Say 'old='old /*show old list of nums/ranges. */ + a=translate(old,,',') /*translate commas to blanks */ + new='' /*new list of numbers (so far). */ + + comma='' + Do While a<>'' /* as long as there is input */ + Parse var a x a /* get one element */ + dashpos=pos('-',x,2) /* find position of dash, if any */ + If dashpos>0 Then Do /* element is low-high */ + Parse Var x low =(dashpos) +1 high /* split the element */ + Do j=low To high /* output all numbers in range */ + new=new||comma||j /* with separating commas */ + End + End + Else /* element is a number */ + new=new||comma||x /* append (with comma) */ + comma=',' /* from now on use comma */ + End + Say 'new='new /*show the expanded list */ diff --git a/Task/Range-expansion/Racket/range-expansion-1.rkt b/Task/Range-expansion/Racket/range-expansion-1.rkt new file mode 100644 index 0000000000..849aee6643 --- /dev/null +++ b/Task/Range-expansion/Racket/range-expansion-1.rkt @@ -0,0 +1,13 @@ +#lang racket + +(define (range-expand s) + (append* + (for/list ([r (regexp-split "," s)]) + (match (regexp-match* "(-?[0-9]+)-(-?[0-9]+)" r + #:match-select cdr) + [(list (list f t)) + (range (string->number f) (+ (string->number t) 1))] + [(list) + (list (string->number r))])))) + +(range-expand "-6,-3--1,3-5,7-11,14,15,17-20") diff --git a/Task/Range-expansion/Racket/range-expansion-2.rkt b/Task/Range-expansion/Racket/range-expansion-2.rkt new file mode 100644 index 0000000000..994cb399ac --- /dev/null +++ b/Task/Range-expansion/Racket/range-expansion-2.rkt @@ -0,0 +1,26 @@ +#lang racket + +(define on-minus + (case-lambda + [(ch ip) (on-minus ch ip #f #f #f #f)] + [(ch ip src line col pos) + (if (char-numeric? (peek-char ip)) + (- (read ip)) + (datum->syntax #f '-))])) + +(define minus-delimits + (make-readtable (current-readtable) #\- 'terminating-macro on-minus)) + +(define (range-expand s) + (parameterize ([current-readtable minus-delimits]) + (append* + (for/list ([f (in-port read s)]) + (match (peek-char s) + [#\, (read-char s) + (list f)] + [#\- (read-char s) + (define t (read s)) + (read-char s) + (range f (+ t 1))]))))) + +(range-expand (open-input-string "-6,-3--1,3-5,7-11,14,15,17-20")) diff --git a/Task/Range-expansion/Ruby/range-expansion.rb b/Task/Range-expansion/Ruby/range-expansion.rb new file mode 100644 index 0000000000..727d9cde37 --- /dev/null +++ b/Task/Range-expansion/Ruby/range-expansion.rb @@ -0,0 +1,11 @@ +def range_expand(rng) + rng.split(',').collect do |part| + if part =~ /^(-?\d+)-(-?\d+)$/ + ($1.to_i .. $2.to_i).to_a + else + Integer(part) + end + end.flatten +end + +p range_expand('-6,-3--1,3-5,7-11,14,15,17-20') diff --git a/Task/Range-expansion/Run-BASIC/range-expansion.run b/Task/Range-expansion/Run-BASIC/range-expansion.run new file mode 100644 index 0000000000..082540bc46 --- /dev/null +++ b/Task/Range-expansion/Run-BASIC/range-expansion.run @@ -0,0 +1,25 @@ +PRINT rangeExpand$("-6,-3--1,3-5,7-11,14,15,17-20") +end + +function rangeExpand$(range$) +[loop] +i = INSTR(range$, "-", i+1) +IF i THEN + j = i + WHILE MID$(range$,j-1,1) <> "," AND j <> 1 + j = j - 1 + wend + IF i > j then + IF MID$(range$,j,i-j) <> str$(i-j)+" " THEN + t$ = "" + FOR k = VAL(MID$(range$,j)) TO VAL(MID$(range$,i+1))-1 + t$ = t$ + str$(k) + "," + NEXT k + range$ = LEFT$(range$,j-1) + t$ + MID$(range$,i+1) + i = j + LEN(t$) + 2 + end if + end if +end if +if i <> 0 then goto [loop] +rangeExpand$ = range$ +end function diff --git a/Task/Range-expansion/SNOBOL4/range-expansion.sno b/Task/Range-expansion/SNOBOL4/range-expansion.sno new file mode 100644 index 0000000000..9debfb4f02 --- /dev/null +++ b/Task/Range-expansion/SNOBOL4/range-expansion.sno @@ -0,0 +1,15 @@ +* # Return range n1 .. n2 + define('range(n1,n2)') :(range_end) +range range = range n1 ','; n1 = lt(n1,n2) n1 + 1 :s(range) + range rtab(1) . range :(return) +range_end + + define('rangex(range)d1,d2') + num = ('-' | '') span('0123456789') :(rangex_end) +rangex range num . d1 '-' num . d2 = range(d1,d2) :s(rangex) + rangex = range :(return) +rangex_end + +* # Test and display + output = rangex('-6,-3--1,3-5,7-11,14,15,17-20') +end diff --git a/Task/Range-expansion/Scala/range-expansion.scala b/Task/Range-expansion/Scala/range-expansion.scala new file mode 100644 index 0000000000..79a54458c8 --- /dev/null +++ b/Task/Range-expansion/Scala/range-expansion.scala @@ -0,0 +1,6 @@ +def rangex(str: String): Seq[Int] = + str split "," flatMap { (s) => + val r = """(-?\d+)(?:-(-?\d+))?""".r + val r(a,b) = s + if (b == null) Seq(a.toInt) else a.toInt to b.toInt + } diff --git a/Task/Range-expansion/Scheme/range-expansion.ss b/Task/Range-expansion/Scheme/range-expansion.ss new file mode 100644 index 0000000000..80146739cb --- /dev/null +++ b/Task/Range-expansion/Scheme/range-expansion.ss @@ -0,0 +1,35 @@ +(define split + (lambda (str char skip count) + (let ((len (string-length str))) + (let loop ((index skip) + (last-index 0) + (result '())) + (if (= index len) + (reverse (cons (substring str last-index) result)) + (if (eq? char (string-ref str index)) + (loop (if (= count (+ 2 (length result))) + len + (+ index 1)) + (+ index 1) + (cons char (cons (substring str last-index index) + result))) + (loop (+ index 1) + last-index + result))))))) + +(define range-expand + (lambda (str) + (for-each + (lambda (token) + (if (char? token) + (display token) + (let ((range (split token #\- 1 2))) + (if (null? (cdr range)) + (display (car range)) + (do ((count (string->number (list-ref range 0)) (+ 1 count)) + (high (string->number (list-ref range 2)))) + ((= count high) (display high)) + (display count) + (display ",")))))) + (split str #\, 0 0)) + (newline))) diff --git a/Task/Range-expansion/Seed7/range-expansion.seed7 b/Task/Range-expansion/Seed7/range-expansion.seed7 new file mode 100644 index 0000000000..fa5263e5c4 --- /dev/null +++ b/Task/Range-expansion/Seed7/range-expansion.seed7 @@ -0,0 +1,35 @@ +$ include "seed7_05.s7i"; + include "scanstri.s7i"; + +const func array integer: rangeExpansion (in var string: rangeStri) is func + result + var array integer: numbers is 0 times 0; + local + var integer: number is 0; + begin + while rangeStri <> "" do + number := integer parse getInteger(rangeStri); + numbers &:= number; + if startsWith(rangeStri, "-") then + rangeStri := rangeStri[2 ..]; + for number range succ(number) to integer parse getInteger(rangeStri) do + numbers &:= number; + end for; + end if; + if startsWith(rangeStri, ",") then + rangeStri := rangeStri[2 ..]; + elsif rangeStri <> "" then + raise RANGE_ERROR; + end if; + end while; + end func; + +const proc: main is func + local + var integer: number is 0; + begin + for number range rangeExpansion("-6,-3--1,3-5,7-11,14,15,17-20") do + write(number <& " "); + end for; + writeln; + end func; diff --git a/Task/Range-expansion/TUSCRIPT/range-expansion.tuscript b/Task/Range-expansion/TUSCRIPT/range-expansion.tuscript new file mode 100644 index 0000000000..30d9be59eb --- /dev/null +++ b/Task/Range-expansion/TUSCRIPT/range-expansion.tuscript @@ -0,0 +1,22 @@ +$$ MODE TUSCRIPT +rangednrs="-6,-3--1,3-5,7-11,14,15,17-20" +expandnrs=SPLIT (rangednrs,":,:") + +LOOP/CLEAR r=expandnrs + test=STRINGS (r,":><-><<>>/:") + sz_test=SIZE (test) + IF (sz_test==1) THEN + expandnrs=APPEND (expandnrs,r) + ELSE + r=SPLIT (r,"::<|->/::-:",beg,end) + expandnrs=APPEND (expandnrs,beg) + LOOP/CLEAR next=beg,end + next=next+1 + expandnrs=APPEND (expandnrs,next) + IF (next==end) EXIT + ENDLOOP + ENDIF +ENDLOOP +expandnrs= JOIN (expandnrs,",") + +PRINT expandnrs diff --git a/Task/Range-expansion/Tcl/range-expansion.tcl b/Task/Range-expansion/Tcl/range-expansion.tcl new file mode 100644 index 0000000000..023439dc7a --- /dev/null +++ b/Task/Range-expansion/Tcl/range-expansion.tcl @@ -0,0 +1,14 @@ +proc rangeExpand desc { + set result {} + foreach term [split $desc ","] { + set count [scan $term %d-%d from to] + if {$count == 1} { + lappend result $from + } elseif {$count == 2} { + for {set i $from} {$i <= $to} {incr i} {lappend result $i} + } + } + return $result +} + +puts [rangeExpand "-6,-3--1,3-5,7-11,14,15,17-20"] diff --git a/Task/Range-expansion/Ursala/range-expansion.ursala b/Task/Range-expansion/Ursala/range-expansion.ursala new file mode 100644 index 0000000000..eef205c7da --- /dev/null +++ b/Task/Range-expansion/Ursala/range-expansion.ursala @@ -0,0 +1,8 @@ +#import std +#import int + +rex = sep`,; zrange+*= %zp~~htttPzztPQhQXbiNC+ rlc ~&r~=`- + +#cast %zL + +t = rex '-6,-3--1,3-5,7-11,14,15,17-20' diff --git a/Task/Range-expansion/VBA/range-expansion.vba b/Task/Range-expansion/VBA/range-expansion.vba new file mode 100644 index 0000000000..038fdcbf12 --- /dev/null +++ b/Task/Range-expansion/VBA/range-expansion.vba @@ -0,0 +1,46 @@ +Public Function RangeExpand(AString as string) +' return a list with the numbers expressed in AString +Dim Splits() As String +Dim List() As Integer +Dim count As Integer + +count = -1 'to start a zero-based List() array +' first split it using comma as delimiter +Splits = Split(AString, ",") +' process all fragments +For Each fragment In Splits + 'is there a "-" in it (do not consider first character)? + P = InStr(2, fragment, "-") + If P > 0 Then 'yes, so it's a range: find start and end numbers + nstart = Val(left$(fragment, P - 1)) + nend = Val(Mid$(fragment, P + 1)) + j = count + count = count + (nend - nstart + 1) + 'add numbers in range to List + ReDim Preserve List(count) + For i = nstart To nend + j = j + 1 + List(j) = i + Next + Else + 'not a range, add a single number + count = count + 1 + ReDim Preserve List(count) + List(count) = Val(fragment) + End If +Next +RangeExpand = List +End Function + +Public Sub RangeExpandTest() +'test function RangeExpand +Dim X As Variant + +X = RangeExpand("-6,-3--1,3-5,7-11,14,15,17-20") +'print X +Debug.Print "Result:" +For Each el In X + Debug.Print el; +Next +Debug.Print +End Sub diff --git a/Task/Range-expansion/XPL0/range-expansion.xpl0 b/Task/Range-expansion/XPL0/range-expansion.xpl0 new file mode 100644 index 0000000000..b68533ce9a --- /dev/null +++ b/Task/Range-expansion/XPL0/range-expansion.xpl0 @@ -0,0 +1,42 @@ +include c:\cxpl\codes; \intrinsic 'code' declarations +string 0; \use zero-terminated strings, instead of MSb +char Str; +int Char, Inx; + + +proc GetCh; \Get character from Str +[Char:= Str(Inx); +Inx:= Inx+1; +]; \GetCh + + +func GetNum; \Get number from Str and return its value +int Neg, Num; +[Neg:= false; +if Char = ^- then [Neg:= true; GetCh]; +Num:= 0; +while Char>=^0 & Char<=^9 do + [Num:= Num*10 + Char-^0; + GetCh; + ]; +return if Neg then -Num else Num; +]; \GetNum + + +int I, N0, N1; +[Str:= "-6,-3--1,3-5,7-11,14,15,17-20"; +Inx:= 0; +GetCh; \one character look ahead +loop [N0:= GetNum; + IntOut(0,N0); + case Char of + ^,: [GetCh; ChOut(0,^,)]; + ^-: [GetCh; + N1:= GetNum; + for I:= N0+1 to N1 do \expand range + [ChOut(0,^,); IntOut(0,I)]; + if Char=^, then [GetCh; ChOut(0,^,)] else quit] + other quit; \must be 0 string terminator + ]; +CrLf(0); +] diff --git a/Task/Range-extraction/0DESCRIPTION b/Task/Range-extraction/0DESCRIPTION new file mode 100644 index 0000000000..4d286a2c76 --- /dev/null +++ b/Task/Range-extraction/0DESCRIPTION @@ -0,0 +1,12 @@ +{{:Range extraction/Format}} + +'''The task''' +* Create a function that takes a list of integers in increasing order and returns a correctly formatted string in the range format. +* Use the function to compute and print the range formatted version of the following ordered list of integers: + 0, 1, 2, 4, 6, 7, 8, 11, 12, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 27, 28, 29, 30, 31, 32, 33, 35, 36, + 37, 38, 39 +* Show the output of your program. + +C.f. [[Range expansion]] diff --git a/Task/Range-extraction/ALGOL-68/range-extraction-1.alg b/Task/Range-extraction/ALGOL-68/range-extraction-1.alg new file mode 100644 index 0000000000..a19038756a --- /dev/null +++ b/Task/Range-extraction/ALGOL-68/range-extraction-1.alg @@ -0,0 +1,54 @@ +### + REQUIRES(MODE SCALAR, OP(SCALAR,SCALAR)BOOL =, OP(SCALAR,SCALAR)SCALAR +); +### +MODE SCALARLIST = FLEX[0]SCALAR; +MODE YIELDINT = PROC(SCALAR)VOID; + +################################################################ +# Declarations for manipulating lists of range pairs [lwb:upb] # +################################################################ +MODE RANGE = STRUCT(SCALAR lwb, upb); +MODE RANGELIST = FLEX[0]RANGE; +MODE YIELDRANGE = PROC(RANGE)VOID; + +PROC range repr = (RANGE range)STRING: ( + STRING lwb := whole(lwb OF range,0); + IF lwb OF range = upb OF range THEN + lwb + ELSE + # "["+lwb+":"+whole(upb OF range,0)+"]" # + lwb+"-"+whole(upb OF range,0) + FI +); + +# OP REPR = (RANGE range)STRING: range repr(range); # # firmly related to UNIRANGE # + +###################################################################### +# Declarations for manipulating lists containing pairs AND lone INTs # +###################################################################### +MODE UNIRANGE = UNION(SCALAR, RANGE); +MODE UNIRANGELIST = FLEX[0]UNIRANGE; +MODE YIELDUNIRANGE = PROC(UNIRANGE)VOID; + +PROC unirange repr = (UNIRANGE unirange)STRING: + CASE unirange IN + (RANGE range): range repr(range), + (SCALAR scalar): whole(scalar,0) + ESAC; + +OP (UNIRANGE)STRING REPR = unirange repr; # alias # + +# The closest thing Algol68 has to inheritance is the UNION # +MODE UNIRANGELISTS = UNION(UNIRANGELIST, RANGELIST, SCALARLIST); + +PROC unirange list repr = (UNIRANGELIST unirange list)STRING: ( +### Produce a STRING representation of a UNIRANGELIST ### + STRING out # := "("#, sep := ""; + FOR key FROM LWB unirange list TO UPB unirange list DO + out +:= sep + REPR unirange list[key]; + sep := "," # +" " # + OD; + out # +")" # +); + +OP (UNIRANGELIST)STRING REPR = unirange list repr; # alias # diff --git a/Task/Range-extraction/ALGOL-68/range-extraction-2.alg b/Task/Range-extraction/ALGOL-68/range-extraction-2.alg new file mode 100644 index 0000000000..fac51e0005 --- /dev/null +++ b/Task/Range-extraction/ALGOL-68/range-extraction-2.alg @@ -0,0 +1,60 @@ +### + REQUIRES(MODE SCALAR, OP(SCALAR,SCALAR)BOOL =, OP(SCALAR,SCALAR)SCALAR +); +### +PR READ "Template_Range_extraction_Base.a68" PR + +OP (UNIRANGELISTS)UNIRANGELIST INITUNIRANGE = init unirange list; # alias # + +PROC init unirange list = (UNIRANGELISTS unirange list)UNIRANGELIST: ( +### Take a []SCALAR, []RANGE or []UNIRANGE, and return a normalised []UNIRANGE ### + + INT len = UPB unirange list-LWB unirange list+1; + [LWB unirange list: LWB unirange list+len*2]UNIRANGE out unirange list; + SCALAR upb out unirange list := LWB out unirange list - 1; + UNION(VOID, RANGE) prev range := EMPTY; + + PROC out unirange list append = (RANGE value)VOID:( + + IF lwb OF value = upb OF value THEN + out unirange list[upb out unirange list+:=1] := lwb OF value + ELIF lwb OF value + 1 = upb OF value THEN + out unirange list[upb out unirange list+:=1] := lwb OF value; + out unirange list[upb out unirange list+:=1] := upb OF value + ELSE + out unirange list[upb out unirange list+:=1] := value + FI + ); + + FOR key FROM LWB unirange list TO UPB unirange list DO + UNIRANGE value = CASE unirange list IN + (SCALARLIST list):list[key], + (RANGELIST list):list[key], + (UNIRANGELIST list):list[key] + ESAC; + + RANGE next range := CASE value IN + (RANGE range): range, + (SCALAR value): RANGE(value, value) + ESAC; + + prev range := + CASE prev range IN + (VOID): next range, + (RANGE prev range): + IF upb OF prev range + 1 = lwb OF next range THEN + RANGE(lwb OF prev range, upb OF next range) # merge the range # + ELSE + out unirange list append(prev range); + next range + FI + OUT SKIP + ESAC + + OD; + + CASE prev range IN + (RANGE last range): out unirange list append(last range) + ESAC; + + out unirange list[:upb out unirange list] +); diff --git a/Task/Range-extraction/ALGOL-68/range-extraction-3.alg b/Task/Range-extraction/ALGOL-68/range-extraction-3.alg new file mode 100644 index 0000000000..03dc05cce4 --- /dev/null +++ b/Task/Range-extraction/ALGOL-68/range-extraction-3.alg @@ -0,0 +1,44 @@ +#!/usr/local/bin/a68g --script # +############################ +# some simple test cases: # +############################ + +MODE SCALAR = INT; +PR READ "Template_Range_extraction_Iterative.a68" PR +#PR READ "Template_Range_extraction_Generative.a68" PR# +MODE RANGEINT = UNIRANGE; + +test: BEGIN + []INT int list = ( # unnormalised # + 0, 1, 2, 4, 6, 7, 8, 11, 12, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 27, 28, 29, 30, 31, 32, 33, 35, 36, + 37, 38, 39); + + []RANGE range list = ( # unnormalised # + (0,0), (1,1), (2,2), (4,4), (6,6), (7,7), (8,8), (11,11), (12,12), (14,14), + (15,15), (16,16), (17,17), (18,18), (19,19), (20,20), (21,21), (22,22), (23,23), (24,24), + (25,25), (27,27), (28,28), (29,29), (30,30), (31,31), (32,32), (33,33), (35,35), (36,36), + (37,37), (38,38), (39,39)); + + []RANGEINT list a = ( # unnormalised # + RANGE(0,2), 4, RANGE(6,8), RANGE(11,12), + RANGE(14,25), RANGE(27,33), RANGE(35,39)); + + []RANGEINT list b = ( # unnormalised # + 0, 1, 2, 4, 6, 7, 8, 11, 12, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 27, 28, 29, 30, 31, 32, 33, 35, 36, + 37, 38, 39); + + []RANGEINT list c = INITUNIRANGE(list b); # normalised # + +# compare manipulation of various types of argument lists # + printf(($gl$, + REPR INITUNIRANGE int list, + REPR INITUNIRANGE range list, + REPR INITUNIRANGE list a, + REPR INITUNIRANGE list b, + REPR list c + )) +END diff --git a/Task/Range-extraction/ALGOL-68/range-extraction-4.alg b/Task/Range-extraction/ALGOL-68/range-extraction-4.alg new file mode 100644 index 0000000000..65fa19d2e8 --- /dev/null +++ b/Task/Range-extraction/ALGOL-68/range-extraction-4.alg @@ -0,0 +1,83 @@ +### + REQUIRES(MODE SCALAR, OP(SCALAR,SCALAR)BOOL =, OP(SCALAR,SCALAR)SCALAR +); +### +PR READ "Template_Range_extraction_Base.a68" PR + +PROC gen range = (UNIRANGELISTS unirange list, YIELDRANGE yield range)VOID: +### Take a []SCALAR, []RANGE or []URANGE, and generatively yield an unnormalised RANGE ### + + FOR key FROM LWB unirange list TO UPB unirange list DO +# Note: Algol 68RS cannot handle LWB and UPB of a UNION in the following: # + UNIRANGE value = CASE unirange list IN + (SCALARLIST list):list[key], + (RANGELIST list):list[key], + (UNIRANGELIST list):list[key] + ESAC; + yield range( + CASE value IN + (RANGE range): range, + (SCALAR value): (value, value) + ESAC + ) + OD; + +PROC gen range merge = (UNIRANGELISTS unirange list, YIELDRANGE yield)VOID: ( +### Take a []SCALAR, []RANGE or []URANGE , and generatively yield a normalised RANGE ### + + UNION(VOID, RANGE) prev range := EMPTY; + +# FOR RANGE next range IN # gen range(unirange list, # ) DO # +## (RANGE next range)VOID: +# if the ranges cannot be merge, then yield 1st, and return 2nd # + prev range := + CASE prev range IN + (VOID): next range, + (RANGE prev range): + IF upb OF prev range + 1 = lwb OF next range THEN + RANGE(lwb OF prev range, upb OF next range) # merge the range # + ELSE + #IF lwb OF prev range <= upb OF prev range THEN# + yield(prev range); + #FI;# + next range + FI + OUT SKIP + ESAC +# OD # ); + + CASE prev range IN (RANGE last range): yield(last range) ESAC +); + +PROC gen unirange merge = (UNIRANGELISTS unirange list, YIELDUNIRANGE yield)VOID: ( +### Take a []SCALAR, []RANGE or []UNIRANGE and generatively yield a normalised UNIRANGE ### + + PROC unpack = (RANGE value)VOID:( + IF lwb OF value = upb OF value THEN + yield(lwb OF value) + ELIF lwb OF value + 1 = upb OF value THEN + yield(lwb OF value); + yield(upb OF value) + ELSE + yield(value) + FI + ); + + gen range merge(unirange list, unpack) +); + +PROC unirange list init = (UNIRANGELISTS unirange list)UNIRANGELIST: ( +### Take a []SCALAR, []RANGE or []UNIRANGE and return a static []UNIRANGE ### + + INT len = UPB unirange list - LWB unirange list + 1; + [LWB unirange list: LWB unirange list + len * 2]UNIRANGE out unirange list; # estimate # + SCALAR upb out unirange list := LWB out unirange list - 1; + +# FOR UNIRANGE unirange IN # gen unirange merge(unirange list, # ) DO # +## (UNIRANGE unirange)VOID: + out unirange list[upb out unirange list+:=1] := unirange +# OD # ); + + out unirange list[:upb out unirange list] +); + +OP (UNIRANGELISTS)UNIRANGELIST INITUNIRANGE = unirange list init; # alias # diff --git a/Task/Range-extraction/AWK/range-extraction.awk b/Task/Range-extraction/AWK/range-extraction.awk new file mode 100644 index 0000000000..37527d8ddc --- /dev/null +++ b/Task/Range-extraction/AWK/range-extraction.awk @@ -0,0 +1,54 @@ +#!/usr/bin/awk -f + +BEGIN { + delete sequence + delete range + + seqStr = "0,1,2,4,6,7,8,11,12,14,15,16,17,18,19,20,21,22,23,24," + seqStr = seqStr "25,27,28,29,30,31,32,33,35,36,37,38,39" + print "Sequence: " seqStr + fillSequence(seqStr) + rangeExtract() + showRange() + exit +} + +function rangeExtract( runStart, runLen) { + delete range + runStart = 1 + while(runStart <= length(sequence)) { + runLen = getSeqRunLen(runStart) + addRange(runStart, runLen) + runStart += runLen + } +} + +function getSeqRunLen(startPos, pos) { + for (pos = startPos; pos < length(sequence); pos++) { + if (sequence[pos] + 1 != sequence[pos + 1]) break; + } + return pos - startPos + 1; +} + +function addRange(startPos, len, str) { + if (len == 1) str = sequence[startPos] + else if (len == 2) str = sequence[startPos] "," sequence[startPos + 1] + else str = sequence[startPos] "-" sequence[startPos + len - 1] + range[length(range) + 1] = str +} + +function showRange( r) { + printf " Ranges: " + for (r = 1; r <= length(range); r++) { + if (r > 1) printf "," + printf range[r] + } + printf "\n" +} + +function fillSequence(seqStr, n, s) { + n = split(seqStr,a,/[,]+/) + for (s = 1; s <= n; s++) { + sequence[s] = a[s] + } +} diff --git a/Task/Range-extraction/Ada/range-extraction-1.ada b/Task/Range-extraction/Ada/range-extraction-1.ada new file mode 100644 index 0000000000..dab4756533 --- /dev/null +++ b/Task/Range-extraction/Ada/range-extraction-1.ada @@ -0,0 +1,46 @@ +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; +with Ada.Strings.Fixed; use Ada.Strings.Fixed; + +procedure Range_Extraction is + type Sequence is array (Positive range <>) of Integer; + function Image (S : Sequence) return String is + Result : Unbounded_String; + From : Integer; + procedure Flush (To : Integer) is + begin + if Length (Result) > 0 then + Append (Result, ','); + end if; + Append (Result, Trim (Integer'Image (From), Ada.Strings.Left)); + if From < To then + if From+1 = To then + Append (Result, ','); + else + Append (Result, '-'); + end if; + Append (Result, Trim (Integer'Image (To), Ada.Strings.Left)); + end if; + end Flush; + begin + if S'Length > 0 then + From := S (S'First); + for I in S'First + 1..S'Last loop + if S (I - 1) + 1 /= S (I) then + Flush (S (I - 1)); + From := S (I); + end if; + end loop; + Flush (S (S'Last)); + end if; + return To_String (Result); + end Image; +begin + Put_Line + ( Image + ( ( 0, 1, 2, 4, 6, 7, 8, 11, 12, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 27, 28, 29, 30, 31, 32, 33, 35, 36, + 37, 38, 39 + ) ) ); +end Range_Extraction; diff --git a/Task/Range-extraction/Ada/range-extraction-2.ada b/Task/Range-extraction/Ada/range-extraction-2.ada new file mode 100644 index 0000000000..ec45693968 --- /dev/null +++ b/Task/Range-extraction/Ada/range-extraction-2.ada @@ -0,0 +1,45 @@ +with Ada.Text_IO, Ada.Strings.Fixed; + +procedure Range_Extract is + type Sequence is array (Positive range <>) of Integer; + + function Img(I: Integer) return String is -- the image of an Integer + begin + return + Ada.Strings.Fixed.Trim(Integer'Image(I), Ada.Strings.Left); + end Img; + + function Img(S: Sequence) return String is -- the image of a Sequence + + function X(S : Sequence) return String is -- recursive eXtract + Idx: Positive := S'First; + begin + if S'Length = 0 then return + ""; -- return nothing if Sequence is empty + else + while Idx < S'Last and then S(Idx+1) = S(Idx) + 1 loop + Idx := Idx + 1; + end loop; + if Idx = S'First then return + "," & Img(S(Idx)) & X(S(Idx+1 .. S'Last)); + elsif Idx = S'First+1 then return + "," & Img(S(S'First)) & ',' & Img(S(Idx)) & X(S(Idx+1 .. S'Last)); + else return + "," & Img(S(S'First)) & '-' & Img(S(Idx)) & X(S(Idx+1 .. S'Last)); + end if; + end if; + end X; + + begin -- function Img(S: Sequence) return String + if S'Length = 0 then return + ""; + else return + Img(S(S'First)) & X(S(S'First+1 .. S'Last)); + end if; + end Img; + +begin -- main + Ada.Text_IO.Put_Line(Img( ( 0, 1, 2, 4, 6, 7, 8, 11, 12, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 28, 29, + 30, 31, 32, 33, 35, 36, 37, 38, 39) )); +end Range_Extract; diff --git a/Task/Range-extraction/Aime/range-extraction.aime b/Task/Range-extraction/Aime/range-extraction.aime new file mode 100644 index 0000000000..1d15929561 --- /dev/null +++ b/Task/Range-extraction/Aime/range-extraction.aime @@ -0,0 +1,54 @@ +void +fs(integer &s, data b) +{ + if (s) { + b_append(b, ','); + } + s = 1; +} + +text +rp(...) +{ + integer f, i, j; + data b; + + f = 0; + i = 0; + j = 0; + while (i < count()) { + while (j < count() - 1) { + if (__integer(lead(j + 1)) == __integer(lead(j)) + 1) { + j += 1; + } else { + break; + } + } + if (i + 1 < j) { + fs(f, b); + b_suffix(b, itoa(lead(i))); + b_append(b, '-'); + b_suffix(b, itoa(lead(j))); + } else { + while (i < j + 1) { + fs(f, b); + b_suffix(b, itoa(lead(i))); + i += 1; + } + } + j += 1; + i = j; + } + + return b_string(b); +} + +integer +main(void) +{ + o_text(rp(0, 1, 2, 4, 6, 7, 8, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 38, 39)); + o_byte('\n'); + + return 0; +} diff --git a/Task/Range-extraction/AutoHotkey/range-extraction.ahk b/Task/Range-extraction/AutoHotkey/range-extraction.ahk new file mode 100644 index 0000000000..644f1c5efc --- /dev/null +++ b/Task/Range-extraction/AutoHotkey/range-extraction.ahk @@ -0,0 +1,11 @@ +msgbox % extract("0,1,2,4,6,7,8,11,12,14,15,16,17,18,19,20,21,22,23,24,25,27,28,29,30,31,32,33,35,36,37,38,39") + +extract( list ) { + loop, parse, list, `,, %A_Tab%%A_Space%`r`n + { + if (A_LoopField+0 != p+1) + ret .= (f!=p ? (p>f+1 ? "-" : ",") p : "") "," f := A_LoopField + p := A_LoopField + } + return SubStr(ret (f!=p ? (p>f+1 ? "-" : ",") p : ""), 2) +} diff --git a/Task/Range-extraction/BBC-BASIC/range-extraction.bbc b/Task/Range-extraction/BBC-BASIC/range-extraction.bbc new file mode 100644 index 0000000000..016c939319 --- /dev/null +++ b/Task/Range-extraction/BBC-BASIC/range-extraction.bbc @@ -0,0 +1,26 @@ + range$ = " 0, 1, 2, 4, 6, 7, 8, 11, 12, 14, " + \ + \ "15, 16, 17, 18, 19, 20, 21, 22, 23, 24, " + \ + \ "25, 27, 28, 29, 30, 31, 32, 33, 35, 36, " + \ + \ "37, 38, 39" + PRINT FNrangeextract(range$) + END + + DEF FNrangeextract(r$) + LOCAL f%, i%, r%, t%, t$ + f% = VAL(r$) + REPEAT + i% = INSTR(r$, ",", i%+1) + t% = VALMID$(r$, i%+1) + IF t% = f% + r% + 1 THEN + r% += 1 + ELSE + CASE r% OF + WHEN 0: t$ += STR$(f%) + "," + WHEN 1: t$ += STR$(f%) + "," + STR$(f% + r%) + "," + OTHERWISE: t$ += STR$(f%) + "-" + STR$(f% + r%) + "," + ENDCASE + r% = 0 + f% = t% + ENDIF + UNTIL i% = 0 + = LEFT$(t$) diff --git a/Task/Range-extraction/Bracmat/range-extraction.bracmat b/Task/Range-extraction/Bracmat/range-extraction.bracmat new file mode 100644 index 0000000000..56121bac28 --- /dev/null +++ b/Task/Range-extraction/Bracmat/range-extraction.bracmat @@ -0,0 +1,51 @@ + ( rangeExtract + = accumulator firstInRange nextInRange + , accumulate fasten rangePattern + . ( accumulate + = !accumulator + (!accumulator:|?&",") + !firstInRange + ( !firstInRange+1:<>!nextInRange + & ( !firstInRange+2:!nextInRange&"," + | "-" + ) + -1+!nextInRange + | + ) + : ?accumulator + ) + & ( fasten + = [%( !accumulate + & (!sjt:?firstInRange)+1:?nextInRange + ) + ) + & ( rangePattern + = ( + | ? + ( !nextInRange + & 1+!nextInRange:?nextInRange + ) + ) + ( &!accumulate + | (#<>!nextInRange:!fasten) !rangePattern + ) + ) + & :?accumulator:?firstInRange + & !arg:(|#!fasten !rangePattern) + & str$!accumulator + ) +& ( test + = L A + . put$(!arg " ==>\n",LIN) + & ( !arg:(?,?) + & whl'(!arg:(?A,?arg)&(!A,!L):?L) + & whl'(!L:(?A,?L)&!A !arg:?arg) + | + ) + & out$(rangeExtract$!arg) + ) +& test + $ (0, 1, 2, 4, 6, 7, 8, 11, 12, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 27, 28, 29, 30, 31, 32, 33, 35, 36, + 37, 38, 39) diff --git a/Task/Range-extraction/C++/range-extraction.cpp b/Task/Range-extraction/C++/range-extraction.cpp new file mode 100644 index 0000000000..c9e3b54d79 --- /dev/null +++ b/Task/Range-extraction/C++/range-extraction.cpp @@ -0,0 +1,53 @@ +#include +#include +#include + +template + void extract_ranges(InIter begin, InIter end, std::ostream& os) +{ + if (begin == end) + return; + + int current = *begin++; + os << current; + int count = 1; + + while (begin != end) + { + int next = *begin++; + if (next == current+1) + ++count; + else + { + if (count > 2) + os << '-'; + else + os << ','; + if (count > 1) + os << current << ','; + os << next; + count = 1; + } + current = next; + } + + if (count > 1) + os << (count > 2? '-' : ',') << current; +} + +template + T* end(T (&array)[n]) +{ + return array+n; +} + +int main() +{ + int data[] = { 0, 1, 2, 4, 6, 7, 8, 11, 12, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 27, 28, 29, 30, 31, 32, 33, 35, 36, + 37, 38, 39 }; + + extract_ranges(data, end(data), std::cout); + std::cout << std::endl; +} diff --git a/Task/Range-extraction/C-sharp/range-extraction.cs b/Task/Range-extraction/C-sharp/range-extraction.cs new file mode 100644 index 0000000000..3abf3a0c1d --- /dev/null +++ b/Task/Range-extraction/C-sharp/range-extraction.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +class RangeExtraction +{ + static void Main() + { + const string testString = "0, 1, 2, 4, 6, 7, 8, 11, 12, 14,15, 16, 17, 18, 19, 20, 21, 22, 23, 24,25, 27, 28, 29, 30, 31, 32, 33, 35, 36,37, 38, 39"; + var result = String.Join(",", RangesToStrings(GetRanges(testString))); + Console.Out.WriteLine(result); + } + + public static IEnumerable> GetRanges(string testString) + { + var numbers = testString.Split(new[] { ',' }).Select(x => Convert.ToInt32(x)); + var current = new List(); + foreach (var n in numbers) + { + if (current.Count == 0) + { + current.Add(n); + } + else + { + if (current.Max() + 1 == n) + { + current.Add(n); + } + else + { + yield return current; + current = new List { n }; + } + } + } + yield return current; + } + + public static IEnumerable RangesToStrings(IEnumerable> ranges) + { + foreach (var range in ranges) + { + if (range.Count() == 1) + { + yield return range.Single().ToString(); + } + else if (range.Count() == 2) + { + yield return range.Min() + "," + range.Max(); + } + else + { + yield return range.Min() + "-" + range.Max(); + } + } + } +} diff --git a/Task/Range-extraction/C/range-extraction-1.c b/Task/Range-extraction/C/range-extraction-1.c new file mode 100644 index 0000000000..4c0fd09e59 --- /dev/null +++ b/Task/Range-extraction/C/range-extraction-1.c @@ -0,0 +1,36 @@ +#include +#include + +size_t rprint(char *s, int *x, int len) +{ +#define sep (a > s ? "," : "") /* use comma except before first output */ +#define ol (s ? 100 : 0) /* print only if not testing for length */ + int i, j; + char *a = s; + for (i = j = 0; i < len; i = ++j) { + for (; j < len - 1 && x[j + 1] == x[j] + 1; j++); + + if (i + 1 < j) + a += snprintf(s?a:s, ol, "%s%d-%d", sep, x[i], x[j]); + else + while (i <= j) + a += snprintf(s?a:s, ol, "%s%d", sep, x[i++]); + } + return a - s; +#undef sep +#undef ol +} + +int main() +{ + int x[] = { 0, 1, 2, 4, 6, 7, 8, 11, 12, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 27, 28, 29, 30, 31, 32, 33, 35, 36, + 37, 38, 39 }; + + char *s = malloc(rprint(0, x, sizeof(x) / sizeof(int)) + 1); + rprint(s, x, sizeof(x) / sizeof(int)); + printf("%s\n", s); + + return 0; +} diff --git a/Task/Range-extraction/C/range-extraction-2.c b/Task/Range-extraction/C/range-extraction-2.c new file mode 100644 index 0000000000..b8bbe64039 --- /dev/null +++ b/Task/Range-extraction/C/range-extraction-2.c @@ -0,0 +1 @@ +0-2,4,6-8,11,12,14-25,27-33,35-39 diff --git a/Task/Range-extraction/Common-Lisp/range-extraction.lisp b/Task/Range-extraction/Common-Lisp/range-extraction.lisp new file mode 100644 index 0000000000..1d0da1599f --- /dev/null +++ b/Task/Range-extraction/Common-Lisp/range-extraction.lisp @@ -0,0 +1,26 @@ +(defun format-with-ranges (list) + (unless list (return "")) + (with-output-to-string (s) + (let ((current (first list)) + (list (rest list)) + (count 1)) + (princ current s) + (dolist (next list) + (if (= next (1+ current)) + (incf count) + (progn (princ (if (> count 2) "-" ",") s) + (when (> count 1) + (princ current s) + (princ "," s)) + (princ next s) + (setf count 1))) + (setf current next)) + (when (> count 1) + (princ (if (> count 2) "-" ",") s) + (princ current s))))) + +CL-USER> (format-with-ranges (list 0 1 2 4 6 7 8 11 12 14 + 15 16 17 18 19 20 21 22 23 24 + 25 27 28 29 30 31 32 33 35 36 + 37 38 39)) +"0-2,4,6-8,11,12,14-25,27-33,35-39" diff --git a/Task/Range-extraction/D/range-extraction.d b/Task/Range-extraction/D/range-extraction.d new file mode 100644 index 0000000000..936ffdfb48 --- /dev/null +++ b/Task/Range-extraction/D/range-extraction.d @@ -0,0 +1,34 @@ +import std.stdio, std.conv, std.string, std.algorithm; + +string extractRanges(in int[] items) +in { + assert(items.isSorted()); +} body { + string[] ranges; + + for (size_t i = 0; i < items.length; i++) { + immutable low = items[i]; + while (i < (items.length - 1) && (items[i] + 1) == items[i + 1]) + i++; + immutable hi = items[i]; + + if (hi - low >= 2) + ranges ~= text(low, '-', hi); + else if (hi - low == 1) + ranges ~= text(low, ',', hi); + else + ranges ~= text(low); + } + + return ranges.join(","); +} + +void main() { + foreach (data; [[-8, -7, -6, -3, -2, -1, 0, 1, 3, 4, 5, 7, 8, 9, + 10, 11, 14, 15, 17, 18, 19, 20], + [0, 0, 0, 1, 1], + [0, 1, 2, 4, 6, 7, 8, 11, 12, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 27, 28, 29, 30, 31, + 32, 33, 35, 36, 37, 38, 39]]) + writeln(extractRanges(data)); +} diff --git a/Task/Range-extraction/DWScript/range-extraction.dwscript b/Task/Range-extraction/DWScript/range-extraction.dwscript new file mode 100644 index 0000000000..24b7837800 --- /dev/null +++ b/Task/Range-extraction/DWScript/range-extraction.dwscript @@ -0,0 +1,25 @@ +procedure ExtractRanges(const values : array of Integer); +begin + var i:=0; + while i0 then + Print(','); + Print(values[i]); + var j:=i+1; + while (ji then begin + if j=i+1 then + Print(',') + else Print('-'); + Print(values[j]); + end; + i:=j+1; + end; +end; + +ExtractRanges([ 0, 1, 2, 4, 6, 7, 8, 11, 12, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 27, 28, 29, 30, 31, 32, 33, 35, 36, + 37, 38, 39]); diff --git a/Task/Range-extraction/E/range-extraction-1.e b/Task/Range-extraction/E/range-extraction-1.e new file mode 100644 index 0000000000..2680d8079b --- /dev/null +++ b/Task/Range-extraction/E/range-extraction-1.e @@ -0,0 +1,17 @@ +def rex(numbers :List[int]) { + var region := 0..!0 + for n in numbers { region |= n..n } + var ranges := [] + for interval in region.getSimpleRegions() { + def a := interval.getOptStart() + def b := interval.getOptBound() - 1 + ranges with= if (b > a + 1) { + `$a-$b` + } else if (b <=> a + 1) { + `$a,$b` + } else { # b <=> a + `$a` + } + } + return ",".rjoin(ranges) +} diff --git a/Task/Range-extraction/E/range-extraction-2.e b/Task/Range-extraction/E/range-extraction-2.e new file mode 100644 index 0000000000..7b50de9a59 --- /dev/null +++ b/Task/Range-extraction/E/range-extraction-2.e @@ -0,0 +1,6 @@ +? rex([ +> 0, 1, 2, 4, 6, 7, 8, 11, 12, 14, +> 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, +> 25, 27, 28, 29, 30, 31, 32, 33, 35, 36, +> 37, 38, 39]) +# value: "0-2,4,6-8,11,12,14-25,27-33,35-39" diff --git a/Task/Range-extraction/Euphoria/range-extraction.euphoria b/Task/Range-extraction/Euphoria/range-extraction.euphoria new file mode 100644 index 0000000000..9e5c93c35b --- /dev/null +++ b/Task/Range-extraction/Euphoria/range-extraction.euphoria @@ -0,0 +1,32 @@ +function extract_ranges(sequence s) + integer first + sequence out + out = "" + if length(s) = 0 then + return out + end if + first = 1 + for i = 2 to length(s) do + if s[i] != s[i-1]+1 then + if first = i-1 then + out &= sprintf("%d,", s[first]) + elsif first = i-2 then + out &= sprintf("%d,%d,", {s[first],s[i-1]}) + else + out &= sprintf("%d-%d,", {s[first],s[i-1]}) + end if + first = i + end if + end for + if first = length(s) then + out &= sprintf("%d", s[first]) + elsif first = length(s)-1 then + out &= sprintf("%d,%d", {s[first],s[$]}) + else + out &= sprintf("%d-%d", {s[first],s[$]}) + end if + return out +end function + +puts(1, extract_ranges({0, 1, 2, 4, 6, 7, 8, 11, 12, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 38, 39})) diff --git a/Task/Range-extraction/Forth/range-extraction.fth b/Task/Range-extraction/Forth/range-extraction.fth new file mode 100644 index 0000000000..2c207cf834 --- /dev/null +++ b/Task/Range-extraction/Forth/range-extraction.fth @@ -0,0 +1,27 @@ +create values +here + 0 , 1 , 2 , 4 , 6 , 7 , 8 , 11 , 12 , 14 , + 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , + 25 , 27 , 28 , 29 , 30 , 31 , 32 , 33 , 35 , 36 , + 37 , 38 , 39 , +here swap - 1 cells / constant /values + +: clip 1- swap cell+ swap ; \ reduce array +: .range2 0 .r ." -" 0 .r ; \ difference two or more +: .range1 0 .r ." , " 0 .r ; \ difference one +: .range0 drop 0 .r ; \ no difference + \ select printing routine +create .range ' .range0 , ' .range1 , ' .range2 , + does> >r over over - 2 min cells r> + @ execute ; + +: .ranges ( a n --) + over @ dup >r >r \ setup first value + begin + clip dup \ check length array + while + over @ dup r@ 1+ = \ check if range breaks + if r> drop >r else r> r> .range ." , " dup >r >r then + repeat 2drop r> r> .range cr \ print last range +; + +values /values .ranges diff --git a/Task/Range-extraction/Go/range-extraction.go b/Task/Range-extraction/Go/range-extraction.go new file mode 100644 index 0000000000..3b0d7d2027 --- /dev/null +++ b/Task/Range-extraction/Go/range-extraction.go @@ -0,0 +1,55 @@ +package main + +import ( + "errors" + "fmt" + "strconv" + "strings" +) + +func main() { + rf, err := rangeFormat([]int{ + 0, 1, 2, 4, 6, 7, 8, 11, 12, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 27, 28, 29, 30, 31, 32, 33, 35, 36, + 37, 38, 39, + }) + if err != nil { + fmt.Println(err) + return + } + fmt.Println("range format:", rf) +} + +func rangeFormat(a []int) (string, error) { + if len(a) == 0 { + return "", nil + } + var parts []string + for n1 := 0; ; { + n2 := n1 + 1 + for n2 < len(a) && a[n2] == a[n2-1]+1 { + n2++ + } + s := strconv.Itoa(a[n1]) + if n2 == n1+2 { + s += "," + strconv.Itoa(a[n2-1]) + } else if n2 > n1+2 { + s += "-" + strconv.Itoa(a[n2-1]) + } + parts = append(parts, s) + if n2 == len(a) { + break + } + if a[n2] == a[n2-1] { + return "", errors.New(fmt.Sprintf( + "sequence repeats value %d", a[n2])) + } + if a[n2] < a[n2-1] { + return "", errors.New(fmt.Sprintf( + "sequence not ordered: %d < %d", a[n2], a[n2-1])) + } + n1 = n2 + } + return strings.Join(parts, ","), nil +} diff --git a/Task/Range-extraction/Groovy/range-extraction-1.groovy b/Task/Range-extraction/Groovy/range-extraction-1.groovy new file mode 100644 index 0000000000..4a2ac9e925 --- /dev/null +++ b/Task/Range-extraction/Groovy/range-extraction-1.groovy @@ -0,0 +1,12 @@ +def range = { s, e -> s == e ? "${s}," : s == e - 1 ? "${s},${e}," : "${s}-${e}," } + +def compressList = { list -> + def sb, start, end + (sb, start, end) = [''<<'', list[0], list[0]] + for (i in list[1..-1]) { + (sb, start, end) = i == end + 1 ? [sb, start, i] : [sb << range(start, end), i, i] + } + (sb << range(start, end))[0..-2].toString() +} + +def compressRanges = { expanded -> compressList(Eval.me('[' + expanded + ']')) } diff --git a/Task/Range-extraction/Groovy/range-extraction-2.groovy b/Task/Range-extraction/Groovy/range-extraction-2.groovy new file mode 100644 index 0000000000..c439ed2731 --- /dev/null +++ b/Task/Range-extraction/Groovy/range-extraction-2.groovy @@ -0,0 +1,7 @@ +def s = ''' + 0, 1, 2, 4, 6, 7, 8, 11, 12, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 27, 28, 29, 30, 31, 32, 33, 35, 36, + 37, 38, 39 +''' +println (compressRanges(s)) diff --git a/Task/Range-extraction/Haskell/range-extraction-1.hs b/Task/Range-extraction/Haskell/range-extraction-1.hs new file mode 100644 index 0000000000..3b64fd3b50 --- /dev/null +++ b/Task/Range-extraction/Haskell/range-extraction-1.hs @@ -0,0 +1,13 @@ +import Data.List (intercalate) + +extractRange :: [Int] -> String +extractRange = intercalate "," . f + where f :: [Int] -> [String] + f (x1 : x2 : x3 : xs) | x1 + 1 == x2 && x2 + 1 == x3 + = (show x1 ++ '-' : show xn) : f xs' + where (xn, xs') = g (x3 + 1) xs + g a (n : ns) | a == n = g (a + 1) ns + | otherwise = (a - 1, n : ns) + g a [] = (a - 1, []) + f (x : xs) = show x : f xs + f [] = [] diff --git a/Task/Range-extraction/Haskell/range-extraction-2.hs b/Task/Range-extraction/Haskell/range-extraction-2.hs new file mode 100644 index 0000000000..4996130c19 --- /dev/null +++ b/Task/Range-extraction/Haskell/range-extraction-2.hs @@ -0,0 +1,2 @@ +> extractRange $ [0..2] ++ 4 : [6..8] ++ 11 : 12 : [14..25] ++ [27..33] ++ [35..39] +"0-2,4,6-8,11,12,14-25,27-33,35-39" diff --git a/Task/Range-extraction/Icon/range-extraction.icon b/Task/Range-extraction/Icon/range-extraction.icon new file mode 100644 index 0000000000..3b82ccf7bd --- /dev/null +++ b/Task/Range-extraction/Icon/range-extraction.icon @@ -0,0 +1,33 @@ +procedure main() + + R := [ 0, 1, 2, 4, 6, 7, 8, 11, 12, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 27, 28, 29, 30, 31, 32, 33, 35, 36, + 37, 38, 39 ] + + write("Input list := ",list2string(R)) + write("Extracted sting := ",s := range_extract(R) | "FAILED") +end + +procedure range_extract(R) #: return string/range representation of a list of unique integers +local s,sep,low,high,x + + every if integer(x:= !R) ~= x then fail # ensure all are integers, + R := sort(set(R)) # unique, and sorted + + s := sep := "" + while s ||:= sep || ( low := high := get(R) ) do { # lower bound of range + sep := "," + while high := ( R[1] = high + 1 ) do get(R) # find the end of range + if high > low+1 then s ||:= "-" || high # - record range of 3+ + else if high = low+1 then push(R,high) # - range of 2, high becomes new low + } + return s +end + +procedure list2string(L) #: helper to convert list to string +local s + + every (s := "[ ") ||:= !L || " " + return s || "]" +end diff --git a/Task/Range-extraction/J/range-extraction-1.j b/Task/Range-extraction/J/range-extraction-1.j new file mode 100644 index 0000000000..1e1f3e271e --- /dev/null +++ b/Task/Range-extraction/J/range-extraction-1.j @@ -0,0 +1,4 @@ +require 'strings' +fmt=: [: ;@(8!:0) [`]`({. ; (',-' {~ 2 < #) ; {:)@.(2 <. #) +group=: <@fmt;.1~ 1 ~: 0 , 2 -~/\ ] +extractRange=: ',' joinstring group diff --git a/Task/Range-extraction/J/range-extraction-2.j b/Task/Range-extraction/J/range-extraction-2.j new file mode 100644 index 0000000000..fd779c824f --- /dev/null +++ b/Task/Range-extraction/J/range-extraction-2.j @@ -0,0 +1,2 @@ + extractRange 0 1 2 4 6 7 8 11 12 14 15 16 17 18 19 20 21 22 23 24 25 27 28 29 30 31 32 33 35 36 37 38 39 +0-2,4,6-8,11,12,14-25,27-33,35-39 diff --git a/Task/Range-extraction/Java/range-extraction.java b/Task/Range-extraction/Java/range-extraction.java new file mode 100644 index 0000000000..f4656bdfa6 --- /dev/null +++ b/Task/Range-extraction/Java/range-extraction.java @@ -0,0 +1,41 @@ +public class Range{ + public static void main(String[] args){ + System.out.println(compress2Range("-6, -3, -2, -1, 0, 1, 3, 4, 5, 7," + + " 8, 9, 10, 11, 14, 15, 17, 18, 19, 20")); + System.out.println(compress2Range( + "0, 1, 2, 4, 6, 7, 8, 11, 12, 14, " + + "15, 16, 17, 18, 19, 20, 21, 22, 23, 24," + + "25, 27, 28, 29, 30, 31, 32, 33, 35, 36," + + "37, 38, 39")); + } + + private static String compress2Range(String expanded){ + StringBuilder result = new StringBuilder(); + String[] nums = expanded.replace(" ", "").split(","); + int firstNum = Integer.parseInt(nums[0]); + int rangeSize = 0; + for(int i = 1; i < nums.length; i++){ + int thisNum = Integer.parseInt(nums[i]); + if(thisNum - firstNum - rangeSize == 1){ + rangeSize++; + }else{ + if(rangeSize != 0){ + result.append(firstNum).append((rangeSize == 1) ? ",": "-") + .append(firstNum+rangeSize).append(","); + rangeSize = 0; + }else{ + result.append(firstNum).append(","); + } + firstNum = thisNum; + } + } + if(rangeSize != 0){ + result.append(firstNum).append((rangeSize == 1) ? "," : "-"). + append(firstNum + rangeSize); + rangeSize = 0; + } else { + result.append(firstNum); + } + return result.toString(); + } +} diff --git a/Task/Range-extraction/JavaScript/range-extraction.js b/Task/Range-extraction/JavaScript/range-extraction.js new file mode 100644 index 0000000000..eab7cd466e --- /dev/null +++ b/Task/Range-extraction/JavaScript/range-extraction.js @@ -0,0 +1,35 @@ +function rangeExtraction(list) { + var len = list.length; + var out = []; + var i, j; + + for (i = 0; i < len; i = j + 1) { + // beginning of range or single + out.push(list[i]); + + // find end of range + for (var j = i + 1; j < len && list[j] == list[j-1] + 1; j++); + j--; + + if (i == j) { + // single number + out.push(","); + } else if (i + 1 == j) { + // two numbers + out.push(",", list[j], ","); + } else { + // range + out.push("-", list[j], ","); + } + } + out.pop(); // remove trailing comma + return out.join(""); +} + +// using print function as supplied by Rhino standalone +print(rangeExtraction([ + 0, 1, 2, 4, 6, 7, 8, 11, 12, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 27, 28, 29, 30, 31, 32, 33, 35, 36, + 37, 38, 39 +])); diff --git a/Task/Range-extraction/K/range-extraction-1.k b/Task/Range-extraction/K/range-extraction-1.k new file mode 100644 index 0000000000..b76c755ed2 --- /dev/null +++ b/Task/Range-extraction/K/range-extraction-1.k @@ -0,0 +1,3 @@ +grp : {(&~1=0,-':x)_ x} +fmt : {:[1=#s:$x;s;(*s),:[3>#s;",";"-"],*|s]} +erng: {{x,",",y}/,//'fmt'grp x} diff --git a/Task/Range-extraction/K/range-extraction-2.k b/Task/Range-extraction/K/range-extraction-2.k new file mode 100644 index 0000000000..67acdeeb8c --- /dev/null +++ b/Task/Range-extraction/K/range-extraction-2.k @@ -0,0 +1,2 @@ + erng 0 1 2 4 6 7 8 11 12 14 15 16 17 18 19 20 21 22 23 24 25 27 28 29 30 31 32 33 35 36 37 38 39 +"0-2,4,6-8,11,12,14-25,27-33,35-39" diff --git a/Task/Range-extraction/Liberty-BASIC/range-extraction.liberty b/Task/Range-extraction/Liberty-BASIC/range-extraction.liberty new file mode 100644 index 0000000000..e062d9b68a --- /dev/null +++ b/Task/Range-extraction/Liberty-BASIC/range-extraction.liberty @@ -0,0 +1,33 @@ +s$ = "0, 1, 2, 4, 6, 7, 8, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24," + _ + "25, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 38, 39" +print ExtractRange$( s$) +end + +function ExtractRange$( range$) + n = 1 + count = ItemCount( range$, ",") + while n <= count + startValue = val( word$( range$, n, ",")) + m = n + 1 + while m <= count + nextValue = val( word$( range$, m, ",")) + if nextValue - startValue <> m - n then exit while + m = m + 1 + wend + if m - n > 2 then + ExtractRange$ = ExtractRange$ + str$( startValue) + "-" + str$( startValue + m - n - 1) + "," + else + for i = n to m - 1 + ExtractRange$ = ExtractRange$ + str$( startValue + i - n) + "," + next i + end if + n = m + wend + ExtractRange$ = left$( ExtractRange$, len( ExtractRange$) - 1) +end function + +function ItemCount( list$, separator$) + while word$( list$, ItemCount + 1, separator$) <> "" + ItemCount = ItemCount + 1 + wend +end function diff --git a/Task/Range-extraction/MUMPS/range-extraction.mumps b/Task/Range-extraction/MUMPS/range-extraction.mumps new file mode 100644 index 0000000000..4cafed624a --- /dev/null +++ b/Task/Range-extraction/MUMPS/range-extraction.mumps @@ -0,0 +1,17 @@ +RANGCONT(X) ;Integer range contraction + NEW Y,I,CONT,NOTFIRST,CURR,PREV,NEXT,SEQ SET Y="",SEQ=0,PREV="",CONT=0 + FOR I=1:1:$LENGTH(X,",") DO + .SET NOTFIRST=$LENGTH(Y),CURR=$PIECE(X,",",I),NEXT=$PIECE(X,",",I+1) + .FOR Q:$EXTRACT(CURR)'=" " S CURR=$EXTRACT(CURR,2,$LENGTH(CURR)) ;clean up leading spaces + .S SEQ=((CURR-1)=PREV)&((CURR+1)=NEXT) + .IF 'NOTFIRST SET Y=CURR + .IF NOTFIRST DO + ..;Order matters due to flags + ..IF CONT&SEQ ;Do nothing + ..IF 'CONT&'SEQ SET Y=Y_","_CURR + ..IF CONT&'SEQ SET Y=Y_CURR,CONT=0 + ..IF 'CONT&SEQ SET Y=Y_"-",CONT=1 + .SET PREV=CURR + IF CONT SET Y=Y_PREV + K I,CONT,NOTFIRST,CURR,PREV,NEXT,SEQ + QUIT Y diff --git a/Task/Range-extraction/Mathematica/range-extraction.math b/Task/Range-extraction/Mathematica/range-extraction.math new file mode 100644 index 0000000000..57a959dc9c --- /dev/null +++ b/Task/Range-extraction/Mathematica/range-extraction.math @@ -0,0 +1,5 @@ +rangeExtract[data_List] := ToString[Row[ + Riffle[ + Flatten[Split[Sort[data], #2 - #1 == 1 &] /. {a_Integer, __, b_} :> Row[{a, "-", b}]], + ","] + ]]; diff --git a/Task/Range-extraction/NetRexx/range-extraction.netrexx b/Task/Range-extraction/NetRexx/range-extraction.netrexx new file mode 100644 index 0000000000..19ab5d9ee6 --- /dev/null +++ b/Task/Range-extraction/NetRexx/range-extraction.netrexx @@ -0,0 +1,37 @@ +/*NetRexx program to test range extraction. *************************** +* 07.08.2012 Walter Pachl derived from my Rexx Version +* Changes: line continuation in aaa assignment changed +* 1e99 -> 999999999 +* Do -> Loop +* words(aaa) -> aaa.words() +* word(aaa,i) -> aaa.word(i) +**********************************************************************/ +Say 'NetRexx program derived from Rexx' +aaa='0 1 2 4 6 7 8 11 12 14 15 16 17 18 19 20 21 22 23 24 25 27 28 29' +aaa=aaa' 30 31 32 33 35 36 37 38 39' +say 'old='aaa; +aaa=aaa 999999999 /* artificial number at the end */ +i=0 /* initialize index */ +ol='' /* initialize output string */ +comma='' /* will become a ',' lateron */ +inrange=0 +Loop While i<=aaa.words /* loop for all numbers */ + i=i+1 /* index of next number */ + n=aaa.word(i) /* the now current number */ + If n=999999999 Then Leave /* we are at the end */ + If inrange Then Do /* range was opened */ + If aaa.word(i+1)<>n+1 Then Do /* following word not in range */ + ol=ol||n /* so this number is the end */ + inrange=0 /* and the range is over */ + End /* else ignore current number */ + End + Else Do /* not in a range */ + ol=ol||comma||n /* add number (with comma) */ + comma=',' /* to the output string */ + If aaa.word(i+2)=n+2 Then Do /* if the nr after the next fits */ + inrange=1 /* open a range */ + ol=ol'-' /* append the range connector */ + End + End + End +Say 'new='ol diff --git a/Task/Range-extraction/OCaml/range-extraction.ocaml b/Task/Range-extraction/OCaml/range-extraction.ocaml new file mode 100644 index 0000000000..8efc743386 --- /dev/null +++ b/Task/Range-extraction/OCaml/range-extraction.ocaml @@ -0,0 +1,21 @@ +let range_extract = function + | [] -> [] + | x::xs -> + let f (i,j,ret) k = + if k = succ j then (i,k,ret) else (k,k,(i,j)::ret) in + let (m,n,ret) = List.fold_left f (x,x,[]) xs in + List.rev ((m,n)::ret) + +let string_of_range rng = + let str (a,b) = + if a = b then string_of_int a + else Printf.sprintf "%d%c%d" a (if b = succ a then ',' else '-') b in + String.concat "," (List.map str rng) + +let () = + let li = + [ 0; 1; 2; 4; 6; 7; 8; 11; 12; 14; 15; 16; 17; 18; 19; 20; 21; + 22; 23; 24; 25; 27; 28; 29; 30; 31; 32; 33; 35; 36; 37; 38; 39 ] + in + let rng = range_extract li in + print_endline(string_of_range rng) diff --git a/Task/Range-extraction/Oberon-2/range-extraction.oberon-2 b/Task/Range-extraction/Oberon-2/range-extraction.oberon-2 new file mode 100644 index 0000000000..2662a6b6e0 --- /dev/null +++ b/Task/Range-extraction/Oberon-2/range-extraction.oberon-2 @@ -0,0 +1,92 @@ +MODULE RangeExtraction; +IMPORT Out; + +PROCEDURE Range(s: ARRAY OF INTEGER); +VAR + i,j: INTEGER; + + PROCEDURE Emit(sep: CHAR); + BEGIN + IF i > 2 THEN + Out.Int(s[j],3);Out.Char('-');Out.Int(s[j + i - 1],3);Out.Char(sep); + INC(j,i) + ELSE + Out.Int(s[j],3);Out.Char(sep); + INC(j) + END; + END Emit; + +BEGIN + j := 0;i := -1; + LOOP + INC(i); + IF j + i >= LEN(s) THEN + Emit(0AX); + EXIT + ELSIF s[j + i] # (s[j] + i) THEN + Emit(','); + i := 0; + END + END +END Range; + +VAR + seq0: ARRAY 33 OF INTEGER; + seq1: ARRAY 20 OF INTEGER; +BEGIN + seq0[0] := 0; + seq0[1] := 1; + seq0[2] := 2; + seq0[3] := 4; + seq0[4] := 6; + seq0[5] := 7; + seq0[6] := 8; + seq0[7] := 11; + seq0[8] := 12; + seq0[9] := 14; + seq0[10] := 15; + seq0[11] := 16; + seq0[12] := 17; + seq0[13] := 18; + seq0[14] := 19; + seq0[15] := 20; + seq0[16] := 21; + seq0[17] := 22; + seq0[18] := 23; + seq0[19] := 24; + seq0[20] := 25; + seq0[21] := 27; + seq0[22] := 28; + seq0[23] := 29; + seq0[24] := 30; + seq0[25] := 31; + seq0[26] := 32; + seq0[27] := 33; + seq0[28] := 35; + seq0[29] := 36; + seq0[30] := 37; + seq0[31] := 38; + seq0[32] := 39; + Range(seq0); + seq1[0] := -6; + seq1[1] := -3; + seq1[2] := -2; + seq1[3] := -1; + seq1[4] := 0; + seq1[5] := 1; + seq1[6] := 3; + seq1[7] := 4; + seq1[8] := 5; + seq1[9] := 7; + seq1[10] := 8; + seq1[11] := 9; + seq1[12] := 10; + seq1[13] := 11; + seq1[14] := 14; + seq1[15] := 15; + seq1[16] := 17; + seq1[17] := 18; + seq1[18] := 19; + seq1[19] := 20; + Range(seq1) +END RangeExtraction. diff --git a/Task/Range-extraction/OxygenBasic/range-extraction.oxy b/Task/Range-extraction/OxygenBasic/range-extraction.oxy new file mode 100644 index 0000000000..ed2c61639e --- /dev/null +++ b/Task/Range-extraction/OxygenBasic/range-extraction.oxy @@ -0,0 +1,38 @@ + dim sys ints(100) + ints=> + 0, 1, 2, 4, 6, 7, 8, 11, 12, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 27, 28, 29, 30, 31, 32, 33, 35, 36, + 37, 38, 39 + + function ShowRange(sys*i) as string + '================================== + pr="" + n=0 + e=0 + j=0 + k=-1 + do + j++ + n=i(j) + e=i(j+1) + if e=0 then + pr+=k "-" i(j+1) ", " 'RANGE OF VALUES + j++ + k=-1 + else + pr+=n ", " 'SINGLE VALUES + end if + end if + end do + return left pr, len(pr)-2 + end function + + + print ShowRange ints diff --git a/Task/Range-extraction/Oz/range-extraction-1.oz b/Task/Range-extraction/Oz/range-extraction-1.oz new file mode 100644 index 0000000000..47b0006861 --- /dev/null +++ b/Task/Range-extraction/Oz/range-extraction-1.oz @@ -0,0 +1,47 @@ +declare + fun {Extract Xs} + {CommaSeparated + {Map {ExtractRanges Xs} RangeToString}} + end + + fun {ExtractRanges Xs} + fun {Loop Ys Start End} + case Ys + of Y|Yr andthen Y == End+1 then {Loop Yr Start Y} + [] Y|Yr then Start#End|{Loop Yr Y Y} + [] nil then [Start#End] + end + end + in + case Xs + of X|Xr then {Loop Xr X X} + [] nil then nil + end + end + + fun {RangeToString S#E} + if E-S >= 2 then + {VirtualString.toString S#"-"#E} + else + {CommaSeparated + {Map {List.number S E 1} Int.toString}} + end + end + + fun {CommaSeparated Xs} + {Flatten {Intersperse "," Xs}} + end + + fun {Intersperse Sep Xs} + case Xs of X|Y|Xr then + X|Sep|{Intersperse Sep Y|Xr} + else + Xs + end + end +in + {System.showInfo + {Extract [ 0 1 2 4 6 7 8 11 12 14 + 15 16 17 18 19 20 21 22 23 24 + 25 27 28 29 30 31 32 33 35 36 + 37 38 39 ]}} diff --git a/Task/Range-extraction/Oz/range-extraction-2.oz b/Task/Range-extraction/Oz/range-extraction-2.oz new file mode 100644 index 0000000000..b8bbe64039 --- /dev/null +++ b/Task/Range-extraction/Oz/range-extraction-2.oz @@ -0,0 +1 @@ +0-2,4,6-8,11,12,14-25,27-33,35-39 diff --git a/Task/Range-extraction/PL-I/range-extraction-1.pli b/Task/Range-extraction/PL-I/range-extraction-1.pli new file mode 100644 index 0000000000..9014070d99 --- /dev/null +++ b/Task/Range-extraction/PL-I/range-extraction-1.pli @@ -0,0 +1,48 @@ +/* Modified 19 November 2011 to meet requirement that there be at */ +/* least 3 items in a run. */ +range_extraction: /* 17 August 2010 */ + procedure options (main); + declare (c, d) character (1); + declare (old, new, initial) fixed binary (31); + declare in file; + declare out file output; + + open file (in) title ('/range2.dat,type(text),recsize(80)' ); + open file (out) output title ('/range2.out,type(text),recsize(70)'); + + c = ' '; d = ','; + get file (in) list (old); + do forever; + initial = old; + on endfile (in) begin; + put file (out) edit (c, trim(old)) (a); + stop; + end; + get file (in) list (new); + if new = old+1 then + do; /* we have a run. */ + on endfile (in) begin; + if old > initial+1 then d = '-'; + put file (out) edit (c, trim(initial), d, trim(old) ) (a); + stop; + end; + do while (new = old+1); + old = new; + get file (in) list (new); + end; + /* At this point, old holds the last in a run; */ + /* initial holds the first in a run. */ + /* if there are only two members in a run, don't use the */ + /* range notation. */ + if old > initial+1 then d = '-'; + put file (out) edit (c, trim(initial), d, trim(old) ) (a); + old = new; + end; + else /* we have an isolated value. */ + do; + put file (out) edit (c, trim(old)) (a); + old = new; + end; + c, d = ','; + end; +end range_extraction; diff --git a/Task/Range-extraction/PL-I/range-extraction-2.pli b/Task/Range-extraction/PL-I/range-extraction-2.pli new file mode 100644 index 0000000000..1da5a94ca5 --- /dev/null +++ b/Task/Range-extraction/PL-I/range-extraction-2.pli @@ -0,0 +1 @@ + 0-2,4,6-8,11-12,14-25,27-33,35-39 diff --git a/Task/Range-extraction/PL-I/range-extraction-3.pli b/Task/Range-extraction/PL-I/range-extraction-3.pli new file mode 100644 index 0000000000..ae893dafc3 --- /dev/null +++ b/Task/Range-extraction/PL-I/range-extraction-3.pli @@ -0,0 +1 @@ + 0-2,4,6-8,11,12,14-25,27-33,35-39 diff --git a/Task/Range-extraction/Perl-6/range-extraction.pl6 b/Task/Range-extraction/Perl-6/range-extraction.pl6 new file mode 100644 index 0000000000..bdf0fdd36a --- /dev/null +++ b/Task/Range-extraction/Perl-6/range-extraction.pl6 @@ -0,0 +1,24 @@ +sub range-extraction (*@ints) { + my $prev = NaN; + my @ranges; + + for @ints -> $int { + if $int == $prev + 1 { + @ranges[*-1].push: $int; + } + else { + @ranges.push: [$int]; + } + $prev = $int; + } + join ',', @ranges.map: -> @r { @r > 2 ?? "@r[0]-@r[*-1]" !! @r } +} + +say range-extraction + -6, -3, -2, -1, 0, 1, 3, 4, 5, 7, 8, 9, 10, 11, 14, 15, 17, 18, 19, 20; + +say range-extraction + 0, 1, 2, 4, 6, 7, 8, 11, 12, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 27, 28, 29, 30, 31, 32, 33, 35, 36, + 37, 38, 39; diff --git a/Task/Range-extraction/Perl/range-extraction.pl b/Task/Range-extraction/Perl/range-extraction.pl new file mode 100644 index 0000000000..54e2d8fdcd --- /dev/null +++ b/Task/Range-extraction/Perl/range-extraction.pl @@ -0,0 +1,15 @@ +sub rangext { + my $str = join ' ', @_; + 1 while $str =~ s{([+-]?\d+) ([+-]?\d+)} + {$1.(abs($2 - $1) == 1 ? '~' : ',').$2}eg; # abs for neg ranges + $str =~ s/(\d+)~(?:[+-]?\d+~)+([+-]?\d+)/$1-$2/g; + $str =~ tr/~/,/; + return $str; +} + +# Test and display +my @test = qw(0 1 2 4 6 7 8 11 12 14, + 15 16 17 18 19 20 21 22 23 24, + 25 27 28 29 30 31 32 33 35 36, + 37 38 39); +print rangext(@test), "\n"; diff --git a/Task/Range-extraction/PicoLisp/range-extraction.l b/Task/Range-extraction/PicoLisp/range-extraction.l new file mode 100644 index 0000000000..e90d206a57 --- /dev/null +++ b/Task/Range-extraction/PicoLisp/range-extraction.l @@ -0,0 +1,11 @@ +(de rangeextract (Lst) + (glue "," + (make + (while Lst + (let (N (pop 'Lst) M N) + (while (= (inc M) (car Lst)) + (setq M (pop 'Lst)) ) + (cond + ((= N M) (link N)) + ((= (inc N) M) (link N M)) + (T (link (list N '- M))) ) ) ) ) ) ) diff --git a/Task/Range-extraction/Prolog/range-extraction.pro b/Task/Range-extraction/Prolog/range-extraction.pro new file mode 100644 index 0000000000..2a181d5cf7 --- /dev/null +++ b/Task/Range-extraction/Prolog/range-extraction.pro @@ -0,0 +1,89 @@ +range_extract :- + L = [0, 1, 2, 4, 6, 7, 8, 11, 12, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 27, 28, 29, 30, 31, 32, 33, 35, 36, + 37, 38, 39] , + writeln(L), + pack_Range(L, LP), + maplist(study_Range, R, LP), + extract_Range(LA, R), + atom_chars(A, LA), + writeln(A). + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% extract_Range(?In, ?Out) +% In : '-6,-3--1,3-5,7-11,14,15,17-20' => +% Out : [-6], [-3--1], [3-5],[7-11], [14],[15], [17-20] +% +extract_Range([], []). + + +extract_Range(X , [Range | Y1]) :- + get_Range(X, U-U, Range, X1), + extract_Range(X1, Y1). + + + +get_Range([], Range-[], Range, []). +get_Range([','|B], Range-[], Range, B) :- !. + +get_Range([A | B], EC, Range, R) :- + append_dl(EC, [A | U]-U, NEC), + get_Range(B, NEC, Range, R). + + +append_dl(X-Y, Y-Z, X-Z). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% study Range(?In, ?Out) +% In : [-6] +% Out : [-6,-6] +% +% In : [-3--1] +% Out : [-3, -1] +% +study_Range(Range1, [Deb, Deb]) :- + catch(number_chars(Deb, Range1), Deb, false). + +study_Range(Range1, [Deb, Fin]) :- + append(A, ['-'|B], Range1), + A \= [], + number_chars(Deb, A), + number_chars(Fin, B). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +:- use_module(library(clpfd)). +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Pack Range(?In, ?Out) +% In : -6, +% Out : [-6] +% +% In : -3, -2,-1 +% Out : [-3,-1] +% +pack_Range([],[]). + +pack_Range([X|Rest],[[X | V]|Packed]):- + run(X,Rest, [X|V], RRest), + pack_Range(RRest,Packed). + + + +run(Fin,[Other|RRest], [Deb, Fin],[Other|RRest]):- + Fin #\= Deb, + Fin #\= Deb + 1, + Other #\= Fin+1. + +run(Fin,[],[_Var, Fin],[]). + +run(Var,[Var1|LRest],[Deb, Fin], RRest):- + Fin #\= Deb, + Fin #\= Deb + 1, + Var1 #= Var + 1, + run(Var1,LRest,[Deb, Fin], RRest). + +run(Val,[Other|RRest], [Val, Val],[Other|RRest]). diff --git a/Task/Range-extraction/PureBasic/range-extraction.purebasic b/Task/Range-extraction/PureBasic/range-extraction.purebasic new file mode 100644 index 0000000000..8a33657d36 --- /dev/null +++ b/Task/Range-extraction/PureBasic/range-extraction.purebasic @@ -0,0 +1,70 @@ +DataSection + Data.i 33 ;count of elements to be read + Data.i 0, 1, 2, 4, 6, 7, 8, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 + Data.i 25, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 38, 39 +EndDataSection + +NewList values() +;setup list +Define elementCount, i +Read.i elementCount +For i = 1 To elementCount + AddElement(values()): Read.i values() +Next + +Procedure.s rangeExtract(List values()) + Protected listSize = ListSize(values()) - 1 + Protected rangeMarker, rangeStart, rangeIncrement, retraceSteps, rangeSize, endOfRange, output.s, sub.s + + ForEach values() + rangeStart = values(): + sub = Str(rangeStart) + If NextElement(values()) + retraceSteps = 1 + rangeIncrement = values() - rangeStart + If rangeIncrement = 1 Or rangeIncrement = -1 + ;found start of possible range + If ListIndex(values()) <> listSize + retraceSteps = 2 + rangeSize = 2 + endOfRange = #False + rangeMarker = values() + While NextElement(values()) + If values() - rangeMarker <> rangeIncrement + endOfRange = #True + Break + EndIf + rangeSize + 1 + rangeMarker = values() + Wend + + If rangeSize > 2 + sub = Str(rangeStart) + "-" + Str(rangeMarker) + If Not endOfRange + retraceSteps = 0 ;at end of list + Else + retraceSteps = 1 + EndIf + EndIf + EndIf + EndIf + + ;return to the value before look-aheads + While retraceSteps > 0 + PreviousElement(values()): retraceSteps - 1 + Wend + EndIf + + output + sub + "," + Next + + ProcedureReturn RTrim(output, ",") +EndProcedure + +If OpenConsole() + PrintN(rangeExtract(values())) + + Print(#CRLF$ + #CRLF$ + "Press ENTER to exit") + Input() + CloseConsole() +EndIf diff --git a/Task/Range-extraction/Python/range-extraction-1.py b/Task/Range-extraction/Python/range-extraction-1.py new file mode 100644 index 0000000000..862626e1c7 --- /dev/null +++ b/Task/Range-extraction/Python/range-extraction-1.py @@ -0,0 +1,19 @@ +def rangeextract(lst): + lenlst = len(lst) + i, ranges = 0, [] + while i< lenlst: + low = lst[i] + while i = 2 else + ('%i,%i' % (low, hi) if hi - low == 1 else + '%i' % low) ) + i += 1 + return ','.join(ranges) + +lst = [ 0, 1, 2, 4, 6, 7, 8, 11, 12, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 27, 28, 29, 30, 31, 32, 33, 35, 36, + 37, 38, 39] +print(rangeextract(lst)) diff --git a/Task/Range-extraction/Python/range-extraction-2.py b/Task/Range-extraction/Python/range-extraction-2.py new file mode 100644 index 0000000000..662e67ca8c --- /dev/null +++ b/Task/Range-extraction/Python/range-extraction-2.py @@ -0,0 +1,26 @@ +def grouper(lst): + src = iter(lst) + acc = [ next(src) ] + for i in src: + if i == acc[-1] + 1: acc.append(i) + else: + yield acc + acc = [i] + yield acc + raise StopIteration() + +def rangegrouper(lst): + for g in grouper(lst): + if len(g) == 2: + # satisfy rule that only runs longer than 2 are grouped + a,b = g + yield [a] + yield [b] + else: yield g + raise StopIteration() + +input= [0, 1, 2, 4, 6, 7, 8, 11, 12, 14,15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 28, 29, 30, 31, 32, 33, 35, 36,37, 38, 39] +print list(rangegrouper(input)) # print groups +as_strings= ['%s%s%s' % ((g[0],'-',g[-1]) if len(g) > 1 else (g[0],'','')) for g in rangegrouper(input)] +print as_strings +print ', '.join(as_strings) diff --git a/Task/Range-extraction/Qi/range-extraction.qi b/Task/Range-extraction/Qi/range-extraction.qi new file mode 100644 index 0000000000..c63cc12a5f --- /dev/null +++ b/Task/Range-extraction/Qi/range-extraction.qi @@ -0,0 +1,17 @@ +(define make-range + Start Start -> ["," Start] + Start End -> ["," Start "," End] where (= End (+ Start 1)) + Start End -> ["," Start "-" End]) + +(define range-extract-0 + Start End [] -> (make-range Start End) + Start End [A|As] -> (range-extract-0 Start A As) where (= (+ 1 End) A) + Start End [A|As] -> (append (make-range Start End) (range-extract-0 A A As))) + +(define range-extract + [A |As] -> (FORMAT NIL "~{~a~}" (tail (range-extract-0 A A As)))) + +(range-extract [ 0 1 2 4 6 7 8 11 12 14 + 15 16 17 18 19 20 21 22 23 24 + 25 27 28 29 30 31 32 33 35 36 + 37 38 39]) diff --git a/Task/Range-extraction/REXX/range-extraction-1.rexx b/Task/Range-extraction/REXX/range-extraction-1.rexx new file mode 100644 index 0000000000..d4d22efbc9 --- /dev/null +++ b/Task/Range-extraction/REXX/range-extraction-1.rexx @@ -0,0 +1,30 @@ +/*REXX program to test range extraction. */ +aaa='0 1 2 4 6 7 8 11 12 14 15 16 17 18 19 20 21 22', + '23 24 25 27 28 29 30 31 32 33 35 36 37 38 39' +say 'old =' aaa; say /*show the old range of numbers. */ +new= /*new list (maybe with ranges). */ +w=words(aaa) /*number of numbers in the list. */ + /*Note: index of DO (J) gets modified within loop !.*/ + do j=1 to w /*step through num word in list.*/ + _=word(aaa,j) /*get the Jth number in the list.*/ + new=new',' _ /*append Jth number to new list.*/ + inc=1 /*start with an increment of one.*/ + + do k=j+1 to w /*now, search for end of range. */ + __=word(aaa,k) /*get the Kth number in the list.*/ + if __ \== _+inc then leave /*this number 1 > than prev? */ + inc=inc+1 /*yes, then increase the range. */ + g_ = __ /*placeholder for last good num. */ + end /*k*/ + + k=k-1 /*fudge the Kth word (subtract 1)*/ + if k == j then iterate /*no range? Then keep truckin'.*/ + if g_ == _+1 then iterate /*range of 1? Then keep truckin'.*/ + new=new'-'g_ /*indicate a range of numbers. */ + j=k /*Bad practice!! Change DO index.*/ + end /*j*/ + +new=substr(new,3) /*remove extraneous leading comma*/ +new=space(new,0) /*remove all spaces (blanks). */ +say 'new =' new /*display new list of numbers. */ + /*stick a fork in it, we're done.*/ diff --git a/Task/Range-extraction/REXX/range-extraction-2.rexx b/Task/Range-extraction/REXX/range-extraction-2.rexx new file mode 100644 index 0000000000..706680a124 --- /dev/null +++ b/Task/Range-extraction/REXX/range-extraction-2.rexx @@ -0,0 +1,31 @@ +/*REXX program to test range extraction. ****************************** +* 07.08.2012 Walter Pachl +**********************************************************************/ +aaa='0 1 2 4 6 7 8 11 12 14 15 16 17 18 19 20 21 22 23 24 25 27 28 29', + '30 31 32 33 35 36 37 38 39' +say 'old='aaa; +aaa=aaa 1e99 /* artificial number at the end */ +i=0 /* initialize index */ +ol='' /* initialize output string */ +comma='' /* will become a ',' lateron */ +inrange=0 +Do While i<=words(aaa) /* loop for all numbers */ + i=i+1 /* index of next number */ + n=word(aaa,i) /* the now current number */ + If n=1e99 Then Leave /* we are at the end */ + If inrange Then Do /* range was opened */ + If word(aaa,i+1)<>n+1 Then Do /* following word not in range */ + ol=ol||n /* so this number is the end */ + inrange=0 /* and the range is over */ + End /* else ignore current number */ + End + Else Do /* not in a range */ + ol=ol||comma||n /* add number (with comma) */ + comma=',' /* to the output string */ + If word(aaa,i+2)=n+2 Then Do /* if the nr after the next fits */ + inrange=1 /* open a range */ + ol=ol'-' /* append the range connector */ + End + End + End +Say 'new='ol diff --git a/Task/Range-extraction/Ruby/range-extraction.rb b/Task/Range-extraction/Ruby/range-extraction.rb new file mode 100644 index 0000000000..804b53e2da --- /dev/null +++ b/Task/Range-extraction/Ruby/range-extraction.rb @@ -0,0 +1,27 @@ +def range_extract(l) + sorted = l.sort + range = [] + start = sorted.first + # pad the list with a big value, so that the last loop iteration will + # appended something to the range + sorted.concat([Float::MAX]).each_cons(2) do |prev,n| + if prev.succ < n + if start == prev + range << start.to_s + else + range << "%d%s%d" % [start, (start.succ == prev ? "," : "-"), prev] + end + start = n + end + end + range.join(',') +end + +lst = [ + 0, 1, 2, 4, 6, 7, 8, 11, 12, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 27, 28, 29, 30, 31, 32, 33, 35, 36, + 37, 38, 39 +] + +p rng = range_extract(lst) diff --git a/Task/Range-extraction/SNOBOL4/range-extraction.sno b/Task/Range-extraction/SNOBOL4/range-extraction.sno new file mode 100644 index 0000000000..7992fe4c38 --- /dev/null +++ b/Task/Range-extraction/SNOBOL4/range-extraction.sno @@ -0,0 +1,22 @@ +* # Absolute value + define('abs(n)') :(abs_end) +abs abs = ~(abs = lt(n,0) -n) n :(return) +abs_end + + define('rangext(str)d1,d2') :(rangext_end) +rangext num = ('+' | '-' | '') span('0123456789') +rxt1 str ',' span(' ') = ' ' :s(rxt1) +rxt2 str num . d1 ' ' num . d2 = ++ d1 ('~,' ? *eq(abs(d2 - d1),1) '~' | ',') d2 :s(rxt2) +rxt3 str ('~' | '-') num '~' = '-' :s(rxt3) +rxt4 str '~' = ',' :s(rxt4) + rangext = str :(return) +rangext_end + +* # Test and display + test = '0, 1, 2, 4, 6, 7, 8, 11, 12, 14, ' ++ '15, 16, 17, 18, 19, 20, 21, 22, 23, 24, ' ++ '25, 27, 28, 29, 30, 31, 32, 33, 35, 36, ' ++ '37, 38, 39' + output = rangext(test) +end diff --git a/Task/Range-extraction/Scala/range-extraction.scala b/Task/Range-extraction/Scala/range-extraction.scala new file mode 100644 index 0000000000..b3b886194b --- /dev/null +++ b/Task/Range-extraction/Scala/range-extraction.scala @@ -0,0 +1,25 @@ +object Range { + def spanRange(ls:List[Int])={ + var last=ls.head + ls span {x => val b=x<=last+1; last=x; b} + } + + def toRangeList(ls:List[Int]):List[List[Int]]=ls match { + case Nil => List() + case _ => spanRange(ls) match { + case (range, Nil) => List(range) + case (range, rest) => range :: toRangeList(rest) + } + } + + def toRangeString(ls:List[List[Int]])=ls map {r=> + if(r.size<3) r mkString "," + else r.head + "-" + r.last + } mkString "," + + def main(args: Array[String]): Unit = { + var l=List(0, 1, 2, 4, 6, 7, 8, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, + 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 38, 39) + println(toRangeString(toRangeList(l))) + } +} diff --git a/Task/Range-extraction/Scheme/range-extraction.ss b/Task/Range-extraction/Scheme/range-extraction.ss new file mode 100644 index 0000000000..a481fb2bc6 --- /dev/null +++ b/Task/Range-extraction/Scheme/range-extraction.ss @@ -0,0 +1,28 @@ +(define (make-range start end) + (cond ((= start end) + `("," ,start)) + ((= end (+ start 1)) + `("," ,start "," ,end)) + (else + `("," ,start "-" ,end)))) + +(define (range-extract-0 start end a) + (cond ((null? a) + (make-range start end)) + ((= (+ 1 end) (car a)) + (range-extract-0 start (car a) (cdr a))) + (else + (append (make-range start end) + (range-extract-0 (car a) (car a) (cdr a)))))) + +(define (range-extract a) + (apply string-append (map (lambda (x) + (if (number? x) + (number->string x) + x)) + (cdr (range-extract-0 (car a) (car a) (cdr a)))))) + +(range-extract '( 0 1 2 4 6 7 8 11 12 14 + 15 16 17 18 19 20 21 22 23 24 + 25 27 28 29 30 31 32 33 35 36 + 37 38 39)) diff --git a/Task/Range-extraction/Seed7/range-extraction.seed7 b/Task/Range-extraction/Seed7/range-extraction.seed7 new file mode 100644 index 0000000000..de72fb1105 --- /dev/null +++ b/Task/Range-extraction/Seed7/range-extraction.seed7 @@ -0,0 +1,32 @@ +$ include "seed7_05.s7i"; + +const func string: rangeExtraction (in array integer: numbers) is func + result + var string: rangeStri is ""; + local + var integer: index is 1; + var integer: index2 is 1; + begin + while index <= length(numbers) do + while index2 <= pred(length(numbers)) and numbers[succ(index2)] = succ(numbers[index2]) do + incr(index2); + end while; + if succ(index) < index2 then + rangeStri &:= "," <& numbers[index] <& "-" <& numbers[index2]; + else + while index <= index2 do + rangeStri &:= "," <& numbers[index]; + incr(index); + end while; + end if; + incr(index2); + index := index2; + end while; + rangeStri := rangeStri[2 ..]; + end func; + +const proc: main is func + begin + writeln(rangeExtraction([] (0, 1, 2, 4, 6, 7, 8, 11, 12, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 38, 39))); + end func; diff --git a/Task/Range-extraction/TUSCRIPT/range-extraction-1.tuscript b/Task/Range-extraction/TUSCRIPT/range-extraction-1.tuscript new file mode 100644 index 0000000000..29597e59b7 --- /dev/null +++ b/Task/Range-extraction/TUSCRIPT/range-extraction-1.tuscript @@ -0,0 +1,13 @@ +$$ MODE TUSCRIPT +MODE DATA +$$ numbers=* +0, 1, 2, 4, 6, 7, 8, 11, 12, 14, +15, 16, 17, 18, 19, 20, 21, 22, 23, 24, +25, 27, 28, 29, 30, 31, 32, 33, 35, 36, +37, 38, 39 +$$ MODE TUSCRIPT +numbers=EXCHANGE (numbers,":,><<> :':") +unrangednrs=JOIN (numbers,"") +rangednrs=COMBINE (unrangednrs,"") +rangednrs=EXCHANGE (rangednrs,":':,:") +PRINT rangednrs diff --git a/Task/Range-extraction/TUSCRIPT/range-extraction-2.tuscript b/Task/Range-extraction/TUSCRIPT/range-extraction-2.tuscript new file mode 100644 index 0000000000..1560e8635a --- /dev/null +++ b/Task/Range-extraction/TUSCRIPT/range-extraction-2.tuscript @@ -0,0 +1,31 @@ +$$ MODE TUSCRIPT +MODE DATA +$$ numbers=* +0, 1, 2, 4, 6, 7, 8, 11, 12, 14, +15, 16, 17, 18, 19, 20, 21, 22, 23, 24, +25, 27, 28, 29, 30, 31, 32, 33, 35, 36, +37, 38, 39 +$$ MODE TUSCRIPT +numbers=EXCHANGE (numbers,":,><<> :':") +unrangednrs=JOIN (numbers,"") + +help = APPEND (unrangednrs, "999999999") +rest = REMOVE (help, 1, n_1) +n_2 = n_1, n_3= n_2 + 1,rangednrs= "" +LOOP n= rest + IF (n!=n_3) THEN + rangednrs = APPEND (rangednrs, n_1) + IF (n_1!=n_2) THEN + range=n_1+1 + IF (range==n_2) THEN + rangednrs = APPEND (rangednrs,n_2) + ELSE + rangednrs = CONCAT (rangednrs, "-", n_2) + ENDIF + ENDIF + n_1 = n + ENDIF + n_2 = n, n_3 = n_2 + 1 +ENDLOOP +rangednrs=EXCHANGE (rangednrs,":':,:") +PRINT rangednrs diff --git a/Task/Range-extraction/Tcl/range-extraction.tcl b/Task/Range-extraction/Tcl/range-extraction.tcl new file mode 100644 index 0000000000..0224821407 --- /dev/null +++ b/Task/Range-extraction/Tcl/range-extraction.tcl @@ -0,0 +1,29 @@ +proc rangeExtract list { + set result [lindex $list 0] + set first [set last [lindex $list 0]] + foreach term [lrange $list 1 end] { + if {$term == $last+1} { + set last $term + continue + } + if {$last > $first} { + append result [expr {$last == $first+1 ? "," : "-"}] $last + } + append result "," $term + set first [set last $term] + } + if {$last == $first+1} { + append result "," $last + } elseif {$last > $first} { + append result "-" $last + } + return $result +} + +# Commas already removed so it is a natural Tcl list +puts [rangeExtract { + 0 1 2 4 6 7 8 11 12 14 + 15 16 17 18 19 20 21 22 23 24 + 25 27 28 29 30 31 32 33 35 36 + 37 38 39 +}] diff --git a/Task/Range-extraction/Ursala/range-extraction.ursala b/Task/Range-extraction/Ursala/range-extraction.ursala new file mode 100644 index 0000000000..1d77aa1910 --- /dev/null +++ b/Task/Range-extraction/Ursala/range-extraction.ursala @@ -0,0 +1,10 @@ +#import std +#import int + +x = <0,1,2,4,6,7,8,11,12,14,15,16,17,18,19,20,21,22,23,24,25,27,28,29,30,31,32,33,35,36,37,38,39> + +f = mat`,+ ==?(~&l,^|T/~& :/`-)*bhPS+ %zP~~hzX*titZBPiNCSiNCQSL+ rlc ^|E/~& predecessor + +#show+ + +t = diff --git a/Task/Range-extraction/VBA/range-extraction.vba b/Task/Range-extraction/VBA/range-extraction.vba new file mode 100644 index 0000000000..c87008ee82 --- /dev/null +++ b/Task/Range-extraction/VBA/range-extraction.vba @@ -0,0 +1,70 @@ +Public Function RangeExtraction(AList) As String +'AList is a variant that is an array, assumed filled with numbers in ascending order +Const RangeDelim = "-" 'range delimiter +Dim result As String +Dim InRange As Boolean +Dim Posn, ub, lb, rangestart, rangelen As Integer + +result = "" +'find dimensions of AList +ub = UBound(AList) +lb = LBound(AList) +Posn = lb +While Posn < ub + rangestart = Posn + rangelen = 0 + InRange = True + 'try to extend the range + While InRange + rangelen = rangelen + 1 + If Posn = ub Then + InRange = False + Else + InRange = (AList(Posn + 1) = AList(Posn) + 1) + Posn = Posn + 1 + End If + Wend + If rangelen > 2 Then 'output the range if it has more than 2 elements + result = result & "," & Format$(AList(rangestart)) & RangeDelim & Format$(AList(rangestart + rangelen - 1)) + Else 'output the separate elements + For i = rangestart To rangestart + rangelen - 1 + result = result & "," & Format$(AList(i)) + Next + End If + Posn = rangestart + rangelen +Wend +RangeExtraction = Mid$(result, 2) 'get rid of first comma! +End Function + + +Public Sub RangeTest() +'test function RangeExtraction +'first test with a Variant array +Dim MyList As Variant +MyList = Array(0, 1, 2, 4, 6, 7, 8, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 38, 39) +Debug.Print "a) "; RangeExtraction(MyList) + +'next test with an array of integers +Dim MyOtherList(1 To 20) As Integer +MyOtherList(1) = -6 +MyOtherList(2) = -3 +MyOtherList(3) = -2 +MyOtherList(4) = -1 +MyOtherList(5) = 0 +MyOtherList(6) = 1 +MyOtherList(7) = 3 +MyOtherList(8) = 4 +MyOtherList(9) = 5 +MyOtherList(10) = 7 +MyOtherList(11) = 8 +MyOtherList(12) = 9 +MyOtherList(13) = 10 +MyOtherList(14) = 11 +MyOtherList(15) = 14 +MyOtherList(16) = 15 +MyOtherList(17) = 17 +MyOtherList(18) = 18 +MyOtherList(19) = 19 +MyOtherList(20) = 20 +Debug.Print "b) "; RangeExtraction(MyOtherList) +End Sub diff --git a/Task/Rate-counter/0DESCRIPTION b/Task/Rate-counter/0DESCRIPTION new file mode 100644 index 0000000000..6598a9cf34 --- /dev/null +++ b/Task/Rate-counter/0DESCRIPTION @@ -0,0 +1,12 @@ +Counting the frequency at which something occurs is a common activity in measuring performance and managing resources. In this task, we assume that there is some job which we want to perform repeatedly, and we want to know how quickly these jobs are being performed. + +Of interest is the code that performs the actual measurements. Any other code (such as job implementation or dispatching) that is required to demonstrate the rate tracking is helpful, but not the focus. + +Multiple approaches are allowed (even preferable), so long as they can accomplish these goals: + +* Run N seconds worth of jobs and/or Y jobs. +* Report at least three distinct times. + +Be aware of the precision and accuracy limitations of your timing mechanisms, and document them if you can. + +'''See also:''' [[System time]], [[Time a function]] diff --git a/Task/Rate-counter/Ada/rate-counter.ada b/Task/Rate-counter/Ada/rate-counter.ada new file mode 100644 index 0000000000..a90a53a5d3 --- /dev/null +++ b/Task/Rate-counter/Ada/rate-counter.ada @@ -0,0 +1,71 @@ +with System; use System; +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Calendar; use Ada.Calendar; +with Ada.Unchecked_Deallocation; use Ada; +with Interfaces; + +procedure Rate_Counter is + pragma Priority (Max_Priority); + + package Duration_IO is new Fixed_IO (Duration); + + Job_Nbr : constant := 6; -- adjust to your need + subtype Job_Index is Natural range 1 .. Job_Nbr; + + task type Job (ID : Job_Index) is + pragma Priority (Default_Priority); + entry Start; + end Job; + + type Job_Ptr is access Job; + procedure Free is new Unchecked_Deallocation (Job, Job_Ptr); + + Jobs : array (Job_Index) of Job_Ptr; + + Done : Natural := 0; + Completed : array (Job_Index) of Boolean := (others => False); + + type Timings is array (Job_Index) of Calendar.Time; + Start_T, Stop_T : Timings; + + task body Job is + Anchor : Interfaces.Integer_32; + pragma Volatile (Anchor); -- necessary to avoid compiler optimization. + begin + accept Start; + + for I in Interfaces.Integer_32'Range loop -- the job to do + Anchor := I; + end loop; + end Job; + +begin + for J in Job_Index'Range loop + Jobs (J) := new Job (ID => J); -- create the jobs first, sync later + end loop; + for J in Job_Index'Range loop -- launch the jobs in parallel + Start_T (J) := Calendar.Clock; -- get the start time + Jobs (J).Start; -- priority settings necessary to regain control. + end loop; + -- Polling for the results / also possible to use a protected type. + while not (Done = Job_Nbr) loop + for J in Job_Index'Range loop + if not Completed (J) and then Jobs (J)'Terminated then + Stop_T (J) := Calendar.Clock; -- get the end time + Put ("Job #" & Job_Index'Image (J) & " is finished. It took "); + Duration_IO.Put (Stop_T (J) - Start_T (J), Fore => 3, Aft => 2); + Put_Line (" seconds."); + Completed (J) := True; + Done := Done + 1; + end if; + end loop; + delay System.Tick; -- according to the precision of the system clock + end loop; + Duration_IO.Put (System.Tick, Fore => 1, Aft => 6); + Put_Line (" seconds is the precision of System clock."); + + for J in Job_Index'Range loop + Free (Jobs (J)); -- no GC in Ada, clean-up is explicit + end loop; + +end Rate_Counter; diff --git a/Task/Rate-counter/BBC-BASIC/rate-counter.bbc b/Task/Rate-counter/BBC-BASIC/rate-counter.bbc new file mode 100644 index 0000000000..e10949d0fc --- /dev/null +++ b/Task/Rate-counter/BBC-BASIC/rate-counter.bbc @@ -0,0 +1,26 @@ + PRINT "Method 1: Calculate reciprocal of elapsed time:" + FOR trial% = 1 TO 3 + start% = TIME + PROCtasktomeasure + finish% = TIME + PRINT "Rate = "; 100 / (finish%-start%) " per second" + NEXT trial% + + PRINT '"Method 2: Count completed tasks in one second:" + FOR trial% = 1 TO 3 + runs% = 0 + finish% = TIME + 100 + REPEAT + PROCtasktomeasure + IF TIME < finish% runs% += 1 + UNTIL TIME >= finish% + PRINT "Rate = "; runs% " per second" + NEXT trial% + END + + REM This is an example, replace with the task you want to measure + DEF PROCtasktomeasure + LOCAL i% + FOR i% = 1 TO 1000000 + NEXT + ENDPROC diff --git a/Task/Rate-counter/C++/rate-counter.cpp b/Task/Rate-counter/C++/rate-counter.cpp new file mode 100644 index 0000000000..52a2e75976 --- /dev/null +++ b/Task/Rate-counter/C++/rate-counter.cpp @@ -0,0 +1,78 @@ +#include +#include + +// We only get one-second precision on most systems, as +// time_t only holds seconds. +class CRateState +{ +protected: + time_t m_lastFlush; + time_t m_period; + size_t m_tickCount; +public: + CRateState(time_t period); + void Tick(); +}; + +CRateState::CRateState(time_t period) : m_lastFlush(std::time(NULL)), + m_period(period), + m_tickCount(0) +{ } + +void CRateState::Tick() +{ + m_tickCount++; + + time_t now = std::time(NULL); + + if((now - m_lastFlush) >= m_period) + { + //TPS Report + size_t tps = 0.0; + if(m_tickCount > 0) + tps = m_tickCount / (now - m_lastFlush); + + std::cout << tps << " tics per second" << std::endl; + + //Reset + m_tickCount = 0; + m_lastFlush = now; + } +} + +// A stub function that simply represents whatever it is +// that we want to multiple times. +void something_we_do() +{ + // We use volatile here, as many compilers will optimize away + // the for() loop otherwise, even without optimizations + // explicitly enabled. + // + // volatile tells the compiler not to make any assumptions + // about the variable, implying that the programmer knows more + // about that variable than the compiler, in this case. + volatile size_t anchor = 0; + for(size_t x = 0; x < 0xffff; ++x) + { + anchor = x; + } +} + +int main() +{ + time_t start = std::time(NULL); + + CRateState rateWatch(5); + + // Loop for twenty seconds + for(time_t latest = start; (latest - start) < 20; latest = std::time(NULL)) + { + // Do something. + something_we_do(); + + // Note that we did something. + rateWatch.Tick(); + } + + return 0; +} diff --git a/Task/Rate-counter/C/rate-counter.c b/Task/Rate-counter/C/rate-counter.c new file mode 100644 index 0000000000..8227b55b54 --- /dev/null +++ b/Task/Rate-counter/C/rate-counter.c @@ -0,0 +1,74 @@ +#include +#include + +// We only get one-second precision on most systems, as +// time_t only holds seconds. +struct rate_state_s +{ + time_t lastFlush; + time_t period; + size_t tickCount; +}; + +void tic_rate(struct rate_state_s* pRate) +{ + pRate->tickCount += 1; + + time_t now = time(NULL); + + if((now - pRate->lastFlush) >= pRate->period) + { + //TPS Report + size_t tps = 0.0; + if(pRate->tickCount > 0) + tps = pRate->tickCount / (now - pRate->lastFlush); + + printf("%u tics per second.\n", tps); + + //Reset + pRate->tickCount = 0; + pRate->lastFlush = now; + } +} + +// A stub function that simply represents whatever it is +// that we want to multiple times. +void something_we_do() +{ + // We use volatile here, as many compilers will optimize away + // the for() loop otherwise, even without optimizations + // explicitly enabled. + // + // volatile tells the compiler not to make any assumptions + // about the variable, implying that the programmer knows more + // about that variable than the compiler, in this case. + volatile size_t anchor = 0; + size_t x = 0; + for(x = 0; x < 0xffff; ++x) + { + anchor = x; + } +} + +int main() +{ + time_t start = time(NULL); + + struct rate_state_s rateWatch; + rateWatch.lastFlush = start; + rateWatch.tickCount = 0; + rateWatch.period = 5; // Report every five seconds. + + time_t latest = start; + // Loop for twenty seconds + for(latest = start; (latest - start) < 20; latest = time(NULL)) + { + // Do something. + something_we_do(); + + // Note that we did something. + tic_rate(&rateWatch); + } + + return 0; +} diff --git a/Task/Rate-counter/Common-Lisp/rate-counter-1.lisp b/Task/Rate-counter/Common-Lisp/rate-counter-1.lisp new file mode 100644 index 0000000000..8655df7db6 --- /dev/null +++ b/Task/Rate-counter/Common-Lisp/rate-counter-1.lisp @@ -0,0 +1 @@ +(time (do some stuff)) diff --git a/Task/Rate-counter/Common-Lisp/rate-counter-2.lisp b/Task/Rate-counter/Common-Lisp/rate-counter-2.lisp new file mode 100644 index 0000000000..295ea1d1c0 --- /dev/null +++ b/Task/Rate-counter/Common-Lisp/rate-counter-2.lisp @@ -0,0 +1,10 @@ +(defmacro time-this (cnt &rest body) + (let ((real-t (gensym)) (run-t (gensym))) + `(let (,real-t ,run-t) + (setf ,real-t (get-internal-real-time) + ,run-t (get-internal-run-time)) + (loop repeat ,cnt do ,@body) + (list (/ (- (get-internal-real-time) ,real-t) + (coerce internal-time-units-per-second 'float)) + (/ (- (get-internal-run-time) ,run-t) + (coerce internal-time-units-per-second 'float)))))) diff --git a/Task/Rate-counter/Common-Lisp/rate-counter-3.lisp b/Task/Rate-counter/Common-Lisp/rate-counter-3.lisp new file mode 100644 index 0000000000..1a139a628a --- /dev/null +++ b/Task/Rate-counter/Common-Lisp/rate-counter-3.lisp @@ -0,0 +1 @@ +(print (time-this 99 (loop for i below 10000 sum i))) diff --git a/Task/Rate-counter/Common-Lisp/rate-counter-4.lisp b/Task/Rate-counter/Common-Lisp/rate-counter-4.lisp new file mode 100644 index 0000000000..4291534207 --- /dev/null +++ b/Task/Rate-counter/Common-Lisp/rate-counter-4.lisp @@ -0,0 +1 @@ +(0.023 0.022) diff --git a/Task/Rate-counter/E/rate-counter-1.e b/Task/Rate-counter/E/rate-counter-1.e new file mode 100644 index 0000000000..fe1f955bed --- /dev/null +++ b/Task/Rate-counter/E/rate-counter-1.e @@ -0,0 +1,24 @@ +def makeLamportSlot := + +The rate counter: + +/** Returns a function to call to report the event being counted, and an + EverReporter slot containing the current rate, as a float64 in units of + events per millisecond. */ +def makeRateCounter(timer, reportPeriod) { + var count := 0 + var start := timer.now() + def &rate := makeLamportSlot(nullOk[float64], null) + + def signal() { + def time := timer.now() + count += 1 + if (time >= start + reportPeriod) { + rate := count / (time - start) + start := time + count := 0 + } + } + + return [signal, &rate] +} diff --git a/Task/Rate-counter/E/rate-counter-2.e b/Task/Rate-counter/E/rate-counter-2.e new file mode 100644 index 0000000000..74d711aec7 --- /dev/null +++ b/Task/Rate-counter/E/rate-counter-2.e @@ -0,0 +1,34 @@ +/** Dummy task: Retrieve http://localhost/ and return the content. */ +def theJob() { + return when (def text := <- getText()) -> { + text + } +} + +/** Repeatedly run 'action' and wait for it until five seconds have elapsed. */ +def repeatForFiveSeconds(action) { + def stopTime := timer.now() + 5000 + def loop() { + if (timer.now() < stopTime) { + when (action <- ()) -> { + loop() + } + } + } + loop() +} + +def whenever := + +def [signal, &rate] := makeRateCounter(timer, 1000) + +# Prepare to report the rate info. +whenever([&rate], fn { + println(`Rate: ${rate*1000} requests/sec`) +}, fn {true}) + +# Do some stuff to be counted. +repeatForFiveSeconds(fn { + signal() + theJob() +}) diff --git a/Task/Rate-counter/Go/rate-counter.go b/Task/Rate-counter/Go/rate-counter.go new file mode 100644 index 0000000000..f909955beb --- /dev/null +++ b/Task/Rate-counter/Go/rate-counter.go @@ -0,0 +1,52 @@ +package main + +import ( + "fmt" + "math/rand" + "time" +) + +// representation of time.Time is nanosecond, actual resolution system specific +type rateStateS struct { + lastFlush time.Time + period time.Duration + tickCount int +} + +func ticRate(pRate *rateStateS) { + pRate.tickCount++ + now := time.Now() + if now.Sub(pRate.lastFlush) >= pRate.period { + // TPS Report + tps := 0. + if pRate.tickCount > 0 { + tps = float64(pRate.tickCount) / now.Sub(pRate.lastFlush).Seconds() + } + fmt.Println(tps, "tics per second.") + + // Reset + pRate.tickCount = 0 + pRate.lastFlush = now + } +} + +func somethingWeDo() { + time.Sleep(time.Duration(9e7 + rand.Int63n(2e7))) // sleep about .1 second. +} + +func main() { + start := time.Now() + + rateWatch := rateStateS{ + lastFlush: start, + period: 5 * time.Second, + } + + // Loop for twenty seconds + latest := start + for latest.Sub(start) < 20*time.Second { + somethingWeDo() + ticRate(&rateWatch) + latest = time.Now() + } +} diff --git a/Task/Rate-counter/HicEst/rate-counter.hicest b/Task/Rate-counter/HicEst/rate-counter.hicest new file mode 100644 index 0000000000..f4a6d0ef16 --- /dev/null +++ b/Task/Rate-counter/HicEst/rate-counter.hicest @@ -0,0 +1,20 @@ +CHARACTER prompt='Count "Hits++" for 5 sec, get current rate' + +DLG(Button="1:&Hits++", CALL="cb", B="2:&Count 5sec", B="3:&Rate", RC=retcod, TItle=prompt, WIN=hdl) + +SUBROUTINE cb ! callback after dialog buttons + IF(retcod == 1) THEN ! "Hits++" button + Hits = Hits + 1 + ELSEIF(retcod == 2) THEN ! "Count 5 sec" button + Hits = 0 + ALARM(5, 5) ! call F5 in 5 seconds + t_start = TIME() + ELSE ! "Rate" button + sec = TIME() - t_start + WRITE(StatusBar) 'Average rate since last "5 sec" button = ', hits/sec, " Hz" + ENDIF +END + +SUBROUTINE F5 ! called 5 sec after button "5 sec" + WRITE(StatusBar) Hits, "hits last 5 sec" +END diff --git a/Task/Rate-counter/J/rate-counter-1.j b/Task/Rate-counter/J/rate-counter-1.j new file mode 100644 index 0000000000..27580cde31 --- /dev/null +++ b/Task/Rate-counter/J/rate-counter-1.j @@ -0,0 +1 @@ + x (6!:2) y diff --git a/Task/Rate-counter/J/rate-counter-2.j b/Task/Rate-counter/J/rate-counter-2.j new file mode 100644 index 0000000000..1dec1c2c51 --- /dev/null +++ b/Task/Rate-counter/J/rate-counter-2.j @@ -0,0 +1,4 @@ + list=: 1e6 ?@$ 100 NB. 1 million random integers from 0 to 99 + freqtable=: ~. ,. #/.~ NB. verb to calculate and build frequency table + 20 (6!:2) 'freqtable list' NB. calculate and build frequency table for list, 20 times +0.00994106 diff --git a/Task/Rate-counter/J/rate-counter-3.j b/Task/Rate-counter/J/rate-counter-3.j new file mode 100644 index 0000000000..c1357c0879 --- /dev/null +++ b/Task/Rate-counter/J/rate-counter-3.j @@ -0,0 +1,2 @@ + 1 1 1 (6!:2) 'freqtable list' +0.0509995 0.0116702 0.0116266 diff --git a/Task/Rate-counter/JavaScript/rate-counter.js b/Task/Rate-counter/JavaScript/rate-counter.js new file mode 100644 index 0000000000..b5b577de83 --- /dev/null +++ b/Task/Rate-counter/JavaScript/rate-counter.js @@ -0,0 +1,14 @@ +function millis() { // Gets current time in milliseconds. + return (new Date()).getTime(); +} + +/* Executes function 'func' n times, returns array of execution times. */ +function benchmark(n, func, args) { + var times = []; + for (var i=0; i60000,print(b);a=0;b=0); +'''code to test''' + b=b+1; + a=a+gettime(); + if(a>60000,print(b);a=0;b=0) +) diff --git a/Task/Rate-counter/Perl-6/rate-counter.pl6 b/Task/Rate-counter/Perl-6/rate-counter.pl6 new file mode 100644 index 0000000000..470cd30d76 --- /dev/null +++ b/Task/Rate-counter/Perl-6/rate-counter.pl6 @@ -0,0 +1,20 @@ +sub runrate($N where $N > 0, &todo) { + my $n = $N; + + my $start = now; + todo() while --$n; + my $end = now; + + say "Start time: ", DateTime.new($start).Str; + say "End time: ", DateTime.new($end).Str; + my $elapsed = $end - $start; + + say "Elapsed time: $elapsed seconds"; + say "Rate: { ($N / $elapsed).fmt('%.2f') } per second\n"; +} + +sub factorial($n) { (state @)[$n] //= $n < 2 ?? 1 !! $n * factorial($n-1) } + +runrate 10000, { state $n = 1; factorial($n++) } + +runrate 10000, { state $n = 1; factorial($n++) } diff --git a/Task/Rate-counter/Perl/rate-counter.pl b/Task/Rate-counter/Perl/rate-counter.pl new file mode 100644 index 0000000000..e7eb1f3bb1 --- /dev/null +++ b/Task/Rate-counter/Perl/rate-counter.pl @@ -0,0 +1,12 @@ +use Benchmark; + +timethese COUNT,{ 'Job1' => &job1, 'Job2' => &job2 }; + +sub job1 +{ + ...job1 code... +} +sub job2 +{ + ...job2 code... +} diff --git a/Task/Rate-counter/PicoLisp/rate-counter-1.l b/Task/Rate-counter/PicoLisp/rate-counter-1.l new file mode 100644 index 0000000000..1e64df86ff --- /dev/null +++ b/Task/Rate-counter/PicoLisp/rate-counter-1.l @@ -0,0 +1,8 @@ +(prin "Hit a key ... ") +(key) +(prinl) +(let Usec (usec) + (prin "Hit another key ... ") + (key) + (prinl) + (prinl "This took " (format (- (usec) Usec) 6) " seconds") ) diff --git a/Task/Rate-counter/PicoLisp/rate-counter-2.l b/Task/Rate-counter/PicoLisp/rate-counter-2.l new file mode 100644 index 0000000000..7e0f5d9b38 --- /dev/null +++ b/Task/Rate-counter/PicoLisp/rate-counter-2.l @@ -0,0 +1 @@ +(bench (key)) diff --git a/Task/Rate-counter/PureBasic/rate-counter-1.purebasic b/Task/Rate-counter/PureBasic/rate-counter-1.purebasic new file mode 100644 index 0000000000..19cfa4b1c8 --- /dev/null +++ b/Task/Rate-counter/PureBasic/rate-counter-1.purebasic @@ -0,0 +1,35 @@ +Procedure.d TimesPSec(Reset=#False) + Static starttime, cnt + Protected Result.d, dt + If Reset + starttime=ElapsedMilliseconds(): cnt=0 + Else + cnt+1 + dt=(ElapsedMilliseconds()-starttime) + If dt + Result=cnt/(ElapsedMilliseconds()-starttime) + EndIf + EndIf + ProcedureReturn Result*1000 +EndProcedure + +If OpenWindow(0,#PB_Ignore,#PB_Ignore,220,110,"",#PB_Window_SystemMenu) + Define Event, r.d, GadgetNumber + ButtonGadget(0,10, 5,200,35,"Click me!") + ButtonGadget(1,10,70,100,35,"Reset") + TextGadget (2,10,45,200,25,"") + TimesPSec(1) + Repeat + Event=WaitWindowEvent() + If Event=#PB_Event_Gadget + GadgetNumber =EventGadget() + If GadgetNumber=0 + r=TimesPSec() + SetGadgetText(2,"You are clicking at "+StrD(r,5)+" Hz.") + ElseIf GadgetNumber=1 + TimesPSec(1) + SetGadgetText(2,"Counter zeroed.") + EndIf + EndIf + Until Event=#PB_Event_CloseWindow +EndIf diff --git a/Task/Rate-counter/PureBasic/rate-counter-2.purebasic b/Task/Rate-counter/PureBasic/rate-counter-2.purebasic new file mode 100644 index 0000000000..0b4d330b37 --- /dev/null +++ b/Task/Rate-counter/PureBasic/rate-counter-2.purebasic @@ -0,0 +1,13 @@ +Procedure DummyThread(arg) + Define.d dummy=#PI*Pow(arg,2)/4 +EndProcedure + +start=ElapsedMilliseconds() +Repeat + T=CreateThread(@DummyThread(),Random(100)) + WaitThread(T) + cnt+1 +Until start+10000<=ElapsedMilliseconds(); Count for 10 sec + +msg$="We got "+Str(cnt)+" st."+Chr(10)+StrF(cnt/10,2)+" threads per sec." +MessageRequester("Counting threads in 10 sec",msg$) diff --git a/Task/Rate-counter/Python/rate-counter.py b/Task/Rate-counter/Python/rate-counter.py new file mode 100644 index 0000000000..1a19717ba7 --- /dev/null +++ b/Task/Rate-counter/Python/rate-counter.py @@ -0,0 +1,58 @@ +import subprocess +import time + +class Tlogger(object): + def __init__(self): + self.counts = 0 + self.tottime = 0.0 + self.laststart = 0.0 + self.lastreport = time.time() + + def logstart(self): + self.laststart = time.time() + + def logend(self): + self.counts +=1 + self.tottime += (time.time()-self.laststart) + if (time.time()-self.lastreport)>5.0: # report once every 5 seconds + self.report() + + def report(self): + if ( self.counts > 4*self.tottime): + print "Subtask execution rate: %f times/second"% (self.counts/self.tottime); + else: + print "Average execution time: %f seconds"%(self.tottime/self.counts); + self.lastreport = time.time() + + +def taskTimer( n, subproc_args ): + logger = Tlogger() + + for x in range(n): + logger.logstart() + p = subprocess.Popen(subproc_args) + p.wait() + logger.logend() + logger.report() + + +import timeit +import sys + +def main( ): + + # for accurate timing of code segments + s = """j = [4*n for n in range(50)]""" + timer = timeit.Timer(s) + rzlts = timer.repeat(5, 5000) + for t in rzlts: + print "Time for 5000 executions of statement = ",t + + # subprocess execution timing + print "#times:",sys.argv[1] + print "Command:",sys.argv[2:] + print "" + for k in range(3): + taskTimer( int(sys.argv[1]), sys.argv[2:]) + +main() diff --git a/Task/Rate-counter/REXX/rate-counter.rexx b/Task/Rate-counter/REXX/rate-counter.rexx new file mode 100644 index 0000000000..3a05a34899 --- /dev/null +++ b/Task/Rate-counter/REXX/rate-counter.rexx @@ -0,0 +1,36 @@ +/*REXX program reports on the time 4 different tasks take (wall clock)*/ +time.= /*nullify times for all tasks. */ +/*──────────────────────────────────────────────────────────────────────*/ +call time 'Reset' /*reset the REXX (elapsed) timer.*/ + /*show π in hexadecimal to */ + /*2,000 decimal places. */ + task.1='base(pi,16)' + call '$CALC' task.1 /*perform task number one. */ +time.1=time('Elapsed') /*save the time used by task 1. */ +/*──────────────────────────────────────────────────────────────────────*/ +call time 'Reset' /*reset the REXX (elapsed) timer.*/ + /*get primes # 40000──►40800 and */ + /*show their differences. */ + task.2='diffs[prime(40k,40.8k)] ;;; group 20' + call '$CALC' task.2 /*perform task number two. */ +time.2=time('Elapsed') /*save the time used by task 2. */ +/*──────────────────────────────────────────────────────────────────────*/ +call time 'Reset' /*reset the REXX (elapsed) timer.*/ + /*show the Collatz sequence for */ + /*a stupidly big number. */ + task.3='collatz(38**8) ;;; Horizontal' + call '$CALC' task.3 /*perform task number three. */ +time.3=time('Elapsed') /*save the time used by task 3. */ +/*──────────────────────────────────────────────────────────────────────*/ +call time 'Reset' /*reset the REXX (elapsed) timer.*/ + /*plot SIN in ½ degree increments*/ + /*using 9 decimal digits (¬ 60).*/ + task.4='sind(-180,+180,0.5) ;;; Plot DIGits 9' + call '$CALC' task.4 /*perform task number four. */ +time.4=time('Elapsed') /*save the time used by task 4. */ +/*──────────────────────────────────────────────────────────────────────*/ +say + do j=1 while time.j\=='' + say 'time used for task' j "was" right(format(time.j,,0),4) 'seconds.' + end /*j*/ + /*stick a fork in it, we're done.*/ diff --git a/Task/Rate-counter/Run-BASIC/rate-counter.run b/Task/Rate-counter/Run-BASIC/rate-counter.run new file mode 100644 index 0000000000..07ec8b5318 --- /dev/null +++ b/Task/Rate-counter/Run-BASIC/rate-counter.run @@ -0,0 +1,45 @@ +html " +
    Rate Counter
    Run Job Times" + textbox #runTimes,"10",3 + +html "
    " + button #r,"Run", [runIt] +html " " + button #a, "Average", [ave] +html "
    " +wait + +[runIt] +runTimes = min(10,val(#runTimes contents$())) +count = count + 1 +print "-------- Run Number ";count;" ----------------" +print "Run jobs";runTimes;" times, reporting each" + +for i = 1 to runTimes + ' ----------------------------------------------------------------- + ' Normally we use a RUN() command to run another program + ' but for test pruporse we have a routine that simply loops a bunch + ' ----------------------------------------------------------------- + begTime = time$("ms") + theRun = bogusProg() + + endTime = time$("ms") + lapsTime = endTime - begTime + print "Job #";i;" Elapsed time, ms ";lapsTime;" ";1000/lapsTime; " ticks per second" +next +aveTime = (endTime-startTime)/runTimes +totAveTime = totAveTime + aveTime +print "Average time, ms, is ";aveTime;" "; 1000/((endTime-startTime)/runTimes); " ticks per second" +wait + +[ave] +print "---------------------------------" +print "Total average time:";aveTime/count + +function bogusProg() + for i = 1 to 10000 + sini = sini + sin(i) + tani = tani + tan(i) + cpsi = cosi + cos(i) + next +end function diff --git a/Task/Rate-counter/Scala/rate-counter-1.scala b/Task/Rate-counter/Scala/rate-counter-1.scala new file mode 100644 index 0000000000..61a5072571 --- /dev/null +++ b/Task/Rate-counter/Scala/rate-counter-1.scala @@ -0,0 +1,11 @@ +def task(n: Int) = Thread.sleep(n * 1000) +def rate(fs: List[() => Unit]) = { + val jobs = fs map (f => scala.actors.Futures.future(f())) + val cnt1 = scala.actors.Futures.awaitAll(5000, jobs: _*).count(_ != None) + val cnt2 = scala.actors.Futures.awaitAll(5000, jobs: _*).count(_ != None) + val cnt3 = scala.actors.Futures.awaitAll(5000, jobs: _*).count(_ != None) + println("%d jobs in 5 seconds" format cnt1) + println("%d jobs in 10 seconds" format cnt2) + println("%d jobs in 15 seconds" format cnt3) +} +rate(List.fill(30)(() => task(scala.util.Random.nextInt(10)+1))) diff --git a/Task/Rate-counter/Scala/rate-counter-2.scala b/Task/Rate-counter/Scala/rate-counter-2.scala new file mode 100644 index 0000000000..252160d606 --- /dev/null +++ b/Task/Rate-counter/Scala/rate-counter-2.scala @@ -0,0 +1,15 @@ +def rate(n: Int, y: Int)(task: => Unit) { + val startTime = System.currentTimeMillis + var currTime = startTime + var loops = 0 + do { + task + currTime = System.currentTimeMillis + loops += 1 + } while (currTime - startTime < n * 1000 && loops < y) + if (currTime - startTime > n * 1000) + println("Rate %d times per %d seconds" format (loops - 1, n)) + else + println("Rate %d times in %.3f seconds" format (y, (currTime - startTime).toDouble / 1000)) +} +rate(5, 20)(task(2)) diff --git a/Task/Rate-counter/Smalltalk/rate-counter.st b/Task/Rate-counter/Smalltalk/rate-counter.st new file mode 100644 index 0000000000..38a314bb58 --- /dev/null +++ b/Task/Rate-counter/Smalltalk/rate-counter.st @@ -0,0 +1,5 @@ +|times| +times := Bag new. +1 to: 10 do: [:n| times add: + (Time millisecondsToRun: [3000 factorial])]. +Transcript show: times average asInteger. diff --git a/Task/Rate-counter/Tcl/rate-counter-1.tcl b/Task/Rate-counter/Tcl/rate-counter-1.tcl new file mode 100644 index 0000000000..9a6e47f0df --- /dev/null +++ b/Task/Rate-counter/Tcl/rate-counter-1.tcl @@ -0,0 +1,16 @@ +set iters 10 + +# A silly example task +proc theTask {} { + for {set a 0} {$a < 100000} {incr a} { + expr {$a**3+$a**2+$a+1} + } +} + +# Measure the time taken $iters times +for {set i 1} {$i <= $iters} {incr i} { + set t [lindex [time { + theTask + }] 0] + puts "task took $t microseconds on iteration $i" +} diff --git a/Task/Rate-counter/Tcl/rate-counter-2.tcl b/Task/Rate-counter/Tcl/rate-counter-2.tcl new file mode 100644 index 0000000000..3808d51f4c --- /dev/null +++ b/Task/Rate-counter/Tcl/rate-counter-2.tcl @@ -0,0 +1 @@ +puts [time { set aVar 123 } 1000000] diff --git a/Task/Rate-counter/UNIX-Shell/rate-counter-1.sh b/Task/Rate-counter/UNIX-Shell/rate-counter-1.sh new file mode 100644 index 0000000000..fd3908aabf --- /dev/null +++ b/Task/Rate-counter/UNIX-Shell/rate-counter-1.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +while : ; do +task && echo >> .fc +done diff --git a/Task/Rate-counter/UNIX-Shell/rate-counter-2.sh b/Task/Rate-counter/UNIX-Shell/rate-counter-2.sh new file mode 100644 index 0000000000..211ed04de1 --- /dev/null +++ b/Task/Rate-counter/UNIX-Shell/rate-counter-2.sh @@ -0,0 +1,15 @@ +./foo.sh & +sleep 5 +mv .fc .fc2 2>/dev/null +wc -l .fc2 2>/dev/null +rm .fc2 +sleep 5 +mv .fc .fc2 2>/dev/null +wc -l .fc2 2>/dev/null +sleep 5 +mv .fc .fc2 2>/dev/null +wc -l .fc2 2>/dev/null +sleep 5 +killall foo.sh +wc -l .fc 2>/dev/null +rm .fc diff --git a/Task/Rate-counter/XPL0/rate-counter.xpl0 b/Task/Rate-counter/XPL0/rate-counter.xpl0 new file mode 100644 index 0000000000..f588141a43 --- /dev/null +++ b/Task/Rate-counter/XPL0/rate-counter.xpl0 @@ -0,0 +1,13 @@ +include c:\cxpl\codes; \intrinsic 'code' declarations +int N, I, T0, Time; +[for N:= 1, 3 do + [T0:= GetTime; + for I:= 1 to 100 do + [while port($3DA) & $08 do []; \wait for vertical retrace to go away + repeat until port($3DA) & $08; \wait for vertical retrace signal + ]; + Time:= GetTime - T0; + IntOut(0, Time); Text(0, " microseconds for 100 samples = "); + RlOut(0, 100.0e6/float(Time)); Text(0, "Hz"); CrLf(0); + ]; +] diff --git a/Task/Ray-casting-algorithm/0DESCRIPTION b/Task/Ray-casting-algorithm/0DESCRIPTION new file mode 100644 index 0000000000..ca25d0acdf --- /dev/null +++ b/Task/Ray-casting-algorithm/0DESCRIPTION @@ -0,0 +1,71 @@ +{{Wikipedia|Point_in_polygon}} +Given a point and a polygon, check if the point is inside or outside the polygon using the [[wp:Point in polygon#Ray casting algorithm|ray-casting algorithm]]. + +A pseudocode can be simply: + + count ← 0 + '''foreach''' side '''in''' polygon: + '''if''' ray_intersects_segment(P,side) '''then''' + count ← count + 1 + '''if''' ''is_odd''(count) '''then''' + '''return''' inside + '''else''' + '''return''' outside + +Where the function ray_intersects_segment return true if the horizontal ray starting from the point P intersects the side (segment), false otherwise. + +An intuitive explanation of why it works is that every time we cross +a border, we change "country" (inside-outside, or outside-inside), but +the last "country" we land on is surely ''outside'' (since the inside of the polygon is finite, while the ray continues towards infinity). So, if we crossed an odd number of borders we were surely inside, otherwise we were outside; we can follow the ray backward to see it better: starting from outside, only an odd number of crossing can give an ''inside'': outside-inside, outside-inside-outside-inside, and so on (the - represents the crossing of a border). + +So the main part of the algorithm is how we determine if a ray intersects a segment. The following text explain one of the possible ways. + +[[Image:intersect.png|200px|thumb|right]] +Looking at the image on the right, we can easily be convinced of the fact that rays starting from points in the hatched area (like P1 and P2) surely do not intersect the segment AB. We also can easily see that rays starting from points in the greenish area surely intersect the segment AB (like point P3). + +So the problematic points are those inside the white area (the box delimited by the points A and B), like P4. + +[[Image:posslope.png|128px|thumb|right]] +[[Image:negslope.png|128px|thumb|right]] +Let us take into account a segment AB (the point A having y coordinate always smaller than B's y coordinate, i.e. point A is always below point B) and a point P. Let us use the cumbersome notation PAX to denote the angle between segment AP and AX, where X is always a point on the horizontal line passing by A with x coordinate bigger than the maximum between the x coordinate of A and the x coordinate of B. As explained graphically by the figures on the right, if PAX is greater than the angle BAX, then the ray starting from P intersects the segment AB. (In the images, the ray starting from PA does not intersect the segment, while the ray starting from PB in the second picture, intersects the segment). + +Points on the boundary or "on" a vertex are someway special and through this approach we do not obtain ''coherent'' results. They could be treated apart, but it is not necessary to do so. + +An algorithm for the previous speech could be (if P is a point, Px is its x coordinate): + + '''ray_intersects_segment''': + P : the point from which the ray starts + A : the end-point of the segment with the smallest y coordinate + (A must be "below" B) + B : the end-point of the segment with the greatest y coordinate + (B must be "above" A) + '''if''' Py = Ay '''or''' Py = By '''then''' + Py ← Py + ε + '''end''' '''if''' + '''if''' Py < Ay '''or''' Py > By '''then''' + '''return''' false + '''else''' '''if''' Px > max(Ax, Bx) '''then''' + '''return''' false + '''else''' + '''if''' Px < min(Ax, Bx) '''then''' + '''return''' true + '''else''' + '''if''' Ax ≠ Bx '''then''' + m_red ← (By - Ay)/(Bx - Ax) + '''else''' + m_red ← ∞ + '''end''' '''if''' + '''if''' Ax ≠ Px '''then''' + m_blue ← (Py - Ay)/(Px - Ax) + '''else''' + m_blue ← ∞ + '''end''' '''if''' + '''if''' m_blue ≥ m_red '''then''' + '''return''' true + '''else''' + '''return''' false + '''end''' '''if''' + '''end''' '''if''' + '''end''' '''if''' + +(To avoid the "ray on vertex" problem, the point is moved upward of a small quantity ε) diff --git a/Task/Ray-casting-algorithm/1META.yaml b/Task/Ray-casting-algorithm/1META.yaml new file mode 100644 index 0000000000..f407ff9d83 --- /dev/null +++ b/Task/Ray-casting-algorithm/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Classic CS problems and programs diff --git a/Task/Ray-casting-algorithm/Ada/ray-casting-algorithm-1.ada b/Task/Ray-casting-algorithm/Ada/ray-casting-algorithm-1.ada new file mode 100644 index 0000000000..97964aecf5 --- /dev/null +++ b/Task/Ray-casting-algorithm/Ada/ray-casting-algorithm-1.ada @@ -0,0 +1,14 @@ +package Polygons is + + type Point is record + X, Y : Float; + end record; + type Point_List is array (Positive range <>) of Point; + subtype Segment is Point_List (1 .. 2); + type Polygon is array (Positive range <>) of Segment; + + function Create_Polygon (List : Point_List) return Polygon; + + function Is_Inside (Who : Point; Where : Polygon) return Boolean; + +end Polygons; diff --git a/Task/Ray-casting-algorithm/Ada/ray-casting-algorithm-2.ada b/Task/Ray-casting-algorithm/Ada/ray-casting-algorithm-2.ada new file mode 100644 index 0000000000..d3e9541e0a --- /dev/null +++ b/Task/Ray-casting-algorithm/Ada/ray-casting-algorithm-2.ada @@ -0,0 +1,87 @@ +package body Polygons is + EPSILON : constant := 0.00001; + + function Ray_Intersects_Segment + (Who : Point; + Where : Segment) + return Boolean + is + The_Point : Point := Who; + Above : Point; + Below : Point; + M_Red : Float; + Red_Is_Infinity : Boolean := False; + M_Blue : Float; + Blue_Is_Infinity : Boolean := False; + begin + if Where (1).Y < Where (2).Y then + Above := Where (2); + Below := Where (1); + else + Above := Where (1); + Below := Where (2); + end if; + if The_Point.Y = Above.Y or The_Point.Y = Below.Y then + The_Point.Y := The_Point.Y + EPSILON; + end if; + if The_Point.Y < Below.Y or The_Point.Y > Above.Y then + return False; + elsif The_Point.X > Above.X and The_Point.X > Below.X then + return False; + elsif The_Point.X < Above.X and The_Point.X < Below.X then + return True; + else + if Above.X /= Below.X then + M_Red := (Above.Y - Below.Y) / (Above.X - Below.X); + else + Red_Is_Infinity := True; + end if; + if Below.X /= The_Point.X then + M_Blue := (The_Point.Y - Below.Y) / (The_Point.X - Below.X); + else + Blue_Is_Infinity := True; + end if; + if Blue_Is_Infinity then + return True; + elsif Red_Is_Infinity then + return False; + elsif M_Blue >= M_Red then + return True; + else + return False; + end if; + end if; + end Ray_Intersects_Segment; + + function Create_Polygon (List : Point_List) return Polygon is + Result : Polygon (List'Range); + Side : Segment; + begin + for I in List'Range loop + Side (1) := List (I); + if I = List'Last then + Side (2) := List (List'First); + else + Side (2) := List (I + 1); + end if; + Result (I) := Side; + end loop; + return Result; + end Create_Polygon; + + function Is_Inside (Who : Point; Where : Polygon) return Boolean is + Count : Natural := 0; + begin + for Side in Where'Range loop + if Ray_Intersects_Segment (Who, Where (Side)) then + Count := Count + 1; + end if; + end loop; + if Count mod 2 = 0 then + return False; + else + return True; + end if; + end Is_Inside; + +end Polygons; diff --git a/Task/Ray-casting-algorithm/Ada/ray-casting-algorithm-3.ada b/Task/Ray-casting-algorithm/Ada/ray-casting-algorithm-3.ada new file mode 100644 index 0000000000..7662f9a657 --- /dev/null +++ b/Task/Ray-casting-algorithm/Ada/ray-casting-algorithm-3.ada @@ -0,0 +1,91 @@ +with Ada.Text_IO; +with Polygons; +procedure Main is + package Float_IO is new Ada.Text_IO.Float_IO (Float); + Test_Points : Polygons.Point_List := + (( 5.0, 5.0), + ( 5.0, 8.0), + (-10.0, 5.0), + ( 0.0, 5.0), + ( 10.0, 5.0), + ( 8.0, 5.0), + ( 10.0, 10.0)); + Square : Polygons.Polygon := + ((( 0.0, 0.0), (10.0, 0.0)), + ((10.0, 0.0), (10.0, 10.0)), + ((10.0, 10.0), ( 0.0, 10.0)), + (( 0.0, 10.0), ( 0.0, 0.0))); + Square_Hole : Polygons.Polygon := + ((( 0.0, 0.0), (10.0, 0.0)), + ((10.0, 0.0), (10.0, 10.0)), + ((10.0, 10.0), ( 0.0, 10.0)), + (( 0.0, 10.0), ( 0.0, 0.0)), + (( 2.5, 2.5), ( 7.5, 2.5)), + (( 7.5, 2.5), ( 7.5, 7.5)), + (( 7.5, 7.5), ( 2.5, 7.5)), + (( 2.5, 7.5), ( 2.5, 2.5))); + Strange : Polygons.Polygon := + ((( 0.0, 0.0), ( 2.5, 2.5)), + (( 2.5, 2.5), ( 0.0, 10.0)), + (( 0.0, 10.0), ( 2.5, 7.5)), + (( 2.5, 7.5), ( 7.5, 7.5)), + (( 7.5, 7.5), (10.0, 10.0)), + ((10.0, 10.0), (10.0, 0.0)), + ((10.0, 0.0), ( 2.5, 2.5))); + Exagon : Polygons.Polygon := + ((( 3.0, 0.0), ( 7.0, 0.0)), + (( 7.0, 0.0), (10.0, 5.0)), + ((10.0, 5.0), ( 7.0, 10.0)), + (( 7.0, 10.0), ( 3.0, 10.0)), + (( 3.0, 10.0), ( 0.0, 5.0)), + (( 0.0, 5.0), ( 3.0, 0.0))); +begin + Ada.Text_IO.Put_Line ("Testing Square:"); + for Point in Test_Points'Range loop + Ada.Text_IO.Put ("Point("); + Float_IO.Put (Test_Points (Point).X, 0, 0, 0); + Ada.Text_IO.Put (","); + Float_IO.Put (Test_Points (Point).Y, 0, 0, 0); + Ada.Text_IO.Put + ("): " & + Boolean'Image (Polygons.Is_Inside (Test_Points (Point), Square))); + Ada.Text_IO.New_Line; + end loop; + Ada.Text_IO.New_Line; + Ada.Text_IO.Put_Line ("Testing Square_Hole:"); + for Point in Test_Points'Range loop + Ada.Text_IO.Put ("Point("); + Float_IO.Put (Test_Points (Point).X, 0, 0, 0); + Ada.Text_IO.Put (","); + Float_IO.Put (Test_Points (Point).Y, 0, 0, 0); + Ada.Text_IO.Put + ("): " & + Boolean'Image + (Polygons.Is_Inside (Test_Points (Point), Square_Hole))); + Ada.Text_IO.New_Line; + end loop; + Ada.Text_IO.New_Line; + Ada.Text_IO.Put_Line ("Testing Strange:"); + for Point in Test_Points'Range loop + Ada.Text_IO.Put ("Point("); + Float_IO.Put (Test_Points (Point).X, 0, 0, 0); + Ada.Text_IO.Put (","); + Float_IO.Put (Test_Points (Point).Y, 0, 0, 0); + Ada.Text_IO.Put + ("): " & + Boolean'Image (Polygons.Is_Inside (Test_Points (Point), Strange))); + Ada.Text_IO.New_Line; + end loop; + Ada.Text_IO.New_Line; + Ada.Text_IO.Put_Line ("Testing Exagon:"); + for Point in Test_Points'Range loop + Ada.Text_IO.Put ("Point("); + Float_IO.Put (Test_Points (Point).X, 0, 0, 0); + Ada.Text_IO.Put (","); + Float_IO.Put (Test_Points (Point).Y, 0, 0, 0); + Ada.Text_IO.Put + ("): " & + Boolean'Image (Polygons.Is_Inside (Test_Points (Point), Exagon))); + Ada.Text_IO.New_Line; + end loop; +end Main; diff --git a/Task/Ray-casting-algorithm/AutoHotkey/ray-casting-algorithm.ahk b/Task/Ray-casting-algorithm/AutoHotkey/ray-casting-algorithm.ahk new file mode 100644 index 0000000000..296d6b9237 --- /dev/null +++ b/Task/Ray-casting-algorithm/AutoHotkey/ray-casting-algorithm.ahk @@ -0,0 +1,11 @@ +PiP(P,N) ; P is point, N is number of sides +{ + count := 0 + Loop %N% + If ray_intersects_segment(P,A_Index) + count++ + if mod(count,2) + return false ; P isn't in the polygon + else + return true ; P is in the polygon +} diff --git a/Task/Ray-casting-algorithm/C/ray-casting-algorithm.c b/Task/Ray-casting-algorithm/C/ray-casting-algorithm.c new file mode 100644 index 0000000000..a1009f6cba --- /dev/null +++ b/Task/Ray-casting-algorithm/C/ray-casting-algorithm.c @@ -0,0 +1,141 @@ +#include +#include +#include + +typedef struct { double x, y; } vec; +typedef struct { int n; vec* v; } polygon_t, *polygon; + +#define BIN_V(op, xx, yy) vec v##op(vec a,vec b){vec c;c.x=xx;c.y=yy;return c;} +#define BIN_S(op, r) double v##op(vec a, vec b){ return r; } +BIN_V(sub, a.x - b.x, a.y - b.y); +BIN_V(add, a.x + b.x, a.y + b.y); +BIN_S(dot, a.x * b.x + a.y * b.y); +BIN_S(cross, a.x * b.y - a.y * b.x); + +/* return a + s * b */ +vec vmadd(vec a, double s, vec b) +{ + vec c; + c.x = a.x + s * b.x; + c.y = a.y + s * b.y; + return c; +} + +/* check if x0->x1 edge crosses y0->y1 edge. dx = x1 - x0, dy = y1 - y0, then + solve x0 + a * dx == y0 + b * dy with a, b in real + cross both sides with dx, then: (remember, cross product is a scalar) + x0 X dx = y0 X dx + b * (dy X dx) + similarly, + x0 X dy + a * (dx X dy) == y0 X dy + there is an intersection iff 0 <= a <= 1 and 0 <= b <= 1 + + returns: 1 for intersect, -1 for not, 0 for hard to say (if the intersect + point is too close to y0 or y1) +*/ +int intersect(vec x0, vec x1, vec y0, vec y1, double tol, vec *sect) +{ + vec dx = vsub(x1, x0), dy = vsub(y1, y0); + double d = vcross(dy, dx), a; + if (!d) return 0; /* edges are parallel */ + + a = (vcross(x0, dx) - vcross(y0, dx)) / d; + if (sect) + *sect = vmadd(y0, a, dy); + + if (a < -tol || a > 1 + tol) return -1; + if (a < tol || a > 1 - tol) return 0; + + a = (vcross(x0, dy) - vcross(y0, dy)) / d; + if (a < 0 || a > 1) return -1; + + return 1; +} + +/* distance between x and nearest point on y0->y1 segment. if the point + lies outside the segment, returns infinity */ +double dist(vec x, vec y0, vec y1, double tol) +{ + vec dy = vsub(y1, y0); + vec x1, s; + int r; + + x1.x = x.x + dy.y; x1.y = x.y - dy.x; + r = intersect(x, x1, y0, y1, tol, &s); + if (r == -1) return HUGE_VAL; + s = vsub(s, x); + return sqrt(vdot(s, s)); +} + +#define for_v(i, z, p) for(i = 0, z = p->v; i < p->n; i++, z++) +/* returns 1 for inside, -1 for outside, 0 for on edge */ +int inside(vec v, polygon p, double tol) +{ + /* should assert p->n > 1 */ + int i, k, crosses; + vec *pv; + double min_x, max_x, min_y, max_y; + + for (i = 0; i < p->n; i++) { + k = i + 1 % p->n; + min_x = dist(v, p->v[i], p->v[k], tol); + if (min_x < tol) return 0; + } + + min_x = max_x = p->v[0].x; + min_y = max_y = p->v[1].y; + + /* calculate extent of polygon */ + for_v(i, pv, p) { + if (pv->x > max_x) max_x = pv->x; + if (pv->x < min_x) min_x = pv->x; + if (pv->y > max_y) max_y = pv->y; + if (pv->y < min_y) min_y = pv->y; + } + if (v.x < min_x || v.x > max_x || v.y < min_y || v.y > max_y) + return -1; + + max_x -= min_x; max_x *= 2; + max_y -= min_y; max_y *= 2; + max_x += max_y; + + vec e; + while (1) { + crosses = 0; + /* pick a rand point far enough to be outside polygon */ + e.x = v.x + (1 + rand() / (RAND_MAX + 1.)) * max_x; + e.y = v.y + (1 + rand() / (RAND_MAX + 1.)) * max_x; + + for (i = 0; i < p->n; i++) { + k = (i + 1) % p->n; + k = intersect(v, e, p->v[i], p->v[k], tol, 0); + + /* picked a bad point, ray got too close to vertex. + re-pick */ + if (!k) break; + + if (k == 1) crosses++; + } + if (i == p->n) break; + } + return (crosses & 1) ? 1 : -1; +} + +int main() +{ + vec vsq[] = { {0,0}, {10,0}, {10,10}, {0,10}, + {2.5,2.5}, {7.5,0.1}, {7.5,7.5}, {2.5,7.5}}; + + polygon_t sq = { 4, vsq }, /* outer square */ + sq_hole = { 8, vsq }; /* outer and inner square, ie hole */ + + vec c = { 10, 5 }; /* on edge */ + vec d = { 5, 5 }; + + printf("%d\n", inside(c, &sq, 1e-10)); + printf("%d\n", inside(c, &sq_hole, 1e-10)); + + printf("%d\n", inside(d, &sq, 1e-10)); /* in */ + printf("%d\n", inside(d, &sq_hole, 1e-10)); /* out (in the hole) */ + + return 0; +} diff --git a/Task/Ray-casting-algorithm/CoffeeScript/ray-casting-algorithm.coffeescript b/Task/Ray-casting-algorithm/CoffeeScript/ray-casting-algorithm.coffeescript new file mode 100644 index 0000000000..dc00291e32 --- /dev/null +++ b/Task/Ray-casting-algorithm/CoffeeScript/ray-casting-algorithm.coffeescript @@ -0,0 +1,28 @@ + Point = (@x,@y) -> + + pointInPoly = (point,poly) -> + segments = for pointA, index in poly + pointB = poly[(index + 1) % poly.length] + [pointA,pointB] + intesected = (segment for segment in segments when rayIntesectsSegment(point,segment)) + intesected.length % 2 != 0 + + rayIntesectsSegment = (p,segment) -> + [p1,p2] = segment + [a,b] = if p1.y < p2.y + [p1,p2] + else + [p2,p1] + if p.y == b.y || p.y == a.y + p.y += Number.MIN_VALUE + + if p.y > b.y || p.y < a.y + false + else if p.x > a.x && p.x > b.x + false + else if p.x < a.x && p.x < b.x + true + else + mAB = (b.y - a.y) / (b.x - a.x) + mAP = (p.y - a.y) / (p.x - a.x) + mAP > mAB diff --git a/Task/Ray-casting-algorithm/Common-Lisp/ray-casting-algorithm-1.lisp b/Task/Ray-casting-algorithm/Common-Lisp/ray-casting-algorithm-1.lisp new file mode 100644 index 0000000000..00715aee5f --- /dev/null +++ b/Task/Ray-casting-algorithm/Common-Lisp/ray-casting-algorithm-1.lisp @@ -0,0 +1,30 @@ +(defun point-in-polygon (point polygon) + (do ((in-p nil)) ((endp polygon) in-p) + (when (ray-intersects-segment point (pop polygon)) + (setf in-p (not in-p))))) + +(defun ray-intersects-segment (point segment &optional (epsilon .001)) + (destructuring-bind (px . py) point + (destructuring-bind ((ax . ay) . (bx . by)) segment + (when (< ay by) + (rotatef ay by) + (rotatef ax bx)) + (when (or (= py ay) (= py by)) + (incf py epsilon)) + (cond + ;; point is above, below, or to the right of the rectangle + ;; determined by segment; ray does not intesect the segment. + ((or (> px (max ax bx)) (> py (max ay by)) (< py (min ay by))) + nil) + ;; point is to left of the rectangle; ray intersects segment + ((< px (min ax bx)) + t) + ;; point is within the rectangle... + (t (let ((m-red (if (= ax bx) nil + (/ (- by ay) (- bx ax)))) + (m-blue (if (= px ax) nil + (/ (- py ay) (- px ax))))) + (cond + ((null m-blue) t) + ((null m-red) nil) + (t (>= m-blue m-red))))))))) diff --git a/Task/Ray-casting-algorithm/Common-Lisp/ray-casting-algorithm-2.lisp b/Task/Ray-casting-algorithm/Common-Lisp/ray-casting-algorithm-2.lisp new file mode 100644 index 0000000000..199c248b99 --- /dev/null +++ b/Task/Ray-casting-algorithm/Common-Lisp/ray-casting-algorithm-2.lisp @@ -0,0 +1,35 @@ +(defparameter *points* + #((0 . 0) (10 . 0) (10 . 10) (0 . 10) + (2.5 . 2.5) (7.5 . 2.5) (7.5 . 7.5) (2.5 . 7.5) + (0 . 5) (10 . 5) (3 . 0) (7 . 0) + (7 . 10) (3 . 10))) + +(defun create-polygon (indices &optional (points *points*)) + (loop for (a b) on indices by 'cddr + collecting (cons (aref points (1- a)) + (aref points (1- b))))) + +(defun square () + (create-polygon '(1 2 2 3 3 4 4 1))) + +(defun square-hole () + (create-polygon '(1 2 2 3 3 4 4 1 5 6 6 7 7 8 8 5))) + +(defun strange () + (create-polygon '(1 5 5 4 4 8 8 7 7 3 3 2 2 5))) + +(defun exagon () + (create-polygon '(11 12 12 10 10 13 13 14 14 9 9 11))) + +(defparameter *test-points* + #((5 . 5) (5 . 8) (-10 . 5) (0 . 5) + (10 . 5) (8 . 5) (10 . 10))) + +(defun test-pip () + (dolist (shape '(square square-hole strange exagon)) + (print shape) + (loop with polygon = (funcall shape) + for test-point across *test-points* + do (format t "~&~w ~:[outside~;inside ~]." + test-point + (point-in-polygon test-point polygon))))) diff --git a/Task/Ray-casting-algorithm/D/ray-casting-algorithm.d b/Task/Ray-casting-algorithm/D/ray-casting-algorithm.d new file mode 100644 index 0000000000..d7a4239165 --- /dev/null +++ b/Task/Ray-casting-algorithm/D/ray-casting-algorithm.d @@ -0,0 +1,66 @@ +import std.stdio, std.math, std.algorithm; + +immutable struct Point { double x, y; } +immutable struct Edge { Point a, b; } +immutable struct Figure { + string name; + Edge[] edges; +} + +bool contains(in Figure poly, in Point p) pure nothrow { + static bool raySegI(in Point p, in Edge edge) pure nothrow { + enum double epsilon = 0.00001; + with (edge) { + if (a.y > b.y) + //swap(a, b); // if edge is mutable + return raySegI(p, Edge(b, a)); + if (p.y == a.y || p.y == b.y) + //p.y += epsilon; // if p is mutable + return raySegI(Point(p.x, p.y + epsilon), edge); + if (p.y > b.y || p.y < a.y || p.x > max(a.x, b.x)) + return false; + if (p.x < min(a.x, b.x)) + return true; + immutable blue = (abs(a.x - p.x) > double.min) ? + ((p.y - a.y) / (p.x - a.x)) : + double.max; + immutable red = (abs(a.x - b.x) > double.min) ? + ((b.y - a.y) / (b.x - a.x)) : + double.max; + return blue >= red; + } + } + + return poly.edges.count!(e => raySegI(p, e))() % 2; +} + +void main() { + enum Figure[] polys = [ + {"Square", [ + {{ 0.0, 0.0}, {10.0, 0.0}}, {{10.0, 0.0}, {10.0, 10.0}}, + {{10.0, 10.0}, { 0.0, 10.0}}, {{ 0.0, 10.0}, { 0.0, 0.0}}]}, + {"Square hole", [ + {{ 0.0, 0.0}, {10.0, 0.0}}, {{10.0, 0.0}, {10.0, 10.0}}, + {{10.0, 10.0}, { 0.0, 10.0}}, {{ 0.0, 10.0}, { 0.0, 0.0}}, + {{ 2.5, 2.5}, { 7.5, 2.5}}, {{ 7.5, 2.5}, { 7.5, 7.5}}, + {{ 7.5, 7.5}, { 2.5, 7.5}}, {{ 2.5, 7.5}, { 2.5, 2.5}}]}, + {"Strange", [ + {{ 0.0, 0.0}, { 2.5, 2.5}}, {{ 2.5, 2.5}, { 0.0, 10.0}}, + {{ 0.0, 10.0}, { 2.5, 7.5}}, {{ 2.5, 7.5}, { 7.5, 7.5}}, + {{ 7.5, 7.5}, {10.0, 10.0}}, {{10.0, 10.0}, {10.0, 0.0}}, + {{10.0, 0}, { 2.5, 2.5}}]}, + {"Exagon", [ + {{ 3.0, 0.0}, { 7.0, 0.0}}, {{ 7.0, 0.0}, {10.0, 5.0}}, + {{10.0, 5.0}, { 7.0, 10.0}}, {{ 7.0, 10.0}, { 3.0, 10.0}}, + {{ 3.0, 10.0}, { 0.0, 5.0}}, {{ 0.0, 5.0}, { 3.0, 0.0}}]} +]; + enum Point[] testPoints = [{ 5, 5}, {5, 8}, {-10, 5}, {0, 5}, + {10, 5}, {8, 5}, { 10, 10}]; + + foreach (poly; polys) { + writefln(`Is point inside figure "%s"?`, poly.name); + foreach (p; testPoints) + writefln(" (%3s, %2s): %s", p.x, p.y, contains(poly, p)); + writeln(); + } +} diff --git a/Task/Ray-casting-algorithm/Factor/ray-casting-algorithm-1.factor b/Task/Ray-casting-algorithm/Factor/ray-casting-algorithm-1.factor new file mode 100644 index 0000000000..9784d2274e --- /dev/null +++ b/Task/Ray-casting-algorithm/Factor/ray-casting-algorithm-1.factor @@ -0,0 +1,19 @@ +USING: kernel prettyprint sequences arrays math math.vectors ; +IN: raycasting + +: between ( a b x -- ? ) [ last ] tri@ [ < ] curry bi@ xor ; + +: lincomb ( a b x -- w ) + 3dup [ last ] tri@ + [ - ] curry bi@ + [ drop ] 2dip + neg 2dup + [ / ] curry bi@ + [ [ v*n ] curry ] bi@ bi* v+ ; +: leftof ( a b x -- ? ) dup [ lincomb ] dip [ first ] bi@ > ; + +: ray ( a b x -- ? ) [ between ] [ leftof ] 3bi and ; + +: raycast ( poly x -- ? ) + [ dup first suffix [ rest-slice ] [ but-last-slice ] bi ] dip + [ ray ] curry 2map + f [ xor ] reduce ; diff --git a/Task/Ray-casting-algorithm/Factor/ray-casting-algorithm-2.factor b/Task/Ray-casting-algorithm/Factor/ray-casting-algorithm-2.factor new file mode 100644 index 0000000000..b67ca84055 --- /dev/null +++ b/Task/Ray-casting-algorithm/Factor/ray-casting-algorithm-2.factor @@ -0,0 +1,7 @@ +( scratchpad ) CONSTANT: square { { -2 -1 } { 1 -2 } { 2 1 } { -1 2 } } +( scratchpad ) square { 0 0 } raycast . +t +( scratchpad ) square { 5 5 } raycast . +f +( scratchpad ) square { 2 0 } raycast . +f diff --git a/Task/Ray-casting-algorithm/Fortran/ray-casting-algorithm-1.f b/Task/Ray-casting-algorithm/Fortran/ray-casting-algorithm-1.f new file mode 100644 index 0000000000..f5dc465a60 --- /dev/null +++ b/Task/Ray-casting-algorithm/Fortran/ray-casting-algorithm-1.f @@ -0,0 +1,35 @@ +module Polygons + use Points_Module + implicit none + + type polygon + type(point), dimension(:), allocatable :: points + integer, dimension(:), allocatable :: vertices + end type polygon + +contains + + function create_polygon(pts, vt) + type(polygon) :: create_polygon + type(point), dimension(:), intent(in) :: pts + integer, dimension(:), intent(in) :: vt + + integer :: np, nv + + np = size(pts,1) + nv = size(vt,1) + + allocate(create_polygon%points(np), create_polygon%vertices(nv)) + create_polygon%points = pts + create_polygon%vertices = vt + + end function create_polygon + + subroutine free_polygon(pol) + type(polygon), intent(inout) :: pol + + deallocate(pol%points, pol%vertices) + + end subroutine free_polygon + +end module Polygons diff --git a/Task/Ray-casting-algorithm/Fortran/ray-casting-algorithm-2.f b/Task/Ray-casting-algorithm/Fortran/ray-casting-algorithm-2.f new file mode 100644 index 0000000000..1c0a2ff8de --- /dev/null +++ b/Task/Ray-casting-algorithm/Fortran/ray-casting-algorithm-2.f @@ -0,0 +1,77 @@ +module Ray_Casting_Algo + use Polygons + implicit none + + real, parameter, private :: eps = 0.00001 + private :: ray_intersects_seg + +contains + + function ray_intersects_seg(p0, a0, b0) result(intersect) + type(point), intent(in) :: p0, a0, b0 + logical :: intersect + + type(point) :: a, b, p + real :: m_red, m_blue + + p = p0 + ! let variable "a" be the point with smallest y coordinate + if ( a0%y > b0%y ) then + b = a0 + a = b0 + else + a = a0 + b = b0 + end if + + if ( (p%y == a%y) .or. (p%y == b%y) ) p%y = p%y + eps + + intersect = .false. + + if ( (p%y > b%y) .or. (p%y < a%y) ) return + if ( p%x > max(a%x, b%x) ) return + + if ( p%x < min(a%x, b%x) ) then + intersect = .true. + else + if ( abs(a%x - b%x) > tiny(a%x) ) then + m_red = (b%y - a%y) / (b%x - a%x) + else + m_red = huge(m_red) + end if + if ( abs(a%x - p%x) > tiny(a%x) ) then + m_blue = (p%y - a%y) / (p%x - a%x) + else + m_blue = huge(m_blue) + end if + if ( m_blue >= m_red ) then + intersect = .true. + else + intersect = .false. + end if + end if + + end function ray_intersects_seg + + function point_is_inside(p, pol) result(inside) + logical :: inside + type(point), intent(in) :: p + type(polygon), intent(in) :: pol + + integer :: i, cnt, pa, pb + + cnt = 0 + do i = lbound(pol%vertices,1), ubound(pol%vertices,1), 2 + pa = pol%vertices(i) + pb = pol%vertices(i+1) + if ( ray_intersects_seg(p, pol%points(pa), pol%points(pb)) ) cnt = cnt + 1 + end do + + inside = .true. + if ( mod(cnt, 2) == 0 ) then + inside = .false. + end if + + end function point_is_inside + +end module Ray_Casting_Algo diff --git a/Task/Ray-casting-algorithm/Fortran/ray-casting-algorithm-3.f b/Task/Ray-casting-algorithm/Fortran/ray-casting-algorithm-3.f new file mode 100644 index 0000000000..ef7ed600e0 --- /dev/null +++ b/Task/Ray-casting-algorithm/Fortran/ray-casting-algorithm-3.f @@ -0,0 +1,40 @@ +program Pointpoly + use Points_Module + use Ray_Casting_Algo + implicit none + + character(len=16), dimension(4) :: names + type(polygon), dimension(4) :: polys + type(point), dimension(14) :: pts + type(point), dimension(7) :: p + + integer :: i, j + + pts = (/ point(0,0), point(10,0), point(10,10), point(0,10), & + point(2.5,2.5), point(7.5,2.5), point(7.5,7.5), point(2.5,7.5), & + point(0,5), point(10,5), & + point(3,0), point(7,0), point(7,10), point(3,10) /) + + polys(1) = create_polygon(pts, (/ 1,2, 2,3, 3,4, 4,1 /) ) + polys(2) = create_polygon(pts, (/ 1,2, 2,3, 3,4, 4,1, 5,6, 6,7, 7,8, 8,5 /) ) + polys(3) = create_polygon(pts, (/ 1,5, 5,4, 4,8, 8,7, 7,3, 3,2, 2,5 /) ) + polys(4) = create_polygon(pts, (/ 11,12, 12,10, 10,13, 13,14, 14,9, 9,11 /) ) + + names = (/ "square", "square hole", "strange", "exagon" /) + + p = (/ point(5,5), point(5, 8), point(-10, 5), point(0,5), point(10,5), & + point(8,5), point(10,10) /) + + do j = 1, size(p) + do i = 1, size(polys) + write(*, "('point (',F8.2,',',F8.2,') is inside ',A,'? ', L)") & + p(j)%x, p(j)%y, names(i), point_is_inside(p(j), polys(i)) + end do + print *, "" + end do + + do i = 1, size(polys) + call free_polygon(polys(i)) + end do + +end program Pointpoly diff --git a/Task/Ray-casting-algorithm/Go/ray-casting-algorithm-1.go b/Task/Ray-casting-algorithm/Go/ray-casting-algorithm-1.go new file mode 100644 index 0000000000..97019c874b --- /dev/null +++ b/Task/Ray-casting-algorithm/Go/ray-casting-algorithm-1.go @@ -0,0 +1,97 @@ +package main + +import ( + "math" + "fmt" +) + +type xy struct { + x, y float64 +} + +type seg struct { + p1, p2 xy +} + +type poly struct { + name string + sides []seg +} + +func inside(pt xy, pg poly) (i bool) { + for _, side := range pg.sides { + if rayIntersectsSegment(pt, side) { + i = !i + } + } + return +} + +func rayIntersectsSegment(p xy, s seg) bool { + var a, b xy + if s.p1.y < s.p2.y { + a, b = s.p1, s.p2 + } else { + a, b = s.p2, s.p1 + } + for p.y == a.y || p.y == b.y { + p.y = math.Nextafter(p.y, math.Inf(1)) + } + if p.y < a.y || p.y > b.y { + return false + } + if a.x > b.x { + if p.x > a.x { + return false + } + if p.x < b.x { + return true + } + } else { + if p.x > b.x { + return false + } + if p.x < a.x { + return true + } + } + return (p.y-a.y)/(p.x-a.x) >= (b.y-a.y)/(b.x-a.x) +} + +var ( + p1 = xy{0, 0} + p2 = xy{10, 0} + p3 = xy{10, 10} + p4 = xy{0, 10} + p5 = xy{2.5, 2.5} + p6 = xy{7.5, 2.5} + p7 = xy{7.5, 7.5} + p8 = xy{2.5, 7.5} + p9 = xy{0, 5} + p10 = xy{10, 5} + p11 = xy{3, 0} + p12 = xy{7, 0} + p13 = xy{7, 10} + p14 = xy{3, 10} +) + +var tpg = []poly{ + {"square", []seg{{p1, p2}, {p2, p3}, {p3, p4}, {p4, p1}}}, + {"square hole", []seg{{p1, p2}, {p2, p3}, {p3, p4}, {p4, p1}, + {p5, p6}, {p6, p7}, {p7, p8}, {p8, p5}}}, + {"strange", []seg{{p1, p5}, + {p5, p4}, {p4, p8}, {p8, p7}, {p7, p3}, {p3, p2}, {p2, p5}}}, + {"exagon", []seg{{p11, p12}, {p12, p10}, {p10, p13}, + {p13, p14}, {p14, p9}, {p9, p11}}}, +} + +var tpt = []xy{{5, 5}, {5, 8}, {-10, 5}, {0, 5}, {10, 5}, {8, 5}, {10, 10}} + +func main() { + for _, pg := range tpg { + fmt.Printf("%s:\n", pg.name) + for _, pt := range tpt { + fmt.Println(pt, inside(pt, pg)) + } + } +} diff --git a/Task/Ray-casting-algorithm/Go/ray-casting-algorithm-2.go b/Task/Ray-casting-algorithm/Go/ray-casting-algorithm-2.go new file mode 100644 index 0000000000..da91e4b6f2 --- /dev/null +++ b/Task/Ray-casting-algorithm/Go/ray-casting-algorithm-2.go @@ -0,0 +1,76 @@ +package main + +import ( + "math" + "fmt" +) + +type xy struct { + x, y float64 +} + +type closedPoly struct { + name string + vert []xy +} + +func inside(pt xy, pg closedPoly) bool { + if len(pg.vert) < 3 { + return false + } + in := rayIntersectsSegment(pt, pg.vert[len(pg.vert)-1], pg.vert[0]) + for i := 1; i < len(pg.vert); i++ { + if rayIntersectsSegment(pt, pg.vert[i-1], pg.vert[i]) { + in = !in + } + } + return in +} + +func rayIntersectsSegment(p, a, b xy) bool { + if a.y > b.y { + a, b = b, a + } + for p.y == a.y || p.y == b.y { + p.y = math.Nextafter(p.y, math.Inf(1)) + } + if p.y < a.y || p.y > b.y { + return false + } + if a.x > b.x { + if p.x > a.x { + return false + } + if p.x < b.x { + return true + } + } else { + if p.x > b.x { + return false + } + if p.x < a.x { + return true + } + } + return (p.y-a.y)/(p.x-a.x) >= (b.y-a.y)/(b.x-a.x) +} + +var tpg = []closedPoly{ + {"square", []xy{{0, 0}, {10, 0}, {10, 10}, {0, 10}}}, + {"square hole", []xy{{0, 0}, {10, 0}, {10, 10}, {0, 10}, {0, 0}, + {2.5, 2.5}, {7.5, 2.5}, {7.5, 7.5}, {2.5, 7.5}, {2.5, 2.5}}}, + {"strange", []xy{{0, 0}, {2.5, 2.5}, {0, 10}, {2.5, 7.5}, {7.5, 7.5}, + {10, 10}, {10, 0}, {2.5, 2.5}}}, + {"exagon", []xy{{3, 0}, {7, 0}, {10, 5}, {7, 10}, {3, 10}, {0, 5}}}, +} + +var tpt = []xy{{1, 2}, {2, 1}} + +func main() { + for _, pg := range tpg { + fmt.Printf("%s:\n", pg.name) + for _, pt := range tpt { + fmt.Println(pt, inside(pt, pg)) + } + } +} diff --git a/Task/Ray-casting-algorithm/Haskell/ray-casting-algorithm.hs b/Task/Ray-casting-algorithm/Haskell/ray-casting-algorithm.hs new file mode 100644 index 0000000000..0260a7d0bd --- /dev/null +++ b/Task/Ray-casting-algorithm/Haskell/ray-casting-algorithm.hs @@ -0,0 +1,49 @@ +import Data.Ratio + +type Point = (Rational, Rational) +type Polygon = [Point] +data Line = Sloped {lineSlope, lineYIntercept :: Rational} | + Vert {lineXIntercept :: Rational} + +polygonSides :: Polygon -> [(Point, Point)] +polygonSides poly@(p1 : ps) = zip poly $ ps ++ [p1] + +intersects :: Point -> Line -> Bool +{- @intersects (px, py) l@ is true if the ray {(x, py) | x ≥ px} +intersects l. -} +intersects (px, _) (Vert xint) = px <= xint +intersects (px, py) (Sloped m b) | m < 0 = py <= m * px + b + | otherwise = py >= m * px + b + +onLine :: Point -> Line -> Bool +{- Is the point on the line? -} +onLine (px, _) (Vert xint) = px == xint +onLine (px, py) (Sloped m b) = py == m * px + b + +carrier :: (Point, Point) -> Line +{- Finds the line containing the given line segment. -} +carrier ((ax, ay), (bx, by)) | ax == bx = Vert ax + | otherwise = Sloped slope yint + where slope = (ay - by) / (ax - bx) + yint = ay - slope * ax + +between :: Ord a => a -> a -> a -> Bool +between x a b | a > b = b <= x && x <= a + | otherwise = a <= x && x <= b + +inPolygon :: Point -> Polygon -> Bool +inPolygon p@(px, py) = f 0 . polygonSides + where f n [] = odd n + f n (side : sides) | far = f n sides + | onSegment = True + | rayIntersects = f (n + 1) sides + | otherwise = f n sides + where far = not $ between py ay by + onSegment | ay == by = between px ax bx + | otherwise = p `onLine` line + rayIntersects = + intersects p line && + (py /= ay || by < py) && + (py /= by || ay < py) + ((ax, ay), (bx, by)) = side + line = carrier side diff --git a/Task/Ray-casting-algorithm/J/ray-casting-algorithm-1.j b/Task/Ray-casting-algorithm/J/ray-casting-algorithm-1.j new file mode 100644 index 0000000000..0e16c5b270 --- /dev/null +++ b/Task/Ray-casting-algorithm/J/ray-casting-algorithm-1.j @@ -0,0 +1,9 @@ +NB.*crossPnP v point in closed polygon, crossing number +NB. bool=. points crossPnP polygon +crossPnP=: 4 : 0"2 + 'X Y'=. |:x + 'x0 y0 x1 y1'=. |:2 ,/\^:(2={:@$@]) y + p1=. ((y0<:/Y)*. y1>/Y) +. (y0>/Y)*. y1<:/Y + p2=. (x0-/X) < (x0-x1) * (y0-/Y) % (y0 - y1) + 2|+/ p1*.p2 +) diff --git a/Task/Ray-casting-algorithm/J/ray-casting-algorithm-2.j b/Task/Ray-casting-algorithm/J/ray-casting-algorithm-2.j new file mode 100644 index 0000000000..68c6b4acbf --- /dev/null +++ b/Task/Ray-casting-algorithm/J/ray-casting-algorithm-2.j @@ -0,0 +1,11 @@ +SQUAREV=: 0 0 , 10 0 , 10 10 ,: 0 10 +SQUAREV=: SQUAREV, 2.5 2.5 , 7.5 0.1 , 7.5 7.5 ,: 2.5 7.5 + +ESAV=: 3 0 , 7 0 , 10 5 , 7 10 , 3 10 ,: 0 5 + +ESA=: (0 1,1 2,2 3,3 4,4 5,:5 0) , .{ ESAV +SQUARE=: (0 1,1 2,2 3,:3 0) , .{ SQUAREV +SQUAREHOLE=: (0 1,1 2,2 3,3 0,4 5,5 6,6 7,:7 4) , .{ SQUAREV +STRANGE=: (0 4,4 3,3 7,7 6,6 2,2 1,1 5,:5 0) , .{ SQUAREV + +POINTS=: 5 5,5 8,2 2,0 0,10 10,2.5 2.5,0.01 5,2.2 7.4,0 5,10 5,:_4 10 diff --git a/Task/Ray-casting-algorithm/J/ray-casting-algorithm-3.j b/Task/Ray-casting-algorithm/J/ray-casting-algorithm-3.j new file mode 100644 index 0000000000..4632e2dd4d --- /dev/null +++ b/Task/Ray-casting-algorithm/J/ray-casting-algorithm-3.j @@ -0,0 +1,5 @@ + (=y)) Or ((yp(j)=y)) Then + f1 = y - yp(i):f2 = yp(j) - yp(i): f3 = xp(j) - xp(i) + If (xp(i) + f1 / f2 * f3) < x Then oddNodes = 1 - oddNodes + End If + j = i + Next + pnp = oddNodes +End Function + +'draw the polygon +Sub drawPoly h$, verts, colour$ + #h$, "Color ";colour$ + j = verts-1 + For i = 0 To verts-1 + #h$ "Line ";xp(j);" ";yp(j);" ";xp(i);" ";yp(i) + j = i + Next +End Sub + +'change message and color of polygon +Sub checkPoint h$, x, y + If pnp(x,y,verts) Then + #h$ "Color 32 160 255;BackColor 32 160 255" + #h$ "Place 5 0;BoxFilled 150 20;Color white" + #h$ "Place 7 15;\Mouse In Polygon" + Call drawPoly h$, verts, "red" + Else + #h$ "Color 32 160 255;BackColor 32 160 255" + #h$ "Place 5 0;BoxFilled 150 20;Color white" + #h$ "Place 7 15;\Mouse Not In Polygon" + Call drawPoly h$, verts, "white" + End If +End Sub + +Function rand(loNum,hiNum) + rand = Int(Rnd(0)*(hiNum-loNum+1)+loNum) +End Function diff --git a/Task/Ray-casting-algorithm/OCaml/ray-casting-algorithm.ocaml b/Task/Ray-casting-algorithm/OCaml/ray-casting-algorithm.ocaml new file mode 100644 index 0000000000..ac1678e582 --- /dev/null +++ b/Task/Ray-casting-algorithm/OCaml/ray-casting-algorithm.ocaml @@ -0,0 +1,97 @@ +type point = { x:float; y:float } + +type polygon = { + vertices: point array; + edges: (int * int) list; +} + +let p x y = { x=x; y=y } + +let square_v = [| + (p 0. 0.); (p 10. 0.); (p 10. 10.); (p 0. 10.); + (p 2.5 2.5); (p 7.5 0.1); (p 7.5 7.5); (p 2.5 7.5) +|] + +let esa_v = [| + (p 3. 0.); (p 7. 0.); (p 10. 5.); (p 7. 10.); (p 3. 10.); (p 0. 5.) +|] + +let esa = { + vertices = esa_v; + edges = [ (0,1); (1,2); (2,3); (3,4); (4,5); (5,0) ] +} + +let square = { + vertices = square_v; + edges = [ (0,1); (1,2); (2,3); (3,0) ] +} + +let squarehole = { + vertices = square_v; + edges = [ (0,1); (1,2); (2,3); (3,0); (4,5); (5,6); (6,7); (7,4) ] +} + +let strange = { + vertices = square_v; + edges = [ (0,4); (4,3); (3,7); (7,6); (6,2); (2,1); (1,5); (5,0) ] +} + + +let min_y ~a ~b = if a.y > b.y then (b) else (a) + +let coeff_ang ~pa ~pb = (pb.y -. pa.y) /. (pb.x -. pa.x) + +let huge_val = infinity + +let hseg_intersect_seg ~s ~a ~b = + let _eps = + if s.y = (max a.y b.y) || + s.y = (min a.y b.y) then 0.00001 else 0.0 + in + if (s.y +. _eps) > (max a.y b.y) || + (s.y +. _eps) < (min a.y b.y) || + s.x > (max a.x b.x) then (false) + else if s.x <= (min a.x b.x) then (true) + else + let ca = if a.x <> b.x then (coeff_ang a b) else (huge_val) in + let my = min_y ~a ~b in + let cp = if (s.x -. my.x) <> 0.0 then (coeff_ang my s) else (huge_val) in + (cp >= ca) +;; + + +let point_is_inside ~poly ~pt = + let cross = ref 0 in + List.iter (fun (a,b) -> + if hseg_intersect_seg pt + poly.vertices.(a) + poly.vertices.(b) + then incr cross + ) poly.edges; + ( (!cross mod 2) <> 0) +;; + + +let make_test p label s = + Printf.printf "point (%.5f,%.5f) is " p.x p.y; + print_string (if point_is_inside s p + then "INSIDE " + else "OUTSIDE "); + print_endline label; +;; + + +let () = + let test_points = [ + (p 5. 5.); (p 5. 8.); (p 2. 2.); (p 0. 0.); + (p 10. 10.); (p 2.5 2.5); (p 0.01 5.); + (p 2.2 7.4); (p 0. 5.); (p 10. 5.); (p (-4.) 10.) ] in + + List.iter (fun p -> + make_test p "square" square; + make_test p "squarehole" squarehole; + make_test p "strange" strange; + make_test p "esa" esa; + print_newline() + ) test_points; +;; diff --git a/Task/Ray-casting-algorithm/Perl-6/ray-casting-algorithm.pl6 b/Task/Ray-casting-algorithm/Perl-6/ray-casting-algorithm.pl6 new file mode 100644 index 0000000000..995bbdb698 --- /dev/null +++ b/Task/Ray-casting-algorithm/Perl-6/ray-casting-algorithm.pl6 @@ -0,0 +1,72 @@ +constant ε = 0.0001; + +sub ray-hits-seg([\Px,\Py], [[\Ax,\Ay], [\Bx,\By]] --> Bool) { + Py += ε if Py == Ay | By; + + if Py < Ay or Py > By or Px > (Ax max Bx) { + False; + } + elsif Px < (Ax min Bx) { + True; + } + else { + my \red = Ax == Bx ?? Inf !! (By - Ay) / (Bx - Ax); + my \blue = Ax == Px ?? Inf !! (Py - Ay) / (Px - Ax); + blue >= red; + } +} + +sub point-in-poly(@point, @polygon --> Bool) { + so 2 R% [+] gather for @polygon -> @side { + take ray-hits-seg @point, @side.sort(*.[1]); + } +} + +my %poly = + squared => + [[[ 0.0, 0.0], [10.0, 0.0]], + [[10.0, 0.0], [10.0, 10.0]], + [[10.0, 10.0], [ 0.0, 10.0]], + [[ 0.0, 10.0], [ 0.0, 0.0]]], + squaredhole => + [[[ 0.0, 0.0], [10.0, 0.0]], + [[10.0, 0.0], [10.0, 10.0]], + [[10.0, 10.0], [ 0.0, 10.0]], + [[ 0.0, 10.0], [ 0.0, 0.0]], + [[ 2.5, 2.5], [ 7.5, 2.5]], + [[ 7.5, 2.5], [ 7.5, 7.5]], + [[ 7.5, 7.5], [ 2.5, 7.5]], + [[ 2.5, 7.5], [ 2.5, 2.5]]], + strange => + [[[ 0.0, 0.0], [ 2.5, 2.5]], + [[ 2.5, 2.5], [ 0.0, 10.0]], + [[ 0.0, 10.0], [ 2.5, 7.5]], + [[ 2.5, 7.5], [ 7.5, 7.5]], + [[ 7.5, 7.5], [10.0, 10.0]], + [[10.0, 10.0], [10.0, 0.0]], + [[10.0, 0.0], [ 2.5, 2.5]], + [[ 2.5, 2.5], [ 0.0, 0.0]]], # conjecturally close polygon + exagon => + [[[ 3.0, 0.0], [ 7.0, 0.0]], + [[ 7.0, 0.0], [10.0, 5.0]], + [[10.0, 5.0], [ 7.0, 10.0]], + [[ 7.0, 10.0], [ 3.0, 10.0]], + [[ 3.0, 10.0], [ 0.0, 5.0]], + [[ 0.0, 5.0], [ 3.0, 0.0]]]; + +my @test-points = + [ 5.0, 5.0], + [ 5.0, 8.0], + [-10.0, 5.0], + [ 0.0, 5.0], + [ 10.0, 5.0], + [ 8.0, 5.0], + [ 10.0, 10.0]; + +for -> $polywanna { + say "$polywanna"; + my @poly = %poly{$polywanna}[]; + for @test-points -> @point { + say "\t(@point.fmt('%.1f',','))\t{ point-in-poly(@point, @poly) ?? 'IN' !! 'OUT' }"; + } +} diff --git a/Task/Ray-casting-algorithm/Perl/ray-casting-algorithm-1.pl b/Task/Ray-casting-algorithm/Perl/ray-casting-algorithm-1.pl new file mode 100644 index 0000000000..526826fed4 --- /dev/null +++ b/Task/Ray-casting-algorithm/Perl/ray-casting-algorithm-1.pl @@ -0,0 +1,38 @@ +use strict; +use List::Util qw(max min); + +sub point_in_polygon +{ + my ( $point, $polygon ) = @_; + + my $count = 0; + foreach my $side ( @$polygon ) { + $count++ if ray_intersect_segment($point, $side); + } + return ($count % 2 == 0) ? 0 : 1; +} + + +my $eps = 0.0001; +my $inf = 1e600; + +sub ray_intersect_segment +{ + my ($point, $segment) = @_; + + my ($A, $B) = @$segment; + + my @P = @$point; # copy it + + ($A, $B) = ($B, $A) if $A->[1] > $B->[1]; + + $P[1] += $eps if ($P[1] == $A->[1]) || ($P[1] == $B->[1]); + + return 0 if ($P[1] < $A->[1]) || ( $P[1] > $B->[1]) || ($P[0] > max($A->[0],$B->[1]) ); + return 1 if $P[0] < min($A->[0], $B->[0]); + + my $m_red = ($A->[0] != $B->[0]) ? ( $B->[1] - $A->[1] )/($B->[0] - $A->[0]) : $inf; + my $m_blue = ($A->[0] != $P[0]) ? ( $P[1] - $A->[1] )/($P[0] - $A->[0]) : $inf; + + return ($m_blue >= $m_red) ? 1 : 0; +} diff --git a/Task/Ray-casting-algorithm/Perl/ray-casting-algorithm-2.pl b/Task/Ray-casting-algorithm/Perl/ray-casting-algorithm-2.pl new file mode 100644 index 0000000000..6feac4d077 --- /dev/null +++ b/Task/Ray-casting-algorithm/Perl/ray-casting-algorithm-2.pl @@ -0,0 +1,37 @@ +# the following are utilities to use the same Fortran data... +sub point +{ + [shift, shift]; +} +sub create_polygon +{ + my ($pts, $sides) = @_; + my @poly; + for(my $i = 0; $i < $#$sides; $i += 2) { + push @poly, [ $pts->[$sides->[$i]-1], $pts->[$sides->[$i+1]-1] ]; + } + @poly; +} + +my @pts = ( point(0,0), point(10,0), point(10,10), point(0,10), + point(2.5,2.5), point(7.5,2.5), point(7.5,7.5), point(2.5,7.5), + point(0,5), point(10,5), + point(3,0), point(7,0), point(7,10), point(3,10) ); + +my @squared = create_polygon(\@pts, [ 1,2, 2,3, 3,4, 4,1 ] ); +my @squaredhole = create_polygon(\@pts, [ 1,2, 2,3, 3,4, 4,1, 5,6, 6,7, 7,8, 8,5 ] ); +my @strange = create_polygon(\@pts, [ 1,5, 5,4, 4,8, 8,7, 7,3, 3,2, 2,5 ] ); +my @exagon = create_polygon(\@pts, [ 11,12, 12,10, 10,13, 13,14, 14,9, 9,11 ]) ; + +my @p = ( point(5,5), point(5, 8), point(-10, 5), point(0,5), point(10,5), & + point(8,5), point(10,10) ); + +foreach my $pol ( qw(squared squaredhole strange exagon) ) { + no strict 'refs'; + print "$pol\n"; + my @rp = @{$pol}; + foreach my $tp ( @p ) { + print "\t($tp->[0],$tp->[1]) " . + ( point_in_polygon($tp, \@rp) ? "INSIDE" : "OUTSIDE" ) . "\n"; + } +} diff --git a/Task/Ray-casting-algorithm/PicoLisp/ray-casting-algorithm.l b/Task/Ray-casting-algorithm/PicoLisp/ray-casting-algorithm.l new file mode 100644 index 0000000000..156b5167b7 --- /dev/null +++ b/Task/Ray-casting-algorithm/PicoLisp/ray-casting-algorithm.l @@ -0,0 +1,27 @@ +(scl 4) + +(de intersects (Px Py Ax Ay Bx By) + (when (> Ay By) + (xchg 'Ax 'Bx) + (xchg 'Ay 'By) ) + (when (or (= Py Ay) (= Py By)) + (inc 'Py) ) + (and + (>= Py Ay) + (>= By Py) + (>= (max Ax Bx) Px) + (or + (> (min Ax Bx) Px) + (= Ax Px) + (and + (<> Ax Bx) + (>= + (*/ (- Py Ay) 1.0 (- Px Ax)) # Blue + (*/ (- By Ay) 1.0 (- Bx Ax)) ) ) ) ) ) # Red + +(de inside (Pt Poly) + (let Res NIL + (for Edge Poly + (when (apply intersects Edge (car Pt) (cdr Pt)) + (onOff Res) ) ) + Res ) ) diff --git a/Task/Ray-casting-algorithm/PureBasic/ray-casting-algorithm.purebasic b/Task/Ray-casting-algorithm/PureBasic/ray-casting-algorithm.purebasic new file mode 100644 index 0000000000..a38f5fb18e --- /dev/null +++ b/Task/Ray-casting-algorithm/PureBasic/ray-casting-algorithm.purebasic @@ -0,0 +1,83 @@ +Structure point_f + x.f + y.f +EndStructure +Procedure inpoly(*p.point_f, List poly.point_f()) + Protected.point_f new, old, lp, rp + Protected inside + If ListSize(poly()) < 3: ProcedureReturn 0: EndIf + LastElement(poly()): old = poly() + ForEach poly() + ;find leftmost endpoint 'lp' and the rightmost endpoint 'rp' based on x value + If poly()\x > old\x + lp = old + rp = poly() + Else + lp = poly() + rp = old + EndIf + If lp\x < *p\x And *p\x <= rp\x And (*p\y - lp\y) * (rp\x - lp\x) < (rp\y - lp\y) * (*p\x - lp\x) + inside = ~inside + EndIf + old = poly() + Next + ProcedureReturn inside & 1 +EndProcedure + +If InitSprite() + If InitKeyboard() And InitMouse() + OpenWindow(0, 0, 0, 800, 600, "Press [Esc] to close, [Left mouse button] Add Point, [Right mouse button] Clear All Points.", #PB_Window_ScreenCentered | #PB_Window_SystemMenu) + OpenWindowedScreen(WindowID(0), 0, 0, 800, 600, 1, 0, 0) + SetFrameRate(60) + EndIf +Else + MessageRequester("", "Unable to initsprite"): End +EndIf + +NewList v.point_f() +Define.point_f pvp, mp +Define Col, EventID, mode.b, modetxt.s +Repeat + Delay(1) + EventID = WindowEvent() + ExamineKeyboard() + ExamineMouse() + ClearScreen(Col) + + mp\x = MouseX() + mp\y = MouseY() + If MouseButton(#PB_MouseButton_Left) + AddElement(v()) + v()\x = mp\x + v()\y = mp\y + Delay(100) + EndIf + + If MouseButton(#PB_MouseButton_Right) + ClearList(v()) + Delay(100) + EndIf + + StartDrawing(ScreenOutput()) + If LastElement(v()) + pvp = v() + ForEach v() + LineXY(pvp\x, pvp\y, v()\x, v()\y, RGB(0, $FF, 0)) ;Green + Circle(pvp\x, pvp\y, 5, RGB($FF, 0, 0)) ;Red + pvp = v() + Next + EndIf + Circle(MouseX(), MouseY(), 5, RGB($C0, $C0, $FF)) ;LightBlue + + If inpoly(mp, v()) + modetxt = "You are in the polygon." + Col = RGB(0, 0, 0) + Else + modetxt = "You are not in the polygon." + Col = RGB($50, $50, $50) + EndIf + DrawText((800 - TextWidth(modetxt)) / 2, 0, modetxt) + StopDrawing() + + FlipBuffers() +Until KeyboardReleased(#PB_Key_Escape) Or EventID = #PB_Event_CloseWindow diff --git a/Task/Ray-casting-algorithm/Python/ray-casting-algorithm-1.py b/Task/Ray-casting-algorithm/Python/ray-casting-algorithm-1.py new file mode 100644 index 0000000000..95dfe0db14 --- /dev/null +++ b/Task/Ray-casting-algorithm/Python/ray-casting-algorithm-1.py @@ -0,0 +1,102 @@ +from collections import namedtuple +from pprint import pprint as pp +import sys + +Pt = namedtuple('Pt', 'x, y') # Point +Edge = namedtuple('Edge', 'a, b') # Polygon edge from a to b +Poly = namedtuple('Poly', 'name, edges') # Polygon + +_eps = 0.00001 +_huge = sys.float_info.max +_tiny = sys.float_info.min + +def rayintersectseg(p, edge): + ''' takes a point p=Pt() and an edge of two endpoints a,b=Pt() of a line segment returns boolean + ''' + a,b = edge + if a.y > b.y: + a,b = b,a + if p.y == a.y or p.y == b.y: + p = Pt(p.x, p.y + _eps) + + intersect = False + + if (p.y > b.y or p.y < a.y) or ( + p.x > max(a.x, b.x)): + return False + + if p.x < min(a.x, b.x): + intersect = True + else: + if abs(a.x - b.x) > _tiny: + m_red = (b.y - a.y) / float(b.x - a.x) + else: + m_red = _huge + if abs(a.x - p.x) > _tiny: + m_blue = (p.y - a.y) / float(p.x - a.x) + else: + m_blue = _huge + intersect = m_blue >= m_red + return intersect + +def _odd(x): return x%2 == 1 + +def ispointinside(p, poly): + ln = len(poly) + return _odd(sum(rayintersectseg(p, edge) + for edge in poly.edges )) + +def polypp(poly): + print "\n Polygon(name='%s', edges=(" % poly.name + print ' ', ',\n '.join(str(e) for e in poly.edges) + '\n ))' + +if __name__ == '__main__': + polys = [ + Poly(name='square', edges=( + Edge(a=Pt(x=0, y=0), b=Pt(x=10, y=0)), + Edge(a=Pt(x=10, y=0), b=Pt(x=10, y=10)), + Edge(a=Pt(x=10, y=10), b=Pt(x=0, y=10)), + Edge(a=Pt(x=0, y=10), b=Pt(x=0, y=0)) + )), + Poly(name='square_hole', edges=( + Edge(a=Pt(x=0, y=0), b=Pt(x=10, y=0)), + Edge(a=Pt(x=10, y=0), b=Pt(x=10, y=10)), + Edge(a=Pt(x=10, y=10), b=Pt(x=0, y=10)), + Edge(a=Pt(x=0, y=10), b=Pt(x=0, y=0)), + Edge(a=Pt(x=2.5, y=2.5), b=Pt(x=7.5, y=2.5)), + Edge(a=Pt(x=7.5, y=2.5), b=Pt(x=7.5, y=7.5)), + Edge(a=Pt(x=7.5, y=7.5), b=Pt(x=2.5, y=7.5)), + Edge(a=Pt(x=2.5, y=7.5), b=Pt(x=2.5, y=2.5)) + )), + Poly(name='strange', edges=( + Edge(a=Pt(x=0, y=0), b=Pt(x=2.5, y=2.5)), + Edge(a=Pt(x=2.5, y=2.5), b=Pt(x=0, y=10)), + Edge(a=Pt(x=0, y=10), b=Pt(x=2.5, y=7.5)), + Edge(a=Pt(x=2.5, y=7.5), b=Pt(x=7.5, y=7.5)), + Edge(a=Pt(x=7.5, y=7.5), b=Pt(x=10, y=10)), + Edge(a=Pt(x=10, y=10), b=Pt(x=10, y=0)), + Edge(a=Pt(x=10, y=0), b=Pt(x=2.5, y=2.5)) + )), + Poly(name='exagon', edges=( + Edge(a=Pt(x=3, y=0), b=Pt(x=7, y=0)), + Edge(a=Pt(x=7, y=0), b=Pt(x=10, y=5)), + Edge(a=Pt(x=10, y=5), b=Pt(x=7, y=10)), + Edge(a=Pt(x=7, y=10), b=Pt(x=3, y=10)), + Edge(a=Pt(x=3, y=10), b=Pt(x=0, y=5)), + Edge(a=Pt(x=0, y=5), b=Pt(x=3, y=0)) + )), + ] + testpoints = (Pt(x=5, y=5), Pt(x=5, y=8), + Pt(x=-10, y=5), Pt(x=0, y=5), + Pt(x=10, y=5), Pt(x=8, y=5), + Pt(x=10, y=10)) + + print "\n TESTING WHETHER POINTS ARE WITHIN POLYGONS" + for poly in polys: + polypp(poly) + print ' ', '\t'.join("%s: %s" % (p, ispointinside(p, poly)) + for p in testpoints[:3]) + print ' ', '\t'.join("%s: %s" % (p, ispointinside(p, poly)) + for p in testpoints[3:6]) + print ' ', '\t'.join("%s: %s" % (p, ispointinside(p, poly)) + for p in testpoints[6:]) diff --git a/Task/Ray-casting-algorithm/Python/ray-casting-algorithm-2.py b/Task/Ray-casting-algorithm/Python/ray-casting-algorithm-2.py new file mode 100644 index 0000000000..822ba670bf --- /dev/null +++ b/Task/Ray-casting-algorithm/Python/ray-casting-algorithm-2.py @@ -0,0 +1,27 @@ +def _convert_fortran_shapes(): + point = Pt + pts = (point(0,0), point(10,0), point(10,10), point(0,10), + point(2.5,2.5), point(7.5,2.5), point(7.5,7.5), point(2.5,7.5), + point(0,5), point(10,5), + point(3,0), point(7,0), point(7,10), point(3,10)) + p = (point(5,5), point(5, 8), point(-10, 5), point(0,5), point(10,5), + point(8,5), point(10,10) ) + + def create_polygon(pts,vertexindex): + return [tuple(Edge(pts[vertexindex[i]-1], pts[vertexindex[i+1]-1]) + for i in range(0, len(vertexindex), 2) )] + polys=[] + polys += create_polygon(pts, ( 1,2, 2,3, 3,4, 4,1 ) ) + polys += create_polygon(pts, ( 1,2, 2,3, 3,4, 4,1, 5,6, 6,7, 7,8, 8,5 ) ) + polys += create_polygon(pts, ( 1,5, 5,4, 4,8, 8,7, 7,3, 3,2, 2,5 ) ) + polys += create_polygon(pts, ( 11,12, 12,10, 10,13, 13,14, 14,9, 9,11 ) ) + + names = ( "square", "square_hole", "strange", "exagon" ) + polys = [Poly(name, edges) + for name, edges in zip(names, polys)] + print 'polys = [' + for p in polys: + print " Poly(name='%s', edges=(" % p.name + print ' ', ',\n '.join(str(e) for e in p.edges) + '\n )),' + print ' ]' + _convert_fortran_shapes() diff --git a/Task/Ray-casting-algorithm/R/ray-casting-algorithm-1.r b/Task/Ray-casting-algorithm/R/ray-casting-algorithm-1.r new file mode 100644 index 0000000000..054b923966 --- /dev/null +++ b/Task/Ray-casting-algorithm/R/ray-casting-algorithm-1.r @@ -0,0 +1,44 @@ +point_in_polygon <- function(polygon, p) { + count <- 0 + for(side in polygon) { + if ( ray_intersect_segment(p, side) ) { + count <- count + 1 + } + } + if ( count %% 2 == 1 ) + "INSIDE" + else + "OUTSIDE" +} + +ray_intersect_segment <- function(p, side) { + eps <- 0.0001 + a <- side$A + b <- side$B + if ( a$y > b$y ) { + a <- side$B + b <- side$A + } + if ( (p$y == a$y) || (p$y == b$y) ) { + p$y <- p$y + eps + } + if ( (p$y < a$y) || (p$y > b$y) ) + return(FALSE) + else if ( p$x > max(a$x, b$x) ) + return(FALSE) + else { + if ( p$x < min(a$x, b$x) ) + return(TRUE) + else { + if ( a$x != b$x ) + m_red <- (b$y - a$y) / (b$x - a$x) + else + m_red <- Inf + if ( a$x != p$x ) + m_blue <- (p$y - a$y) / (p$x - a$x) + else + m_blue <- Inf + return( m_blue >= m_red ) + } + } +} diff --git a/Task/Ray-casting-algorithm/R/ray-casting-algorithm-2.r b/Task/Ray-casting-algorithm/R/ray-casting-algorithm-2.r new file mode 100644 index 0000000000..ebfe76af31 --- /dev/null +++ b/Task/Ray-casting-algorithm/R/ray-casting-algorithm-2.r @@ -0,0 +1,13 @@ +######## utility functions ######### + +point <- function(x,y) list(x=x, y=y) + +# pts = list(p1, p2, ... )... coords +# segs = list(c(1,2), c(2,1) ...) indices +createPolygon <- function(pts, segs) { + pol <- list() + for(pseg in segs) { + pol <- c(pol, list(list(A=pts[[pseg[1]]], B=pts[[pseg[2]]]))) + } + pol +} diff --git a/Task/Ray-casting-algorithm/R/ray-casting-algorithm-3.r b/Task/Ray-casting-algorithm/R/ray-casting-algorithm-3.r new file mode 100644 index 0000000000..022fd6dfc2 --- /dev/null +++ b/Task/Ray-casting-algorithm/R/ray-casting-algorithm-3.r @@ -0,0 +1,26 @@ +#### testing #### + +pts <- list(point(0,0), point(10,0), point(10,10), point(0,10), + point(2.5,2.5), point(7.5,2.5), point(7.5,7.5), point(2.5,7.5), + point(0,5), point(10,5), + point(3,0), point(7,0), point(7,10), point(3,10)) + +polygons <- + list( + square = createPolygon(pts, list(c(1,2), c(2,3), c(3,4), c(4,1))), + squarehole = createPolygon(pts, list(c(1,2), c(2,3), c(3,4), c(4,1), c(5,6), c(6,7), c(7,8), c(8,5))), + exagon = createPolygon(pts, list(c(11,12), c(12,10), c(10,13), c(13,14), c(14,9), c(9,11))) + ) + +testpoints <- + list( + point(5,5), point(5, 8), point(-10, 5), point(0,5), point(10,5), + point(8,5), point(9.9,9.9) + ) + +for(p in testpoints) { + for(polysi in 1:length(polygons)) { + cat(sprintf("point (%lf, %lf) is %s polygon (%s)\n", + p$x, p$y, point_in_polygon(polygons[[polysi]], p), names(polygons[polysi]))) + } +} diff --git a/Task/Ray-casting-algorithm/REXX/ray-casting-algorithm.rexx b/Task/Ray-casting-algorithm/REXX/ray-casting-algorithm.rexx new file mode 100644 index 0000000000..9af49f411d --- /dev/null +++ b/Task/Ray-casting-algorithm/REXX/ray-casting-algorithm.rexx @@ -0,0 +1,49 @@ +/*REXX program to see if a horizontal ray from pt P intersects a polygon*/ +call points 5 5, 5 8, -10 5, 0 5, 10 5, 8 5, 10 10 +call polygon 0 0, 10 0, 10 10, 0 10 ; call test 'square' +call polygon 0 0, 10 0, 10 10, 0 10, 2.5 2.5, 7.5 2.5, 7.5 7.5, 2.5 7.5 ; call test 'square hole' +call polygon 0 0, 2.5 2.5, 0 10, 2.5 7.5, 7.5 7.5, 10 10, 10 0 ; call test 'irregular' +call polygon 3 0, 7 0, 10 5, 7 10, 3 10, 0 5 ; call test 'exagon' +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────IN_OUT subroutine────────────────────*/ +in_out: procedure expose point. poly. /*note: // is division remainder.*/ +parse arg p; #=0; do side=1 to poly.0 by 2; #=#+ray_intersect(p,side) + end /*side*/ +return #//2 /*odd=inside, return 1; else 0.*/ +/*──────────────────────────────────POINTS subroutine───────────────────*/ +points: n=0; v='POINT.'; do j=1 for arg(); n=n+1 + call value v||n'.X', word(arg(j),1) + call value v||n'.Y', word(arg(j),2) + end /*j*/ +call value v'0',n /*define number of points.*/ +return +/*──────────────────────────────────POLYGON subroutine──────────────────*/ +polygon: n=0; v='POLY.'; parse arg Fx Fy + + do j=1 for arg(); _=arg(j); n=n+1 + call value v||n'.X', word(_,1); call value v||n'.Y', word(_,2) + if n//2 then iterate + n=n+1 + call value v||n'.X', word(_,1); call value v||n'.Y', word(_,2) + end /*j*/ +n=n+1 +call value v||n".X", Fx; call value v||n".Y", Fy; call value v'0',n +return /*POLY.0 is # of segments/sides.*/ +/*──────────────────────────────────RAY_INTERSECT subroutine────────────*/ +ray_intersect: procedure expose point. poly.; parse arg ?,s; sp=s+1 +epsilon = '1e'||(digits()%2); infinity = '1e'||(digits()*2) +Px=point.?.x; Py=point.?.y +Ax=poly.s.x; Bx=poly.sp.x ; Ay=poly.s.y; By=poly.sp.y +if Ay>By then parse value Ax Ay Bx By with Bx By Ax Ay +if Py=Ay | Py=By then Py=Py+epsilon +if PyBy | Px>max(Ax,Bx) then return 0 +if Px=m_red +/*──────────────────────────────────TEST procedure──────────────────────*/ +test: say; do k=1 for point.0 /*traipse through each test point*/ + say ' ['arg(1)"] point:" right(point.k.x','point.k.y, 9), + " is " word('outside inside', in_out(k)+1) + end /*k*/ +return diff --git a/Task/Ray-casting-algorithm/Racket/ray-casting-algorithm-1.rkt b/Task/Ray-casting-algorithm/Racket/ray-casting-algorithm-1.rkt new file mode 100644 index 0000000000..f7c3e63219 --- /dev/null +++ b/Task/Ray-casting-algorithm/Racket/ray-casting-algorithm-1.rkt @@ -0,0 +1,75 @@ +#lang racket + +(module pip racket + (require racket/contract) + + (provide point) + (provide seg) + (provide (contract-out [point-in-polygon? (-> + point? + list? + boolean?)])) + + (struct point (x y) #:transparent) + (struct seg (Ax Ay Bx By)) + (define ε 0.000001) + (define (neq? x y) (not (eq? x y))) + + (define (ray-cross-seg? r s) + (let* ([Ax (seg-Ax s)] [Ay (seg-Ay s)] + [Bx (seg-Bx s)] [By (seg-By s)] + [Px (point-x r)] [Pyo (point-y r)] + [Py (+ Pyo (if (or (eq? Pyo Ay) + (eq? Pyo By)) + ε 0))]) + + (cond [(or (< Py Ay) (> Py By)) #f] + [(> Px (max Ax Bx)) #f] + [(< Px (min Ax Bx)) #t] + [else + (let ([red (if (neq? Ax Px) + (/ (- By Ay) (- Bx Ax)) + +inf.0)] + [blue (if (neq? Ax Px) + (/ (- Py Ax) (- Px Ax)) + +inf.0)]) + (if (>= blue red) #t #f))]))) + + (define (point-in-polygon? point polygon) + (odd? + (for/fold ([c 0]) ([seg polygon]) + (+ c (if (ray-cross-seg? point seg) 1 0)))))) + +(require 'pip) + +(define test-point-list + (list + (point 5.0 5.0) + (point 5.0 8.0) + (point -10.0 5.0) + (point 0.0 5.0) + (point 10.0 5.0) + (point 8.0 5.0) + (point 10.0 10.0))) + +(define square + (list (seg 0.0 0.0 10.0 0.0) + (seg 10.0 0.0 10.0 10.0) + (seg 10.0 10.0 0.0 10.0) + (seg 0.0 0.0 0.0 10.0))) + +(define exagon + (list (seg 3.0 0.0 7.0 0.0) + (seg 7.0 0.0 10.0 5.0) + (seg 10.0 5.0 7.0 10.0) + (seg 7.0 10.0 3.0 10.0) + (seg 0.0 5.0 3.0 10.0) + (seg 3.0 0.0 0.0 5.0))) + +(define (test-figure fig name) + (printf "\ntesting ~a: \n" name) + (for ([p test-point-list]) + (printf "testing ~v: ~a\n" p (point-in-polygon? p fig)))) + +(test-figure square "square") +(test-figure exagon "exagon") diff --git a/Task/Ray-casting-algorithm/Racket/ray-casting-algorithm-2.rkt b/Task/Ray-casting-algorithm/Racket/ray-casting-algorithm-2.rkt new file mode 100644 index 0000000000..3d7177c58c --- /dev/null +++ b/Task/Ray-casting-algorithm/Racket/ray-casting-algorithm-2.rkt @@ -0,0 +1,17 @@ +testing square: +testing (point 5.0 5.0): #t +testing (point 5.0 8.0): #t +testing (point -10.0 5.0): #f +testing (point 0.0 5.0): #f +testing (point 10.0 5.0): #t +testing (point 8.0 5.0): #t +testing (point 10.0 10.0): #f + +testing exagon: +testing (point 5.0 5.0): #t +testing (point 5.0 8.0): #t +testing (point -10.0 5.0): #f +testing (point 0.0 5.0): #f +testing (point 10.0 5.0): #t +testing (point 8.0 5.0): #t +testing (point 10.0 10.0): #f diff --git a/Task/Ray-casting-algorithm/Smalltalk/ray-casting-algorithm-1.st b/Task/Ray-casting-algorithm/Smalltalk/ray-casting-algorithm-1.st new file mode 100644 index 0000000000..8d43253b24 --- /dev/null +++ b/Task/Ray-casting-algorithm/Smalltalk/ray-casting-algorithm-1.st @@ -0,0 +1,77 @@ +Object subclass: Segment [ + |pts| + Segment class >> new: points [ |a| + a := super new. + ^ a init: points + ] + init: points [ pts := points copy. ^self ] + endPoints [ ^pts ] + "utility methods" + first [ ^ pts at: 1] + second [ ^ pts at: 2] + leftmostEndPoint [ + ^ (self first x > self second x) ifTrue: [ self second ] ifFalse: [ self first ] + ] + rightmostEndPoint [ + ^ (self first x > self second x) ifTrue: [ self first ] ifFalse: [ self second ] + ] + topmostEndPoint [ + ^ (self first y > self second y) ifTrue: [ self first ] ifFalse: [ self second ] + ] + bottommostEndPoint [ + ^ (self first y > self second y) ifTrue: [ self second ] ifFalse: [ self first ] + ] + + slope [ + (pts at: 1) x ~= (pts at: 2) x + ifTrue: [ ^ ((pts at: 1) y - (pts at: 2) y) / ((pts at: 1) x - (pts at: 2) x) ] + ifFalse: [ ^ FloatD infinity ] + ] + + doesIntersectRayFrom: point [ |p A B| + (point y = (pts at: 1) y) | (point y = (pts at: 2) y) + ifTrue: [ p := Point x: (point x) y: (point y) + 0.00001 ] + ifFalse: [ p := point copy ]. + A := self bottommostEndPoint. + B := self topmostEndPoint. + (p y < A y) | (p y > B y) | (p x > (self rightmostEndPoint x)) + ifTrue: [ ^false ] + ifFalse: [ (p x < (self leftmostEndPoint x)) + ifTrue: [ ^true ] + ifFalse: [ |s| + s := Segment new: { A . point }. + (s slope) >= (self slope) + ifTrue: [ ^ true ] + ] + ]. + ^false + ] +]. + +Object subclass: Polygon [ + |polysegs| + Polygon class >> new [ |a| a := super new. ^ a init. ] + Polygon class >> fromSegments: segments [ |a| + a := super new. + ^ a initWithSegments: segments + ] + Polygon class >> fromPoints: pts and: indexes [ |a| + a := self new. + indexes do: [ :i | + a addSegment: ( Segment new: { pts at: (i at: 1) . pts at: (i at: 2) } ) + ]. + ^ a + ] + initWithSegments: segments [ + polysegs := segments copy. ^self + ] + init [ polysegs := OrderedCollection new. ^ self ] + addSegment: segment [ polysegs add: segment ] + + pointInside: point [ |cnt| + cnt := 0. + polysegs do: [ :s | (s doesIntersectRayFrom: point) + ifTrue: [ cnt := cnt + 1 ] ]. + ^ ( cnt \\ 2 = 0 ) not + ] +]. diff --git a/Task/Ray-casting-algorithm/Smalltalk/ray-casting-algorithm-2.st b/Task/Ray-casting-algorithm/Smalltalk/ray-casting-algorithm-2.st new file mode 100644 index 0000000000..73ff6090e0 --- /dev/null +++ b/Task/Ray-casting-algorithm/Smalltalk/ray-casting-algorithm-2.st @@ -0,0 +1,42 @@ +|points names polys| + +points := { + 0@0 . 10@0 . 10@10 . 0@10 . + 2.5@2.5 . 7.5@2.5 . 7.5@7.5 . + 2.5@7.5 . 0@5 . 10@5 . + 3@0 . 7@0 . 7@10 . 3@10 + }. + +names := { 'square' . 'square hole' . 'strange' . 'exagon' }. + +polys := OrderedCollection new. + +polys add: + ( + Polygon fromPoints: points + and: { {1 . 2}. {2 . 3}. {3 . 4}. {4 . 1} } + ) ; + add: + ( + Polygon fromPoints: points + and: { {1 . 2}. {2 . 3}. {3 . 4}. {4 . 1}. {5 . 6}. {6 . 7}. {7 . 8}. {8 . 5} } + ) ; + add: + ( + Polygon fromPoints: points + and: { {1 . 5}. {5 . 4}. {4 . 8}. {8 . 7}. {7 . 3}. {3 . 2}. {2 . 5} } + ) ; + add: + ( + Polygon fromPoints: points + and: { {11 . 12}. {12 . 10}. {10 . 13}. {13 . 14}. {14 . 9}. {9 . 11} } + ). + +{ 5@5 . 5@8 . -10@5 . 0@5 . 10@5 . 8@5 . 10@10 } +do: [ :p | + 1 to: 4 do: [ :i | + ('point %1 inside %2? %3' % + { p . names at: i. (polys at: i) pointInside: p }) displayNl + ]. + ' ' displayNl. +] diff --git a/Task/Ray-casting-algorithm/Tcl/ray-casting-algorithm.tcl b/Task/Ray-casting-algorithm/Tcl/ray-casting-algorithm.tcl new file mode 100644 index 0000000000..e7aefb8519 --- /dev/null +++ b/Task/Ray-casting-algorithm/Tcl/ray-casting-algorithm.tcl @@ -0,0 +1,58 @@ +package require Tcl 8.5 + +proc point_in_polygon {point polygon} { + set count 0 + foreach side [sides $polygon] { + if {[ray_intersects_line $point $side]} { + incr count + } + } + expr {$count % 2} ;#-- 1 = odd = true, 0 = even = false +} +proc sides polygon { + lassign $polygon x0 y0 + foreach {x y} [lrange [lappend polygon $x0 $y0] 2 end] { + lappend res [list $x0 $y0 $x $y] + set x0 $x + set y0 $y + } + return $res +} +proc ray_intersects_line {point line} { + lassign $point Px Py + lassign $line Ax Ay Bx By + # Reverse line direction if necessary + if {$By < $Ay} { + lassign $line Bx By Ax Ay + } + # Add epsilon to + if {$Py == $Ay || $Py == $By} { + set Py [expr {$Py + abs($Py)/1e6}] + } + # Bounding box checks + if {$Py < $Ay || $Py > $By || $Px > max($Ax,$Bx)} { + return 0 + } elseif {$Px < min($Ax,$Bx)} { + return 1 + } + # Compare dot products to compare (cosines of) angles + set mRed [expr {$Ax != $Bx ? ($By-$Ay)/($Bx-$Ax) : Inf}] + set mBlu [expr {$Ax != $Px ? ($Py-$Ay)/($Px-$Ax) : Inf}] + return [expr {$mBlu >= $mRed}] +} + +foreach {point poly} { + {0 0} {-1 -1 -1 1 1 1 1 -1} + {2 2} {-1 -1 -1 1 1 1 1 -1} + {0 0} {-2 -2 -2 2 2 2 2 -2 2 -1 1 1 -1 1 -1 -1 1 -1 2 -1} + {1.5 1.5} {-2 -2 -2 2 2 2 2 -2 2 -1 1 1 -1 1 -1 -1 1 -1 2 -1} + {5 5} {0 0 2.5 2.5 0 10 2.5 7.5 7.5 7.5 10 10 10 0 7.5 0.1} + {5 8} {0 0 2.5 2.5 0 10 2.5 7.5 7.5 7.5 10 10 10 0 7.5 0.1} + {2 2} {0 0 2.5 2.5 0 10 2.5 7.5 7.5 7.5 10 10 10 0 7.5 0.1} + {0 0} {0 0 2.5 2.5 0 10 2.5 7.5 7.5 7.5 10 10 10 0 7.5 0.1} + {10 10} {0 0 2.5 2.5 0 10 2.5 7.5 7.5 7.5 10 10 10 0 7.5 0.1} + {2.5 2.5} {0 0 2.5 2.5 0 10 2.5 7.5 7.5 7.5 10 10 10 0 7.5 0.1} + {-5 5} {3 0 7 0 10 5 7 10 3 10 0 5} +} { + puts "$point in $poly = [point_in_polygon $point $poly]" +} diff --git a/Task/Ray-casting-algorithm/Ursala/ray-casting-algorithm-1.ursala b/Task/Ray-casting-algorithm/Ursala/ray-casting-algorithm-1.ursala new file mode 100644 index 0000000000..7c9401d481 --- /dev/null +++ b/Task/Ray-casting-algorithm/Ursala/ray-casting-algorithm-1.ursala @@ -0,0 +1,7 @@ +#import flo + +in = + +@lrzyCipPX ~|afatPRZaq ~&EZ+fleq~~lrPrbr2G&& ~&B+fleq~~lrPrbl2G!| -& + ~&Y+ ~~lrPrbl2G fleq, + ^E(fleq@lrrPX,@rl fleq\0.)^/~&lr ^(~&r,times)^/minus@llPrll2X vid+ minus~~rbbI&- diff --git a/Task/Ray-casting-algorithm/Ursala/ray-casting-algorithm-2.ursala b/Task/Ray-casting-algorithm/Ursala/ray-casting-algorithm-2.ursala new file mode 100644 index 0000000000..37be8d5130 --- /dev/null +++ b/Task/Ray-casting-algorithm/Ursala/ray-casting-algorithm-2.ursala @@ -0,0 +1,7 @@ +#cast %bL + +examples = + +in* < + ((0.5,0.6),<(0.,0.),(1.,2.),(1.,0.)>), + ((0.5,0.6),<(0.,0.),(1.,1.),(1.,0.)>)> diff --git a/Task/Read-a-configuration-file/0DESCRIPTION b/Task/Read-a-configuration-file/0DESCRIPTION new file mode 100644 index 0000000000..f629bf5f2d --- /dev/null +++ b/Task/Read-a-configuration-file/0DESCRIPTION @@ -0,0 +1,42 @@ +The task is to read a configuration file in standard configuration file, and set variables accordingly. For this task, we have a configuration file as follows: + + # This is a configuration file in standard configuration file format + # + # Lines begininning with a hash or a semicolon are ignored by the application + # program. Blank lines are also ignored by the application program. + + # This is the fullname parameter + FULLNAME Foo Barber + + # This is a favourite fruit + FAVOURITEFRUIT banana + + # This is a boolean that should be set + NEEDSPEELING + + # This boolean is commented out + ; SEEDSREMOVED + + # Configuration option names are not case sensitive, but configuration parameter + # data is case sensitive and may be preserved by the application program. + + # An optional equals sign can be used to separate configuration parameter data + # from the option name. This is dropped by the parser. + + # A configuration option may take multiple parameters separated by commas. + # Leading and trailing whitespace around parameter names and parameter data fields + # are ignored by the application program. + + OTHERFAMILY Rhu Barber, Harry Barber + +For the task we need to set four variables according to the configuration entries as follows: + +*fullname = Foo Barber +*favouritefruit = banana +*needspeeling = true +*seedsremoved = false + +We also have an option that contains multiple parameters. These may be stored in an array. + +* otherfamily(1) = Rhu Barber +* otherfamily(2) = Harry Barber diff --git a/Task/Read-a-configuration-file/1META.yaml b/Task/Read-a-configuration-file/1META.yaml new file mode 100644 index 0000000000..53d5156105 --- /dev/null +++ b/Task/Read-a-configuration-file/1META.yaml @@ -0,0 +1,2 @@ +--- +note: File handling diff --git a/Task/Read-a-configuration-file/Ada/read-a-configuration-file-1.ada b/Task/Read-a-configuration-file/Ada/read-a-configuration-file-1.ada new file mode 100644 index 0000000000..06232aadaa --- /dev/null +++ b/Task/Read-a-configuration-file/Ada/read-a-configuration-file-1.ada @@ -0,0 +1,39 @@ +with Ada.Strings.Unbounded; +with Config_File_Parser; +pragma Elaborate_All (Config_File_Parser); + +package Config is + + function TUS (S : String) return Ada.Strings.Unbounded.Unbounded_String + renames Ada.Strings.Unbounded.To_Unbounded_String; + -- Convenience rename. TUS is much shorter than To_Unbounded_String. + + type Keys is ( + FULLNAME, + FAVOURITEFRUIT, + NEEDSPEELING, + SEEDSREMOVED, + OTHERFAMILY); + -- These are the valid configuration keys. + + type Defaults_Array is + array (Keys) of Ada.Strings.Unbounded.Unbounded_String; + -- The array type we'll use to hold our default configuration settings. + + Defaults_Conf : Defaults_Array := + (FULLNAME => TUS ("John Doe"), + FAVOURITEFRUIT => TUS ("blackberry"), + NEEDSPEELING => TUS ("False"), + SEEDSREMOVED => TUS ("False"), + OTHERFAMILY => TUS ("Daniel Defoe, Ada Byron")); + -- Default values for the Program object. These can be overwritten by + -- the contents of the rosetta.cfg file(see below). + + package Rosetta_Config is new Config_File_Parser ( + Keys => Keys, + Defaults_Array => Defaults_Array, + Defaults => Defaults_Conf, + Config_File => "rosetta.cfg"); + -- Instantiate the Config configuration object. + +end Config; diff --git a/Task/Read-a-configuration-file/Ada/read-a-configuration-file-2.ada b/Task/Read-a-configuration-file/Ada/read-a-configuration-file-2.ada new file mode 100644 index 0000000000..0bc3b4cb51 --- /dev/null +++ b/Task/Read-a-configuration-file/Ada/read-a-configuration-file-2.ada @@ -0,0 +1,24 @@ +with Ada.Text_IO; +with Config; use Config; + +procedure Read_Config is + use Ada.Text_IO; + use Rosetta_Config; + +begin + New_Line; + Put_Line ("Reading Configuration File."); + Put_Line ("Fullname := " & Get (Key => FULLNAME)); + Put_Line ("Favorite Fruit := " & Get (Key => FAVOURITEFRUIT)); + Put_Line ("Other Family := " & Get (Key => OTHERFAMILY)); + if Has_Value (Key => NEEDSPEELING) then + Put_Line ("NEEDSPEELLING := " & Get (Key => NEEDSPEELING)); + else + Put_Line ("NEEDSPEELLING := True"); + end if; + if Has_Value (Key => SEEDSREMOVED) then + Put_Line ("SEEDSREMOVED := " & Get (Key => SEEDSREMOVED)); + else + Put_Line ("SEEDSREMOVED := True"); + end if; +end Read_Config; diff --git a/Task/Read-a-configuration-file/AutoHotkey/read-a-configuration-file.ahk b/Task/Read-a-configuration-file/AutoHotkey/read-a-configuration-file.ahk new file mode 100644 index 0000000000..8fe80c0b4a --- /dev/null +++ b/Task/Read-a-configuration-file/AutoHotkey/read-a-configuration-file.ahk @@ -0,0 +1,37 @@ +; Author: AlephX, Aug 18 2011 +data = %A_scriptdir%\rosettaconfig.txt +comma := "," + +Loop, Read, %data% + { + if NOT (instr(A_LoopReadLine, "#") == 1 OR A_LoopReadLine == "") + + { + if instr(A_LoopReadLine, ";") == 1 + { + parameter := RegExReplace(Substr(A_LoopReadLine,2), "^[ \s]+|[ \s]+$", "") + %parameter% = "1" + } + else + { + parameter := RegExReplace(A_LoopReadLine, "^[ \s]+|[ \s]+$", "") + + if instr(parameter, A_Space) + { + value := substr(parameter, instr(parameter, A_Space)+1,999) + parameter := substr(parameter, 1, instr(parameter, A_Space)-1) + + if (instr(value, ",") <> 0) + { + Loop, Parse, value, %comma% ,%A_Space% + %parameter%%A_Index% := A_Loopfield + } + else + %parameter% = %value% + } + else + %parameter% = "0" + } + } + } +msgbox, FULLNAME %fullname%`nFAVOURITEFRUIT %FAVOURITEFRUIT%`nNEEDSPEELING %NEEDSPEELING%`nSEEDSREMOVED %SEEDSREMOVED%`nOTHERFAMILY %OTHERFAMILY1% + %OTHERFAMILY2% diff --git a/Task/Read-a-configuration-file/BBC-BASIC/read-a-configuration-file.bbc b/Task/Read-a-configuration-file/BBC-BASIC/read-a-configuration-file.bbc new file mode 100644 index 0000000000..feaf25c35d --- /dev/null +++ b/Task/Read-a-configuration-file/BBC-BASIC/read-a-configuration-file.bbc @@ -0,0 +1,61 @@ + BOOL = 1 + NAME = 2 + ARRAY = 3 + + optfile$ = "options.cfg" + + fullname$ = FNoption(optfile$, "FULLNAME", NAME) + favouritefruit$ = FNoption(optfile$, "FAVOURITEFRUIT", NAME) + needspeeling% = FNoption(optfile$, "NEEDSPEELING", BOOL) + seedsremoved% = FNoption(optfile$, "SEEDSREMOVED", BOOL) + !^otherfamily$() = FNoption(optfile$, "OTHERFAMILY", ARRAY) + + PRINT "fullname = " fullname$ + PRINT "favouritefruit = " favouritefruit$ + PRINT "needspeeling = "; : IF needspeeling% PRINT "true" ELSE PRINT "false" + PRINT "seedsremoved = "; : IF seedsremoved% PRINT "true" ELSE PRINT "false" + PRINT "otherfamily(1) = " otherfamily$(1) + PRINT "otherfamily(2) = " otherfamily$(2) + END + + DEF FNoption(file$, key$, type%) + LOCAL file%, opt$, comma%, bool%, name$, size%, !^array$() + file% = OPENIN(file$) + IF file% = 0 THEN = 0 + WHILE NOT EOF#file% + opt$ = GET$#file% + WHILE RIGHT$(opt$) = " " opt$ = LEFT$(opt$) : ENDWHILE + IF opt$ = key$ OR LEFT$(opt$, LEN(key$)+1) = key$ + " " THEN + opt$ = MID$(opt$, LEN(key$) + 1) + WHILE LEFT$(opt$,1) = " " opt$ = MID$(opt$,2) : ENDWHILE + CASE type% OF + WHEN BOOL: bool% = TRUE : EXIT WHILE + WHEN NAME: name$ = opt$ : EXIT WHILE + WHEN ARRAY: + REPEAT + comma% = INSTR(opt$, ",", comma%+1) + IF comma% size% += 1 + UNTIL comma% = 0 + DIM array$(size% + 1) + size% = 0 + REPEAT + comma% = INSTR(opt$, ",") + IF comma% THEN + size% += 1 + array$(size%) = LEFT$(opt$, comma%-1) + opt$ = MID$(opt$, comma%+1) + WHILE LEFT$(opt$,1) = " " opt$ = MID$(opt$,2) : ENDWHILE + ENDIF + UNTIL comma% = 0 + array$(size% + 1) = opt$ + EXIT WHILE + ENDCASE + ENDIF + ENDWHILE + CLOSE #file% + CASE type% OF + WHEN BOOL: = bool% + WHEN NAME: = name$ + WHEN ARRAY: = !^array$() + ENDCASE + = 0 diff --git a/Task/Read-a-configuration-file/C++/read-a-configuration-file-1.cpp b/Task/Read-a-configuration-file/C++/read-a-configuration-file-1.cpp new file mode 100644 index 0000000000..bb5f89d8db --- /dev/null +++ b/Task/Read-a-configuration-file/C++/read-a-configuration-file-1.cpp @@ -0,0 +1,105 @@ +#include "stdafx.h" +#include +#include +#include +#include +#include +#include +using namespace std; +using namespace boost; + +typedef boost::tokenizer > Tokenizer; +static const char_separator sep(" ","#;,"); + +//Assume that the config file represent a struct containing all the parameters to load +struct configs{ + string fullname; + string favoritefruit; + bool needspelling; + bool seedsremoved; + vector otherfamily; +} conf; + +void parseLine(const string &line, configs &conf) +{ + if (line[0] == '#' || line.empty()) + return; + Tokenizer tokenizer(line, sep); + vector tokens; + for (Tokenizer::iterator iter = tokenizer.begin(); iter != tokenizer.end(); iter++) + tokens.push_back(*iter); + if (tokens[0] == ";"){ + algorithm::to_lower(tokens[1]); + if (tokens[1] == "needspeeling") + conf.needspelling = false; + if (tokens[1] == "seedsremoved") + conf.seedsremoved = false; + } + algorithm::to_lower(tokens[0]); + if (tokens[0] == "needspeeling") + conf.needspelling = true; + if (tokens[0] == "seedsremoved") + conf.seedsremoved = true; + if (tokens[0] == "fullname"){ + for (unsigned int i=1; i" << endl; + return -1; + } + ifstream file (argv[1]); + + if (file.is_open()) + while(file.good()) + { + char line[255]; + file.getline(line, 255); + string linestring(line); + parseLine(linestring, conf); + } + else + { + cout << "Unable to open the file" << endl; + return -2; + } + + cout << "Fullname= " << conf.fullname << endl; + cout << "Favorite Fruit= " << conf.favoritefruit << endl; + cout << "Need Spelling= " << (conf.needspelling?"True":"False") << endl; + cout << "Seed Removed= " << (conf.seedsremoved?"True":"False") << endl; + string otherFamily; + for (unsigned int i = 0; i < conf.otherfamily.size(); i++) + otherFamily += conf.otherfamily[i] + ", "; + otherFamily.erase(otherFamily.size()-2, 2); + cout << "Other Family= " << otherFamily << endl; + + return 0; +} diff --git a/Task/Read-a-configuration-file/C++/read-a-configuration-file-2.cpp b/Task/Read-a-configuration-file/C++/read-a-configuration-file-2.cpp new file mode 100644 index 0000000000..aa1ef631a3 --- /dev/null +++ b/Task/Read-a-configuration-file/C++/read-a-configuration-file-2.cpp @@ -0,0 +1,75 @@ +#include +#include +#include +#include +#include +#include +#include + +struct confi { + std::string fullname; + std::string favouritefruit; + bool needspeeling; + bool seedsremoved; + std::vector otherfamily; +}; + +void read_config(std::ifstream& in, confi& out) { + in.open("Config.txt"); + std::string str; + out.needspeeling = false; + out.seedsremoved = false; + while(!in.eof()) { + while(getline(in,str)) { + std::string::size_type begin = str.find_first_not_of(" \f\t\v"); + //Skips blank lines + if(begin == std::string::npos) + continue; + //Skips # + if(std::string("#").find(str[begin]) != std::string::npos) + continue; + std::string firstWord; + try { + firstWord = str.substr(0,str.find(" ")); + } + catch(std::exception& e) { + firstWord = str.erase(str.find_first_of(" "),str.find_first_not_of(" ")); + } + std::transform(firstWord.begin(),firstWord.end(),firstWord.begin(), ::toupper); + if(firstWord == "FULLNAME") + out.fullname = str.substr(str.find(" ")+1,str.length()); + if(firstWord == "FAVOURITEFRUIT") + out.favouritefruit = str.substr(str.find(" ")+1,str.length()); + if(firstWord == "NEEDSPEELING") + out.needspeeling = true; + if(firstWord == "SEEDSREMOVED") + out.seedsremoved = true; + if(firstWord == "OTHERFAMILY") { + size_t found = str.find(","); + if(found != std::string::npos) { + out.otherfamily.push_back(str.substr(str.find_first_of(" ")+1,found-str.find_first_of(" ")-1)); + out.otherfamily.push_back(str.substr(found+2,str.length())); + } + } + + } + } + std::cout << "Full Name: " << out.fullname << std::endl; + std::cout << "Favourite Fruit: " << out.favouritefruit << std::endl; + std::cout << "Needs peeling?: "; + if(out.needspeeling == true) + std::cout << "True" << std::endl; + else + std::cout << "False" << std::endl; + std::cout << "Seeds removed?: "; + if(out.seedsremoved == true) + std::cout << "True" << std::endl; + else + std::cout << "False" << std::endl; + std::cout << "Other family members: " << out.otherfamily[0] << ", " << out.otherfamily[1] << std::endl; +} +int main() { + std::ifstream inp; + confi outp; + read_config(inp,outp); +} diff --git a/Task/Read-a-configuration-file/D/read-a-configuration-file.d b/Task/Read-a-configuration-file/D/read-a-configuration-file.d new file mode 100644 index 0000000000..aabf3d3803 --- /dev/null +++ b/Task/Read-a-configuration-file/D/read-a-configuration-file.d @@ -0,0 +1,38 @@ +import std.stdio, std.string, std.conv, std.regex, std.getopt; + +template VarName(alias var) { + enum VarName = var.stringof.toUpper(); +} + +void setOpt(alias Var)(in string line) { + auto m = match(line, regex(`^` ~ VarName!Var ~ `(\s+(.*))?`)); + if (!m.empty) { + static if (is(typeof(Var) == string)) + Var = m.captures.length > 2 ? m.captures[2] : ""; + static if (is(typeof(Var) == bool)) + Var = true; + static if (is(typeof(Var) == int)) + Var = m.captures.length > 2 ? to!int(m.captures[2]) : 0; + } +} + +void main(string[] args) { + string fullName, favouriteFruit, otherFamily; + bool needsPeeling, seedsRemoved; // Default false. + auto f = File("readcfg.txt", "r"); + + foreach (line; f.byLine()) { + auto opt = line.strip().idup; + setOpt!fullName(opt); + setOpt!favouriteFruit(opt); + setOpt!needsPeeling(opt); + setOpt!seedsRemoved(opt); + setOpt!otherFamily(opt); + } + + writefln("%14s = %s", VarName!fullName, fullName); + writefln("%14s = %s", VarName!favouriteFruit, favouriteFruit); + writefln("%14s = %s", VarName!needsPeeling, needsPeeling); + writefln("%14s = %s", VarName!seedsRemoved, seedsRemoved); + writefln("%14s = %s", VarName!otherFamily, otherFamily); +} diff --git a/Task/Read-a-configuration-file/Fantom/read-a-configuration-file.fantom b/Task/Read-a-configuration-file/Fantom/read-a-configuration-file.fantom new file mode 100644 index 0000000000..7c7606d205 --- /dev/null +++ b/Task/Read-a-configuration-file/Fantom/read-a-configuration-file.fantom @@ -0,0 +1,60 @@ +class Main +{ + // remove the given key and an optional '=' from start of line + Str removeKey (Str key, Str line) + { + remainder := line[key.size..-1].trim + if (remainder.startsWith("=")) + { + remainder = remainder.replace("=", "").trim + } + return remainder + } + + Void main () + { + // define the variables which need configuring + fullname := "" + favouritefruit := "" + needspeeling := false + seedsremoved := false + Str[] otherfamily := [,] + + // loop through the file, setting variables as needed + File(`config.dat`).eachLine |Str line| + { + line = line.trim + if (line.isEmpty || line.startsWith("#") || line.startsWith(";")) + { + // do nothing for empty and comment lines + } + else if (line.upper.startsWith("FULLNAME")) + { + fullname = removeKey("FULLNAME", line) + } + else if (line.upper.startsWith("FAVOURITEFRUIT")) + { + favouritefruit = removeKey("FAVOURITEFRUIT", line) + } + else if (line.upper.startsWith("NEEDSPEELING")) + { + needspeeling = true + } + else if (line.upper.startsWith("SEEDSREMOVED")) + { + seedsremoved = true + } + else if (line.upper.startsWith("OTHERFAMILY")) + { + otherfamily = removeKey("OTHERFAMILY", line).split(',') + } + } + + // report results + echo ("Full name is $fullname") + echo ("Favourite fruit is $favouritefruit") + echo ("Needs peeling is $needspeeling") + echo ("Seeds removed is $seedsremoved") + echo ("Other family is " + otherfamily.join(", ")) + } +} diff --git a/Task/Read-a-configuration-file/Go/read-a-configuration-file-1.go b/Task/Read-a-configuration-file/Go/read-a-configuration-file-1.go new file mode 100644 index 0000000000..1e525e0726 --- /dev/null +++ b/Task/Read-a-configuration-file/Go/read-a-configuration-file-1.go @@ -0,0 +1,160 @@ +package config + +import ( + "errors" + "io" + "fmt" + "bytes" + "strings" + "io/ioutil" +) + +var ( + ENONE = errors.New("Requested value does not exist") + EBADTYPE = errors.New("Requested type and actual type do not match") + EBADVAL = errors.New("Value and type do not match") +) + +type varError struct { + err error + n string + t VarType +} + +func (err *varError) Error() string { + return fmt.Sprintf("%v: (%q, %v)", err.err, err.n, err.t) +} + +type VarType int + +const ( + Bool VarType = 1 + iota + Array + String +) + +func (t VarType) String() string { + switch t { + case Bool: + return "Bool" + case Array: + return "Array" + case String: + return "String" + } + + panic("Unknown VarType") +} + +type confvar struct { + Type VarType + Val interface{} +} + +type Config struct { + m map[string]confvar +} + +func Parse(r io.Reader) (c *Config, err error) { + c = new(Config) + c.m = make(map[string]confvar) + + buf, err := ioutil.ReadAll(r) + if err != nil { + return + } + + lines := bytes.Split(buf, []byte{'\n'}) + + for _, line := range lines { + line = bytes.TrimSpace(line) + if len(line) == 0 { + continue + } + switch line[0] { + case '#', ';': + continue + } + + parts := bytes.SplitN(line, []byte{' '}, 2) + nam := string(bytes.ToLower(parts[0])) + + if len(parts) == 1 { + c.m[nam] = confvar{Bool, true} + continue + } + + if strings.Contains(string(parts[1]), ",") { + tmpB := bytes.Split(parts[1], []byte{','}) + for i := range tmpB { + tmpB[i] = bytes.TrimSpace(tmpB[i]) + } + tmpS := make([]string, 0, len(tmpB)) + for i := range tmpB { + tmpS = append(tmpS, string(tmpB[i])) + } + + c.m[nam] = confvar{Array, tmpS} + continue + } + + c.m[nam] = confvar{String, string(bytes.TrimSpace(parts[1]))} + } + + return +} + +func (c *Config) Bool(name string) (bool, error) { + name = strings.ToLower(name) + + if _, ok := c.m[name]; !ok { + return false, nil + } + + if c.m[name].Type != Bool { + return false, &varError{EBADTYPE, name, Bool} + } + + v, ok := c.m[name].Val.(bool) + if !ok { + return false, &varError{EBADVAL, name, Bool} + } + return v, nil +} + +func (c *Config) Array(name string) ([]string, error) { + name = strings.ToLower(name) + + if _, ok := c.m[name]; !ok { + return nil, &varError{ENONE, name, Array} + } + + if c.m[name].Type != Array { + return nil, &varError{EBADTYPE, name, Array} + } + + v, ok := c.m[name].Val.([]string) + if !ok { + return nil, &varError{EBADVAL, name, Array} + } + return v, nil +} + +func (c *Config) String(name string) (string, error) { + name = strings.ToLower(name) + + if _, ok := c.m[name]; !ok { + return "", &varError{ENONE, name, String} + } + + if c.m[name].Type != String { + return "", &varError{EBADTYPE, name, String} + } + + v, ok := c.m[name].Val.(string) + if !ok { + return "", &varError{EBADVAL, name, String} + } + + return v, nil +} diff --git a/Task/Read-a-configuration-file/Go/read-a-configuration-file-2.go b/Task/Read-a-configuration-file/Go/read-a-configuration-file-2.go new file mode 100644 index 0000000000..f6490e82d5 --- /dev/null +++ b/Task/Read-a-configuration-file/Go/read-a-configuration-file-2.go @@ -0,0 +1,63 @@ +package main + +import ( + "os" + "fmt" + "config" +) + +func main() { + if len(os.Args) != 2 { + fmt.Printf("Usage: %v \n", os.Args[0]) + os.Exit(1) + } + + file, err := os.Open(os.Args[1]) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + defer file.Close() + + conf, err := config.Parse(file) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + fullname, err := conf.String("fullname") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + favouritefruit, err := conf.String("favouritefruit") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + needspeeling, err := conf.Bool("needspeeling") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + seedsremoved, err := conf.Bool("seedsremoved") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + otherfamily, err := conf.Array("otherfamily") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + fmt.Printf("FULLNAME: %q\n", fullname) + fmt.Printf("FAVOURITEFRUIT: %q\n", favouritefruit) + fmt.Printf("NEEDSPEELING: %q\n", needspeeling) + fmt.Printf("SEEDSREMOVED: %q\n", seedsremoved) + fmt.Printf("OTHERFAMILY: %q\n", otherfamily) +} diff --git a/Task/Read-a-configuration-file/Haskell/read-a-configuration-file-1.hs b/Task/Read-a-configuration-file/Haskell/read-a-configuration-file-1.hs new file mode 100644 index 0000000000..f6fca57fca --- /dev/null +++ b/Task/Read-a-configuration-file/Haskell/read-a-configuration-file-1.hs @@ -0,0 +1,33 @@ +import Data.Char +import Data.List +import Data.List.Split + +main :: IO () +main = readFile "config" >>= (print . parseConfig) + +parseConfig :: String -> Config +parseConfig = foldr addConfigValue defaultConfig . clean . lines + where clean = filter (not . flip any ["#", ";", "", " "] . (==) . take 1) + +addConfigValue :: String -> Config -> Config +addConfigValue raw config = case key of + "fullname" -> config {fullName = values} + "favouritefruit" -> config {favoriteFruit = values} + "needspeeling" -> config {needsPeeling = True} + "seedsremoved" -> config {seedsRemoved = True} + "otherfamily" -> config {otherFamily = splitOn "," values} + _ -> config + where (k, vs) = span (/= ' ') raw + key = map toLower k + values = tail vs + +data Config = Config + { fullName :: String + , favoriteFruit :: String + , needsPeeling :: Bool + , seedsRemoved :: Bool + , otherFamily :: [String] + } deriving (Show) + +defaultConfig :: Config +defaultConfig = Config "" "" False False [] diff --git a/Task/Read-a-configuration-file/Haskell/read-a-configuration-file-2.hs b/Task/Read-a-configuration-file/Haskell/read-a-configuration-file-2.hs new file mode 100644 index 0000000000..b163ffcf55 --- /dev/null +++ b/Task/Read-a-configuration-file/Haskell/read-a-configuration-file-2.hs @@ -0,0 +1,8 @@ +import Data.ConfigFile +import Data.Either.Utils + +getSetting cp x = forceEither $ get cp "Default" x + +cp <- return . forceEither =<< readfile emptyCP "name_of_configuration_file" +let username = getSetting cp "username" + password = getSetting cp "password" diff --git a/Task/Read-a-configuration-file/J/read-a-configuration-file-1.j b/Task/Read-a-configuration-file/J/read-a-configuration-file-1.j new file mode 100644 index 0000000000..1016f1a761 --- /dev/null +++ b/Task/Read-a-configuration-file/J/read-a-configuration-file-1.j @@ -0,0 +1,22 @@ +require'regex' +set=:4 :'(x)=:y' + +cfgString=:4 :0 + y set '' + (1;&,~'(?i:',y,')\s*(.*)') y&set rxapply x +) + +cfgBoolean=:4 :0 + y set 0 + (1;&,~'(?i:',y,')\s*(.*)') y&set rxapply x + if.-.0-:y do.y set 1 end. +) + +taskCfg=:3 :0 + cfg=: ('[#;].*';'') rxrplc 1!:1 "" + print counter; ". "; trim$(word$(otherFamily$, counter, ",")) + counter = counter + 1 +wend +end + +'parses the configuration file, stores the uppercase keys in array confKeys$ and corresponding values in confValues$ +'returns the number of key-value pairs found +function ParseConfiguration(fileName$) + count = 0 + open fileName$ for input as #f + while not(eof(#f)) + line input #f, s$ + if not(Left$(s$,1) = "#" or Left$( s$,1) = ";" or trim$(s$) = "") then 'ignore empty and comment lines + s$ = trim$(s$) + key$ = ParseKey$(s$) + value$ = trim$(Mid$(s$,len(key$) + 1)) + if Left$( value$,1) = "=" then value$ = trim$(Mid$(value$,2)) 'optional = + count = count + 1 + confKeys$(count) = upper$(key$) + confValues$(count) = value$ + end if + wend + close #f + ParseConfiguration = count +end function + +function ParseKey$(s$) + 'key is the first word in s$, delimited by whitespace or = + s$ = word$(s$, 1) + ParseKey$ = trim$(word$(s$, 1, "=")) +end function + + +function GetOption$( key$, optionCount) + index = Find.confKeys( 1, optionCount, key$) + if index > 0 then GetOption$ =(confValues$(index)) +end function + + +function HasOption(key$, optionCount) + HasOption = Find.confKeys( 1, optionCount, key$) > 0 +end function + +function Find.confKeys( Start, Finish, value$) + Find.confKeys = -1 + for i = Start to Finish + if confKeys$(i) = value$ then Find.confKeys = i : exit for + next i +end function diff --git a/Task/Read-a-configuration-file/Lua/read-a-configuration-file.lua b/Task/Read-a-configuration-file/Lua/read-a-configuration-file.lua new file mode 100644 index 0000000000..1d3302b7c0 --- /dev/null +++ b/Task/Read-a-configuration-file/Lua/read-a-configuration-file.lua @@ -0,0 +1,40 @@ +conf = {} + +fp = io.open( "conf.txt", "r" ) + +for line in fp:lines() do + line = line:match( "%s*(.+)" ) + if line and line:sub( 1, 1 ) ~= "#" and line:sub( 1, 1 ) ~= ";" then + option = line:match( "%S+" ):lower() + value = line:match( "%S*%s*(.*)" ) + + if not value then + conf[option] = true + else + if not value:find( "," ) then + conf[option] = value + else + value = value .. "," + conf[option] = {} + for entry in value:gmatch( "%s*(.-)," ) do + conf[option][#conf[option]+1] = entry + end + end + end + + end +end + +fp:close() + + +print( "fullname = ", conf["fullname"] ) +print( "favouritefruit = ", conf["favouritefruit"] ) +if conf["needspeeling"] then print( "needspeeling = true" ) else print( "needspeeling = false" ) end +if conf["seedsremoved"] then print( "seedsremoved = true" ) else print( "seedsremoved = false" ) end +if conf["otherfamily"] then + print "otherfamily:" + for _, entry in pairs( conf["otherfamily"] ) do + print( "", entry ) + end +end diff --git a/Task/Read-a-configuration-file/MATLAB/read-a-configuration-file.m b/Task/Read-a-configuration-file/MATLAB/read-a-configuration-file.m new file mode 100644 index 0000000000..ff781a6d50 --- /dev/null +++ b/Task/Read-a-configuration-file/MATLAB/read-a-configuration-file.m @@ -0,0 +1,38 @@ +function R = readconf(configfile) +% READCONF reads configuration file. +% +% The value of boolean parameters can be tested with +% exist(parameter,'var') + +if nargin<1, + configfile = 'q.conf'; +end; + +fid = fopen(configfile); +if fid<0, error('cannot open file %s\n',a); end; + +while ~feof(fid) + line = strtrim(fgetl(fid)); + if isempty(line) || all(isspace(line)) || strncmp(line,'#',1) || strncmp(line,';',1), + ; % no operation + else + [var,tok] = strtok(line,' \t='); + var = upper(var); + if any(tok==','), + k = 1; + while (1) + [val, tok]=strtok(tok,','); + R.(var){k} = strtrim(val); % return value of function + eval(sprintf('%s{%i}=''%s'';',var,k,strtrim(val))); % stores variable in local workspace + if isempty(tok), break; end; + k=k+1; + end; + else + tok = strtrim(tok); + R.(var) = tok; % return value of function + eval(sprintf('%s=''%s''; ',var,tok)); % stores variable in local workspace + end; + end; +end; +fclose(fid); +whos, % shows the parameter in the local workspace diff --git a/Task/Read-a-configuration-file/OCaml/read-a-configuration-file.ocaml b/Task/Read-a-configuration-file/OCaml/read-a-configuration-file.ocaml new file mode 100644 index 0000000000..46246a9469 --- /dev/null +++ b/Task/Read-a-configuration-file/OCaml/read-a-configuration-file.ocaml @@ -0,0 +1,25 @@ +#use "topfind" +#require "inifiles" +open Inifiles + +let print_field ini (label, field) = + try + let v = ini#getval "params" field in + Printf.printf "%s: %s\n" label v + with Invalid_element _ -> + Printf.printf "%s: not defined\n" label + +let () = + let ini = new inifile "./conf.ini" in + let lst = [ + "Full name", "FULLNAME"; + "likes", "FAVOURITEFRUIT"; + "needs peeling", "NEEDSPEELING"; + "seeds removed", "SEEDSREMOVED"; + ] in + List.iter (print_field ini) lst; + + let v = ini#getaval "params" "OTHERFAMILY" in + print_endline "other family:"; + List.iter (Printf.printf "- %s\n") v; +;; diff --git a/Task/Read-a-configuration-file/PL-I/read-a-configuration-file.pli b/Task/Read-a-configuration-file/PL-I/read-a-configuration-file.pli new file mode 100644 index 0000000000..740b3ad72d --- /dev/null +++ b/Task/Read-a-configuration-file/PL-I/read-a-configuration-file.pli @@ -0,0 +1,58 @@ +set: procedure options (main); + declare text character (100) varying; + declare (fullname, favouritefruit) character (100) varying initial (''); + declare needspeeling bit (1) static initial ('0'b); + declare seedsremoved bit (1) static initial ('0'b); + declare otherfamily(10) character (100) varying; + declare (i, j) fixed binary; + declare in file; + + open file (in) title ( '/RD-CON.DAT,TYPE(TEXT),RECSIZE(200)' ); + + on endfile (in) go to variables; + + otherfamily = ''; j = 0; + + do forever; + get file (in) edit (text) (L); + text = trim(text); + + if length(text) = 0 then iterate; + if substr(text, 1, 1) = ';' then iterate; + if substr(text, 1, 1) = '#' then iterate; + if length(text) >= 9 then + if substr(text, 1, 9) = 'FULLNAME ' then + fullname = trim( substr(text, 9) ); + if length(text) >= 15 then + if substr(text, 1, 15) = 'FAVOURITEFRUIT ' then + favouritefruit = trim( substr(text, 15) ); + if length(text) >= 12 then + if text = 'NEEDSPEELING' then needspeeling = '1'b; + if length(text) >= 12 then + if text = 'SEEDSREMOVED' then seedsremoved = '1'b; + if length(text) >= 12 then + if substr(text, 1, 12) = 'OTHERFAMILY ' then + do; + text = trim(substr(text, 12) ); + i = index(text, ','); + do while (i > 0); + j = j + 1; + otherfamily(j) = substr(text, 1, i-1); + text = trim(substr(text, i+1)); + i = index(text, ','); + end; + j = j + 1; + otherfamily(j) = trim(text); + end; + end; + +variables: + put skip data (fullname); + put skip data (favouritefruit); + put skip data (needspeeling); + put skip data (seedsremoved); + do i = 1 to j; + put skip data (otherfamily(i)); + end; + +end set; diff --git a/Task/Read-a-configuration-file/Pascal/read-a-configuration-file.pascal b/Task/Read-a-configuration-file/Pascal/read-a-configuration-file.pascal new file mode 100644 index 0000000000..f90a53c793 --- /dev/null +++ b/Task/Read-a-configuration-file/Pascal/read-a-configuration-file.pascal @@ -0,0 +1,100 @@ +#!/usr/bin/instantfpc + +{$if not defined(fpc) or (fpc_fullversion < 20600)} + {$error FPC 2.6.0 or greater required} +{$endif} + +{$mode objfpc}{$H+} + +uses + Classes,SysUtils,gvector,ghashmap; + +type + TStrHashCaseInsensitive = class + class function hash(s: String; n: Integer): Integer; + end; + +class function TStrHashCaseInsensitive.hash(s: String; n: Integer): Integer; +var + x: Integer; + c: Char; +begin + x := 0; + for c in UpCase(s) do Inc(x,Ord(c)); + Result := x mod n; +end; + +type + TConfigValues = specialize TVector; + TConfigStorage = class(specialize THashMap) + destructor Destroy; override; + end; + +destructor TConfigStorage.Destroy; +var + It: TIterator; +begin + if Size > 0 then begin + It := Iterator; + repeat + It.Value.Free; + until not It.Next; + It.Free; + end; + inherited Destroy; +end; + +var + ConfigStrings,ConfigValues: TStrings; + ConfigStorage: TConfigStorage; + ConfigLine,ConfigName,ConfigValue: String; + SeparatorPos: Integer; +begin + ConfigStrings := TStringList.Create; + ConfigValues := TStringList.Create; + ConfigValues.Delimiter := ','; + ConfigValues.StrictDelimiter := true; + ConfigStorage := TConfigStorage.Create; + + ConfigStrings.LoadFromFile('config.test'); + for ConfigLine in ConfigStrings do begin + if Length(ConfigLine) > 0 then begin + case ConfigLine[1] of + '#',';': ; // ignore + else begin + // look for = first + SeparatorPos := Pos('=',ConfigLine); + // if not found, then look for space + if SeparatorPos = 0 then begin + SeparatorPos := Pos(' ',ConfigLine); + end; + // found space + if SeparatorPos <> 0 then begin + ConfigName := UpCase(Copy(ConfigLine,1,SeparatorPos - 1)); + ConfigValues.DelimitedText := Copy(ConfigLine,SeparatorPos + 1,Length(ConfigLine) - SeparatorPos); + // no = or space found, take the whole line as a key name + end else begin + ConfigName := UpCase(Trim(ConfigLine)); + end; + if not ConfigStorage.Contains(ConfigName) then begin + ConfigStorage[ConfigName] := TConfigValues.Create; + end; + for ConfigValue in ConfigValues do begin + ConfigStorage[ConfigName].PushBack(Trim(ConfigValue)); + end; + end; + end; + end; + end; + + WriteLn('FULLNAME = ' + ConfigStorage['FULLNAME'][0]); + WriteLn('FAVOURITEFRUIT = ' + ConfigStorage['FAVOURITEFRUIT'][0]); + WriteLn('NEEDSPEELING = ' + BoolToStr(ConfigStorage.Contains('NEEDSPEELING'),true)); + WriteLn('SEEDSREMOVED = ' + BoolToStr(ConfigStorage.Contains('SEEDSREMOVED'),true)); + WriteLn('OTHERFAMILY(1) = ' + ConfigStorage['OTHERFAMILY'][0]); + WriteLn('OTHERFAMILY(2) = ' + ConfigStorage['OTHERFAMILY'][1]); + + ConfigStorage.Free; + ConfigValues.Free; + ConfigStrings.Free; +end. diff --git a/Task/Read-a-configuration-file/Perl-6/read-a-configuration-file.pl6 b/Task/Read-a-configuration-file/Perl-6/read-a-configuration-file.pl6 new file mode 100644 index 0000000000..df3a93bf4c --- /dev/null +++ b/Task/Read-a-configuration-file/Perl-6/read-a-configuration-file.pl6 @@ -0,0 +1,52 @@ +my $fullname; +my $favouritefruit; +my $needspeeling = False; +my $seedsremoved = False; +my @otherfamily; + +grammar ConfFile { + token TOP { + :my $*linenum = 0; + ^ * [$ || (\N*) { die "Parse failed at $0" } ] + } + + token fullline { + + { ++$*linenum } + + [ \n || { die "Parse failed at line $*linenum" } ] + } + + proto token line() {{*}} + + token line:misc { {} (\S+) { die "Unrecognized word: $0" } } + + token line:sym { ^^ [ ';' | '#' ] \N* } + token line:sym { ^^ \h* $$ } + + token line:sym {:i fullname» { $fullname = $[0].trim } } + token line:sym {:i favouritefruit» { $favouritefruit = $[0].trim } } + token line:sym {:i needspeeling» { $needspeeling = defined $[0] } } + token rest { \h* '='? (\N*) } + token yes { :i \h* '='? \h* + [ + || ([yes|true|1]) + || [no|false|0] + || () + ] \h* + } +} + +grammar MyConfFile is ConfFile { + token line:sym {:i otherfamily» { @otherfamily = $[0]».trim} } + token many { \h*'='? ([ \N ]*) ** ',' } +} + +MyConfFile.parsefile('file.cfg'); + +.perl.say for + :$fullname, + :$favouritefruit, + :$needspeeling, + :$seedsremoved, + :@otherfamily; diff --git a/Task/Read-a-configuration-file/Perl/read-a-configuration-file.pl b/Task/Read-a-configuration-file/Perl/read-a-configuration-file.pl new file mode 100644 index 0000000000..f92add359c --- /dev/null +++ b/Task/Read-a-configuration-file/Perl/read-a-configuration-file.pl @@ -0,0 +1,77 @@ +my $fullname; +my $favouritefruit; +my $needspeeling; +my $seedsremoved; +my @otherfamily; + +# configuration file definition. See read_conf_file below for explanation. +my $conf_definition = { + 'fullname' => [ 'string', \$fullname ], + 'favouritefruit' => [ 'string', \$favouritefruit ], + 'needspeeling' => [ 'boolean', \$needspeeling ], + 'seedsremoved' => [ 'boolean', \$seedsremoved ], + 'otherfamily' => [ 'array', \@otherfamily ], +}; + +my $arg = shift; # take the configuration file name from the command line + # (or first subroutine argument if this were in a sub) +my $file; # this is going to be a file handle reference +open $file, $arg or die "Can't open configuration file '$arg': $!"; + +read_conf_file($file, $conf_definition); + +print "fullname = $fullname\n"; +print "favouritefruit = $favouritefruit\n"; +print "needspeeling = ", ($needspeeling ? 'true' : 'false'), "\n"; +print "seedsremoved = ", ($seedsremoved ? 'true' : 'false'), "\n"; +for (my $i = 0; $i < @otherfamily; ++$i) { + print "otherfamily(", $i + 1, ") = ", $otherfamily[$i], "\n"; +} + +# read_conf_file: Given a file handle opened for reading and a configuration definition, +# read the file. +# If the configuration file doesn't match the definition, raise an exception with "die". +# The configuration definition is (a reference to) an associative array +# where the keys are the configuration variable names in all lower case +# and the values are references to arrays. +# The first element of each of these arrays is the expected type: 'boolean', 'string', or 'array'; +# the second element is a reference to the variable that should be assigned the data. +sub read_conf_file { + my ($fh, $def) = @_; # copy parameters + + local $_; # avoid interfering with use of $_ in main program + while (<$fh>) { # read a line from $fh into $_ until end of file + next if /^#/; # skip "#" comments + next if /^;/; # skip ";" comments + next if /^$/; # skip blank lines + chomp; # strip final newline + + $_ =~ /^\s*(\w+)\s*(.*)$/i or die "Syntax error"; + my $key = $1; + my $rest = $2; + $key =~ tr/[A-Z]/[a-z]/; # convert keyword to lower case + + if (!exists $def->{$key}) { + die "Unknown keyword: '$key'"; + } + + if ($def->{$key}[0] eq 'boolean') { + if ($rest) { + die "Syntax error: extra data following boolean '$key'"; + } + ${$def->{$key}[1]} = 1; + next; # done with this line, go back to "while" + } + + $rest =~ s/\s*$//; # drop trailing whitespace + $rest =~ s/^=\s*//; # drop equals sign if present + + if ($def->{$key}[0] eq 'string') { + ${$def->{$key}[1]} = $rest; + } elsif ($def->{$key}[0] eq 'array') { + @{$def->{$key}[1]} = split /\s*,\s*/, $rest; + } else { + die "Internal error (unknown type in configuration definition)"; + } + } +} diff --git a/Task/Read-a-configuration-file/PicoLisp/read-a-configuration-file-1.l b/Task/Read-a-configuration-file/PicoLisp/read-a-configuration-file-1.l new file mode 100644 index 0000000000..de382f05a4 --- /dev/null +++ b/Task/Read-a-configuration-file/PicoLisp/read-a-configuration-file-1.l @@ -0,0 +1,4 @@ +(de rdConf (File) + (pipe (in File (while (echo "#" ";") (till "^J"))) + (while (read) + (set @ (or (line T) T)) ) ) ) diff --git a/Task/Read-a-configuration-file/PicoLisp/read-a-configuration-file-2.l b/Task/Read-a-configuration-file/PicoLisp/read-a-configuration-file-2.l new file mode 100644 index 0000000000..406723f73c --- /dev/null +++ b/Task/Read-a-configuration-file/PicoLisp/read-a-configuration-file-2.l @@ -0,0 +1,2 @@ +(off FULLNAME FAVOURITEFRUIT NEEDSPEELING SEEDSREMOVED OTHERFAMILY) +(rdConf "conf.txt") diff --git a/Task/Read-a-configuration-file/Protium/read-a-configuration-file.protium b/Task/Read-a-configuration-file/Protium/read-a-configuration-file.protium new file mode 100644 index 0000000000..c249509410 --- /dev/null +++ b/Task/Read-a-configuration-file/Protium/read-a-configuration-file.protium @@ -0,0 +1,27 @@ +<@ DEFUDRLIT>__ReadConfigurationFile| + <@ LETSCPPNTPARSRC>Data|1<@ OMT> read file into locally scope variable + <@ LETCGDLSTLLOSCP>List|Data<@ OMT> split Data into a list of lines + <@ OMT> Remove comment lines, and blank lines + <@ ACTOVRBEFLSTLIT>List|; + <@ ACTOVRBEFLSTLIT>List|# + <@ ACTRMELST>List + <@ OMT> Iterate over the lines of the list + <@ ITEENULSTLit>List| + <@ LETVARUPTVALLSTLIT>key|...| + <@ LETVARAFTVALLSTLIT>val|...| + <@ OMT> test for an empty key (in the case of a boolean) + <@ TSTVARLIT>key| + <@ IFE><@ LETPNTVARVARLIT>val|__True + <@ ELS> + <@ TSTGT0ATBVARLIT>val|, + <@ IFE><@ ACTEXEEMMCAP><&prot; LETCNDLSTLITLIT>&key;&pipe;&val;&pipe;, + <@ ELS><@ LETPNTVARVARVAR>key|val + + + + +<@ ACTUDRLIT>__ReadConfigurationFile|c:\rosetta.config +<@ SAYVAR>FAVOURITEFRUIT +<@ SAYVAR>FULLNAME +<@ SAYVAR>NEEDSPEELING +<@ SAYDMPLST>OTHERFAMILY diff --git a/Task/Read-a-configuration-file/Python/read-a-configuration-file.py b/Task/Read-a-configuration-file/Python/read-a-configuration-file.py new file mode 100644 index 0000000000..0bd4c2bfac --- /dev/null +++ b/Task/Read-a-configuration-file/Python/read-a-configuration-file.py @@ -0,0 +1,34 @@ +def readconf(fn): + ret = {} + with file(fn) as fp: + for line in fp: + # Assume whitespace is ignorable + line = line.strip() + if not line or line.startswith('#'): continue + + boolval = True + # Assume leading ";" means a false boolean + if line.startswith(';'): + # Remove one or more leading semicolons + line = line.lstrip(';') + # If more than just one word, not a valid boolean + if len(line.split()) != 1: continue + boolval = False + + bits = line.split(None, 1) + if len(bits) == 1: + # Assume booleans are just one standalone word + k = bits[0] + v = boolval + else: + # Assume more than one word is a string value + k, v = bits + ret[k.lower()] = v + return ret + + +if __name__ == '__main__': + import sys + conf = readconf(sys.argv[1]) + for k, v in sorted(conf.items()): + print k, '=', v diff --git a/Task/Read-a-configuration-file/REXX/read-a-configuration-file-1.rexx b/Task/Read-a-configuration-file/REXX/read-a-configuration-file-1.rexx new file mode 100644 index 0000000000..0b1c588d62 --- /dev/null +++ b/Task/Read-a-configuration-file/REXX/read-a-configuration-file-1.rexx @@ -0,0 +1,47 @@ +/*REXX program to read a config file and assign VARs as found within. */ +signal on syntax; signal on novalue /*handle REXX program errors. */ +parse arg cFID _ . /*cFID = config file to be read. */ +if cFID=='' then cFID='CONFIG.DAT' /*Not specified? Use the default*/ +bad= /*this will contain all bad VARs.*/ +varList= /*this will contain all the VARs.*/ +maxLenV=0; blanks=0; hashes=0; semics=0; badVar=0 /*zero 'em.*/ + + do j=0 while lines(cFID)\==0 /*J count's the file's lines. */ + txt=strip(linein(cFID)) /*read a line (record) from file,*/ + /*& strip leading/trailing blanks*/ + if txt ='' then do; blanks=blanks+1; iterate; end + if left(txt,1)=='#' then do; hashes=hashes+1; iterate; end + if left(txt,1)==';' then do; semics=semics+1; iterate; end + eqS=pos('=',txt) /*can't use the TRANSLATE bif. */ + if eqS\==0 then txt=overlay(' ',txt,eqS) /*replace 1st '=' with blank*/ + parse var txt xxx value; upper xxx /*get the variableName and value.*/ + value=strip(value) /*strip leading & trailing blanks*/ + varList=varList xxx /*add it to the list of vARiables*/ + if value='' then value='true' /*if no value, then use "true". */ + if symbol(xxx)=='BAD' then do /*can REXX use the variable name?*/ + badVar=badVar+1; bad=bad xxx; iterate + end + call value xxx,value /*now, use VALUE to set the var. */ + maxLenV=max(maxLenV,length(value)) /*maxLen of varNames, pretty disp*/ + end /*j*/ + +vars=words(varList) + say #(j) 'record's(j) "were read from file: " cFID +if blanks\==0 then say #(blanks) 'blank record's(blanks) "were read." +if hashes\==0 then say #(hashes) 'record's(hashes) "ignored that began with a # (hash)." +if semics\==0 then say #(semics) 'record's(semics) "ignored that began with a ; (semicolon)." +if badVar\==0 then say #(badVar) 'bad variable name's(badVar) 'detected:' bad +say; say 'The list of' vars "variable"s(vars) 'and' s(vars,'their',"it's") "value"s(vars) 'follows:'; say + + do k=1 for vars + v=word(varList,k) + say right(v,maxLenV) '=' value(v) + end /*k*/ +exit /*stick a fork in it, we're done.*/ +/*───────────────────────────────error handling subroutines and others.─*/ +s: if arg(1)==1 then return arg(3); return word(arg(2) 's',1) +#: return right(arg(1),length(j)+11) /*right justify a number +indent*/ +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) diff --git a/Task/Read-a-configuration-file/REXX/read-a-configuration-file-2.rexx b/Task/Read-a-configuration-file/REXX/read-a-configuration-file-2.rexx new file mode 100644 index 0000000000..3e83f557c0 --- /dev/null +++ b/Task/Read-a-configuration-file/REXX/read-a-configuration-file-2.rexx @@ -0,0 +1,161 @@ +#!/usr/bin/rexx +/*.----------------------------------------------------------------------.*/ +/*|readconfig: Read keyword value pairs from a configuration file into |*/ +/*| Rexx variables. |*/ +/*| |*/ +/*|Usage: |*/ +/*| .-~/rosetta.conf-. |*/ +/*|>>-readconfig-+----------------+------------------------------------><|*/ +/*| |-configfilename-| |*/ +/*| |-- -? ----------| |*/ +/*| |-- -h ----------| |*/ +/*| '- --help -------' |*/ +/*| |*/ +/*|where |*/ +/*| configfilename |*/ +/*| is the name of the configuration file to be processed. if not|*/ +/*| specified, ~/rosetta.conf is used. |*/ +/*| |*/ +/*|All values retrieved from the configuration file are stored in |*/ +/*|compound variables with the stem config. Variables with multiple |*/ +/*|values have a numeric index appended, and the highest index number |*/ +/*|is stored in the variable with index 0; e.g. if CONFIG.OTHERFAMILY.1 |*/ +/*|and CONFIG.OTHERFAMILY.2 have values assigned, CONFIG.OTHERFAMILY.0 = |*/ +/*|2. |*/ +/*|-?, -h or --help all cause this documentation to be displayed. |*/ +/*| |*/ +/*|This program was tested using Open Object Rexx 4.1.1. It should work |*/ +/*|with most other dialects as well. |*/ +/*'----------------------------------------------------------------------'*/ + call usage arg(1) + trace normal + signal on any name error + +/* Prepare for processing the configuration file. */ + keywords = 'FULLNAME FAVOURITEFRUIT NEEDSPEELING SEEDSREMOVED OTHERFAMILY' + +/* Set default values for configuration variables here */ + config_single?. = 1 + config. = '' + config.NEEDSPEELING = 0 + config.SEEDSREMOVED = 1 + +/* Validate command line inputs. */ + parse arg configfilename + + if length(configfilename) = 0 then + configfilename = '~/rosetta.conf' + + configfile = stream(configfilename,'COMMAND','QUERY EXISTS') + + if length(configfile) = 0 then + do + say configfilename 'was not found.' + exit 28 + end + + signal on notready /* if an I/O error occurs. */ + +/* Open the configuration file. */ + response = stream(configfile,'COMMAND','OPEN READ SHARED') + +/* Parse the contents of the configuration file into variables. */ + do while lines(configfile) > 0 + statement = linein(configfile) + + select + when left(statement,1) = '#', + | left(statement,1) = ';', + | length(strip(statement)) = 0, + then /* a comment or a blank line. */ + nop /* skip it. */ + + otherwise + do + if pos('=',word(statement,1)) > 0, + | left(word(statement,2),1) = '=', + then /* a keyword/value pair with = between. */ + parse var statement keyword '=' value + + else /* a keyword/value pair with no =. */ + parse var statement keyword value + + keyword = translate(strip(keyword)) /* make it uppercase. */ + single? = pos(',',value) = 0 /* a single value, or multiple values? */ + call value 'CONFIG_single?.'keyword,single? /* remember. */ + + if single? then + do + if length(value) > 0 then + call value 'CONFIG.'keyword,strip(value) + end /* strip keeps internal whitespace only. */ + + else /* store each value with its index. */ + do v = 1 by 1 while length(value) > 0 + parse var value value1 ',' value + + if length(value1) > 0 then + do + call value 'CONFIG.'keyword'.'v,strip(value1) + call value 'CONFIG.'keyword'.0',v /* remember this. */ + end + end + end + end + end + +/* Display the values of the configuration variables. */ + say 'Values associated with configuration file' configfilename':' + say + + do while words(keywords) > 0 + parse var keywords keyword keywords + + if value('CONFIG_single?.'keyword) then + say right(keyword,20) '= "'value('CONFIG.'keyword)'"' + + else + do + lastv = value('CONFIG.'keyword'.0') + + do v = 1 to lastv + say right(keyword,20-(length(v)+2))'['v'] = "'value('CONFIG.'keyword'.'v)'"' + end + end + end + + say + +notready: /* I/O errors come here. */ + filestatus = stream(configfile,'STATE') + + if filestatus \= 'READY' then + say 'An I/O error occurred; the file status is' filestatus'.' + + response = stream(configfile,'COMMAND','CLOSE') + +error: +/*? = sysdumpvariables() */ /* see everything Rexx used. */ +exit + +usage: procedure + trace normal + + if arg(1) = '-h', + | arg(1) = '-?', + | arg(1) = '--help' + then + do + line = '/*|' + say + + do l = 3 by 1 while line~left(3) = '/*|' + line = sourceline(l) + parse var line . '/*|' text '|*/' . + say text + end + + say + exit 0 + end +return diff --git a/Task/Read-a-configuration-file/Ruby/read-a-configuration-file.rb b/Task/Read-a-configuration-file/Ruby/read-a-configuration-file.rb new file mode 100644 index 0000000000..b892bfaeb4 --- /dev/null +++ b/Task/Read-a-configuration-file/Ruby/read-a-configuration-file.rb @@ -0,0 +1,19 @@ +fullname = favouritefruit = needspeeling = seedsremoved = false + +IO.foreach("fruit.conf") do |line| + line.chomp! + key, value = line.split(nil, 2) + case key + when /^([#;]|$)/; # ignore line + when "FULLNAME"; fullname = value + when "FAVOURITEFRUIT"; favouritefruit = value + when "NEEDSPEELING"; needspeeling = true + when "SEEDSREMOVED"; seedsremoved = true + when /^./; puts "#{key}: unknown key" + end +end + +puts "fullname = #{fullname}" +puts "favouritefruit = #{favouritefruit}" +puts "needspeeling = #{needspeeling}" +puts "seedsremoved = #{seedsremoved}" diff --git a/Task/Read-a-configuration-file/Seed7/read-a-configuration-file.seed7 b/Task/Read-a-configuration-file/Seed7/read-a-configuration-file.seed7 new file mode 100644 index 0000000000..44d0c8621c --- /dev/null +++ b/Task/Read-a-configuration-file/Seed7/read-a-configuration-file.seed7 @@ -0,0 +1,49 @@ +$ include "seed7_05.s7i"; + include "scanfile.s7i"; + +var string: fullname is ""; +var string: favouritefruit is ""; +var boolean: needspeeling is FALSE; +var boolean: seedsremoved is FALSE; +var array string: otherfamily is 0 times ""; + +const proc: main is func + local + var file: configFile is STD_NULL; + var string: symbol is ""; + var integer: index is 0; + begin + configFile := open("readcfg.txt", "r"); + configFile.bufferChar := getc(configFile); + symbol := lower(getWord(configFile)); + while symbol <> "" do + skipSpace(configFile); + if symbol = "#" or symbol = ";" then + skipLine(configFile); + elsif symbol = "fullname" then + fullname := getLine(configFile); + elsif symbol = "favouritefruit" then + favouritefruit := getLine(configFile); + elsif symbol = "needspeeling" then + needspeeling := TRUE; + elsif symbol = "seedsremoved" then + seedsremoved := TRUE; + elsif symbol = "otherfamily" then + otherfamily := split(getLine(configFile), ","); + for key index range otherfamily do + otherfamily[index] := trim(otherfamily[index]); + end for; + else + writeln(" *** Illegal line " <& literal(getLine(configFile))); + end if; + symbol := lower(getWord(configFile)); + end while; + close(configFile); + writeln("fullname: " <& fullname); + writeln("favouritefruit: " <& favouritefruit); + writeln("needspeeling: " <& needspeeling); + writeln("seedsremoved: " <& seedsremoved); + for key index range otherfamily do + writeln(("otherfamily[" <& index <& "]:") rpad 16 <& otherfamily[index]); + end for; + end func; diff --git a/Task/Read-a-configuration-file/Smalltalk/read-a-configuration-file-1.st b/Task/Read-a-configuration-file/Smalltalk/read-a-configuration-file-1.st new file mode 100644 index 0000000000..30da53c214 --- /dev/null +++ b/Task/Read-a-configuration-file/Smalltalk/read-a-configuration-file-1.st @@ -0,0 +1,19 @@ +dict := Dictionary new. +configFile asFilename readingLinesDo:[:line | + (line isEmpty or:[ line startsWithAnyOf:#('#' ';') ]) ifFalse:[ + s := line readStream. + (s skipSeparators; atEnd) ifFalse:[ + |optionName values| + optionName := s upToSeparator. + values := (s upToEnd asCollectionOfSubstringsSeparatedBy:$,) + collect:[:each | each withoutSeparators] + thenSelect:[:vals | vals notEmpty]. + dict at:optionName asLowercase put:(values isEmpty + ifTrue:[true] + ifFalse:[ + values size == 1 + ifTrue:[values first] + ifFalse:[values]]). + ] + ]. +] diff --git a/Task/Read-a-configuration-file/Smalltalk/read-a-configuration-file-2.st b/Task/Read-a-configuration-file/Smalltalk/read-a-configuration-file-2.st new file mode 100644 index 0000000000..f2a5cd78e2 --- /dev/null +++ b/Task/Read-a-configuration-file/Smalltalk/read-a-configuration-file-2.st @@ -0,0 +1,5 @@ +dict keysAndValuesDo:[:eachOption :eachValue | + someObject + perform:(eachOption,':') asSymbol with:eachValue + ifNotUnderstood: [ self error: 'unknown option: ', eachOption ] +] diff --git a/Task/Read-a-configuration-file/Smalltalk/read-a-configuration-file-3.st b/Task/Read-a-configuration-file/Smalltalk/read-a-configuration-file-3.st new file mode 100644 index 0000000000..0999febdb9 --- /dev/null +++ b/Task/Read-a-configuration-file/Smalltalk/read-a-configuration-file-3.st @@ -0,0 +1,5 @@ +fullname := dict at: 'fullname' ifAbsent:false. +needspeeling := dict at: 'needspeeling' ifAbsent:false. +favouritefruit := dict at: 'favouritefruit' ifAbsent:false. +otherfamily := dict at: 'otherfamily' ifAbsent:false. +seedsremoved := dict at: 'seedsremoved' ifAbsent:false. diff --git a/Task/Read-a-configuration-file/TXR/read-a-configuration-file.txr b/Task/Read-a-configuration-file/TXR/read-a-configuration-file.txr new file mode 100644 index 0000000000..257fdc07b1 --- /dev/null +++ b/Task/Read-a-configuration-file/TXR/read-a-configuration-file.txr @@ -0,0 +1,24 @@ +@(collect) +@ (cases) +#@/.*/ +@ (or) +;@/.*/ +@ (or) +@{IDENT /[A-Z_][A-Z_0-9]+/}@/ */ +@(bind VAL ("true")) +@ (or) +@{IDENT /[A-Z_][A-Z_0-9]+/}@(coll)@/ */@{VAL /[^,]+/}@/ */@(end) +@ (or) +@{IDENT /[A-Z_][A-Z_0-9]+/}@(coll)@/ */@{VAL /[^, ]+/}@/,? */@(end) +@(flatten VAL) +@ (or) +@/ */ +@ (or) +@ (throw error "bad configuration syntax") +@ (end) +@(end) +@(output) +@ (repeat) +@IDENT = @(rep)@VAL, @(first){ @VAL, @(last)@VAL };@(single)@VAL;@(end) +@ (end) +@(end) diff --git a/Task/Read-a-configuration-file/Tcl/read-a-configuration-file.tcl b/Task/Read-a-configuration-file/Tcl/read-a-configuration-file.tcl new file mode 100644 index 0000000000..55e771555c --- /dev/null +++ b/Task/Read-a-configuration-file/Tcl/read-a-configuration-file.tcl @@ -0,0 +1,46 @@ +proc readConfig {filename {defaults {}}} { + global cfg + # Read the file in + set f [open $filename] + set contents [read $f] + close $f + # Set up the defaults, if supplied + foreach {var defaultValue} $defaults { + set cfg($var) $defaultValue + } + # Parse the file's contents + foreach line [split $contents "\n"] { + set line [string trim $line] + # Skip comments + if {[string match "#*" $line] || [string match ";*" $line]} continue + # Skip blanks + if {$line eq ""} continue + + if {[regexp {^\w+$} $line]} { + # Boolean case + set cfg([string tolower $line]) true + } elseif {[regexp {^(\w+)\s+([^,]+)$} $line -> var value]} { + # Simple value case + set cfg([string tolower $var]) $value + } elseif {[regexp {^(\w+)\s+(.+)$} $line -> var listValue]} { + # List value case + set cfg([string tolower $var]) {} + foreach value [split $listValue ","] { + lappend cfg([string tolower $var]) [string trim $value] + } + } else { + error "malformatted config file: $filename" + } + } +} + +# Need to supply some default values due to config file grammar ambiguities +readConfig "fruit.cfg" { + needspeeling false + seedsremoved false +} +puts "Full name: $cfg(fullname)" +puts "Favourite: $cfg(favouritefruit)" +puts "Peeling? $cfg(needspeeling)" +puts "Unseeded? $cfg(seedsremoved)" +puts "Family: $cfg(otherfamily)" diff --git a/Task/Read-a-configuration-file/Vedit-macro-language/read-a-configuration-file.vedit b/Task/Read-a-configuration-file/Vedit-macro-language/read-a-configuration-file.vedit new file mode 100644 index 0000000000..d3b93ff7ad --- /dev/null +++ b/Task/Read-a-configuration-file/Vedit-macro-language/read-a-configuration-file.vedit @@ -0,0 +1,35 @@ +#11 = 0 // needspeeling = FALSE +#12 = 0 // seedsremoved = FALSE +Reg_Empty(21) // fullname +Reg_Empty(22) // favouritefruit +Reg_Empty(23) // otherfamily + +File_Open("|(PATH_ONLY)\example.cfg") + +if (Search("| "Y" Then + flg.abort = "Y" + Exit Sub + End If + var.inistream = var.stream +readinilabela: + Call readlinefromfile + If flg.error = "Y" Then + flg.abort = "Y" + Call closestream + flg.error = "Y" + Exit Sub + End If + If flg.endoffile <> "Y" Then + iniline$ = message$ + If iniline$ <> "" Then + If Left$(iniline$, 1) <> ini.commentchar AND Left$(iniline$, 1) <> ini.ignorechar Then + endofinicommand% = 0 + For l% = 1 To Len(iniline$) + If Mid$(iniline$, l%, 1) < " " Then + endofinicommand% = l% + End If + If Not (endofinicommand%) Then + If Mid$(iniline$, l%, 1) = " " Then + endofinicommand% = l% + End If + End If + If endofinicommand% Then + l% = Len(iniline$) + End If + Next l% + iniarg$ = "" + If endofinicommand% Then + If endofinicommand% <> Len(iniline$) Then + iniarg$ = btrim$(Mid$(iniline$, endofinicommand% + 1)) + If iniarg$ = "" Then + GoTo readinilabelb + End If + inicommand$ = Left$(iniline$, endofinicommand% - 1) + End If + Else + inicommand$ = btrim$(iniline$) + End If +readinilabelb: + 'interpret command + inicommand$ = UCase$(inicommand$) + Select Case inicommand$ + Case "FULLNAME" + If iniarg$ <> "" Then + ini.fullname = iniarg$ + End If + Case "FAVOURITEFRUIT" + If iniarg$ <> "" Then + ini.favouritefruit = iniarg$ + End If + Case "NEEDSPEELING" + ini.needspeeling = "Y" + Case "SEEDSREMOVED" + ini.seedsremoved = "Y" + Case "OTHERFAMILY" + If iniarg$ <> "" Then + ini.otherfamily = iniarg$ + CALL familyparser + End If + Case Else + '!! error handling required + End Select + End If + End If + GoTo readinilabela + End If + Call closestream + Exit Sub +readinierror: + +End Sub + +Sub openfileread() + flg.streamopen = "N" + Call checkfileexists + If flg.error = "Y" Then Exit Sub + If flg.exists <> "Y" Then Exit Sub + Call getfreestream + If flg.error = "Y" Then Exit Sub + var.errorsection = "Opening File" + var.errordevice = var.filename + If ini.errortrap = "Y" Then + On Local Error GoTo openfilereaderror + End If + flg.endoffile = "N" + Open var.filename For Input As #var.stream Len = var.filebuffersize + flg.streamopen = "Y" + Exit Sub +openfilereaderror: + var.errorcode = Err + Call errorhandler + resume '!! +End Sub + +Public Sub checkfileexists() + var.errorsection = "Checking File Exists" + var.errordevice = var.filename + If ini.errortrap = "Y" Then + On Local Error GoTo checkfileexistserror + End If + flg.exists = "N" + If Dir$(var.filename, 0) <> "" Then + flg.exists = "Y" + End If + Exit Sub +checkfileexistserror: + var.errorcode = Err + Call errorhandler +End Sub + +Public Sub getfreestream() + var.errorsection = "Opening Free Data Stream" + var.errordevice = "" + If ini.errortrap = "Y" Then + On Local Error GoTo getfreestreamerror + End If + var.stream = FreeFile + Exit Sub +getfreestreamerror: + var.errorcode = Err + Call errorhandler + resume '!! +End Sub + +Sub closestream() + If ini.errortrap = "Y" Then + On Local Error GoTo closestreamerror + End If + var.errorsection = "Closing Stream" + var.errordevice = "" + flg.resumenext = "Y" + Close #var.stream + If flg.error = "Y" Then + flg.error = "N" + '!! Call unexpectederror + End If + flg.streamopen = "N" + Exit Sub +closestreamerror: + var.errorcode = Err + Call errorhandler + resume next +End Sub + +Sub readlinefromfile() + If ini.errortrap = "Y" Then + On Local Error GoTo readlinefromfileerror + End If + If EOF(var.stream) Then + flg.endoffile = "Y" + Exit Sub + End If + Line Input #var.stream, tmp$ + message$ = tmp$ + Exit Sub +readlinefromfileerror: + var.errorcode = Err + Call errorhandler + resume '!! +End Sub + +Public Sub errorhandler() + tmp$ = btrim$(var.errorsection) + tmp2$ = btrim$(var.errordevice) + If tmp2$ <> "" Then + tmp$ = tmp$ + " (" + tmp2$ + ")" + End If + tmp$ = tmp$ + " : " + Str$(var.errorcode) + tmp1% = MsgBox(tmp$, 0, "Error!") + flg.error = "Y" + If flg.resumenext = "Y" Then + flg.resumenext = "N" +' Resume Next + Else + flg.error = "N" +' Resume + End If +End Sub + +Public Function btrim$(arg$) + btrim$ = LTrim$(RTrim$(arg$)) +End Function diff --git a/Task/Read-a-file-line-by-line/0DESCRIPTION b/Task/Read-a-file-line-by-line/0DESCRIPTION new file mode 100644 index 0000000000..ba03c99b0e --- /dev/null +++ b/Task/Read-a-file-line-by-line/0DESCRIPTION @@ -0,0 +1,5 @@ +Read a file one line at a time, as opposed to [[Read entire file|reading the entire file at once]]. + +;See also +* [[Read a file character by character]] +* [[Input loop]]. diff --git a/Task/Read-a-file-line-by-line/1META.yaml b/Task/Read-a-file-line-by-line/1META.yaml new file mode 100644 index 0000000000..53d5156105 --- /dev/null +++ b/Task/Read-a-file-line-by-line/1META.yaml @@ -0,0 +1,2 @@ +--- +note: File handling diff --git a/Task/Read-a-file-line-by-line/ALGOL-68/read-a-file-line-by-line.alg b/Task/Read-a-file-line-by-line/ALGOL-68/read-a-file-line-by-line.alg new file mode 100644 index 0000000000..0acd400e44 --- /dev/null +++ b/Task/Read-a-file-line-by-line/ALGOL-68/read-a-file-line-by-line.alg @@ -0,0 +1,21 @@ +#!/usr/local/bin/a68g --script # + +FILE foobar; +INT errno = open(foobar, "Read_a_file_line_by_line.a68", stand in channel); + +STRING line; +FORMAT line fmt = $gl$; + +PROC mount next tape = (REF FILE file)BOOL: ( + print("Please mount next tape or q to quit"); + IF read char = "q" THEN done ELSE TRUE FI +); + +on physical file end(foobar, mount next tape); +on logical file end(foobar, (REF FILE skip)BOOL: done); + +FOR count DO + getf(foobar, (line fmt, line)); + printf(($g(0)": "$, count, line fmt, line)) +OD; +done: SKIP diff --git a/Task/Read-a-file-line-by-line/AWK/read-a-file-line-by-line.awk b/Task/Read-a-file-line-by-line/AWK/read-a-file-line-by-line.awk new file mode 100644 index 0000000000..c0d619003b --- /dev/null +++ b/Task/Read-a-file-line-by-line/AWK/read-a-file-line-by-line.awk @@ -0,0 +1 @@ +awk '{ print $0 }' filename diff --git a/Task/Read-a-file-line-by-line/Ada/read-a-file-line-by-line.ada b/Task/Read-a-file-line-by-line/Ada/read-a-file-line-by-line.ada new file mode 100644 index 0000000000..bacabd1df0 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Ada/read-a-file-line-by-line.ada @@ -0,0 +1,19 @@ +with Ada.Text_IO; +procedure Line_By_Line is + Filename : String := "line_by_line.adb"; + File : Ada.Text_IO.File_Type; + Line_Count : Natural := 0; +begin + Ada.Text_IO.Open (File => File, + Mode => Ada.Text_IO.In_File, + Name => Filename); + while not Ada.Text_IO.End_Of_File (File) loop + declare + Line : String := Ada.Text_IO.Get_Line (File); + begin + Line_Count := Line_Count + 1; + Ada.Text_IO.Put_Line (Natural'Image (Line_Count) & ": " & Line); + end; + end loop; + Ada.Text_IO.Close (File); +end Line_By_Line; diff --git a/Task/Read-a-file-line-by-line/Aime/read-a-file-line-by-line.aime b/Task/Read-a-file-line-by-line/Aime/read-a-file-line-by-line.aime new file mode 100644 index 0000000000..8160c335a7 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Aime/read-a-file-line-by-line.aime @@ -0,0 +1,9 @@ +file f; +text s; + +f_affix(f, "src/aime.c"); + +while (f_line(f, s) != -1) { + o_text(s); + o_byte('\n'); +} diff --git a/Task/Read-a-file-line-by-line/AutoHotkey/read-a-file-line-by-line.ahk b/Task/Read-a-file-line-by-line/AutoHotkey/read-a-file-line-by-line.ahk new file mode 100644 index 0000000000..70f706d4ce --- /dev/null +++ b/Task/Read-a-file-line-by-line/AutoHotkey/read-a-file-line-by-line.ahk @@ -0,0 +1,21 @@ +; --> Prompt the user to select the file being read + +FileSelectFile, File, 1, %A_ScriptDir%, Select the (text) file to read, Documents (*.txt) ; Could of course be set to support other filetypes +If Errorlevel ; If no file selected + ExitApp + +; --> Main loop: Input (File), Output (Text) + +Loop +{ +FileReadLine, Line, %File%, %A_Index% ; Reads line N (where N is loop iteration) +if Errorlevel ; If line does not exist, break loop + break +Text .= A_Index ". " Line . "`n" ; Appends the line to the variable "Text", adding line number before & new line after +} + +; --> Delivers the output as a text file + +FileDelete, Output.txt ; Makes sure output is clear before writing +FileAppend, %Text%, Output.txt ; Writes the result to Output.txt +Run Output.txt ; Shows the created file diff --git a/Task/Read-a-file-line-by-line/BASIC/read-a-file-line-by-line-1.basic b/Task/Read-a-file-line-by-line/BASIC/read-a-file-line-by-line-1.basic new file mode 100644 index 0000000000..c783f862a8 --- /dev/null +++ b/Task/Read-a-file-line-by-line/BASIC/read-a-file-line-by-line-1.basic @@ -0,0 +1,5 @@ +10 OPENIN"foo.txt" +20 WHILE NOT EOF +30 LINE INPUT#9,i$ +40 PRINT i$ +50 WEND diff --git a/Task/Read-a-file-line-by-line/BASIC/read-a-file-line-by-line-2.basic b/Task/Read-a-file-line-by-line/BASIC/read-a-file-line-by-line-2.basic new file mode 100644 index 0000000000..93090d2f18 --- /dev/null +++ b/Task/Read-a-file-line-by-line/BASIC/read-a-file-line-by-line-2.basic @@ -0,0 +1,7 @@ +10 REM open my file for input +20 OPEN #4;"m";1;"MYFILE": REM stream 4 is the first available for general purpose +30 INPUT #4; LINE a$: REM a$ will hold our line from the file +40 REM because we do not know how many lines are in the file, we need an error trap +50 REM to gracefully exit when the file is read. (omitted from this example) +60 REM to prevent an error at end of file, place a handler here +100 GOTO 30 diff --git a/Task/Read-a-file-line-by-line/BBC-BASIC/read-a-file-line-by-line-1.bbc b/Task/Read-a-file-line-by-line/BBC-BASIC/read-a-file-line-by-line-1.bbc new file mode 100644 index 0000000000..b8e7bf3c2d --- /dev/null +++ b/Task/Read-a-file-line-by-line/BBC-BASIC/read-a-file-line-by-line-1.bbc @@ -0,0 +1,6 @@ + file% = OPENIN("*.txt") + IF file%=0 ERROR 100, "File could not be opened" + WHILE NOT EOF#file% + a$ = GET$#file% + ENDWHILE + CLOSE #file% diff --git a/Task/Read-a-file-line-by-line/BBC-BASIC/read-a-file-line-by-line-2.bbc b/Task/Read-a-file-line-by-line/BBC-BASIC/read-a-file-line-by-line-2.bbc new file mode 100644 index 0000000000..6e2d106823 --- /dev/null +++ b/Task/Read-a-file-line-by-line/BBC-BASIC/read-a-file-line-by-line-2.bbc @@ -0,0 +1,7 @@ + file% = OPENIN("*.txt") + IF file%=0 ERROR 100, "File could not be opened" + WHILE NOT EOF#file% + INPUT #file%, a$ + IF ASCa$=10 a$ = MID$(a$,2) + ENDWHILE + CLOSE #file% diff --git a/Task/Read-a-file-line-by-line/Brat/read-a-file-line-by-line.brat b/Task/Read-a-file-line-by-line/Brat/read-a-file-line-by-line.brat new file mode 100644 index 0000000000..1e72268618 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Brat/read-a-file-line-by-line.brat @@ -0,0 +1,5 @@ +include :file + +file.each_line "foobar.txt" { line | + p line +} diff --git a/Task/Read-a-file-line-by-line/C++/read-a-file-line-by-line-1.cpp b/Task/Read-a-file-line-by-line/C++/read-a-file-line-by-line-1.cpp new file mode 100644 index 0000000000..7b7cc99910 --- /dev/null +++ b/Task/Read-a-file-line-by-line/C++/read-a-file-line-by-line-1.cpp @@ -0,0 +1,17 @@ +#include +#include +#include + +int main( int argc , char** argv ) { + int linecount = 0 ; + std::string line ; + std::ifstream infile( argv[ 1 ] ) ; + if ( infile ) { + while ( getline( infile , line ) ) { + std::cout << linecount << ": " << line << '\n' ;//supposing '\n' to be line end + linecount++ ; + } + } + infile.close( ) ; + return 0 ; +} diff --git a/Task/Read-a-file-line-by-line/C++/read-a-file-line-by-line-2.cpp b/Task/Read-a-file-line-by-line/C++/read-a-file-line-by-line-2.cpp new file mode 100644 index 0000000000..56f5bfc548 --- /dev/null +++ b/Task/Read-a-file-line-by-line/C++/read-a-file-line-by-line-2.cpp @@ -0,0 +1,10 @@ +#include + +using namespace Upp; + +CONSOLE_APP_MAIN +{ + FileIn in(CommandLine()[0]); + while(in && !in.IsEof()) + Cout().PutLine(in.GetLine()); +} diff --git a/Task/Read-a-file-line-by-line/C-sharp/read-a-file-line-by-line-1.cs b/Task/Read-a-file-line-by-line/C-sharp/read-a-file-line-by-line-1.cs new file mode 100644 index 0000000000..3e4de15795 --- /dev/null +++ b/Task/Read-a-file-line-by-line/C-sharp/read-a-file-line-by-line-1.cs @@ -0,0 +1,2 @@ +foreach (string readLine in File.ReadLines("FileName") + DoSomething(readLine); diff --git a/Task/Read-a-file-line-by-line/C-sharp/read-a-file-line-by-line-2.cs b/Task/Read-a-file-line-by-line/C-sharp/read-a-file-line-by-line-2.cs new file mode 100644 index 0000000000..24891b992e --- /dev/null +++ b/Task/Read-a-file-line-by-line/C-sharp/read-a-file-line-by-line-2.cs @@ -0,0 +1,34 @@ +using System; +using System.IO; +using System.Text; + +namespace RosettaCode +{ + internal class Program + { + private static void Main() + { + var sb = new StringBuilder(); + string F = "File.txt"; + + // Read a file, line by line. + try + { + foreach (string readLine in File.ReadLines(F)) + { + // Use the data in some way... + sb.Append(readLine); + sb.Append("\n"); + } + } + catch (Exception exception) + { + Console.WriteLine(exception.Message); + Environment.Exit(1); + } + + // Preset the results + Console.WriteLine(sb.ToString()); + } + } +} diff --git a/Task/Read-a-file-line-by-line/C/read-a-file-line-by-line-1.c b/Task/Read-a-file-line-by-line/C/read-a-file-line-by-line-1.c new file mode 100644 index 0000000000..c65bf46270 --- /dev/null +++ b/Task/Read-a-file-line-by-line/C/read-a-file-line-by-line-1.c @@ -0,0 +1,35 @@ +#include /* err */ +#include /* fopen, fgetln, fputs, fwrite */ + +/* + * Read a file line by line. + * http://rosettacode.org/wiki/Read_a_file_line_by_line + */ +int +main() +{ + FILE *f; + size_t len; + char *line; + + f = fopen("foobar.txt", "r"); + if (f == NULL) + err(1, "foobar.txt"); + + /* + * This loop reads each line. + * Remember that line is not a C string. + * There is no terminating '\0'. + */ + while (line = fgetln(f, &len)) { + /* + * Do something with line. + */ + fputs("LINE: ", stdout); + fwrite(line, len, 1, stdout); + } + if (!feof(f)) + err(1, "fgetln"); + + return 0; +} diff --git a/Task/Read-a-file-line-by-line/C/read-a-file-line-by-line-2.c b/Task/Read-a-file-line-by-line/C/read-a-file-line-by-line-2.c new file mode 100644 index 0000000000..6e36638c56 --- /dev/null +++ b/Task/Read-a-file-line-by-line/C/read-a-file-line-by-line-2.c @@ -0,0 +1,123 @@ +#include /* exit, malloc, realloc, free */ +#include /* fopen, fgetc, fputs, fwrite */ + +struct line_reader { + /* All members are private. */ + FILE *f; + char *buf; + size_t siz; +}; + +/* + * Initializes a line reader _lr_ for the stream _f_. + */ +void +lr_init(struct line_reader *lr, FILE *f) +{ + lr->f = f; + lr->buf = NULL; + lr->siz = 0; +} + +/* + * Reads the next line. If successful, returns a pointer to the line, + * and sets *len to the number of characters, at least 1. The result is + * _not_ a C string; it has no terminating '\0'. The returned pointer + * remains valid until the next call to next_line() or lr_free() with + * the same _lr_. + * + * next_line() returns NULL at end of file, or if there is an error (on + * the stream, or with memory allocation). + */ +char * +next_line(struct line_reader *lr, size_t *len) +{ + size_t newsiz; + int c; + char *newbuf; + + *len = 0; /* Start with empty line. */ + for (;;) { + c = fgetc(lr->f); /* Read next character. */ + if (ferror(lr->f)) + return NULL; + + if (c == EOF) { + /* + * End of file is also end of last line, + ` * unless this last line would be empty. + */ + if (*len == 0) + return NULL; + else + return lr->buf; + } else { + /* Append c to the buffer. */ + if (*len == lr->siz) { + /* Need a bigger buffer! */ + newsiz = lr->siz + 4096; + newbuf = realloc(lr->buf, newsiz); + if (newbuf == NULL) + return NULL; + lr->buf = newbuf; + lr->siz = newsiz; + } + lr->buf[(*len)++] = c; + + /* '\n' is end of line. */ + if (c == '\n') + return lr->buf; + } + } +} + +/* + * Frees internal memory used by _lr_. + */ +void +lr_free(struct line_reader *lr) +{ + free(lr->buf); + lr->buf = NULL; + lr->siz = 0; +} + +/* + * Read a file line by line. + * http://rosettacode.org/wiki/Read_a_file_line_by_line + */ +int +main() +{ + struct line_reader lr; + FILE *f; + size_t len; + char *line; + + f = fopen("foobar.txt", "r"); + if (f == NULL) { + perror("foobar.txt"); + exit(1); + } + + /* + * This loop reads each line. + * Remember that line is not a C string. + * There is no terminating '\0'. + */ + lr_init(&lr, f); + while (line = next_line(&lr, &len)) { + /* + * Do something with line. + */ + fputs("LINE: ", stdout); + fwrite(line, len, 1, stdout); + } + if (!feof(f)) { + perror("next_line"); + exit(1); + } + lr_free(&lr); + + return 0; +} diff --git a/Task/Read-a-file-line-by-line/C/read-a-file-line-by-line-3.c b/Task/Read-a-file-line-by-line/C/read-a-file-line-by-line-3.c new file mode 100644 index 0000000000..c6c2bacffa --- /dev/null +++ b/Task/Read-a-file-line-by-line/C/read-a-file-line-by-line-3.c @@ -0,0 +1,75 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +int read_lines(const char * fname, int (*call_back)(const char*, const char*)) +{ + int fd = open(fname, O_RDONLY); + struct stat fs; + char *buf, *buf_end; + char *begin, *end, c; + + if (fd == -1) { + err(1, "open: %s", fname); + return 0; + } + + if (fstat(fd, &fs) == -1) { + err(1, "stat: %s", fname); + return 0; + } + + /* fs.st_size could have been 0 actually */ + buf = mmap(0, fs.st_size, PROT_READ, MAP_SHARED, fd, 0); + if (buf == (void*) -1) { + err(1, "mmap: %s", fname); + close(fd); + return 0; + } + + buf_end = buf + fs.st_size; + + begin = end = buf; + while (1) { + if (! (*end == '\r' || *end == '\n')) { + if (++end < buf_end) continue; + } else if (1 + end < buf_end) { + /* see if we got "\r\n" or "\n\r" here */ + c = *(1 + end); + if ( (c == '\r' || c == '\n') && c != *end) + ++end; + } + + /* call the call back and check error indication. Announce + error here, because we didn't tell call_back the file name */ + if (! call_back(begin, end)) { + err(1, "[callback] %s", fname); + break; + } + + if ((begin = ++end) >= buf_end) + break; + } + + munmap(buf, fs.st_size); + close(fd); + return 1; +} + +int print_line(const char* begin, const char* end) +{ + if (write(fileno(stdout), begin, end - begin + 1) == -1) { + return 0; + } + return 1; +} + +int main() +{ + return read_lines("test.ps", print_line) ? 0 : 1; +} diff --git a/Task/Read-a-file-line-by-line/Clojure/read-a-file-line-by-line.clj b/Task/Read-a-file-line-by-line/Clojure/read-a-file-line-by-line.clj new file mode 100644 index 0000000000..68cf978f47 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Clojure/read-a-file-line-by-line.clj @@ -0,0 +1,3 @@ +(with-open [r (clojure.java.io/reader "some-file.txt")] + (doseq [l (line-seq r)] + (println l))) diff --git a/Task/Read-a-file-line-by-line/CoffeeScript/read-a-file-line-by-line.coffeescript b/Task/Read-a-file-line-by-line/CoffeeScript/read-a-file-line-by-line.coffeescript new file mode 100644 index 0000000000..02b69b6684 --- /dev/null +++ b/Task/Read-a-file-line-by-line/CoffeeScript/read-a-file-line-by-line.coffeescript @@ -0,0 +1,80 @@ +# This module shows two ways to read a file line-by-line in node.js. +fs = require 'fs' + +# First, let's keep things simple, and do things synchronously. This +# approach is well-suited for simple scripts. +do -> + fn = "read_file.coffee" + for line in fs.readFileSync(fn).toString().split '\n' + console.log line + console.log "DONE SYNC!" + +# Now let's complicate things. +# +# Use the following code when files are large, and memory is +# constrained and/or where you want a large amount of concurrency. +# +# Protocol: +# Call LineByLineReader, which calls back to you with a reader. +# The reader has two methods. +# next_line: call to this when you want a new line +# close: call this when you are done using the file before +# it has been read completely +# +# When you call next_line, you must supply two callbacks: +# line_cb: called back when there is a line of text +# done_cb: called back when there is no more text in the file +LineByLineReader = (fn, cb) -> + fs.open fn, 'r', (err, fd) -> + bufsize = 256 + pos = 0 + text = '' + eof = false + closed = false + reader = + next_line: (line_cb, done_cb) -> + if eof + if text + last_line = text + text = '' + line_cb last_line + else + done_cb() + return + + new_line_index = text.indexOf '\n' + if new_line_index >= 0 + line = text.substr 0, new_line_index + text = text.substr new_line_index + 1, text.length - new_line_index - 1 + line_cb line + else + frag = new Buffer(bufsize) + fs.read fd, frag, 0, bufsize, pos, (err, bytesRead) -> + s = frag.toString('utf8', 0, bytesRead) + text += s + pos += bytesRead + if (bytesRead) + reader.next_line line_cb, done_cb + else + eof = true + fs.closeSync(fd) + closed = true + reader.next_line line_cb, done_cb + close: -> + # The reader should call this if they abandon mid-file. + fs.closeSync(fd) unless closed + + cb reader + +# Test our interface here. +do -> + console.log '---' + fn = 'read_file.coffee' + LineByLineReader fn, (reader) -> + callbacks = + process_line: (line) -> + console.log line + reader.next_line callbacks.process_line, callbacks.all_done + all_done: -> + console.log "DONE ASYNC!" + reader.next_line callbacks.process_line, callbacks.all_done diff --git a/Task/Read-a-file-line-by-line/Common-Lisp/read-a-file-line-by-line.lisp b/Task/Read-a-file-line-by-line/Common-Lisp/read-a-file-line-by-line.lisp new file mode 100644 index 0000000000..896a6c1e89 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Common-Lisp/read-a-file-line-by-line.lisp @@ -0,0 +1,3 @@ +(with-open-file (input "file.txt") + (loop for line = (read-line input nil) + while line do (format t "~a~%" line))) diff --git a/Task/Read-a-file-line-by-line/D/read-a-file-line-by-line.d b/Task/Read-a-file-line-by-line/D/read-a-file-line-by-line.d new file mode 100644 index 0000000000..8bff975e97 --- /dev/null +++ b/Task/Read-a-file-line-by-line/D/read-a-file-line-by-line.d @@ -0,0 +1,6 @@ +import std.stdio; + +void main() { + foreach (line; File("unixdict.txt").byLine()) + writeln(line); +} diff --git a/Task/Read-a-file-line-by-line/Delphi/read-a-file-line-by-line-1.delphi b/Task/Read-a-file-line-by-line/Delphi/read-a-file-line-by-line-1.delphi new file mode 100644 index 0000000000..1858aeea77 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Delphi/read-a-file-line-by-line-1.delphi @@ -0,0 +1,11 @@ + procedure ReadFileByLine; + var + TextFile: text; + TextLine: String; + begin + Assign(TextFile, 'c:\test.txt'); + Reset(TextFile); + while not Eof(TextFile) do + Readln(TextFile, TextLine); + CloseFile(TextFile); + end; diff --git a/Task/Read-a-file-line-by-line/Delphi/read-a-file-line-by-line-2.delphi b/Task/Read-a-file-line-by-line/Delphi/read-a-file-line-by-line-2.delphi new file mode 100644 index 0000000000..67eb595201 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Delphi/read-a-file-line-by-line-2.delphi @@ -0,0 +1,10 @@ +procedure ReadFileByLine; + var + TextLines : TStringList; + i : Integer; + begin + TextLines := TStringList.Create; + TextLines.LoadFromFile('c:\text.txt'); + for i := 0 to TextLines.count -1 do + ShowMessage(TextLines[i]); + end; diff --git a/Task/Read-a-file-line-by-line/Euphoria/read-a-file-line-by-line.euphoria b/Task/Read-a-file-line-by-line/Euphoria/read-a-file-line-by-line.euphoria new file mode 100644 index 0000000000..062e5a4a02 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Euphoria/read-a-file-line-by-line.euphoria @@ -0,0 +1,15 @@ +constant cmd = command_line() +constant filename = cmd[2] +constant fn = open(filename,"r") +integer i +i = 1 +object x +while 1 do + x = gets(fn) + if atom(x) then + exit + end if + printf(1,"%2d: %s",{i,x}) + i += 1 +end while +close(fn) diff --git a/Task/Read-a-file-line-by-line/Factor/read-a-file-line-by-line.factor b/Task/Read-a-file-line-by-line/Factor/read-a-file-line-by-line.factor new file mode 100644 index 0000000000..53be72f29d --- /dev/null +++ b/Task/Read-a-file-line-by-line/Factor/read-a-file-line-by-line.factor @@ -0,0 +1 @@ + "path/to/file" utf8 [ [ readln dup [ print ] when* ] loop ] with-file-reader diff --git a/Task/Read-a-file-line-by-line/Fantom/read-a-file-line-by-line.fantom b/Task/Read-a-file-line-by-line/Fantom/read-a-file-line-by-line.fantom new file mode 100644 index 0000000000..8dd44c132c --- /dev/null +++ b/Task/Read-a-file-line-by-line/Fantom/read-a-file-line-by-line.fantom @@ -0,0 +1,10 @@ +class Main +{ + Void main () + { + File (`data.txt`).eachLine |Str line| + { + echo ("Line: $line") + } + } +} diff --git a/Task/Read-a-file-line-by-line/Forth/read-a-file-line-by-line.fth b/Task/Read-a-file-line-by-line/Forth/read-a-file-line-by-line.fth new file mode 100644 index 0000000000..542557dbc9 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Forth/read-a-file-line-by-line.fth @@ -0,0 +1,10 @@ +4096 constant max-line + +: third ( A b c -- A b c A ) + >r over r> swap ; + +: read-lines ( fileid -- ) + begin pad max-line third read-line throw + while pad swap ( fileid c-addr u ) \ string excludes the newline + 2drop + repeat 2drop ; diff --git a/Task/Read-a-file-line-by-line/Frink/read-a-file-line-by-line.frink b/Task/Read-a-file-line-by-line/Frink/read-a-file-line-by-line.frink new file mode 100644 index 0000000000..dc94c3f76c --- /dev/null +++ b/Task/Read-a-file-line-by-line/Frink/read-a-file-line-by-line.frink @@ -0,0 +1,2 @@ +for line = lines["file:yourfile.txt"] + println[line] diff --git a/Task/Read-a-file-line-by-line/GAP/read-a-file-line-by-line.gap b/Task/Read-a-file-line-by-line/GAP/read-a-file-line-by-line.gap new file mode 100644 index 0000000000..5826acc3fd --- /dev/null +++ b/Task/Read-a-file-line-by-line/GAP/read-a-file-line-by-line.gap @@ -0,0 +1,18 @@ +ReadByLines := function(name) + local file, line, count; + file := InputTextFile(name); + count := 0; + while true do + line := ReadLine(file); + if line = fail then + break; + fi; + count := count + 1; + od; + CloseStream(file); + return count; +end; + +# With [http://www.ibiblio.org/pub/docs/misc/amnesty.txt amnesty.txt] +ReadByLines("amnesty.txt"); +# 384 diff --git a/Task/Read-a-file-line-by-line/Go/read-a-file-line-by-line-1.go b/Task/Read-a-file-line-by-line/Go/read-a-file-line-by-line-1.go new file mode 100644 index 0000000000..1ef5db06c8 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Go/read-a-file-line-by-line-1.go @@ -0,0 +1,63 @@ +package main + +import ( + "bufio" + "fmt" + "io" + "log" + "os" +) + +func main() { + f, err := os.Open("file") // os.OpenFile has more options if you need them + if err != nil { // error checking is good practice + // error *handling* is good practice. log.Fatal sends the error + // message to stderr and exits with a non-zero code. + log.Fatal(err) + } + + // os.File has no special buffering, it makes straight operating system + // requests. bufio.Reader does buffering and has several useful methods. + bf := bufio.NewReader(f) + + // there are a few possible loop termination + // conditions, so just start with an infinite loop. + for { + // reader.ReadLine does a buffered read up to a line terminator, + // handles either /n or /r/n, and returns just the line without + // the /r or /r/n. + line, isPrefix, err := bf.ReadLine() + + // loop termination condition 1: EOF. + // this is the normal loop termination condition. + if err == io.EOF { + break + } + + // loop termination condition 2: some other error. + // Errors happen, so check for them and do something with them. + if err != nil { + log.Fatal(err) + } + + // loop termination condition 3: line too long to fit in buffer + // without multiple reads. Bufio's default buffer size is 4K. + // Chances are if you haven't seen a line terminator after 4k + // you're either reading the wrong file or the file is corrupt. + if isPrefix { + log.Fatal("Error: Unexpected long line reading", f.Name()) + } + + // success. The variable line is now a byte slice based on on + // bufio's underlying buffer. This is the minimal churn necessary + // to let you look at it, but note! the data may be overwritten or + // otherwise invalidated on the next read. Look at it and decide + // if you want to keep it. If so, copy it or copy the portions + // you want before iterating in this loop. Also note, it is a byte + // slice. Often you will want to work on the data as a string, + // and the string type conversion (shown here) allocates a copy of + // the data. It would be safe to send, store, reference, or otherwise + // hold on to this string, then continue iterating in this loop. + fmt.Println(string(line)) + } +} diff --git a/Task/Read-a-file-line-by-line/Go/read-a-file-line-by-line-2.go b/Task/Read-a-file-line-by-line/Go/read-a-file-line-by-line-2.go new file mode 100644 index 0000000000..ca2a4afc0f --- /dev/null +++ b/Task/Read-a-file-line-by-line/Go/read-a-file-line-by-line-2.go @@ -0,0 +1,32 @@ +package main + +import ( + "bufio" + "fmt" + "io" + "log" + "os" +) + +func main() { + f, err := os.Open("file") + if err != nil { + log.Fatal(err) + } + bf := bufio.NewReader(f) + for { + switch line, err := bf.ReadString('\n'); err { + case nil: + // valid line, echo it. note that line contains trailing \n. + fmt.Print(line) + case io.EOF: + if line > "" { + // last line of file missing \n, but still valid + fmt.Println(line) + } + return + default: + log.Fatal(err) + } + } +} diff --git a/Task/Read-a-file-line-by-line/Groovy/read-a-file-line-by-line-1.groovy b/Task/Read-a-file-line-by-line/Groovy/read-a-file-line-by-line-1.groovy new file mode 100644 index 0000000000..c82f9f32bd --- /dev/null +++ b/Task/Read-a-file-line-by-line/Groovy/read-a-file-line-by-line-1.groovy @@ -0,0 +1,3 @@ +new File("Test.txt").eachLine { line, lineNumber -> + println "processing line $lineNumber: $line" +} diff --git a/Task/Read-a-file-line-by-line/Groovy/read-a-file-line-by-line-2.groovy b/Task/Read-a-file-line-by-line/Groovy/read-a-file-line-by-line-2.groovy new file mode 100644 index 0000000000..7d51df2792 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Groovy/read-a-file-line-by-line-2.groovy @@ -0,0 +1,3 @@ +main = do + file <- readFile "linebyline.hs" + mapM_ putStrLn (lines file) diff --git a/Task/Read-a-file-line-by-line/Groovy/read-a-file-line-by-line-3.groovy b/Task/Read-a-file-line-by-line/Groovy/read-a-file-line-by-line-3.groovy new file mode 100644 index 0000000000..fafc6bda21 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Groovy/read-a-file-line-by-line-3.groovy @@ -0,0 +1,5 @@ +procedure main() +f := open("input.txt","r") | stop("cannot open file ",fn) +while line := read(f) +close(f) +end diff --git a/Task/Read-a-file-line-by-line/J/read-a-file-line-by-line-1.j b/Task/Read-a-file-line-by-line/J/read-a-file-line-by-line-1.j new file mode 100644 index 0000000000..a39406b8e2 --- /dev/null +++ b/Task/Read-a-file-line-by-line/J/read-a-file-line-by-line-1.j @@ -0,0 +1,34 @@ +cocurrent 'linereader' + + NB. configuration parameter + blocksize=: 400000 + + NB. implementation + offset=: 0 + position=: 0 + buffer=: '' + lines=: '' + + create=: monad define + name=: boxxopen y + size=: 1!:4 name + blocks=: 2 <@(-~/\)\ ~. size <. blocksize * i. 1 + >. size % blocksize + ) + + readblocks=: monad define + if. 0=#blocks do. return. end. + if. 1<#lines do. return. end. + whilst. -.LF e.chars do. + buffer=: buffer,chars=. 1!:11 name,{.blocks + blocks=: }.blocks + lines=: <;._2 buffer,LF + end. + buffer=: _1{::lines + ) + + next=: monad define + if. (#blocks)*.2>#lines do. readblocks'' end. + r=. 0{::lines + lines=: }.lines + r + ) diff --git a/Task/Read-a-file-line-by-line/J/read-a-file-line-by-line-2.j b/Task/Read-a-file-line-by-line/J/read-a-file-line-by-line-2.j new file mode 100644 index 0000000000..f9230874e6 --- /dev/null +++ b/Task/Read-a-file-line-by-line/J/read-a-file-line-by-line-2.j @@ -0,0 +1,5 @@ + example=: '/tmp/example.txt' conew 'linereader' + next__example'' +this is line 1 + next__example'' +and this is line 2 diff --git a/Task/Read-a-file-line-by-line/Java/read-a-file-line-by-line-1.java b/Task/Read-a-file-line-by-line/Java/read-a-file-line-by-line-1.java new file mode 100644 index 0000000000..472f5f3d61 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Java/read-a-file-line-by-line-1.java @@ -0,0 +1,39 @@ +import java.io.BufferedReader; +import java.io.FileReader; + +/** + * Reads a file line by line, processing each line. + * + * @author $Author$ + * @version $Revision$ + */ +public class ReadFileByLines { + private static void processLine(int lineNo, String line) { + // ... + } + + public static void main(String[] args) { + for (String filename : args) { + BufferedReader br = null; + FileReader fr = null; + try { + fr = new FileReader(filename); + br = new BufferedReader(fr); + String line; + int lineNo = 0; + while ((line = br.readLine()) != null) { + processLine(++lineNo, line); + } + } + catch (Exception x) { + x.printStackTrace(); + } + finally { + if (fr != null) { + try {br.close();} catch (Exception ignoreMe) {} + try {fr.close();} catch (Exception ignoreMe) {} + } + } + } + } +} diff --git a/Task/Read-a-file-line-by-line/Java/read-a-file-line-by-line-2.java b/Task/Read-a-file-line-by-line/Java/read-a-file-line-by-line-2.java new file mode 100644 index 0000000000..abbcd917ef --- /dev/null +++ b/Task/Read-a-file-line-by-line/Java/read-a-file-line-by-line-2.java @@ -0,0 +1,12 @@ +for (String filename : args) { + try (FileReader fr = new FileReader(filename);BufferedReader br = new BufferedReader(fr)){ + String line; + int lineNo = 0; + while ((line = br.readLine()) != null) { + processLine(++lineNo, line); + } + } + catch (Exception x) { + x.printStackTrace(); + } +} diff --git a/Task/Read-a-file-line-by-line/Java/read-a-file-line-by-line-3.java b/Task/Read-a-file-line-by-line/Java/read-a-file-line-by-line-3.java new file mode 100644 index 0000000000..a64a468a79 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Java/read-a-file-line-by-line-3.java @@ -0,0 +1,11 @@ +import java.nio.file.Files; +import java.nio.file.Paths; +import java.nio.charset.Charset; +import java.io.IOException; +//...other class code +List lines = null; +try{ + lines = Files.readAllLines(Paths.get(filename), Charset.defaultCharset()); +}catch(IOException | SecurityException e){ + //problem with the file +} diff --git a/Task/Read-a-file-line-by-line/Julia/read-a-file-line-by-line.julia b/Task/Read-a-file-line-by-line/Julia/read-a-file-line-by-line.julia new file mode 100644 index 0000000000..075a346263 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Julia/read-a-file-line-by-line.julia @@ -0,0 +1,5 @@ +input = open("input_file","r") +for line in each_line(input) + #line operations +end +close(input) diff --git a/Task/Read-a-file-line-by-line/Liberty-BASIC/read-a-file-line-by-line-1.liberty b/Task/Read-a-file-line-by-line/Liberty-BASIC/read-a-file-line-by-line-1.liberty new file mode 100644 index 0000000000..ded2b856c6 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Liberty-BASIC/read-a-file-line-by-line-1.liberty @@ -0,0 +1,8 @@ +filedialog "Open","*.txt",file$ +if file$="" then end +open file$ for input as #f +while not(eof(#f)) + line input #f, t$ + print t$ +wend +close #f diff --git a/Task/Read-a-file-line-by-line/Liberty-BASIC/read-a-file-line-by-line-2.liberty b/Task/Read-a-file-line-by-line/Liberty-BASIC/read-a-file-line-by-line-2.liberty new file mode 100644 index 0000000000..7542e8f7bd --- /dev/null +++ b/Task/Read-a-file-line-by-line/Liberty-BASIC/read-a-file-line-by-line-2.liberty @@ -0,0 +1,8 @@ +filedialog "Open","*.txt",file$ +if file$="" then end +open file$ for input as #f +while not(eof(#f)) + t$ = inputto$(#f, chr$(13)) + print t$ +wend +close #f diff --git a/Task/Read-a-file-line-by-line/Liberty-BASIC/read-a-file-line-by-line-3.liberty b/Task/Read-a-file-line-by-line/Liberty-BASIC/read-a-file-line-by-line-3.liberty new file mode 100644 index 0000000000..81518abb40 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Liberty-BASIC/read-a-file-line-by-line-3.liberty @@ -0,0 +1,8 @@ +filedialog "Open","*.txt",file$ +if file$="" then end +open file$ for input as #f +while not(eof(#f)) + t$ = inputto$(#f, chr$(10)) + print t$ +wend +close #f diff --git a/Task/Read-a-file-line-by-line/Logo/read-a-file-line-by-line.logo b/Task/Read-a-file-line-by-line/Logo/read-a-file-line-by-line.logo new file mode 100644 index 0000000000..89a8317982 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Logo/read-a-file-line-by-line.logo @@ -0,0 +1 @@ +while [not eof?] [print readline] diff --git a/Task/Read-a-file-line-by-line/Lua/read-a-file-line-by-line.lua b/Task/Read-a-file-line-by-line/Lua/read-a-file-line-by-line.lua new file mode 100644 index 0000000000..4798163d1f --- /dev/null +++ b/Task/Read-a-file-line-by-line/Lua/read-a-file-line-by-line.lua @@ -0,0 +1,8 @@ +filename = "input.txt" +fp = io.open( filename, "r" ) + +for line in fp:lines() do + print( line ) +end + +fp:close() diff --git a/Task/Read-a-file-line-by-line/MATLAB/read-a-file-line-by-line.m b/Task/Read-a-file-line-by-line/MATLAB/read-a-file-line-by-line.m new file mode 100644 index 0000000000..7f2185607d --- /dev/null +++ b/Task/Read-a-file-line-by-line/MATLAB/read-a-file-line-by-line.m @@ -0,0 +1,10 @@ + fid = fopen('foobar.txt','r'); + if (fid < 0) + printf('Error:could not open file\n') + else + while ~feof(fid), + line = fgetl(fid); + %% process line %% + end; + fclose(fid) + end; diff --git a/Task/Read-a-file-line-by-line/Mathematica/read-a-file-line-by-line.math b/Task/Read-a-file-line-by-line/Mathematica/read-a-file-line-by-line.math new file mode 100644 index 0000000000..39a2309cb0 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Mathematica/read-a-file-line-by-line.math @@ -0,0 +1,7 @@ +strm=OpenRead["input.txt"]; +If[strm=!=$Failed, + While[line=!=EndOfFile, + line=Read[strm]; + (*Do something*) + ]]; +Close[strm]; diff --git a/Task/Read-a-file-line-by-line/Maxima/read-a-file-line-by-line.maxima b/Task/Read-a-file-line-by-line/Maxima/read-a-file-line-by-line.maxima new file mode 100644 index 0000000000..1153dc1977 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Maxima/read-a-file-line-by-line.maxima @@ -0,0 +1,8 @@ +/* Read a file and return a list of all lines */ + +readfile(name) := block( + [v: [ ], f: openr(name), line], + while stringp(line: readline(f)) do v: endcons(line, v), + close(f), + v +)$ diff --git a/Task/Read-a-file-line-by-line/NetRexx/read-a-file-line-by-line-1.netrexx b/Task/Read-a-file-line-by-line/NetRexx/read-a-file-line-by-line-1.netrexx new file mode 100644 index 0000000000..81cbaab3f6 --- /dev/null +++ b/Task/Read-a-file-line-by-line/NetRexx/read-a-file-line-by-line-1.netrexx @@ -0,0 +1,31 @@ +/* NetRexx */ +options replace format comments java crossref symbols nobinary + +parse arg inFileName . + +if inFileName = '' | inFileName = '.' then inFileName = './data/dwarfs.json' +lines = scanFile(inFileName) +loop l_ = 1 to lines[0] + say l_.right(4)':' lines[l_] + end l_ + +return + +-- Read a file and return contents as a Rexx indexed string +method scanFile(inFileName) public static returns Rexx + + fileLines = '' + do + inFile = File(inFileName) + inFileScanner = Scanner(inFile) + loop l_ = 1 while inFileScanner.hasNext() + fileLines[0] = l_ + fileLines[l_] = inFileScanner.nextLine() + end l_ + inFileScanner.close() + + catch ex = FileNotFoundException + ex.printStackTrace + end + + return fileLines diff --git a/Task/Read-a-file-line-by-line/NetRexx/read-a-file-line-by-line-2.netrexx b/Task/Read-a-file-line-by-line/NetRexx/read-a-file-line-by-line-2.netrexx new file mode 100644 index 0000000000..262b904ca0 --- /dev/null +++ b/Task/Read-a-file-line-by-line/NetRexx/read-a-file-line-by-line-2.netrexx @@ -0,0 +1,46 @@ +/* NetRexx */ +options replace format comments java crossref symbols nobinary + +parse arg inFileName . + +if inFileName = '' | inFileName = '.' then inFileName = './data/dwarfs.json' +lines = readFile(inFileName) +loop l_ = 1 to lines[0] + say l_.right(4)':' lines[l_] + end l_ + +return + +-- Read a file and return contents as a Rexx indexed string +method readFile(inFileName) public static returns Rexx + + fileLines = '' + inLine = String null + inFileBR = BufferedReader null + + do + inFile = File(inFileName) + inFileBR = BufferedReader(FileReader(inFile)) + loop l_ = 1 until inline = null + inLine = inFileBR.readLine() + if inline \= null then do + fileLines[0] = l_ + fileLines[l_] = inLine + end + end l_ + + catch exFNF = FileNotFoundException + exFNF.printStackTrace + catch exIO = IOException + exIO.printStackTrace + finally + if inFileBR \= null then do + do + inFileBR.close() + catch ex = IOException + ex.printStackTrace + end + end + end + + return fileLines diff --git a/Task/Read-a-file-line-by-line/NewLISP/read-a-file-line-by-line.newlisp b/Task/Read-a-file-line-by-line/NewLISP/read-a-file-line-by-line.newlisp new file mode 100644 index 0000000000..e28066ad38 --- /dev/null +++ b/Task/Read-a-file-line-by-line/NewLISP/read-a-file-line-by-line.newlisp @@ -0,0 +1,4 @@ +(set 'in-file (open "filename" "read")) +(while (read-line in-file) + (write-line)) +(close in-file) diff --git a/Task/Read-a-file-line-by-line/OCaml/read-a-file-line-by-line.ocaml b/Task/Read-a-file-line-by-line/OCaml/read-a-file-line-by-line.ocaml new file mode 100644 index 0000000000..ff0602a5e2 --- /dev/null +++ b/Task/Read-a-file-line-by-line/OCaml/read-a-file-line-by-line.ocaml @@ -0,0 +1,9 @@ +let () = + let ic = open_in "input.txt" in + try + while true do + let line = input_line ic in + print_endline line + done + with End_of_file -> + close_in ic diff --git a/Task/Read-a-file-line-by-line/Objeck/read-a-file-line-by-line.objeck b/Task/Read-a-file-line-by-line/Objeck/read-a-file-line-by-line.objeck new file mode 100644 index 0000000000..2b7134f3bd --- /dev/null +++ b/Task/Read-a-file-line-by-line/Objeck/read-a-file-line-by-line.objeck @@ -0,0 +1,15 @@ +bundle Default { + class ReadFile { + function : Main(args : String[]) ~ Nil { + f := IO.FileReader->New("in.txt"); + if(f->IsOpen()) { + string := f->ReadString(); + while(f->IsEOF() = false) { + string->PrintLine(); + string := f->ReadString(); + }; + f->Close(); + }; + } + } +} diff --git a/Task/Read-a-file-line-by-line/Objective-C/read-a-file-line-by-line-1.m b/Task/Read-a-file-line-by-line/Objective-C/read-a-file-line-by-line-1.m new file mode 100644 index 0000000000..5f2bb88120 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Objective-C/read-a-file-line-by-line-1.m @@ -0,0 +1,4 @@ +NSString *path = [NSString stringWithString:@"/usr/share/dict/words"]; +NSError *error = nil; +NSString *words = [[NSString alloc] initWithContentsOfFile:path + encoding:NSUTF8StringEncoding error:&error]; diff --git a/Task/Read-a-file-line-by-line/Objective-C/read-a-file-line-by-line-2.m b/Task/Read-a-file-line-by-line/Objective-C/read-a-file-line-by-line-2.m new file mode 100644 index 0000000000..d80482887c --- /dev/null +++ b/Task/Read-a-file-line-by-line/Objective-C/read-a-file-line-by-line-2.m @@ -0,0 +1 @@ +NSArray* lines = [words componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]]; diff --git a/Task/Read-a-file-line-by-line/OxygenBasic/read-a-file-line-by-line.oxy b/Task/Read-a-file-line-by-line/OxygenBasic/read-a-file-line-by-line.oxy new file mode 100644 index 0000000000..77a82c45ac --- /dev/null +++ b/Task/Read-a-file-line-by-line/OxygenBasic/read-a-file-line-by-line.oxy @@ -0,0 +1,32 @@ +function getline(string s, sys *i, *el) as string + sys e + e=instr i,s,chr(el) + if e=0 then + el=10 + e=instr i,s,chr(el) 'files not using chr 13 + end if + if e=0 then e=len s + e++ + if el=13 then + if asc(s,e)=10 then e++ 'crlf + end if + function = mid s,i,e-i + i=e +end function + +'===== +'TEST: +'===== + +s=getfile "t.txt" +i=1 +wr="" +c=0 +el=13 +do + wr = getline s,i,el + if wr="" then exit do + 'print wr + c++ +end do +print "Line count " c diff --git a/Task/Read-a-file-line-by-line/PARI-GP/read-a-file-line-by-line.pari b/Task/Read-a-file-line-by-line/PARI-GP/read-a-file-line-by-line.pari new file mode 100644 index 0000000000..d0627754b9 --- /dev/null +++ b/Task/Read-a-file-line-by-line/PARI-GP/read-a-file-line-by-line.pari @@ -0,0 +1,7 @@ +FILE *f = fopen(name, "r"); +if (!f) { + pari_err(openfiler, "input", name); +} +while(fgets(line, MAX_LINELEN, f) != NULL) { + // ... +} diff --git a/Task/Read-a-file-line-by-line/PHP/read-a-file-line-by-line.php b/Task/Read-a-file-line-by-line/PHP/read-a-file-line-by-line.php new file mode 100644 index 0000000000..91cfd0210d --- /dev/null +++ b/Task/Read-a-file-line-by-line/PHP/read-a-file-line-by-line.php @@ -0,0 +1,6 @@ +) { # each line is stored in $_, with terminating newline + chomp; # chomp, short for chomp($_), removes the terminating newline + process($_); +} +close(FOO); diff --git a/Task/Read-a-file-line-by-line/Perl/read-a-file-line-by-line-2.pl b/Task/Read-a-file-line-by-line/Perl/read-a-file-line-by-line-2.pl new file mode 100644 index 0000000000..d5ca26a67b --- /dev/null +++ b/Task/Read-a-file-line-by-line/Perl/read-a-file-line-by-line-2.pl @@ -0,0 +1,6 @@ +open(FOO, '<', 'foobar.txt') or die $!; +while (my $line = ) { + chomp($line); + process($line); +} +close(FOO); diff --git a/Task/Read-a-file-line-by-line/Perl/read-a-file-line-by-line-3.pl b/Task/Read-a-file-line-by-line/Perl/read-a-file-line-by-line-3.pl new file mode 100644 index 0000000000..b74c354302 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Perl/read-a-file-line-by-line-3.pl @@ -0,0 +1,4 @@ +while (<>) { + chomp; + process($_); +} diff --git a/Task/Read-a-file-line-by-line/PicoLisp/read-a-file-line-by-line.l b/Task/Read-a-file-line-by-line/PicoLisp/read-a-file-line-by-line.l new file mode 100644 index 0000000000..1879628114 --- /dev/null +++ b/Task/Read-a-file-line-by-line/PicoLisp/read-a-file-line-by-line.l @@ -0,0 +1,3 @@ +(in "foobar.txt" + (while (line) + (process @) ) ) diff --git a/Task/Read-a-file-line-by-line/PureBasic/read-a-file-line-by-line.purebasic b/Task/Read-a-file-line-by-line/PureBasic/read-a-file-line-by-line.purebasic new file mode 100644 index 0000000000..a6d70e1513 --- /dev/null +++ b/Task/Read-a-file-line-by-line/PureBasic/read-a-file-line-by-line.purebasic @@ -0,0 +1,9 @@ +FileName$ = OpenFileRequester("","foo.txt","*.txt",0) + +If OpenFile(0, FileName$) + While Not Eof(0) + line$ = ReadString(0) + DoSomethingWithTheLine(Line) + Wend + CloseFile(0) +EndIf diff --git a/Task/Read-a-file-line-by-line/Python/read-a-file-line-by-line-1.py b/Task/Read-a-file-line-by-line/Python/read-a-file-line-by-line-1.py new file mode 100644 index 0000000000..90181abba6 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Python/read-a-file-line-by-line-1.py @@ -0,0 +1,3 @@ +with open("foobar.txt") as f: + for line in f: + process(line) diff --git a/Task/Read-a-file-line-by-line/Python/read-a-file-line-by-line-2.py b/Task/Read-a-file-line-by-line/Python/read-a-file-line-by-line-2.py new file mode 100644 index 0000000000..8252947d4d --- /dev/null +++ b/Task/Read-a-file-line-by-line/Python/read-a-file-line-by-line-2.py @@ -0,0 +1,3 @@ +import fileinput +for line in fileinput.input(): + process(line) diff --git a/Task/Read-a-file-line-by-line/R/read-a-file-line-by-line.r b/Task/Read-a-file-line-by-line/R/read-a-file-line-by-line.r new file mode 100644 index 0000000000..18c9954245 --- /dev/null +++ b/Task/Read-a-file-line-by-line/R/read-a-file-line-by-line.r @@ -0,0 +1,4 @@ +conn <- file("notes.txt", "r") +while(length(line <- readLines(conn, 1)) > 0) { + cat(line, "\n") +} diff --git a/Task/Read-a-file-line-by-line/REXX/read-a-file-line-by-line.rexx b/Task/Read-a-file-line-by-line/REXX/read-a-file-line-by-line.rexx new file mode 100644 index 0000000000..e28b1fa354 --- /dev/null +++ b/Task/Read-a-file-line-by-line/REXX/read-a-file-line-by-line.rexx @@ -0,0 +1,17 @@ +/*REXX program to read and display (with count) a file, one line at a time.*/ + +parse arg fileID . +say 'Displaying file:' fileID + +do linenumber=1 by 1 while lines(fileID)>0 /* loop construct */ + line=linein(fileID) /* read line */ + say 'Line' linenumber':' line /* show line number and line */ + end linenumber /* end loop and confirm which loop */ +say +say 'File' fileID 'has' linenumber-1 'lines.' /*summary.*/ + + +---- +/* Or: the 'known name' short version: */ +file='foobar.txt' +do while lines(file)>0; say linein(file); end diff --git a/Task/Read-a-file-line-by-line/Racket/read-a-file-line-by-line.rkt b/Task/Read-a-file-line-by-line/Racket/read-a-file-line-by-line.rkt new file mode 100644 index 0000000000..70bde965e6 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Racket/read-a-file-line-by-line.rkt @@ -0,0 +1,7 @@ +(define (read-next-line-iter file) + (let ((line (read-line file))) + (unless (eof-object? line) + (display line) + (newline) + (read-next-line-iter file)))) +(call-with-input-file "foobar.txt" read-next-line-iter) diff --git a/Task/Read-a-file-line-by-line/Ruby/read-a-file-line-by-line-1.rb b/Task/Read-a-file-line-by-line/Ruby/read-a-file-line-by-line-1.rb new file mode 100644 index 0000000000..b13cb2d450 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Ruby/read-a-file-line-by-line-1.rb @@ -0,0 +1,4 @@ +IO.foreach "foobar.txt" do |line| + # Do something with line. + puts line +end diff --git a/Task/Read-a-file-line-by-line/Ruby/read-a-file-line-by-line-2.rb b/Task/Read-a-file-line-by-line/Ruby/read-a-file-line-by-line-2.rb new file mode 100644 index 0000000000..84de1f62d7 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Ruby/read-a-file-line-by-line-2.rb @@ -0,0 +1,2 @@ +# File inherits from IO, so File.foreach also works. +File.foreach("foobar.txt") {|line| puts line} diff --git a/Task/Read-a-file-line-by-line/Ruby/read-a-file-line-by-line-3.rb b/Task/Read-a-file-line-by-line/Ruby/read-a-file-line-by-line-3.rb new file mode 100644 index 0000000000..de806f181f --- /dev/null +++ b/Task/Read-a-file-line-by-line/Ruby/read-a-file-line-by-line-3.rb @@ -0,0 +1,4 @@ +# IO.foreach and File.foreach can also read a subprocess. +IO.foreach "| grep afs3 /etc/services" do |line| + puts line +end diff --git a/Task/Read-a-file-line-by-line/Ruby/read-a-file-line-by-line-4.rb b/Task/Read-a-file-line-by-line/Ruby/read-a-file-line-by-line-4.rb new file mode 100644 index 0000000000..7d155169f2 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Ruby/read-a-file-line-by-line-4.rb @@ -0,0 +1,4 @@ +filename = "|strange-name.txt" +File.open(filename) do |file| + file.each {|line| puts line} +end diff --git a/Task/Read-a-file-line-by-line/Run-BASIC/read-a-file-line-by-line.run b/Task/Read-a-file-line-by-line/Run-BASIC/read-a-file-line-by-line.run new file mode 100644 index 0000000000..890a07a4b0 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Run-BASIC/read-a-file-line-by-line.run @@ -0,0 +1,6 @@ +open DefaultDir$ + "\public\filetest.txt" for input as #f +while not(eof(#f)) + line input #f, a$ + print a$ +wend +close #f diff --git a/Task/Read-a-file-line-by-line/SNOBOL4/read-a-file-line-by-line.sno b/Task/Read-a-file-line-by-line/SNOBOL4/read-a-file-line-by-line.sno new file mode 100644 index 0000000000..481577a37f --- /dev/null +++ b/Task/Read-a-file-line-by-line/SNOBOL4/read-a-file-line-by-line.sno @@ -0,0 +1,3 @@ + input(.infile,20,"readfrom.txt") :f(end) +rdloop output = infile :s(rdloop) +end diff --git a/Task/Read-a-file-line-by-line/Scala/read-a-file-line-by-line.scala b/Task/Read-a-file-line-by-line/Scala/read-a-file-line-by-line.scala new file mode 100644 index 0000000000..c11e96dd23 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Scala/read-a-file-line-by-line.scala @@ -0,0 +1,2 @@ +import scala.io._ +Source.fromFile("foobar.txt").getLines.foreach(println) diff --git a/Task/Read-a-file-line-by-line/Scheme/read-a-file-line-by-line.ss b/Task/Read-a-file-line-by-line/Scheme/read-a-file-line-by-line.ss new file mode 100644 index 0000000000..df48d267b7 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Scheme/read-a-file-line-by-line.ss @@ -0,0 +1,7 @@ +; Commented line below should be uncommented to use read-line with Guile +;(use-modules (ice-9 rdelim)) + +(define file (open-input-file "input.txt")) +(do ((line (read-line file) (read-line file))) ((eof-object? line)) + (display line) + (newline)) diff --git a/Task/Read-a-file-line-by-line/Sed/read-a-file-line-by-line-1.sed b/Task/Read-a-file-line-by-line/Sed/read-a-file-line-by-line-1.sed new file mode 100644 index 0000000000..87130467ed --- /dev/null +++ b/Task/Read-a-file-line-by-line/Sed/read-a-file-line-by-line-1.sed @@ -0,0 +1,2 @@ +#!/bin/sed -f +p diff --git a/Task/Read-a-file-line-by-line/Sed/read-a-file-line-by-line-2.sed b/Task/Read-a-file-line-by-line/Sed/read-a-file-line-by-line-2.sed new file mode 100644 index 0000000000..fbdb0e9741 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Sed/read-a-file-line-by-line-2.sed @@ -0,0 +1 @@ +sed p filename diff --git a/Task/Read-a-file-line-by-line/Seed7/read-a-file-line-by-line.seed7 b/Task/Read-a-file-line-by-line/Seed7/read-a-file-line-by-line.seed7 new file mode 100644 index 0000000000..d55a19b066 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Seed7/read-a-file-line-by-line.seed7 @@ -0,0 +1,13 @@ +$ include "seed7_05.s7i"; + +const proc: main is func + local + var file: aFile is STD_NULL; + var string: line is ""; + begin + aFile := open("input.txt", "r"); + while hasNext(aFile) do + readln(aFile, line); + writeln("LINE: " <& line); + end while; + end func; diff --git a/Task/Read-a-file-line-by-line/Smalltalk/read-a-file-line-by-line-1.st b/Task/Read-a-file-line-by-line/Smalltalk/read-a-file-line-by-line-1.st new file mode 100644 index 0000000000..77284ba4c4 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Smalltalk/read-a-file-line-by-line-1.st @@ -0,0 +1 @@ +'foobar.txt' asFilename readingLinesDo:[:eachLine | eachLine printCR] diff --git a/Task/Read-a-file-line-by-line/Smalltalk/read-a-file-line-by-line-2.st b/Task/Read-a-file-line-by-line/Smalltalk/read-a-file-line-by-line-2.st new file mode 100644 index 0000000000..b60cd7ad70 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Smalltalk/read-a-file-line-by-line-2.st @@ -0,0 +1,6 @@ +|s| +s := 'foobar.txt' asFilename readStream. +[ s atEnd ] whileFalse:[ + s nextLine printCR. +]. +s close diff --git a/Task/Read-a-file-line-by-line/Smalltalk/read-a-file-line-by-line-3.st b/Task/Read-a-file-line-by-line/Smalltalk/read-a-file-line-by-line-3.st new file mode 100644 index 0000000000..1be8439d7e --- /dev/null +++ b/Task/Read-a-file-line-by-line/Smalltalk/read-a-file-line-by-line-3.st @@ -0,0 +1 @@ +'foobar.txt' asFilename contents do:[:eachLine | eachLine printCR]. diff --git a/Task/Read-a-file-line-by-line/TUSCRIPT/read-a-file-line-by-line-1.tuscript b/Task/Read-a-file-line-by-line/TUSCRIPT/read-a-file-line-by-line-1.tuscript new file mode 100644 index 0000000000..62b113ac0a --- /dev/null +++ b/Task/Read-a-file-line-by-line/TUSCRIPT/read-a-file-line-by-line-1.tuscript @@ -0,0 +1,11 @@ +$$ MODE TUSCRIPT + +datei="rosetta.txt" +ERROR/STOP OPEN (datei,READ,-std-) + +ACCESS q: READ/RECORDS/UTF8 $datei s,line + LOOP + READ/NEXT/EXIT q + PRINT line + ENDLOOP +ENDACCESS q diff --git a/Task/Read-a-file-line-by-line/TUSCRIPT/read-a-file-line-by-line-2.tuscript b/Task/Read-a-file-line-by-line/TUSCRIPT/read-a-file-line-by-line-2.tuscript new file mode 100644 index 0000000000..b49ed9c504 --- /dev/null +++ b/Task/Read-a-file-line-by-line/TUSCRIPT/read-a-file-line-by-line-2.tuscript @@ -0,0 +1,3 @@ +LOOP line=datei + PRINT line +ENDLOOP diff --git a/Task/Read-a-file-line-by-line/Tcl/read-a-file-line-by-line.tcl b/Task/Read-a-file-line-by-line/Tcl/read-a-file-line-by-line.tcl new file mode 100644 index 0000000000..d6618a10a4 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Tcl/read-a-file-line-by-line.tcl @@ -0,0 +1,6 @@ +set f [open "foobar.txt"] +while {[gets $f line] >= 0} { + # This loops over every line + puts ">>$line<<" +} +close $f diff --git a/Task/Read-a-file-line-by-line/TorqueScript/read-a-file-line-by-line.torquescript b/Task/Read-a-file-line-by-line/TorqueScript/read-a-file-line-by-line.torquescript new file mode 100644 index 0000000000..ffa9692c85 --- /dev/null +++ b/Task/Read-a-file-line-by-line/TorqueScript/read-a-file-line-by-line.torquescript @@ -0,0 +1,22 @@ +//Create a file object + +%f = new fileObject(); + +//Open and read a file + +%f.openForRead("PATH/PATH.txt"); + +while(!%f.isEOF()) +{ + //Read each line from our file + + %line = %f.readLine(); +} + +//Close the file object + +%f.close(); + +//Delete the file object + +%f.delete(); diff --git a/Task/Read-a-file-line-by-line/UNIX-Shell/read-a-file-line-by-line-1.sh b/Task/Read-a-file-line-by-line/UNIX-Shell/read-a-file-line-by-line-1.sh new file mode 100644 index 0000000000..cc624e7f73 --- /dev/null +++ b/Task/Read-a-file-line-by-line/UNIX-Shell/read-a-file-line-by-line-1.sh @@ -0,0 +1,7 @@ +# This while loop repeats for each line of the file. +# This loop is inside a pipeline; many shells will +# run this loop inside a subshell. +cat input.txt | +while IFS= read -r line ; do + printf '%s\n' "$line" +done diff --git a/Task/Read-a-file-line-by-line/UNIX-Shell/read-a-file-line-by-line-2.sh b/Task/Read-a-file-line-by-line/UNIX-Shell/read-a-file-line-by-line-2.sh new file mode 100644 index 0000000000..0685e67e57 --- /dev/null +++ b/Task/Read-a-file-line-by-line/UNIX-Shell/read-a-file-line-by-line-2.sh @@ -0,0 +1,7 @@ +# This loop runs in the current shell, and can read both +# the old standard input (fd 1) and input.txt (fd 3). +exec 3&- diff --git a/Task/Read-a-file-line-by-line/UNIX-Shell/read-a-file-line-by-line-3.sh b/Task/Read-a-file-line-by-line/UNIX-Shell/read-a-file-line-by-line-3.sh new file mode 100644 index 0000000000..28e015e52c --- /dev/null +++ b/Task/Read-a-file-line-by-line/UNIX-Shell/read-a-file-line-by-line-3.sh @@ -0,0 +1,10 @@ +# The old Bourne Shell interprets 'IFS= read' as 'IFS= ; read'. +# It requires extra code to restore the original value of IFS. +exec 3&- diff --git a/Task/Read-a-file-line-by-line/Vala/read-a-file-line-by-line.vala b/Task/Read-a-file-line-by-line/Vala/read-a-file-line-by-line.vala new file mode 100644 index 0000000000..0ddc1b5275 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Vala/read-a-file-line-by-line.vala @@ -0,0 +1,9 @@ +public static void main(){ + var file = FileStream.open("foo.txt", "r"); + + string line = file.read_line(); + while (line != null){ + stdout.printf("%s\n", line); + line = file.read_line(); + } +} diff --git a/Task/Read-a-file-line-by-line/Vedit-macro-language/read-a-file-line-by-line.vedit b/Task/Read-a-file-line-by-line/Vedit-macro-language/read-a-file-line-by-line.vedit new file mode 100644 index 0000000000..2f4cdbb5bb --- /dev/null +++ b/Task/Read-a-file-line-by-line/Vedit-macro-language/read-a-file-line-by-line.vedit @@ -0,0 +1,15 @@ +File_Open("line_by_line.vdm") +#10 = Buf_Num // edit buffer for input file +#11 = Buf_Free // edit buffer for output +#1 = 1 // line number +while (!At_EOF) { + Reg_Copy(20,1) // read one line into text register 20 + Buf_Switch(#11) // switch to output file + Num_Ins(#1++, NOCR) // write line number + Ins_Text(" ") + Reg_Ins(20) // write the line + Buf_Switch(#10) // switch to input file + Line(1) // next line +} +Buf_Close(NOMSG) // close the input file +Buf_Switch(#11) // show the output diff --git a/Task/Read-a-file-line-by-line/Visual-Basic-.NET/read-a-file-line-by-line.visual b/Task/Read-a-file-line-by-line/Visual-Basic-.NET/read-a-file-line-by-line.visual new file mode 100644 index 0000000000..abc74f6e0d --- /dev/null +++ b/Task/Read-a-file-line-by-line/Visual-Basic-.NET/read-a-file-line-by-line.visual @@ -0,0 +1,17 @@ +Imports System.IO + + ' Loop through the lines of a file. + ' Function assumes that the file exists. + Private Sub ReadLines(ByVal FileName As String) + + Dim oReader As New StreamReader(FileName) + Dim sLine As String = Nothing + + While Not oReader.EndOfStream + sLine = oReader.ReadLine() + ' Do something with the line. + End While + + oReader.Close() + + End Sub diff --git a/Task/Read-a-file-line-by-line/Visual-Basic/read-a-file-line-by-line.vb b/Task/Read-a-file-line-by-line/Visual-Basic/read-a-file-line-by-line.vb new file mode 100644 index 0000000000..f382b78ab7 --- /dev/null +++ b/Task/Read-a-file-line-by-line/Visual-Basic/read-a-file-line-by-line.vb @@ -0,0 +1,133 @@ +' Read lines from a file +' +' (c) Copyright 1993 - 2011 Mark Hobley +' +' This code was ported from an application program written in Microsoft Quickbasic +' +' This code can be redistributed or modified under the terms of version 1.2 of +' the GNU Free Documentation Licence as published by the Free Software Foundation. + +Sub readlinesfromafile() + var.filename = "foobar.txt" + var.filebuffersize = ini.inimaxlinelength + Call openfileread + If flg.error = "Y" Then + flg.abort = "Y" + Exit Sub + End If + If flg.exists <> "Y" Then + flg.abort = "Y" + Exit Sub + End If +readfilelabela: + Call readlinefromfile + If flg.error = "Y" Then + flg.abort = "Y" + Call closestream + flg.error = "Y" + Exit Sub + End If + If flg.endoffile <> "Y" Then + ' We have a line from the file + Print message$ + GoTo readfilelabela + End If + ' End of file reached + ' Close the file and exit + Call closestream + Exit Sub +End Sub + +Sub openfileread() + flg.streamopen = "N" + Call checkfileexists + If flg.error = "Y" Then Exit Sub + If flg.exists <> "Y" Then Exit Sub + Call getfreestream + If flg.error = "Y" Then Exit Sub + var.errorsection = "Opening File" + var.errordevice = var.filename + If ini.errortrap = "Y" Then + On Local Error GoTo openfilereaderror + End If + flg.endoffile = "N" + Open var.filename For Input As #var.stream Len = var.filebuffersize + flg.streamopen = "Y" + Exit Sub +openfilereaderror: + var.errorcode = Err + Call errorhandler + resume '!! +End Sub + +Public Sub checkfileexists() + var.errorsection = "Checking File Exists" + var.errordevice = var.filename + If ini.errortrap = "Y" Then + On Local Error GoTo checkfileexistserror + End If + flg.exists = "N" + If Dir$(var.filename, 0) <> "" Then + flg.exists = "Y" + End If + Exit Sub +checkfileexistserror: + var.errorcode = Err + Call errorhandler +End Sub + +Public Sub getfreestream() + var.errorsection = "Opening Free Data Stream" + var.errordevice = "" + If ini.errortrap = "Y" Then + On Local Error GoTo getfreestreamerror + End If + var.stream = FreeFile + Exit Sub +getfreestreamerror: + var.errorcode = Err + Call errorhandler + resume '!! +End Sub + +Sub closestream() + If ini.errortrap = "Y" Then + On Local Error GoTo closestreamerror + End If + var.errorsection = "Closing Stream" + var.errordevice = "" + flg.resumenext = "Y" + Close #var.stream + If flg.error = "Y" Then + flg.error = "N" + '!! Call unexpectederror + End If + flg.streamopen = "N" + Exit Sub +closestreamerror: + var.errorcode = Err + Call errorhandler + resume next +End Sub + +Public Sub errorhandler() + tmp$ = btrim$(var.errorsection) + tmp2$ = btrim$(var.errordevice) + If tmp2$ <> "" Then + tmp$ = tmp$ + " (" + tmp2$ + ")" + End If + tmp$ = tmp$ + " : " + Str$(var.errorcode) + tmp1% = MsgBox(tmp$, 0, "Error!") + flg.error = "Y" + If flg.resumenext = "Y" Then + flg.resumenext = "N" +' Resume Next + Else + flg.error = "N" +' Resume + End If +End Sub + +Public Function btrim$(arg$) + btrim$ = LTrim$(RTrim$(arg$)) +End Function diff --git a/Task/Read-a-specific-line-from-a-file/0DESCRIPTION b/Task/Read-a-specific-line-from-a-file/0DESCRIPTION new file mode 100644 index 0000000000..0e4fc1bf49 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/0DESCRIPTION @@ -0,0 +1,2 @@ +Some languages have special semantics for obtaining a known line number from a file. +The task is to demonstrate how to obtain the contents of a specific line within a file. For the purpose of this task demonstrate how the contents of the seventh line of a file can be obtained, and store it in a variable or in memory (for potential future use within the program if the code were to become embedded). If the file does not contain seven lines, or the seventh line is empty, or too big to be retrieved, output an appropriate message. If no special semantics are available for obtaining the required line, it is permissible to read line by line. Note that empty lines are considered and should still be counted. Note that for functional languages or languages without variables or storage, it is permissible to output the extracted data to standard output. diff --git a/Task/Read-a-specific-line-from-a-file/AWK/read-a-specific-line-from-a-file.awk b/Task/Read-a-specific-line-from-a-file/AWK/read-a-specific-line-from-a-file.awk new file mode 100644 index 0000000000..154e6aa4a6 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/AWK/read-a-specific-line-from-a-file.awk @@ -0,0 +1,4 @@ +#!/usr/bin/awk -f +#usage: readnthline.awk -v lineno=6 filename +FNR==lineno { storedline=$0; found++ } +END {if(found<1){print "ERROR: Line",lineno,"not found"} diff --git a/Task/Read-a-specific-line-from-a-file/Ada/read-a-specific-line-from-a-file.ada b/Task/Read-a-specific-line-from-a-file/Ada/read-a-specific-line-from-a-file.ada new file mode 100644 index 0000000000..1130889680 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/Ada/read-a-specific-line-from-a-file.ada @@ -0,0 +1,54 @@ +with Ada.Command_Line, + Ada.Text_IO; + +procedure Rosetta_Read is + use Ada.Command_Line, Ada.Text_IO; + + Source : File_Type; +begin + + if Argument_Count /= 1 then + Put_Line (File => Standard_Error, + Item => "Usage: " & Command_Name & " file_name"); + Set_Exit_Status (Failure); + return; + end if; + + declare + File_Name : String renames Argument (Number => 1); + begin + Open (File => Source, + Mode => In_File, + Name => File_Name); + exception + when others => + Put_Line (File => Standard_Error, + Item => "Can not open '" & File_Name & "'."); + Set_Exit_Status (Failure); + return; + end; + + Set_Line (File => Source, + To => 7); + + declare + Line_7 : constant String := Get_Line (File => Source); + begin + if Line_7'Length = 0 then + Put_Line ("Line 7 is empty."); + else + Put_Line (Line_7); + end if; + end; +exception + when End_Error => + Put_Line (File => Standard_Error, + Item => "The file contains fewer than 7 lines."); + Set_Exit_Status (Failure); + return; + when Storage_Error => + Put_Line (File => Standard_Error, + Item => "Line 7 is too long to load."); + Set_Exit_Status (Failure); + return; +end Rosetta_Read; diff --git a/Task/Read-a-specific-line-from-a-file/Aime/read-a-specific-line-from-a-file.aime b/Task/Read-a-specific-line-from-a-file/Aime/read-a-specific-line-from-a-file.aime new file mode 100644 index 0000000000..2e121586fe --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/Aime/read-a-specific-line-from-a-file.aime @@ -0,0 +1,30 @@ +void +read_line(text &line, text path, integer n) +{ + file f; + + f_affix(f, path); + + while (n) { + n -= 1; + f_slip(f); + } + + f_line(f, line); +} + + +integer +main(void) +{ + if (2 < argc()) { + text line; + + read_line(line, argv(1), 6); + + o_text(line); + o_byte('\n'); + } + + return 0; +} diff --git a/Task/Read-a-specific-line-from-a-file/AutoHotkey/read-a-specific-line-from-a-file.ahk b/Task/Read-a-specific-line-from-a-file/AutoHotkey/read-a-specific-line-from-a-file.ahk new file mode 100644 index 0000000000..317270f61c --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/AutoHotkey/read-a-specific-line-from-a-file.ahk @@ -0,0 +1,3 @@ +FileReadLine, OutputVar, filename.txt, 7 +if ErrorLevel + MsgBox, There was an error reading the 7th line of the file diff --git a/Task/Read-a-specific-line-from-a-file/BBC-BASIC/read-a-specific-line-from-a-file.bbc b/Task/Read-a-specific-line-from-a-file/BBC-BASIC/read-a-specific-line-from-a-file.bbc new file mode 100644 index 0000000000..7e59ccf464 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/BBC-BASIC/read-a-specific-line-from-a-file.bbc @@ -0,0 +1,13 @@ + filepath$ = @lib$ + "..\licence.txt" + requiredline% = 7 + + file% = OPENIN(filepath$) + IF file%=0 ERROR 100, "File could not be opened" + FOR i% = 1 TO requiredline% + IF EOF#file% ERROR 100, "File contains too few lines" + INPUT #file%, text$ + NEXT + CLOSE #file% + + IF ASCtext$=10 text$ = MID$(text$,2) + PRINT text$ diff --git a/Task/Read-a-specific-line-from-a-file/C-sharp/read-a-specific-line-from-a-file.cs b/Task/Read-a-specific-line-from-a-file/C-sharp/read-a-specific-line-from-a-file.cs new file mode 100644 index 0000000000..5e69566f82 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/C-sharp/read-a-specific-line-from-a-file.cs @@ -0,0 +1,44 @@ +using System; +using System.IO; + +namespace GetLine +{ + internal class Program + { + private static void Main(string[] args) + { + Console.WriteLine(GetLine(args[0], uint.Parse(args[1]))); + } + + private static string GetLine(string path, uint line) + { + using (var reader = new StreamReader(path)) + { + try + { + for (uint i = 0; i <= line; i++) + { + if (reader.EndOfStream) + return string.Format("There {1} less than {0} line{2} in the file.", line, + ((line == 1) ? "is" : "are"), ((line == 1) ? "" : "s")); + + if (i == line) + return reader.ReadLine(); + + reader.ReadLine(); + } + } + catch (IOException ex) + { + return ex.Message; + } + catch (OutOfMemoryException ex) + { + return ex.Message; + } + } + + throw new Exception("Something bad happened."); + } + } +} diff --git a/Task/Read-a-specific-line-from-a-file/C/read-a-specific-line-from-a-file.c b/Task/Read-a-specific-line-from-a-file/C/read-a-specific-line-from-a-file.c new file mode 100644 index 0000000000..42b299dcfe --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/C/read-a-specific-line-from-a-file.c @@ -0,0 +1,66 @@ +#include +#include +#include +#include +#include +#include + +/* following code assumes all file operations succeed. In practice, + * return codes from open, close, fstat, mmap, munmap all need to be + * checked for error. +*/ +int read_file_line(const char *path, int line_no) +{ + struct stat s; + char *buf; + off_t start = -1, end = -1; + size_t i; + int ln, fd, ret = 1; + + if (line_no == 1) start = 0; + else if (line_no < 1){ + warn("line_no too small"); + return 0; /* line_no starts at 1; less is error */ + } + + line_no--; /* back to zero based, easier */ + + fd = open(path, O_RDONLY); + fstat(fd, &s); + + /* Map the whole file. If the file is huge (up to GBs), OS will swap + * pages in and out, and because search for lines goes sequentially + * and never accesses more than one page at a time, penalty is low. + * If the file is HUGE, such that OS can't find an address space to map + * it, we got a real problem. In practice one would repeatedly map small + * chunks, say 1MB at a time, and find the offsets of the line along the + * way. Although, if file is really so huge, the line itself can't be + * guaranteed small enough to be "stored in memory", so there. + */ + buf = mmap(0, s.st_size, PROT_READ, MAP_PRIVATE, fd, 0); + + /* optional; if the file is large, tell OS to read ahead */ + madvise(buf, s.st_size, MADV_SEQUENTIAL); + + for (i = ln = 0; i < s.st_size && ln <= line_no; i++) { + if (buf[i] != '\n') continue; + + if (++ln == line_no) start = i + 1; + else if (ln == line_no + 1) end = i + 1; + } + + if (start >= s.st_size || start < 0) { + warn("file does not have line %d", line_no + 1); + ret = 0; + } else { + /* do something with the line here, like + write(STDOUT_FILENO, buf + start, end - start); + or copy it out, or something + */ + } + + munmap(buf, s.st_size); + close(fd); + + return ret; +} diff --git a/Task/Read-a-specific-line-from-a-file/Common-Lisp/read-a-specific-line-from-a-file.lisp b/Task/Read-a-specific-line-from-a-file/Common-Lisp/read-a-specific-line-from-a-file.lisp new file mode 100644 index 0000000000..4a193ee596 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/Common-Lisp/read-a-specific-line-from-a-file.lisp @@ -0,0 +1,11 @@ +(defun read-nth-line (file n &aux (line-number 0)) + "Read the nth line from a text file. The first line has the number 1" + (assert (> n 0) (n)) + (with-open-file (stream file) + (loop for line = (read-line stream nil nil) + if (and (null line) (< line-number n)) + do (error "file ~a is too short, just ~a, not ~a lines long" + file line-number n) + do (incf line-number) + if (and line (= line-number n)) + do (return line)))) diff --git a/Task/Read-a-specific-line-from-a-file/D/read-a-specific-line-from-a-file.d b/Task/Read-a-specific-line-from-a-file/D/read-a-specific-line-from-a-file.d new file mode 100644 index 0000000000..97c4e6aa28 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/D/read-a-specific-line-from-a-file.d @@ -0,0 +1,22 @@ +import std.stdio; + +void main() { + int countLines; + char[] ln; + auto f = File("linenumber.d", "r"); + foreach (char[] line; f.byLine()) { + countLines++; + if (countLines == 7) { + ln = line; + break; + } + } + switch(countLines) { + case 0 : writeln("the file has zero length"); + break; + case 7 : writeln("line 7: ", (ln.length ? ln : "empty")); + break; + default : + writefln("the file only contains %d lines", countLines); + } +} diff --git a/Task/Read-a-specific-line-from-a-file/Go/read-a-specific-line-from-a-file.go b/Task/Read-a-specific-line-from-a-file/Go/read-a-specific-line-from-a-file.go new file mode 100644 index 0000000000..69cd4a46f1 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/Go/read-a-specific-line-from-a-file.go @@ -0,0 +1,69 @@ +package main + +import ( + "bufio" + "errors" + "fmt" + "io" + "os" +) + +func main() { + if line, err := rsl("input.txt", 7); err == nil { + fmt.Println("7th line:") + fmt.Println(line) + } else { + fmt.Println(err) + } +} + +func rsl(fn string, n int) (r string, err error) { + if n < 1 { + return "", errors.New(fmt.Sprintf("Invalid request: line %d", n)) + } + f, err := os.Open(fn) + if err != nil { + return + } + defer f.Close() + bf := bufio.NewReader(f) + var l int + for { + line, isPrefix, err := bf.ReadLine() + if err == io.EOF { + switch l { + case 0: + return "", errors.New("Empty file.") + case 1: + return "", errors.New("Only 1 line.") + default: + return "", errors.New(fmt.Sprintf("Only %d lines", l)) + } + } + if err != nil { + return "", err + } + l++ + if l == n { + r = string(line) + for isPrefix { + line, isPrefix, err = bf.ReadLine() + if err != nil { + return "", err + } + r += string(line) + } + if r == "" { + return "", errors.New(fmt.Sprintf("Line %d empty.", n)) + } + break + } + for isPrefix { + line, isPrefix, err = bf.ReadLine() + if err != nil { + return "", err + } + } + } + return // success +} diff --git a/Task/Read-a-specific-line-from-a-file/Groovy/read-a-specific-line-from-a-file.groovy b/Task/Read-a-specific-line-from-a-file/Groovy/read-a-specific-line-from-a-file.groovy new file mode 100644 index 0000000000..497c77618c --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/Groovy/read-a-specific-line-from-a-file.groovy @@ -0,0 +1,7 @@ +def line = null +new File("lines.txt").eachLine { currentLine, lineNumber -> + if (lineNumber == 7) { + line = currentLine + } +} +println "Line 7 = $line" diff --git a/Task/Read-a-specific-line-from-a-file/Haskell/read-a-specific-line-from-a-file.hs b/Task/Read-a-specific-line-from-a-file/Haskell/read-a-specific-line-from-a-file.hs new file mode 100644 index 0000000000..c6c8294565 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/Haskell/read-a-specific-line-from-a-file.hs @@ -0,0 +1,6 @@ +main :: IO () +main = do contents <- readFile filename + case drop 6 $ lines contents of + [] -> error "File has less than seven lines" + l:_ -> putStrLn l + where filename = "testfile" diff --git a/Task/Read-a-specific-line-from-a-file/Icon/read-a-specific-line-from-a-file.icon b/Task/Read-a-specific-line-from-a-file/Icon/read-a-specific-line-from-a-file.icon new file mode 100644 index 0000000000..08aae12d23 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/Icon/read-a-specific-line-from-a-file.icon @@ -0,0 +1,10 @@ +procedure main() +write(readline("foo.bar.txt",7)|"failed") +end + +procedure readline(f,n) # return n'th line of file f +f := open(\f,"r") | fail # open file +every i := n & line := |read() \ n do i -:= 1 # <== here +close(f) +if i = 0 then return line +end diff --git a/Task/Read-a-specific-line-from-a-file/J/read-a-specific-line-from-a-file-1.j b/Task/Read-a-specific-line-from-a-file/J/read-a-specific-line-from-a-file-1.j new file mode 100644 index 0000000000..f066bcb9de --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/J/read-a-specific-line-from-a-file-1.j @@ -0,0 +1,3 @@ +readLine=: 4 :0 + (x-1) {:: <;.2 ] 1!:1 boxxopen y +) diff --git a/Task/Read-a-specific-line-from-a-file/J/read-a-specific-line-from-a-file-2.j b/Task/Read-a-specific-line-from-a-file/J/read-a-specific-line-from-a-file-2.j new file mode 100644 index 0000000000..109b041437 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/J/read-a-specific-line-from-a-file-2.j @@ -0,0 +1 @@ +$ cal 2011 > cal.txt diff --git a/Task/Read-a-specific-line-from-a-file/J/read-a-specific-line-from-a-file-3.j b/Task/Read-a-specific-line-from-a-file/J/read-a-specific-line-from-a-file-3.j new file mode 100644 index 0000000000..8193103bcf --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/J/read-a-specific-line-from-a-file-3.j @@ -0,0 +1,2 @@ + 7 readLine 'cal.txt' + 9 10 11 12 13 14 15 13 14 15 16 17 18 19 13 14 15 16 17 18 19 diff --git a/Task/Read-a-specific-line-from-a-file/J/read-a-specific-line-from-a-file-4.j b/Task/Read-a-specific-line-from-a-file/J/read-a-specific-line-from-a-file-4.j new file mode 100644 index 0000000000..d1b8481362 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/J/read-a-specific-line-from-a-file-4.j @@ -0,0 +1,2 @@ +require 'files' NB. required for versions before J701 +readLineT=: <:@[ {:: 'b'&freads@] diff --git a/Task/Read-a-specific-line-from-a-file/Java/read-a-specific-line-from-a-file.java b/Task/Read-a-specific-line-from-a-file/Java/read-a-specific-line-from-a-file.java new file mode 100644 index 0000000000..9097cf8f25 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/Java/read-a-specific-line-from-a-file.java @@ -0,0 +1,33 @@ +package linenbr7; + +import java.io.*; + +public class LineNbr7 { + + public static void main(String[] args) throws Exception { + File f = new File(args[0]); + if (!f.isFile() || !f.canRead()) + throw new IOException("can't read " + args[0]); + + BufferedReader br = new BufferedReader(new FileReader(f)); + try (LineNumberReader lnr = new LineNumberReader(br)) { + String line = null; + int lnum = 0; + while ((line = lnr.readLine()) != null + && (lnum = lnr.getLineNumber()) < 7) { + } + + switch (lnum) { + case 0: + System.out.println("the file has zero length"); + break; + case 7: + boolean empty = "".equals(line); + System.out.println("line 7: " + (empty ? "empty" : line)); + break; + default: + System.out.println("the file has only " + lnum + " line(s)"); + } + } + } +} diff --git a/Task/Read-a-specific-line-from-a-file/Liberty-BASIC/read-a-specific-line-from-a-file.liberty b/Task/Read-a-specific-line-from-a-file/Liberty-BASIC/read-a-specific-line-from-a-file.liberty new file mode 100644 index 0000000000..edbae883f4 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/Liberty-BASIC/read-a-specific-line-from-a-file.liberty @@ -0,0 +1,11 @@ +fileName$ ="F:\sample.txt" +requiredLine =7 + +open fileName$ for input as #i + f$ =input$( #i, lof( #i)) +close #i + +line7$ =word$( f$, 7, chr$( 13)) +if line7$ =chr$( 13) +chr$( 10) or line7$ ="" then notice "Empty line! ( or file has fewer lines)." + +print line7$ diff --git a/Task/Read-a-specific-line-from-a-file/MATLAB/read-a-specific-line-from-a-file.m b/Task/Read-a-specific-line-from-a-file/MATLAB/read-a-specific-line-from-a-file.m new file mode 100644 index 0000000000..ac10678cf2 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/MATLAB/read-a-specific-line-from-a-file.m @@ -0,0 +1,18 @@ + eln = 7; % extract line number 7 + line = ''; + fid = fopen('foobar.txt','r'); + if (fid < 0) + printf('Error:could not open file\n') + else + n = 0; + while ~feof(fid), + n = n + 1; + if (n ~= eln), + fgetl(fid); + else + line = fgetl(fid); + end + end; + fclose(fid); + end; + printf('line %i: %s\n',eln,line); diff --git a/Task/Read-a-specific-line-from-a-file/Mathematica/read-a-specific-line-from-a-file.math b/Task/Read-a-specific-line-from-a-file/Mathematica/read-a-specific-line-from-a-file.math new file mode 100644 index 0000000000..d5152b31ac --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/Mathematica/read-a-specific-line-from-a-file.math @@ -0,0 +1 @@ + If[# != EndOfFile , Print[#]]& @ ReadList["file", String, 7] diff --git a/Task/Read-a-specific-line-from-a-file/NetRexx/read-a-specific-line-from-a-file.netrexx b/Task/Read-a-specific-line-from-a-file/NetRexx/read-a-specific-line-from-a-file.netrexx new file mode 100644 index 0000000000..93e669cf65 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/NetRexx/read-a-specific-line-from-a-file.netrexx @@ -0,0 +1,52 @@ +/* NetRexx */ +options replace format comments java crossref symbols nobinary + +parse arg inFileName lineNr . + +if inFileName = '' | inFileName = '.' then inFileName = './data/input.txt' +if lineNr = '' | lineNr = '.' then lineNr = 7 + +do + lineTxt = readLine(inFileName, lineNr) + say ''lineTxt'' +catch ex = Exception + ex.printStackTrace() +end + +return + +-- ============================================================================= +-- NetRexx/Java programs don't have a special mechanism to seek to a specified line number +-- the simple solution is to iterate through file. (Costly for very large files) +method readLine(inFileName, lineNr) public static signals IOException, FileNotFoundException + + lineReader = LineNumberReader(FileReader(File(inFileName))) + notFound = isTrue + lineTxt = '' + loop label reading forever + line = lineReader.readLine() + select + when lineReader.getLineNumber() = lineNr then do + lineTxt = line + notFound = isFalse + leave reading -- terminate I/O loop + end + when line = null then do + leave reading -- terminate I/O loop + end + otherwise nop + end + finally + lineReader.close() + end reading + + if notFound then signal RuntimeException('File' inFileName 'does not contain line' lineNr.right(5)) + + return lineTxt + +-- ============================================================================= +method isTrue() public static returns boolean + return 1 == 1 +-- ============================================================================= +method isFalse() public static returns boolean + return \(1 == 1) diff --git a/Task/Read-a-specific-line-from-a-file/OCaml/read-a-specific-line-from-a-file.ocaml b/Task/Read-a-specific-line-from-a-file/OCaml/read-a-specific-line-from-a-file.ocaml new file mode 100644 index 0000000000..0b3ce87c76 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/OCaml/read-a-specific-line-from-a-file.ocaml @@ -0,0 +1,21 @@ +let input_line_opt ic = + try Some (input_line ic) + with End_of_file -> None + +let nth_line n filename = + let ic = open_in filename in + let rec aux i = + match input_line_opt ic with + | Some line -> + if i = n then begin + close_in ic; + (line) + end else aux (succ i) + | None -> + close_in ic; + failwith "end of file reached" + in + aux 1 + +let () = + print_endline (nth_line 7 Sys.argv.(1)) diff --git a/Task/Read-a-specific-line-from-a-file/PL-I/read-a-specific-line-from-a-file.pli b/Task/Read-a-specific-line-from-a-file/PL-I/read-a-specific-line-from-a-file.pli new file mode 100644 index 0000000000..174389531f --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/PL-I/read-a-specific-line-from-a-file.pli @@ -0,0 +1,12 @@ +declare text character (1000) varying, line_no fixed; + +get (line_no); +on endfile (f) begin; + put skip list ('the specified line does not exist'); + go to next; +end; + +get file (f) edit ((text do i = 1 to line_no)) (L); + +put skip list (text); +next: ; diff --git a/Task/Read-a-specific-line-from-a-file/Pascal/read-a-specific-line-from-a-file.pascal b/Task/Read-a-specific-line-from-a-file/Pascal/read-a-specific-line-from-a-file.pascal new file mode 100644 index 0000000000..e4c1665fbb --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/Pascal/read-a-specific-line-from-a-file.pascal @@ -0,0 +1,38 @@ +Program FileTruncate; + +uses + SysUtils; + +const + filename = 'test'; + position = 7; + +var + myfile: text; + line: string; + counter: integer; + +begin + if not FileExists(filename) then + begin + writeln('Error: File does not exist.'); + exit; + end; + + Assign(myfile, filename); + Reset(myfile); + counter := 0; + Repeat + if eof(myfile) then + begin + writeln('Error: The file "', filename, '" is too short. Cannot read line ', position); + Close(myfile); + exit; + end; + inc(counter); + readln(myfile); + until counter = position - 1; + readln(myfile, line); + Close(myfile); + writeln(line); +end. diff --git a/Task/Read-a-specific-line-from-a-file/Perl-6/read-a-specific-line-from-a-file.pl6 b/Task/Read-a-specific-line-from-a-file/Perl-6/read-a-specific-line-from-a-file.pl6 new file mode 100644 index 0000000000..d4e65457d5 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/Perl-6/read-a-specific-line-from-a-file.pl6 @@ -0,0 +1 @@ +say lines[6] // die "Short file"; diff --git a/Task/Read-a-specific-line-from-a-file/Perl/read-a-specific-line-from-a-file.pl b/Task/Read-a-specific-line-from-a-file/Perl/read-a-specific-line-from-a-file.pl new file mode 100644 index 0000000000..f1cca9eb56 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/Perl/read-a-specific-line-from-a-file.pl @@ -0,0 +1,4 @@ +#!/usr/bin/perl -s +# invoke as -n=7 [input] +while (<>) { $. == $n and print, exit } +die "file too short\n"; diff --git a/Task/Read-a-specific-line-from-a-file/PicoLisp/read-a-specific-line-from-a-file.l b/Task/Read-a-specific-line-from-a-file/PicoLisp/read-a-specific-line-from-a-file.l new file mode 100644 index 0000000000..5dda39f61a --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/PicoLisp/read-a-specific-line-from-a-file.l @@ -0,0 +1,3 @@ +(in "file.txt" + (do 6 (line)) + (or (line) (quit "No 7 lines")) ) diff --git a/Task/Read-a-specific-line-from-a-file/PureBasic/read-a-specific-line-from-a-file.purebasic b/Task/Read-a-specific-line-from-a-file/PureBasic/read-a-specific-line-from-a-file.purebasic new file mode 100644 index 0000000000..d08aa56ccc --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/PureBasic/read-a-specific-line-from-a-file.purebasic @@ -0,0 +1,32 @@ +Structure lineLastRead + lineRead.i + line.s +EndStructure + +Procedure readNthLine(file, n, *results.lineLastRead) + *results\lineRead = 0 + While *results\lineRead < n And Not Eof(file) + *results\line = ReadString(file) + *results\lineRead + 1 + Wend + + If *results\lineRead = n + ProcedureReturn 1 + EndIf +EndProcedure + +Define filename.s = OpenFileRequester("Choose file to read a line from", "*.*", "All files (*.*)|*.*", 0) +If filename + Define file = ReadFile(#PB_Any, filename) + If file + Define fileReadResults.lineLastRead, lineToRead = 7 + If readNthLine(file, lineToRead, fileReadResults) + MessageRequester("Results", fileReadResults\line) + Else + MessageRequester("Error", "There are less than " + Str(lineToRead) + " lines in file.") + EndIf + CloseFile(file) + Else + MessageRequester("Error", "Couldn't open file " + filename + ".") + EndIf +EndIf diff --git a/Task/Read-a-specific-line-from-a-file/Python/read-a-specific-line-from-a-file.py b/Task/Read-a-specific-line-from-a-file/Python/read-a-specific-line-from-a-file.py new file mode 100644 index 0000000000..1f6be62c40 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/Python/read-a-specific-line-from-a-file.py @@ -0,0 +1,6 @@ +from itertools import islice + +with open('xxx.txt') as f: + linelist = list(islice(f, 7, 8)) + assert linelist != [], 'Not 7 lines in file' + line = linelist[0] diff --git a/Task/Read-a-specific-line-from-a-file/R/read-a-specific-line-from-a-file.r b/Task/Read-a-specific-line-from-a-file/R/read-a-specific-line-from-a-file.r new file mode 100644 index 0000000000..41341b8f27 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/R/read-a-specific-line-from-a-file.r @@ -0,0 +1,4 @@ +> seven <- scan('hw.txt', '', skip = 6, nlines = 1, sep = '\n') # too short +Read 0 items +> seven <- scan('Incoming/quotes.txt', '', skip = 6, nlines = 1, sep = '\n') +Read 1 item diff --git a/Task/Read-a-specific-line-from-a-file/REXX/read-a-specific-line-from-a-file.rexx b/Task/Read-a-specific-line-from-a-file/REXX/read-a-specific-line-from-a-file.rexx new file mode 100644 index 0000000000..6cda11a740 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/REXX/read-a-specific-line-from-a-file.rexx @@ -0,0 +1,26 @@ +/*REXX program to read a specific line from a file. */ +parse arg fileId n . /*get the user args: fileid n */ +if fileID=='' then fileId='JUNK.TXT' /*assume the default: JUNK.TXT */ +if n=='' then n=7 /*assume the default (n=7) */ +L=lines(fileid) /*first, see if the file exists. */ +if L ==0 then do; say 'error, fileID not found:' fileId; exit; end +if n\==1 then call linein fileId,n-1 /*second, read previous rec. to N*/ +L=lines(fileid) /* L = # lines left in the file.*/ +q=linein(fileId,n) /*read the Nth line, store in Q.*/ +qL=length(q) /*get the length of the record. */ + select + when L==0 & qL==0 then say 'line' n "not found." + when L==1 & qL==0 then say 'line' n "has a zero length." + otherwise say 'file' fileId "record" n '=' q + end /*select*/ + /*stick a fork in it, we're done.*/ +/*┌────────────────────────────────────────────────────────────────────┐ + │ ─── Normally, we could just use: ─── │ + │ │ + │ q=linein(fileId,n) /*read a specific record num. */ │ + │ │ + │── but LINEIN will just return a null when a record isn't found or│ + │ when the fileID doesn't exist, or N is beyond the end-of-file.│ + │ │ + │── In the case of sparse files, the record may not exist (be null).│ + └────────────────────────────────────────────────────────────────────┘*/ diff --git a/Task/Read-a-specific-line-from-a-file/Ruby/read-a-specific-line-from-a-file.rb b/Task/Read-a-specific-line-from-a-file/Ruby/read-a-specific-line-from-a-file.rb new file mode 100644 index 0000000000..30d2ac1038 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/Ruby/read-a-specific-line-from-a-file.rb @@ -0,0 +1,15 @@ +def getNthLine(filename, n) + line="" + File.open(filename) do |f| + n.times do |nr| + line = f.gets + if line.nil? + puts "file #{filename} does not have #{n} lines, only #{nr}" + break + end + end + end + line +end + +puts getNthLine("/etc/passwd", 7) diff --git a/Task/Read-a-specific-line-from-a-file/Run-BASIC/read-a-specific-line-from-a-file.run b/Task/Read-a-specific-line-from-a-file/Run-BASIC/read-a-specific-line-from-a-file.run new file mode 100644 index 0000000000..f988b4df60 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/Run-BASIC/read-a-specific-line-from-a-file.run @@ -0,0 +1,10 @@ +fileName$ = "f:\sample.txt" +requiredLine = 7 +open fileName$ for input as #f + +for i = 1 to requiredLine + if not(eof(#f)) then line input #f, a$ +next i +close #f +print a$ +end diff --git a/Task/Read-a-specific-line-from-a-file/Scala/read-a-specific-line-from-a-file-1.scala b/Task/Read-a-specific-line-from-a-file/Scala/read-a-specific-line-from-a-file-1.scala new file mode 100644 index 0000000000..4dcb2234e9 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/Scala/read-a-specific-line-from-a-file-1.scala @@ -0,0 +1,2 @@ +val lines = io.Source.fromFile("input.txt").getLines +val seventhLine = lines drop(6) next diff --git a/Task/Read-a-specific-line-from-a-file/Scala/read-a-specific-line-from-a-file-2.scala b/Task/Read-a-specific-line-from-a-file/Scala/read-a-specific-line-from-a-file-2.scala new file mode 100644 index 0000000000..3309490b95 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/Scala/read-a-specific-line-from-a-file-2.scala @@ -0,0 +1,13 @@ +var lines: Iterator[String] = _ +try { + lines = io.Source.fromFile("input.txt").getLines drop(6) +} catch { + case exc: java.io.IOException => + println("File not found") +} +var seventhLine: String = _ +if (lines != null) { + if (lines.isEmpty) println("too few lines in file") + else seventhLine = lines next +} +if ("" == seventhLine) println("line is empty") diff --git a/Task/Read-a-specific-line-from-a-file/Scala/read-a-specific-line-from-a-file-3.scala b/Task/Read-a-specific-line-from-a-file/Scala/read-a-specific-line-from-a-file-3.scala new file mode 100644 index 0000000000..faf9a5209d --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/Scala/read-a-specific-line-from-a-file-3.scala @@ -0,0 +1,6 @@ +val file = try Left(io.Source.fromFile("input.txt")) catch { + case exc => Right(exc.getMessage) +} +val seventhLine = (for(f <- file.left; + line <- f.getLines.toStream.drop(6).headOption.toLeft("too few lines").left) yield + if (line == "") Right("line is empty") else Left(line)).joinLeft diff --git a/Task/Read-a-specific-line-from-a-file/Seed7/read-a-specific-line-from-a-file.seed7 b/Task/Read-a-specific-line-from-a-file/Seed7/read-a-specific-line-from-a-file.seed7 new file mode 100644 index 0000000000..758a647f0b --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/Seed7/read-a-specific-line-from-a-file.seed7 @@ -0,0 +1,32 @@ +$ include "seed7_05.s7i"; + +const func string: getLine (inout file: aFile, in var integer: lineNum) is func + result + var string: line is ""; + begin + while lineNum > 1 and hasNext(aFile) do + readln(aFile); + decr(lineNum); + end while; + line := getln(aFile); + end func; + +const proc: main is func + local + var string: fileName is "input.txt"; + var file: aFile is STD_NULL; + var string: line is ""; + begin + aFile := open(fileName, "r"); + if aFile = STD_NULL then + writeln("Cannot open " <& fileName); + else + line := getLine(aFile, 7); + if eof(aFile) then + writeln("The file does not have 7 lines"); + else + writeln("The 7th line of the file is:"); + writeln(line); + end if; + end if; + end func; diff --git a/Task/Read-a-specific-line-from-a-file/TUSCRIPT/read-a-specific-line-from-a-file.tuscript b/Task/Read-a-specific-line-from-a-file/TUSCRIPT/read-a-specific-line-from-a-file.tuscript new file mode 100644 index 0000000000..8368c485e5 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/TUSCRIPT/read-a-specific-line-from-a-file.tuscript @@ -0,0 +1,17 @@ +$$ MODE TUSCRIPT +file="lines.txt" +ERROR/STOP OPEN (file,READ,-std-) +line2fetch=7 + +--> solution 1 +ACCESS file: READ/RECORDS/UTF8 $file s,line +LOOP n=1,99 +READ/NEXT/EXIT file +IF (n==line2fetch) PRINT line +ENDLOOP +ENDACCESS file + +--> solution 2 +line1to7=FILE (file,#line2fetch) +line=SELECT (line1to7,#line2fetch) +PRINT line diff --git a/Task/Read-a-specific-line-from-a-file/TXR/read-a-specific-line-from-a-file-1.txr b/Task/Read-a-specific-line-from-a-file/TXR/read-a-specific-line-from-a-file-1.txr new file mode 100644 index 0000000000..4468d8b60e --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/TXR/read-a-specific-line-from-a-file-1.txr @@ -0,0 +1,2 @@ +@(skip nil 7) +@line diff --git a/Task/Read-a-specific-line-from-a-file/TXR/read-a-specific-line-from-a-file-2.txr b/Task/Read-a-specific-line-from-a-file/TXR/read-a-specific-line-from-a-file-2.txr new file mode 100644 index 0000000000..8eafcd4a28 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/TXR/read-a-specific-line-from-a-file-2.txr @@ -0,0 +1,4 @@ +@(skip) +@line +@(skip 1 2) +@(eof) diff --git a/Task/Read-a-specific-line-from-a-file/Tcl/read-a-specific-line-from-a-file.tcl b/Task/Read-a-specific-line-from-a-file/Tcl/read-a-specific-line-from-a-file.tcl new file mode 100644 index 0000000000..e609924773 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/Tcl/read-a-specific-line-from-a-file.tcl @@ -0,0 +1,13 @@ +proc getNthLineFromFile {filename n} { + set f [open $filename] + while {[incr n -1] > 0} { + if {[gets $f line] < 0} { + close $f + error "no such line" + } + } + close $f + return $line +} + +puts [getNthLineFromFile example.txt 7] diff --git a/Task/Read-a-specific-line-from-a-file/Vedit-macro-language/read-a-specific-line-from-a-file.vedit b/Task/Read-a-specific-line-from-a-file/Vedit-macro-language/read-a-specific-line-from-a-file.vedit new file mode 100644 index 0000000000..96f5a10daf --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/Vedit-macro-language/read-a-specific-line-from-a-file.vedit @@ -0,0 +1,11 @@ +File_Open("example.txt", BROWSE) +Goto_Line(7) +if (Cur_Line < 7) { + Statline_Message("File contains too few lines") +} else { + if (At_EOL) { + Statline_Message("Empty line") + } + Reg_Copy(10, 1) +} +Buf_Close(NOMSG) diff --git a/Task/Read-a-specific-line-from-a-file/XPL0/read-a-specific-line-from-a-file.xpl0 b/Task/Read-a-specific-line-from-a-file/XPL0/read-a-specific-line-from-a-file.xpl0 new file mode 100644 index 0000000000..da4d500334 --- /dev/null +++ b/Task/Read-a-specific-line-from-a-file/XPL0/read-a-specific-line-from-a-file.xpl0 @@ -0,0 +1,26 @@ +include c:\cxpl\codes; \intrinsic 'code' declarations +def MaxLen = 82; \maximum length of line that can be stored (incl CR+LF) + +func ReadLine(N, L); \Read line N from input file and return it in string L +int N; char L; +int I, C; +[for I:= 1 to N-1 do \skip to start of specified line + repeat C:= ChIn(1); + if C = $1A\EOF\ then + [Text(0, "File only has "); IntOut(0, I); + Text(0, " lines^M^J"); return false]; + until C = $0A\LF\; +I:= 0; +repeat C:= ChIn(1); + if C = $1A\EOF\ then + [Text(0, "Line is empty (EOF)^M^L"); return false]; + L(I):= C; I:= I+1; +until C=$0A\LF\ or I>=MaxLen; +if I >= MaxLen then Text(0, "Line might be truncated^M^J"); +if I = 2 then Text(0, "Line is empty^M^J"); +L(I-1):= L(I-1) ! $80; \terminate string +return true; +]; + +char LineN(MaxLen); +if ReadLine(7, LineN) then Text(0, LineN) diff --git a/Task/Read-entire-file/0DESCRIPTION b/Task/Read-entire-file/0DESCRIPTION new file mode 100644 index 0000000000..8c69b9c010 --- /dev/null +++ b/Task/Read-entire-file/0DESCRIPTION @@ -0,0 +1,5 @@ +Load the entire contents of some text file as a single string variable. + +If applicable, discuss: encoding selection, the possibility of memory-mapping. + +Of course, one should avoid reading an entire file at once if the file is large and the task can be accomplished incrementally instead (in which case check [[File IO]]); this is for those cases where having the entire file is actually what is wanted. diff --git a/Task/Read-entire-file/1META.yaml b/Task/Read-entire-file/1META.yaml new file mode 100644 index 0000000000..53d5156105 --- /dev/null +++ b/Task/Read-entire-file/1META.yaml @@ -0,0 +1,2 @@ +--- +note: File handling diff --git a/Task/Read-entire-file/ALGOL-68/read-entire-file-1.alg b/Task/Read-entire-file/ALGOL-68/read-entire-file-1.alg new file mode 100644 index 0000000000..6e893d9819 --- /dev/null +++ b/Task/Read-entire-file/ALGOL-68/read-entire-file-1.alg @@ -0,0 +1,7 @@ +MODE BOOK = FLEX[0]FLEX[0]FLEX[0]CHAR; ¢ pages of lines of characters ¢ +BOOK book; + +FILE book file; +INT errno = open(book file, "book.txt", stand in channel); + +get(book file, book) diff --git a/Task/Read-entire-file/ALGOL-68/read-entire-file-2.alg b/Task/Read-entire-file/ALGOL-68/read-entire-file-2.alg new file mode 100644 index 0000000000..93362a8f8b --- /dev/null +++ b/Task/Read-entire-file/ALGOL-68/read-entire-file-2.alg @@ -0,0 +1,2 @@ +FILE cached book file; +associate(cached book file, book) diff --git a/Task/Read-entire-file/AWK/read-entire-file.awk b/Task/Read-entire-file/AWK/read-entire-file.awk new file mode 100644 index 0000000000..48a375415d --- /dev/null +++ b/Task/Read-entire-file/AWK/read-entire-file.awk @@ -0,0 +1,13 @@ +#!/usr/bin/awk -f +BEGIN { + ## empty record separate, + RS=""; + ## read line (i.e. whole file) into $0 + getline; + ## print line number and content of line + print "=== line "NR,":",$0; +} +{ + ## no further line is read printed + print "=== line "NR,":",$0; +} diff --git a/Task/Read-entire-file/Ada/read-entire-file-1.ada b/Task/Read-entire-file/Ada/read-entire-file-1.ada new file mode 100644 index 0000000000..e9c43a59ef --- /dev/null +++ b/Task/Read-entire-file/Ada/read-entire-file-1.ada @@ -0,0 +1,23 @@ +with Ada.Directories, + Ada.Direct_IO, + Ada.Text_IO; + +procedure Whole_File is + + File_Name : String := "whole_file.adb"; + File_Size : Natural := Natural (Ada.Directories.Size (File_Name)); + + subtype File_String is String (1 .. File_Size); + package File_String_IO is new Ada.Direct_IO (File_String); + + File : File_String_IO.File_Type; + Contents : File_String; + +begin + File_String_IO.Open (File, Mode => File_String_IO.In_File, + Name => File_Name); + File_String_IO.Read (File, Item => Contents); + File_String_IO.Close (File); + + Ada.Text_IO.Put (Contents); +end Whole_File; diff --git a/Task/Read-entire-file/Ada/read-entire-file-2.ada b/Task/Read-entire-file/Ada/read-entire-file-2.ada new file mode 100644 index 0000000000..9a1cf2af91 --- /dev/null +++ b/Task/Read-entire-file/Ada/read-entire-file-2.ada @@ -0,0 +1,35 @@ +with Ada.Text_IO, + POSIX.IO, + POSIX.Memory_Mapping, + System.Storage_Elements; + +procedure Read_Entire_File is + + use POSIX, POSIX.IO, POSIX.Memory_Mapping; + use System.Storage_Elements; + + Text_File : File_Descriptor; + Text_Size : System.Storage_Elements.Storage_Offset; + Text_Address : System.Address; + +begin + Text_File := Open (Name => "read_entire_file.adb", + Mode => Read_Only); + Text_Size := Storage_Offset (File_Size (Text_File)); + Text_Address := Map_Memory (Length => Text_Size, + Protection => Allow_Read, + Mapping => Map_Shared, + File => Text_File, + Offset => 0); + + declare + Text : String (1 .. Natural (Text_Size)); + for Text'Address use Text_Address; + begin + Ada.Text_IO.Put (Text); + end; + + Unmap_Memory (First => Text_Address, + Length => Text_Size); + Close (File => Text_File); +end Read_Entire_File; diff --git a/Task/Read-entire-file/AutoHotkey/read-entire-file.ahk b/Task/Read-entire-file/AutoHotkey/read-entire-file.ahk new file mode 100644 index 0000000000..ad114c64da --- /dev/null +++ b/Task/Read-entire-file/AutoHotkey/read-entire-file.ahk @@ -0,0 +1 @@ +fileread, varname, C:\filename.txt ; adding "MsgBox %varname%" (no quotes) to the next line will display the file contents. diff --git a/Task/Read-entire-file/BASIC/read-entire-file.basic b/Task/Read-entire-file/BASIC/read-entire-file.basic new file mode 100644 index 0000000000..131a27f138 --- /dev/null +++ b/Task/Read-entire-file/BASIC/read-entire-file.basic @@ -0,0 +1,5 @@ +DIM f AS STRING +OPEN "file.txt" FOR BINARY AS 1 +f = SPACE$(LOF(1)) +GET #1, 1, f +CLOSE 1 diff --git a/Task/Read-entire-file/BBC-BASIC/read-entire-file-1.bbc b/Task/Read-entire-file/BBC-BASIC/read-entire-file-1.bbc new file mode 100644 index 0000000000..86ab24b6d5 --- /dev/null +++ b/Task/Read-entire-file/BBC-BASIC/read-entire-file-1.bbc @@ -0,0 +1,6 @@ + file% = OPENIN("input.txt") + strvar$ = "" + WHILE NOT EOF#file% + strvar$ += CHR$(BGET#file%) + ENDWHILE + CLOSE #file% diff --git a/Task/Read-entire-file/BBC-BASIC/read-entire-file-2.bbc b/Task/Read-entire-file/BBC-BASIC/read-entire-file-2.bbc new file mode 100644 index 0000000000..3722ba7b5f --- /dev/null +++ b/Task/Read-entire-file/BBC-BASIC/read-entire-file-2.bbc @@ -0,0 +1,4 @@ + file% = OPENIN("input.txt") + strvar$ = STRING$(EXT#file%, " ") + SYS "ReadFile", @hfile%(file%), !^strvar$, EXT#file%, ^temp%, 0 + CLOSE #file% diff --git a/Task/Read-entire-file/Brainf---/read-entire-file.bf b/Task/Read-entire-file/Brainf---/read-entire-file.bf new file mode 100644 index 0000000000..3a0fbd210d --- /dev/null +++ b/Task/Read-entire-file/Brainf---/read-entire-file.bf @@ -0,0 +1,4 @@ +> Keep cell 0 at 0 as a sentinel value +,[>,] Read into successive cells until EOF +<[<] Go all the way back to the beginning +>[.>] Print successive cells while nonzero diff --git a/Task/Read-entire-file/Brat/read-entire-file.brat b/Task/Read-entire-file/Brat/read-entire-file.brat new file mode 100644 index 0000000000..7cdbb7c16d --- /dev/null +++ b/Task/Read-entire-file/Brat/read-entire-file.brat @@ -0,0 +1,3 @@ +include :file + +file.read file_name diff --git a/Task/Read-entire-file/C++/read-entire-file.cpp b/Task/Read-entire-file/C++/read-entire-file.cpp new file mode 100644 index 0000000000..22dcb7f898 --- /dev/null +++ b/Task/Read-entire-file/C++/read-entire-file.cpp @@ -0,0 +1,18 @@ +#include +#include +#include +#include + +int main( ) { + std::ifstream infile( "sample.txt" ) ; + if ( infile ) { + std::string fileData( ( std::istreambuf_iterator ( infile ) ) , + std::istreambuf_iterator ( ) ) ; + infile.close( ) ; ; + return 0 ; + } + else { + std::cout << "file not found!\n" ; + return 1 ; + } +} diff --git a/Task/Read-entire-file/C-sharp/read-entire-file.cs b/Task/Read-entire-file/C-sharp/read-entire-file.cs new file mode 100644 index 0000000000..ca72732112 --- /dev/null +++ b/Task/Read-entire-file/C-sharp/read-entire-file.cs @@ -0,0 +1,9 @@ +using System.IO; + +class Program +{ + static void Main(string[] args) + { + var fileContents = File.ReadAllText("c:\\autoexec.bat"); + } +} diff --git a/Task/Read-entire-file/C/read-entire-file-1.c b/Task/Read-entire-file/C/read-entire-file-1.c new file mode 100644 index 0000000000..d2fcf97f3b --- /dev/null +++ b/Task/Read-entire-file/C/read-entire-file-1.c @@ -0,0 +1,28 @@ +#include +#include + +int main() +{ + char *buffer; + FILE *fh = fopen("readentirefile.c", "rb"); + if ( fh != NULL ) + { + fseek(fh, 0L, SEEK_END); + long s = ftell(fh); + rewind(fh); + buffer = malloc(s); + if ( buffer != NULL ) + { + fread(buffer, s, 1, fh); + // we can now close the file + fclose(fh); fh = NULL; + + // do something, e.g. + fwrite(buffer, s, 1, stdout); + + free(buffer); + } + if (fh != NULL) fclose(fh); + } + return EXIT_SUCCESS; +} diff --git a/Task/Read-entire-file/C/read-entire-file-2.c b/Task/Read-entire-file/C/read-entire-file-2.c new file mode 100644 index 0000000000..b6b80fb166 --- /dev/null +++ b/Task/Read-entire-file/C/read-entire-file-2.c @@ -0,0 +1,29 @@ +#include +#include +#include +#include +#include +#include +#include + +int main() +{ + char *buffer; + struct stat s; + + int fd = open("readentirefile_mm.c", O_RDONLY); + if (fd < 0 ) return EXIT_FAILURE; + fstat(fd, &s); + /* PROT_READ disallows writing to buffer: will segv */ + buffer = mmap(0, s.st_size, PROT_READ, MAP_PRIVATE, fd, 0); + + if ( buffer != (void*)-1 ) + { + /* do something */ + fwrite(buffer, s.st_size, 1, stdout); + munmap(buffer, s.st_size); + } + + close(fd); + return EXIT_SUCCESS; +} diff --git a/Task/Read-entire-file/CMake/read-entire-file-1.cmake b/Task/Read-entire-file/CMake/read-entire-file-1.cmake new file mode 100644 index 0000000000..6ae160f0d7 --- /dev/null +++ b/Task/Read-entire-file/CMake/read-entire-file-1.cmake @@ -0,0 +1 @@ +file(READ /etc/passwd string) diff --git a/Task/Read-entire-file/CMake/read-entire-file-2.cmake b/Task/Read-entire-file/CMake/read-entire-file-2.cmake new file mode 100644 index 0000000000..cf77421520 --- /dev/null +++ b/Task/Read-entire-file/CMake/read-entire-file-2.cmake @@ -0,0 +1 @@ +file(READ /etc/pwd.db string HEX) diff --git a/Task/Read-entire-file/Clojure/read-entire-file.clj b/Task/Read-entire-file/Clojure/read-entire-file.clj new file mode 100644 index 0000000000..3571501058 --- /dev/null +++ b/Task/Read-entire-file/Clojure/read-entire-file.clj @@ -0,0 +1,2 @@ +(slurp "myfile.txt") +(slurp "my-utf8-file.txt" "UTF-8") diff --git a/Task/Read-entire-file/Common-Lisp/read-entire-file.lisp b/Task/Read-entire-file/Common-Lisp/read-entire-file.lisp new file mode 100644 index 0000000000..33466fd4e9 --- /dev/null +++ b/Task/Read-entire-file/Common-Lisp/read-entire-file.lisp @@ -0,0 +1,5 @@ +(defun file-string (path) + (with-open-file (stream path) + (let ((data (make-string (file-length stream)))) + (read-sequence data stream) + data))) diff --git a/Task/Read-entire-file/D/read-entire-file.d b/Task/Read-entire-file/D/read-entire-file.d new file mode 100644 index 0000000000..4607fc48d7 --- /dev/null +++ b/Task/Read-entire-file/D/read-entire-file.d @@ -0,0 +1,9 @@ +import std.file: read, readText; + +void main() { + // To read a whole file into a dynamic array of unsigned bytes: + auto data = cast(ubyte[])read("unixdict.txt"); + + // To read a whole file into a validated UTF-8 string: + string txt = readText("unixdict.txt"); +} diff --git a/Task/Read-entire-file/Delphi/read-entire-file-1.delphi b/Task/Read-entire-file/Delphi/read-entire-file-1.delphi new file mode 100644 index 0000000000..30349fdab8 --- /dev/null +++ b/Task/Read-entire-file/Delphi/read-entire-file-1.delphi @@ -0,0 +1,22 @@ +program ReadAll; + +{$APPTYPE CONSOLE} + +uses Classes; + +var + i: Integer; + lList: TStringList; +begin + lList := TStringList.Create; + try + lList.LoadFromFile('c:\input.txt'); + // Write everything at once + Writeln(lList.Text); + // Write one line at a time + for i := 0 to lList.Count - 1 do + Writeln(lList[i]); + finally + lList.Free; + end; +end. diff --git a/Task/Read-entire-file/Delphi/read-entire-file-2.delphi b/Task/Read-entire-file/Delphi/read-entire-file-2.delphi new file mode 100644 index 0000000000..5758a4ee6b --- /dev/null +++ b/Task/Read-entire-file/Delphi/read-entire-file-2.delphi @@ -0,0 +1,14 @@ +program ReadAll; + +{$APPTYPE CONSOLE} + +uses + SysUtils, IOUtils; + +begin +// with default encoding: + Writeln(TFile.ReadAllText('C:\autoexec.bat')); +// with encoding specified: + Writeln(TFile.ReadAllText('C:\autoexec.bat', TEncoding.ASCII)); + Readln; +end. diff --git a/Task/Read-entire-file/E/read-entire-file.e b/Task/Read-entire-file/E/read-entire-file.e new file mode 100644 index 0000000000..e8a30d690f --- /dev/null +++ b/Task/Read-entire-file/E/read-entire-file.e @@ -0,0 +1 @@ +.getText() diff --git a/Task/Read-entire-file/Erlang/read-entire-file.erl b/Task/Read-entire-file/Erlang/read-entire-file.erl new file mode 100644 index 0000000000..41a79c712b --- /dev/null +++ b/Task/Read-entire-file/Erlang/read-entire-file.erl @@ -0,0 +1 @@ +{ok, B} = file:read_file("myfile.txt"). diff --git a/Task/Read-entire-file/Euphoria/read-entire-file.euphoria b/Task/Read-entire-file/Euphoria/read-entire-file.euphoria new file mode 100644 index 0000000000..4a9c53da33 --- /dev/null +++ b/Task/Read-entire-file/Euphoria/read-entire-file.euphoria @@ -0,0 +1,16 @@ +function load_file(sequence filename) + integer fn,c + sequence data + fn = open(filename,"r") -- "r" for text files, "rb" for binary files + if (fn = -1) then return {} end if -- failed to open the file + + data = {} -- init to empty sequence + c = getc(fn) -- prime the char buffer + while (c != -1) do -- while not EOF + data &= c -- append each character + c = getc(fn) -- next char + end while + + close(fn) + return data +end function diff --git a/Task/Read-entire-file/Factor/read-entire-file.factor b/Task/Read-entire-file/Factor/read-entire-file.factor new file mode 100644 index 0000000000..eccaf383a7 --- /dev/null +++ b/Task/Read-entire-file/Factor/read-entire-file.factor @@ -0,0 +1,7 @@ +USING: io.encodings.ascii io.encodings.binary io.files ; + +! to read entire file as binary +"foo.txt" binary file-contents + +! to read entire file as lines of text +"foo.txt" ascii file-lines diff --git a/Task/Read-entire-file/Fantom/read-entire-file.fantom b/Task/Read-entire-file/Fantom/read-entire-file.fantom new file mode 100644 index 0000000000..836cb544c6 --- /dev/null +++ b/Task/Read-entire-file/Fantom/read-entire-file.fantom @@ -0,0 +1,8 @@ +class ReadString +{ + public static Void main (Str[] args) + { + Str contents := File(args[0].toUri).readAllStr + echo ("contents: $contents") + } +} diff --git a/Task/Read-entire-file/Forth/read-entire-file.fth b/Task/Read-entire-file/Forth/read-entire-file.fth new file mode 100644 index 0000000000..3d0cd34067 --- /dev/null +++ b/Task/Read-entire-file/Forth/read-entire-file.fth @@ -0,0 +1 @@ +s" foo.txt" slurp-file ( str len ) diff --git a/Task/Read-entire-file/Frink/read-entire-file.frink b/Task/Read-entire-file/Frink/read-entire-file.frink new file mode 100644 index 0000000000..9a3c70dbb6 --- /dev/null +++ b/Task/Read-entire-file/Frink/read-entire-file.frink @@ -0,0 +1,2 @@ +a = read["file:yourfile.txt"] +b = read["file:yourfile.txt", "UTF-8"] diff --git a/Task/Read-entire-file/GAP/read-entire-file.gap b/Task/Read-entire-file/GAP/read-entire-file.gap new file mode 100644 index 0000000000..d64ce522f8 --- /dev/null +++ b/Task/Read-entire-file/GAP/read-entire-file.gap @@ -0,0 +1,3 @@ +InputTextFile("input.txt"); +s := ReadAll(f);; # two semicolons to hide the result, which may be long +CloseStream(f); diff --git a/Task/Read-entire-file/GUISS/read-entire-file.guiss b/Task/Read-entire-file/GUISS/read-entire-file.guiss new file mode 100644 index 0000000000..b5be83a710 --- /dev/null +++ b/Task/Read-entire-file/GUISS/read-entire-file.guiss @@ -0,0 +1 @@ +Start,Programs,Accessories,Notepad,Menu:File,Open,Doubleclick:Icon:Notes.TXT,Button:OK diff --git a/Task/Read-entire-file/Go/read-entire-file-1.go b/Task/Read-entire-file/Go/read-entire-file-1.go new file mode 100644 index 0000000000..c030f7ebf3 --- /dev/null +++ b/Task/Read-entire-file/Go/read-entire-file-1.go @@ -0,0 +1,4 @@ +import "io/ioutil" + +data, err := ioutil.ReadFile(filename) +sv := string(data) diff --git a/Task/Read-entire-file/Go/read-entire-file-2.go b/Task/Read-entire-file/Go/read-entire-file-2.go new file mode 100644 index 0000000000..61d5ce8fc6 --- /dev/null +++ b/Task/Read-entire-file/Go/read-entire-file-2.go @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "log" + "os" + "syscall" +) + +func main() { + f, err := os.Open("file") + if err != nil { + log.Fatal(err) + } + fi, err := f.Stat() + if err != nil { + log.Fatal(err) + } + data, err := syscall.Mmap(int(f.Fd()), 0, int(fi.Size()), + syscall.PROT_READ, syscall.MAP_PRIVATE) + if err != nil { + log.Fatal(err) + } + fmt.Println(string(data)) +} diff --git a/Task/Read-entire-file/Groovy/read-entire-file.groovy b/Task/Read-entire-file/Groovy/read-entire-file.groovy new file mode 100644 index 0000000000..039cfe6a92 --- /dev/null +++ b/Task/Read-entire-file/Groovy/read-entire-file.groovy @@ -0,0 +1 @@ +def fileContent = new File("c:\\file.txt").text diff --git a/Task/Read-entire-file/Haskell/read-entire-file-1.hs b/Task/Read-entire-file/Haskell/read-entire-file-1.hs new file mode 100644 index 0000000000..9a22c5a46f --- /dev/null +++ b/Task/Read-entire-file/Haskell/read-entire-file-1.hs @@ -0,0 +1,2 @@ +do text <- readFile filepath + -- do stuff with text diff --git a/Task/Read-entire-file/Haskell/read-entire-file-2.hs b/Task/Read-entire-file/Haskell/read-entire-file-2.hs new file mode 100644 index 0000000000..fa98d2a056 --- /dev/null +++ b/Task/Read-entire-file/Haskell/read-entire-file-2.hs @@ -0,0 +1,4 @@ +eagerReadFile :: FilePath -> IO String +eagerReadFile filepath = do + text <- readFile filepath + last text `seq` return text diff --git a/Task/Read-entire-file/Icon/read-entire-file-1.icon b/Task/Read-entire-file/Icon/read-entire-file-1.icon new file mode 100644 index 0000000000..93a4ecad1a --- /dev/null +++ b/Task/Read-entire-file/Icon/read-entire-file-1.icon @@ -0,0 +1 @@ +every (fs := "") ||:= |reads(1000000) diff --git a/Task/Read-entire-file/Icon/read-entire-file-2.icon b/Task/Read-entire-file/Icon/read-entire-file-2.icon new file mode 100644 index 0000000000..25f475ca05 --- /dev/null +++ b/Task/Read-entire-file/Icon/read-entire-file-2.icon @@ -0,0 +1,3 @@ +every put(fL := [],|FUNC(read())) +every (fs := "") ||:= !fL || "\n" +fL := &null diff --git a/Task/Read-entire-file/Inform-7/read-entire-file.inf b/Task/Read-entire-file/Inform-7/read-entire-file.inf new file mode 100644 index 0000000000..321d0bfee8 --- /dev/null +++ b/Task/Read-entire-file/Inform-7/read-entire-file.inf @@ -0,0 +1,7 @@ +Home is a room. + +The File of Testing is called "test". + +When play begins: + say "[text of the File of Testing]"; + end the story. diff --git a/Task/Read-entire-file/J/read-entire-file-1.j b/Task/Read-entire-file/J/read-entire-file-1.j new file mode 100644 index 0000000000..b6661bda94 --- /dev/null +++ b/Task/Read-entire-file/J/read-entire-file-1.j @@ -0,0 +1 @@ + var=: 1!:1<'foo.txt' diff --git a/Task/Read-entire-file/J/read-entire-file-2.j b/Task/Read-entire-file/J/read-entire-file-2.j new file mode 100644 index 0000000000..8d8a4c19f9 --- /dev/null +++ b/Task/Read-entire-file/J/read-entire-file-2.j @@ -0,0 +1,2 @@ + require'jmf' + JCHAR map_jmf_ 'var';'foo.txt' diff --git a/Task/Read-entire-file/Java/read-entire-file-1.java b/Task/Read-entire-file/Java/read-entire-file-1.java new file mode 100644 index 0000000000..d12b424516 --- /dev/null +++ b/Task/Read-entire-file/Java/read-entire-file-1.java @@ -0,0 +1,21 @@ +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; + +public class ReadFile { + public static void main(String[] args) throws IOException{ + String fileContents = readEntireFile("./foo.txt"); + } + + private static String readEntireFile(String filename) throws IOException { + FileReader in = new FileReader(filename); + StringBuilder contents = new StringBuilder(); + char[] buffer = new char[4096]; + int read = 0; + do { + contents.append(buffer, 0, read); + read = in.read(buffer); + } while (read >= 0); + return contents.toString(); + } +} diff --git a/Task/Read-entire-file/Java/read-entire-file-2.java b/Task/Read-entire-file/Java/read-entire-file-2.java new file mode 100644 index 0000000000..e16137bd30 --- /dev/null +++ b/Task/Read-entire-file/Java/read-entire-file-2.java @@ -0,0 +1,20 @@ +import java.nio.channels.FileChannel.MapMode; +import java.nio.MappedByteBuffer; +import java.io.RandomAccessFile; +import java.io.IOException; +import java.io.File; + +public class MMapReadFile { + public static void main(String[] args) throws IOException { + MappedByteBuffer buff = getBufferFor(new File(args[0])); + String results = new String(buff.asCharBuffer()); + } + + public static MappedByteBuffer getBufferFor(File f) throws IOException { + RandomAccessFile file = new RandomAccessFile(f, "r"); + + MappedByteBuffer buffer = file.getChannel().map(MapMode.READ_ONLY, 0, f.length()); + file.close(); + return buffer; + } +} diff --git a/Task/Read-entire-file/Java/read-entire-file-3.java b/Task/Read-entire-file/Java/read-entire-file-3.java new file mode 100644 index 0000000000..9df960dfb0 --- /dev/null +++ b/Task/Read-entire-file/Java/read-entire-file-3.java @@ -0,0 +1 @@ +String content = new Scanner(new File("foo"), "UTF-8").useDelimiter("\\A").next(); diff --git a/Task/Read-entire-file/Java/read-entire-file-4.java b/Task/Read-entire-file/Java/read-entire-file-4.java new file mode 100644 index 0000000000..02a10cd80c --- /dev/null +++ b/Task/Read-entire-file/Java/read-entire-file-4.java @@ -0,0 +1,15 @@ +import java.util.List; +import java.nio.charset.Charset; +import java.nio.file.*; + +public class ReadAll { + public static List readAllLines(String filesname){ + Path file = Paths.get(filename); + return Files.readAllLines(file, Charset.defaultCharset()); + } + + public static byte[] readAllBytes(String filename){ + Path file = Paths.get(filename); + return Files.readAllBytes(file); + } +} diff --git a/Task/Read-entire-file/JavaScript/read-entire-file-1.js b/Task/Read-entire-file/JavaScript/read-entire-file-1.js new file mode 100644 index 0000000000..10bd46d7b9 --- /dev/null +++ b/Task/Read-entire-file/JavaScript/read-entire-file-1.js @@ -0,0 +1,5 @@ +var fso=new ActiveXObject("Scripting.FileSystemObject"); +var f=fso.OpenTextFile("c:\\myfile.txt",1); +var s=f.ReadAll(); +f.Close(); +try{alert(s)}catch(e){WScript.Echo(s)} diff --git a/Task/Read-entire-file/JavaScript/read-entire-file-2.js b/Task/Read-entire-file/JavaScript/read-entire-file-2.js new file mode 100644 index 0000000000..b0304f548d --- /dev/null +++ b/Task/Read-entire-file/JavaScript/read-entire-file-2.js @@ -0,0 +1,14 @@ +var file = document.getElementById("fileInput").files.item(0); //a file input element +if (file) { + var reader = new FileReader(); + reader.readAsText(file, "UTF-8"); + reader.onload = loadedFile; + reader.onerror = errorHandler; +} +function loadedFile(event) { + var fileString = event.target.result; + alert(fileString); +} +function errorHandler(event) { + alert(event); +} diff --git a/Task/Read-entire-file/Julia/read-entire-file.julia b/Task/Read-entire-file/Julia/read-entire-file.julia new file mode 100644 index 0000000000..d7cf6437e6 --- /dev/null +++ b/Task/Read-entire-file/Julia/read-entire-file.julia @@ -0,0 +1,4 @@ +sample_filepath = "/devel/myfile.txt" +f = open(sample_filepath) +file_contents = readall(f) # load all into a single String +close(f) diff --git a/Task/Read-entire-file/Lang5/read-entire-file.lang5 b/Task/Read-entire-file/Lang5/read-entire-file.lang5 new file mode 100644 index 0000000000..f4876cf761 --- /dev/null +++ b/Task/Read-entire-file/Lang5/read-entire-file.lang5 @@ -0,0 +1 @@ +'foo.txt slurp diff --git a/Task/Read-entire-file/Liberty-BASIC/read-entire-file.liberty b/Task/Read-entire-file/Liberty-BASIC/read-entire-file.liberty new file mode 100644 index 0000000000..dcdbcac329 --- /dev/null +++ b/Task/Read-entire-file/Liberty-BASIC/read-entire-file.liberty @@ -0,0 +1,7 @@ +filedialog "Open a Text File","*.txt",file$ +if file$<>"" then + open file$ for input as #1 + entire$ = input$(#1, lof(#1)) + close #1 + print entire$ +end if diff --git a/Task/Read-entire-file/Lua/read-entire-file.lua b/Task/Read-entire-file/Lua/read-entire-file.lua new file mode 100644 index 0000000000..2ab28f034c --- /dev/null +++ b/Task/Read-entire-file/Lua/read-entire-file.lua @@ -0,0 +1,21 @@ +--If the file opens with no problems, io.open will return a +--handle to the file with methods attached. +--If the file does not exist, io.open will return nil and +--an error message. +--assert will return the handle to the file if present, or +--it will throw an error with the message returned second +--by io.open. +local file = assert(io.open(filename)) +--Without wrapping io.open in an assert, local file would be nil, +--which would cause an 'attempt to index a nil value' error when +--calling file:read. + +--file:read takes the number of bytes to read, or a string for +--special cases, such as "*a" to read the entire file. +local contents = file:read'*a' + +--If the file handle was local to the expression +--(ie. "assert(io.open(filename)):read'a'"), +--the file would remain open until its handle was +--garbage collected. +file:close() diff --git a/Task/Read-entire-file/MATLAB/read-entire-file.m b/Task/Read-entire-file/MATLAB/read-entire-file.m new file mode 100644 index 0000000000..d1f3788303 --- /dev/null +++ b/Task/Read-entire-file/MATLAB/read-entire-file.m @@ -0,0 +1,3 @@ + fid = fopen('filename','r'); + [str,count] = fread(fid, [1,inf], 'uint8=>char'); % s will be a character array, count has the number of bytes + fclose(fid); diff --git a/Task/Read-entire-file/Maple/read-entire-file-1.maple b/Task/Read-entire-file/Maple/read-entire-file-1.maple new file mode 100644 index 0000000000..b55309f62c --- /dev/null +++ b/Task/Read-entire-file/Maple/read-entire-file-1.maple @@ -0,0 +1 @@ +s1 := readbytes( "file1.txt", infinity, TEXT ): diff --git a/Task/Read-entire-file/Maple/read-entire-file-2.maple b/Task/Read-entire-file/Maple/read-entire-file-2.maple new file mode 100644 index 0000000000..ee99093cca --- /dev/null +++ b/Task/Read-entire-file/Maple/read-entire-file-2.maple @@ -0,0 +1 @@ +s2 := FileTools:-Text:-ReadFile( "file2.txt" ): diff --git a/Task/Read-entire-file/Mathematica/read-entire-file.math b/Task/Read-entire-file/Mathematica/read-entire-file.math new file mode 100644 index 0000000000..6a70ab245e --- /dev/null +++ b/Task/Read-entire-file/Mathematica/read-entire-file.math @@ -0,0 +1 @@ +Import["filename","String"] diff --git a/Task/Read-entire-file/NetRexx/read-entire-file.netrexx b/Task/Read-entire-file/NetRexx/read-entire-file.netrexx new file mode 100644 index 0000000000..18317b02e1 --- /dev/null +++ b/Task/Read-entire-file/NetRexx/read-entire-file.netrexx @@ -0,0 +1,43 @@ +/* NetRexx */ +options replace format comments java crossref symbols nobinary + +parse arg inFileName . + +if inFileName = '' | inFileName = '.' then inFileName = './data/dwarfs.json' +fileContents = slurp(inFileName) +say fileContents + +return + +-- Slurp a file and return contents as a Rexx string +method slurp(inFileName) public static returns Rexx + + slurped = Rexx null + slurpStr = StringBuilder() + ioBuffer = byte[1024] + inBytes = int 0 + + do + inFile = File(inFileName) + inFileIS = BufferedInputStream(FileInputStream(inFile)) + + loop label ioLoop until inBytes = -1 + slurpStr.append(String(ioBuffer, 0, inBytes)) + inBytes = inFileIS.read(ioBuffer) + end ioLoop + + catch exFNF = FileNotFoundException + exFNF.printStackTrace + catch exIO = IOException + exIO.printStackTrace + finally + do + inFileIS.close() + catch ex = IOException + ex.printStackTrace + end + end + + slurped = Rexx(slurpStr.toString) + + return slurped diff --git a/Task/Read-entire-file/NewLISP/read-entire-file.newlisp b/Task/Read-entire-file/NewLISP/read-entire-file.newlisp new file mode 100644 index 0000000000..46b34eeab9 --- /dev/null +++ b/Task/Read-entire-file/NewLISP/read-entire-file.newlisp @@ -0,0 +1 @@ +(read-file "filename") diff --git a/Task/Read-entire-file/Nimrod/read-entire-file.nimrod b/Task/Read-entire-file/Nimrod/read-entire-file.nimrod new file mode 100644 index 0000000000..459831b1a0 --- /dev/null +++ b/Task/Read-entire-file/Nimrod/read-entire-file.nimrod @@ -0,0 +1 @@ +readFile(filename) diff --git a/Task/Read-entire-file/OCaml/read-entire-file-1.ocaml b/Task/Read-entire-file/OCaml/read-entire-file-1.ocaml new file mode 100644 index 0000000000..09d27ccbe1 --- /dev/null +++ b/Task/Read-entire-file/OCaml/read-entire-file-1.ocaml @@ -0,0 +1,7 @@ +let load_file f = + let ic = open_in f in + let n = in_channel_length ic in + let s = String.create n in + really_input ic s 0 n; + close_in ic; + (s) diff --git a/Task/Read-entire-file/OCaml/read-entire-file-2.ocaml b/Task/Read-entire-file/OCaml/read-entire-file-2.ocaml new file mode 100644 index 0000000000..111ac5d0f0 --- /dev/null +++ b/Task/Read-entire-file/OCaml/read-entire-file-2.ocaml @@ -0,0 +1,2 @@ +type big_string = + (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t diff --git a/Task/Read-entire-file/OCaml/read-entire-file-3.ocaml b/Task/Read-entire-file/OCaml/read-entire-file-3.ocaml new file mode 100644 index 0000000000..82557e2ed7 --- /dev/null +++ b/Task/Read-entire-file/OCaml/read-entire-file-3.ocaml @@ -0,0 +1,9 @@ +let load_big_file filename = + let fd = Unix.openfile filename [Unix.O_RDONLY] 0o640 in + let len = Unix.lseek fd 0 Unix.SEEK_END in + let _ = Unix.lseek fd 0 Unix.SEEK_SET in + let shared = false in (* modifications are done in memory only *) + let bstr = Bigarray.Array1.map_file fd + Bigarray.char Bigarray.c_layout shared len in + Unix.close fd; + (bstr) diff --git a/Task/Read-entire-file/OCaml/read-entire-file-4.ocaml b/Task/Read-entire-file/OCaml/read-entire-file-4.ocaml new file mode 100644 index 0000000000..09396f83b1 --- /dev/null +++ b/Task/Read-entire-file/OCaml/read-entire-file-4.ocaml @@ -0,0 +1,7 @@ +let () = + let bstr = load_big_file Sys.argv.(1) in + let len = Bigarray.Array1.dim bstr in + for i = 0 to pred len do + let c = bstr.{i} in + print_char c + done diff --git a/Task/Read-entire-file/Objeck/read-entire-file.objeck b/Task/Read-entire-file/Objeck/read-entire-file.objeck new file mode 100644 index 0000000000..7dea01d157 --- /dev/null +++ b/Task/Read-entire-file/Objeck/read-entire-file.objeck @@ -0,0 +1 @@ +string := FileReader->ReadFile("in.txt"); diff --git a/Task/Read-entire-file/Objective-C/read-entire-file.m b/Task/Read-entire-file/Objective-C/read-entire-file.m new file mode 100644 index 0000000000..0189778470 --- /dev/null +++ b/Task/Read-entire-file/Objective-C/read-entire-file.m @@ -0,0 +1,32 @@ + /*** 0. PREPARATION */ + // We need a text file to read; let's redirect a C string to a new file + // using the shell by way of the stdlib system() function. + system ("echo \"Hello, World!\" > ~/HelloRosetta"); + + + + /*** 1. THE TASK */ + // Instantiate an NSString which describes the filesystem location of + // the file we will be reading. + NSString *filePath = [NSHomeDirectory() stringByAppendingPathComponent:@"HelloRosetta"]; + + // The selector we're going to use to complete this task, + // stringWithContentsOfFile:encoding:error, has an optional `error' + // parameter which can be used to return information about any + // errors it might run into. It's optional, but we'll create an NSError + // anyways to demonstrate best practice. + NSError *anError; + + // And finally, the task: read and store the contents of a file as an + // NSString. + NSString *aString = [NSString stringWithContentsOfFile:filePath + encoding:NSUTF8StringEncoding + error:&anError]; + + // If the file read was unsuccessful, display the error description. + // Otherwise, display the NSString. + if (!aString) { + NSLog(@"%@", [anError localizedDescription]); + } else { + NSLog(@"%@", aString); + } diff --git a/Task/Read-entire-file/Oz/read-entire-file.oz b/Task/Read-entire-file/Oz/read-entire-file.oz new file mode 100644 index 0000000000..c243a6ef1e --- /dev/null +++ b/Task/Read-entire-file/Oz/read-entire-file.oz @@ -0,0 +1,6 @@ +declare + FileHandle = {New Open.file init(name:"test.txt")} + FileContents = {FileHandle read(size:all list:$)} +in + {FileHandle close} + {System.printInfo FileContents} diff --git a/Task/Read-entire-file/PARI-GP/read-entire-file.pari b/Task/Read-entire-file/PARI-GP/read-entire-file.pari new file mode 100644 index 0000000000..21e3e3bb79 --- /dev/null +++ b/Task/Read-entire-file/PARI-GP/read-entire-file.pari @@ -0,0 +1 @@ +text=read("file.txt"); diff --git a/Task/Read-entire-file/PHP/read-entire-file.php b/Task/Read-entire-file/PHP/read-entire-file.php new file mode 100644 index 0000000000..21642ab362 --- /dev/null +++ b/Task/Read-entire-file/PHP/read-entire-file.php @@ -0,0 +1 @@ +file_get_contents($filename) diff --git a/Task/Read-entire-file/PL-I/read-entire-file.pli b/Task/Read-entire-file/PL-I/read-entire-file.pli new file mode 100644 index 0000000000..d12cf44303 --- /dev/null +++ b/Task/Read-entire-file/PL-I/read-entire-file.pli @@ -0,0 +1 @@ +get file (in) edit ((substr(s, i, 1) do i = 1 to 32767)) (a); diff --git a/Task/Read-entire-file/Perl-6/read-entire-file.pl6 b/Task/Read-entire-file/Perl-6/read-entire-file.pl6 new file mode 100644 index 0000000000..ed83b06b6e --- /dev/null +++ b/Task/Read-entire-file/Perl-6/read-entire-file.pl6 @@ -0,0 +1 @@ +my $string = slurp 'sample.txt'; diff --git a/Task/Read-entire-file/Perl/read-entire-file-1.pl b/Task/Read-entire-file/Perl/read-entire-file-1.pl new file mode 100644 index 0000000000..6215ca3346 --- /dev/null +++ b/Task/Read-entire-file/Perl/read-entire-file-1.pl @@ -0,0 +1,3 @@ +open my $fh, $filename; +my $text = do { local( $/ ); <$fh> }; +close $fh; diff --git a/Task/Read-entire-file/Perl/read-entire-file-2.pl b/Task/Read-entire-file/Perl/read-entire-file-2.pl new file mode 100644 index 0000000000..dffd45e950 --- /dev/null +++ b/Task/Read-entire-file/Perl/read-entire-file-2.pl @@ -0,0 +1,3 @@ +open my $fh, $filename; +my $text;read $fh, $text, -s $filename; +close $fh; diff --git a/Task/Read-entire-file/Perl/read-entire-file-3.pl b/Task/Read-entire-file/Perl/read-entire-file-3.pl new file mode 100644 index 0000000000..225de97e14 --- /dev/null +++ b/Task/Read-entire-file/Perl/read-entire-file-3.pl @@ -0,0 +1,2 @@ +use File::Slurp; +my $text = read_file($filename); diff --git a/Task/Read-entire-file/Perl/read-entire-file-4.pl b/Task/Read-entire-file/Perl/read-entire-file-4.pl new file mode 100644 index 0000000000..30f5d8ae23 --- /dev/null +++ b/Task/Read-entire-file/Perl/read-entire-file-4.pl @@ -0,0 +1,6 @@ +use IO::All; +$text = io($filename)->all; +$text = io($filename)->utf8->all; +@text = io($filename)->slurp; +$text < io($filename); +io($filename) > $text; diff --git a/Task/Read-entire-file/Perl/read-entire-file-5.pl b/Task/Read-entire-file/Perl/read-entire-file-5.pl new file mode 100644 index 0000000000..b3889b504a --- /dev/null +++ b/Task/Read-entire-file/Perl/read-entire-file-5.pl @@ -0,0 +1 @@ +perl -n -0777 -e 'print "file len: ".length' stuff.txt diff --git a/Task/Read-entire-file/PicoLisp/read-entire-file-1.l b/Task/Read-entire-file/PicoLisp/read-entire-file-1.l new file mode 100644 index 0000000000..1454ef3b7e --- /dev/null +++ b/Task/Read-entire-file/PicoLisp/read-entire-file-1.l @@ -0,0 +1 @@ +(in "file" (till NIL T)) diff --git a/Task/Read-entire-file/PicoLisp/read-entire-file-2.l b/Task/Read-entire-file/PicoLisp/read-entire-file-2.l new file mode 100644 index 0000000000..9dc4ea238e --- /dev/null +++ b/Task/Read-entire-file/PicoLisp/read-entire-file-2.l @@ -0,0 +1 @@ +(in "file" (till NIL)) diff --git a/Task/Read-entire-file/PicoLisp/read-entire-file-3.l b/Task/Read-entire-file/PicoLisp/read-entire-file-3.l new file mode 100644 index 0000000000..9ae1b502cd --- /dev/null +++ b/Task/Read-entire-file/PicoLisp/read-entire-file-3.l @@ -0,0 +1 @@ +(in "file" (make (while (char) (link @)))) diff --git a/Task/Read-entire-file/Pike/read-entire-file.pike b/Task/Read-entire-file/Pike/read-entire-file.pike new file mode 100644 index 0000000000..a57fe6e33f --- /dev/null +++ b/Task/Read-entire-file/Pike/read-entire-file.pike @@ -0,0 +1 @@ +string content=Stdio.File("foo.txt")->read(); diff --git a/Task/Read-entire-file/PowerShell/read-entire-file-1.psh b/Task/Read-entire-file/PowerShell/read-entire-file-1.psh new file mode 100644 index 0000000000..ee6cec5ee8 --- /dev/null +++ b/Task/Read-entire-file/PowerShell/read-entire-file-1.psh @@ -0,0 +1 @@ +Get-Content foo.txt diff --git a/Task/Read-entire-file/PowerShell/read-entire-file-2.psh b/Task/Read-entire-file/PowerShell/read-entire-file-2.psh new file mode 100644 index 0000000000..75a740ef51 --- /dev/null +++ b/Task/Read-entire-file/PowerShell/read-entire-file-2.psh @@ -0,0 +1 @@ +Get-Content foo.txt -Encoding UTF8 diff --git a/Task/Read-entire-file/PowerShell/read-entire-file-3.psh b/Task/Read-entire-file/PowerShell/read-entire-file-3.psh new file mode 100644 index 0000000000..9e6fe739ee --- /dev/null +++ b/Task/Read-entire-file/PowerShell/read-entire-file-3.psh @@ -0,0 +1 @@ +(Get-Content foo.txt) -join "`n" diff --git a/Task/Read-entire-file/PureBasic/read-entire-file-1.purebasic b/Task/Read-entire-file/PureBasic/read-entire-file-1.purebasic new file mode 100644 index 0000000000..20fc5526d6 --- /dev/null +++ b/Task/Read-entire-file/PureBasic/read-entire-file-1.purebasic @@ -0,0 +1,10 @@ +Number.b = ReadByte(#File) +Length.i = ReadData(#File, *MemoryBuffer, LengthToRead) +Number.c = ReadCharacter(#File) +Number.d = ReadDouble(#File) +Number.f = ReadFloat(#File) +Number.i = ReadInteger(#File) +Number.l = ReadLong(#File) +Number.q = ReadQuad(#File) +Text$ = ReadString(#File [, Flags]) +Number.w = ReadWord(#File) diff --git a/Task/Read-entire-file/PureBasic/read-entire-file-2.purebasic b/Task/Read-entire-file/PureBasic/read-entire-file-2.purebasic new file mode 100644 index 0000000000..28fe1c05c2 --- /dev/null +++ b/Task/Read-entire-file/PureBasic/read-entire-file-2.purebasic @@ -0,0 +1,4 @@ +If ReadFile(0, "RC.txt") + Variable$=ReadString(0) + CloseFile(0) +EndIf diff --git a/Task/Read-entire-file/PureBasic/read-entire-file-3.purebasic b/Task/Read-entire-file/PureBasic/read-entire-file-3.purebasic new file mode 100644 index 0000000000..00907ddf45 --- /dev/null +++ b/Task/Read-entire-file/PureBasic/read-entire-file-3.purebasic @@ -0,0 +1,14 @@ +Title$="Select a file" +Pattern$="Text (.txt)|*.txt|All files (*.*)|*.*" +fileName$ = OpenFileRequester(Title$,"",Pattern$,0) +If fileName$ + If ReadFile(0, fileName$) + length = Lof(0) + *MemoryID = AllocateMemory(length) + If *MemoryID + bytes = ReadData(0, *MemoryID, length) + MessageRequester("Info",Str(bytes)+" was read") + EndIf + CloseFile(0) + EndIf +EndIf diff --git a/Task/Read-entire-file/Python/read-entire-file-1.py b/Task/Read-entire-file/Python/read-entire-file-1.py new file mode 100644 index 0000000000..8853b9facd --- /dev/null +++ b/Task/Read-entire-file/Python/read-entire-file-1.py @@ -0,0 +1 @@ +open(filename).read() diff --git a/Task/Read-entire-file/Python/read-entire-file-2.py b/Task/Read-entire-file/Python/read-entire-file-2.py new file mode 100644 index 0000000000..a004116385 --- /dev/null +++ b/Task/Read-entire-file/Python/read-entire-file-2.py @@ -0,0 +1 @@ +open(filename, encoding='utf-8').read() diff --git a/Task/Read-entire-file/R/read-entire-file.r b/Task/Read-entire-file/R/read-entire-file.r new file mode 100644 index 0000000000..8b1d0281a2 --- /dev/null +++ b/Task/Read-entire-file/R/read-entire-file.r @@ -0,0 +1,5 @@ +fname <- "notes.txt" +len <- file.info(fname)$size +conn <- file(fname, 'r') +contents <- readChar(conn, len) +close(conn) diff --git a/Task/Read-entire-file/REALbasic/read-entire-file.realbasic b/Task/Read-entire-file/REALbasic/read-entire-file.realbasic new file mode 100644 index 0000000000..a6ffbdae7d --- /dev/null +++ b/Task/Read-entire-file/REALbasic/read-entire-file.realbasic @@ -0,0 +1,11 @@ +Function readFile(theFile As FolderItem, txtEncode As TextEncoding = Nil) As String + Dim fileContents As String + Dim tis As TextInputStream + tis = tis.Open(theFile) + fileContents = tis.ReadAll(txtEncode) + tis.Close + Return fileContents + +Exception err As NilObjectException + MsgBox("File Not Found.") +End Function diff --git a/Task/Read-entire-file/REBOL/read-entire-file.rebol b/Task/Read-entire-file/REBOL/read-entire-file.rebol new file mode 100644 index 0000000000..3a2b67fe00 --- /dev/null +++ b/Task/Read-entire-file/REBOL/read-entire-file.rebol @@ -0,0 +1,2 @@ +read %my-file ; read as text +read/binary %my-file ; preserve contents exactly diff --git a/Task/Read-entire-file/REXX/read-entire-file.rexx b/Task/Read-entire-file/REXX/read-entire-file.rexx new file mode 100644 index 0000000000..a139dbb705 --- /dev/null +++ b/Task/Read-entire-file/REXX/read-entire-file.rexx @@ -0,0 +1,9 @@ +/*REXX program to read a file and store it as a continuous char string. */ + +iFID = 'a_file' /*name of the input file. */ +aString = + + do while lines(iFID)\==0 /*read until finished. */ + aString = aString || linein(iFID) /*append input to Astring. */ + end /*while*/ + /*stick a fork in it, we're done.*/ diff --git a/Task/Read-entire-file/Racket/read-entire-file.rkt b/Task/Read-entire-file/Racket/read-entire-file.rkt new file mode 100644 index 0000000000..19b556e463 --- /dev/null +++ b/Task/Read-entire-file/Racket/read-entire-file.rkt @@ -0,0 +1 @@ +(file->string "foo.txt") diff --git a/Task/Read-entire-file/Retro/read-entire-file.retro b/Task/Read-entire-file/Retro/read-entire-file.retro new file mode 100644 index 0000000000..a2d95b1d28 --- /dev/null +++ b/Task/Read-entire-file/Retro/read-entire-file.retro @@ -0,0 +1,2 @@ +with files' +here "input.txt" slurp diff --git a/Task/Read-entire-file/Ruby/read-entire-file-1.rb b/Task/Read-entire-file/Ruby/read-entire-file-1.rb new file mode 100644 index 0000000000..089f7013c4 --- /dev/null +++ b/Task/Read-entire-file/Ruby/read-entire-file-1.rb @@ -0,0 +1,5 @@ +# Read entire text file. +str = IO.read "foobar.txt" + +# It can also read a subprocess. +str = IO.read "| grep ftp /etc/services" diff --git a/Task/Read-entire-file/Ruby/read-entire-file-2.rb b/Task/Read-entire-file/Ruby/read-entire-file-2.rb new file mode 100644 index 0000000000..db2f29ee44 --- /dev/null +++ b/Task/Read-entire-file/Ruby/read-entire-file-2.rb @@ -0,0 +1,2 @@ +path = "|strange-name.txt" +str = File.open(path) {|f| f.read} diff --git a/Task/Read-entire-file/Ruby/read-entire-file-3.rb b/Task/Read-entire-file/Ruby/read-entire-file-3.rb new file mode 100644 index 0000000000..0887d6954e --- /dev/null +++ b/Task/Read-entire-file/Ruby/read-entire-file-3.rb @@ -0,0 +1,2 @@ +# Read entire binary file. +str = File.open(path, "rb") {|f| f.read} diff --git a/Task/Read-entire-file/Ruby/read-entire-file-4.rb b/Task/Read-entire-file/Ruby/read-entire-file-4.rb new file mode 100644 index 0000000000..891b2d9d7d --- /dev/null +++ b/Task/Read-entire-file/Ruby/read-entire-file-4.rb @@ -0,0 +1,5 @@ +# Read EUC-JP text from file. +str = File.open(path, "r:euc-jp") {|f| f.read} + +# Read EUC-JP text from file; transcode text from EUC-JP to UTF-8. +str = File.open(path, "r:euc-jp:utf-8") {|f| f.read} diff --git a/Task/Read-entire-file/SNOBOL4/read-entire-file.sno b/Task/Read-entire-file/SNOBOL4/read-entire-file.sno new file mode 100644 index 0000000000..6527dfc476 --- /dev/null +++ b/Task/Read-entire-file/SNOBOL4/read-entire-file.sno @@ -0,0 +1,6 @@ + input(.inbin,21,"filename.txt [-r524288]") :f(end) +rdlp buf = inbin :s(rdlp) +* +* now process the 'buf' containing the file +* +end diff --git a/Task/Read-entire-file/Smalltalk/read-entire-file-1.st b/Task/Read-entire-file/Smalltalk/read-entire-file-1.st new file mode 100644 index 0000000000..e21fb1cfd7 --- /dev/null +++ b/Task/Read-entire-file/Smalltalk/read-entire-file-1.st @@ -0,0 +1 @@ +(StandardFileStream oldFileNamed: 'foo.txt') contents diff --git a/Task/Read-entire-file/Smalltalk/read-entire-file-2.st b/Task/Read-entire-file/Smalltalk/read-entire-file-2.st new file mode 100644 index 0000000000..cea877f89b --- /dev/null +++ b/Task/Read-entire-file/Smalltalk/read-entire-file-2.st @@ -0,0 +1 @@ +'foo.txt' asFilename contentsAsString diff --git a/Task/Read-entire-file/TUSCRIPT/read-entire-file.tuscript b/Task/Read-entire-file/TUSCRIPT/read-entire-file.tuscript new file mode 100644 index 0000000000..68a469db05 --- /dev/null +++ b/Task/Read-entire-file/TUSCRIPT/read-entire-file.tuscript @@ -0,0 +1,3 @@ +$$ MODE TUSCRIPT +ERROR/STOP OPEN ("rosetta.txt",READ,-std-) +var=FILE ("rosetta.txt") diff --git a/Task/Read-entire-file/TXR/read-entire-file.txr b/Task/Read-entire-file/TXR/read-entire-file.txr new file mode 100644 index 0000000000..870b5a2132 --- /dev/null +++ b/Task/Read-entire-file/TXR/read-entire-file.txr @@ -0,0 +1,3 @@ +@(next "foo.txt") +@(freeform) +@LINE diff --git a/Task/Read-entire-file/Tcl/read-entire-file-1.tcl b/Task/Read-entire-file/Tcl/read-entire-file-1.tcl new file mode 100644 index 0000000000..476078365d --- /dev/null +++ b/Task/Read-entire-file/Tcl/read-entire-file-1.tcl @@ -0,0 +1,3 @@ +set f [open $filename] +set data [read $f] +close $f diff --git a/Task/Read-entire-file/Tcl/read-entire-file-2.tcl b/Task/Read-entire-file/Tcl/read-entire-file-2.tcl new file mode 100644 index 0000000000..9b57248553 --- /dev/null +++ b/Task/Read-entire-file/Tcl/read-entire-file-2.tcl @@ -0,0 +1,3 @@ +set f [open $filename "rb"] +set data [read $f] +close $f diff --git a/Task/Read-entire-file/UNIX-Shell/read-entire-file-1.sh b/Task/Read-entire-file/UNIX-Shell/read-entire-file-1.sh new file mode 100644 index 0000000000..d1ed6bc7fc --- /dev/null +++ b/Task/Read-entire-file/UNIX-Shell/read-entire-file-1.sh @@ -0,0 +1,2 @@ +f=`cat foo.txt` # f will contain the entire contents of the file +printf '%s\n' "$f" diff --git a/Task/Read-entire-file/UNIX-Shell/read-entire-file-2.sh b/Task/Read-entire-file/UNIX-Shell/read-entire-file-2.sh new file mode 100644 index 0000000000..12801dc123 --- /dev/null +++ b/Task/Read-entire-file/UNIX-Shell/read-entire-file-2.sh @@ -0,0 +1,2 @@ +f=$(cat foo.txt) +printf '%s\n' "$f" diff --git a/Task/Read-entire-file/UNIX-Shell/read-entire-file-3.sh b/Task/Read-entire-file/UNIX-Shell/read-entire-file-3.sh new file mode 100644 index 0000000000..5d96af9d15 --- /dev/null +++ b/Task/Read-entire-file/UNIX-Shell/read-entire-file-3.sh @@ -0,0 +1,2 @@ +f=$(e (base of the natural logarithm) +*\pi +*square root +*logarithm (any base allowed) +*exponential (e^x) +*absolute value (a.k.a. "magnitude") +*floor (largest integer less than or equal to this number--not the same as truncate or int) +*ceiling (smallest integer not less than this number--not the same as round up) +*power (x^y) + +See also [[Trigonometric Functions]] diff --git a/Task/Real-constants-and-functions/1META.yaml b/Task/Real-constants-and-functions/1META.yaml new file mode 100644 index 0000000000..a4efa5b7bb --- /dev/null +++ b/Task/Real-constants-and-functions/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Arithmetic operations +note: Basic language learning diff --git a/Task/Real-constants-and-functions/ACL2/real-constants-and-functions.acl2 b/Task/Real-constants-and-functions/ACL2/real-constants-and-functions.acl2 new file mode 100644 index 0000000000..d2820240ca --- /dev/null +++ b/Task/Real-constants-and-functions/ACL2/real-constants-and-functions.acl2 @@ -0,0 +1,11 @@ +define floor(x); + if x < 0 then + -intof(x); + else + intof(x); + endif; +enddefine; + +define ceiling(x); + -floor(-x); +enddefine; diff --git a/Task/Real-constants-and-functions/ALGOL-68/real-constants-and-functions.alg b/Task/Real-constants-and-functions/ALGOL-68/real-constants-and-functions.alg new file mode 100644 index 0000000000..580e90dc54 --- /dev/null +++ b/Task/Real-constants-and-functions/ALGOL-68/real-constants-and-functions.alg @@ -0,0 +1,13 @@ +REAL x:=exp(1), y:=4*atan(1); +printf(($g(-8,5)"; "$, + exp(1), # e # + pi, # pi # + sqrt(x), # square root # + log(x), # logarithm base 10 # + ln(x), # natural logarithm # + exp(x), # exponential # + ABS x, # absolute value # + ENTIER x, # floor # + -ENTIER -x, # ceiling # + x ** y # power # +)) diff --git a/Task/Real-constants-and-functions/AWK/real-constants-and-functions-1.awk b/Task/Real-constants-and-functions/AWK/real-constants-and-functions-1.awk new file mode 100644 index 0000000000..79bf687fa1 --- /dev/null +++ b/Task/Real-constants-and-functions/AWK/real-constants-and-functions-1.awk @@ -0,0 +1,7 @@ +BEGIN { + print sqrt(2) # square root + print log(2) # logarithm base e + print exp(2) # exponential + print 2 ^ -3.4 # power +} +# outputs 1.41421, 0.693147, 7.38906, 0.0947323 diff --git a/Task/Real-constants-and-functions/AWK/real-constants-and-functions-2.awk b/Task/Real-constants-and-functions/AWK/real-constants-and-functions-2.awk new file mode 100644 index 0000000000..2bfb45220a --- /dev/null +++ b/Task/Real-constants-and-functions/AWK/real-constants-and-functions-2.awk @@ -0,0 +1,27 @@ +BEGIN { + E = exp(1) + PI = atan2(0, -1) +} + +function abs(x) { + return x < 0 ? -x : x +} + +function floor(x) { + y = int(x) + return y > x ? y - 1 : y +} + +function ceil(x) { + y = int(x) + return y < x ? y + 1 : y +} + +BEGIN { + print E + print PI + print abs(-3.4) # absolute value + print floor(-3.4) # floor + print ceil(-3.4) # ceiling +} +# outputs 2.71828, 3.14159, 3.4, -4, -3 diff --git a/Task/Real-constants-and-functions/ActionScript/real-constants-and-functions-1.as b/Task/Real-constants-and-functions/ActionScript/real-constants-and-functions-1.as new file mode 100644 index 0000000000..3c544965b6 --- /dev/null +++ b/Task/Real-constants-and-functions/ActionScript/real-constants-and-functions-1.as @@ -0,0 +1,9 @@ +Math.E; //e +Math.PI; //pi +Math.sqrt(u); //square root of u +Math.log(u); //natural logarithm of u +Math.exp(u); //e to the power of u +Math.abs(u); //absolute value of u +Math.floor(u);//floor of u +Math.ceil(u); //ceiling of u +Math.pow(u,v);//u to the power of v diff --git a/Task/Real-constants-and-functions/ActionScript/real-constants-and-functions-2.as b/Task/Real-constants-and-functions/ActionScript/real-constants-and-functions-2.as new file mode 100644 index 0000000000..02c9de8d7f --- /dev/null +++ b/Task/Real-constants-and-functions/ActionScript/real-constants-and-functions-2.as @@ -0,0 +1,6 @@ +Math.LN10; // natural logarithm of 10 +Math.LN2; // natural logarithm of 2 +Math.LOG10E; // base-10 logarithm of e +Math.LOG2E; // base-2 logarithm of e +Math.SQRT1_2;// square root of 1/2 +Math.SQRT2; //square root of 2 diff --git a/Task/Real-constants-and-functions/Ada/real-constants-and-functions.ada b/Task/Real-constants-and-functions/Ada/real-constants-and-functions.ada new file mode 100644 index 0000000000..8ccf972f58 --- /dev/null +++ b/Task/Real-constants-and-functions/Ada/real-constants-and-functions.ada @@ -0,0 +1,9 @@ +Ada.Numerics.e -- Euler's number +Ada.Numerics.pi -- pi +sqrt(x) -- square root +log(x, base) -- logarithm to any specified base +exp(x) -- exponential +abs(x) -- absolute value +S'floor(x) -- Produces the floor of an instance of subtype S +S'ceiling(x) -- Produces the ceiling of an instance of subtype S +x**y -- x raised to the y power diff --git a/Task/Real-constants-and-functions/AutoHotkey/real-constants-and-functions-1.ahk b/Task/Real-constants-and-functions/AutoHotkey/real-constants-and-functions-1.ahk new file mode 100644 index 0000000000..95ce13e7d5 --- /dev/null +++ b/Task/Real-constants-and-functions/AutoHotkey/real-constants-and-functions-1.ahk @@ -0,0 +1,7 @@ +Sqrt(Number) ; square root +Log(Number) ; returns logarithm (base 10) +Ln(Number) ; returns natural logarithm (base e) +Exp(N) ; returns e to the N power +Abs(Number) ; absolute value +Floor(Number) ; floor value +Ceil(Number) ; ceiling value diff --git a/Task/Real-constants-and-functions/AutoHotkey/real-constants-and-functions-2.ahk b/Task/Real-constants-and-functions/AutoHotkey/real-constants-and-functions-2.ahk new file mode 100644 index 0000000000..9bf922dfc5 --- /dev/null +++ b/Task/Real-constants-and-functions/AutoHotkey/real-constants-and-functions-2.ahk @@ -0,0 +1,4 @@ +x**y ; x to the y power +pi() { ; will return pi when custom function is called +return 22/7 +} diff --git a/Task/Real-constants-and-functions/AutoHotkey/real-constants-and-functions-3.ahk b/Task/Real-constants-and-functions/AutoHotkey/real-constants-and-functions-3.ahk new file mode 100644 index 0000000000..84fde2ebaf --- /dev/null +++ b/Task/Real-constants-and-functions/AutoHotkey/real-constants-and-functions-3.ahk @@ -0,0 +1,6 @@ +Sin(Number) ; sine +Cos(Number) ; cosine +Tan(Number) ; tangent +ASin(Number) ; arcsine +ACos(Number) ; arccosine +ATan(Number) ; arctangent diff --git a/Task/Real-constants-and-functions/BASIC/real-constants-and-functions.basic b/Task/Real-constants-and-functions/BASIC/real-constants-and-functions.basic new file mode 100644 index 0000000000..7636735e14 --- /dev/null +++ b/Task/Real-constants-and-functions/BASIC/real-constants-and-functions.basic @@ -0,0 +1,6 @@ +abs(x) 'absolute value +sqr(x) 'square root +exp(x) 'exponential +log(x) 'natural logarithm +x ^ y 'power +'floor, ceiling, e, and pi not available diff --git a/Task/Real-constants-and-functions/BBC-BASIC/real-constants-and-functions.bbc b/Task/Real-constants-and-functions/BBC-BASIC/real-constants-and-functions.bbc new file mode 100644 index 0000000000..807828f248 --- /dev/null +++ b/Task/Real-constants-and-functions/BBC-BASIC/real-constants-and-functions.bbc @@ -0,0 +1,13 @@ + e = EXP(1) + Pi = PI + Sqr2 = SQR(2) + Ln2 = LN(2) + Log2 = LOG(2) : REM Base 10 + Exp2 = EXP(2) + Abs2 = ABS(-2) + Floor = INT(1.234) + Ceil = FNceil(1.234) + Power = 1.23^4 + END + + DEF FNceil(n) = INT(n) - (INT(n) <> n) diff --git a/Task/Real-constants-and-functions/C++/real-constants-and-functions.cpp b/Task/Real-constants-and-functions/C++/real-constants-and-functions.cpp new file mode 100644 index 0000000000..ee7041baa0 --- /dev/null +++ b/Task/Real-constants-and-functions/C++/real-constants-and-functions.cpp @@ -0,0 +1,28 @@ +#include +#include + +#ifdef M_E +static double euler_e = M_E; +#else +static double euler_e = std::exp(1); // standard fallback +#endif + +#ifdef M_PI +static double pi = M_PI; +#else +static double pi = std::acos(-1); +#endif + +int main() +{ + std::cout << "e = " << euler_e + << "\npi = " << pi + << "\nsqrt(2) = " << std::sqrt(2.0) + << "\nln(e) = " << std::log(e) + << "\nlg(100) = " << std::log10(100.0) + << "\nexp(3) = " << std::exp(3.0) + << "\n|-4.5| = " << std::abs(-4.5) // or std::fabs(4.0); both work in C++ + << "\nfloor(4.5) = " << std::floor(4.5) + << "\nceiling(4.5) = " << std::ceil(4.5) + << "\npi^2 = " << std::pow(pi,2.0) << std::endl; +} diff --git a/Task/Real-constants-and-functions/C-sharp/real-constants-and-functions.cs b/Task/Real-constants-and-functions/C-sharp/real-constants-and-functions.cs new file mode 100644 index 0000000000..b9ad9ade0c --- /dev/null +++ b/Task/Real-constants-and-functions/C-sharp/real-constants-and-functions.cs @@ -0,0 +1,16 @@ +using System; + +class Program { + static void Main(string[] args) { + Console.WriteLine(Math.E); //E + Console.WriteLine(Math.PI); //PI + Console.WriteLine(Math.Sqrt(10)); //Square Root + Console.WriteLine(Math.Log(10)); // Logarithm + Console.WriteLine(Math.Log10(10)); // Base 10 Logarithm + Console.WriteLine(Math.Exp(10)); // Exponential + Console.WriteLine(Math.Abs(10)); //Absolute value + Console.WriteLine(Math.Floor(10.0)); //Floor + Console.WriteLine(Math.Ceiling(10.0)); //Ceiling + Console.WriteLine(Math.Pow(2, 5)); // Exponentiation + } +} diff --git a/Task/Real-constants-and-functions/C/real-constants-and-functions.c b/Task/Real-constants-and-functions/C/real-constants-and-functions.c new file mode 100644 index 0000000000..0e15d15d8a --- /dev/null +++ b/Task/Real-constants-and-functions/C/real-constants-and-functions.c @@ -0,0 +1,12 @@ +#include + +M_E; /* e - not standard but offered by most implementations */ +M_PI; /* pi - not standard but offered by most implementations */ +sqrt(x); /* square root--cube root also available in C99 (cbrt) */ +log(x); /* natural logarithm--log base 10 also available (log10) */ +exp(x); /* exponential */ +abs(x); /* absolute value (for integers) */ +fabs(x); /* absolute value (for doubles) */ +floor(x); /* floor */ +ceil(x); /* ceiling */ +pow(x,y); /* power */ diff --git a/Task/Real-constants-and-functions/Clojure/real-constants-and-functions-1.clj b/Task/Real-constants-and-functions/Clojure/real-constants-and-functions-1.clj new file mode 100644 index 0000000000..da6ea613c3 --- /dev/null +++ b/Task/Real-constants-and-functions/Clojure/real-constants-and-functions-1.clj @@ -0,0 +1,9 @@ +(Math/E); //e +(Math/PI); //pi +(Math/sqrt x); //square root--cube root also available (cbrt) +(Math/log x); //natural logarithm--log base 10 also available (log10) +(Math/exp x); //exponential +(Math/abs x); //absolute value +(Math/floor x); //floor +(Math/ceil x); //ceiling +(Math/pow x y); //power diff --git a/Task/Real-constants-and-functions/Clojure/real-constants-and-functions-2.clj b/Task/Real-constants-and-functions/Clojure/real-constants-and-functions-2.clj new file mode 100644 index 0000000000..17f647957a --- /dev/null +++ b/Task/Real-constants-and-functions/Clojure/real-constants-and-functions-2.clj @@ -0,0 +1,6 @@ +(ns user (:require [clojure.contrib.math :as math])) +(math/sqrt x) +(math/abs x) +(math/floor x) +(math/ceil x) +(math/expt x y) diff --git a/Task/Real-constants-and-functions/Clojure/real-constants-and-functions-3.clj b/Task/Real-constants-and-functions/Clojure/real-constants-and-functions-3.clj new file mode 100644 index 0000000000..a09a11927e --- /dev/null +++ b/Task/Real-constants-and-functions/Clojure/real-constants-and-functions-3.clj @@ -0,0 +1,8 @@ +(ns user (:require [clojure.contrib.generic.math-functions :as generic])) +(generic/sqrt x) +(generic/log x) +(generic/exp x) +(generic/abs x) +(generic/floor x) +(generic/ceil x) +(generic/pow x y) diff --git a/Task/Real-constants-and-functions/Common-Lisp/real-constants-and-functions.lisp b/Task/Real-constants-and-functions/Common-Lisp/real-constants-and-functions.lisp new file mode 100644 index 0000000000..cd710d50c6 --- /dev/null +++ b/Task/Real-constants-and-functions/Common-Lisp/real-constants-and-functions.lisp @@ -0,0 +1,10 @@ +(exp 1) ; e (Euler's number) +pi ; pi constant +(sqrt x) ; square root: works for negative reals and complex +(log x) ; natural logarithm: works for negative reals and complex +(log x 10) ; logarithm base 10 +(exp x) ; exponential +(abs x) ; absolute value: result exact if input exact: (abs -1/3) -> 1/3. +(floor x) ; floor: restricted to real, two valued (second value gives residue) +(ceiling x) ; ceiling: restricted to real, two valued (second value gives residue) +(expt x y) ; power diff --git a/Task/Real-constants-and-functions/D/real-constants-and-functions.d b/Task/Real-constants-and-functions/D/real-constants-and-functions.d new file mode 100644 index 0000000000..fc0a78f252 --- /dev/null +++ b/Task/Real-constants-and-functions/D/real-constants-and-functions.d @@ -0,0 +1,12 @@ +import std.math ; // need to import this module +E // Euler's number +PI // pi constant +sqrt(x) // square root +log(x) // natural logarithm +log10(x) // logarithm base 10 +log2(x) // logarithm base 2 +exp(x) // exponential +abs(x) // absolute value (= magnitude for complex) +floor(x) // floor +ceil(x) // ceiling +pow(x,y) // power diff --git a/Task/Real-constants-and-functions/Delphi/real-constants-and-functions.delphi b/Task/Real-constants-and-functions/Delphi/real-constants-and-functions.delphi new file mode 100644 index 0000000000..fc6379a6c0 --- /dev/null +++ b/Task/Real-constants-and-functions/Delphi/real-constants-and-functions.delphi @@ -0,0 +1,12 @@ +Exp(1); // e (Euler's number) +Pi; // π (Pi) +Sqrt(x); // square root +LogN(BASE, x) // log of x for a specified base +Log2(x) // log of x for base 2 +Log10(x) // log of x for base 10 +Ln(x); // natural logarithm (for good measure) +Exp(x); // exponential +Abs(x); // absolute value (a.k.a. "magnitude") +Floor(x); // floor +Ceil(x); // ceiling +Power(x, y); // power diff --git a/Task/Real-constants-and-functions/E/real-constants-and-functions.e b/Task/Real-constants-and-functions/E/real-constants-and-functions.e new file mode 100644 index 0000000000..d5bb9e468e --- /dev/null +++ b/Task/Real-constants-and-functions/E/real-constants-and-functions.e @@ -0,0 +1,26 @@ +? 1.0.exp() +# value: 2.7182818284590455 + +? 0.0.acos() * 2 +# value: 3.141592653589793 + +? 2.0.sqrt() +# value: 1.4142135623730951 + +? 2.0.log() +# value: 0.6931471805599453 + +? 5.0.exp() +# value: 148.4131591025766 + +? (-5).abs() +# value: 5 + +? 1.2.floor() +# value: 1 + +? 1.2.ceil() +# value: 2 + +? 10 ** 6 +# value: 1000000 diff --git a/Task/Real-constants-and-functions/Factor/real-constants-and-functions.factor b/Task/Real-constants-and-functions/Factor/real-constants-and-functions.factor new file mode 100644 index 0000000000..986d59c42e --- /dev/null +++ b/Task/Real-constants-and-functions/Factor/real-constants-and-functions.factor @@ -0,0 +1,11 @@ +e ! e +pi ! π +sqrt ! square root +log ! natural logarithm +exp ! exponentiation +abs ! absolute value +floor ! greatest whole number smaller than or equal +ceiling ! smallest whole number greater than or equal +truncate ! remove the fractional part (i.e. round towards 0) +round ! round to next whole number +^ ! power diff --git a/Task/Real-constants-and-functions/Fantom/real-constants-and-functions.fantom b/Task/Real-constants-and-functions/Fantom/real-constants-and-functions.fantom new file mode 100644 index 0000000000..a1d123f1c9 --- /dev/null +++ b/Task/Real-constants-and-functions/Fantom/real-constants-and-functions.fantom @@ -0,0 +1,11 @@ +Float.e +Float.pi +9f.sqrt +9f.log // natural logarithm +9f.log10 // logarithm to base 10 +9f.exp // exponentiation +(-3f).abs // absolute value, note bracket +3.2f.floor // nearest Int smaller than this number +3.2f.ceil // nearest Int bigger than this number +3.2f.round // nearest Int +3f.pow(2f) // power diff --git a/Task/Real-constants-and-functions/Forth/real-constants-and-functions.fth b/Task/Real-constants-and-functions/Forth/real-constants-and-functions.fth new file mode 100644 index 0000000000..267f160299 --- /dev/null +++ b/Task/Real-constants-and-functions/Forth/real-constants-and-functions.fth @@ -0,0 +1,9 @@ +1e fexp fconstant e +0e facos 2e f* fconstant pi \ predefined in gforth +fsqrt ( f -- f ) +fln ( f -- f ) \ flog for base 10 +fexp ( f -- f ) +fabs ( f -- f ) +floor ( f -- f ) \ round towards -inf +: ceil ( f -- f ) fnegate floor fnegate ; \ not standard, though fround is available +f** ( f e -- f^e ) diff --git a/Task/Real-constants-and-functions/Fortran/real-constants-and-functions.f b/Task/Real-constants-and-functions/Fortran/real-constants-and-functions.f new file mode 100644 index 0000000000..f18f0d3e26 --- /dev/null +++ b/Task/Real-constants-and-functions/Fortran/real-constants-and-functions.f @@ -0,0 +1,10 @@ +e ! Not available. Can be calculated EXP(1) +pi ! Not available. Can be calculated 4.0*ATAN(1.0) +SQRT(x) ! square root +LOG(x) ! natural logarithm +LOG10(x) ! logarithm to base 10 +EXP(x) ! exponential +ABS(x) ! absolute value +FLOOR(x) ! floor - Fortran 90 or later only +CEILING(x) ! ceiling - Fortran 90 or later only +x**y ! x raised to the y power diff --git a/Task/Real-constants-and-functions/Go/real-constants-and-functions.go b/Task/Real-constants-and-functions/Go/real-constants-and-functions.go new file mode 100644 index 0000000000..e39b7a3af1 --- /dev/null +++ b/Task/Real-constants-and-functions/Go/real-constants-and-functions.go @@ -0,0 +1,18 @@ +import "math" + +// e and pi defined as constants. +// In Go, that means they are not of a specific data type and can be used as float32 or float64. +math.E +math.Pi + +// The following functions all take and return the float64 data type. + +math.Sqrt(x) // square root--cube root also available (math.Cbrt) +// natural logarithm--log base 10, 2 also available (math.Log10, math.Log2) +// also available is log1p, the log of 1+x. It is more accurate when x is near zero. +math.Log(x) +math.Exp(x) // exponential--exp base 10, 2 also available (math.Pow10, math.Exp2) +math.Abs(x) // absolute value +math.Floor(x) // floor +math.Ceil(x) // ceiling +math.Pow(x,y) // power diff --git a/Task/Real-constants-and-functions/Groovy/real-constants-and-functions-1.groovy b/Task/Real-constants-and-functions/Groovy/real-constants-and-functions-1.groovy new file mode 100644 index 0000000000..dee7727fc9 --- /dev/null +++ b/Task/Real-constants-and-functions/Groovy/real-constants-and-functions-1.groovy @@ -0,0 +1 @@ +println ((-22).abs()) diff --git a/Task/Real-constants-and-functions/Groovy/real-constants-and-functions-2.groovy b/Task/Real-constants-and-functions/Groovy/real-constants-and-functions-2.groovy new file mode 100644 index 0000000000..d52a4023a8 --- /dev/null +++ b/Task/Real-constants-and-functions/Groovy/real-constants-and-functions-2.groovy @@ -0,0 +1 @@ +println 22**3.5 diff --git a/Task/Real-constants-and-functions/Groovy/real-constants-and-functions-3.groovy b/Task/Real-constants-and-functions/Groovy/real-constants-and-functions-3.groovy new file mode 100644 index 0000000000..0135ecd346 --- /dev/null +++ b/Task/Real-constants-and-functions/Groovy/real-constants-and-functions-3.groovy @@ -0,0 +1 @@ +println ((-22)**3.5) diff --git a/Task/Real-constants-and-functions/Haskell/real-constants-and-functions.hs b/Task/Real-constants-and-functions/Haskell/real-constants-and-functions.hs new file mode 100644 index 0000000000..6c3b44ce7d --- /dev/null +++ b/Task/Real-constants-and-functions/Haskell/real-constants-and-functions.hs @@ -0,0 +1,11 @@ +exp 1 -- Euler number +pi -- pi +sqrt x -- square root +log x -- natural logarithm +exp x -- exponential +abs x -- absolute value +floor x -- floor +ceiling x -- ceiling +x ** y -- power (e.g. floating-point exponentiation) +x ^ y -- power (e.g. integer exponentiation, nonnegative y only) +x ^^ y -- power (e.g. integer exponentiation of rationals, also negative y) diff --git a/Task/Real-constants-and-functions/HicEst/real-constants-and-functions-1.hicest b/Task/Real-constants-and-functions/HicEst/real-constants-and-functions-1.hicest new file mode 100644 index 0000000000..c00943f061 --- /dev/null +++ b/Task/Real-constants-and-functions/HicEst/real-constants-and-functions-1.hicest @@ -0,0 +1,11 @@ +e ! Not available. Can be calculated EXP(1) +pi ! Not available. Can be calculated 4.0*ATAN(1.0) +x^0.5 ! square root +LOG(x) ! natural logarithm +LOG(x, 10) ! logarithm to base 10 +EXP(x) ! exponential +ABS(x) ! absolute value +FLOOR(x) ! floor +CEILING(x) ! ceiling +x**y ! x raised to the y power +x^y ! same as x**y diff --git a/Task/Real-constants-and-functions/HicEst/real-constants-and-functions-2.hicest b/Task/Real-constants-and-functions/HicEst/real-constants-and-functions-2.hicest new file mode 100644 index 0000000000..eece771615 --- /dev/null +++ b/Task/Real-constants-and-functions/HicEst/real-constants-and-functions-2.hicest @@ -0,0 +1,15 @@ +link numbers # for floor and ceil + +procedure main() +write("e=",&e) +write("pi=",&pi) +write("phi=",&phi) +write("sqrt(2)=",sqrt(2.0)) +write("log(e)=",log(&e)) +write("log(100.,10)=",log(100,10)) +write("exp(1)=",exp(1.0)) +write("abs(-2)=",abs(-2)) +write("floor(-2.2)=",floor(-2.2)) +write("ceil(-2.2)=",ceil(-2.2)) +write("power: 3^3=",3^3) +end diff --git a/Task/Real-constants-and-functions/J/real-constants-and-functions.j b/Task/Real-constants-and-functions/J/real-constants-and-functions.j new file mode 100644 index 0000000000..bc4b1d9115 --- /dev/null +++ b/Task/Real-constants-and-functions/J/real-constants-and-functions.j @@ -0,0 +1,14 @@ +e =. 1x1 NB. Euler's number, specified as a numeric literal. +e =. ^ 1 NB. Euler's number, computed by exponentiation. +pi=. 1p1 NB. pi, specified as a numeric literal. +pi=. o.1 NB. pi, computed trigonometrically. +magnitude_of_x =. |x +floor_of_x =. <.x +ceiling_of_x =. >.x +natural_log_of_x =. ^.x +base_x_log_of_y =. x^.y +x_squared =. *:x NB. special form +x_squared =. x^2 NB. exponential form +square_root_of_x =. %:x NB. special form +square_root_of_x =. x^0.5 NB. exponential form +x_to_the_y_power =. x^y diff --git a/Task/Real-constants-and-functions/Java/real-constants-and-functions.java b/Task/Real-constants-and-functions/Java/real-constants-and-functions.java new file mode 100644 index 0000000000..40089414bc --- /dev/null +++ b/Task/Real-constants-and-functions/Java/real-constants-and-functions.java @@ -0,0 +1,9 @@ +Math.E; //e +Math.PI; //pi +Math.sqrt(x); //square root--cube root also available (cbrt) +Math.log(x); //natural logarithm--log base 10 also available (log10) +Math.exp(x); //exponential +Math.abs(x); //absolute value +Math.floor(x); //floor +Math.ceil(x); //ceiling +Math.pow(x,y); //power diff --git a/Task/Real-constants-and-functions/JavaScript/real-constants-and-functions.js b/Task/Real-constants-and-functions/JavaScript/real-constants-and-functions.js new file mode 100644 index 0000000000..1d14fa68e0 --- /dev/null +++ b/Task/Real-constants-and-functions/JavaScript/real-constants-and-functions.js @@ -0,0 +1,9 @@ +Math.E +Math.PI +Math.sqrt(x) +Math.log(x) +Math.exp(x) +Math.abs(x) +Math.floor(x) +Math.ceil(x) +Math.pow(x,y) diff --git a/Task/Real-constants-and-functions/Liberty-BASIC/real-constants-and-functions.liberty b/Task/Real-constants-and-functions/Liberty-BASIC/real-constants-and-functions.liberty new file mode 100644 index 0000000000..f3022653fc --- /dev/null +++ b/Task/Real-constants-and-functions/Liberty-BASIC/real-constants-and-functions.liberty @@ -0,0 +1,32 @@ +print exp( 1) ' e not available +print 4 *atn( 1) ' pi not available + +x =12.345: y =1.23 + +print sqr( x), x^0.5 ' square root- NB the unusual name +print log( x) ' natural logarithm base e +print log( x) /2.303 ' base 10 logarithm +print log( x) /log( y) ' arbitrary base logarithm +print exp( x) ' exponential +print abs( x) ' absolute value +print floor( x) ' floor +print ceiling( x) ' ceiling +print x^y ' power + +end + +function floor( x) + if x >0 then + floor =int( x) + else + if x <>int( x) then floor =int( x) -1 else floor =int( x) + end if +end function + +function ceiling( x) + if x <0 then + ceiling =int( x) + else + ceiling =int( x) +1 + end if +end function diff --git a/Task/Real-constants-and-functions/Logo/real-constants-and-functions.logo b/Task/Real-constants-and-functions/Logo/real-constants-and-functions.logo new file mode 100644 index 0000000000..4a025d2990 --- /dev/null +++ b/Task/Real-constants-and-functions/Logo/real-constants-and-functions.logo @@ -0,0 +1,7 @@ +make "e exp 1 +make "pi 2*(RADARCTAN 0 1) +sqrt :x +ln :x +exp :x +; there is no standard abs, floor, or ceiling; only INT and ROUND. +power :x :y diff --git a/Task/Real-constants-and-functions/Lua/real-constants-and-functions.lua b/Task/Real-constants-and-functions/Lua/real-constants-and-functions.lua new file mode 100644 index 0000000000..d9ddecdac1 --- /dev/null +++ b/Task/Real-constants-and-functions/Lua/real-constants-and-functions.lua @@ -0,0 +1,10 @@ +math.exp(1) +math.pi +math.sqrt(x) +math.log(x) +math.log10(x) +math.exp(x) +math.abs(x) +math.floor(x) +math.ceil(x) +x^y diff --git a/Task/Real-constants-and-functions/MAXScript/real-constants-and-functions.maxscript b/Task/Real-constants-and-functions/MAXScript/real-constants-and-functions.maxscript new file mode 100644 index 0000000000..89fdb37460 --- /dev/null +++ b/Task/Real-constants-and-functions/MAXScript/real-constants-and-functions.maxscript @@ -0,0 +1,9 @@ +e -- Euler's number +pi -- pi +log x -- natural logarithm +log10 x -- log base 10 +exp x -- exponantial +abs x -- absolute value +floor x -- floor +ceil x -- ceiling +pow x y -- power diff --git a/Task/Real-constants-and-functions/Maple/real-constants-and-functions.maple b/Task/Real-constants-and-functions/Maple/real-constants-and-functions.maple new file mode 100644 index 0000000000..65e8519cfe --- /dev/null +++ b/Task/Real-constants-and-functions/Maple/real-constants-and-functions.maple @@ -0,0 +1,2 @@ +> abs(ceil(floor(ln(exp(1)^sqrt(exp(Pi*I)+1))))); + 0 diff --git a/Task/Real-constants-and-functions/Mathematica/real-constants-and-functions-1.math b/Task/Real-constants-and-functions/Mathematica/real-constants-and-functions-1.math new file mode 100644 index 0000000000..7a6515820d --- /dev/null +++ b/Task/Real-constants-and-functions/Mathematica/real-constants-and-functions-1.math @@ -0,0 +1,10 @@ +E +Pi +Sqrt[x] +Log[x] +Log[b,x] +Exp[x] +Abs[x] +Floor[x] +Ceiling[x] +Power[x, y] diff --git a/Task/Real-constants-and-functions/Mathematica/real-constants-and-functions-2.math b/Task/Real-constants-and-functions/Mathematica/real-constants-and-functions-2.math new file mode 100644 index 0000000000..1df8b7f192 --- /dev/null +++ b/Task/Real-constants-and-functions/Mathematica/real-constants-and-functions-2.math @@ -0,0 +1,16 @@ +Log[1.23] => 0.207014 +Log[10] => Log[10] +Log[10,100] => 2 +Log[E^4] => 4 +Log[1 + I] => Log[1+I] +Log[1. + I] => 0.346574 + 0.785398 I +Ceiling[Pi] => 4 +Floor[Pi] => 3 +Sqrt[2] => Sqrt[2] +Sqrt[4] => 2 +Sqrt[9/2] => 3/Sqrt[2] +Sqrt[3.5] => 1.87083 +Sqrt[-5 + 12 I] => 2 + 3 I +Sqrt[-4] => 2I +Exp[2] => E^2 +Exp[Log[4]] => 4 diff --git a/Task/Real-constants-and-functions/Mercury/real-constants-and-functions.mercury b/Task/Real-constants-and-functions/Mercury/real-constants-and-functions.mercury new file mode 100644 index 0000000000..2f8df66a38 --- /dev/null +++ b/Task/Real-constants-and-functions/Mercury/real-constants-and-functions.mercury @@ -0,0 +1,12 @@ +math.pi % Pi. +math.e % Euler's number. +math.sqrt(X) % Square root of X. +math.ln(X) % Natural logarithm of X. +math.log10(X) % Logarithm to the base 10 of X. +math.log2(X) % Logarithm to the base 2 of X. +math.log(B, X) % Logarithm to the base B of X. +math.exp(X) % e raised to the power of X. +float.abs(X) % Absolute value of X. +math.floor(X) % Floor of X. +math.ceiling(X) % Ceiling of X. +math.pow(X, Y) % X raised to the power of Y. diff --git a/Task/Real-constants-and-functions/Metafont/real-constants-and-functions.metafont b/Task/Real-constants-and-functions/Metafont/real-constants-and-functions.metafont new file mode 100644 index 0000000000..54a4227ff0 --- /dev/null +++ b/Task/Real-constants-and-functions/Metafont/real-constants-and-functions.metafont @@ -0,0 +1,15 @@ +show mexp(256); % outputs e; since MF uses mexp(x) = exp(x/256) +show 3.14159; % no pi constant built in; of course we can define it + % in several ways... even computing + % C/2r (which would be funny since MF handles paths, + % and a circle is a path...) +show sqrt2; % 1.41422, or in general sqrt(a) +show mexp(256*x); % see e. +show abs(x); % returns |x| (the absolute value of the number x, or + % the length of the vector x); it is the same as + % length(x); plain Metafont in fact says: + % let abs = length; +show floor(x); % floor +show ceiling(x); % ceiling +show x**y; % ** is not a built in: it is defined in the basic macros + % set for Metafont (plain Metafont) as a primarydef diff --git a/Task/Real-constants-and-functions/Modula-3/real-constants-and-functions.mod3 b/Task/Real-constants-and-functions/Modula-3/real-constants-and-functions.mod3 new file mode 100644 index 0000000000..478d50878f --- /dev/null +++ b/Task/Real-constants-and-functions/Modula-3/real-constants-and-functions.mod3 @@ -0,0 +1,9 @@ +Math.E; +Math.Pi; +Math.sqrt(x); +Math.log(x); +Math.exp(x); +ABS(x); (* Built in function. *) +FLOOR(x); (* Built in function. *) +CEILING(x); (* Built in function. *) +Math.pow(x, y); diff --git a/Task/Real-constants-and-functions/NetRexx/real-constants-and-functions.netrexx b/Task/Real-constants-and-functions/NetRexx/real-constants-and-functions.netrexx new file mode 100644 index 0000000000..1e4428e494 --- /dev/null +++ b/Task/Real-constants-and-functions/NetRexx/real-constants-and-functions.netrexx @@ -0,0 +1,49 @@ +/* NetRexx */ +options replace format comments java crossref symbols nobinary utf8 + +numeric digits 30 + +x = 2.5 +y = 3 +pad = 40 +say +say 'Java Math constants & functions:' +say Rexx(' Euler''s number (e):').left(pad) Math.E +say Rexx(' Pi:').left(pad) Math.PI +say Rexx(' Square root of' x':').left(pad) Math.sqrt(x) +say Rexx(' Log(e) of' x':').left(pad) Math.log(x) +say Rexx(' Log(e) of e:').left(pad) Math.log(Math.E) +say Rexx(' Log(10) of' x':').left(pad) Math.log10(x) +say Rexx(' Log(10) of 10:').left(pad) Math.log10(10) +say Rexx(' Exponential (e**x) of' x':').left(pad) Math.exp(x) +say Rexx(' Exponential (e**x) of log(e)' x':').left(pad) Math.exp(Math.log(x)) +say Rexx(' Abs of' x':').left(pad) Math.abs(x.todouble) +say Rexx(' Abs of' (-x)':').left(pad) Math.abs((-x).todouble) +say Rexx(' Floor of' x':').left(pad) Math.floor(x) +say Rexx(' Floor of' (-x)':').left(pad) Math.floor((-x)) +say Rexx(' Ceiling of' x':').left(pad) Math.ceil(x) +say Rexx(' Ceiling of' (-x)':').left(pad) Math.ceil((-x)) +say Rexx(' ' x 'to the power of' y':').left(pad) Math.pow(x, y) +say Rexx(' ' x 'to the power of' 1 / y':').left(pad) Math.pow(x, 1 / y) +say Rexx(' 10 to the power of log10' x':').left(pad) Math.pow(10, Math.log10(x)) + +-- Extras +say Rexx(' Cube root of' x':').left(pad) Math.cbrt(x) +say Rexx(' Hypotenuse of' 3 'x' 4 'right triangle:').left(pad) Math.hypot(3, 4) +say Rexx(' Max of' (-x) '&' x':').left(pad) Math.max((-x).todouble, x) +say Rexx(' Min of' (-x) '&' x':').left(pad) Math.min((-x).todouble, x) +say Rexx(' Signum of' x':').left(pad) Math.signum((x).todouble) +say Rexx(' Signum of' x '-' x':').left(pad) Math.signum((x - x).todouble) +say Rexx(' Signum of' (-x)':').left(pad) Math.signum((-x).todouble) + +say +say 'NetRexx built-in support for numeric data:' +say Rexx(' Abs of' x':').left(pad) x.abs() +say Rexx(' Abs of' (-x)':').left(pad) (-x).abs() +say Rexx(' Sign of' x':').left(pad) x.sign() +say Rexx(' Sign of' x '-' x':').left(pad) (x - x).sign() +say Rexx(' Sign of' (-x)':').left(pad) (-x).sign() +say Rexx(' Max of' (-x) '&' x':').left(pad) (-x).max(x) +say Rexx(' Min of' (-x) '&' x':').left(pad) (-x).min(x) +say Rexx(' Truncate' x 'by' y':').left(pad) x.trunc(y) +say Rexx(' Format (with rounding)' x 'by' y':').left(pad) x.format(y, 0) diff --git a/Task/Real-constants-and-functions/OCaml/real-constants-and-functions.ocaml b/Task/Real-constants-and-functions/OCaml/real-constants-and-functions.ocaml new file mode 100644 index 0000000000..be649bb1e7 --- /dev/null +++ b/Task/Real-constants-and-functions/OCaml/real-constants-and-functions.ocaml @@ -0,0 +1,9 @@ +sqrt x (* square root *) +log x (* natural logarithm--log base 10 also available (log10) *) +exp x (* exponential *) +abs_float x (* absolute value *) +abs x (* absolute value (for integers) *) +floor x (* floor *) +ceil x (* ceiling *) +x ** y (* power *) +-. x (* negation for floats *) diff --git a/Task/Real-constants-and-functions/Objeck/real-constants-and-functions.objeck b/Task/Real-constants-and-functions/Objeck/real-constants-and-functions.objeck new file mode 100644 index 0000000000..e9ca8a3da0 --- /dev/null +++ b/Task/Real-constants-and-functions/Objeck/real-constants-and-functions.objeck @@ -0,0 +1,9 @@ +Float->Pi(); +Float->E(); +4.0->SquareRoot(); +1.5->Log(); +# exponential is not supported +3.99->Abs(); +3.99->Floor(); +3.99->Ceiling(); +4.5->Ceiling(2.0); diff --git a/Task/Real-constants-and-functions/Octave/real-constants-and-functions.octave b/Task/Real-constants-and-functions/Octave/real-constants-and-functions.octave new file mode 100644 index 0000000000..72ce62ba85 --- /dev/null +++ b/Task/Real-constants-and-functions/Octave/real-constants-and-functions.octave @@ -0,0 +1,9 @@ +e % e +pi % pi +sqrt(pi) % square root +log(e) % natural logarithm +exp(pi) % exponential +abs(-e) % absolute value +floor(pi) % floor +ceil(pi) % ceiling +e**pi % power diff --git a/Task/Real-constants-and-functions/Oz/real-constants-and-functions.oz b/Task/Real-constants-and-functions/Oz/real-constants-and-functions.oz new file mode 100644 index 0000000000..c0e3b63b8f --- /dev/null +++ b/Task/Real-constants-and-functions/Oz/real-constants-and-functions.oz @@ -0,0 +1,12 @@ +{ForAll + [ + {Exp 1.} %% 2.7183 Euler's number: not predefined + 4. * {Atan2 1. 1.} %% 3.1416 pi: not predefined + {Sqrt 81.} %% 9.0 square root; expects a float + {Log 2.7183} %% 1.0 natural logarithm + {Abs ~1} %% 1 absolute value; expects a float or an integer + {Floor 1.999} %% 1.0 floor; expects and returns a float + {Ceil 1.999} %% 2.0 ceiling; expects and returns a float + {Pow 2 3} %% 8 power; both arguments must be of the same type + ] + Show} diff --git a/Task/Real-constants-and-functions/PARI-GP/real-constants-and-functions.pari b/Task/Real-constants-and-functions/PARI-GP/real-constants-and-functions.pari new file mode 100644 index 0000000000..c1964b3a5e --- /dev/null +++ b/Task/Real-constants-and-functions/PARI-GP/real-constants-and-functions.pari @@ -0,0 +1 @@ +[exp(1), Pi, sqrt(2), log(2), abs(2), floor(2), ceil(2), 2^3] diff --git a/Task/Real-constants-and-functions/PHP/real-constants-and-functions.php b/Task/Real-constants-and-functions/PHP/real-constants-and-functions.php new file mode 100644 index 0000000000..23c2c8eb7a --- /dev/null +++ b/Task/Real-constants-and-functions/PHP/real-constants-and-functions.php @@ -0,0 +1,9 @@ +M_E; //e +M_PI; //pi +sqrt(x); //square root +log(x); //natural logarithm--log base 10 also available (log10) +exp(x); //exponential +abs(x); //absolute value +floor(x); //floor +ceil(x); //ceiling +pow(x,y); //power diff --git a/Task/Real-constants-and-functions/PL-I/real-constants-and-functions.pli b/Task/Real-constants-and-functions/PL-I/real-constants-and-functions.pli new file mode 100644 index 0000000000..0feeaa0c10 --- /dev/null +++ b/Task/Real-constants-and-functions/PL-I/real-constants-and-functions.pli @@ -0,0 +1,16 @@ +/* e not available other than by using exp(1q0).*/ +/* pi not available other than by using a trig function such as atan */ +y = sqrt(x); +y = log(x); +y = log2(x); +y = log10(x); +y = exp(x); +y = abs(x); +y = floor(x); +y = ceil(x); +a = x**y; /* power */ +/* extra functions: */ +y = erf(x); /* the error function. */ +y = erfc(x); /* the error function complemented. */ +y = gamma (x); +y = loggamma (x); diff --git a/Task/Real-constants-and-functions/Perl-6/real-constants-and-functions.pl6 b/Task/Real-constants-and-functions/Perl-6/real-constants-and-functions.pl6 new file mode 100644 index 0000000000..d2b65ffb29 --- /dev/null +++ b/Task/Real-constants-and-functions/Perl-6/real-constants-and-functions.pl6 @@ -0,0 +1,9 @@ +say e; # e +say pi; # pi +say sqrt 2; # Square root +say log 2; # Natural logarithm +say exp 42; # Exponentiation base e +say abs -2; # Absolute value +say floor pi; # Floor +say ceiling pi; # Ceiling +say 4**7; # Exponentiation diff --git a/Task/Real-constants-and-functions/Perl/real-constants-and-functions.pl b/Task/Real-constants-and-functions/Perl/real-constants-and-functions.pl new file mode 100644 index 0000000000..35610128b4 --- /dev/null +++ b/Task/Real-constants-and-functions/Perl/real-constants-and-functions.pl @@ -0,0 +1,11 @@ +use POSIX; # for floor() and ceil() + +exp(1); # e +4 * atan2(1, 1); # pi +sqrt($x); # square root +log($x); # natural logarithm; log10() available in POSIX module +exp($x); # exponential +abs($x); # absolute value +floor($x); # floor +ceil($x); # ceiling +$x ** $y; # power diff --git a/Task/Real-constants-and-functions/PicoLisp/real-constants-and-functions.l b/Task/Real-constants-and-functions/PicoLisp/real-constants-and-functions.l new file mode 100644 index 0000000000..4d8d55427f --- /dev/null +++ b/Task/Real-constants-and-functions/PicoLisp/real-constants-and-functions.l @@ -0,0 +1,16 @@ +(scl 12) # 12 places after decimal point +(load "@lib/math.l") + +(prinl (format (exp 1.0) *Scl)) # e, exp +(prinl (format pi *Scl)) # pi + +(prinl (format (pow 2.0 0.5) *Scl)) # sqare root +(prinl (format (sqrt (* 2.0 1.0)) *Scl)) + +(prinl (format (log 2.0) *Scl)) # logarithm +(prinl (format (exp 4.0) *Scl)) # exponential + +(prinl (format (abs -7.2) *Scl)) # absolute value +(prinl (abs -123)) + +(prinl (format (pow 3.0 4.0) *Scl)) # power diff --git a/Task/Real-constants-and-functions/Pop11/real-constants-and-functions.pop11 b/Task/Real-constants-and-functions/Pop11/real-constants-and-functions.pop11 new file mode 100644 index 0000000000..240edf298c --- /dev/null +++ b/Task/Real-constants-and-functions/Pop11/real-constants-and-functions.pop11 @@ -0,0 +1,6 @@ +pi ;;; Number Pi +sqrt(x) ;;; Square root +log(x) ;;; Natural logarithm +exp(x) ;;; Exponential function +abs(x) ;;; Absolute value +x ** y ;;; x to the power y diff --git a/Task/Real-constants-and-functions/PowerShell/real-constants-and-functions.psh b/Task/Real-constants-and-functions/PowerShell/real-constants-and-functions.psh new file mode 100644 index 0000000000..979ba96491 --- /dev/null +++ b/Task/Real-constants-and-functions/PowerShell/real-constants-and-functions.psh @@ -0,0 +1,9 @@ +Write-Host ([Math]::E) +Write-Host ([Math]::Pi) +Write-Host ([Math]::Sqrt(2)) +Write-Host ([Math]::Log(2)) +Write-Host ([Math]::Exp(2)) +Write-Host ([Math]::Abs(-2)) +Write-Host ([Math]::Floor(3.14)) +Write-Host ([Math]::Ceiling(3.14)) +Write-Host ([Math]::Pow(2, 3)) diff --git a/Task/Real-constants-and-functions/PureBasic/real-constants-and-functions.purebasic b/Task/Real-constants-and-functions/PureBasic/real-constants-and-functions.purebasic new file mode 100644 index 0000000000..d185bc4d75 --- /dev/null +++ b/Task/Real-constants-and-functions/PureBasic/real-constants-and-functions.purebasic @@ -0,0 +1,8 @@ +Debug #E +Debug #PI +Debug Sqr(f) +Debug Log(f) +Debug Exp(f) +Debug Log10(f) +Debug Abs(f) +Debug Pow(f,f) diff --git a/Task/Real-constants-and-functions/Python/real-constants-and-functions.py b/Task/Real-constants-and-functions/Python/real-constants-and-functions.py new file mode 100644 index 0000000000..05131b17a7 --- /dev/null +++ b/Task/Real-constants-and-functions/Python/real-constants-and-functions.py @@ -0,0 +1,16 @@ +import math + +math.e # e +math.pi # pi +math.sqrt(x) # square root (Also commonly seen as x ** 0.5 to obviate importing the math module) +math.log(x) # natural logarithm +math.log10(x) # base 10 logarithm +math.exp(x) # e raised to the power of x +abs(x) # absolute value +math.floor(x) # floor +math.ceil(x) # ceiling +x ** y # exponentiation +pow(x, y[, n]) # exponentiation [, modulo n (useful in certain encryption/decryption algorithms)] + +# The math module constants and functions can, of course, be imported directly by: +# from math import e, pi, sqrt, log, log10, exp, floor, ceil diff --git a/Task/Real-constants-and-functions/R/real-constants-and-functions.r b/Task/Real-constants-and-functions/R/real-constants-and-functions.r new file mode 100644 index 0000000000..37e381320a --- /dev/null +++ b/Task/Real-constants-and-functions/R/real-constants-and-functions.r @@ -0,0 +1,11 @@ +exp(1) # e +pi # pi +sqrt(x) # square root +log(x) # natural logarithm +log10(x) # base 10 logarithm +log(x, y) # arbitrary base logarithm +exp(x) # exponential +abs(x) # absolute value +floor(x) # floor +ceiling(x) # ceiling +x^y # power diff --git a/Task/Real-constants-and-functions/REXX/real-constants-and-functions-1.rexx b/Task/Real-constants-and-functions/REXX/real-constants-and-functions-1.rexx new file mode 100644 index 0000000000..2f0036db4b --- /dev/null +++ b/Task/Real-constants-and-functions/REXX/real-constants-and-functions-1.rexx @@ -0,0 +1,3 @@ +a=abs(y) /*takes the absolute value of y.*/ + +r=x**y /*only supports integer powers. */ diff --git a/Task/Real-constants-and-functions/REXX/real-constants-and-functions-2.rexx b/Task/Real-constants-and-functions/REXX/real-constants-and-functions-2.rexx new file mode 100644 index 0000000000..38feb02eeb --- /dev/null +++ b/Task/Real-constants-and-functions/REXX/real-constants-and-functions-2.rexx @@ -0,0 +1 @@ +ceiling: procedure; parse arg x; t=trunc(x); return t+(x>0)*(x\=t) diff --git a/Task/Real-constants-and-functions/REXX/real-constants-and-functions-3.rexx b/Task/Real-constants-and-functions/REXX/real-constants-and-functions-3.rexx new file mode 100644 index 0000000000..794b93d5b4 --- /dev/null +++ b/Task/Real-constants-and-functions/REXX/real-constants-and-functions-3.rexx @@ -0,0 +1 @@ +floor: procedure; parse arg x; t=trunc(x); return t-(x<0)-(x\=t) diff --git a/Task/Real-constants-and-functions/REXX/real-constants-and-functions-4.rexx b/Task/Real-constants-and-functions/REXX/real-constants-and-functions-4.rexx new file mode 100644 index 0000000000..c2e8010353 --- /dev/null +++ b/Task/Real-constants-and-functions/REXX/real-constants-and-functions-4.rexx @@ -0,0 +1,63 @@ +/*─────────────────────────────────────SQRT subroutine──────────────────*/ +sqrt: procedure /*square root subroutine. */ + /*returns the principal SQRT. */ + +r='' /*list of square roots calculated*/ + do j=1 for arg() /*process each argument specified*/ + a=arg(j) /*extract the argument specified*/ + do k=1 for words(a) /*process each number specified. */ + r=r sqrt_(word(a,k)) /*calculate sqrt, add to results.*/ + end + end +return space(r) /*return list of SQRTs calculated*/ + + +/*─────────────────────────────────────SQRT_ subroutine─────────────────*/ +sqrt_: procedure; parse arg x 1 ox +if x=0 then return 0 /*handle special case of zero. */ +if x='' then return '' /*if null, then return null. */ +if pos(',',x)\==0 then do;x=space(translate(x,,","),0);ox=x;end /*del ,*/ +if \datatype(x,'N') then return '[n/a]' /*not numberic? not applicable*/ +x=abs(x) /*just use positive value of X. */ +d=digits() /*get the current precision. */ +numeric digits 11 /*use "small" precision at first.*/ +g=sqrt_guess() /*try get a good 1st guesstimate.*/ +m.=11 /*technique uses just enough digs*/ +p=d+d%4+2 /*# of iterations (calculations).*/ + + /*Note: to insure enough accuracy*/ + /*for the result, the precsion */ + /*during the SQRT calcuations is */ + /*increased by two extra digits. */ + 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 /*each iteration, increase digits*/ + g=.5*(g+x/g) /*do the nitty-gritty calculation*/ + end /* .5* is faster than /2 */ + +numeric digits d /*restore the original precision.*/ +return (g/1)left('i',ox<0) /*normalize to old digs, complex?*/ + + +sqrt_guess: numeric form scientific /*force scientific form of number*/ +parse value format(x,2,1,,0) 'E0' with g 'E' _ . /*get X's exponent.*/ +return g*.5'E'_%2 /*1st guesstimate. */ + + +/*┌────────────────────────────────────────────────────────────────────┐ +┌─┘ √ └─┐ +│ While the above REXX code seems like it's doing a lot of extra work, │ +│ it saves a substanial amount of processing time when the precision │ +│ (DIGITs) is a lot greater than the default (9 digits). │ +│ │ +│ Indeed, when computing square roots in the hundreds (even thousands) │ +│ of digits, this technique reduces the amount of CPU processing time │ +│ by keeping the length of the computations to a minimim (due to a large │ +│ precision) while the accuracy (at the beginning) isn't important for │ +│ caculating the guesstimate (the running square root guess). │ +└─┐ √ ┌─┘ + └────────────────────────────────────────────────────────────────────┘*/ diff --git a/Task/Real-constants-and-functions/REXX/real-constants-and-functions-5.rexx b/Task/Real-constants-and-functions/REXX/real-constants-and-functions-5.rexx new file mode 100644 index 0000000000..a3feaaf2cd --- /dev/null +++ b/Task/Real-constants-and-functions/REXX/real-constants-and-functions-5.rexx @@ -0,0 +1,16 @@ +/*─────────────────────────────────────SQRT subroutine──────────────────*/ +sqrt: procedure; parse arg x /*a simple SQRT subroutine. */ +if x=0 then return 0 /*handle special case of zero. */ +d=digits() /*get the current precision. */ +numeric digits digits()+2 /*ensure extra precision. */ +g=x/4 /*try get a so-so 1st guesstimate*/ +old=0 /*set OLD guess to zero. */ + + do forever + g=.5*(g+x/g) /*do the nitty-gritty calculation*/ + if g=old then leave /*if G is the same as old, quit. */ + old=g /*save OLD for next iteration. */ + end /* .5* is faster than /2 */ + +numeric digits d /*restore the original precision.*/ +return g/1 /*normalize to old precision. */ diff --git a/Task/Real-constants-and-functions/REXX/real-constants-and-functions-6.rexx b/Task/Real-constants-and-functions/REXX/real-constants-and-functions-6.rexx new file mode 100644 index 0000000000..abb4b2d2f1 --- /dev/null +++ b/Task/Real-constants-and-functions/REXX/real-constants-and-functions-6.rexx @@ -0,0 +1,27 @@ +numeric digits ddd /*sets the current precision to DDD */ +numeric fuzz fff /*arithmetic comparisons with FFF fuzzy*/ +numeric form kkk /*exponential: scientific | engineering*/ + +low=min(a,b,c,d,e,f,g, ...) /*finds the min of specified arguments.*/ +big=min(a,b,c,d,e,f,g, ...) /*finds the max of specified arguments.*/ + +rrr=random(low,high) /*gets a random integer from LOW-->HIGH*/ +arr=random(low,high,seed) /* ... with a seed (to make repeatable)*/ + +mzp=sign(x) /*finds the sign of x (-1, 0, +1). */ + + fs=format(x) /*formats X with the current DIGITS() */ + fb=format(x,bbb) /* BBB digs before decimal*/ + fa=format(x,bbb,aaa) /* AAA digs after decimal*/ + fa=format(x,,0) /* rounds X to an integer.*/ + fe=format(x,,eee) /* exponent has eee places. */ + ft=format(x,,eee,ttt) /*if x exceeds TTT digits, force exp. */ + +hh=b2x(bbb) /*converts binary/bits to hexadecimal. */ +dd=c2d(ccc) /*converts character to decimal. */ +hh=c2x(ccc) /*converts character to hexadecimal. */ +cc=d2c(ddd) /*converts decimal to character. */ +hh=d2x(ddd) /*converts decimal to hexadecimal. */ +bb=x2b(hhh) /*converts hexadecimal to binary (bits)*/ +cc=x2c(hhh) /*converts hexadecimal to character. */ +dd=x2d(hhh) /*converts hexadecimal to decimal. */ diff --git a/Task/Real-constants-and-functions/RLaB/real-constants-and-functions-1.rlab b/Task/Real-constants-and-functions/RLaB/real-constants-and-functions-1.rlab new file mode 100644 index 0000000000..9c7f187665 --- /dev/null +++ b/Task/Real-constants-and-functions/RLaB/real-constants-and-functions-1.rlab @@ -0,0 +1,5 @@ +>> const + e euler ln10 ln2 lnpi + log10e log2e pi pihalf piquarter + rpi sqrt2 sqrt2r sqrt3 sqrtpi + tworpi diff --git a/Task/Real-constants-and-functions/RLaB/real-constants-and-functions-2.rlab b/Task/Real-constants-and-functions/RLaB/real-constants-and-functions-2.rlab new file mode 100644 index 0000000000..a15d688335 --- /dev/null +++ b/Task/Real-constants-and-functions/RLaB/real-constants-and-functions-2.rlab @@ -0,0 +1,24 @@ +>> mks + F G J L N + Na R0 Ry Tsp V0 + a a0 acre alpha atm + au bar barn btu c + cal cgal cm cm2 cm3 + ct cup curie day dm + dm2 dm3 dyne e eV + eps0 erg fathom floz ft + ftcan ftlam g gal gauss + gf h ha hbar hour + hp in inH2O inHg kSB + kb kcal km km2 km3 + kmh knot kpf lam lb + lumen lux ly mHg mSun + me micron mil mile min + mm mm2 mm3 mmu mn + mp mph mu0 mub mue + mun mup nmi oz pal + parsec pf phot poise psi + rad roe stilb stokes tcs + therm tntton ton torr toz + tsp uam ukgal ukton uston + week yd diff --git a/Task/Real-constants-and-functions/RLaB/real-constants-and-functions-3.rlab b/Task/Real-constants-and-functions/RLaB/real-constants-and-functions-3.rlab new file mode 100644 index 0000000000..c131237978 --- /dev/null +++ b/Task/Real-constants-and-functions/RLaB/real-constants-and-functions-3.rlab @@ -0,0 +1,17 @@ +>> x = rand() +>> sqrt(x) + 2.23606798 +>> log(x) + 1.60943791 +>> log10(x) + 0.698970004 +>> exp(x) + 148.413159 +>> abs(x) + 5 +>> floor(x) + 5 +>> ceil(x) + 5 +>> x .^ 2 + 25 diff --git a/Task/Real-constants-and-functions/Racket/real-constants-and-functions.rkt b/Task/Real-constants-and-functions/Racket/real-constants-and-functions.rkt new file mode 100644 index 0000000000..c8d493f906 --- /dev/null +++ b/Task/Real-constants-and-functions/Racket/real-constants-and-functions.rkt @@ -0,0 +1,9 @@ +(exp 1) ; e +pi ; pi +(sqrt x) ; square root +(log x) ; natural logarithm +(exp x) ; exponential +(abs x) ; absolute value +(floor x) ; floor +(ceiling x) ; ceiling +(expt x y) ; power diff --git a/Task/Real-constants-and-functions/Ruby/real-constants-and-functions.rb b/Task/Real-constants-and-functions/Ruby/real-constants-and-functions.rb new file mode 100644 index 0000000000..dbd4d5b7f0 --- /dev/null +++ b/Task/Real-constants-and-functions/Ruby/real-constants-and-functions.rb @@ -0,0 +1,10 @@ +Math::E #e +Math::PI #pi +Math.sqrt(x) #square root +Math.log(x) #natural logarithm +Math.log10(x) #base 10 logarithm +Math.exp(x) #exponential +x.abs #absolute value +x.floor #floor +x.ceil #ceiling +x ** y #power diff --git a/Task/Real-constants-and-functions/Run-BASIC/real-constants-and-functions.run b/Task/Real-constants-and-functions/Run-BASIC/real-constants-and-functions.run new file mode 100644 index 0000000000..0fa682fa9d --- /dev/null +++ b/Task/Real-constants-and-functions/Run-BASIC/real-constants-and-functions.run @@ -0,0 +1,9 @@ +print "exp:";chr$(9); EXP(1) +print "PI:";chr$(9); 22/7 +print "Sqr2:";chr$(9); SQR(2) +print "Log2:";chr$(9); LOG(2) : REM Base 10 +print "Exp2:";chr$(9); EXP(2) +print "Abs2:";chr$(9); ABS(-2) +print "Floor:";chr$(9); INT(1.534) +print "ceil:";chr$(9); val(using("###",1.534)) +print "Power:";chr$(9); 1.23^4 diff --git a/Task/Real-constants-and-functions/Scheme/real-constants-and-functions.ss b/Task/Real-constants-and-functions/Scheme/real-constants-and-functions.ss new file mode 100644 index 0000000000..1399224dde --- /dev/null +++ b/Task/Real-constants-and-functions/Scheme/real-constants-and-functions.ss @@ -0,0 +1,7 @@ +(sqrt x) ;square root +(log x) ;natural logarithm +(exp x) ;exponential +(abs x) ;absolute value +(floor x) ;floor +(ceiling x) ;ceiling +(expt x y) ;power diff --git a/Task/Real-constants-and-functions/Slate/real-constants-and-functions.slate b/Task/Real-constants-and-functions/Slate/real-constants-and-functions.slate new file mode 100644 index 0000000000..f67457053a --- /dev/null +++ b/Task/Real-constants-and-functions/Slate/real-constants-and-functions.slate @@ -0,0 +1,11 @@ +numerics E. +numerics Pi. +n sqrt. +n log10. "base 10 logarithm" +n ln. "natural logarithm" +n log: m. "arbitrary base logarithm" +n exp. "exponential" +n abs. "absolute value" +n floor. +n ceiling. +n raisedTo: anotherNumber diff --git a/Task/Real-constants-and-functions/Smalltalk/real-constants-and-functions.st b/Task/Real-constants-and-functions/Smalltalk/real-constants-and-functions.st new file mode 100644 index 0000000000..dd919a7b07 --- /dev/null +++ b/Task/Real-constants-and-functions/Smalltalk/real-constants-and-functions.st @@ -0,0 +1,10 @@ +Float e. +Float pi. +aNumber sqrt. +aNumber log. "base 10 logarithm" +aNumber ln. "natural logarithm" +aNumber exp. "exponential" +aNumber abs. "absolute value" +aNumber floor. +aNumber ceiling. +aNumber raisedTo: anotherNumber diff --git a/Task/Real-constants-and-functions/Standard-ML/real-constants-and-functions.ml b/Task/Real-constants-and-functions/Standard-ML/real-constants-and-functions.ml new file mode 100644 index 0000000000..73fdedeed4 --- /dev/null +++ b/Task/Real-constants-and-functions/Standard-ML/real-constants-and-functions.ml @@ -0,0 +1,10 @@ +Math.e; (* e *) +Math.pi; (* pi *) +Math.sqrt x; (* square root *) +Math.ln x; (* natural logarithm--log base 10 also available (Math.log10) *) +Math.exp x; (* exponential *) +abs x; (* absolute value *) +floor x; (* floor *) +ceil x; (* ceiling *) +Math.pow (x, y); (* power *) +~ x; (* negation *) diff --git a/Task/Real-constants-and-functions/Tcl/real-constants-and-functions-1.tcl b/Task/Real-constants-and-functions/Tcl/real-constants-and-functions-1.tcl new file mode 100644 index 0000000000..580b577882 --- /dev/null +++ b/Task/Real-constants-and-functions/Tcl/real-constants-and-functions-1.tcl @@ -0,0 +1,9 @@ +expr {exp(1)} ;# e +expr {4 * atan(1)} ;# pi -- also, simpler: expr acos(-1) +expr {sqrt($x)} ;# square root +expr {log($x)} ;# natural logarithm, also log10 +expr {exp($x)} ;# exponential +expr {abs($x)} ;# absolute value +expr {floor($x)} ;# floor +expr {ceil($x)} ;# ceiling +expr {$x**$y} ;# power, also pow($x,$y) diff --git a/Task/Real-constants-and-functions/Tcl/real-constants-and-functions-2.tcl b/Task/Real-constants-and-functions/Tcl/real-constants-and-functions-2.tcl new file mode 100644 index 0000000000..e47af3310c --- /dev/null +++ b/Task/Real-constants-and-functions/Tcl/real-constants-and-functions-2.tcl @@ -0,0 +1,3 @@ +package require math::constants +math::constants::constants e pi +puts "e = $e, pi = $pi" diff --git a/Task/Real-constants-and-functions/XPL0/real-constants-and-functions.xpl0 b/Task/Real-constants-and-functions/XPL0/real-constants-and-functions.xpl0 new file mode 100644 index 0000000000..b1386ee8d1 --- /dev/null +++ b/Task/Real-constants-and-functions/XPL0/real-constants-and-functions.xpl0 @@ -0,0 +1,26 @@ +include c:\cxpl\codes; \intrinsic 'code' declarations + +func real Power(X, Y); \X raised to the Y power +real X, Y; +return Exp(Y*Ln(X)); + +real E, Pi; +[Format(4, 16); \places shown before and after . +E:= Exp(1.0); +RlOut(0, E); CrLf(0); +RlOut(0, Ln(E)); CrLf(0); +CrLf(0); +Pi:= ATan2(0.0, -1.0); \Pi is also a defined constant +RlOut(0, Pi); CrLf(0); +RlOut(0, Cos(Pi)); CrLf(0); +CrLf(0); +RlOut(0, Sqrt(2.0)); CrLf(0); \Sqrt is a call to an intrinsic +RlOut(0, Log(100.0)); CrLf(0); +RlOut(0, Ln(Exp(123.456789))); CrLf(0); +CrLf(0); +RlOut(0, abs(-1234.5)); CrLf(0); \abs works for both reals & ints +CrLf(0); +RlOut(0, float(fix(1.999-0.5))); CrLf(0); \floor rounds toward -infinity +RlOut(0, float(fix(1.001+0.5))); CrLf(0); \ceiling rounds toward +infinity +RlOut(0, Power(sqrt(2.0), 4.0)); CrLf(0); \sqrt is an inline function and +] \ can be used for both reals & ints diff --git a/Task/Record-sound/0DESCRIPTION b/Task/Record-sound/0DESCRIPTION new file mode 100644 index 0000000000..312cb2e30c --- /dev/null +++ b/Task/Record-sound/0DESCRIPTION @@ -0,0 +1,3 @@ +Record a monophonic 16-bit PCM sound into either memory space, a file or array. + +(This task neglects to specify the sample rate, and whether to use signed samples. The programs in this page might use signed 16-bit or unsigned 16-bit samples, at 8000 Hz, 44100 Hz, or any other sample rate. Therefore, these programs might not record sound in the same format.) diff --git a/Task/Record-sound/BBC-BASIC/record-sound.bbc b/Task/Record-sound/BBC-BASIC/record-sound.bbc new file mode 100644 index 0000000000..6b02246193 --- /dev/null +++ b/Task/Record-sound/BBC-BASIC/record-sound.bbc @@ -0,0 +1,36 @@ + wavfile$ = @dir$ + "capture.wav" + bitspersample% = 16 + channels% = 2 + samplespersec% = 44100 + + alignment% = bitspersample% * channels% / 8 + bytespersec% = alignment% * samplespersec% + + params$ = " bitspersample " + STR$(bitspersample%) + \ + \ " channels " + STR$(channels%) + \ + \ " alignment " + STR$(alignment%) + \ + \ " samplespersec " + STR$(samplespersec%) + \ + \ " bytespersec " + STR$(bytespersec%) + + SYS "mciSendString", "close all", 0, 0, 0 + SYS "mciSendString", "open new type waveaudio alias capture", 0, 0, 0 + SYS "mciSendString", "set capture" + params$, 0, 0, 0 TO res% + IF res% ERROR 100, "Couldn't set capture parameters: " + STR$(res% AND &FFFF) + + PRINT "Press SPACE to start recording..." + REPEAT UNTIL INKEY(1) = 32 + + SYS "mciSendString", "record capture", 0, 0, 0 TO res% + IF res% ERROR 100, "Couldn't start audio capture: " + STR$(res% AND &FFFF) + + PRINT "Recording, press SPACE to stop..." + REPEAT UNTIL INKEY(1) = 32 + + SYS "mciSendString", "stop capture", 0, 0, 0 + SYS "mciSendString", "save capture " + wavfile$, 0, 0, 0 TO res% + IF res% ERROR 100, "Couldn't save to WAV file: " + STR$(res% AND &FFFF) + + SYS "mciSendString", "delete capture", 0, 0, 0 + SYS "mciSendString", "close capture", 0, 0, 0 + + PRINT "Captured audio is stored in " wavfile$ diff --git a/Task/Record-sound/C/record-sound.c b/Task/Record-sound/C/record-sound.c new file mode 100644 index 0000000000..3494e08596 --- /dev/null +++ b/Task/Record-sound/C/record-sound.c @@ -0,0 +1,30 @@ +#include +#include +#include +#include + +void * record(size_t bytes) +{ + int fd; + if (-1 == (fd = open("/dev/dsp", O_RDONLY))) return 0; + void *a = malloc(bytes); + read(fd, a, bytes); + close(fd); + return a; +} + +int play(void *buf, size_t len) +{ + int fd; + if (-1 == (fd = open("/dev/dsp", O_WRONLY))) return 0; + write(fd, buf, len); + close(fd); + return 1; +} + +int main() +{ + void *p = record(65536); + play(p, 65536); + return 0; +} diff --git a/Task/Record-sound/GUISS/record-sound.guiss b/Task/Record-sound/GUISS/record-sound.guiss new file mode 100644 index 0000000000..ff71e83a95 --- /dev/null +++ b/Task/Record-sound/GUISS/record-sound.guiss @@ -0,0 +1 @@ +Start,Programs,Accessories,Sound Recorder,Button:Record diff --git a/Task/Record-sound/Liberty-BASIC/record-sound-1.liberty b/Task/Record-sound/Liberty-BASIC/record-sound-1.liberty new file mode 100644 index 0000000000..af335953bd --- /dev/null +++ b/Task/Record-sound/Liberty-BASIC/record-sound-1.liberty @@ -0,0 +1 @@ +run "sndrec32.exe" diff --git a/Task/Record-sound/Liberty-BASIC/record-sound-2.liberty b/Task/Record-sound/Liberty-BASIC/record-sound-2.liberty new file mode 100644 index 0000000000..cc20c509c9 --- /dev/null +++ b/Task/Record-sound/Liberty-BASIC/record-sound-2.liberty @@ -0,0 +1,34 @@ + print "Starting 5 sec. recording..." + r$ =mciSendString$( "open new type waveaudio alias capture") + r$ =mciSendString$( "set capture time format ms bitspersample 16") + r$ =mciSendString$( "set capture channels 1 samplespersec 8000") + r$ =mciSendString$( "set capture alignment 1 bytespersec 8000") + r$ =mciSendString$( "record capture") + timer 5000, [on] + wait + [on] + timer 0 + print " .... now stopping the recording." + r$ =mciSendString$( "stop capture") + r$ =mciSendString$( "save capture " +chr$( 34) +"sample.wav" +chr$( 34)) + r$ =mciSendString$( "close capture") + print "Done recording." + r$=mciSendString$( "open " +q$ +"sample.wav" +q$ +" type waveaudio alias sfx") + r$=mciSendString$( "play sfx wait") + r$=mciSendString$( "close sfx") + print "Done playing back." + end + +function mciSendString$( s$) + print s$ + buffer$ =space$( 1024) +chr$( 0) + calldll #winmm, "mciSendStringA", s$ as ptr, buffer$ as ptr, 1028 as long, 0 as long, r as long + buffer$ =left$( buffer$, instr( buffer$, chr$( 0)) -1) + if r >0 then + mciSendString$ ="error" + print "returned "; mciSendString$ + else + mciSendString$ =""'buffer$ + print "OK" + end if +end function diff --git a/Task/Record-sound/Mathematica/record-sound.math b/Task/Record-sound/Mathematica/record-sound.math new file mode 100644 index 0000000000..26f867ceab --- /dev/null +++ b/Task/Record-sound/Mathematica/record-sound.math @@ -0,0 +1 @@ +SystemDialogInput["RecordSound"] diff --git a/Task/Record-sound/OCaml/record-sound.ocaml b/Task/Record-sound/OCaml/record-sound.ocaml new file mode 100644 index 0000000000..22d7987c0e --- /dev/null +++ b/Task/Record-sound/OCaml/record-sound.ocaml @@ -0,0 +1,21 @@ +#load "unix.cma" + +let record bytes = + let buf = String.make bytes '\000' in + let ic = open_in "/dev/dsp" in + let chunk = 4096 in + for i = 0 to pred (bytes / chunk) do + ignore (input ic buf (i * chunk) chunk) + done; + close_in ic; + (buf) + +let play buf len = + let oc = open_out "/dev/dsp" in + output_string oc buf; + close_out oc + +let () = + let bytes = 65536 in + let p = record bytes in + play p bytes diff --git a/Task/Record-sound/PicoLisp/record-sound.l b/Task/Record-sound/PicoLisp/record-sound.l new file mode 100644 index 0000000000..cb0b79b180 --- /dev/null +++ b/Task/Record-sound/PicoLisp/record-sound.l @@ -0,0 +1,4 @@ +(in '(rec -q -c1 -tu16 - trim 0 2) # Record 2 seconds + (make + (while (rd 2) + (link @) ) ) ) diff --git a/Task/Record-sound/Python/record-sound.py b/Task/Record-sound/Python/record-sound.py new file mode 100644 index 0000000000..6484ea6bde --- /dev/null +++ b/Task/Record-sound/Python/record-sound.py @@ -0,0 +1,17 @@ +import pyaudio + +chunk = 1024 +FORMAT = pyaudio.paInt16 +CHANNELS = 1 +RATE = 44100 + +p = pyaudio.PyAudio() + +stream = p.open(format = FORMAT, + channels = CHANNELS, + rate = RATE, + input = True, + frames_per_buffer = chunk) + +data = stream.read(chunk) +print [ord(i) for i in data] diff --git a/Task/Record-sound/Tcl/record-sound.tcl b/Task/Record-sound/Tcl/record-sound.tcl new file mode 100644 index 0000000000..3ccc1ed20a --- /dev/null +++ b/Task/Record-sound/Tcl/record-sound.tcl @@ -0,0 +1,19 @@ +package require sound + +# Helper to do a responsive wait +proc delay t {after $t {set ::doneDelay ok}; vwait ::doneDelay} + +# Make an in-memory recording object +set recording [snack::sound -encoding "Lin16" -rate 44100 -channels 1] + +# Set it doing the recording, wait for a second, and stop +$recording record -append true +delay 1000 +$recording stop + +# Convert the internal buffer to viewable numbers, and print them out +binary scan [$recording data -byteorder littleEndian] s* words +puts [join $words ", "] + +# Destroy the recording object +$recording destroy diff --git a/Task/Reduced-row-echelon-form/0DESCRIPTION b/Task/Reduced-row-echelon-form/0DESCRIPTION new file mode 100644 index 0000000000..fd350e8ef6 --- /dev/null +++ b/Task/Reduced-row-echelon-form/0DESCRIPTION @@ -0,0 +1,39 @@ +Show how to compute the '''reduced row echelon form''' (a.k.a. '''row canonical form''') of a matrix. The matrix can be stored in any datatype that is convenient (for most languages, this will probably be a two-dimensional array). Built-in functions or this pseudocode (from Wikipedia) may be used: + '''function''' ToReducedRowEchelonForm(Matrix M) '''is''' + ''lead'' := 0 + ''rowCount'' := the number of rows in M + ''columnCount'' := the number of columns in M + '''for''' 0 ≤ ''r'' < ''rowCount'' '''do''' + '''if''' ''columnCount'' ≤ ''lead'' '''then''' + '''stop''' + '''end if''' + ''i'' = ''r'' + '''while''' M[''i'', ''lead''] = 0 '''do''' + ''i'' = ''i'' + 1 + '''if''' ''rowCount'' = ''i'' '''then''' + ''i'' = ''r'' + ''lead'' = ''lead'' + 1 + '''if''' ''columnCount'' = ''lead'' '''then''' + '''stop''' + '''end if''' + '''end if''' + '''end while''' + Swap rows ''i'' and ''r'' + If M[''r'', ''lead''] is not 0 divide row ''r'' by M[''r'', ''lead''] + '''for''' 0 ≤ ''i'' < ''rowCount'' '''do''' + '''if''' ''i'' ≠ ''r'' '''do''' + Subtract M[i, lead] multiplied by row ''r'' from row ''i'' + '''end if''' + '''end for''' + ''lead'' = ''lead'' + 1 + '''end for''' + '''end function''' + +For testing purposes, the RREF of this matrix: +
    1   2   -1   -4
    +2   3   -1   -11
    +-2   0   -3   22
    +is: +
    1   0   0   -8
    +0   1   0   1
    +0   0   1   -2
    diff --git a/Task/Reduced-row-echelon-form/1META.yaml b/Task/Reduced-row-echelon-form/1META.yaml new file mode 100644 index 0000000000..1e81690bbc --- /dev/null +++ b/Task/Reduced-row-echelon-form/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Matrices diff --git a/Task/Reduced-row-echelon-form/ALGOL-68/reduced-row-echelon-form.alg b/Task/Reduced-row-echelon-form/ALGOL-68/reduced-row-echelon-form.alg new file mode 100644 index 0000000000..5973fc73df --- /dev/null +++ b/Task/Reduced-row-echelon-form/ALGOL-68/reduced-row-echelon-form.alg @@ -0,0 +1,54 @@ +MODE FIELD = REAL; # FIELD can be REAL, LONG REAL etc, or COMPL, FRAC etc # +MODE VEC = [0]FIELD; +MODE MAT = [0,0]FIELD; + +PROC to reduced row echelon form = (REF MAT m)VOID: ( + INT lead col := 2 LWB m; + + FOR this row FROM LWB m TO UPB m DO + IF lead col > 2 UPB m THEN return FI; + INT other row := this row; + WHILE m[other row,lead col] = 0 DO + other row +:= 1; + IF other row > UPB m THEN + other row := this row; + lead col +:= 1; + IF lead col > 2 UPB m THEN return FI + FI + OD; + IF this row /= other row THEN + VEC swap = m[this row,lead col:]; + m[this row,lead col:] := m[other row,lead col:]; + m[other row,lead col:] := swap + FI; + FIELD scale = 1/m[this row,lead col]; + IF scale /= 1 THEN + m[this row,lead col] := 1; + FOR col FROM lead col+1 TO 2 UPB m DO m[this row,col] *:= scale OD + FI; + FOR other row FROM LWB m TO UPB m DO + IF this row /= other row THEN + REAL scale = m[other row,lead col]; + m[other row,lead col]:=0; + FOR col FROM lead col+1 TO 2 UPB m DO m[other row,col] -:= scale*m[this row,col] OD + FI + OD; + lead col +:= 1 + OD; + return: EMPTY +); + +[3,4]FIELD mat := ( + ( 1, 2, -1, -4), + ( 2, 3, -1, -11), + (-2, 0, -3, 22) +); + +to reduced row echelon form( mat ); + +FORMAT + real repr = $g(-7,4)$, + vec repr = $"("n(2 UPB mat-1)(f(real repr)", ")f(real repr)")"$, + mat repr = $"("n(1 UPB mat-1)(f(vec repr)", "lx)f(vec repr)")"$; + +printf((mat repr, mat, $l$)) diff --git a/Task/Reduced-row-echelon-form/ActionScript/reduced-row-echelon-form.as b/Task/Reduced-row-echelon-form/ActionScript/reduced-row-echelon-form.as new file mode 100644 index 0000000000..5a0b13b2c2 --- /dev/null +++ b/Task/Reduced-row-echelon-form/ActionScript/reduced-row-echelon-form.as @@ -0,0 +1,37 @@ +public function RREF():Matrix { + var lead:uint, i:uint, j:uint, r:uint = 0; + + for(r = 0; r < rows; r++) { + if(columns <= lead) + break; + i = r; + + while(_m[i][lead] == 0) { + i++; + + if(rows == i) { + i = r; + lead++; + + if(columns == lead) + return this; + } + } + rowSwitch(i, r); + var val:Number = _m[r][lead]; + + for(j = 0; j < columns; j++) + _m[r][j] /= val; + + for(i = 0; i < rows; i++) { + if(i == r) + continue; + val = _m[i][lead]; + + for(j = 0; j < columns; j++) + _m[i][j] -= val * _m[r][j]; + } + lead++; + } + return this; +} diff --git a/Task/Reduced-row-echelon-form/Ada/reduced-row-echelon-form-1.ada b/Task/Reduced-row-echelon-form/Ada/reduced-row-echelon-form-1.ada new file mode 100644 index 0000000000..cc25d92c4e --- /dev/null +++ b/Task/Reduced-row-echelon-form/Ada/reduced-row-echelon-form-1.ada @@ -0,0 +1,11 @@ +generic + type Element_Type is private; + Zero : Element_Type; + with function "-" (Left, Right : in Element_Type) return Element_Type is <>; + with function "*" (Left, Right : in Element_Type) return Element_Type is <>; + with function "/" (Left, Right : in Element_Type) return Element_Type is <>; +package Matrices is + type Matrix is + array (Positive range <>, Positive range <>) of Element_Type; + function Reduced_Row_Echelon_form (Source : Matrix) return Matrix; +end Matrices; diff --git a/Task/Reduced-row-echelon-form/Ada/reduced-row-echelon-form-2.ada b/Task/Reduced-row-echelon-form/Ada/reduced-row-echelon-form-2.ada new file mode 100644 index 0000000000..8dc78da6f5 --- /dev/null +++ b/Task/Reduced-row-echelon-form/Ada/reduced-row-echelon-form-2.ada @@ -0,0 +1,71 @@ +package body Matrices is + procedure Swap_Rows (From : in out Matrix; First, Second : in Positive) is + Temporary : Element_Type; + begin + for Col in From'Range (2) loop + Temporary := From (First, Col); + From (First, Col) := From (Second, Col); + From (Second, Col) := Temporary; + end loop; + end Swap_Rows; + + procedure Divide_Row + (From : in out Matrix; + Row : in Positive; + Divisor : in Element_Type) + is + begin + for Col in From'Range (2) loop + From (Row, Col) := From (Row, Col) / Divisor; + end loop; + end Divide_Row; + + procedure Subtract_Rows + (From : in out Matrix; + Subtrahend, Minuend : in Positive; + Factor : in Element_Type) + is + begin + for Col in From'Range (2) loop + From (Minuend, Col) := From (Minuend, Col) - + From (Subtrahend, Col) * Factor; + end loop; + end Subtract_Rows; + + function Reduced_Row_Echelon_form (Source : Matrix) return Matrix is + Result : Matrix := Source; + Lead : Positive := Result'First (2); + I : Positive; + begin + Rows : for Row in Result'Range (1) loop + exit Rows when Lead > Result'Last (2); + I := Row; + while Result (I, Lead) = Zero loop + I := I + 1; + if I = Result'Last (1) then + I := Row; + Lead := Lead + 1; + exit Rows when Lead = Result'Last (2); + end if; + end loop; + if I /= Row then + Swap_Rows (From => Result, First => I, Second => Row); + end if; + Divide_Row + (From => Result, + Row => Row, + Divisor => Result (Row, Lead)); + for Other_Row in Result'Range (1) loop + if Other_Row /= Row then + Subtract_Rows + (From => Result, + Subtrahend => Row, + Minuend => Other_Row, + Factor => Result (Other_Row, Lead)); + end if; + end loop; + Lead := Lead + 1; + end loop Rows; + return Result; + end Reduced_Row_Echelon_form; +end Matrices; diff --git a/Task/Reduced-row-echelon-form/Ada/reduced-row-echelon-form-3.ada b/Task/Reduced-row-echelon-form/Ada/reduced-row-echelon-form-3.ada new file mode 100644 index 0000000000..47b418e289 --- /dev/null +++ b/Task/Reduced-row-echelon-form/Ada/reduced-row-echelon-form-3.ada @@ -0,0 +1,28 @@ +with Matrices; +with Ada.Text_IO; +procedure Main is + package Float_IO is new Ada.Text_IO.Float_IO (Float); + package Float_Matrices is new Matrices ( + Element_Type => Float, + Zero => 0.0); + procedure Print_Matrix (Matrix : in Float_Matrices.Matrix) is + begin + for Row in Matrix'Range (1) loop + for Col in Matrix'Range (2) loop + Float_IO.Put (Matrix (Row, Col), 0, 0, 0); + Ada.Text_IO.Put (' '); + end loop; + Ada.Text_IO.New_Line; + end loop; + end Print_Matrix; + My_Matrix : Float_Matrices.Matrix := + ((1.0, 2.0, -1.0, -4.0), + (2.0, 3.0, -1.0, -11.0), + (-2.0, 0.0, -3.0, 22.0)); + Reduced : Float_Matrices.Matrix := + Float_Matrices.Reduced_Row_Echelon_form (My_Matrix); +begin + Print_Matrix (My_Matrix); + Ada.Text_IO.Put_Line ("reduced to:"); + Print_Matrix (Reduced); +end Main; diff --git a/Task/Reduced-row-echelon-form/AutoIt/reduced-row-echelon-form.autoit b/Task/Reduced-row-echelon-form/AutoIt/reduced-row-echelon-form.autoit new file mode 100644 index 0000000000..cd02cbe02e --- /dev/null +++ b/Task/Reduced-row-echelon-form/AutoIt/reduced-row-echelon-form.autoit @@ -0,0 +1,56 @@ +Global $ivMatrix[3][4] = [[1, 2, -1, -4],[2, 3, -1, -11],[-2, 0, -3, 22]] +ToReducedRowEchelonForm($ivMatrix) + +Func ToReducedRowEchelonForm($matrix) + Local $clonematrix, $i + Local $lead = 0 + Local $rowCount = UBound($matrix) - 1 + Local $columnCount = UBound($matrix, 2) - 1 + For $r = 0 To $rowCount + If $columnCount = $lead Then ExitLoop + $i = $r + While $matrix[$i][$lead] = 0 + $i += 1 + If $rowCount = $i Then + $i = $r + $lead += 1 + If $columnCount = $lead Then ExitLoop + EndIf + WEnd + ; There´s no built in Function to swap Rows of a 2-Dimensional Array + ; We need to clone our matrix to swap complete lines + $clonematrix = $matrix ; Swap Lines, no + For $s = 0 To $columnCount + $matrix[$r][$s] = $clonematrix[$i][$s] + $matrix[$i][$s] = $clonematrix[$r][$s] + Next + Local $m = $matrix[$r][$lead] + For $k = 0 To $columnCount + $matrix[$r][$k] = $matrix[$r][$k] / $m + Next + For $i = 0 To $rowCount + If $i <> $r Then + Local $m = $matrix[$i][$lead] + For $k = 0 To $columnCount + $matrix[$i][$k] -= $m * $matrix[$r][$k] + Next + EndIf + Next + $lead += 1 + Next + ;########################################################## + ;###################CONSOLE OUTPUT######################### + ;########################################################## + For $i = 0 To $rowCount + ConsoleWrite("[") + For $k = 0 To $columnCount + ConsoleWrite($matrix[$i][$k]) + If $k <> $columnCount Then ConsoleWrite(",") + Next + ConsoleWrite("]" & @CRLF) + Next + ;########################################################## + ;########################################################## + ;########################################################## + Return $matrix +EndFunc ;==>ToReducedRowEchelonForm diff --git a/Task/Reduced-row-echelon-form/BBC-BASIC/reduced-row-echelon-form.bbc b/Task/Reduced-row-echelon-form/BBC-BASIC/reduced-row-echelon-form.bbc new file mode 100644 index 0000000000..7006c71c7e --- /dev/null +++ b/Task/Reduced-row-echelon-form/BBC-BASIC/reduced-row-echelon-form.bbc @@ -0,0 +1,42 @@ + DIM matrix(2,3) + matrix() = 1, 2, -1, -4, \ + \ 2, 3, -1, -11, \ + \ -2, 0, -3, 22 + PROCrref(matrix()) + FOR row% = 0 TO 2 + FOR col% = 0 TO 3 + PRINT matrix(row%,col%); + NEXT + PRINT + NEXT row% + END + + DEF PROCrref(m()) + LOCAL lead%, nrows%, ncols%, i%, j%, r%, n + nrows% = DIM(m(),1)+1 + ncols% = DIM(m(),2)+1 + FOR r% = 0 TO nrows%-1 + IF lead% >= ncols% EXIT FOR + i% = r% + WHILE m(i%,lead%) = 0 + i% += 1 + IF i% = nrows% THEN + i% = r% + lead% += 1 + IF lead% = ncols% EXIT FOR + ENDIF + ENDWHILE + FOR j% = 0 TO ncols%-1 : SWAP m(i%,j%),m(r%,j%) : NEXT + n = m(r%,lead%) + IF n <> 0 FOR j% = 0 TO ncols%-1 : m(r%,j%) /= n : NEXT + FOR i% = 0 TO nrows%-1 + IF i% <> r% THEN + n = m(i%,lead%) + FOR j% = 0 TO ncols%-1 + m(i%,j%) -= m(r%,j%) * n + NEXT + ENDIF + NEXT + lead% += 1 + NEXT r% + ENDPROC diff --git a/Task/Reduced-row-echelon-form/C++/reduced-row-echelon-form.cpp b/Task/Reduced-row-echelon-form/C++/reduced-row-echelon-form.cpp new file mode 100644 index 0000000000..df06359217 --- /dev/null +++ b/Task/Reduced-row-echelon-form/C++/reduced-row-echelon-form.cpp @@ -0,0 +1,186 @@ +#include // for std::swap +#include +#include + +// Matrix traits: This describes how a matrix is accessed. By +// externalizing this information into a traits class, the same code +// can be used both with native arrays and matrix classes. To use the +// dfault implementation of the traits class, a matrix type has to +// provide the following definitions as members: +// +// * typedef ... index_type; +// - The type used for indexing (e.g. size_t) +// * typedef ... value_type; +// - The element type of the matrix (e.g. double) +// * index_type min_row() const; +// - returns the minimal allowed row index +// * index_type max_row() const; +// - returns the maximal allowed row index +// * index_type min_column() const; +// - returns the minimal allowed column index +// * index_type max_column() const; +// - returns the maximal allowed column index +// * value_type& operator()(index_type i, index_type k) +// - returns a reference to the element i,k, where +// min_row() <= i <= max_row() +// min_column() <= k <= max_column() +// * value_type operator()(index_type i, index_type k) const +// - returns the value of element i,k +// +// Note that the functions are all inline and simple, so the compiler +// should completely optimize them away. +template struct matrix_traits +{ + typedef typename MatrixType::index_type index_type; + typedef typename MatrixType::value_typ value_type; + static index_type min_row(MatrixType const& A) + { return A.min_row(); } + static index_type max_row(MatrixType const& A) + { return A.max_row(); } + static index_type min_column(MatrixType const& A) + { return A.min_column(); } + static index_type max_column(MatrixType const& A) + { return A.max_column(); } + static value_type& element(MatrixType& A, index_type i, index_type k) + { return A(i,k); } + static value_type element(MatrixType const& A, index_type i, index_type k) + { return A(i,k); } +}; + +// specialization of the matrix traits for built-in two-dimensional +// arrays +template + struct matrix_traits +{ + typedef std::size_t index_type; + typedef T value_type; + static index_type min_row(T const (&)[rows][columns]) + { return 0; } + static index_type max_row(T const (&)[rows][columns]) + { return rows-1; } + static index_type min_column(T const (&)[rows][columns]) + { return 0; } + static index_type max_column(T const (&)[rows][columns]) + { return columns-1; } + static value_type& element(T (&A)[rows][columns], + index_type i, index_type k) + { return A[i][k]; } + static value_type element(T const (&A)[rows][columns], + index_type i, index_type k) + { return A[i][k]; } +}; + +// Swap rows i and k of a matrix A +// Note that due to the reference, both dimensions are preserved for +// built-in arrays +template + void swap_rows(MatrixType& A, + typename matrix_traits::index_type i, + typename matrix_traits::index_type k) +{ + matrix_traits mt; + typedef typename matrix_traits::index_type index_type; + + // check indices + assert(mt.min_row(A) <= i); + assert(i <= mt.max_row(A)); + + assert(mt.min_row(A) <= k); + assert(k <= mt.max_row(A)); + + for (index_type col = mt.min_column(A); col <= mt.max_column(A); ++col) + std::swap(mt.element(A, i, col), mt.element(A, k, col)); +} + +// divide row i of matrix A by v +template + void divide_row(MatrixType& A, + typename matrix_traits::index_type i, + typename matrix_traits::value_type v) +{ + matrix_traits mt; + typedef typename matrix_traits::index_type index_type; + + assert(mt.min_row(A) <= i); + assert(i <= mt.max_row(A)); + + assert(v != 0); + + for (index_type col = mt.min_column(A); col <= mt.max_column(A); ++col) + mt.element(A, i, col) /= v; +} + +// in matrix A, add v times row k to row i +template + void add_multiple_row(MatrixType& A, + typename matrix_traits::index_type i, + typename matrix_traits::index_type k, + typename matrix_traits::value_type v) +{ + matrix_traits mt; + typedef typename matrix_traits::index_type index_type; + + assert(mt.min_row(A) <= i); + assert(i <= mt.max_row(A)); + + assert(mt.min_row(A) <= k); + assert(k <= mt.max_row(A)); + + for (index_type col = mt.min_column(A); col <= mt.max_column(A); ++col) + mt.element(A, i, col) += v * mt.element(A, k, col); +} + +// convert A to reduced row echelon form +template + void to_reduced_row_echelon_form(MatrixType& A) +{ + matrix_traits mt; + typedef typename matrix_traits::index_type index_type; + + index_type lead = mt.min_row(A); + + for (index_type row = mt.min_row(A); row <= mt.max_row(A); ++row) + { + if (lead > mt.max_column(A)) + return; + index_type i = row; + while (mt.element(A, i, lead) == 0) + { + ++i; + if (i > mt.max_row(A)) + { + i = row; + ++lead; + if (lead > mt.max_column(A)) + return; + } + } + swap_rows(A, i, row); + divide_row(A, row, mt.element(A, row, lead)); + for (i = mt.min_row(A); i <= mt.max_row(A); ++i) + { + if (i != row) + add_multiple_row(A, i, row, -mt.element(A, i, lead)); + } + } +} + +// test code +#include + +int main() +{ + double M[3][4] = { { 1, 2, -1, -4 }, + { 2, 3, -1, -11 }, + { -2, 0, -3, 22 } }; + + to_reduced_row_echelon_form(M); + for (int i = 0; i < 3; ++i) + { + for (int j = 0; j < 4; ++j) + std::cout << M[i][j] << '\t'; + std::cout << "\n"; + } + + return EXIT_SUCCESS; +} diff --git a/Task/Reduced-row-echelon-form/C/reduced-row-echelon-form.c b/Task/Reduced-row-echelon-form/C/reduced-row-echelon-form.c new file mode 100644 index 0000000000..63df991bf1 --- /dev/null +++ b/Task/Reduced-row-echelon-form/C/reduced-row-echelon-form.c @@ -0,0 +1,156 @@ +#include +#define TALLOC(n,typ) malloc(n*sizeof(typ)) + +#define EL_Type int + +typedef struct sMtx { + int dim_x, dim_y; + EL_Type *m_stor; + EL_Type **mtx; +} *Matrix, sMatrix; + +typedef struct sRvec { + int dim_x; + EL_Type *m_stor; +} *RowVec, sRowVec; + +Matrix NewMatrix( int x_dim, int y_dim ) +{ + int n; + Matrix m; + m = TALLOC( 1, sMatrix); + n = x_dim * y_dim; + m->dim_x = x_dim; + m->dim_y = y_dim; + m->m_stor = TALLOC(n, EL_Type); + m->mtx = TALLOC(m->dim_y, EL_Type *); + for(n=0; nmtx[n] = m->m_stor+n*x_dim; + } + return m; +} + +void MtxSetRow(Matrix m, int irow, EL_Type *v) +{ + int ix; + EL_Type *mr; + mr = m->mtx[irow]; + for(ix=0; ixdim_x; ix++) + mr[ix] = v[ix]; +} + +Matrix InitMatrix( int x_dim, int y_dim, EL_Type **v) +{ + Matrix m; + int iy; + m = NewMatrix(x_dim, y_dim); + for (iy=0; iydim_y; iy++) { + printf(" "); + sc = " "; + for (ix=0; ixdim_x; ix++) { + printf("%s %3d", sc, m->mtx[iy][ix]); + sc = ","; + } + printf("\n"); + } + printf("\n"); +} + +void MtxMulAndAddRows(Matrix m, int ixrdest, int ixrsrc, EL_Type mplr) +{ + int ix; + EL_Type *drow, *srow; + drow = m->mtx[ixrdest]; + srow = m->mtx[ixrsrc]; + for (ix=0; ixdim_x; ix++) + drow[ix] += mplr * srow[ix]; +// printf("Mul row %d by %d and add to row %d\n", ixrsrc, mplr, ixrdest); +// MtxDisplay(m); +} + +void MtxSwapRows( Matrix m, int rix1, int rix2) +{ + EL_Type *r1, *r2, temp; + int ix; + if (rix1 == rix2) return; + r1 = m->mtx[rix1]; + r2 = m->mtx[rix2]; + for (ix=0; ixdim_x; ix++) + temp = r1[ix]; r1[ix]=r2[ix]; r2[ix]=temp; +// printf("Swap rows %d and %d\n", rix1, rix2); +// MtxDisplay(m); +} + +void MtxNormalizeRow( Matrix m, int rix, int lead) +{ + int ix; + EL_Type *drow; + EL_Type lv; + drow = m->mtx[rix]; + lv = drow[lead]; + for (ix=0; ixdim_x; ix++) + drow[ix] /= lv; +// printf("Normalize row %d\n", rix); +// MtxDisplay(m); +} + +#define MtxGet( m, rix, cix ) m->mtx[rix][cix] + +void MtxToReducedREForm(Matrix m) +{ + int lead; + int rix, iix; + EL_Type lv; + int rowCount = m->dim_y; + + lead = 0; + for (rix=0; rix= m->dim_x) + return; + iix = rix; + while (0 == MtxGet(m, iix,lead)) { + iix++; + if (iix == rowCount) { + iix = rix; + lead++; + if (lead == m->dim_x) + return; + } + } + MtxSwapRows(m, iix, rix ); + MtxNormalizeRow(m, rix, lead ); + for (iix=0; iix= columnCount { + return + } + i := r + for m[i][lead] == 0 { + i++ + if rowCount == i { + i = r + lead++ + if columnCount == lead { + return + } + } + } + m[i], m[r] = m[r], m[i] + f := 1 / m[r][lead] + for j, _ := range m[r] { + m[r][j] *= f + } + for i = 0; i < rowCount; i++ { + if i != r { + f = m[i][lead] + for j, e := range m[r] { + m[i][j] -= e * f + } + } + } + lead++ + } +} diff --git a/Task/Reduced-row-echelon-form/Go/reduced-row-echelon-form-2.go b/Task/Reduced-row-echelon-form/Go/reduced-row-echelon-form-2.go new file mode 100644 index 0000000000..d9b2cd446b --- /dev/null +++ b/Task/Reduced-row-echelon-form/Go/reduced-row-echelon-form-2.go @@ -0,0 +1,83 @@ +package main + +import "fmt" + +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 (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.2f ", m.ele[e:e+m.stride]) + fmt.Println() + } +} + +func (m *matrix) rref() { + lead := 0 + for rxc0 := 0; rxc0 < len(m.ele); rxc0 += m.stride { + if lead >= m.stride { + return + } + ixc0 := rxc0 + for m.ele[ixc0+lead] == 0 { + ixc0 += m.stride + if ixc0 == len(m.ele) { + ixc0 = rxc0 + lead++ + if lead == m.stride { + return + } + } + } + for c, ix, rx := 0, ixc0, rxc0; c < m.stride; c++ { + m.ele[ix], m.ele[rx] = m.ele[rx], m.ele[ix] + ix++ + rx++ + } + if d := m.ele[rxc0+lead]; d != 0 { + d := 1 / d + for c, rx := 0, rxc0; c < m.stride; c++ { + m.ele[rx] *= d + rx++ + } + } + for ixc0 = 0; ixc0 < len(m.ele); ixc0 += m.stride { + if ixc0 != rxc0 { + f := m.ele[ixc0+lead] + for c, ix, rx := 0, ixc0, rxc0; c < m.stride; c++ { + m.ele[ix] -= m.ele[rx] * f + ix++ + rx++ + } + } + } + lead++ + } +} + +func main() { + m := matrixFromRows([][]float64{ + {1, 2, -1, -4}, + {2, 3, -1, -11}, + {-2, 0, -3, 22}, + }) + m.print("Input:") + m.rref() + m.print("Reduced:") +} diff --git a/Task/Reduced-row-echelon-form/Groovy/reduced-row-echelon-form-1.groovy b/Task/Reduced-row-echelon-form/Groovy/reduced-row-echelon-form-1.groovy new file mode 100644 index 0000000000..c7b496266b --- /dev/null +++ b/Task/Reduced-row-echelon-form/Groovy/reduced-row-echelon-form-1.groovy @@ -0,0 +1,32 @@ +enum Pivoting { + NONE({ i, it -> 1 }), + PARTIAL({ i, it -> - (it[i].abs()) }), + SCALED({ i, it -> - it[i].abs()/(it.inject(0) { sum, elt -> sum + elt.abs() } ) }); + + public final Closure comparer + + private Pivoting(Closure c) { + comparer = c + } +} + +def isReducibleMatrix = { matrix -> + def m = matrix.size() + m > 1 && matrix[0].size() > m && matrix[1.. row.size() == matrix[0].size() } +} + +def reducedRowEchelonForm = { matrix, Pivoting pivoting = Pivoting.NONE -> + assert isReducibleMatrix(matrix) + def m = matrix.size() + def n = matrix[0].size() + (0.. + matrix[i.. + (i.. + matrix[k][j] -= matrix[i][j]*matrix[k][i] + } + } + } + matrix +} diff --git a/Task/Reduced-row-echelon-form/Groovy/reduced-row-echelon-form-2.groovy b/Task/Reduced-row-echelon-form/Groovy/reduced-row-echelon-form-2.groovy new file mode 100644 index 0000000000..ed5093b0e1 --- /dev/null +++ b/Task/Reduced-row-echelon-form/Groovy/reduced-row-echelon-form-2.groovy @@ -0,0 +1,46 @@ +def matrixCopy = { matrix -> matrix.collect { row -> row.collect { it } } } + +println "Tests for matrix A:" +def a = [ + [1, 2, -1, -4], + [2, 3, -1, -11], + [-2, 0, -3, 22] +] +a.each { println it } +println() + +println "pivoting == Pivoting.NONE" +reducedRowEchelonForm(matrixCopy(a)).each { println it } +println() +println "pivoting == Pivoting.PARTIAL" +reducedRowEchelonForm(matrixCopy(a), Pivoting.PARTIAL).each { println it } +println() +println "pivoting == Pivoting.SCALED" +reducedRowEchelonForm(matrixCopy(a), Pivoting.SCALED).each { println it } +println() + + +println "Tests for matrix B (divides by 0 without pivoting):" +def b = [ + [1, 2, -1, -4], + [2, 4, -1, -11], + [-2, 0, -6, 24] +] +b.each { println it } +println() + +println "pivoting == Pivoting.NONE" +try { + reducedRowEchelonForm(matrixCopy(b)).each { println it } + println() +} catch (e) { + println "KABOOM! ${e.message}" + println() +} + +println "pivoting == Pivoting.PARTIAL" +reducedRowEchelonForm(matrixCopy(b), Pivoting.PARTIAL).each { println it } +println() +println "pivoting == Pivoting.SCALED" +reducedRowEchelonForm(matrixCopy(b), Pivoting.SCALED).each { println it } +println() diff --git a/Task/Reduced-row-echelon-form/Haskell/reduced-row-echelon-form.hs b/Task/Reduced-row-echelon-form/Haskell/reduced-row-echelon-form.hs new file mode 100644 index 0000000000..1400a67329 --- /dev/null +++ b/Task/Reduced-row-echelon-form/Haskell/reduced-row-echelon-form.hs @@ -0,0 +1,32 @@ +import Data.List (find) + +rref :: Fractional a => [[a]] -> [[a]] +rref m = f m 0 [0 .. rows - 1] + where rows = length m + cols = length $ head m + + f m _ [] = m + f m lead (r : rs) + | indices == Nothing = m + | otherwise = f m' (lead' + 1) rs + where indices = find p l + p (col, row) = m !! row !! col /= 0 + l = [(col, row) | + col <- [lead .. cols - 1], + row <- [r .. rows - 1]] + + Just (lead', i) = indices + newRow = map (/ m !! i !! lead') $ m !! i + + m' = zipWith g [0..] $ + replace r newRow $ + replace i (m !! r) m + g n row + | n == r = row + | otherwise = zipWith h newRow row + where h = subtract . (* row !! lead') + +replace :: Int -> a -> [a] -> [a] +{- Replaces the element at the given index. -} +replace n e l = a ++ e : b + where (a, _ : b) = splitAt n l diff --git a/Task/Reduced-row-echelon-form/J/reduced-row-echelon-form-1.j b/Task/Reduced-row-echelon-form/J/reduced-row-echelon-form-1.j new file mode 100644 index 0000000000..0ec1f9ddb9 --- /dev/null +++ b/Task/Reduced-row-echelon-form/J/reduced-row-echelon-form-1.j @@ -0,0 +1,10 @@ + ]mymatrix=: _4]\ 1 2 _1 _4 2 3 _1 _11 _2 0 _3 22 + 1 2 _1 _4 + 2 3 _1 _11 +_2 0 _3 22 + + require 'math/misc/linear' + gauss_jordan mymatrix +1 0 0 _8 +0 1 0 1 +0 0 1 _2 diff --git a/Task/Reduced-row-echelon-form/J/reduced-row-echelon-form-2.j b/Task/Reduced-row-echelon-form/J/reduced-row-echelon-form-2.j new file mode 100644 index 0000000000..a8745495f1 --- /dev/null +++ b/Task/Reduced-row-echelon-form/J/reduced-row-echelon-form-2.j @@ -0,0 +1,16 @@ + gauss_jordan 2 0 _1 0 0,1 0 0 _1 0,3 0 0 _2 _1,0 1 0 0 _2,:0 1 _1 0 0 +1 0 0 0 _1 +0 1 0 0 _2 +0 0 1 0 _2 +0 0 0 1 _1 +0 0 0 0 0 + gauss_jordan 1 2 3 4 3 1,2 4 6 2 6 2,3 6 18 9 9 _6,4 8 12 10 12 4,:5 10 24 11 15 _4 +1 2 0 0 3 0 +0 0 1 0 0 0 +0 0 0 1 0 0 +0 0 0 0 0 1 +0 0 0 0 0 0 + gauss_jordan 0 1,1 2,:0 5 +1 0 +0 1 +0 0 diff --git a/Task/Reduced-row-echelon-form/Java/reduced-row-echelon-form.java b/Task/Reduced-row-echelon-form/Java/reduced-row-echelon-form.java new file mode 100644 index 0000000000..8c76b9e7b0 --- /dev/null +++ b/Task/Reduced-row-echelon-form/Java/reduced-row-echelon-form.java @@ -0,0 +1,260 @@ +import java.util.*; +import java.lang.Math; +import org.apache.commons.math.fraction.Fraction; +import org.apache.commons.math.fraction.FractionConversionException; + +/* Matrix class + * Handles elementary Matrix operations: + * Interchange + * Multiply and Add + * Scale + * Reduced Row Echelon Form + */ +class Matrix { + LinkedList> matrix; + int numRows; + int numCols; + + static class Coordinate { + int row; + int col; + + Coordinate(int r, int c) { + row = r; + col = c; + } + + public String toString() { + return "(" + row + ", " + col + ")"; + } + } + + Matrix(double [][] m) { + numRows = m.length; + numCols = m[0].length; + + matrix = new LinkedList>(); + + for (int i = 0; i < numRows; i++) { + matrix.add(new LinkedList()); + for (int j = 0; j < numCols; j++) { + try { + matrix.get(i).add(new Fraction(m[i][j])); + } catch (FractionConversionException e) { + System.err.println("Fraction could not be converted from double by apache commons . . ."); + } + } + } + } + + public void Interchange(Coordinate a, Coordinate b) { + LinkedList temp = matrix.get(a.row); + matrix.set(a.row, matrix.get(b.row)); + matrix.set(b.row, temp); + + int t = a.row; + a.row = b.row; + b.row = t; + } + + public void Scale(Coordinate x, Fraction d) { + LinkedList row = matrix.get(x.row); + for (int i = 0; i < numCols; i++) { + row.set(i, row.get(i).multiply(d)); + } + } + + public void MultiplyAndAdd(Coordinate to, Coordinate from, Fraction scalar) { + LinkedList row = matrix.get(to.row); + LinkedList rowMultiplied = matrix.get(from.row); + + for (int i = 0; i < numCols; i++) { + row.set(i, row.get(i).add((rowMultiplied.get(i).multiply(scalar)))); + } + } + + public void RREF() { + Coordinate pivot = new Coordinate(0,0); + + int submatrix = 0; + for (int x = 0; x < numCols; x++) { + pivot = new Coordinate(pivot.row, x); + //Step 1 + //Begin with the leftmost nonzero column. This is a pivot column. The pivot position is at the top. + for (int i = x; i < numCols; i++) { + if (isColumnZeroes(pivot) == false) { + break; + } else { + pivot.col = i; + } + } + //Step 2 + //Select a nonzero entry in the pivot column with the highest absolute value as a pivot. + pivot = findPivot(pivot); + + if (getCoordinate(pivot).doubleValue() == 0.0) { + pivot.row++; + continue; + } + + //If necessary, interchange rows to move this entry into the pivot position. + //move this row to the top of the submatrix + if (pivot.row != submatrix) { + Interchange(new Coordinate(submatrix, pivot.col), pivot); + } + + //Force pivot to be 1 + if (getCoordinate(pivot).doubleValue() != 1) { + /* + System.out.println(getCoordinate(pivot)); + System.out.println(pivot); + System.out.println(matrix); + */ + Fraction scalar = getCoordinate(pivot).reciprocal(); + Scale(pivot, scalar); + } + //Step 3 + //Use row replacement operations to create zeroes in all positions below the pivot. + //belowPivot = belowPivot + (Pivot * -belowPivot) + for (int i = pivot.row; i < numRows; i++) { + if (i == pivot.row) { + continue; + } + Coordinate belowPivot = new Coordinate(i, pivot.col); + Fraction complement = (getCoordinate(belowPivot).negate().divide(getCoordinate(pivot))); + MultiplyAndAdd(belowPivot, pivot, complement); + } + //Step 5 + //Beginning with the rightmost pivot and working upward and to the left, create zeroes above each pivot. + //If a pivot is not 1, make it 1 by a scaling operation. + //Use row replacement operations to create zeroes in all positions above the pivot + for (int i = pivot.row; i >= 0; i--) { + if (i == pivot.row) { + if (getCoordinate(pivot).doubleValue() != 1.0) { + Scale(pivot, getCoordinate(pivot).reciprocal()); + } + continue; + } + if (i == pivot.row) { + continue; + } + + Coordinate abovePivot = new Coordinate(i, pivot.col); + Fraction complement = (getCoordinate(abovePivot).negate().divide(getCoordinate(pivot))); + MultiplyAndAdd(abovePivot, pivot, complement); + } + //Step 4 + //Ignore the row containing the pivot position and cover all rows, if any, above it. + //Apply steps 1-3 to the remaining submatrix. Repeat until there are no more nonzero entries. + if ((pivot.row + 1) >= numRows || isRowZeroes(new Coordinate(pivot.row+1, pivot.col))) { + break; + } + + submatrix++; + pivot.row++; + } + } + + public boolean isColumnZeroes(Coordinate a) { + for (int i = 0; i < numRows; i++) { + if (matrix.get(i).get(a.col).doubleValue() != 0.0) { + return false; + } + } + + return true; + } + + public boolean isRowZeroes(Coordinate a) { + for (int i = 0; i < numCols; i++) { + if (matrix.get(a.row).get(i).doubleValue() != 0.0) { + return false; + } + } + + return true; + } + + public Coordinate findPivot(Coordinate a) { + int first_row = a.row; + Coordinate pivot = new Coordinate(a.row, a.col); + Coordinate current = new Coordinate(a.row, a.col); + + for (int i = a.row; i < (numRows - first_row); i++) { + current.row = i; + if (getCoordinate(current).doubleValue() == 1.0) { + Interchange(current, a); + } + } + + current.row = a.row; + for (int i = current.row; i < (numRows - first_row); i++) { + current.row = i; + if (getCoordinate(current).doubleValue() != 0) { + pivot.row = i; + break; + } + } + + + return pivot; + } + + public Fraction getCoordinate(Coordinate a) { + return matrix.get(a.row).get(a.col); + } + + public String toString() { + return matrix.toString().replace("], ", "]\n"); + } + + public static void main (String[] args) { + double[][] matrix_1 = { + {1, 2, -1, -4}, + {2, 3, -1, -11}, + {-2, 0, -3, 22} + }; + + Matrix x = new Matrix(matrix_1); + System.out.println("before\n" + x.toString() + "\n"); + x.RREF(); + System.out.println("after\n" + x.toString() + "\n"); + + double matrix_2 [][] = { + {2, 0, -1, 0, 0}, + {1, 0, 0, -1, 0}, + {3, 0, 0, -2, -1}, + {0, 1, 0, 0, -2}, + {0, 1, -1, 0, 0} + }; + + Matrix y = new Matrix(matrix_2); + System.out.println("before\n" + y.toString() + "\n"); + y.RREF(); + System.out.println("after\n" + y.toString() + "\n"); + + double matrix_3 [][] = { + {1, 2, 3, 4, 3, 1}, + {2, 4, 6, 2, 6, 2}, + {3, 6, 18, 9, 9, -6}, + {4, 8, 12, 10, 12, 4}, + {5, 10, 24, 11, 15, -4} + }; + + Matrix z = new Matrix(matrix_3); + System.out.println("before\n" + z.toString() + "\n"); + z.RREF(); + System.out.println("after\n" + z.toString() + "\n"); + + double matrix_4 [][] = { + {0, 1}, + {1, 2}, + {0,5} + }; + + Matrix a = new Matrix(matrix_4); + System.out.println("before\n" + a.toString() + "\n"); + a.RREF(); + System.out.println("after\n" + a.toString() + "\n"); + } +} diff --git a/Task/Reduced-row-echelon-form/JavaScript/reduced-row-echelon-form.js b/Task/Reduced-row-echelon-form/JavaScript/reduced-row-echelon-form.js new file mode 100644 index 0000000000..167667b5d5 --- /dev/null +++ b/Task/Reduced-row-echelon-form/JavaScript/reduced-row-echelon-form.js @@ -0,0 +1,54 @@ +// modifies the matrix in-place +Matrix.prototype.toReducedRowEchelonForm = function() { + var lead = 0; + for (var r = 0; r < this.rows(); r++) { + if (this.columns() <= lead) { + return; + } + var i = r; + while (this.mtx[i][lead] == 0) { + i++; + if (this.rows() == i) { + i = r; + lead++; + if (this.columns() == lead) { + return; + } + } + } + + var tmp = this.mtx[i]; + this.mtx[i] = this.mtx[r]; + this.mtx[r] = tmp; + + var val = this.mtx[r][lead]; + for (var j = 0; j < this.columns(); j++) { + this.mtx[r][j] /= val; + } + + for (var i = 0; i < this.rows(); i++) { + if (i == r) continue; + val = this.mtx[i][lead]; + for (var j = 0; j < this.columns(); j++) { + this.mtx[i][j] -= val * this.mtx[r][j]; + } + } + lead++; + } + return this; +} + +var m = new Matrix([ + [ 1, 2, -1, -4], + [ 2, 3, -1,-11], + [-2, 0, -3, 22] +]); +print(m.toReducedRowEchelonForm()); +print(); + +m = new Matrix([ + [ 1, 2, 3, 7], + [-4, 7,-2, 7], + [ 3, 3, 0, 7] +]); +print(m.toReducedRowEchelonForm()); diff --git a/Task/Reduced-row-echelon-form/Lua/reduced-row-echelon-form.lua b/Task/Reduced-row-echelon-form/Lua/reduced-row-echelon-form.lua new file mode 100644 index 0000000000..8951cdcc98 --- /dev/null +++ b/Task/Reduced-row-echelon-form/Lua/reduced-row-echelon-form.lua @@ -0,0 +1,46 @@ +function ToReducedRowEchelonForm ( M ) + local lead = 1 + local n_rows, n_cols = #M, #M[1] + + for r = 1, n_rows do + if n_cols <= lead then break end + + local i = r + while M[i][lead] == 0 do + i = i + 1 + if n_rows == i then + i = r + lead = lead + 1 + if n_cols == lead then break end + end + end + M[i], M[r] = M[r], M[i] + + local m = M[r][lead] + for k = 1, n_cols do + M[r][k] = M[r][k] / m + end + for i = 1, n_rows do + if i ~= r then + local m = M[i][lead] + for k = 1, n_cols do + M[i][k] = M[i][k] - m * M[r][k] + end + end + end + lead = lead + 1 + end +end + +M = { { 1, 2, -1, -4 }, + { 2, 3, -1, -11 }, + { -2, 0, -3, 22 } } + +res = ToReducedRowEchelonForm( M ) + +for i = 1, #M do + for j = 1, #M[1] do + io.write( M[i][j], " " ) + end + io.write( "\n" ) +end diff --git a/Task/Reduced-row-echelon-form/MATLAB/reduced-row-echelon-form.m b/Task/Reduced-row-echelon-form/MATLAB/reduced-row-echelon-form.m new file mode 100644 index 0000000000..f8fbf9bea2 --- /dev/null +++ b/Task/Reduced-row-echelon-form/MATLAB/reduced-row-echelon-form.m @@ -0,0 +1 @@ +rref([1, 2, -1, -4; 2, 3, -1, -11; -2, 0, -3, 22]) diff --git a/Task/Reduced-row-echelon-form/Mathematica/reduced-row-echelon-form-1.math b/Task/Reduced-row-echelon-form/Mathematica/reduced-row-echelon-form-1.math new file mode 100644 index 0000000000..00cab77734 --- /dev/null +++ b/Task/Reduced-row-echelon-form/Mathematica/reduced-row-echelon-form-1.math @@ -0,0 +1 @@ +RowReduce[{{1, 2, -1, -4}, {2, 3, -1, -11}, {-2, 0, -3, 22}}] diff --git a/Task/Reduced-row-echelon-form/Mathematica/reduced-row-echelon-form-2.math b/Task/Reduced-row-echelon-form/Mathematica/reduced-row-echelon-form-2.math new file mode 100644 index 0000000000..1fcbdfa77b --- /dev/null +++ b/Task/Reduced-row-echelon-form/Mathematica/reduced-row-echelon-form-2.math @@ -0,0 +1 @@ +{{1, 0, 0, -8}, {0, 1, 0, 1}, {0, 0, 1, -2}} diff --git a/Task/Reduced-row-echelon-form/Maxima/reduced-row-echelon-form.maxima b/Task/Reduced-row-echelon-form/Maxima/reduced-row-echelon-form.maxima new file mode 100644 index 0000000000..216417e8c9 --- /dev/null +++ b/Task/Reduced-row-echelon-form/Maxima/reduced-row-echelon-form.maxima @@ -0,0 +1,10 @@ +rref(a):=block([p,q,k],[p,q]:matrix_size(a),a:echelon(a), + for i:p thru 2 step -1 do ( + if not integerp(k:for j thru q do + if a[i,j]#0 then return(j)) then return(), + for j from i-1 thru 1 step -1 do a:rowop(a,j,i,a[j,k])), + a)$ + +m:matrix([1,2,-1,-4],[2,3,-1,-11],[-2,0,-3,22]); +rref(m); +matrix([1,0,0,-8],[0,1,0,1],[0,0,1,-2]) diff --git a/Task/Reduced-row-echelon-form/OCaml/reduced-row-echelon-form-1.ocaml b/Task/Reduced-row-echelon-form/OCaml/reduced-row-echelon-form-1.ocaml new file mode 100644 index 0000000000..cce0dbc001 --- /dev/null +++ b/Task/Reduced-row-echelon-form/OCaml/reduced-row-echelon-form-1.ocaml @@ -0,0 +1,51 @@ +let swap_rows m i j = + let tmp = m.(i) in + m.(i) <- m.(j); + m.(j) <- tmp; +;; + +let rref m = + try + let lead = ref 0 + and rows = Array.length m + and cols = Array.length m.(0) in + for r = 0 to pred rows do + if cols <= !lead then + raise Exit; + let i = ref r in + while m.(!i).(!lead) = 0 do + incr i; + if rows = !i then begin + i := r; + incr lead; + if cols = !lead then + raise Exit; + end + done; + swap_rows m !i r; + let lv = m.(r).(!lead) in + m.(r) <- Array.map (fun v -> v / lv) m.(r); + for i = 0 to pred rows do + if i <> r then + let lv = m.(i).(!lead) in + m.(i) <- Array.mapi (fun i iv -> iv - lv * m.(r).(i)) m.(i); + done; + incr lead; + done + with Exit -> () +;; + +let () = + let m = + [| [| 1; 2; -1; -4 |]; + [| 2; 3; -1; -11 |]; + [| -2; 0; -3; 22 |]; |] + in + rref m; + + Array.iter (fun row -> + Array.iter (fun v -> + Printf.printf " %d" v + ) row; + print_newline() + ) m diff --git a/Task/Reduced-row-echelon-form/OCaml/reduced-row-echelon-form-2.ocaml b/Task/Reduced-row-echelon-form/OCaml/reduced-row-echelon-form-2.ocaml new file mode 100644 index 0000000000..c1628886a7 --- /dev/null +++ b/Task/Reduced-row-echelon-form/OCaml/reduced-row-echelon-form-2.ocaml @@ -0,0 +1,28 @@ +let rref m = + let nr, nc = Array.length m, Array.length m.(0) in + let add r s k = + for i = 0 to nc-1 do m.(r).(i) <- m.(r).(i) +. m.(s).(i)*.k done in + for c = 0 to min (nc-1) (nr-1) do + for r = c+1 to nr-1 do + if abs_float m.(c).(c) < abs_float m.(r).(c) then + let v = m.(r) in (m.(r) <- m.(c); m.(c) <- v) + done; + let t = m.(c).(c) in + if t <> 0.0 then + begin + for r = 0 to nr-1 do if r <> c then add r c (-.m.(r).(c)/.t) done; + for i = 0 to nc-1 do m.(c).(i) <- m.(c).(i)/.t done + end + done;; + +let mat = [| + [| 1.0; 2.0; -.1.0; -.4.0;|]; + [| 2.0; 3.0; -.1.0; -.11.0;|]; + [|-.2.0; 0.0; -.3.0; 22.0;|] + |] in +let pr v = Array.iter (Printf.printf " %9.4f") v; print_newline() in +let show = Array.iter pr in + show mat; + print_newline(); + rref mat; + show mat diff --git a/Task/Reduced-row-echelon-form/Objeck/reduced-row-echelon-form.objeck b/Task/Reduced-row-echelon-form/Objeck/reduced-row-echelon-form.objeck new file mode 100644 index 0000000000..0cfe8eed66 --- /dev/null +++ b/Task/Reduced-row-echelon-form/Objeck/reduced-row-echelon-form.objeck @@ -0,0 +1,68 @@ +class RowEchelon { + function : Main(args : String[]) ~ Nil { + matrix := [ + [1, 2, -1, -4 ] + [2, 3, -1, -11 ] + [-2, 0, -3, 22] + ]; + + matrix := Rref(matrix); + + sizes := matrix->Size(); + for(i := 0; i < sizes[0]; i += 1;) { + for(j := 0; j < sizes[1]; j += 1;) { + IO.Console->Print(matrix[i,j])->Print(","); + }; + IO.Console->PrintLine(); + }; + } + + function : native : Rref(matrix : Int[,]) ~ Int[,] { + lead := 0; + sizes := matrix->Size(); + rowCount := sizes[0]; + columnCount := sizes[1]; + + for(r := 0; r < rowCount; r+=1;) { + if (columnCount <= lead) { + break; + }; + + i := r; + while(matrix[i, lead] = 0) { + i+=1; + if (i = rowCount) { + i := r; + lead += 1; + if (columnCount = lead) { + lead-=1; + break; + }; + }; + }; + + for (j := 0; j < columnCount; j+=1;) { + temp := matrix[r, j]; + matrix[r, j] := matrix[i, j]; + matrix[i, j] := temp; + }; + + div := matrix[r, lead]; + for(j := 0; j < columnCount; j+=1;) { + matrix[r, j] /= div; + }; + + for(j := 0; j < rowCount; j+=1;) { + if (j <> r) { + sub := matrix[j, lead]; + for (k := 0; k < columnCount; k+=1;) { + matrix[j, k] -= sub * matrix[r, k]; + }; + }; + }; + lead+=1; + }; + + return matrix; + } +} diff --git a/Task/Reduced-row-echelon-form/Octave/reduced-row-echelon-form.octave b/Task/Reduced-row-echelon-form/Octave/reduced-row-echelon-form.octave new file mode 100644 index 0000000000..3070b5581b --- /dev/null +++ b/Task/Reduced-row-echelon-form/Octave/reduced-row-echelon-form.octave @@ -0,0 +1,3 @@ +A = [ 1, 2, -1, -4; 2, 3, -1, -11; -2, 0, -3, 22]; +refA = rref(A); +disp(refA); diff --git a/Task/Reduced-row-echelon-form/PARI-GP/reduced-row-echelon-form-1.pari b/Task/Reduced-row-echelon-form/PARI-GP/reduced-row-echelon-form-1.pari new file mode 100644 index 0000000000..12b59e49a0 --- /dev/null +++ b/Task/Reduced-row-echelon-form/PARI-GP/reduced-row-echelon-form-1.pari @@ -0,0 +1,5 @@ +rref(M)={ + my(d=matsize(M)); + if(d[1]+1 != d[2], error("Bad size in rref"), d=d[1]); + concat(matid(d), matsolve(matrix(d,d,x,y,M[x,y]), M[,d+1])) +}; diff --git a/Task/Reduced-row-echelon-form/PARI-GP/reduced-row-echelon-form-2.pari b/Task/Reduced-row-echelon-form/PARI-GP/reduced-row-echelon-form-2.pari new file mode 100644 index 0000000000..de6a9dd0eb --- /dev/null +++ b/Task/Reduced-row-echelon-form/PARI-GP/reduced-row-echelon-form-2.pari @@ -0,0 +1 @@ +rref([1,2,-1,-4;2,3,-1,-11;-2,0,-3,22]) diff --git a/Task/Reduced-row-echelon-form/PHP/reduced-row-echelon-form.php b/Task/Reduced-row-echelon-form/PHP/reduced-row-echelon-form.php new file mode 100644 index 0000000000..6fb979b615 --- /dev/null +++ b/Task/Reduced-row-echelon-form/PHP/reduced-row-echelon-form.php @@ -0,0 +1,47 @@ += $columnCount) + break; { + $i = $r; + while ($matrix[$i][$lead] == 0) { + $i++; + if ($i == $rowCount) { + $i = $r; + $lead++; + if ($lead == $columnCount) + return $matrix; + } + } + $temp = $matrix[$r]; + $matrix[$r] = $matrix[$i]; + $matrix[$i] = $temp; + } { + $lv = $matrix[$r][$lead]; + for ($j = 0; $j < $columnCount; $j++) { + $matrix[$r][$j] = $matrix[$r][$j] / $lv; + } + } + for ($i = 0; $i < $rowCount; $i++) { + if ($i != $r) { + $lv = $matrix[$i][$lead]; + for ($j = 0; $j < $columnCount; $j++) { + $matrix[$i][$j] -= $lv * $matrix[$r][$j]; + } + } + } + $lead++; + } + return $matrix; +} +?> diff --git a/Task/Reduced-row-echelon-form/Perl-6/reduced-row-echelon-form-1.pl6 b/Task/Reduced-row-echelon-form/Perl-6/reduced-row-echelon-form-1.pl6 new file mode 100644 index 0000000000..2d4c9e69fb --- /dev/null +++ b/Task/Reduced-row-echelon-form/Perl-6/reduced-row-echelon-form-1.pl6 @@ -0,0 +1,83 @@ +sub rref (@m is rw) { + @m or return; + my ($lead, $rows, $cols) = 0, +@m, +@m[0]; + + for ^$rows -> $r { + $lead < $cols or return @m; + my $i = $r; + + until @m[$i][$lead] { + ++$i == $rows or next; + $i = $r; + ++$lead == $cols and return @m; + } + + @m[$i, $r] = @m[$r, $i]; + + my $lv = @m[$r][$lead]; + @m[$r] »/=» $lv; + + for ^$rows -> $n { + next if $n == $r; + @m[$n] »-=» @m[$r] »*» @m[$n][$lead]; + } + ++$lead; + } + @m; +} + +sub rat_or_int ($num is rw) { + return $num unless $num ~~ Rat; + return $num.Int if $num.denominator == 1; + return $num.perl; +} + +sub say_it ($message, @array) { + say "\n$message"; + $_».&rat_or_int.fmt(" %5s").say for @array; +} + +my @M = ( + [ # base test case + [ 1, 2, -1, -4 ], + [ 2, 3, -1, -11 ], + [ -2, 0, -3, 22 ], + ], + [ # mix of number styles + [ 3, 0, -3, 1 ], + [ .5, 3/2, -3, -2 ], + [ .2, 4/5, -1.6, .3 ], + ], + [ # degenerate case + [ 1, 2, 3, 4, 3, 1], + [ 2, 4, 6, 2, 6, 2], + [ 3, 6, 18, 9, 9, -6], + [ 4, 8, 12, 10, 12, 4], + [ 5, 10, 24, 11, 15, -4], + ], + [ # larger matrix + [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0], + [1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0], + [1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0], + [0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0], + [0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0], + [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0], + [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0], + [0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0], + [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0], + [0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0], + [0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -1, 0], + [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0], + [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1], + [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0], + ] +); + +for @M -> @matrix { + say_it( 'Original Matrix', @matrix ); + say_it( 'Reduced Row Echelon Form Matrix', rref(@matrix) ); + say "\n"; +} diff --git a/Task/Reduced-row-echelon-form/Perl-6/reduced-row-echelon-form-2.pl6 b/Task/Reduced-row-echelon-form/Perl-6/reduced-row-echelon-form-2.pl6 new file mode 100644 index 0000000000..34f57858dd --- /dev/null +++ b/Task/Reduced-row-echelon-form/Perl-6/reduced-row-echelon-form-2.pl6 @@ -0,0 +1,32 @@ +sub swap_rows ( @M, $r1, $r2 ) { @M[ $r1, $r2 ] = @M[ $r2, $r1 ] }; +sub scale_row ( @M, $scale, $r ) { @M[$r] = @M[$r] X* $scale }; +sub shear_row ( @M, $scale, $r1, $r2 ) { @M[$r1] = @M[$r1] Z+ ( @M[$r2] X* $scale ) }; +sub reduce_row ( @M, $r, $c ) { scale_row( @M, 1/@M[$r][$c], $r ) }; +sub clear_column ( @M, $r, $c ) { + for @M.keys.grep( * != $r ) -> $row_num { + shear_row( @M, -1*@M[$row_num][$c], $row_num, $r ); + } +} + +my @M = ( + [< 1 2 -1 -4 >], + [< 2 3 -1 -11 >], + [< -2 0 -3 22 >], +); + +my $column_count = +@( @M[0] ); + +my $current_col = 0; +while all( @M».[$current_col] ) == 0 { + $current_col++; + return if $current_col == $column_count; # Matrix was all-zeros. +} + +for @M.keys -> $current_row { + reduce_row( @M, $current_row, $current_col ); + clear_column( @M, $current_row, $current_col ); + $current_col++; + return if $current_col == $column_count; +} + +say @($_)».fmt(' %4g') for @M; diff --git a/Task/Reduced-row-echelon-form/Perl-6/reduced-row-echelon-form-3.pl6 b/Task/Reduced-row-echelon-form/Perl-6/reduced-row-echelon-form-3.pl6 new file mode 100644 index 0000000000..37708e0f6d --- /dev/null +++ b/Task/Reduced-row-echelon-form/Perl-6/reduced-row-echelon-form-3.pl6 @@ -0,0 +1,43 @@ +class Matrix is Array { + method unscale_row ( @M: $scale, $row ) { + @M[$row] = @M[$row] X/ $scale; + } + method unshear_row ( @M: $scale, $r1, $r2 ) { + @M[$r1] = @M[$r1] Z- ( @M[$r2] X* $scale ); + } + method reduce_row ( @M: $row, $col ) { + @M.unscale_row( @M[$row][$col], $row ); + } + method clear_column ( @M: $row, $col ) { + for @M.keys.grep( * != $row ) -> $scanning_row { + @M.unshear_row( @M[$scanning_row][$col], $scanning_row, $row ); + } + } + method reduced_row_echelon_form ( @M: ) { + my $column_count = +@( @M[0] ); + + my $current_col = 0; + # Skip past all-zero columns. + while all( @M».[$current_col] ) == 0 { + $current_col++; + return if $current_col == $column_count; # Matrix was all-zeros. + } + + for @M.keys -> $current_row { + @M.reduce_row( $current_row, $current_col ); + @M.clear_column( $current_row, $current_col ); + $current_col++; + return if $current_col == $column_count; + } + } +} + +my $M = Matrix.new.push( + [< 1 2 -1 -4 >], + [< 2 3 -1 -11 >], + [< -2 0 -3 22 >], +); + +$M.reduced_row_echelon_form; + +say @($_)».fmt(' %4g') for @($M); diff --git a/Task/Reduced-row-echelon-form/Perl/reduced-row-echelon-form.pl b/Task/Reduced-row-echelon-form/Perl/reduced-row-echelon-form.pl new file mode 100644 index 0000000000..8dbc72e596 --- /dev/null +++ b/Task/Reduced-row-echelon-form/Perl/reduced-row-echelon-form.pl @@ -0,0 +1,25 @@ +sub rref + {our @m; local *m = shift; + @m or return; + my ($lead, $rows, $cols) = (0, scalar(@m), scalar(@{$m[0]})); + + foreach my $r (0 .. $rows - 1) + {$lead < $cols or return; + my $i = $r; + + until ($m[$i][$lead]) + {++$i == $rows or next; + $i = $r; + ++$lead == $cols and return;} + + @m[$i, $r] = @m[$r, $i]; + my $lv = $m[$r][$lead]; + $_ /= $lv foreach @{ $m[$r] }; + + my @mr = @{ $m[$r] }; + foreach my $i (0 .. $rows - 1) + {$i == $r and next; + ($lv, my $n) = ($m[$i][$lead], -1); + $_ -= $lv * $mr[++$n] foreach @{ $m[$i] };} + + ++$lead;}} diff --git a/Task/Reduced-row-echelon-form/PicoLisp/reduced-row-echelon-form.l b/Task/Reduced-row-echelon-form/PicoLisp/reduced-row-echelon-form.l new file mode 100644 index 0000000000..1942e4e34a --- /dev/null +++ b/Task/Reduced-row-echelon-form/PicoLisp/reduced-row-echelon-form.l @@ -0,0 +1,23 @@ +(de reducedRowEchelonForm (Mat) + (let (Lead 1 Cols (length (car Mat))) + (for (X Mat X (cdr X)) + (NIL + (loop + (T (seek '((R) (n0 (get R 1 Lead))) X) + @ ) + (T (> (inc 'Lead) Cols)) ) ) + (xchg @ X) + (let D (get X 1 Lead) + (map + '((R) (set R (/ (car R) D))) + (car X) ) ) + (for Y Mat + (unless (== Y (car X)) + (let N (- (get Y Lead)) + (map + '((Dst Src) + (inc Dst (* N (car Src))) ) + Y + (car X) ) ) ) ) + (T (> (inc 'Lead) Cols)) ) ) + Mat ) diff --git a/Task/Reduced-row-echelon-form/Python/reduced-row-echelon-form.py b/Task/Reduced-row-echelon-form/Python/reduced-row-echelon-form.py new file mode 100644 index 0000000000..65e47719ea --- /dev/null +++ b/Task/Reduced-row-echelon-form/Python/reduced-row-echelon-form.py @@ -0,0 +1,35 @@ +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 + + +mtx = [ + [ 1, 2, -1, -4], + [ 2, 3, -1, -11], + [-2, 0, -3, 22],] + +ToReducedRowEchelonForm( mtx ) + +for rw in mtx: + print ', '.join( (str(rv) for rv in rw) ) diff --git a/Task/Reduced-row-echelon-form/R/reduced-row-echelon-form.r b/Task/Reduced-row-echelon-form/R/reduced-row-echelon-form.r new file mode 100644 index 0000000000..327927c078 --- /dev/null +++ b/Task/Reduced-row-echelon-form/R/reduced-row-echelon-form.r @@ -0,0 +1,33 @@ +rref <- function(m) { + pivot <- 1 + norow <- nrow(m) + nocolumn <- ncol(m) + for(r in 1:norow) { + if ( nocolumn <= pivot ) break; + i <- r + while( m[i,pivot] == 0 ) { + i <- i + 1 + if ( norow == i ) { + i <- r + pivot <- pivot + 1 + if ( nocolumn == pivot ) return(m) + } + } + trow <- m[i, ] + m[i, ] <- m[r, ] + m[r, ] <- trow + m[r, ] <- m[r, ] / m[r, pivot] + for(i in 1:norow) { + if ( i != r ) + m[i, ] <- m[i, ] - m[r, ] * m[i, pivot] + } + pivot <- pivot + 1 + } + return(m) +} + +m <- matrix(c(1, 2, -1, -4, + 2, 3, -1, -11, + -2, 0, -3, 22), 3, 4, byrow=TRUE) +print(m) +print(rref(m)) diff --git a/Task/Reduced-row-echelon-form/REXX/reduced-row-echelon-form.rexx b/Task/Reduced-row-echelon-form/REXX/reduced-row-echelon-form.rexx new file mode 100644 index 0000000000..4899769a10 --- /dev/null +++ b/Task/Reduced-row-echelon-form/REXX/reduced-row-echelon-form.rexx @@ -0,0 +1,66 @@ +/*REXX program to perform Reduced Row Echelon Form (RREF) on a matrix. */ +cols=0 /*maximum columns in any row. */ +maxW=0 /*maximum width of any element. */ +@.= /*matrix to be constructed. */ +mat.= +mat.1 = ' 1 2 -1 -4 ' +mat.2 = ' 2 3 -1 -11 ' +mat.3 = ' -2 0 -3 22 ' + + do r=1 until mat.r==''; _=mat.r /*build @.row.col from mat.n */ + do c=1 until _=''; parse var _ @.r.c _ + maxW = max(maxW, length(@.r.c)) + end /*c*/ + cols = max(cols,c) + end + +rows = r - 1 /*adjust the row count. */ +maxW = maxW + 1 /*bump the max width, better view*/ +call showMat 'original matrix' /*show the original matrix. */ +! = 1 /*set the pointer to one. */ +/*═══════════════════════════════════Reduced Row Echelon Form on matrix.*/ + do r=1 for rows while cols>! /*start to do the heavy lifting. */ + j=r + do while @.j.!==0; j = j+1 + if j==rows then do + j = r + ! = ! + 1; if cols==! then leave r + end + end /*while*/ + + do w=1 for cols while j\==r /*swap rows J,R (but not if same)*/ + parse value @.r.w @.j.w with @.j.w @.w.w + end /*w*/ + ?=@.r.! + do d=1 for cols while ?\=1 /*divide row J by @.r.p--unless 1*/ + @.r.d = @.r.d / ? + end /*d*/ + + do k=1 for rows /*sub (row K) *@.r.s from row K */ + if k==r then iterate /*skip if row k is the same as R */ + ?=@.k.! + do s=1 for cols while ?\=0 /*but not if @.r.! is 0*/ + @.k.s = @.k.s - ? * @.r.s + end /*s*/ + end /*k*/ + !=!+1 + end /*r*/ + +call showMat 'matrix RREF' /*show reduced row echelon form. */ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────SHOWMAT subroutine──────────────────*/ +showMat: parse arg title; say +say center(title,3+(cols+1)*maxW,'─'); say /*build a pretty title.*/ + + do r =1 for rows; _= + do c=1 for cols + if @.r.c=='' then do; say; say '*** error! ***'; say + say "matrix element isn't defined:" + say 'row' row", column" c'.'; say + exit 13 + end + _ = _ right(@.r.c,maxW) + end /*c*/ + say _ + end /*r*/ +return diff --git a/Task/Reduced-row-echelon-form/Racket/reduced-row-echelon-form.rkt b/Task/Reduced-row-echelon-form/Racket/reduced-row-echelon-form.rkt new file mode 100644 index 0000000000..c94d1e2d47 --- /dev/null +++ b/Task/Reduced-row-echelon-form/Racket/reduced-row-echelon-form.rkt @@ -0,0 +1,9 @@ +#lang racket +(require math) +(define (reduced-echelon M) + (matrix-row-echelon M #t #t)) + +(reduced-echelon + (matrix [[1 2 -1 -4] + [2 3 -1 -11] + [-2 0 -3 22]])) diff --git a/Task/Reduced-row-echelon-form/Ruby/reduced-row-echelon-form.rb b/Task/Reduced-row-echelon-form/Ruby/reduced-row-echelon-form.rb new file mode 100644 index 0000000000..71df98ffca --- /dev/null +++ b/Task/Reduced-row-echelon-form/Ruby/reduced-row-echelon-form.rb @@ -0,0 +1,76 @@ +require 'rational' + +# returns an 2-D array where each element is a Rational +def reduced_row_echelon_form(ary) + lead = 0 + rows = ary.size + cols = ary[0].size + rary = convert_to_rational(ary) # use rational arithmetic + catch :done do + rows.times do |r| + throw :done if cols <= lead + i = r + while rary[i][lead] == 0 + i += 1 + if rows == i + i = r + lead += 1 + throw :done if cols == lead + end + end + # swap rows i and r + rary[i], rary[r] = rary[r], rary[i] + # normalize row r + v = rary[r][lead] + rary[r].collect! {|x| x /= v} + # reduce other rows + rows.times do |i| + next if i == r + v = rary[i][lead] + rary[i].each_index {|j| rary[i][j] -= v * rary[r][j]} + end + lead += 1 + end + end + rary +end + +def convert_to_rational(ary) + new = [] + ary.each_index do |row| + new << ary[row].collect {|elem| Rational(elem)} + end + new +end + +# type should be one of :to_s, :to_i, :to_f, :to_r +def convert_to(ary, type) + new = [] + ary.each_index do |row| + new << ary[row].collect {|elem| elem.send(type)} + end + new +end + +def print_matrix(m) + max = m[0].collect {-1} + m.each {|row| row.each_index {|i| max[i] = [max[i], row[i].to_s.length].max}} + m.each {|row| row.each_index {|i| print "%#{max[i]}s " % row[i].to_s}; puts ""} +end + +mtx = [ + [ 1, 2, -1, -4], + [ 2, 3, -1,-11], + [-2, 0, -3, 22] +] +print_matrix convert_to(reduced_row_echelon_form(mtx), :to_s) +puts "" + +mtx = [ + [ 1, 2, 3, 7], + [-4, 7,-2, 7], + [ 3, 3, 0, 7] +] +reduced = reduced_row_echelon_form(mtx) +print_matrix convert_to(reduced, :to_r) +print_matrix convert_to(reduced, :to_f) diff --git a/Task/Reduced-row-echelon-form/Sage/reduced-row-echelon-form.sage b/Task/Reduced-row-echelon-form/Sage/reduced-row-echelon-form.sage new file mode 100644 index 0000000000..ded3ebc37f --- /dev/null +++ b/Task/Reduced-row-echelon-form/Sage/reduced-row-echelon-form.sage @@ -0,0 +1,5 @@ +sage: m = matrix(ZZ, [[1,2,-1,-4],[2,3,-1,-11],[-2,0,-3,22]]) +sage: m.rref() +[ 1 0 0 -8] +[ 0 1 0 1] +[ 0 0 1 -2] diff --git a/Task/Reduced-row-echelon-form/Scheme/reduced-row-echelon-form-1.ss b/Task/Reduced-row-echelon-form/Scheme/reduced-row-echelon-form-1.ss new file mode 100644 index 0000000000..502bb8722f --- /dev/null +++ b/Task/Reduced-row-echelon-form/Scheme/reduced-row-echelon-form-1.ss @@ -0,0 +1,48 @@ +(define (reduced-row-echelon-form matrix) + (define (clean-down matrix from-row column) + (cons (car matrix) + (if (zero? from-row) + (map (lambda (row) + (map - + row + (map (lambda (element) + (/ (* element (list-ref row column)) + (list-ref (car matrix) column))) + (car matrix)))) + (cdr matrix)) + (clean-down (cdr matrix) (- from-row 1) column)))) + (define (clean-up matrix until-row column) + (if (zero? until-row) + matrix + (cons (map - + (car matrix) + (map (lambda (element) + (/ (* element (list-ref (car matrix) column)) + (list-ref (list-ref matrix until-row) column))) + (list-ref matrix until-row))) + (clean-up (cdr matrix) (- until-row 1) column)))) + (define (normalise matrix row with-column) + (if (zero? row) + (cons (map (lambda (element) + (/ element (list-ref (car matrix) with-column))) + (car matrix)) + (cdr matrix)) + (cons (car matrix) (normalise (cdr matrix) (- row 1) with-column)))) + (define (repeat procedure matrix indices) + (if (null? indices) + matrix + (repeat procedure + (procedure matrix (car indices) (car indices)) + (cdr indices)))) + (define (iota start stop) + (if (> start stop) + (list) + (cons start (iota (+ start 1) stop)))) + (let ((indices (iota 0 (- (length matrix) 1)))) + (repeat normalise + (repeat clean-up + (repeat clean-down + matrix + indices) + indices) + indices))) diff --git a/Task/Reduced-row-echelon-form/Scheme/reduced-row-echelon-form-2.ss b/Task/Reduced-row-echelon-form/Scheme/reduced-row-echelon-form-2.ss new file mode 100644 index 0000000000..e03f06f48b --- /dev/null +++ b/Task/Reduced-row-echelon-form/Scheme/reduced-row-echelon-form-2.ss @@ -0,0 +1,5 @@ +(define matrix + (list (list 1 2 -1 -4) (list 2 3 -1 -11) (list -2 0 -3 22))) + +(display (reduced-row-echelon-form matrix)) +(newline) diff --git a/Task/Reduced-row-echelon-form/Scheme/reduced-row-echelon-form-3.ss b/Task/Reduced-row-echelon-form/Scheme/reduced-row-echelon-form-3.ss new file mode 100644 index 0000000000..45622adee6 --- /dev/null +++ b/Task/Reduced-row-echelon-form/Scheme/reduced-row-echelon-form-3.ss @@ -0,0 +1 @@ +((1 0 0 -8) (0 1 0 1) (0 0 1 -2)) diff --git a/Task/Reduced-row-echelon-form/Seed7/reduced-row-echelon-form.seed7 b/Task/Reduced-row-echelon-form/Seed7/reduced-row-echelon-form.seed7 new file mode 100644 index 0000000000..d7d97c9b9d --- /dev/null +++ b/Task/Reduced-row-echelon-form/Seed7/reduced-row-echelon-form.seed7 @@ -0,0 +1,54 @@ +const type: matrix is array array float; + +const proc: toReducedRowEchelonForm (inout matrix: mat) is func + local + var integer: numRows is 0; + var integer: numColumns is 0; + var integer: row is 0; + var integer: column is 0; + var integer: pivot is 0; + var float: factor is 0.0; + begin + numRows := length(mat); + numColumns := length(mat[1]); + for row range numRows downto 1 do + column := 1; + while column <= numColumns and mat[row][column] = 0.0 do + incr(column); + end while; + if column > numColumns then + # Empty rows are moved to the bottom + mat := mat[.. pred(row)] & mat[succ(row) ..] & [] (mat[row]); + decr(numRows); + end if; + end for; + for pivot range 1 to numRows do + if mat[pivot][pivot] = 0.0 then + # Find a row were the pivot column is not zero + row := 1; + while row <= numRows and mat[row][pivot] = 0.0 do + incr(row); + end while; + # Add row were the pivot column is not zero + for column range 1 to numColumns do + mat[pivot][column] +:= mat[row][column]; + end for; + end if; + if mat[pivot][pivot] <> 1.0 then + # Make sure that the pivot element is 1.0 + factor := 1.0 / mat[pivot][pivot]; + for column range pivot to numColumns do + mat[pivot][column] := mat[pivot][column] * factor; + end for; + end if; + for row range 1 to numRows do + if row <> pivot and mat[row][pivot] <> 0.0 then + # Make sure that in all other rows the pivot column contains zero + factor := -mat[row][pivot]; + for column range pivot to numColumns do + mat[row][column] +:= mat[pivot][column] * factor; + end for; + end if; + end for; + end for; + end func; diff --git a/Task/Reduced-row-echelon-form/TI-89-BASIC/reduced-row-echelon-form.ti-89 b/Task/Reduced-row-echelon-form/TI-89-BASIC/reduced-row-echelon-form.ti-89 new file mode 100644 index 0000000000..4f94c03116 --- /dev/null +++ b/Task/Reduced-row-echelon-form/TI-89-BASIC/reduced-row-echelon-form.ti-89 @@ -0,0 +1 @@ +rref([1,2,–1,–4; 2,3,–1,–11; –2,0,–3,22]) diff --git a/Task/Reduced-row-echelon-form/Tcl/reduced-row-echelon-form.tcl b/Task/Reduced-row-echelon-form/Tcl/reduced-row-echelon-form.tcl new file mode 100644 index 0000000000..59f8bc1d1f --- /dev/null +++ b/Task/Reduced-row-echelon-form/Tcl/reduced-row-echelon-form.tcl @@ -0,0 +1,49 @@ +package require Tcl 8.5 +namespace path {::tcl::mathop ::tcl::mathfunc} + +proc toRREF {m} { + set lead 0 + lassign [size $m] rows cols + 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 idx [list $i $r] row [list [lindex $m $r] [lindex $m $i]] { + lset m $idx $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 +} + +set m {{1 2 -1 -4} {2 3 -1 -11} {-2 0 -3 22}} +print_matrix $m +print_matrix [toRREF $m] diff --git a/Task/Reduced-row-echelon-form/Ursala/reduced-row-echelon-form-1.ursala b/Task/Reduced-row-echelon-form/Ursala/reduced-row-echelon-form-1.ursala new file mode 100644 index 0000000000..ae53181052 --- /dev/null +++ b/Task/Reduced-row-echelon-form/Ursala/reduced-row-echelon-form-1.ursala @@ -0,0 +1,17 @@ +#import std +#import flo + +pivot = -, + <2.,3.,-1.,-11.>, + <-2.,0.,-3.,22.>> diff --git a/Task/Reduced-row-echelon-form/Ursala/reduced-row-echelon-form-2.ursala b/Task/Reduced-row-echelon-form/Ursala/reduced-row-echelon-form-2.ursala new file mode 100644 index 0000000000..cb79514c32 --- /dev/null +++ b/Task/Reduced-row-echelon-form/Ursala/reduced-row-echelon-form-2.ursala @@ -0,0 +1,3 @@ +#import lin + +rref = @ySzSX msolve; ^plrNCTS\~& ~&iiDlSzyCK9+ :/1.+ 0.!*t diff --git a/Task/Regular-expressions/0DESCRIPTION b/Task/Regular-expressions/0DESCRIPTION new file mode 100644 index 0000000000..66e1e182e1 --- /dev/null +++ b/Task/Regular-expressions/0DESCRIPTION @@ -0,0 +1,3 @@ +The goal of this task is +* to match a string against a regular expression +* to substitute part of a string using a regular expression diff --git a/Task/Regular-expressions/1META.yaml b/Task/Regular-expressions/1META.yaml new file mode 100644 index 0000000000..88eb5468ca --- /dev/null +++ b/Task/Regular-expressions/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Text processing diff --git a/Task/Regular-expressions/ALGOL-68/regular-expressions-1.alg b/Task/Regular-expressions/ALGOL-68/regular-expressions-1.alg new file mode 100644 index 0000000000..7e5b802824 --- /dev/null +++ b/Task/Regular-expressions/ALGOL-68/regular-expressions-1.alg @@ -0,0 +1,13 @@ +INT match=0, no match=1, out of memory error=2, other error=3; + +STRING str := "i am a string"; + +# Match: # + +STRING m := "string$"; +INT start, end; +IF grep in string(m, str, start, end) = match THEN printf(($"Ends with """g""""l$, str[start:end])) FI; + +# Replace: # + +IF sub in string(" a ", " another ",str) = match THEN printf(($gl$, str)) FI; diff --git a/Task/Regular-expressions/ALGOL-68/regular-expressions-2.alg b/Task/Regular-expressions/ALGOL-68/regular-expressions-2.alg new file mode 100644 index 0000000000..49da436ebf --- /dev/null +++ b/Task/Regular-expressions/ALGOL-68/regular-expressions-2.alg @@ -0,0 +1,12 @@ +FORMAT pattern = $ddd" "c("cats","dogs")$; +FILE file; STRING book; associate(file, book); +on value error(file, (REF FILE f)BOOL: stop); +on format error(file, (REF FILE f)BOOL: stop); + +book := "100 dogs"; +STRUCT(INT count, type) dalmatians; + +getf(file, (pattern, dalmatians)); +print(("Dalmatians: ", dalmatians, new line)); +count OF dalmatians +:=1; +printf(($"Gives: "$, pattern, dalmatians, $l$)) diff --git a/Task/Regular-expressions/AWK/regular-expressions-1.awk b/Task/Regular-expressions/AWK/regular-expressions-1.awk new file mode 100644 index 0000000000..9347e0c209 --- /dev/null +++ b/Task/Regular-expressions/AWK/regular-expressions-1.awk @@ -0,0 +1,4 @@ +$ awk '{if($0~/[A-Z]/)print "uppercase detected"}' +abc +ABC +uppercase detected diff --git a/Task/Regular-expressions/AWK/regular-expressions-2.awk b/Task/Regular-expressions/AWK/regular-expressions-2.awk new file mode 100644 index 0000000000..c28d1a9753 --- /dev/null +++ b/Task/Regular-expressions/AWK/regular-expressions-2.awk @@ -0,0 +1,4 @@ +awk '/[A-Z]/{print "uppercase detected"}' +def +DeF +uppercase detected diff --git a/Task/Regular-expressions/AWK/regular-expressions-3.awk b/Task/Regular-expressions/AWK/regular-expressions-3.awk new file mode 100644 index 0000000000..f2c47430ae --- /dev/null +++ b/Task/Regular-expressions/AWK/regular-expressions-3.awk @@ -0,0 +1,6 @@ +$ awk '{gsub(/[A-Z]/,"*");print}' +abCDefG +ab**ef* +$ awk '{gsub(/[A-Z]/,"(&)");print}' +abCDefGH +ab(C)(D)ef(G)(H) diff --git a/Task/Regular-expressions/AWK/regular-expressions-4.awk b/Task/Regular-expressions/AWK/regular-expressions-4.awk new file mode 100644 index 0000000000..0a5b217adc --- /dev/null +++ b/Task/Regular-expressions/AWK/regular-expressions-4.awk @@ -0,0 +1,3 @@ +$ awk '{gsub(/[A-Z]+/,"(&)");print}' +abCDefGH +ab(CD)ef(GH) diff --git a/Task/Regular-expressions/Ada/regular-expressions.ada b/Task/Regular-expressions/Ada/regular-expressions.ada new file mode 100644 index 0000000000..2cf1441f12 --- /dev/null +++ b/Task/Regular-expressions/Ada/regular-expressions.ada @@ -0,0 +1,43 @@ +with Ada.Text_IO; with Gnat.Regpat; use Ada.Text_IO; + +procedure Regex is + + package Pat renames Gnat.Regpat; + + procedure Search_For_Pattern(Compiled_Expression: Pat.Pattern_Matcher; + Search_In: String; + First, Last: out Positive; + Found: out Boolean) is + Result: Pat.Match_Array (0 .. 1); + begin + Pat.Match(Compiled_Expression, Search_In, Result); + Found := not Pat."="(Result(1), Pat.No_Match); + if Found then + First := Result(1).First; + Last := Result(1).Last; + end if; + end Search_For_Pattern; + + Word_Pattern: constant String := "([a-zA-Z]+)"; + + Str: String:= "I love PATTERN matching!"; + Current_First: Positive := Str'First; + First, Last: Positive; + Found: Boolean; + +begin + -- first, find all the words in Str + loop + Search_For_Pattern(Pat.Compile(Word_Pattern), + Str(Current_First .. Str'Last), + First, Last, Found); + exit when not Found; + Put_Line("<" & Str(First .. Last) & ">"); + Current_First := Last+1; + end loop; + + -- second, replace "PATTERN" in Str by "pattern" + Search_For_Pattern(Pat.Compile("(PATTERN)"), Str, First, Last, Found); + Str := Str(Str'First .. First-1) & "pattern" & Str(Last+1 .. Str'Last); + Put_Line(Str); +end Regex; diff --git a/Task/Regular-expressions/AppleScript/regular-expressions.applescript b/Task/Regular-expressions/AppleScript/regular-expressions.applescript new file mode 100644 index 0000000000..677369aab6 --- /dev/null +++ b/Task/Regular-expressions/AppleScript/regular-expressions.applescript @@ -0,0 +1,11 @@ +try + find text ".*string$" in "I am a string" with regexp +on error message + return message +end try + +try + change "original" into "modified" in "I am the original string" with regexp +on error message + return message +end try diff --git a/Task/Regular-expressions/Argile/regular-expressions.argile b/Task/Regular-expressions/Argile/regular-expressions.argile new file mode 100644 index 0000000000..58685475a0 --- /dev/null +++ b/Task/Regular-expressions/Argile/regular-expressions.argile @@ -0,0 +1,22 @@ +use std, regex + +(: matching :) +if "some matchable string" =~ /^some" "+[a-z]*" "+string$/ + echo string matches +else + echo string "doesn't" match + +(: replacing :) +let t = strdup "some allocated string" +t =~ s/a/"4"/g +t =~ s/e/"3"/g +t =~ s/i/"1"/g +t =~ s/o/"0"/g +t =~ s/s/$/g +print t +free t + +(: flushing regex allocations :) +uninit regex + +check mem leak; use dbg (:optional:) diff --git a/Task/Regular-expressions/AutoHotkey/regular-expressions.ahk b/Task/Regular-expressions/AutoHotkey/regular-expressions.ahk new file mode 100644 index 0000000000..30ae89d69a --- /dev/null +++ b/Task/Regular-expressions/AutoHotkey/regular-expressions.ahk @@ -0,0 +1,2 @@ +MsgBox % foundpos := RegExMatch("Hello World", "World$") +MsgBox % replaced := RegExReplace("Hello World", "World$", "yourself") diff --git a/Task/Regular-expressions/BBC-BASIC/regular-expressions.bbc b/Task/Regular-expressions/BBC-BASIC/regular-expressions.bbc new file mode 100644 index 0000000000..e46cba5c34 --- /dev/null +++ b/Task/Regular-expressions/BBC-BASIC/regular-expressions.bbc @@ -0,0 +1,40 @@ + SYS "LoadLibrary", "gnu_regex.dll" TO gnu_regex% + IF gnu_regex% = 0 ERROR 100, "Cannot load gnu_regex.dll" + SYS "GetProcAddress", gnu_regex%, "regcomp" TO regcomp + SYS "GetProcAddress", gnu_regex%, "regexec" TO regexec + + DIM regmatch{start%, finish%}, buffer% 256 + + REM Find all 'words' in a string: + teststr$ = "I love PATTERN matching!" + pattern$ = "([a-zA-Z]+)" + + SYS regcomp, buffer%, pattern$, 1 TO result% + IF result% ERROR 101, "Failed to compile regular expression" + + first% = 1 + REPEAT + SYS regexec, buffer%, MID$(teststr$, first%), 1, regmatch{}, 0 TO result% + IF result% = 0 THEN + s% = regmatch.start% + f% = regmatch.finish% + PRINT "<" MID$(teststr$, first%+s%, f%-s%) ">" + first% += f% + ENDIF + UNTIL result% + + REM Replace 'PATTERN' with 'pattern': + teststr$ = "I love PATTERN matching!" + pattern$ = "(PATTERN)" + + SYS regcomp, buffer%, pattern$, 1 TO result% + IF result% ERROR 101, "Failed to compile regular expression" + SYS regexec, buffer%, teststr$, 1, regmatch{}, 0 TO result% + IF result% = 0 THEN + s% = regmatch.start% + f% = regmatch.finish% + MID$(teststr$, s%+1, f%-s%) = "pattern" + PRINT teststr$ + ENDIF + + SYS "FreeLibrary", gnu_regex% diff --git a/Task/Regular-expressions/Bracmat/regular-expressions.bracmat b/Task/Regular-expressions/Bracmat/regular-expressions.bracmat new file mode 100644 index 0000000000..fe323ac968 --- /dev/null +++ b/Task/Regular-expressions/Bracmat/regular-expressions.bracmat @@ -0,0 +1 @@ +@("fesylk789/35768poq2art":? (#<7:?n & out$!n & ~) ?) diff --git a/Task/Regular-expressions/C++/regular-expressions.cpp b/Task/Regular-expressions/C++/regular-expressions.cpp new file mode 100644 index 0000000000..c001e2fa3f --- /dev/null +++ b/Task/Regular-expressions/C++/regular-expressions.cpp @@ -0,0 +1,39 @@ +#include +#include +#include +#include + +int main() +{ + boost::regex re(".* string$"); + std::string s = "Hi, I am a string"; + + // match the complete string + if (boost::regex_match(s, re)) + std::cout << "The string matches.\n"; + else + std::cout << "Oops - not found?\n"; + + // match a substring + boost::regex re2(" a.*a"); + boost::smatch match; + if (boost::regex_search(s, match, re2)) + { + std::cout << "Matched " << match.length() + << " characters starting at " << match.position() << ".\n"; + std::cout << "Matched character sequence: \"" + << match.str() << "\"\n"; + } + else + { + std::cout << "Oops - not found?\n"; + } + + // replace a substring + std::string dest_string; + boost::regex_replace(std::back_inserter(dest_string), + s.begin(), s.end(), + re2, + "'m now a changed"); + std::cout << dest_string << std::endl; +} diff --git a/Task/Regular-expressions/C-sharp/regular-expressions.cs b/Task/Regular-expressions/C-sharp/regular-expressions.cs new file mode 100644 index 0000000000..b41bdcaceb --- /dev/null +++ b/Task/Regular-expressions/C-sharp/regular-expressions.cs @@ -0,0 +1,15 @@ +using System; +using System.Text.RegularExpressions; + +class Program { + static void Main(string[] args) { + string str = "I am a string"; + + if (new Regex("string$").IsMatch(str)) { + Console.WriteLine("Ends with string."); + } + + str = new Regex(" a ").Replace(str, " another "); + Console.WriteLine(str); + } +} diff --git a/Task/Regular-expressions/C/regular-expressions.c b/Task/Regular-expressions/C/regular-expressions.c new file mode 100644 index 0000000000..87531137be --- /dev/null +++ b/Task/Regular-expressions/C/regular-expressions.c @@ -0,0 +1,43 @@ +#include +#include +#include +#include +#include + +int main() +{ + regex_t preg; + regmatch_t substmatch[1]; + const char *tp = "string$"; + const char *t1 = "this is a matching string"; + const char *t2 = "this is not a matching string!"; + const char *ss = "istyfied"; + + regcomp(&preg, "string$", REG_EXTENDED); + printf("'%s' %smatched with '%s'\n", t1, + (regexec(&preg, t1, 0, NULL, 0)==0) ? "" : "did not ", tp); + printf("'%s' %smatched with '%s'\n", t2, + (regexec(&preg, t2, 0, NULL, 0)==0) ? "" : "did not ", tp); + regfree(&preg); + /* change "a[a-z]+" into "istifyed"?*/ + regcomp(&preg, "a[a-z]+", REG_EXTENDED); + if ( regexec(&preg, t1, 1, substmatch, 0) == 0 ) + { + //fprintf(stderr, "%d, %d\n", substmatch[0].rm_so, substmatch[0].rm_eo); + char *ns = malloc(substmatch[0].rm_so + 1 + strlen(ss) + + (strlen(t1) - substmatch[0].rm_eo) + 2); + memcpy(ns, t1, substmatch[0].rm_so+1); + memcpy(&ns[substmatch[0].rm_so], ss, strlen(ss)); + memcpy(&ns[substmatch[0].rm_so+strlen(ss)], &t1[substmatch[0].rm_eo], + strlen(&t1[substmatch[0].rm_eo])); + ns[ substmatch[0].rm_so + strlen(ss) + + strlen(&t1[substmatch[0].rm_eo]) ] = 0; + printf("mod string: '%s'\n", ns); + free(ns); + } else { + printf("the string '%s' is the same: no matching!\n", t1); + } + regfree(&preg); + + return 0; +} diff --git a/Task/Regular-expressions/Clojure/regular-expressions.clj b/Task/Regular-expressions/Clojure/regular-expressions.clj new file mode 100644 index 0000000000..876dc24c47 --- /dev/null +++ b/Task/Regular-expressions/Clojure/regular-expressions.clj @@ -0,0 +1,10 @@ +(let [s "I am a string"] + ;; match + (when (re-find #"string$" s) + (println "Ends with 'string'.")) + (when-not (re-find #"^You" s) + (println "Does not start with 'You'.")) + + ;; substitute + (println (clojure.string/replace s " a " " another ")) +) diff --git a/Task/Regular-expressions/Common-Lisp/regular-expressions-1.lisp b/Task/Regular-expressions/Common-Lisp/regular-expressions-1.lisp new file mode 100644 index 0000000000..fa8eb430b3 --- /dev/null +++ b/Task/Regular-expressions/Common-Lisp/regular-expressions-1.lisp @@ -0,0 +1,5 @@ +(let ((string "I am a string")) + (when (cl-ppcre:scan "string$" string) + (write-line "Ends with string")) + (unless (cl-ppcre:scan "^You" string ) + (write-line "Does not start with 'You'"))) diff --git a/Task/Regular-expressions/Common-Lisp/regular-expressions-2.lisp b/Task/Regular-expressions/Common-Lisp/regular-expressions-2.lisp new file mode 100644 index 0000000000..631aa6a394 --- /dev/null +++ b/Task/Regular-expressions/Common-Lisp/regular-expressions-2.lisp @@ -0,0 +1,3 @@ +(let* ((string "I am a string") + (string (cl-ppcre:regex-replace " a " string " another "))) + (write-line string)) diff --git a/Task/Regular-expressions/Common-Lisp/regular-expressions-3.lisp b/Task/Regular-expressions/Common-Lisp/regular-expressions-3.lisp new file mode 100644 index 0000000000..4c97eae9c7 --- /dev/null +++ b/Task/Regular-expressions/Common-Lisp/regular-expressions-3.lisp @@ -0,0 +1,5 @@ +(let ((string "I am a string")) + (multiple-value-bind (string matchp) + (cl-ppcre:regex-replace "\\bam\\b" string "was") + (when matchp + (write-line "I was able to find and replace 'am' with 'was'.")))) diff --git a/Task/Regular-expressions/Common-Lisp/regular-expressions-4.lisp b/Task/Regular-expressions/Common-Lisp/regular-expressions-4.lisp new file mode 100644 index 0000000000..c5e3af0fb7 --- /dev/null +++ b/Task/Regular-expressions/Common-Lisp/regular-expressions-4.lisp @@ -0,0 +1,2 @@ +[1]> (regexp:match "fox" "quick fox jumps") +#S(REGEXP:MATCH :START 6 :END 9) diff --git a/Task/Regular-expressions/Common-Lisp/regular-expressions-5.lisp b/Task/Regular-expressions/Common-Lisp/regular-expressions-5.lisp new file mode 100644 index 0000000000..8c78675b2e --- /dev/null +++ b/Task/Regular-expressions/Common-Lisp/regular-expressions-5.lisp @@ -0,0 +1,6 @@ +[2]> (defun regexp-replace (pat repl string) + (reduce #'(lambda (x y) (string-concat x repl y)) + (regexp:regexp-split pat string))) +REGEXP-REPLACE +[3]> (regexp-replace "x\\b" "-X-" "quick foxx jumps") +"quick fox-X- jumps" diff --git a/Task/Regular-expressions/D/regular-expressions.d b/Task/Regular-expressions/D/regular-expressions.d new file mode 100644 index 0000000000..0b46eba025 --- /dev/null +++ b/Task/Regular-expressions/D/regular-expressions.d @@ -0,0 +1,12 @@ +import std.stdio, std.regex; + +void main() { + immutable string s = "I am a string"; + + // Test: + if (!match(s, r"string$").empty) + writeln("Ends with 'string'."); + + // Substitute: + replace(s, regex(" a "), " another ").writeln(); +} diff --git a/Task/Regular-expressions/Erlang/regular-expressions.erl b/Task/Regular-expressions/Erlang/regular-expressions.erl new file mode 100644 index 0000000000..78e7b18ac1 --- /dev/null +++ b/Task/Regular-expressions/Erlang/regular-expressions.erl @@ -0,0 +1,11 @@ +match() -> + String = "This is a string", + case re:run(String, "string$") of + {match,_} -> io:format("Ends with 'string'~n"); + _ -> ok + end. + +substitute() -> + String = "This is a string", + NewString = re:replace(String, " a ", " another ", [{return, list}]), + io:format("~s~n",[NewString]). diff --git a/Task/Regular-expressions/Forth/regular-expressions.fth b/Task/Regular-expressions/Forth/regular-expressions.fth new file mode 100644 index 0000000000..e3b1385899 --- /dev/null +++ b/Task/Regular-expressions/Forth/regular-expressions.fth @@ -0,0 +1,19 @@ +include ffl/rgx.fs + +\ Create a regular expression variable 'exp' in the dictionary + +rgx-create exp + +\ Compile an expression + +s" Hello (World)" exp rgx-compile [IF] + .( Regular expression successful compiled.) cr +[THEN] + +\ (Case sensitive) match a string with the expression + +s" Hello World" exp rgx-cmatch? [IF] + .( String matches with the expression.) cr +[ELSE] + .( No match.) cr +[THEN] diff --git a/Task/Regular-expressions/Frink/regular-expressions-1.frink b/Task/Regular-expressions/Frink/regular-expressions-1.frink new file mode 100644 index 0000000000..aa3aa15391 --- /dev/null +++ b/Task/Regular-expressions/Frink/regular-expressions-1.frink @@ -0,0 +1,7 @@ +line = "My name is Inigo Montoya." + +for [first, last] = line =~ %r/my name is (\w+) (\w+)/ig +{ + println["First name is: $first"] + println["Last name is: $last"] +} diff --git a/Task/Regular-expressions/Frink/regular-expressions-2.frink b/Task/Regular-expressions/Frink/regular-expressions-2.frink new file mode 100644 index 0000000000..85efa9beb1 --- /dev/null +++ b/Task/Regular-expressions/Frink/regular-expressions-2.frink @@ -0,0 +1 @@ +line =~ %s/Frank/Frink/g diff --git a/Task/Regular-expressions/Go/regular-expressions.go b/Task/Regular-expressions/Go/regular-expressions.go new file mode 100644 index 0000000000..0ecef84b8b --- /dev/null +++ b/Task/Regular-expressions/Go/regular-expressions.go @@ -0,0 +1,16 @@ +package main +import "fmt" +import "regexp" + +func main() { + str := "I am the original string" + + // Test + matched, _ := regexp.MatchString(".*string$", str) + if matched { fmt.Println("ends with 'string'") } + + // Substitute + pattern := regexp.MustCompile("original") + result := pattern.ReplaceAllString(str, "modified") + fmt.Println(result) +} diff --git a/Task/Regular-expressions/Groovy/regular-expressions-1.groovy b/Task/Regular-expressions/Groovy/regular-expressions-1.groovy new file mode 100644 index 0000000000..65fb1f03ac --- /dev/null +++ b/Task/Regular-expressions/Groovy/regular-expressions-1.groovy @@ -0,0 +1,54 @@ +import java.util.regex.*; + +def woodchuck = "How much wood would a woodchuck chuck if a woodchuck could chuck wood?" +def pepper = "Peter Piper picked a peck of pickled peppers" + + +println "=== Regular-expression String syntax (/string/) ===" +def woodRE = /[Ww]o\w+d/ +def piperRE = /[Pp]\w+r/ +assert woodRE instanceof String && piperRE instanceof String +assert (/[Ww]o\w+d/ == "[Ww]o\\w+d") && (/[Pp]\w+r/ == "[Pp]\\w+r") +println ([woodRE: woodRE, piperRE: piperRE]) +println () + + +println "=== Pattern (~) operator ===" +def woodPat = ~/[Ww]o\w+d/ +def piperPat = ~piperRE +assert woodPat instanceof Pattern && piperPat instanceof Pattern + +def woodList = woodchuck.split().grep(woodPat) +println ([exactTokenMatches: woodList]) +println ([exactTokenMatches: pepper.split().grep(piperPat)]) +println () + + +println "=== Matcher (=~) operator ===" +def wwMatcher = (woodchuck =~ woodRE) +def ppMatcher = (pepper =~ /[Pp]\w+r/) +def wpMatcher = (woodchuck =~ /[Pp]\w+r/) +assert wwMatcher instanceof Matcher && ppMatcher instanceof Matcher +assert wwMatcher.toString() == woodPat.matcher(woodchuck).toString() +assert ppMatcher.toString() == piperPat.matcher(pepper).toString() +assert wpMatcher.toString() == piperPat.matcher(woodchuck).toString() + +println ([ substringMatches: wwMatcher.collect { it }]) +println ([ substringMatches: ppMatcher.collect { it }]) +println ([ substringMatches: wpMatcher.collect { it }]) +println () + + +println "=== Exact Match (==~) operator ===" +def containsWoodRE = /.*/ + woodRE + /.*/ +def containsPiperRE = /.*/ + piperRE + /.*/ +def wwMatches = (woodchuck ==~ containsWoodRE) +assert wwMatches instanceof Boolean +def wwNotMatches = ! (woodchuck ==~ woodRE) +def ppMatches = (pepper ==~ containsPiperRE) +def pwNotMatches = ! (pepper ==~ containsWoodRE) +def wpNotMatches = ! (woodchuck ==~ containsPiperRE) +assert wwMatches && wwNotMatches && ppMatches && pwNotMatches && pwNotMatches + +println ("'${woodchuck}' ${wwNotMatches ? 'does not' : 'does'} match '${woodRE}' exactly") +println ("'${woodchuck}' ${wwMatches ? 'does' : 'does not'} match '${containsWoodRE}' exactly") diff --git a/Task/Regular-expressions/Groovy/regular-expressions-2.groovy b/Task/Regular-expressions/Groovy/regular-expressions-2.groovy new file mode 100644 index 0000000000..a72bdbcdad --- /dev/null +++ b/Task/Regular-expressions/Groovy/regular-expressions-2.groovy @@ -0,0 +1 @@ +println woodchuck.replaceAll(/c\w+k/, "CHUCK") diff --git a/Task/Regular-expressions/Groovy/regular-expressions-3.groovy b/Task/Regular-expressions/Groovy/regular-expressions-3.groovy new file mode 100644 index 0000000000..e132f0a78a --- /dev/null +++ b/Task/Regular-expressions/Groovy/regular-expressions-3.groovy @@ -0,0 +1,11 @@ +def ck = (woodchuck =~ /c\w+k/) +println (ck.replaceAll("CHUCK")) +println (ck.replaceAll("wind")) +println (ck.replaceAll("pile")) +println (ck.replaceAll("craft")) +println (ck.replaceAll("block")) +println (ck.replaceAll("row")) +println (ck.replaceAll("shed")) +println (ck.replaceAll("man")) +println (ck.replaceAll("work")) +println (ck.replaceAll("pickle")) diff --git a/Task/Regular-expressions/Haskell/regular-expressions-1.hs b/Task/Regular-expressions/Haskell/regular-expressions-1.hs new file mode 100644 index 0000000000..f8d1fc5bc4 --- /dev/null +++ b/Task/Regular-expressions/Haskell/regular-expressions-1.hs @@ -0,0 +1,7 @@ +import Text.Regex + +str = "I am a string" + +case matchRegex (mkRegex ".*string$") str of + Just _ -> putStrLn $ "ends with 'string'" + Nothing -> return () diff --git a/Task/Regular-expressions/Haskell/regular-expressions-2.hs b/Task/Regular-expressions/Haskell/regular-expressions-2.hs new file mode 100644 index 0000000000..9b21ddc54d --- /dev/null +++ b/Task/Regular-expressions/Haskell/regular-expressions-2.hs @@ -0,0 +1,5 @@ +import Text.Regex + +orig = "I am the original string" +result = subRegex (mkRegex "original") orig "modified" +putStrLn $ result diff --git a/Task/Regular-expressions/HicEst/regular-expressions.hicest b/Task/Regular-expressions/HicEst/regular-expressions.hicest new file mode 100644 index 0000000000..58670f6604 --- /dev/null +++ b/Task/Regular-expressions/HicEst/regular-expressions.hicest @@ -0,0 +1,7 @@ +CHARACTER string*100/ "The quick brown fox jumps over the lazy dog" / +REAL, PARAMETER :: Regex=128, Count=256 + +characters_a_m = INDEX(string, "[a-m]", Regex+Count) ! counts 16 + +vocals_changed = EDIT(Text=string, Option=Regex, Right="[aeiou]", RePLaceby='**', DO=LEN(string) ) ! changes 11 +WRITE(ClipBoard) string ! Th** q****ck br**wn f**x j**mps **v**r th** l**zy d**g diff --git a/Task/Regular-expressions/Icon/regular-expressions.icon b/Task/Regular-expressions/Icon/regular-expressions.icon new file mode 100644 index 0000000000..65205e422b --- /dev/null +++ b/Task/Regular-expressions/Icon/regular-expressions.icon @@ -0,0 +1,12 @@ +procedure main() + +s := "A simple string" +p := "string$" # regular expression + +s ? write(image(s),if ReFind(p) then " matches " else " doesn't match ",image(p)) + +s[j := ReFind(p,s):ReMatch(p,s,j)] := "replacement" +write(image(s)) +end + +link regexp # link to IPL regexp diff --git a/Task/Regular-expressions/Inform-7/regular-expressions.inf b/Task/Regular-expressions/Inform-7/regular-expressions.inf new file mode 100644 index 0000000000..752b3591f4 --- /dev/null +++ b/Task/Regular-expressions/Inform-7/regular-expressions.inf @@ -0,0 +1,4 @@ +let T be indexed text; +let T be "A simple string"; +if T matches the regular expression ".*string$", say "ends with string."; +replace the regular expression "simple" in T with "replacement"; diff --git a/Task/Regular-expressions/J/regular-expressions-1.j b/Task/Regular-expressions/J/regular-expressions-1.j new file mode 100644 index 0000000000..dab19e7d5a --- /dev/null +++ b/Task/Regular-expressions/J/regular-expressions-1.j @@ -0,0 +1,2 @@ +load'regex' NB. Load regex library +str =: 'I am a string' NB. String used in examples. diff --git a/Task/Regular-expressions/J/regular-expressions-2.j b/Task/Regular-expressions/J/regular-expressions-2.j new file mode 100644 index 0000000000..21f519c4b1 --- /dev/null +++ b/Task/Regular-expressions/J/regular-expressions-2.j @@ -0,0 +1,2 @@ + '.*string$' rxeq str NB. 1 is true, 0 is false +1 diff --git a/Task/Regular-expressions/J/regular-expressions-3.j b/Task/Regular-expressions/J/regular-expressions-3.j new file mode 100644 index 0000000000..86d55d8301 --- /dev/null +++ b/Task/Regular-expressions/J/regular-expressions-3.j @@ -0,0 +1,2 @@ + ('am';'am still') rxrplc str +I am still a string diff --git a/Task/Regular-expressions/J/regular-expressions-4.j b/Task/Regular-expressions/J/regular-expressions-4.j new file mode 100644 index 0000000000..ea788868be --- /dev/null +++ b/Task/Regular-expressions/J/regular-expressions-4.j @@ -0,0 +1 @@ + open'regex' diff --git a/Task/Regular-expressions/Java/regular-expressions-1.java b/Task/Regular-expressions/Java/regular-expressions-1.java new file mode 100644 index 0000000000..c670360ebb --- /dev/null +++ b/Task/Regular-expressions/Java/regular-expressions-1.java @@ -0,0 +1,4 @@ +String str = "I am a string"; +if (str.matches(".*string")) { // note: matches() tests if the entire string is a match + System.out.println("ends with 'string'"); +} diff --git a/Task/Regular-expressions/Java/regular-expressions-2.java b/Task/Regular-expressions/Java/regular-expressions-2.java new file mode 100644 index 0000000000..9baaa09f32 --- /dev/null +++ b/Task/Regular-expressions/Java/regular-expressions-2.java @@ -0,0 +1,6 @@ +import java.util.regex.*; +Pattern p = Pattern.compile("a*b"); +Matcher m = p.matcher(str); +while (m.find()) { + // use m.group() to extract matches +} diff --git a/Task/Regular-expressions/Java/regular-expressions-3.java b/Task/Regular-expressions/Java/regular-expressions-3.java new file mode 100644 index 0000000000..3035648594 --- /dev/null +++ b/Task/Regular-expressions/Java/regular-expressions-3.java @@ -0,0 +1,3 @@ +String orig = "I am the original string"; +String result = orig.replaceAll("original", "modified"); +// result is now "I am the modified string" diff --git a/Task/Regular-expressions/JavaScript/regular-expressions-1.js b/Task/Regular-expressions/JavaScript/regular-expressions-1.js new file mode 100644 index 0000000000..d978f6dc2d --- /dev/null +++ b/Task/Regular-expressions/JavaScript/regular-expressions-1.js @@ -0,0 +1,15 @@ +var subject = "Hello world!"; + +// Two different ways to create the RegExp object +// Both examples use the exact same pattern... matching "hello" +var re_PatternToMatch = /Hello (World)/i; // creates a RegExp literal with case-insensitivity +var re_PatternToMatch2 = new RegExp("Hello (World)", "i"); + +// Test for a match - return a bool +var isMatch = re_PatternToMatch.test(subject); + +// Get the match details +// Returns an array with the match's details +// matches[0] == "Hello world" +// matches[1] == "world" +var matches = re_PatternToMatch2.exec(subject); diff --git a/Task/Regular-expressions/JavaScript/regular-expressions-2.js b/Task/Regular-expressions/JavaScript/regular-expressions-2.js new file mode 100644 index 0000000000..e280a53248 --- /dev/null +++ b/Task/Regular-expressions/JavaScript/regular-expressions-2.js @@ -0,0 +1,5 @@ +var subject = "Hello world!"; + +// Perform a string replacement +// newSubject == "Replaced!" +var newSubject = subject.replace(re_PatternToMatch, "Replaced"); diff --git a/Task/Regular-expressions/Julia/regular-expressions-1.julia b/Task/Regular-expressions/Julia/regular-expressions-1.julia new file mode 100644 index 0000000000..fec476817e --- /dev/null +++ b/Task/Regular-expressions/Julia/regular-expressions-1.julia @@ -0,0 +1,5 @@ +julia> ismatch(r"^\s*(?:#|$)", "not a comment") +false + +julia> ismatch(r"^\s*(?:#|$)", "# a comment") +true diff --git a/Task/Regular-expressions/Julia/regular-expressions-2.julia b/Task/Regular-expressions/Julia/regular-expressions-2.julia new file mode 100644 index 0000000000..5694f93d56 --- /dev/null +++ b/Task/Regular-expressions/Julia/regular-expressions-2.julia @@ -0,0 +1,41 @@ +julia> m = match(r"(a|b)(c)?(d)", "acd") +RegexMatch("acd", 1="a", 2="c", 3="d") + +julia> m.match +"acd" + +julia> m.captures +3-element Union(UTF8String,ASCIIString,Nothing) Array: + "a" + "c" + "d" + +julia> m.offset +1 + +julia> m.offsets +3-element Int64 Array: + 1 + 2 + 3 + +julia> m = match(r"(a|b)(c)?(d)", "ad") +RegexMatch("ad", 1="a", 2=nothing, 3="d") + +julia> m.match +"ad" + +julia> m.captures +3-element Union(UTF8String,ASCIIString,Nothing) Array: + "a" + nothing + "d" + +julia> m.offset +1 + +julia> m.offsets +3-element Int64 Array: + 1 + 0 + 2 diff --git a/Task/Regular-expressions/Lua/regular-expressions.lua b/Task/Regular-expressions/Lua/regular-expressions.lua new file mode 100644 index 0000000000..40f354d3b2 --- /dev/null +++ b/Task/Regular-expressions/Lua/regular-expressions.lua @@ -0,0 +1,5 @@ +str1 = "This is a string!" +str2 = "string" + +print( str1:match( str2 ) ) +erg = str1:gsub( "a", "another" ); print( erg ) diff --git a/Task/Regular-expressions/M4/regular-expressions.m4 b/Task/Regular-expressions/M4/regular-expressions.m4 new file mode 100644 index 0000000000..e3da0baa99 --- /dev/null +++ b/Task/Regular-expressions/M4/regular-expressions.m4 @@ -0,0 +1,2 @@ +regexp(`GNUs not Unix', `\<[a-z]\w+') +regexp(`GNUs not Unix', `\<[a-z]\(\w+\)', `a \& b \1 c') diff --git a/Task/Regular-expressions/MIRC-Scripting-Language/regular-expressions.mirc b/Task/Regular-expressions/MIRC-Scripting-Language/regular-expressions.mirc new file mode 100644 index 0000000000..49b61abd1d --- /dev/null +++ b/Task/Regular-expressions/MIRC-Scripting-Language/regular-expressions.mirc @@ -0,0 +1,13 @@ +alias regular_expressions { + var %string = This is a string + var %re = string$ + if ($regex(%string,%re) > 0) { + echo -a Ends with string. + } + %re = \ba\b + if ($regsub(%string,%re,another,%string) > 0) { + echo -a Result 1: %string + } + %re = \b(another)\b + echo -a Result 2: $regsubex(%string,%re,yet \1) +} diff --git a/Task/Regular-expressions/MUMPS/regular-expressions.mumps b/Task/Regular-expressions/MUMPS/regular-expressions.mumps new file mode 100644 index 0000000000..511c14b560 --- /dev/null +++ b/Task/Regular-expressions/MUMPS/regular-expressions.mumps @@ -0,0 +1,13 @@ +REGEXP + NEW HI,W,PATTERN,BOOLEAN + SET HI="Hello, world!",W="world" + SET PATTERN=".E1"""_W_""".E" + SET BOOLEAN=HI?@PATTERN + WRITE "Source string - '"_HI_"'",! + WRITE "Partial string - '"_W_"'",! + WRITE "Pattern string created is - '"_PATTERN_"'",! + WRITE "Match? ",$SELECT(BOOLEAN:"YES",'BOOLEAN:"No"),! + ; + SET BOOLEAN=$FIND(HI,W) + IF BOOLEAN>0 WRITE $PIECE(HI,W,1)_"string"_$PIECE(HI,W,2) + QUIT diff --git a/Task/Regular-expressions/Mathematica/regular-expressions.math b/Task/Regular-expressions/Mathematica/regular-expressions.math new file mode 100644 index 0000000000..613eb5b48d --- /dev/null +++ b/Task/Regular-expressions/Mathematica/regular-expressions.math @@ -0,0 +1,2 @@ +StringCases["I am a string with the number 18374 in me",RegularExpression["[0-9]+"]] +StringReplace["I am a string",RegularExpression["I\\sam"] -> "I'm"] diff --git a/Task/Regular-expressions/NetRexx/regular-expressions.netrexx b/Task/Regular-expressions/NetRexx/regular-expressions.netrexx new file mode 100644 index 0000000000..a405b3ea75 --- /dev/null +++ b/Task/Regular-expressions/NetRexx/regular-expressions.netrexx @@ -0,0 +1,37 @@ +/* NetRexx */ +options replace format comments java crossref symbols nobinary + +import java.util.regex. + +st1 = 'Fee, fie, foe, fum, I smell the blood of an Englishman' +rx1 = 'f.e.*?' +sbx = 'foo' + +rx1ef = '(?i)'rx1 -- use embedded flag expression == Pattern.CASE_INSENSITIVE + +-- using String's matches & replaceAll +mcm = (String st1).matches(rx1ef) +say 'String "'st1'"' 'matches pattern "'rx1ef'":' Boolean(mcm) +say +say 'Replace all occurrences of regex pattern "'rx1ef'" with "'sbx'"' +stx = Rexx +stx = (String st1).replaceAll(rx1ef, sbx) +say 'Input string: "'st1'"' +say 'Result string: "'stx'"' +say + +-- using java.util.regex classes +pt1 = Pattern.compile(rx1, Pattern.CASE_INSENSITIVE) +mc1 = pt1.matcher(st1) +mcm = mc1.matches() +say 'String "'st1'"' 'matches pattern "'pt1.toString()'":' Boolean(mcm) +mc1 = pt1.matcher(st1) +say +say 'Replace all occurrences of regex pattern "'rx1'" with "'sbx'"' +sx1 = Rexx +sx1 = mc1.replaceAll(sbx) +say 'Input string: "'st1'"' +say 'Result string: "'sx1'"' +say + +return diff --git a/Task/Regular-expressions/OCaml/regular-expressions-1.ocaml b/Task/Regular-expressions/OCaml/regular-expressions-1.ocaml new file mode 100644 index 0000000000..af13244c1a --- /dev/null +++ b/Task/Regular-expressions/OCaml/regular-expressions-1.ocaml @@ -0,0 +1,7 @@ +#load "str.cma";; +let str = "I am a string";; +try + ignore(Str.search_forward (Str.regexp ".*string$") str 0); + print_endline "ends with 'string'" +with Not_found -> () +;; diff --git a/Task/Regular-expressions/OCaml/regular-expressions-2.ocaml b/Task/Regular-expressions/OCaml/regular-expressions-2.ocaml new file mode 100644 index 0000000000..332e156d9c --- /dev/null +++ b/Task/Regular-expressions/OCaml/regular-expressions-2.ocaml @@ -0,0 +1,4 @@ +#load "str.cma";; +let orig = "I am the original string";; +let result = Str.global_replace (Str.regexp "original") "modified" orig;; +(* result is now "I am the modified string" *) diff --git a/Task/Regular-expressions/OCaml/regular-expressions-3.ocaml b/Task/Regular-expressions/OCaml/regular-expressions-3.ocaml new file mode 100644 index 0000000000..2039c6741e --- /dev/null +++ b/Task/Regular-expressions/OCaml/regular-expressions-3.ocaml @@ -0,0 +1,10 @@ +let matched pat str = + try ignore(Pcre.exec ~pat str); (true) + with Not_found -> (false) +;; + +let () = + Printf.printf "matched = %b\n" (matched "string$" "I am a string"); + Printf.printf "Substitute: %s\n" + (Pcre.replace ~pat:"original" ~templ:"modified" "I am the original string") +;; diff --git a/Task/Regular-expressions/Objeck/regular-expressions.objeck b/Task/Regular-expressions/Objeck/regular-expressions.objeck new file mode 100644 index 0000000000..afbbafd152 --- /dev/null +++ b/Task/Regular-expressions/Objeck/regular-expressions.objeck @@ -0,0 +1,17 @@ +use RegEx; + +bundle Default { + class RegExTest { + function : Main(args : String[]) ~ Nil { + string := "I am a string"; + # exact match + regex := RegEx->New(".*string"); + if(regex->MatchExact(".*string")) { + "ends with 'string'"->PrintLine(); + }; + # replace all + regex := RegEx->New(" a "); + regex->ReplaceAll(string, " another ")->PrintLine(); + } + } +} diff --git a/Task/Regular-expressions/Objective-C/regular-expressions-1.m b/Task/Regular-expressions/Objective-C/regular-expressions-1.m new file mode 100644 index 0000000000..22c64ffec5 --- /dev/null +++ b/Task/Regular-expressions/Objective-C/regular-expressions-1.m @@ -0,0 +1,9 @@ +NSString *str = @"I am a string"; +NSString *regex = @".*string$"; + +// Note: the MATCHES operator matches the entire string, necessitating the ".*" +NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex]; + +if ([pred evaluateWithObject:str]) { + NSLog(@"ends with 'string'"); +} diff --git a/Task/Regular-expressions/Objective-C/regular-expressions-2.m b/Task/Regular-expressions/Objective-C/regular-expressions-2.m new file mode 100644 index 0000000000..7e0d79622b --- /dev/null +++ b/Task/Regular-expressions/Objective-C/regular-expressions-2.m @@ -0,0 +1,4 @@ +NSString *str = @"I am a string"; +if ([str rangeOfString:@"string$" options:NSRegularExpressionSearch].location != NSNotFound) { + NSLog(@"Ends with 'string'"); +} diff --git a/Task/Regular-expressions/Objective-C/regular-expressions-3.m b/Task/Regular-expressions/Objective-C/regular-expressions-3.m new file mode 100644 index 0000000000..4a028af112 --- /dev/null +++ b/Task/Regular-expressions/Objective-C/regular-expressions-3.m @@ -0,0 +1,6 @@ +NSString *orig = @"I am the original string"; +NSString *result = [orig stringByReplacingOccurrencesOfString:@"original" + withString:@"modified" + options:NSRegularExpressionSearch + range:NSMakeRange(0, [orig length])]; +NSLog(@"%@", result); diff --git a/Task/Regular-expressions/Objective-C/regular-expressions-4.m b/Task/Regular-expressions/Objective-C/regular-expressions-4.m new file mode 100644 index 0000000000..482b87b56c --- /dev/null +++ b/Task/Regular-expressions/Objective-C/regular-expressions-4.m @@ -0,0 +1,10 @@ +NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"string$" + options:0 + error:NULL]; +NSString *str = @"I am a string"; +if ([regex rangeOfFirstMatchInString:str + options:0 + range:NSMakeRange(0, [str length]) + ].location != NSNotFound) { + NSLog(@"Ends with 'string'"); +} diff --git a/Task/Regular-expressions/Objective-C/regular-expressions-5.m b/Task/Regular-expressions/Objective-C/regular-expressions-5.m new file mode 100644 index 0000000000..b67aacca77 --- /dev/null +++ b/Task/Regular-expressions/Objective-C/regular-expressions-5.m @@ -0,0 +1,7 @@ +for (NSTextCheckingResult *match in [regex matchesInString:str + options:0 + range:NSMakeRange(0, [str length]) + ]) { + // match.range gives the range of the whole match + // [match rangeAtIndex:i] gives the range of the i'th capture group (starting from 1) +} diff --git a/Task/Regular-expressions/Objective-C/regular-expressions-6.m b/Task/Regular-expressions/Objective-C/regular-expressions-6.m new file mode 100644 index 0000000000..792c65e900 --- /dev/null +++ b/Task/Regular-expressions/Objective-C/regular-expressions-6.m @@ -0,0 +1,9 @@ +NSString *orig = @"I am the original string"; +NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"original" + options:0 + error:NULL]; +NSString *result = [regex stringByReplacingMatchesInString:orig + options:0 + range:NSMakeRange(0, [orig length]) + withTemplate:@"modified"]; +NSLog(@"%@", result); diff --git a/Task/Regular-expressions/Oxygene/regular-expressions.oxy b/Task/Regular-expressions/Oxygene/regular-expressions.oxy new file mode 100644 index 0000000000..d8460bd04a --- /dev/null +++ b/Task/Regular-expressions/Oxygene/regular-expressions.oxy @@ -0,0 +1,30 @@ +// Match and Replace part of a string using a Regular Expression +// +// Nigel Galloway - April 15th., 2012 +// +namespace re; + +interface + +type + re = class + public + class method Main; + end; + +implementation + +class method re.Main; +const + myString = 'I think that I am Nigel'; +var + r: System.Text.RegularExpressions.Regex; + myResult : String; +begin + r := new System.Text.RegularExpressions.Regex('(I am)|(you are)'); + Console.WriteLine("{0} contains {1}", myString, r.Match(myString)); + myResult := r.Replace(myString, "you are"); + Console.WriteLine("{0} contains {1}", myResult, r.Match(myResult)); +end; + +end. diff --git a/Task/Regular-expressions/Oz/regular-expressions.oz b/Task/Regular-expressions/Oz/regular-expressions.oz new file mode 100644 index 0000000000..b6d27734e9 --- /dev/null +++ b/Task/Regular-expressions/Oz/regular-expressions.oz @@ -0,0 +1,8 @@ +declare + [Regex] = {Module.link ['x-oz://contrib/regex']} + String = "This is a string" +in + if {Regex.search "string$" String} \= false then + {System.showInfo "Ends with string."} + end + {System.showInfo {Regex.replace String " a " fun {$ _ _} " another " end}} diff --git a/Task/Regular-expressions/PHP/regular-expressions.php b/Task/Regular-expressions/PHP/regular-expressions.php new file mode 100644 index 0000000000..130101ea75 --- /dev/null +++ b/Task/Regular-expressions/PHP/regular-expressions.php @@ -0,0 +1,9 @@ +$string = 'I am a string'; +# Test +if (preg_match('/string$/', $string)) +{ + echo "Ends with 'string'\n"; +} +# Replace +$string = preg_replace('/\ba\b/', 'another', $string); +echo "Found 'a' and replace it with 'another', resulting in this string: $string\n"; diff --git a/Task/Regular-expressions/Pascal/regular-expressions.pascal b/Task/Regular-expressions/Pascal/regular-expressions.pascal new file mode 100644 index 0000000000..99444972b7 --- /dev/null +++ b/Task/Regular-expressions/Pascal/regular-expressions.pascal @@ -0,0 +1,25 @@ +// Match and Replace part of a string using a Regular Expression +// +// Nigel Galloway - April 11th., 2012 +// +program RegularExpr; + +uses + RegExpr; + +const + myString = 'I think that I am Nigel'; + myMatch = '(I am)|(you are)'; +var + r : TRegExpr; + myResult : String; + +begin + r := TRegExpr.Create; + r.Expression := myMatch; + write(myString); + if r.Exec(myString) then writeln(' contains ' + r.Match[0]); + myResult := r.Replace(myString, 'you are', False); + write(myResult); + if r.Exec(myResult) then writeln(' contains ' + r.Match[0]); +end. diff --git a/Task/Regular-expressions/Perl-6/regular-expressions.pl6 b/Task/Regular-expressions/Perl-6/regular-expressions.pl6 new file mode 100644 index 0000000000..a80092a894 --- /dev/null +++ b/Task/Regular-expressions/Perl-6/regular-expressions.pl6 @@ -0,0 +1,12 @@ +use v6; +if 'a long string' ~~ /string$/ { + say "It ends with 'string'"; +} + +# substitution has a few nifty features + +$_ = 'The quick Brown fox'; +s:g:samecase/\w+/xxx/; +.say; +# output: +# Xxx xxx Xxx xxx diff --git a/Task/Regular-expressions/Perl/regular-expressions-1.pl b/Task/Regular-expressions/Perl/regular-expressions-1.pl new file mode 100644 index 0000000000..9693e9f707 --- /dev/null +++ b/Task/Regular-expressions/Perl/regular-expressions-1.pl @@ -0,0 +1,8 @@ +$string = "I am a string"; +if ($string =~ /string$/) { + print "Ends with 'string'\n"; +} + +if ($string !~ /^You/) { + print "Does not start with 'You'\n"; +} diff --git a/Task/Regular-expressions/Perl/regular-expressions-2.pl b/Task/Regular-expressions/Perl/regular-expressions-2.pl new file mode 100644 index 0000000000..9cf7585372 --- /dev/null +++ b/Task/Regular-expressions/Perl/regular-expressions-2.pl @@ -0,0 +1,3 @@ +$string = "I am a string"; +$string =~ s/ a / another /; # makes "I am a string" into "I am another string" +print $string; diff --git a/Task/Regular-expressions/Perl/regular-expressions-3.pl b/Task/Regular-expressions/Perl/regular-expressions-3.pl new file mode 100644 index 0000000000..3c71a961b4 --- /dev/null +++ b/Task/Regular-expressions/Perl/regular-expressions-3.pl @@ -0,0 +1,3 @@ +$string = "I am a string"; +$string2 = $string =~ s/ a / another /r; # $string2 == "I am another string", $string is unaltered +print $string2; diff --git a/Task/Regular-expressions/Perl/regular-expressions-4.pl b/Task/Regular-expressions/Perl/regular-expressions-4.pl new file mode 100644 index 0000000000..43c2c5c61e --- /dev/null +++ b/Task/Regular-expressions/Perl/regular-expressions-4.pl @@ -0,0 +1,4 @@ +$string = "I am a string"; +if ($string =~ s/\bam\b/was/) { # \b is a word border + print "I was able to find and replace 'am' with 'was'\n"; +} diff --git a/Task/Regular-expressions/Perl/regular-expressions-5.pl b/Task/Regular-expressions/Perl/regular-expressions-5.pl new file mode 100644 index 0000000000..a91fd931d4 --- /dev/null +++ b/Task/Regular-expressions/Perl/regular-expressions-5.pl @@ -0,0 +1,7 @@ +# add the following just after the last / for additional control +# g = globally (match as many as possible) +# i = case-insensitive +# s = treat all of $string as a single line (in case you have line breaks in the content) +# m = multi-line (the expression is run on each line individually) + +$string =~ s/i/u/ig; # would change "I am a string" into "u am a strung" diff --git a/Task/Regular-expressions/Perl/regular-expressions-6.pl b/Task/Regular-expressions/Perl/regular-expressions-6.pl new file mode 100644 index 0000000000..1d1030ec2d --- /dev/null +++ b/Task/Regular-expressions/Perl/regular-expressions-6.pl @@ -0,0 +1,4 @@ +$_ = "I like banana milkshake."; +if (/banana/) { # The regular expression binding operator is omitted + print "Match found\n"; +} diff --git a/Task/Regular-expressions/PicoLisp/regular-expressions-1.l b/Task/Regular-expressions/PicoLisp/regular-expressions-1.l new file mode 100644 index 0000000000..072ce7a99d --- /dev/null +++ b/Task/Regular-expressions/PicoLisp/regular-expressions-1.l @@ -0,0 +1,5 @@ +(let (Pat "a[0-9]z" String "a7z") + (use Preg + (native "@" "regcomp" 'I '(Preg (64 B . 64)) Pat 1) # Compile regex + (when (=0 (native "@" "regexec" 'I (cons NIL (64) Preg) String 0 0 0)) + (prinl "String \"" String "\" matches regex \"" Pat "\"") ) ) ) diff --git a/Task/Regular-expressions/PicoLisp/regular-expressions-2.l b/Task/Regular-expressions/PicoLisp/regular-expressions-2.l new file mode 100644 index 0000000000..64baeda8da --- /dev/null +++ b/Task/Regular-expressions/PicoLisp/regular-expressions-2.l @@ -0,0 +1,6 @@ +(let String "The number <7> is incremented" + (use (@A @N @Z) + (and + (match '(@A "<" @N ">" @Z) (chop String)) + (format @N) + (prinl @A "<" (inc @) ">" @Z) ) ) ) diff --git a/Task/Regular-expressions/PowerShell/regular-expressions.psh b/Task/Regular-expressions/PowerShell/regular-expressions.psh new file mode 100644 index 0000000000..99f54aa2c6 --- /dev/null +++ b/Task/Regular-expressions/PowerShell/regular-expressions.psh @@ -0,0 +1,2 @@ +"I am a string" -match '\bstr' # true +"I am a string" -replace 'a\b','no' # I am no string diff --git a/Task/Regular-expressions/PureBasic/regular-expressions.purebasic b/Task/Regular-expressions/PureBasic/regular-expressions.purebasic new file mode 100644 index 0000000000..4ce7e1e606 --- /dev/null +++ b/Task/Regular-expressions/PureBasic/regular-expressions.purebasic @@ -0,0 +1,9 @@ +String$ = "some text consisting of Roman letters spaces and numbers like 12" +regex$ = "<([a-z]*)>[a-z,A-Z,0-9, ]*" +regex_replace$ = "letters[a-z,A-Z,0-9, ]*numbers[a-z,A-Z,0-9, ]*" +If CreateRegularExpression(1, regex$) And CreateRegularExpression(2, regex_replace$) + If MatchRegularExpression(1, String$) + Debug "Tags correct, and only alphanummeric or space characters between them" + EndIf + Debug ReplaceRegularExpression(2, String$, "char stuff") +EndIf diff --git a/Task/Regular-expressions/Python/regular-expressions.py b/Task/Regular-expressions/Python/regular-expressions.py new file mode 100644 index 0000000000..caef1e7e8b --- /dev/null +++ b/Task/Regular-expressions/Python/regular-expressions.py @@ -0,0 +1,9 @@ +import re + +string = "This is a string" + +if re.search('string$',string): + print "Ends with string." + +string = re.sub(" a "," another ",string) +print string diff --git a/Task/Regular-expressions/R/regular-expressions-1.r b/Task/Regular-expressions/R/regular-expressions-1.r new file mode 100644 index 0000000000..896ee75940 --- /dev/null +++ b/Task/Regular-expressions/R/regular-expressions-1.r @@ -0,0 +1,3 @@ +pattern <- "string" +text1 <- "this is a matching string" +text2 <- "this does not match" diff --git a/Task/Regular-expressions/R/regular-expressions-2.r b/Task/Regular-expressions/R/regular-expressions-2.r new file mode 100644 index 0000000000..9b6057d8a0 --- /dev/null +++ b/Task/Regular-expressions/R/regular-expressions-2.r @@ -0,0 +1 @@ +grep(pattern, c(text1, text2)) # 1 diff --git a/Task/Regular-expressions/R/regular-expressions-3.r b/Task/Regular-expressions/R/regular-expressions-3.r new file mode 100644 index 0000000000..aaa3f93aa5 --- /dev/null +++ b/Task/Regular-expressions/R/regular-expressions-3.r @@ -0,0 +1 @@ +regexpr(pattern, c(text1, text2)) diff --git a/Task/Regular-expressions/R/regular-expressions-4.r b/Task/Regular-expressions/R/regular-expressions-4.r new file mode 100644 index 0000000000..7df947fcbe --- /dev/null +++ b/Task/Regular-expressions/R/regular-expressions-4.r @@ -0,0 +1 @@ +gsub(pattern, "pair of socks", c(text1, text2)) diff --git a/Task/Regular-expressions/REBOL/regular-expressions.rebol b/Task/Regular-expressions/REBOL/regular-expressions.rebol new file mode 100644 index 0000000000..00cbde1272 --- /dev/null +++ b/Task/Regular-expressions/REBOL/regular-expressions.rebol @@ -0,0 +1,42 @@ +REBOL [ + Title: "Regular Expression Matching" + Author: oofoe + Date: 2009-12-06 + URL: http://rosettacode.org/wiki/Regular_expression_matching +] + +string: "This is a string." + +; REBOL doesn't use a conventional Perl-compatible regular expression +; syntax. Instead, it uses a variant Parsing Expression Grammar with +; the 'parse' function. It's also not limited to just strings. You can +; define complex grammars that actually parse and execute program +; files. + +; Here, I provide a rule to 'parse' that specifies searching through +; the string until "string." is found, then the end of the string. If +; the subject string satisfies the rule, the expression will be true. + +if parse string [thru "string." end] [ + print "Subject ends with 'string.'"] + +; For replacement, I take advantage of the ability to call arbitrary +; code when a pattern is matched -- everything in the parens will be +; executed when 'to " a "' is satisfied. This marks the current string +; location, then removes the offending word and inserts the replacement. + +parse string [ + to " a " ; Jump to target. + mark: ( + remove/part mark 3 ; Remove target. + mark: insert mark " another " ; Insert replacement. + ) + :mark ; Pick up where I left off. +] +print [crlf "Parse replacement:" string] + +; For what it's worth, the above operation is more conveniently done +; with the 'replace' function: + +replace string " another " " a " ; Change string back. +print [crlf "Replacement:" string] diff --git a/Task/Regular-expressions/REXX/regular-expressions-1.rexx b/Task/Regular-expressions/REXX/regular-expressions-1.rexx new file mode 100644 index 0000000000..977928f126 --- /dev/null +++ b/Task/Regular-expressions/REXX/regular-expressions-1.rexx @@ -0,0 +1,15 @@ +/*REXX program demonstrates testing (modeled after Perl example).*/ +$string = "I am a string" + say 'The string is:' $string + x = "string" +if right($string,length(x))=x then say 'It ends with:' x + + y = "You" +if left($string,length(y))\=y then say 'It does not start with:' y + + z = "ring" +if pos(z,$string)\==0 then say 'It contains the string:' z + + z = "ring" +if wordpos(z,$string)==0 then say 'It does not contain the word:' z + /*stick a fork in it, we're done.*/ diff --git a/Task/Regular-expressions/REXX/regular-expressions-2.rexx b/Task/Regular-expressions/REXX/regular-expressions-2.rexx new file mode 100644 index 0000000000..687d92034f --- /dev/null +++ b/Task/Regular-expressions/REXX/regular-expressions-2.rexx @@ -0,0 +1,10 @@ +/*REXX program demonstrates substitution (modeled after Perl example).*/ +$string = "I am a string" + old = " a " + new = " another " +say 'The original string is:' $string +say 'old word is:' old +say 'new word is:' new +$string = changestr(old,$string,new) +say 'The changed string is:' $string + /*stick a fork in it, we're done.*/ diff --git a/Task/Regular-expressions/REXX/regular-expressions-3.rexx b/Task/Regular-expressions/REXX/regular-expressions-3.rexx new file mode 100644 index 0000000000..ed7e2c992c --- /dev/null +++ b/Task/Regular-expressions/REXX/regular-expressions-3.rexx @@ -0,0 +1,11 @@ +/*REXX program shows non-destructive sub. (modeled after Perl example).*/ +$string = "I am a string" + old = " a " + new = " another " +say 'The original string is:' $string +say 'old word is:' old +say 'new word is:' new +$string2 = changestr(old,$string,new) +say 'The original string is:' $string +say 'The changed string is:' $string2 + /*stick a fork in it, we're done.*/ diff --git a/Task/Regular-expressions/REXX/regular-expressions-4.rexx b/Task/Regular-expressions/REXX/regular-expressions-4.rexx new file mode 100644 index 0000000000..f0f0942a69 --- /dev/null +++ b/Task/Regular-expressions/REXX/regular-expressions-4.rexx @@ -0,0 +1,14 @@ +/*REXX program shows test and substitute (modeled after Perl example).*/ + $string = "I am a string" + old = " am " + new = " was " +say 'The original string is:' $string +say 'old word is:' old +say 'new word is:' new + +if wordpos(old,$string)\==0 then + do + $string = changestr(old,$string,new) + say 'I was able to find and replace ' old " with " new + end + /*stick a fork in it, we're done.*/ diff --git a/Task/Regular-expressions/Racket/regular-expressions.rkt b/Task/Regular-expressions/Racket/regular-expressions.rkt new file mode 100644 index 0000000000..95b9e8a430 --- /dev/null +++ b/Task/Regular-expressions/Racket/regular-expressions.rkt @@ -0,0 +1,11 @@ +#lang racket + +(define s "I am a string") + +(when (regexp-match? #rx"string$" s) + (displayln "Ends with 'string'.")) + +(unless (regexp-match? #rx"^You" s) + (displayln "Does not start with 'You'.")) + +(displayln (regexp-replace " a " s " another ")) diff --git a/Task/Regular-expressions/Raven/regular-expressions-1.raven b/Task/Regular-expressions/Raven/regular-expressions-1.raven new file mode 100644 index 0000000000..0eeebdb8f8 --- /dev/null +++ b/Task/Regular-expressions/Raven/regular-expressions-1.raven @@ -0,0 +1 @@ +'i am a string' as str diff --git a/Task/Regular-expressions/Raven/regular-expressions-2.raven b/Task/Regular-expressions/Raven/regular-expressions-2.raven new file mode 100644 index 0000000000..b872a4e03c --- /dev/null +++ b/Task/Regular-expressions/Raven/regular-expressions-2.raven @@ -0,0 +1,2 @@ +str m/string$/ +if "Ends with 'string'\n" print diff --git a/Task/Regular-expressions/Raven/regular-expressions-3.raven b/Task/Regular-expressions/Raven/regular-expressions-3.raven new file mode 100644 index 0000000000..58171a66a4 --- /dev/null +++ b/Task/Regular-expressions/Raven/regular-expressions-3.raven @@ -0,0 +1 @@ +str r/ a / another / print diff --git a/Task/Regular-expressions/Ruby/regular-expressions-1.rb b/Task/Regular-expressions/Ruby/regular-expressions-1.rb new file mode 100644 index 0000000000..33f8f2574b --- /dev/null +++ b/Task/Regular-expressions/Ruby/regular-expressions-1.rb @@ -0,0 +1,3 @@ +str = "I am a string" +p "Ends with 'string'" if str =~ /string$/ +p "Does not start with 'You'" unless str =~ /^You/ diff --git a/Task/Regular-expressions/Ruby/regular-expressions-2.rb b/Task/Regular-expressions/Ruby/regular-expressions-2.rb new file mode 100644 index 0000000000..bf05bfc873 --- /dev/null +++ b/Task/Regular-expressions/Ruby/regular-expressions-2.rb @@ -0,0 +1,4 @@ +str.sub(/ a /, ' another ') #=> "I am another string" +# Or: +str[/ a /] = ' another ' #=> "another" +str #=> "I am another string" diff --git a/Task/Regular-expressions/Ruby/regular-expressions-3.rb b/Task/Regular-expressions/Ruby/regular-expressions-3.rb new file mode 100644 index 0000000000..44ea4a64b4 --- /dev/null +++ b/Task/Regular-expressions/Ruby/regular-expressions-3.rb @@ -0,0 +1 @@ +str.gsub(/\bam\b/) { |match| match.upcase } #=> "I AM a string" diff --git a/Task/Regular-expressions/Run-BASIC/regular-expressions.run b/Task/Regular-expressions/Run-BASIC/regular-expressions.run new file mode 100644 index 0000000000..c9388d6222 --- /dev/null +++ b/Task/Regular-expressions/Run-BASIC/regular-expressions.run @@ -0,0 +1,5 @@ +string$ = "I am a string" +if right$(string$,6) = "string" then print "'";string$;"' ends with 'string'" +i = instr(string$,"am") +string$ = left$(string$,i - 1) + "was" + mid$(string$,i + 2) +print "replace 'am' with 'was' = ";string$ diff --git a/Task/Regular-expressions/SNOBOL4/regular-expressions-1.sno b/Task/Regular-expressions/SNOBOL4/regular-expressions-1.sno new file mode 100644 index 0000000000..deb71f0b22 --- /dev/null +++ b/Task/Regular-expressions/SNOBOL4/regular-expressions-1.sno @@ -0,0 +1 @@ +label subject pattern = object :(goto) diff --git a/Task/Regular-expressions/SNOBOL4/regular-expressions-2.sno b/Task/Regular-expressions/SNOBOL4/regular-expressions-2.sno new file mode 100644 index 0000000000..185ebab772 --- /dev/null +++ b/Task/Regular-expressions/SNOBOL4/regular-expressions-2.sno @@ -0,0 +1,2 @@ + string1 = "The SNOBOL4 language is designed for string manipulation." + string1 "SNOBOL4" = "new SPITBOL" :s(changed)f(nochange) diff --git a/Task/Regular-expressions/SNOBOL4/regular-expressions-3.sno b/Task/Regular-expressions/SNOBOL4/regular-expressions-3.sno new file mode 100644 index 0000000000..87789279ee --- /dev/null +++ b/Task/Regular-expressions/SNOBOL4/regular-expressions-3.sno @@ -0,0 +1,5 @@ + pi = 3.1415926 + dd = "0123456789" + string1 = "For the first circle, the diameter is 2.5 inches." + numpat = span(dd) (("." span(dd)) | null) + string1 "diameter is " numpat . diam = "circumference is " diam * pi diff --git a/Task/Regular-expressions/Sather/regular-expressions.sa b/Task/Regular-expressions/Sather/regular-expressions.sa new file mode 100644 index 0000000000..a8f2339d2e --- /dev/null +++ b/Task/Regular-expressions/Sather/regular-expressions.sa @@ -0,0 +1,22 @@ +class MAIN is + -- we need to implement the substitution + regex_subst(re:REGEXP, s, sb:STR):STR is + from, to:INT; + re.match(s, out from, out to); + if from = -1 then return s; end; + return s.head(from) + sb + s.tail(s.size - to); + end; + + main is + s ::= "I am a string"; + re ::= REGEXP::regexp("string$", true); + if re.match(s) then + #OUT + "'" + s + "'" + " ends with 'string'\n"; + end; + if ~REGEXP::regexp("^You", false).match(s) then + #OUT + "'" + s + "'" + " does not begin with 'You'\n"; + end; + #OUT + regex_subst(re, s, "integer") + "\n"; + #OUT + regex_subst(REGEXP::regexp("am +a +st", true), s, "get the ") + "\n"; + end; +end; diff --git a/Task/Regular-expressions/Scala/regular-expressions-1.scala b/Task/Regular-expressions/Scala/regular-expressions-1.scala new file mode 100644 index 0000000000..453d317af5 --- /dev/null +++ b/Task/Regular-expressions/Scala/regular-expressions-1.scala @@ -0,0 +1,4 @@ +val Bottles1 = "(\\d+) bottles of beer".r // syntactic sugar +val Bottles2 = """(\d+) bottles of beer""".r // using triple-quotes to preserve backslashes +val Bottles3 = new scala.util.matching.Regex("(\\d+) bottles of beer") // standard +val Bottles4 = new scala.util.matching.Regex("""(\d+) bottles of beer""", "bottles") // with named groups diff --git a/Task/Regular-expressions/Scala/regular-expressions-2.scala b/Task/Regular-expressions/Scala/regular-expressions-2.scala new file mode 100644 index 0000000000..6e4f2aef34 --- /dev/null +++ b/Task/Regular-expressions/Scala/regular-expressions-2.scala @@ -0,0 +1,3 @@ +"99 bottles of beer" matches "(\\d+) bottles of beer" // the full string must match +"99 bottles of beer" replace ("99", "98") // Single replacement +"99 bottles of beer" replaceAll ("b", "B") // Multiple replacement diff --git a/Task/Regular-expressions/Scala/regular-expressions-3.scala b/Task/Regular-expressions/Scala/regular-expressions-3.scala new file mode 100644 index 0000000000..be99cf0861 --- /dev/null +++ b/Task/Regular-expressions/Scala/regular-expressions-3.scala @@ -0,0 +1,7 @@ +"\\d+".r findFirstIn "99 bottles of beer" // returns first partial match, or None +"\\w+".r findAllIn "99 bottles of beer" // returns all partial matches as an iterator +"\\s+".r findPrefixOf "99 bottles of beer" // returns a matching prefix, or None +Bottles4 findFirstMatchIn "99 bottles of beer" // returns a "Match" object, or None +Bottles4 findPrefixMatchOf "99 bottles of beer" // same thing, for prefixes +val bottles = (Bottles4 findFirstMatchIn "99 bottles of beer").get.group("bottles") // Getting a group by name +val Bottles4(bottles) = "99 bottles of beer" // syntactic sugar (not using group name) diff --git a/Task/Regular-expressions/Scala/regular-expressions-4.scala b/Task/Regular-expressions/Scala/regular-expressions-4.scala new file mode 100644 index 0000000000..ea8351d10b --- /dev/null +++ b/Task/Regular-expressions/Scala/regular-expressions-4.scala @@ -0,0 +1,13 @@ +val Some(bottles) = Bottles4 findPrefixOf "99 bottles of beer" // throws an exception if the matching fails; full string must match +for { + line <- """|99 bottles of beer on the wall + |99 bottles of beer + |Take one down, pass it around + |98 bottles of beer on the wall""".stripMargin.lines +} line match { + case Bottles1(bottles) => println("There are still "+bottles+" bottles.") // full string must match, so this will match only once + case _ => +} +for { + matched <- "(\\w+)".r findAllIn "99 bottles of beer" matchData // matchData converts to an Iterator of Match +} println("Matched from "+matched.start+" to "+matched.end) diff --git a/Task/Regular-expressions/Scala/regular-expressions-5.scala b/Task/Regular-expressions/Scala/regular-expressions-5.scala new file mode 100644 index 0000000000..dd02bbc56b --- /dev/null +++ b/Task/Regular-expressions/Scala/regular-expressions-5.scala @@ -0,0 +1,2 @@ +Bottles2 replaceFirstIn ("99 bottles of beer", "98 bottles of beer") +Bottles3 replaceAllIn ("99 bottles of beer", "98 bottles of beer") diff --git a/Task/Regular-expressions/Shiny/regular-expressions-1.shiny b/Task/Regular-expressions/Shiny/regular-expressions-1.shiny new file mode 100644 index 0000000000..74ede7e160 --- /dev/null +++ b/Task/Regular-expressions/Shiny/regular-expressions-1.shiny @@ -0,0 +1 @@ +str: 'I am a string' diff --git a/Task/Regular-expressions/Shiny/regular-expressions-2.shiny b/Task/Regular-expressions/Shiny/regular-expressions-2.shiny new file mode 100644 index 0000000000..8af5291628 --- /dev/null +++ b/Task/Regular-expressions/Shiny/regular-expressions-2.shiny @@ -0,0 +1,3 @@ +if str.match ~string$~ + say "Ends with 'string'" +end diff --git a/Task/Regular-expressions/Shiny/regular-expressions-3.shiny b/Task/Regular-expressions/Shiny/regular-expressions-3.shiny new file mode 100644 index 0000000000..6e08f93b2e --- /dev/null +++ b/Task/Regular-expressions/Shiny/regular-expressions-3.shiny @@ -0,0 +1 @@ +say str.alter ~ a ~ 'another' diff --git a/Task/Regular-expressions/Slate/regular-expressions.slate b/Task/Regular-expressions/Slate/regular-expressions.slate new file mode 100644 index 0000000000..11266f31bc --- /dev/null +++ b/Task/Regular-expressions/Slate/regular-expressions.slate @@ -0,0 +1,3 @@ + 'http://slatelanguage.org/test/page?query' =~ '^(([^:/?#]+)\\:)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?'. + +" ==> {'http:'. 'http'. '//slatelanguage.org'. 'slatelanguage.org'. '/test/page'. '?query'. 'query'. Nil} " diff --git a/Task/Regular-expressions/Smalltalk/regular-expressions.st b/Task/Regular-expressions/Smalltalk/regular-expressions.st new file mode 100644 index 0000000000..34515d1f55 --- /dev/null +++ b/Task/Regular-expressions/Smalltalk/regular-expressions.st @@ -0,0 +1,18 @@ +|re s s1| +re := Regex fromString: '[a-z]+ing'. +s := 'this is a matching string'. +s1 := 'this does not match'. + +(s =~ re) +ifMatched: [ :b | + b match displayNl +]. +(s1 =~ re) +ifMatched: [ :b | + 'Strangely matched!' displayNl +] +ifNotMatched: [ + 'no match!' displayNl +]. + +(s replacingRegex: re with: 'modified') displayNl. diff --git a/Task/Regular-expressions/Standard-ML/regular-expressions.ml b/Task/Regular-expressions/Standard-ML/regular-expressions.ml new file mode 100644 index 0000000000..19cd491172 --- /dev/null +++ b/Task/Regular-expressions/Standard-ML/regular-expressions.ml @@ -0,0 +1,14 @@ +CM.make "$/regexp-lib.cm"; +structure RE = RegExpFn ( + structure P = AwkSyntax + structure E = BackTrackEngine); +val re = RE.compileString "string$"; +val string = "I am a string"; +case StringCvt.scanString (RE.find re) string + of NONE => print "match failed\n" + | SOME match => + let + val {pos, len} = MatchTree.root match + in + print ("matched at position " ^ Int.toString pos ^ "\n") + end; diff --git a/Task/Regular-expressions/TXR/regular-expressions-1.txr b/Task/Regular-expressions/TXR/regular-expressions-1.txr new file mode 100644 index 0000000000..87e802fe6e --- /dev/null +++ b/Task/Regular-expressions/TXR/regular-expressions-1.txr @@ -0,0 +1,6 @@ +@(collect) +@(coll :gap 0)@mismatch@{match /dog/}@(end)@suffix +@(output) +@(rep)@{mismatch}cat@(end)@suffix +@(end) +@(end) diff --git a/Task/Regular-expressions/TXR/regular-expressions-2.txr b/Task/Regular-expressions/TXR/regular-expressions-2.txr new file mode 100644 index 0000000000..8becfd6740 --- /dev/null +++ b/Task/Regular-expressions/TXR/regular-expressions-2.txr @@ -0,0 +1,5 @@ +@(freeform) +@(coll :gap 0)@notcomment@{comment /[/][*].%[*][/]/}@(end)@tail +@(output) +@(rep)@notcomment @(end)@tail +@(end) diff --git a/Task/Regular-expressions/Tcl/regular-expressions-1.tcl b/Task/Regular-expressions/Tcl/regular-expressions-1.tcl new file mode 100644 index 0000000000..3fa925de20 --- /dev/null +++ b/Task/Regular-expressions/Tcl/regular-expressions-1.tcl @@ -0,0 +1,8 @@ +set theString "I am a string" +if {[regexp -- {string$} $theString]} { + puts "Ends with 'string'" +} + +if {![regexp -- {^You} $theString]} { + puts "Does not start with 'You'" +} diff --git a/Task/Regular-expressions/Tcl/regular-expressions-2.tcl b/Task/Regular-expressions/Tcl/regular-expressions-2.tcl new file mode 100644 index 0000000000..c93acc494f --- /dev/null +++ b/Task/Regular-expressions/Tcl/regular-expressions-2.tcl @@ -0,0 +1,4 @@ +set theString "This string has >123< a number in it" +if {[regexp -- {>(\d+)<} $theString -> number]} { + puts "Contains the number $number" +} diff --git a/Task/Regular-expressions/Tcl/regular-expressions-3.tcl b/Task/Regular-expressions/Tcl/regular-expressions-3.tcl new file mode 100644 index 0000000000..f9dc60e60a --- /dev/null +++ b/Task/Regular-expressions/Tcl/regular-expressions-3.tcl @@ -0,0 +1,2 @@ +set theString = "I am a string" +puts [regsub -- { +a +} $theString { another }] diff --git a/Task/Regular-expressions/Toka/regular-expressions.toka b/Task/Regular-expressions/Toka/regular-expressions.toka new file mode 100644 index 0000000000..466526cbc8 --- /dev/null +++ b/Task/Regular-expressions/Toka/regular-expressions.toka @@ -0,0 +1,19 @@ +#! Include the regex library +needs regex + +#! The two test strings +" This is a string" is-data test.1 +" Another string" is-data test.2 + +#! Create a new regex named 'expression' which tries +#! to match strings beginning with 'This'. +" ^This" regex: expression + +#! An array to store the results of the match +#! (Element 0 = starting offset, Element 1 = ending offset of match) +2 cells is-array match + +#! Try both test strings against the expression. +#! try-regex will return a flag. -1 is TRUE, 0 is FALSE +expression test.1 2 match try-regex . +expression test.2 2 match try-regex . diff --git a/Task/Regular-expressions/Vala/regular-expressions.vala b/Task/Regular-expressions/Vala/regular-expressions.vala new file mode 100644 index 0000000000..7c8e0aa1df --- /dev/null +++ b/Task/Regular-expressions/Vala/regular-expressions.vala @@ -0,0 +1,13 @@ +void main(){ + string sentence = "This is a sample sentence."; + + Regex a = new Regex("s[ai]mple"); // if using \n type expressions, use triple " for string literals as easy method to escape them + + if (a.match(sentence)){ + stdout.printf("\"%s\" is in \"%s\"!\n", a.get_pattern(), sentence); + } + + string sentence_replacement = "cat"; + sentence = a.replace(sentence, sentence.length, 0, sentence_replacement); + stdout.printf("Replaced sentence is: %s\n", sentence); +} diff --git a/Task/Regular-expressions/Vedit-macro-language/regular-expressions-1.vedit b/Task/Regular-expressions/Vedit-macro-language/regular-expressions-1.vedit new file mode 100644 index 0000000000..f3f9dfaa8f --- /dev/null +++ b/Task/Regular-expressions/Vedit-macro-language/regular-expressions-1.vedit @@ -0,0 +1,3 @@ +if (Match(".* string$", REGEXP)==0) { + Statline_Message("This line ends with 'string'") +} diff --git a/Task/Regular-expressions/Vedit-macro-language/regular-expressions-2.vedit b/Task/Regular-expressions/Vedit-macro-language/regular-expressions-2.vedit new file mode 100644 index 0000000000..227795076f --- /dev/null +++ b/Task/Regular-expressions/Vedit-macro-language/regular-expressions-2.vedit @@ -0,0 +1,3 @@ +if (Search("string$", REGEXP+NOERR)) { + Statline_Message("'string' at and of line found") +} diff --git a/Task/Regular-expressions/Vedit-macro-language/regular-expressions-3.vedit b/Task/Regular-expressions/Vedit-macro-language/regular-expressions-3.vedit new file mode 100644 index 0000000000..2985d0a52f --- /dev/null +++ b/Task/Regular-expressions/Vedit-macro-language/regular-expressions-3.vedit @@ -0,0 +1 @@ +Replace(" a ", " another ", REGEXP+NOERR) diff --git a/Task/Remove-duplicate-elements/0DESCRIPTION b/Task/Remove-duplicate-elements/0DESCRIPTION new file mode 100644 index 0000000000..4dc178b960 --- /dev/null +++ b/Task/Remove-duplicate-elements/0DESCRIPTION @@ -0,0 +1,6 @@ +Given an Array, derive a sequence of elements in which all duplicates are removed. + +There are basically three approaches seen here: +* Put the elements into a hash table which does not allow duplicates. The complexity is O(''n'') on average, and O(''n''2) worst case. This approach requires a hash function for your type (which is compatible with equality), either built-in to your language, or provided by the user. +* Sort the elements and remove consecutive duplicate elements. The complexity of the best sorting algorithms is O(''n'' log ''n''). This approach requires that your type be "comparable", i.e., have an ordering. Putting the elements into a self-balancing binary search tree is a special case of sorting. +* Go through the list, and for each element, check the rest of the list to see if it appears again, and discard it if it does. The complexity is O(''n''2). The up-shot is that this always works on any type (provided that you can test for equality). diff --git a/Task/Remove-duplicate-elements/ACL2/remove-duplicate-elements.acl2 b/Task/Remove-duplicate-elements/ACL2/remove-duplicate-elements.acl2 new file mode 100644 index 0000000000..28613ffc40 --- /dev/null +++ b/Task/Remove-duplicate-elements/ACL2/remove-duplicate-elements.acl2 @@ -0,0 +1 @@ +(remove-duplicates xs) diff --git a/Task/Remove-duplicate-elements/AWK/remove-duplicate-elements.awk b/Task/Remove-duplicate-elements/AWK/remove-duplicate-elements.awk new file mode 100644 index 0000000000..4b9fc89970 --- /dev/null +++ b/Task/Remove-duplicate-elements/AWK/remove-duplicate-elements.awk @@ -0,0 +1,2 @@ +$ awk 'BEGIN{split("a b c d c b a",a);for(i in a)b[a[i]]=1;r="";for(i in b)r=r" "i;print r}' +a b c d diff --git a/Task/Remove-duplicate-elements/Ada/remove-duplicate-elements-1.ada b/Task/Remove-duplicate-elements/Ada/remove-duplicate-elements-1.ada new file mode 100644 index 0000000000..c8e014d55b --- /dev/null +++ b/Task/Remove-duplicate-elements/Ada/remove-duplicate-elements-1.ada @@ -0,0 +1,21 @@ +with Ada.Containers.Ordered_Sets; +with Ada.Text_IO; use Ada.Text_IO; + +procedure Unique_Set is + package Int_Sets is new Ada.Containers.Ordered_Sets(Integer); + use Int_Sets; + Nums : array (Natural range <>) of Integer := (1,2,3,4,5,5,6,7,1); + Unique : Set; + Set_Cur : Cursor; + Success : Boolean; +begin + for I in Nums'range loop + Unique.Insert(Nums(I), Set_Cur, Success); + end loop; + Set_Cur := Unique.First; + loop + Put_Line(Item => Integer'Image(Element(Set_Cur))); + exit when Set_Cur = Unique.Last; + Set_Cur := Next(Set_Cur); + end loop; +end Unique_Set; diff --git a/Task/Remove-duplicate-elements/Ada/remove-duplicate-elements-2.ada b/Task/Remove-duplicate-elements/Ada/remove-duplicate-elements-2.ada new file mode 100644 index 0000000000..76fc8b13c5 --- /dev/null +++ b/Task/Remove-duplicate-elements/Ada/remove-duplicate-elements-2.ada @@ -0,0 +1,2 @@ +∪ 1 2 3 1 2 3 4 1 +1 2 3 4 diff --git a/Task/Remove-duplicate-elements/Ada/remove-duplicate-elements-3.ada b/Task/Remove-duplicate-elements/Ada/remove-duplicate-elements-3.ada new file mode 100644 index 0000000000..1e01817e31 --- /dev/null +++ b/Task/Remove-duplicate-elements/Ada/remove-duplicate-elements-3.ada @@ -0,0 +1,3 @@ +w←1 2 3 1 2 3 4 1 + ((⍳⍨w)=⍳⍴w)/w +1 2 3 4 diff --git a/Task/Remove-duplicate-elements/AppleScript/remove-duplicate-elements.applescript b/Task/Remove-duplicate-elements/AppleScript/remove-duplicate-elements.applescript new file mode 100644 index 0000000000..184753efb1 --- /dev/null +++ b/Task/Remove-duplicate-elements/AppleScript/remove-duplicate-elements.applescript @@ -0,0 +1,9 @@ +unique({1, 2, 3, "a", "b", "c", 2, 3, 4, "b", "c", "d"}) + +on unique(x) + set R to {} + repeat with i in x + if i is not in R then set end of R to i's contents + end repeat + return R +end unique diff --git a/Task/Remove-duplicate-elements/AutoHotkey/remove-duplicate-elements.ahk b/Task/Remove-duplicate-elements/AutoHotkey/remove-duplicate-elements.ahk new file mode 100644 index 0000000000..6f54e9e916 --- /dev/null +++ b/Task/Remove-duplicate-elements/AutoHotkey/remove-duplicate-elements.ahk @@ -0,0 +1,3 @@ +a = 1,2,1,4,5,2,15,1,3,4 +Sort, a, a, NUD`, +MsgBox % a ; 1,2,3,4,5,15 diff --git a/Task/Remove-duplicate-elements/BBC-BASIC/remove-duplicate-elements.bbc b/Task/Remove-duplicate-elements/BBC-BASIC/remove-duplicate-elements.bbc new file mode 100644 index 0000000000..9312d8066d --- /dev/null +++ b/Task/Remove-duplicate-elements/BBC-BASIC/remove-duplicate-elements.bbc @@ -0,0 +1,21 @@ + DIM list$(15) + list$() = "Now", "is", "the", "time", "for", "all", "good", "men", \ + \ "to", "come", "to", "the", "aid", "of", "the", "party." + num% = FNremoveduplicates(list$()) + FOR i% = 0 TO num%-1 + PRINT list$(i%) " " ; + NEXT + PRINT + END + + DEF FNremoveduplicates(l$()) + LOCAL i%, j%, n%, i$ + n% = 1 + FOR i% = 1 TO DIM(l$(), 1) + i$ = l$(i%) + FOR j% = 0 TO i%-1 + IF i$ = l$(j%) EXIT FOR + NEXT + IF j%>=i% l$(n%) = i$ : n% += 1 + NEXT + = n% diff --git a/Task/Remove-duplicate-elements/Bracmat/remove-duplicate-elements.bracmat b/Task/Remove-duplicate-elements/Bracmat/remove-duplicate-elements.bracmat new file mode 100644 index 0000000000..eaaf556c68 --- /dev/null +++ b/Task/Remove-duplicate-elements/Bracmat/remove-duplicate-elements.bracmat @@ -0,0 +1,63 @@ +2 3 5 7 11 13 17 19 cats 222 (-100.2) "+11" (1.1) "+7" (7.) 7 5 5 3 2 0 (4.4) 2:?LIST + +(A= + ( Hashing + = h elm list + . new$hash:?h + & whl + ' ( !arg:%?elm ?arg + & ( (h..find)$str$!elm + | (h..insert)$(str$!elm.!elm) + ) + ) + & :?list + & (h..forall) + $ ( + = .!arg:(?.?arg)&!arg !list:?list + ) + & !list + ) +& put$("Solution A:" Hashing$!LIST \n,LIN) +); + +(B= + ( backtracking + = answr elm + . :?answr + & !arg + : ? + ( %?`elm + ? + ( !elm ? + | &!answr !elm:?answr + ) + & ~ + ) + | !answr + ) +& put$("Solution B:" backtracking$!LIST \n,LIN) +); + +(C= + ( summing + = sum car LIST + . !arg:?LIST + & 0:?sum + & whl + ' ( !LIST:%?car ?LIST + & (.!car)+!sum:?sum + ) + & whl + ' ( !sum:#*(.?el)+?sum + & !el !LIST:?LIST + ) + & !LIST + ) +& put$("Solution C:" summing$!LIST \n,LIN) +); + +( !A +& !B +& !C +& +) diff --git a/Task/Remove-duplicate-elements/Brat/remove-duplicate-elements.brat b/Task/Remove-duplicate-elements/Brat/remove-duplicate-elements.brat new file mode 100644 index 0000000000..2122669571 --- /dev/null +++ b/Task/Remove-duplicate-elements/Brat/remove-duplicate-elements.brat @@ -0,0 +1,3 @@ +some_array = [1 1 2 1 'redundant' [1 2 3] [1 2 3] 'redundant'] + +unique_array = some_array.unique diff --git a/Task/Remove-duplicate-elements/C++/remove-duplicate-elements-1.cpp b/Task/Remove-duplicate-elements/C++/remove-duplicate-elements-1.cpp new file mode 100644 index 0000000000..f3c8902542 --- /dev/null +++ b/Task/Remove-duplicate-elements/C++/remove-duplicate-elements-1.cpp @@ -0,0 +1,15 @@ +#include +#include +using namespace std; + +int main() { + typedef set TySet; + int data[] = {1, 2, 3, 2, 3, 4}; + + TySet unique_set(data, data + 6); + + cout << "Set items:" << endl; + for (TySet::iterator iter = unique_set.begin(); iter != unique_set.end(); iter++) + cout << *iter << " "; + cout << endl; +} diff --git a/Task/Remove-duplicate-elements/C++/remove-duplicate-elements-2.cpp b/Task/Remove-duplicate-elements/C++/remove-duplicate-elements-2.cpp new file mode 100644 index 0000000000..2ddf068562 --- /dev/null +++ b/Task/Remove-duplicate-elements/C++/remove-duplicate-elements-2.cpp @@ -0,0 +1,15 @@ +#include +#include +using namespace std; + +int main() { + typedef __gnu_cxx::hash_set TyHash; + int data[] = {1, 2, 3, 2, 3, 4}; + + TyHash unique_set(data, data + 6); + + cout << "Set items:" << endl; + for (TyHash::iterator iter = unique_set.begin(); iter != unique_set.end(); iter++) + cout << *iter << " "; + cout << endl; +} diff --git a/Task/Remove-duplicate-elements/C++/remove-duplicate-elements-3.cpp b/Task/Remove-duplicate-elements/C++/remove-duplicate-elements-3.cpp new file mode 100644 index 0000000000..543db1e441 --- /dev/null +++ b/Task/Remove-duplicate-elements/C++/remove-duplicate-elements-3.cpp @@ -0,0 +1,15 @@ +#include +#include +using namespace std; + +int main() { + typedef tr1::unordered_set TyHash; + int data[] = {1, 2, 3, 2, 3, 4}; + + TyHash unique_set(data, data + 6); + + cout << "Set items:" << endl; + for (TyHash::iterator iter = unique_set.begin(); iter != unique_set.end(); iter++) + cout << *iter << " "; + cout << endl; +} diff --git a/Task/Remove-duplicate-elements/C++/remove-duplicate-elements-4.cpp b/Task/Remove-duplicate-elements/C++/remove-duplicate-elements-4.cpp new file mode 100644 index 0000000000..0f291700c3 --- /dev/null +++ b/Task/Remove-duplicate-elements/C++/remove-duplicate-elements-4.cpp @@ -0,0 +1,15 @@ +#include +#include +#include + +// helper template +template T* end(T (&array)[size]) { return array+size; } + +int main() +{ + int data[] = { 1, 2, 3, 2, 3, 4 }; + std::sort(data, end(data)); + int* new_end = std::unique(data, end(data)); + std::copy(data, new_end, std::ostream_iterator(std::cout, " "); + std::cout << std::endl; +} diff --git a/Task/Remove-duplicate-elements/C-sharp/remove-duplicate-elements-1.cs b/Task/Remove-duplicate-elements/C-sharp/remove-duplicate-elements-1.cs new file mode 100644 index 0000000000..a51ea9c03c --- /dev/null +++ b/Task/Remove-duplicate-elements/C-sharp/remove-duplicate-elements-1.cs @@ -0,0 +1,5 @@ +int[] nums = { 1, 1, 2, 3, 4, 4 }; +List unique = new List(); +foreach (int n in nums) + if (!unique.Contains(n)) + unique.Add(n); diff --git a/Task/Remove-duplicate-elements/C-sharp/remove-duplicate-elements-2.cs b/Task/Remove-duplicate-elements/C-sharp/remove-duplicate-elements-2.cs new file mode 100644 index 0000000000..8ab0194538 --- /dev/null +++ b/Task/Remove-duplicate-elements/C-sharp/remove-duplicate-elements-2.cs @@ -0,0 +1,2 @@ +int[] nums = {1, 1, 2, 3, 4, 4}; +int[] unique = nums.Distinct().ToArray(); diff --git a/Task/Remove-duplicate-elements/C/remove-duplicate-elements-1.c b/Task/Remove-duplicate-elements/C/remove-duplicate-elements-1.c new file mode 100644 index 0000000000..20511b72b4 --- /dev/null +++ b/Task/Remove-duplicate-elements/C/remove-duplicate-elements-1.c @@ -0,0 +1,33 @@ +#include +#include + +struct list_node {int x; struct list_node *next;}; +typedef struct list_node node; + +node * uniq(int *a, unsigned alen) + {if (alen == 0) return NULL; + node *start = malloc(sizeof(node)); + if (start == NULL) exit(EXIT_FAILURE); + start->x = a[0]; + start->next = NULL; + + for (int i = 1 ; i < alen ; ++i) + {node *n = start; + for (;; n = n->next) + {if (a[i] == n->x) break; + if (n->next == NULL) + {n->next = malloc(sizeof(node)); + n = n->next; + if (n == NULL) exit(EXIT_FAILURE); + n->x = a[i]; + n->next = NULL; + break;}}} + + return start;} + +int main(void) + {int a[] = {1, 2, 1, 4, 5, 2, 15, 1, 3, 4}; + for (node *n = uniq(a, 10) ; n != NULL ; n = n->next) + printf("%d ", n->x); + puts(""); + return 0;} diff --git a/Task/Remove-duplicate-elements/C/remove-duplicate-elements-2.c b/Task/Remove-duplicate-elements/C/remove-duplicate-elements-2.c new file mode 100644 index 0000000000..ef16132872 --- /dev/null +++ b/Task/Remove-duplicate-elements/C/remove-duplicate-elements-2.c @@ -0,0 +1,59 @@ +#include +#include +#include +#include + +/* Returns `true' if element `e' is in array `a'. Otherwise, returns `false'. + * Checks only the first `n' elements. Pure, O(n). + */ +bool elem(int *a, size_t n, int e) +{ + for (size_t i = 0; i < n; ++i) + if (a[i] == e) + return true; + + return false; +} + +/* Removes the duplicates in array `a' of given length `n'. Returns the number + * of unique elements. In-place, order preserving, O(n ^ 2). + */ +size_t nub(int *a, size_t n) +{ + size_t m = 0; + + for (size_t i = 0; i < n; ++i) + if (!elem(a, m, a[i])) + a[m++] = a[i]; + + return m; +} + +/* Out-place version of `nub'. Pure, order preserving, alloc < n * sizeof(int) + * bytes, O(n ^ 2). + */ +size_t nub_new(int **b, int *a, size_t n) +{ + int *c = malloc(n * sizeof(int)); + memcpy(c, a, n * sizeof(int)); + int m = nub(c, n); + *b = malloc(m * sizeof(int)); + memcpy(*b, c, m * sizeof(int)); + free(c); + return m; +} + +int main(void) +{ + int a[] = {1, 2, 1, 4, 5, 2, 15, 1, 3, 4}; + int *b; + + size_t n = nub_new(&b, a, sizeof(a) / sizeof(a[0])); + + for (size_t i = 0; i < n; ++i) + printf("%d ", b[i]); + puts(""); + + free(b); + return 0; +} diff --git a/Task/Remove-duplicate-elements/C/remove-duplicate-elements-3.c b/Task/Remove-duplicate-elements/C/remove-duplicate-elements-3.c new file mode 100644 index 0000000000..d52c287d7f --- /dev/null +++ b/Task/Remove-duplicate-elements/C/remove-duplicate-elements-3.c @@ -0,0 +1,29 @@ +#include +#include + +int icmp(const void *a, const void *b) +{ +#define _I(x) *(int*)x + return _I(a) < _I(b) ? -1 : _I(a) > _I(b); +#undef _I +} + +/* filter items in place and return number of uniques. if a separate + list is desired, duplicate it before calling this function */ +int uniq(int *a, int len) +{ + int i, j; + qsort(a, len, sizeof(int), icmp); + for (i = j = 0; i < len; i++) + if (a[i] != a[j]) a[++j] = a[i]; + return j + 1; +} + +int main() +{ + int x[] = {1, 2, 1, 4, 5, 2, 15, 1, 3, 4}; + int i, len = uniq(x, sizeof(x) / sizeof(x[0])); + for (i = 0; i < len; i++) printf("%d\n", x[i]); + + return 0; +} diff --git a/Task/Remove-duplicate-elements/Clojure/remove-duplicate-elements.clj b/Task/Remove-duplicate-elements/Clojure/remove-duplicate-elements.clj new file mode 100644 index 0000000000..18ae86410f --- /dev/null +++ b/Task/Remove-duplicate-elements/Clojure/remove-duplicate-elements.clj @@ -0,0 +1,3 @@ +user=> (distinct [1 3 2 9 1 2 3 8 8 1 0 2]) +(1 3 2 9 8 0) +user=> diff --git a/Task/Remove-duplicate-elements/Common-Lisp/remove-duplicate-elements-1.lisp b/Task/Remove-duplicate-elements/Common-Lisp/remove-duplicate-elements-1.lisp new file mode 100644 index 0000000000..17dd1ed493 --- /dev/null +++ b/Task/Remove-duplicate-elements/Common-Lisp/remove-duplicate-elements-1.lisp @@ -0,0 +1,2 @@ +(remove-duplicates '(1 3 2 9 1 2 3 8 8 1 0 2)) +> (9 3 8 1 0 2) diff --git a/Task/Remove-duplicate-elements/Common-Lisp/remove-duplicate-elements-2.lisp b/Task/Remove-duplicate-elements/Common-Lisp/remove-duplicate-elements-2.lisp new file mode 100644 index 0000000000..e98c72c781 --- /dev/null +++ b/Task/Remove-duplicate-elements/Common-Lisp/remove-duplicate-elements-2.lisp @@ -0,0 +1,2 @@ +(delete-duplicates '(1 3 2 9 1 2 3 8 8 1 0 2)) +> (9 3 8 1 0 2) diff --git a/Task/Remove-duplicate-elements/D/remove-duplicate-elements-1.d b/Task/Remove-duplicate-elements/D/remove-duplicate-elements-1.d new file mode 100644 index 0000000000..2e0f68ec2a --- /dev/null +++ b/Task/Remove-duplicate-elements/D/remove-duplicate-elements-1.d @@ -0,0 +1,7 @@ +import std.stdio, std.algorithm; + +void main() { + auto data = [1, 3, 2, 9, 1, 2, 3, 8, 8, 1, 0, 2]; + data.sort(); + writeln(uniq(data)); +} diff --git a/Task/Remove-duplicate-elements/D/remove-duplicate-elements-2.d b/Task/Remove-duplicate-elements/D/remove-duplicate-elements-2.d new file mode 100644 index 0000000000..c022116b0f --- /dev/null +++ b/Task/Remove-duplicate-elements/D/remove-duplicate-elements-2.d @@ -0,0 +1,10 @@ +import std.stdio; + +void main() { + auto data = [1, 3, 2, 9, 1, 2, 3, 8, 8, 1, 0, 2]; + + int[int] hash; + foreach (el; data) + hash[el] = 0; + writeln(hash.keys); +} diff --git a/Task/Remove-duplicate-elements/Delphi/remove-duplicate-elements.delphi b/Task/Remove-duplicate-elements/Delphi/remove-duplicate-elements.delphi new file mode 100644 index 0000000000..4a72f17b24 --- /dev/null +++ b/Task/Remove-duplicate-elements/Delphi/remove-duplicate-elements.delphi @@ -0,0 +1,24 @@ +program RemoveDuplicateElements; + +{$APPTYPE CONSOLE} + +uses Generics.Collections; + +var + i: Integer; + lIntegerList: TList; +const + INT_ARRAY: array[1..7] of Integer = (1, 2, 2, 3, 4, 5, 5); +begin + lIntegerList := TList.Create; + try + for i in INT_ARRAY do + if not lIntegerList.Contains(i) then + lIntegerList.Add(i); + + for i in lIntegerList do + Writeln(i); + finally + lIntegerList.Free; + end; +end. diff --git a/Task/Remove-duplicate-elements/E/remove-duplicate-elements.e b/Task/Remove-duplicate-elements/E/remove-duplicate-elements.e new file mode 100644 index 0000000000..1112880336 --- /dev/null +++ b/Task/Remove-duplicate-elements/E/remove-duplicate-elements.e @@ -0,0 +1 @@ +[1,2,3,2,3,4].asSet().getElements() diff --git a/Task/Remove-duplicate-elements/Erlang/remove-duplicate-elements.erl b/Task/Remove-duplicate-elements/Erlang/remove-duplicate-elements.erl new file mode 100644 index 0000000000..7a33cd6d06 --- /dev/null +++ b/Task/Remove-duplicate-elements/Erlang/remove-duplicate-elements.erl @@ -0,0 +1,2 @@ +List = [1, 2, 3, 2, 2, 4, 5, 5, 4, 6, 6, 5]. +UniqueList = gb_sets:to_list(gb_sets:from_list(List)). diff --git a/Task/Remove-duplicate-elements/Euphoria/remove-duplicate-elements.euphoria b/Task/Remove-duplicate-elements/Euphoria/remove-duplicate-elements.euphoria new file mode 100644 index 0000000000..70d5146b06 --- /dev/null +++ b/Task/Remove-duplicate-elements/Euphoria/remove-duplicate-elements.euphoria @@ -0,0 +1,17 @@ +include sort.e + +function uniq(sequence s) + sequence out + s = sort(s) + out = s[1..1] + for i = 2 to length(s) do + if not equal(s[i],out[$]) then + out = append(out, s[i]) + end if + end for + return out +end function + +constant s = {1, 2, 1, 4, 5, 2, 15, 1, 3, 4} +? s +? uniq(s) diff --git a/Task/Remove-duplicate-elements/Factor/remove-duplicate-elements.factor b/Task/Remove-duplicate-elements/Factor/remove-duplicate-elements.factor new file mode 100644 index 0000000000..f8e1f3a6ed --- /dev/null +++ b/Task/Remove-duplicate-elements/Factor/remove-duplicate-elements.factor @@ -0,0 +1,4 @@ +USING: sets ; +V{ 1 2 1 3 2 4 5 } pruned . + +V{ 1 2 3 4 5 } diff --git a/Task/Remove-duplicate-elements/Forth/remove-duplicate-elements-1.fth b/Task/Remove-duplicate-elements/Forth/remove-duplicate-elements-1.fth new file mode 100644 index 0000000000..134bdf3285 --- /dev/null +++ b/Task/Remove-duplicate-elements/Forth/remove-duplicate-elements-1.fth @@ -0,0 +1,19 @@ +\ Increments a2 until it no longer points to the same value as a1 +\ a3 is the address beyond the data a2 is traversing. +: skip-dups ( a1 a2 a3 -- a1 a2+n ) + dup rot ?do + over @ i @ <> if drop i leave then + cell +loop ; + +\ Compress an array of cells by removing adjacent duplicates +\ Returns the new count +: uniq ( a n -- n2 ) + over >r \ Original addr to return stack + cells over + >r \ "to" addr now on return stack, available as r@ + dup begin ( write read ) + dup r@ < + while + 2dup @ swap ! \ copy one cell + cell+ r@ skip-dups + cell 0 d+ \ increment write ptr only + repeat r> 2drop r> - cell / ; diff --git a/Task/Remove-duplicate-elements/Forth/remove-duplicate-elements-2.fth b/Task/Remove-duplicate-elements/Forth/remove-duplicate-elements-2.fth new file mode 100644 index 0000000000..6ac03b0e43 --- /dev/null +++ b/Task/Remove-duplicate-elements/Forth/remove-duplicate-elements-2.fth @@ -0,0 +1,12 @@ +: uniqv { a n \ r e -- n } + a n cells+ to e + a dup to r + \ the write address lives on the stack + begin + r e < + while + r @ over ! + r cell+ e skip-dups to r + cell+ + repeat + a - cell / ; diff --git a/Task/Remove-duplicate-elements/Forth/remove-duplicate-elements-3.fth b/Task/Remove-duplicate-elements/Forth/remove-duplicate-elements-3.fth new file mode 100644 index 0000000000..b7908172e8 --- /dev/null +++ b/Task/Remove-duplicate-elements/Forth/remove-duplicate-elements-3.fth @@ -0,0 +1,5 @@ +create test 1 , 2 , 3 , 2 , 6 , 4 , 5 , 3 , 6 , +here test - cell / constant ntest +: .test ( n -- ) 0 ?do test i cells + ? loop ; + +test ntest 2dup cell-sort uniq .test diff --git a/Task/Remove-duplicate-elements/Forth/remove-duplicate-elements-4.fth b/Task/Remove-duplicate-elements/Forth/remove-duplicate-elements-4.fth new file mode 100644 index 0000000000..d8139d8f05 --- /dev/null +++ b/Task/Remove-duplicate-elements/Forth/remove-duplicate-elements-4.fth @@ -0,0 +1 @@ +1 2 3 4 5 6 ok diff --git a/Task/Remove-duplicate-elements/Fortran/remove-duplicate-elements.f b/Task/Remove-duplicate-elements/Fortran/remove-duplicate-elements.f new file mode 100644 index 0000000000..0b6f4afbf6 --- /dev/null +++ b/Task/Remove-duplicate-elements/Fortran/remove-duplicate-elements.f @@ -0,0 +1,24 @@ +program remove_dups + implicit none + integer :: example(12) ! The input + integer :: res(size(example)) ! The output + integer :: k ! The number of unique elements + integer :: i, j + + example = [1, 2, 3, 2, 2, 4, 5, 5, 4, 6, 6, 5] + k = 1 + res(1) = example(1) + outer: do i=2,size(example) + do j=1,k + if (res(j) == example(i)) then + ! Found a match so start looking again + cycle outer + end if + end do + ! No match found so add it to the output + k = k + 1 + res(k) = example(i) + end do outer + write(*,advance='no',fmt='(a,i0,a)') 'Unique list has ',k,' elements: ' + write(*,*) res(1:k) +end program remove_dups diff --git a/Task/Remove-duplicate-elements/GAP/remove-duplicate-elements.gap b/Task/Remove-duplicate-elements/GAP/remove-duplicate-elements.gap new file mode 100644 index 0000000000..6a1649c740 --- /dev/null +++ b/Task/Remove-duplicate-elements/GAP/remove-duplicate-elements.gap @@ -0,0 +1,9 @@ +# Built-in, using sets (which are also lists) +a := [ 1, 2, 3, 1, [ 4 ], 5, 5, [4], 6 ]; +# [ 1, 2, 3, 1, [ 4 ], 5, 5, [ 4 ], 6 ] +b := Set(a); +# [ 1, 2, 3, 5, 6, [ 4 ] ] +IsSet(b); +# true +IsList(b); +# true diff --git a/Task/Remove-duplicate-elements/Go/remove-duplicate-elements-1.go b/Task/Remove-duplicate-elements/Go/remove-duplicate-elements-1.go new file mode 100644 index 0000000000..1a9254f54b --- /dev/null +++ b/Task/Remove-duplicate-elements/Go/remove-duplicate-elements-1.go @@ -0,0 +1,20 @@ +package main +import "fmt" + +func uniq(list []int) []int { + unique_set := make(map[int] bool, len(list)) + for _, x := range list { + unique_set[x] = true + } + result := make([]int, len(unique_set)) + i := 0 + for x := range unique_set { + result[i] = x + i++ + } + return result +} + +func main() { + fmt.Println(uniq([]int {1,2,3,2,3,4})) // prints: [3 1 4 2] +} diff --git a/Task/Remove-duplicate-elements/Go/remove-duplicate-elements-2.go b/Task/Remove-duplicate-elements/Go/remove-duplicate-elements-2.go new file mode 100644 index 0000000000..9aa3b7dffa --- /dev/null +++ b/Task/Remove-duplicate-elements/Go/remove-duplicate-elements-2.go @@ -0,0 +1,23 @@ +package main + +import "fmt" + +func uniq(list []int) []int { + unique_set := make(map[int]int, len(list)) + i := 0 + for _, x := range list { + if _, there := unique_set[x]; !there { + unique_set[x] = i + i++ + } + } + result := make([]int, len(unique_set)) + for x, i := range unique_set { + result[i] = x + } + return result +} + +func main() { + fmt.Println(uniq([]int{1, 2, 3, 2, 3, 4})) // prints: [1 2 3 4] +} diff --git a/Task/Remove-duplicate-elements/Go/remove-duplicate-elements-3.go b/Task/Remove-duplicate-elements/Go/remove-duplicate-elements-3.go new file mode 100644 index 0000000000..96c89f8e32 --- /dev/null +++ b/Task/Remove-duplicate-elements/Go/remove-duplicate-elements-3.go @@ -0,0 +1,35 @@ +package main + +import ( + "fmt" + "math" +) + +func uniq(list []float64) []float64 { + unique_set := map[float64]int{} + i := 0 + nan := false + for _, x := range list { + if _, exists := unique_set[x]; exists { + continue + } + if math.IsNaN(x) { + if nan { + continue + } else { + nan = true + } + } + unique_set[x] = i + i++ + } + result := make([]float64, len(unique_set)) + for x, i := range unique_set { + result[i] = x + } + return result +} + +func main() { + fmt.Println(uniq([]float64{1, 2, math.NaN(), 2, math.NaN(), 4})) +} diff --git a/Task/Remove-duplicate-elements/Groovy/remove-duplicate-elements.groovy b/Task/Remove-duplicate-elements/Groovy/remove-duplicate-elements.groovy new file mode 100644 index 0000000000..c0c0745857 --- /dev/null +++ b/Task/Remove-duplicate-elements/Groovy/remove-duplicate-elements.groovy @@ -0,0 +1,21 @@ +def list = [1, 2, 3, 'a', 'b', 'c', 2, 3, 4, 'b', 'c', 'd'] +assert list.size() == 12 +println " Original List: ${list}" + +// Filtering the List +list.unique() +assert list.size() == 8 +println " Filtered List: ${list}" + +list = [1, 2, 3, 'a', 'b', 'c', 2, 3, 4, 'b', 'c', 'd'] +assert list.size() == 12 + +// Converting to Set +def set = new HashSet(list) +assert set.size() == 8 +println " Set: ${set}" + +// Converting to Order-preserving Set +set = new LinkedHashSet(list) +assert set.size() == 8 +println "List-ordered Set: ${set}" diff --git a/Task/Remove-duplicate-elements/Haskell/remove-duplicate-elements.hs b/Task/Remove-duplicate-elements/Haskell/remove-duplicate-elements.hs new file mode 100644 index 0000000000..84409b2ef9 --- /dev/null +++ b/Task/Remove-duplicate-elements/Haskell/remove-duplicate-elements.hs @@ -0,0 +1,2 @@ +values = [1,2,3,2,3,4] +unique = List.nub values diff --git a/Task/Remove-duplicate-elements/HicEst/remove-duplicate-elements.hicest b/Task/Remove-duplicate-elements/HicEst/remove-duplicate-elements.hicest new file mode 100644 index 0000000000..f86197ad29 --- /dev/null +++ b/Task/Remove-duplicate-elements/HicEst/remove-duplicate-elements.hicest @@ -0,0 +1,9 @@ +REAL :: nums(12) +CHARACTER :: workspace*100 + +nums = (1, 3, 2, 9, 1, 2, 3, 8, 8, 1, 0, 2) +WRITE(Text=workspace) nums ! convert to string +EDIT(Text=workspace, SortDelDbls=workspace) ! do the job for a string +READ(Text=workspace, ItemS=individuals) nums ! convert to numeric + +WRITE(ClipBoard) individuals, "individuals: ", nums ! 6 individuals: 0 1 2 3 8 9 0 0 0 0 0 0 diff --git a/Task/Remove-duplicate-elements/IDL/remove-duplicate-elements.idl b/Task/Remove-duplicate-elements/IDL/remove-duplicate-elements.idl new file mode 100644 index 0000000000..1e78efd930 --- /dev/null +++ b/Task/Remove-duplicate-elements/IDL/remove-duplicate-elements.idl @@ -0,0 +1 @@ +non_repeated_values = array[uniq(array, sort( array))] diff --git a/Task/Remove-duplicate-elements/Icon/remove-duplicate-elements.icon b/Task/Remove-duplicate-elements/Icon/remove-duplicate-elements.icon new file mode 100644 index 0000000000..26d7dd4bfa --- /dev/null +++ b/Task/Remove-duplicate-elements/Icon/remove-duplicate-elements.icon @@ -0,0 +1,15 @@ +procedure main(args) + every write(!noDups(args)) +end + +procedure noDups(L) + every put(newL := [], notDup(set(),!L)) + return newL +end + +procedure notDup(cache, a) + if not member(cache, a) then { + insert(cache, a) + return a + } +end diff --git a/Task/Remove-duplicate-elements/Inform-7/remove-duplicate-elements.inf b/Task/Remove-duplicate-elements/Inform-7/remove-duplicate-elements.inf new file mode 100644 index 0000000000..ee495c60a4 --- /dev/null +++ b/Task/Remove-duplicate-elements/Inform-7/remove-duplicate-elements.inf @@ -0,0 +1,5 @@ +To decide which list of Ks is (L - list of values of kind K) without duplicates: + let result be a list of Ks; + repeat with X running through L: + add X to result, if absent; + decide on result. diff --git a/Task/Remove-duplicate-elements/J/remove-duplicate-elements-1.j b/Task/Remove-duplicate-elements/J/remove-duplicate-elements-1.j new file mode 100644 index 0000000000..568bf4eee3 --- /dev/null +++ b/Task/Remove-duplicate-elements/J/remove-duplicate-elements-1.j @@ -0,0 +1,4 @@ + ~. 4 3 2 8 0 1 9 5 1 7 6 3 9 9 4 2 1 5 3 2 +4 3 2 8 0 1 9 5 7 6 + ~. 'chthonic eleemosynary paronomasiac' +chtoni elmsyarp diff --git a/Task/Remove-duplicate-elements/J/remove-duplicate-elements-2.j b/Task/Remove-duplicate-elements/J/remove-duplicate-elements-2.j new file mode 100644 index 0000000000..dca038af45 --- /dev/null +++ b/Task/Remove-duplicate-elements/J/remove-duplicate-elements-2.j @@ -0,0 +1,10 @@ + 0 1 1 2 0 */0 1 2 +0 0 0 +0 1 2 +0 1 2 +0 2 4 +0 0 0 + ~. 0 1 1 2 0 */0 1 2 +0 0 0 +0 1 2 +0 2 4 diff --git a/Task/Remove-duplicate-elements/Java/remove-duplicate-elements.java b/Task/Remove-duplicate-elements/Java/remove-duplicate-elements.java new file mode 100644 index 0000000000..9999d778a2 --- /dev/null +++ b/Task/Remove-duplicate-elements/Java/remove-duplicate-elements.java @@ -0,0 +1,7 @@ +import java.util.Set; +import java.util.HashSet; +import java.util.Arrays; + +Object[] data = {1, 2, 3, "a", "b", "c", 2, 3, 4, "b", "c", "d"}; +Set uniqueSet = new HashSet(Arrays.asList(data)); +Object[] unique = uniqueSet.toArray(); diff --git a/Task/Remove-duplicate-elements/JavaScript/remove-duplicate-elements-1.js b/Task/Remove-duplicate-elements/JavaScript/remove-duplicate-elements-1.js new file mode 100644 index 0000000000..3208c188ae --- /dev/null +++ b/Task/Remove-duplicate-elements/JavaScript/remove-duplicate-elements-1.js @@ -0,0 +1,16 @@ +function unique(ary) { + // concat() with no args is a way to clone an array + var u = ary.concat().sort(); + for (var i = 1; i < u.length; ) { + if (u[i-1] === u[i]) + u.splice(i,1); + else + i++; + } + return u; +} + +var ary = [1, 2, 3, "a", "b", "c", 2, 3, 4, "b", "c", "d", "4"]; +var uniq = unique(ary); +for (var i = 0; i < uniq.length; i++) + print(uniq[i] + "\t" + typeof(uniq[i])); diff --git a/Task/Remove-duplicate-elements/JavaScript/remove-duplicate-elements-2.js b/Task/Remove-duplicate-elements/JavaScript/remove-duplicate-elements-2.js new file mode 100644 index 0000000000..607c9cf586 --- /dev/null +++ b/Task/Remove-duplicate-elements/JavaScript/remove-duplicate-elements-2.js @@ -0,0 +1,11 @@ +Array.prototype.unique = function() { + var u = this.concat().sort(); + for (var i = 1; i < u.length; ) { + if (u[i-1] === u[i]) + u.splice(i,1); + else + i++; + } + return u; +} +var uniq = [1, 2, 3, "a", "b", "c", 2, 3, 4, "b", "c", "d"].unique(); diff --git a/Task/Remove-duplicate-elements/Julia/remove-duplicate-elements.julia b/Task/Remove-duplicate-elements/Julia/remove-duplicate-elements.julia new file mode 100644 index 0000000000..c176d57578 --- /dev/null +++ b/Task/Remove-duplicate-elements/Julia/remove-duplicate-elements.julia @@ -0,0 +1,2 @@ +a = [1,2,3,4,1,2,3,4] +unique(a) diff --git a/Task/Remove-duplicate-elements/K/remove-duplicate-elements.k b/Task/Remove-duplicate-elements/K/remove-duplicate-elements.k new file mode 100644 index 0000000000..47d7ed9b43 --- /dev/null +++ b/Task/Remove-duplicate-elements/K/remove-duplicate-elements.k @@ -0,0 +1,31 @@ + a:4 5#20?13 / create a random 4 x 5 matrix +(12 7 12 4 3 + 6 3 7 4 7 + 3 8 3 1 2 + 2 12 6 4 1) + + ,/a / flatten to array +12 7 12 4 3 6 3 7 4 7 3 8 3 1 2 2 12 6 4 1 + + ?,/a / distinct elements +12 7 4 3 6 8 1 2 + + ?"chthonic eleemosynary paronomasiac" +"chtoni elmsyarp" + + ?("this";"that";"was";"that";"was";"this") +("this" + "that" + "was") + + 0 1 1 2 0 *\: 0 1 2 +(0 0 0 + 0 1 2 + 0 1 2 + 0 2 4 + 0 0 0) + + ?0 1 1 2 0 *\: 0 1 2 +(0 0 0 + 0 1 2 + 0 2 4) diff --git a/Task/Remove-duplicate-elements/Lang5/remove-duplicate-elements-1.lang5 b/Task/Remove-duplicate-elements/Lang5/remove-duplicate-elements-1.lang5 new file mode 100644 index 0000000000..793f67cafa --- /dev/null +++ b/Task/Remove-duplicate-elements/Lang5/remove-duplicate-elements-1.lang5 @@ -0,0 +1,8 @@ +: dip swap '_ set execute _ ; + +: remove-duplicates + [] swap do unique? length 0 == if break then loop drop ; +: unique? + 0 extract swap "2dup in if drop else append then" dip ; + +[1 2 6 3 6 4 5 6] remove-duplicates . diff --git a/Task/Remove-duplicate-elements/Lang5/remove-duplicate-elements-2.lang5 b/Task/Remove-duplicate-elements/Lang5/remove-duplicate-elements-2.lang5 new file mode 100644 index 0000000000..f5f6499fce --- /dev/null +++ b/Task/Remove-duplicate-elements/Lang5/remove-duplicate-elements-2.lang5 @@ -0,0 +1,2 @@ +[1 2 6 3 6 4 5 6] 's distinct +[1 2 6 3 6 4 5 6] 's dress dup union . diff --git a/Task/Remove-duplicate-elements/Liberty-BASIC/remove-duplicate-elements.liberty b/Task/Remove-duplicate-elements/Liberty-BASIC/remove-duplicate-elements.liberty new file mode 100644 index 0000000000..8827ecf924 --- /dev/null +++ b/Task/Remove-duplicate-elements/Liberty-BASIC/remove-duplicate-elements.liberty @@ -0,0 +1,18 @@ +a$ =" 1 $23.19 2 elbow 3 2 Bork 4 3 elbow 2 $23.19 " +print "Original set of elements = ["; a$; "]" + +b$ =removeDuplicates$( a$) +print "With duplicates removed = ["; b$; "]" + +end + +function removeDuplicates$( in$) + o$ =" " + i =1 + do + term$ =word$( in$, i, " ") + if instr( o$, " "; term$; " ") =0 and term$ <>" " then o$ =o$ +term$ +" " + i =i +1 + loop until term$ ="" + removeDuplicates$ =o$ +end function diff --git a/Task/Remove-duplicate-elements/Logo/remove-duplicate-elements.logo b/Task/Remove-duplicate-elements/Logo/remove-duplicate-elements.logo new file mode 100644 index 0000000000..56b7b279df --- /dev/null +++ b/Task/Remove-duplicate-elements/Logo/remove-duplicate-elements.logo @@ -0,0 +1 @@ +show remdup [1 2 3 a b c 2 3 4 b c d] ; [1 a 2 3 4 b c d] diff --git a/Task/Remove-duplicate-elements/Lua/remove-duplicate-elements.lua b/Task/Remove-duplicate-elements/Lua/remove-duplicate-elements.lua new file mode 100644 index 0000000000..7529e2733c --- /dev/null +++ b/Task/Remove-duplicate-elements/Lua/remove-duplicate-elements.lua @@ -0,0 +1,10 @@ +items = {1,2,3,4,1,2,3,4,"bird","cat","dog","dog","bird"} +flags = {} +io.write('Unique items are:') +for i=1,#items do + if not flags[items[i]] then + io.write(' ' .. items[i]) + flags[items[i]] = true + end +end +io.write('\n') diff --git a/Task/Remove-duplicate-elements/MATLAB/remove-duplicate-elements.m b/Task/Remove-duplicate-elements/MATLAB/remove-duplicate-elements.m new file mode 100644 index 0000000000..6067e4af30 --- /dev/null +++ b/Task/Remove-duplicate-elements/MATLAB/remove-duplicate-elements.m @@ -0,0 +1,5 @@ +>> unique([1 2 6 3 6 4 5 6]) + +ans = + + 1 2 3 4 5 6 diff --git a/Task/Remove-duplicate-elements/MAXScript/remove-duplicate-elements.maxscript b/Task/Remove-duplicate-elements/MAXScript/remove-duplicate-elements.maxscript new file mode 100644 index 0000000000..0a73861a3b --- /dev/null +++ b/Task/Remove-duplicate-elements/MAXScript/remove-duplicate-elements.maxscript @@ -0,0 +1,6 @@ +uniques = #(1, 2, 3, "a", "b", "c", 2, 3, 4, "b", "c", "d") +for i in uniques.count to 1 by -1 do +( + id = findItem uniques uniques[i] + if (id != i) do deleteItem uniques i +) diff --git a/Task/Remove-duplicate-elements/MUMPS/remove-duplicate-elements.mumps b/Task/Remove-duplicate-elements/MUMPS/remove-duplicate-elements.mumps new file mode 100644 index 0000000000..43733788dc --- /dev/null +++ b/Task/Remove-duplicate-elements/MUMPS/remove-duplicate-elements.mumps @@ -0,0 +1,11 @@ +REMDUPE(L,S) + ;L is the input listing + ;S is the separator between entries + ;R is the list to be returned + NEW Z,I,R + FOR I=1:1:$LENGTH(L,S) SET Z($PIECE(L,S,I))="" + ;Repack for return + SET I="",R="" + FOR SET I=$O(Z(I)) QUIT:I="" SET R=$SELECT($L(R)=0:I,1:R_S_I) + KILL Z,I + QUIT R diff --git a/Task/Remove-duplicate-elements/Maple/remove-duplicate-elements-1.maple b/Task/Remove-duplicate-elements/Maple/remove-duplicate-elements-1.maple new file mode 100644 index 0000000000..9a2e94b777 --- /dev/null +++ b/Task/Remove-duplicate-elements/Maple/remove-duplicate-elements-1.maple @@ -0,0 +1,5 @@ +> L := [ 1, 2, 1, 2, 3, 3, 2, 1, "a", "b", "b", "a", "c", "b" ]; + L := [1, 2, 1, 2, 3, 3, 2, 1, "a", "b", "b", "a", "c", "b"] + +> [op]({op}(L)); + [1, 2, 3, "a", "b", "c"] diff --git a/Task/Remove-duplicate-elements/Maple/remove-duplicate-elements-2.maple b/Task/Remove-duplicate-elements/Maple/remove-duplicate-elements-2.maple new file mode 100644 index 0000000000..3111d7d0a3 --- /dev/null +++ b/Task/Remove-duplicate-elements/Maple/remove-duplicate-elements-2.maple @@ -0,0 +1,2 @@ +> convert( convert( L, 'set' ), 'list' ); + [1, 2, 3, "a", "b", "c"] diff --git a/Task/Remove-duplicate-elements/Maple/remove-duplicate-elements-3.maple b/Task/Remove-duplicate-elements/Maple/remove-duplicate-elements-3.maple new file mode 100644 index 0000000000..b7e773ee8e --- /dev/null +++ b/Task/Remove-duplicate-elements/Maple/remove-duplicate-elements-3.maple @@ -0,0 +1,3 @@ +> A := Array( L ): +> for u in A do T[u] := 1 end: Array( [indices]( T, 'nolist' ) ); + [1, 2, 3, "c", "a", "b"] diff --git a/Task/Remove-duplicate-elements/Mathematica/remove-duplicate-elements-1.math b/Task/Remove-duplicate-elements/Mathematica/remove-duplicate-elements-1.math new file mode 100644 index 0000000000..64ec60acd9 --- /dev/null +++ b/Task/Remove-duplicate-elements/Mathematica/remove-duplicate-elements-1.math @@ -0,0 +1 @@ +DeleteDuplicates[{0, 2, 1, 4, 2, 0, 3, 1, 1, 1, 0, 3}] diff --git a/Task/Remove-duplicate-elements/Mathematica/remove-duplicate-elements-2.math b/Task/Remove-duplicate-elements/Mathematica/remove-duplicate-elements-2.math new file mode 100644 index 0000000000..72e6308b86 --- /dev/null +++ b/Task/Remove-duplicate-elements/Mathematica/remove-duplicate-elements-2.math @@ -0,0 +1 @@ +{0, 2, 1, 4, 3} diff --git a/Task/Remove-duplicate-elements/Mathematica/remove-duplicate-elements-3.math b/Task/Remove-duplicate-elements/Mathematica/remove-duplicate-elements-3.math new file mode 100644 index 0000000000..3e07149f89 --- /dev/null +++ b/Task/Remove-duplicate-elements/Mathematica/remove-duplicate-elements-3.math @@ -0,0 +1,2 @@ +NoDupes[input_List] := Split[Sort[input]][[All, 1]] +NoDupes[{0, 2, 1, 4, 2, 0, 3, 1, 1, 1, 0, 3}] diff --git a/Task/Remove-duplicate-elements/Mathematica/remove-duplicate-elements-4.math b/Task/Remove-duplicate-elements/Mathematica/remove-duplicate-elements-4.math new file mode 100644 index 0000000000..57387b15bd --- /dev/null +++ b/Task/Remove-duplicate-elements/Mathematica/remove-duplicate-elements-4.math @@ -0,0 +1 @@ +{0, 1, 2, 3, 4} diff --git a/Task/Remove-duplicate-elements/Maxima/remove-duplicate-elements.maxima b/Task/Remove-duplicate-elements/Maxima/remove-duplicate-elements.maxima new file mode 100644 index 0000000000..e9d6b3bfa4 --- /dev/null +++ b/Task/Remove-duplicate-elements/Maxima/remove-duplicate-elements.maxima @@ -0,0 +1,2 @@ +unique([8, 9, 5, 2, 0, 7, 0, 0, 4, 2, 7, 3, 9, 6, 6, 2, 4, 7, 9, 8, 3, 8, 0, 3, 7, 0, 2, 7, 6, 0]); +[0, 2, 3, 4, 5, 6, 7, 8, 9] diff --git a/Task/Remove-duplicate-elements/Nemerle/remove-duplicate-elements.nemerle b/Task/Remove-duplicate-elements/Nemerle/remove-duplicate-elements.nemerle new file mode 100644 index 0000000000..09e65c4c2e --- /dev/null +++ b/Task/Remove-duplicate-elements/Nemerle/remove-duplicate-elements.nemerle @@ -0,0 +1,12 @@ +using System.Linq; +using System.Console; + +module RemDups +{ + Main() : void + { + def nums = [1, 4, 6, 3, 6, 2, 7, 2, 5, 2, 6, 8]; + def unique = $[n | n in nums.Distinct()]; + WriteLine(unique); + } +} diff --git a/Task/Remove-duplicate-elements/NetRexx/remove-duplicate-elements.netrexx b/Task/Remove-duplicate-elements/NetRexx/remove-duplicate-elements.netrexx new file mode 100644 index 0000000000..16d8a08093 --- /dev/null +++ b/Task/Remove-duplicate-elements/NetRexx/remove-duplicate-elements.netrexx @@ -0,0 +1,47 @@ +/* NetRexx */ +options replace format comments java crossref symbols nobinary + +-- Note: Task requirement is to process "arrays". The following converts arrays into simple lists of words: +-- Putting the resulting list back into an array is left as an exercise for the reader. +a1 = [2, 3, 5, 7, 11, 13, 17, 19, 'cats', 222, -100.2, +11, 1.1, +7, '7.', 7, 5, 5, 3, 2, 0, 4.4, 2] +a2 = [1, 2, 3, 'a', 'b', 'c', 2, 3, 4, 'b', 'c', 'd'] +a3 = ['Now', 'is', 'the', 'time', 'for', 'all', 'good', 'men', 'to', 'come', 'to', 'the', 'aid', 'of', 'the', 'party.'] +x = 0 +lists = '' +x = x + 1; lists[0] = x; lists[x] = array2wordlist(a1) +x = x + 1; lists[0] = x; lists[x] = array2wordlist(a2) +x = x + 1; lists[0] = x; lists[x] = array2wordlist(a3) + +loop ix = 1 to lists[0] + nodups_list = remove_dups(lists[ix]) + say ix.right(4)':' lists[ix] + say ''.right(4)':' nodups_list + say + end ix + +return + +-- ============================================================================= +method remove_dups(list) public static + + newlist = '' + nodups = '0' + loop w_ = 1 to list.words() + ix = list.word(w_) + nodups[ix] = nodups[ix] + 1 -- we can even collect a count of dups if we want + end w_ + loop k_ over nodups + newlist = newlist k_ + end k_ + + return newlist.space + +-- ============================================================================= +method array2wordlist(ra = Rexx[]) public static + + wordlist = '' + loop r_ over ra + wordlist = wordlist r_ + end r_ + + return wordlist.space diff --git a/Task/Remove-duplicate-elements/NewLISP/remove-duplicate-elements.newlisp b/Task/Remove-duplicate-elements/NewLISP/remove-duplicate-elements.newlisp new file mode 100644 index 0000000000..5f783def84 --- /dev/null +++ b/Task/Remove-duplicate-elements/NewLISP/remove-duplicate-elements.newlisp @@ -0,0 +1 @@ +(unique '(1 2 3 a b c 2 3 4 b c d)) diff --git a/Task/Remove-duplicate-elements/Nial/remove-duplicate-elements-1.nial b/Task/Remove-duplicate-elements/Nial/remove-duplicate-elements-1.nial new file mode 100644 index 0000000000..ef62bb6bcb --- /dev/null +++ b/Task/Remove-duplicate-elements/Nial/remove-duplicate-elements-1.nial @@ -0,0 +1,5 @@ +uniques := [1, 2, 3, 'a', 'b', 'c', 2, 3, 4, 'b', 'c', 'd'] +cull uniques +=+-+-+-+-+-+-+-+-+ +=|1|2|3|a|b|c|4|d| +=+-+-+-+-+-+-+-+-+ diff --git a/Task/Remove-duplicate-elements/Nial/remove-duplicate-elements-2.nial b/Task/Remove-duplicate-elements/Nial/remove-duplicate-elements-2.nial new file mode 100644 index 0000000000..c3e5901602 --- /dev/null +++ b/Task/Remove-duplicate-elements/Nial/remove-duplicate-elements-2.nial @@ -0,0 +1,2 @@ +cull 1 1 2 2 3 3 +=1 2 3 diff --git a/Task/Remove-duplicate-elements/OCaml/remove-duplicate-elements.ocaml b/Task/Remove-duplicate-elements/OCaml/remove-duplicate-elements.ocaml new file mode 100644 index 0000000000..781110c7a2 --- /dev/null +++ b/Task/Remove-duplicate-elements/OCaml/remove-duplicate-elements.ocaml @@ -0,0 +1,7 @@ +let uniq lst = + let unique_set = Hashtbl.create (List.length lst) in + List.iter (fun x -> Hashtbl.replace unique_set x ()) lst; + Hashtbl.fold (fun x () xs -> x :: xs) unique_set [] + +let _ = + uniq [1;2;3;2;3;4] diff --git a/Task/Remove-duplicate-elements/Objeck/remove-duplicate-elements.objeck b/Task/Remove-duplicate-elements/Objeck/remove-duplicate-elements.objeck new file mode 100644 index 0000000000..3b492fe372 --- /dev/null +++ b/Task/Remove-duplicate-elements/Objeck/remove-duplicate-elements.objeck @@ -0,0 +1,21 @@ +use Structure; + +bundle Default { + class Unique { + function : Main(args : String[]) ~ Nil { + nums := [1, 1, 2, 3, 4, 4]; + unique := IntVector->New(); + + each(i : nums) { + n := nums[i]; + if(unique->Has(n) = false) { + unique->AddBack(n); + }; + }; + + each(i : unique) { + unique->Get(i)->PrintLine(); + }; + } + } +} diff --git a/Task/Remove-duplicate-elements/Objective-C/remove-duplicate-elements.m b/Task/Remove-duplicate-elements/Objective-C/remove-duplicate-elements.m new file mode 100644 index 0000000000..71a9016329 --- /dev/null +++ b/Task/Remove-duplicate-elements/Objective-C/remove-duplicate-elements.m @@ -0,0 +1,3 @@ +NSArray *items = [NSArray arrayWithObjects:@"A", @"B", @"C", @"B", @"A", nil]; + +NSSet *unique = [NSSet setWithArray:items]; diff --git a/Task/Remove-duplicate-elements/Octave/remove-duplicate-elements.octave b/Task/Remove-duplicate-elements/Octave/remove-duplicate-elements.octave new file mode 100644 index 0000000000..a537db934a --- /dev/null +++ b/Task/Remove-duplicate-elements/Octave/remove-duplicate-elements.octave @@ -0,0 +1,2 @@ +input=[1 2 6 4 2 32 5 5 4 3 3 5 1 2 32 4 4]; +output=unique(input); diff --git a/Task/Remove-duplicate-elements/Oz/remove-duplicate-elements.oz b/Task/Remove-duplicate-elements/Oz/remove-duplicate-elements.oz new file mode 100644 index 0000000000..e4b7de6a0b --- /dev/null +++ b/Task/Remove-duplicate-elements/Oz/remove-duplicate-elements.oz @@ -0,0 +1,12 @@ +declare + + fun {Nub Xs} + D = {Dictionary.new} + in + for X in Xs do D.X := unit end + {Dictionary.keys D} + end + +in + + {Show {Nub [1 2 1 3 5 4 3 4 4]}} diff --git a/Task/Remove-duplicate-elements/PARI-GP/remove-duplicate-elements.pari b/Task/Remove-duplicate-elements/PARI-GP/remove-duplicate-elements.pari new file mode 100644 index 0000000000..46af52eb3c --- /dev/null +++ b/Task/Remove-duplicate-elements/PARI-GP/remove-duplicate-elements.pari @@ -0,0 +1,3 @@ +rd(v)={ + vecsort(v,,8) +}; diff --git a/Task/Remove-duplicate-elements/PHP/remove-duplicate-elements.php b/Task/Remove-duplicate-elements/PHP/remove-duplicate-elements.php new file mode 100644 index 0000000000..e3ff40f1b3 --- /dev/null +++ b/Task/Remove-duplicate-elements/PHP/remove-duplicate-elements.php @@ -0,0 +1,2 @@ +$list = array(1, 2, 3, 'a', 'b', 'c', 2, 3, 4, 'b', 'c', 'd'); +$unique_list = array_unique($list); diff --git a/Task/Remove-duplicate-elements/PL-I/remove-duplicate-elements.pli b/Task/Remove-duplicate-elements/PL-I/remove-duplicate-elements.pli new file mode 100644 index 0000000000..19e2222efa --- /dev/null +++ b/Task/Remove-duplicate-elements/PL-I/remove-duplicate-elements.pli @@ -0,0 +1,18 @@ + declare t(20) fixed initial (1, 5, 6, 2, 1, 7, + 5, 22, 4, 19, 1, 1, 6, 6, 6, 8, 9, 10, 11, 12); + declare (i, j, k, n, e) fixed; + + n = hbound(t,1); + i = 0; +outer: + do k = 1 to n; + e = t(k); + do j = k-1 to 1 by -1; + if e = t(j) then iterate outer; + end; + i = i + 1; + t(i) = e; + end; + + put skip list ('Unique elements are:'); + put edit ((t(k) do k = 1 to i)) (skip, f(11)); diff --git a/Task/Remove-duplicate-elements/Pascal/remove-duplicate-elements.pascal b/Task/Remove-duplicate-elements/Pascal/remove-duplicate-elements.pascal new file mode 100644 index 0000000000..a90bd3a2bf --- /dev/null +++ b/Task/Remove-duplicate-elements/Pascal/remove-duplicate-elements.pascal @@ -0,0 +1,33 @@ +Program RemoveDuplicates; + +const + iArray: array[1..7] of integer = (1, 2, 2, 3, 4, 5, 5); + +var + rArray: array[1..7] of integer; + i, pos, last: integer; + newNumber: boolean; + +begin + rArray[1] := iArray[1]; + last := 1; + pos := 1; + while pos < high(iArray) do + begin + inc(pos); + newNumber := true; + for i := low(rArray) to last do + if iArray[pos] = rArray[i] then + begin + newNumber := false; + break; + end; + if newNumber then + begin + inc(last); + rArray[last] := iArray[pos]; + end; + end; + for i := low(rArray) to last do + writeln (rArray[i]); +end. diff --git a/Task/Remove-duplicate-elements/Perl-6/remove-duplicate-elements-1.pl6 b/Task/Remove-duplicate-elements/Perl-6/remove-duplicate-elements-1.pl6 new file mode 100644 index 0000000000..bef83b8f4e --- /dev/null +++ b/Task/Remove-duplicate-elements/Perl-6/remove-duplicate-elements-1.pl6 @@ -0,0 +1,7 @@ +sub nub (@a) { + my @b; + none(@b) eqv $_ and push @b, $_ for @a; + return @b; +} + +my @unique = nub [1, 2, 3, 5, 2, 4, 3, -3, 7, 5, 6]; diff --git a/Task/Remove-duplicate-elements/Perl-6/remove-duplicate-elements-2.pl6 b/Task/Remove-duplicate-elements/Perl-6/remove-duplicate-elements-2.pl6 new file mode 100644 index 0000000000..b8ce167a9f --- /dev/null +++ b/Task/Remove-duplicate-elements/Perl-6/remove-duplicate-elements-2.pl6 @@ -0,0 +1 @@ +my @unique = [1, 2, 3, 5, 2, 4, 3, -3, 7, 5, 6].uniq; diff --git a/Task/Remove-duplicate-elements/Perl/remove-duplicate-elements-1.pl b/Task/Remove-duplicate-elements/Perl/remove-duplicate-elements-1.pl new file mode 100644 index 0000000000..4712d8baac --- /dev/null +++ b/Task/Remove-duplicate-elements/Perl/remove-duplicate-elements-1.pl @@ -0,0 +1,3 @@ +use List::MoreUtils qw(uniq); + +my @uniq = uniq qw(1 2 3 a b c 2 3 4 b c d); diff --git a/Task/Remove-duplicate-elements/Perl/remove-duplicate-elements-2.pl b/Task/Remove-duplicate-elements/Perl/remove-duplicate-elements-2.pl new file mode 100644 index 0000000000..d686e43762 --- /dev/null +++ b/Task/Remove-duplicate-elements/Perl/remove-duplicate-elements-2.pl @@ -0,0 +1,2 @@ +my %seen; +my @uniq = grep {!$seen{$_}++} qw(1 2 3 a b c 2 3 4 b c d); diff --git a/Task/Remove-duplicate-elements/Perl/remove-duplicate-elements-3.pl b/Task/Remove-duplicate-elements/Perl/remove-duplicate-elements-3.pl new file mode 100644 index 0000000000..e280c4a254 --- /dev/null +++ b/Task/Remove-duplicate-elements/Perl/remove-duplicate-elements-3.pl @@ -0,0 +1,2 @@ +my %hash = map { $_ => 1 } qw(1 2 3 a b c 2 3 4 b c d); +my @uniq = keys %hash; diff --git a/Task/Remove-duplicate-elements/Perl/remove-duplicate-elements-4.pl b/Task/Remove-duplicate-elements/Perl/remove-duplicate-elements-4.pl new file mode 100644 index 0000000000..cfafe46a2b --- /dev/null +++ b/Task/Remove-duplicate-elements/Perl/remove-duplicate-elements-4.pl @@ -0,0 +1,3 @@ +my %seen; +@seen{qw(1 2 3 a b c 2 3 4 b c d)} = (); +my @uniq = keys %seen; diff --git a/Task/Remove-duplicate-elements/PicoLisp/remove-duplicate-elements.l b/Task/Remove-duplicate-elements/PicoLisp/remove-duplicate-elements.l new file mode 100644 index 0000000000..36db6f22ab --- /dev/null +++ b/Task/Remove-duplicate-elements/PicoLisp/remove-duplicate-elements.l @@ -0,0 +1 @@ +(uniq (2 4 6 1 2 3 4 5 6 1 3 5)) diff --git a/Task/Remove-duplicate-elements/Pop11/remove-duplicate-elements.pop11 b/Task/Remove-duplicate-elements/Pop11/remove-duplicate-elements.pop11 new file mode 100644 index 0000000000..e64c529291 --- /dev/null +++ b/Task/Remove-duplicate-elements/Pop11/remove-duplicate-elements.pop11 @@ -0,0 +1,13 @@ +;;; Initial array +lvars ar = {1 2 3 2 3 4}; +;;; Create a hash table +lvars ht= newmapping([], 50, 0, true); +;;; Put all array as keys into the hash table +lvars i; +for i from 1 to length(ar) do + 1 -> ht(ar(i)) +endfor; + +;;; Collect keys into a list +lvars ls = []; +appdata(ht, procedure(x); cons(front(x), ls) -> ls; endprocedure); diff --git a/Task/Remove-duplicate-elements/PostScript/remove-duplicate-elements.ps b/Task/Remove-duplicate-elements/PostScript/remove-duplicate-elements.ps new file mode 100644 index 0000000000..6012deb479 --- /dev/null +++ b/Task/Remove-duplicate-elements/PostScript/remove-duplicate-elements.ps @@ -0,0 +1 @@ + [10 8 8 98 32 2 4 5 10 ] dup length dict begin aload let* currentdict {pop} map end diff --git a/Task/Remove-duplicate-elements/PowerShell/remove-duplicate-elements-1.psh b/Task/Remove-duplicate-elements/PowerShell/remove-duplicate-elements-1.psh new file mode 100644 index 0000000000..8f8e709873 --- /dev/null +++ b/Task/Remove-duplicate-elements/PowerShell/remove-duplicate-elements-1.psh @@ -0,0 +1 @@ +$data = 1,2,3,1,2,3,4,1 diff --git a/Task/Remove-duplicate-elements/PowerShell/remove-duplicate-elements-2.psh b/Task/Remove-duplicate-elements/PowerShell/remove-duplicate-elements-2.psh new file mode 100644 index 0000000000..30f3abcc7d --- /dev/null +++ b/Task/Remove-duplicate-elements/PowerShell/remove-duplicate-elements-2.psh @@ -0,0 +1,5 @@ +$h = @{} +foreach ($x in $data) { + $h[$x] = 1 +} +$h.Keys diff --git a/Task/Remove-duplicate-elements/PowerShell/remove-duplicate-elements-3.psh b/Task/Remove-duplicate-elements/PowerShell/remove-duplicate-elements-3.psh new file mode 100644 index 0000000000..24580a883c --- /dev/null +++ b/Task/Remove-duplicate-elements/PowerShell/remove-duplicate-elements-3.psh @@ -0,0 +1 @@ +$data | Sort-Object -Unique diff --git a/Task/Remove-duplicate-elements/PowerShell/remove-duplicate-elements-4.psh b/Task/Remove-duplicate-elements/PowerShell/remove-duplicate-elements-4.psh new file mode 100644 index 0000000000..cafd3d1e34 --- /dev/null +++ b/Task/Remove-duplicate-elements/PowerShell/remove-duplicate-elements-4.psh @@ -0,0 +1 @@ +$data | Select-Object -Unique diff --git a/Task/Remove-duplicate-elements/Prolog/remove-duplicate-elements-1.pro b/Task/Remove-duplicate-elements/Prolog/remove-duplicate-elements-1.pro new file mode 100644 index 0000000000..a72e228a4b --- /dev/null +++ b/Task/Remove-duplicate-elements/Prolog/remove-duplicate-elements-1.pro @@ -0,0 +1 @@ +uniq(Data,Uniques) :- sort(Data,Uniques). diff --git a/Task/Remove-duplicate-elements/Prolog/remove-duplicate-elements-2.pro b/Task/Remove-duplicate-elements/Prolog/remove-duplicate-elements-2.pro new file mode 100644 index 0000000000..e16ec0c066 --- /dev/null +++ b/Task/Remove-duplicate-elements/Prolog/remove-duplicate-elements-2.pro @@ -0,0 +1,2 @@ +?- uniq([1, 2, 3, 2, 3, 4],Xs). +Xs = [1, 2, 3, 4] diff --git a/Task/Remove-duplicate-elements/Prolog/remove-duplicate-elements-3.pro b/Task/Remove-duplicate-elements/Prolog/remove-duplicate-elements-3.pro new file mode 100644 index 0000000000..39f13f8285 --- /dev/null +++ b/Task/Remove-duplicate-elements/Prolog/remove-duplicate-elements-3.pro @@ -0,0 +1,6 @@ +member1(X,[H|_]) :- X==H,!. +member1(X,[_|T]) :- member1_(X,T). + +distinct([],[]). +distinct([H|T],C) :- member1(H,T),!, distinct(T,C). +distinct([H|T],[H|C]) :- distinct(T,C). diff --git a/Task/Remove-duplicate-elements/Prolog/remove-duplicate-elements-4.pro b/Task/Remove-duplicate-elements/Prolog/remove-duplicate-elements-4.pro new file mode 100644 index 0000000000..baae340a5c --- /dev/null +++ b/Task/Remove-duplicate-elements/Prolog/remove-duplicate-elements-4.pro @@ -0,0 +1,2 @@ +?- distinct([A, A, 1, 2, 3, 2, 3, 4],Xs). +Xs = [A, 1, 2, 3, 4] diff --git a/Task/Remove-duplicate-elements/PureBasic/remove-duplicate-elements.purebasic b/Task/Remove-duplicate-elements/PureBasic/remove-duplicate-elements.purebasic new file mode 100644 index 0000000000..b41111b238 --- /dev/null +++ b/Task/Remove-duplicate-elements/PureBasic/remove-duplicate-elements.purebasic @@ -0,0 +1,11 @@ +NewMap MyElements.s() + +For i=0 To 9 ;Mark 10 items at random, causing high risk of duplication items. + x=Random(9) + t$="Number "+str(x)+" is marked" + MyElements(str(x))=t$ ; Add element 'X' to the hash list or overwrite if already included. +Next + +ForEach MyElements() + Debug MyElements() +Next diff --git a/Task/Remove-duplicate-elements/Python/remove-duplicate-elements-1.py b/Task/Remove-duplicate-elements/Python/remove-duplicate-elements-1.py new file mode 100644 index 0000000000..327129fb6b --- /dev/null +++ b/Task/Remove-duplicate-elements/Python/remove-duplicate-elements-1.py @@ -0,0 +1,2 @@ +items = [1, 2, 3, 'a', 'b', 'c', 2, 3, 4, 'b', 'c', 'd'] +unique = list(set(items)) diff --git a/Task/Remove-duplicate-elements/Python/remove-duplicate-elements-2.py b/Task/Remove-duplicate-elements/Python/remove-duplicate-elements-2.py new file mode 100644 index 0000000000..d05d59cd9e --- /dev/null +++ b/Task/Remove-duplicate-elements/Python/remove-duplicate-elements-2.py @@ -0,0 +1,3 @@ +import itertools +items = [1, 2, 3, 'a', 'b', 'c', 2, 3, 4, 'b', 'c', 'd'] +unique = [k for k,g in itertools.groupby(sorted(items))] diff --git a/Task/Remove-duplicate-elements/Python/remove-duplicate-elements-3.py b/Task/Remove-duplicate-elements/Python/remove-duplicate-elements-3.py new file mode 100644 index 0000000000..bcda68e080 --- /dev/null +++ b/Task/Remove-duplicate-elements/Python/remove-duplicate-elements-3.py @@ -0,0 +1,5 @@ +items = [1, 2, 3, 'a', 'b', 'c', 2, 3, 4, 'b', 'c', 'd'] +unique = [] +for x in items: + if x not in unique: + unique.append(x) diff --git a/Task/Remove-duplicate-elements/Qi/remove-duplicate-elements.qi b/Task/Remove-duplicate-elements/Qi/remove-duplicate-elements.qi new file mode 100644 index 0000000000..2ec85f01d7 --- /dev/null +++ b/Task/Remove-duplicate-elements/Qi/remove-duplicate-elements.qi @@ -0,0 +1,6 @@ +(define remove-duplicates + [] -> [] + [A|R] -> (remove-duplicates R) where (element? A R) + [A|R] -> [A|(remove-duplicates R)]) + +(remove-duplicates [a b a a b b c d e]) diff --git a/Task/Remove-duplicate-elements/REBOL/remove-duplicate-elements.rebol b/Task/Remove-duplicate-elements/REBOL/remove-duplicate-elements.rebol new file mode 100644 index 0000000000..4e8e895e47 --- /dev/null +++ b/Task/Remove-duplicate-elements/REBOL/remove-duplicate-elements.rebol @@ -0,0 +1 @@ +print mold unique [1 $23.19 2 elbow 3 2 Bork 4 3 elbow 2 $23.19] diff --git a/Task/Remove-duplicate-elements/REXX/remove-duplicate-elements-1.rexx b/Task/Remove-duplicate-elements/REXX/remove-duplicate-elements-1.rexx new file mode 100644 index 0000000000..7814224902 --- /dev/null +++ b/Task/Remove-duplicate-elements/REXX/remove-duplicate-elements-1.rexx @@ -0,0 +1,12 @@ +/*REXX program to remove duplicate elements (items) in a list. */ +$= '2 3 5 7 11 13 17 19 cats 222 -100.2 +11 1.1 +7 7. 7 5 5 3 2 0 4.4 2' +say 'original list:' $ +say right(words($),13) ' words in the original list.'; say + + do j=words($) by -1 to 1; y=word($,j) /*process words in the list, */ + _=wordpos(y, $, j+1); if _\==0 then $=delword($, _, 1) /*del if dup.*/ + end /*j*/ + +say 'modified list:' space($) +say right(words($),13) ' words in the modified list.' + /*stick a fork in it, we're done.*/ diff --git a/Task/Remove-duplicate-elements/REXX/remove-duplicate-elements-2.rexx b/Task/Remove-duplicate-elements/REXX/remove-duplicate-elements-2.rexx new file mode 100644 index 0000000000..47a9f05de7 --- /dev/null +++ b/Task/Remove-duplicate-elements/REXX/remove-duplicate-elements-2.rexx @@ -0,0 +1,13 @@ +/*REXX program to remove duplicate elements (items) in a list. */ +old= '2 3 5 7 11 13 17 19 cats 222 -100.2 +11 1.1 +7 7. 7 5 5 3 2 0 4.4 2' +say 'original list:' old +say right(words(old),13) ' words in the original list.'; say +new= /*start with a clean slate. */ + + do j=1 for words(old); _=word(old,j) /*process the words in old list. */ + if wordpos(_,new)==0 then new=new _ /*Doesn't exist? Then add to list*/ + end /*j*/ + +say 'modified list:' space(new) +say right(words(new),13) ' words in the modified list.' + /*stick a fork in it, we're done.*/ diff --git a/Task/Remove-duplicate-elements/REXX/remove-duplicate-elements-3.rexx b/Task/Remove-duplicate-elements/REXX/remove-duplicate-elements-3.rexx new file mode 100644 index 0000000000..598aba2103 --- /dev/null +++ b/Task/Remove-duplicate-elements/REXX/remove-duplicate-elements-3.rexx @@ -0,0 +1,28 @@ +/* REXX ************************************************************ +* 26.11.2012 Walter Pachl +* added: show multiple occurrences +**********************************************************************/ +old='2 3 5 7 11 13 17 19 cats 222 -100.2 +11 1.1 +7 7. 7 5 5', + '3 2 0 4.4 2' +say 'old list='old +say 'words in the old list=' words(old) +new='' +found.=0 +count.=0 +Do While old<>'' + Parse Var old w old + If found.w=0 Then Do + new=new w + found.w=1 + End + count.w=count.w+1 + End +say 'new list='strip(new) +say 'words in the new list=' words(new) +Say 'Multiple occurrences:' +Say 'occ word' +Do While new<>'' + Parse Var new w new + If count.w>1 Then + Say right(count.w,3) w + End diff --git a/Task/Remove-duplicate-elements/Raven/remove-duplicate-elements.raven b/Task/Remove-duplicate-elements/Raven/remove-duplicate-elements.raven new file mode 100644 index 0000000000..719281ed77 --- /dev/null +++ b/Task/Remove-duplicate-elements/Raven/remove-duplicate-elements.raven @@ -0,0 +1,12 @@ +[ 1 2 3 'a' 'b' 'c' 2 3 4 'b' 'c' 'd' ] as items +items copy unique print + +list (8 items) + 0 => 1 + 1 => 2 + 2 => 3 + 3 => "a" + 4 => "b" + 5 => "c" + 6 => 4 + 7 => "d" diff --git a/Task/Remove-duplicate-elements/Ruby/remove-duplicate-elements.rb b/Task/Remove-duplicate-elements/Ruby/remove-duplicate-elements.rb new file mode 100644 index 0000000000..00e06623e6 --- /dev/null +++ b/Task/Remove-duplicate-elements/Ruby/remove-duplicate-elements.rb @@ -0,0 +1,3 @@ +ary = [1,1,2,1,'redundant',[1,2,3],[1,2,3],'redundant'] +uniq_ary = ary.uniq +# => [1, 2, "redundant", [1, 2, 3]] diff --git a/Task/Remove-duplicate-elements/SETL/remove-duplicate-elements-1.setl b/Task/Remove-duplicate-elements/SETL/remove-duplicate-elements-1.setl new file mode 100644 index 0000000000..ee52d0cdc5 --- /dev/null +++ b/Task/Remove-duplicate-elements/SETL/remove-duplicate-elements-1.setl @@ -0,0 +1,2 @@ +items := [0,7,6,6,4,9,7,1,2,3,2]; +print(unique(items)); diff --git a/Task/Remove-duplicate-elements/SETL/remove-duplicate-elements-2.setl b/Task/Remove-duplicate-elements/SETL/remove-duplicate-elements-2.setl new file mode 100644 index 0000000000..32a9ca93d0 --- /dev/null +++ b/Task/Remove-duplicate-elements/SETL/remove-duplicate-elements-2.setl @@ -0,0 +1,3 @@ +proc unique(items); + return [item: item in {item: item in items}]; +end proc; diff --git a/Task/Remove-duplicate-elements/SETL/remove-duplicate-elements-3.setl b/Task/Remove-duplicate-elements/SETL/remove-duplicate-elements-3.setl new file mode 100644 index 0000000000..bec776839c --- /dev/null +++ b/Task/Remove-duplicate-elements/SETL/remove-duplicate-elements-3.setl @@ -0,0 +1,4 @@ +proc unique(items); + seen := {}; + return [item: item in items, nps in {#seen} | #(seen with:= item) > nps]; +end proc; diff --git a/Task/Remove-duplicate-elements/Scala/remove-duplicate-elements.scala b/Task/Remove-duplicate-elements/Scala/remove-duplicate-elements.scala new file mode 100644 index 0000000000..25b42728f1 --- /dev/null +++ b/Task/Remove-duplicate-elements/Scala/remove-duplicate-elements.scala @@ -0,0 +1,7 @@ +val list = List(1,2,3,4,2,3,4,99) +val l2 = list.distinct +// l2: scala.List[scala.Int] = List(1,2,3,4,99) + +val arr = Array(1,2,3,4,2,3,4,99) +val arr2 = arr.distinct +// arr2: Array[Int] = Array(1, 2, 3, 4, 99) diff --git a/Task/Remove-duplicate-elements/Scheme/remove-duplicate-elements-1.ss b/Task/Remove-duplicate-elements/Scheme/remove-duplicate-elements-1.ss new file mode 100644 index 0000000000..913387e949 --- /dev/null +++ b/Task/Remove-duplicate-elements/Scheme/remove-duplicate-elements-1.ss @@ -0,0 +1,9 @@ +(define (remove-duplicates l) + (cond ((null? l) + '()) + ((member (car l) (cdr l)) + (remove-duplicates (cdr l))) + (else + (cons (car l) (remove-duplicates (cdr l)))))) + +(remove-duplicates '(1 2 1 3 2 4 5)) diff --git a/Task/Remove-duplicate-elements/Scheme/remove-duplicate-elements-2.ss b/Task/Remove-duplicate-elements/Scheme/remove-duplicate-elements-2.ss new file mode 100644 index 0000000000..525f39f575 --- /dev/null +++ b/Task/Remove-duplicate-elements/Scheme/remove-duplicate-elements-2.ss @@ -0,0 +1 @@ +(1 3 2 4 5) diff --git a/Task/Remove-duplicate-elements/Scheme/remove-duplicate-elements-3.ss b/Task/Remove-duplicate-elements/Scheme/remove-duplicate-elements-3.ss new file mode 100644 index 0000000000..c057ef45aa --- /dev/null +++ b/Task/Remove-duplicate-elements/Scheme/remove-duplicate-elements-3.ss @@ -0,0 +1,6 @@ +(define (remove-duplicates l) + (do ((a '() (if (member (car l) a) a (cons (car l) a))) + (l l (cdr l))) + ((null? l) (reverse a)))) + +(remove-duplicates '(1 2 1 3 2 4 5)) diff --git a/Task/Remove-duplicate-elements/Scheme/remove-duplicate-elements-4.ss b/Task/Remove-duplicate-elements/Scheme/remove-duplicate-elements-4.ss new file mode 100644 index 0000000000..695e389e14 --- /dev/null +++ b/Task/Remove-duplicate-elements/Scheme/remove-duplicate-elements-4.ss @@ -0,0 +1 @@ +(1 2 3 4 5) diff --git a/Task/Remove-duplicate-elements/Seed7/remove-duplicate-elements.seed7 b/Task/Remove-duplicate-elements/Seed7/remove-duplicate-elements.seed7 new file mode 100644 index 0000000000..1eb213fc7d --- /dev/null +++ b/Task/Remove-duplicate-elements/Seed7/remove-duplicate-elements.seed7 @@ -0,0 +1,13 @@ +$ include "seed7_05.s7i"; + +const proc: main is func + local + const array integer: data is [] (1, 3, 2, 9, 1, 2, 3, 8, 8, 1, 0, 2); + var set of integer: dataSet is (set of integer).value; + var integer: number is 0; + begin + for number range data do + incl(dataSet, number); + end for; + writeln(dataSet); + end func; diff --git a/Task/Remove-duplicate-elements/Slate/remove-duplicate-elements.slate b/Task/Remove-duplicate-elements/Slate/remove-duplicate-elements.slate new file mode 100644 index 0000000000..5a37ac016f --- /dev/null +++ b/Task/Remove-duplicate-elements/Slate/remove-duplicate-elements.slate @@ -0,0 +1,3 @@ +[|:s| #(1 2 3 4 1 2 3 4) >> s] writingAs: Set. + +"==> {"Set traitsWindow" 1. 2. 3. 4}" diff --git a/Task/Remove-duplicate-elements/Smalltalk/remove-duplicate-elements-1.st b/Task/Remove-duplicate-elements/Smalltalk/remove-duplicate-elements-1.st new file mode 100644 index 0000000000..483e812f39 --- /dev/null +++ b/Task/Remove-duplicate-elements/Smalltalk/remove-duplicate-elements-1.st @@ -0,0 +1,4 @@ +"Example of creating a collection" +|a| +a := #( 1 1 2 'hello' 'world' #symbol #another 2 'hello' #symbol ). +a asSet. diff --git a/Task/Remove-duplicate-elements/Smalltalk/remove-duplicate-elements-2.st b/Task/Remove-duplicate-elements/Smalltalk/remove-duplicate-elements-2.st new file mode 100644 index 0000000000..c1340bb2a2 --- /dev/null +++ b/Task/Remove-duplicate-elements/Smalltalk/remove-duplicate-elements-2.st @@ -0,0 +1,3 @@ +|a| +a := #( 1 1 2 'hello' 'world' #symbol #another 2 'hello' #symbol ). +a asOrderedSet. diff --git a/Task/Remove-duplicate-elements/TUSCRIPT/remove-duplicate-elements-1.tuscript b/Task/Remove-duplicate-elements/TUSCRIPT/remove-duplicate-elements-1.tuscript new file mode 100644 index 0000000000..3061e3411a --- /dev/null +++ b/Task/Remove-duplicate-elements/TUSCRIPT/remove-duplicate-elements-1.tuscript @@ -0,0 +1,6 @@ +$$ MODE TUSCRIPT +list_old="b'A'A'5'1'2'3'2'3'4" +list_sort=MIXED_SORT (list_old) +list_new=REDUCE (list_sort) +PRINT list_old +PRINT list_new diff --git a/Task/Remove-duplicate-elements/TUSCRIPT/remove-duplicate-elements-2.tuscript b/Task/Remove-duplicate-elements/TUSCRIPT/remove-duplicate-elements-2.tuscript new file mode 100644 index 0000000000..05893304e7 --- /dev/null +++ b/Task/Remove-duplicate-elements/TUSCRIPT/remove-duplicate-elements-2.tuscript @@ -0,0 +1,11 @@ +$$ MODE TUSCRIPT +list_old="b'A'A'5'1'2'3'2'3'4" +DICT list CREATE +LOOP l=list_old +DICT list LOOKUP l,num +IF (num==0) DICT list ADD l +ENDLOOP +DICT list unload list +list_new=JOIN (list) +PRINT list_old +PRINT list_new diff --git a/Task/Remove-duplicate-elements/Tcl/remove-duplicate-elements.tcl b/Task/Remove-duplicate-elements/Tcl/remove-duplicate-elements.tcl new file mode 100644 index 0000000000..d4fdeeaf4d --- /dev/null +++ b/Task/Remove-duplicate-elements/Tcl/remove-duplicate-elements.tcl @@ -0,0 +1 @@ +set result [lsort -unique $listname] diff --git a/Task/Remove-duplicate-elements/UnixPipes/remove-duplicate-elements-1.unixpipes b/Task/Remove-duplicate-elements/UnixPipes/remove-duplicate-elements-1.unixpipes new file mode 100644 index 0000000000..487c4e4537 --- /dev/null +++ b/Task/Remove-duplicate-elements/UnixPipes/remove-duplicate-elements-1.unixpipes @@ -0,0 +1,15 @@ +bash$ # original list +bash$ printf '6\n2\n3\n6\n4\n2\n' +6 +2 +3 +6 +4 +2 +bash$ # made uniq +bash$ printf '6\n2\n3\n6\n4\n2\n'|sort -n|uniq +2 +3 +4 +6 +bash$ diff --git a/Task/Remove-duplicate-elements/UnixPipes/remove-duplicate-elements-2.unixpipes b/Task/Remove-duplicate-elements/UnixPipes/remove-duplicate-elements-2.unixpipes new file mode 100644 index 0000000000..0245442372 --- /dev/null +++ b/Task/Remove-duplicate-elements/UnixPipes/remove-duplicate-elements-2.unixpipes @@ -0,0 +1,7 @@ +bash$ # made uniq +bash$ printf '6\n2\n3\n6\n4\n2\n'|sort -nu +2 +3 +4 +6 +bash$ diff --git a/Task/Remove-duplicate-elements/Ursala/remove-duplicate-elements.ursala b/Task/Remove-duplicate-elements/Ursala/remove-duplicate-elements.ursala new file mode 100644 index 0000000000..f85b09003a --- /dev/null +++ b/Task/Remove-duplicate-elements/Ursala/remove-duplicate-elements.ursala @@ -0,0 +1,3 @@ +#cast %s + +example = |=hS& 'mississippi' diff --git a/Task/Remove-duplicate-elements/Vedit-macro-language/remove-duplicate-elements.vedit b/Task/Remove-duplicate-elements/Vedit-macro-language/remove-duplicate-elements.vedit new file mode 100644 index 0000000000..1b451cc6af --- /dev/null +++ b/Task/Remove-duplicate-elements/Vedit-macro-language/remove-duplicate-elements.vedit @@ -0,0 +1,2 @@ +Sort(0, File_Size) // sort the data +While(Replace("^(.*)\N\1$", "\1", REGEXP+BEGIN+NOERR)){} // remove duplicates diff --git a/Task/Remove-duplicate-elements/XPL0/remove-duplicate-elements.xpl0 b/Task/Remove-duplicate-elements/XPL0/remove-duplicate-elements.xpl0 new file mode 100644 index 0000000000..87cf561243 --- /dev/null +++ b/Task/Remove-duplicate-elements/XPL0/remove-duplicate-elements.xpl0 @@ -0,0 +1,24 @@ +code Text=12; \built-in routine to display a string of characters +string 0; \use zero-terminated strings (not MSb terminated) + +func StrLen(S); \Return number of characters in an ASCIIZ string +char S; +int I; +for I:= 0, -1>>1-1 do \(limit = 2,147,483,646 if 32 bit, or 32766 if 16 bit) + if S(I) = 0 then return I; + +func Unique(S); \Remove duplicate bytes from string +char S; +int I, J, K, L; +[L:= StrLen(S); \string length +for I:= 0 to L-1 do \for all characters in string... + for J:= I+1 to L-1 do \scan rest of string for duplicates + if S(I) = S(J) then \if duplicate then + [for K:= J+1 to L do \ shift rest of string down (including + S(K-1):= S(K); \ terminating zero) + L:= L-1 \ string is now one character shorter + ]; +return S; \return pointer to string +]; + +Text(0, Unique("Pack my box with five dozen liquor jugs.")) diff --git a/Task/Remove-lines-from-a-file/0DESCRIPTION b/Task/Remove-lines-from-a-file/0DESCRIPTION new file mode 100644 index 0000000000..7c34897a03 --- /dev/null +++ b/Task/Remove-lines-from-a-file/0DESCRIPTION @@ -0,0 +1,3 @@ +The task is to demonstrate how to remove a specific line or a number of lines from a file. This should be implemented as a routine that takes three parameters (filename, starting line, and the number of lines to be removed). For the purpose of this task, line numbers and the number of lines start at one, so to remove the first two lines from the file foobar.txt, the parameters should be: foobar.txt, 1, 2 + +Empty lines are considered and should still be counted, and if the specified line is empty, it should still be removed. An appropriate message should appear if an attempt is made to remove lines beyond the end of the file. diff --git a/Task/Remove-lines-from-a-file/1META.yaml b/Task/Remove-lines-from-a-file/1META.yaml new file mode 100644 index 0000000000..27fd5ba4e4 --- /dev/null +++ b/Task/Remove-lines-from-a-file/1META.yaml @@ -0,0 +1,3 @@ +--- +category: +- File handling diff --git a/Task/Remove-lines-from-a-file/AWK/remove-lines-from-a-file.awk b/Task/Remove-lines-from-a-file/AWK/remove-lines-from-a-file.awk new file mode 100644 index 0000000000..fe1aaebaf4 --- /dev/null +++ b/Task/Remove-lines-from-a-file/AWK/remove-lines-from-a-file.awk @@ -0,0 +1,43 @@ +# syntax: GAWK -f REMOVE_LINES_FROM_A_FILE.AWK +# show files after lines are removed: +# GAWK "FNR==1{print(FILENAME)};{print(FNR,$0)}" TEST1 TEST2 TEST3 +BEGIN { + build_test_data() + remove_lines("TEST0",1,1) + remove_lines("TEST1",3,4) + remove_lines("TEST2",9,3) + remove_lines("TEST3",11,1) + exit(errors+0) +} +function build_test_data( fn,i,j) { # create 3 files with 10 lines each + for (i=1; i<=3; i++) { + fn = "TEST" i + for (j=1; j<=10; j++) { + printf("line %d\n",j) >fn + } + close(fn) + } +} +function remove_lines(fn,start,number_of_lines, arr,fnr,i,n,rec,stop) { + stop = start + number_of_lines - 1 + while (getline rec 0) { # read file + fnr++ + if (fnr < start || fnr > stop) { + arr[++n] = rec + } + } + close(fn) + if (fnr == 0) { + printf("error: file %s not found\n",fn) + errors = 1 + return + } + for (i=1; i<=n; i++) { # write file + printf("%s\n",arr[i]) >fn + } + close(fn) + if (stop > fnr) { + printf("error: file %s trying to remove nonexistent lines\n",fn) + errors = 1 + } +} diff --git a/Task/Remove-lines-from-a-file/Ada/remove-lines-from-a-file.ada b/Task/Remove-lines-from-a-file/Ada/remove-lines-from-a-file.ada new file mode 100644 index 0000000000..c8b5396c8e --- /dev/null +++ b/Task/Remove-lines-from-a-file/Ada/remove-lines-from-a-file.ada @@ -0,0 +1,41 @@ +with Ada.Text_IO, Ada.Directories, Ada.Command_Line, Ada.IO_Exceptions; +use Ada.Text_IO; + +procedure Remove_Lines_From_File is + Temporary: constant String := ".tmp"; +begin + if Ada.Command_Line.Argument_Count /= 3 then + raise Constraint_Error; + end if; + declare + Filename: String := Ada.Command_Line.Argument(1); + First: Positive := Integer'Value(Ada.Command_Line.Argument(2)); + Last: Natural := Integer'Value(Ada.Command_Line.Argument(3)) + First - 1; + Input, Output: File_Type; + Line_Number: Positive := 1; + begin + Open(Input, In_File, Filename); -- open original file for reading + Create(Output, Out_File, Filename & Temporary); -- write to temp. file + while not End_Of_File(Input) loop + declare + Line: String := Get_Line(Input); + begin + if Line_Number < First or else Line_Number > Last then + Put_Line(Output, Line); + end if; + end; + Line_Number := Line_Number + 1; + end loop; + Close(Input); + Close(Output); + Ada.Directories.Rename(Old_Name => Filename & Temporary, + New_Name => Filename); + end; +exception + when Constraint_Error | Ada.IO_Exceptions.Name_Error => + Put_Line("usage: " & Ada.Command_Line.Command_Name & + " "); + Put_Line(" opens for reading and " & + "" & Temporary & " for temporary writing"); + Put_Line(" requires first > 0, length >= 0"); +end Remove_Lines_From_File; diff --git a/Task/Remove-lines-from-a-file/AutoHotkey/remove-lines-from-a-file.ahk b/Task/Remove-lines-from-a-file/AutoHotkey/remove-lines-from-a-file.ahk new file mode 100644 index 0000000000..d8744a4743 --- /dev/null +++ b/Task/Remove-lines-from-a-file/AutoHotkey/remove-lines-from-a-file.ahk @@ -0,0 +1,11 @@ +RemoveLines(filename, startingLine, numOfLines){ + Loop, Read, %filename% + if ( A_Index < StartingLine ) + || ( A_Index >= StartingLine + numOfLines ) + ret .= "`r`n" . A_LoopReadLine + FileDelete, % FileName + FileAppend, % SubStr(ret, 3), % FileName +} + +SetWorkingDir, % A_ScriptDir +RemoveLines("test.txt", 4, 3) diff --git a/Task/Remove-lines-from-a-file/C++/remove-lines-from-a-file.cpp b/Task/Remove-lines-from-a-file/C++/remove-lines-from-a-file.cpp new file mode 100644 index 0000000000..1491bbe734 --- /dev/null +++ b/Task/Remove-lines-from-a-file/C++/remove-lines-from-a-file.cpp @@ -0,0 +1,58 @@ +#include +#include +#include +#include +#include + +void deleteLines( const std::string & , int , int ) ; + +int main( int argc, char * argv[ ] ) { + if ( argc != 4 ) { + std::cerr << "Error! Invoke with !\n" ; + return 1 ; + } + std::string filename( argv[ 1 ] ) ; + int startfrom = atoi( argv[ 2 ] ) ; + int howmany = atoi( argv[ 3 ] ) ; + deleteLines ( filename , startfrom , howmany ) ; + return 0 ; +} + +void deleteLines( const std::string & filename , int start , int skip ) { + std::ifstream infile( filename.c_str( ) , std::ios::in ) ; + if ( infile.is_open( ) ) { + std::string line ; + std::list filelines ; + while ( infile ) { + getline( infile , line ) ; + filelines.push_back( line ) ; + } + infile.close( ) ; + if ( start > filelines.size( ) ) { + std::cerr << "Error! Starting to delete lines past the end of the file!\n" ; + return ; + } + if ( ( start + skip ) > filelines.size( ) ) { + std::cerr << "Error! Trying to delete lines past the end of the file!\n" ; + return ; + } + std::list::iterator deletebegin = filelines.begin( ) , deleteend ; + for ( int i = 1 ; i < start ; i++ ) + deletebegin++ ; + deleteend = deletebegin ; + for( int i = 0 ; i < skip ; i++ ) + deleteend++ ; + filelines.erase( deletebegin , deleteend ) ; + std::ofstream outfile( filename.c_str( ) , std::ios::out | std::ios::trunc ) ; + if ( outfile.is_open( ) ) { + for ( std::list::const_iterator sli = filelines.begin( ) ; + sli != filelines.end( ) ; sli++ ) + outfile << *sli << "\n" ; + } + outfile.close( ) ; + } + else { + std::cerr << "Error! Could not find file " << filename << " !\n" ; + return ; + } +} diff --git a/Task/Remove-lines-from-a-file/C/remove-lines-from-a-file.c b/Task/Remove-lines-from-a-file/C/remove-lines-from-a-file.c new file mode 100644 index 0000000000..346d046d5d --- /dev/null +++ b/Task/Remove-lines-from-a-file/C/remove-lines-from-a-file.c @@ -0,0 +1,61 @@ +#include +#include /* for atoi() and malloc() */ +#include /* for memmove() */ + +/* Conveniently print to standard error and exit nonzero. */ +#define ERROR(fmt, arg) return fprintf(stderr, fmt "\n", arg) + +int main(int argc, char **argv) +{ + FILE *fp; + char *buf; + size_t sz; + int start, count, lines = 1; + int dest = 0, src = 0, pos = -1; + + /* Initialization and sanity checks */ + if (argc != 4) + ERROR("Usage: %s ", argv[0]); + + if ((count = atoi(argv[3])) < 1) /* We're a no-op. */ + return 0; + + if ((start = atoi(argv[2])) < 1) + ERROR("Error: (%d) must be positive", start); + + if ((fp = fopen(argv[1], "r")) == NULL) + ERROR("No such file: %s", argv[1]); + + /* Determine filesize and allocate a buffer accordingly. */ + fseek(fp, 0, SEEK_END); + sz = ftell(fp); + buf = malloc(sz + 1); + rewind(fp); + + /* Fill the buffer, count lines, and remember a few important offsets. */ + while ((buf[++pos] = fgetc(fp)) != EOF) { + if (buf[pos] == '\n') { + ++lines; + if (lines == start) dest = pos + 1; + if (lines == start + count) src = pos + 1; + } + } + + /* We've been asked to do something weird; clean up and bail. */ + if (start + count > lines) { + free(buf); + fclose(fp); + ERROR("Error: invalid parameters for file with %d lines", --lines); + } + + /* Overwrite the lines to be deleted with the survivors. */ + memmove(buf + dest, buf + src, pos - src); + + /* Reopen the file and write back just enough of the buffer. */ + freopen(argv[1], "w", fp); + fwrite(buf, pos - src + dest, 1, fp); + + free(buf); + fclose(fp); + return 0; +} diff --git a/Task/Remove-lines-from-a-file/Common-Lisp/remove-lines-from-a-file.lisp b/Task/Remove-lines-from-a-file/Common-Lisp/remove-lines-from-a-file.lisp new file mode 100644 index 0000000000..b9bc6199a3 --- /dev/null +++ b/Task/Remove-lines-from-a-file/Common-Lisp/remove-lines-from-a-file.lisp @@ -0,0 +1,25 @@ +(defun remove-lines (filename start num) + (let ((tmp-filename (concatenate 'string filename ".tmp")) + (lines-omitted 0)) + ;; Open a temp file to write the result to + (with-open-file (out tmp-filename + :direction :output + :if-exists :supersede + :if-does-not-exist :create) + ;; Open the original file for reading + (with-open-file (in filename) + (loop + for line = (read-line in nil 'eof) + for i from 1 + until (eql line 'eof) + ;; Write the line to temp file if it is not in the omitted range + do (if (or (< i start) + (>= i (+ start num))) + (write-line line out) + (setf lines-omitted (1+ lines-omitted)))))) + ;; Swap in the temp file for the original + (delete-file filename) + (rename-file tmp-filename filename) + ;; Warn if line removal went past the end of the file + (when (< lines-omitted num) + (warn "End of file reached with only ~d lines removed." lines-omitted)))) diff --git a/Task/Remove-lines-from-a-file/D/remove-lines-from-a-file.d b/Task/Remove-lines-from-a-file/D/remove-lines-from-a-file.d new file mode 100644 index 0000000000..11fdb3e612 --- /dev/null +++ b/Task/Remove-lines-from-a-file/D/remove-lines-from-a-file.d @@ -0,0 +1,25 @@ +import std.stdio, std.file, std.string; + +void main() { + deleteLines("deleteline_test.txt", 1, 2); +} + +void deleteLines(string name, int start, int num) +in { + assert(start > 0, "Line counting must start at 1"); +} body { + start--; + + if (!exists(name) || !isFile(name)) + throw new FileException("File not found"); + + auto lines = readText(name).splitLines(); + if (lines.length < start + num) + throw new Exception("Can't delete lines past the end of file!"); + + auto f = File(name, "w"); + foreach (int i, line; lines) { + if (start > i || i >= start + num) + f.writeln(line); + } +} diff --git a/Task/Remove-lines-from-a-file/Go/remove-lines-from-a-file.go b/Task/Remove-lines-from-a-file/Go/remove-lines-from-a-file.go new file mode 100644 index 0000000000..121d6a49cd --- /dev/null +++ b/Task/Remove-lines-from-a-file/Go/remove-lines-from-a-file.go @@ -0,0 +1,72 @@ +package main + +import ( + "bytes" + "errors" + "fmt" + "io/ioutil" + "os" +) + +func main() { + if err := removeLines("foobar.txt", 1, 2); err != nil { + fmt.Println(err) + } +} + +func removeLines(fn string, start, n int) (err error) { + if start < 1 { + return errors.New("invalid request. line numbers start at 1.") + } + if n < 0 { + return errors.New("invalid request. negative number to remove.") + } + var f *os.File + if f, err = os.OpenFile(fn, os.O_RDWR, 0); err != nil { + return + } + defer func() { + if cErr := f.Close(); err == nil { + err = cErr + } + }() + var b []byte + if b, err = ioutil.ReadAll(f); err != nil { + return + } + cut, ok := skip(b, start-1) + if !ok { + return fmt.Errorf("less than %d lines", start) + } + if n == 0 { + return nil + } + tail, ok := skip(cut, n) + if !ok { + return fmt.Errorf("less than %d lines after line %d", n, start) + } + t := int64(len(b) - len(cut)) + if err = f.Truncate(t); err != nil { + return + } + if len(tail) > 0 { + _, err = f.WriteAt(tail, t) + } + return +} + +func skip(b []byte, n int) ([]byte, bool) { + for ; n > 0; n-- { + if len(b) == 0 { + return nil, false + } + x := bytes.IndexByte(b, '\n') + if x < 0 { + x = len(b) + } else { + x++ + } + b = b[x:] + } + return b, true +} diff --git a/Task/Remove-lines-from-a-file/Haskell/remove-lines-from-a-file.hs b/Task/Remove-lines-from-a-file/Haskell/remove-lines-from-a-file.hs new file mode 100644 index 0000000000..f437307e03 --- /dev/null +++ b/Task/Remove-lines-from-a-file/Haskell/remove-lines-from-a-file.hs @@ -0,0 +1,8 @@ +import System.Environment (getArgs) + +main = getArgs >>= (\[a, b, c] -> + do contents <- fmap lines $ readFile a + let b1 = read b :: Int + c1 = read c :: Int + putStr $ unlines $ concat [take (b1 - 1) contents, drop c1 $ drop b1 contents] + ) diff --git a/Task/Remove-lines-from-a-file/Icon/remove-lines-from-a-file.icon b/Task/Remove-lines-from-a-file/Icon/remove-lines-from-a-file.icon new file mode 100644 index 0000000000..075f9c1ed7 --- /dev/null +++ b/Task/Remove-lines-from-a-file/Icon/remove-lines-from-a-file.icon @@ -0,0 +1,18 @@ +procedure main() # remove lines + removelines("foo.bar",3,2) | stop("Failed to remove lines.") +end + +procedure removelines(fn,start,skip) + + f := open(fn,"r") | fail # open to read + every put(F := [],|read(f)) # file to list + close(f) + + if *F < start-1+skip then fail + every F[start - 1 + (1 to skip)] := &null # mark delete + + f := open(fn,"w") | fail # open to rewrite + every write(\!F) # write non-nulls + close(f) + return # done +end diff --git a/Task/Remove-lines-from-a-file/J/remove-lines-from-a-file-1.j b/Task/Remove-lines-from-a-file/J/remove-lines-from-a-file-1.j new file mode 100644 index 0000000000..c673219a01 --- /dev/null +++ b/Task/Remove-lines-from-a-file/J/remove-lines-from-a-file-1.j @@ -0,0 +1,6 @@ +removeLines=:4 :0 + 'count start'=. x + file=. boxxopen y + lines=. <;.2]1!:1 file + (;lines {~ <<< (start-1)+i.count) 1!:2 file +) diff --git a/Task/Remove-lines-from-a-file/J/remove-lines-from-a-file-2.j b/Task/Remove-lines-from-a-file/J/remove-lines-from-a-file-2.j new file mode 100644 index 0000000000..d738ac1259 --- /dev/null +++ b/Task/Remove-lines-from-a-file/J/remove-lines-from-a-file-2.j @@ -0,0 +1,10 @@ +$ cal >cal.txt +$ cat cal.txt + July 2011 +Su Mo Tu We Th Fr Sa + 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 diff --git a/Task/Remove-lines-from-a-file/J/remove-lines-from-a-file-3.j b/Task/Remove-lines-from-a-file/J/remove-lines-from-a-file-3.j new file mode 100644 index 0000000000..e4cc55060d --- /dev/null +++ b/Task/Remove-lines-from-a-file/J/remove-lines-from-a-file-3.j @@ -0,0 +1 @@ + 2 1 removeLines 'cal.txt' diff --git a/Task/Remove-lines-from-a-file/J/remove-lines-from-a-file-4.j b/Task/Remove-lines-from-a-file/J/remove-lines-from-a-file-4.j new file mode 100644 index 0000000000..e308c8a251 --- /dev/null +++ b/Task/Remove-lines-from-a-file/J/remove-lines-from-a-file-4.j @@ -0,0 +1,7 @@ +$ cat cal.txt + 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 diff --git a/Task/Remove-lines-from-a-file/Liberty-BASIC/remove-lines-from-a-file.liberty b/Task/Remove-lines-from-a-file/Liberty-BASIC/remove-lines-from-a-file.liberty new file mode 100644 index 0000000000..3691561504 --- /dev/null +++ b/Task/Remove-lines-from-a-file/Liberty-BASIC/remove-lines-from-a-file.liberty @@ -0,0 +1,20 @@ +call removeLines "foobar.txt", 1, 2 +end + +sub removeLines filename$, start, count + open filename$ for input as #in + open filename$ + ".tmp" for output as #out + lineCounter = 1 + firstAfterIgnored = start + count + while not(eof(#in)) + line input #in, s$ + if lineCounter < start or lineCounter >= firstAfterIgnored then + print #out, s$ + end if + lineCounter = lineCounter + 1 + wend + close #in + close #out + 'kill filename$ + 'name filename$ + ".tmp" as filename$ +end sub diff --git a/Task/Remove-lines-from-a-file/Lua/remove-lines-from-a-file.lua b/Task/Remove-lines-from-a-file/Lua/remove-lines-from-a-file.lua new file mode 100644 index 0000000000..4cf7170e62 --- /dev/null +++ b/Task/Remove-lines-from-a-file/Lua/remove-lines-from-a-file.lua @@ -0,0 +1,26 @@ +function remove( filename, starting_line, num_lines ) + local fp = io.open( filename, "r" ) + if fp == nil then return nil end + + content = {} + i = 1; + for line in fp:lines() do + if i < starting_line or i >= starting_line + num_lines then + content[#content+1] = line + end + i = i + 1 + end + + if i > starting_line and i < starting_line + num_lines then + print( "Warning: Tried to remove lines after EOF." ) + end + + fp:close() + fp = io.open( filename, "w+" ) + + for i = 1, #content do + fp:write( string.format( "%s\n", content[i] ) ) + end + + fp:close() +end diff --git a/Task/Remove-lines-from-a-file/OCaml/remove-lines-from-a-file.ocaml b/Task/Remove-lines-from-a-file/OCaml/remove-lines-from-a-file.ocaml new file mode 100644 index 0000000000..c78a8f67e8 --- /dev/null +++ b/Task/Remove-lines-from-a-file/OCaml/remove-lines-from-a-file.ocaml @@ -0,0 +1,33 @@ +let input_line_opt ic = + try Some (input_line ic) + with End_of_file -> None + +let delete_lines filename start skip = + if start < 1 || skip < 1 then + invalid_arg "delete_lines"; + let tmp_file = filename ^ ".tmp" in + let ic = open_in filename + and oc = open_out tmp_file in + let until = start + skip - 1 in + let rec aux i = + match input_line_opt ic with + | Some line -> + if i < start || i > until + then (output_string oc line; output_char oc '\n'); + aux (succ i) + | None -> + close_in ic; + close_out oc; + Sys.remove filename; + Sys.rename tmp_file filename + in + aux 1 + +let usage () = + Printf.printf "Usage:\n%s \n" Sys.argv.(0); + exit 0 + +let () = + if Array.length Sys.argv < 4 then usage (); + delete_lines + Sys.argv.(1) (int_of_string Sys.argv.(2)) (int_of_string Sys.argv.(3)) diff --git a/Task/Remove-lines-from-a-file/Perl-6/remove-lines-from-a-file.pl6 b/Task/Remove-lines-from-a-file/Perl-6/remove-lines-from-a-file.pl6 new file mode 100644 index 0000000000..9b4b916acd --- /dev/null +++ b/Task/Remove-lines-from-a-file/Perl-6/remove-lines-from-a-file.pl6 @@ -0,0 +1,6 @@ +sub MAIN ($filename, $beg, $len) { + my @lines = split /^^/, slurp $filename; + unlink $filename; # or rename + splice(@lines,$beg,$len) == $len or warn "Too few lines"; + spurt $filename, @lines; +} diff --git a/Task/Remove-lines-from-a-file/Perl/remove-lines-from-a-file-1.pl b/Task/Remove-lines-from-a-file/Perl/remove-lines-from-a-file-1.pl new file mode 100644 index 0000000000..caa956dd82 --- /dev/null +++ b/Task/Remove-lines-from-a-file/Perl/remove-lines-from-a-file-1.pl @@ -0,0 +1,2 @@ +#!/usr/bin/perl -n -s -i +print unless $. >= $from && $. <= $to; diff --git a/Task/Remove-lines-from-a-file/Perl/remove-lines-from-a-file-2.pl b/Task/Remove-lines-from-a-file/Perl/remove-lines-from-a-file-2.pl new file mode 100644 index 0000000000..5deff2cab2 --- /dev/null +++ b/Task/Remove-lines-from-a-file/Perl/remove-lines-from-a-file-2.pl @@ -0,0 +1,27 @@ +#!/usr/bin/perl -w +use strict ; +use Tie::File ; + +sub deletelines { + my $arguments = shift ; + my( $file , $startfrom , $howmany ) = @{$arguments} ; + tie my @lines , 'Tie::File' , $file or die "Can't find file $file!\n" ; + my $nrecs = @lines ; + if ( $startfrom > $nrecs ) { + print "Error! Starting to delete lines past the end of the file!\n" ; + return ; + } + if ( ( $startfrom + $howmany ) > $nrecs ) { + print "Error! Trying to delete lines past the end of the file!\n" ; + return ; + } + splice @lines , $startfrom - 1 , $howmany ; + untie @lines ; +} + +if ( @ARGV != 3 ) { + print "Error! Invoke with deletelines !\n" ; + exit( 1 ) ; +} + +deletelines( \@ARGV ) ; diff --git a/Task/Remove-lines-from-a-file/PicoLisp/remove-lines-from-a-file.l b/Task/Remove-lines-from-a-file/PicoLisp/remove-lines-from-a-file.l new file mode 100644 index 0000000000..51c5295341 --- /dev/null +++ b/Task/Remove-lines-from-a-file/PicoLisp/remove-lines-from-a-file.l @@ -0,0 +1,7 @@ +(de deleteLines (File Start Cnt) + (let L (in File (make (until (eof) (link (line))))) + (if (> (+ (dec 'Start) Cnt) (length L)) + (quit "Not enough lines") + (out File + (mapc prinl (cut Start 'L)) + (mapc prinl (nth L (inc Cnt))) ) ) ) ) diff --git a/Task/Remove-lines-from-a-file/PowerBASIC/remove-lines-from-a-file.powerbasic b/Task/Remove-lines-from-a-file/PowerBASIC/remove-lines-from-a-file.powerbasic new file mode 100644 index 0000000000..a90d2dc7b3 --- /dev/null +++ b/Task/Remove-lines-from-a-file/PowerBASIC/remove-lines-from-a-file.powerbasic @@ -0,0 +1,37 @@ +#DIM ALL + +FUNCTION PBMAIN () AS LONG + DIM filespec AS STRING, linein AS STRING + DIM linecount AS LONG, L0 AS LONG, ok AS LONG + + filespec = DIR$(COMMAND$(1)) + WHILE LEN(filespec) + linecount = 0: ok = 0 + OPEN filespec FOR INPUT AS 1 + OPEN filespec & ".tmp" FOR OUTPUT AS 2 + DO UNTIL EOF(1) + LINE INPUT #1, linein + INCR linecount + IF VAL(COMMAND$(2)) <> linecount THEN + PRINT #2, linein + ELSE + ok = -1 + FOR L0 = 2 TO VAL(COMMAND$(3)) + IF EOF(1) THEN + ok = 1 + PRINT "Tried to remove beyond the end of "; filespec + EXIT DO + END IF + LINE INPUT #1, linein + NEXT + END IF + LOOP + IF 0 = ok THEN + PRINT "Lines to remove are beyond the end of "; filespec + ELSEIF -1 = ok THEN + PRINT filespec; ": done" + END IF + CLOSE + filespec = DIR$ + WEND +END FUNCTION diff --git a/Task/Remove-lines-from-a-file/Python/remove-lines-from-a-file.py b/Task/Remove-lines-from-a-file/Python/remove-lines-from-a-file.py new file mode 100644 index 0000000000..da1912ebf4 --- /dev/null +++ b/Task/Remove-lines-from-a-file/Python/remove-lines-from-a-file.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python + +import fileinput, sys + +fname, start, count = sys.argv[1:4] +start, count = int(start), int(count) + +for line in fileinput.input(fname, inplace=1, backup='.orig'): + if start <= fileinput.lineno() < start + count: + pass + else: + print line[:-1] +fileinput.close() diff --git a/Task/Remove-lines-from-a-file/REXX/remove-lines-from-a-file.rexx b/Task/Remove-lines-from-a-file/REXX/remove-lines-from-a-file.rexx new file mode 100644 index 0000000000..05e72e9514 --- /dev/null +++ b/Task/Remove-lines-from-a-file/REXX/remove-lines-from-a-file.rexx @@ -0,0 +1,24 @@ +/*REXX program to read a specified file and delete specified record(s). */ +parse arg iFID ',' at ',' many /*input FID, del start, how many.*/ +if iFID='' then call er "no input fileID specified." +if at='' then call er "no start number specified." +if many='' then many=1 /*Not specified? Assume 1 line.*/ +stop=at+many-1 /*calculate high end of deletes. */ +oFID=iFID'.out' /*the name of the output file. */ +w=0 + do j=1 while lines(iFID)\==0 /*J is the line number being read*/ + x=linein(iFID) /*read a line from the input file*/ + if j>=at & j<=stop then iterate /*if in the range, then ignore it*/ + call lineout oFID,x; w=w+1 /*write line, bump the write cnt.*/ + end +j=j-1 +if j= start and num > 0 + num -= 1 + else + tmp.write line + end + end + tmp.close + STDERR.puts "Warning: End of file encountered before all lines removed" if num > 0 + FileUtils.copy(tmp.path, filename) + tmp.unlink +end diff --git a/Task/Remove-lines-from-a-file/Ruby/remove-lines-from-a-file-2.rb b/Task/Remove-lines-from-a-file/Ruby/remove-lines-from-a-file-2.rb new file mode 100644 index 0000000000..2cbbd6c7c8 --- /dev/null +++ b/Task/Remove-lines-from-a-file/Ruby/remove-lines-from-a-file-2.rb @@ -0,0 +1,19 @@ +def setup(start, remove) + puts "remove #{remove} lines starting at line #{start}" + File.open($filename, "w") {|fh| (1..5).each {|i| fh.puts i}} + puts "before:\n" + File.read($filename) +end + +def teardown + puts "after:\n" + File.read($filename) + puts "" + File.unlink($filename) +end + +$filename = "test.file" +start = 2 +[2, 6].each do |remove| + setup(start, remove) + remove_lines $filename, start, remove + teardown +end diff --git a/Task/Remove-lines-from-a-file/Run-BASIC/remove-lines-from-a-file.run b/Task/Remove-lines-from-a-file/Run-BASIC/remove-lines-from-a-file.run new file mode 100644 index 0000000000..4e85870bc4 --- /dev/null +++ b/Task/Remove-lines-from-a-file/Run-BASIC/remove-lines-from-a-file.run @@ -0,0 +1,14 @@ +fileName$ = "aFile.txt" +startLine = 100 +lineCount = 10 + +open filename$ for input as #in +open filename$ ; "_tmp" for output as #out + +while not(eof(#in)) + lineNum = lineNum + 1 + line input #in, a$ + if lineNum < startLine or lineNum >= startLine + lineCount then print #out, a$ +wend +close #in +close #out diff --git a/Task/Remove-lines-from-a-file/Seed7/remove-lines-from-a-file.seed7 b/Task/Remove-lines-from-a-file/Seed7/remove-lines-from-a-file.seed7 new file mode 100644 index 0000000000..f436594eb0 --- /dev/null +++ b/Task/Remove-lines-from-a-file/Seed7/remove-lines-from-a-file.seed7 @@ -0,0 +1,31 @@ +$ include "seed7_05.s7i"; + include "osfiles.s7i"; + +const proc: removeLines (in string: fileName, in integer: start, in integer: count) is func + local + var file: inFile is STD_NULL; + var file: outFile is STD_NULL; + var integer: lineNumber is 1; + var string: line is ""; + begin + inFile := open(fileName, "r"); + outFile := open(fileName & ".tmp", "w"); + while hasNext(inFile) do + line := getln(inFile); + if lineNumber < start or lineNumber >= start + count then + writeln(outFile, line); + end if; + incr(lineNumber); + end while; + close(inFile); + close(outFile); + removeFile(fileName); + moveFile(fileName & ".tmp", fileName); + end func; + +const proc: main is func + begin + if length(argv(PROGRAM)) = 3 then + removeLines(argv(PROGRAM)[1], integer parse (argv(PROGRAM)[2]), integer parse (argv(PROGRAM)[3])); + end if; + end func; diff --git a/Task/Remove-lines-from-a-file/TUSCRIPT/remove-lines-from-a-file.tuscript b/Task/Remove-lines-from-a-file/TUSCRIPT/remove-lines-from-a-file.tuscript new file mode 100644 index 0000000000..b7cf41045d --- /dev/null +++ b/Task/Remove-lines-from-a-file/TUSCRIPT/remove-lines-from-a-file.tuscript @@ -0,0 +1,26 @@ +$$! input=testfile,begnr=3,endnr=4 +$$ MODE TUSCRIPT +- CREATE inputfile +ERROR/STOP CREATE (input,FDF-o,-std-) +FILE/ERASE $input + LOOP n=1,9 + content=CONCAT ("line",n) + DATA {content} + ENDLOOP +ENDFILE + +- CREATE outputfile +output="outputfile" + +ERROR/STOP CREATE (output,fdf-o,-std-) +ACCESS q: READ/RECORDS/utf8 $input L,line +ACCESS z: WRITE/RECORDS/utf8 $output L,line +PRINT "content: of output-file" +LOOP/9999 +READ/NEXT/EXIT q +IF (begnr<=L&&endnr>=L) CYCLE +PRINT line +WRITE z +ENDLOOP +ENDACCESS/PRINT q +ENDACCESS/PRINT z diff --git a/Task/Remove-lines-from-a-file/Tcl/remove-lines-from-a-file.tcl b/Task/Remove-lines-from-a-file/Tcl/remove-lines-from-a-file.tcl new file mode 100644 index 0000000000..4a8086542e --- /dev/null +++ b/Task/Remove-lines-from-a-file/Tcl/remove-lines-from-a-file.tcl @@ -0,0 +1,13 @@ +proc removeLines {fileName startLine count} { + # Work out range to remove + set from [expr {$startLine - 1}] + set to [expr {$startLine + $count - 2}] + # Read the lines + set f [open $fileName] + set lines [split [read $f] "\n"] + close $f + # Write the lines back out, without removed range + set f [open $fileName w] + puts -nonewline $f [join [lreplace $lines $from $to] "\n"] + close $f +} diff --git a/Task/Remove-lines-from-a-file/UNIX-Shell/remove-lines-from-a-file-1.sh b/Task/Remove-lines-from-a-file/UNIX-Shell/remove-lines-from-a-file-1.sh new file mode 100644 index 0000000000..9aab23dcea --- /dev/null +++ b/Task/Remove-lines-from-a-file/UNIX-Shell/remove-lines-from-a-file-1.sh @@ -0,0 +1,15 @@ +#!/bin/sh +error() { + echo "$*" + exit 1 +} + +[ $# -ne 3 ] && error "Incorrect number of parameters" + +file=$1 +start=$2 +end=$3 + +[ -f $file ] || error "$file does not exist" + +sed $start,${end}d $file >/tmp/$$ && mv /tmp/$$ $file diff --git a/Task/Remove-lines-from-a-file/UNIX-Shell/remove-lines-from-a-file-2.sh b/Task/Remove-lines-from-a-file/UNIX-Shell/remove-lines-from-a-file-2.sh new file mode 100644 index 0000000000..d9297662af --- /dev/null +++ b/Task/Remove-lines-from-a-file/UNIX-Shell/remove-lines-from-a-file-2.sh @@ -0,0 +1 @@ +sed -i $start,${end}d $file diff --git a/Task/Rename-a-file/0DESCRIPTION b/Task/Rename-a-file/0DESCRIPTION new file mode 100644 index 0000000000..9fe600f18f --- /dev/null +++ b/Task/Rename-a-file/0DESCRIPTION @@ -0,0 +1 @@ +In this task, the job is to rename the file called "input.txt" into "output.txt" and a directory called "docs" into "mydocs". This should be done twice: once "here", i.e. in the current working directory and once in the filesystem root. diff --git a/Task/Rename-a-file/1META.yaml b/Task/Rename-a-file/1META.yaml new file mode 100644 index 0000000000..40458d9f21 --- /dev/null +++ b/Task/Rename-a-file/1META.yaml @@ -0,0 +1,2 @@ +--- +note: File System Operations diff --git a/Task/Rename-a-file/ALGOL-68/rename-a-file.alg b/Task/Rename-a-file/ALGOL-68/rename-a-file.alg new file mode 100644 index 0000000000..18db7fdbef --- /dev/null +++ b/Task/Rename-a-file/ALGOL-68/rename-a-file.alg @@ -0,0 +1,22 @@ +main:( + PROC rename = (STRING source name, dest name)INT: + BEGIN + FILE actual file; + INT errno = open(actual file, source name, stand back channel); + IF errno NE 0 THEN + errno + ELSE + IF reidf possible(actual file) THEN + reidf(actual file, dest name); # change the identification of the book # + errno + ELSE + close(actual file); + -1 + FI + FI + END; + rename("input.txt", "output.txt"); + rename("/input.txt", "/output.txt"); + rename("docs", "mydocs"); + rename("/docs", "/mydocs") +) diff --git a/Task/Rename-a-file/AWK/rename-a-file.awk b/Task/Rename-a-file/AWK/rename-a-file.awk new file mode 100644 index 0000000000..a9a86652f7 --- /dev/null +++ b/Task/Rename-a-file/AWK/rename-a-file.awk @@ -0,0 +1,4 @@ +$ awk 'BEGIN{system("mv input.txt output.txt")}' +$ awk 'BEGIN{system("mv docs mydocs")}' +$ awk 'BEGIN{system("mv /input.txt /output.txt")}' +$ awk 'BEGIN{system("mv docs mydocs")}' diff --git a/Task/Rename-a-file/Ada/rename-a-file.ada b/Task/Rename-a-file/Ada/rename-a-file.ada new file mode 100644 index 0000000000..1514d8732e --- /dev/null +++ b/Task/Rename-a-file/Ada/rename-a-file.ada @@ -0,0 +1,6 @@ +with Ada.Directories; use Ada.Directories; + ... +Rename ("input.txt", "output.txt"); +Rename ("docs", "mydocs"); +Rename ("/input.txt", "/output.txt"); +Rename ("/docs", "/mydocs"); diff --git a/Task/Rename-a-file/AutoHotkey/rename-a-file.ahk b/Task/Rename-a-file/AutoHotkey/rename-a-file.ahk new file mode 100644 index 0000000000..7e579aa615 --- /dev/null +++ b/Task/Rename-a-file/AutoHotkey/rename-a-file.ahk @@ -0,0 +1 @@ +FileMove, oldname, newname diff --git a/Task/Rename-a-file/BASIC/rename-a-file-1.basic b/Task/Rename-a-file/BASIC/rename-a-file-1.basic new file mode 100644 index 0000000000..ee9a114a60 --- /dev/null +++ b/Task/Rename-a-file/BASIC/rename-a-file-1.basic @@ -0,0 +1,4 @@ +NAME "input.txt" AS "output.txt" +NAME "\input.txt" AS "\output.txt" +NAME "docs" AS "mydocs" +NAME "\docs" AS "\mydocs" diff --git a/Task/Rename-a-file/BASIC/rename-a-file-2.basic b/Task/Rename-a-file/BASIC/rename-a-file-2.basic new file mode 100644 index 0000000000..c60d81dc8a --- /dev/null +++ b/Task/Rename-a-file/BASIC/rename-a-file-2.basic @@ -0,0 +1 @@ +RENAME INPUT.TXT,OUTPUT.TXT diff --git a/Task/Rename-a-file/BASIC/rename-a-file-3.basic b/Task/Rename-a-file/BASIC/rename-a-file-3.basic new file mode 100644 index 0000000000..81f668c7ee --- /dev/null +++ b/Task/Rename-a-file/BASIC/rename-a-file-3.basic @@ -0,0 +1 @@ +10 PRINT CHR$ (4)"RENAME INPUT.TXT,OUTPUT.TXT" diff --git a/Task/Rename-a-file/BASIC/rename-a-file-4.basic b/Task/Rename-a-file/BASIC/rename-a-file-4.basic new file mode 100644 index 0000000000..78cfad1ada --- /dev/null +++ b/Task/Rename-a-file/BASIC/rename-a-file-4.basic @@ -0,0 +1,5 @@ +10 PRINT CHR$ (4)"RENAME INPUT.TXT,OUTPUT.TXT" +20 PRINT CHR$ (4)"RENAME DOCS,MYDOCS" +30 PRINT CHR$ (4)"PREFIX /" +40 PRINT CHR$ (4)"RENAME INPUT.TXT,OUTPUT.TXT" +50 PRINT CHR$ (4)"RENAME DOCS,MYDOCS" diff --git a/Task/Rename-a-file/BBC-BASIC/rename-a-file-1.bbc b/Task/Rename-a-file/BBC-BASIC/rename-a-file-1.bbc new file mode 100644 index 0000000000..d86640d67f --- /dev/null +++ b/Task/Rename-a-file/BBC-BASIC/rename-a-file-1.bbc @@ -0,0 +1,4 @@ + *RENAME input.txt output.txt + *RENAME \input.txt \output.txt + *RENAME docs. mydocs. + *RENAME \docs. \mydocs. diff --git a/Task/Rename-a-file/BBC-BASIC/rename-a-file-2.bbc b/Task/Rename-a-file/BBC-BASIC/rename-a-file-2.bbc new file mode 100644 index 0000000000..40d79f90da --- /dev/null +++ b/Task/Rename-a-file/BBC-BASIC/rename-a-file-2.bbc @@ -0,0 +1,4 @@ + OSCLI "RENAME input.txt output.txt" + OSCLI "RENAME \input.txt \output.txt" + OSCLI "RENAME docs. mydocs." + OSCLI "RENAME \docs. \mydocs." diff --git a/Task/Rename-a-file/Batch-File/rename-a-file.bat b/Task/Rename-a-file/Batch-File/rename-a-file.bat new file mode 100644 index 0000000000..2d869fd7ea --- /dev/null +++ b/Task/Rename-a-file/Batch-File/rename-a-file.bat @@ -0,0 +1,4 @@ +ren input.txt output.txt +ren \input.txt output.txt +ren docs mydocs +ren \docs mydocs diff --git a/Task/Rename-a-file/Bracmat/rename-a-file.bracmat b/Task/Rename-a-file/Bracmat/rename-a-file.bracmat new file mode 100644 index 0000000000..a049779bfc --- /dev/null +++ b/Task/Rename-a-file/Bracmat/rename-a-file.bracmat @@ -0,0 +1,4 @@ +ren$("input.txt"."output.txt") { 'ren' is based on standard C function 'rename()' } +ren$(docs.mydocs) { No quotes needed: names don't contain dots or colons. } +ren$("d:\\input.txt"."d:\\output.txt") { Backslash is escape character, so we need to escape it. } +ren$(@"d:\docs".@"d:\mydocs") { @ used as syntactic sugar as in C# for inhibiting escape. } diff --git a/Task/Rename-a-file/C++/rename-a-file-1.cpp b/Task/Rename-a-file/C++/rename-a-file-1.cpp new file mode 100644 index 0000000000..1e9d8ba069 --- /dev/null +++ b/Task/Rename-a-file/C++/rename-a-file-1.cpp @@ -0,0 +1,10 @@ +#include + +int main() +{ + std::rename("input.txt", "output.txt"); + std::rename("docs", "mydocs"); + std::rename("/input.txt", "/output.txt"); + std::rename("/docs", "/mydocs"); + return 0; +} diff --git a/Task/Rename-a-file/C++/rename-a-file-2.cpp b/Task/Rename-a-file/C++/rename-a-file-2.cpp new file mode 100644 index 0000000000..4e333ebd64 --- /dev/null +++ b/Task/Rename-a-file/C++/rename-a-file-2.cpp @@ -0,0 +1,18 @@ +#include "boost/filesystem.hpp" + +int main() +{ + boost::filesystem::rename( + boost::filesystem::path("input.txt"), + boost::filesystem::path("output.txt")); + boost::filesystem::rename( + boost::filesystem::path("docs"), + boost::filesystem::path("mydocs")); + boost::filesystem::rename( + boost::filesystem::path("/input.txt"), + boost::filesystem::path("/output.txt")); + boost::filesystem::rename( + boost::filesystem::path("/docs"), + boost::filesystem::path("/mydocs"));*/ + return 0; +} diff --git a/Task/Rename-a-file/C-sharp/rename-a-file.cs b/Task/Rename-a-file/C-sharp/rename-a-file.cs new file mode 100644 index 0000000000..fc36774acd --- /dev/null +++ b/Task/Rename-a-file/C-sharp/rename-a-file.cs @@ -0,0 +1,12 @@ +using System; +using System.IO; + +class Program { + static void Main(string[] args) { + File.Move("input.txt","output.txt"); + File.Move(@"\input.txt",@"\output.txt"); + + Directory.Move("docs","mydocs"); + Directory.Move(@"\docs",@"\mydocs"); + } +} diff --git a/Task/Rename-a-file/C/rename-a-file.c b/Task/Rename-a-file/C/rename-a-file.c new file mode 100644 index 0000000000..09a32251bb --- /dev/null +++ b/Task/Rename-a-file/C/rename-a-file.c @@ -0,0 +1,10 @@ +#include + +int main() +{ + rename("input.txt", "output.txt"); + rename("docs", "mydocs"); + rename("/input.txt", "/output.txt"); + rename("/docs", "/mydocs"); + return 0; +} diff --git a/Task/Rename-a-file/Clojure/rename-a-file.clj b/Task/Rename-a-file/Clojure/rename-a-file.clj new file mode 100644 index 0000000000..eab5125ab3 --- /dev/null +++ b/Task/Rename-a-file/Clojure/rename-a-file.clj @@ -0,0 +1,11 @@ +(import '(java.io File)) + +(.renameTo (File. "input.txt") (File. "output.txt")) +(.renameTo (File. "docs") (File. "mydocs")) + +(.renameTo + (File. (str (File/separator) "input.txt")) + (File. (str (File/separator) "output.txt"))) +(.renameTo + (File. (str (File/separator) "docs")) + (File. (str (File/separator) "mydocs"))) diff --git a/Task/Rename-a-file/Common-Lisp/rename-a-file.lisp b/Task/Rename-a-file/Common-Lisp/rename-a-file.lisp new file mode 100644 index 0000000000..46e9e19d86 --- /dev/null +++ b/Task/Rename-a-file/Common-Lisp/rename-a-file.lisp @@ -0,0 +1,4 @@ +(rename-file "input.txt" "output.txt") +(rename-file "docs" "mydocs") +(rename-file "/input.txt" "/output.txt") +(rename-file "/docs" "/mydocs") diff --git a/Task/Rename-a-file/D/rename-a-file.d b/Task/Rename-a-file/D/rename-a-file.d new file mode 100644 index 0000000000..5e36162065 --- /dev/null +++ b/Task/Rename-a-file/D/rename-a-file.d @@ -0,0 +1,4 @@ +std.file.rename("input.txt","output.txt"); +std.file.rename("/input.txt","/output.txt"); +std.file.rename("docs","mydocs"); +std.file.rename("/docs","/mydocs"); diff --git a/Task/Rename-a-file/DCL/rename-a-file.dcl b/Task/Rename-a-file/DCL/rename-a-file.dcl new file mode 100644 index 0000000000..6a9aa4daa5 --- /dev/null +++ b/Task/Rename-a-file/DCL/rename-a-file.dcl @@ -0,0 +1,4 @@ +rename input.txt output.txt +rename docs.dir mydocs.dir +rename [000000]input.txt [000000]output.txt +rename [000000]docs.dir [000000]mydocs.dir diff --git a/Task/Rename-a-file/Delphi/rename-a-file.delphi b/Task/Rename-a-file/Delphi/rename-a-file.delphi new file mode 100644 index 0000000000..b7c882c3ec --- /dev/null +++ b/Task/Rename-a-file/Delphi/rename-a-file.delphi @@ -0,0 +1,14 @@ +program RenameFile; + +{$APPTYPE CONSOLE} + +uses SysUtils; + +begin + SysUtils.RenameFile('input.txt', 'output.txt'); + SysUtils.RenameFile('\input.txt', '\output.txt'); + + // RenameFile works for both files and folders + SysUtils.RenameFile('docs', 'MyDocs'); + SysUtils.RenameFile('\docs', '\MyDocs'); +end. diff --git a/Task/Rename-a-file/E/rename-a-file.e b/Task/Rename-a-file/E/rename-a-file.e new file mode 100644 index 0000000000..986a749e27 --- /dev/null +++ b/Task/Rename-a-file/E/rename-a-file.e @@ -0,0 +1,4 @@ +for where in [, ] { + where["input.txt"].renameTo(where["output.txt"], null) + where["docs"].renameTo(where["mydocs"], null) +} diff --git a/Task/Rename-a-file/Erlang/rename-a-file.erl b/Task/Rename-a-file/Erlang/rename-a-file.erl new file mode 100644 index 0000000000..b4566485c0 --- /dev/null +++ b/Task/Rename-a-file/Erlang/rename-a-file.erl @@ -0,0 +1 @@ +file:rename("input.txt","output.txt"). diff --git a/Task/Rename-a-file/Factor/rename-a-file.factor b/Task/Rename-a-file/Factor/rename-a-file.factor new file mode 100644 index 0000000000..f09711da13 --- /dev/null +++ b/Task/Rename-a-file/Factor/rename-a-file.factor @@ -0,0 +1,3 @@ +"" "/" [ + [ "input.txt" "output.txt" move-file "docs" "mydocs" move-file ] with-directory +] bi@ diff --git a/Task/Rename-a-file/Fantom/rename-a-file.fantom b/Task/Rename-a-file/Fantom/rename-a-file.fantom new file mode 100644 index 0000000000..f6cb2e3874 --- /dev/null +++ b/Task/Rename-a-file/Fantom/rename-a-file.fantom @@ -0,0 +1,12 @@ +class Rename +{ + public static Void main () + { + // rename file/dir in current directory + File.rename("input.txt".toUri).rename("output.txt") + File.rename("docs/".toUri).rename("mydocs/") + // rename file/dir in root directory + File.rename("/input.txt".toUri).rename("/output.txt") + File.rename("/docs/".toUri).rename("/mydocs/") + } +} diff --git a/Task/Rename-a-file/Forth/rename-a-file.fth b/Task/Rename-a-file/Forth/rename-a-file.fth new file mode 100644 index 0000000000..152fd1dcea --- /dev/null +++ b/Task/Rename-a-file/Forth/rename-a-file.fth @@ -0,0 +1,2 @@ + s" input.txt" s" output.txt" rename-file throw +s" /input.txt" s" /output.txt" rename-file throw diff --git a/Task/Rename-a-file/Fortran/rename-a-file.f b/Task/Rename-a-file/Fortran/rename-a-file.f new file mode 100644 index 0000000000..c8586d163f --- /dev/null +++ b/Task/Rename-a-file/Fortran/rename-a-file.f @@ -0,0 +1,6 @@ + PROGRAM EX_RENAME + CALL RENAME('input.txt','output.txt') + CALL RENAME('docs','mydocs') + CALL RENAME('/input.txt','/output.txt') + CALL RENAME('/docs','/mydocs') + END diff --git a/Task/Rename-a-file/Go/rename-a-file.go b/Task/Rename-a-file/Go/rename-a-file.go new file mode 100644 index 0000000000..0433193be8 --- /dev/null +++ b/Task/Rename-a-file/Go/rename-a-file.go @@ -0,0 +1,9 @@ +package main +import "os" + +func main() { + os.Rename("input.txt", "output.txt") + os.Rename("docs", "mydocs") + os.Rename("/input.txt", "/output.txt") + os.Rename("/docs", "/mydocs") +} diff --git a/Task/Rename-a-file/Groovy/rename-a-file-1.groovy b/Task/Rename-a-file/Groovy/rename-a-file-1.groovy new file mode 100644 index 0000000000..ac181f5315 --- /dev/null +++ b/Task/Rename-a-file/Groovy/rename-a-file-1.groovy @@ -0,0 +1,5 @@ +['input.txt':'output.txt', 'docs':'mydocs'].each { src, dst -> + ['.', ''].each { dir -> + new File("$dir/$src").renameTo(new File("$dir/$dst")) + } +} diff --git a/Task/Rename-a-file/Groovy/rename-a-file-2.groovy b/Task/Rename-a-file/Groovy/rename-a-file-2.groovy new file mode 100644 index 0000000000..3a837510e7 --- /dev/null +++ b/Task/Rename-a-file/Groovy/rename-a-file-2.groovy @@ -0,0 +1,5 @@ +['input.txt':'output.txt', 'docs':'mydocs'].each { src, dst -> + ['.', ''].each { dir -> + new AntBuilder().move(file:"$dir/$src", toFile:"$dir/$dst") + } +} diff --git a/Task/Rename-a-file/Haskell/rename-a-file.hs b/Task/Rename-a-file/Haskell/rename-a-file.hs new file mode 100644 index 0000000000..48e5f0e304 --- /dev/null +++ b/Task/Rename-a-file/Haskell/rename-a-file.hs @@ -0,0 +1,8 @@ +import System.IO +import System.Directory + +main = do + renameFile "input.txt" "output.txt" + renameDirectory "docs" "mydocs" + renameFile "/input.txt" "/output.txt" + renameDirectory "/docs" "/mydocs" diff --git a/Task/Rename-a-file/HicEst/rename-a-file.hicest b/Task/Rename-a-file/HicEst/rename-a-file.hicest new file mode 100644 index 0000000000..0e4da84971 --- /dev/null +++ b/Task/Rename-a-file/HicEst/rename-a-file.hicest @@ -0,0 +1,7 @@ +WRITE(FIle='input.txt', REName='.\output.txt') +SYSTEM(DIR='E:\HicEst\Rosetta') +WRITE(FIle='.\docs', REName='.\mydocs') + +WRITE(FIle='\input.txt', REName='\output.txt') +SYSTEM(DIR='\') +WRITE(FIle='\docs', REName='\mydocs') diff --git a/Task/Rename-a-file/Icon/rename-a-file.icon b/Task/Rename-a-file/Icon/rename-a-file.icon new file mode 100644 index 0000000000..8d5fabeedd --- /dev/null +++ b/Task/Rename-a-file/Icon/rename-a-file.icon @@ -0,0 +1,4 @@ +every dir := !["./","/"] do { + rename(f := dir || "input.txt", dir || "output.txt") |stop("failure for file rename ",f) + rename(f := dir || "docs", dir || "mydocs") |stop("failure for directory rename ",f) + } diff --git a/Task/Rename-a-file/Io/rename-a-file.io b/Task/Rename-a-file/Io/rename-a-file.io new file mode 100644 index 0000000000..c2b41026b4 --- /dev/null +++ b/Task/Rename-a-file/Io/rename-a-file.io @@ -0,0 +1,15 @@ +// rename file in current directory +f := File with("input.txt") +f moveTo("output.txt") + +// rename file in root directory +f := File with("/input.txt") +f moveTo("/output.txt") + +// rename directory in current directory +d := Directory with("docs") +d moveTo("mydocs") + +// rename directory in root directory +d := Directory with("/docs") +d moveTo("/mydocs") diff --git a/Task/Rename-a-file/J/rename-a-file-1.j b/Task/Rename-a-file/J/rename-a-file-1.j new file mode 100644 index 0000000000..3fc9aafa79 --- /dev/null +++ b/Task/Rename-a-file/J/rename-a-file-1.j @@ -0,0 +1,9 @@ +frename=: 4 : 0 + if. x -: y do. return. end. + if. IFUNIX do. + hostcmd=. [: 2!:0 '('"_ , ] , ' || true)'"_ + hostcmd 'mv "',y,'" "',x,'"' + else. + 'kernel32 MoveFileA i *c *c' 15!:0 y;x + end. +) diff --git a/Task/Rename-a-file/J/rename-a-file-2.j b/Task/Rename-a-file/J/rename-a-file-2.j new file mode 100644 index 0000000000..65c47c3043 --- /dev/null +++ b/Task/Rename-a-file/J/rename-a-file-2.j @@ -0,0 +1,4 @@ +'output.txt' frename 'input.txt' +'/output.txt' frename '/input.txt' +'mydocs' frename 'docs' +'/mydocs' frename '/docs' diff --git a/Task/Rename-a-file/Java/rename-a-file.java b/Task/Rename-a-file/Java/rename-a-file.java new file mode 100644 index 0000000000..031be79db7 --- /dev/null +++ b/Task/Rename-a-file/Java/rename-a-file.java @@ -0,0 +1,26 @@ +import java.util.File; +public class FileRenameTest { + public static boolean renameFile(String oldname, String newname) { + // File (or directory) with old name + File file = new File(oldname); + + // File (or directory) with new name + File file2 = new File(newname); + + // Rename file (or directory) + boolean success = file.renameTo(file2); + return success; + } + public static void test(String type, String oldname, String newname) { + System.out.println("The following " + type + " called " + oldname + + ( renameFile(oldname, newname) ? " was renamed as " : " could not be renamed into ") + + newname + "." + ); + } + public static void main(String args[]) { + test("file", "input.txt", "output.txt"); + test("file", File.separator + "input.txt", File.separator + "output.txt"); + test("directory", "docs", "mydocs"); + test("directory", File.separator + "docs" + File.separator, File.separator + "mydocs" + File.separator); + } +} diff --git a/Task/Rename-a-file/JavaScript/rename-a-file.js b/Task/Rename-a-file/JavaScript/rename-a-file.js new file mode 100644 index 0000000000..0eb3b89acf --- /dev/null +++ b/Task/Rename-a-file/JavaScript/rename-a-file.js @@ -0,0 +1,5 @@ +var fso = new ActiveXObject("Scripting.FileSystemObject"); +fso.MoveFile('input.txt', 'output.txt'); +fso.MoveFile('c:/input.txt', 'c:/output.txt'); +fso.MoveFolder('docs', 'mydocs'); +fso.MoveFolder('c:/docs', 'c:/mydocs'); diff --git a/Task/Rename-a-file/Joy/rename-a-file.joy b/Task/Rename-a-file/Joy/rename-a-file.joy new file mode 100644 index 0000000000..2edf1a6952 --- /dev/null +++ b/Task/Rename-a-file/Joy/rename-a-file.joy @@ -0,0 +1,4 @@ +"input.txt" "output.txt" frename +"/input.txt" "/output.txt" frename +"docs" "mydocs" frename +"/docs" "/mydocs" frename. diff --git a/Task/Rename-a-file/Liberty-BASIC/rename-a-file.liberty b/Task/Rename-a-file/Liberty-BASIC/rename-a-file.liberty new file mode 100644 index 0000000000..6c360a6eab --- /dev/null +++ b/Task/Rename-a-file/Liberty-BASIC/rename-a-file.liberty @@ -0,0 +1,10 @@ +' LB has inbuilt 'name' command, but can also run batch files + +nomainwin + +name "input.txt" as "output.txt" +run "cmd.exe /c ren docs mydocs", HIDE +name "C:\input.txt" as "C:\output.txt" +run "cmd.exe /c ren C:\docs mydocs", HIDE + +end diff --git a/Task/Rename-a-file/Locomotive-Basic/rename-a-file.locomotive b/Task/Rename-a-file/Locomotive-Basic/rename-a-file.locomotive new file mode 100644 index 0000000000..89da698855 --- /dev/null +++ b/Task/Rename-a-file/Locomotive-Basic/rename-a-file.locomotive @@ -0,0 +1 @@ +|ren,"input.txt","output.txt" diff --git a/Task/Rename-a-file/Lua/rename-a-file.lua b/Task/Rename-a-file/Lua/rename-a-file.lua new file mode 100644 index 0000000000..f01bebcac0 --- /dev/null +++ b/Task/Rename-a-file/Lua/rename-a-file.lua @@ -0,0 +1,4 @@ +os.rename( "input.txt", "output.txt" ) +os.rename( "/input.txt", "/output.txt" ) +os.rename( "docs", "mydocs" ) +os.rename( "/docs", "/mydocs" ) diff --git a/Task/Rename-a-file/MATLAB/rename-a-file.m b/Task/Rename-a-file/MATLAB/rename-a-file.m new file mode 100644 index 0000000000..c1fa7b69c3 --- /dev/null +++ b/Task/Rename-a-file/MATLAB/rename-a-file.m @@ -0,0 +1 @@ + [STATUS, MSG, MSGID] = movefile (F1, F2); diff --git a/Task/Rename-a-file/MAXScript/rename-a-file.maxscript b/Task/Rename-a-file/MAXScript/rename-a-file.maxscript new file mode 100644 index 0000000000..81f29ee91f --- /dev/null +++ b/Task/Rename-a-file/MAXScript/rename-a-file.maxscript @@ -0,0 +1,4 @@ +-- Here +renameFile "input.txt" "output.txt" +-- Root +renameFile "/input.txt" "/output.txt" diff --git a/Task/Rename-a-file/MUMPS/rename-a-file.mumps b/Task/Rename-a-file/MUMPS/rename-a-file.mumps new file mode 100644 index 0000000000..32106214e3 --- /dev/null +++ b/Task/Rename-a-file/MUMPS/rename-a-file.mumps @@ -0,0 +1,6 @@ + ;Local + S X=$ZF(-1,"rename input.txt output.txt") + S X=$ZF(-1,"rename docs.dir mydocs.dir") + ;Root of current device + S X=$ZF(-1,"rename [000000]input.txt [000000]output.txt") + S X=$ZF(-1,"rename [000000]docs.dir [000000]mydocs.dir") diff --git a/Task/Rename-a-file/Maple/rename-a-file.maple b/Task/Rename-a-file/Maple/rename-a-file.maple new file mode 100644 index 0000000000..38e577bccd --- /dev/null +++ b/Task/Rename-a-file/Maple/rename-a-file.maple @@ -0,0 +1,6 @@ +use FileTools in + Rename( "input.txt", "output.txt" ); + Rename( "docs", "mydocs" ); + Rename( "/input.txt", "/output.txt" ); # assuming permissions in / + Rename( "/docs", "/mydocs" ) # assuming permissions in / +end use: diff --git a/Task/Rename-a-file/Mathematica/rename-a-file.math b/Task/Rename-a-file/Mathematica/rename-a-file.math new file mode 100644 index 0000000000..05e1df6e45 --- /dev/null +++ b/Task/Rename-a-file/Mathematica/rename-a-file.math @@ -0,0 +1,6 @@ +SetDirectory[NotebookDirectory[]] +RenameFile["input.txt", "output.txt"] +RenameDirectory["docs", "mydocs"] +SetDirectory[$RootDirectory] +RenameFile["input.txt", "output.txt"] +RenameDirectory["docs", "mydocs"] diff --git a/Task/Rename-a-file/NewLISP/rename-a-file.newlisp b/Task/Rename-a-file/NewLISP/rename-a-file.newlisp new file mode 100644 index 0000000000..4591cda06e --- /dev/null +++ b/Task/Rename-a-file/NewLISP/rename-a-file.newlisp @@ -0,0 +1,4 @@ +(rename-file "./input.txt" "./output.txt") +(rename-file "./docs" "./mydocs") +(rename-file "/input.txt" "/output.txt") +(rename-file "/docs" "/mydocs") diff --git a/Task/Rename-a-file/OCaml/rename-a-file.ocaml b/Task/Rename-a-file/OCaml/rename-a-file.ocaml new file mode 100644 index 0000000000..12a31dbe55 --- /dev/null +++ b/Task/Rename-a-file/OCaml/rename-a-file.ocaml @@ -0,0 +1,4 @@ +Sys.rename "input.txt" "output.txt";; +Sys.rename "docs" "mydocs";; +Sys.rename "/input.txt" "/output.txt";; +Sys.rename "/docs" "/mydocs";; diff --git a/Task/Rename-a-file/Objeck/rename-a-file.objeck b/Task/Rename-a-file/Objeck/rename-a-file.objeck new file mode 100644 index 0000000000..7b4b1bc99b --- /dev/null +++ b/Task/Rename-a-file/Objeck/rename-a-file.objeck @@ -0,0 +1,11 @@ +use IO; +bundle Default { + class FileExample { + function : Main(args : String[]) ~ Nil { + File->Rename("input.txt", "output.txt"); + File->Rename("docs", "mydocs"); + File->Rename("/input.txt", "/output.txt"); + File->Rename("/docs", "/mydocs"); + } + } +} diff --git a/Task/Rename-a-file/Objective-C/rename-a-file.m b/Task/Rename-a-file/Objective-C/rename-a-file.m new file mode 100644 index 0000000000..58d098520c --- /dev/null +++ b/Task/Rename-a-file/Objective-C/rename-a-file.m @@ -0,0 +1,9 @@ +NSFileManager *fm = [NSFileManager defaultManager]; + +// Pre-OS X 10.5 +[fm movePath:@"input.txt" toPath:@"output.txt" handler:nil]; +[fm movePath:@"docs" toPath:@"mydocs" handler:nil]; + +// OS X 10.5+ +[fm moveItemAtPath:@"input.txt" toPath:@"output.txt" error:NULL]; +[fm moveItemAtPath:@"docs" toPath:@"mydocs" error:NULL]; diff --git a/Task/Rename-a-file/Octave/rename-a-file.octave b/Task/Rename-a-file/Octave/rename-a-file.octave new file mode 100644 index 0000000000..d64fba013b --- /dev/null +++ b/Task/Rename-a-file/Octave/rename-a-file.octave @@ -0,0 +1,3 @@ + rename('docs','mydocs'); +rename('input.txt','/output.txt'); +rename('/docs','/mydocs'); diff --git a/Task/Rename-a-file/PARI-GP/rename-a-file.pari b/Task/Rename-a-file/PARI-GP/rename-a-file.pari new file mode 100644 index 0000000000..49ea21b727 --- /dev/null +++ b/Task/Rename-a-file/PARI-GP/rename-a-file.pari @@ -0,0 +1,4 @@ +system("mv input.txt output.txt"); +system("mv /input.txt /output.txt"); +system("mv docs mydocs"); +system("mv /docs /mydocs"); diff --git a/Task/Rename-a-file/PHP/rename-a-file.php b/Task/Rename-a-file/PHP/rename-a-file.php new file mode 100644 index 0000000000..062aa8031d --- /dev/null +++ b/Task/Rename-a-file/PHP/rename-a-file.php @@ -0,0 +1,6 @@ + diff --git a/Task/Rename-a-file/Pascal/rename-a-file.pascal b/Task/Rename-a-file/Pascal/rename-a-file.pascal new file mode 100644 index 0000000000..1e4fd3ef4a --- /dev/null +++ b/Task/Rename-a-file/Pascal/rename-a-file.pascal @@ -0,0 +1,22 @@ + var + f : file ; // Untyped file + begin + + // as current directory + AssignFile(f,'input.doc'); + Rename(f,'output.doc'); + + // as root directory + AssignFile(f,'\input.doc'); + Rename(f,'\output.doc'); + + // rename a directory + AssignFile(f,'docs'); + Rename(f,'mydocs'); + + //rename a directory off the root + + AssignFile(f,'\docs'); + Rename(f,'\mydocs'); + +end; diff --git a/Task/Rename-a-file/Perl-6/rename-a-file.pl6 b/Task/Rename-a-file/Perl-6/rename-a-file.pl6 new file mode 100644 index 0000000000..235483ee74 --- /dev/null +++ b/Task/Rename-a-file/Perl-6/rename-a-file.pl6 @@ -0,0 +1,4 @@ +rename 'input.txt', 'output.txt'; +rename 'docs', 'mydocs'; +rename '/input.txt', '/output.txt'; +rename '/docs', '/mydocs'; diff --git a/Task/Rename-a-file/Perl/rename-a-file.pl b/Task/Rename-a-file/Perl/rename-a-file.pl new file mode 100644 index 0000000000..b9a2ae0ae6 --- /dev/null +++ b/Task/Rename-a-file/Perl/rename-a-file.pl @@ -0,0 +1,8 @@ +use File::Copy qw(move); +use File::Spec::Functions qw(catfile rootdir); +# here +move 'input.txt', 'output.txt'; +move 'docs', 'mydocs'; +# root dir +move (catfile rootdir, 'input.txt'), (catfile rootdir, 'output.txt'); +move (catfile rootdir, 'docs'), (catfile rootdir, 'mydocs'); diff --git a/Task/Rename-a-file/PicoLisp/rename-a-file.l b/Task/Rename-a-file/PicoLisp/rename-a-file.l new file mode 100644 index 0000000000..8f8d6fd89c --- /dev/null +++ b/Task/Rename-a-file/PicoLisp/rename-a-file.l @@ -0,0 +1,4 @@ +(call 'mv "input.txt" "output.txt") +(call 'mv "docs" "mydocs") +(call 'mv "/input.txt" "/output.txt") +(call 'mv "/docs" "/mydocs") diff --git a/Task/Rename-a-file/Pike/rename-a-file.pike b/Task/Rename-a-file/Pike/rename-a-file.pike new file mode 100644 index 0000000000..9b44c587ea --- /dev/null +++ b/Task/Rename-a-file/Pike/rename-a-file.pike @@ -0,0 +1,6 @@ +int main(){ + mv("input.txt", "output.txt"); + mv("/input.txt", "/output.txt"); + mv("docs", "mydocs"); + mv("/docs", "/mydocs"); +} diff --git a/Task/Rename-a-file/Pop11/rename-a-file.pop11 b/Task/Rename-a-file/Pop11/rename-a-file.pop11 new file mode 100644 index 0000000000..056c868c24 --- /dev/null +++ b/Task/Rename-a-file/Pop11/rename-a-file.pop11 @@ -0,0 +1,4 @@ +sys_file_move('inputs.txt', 'output.txt'); +sys_file_move('docs', 'mydocs'); +sys_file_move('/inputs.txt', '/output.txt'); +sys_file_move(/'docs', '/mydocs'); diff --git a/Task/Rename-a-file/PowerShell/rename-a-file.psh b/Task/Rename-a-file/PowerShell/rename-a-file.psh new file mode 100644 index 0000000000..e4fedf03ad --- /dev/null +++ b/Task/Rename-a-file/PowerShell/rename-a-file.psh @@ -0,0 +1,4 @@ +Rename-Item input.txt output.txt + +# The Rename-item has the alias ren +ren input.txt output.txt diff --git a/Task/Rename-a-file/ProDOS/rename-a-file.dos b/Task/Rename-a-file/ProDOS/rename-a-file.dos new file mode 100644 index 0000000000..b8d0a74f70 --- /dev/null +++ b/Task/Rename-a-file/ProDOS/rename-a-file.dos @@ -0,0 +1,2 @@ +rename input.txt to output.txt +rename docs to mydocs diff --git a/Task/Rename-a-file/PureBasic/rename-a-file.purebasic b/Task/Rename-a-file/PureBasic/rename-a-file.purebasic new file mode 100644 index 0000000000..e60bfa8108 --- /dev/null +++ b/Task/Rename-a-file/PureBasic/rename-a-file.purebasic @@ -0,0 +1,5 @@ +RenameFile("input.txt", "output.txt") +RenameFile("docs\", "mydocs\") + +RenameFile("/input.txt","/output.txt") +RenameFile("/docs\","/mydocs\") diff --git a/Task/Rename-a-file/Python/rename-a-file-1.py b/Task/Rename-a-file/Python/rename-a-file-1.py new file mode 100644 index 0000000000..dcac01f022 --- /dev/null +++ b/Task/Rename-a-file/Python/rename-a-file-1.py @@ -0,0 +1,7 @@ +import os + +os.rename("input.txt", "output.txt") +os.rename("docs", "mydocs") + +os.rename(os.sep + "input.txt", os.sep + "output.txt") +os.rename(os.sep + "docs", os.sep + "mydocs") diff --git a/Task/Rename-a-file/Python/rename-a-file-2.py b/Task/Rename-a-file/Python/rename-a-file-2.py new file mode 100644 index 0000000000..0b6178c67b --- /dev/null +++ b/Task/Rename-a-file/Python/rename-a-file-2.py @@ -0,0 +1,7 @@ +import shutil + +shutil.move("input.txt", "output.txt") +shutil.move("docs", "mydocs") + +shutil.move("/input.txt", "/output.txt") +shutil.move("/docs", "/mydocs") diff --git a/Task/Rename-a-file/R/rename-a-file.r b/Task/Rename-a-file/R/rename-a-file.r new file mode 100644 index 0000000000..de88f062a2 --- /dev/null +++ b/Task/Rename-a-file/R/rename-a-file.r @@ -0,0 +1,4 @@ +file.rename("input.txt", "output.txt") +file.rename("/input.txt", "/output.txt") +file.rename("docs", "mydocs") +file.rename("/docs", "/mydocs") diff --git a/Task/Rename-a-file/REALbasic/rename-a-file.realbasic b/Task/Rename-a-file/REALbasic/rename-a-file.realbasic new file mode 100644 index 0000000000..ec7a551873 --- /dev/null +++ b/Task/Rename-a-file/REALbasic/rename-a-file.realbasic @@ -0,0 +1,29 @@ +Sub Renamer() + Dim f As FolderItem, r As FolderItem + + f = GetFolderItem("input.txt") + 'Changing a FolderItem's Name attribute renames the file or directory. + If f.Exists Then f.Name = "output.txt" + 'Files and directories are handled almost identically in RB. + f = GetFolderItem("docs") + If f.Exists Then f.Name = "mydocs" + + 'Jump through hoops to find the root directory. + r = RootDir(GetFolderItem(".")) + + f = r.Child("input.txt") + 'Renaming in a different directory identical to renaming in current directory. + If f.Exists Then f.Name = "output.txt" + f = r.Child("docs") + If f.Exists Then f.Name = "mydocs" +End Sub + +Function RootDir(what As FolderItem) As FolderItem + 'RB doesn't have an easy way to find the root of the current drive; + 'not an issue under *nix but troublesome under Windows. + If what.Parent <> Nil Then 'Nil = no parent = root. + Return RootDir(what.Parent) 'Recursive. + Else + Return what + End If +End Function diff --git a/Task/Rename-a-file/REBOL/rename-a-file.rebol b/Task/Rename-a-file/REBOL/rename-a-file.rebol new file mode 100644 index 0000000000..4b1999f35e --- /dev/null +++ b/Task/Rename-a-file/REBOL/rename-a-file.rebol @@ -0,0 +1,19 @@ +rename %input.txt %output.txt +rename %docs/ %mydocs/ + +; Unix. Note that there's no path specification used for the +; new name. "Rename" is not "move". + +rename %/input.txt %output.txt +rename %/docs/ %mydocs/ + +; DOS/Windows: + +rename %/c/input.txt %output.txt +rename %/c/docs/ %mydocs/ + +; Because REBOL treats data access schemes as uniformly as possible, +; you can do tricks like this: + +rename ftp://username:password@ftp.site.com/www/input.txt %output.txt +rename ftp://username:password@ftp.site.com/www/docs/ %mydocs/ diff --git a/Task/Rename-a-file/REXX/rename-a-file-1.rexx b/Task/Rename-a-file/REXX/rename-a-file-1.rexx new file mode 100644 index 0000000000..0e7e46987f --- /dev/null +++ b/Task/Rename-a-file/REXX/rename-a-file-1.rexx @@ -0,0 +1,5 @@ + do 2 + 'RENAME' "input.txt" "output.txt" + 'CD' "\" + 'MOVE' "\docs" "\mydocs" + end diff --git a/Task/Rename-a-file/REXX/rename-a-file-2.rexx b/Task/Rename-a-file/REXX/rename-a-file-2.rexx new file mode 100644 index 0000000000..3c81c957bc --- /dev/null +++ b/Task/Rename-a-file/REXX/rename-a-file-2.rexx @@ -0,0 +1,5 @@ + do 2 + 'RENAME' "input.txt output.txt" + 'CD' "\" + 'MOVE' "\docs \mydocs" + end diff --git a/Task/Rename-a-file/Racket/rename-a-file.rkt b/Task/Rename-a-file/Racket/rename-a-file.rkt new file mode 100644 index 0000000000..7fae0dfcd9 --- /dev/null +++ b/Task/Rename-a-file/Racket/rename-a-file.rkt @@ -0,0 +1,12 @@ +#lang racket + +(rename-file-or-directory "input.txt" "output.txt") +(rename-file-or-directory "docs" "mydocs") + +;; find the filesystem roots, and pick the first one +(define root (first (filesystem-root-list))) + +(rename-file-or-directory (build-path root "input.txt") + (build-path root "output.txt")) +(rename-file-or-directory (build-path root "docs") + (build-path root "mydocs")) diff --git a/Task/Rename-a-file/Ruby/rename-a-file-1.rb b/Task/Rename-a-file/Ruby/rename-a-file-1.rb new file mode 100644 index 0000000000..1241806b53 --- /dev/null +++ b/Task/Rename-a-file/Ruby/rename-a-file-1.rb @@ -0,0 +1,4 @@ +File.rename('input.txt', 'output.txt') +File.rename('/input.txt', '/output.txt') +File.rename('docs', 'mydocs') +File.rename('/docs', '/mydocs') diff --git a/Task/Rename-a-file/Ruby/rename-a-file-2.rb b/Task/Rename-a-file/Ruby/rename-a-file-2.rb new file mode 100644 index 0000000000..86eb51239b --- /dev/null +++ b/Task/Rename-a-file/Ruby/rename-a-file-2.rb @@ -0,0 +1,3 @@ +require 'fileutils' +moves = { "input.txt" => "output.txt", "/input.txt" => "/output.txt", "docs" => "mydocs","/docs" => "/mydocs"} +moves.each{ |src, dest| FileUtils.move( src, dest, :verbose => true ) } diff --git a/Task/Rename-a-file/Run-BASIC/rename-a-file.run b/Task/Rename-a-file/Run-BASIC/rename-a-file.run new file mode 100644 index 0000000000..ee61501f0d --- /dev/null +++ b/Task/Rename-a-file/Run-BASIC/rename-a-file.run @@ -0,0 +1,4 @@ +a$ = shell$("RENAME input.txt output.txt") +a$ = shell$("RENAME docs mydocs") +a$ = shell$("RENAME \input.txt \output.txt") +a$ = shell$("RENAME \docs \mydocs") diff --git a/Task/Rename-a-file/Scala/rename-a-file.scala b/Task/Rename-a-file/Scala/rename-a-file.scala new file mode 100644 index 0000000000..fc24ade9ec --- /dev/null +++ b/Task/Rename-a-file/Scala/rename-a-file.scala @@ -0,0 +1,9 @@ +object rename { + def main(args: Array[String]) { + implicit def file(s: String) = new File(s) + "myfile.txt" renameTo "anotherfile.txt" + "/tmp/myfile.txt" renameTo "/tmp/anotherfile.txt" + "mydir" renameTo "anotherdir" + "/tmp/mydir" renameTo "/tmp/anotherdir" + } +} diff --git a/Task/Rename-a-file/Scheme/rename-a-file.ss b/Task/Rename-a-file/Scheme/rename-a-file.ss new file mode 100644 index 0000000000..46e9e19d86 --- /dev/null +++ b/Task/Rename-a-file/Scheme/rename-a-file.ss @@ -0,0 +1,4 @@ +(rename-file "input.txt" "output.txt") +(rename-file "docs" "mydocs") +(rename-file "/input.txt" "/output.txt") +(rename-file "/docs" "/mydocs") diff --git a/Task/Rename-a-file/Seed7/rename-a-file.seed7 b/Task/Rename-a-file/Seed7/rename-a-file.seed7 new file mode 100644 index 0000000000..7675a2e7b7 --- /dev/null +++ b/Task/Rename-a-file/Seed7/rename-a-file.seed7 @@ -0,0 +1,10 @@ +$ include "seed7_05.s7i"; + include "osfiles.s7i"; + +const proc: main is func + begin + moveFile("input.txt", "output.txt"); + moveFile("docs", "mydocs"); + moveFile("/input.txt", "/output.txt"); + moveFile("/docs", "/mydocs"); + end func; diff --git a/Task/Rename-a-file/Slate/rename-a-file.slate b/Task/Rename-a-file/Slate/rename-a-file.slate new file mode 100644 index 0000000000..cb0b6c8336 --- /dev/null +++ b/Task/Rename-a-file/Slate/rename-a-file.slate @@ -0,0 +1,4 @@ +(File newNamed: 'input.txt') renameTo: 'output.txt'. +(File newNamed: '/input.txt') renameTo: '/output.txt'. +(Directory newNamed: 'docs') renameTo: 'mydocs'. +(Directory newNamed: '/docs') renameTo: '/mydocs'. diff --git a/Task/Rename-a-file/Smalltalk/rename-a-file-1.st b/Task/Rename-a-file/Smalltalk/rename-a-file-1.st new file mode 100644 index 0000000000..24d2124810 --- /dev/null +++ b/Task/Rename-a-file/Smalltalk/rename-a-file-1.st @@ -0,0 +1,6 @@ +File rename: 'input.txt' to: 'output.txt'. +File rename: 'docs' to: 'mydocs'. +"as for other example, this works on systems + where the root is / ..." +File rename: '/input.txt' to: '/output.txt'. +File rename: '/docs' to: '/mydocs' diff --git a/Task/Rename-a-file/Smalltalk/rename-a-file-2.st b/Task/Rename-a-file/Smalltalk/rename-a-file-2.st new file mode 100644 index 0000000000..5d90b615da --- /dev/null +++ b/Task/Rename-a-file/Smalltalk/rename-a-file-2.st @@ -0,0 +1,4 @@ +'input.txt' asFilename renameTo: 'output.txt'. +'docs' asFilename renameTo: 'mydocs'. +'/input.txt' asFilename renameTo: '/output.txt'. +'/docs' asFilename renameTo: '/mydocs' diff --git a/Task/Rename-a-file/Standard-ML/rename-a-file.ml b/Task/Rename-a-file/Standard-ML/rename-a-file.ml new file mode 100644 index 0000000000..8887de806e --- /dev/null +++ b/Task/Rename-a-file/Standard-ML/rename-a-file.ml @@ -0,0 +1,4 @@ +OS.FileSys.rename {old = "input.txt", new = "output.txt"}; +OS.FileSys.rename {old = "docs", new = "mydocs"}; +OS.FileSys.rename {old = "/input.txt", new = "/output.txt"}; +OS.FileSys.rename {old = "/docs", new = "/mydocs"}; diff --git a/Task/Rename-a-file/TUSCRIPT/rename-a-file.tuscript b/Task/Rename-a-file/TUSCRIPT/rename-a-file.tuscript new file mode 100644 index 0000000000..e6ec049e68 --- /dev/null +++ b/Task/Rename-a-file/TUSCRIPT/rename-a-file.tuscript @@ -0,0 +1,5 @@ +$$ MODE TUSCRIPT +- rename file +ERROR/STOP RENAME ("input.txt","output.txt") +- rename directory +ERROR/STOP RENAME ("docs","mydocs",-std-) diff --git a/Task/Rename-a-file/Tcl/rename-a-file-1.tcl b/Task/Rename-a-file/Tcl/rename-a-file-1.tcl new file mode 100644 index 0000000000..e935365386 --- /dev/null +++ b/Task/Rename-a-file/Tcl/rename-a-file-1.tcl @@ -0,0 +1,5 @@ +file rename inputs.txt output.txt +file rename docs mydocs + +file rename [file nativename /inputs.txt] [file nativename /output.txt] +file rename [file nativename /docs] [file nativename /mydocs] diff --git a/Task/Rename-a-file/Tcl/rename-a-file-2.tcl b/Task/Rename-a-file/Tcl/rename-a-file-2.tcl new file mode 100644 index 0000000000..ada2cddf89 --- /dev/null +++ b/Task/Rename-a-file/Tcl/rename-a-file-2.tcl @@ -0,0 +1,5 @@ +file rename inputs.txt output.txt +file rename docs mydocs + +file rename /inputs.txt /output.txt +file rename /docs /mydocs diff --git a/Task/Rename-a-file/Toka/rename-a-file.toka b/Task/Rename-a-file/Toka/rename-a-file.toka new file mode 100644 index 0000000000..c1455504c3 --- /dev/null +++ b/Task/Rename-a-file/Toka/rename-a-file.toka @@ -0,0 +1,6 @@ +needs shell +" input.txt" " output.txt" rename +" /input.txt" " /output.txt" rename + +" docs" " mydocs" rename +" /docs" " /mydocs" rename diff --git a/Task/Rename-a-file/TorqueScript/rename-a-file.torquescript b/Task/Rename-a-file/TorqueScript/rename-a-file.torquescript new file mode 100644 index 0000000000..72950db1e7 --- /dev/null +++ b/Task/Rename-a-file/TorqueScript/rename-a-file.torquescript @@ -0,0 +1,8 @@ +fileCopy("Input.txt", "Output.txt"); +fileDelete("Input.txt"); + +for(%File = FindFirstFile("Path/*.*"); %File !$= ""; %File = FindNextFile("Path/*.*")) +{ + fileCopy(%File, "OtherPath/" @ %File); + fileDelete(%File); +} diff --git a/Task/Rename-a-file/UNIX-Shell/rename-a-file.sh b/Task/Rename-a-file/UNIX-Shell/rename-a-file.sh new file mode 100644 index 0000000000..2557093cc3 --- /dev/null +++ b/Task/Rename-a-file/UNIX-Shell/rename-a-file.sh @@ -0,0 +1,4 @@ +mv input.txt output.txt +mv /input.txt /output.txt +mv docs mydocs +mv /docs /mydocs diff --git a/Task/Rename-a-file/Vedit-macro-language/rename-a-file.vedit b/Task/Rename-a-file/Vedit-macro-language/rename-a-file.vedit new file mode 100644 index 0000000000..5f5b6beec0 --- /dev/null +++ b/Task/Rename-a-file/Vedit-macro-language/rename-a-file.vedit @@ -0,0 +1,7 @@ +// In current directory +File_Rename("input.txt", "output.txt") +File_Rename("docs", "mydocs") + +// In the root directory +File_Rename("/input.txt", "/output.txt") +File_Rename("/docs", "/mydocs") diff --git a/Task/Rename-a-file/Visual-Basic-.NET/rename-a-file.visual b/Task/Rename-a-file/Visual-Basic-.NET/rename-a-file.visual new file mode 100644 index 0000000000..0421572432 --- /dev/null +++ b/Task/Rename-a-file/Visual-Basic-.NET/rename-a-file.visual @@ -0,0 +1,13 @@ +'Current Directory +IO.Directory.Move("docs", "mydocs") +IO.File.Move("input.txt", "output.txt") + +'Root +IO.Directory.Move("\docs", "\mydocs") +IO.File.Move("\input.txt", "\output.txt") + +'Root, platform independent +IO.Directory.Move(IO.Path.DirectorySeparatorChar & "docs", _ + IO.Path.DirectorySeparatorChar & "mydocs") +IO.File.Move(IO.Path.DirectorySeparatorChar & "input.txt", _ + IO.Path.DirectorySeparatorChar & "output.txt") diff --git a/Task/Rename-a-file/Yorick/rename-a-file.yorick b/Task/Rename-a-file/Yorick/rename-a-file.yorick new file mode 100644 index 0000000000..44b356f1ee --- /dev/null +++ b/Task/Rename-a-file/Yorick/rename-a-file.yorick @@ -0,0 +1,4 @@ +rename, "input.txt", "output.txt"; +rename, "/input.txt", "/output.txt"; +rename, "docs", "mydocs"; +rename, "/docs", "/mydocs"; diff --git a/Task/Rendezvous/0DESCRIPTION b/Task/Rendezvous/0DESCRIPTION new file mode 100644 index 0000000000..ee879d6e50 --- /dev/null +++ b/Task/Rendezvous/0DESCRIPTION @@ -0,0 +1,29 @@ +Demonstrate the “rendezvous” communications technique by implementing a printer monitor. +==Detailed Description of Programming Task== +Rendezvous is a synchronization mechanism based on procedural decomposition. Rendezvous is similar to a procedure call with the difference that the caller and the callee belong to different [[task]]s. The called procedure is usually called an '''entry point''' of the corresponding task. A call to an entry point is synchronous, i.e. the caller is blocked until completion. For the caller a call to the entry point is indivisible. Internally it consists of: + +* Waiting for the callee ready to accept the rendezvous; +* Engaging the rendezvous (servicing the entry point). + +The caller may limit the waiting time to the callee to accept the rendezvous. I.e. a rendezvous request can be aborted if not yet accepted by the callee. When accepted the rendezvous is processed until its completion. During this time the caller and the callee tasks stay synchronized. Which context is used to process the rendezvous depends on the implementation which may wish to minimize context switching. + +The callee task may accept several rendezvous requests: + +* Rendezvous to the same entry point from different tasks; +* Rendezvous to different entry points. + +The callee accepts one rendezvous at a time. + +Language mechanism of [[exceptions]] (if any) has to be consistent with the rendezvous. In particular when an exception is propagated out of a rendezvous it shall do in both tasks. The exception propagation is synchronous within the rendezvous and asynchronous outside it. + +An engaged rendezvous can be requeued by the callee to another entry point of its task or to another task, transparently to the caller. + +Differently to messages which are usually asynchronous, rendezvous are synchronous, as it was stated before. Therefore a rendezvous does not require marshaling the parameters and a buffer to keep them. Further, rendezvous can be implemented without context switch. This makes rendezvous a more efficient than messaging. + +Rendezvous can be used to implement monitor synchronization objects. A monitor guards a shared resource. All users of the resource request a rendezvous to the monitor in order to get access to the resource. Access is granted by accepting the rendezvous for the time while the rendezvous is serviced. + +===Language task=== +Show how rendezvous are supported by the language. If the language does not have rendezvous, provide an implementation of them based on other primitives. + +===Use case task=== +Implement a printer monitor. The monitor guards a printer. There are two printers ''main'' and ''reserve''. Each has a monitor that accepts a rendezvous Print with a text line to print of the printer. The standard output may serve for printing purpose. Each character of the line is printed separately in order to illustrate that lines are printed indivisibly. Each printer has ink for only 5 lines of text. When the ''main'' printer runs out of ink it redirects its requests to the ''reserve'' printer. When that runs out of ink too, Out_Of_Ink exception propagates back to the caller. Create two writer tasks which print their plagiarisms on the printer. One does ''Humpty Dumpty'', another ''Mother Goose''. diff --git a/Task/Rendezvous/1META.yaml b/Task/Rendezvous/1META.yaml new file mode 100644 index 0000000000..d2f44cc2b9 --- /dev/null +++ b/Task/Rendezvous/1META.yaml @@ -0,0 +1,6 @@ +--- +category: +- Encyclopedia +note: Concurrency +requires: +- Concurrency diff --git a/Task/Rendezvous/Ada/rendezvous-1.ada b/Task/Rendezvous/Ada/rendezvous-1.ada new file mode 100644 index 0000000000..3154f7e0a9 --- /dev/null +++ b/Task/Rendezvous/Ada/rendezvous-1.ada @@ -0,0 +1,6 @@ +select + Server.Wake_Up (Parameters); +or delay 5.0; + -- No response, try something else + ... +end select; diff --git a/Task/Rendezvous/Ada/rendezvous-2.ada b/Task/Rendezvous/Ada/rendezvous-2.ada new file mode 100644 index 0000000000..81fb1a1daa --- /dev/null +++ b/Task/Rendezvous/Ada/rendezvous-2.ada @@ -0,0 +1,8 @@ +select + accept Wake_Up (Parameters : Work_Item) do + Current_Work_Item := Parameters; + end; + Process (Current_Work_Item); +or accept Shut_Down; + exit; -- Shut down requested +end select; diff --git a/Task/Rendezvous/Ada/rendezvous-3.ada b/Task/Rendezvous/Ada/rendezvous-3.ada new file mode 100644 index 0000000000..70033243a3 --- /dev/null +++ b/Task/Rendezvous/Ada/rendezvous-3.ada @@ -0,0 +1,77 @@ +with Ada.Text_IO; use Ada.Text_IO; + +procedure Rendezvous is + Out_Of_Ink : exception; + + type Printer; + type Printer_Ptr is access all Printer; + task type Printer (ID : Natural; Backup : Printer_Ptr) is + entry Print (Line : String); + end Printer; + + task body Printer is + Ink : Natural := 5; + begin + loop + begin + select + accept Print (Line : String) do + if Ink = 0 then + if Backup = null then + raise Out_Of_Ink; + else + requeue Backup.Print with abort; + end if; + else + Put (Integer'Image (ID) & ": "); + for I in Line'Range loop + Put (Line (I)); + end loop; + New_Line; + Ink := Ink - 1; + end if; + end Print; + or terminate; + end select; + exception + when Out_Of_Ink => + null; + end; + end loop; + end Printer; + + Reserve : aliased Printer (2, null); + Main : Printer (1, Reserve'Access); + + task Humpty_Dumpty; + task Mother_Goose; + + task body Humpty_Dumpty is + begin + Main.Print ("Humpty Dumpty sat on a wall."); + Main.Print ("Humpty Dumpty had a great fall."); + Main.Print ("All the king's horses and all the king's men"); + Main.Print ("Couldn't put Humpty together again."); + exception + when Out_Of_Ink => + Put_Line (" Humpty Dumpty out of ink!"); + end Humpty_Dumpty; + + task body Mother_Goose is + begin + Main.Print ("Old Mother Goose"); + Main.Print ("When she wanted to wander,"); + Main.Print ("Would ride through the air"); + Main.Print ("On a very fine gander."); + Main.Print ("Jack's mother came in,"); + Main.Print ("And caught the goose soon,"); + Main.Print ("And mounting its back,"); + Main.Print ("Flew up to the moon."); + exception + when Out_Of_Ink => + Put_Line (" Mother Goose out of ink!"); + end Mother_Goose; + +begin + null; +end Rendezvous; diff --git a/Task/Rendezvous/AutoHotkey/rendezvous.ahk b/Task/Rendezvous/AutoHotkey/rendezvous.ahk new file mode 100644 index 0000000000..e2e0f62665 --- /dev/null +++ b/Task/Rendezvous/AutoHotkey/rendezvous.ahk @@ -0,0 +1,77 @@ +OnMessage(0x4a, "PrintMonitor") +SetTimer, print2, 400 + +print1: + print("Old Mother Goose") + print("When she wanted to wander,") + print("Would ride through the air") + print("On a very fine gander.") + print("Jack's mother came in,") + print("And caught the goose soon,") + print("And mounting its back,") + print("Flew up to the moon.") +Return + +print2: + SetTimer, print2, Off + print("Humpty Dumpty sat on a wall.") + print("Humpty Dumpty had a great fall.") + print("All the king's horses and all the king's men") + print("Couldn't put Humpty together again.") +Return + +print(message) +{ + Static StringToSend + StringToSend := message + Gui +LastFound + VarSetCapacity(CopyDataStruct, 12, 0) + NumPut(StrLen(StringToSend) + 1, CopyDataStruct, 4) + NumPut(&StringToSend, CopyDataStruct, 8) + SendMessage, 0x4a, 0, &CopyDataStruct + If ErrorLevel + MsgBox out of ink + Sleep, 200 + Return +} + +PrintMonitor(wParam, lParam, msg) +{ + Static ink = 5 + Global printed + Critical + If ink + { + StringAddress := NumGet(lParam + 8) + StringLength := DllCall("lstrlen", UInt, StringAddress) + VarSetCapacity(CopyOfData, StringLength) + DllCall("lstrcpy", "str", CopyOfData, "uint", StringAddress) + printed .= "primaryprinter: " . CopyOfData . "`n" + ToolTip, primary printer`n: %printed% + ink-- + } + Else + { + OnMessage(0x4a, "Reserve") + print(CopyOfData) + } +} + +Reserve(wParam, lParam, msg) +{ + Static ink = 5 + Global printed + Critical + If ink + { + StringAddress := NumGet(lParam + 8) + StringLength := DllCall("lstrlen", UInt, StringAddress) + VarSetCapacity(CopyOfData, StringLength) + DllCall("lstrcpy", "str", CopyOfData, "uint", StringAddress) + printed .= "reserveprinter: " . CopyOfData . "`n" + ToolTip, Reserve printer`n: %printed% + ink-- + } + Else + Return -1 +} diff --git a/Task/Rendezvous/C/rendezvous.c b/Task/Rendezvous/C/rendezvous.c new file mode 100644 index 0000000000..883fd1d547 --- /dev/null +++ b/Task/Rendezvous/C/rendezvous.c @@ -0,0 +1,72 @@ +#include +#include +#include + +typedef struct printer printer; +struct printer { int id, ink; }; +printer pnt_main = { 1, 5 }; +printer pnt_backup = { 2, 5 }; + +int print(const char * text, const char **error) +{ + #pragma omp critical + { + printer *p = &pnt_main; + if (!p->ink) p = &pnt_backup; + if (!p->ink) + *error = "Out of ink"; + else { + *error = 0; + p->ink--; + printf("%d | ", p->id, p->ink); + while (*text != '\0') { + putchar(*(text++)); + fflush(stdout); + usleep(30000); + } + putchar('\n'); + } + } + return 0 != *error; +} + +const char *humpty[] = { + "Humpty Dumpty sat on a wall.", + "Humpty Dumpty had a great fall.", + "All the king's horses and all the king's men,", + "Couldn't put Humpty together again." +}; + +const char *goose[] = { + "Old Mother Goose,", + "When she wanted to wander,", + "Would ride through the air,", + "On a very fine gander.", + "Jack's mother came in,", + "And caught the goose soon,", + "And mounting its back,", + "Flew up to the moon." +}; + +int main() +{ + int i, j, len; + const char *msg, **text; + + omp_set_num_threads(2); + + #pragma omp parallel for private(text, msg, len, j) + for (i = 0; i < 2; i++) { + text = i ? goose : humpty; + len = (i ? sizeof(goose) : sizeof(humpty) ) / sizeof(const char*); + for (j = 0; j < len; j++) { + usleep(100000); + if (print(text[j], &msg)) { + fprintf(stderr, "Error: %s\n", msg); + break; + } + } + } + + return 0; +} diff --git a/Task/Rendezvous/Go/rendezvous.go b/Task/Rendezvous/Go/rendezvous.go new file mode 100644 index 0000000000..9ef2e09115 --- /dev/null +++ b/Task/Rendezvous/Go/rendezvous.go @@ -0,0 +1,145 @@ +package main + +import ( + "errors" + "fmt" + "strings" + "sync" +) + +var hdText = `Humpty Dumpty sat on a wall. +Humpty Dumpty had a great fall. +All the king's horses and all the king's men, +Couldn't put Humpty together again.` + +var mgText = `Old Mother Goose, +When she wanted to wander, +Would ride through the air, +On a very fine gander. +Jack's mother came in, +And caught the goose soon, +And mounting its back, +Flew up to the moon.` + +func main() { + reservePrinter := startMonitor(newPrinter(5), nil) + mainPrinter := startMonitor(newPrinter(5), reservePrinter) + var busy sync.WaitGroup + busy.Add(2) + go writer(mainPrinter, "hd", hdText, &busy) + go writer(mainPrinter, "mg", mgText, &busy) + busy.Wait() +} + +// printer is a type representing an abstraction of a physical printer. +// It is a type defintion for a function that takes a string to print +// and returns an error value, (hopefully usually nil, meaning no error.) +type printer func(string) error + +// newPrinter is a constructor. The parameter is a quantity of ink. It +// returns a printer object encapsulating the ink quantity. +// Note that this is not creating the monitor, only the object serving as +// a physical printer by writing to standard output. +func newPrinter(ink int) printer { + return func(line string) error { + if ink == 0 { + return eOutOfInk + } + for _, c := range line { + fmt.Printf("%c", c) + } + fmt.Println() + ink-- + return nil + } +} + +var eOutOfInk = errors.New("out of ink") + +// For the language task, rSync is a type used to approximate the Ada +// rendezvous mechanism that includes the caller waiting for completion +// of the callee. For this use case, we signal completion with an error +// value as a response. Exceptions are not idiomatic in Go and there is +// no attempt here to model the Ada exception mechanism. Instead, it is +// idomatic in Go to return error values. Sending an error value on a +// channel works well here to signal completion. Go unbuffered channels +// provide synchronous rendezvous, but call and response takes two channels, +// which are bundled together here in a struct. The channel types are chosen +// to mirror the parameter and return types of "type printer" defined above. +// The channel types here, string and error are both "reference types" +// in Go terminology. That is, they are small things containing pointers +// to the actual data. Sending one on a channel does not involve copying, +// or much less marshalling string data. +type rSync struct { + call chan string + response chan error +} + +// "rendezvous Print" requested by use case task. +// For the language task though, it is implemented here as a method on +// rSync that sends its argument on rSync.call and returns the result +// received from rSync.response. Each channel operation is synchronous. +// The two operations back to back approximate the Ada rendezvous. +func (r *rSync) print(data string) error { + r.call <- data // blocks until data is accepted on channel + return <-r.response // blocks until response is received +} + +// monitor is run as a goroutine. It encapsulates the printer passed to it. +// Print requests are received through the rSync object "entry," named entry +// here to correspond to the Ada concept of an entry point. +func monitor(hardPrint printer, entry, reserve *rSync) { + for { + // The monitor goroutine will block here waiting for a "call" + // to its "entry point." + data := <-entry.call + // Assuming the call came from a goroutine calling rSync.print, + // that goroutine is now blocked, waiting for this one to send + // a response. + + // attempt output + switch err := hardPrint(data); { + + // consider return value from attempt + case err == nil: + entry.response <- nil // no problems + + case err == eOutOfInk && reserve != nil: + // Requeue to "entry point" of reserve printer monitor. + // Caller stays blocked, and now this goroutine blocks until + // it gets a response from the reserve printer monitor. + // It then transparently relays the response to the caller. + entry.response <- reserve.print(data) + + default: + entry.response <- err // return failure + } + // The response is away. Loop, and so immediately block again. + } +} + +// startMonitor can be seen as an rSync constructor. It also +// of course, starts the monitor for which the rSync serves as entry point. +// Further to the langauge task, note that the channels created here are +// unbuffered. There is no buffer or message box to hold channel data. +// A sender will block waiting for a receiver to accept data synchronously. +func startMonitor(p printer, reservePrinter *rSync) *rSync { + entry := &rSync{make(chan string), make(chan error)} + go monitor(p, entry, reservePrinter) + return entry +} + +// Two writer tasks are started as goroutines by main. They run concurrently +// and compete for printers as resources. Note the call to "rendezvous Print" +// as requested in the use case task and compare the syntax, +// Here: printMonitor.print(line); +// Ada solution: Main.Print ("string literal"); +func writer(printMonitor *rSync, id, text string, busy *sync.WaitGroup) { + for _, line := range strings.Split(text, "\n") { + if err := printMonitor.print(line); err != nil { + fmt.Printf("**** writer task %q terminated: %v ****\n", id, err) + break + } + } + busy.Done() +} diff --git a/Task/Rendezvous/Oz/rendezvous-1.oz b/Task/Rendezvous/Oz/rendezvous-1.oz new file mode 100644 index 0000000000..993d05ae30 --- /dev/null +++ b/Task/Rendezvous/Oz/rendezvous-1.oz @@ -0,0 +1,28 @@ +declare + class Printer + attr ink:5 + + feat id backup + + meth init(id:ID backup:Backup<=unit) + self.id = ID + self.backup = Backup + end + + meth print(Line)=Msg + if @ink == 0 then + if self.backup == unit then + raise outOfInk end + else + {self.backup Msg} + end + else + {System.printInfo self.id#": "} + for C in Line do + {System.printInfo [C]} + end + {System.printInfo "\n"} + ink := @ink - 1 + end + end + end diff --git a/Task/Rendezvous/Oz/rendezvous-2.oz b/Task/Rendezvous/Oz/rendezvous-2.oz new file mode 100644 index 0000000000..792c294368 --- /dev/null +++ b/Task/Rendezvous/Oz/rendezvous-2.oz @@ -0,0 +1,21 @@ + fun {NewActiveSync Class Init} + Obj = {New Class Init} + MsgPort + in + thread MsgStream in + {NewPort ?MsgStream ?MsgPort} + for Msg#Sync in MsgStream do + try + {Obj Msg} + Sync = unit + catch E then + Sync = {Value.failed E} + end + end + end + proc {$ Msg} + Sync = {Port.sendRecv MsgPort Msg} + in + {Wait Sync} + end + end diff --git a/Task/Rendezvous/Oz/rendezvous-3.oz b/Task/Rendezvous/Oz/rendezvous-3.oz new file mode 100644 index 0000000000..6e0fd0b8ab --- /dev/null +++ b/Task/Rendezvous/Oz/rendezvous-3.oz @@ -0,0 +1,30 @@ + Main = {NewActiveSync Printer init(id:1 backup:Reserve)} + Reserve = {NewActiveSync Printer init(id:2)} +in + %% task Humpty Dumpty + thread + try + {Main print("Humpty Dumpty sat on a wall.")} + {Main print("Humpty Dumpty had a great fall.")} + {Main print("All the king's horses and all the king's men")} + {Main print("Couldn't put Humpty together again.")} + catch outOfInk then + {System.showInfo " Humpty Dumpty out of ink!"} + end + end + + %% task Mother Goose + thread + try + {Main print("Old Mother Goose")} + {Main print("When she wanted to wander,")} + {Main print("Would ride through the air")} + {Main print("On a very fine gander.")} + {Main print("Jack's mother came in,")} + {Main print("And caught the goose soon,")} + {Main print("And mounting its back,")} + {Main print("Flew up to the moon.")} + catch outOfInk then + {System.showInfo " Mother Goose out of ink!"} + end + end diff --git a/Task/Rendezvous/PicoLisp/rendezvous-1.l b/Task/Rendezvous/PicoLisp/rendezvous-1.l new file mode 100644 index 0000000000..837b02c7fe --- /dev/null +++ b/Task/Rendezvous/PicoLisp/rendezvous-1.l @@ -0,0 +1,6 @@ +(de rendezvous (Pid . Exe) + (when + (catch '(NIL) + (tell Pid 'setq 'Rendezvous (lit (eval Exe))) + NIL ) + (tell Pid 'quit @) ) ) # Raise caught error in caller diff --git a/Task/Rendezvous/PicoLisp/rendezvous-2.l b/Task/Rendezvous/PicoLisp/rendezvous-2.l new file mode 100644 index 0000000000..1dfc7e4a65 --- /dev/null +++ b/Task/Rendezvous/PicoLisp/rendezvous-2.l @@ -0,0 +1,56 @@ +(de printLine (Str) + (cond + ((gt0 *Ink) (prinl *ID ": " Str) (dec '*Ink)) + (*Backup (rendezvousPrint @ Str) T) + (T (quit "Out of Ink")) ) ) + +(de rendezvousPrint (Printer Str) + (let Rendezvous NIL + (tell Printer 'rendezvous *Pid 'printLine Str) # Call entry point + (unless (wait 6000 Rendezvous) # Block max. 1 minute + (quit "Rendezvous timed out") ) ) ) + +# Start RESERVE printer process +(unless (setq *ReservePrinter (fork)) + (setq *ID 2 *Ink 5) + (wait) ) # Run forever + +# Start MAIN printer process +(unless (setq *MainPrinter (fork)) + (setq *ID 1 *Ink 5 *Backup *ReservePrinter) + (wait) ) + +# Start Humpty Dumpty process +(unless (fork) + (when + (catch '(NIL) + (for Line + (quote + "Humpty Dumpty sat on a wall." + "Humpty Dumpty had a great fall." + "All the king's horses and all the king's men" + "Couldn't put Humpty together again." ) + (rendezvousPrint *MainPrinter Line) ) ) + (prinl " Humpty Dumpty: " @ "!") ) + (bye) ) + +# Start Mother Goose process +(unless (fork) + (when + (catch '(NIL) + (for Line + (quote + "Old Mother Goose" + "When she wanted to wander," + "Would ride through the air" + "On a very fine gander." + "Jack's mother came in," + "And caught the goose soon," + "And mounting its back," + "Flew up to the moon." ) + (rendezvousPrint *MainPrinter Line) ) ) + (prinl " Mother Goose: " @ "!") ) + (bye) ) + +# Prepare to terminate all processes upon exit +(push '*Bye '(tell 'bye)) diff --git a/Task/Rendezvous/Tcl/rendezvous.tcl b/Task/Rendezvous/Tcl/rendezvous.tcl new file mode 100644 index 0000000000..7be1992cba --- /dev/null +++ b/Task/Rendezvous/Tcl/rendezvous.tcl @@ -0,0 +1,157 @@ +package require Tcl 8.6 +package require Thread + +# Really ought to go in a package +eval [set rendezvousEngine { +array set Select {w {} c 0} + +# Turns the task into a coroutine, making it easier to write in "Ada style". +# The real thread ids are stored in shared variables. +proc task {id script} { + global rendezvousEngine + set task [list coroutine RTask eval "$script;thread::exit"] + tsv::set tasks $id [thread::create \ + "$rendezvousEngine;$task;thread::wait"] +} + +# A simple yielding pause. +proc pause t { + after $t [info coroutine] + yield +} + +# Wait for a message. Note that this is *not* pretty code and doesn't do +# everything that the Ada rendezvous does. +proc select args { + global Select + set var [namespace which -variable Select](m[incr Select(c)]) + set messages {} + foreach {message vars body} $args { + dict set messages $message $body + dict set bindings $message $vars + } + lappend Select(w) [list $var [dict keys $messages]] + try { + set Master "" + while {$Master eq ""} { + set Master [yield] + } + lassign $Master message responder payload + foreach vbl [dict get $bindings $message] value $payload { + upvar 1 $vbl v + set v $value + } + set body [dict get $messages $message] + set code [uplevel 1 [list catch $body ::Select(em) ::Select(op)]] + set opts $Select(op) + if {$code == 1} { + dict append opts -errorinfo \ + "\n while processing message\n$message $payload" + } + set $responder [list $code $Select(em) $opts] + } finally { + catch {unset $var} + set Select(w) [lrange $Select(w) 0 end-1] + } +} + +# This acts as a receiver for messages, feeding them into the waiting +# [select]. It is incomplete as it should (but doesn't) queue messages that +# can't be received currently. +proc receive {message args} { + global Select + lassign [lindex $Select(w) end] var messages + if {$message ni $messages} { + throw BAD_MESSAGE "don't know message $message" + } + set responder [namespace which -variable Select](r[incr Select(c)]) + set $responder "" + RTask [list $message $responder $args] + set response [set $responder] + unset responder + after 1 + return $response +} + +# This dispatches a message to a task in another thread. +proc send {target message args} { + after 1 + set t [tsv::get tasks $target] + if {![thread::send $t [list receive $message {*}$args] response]} { + lassign $response code msg opts + return -options $opts $msg + } else { + return -code error $response + } +} +}] + +# The backup printer task. +task BackupPrinter { + set n 5 + while {$n >= 0} { + select Print msg { + if {$n > 0} { + incr n -1 + puts Backup:$msg + } else { + throw OUT_OF_INK "out of ink" + } + } + } +} + +# The main printer task. +task MainPrinter { + set n 5 + set Backup BackupPrinter + while 1 { + select Print msg { + try { + if {$n > 0} { + incr n -1 + puts Main:$msg + } elseif {$Backup ne ""} { + send $Backup Print $msg + } else { + throw OUT_OF_INK "out of ink" + } + } trap OUT_OF_INK {} { + set Backup "" + throw OUT_OF_INK "out of ink" + } + } + } +} + +# Tasks that generate messages to print. +task HumptyDumpty { + pause 100 + try { + send MainPrinter Print "Humpty Dumpty sat on a wall." + send MainPrinter Print "Humpty Dumpty had a great fall." + send MainPrinter Print "All the King's horses and all the King's men" + send MainPrinter Print "Couldn't put Humpty together again." + } trap OUT_OF_INK {} { + puts "Humpty Dumpty out of ink!" + } +} +task MotherGoose { + pause 100 + try { + send MainPrinter Print "Old Mother Goose" + send MainPrinter Print "When she wanted to wander," + send MainPrinter Print "Would ride through the air" + send MainPrinter Print "On a very fine gander." + send MainPrinter Print "Jack's mother came in," + send MainPrinter Print "And caught the goose soon," + send MainPrinter Print "And mounting its back," + send MainPrinter Print "Flew up to the moon." + } trap OUT_OF_INK {} { + puts "Mother Goose out of ink!" + } +} + +# Wait enough time for the example to run and then finish +after 1000 +thread::broadcast thread::exit diff --git a/Task/Repeat-a-string/0DESCRIPTION b/Task/Repeat-a-string/0DESCRIPTION new file mode 100644 index 0000000000..c271ccd070 --- /dev/null +++ b/Task/Repeat-a-string/0DESCRIPTION @@ -0,0 +1,3 @@ +Take a string and repeat it some number of times. Example: repeat("ha", 5) => "hahahahaha" + +If there is a simpler/more efficient way to repeat a single “character” (i.e. creating a string filled with a certain character), you might want to show that as well (i.e. repeat-char("*", 5) => "*****"). diff --git a/Task/Repeat-a-string/1META.yaml b/Task/Repeat-a-string/1META.yaml new file mode 100644 index 0000000000..ae625822b7 --- /dev/null +++ b/Task/Repeat-a-string/1META.yaml @@ -0,0 +1,2 @@ +--- +note: String manipulation diff --git a/Task/Repeat-a-string/4DOS-Batch/repeat-a-string.4dos b/Task/Repeat-a-string/4DOS-Batch/repeat-a-string.4dos new file mode 100644 index 0000000000..6bc96faf4d --- /dev/null +++ b/Task/Repeat-a-string/4DOS-Batch/repeat-a-string.4dos @@ -0,0 +1,10 @@ +gosub repeat ha 5 +echo %@repeat[*,5] +quit + +:Repeat [String Times] + do %Times% + echos %String% + enddo + echo. +return diff --git a/Task/Repeat-a-string/ALGOL-68/repeat-a-string.alg b/Task/Repeat-a-string/ALGOL-68/repeat-a-string.alg new file mode 100644 index 0000000000..de1826ac04 --- /dev/null +++ b/Task/Repeat-a-string/ALGOL-68/repeat-a-string.alg @@ -0,0 +1 @@ +print (5 * "ha") diff --git a/Task/Repeat-a-string/AWK/repeat-a-string.awk b/Task/Repeat-a-string/AWK/repeat-a-string.awk new file mode 100644 index 0000000000..f4274be3e5 --- /dev/null +++ b/Task/Repeat-a-string/AWK/repeat-a-string.awk @@ -0,0 +1,10 @@ +function repeat( str, n, rep, i ) +{ + for( ; i times } diff --git a/Task/Repeat-a-string/Babel/repeat-a-string-2.pb b/Task/Repeat-a-string/Babel/repeat-a-string-2.pb new file mode 100644 index 0000000000..d8dbb13079 --- /dev/null +++ b/Task/Repeat-a-string/Babel/repeat-a-string-2.pb @@ -0,0 +1 @@ +hahahahaha diff --git a/Task/Repeat-a-string/Batch-File/repeat-a-string-1.bat b/Task/Repeat-a-string/Batch-File/repeat-a-string-1.bat new file mode 100644 index 0000000000..69a1827f68 --- /dev/null +++ b/Task/Repeat-a-string/Batch-File/repeat-a-string-1.bat @@ -0,0 +1,8 @@ +@echo off +if "%2" equ "" goto fail +setlocal enabledelayedexpansion +set char=%1 +set num=%2 +for /l %%i in (1,1,%num%) do set res=!res!%char% +echo %res% +:fail diff --git a/Task/Repeat-a-string/Batch-File/repeat-a-string-2.bat b/Task/Repeat-a-string/Batch-File/repeat-a-string-2.bat new file mode 100644 index 0000000000..a982c7f0a1 --- /dev/null +++ b/Task/Repeat-a-string/Batch-File/repeat-a-string-2.bat @@ -0,0 +1,10 @@ +@echo off +set /p a=Enter string to repeat : +set /p b=Enter how many times to repeat : +set "c=1" +set "d=%b%" +:a +echo %a% +set "c=%c%+=1" +if /i _"%c%"==_"%d%" (exit /b) +goto :a diff --git a/Task/Repeat-a-string/Batch-File/repeat-a-string-3.bat b/Task/Repeat-a-string/Batch-File/repeat-a-string-3.bat new file mode 100644 index 0000000000..0060a8db6e --- /dev/null +++ b/Task/Repeat-a-string/Batch-File/repeat-a-string-3.bat @@ -0,0 +1,13 @@ +@echo off +@FOR /L %%i in (0,1,9) DO @CALL :REPEAT %%i +@echo That's it! +@FOR /L %%i in (0,1,9) DO @CALL :REPEAT %%i +@echo. +@echo And that! +@GOTO END + +:REPEAT +@echo|set /p="*" +@GOTO:EOF + +:END diff --git a/Task/Repeat-a-string/Bracmat/repeat-a-string.bracmat b/Task/Repeat-a-string/Bracmat/repeat-a-string.bracmat new file mode 100644 index 0000000000..c776a1909e --- /dev/null +++ b/Task/Repeat-a-string/Bracmat/repeat-a-string.bracmat @@ -0,0 +1,8 @@ +(repeat= + string N rep +. !arg:(?string.?N) + & !string:?rep + & whl + ' (!N+-1:>0:?N&!string !rep:?rep) + & str$!rep +); diff --git a/Task/Repeat-a-string/Brainf---/repeat-a-string.bf b/Task/Repeat-a-string/Brainf---/repeat-a-string.bf new file mode 100644 index 0000000000..b05aa4ffa3 --- /dev/null +++ b/Task/Repeat-a-string/Brainf---/repeat-a-string.bf @@ -0,0 +1,9 @@ ++++++ +++++ init first as 10 counter +[-> +++++ +++++<] we add 10 to second each loopround + + Now we want to loop 5 times to follow std ++++++ +[-> ++++ . ----- -- . +++<] print h and a each loop + +and a newline because I'm kind and it looks good ++++++ +++++ +++ . --- . diff --git a/Task/Repeat-a-string/Brat/repeat-a-string.brat b/Task/Repeat-a-string/Brat/repeat-a-string.brat new file mode 100644 index 0000000000..b9bd4681f1 --- /dev/null +++ b/Task/Repeat-a-string/Brat/repeat-a-string.brat @@ -0,0 +1 @@ +p "ha" * 5 #Prints "hahahahaha" diff --git a/Task/Repeat-a-string/Burlesque/repeat-a-string.blq b/Task/Repeat-a-string/Burlesque/repeat-a-string.blq new file mode 100644 index 0000000000..eefc6373a4 --- /dev/null +++ b/Task/Repeat-a-string/Burlesque/repeat-a-string.blq @@ -0,0 +1,4 @@ +blsq ) 'h5?* +"hhhhh" +blsq ) "ha"5.*\[ +"hahahahaha" diff --git a/Task/Repeat-a-string/C++/repeat-a-string-1.cpp b/Task/Repeat-a-string/C++/repeat-a-string-1.cpp new file mode 100644 index 0000000000..82a773843d --- /dev/null +++ b/Task/Repeat-a-string/C++/repeat-a-string-1.cpp @@ -0,0 +1,15 @@ +#include +#include + +std::string repeat( const std::string &word, int times ) { + std::string result ; + result.reserve(times*word.length()); // avoid repeated reallocation + for ( int a = 0 ; a < times ; a++ ) + result += word ; + return result ; +} + +int main( ) { + std::cout << repeat( "Ha" , 5 ) << std::endl ; + return 0 ; +} diff --git a/Task/Repeat-a-string/C++/repeat-a-string-2.cpp b/Task/Repeat-a-string/C++/repeat-a-string-2.cpp new file mode 100644 index 0000000000..ee608399ce --- /dev/null +++ b/Task/Repeat-a-string/C++/repeat-a-string-2.cpp @@ -0,0 +1,7 @@ +#include +#include + +int main( ) { + std::cout << std::string( 5, '*' ) << std::endl ; + return 0 ; +} diff --git a/Task/Repeat-a-string/C-sharp/repeat-a-string-1.cs b/Task/Repeat-a-string/C-sharp/repeat-a-string-1.cs new file mode 100644 index 0000000000..fa8e49934f --- /dev/null +++ b/Task/Repeat-a-string/C-sharp/repeat-a-string-1.cs @@ -0,0 +1 @@ +string s = "".PadLeft(5, 'X').Replace("X", "ha"); diff --git a/Task/Repeat-a-string/C-sharp/repeat-a-string-2.cs b/Task/Repeat-a-string/C-sharp/repeat-a-string-2.cs new file mode 100644 index 0000000000..e4d3942805 --- /dev/null +++ b/Task/Repeat-a-string/C-sharp/repeat-a-string-2.cs @@ -0,0 +1 @@ +string s = new String('X', 5).Replace("X", "ha"); diff --git a/Task/Repeat-a-string/C-sharp/repeat-a-string-3.cs b/Task/Repeat-a-string/C-sharp/repeat-a-string-3.cs new file mode 100644 index 0000000000..b1fed71a2c --- /dev/null +++ b/Task/Repeat-a-string/C-sharp/repeat-a-string-3.cs @@ -0,0 +1 @@ +string s = String.Join("ha", new string[5 + 1]); diff --git a/Task/Repeat-a-string/C-sharp/repeat-a-string-4.cs b/Task/Repeat-a-string/C-sharp/repeat-a-string-4.cs new file mode 100644 index 0000000000..6f9c911e39 --- /dev/null +++ b/Task/Repeat-a-string/C-sharp/repeat-a-string-4.cs @@ -0,0 +1 @@ +string s = String.Concat(Enumerable.Repeat("ha", 5)); diff --git a/Task/Repeat-a-string/C-sharp/repeat-a-string-5.cs b/Task/Repeat-a-string/C-sharp/repeat-a-string-5.cs new file mode 100644 index 0000000000..4ec3523c16 --- /dev/null +++ b/Task/Repeat-a-string/C-sharp/repeat-a-string-5.cs @@ -0,0 +1 @@ +string s = "".PadLeft(5, '*'); diff --git a/Task/Repeat-a-string/C-sharp/repeat-a-string-6.cs b/Task/Repeat-a-string/C-sharp/repeat-a-string-6.cs new file mode 100644 index 0000000000..5af562275c --- /dev/null +++ b/Task/Repeat-a-string/C-sharp/repeat-a-string-6.cs @@ -0,0 +1 @@ +string s = new String('*', 5); diff --git a/Task/Repeat-a-string/C/repeat-a-string-1.c b/Task/Repeat-a-string/C/repeat-a-string-1.c new file mode 100644 index 0000000000..48da2484d6 --- /dev/null +++ b/Task/Repeat-a-string/C/repeat-a-string-1.c @@ -0,0 +1,22 @@ +#include +#include +#include + +char * string_repeat( int n, const char * s ) { + size_t slen = strlen(s); + char * dest = malloc(n*slen+1); + + int i; char * p; + for ( i=0, p = dest; i < n; ++i, p += slen ) { + memcpy(p, s, slen); + } + *p = '\0'; + return dest; +} + +int main() { + char * result = string_repeat(5, "ha") + puts(result); + free(result); + return 0; +} diff --git a/Task/Repeat-a-string/C/repeat-a-string-2.c b/Task/Repeat-a-string/C/repeat-a-string-2.c new file mode 100644 index 0000000000..86be18df57 --- /dev/null +++ b/Task/Repeat-a-string/C/repeat-a-string-2.c @@ -0,0 +1,13 @@ +... +char *string_repeat(const char *str, int n) +{ + char *pa, *pb; + size_t slen = strlen(str); + char *dest = malloc(n*slen+1); + + pa = dest + (n-1)*slen; + strcpy(pa, str); + pb = --pa + slen; + while (pa>=dest) *pa-- = *pb--; + return dest; +} diff --git a/Task/Repeat-a-string/C/repeat-a-string-3.c b/Task/Repeat-a-string/C/repeat-a-string-3.c new file mode 100644 index 0000000000..58ac95f0fe --- /dev/null +++ b/Task/Repeat-a-string/C/repeat-a-string-3.c @@ -0,0 +1,17 @@ +#include +#include +#include + +char * char_repeat( int n, char c ) { + char * dest = malloc(n+1); + memset(dest, c, n); + dest[n] = '\0'; + return dest; +} + +int main() { + char * result = char_repeat(5, '*'); + puts(result); + free(result); + return 0; +} diff --git a/Task/Repeat-a-string/Clojure/repeat-a-string.clj b/Task/Repeat-a-string/Clojure/repeat-a-string.clj new file mode 100644 index 0000000000..87c062fd94 --- /dev/null +++ b/Task/Repeat-a-string/Clojure/repeat-a-string.clj @@ -0,0 +1 @@ +(apply str (repeat 5 "ha")) diff --git a/Task/Repeat-a-string/Common-Lisp/repeat-a-string-1.lisp b/Task/Repeat-a-string/Common-Lisp/repeat-a-string-1.lisp new file mode 100644 index 0000000000..9da1e0dcb2 --- /dev/null +++ b/Task/Repeat-a-string/Common-Lisp/repeat-a-string-1.lisp @@ -0,0 +1,5 @@ +(defun repeat-string (n string) + (with-output-to-string (stream) + (loop repeat n do (write-string string stream)))) + +(princ (repeat-string 5 "hi")) diff --git a/Task/Repeat-a-string/Common-Lisp/repeat-a-string-2.lisp b/Task/Repeat-a-string/Common-Lisp/repeat-a-string-2.lisp new file mode 100644 index 0000000000..a224195bec --- /dev/null +++ b/Task/Repeat-a-string/Common-Lisp/repeat-a-string-2.lisp @@ -0,0 +1 @@ +(make-string 5 :initial-element #\X) diff --git a/Task/Repeat-a-string/D/repeat-a-string-1.d b/Task/Repeat-a-string/D/repeat-a-string-1.d new file mode 100644 index 0000000000..7f5a72a7b6 --- /dev/null +++ b/Task/Repeat-a-string/D/repeat-a-string-1.d @@ -0,0 +1,5 @@ +import std.stdio, std.array; + +void main() { + writeln("ha".replicate(5)); +} diff --git a/Task/Repeat-a-string/D/repeat-a-string-2.d b/Task/Repeat-a-string/D/repeat-a-string-2.d new file mode 100644 index 0000000000..b8595e5850 --- /dev/null +++ b/Task/Repeat-a-string/D/repeat-a-string-2.d @@ -0,0 +1,8 @@ +import std.stdio; + +void main() { + char[] chars; // create the dynamic array + chars.length = 5; // set the length + chars[] = '*'; // set all characters in the string to '*' + writeln(chars); +} diff --git a/Task/Repeat-a-string/DWScript/repeat-a-string-1.dwscript b/Task/Repeat-a-string/DWScript/repeat-a-string-1.dwscript new file mode 100644 index 0000000000..6f2bd82718 --- /dev/null +++ b/Task/Repeat-a-string/DWScript/repeat-a-string-1.dwscript @@ -0,0 +1 @@ +PrintLn( StringOfString('abc',5) ); diff --git a/Task/Repeat-a-string/DWScript/repeat-a-string-2.dwscript b/Task/Repeat-a-string/DWScript/repeat-a-string-2.dwscript new file mode 100644 index 0000000000..9638424705 --- /dev/null +++ b/Task/Repeat-a-string/DWScript/repeat-a-string-2.dwscript @@ -0,0 +1 @@ +PrintLn( StringOfChar('a',5) ); diff --git a/Task/Repeat-a-string/Delphi/repeat-a-string-1.delphi b/Task/Repeat-a-string/Delphi/repeat-a-string-1.delphi new file mode 100644 index 0000000000..5e51b3f341 --- /dev/null +++ b/Task/Repeat-a-string/Delphi/repeat-a-string-1.delphi @@ -0,0 +1,9 @@ +function RepeatString(const s: string; count: cardinal): string; +var + i: Integer; +begin + for i := 1 to count do + Result := Result + s; +end; + +Writeln(RepeatString('ha',5)); diff --git a/Task/Repeat-a-string/Delphi/repeat-a-string-2.delphi b/Task/Repeat-a-string/Delphi/repeat-a-string-2.delphi new file mode 100644 index 0000000000..1228141dd2 --- /dev/null +++ b/Task/Repeat-a-string/Delphi/repeat-a-string-2.delphi @@ -0,0 +1 @@ +Writeln( StringOfChar('a',5) ); diff --git a/Task/Repeat-a-string/Delphi/repeat-a-string-3.delphi b/Task/Repeat-a-string/Delphi/repeat-a-string-3.delphi new file mode 100644 index 0000000000..dc64f94549 --- /dev/null +++ b/Task/Repeat-a-string/Delphi/repeat-a-string-3.delphi @@ -0,0 +1 @@ +StrUtils.DupeString diff --git a/Task/Repeat-a-string/E/repeat-a-string.e b/Task/Repeat-a-string/E/repeat-a-string.e new file mode 100644 index 0000000000..def4eb99f1 --- /dev/null +++ b/Task/Repeat-a-string/E/repeat-a-string.e @@ -0,0 +1 @@ +"ha" * 5 diff --git a/Task/Repeat-a-string/Erlang/repeat-a-string.erl b/Task/Repeat-a-string/Erlang/repeat-a-string.erl new file mode 100644 index 0000000000..89fca0b2e8 --- /dev/null +++ b/Task/Repeat-a-string/Erlang/repeat-a-string.erl @@ -0,0 +1,2 @@ +repeat(X,N) -> + lists:flatten(lists:duplicate(N,X)). diff --git a/Task/Repeat-a-string/Euphoria/repeat-a-string-1.euphoria b/Task/Repeat-a-string/Euphoria/repeat-a-string-1.euphoria new file mode 100644 index 0000000000..74e8c2005c --- /dev/null +++ b/Task/Repeat-a-string/Euphoria/repeat-a-string-1.euphoria @@ -0,0 +1,16 @@ +function repeat_string(object x, integer times) + sequence out + if atom(x) then + return repeat(x,times) + else + out = "" + for n = 1 to times do + out &= x + end for + return out + end if +end function + +puts(1,repeat_string("ha",5) & '\n') -- hahahahaha + +puts(1,repeat_string('*',5) & '\n') -- ***** diff --git a/Task/Repeat-a-string/Euphoria/repeat-a-string-2.euphoria b/Task/Repeat-a-string/Euphoria/repeat-a-string-2.euphoria new file mode 100644 index 0000000000..0e3cd711eb --- /dev/null +++ b/Task/Repeat-a-string/Euphoria/repeat-a-string-2.euphoria @@ -0,0 +1,4 @@ +-- Here is an alternative method for "Repeat a string" +include std/sequence.e +printf(1,"Here is the repeated string: %s\n", {repeat_pattern("ha",5)}) +printf(1,"Here is another: %s\n", {repeat_pattern("*",5)}) diff --git a/Task/Repeat-a-string/Factor/repeat-a-string.factor b/Task/Repeat-a-string/Factor/repeat-a-string.factor new file mode 100644 index 0000000000..1e08d3fc63 --- /dev/null +++ b/Task/Repeat-a-string/Factor/repeat-a-string.factor @@ -0,0 +1,3 @@ +: repeat-string ( str n -- str' ) swap concat ; + +"ha" 5 repeat-string print diff --git a/Task/Repeat-a-string/Forth/repeat-a-string-1.fth b/Task/Repeat-a-string/Forth/repeat-a-string-1.fth new file mode 100644 index 0000000000..3efcdf6364 --- /dev/null +++ b/Task/Repeat-a-string/Forth/repeat-a-string-1.fth @@ -0,0 +1,6 @@ +: place-n { src len dest n -- } + 0 dest c! + n 0 ?do src len dest +place loop ; + +s" ha" pad 5 place-n +pad count type \ hahahahaha diff --git a/Task/Repeat-a-string/Forth/repeat-a-string-2.fth b/Task/Repeat-a-string/Forth/repeat-a-string-2.fth new file mode 100644 index 0000000000..05c719eda8 --- /dev/null +++ b/Task/Repeat-a-string/Forth/repeat-a-string-2.fth @@ -0,0 +1,7 @@ +: place-n ( src len dest n -- ) + swap >r 0 r@ c! + begin dup while -rot 2dup r@ +place rot 1- repeat + r> 2drop 2drop ; + +s" ha" pad 5 place-n +pad count type \ hahahahaha diff --git a/Task/Repeat-a-string/Forth/repeat-a-string-3.fth b/Task/Repeat-a-string/Forth/repeat-a-string-3.fth new file mode 100644 index 0000000000..fe26e9effc --- /dev/null +++ b/Task/Repeat-a-string/Forth/repeat-a-string-3.fth @@ -0,0 +1,2 @@ +pad 10 char * fill \ repeat a single character +pad 10 type \ ********** diff --git a/Task/Repeat-a-string/Fortran/repeat-a-string.f b/Task/Repeat-a-string/Fortran/repeat-a-string.f new file mode 100644 index 0000000000..b7c82ebfd4 --- /dev/null +++ b/Task/Repeat-a-string/Fortran/repeat-a-string.f @@ -0,0 +1,5 @@ +program test_repeat + + write (*, '(a)') repeat ('ha', 5) + +end program test_repeat diff --git a/Task/Repeat-a-string/Frink/repeat-a-string.frink b/Task/Repeat-a-string/Frink/repeat-a-string.frink new file mode 100644 index 0000000000..0600962c5a --- /dev/null +++ b/Task/Repeat-a-string/Frink/repeat-a-string.frink @@ -0,0 +1 @@ +println[repeat["ha", 5]] diff --git a/Task/Repeat-a-string/GAP/repeat-a-string.gap b/Task/Repeat-a-string/GAP/repeat-a-string.gap new file mode 100644 index 0000000000..4d0aa25728 --- /dev/null +++ b/Task/Repeat-a-string/GAP/repeat-a-string.gap @@ -0,0 +1,2 @@ +Concatenation(List([1 .. 10], n -> "BOB ")); +# "BOB BOB BOB BOB BOB BOB BOB BOB BOB BOB " diff --git a/Task/Repeat-a-string/Go/repeat-a-string-1.go b/Task/Repeat-a-string/Go/repeat-a-string-1.go new file mode 100644 index 0000000000..303b808ecb --- /dev/null +++ b/Task/Repeat-a-string/Go/repeat-a-string-1.go @@ -0,0 +1 @@ +fmt.Println(strings.Repeat("ha", 5)) // ==> "hahahahaha" diff --git a/Task/Repeat-a-string/Go/repeat-a-string-2.go b/Task/Repeat-a-string/Go/repeat-a-string-2.go new file mode 100644 index 0000000000..94cdae0118 --- /dev/null +++ b/Task/Repeat-a-string/Go/repeat-a-string-2.go @@ -0,0 +1 @@ +fmt.Println(strings.Repeat(string('h'), 5)) // prints hhhhh diff --git a/Task/Repeat-a-string/Groovy/repeat-a-string.groovy b/Task/Repeat-a-string/Groovy/repeat-a-string.groovy new file mode 100644 index 0000000000..58efeef6f6 --- /dev/null +++ b/Task/Repeat-a-string/Groovy/repeat-a-string.groovy @@ -0,0 +1 @@ + println 'ha' * 5 diff --git a/Task/Repeat-a-string/Haskell/repeat-a-string-1.hs b/Task/Repeat-a-string/Haskell/repeat-a-string-1.hs new file mode 100644 index 0000000000..4c6d0dbef2 --- /dev/null +++ b/Task/Repeat-a-string/Haskell/repeat-a-string-1.hs @@ -0,0 +1 @@ +concat $ replicate 5 "ha" diff --git a/Task/Repeat-a-string/Haskell/repeat-a-string-2.hs b/Task/Repeat-a-string/Haskell/repeat-a-string-2.hs new file mode 100644 index 0000000000..a3012a974f --- /dev/null +++ b/Task/Repeat-a-string/Haskell/repeat-a-string-2.hs @@ -0,0 +1 @@ +[1..5] >> "ha" diff --git a/Task/Repeat-a-string/Haskell/repeat-a-string-3.hs b/Task/Repeat-a-string/Haskell/repeat-a-string-3.hs new file mode 100644 index 0000000000..0576d95f03 --- /dev/null +++ b/Task/Repeat-a-string/Haskell/repeat-a-string-3.hs @@ -0,0 +1 @@ +cycle "ha" diff --git a/Task/Repeat-a-string/Haskell/repeat-a-string-4.hs b/Task/Repeat-a-string/Haskell/repeat-a-string-4.hs new file mode 100644 index 0000000000..8ca2a5503a --- /dev/null +++ b/Task/Repeat-a-string/Haskell/repeat-a-string-4.hs @@ -0,0 +1 @@ +replicate 5 '*' diff --git a/Task/Repeat-a-string/HicEst/repeat-a-string.hicest b/Task/Repeat-a-string/HicEst/repeat-a-string.hicest new file mode 100644 index 0000000000..6786e89e9a --- /dev/null +++ b/Task/Repeat-a-string/HicEst/repeat-a-string.hicest @@ -0,0 +1,3 @@ +CHARACTER out*20 + +EDIT(Text=out, Insert="ha", DO=5) diff --git a/Task/Repeat-a-string/Icon/repeat-a-string-1.icon b/Task/Repeat-a-string/Icon/repeat-a-string-1.icon new file mode 100644 index 0000000000..35b154103a --- /dev/null +++ b/Task/Repeat-a-string/Icon/repeat-a-string-1.icon @@ -0,0 +1,3 @@ +procedure main(args) + write(repl(integer(!args) | 5)) +end diff --git a/Task/Repeat-a-string/Icon/repeat-a-string-2.icon b/Task/Repeat-a-string/Icon/repeat-a-string-2.icon new file mode 100644 index 0000000000..407a49833d --- /dev/null +++ b/Task/Repeat-a-string/Icon/repeat-a-string-2.icon @@ -0,0 +1,4 @@ +procedure repl(s, n) + every (ns := "") ||:= |s\(0 <= n) + return ns +end diff --git a/Task/Repeat-a-string/Inform-7/repeat-a-string.inf b/Task/Repeat-a-string/Inform-7/repeat-a-string.inf new file mode 100644 index 0000000000..0e283966cd --- /dev/null +++ b/Task/Repeat-a-string/Inform-7/repeat-a-string.inf @@ -0,0 +1,11 @@ +Home is a room. + +To decide which indexed text is (T - indexed text) repeated (N - number) times: + let temp be indexed text; + repeat with M running from 1 to N: + let temp be "[temp][T]"; + decide on temp. + +When play begins: + say "ha" repeated 5 times; + end the story. diff --git a/Task/Repeat-a-string/J/repeat-a-string.j b/Task/Repeat-a-string/J/repeat-a-string.j new file mode 100644 index 0000000000..4ea8827517 --- /dev/null +++ b/Task/Repeat-a-string/J/repeat-a-string.j @@ -0,0 +1,8 @@ + 5 # '*' NB. repeat each item 5 times +***** + 5 # 'ha' NB. repeat each item 5 times +hhhhhaaaaa + 5 ((* #) $ ]) 'ha' NB. repeat array 5 times +hahahahaha + 5 ;@# < 'ha' NB. boxing is used to treat the array as a whole +hahahahaha diff --git a/Task/Repeat-a-string/Java/repeat-a-string-1.java b/Task/Repeat-a-string/Java/repeat-a-string-1.java new file mode 100644 index 0000000000..f77d853a7b --- /dev/null +++ b/Task/Repeat-a-string/Java/repeat-a-string-1.java @@ -0,0 +1,9 @@ +public static String repeat(String str, int times){ + StringBuilder ret = new StringBuilder(); + for(int i = 0;i < times;i++) ret.append(str); + return ret.toString(); +} + +public static void main(String[] args){ + System.out.println(repeat("ha", 5)); +} diff --git a/Task/Repeat-a-string/Java/repeat-a-string-2.java b/Task/Repeat-a-string/Java/repeat-a-string-2.java new file mode 100644 index 0000000000..a843ebc700 --- /dev/null +++ b/Task/Repeat-a-string/Java/repeat-a-string-2.java @@ -0,0 +1,3 @@ +public static String repeat(String str, int times){ + return new String(new char[times]).replace("\0", str); +} diff --git a/Task/Repeat-a-string/JavaScript/repeat-a-string.js b/Task/Repeat-a-string/JavaScript/repeat-a-string.js new file mode 100644 index 0000000000..ed4f8cec4b --- /dev/null +++ b/Task/Repeat-a-string/JavaScript/repeat-a-string.js @@ -0,0 +1,5 @@ +String.prototype.repeat = function(n) { + return new Array(1 + n).join(this); +} + +alert("ha".repeat(5)); // hahahahaha diff --git a/Task/Repeat-a-string/Julia/repeat-a-string.julia b/Task/Repeat-a-string/Julia/repeat-a-string.julia new file mode 100644 index 0000000000..61dfc34329 --- /dev/null +++ b/Task/Repeat-a-string/Julia/repeat-a-string.julia @@ -0,0 +1,2 @@ +"ha"^5 +'*'^5 diff --git a/Task/Repeat-a-string/K/repeat-a-string.k b/Task/Repeat-a-string/K/repeat-a-string.k new file mode 100644 index 0000000000..9934307462 --- /dev/null +++ b/Task/Repeat-a-string/K/repeat-a-string.k @@ -0,0 +1,5 @@ + ,/5#,"ha" +"hahahahaha" + + 5#"*" +"*****" diff --git a/Task/Repeat-a-string/Liberty-BASIC/repeat-a-string.liberty b/Task/Repeat-a-string/Liberty-BASIC/repeat-a-string.liberty new file mode 100644 index 0000000000..3eda4bb633 --- /dev/null +++ b/Task/Repeat-a-string/Liberty-BASIC/repeat-a-string.liberty @@ -0,0 +1,12 @@ +a$ ="ha " +print StringRepeat$( a$, 5) + +end + +function StringRepeat$( in$, n) + o$ ="" + for i =1 to n + o$ =o$ +in$ + next i + StringRepeat$ =o$ +end function diff --git a/Task/Repeat-a-string/Logo/repeat-a-string-1.logo b/Task/Repeat-a-string/Logo/repeat-a-string-1.logo new file mode 100644 index 0000000000..4f94ac26c5 --- /dev/null +++ b/Task/Repeat-a-string/Logo/repeat-a-string-1.logo @@ -0,0 +1,4 @@ +to copies :n :thing [:acc "||] + if :n = 0 [output :acc] + output (copies :n-1 :thing combine :acc :thing) +end diff --git a/Task/Repeat-a-string/Logo/repeat-a-string-2.logo b/Task/Repeat-a-string/Logo/repeat-a-string-2.logo new file mode 100644 index 0000000000..9ce0043ce6 --- /dev/null +++ b/Task/Repeat-a-string/Logo/repeat-a-string-2.logo @@ -0,0 +1 @@ +show cascade 5 [combine "ha ?] "|| ; hahahahaha diff --git a/Task/Repeat-a-string/Logo/repeat-a-string-3.logo b/Task/Repeat-a-string/Logo/repeat-a-string-3.logo new file mode 100644 index 0000000000..dcd00dad2d --- /dev/null +++ b/Task/Repeat-a-string/Logo/repeat-a-string-3.logo @@ -0,0 +1,6 @@ +to copies :n :thing :acc + if :n = 0 [output :acc] + output (copies :n-1 :thing combine :acc :thing) +end + +print copies 5 "ha "|| diff --git a/Task/Repeat-a-string/Lua/repeat-a-string-1.lua b/Task/Repeat-a-string/Lua/repeat-a-string-1.lua new file mode 100644 index 0000000000..0a8d3c53f8 --- /dev/null +++ b/Task/Repeat-a-string/Lua/repeat-a-string-1.lua @@ -0,0 +1 @@ +function repeats(s, n) return n > 0 and s .. repeat(s, n-1) or "" end diff --git a/Task/Repeat-a-string/Lua/repeat-a-string-2.lua b/Task/Repeat-a-string/Lua/repeat-a-string-2.lua new file mode 100644 index 0000000000..2f975e4142 --- /dev/null +++ b/Task/Repeat-a-string/Lua/repeat-a-string-2.lua @@ -0,0 +1 @@ +string.rep(s,n) diff --git a/Task/Repeat-a-string/MATLAB/repeat-a-string.m b/Task/Repeat-a-string/MATLAB/repeat-a-string.m new file mode 100644 index 0000000000..fcbc3cce59 --- /dev/null +++ b/Task/Repeat-a-string/MATLAB/repeat-a-string.m @@ -0,0 +1,3 @@ +function S = repeat(s , n) + S = repmat(s , [1,n]) ; +return diff --git a/Task/Repeat-a-string/MUMPS/repeat-a-string-1.mumps b/Task/Repeat-a-string/MUMPS/repeat-a-string-1.mumps new file mode 100644 index 0000000000..7f8d9762f6 --- /dev/null +++ b/Task/Repeat-a-string/MUMPS/repeat-a-string-1.mumps @@ -0,0 +1,9 @@ +RPTSTR(S,N) + ;Repeat a string S for N times + NEW I + FOR I=1:1:N WRITE S + KILL I + QUIT +RPTSTR1(S,N) ;Functionally equivalent, but denser to read + F I=1:1:N W S + Q diff --git a/Task/Repeat-a-string/MUMPS/repeat-a-string-2.mumps b/Task/Repeat-a-string/MUMPS/repeat-a-string-2.mumps new file mode 100644 index 0000000000..424b49b7e6 --- /dev/null +++ b/Task/Repeat-a-string/MUMPS/repeat-a-string-2.mumps @@ -0,0 +1,3 @@ + ;Even better (more terse) + S x="",$P(x,"-",10)="-" + W x diff --git a/Task/Repeat-a-string/Maple/repeat-a-string-1.maple b/Task/Repeat-a-string/Maple/repeat-a-string-1.maple new file mode 100644 index 0000000000..ea7b6c9f43 --- /dev/null +++ b/Task/Repeat-a-string/Maple/repeat-a-string-1.maple @@ -0,0 +1,7 @@ +> use StringTools in +> Repeat( "abc", 10 ); # repeat an arbitrary string +> Fill( "x", 20 ) # repeat a character +> end use; + "abcabcabcabcabcabcabcabcabcabc" + + "xxxxxxxxxxxxxxxxxxxx" diff --git a/Task/Repeat-a-string/Maple/repeat-a-string-2.maple b/Task/Repeat-a-string/Maple/repeat-a-string-2.maple new file mode 100644 index 0000000000..8a0d3a6d02 --- /dev/null +++ b/Task/Repeat-a-string/Maple/repeat-a-string-2.maple @@ -0,0 +1,5 @@ +> cat( "abc" $ 10 ); + "abcabcabcabcabcabcabcabcabcabc" + +> cat( seq( "abc", i = 1 .. 10 ) ); + "abcabcabcabcabcabcabcabcabcabc" diff --git a/Task/Repeat-a-string/Maple/repeat-a-string-3.maple b/Task/Repeat-a-string/Maple/repeat-a-string-3.maple new file mode 100644 index 0000000000..0c15db5dcf --- /dev/null +++ b/Task/Repeat-a-string/Maple/repeat-a-string-3.maple @@ -0,0 +1,3 @@ +> s := "": +> to 10 do s := cat( s, "abc" ) end: s; + "abcabcabcabcabcabcabcabcabcabc" diff --git a/Task/Repeat-a-string/Mathematica/repeat-a-string.math b/Task/Repeat-a-string/Mathematica/repeat-a-string.math new file mode 100644 index 0000000000..1238dcd09b --- /dev/null +++ b/Task/Repeat-a-string/Mathematica/repeat-a-string.math @@ -0,0 +1,8 @@ +(* solution 1 *) +rep[n_Integer,s_String]:=Apply[StringJoin,ConstantArray[s,{n}]] + +(* solution 2 -- @@ is the infix form of Apply[] *) +rep[n_Integer,s_String]:=StringJoin@@Table[s,{n}] + +(* solution 3 -- demonstrating another of the large number of looping constructs available *) +rep[n_Integer,s_String]:=Nest[StringJoin[s, #] &,s,n-1] diff --git a/Task/Repeat-a-string/Maxima/repeat-a-string.maxima b/Task/Repeat-a-string/Maxima/repeat-a-string.maxima new file mode 100644 index 0000000000..046867f63e --- /dev/null +++ b/Task/Repeat-a-string/Maxima/repeat-a-string.maxima @@ -0,0 +1,5 @@ +"$*"(s, n) := apply(sconcat, makelist(s, n))$ +infix("$*")$ + +"abc" $* 5; +/* "abcabcabcabcabc" */ diff --git a/Task/Repeat-a-string/Mercury/repeat-a-string.mercury b/Task/Repeat-a-string/Mercury/repeat-a-string.mercury new file mode 100644 index 0000000000..1e9150443a --- /dev/null +++ b/Task/Repeat-a-string/Mercury/repeat-a-string.mercury @@ -0,0 +1,26 @@ +:- module repeat. +:- interface. +:- import_module string, char, int. + +:- func repeat_char(char, int) = string. +:- func repeat(string, int) = string. + +:- implementation. +:- import_module stream, stream.string_writer, string.builder. + +repeat_char(C, N) = string.duplicate_char(C, N). + +repeat(String, Count) = Repeated :- + S0 = string.builder.init, + Repeated = string.builder.to_string(S), + printn(string.builder.handle, Count, String, S0, S). + +:- pred printn(Stream, int, string, State, State) + <= (stream.writer(Stream, string, State), + stream.writer(Stream, character, State)). +:- mode printn(in, in, in, di, uo) is det. +printn(Stream, N, String, !S) :- + ( N > 0 -> + print(Stream, String, !S), + printn(Stream, N - 1, String, !S) + ; true ). diff --git a/Task/Repeat-a-string/Mirah/repeat-a-string.mirah b/Task/Repeat-a-string/Mirah/repeat-a-string.mirah new file mode 100644 index 0000000000..7020b649bc --- /dev/null +++ b/Task/Repeat-a-string/Mirah/repeat-a-string.mirah @@ -0,0 +1,7 @@ +x = StringBuilder.new + +5.times do + x.append "ha" +end + +puts x # ==> "hahahahaha" diff --git a/Task/Repeat-a-string/NetRexx/repeat-a-string-1.netrexx b/Task/Repeat-a-string/NetRexx/repeat-a-string-1.netrexx new file mode 100644 index 0000000000..b5bf763779 --- /dev/null +++ b/Task/Repeat-a-string/NetRexx/repeat-a-string-1.netrexx @@ -0,0 +1,3 @@ +/* NetRexx */ + +ha5 = 'ha'.copies(5) diff --git a/Task/Repeat-a-string/NetRexx/repeat-a-string-2.netrexx b/Task/Repeat-a-string/NetRexx/repeat-a-string-2.netrexx new file mode 100644 index 0000000000..0185f336a6 --- /dev/null +++ b/Task/Repeat-a-string/NetRexx/repeat-a-string-2.netrexx @@ -0,0 +1,12 @@ +/* NetRexx */ +sampleStr = 'ha' -- string to duplicate +say ' COPIES:' sampleStr.copies(5) +say 'CHANGESTR:' '.....'.changestr('.', sampleStr) + +sampleChr = '*' -- character to duplicate +say ' LEFT:' sampleChr.left(5, sampleChr) +say ' RIGHT:' sampleChr.right(5, sampleChr) +say ' CENTRE:' sampleChr.centre(5, sampleChr) +say ' OVERLAY:' sampleChr.overlay(sampleChr, 1, 5, sampleChr) +say ' SUBSTR:' ''.substr(1, 5, sampleChr) +say 'TRANSLATE:' '.....'.translate(sampleChr, '.') diff --git a/Task/Repeat-a-string/NewLISP/repeat-a-string.newlisp b/Task/Repeat-a-string/NewLISP/repeat-a-string.newlisp new file mode 100644 index 0000000000..b8c1edc033 --- /dev/null +++ b/Task/Repeat-a-string/NewLISP/repeat-a-string.newlisp @@ -0,0 +1 @@ +(dup "ha" 5) diff --git a/Task/Repeat-a-string/OCaml/repeat-a-string-1.ocaml b/Task/Repeat-a-string/OCaml/repeat-a-string-1.ocaml new file mode 100644 index 0000000000..49216afd99 --- /dev/null +++ b/Task/Repeat-a-string/OCaml/repeat-a-string-1.ocaml @@ -0,0 +1,8 @@ +let string_repeat s n = + let len = String.length s in + let res = String.create(n * len) in + for i = 0 to pred n do + String.blit s 0 res (i * len) len; + done; + (res) +;; diff --git a/Task/Repeat-a-string/OCaml/repeat-a-string-2.ocaml b/Task/Repeat-a-string/OCaml/repeat-a-string-2.ocaml new file mode 100644 index 0000000000..2e347b1cff --- /dev/null +++ b/Task/Repeat-a-string/OCaml/repeat-a-string-2.ocaml @@ -0,0 +1,2 @@ +# string_repeat "Hiuoa" 3 ;; +- : string = "HiuoaHiuoaHiuoa" diff --git a/Task/Repeat-a-string/OCaml/repeat-a-string-3.ocaml b/Task/Repeat-a-string/OCaml/repeat-a-string-3.ocaml new file mode 100644 index 0000000000..d388be7490 --- /dev/null +++ b/Task/Repeat-a-string/OCaml/repeat-a-string-3.ocaml @@ -0,0 +1,3 @@ +let string_repeat s n = + String.concat "" (Array.to_list (Array.make n s)) +;; diff --git a/Task/Repeat-a-string/OCaml/repeat-a-string-4.ocaml b/Task/Repeat-a-string/OCaml/repeat-a-string-4.ocaml new file mode 100644 index 0000000000..7914dfb1c7 --- /dev/null +++ b/Task/Repeat-a-string/OCaml/repeat-a-string-4.ocaml @@ -0,0 +1,3 @@ +let string_repeat s n = + Array.fold_left (^) "" (Array.make n s) +;; diff --git a/Task/Repeat-a-string/OCaml/repeat-a-string-5.ocaml b/Task/Repeat-a-string/OCaml/repeat-a-string-5.ocaml new file mode 100644 index 0000000000..a3b44b8b1f --- /dev/null +++ b/Task/Repeat-a-string/OCaml/repeat-a-string-5.ocaml @@ -0,0 +1 @@ +String.make 5 '*' diff --git a/Task/Repeat-a-string/Objeck/repeat-a-string.objeck b/Task/Repeat-a-string/Objeck/repeat-a-string.objeck new file mode 100644 index 0000000000..83ec13631b --- /dev/null +++ b/Task/Repeat-a-string/Objeck/repeat-a-string.objeck @@ -0,0 +1,16 @@ +bundle Default { + class Repeat { + function : Main(args : String[]) ~ Nil { + Repeat("ha", 5)->PrintLine(); + } + + function : Repeat(string : String, max : Int) ~ String { + repeat : String := String->New(); + for(i := 0; i < max; i += 1;) { + repeat->Append(string); + }; + + return repeat; + } + } +} diff --git a/Task/Repeat-a-string/Objective-C/repeat-a-string-1.m b/Task/Repeat-a-string/Objective-C/repeat-a-string-1.m new file mode 100644 index 0000000000..c146a9633b --- /dev/null +++ b/Task/Repeat-a-string/Objective-C/repeat-a-string-1.m @@ -0,0 +1,9 @@ +@interface NSString (RosettaCodeAddition) +- (NSString *) repeatStringByNumberOfTimes: (NSUInteger) times; +@end + +@implementation NSString (RosettaCodeAddition) +- (NSString *) repeatStringByNumberOfTimes: (NSUInteger) times { + return [@"" stringByPaddingToLength:[self length]*times withString:self startingAtIndex:0]; +} +@end diff --git a/Task/Repeat-a-string/Objective-C/repeat-a-string-2.m b/Task/Repeat-a-string/Objective-C/repeat-a-string-2.m new file mode 100644 index 0000000000..55bad05212 --- /dev/null +++ b/Task/Repeat-a-string/Objective-C/repeat-a-string-2.m @@ -0,0 +1,6 @@ + // Instantiate an NSString by sending an NSString literal our new + // -repeatByNumberOfTimes: selector. + NSString *aString = [@"ha" repeatStringByNumberOfTimes:5]; + + // Display the NSString. + NSLog(@"%@", aString); diff --git a/Task/Repeat-a-string/OpenEdge-Progress/repeat-a-string.openedge b/Task/Repeat-a-string/OpenEdge-Progress/repeat-a-string.openedge new file mode 100644 index 0000000000..cd878296a3 --- /dev/null +++ b/Task/Repeat-a-string/OpenEdge-Progress/repeat-a-string.openedge @@ -0,0 +1 @@ +MESSAGE FILL( "ha", 5 ) VIEW-AS ALERT-BOX. diff --git a/Task/Repeat-a-string/OxygenBasic/repeat-a-string.oxy b/Task/Repeat-a-string/OxygenBasic/repeat-a-string.oxy new file mode 100644 index 0000000000..3f25829e8a --- /dev/null +++ b/Task/Repeat-a-string/OxygenBasic/repeat-a-string.oxy @@ -0,0 +1,18 @@ +'REPEATING A CHARACTER + +print string 10,"A" 'result AAAAAAAAAA + +'REPEATING A STRING + +function RepeatString(string s,sys n) as string + sys i, le=len s + if le=0 then exit function + n*=le + function=nuls n + ' + for i=1 to n step le + mid function,i,s + next +end function + +print RepeatString "ABC",3 'result ABCABCABC diff --git a/Task/Repeat-a-string/Oz/repeat-a-string.oz b/Task/Repeat-a-string/Oz/repeat-a-string.oz new file mode 100644 index 0000000000..7f42ff3989 --- /dev/null +++ b/Task/Repeat-a-string/Oz/repeat-a-string.oz @@ -0,0 +1,10 @@ +declare + fun {Repeat Xs N} + if N > 0 then + {Append Xs {Repeat Xs N-1}} + else + nil + end + end +in + {System.showInfo {Repeat "Ha" 5}} diff --git a/Task/Repeat-a-string/PARI-GP/repeat-a-string.pari b/Task/Repeat-a-string/PARI-GP/repeat-a-string.pari new file mode 100644 index 0000000000..e20d02c408 --- /dev/null +++ b/Task/Repeat-a-string/PARI-GP/repeat-a-string.pari @@ -0,0 +1,3 @@ +repeat(s,n)={ + if(n, Str(repeat(s, n-1), s), "") +}; diff --git a/Task/Repeat-a-string/PHP/repeat-a-string.php b/Task/Repeat-a-string/PHP/repeat-a-string.php new file mode 100644 index 0000000000..7e195461e2 --- /dev/null +++ b/Task/Repeat-a-string/PHP/repeat-a-string.php @@ -0,0 +1 @@ +str_repeat("ha", 5) diff --git a/Task/Repeat-a-string/PL-I/repeat-a-string.pli b/Task/Repeat-a-string/PL-I/repeat-a-string.pli new file mode 100644 index 0000000000..4cedcc8877 --- /dev/null +++ b/Task/Repeat-a-string/PL-I/repeat-a-string.pli @@ -0,0 +1,5 @@ +s = copy('ha', 5); + +/* To repeat a single character a fixed number of times: */ + +s = (5)'h'; /* asigns 'hhhhh' to s. */ diff --git a/Task/Repeat-a-string/Perl-6/repeat-a-string.pl6 b/Task/Repeat-a-string/Perl-6/repeat-a-string.pl6 new file mode 100644 index 0000000000..a9ae20555f --- /dev/null +++ b/Task/Repeat-a-string/Perl-6/repeat-a-string.pl6 @@ -0,0 +1 @@ +"ha" x 5 diff --git a/Task/Repeat-a-string/Perl/repeat-a-string.pl b/Task/Repeat-a-string/Perl/repeat-a-string.pl new file mode 100644 index 0000000000..a9ae20555f --- /dev/null +++ b/Task/Repeat-a-string/Perl/repeat-a-string.pl @@ -0,0 +1 @@ +"ha" x 5 diff --git a/Task/Repeat-a-string/PicoLisp/repeat-a-string-1.l b/Task/Repeat-a-string/PicoLisp/repeat-a-string-1.l new file mode 100644 index 0000000000..e7f1f66a11 --- /dev/null +++ b/Task/Repeat-a-string/PicoLisp/repeat-a-string-1.l @@ -0,0 +1,2 @@ +(pack (need 5 "ha")) +-> "hahahahaha" diff --git a/Task/Repeat-a-string/PicoLisp/repeat-a-string-2.l b/Task/Repeat-a-string/PicoLisp/repeat-a-string-2.l new file mode 100644 index 0000000000..31dee1ce6f --- /dev/null +++ b/Task/Repeat-a-string/PicoLisp/repeat-a-string-2.l @@ -0,0 +1,2 @@ +(pack (make (do 5 (link "ha")))) +-> "hahahahaha" diff --git a/Task/Repeat-a-string/Pike/repeat-a-string.pike b/Task/Repeat-a-string/Pike/repeat-a-string.pike new file mode 100644 index 0000000000..65c6f2c7e1 --- /dev/null +++ b/Task/Repeat-a-string/Pike/repeat-a-string.pike @@ -0,0 +1 @@ +"ha"*5; diff --git a/Task/Repeat-a-string/PostScript/repeat-a-string.ps b/Task/Repeat-a-string/PostScript/repeat-a-string.ps new file mode 100644 index 0000000000..d03df45465 --- /dev/null +++ b/Task/Repeat-a-string/PostScript/repeat-a-string.ps @@ -0,0 +1,19 @@ +% the comments show the stack content after the line was executed +% where rcount is the repeat count, "o" is for orignal, +% "f" is for final, and iter is the for loop variable +% +% usage: rcount ostring times -> fstring + +/times { + dup length dup % rcount ostring olength olength + 4 3 roll % ostring olength olength rcount + mul dup string % ostring olength flength fstring + 4 1 roll % fstring ostring olength flength + 1 sub 0 3 1 roll % fstring ostring 0 olength flength_minus_one + { % fstring ostring iter + 1 index 3 index % fstring ostring iter ostring fstring + 3 1 roll % fstring ostring fstring iter ostring + putinterval % fstring ostring + } for + pop % fstring +} def diff --git a/Task/Repeat-a-string/PowerBASIC/repeat-a-string.powerbasic b/Task/Repeat-a-string/PowerBASIC/repeat-a-string.powerbasic new file mode 100644 index 0000000000..634e157f1d --- /dev/null +++ b/Task/Repeat-a-string/PowerBASIC/repeat-a-string.powerbasic @@ -0,0 +1 @@ +MSGBOX REPEAT$(5, "ha") diff --git a/Task/Repeat-a-string/PowerShell/repeat-a-string.psh b/Task/Repeat-a-string/PowerShell/repeat-a-string.psh new file mode 100644 index 0000000000..0cf142bf02 --- /dev/null +++ b/Task/Repeat-a-string/PowerShell/repeat-a-string.psh @@ -0,0 +1 @@ +"ha" * 5 # ==> "hahahahaha" diff --git a/Task/Repeat-a-string/Prolog/repeat-a-string.pro b/Task/Repeat-a-string/Prolog/repeat-a-string.pro new file mode 100644 index 0000000000..f8d8a5727f --- /dev/null +++ b/Task/Repeat-a-string/Prolog/repeat-a-string.pro @@ -0,0 +1,6 @@ +%repeat(Str,Num,Res). +repeat(Str,1,Str). +repeat(Str,Num,Res):- + Num1 is Num-1, + repeat(Str,Num1,Res1), + string_concat(Str, Res1, Res). diff --git a/Task/Repeat-a-string/Pure/repeat-a-string.pure b/Task/Repeat-a-string/Pure/repeat-a-string.pure new file mode 100644 index 0000000000..f19503ff3d --- /dev/null +++ b/Task/Repeat-a-string/Pure/repeat-a-string.pure @@ -0,0 +1,5 @@ +> str_repeat 0 s = ""; +> str_repeat n s = s + (str_repeat (n-1) s) if n>0; +> str_repeat 5 "ha"; +"hahahahaha" +> diff --git a/Task/Repeat-a-string/PureBasic/repeat-a-string.purebasic b/Task/Repeat-a-string/PureBasic/repeat-a-string.purebasic new file mode 100644 index 0000000000..2918b454b3 --- /dev/null +++ b/Task/Repeat-a-string/PureBasic/repeat-a-string.purebasic @@ -0,0 +1,10 @@ +Procedure.s RepeatString(count, text$=" ") + Protected i, ret$="" + + For i = 1 To count + ret$ + text$ + Next + ProcedureReturn ret$ +EndProcedure + +Debug RepeatString(5, "ha") diff --git a/Task/Repeat-a-string/Python/repeat-a-string-1.py b/Task/Repeat-a-string/Python/repeat-a-string-1.py new file mode 100644 index 0000000000..0cf142bf02 --- /dev/null +++ b/Task/Repeat-a-string/Python/repeat-a-string-1.py @@ -0,0 +1 @@ +"ha" * 5 # ==> "hahahahaha" diff --git a/Task/Repeat-a-string/Python/repeat-a-string-2.py b/Task/Repeat-a-string/Python/repeat-a-string-2.py new file mode 100644 index 0000000000..6a7e7eea68 --- /dev/null +++ b/Task/Repeat-a-string/Python/repeat-a-string-2.py @@ -0,0 +1 @@ +5 * "ha" # ==> "hahahahaha" diff --git a/Task/Repeat-a-string/R/repeat-a-string.r b/Task/Repeat-a-string/R/repeat-a-string.r new file mode 100644 index 0000000000..6b7649dfc9 --- /dev/null +++ b/Task/Repeat-a-string/R/repeat-a-string.r @@ -0,0 +1 @@ +paste(rep("ha",5), collapse='') diff --git a/Task/Repeat-a-string/REALbasic/repeat-a-string.realbasic b/Task/Repeat-a-string/REALbasic/repeat-a-string.realbasic new file mode 100644 index 0000000000..fe1131421b --- /dev/null +++ b/Task/Repeat-a-string/REALbasic/repeat-a-string.realbasic @@ -0,0 +1,7 @@ +Function Repeat(s As String, count As Integer) As String + Dim output As String + For i As Integer = 0 To count + output = output + s + Next + Return output +End Function diff --git a/Task/Repeat-a-string/REBOL/repeat-a-string.rebol b/Task/Repeat-a-string/REBOL/repeat-a-string.rebol new file mode 100644 index 0000000000..b5fde4e8bf --- /dev/null +++ b/Task/Repeat-a-string/REBOL/repeat-a-string.rebol @@ -0,0 +1 @@ +head insert/dup "" "ha" 5 diff --git a/Task/Repeat-a-string/REXX/repeat-a-string.rexx b/Task/Repeat-a-string/REXX/repeat-a-string.rexx new file mode 100644 index 0000000000..c3a61f581e --- /dev/null +++ b/Task/Repeat-a-string/REXX/repeat-a-string.rexx @@ -0,0 +1,118 @@ +/*REXX program to show various ways to repeat a string (or repeat a single char).*/ + +/*all examples are equivalent, but not created equal.*/ + + /*───────────────────────────────────────────*/ +y='ha' +z=copies(y,5) + /*───────────────────────────────────────────*/ +z=copies( 'ha', 5 ) + /*───────────────────────────────────────────*/ +y='ha' +z=y||y||y||y||y + /*───────────────────────────────────────────*/ +y='ha' +z=y || y || y || y || y /*same as previous, but the "big sky" version*/ + /*───────────────────────────────────────────*/ +y='ha' +z='' + do 5 + z=z||y + end + /*───────────────────────────────────────────*/ +y="ha" +z= + do 5 + z=z||y + end + /*───────────────────────────────────────────*/ +y="ha" +z= + do i=101 to 105 + z=z||y + end + + /*───────────────────────────────────────────*/ +y='+' +z=left('',5,y) + /*───────────────────────────────────────────*/ +y='+' +z=right('',5,y) + /*───────────────────────────────────────────*/ +y='+' +z=substr('',1,5,y) + /*───────────────────────────────────────────*/ +y='+' +z=center('',5,y) + /*───────────────────────────────────────────*/ +y='+' +z=centre('',5,y) + /*───────────────────────────────────────────*/ +y='+' +z=space('',5,y) + /*───────────────────────────────────────────*/ +y='+' +z=translate('@@@@@',y,"@") + /*───────────────────────────────────────────*/ +y='abcdef' +z=five(y) +exit + +five: procedure expose y; parse arg g +if length(g)>=5*length(y) then return g +return five(y||g) + /*───────────────────────────────────────────*/ +y='something wicked this way comes.' +z=y||y||y||y||y||y||y||y||y||y||y||y|\y||y||y +z=left(z,5*length(y)) + /*───────────────────────────────────────────*/ +y='+' +z=copies('',5,y) + /*───────────────────────────────────────────*/ +y='+' +z=lower('',1,5,y) + /*───────────────────────────────────────────*/ +y='+' +z=lower('',,5,y) + /*───────────────────────────────────────────*/ +z='+' +z=upper('',1,5,y) + /*───────────────────────────────────────────*/ +z=upper('',,5,y) + /*───────────────────────────────────────────*/ + +y='charter bus.' +z='*****' +z=changestr('*',z,y) + /*───────────────────────────────────────────*/ +y='what the hey!' +z= + do until length(z)==5*length(y) + z=z||y + end + /*───────────────────────────────────────────*/ +y='what the hey!' +z= + do until length(z)==5*length(y) + z=insert(z,0,y) + end + /*───────────────────────────────────────────*/ +y='yippie ki yay' +z= + do i=1 by 5 for 5 + z=overlay(y,z,i) + end + /*───────────────────────────────────────────*/ +y='+' +z=justify('',5,y) + /*───────────────────────────────────────────*/ +whatever_this_variable_is_____it_aint_referenced_directly= 'boy oh boy.' +z=; signal me; me: + do 5 + z=z||strip(subword(sourceline(sigl-1),2),,"'") + end + /*───────────────────────────────────────────*/ +y="any more examples & the angry townfolk with pitchforks will burn the castle." +parse value y||y||y||y||y with z + +exit /*stick a fork in it, we're done.*/ diff --git a/Task/Repeat-a-string/Racket/repeat-a-string-1.rkt b/Task/Repeat-a-string/Racket/repeat-a-string-1.rkt new file mode 100644 index 0000000000..5dd06c19f4 --- /dev/null +++ b/Task/Repeat-a-string/Racket/repeat-a-string-1.rkt @@ -0,0 +1,4 @@ +; fast +(define (string-repeat n str) + (apply string-append (make-list n str))) +(string-repeat 5 "ha") ==> "hahahahaha" diff --git a/Task/Repeat-a-string/Racket/repeat-a-string-2.rkt b/Task/Repeat-a-string/Racket/repeat-a-string-2.rkt new file mode 100644 index 0000000000..89fd319d64 --- /dev/null +++ b/Task/Repeat-a-string/Racket/repeat-a-string-2.rkt @@ -0,0 +1,7 @@ +; memory efficient +(define (string-repeat n string) + (with-output-to-string + (λ () + (for ([_ (in-range n)]) + (display string))))) +(string-repeat 5 "ha") ==> "hahahahaha" diff --git a/Task/Repeat-a-string/Racket/repeat-a-string-3.rkt b/Task/Repeat-a-string/Racket/repeat-a-string-3.rkt new file mode 100644 index 0000000000..bf26460c17 --- /dev/null +++ b/Task/Repeat-a-string/Racket/repeat-a-string-3.rkt @@ -0,0 +1 @@ +(make-string 5 #\*) => "*****" diff --git a/Task/Repeat-a-string/Retro/repeat-a-string.retro b/Task/Repeat-a-string/Retro/repeat-a-string.retro new file mode 100644 index 0000000000..0c66e6206b --- /dev/null +++ b/Task/Repeat-a-string/Retro/repeat-a-string.retro @@ -0,0 +1,5 @@ +with strings' +: repeatString ( $n-$ ) + 1- [ dup ] dip [ over prepend ] times nip ; + +"ha" 5 repeatString diff --git a/Task/Repeat-a-string/Ruby/repeat-a-string-1.rb b/Task/Repeat-a-string/Ruby/repeat-a-string-1.rb new file mode 100644 index 0000000000..0cf142bf02 --- /dev/null +++ b/Task/Repeat-a-string/Ruby/repeat-a-string-1.rb @@ -0,0 +1 @@ +"ha" * 5 # ==> "hahahahaha" diff --git a/Task/Repeat-a-string/Ruby/repeat-a-string-2.rb b/Task/Repeat-a-string/Ruby/repeat-a-string-2.rb new file mode 100644 index 0000000000..57ea405b5e --- /dev/null +++ b/Task/Repeat-a-string/Ruby/repeat-a-string-2.rb @@ -0,0 +1 @@ +5 * "ha" # TypeError: String can't be coerced into Fixnum diff --git a/Task/Repeat-a-string/Run-BASIC/repeat-a-string.run b/Task/Repeat-a-string/Run-BASIC/repeat-a-string.run new file mode 100644 index 0000000000..7958ae395e --- /dev/null +++ b/Task/Repeat-a-string/Run-BASIC/repeat-a-string.run @@ -0,0 +1,6 @@ +a$ = "ha " +for i = 1 to 5 + a1$ = a1$ + a$ +next i +a$ = a1$ +print a$ diff --git a/Task/Repeat-a-string/SNOBOL4/repeat-a-string.sno b/Task/Repeat-a-string/SNOBOL4/repeat-a-string.sno new file mode 100644 index 0000000000..e7e4a515e0 --- /dev/null +++ b/Task/Repeat-a-string/SNOBOL4/repeat-a-string.sno @@ -0,0 +1,2 @@ + output = dupl("ha",5) +end diff --git a/Task/Repeat-a-string/SQL/repeat-a-string.sql b/Task/Repeat-a-string/SQL/repeat-a-string.sql new file mode 100644 index 0000000000..cca9040f33 --- /dev/null +++ b/Task/Repeat-a-string/SQL/repeat-a-string.sql @@ -0,0 +1 @@ +select rpad('', 10, 'ha') diff --git a/Task/Repeat-a-string/Scala/repeat-a-string.scala b/Task/Repeat-a-string/Scala/repeat-a-string.scala new file mode 100644 index 0000000000..1a78b4c67c --- /dev/null +++ b/Task/Repeat-a-string/Scala/repeat-a-string.scala @@ -0,0 +1 @@ +"ha" * 5 // ==> "hahahahaha" diff --git a/Task/Repeat-a-string/Scheme/repeat-a-string-1.ss b/Task/Repeat-a-string/Scheme/repeat-a-string-1.ss new file mode 100644 index 0000000000..e41ac45be1 --- /dev/null +++ b/Task/Repeat-a-string/Scheme/repeat-a-string-1.ss @@ -0,0 +1,2 @@ +(define (string-repeat n str) + (apply string-append (vector->list (make-vector n str)))) diff --git a/Task/Repeat-a-string/Scheme/repeat-a-string-2.ss b/Task/Repeat-a-string/Scheme/repeat-a-string-2.ss new file mode 100644 index 0000000000..32e2aed0b2 --- /dev/null +++ b/Task/Repeat-a-string/Scheme/repeat-a-string-2.ss @@ -0,0 +1,3 @@ +(define (string-repeat n str) + (fold string-append "" (make-list n str))) +(string-repeat 5 "ha") ==> "hahahahaha" diff --git a/Task/Repeat-a-string/Scheme/repeat-a-string-3.ss b/Task/Repeat-a-string/Scheme/repeat-a-string-3.ss new file mode 100644 index 0000000000..6664ad9b66 --- /dev/null +++ b/Task/Repeat-a-string/Scheme/repeat-a-string-3.ss @@ -0,0 +1 @@ +(make-string 5 #\*) diff --git a/Task/Repeat-a-string/Seed7/repeat-a-string.seed7 b/Task/Repeat-a-string/Seed7/repeat-a-string.seed7 new file mode 100644 index 0000000000..8d63fd7211 --- /dev/null +++ b/Task/Repeat-a-string/Seed7/repeat-a-string.seed7 @@ -0,0 +1,6 @@ +$ include "seed7_05.s7i"; + +const proc: main is func + begin + writeln("ha" mult 5); + end func; diff --git a/Task/Repeat-a-string/Smalltalk/repeat-a-string-1.st b/Task/Repeat-a-string/Smalltalk/repeat-a-string-1.st new file mode 100644 index 0000000000..6d79d982c3 --- /dev/null +++ b/Task/Repeat-a-string/Smalltalk/repeat-a-string-1.st @@ -0,0 +1,2 @@ +v := 'ha'. +v,v,v,v,v diff --git a/Task/Repeat-a-string/Smalltalk/repeat-a-string-2.st b/Task/Repeat-a-string/Smalltalk/repeat-a-string-2.st new file mode 100644 index 0000000000..ce05c3e072 --- /dev/null +++ b/Task/Repeat-a-string/Smalltalk/repeat-a-string-2.st @@ -0,0 +1 @@ +((1 to: n) collect: [:x | 'ha']) joinUsing: ''. diff --git a/Task/Repeat-a-string/Smalltalk/repeat-a-string-3.st b/Task/Repeat-a-string/Smalltalk/repeat-a-string-3.st new file mode 100644 index 0000000000..7a52f230bc --- /dev/null +++ b/Task/Repeat-a-string/Smalltalk/repeat-a-string-3.st @@ -0,0 +1 @@ +(Array new:n withAll:'ha') asStringWith:''. diff --git a/Task/Repeat-a-string/Smalltalk/repeat-a-string-4.st b/Task/Repeat-a-string/Smalltalk/repeat-a-string-4.st new file mode 100644 index 0000000000..96587dbcdf --- /dev/null +++ b/Task/Repeat-a-string/Smalltalk/repeat-a-string-4.st @@ -0,0 +1,3 @@ +ws := '' writeStream. +n timesRepeat: [ws nextPutAll: 'ha']. +ws contents. diff --git a/Task/Repeat-a-string/Smalltalk/repeat-a-string-5.st b/Task/Repeat-a-string/Smalltalk/repeat-a-string-5.st new file mode 100644 index 0000000000..59616907df --- /dev/null +++ b/Task/Repeat-a-string/Smalltalk/repeat-a-string-5.st @@ -0,0 +1 @@ +(String streamContents:[:ws | n timesRepeat: [ws nextPutAll: 'ha']]) diff --git a/Task/Repeat-a-string/Smalltalk/repeat-a-string-6.st b/Task/Repeat-a-string/Smalltalk/repeat-a-string-6.st new file mode 100644 index 0000000000..292211ce4e --- /dev/null +++ b/Task/Repeat-a-string/Smalltalk/repeat-a-string-6.st @@ -0,0 +1 @@ +String new:n withAll:$* diff --git a/Task/Repeat-a-string/Standard-ML/repeat-a-string-1.ml b/Task/Repeat-a-string/Standard-ML/repeat-a-string-1.ml new file mode 100644 index 0000000000..555bc99c5f --- /dev/null +++ b/Task/Repeat-a-string/Standard-ML/repeat-a-string-1.ml @@ -0,0 +1,3 @@ +fun string_repeat (s, n) = + concat (List.tabulate (n, fn _ => s)) +; diff --git a/Task/Repeat-a-string/Standard-ML/repeat-a-string-2.ml b/Task/Repeat-a-string/Standard-ML/repeat-a-string-2.ml new file mode 100644 index 0000000000..5e846f319c --- /dev/null +++ b/Task/Repeat-a-string/Standard-ML/repeat-a-string-2.ml @@ -0,0 +1,2 @@ +- string_repeat ("Hiuoa", 3) ; +val it = "HiuoaHiuoaHiuoa" : string diff --git a/Task/Repeat-a-string/Standard-ML/repeat-a-string-3.ml b/Task/Repeat-a-string/Standard-ML/repeat-a-string-3.ml new file mode 100644 index 0000000000..6defdf5b83 --- /dev/null +++ b/Task/Repeat-a-string/Standard-ML/repeat-a-string-3.ml @@ -0,0 +1,3 @@ +fun char_repeat (c, n) = + implode (List.tabulate (n, fn _ => c)) +; diff --git a/Task/Repeat-a-string/Suneido/repeat-a-string.suneido b/Task/Repeat-a-string/Suneido/repeat-a-string.suneido new file mode 100644 index 0000000000..e2b9028f2f --- /dev/null +++ b/Task/Repeat-a-string/Suneido/repeat-a-string.suneido @@ -0,0 +1,2 @@ +'ha'.Repeat(5) --> "hahahahaha" +'*'.Repeat(5) --> "*****" diff --git a/Task/Repeat-a-string/TUSCRIPT/repeat-a-string.tuscript b/Task/Repeat-a-string/TUSCRIPT/repeat-a-string.tuscript new file mode 100644 index 0000000000..d179bd5dca --- /dev/null +++ b/Task/Repeat-a-string/TUSCRIPT/repeat-a-string.tuscript @@ -0,0 +1,2 @@ +$$ MODE TUSCRIPT +repeatstring=REPEAT ("ha",5) diff --git a/Task/Repeat-a-string/Tcl/repeat-a-string.tcl b/Task/Repeat-a-string/Tcl/repeat-a-string.tcl new file mode 100644 index 0000000000..b7c1afe468 --- /dev/null +++ b/Task/Repeat-a-string/Tcl/repeat-a-string.tcl @@ -0,0 +1 @@ +string repeat "ha" 5 ;# => hahahahaha diff --git a/Task/Repeat-a-string/TorqueScript/repeat-a-string.torquescript b/Task/Repeat-a-string/TorqueScript/repeat-a-string.torquescript new file mode 100644 index 0000000000..9d6a29cd2e --- /dev/null +++ b/Task/Repeat-a-string/TorqueScript/repeat-a-string.torquescript @@ -0,0 +1,9 @@ +function strRep(%str,%int) +{ + for(%i = 0; %i < %int; %i++) + { + %rstr = %rstr@%str; + } + + return %rstr; +} diff --git a/Task/Repeat-a-string/UNIX-Shell/repeat-a-string-1.sh b/Task/Repeat-a-string/UNIX-Shell/repeat-a-string-1.sh new file mode 100644 index 0000000000..08eee0b2dc --- /dev/null +++ b/Task/Repeat-a-string/UNIX-Shell/repeat-a-string-1.sh @@ -0,0 +1 @@ +printf "ha"%.0s {1..5} diff --git a/Task/Repeat-a-string/UNIX-Shell/repeat-a-string-2.sh b/Task/Repeat-a-string/UNIX-Shell/repeat-a-string-2.sh new file mode 100644 index 0000000000..b52157b58d --- /dev/null +++ b/Task/Repeat-a-string/UNIX-Shell/repeat-a-string-2.sh @@ -0,0 +1,2 @@ +i=5 +printf "ha"%.0s {1..$i} diff --git a/Task/Repeat-a-string/UNIX-Shell/repeat-a-string-3.sh b/Task/Repeat-a-string/UNIX-Shell/repeat-a-string-3.sh new file mode 100644 index 0000000000..10ecaecd94 --- /dev/null +++ b/Task/Repeat-a-string/UNIX-Shell/repeat-a-string-3.sh @@ -0,0 +1,2 @@ +i=5 +eval "printf 'ha'%.0s {1..$i}" diff --git a/Task/Repeat-a-string/UNIX-Shell/repeat-a-string-4.sh b/Task/Repeat-a-string/UNIX-Shell/repeat-a-string-4.sh new file mode 100644 index 0000000000..93acaacefc --- /dev/null +++ b/Task/Repeat-a-string/UNIX-Shell/repeat-a-string-4.sh @@ -0,0 +1,5 @@ +reprint() { + typeset e="$(sed -e 's,%,%%,g' -e 's,\\,\\\\,g' <<<"$1")" + eval 'printf "$e"%.0s '"{1..$2}" +} +reprint '% ha \' 5 diff --git a/Task/Repeat-a-string/UNIX-Shell/repeat-a-string-5.sh b/Task/Repeat-a-string/UNIX-Shell/repeat-a-string-5.sh new file mode 100644 index 0000000000..c6d9c6f081 --- /dev/null +++ b/Task/Repeat-a-string/UNIX-Shell/repeat-a-string-5.sh @@ -0,0 +1,2 @@ +width=72; char='=' +head -c ${width} < /dev/zero | tr '\0' "$char" diff --git a/Task/Repeat-a-string/Ursala/repeat-a-string.ursala b/Task/Repeat-a-string/Ursala/repeat-a-string.ursala new file mode 100644 index 0000000000..effb21e39c --- /dev/null +++ b/Task/Repeat-a-string/Ursala/repeat-a-string.ursala @@ -0,0 +1,7 @@ +#import nat + +repeat = ^|DlSL/~& iota + +#cast %s + +example = repeat('ha',5) diff --git a/Task/Repeat-a-string/VBA/repeat-a-string.vba b/Task/Repeat-a-string/VBA/repeat-a-string.vba new file mode 100644 index 0000000000..a0d1594073 --- /dev/null +++ b/Task/Repeat-a-string/VBA/repeat-a-string.vba @@ -0,0 +1,11 @@ +Public Function RepeatStr(aString As String, aNumber As Integer) As String +Dim bString As String + +bString = aString +If aNumber > 1 Then + For i = 2 To aNumber + bString = bString & aString + Next i +End If +RepeatStr = bString +End Function diff --git a/Task/Repeat-a-string/Vala/repeat-a-string-1.vala b/Task/Repeat-a-string/Vala/repeat-a-string-1.vala new file mode 100644 index 0000000000..78b477a820 --- /dev/null +++ b/Task/Repeat-a-string/Vala/repeat-a-string-1.vala @@ -0,0 +1,4 @@ +string s = "ha"; +string copy = ""; +for (int x = 0; x < 5; x++) + copy += s; diff --git a/Task/Repeat-a-string/Vala/repeat-a-string-2.vala b/Task/Repeat-a-string/Vala/repeat-a-string-2.vala new file mode 100644 index 0000000000..b8538654df --- /dev/null +++ b/Task/Repeat-a-string/Vala/repeat-a-string-2.vala @@ -0,0 +1 @@ +string s = string.nfill(5, 'c'); diff --git a/Task/Repeat-a-string/Vedit-macro-language/repeat-a-string.vedit b/Task/Repeat-a-string/Vedit-macro-language/repeat-a-string.vedit new file mode 100644 index 0000000000..b6a78e57b7 --- /dev/null +++ b/Task/Repeat-a-string/Vedit-macro-language/repeat-a-string.vedit @@ -0,0 +1 @@ +Ins_Text("ha", COUNT, 5) diff --git a/Task/Repeat-a-string/Visual-Basic-.NET/repeat-a-string.visual b/Task/Repeat-a-string/Visual-Basic-.NET/repeat-a-string.visual new file mode 100644 index 0000000000..146fedc0db --- /dev/null +++ b/Task/Repeat-a-string/Visual-Basic-.NET/repeat-a-string.visual @@ -0,0 +1,6 @@ +FileContents = "X".PadRight(FileSizeBytes - 1, "X") + +Where: + +* FileContents is the string to populate +* FileSizeBytes is the number of repetitions (Remember that "-1" is valid as we have already specified the first character as being "X", which is to be padded on. diff --git a/Task/Repeat-a-string/XPL0/repeat-a-string.xpl0 b/Task/Repeat-a-string/XPL0/repeat-a-string.xpl0 new file mode 100644 index 0000000000..5d3e4a6658 --- /dev/null +++ b/Task/Repeat-a-string/XPL0/repeat-a-string.xpl0 @@ -0,0 +1 @@ +cod T=12; int I; for I gets 1,5 do T(0,"ha") diff --git a/Task/Repeat-a-string/Yorick/repeat-a-string.yorick b/Task/Repeat-a-string/Yorick/repeat-a-string.yorick new file mode 100644 index 0000000000..5ed0358e69 --- /dev/null +++ b/Task/Repeat-a-string/Yorick/repeat-a-string.yorick @@ -0,0 +1 @@ +array("ha", 5)(sum) diff --git a/Task/Resistor-mesh/0DESCRIPTION b/Task/Resistor-mesh/0DESCRIPTION new file mode 100644 index 0000000000..407aef8133 --- /dev/null +++ b/Task/Resistor-mesh/0DESCRIPTION @@ -0,0 +1,5 @@ +[[image:resistor-mesh.svg]] + +Given 10 × 10 grid nodes interconnected by 1Ω resistors as shown, find the resistance between point A and B. + +See also [[http://xkcd.com/356/]] diff --git a/Task/Resistor-mesh/Ada/resistor-mesh.ada b/Task/Resistor-mesh/Ada/resistor-mesh.ada new file mode 100644 index 0000000000..373da93f75 --- /dev/null +++ b/Task/Resistor-mesh/Ada/resistor-mesh.ada @@ -0,0 +1,69 @@ +with Ada.Text_IO; use Ada.Text_IO; +procedure ResistMesh is + H, W : constant Positive := 10; + rowA, colA : constant Positive := 2; -- row/col indexed from 1 + rowB : constant Positive := 7; + colB : constant Positive := 8; + + type Ntype is (A, B, Free); + type Vtype is digits 15; + type Node is record + volt : Vtype := 0.0; + name : Ntype := Free; + end record; + type NodeMesh is array (Positive range <>, Positive range <>) of Node; + package IIO is new Ada.Text_IO.Float_IO (Vtype); + mesh, dmesh : NodeMesh (1 .. H, 1 .. W); + curA, curB, diff : Vtype; + + procedure set_AB (mesh : in out NodeMesh) is begin + mesh (rowA, colA).volt := 1.0; mesh (rowA, colA).name := A; + mesh (rowB, colB).volt := -1.0; mesh (rowB, colB).name := B; + end set_AB; + + function sides (i : Positive; j : Positive) return Vtype is + s : Integer := 0; + begin + if i /= 1 and i /= H then s := s + 2; else s := s + 1; end if; + if j /= 1 and j /= W then s := s + 2; else s := s + 1; end if; + return Vtype (s); + end sides; + + procedure calc_diff (mesh : NodeMesh; dmesh : out NodeMesh; + total : out Vtype) is + n : Natural; + v : Vtype := 0.0; + begin + total := 0.0; + for i in Positive range 1 .. H loop + for j in Positive range 1 .. W loop + n := 0; v := 0.0; + if i /= 1 then v := v + mesh (i - 1, j).volt; n := n + 1; end if; + if j /= 1 then v := v + mesh (i, j - 1).volt; n := n + 1; end if; + if i < H then v := v + mesh (i + 1, j).volt; n := n + 1; end if; + if j < W then v := v + mesh (i, j + 1).volt; n := n + 1; end if; + v := mesh (i, j).volt - v / Vtype (n); + dmesh (i, j).volt := v; + if mesh (i, j).name = Free then total := total + v ** 2; end if; + end loop; + end loop; + end calc_diff; + +begin + + loop + set_AB (mesh); + calc_diff (mesh, dmesh, diff); + exit when diff < 1.0e-40; + for i in Positive range 1 .. H loop + for j in Positive range 1 .. W loop + mesh (i, j).volt := mesh (i, j).volt - dmesh (i, j).volt; + end loop; + end loop; + end loop; + + curA := dmesh (rowA, colA).volt * sides (rowA, colA); + curB := dmesh (rowB, colB).volt * sides (rowB, colB); + diff := 4.0 / (curA - curB); + IIO.Put (diff, Exp => 0); New_Line; +end ResistMesh; diff --git a/Task/Resistor-mesh/BBC-BASIC/resistor-mesh.bbc b/Task/Resistor-mesh/BBC-BASIC/resistor-mesh.bbc new file mode 100644 index 0000000000..810f8ec5d2 --- /dev/null +++ b/Task/Resistor-mesh/BBC-BASIC/resistor-mesh.bbc @@ -0,0 +1,31 @@ + INSTALL @lib$+"ARRAYLIB" + *FLOAT 64 + @% = &F0F + + PRINT "Resistance = "; FNresistormesh(10, 10, 1, 1, 7, 6) " ohms" + END + + DEF FNresistormesh(ni%, nj%, ai%, aj%, bi%, bj%) + LOCAL c%, i%, j%, k%, n%, A(), B() + n% = ni% * nj% + DIM A(n%-1, n%-1), B(n%-1, 0) + FOR i% = 0 TO ni%-1 + FOR j% = 0 TO nj%-1 + k% = i% * nj% + j% + IF i% = ai% AND j% = aj% THEN + A(k%, k%) = 1 + ELSE + c% = 0 + IF (i% + 1) < ni% c% += 1 : A(k%, k% + nj%) = -1 + IF i% > 0 c% += 1 : A(k%, k% - nj%) = -1 + IF (j% + 1) < nj% c% += 1 : A(k%, k% + 1) = -1 + IF j% > 0 c% += 1 : A(k%, k% - 1) = -1 + A(k%, k%) = c% + ENDIF + NEXT + NEXT + k% = bi% * nj% + bj% + B(k%, 0) = 1 + PROC_invert(A()) + B() = A().B() + = B(k%, 0) diff --git a/Task/Resistor-mesh/C/resistor-mesh.c b/Task/Resistor-mesh/C/resistor-mesh.c new file mode 100644 index 0000000000..d57248206f --- /dev/null +++ b/Task/Resistor-mesh/C/resistor-mesh.c @@ -0,0 +1,65 @@ +#include +#include + +#define S 10 +typedef struct { double v; int fixed; } node; + +#define each(i, x) for(i = 0; i < x; i++) +node **alloc2(int w, int h) +{ + int i; + node **a = calloc(1, sizeof(node*)*h + sizeof(node)*w*h); + each(i, h) a[i] = i ? a[i-1] + w : (node*)(a + h); + return a; +} + +void set_boundary(node **m) +{ + m[1][1].fixed = 1; m[1][1].v = 1; + m[6][7].fixed = -1; m[6][7].v = -1; +} + +double calc_diff(node **m, node **d, int w, int h) +{ + int i, j, n; + double v, total = 0; + each(i, h) each(j, w) { + v = 0; n = 0; + if (i) v += m[i-1][j].v, n++; + if (j) v += m[i][j-1].v, n++; + if (i+1 < h) v += m[i+1][j].v, n++; + if (j+1 < w) v += m[i][j+1].v, n++; + + d[i][j].v = v = m[i][j].v - v / n; + if (!m[i][j].fixed) total += v * v; + } + return total; +} + +double iter(node **m, int w, int h) +{ + node **d = alloc2(w, h); + int i, j; + double diff = 1e10; + double cur[] = {0, 0, 0}; + + while (diff > 1e-24) { + set_boundary(m); + diff = calc_diff(m, d, w, h); + each(i,h) each(j, w) m[i][j].v -= d[i][j].v; + } + + each(i, h) each(j, w) + cur[ m[i][j].fixed + 1 ] += d[i][j].v * + (!!i + !!j + (i < h-1) + (j < w -1)); + + free(d); + return (cur[2] - cur[0])/2; +} + +int main() +{ + node **mesh = alloc2(S, S); + printf("R = %g\n", 2 / iter(mesh, S, S)); + return 0; +} diff --git a/Task/Resistor-mesh/D/resistor-mesh.d b/Task/Resistor-mesh/D/resistor-mesh.d new file mode 100644 index 0000000000..eec8c05d43 --- /dev/null +++ b/Task/Resistor-mesh/D/resistor-mesh.d @@ -0,0 +1,76 @@ +import std.stdio, std.traits; + +enum Node.FP differenceThreshold = 1e-40; + +struct Node { + alias real FP; + enum Kind : size_t { free, A, B } + + FP voltage = 0.0; + private Kind kind = Kind.free; + + @property Kind fixed() const pure nothrow { return kind; } +} + +Node.FP iter(size_t w, size_t h)(ref Node[w][h] m) pure nothrow { + static void enforceBoundaryConditions(ref Node[w][h] m) + pure nothrow { + m[1][1].voltage = 1.0; + m[6][7].voltage = -1.0; + } + + static Node.FP calcDifference(in ref Node[w][h] m, + ref Node[w][h] d) pure nothrow { + Node.FP total = 0.0; + + foreach (i; 0 .. h) + foreach (j; 0 .. w) { + Node.FP v = 0.0; + { + size_t n = 0; + if (i != 0) { v += m[i - 1][j].voltage; n++; } + if (j != 0) { v += m[i][j - 1].voltage; n++; } + if (i < h-1) { v += m[i + 1][j].voltage; n++; } + if (j < w-1) { v += m[i][j + 1].voltage; n++; } + v = m[i][j].voltage - v / n; + } + + d[i][j].voltage = v; + if (m[i][j].fixed == Node.Kind.free) + total += v ^^ 2; + } + + return total; + } + + Node[w][h] difference; + + while (true) { + enforceBoundaryConditions(m); + if (calcDifference(m, difference) < differenceThreshold) + break; + foreach (i, const(Node[]) di; difference) + foreach (j, ref const(Node) dij; di) + m[i][j].voltage -= dij.voltage; + } + + Node.FP[EnumMembers!(Node.Kind).length] cur = 0.0; + foreach (i, const(Node[]) di; difference) + foreach (j, ref const(Node) dij; di) + cur[m[i][j].fixed] += dij.voltage * + (!!i + !!j + (i < h-1) + (j < w-1)); + + return (cur[Node.Kind.A] - cur[Node.Kind.B]) / 2.0; +} + +void main() { + enum size_t w = 10, + h = w; + Node[w][h] mesh; + + // Set A and B Nodes. + mesh[1][1] = Node( 1.0, Node.Kind.A); + mesh[6][7] = Node(-1.0, Node.Kind.B); + + writefln("R = %.19f", 2 / iter(mesh)); +} diff --git a/Task/Resistor-mesh/Euler-Math-Toolbox/resistor-mesh-1.euler b/Task/Resistor-mesh/Euler-Math-Toolbox/resistor-mesh-1.euler new file mode 100644 index 0000000000..b90dc40851 --- /dev/null +++ b/Task/Resistor-mesh/Euler-Math-Toolbox/resistor-mesh-1.euler @@ -0,0 +1,3 @@ +>load incidence; +>{u,r}=solvePotentialX(makeRectangleX(10,10),12,68); r, + 1.60899124173 diff --git a/Task/Resistor-mesh/Euler-Math-Toolbox/resistor-mesh-2.euler b/Task/Resistor-mesh/Euler-Math-Toolbox/resistor-mesh-2.euler new file mode 100644 index 0000000000..22981275b8 --- /dev/null +++ b/Task/Resistor-mesh/Euler-Math-Toolbox/resistor-mesh-2.euler @@ -0,0 +1,44 @@ +function makeRectangleX (n:index,m:index) +## Make the incidence matrix of a rectangle grid in compact form. +## see: makeRectangleIncidence + K=zeros(n*(m-1)+m*(n-1),3); + k=1; + for i=1 to n; + for j=1 to m-1; + K[k,1]=(i-1)*m+j; K[k,2]=(i-1)*m+j+1; K[k,3]=1; + k=k+1; + end; + end; + for i=1 to n-1; + for j=1 to m; + K[k,1]=(i-1)*m+j; K[k,2]=i*m+j; K[k,3]=1; + k=k+1; + end; + end; + H=cpxzeros([n*m,n*m]); + H=cpxset(H,K); + H=cpxset(H,K[:,[2,1,3]]); + return H; +endfunction + +function solvePotentialX (A:cpx, i:index ,j:index) +## Solve the potential problem of resistance in a graph. +## This functions uses the conjugate gradient method. +## A is a compressed incidence matrix. +## Return the potential u for the nodes in A, +## such that u[i]=1, u[j]=-1, and the flow +## to each knot is equal to the flow from the knot, +## and the flow from i to j is (u[i]-u[j])*A[i,j]. +## see: makeIncidence + n=size(A)[1]; + b=ones(n,1); f=-cpxmult(A,b); + h=1:n; B=cpxset(A,h'|h'|f); + B=cpxset(B,i|h'|0); + B=cpxset(B,[i,i,1]); + B=cpxset(B,j|h'|0); + B=cpxset(B,[j,j,1]); + v=zeros(n,1); v[i]=1; v[j]=-1; + u=cpxfit(B,v); + f=(-f[i])*u[i]-cpxmult(A,u)[i]; + return {u,2/f} +endfunction diff --git a/Task/Resistor-mesh/Euler-Math-Toolbox/resistor-mesh-3.euler b/Task/Resistor-mesh/Euler-Math-Toolbox/resistor-mesh-3.euler new file mode 100644 index 0000000000..3c9cd00f79 --- /dev/null +++ b/Task/Resistor-mesh/Euler-Math-Toolbox/resistor-mesh-3.euler @@ -0,0 +1,39 @@ +function cgX (H:cpx, b:real column, x0:real column=none, f:index=10) +## Conjugate gradient method to solve Hx=b for compressed H. +## +## This is the method of choice for large, sparse matrices. In most +## cases, it will work well, fast, and accurate. +## +## H must be positive definite. Use cpxfit, if it is not. +## +## The accuarcy can be controlled with an additional parameter +## eps. The algorithm stops, when the error gets smaller then eps, or +## after f*n iterations, if the error gets larger. x0 is an optional +## start vector. +## +## H : compressed matrix (nxm) +## b : column vector (mx1) +## x0 : optional start point (mx1) +## f : number of steps, when the method should be restarted +## +## See: cpxfit, cg, cgXnormal + if isvar("eps") then localepsilon(eps); endif; + n=cols(H); + if x0==none then x=zeros(size(b)); + else; x=x0; + endif; + loop 1 to 10 + r=b-cpxmult(H,x); p=r; fehler=r'.r; + loop 1 to f*n + if sqrt(fehler)~=0 then return x; endif; + Hp=cpxmult(H,p); + a=fehler/(p'.Hp); + x=x+a*p; + rn=r-a*Hp; + fehlerneu=rn'.rn; + p=rn+fehlerneu/fehler*p; + r=rn; fehler=fehlerneu; + end; + end; + return x; +endfunction diff --git a/Task/Resistor-mesh/J/resistor-mesh-1.j b/Task/Resistor-mesh/J/resistor-mesh-1.j new file mode 100644 index 0000000000..57d25e8993 --- /dev/null +++ b/Task/Resistor-mesh/J/resistor-mesh-1.j @@ -0,0 +1,10 @@ +nodes=: 10 10 #: i. 100 +nodeA=: 1 1 +nodeB=: 6 7 + +conn =: [: (#~ e.~/@|:~&0 2) ([ ,: +)"1 +ref =: ~. nodeA,nodes-.nodeB +wiring=: /:~ ref i. ,/ nodes conn"2 1 (,-)=i.2 +Yii=: _1 _1 }. (* =@i.@#) #/.~ {."1 wiring +Yij=: - _1 _1 }. 1:`(<"1@[)`]}&(+/~ 0*i.1+#ref) wiring +Y=: Yii+Yij diff --git a/Task/Resistor-mesh/J/resistor-mesh-2.j b/Task/Resistor-mesh/J/resistor-mesh-2.j new file mode 100644 index 0000000000..690d49c8c8 --- /dev/null +++ b/Task/Resistor-mesh/J/resistor-mesh-2.j @@ -0,0 +1,2 @@ + {.{. %. Y +1.60899 diff --git a/Task/Resistor-mesh/J/resistor-mesh-3.j b/Task/Resistor-mesh/J/resistor-mesh-3.j new file mode 100644 index 0000000000..c1e830f465 --- /dev/null +++ b/Task/Resistor-mesh/J/resistor-mesh-3.j @@ -0,0 +1,2 @@ + {.{.%. x:Y +455859137025721r283319837425200 diff --git a/Task/Resistor-mesh/Mathematica/resistor-mesh-1.math b/Task/Resistor-mesh/Mathematica/resistor-mesh-1.math new file mode 100644 index 0000000000..da7b819535 --- /dev/null +++ b/Task/Resistor-mesh/Mathematica/resistor-mesh-1.math @@ -0,0 +1,12 @@ +gridresistor[p_, q_, ai_, aj_, bi_, bj_] := + Block[{A, B, k, c, V}, A = ConstantArray[0, {p*q, p*q}]; + Do[k = (i - 1) q + j; + If[{i, j} == {ai, aj}, A[[k, k]] = 1, c = 0; + If[1 <= i + 1 <= p && 1 <= j <= q, c++; A[[k, k + q]] = -1]; + If[1 <= i - 1 <= p && 1 <= j <= q, c++; A[[k, k - q]] = -1]; + If[1 <= i <= p && 1 <= j + 1 <= q, c++; A[[k, k + 1]] = -1]; + If[1 <= i <= p && 1 <= j - 1 <= q, c++; A[[k, k - 1]] = -1]; + A[[k, k]] = c], {i, p}, {j, q}]; + B = SparseArray[(k = (bi - 1) q + bj) -> 1, p*q]; + LinearSolve[A, B][[k]]]; +N[gridresistor[10, 10, 2, 2, 8, 7], 40] diff --git a/Task/Resistor-mesh/Mathematica/resistor-mesh-2.math b/Task/Resistor-mesh/Mathematica/resistor-mesh-2.math new file mode 100644 index 0000000000..66d4c1f432 --- /dev/null +++ b/Task/Resistor-mesh/Mathematica/resistor-mesh-2.math @@ -0,0 +1,7 @@ +graphresistor[g_, a_, b_] := + LinearSolve[ + SparseArray[{{a, a} -> 1, {i_, i_} :> Length@AdjacencyList[g, i], + Alternatives @@ Join[#, Reverse /@ #] &[ + List @@@ EdgeList[VertexDelete[g, a]]] -> -1}, {VertexCount[ + g], VertexCount[g]}], SparseArray[b -> 1, VertexCount[g]]][[b]]; +N[graphresistor[GridGraph[{10, 10}], 12, 77], 40] diff --git a/Task/Resistor-mesh/Maxima/resistor-mesh.maxima b/Task/Resistor-mesh/Maxima/resistor-mesh.maxima new file mode 100644 index 0000000000..312ee766dc --- /dev/null +++ b/Task/Resistor-mesh/Maxima/resistor-mesh.maxima @@ -0,0 +1,62 @@ +/* Place a current souce between A and B, providing 1 A. Then we are really looking + for the potential at A and B, since I = R (V(B) - V(A)) where I is given and we want R. + + Atually, we will compute potential at each node, except A where we assume it's 0. + Without with assumption, there would be infinitely many solutions since potential + is known up to a constant. For A we will simply write the equation V(A) = 0, to + keep the program simple. + + Hence, for a general grid of p rows and q columns, there are n = p * q nodes, + so n unknowns, and n equations. Write Kirchhoff's current law at each node. + Be careful with the node A (equation A = 0) and the node B (there is a constant + current to add, from the source, that will go in the constant terms of the system). + + Finally, we have a n x n linear system of equations to solve. Simply use Maxima's + builtin LU decomposition. + + Since all computations are exact, the result will be also exact, written as a fraction. + Also, the program can work with any grid, and any two nodes on the grid. + + For those who want more speed and less space, notice the system is sparse and necessarily + symmetric, so one can use conjugate gradient or any other sparse symmetric solver. */ + + +/* Auxiliary function to get rid of the borders */ +ongrid(i, j, p, q) := is(i >= 1 and i <= p and j >= 1 and j <= q)$ + +grid_resistor(p, q, ai, aj, bi, bj) := block( + [n: p * q, A, B, M, k, c, V], + A: zeromatrix(n, n), + for i thru p do + for j thru q do ( + k: (i - 1) * q + j, + if i = ai and j = aj then + A[k, k]: 1 + else ( + c: 0, + if ongrid(i + 1, j, p, q) then (c: c + 1, A[k, k + q]: -1), + if ongrid(i - 1, j, p, q) then (c: c + 1, A[k, k - q]: -1), + if ongrid(i, j + 1, p, q) then (c: c + 1, A[k, k + 1]: -1), + if ongrid(i, j - 1, p, q) then (c: c + 1, A[k, k - 1]: -1), + A[k, k]: c + ) + ), + B: zeromatrix(n, 1), + B[k: (bi - 1) * q + bj, 1]: 1, + M: lu_factor(A), + V: lu_backsub(M, B), + V[k, 1] +)$ + +grid_resistor(10, 10, 2, 2, 8, 7); +455859137025721 / 283319837425200 + +bfloat(%), fpprec = 40; +1.608991241730729655954495520510088761201b0 + +/* Some larger example */ +grid_resistor(20, 20, 1, 1, 20, 20); +129548954101732562831760781545158173626645023 / 33283688571680493510612137844679320717594861 + +bfloat(%), fpprec = 40; +3.89226554090400912102670691601064387507b0 diff --git a/Task/Resistor-mesh/Perl-6/resistor-mesh.pl6 b/Task/Resistor-mesh/Perl-6/resistor-mesh.pl6 new file mode 100644 index 0000000000..629bb6ca5d --- /dev/null +++ b/Task/Resistor-mesh/Perl-6/resistor-mesh.pl6 @@ -0,0 +1,58 @@ +my $S = 10; + +my @fixed; + +sub allocmesh ($w, $h) { + gather for ^$h { + take [0 xx $w]; + } +} + +sub force-fixed(@f) { + @f[1][1] = 1; + @f[6][7] = -1; +} + +sub force-v(@v) { + @v[1][1] = 1; + @v[6][7] = -1; +} + +sub calc_diff(@v, @d, Int $w, Int $h) { + my $total = 0; + for ^$h X ^$w -> $i, $j { + my @neighbors = grep *.defined, @v[$i-1][$j], @v[$i][$j-1], @v[$i+1][$j], @v[$i][$j+1]; + my $v = [+] @neighbors; + @d[$i][$j] = $v = @v[$i][$j] - $v / +@neighbors; + $total += $v * $v unless @fixed[$i][$j]; + } + return $total; +} + +sub iter(@v, Int $w, Int $h) { + my @d = allocmesh($w, $h); + my $diff = 1e10; + my @cur = 0, 0, 0; + + while $diff > 1e-24 { + force-v(@v); + $diff = calc_diff(@v, @d, $w, $h); + for ^$h X ^$w -> $i, $j { + @v[$i][$j] -= @d[$i][$j]; + } + } + + for ^$h X ^$w -> $i, $j { + @cur[ @fixed[$i][$j] + 1 ] + += @d[$i][$j] * (?$i + ?$j + ($i < $h - 1) + ($j < $w - 1)); + } + + return (@cur[2] - @cur[0]) / 2; +} + +my @mesh = allocmesh($S, $S); + +@fixed = allocmesh($S, $S); +force-fixed(@fixed); + +say 2 / iter(@mesh, $S, $S); diff --git a/Task/Resistor-mesh/Perl/resistor-mesh.pl b/Task/Resistor-mesh/Perl/resistor-mesh.pl new file mode 100644 index 0000000000..59f850353e --- /dev/null +++ b/Task/Resistor-mesh/Perl/resistor-mesh.pl @@ -0,0 +1,60 @@ +use strict; + +my ($w, $h) = (9, 9); +my @v = map([ (0) x ($w + 1) ], 0 .. $h); # voltage +my @f = map([ (0) x ($w + 1) ], 0 .. $h); # fixed condition +my @d = map([ (0) x ($w + 1) ], 0 .. $h); # diff + +my @n; # neighbors +for my $i (0 .. $h) { + push @{$n[$i][$_]}, [$i, $_ - 1] for 1 .. $w; + push @{$n[$i][$_]}, [$i, $_ + 1] for 0 .. $w - 1; +} +for my $j (0 .. $w) { + push @{$n[$_][$j]}, [$_ - 1, $j] for 1 .. $h; + push @{$n[$_][$j]}, [$_ + 1, $j] for 0 .. $h - 1; +} + +sub set_boundary { + $f[1][1] = 1; $f[6][7] = -1; + $v[1][1] = 1; $v[6][7] = -1; +} + +sub calc_diff { + my $total_diff; + for my $i (0 .. $h) { + for my $j (0 .. $w) { + my ($p, $v) = $n[$i][$j]; + $v += $v[$_->[0]][$_->[1]] for @$p; + $d[$i][$j] = $v = $v[$i][$j] - $v / scalar(@$p); + $total_diff += $v * $v unless $f[$i][$j]; + } + } + $total_diff; +} + +sub iter { + my $diff = 1; + while ($diff > 1e-24) { # 1e-24 is overkill (12 digits of precision) + set_boundary(); + $diff = calc_diff(); + print "error^2: $diff\r"; + for my $i (0 .. $h) { + for my $j (0 .. $w) { + $v[$i][$j] -= $d[$i][$j]; + } + } + } + print "\n"; + + my @current = (0) x 3; + for my $i (0 .. $h) { + for my $j (0 .. $w) { + $current[ $f[$i][$j] ] += + $d[$i][$j] * scalar(@{$n[$i][$j]}); + } + } + return ($current[1] - $current[-1]) / 2; +} + +print "R = @{[2 / iter()]}\n"; diff --git a/Task/Resistor-mesh/Python/resistor-mesh.py b/Task/Resistor-mesh/Python/resistor-mesh.py new file mode 100644 index 0000000000..c27e3b9bf1 --- /dev/null +++ b/Task/Resistor-mesh/Python/resistor-mesh.py @@ -0,0 +1,64 @@ +DIFF_THRESHOLD = 1e-40 + +class Fixed: + FREE = 0 + A = 1 + B = 2 + +class Node: + __slots__ = ["voltage", "fixed"] + def __init__(self, v=0.0, f=Fixed.FREE): + self.voltage = v + self.fixed = f + +def set_boundary(m): + m[1][1] = Node( 1.0, Fixed.A) + m[6][7] = Node(-1.0, Fixed.B) + +def calc_difference(m, d): + h = len(m) + w = len(m[0]) + total = 0.0 + + for i in xrange(h): + for j in xrange(w): + v = 0.0 + n = 0 + if i != 0: v += m[i-1][j].voltage; n += 1 + if j != 0: v += m[i][j-1].voltage; n += 1 + if i < h-1: v += m[i+1][j].voltage; n += 1 + if j < w-1: v += m[i][j+1].voltage; n += 1 + v = m[i][j].voltage - v / n + + d[i][j].voltage = v + if m[i][j].fixed == Fixed.FREE: + total += v ** 2 + return total + +def iter(m): + h = len(m) + w = len(m[0]) + difference = [[Node() for j in xrange(w)] for i in xrange(h)] + + while True: + set_boundary(m) # Enforce boundary conditions. + if calc_difference(m, difference) < DIFF_THRESHOLD: + break + for i, di in enumerate(difference): + for j, dij in enumerate(di): + m[i][j].voltage -= dij.voltage + + cur = [0.0] * 3 + for i, di in enumerate(difference): + for j, dij in enumerate(di): + cur[m[i][j].fixed] += (dij.voltage * + (bool(i) + bool(j) + (i < h-1) + (j < w-1))) + + return (cur[Fixed.A] - cur[Fixed.B]) / 2.0 + +def main(): + w = h = 10 + mesh = [[Node() for j in xrange(w)] for i in xrange(h)] + print "R = %.16f" % (2 / iter(mesh)) + +main() diff --git a/Task/Resistor-mesh/REXX/resistor-mesh.rexx b/Task/Resistor-mesh/REXX/resistor-mesh.rexx new file mode 100644 index 0000000000..c692e76121 --- /dev/null +++ b/Task/Resistor-mesh/REXX/resistor-mesh.rexx @@ -0,0 +1,40 @@ +/*REXX pgm calculates resistance between any 2 points on a resister grid*/ +numeric digits 20 /*use moderate digits (precision)*/ +minVal=(1'e-'||(digits()*2)) / 1 /*calculate the threshold min val*/ +if 1=='f1'x then ohms = 'ohms' /*EBCDIC machine? Use 'ohms'. */ + else ohms = 'ea'x /* ASCII machine? Use Greek Ω.*/ +parse arg wide high Arow Acol Brow Bcol . +say 'minVal = ' format(minVal,,,,0) ; say +say 'resistor mesh is of size: ' wide "wide, " high 'high.' ; say +say 'point A is at (row,col): ' Arow","Acol +say 'point B is at (row,col): ' Brow","Bcol +@.=0; cell.=1 + do until $ <= minVal; $=0; v = 0 + @.Arow.Acol = +1 ; cell.Arow.Acol = 0 + @.Brow.Bcol = -1 ; cell.Brow.Bcol = 0 + + do i =1 for high; im=i-1; ip=i+1 + do j=1 for wide; jm=j-1; jp=j+1; n=0; v=0 + if i\==1 then do; v=v+@.im.j; n=n+1; end + if j\==1 then do; v=v+@.i.jm; n=n+1; end + if i 1E-24 do + [SetBoundary(MV, MF); + Diff:= CalcDiff(MV, MF, DV, W, H); + for I:= 0 to H-1 do + for J:= 0 to W-1 do + MV(I,J):= MV(I,J) - DV(I,J); + ]; +for I:= 0 to H-1 do + for J:= 0 to W-1 do + Cur(MF(I,J)+1):= Cur(MF(I,J)+1) + + DV(I,J) * float(-(I>0) - (J>0) - (I on (4).") diff --git a/Task/Respond-to-an-unknown-method-call/D/respond-to-an-unknown-method-call.d b/Task/Respond-to-an-unknown-method-call/D/respond-to-an-unknown-method-call.d new file mode 100644 index 0000000000..5c9092e6a5 --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/D/respond-to-an-unknown-method-call.d @@ -0,0 +1,25 @@ +import std.stdio; + +struct Catcher { + void foo() { writeln("This is foo"); } + + void bar() { writeln("This is bar"); } + + void opDispatch(string name, ArgsTypes...)(ArgsTypes args) { + writef("Tried to handle unknown method '%s'", name); + if (ArgsTypes.length) { + write(", with arguments: "); + foreach (arg; args) + write(arg, " "); + } + writeln(); + } +} + +void main() { + Catcher ca; + ca.foo(); + ca.bar(); + ca.grill(); + ca.ding("dong", 11); +} diff --git a/Task/Respond-to-an-unknown-method-call/E/respond-to-an-unknown-method-call.e b/Task/Respond-to-an-unknown-method-call/E/respond-to-an-unknown-method-call.e new file mode 100644 index 0000000000..c8ac98583a --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/E/respond-to-an-unknown-method-call.e @@ -0,0 +1,10 @@ +def example { + to foo() { println("this is foo") } + to bar() { println("this is bar") } + match [verb, args] { + println(`got unrecognized message $verb`) + if (args.size() > 0) { + println(`it had arguments: $args`) + } + } +} diff --git a/Task/Respond-to-an-unknown-method-call/Fancy/respond-to-an-unknown-method-call.fancy b/Task/Respond-to-an-unknown-method-call/Fancy/respond-to-an-unknown-method-call.fancy new file mode 100644 index 0000000000..878dca2370 --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/Fancy/respond-to-an-unknown-method-call.fancy @@ -0,0 +1,20 @@ +class CatchThemAll { + def foo { + "foo received" println + } + + def bar { + "bar received" println + } + + def unknown_message: msg with_params: params { + "message: " ++ msg print + "arguments: " ++ (params join: ", ") println + } +} + +a = CatchThemAll new +a foo +a bar +a we_can_do_it +a they_can_too: "eat" and: "walk" diff --git a/Task/Respond-to-an-unknown-method-call/Fantom/respond-to-an-unknown-method-call.fantom b/Task/Respond-to-an-unknown-method-call/Fantom/respond-to-an-unknown-method-call.fantom new file mode 100644 index 0000000000..e8112f8c51 --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/Fantom/respond-to-an-unknown-method-call.fantom @@ -0,0 +1,32 @@ +class A +{ + public Void doit (Int n) + { + echo ("known function called on $n") + } + + // override the 'trap' method, which catches dynamic invocations of methods + override Obj? trap(Str name, Obj?[]? args := null) + { + try + { + return super.trap(name, args) + } + catch (UnknownSlotErr err) + { + echo ("In trap, you called: " + name + " with args " + args.join(",")) + return null + } + } +} + +class Main +{ + public static Void main () + { + a := A() + // note the dynamic dispatch + a->doit (1) + a->methodName (1, 2, 3) + } +} diff --git a/Task/Respond-to-an-unknown-method-call/Go/respond-to-an-unknown-method-call-1.go b/Task/Respond-to-an-unknown-method-call/Go/respond-to-an-unknown-method-call-1.go new file mode 100644 index 0000000000..9d3b3b9f14 --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/Go/respond-to-an-unknown-method-call-1.go @@ -0,0 +1,29 @@ +package main + +import ( + "fmt" + "reflect" +) + +type example struct{} + +func (example) Foo() int { + return 42 +} + +// a method to call another method by name +func (e example) CallMethod(n string) int { + if m := reflect.ValueOf(e).MethodByName(n); m.IsValid() { + // it's known. call it. + return int(m.Call(nil)[0].Int()) + } + // otherwise it's unknown. handle as needed. + fmt.Println("Unknown method:", n) + return 0 +} + +func main() { + var e example + fmt.Println(e.CallMethod("Foo")) + fmt.Println(e.CallMethod("Bar")) +} diff --git a/Task/Respond-to-an-unknown-method-call/Go/respond-to-an-unknown-method-call-2.go b/Task/Respond-to-an-unknown-method-call/Go/respond-to-an-unknown-method-call-2.go new file mode 100644 index 0000000000..80eae5408a --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/Go/respond-to-an-unknown-method-call-2.go @@ -0,0 +1,16 @@ +procedure DynMethod(obj,meth,arglist[]) + local m + + if not (type(obj) ? ( tab(find("__")), ="__state", pos(0))) then + runerr(205,obj) # invalid value - not an object + + if meth == ("initially"|"UndefinedMethod") then fail # avoid protected + + m := obj.__m # get methods list + if fieldnames(m) == meth then # method exists? + return m[meth]!push(copy(arglist),obj) # ... call it + else + if fieldnames(m) == "UndefinedMethod" then # handler exists? + return obj.UndefinedMethod!arglist # ... call it + else runerr(207,obj) # error invalid method (i.e. field) +end diff --git a/Task/Respond-to-an-unknown-method-call/Go/respond-to-an-unknown-method-call-3.go b/Task/Respond-to-an-unknown-method-call/Go/respond-to-an-unknown-method-call-3.go new file mode 100644 index 0000000000..738e8ab7aa --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/Go/respond-to-an-unknown-method-call-3.go @@ -0,0 +1,31 @@ +procedure main() + x := foo() + y := foo2() + + x.a() # example of normal method call + DynMethod(x,"a") # using DynMethod + DynMethod(x,"simplydoesntexist") # results in error + DynMethod(y,"simplydoesntexist") # catches error + DynMethod(y,"simplydoesntexist",1,2,3,4,5) # with parameters +end + +class foo(A) # sample class and methods + method a(p1) + l1 := p1 + return + end + method b(p2) + l2 := p2 + return + end + initially + i1 := 0 + return +end + +class foo2 : foo (A) + method UndefinedMethod(x[]) # Undefined Method handler + write(&errout,"You called an undefinded method of this object.") + return + end +end diff --git a/Task/Respond-to-an-unknown-method-call/J/respond-to-an-unknown-method-call-1.j b/Task/Respond-to-an-unknown-method-call/J/respond-to-an-unknown-method-call-1.j new file mode 100644 index 0000000000..4438f61851 --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/J/respond-to-an-unknown-method-call-1.j @@ -0,0 +1,7 @@ +example=:3 :0 + doSomething_z_=: assert&0 bind 'doSomething was not implemented' + doSomething__y '' +) + +doSomething_adhoc1_=: smoutput bind 'hello world' +dSomethingElse_adhoc2_=: smoutput bind 'hello world' diff --git a/Task/Respond-to-an-unknown-method-call/J/respond-to-an-unknown-method-call-2.j b/Task/Respond-to-an-unknown-method-call/J/respond-to-an-unknown-method-call-2.j new file mode 100644 index 0000000000..e0d05d5725 --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/J/respond-to-an-unknown-method-call-2.j @@ -0,0 +1,4 @@ + example <'adhoc1' +hello world + example<'adhoc2' +|doSomething was not implemented: assert diff --git a/Task/Respond-to-an-unknown-method-call/JavaScript/respond-to-an-unknown-method-call.js b/Task/Respond-to-an-unknown-method-call/JavaScript/respond-to-an-unknown-method-call.js new file mode 100644 index 0000000000..dda25d3eb7 --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/JavaScript/respond-to-an-unknown-method-call.js @@ -0,0 +1,18 @@ +var example = new Object; +example.foo = function () { + alert("this is foo"); +} +example.bar = function () { + alert("this is bar"); +} +example.__noSuchMethod__ = function (id, args) { + alert("tried to handle unknown method " + id); + if (args.length != 0) + alert("it had arguments: " + args); +} + +example.foo(); // alerts "this is foo" +example.bar(); // alerts "this is bar" +example.grill(); // alerts "tried to handle unknown method grill" +example.ding("dong"); // alerts "tried to handle unknown method ding" + // alerts "it had arguments: dong diff --git a/Task/Respond-to-an-unknown-method-call/Lua/respond-to-an-unknown-method-call.lua b/Task/Respond-to-an-unknown-method-call/Lua/respond-to-an-unknown-method-call.lua new file mode 100644 index 0000000000..77e45c493d --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/Lua/respond-to-an-unknown-method-call.lua @@ -0,0 +1,4 @@ +local object={print=print} +setmetatable(object,{__index=function(t,k)return function() print("You called the method",k)end end}) +object.print("Hi") -->Hi +object.hello() -->You called the method hello diff --git a/Task/Respond-to-an-unknown-method-call/Objective-C/respond-to-an-unknown-method-call.m b/Task/Respond-to-an-unknown-method-call/Objective-C/respond-to-an-unknown-method-call.m new file mode 100644 index 0000000000..a3e25297b6 --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/Objective-C/respond-to-an-unknown-method-call.m @@ -0,0 +1,59 @@ +#include + +// The methods need to be declared somewhere +@interface Dummy : NSObject { } +- (void)grill; +- (void)ding:(NSString *)s; +@end + +@interface Example : NSObject { } +- (void)foo; +- (void)bar; +@end + +@implementation Example +- (void)foo { + NSLog(@"this is foo"); +} +- (void)bar { + NSLog(@"this is bar"); +} +- (void)forwardInvocation:(NSInvocation *)inv { + NSLog(@"tried to handle unknown method %@", NSStringFromSelector([inv selector])); + unsigned n = [[inv methodSignature] numberOfArguments]; + unsigned i; + for (i = 0; i < n-2; i++) { // first two arguments are the object and selector + id arg; // we assume that all arguments are objects + [inv getArgument:&arg atIndex:i+2]; + NSLog(@"argument #%u: %@", i, arg); + } +} +// forwardInvocation: does not work without methodSignatureForSelector: +- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector { + int numArgs = [[NSStringFromSelector(aSelector) componentsSeparatedByString:@":"] count] - 1; + // we assume that all arguments are objects + // The type encoding is "v@:@@@...", where "v" is the return type, void + // "@" is the receiver, object type; ":" is the selector of the current method; + // and each "@" after corresponds to an object argument + return [NSMethodSignature signatureWithObjCTypes: + [[@"v@:" stringByPaddingToLength:numArgs+3 withString:@"@" startingAtIndex:0] UTF8String]]; +} +@end + +int main() +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + id example = [[Example alloc] init]; + + [example foo]; // prints "this is foo" + [example bar]; // prints "this is bar" + [example grill]; // prints "tried to handle unknown method grill" + [example ding:@"dong"]; // prints "tried to handle unknown method ding:" + // prints "argument #0: dong" + [example release]; + + [pool release]; + + return 0; +} diff --git a/Task/Respond-to-an-unknown-method-call/Oz/respond-to-an-unknown-method-call.oz b/Task/Respond-to-an-unknown-method-call/Oz/respond-to-an-unknown-method-call.oz new file mode 100644 index 0000000000..9620a002d5 --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/Oz/respond-to-an-unknown-method-call.oz @@ -0,0 +1,23 @@ +declare + class Example + meth init skip end + + meth foo {System.showInfo foo} end + + meth bar {System.showInfo bar} end + + meth otherwise(Msg) + {System.showInfo "Unknown method "#{Label Msg}} + if {Width Msg} > 0 then + {System.printInfo "Arguments: "} + {System.show {Record.toListInd Msg}} + end + end + end + + Object = {New Example init} + in + {Object foo} + {Object bar} + {Object grill} + {Object ding(dong)} diff --git a/Task/Respond-to-an-unknown-method-call/PHP/respond-to-an-unknown-method-call.php b/Task/Respond-to-an-unknown-method-call/PHP/respond-to-an-unknown-method-call.php new file mode 100644 index 0000000000..9fe773f8c8 --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/PHP/respond-to-an-unknown-method-call.php @@ -0,0 +1,23 @@ +foo(); // prints "this is foo" +$example->bar(); // prints "this is bar" +$example->grill(); // prints "tried to handle unknown method grill" +$example->ding("dong"); // prints "tried to handle unknown method ding" + // prints "it had arguments: dong +?> diff --git a/Task/Respond-to-an-unknown-method-call/Perl-6/respond-to-an-unknown-method-call.pl6 b/Task/Respond-to-an-unknown-method-call/Perl-6/respond-to-an-unknown-method-call.pl6 new file mode 100644 index 0000000000..20f8a761e1 --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/Perl-6/respond-to-an-unknown-method-call.pl6 @@ -0,0 +1,10 @@ +class Farragut { + method FALLBACK ($name, *@rest) { + say "{self.WHAT.perl}: $name.tc() the @rest[], full speed ahead!"; + } +} + +class Sparrow is Farragut { } + +Farragut.damn: 'torpedoes'; +Sparrow.hoist: ; diff --git a/Task/Respond-to-an-unknown-method-call/Perl/respond-to-an-unknown-method-call.pl b/Task/Respond-to-an-unknown-method-call/Perl/respond-to-an-unknown-method-call.pl new file mode 100644 index 0000000000..fd80166a81 --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/Perl/respond-to-an-unknown-method-call.pl @@ -0,0 +1,30 @@ +package Example; +sub new { + bless {} +} +sub foo { + print "this is foo\n"; +} +sub bar { + print "this is bar\n"; +} +sub AUTOLOAD { + my $name = $Example::AUTOLOAD; + my ($self, @args) = @_; + print "tried to handle unknown method $name\n"; + if (@args) { + print "it had arguments: @args\n"; + } +} +sub DESTROY {} # dummy method to prevent AUTOLOAD from + # being triggered when an Example is + # destroyed + +package main; +my $example = Example->new; + +$example->foo; # prints "this is foo" +$example->bar; # prints "this is bar" +$example->grill; # prints "tried to handle unknown method Example::grill" +$example->ding("dong"); # prints "tried to handle unknown method Example::ding" + # and "it had arguments: dong" diff --git a/Task/Respond-to-an-unknown-method-call/PicoLisp/respond-to-an-unknown-method-call-1.l b/Task/Respond-to-an-unknown-method-call/PicoLisp/respond-to-an-unknown-method-call-1.l new file mode 100644 index 0000000000..e2acdce497 --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/PicoLisp/respond-to-an-unknown-method-call-1.l @@ -0,0 +1,12 @@ +(redef send (Msg Obj . @) + (or + (pass try Msg Obj) + (pass 'no-applicable-method> Obj Msg) ) ) + +(de no-applicable-method> (This Msg) + (pack "No method for " Msg " on " This) ) + +(class +A) + +(dm do-something> () + (pack "Do something to " This) ) diff --git a/Task/Respond-to-an-unknown-method-call/PicoLisp/respond-to-an-unknown-method-call-2.l b/Task/Respond-to-an-unknown-method-call/PicoLisp/respond-to-an-unknown-method-call-2.l new file mode 100644 index 0000000000..77f8ce6205 --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/PicoLisp/respond-to-an-unknown-method-call-2.l @@ -0,0 +1,6 @@ +: (object 'A '(+A)) +-> A +: (object 'B '(+B)) +-> B +: (list (send 'do-something> 'A) (send 'do-something> 'B)) +-> ("Do something to A" "No method for do-something> on B") diff --git a/Task/Respond-to-an-unknown-method-call/Pike/respond-to-an-unknown-method-call.pike b/Task/Respond-to-an-unknown-method-call/Pike/respond-to-an-unknown-method-call.pike new file mode 100644 index 0000000000..1c9ba9e51d --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/Pike/respond-to-an-unknown-method-call.pike @@ -0,0 +1,12 @@ +class CatchAll +{ + mixed `->(string name) + { + return lambda(int arg){ write("you are calling %s(%d);\n", name, arg); }; + } +} + +> CatchAll()->hello(5); +you are calling hello(5); +> CatchAll()->something(99); +you are calling something(99); diff --git a/Task/Respond-to-an-unknown-method-call/Python/respond-to-an-unknown-method-call.py b/Task/Respond-to-an-unknown-method-call/Python/respond-to-an-unknown-method-call.py new file mode 100644 index 0000000000..32192594c4 --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/Python/respond-to-an-unknown-method-call.py @@ -0,0 +1,19 @@ +class Example(object): + def foo(self): + print("this is foo") + def bar(self): + print("this is bar") + def __getattr__(self, name): + def method(*args): + print("tried to handle unknown method " + name) + if args: + print("it had arguments: " + str(args)) + return method + +example = Example() + +example.foo() # prints “this is foo” +example.bar() # prints “this is bar” +example.grill() # prints “tried to handle unknown method grill” +example.ding("dong") # prints “tried to handle unknown method ding” + # prints “it had arguments: ('dong',)” diff --git a/Task/Respond-to-an-unknown-method-call/Ruby/respond-to-an-unknown-method-call.rb b/Task/Respond-to-an-unknown-method-call/Ruby/respond-to-an-unknown-method-call.rb new file mode 100644 index 0000000000..690a79c959 --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/Ruby/respond-to-an-unknown-method-call.rb @@ -0,0 +1,22 @@ +class Example + def foo + puts "this is foo" + end + def bar + puts "this is bar" + end + def method_missing(name, *args, &block) + puts "tried to handle unknown method %s" % name # name is a symbol + unless args.empty? + puts "it had arguments: %p" % [args] + end + end +end + +example = Example.new + +example.foo # prints “this is foo” +example.bar # prints “this is bar” +example.grill # prints “tried to handle unknown method grill” +example.ding("dong") # prints “tried to handle unknown method ding” + # prints “it had arguments: ["dong"]” diff --git a/Task/Respond-to-an-unknown-method-call/Scala/respond-to-an-unknown-method-call.scala b/Task/Respond-to-an-unknown-method-call/Scala/respond-to-an-unknown-method-call.scala new file mode 100644 index 0000000000..c4a3b7cda2 --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/Scala/respond-to-an-unknown-method-call.scala @@ -0,0 +1,20 @@ +class DynamicTest extends Dynamic +{ + def foo()=println("this is foo") + def bar()=println("this is bar") + def applyDynamic(name: String)(args: Any*)={ + println("tried to handle unknown method "+name) + if(!args.isEmpty) + println(" it had arguments: "+args.mkString(",")) + } +} + +object DynamicTest { + def main(args: Array[String]): Unit = { + val d=new DynamicTest() + d.foo() + d.bar() + d.grill() + d.ding("dong") + } +} diff --git a/Task/Respond-to-an-unknown-method-call/Slate/respond-to-an-unknown-method-call-1.slate b/Task/Respond-to-an-unknown-method-call/Slate/respond-to-an-unknown-method-call-1.slate new file mode 100644 index 0000000000..a12eaedad9 --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/Slate/respond-to-an-unknown-method-call-1.slate @@ -0,0 +1,24 @@ +define: #shell &builder: [lobby newSubSpace]. + +_@shell didNotUnderstand: message at: position +"Form a command string and execute it." +[ + position > 0 + ifTrue: [resend] + ifFalse: + [([| :command | + message selector isUnarySelector ifTrue: + [command ; message selector. + message optionals pairsDo: + [| :key :value | + command ; ' -' ; (key as: String) allButFirst allButLast ; ' ' ; (value as: String)]]. + message selector isKeywordSelector ifTrue: + [| keywords args | + keywords: ((message selector as: String) splitWith: $:). + command ; keywords first. + keywords size = 1 ifTrue: "Read a string or array of arguments." + [args: message arguments second. + (args is: String) ifTrue: [command ; ' ' ; args] + ifFalse: [args do: [| :arg | command ; ' ' ; arg]]]]] writingAs: String) + ifNil: [resend] ifNotNilDo: [| :cmd | [Platform run: cmd]]] +]. diff --git a/Task/Respond-to-an-unknown-method-call/Slate/respond-to-an-unknown-method-call-2.slate b/Task/Respond-to-an-unknown-method-call/Slate/respond-to-an-unknown-method-call-2.slate new file mode 100644 index 0000000000..ca6457245f --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/Slate/respond-to-an-unknown-method-call-2.slate @@ -0,0 +1,5 @@ +slate[1]> shell ls: '*.image'. +kernel.new.little.64.1244260494374694.image slate2.image +net.image slate.image +True +slate[2]> diff --git a/Task/Respond-to-an-unknown-method-call/Smalltalk/respond-to-an-unknown-method-call-1.st b/Task/Respond-to-an-unknown-method-call/Smalltalk/respond-to-an-unknown-method-call-1.st new file mode 100644 index 0000000000..5576451360 --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/Smalltalk/respond-to-an-unknown-method-call-1.st @@ -0,0 +1,18 @@ +Object subclass: CatchThemAll [ + foo [ 'foo received' displayNl ] + + bar [ 'bar received' displayNl ] + + doesNotUnderstand: aMessage [ + ('message "' , (aMessage selector asString) , '"') displayNl. + (aMessage arguments) do: [ :a | + 'argument: ' display. a printNl. + ] + ] +] + +|a| a := CatchThemAll new. +a foo. +a bar. +a weCanDoIt. +a theyCanToo: 'eat' and: 'walk'. diff --git a/Task/Respond-to-an-unknown-method-call/Smalltalk/respond-to-an-unknown-method-call-2.st b/Task/Respond-to-an-unknown-method-call/Smalltalk/respond-to-an-unknown-method-call-2.st new file mode 100644 index 0000000000..aa144428cd --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/Smalltalk/respond-to-an-unknown-method-call-2.st @@ -0,0 +1,6 @@ +[ + bla := someObject fooBar. + foo := bla. +] on: MessageNotUnderstood do:[:ex | + ex return: 'fortyTwo' +] diff --git a/Task/Respond-to-an-unknown-method-call/Smalltalk/respond-to-an-unknown-method-call-3.st b/Task/Respond-to-an-unknown-method-call/Smalltalk/respond-to-an-unknown-method-call-3.st new file mode 100644 index 0000000000..e607ecdf29 --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/Smalltalk/respond-to-an-unknown-method-call-3.st @@ -0,0 +1,11 @@ +[ + bla := someObject fooBar. + foo := bla. +] on: MessageNotUnderstood do:[:ex | + ((ex message selector == #fooBar) and: [ ex message receiver == someObject]) + ifTrue:[ + ex return: 'fortyTwo' + ] ifFalse:[ + ex reject + ] +] diff --git a/Task/Respond-to-an-unknown-method-call/Smalltalk/respond-to-an-unknown-method-call-4.st b/Task/Respond-to-an-unknown-method-call/Smalltalk/respond-to-an-unknown-method-call-4.st new file mode 100644 index 0000000000..f773bdf748 --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/Smalltalk/respond-to-an-unknown-method-call-4.st @@ -0,0 +1 @@ +anObject perform:#fooBar ifNotUnderstood:[ ...some alternative code and return value... ]. diff --git a/Task/Respond-to-an-unknown-method-call/Tcl/respond-to-an-unknown-method-call.tcl b/Task/Respond-to-an-unknown-method-call/Tcl/respond-to-an-unknown-method-call.tcl new file mode 100644 index 0000000000..0871edf397 --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/Tcl/respond-to-an-unknown-method-call.tcl @@ -0,0 +1,28 @@ +package require TclOO +# First create a simple, conventional class and object +oo::class create Example { + method foo {} { + puts "this is foo" + } + method bar {} { + puts "this is bar" + } +} +Example create example + +# Modify the object to have a custom ‘unknown method’ interceptor +oo::objdefine example { + method unknown {name args} { + puts "tried to handle unknown method \"$name\"" + if {[llength $args]} { + puts "it had arguments: $args" + } + } +} + +# Show off what we can now do... +example foo; # prints “this is foo” +example bar; # prints “this is bar” +example grill; # prints “tried to handle unknown method "grill"” +example ding dong; # prints “tried to handle unknown method "ding"” + # prints “it had arguments: dong” diff --git a/Task/Respond-to-an-unknown-method-call/UNIX-Shell/respond-to-an-unknown-method-call.sh b/Task/Respond-to-an-unknown-method-call/UNIX-Shell/respond-to-an-unknown-method-call.sh new file mode 100644 index 0000000000..cd3172a55f --- /dev/null +++ b/Task/Respond-to-an-unknown-method-call/UNIX-Shell/respond-to-an-unknown-method-call.sh @@ -0,0 +1,17 @@ +function handle_error { + status=$? + + # 127 is: command not found + if [[ $status -ne 127 ]]; then + return + fi + + lastcmd=$(history | tail -1 | sed 's/^ *[0-9]* *//') + + read cmd args <<< "$lastcmd" + + echo "you tried to call $cmd" +} + +# Trap errors. +trap 'handle_error' ERR diff --git a/Task/Return-multiple-values/0DESCRIPTION b/Task/Return-multiple-values/0DESCRIPTION new file mode 100644 index 0000000000..48da6d70c7 --- /dev/null +++ b/Task/Return-multiple-values/0DESCRIPTION @@ -0,0 +1 @@ +Show how to return more than one value from a function. diff --git a/Task/Return-multiple-values/1META.yaml b/Task/Return-multiple-values/1META.yaml new file mode 100644 index 0000000000..e316a9ad81 --- /dev/null +++ b/Task/Return-multiple-values/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Functions and subroutines +note: Basic language learning diff --git a/Task/Return-multiple-values/ACL2/return-multiple-values.acl2 b/Task/Return-multiple-values/ACL2/return-multiple-values.acl2 new file mode 100644 index 0000000000..b67ba0dedf --- /dev/null +++ b/Task/Return-multiple-values/ACL2/return-multiple-values.acl2 @@ -0,0 +1,8 @@ +;; To return multiple values: +(defun multiple-values (a b) + (mv a b)) + +;; To extract the values: +(mv-let (x y) + (multiple-values 1 2) + (+ x y)) diff --git a/Task/Return-multiple-values/ATS/return-multiple-values.ats b/Task/Return-multiple-values/ATS/return-multiple-values.ats new file mode 100644 index 0000000000..e33604b119 --- /dev/null +++ b/Task/Return-multiple-values/ATS/return-multiple-values.ats @@ -0,0 +1,9 @@ +fn addsub (x: int, y: int): (int, int) = + (x+y, x-y) + +implement main () = let + val (sum, diff) = addsub (33, 12) +in + print! ("33 + 12 = ", sum, "\n"); + print! ("33 - 12 = ", diff, "\n") +end diff --git a/Task/Return-multiple-values/Ada/return-multiple-values.ada b/Task/Return-multiple-values/Ada/return-multiple-values.ada new file mode 100644 index 0000000000..4af168fbdf --- /dev/null +++ b/Task/Return-multiple-values/Ada/return-multiple-values.ada @@ -0,0 +1,14 @@ +with Ada.Text_IO; use Ada.Text_IO; +procedure MultiReturn is + procedure SumAndDiff (x, y : Integer; sum, diff : out Integer) is begin + sum := x + y; + diff := x - y; + end SumAndDiff; + inta : Integer := 5; + intb : Integer := 3; + thesum, thediff : Integer; +begin + SumAndDiff (inta, intb, thesum, thediff); + Put_Line ("Sum:" & Integer'Image (thesum)); + Put_Line ("Diff:" & Integer'Image (thediff)); +end MultiReturn; diff --git a/Task/Return-multiple-values/AutoHotkey/return-multiple-values.ahk b/Task/Return-multiple-values/AutoHotkey/return-multiple-values.ahk new file mode 100644 index 0000000000..4537a30eae --- /dev/null +++ b/Task/Return-multiple-values/AutoHotkey/return-multiple-values.ahk @@ -0,0 +1,3 @@ +addsub(x, y) { + return [x + y, x - y] +} diff --git a/Task/Return-multiple-values/AutoIt/return-multiple-values.autoit b/Task/Return-multiple-values/AutoIt/return-multiple-values.autoit new file mode 100644 index 0000000000..07b10174b5 --- /dev/null +++ b/Task/Return-multiple-values/AutoIt/return-multiple-values.autoit @@ -0,0 +1,6 @@ +Func _AddSub($iX, $iY) +Local $aReturn[2] +$aReturn[0] = $iX + $iY +$aReturn[1] = $iX - $iY +Return $aReturn +EndFunc diff --git a/Task/Return-multiple-values/BBC-BASIC/return-multiple-values.bbc b/Task/Return-multiple-values/BBC-BASIC/return-multiple-values.bbc new file mode 100644 index 0000000000..cac0458433 --- /dev/null +++ b/Task/Return-multiple-values/BBC-BASIC/return-multiple-values.bbc @@ -0,0 +1,9 @@ + PROCsumdiff(5, 3, sum, diff) + PRINT "Sum is " ; sum + PRINT "Difference is " ; diff + END + + DEF PROCsumdiff(a, b, RETURN c, RETURN d) + c = a + b + d = a - b + ENDPROC diff --git a/Task/Return-multiple-values/Bracmat/return-multiple-values-1.bracmat b/Task/Return-multiple-values/Bracmat/return-multiple-values-1.bracmat new file mode 100644 index 0000000000..43439f3f88 --- /dev/null +++ b/Task/Return-multiple-values/Bracmat/return-multiple-values-1.bracmat @@ -0,0 +1 @@ +(addsub=x y.!arg:(?x.?y)&(!x+!y.!x+-1*!y)); diff --git a/Task/Return-multiple-values/Bracmat/return-multiple-values-2.bracmat b/Task/Return-multiple-values/Bracmat/return-multiple-values-2.bracmat new file mode 100644 index 0000000000..a4e2cc50ee --- /dev/null +++ b/Task/Return-multiple-values/Bracmat/return-multiple-values-2.bracmat @@ -0,0 +1,4 @@ +( addsub$(33.12):(?sum.?difference) +& out$("33 + 12 = " !sum) +& out$("33 - 12 = " !difference) +); diff --git a/Task/Return-multiple-values/C++/return-multiple-values.cpp b/Task/Return-multiple-values/C++/return-multiple-values.cpp new file mode 100644 index 0000000000..24cb067615 --- /dev/null +++ b/Task/Return-multiple-values/C++/return-multiple-values.cpp @@ -0,0 +1,19 @@ +#include +#include +#include + +std::tr1::tuple minmax ( const int * numbers , const int num ) { + const int *maximum = std::max_element ( numbers , numbers + num ) ; + const int *minimum = std::min_element ( numbers , numbers + num ) ; + std::tr1::tuple result( *maximum , *minimum ) ; + return result ; +} + +int main( ) { + const int numbers[ ] = { 17 , 88 , 9 , 33 , 4 , 987 , -10 , 2 } ; + int numbersize = sizeof( numbers ) / sizeof ( int ) ; + std::tr1::tuple result = minmax( numbers , numbersize ) ; + std::cout << "The greatest number is " << std::tr1::get<0>( result ) + << " , the smallest " << std::tr1::get<1>( result ) << " !\n" ; + return 0 ; +} diff --git a/Task/Return-multiple-values/C/return-multiple-values.c b/Task/Return-multiple-values/C/return-multiple-values.c new file mode 100644 index 0000000000..3792fb5c90 --- /dev/null +++ b/Task/Return-multiple-values/C/return-multiple-values.c @@ -0,0 +1,39 @@ +#include + +typedef struct{ + int integer; + float decimal; + char letter; + char string[100]; + double bigDecimal; +}Composite; + +typedef union{ + int num; + char letter; +}Zip; + +Composite example() +{ + Composite C = {1,2.3,'a',"Hello World",45.678}; + return C; +} + +Zip example2() +{ + Zip r; + r.num = 99; + r.letter = 'C'; + return r; +} + +int main() +{ + Composite C = example(); + Zip rar = example2(); + + printf("Values from a function returning a structure : { %d, %f, %c, %s, %f}",C.integer, C.decimal,C.letter,C.string,C.bigDecimal); + printf("\n\nValues from a function returning a union : { %d, %c}",rar.num,rar.letter); + + return 0; +} diff --git a/Task/Return-multiple-values/CMake/return-multiple-values.cmake b/Task/Return-multiple-values/CMake/return-multiple-values.cmake new file mode 100644 index 0000000000..e838f58e2b --- /dev/null +++ b/Task/Return-multiple-values/CMake/return-multiple-values.cmake @@ -0,0 +1,17 @@ +# Returns the first and last characters of string. +function(firstlast string first last) + # f = first character. + string(SUBSTRING "${string}" 0 1 f) + + # g = last character. + string(LENGTH "${string}" length) + math(EXPR index "${length} - 1") + string(SUBSTRING "${string}" ${index} 1 g) + + # Return both characters. + set("${first}" "${f}" PARENT_SCOPE) + set("${last}" "${g}" PARENT_SCOPE) +endfunction(firstlast) + +firstlast("Rosetta Code" begin end) +message(STATUS "begins with ${begin}, ends with ${end}") diff --git a/Task/Return-multiple-values/Clojure/return-multiple-values-1.clj b/Task/Return-multiple-values/Clojure/return-multiple-values-1.clj new file mode 100644 index 0000000000..4788b40534 --- /dev/null +++ b/Task/Return-multiple-values/Clojure/return-multiple-values-1.clj @@ -0,0 +1,6 @@ +(defn quot-rem [m n] [(quot m n) (rem m n)]) + +; The following prints 3 2. +(let [[q r] (quot-rem 11 3)] + (println q) + (println r)) diff --git a/Task/Return-multiple-values/Clojure/return-multiple-values-2.clj b/Task/Return-multiple-values/Clojure/return-multiple-values-2.clj new file mode 100644 index 0000000000..4e9d572e96 --- /dev/null +++ b/Task/Return-multiple-values/Clojure/return-multiple-values-2.clj @@ -0,0 +1,8 @@ +(defn quot-rem [m n] + {:q (quot m n) + :r (rem m n)}) + +; The following prints 3 2. +(let [{:keys [q r]} (quot-rem 11 3)] + (println q) + (println r)) diff --git a/Task/Return-multiple-values/Common-Lisp/return-multiple-values-1.lisp b/Task/Return-multiple-values/Common-Lisp/return-multiple-values-1.lisp new file mode 100644 index 0000000000..338fae02ca --- /dev/null +++ b/Task/Return-multiple-values/Common-Lisp/return-multiple-values-1.lisp @@ -0,0 +1,2 @@ +(defun return-three () + 3) diff --git a/Task/Return-multiple-values/Common-Lisp/return-multiple-values-10.lisp b/Task/Return-multiple-values/Common-Lisp/return-multiple-values-10.lisp new file mode 100644 index 0000000000..85d06ae13c --- /dev/null +++ b/Task/Return-multiple-values/Common-Lisp/return-multiple-values-10.lisp @@ -0,0 +1,2 @@ +;; assign 5 to dividend, 1 to remainder: +(multiple-value-setq (dividend remainder) (truncate 16 1)) diff --git a/Task/Return-multiple-values/Common-Lisp/return-multiple-values-11.lisp b/Task/Return-multiple-values/Common-Lisp/return-multiple-values-11.lisp new file mode 100644 index 0000000000..d0873a9152 --- /dev/null +++ b/Task/Return-multiple-values/Common-Lisp/return-multiple-values-11.lisp @@ -0,0 +1 @@ +(setf (values dividend remainder) (truncate 16 1)) diff --git a/Task/Return-multiple-values/Common-Lisp/return-multiple-values-2.lisp b/Task/Return-multiple-values/Common-Lisp/return-multiple-values-2.lisp new file mode 100644 index 0000000000..fdac738c83 --- /dev/null +++ b/Task/Return-multiple-values/Common-Lisp/return-multiple-values-2.lisp @@ -0,0 +1,2 @@ +(defun return-nothing () + (values)) diff --git a/Task/Return-multiple-values/Common-Lisp/return-multiple-values-3.lisp b/Task/Return-multiple-values/Common-Lisp/return-multiple-values-3.lisp new file mode 100644 index 0000000000..90f228de6d --- /dev/null +++ b/Task/Return-multiple-values/Common-Lisp/return-multiple-values-3.lisp @@ -0,0 +1,12 @@ +[1]> (defun add-sub (x y) (values-list (list (+ x y) (- x y)))) +ADD-SUB +[2]> (add-sub 4 2) ; 6 (primary) and 2 +6 ; +2 +[3]> (add-sub 3 1) ; 4 (primary) and 2 +4 ; +2 +[4]> (+ (add-sub 4 2) (add-sub 3 1)) ; 6 + 4 +10 +[5]> (multiple-value-call #'+ (add-sub 4 2) (add-sub 3 1)) ; 6+2+4+2 +14 diff --git a/Task/Return-multiple-values/Common-Lisp/return-multiple-values-4.lisp b/Task/Return-multiple-values/Common-Lisp/return-multiple-values-4.lisp new file mode 100644 index 0000000000..1187c56935 --- /dev/null +++ b/Task/Return-multiple-values/Common-Lisp/return-multiple-values-4.lisp @@ -0,0 +1 @@ +(car (values)) ;; no error: same as (car nil) diff --git a/Task/Return-multiple-values/Common-Lisp/return-multiple-values-5.lisp b/Task/Return-multiple-values/Common-Lisp/return-multiple-values-5.lisp new file mode 100644 index 0000000000..7174b261b4 --- /dev/null +++ b/Task/Return-multiple-values/Common-Lisp/return-multiple-values-5.lisp @@ -0,0 +1 @@ +(values (values 1 2 3) (values) 'a) diff --git a/Task/Return-multiple-values/Common-Lisp/return-multiple-values-6.lisp b/Task/Return-multiple-values/Common-Lisp/return-multiple-values-6.lisp new file mode 100644 index 0000000000..4bb1df7850 --- /dev/null +++ b/Task/Return-multiple-values/Common-Lisp/return-multiple-values-6.lisp @@ -0,0 +1,3 @@ +;; return exactly one value, no matter how many expr returns, +;; nil if expr returns no values +(values expr) diff --git a/Task/Return-multiple-values/Common-Lisp/return-multiple-values-7.lisp b/Task/Return-multiple-values/Common-Lisp/return-multiple-values-7.lisp new file mode 100644 index 0000000000..e488b2c797 --- /dev/null +++ b/Task/Return-multiple-values/Common-Lisp/return-multiple-values-7.lisp @@ -0,0 +1,3 @@ +(multiple-value-bind (dividend remainder) (truncate 16 3) + ;; in this scope dividend is 5; remainder is 1 + ) diff --git a/Task/Return-multiple-values/Common-Lisp/return-multiple-values-8.lisp b/Task/Return-multiple-values/Common-Lisp/return-multiple-values-8.lisp new file mode 100644 index 0000000000..899e1c1f1f --- /dev/null +++ b/Task/Return-multiple-values/Common-Lisp/return-multiple-values-8.lisp @@ -0,0 +1 @@ +(multiple-value-list (truncate 16 3)) ;; yields (5 1) diff --git a/Task/Return-multiple-values/Common-Lisp/return-multiple-values-9.lisp b/Task/Return-multiple-values/Common-Lisp/return-multiple-values-9.lisp new file mode 100644 index 0000000000..d734da731f --- /dev/null +++ b/Task/Return-multiple-values/Common-Lisp/return-multiple-values-9.lisp @@ -0,0 +1,2 @@ +;; pass arguments 5 1 to +, resulting in 6: +(multiple-value-call #'+ (truncate 16 3)) diff --git a/Task/Return-multiple-values/D/return-multiple-values.d b/Task/Return-multiple-values/D/return-multiple-values.d new file mode 100644 index 0000000000..a1b87c2156 --- /dev/null +++ b/Task/Return-multiple-values/D/return-multiple-values.d @@ -0,0 +1,10 @@ +import std.stdio, std.typecons; + +auto addSub(T)(T x, T y) { + return tuple(x + y, x - y); +} + +void main() { + auto r = addSub(33, 12); + writefln("33 + 12 = %d\n33 - 12 = %d", r.tupleof); +} diff --git a/Task/Return-multiple-values/Delphi/return-multiple-values.delphi b/Task/Return-multiple-values/Delphi/return-multiple-values.delphi new file mode 100644 index 0000000000..2f4fb596a1 --- /dev/null +++ b/Task/Return-multiple-values/Delphi/return-multiple-values.delphi @@ -0,0 +1,17 @@ +program ReturnMultipleValues; + +{$APPTYPE CONSOLE} + +procedure GetTwoValues(var aParam1, aParam2: Integer); +begin + aParam1 := 100; + aParam2 := 200; +end; + +var + x, y: Integer; +begin + GetTwoValues(x, y); + Writeln(x); + Writeln(y); +end. diff --git a/Task/Return-multiple-values/Euphoria/return-multiple-values.euphoria b/Task/Return-multiple-values/Euphoria/return-multiple-values.euphoria new file mode 100644 index 0000000000..bb85f7d752 --- /dev/null +++ b/Task/Return-multiple-values/Euphoria/return-multiple-values.euphoria @@ -0,0 +1,14 @@ +include std\console.e --only for any_key, to help make running this program easy on windows GUI + +integer aWholeNumber = 1 +atom aFloat = 1.999999 +sequence aSequence = {3, 4} +sequence result = {} --empty initialized sequence + +function addmultret(integer first, atom second, sequence third)--takes three kinds of input, adds them all into one element of the.. + return (first + second + third[1]) + third[2] & (first * second * third[1]) * third[2] --..output sequence and multiplies them into.. +end function --..the second element + +result = addmultret(aWholeNumber, aFloat, aSequence) --call function, assign what it gets into result - {9.999999, 23.999988} +? result +any_key() diff --git a/Task/Return-multiple-values/FALSE/return-multiple-values.false b/Task/Return-multiple-values/FALSE/return-multiple-values.false new file mode 100644 index 0000000000..b1c6b889bc --- /dev/null +++ b/Task/Return-multiple-values/FALSE/return-multiple-values.false @@ -0,0 +1,2 @@ +[\$@$@*@@/]f: { in: a b, out: a*b a/b } +6 2f;! .` ,. { 3 12 } diff --git a/Task/Return-multiple-values/Factor/return-multiple-values.factor b/Task/Return-multiple-values/Factor/return-multiple-values.factor new file mode 100644 index 0000000000..3848aab373 --- /dev/null +++ b/Task/Return-multiple-values/Factor/return-multiple-values.factor @@ -0,0 +1,10 @@ +USING: io kernel math prettyprint ; +IN: script + +: */ ( x y -- x*y x/y ) + [ * ] [ / ] 2bi ; + +15 3 */ + +[ "15 * 3 = " write . ] +[ "15 / 3 = " write . ] bi* diff --git a/Task/Return-multiple-values/Forth/return-multiple-values.fth b/Task/Return-multiple-values/Forth/return-multiple-values.fth new file mode 100644 index 0000000000..935a206e01 --- /dev/null +++ b/Task/Return-multiple-values/Forth/return-multiple-values.fth @@ -0,0 +1,2 @@ +: muldiv ( a b -- a*b a/b ) + 2dup / >r * r> ; diff --git a/Task/Return-multiple-values/Go/return-multiple-values-1.go b/Task/Return-multiple-values/Go/return-multiple-values-1.go new file mode 100644 index 0000000000..9c8cc6e6fb --- /dev/null +++ b/Task/Return-multiple-values/Go/return-multiple-values-1.go @@ -0,0 +1,3 @@ +func addsub(x, y int) (int, int) { + return x + y, x - y +} diff --git a/Task/Return-multiple-values/Go/return-multiple-values-2.go b/Task/Return-multiple-values/Go/return-multiple-values-2.go new file mode 100644 index 0000000000..5d6e0372e9 --- /dev/null +++ b/Task/Return-multiple-values/Go/return-multiple-values-2.go @@ -0,0 +1,5 @@ +func addsub(x, y int) (sum, difference int) { + sum = x + y + difference = x - y + return +} diff --git a/Task/Return-multiple-values/Go/return-multiple-values-3.go b/Task/Return-multiple-values/Go/return-multiple-values-3.go new file mode 100644 index 0000000000..5f4a44fb15 --- /dev/null +++ b/Task/Return-multiple-values/Go/return-multiple-values-3.go @@ -0,0 +1,3 @@ +sum, difference := addsub(33, 12) +fmt.Printf("33 + 12 = %d\n", sum) +fmt.Printf("33 - 12 = %d\n", difference) diff --git a/Task/Return-multiple-values/Groovy/return-multiple-values-1.groovy b/Task/Return-multiple-values/Groovy/return-multiple-values-1.groovy new file mode 100644 index 0000000000..d2517d45ae --- /dev/null +++ b/Task/Return-multiple-values/Groovy/return-multiple-values-1.groovy @@ -0,0 +1,6 @@ +def addSub(x,y) { + [ + sum: x+y, + difference: x-y + ] +} diff --git a/Task/Return-multiple-values/Groovy/return-multiple-values-2.groovy b/Task/Return-multiple-values/Groovy/return-multiple-values-2.groovy new file mode 100644 index 0000000000..6a1c2bf313 --- /dev/null +++ b/Task/Return-multiple-values/Groovy/return-multiple-values-2.groovy @@ -0,0 +1,3 @@ +addSub(10,12) + +["sum":22, "difference":-2] diff --git a/Task/Return-multiple-values/Haskell/return-multiple-values-1.hs b/Task/Return-multiple-values/Haskell/return-multiple-values-1.hs new file mode 100644 index 0000000000..cb885baaca --- /dev/null +++ b/Task/Return-multiple-values/Haskell/return-multiple-values-1.hs @@ -0,0 +1,2 @@ +addsub x y = + (x + y, x - y) diff --git a/Task/Return-multiple-values/Haskell/return-multiple-values-2.hs b/Task/Return-multiple-values/Haskell/return-multiple-values-2.hs new file mode 100644 index 0000000000..4b05681b90 --- /dev/null +++ b/Task/Return-multiple-values/Haskell/return-multiple-values-2.hs @@ -0,0 +1,4 @@ +main = do + let sum, difference = addsub 33 12 + putStrLn $ "33 + 12 = " ++ show sum + putStrLn $ "33 - 12 = " ++ show difference diff --git a/Task/Return-multiple-values/Icon/return-multiple-values.icon b/Task/Return-multiple-values/Icon/return-multiple-values.icon new file mode 100644 index 0000000000..c25481b5d3 --- /dev/null +++ b/Task/Return-multiple-values/Icon/return-multiple-values.icon @@ -0,0 +1,26 @@ +procedure retList() # returns as ordered list +return [1,2,3] +end + +procedure retSet() # returns as un-ordered list +insert(S := set(),3,1,2) +return S +end + +procedure retLazy() # return as a generator +suspend 1|2|3 +end + +procedure retTable() # return as a table +T := table() +T["A"] := 1 +T["B"] := 2 +T["C"] := 3 +return T +end + +record retdata(a,b,c) + +procedure retRecord() # return as a record, least general method +return retdata(1,2,3) +end diff --git a/Task/Return-multiple-values/J/return-multiple-values.j b/Task/Return-multiple-values/J/return-multiple-values.j new file mode 100644 index 0000000000..f465eedb1d --- /dev/null +++ b/Task/Return-multiple-values/J/return-multiple-values.j @@ -0,0 +1,2 @@ + 1 2+3 4 +4 6 diff --git a/Task/Return-multiple-values/Java/return-multiple-values.java b/Task/Return-multiple-values/Java/return-multiple-values.java new file mode 100644 index 0000000000..b00c67d403 --- /dev/null +++ b/Task/Return-multiple-values/Java/return-multiple-values.java @@ -0,0 +1,100 @@ +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; + +// ============================================================================= +public class RReturnMultipleVals { + public static final String K_lipsum = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."; + public static final Long K_1024 = 1024L; + public static final String L = "L"; + public static final String R = "R"; + + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + public static void main(String[] args) throws NumberFormatException{ + Long nv_; + String sv_; + switch (args.length) { + case 0: + nv_ = K_1024; + sv_ = K_lipsum; + break; + case 1: + nv_ = Long.parseLong(args[0]); + sv_ = K_lipsum; + break; + case 2: + nv_ = Long.parseLong(args[0]); + sv_ = args[1]; + break; + default: + nv_ = Long.parseLong(args[0]); + sv_ = args[1]; + for (int ix = 2; ix < args.length; ++ix) { + sv_ = sv_ + " " + args[ix]; + } + break; + } + + RReturnMultipleVals lcl = new RReturnMultipleVals(); + + Pair rvp = lcl.getPairFromPair(nv_, sv_); // values returned in a bespoke object + System.out.println("Results extracted from a composite object:"); + System.out.printf("%s, %s%n%n", rvp.getLeftVal(), rvp.getRightVal()); + + List rvl = lcl.getPairFromList(nv_, sv_); // values returned in a Java Collection object + System.out.println("Results extracted from a Java Colections \"List\" object:"); + System.out.printf("%s, %s%n%n", rvl.get(0), rvl.get(1)); + + Map rvm = lcl.getPairFromMap(nv_, sv_); // values returned in a Java Collection object + System.out.println("Results extracted from a Java Colections \"Map\" object:"); + System.out.printf("%s, %s%n%n", rvm.get(L), rvm.get(R)); + } + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // Return a bespoke object. + // Permits any number and type of value to be returned + public Pair getPairFromPair(T vl_, U vr_) { + return new Pair(vl_, vr_); + } + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // Exploit Java Collections classes to assemble a collection of results. + // This example uses java.util.List + public List getPairFromList(Object nv_, Object sv_) { + List rset = new ArrayList(); + rset.add(nv_); + rset.add(sv_); + return rset; + } + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // Exploit Java Collections classes to assemble a collection of results. + // This example uses java.util.Map + public Map getPairFromMap(Object nv_, Object sv_) { + Map rset = new HashMap(); + rset.put(L, nv_); + rset.put(R, sv_); + return rset; + } + + // =========================================================================== + private static class Pair { + private L leftVal; + private R rightVal; + + public Pair(L nv_, R sv_) { + setLeftVal(nv_); + setRightVal(sv_); + } + public void setLeftVal(L nv_) { + leftVal = nv_; + } + public L getLeftVal() { + return leftVal; + } + public void setRightVal(R sv_) { + rightVal = sv_; + } + public R getRightVal() { + return rightVal; + } + } +} diff --git a/Task/Return-multiple-values/Julia/return-multiple-values.julia b/Task/Return-multiple-values/Julia/return-multiple-values.julia new file mode 100644 index 0000000000..9d6b4f0ff6 --- /dev/null +++ b/Task/Return-multiple-values/Julia/return-multiple-values.julia @@ -0,0 +1,3 @@ +function addsub(x, y) + return x + y, x - y +end diff --git a/Task/Return-multiple-values/Liberty-BASIC/return-multiple-values.liberty b/Task/Return-multiple-values/Liberty-BASIC/return-multiple-values.liberty new file mode 100644 index 0000000000..eef1c2f3bb --- /dev/null +++ b/Task/Return-multiple-values/Liberty-BASIC/return-multiple-values.liberty @@ -0,0 +1,21 @@ +data$ ="5 6 7 22 9 3 4 8 7 6 3 -5 2 1 8 9" + +a$ =minMax$( data$) +print " Minimum was "; word$( a$, 1, " "); " & maximum was "; word$( a$, 2, " ") + +end + +function minMax$( i$) +min = 1E6 +max =-1E6 +i =1 +do + t$ =word$( i$, i, " ") + if t$ ="" then exit do + v =val( t$) + min =min( min, v) + max =max( max, v) + i =i +1 +loop until 0 +minMax$ =str$( min) +" " +str$( max) +end function diff --git a/Task/Return-multiple-values/Lua/return-multiple-values.lua b/Task/Return-multiple-values/Lua/return-multiple-values.lua new file mode 100644 index 0000000000..3507359731 --- /dev/null +++ b/Task/Return-multiple-values/Lua/return-multiple-values.lua @@ -0,0 +1,6 @@ +function addsub( a, b ) + return a+b, a-b +end + +s, d = addsub( 7, 5 ) +print( s, d ) diff --git a/Task/Return-multiple-values/MATLAB/return-multiple-values-1.m b/Task/Return-multiple-values/MATLAB/return-multiple-values-1.m new file mode 100644 index 0000000000..6e3e46ce97 --- /dev/null +++ b/Task/Return-multiple-values/MATLAB/return-multiple-values-1.m @@ -0,0 +1,6 @@ + function [a,b,c]=foo(d) + a = 1-d; + b = 2+d; + c = a+b; + end; + [x,y,z] = foo(5) diff --git a/Task/Return-multiple-values/MATLAB/return-multiple-values-2.m b/Task/Return-multiple-values/MATLAB/return-multiple-values-2.m new file mode 100644 index 0000000000..7533d7e2ce --- /dev/null +++ b/Task/Return-multiple-values/MATLAB/return-multiple-values-2.m @@ -0,0 +1,4 @@ + > [x,y,z] = foo(5) + x = -4 + y = 7 + z = 3 diff --git a/Task/Return-multiple-values/Maple/return-multiple-values-1.maple b/Task/Return-multiple-values/Maple/return-multiple-values-1.maple new file mode 100644 index 0000000000..85df12ff4b --- /dev/null +++ b/Task/Return-multiple-values/Maple/return-multiple-values-1.maple @@ -0,0 +1,6 @@ +> sumprod := ( a, b ) -> (a + b, a * b): +> sumprod( x, y ); + x + y, x y + +> sumprod( 2, 3 ); + 5, 6 diff --git a/Task/Return-multiple-values/Maple/return-multiple-values-2.maple b/Task/Return-multiple-values/Maple/return-multiple-values-2.maple new file mode 100644 index 0000000000..51fe429321 --- /dev/null +++ b/Task/Return-multiple-values/Maple/return-multiple-values-2.maple @@ -0,0 +1 @@ +sumprod := proc( a, b ) a + b, a * b end: diff --git a/Task/Return-multiple-values/Mathematica/return-multiple-values.math b/Task/Return-multiple-values/Mathematica/return-multiple-values.math new file mode 100644 index 0000000000..62df3e8787 --- /dev/null +++ b/Task/Return-multiple-values/Mathematica/return-multiple-values.math @@ -0,0 +1,2 @@ +addsub [x_,y_]:= List [x+y,x-y] +addsub[4,2] diff --git a/Task/Return-multiple-values/Maxima/return-multiple-values.maxima b/Task/Return-multiple-values/Maxima/return-multiple-values.maxima new file mode 100644 index 0000000000..3bc38c2b0a --- /dev/null +++ b/Task/Return-multiple-values/Maxima/return-multiple-values.maxima @@ -0,0 +1,4 @@ +f(a, b) := [a * b, a + b]$ + +[u, v]: f(5, 6); +[30, 11] diff --git a/Task/Return-multiple-values/Mercury/return-multiple-values.mercury b/Task/Return-multiple-values/Mercury/return-multiple-values.mercury new file mode 100644 index 0000000000..0c9f40956a --- /dev/null +++ b/Task/Return-multiple-values/Mercury/return-multiple-values.mercury @@ -0,0 +1,26 @@ +:- module addsub. + +:- interface. +:- import_module io. +:- pred main(io::di, io::uo) is det. + +:- implementation. +:- import_module int, list, string. + +main(!IO) :- + command_line_arguments(Args, !IO), + filter_map(to_int, Args, CleanArgs), + (length(CleanArgs, 2) -> + X = det_index1(CleanArgs,1), + Y = det_index1(CleanArgs,2), + addsub(X, Y, S, D), + format("%d + %d = %d\n%d - %d = %d\n", + [i(X), i(Y), i(S), i(X), i(Y), i(D)], !IO) + ; + write_string("Please pass two integers on the command line.\n", !IO) + ). + +:- pred addsub(int::in, int::in, int::out, int::out) is det. +addsub(X, Y, S, D) :- + S = X + Y, + D = X - Y. diff --git a/Task/Return-multiple-values/NetRexx/return-multiple-values.netrexx b/Task/Return-multiple-values/NetRexx/return-multiple-values.netrexx new file mode 100644 index 0000000000..f54b35c69c --- /dev/null +++ b/Task/Return-multiple-values/NetRexx/return-multiple-values.netrexx @@ -0,0 +1,102 @@ +/* NetRexx */ +options replace format comments java crossref symbols nobinary + +-- ============================================================================= +class RReturnMultipleVals public + properties constant + L = 'L' + R = 'R' + K_lipsum = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.' + K_1024 = 1024 + + -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + method RReturnMultipleVals() public + return + + -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + method main(args = String[]) public static + arg = Rexx(args) + parse arg nv_ sv_ . + if \nv_.datatype('n') then nv_ = K_1024 + if sv_ = '' then sv_ = K_lipsum + + lcl = RReturnMultipleVals() + + rvr = lcl.getPair(nv_, sv_) -- multiple values returned as a string. Use PARSE to extract values + parse rvr val1 val2 + say 'Results extracted from a NetRexx string:' + say val1',' val2 + say + + rvr = lcl.getPairFromRexx(nv_, sv_) -- values returned in a NetRexx indexed string + say 'Results extracted from a NetRexx "indexed string":' + say rvr[L]',' rvr[R] + say + + rvp = lcl.getPairFromPair(nv_, sv_) -- values returned in a bespoke object + say 'Results extracted from a composite object:' + say rvp.getLeftVal',' rvp.getRightVal + say + + rvl = lcl.getPairFromList(nv_, sv_) -- values returned in a Java Collection "List" object + say 'Results extracted from a Java Colections "List" object:' + say rvl.get(0)',' rvl.get(1) + say + + rvm = lcl.getPairFromMap(nv_, sv_) -- values returned in a Java Collection "Map" object + say 'Results extracted from a Java Colections "Map" object:' + say rvm.get(L)',' rvm.get(R) + say + + return + + -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + -- returns the values in a NetRexx string. + -- Caller can the power of PARSE to extract the results + method getPair(nv_, sv_) public returns Rexx + return nv_ sv_ + + -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + -- Return the values as members of a NetRexx indexed string + method getPairFromRexx(nv_, sv_) public returns Rexx + rval = '' + rval[L] = nv_ + rval[R] = sv_ + return rval + + -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + -- Return a bespoke object. + -- Permits any number and type of value to be returned + method getPairFromPair(nv_, sv_) public returns RReturnMultipleVals.Pair + rset = RReturnMultipleVals.Pair(nv_, sv_) + return rset + + -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + -- Exploit Java Collections classes to assemble a collection of results. + -- This example uses java.util.List + method getPairFromList(nv_, sv_) public returns java.util.List + rset = ArrayList() + rset.add(nv_) + rset.add(sv_) + return rset + + -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + -- This example uses java.util.Map + method getPairFromMap(nv_, sv_) public returns java.util.Map + rset = HashMap() + rset.put(L, nv_) + rset.put(R, sv_) + return rset + +-- ============================================================================= +class RReturnMultipleVals.Pair dependent + + properties indirect + leftVal + rightVal + + -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + method Pair(nv_ = parent.K_1024, sv_ = parent.K_lipsum) public + setLeftVal(nv_) + setRightVal(sv_) + return diff --git a/Task/Return-multiple-values/OCaml/return-multiple-values-1.ocaml b/Task/Return-multiple-values/OCaml/return-multiple-values-1.ocaml new file mode 100644 index 0000000000..1cb2a9346a --- /dev/null +++ b/Task/Return-multiple-values/OCaml/return-multiple-values-1.ocaml @@ -0,0 +1,2 @@ +let addsub x y = + x + y, x - y diff --git a/Task/Return-multiple-values/OCaml/return-multiple-values-2.ocaml b/Task/Return-multiple-values/OCaml/return-multiple-values-2.ocaml new file mode 100644 index 0000000000..325b4ffdb3 --- /dev/null +++ b/Task/Return-multiple-values/OCaml/return-multiple-values-2.ocaml @@ -0,0 +1,3 @@ +let sum, difference = addsub 33 12 in + Printf.printf "33 + 12 = %d\n" sum; + Printf.printf "33 - 12 = %d\n" difference diff --git a/Task/Return-multiple-values/OCaml/return-multiple-values-3.ocaml b/Task/Return-multiple-values/OCaml/return-multiple-values-3.ocaml new file mode 100644 index 0000000000..b2700561a2 --- /dev/null +++ b/Task/Return-multiple-values/OCaml/return-multiple-values-3.ocaml @@ -0,0 +1,13 @@ +let pair a b = + let ra = Array.create 1 a + and rb = Array.create 1 b in + let f r = Printf.printf "> finalised: %d\n%!" r.(0) in + Gc.finalise f ra; + Gc.finalise f rb; + (ra, rb) + +let () = + let a, b = pair 1 2 in + let c, d = pair 3 4 in + Gc.full_major (); (* garbage collection *) + Printf.printf "Used: %d\n%!" a.(0) diff --git a/Task/Return-multiple-values/OCaml/return-multiple-values-4.ocaml b/Task/Return-multiple-values/OCaml/return-multiple-values-4.ocaml new file mode 100644 index 0000000000..8f744b2878 --- /dev/null +++ b/Task/Return-multiple-values/OCaml/return-multiple-values-4.ocaml @@ -0,0 +1,2 @@ +val fst : 'a * 'b -> 'a +val snd : 'a * 'b -> 'b diff --git a/Task/Return-multiple-values/OCaml/return-multiple-values-5.ocaml b/Task/Return-multiple-values/OCaml/return-multiple-values-5.ocaml new file mode 100644 index 0000000000..7ff1a1976a --- /dev/null +++ b/Task/Return-multiple-values/OCaml/return-multiple-values-5.ocaml @@ -0,0 +1,15 @@ +let pair a b = + let ra = Array.create 1 a + and rb = Array.create 1 b in + let f r = Printf.printf "> finalised: %d\n%!" r.(0) in + Gc.finalise f ra; + Gc.finalise f rb; + (ra, rb) + +let () = + let ab = pair 1 2 in + let a = fst ab + and b = snd ab in + let c, d = pair 3 4 in + Gc.full_major (); (* garbage collection *) + Printf.printf "Used: %d\n%!" a.(0) diff --git a/Task/Return-multiple-values/OxygenBasic/return-multiple-values.oxy b/Task/Return-multiple-values/OxygenBasic/return-multiple-values.oxy new file mode 100644 index 0000000000..fd4b7a050b --- /dev/null +++ b/Task/Return-multiple-values/OxygenBasic/return-multiple-values.oxy @@ -0,0 +1,42 @@ +'============ +class vector4 +'============ + +float w,x,y,z + +method values(float fw,fx,fy,fz) +this <= fw, fx, fy, fz +end method + +method values(vector4 *v) +this <= v.w, v.x, v.y, v.z +end method + +method values() as vector4 +return this +end method + +method ScaledValues(float fw,fx,fy,fz) as vector4 +static vector4 v +v <= w*fw, x*fx, y*fy, z*fz +return v +end method + +method ShowValues() as string +string cm="," +return w cm x cm y cm z +end method + +end class + +vector4 aa,bb + +bb.values = 1,2,3,4 + +aa.values = bb.Values() + +print aa.ShowValues() 'result 1,2,3,4 + +aa.values = bb.ScaledValues(100,100,-100,100) + +print aa.ShowValues() 'result 100,200,-300,400 diff --git a/Task/Return-multiple-values/PARI-GP/return-multiple-values.pari b/Task/Return-multiple-values/PARI-GP/return-multiple-values.pari new file mode 100644 index 0000000000..69f825d977 --- /dev/null +++ b/Task/Return-multiple-values/PARI-GP/return-multiple-values.pari @@ -0,0 +1,3 @@ +foo(x)={ + [x^2, x^3] +}; diff --git a/Task/Return-multiple-values/PHP/return-multiple-values-1.php b/Task/Return-multiple-values/PHP/return-multiple-values-1.php new file mode 100644 index 0000000000..cc66fc5370 --- /dev/null +++ b/Task/Return-multiple-values/PHP/return-multiple-values-1.php @@ -0,0 +1,3 @@ +function addsub($x, $y) { + return array($x + $y, $x - $y); +} diff --git a/Task/Return-multiple-values/PHP/return-multiple-values-2.php b/Task/Return-multiple-values/PHP/return-multiple-values-2.php new file mode 100644 index 0000000000..7728bbb043 --- /dev/null +++ b/Task/Return-multiple-values/PHP/return-multiple-values-2.php @@ -0,0 +1,3 @@ +list($sum, $difference) = addsub(33, 12); +echo "33 + 12 = $sum\n"; +echo "33 - 12 = $difference\n"; diff --git a/Task/Return-multiple-values/PL-I/return-multiple-values-1.pli b/Task/Return-multiple-values/PL-I/return-multiple-values-1.pli new file mode 100644 index 0000000000..2146a3d16f --- /dev/null +++ b/Task/Return-multiple-values/PL-I/return-multiple-values-1.pli @@ -0,0 +1,12 @@ + define structure 1 h, + 2 a (10) float; + declare i fixed binary; + +sub: procedure (a, b) returns (type(h)); + declare (a, b) float; + declare p type (h); + do i = 1 to 10; + p.a(i) = i; + end; + return (p); +end sub; diff --git a/Task/Return-multiple-values/PL-I/return-multiple-values-2.pli b/Task/Return-multiple-values/PL-I/return-multiple-values-2.pli new file mode 100644 index 0000000000..439264fec7 --- /dev/null +++ b/Task/Return-multiple-values/PL-I/return-multiple-values-2.pli @@ -0,0 +1,15 @@ + define structure 1 customer, + 2 name, + 3 surname character (20), + 3 given_name character (10), + 2 address, + 3 street character (20), + 3 suburb character (20), + 3 zip fixed decimal (7); + +sub2: procedure() returns (type(customer)); + declare c type (customer); + get edit (c.surname, c.given_name) (L); + get edit (c.street, c.suburb, c.zip) (L); + return (c); +end sub2; diff --git a/Task/Return-multiple-values/PL-I/return-multiple-values-3.pli b/Task/Return-multiple-values/PL-I/return-multiple-values-3.pli new file mode 100644 index 0000000000..a2ccbd3dc6 --- /dev/null +++ b/Task/Return-multiple-values/PL-I/return-multiple-values-3.pli @@ -0,0 +1,5 @@ +comp: procedure(a, b) returns (complex); + declare (a, b) float; + + return (complex(a, b) ); +end comp; diff --git a/Task/Return-multiple-values/Perl-6/return-multiple-values.pl6 b/Task/Return-multiple-values/Perl-6/return-multiple-values.pl6 new file mode 100644 index 0000000000..8fd3f60bea --- /dev/null +++ b/Task/Return-multiple-values/Perl-6/return-multiple-values.pl6 @@ -0,0 +1,5 @@ +sub foo($a,$b) { + $a + $b, $a * $b, $b xx $a +} + +say foo 3, 7; diff --git a/Task/Return-multiple-values/Perl/return-multiple-values.pl b/Task/Return-multiple-values/Perl/return-multiple-values.pl new file mode 100644 index 0000000000..f27b1fb91d --- /dev/null +++ b/Task/Return-multiple-values/Perl/return-multiple-values.pl @@ -0,0 +1,4 @@ +sub foo { + my ($a, $b) = @_; + return $a + $b, $a * $b; +} diff --git a/Task/Return-multiple-values/PicoLisp/return-multiple-values-1.l b/Task/Return-multiple-values/PicoLisp/return-multiple-values-1.l new file mode 100644 index 0000000000..7debeaa1e6 --- /dev/null +++ b/Task/Return-multiple-values/PicoLisp/return-multiple-values-1.l @@ -0,0 +1,2 @@ +(de addsub (X Y) + (list (+ X Y) (- X Y)) ) diff --git a/Task/Return-multiple-values/PicoLisp/return-multiple-values-2.l b/Task/Return-multiple-values/PicoLisp/return-multiple-values-2.l new file mode 100644 index 0000000000..273162a620 --- /dev/null +++ b/Task/Return-multiple-values/PicoLisp/return-multiple-values-2.l @@ -0,0 +1,8 @@ +: (addsub 4 2) +-> (6 2) +: (addsub 3 1) +-> (4 2) +: (+ (car (addsub 4 2)) (car (addsub 3 1))) +-> 10 +: (sum + (addsub 4 2) (addsub 3 1)) +-> 14 diff --git a/Task/Return-multiple-values/Pike/return-multiple-values.pike b/Task/Return-multiple-values/Pike/return-multiple-values.pike new file mode 100644 index 0000000000..8df1d1efb5 --- /dev/null +++ b/Task/Return-multiple-values/Pike/return-multiple-values.pike @@ -0,0 +1,6 @@ +array(int) addsub(int x, int y) +{ + return ({ x+y, x-y }); +} + +[int z, int w] = addsub(5,4); diff --git a/Task/Return-multiple-values/PureBasic/return-multiple-values.purebasic b/Task/Return-multiple-values/PureBasic/return-multiple-values.purebasic new file mode 100644 index 0000000000..b48a587ba8 --- /dev/null +++ b/Task/Return-multiple-values/PureBasic/return-multiple-values.purebasic @@ -0,0 +1,33 @@ +;An array, map, or list can be used as a parameter to a procedure and in the +;process contain values to be returned as well. +Procedure example_1(x, y, Array r(1)) ;array r() will contain the return values + Dim r(2) ;clear and resize the array + r(0) = x + y ;return these values in the array + r(1) = x - y + r(2) = x * y +EndProcedure + +;A pointer to memory or a structured variable may also be returned to reference +;multiple return values (requiring the memory to be manually freed afterwards). +Procedure example_2(x, y) + Protected *result.POINT = AllocateMemory(SizeOf(POINT)) + *result\x = x + *result\y = y + + ProcedureReturn *result ;*result points to a 'POINT' structure containing x and y +EndProcedure + +If OpenConsole() + Dim a(5) + example_1(6, 5, a()) ;a() now contains {11, 1, 30} + PrintN("Array returned with {" + Str(a(0)) + ", " + Str(a(1)) + ", " + Str(a(2)) + "}") + + Define *aPoint.POINT + *aPoint = example_2(6, 5) ;*aPoint references structured memory containing {6, 5} + + PrintN("structured memory holds: (" + Str(*aPoint\x) + ", " + Str(*aPoint\y) + ")") + FreeMemory(*aPoint) ;freememory + + Print(#CRLF$ + #CRLF$ + "Press ENTER to exit"): Input() + CloseConsole() +EndIf diff --git a/Task/Return-multiple-values/Python/return-multiple-values-1.py b/Task/Return-multiple-values/Python/return-multiple-values-1.py new file mode 100644 index 0000000000..e4dfbd1709 --- /dev/null +++ b/Task/Return-multiple-values/Python/return-multiple-values-1.py @@ -0,0 +1,2 @@ +def addsub(x, y): + return x + y, x - y diff --git a/Task/Return-multiple-values/Python/return-multiple-values-2.py b/Task/Return-multiple-values/Python/return-multiple-values-2.py new file mode 100644 index 0000000000..b7f4318ef9 --- /dev/null +++ b/Task/Return-multiple-values/Python/return-multiple-values-2.py @@ -0,0 +1,3 @@ +sum, difference = addsub(33, 12) +print "33 + 12 = %s" % sum +print "33 - 12 = %s" % difference diff --git a/Task/Return-multiple-values/R/return-multiple-values.r b/Task/Return-multiple-values/R/return-multiple-values.r new file mode 100644 index 0000000000..66a8ac0931 --- /dev/null +++ b/Task/Return-multiple-values/R/return-multiple-values.r @@ -0,0 +1 @@ +addsub <- function(x, y) list(add=(x + y), sub=(x - y)) diff --git a/Task/Return-multiple-values/REXX/return-multiple-values.rexx b/Task/Return-multiple-values/REXX/return-multiple-values.rexx new file mode 100644 index 0000000000..4a5fa825cc --- /dev/null +++ b/Task/Return-multiple-values/REXX/return-multiple-values.rexx @@ -0,0 +1,32 @@ +/*REXX program shows examples of multiple RETURN values from a function.*/ +numeric digits 70 /*default is: NUMERIC DIGITS 9 */ +arg a b /*get 2 numbers from comand line.*/ +say ' a =' a /*display the first number. */ +say ' b =' b /* " " second " */ +say copies('=',50) /*display a separator line. */ + +z=giveMeBackStuff(a,b) /*call function: giveMeBackStuff */ + +parse var z sum dif mod div idiv prod pow /*get the returned values,*/ + prod=word(z,6) /*obtain an alternate way.*/ +say ' + =' sum +say ' - =' dif +say '// =' mod +say ' / =' div +say ' % =' idiv +say ' * =' prod +say '** =' pow +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────giveMeBackStuff subroutine──────────*/ +giveMeBackStuff: procedure; parse arg x,y + addition = x+y + subtract = x-y + modulus = x//y + divide = x/y + intDiv = x%y + multiply = x*y + power = x**y +return addition subtract modulus divide intDiv multiply power +/*──────────────────────────────────giveMeBackStuff2 subroutine─────────*/ +giveMeBackStuff2: procedure; parse arg x,y +return x+y x-y x//y x/y x%y x*y x**y /*same as version above.*/ diff --git a/Task/Return-multiple-values/Retro/return-multiple-values.retro b/Task/Return-multiple-values/Retro/return-multiple-values.retro new file mode 100644 index 0000000000..7b083ef0a6 --- /dev/null +++ b/Task/Return-multiple-values/Retro/return-multiple-values.retro @@ -0,0 +1,2 @@ +: addSubtract ( xy-nm ) + 2over - [ + ] dip ; diff --git a/Task/Return-multiple-values/Ruby/return-multiple-values-1.rb b/Task/Return-multiple-values/Ruby/return-multiple-values-1.rb new file mode 100644 index 0000000000..9612647528 --- /dev/null +++ b/Task/Return-multiple-values/Ruby/return-multiple-values-1.rb @@ -0,0 +1,3 @@ +def addsub(x, y) + [x + y, x - y] +end diff --git a/Task/Return-multiple-values/Ruby/return-multiple-values-2.rb b/Task/Return-multiple-values/Ruby/return-multiple-values-2.rb new file mode 100644 index 0000000000..6e7eac627e --- /dev/null +++ b/Task/Return-multiple-values/Ruby/return-multiple-values-2.rb @@ -0,0 +1,3 @@ +def addsub(x, y) + return x + y, x - y +end diff --git a/Task/Return-multiple-values/Ruby/return-multiple-values-3.rb b/Task/Return-multiple-values/Ruby/return-multiple-values-3.rb new file mode 100644 index 0000000000..38fcff99e2 --- /dev/null +++ b/Task/Return-multiple-values/Ruby/return-multiple-values-3.rb @@ -0,0 +1,3 @@ +sum, difference = addsub(33, 12) +puts "33 + 12 = #{sum}" +puts "33 - 12 = #{difference}" diff --git a/Task/Return-multiple-values/Run-BASIC/return-multiple-values.run b/Task/Return-multiple-values/Run-BASIC/return-multiple-values.run new file mode 100644 index 0000000000..726c86075e --- /dev/null +++ b/Task/Return-multiple-values/Run-BASIC/return-multiple-values.run @@ -0,0 +1,11 @@ +a$ = timeInfo$() +print " UTC:";word$(a$,1,"|") +print "Date:";word$(a$,2,"|") +print "Time:";word$(a$,3,"|") +wait +function timeInfo$() +utc$ = word$(word$(httpget$("http://tycho.usno.navy.mil/cgi-bin/timer.pl"),1,"UTC"),2,"
    ") ' Universal time +d$ = date$() +t$ = time$() +timeInfo$ = utc$;"|";d$;"|";t$ +end function diff --git a/Task/Return-multiple-values/Scala/return-multiple-values-1.scala b/Task/Return-multiple-values/Scala/return-multiple-values-1.scala new file mode 100644 index 0000000000..0b9ee82944 --- /dev/null +++ b/Task/Return-multiple-values/Scala/return-multiple-values-1.scala @@ -0,0 +1 @@ +def addsub(x: Int, y: Int) = (x + y, x - y) diff --git a/Task/Return-multiple-values/Scala/return-multiple-values-2.scala b/Task/Return-multiple-values/Scala/return-multiple-values-2.scala new file mode 100644 index 0000000000..b437978e7f --- /dev/null +++ b/Task/Return-multiple-values/Scala/return-multiple-values-2.scala @@ -0,0 +1 @@ +val (sum, difference) = addsub(33, 12) diff --git a/Task/Return-multiple-values/Scheme/return-multiple-values-1.ss b/Task/Return-multiple-values/Scheme/return-multiple-values-1.ss new file mode 100644 index 0000000000..6c39bd4b12 --- /dev/null +++ b/Task/Return-multiple-values/Scheme/return-multiple-values-1.ss @@ -0,0 +1,2 @@ +(define (addsub x y) + (values (+ x y) (- x y))) diff --git a/Task/Return-multiple-values/Scheme/return-multiple-values-2.ss b/Task/Return-multiple-values/Scheme/return-multiple-values-2.ss new file mode 100644 index 0000000000..d7d33826af --- /dev/null +++ b/Task/Return-multiple-values/Scheme/return-multiple-values-2.ss @@ -0,0 +1,5 @@ +(call-with-values + (lambda () (addsub 33 12)) + (lambda (sum difference) + (display "33 + 12 = ") (display sum) (newline) + (display "33 - 12 = ") (display difference) (newline))) diff --git a/Task/Return-multiple-values/Scheme/return-multiple-values-3.ss b/Task/Return-multiple-values/Scheme/return-multiple-values-3.ss new file mode 100644 index 0000000000..36dd54f783 --- /dev/null +++ b/Task/Return-multiple-values/Scheme/return-multiple-values-3.ss @@ -0,0 +1,4 @@ +(receive (sum difference) (addsub 33 12) + ; in this scope you can use sum and difference + (display "33 + 12 = ") (display sum) (newline) + (display "33 - 12 = ") (display difference) (newline)) diff --git a/Task/Return-multiple-values/Scheme/return-multiple-values-4.ss b/Task/Return-multiple-values/Scheme/return-multiple-values-4.ss new file mode 100644 index 0000000000..0916c5bb4a --- /dev/null +++ b/Task/Return-multiple-values/Scheme/return-multiple-values-4.ss @@ -0,0 +1,4 @@ +(let-values (((sum difference) (addsub 33 12))) + ; in this scope you can use sum and difference + (display "33 + 12 = ") (display sum) (newline) + (display "33 - 12 = ") (display difference) (newline)) diff --git a/Task/Return-multiple-values/Seed7/return-multiple-values.seed7 b/Task/Return-multiple-values/Seed7/return-multiple-values.seed7 new file mode 100644 index 0000000000..744d4b8aff --- /dev/null +++ b/Task/Return-multiple-values/Seed7/return-multiple-values.seed7 @@ -0,0 +1,17 @@ +$ include "seed7_05.s7i"; + +const proc: sumAndDiff (in integer: x, in integer: y, inout integer: sum, inout integer: diff) is func + begin + sum := x + y; + diff := x - y; + end func; + +const proc: main is func + local + var integer: sum is 0; + var integer: diff is 0; + begin + sumAndDiff(5, 3, sum, diff); + writeln("Sum: " <& sum); + writeln("Diff: " <& diff); + end func; diff --git a/Task/Return-multiple-values/Standard-ML/return-multiple-values-1.ml b/Task/Return-multiple-values/Standard-ML/return-multiple-values-1.ml new file mode 100644 index 0000000000..f68e9fe124 --- /dev/null +++ b/Task/Return-multiple-values/Standard-ML/return-multiple-values-1.ml @@ -0,0 +1,2 @@ +fun addsub (x, y) = + (x + y, x - y) diff --git a/Task/Return-multiple-values/Standard-ML/return-multiple-values-2.ml b/Task/Return-multiple-values/Standard-ML/return-multiple-values-2.ml new file mode 100644 index 0000000000..4a02888f77 --- /dev/null +++ b/Task/Return-multiple-values/Standard-ML/return-multiple-values-2.ml @@ -0,0 +1,6 @@ +let + val (sum, difference) = addsub (33, 12) +in + print ("33 + 12 = " ^ Int.toString sum ^ "\n"); + print ("33 - 12 = " ^ Int.toString difference ^ "\n") +end diff --git a/Task/Return-multiple-values/TXR/return-multiple-values-1.txr b/Task/Return-multiple-values/TXR/return-multiple-values-1.txr new file mode 100644 index 0000000000..af8ca467b1 --- /dev/null +++ b/Task/Return-multiple-values/TXR/return-multiple-values-1.txr @@ -0,0 +1,4 @@ +@(define func (x y z)) +@ (bind w "discarded") +@ (bind (x y z) ("a" "b" "c")) +@(end) diff --git a/Task/Return-multiple-values/TXR/return-multiple-values-2.txr b/Task/Return-multiple-values/TXR/return-multiple-values-2.txr new file mode 100644 index 0000000000..74904f2ee2 --- /dev/null +++ b/Task/Return-multiple-values/TXR/return-multiple-values-2.txr @@ -0,0 +1 @@ +@(func t r s) diff --git a/Task/Return-multiple-values/TXR/return-multiple-values-3.txr b/Task/Return-multiple-values/TXR/return-multiple-values-3.txr new file mode 100644 index 0000000000..14a894e892 --- /dev/null +++ b/Task/Return-multiple-values/TXR/return-multiple-values-3.txr @@ -0,0 +1 @@ +@(func "1" r s) diff --git a/Task/Return-multiple-values/TXR/return-multiple-values-4.txr b/Task/Return-multiple-values/TXR/return-multiple-values-4.txr new file mode 100644 index 0000000000..13abbddec9 --- /dev/null +++ b/Task/Return-multiple-values/TXR/return-multiple-values-4.txr @@ -0,0 +1 @@ +@(func "a" "b" s) diff --git a/Task/Return-multiple-values/Tcl/return-multiple-values-1.tcl b/Task/Return-multiple-values/Tcl/return-multiple-values-1.tcl new file mode 100644 index 0000000000..bf09eee290 --- /dev/null +++ b/Task/Return-multiple-values/Tcl/return-multiple-values-1.tcl @@ -0,0 +1,3 @@ +proc addsub {x y} { + list [expr {$x+$y}] [expr {$x-$y}] +} diff --git a/Task/Return-multiple-values/Tcl/return-multiple-values-2.tcl b/Task/Return-multiple-values/Tcl/return-multiple-values-2.tcl new file mode 100644 index 0000000000..680288158d --- /dev/null +++ b/Task/Return-multiple-values/Tcl/return-multiple-values-2.tcl @@ -0,0 +1,2 @@ +lassign [addsub 33 12] sum difference +puts "33 + 12 = $sum, 33 - 12 = $difference" diff --git a/Task/Return-multiple-values/UNIX-Shell/return-multiple-values.sh b/Task/Return-multiple-values/UNIX-Shell/return-multiple-values.sh new file mode 100644 index 0000000000..47d05521d6 --- /dev/null +++ b/Task/Return-multiple-values/UNIX-Shell/return-multiple-values.sh @@ -0,0 +1,14 @@ +#!/bin/sh +funct1() { + a=$1 + b=`expr $a + 1` + echo $a $b +} + +values=`funct1 5` + +set $values +x=$1 +y=$2 +echo "x=$x" +echo "y=$y" diff --git a/Task/Return-multiple-values/XPL0/return-multiple-values.xpl0 b/Task/Return-multiple-values/XPL0/return-multiple-values.xpl0 new file mode 100644 index 0000000000..dc7a0aee07 --- /dev/null +++ b/Task/Return-multiple-values/XPL0/return-multiple-values.xpl0 @@ -0,0 +1,14 @@ +include c:\cxpl\codes; \intrinsic 'code' declarations + +proc Rect2Polar(X,Y,A,D); \Return two polar coordinate values +real X,Y,A,D; +[A(0):= ATan2(Y,X); + D(0):= Sqrt(X*X+Y*Y); +]; \Rect2Polar + +real Ang, Dist; +[Rect2Polar(4.0, 3.0, @Ang, @Dist); \("@" is a new feature similar to 'addr') +RlOut(0, Ang); +RlOut(0, Dist); +CrLf(0); +] diff --git a/Task/Reverse-a-string/0815/reverse-a-string-1.0815 b/Task/Reverse-a-string/0815/reverse-a-string-1.0815 new file mode 100644 index 0000000000..96bafc909b --- /dev/null +++ b/Task/Reverse-a-string/0815/reverse-a-string-1.0815 @@ -0,0 +1,10 @@ +}:r: Start reader loop. + !~>& Push a character to the "stack". + <:a:=- Stop reading on newline. +^:r: +@> Rotate the newline to the end and enqueue a sentinel 0. +{~ Dequeue and rotate the first character into place. +}:p: + ${~ Print the current character until it's 0. +^:p: +#:r: Read again. diff --git a/Task/Reverse-a-string/0815/reverse-a-string-2.0815 b/Task/Reverse-a-string/0815/reverse-a-string-2.0815 new file mode 100644 index 0000000000..424679e97e --- /dev/null +++ b/Task/Reverse-a-string/0815/reverse-a-string-2.0815 @@ -0,0 +1,3 @@ +echo -e "foo\nbar" | 0815 rev.0 +oof +rab diff --git a/Task/Reverse-a-string/0DESCRIPTION b/Task/Reverse-a-string/0DESCRIPTION new file mode 100644 index 0000000000..6eb3f1bd35 --- /dev/null +++ b/Task/Reverse-a-string/0DESCRIPTION @@ -0,0 +1,3 @@ +Take a string and reverse it. For example, "asdf" becomes "fdsa". + +For extra credit, preserve Unicode combining characters. For example, "as⃝df̅" becomes "f̅ds⃝a", not "̅fd⃝sa". diff --git a/Task/Reverse-a-string/1META.yaml b/Task/Reverse-a-string/1META.yaml new file mode 100644 index 0000000000..ae625822b7 --- /dev/null +++ b/Task/Reverse-a-string/1META.yaml @@ -0,0 +1,2 @@ +--- +note: String manipulation diff --git a/Task/Reverse-a-string/ACL2/reverse-a-string.acl2 b/Task/Reverse-a-string/ACL2/reverse-a-string.acl2 new file mode 100644 index 0000000000..681e6fa190 --- /dev/null +++ b/Task/Reverse-a-string/ACL2/reverse-a-string.acl2 @@ -0,0 +1 @@ +(reverse "hello") diff --git a/Task/Reverse-a-string/ALGOL-68/reverse-a-string-1.alg b/Task/Reverse-a-string/ALGOL-68/reverse-a-string-1.alg new file mode 100644 index 0000000000..b3ee6c60e3 --- /dev/null +++ b/Task/Reverse-a-string/ALGOL-68/reverse-a-string-1.alg @@ -0,0 +1,13 @@ +PROC reverse = (REF STRING s)VOID: + FOR i TO UPB s OVER 2 DO + CHAR c = s[i]; + s[i] := s[UPB s - i + 1]; + s[UPB s - i + 1] := c + OD; + +main: +( + STRING text := "Was it a cat I saw"; + reverse(text); + print((text, new line)) +) diff --git a/Task/Reverse-a-string/ALGOL-68/reverse-a-string-2.alg b/Task/Reverse-a-string/ALGOL-68/reverse-a-string-2.alg new file mode 100644 index 0000000000..fb792368e4 --- /dev/null +++ b/Task/Reverse-a-string/ALGOL-68/reverse-a-string-2.alg @@ -0,0 +1,2 @@ + ⌽'asdf' +fdsa diff --git a/Task/Reverse-a-string/AWK/reverse-a-string-1.awk b/Task/Reverse-a-string/AWK/reverse-a-string-1.awk new file mode 100644 index 0000000000..2bc97bcb3b --- /dev/null +++ b/Task/Reverse-a-string/AWK/reverse-a-string-1.awk @@ -0,0 +1,10 @@ +function reverse(s) +{ + p = "" + for(i=length(s); i > 0; i--) { p = p substr(s, i, 1) } + return p +} + +BEGIN { + print reverse("edoCattesoR") +} diff --git a/Task/Reverse-a-string/AWK/reverse-a-string-2.awk b/Task/Reverse-a-string/AWK/reverse-a-string-2.awk new file mode 100644 index 0000000000..bdf1238d68 --- /dev/null +++ b/Task/Reverse-a-string/AWK/reverse-a-string-2.awk @@ -0,0 +1,9 @@ +function reverse(s ,l) +{ + l = length(s) + return l < 2 ? s:( substr(s,l,1) reverse(substr(s,1,l-1)) ) +} + +BEGIN { + print reverse("edoCattesoR") +} diff --git a/Task/Reverse-a-string/ActionScript/reverse-a-string.as b/Task/Reverse-a-string/ActionScript/reverse-a-string.as new file mode 100644 index 0000000000..50f03a9c19 --- /dev/null +++ b/Task/Reverse-a-string/ActionScript/reverse-a-string.as @@ -0,0 +1,12 @@ +function reverseString(string:String):String +{ + var reversed:String = new String(); + for(var i:int = string.length -1; i >= 0; i--) + reversed += string.charAt(i); + return reversed; +} + +function reverseStringCQAlternative(string:String):String +{ + return string.split('').reverse().join(''); +} diff --git a/Task/Reverse-a-string/Ada/reverse-a-string.ada b/Task/Reverse-a-string/Ada/reverse-a-string.ada new file mode 100644 index 0000000000..2ea9991ac1 --- /dev/null +++ b/Task/Reverse-a-string/Ada/reverse-a-string.ada @@ -0,0 +1,14 @@ +with Ada.Text_IO; use Ada.Text_IO; + +procedure Reverse_String is + function Reverse_It (Item : String) return String is + Result : String (Item'Range); + begin + for I in Item'range loop + Result (Result'Last - I + Item'First) := Item (I); + end loop; + return Result; + end Reverse_It; +begin + Put_Line (Reverse_It (Get_Line)); +end Reverse_String; diff --git a/Task/Reverse-a-string/Agda2/reverse-a-string.agda2 b/Task/Reverse-a-string/Agda2/reverse-a-string.agda2 new file mode 100644 index 0000000000..36d529693d --- /dev/null +++ b/Task/Reverse-a-string/Agda2/reverse-a-string.agda2 @@ -0,0 +1,7 @@ +module reverse_string where + +open import Data.String +open import Data.List + +reverse_string : String → String +reverse_string s = fromList (reverse (toList s)) diff --git a/Task/Reverse-a-string/AppleScript/reverse-a-string.applescript b/Task/Reverse-a-string/AppleScript/reverse-a-string.applescript new file mode 100644 index 0000000000..0eb1fc07d0 --- /dev/null +++ b/Task/Reverse-a-string/AppleScript/reverse-a-string.applescript @@ -0,0 +1,12 @@ +get reverse_string("as⃝df̅") + +on reverse_string(str) + set old_delim to (get AppleScript's text item delimiters) + set AppleScript's text item delimiters to "" + + set temp to (reverse of text items of str) + set temp to (text items of temp) as Unicode text + + set AppleScript's text item delimiters to old_delim + return temp +end reverse_string diff --git a/Task/Reverse-a-string/AutoHotkey/reverse-a-string-1.ahk b/Task/Reverse-a-string/AutoHotkey/reverse-a-string-1.ahk new file mode 100644 index 0000000000..4144fafe25 --- /dev/null +++ b/Task/Reverse-a-string/AutoHotkey/reverse-a-string-1.ahk @@ -0,0 +1,8 @@ +MsgBox % reverse("asdf") + +reverse(string) +{ + Loop, Parse, string + reversed := A_LoopField . reversed + Return reversed +} diff --git a/Task/Reverse-a-string/AutoHotkey/reverse-a-string-2.ahk b/Task/Reverse-a-string/AutoHotkey/reverse-a-string-2.ahk new file mode 100644 index 0000000000..1093983e91 --- /dev/null +++ b/Task/Reverse-a-string/AutoHotkey/reverse-a-string-2.ahk @@ -0,0 +1,19 @@ +Reverse(String){ ; credit to Rseding91 + If (A_IsUnicode){ + SLen := StrLen(String) * 2 + VarSetCapacity(RString,SLen) + + Loop,Parse,String + NumPut(Asc(A_LoopField),RString,SLen-(A_Index * 2),"UShort") + } Else { + SLen := StrLen(String) + VarSetCapacity(RString,SLen) + + Loop,Parse,String + NumPut(Asc(A_LoopField),RString,SLen-A_Index,"UChar") + } + + VarSetCapacity(RString,-1) + + Return RString +} diff --git a/Task/Reverse-a-string/AutoIt/reverse-a-string.autoit b/Task/Reverse-a-string/AutoIt/reverse-a-string.autoit new file mode 100644 index 0000000000..4fdde34c8d --- /dev/null +++ b/Task/Reverse-a-string/AutoIt/reverse-a-string.autoit @@ -0,0 +1,12 @@ +#AutoIt Version: 3.2.10.0 +$mystring="asdf" +$reverse_string = "" +$string_length = StringLen($mystring) + +For $i = 1 to $string_length + $last_n_chrs = StringRight($mystring, $i) + $nth_chr = StringTrimRight($last_n_chrs, $i-1) + $reverse_string= $reverse_string & $nth_chr +Next + +MsgBox(0, "Reversed string is:", $reverse_string) diff --git a/Task/Reverse-a-string/BASIC/reverse-a-string.basic b/Task/Reverse-a-string/BASIC/reverse-a-string.basic new file mode 100644 index 0000000000..2a866c229a --- /dev/null +++ b/Task/Reverse-a-string/BASIC/reverse-a-string.basic @@ -0,0 +1,7 @@ +function reverse$(a$) + b$ = "" + for i = 1 to len(a$) + b$ = mid$(a$, i, 1) + b$ + next i + reverse$ = b$ +end function diff --git a/Task/Reverse-a-string/BBC-BASIC/reverse-a-string.bbc b/Task/Reverse-a-string/BBC-BASIC/reverse-a-string.bbc new file mode 100644 index 0000000000..332eb95890 --- /dev/null +++ b/Task/Reverse-a-string/BBC-BASIC/reverse-a-string.bbc @@ -0,0 +1,9 @@ + PRINT FNreverse("The five boxing wizards jump quickly") + END + + DEF FNreverse(A$) + LOCAL B$, C% + FOR C% = LEN(A$) TO 1 STEP -1 + B$ += MID$(A$,C%,1) + NEXT + = B$ diff --git a/Task/Reverse-a-string/Babel/reverse-a-string.pb b/Task/Reverse-a-string/Babel/reverse-a-string.pb new file mode 100644 index 0000000000..a8982e981e --- /dev/null +++ b/Task/Reverse-a-string/Babel/reverse-a-string.pb @@ -0,0 +1 @@ +strrev: { str2ar ar2ls reverse ls2lf ar2str } diff --git a/Task/Reverse-a-string/Batch-File/reverse-a-string.bat b/Task/Reverse-a-string/Batch-File/reverse-a-string.bat new file mode 100644 index 0000000000..0d74715f5c --- /dev/null +++ b/Task/Reverse-a-string/Batch-File/reverse-a-string.bat @@ -0,0 +1,17 @@ +@echo off +setlocal enabledelayedexpansion +call :reverse %1 res +echo %res% +goto :eof + +:reverse +set str=%~1 +set cnt=0 +:loop +if "%str%" equ "" ( + goto :eof + ) +set chr=!str:~0,1! +set str=%str:~1% +set %2=%chr%!%2! +goto loop diff --git a/Task/Reverse-a-string/Befunge/reverse-a-string.bf b/Task/Reverse-a-string/Befunge/reverse-a-string.bf new file mode 100644 index 0000000000..062a605564 --- /dev/null +++ b/Task/Reverse-a-string/Befunge/reverse-a-string.bf @@ -0,0 +1,14 @@ +v The string to reverse. The row to copy to. + | | The actual copying happens here. + | | | Increment column to write to. + | | | | Store column #. + v v v v v +> "reverse me" 3 10p >10g 4 p 10g1+ 10pv + ^ ^ |: < +First column --| | @ ^ +to write to. | ^ Get the address + All calls to 10 | to copy the next + involve saving or | character to. + reading the End when stack is empty or + column to write explicit zero is reached. + to. diff --git a/Task/Reverse-a-string/Bracmat/reverse-a-string.bracmat b/Task/Reverse-a-string/Bracmat/reverse-a-string.bracmat new file mode 100644 index 0000000000..8dc71694a6 --- /dev/null +++ b/Task/Reverse-a-string/Bracmat/reverse-a-string.bracmat @@ -0,0 +1,15 @@ + ( reverse + = L x + . :?L + & @( !arg + : ? + ( %?x + & utf$!x + & !x !L:?L + & ~` + ) + ? + ) + | str$!L + ) +& out$reverse$Ελληνικά diff --git a/Task/Reverse-a-string/Brainf---/reverse-a-string-1.bf b/Task/Reverse-a-string/Brainf---/reverse-a-string-1.bf new file mode 100644 index 0000000000..713b0bb245 --- /dev/null +++ b/Task/Reverse-a-string/Brainf---/reverse-a-string-1.bf @@ -0,0 +1 @@ +[-]>,+[->,+]<[.<] diff --git a/Task/Reverse-a-string/Brainf---/reverse-a-string-2.bf b/Task/Reverse-a-string/Brainf---/reverse-a-string-2.bf new file mode 100644 index 0000000000..5e6e63c4ce --- /dev/null +++ b/Task/Reverse-a-string/Brainf---/reverse-a-string-2.bf @@ -0,0 +1,5 @@ +,----- ----- [+++++ +++++ > , ----- -----] If a newline is hit counter will be zero and input loop ends +<[.<] run all chars backwards and print them + +just because it looks good we print CRLF ++++++ +++++ +++ . --- . diff --git a/Task/Reverse-a-string/Brat/reverse-a-string.brat b/Task/Reverse-a-string/Brat/reverse-a-string.brat new file mode 100644 index 0000000000..fdb08203e7 --- /dev/null +++ b/Task/Reverse-a-string/Brat/reverse-a-string.brat @@ -0,0 +1 @@ +p "olleh".reverse #Prints "hello" diff --git a/Task/Reverse-a-string/Burlesque/reverse-a-string.blq b/Task/Reverse-a-string/Burlesque/reverse-a-string.blq new file mode 100644 index 0000000000..2f5e46e480 --- /dev/null +++ b/Task/Reverse-a-string/Burlesque/reverse-a-string.blq @@ -0,0 +1 @@ +"Hello, world!"<- diff --git a/Task/Reverse-a-string/C++/reverse-a-string.cpp b/Task/Reverse-a-string/C++/reverse-a-string.cpp new file mode 100644 index 0000000000..72bcf1da05 --- /dev/null +++ b/Task/Reverse-a-string/C++/reverse-a-string.cpp @@ -0,0 +1,12 @@ +#include +#include +#include + +int main() +{ + std::string s; + std::getline(std::cin, s); + std::reverse(s.begin(), s.end()); // modifies s + std::cout << s << std::endl; + return 0; +} diff --git a/Task/Reverse-a-string/C/reverse-a-string-1.c b/Task/Reverse-a-string/C/reverse-a-string-1.c new file mode 100644 index 0000000000..d2ca30ee5b --- /dev/null +++ b/Task/Reverse-a-string/C/reverse-a-string-1.c @@ -0,0 +1,67 @@ +#include +#include +#include +#include + +const char *sa = "abcdef"; +const char *su = "as⃝df̅"; /* Should be in your native locale encoding. Mine is UTF-8 */ + +int is_comb(wchar_t c) +{ + if (c >= 0x300 && c <= 0x36f) return 1; + if (c >= 0x1dc0 && c <= 0x1dff) return 1; + if (c >= 0x20d0 && c <= 0x20ff) return 1; + if (c >= 0xfe20 && c <= 0xfe2f) return 1; + return 0; +} + +wchar_t* mb_to_wchar(const char *s) +{ + wchar_t *u; + size_t len = mbstowcs(0, s, 0) + 1; + if (!len) return 0; + + u = malloc(sizeof(wchar_t) * len); + mbstowcs(u, s, len); + return u; +} + +wchar_t* ws_reverse(const wchar_t* u) +{ + size_t len, i, j; + wchar_t *out; + for (len = 0; u[len]; len++); + out = malloc(sizeof(wchar_t) * (len + 1)); + out[len] = 0; + j = 0; + while (len) { + for (i = len - 1; i && is_comb(u[i]); i--); + wcsncpy(out + j, u + i, len - i); + j += len - i; + len = i; + } + return out; +} + +char *mb_reverse(const char *in) +{ + size_t len; + char *out; + wchar_t *u = mb_to_wchar(in); + wchar_t *r = ws_reverse(u); + len = wcstombs(0, r, 0) + 1; + out = malloc(len); + wcstombs(out, r, len); + free(u); + free(r); + return out; +} + +int main(void) +{ + setlocale(LC_CTYPE, ""); + + printf("%s => %s\n", sa, mb_reverse(sa)); + printf("%s => %s\n", su, mb_reverse(su)); + return 0; +} diff --git a/Task/Reverse-a-string/C/reverse-a-string-2.c b/Task/Reverse-a-string/C/reverse-a-string-2.c new file mode 100644 index 0000000000..df0a21e92d --- /dev/null +++ b/Task/Reverse-a-string/C/reverse-a-string-2.c @@ -0,0 +1,13 @@ +#include +gchar *srev (const gchar *s) { + if (g_utf8_validate(s,-1,NULL)) { + return g_utf8_strreverse (s,-1); +} } +// main +int main (void) { + const gchar *t="asdf"; + const gchar *u="as⃝df̅"; + printf ("%s\n",srev(t)); + printf ("%s\n",srev(u)); + return 0; +} diff --git a/Task/Reverse-a-string/COBOL/reverse-a-string.cobol b/Task/Reverse-a-string/COBOL/reverse-a-string.cobol new file mode 100644 index 0000000000..91e6273d8d --- /dev/null +++ b/Task/Reverse-a-string/COBOL/reverse-a-string.cobol @@ -0,0 +1 @@ +FUNCTION REVERSE-STRING('QWERTY') diff --git a/Task/Reverse-a-string/Clojure/reverse-a-string-1.clj b/Task/Reverse-a-string/Clojure/reverse-a-string-1.clj new file mode 100644 index 0000000000..f542fdb283 --- /dev/null +++ b/Task/Reverse-a-string/Clojure/reverse-a-string-1.clj @@ -0,0 +1 @@ +(defn str-reverse [s] (apply str (reverse s))) diff --git a/Task/Reverse-a-string/Clojure/reverse-a-string-2.clj b/Task/Reverse-a-string/Clojure/reverse-a-string-2.clj new file mode 100644 index 0000000000..2be95a22c0 --- /dev/null +++ b/Task/Reverse-a-string/Clojure/reverse-a-string-2.clj @@ -0,0 +1 @@ +(apply str (interpose " " (reverse (.split "the quick brown fox" " ")))) diff --git a/Task/Reverse-a-string/Clojure/reverse-a-string-3.clj b/Task/Reverse-a-string/Clojure/reverse-a-string-3.clj new file mode 100644 index 0000000000..8a385b6732 --- /dev/null +++ b/Task/Reverse-a-string/Clojure/reverse-a-string-3.clj @@ -0,0 +1,21 @@ +(defn combining? [c] + (let [type (Character/getType c)] + ;; currently hardcoded to the types taken from the sample string + (or (= type 6) (= type 7)))) + +(defn group + "Group normal characters with their combining characters" + [chars] + (cond (empty? chars) chars + (empty? (next chars)) (list chars) + :else + (let [dres (group (next chars))] + (cond (combining? (second chars)) (cons (cons (first chars) + (first dres)) + (rest dres)) + :else (cons (list (first chars)) dres))))) + +(defn str-reverse + "Unicode-safe string reverse" + [s] + (apply str (apply concat (reverse (group s))))) diff --git a/Task/Reverse-a-string/CoffeeScript/reverse-a-string.coffeescript b/Task/Reverse-a-string/CoffeeScript/reverse-a-string.coffeescript new file mode 100644 index 0000000000..fce8acba72 --- /dev/null +++ b/Task/Reverse-a-string/CoffeeScript/reverse-a-string.coffeescript @@ -0,0 +1 @@ +"qwerty".split("").reverse().join "" diff --git a/Task/Reverse-a-string/ColdFusion/reverse-a-string.cfm b/Task/Reverse-a-string/ColdFusion/reverse-a-string.cfm new file mode 100644 index 0000000000..cc7195660c --- /dev/null +++ b/Task/Reverse-a-string/ColdFusion/reverse-a-string.cfm @@ -0,0 +1,2 @@ + + diff --git a/Task/Reverse-a-string/Common-Lisp/reverse-a-string.lisp b/Task/Reverse-a-string/Common-Lisp/reverse-a-string.lisp new file mode 100644 index 0000000000..4e37279b29 --- /dev/null +++ b/Task/Reverse-a-string/Common-Lisp/reverse-a-string.lisp @@ -0,0 +1 @@ +(reverse my-string) diff --git a/Task/Reverse-a-string/D/reverse-a-string.d b/Task/Reverse-a-string/D/reverse-a-string.d new file mode 100644 index 0000000000..bf6155bd64 --- /dev/null +++ b/Task/Reverse-a-string/D/reverse-a-string.d @@ -0,0 +1,15 @@ +import std.stdio, std.range, std.conv; + +void main() { + string s1 = "hello"; // UTF-8 + string s1r = text(retro("hello")); + assert(s1r == "olleh"); + + wstring s2 = "hello"w; // UTF-16 + wstring s2r = wtext(retro("hello")); + assert(s2r == "olleh"); + + dstring s3 = "hello"d; // UTF-32 + dstring s3r = dtext(retro("hello")); + assert(s3r == "olleh"); +} diff --git a/Task/Reverse-a-string/Dart/reverse-a-string.dart b/Task/Reverse-a-string/Dart/reverse-a-string.dart new file mode 100644 index 0000000000..e9ec208922 --- /dev/null +++ b/Task/Reverse-a-string/Dart/reverse-a-string.dart @@ -0,0 +1,11 @@ +String reverse(String s) { + StringBuffer sb=new StringBuffer(); + for(int i=s.length-1;i>=0;i--) { + sb.add(s[i]); + } + return sb.toString(); +} + +main() { + print(reverse('a string.')); +} diff --git a/Task/Reverse-a-string/Delphi/reverse-a-string-1.delphi b/Task/Reverse-a-string/Delphi/reverse-a-string-1.delphi new file mode 100644 index 0000000000..cd5e4a3cae --- /dev/null +++ b/Task/Reverse-a-string/Delphi/reverse-a-string-1.delphi @@ -0,0 +1,7 @@ +function ReverseString(const InString: string): string; +var + i: integer; +begin + for i := Length(InString) downto 1 do + Result := Result + InString[i]; +end; diff --git a/Task/Reverse-a-string/Delphi/reverse-a-string-2.delphi b/Task/Reverse-a-string/Delphi/reverse-a-string-2.delphi new file mode 100644 index 0000000000..2becb68da0 --- /dev/null +++ b/Task/Reverse-a-string/Delphi/reverse-a-string-2.delphi @@ -0,0 +1 @@ +StrUtils.ReverseString diff --git a/Task/Reverse-a-string/E/reverse-a-string.e b/Task/Reverse-a-string/E/reverse-a-string.e new file mode 100644 index 0000000000..83f05514bf --- /dev/null +++ b/Task/Reverse-a-string/E/reverse-a-string.e @@ -0,0 +1,4 @@ +pragma.enable("accumulator") +def reverse(string) { + return accum "" for i in (0..!(string.size())).descending() { _ + string[i] } +} diff --git a/Task/Reverse-a-string/EGL/reverse-a-string.egl b/Task/Reverse-a-string/EGL/reverse-a-string.egl new file mode 100644 index 0000000000..81381fd16c --- /dev/null +++ b/Task/Reverse-a-string/EGL/reverse-a-string.egl @@ -0,0 +1,7 @@ +function reverse( str string ) returns( string ) + result string; + for ( i int from StrLib.characterLen( str ) to 1 decrement by 1 ) + result ::= str[i:i]; + end + return( result ); +end diff --git a/Task/Reverse-a-string/Eiffel/reverse-a-string.e b/Task/Reverse-a-string/Eiffel/reverse-a-string.e new file mode 100644 index 0000000000..a6a56d15b6 --- /dev/null +++ b/Task/Reverse-a-string/Eiffel/reverse-a-string.e @@ -0,0 +1,15 @@ +class + APPLICATION +create + make +feature + make + -- Demonstrate string reversal. + do + my_string := "Hello World!" + my_string.mirror + print (my_string) + end + my_string: STRING + -- Used for reversal +end diff --git a/Task/Reverse-a-string/Emacs-Lisp/reverse-a-string.l b/Task/Reverse-a-string/Emacs-Lisp/reverse-a-string.l new file mode 100644 index 0000000000..57f25aca50 --- /dev/null +++ b/Task/Reverse-a-string/Emacs-Lisp/reverse-a-string.l @@ -0,0 +1 @@ +(concat (reverse (append "Hello World" nil))) diff --git a/Task/Reverse-a-string/Erlang/reverse-a-string-1.erl b/Task/Reverse-a-string/Erlang/reverse-a-string-1.erl new file mode 100644 index 0000000000..bdb70a7a1f --- /dev/null +++ b/Task/Reverse-a-string/Erlang/reverse-a-string-1.erl @@ -0,0 +1,2 @@ +1> lists:reverse("reverse!"). +"!esrever" diff --git a/Task/Reverse-a-string/Erlang/reverse-a-string-2.erl b/Task/Reverse-a-string/Erlang/reverse-a-string-2.erl new file mode 100644 index 0000000000..5ab6a7ea5e --- /dev/null +++ b/Task/Reverse-a-string/Erlang/reverse-a-string-2.erl @@ -0,0 +1,4 @@ +reverse(Bin) -> + Size = size(Bin)*8, + <> = Bin, + <>. diff --git a/Task/Reverse-a-string/Euler-Math-Toolbox/reverse-a-string.euler b/Task/Reverse-a-string/Euler-Math-Toolbox/reverse-a-string.euler new file mode 100644 index 0000000000..6e29139446 --- /dev/null +++ b/Task/Reverse-a-string/Euler-Math-Toolbox/reverse-a-string.euler @@ -0,0 +1,3 @@ +>function strrev (s) := chartostr(fliplr(strtochar(s))) +>strrev("This is a test!") + !tset a si sihT diff --git a/Task/Reverse-a-string/Euphoria/reverse-a-string.euphoria b/Task/Reverse-a-string/Euphoria/reverse-a-string.euphoria new file mode 100644 index 0000000000..9bb12bdac9 --- /dev/null +++ b/Task/Reverse-a-string/Euphoria/reverse-a-string.euphoria @@ -0,0 +1,2 @@ +include std/sequence.e +printf(1, "%s\n", {reverse("abcdef") }) diff --git a/Task/Reverse-a-string/FBSL/reverse-a-string-1.fbsl b/Task/Reverse-a-string/FBSL/reverse-a-string-1.fbsl new file mode 100644 index 0000000000..c37971ad09 --- /dev/null +++ b/Task/Reverse-a-string/FBSL/reverse-a-string-1.fbsl @@ -0,0 +1,8 @@ +Function StrRev1(ByVal $p1) + dim $b = "" + repeat len(p1) + b = b & right(p1,1) + p1 = left(p1,len(p1)-1) + end repeat + return b +End Function diff --git a/Task/Reverse-a-string/FBSL/reverse-a-string-2.fbsl b/Task/Reverse-a-string/FBSL/reverse-a-string-2.fbsl new file mode 100644 index 0000000000..6024fba0bb --- /dev/null +++ b/Task/Reverse-a-string/FBSL/reverse-a-string-2.fbsl @@ -0,0 +1,8 @@ +Function StrRev2(ByVal $p1) + dim $b = "" + dim %i + for i = len(p1) downto 1 + b = b & mid(p1,i,1) + next + return b +End Function diff --git a/Task/Reverse-a-string/FBSL/reverse-a-string-3.fbsl b/Task/Reverse-a-string/FBSL/reverse-a-string-3.fbsl new file mode 100644 index 0000000000..4bc490d61f --- /dev/null +++ b/Task/Reverse-a-string/FBSL/reverse-a-string-3.fbsl @@ -0,0 +1,7 @@ +Function StrRev3( $s ) + FOR DIM x = 1 TO LEN(s) \ 2 + PEEK(@s + LEN - x, $1) + POKE(@s + LEN - x, s{x})(@s + x - 1, PEEK) + NEXT + RETURN s +end function diff --git a/Task/Reverse-a-string/FBSL/reverse-a-string-4.fbsl b/Task/Reverse-a-string/FBSL/reverse-a-string-4.fbsl new file mode 100644 index 0000000000..8855dc781d --- /dev/null +++ b/Task/Reverse-a-string/FBSL/reverse-a-string-4.fbsl @@ -0,0 +1,20 @@ +DynC StringRev($theString) As String + void rev(char *str) + { + int len = strlen(str); + char *HEAD = str; + char *TAIL = str + len - 1; + char temp; + int i; + for ( i = 0; i <= len / 2; i++, HEAD++, TAIL--) { + temp = *HEAD; + *HEAD = *TAIL; + *TAIL = temp; + } + } + char *main(char* theString) + { + rev(theString); + return theString; + } +End DynC diff --git a/Task/Reverse-a-string/Factor/reverse-a-string-1.factor b/Task/Reverse-a-string/Factor/reverse-a-string-1.factor new file mode 100644 index 0000000000..2801b35d54 --- /dev/null +++ b/Task/Reverse-a-string/Factor/reverse-a-string-1.factor @@ -0,0 +1 @@ +"hello" reverse diff --git a/Task/Reverse-a-string/Factor/reverse-a-string-2.factor b/Task/Reverse-a-string/Factor/reverse-a-string-2.factor new file mode 100644 index 0000000000..1096ca87d0 --- /dev/null +++ b/Task/Reverse-a-string/Factor/reverse-a-string-2.factor @@ -0,0 +1 @@ +"as⃝df̅" string-reverse "f̅ds⃝a" = . diff --git a/Task/Reverse-a-string/Fancy/reverse-a-string.fancy b/Task/Reverse-a-string/Fancy/reverse-a-string.fancy new file mode 100644 index 0000000000..828c6c2dc3 --- /dev/null +++ b/Task/Reverse-a-string/Fancy/reverse-a-string.fancy @@ -0,0 +1 @@ +"hello world!" reverse diff --git a/Task/Reverse-a-string/Forth/reverse-a-string.fth b/Task/Reverse-a-string/Forth/reverse-a-string.fth new file mode 100644 index 0000000000..63ae5f43ba --- /dev/null +++ b/Task/Reverse-a-string/Forth/reverse-a-string.fth @@ -0,0 +1,9 @@ +: exchange ( a1 a2 -- ) + 2dup c@ swap c@ rot c! swap c! ; +: reverse ( c-addr u -- ) + 1- bounds begin 2dup > while + 2dup exchange + -1 /string + repeat 2drop ; + +s" testing" 2dup reverse type \ gnitset diff --git a/Task/Reverse-a-string/Fortran/reverse-a-string-1.f b/Task/Reverse-a-string/Fortran/reverse-a-string-1.f new file mode 100644 index 0000000000..6f01424005 --- /dev/null +++ b/Task/Reverse-a-string/Fortran/reverse-a-string-1.f @@ -0,0 +1,16 @@ +PROGRAM Example + + CHARACTER(80) :: str = "This is a string" + CHARACTER :: temp + INTEGER :: i, length + + WRITE (*,*) str + length = LEN_TRIM(str) ! Ignores trailing blanks. Use LEN(str) to reverse those as well + DO i = 1, length/2 + temp = str(i:i) + str(i:i) = str(length+1-i:length+1-i) + str(length+1-i:length+1-i) = temp + END DO + WRITE(*,*) str + +END PROGRAM Example diff --git a/Task/Reverse-a-string/Fortran/reverse-a-string-2.f b/Task/Reverse-a-string/Fortran/reverse-a-string-2.f new file mode 100644 index 0000000000..7a0ebae106 --- /dev/null +++ b/Task/Reverse-a-string/Fortran/reverse-a-string-2.f @@ -0,0 +1,25 @@ +program reverse_string + + implicit none + character (*), parameter :: string = 'no devil lived on' + + write (*, '(a)') string + write (*, '(a)') reverse (string) + +contains + + recursive function reverse (string) result (res) + + implicit none + character (*), intent (in) :: string + character (len (string)) :: res + + if (len (string) == 0) then + res = '' + else + res = string (len (string) :) // reverse (string (: len (string) - 1)) + end if + + end function reverse + +end program reverse_string diff --git a/Task/Reverse-a-string/Frink/reverse-a-string.frink b/Task/Reverse-a-string/Frink/reverse-a-string.frink new file mode 100644 index 0000000000..268a3e0a9b --- /dev/null +++ b/Task/Reverse-a-string/Frink/reverse-a-string.frink @@ -0,0 +1 @@ +println[reverse["abcdef"]] diff --git a/Task/Reverse-a-string/GAP/reverse-a-string.gap b/Task/Reverse-a-string/GAP/reverse-a-string.gap new file mode 100644 index 0000000000..d2b56cbc1b --- /dev/null +++ b/Task/Reverse-a-string/GAP/reverse-a-string.gap @@ -0,0 +1,2 @@ +Reversed("abcdef"); +# "fedcba" diff --git a/Task/Reverse-a-string/Gema/reverse-a-string-1.gema b/Task/Reverse-a-string/Gema/reverse-a-string-1.gema new file mode 100644 index 0000000000..9d764ac851 --- /dev/null +++ b/Task/Reverse-a-string/Gema/reverse-a-string-1.gema @@ -0,0 +1 @@ +\L=@reverse{$1} diff --git a/Task/Reverse-a-string/Gema/reverse-a-string-2.gema b/Task/Reverse-a-string/Gema/reverse-a-string-2.gema new file mode 100644 index 0000000000..a41126a112 --- /dev/null +++ b/Task/Reverse-a-string/Gema/reverse-a-string-2.gema @@ -0,0 +1 @@ +\L=@{$2}$1 diff --git a/Task/Reverse-a-string/Go/reverse-a-string.go b/Task/Reverse-a-string/Go/reverse-a-string.go new file mode 100644 index 0000000000..7a248268a7 --- /dev/null +++ b/Task/Reverse-a-string/Go/reverse-a-string.go @@ -0,0 +1,76 @@ +package main + +import ( + "fmt" + "unicode" + "unicode/utf8" +) + +// no encoding +func reverseBytes(s string) string { + r := make([]byte, len(s)) + for i := 0; i < len(s); i++ { + r[i] = s[len(s)-1-i] + } + return string(r) +} + +// reverseCodePoints interprets its argument as UTF-8 and ignores bytes +// that do not form valid UTF-8. return value is UTF-8. +func reverseCodePoints(s string) string { + r := make([]rune, len(s)) + start := len(s) + for _, c := range s { + // quietly skip invalid UTF-8 + if c != utf8.RuneError { + start-- + r[start] = c + } + } + return string(r[start:]) +} + +// reversePreservingCombiningCharacters interprets its argument as UTF-8 +// and ignores bytes that do not form valid UTF-8. return value is UTF-8. +func reversePreservingCombiningCharacters(s string) string { + if s == "" { + return "" + } + p := []rune(s) + r := make([]rune, len(p)) + start := len(r) + for i := 0; i < len(p); { + // quietly skip invalid UTF-8 + if p[i] == utf8.RuneError { + i++ + continue + } + j := i + 1 + for j < len(p) && (unicode.Is(unicode.Mn, p[j]) || + unicode.Is(unicode.Me, p[j]) || unicode.Is(unicode.Mc, p[j])) { + j++ + } + for k := j - 1; k >= i; k-- { + start-- + r[start] = p[k] + } + i = j + } + return (string(r[start:])) +} + +func main() { + test("asdf") + test("as⃝df̅") +} + +func test(s string) { + fmt.Println("\noriginal: ", []byte(s), s) + r := reverseBytes(s) + fmt.Println("reversed bytes:", []byte(r), r) + fmt.Println("original code points:", []rune(s), s) + r = reverseCodePoints(s) + fmt.Println("reversed code points:", []rune(r), r) + r = reversePreservingCombiningCharacters(s) + fmt.Println("combining characters:", []rune(r), r) +} diff --git a/Task/Reverse-a-string/Groovy/reverse-a-string.groovy b/Task/Reverse-a-string/Groovy/reverse-a-string.groovy new file mode 100644 index 0000000000..12d84ded34 --- /dev/null +++ b/Task/Reverse-a-string/Groovy/reverse-a-string.groovy @@ -0,0 +1 @@ +println "Able was I, 'ere I saw Elba.".reverse() diff --git a/Task/Reverse-a-string/Haskell/reverse-a-string-1.hs b/Task/Reverse-a-string/Haskell/reverse-a-string-1.hs new file mode 100644 index 0000000000..0179759dcc --- /dev/null +++ b/Task/Reverse-a-string/Haskell/reverse-a-string-1.hs @@ -0,0 +1 @@ +reverse = foldl (flip (:)) [] diff --git a/Task/Reverse-a-string/Haskell/reverse-a-string-2.hs b/Task/Reverse-a-string/Haskell/reverse-a-string-2.hs new file mode 100644 index 0000000000..3a3da1eb28 --- /dev/null +++ b/Task/Reverse-a-string/Haskell/reverse-a-string-2.hs @@ -0,0 +1,3 @@ +import Data.Char (isMark) +import Data.List (groupBy) +myReverse = concat . reverse . groupBy (const isMark) diff --git a/Task/Reverse-a-string/HicEst/reverse-a-string.hicest b/Task/Reverse-a-string/HicEst/reverse-a-string.hicest new file mode 100644 index 0000000000..83866df5c9 --- /dev/null +++ b/Task/Reverse-a-string/HicEst/reverse-a-string.hicest @@ -0,0 +1,10 @@ +CHARACTER string = "Hello World", tmp + +L = LEN( string ) +DO i = 1, L/2 + tmp = string(i) + string(i) = string(L-i+1) + string(L-i+1) = tmp +ENDDO + +WRITE(Messagebox, Name) string diff --git a/Task/Reverse-a-string/Icon/reverse-a-string.icon b/Task/Reverse-a-string/Icon/reverse-a-string.icon new file mode 100644 index 0000000000..3a5daac457 --- /dev/null +++ b/Task/Reverse-a-string/Icon/reverse-a-string.icon @@ -0,0 +1,4 @@ +procedure main(arglist) +s := \arglist[1] | "asdf" +write(s," <-> ", reverse(s)) # reverse is built-in +end diff --git a/Task/Reverse-a-string/Io/reverse-a-string.io b/Task/Reverse-a-string/Io/reverse-a-string.io new file mode 100644 index 0000000000..5e81082950 --- /dev/null +++ b/Task/Reverse-a-string/Io/reverse-a-string.io @@ -0,0 +1 @@ +"asdf" reverse diff --git a/Task/Reverse-a-string/J/reverse-a-string-1.j b/Task/Reverse-a-string/J/reverse-a-string-1.j new file mode 100644 index 0000000000..47a8a3b24c --- /dev/null +++ b/Task/Reverse-a-string/J/reverse-a-string-1.j @@ -0,0 +1,2 @@ + |.'asdf' +fdsa diff --git a/Task/Reverse-a-string/J/reverse-a-string-2.j b/Task/Reverse-a-string/J/reverse-a-string-2.j new file mode 100644 index 0000000000..b86ebc45b4 --- /dev/null +++ b/Task/Reverse-a-string/J/reverse-a-string-2.j @@ -0,0 +1,2 @@ + ranges=.16b02ff 16b036f, 16b1dbf 16b1dff, 16b20cf 16b20ff, 16bfe1f 16bfe2f + iscombining=. 2 | ranges&I. diff --git a/Task/Reverse-a-string/J/reverse-a-string-3.j b/Task/Reverse-a-string/J/reverse-a-string-3.j new file mode 100644 index 0000000000..befd0f3f94 --- /dev/null +++ b/Task/Reverse-a-string/J/reverse-a-string-3.j @@ -0,0 +1 @@ + split=. (<;.1~ -.@iscombining) :. ; diff --git a/Task/Reverse-a-string/J/reverse-a-string-4.j b/Task/Reverse-a-string/J/reverse-a-string-4.j new file mode 100644 index 0000000000..f42d45b68a --- /dev/null +++ b/Task/Reverse-a-string/J/reverse-a-string-4.j @@ -0,0 +1,2 @@ + |.&.split&.(3 u: 7&u:) 'as⃝df̅' +f̅ds⃝a diff --git a/Task/Reverse-a-string/Java/reverse-a-string-1.java b/Task/Reverse-a-string/Java/reverse-a-string-1.java new file mode 100644 index 0000000000..8990cd7936 --- /dev/null +++ b/Task/Reverse-a-string/Java/reverse-a-string-1.java @@ -0,0 +1,3 @@ +public static String reverseString(String s) { + return new StringBuffer(s).reverse().toString(); +} diff --git a/Task/Reverse-a-string/Java/reverse-a-string-2.java b/Task/Reverse-a-string/Java/reverse-a-string-2.java new file mode 100644 index 0000000000..ed5bdba287 --- /dev/null +++ b/Task/Reverse-a-string/Java/reverse-a-string-2.java @@ -0,0 +1,3 @@ +public static String reverseString(String s) { + return new StringBuilder(s).reverse().toString(); +} diff --git a/Task/Reverse-a-string/JavaScript/reverse-a-string.js b/Task/Reverse-a-string/JavaScript/reverse-a-string.js new file mode 100644 index 0000000000..344ca8e062 --- /dev/null +++ b/Task/Reverse-a-string/JavaScript/reverse-a-string.js @@ -0,0 +1,3 @@ +var a = "cat".split(""); +a.reverse(); +print(a.join("")); // tac diff --git a/Task/Reverse-a-string/Julia/reverse-a-string.julia b/Task/Reverse-a-string/Julia/reverse-a-string.julia new file mode 100644 index 0000000000..f599a6d450 --- /dev/null +++ b/Task/Reverse-a-string/Julia/reverse-a-string.julia @@ -0,0 +1,2 @@ +julia> reverse("hey") +"yeh" diff --git a/Task/Reverse-a-string/Lang5/reverse-a-string.lang5 b/Task/Reverse-a-string/Lang5/reverse-a-string.lang5 new file mode 100644 index 0000000000..09e73a170f --- /dev/null +++ b/Task/Reverse-a-string/Lang5/reverse-a-string.lang5 @@ -0,0 +1,2 @@ +: flip "" split reverse "" join ; +"qwer asdf" flip . diff --git a/Task/Reverse-a-string/Liberty-BASIC/reverse-a-string.liberty b/Task/Reverse-a-string/Liberty-BASIC/reverse-a-string.liberty new file mode 100644 index 0000000000..3c29c88cf5 --- /dev/null +++ b/Task/Reverse-a-string/Liberty-BASIC/reverse-a-string.liberty @@ -0,0 +1,11 @@ +input$ ="abcdefgABCDEFG012345" +print input$ +print ReversedStr$( input$) + +end + +function ReversedStr$(in$) + for i =len(in$) to 1 step -1 + ReversedStr$ =ReversedStr$ +mid$( in$, i, 1) + next i +end function diff --git a/Task/Reverse-a-string/Logo/reverse-a-string.logo b/Task/Reverse-a-string/Logo/reverse-a-string.logo new file mode 100644 index 0000000000..6e7f35f96c --- /dev/null +++ b/Task/Reverse-a-string/Logo/reverse-a-string.logo @@ -0,0 +1 @@ +print reverse "cat ; tac diff --git a/Task/Reverse-a-string/Lua/reverse-a-string.lua b/Task/Reverse-a-string/Lua/reverse-a-string.lua new file mode 100644 index 0000000000..7b2eb788f5 --- /dev/null +++ b/Task/Reverse-a-string/Lua/reverse-a-string.lua @@ -0,0 +1 @@ +theString = theString:reverse() diff --git a/Task/Reverse-a-string/M4/reverse-a-string.m4 b/Task/Reverse-a-string/M4/reverse-a-string.m4 new file mode 100644 index 0000000000..7fb5bf8de1 --- /dev/null +++ b/Task/Reverse-a-string/M4/reverse-a-string.m4 @@ -0,0 +1 @@ +define(`invert',`ifelse(len(`$1'),0,,`invert(substr(`$1',1))'`'substr(`$1',0,1))') diff --git a/Task/Reverse-a-string/MATLAB/reverse-a-string.m b/Task/Reverse-a-string/MATLAB/reverse-a-string.m new file mode 100644 index 0000000000..db4e99eddd --- /dev/null +++ b/Task/Reverse-a-string/MATLAB/reverse-a-string.m @@ -0,0 +1,6 @@ +>> fliplr(['She told me that she spoke English and I said great. '... +'Grabbed her hand out the club and I said let''s skate.']) + +ans = + +.etaks s'tel dias I dna bulc eht tuo dnah reh debbarG .taerg dias I dna hsilgnE ekops ehs taht em dlot ehS diff --git a/Task/Reverse-a-string/MAXScript/reverse-a-string.maxscript b/Task/Reverse-a-string/MAXScript/reverse-a-string.maxscript new file mode 100644 index 0000000000..a53093f4bc --- /dev/null +++ b/Task/Reverse-a-string/MAXScript/reverse-a-string.maxscript @@ -0,0 +1,6 @@ +fn reverseString s = +( + local reversed = "" + for i in s.count to 1 by -1 do reversed += s[i] + reversed +) diff --git a/Task/Reverse-a-string/MUMPS/reverse-a-string.mumps b/Task/Reverse-a-string/MUMPS/reverse-a-string.mumps new file mode 100644 index 0000000000..1c6036af21 --- /dev/null +++ b/Task/Reverse-a-string/MUMPS/reverse-a-string.mumps @@ -0,0 +1,6 @@ +REVERSE + ;Take in a string and reverse it using the built in function $REVERSE + NEW S + READ:30 "Enter a string: ",S + WRITE !,$REVERSE(S) + QUIT diff --git a/Task/Reverse-a-string/Maple/reverse-a-string.maple b/Task/Reverse-a-string/Maple/reverse-a-string.maple new file mode 100644 index 0000000000..20d9f95516 --- /dev/null +++ b/Task/Reverse-a-string/Maple/reverse-a-string.maple @@ -0,0 +1,2 @@ +> StringTools:-Reverse( "foo" ); + "oof" diff --git a/Task/Reverse-a-string/Mathematica/reverse-a-string.math b/Task/Reverse-a-string/Mathematica/reverse-a-string.math new file mode 100644 index 0000000000..1dd3603698 --- /dev/null +++ b/Task/Reverse-a-string/Mathematica/reverse-a-string.math @@ -0,0 +1 @@ +StringReverse["asdf"] diff --git a/Task/Reverse-a-string/Maxima/reverse-a-string.maxima b/Task/Reverse-a-string/Maxima/reverse-a-string.maxima new file mode 100644 index 0000000000..4e5df653b4 --- /dev/null +++ b/Task/Reverse-a-string/Maxima/reverse-a-string.maxima @@ -0,0 +1,3 @@ +sreverse("abcdef"); /* "fedcba" */ + +sreverse("rats live on no evil star"); /* not a bug :o) */ diff --git a/Task/Reverse-a-string/Mirah/reverse-a-string.mirah b/Task/Reverse-a-string/Mirah/reverse-a-string.mirah new file mode 100644 index 0000000000..414935615c --- /dev/null +++ b/Task/Reverse-a-string/Mirah/reverse-a-string.mirah @@ -0,0 +1,5 @@ +def reverse(s:string) + StringBuilder.new(s).reverse +end + +puts reverse('reversed') diff --git a/Task/Reverse-a-string/Modula-3/reverse-a-string.mod3 b/Task/Reverse-a-string/Modula-3/reverse-a-string.mod3 new file mode 100644 index 0000000000..4742377440 --- /dev/null +++ b/Task/Reverse-a-string/Modula-3/reverse-a-string.mod3 @@ -0,0 +1,16 @@ +MODULE Reverse EXPORTS Main; + +IMPORT IO, Text; + +PROCEDURE String(item: TEXT): TEXT = + VAR result: TEXT := ""; + BEGIN + FOR i := Text.Length(item) - 1 TO 0 BY - 1 DO + result := Text.Cat(result, Text.FromChar(Text.GetChar(item, i))); + END; + RETURN result; + END String; + +BEGIN + IO.Put(String("Foobarbaz") & "\n"); +END Reverse. diff --git a/Task/Reverse-a-string/Nemerle/reverse-a-string-1.nemerle b/Task/Reverse-a-string/Nemerle/reverse-a-string-1.nemerle new file mode 100644 index 0000000000..750cc9d527 --- /dev/null +++ b/Task/Reverse-a-string/Nemerle/reverse-a-string-1.nemerle @@ -0,0 +1,23 @@ +using System; +using System.Globalization; +using System.Windows.Forms; +using System.Console; +using Nemerle.Utility.NString; + +module StrReverse +{ + UReverse(text : string) : string + { + mutable output = []; + def elements = StringInfo.GetTextElementEnumerator(text); + while (elements.MoveNext()) + output ::= elements.GetTextElement().ToString(); + Concat("", output.Reverse()); + } + + Main() : void + { + def test = "as⃝df̅"; + MessageBox.Show($"$test --> $(UReverse(test))"); //for whatever reason my console didn't display Unicode properly, but a MessageBox worked + } +} diff --git a/Task/Reverse-a-string/Nemerle/reverse-a-string-2.nemerle b/Task/Reverse-a-string/Nemerle/reverse-a-string-2.nemerle new file mode 100644 index 0000000000..b1dc45fd91 --- /dev/null +++ b/Task/Reverse-a-string/Nemerle/reverse-a-string-2.nemerle @@ -0,0 +1,7 @@ +Reverse(text : string) : string +{ + mutable output = []; + foreach (c in text.ToCharArray()) + output ::= c.ToString(); + Concat("", output) +} diff --git a/Task/Reverse-a-string/NetRexx/reverse-a-string.netrexx b/Task/Reverse-a-string/NetRexx/reverse-a-string.netrexx new file mode 100644 index 0000000000..6d99f1d0d4 --- /dev/null +++ b/Task/Reverse-a-string/NetRexx/reverse-a-string.netrexx @@ -0,0 +1,11 @@ +/* NetRexx */ + +options replace format comments java crossref savelog symbols nobinary + +reverseThis = 'asdf' +sihTesrever = reverseThis.reverse + +say reverseThis +say sihTesrever + +return diff --git a/Task/Reverse-a-string/NewLISP/reverse-a-string.newlisp b/Task/Reverse-a-string/NewLISP/reverse-a-string.newlisp new file mode 100644 index 0000000000..074dbcd963 --- /dev/null +++ b/Task/Reverse-a-string/NewLISP/reverse-a-string.newlisp @@ -0,0 +1 @@ +(reverse "!dlroW olleH") diff --git a/Task/Reverse-a-string/Nial/reverse-a-string.nial b/Task/Reverse-a-string/Nial/reverse-a-string.nial new file mode 100644 index 0000000000..c38f8f429a --- /dev/null +++ b/Task/Reverse-a-string/Nial/reverse-a-string.nial @@ -0,0 +1,2 @@ +reverse 'asdf' +=fdsa diff --git a/Task/Reverse-a-string/Nimrod/reverse-a-string.nimrod b/Task/Reverse-a-string/Nimrod/reverse-a-string.nimrod new file mode 100644 index 0000000000..85180844cf --- /dev/null +++ b/Task/Reverse-a-string/Nimrod/reverse-a-string.nimrod @@ -0,0 +1,9 @@ +var + str1 = "Reverse This!" + +proc reverse(s: string): string = + result = "" + for i in countdown(high(str1), 0): + result.add str1[i] + +echo "Original string: ", str1, "\nReversed: ", reverse(str1) diff --git a/Task/Reverse-a-string/OCaml/reverse-a-string-1.ocaml b/Task/Reverse-a-string/OCaml/reverse-a-string-1.ocaml new file mode 100644 index 0000000000..f794657d0f --- /dev/null +++ b/Task/Reverse-a-string/OCaml/reverse-a-string-1.ocaml @@ -0,0 +1,9 @@ +let rev_string str = + let len = String.length str in + let res = String.create len in + let last = len - 1 in + for i = 0 to last do + let j = last - i in + res.[i] <- str.[j]; + done; + (res) diff --git a/Task/Reverse-a-string/OCaml/reverse-a-string-2.ocaml b/Task/Reverse-a-string/OCaml/reverse-a-string-2.ocaml new file mode 100644 index 0000000000..d730308ea2 --- /dev/null +++ b/Task/Reverse-a-string/OCaml/reverse-a-string-2.ocaml @@ -0,0 +1,8 @@ +let rev_string str = + let last = String.length str - 1 in + for i = 0 to last / 2 do + let j = last - i in + let c = str.[i] in + str.[i] <- str.[j]; + str.[j] <- c; + done diff --git a/Task/Reverse-a-string/OCaml/reverse-a-string-3.ocaml b/Task/Reverse-a-string/OCaml/reverse-a-string-3.ocaml new file mode 100644 index 0000000000..235a813810 --- /dev/null +++ b/Task/Reverse-a-string/OCaml/reverse-a-string-3.ocaml @@ -0,0 +1,4 @@ +let rec revs strin list index = + if List.length list = String.length strin + then String.concat "" list + else revs strin ((String.sub strin index 1)::list) (index+1) diff --git a/Task/Reverse-a-string/Objeck/reverse-a-string.objeck b/Task/Reverse-a-string/Objeck/reverse-a-string.objeck new file mode 100644 index 0000000000..42a40382b4 --- /dev/null +++ b/Task/Reverse-a-string/Objeck/reverse-a-string.objeck @@ -0,0 +1 @@ +result := "asdf"->Reverse(); diff --git a/Task/Reverse-a-string/Objective-C/reverse-a-string-1.m b/Task/Reverse-a-string/Objective-C/reverse-a-string-1.m new file mode 100644 index 0000000000..5bddb19c97 --- /dev/null +++ b/Task/Reverse-a-string/Objective-C/reverse-a-string-1.m @@ -0,0 +1,20 @@ +#import + +@interface NSString (Extended) +-(NSString *)reverseString; +@end + +@implementation NSString (Extended) +-(NSString *) reverseString +{ + NSUInteger len = [self length]; + NSMutableString *rtr=[NSMutableString stringWithCapacity:len]; + // unichar buf[1]; + + while (len > (NSUInteger)0) { + unichar uch = [self characterAtIndex:--len]; + [rtr appendString:[NSString stringWithCharacters:&uch length:1]]; + } + return rtr; +} +@end diff --git a/Task/Reverse-a-string/Objective-C/reverse-a-string-2.m b/Task/Reverse-a-string/Objective-C/reverse-a-string-2.m new file mode 100644 index 0000000000..245617956c --- /dev/null +++ b/Task/Reverse-a-string/Objective-C/reverse-a-string-2.m @@ -0,0 +1,11 @@ +int main() +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + NSString *test = [@"!A string to be reverted!" reverseString]; + + NSLog(@"%@", test); + + [pool release]; + return 0; +} diff --git a/Task/Reverse-a-string/Objective-C/reverse-a-string-3.m b/Task/Reverse-a-string/Objective-C/reverse-a-string-3.m new file mode 100644 index 0000000000..b5ec48303a --- /dev/null +++ b/Task/Reverse-a-string/Objective-C/reverse-a-string-3.m @@ -0,0 +1,20 @@ +#import + +@interface NSString (Extended) +-(NSString *)reverseString; +@end + +@implementation NSString (Extended) +-(NSString *)reverseString +{ + NSInteger l = [self length] - 1; + NSMutableString *ostr = [NSMutableString stringWithCapacity:[self length]]; + while (l >= 0) + { + NSRange range = [self rangeOfComposedCharacterSequenceAtIndex:l]; + [ostr appendString:[self substringWithRange:range]]; + l -= range.length; + } + return ostr; +} +@end diff --git a/Task/Reverse-a-string/Objective-C/reverse-a-string-4.m b/Task/Reverse-a-string/Objective-C/reverse-a-string-4.m new file mode 100644 index 0000000000..c114a18b02 --- /dev/null +++ b/Task/Reverse-a-string/Objective-C/reverse-a-string-4.m @@ -0,0 +1,11 @@ +int main() +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + NSString *test = [@"as⃝df̅" reverseString]; + + NSLog(@"%@", test); + + [pool release]; + return 0; +} diff --git a/Task/Reverse-a-string/Octave/reverse-a-string.octave b/Task/Reverse-a-string/Octave/reverse-a-string.octave new file mode 100644 index 0000000000..00297cda81 --- /dev/null +++ b/Task/Reverse-a-string/Octave/reverse-a-string.octave @@ -0,0 +1,2 @@ +s = "a string"; +rev = s(length(s):-1:1) diff --git a/Task/Reverse-a-string/OpenEdge-Progress/reverse-a-string.openedge b/Task/Reverse-a-string/OpenEdge-Progress/reverse-a-string.openedge new file mode 100644 index 0000000000..318fa1f8be --- /dev/null +++ b/Task/Reverse-a-string/OpenEdge-Progress/reverse-a-string.openedge @@ -0,0 +1,15 @@ +FUNCTION reverseString RETURNS CHARACTER ( + INPUT i_c AS CHARACTER +): + + DEFINE VARIABLE cresult AS CHARACTER NO-UNDO. + DEFINE VARIABLE ii AS INTEGER NO-UNDO. + + DO ii = LENGTH( i_c ) TO 1 BY -1: + cresult = cresult + SUBSTRING( i_c, ii, 1 ). + END. + RETURN cresult. + +END FUNCTION. + +MESSAGE reverseString( "asdf" ) VIEW-AS ALERT-BOX. diff --git a/Task/Reverse-a-string/OxygenBasic/reverse-a-string-1.oxy b/Task/Reverse-a-string/OxygenBasic/reverse-a-string-1.oxy new file mode 100644 index 0000000000..0ab71d7e5f --- /dev/null +++ b/Task/Reverse-a-string/OxygenBasic/reverse-a-string-1.oxy @@ -0,0 +1,32 @@ +'8 BIT CHARACTERS + +string s="qwertyuiop" +sys a,b,i,j,le=len s +' +for i=1 to le + j=le-i+1 + if j<=i then exit for + a=asc s,i + b=asc s,j + mid s,j,chr a + mid s,i,chr b +next +' + +print s + +'16 BIT CHARACTERS + +wstring s="qwertyuiop" +sys a,b,i,j,le=len s +' +for i=1 to le + j=le-i+1 + if j<=i then exit for + a=unic s,i + b=unic s,j + mid s,j,wchr a + mid s,i,wchr b +next +' +print s diff --git a/Task/Reverse-a-string/OxygenBasic/reverse-a-string-2.oxy b/Task/Reverse-a-string/OxygenBasic/reverse-a-string-2.oxy new file mode 100644 index 0000000000..9768a4ec41 --- /dev/null +++ b/Task/Reverse-a-string/OxygenBasic/reverse-a-string-2.oxy @@ -0,0 +1,19 @@ +string s="qwertyuiop" +sys p=strptr s, le=len s +mov esi,p +mov edi,esi +add edi,le +dec edi +( + cmp esi,edi + jge exit + mov al,[esi] + mov ah,[edi] + mov [esi],ah + mov [edi],al + inc esi + dec edi + repeat +) + +print s diff --git a/Task/Reverse-a-string/Oz/reverse-a-string-1.oz b/Task/Reverse-a-string/Oz/reverse-a-string-1.oz new file mode 100644 index 0000000000..09856df35e --- /dev/null +++ b/Task/Reverse-a-string/Oz/reverse-a-string-1.oz @@ -0,0 +1 @@ +{System.showInfo {Reverse "!dlroW olleH"}} diff --git a/Task/Reverse-a-string/Oz/reverse-a-string-2.oz b/Task/Reverse-a-string/Oz/reverse-a-string-2.oz new file mode 100644 index 0000000000..5aca4e7f4d --- /dev/null +++ b/Task/Reverse-a-string/Oz/reverse-a-string-2.oz @@ -0,0 +1,9 @@ +local + fun {DoReverse Xs Ys} + case Xs of nil then Ys + [] X|Xr then {DoReverse Xr X|Ys} + end + end +in + fun {Reverse Xs} {DoReverse Xs nil} end +end diff --git a/Task/Reverse-a-string/PARI-GP/reverse-a-string.pari b/Task/Reverse-a-string/PARI-GP/reverse-a-string.pari new file mode 100644 index 0000000000..4a74ea454b --- /dev/null +++ b/Task/Reverse-a-string/PARI-GP/reverse-a-string.pari @@ -0,0 +1 @@ +reverse(expr)=my(v=Vec(Str(expr)),n=length(v));concat(vector(n,i,v[n-i+1])); diff --git a/Task/Reverse-a-string/PHP/reverse-a-string-1.php b/Task/Reverse-a-string/PHP/reverse-a-string-1.php new file mode 100644 index 0000000000..948f375058 --- /dev/null +++ b/Task/Reverse-a-string/PHP/reverse-a-string-1.php @@ -0,0 +1 @@ +strrev($string); diff --git a/Task/Reverse-a-string/PHP/reverse-a-string-2.php b/Task/Reverse-a-string/PHP/reverse-a-string-2.php new file mode 100644 index 0000000000..37b77399cb --- /dev/null +++ b/Task/Reverse-a-string/PHP/reverse-a-string-2.php @@ -0,0 +1,2 @@ +// Will split every Unicode character to array, reverse array and will convert it to string. +join('', array_reverse(preg_split('""u', $string, -1, PREG_SPLIT_NO_EMPTY))); diff --git a/Task/Reverse-a-string/PL-I/reverse-a-string.pli b/Task/Reverse-a-string/PL-I/reverse-a-string.pli new file mode 100644 index 0000000000..c7064f3a93 --- /dev/null +++ b/Task/Reverse-a-string/PL-I/reverse-a-string.pli @@ -0,0 +1 @@ +s = reverse(s); diff --git a/Task/Reverse-a-string/Pascal/reverse-a-string-1.pascal b/Task/Reverse-a-string/Pascal/reverse-a-string-1.pascal new file mode 100644 index 0000000000..4e13bcb4f0 --- /dev/null +++ b/Task/Reverse-a-string/Pascal/reverse-a-string-1.pascal @@ -0,0 +1,9 @@ +{ the result array must be at least as large as the original array } +procedure reverse(s: array[min .. max: integer] of char, var result: array[min1 .. max1: integer] of char); + var + i, len: integer; + begin + len := max-min+1; + for i := 0 to len-1 do + result[min1 + len-1 - i] := s[min + i] + end; diff --git a/Task/Reverse-a-string/Pascal/reverse-a-string-2.pascal b/Task/Reverse-a-string/Pascal/reverse-a-string-2.pascal new file mode 100644 index 0000000000..e1f7d11f48 --- /dev/null +++ b/Task/Reverse-a-string/Pascal/reverse-a-string-2.pascal @@ -0,0 +1,10 @@ +{Copy and paste it in your program} +function revstr(my_s:string):string; + var out_s:string; + ls,i:integer; + begin + ls:=length(my_s); + for i:=1 to ls do + out_s:=out_s+my_s[ls-i+1]; + revstr:=out_s; + end; diff --git a/Task/Reverse-a-string/Pascal/reverse-a-string-3.pascal b/Task/Reverse-a-string/Pascal/reverse-a-string-3.pascal new file mode 100644 index 0000000000..3dbfc89b4a --- /dev/null +++ b/Task/Reverse-a-string/Pascal/reverse-a-string-3.pascal @@ -0,0 +1,12 @@ +function reverse(s:string):string; +var i:integer; +var tmp:char; +begin + for i:=1 to length(s) div 2 do + begin + tmp:=s[i]; + s[i]:=s[length(s)+1-i]; + s[length(s)+1-i]:=tmp; + reverse:=s; + end; +end; diff --git a/Task/Reverse-a-string/Perl-6/reverse-a-string.pl6 b/Task/Reverse-a-string/Perl-6/reverse-a-string.pl6 new file mode 100644 index 0000000000..9d9b2bd958 --- /dev/null +++ b/Task/Reverse-a-string/Perl-6/reverse-a-string.pl6 @@ -0,0 +1,4 @@ +# Not transformative. +my $reverse = flip $string; +# or +say "hello world".flip; diff --git a/Task/Reverse-a-string/Perl/reverse-a-string-1.pl b/Task/Reverse-a-string/Perl/reverse-a-string-1.pl new file mode 100644 index 0000000000..8470e6a875 --- /dev/null +++ b/Task/Reverse-a-string/Perl/reverse-a-string-1.pl @@ -0,0 +1,2 @@ +$string = "visor"; +$flip = reverse $string; # becomes "rosiv" diff --git a/Task/Reverse-a-string/Perl/reverse-a-string-2.pl b/Task/Reverse-a-string/Perl/reverse-a-string-2.pl new file mode 100644 index 0000000000..897a47fd3d --- /dev/null +++ b/Task/Reverse-a-string/Perl/reverse-a-string-2.pl @@ -0,0 +1,2 @@ +$string = "Jose\x{301}"; # "José" in NFD +$flip = join("", reverse $string =~ /\X/g); # becomes "ésoJ" diff --git a/Task/Reverse-a-string/PicoLisp/reverse-a-string.l b/Task/Reverse-a-string/PicoLisp/reverse-a-string.l new file mode 100644 index 0000000000..5b586a4926 --- /dev/null +++ b/Task/Reverse-a-string/PicoLisp/reverse-a-string.l @@ -0,0 +1 @@ +(pack (flip (chop "äöüÄÖÜß"))) diff --git a/Task/Reverse-a-string/Pop11/reverse-a-string.pop11 b/Task/Reverse-a-string/Pop11/reverse-a-string.pop11 new file mode 100644 index 0000000000..71a5d2404c --- /dev/null +++ b/Task/Reverse-a-string/Pop11/reverse-a-string.pop11 @@ -0,0 +1,7 @@ +define reverse_string(s); + lvars i, l = length(s); + for i from l by -1 to 1 do + s(i); + endfor; + consstring(l); +enddefine; diff --git a/Task/Reverse-a-string/PostScript/reverse-a-string-1.ps b/Task/Reverse-a-string/PostScript/reverse-a-string-1.ps new file mode 100644 index 0000000000..9c0ac6d6f3 --- /dev/null +++ b/Task/Reverse-a-string/PostScript/reverse-a-string-1.ps @@ -0,0 +1,12 @@ +/reverse{ +/str exch def +/temp str 0 get def +/i 0 def +str length 2 idiv{ +/temp str i get def +str i str str length i sub 1 sub get put +str str length i sub 1 sub temp put +/i i 1 add def +}repeat +str pstack +}def diff --git a/Task/Reverse-a-string/PostScript/reverse-a-string-2.ps b/Task/Reverse-a-string/PostScript/reverse-a-string-2.ps new file mode 100644 index 0000000000..f63de332b1 --- /dev/null +++ b/Task/Reverse-a-string/PostScript/reverse-a-string-2.ps @@ -0,0 +1,5 @@ +[1 2 3] reverse % input +[3 2 1] + +(Hello World) reverse % input +(dlroW olleH) diff --git a/Task/Reverse-a-string/PowerShell/reverse-a-string-1.psh b/Task/Reverse-a-string/PowerShell/reverse-a-string-1.psh new file mode 100644 index 0000000000..5d82370750 --- /dev/null +++ b/Task/Reverse-a-string/PowerShell/reverse-a-string-1.psh @@ -0,0 +1 @@ +$s = "asdf" diff --git a/Task/Reverse-a-string/PowerShell/reverse-a-string-2.psh b/Task/Reverse-a-string/PowerShell/reverse-a-string-2.psh new file mode 100644 index 0000000000..35096dddad --- /dev/null +++ b/Task/Reverse-a-string/PowerShell/reverse-a-string-2.psh @@ -0,0 +1 @@ +[string]::Join('', $s[$s.Length..0]) diff --git a/Task/Reverse-a-string/PowerShell/reverse-a-string-3.psh b/Task/Reverse-a-string/PowerShell/reverse-a-string-3.psh new file mode 100644 index 0000000000..0d7e0598ec --- /dev/null +++ b/Task/Reverse-a-string/PowerShell/reverse-a-string-3.psh @@ -0,0 +1 @@ +-join ($s[$s.Length..0]) diff --git a/Task/Reverse-a-string/PowerShell/reverse-a-string-4.psh b/Task/Reverse-a-string/PowerShell/reverse-a-string-4.psh new file mode 100644 index 0000000000..05e4e5c9bc --- /dev/null +++ b/Task/Reverse-a-string/PowerShell/reverse-a-string-4.psh @@ -0,0 +1 @@ +[array]::Reverse($s) diff --git a/Task/Reverse-a-string/PowerShell/reverse-a-string-5.psh b/Task/Reverse-a-string/PowerShell/reverse-a-string-5.psh new file mode 100644 index 0000000000..1188b1d8b7 --- /dev/null +++ b/Task/Reverse-a-string/PowerShell/reverse-a-string-5.psh @@ -0,0 +1,3 @@ +$s -replace + ('(.)' * $s.Length), + [string]::Join('', ($s.Length..1 | ForEach-Object { "`$$_" })) diff --git a/Task/Reverse-a-string/PowerShell/reverse-a-string-6.psh b/Task/Reverse-a-string/PowerShell/reverse-a-string-6.psh new file mode 100644 index 0000000000..f28c286a06 --- /dev/null +++ b/Task/Reverse-a-string/PowerShell/reverse-a-string-6.psh @@ -0,0 +1,3 @@ +$s -replace + ('(.)' * $s.Length), + -join ($s.Length..1 | ForEach-Object { "`$$_" } ) diff --git a/Task/Reverse-a-string/Prolog/reverse-a-string-1.pro b/Task/Reverse-a-string/Prolog/reverse-a-string-1.pro new file mode 100644 index 0000000000..d006aa7a8b --- /dev/null +++ b/Task/Reverse-a-string/Prolog/reverse-a-string-1.pro @@ -0,0 +1 @@ +reverse("abcd", L), string_to_list(S,L). diff --git a/Task/Reverse-a-string/Prolog/reverse-a-string-2.pro b/Task/Reverse-a-string/Prolog/reverse-a-string-2.pro new file mode 100644 index 0000000000..91a7cac352 --- /dev/null +++ b/Task/Reverse-a-string/Prolog/reverse-a-string-2.pro @@ -0,0 +1,3 @@ +output : +L = [100,99,98,97], +S = "dcba". diff --git a/Task/Reverse-a-string/Prolog/reverse-a-string-3.pro b/Task/Reverse-a-string/Prolog/reverse-a-string-3.pro new file mode 100644 index 0000000000..f27483e3d3 --- /dev/null +++ b/Task/Reverse-a-string/Prolog/reverse-a-string-3.pro @@ -0,0 +1,4 @@ +accRev([H|T], A, R) :- accRev(T, [H|A], R). +accRev([], A, A). + +rev(L,R) :- accRev(L,[],R). diff --git a/Task/Reverse-a-string/Protium/reverse-a-string-1.protium b/Task/Reverse-a-string/Protium/reverse-a-string-1.protium new file mode 100644 index 0000000000..d267f6da1d --- /dev/null +++ b/Task/Reverse-a-string/Protium/reverse-a-string-1.protium @@ -0,0 +1 @@ +<# 显示 指定 变量 反转顺序 字串>集装箱|猫坐在垫子 diff --git a/Task/Reverse-a-string/Protium/reverse-a-string-2.protium b/Task/Reverse-a-string/Protium/reverse-a-string-2.protium new file mode 100644 index 0000000000..3933f09397 --- /dev/null +++ b/Task/Reverse-a-string/Protium/reverse-a-string-2.protium @@ -0,0 +1 @@ +<# 보이십 할당하 변물건 열거꾸 문자그>컨테이너|고양이가 매트 위에 앉아 diff --git a/Task/Reverse-a-string/Protium/reverse-a-string-3.protium b/Task/Reverse-a-string/Protium/reverse-a-string-3.protium new file mode 100644 index 0000000000..b7e8cf08b7 --- /dev/null +++ b/Task/Reverse-a-string/Protium/reverse-a-string-3.protium @@ -0,0 +1 @@ +<@ SAYLETVARREVLIT>集装箱|猫坐在垫子 diff --git a/Task/Reverse-a-string/PureBasic/reverse-a-string.purebasic b/Task/Reverse-a-string/PureBasic/reverse-a-string.purebasic new file mode 100644 index 0000000000..d1b866378b --- /dev/null +++ b/Task/Reverse-a-string/PureBasic/reverse-a-string.purebasic @@ -0,0 +1 @@ +Debug ReverseString("!dekrow tI") diff --git a/Task/Reverse-a-string/Python/reverse-a-string-1.py b/Task/Reverse-a-string/Python/reverse-a-string-1.py new file mode 100644 index 0000000000..b1bb2ca3e8 --- /dev/null +++ b/Task/Reverse-a-string/Python/reverse-a-string-1.py @@ -0,0 +1 @@ +raw_input()[::-1] diff --git a/Task/Reverse-a-string/Python/reverse-a-string-2.py b/Task/Reverse-a-string/Python/reverse-a-string-2.py new file mode 100644 index 0000000000..d430855bba --- /dev/null +++ b/Task/Reverse-a-string/Python/reverse-a-string-2.py @@ -0,0 +1 @@ +string[::-1] diff --git a/Task/Reverse-a-string/Python/reverse-a-string-3.py b/Task/Reverse-a-string/Python/reverse-a-string-3.py new file mode 100644 index 0000000000..621071bae6 --- /dev/null +++ b/Task/Reverse-a-string/Python/reverse-a-string-3.py @@ -0,0 +1,36 @@ +''' + Reverse a Unicode string with proper handling of combining characters +''' + +import unicodedata + +def ureverse(ustring): + ''' + Reverse a string including unicode combining characters + + Example: + >>> ucode = ''.join( chr(int(n, 16)) + for n in ['61', '73', '20dd', '64', '66', '305'] ) + >>> ucoderev = ureverse(ucode) + >>> ['%x' % ord(char) for char in ucoderev] + ['66', '305', '64', '73', '20dd', '61'] + >>> + ''' + groupedchars = [] + uchar = list(ustring) + while uchar: + if 'COMBINING' in unicodedata.name(uchar[0], ''): + groupedchars[-1] += uchar.pop(0) + else: + groupedchars.append(uchar.pop(0)) + # Grouped reversal + groupedchars = groupedchars[::-1] + + return ''.join(groupedchars) + +if __name__ == '__main__': + ucode = ''.join( chr(int(n, 16)) + for n in ['61', '73', '20dd', '64', '66', '305'] ) + ucoderev = ureverse(ucode) + print (ucode) + print (ucoderev) diff --git a/Task/Reverse-a-string/Qi/reverse-a-string.qi b/Task/Reverse-a-string/Qi/reverse-a-string.qi new file mode 100644 index 0000000000..95333b9faa --- /dev/null +++ b/Task/Reverse-a-string/Qi/reverse-a-string.qi @@ -0,0 +1 @@ +(REVERSE "ABCD") diff --git a/Task/Reverse-a-string/R/reverse-a-string-1.r b/Task/Reverse-a-string/R/reverse-a-string-1.r new file mode 100644 index 0000000000..b0fe05e5a9 --- /dev/null +++ b/Task/Reverse-a-string/R/reverse-a-string-1.r @@ -0,0 +1,7 @@ +revstring <- function(stringtorev) { + return( + paste( + strsplit(stringtorev,"")[[1]][nchar(stringtorev):1] + ,collapse="") + ) +} diff --git a/Task/Reverse-a-string/R/reverse-a-string-2.r b/Task/Reverse-a-string/R/reverse-a-string-2.r new file mode 100644 index 0000000000..433e6c9c87 --- /dev/null +++ b/Task/Reverse-a-string/R/reverse-a-string-2.r @@ -0,0 +1 @@ + revstring <- function(s) paste(rev(strsplit(s,"")[[1]]),collapse="") diff --git a/Task/Reverse-a-string/R/reverse-a-string-3.r b/Task/Reverse-a-string/R/reverse-a-string-3.r new file mode 100644 index 0000000000..611a9594a1 --- /dev/null +++ b/Task/Reverse-a-string/R/reverse-a-string-3.r @@ -0,0 +1,4 @@ +revstring("asdf") +revstring("m\u00f8\u00f8se") +Encoding("m\u00f8\u00f8se") # just to check if on your system it's something + # different! diff --git a/Task/Reverse-a-string/REBOL/reverse-a-string-1.rebol b/Task/Reverse-a-string/REBOL/reverse-a-string-1.rebol new file mode 100644 index 0000000000..16ec445ce9 --- /dev/null +++ b/Task/Reverse-a-string/REBOL/reverse-a-string-1.rebol @@ -0,0 +1 @@ +print reverse "asdf" diff --git a/Task/Reverse-a-string/REBOL/reverse-a-string-2.rebol b/Task/Reverse-a-string/REBOL/reverse-a-string-2.rebol new file mode 100644 index 0000000000..715e4dab08 --- /dev/null +++ b/Task/Reverse-a-string/REBOL/reverse-a-string-2.rebol @@ -0,0 +1,3 @@ +x: "asdf" +print reverse x +print x ; Now reversed. diff --git a/Task/Reverse-a-string/REXX/reverse-a-string-1.rexx b/Task/Reverse-a-string/REXX/reverse-a-string-1.rexx new file mode 100644 index 0000000000..e94666a3be --- /dev/null +++ b/Task/Reverse-a-string/REXX/reverse-a-string-1.rexx @@ -0,0 +1,8 @@ +/*REXX program to reverse a string (and show before and after strings).*/ + +string1 = 'A man, a plan, a canal, Panama!' +string2 = reverse(string1) + +say ' original string: ' string1 +say ' reversed string: ' string2 + /*stick a fork in it, we're done.*/ diff --git a/Task/Reverse-a-string/REXX/reverse-a-string-2.rexx b/Task/Reverse-a-string/REXX/reverse-a-string-2.rexx new file mode 100644 index 0000000000..343e3157d3 --- /dev/null +++ b/Task/Reverse-a-string/REXX/reverse-a-string-2.rexx @@ -0,0 +1,10 @@ +/*REXX program to reverse a string (and show before and after strings).*/ + +string1 = 'A man, a plan, a canal, Panama!' +string2 = + do j=1 for length(string1) + string2 = substr(string1,j,1)string2 + end /*j*/ +say ' original string: ' string1 +say ' reversed string: ' string2 + /*stick a fork in it, we're done.*/ diff --git a/Task/Reverse-a-string/REXX/reverse-a-string-3.rexx b/Task/Reverse-a-string/REXX/reverse-a-string-3.rexx new file mode 100644 index 0000000000..93e1f48289 --- /dev/null +++ b/Task/Reverse-a-string/REXX/reverse-a-string-3.rexx @@ -0,0 +1,3 @@ + string2 = substr(string1,j,1) || string2 + /*───── or ─────*/ + string2=substr(string1,j,1)||string2 diff --git a/Task/Reverse-a-string/REXX/reverse-a-string-4.rexx b/Task/Reverse-a-string/REXX/reverse-a-string-4.rexx new file mode 100644 index 0000000000..2fdeb4244c --- /dev/null +++ b/Task/Reverse-a-string/REXX/reverse-a-string-4.rexx @@ -0,0 +1,10 @@ +/*REXX program to reverse a string (and show before and after strings).*/ + +string1 = 'A man, a plan, a canal, Panama!' +string2 = + do j=length(string1) to 1 by -1 + string2 = string2 || substr(string1,j,1) + end /*j*/ +say ' original string: ' string1 +say ' reversed string: ' string2 + /*stick a fork in it, we're done.*/ diff --git a/Task/Reverse-a-string/RLaB/reverse-a-string.rlab b/Task/Reverse-a-string/RLaB/reverse-a-string.rlab new file mode 100644 index 0000000000..2fdecda92f --- /dev/null +++ b/Task/Reverse-a-string/RLaB/reverse-a-string.rlab @@ -0,0 +1,12 @@ +>> x = "rosettacode" +rosettacode + +// script +rx = ""; +for (i in strlen(x):1:-1) +{ + rx = rx + substr(x, i); +} + +>> rx +edocattesor diff --git a/Task/Reverse-a-string/Racket/reverse-a-string.rkt b/Task/Reverse-a-string/Racket/reverse-a-string.rkt new file mode 100644 index 0000000000..24552d8378 --- /dev/null +++ b/Task/Reverse-a-string/Racket/reverse-a-string.rkt @@ -0,0 +1,6 @@ +#lang racket + +(define (string-reverse s) + (list->string (reverse (string->list s)))) + +(string-reverse "aoeu") diff --git a/Task/Reverse-a-string/Rascal/reverse-a-string.rascal b/Task/Reverse-a-string/Rascal/reverse-a-string.rascal new file mode 100644 index 0000000000..e4c10081b3 --- /dev/null +++ b/Task/Reverse-a-string/Rascal/reverse-a-string.rascal @@ -0,0 +1,2 @@ +import String; +reverse("string") diff --git a/Task/Reverse-a-string/Retro/reverse-a-string.retro b/Task/Reverse-a-string/Retro/reverse-a-string.retro new file mode 100644 index 0000000000..80f570d537 --- /dev/null +++ b/Task/Reverse-a-string/Retro/reverse-a-string.retro @@ -0,0 +1,2 @@ +with strings' +"asdf" reverse puts diff --git a/Task/Reverse-a-string/Ruby/reverse-a-string-1.rb b/Task/Reverse-a-string/Ruby/reverse-a-string-1.rb new file mode 100644 index 0000000000..8d3e07aab7 --- /dev/null +++ b/Task/Reverse-a-string/Ruby/reverse-a-string-1.rb @@ -0,0 +1,2 @@ +str = "asdf" +reversed = str.reverse diff --git a/Task/Reverse-a-string/Ruby/reverse-a-string-2.rb b/Task/Reverse-a-string/Ruby/reverse-a-string-2.rb new file mode 100644 index 0000000000..3f016b77d0 --- /dev/null +++ b/Task/Reverse-a-string/Ruby/reverse-a-string-2.rb @@ -0,0 +1,2 @@ +#encoding: utf-8 +"résumé niño".reverse #=> "oñin émusér" diff --git a/Task/Reverse-a-string/Run-BASIC/reverse-a-string.run b/Task/Reverse-a-string/Run-BASIC/reverse-a-string.run new file mode 100644 index 0000000000..1b6e4c7423 --- /dev/null +++ b/Task/Reverse-a-string/Run-BASIC/reverse-a-string.run @@ -0,0 +1,4 @@ +string$ = "123456789abcdefghijk" +for i = len(string$) to 1 step -1 + print mid$(string$,i,1); +next i diff --git a/Task/Reverse-a-string/SAS/reverse-a-string.sas b/Task/Reverse-a-string/SAS/reverse-a-string.sas new file mode 100644 index 0000000000..9856aa49e3 --- /dev/null +++ b/Task/Reverse-a-string/SAS/reverse-a-string.sas @@ -0,0 +1,7 @@ +data _null_; +length a b $11; +a="I am Legend"; +b=reverse(a); +put a; +put b; +run; diff --git a/Task/Reverse-a-string/SNOBOL4/reverse-a-string.sno b/Task/Reverse-a-string/SNOBOL4/reverse-a-string.sno new file mode 100644 index 0000000000..e2c2e0378b --- /dev/null +++ b/Task/Reverse-a-string/SNOBOL4/reverse-a-string.sno @@ -0,0 +1,2 @@ + output = reverse(reverse("reverse")) +end diff --git a/Task/Reverse-a-string/Sather/reverse-a-string.sa b/Task/Reverse-a-string/Sather/reverse-a-string.sa new file mode 100644 index 0000000000..4dbf8ccff6 --- /dev/null +++ b/Task/Reverse-a-string/Sather/reverse-a-string.sa @@ -0,0 +1,7 @@ +class MAIN is + main is + s ::= "asdf"; + reversed ::= s.reverse; + -- current implementation does not handle multibyte encodings correctly + end; +end; diff --git a/Task/Reverse-a-string/Scala/reverse-a-string-1.scala b/Task/Reverse-a-string/Scala/reverse-a-string-1.scala new file mode 100644 index 0000000000..14907b20b8 --- /dev/null +++ b/Task/Reverse-a-string/Scala/reverse-a-string-1.scala @@ -0,0 +1 @@ +"asdf".reverse diff --git a/Task/Reverse-a-string/Scala/reverse-a-string-2.scala b/Task/Reverse-a-string/Scala/reverse-a-string-2.scala new file mode 100644 index 0000000000..04c22cbf30 --- /dev/null +++ b/Task/Reverse-a-string/Scala/reverse-a-string-2.scala @@ -0,0 +1 @@ +"asdf".foldRight(""){ (a,b)=> b+a } diff --git a/Task/Reverse-a-string/Scala/reverse-a-string-3.scala b/Task/Reverse-a-string/Scala/reverse-a-string-3.scala new file mode 100644 index 0000000000..baacf97a84 --- /dev/null +++ b/Task/Reverse-a-string/Scala/reverse-a-string-3.scala @@ -0,0 +1,30 @@ +def reverseString(s: String) = { + import java.lang.Character._ + + val combiningTypes = List(NON_SPACING_MARK, ENCLOSING_MARK, COMBINING_SPACING_MARK) + def isCombiningCharacter(c: Char) = combiningTypes contains c.getType + def isCombiningSurrogate(high: Char, low: Char) = combiningTypes contains getType(toCodePoint(high, low)) + def isCombining(l: List[Char]) = l match { + case List(a, b) => isCombiningSurrogate(a, b) + case List(a) => isCombiningCharacter(a) + case Nil => true + case _ => throw new IllegalArgumentException("isCombining expects a list of up to two characters") + } + + def cleanSurrogate(l: List[Char]) = l match { + case List(a, b) if a.isHighSurrogate && b.isLowSurrogate => l + case List(a, b) if a.isLowSurrogate => Nil + case List(a, b) => List(a) + case _ => throw new IllegalArgumentException("cleanSurrogate expects lists of two characters, exactly") + } + + def splitString(string: String) = (string+" ").iterator sliding 2 map (_.toList) map cleanSurrogate toList + + def recurse(fwd: List[List[Char]], rev: List[Char]): String = fwd match { + case Nil => rev.mkString + case c :: rest => + val (combining, remaining) = rest span isCombining + recurse(remaining, c ::: combining.foldLeft(List[Char]())(_ ::: _) ::: rev) + } + recurse(splitString(s), Nil) +} diff --git a/Task/Reverse-a-string/Scheme/reverse-a-string.ss b/Task/Reverse-a-string/Scheme/reverse-a-string.ss new file mode 100644 index 0000000000..250e0e8256 --- /dev/null +++ b/Task/Reverse-a-string/Scheme/reverse-a-string.ss @@ -0,0 +1,2 @@ +(define (string-reverse s) + (list->string (reverse (string->list s)))) diff --git a/Task/Reverse-a-string/Sed/reverse-a-string.sed b/Task/Reverse-a-string/Sed/reverse-a-string.sed new file mode 100644 index 0000000000..ca3958b7c9 --- /dev/null +++ b/Task/Reverse-a-string/Sed/reverse-a-string.sed @@ -0,0 +1,18 @@ +#!/bin/sed -f + +/../! b + +# Reverse a line. Begin embedding the line between two newlines +s/^.*$/\ +&\ +/ + +# Move first character at the end. The regexp matches until +# there are zero or one characters between the markers +tx +:x +s/\(\n.\)\(.*\)\(.\n\)/\3\2\1/ +tx + +# Remove the newline markers +s/\n//g diff --git a/Task/Reverse-a-string/Seed7/reverse-a-string.seed7 b/Task/Reverse-a-string/Seed7/reverse-a-string.seed7 new file mode 100644 index 0000000000..28eb7de6c8 --- /dev/null +++ b/Task/Reverse-a-string/Seed7/reverse-a-string.seed7 @@ -0,0 +1,17 @@ +$ include "seed7_05.s7i"; + +const func string: reverse (in string: stri) is func + result + var string: result is ""; + local + var integer: index is 0; + begin + for index range length(stri) downto 1 do + result &:= stri[index]; + end for; + end func; + +const proc: main is func + begin + writeln(reverse("Was it a cat I saw")); + end func; diff --git a/Task/Reverse-a-string/Slate/reverse-a-string-1.slate b/Task/Reverse-a-string/Slate/reverse-a-string-1.slate new file mode 100644 index 0000000000..0e7631bad3 --- /dev/null +++ b/Task/Reverse-a-string/Slate/reverse-a-string-1.slate @@ -0,0 +1 @@ +'asdf' reverse diff --git a/Task/Reverse-a-string/Slate/reverse-a-string-2.slate b/Task/Reverse-a-string/Slate/reverse-a-string-2.slate new file mode 100644 index 0000000000..a7bc2a41a3 --- /dev/null +++ b/Task/Reverse-a-string/Slate/reverse-a-string-2.slate @@ -0,0 +1 @@ +'asdf' reversed diff --git a/Task/Reverse-a-string/Smalltalk/reverse-a-string-1.st b/Task/Reverse-a-string/Smalltalk/reverse-a-string-1.st new file mode 100644 index 0000000000..0e7631bad3 --- /dev/null +++ b/Task/Reverse-a-string/Smalltalk/reverse-a-string-1.st @@ -0,0 +1 @@ +'asdf' reverse diff --git a/Task/Reverse-a-string/Smalltalk/reverse-a-string-2.st b/Task/Reverse-a-string/Smalltalk/reverse-a-string-2.st new file mode 100644 index 0000000000..a7bc2a41a3 --- /dev/null +++ b/Task/Reverse-a-string/Smalltalk/reverse-a-string-2.st @@ -0,0 +1 @@ +'asdf' reversed diff --git a/Task/Reverse-a-string/Standard-ML/reverse-a-string.ml b/Task/Reverse-a-string/Standard-ML/reverse-a-string.ml new file mode 100644 index 0000000000..17a5328c51 --- /dev/null +++ b/Task/Reverse-a-string/Standard-ML/reverse-a-string.ml @@ -0,0 +1,3 @@ +val str_reverse = implode o rev o explode; +val string = "asdf"; +val reversed = str_reverse string; diff --git a/Task/Reverse-a-string/TI-83-BASIC/reverse-a-string.ti-83 b/Task/Reverse-a-string/TI-83-BASIC/reverse-a-string.ti-83 new file mode 100644 index 0000000000..0aff34ab2f --- /dev/null +++ b/Task/Reverse-a-string/TI-83-BASIC/reverse-a-string.ti-83 @@ -0,0 +1,8 @@ +:"ASDF"→Str1 +: +:" "→Str0 +:length(Str1)→B +:For(A,B,1,-1) +:Str0+sub(Str1,A,1)→Str0 +:End +:sub(Str0,2,B)→Str0 diff --git a/Task/Reverse-a-string/TUSCRIPT/reverse-a-string.tuscript b/Task/Reverse-a-string/TUSCRIPT/reverse-a-string.tuscript new file mode 100644 index 0000000000..a2309324cb --- /dev/null +++ b/Task/Reverse-a-string/TUSCRIPT/reverse-a-string.tuscript @@ -0,0 +1,5 @@ +$$ MODE TUSCRIPT +SET input="was it really a big fat cat i saw" +SET reversetext=TURN (input) +PRINT "before: ",input +PRINT "after: ",reversetext diff --git a/Task/Reverse-a-string/Tcl/reverse-a-string.tcl b/Task/Reverse-a-string/Tcl/reverse-a-string.tcl new file mode 100644 index 0000000000..aa0e344bc2 --- /dev/null +++ b/Task/Reverse-a-string/Tcl/reverse-a-string.tcl @@ -0,0 +1,2 @@ +package require Tcl 8.5 +string reverse asdf diff --git a/Task/Reverse-a-string/Turing/reverse-a-string.turing b/Task/Reverse-a-string/Turing/reverse-a-string.turing new file mode 100644 index 0000000000..02e08e2fd2 --- /dev/null +++ b/Task/Reverse-a-string/Turing/reverse-a-string.turing @@ -0,0 +1,16 @@ +% Reverse a string + +var input : string (100) + +put "Enter a string to reverse: " .. +get input + +var count : int := length(input) +loop + if count >= 1 then + put input(count) .. + else + exit + end if + count := count - 1 +end loop diff --git a/Task/Reverse-a-string/Unlambda/reverse-a-string.unlambda b/Task/Reverse-a-string/Unlambda/reverse-a-string.unlambda new file mode 100644 index 0000000000..2ef653e229 --- /dev/null +++ b/Task/Reverse-a-string/Unlambda/reverse-a-string.unlambda @@ -0,0 +1 @@ +``@c`d``s`|k`@c diff --git a/Task/Reverse-a-string/Ursala/reverse-a-string.ursala b/Task/Reverse-a-string/Ursala/reverse-a-string.ursala new file mode 100644 index 0000000000..d09f739390 --- /dev/null +++ b/Task/Reverse-a-string/Ursala/reverse-a-string.ursala @@ -0,0 +1,7 @@ +#import std + +#cast %s + +example = ~&x 'asdf' + +verbose_example = reverse 'asdf' diff --git a/Task/Reverse-a-string/VBA/reverse-a-string-1.vba b/Task/Reverse-a-string/VBA/reverse-a-string-1.vba new file mode 100644 index 0000000000..6b95d78603 --- /dev/null +++ b/Task/Reverse-a-string/VBA/reverse-a-string-1.vba @@ -0,0 +1,12 @@ +Public Function Reverse(aString as String) as String +' returns the reversed string +dim L as integer 'length of string +dim newString as string + +newString = "" +L = len(aString) +for i = L to 1 step -1 + newString = newString & mid$(aString, i, 1) +next +Reverse = newString +End Function diff --git a/Task/Reverse-a-string/VBA/reverse-a-string-2.vba b/Task/Reverse-a-string/VBA/reverse-a-string-2.vba new file mode 100644 index 0000000000..cdd9e6ffb6 --- /dev/null +++ b/Task/Reverse-a-string/VBA/reverse-a-string-2.vba @@ -0,0 +1,14 @@ +Public Function RReverse(aString As String) As String +'returns the reversed string +'do it recursively: cut the string in two, reverse these fragments and put them back together in reverse order +Dim L As Integer 'length of string +Dim M As Integer 'cut point + +L = Len(aString) +If L <= 1 Then 'no need to reverse + RReverse = aString +Else + M = Int(L / 2) + RReverse = RReverse(Right$(aString, L - M)) & RReverse(Left$(aString, M)) +End If +End Function diff --git a/Task/Reverse-a-string/Vedit-macro-language/reverse-a-string-1.vedit b/Task/Reverse-a-string/Vedit-macro-language/reverse-a-string-1.vedit new file mode 100644 index 0000000000..27244b711b --- /dev/null +++ b/Task/Reverse-a-string/Vedit-macro-language/reverse-a-string-1.vedit @@ -0,0 +1,4 @@ +Reg_Empty(10) +for (BOL; !At_EOL; Char) { + Reg_Copy_Block(10, CP, CP+1, INSERT) +} diff --git a/Task/Reverse-a-string/Vedit-macro-language/reverse-a-string-2.vedit b/Task/Reverse-a-string/Vedit-macro-language/reverse-a-string-2.vedit new file mode 100644 index 0000000000..cf25bd19b6 --- /dev/null +++ b/Task/Reverse-a-string/Vedit-macro-language/reverse-a-string-2.vedit @@ -0,0 +1,4 @@ +BOL +while (!At_EOL) { + Block_Copy(EOL_pos-1, EOL_pos, DELETE) +} diff --git a/Task/Reverse-a-string/Visual-Basic-.NET/reverse-a-string.visual b/Task/Reverse-a-string/Visual-Basic-.NET/reverse-a-string.visual new file mode 100644 index 0000000000..a684e5efcb --- /dev/null +++ b/Task/Reverse-a-string/Visual-Basic-.NET/reverse-a-string.visual @@ -0,0 +1,5 @@ + Function Reverse(ByVal s As String) As String + Dim t() as Char = s.toCharArray + Array.reverse(t) + Return new String(t) + End Function diff --git a/Task/Reverse-a-string/XPL0/reverse-a-string.xpl0 b/Task/Reverse-a-string/XPL0/reverse-a-string.xpl0 new file mode 100644 index 0000000000..a5b3158e78 --- /dev/null +++ b/Task/Reverse-a-string/XPL0/reverse-a-string.xpl0 @@ -0,0 +1,23 @@ +include c:\cxpl\codes; \intrinsic 'code' declarations +string 0; \use zero-terminated strings, instead of MSb terminated + +func StrLen(Str); \Return the number of characters in an ASCIIZ string +char Str; +int I; +for I:= 0 to -1>>1-1 do + if Str(I) = 0 then return I; + +func RevStr(S); \Reverse the order of the bytes in a string +char S; +int L, I, T; +[L:= StrLen(S); +for I:= 0 to L/2-1 do + [T:= S(I); S(I):= S(L-I-1); S(L-I-1):= T]; +return S; +]; + +[Text(0, RevStr("a")); CrLf(0); + Text(0, RevStr("ab")); CrLf(0); + Text(0, RevStr("abc")); CrLf(0); + Text(0, RevStr("Able was I ere I saw Elba.")); CrLf(0); +] diff --git a/Task/Reverse-a-string/Yorick/reverse-a-string.yorick b/Task/Reverse-a-string/Yorick/reverse-a-string.yorick new file mode 100644 index 0000000000..477404db6c --- /dev/null +++ b/Task/Reverse-a-string/Yorick/reverse-a-string.yorick @@ -0,0 +1 @@ +strchar(strchar("asdf")(:-1)(::-1)) diff --git a/Task/Rock-paper-scissors/0DESCRIPTION b/Task/Rock-paper-scissors/0DESCRIPTION new file mode 100644 index 0000000000..36fa966c96 --- /dev/null +++ b/Task/Rock-paper-scissors/0DESCRIPTION @@ -0,0 +1,11 @@ +The task is to implement the classic children's game [[wp:Rock-paper-scissors|Rock-paper-scissors]], as well as a simple predictive AI player. + +Rock Paper Scissors is a two player game. Each player chooses one of rock, paper or scissors, without knowing the other player's choice. The winner is decided by a set of rules: + +* Rock beats scissors +* Scissors beat paper +* Paper beats rock. + +If both players choose the same thing, there is no winner for that round. + +For this task, the computer will be one of the players. The operator will select Rock, Paper or Scissors and the computer will keep a record of the choice frequency, and use that information to make a [[Probabilistic choice|weighted random choice]] in an attempt to defeat its opponent. diff --git a/Task/Rock-paper-scissors/1META.yaml b/Task/Rock-paper-scissors/1META.yaml new file mode 100644 index 0000000000..a2413d963b --- /dev/null +++ b/Task/Rock-paper-scissors/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Games diff --git a/Task/Rock-paper-scissors/Ada/rock-paper-scissors.ada b/Task/Rock-paper-scissors/Ada/rock-paper-scissors.ada new file mode 100644 index 0000000000..9b298bf4f3 --- /dev/null +++ b/Task/Rock-paper-scissors/Ada/rock-paper-scissors.ada @@ -0,0 +1,107 @@ +with Ada.Text_IO; with Ada.Numerics.Float_Random; + +procedure Rock_Paper_Scissors is + + package Rand renames Ada.Numerics.Float_Random; + Gen: Rand.Generator; + + type Choice is (Rock, Paper, Scissors); + + Cnt: array (Choice) of Natural := (1, 1, 1); + -- for the initialization: pretend that each of Rock, Paper, + -- and Scissors, has been played once by the human + -- else the first computer choice would be deterministic + + function Computer_Choice return Choice is + Random_Number: Natural := + Integer(Rand.Random(Gen) + * (Float(Cnt(Rock)) + Float(Cnt(Paper)) + Float(Cnt(Scissors)))); + begin + if Random_Number < Cnt(Rock) then + -- guess the human will choose Rock + return Paper; + elsif Random_Number - Cnt(Rock) < Cnt(Paper) then + -- guess the human will choose Paper + return Scissors; + else -- guess the human will choose Scissors + return Rock; + end if; + end Computer_Choice; + + Finish_The_Game: exception; + + function Human_Choice return Choice is + Done: Boolean := False; + T: constant String + := "enter ""r"" for Rock, ""p"" for Paper, or ""s"" for Scissors""!"; + U: constant String + := "or enter ""q"" to Quit the game"; + Result: Choice; + begin + Ada.Text_IO.Put_Line(T); + Ada.Text_IO.Put_Line(U); + while not Done loop + Done := True; + declare + S: String := Ada.Text_IO.Get_Line; + begin + if S="r" or S="R" then + Result := Rock; + elsif S="p" or S = "P" then + Result := Paper; + elsif S="s" or S="S" then + Result := Scissors; + elsif S="q" or S="Q" then + raise Finish_The_Game; + else + Done := False; + end if; + end; + end loop; + return Result; + end Human_Choice; + + type Result is (Human_Wins, Draw, Computer_Wins); + + function "<" (X, Y: Choice) return Boolean is + -- X < Y if X looses against Y + begin + case X is + when Rock => return (Y = Paper); + when Paper => return (Y = Scissors); + when Scissors => return (Y = Rock); + end case; + end "<"; + + Score: array(Result) of Natural := (0, 0, 0); + + C,H: Choice; + + Res: Result; + +begin + -- play the game + loop + C := Computer_Choice; -- the computer makes its choice first + H := Human_Choice; -- now ask the player for his/her choice + Cnt(H) := Cnt(H) + 1; -- update the counts for the AI + if C < H then + Res := Human_Wins; + elsif H < C then + Res := Computer_Wins; + else + Res := Draw; + end if; + Ada.Text_IO.Put_Line("COMPUTER'S CHOICE: " & Choice'Image(C) + & " RESULT: " & Result'Image(Res)); + Ada.Text_IO.New_Line; + Score(Res) := Score(Res) + 1; + end loop; + +exception + when Finish_The_Game => + Ada.Text_IO.New_Line; + for R in Score'Range loop + Ada.Text_IO.Put_Line(Result'Image(R) & Natural'Image(Score(R))); + end loop; +end Rock_Paper_Scissors; diff --git a/Task/Rock-paper-scissors/AutoHotkey/rock-paper-scissors.ahk b/Task/Rock-paper-scissors/AutoHotkey/rock-paper-scissors.ahk new file mode 100644 index 0000000000..7c170cfa7b --- /dev/null +++ b/Task/Rock-paper-scissors/AutoHotkey/rock-paper-scissors.ahk @@ -0,0 +1,46 @@ +#Warn +DllCall("AllocConsole") +Write("Welcome to Rock-Paper-Scissors`nMake a choice: ") + +cR := cP := cS := 0 ; user choice count +userChoice := Read() +Write("My choice: " . cpuChoice := MakeChoice(1, 1, 1)) + +Loop +{ + Write(DecideWinner(userChoice, cpuChoice) . "`nMake A Choice: ") + cR += SubStr(userChoice, 1, 1) = "r", cP += InStr(userChoice, "P"), cS += InStr(userChoice, "S") + userChoice := Read() + Write("My Choice: " . cpuChoice := MakeChoice(cR, cP, cS)) +} + +MakeChoice(cR, cP, cS){ + ; parameters are number of times user has chosen each item + total := cR + cP + cS + + Random, rand, 0.0, 1.0 + if (rand >= 0 and rand <= cR / total) + return "Paper" + else if (rand > cR / total and rand <= (cR + cP) / total) + return "Scissors" + else + return "Rock" +} + +DecideWinner(user, cpu){ + user := SubStr(user, 1, 1), cpu := SubStr(cpu, 1, 1) + if (user = cpu) + return "`nTie!" + else if (user = "r" and cpu = "s") or (user = "p" and cpu = "r") or (user = "s" and cpu = "p") + return "`nYou Win!" + else + return "`nI Win!" +} + +Read(){ + FileReadLine, a, CONIN$, 1 + return a +} +Write(txt){ + FileAppend, % txt, CONOUT$ +} diff --git a/Task/Rock-paper-scissors/AutoIt/rock-paper-scissors.autoit b/Task/Rock-paper-scissors/AutoIt/rock-paper-scissors.autoit new file mode 100644 index 0000000000..19e60241a2 --- /dev/null +++ b/Task/Rock-paper-scissors/AutoIt/rock-paper-scissors.autoit @@ -0,0 +1,92 @@ +RPS() + +Func RPS() + Local $ai_Played_games[4] + $ai_Played_games[0] = 3 + For $I = 1 To 3 + $ai_Played_games[$I] = 1 + Next + $RPS = GUICreate("Rock Paper Scissors", 338, 108, 292, 248) + $Rock = GUICtrlCreateButton("Rock", 8, 8, 113, 25, 131072) + $Paper = GUICtrlCreateButton("Paper", 8, 40, 113, 25, 131072) + $Scissors = GUICtrlCreateButton("Scissors", 8, 72, 113, 25, 131072) + $Label1 = GUICtrlCreateLabel("W:", 136, 8, 18, 17) + $Wins = GUICtrlCreateLabel("0", 160, 8, 36, 17) + $Label3 = GUICtrlCreateLabel("L:", 208, 8, 13, 17) + $Looses = GUICtrlCreateLabel("0", 224, 8, 36, 17) + $Label5 = GUICtrlCreateLabel("D:", 272, 8, 15, 17) + $Deuce = GUICtrlCreateLabel("0", 296, 8, 36, 17) + $Displaybutton = GUICtrlCreateButton("", 136, 48, 193, 49, 131072) + GUICtrlSetState($ai_Played_games, 128) + GUISetState(@SW_SHOW) + While 1 + $nMsg = GUIGetMsg() + Switch $nMsg + Case -3 + Exit + Case $Rock + $Ret = _RPS_Eval(1, $ai_Played_games) + GUICtrlSetData($Displaybutton, $Ret) + If $Ret = "Deuce" Then + GUICtrlSetData($Deuce, Guictrlread($Deuce)+1) + Elseif $Ret = "You Loose" Then + GUICtrlSetData($Looses, Guictrlread($Looses)+1) + Elseif $Ret = "You Win" Then + GUICtrlSetData($Wins, Guictrlread($Wins)+1) + EndIf + Case $Paper + $Ret = _RPS_Eval(2, $ai_Played_games) + GUICtrlSetData($Displaybutton, $Ret) + If $Ret = "Deuce" Then + GUICtrlSetData($Deuce, Guictrlread($Deuce)+1) + Elseif $Ret = "You Loose" Then + GUICtrlSetData($Looses, Guictrlread($Looses)+1) + Elseif $Ret = "You Win" Then + GUICtrlSetData($Wins, Guictrlread($Wins)+1) + EndIf + Case $Scissors + $Ret = _RPS_Eval(3, $ai_Played_games) + GUICtrlSetData($Displaybutton, $Ret) + If $Ret = "Deuce" Then + GUICtrlSetData($Deuce, Guictrlread($Deuce)+1) + Elseif $Ret = "You Loose" Then + GUICtrlSetData($Looses, Guictrlread($Looses)+1) + Elseif $Ret = "You Win" Then + GUICtrlSetData($Wins, Guictrlread($Wins)+1) + EndIf + EndSwitch + WEnd + +EndFunc ;==>RPS + +Func _RPS_Eval($i_Player_Choose, $ai_Played_games) + Local $i_choice = 1 + $i_rnd = Random(1, 1000, 1) + $i_choose_1 = ($ai_Played_games[1] / $ai_Played_games[0] * 1000) + $i_choose_2 = ($ai_Played_games[2] / $ai_Played_games[0] * 1000) + $i_choose_3 = ($ai_Played_games[3] / $ai_Played_games[0] * 1000) + If $i_rnd < $i_choose_1 Then + $i_choice = 2 + ElseIf $i_rnd < $i_choose_1 + $i_choose_2 And $i_rnd > $i_choose_1 Then + $i_choice = 3 + ElseIf $i_rnd < $i_choose_1 + $i_choose_2 + $i_choose_3 And $i_rnd > $i_choose_1 + $i_choose_2 Then + $i_choice = 1 + EndIf + $ai_Played_games[0] += 1 + If $i_Player_Choose = 1 Then + $ai_Played_games[1] += 1 + If $i_choice = 1 Then Return "Deuce" + If $i_choice = 2 Then Return "You Loose" + If $i_choice = 3 Then Return "You Win" + ElseIf $i_Player_Choose = 2 Then + $ai_Played_games[2] += 1 + If $i_choice = 2 Then Return "Deuce" + If $i_choice = 3 Then Return "You Loose" + If $i_choice = 1 Then Return "You Win" + ElseIf $i_Player_Choose = 3 Then + $ai_Played_games[3] += 1 + If $i_choice = 3 Then Return "Deuce" + If $i_choice = 1 Then Return "You Loose" + If $i_choice = 2 Then Return "You Win" + EndIf +EndFunc ;==>_RPS_Eval diff --git a/Task/Rock-paper-scissors/BASIC/rock-paper-scissors-1.basic b/Task/Rock-paper-scissors/BASIC/rock-paper-scissors-1.basic new file mode 100644 index 0000000000..e2f1580179 --- /dev/null +++ b/Task/Rock-paper-scissors/BASIC/rock-paper-scissors-1.basic @@ -0,0 +1,62 @@ +DIM pPLchoice(1 TO 3) AS INTEGER, pCMchoice(1 TO 3) AS INTEGER +DIM choices(1 TO 3) AS STRING +DIM playerwins(1 TO 3) AS INTEGER +DIM playerchoice AS INTEGER, compchoice AS INTEGER +DIM playerwon AS INTEGER, compwon AS INTEGER, tie AS INTEGER +DIM tmp AS INTEGER + +' Do it this way for QBasic; FreeBASIC supports direct array assignment. +DATA "rock", "paper", "scissors" +FOR tmp = 1 to 3 + READ choices(tmp) +NEXT +DATA 3, 1, 2 +FOR tmp = 1 to 3 + READ playerwins(tmp) +NEXT + +RANDOMIZE TIMER + +DO + ' Computer chooses first to ensure there's no "cheating". + compchoice = INT(RND * (pPLchoice(1) + pPLchoice(2) + pPLchoice(3) + 3)) + SELECT CASE compchoice + CASE 0 to (pPLchoice(1)) + ' Player past choice: rock; choose paper. + compchoice = 2 + CASE (pPLchoice(1) + 1) TO (pPLchoice(1) + pPLchoice(2) + 1) + ' Player past choice: paper; choose scissors. + compchoice = 3 + CASE (pPLchoice(1) + pPLchoice(2) + 2) TO (pPLchoice(1) + pPLchoice(2) + pPLchoice(3) + 2) + ' Player past choice: scissors; choose rock. + compchoice = 1 + END SELECT + + PRINT "Rock, paper, or scissors "; + DO + PRINT "[1 = rock, 2 = paper, 3 = scissors, 0 to quit]"; + INPUT playerchoice + LOOP WHILE (playerchoice < 0) OR (playerchoice > 3) + + IF 0 = playerchoice THEN EXIT DO + + pCMchoice(compchoice) = pCMchoice(compchoice) + 1 + pPLchoice(playerchoice) = pPLchoice(playerchoice) + 1 + PRINT "You chose "; choices(playerchoice); " and I chose "; choices(compchoice); ". "; + IF (playerchoice) = compchoice THEN + PRINT "Tie!" + tie = tie + 1 + ELSEIF (compchoice) = playerwins(playerchoice) THEN + PRINT "You won!" + playerwon = playerwon + 1 + ELSE + PRINT "I won!" + compwon = compwon + 1 + END IF +LOOP + +PRINT "Some useless statistics:" +PRINT "You won "; STR$(playerwon); " times, and I won "; STR$(compwon); " times; "; STR$(tie); " ties." +PRINT , choices(1), choices(2), choices(3) +PRINT "You chose:", pPLchoice(1), pPLchoice(2), pPLchoice(3) +PRINT " I chose:", pCMchoice(1), pCMchoice(2), pCMchoice(3) diff --git a/Task/Rock-paper-scissors/BASIC/rock-paper-scissors-2.basic b/Task/Rock-paper-scissors/BASIC/rock-paper-scissors-2.basic new file mode 100644 index 0000000000..09750db1ba --- /dev/null +++ b/Task/Rock-paper-scissors/BASIC/rock-paper-scissors-2.basic @@ -0,0 +1,16 @@ + 20 LET P=0: LET Q=0: LET Z=0 + 30 INPUT "Rock, paper, or scissors (1 = rock, 2 = paper, 3 = scissors)? ", A + 40 IF A>3 THEN GOTO 400 + 50 IF A=3 THEN LET A=4 + 60 IF A<1 THEN GOTO 400 + 70 CHOOSE C=3 : LET D=4: FOR B=1 TO C+1 : LET D = D+D : NEXT : GOTO (A+D)*10 + 90 Z=Z+1 : PRINT "We both chose 'rock'. It's a draw." : GOTO 30 +100 P=P+1 : PRINT "You chose 'paper', I chose 'rock'. You win.." : GOTO 30 +120 Q=Q+1 : PRINT "You chose 'scissors', I chose 'rock'. I win!" : GOTO 30 +170 Q=Q+1 : PRINT "You chose 'rock', I chose 'paper'. I win!" : GOTO 30 +180 Z=Z+1 : PRINT "We both chose 'paper'. It's a draw." : GOTO 30 +200 P=P+1 : PRINT "You chose 'scissors', I chose 'paper'. You win.." : GOTO 30 +330 P=P+1 : PRINT "You chose 'rock', I chose 'scissors'. You win.." : GOTO 30 +340 Q=Q+1 : PRINT "You chose 'paper', I chose 'scissors'. I win!" : GOTO 30 +360 Z=Z+1 : PRINT "We both chose 'scissors'. It's a draw." : GOTO 30 +400 PRINT "There were ";Z;" draws. I lost ";P;" times, you lost ";Q;" times." : END diff --git a/Task/Rock-paper-scissors/BBC-BASIC/rock-paper-scissors.bbc b/Task/Rock-paper-scissors/BBC-BASIC/rock-paper-scissors.bbc new file mode 100644 index 0000000000..f02c5fe455 --- /dev/null +++ b/Task/Rock-paper-scissors/BBC-BASIC/rock-paper-scissors.bbc @@ -0,0 +1,46 @@ +PRINT"Welcome to the game of rock-paper-scissors" +PRINT "Each player guesses one of these three, and reveals it at the same time." +PRINT "Rock blunts scissors, which cut paper, which wraps stone." +PRINT "If both players choose the same, it is a draw!" +PRINT "When you've had enough, choose Q." +DIM rps%(2),g$(3) +g$()="rock","paper","scissors" +total%=0 +draw%=0 +pwin%=0 +cwin%=0 +c%=RND(3) +PRINT"What is your move (press R, P, or S)?" +REPEAT + REPEAT q$=GET$ UNTIL INSTR("RPSrpsQq",q$)>0 + g%=(INSTR("RrPpSsQq",q$)-1) DIV 2 + IF g%>2 THEN PROCsummarise:END + total%+=1 + rps%(g%)+=1 + PRINT"You chose ";g$(g%);" and I chose ";g$(c%); + CASE g%-c% OF + WHEN 0: + PRINT ". It's a draw" + draw%+=1 + WHEN 1,-2: + PRINT ". You win!" + pwin%+=1 + WHEN -1,2: + PRINT ". I win!" + cwin%+=1 + ENDCASE + c%=FNmove(rps%(),total%) +UNTIL FALSE +END +: +DEFPROCsummarise +PRINT "You won ";pwin%;", and I won ";cwin%;". There were ";draw%;" draws" +PRINT "Thanks for playing!" +ENDPROC +: +DEFFNmove(p%(),t%) +LOCAL r% +r%=RND(total%) +IF r%<=p%(0) THEN =1 +IF r%<=p%(0)+p%(1) THEN =2 +=0 diff --git a/Task/Rock-paper-scissors/C++/rock-paper-scissors.cpp b/Task/Rock-paper-scissors/C++/rock-paper-scissors.cpp new file mode 100644 index 0000000000..d51bdcb61e --- /dev/null +++ b/Task/Rock-paper-scissors/C++/rock-paper-scissors.cpp @@ -0,0 +1,179 @@ +#include +#include +#include + +//------------------------------------------------------------------------------- +using namespace std; + +//------------------------------------------------------------------------------- +enum choices { ROCK, PAPER, SCISSORS }; +enum indexes { PLAYER, COMPUTER, DRAW }; + +//------------------------------------------------------------------------------- +class stats +{ +public: + stats() : _draw( 0 ) + { + ZeroMemory( _moves, sizeof( _moves ) ); + ZeroMemory( _win, sizeof( _win ) ); + } + void draw() { _draw++; } + void win( int p ) { _win[p]++; } + void move( int p, int m ) { _moves[p][m]++; } + int getMove( int p, int m ) { return _moves[p][m]; } + void print() + { + char t[256]; + wsprintf( t, "%.4d", _draw ); string d( t ); + + wsprintf( t, "%.4d", _win[PLAYER] ); string pw( t ); + wsprintf( t, "%.4d", _moves[PLAYER][ROCK] ); string pr( t ); + wsprintf( t, "%.4d", _moves[PLAYER][PAPER] ); string pp( t ); + wsprintf( t, "%.4d", _moves[PLAYER][SCISSORS] ); string ps( t ); + + wsprintf( t, "%.4d", _win[COMPUTER] ); string cw( t ); + wsprintf( t, "%.4d", _moves[COMPUTER][ROCK] ); string cr( t ); + wsprintf( t, "%.4d", _moves[COMPUTER][PAPER] ); string cp( t ); + wsprintf( t, "%.4d", _moves[COMPUTER][SCISSORS] ); string cs( t ); + + system( "cls" ); + cout << endl; + cout << "+--------------+----------+----------+----------+----------+----------+" << endl; + cout << "| | WON | DRAW | ROCK | PAPER | SCISSORS |" << endl; + cout << "+--------------+----------+----------+----------+----------+----------+" << endl; + cout << "| PLAYER | " << pw << " | | " << pr; + cout << " | " << pp << " | " << ps << " |" << endl; + cout << "+--------------+----------+ " << d << " +----------+----------+----------+" << endl; + cout << "| COMPUTER | " << cw << " | | " << cr; + cout << " | " << cp << " | " << cs << " |" << endl; + cout << "+--------------+----------+----------+----------+----------+----------+" << endl; + cout << endl << endl; + + system( "pause" ); + + } + +private: + int _moves[2][3], _win[2], _draw; +}; +//------------------------------------------------------------------------------- +class rps +{ +private: + int makeMove() + { + int total = 0, r, s; + for( int i = 0; i < 3; total += statistics.getMove( PLAYER, i++ ) ); + r = rand() % total; + s = statistics.getMove( PLAYER, ROCK ); + if( r < s ) return PAPER; + if( r - s < statistics.getMove( PLAYER, PAPER ) ) return SCISSORS; + return ROCK; + } + + int checkWinner( int p, int m ) + { + if( p == ROCK ) + { + switch( m ) + { + case PAPER: return COMPUTER; + case SCISSORS: return PLAYER; + default: return DRAW; + } + } + if( p == PAPER ) + { + switch( m ) + { + case SCISSORS: return COMPUTER; + case ROCK: return PLAYER; + default: return DRAW; + } + } + if( p == SCISSORS ) + { + switch( m ) + { + case ROCK: return COMPUTER; + case PAPER: return PLAYER; + default: return DRAW; + } + } + return DRAW; + } + + void printMove( int p, int m ) + { + string ms = ""; + switch( m ) + { + case 0: ms = "ROCK"; break; + case 1: ms = "PAPER"; break; + case 2: ms = "SCISSORS"; break; + } + + if( p == COMPUTER ) cout << "My move: "; + else cout << "Your move: "; + cout << ms << endl; + } + +public: + void play() + { + int p, r, m; + while( true ) + { + cout << "What is your move (1)ROCK (2)PAPER (3)SCISSORS (0)Quit ? "; + cin >> p; + if( !p || p < 0 ) break; + if( p > 0 && p < 4 ) + { + p--; + cout << endl; + printMove( PLAYER, p ); + statistics.move( PLAYER, p ); + + m = makeMove(); + statistics.move( COMPUTER, m ); + printMove( COMPUTER, m ); + + r = checkWinner( p, m ); + switch( r ) + { + case DRAW: + cout << endl << "DRAW!" << endl << endl; + statistics.draw(); + + break; + case COMPUTER: + cout << endl << "I WIN!" << endl << endl; + statistics.win( COMPUTER ); + + break; + case PLAYER: + cout << endl << "YOU WIN!" << endl << endl; + statistics.win( PLAYER ); + + } + system( "pause" ); + } + system( "cls" ); + } + + statistics.print(); + } + +private: + stats statistics; +}; +//------------------------------------------------------------------------------- +int main( int argc, char* argv[] ) +{ + srand( GetTickCount() ); + rps game; + game.play(); + return 0; +} +//------------------------------------------------------------------------------- diff --git a/Task/Rock-paper-scissors/C/rock-paper-scissors-1.c b/Task/Rock-paper-scissors/C/rock-paper-scissors-1.c new file mode 100644 index 0000000000..13cc3716b7 --- /dev/null +++ b/Task/Rock-paper-scissors/C/rock-paper-scissors-1.c @@ -0,0 +1,54 @@ +#include +#include + +int rand_i(int n) +{ + int rand_max = RAND_MAX - (RAND_MAX % n); + int ret; + while ((ret = rand()) >= rand_max); + return ret/(rand_max / n); +} + +int weighed_rand(int *tbl, int len) +{ + int i, sum, r; + for (i = 0, sum = 0; i < len; sum += tbl[i++]); + if (!sum) return rand_i(len); + + r = rand_i(sum) + 1; + for (i = 0; i < len && (r -= tbl[i]) > 0; i++); + return i; +} + +int main() +{ + int user_action, my_action; + int user_rec[] = {0, 0, 0}; + const char *names[] = { "Rock", "Paper", "Scissors" }; + char str[2]; + const char *winner[] = { "We tied.", "Meself winned.", "You win." }; + + while (1) { + my_action = (weighed_rand(user_rec, 3) + 1) % 3; + + printf("\nYour choice [1-3]:\n" + " 1. Rock\n 2. Paper\n 3. Scissors\n> "); + + /* scanf is a terrible way to do input. should use stty and keystrokes */ + if (!scanf("%d", &user_action)) { + scanf("%1s", str); + if (*str == 'q') return 0; + continue; + } + user_action --; + if (user_action > 2 || user_action < 0) { + printf("invalid choice; again\n"); + continue; + } + printf("You chose %s; I chose %s. %s\n", + names[user_action], names[my_action], + winner[(my_action - user_action + 3) % 3]); + + user_rec[user_action]++; + } +} diff --git a/Task/Rock-paper-scissors/C/rock-paper-scissors-2.c b/Task/Rock-paper-scissors/C/rock-paper-scissors-2.c new file mode 100644 index 0000000000..2bf96d2b96 --- /dev/null +++ b/Task/Rock-paper-scissors/C/rock-paper-scissors-2.c @@ -0,0 +1,28 @@ +#include // Standard IO +#include // other stuff +#include +#include +int main(int argc, const char *argv[]){ + printf("Hello, Welcome to rock-paper-scissors\nBy The Elite Noob\n"); + while(1){ // infinite loop :) + printf("\n\nPlease type in 1 for Rock, 2 For Paper, 3 for Scissors, 4 to quit\n"); + srand(time(NULL)); + int user, comp = (rand()%3)+1; + char line[255]; + fgets(line, sizeof(line), stdin); + while(sscanf(line, "%d", &user) != 1) { //1 match of defined specifier on input line + printf("You have not entered an integer.\n"); + fgets(line, sizeof(line), stdin); + } + if(user != 1 && user != 2 && user != 3 && user != 4){printf("Please enter a valid number!\n");continue;} + char umove[10], cmove[10]; + if(comp == 1){strcpy(cmove, "Rock");}else if(comp == 2){strcpy(cmove, "Paper");}else{strcpy(cmove, "Scissors");} + if(user == 1){strcpy(umove, "Rock");}else if(user == 2){strcpy(umove, "Paper");}else{strcpy(umove, "Scissors");} + if(user == 4){printf("Goodbye! Thanks for playing!\n");break;} + if((comp == 1 && user == 3)||(comp == 2 && user == 1)||(comp == 3 && user == 2)){ + printf("Comp Played: %s\nYou Played: %s\nSorry, You Lost!\n", cmove, umove); + }else if(comp == user){ + printf("Comp Played: %s\nYou Played: %s\nYou Tied :p\n", cmove, umove);} + else{ + printf("Comp Played: %s\nYou Played: %s\nYay, You Won!\n", cmove, umove); + }}return 1;} diff --git a/Task/Rock-paper-scissors/D/rock-paper-scissors.d b/Task/Rock-paper-scissors/D/rock-paper-scissors.d new file mode 100644 index 0000000000..f0bccabaf5 --- /dev/null +++ b/Task/Rock-paper-scissors/D/rock-paper-scissors.d @@ -0,0 +1,55 @@ +import std.stdio, std.random, std.string, std.array; + +enum string[] order = ["rock", "paper", "scissors"]; +int[string] choiceFrequency; // mutable + +immutable(string[string]) whatBeats; +nothrow pure static this() { + whatBeats = ["paper": "scissors", + "scissors": "rock", + "rock": "paper"]; +} + +string checkWinner(in string a, in string b) pure nothrow { + if (b == whatBeats[a]) + return b; + else if (a == whatBeats[b]) + return a; + return ""; +} + +string getRandomChoice() /*nothrow*/ { + //if (choiceFrequency.empty) + if (choiceFrequency.length == 0) + return order[uniform(0, $)]; + const choices = choiceFrequency.keys; + const probabilities = choiceFrequency.values; + return whatBeats[choices[dice(probabilities)]]; +} + +void main() { + writeln("Rock-paper-scissors game"); + while (true) { + write("Your choice: "); + immutable string humanChoice = readln().strip().toLower(); + if (humanChoice.empty) + break; + if (humanChoice !in whatBeats) { + writeln("Wrong input: ", humanChoice); + continue; + } + + immutable compChoice = getRandomChoice(); + write("Computer picked ", compChoice, ", "); + + // Don't register the player choice until after + // the computer has made its choice. + choiceFrequency[humanChoice]++; + + immutable winner = checkWinner(humanChoice, compChoice); + if (winner.empty) + writeln("nobody wins!"); + else + writeln(winner, " wins!"); + } +} diff --git a/Task/Rock-paper-scissors/Erlang/rock-paper-scissors.erl b/Task/Rock-paper-scissors/Erlang/rock-paper-scissors.erl new file mode 100644 index 0000000000..15cd46b09a --- /dev/null +++ b/Task/Rock-paper-scissors/Erlang/rock-paper-scissors.erl @@ -0,0 +1,46 @@ +-module(rps). +-compile(export_all). + +play() -> + loop([1,1,1]). + +loop([R,P,S]=Odds) -> + case io:fread("What is your move? (R,P,S,Q) ","~c") of + {ok,["Q"]} -> io:fwrite("Good bye!~n"); + {ok,[[Human]]} when Human == $R; Human == $P; Human == $S -> + io:fwrite("Your move is ~s.~n", + [play_to_string(Human)]), + Computer = select_play(Odds), + io:fwrite("My move is ~s~n", + [play_to_string(Computer)]), + case {beats(Human,Computer),beats(Computer,Human)} of + {true,_} -> io:fwrite("You win!~n"); + {_,true} -> io:fwrite("I win!~n"); + _ -> io:fwrite("Draw~n") + end, + case Human of + $R -> loop([R+1,P,S]); + $P -> loop([R,P+1,S]); + $S -> loop([R,P,S+1]) + end; + _ -> + io:fwrite("Invalid play~n"), + loop(Odds) + end. + +beats($R,$S) -> true; +beats($P,$R) -> true; +beats($S,$P) -> true; +beats(_,_) -> false. + +play_to_string($R) -> "Rock"; +play_to_string($P) -> "Paper"; +play_to_string($S) -> "Scissors". + +select_play([R,P,S]) -> + N = random:uniform(R+P+S), + if + N =< R -> $P; + N =< R+P -> $S; + true -> $R + end. diff --git a/Task/Rock-paper-scissors/Euphoria/rock-paper-scissors.euphoria b/Task/Rock-paper-scissors/Euphoria/rock-paper-scissors.euphoria new file mode 100644 index 0000000000..2357a87811 --- /dev/null +++ b/Task/Rock-paper-scissors/Euphoria/rock-paper-scissors.euphoria @@ -0,0 +1,50 @@ +function weighted_rand(sequence table) + integer sum,r + sum = 0 + for i = 1 to length(table) do + sum += table[i] + end for + + r = rand(sum) + for i = 1 to length(table)-1 do + r -= table[i] + if r <= 0 then + return i + end if + end for + return length(table) +end function + +constant names = { "Rock", "Paper", "Scissors" } +constant winner = { "We tied.", "Meself winned.", "You win." } +integer user_action, my_action, key, win +sequence user_rec, score +user_rec = {1,1,1} +score = {0,0} + +while 1 do + my_action = remainder(weighted_rand(user_rec)+1,3)+1 + puts(1,"Your choice [1-3]:\n") + puts(1," 1. Rock\n 2. Paper\n 3. Scissors\n> ") + key = -1 + while (key < '1' or key > '3') and key != 'q' do + key = get_key() + end while + puts(1,key) + puts(1,'\n') + if key = 'q' then + exit + end if + user_action = key-'0' + win = remainder(my_action-user_action+3,3) + printf(1,"You chose %s; I chose %s. %s\n", + { names[user_action], + names[my_action], + winner[win+1] }) + + if win then + score[win] += 1 + end if + printf(1,"\nScore %d:%d\n",score) + user_rec[user_action] += 1 +end while diff --git a/Task/Rock-paper-scissors/Go/rock-paper-scissors.go b/Task/Rock-paper-scissors/Go/rock-paper-scissors.go new file mode 100644 index 0000000000..72124a7d9d --- /dev/null +++ b/Task/Rock-paper-scissors/Go/rock-paper-scissors.go @@ -0,0 +1,69 @@ +package main + +import ( + "fmt" + "math/rand" + "strings" + "time" +) + +const rps = "rps" + +var msg = []string{ + "Rock breaks scissors", + "Paper covers rock", + "Scissors cut paper", +} + +func main() { + rand.Seed(time.Now().UnixNano()) + fmt.Println("Rock Paper Scissors") + fmt.Println("Enter r, p, or s as your play. Anything else ends the game.") + fmt.Println("Running score shown as :") + var pi string // player input + var aScore, pScore int + sl := 3 // for output alignment + pcf := make([]int, 3) // pcf = player choice frequency + var plays int + aChoice := rand.Intn(3) // ai choice for first play is completely random + for { + // get player choice + fmt.Print("Play: ") + _, err := fmt.Scanln(&pi) // lazy + if err != nil || len(pi) != 1 { + break + } + pChoice := strings.Index(rps, pi) + if pChoice < 0 { + break + } + pcf[pChoice]++ + plays++ + + // show result of play + fmt.Printf("My play:%s%c. ", strings.Repeat(" ", sl-2), rps[aChoice]) + switch (aChoice - pChoice + 3) % 3 { + case 0: + fmt.Println("Tie.") + case 1: + fmt.Printf("%s. My point.\n", msg[aChoice]) + aScore++ + case 2: + fmt.Printf("%s. Your point.\n", msg[pChoice]) + pScore++ + } + + // show score + sl, _ = fmt.Printf("%d:%d ", pScore, aScore) + + // compute ai choice for next play + switch rn := rand.Intn(plays); { + case rn < pcf[0]: + aChoice = 1 + case rn < pcf[0]+pcf[1]: + aChoice = 2 + default: + aChoice = 0 + } + } +} diff --git a/Task/Rock-paper-scissors/Haskell/rock-paper-scissors.hs b/Task/Rock-paper-scissors/Haskell/rock-paper-scissors.hs new file mode 100644 index 0000000000..ff9f58ae87 --- /dev/null +++ b/Task/Rock-paper-scissors/Haskell/rock-paper-scissors.hs @@ -0,0 +1,36 @@ +import System.Random + +data Choice = Rock | Paper | Scissors + deriving (Show, Eq) + + +beats Paper Rock = True +beats Scissors Paper = True +beats Rock Scissors = True +beats _ _ = False + +genrps (r,p,s) = fmap rps rand + where rps x | x <= s = Rock + | x <= s+r = Paper + | otherwise = Scissors + rand = randomRIO (1,r+p+s) :: IO Int + +getrps = fmap rps getLine + where rps "scissors" = Scissors + rps "rock" = Rock + rps "paper" = Paper + rps _ = error "invalid input" + +game (r,p,s) = do putStrLn "rock, paper or scissors?" + h <- getrps + c <- genrps (r,p,s) + putStrLn ("Player: " ++ show h ++ " Computer: " ++ show c) + putStrLn (if beats h c then "player wins\n" + else if beats c h then "player loses\n" + else "draw\n") + let rr = if h == Rock then r+1 else r + pp = if h == Paper then p+1 else p + ss = if h == Scissors then s+1 else s + game (rr,pp,ss) + +main = game (1,1,1) diff --git a/Task/Rock-paper-scissors/Icon/rock-paper-scissors.icon b/Task/Rock-paper-scissors/Icon/rock-paper-scissors.icon new file mode 100644 index 0000000000..5355dc9516 --- /dev/null +++ b/Task/Rock-paper-scissors/Icon/rock-paper-scissors.icon @@ -0,0 +1,41 @@ +link printf + +procedure main() + +printf("Welcome to Rock, Paper, Scissors.\n_ + Rock beats scissors, Scissors beat paper, and Paper beats rock.\n\n") + +historyP := ["rock","paper","scissors"] # seed player history +winP := winC := draws := 0 # totals + +beats := ["rock","scissors","paper","rock"] # what beats what 1 apart + +repeat { + printf("Enter your choice or rock(r), paper(p), scissors(s) or quit(q):") + turnP := case map(read()) of { + "q"|"quit": break + "r"|"rock": "rock" + "p"|"paper": "paper" + "s"|"scissors": "scissors" + default: printf(" - invalid choice.\n") & next + } + + turnC := beats[(?historyP == beats[i := 2 to *beats],i-1)] # choose move + + put(historyP,turnP) # record history + printf("You chose %s, computer chose %s",turnP,turnC) + + (beats[p := 1 to *beats] == turnP) & + (beats[c := 1 to *beats] == turnC) & (abs(p-c) <= 1) # rank play + + if p = c then + printf(" - draw (#%d)\n",draws +:= 1 ) + else if p > c then + printf(" - player win(#%d)\n",winP +:= 1) + else + printf(" - computer win(#%d)\n",winC +:= 1) + } + +printf("\nResults:\n %d rounds\n %d Draws\n %d Computer wins\n %d Player wins\n", + winP+winC+draws,draws,winC,winP) +end diff --git a/Task/Rock-paper-scissors/J/rock-paper-scissors-1.j b/Task/Rock-paper-scissors/J/rock-paper-scissors-1.j new file mode 100644 index 0000000000..04b4416aa4 --- /dev/null +++ b/Task/Rock-paper-scissors/J/rock-paper-scissors-1.j @@ -0,0 +1,19 @@ +require'misc strings' +game=:3 :0 + outcomes=. rps=. 0 0 0 + choice=. 1+?3 + while.#response=. prompt' Choose Rock, Paper or Scissors: ' do. + playerchoice=. 1+'rps' i. tolower {.deb response + if.4 = playerchoice do. + smoutput 'Unknown response.' + smoutput 'Enter an empty line to quit' + continue. + end. + smoutput ' I choose ',choice {::;:'. Rock Paper Scissors' + smoutput (wintype=. 3 | choice-playerchoice) {:: 'Draw';'I win';'You win' + outcomes=. outcomes+0 1 2 = wintype + rps=. rps+1 2 3=playerchoice + choice=. 1+3|(?0) I.~ (}:%{:)+/\ 0, rps + end. + ('Draws:','My wins:',:'Your wins: '),.":,.outcomes +) diff --git a/Task/Rock-paper-scissors/J/rock-paper-scissors-2.j b/Task/Rock-paper-scissors/J/rock-paper-scissors-2.j new file mode 100644 index 0000000000..1879e1a67d --- /dev/null +++ b/Task/Rock-paper-scissors/J/rock-paper-scissors-2.j @@ -0,0 +1,20 @@ + game'' + Choose Rock, Paper or Scissors: rock + I choose Scissors +You win + Choose Rock, Paper or Scissors: rock + I choose Paper +I win + Choose Rock, Paper or Scissors: rock + I choose Paper +I win + Choose Rock, Paper or Scissors: rock + I choose Paper +I win + Choose Rock, Paper or Scissors: rock + I choose Paper +I win + Choose Rock, Paper or Scissors: +Draws: 0 +My wins: 4 +Your wins: 1 diff --git a/Task/Rock-paper-scissors/Java/rock-paper-scissors.java b/Task/Rock-paper-scissors/Java/rock-paper-scissors.java new file mode 100644 index 0000000000..9195b0965d --- /dev/null +++ b/Task/Rock-paper-scissors/Java/rock-paper-scissors.java @@ -0,0 +1,79 @@ +import java.util.Arrays; +import java.util.EnumMap; +import java.util.List; +import java.util.Map; +import java.util.Scanner; +import java.util.Random; + +public class RPS { + public enum Item{ + ROCK, PAPER, SCISSORS, /*LIZARD, SPOCK*/; + public List losesToList; + public boolean losesTo(Item other) { + return losesToList.contains(other); + } + static { + SCISSORS.losesToList = Arrays.asList(ROCK/*, SPOCK*/); + ROCK.losesToList = Arrays.asList(PAPER/*, SPOCK*/); + PAPER.losesToList = Arrays.asList(SCISSORS/*, LIZARD*/); + /* + SPOCK.losesToList = Arrays.asList(PAPER, LIZARD); + LIZARD.losesToList = Arrays.asList(SCISSORS, ROCK); + */ + } + } + //EnumMap uses a simple array under the hood + public final Map counts = new EnumMap(Item.class){{ + for(Item item:Item.values()) + put(item, 1); + }}; + + private int totalThrows = Item.values().length; + + public static void main(String[] args){ + RPS rps = new RPS(); + rps.run(); + } + + public void run() { + Scanner in = new Scanner(System.in); + System.out.print("Make your choice: "); + while(in.hasNextLine()){ + Item aiChoice = getAIChoice(); + String input = in.nextLine(); + Item choice; + try{ + choice = Item.valueOf(input.toUpperCase()); + }catch (IllegalArgumentException ex){ + System.out.println("Invalid choice"); + continue; + } + counts.put(choice, counts.get(choice) + 1); + totalThrows++; + System.out.println("Computer chose: " + aiChoice); + if(aiChoice == choice){ + System.out.println("Tie!"); + }else if(aiChoice.losesTo(choice)){ + System.out.println("You chose...wisely. You win!"); + }else{ + System.out.println("You chose...poorly. You lose!"); + } + System.out.print("Make your choice: "); + } + } + + private static final Random rng = new Random(); + private Item getAIChoice() { + int rand = rng.nextInt(totalThrows); + for(Map.Entry entry:counts.entrySet()){ + Item item = entry.getKey(); + int count = entry.getValue(); + if(rand < count){ + List losesTo = item.losesToList; + return losesTo.get(rng.nextInt(losesTo.size())); + } + rand -= count; + } + return null; + } +} diff --git a/Task/Rock-paper-scissors/Julia/rock-paper-scissors.julia b/Task/Rock-paper-scissors/Julia/rock-paper-scissors.julia new file mode 100644 index 0000000000..7cecadd079 --- /dev/null +++ b/Task/Rock-paper-scissors/Julia/rock-paper-scissors.julia @@ -0,0 +1,23 @@ +function rps() + print("Welcome to Rock, paper, scissors! Go ahead and type your pick.\n + r(ock), p(aper), or s(cissors)\n + Enter 'q' to quit.\n>") + comp_score = 0 + user_score = 0 + options = ["r","p","s"] + new_pick() = options[rand(1:3)] + i_win(m,y) = ((m == "r" && y == "s")|(m == "s" && y == "p")|(m == "p" && y == "r")) + while true + input = string(readline(STDIN)[1]) + input == "q" && break + !ismatch(r"^[rps]",input) && begin print("Invalid guess: Please enter 'r', 'p', or 's'\n"); continue end + answer = new_pick() + if input == answer + print("\nTie!\nScore still: \nyou $user_score\nme $comp_score\n>") + continue + else + i_win(answer,input) ? (comp_score += 1) : (user_score += 1) + print(i_win(answer,input) ? "\nSorry you lose!\n" : "\nYou win!","Score: \nyou $user_score\nme $comp_score\n>") + end + end +end diff --git a/Task/Rock-paper-scissors/Liberty-BASIC/rock-paper-scissors.liberty b/Task/Rock-paper-scissors/Liberty-BASIC/rock-paper-scissors.liberty new file mode 100644 index 0000000000..37184e926e --- /dev/null +++ b/Task/Rock-paper-scissors/Liberty-BASIC/rock-paper-scissors.liberty @@ -0,0 +1,88 @@ +dim rps( 2), g$( 3) + +g$( 0) ="rock": g$( 1) ="paper": g$( 2) ="scissors" +global total + +total =0: draw =0: pwin =0: cwin =0 + +rps( 0) =1: rps( 1) =1: rps( 2) =1 ' at first computer will play all three with equal probability + +c =int( 3 *rnd( 1)) ' first time, computer response is random + +' In the following code we set three integer %ages for the 's biassed throws. + ' set up the player's key frequencies as %ages. + ' Done like this it's easy to mimic the input of q$ + ' It allows only integer %age frequency- not an important thing. +rockP =45 ' <<<<<<<<< Set here the 's %age of 'rock' choices. +for i =1 to rockP: qF$ =qF$ +"R": next i + +paprP =24 ' <<<<<<<<< Set here the %age of 'paper' choices. +for i =1 to paprP: qF$ =qF$ +"P": next i + +scisP =100 -rockP -paprP ' <<<<<<<<< %age 'scissors' calculated to make 100% +for i =1 to scisP: qF$ =qF$ +"S": next i +'print qF$ + +do + 'do: input q$:loop until instr( "RPSrpsQq", q$) ' for actual human input... possibly biassed. <<<<<<<<<<<<< REM one or the other line... + q$ =mid$( qF$, int( 100 *rnd( 1)), 1) ' simulated input with controlled bias. <<<<<<<<<<<<< + + if total >10000 then q$ ="Q" + + g =int( ( instr( "RrPpSsQq", q$) -1) / 2) + if g >2 then [endGame] + + total =total +1 + rps( g) =rps( g) +1 ' accumulate plays the has chosen. ( & hence their (biassed?) frequencies.) + 'print " You chose "; g$( g); " and I chose "; g$( c); ". " + + select case g -c + case 0 + draw =draw +1 ':print "It's a draw" + case 1, -2 + pwin =pwin +1 ':print "You win!" + case -1, 2 + cwin =cwin +1 ':print "I win!" + end select + + r =int( total *rnd( 1)) ' Now select computer's choice for next confrontation. + select case ' Using the accumulating data about 's frequencies so far. + case r <=rps( 0) + c =1 + case r <=( rps( 0) +rps( 1)) + c =2 + case else + c =0 + end select + + scan +loop until 0 + +[endGame] + print + print " You won "; pwin; ", and I won "; cwin; ". There were "; draw; " draws." + if cwin >pwin then print " I AM THE CHAMPION!!" else print " You won this time." + print + print " At first I assumed you'd throw each equally often." + print " This means I'd win 1 time in 3; draw 1 in 3; lose 1 in 3." + print " However if I detect a bias in your throws,...." + print " ....this allows me to anticipate your most likely throw & on average beat it." + print + print " In fact, keyboard layout & human frailty mean even if you TRY to be even & random..." + print " ... you may be typing replies with large bias. In 100 tries I gave 48 'P's, 29 'R' & 23 'S'!" + print + print " This time I played.." + print " Rock "; using( "##.##", rps( 2)* 100 /total); "% Paper "; using( "##.##", rps( 0) *100 /total); "% Scissors "; using( "##.##", rps( 1) *100 /total); "%." + print + print " ( PS. I have since learned your actual bias had been.." + print " Rock "; using( "##.##", rockP); "% Paper "; using( "##.##", paprP ); "% Scissors "; using( "##.##", ( 100 -rockP -paprP)); "%.)" + print + print " The advantage I can gain gets bigger the further the 'human' entries are biassed." + print " The results statistically smooth out better with large runs." + print " Try 10,000,000, & have a cuppa while you wait." + print + print " Can you see what will happen if, say, the 'human' is set to give 'Rock' EVERY time?" + print " Try different %ages by altering the marked code lines." + print + print " Thanks for playing!" + end diff --git a/Task/Rock-paper-scissors/Locomotive-Basic/rock-paper-scissors.locomotive b/Task/Rock-paper-scissors/Locomotive-Basic/rock-paper-scissors.locomotive new file mode 100644 index 0000000000..defa5adf61 --- /dev/null +++ b/Task/Rock-paper-scissors/Locomotive-Basic/rock-paper-scissors.locomotive @@ -0,0 +1,23 @@ +10 mode 1:defint a-z:randomize time +20 rps$="rps" +30 msg$(1)="Rock breaks scissors" +40 msg$(2)="Paper covers rock" +50 msg$(3)="Scissors cut paper" +60 print "Rock Paper Scissors":print +70 print "Enter r, p, or s as your play." +80 print "Running score shown as :" +90 achoice=rnd*2.99+.5 ' get integer between 1 and 3 from real between .5 and <3.5 +100 ' get key +110 pin$=inkey$ +120 if pin$="" then 110 +130 pchoice=instr(rps$,pin$) +140 if pchoice=0 then print "Sorry?":goto 110 +150 pcf(pchoice)=pcf(pchoice)+1 +160 plays=plays+1 +170 print "My play: "mid$(rps$,achoice,1) +180 sw=(achoice-pchoice+3) mod 3 +190 if sw=0 then print "Tie." else if sw=1 then print msg$(achoice);". My point.":ascore=ascore+1 else print msg$(pchoice);". Your point.":pscore=pscore+1 +200 print pscore":"ascore +210 rn=rnd*plays +220 if rn RotateLeft@choices]}, + record[x]++; + text = "Your Choice:" <> x <> "\nComputer's Choice:" <> y <> "\n" <> + Switch[{x, y}, Alternatives @@ Partition[choices, 2, 1, 1], + "You lost.", + Alternatives @@ Reverse /@ Partition[choices, 2, 1, 1], + "You win.", _, "Draw."]]; + Column@{Dynamic[text], ButtonBar[# :> play[#] & /@ choices]}] diff --git a/Task/Rock-paper-scissors/OCaml/rock-paper-scissors.ocaml b/Task/Rock-paper-scissors/OCaml/rock-paper-scissors.ocaml new file mode 100644 index 0000000000..83f3d84b22 --- /dev/null +++ b/Task/Rock-paper-scissors/OCaml/rock-paper-scissors.ocaml @@ -0,0 +1,52 @@ +let pf = Printf.printf ;; + +let looses a b = match a, b with + `R, `P -> true + | `P, `S -> true + | `S, `R -> true + | _, _ -> false ;; + +let rec get_move () = + pf "[R]ock, [P]aper, [S]cisors [Q]uit? " ; + match String.uppercase (read_line ()) with + "P" -> `P + | "S" -> `S + | "R" -> `R + | "Q" -> exit 0 + | _ -> get_move () ;; + +let str_of_move = function + `P -> "paper" + | `R -> "rock" + | `S -> "scisors" ;; + +let comp_move r p s = + let tot = r +. p +. s in + let n = Random.float 1.0 in + if n < r /. tot then + `R + else + if n < (r +. p) /. tot then + `P + else + `S ;; + +let rec make_moves r p s = + let cm = comp_move r p s in (* Computer move is based on game history. *) + let hm = get_move () in (* Human move is requested. *) + pf "Me: %s. You: %s. " (str_of_move cm) (str_of_move hm); + let outcome = + if looses hm cm then + "I win. You loose.\n" + else if cm = hm then + "We draw.\n" + else + "You win. I loose.\n" + in pf "%s" outcome; + match hm with (* Play on with adapted strategy. *) + `S -> make_moves (r +. 1.) p s + | `R -> make_moves r (p +. 1.) s + | `P -> make_moves r p (s +. 1.) ;; + +(* Main loop. *) +make_moves 1. 1. 1. ;; diff --git a/Task/Rock-paper-scissors/PARI-GP/rock-paper-scissors.pari b/Task/Rock-paper-scissors/PARI-GP/rock-paper-scissors.pari new file mode 100644 index 0000000000..e0380c899a --- /dev/null +++ b/Task/Rock-paper-scissors/PARI-GP/rock-paper-scissors.pari @@ -0,0 +1,35 @@ +contest(rounds)={ + my(v=[1,1,1],wins,losses); \\ Laplace rule + for(i=1,rounds, + my(computer,player,t); + t=random(v[1]+v[2]+v[3]); + if(t "R" && player <> "P", player = "S") + , + player = "S" + ); + if (player == "R", v[2]++); + if (player == "P", v[3]++); + if (player == "S", v[1]++); + print1(player" vs. "computer": "); + if (computer <> player, + if((computer == "R" && player = "P") || (computer == "P" && player = "S") || (computer == "S" && player == "R"), + print("You win"); + losses++ + , + print("I win"); + wins++ + ) + , + print("Tie"); + ) + ); + [wins,losses] +}; +contest(10) diff --git a/Task/Rock-paper-scissors/Perl-6/rock-paper-scissors-1.pl6 b/Task/Rock-paper-scissors/Perl-6/rock-paper-scissors-1.pl6 new file mode 100644 index 0000000000..68bfd55a72 --- /dev/null +++ b/Task/Rock-paper-scissors/Perl-6/rock-paper-scissors-1.pl6 @@ -0,0 +1,40 @@ +my %vs = ( + options => [], + ro => { + ro => [ 2, '' ], + pa => [ 1, 'Paper covers Rock: ' ], + sc => [ 0, 'Rock smashes Scissors: ' ] + }, + pa => { + ro => [ 0, 'Paper covers Rock: ' ], + pa => [ 2, '' ], + sc => [ 1, 'Scissors cut Paper: ' ] + }, + sc => { + ro => [ 1, 'Rock smashes Scissors: '], + pa => [ 0, 'Scissors cut Paper: ' ], + sc => [ 2, '' ] + } +); + +my %choices = %vs.map({; $_.substr(0,2).lc => $_ }); +my $keys = %choices.keys.join('|'); +my $prompt = %vs.map({$_.subst(/(\w\w)/,->$/{"[$0]"})}).join(' ')~"? "; +my %weight = %choices.keys »=>» 1; + +my @stats = 0,0,0; +my $round; + +while my $player = (prompt "Round {++$round}: " ~ $prompt).lc { + $player.=substr(0,2); + say 'Invalid choice, try again.' and $round-- and next + unless $player.chars == 2 and $player ~~ /<$keys>/; + my $computer = %weight.keys.map( { $_ xx %weight{$_} } ).pick; + %weight{$_.key}++ for %vs{$player}.grep( { $_.value[0] == 1 } ); + my $result = %vs{$player}{$computer}[0]; + @stats[$result]++; + say "You chose %choices{$player}, Computer chose %choices{$computer}."; + print %vs{$player}{$computer}[1]; + print ( 'You win!', 'You Lose!','Tie.' )[$result]; + say " - (W:{@stats[0]} L:{@stats[1]} T:{@stats[2]})\n", +}; diff --git a/Task/Rock-paper-scissors/Perl-6/rock-paper-scissors-2.pl6 b/Task/Rock-paper-scissors/Perl-6/rock-paper-scissors-2.pl6 new file mode 100644 index 0000000000..64ba6b6543 --- /dev/null +++ b/Task/Rock-paper-scissors/Perl-6/rock-paper-scissors-2.pl6 @@ -0,0 +1,38 @@ +my %vs = ( + options => [], + ro => { + ro => [ 2, '' ], + pa => [ 1, 'Paper covers Rock: ' ], + sc => [ 0, 'Rock smashes Scissors: ' ], + li => [ 0, 'Rock crushes Lizard: ' ], + sp => [ 1, 'Spock vaporizes Rock: ' ] + }, + pa => { + ro => [ 0, 'Paper covers Rock: ' ], + pa => [ 2, '' ], + sc => [ 1, 'Scissors cut Paper: ' ], + li => [ 1, 'Lizard eats Paper: ' ], + sp => [ 0, 'Paper disproves Spock: ' ] + }, + sc => { + ro => [ 1, 'Rock smashes Scissors: ' ], + pa => [ 0, 'Scissors cut Paper: ' ], + sc => [ 2, '' ], + li => [ 0, 'Scissors decapitate Lizard: '], + sp => [ 1, 'Spock smashes Scissors: ' ] + }, + li => { + ro => [ 1, 'Rock crushes Lizard: ' ], + pa => [ 0, 'Lizard eats Paper: ' ], + sc => [ 1, 'Scissors decapitate Lizard: '], + li => [ 2, '' ], + sp => [ 0, 'Lizard poisons Spock: ' ] + }, + sp => { + ro => [ 0, 'Spock vaporizes Rock: ' ], + pa => [ 1, 'Paper disproves Spock: ' ], + sc => [ 0, 'Spock smashes Scissors: ' ], + li => [ 1, 'Lizard poisons Spock: ' ], + sp => [ 2, '' ] + } +); diff --git a/Task/Rock-paper-scissors/PicoLisp/rock-paper-scissors.l b/Task/Rock-paper-scissors/PicoLisp/rock-paper-scissors.l new file mode 100644 index 0000000000..b0bea5aed3 --- /dev/null +++ b/Task/Rock-paper-scissors/PicoLisp/rock-paper-scissors.l @@ -0,0 +1,20 @@ +(use (C Mine Your) + (let (Rock 0 Paper 0 Scissors 0) + (loop + (setq Mine + (let N (if (gt0 (+ Rock Paper Scissors)) (rand 1 @) 0) + (seek + '((L) (le0 (dec 'N (caar L)))) + '(Rock Paper Scissors .) ) ) ) + (prin "Enter R, P or S to play, or Q to quit: ") + (loop + (and (= "Q" (prinl (setq C (uppc (key))))) (bye)) + (T (setq Your (find '((S) (pre? C S)) '(Rock Paper Scissors)))) + (prinl "Bad input - try again") ) + (prinl + "I say " (cadr Mine) ", You say " Your ": " + (cond + ((== Your (cadr Mine)) "Draw") + ((== Your (car Mine)) "I win") + (T "You win") ) ) + (inc Your) ) ) ) diff --git a/Task/Rock-paper-scissors/PureBasic/rock-paper-scissors.purebasic b/Task/Rock-paper-scissors/PureBasic/rock-paper-scissors.purebasic new file mode 100644 index 0000000000..199812b3e0 --- /dev/null +++ b/Task/Rock-paper-scissors/PureBasic/rock-paper-scissors.purebasic @@ -0,0 +1,84 @@ +Enumeration + ;choices are in listed according to their cycle, weaker followed by stronger + #rock + #paper + #scissors + #numChoices ;this comes after all possible choices +EndEnumeration + +;give names to each of the choices +Dim choices.s(#numChoices - 1) +choices(#rock) = "rock" +choices(#paper) = "paper" +choices(#scissors) = "scissors" + +Define gameCount +Dim playerChoiceHistory(#numChoices - 1) + +Procedure weightedRandomChoice() + Shared gameCount, playerChoiceHistory() + Protected x = Random(gameCount - 1), t, c + + For i = 0 To #numChoices - 1 + t + playerChoiceHistory(i) + If t >= x + c = i + Break + EndIf + Next + + ProcedureReturn (c + 1) % #numChoices +EndProcedure + +If OpenConsole() + PrintN("Welcome to the game of rock-paper-scissors") + PrintN("Each player guesses one of these three, and reveals it at the same time.") + PrintN("Rock blunts scissors, which cut paper, which wraps stone.") + PrintN("If both players choose the same, it is a draw!") + PrintN("When you've had enough, choose Q.") + + Define computerChoice, playerChoice, response.s + Define playerWins, computerWins, draw, quit + + computerChoice = Random(#numChoices - 1) + Repeat + Print(#CRLF$ + "What is your move (press R, P, or S)?") + Repeat + response = LCase(Input()) + Until FindString("rpsq", response) > 0 + + If response = "q": + quit = 1 + Else + gameCount + 1 + playerChoice = FindString("rps", response) - 1 + + result = (playerChoice - computerChoice + #numChoices) % #numChoices + Print("You chose " + choices(playerChoice) + " and I chose " + choices(computerChoice)) + Select result + Case 0 + PrintN(". It's a draw.") + draw + 1 + Case 1 + PrintN(". You win!") + playerWins + 1 + Case 2 + PrintN(". I win!") + computerWins + 1 + EndSelect + playerChoiceHistory(playerChoice) + 1 + computerChoice = weightedRandomChoice() + EndIf + Until quit + + Print(#CRLF$ + "You chose: ") + For i = 0 To #numChoices - 1 + Print(choices(i) + " " + StrF(playerChoiceHistory(i) * 100 / gameCount, 1) + "%; ") + Next + PrintN("") + PrintN("You won " + Str(playerWins) + ", and I won " + Str(computerWins) + ". There were " + Str(draw) + " draws.") + PrintN("Thanks for playing!") + + Print(#CRLF$ + #CRLF$ + "Press ENTER to exit"): Input() + CloseConsole() +EndIf diff --git a/Task/Rock-paper-scissors/Python/rock-paper-scissors.py b/Task/Rock-paper-scissors/Python/rock-paper-scissors.py new file mode 100644 index 0000000000..05d91a4f21 --- /dev/null +++ b/Task/Rock-paper-scissors/Python/rock-paper-scissors.py @@ -0,0 +1,66 @@ +#!/usr/bin/python +from random import choice, randrange +from bisect import bisect +from collections import defaultdict + +WHATBEATS = { 'paper' : 'scissors', + 'scissors' : 'rock', + 'rock' : 'paper' } + +ORDER = ('rock', 'paper', 'scissors') + +CHOICEFREQUENCY = defaultdict(int) + +def probChoice(choices, probabilities): + total = sum(probabilities) + prob_accumulator = 0 + accumulator = [] + for p in probabilities: + prob_accumulator += p + accumulator.append(prob_accumulator) + r = randrange(total) + bsct = bisect(accumulator, r) + chc = choices[bsct] + return chc + +def checkWinner(a, b): + if b == WHATBEATS[a]: + return b + elif a == WHATBEATS[b]: + return a + + return None + +def sanitizeChoice(a): + # Drop it to lower-case + return a.lower() + +def registerPlayerChoice(choice): + CHOICEFREQUENCY[choice] += 1 + +def getRandomChoice(): + if len(CHOICEFREQUENCY) == 0: + return choice(ORDER) + choices = CHOICEFREQUENCY.keys() + probabilities = CHOICEFREQUENCY.values() + return WHATBEATS[probChoice(choices, probabilities)] + +while True: + humanChoice = raw_input() + humanChoice = sanitizeChoice(humanChoice) + if humanChoice not in ORDER: + continue + + compChoice = getRandomChoice() + print "Computer picked", compChoice+",", + + # Don't register the player choice until after the computer has made + # its choice. + registerPlayerChoice(humanChoice) + + winner = checkWinner(humanChoice, compChoice) + + if winner == None: + winner = "nobody" + + print winner, "wins!" diff --git a/Task/Rock-paper-scissors/Rascal/rock-paper-scissors-1.rascal b/Task/Rock-paper-scissors/Rascal/rock-paper-scissors-1.rascal new file mode 100644 index 0000000000..00097e8a7c --- /dev/null +++ b/Task/Rock-paper-scissors/Rascal/rock-paper-scissors-1.rascal @@ -0,0 +1,20 @@ +import Prelude; + +rel[str, str] whatbeats = {<"Rock", "Scissors">, <"Scissors", "Paper">, <"Paper", "Rock">}; + +list[str] ComputerChoices = ["Rock", "Paper", "Scissors"]; + +str CheckWinner(a, b){ + if(b == getOneFrom(whatbeats[a])) + return a; + elseif(a == getOneFrom(whatbeats[b])) + return b; + else return "Nobody"; +} + +public str RPS(human){ + computer = getOneFrom(ComputerChoices); + x = if(human == "Rock") "Paper"; elseif(human == "Paper") "Scissors"; else "Rock"; + ComputerChoices += x; + return "Computer played . wins!"; +} diff --git a/Task/Rock-paper-scissors/Rascal/rock-paper-scissors-2.rascal b/Task/Rock-paper-scissors/Rascal/rock-paper-scissors-2.rascal new file mode 100644 index 0000000000..317e31851c --- /dev/null +++ b/Task/Rock-paper-scissors/Rascal/rock-paper-scissors-2.rascal @@ -0,0 +1,29 @@ +rascal>RPS("Rock") +str: "Computer played Rock. Nobody wins!" + +rascal>RPS("Rock") +str: "Computer played Rock. Nobody wins!" + +rascal>RPS("Rock") +str: "Computer played Scissors. Rock wins!" + +rascal>RPS("Rock") +str: "Computer played Paper. Paper wins!" + +rascal>RPS("Rock") +str: "Computer played Paper. Paper wins!" + +rascal>RPS("Rock") +str: "Computer played Paper. Paper wins!" + +rascal>RPS("Rock") +str: "Computer played Paper. Paper wins!" + +rascal>RPS("Rock") +str: "Computer played Rock. Nobody wins!" + +rascal>RPS("Rock") +str: "Computer played Paper. Paper wins!" + +rascal>RPS("Rock") +str: "Computer played Paper. Paper wins!" diff --git a/Task/Rock-paper-scissors/Ruby/rock-paper-scissors.rb b/Task/Rock-paper-scissors/Ruby/rock-paper-scissors.rb new file mode 100644 index 0000000000..8854039cec --- /dev/null +++ b/Task/Rock-paper-scissors/Ruby/rock-paper-scissors.rb @@ -0,0 +1,73 @@ +class RockPaperScissorsGame + def initialize() + @pieces = %w[rock paper scissors] + @beats = { + 'rock' => 'paper', + 'paper' => 'scissors', + 'scissors' => 'rock', + } + @plays = { + 'rock' => 1, + 'paper' => 1, + 'scissors' => 1, + } + @score = [0, 0] + + play + end + + def humanPlay() + answer = nil + loop do + print "\nYour choice: #@pieces? " + answer = STDIN.gets.strip.downcase + next if answer.empty? + if idx = @pieces.find_index {|piece| piece.match(/^#{answer}/)} + answer = @pieces[idx] + break + else + puts "invalid answer, try again" + end + end + answer + end + + def computerPlay() + total = @plays.values.reduce(:+) + r = rand(total) + 1 + sum = 0 + humans_choice = nil + @pieces.each do |piece| + sum += @plays[piece] + if r <= sum + humans_choice = piece + break + end + end + @beats[humans_choice] + end + + def play + loop do + h = humanPlay + c = computerPlay + print "H: #{h}, C: #{c} => " + + # only update the human player's history after the computer has chosen + @plays[h] += 1 + + if h == c + puts "draw" + elsif h == @beats[c] + puts "Human wins" + @score[0] += 1 + else + puts "Computer wins" + @score[1] += 1 + end + puts "score: human=#{@score[0]}, computer=#{@score[1]}" + end + end +end + +game = RockPaperScissorsGame.new diff --git a/Task/Rock-paper-scissors/Run-BASIC/rock-paper-scissors.run b/Task/Rock-paper-scissors/Run-BASIC/rock-paper-scissors.run new file mode 100644 index 0000000000..0f7776e31a --- /dev/null +++ b/Task/Rock-paper-scissors/Run-BASIC/rock-paper-scissors.run @@ -0,0 +1,30 @@ +pri$ = "RSPR" +rps$ = "Rock,Paper,Sissors" +[loop] +button #r, "Rock", [r] +button #p, "Paper", [p] +button #s, "Scissors",[s] +button #q, "Quit", [q] +wait +[r] y = 1 :goto [me] +[p] y = 2 :goto [me] +[s] y = 3 +[me] +cls +y$ = word$(rps$,y,",") +m = int((rnd(0) * 2) + 1) +m$ = word$(rps$,m,",") +print chr$(10);"You Chose:";y$;" I chose:";m$ +yp = instr(pri$,left$(y$,1)) +mp = instr(pri$,left$(m$,1)) +if yp = 1 and mp = 3 then mp = 0 +if mp = 1 and yp = 3 then yp = 0 +if yp < mp then print "You win" +if yp = mp then print "Tie" +if yp > mp then print "I win" +goto [loop] +wait + +[q] cls +print "Good Bye! I enjoyed the game" +end diff --git a/Task/Rock-paper-scissors/TI-83-BASIC/rock-paper-scissors.ti-83 b/Task/Rock-paper-scissors/TI-83-BASIC/rock-paper-scissors.ti-83 new file mode 100644 index 0000000000..20dba8381c --- /dev/null +++ b/Task/Rock-paper-scissors/TI-83-BASIC/rock-paper-scissors.ti-83 @@ -0,0 +1,64 @@ +PROGRAM:RPS +:{0,0,0}→L1 +:{0,0,0}→L2 +:Lbl ST +:Disp "R/P/S" +:Disp "1/2/3" +:Lbl EC +:Input A +:If A>3 or A<1 +:Then +:Goto NO +:End +:randInt(1,3+L1(1)+L1(2)+L1(3)→C +:If C≤1+L1(1) +:Then +:2→B +:Goto NS +:End +:If C>2+L1(2) +:Then +:1→B +:Else +:3→B +:End +:Lbl NS +:L1(A)+1→L1(A) +:If A=B +:Then +:Disp "TIE GAME" +:L2(3)+1→L2(3) +:Goto TG +:End +:If (A=1 and B=2) or (A=2 and B=3) or (A=3 and B=1) +:Then +:Disp "I WIN" +:L2(1)+1→L2(1) +:Else +:Disp "YOU WIN" +:L2(2)+1→L2(2) +:End +:Lbl TG +:Disp "PLAY AGAIN?" +:Input Str1 +:If Str1="YES" +:Then +:ClrHome +:Goto ST +:Else +:Goto EN +:End +:Lbl NO +:ClrHome +:Pause "PICK 1,2, or 3" +:ClrHome +:Goto EC +:Lbl EN +:ClrHome +:Disp "I WON:" +:Disp L2(1) +:Disp "YOU WON:" +:Disp L2(2) +:Disp "WE TIED:" +:Disp L2(3) +:Disp "BYE" diff --git a/Task/Rock-paper-scissors/Tcl/rock-paper-scissors.tcl b/Task/Rock-paper-scissors/Tcl/rock-paper-scissors.tcl new file mode 100644 index 0000000000..d5f0a48ee3 --- /dev/null +++ b/Task/Rock-paper-scissors/Tcl/rock-paper-scissors.tcl @@ -0,0 +1,64 @@ +package require Tcl 8.5 + +### Choices are represented by integers, which are indices into this list: +### Rock, Paper, Scissors +### Normally, idiomatic Tcl code uses names for these sorts of things, but it +### turns out that using integers simplifies the move-comparison logic. + +# How to ask for a move from the human player +proc getHumanMove {} { + while 1 { + puts -nonewline "Your move? \[R\]ock, \[P\]aper, \[S\]cissors: " + flush stdout + gets stdin line + if {[eof stdin]} { + puts "\nBye!" + exit + } + set len [string length $line] + foreach play {0 1 2} name {"rock" "paper" "scissors"} { + # Do a prefix comparison + if {$len && [string equal -nocase -length $len $line $name]} { + return $play + } + } + puts "Sorry, I don't understand that. Try again please." + } +} + +# How to ask for a move from the machine player +proc getMachineMove {} { + global states + set choice [expr {int(rand() * [::tcl::mathop::+ {*}$states 3])}] + foreach play {1 2 0} count $states { + if {[incr sum [expr {$count+1}]] > $choice} { + puts "I play \"[lindex {Rock Paper Scissors} $play]\"" + return $play + } + } +} + +# Initialize some state variables +set states {0 0 0} +set humanWins 0 +set machineWins 0 + +# The main game loop +while 1 { + # Get the moves for this round + set machineMove [getMachineMove] + set humanMove [getHumanMove] + # Report on what happened + if {$humanMove == $machineMove} { + puts "A draw!" + } elseif {($humanMove+1)%3 == $machineMove} { + puts "I win!" + incr machineWins + } else { + puts "You win!" + incr humanWins + } + puts "Cumulative scores: $humanWins to you, $machineWins to me" + # Update the state of how the human has played in the past + lset states $humanMove [expr {[lindex $states $humanMove] + 1}] +} diff --git a/Task/Rock-paper-scissors/TorqueScript/rock-paper-scissors-1.torquescript b/Task/Rock-paper-scissors/TorqueScript/rock-paper-scissors-1.torquescript new file mode 100644 index 0000000000..f6d4dc4993 --- /dev/null +++ b/Task/Rock-paper-scissors/TorqueScript/rock-paper-scissors-1.torquescript @@ -0,0 +1,140 @@ +while(isobject(RockPaperScissors)) + RockPaperScissors.delete(); + +new scriptObject(RockPaperScissors); + +function RockPaperScissors::startGame(%this) +{ + %this.idle = true; + echo("Starting rock paper scissors, please type choose(\"choice\"); to proceed!"); +} + +function RockPaperScissors::endGame(%this) +{ + %this.idle = true; +} + +function RockPaperScissors::main(%this) +{ + %this.idle = 0; + + if(getRandom(1,2) == 1) + { + %result = %this.getChoiceByUserFrequency(); + } + else + { + %c[0] = "rock"; + %c[1] = "paper"; + %c[2] = "scissors"; + + %result = %c[getRandom(0,2)]; + } + + %userChoice = %this.current; + + %winner = thisVSthat(%userChoice,%result); + + if(%winner == 0) + { + echo("You both chose "@%userChoice@", tie!"); + } + else + if(%winner == 1) + { + echo("You chose "@%userChoice@" computer chose "@%result@", you win!"); + } + else + if(%winner == 2) + { + echo("You chose "@%userChoice@" computer chose "@%result@", you lose!"); + } + + %this.idle = true; +} + +function RockPaperScissors::getChoiceByUserFrequency(%this) +{ + %weakness["rock"] = "paper"; + %weakness["paper"] = "Scissors"; + %weakness["scissors"] = "rock"; + + %a[0] = %this.choice["rock"]; + %a[1] = %this.choice["paper"]; + %a[2] = %this.choice["Scissors"]; + + %b[0] = "rock"; + %b[1] = "paper"; + %b[2] = "scissors"; + + for(%i=0;%i<3;%i++) + { + %curr = %a[%i]; + + if(%temp $= "") + { + %temp = %curr; + %tempi = %i; + } + else + if(%curr > %temp) + { + %temp = %curr; + %tempi = %i; + } + } + + return %weakness[%b[%tempi]]; +} + +function choose(%this) +{ + %rps = rockPaperScissors; + + if(!%rps.idle) + { + return 0; + } + else + if(%this !$= "rock" && %this !$= "paper" && %this !$= "scissors") + { + return 0; + } + + %rps.choice[%this]++; + %rps.current = %this; + %rps.main(); + + return %this; +} + +function thisVSthat(%this,%that) +{ + if(%this !$= "rock" && %this !$= "paper" && %this !$= "scissors") + { + return 0; + } + else + if(%that !$= "rock" && %that !$= "paper" && %that !$= "scissors") + { + return 0; + } + + %weakness["rock"] = "paper"; + %weakness["paper"] = "Scissors"; + %weakness["scissors"] = "rock"; + + if(%weakness[%this] $= %that) + { + %result = 2; + } + else + if(%weakness[%that] $= %this) + { + %result = 1; + } + else + %result = 0; + + return %result; +} diff --git a/Task/Rock-paper-scissors/TorqueScript/rock-paper-scissors-2.torquescript b/Task/Rock-paper-scissors/TorqueScript/rock-paper-scissors-2.torquescript new file mode 100644 index 0000000000..81f2615c2a --- /dev/null +++ b/Task/Rock-paper-scissors/TorqueScript/rock-paper-scissors-2.torquescript @@ -0,0 +1 @@ +RockPaperScissors.startGame(); diff --git a/Task/Rock-paper-scissors/TorqueScript/rock-paper-scissors-3.torquescript b/Task/Rock-paper-scissors/TorqueScript/rock-paper-scissors-3.torquescript new file mode 100644 index 0000000000..f367058276 --- /dev/null +++ b/Task/Rock-paper-scissors/TorqueScript/rock-paper-scissors-3.torquescript @@ -0,0 +1 @@ +choose("Rock"); diff --git a/Task/Roman-numerals-Decode/0DESCRIPTION b/Task/Roman-numerals-Decode/0DESCRIPTION new file mode 100644 index 0000000000..706c17e806 --- /dev/null +++ b/Task/Roman-numerals-Decode/0DESCRIPTION @@ -0,0 +1,3 @@ +Create a function that takes a Roman numeral as its argument and returns its value as a numeric decimal integer. You don't need to validate the form of the Roman numeral. + +Modern Roman numerals are written by expressing each decimal digit of the number to be encoded separately, starting with the leftmost digit and skipping any 0s. So 1990 is rendered "MCMXC" (1000 = M, 900 = CM, 90 = XC) and 2008 is rendered "MMVIII" (2000 = MM, 8 = VIII). The Roman numeral for 1666, "MDCLXVI", uses each letter in descending order. diff --git a/Task/Roman-numerals-Decode/ALGOL-68/roman-numerals-decode.alg b/Task/Roman-numerals-Decode/ALGOL-68/roman-numerals-decode.alg new file mode 100644 index 0000000000..9e1d2e0b06 --- /dev/null +++ b/Task/Roman-numerals-Decode/ALGOL-68/roman-numerals-decode.alg @@ -0,0 +1,48 @@ + PROC roman to int = (STRING roman) INT: + BEGIN + PROC roman digit value = (CHAR roman digit) INT: + (roman digit = "M" | 1000 |: + roman digit = "D" | 500 |: + roman digit = "C" | 100 |: + roman digit = "L" | 50 |: + roman digit = "X" | 10 |: + roman digit = "V" | 5 |: + roman digit = "I" | 1); + + INT result := 0, previous value := 0, run := 0; + + FOR i FROM LWB roman TO UPB roman + DO + INT value = roman digit value(roman[i]); + IF previous value = value THEN + run +:= value + ELSE + IF previous value < value THEN + result -:= run + ELSE + result +:= run + FI; + run := previous value := value + FI + OD; + + result +:= run + END; + + MODE TEST = STRUCT (STRING input, INT expected output); + + [] TEST roman test = ( + ("MMXI", 2011), ("MIM", 1999), + ("MCMLVI", 1956), ("MDCLXVI", 1666), + ("XXCIII", 83), ("LXXIIX", 78), + ("IIIIX", 6) + ); + + print(("Test input Value Got", newline, "--------------------------", newline)); + FOR i FROM LWB roman test TO UPB roman test + DO + INT output = roman to int(input OF roman test[i]); + printf(($g, n (12 - UPB input OF roman test[i]) x$, input OF roman test[i])); + printf(($g(5), 1x, g(5), 1x$, expected output OF roman test[i], output)); + printf(($b("ok", "not ok"), 1l$, output = expected output OF roman test[i])) + OD diff --git a/Task/Roman-numerals-Decode/ANTLR/roman-numerals-decode.antlr b/Task/Roman-numerals-Decode/ANTLR/roman-numerals-decode.antlr new file mode 100644 index 0000000000..ce6625cb69 --- /dev/null +++ b/Task/Roman-numerals-Decode/ANTLR/roman-numerals-decode.antlr @@ -0,0 +1,39 @@ +/* Parse Roman Numerals + + Nigel Galloway March 16th., 2012 +*/ +grammar ParseRN ; + +options { + language = Java; +} +@members { +int rnValue; +int ONE; +} + +parseRN: ({rnValue = 0;} rn NEWLINE {System.out.println($rn.text + " = " + rnValue);})* + ; + +rn : (Thousand {rnValue += 1000;})* hundreds? tens? units?; + +hundreds: {ONE = 0;} (h9 | h5) {if (ONE > 3) System.out.println ("Too many hundreds");}; +h9 : Hundred {ONE += 1;} (FiveHund {rnValue += 400;}| Thousand {rnValue += 900;}|{rnValue += 100;} (Hundred {rnValue += 100; ONE += 1;})*); +h5 : FiveHund {rnValue += 500;} (Hundred {rnValue += 100; ONE += 1;})*; + +tens : {ONE = 0;} (t9 | t5) {if (ONE > 3) System.out.println ("Too many tens");}; +t9 : Ten {ONE += 1;} (Fifty {rnValue += 40;}| Hundred {rnValue += 90;}|{rnValue += 10;} (Ten {rnValue += 10; ONE += 1;})*); +t5 : Fifty {rnValue += 50;} (Ten {rnValue += 10; ONE += 1;})*; + +units : {ONE = 0;} (u9 | u5) {if (ONE > 3) System.out.println ("Too many ones");}; +u9 : One {ONE += 1;} (Five {rnValue += 4;}| Ten {rnValue += 9;}|{rnValue += 1;} (One {rnValue += 1; ONE += 1;})*); +u5 : Five {rnValue += 5;} (One {rnValue += 1; ONE += 1;})*; + +One : 'I'; +Five : 'V'; +Ten : 'X'; +Fifty : 'L'; +Hundred: 'C'; +FiveHund: 'D'; +Thousand: 'M' ; +NEWLINE: '\r'? '\n' ; diff --git a/Task/Roman-numerals-Decode/AWK/roman-numerals-decode.awk b/Task/Roman-numerals-Decode/AWK/roman-numerals-decode.awk new file mode 100644 index 0000000000..075b599c1e --- /dev/null +++ b/Task/Roman-numerals-Decode/AWK/roman-numerals-decode.awk @@ -0,0 +1,23 @@ +# syntax: GAWK -f ROMAN_NUMERALS_DECODE.AWK +BEGIN { + leng = split("MCMXC MMVIII MDCLXVI",arr," ") + for (i=1; i<=leng; i++) { + n = arr[i] + printf("%s = %s\n",n,roman2arabic(n)) + } + exit(0) +} +function roman2arabic(r, a,i,p,q,u,ua,una,unr) { + r = toupper(r) + unr = "MDCLXVI" # each Roman numeral in descending order + una = "1000 500 100 50 10 5 1" # and its Arabic equivalent + split(una,ua," ") + i = split(r,u,"") + a = ua[index(unr,u[i])] + while (--i) { + p = index(unr,u[i]) + q = index(unr,u[i+1]) + a += ua[p] * ((p>q) ? -1 : 1) + } + return( (a>0) ? a : "" ) +} diff --git a/Task/Roman-numerals-Decode/Ada/roman-numerals-decode.ada b/Task/Roman-numerals-Decode/Ada/roman-numerals-decode.ada new file mode 100644 index 0000000000..36ebbb7da5 --- /dev/null +++ b/Task/Roman-numerals-Decode/Ada/roman-numerals-decode.ada @@ -0,0 +1,46 @@ +with Ada.Text_IO; + +procedure Decode_Roman_Numerals is + + function Roman_To_Integer(A_Roman: String) return Integer is + + function Decode_Roman_Digit (A_Char: Character) return Integer is + begin + case A_Char is + when 'M' | 'm' => return 1000; + when 'D' | 'd' => return 500; + when 'C' | 'c' => return 100; + when 'L' | 'l' => return 50; + when 'X' | 'x' => return 10; + when 'V' | 'v' => return 5; + when 'I' | 'i' => return 1; + when others => return 0; + end case; + end Decode_Roman_Digit; + + L_Curr_Val: Integer; + L_Last_Val: Integer; + + Result: Integer; + begin + Result := 0; + + L_Last_Val := 0; + + for i in reverse 1 .. A_Roman'Length loop + L_Curr_Val := Decode_Roman_Digit(A_Roman(I)); + if L_Curr_Val < L_Last_Val then + Result := Result - L_Curr_Val; + else + Result := Result + L_Curr_Val; + end if; + L_Last_Val := L_Curr_Val; + end loop; + return Result; + end Roman_To_Integer; + +begin + Ada.Text_IO.Put_Line(Integer'Image(Roman_To_Integer("MCMXC"))); -- 1990 + Ada.Text_IO.Put_Line(Integer'Image(Roman_To_Integer("MMVIII"))); -- 2008 + Ada.Text_IO.Put_Line(Integer'Image(Roman_To_Integer("MDCLXVI"))); -- 1666 +end Decode_Roman_Numerals; diff --git a/Task/Roman-numerals-Decode/AutoHotkey/roman-numerals-decode.ahk b/Task/Roman-numerals-Decode/AutoHotkey/roman-numerals-decode.ahk new file mode 100644 index 0000000000..b3b18c6021 --- /dev/null +++ b/Task/Roman-numerals-Decode/AutoHotkey/roman-numerals-decode.ahk @@ -0,0 +1,16 @@ +Roman_Decode(str){ + res := 0 + Loop Parse, str + { + n := {M: 1000, D:500, C:100, L:50, X:10, V:5, I:1}[A_LoopField] + If ( n > OldN ) && OldN + res -= 2*OldN + res += n, oldN := n + } + return res +} + +test = MCMXC|MMVIII|MDCLXVI +Loop Parse, test, | + res .= A_LoopField "`t= " Roman_Decode(A_LoopField) "`r`n" +clipboard := res diff --git a/Task/Roman-numerals-Decode/BBC-BASIC/roman-numerals-decode.bbc b/Task/Roman-numerals-Decode/BBC-BASIC/roman-numerals-decode.bbc new file mode 100644 index 0000000000..0b4824540a --- /dev/null +++ b/Task/Roman-numerals-Decode/BBC-BASIC/roman-numerals-decode.bbc @@ -0,0 +1,16 @@ + PRINT "MCMXCIX", FNromandecode("MCMXCIX") + PRINT "MMXII", FNromandecode("MMXII") + PRINT "MDCLXVI", FNromandecode("MDCLXVI") + PRINT "MMMDCCCLXXXVIII", FNromandecode("MMMDCCCLXXXVIII") + END + + DEF FNromandecode(roman$) + LOCAL i%, j%, p%, n%, r%() + DIM r%(7) : r%() = 0,1,5,10,50,100,500,1000 + FOR i% = LEN(roman$) TO 1 STEP -1 + j% = INSTR("IVXLCDM", MID$(roman$,i%,1)) + IF j%=0 ERROR 100, "Invalid character" + IF j%>=p% n% += r%(j%) ELSE n% -= r%(j%) + p% = j% + NEXT + = n% diff --git a/Task/Roman-numerals-Decode/Bracmat/roman-numerals-decode.bracmat b/Task/Roman-numerals-Decode/Bracmat/roman-numerals-decode.bracmat new file mode 100644 index 0000000000..afc737fe54 --- /dev/null +++ b/Task/Roman-numerals-Decode/Bracmat/roman-numerals-decode.bracmat @@ -0,0 +1,40 @@ + ( unroman + = nbr,lastVal,val + . 0:?nbr:?lastVal + & @( low$!arg + : ? + %@?L + ( ? + & (m.1000) + (d.500) + (c.100) + (l.50) + (x.10) + (v.5) + (i.1) + : ? (!L.?val) ? + & (!val:~>!lastVal|!val+-2*!lastVal) + + !nbr + : ?nbr + & !val:?lastVal + & ~ + ) + ) + | !nbr + ) +& (M.1000) + (MCXI.1111) + (CMXI.911) + (MCM.1900) + (MCMXC.1990) + (MMVIII.2008) + (MMIX.2009) + (MCDXLIV.1444) + (MDCLXVI.1666) + (MMXII.2012) + : ?years +& (test=.out$(!arg unroman$!arg)) +& ( !years + : ? (?L.?D) (?&test$!L&~) + | done + ); diff --git a/Task/Roman-numerals-Decode/C++/roman-numerals-decode.cpp b/Task/Roman-numerals-Decode/C++/roman-numerals-decode.cpp new file mode 100644 index 0000000000..178d76268e --- /dev/null +++ b/Task/Roman-numerals-Decode/C++/roman-numerals-decode.cpp @@ -0,0 +1,48 @@ +#include +#include +#include +#include + +static std::map Romans; + +int RomanToInt( const std::string &roman ) { + int number = 0 ; + // look for all the letters in the array + for ( std::string::const_iterator i = roman.begin( ) ; i != roman.end( ) ; i++ ) { + std::map::const_iterator it1 = Romans.find( *i ) ; + if ( it1 == Romans.end( ) ) { + std::cerr << *i << " not a valid Roman numeral character." << std::endl ; + return -1 ; + } + int pos1 = it1->second ; + if ( i + 1 != roman.end( ) ) { + std::map::const_iterator it2 = Romans.find( *( i + 1 ) ); + if ( it2 == Romans.end( ) ) { + std::cerr << *( i + 1 ) << " not a valid Roman numeral character." << std::endl ; + return -1 ; + } + int pos2 = it2->second ; + if ( pos2 > pos1 ) { + number += pos2 - pos1 ; + i++ ; + continue ; + } + } + number += pos1 ; + } + return number ; +} + +int main( ) { + Romans[ 'I' ] = 1 ; + Romans[ 'V' ] = 5 ; + Romans[ 'X' ] = 10 ; + Romans[ 'L' ] = 50 ; + Romans[ 'C' ] = 100 ; + Romans[ 'D' ] = 500 ; + Romans[ 'M' ] = 1000 ; + + std::cout << "MCMXC in Roman numerals is " << RomanToInt( "MCMXC" ) << " in Arabic!\n" ; + std::cout << "And MDCLXVI for the Romans is " << RomanToInt( "MDCLXVI" ) << " in better known Arabic figures!\n" ; + return 0 ; +} diff --git a/Task/Roman-numerals-Decode/C/roman-numerals-decode.c b/Task/Roman-numerals-Decode/C/roman-numerals-decode.c new file mode 100644 index 0000000000..b2e77f2e93 --- /dev/null +++ b/Task/Roman-numerals-Decode/C/roman-numerals-decode.c @@ -0,0 +1,47 @@ +#include + +int digits[26] = { 0, 0, 100, 500, 0, 0, 0, 0, 1, 1, 0, 50, 1000, 0, 0, 0, 0, 0, 0, 0, 5, 5, 0, 10, 0, 0 }; + +/* assuming ASCII, do upper case and get index in alphabet. could also be + inline int VALUE(char x) { return digits [ (~0x20 & x) - 'A' ]; } + if you think macros are evil */ +#define VALUE(x) digits[(~0x20 & (x)) - 'A'] + +int decode(const char * roman) +{ + const char *bigger; + int current; + int arabic = 0; + while (*roman != '\0') { + current = VALUE(*roman); + /* if (!current) return -1; + note: -1 can be used as error code; Romans didn't even have zero + */ + bigger = roman; + + /* look for a larger digit, like IV or XM */ + while (VALUE(*bigger) <= current && *++bigger != '\0'); + + if (*bigger == '\0') + arabic += current; + else { + arabic += VALUE(*bigger); + while (roman < bigger) + arabic -= VALUE(* (roman++) ); + } + + roman ++; + } + return arabic; +} + +int main() +{ + const char * romans[] = { "MCmxC", "MMVIII", "MDClXVI", "MCXLUJ" }; + int i; + + for (i = 0; i < 4; i++) + printf("%s\t%d\n", romans[i], decode(romans[i])); + + return 0; +} diff --git a/Task/Roman-numerals-Decode/Clojure/roman-numerals-decode.clj b/Task/Roman-numerals-Decode/Clojure/roman-numerals-decode.clj new file mode 100644 index 0000000000..4a52f55a61 --- /dev/null +++ b/Task/Roman-numerals-Decode/Clojure/roman-numerals-decode.clj @@ -0,0 +1,6 @@ +(defn ro2ar [r] + (->> (reverse r) + (replace (zipmap "MDCLXVI" [1000 500 100 50 10 5 1])) + (partition-by identity) + (map (partial apply +)) + (reduce #(if (< %1 %2) (+ %1 %2) (- %1 %2))))) diff --git a/Task/Roman-numerals-Decode/CoffeeScript/roman-numerals-decode.coffeescript b/Task/Roman-numerals-Decode/CoffeeScript/roman-numerals-decode.coffeescript new file mode 100644 index 0000000000..601ce5c3bf --- /dev/null +++ b/Task/Roman-numerals-Decode/CoffeeScript/roman-numerals-decode.coffeescript @@ -0,0 +1,36 @@ +roman_to_demical = (s) -> + # s is well-formed Roman Numeral >= I + numbers = + M: 1000 + D: 500 + C: 100 + L: 50 + X: 10 + V: 5 + I: 1 + + result = 0 + for c in s + num = numbers[c] + result += num + if old_num < num + # If old_num exists and is less than num, then + # we need to subtract it twice, once because we + # have already added it on the last pass, and twice + # to conform to the Roman convention that XC = 90, + # not 110. + result -= 2 * old_num + old_num = num + result + +tests = + IV: 4 + XLII: 42 + MCMXC: 1990 + MMVIII: 2008 + MDCLXVI: 1666 + +for roman, expected of tests + dec = roman_to_demical(roman) + console.log "error" if dec != expected + console.log "#{roman} = #{dec}" diff --git a/Task/Roman-numerals-Decode/Common-Lisp/roman-numerals-decode.lisp b/Task/Roman-numerals-Decode/Common-Lisp/roman-numerals-decode.lisp new file mode 100644 index 0000000000..de01944593 --- /dev/null +++ b/Task/Roman-numerals-Decode/Common-Lisp/roman-numerals-decode.lisp @@ -0,0 +1,9 @@ +(defun parse-roman (r) + (loop for l on (map 'list (lambda (c) + (getf '(#\I 1 #\V 5 #\X 10 #\L 50 #\C 100 #\D 500 #\M 1000) c)) + (string-upcase r)) + sum (let ((a (first l)) (b (second l))) + (if (and b (< a b)) (- a) a)))) +;; test code +(dolist (r '("MCMXC" "MDCLXVI" "MMVIII")) + (format t "~a: ~d~%" r (parse-roman r))) diff --git a/Task/Roman-numerals-Decode/D/roman-numerals-decode-1.d b/Task/Roman-numerals-Decode/D/roman-numerals-decode-1.d new file mode 100644 index 0000000000..a46b4daeae --- /dev/null +++ b/Task/Roman-numerals-Decode/D/roman-numerals-decode-1.d @@ -0,0 +1,19 @@ +import std.regex, std.algorithm; + +int toArabic(in string s) /*pure nothrow*/ { + static immutable weights = [1000, 900, 500, 400, 100, + 90, 50, 40, 10, 9, 5, 4, 1]; + static immutable symbols = ["M","CM","D","CD","C","XC", + "L","XL","X","IX","V","IV","I"]; + + int arabic; + foreach (m; s.match(regex(r"CM|CD|XC|XL|IX|IV|[MDCLXVI]", "g"))) + arabic += weights[symbols.countUntil(m.hit)]; + return arabic; +} + +void main() { + assert(toArabic("MCMXC") == 1990); + assert(toArabic("MMVIII") == 2008); + assert(toArabic("MDCLXVI") == 1666); +} diff --git a/Task/Roman-numerals-Decode/D/roman-numerals-decode-2.d b/Task/Roman-numerals-Decode/D/roman-numerals-decode-2.d new file mode 100644 index 0000000000..f99c9f2683 --- /dev/null +++ b/Task/Roman-numerals-Decode/D/roman-numerals-decode-2.d @@ -0,0 +1,20 @@ +import std.regex, std.algorithm; + +immutable int[string] w2s; + +nothrow static this() { + w2s = ["IX": 9, "C": 100, "D": 500, "CM": 900, "I": 1, + "XC": 90, "M": 1000, "L": 50, "CD": 400, "XL": 40, + "V": 5, "X": 10, "IV": 4]; +} + +int toArabic(in string s) /*pure nothrow*/ { + auto ms = match(s, regex("CM|CD|XC|XL|IX|IV|[MDCLXVI]", "g")); + return reduce!((a, m) => a + w2s[m.hit])(0, ms); +} + +void main() { + assert("MCMXC".toArabic == 1990); + assert("MMVIII".toArabic == 2008); + assert("MDCLXVI".toArabic == 1666); +} diff --git a/Task/Roman-numerals-Decode/Delphi/roman-numerals-decode.delphi b/Task/Roman-numerals-Decode/Delphi/roman-numerals-decode.delphi new file mode 100644 index 0000000000..1a0d937244 --- /dev/null +++ b/Task/Roman-numerals-Decode/Delphi/roman-numerals-decode.delphi @@ -0,0 +1,44 @@ +program RomanNumeralsDecode; + +{$APPTYPE CONSOLE} + +function RomanToInteger(const aRoman: string): Integer; + function DecodeRomanDigit(aChar: Char): Integer; + begin + case aChar of + 'M', 'm': Result := 1000; + 'D', 'd': Result := 500; + 'C', 'c': Result := 100; + 'L', 'l': Result := 50; + 'X', 'x': Result := 10; + 'V', 'v': Result := 5; + 'I', 'i': Result := 1 + else + Result := 0; + end; + end; + +var + i: Integer; + lCurrVal: Integer; + lLastVal: Integer; +begin + Result := 0; + + lLastVal := 0; + for i := Length(aRoman) downto 1 do + begin + lCurrVal := DecodeRomanDigit(aRoman[i]); + if lCurrVal < lLastVal then + Result := Result - lCurrVal + else + Result := Result + lCurrVal; + lLastVal := lCurrVal; + end; +end; + +begin + Writeln(RomanToInteger('MCMXC')); // 1990 + Writeln(RomanToInteger('MMVIII')); // 2008 + Writeln(RomanToInteger('MDCLXVI')); // 1666 +end. diff --git a/Task/Roman-numerals-Decode/Emacs-Lisp/roman-numerals-decode.l b/Task/Roman-numerals-Decode/Emacs-Lisp/roman-numerals-decode.l new file mode 100644 index 0000000000..89338218a0 --- /dev/null +++ b/Task/Roman-numerals-Decode/Emacs-Lisp/roman-numerals-decode.l @@ -0,0 +1,16 @@ +(defun ro2ar (RN) + "translate a roman number RN into arabic number. + Its argument RN is wether a symbol, wether a list. + Returns the arabic number. (ro2ar 'C) gives 100, + (ro2ar '(X X I V)) gives 24" + (cond + ((eq RN 'M) 1000) + ((eq RN 'D) 500) + ((eq RN 'C) 100) + ((eq RN 'L) 50) + ((eq RN 'X) 10) + ((eq RN 'V) 5) + ((eq RN 'I) 1) + ((null (cdr RN)) (ro2ar (car RN))) ;; stop recursion + ((< (ro2ar (car RN)) (ro2ar (car (cdr RN)))) (- (ro2ar (cdr RN)) (ro2ar (car RN)))) ;; "IV" -> 5-1=4 + (t (+ (ro2ar (car RN)) (ro2ar (cdr RN)))))) ;; "VI" -> 5+1=6 diff --git a/Task/Roman-numerals-Decode/Euphoria/roman-numerals-decode.euphoria b/Task/Roman-numerals-Decode/Euphoria/roman-numerals-decode.euphoria new file mode 100644 index 0000000000..864a687f35 --- /dev/null +++ b/Task/Roman-numerals-Decode/Euphoria/roman-numerals-decode.euphoria @@ -0,0 +1,25 @@ +constant symbols = "MDCLXVI", weights = {1000,500,100,50,10,5,1} +function romanDec(sequence roman) + integer n, lastval, arabic + lastval = 0 + arabic = 0 + for i = length(roman) to 1 by -1 do + n = find(roman[i],symbols) + if n then + n = weights[n] + end if + if n < lastval then + arabic -= n + else + arabic += n + end if + lastval = n + end for + return arabic +end function + +? romanDec("MCMXCIX") +? romanDec("MDCLXVI") +? romanDec("XXV") +? romanDec("CMLIV") +? romanDec("MMXI") diff --git a/Task/Roman-numerals-Decode/Forth/roman-numerals-decode.fth b/Task/Roman-numerals-Decode/Forth/roman-numerals-decode.fth new file mode 100644 index 0000000000..3cef43a4c4 --- /dev/null +++ b/Task/Roman-numerals-Decode/Forth/roman-numerals-decode.fth @@ -0,0 +1,26 @@ +create (arabic) + 1000 128 * char M + , + 500 128 * char D + , + 100 128 * char C + , + 50 128 * char L + , + 10 128 * char X + , + 5 128 * char V + , + 1 128 * char I + , +does> + 7 cells bounds do + i @ over over 127 and = if nip 7 rshift leave else drop then + 1 cells +loop dup +; + +: >arabic + 0 dup >r >r + begin + over over + while + c@ dup (arabic) rot <> + while + r> over r> over over > if 2* negate + else drop then + swap >r >r 1 /string + repeat then drop 2drop r> r> drop +; + +s" MCMLXXXIV" >arabic . diff --git a/Task/Roman-numerals-Decode/Fortran/roman-numerals-decode.f b/Task/Roman-numerals-Decode/Fortran/roman-numerals-decode.f new file mode 100644 index 0000000000..30ed1f5bbf --- /dev/null +++ b/Task/Roman-numerals-Decode/Fortran/roman-numerals-decode.f @@ -0,0 +1,41 @@ +program Roman_decode + implicit none + + write(*,*) decode("MCMXC"), decode("MMVIII"), decode("MDCLXVI") + +contains + +function decode(roman) result(arabic) + character(*), intent(in) :: roman + integer :: i, n, lastval, arabic + + arabic = 0 + lastval = 0 + do i = len(roman), 1, -1 + select case(roman(i:i)) + case ('M','m') + n = 1000 + case ('D','d') + n = 500 + case ('C','c') + n = 100 + case ('L','l') + n = 50 + case ('X','x') + n = 10 + case ('V','v') + n = 5 + case ('I','i') + n = 1 + case default + n = 0 + end select + if (n < lastval) then + arabic = arabic - n + else + arabic = arabic + n + end if + lastval = n + end do +end function decode +end program Roman_decode diff --git a/Task/Roman-numerals-Decode/Go/roman-numerals-decode-1.go b/Task/Roman-numerals-Decode/Go/roman-numerals-decode-1.go new file mode 100644 index 0000000000..2a720a779c --- /dev/null +++ b/Task/Roman-numerals-Decode/Go/roman-numerals-decode-1.go @@ -0,0 +1,84 @@ +package main + +import ( + "errors" + "fmt" +) + +var m = map[rune]int{ + 'I': 1, + 'V': 5, + 'X': 10, + 'L': 50, + 'C': 100, + 'D': 500, + 'M': 1000, +} + +func parseRoman(s string) (r int, err error) { + if s == "" { + return 0, errors.New("Empty string") + } + is := []rune(s) // easier to convert string up front + var c0 rune // c0: roman character last read + var cv0 int // cv0: value of cv + + // the key to the algorithm is to process digits from right to left + for i := len(is) - 1; i >= 0; i-- { + // read roman digit + c := is[i] + k := c == 0x305 // unicode overbar combining character + if k { + if i == 0 { + return 0, errors.New( + "Overbar combining character invalid at position 0") + } + i-- + c = is[i] + } + cv := m[c] + if cv == 0 { + if c == 0x0305 { + return 0, errors.New(fmt.Sprintf( + "Overbar combining character invalid at position %d", i)) + } else { + return 0, errors.New(fmt.Sprintf( + "Character unrecognized as Roman digit: %c", c)) + } + } + if k { + c = -c // convention indicating overbar + cv *= 1000 + } + + // handle cases of new, same, subtractive, changed, in that order. + switch { + default: // case 4: digit change + fallthrough + case c0 == 0: // case 1: no previous digit + c0 = c + cv0 = cv + case c == c0: // case 2: same digit + case cv*5 == cv0 || cv*10 == cv0: // case 3: subtractive + // handle next digit as new. + // a subtractive digit doesn't count as a previous digit. + c0 = 0 + r -= cv // subtract... + continue // ...instead of adding + } + r += cv // add, in all cases except subtractive + } + return r, nil +} + +func main() { + // parse three numbers mentioned in task description + for _, r := range []string{"MCMXC", "MMVIII", "MDCLXVI"} { + v, err := parseRoman(r) + if err != nil { + fmt.Println(err) + } else { + fmt.Println(r, "==", v) + } + } +} diff --git a/Task/Roman-numerals-Decode/Go/roman-numerals-decode-2.go b/Task/Roman-numerals-Decode/Go/roman-numerals-decode-2.go new file mode 100644 index 0000000000..a0c94bf961 --- /dev/null +++ b/Task/Roman-numerals-Decode/Go/roman-numerals-decode-2.go @@ -0,0 +1,38 @@ +package main + +import ( + "fmt" + "strings" +) + +var m = map[string]int{ + "I": 1, + "V": 5, + "X": 10, + "L": 50, + "C": 100, + "D": 500, + "M": 1000, +} + +// function, per task description +func from_roman(roman string) (arabic int) { + last_digit := 1000 + for _, r := range strings.Split(roman, "") { + digit := m[r] + if last_digit < digit { + arabic -= 2 * last_digit + } + last_digit = digit + arabic += digit + } + + return arabic +} + +func main() { + // parse three numbers mentioned in task description + for _, roman_digit := range []string{"MCMXC", "MMVIII", "MDCLXVI"} { + fmt.Printf("%-10s == %d\n", roman_digit, from_roman(roman_digit)) + } +} diff --git a/Task/Roman-numerals-Decode/Groovy/roman-numerals-decode-1.groovy b/Task/Roman-numerals-Decode/Groovy/roman-numerals-decode-1.groovy new file mode 100644 index 0000000000..0fb4c7211e --- /dev/null +++ b/Task/Roman-numerals-Decode/Groovy/roman-numerals-decode-1.groovy @@ -0,0 +1,20 @@ +enum RomanDigits { + I(1), V(5), X(10), L(50), C(100), D(500), M(1000); + + private magnitude; + private RomanDigits(magnitude) { this.magnitude = magnitude } + + String toString() { super.toString() + "=${magnitude}" } + + static BigInteger parse(String numeral) { + assert numeral != null && !numeral.empty + def digits = (numeral as List).collect { + RomanDigits.valueOf(it) + } + def L = digits.size() + (0.. + def sign = (i == L - 1 || digits[i] >= digits[i+1]) ? 1 : -1 + total + sign * digits[i].magnitude + } + } +} diff --git a/Task/Roman-numerals-Decode/Groovy/roman-numerals-decode-2.groovy b/Task/Roman-numerals-Decode/Groovy/roman-numerals-decode-2.groovy new file mode 100644 index 0000000000..1c79744e98 --- /dev/null +++ b/Task/Roman-numerals-Decode/Groovy/roman-numerals-decode-2.groovy @@ -0,0 +1,12 @@ +println """ +Digit Values = ${RomanDigits.values()} +M => ${RomanDigits.parse('M')} +MCXI => ${RomanDigits.parse('MCXI')} +CMXI => ${RomanDigits.parse('CMXI')} +MCM => ${RomanDigits.parse('MCM')} +MCMXC => ${RomanDigits.parse('MCMXC')} +MMVIII => ${RomanDigits.parse('MMVIII')} +MMIX => ${RomanDigits.parse('MMIX')} +MCDXLIV => ${RomanDigits.parse('MCDXLIV')} +MDCLXVI => ${RomanDigits.parse('MDCLXVI')} +""" diff --git a/Task/Roman-numerals-Decode/Haskell/roman-numerals-decode.hs b/Task/Roman-numerals-Decode/Haskell/roman-numerals-decode.hs new file mode 100644 index 0000000000..63a6dcd2a4 --- /dev/null +++ b/Task/Roman-numerals-Decode/Haskell/roman-numerals-decode.hs @@ -0,0 +1,9 @@ +import Data.List (isPrefixOf) + +mapping = [("M",1000),("CM",900),("D",500),("CD",400),("C",100),("XC",90), + ("L",50),("XL",40),("X",10),("IX",9),("V",5),("IV",4),("I",1)] + +toArabic :: String -> Int +toArabic "" = 0 +toArabic str = num + toArabic xs + where (num, xs):_ = [ (num, drop (length n) str) | (n,num) <- mapping, isPrefixOf n str ] diff --git a/Task/Roman-numerals-Decode/Icon/roman-numerals-decode-1.icon b/Task/Roman-numerals-Decode/Icon/roman-numerals-decode-1.icon new file mode 100644 index 0000000000..5589e151c8 --- /dev/null +++ b/Task/Roman-numerals-Decode/Icon/roman-numerals-decode-1.icon @@ -0,0 +1,6 @@ +link numbers + +procedure main() +every R := "MCMXC"|"MDCLXVI"|"MMVIII" do + write(R, " = ",unroman(R)) +end diff --git a/Task/Roman-numerals-Decode/Icon/roman-numerals-decode-2.icon b/Task/Roman-numerals-Decode/Icon/roman-numerals-decode-2.icon new file mode 100644 index 0000000000..240208a5d8 --- /dev/null +++ b/Task/Roman-numerals-Decode/Icon/roman-numerals-decode-2.icon @@ -0,0 +1,20 @@ +procedure unroman(s) #: convert Roman numeral to integer + local nbr,lastVal,val + + nbr := lastVal := 0 + s ? { + while val := case map(move(1)) of { + "m": 1000 + "d": 500 + "c": 100 + "l": 50 + "x": 10 + "v": 5 + "i": 1 + } do { + nbr +:= if val <= lastVal then val else val - 2 * lastVal + lastVal := val + } + } + return nbr +end diff --git a/Task/Roman-numerals-Decode/J/roman-numerals-decode-1.j b/Task/Roman-numerals-Decode/J/roman-numerals-decode-1.j new file mode 100644 index 0000000000..e51aee5c30 --- /dev/null +++ b/Task/Roman-numerals-Decode/J/roman-numerals-decode-1.j @@ -0,0 +1 @@ +rom2d=: [: (+/ .* _1^ 0,~ 2':v),0} diff --git a/Task/Roman-numerals-Decode/K/roman-numerals-decode-2.k b/Task/Roman-numerals-Decode/K/roman-numerals-decode-2.k new file mode 100644 index 0000000000..8dbd03d068 --- /dev/null +++ b/Task/Roman-numerals-Decode/K/roman-numerals-decode-2.k @@ -0,0 +1,2 @@ + romd'("MCMXC";"MMVIII";"MDCLXVI") +1990 2008 1666 diff --git a/Task/Roman-numerals-Decode/Liberty-BASIC/roman-numerals-decode.liberty b/Task/Roman-numerals-Decode/Liberty-BASIC/roman-numerals-decode.liberty new file mode 100644 index 0000000000..fc27d9ed76 --- /dev/null +++ b/Task/Roman-numerals-Decode/Liberty-BASIC/roman-numerals-decode.liberty @@ -0,0 +1,43 @@ + print "MCMXCIX = "; romanDec( "MCMXCIX") '1999 + print "MDCLXVI = "; romanDec( "MDCLXVI") '1666 + print "XXV = "; romanDec( "XXV") '25 + print "CMLIV = "; romanDec( "CMLIV") '954 + print "MMXI = "; romanDec( "MMXI") '2011 + + end + +function romanDec( roman$) + arabic =0 + lastval =0 + + for i = len( roman$) to 1 step -1 + select case upper$( mid$( roman$, i, 1)) + case "M" + n = 1000 + case "D" + n = 500 + case "C" + n = 100 + case "L" + n = 50 + case "X" + n = 10 + case "V" + n = 5 + case "I" + n = 1 + case else + n = 0 + end select + + if n 1000 + | 'D' | 'd' -> 500 + | 'C' | 'c' -> 100 + | 'L' | 'l' -> 50 + | 'X' | 'x' -> 10 + | 'V' | 'v' -> 5 + | 'I' | 'i' -> 1 + | _ -> 0 + in + if n < !lastval + then arabic := !arabic - n + else arabic := !arabic + n; + lastval := n + done; + !arabic + +let () = + Printf.printf " %d\n" (decimal_of_roman "MCMXC"); + Printf.printf " %d\n" (decimal_of_roman "MMVIII"); + Printf.printf " %d\n" (decimal_of_roman "MDCLXVI"); +;; diff --git a/Task/Roman-numerals-Decode/PARI-GP/roman-numerals-decode.pari b/Task/Roman-numerals-Decode/PARI-GP/roman-numerals-decode.pari new file mode 100644 index 0000000000..3c77facf92 --- /dev/null +++ b/Task/Roman-numerals-Decode/PARI-GP/roman-numerals-decode.pari @@ -0,0 +1,17 @@ +fromRoman(s)={ + my(v=Vecsmall(s),key=vector(88),cur,t=0,tmp); + key[73]=1;key[86]=5;key[88]=10;key[76]=50;key[67]=100;key[68]=500;key[77]=1000; + cur=key[v[1]]; + for(i=2,#v, + tmp=key[v[i]]; + if(!cur, cur=tmp; next); + if(tmp>cur, + t+=tmp-cur; + cur=0 + , + t+=cur; + cur=tmp + ) + ); + t+cur +}; diff --git a/Task/Roman-numerals-Decode/PHP/roman-numerals-decode.php b/Task/Roman-numerals-Decode/PHP/roman-numerals-decode.php new file mode 100644 index 0000000000..dd2d446613 --- /dev/null +++ b/Task/Roman-numerals-Decode/PHP/roman-numerals-decode.php @@ -0,0 +1,86 @@ + + */ +$roman_to_decimal = array( + 'I' => 1, + 'V' => 5, + 'X' => 10, + 'L' => 50, + 'C' => 100, + 'D' => 500, + 'M' => 1000, +); + +/** + * @param $number + * @return int + */ +function roman2decimal($number) +{ + global $roman_to_decimal; + + // breaks the string into an array of chars + $digits = str_split($number); + $lastIndex = count($digits)-1; + $sum = 0; + + foreach($digits as $index => $digit) + { + if(!isset($digits[$index])) + { + continue; + } + + if(isset($roman_to_decimal[$digit])) + { + if($index < $lastIndex) + { + $left = $roman_to_decimal[$digits[$index]]; + $right = $roman_to_decimal[$digits[$index+1]]; + if($left < $right) + { + $sum += ($right - $left); + unset($digits[$index+1],$left, $right); + continue; + } + unset($left, $right); + } + } + $sum += $roman_to_decimal[$digit]; + } + + return $sum; +} + +/*============= OUTPUT =============*/ +header('Content-Type: text/plain'); + +$tests = array( + "I" => array(roman2decimal('I'), 1), + "II" => array(roman2decimal('II'), 2), + "III" => array(roman2decimal('III'), 3), + "IV" => array(roman2decimal('IV'), 4), + "V" => array(roman2decimal('V'), 5), + "VI" => array(roman2decimal('VI'), 6), + "VII" => array(roman2decimal('VII'), 7), + "IX" => array(roman2decimal('IX'), 9), + "X" => array(roman2decimal('X'), 10), + "XI" => array(roman2decimal('XI'), 11), + "XIV" => array(roman2decimal('XIV'), 14), + "XV" => array(roman2decimal('XV'), 15), + "XVI" => array(roman2decimal('XVI'), 16), + "XVIV" => array(roman2decimal('XVIV'), 19), + "XIX" => array(roman2decimal('XIX'), 19), + "MDCLXVI" => array(roman2decimal('MDCLXVI'), 1666), + "MCMXC" => array(roman2decimal('MCMXC'), 1990), + "MMVIII" => array(roman2decimal('MMVIII'), 2008), + "MMMCLIX" => array(roman2decimal('MMMCLIX'), 3159), + "MCMLXXVII" => array(roman2decimal('MCMLXXVII'), 1977), +); + + +foreach($tests as $key => $value) +{ + echo "($key == {$value[0]}) => " . ($value[0] === $value[1] ? "true" : "false, should be {$value[1]}.") . "\n"; +} diff --git a/Task/Roman-numerals-Decode/PL-I/roman-numerals-decode.pli b/Task/Roman-numerals-Decode/PL-I/roman-numerals-decode.pli new file mode 100644 index 0000000000..55de56f2b3 --- /dev/null +++ b/Task/Roman-numerals-Decode/PL-I/roman-numerals-decode.pli @@ -0,0 +1,46 @@ +test_decode: procedure options (main); /* 28 January 2013 */ + declare roman character (20) varying; + + do roman = 'i', 'ii', 'iii', 'iv', 'v', 'vi', 'vii', 'viii', 'iix', + 'ix', 'x', 'xi', 'xiv', 'MCMLXIV', 'MCMXC', 'MDCLXVI', + 'MIM', 'MM', 'MMXIII'; + put skip list (roman, decode(roman)); + end; + +decode: procedure (roman) returns (fixed(15)); + declare roman character (*) varying; + declare (current, previous) character (1); + declare n fixed (15); + declare i fixed binary; + + previous = ''; n = 0; + do i = length(roman) to 1 by -1; + current = substr(roman, i, 1); + if digit_value(current) < digit_value(previous) then + n = n - digit_value(current); + else if digit_value(current) > digit_value(previous) then + do; + n = n + digit_value(current); + previous = current; + end; + else + n = n + digit_value(current); + end; + return (n); +end decode; + +digit_value: procedure (roman_char) returns (fixed); + declare roman_char character(1); + select (roman_char); + when ('M', 'm') return (1000); + when ('D', 'd') return (500); + when ('C', 'c') return (100); + when ('L', 'l') return (50); + when ('X', 'x') return (10); + when ('V', 'v') return (5); + when ('I', 'i') return (1); + otherwise return (0); + end; +end digit_value; + +end test_decode; diff --git a/Task/Roman-numerals-Decode/PL-SQL/roman-numerals-decode.sql b/Task/Roman-numerals-Decode/PL-SQL/roman-numerals-decode.sql new file mode 100644 index 0000000000..5d31f69610 --- /dev/null +++ b/Task/Roman-numerals-Decode/PL-SQL/roman-numerals-decode.sql @@ -0,0 +1,83 @@ +/***************************************************************** + * $Author: Atanas Kebedjiev $ + ***************************************************************** + * PL/SQL code can be run as anonymous block. + * To test, execute the whole script or create the functions and then e.g. 'select rdecode('2012') from dual; + * Please note that task definition does not describe fully some current rules, such as + * * subtraction - IX XC CM are the valid subtraction combinations + * * A subtraction character cannot be repeated: 8 is expressed as VIII and not as IIX + * * V L and D cannot be used for subtraction + * * Any numeral cannot be repeated more than 3 times: 1910 should be MCMX and not MDCCCCX + * Code below does not validate the Roman numeral itself and will return a result even for a non-compliant number + * E.g. both MCMXCIX and IMM will return 1999 but the first one is the correct notation + */ + +DECLARE + +FUNCTION rvalue(c IN CHAR) RETURN NUMBER IS + i INTEGER; +BEGIN + i := 0; + CASE (c) + when 'M' THEN i := 1000; + when 'D' THEN i := 500; + when 'C' THEN i := 100; + when 'L' THEN i := 50; + when 'X' THEN i := 10; + when 'V' THEN i := 5; + when 'I' THEN i := 1; + END CASE; + RETURN i; +END; + + +FUNCTION decode(rn IN VARCHAR2) RETURN NUMBER IS + i INTEGER; + l INTEGER; + cr CHAR; -- current Roman numeral as substring from r + cv INTEGER; -- value of current Roman numeral + + gr CHAR; -- next Roman numeral + gv NUMBER; -- value of the next numeral; + + dv NUMBER; -- decimal value to return +BEGIN + l := length(rn); + i := 1; + dv := 0; + while (i <= l) + LOOP + cr := substr(rn,i,1); + cv := rvalue(cr); + + /* Look for a larger numeral in next position, like IV or CM + The number to subtract should be at least 1/10th of the bigger number + CM and XC are valid, but IC and XM are not */ + IF (i < l) THEN + gr := substr(rn,i+1,1); + gv := rvalue(gr); + IF (cv < gv ) THEN + dv := dv - cv; + ELSE + dv := dv + cv; + END IF; + ELSE + dv := dv + cv; + END IF; -- need to add the last value unconditionally + + i := i + 1; + END LOOP; + +RETURN dv; + +END; + +BEGIN + + DBMS_OUTPUT.PUT_LINE ('MMXII = ' || rdecode('MMXII')); -- 2012 + DBMS_OUTPUT.PUT_LINE ('MCMLI = ' || rdecode('MCMLI')); -- 1951 + DBMS_OUTPUT.PUT_LINE ('MCMLXXXVII = ' || rdecode('MCMLXXXVII')); -- 1987 + DBMS_OUTPUT.PUT_LINE ('MDCLXVI = ' || rdecode('MDCLXVI')); -- 1666 + DBMS_OUTPUT.PUT_LINE ('MCMXCIX = ' || rdecode('MCMXCIX')); -- 1999 + +END; diff --git a/Task/Roman-numerals-Decode/Perl-6/roman-numerals-decode-1.pl6 b/Task/Roman-numerals-Decode/Perl-6/roman-numerals-decode-1.pl6 new file mode 100644 index 0000000000..1ba5c34c96 --- /dev/null +++ b/Task/Roman-numerals-Decode/Perl-6/roman-numerals-decode-1.pl6 @@ -0,0 +1,23 @@ +sub rom-to-num($r) { + [+] gather $r.uc ~~ / + ^ + [ + | M { take 1000 } + | CM { take 900 } + | D { take 500 } + | CD { take 400 } + | C { take 100 } + | XC { take 90 } + | L { take 50 } + | XL { take 40 } + | X { take 10 } + | IX { take 9 } + | V { take 5 } + | IV { take 4 } + | I { take 1 } + ]+ + $ + /; +} + +say "$_ => &rom-to-num($_)" for ; diff --git a/Task/Roman-numerals-Decode/Perl-6/roman-numerals-decode-2.pl6 b/Task/Roman-numerals-Decode/Perl-6/roman-numerals-decode-2.pl6 new file mode 100644 index 0000000000..87b1b16acf --- /dev/null +++ b/Task/Roman-numerals-Decode/Perl-6/roman-numerals-decode-2.pl6 @@ -0,0 +1,15 @@ +sub rom-to-num($r) { + [+] gather $r.uc ~~ / + ^ + ( (C*)M { take 1000 - 100 * $0.chars } )* + ( (C*)D { take 500 - 100 * $0.chars } )? + ( (X*)C { take 100 - 10 * $0.chars } )* + ( (X*)L { take 50 - 10 * $0.chars } )? + ( (I*)X { take 10 - $0.chars } )* + ( (I*)V { take 5 - $0.chars } )? + ( I { take 1 } )* + [ $ || { return NaN } ] + /; +} + +say "$_ => ", rom-to-num($_) for ; diff --git a/Task/Roman-numerals-Decode/Perl/roman-numerals-decode.pl b/Task/Roman-numerals-Decode/Perl/roman-numerals-decode.pl new file mode 100644 index 0000000000..23e0d35577 --- /dev/null +++ b/Task/Roman-numerals-Decode/Perl/roman-numerals-decode.pl @@ -0,0 +1,25 @@ +use 5.10.0; + +{ + my @trans = ( + [M => 1000], [CM => 900], + [D => 500], [CD => 400], + [C => 100], [XC => 90], + [L => 50], [XL => 40], + [X => 10], [IX => 9], + [V => 5], [IV => 4], + [I => 1], + ); + + sub from_roman { + my $r = shift; + my $n = 0; + foreach my $pair (@trans) { + my ($k, $v) = @$pair; + $n += $v while $r =~ s/^$k//i; + } + return $n + } +} + +say "$_: ", from_roman($_) for qw(MCMXC MDCLXVI MMVIII); diff --git a/Task/Roman-numerals-Decode/PicoLisp/roman-numerals-decode.l b/Task/Roman-numerals-Decode/PicoLisp/roman-numerals-decode.l new file mode 100644 index 0000000000..86e766c2eb --- /dev/null +++ b/Task/Roman-numerals-Decode/PicoLisp/roman-numerals-decode.l @@ -0,0 +1,3 @@ +(de roman2decimal (Rom) + (let L (replace (chop Rom) 'M 1000 'D 500 'C 100 'L 50 'X 10 'V 5 'I 1) + (sum '((A B) (if (>= A B) A (- A))) L (cdr L)) ) ) diff --git a/Task/Roman-numerals-Decode/Prolog/roman-numerals-decode.pro b/Task/Roman-numerals-Decode/Prolog/roman-numerals-decode.pro new file mode 100644 index 0000000000..e0cadbf3bc --- /dev/null +++ b/Task/Roman-numerals-Decode/Prolog/roman-numerals-decode.pro @@ -0,0 +1,32 @@ +decode_digit(i, 1). +decode_digit(v, 5). +decode_digit(x, 10). +decode_digit(l, 50). +decode_digit(c, 100). +decode_digit(d, 500). +decode_digit(m, 1000). + +decode_string(Sum, _, [], Sum). + +decode_string(LastSum, LastValue, [Digit|Rest], NextSum) :- + decode_digit(Digit, Value), + Value < LastValue, + Sum is LastSum - Value, + decode_string(Sum, Value, Rest, NextSum). + +decode_string(LastSum, LastValue, [Digit|Rest], NextSum) :- + decode_digit(Digit, Value), + Value >= LastValue, + Sum is LastSum + Value, + decode_string(Sum, Value, Rest, NextSum). + +decode_string(Atom, Value) :- + atom_chars(Atom, String), + reverse(String, [Last|Rest]), + decode_digit(Last, Start), + decode_string(Start, Start, Rest, Value). + +test :- + decode_string(mcmxc, 1990), + decode_string(mmviii, 2008), + decode_string(mdclxvi, 1666). diff --git a/Task/Roman-numerals-Decode/PureBasic/roman-numerals-decode.purebasic b/Task/Roman-numerals-Decode/PureBasic/roman-numerals-decode.purebasic new file mode 100644 index 0000000000..a44b73f775 --- /dev/null +++ b/Task/Roman-numerals-Decode/PureBasic/roman-numerals-decode.purebasic @@ -0,0 +1,43 @@ +Procedure romanDec(roman.s) + Protected i, n, lastval, arabic + + For i = Len(roman) To 1 Step -1 + Select UCase(Mid(roman, i, 1)) + Case "M" + n = 1000 + Case "D" + n = 500 + Case "C" + n = 100 + Case "L" + n = 50 + Case "X" + n = 10 + Case "V" + n = 5 + Case "I" + n = 1 + Default + n = 0 + EndSelect + If (n < lastval) + arabic - n + Else + arabic + n + EndIf + lastval = n + Next + + ProcedureReturn arabic +EndProcedure + +If OpenConsole() + PrintN(Str(romanDec("MCMXCIX"))) ;1999 + PrintN(Str(romanDec("MDCLXVI"))) ;1666 + PrintN(Str(romanDec("XXV"))) ;25 + PrintN(Str(romanDec("CMLIV"))) ;954 + PrintN(Str(romanDec("MMXI"))) ;2011 + + Print(#CRLF$ + #CRLF$ + "Press ENTER to exit"): Input() + CloseConsole() +EndIf diff --git a/Task/Roman-numerals-Decode/Python/roman-numerals-decode-1.py b/Task/Roman-numerals-Decode/Python/roman-numerals-decode-1.py new file mode 100644 index 0000000000..c32ce9a51d --- /dev/null +++ b/Task/Roman-numerals-Decode/Python/roman-numerals-decode-1.py @@ -0,0 +1,12 @@ +_rdecode = dict(zip('MDCLXVI', (1000, 500, 100, 50, 10, 5, 1))) + +def decode( roman ): + result = 0 + for r, r1 in zip(roman, roman[1:]): + rd, rd1 = _rdecode[r], _rdecode[r1] + result += -rd if rd < rd1 else rd + return result + _rdecode[roman[-1]] + +if __name__ == '__main__': + for r in 'MCMXC MMVIII MDCLXVI'.split(): + print( r, decode(r) ) diff --git a/Task/Roman-numerals-Decode/Python/roman-numerals-decode-2.py b/Task/Roman-numerals-Decode/Python/roman-numerals-decode-2.py new file mode 100644 index 0000000000..5afb1f06d6 --- /dev/null +++ b/Task/Roman-numerals-Decode/Python/roman-numerals-decode-2.py @@ -0,0 +1,20 @@ +roman_values = (('I',1), ('IV',4), ('V',5), ('IX',9),('X',10),('XL',40),('L',50),('XC',90),('C',100), + ('CD', 400), ('D', 500), ('CM', 900), ('M',1000)) + +def roman_value(roman): + total=0 + for symbol,value in reversed(roman_values): + while roman.startswith(symbol): + total += value + roman = roman[len(symbol):] + return total + +if __name__=='__main__': + for value in "MCMXC", "MMVIII", "MDCLXVI": + print('%s = %i' % (value, roman_value(value))) + +""" Output: +MCMXC = 1990 +MMVIII = 2008 +MDCLXVI = 1666 +""" diff --git a/Task/Roman-numerals-Decode/REXX/roman-numerals-decode-1.rexx b/Task/Roman-numerals-Decode/REXX/roman-numerals-decode-1.rexx new file mode 100644 index 0000000000..1a6fe33f0e --- /dev/null +++ b/Task/Roman-numerals-Decode/REXX/roman-numerals-decode-1.rexx @@ -0,0 +1,63 @@ +/* Rexx */ + +Do + /* 1990 2008 1666 */ + years = 'MCMXC MMVIII MDCLXVI' + + Do y_ = 1 to words(years) + Say right(word(years, y_), 10) || ':' decode(word(years, y_)) + End y_ + + Return +End +Exit + +decode: + Procedure +Do + Parse upper arg roman . + + If verify(roman, 'MDCLXVI') = 0 then Do + + /* always insert the value of the least significant numeral */ + decnum = rchar(substr(roman, length(roman), 1)) + Do d_ = 1 to length(roman) - 1 + If rchar(substr(roman, d_, 1)) < rchar(substr(roman, d_ + 1, 1)) then Do + /* Handle cases where numerals are not in descending order */ + /* subtract the value of the numeral */ + decnum = decnum - rchar(substr(roman, d_, 1)) + End + else Do + /* Normal case */ + /* add the value of the numeral */ + decnum = decnum + rchar(substr(roman, d_, 1)) + End + End d_ + End + else Do + decnum = roman 'contains invalid roman numerals' + End + + Return decnum +End +Exit + +rchar: + Procedure +Do + Parse upper arg ch +1 . + + select + when ch = 'M' then digit = 1000 + when ch = 'D' then digit = 500 + when ch = 'C' then digit = 100 + when ch = 'L' then digit = 50 + when ch = 'X' then digit = 10 + when ch = 'V' then digit = 5 + when ch = 'I' then digit = 1 + otherwise digit = 0 + end + + Return digit +End +Exit diff --git a/Task/Roman-numerals-Decode/REXX/roman-numerals-decode-2.rexx b/Task/Roman-numerals-Decode/REXX/roman-numerals-decode-2.rexx new file mode 100644 index 0000000000..a8c666e459 --- /dev/null +++ b/Task/Roman-numerals-Decode/REXX/roman-numerals-decode-2.rexx @@ -0,0 +1,30 @@ +/*REXX program to convert Roman numeral number(s) to Arabic number(s). */ + +rYear='MCMXC' ; say right(rYear,9)':' rom2dec(rYear) +rYear='mmviii' ; say right(rYear,9)':' rom2dec(rYear) +rYear='MDCLXVI' ; say right(rYear,9)':' rom2dec(rYear) +exit + +rom2dec: procedure; arg roman . +if verify(roman,'MDCLXVI')\==0 then do + say 'invalid Roman number:' roman + return '***error!***' + end +#=rChar(right(roman,1)) /*start with the last numeral*/ + do j=1 for length(roman)-1 + x=rChar(substr(roman,j ,1)) /*the current Roman numeral. */ + y=rChar(substr(roman,j+1,1)) /*the next Roman numeral. */ + if xh then h=_ /*remember Roman numeral.*/ + if _next? Then sub. */ + else #=#+_ /* else add. */ + end /*k*/ +return # /*return Arabic number. */ diff --git a/Task/Roman-numerals-Decode/Ruby/roman-numerals-decode.rb b/Task/Roman-numerals-Decode/Ruby/roman-numerals-decode.rb new file mode 100644 index 0000000000..fb66df9cb7 --- /dev/null +++ b/Task/Roman-numerals-Decode/Ruby/roman-numerals-decode.rb @@ -0,0 +1,28 @@ +def fromRoman(roman) + r = roman.dup.upcase + n = 0 + until r.empty? do + case + when r.start_with?('M') then v = 1000; len = 1 + when r.start_with?('CM') then v = 900; len = 2 + when r.start_with?('D') then v = 500; len = 1 + when r.start_with?('CD') then v = 400; len = 2 + when r.start_with?('C') then v = 100; len = 1 + when r.start_with?('XC') then v = 90; len = 2 + when r.start_with?('L') then v = 50; len = 1 + when r.start_with?('XL') then v = 40; len = 2 + when r.start_with?('X') then v = 10; len = 1 + when r.start_with?('IX') then v = 9; len = 2 + when r.start_with?('V') then v = 5; len = 1 + when r.start_with?('IV') then v = 4; len = 2 + when r.start_with?('I') then v = 1; len = 1 + else + raise ArgumentError.new("invalid roman numerals: " + roman) + end + n += v + r[0 .. len-1] = "" + end + n +end + +[ "MCMXC", "MMVIII", "MDCLXVI" ].each {|r| pp [r, fromRoman(r)]} diff --git a/Task/Roman-numerals-Decode/Run-BASIC/roman-numerals-decode.run b/Task/Roman-numerals-Decode/Run-BASIC/roman-numerals-decode.run new file mode 100644 index 0000000000..aabb7d6765 --- /dev/null +++ b/Task/Roman-numerals-Decode/Run-BASIC/roman-numerals-decode.run @@ -0,0 +1,24 @@ +print "MCMXCIX = "; romToDec( "MCMXCIX") '1999 +print "MDCLXVI = "; romToDec( "MDCLXVI") '1666 +print "XXV = "; romToDec( "XXV") '25 +print "CMLIV = "; romToDec( "CMLIV") '954 +print "MMXI = "; romToDec( "MMXI") '2011 + +function romToDec(roman$) + for i = len(roman$) to 1 step -1 + x$ = mid$(roman$, i, 1) + n = 0 + if x$ = "M" then n = 1000 + if x$ = "D" then n = 500 + if x$ = "C" then n = 100 + if x$ = "L" then n = 50 + if x$ = "X" then n = 10 + if x$ = "V" then n = 5 + if x$ = "I" then n = 1 + + if n < preNum then num = num - n else num = num + n + preNum = n + next + + romToDec =num +end function diff --git a/Task/Roman-numerals-Decode/SNOBOL4/roman-numerals-decode-1.sno b/Task/Roman-numerals-Decode/SNOBOL4/roman-numerals-decode-1.sno new file mode 100644 index 0000000000..a9a27eef3e --- /dev/null +++ b/Task/Roman-numerals-Decode/SNOBOL4/roman-numerals-decode-1.sno @@ -0,0 +1,17 @@ +* Roman to Arabic + define('arabic(n)s,ch,val,sum,x') :(arabic_end) +arabic s = 'M1000 D500 C100 L50 X10 V5 I1 ' + n = reverse(n) +arab1 n len(1) . ch = :f(arab2) + s ch break(' ') . val + val = lt(val,x) (-1 * val) + sum = sum + val; x = val :(arab1) +arab2 arabic = sum :(return) +arabic_end + +* Test and display + tstr = 'MMX MCMXCIX MCDXCII MLXVI CDLXXVI " +tloop tstr break(' ') . r span(' ') = :f(out) + astr = astr r '=' arabic(r) ' ' :(tloop) +out output = astr +end diff --git a/Task/Roman-numerals-Decode/SNOBOL4/roman-numerals-decode-2.sno b/Task/Roman-numerals-Decode/SNOBOL4/roman-numerals-decode-2.sno new file mode 100644 index 0000000000..3d977b868a --- /dev/null +++ b/Task/Roman-numerals-Decode/SNOBOL4/roman-numerals-decode-2.sno @@ -0,0 +1,15 @@ +* Roman to Arabic + define("arabic1(romans,arabic1)rdigit,adigit,b4") + romans1 = " 0 IX9 IV4 III3 II2 I1 VIII8 VII7 VI6 V5" :(arabic1_end) +arabic1 ident(romans) :s(return) + romans (break("IV") | rem) . b4 rem . rdigit = b4 + romans1 " " rdigit any("0123456789") . adigit + arabic1 = adigit arabic1 + romans = replace(romans,"MDCLX","CLXVI") :(arabic1) +arabic1_end +* Test and display + tstr = "MMX MCMXCIX MCDXCII MLXVI CDLXXVI " +tloop tstr break(' ') . r span(' ') = :f(out) + astr = astr r '=' arabic1(r) ' ' :(tloop) +out output = astr +end diff --git a/Task/Roman-numerals-Decode/SNOBOL4/roman-numerals-decode-3.sno b/Task/Roman-numerals-Decode/SNOBOL4/roman-numerals-decode-3.sno new file mode 100644 index 0000000000..56c7e9de41 --- /dev/null +++ b/Task/Roman-numerals-Decode/SNOBOL4/roman-numerals-decode-3.sno @@ -0,0 +1,13 @@ +* Roman to Arabic + define("arabic1(romans,arabic1)rdigit,adigit,b4") + romans1 = " 0 IX9 IV4 III3 II2 I1 VIII8 VII7 VI6 V5" :(arabic1_end) +arabic1 ident(romans) :s(return) + romans (break("IV") | rem) . b4 rem . rdigit = replace(b4,"MDCLX","CLXVI") + romans1 " " rdigit any("0123456789") . adigit + arabic1 = adigit arabic1 :(arabic1) +arabic1_end +* Test and display + tstr = " MMX MCMXCIX MCDXCII MLXVI CDLXXVI " + tstr span(' ') break(' ') $ r *?(astr = astr r '=' arabic1(r) ' ') fail + output = astr +end diff --git a/Task/Roman-numerals-Decode/Scala/roman-numerals-decode.scala b/Task/Roman-numerals-Decode/Scala/roman-numerals-decode.scala new file mode 100644 index 0000000000..f737b1960d --- /dev/null +++ b/Task/Roman-numerals-Decode/Scala/roman-numerals-decode.scala @@ -0,0 +1,18 @@ +def fromRoman( r:String ) : Int = { + val arabicNumerals = List("CM"->900,"M"->1000,"CD"->400,"D"->500,"XC"->90,"C"->100, + "XL"->40,"L"->50,"IX"->9,"X"->10,"IV"->4,"V"->5,"I"->1) + + var s = r + arabicNumerals.foldLeft(0){ (n,t) => { + val l = s.length; s = s.replaceAll(t._1,""); val c = (l - s.length)/t._1.length // Get the frequency + n + (c*t._2) // Add the arabic numerals up + } } +} + + +// A small test +def test( roman:String ) = println( roman + " => " + fromRoman( roman ) ) + +test("MCMXC") +test("MMVIII") +test("MDCLXVI") diff --git a/Task/Roman-numerals-Decode/Seed7/roman-numerals-decode.seed7 b/Task/Roman-numerals-Decode/Seed7/roman-numerals-decode.seed7 new file mode 100644 index 0000000000..d4adc202d6 --- /dev/null +++ b/Task/Roman-numerals-Decode/Seed7/roman-numerals-decode.seed7 @@ -0,0 +1,36 @@ +$ include "seed7_05.s7i"; + +const func integer: ROMAN parse (in string: roman) is func + result + var integer: arabic is 0; + local + var integer: index is 0; + var integer: number is 0; + var integer: lastval is 0; + begin + for index range length(roman) downto 1 do + case roman[index] of + when {'M', 'm'}: number := 1000; + when {'D', 'd'}: number := 500; + when {'C', 'c'}: number := 100; + when {'L', 'l'}: number := 50; + when {'X', 'x'}: number := 10; + when {'V', 'v'}: number := 5; + when {'I', 'i'}: number := 1; + otherwise: raise RANGE_ERROR; + end case; + if number < lastval then + arabic -:= number; + else + arabic +:= number; + end if; + lastval := number; + end for; + end func; + +const proc: main is func + begin + writeln(ROMAN parse "MCMXC"); + writeln(ROMAN parse "MMVIII"); + writeln(ROMAN parse "MDCLXVI"); + end func; diff --git a/Task/Roman-numerals-Decode/TI-83-BASIC/roman-numerals-decode-1.ti-83 b/Task/Roman-numerals-Decode/TI-83-BASIC/roman-numerals-decode-1.ti-83 new file mode 100644 index 0000000000..4c4251615d --- /dev/null +++ b/Task/Roman-numerals-Decode/TI-83-BASIC/roman-numerals-decode-1.ti-83 @@ -0,0 +1,3 @@ +PROGRAM:ROM2DEC +:Input Str1 +:Disp real(21,Str1) diff --git a/Task/Roman-numerals-Decode/TI-83-BASIC/roman-numerals-decode-2.ti-83 b/Task/Roman-numerals-Decode/TI-83-BASIC/roman-numerals-decode-2.ti-83 new file mode 100644 index 0000000000..6958f77852 --- /dev/null +++ b/Task/Roman-numerals-Decode/TI-83-BASIC/roman-numerals-decode-2.ti-83 @@ -0,0 +1,20 @@ +PROGRAM:ROM2DEC +:Input "ROMAN:",Str1 +:{1000,500,100,50,10,5,1}➞L1 +:0➞P +:0➞Y +:For(I,length(Str1),1,-1) + :inString("MDCLXVI",sub(Str1,I,1))➞X + :If X≤0:Then + :Disp "BAD NUMBER" + :Stop + :End + :L1(x)➞N + :If N [fromRoman $r]" +} diff --git a/Task/Roman-numerals-Decode/Vedit-macro-language/roman-numerals-decode.vedit b/Task/Roman-numerals-Decode/Vedit-macro-language/roman-numerals-decode.vedit new file mode 100644 index 0000000000..41c56934c6 --- /dev/null +++ b/Task/Roman-numerals-Decode/Vedit-macro-language/roman-numerals-decode.vedit @@ -0,0 +1,38 @@ +// Main program for testing the function +// +do { + Get_Input(10, "Enter a roman numeral: ", NOCR+STATLINE) + Call("Roman_to_Arabic") + Reg_Type(10) Message(" = ") Num_Type(#1) +} while(#1) +Return + +// Convert Roman numeral into numeric value +// in: @10 = Roman numeral +// out: #1 = numeric value +// +:Roman_to_Arabic: + Buf_Switch(Buf_Free) + Ins_Text("M1000 D500 C100 L50 X10 V5 I1") Ins_Newline + Reg_Ins(10) Ins_Char(' ') + #1 = #2 = 0 + + Repeat(ALL) { + #3 = #2 // #3 = previous character + Goto_Line(2) // roman numeral to be converted + if (At_EOL) { + Break // all done + } + Reg_Copy_Block(11, CP, CP+1, DELETE) // next character in roman numeral + if (Search(@11, BEGIN+ADVANCE+NOERR)) { // find character from the table + #2 = Num_Eval(SUPPRESS) // corresponding numeric value + if (#2 > #3) { // larger than previous digit? + #1 -= #3 // substract previous digit + } else { + #1 += #3 // add previous digit + } + } + } + Reg_Empty(11) + Buf_Quit(OK) +Return diff --git a/Task/Roman-numerals-Decode/XPL0/roman-numerals-decode.xpl0 b/Task/Roman-numerals-Decode/XPL0/roman-numerals-decode.xpl0 new file mode 100644 index 0000000000..6b37046004 --- /dev/null +++ b/Task/Roman-numerals-Decode/XPL0/roman-numerals-decode.xpl0 @@ -0,0 +1,27 @@ +string 0; \use zero-terminated strings +code CrLf=9, IntOut=11; + +func Roman(Str); \Convert Roman numeral string to decimal value +char Str; +int I, Val, Val0, Sum; +[I:= 0; Sum:= 0; Val0:= 5000; +loop [case Str(I) of + ^M: Val:= 1000; + ^D: Val:= 500; + ^C: Val:= 100; + ^L: Val:= 50; + ^X: Val:= 10; + ^V: Val:= 5; + ^I: Val:= 1 + other return Sum; \zero string terminator + I:= I+1; + Sum:= Sum + Val; + if Val > Val0 then Sum:= Sum - 2*Val0; + Val0:= Val; + ]; +]; + +[IntOut(0, Roman("MCMXC")); CrLf(0); + IntOut(0, Roman("MMVIII")); CrLf(0); + IntOut(0, Roman("MDCLXVI")); CrLf(0); +] diff --git a/Task/Roman-numerals-Encode/0DESCRIPTION b/Task/Roman-numerals-Encode/0DESCRIPTION new file mode 100644 index 0000000000..834b23c809 --- /dev/null +++ b/Task/Roman-numerals-Encode/0DESCRIPTION @@ -0,0 +1,3 @@ +Create a function taking a positive integer as its parameter and returning a string containing the Roman Numeral representation of that integer. + +Modern Roman numerals are written by expressing each digit separately starting with the left most digit and skipping any digit with a value of zero. In Roman numerals 1990 is rendered: 1000=M, 900=CM, 90=XC; resulting in MCMXC. 2008 is written as 2000=MM, 8=VIII; or MMVIII. 1666 uses each Roman symbol in descending order: MDCLXVI. diff --git a/Task/Roman-numerals-Encode/ALGOL-68/roman-numerals-encode.alg b/Task/Roman-numerals-Encode/ALGOL-68/roman-numerals-encode.alg new file mode 100644 index 0000000000..c9589a927a --- /dev/null +++ b/Task/Roman-numerals-Encode/ALGOL-68/roman-numerals-encode.alg @@ -0,0 +1,29 @@ +[]CHAR roman = "MDCLXVmdclxvi"; # UPPERCASE for thousands # +[]CHAR adjust roman = "CCXXmmccxxii"; +[]INT arabic = (1000000, 500000, 100000, 50000, 10000, 5000, 1000, 500, 100, 50, 10, 5, 1); +[]INT adjust arabic = (100000, 100000, 10000, 10000, 1000, 1000, 100, 100, 10, 10, 1, 1, 0); + +PROC arabic to roman = (INT dclxvi)STRING: ( + INT in := dclxvi; # 666 # + STRING out := ""; + FOR scale TO UPB roman WHILE in /= 0 DO + INT multiples = in OVER arabic[scale]; + in -:= arabic[scale] * multiples; + out +:= roman[scale] * multiples; + IF in >= -adjust arabic[scale] + arabic[scale] THEN + in -:= -adjust arabic[scale] + arabic[scale]; + out +:= adjust roman[scale] + roman[scale] + FI + OD; + out +); + +main:( + []INT test = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,25,30,40,50,60,69,70, + 80,90,99,100,200,300,400,500,600,666,700,800,900,1000,1009,1444,1666,1945,1997,1999, + 2000,2008,2500,3000,4000,4999,5000,6666,10000,50000,100000,500000,1000000,max int); + FOR key TO UPB test DO + INT val = test[key]; + print((val, " - ", arabic to roman(val), new line)) + OD +) diff --git a/Task/Roman-numerals-Encode/ALGOL-W/roman-numerals-encode.alg b/Task/Roman-numerals-Encode/ALGOL-W/roman-numerals-encode.alg new file mode 100644 index 0000000000..374b8d7864 --- /dev/null +++ b/Task/Roman-numerals-Encode/ALGOL-W/roman-numerals-encode.alg @@ -0,0 +1,51 @@ +BEGIN + +PROCEDURE ROMAN (INTEGER VALUE NUMBER; STRING(15) RESULT CHARACTERS; INTEGER RESULT LENGTH); + COMMENT + Returns the Roman number of an integer between 1 and 3999. + "MMMDCCCLXXXVIII" (15 characters long) is the longest Roman number under 4000; + BEGIN + INTEGER PLACE, POWER; + + PROCEDURE APPEND (STRING(1) VALUE C); + BEGIN CHARACTERS(LENGTH|1) := C; LENGTH := LENGTH + 1 END; + + PROCEDURE I; APPEND(CASE PLACE OF ("I","X","C","M")); + PROCEDURE V; APPEND(CASE PLACE OF ("V","L","D")); + PROCEDURE X; APPEND(CASE PLACE OF ("X","C","M")); + + ASSERT (NUMBER >= 1) AND (NUMBER < 4000); + + CHARACTERS := " "; + LENGTH := 0; + POWER := 1000; + PLACE := 4; + WHILE PLACE > 0 DO + BEGIN + CASE NUMBER DIV POWER + 1 OF BEGIN + BEGIN END; + BEGIN I END; + BEGIN I; I END; + BEGIN I; I; I END; + BEGIN I; V END; + BEGIN V END; + BEGIN V; I END; + BEGIN V; I; I END; + BEGIN V; I; I; I END; + BEGIN I; X END + END; + NUMBER := NUMBER REM POWER; + POWER := POWER DIV 10; + PLACE := PLACE - 1 + END + END ROMAN; + +INTEGER I; +STRING(15) S; + +ROMAN(1, S, I); WRITE(S, I); +ROMAN(3999, S, I); WRITE(S, I); +ROMAN(3888, S, I); WRITE(S, I); +ROMAN(2009, S, I); WRITE(S, I); +ROMAN(405, S, I); WRITE(S, I); +END. diff --git a/Task/Roman-numerals-Encode/AWK/roman-numerals-encode.awk b/Task/Roman-numerals-Encode/AWK/roman-numerals-encode.awk new file mode 100644 index 0000000000..af362acabb --- /dev/null +++ b/Task/Roman-numerals-Encode/AWK/roman-numerals-encode.awk @@ -0,0 +1,26 @@ +# syntax: GAWK -f ROMAN_NUMERALS_ENCODE.AWK +BEGIN { + leng = split("1990 2008 1666",arr," ") + for (i=1; i<=leng; i++) { + n = arr[i] + printf("%s = %s\n",n,dec2roman(n)) + } + exit(0) +} +function dec2roman(number, v,w,x,y,roman1,roman10,roman100,roman1000) { + number = int(number) # force to integer + if (number < 1 || number > 3999) { # number is too small | big + return + } + split("I II III IV V VI VII VIII IX",roman1," ") # 1 2 ... 9 + split("X XX XXX XL L LX LXX LXXX XC",roman10," ") # 10 20 ... 90 + split("C CC CCC CD D DC DCC DCCC CM",roman100," ") # 100 200 ... 900 + split("M MM MMM",roman1000," ") # 1000 2000 3000 + v = (number - (number % 1000)) / 1000 + number = number % 1000 + w = (number - (number % 100)) / 100 + number = number % 100 + x = (number - (number % 10)) / 10 + y = number % 10 + return(roman1000[v] roman100[w] roman10[x] roman1[y]) +} diff --git a/Task/Roman-numerals-Encode/ActionScript/roman-numerals-encode-1.as b/Task/Roman-numerals-Encode/ActionScript/roman-numerals-encode-1.as new file mode 100644 index 0000000000..693dc6441d --- /dev/null +++ b/Task/Roman-numerals-Encode/ActionScript/roman-numerals-encode-1.as @@ -0,0 +1,14 @@ +function arabic2roman(num:Number):String { + var lookup:Object = {M:1000, CM:900, D:500, CD:400, C:100, XC:90, L:50, XL:40, X:10, IX:9, V:5, IV:4, I:1}; + var roman:String = "", i:String; + for (i in lookup) { + while (num >= lookup[i]) { + roman += i; + num -= lookup[i]; + } + } + return roman; +} +trace("1990 in roman is " + arabic2roman(1990)); +trace("2008 in roman is " + arabic2roman(2008)); +trace("1666 in roman is " + arabic2roman(1666)); diff --git a/Task/Roman-numerals-Encode/ActionScript/roman-numerals-encode-2.as b/Task/Roman-numerals-Encode/ActionScript/roman-numerals-encode-2.as new file mode 100644 index 0000000000..15cb742bbd --- /dev/null +++ b/Task/Roman-numerals-Encode/ActionScript/roman-numerals-encode-2.as @@ -0,0 +1,13 @@ +function roman2arabic(roman:String):Number { + var romanArr:Array = roman.toUpperCase().split(''); + var lookup:Object = {I:1, V:5, X:10, L:50, C:100, D:500, M:1000}; + var num:Number = 0, val:Number = 0; + while (romanArr.length) { + val = lookup[romanArr.shift()]; + num += val * (val < lookup[romanArr[0]] ? -1 : 1); + } + return num; +} +trace("MCMXC in arabic is " + roman2arabic("MCMXC")); +trace("MMVIII in arabic is " + roman2arabic("MMVIII")); +trace("MDCLXVI in arabic is " + roman2arabic("MDCLXVI")); diff --git a/Task/Roman-numerals-Encode/Ada/roman-numerals-encode.ada b/Task/Roman-numerals-Encode/Ada/roman-numerals-encode.ada new file mode 100644 index 0000000000..434728d4f9 --- /dev/null +++ b/Task/Roman-numerals-Encode/Ada/roman-numerals-encode.ada @@ -0,0 +1,33 @@ +with Ada.Text_IO; use Ada.Text_IO; + +procedure Roman_Numeral_Test is + function To_Roman (Number : Positive) return String is + subtype Digit is Integer range 0..9; + function Roman (Figure : Digit; I, V, X : Character) return String is + begin + case Figure is + when 0 => return ""; + when 1 => return "" & I; + when 2 => return I & I; + when 3 => return I & I & I; + when 4 => return I & V; + when 5 => return "" & V; + when 6 => return V & I; + when 7 => return V & I & I; + when 8 => return V & I & I & I; + when 9 => return I & X; + end case; + end Roman; + begin + pragma Assert (Number >= 1 and Number < 4000); + return + Roman (Number / 1000, 'M', ' ', ' ') & + Roman (Number / 100 mod 10, 'C', 'D', 'M') & + Roman (Number / 10 mod 10, 'X', 'L', 'C') & + Roman (Number mod 10, 'I', 'V', 'X'); + end To_Roman; +begin + Put_Line (To_Roman (1999)); + Put_Line (To_Roman (25)); + Put_Line (To_Roman (944)); +end Roman_Numeral_Test; diff --git a/Task/Roman-numerals-Encode/AutoHotkey/roman-numerals-encode.ahk b/Task/Roman-numerals-Encode/AutoHotkey/roman-numerals-encode.ahk new file mode 100644 index 0000000000..b60b8c58af --- /dev/null +++ b/Task/Roman-numerals-Encode/AutoHotkey/roman-numerals-encode.ahk @@ -0,0 +1,28 @@ +MsgBox % stor(444) + +stor(value) +{ + romans = M,CM,D,CD,C,XC,L,XL,X,IX,V,IV,I + M := 1000 + CM := 900 + D := 500 + CD := 400 + C := 100 + XC := 90 + L := 50 + XL := 40 + X := 10 + IX := 9 + V := 5 + IV := 4 + I := 1 + Loop, Parse, romans, `, + { + While, value >= %A_LoopField% + { + result .= A_LoopField + value := value - (%A_LoopField%) + } + } + Return result . "O" +} diff --git a/Task/Roman-numerals-Encode/BASIC/roman-numerals-encode-1.basic b/Task/Roman-numerals-Encode/BASIC/roman-numerals-encode-1.basic new file mode 100644 index 0000000000..8c2bc4bb2b --- /dev/null +++ b/Task/Roman-numerals-Encode/BASIC/roman-numerals-encode-1.basic @@ -0,0 +1,20 @@ +DIM SHARED arabic(0 TO 12) AS Integer => {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 } +DIM SHARED roman(0 TO 12) AS String*2 => {"M", "CM", "D","CD", "C","XC","L","XL","X","IX","V","IV","I"} + +FUNCTION toRoman(value AS Integer) AS String + DIM i AS Integer + DIM result AS String + + FOR i = 0 TO 12 + DO WHILE value >= arabic(i) + result = result + roman(i) + value = value - arabic(i) + LOOP + NEXT i + toRoman = result +END FUNCTION + +'Testing +PRINT "2009 = "; toRoman(2009) +PRINT "1666 = "; toRoman(1666) +PRINT "3888 = "; toRoman(3888) diff --git a/Task/Roman-numerals-Encode/BASIC/roman-numerals-encode-2.basic b/Task/Roman-numerals-Encode/BASIC/roman-numerals-encode-2.basic new file mode 100644 index 0000000000..61eedbe38f --- /dev/null +++ b/Task/Roman-numerals-Encode/BASIC/roman-numerals-encode-2.basic @@ -0,0 +1,17 @@ + 10 DATA 1000,"M",900,"CM" + 20 DATA 500,"D",400,"CD" + 30 DATA 100,"C",90,"XC" + 40 DATA 50,"L",40,"XL" + 50 DATA 10,"X",9,"IX" + 60 DATA 5,"V",4,"IV",1,"I" + 70 INPUT "Enter an arabic number: ";V + 80 LET VALUE=V + 90 LET V$="" +100 FOR I=0 TO 12 +110 READ A,R$ +120 IF V= arabic[i] + convert$ += roman$[i] + value = value - arabic[i] + end while + next i +end function diff --git a/Task/Roman-numerals-Encode/BBC-BASIC/roman-numerals-encode.bbc b/Task/Roman-numerals-Encode/BBC-BASIC/roman-numerals-encode.bbc new file mode 100644 index 0000000000..51d0ab1560 --- /dev/null +++ b/Task/Roman-numerals-Encode/BBC-BASIC/roman-numerals-encode.bbc @@ -0,0 +1,18 @@ + PRINT ;1999, FNroman(1999) + PRINT ;2012, FNroman(2012) + PRINT ;1666, FNroman(1666) + PRINT ;3888, FNroman(3888) + END + + DEF FNroman(n%) + LOCAL i%, r$, arabic%(), roman$() + DIM arabic%(12), roman$(12) + arabic%() = 1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900,1000 + roman$() = "I","IV", "V","IX", "X","XL", "L","XC", "C","CD", "D","CM", "M" + FOR i% = 12 TO 0 STEP -1 + WHILE n% >= arabic%(i%) + r$ += roman$(i%) + n% -= arabic%(i%) + ENDWHILE + NEXT + = r$ diff --git a/Task/Roman-numerals-Encode/Bracmat/roman-numerals-encode.bracmat b/Task/Roman-numerals-Encode/Bracmat/roman-numerals-encode.bracmat new file mode 100644 index 0000000000..2210433f65 --- /dev/null +++ b/Task/Roman-numerals-Encode/Bracmat/roman-numerals-encode.bracmat @@ -0,0 +1,49 @@ +( ( encode + = indian roman cifr tenfoldroman letter tenfold + . !arg:#?indian + & :?roman + & whl + ' ( @(!indian:#%?cifr ?indian) + & :?tenfoldroman + & whl + ' ( !roman:%?letter ?roman + & !tenfoldroman + ( (I.X) + (V.L) + (X.C) + (L.D) + (C.M) + : ? (!letter.?tenfold) ? + & !tenfold + | "*" + ) + : ?tenfoldroman + ) + & !tenfoldroman:?roman + & ( !cifr:9&!roman I X:?roman + | !cifr:~<4 + & !roman + (!cifr:4&I|) + V + : ?roman + & !cifr+-5:?cifr + & ~ + | whl + ' ( !cifr+-1:~<0:?cifr + & !roman I:?roman + ) + ) + ) + & ( !roman:? "*" ?&~` + | str$!roman + ) + ) +& 1990 2008 1666 3888 3999 4000:?NS +& whl + ' ( !NS:%?N ?NS + & out + $ ( encode$!N:?K&!N !K + | str$("Can't convert " !N " to Roman numeral") + ) + ) +); diff --git a/Task/Roman-numerals-Encode/C++/roman-numerals-encode.cpp b/Task/Roman-numerals-Encode/C++/roman-numerals-encode.cpp new file mode 100644 index 0000000000..d5079420d6 --- /dev/null +++ b/Task/Roman-numerals-Encode/C++/roman-numerals-encode.cpp @@ -0,0 +1,41 @@ +#include +#include + +std::string to_roman(int value) +{ + struct romandata_t { int value; char const* numeral; }; + static romandata_t const romandata[] = + { 1000, "M", + 900, "CM", + 500, "D", + 400, "CD", + 100, "C", + 90, "XC", + 50, "L", + 40, "XL", + 10, "X", + 9, "IX", + 5, "V", + 4, "IV", + 1, "I", + 0, NULL }; // end marker + + std::string result; + for (romandata_t const* current = romandata; current->value > 0; ++current) + { + while (value >= current->value) + { + result += current->numeral; + value -= current->value; + } + } + return result; +} + +int main() +{ + for (int i = 1; i <= 4000; ++i) + { + std::cout << to_roman(i) << std::endl; + } +} diff --git a/Task/Roman-numerals-Encode/C/roman-numerals-encode-1.c b/Task/Roman-numerals-Encode/C/roman-numerals-encode-1.c new file mode 100644 index 0000000000..4b2603f4d1 --- /dev/null +++ b/Task/Roman-numerals-Encode/C/roman-numerals-encode-1.c @@ -0,0 +1,59 @@ +#include +#include + +/* + * Writes the Roman numeral representing n into the buffer s. + * Handles up to n = 3999. + * Since C doesn't have exceptions, n = 0 causes the whole program to exit + * unsuccessfully. + * s should be have room for at least 16 characters, including the trailing + * null. + */ +void roman(char *s, unsigned int n) +{ + if (n == 0) + { + fputs(stderr, "Roman numeral for zero requested."); + exit(EXIT_FAILURE); + } + + #define digit(loop, num, c) \ + loop (n >= num) \ + {*(s++) = c; \ + n -= num;} + #define digits(loop, num, c1, c2) \ + loop (n >= num) \ + {*(s++) = c1; \ + *(s++) = c2; \ + n -= num;} + + digit ( while, 1000, 'M' ) + digits ( if, 900, 'C', 'M' ) + digit ( if, 500, 'D' ) + digits ( if, 400, 'C', 'D' ) + digit ( while, 100, 'C' ) + digits ( if, 90, 'X', 'C' ) + digit ( if, 50, 'L' ) + digits ( if, 40, 'X', 'L' ) + digit ( while, 10, 'X' ) + digits ( if, 9, 'I', 'X' ) + digit ( if, 5, 'V' ) + digits ( if, 4, 'I', 'V' ) + digit ( while, 1, 'I' ) + + #undef digit + #undef digits + + *s = 0;} + +int main(void) +{ + char buffer[16]; + unsigned int i; + for (i = 1 ; i < 4000 ; ++i) + { + roman(buffer, i); + printf("%4u: %s\n", i, buffer); + } + return EXIT_SUCCESS; +} diff --git a/Task/Roman-numerals-Encode/C/roman-numerals-encode-2.c b/Task/Roman-numerals-Encode/C/roman-numerals-encode-2.c new file mode 100644 index 0000000000..71cfb76f94 --- /dev/null +++ b/Task/Roman-numerals-Encode/C/roman-numerals-encode-2.c @@ -0,0 +1,38 @@ +char *ToRoman(int num, char *buf, int buflen) +{ + static const char romanDgts[] = "ivxlcdmVXLCDM_"; + char *roman = buf + buflen; + int rdix, r, v; + *--roman = '\0'; /* null terminate return string */ + if (num >= 4000000) { + printf("Number Too Big.\n"); + return NULL; + } + for (rdix = 0; rdix < strlen(romanDgts); rdix += 2) { + if (num == 0) break; + v = (num % 10) / 5; + r = num % 5; + num = num / 10; + if (r == 4) { + if (roman < buf+2) { + printf("Buffer too small."); + return NULL; + } + *--roman = romanDgts[rdix+1+v]; + *--roman = romanDgts[rdix]; + } + else { + if (roman < buf+r+v) { + printf("Buffer too small."); + return NULL; + } + while(r-- > 0) { + *--roman = romanDgts[rdix]; + } + if (v==1) { + *--roman = romanDgts[rdix+1]; + } + } + } + return roman; +} diff --git a/Task/Roman-numerals-Encode/C/roman-numerals-encode-3.c b/Task/Roman-numerals-Encode/C/roman-numerals-encode-3.c new file mode 100644 index 0000000000..509db34e8c --- /dev/null +++ b/Task/Roman-numerals-Encode/C/roman-numerals-encode-3.c @@ -0,0 +1,40 @@ +#include + +int to_roman(char *out, int n) +{ + int len = 0; + if (n <= 0) return 0; /* error indication */ +# define RPUT(c) if (out) out[len] = c; len++ + while(n>= 1000) { n -= 1000;RPUT('M'); }; + + if (n >= 900) { n -= 900; RPUT('C'); RPUT('M'); }; + if (n >= 500) { n -= 500; RPUT('D'); }; + if (n >= 400) { n -= 400; RPUT('C'); RPUT('D'); }; + while (n >= 100){ n -= 100; RPUT('C'); }; + + if (n >= 90) { n -= 90; RPUT('X'); RPUT('C'); }; + if (n >= 50) { n -= 50; RPUT('L'); }; + if (n >= 40) { n -= 40; RPUT('X'); RPUT('L'); }; + while (n >= 10) { n -= 10; RPUT('X'); }; + + if (n >= 9) { n -= 9; RPUT('I'); RPUT('X'); }; + if (n >= 5) { n -= 5; RPUT('V'); }; + if (n >= 4) { n -= 4; RPUT('I'); RPUT('V'); }; + while (n) { n--; RPUT('I'); }; + RPUT('\0'); +# undef RPUT + + return len; +} + +int main() +{ + char buf[16]; + int d = to_roman(buf, 1666); + printf("roman for 1666 is %d bytes: %s\n", d, buf); + + d = 68999123; + printf("%d would have required %d bytes\n", d, to_roman(0, d)); + + return 0; +} diff --git a/Task/Roman-numerals-Encode/Clojure/roman-numerals-encode-1.clj b/Task/Roman-numerals-Encode/Clojure/roman-numerals-encode-1.clj new file mode 100644 index 0000000000..939eec0055 --- /dev/null +++ b/Task/Roman-numerals-Encode/Clojure/roman-numerals-encode-1.clj @@ -0,0 +1,7 @@ +(def arabic->roman + (partial clojure.pprint/cl-format nil "~@R")) + +(arabic->roman 147) +;"CXXIII" +(arabic->roman 99) +;"XCIX" diff --git a/Task/Roman-numerals-Encode/Clojure/roman-numerals-encode-2.clj b/Task/Roman-numerals-Encode/Clojure/roman-numerals-encode-2.clj new file mode 100644 index 0000000000..09e2374072 --- /dev/null +++ b/Task/Roman-numerals-Encode/Clojure/roman-numerals-encode-2.clj @@ -0,0 +1,31 @@ +(def arabic-roman-map + {1 "I", 5 "V", + 10 "X", 50 "L", + 100 "C", 500 "D", + 1000 "M", + 4 "IV", 9 "IX", + 40 "XL", 90 "XC", + 400 "CD", 900 "CM" }) + +(def arabic-roman-map-sorted-keys + (sort (keys arabic-roman-map))) + +(defn find-value-in-coll + [coll k] + (let [aval (find coll k)] + (if (nil? aval) "" (val aval)))) + +(defn to-roman + [result n] + (let + [closest-key-for-n (last (filter #(> n %) arabic-roman-map-sorted-keys)) + roman-value-for-n (find-value-in-coll arabic-roman-map n) + roman-value-for-closet-to-n (find-value-in-coll arabic-roman-map + closest-key-for-n)] + (if (or (<= n 0)(contains? arabic-roman-map n)) + (conj result roman-value-for-n) + (recur (conj result roman-value-for-closet-to-n) + (- n closest-key-for-n))))) + +Usage: >(to-roman [] 1999) +result: ["M" "CM" "XC" "IX"] diff --git a/Task/Roman-numerals-Encode/Clojure/roman-numerals-encode-3.clj b/Task/Roman-numerals-Encode/Clojure/roman-numerals-encode-3.clj new file mode 100644 index 0000000000..a328e2ad8f --- /dev/null +++ b/Task/Roman-numerals-Encode/Clojure/roman-numerals-encode-3.clj @@ -0,0 +1,17 @@ +(defn a2r + [a] + (let [rv [1000 500 100 50 10 5 1] + rm (zipmap rv "MDCLXVI") + dv (->> rv (take-nth 2) next (#(interleave % %)))] + (loop [a a rv rv dv dv r nil] + (if (<= a 0) + r + (let [v (first rv) + d (or (first dv) 0) + l (- v d)] + (cond + (= a v) (str r (rm v)) + (= a l) (str r (rm d) (rm v)) + (and (> a v) (> a l)) (recur (- a v) rv dv (str r (rm v))) + (and (< a v) (< a l)) (recur a (rest rv) (rest dv) r) + :else (recur (- a l) (rest rv) (rest dv) (str r (rm d) (rm v))))))))) diff --git a/Task/Roman-numerals-Encode/Clojure/roman-numerals-encode-4.clj b/Task/Roman-numerals-Encode/Clojure/roman-numerals-encode-4.clj new file mode 100644 index 0000000000..a27d77242b --- /dev/null +++ b/Task/Roman-numerals-Encode/Clojure/roman-numerals-encode-4.clj @@ -0,0 +1,5 @@ +(a2r 1666) +"MDCLXVI" + +(map a2r [1000 1 389 45]) +("M" "I" "CCCLXXXIX" "XLV") diff --git a/Task/Roman-numerals-Encode/CoffeeScript/roman-numerals-encode.coffeescript b/Task/Roman-numerals-Encode/CoffeeScript/roman-numerals-encode.coffeescript new file mode 100644 index 0000000000..b9848edee2 --- /dev/null +++ b/Task/Roman-numerals-Encode/CoffeeScript/roman-numerals-encode.coffeescript @@ -0,0 +1,46 @@ +decimal_to_roman = (n) -> + # This should work for any positive integer, although it + # gets a bit preposterous for large numbers. + if n >= 4000 + thousands = decimal_to_roman n / 1000 + ones = decimal_to_roman n % 1000 + return "M(#{thousands})#{ones}" + + s = '' + translate_each = (min, roman) -> + while n >= min + n -= min + s += roman + translate_each 1000, "M" + translate_each 900, "CM" + translate_each 500, "D" + translate_each 400, "CD" + translate_each 100, "C" + translate_each 90, "XC" + translate_each 50, "L" + translate_each 40, "XL" + translate_each 10, "X" + translate_each 9, "IX" + translate_each 5, "V" + translate_each 4, "IV" + translate_each 1, "I" + s + +################### +tests = + IV: 4 + XLII: 42 + MCMXC: 1990 + MMVIII: 2008 + MDCLXVI: 1666 + 'M(IV)': 4000 + 'M(VI)IX': 6009 + 'M(M(CXXIII)CDLVI)DCCLXXXIX': 123456789 + 'M(MMMV)I': 3005001 + +for expected, decimal of tests + roman = decimal_to_roman(decimal) + if roman == expected + console.log "#{decimal} = #{roman}" + else + console.log "error for #{decimal}: #{roman} is wrong" diff --git a/Task/Roman-numerals-Encode/Common-Lisp/roman-numerals-encode.lisp b/Task/Roman-numerals-Encode/Common-Lisp/roman-numerals-encode.lisp new file mode 100644 index 0000000000..f95461dcdd --- /dev/null +++ b/Task/Roman-numerals-Encode/Common-Lisp/roman-numerals-encode.lisp @@ -0,0 +1,2 @@ +(defun roman-numeral (n) + (format nil "~@R" n)) diff --git a/Task/Roman-numerals-Encode/D/roman-numerals-encode.d b/Task/Roman-numerals-Encode/D/roman-numerals-encode.d new file mode 100644 index 0000000000..f331ca161c --- /dev/null +++ b/Task/Roman-numerals-Encode/D/roman-numerals-encode.d @@ -0,0 +1,26 @@ +string toRoman(int n) pure nothrow +in { + assert(n < 5000); +} body { + static immutable weights = [1000, 900, 500, 400, 100, 90, + 50, 40, 10, 9, 5, 4, 1]; + static immutable symbols = ["M","CM","D","CD","C","XC","L", + "XL","X","IX","V","IV","I"]; + + string roman; + foreach (i, w; weights) { + while (n >= w) { + roman ~= symbols[i]; + n -= w; + } + if (n == 0) + break; + } + return roman; +} unittest { + assert(toRoman(455) == "CDLV"); + assert(toRoman(3456) == "MMMCDLVI"); + assert(toRoman(2488) == "MMCDLXXXVIII"); +} + +void main() {} diff --git a/Task/Roman-numerals-Encode/DWScript/roman-numerals-encode.dwscript b/Task/Roman-numerals-Encode/DWScript/roman-numerals-encode.dwscript new file mode 100644 index 0000000000..4563d8c0a1 --- /dev/null +++ b/Task/Roman-numerals-Encode/DWScript/roman-numerals-encode.dwscript @@ -0,0 +1,20 @@ +const weights = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]; +const symbols = ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"]; + +function toRoman(n : Integer) : String; +var + i, w : Integer; +begin + for i := 0 to weights.High do begin + w := weights[i]; + while n >= w do begin + Result += symbols[i]; + n -= w; + end; + if n = 0 then Break; + end; +end; + +PrintLn(toRoman(455)); +PrintLn(toRoman(3456)); +PrintLn(toRoman(2488)); diff --git a/Task/Roman-numerals-Encode/Delphi/roman-numerals-encode.delphi b/Task/Roman-numerals-Encode/Delphi/roman-numerals-encode.delphi new file mode 100644 index 0000000000..8e85c216a1 --- /dev/null +++ b/Task/Roman-numerals-Encode/Delphi/roman-numerals-encode.delphi @@ -0,0 +1,28 @@ +program RomanNumeralsEncode; + +{$APPTYPE CONSOLE} + +function IntegerToRoman(aValue: Integer): string; +var + i: Integer; +const + WEIGHTS: array[0..12] of Integer = (1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1); + SYMBOLS: array[0..12] of string = ('M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I'); +begin + for i := Low(WEIGHTS) to High(WEIGHTS) do + begin + while aValue >= WEIGHTS[i] do + begin + Result := Result + SYMBOLS[i]; + aValue := aValue - WEIGHTS[i]; + end; + if aValue = 0 then + Break; + end; +end; + +begin + Writeln(IntegerToRoman(1990)); // MCMXC + Writeln(IntegerToRoman(2008)); // MMVIII + Writeln(IntegerToRoman(1666)); // MDCLXVI +end. diff --git a/Task/Roman-numerals-Encode/Emacs-Lisp/roman-numerals-encode.l b/Task/Roman-numerals-Encode/Emacs-Lisp/roman-numerals-encode.l new file mode 100644 index 0000000000..987f6a1150 --- /dev/null +++ b/Task/Roman-numerals-Encode/Emacs-Lisp/roman-numerals-encode.l @@ -0,0 +1,17 @@ +(defun ar2ro (AN) + "translate from arabic number AN to roman number, + ar2ro(1666) returns (M D C L X V I)" + (cond + ((>= AN 1000) (cons 'M (ar2ro (- AN 1000)))) + ((>= AN 900) (cons 'C (cons 'M (ar2ro (-AN 900))))) + ((>= AN 500) (cons 'D (ar2ro (- AN 500)))) + ((>= AN 400) (cons 'C (cons 'D (ar2ro (- AN 400))))) + ((>= AN 100) (cons 'C (ar2ro (- AN 100)))) + ((>= AN 90) (cons 'X (cons 'C (ar2ro (- AN 90))))) + ((>= AN 50) (cons 'L (ar2ro (- AN 50)))) + ((>= AN 40) (cons 'X (cons 'L (ar2ro (- AN 40))))) + ((>= AN 10) (cons 'X (ar2ro (- AN 10)))) + ((>= AN 5) (cons 'V (ar2ro (- AN 5)))) + ((>= AN 4) (cons 'I (cons 'V (ar2ro (- AN 4))))) + ((>= AN 1) (cons 'I (ar2ro (- AN 1)))) + ((= AN 0) nil))) diff --git a/Task/Roman-numerals-Encode/Erlang/roman-numerals-encode.erl b/Task/Roman-numerals-Encode/Erlang/roman-numerals-encode.erl new file mode 100644 index 0000000000..d5d4937b0d --- /dev/null +++ b/Task/Roman-numerals-Encode/Erlang/roman-numerals-encode.erl @@ -0,0 +1,20 @@ +-module(roman). +-export([to_roman/1]). + +to_roman(0) -> []; +to_roman(X) when X >= 1000 -> [$M | to_roman(X - 1000)]; +to_roman(X) when X >= 100 -> + digit(X div 100, $C, $D, $M) ++ to_roman(X rem 100); +to_roman(X) when X >= 10 -> + digit(X div 10, $X, $L, $C) ++ to_roman(X rem 10); +to_roman(X) when X >= 1 -> digit(X, $I, $V, $X). + +digit(1, X, _, _) -> [X]; +digit(2, X, _, _) -> [X, X]; +digit(3, X, _, _) -> [X, X, X]; +digit(4, X, Y, _) -> [X, Y]; +digit(5, _, Y, _) -> [Y]; +digit(6, X, Y, _) -> [Y, X]; +digit(7, X, Y, _) -> [Y, X, X]; +digit(8, X, Y, _) -> [Y, X, X, X]; +digit(9, X, _, Z) -> [X, Z]. diff --git a/Task/Roman-numerals-Encode/Euphoria/roman-numerals-encode.euphoria b/Task/Roman-numerals-Encode/Euphoria/roman-numerals-encode.euphoria new file mode 100644 index 0000000000..db08b89b4a --- /dev/null +++ b/Task/Roman-numerals-Encode/Euphoria/roman-numerals-encode.euphoria @@ -0,0 +1,18 @@ +constant arabic = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 } +constant roman = {"M", "CM", "D","CD", "C","XC","L","XL","X","IX","V","IV","I"} + +function toRoman(integer val) + sequence result + result = "" + for i = 1 to 13 do + while val >= arabic[i] do + result &= roman[i] + val -= arabic[i] + end while + end for + return result +end function + +printf(1,"%d = %s\n",{2009,toRoman(2009)}) +printf(1,"%d = %s\n",{1666,toRoman(1666)}) +printf(1,"%d = %s\n",{3888,toRoman(3888)}) diff --git a/Task/Roman-numerals-Encode/FALSE/roman-numerals-encode.false b/Task/Roman-numerals-Encode/FALSE/roman-numerals-encode.false new file mode 100644 index 0000000000..daa07790a2 --- /dev/null +++ b/Task/Roman-numerals-Encode/FALSE/roman-numerals-encode.false @@ -0,0 +1,14 @@ +^$." " +[$999>][1000- "M"]# + $899> [ 900-"CM"]? + $499> [ 500- "D"]? + $399> [ 400-"CD"]? +[$ 99>][ 100- "C"]# + $ 89> [ 90-"XC"]? + $ 49> [ 50- "L"]? + $ 39> [ 40-"XL"]? +[$ 9>][ 10- "X"]# + $ 8> [ 9-"IX"]? + $ 4> [ 5- "V"]? + $ 3> [ 4-"IV"]? +[$ ][ 1- "I"]#% diff --git a/Task/Roman-numerals-Encode/Factor/roman-numerals-encode-1.factor b/Task/Roman-numerals-Encode/Factor/roman-numerals-encode-1.factor new file mode 100644 index 0000000000..903ac9a119 --- /dev/null +++ b/Task/Roman-numerals-Encode/Factor/roman-numerals-encode-1.factor @@ -0,0 +1,3 @@ +USE: roman +( scratchpad ) 3333 >roman . +"mmmcccxxxiii" diff --git a/Task/Roman-numerals-Encode/Factor/roman-numerals-encode-2.factor b/Task/Roman-numerals-Encode/Factor/roman-numerals-encode-2.factor new file mode 100644 index 0000000000..1903767334 --- /dev/null +++ b/Task/Roman-numerals-Encode/Factor/roman-numerals-encode-2.factor @@ -0,0 +1,16 @@ +CONSTANT: roman-digits + { "m" "cm" "d" "cd" "c" "xc" "l" "xl" "x" "ix" "v" "iv" "i" } + +CONSTANT: roman-values + { 1000 900 500 400 100 90 50 40 10 9 5 4 1 } + +ERROR: roman-range-error n ; + +: roman-range-check ( n -- n ) + dup 1 10000 between? [ roman-range-error ] unless ; + +: >roman ( n -- str ) + roman-range-check + roman-values roman-digits [ + [ /mod swap ] dip concat + ] 2map "" concat-as nip ; diff --git a/Task/Roman-numerals-Encode/Fan/roman-numerals-encode.fan b/Task/Roman-numerals-Encode/Fan/roman-numerals-encode.fan new file mode 100644 index 0000000000..18ce40d3e6 --- /dev/null +++ b/Task/Roman-numerals-Encode/Fan/roman-numerals-encode.fan @@ -0,0 +1,38 @@ +** +** converts a number to its roman numeral representation +** +class RomanNumerals +{ + + private Str digit(Str x, Str y, Str z, Int i) + { + switch (i) + { + case 1: return x + case 2: return x+x + case 3: return x+x+x + case 4: return x+y + case 5: return y + case 6: return y+x + case 7: return y+x+x + case 8: return y+x+x+x + case 9: return x+z + } + return "" + } + + Str toRoman(Int i) + { + if (i>=1000) { return "M" + toRoman(i-1000) } + if (i>=100) { return digit("C", "D", "M", i/100) + toRoman(i%100) } + if (i>=10) { return digit("X", "L", "C", i/10) + toRoman(i%10) } + if (i>=1) { return digit("I", "V", "X", i) } + return "" + } + + Void main() + { + 2000.times |i| { echo("$i = ${toRoman(i)}") } + } + +} diff --git a/Task/Roman-numerals-Encode/Forth/roman-numerals-encode-1.fth b/Task/Roman-numerals-Encode/Forth/roman-numerals-encode-1.fth new file mode 100644 index 0000000000..c0314b856f --- /dev/null +++ b/Task/Roman-numerals-Encode/Forth/roman-numerals-encode-1.fth @@ -0,0 +1,18 @@ +: vector create ( n -- ) 0 do , loop does> ( n -- ) swap cells + @ execute ; +\ these are ( numerals -- numerals ) +: ,I dup c@ C, ; : ,V dup 1 + c@ C, ; : ,X dup 2 + c@ C, ; + +\ these are ( numerals -- ) +:noname ,I ,X drop ; :noname ,V ,I ,I ,I drop ; :noname ,V ,I ,I drop ; +:noname ,V ,I drop ; :noname ,V drop ; :noname ,I ,V drop ; +:noname ,I ,I ,I drop ; :noname ,I ,I drop ; :noname ,I drop ; +' drop ( 0 : no output ) 10 vector ,digit + +: roman-rec ( numerals n -- ) 10 /mod dup if >r over 2 + r> recurse else drop then ,digit ; +: roman ( n -- c-addr u ) + dup 0 4000 within 0= abort" EX LIMITO!" + HERE SWAP s" IVXLCDM" drop swap roman-rec HERE OVER - ; + +1999 roman type \ MCMXCIX + 25 roman type \ XXV + 944 roman type \ CMXLIV diff --git a/Task/Roman-numerals-Encode/Forth/roman-numerals-encode-2.fth b/Task/Roman-numerals-Encode/Forth/roman-numerals-encode-2.fth new file mode 100644 index 0000000000..1cd7e1ccbb --- /dev/null +++ b/Task/Roman-numerals-Encode/Forth/roman-numerals-encode-2.fth @@ -0,0 +1,19 @@ +create romans 0 , 1 , 5 , 21 , 9 , 2 , 6 , 22 , 86 , 13 , + does> swap cells + @ ; + +: roman-digit ( a1 n1 a2 n2 -- a3) + drop >r romans + begin dup while tuck 4 mod 1- chars r@ + c@ over c! char+ swap 4 / repeat + r> drop drop +; + +: (split) swap >r /mod r> swap ; + +: >roman ( n1 a -- a n2) + tuck 1000 (split) s" M " roman-digit 100 (split) s" CDM" roman-digit + 10 (split) s" XLC" roman-digit 1 (split) s" IVX" roman-digit nip over - +; + +create (roman) 16 chars allot + +1999 (roman) >roman type cr diff --git a/Task/Roman-numerals-Encode/Fortran/roman-numerals-encode.f b/Task/Roman-numerals-Encode/Fortran/roman-numerals-encode.f new file mode 100644 index 0000000000..1fe1d8ecb2 --- /dev/null +++ b/Task/Roman-numerals-Encode/Fortran/roman-numerals-encode.f @@ -0,0 +1,35 @@ +program roman_numerals + + implicit none + + write (*, '(a)') roman (2009) + write (*, '(a)') roman (1666) + write (*, '(a)') roman (3888) + +contains + +function roman (n) result (r) + + implicit none + integer, intent (in) :: n + integer, parameter :: d_max = 13 + integer :: d + integer :: m + integer :: m_div + character (32) :: r + integer, dimension (d_max), parameter :: d_dec = & + & (/1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1/) + character (32), dimension (d_max), parameter :: d_rom = & + & (/'M ', 'CM', 'D ', 'CD', 'C ', 'XC', 'L ', 'XL', 'X ', 'IX', 'V ', 'IV', 'I '/) + + r = '' + m = n + do d = 1, d_max + m_div = m / d_dec (d) + r = trim (r) // repeat (trim (d_rom (d)), m_div) + m = m - d_dec (d) * m_div + end do + +end function roman + +end program roman_numerals diff --git a/Task/Roman-numerals-Encode/Go/roman-numerals-encode.go b/Task/Roman-numerals-Encode/Go/roman-numerals-encode.go new file mode 100644 index 0000000000..c310672c9a --- /dev/null +++ b/Task/Roman-numerals-Encode/Go/roman-numerals-encode.go @@ -0,0 +1,39 @@ +package main + +import "fmt" + +var ( + m0 = []string{"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"} + m1 = []string{"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"} + m2 = []string{"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"} + m3 = []string{"", "M", "MM", "MMM", "I̅V̅", + "V̅", "V̅I̅", "V̅I̅I̅", "V̅I̅I̅I̅", "I̅X̅"} + m4 = []string{"", "X̅", "X̅X̅", "X̅X̅X̅", "X̅L̅", + "L̅", "L̅X̅", "L̅X̅X̅", "L̅X̅X̅X̅", "X̅C̅"} + m5 = []string{"", "C̅", "C̅C̅", "C̅C̅C̅", "C̅D̅", + "D̅", "D̅C̅", "D̅C̅C̅", "D̅C̅C̅C̅", "C̅M̅"} + m6 = []string{"", "M̅", "M̅M̅", "M̅M̅M̅"} +) + +func formatRoman(n int) (string, bool) { + if n < 1 || n >= 4e6 { + return "", false + } + // this is efficient in Go. the seven operands are evaluated, + // then a single allocation is made of the exact size needed for the result. + return m6[n/1e6] + m5[n%1e6/1e5] + m4[n%1e5/1e4] + m3[n%1e4/1e3] + + m2[n%1e3/1e2] + m1[n%100/10] + m0[n%10], + true +} + +func main() { + // show three numbers mentioned in task descriptions + for _, n := range []int{1990, 2008, 1666} { + r, ok := formatRoman(n) + if ok { + fmt.Println(n, "==", r) + } else { + fmt.Println(n, "not representable") + } + } +} diff --git a/Task/Roman-numerals-Encode/Groovy/roman-numerals-encode.groovy b/Task/Roman-numerals-Encode/Groovy/roman-numerals-encode.groovy new file mode 100644 index 0000000000..8833fa760f --- /dev/null +++ b/Task/Roman-numerals-Encode/Groovy/roman-numerals-encode.groovy @@ -0,0 +1,28 @@ +symbols = [ 1:'I', 4:'IV', 5:'V', 9:'IX', 10:'X', 40:'XL', 50:'L', 90:'XC', 100:'C', 400:'CD', 500:'D', 900:'CM', 1000:'M' ] + +def roman(arabic) { + def result = "" + symbols.keySet().sort().reverse().each { + while (arabic >= it) { + arabic-=it + result+=symbols[it] + } + } + return result +} +assert roman(1) == 'I' +assert roman(2) == 'II' +assert roman(4) == 'IV' +assert roman(8) == 'VIII' +assert roman(16) == 'XVI' +assert roman(32) == 'XXXII' +assert roman(25) == 'XXV' +assert roman(64) == 'LXIV' +assert roman(128) == 'CXXVIII' +assert roman(256) == 'CCLVI' +assert roman(512) == 'DXII' +assert roman(954) == 'CMLIV' +assert roman(1024) == 'MXXIV' +assert roman(1666) == 'MDCLXVI' +assert roman(1990) == 'MCMXC' +assert roman(2008) == 'MMVIII' diff --git a/Task/Roman-numerals-Encode/Haskell/roman-numerals-encode-1.hs b/Task/Roman-numerals-Encode/Haskell/roman-numerals-encode-1.hs new file mode 100644 index 0000000000..1bb1ed0b84 --- /dev/null +++ b/Task/Roman-numerals-Encode/Haskell/roman-numerals-encode-1.hs @@ -0,0 +1,13 @@ +digit x y z k = + [[x],[x,x],[x,x,x],[x,y],[y],[y,x],[y,x,x],[y,x,x,x],[x,z]] !! + (fromInteger k - 1) + +toRoman :: Integer -> String +toRoman 0 = "" +toRoman x | x < 0 = error "Negative roman numeral" +toRoman x | x >= 1000 = 'M' : toRoman (x - 1000) +toRoman x | x >= 100 = digit 'C' 'D' 'M' q ++ toRoman r where + (q,r) = x `divMod` 100 +toRoman x | x >= 10 = digit 'X' 'L' 'C' q ++ toRoman r where + (q,r) = x `divMod` 10 +toRoman x = digit 'I' 'V' 'X' x diff --git a/Task/Roman-numerals-Encode/Haskell/roman-numerals-encode-2.hs b/Task/Roman-numerals-Encode/Haskell/roman-numerals-encode-2.hs new file mode 100644 index 0000000000..1d1e3313de --- /dev/null +++ b/Task/Roman-numerals-Encode/Haskell/roman-numerals-encode-2.hs @@ -0,0 +1,2 @@ +*Main> map toRoman [1999,25,944] +["MCMXCIX","XXV","CMXLIV"] diff --git a/Task/Roman-numerals-Encode/HicEst/roman-numerals-encode.hicest b/Task/Roman-numerals-Encode/HicEst/roman-numerals-encode.hicest new file mode 100644 index 0000000000..0ab9991703 --- /dev/null +++ b/Task/Roman-numerals-Encode/HicEst/roman-numerals-encode.hicest @@ -0,0 +1,22 @@ +CHARACTER Roman*20 + +CALL RomanNumeral(1990, Roman) ! MCMXC +CALL RomanNumeral(2008, Roman) ! MMVIII +CALL RomanNumeral(1666, Roman) ! MDCLXVI + +END + +SUBROUTINE RomanNumeral( arabic, roman) + CHARACTER roman + DIMENSION ddec(13) + DATA ddec/1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1/ + + roman = ' ' + todo = arabic + DO d = 1, 13 + DO rep = 1, todo / ddec(d) + roman = TRIM(roman) // TRIM(CHAR(d, 13, "M CM D CD C XC L XL X OX V IV I ")) + todo = todo - ddec(d) + ENDDO + ENDDO +END diff --git a/Task/Roman-numerals-Encode/Icon/roman-numerals-encode-1.icon b/Task/Roman-numerals-Encode/Icon/roman-numerals-encode-1.icon new file mode 100644 index 0000000000..0e3600c72f --- /dev/null +++ b/Task/Roman-numerals-Encode/Icon/roman-numerals-encode-1.icon @@ -0,0 +1,6 @@ +link numbers # commas, roman + +procedure main(arglist) +every x := !arglist do + write(commas(x), " -> ",roman(x)|"*** can't convert to Roman numerals ***") +end diff --git a/Task/Roman-numerals-Encode/Icon/roman-numerals-encode-2.icon b/Task/Roman-numerals-Encode/Icon/roman-numerals-encode-2.icon new file mode 100644 index 0000000000..089e6b662c --- /dev/null +++ b/Task/Roman-numerals-Encode/Icon/roman-numerals-encode-2.icon @@ -0,0 +1,12 @@ +procedure roman(n) #: convert integer to Roman numeral + local arabic, result + static equiv + + initial equiv := ["","I","II","III","IV","V","VI","VII","VIII","IX"] + + integer(n) > 0 | fail + result := "" + every arabic := !n do + result := map(result,"IVXLCDM","XLCDM**") || equiv[arabic + 1] + if find("*",result) then fail else return result +end diff --git a/Task/Roman-numerals-Encode/Io/roman-numerals-encode.io b/Task/Roman-numerals-Encode/Io/roman-numerals-encode.io new file mode 100644 index 0000000000..9e402ca021 --- /dev/null +++ b/Task/Roman-numerals-Encode/Io/roman-numerals-encode.io @@ -0,0 +1,18 @@ +Roman := Object clone do ( + nums := list(1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1) + rum := list("M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I") + + numeral := method(number, + result := "" + for(i, 0, nums size, + if(number == 0, break) + while(number >= nums at(i), + number = number - nums at(i) + result = result .. rum at(i) + ) + ) + return result + ) +) + +Roman numeral(1666) println diff --git a/Task/Roman-numerals-Encode/J/roman-numerals-encode-1.j b/Task/Roman-numerals-Encode/J/roman-numerals-encode-1.j new file mode 100644 index 0000000000..7c8dd1211c --- /dev/null +++ b/Task/Roman-numerals-Encode/J/roman-numerals-encode-1.j @@ -0,0 +1,7 @@ +R1000=. ;L:1 ,{ <@(<;._1);._2]0 :0 + C CC CCC CD D DC DCC DCCC CM + X XX XXX XL L LX LXX LXXX XC + I II III IV V VI VII VIII IX +) + +rfd=: ('M' $~ <.@%&1000) , R1000 {::~ 1000&| diff --git a/Task/Roman-numerals-Encode/J/roman-numerals-encode-2.j b/Task/Roman-numerals-Encode/J/roman-numerals-encode-2.j new file mode 100644 index 0000000000..dcace71cad --- /dev/null +++ b/Task/Roman-numerals-Encode/J/roman-numerals-encode-2.j @@ -0,0 +1,6 @@ + rfd 1234 +MCCXXXIV + rfd 567 +DLXVII + rfd 89 +LXXXIX diff --git a/Task/Roman-numerals-Encode/Java/roman-numerals-encode.java b/Task/Roman-numerals-Encode/Java/roman-numerals-encode.java new file mode 100644 index 0000000000..81508f53e1 --- /dev/null +++ b/Task/Roman-numerals-Encode/Java/roman-numerals-encode.java @@ -0,0 +1,41 @@ +public class RN { + + enum Numeral { + I(1), IV(4), V(5), IX(9), X(10), XL(40), L(50), XC(90), C(100), CD(400), D(500), CM(900), M(1000); + int weight; + + Numeral(int weight) { + this.weight = weight; + } + }; + + public static String roman(long n) { + + if( n <= 0) { + throw new IllegalArgumentException(); + } + + StringBuilder buf = new StringBuilder(); + + final Numeral[] values = Numeral.values(); + for (int i = values.length - 1; i >= 0; i--) { + while (n >= values[i].weight) { + buf.append(values[i]); + n -= values[i].weight; + } + } + return buf.toString(); + } + + public static void test(long n) { + System.out.println(n + " = " + roman(n)); + } + + public static void main(String[] args) { + test(1999); + test(25); + test(944); + test(0); + } + +} diff --git a/Task/Roman-numerals-Encode/JavaScript/roman-numerals-encode.js b/Task/Roman-numerals-Encode/JavaScript/roman-numerals-encode.js new file mode 100644 index 0000000000..b86876672b --- /dev/null +++ b/Task/Roman-numerals-Encode/JavaScript/roman-numerals-encode.js @@ -0,0 +1,18 @@ +var roman = { + map: [ + 1000, 'M', 900, 'CM', 500, 'D', 400, 'CD', 100, 'C', 90, 'XC', + 50, 'L', 40, 'XL', 10, 'X', 9, 'IX', 5, 'V', 4, 'IV', 1, 'I', + ], + int_to_roman: function(n) { + var value = ''; + for (var idx = 0; n > 0 && idx < this.map.length; idx += 2) { + while (n >= this.map[idx]) { + value += this.map[idx + 1]; + n -= this.map[idx]; + } + } + return value; + } +} + +roman.int_to_roman(1999); // "MCMXCIX" diff --git a/Task/Roman-numerals-Encode/LaTeX/roman-numerals-encode.tex b/Task/Roman-numerals-Encode/LaTeX/roman-numerals-encode.tex new file mode 100644 index 0000000000..b399391a44 --- /dev/null +++ b/Task/Roman-numerals-Encode/LaTeX/roman-numerals-encode.tex @@ -0,0 +1,5 @@ +\documentclass{article} +\begin{document} +\newcounter{currentyear}\setcounter{currentyear}{\year} +Anno Domini \Roman{currentyear} +\end{document} diff --git a/Task/Roman-numerals-Encode/Liberty-BASIC/roman-numerals-encode.liberty b/Task/Roman-numerals-Encode/Liberty-BASIC/roman-numerals-encode.liberty new file mode 100644 index 0000000000..e7d69a77d6 --- /dev/null +++ b/Task/Roman-numerals-Encode/Liberty-BASIC/roman-numerals-encode.liberty @@ -0,0 +1,31 @@ + dim arabic( 12) + for i =0 to 12 + read k + arabic( i) =k + next i + data 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 + + dim roman$( 12) + for i =0 to 12 + read k$ + roman$( i) =k$ + next i + data "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I" + + print 2009, toRoman$( 2009) + print 1666, toRoman$( 1666) + print 3888, toRoman$( 3888) + + end + +function toRoman$( value) + i =0 + result$ ="" + for i = 0 to 12 + while value >=arabic( i) + result$ = result$ + roman$( i) + value = value - arabic( i) + wend + next i + toRoman$ =result$ +end function diff --git a/Task/Roman-numerals-Encode/Logo/roman-numerals-encode-1.logo b/Task/Roman-numerals-Encode/Logo/roman-numerals-encode-1.logo new file mode 100644 index 0000000000..0a243c1a1a --- /dev/null +++ b/Task/Roman-numerals-Encode/Logo/roman-numerals-encode-1.logo @@ -0,0 +1,12 @@ +make "roman.rules [ + [1000 M] [900 CM] [500 D] [400 CD] + [ 100 C] [ 90 XC] [ 50 L] [ 40 XL] + [ 10 X] [ 9 IX] [ 5 V] [ 4 IV] + [ 1 I] +] + +to roman :n [:rules :roman.rules] [:acc "||] + if empty? :rules [output :acc] + if :n < first first :rules [output (roman :n bf :rules :acc)] + output (roman :n - first first :rules :rules word :acc last first :rules) +end diff --git a/Task/Roman-numerals-Encode/Logo/roman-numerals-encode-2.logo b/Task/Roman-numerals-Encode/Logo/roman-numerals-encode-2.logo new file mode 100644 index 0000000000..b2aa008761 --- /dev/null +++ b/Task/Roman-numerals-Encode/Logo/roman-numerals-encode-2.logo @@ -0,0 +1,18 @@ +make "patterns [[?] [? ?] [? ? ?] [? ?2] [?2] [?2 ?] [?2 ? ?] [?2 ? ? ?] [? ?3]] + +to digit :d :numerals + if :d = 0 [output "||] + output apply (sentence "\( "word (item :d :patterns) "\)) :numerals +end +to digits :n :numerals + output word ifelse :n < 10 ["||] [digits int :n/10 bf bf :numerals] ~ + digit modulo :n 10 :numerals +end +to roman :n + if or :n < 0 :n >= 4000 [output [EX MODVS!]] + output digits :n [I V X L C D M] +end + +print roman 1999 ; MCMXCIX +print roman 25 ; XXV +print roman 944 ; CMXLIV diff --git a/Task/Roman-numerals-Encode/LotusScript/roman-numerals-encode.lotusscript b/Task/Roman-numerals-Encode/LotusScript/roman-numerals-encode.lotusscript new file mode 100644 index 0000000000..1fe78dfb38 --- /dev/null +++ b/Task/Roman-numerals-Encode/LotusScript/roman-numerals-encode.lotusscript @@ -0,0 +1,43 @@ +Function toRoman(value) As String + Dim arabic(12) As Integer + Dim roman(12) As String + + arabic(0) = 1000 + arabic(1) = 900 + arabic(2) = 500 + arabic(3) = 400 + arabic(4) = 100 + arabic(5) = 90 + arabic(6) = 50 + arabic(7) = 40 + arabic(8) = 10 + arabic(9) = 9 + arabic(10) = 5 + arabic(11) = 4 + arabic(12) = 1 + + roman(0) = "M" + roman(1) = "CM" + roman(2) = "D" + roman(3) = "CD" + roman(4) = "C" + roman(5) = "XC" + roman(6) = "L" + roman(7) = "XL" + roman(8) = "X" + roman(9) = "IX" + roman(10) = "V" + roman(11) = "IV" + roman(12) = "I" + + Dim i As Integer, result As String + + For i = 0 To 12 + Do While value >= arabic(i) + result = result + roman(i) + value = value - arabic(i) + Loop + Next i + + toRoman = result +End Function diff --git a/Task/Roman-numerals-Encode/Lua/roman-numerals-encode.lua b/Task/Roman-numerals-Encode/Lua/roman-numerals-encode.lua new file mode 100644 index 0000000000..e4c87a1314 --- /dev/null +++ b/Task/Roman-numerals-Encode/Lua/roman-numerals-encode.lua @@ -0,0 +1,15 @@ +romans = { +{1000, "M"}, +{900, "CM"}, {500, "D"}, {400, "CD"}, {100, "C"}, +{90, "XC"}, {50, "L"}, {40, "XL"}, {10, "X"}, +{9, "IX"}, {5, "V"}, {4, "IV"}, {1, "I"} } + +k = io.read() + 0 +for _, v in ipairs(romans) do --note that this is -not- ipairs. + val, let = unpack(v) + while k >= val do + k = k - val + io.write(let) + end +end +print() diff --git a/Task/Roman-numerals-Encode/M4/roman-numerals-encode.m4 b/Task/Roman-numerals-Encode/M4/roman-numerals-encode.m4 new file mode 100644 index 0000000000..a8851a888d --- /dev/null +++ b/Task/Roman-numerals-Encode/M4/roman-numerals-encode.m4 @@ -0,0 +1,15 @@ +define(`roman',`ifelse(eval($1>=1000),1,`M`'roman(eval($1-1000))', +`ifelse(eval($1>=900),1,`CM`'roman(eval($1-900))', +`ifelse(eval($1>=500),1,`D`'roman(eval($1-500))', +`ifelse(eval($1>=100),1,`C`'roman(eval($1-100))', +`ifelse(eval($1>=90),1,`XC`'roman(eval($1-90))', +`ifelse(eval($1>=50),1,`L`'roman(eval($1-50))', +`ifelse(eval($1>=40),1,`XL`'roman(eval($1-40))', +`ifelse(eval($1>=10),1,`X`'roman(eval($1-10))', +`ifelse(eval($1>=9),1,`IX`'roman(eval($1-9))', +`ifelse(eval($1>=5),1,`V`'roman(eval($1-5))', +`ifelse(eval($1>=4),1,`IV`'roman(eval($1-4))', +`ifelse(eval($1>=1),1,`I`'roman(eval($1-1))' +)')')')')')')')')')')')')dnl +dnl +roman(3675) diff --git a/Task/Roman-numerals-Encode/MUMPS/roman-numerals-encode.mumps b/Task/Roman-numerals-Encode/MUMPS/roman-numerals-encode.mumps new file mode 100644 index 0000000000..a84a3c5bbd --- /dev/null +++ b/Task/Roman-numerals-Encode/MUMPS/roman-numerals-encode.mumps @@ -0,0 +1,14 @@ +TOROMAN(INPUT) + ;Converts INPUT into a Roman numeral. INPUT must be an integer between 1 and 3999 + ;OUTPUT is the string to return + ;I is a loop variable + ;CURRVAL is the current value in the loop + QUIT:($FIND(INPUT,".")>1)!(INPUT<=0)!(INPUT>3999) "Invalid input" + NEW OUTPUT,I,CURRVAL + SET OUTPUT="",CURRVAL=INPUT + SET:$DATA(ROMANNUM)=0 ROMANNUM="I^IV^V^IX^X^XL^L^XC^C^CD^D^CM^M" + SET:$DATA(ROMANVAL)=0 ROMANVAL="1^4^5^9^10^40^50^90^100^400^500^900^1000" + FOR I=$LENGTH(ROMANVAL,"^"):-1:1 DO + .FOR Q:CURRVAL<$PIECE(ROMANVAL,"^",I) SET OUTPUT=OUTPUT_$PIECE(ROMANNUM,"^",I),CURRVAL=CURRVAL-$PIECE(ROMANVAL,"^",I) + KILL I,CURRVAL + QUIT OUTPUT diff --git a/Task/Roman-numerals-Encode/Mathematica/roman-numerals-encode-1.math b/Task/Roman-numerals-Encode/Mathematica/roman-numerals-encode-1.math new file mode 100644 index 0000000000..bff98c1877 --- /dev/null +++ b/Task/Roman-numerals-Encode/Mathematica/roman-numerals-encode-1.math @@ -0,0 +1,10 @@ +RomanForm[i_Integer?Positive] := + Module[{num = i, string = "", value, letters, digits}, + digits = {{1000, "M"}, {900, "CM"}, {500, "D"}, {400, "CD"}, {100, + "C"}, {90, "XC"}, {50, "L"}, {40, "XL"}, {10, "X"}, {9, + "IX"}, {5, "V"}, {4, "IV"}, {1, "I"}}; + While[num > 0, {value, letters} = + Which @@ Flatten[{num >= #[[1]], ##} & /@ digits, 1]; + num -= value; + string = string <> letters;]; + string] diff --git a/Task/Roman-numerals-Encode/Mathematica/roman-numerals-encode-2.math b/Task/Roman-numerals-Encode/Mathematica/roman-numerals-encode-2.math new file mode 100644 index 0000000000..7fc493446b --- /dev/null +++ b/Task/Roman-numerals-Encode/Mathematica/roman-numerals-encode-2.math @@ -0,0 +1,5 @@ +RomanForm[4] +RomanForm[99] +RomanForm[1337] +RomanForm[1666] +RomanForm[6889] diff --git a/Task/Roman-numerals-Encode/Mathematica/roman-numerals-encode-3.math b/Task/Roman-numerals-Encode/Mathematica/roman-numerals-encode-3.math new file mode 100644 index 0000000000..f87b75c0cb --- /dev/null +++ b/Task/Roman-numerals-Encode/Mathematica/roman-numerals-encode-3.math @@ -0,0 +1,5 @@ +IV +XCIX +MCCCXXXVII +MDCLXVI +MMMMMMDCCCLXXXIX diff --git a/Task/Roman-numerals-Encode/Mathematica/roman-numerals-encode-4.math b/Task/Roman-numerals-Encode/Mathematica/roman-numerals-encode-4.math new file mode 100644 index 0000000000..e4e29920f3 --- /dev/null +++ b/Task/Roman-numerals-Encode/Mathematica/roman-numerals-encode-4.math @@ -0,0 +1,52 @@ +:- module roman. + +:- interface. + +:- import_module io. + +:- pred main(io::di, io::uo) is det. + +:- implementation. + +:- import_module char, int, list, string. + +main(!IO) :- + command_line_arguments(Args, !IO), + filter(is_all_digits, Args, CleanArgs), + foldl((pred(Arg::in, !.IO::di, !:IO::uo) is det :- + ( Roman = to_roman(Arg) -> + format("%s => %s", [s(Arg), s(Roman)], !IO), nl(!IO) + ; format("%s cannot be converted.", [s(Arg)], !IO), nl(!IO) ) + ), CleanArgs, !IO). + +:- func to_roman(string::in) = (string::out) is semidet. +to_roman(Number) = from_char_list(build_roman(reverse(to_char_list(Number)))). + +:- func build_roman(list(char)) = list(char). +:- mode build_roman(in) = out is semidet. +build_roman([]) = []. +build_roman([D|R]) = Roman :- + map(promote, build_roman(R), Interim), + Roman = Interim ++ digit_to_roman(D). + +:- func digit_to_roman(char) = list(char). +:- mode digit_to_roman(in) = out is semidet. +digit_to_roman('0') = []. +digit_to_roman('1') = ['I']. +digit_to_roman('2') = ['I','I']. +digit_to_roman('3') = ['I','I','I']. +digit_to_roman('4') = ['I','V']. +digit_to_roman('5') = ['V']. +digit_to_roman('6') = ['V','I']. +digit_to_roman('7') = ['V','I','I']. +digit_to_roman('8') = ['V','I','I','I']. +digit_to_roman('9') = ['I','X']. + +:- pred promote(char::in, char::out) is semidet. +promote('I', 'X'). +promote('V', 'L'). +promote('X', 'C'). +promote('L', 'D'). +promote('C', 'M'). + +:- end_module roman. diff --git a/Task/Roman-numerals-Encode/Mathematica/roman-numerals-encode-5.math b/Task/Roman-numerals-Encode/Mathematica/roman-numerals-encode-5.math new file mode 100644 index 0000000000..9215a87478 --- /dev/null +++ b/Task/Roman-numerals-Encode/Mathematica/roman-numerals-encode-5.math @@ -0,0 +1,48 @@ +:- module roman2. + +:- interface. + +:- import_module io. + +:- pred main(io::di, io::uo) is det. + +:- implementation. + +:- import_module char, int, list, string. + +main(!IO) :- + command_line_arguments(Args, !IO), + filter_map(to_int, Args, CleanArgs), + foldl((pred(Arg::in, !.IO::di, !:IO::uo) is det :- + ( Roman = to_roman(Arg) -> + format("%i => %s", + [i(Arg), s(from_char_list(Roman))], !IO), + nl(!IO) + ; format("%i cannot be converted.", [i(Arg)], !IO), nl(!IO) ) + ), CleanArgs, !IO). + +:- func to_roman(int) = list(char). +:- mode to_roman(in) = out is semidet. +to_roman(N) = ( N >= 1000 -> + ['M'] ++ to_roman(N - 1000) + ;( N >= 100 -> + digit(N / 100, 'C', 'D', 'M') ++ to_roman(N rem 100) + ;( N >= 10 -> + digit(N / 10, 'X', 'L', 'C') ++ to_roman(N rem 10) + ;( N >= 1 -> + digit(N, 'I', 'V', 'X') + ; [] ) ) ) ). + +:- func digit(int, char, char, char) = list(char). +:- mode digit(in, in, in, in) = out is semidet. +digit(1, X, _, _) = [X]. +digit(2, X, _, _) = [X, X]. +digit(3, X, _, _) = [X, X, X]. +digit(4, X, Y, _) = [X, Y]. +digit(5, _, Y, _) = [Y]. +digit(6, X, Y, _) = [Y, X]. +digit(7, X, Y, _) = [Y, X, X]. +digit(8, X, Y, _) = [Y, X, X, X]. +digit(9, X, _, Z) = [X, Z]. + +:- end_module roman2. diff --git a/Task/Roman-numerals-Encode/OCaml/roman-numerals-encode.ocaml b/Task/Roman-numerals-Encode/OCaml/roman-numerals-encode.ocaml new file mode 100644 index 0000000000..1f8eb9ab45 --- /dev/null +++ b/Task/Roman-numerals-Encode/OCaml/roman-numerals-encode.ocaml @@ -0,0 +1,23 @@ +let digit x y z = function + 1 -> [x] + | 2 -> [x;x] + | 3 -> [x;x;x] + | 4 -> [x;y] + | 5 -> [y] + | 6 -> [y;x] + | 7 -> [y;x;x] + | 8 -> [y;x;x;x] + | 9 -> [x;z] + +let rec to_roman x = + if x = 0 then [] + else if x < 0 then + invalid_arg "Negative roman numeral" + else if x >= 1000 then + 'M' :: to_roman (x - 1000) + else if x >= 100 then + digit 'C' 'D' 'M' (x / 100) @ to_roman (x mod 100) + else if x >= 10 then + digit 'X' 'L' 'C' (x / 10) @ to_roman (x mod 10) + else + digit 'I' 'V' 'X' x diff --git a/Task/Roman-numerals-Encode/Objeck/roman-numerals-encode.objeck b/Task/Roman-numerals-Encode/Objeck/roman-numerals-encode.objeck new file mode 100644 index 0000000000..b68fc0fe17 --- /dev/null +++ b/Task/Roman-numerals-Encode/Objeck/roman-numerals-encode.objeck @@ -0,0 +1,32 @@ +bundle Default { + class Roman { + nums: static : Int[]; + rum : static : String[]; + + function : Init() ~ Nil { + nums := [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]; + rum := ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"]; + } + + function : native : ToRoman(number : Int) ~ String { + result := ""; + + for(i :=0; i < nums->Size(); i += 1;) { + while(number >= nums[i]) { + result->Append(rum[i]); + number -= nums[i]; + }; + }; + + return result; + } + + function : Main(args : String[]) ~ Nil { + Init(); + + ToRoman(1999)->PrintLine(); + ToRoman(25)->PrintLine(); + ToRoman(944)->PrintLine(); + } + } +} diff --git a/Task/Roman-numerals-Encode/OpenEdge-Progress/roman-numerals-encode.openedge b/Task/Roman-numerals-Encode/OpenEdge-Progress/roman-numerals-encode.openedge new file mode 100644 index 0000000000..b4eecfdb77 --- /dev/null +++ b/Task/Roman-numerals-Encode/OpenEdge-Progress/roman-numerals-encode.openedge @@ -0,0 +1,36 @@ +FUNCTION encodeRoman RETURNS CHAR ( + i_i AS INT +): + + DEF VAR cresult AS CHAR. + DEF VAR croman AS CHAR EXTENT 7 INIT [ "M", "D", "C", "L", "X", "V", "I" ]. + DEF VAR idecimal AS INT EXTENT 7 INIT [ 1000, 500, 100, 50, 10, 5, 1 ]. + DEF VAR ipos AS INT INIT 1. + + DO WHILE i_i > 0: + + IF i_i - idecimal[ ipos ] >= 0 THEN + ASSIGN + cresult = cresult + croman[ ipos ] + i_i = i_i - idecimal[ ipos ] + . + ELSE IF ipos < EXTENT( croman ) - 1 AND i_i - ( idecimal[ ipos ] - idecimal[ ipos + 2 ] ) >= 0 THEN + ASSIGN + cresult = cresult + croman[ ipos + 2 ] + croman[ ipos ] + i_i = i_i - ( idecimal[ ipos ] - idecimal[ ipos + 2 ] ) + ipos = ipos + 1 + . + ELSE + ipos = ipos + 1. + END. + + RETURN cresult. + +END FUNCTION. /* encodeRoman */ + +MESSAGE + 1990 encodeRoman( 1990 ) SKIP + 2008 encodeRoman( 2008 ) SKIP + 2000 encodeRoman( 2000 ) SKIP + 1666 encodeRoman( 1666 ) SKIP +VIEW-AS ALERT-BOX. diff --git a/Task/Roman-numerals-Encode/Oz/roman-numerals-encode.oz b/Task/Roman-numerals-Encode/Oz/roman-numerals-encode.oz new file mode 100644 index 0000000000..64de43af4e --- /dev/null +++ b/Task/Roman-numerals-Encode/Oz/roman-numerals-encode.oz @@ -0,0 +1,17 @@ +declare + fun {Digit X Y Z K} + unit([X] [X X] [X X X] [X Y] [Y] [Y X] [Y X X] [Y X X X] [X Z]) + .K + end + + fun {ToRoman X} + if X == 0 then "" + elseif X < 0 then raise toRoman(negativeInput X) end + elseif X >= 1000 then "M"#{ToRoman X-1000} + elseif X >= 100 then {Digit &C &D &M X div 100}#{ToRoman X mod 100} + elseif X >= 10 then {Digit &X &L &C X div 10}#{ToRoman X mod 10} + else {Digit &I &V &X X} + end + end +in + {ForAll {Map [1999 25 944] ToRoman} System.showInfo} diff --git a/Task/Roman-numerals-Encode/PARI-GP/roman-numerals-encode-1.pari b/Task/Roman-numerals-Encode/PARI-GP/roman-numerals-encode-1.pari new file mode 100644 index 0000000000..8a61120b15 --- /dev/null +++ b/Task/Roman-numerals-Encode/PARI-GP/roman-numerals-encode-1.pari @@ -0,0 +1,55 @@ +oldRoman(n)={ + while(n>999999, + n-=1000000; + print1("((((I))))") + ); + if(n>499999, + n-=500000; + print1("I))))") + ); + while(n>99999, + n-=100000; + print1("(((I)))") + ); + if(n>49999, + n-=50000; + print1("I)))") + ); + while(n>9999, + n-=10000; + print1("((I))") + ); + if(n>4999, + n-=5000; + print1("I))") + ); + while(n>999, + n-=1000; + print1("(I)") + ); + if(n>499, + n-=500; + print1("I)") + ); + while(n>99, + n-=100; + print1("C") + ); + if(n>49, + n-=50; + print1("L"); + ); + while(n>9, + n-=10; + print1("X") + ); + if(n>4, + n-=5; + print1("V"); + ); + while(n, + n--; + print1("I") + ); + print() +}; diff --git a/Task/Roman-numerals-Encode/PARI-GP/roman-numerals-encode-2.pari b/Task/Roman-numerals-Encode/PARI-GP/roman-numerals-encode-2.pari new file mode 100644 index 0000000000..e4954dad1d --- /dev/null +++ b/Task/Roman-numerals-Encode/PARI-GP/roman-numerals-encode-2.pari @@ -0,0 +1,55 @@ +medievalRoman(n)={ + while(n>999, + n-=1000; + print1("M") + ); + if(n>899, + n-=900; + print1("CM") + ); + if(n>499, + n-=500; + print1("D") + ); + if(n>399, + n-=400; + print1("CD") + ); + while(n>99, + n-=100; + print1("C") + ); + if(n>89, + n-=90; + print1("XC") + ); + if(n>49, + n-=50; + print1("L") + ); + if(n>39, + n-=40; + print1("XL") + ); + while(n>9, + n-=10; + print1("X") + ); + if(n>8, + n-=9; + print1("IX") + ); + if(n>4, + n-=5; + print1("V") + ); + if(n>3, + n-=4; + print1("IV") + ); + while(n, + n--; + print1("I") + ); + print() +}; diff --git a/Task/Roman-numerals-Encode/PHP/roman-numerals-encode.php b/Task/Roman-numerals-Encode/PHP/roman-numerals-encode.php new file mode 100644 index 0000000000..a7aea7d420 --- /dev/null +++ b/Task/Roman-numerals-Encode/PHP/roman-numerals-encode.php @@ -0,0 +1,60 @@ +/** + * int2roman + * Convert any positive value of a 32-bit signed integer to its modern roman + * numeral representation. Numerals within parentheses are multiplied by + * 1000. ie. M == 1 000, (M) == 1 000 000, ((M)) == 1 000 000 000 + * + * @param number - an integer between 1 and 2147483647 + * @return roman numeral representation of number + */ +function int2roman($number) +{ + if (!is_int($number) || $number < 1) return false; // ignore negative numbers and zero + + $integers = array(900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1); + $numerals = array('CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I'); + $major = intval($number / 1000) * 1000; + $minor = $number - $major; + $numeral = $leastSig = ''; + + for ($i = 0; $i < sizeof($integers); $i++) { + while ($minor >= $integers[$i]) { + $leastSig .= $numerals[$i]; + $minor -= $integers[$i]; + } + } + + if ($number >= 1000 && $number < 40000) { + if ($major >= 10000) { + $numeral .= '('; + while ($major >= 10000) { + $numeral .= 'X'; + $major -= 10000; + } + $numeral .= ')'; + } + if ($major == 9000) { + $numeral .= 'M(X)'; + return $numeral . $leastSig; + } + if ($major == 4000) { + $numeral .= 'M(V)'; + return $numeral . $leastSig; + } + if ($major >= 5000) { + $numeral .= '(V)'; + $major -= 5000; + } + while ($major >= 1000) { + $numeral .= 'M'; + $major -= 1000; + } + } + + if ($number >= 40000) { + $major = $major/1000; + $numeral .= '(' . int2roman($major) . ')'; + } + + return $numeral . $leastSig; +} diff --git a/Task/Roman-numerals-Encode/PL-I/roman-numerals-encode.pli b/Task/Roman-numerals-Encode/PL-I/roman-numerals-encode.pli new file mode 100644 index 0000000000..b17a61077e --- /dev/null +++ b/Task/Roman-numerals-Encode/PL-I/roman-numerals-encode.pli @@ -0,0 +1,19 @@ +/* From Wiki Fortran */ +roman: procedure (n) returns(character (32) varying); + declare n fixed binary nonassignable; + declare (d, m) fixed binary; + declare (r, m_div) character (32) varying; + declare d_dec(13) fixed binary static initial + (1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1); + declare d_rom(13) character (2) varying static initial + ('M', 'CM', 'D', 'CD', 'C', 'XC', 'L', + 'XL', 'X', 'IX', 'V', 'IV', 'I'); + r = ''; + m = n; + do d = 1 to 13; + m_div = m / d_dec (d); + r = r || copy (d_rom (d), m_div); + m = m - d_dec (d) * m_div; + end; + return (r); +end roman; diff --git a/Task/Roman-numerals-Encode/PL-SQL/roman-numerals-encode.sql b/Task/Roman-numerals-Encode/PL-SQL/roman-numerals-encode.sql new file mode 100644 index 0000000000..38ef69488a --- /dev/null +++ b/Task/Roman-numerals-Encode/PL-SQL/roman-numerals-encode.sql @@ -0,0 +1,24 @@ +/***************************************************************** + * $Author: Atanas Kebedjiev $ + ***************************************************************** + * Encoding an Arabic numeral to a Roman in the range 1..3999 is much simpler as Oracle provides the conversion formats. + * Please see also the SQL solution for the same task. + */ + +DECLARE +FUNCTION rencode(an IN NUMBER) RETURN VARCHAR2 IS + rs VARCHAR2(20); +BEGIN +SELECT to_char(to_char(to_date(an,'YYYY'), 'RRRR'), 'RN') INTO rs FROM dual; +RETURN rs; +END; + +BEGIN + + DBMS_OUTPUT.PUT_LINE ('2012 = ' || rencode('2012')); -- MMXII + DBMS_OUTPUT.PUT_LINE ('1951 = ' || rencode('1951')); -- MCMLI + DBMS_OUTPUT.PUT_LINE ('1987 = ' || rencode('1987')); -- MCMLXXXVII + DBMS_OUTPUT.PUT_LINE ('1666 = ' || rencode('1666')); -- MDCLXVI + DBMS_OUTPUT.PUT_LINE ('1999 = ' || rencode('1999')); -- MCMXCIX + +END; diff --git a/Task/Roman-numerals-Encode/Perl-6/roman-numerals-encode-1.pl6 b/Task/Roman-numerals-Encode/Perl-6/roman-numerals-encode-1.pl6 new file mode 100644 index 0000000000..a96074ba90 --- /dev/null +++ b/Task/Roman-numerals-Encode/Perl-6/roman-numerals-encode-1.pl6 @@ -0,0 +1,16 @@ +my %symbols = + 1 => "I", 5 => "V", 10 => "X", 50 => "L", 100 => "C", + 500 => "D", 1_000 => "M"; + +my @subtractors = + 1_000, 100, 500, 100, 100, 10, 50, 10, 10, 1, 5, 1, 1, 0; + +multi sub roman (0) { '' } +multi sub roman (Int $n) { + for @subtractors -> $cut, $minus { + $n >= $cut + and return %symbols{$cut} ~ roman($n - $cut); + $n >= $cut - $minus + and return %symbols{$minus} ~ roman($n + $minus); + } +} diff --git a/Task/Roman-numerals-Encode/Perl-6/roman-numerals-encode-2.pl6 b/Task/Roman-numerals-Encode/Perl-6/roman-numerals-encode-2.pl6 new file mode 100644 index 0000000000..24bba57036 --- /dev/null +++ b/Task/Roman-numerals-Encode/Perl-6/roman-numerals-encode-2.pl6 @@ -0,0 +1,3 @@ +for 1 .. 2_010 -> $x { + say roman($x); +} diff --git a/Task/Roman-numerals-Encode/Perl/roman-numerals-encode-1.pl b/Task/Roman-numerals-Encode/Perl/roman-numerals-encode-1.pl new file mode 100644 index 0000000000..5e3262610e --- /dev/null +++ b/Task/Roman-numerals-Encode/Perl/roman-numerals-encode-1.pl @@ -0,0 +1,3 @@ +per quisque in I tum C conscribementum sic + hoc tum duos multiplicamentum comementum egresso scribe. +cis diff --git a/Task/Roman-numerals-Encode/Perl/roman-numerals-encode-2.pl b/Task/Roman-numerals-Encode/Perl/roman-numerals-encode-2.pl new file mode 100644 index 0000000000..459e13a28d --- /dev/null +++ b/Task/Roman-numerals-Encode/Perl/roman-numerals-encode-2.pl @@ -0,0 +1,25 @@ +use v5.12; +use Sub::SmartMatch; +use SmartMatch::Sugar qw(any); +use List::MoreUtils qw( natatime ); + +my %symbols = ( + 1 => "I", 5 => "V", 10 => "X", 50 => "L", 100 => "C", + 500 => "D", 1_000 => "M" +); + +my @subtractors = ( + 1_000, 100, 500, 100, 100, 10, 50, 10, 10, 1, 5, 1, 1, 0 +); + +multi roman => [0], sub { '' }; +multi roman => any, sub { + my $n = shift; + my $iter = natatime 2, @subtractors; + while( my ($cut, $minus) = $iter->() ) { + $n >= $cut + and return $symbols{$cut} . roman($n - $cut); + $n >= $cut - $minus + and return $symbols{$minus} . roman($n + $minus); + } +}; diff --git a/Task/Roman-numerals-Encode/Perl/roman-numerals-encode-3.pl b/Task/Roman-numerals-Encode/Perl/roman-numerals-encode-3.pl new file mode 100644 index 0000000000..f7a00bb956 --- /dev/null +++ b/Task/Roman-numerals-Encode/Perl/roman-numerals-encode-3.pl @@ -0,0 +1 @@ +say roman($_) for 1..2_012; diff --git a/Task/Roman-numerals-Encode/PicoLisp/roman-numerals-encode.l b/Task/Roman-numerals-Encode/PicoLisp/roman-numerals-encode.l new file mode 100644 index 0000000000..384031a02c --- /dev/null +++ b/Task/Roman-numerals-Encode/PicoLisp/roman-numerals-encode.l @@ -0,0 +1,10 @@ +(de roman (N) + (pack + (make + (mapc + '((C D) + (while (>= N D) + (dec 'N D) + (link C) ) ) + '(M CM D CD C XC L XL X IX V IV I) + (1000 900 500 400 100 90 50 40 10 9 5 4 1) ) ) ) ) diff --git a/Task/Roman-numerals-Encode/Pike/roman-numerals-encode.pike b/Task/Roman-numerals-Encode/Pike/roman-numerals-encode.pike new file mode 100644 index 0000000000..c904953afe --- /dev/null +++ b/Task/Roman-numerals-Encode/Pike/roman-numerals-encode.pike @@ -0,0 +1,6 @@ +import String; +int main(){ + write(int2roman(2009) + "\n"); + write(int2roman(1666) + "\n"); + write(int2roman(1337) + "\n"); +} diff --git a/Task/Roman-numerals-Encode/PowerBASIC/roman-numerals-encode.powerbasic b/Task/Roman-numerals-Encode/PowerBASIC/roman-numerals-encode.powerbasic new file mode 100644 index 0000000000..78d9e42548 --- /dev/null +++ b/Task/Roman-numerals-Encode/PowerBASIC/roman-numerals-encode.powerbasic @@ -0,0 +1,24 @@ +FUNCTION toRoman(value AS INTEGER) AS STRING + DIM arabic(0 TO 12) AS INTEGER + DIM roman(0 TO 12) AS STRING + ARRAY ASSIGN arabic() = 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 + ARRAY ASSIGN roman() = "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I" + + DIM i AS INTEGER + DIM result AS STRING + + FOR i = 0 TO 12 + DO WHILE value >= arabic(i) + result = result & roman(i) + value = value - arabic(i) + LOOP + NEXT i + toRoman = result +END FUNCTION + +FUNCTION PBMAIN + 'Testing + ? "2009 = " & toRoman(2009) + ? "1666 = " & toRoman(1666) + ? "3888 = " & toRoman(3888) +END FUNCTION diff --git a/Task/Roman-numerals-Encode/Prolog/roman-numerals-encode.pro b/Task/Roman-numerals-Encode/Prolog/roman-numerals-encode.pro new file mode 100644 index 0000000000..89d15ecc5f --- /dev/null +++ b/Task/Roman-numerals-Encode/Prolog/roman-numerals-encode.pro @@ -0,0 +1,102 @@ +:- use_module(library(clpfd)). + +roman :- + LA = [ _ , 2010, _, 1449, _], + LR = ['MDCCLXXXIX', _ , 'CX', _, 'MDCLXVI'], + maplist(roman, LA, LR), + maplist(my_print,LA, LR). + + +roman(A, R) :- + A #> 0, + roman(A, [u, t, h, th], LR, []), + label([A]), + parse_Roman(CR, LR, []), + atom_chars(R, CR). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% using DCG + +roman(0, []) --> []. + +roman(N, [H | T]) --> + {N1 #= N / 10, + N2 #= N mod 10}, + roman(N1, T), + unity(N2, H). + +unity(1, u) --> ['I']. +unity(1, t) --> ['X']. +unity(1, h) --> ['C']. +unity(1, th)--> ['M']. + +unity(4, u) --> ['IV']. +unity(4, t) --> ['XL']. +unity(4, h) --> ['CD']. +unity(4, th)--> ['MMMM']. + +unity(5, u) --> ['V']. +unity(5, t) --> ['L']. +unity(5, h) --> ['D']. +unity(5, th)--> ['MMMMM']. + +unity(9, u) --> ['IX']. +unity(9, t) --> ['XC']. +unity(9, h) --> ['CM']. +unity(9, th)--> ['MMMMMMMMM']. + +unity(0, _) --> []. + + +unity(V, U)--> + {V #> 5, + V1 #= V - 5}, + unity(5, U), + unity(V1, U). + +unity(V, U) --> + {V #> 1, V #< 4, + V1 #= V-1}, + unity(1, U), + unity(V1, U). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Extraction of roman "lexeme" +parse_Roman(['C','M'|T]) --> + ['CM'], + parse_Roman(T). + +parse_Roman(['C','D'|T]) --> + ['CD'], + parse_Roman(T). + +parse_Roman(['X','C'| T]) --> + ['XC'], + parse_Roman(T). + + +parse_Roman(['X','L'| T]) --> + ['XL'], + parse_Roman(T). + + +parse_Roman(['I','X'| T]) --> + ['IX'], + parse_Roman(T). + + +parse_Roman(['I','V'| T]) --> + ['IV'], + parse_Roman(T). + +parse_Roman([H | T]) --> + [H], + parse_Roman(T). + + +parse_Roman([]) --> + []. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +my_print(A, R) :- + format('~w in roman is ~w~n', [A, R]). diff --git a/Task/Roman-numerals-Encode/Protium/roman-numerals-encode-1.protium b/Task/Roman-numerals-Encode/Protium/roman-numerals-encode-1.protium new file mode 100644 index 0000000000..fe4922fcc7 --- /dev/null +++ b/Task/Roman-numerals-Encode/Protium/roman-numerals-encode-1.protium @@ -0,0 +1,5 @@ +<@ DEFUDOLITLIT>_RO|__Transformer|<@ DEFKEYPAR>__NationalNumericID|2<@ LETRESCS%NNMPAR>...|1 + +<@ ENU$$DLSTLITLIT>1990,2008,1,2,64,124,1666,10001|,| +<@ SAYELTLST>... is <@ SAY_ROELTLSTLIT>...|RomanLowerUnicode <@ SAY_ROELTLSTLIT>...|RomanUpperUnicode <@ SAY_ROELTLSTLIT>...|RomanASCII + diff --git a/Task/Roman-numerals-Encode/Protium/roman-numerals-encode-2.protium b/Task/Roman-numerals-Encode/Protium/roman-numerals-encode-2.protium new file mode 100644 index 0000000000..4fb8483617 --- /dev/null +++ b/Task/Roman-numerals-Encode/Protium/roman-numerals-encode-2.protium @@ -0,0 +1,5 @@ +<# DEFINE USERDEFINEDOPCODE LITERAL LITERAL>_RO|__Transformer|<# DEFINE KEYWORD PARAMETER>__NationalNumericID|2<# LET RESULT CAST NATIONALNUMBER PARAMETER>...|1 + +<# ENUMERATION LAMBDASPECIFIEDDELMITER LIST LITERAL LITERAL>1990,2008,1,2,64,124,1666,10001|,| +<# SAY ELEMENT LIST>... is <# SAY _RO ELEMENT LIST LITERAL>...|RomanLowerUnicode <# SAY _RO ELEMENT LIST LITERAL>...|RomanUpperUnicode <# SAY _RO ELEMENT LIST LITERAL>...|RomanASCII + diff --git a/Task/Roman-numerals-Encode/PureBasic/roman-numerals-encode.purebasic b/Task/Roman-numerals-Encode/PureBasic/roman-numerals-encode.purebasic new file mode 100644 index 0000000000..c689559fd5 --- /dev/null +++ b/Task/Roman-numerals-Encode/PureBasic/roman-numerals-encode.purebasic @@ -0,0 +1,56 @@ +#SymbolCount = 12 ;0 based count +DataSection + denominations: + Data.s "M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I" ;0-12 + + denomValues: + Data.i 1000,900,500,400,100,90,50,40,10,9,5,4,1 ;values in decending sequential order +EndDataSection + +;-setup +Structure romanNumeral + symbol.s + value.i +EndStructure + +Global Dim refRomanNum.romanNumeral(#SymbolCount) + +Restore denominations +For i = 0 To #SymbolCount + Read.s refRomanNum(i)\symbol +Next + +Restore denomValues +For i = 0 To #SymbolCount + Read refRomanNum(i)\value +Next + +Procedure.s decRoman(n) + ;converts a decimal number to a roman numeral + Protected roman$, i + + For i = 0 To #SymbolCount + Repeat + If n >= refRomanNum(i)\value + roman$ + refRomanNum(i)\symbol + n - refRomanNum(i)\value + Else + Break + EndIf + ForEver + Next + + ProcedureReturn roman$ +EndProcedure + +If OpenConsole() + + PrintN(decRoman(1999)) ;MCMXCIX + PrintN(decRoman(1666)) ;MDCLXVI + PrintN(decRoman(25)) ;XXV + PrintN(decRoman(954)) ;CMLIV + + Print(#CRLF$ + #CRLF$ + "Press ENTER to exit") + Input() + CloseConsole() +EndIf diff --git a/Task/Roman-numerals-Encode/Python/roman-numerals-encode-1.py b/Task/Roman-numerals-Encode/Python/roman-numerals-encode-1.py new file mode 100644 index 0000000000..dade3e11ee --- /dev/null +++ b/Task/Roman-numerals-Encode/Python/roman-numerals-encode-1.py @@ -0,0 +1,24 @@ +roman = "MDCLXVmdclxvi"; # UPPERCASE for thousands # +adjust_roman = "CCXXmmccxxii"; +arabic = (1000000, 500000, 100000, 50000, 10000, 5000, 1000, 500, 100, 50, 10, 5, 1); +adjust_arabic = (100000, 100000, 10000, 10000, 1000, 1000, 100, 100, 10, 10, 1, 1, 0); + +def arabic_to_roman(dclxvi): + org = dclxvi; # 666 # + out = ""; + for scale,arabic_scale in enumerate(arabic): + if org == 0: break + multiples = org / arabic_scale; + org -= arabic_scale * multiples; + out += roman[scale] * multiples; + if org >= -adjust_arabic[scale] + arabic_scale: + org -= -adjust_arabic[scale] + arabic_scale; + out += adjust_roman[scale] + roman[scale] + return out + +if __name__ == "__main__": + test = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,25,30,40,50,60,69,70, + 80,90,99,100,200,300,400,500,600,666,700,800,900,1000,1009,1444,1666,1945,1997,1999, + 2000,2008,2500,3000,4000,4999,5000,6666,10000,50000,100000,500000,1000000); + for val in test: + print '%d - %s'%(val, arabic_to_roman(val)) diff --git a/Task/Roman-numerals-Encode/Python/roman-numerals-encode-2.py b/Task/Roman-numerals-Encode/Python/roman-numerals-encode-2.py new file mode 100644 index 0000000000..0f21730816 --- /dev/null +++ b/Task/Roman-numerals-Encode/Python/roman-numerals-encode-2.py @@ -0,0 +1,16 @@ +romanDgts= 'ivxlcdmVXLCDM_' + +def ToRoman(num): + namoR = '' + if num >=4000000: + print 'Too Big -' + return '-----' + for rdix in range(0, len(romanDgts), 2): + if num==0: break + num,r = divmod(num,10) + v,r = divmod(r, 5) + if r==4: + namoR += romanDgts[rdix+1+v] + romanDgts[rdix] + else: + namoR += r*romanDgts[rdix] + (romanDgts[rdix+1] if(v==1) else '') + return namoR[-1::-1] diff --git a/Task/Roman-numerals-Encode/Python/roman-numerals-encode-3.py b/Task/Roman-numerals-Encode/Python/roman-numerals-encode-3.py new file mode 100644 index 0000000000..263e5d4d6e --- /dev/null +++ b/Task/Roman-numerals-Encode/Python/roman-numerals-encode-3.py @@ -0,0 +1,18 @@ +anums = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1] +rnums = "M CM D CD C XC L XL X IX V IV I".split() + +def to_roman(x): + ret = [] + for a,r in zip(anums, rnums): + n,x = divmod(x,a) + ret.append(r*n) + return ''.join(ret) + +if __name__ == "__main__": + test = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,25,30,40, + 50,60,69,70,80,90,99,100,200,300,400,500,600,666,700,800,900, + 1000,1009,1444,1666,1945,1997,1999,2000,2008,2010,2011,2500, + 3000,3999) + + for val in test: + print '%d - %s'%(val, to_roman(val)) diff --git a/Task/Roman-numerals-Encode/R/roman-numerals-encode-1.r b/Task/Roman-numerals-Encode/R/roman-numerals-encode-1.r new file mode 100644 index 0000000000..3d4229b724 --- /dev/null +++ b/Task/Roman-numerals-Encode/R/roman-numerals-encode-1.r @@ -0,0 +1 @@ +as.roman(1666) # MDCLXVI diff --git a/Task/Roman-numerals-Encode/R/roman-numerals-encode-2.r b/Task/Roman-numerals-Encode/R/roman-numerals-encode-2.r new file mode 100644 index 0000000000..40217744ae --- /dev/null +++ b/Task/Roman-numerals-Encode/R/roman-numerals-encode-2.r @@ -0,0 +1 @@ +as.roman(1666) + 334 # MM diff --git a/Task/Roman-numerals-Encode/REXX/roman-numerals-encode-1.rexx b/Task/Roman-numerals-Encode/REXX/roman-numerals-encode-1.rexx new file mode 100644 index 0000000000..249e70c0e8 --- /dev/null +++ b/Task/Roman-numerals-Encode/REXX/roman-numerals-encode-1.rexx @@ -0,0 +1,17 @@ +roman: procedure +arg number + +/* handle only 1 to 3999, else return ? */ +if number >= 4000 | number <= 0 then return "?" + +romans = " M CM D CD C XC L XL X IX V IV I" +arabic = "1000 900 500 400 100 90 50 40 10 9 5 4 1" + +result = "" +do i = 1 to words(romans) + do while number >= word(arabic,i) + result = result || word(romans,i) + number = number - word(arabic,i) + end +end +return result diff --git a/Task/Roman-numerals-Encode/REXX/roman-numerals-encode-2.rexx b/Task/Roman-numerals-Encode/REXX/roman-numerals-encode-2.rexx new file mode 100644 index 0000000000..245c16ed42 --- /dev/null +++ b/Task/Roman-numerals-Encode/REXX/roman-numerals-encode-2.rexx @@ -0,0 +1,64 @@ +/*REXX program converts (Arabic) decimal numbers (≥0) ──► Roman numerals*/ +numeric digits 10000 /*could be higher if wanted*/ +parse arg nums + +if nums='' then do /*not specified? Gen some.*/ + do j=0 by 11 to 111 + nums=nums j + end /*j*/ + nums=nums 49 + do k=88 by 100 to 1200 + nums=nums k + end /*k*/ + nums=nums 1000 2000 3000 4000 5000 6000 + do m=88 by 200 to 1200 + nums=nums m + end /*m*/ + nums=nums 1304 1405 1506 1607 1708 1809 1910 2011 + do p=4 to 50 /*there is no limit to this*/ + nums=nums 10**p + end /*p*/ + end /*end generation of numbers*/ + + do i=1 for words(nums); x=word(nums,i) + say right(x,55) dec2rom(x) + end /*i*/ +exit /*stick a fork in it, we're done.*/ +/*───────────────────────────DEC2ROM subroutine─────────────────────────*/ +dec2rom: procedure; parse arg n,# /*get number, assign # to a null. */ +n=space(translate(n,,','),0) /*remove any commas from number. */ +nulla='ZEPHIRUM NULLAE NULLA NIHIL' /*Roman words for nothing or none.*/ +if n==0 then return word(nulla,1) /*return a Roman word for zero. */ +maxnp=(length(n)-1)%3 /*find max(+1) # of parens to use.*/ +highPos=(maxnp+1)*3 /*highest position of number. */ +nn=reverse(right(n,highPos,0)) /*digits for Arabic───►Roman conv.*/ +nine=9 +four=4; do j=highPos to 1 by -3 + _=substr(nn,j,1); select + when _==nine then hx='CM' + when _>= 5 then hx='D'copies("C",_-5) + when _==four then hx='CD' + otherwise hx=copies('C',_) + end + _=substr(nn,j-1,1); select + when _==nine then tx='XC' + when _>= 5 then tx='L'copies("X",_-5) + when _==four then tx='XL' + otherwise tx=copies('X',_) + end + _=substr(nn,j-2,1); select + when _==nine then ux='IX' + when _>= 5 then ux='V'copies("I",_-5) + when _==four then ux='IV' + otherwise ux=copies('I',_) + end + xx=hx || tx || ux + if xx\=='' then #=# ||copies('(',(j-1)%3)xx ||copies(')',(j-1)%3) + end /*j*/ + +if pos('(I',#)\==0 then do i=1 for 4 /*special case: M,MM,MMM,MMMM.*/ + if i==4 then _ = '(IV)' + else _ = '('copies("I",i)')' + if pos(_,#)\==0 then #=changestr(_,#,copies('M',i)) + end /*i*/ +return # diff --git a/Task/Roman-numerals-Encode/Retro/roman-numerals-encode.retro b/Task/Roman-numerals-Encode/Retro/roman-numerals-encode.retro new file mode 100644 index 0000000000..24f702136e --- /dev/null +++ b/Task/Roman-numerals-Encode/Retro/roman-numerals-encode.retro @@ -0,0 +1,24 @@ +: vector ( ...n"- ) + here [ &, times ] dip : .data ` swap ` + ` @ ` do ` ; ; +: .I dup @ ^buffer'add ; +: .V dup 1 + @ ^buffer'add ; +: .X dup 2 + @ ^buffer'add ; + +[ .I .X drop ] +[ .V .I .I .I drop ] +[ .V .I .I drop ] +[ .V .I drop ] +[ .V drop ] +[ .I .V drop ] +[ .I .I .I drop ] +[ .I .I drop ] +[ .I drop ] +&drop +10 vector .digit + +: record ( an- ) + 10 /mod dup [ [ over 2 + ] dip record ] &drop if .digit ; +: toRoman ( n-a ) + here ^buffer'set + dup 1 3999 within 0 = + [ "EX LIMITO!\n" ] [ "IVXLCDM" swap record here ] if ; diff --git a/Task/Roman-numerals-Encode/Ruby/roman-numerals-encode.rb b/Task/Roman-numerals-Encode/Ruby/roman-numerals-encode.rb new file mode 100644 index 0000000000..95e86d6537 --- /dev/null +++ b/Task/Roman-numerals-Encode/Ruby/roman-numerals-encode.rb @@ -0,0 +1,10 @@ +Symbols = { 1=>'I', 5=>'V', 10=>'X', 50=>'L', 100=>'C', 500=>'D', 1000=>'M' } +Subtractors = [ [1000, 100], [500, 100], [100, 10], [50, 10], [10, 1], [5, 1], [1, 0] ] + +def roman(num) + return Symbols[num] if Symbols.has_key?(num) + Subtractors.each do |cutPoint, subtractor| + return roman(cutPoint) + roman(num - cutPoint) if num > cutPoint + return roman(subtractor) + roman(num + subtractor) if num >= cutPoint - subtractor and num < cutPoint + end +end diff --git a/Task/Roman-numerals-Encode/Run-BASIC/roman-numerals-encode.run b/Task/Roman-numerals-Encode/Run-BASIC/roman-numerals-encode.run new file mode 100644 index 0000000000..65e9412f4f --- /dev/null +++ b/Task/Roman-numerals-Encode/Run-BASIC/roman-numerals-encode.run @@ -0,0 +1,20 @@ +[loop] +input "Input value:";val$ +print roman$(val$) +goto [loop] + +' ------------------------------ +' Roman numerals +' ------------------------------ +FUNCTION roman$(val$) +a2r$ = "M:1000,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1" +v = val(val$) +for i = 1 to 13 + r$ = word$(a2r$,i,",") + a = val(word$(r$,2,":")) + while v >= a + roman$ = roman$ + word$(r$,1,":") + v = v - a + wend +next i +END FUNCTION diff --git a/Task/Roman-numerals-Encode/SNOBOL4/roman-numerals-encode-1.sno b/Task/Roman-numerals-Encode/SNOBOL4/roman-numerals-encode-1.sno new file mode 100644 index 0000000000..0e1fa9261a --- /dev/null +++ b/Task/Roman-numerals-Encode/SNOBOL4/roman-numerals-encode-1.sno @@ -0,0 +1,31 @@ +* ROMAN(N) - Convert integer N to Roman numeral form. +* +* N must be positive and less than 4000. +* +* An asterisk appears in the result if N >= 4000. +* +* The function fails if N is not an integer. + + DEFINE('ROMAN(N)UNITS') :(ROMAN_END) + +* Get rightmost digit to UNITS and remove it from N. +* Return null result if argument is null. +ROMAN N RPOS(1) LEN(1) . UNITS = :F(RETURN) + +* Search for digit, replace with its Roman form. +* Return failing if not a digit. + '0,1I,2II,3III,4IV,5V,6VI,7VII,8VIII,9IX,' UNITS ++ BREAK(',') . UNITS :F(FRETURN) + +* Convert rest of N and multiply by 10. Propagate a +* failure return from recursive call back to caller. + ROMAN = REPLACE(ROMAN(N), 'IVXLCDM', 'XLCDM**') ++ UNITS :S(RETURN) F(FRETURN) +ROMAN_END + +* Testing + OUTPUT = "1999 = " ROMAN(1999) + OUTPUT = " 24 = " ROMAN(24) + OUTPUT = " 944 = " ROMAN(944) + +END diff --git a/Task/Roman-numerals-Encode/SNOBOL4/roman-numerals-encode-2.sno b/Task/Roman-numerals-Encode/SNOBOL4/roman-numerals-encode-2.sno new file mode 100644 index 0000000000..65372a354f --- /dev/null +++ b/Task/Roman-numerals-Encode/SNOBOL4/roman-numerals-encode-2.sno @@ -0,0 +1,29 @@ +* # Arabic to Roman + define('roman(n)s,ch,val,str') :(roman_end) +roman roman = ge(n,4000) n :s(return) + s = 'M1000 CM900 D500 CD400 C100 XC90 L50 XL40 X10 IX9 V5 IV4 I1 ' +rom1 s span(&ucase) . ch break(' ') . val span(' ') = :f(rom2) + str = str dupl(ch,(n / val)) + n = remdr(n,val) :(rom1) +rom2 roman = str :(return) +roman_end + +* # Roman to Arabic + define('arabic(n)s,ch,val,sum,x') :(arabic_end) +arabic s = 'M1000 D500 C100 L50 X10 V5 I1 ' + n = reverse(n) +arab1 n len(1) . ch = :f(arab2) + s ch break(' ') . val + val = lt(val,x) (-1 * val) + sum = sum + val; x = val :(arab1) +arab2 arabic = sum :(return) +arabic_end + +* # Test and display + tstr = '2010 1999 1492 1066 476 ' +tloop tstr break(' ') . year span(' ') = :f(out) + r = roman(year) + rstr = rstr year '=' r ' ' + astr = astr r '=' arabic(r) ' ' :(tloop) +out output = rstr; output = astr +end diff --git a/Task/Roman-numerals-Encode/SQL/roman-numerals-encode.sql b/Task/Roman-numerals-Encode/SQL/roman-numerals-encode.sql new file mode 100644 index 0000000000..cff356195f --- /dev/null +++ b/Task/Roman-numerals-Encode/SQL/roman-numerals-encode.sql @@ -0,0 +1,16 @@ +-- +-- This only works under Oracle and has the limitation of 1 to 3999 +--- Higher numbers in the Middle Ages were represented by "superscores" on top of the numeral to multiply by 1000 +--- Vertical bars to the sides multiply by 100. So |M| means 100,000 +-- When the query is run, user provides the Arabic numerals for the ar_year +-- A.Kebedjiev +-- + +SELECT to_char(to_char(to_date(&ar_year,'YYYY'), 'RRRR'), 'RN') AS roman_year FROM DUAL; + +-- or you can type in the year directly + +SELECT to_char(to_char(to_date(1666,'YYYY'), 'RRRR'), 'RN') AS roman_year FROM DUAL; + +ROMAN_YEAR +MDCLXVI diff --git a/Task/Roman-numerals-Encode/Scala/roman-numerals-encode-1.scala b/Task/Roman-numerals-Encode/Scala/roman-numerals-encode-1.scala new file mode 100644 index 0000000000..6b206d5fab --- /dev/null +++ b/Task/Roman-numerals-Encode/Scala/roman-numerals-encode-1.scala @@ -0,0 +1,13 @@ +val romanDigits = Map( + 1 -> "I", 5 -> "V", + 10 -> "X", 50 -> "L", + 100 -> "C", 500 -> "D", + 1000 -> "M", + 4 -> "IV", 9 -> "IX", + 40 -> "XL", 90 -> "XC", + 400 -> "CD", 900 -> "CM") +val romanDigitsKeys = romanDigits.keysIterator.toList sortBy (x => -x) +def toRoman(n: Int): String = romanDigitsKeys find (_ >= n) match { + case Some(key) => romanDigits(key) + toRoman(n - key) + case None => "" +} diff --git a/Task/Roman-numerals-Encode/Scala/roman-numerals-encode-2.scala b/Task/Roman-numerals-Encode/Scala/roman-numerals-encode-2.scala new file mode 100644 index 0000000000..c5e528f392 --- /dev/null +++ b/Task/Roman-numerals-Encode/Scala/roman-numerals-encode-2.scala @@ -0,0 +1,14 @@ +def toRoman( v:Int ) : String = { + val romanNumerals = List(1000->"M",900->"CM",500->"D",400->"CD",100->"C",90->"XC", + 50->"L",40->"XL",10->"X",9->"IX",5->"V",4->"IV",1->"I") + + var n = v + romanNumerals.foldLeft(""){(s,t) => {val c = n/t._1; n = n-t._1*c; s + (t._2 * c) } } +} + +// A small test +def test( arabic:Int ) = println( arabic + " => " + toRoman( arabic ) ) + +test(1990) +test(2008) +test(1666) diff --git a/Task/Roman-numerals-Encode/Scheme/roman-numerals-encode.ss b/Task/Roman-numerals-Encode/Scheme/roman-numerals-encode.ss new file mode 100644 index 0000000000..992b6a9950 --- /dev/null +++ b/Task/Roman-numerals-Encode/Scheme/roman-numerals-encode.ss @@ -0,0 +1,2 @@ +(define (to-roman n) + (format "~@r" n)) diff --git a/Task/Roman-numerals-Encode/Seed7/roman-numerals-encode.seed7 b/Task/Roman-numerals-Encode/Seed7/roman-numerals-encode.seed7 new file mode 100644 index 0000000000..aa611e1d82 --- /dev/null +++ b/Task/Roman-numerals-Encode/Seed7/roman-numerals-encode.seed7 @@ -0,0 +1,12 @@ +$ include "seed7_05.s7i"; + include "stdio.s7i"; + include "wrinum.s7i"; + +const proc: main is func + local + var integer: number is 0; + begin + for number range 1 to 3999 do + writeln(str(ROMAN, number)); + end for; + end func; diff --git a/Task/Roman-numerals-Encode/Smalltalk/roman-numerals-encode-1.st b/Task/Roman-numerals-Encode/Smalltalk/roman-numerals-encode-1.st new file mode 100644 index 0000000000..d89c6d894b --- /dev/null +++ b/Task/Roman-numerals-Encode/Smalltalk/roman-numerals-encode-1.st @@ -0,0 +1 @@ +2013 printRomanOn:Stdout naive:false diff --git a/Task/Roman-numerals-Encode/Smalltalk/roman-numerals-encode-2.st b/Task/Roman-numerals-Encode/Smalltalk/roman-numerals-encode-2.st new file mode 100644 index 0000000000..a524510604 --- /dev/null +++ b/Task/Roman-numerals-Encode/Smalltalk/roman-numerals-encode-2.st @@ -0,0 +1,53 @@ +printRomanOn:aStream naive:naive + "print the receiver as roman number to the argument, aStream. + The naive argument controls if the conversion is + correct (i.e. subtracting prefix notation for 4,9,40,90, etc.), + or naive (i.e. print 4 as IIII and 9 as VIIII); also called simple. + The naive version is often used for page numbers in documents." + + |restValue spec| + + restValue := self. + restValue > 0 ifFalse:[self error:'negative roman']. + + naive ifTrue:[ + spec := #( + " value string repeat " + 1000 'M' true + 500 'D' false + 100 'C' true + 50 'L' false + 10 'X' true + 5 'V' false + 1 'I' true + ). + ] ifFalse:[ + spec := #( + " value string repeat " + 1000 'M' true + 900 'CM' false + 500 'D' false + 400 'CD' false + 100 'C' true + 90 'XC' false + 50 'L' false + 40 'XL' false + 10 'X' true + 9 'IX' false + 5 'V' false + 4 'IV' false + 1 'I' true + ). + ]. + + spec + inGroupsOf:3 + do:[:rValue :rString :repeatFlag | + + [ + (restValue >= rValue) ifTrue:[ + aStream nextPutAll:rString. + restValue := restValue - rValue. + ]. + ] doWhile:[ repeatFlag and:[ restValue >= rValue] ]. + ]. diff --git a/Task/Roman-numerals-Encode/TI-83-BASIC/roman-numerals-encode.ti-83 b/Task/Roman-numerals-Encode/TI-83-BASIC/roman-numerals-encode.ti-83 new file mode 100644 index 0000000000..9eb35881d9 --- /dev/null +++ b/Task/Roman-numerals-Encode/TI-83-BASIC/roman-numerals-encode.ti-83 @@ -0,0 +1,84 @@ +PROGRAM:DEC2ROM +:"="→Str1 +:Lbl ST +:ClrHome +:Disp "NUMBER TO" +:Disp "CONVERT:" +:Input A +:If fPart(A) or A≠abs(A) +:Then +:Goto PI +:End +:A→B +:While B≥1000 +:Str1+"M"→Str1 +:B-1000→B +:End +:If B≥900 +:Then +:Str1+"CM"→Str1 +:B-900→B +:End +:If B≥500 +:Then +:Str1+"D"→Str1 +:B-500→B +:End +:If B≥400 +:Then +:Str1+"CD"?Str1 +:B-400→B +:End +:While B≥100 +:Str1+"C"→Str1 +:B-100→B +:End +:If B≥90 +:Then +:Str1+"XC"→Str1 +:B-90→B +:End +:If B≥50 +:Then +:Str1+"L"→Str1 +:B-50→B +:End +:If B≥40 +:Then +:Str1+"XL"→Str1 +:B-40→B +:End +:While B≥10 +:Str1+"X"→Str1 +:B-10→B +:End +:If B≥9 +:Then +:Str1+"IX"→Str1 +:B-9→B +:End +:If B≥5 +:Then +:Str1+"V"→Str1 +:B-5→B +:End +:If B≥4 +:Then +:Str1+"IV"→Str1 +:B-4→B +:End +:While B>0 +:Str1+"I"→Str1 +:B-1→B +:End +:ClrHome +:Disp A +:Disp Str1 +:Stop +:Lbl PI +:ClrHome +:Disp "THE NUMBER MUST" +:Disp "BE A POSITIVE" +:Disp "INTEGER." +:Pause +:Goto ST diff --git a/Task/Roman-numerals-Encode/TUSCRIPT/roman-numerals-encode.tuscript b/Task/Roman-numerals-Encode/TUSCRIPT/roman-numerals-encode.tuscript new file mode 100644 index 0000000000..8534a8c221 --- /dev/null +++ b/Task/Roman-numerals-Encode/TUSCRIPT/roman-numerals-encode.tuscript @@ -0,0 +1,5 @@ +$$ MODE TUSCRIPT +LOOP arab_number="1990'2008'1666" +roman_number = ENCODE (arab_number,ROMAN) +PRINT "Arabic number ",arab_number, " equals ", roman_number +ENDLOOP diff --git a/Task/Roman-numerals-Encode/Tcl/roman-numerals-encode.tcl b/Task/Roman-numerals-Encode/Tcl/roman-numerals-encode.tcl new file mode 100644 index 0000000000..febffd05f2 --- /dev/null +++ b/Task/Roman-numerals-Encode/Tcl/roman-numerals-encode.tcl @@ -0,0 +1,10 @@ +proc to_roman {i} { + set map {1000 M 900 CM 500 D 400 CD 100 C 90 XC 50 L 40 XL 10 X 9 IX 5 V 4 IV 1 I} + foreach {value roman} $map { + while {$i >= $value} { + append res $roman + incr i -$value + } + } + return $res +} diff --git a/Task/Roman-numerals-Encode/Ursala/roman-numerals-encode-1.ursala b/Task/Roman-numerals-Encode/Ursala/roman-numerals-encode-1.ursala new file mode 100644 index 0000000000..d949768588 --- /dev/null +++ b/Task/Roman-numerals-Encode/Ursala/roman-numerals-encode-1.ursala @@ -0,0 +1,7 @@ +#import nat + +roman = + +-+ + 'IIII'%='IV'+ 'VIIII'%='IX'+ 'XXXX'%='XL'+ 'LXXXX'%='XC'+ 'CCCC'%='CD'+ 'DCCCC'%='CM', + ~&plrDlSPSL/'MDCLXVI'+ iota*+ +^|(^|C/~&,\/division)@rlX=>~&iNC <1000,500,100,50,10,5>+- diff --git a/Task/Roman-numerals-Encode/Ursala/roman-numerals-encode-2.ursala b/Task/Roman-numerals-Encode/Ursala/roman-numerals-encode-2.ursala new file mode 100644 index 0000000000..cd1758c550 --- /dev/null +++ b/Task/Roman-numerals-Encode/Ursala/roman-numerals-encode-2.ursala @@ -0,0 +1,3 @@ +#show+ + +test = roman* <1990,2008,1,2,64,124,1666,10001> diff --git a/Task/Roman-numerals-Encode/Vedit-macro-language/roman-numerals-encode.vedit b/Task/Roman-numerals-Encode/Vedit-macro-language/roman-numerals-encode.vedit new file mode 100644 index 0000000000..d3cc4c7ff3 --- /dev/null +++ b/Task/Roman-numerals-Encode/Vedit-macro-language/roman-numerals-encode.vedit @@ -0,0 +1,32 @@ +// Main program for testing the function +// +do { + #1 = Get_Num("Number to convert: ", STATLINE) + Call("NUM_TO_ROMAN") + Num_Type(#1, NOCR) Message(" = ") Reg_Type(1) Type_Newline +} while (Reg_Size(1)) +Return + +// Convert numeric value into Roman number +// #1 = number to convert; on return: T-reg(1) = Roman number +// +:NUM_TO_ROMAN: + Reg_Empty(1) // @1 = Results (Roman number) + if (#1 < 1) { Return } // non-positive numbers return empty string + + Buf_Switch(Buf_Free) + Ins_Text("M1000,CM900,D500,CD400,C100,XC90,L50,XL40,X10,IX9,V5,IV4,I1") + + BOF + #2 = #1 + Repeat(ALL) { + Search("|A|[|A]", ADVANCE+ERRBREAK) // get next item from conversion list + Reg_Copy_Block(20, CP-Chars_Matched, CP) // @20 = Letter(s) to be inserted + #11 = Num_Eval() // #11 = magnitude (1000...1) + while (#2 >= #11) { + Reg_Set(1, @20, APPEND) + #2 -= #11 + } + } + Buf_Quit(OK) +Return diff --git a/Task/Roman-numerals-Encode/Visual-Basic/roman-numerals-encode.vb b/Task/Roman-numerals-Encode/Visual-Basic/roman-numerals-encode.vb new file mode 100644 index 0000000000..3f36264910 --- /dev/null +++ b/Task/Roman-numerals-Encode/Visual-Basic/roman-numerals-encode.vb @@ -0,0 +1,22 @@ +Function toRoman(value) As String + Dim arabic As Variant + Dim roman As Variant + + arabic = Array(1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1) + roman = Array("M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I") + + Dim i As Integer, result As String + + For i = 0 To 12 + Do While value >= arabic(i) + result = result + roman(i) + value = value - arabic(i) + Loop + Next i + + toRoman = result +End Function + +Sub Main() + MsgBox toRoman(Val(InputBox("Number, please"))) +End Sub diff --git a/Task/Roman-numerals-Encode/XSLT/roman-numerals-encode.xslt b/Task/Roman-numerals-Encode/XSLT/roman-numerals-encode.xslt new file mode 100644 index 0000000000..b33d08990a --- /dev/null +++ b/Task/Roman-numerals-Encode/XSLT/roman-numerals-encode.xslt @@ -0,0 +1,50 @@ + + + + 13 + + + + + + 1 + 1 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Task/Roots-of-a-function/0DESCRIPTION b/Task/Roots-of-a-function/0DESCRIPTION new file mode 100644 index 0000000000..23295a88f4 --- /dev/null +++ b/Task/Roots-of-a-function/0DESCRIPTION @@ -0,0 +1,3 @@ +Create a program that finds and outputs the roots of a given function, range and (if applicable) step width. The program should identify whether the root is exact or approximate. + +For this example, use f(x)=x3-3x2+2x. diff --git a/Task/Roots-of-a-function/1META.yaml b/Task/Roots-of-a-function/1META.yaml new file mode 100644 index 0000000000..8644b2ad9b --- /dev/null +++ b/Task/Roots-of-a-function/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Arithmetic operations diff --git a/Task/Roots-of-a-function/ALGOL-68/roots-of-a-function.alg b/Task/Roots-of-a-function/ALGOL-68/roots-of-a-function.alg new file mode 100644 index 0000000000..4d81b0a5ab --- /dev/null +++ b/Task/Roots-of-a-function/ALGOL-68/roots-of-a-function.alg @@ -0,0 +1,70 @@ +MODE DBL = LONG REAL; +FORMAT dbl = $g(-long real width, long real width-6, -2)$; + +MODE XY = STRUCT(DBL x, y); +FORMAT xy root = $f(dbl)" ("b("Exactly", "Approximately")")"$; + +MODE DBLOPT = UNION(DBL, VOID); +MODE XYRES = UNION(XY, VOID); + +PROC find root = (PROC (DBL)DBL f, DBLOPT in x1, in x2, in x error, in y error)XYRES:( + INT limit = ENTIER (long real width / log(2)); # worst case of a binary search) # + DBL x1 := (in x1|(DBL x1):x1|-5.0), # if x1 is EMPTY then -5.0 # + x2 := (in x2|(DBL x2):x2|+5.0), + x error := (in x error|(DBL x error):x error|small real), + y error := (in y error|(DBL y error):y error|small real); + DBL y1 := f(x1), y2; + DBL dx := x1 - x2, dy; + + IF y1 = 0 THEN + XY(x1, y1) # we already have a solution! # + ELSE + FOR i WHILE + y2 := f(x2); + IF y2 = 0 THEN stop iteration FI; + IF i = limit THEN value error FI; + IF y1 = y2 THEN value error FI; + dy := y1 - y2; + dx := dx / dy * y2; + x1 := x2; y1 := y2; # retain for next iteration # + x2 -:= dx; + # WHILE # ABS dx > x error AND ABS dy > y error DO + SKIP + OD; + stop iteration: + XY(x2, y2) EXIT + value error: + EMPTY + FI +); + +PROC f = (DBL x)DBL: x UP 3 - LONG 3.1 * x UP 2 + LONG 2.0 * x; + +DBL first root, second root, third root; + +XYRES first result = find root(f, LENG -1.0, LENG 3.0, EMPTY, EMPTY); +CASE first result IN + (XY first result): ( + printf(($"1st root found at x = "f(xy root)l$, x OF first result, y OF first result=0)); + first root := x OF first result + ) + OUT printf($"No first root found"l$); stop +ESAC; + +XYRES second result = find root( (DBL x)DBL: f(x) / (x - first root), EMPTY, EMPTY, EMPTY, EMPTY); +CASE second result IN + (XY second result): ( + printf(($"2nd root found at x = "f(xy root)l$, x OF second result, y OF second result=0)); + second root := x OF second result + ) + OUT printf($"No second root found"l$); stop +ESAC; + +XYRES third result = find root( (DBL x)DBL: f(x) / (x - first root) / ( x - second root ), EMPTY, EMPTY, EMPTY, EMPTY); +CASE third result IN + (XY third result): ( + printf(($"3rd root found at x = "f(xy root)l$, x OF third result, y OF third result=0)); + third root := x OF third result + ) + OUT printf($"No third root found"l$); stop +ESAC diff --git a/Task/Roots-of-a-function/Ada/roots-of-a-function.ada b/Task/Roots-of-a-function/Ada/roots-of-a-function.ada new file mode 100644 index 0000000000..b0d1f1fc37 --- /dev/null +++ b/Task/Roots-of-a-function/Ada/roots-of-a-function.ada @@ -0,0 +1,39 @@ +with Ada.Text_Io; use Ada.Text_Io; + +procedure Roots_Of_Function is + package Real_Io is new Ada.Text_Io.Float_Io(Long_Float); + use Real_Io; + + function F(X : Long_Float) return Long_Float is + begin + return (X**3 - 3.0*X*X + 2.0*X); + end F; + + Step : constant Long_Float := 1.0E-6; + Start : constant Long_Float := -1.0; + Stop : constant Long_Float := 3.0; + Value : Long_Float := F(Start); + Sign : Boolean := Value > 0.0; + X : Long_Float := Start + Step; + +begin + if Value = 0.0 then + Put("Root found at "); + Put(Item => Start, Fore => 1, Aft => 6, Exp => 0); + New_Line; + end if; + while X <= Stop loop + Value := F(X); + if (Value > 0.0) /= Sign then + Put("Root found near "); + Put(Item => X, Fore => 1, Aft => 6, Exp => 0); + New_Line; + elsif Value = 0.0 then + Put("Root found at "); + Put(Item => X, Fore => 1, Aft => 6, Exp => 0); + New_Line; + end if; + Sign := Value > 0.0; + X := X + Step; + end loop; +end Roots_Of_Function; diff --git a/Task/Roots-of-a-function/AutoHotkey/roots-of-a-function.ahk b/Task/Roots-of-a-function/AutoHotkey/roots-of-a-function.ahk new file mode 100644 index 0000000000..455c937e62 --- /dev/null +++ b/Task/Roots-of-a-function/AutoHotkey/roots-of-a-function.ahk @@ -0,0 +1,36 @@ +MsgBox % roots("poly", -0.99, 2, 0.1, 1.0e-5) +MsgBox % roots("poly", -1, 3, 0.1, 1.0e-5) + +roots(f,x1,x2,step,tol) { ; search for roots in intervals of length "step", within tolerance "tol" + x := x1, y := %f%(x), s := (y>0)-(y<0) + Loop % ceil((x2-x1)/step) { + x += step, y := %f%(x), t := (y>0)-(y<0) + If (s=0 || s!=t) + res .= root(f, x-step, x, tol) " [" ErrorLevel "]`n" + s := t + } + Sort res, UN ; remove duplicate endpoints + Return res +} + +root(f,x1,x2,d) { ; find x in [x1,x2]: f(x)=0 within tolerance d, by bisection + If (!y1 := %f%(x1)) + Return x1, ErrorLevel := "Exact" + If (!y2 := %f%(x2)) + Return x2, ErrorLevel := "Exact" + If (y1*y2>0) + Return "", ErrorLevel := "Need different sign ends!" + Loop { + x := (x2+x1)/2, y := %f%(x) + If (y = 0 || x2-x1 < d) + Return x, ErrorLevel := y ? "Approximate" : "Exact" + If ((y>0) = (y1>0)) + x1 := x, y1 := y + Else + x2 := x, y2 := y + } +} + +poly(x) { + Return ((x-3)*x+2)*x +} diff --git a/Task/Roots-of-a-function/Axiom/roots-of-a-function-1.axiom b/Task/Roots-of-a-function/Axiom/roots-of-a-function-1.axiom new file mode 100644 index 0000000000..7f426a52c3 --- /dev/null +++ b/Task/Roots-of-a-function/Axiom/roots-of-a-function-1.axiom @@ -0,0 +1,2 @@ +expr := x^3-3*x^2+2*x +solve(expr,x) diff --git a/Task/Roots-of-a-function/Axiom/roots-of-a-function-2.axiom b/Task/Roots-of-a-function/Axiom/roots-of-a-function-2.axiom new file mode 100644 index 0000000000..cf34bee208 --- /dev/null +++ b/Task/Roots-of-a-function/Axiom/roots-of-a-function-2.axiom @@ -0,0 +1,2 @@ + (1) [x= 2,x= 1,x= 0] + Type: List(Equation(Fraction(Polynomial(Integer)))) diff --git a/Task/Roots-of-a-function/Axiom/roots-of-a-function-3.axiom b/Task/Roots-of-a-function/Axiom/roots-of-a-function-3.axiom new file mode 100644 index 0000000000..f58cae84e2 --- /dev/null +++ b/Task/Roots-of-a-function/Axiom/roots-of-a-function-3.axiom @@ -0,0 +1,15 @@ +digits(30) +secant(eq: Equation Expression Float, binding: SegmentBinding(Float)):Float == + eps := 1.0e-30 + expr := lhs eq - rhs eq + x := variable binding + seg := segment binding + x1 := lo seg + x2 := hi seg + fx1 := eval(expr, x=x1)::Float + abs(fx1) return x1 + for i in 1..100 repeat + fx2 := eval(expr, x=x2)::Float + abs(fx2) return x2 + (x1, fx1, x2) := (x2, fx2, x2 - fx2 * (x2 - x1) / (fx2 - fx1)) + error "Function not converging." diff --git a/Task/Roots-of-a-function/Axiom/roots-of-a-function-4.axiom b/Task/Roots-of-a-function/Axiom/roots-of-a-function-4.axiom new file mode 100644 index 0000000000..64cbc6bb50 --- /dev/null +++ b/Task/Roots-of-a-function/Axiom/roots-of-a-function-4.axiom @@ -0,0 +1 @@ +secant(expr=0,x=-0.5..0.5) diff --git a/Task/Roots-of-a-function/BBC-BASIC/roots-of-a-function.bbc b/Task/Roots-of-a-function/BBC-BASIC/roots-of-a-function.bbc new file mode 100644 index 0000000000..5d24380dc6 --- /dev/null +++ b/Task/Roots-of-a-function/BBC-BASIC/roots-of-a-function.bbc @@ -0,0 +1,27 @@ + function$ = "x^3-3*x^2+2*x" + rangemin = -1 + rangemax = 3 + stepsize = 0.001 + accuracy = 1E-8 + PROCroots(function$, rangemin, rangemax, stepsize, accuracy) + END + + DEF PROCroots(func$, min, max, inc, eps) + LOCAL x, sign%, oldsign% + oldsign% = 0 + FOR x = min TO max STEP inc + sign% = SGN(EVAL(func$)) + IF sign% = 0 THEN + PRINT "Root found at x = "; x + sign% = -oldsign% + ELSE IF sign% <> oldsign% AND oldsign% <> 0 THEN + IF inc < eps THEN + PRINT "Root found near x = "; x + ELSE + PROCroots(func$, x-inc, x+inc/8, inc/8, eps) + ENDIF + ENDIF + ENDIF + oldsign% = sign% + NEXT x + ENDPROC diff --git a/Task/Roots-of-a-function/C++/roots-of-a-function.cpp b/Task/Roots-of-a-function/C++/roots-of-a-function.cpp new file mode 100644 index 0000000000..ff560c0f63 --- /dev/null +++ b/Task/Roots-of-a-function/C++/roots-of-a-function.cpp @@ -0,0 +1,36 @@ +#include + +double f(double x) +{ + return (x*x*x - 3*x*x + 2*x); +} + +int main() +{ + double step = 0.001; // Smaller step values produce more accurate and precise results + double start = -1; + double stop = 3; + double value = f(start); + double sign = (value > 0); + + // Check for root at start + if ( 0 == value ) + std::cout << "Root found at " << start << std::endl; + + for( double x = start + step; + x <= stop; + x += step ) + { + value = f(x); + + if ( ( value > 0 ) != sign ) + // We passed a root + std::cout << "Root found near " << x << std::endl; + else if ( 0 == value ) + // We hit a root + std::cout << "Root found at " << x << std::endl; + + // Update our sign + sign = ( value > 0 ); + } +} diff --git a/Task/Roots-of-a-function/C/roots-of-a-function.c b/Task/Roots-of-a-function/C/roots-of-a-function.c new file mode 100644 index 0000000000..1074d9d43d --- /dev/null +++ b/Task/Roots-of-a-function/C/roots-of-a-function.c @@ -0,0 +1,60 @@ +#include +#include + +double f(double x) +{ + return x*x*x-3.0*x*x +2.0*x; +} + +double secant( double xA, double xB, double(*f)(double) ) +{ + double e = 1.0e-12; + double fA, fB; + double d; + int i; + int limit = 50; + + fA=(*f)(xA); + for (i=0; i 0.0); + + while (x < 3.0) { + value = f(x); + if (fabs(value) < e) { + printf("Root found at x= %12.9f\n", x); + s = (f(x+.0001)>0.0); + } + else if ((value > 0.0) != s) { + xx = secant(x-step, x,&f); + if (xx != -99.0) // -99 meaning secand method failed + printf("Root found at x= %12.9f\n", xx); + else + printf("Root found near x= %7.4f\n", x); + s = (f(x+.0001)>0.0); + } + x += step; + } + return 0; +} diff --git a/Task/Roots-of-a-function/Clojure/roots-of-a-function.clj b/Task/Roots-of-a-function/Clojure/roots-of-a-function.clj new file mode 100644 index 0000000000..888c61506e --- /dev/null +++ b/Task/Roots-of-a-function/Clojure/roots-of-a-function.clj @@ -0,0 +1,2 @@ +(defn findRoots [f start stop step eps] + (filter #(-> (f %) Math/abs (< eps)) (range start stop step))) diff --git a/Task/Roots-of-a-function/CoffeeScript/roots-of-a-function-1.coffeescript b/Task/Roots-of-a-function/CoffeeScript/roots-of-a-function-1.coffeescript new file mode 100644 index 0000000000..068e54d192 --- /dev/null +++ b/Task/Roots-of-a-function/CoffeeScript/roots-of-a-function-1.coffeescript @@ -0,0 +1,35 @@ +print_roots = (f, begin, end, step) -> + # Print approximate roots of f between x=begin and x=end, + # using sign changes as an indicator that a root has been + # encountered. + x = begin + y = f(x) + last_y = y + + cross_x_axis = -> + (last_y < 0 and y > 0) or (last_y > 0 and y < 0) + + console.log '-----' + while x <= end + y = f(x) + if y == 0 + console.log "Root found at", x + else if cross_x_axis() + console.log "Root found near", x + x += step + last_y = y + +do -> + # Smaller steps produce more accurate/precise results in general, + # but for many functions we'll never get exact roots, either due + # to imperfect binary representation or irrational roots. + step = 1 / 256 + + f1 = (x) -> x*x*x - 3*x*x + 2*x + print_roots f1, -1, 5, step + f2 = (x) -> x*x - 4*x + 3 + print_roots f2, -1, 5, step + f3 = (x) -> x - 1.5 + print_roots f3, 0, 4, step + f4 = (x) -> x*x - 2 + print_roots f4, -2, 2, step diff --git a/Task/Roots-of-a-function/CoffeeScript/roots-of-a-function-2.coffeescript b/Task/Roots-of-a-function/CoffeeScript/roots-of-a-function-2.coffeescript new file mode 100644 index 0000000000..d1fa6484f6 --- /dev/null +++ b/Task/Roots-of-a-function/CoffeeScript/roots-of-a-function-2.coffeescript @@ -0,0 +1,13 @@ +> coffee roots.coffee +----- +Root found at 0 +Root found at 1 +Root found at 2 +----- +Root found at 1 +Root found at 3 +----- +Root found at 1.5 +----- +Root found near -1.4140625 +Root found near 1.41796875 diff --git a/Task/Roots-of-a-function/Common-Lisp/roots-of-a-function.lisp b/Task/Roots-of-a-function/Common-Lisp/roots-of-a-function.lisp new file mode 100644 index 0000000000..76d5438979 --- /dev/null +++ b/Task/Roots-of-a-function/Common-Lisp/roots-of-a-function.lisp @@ -0,0 +1,17 @@ +(defun find-roots (function start end &optional (step 0.0001)) + (let* ((roots '()) + (value (funcall function start)) + (plusp (plusp value))) + (when (zerop value) + (format t "~&Root found at ~W." start)) + (do ((x (+ start step) (+ x step))) + ((> x end) (nreverse roots)) + (setf value (funcall function x)) + (cond + ((zerop value) + (format t "~&Root found at ~w." x) + (push x roots)) + ((not (eql plusp (plusp value))) + (format t "~&Root found near ~w." x) + (push (cons (- x step) x) roots))) + (setf plusp (plusp value))))) diff --git a/Task/Roots-of-a-function/D/roots-of-a-function.d b/Task/Roots-of-a-function/D/roots-of-a-function.d new file mode 100644 index 0000000000..154bac805b --- /dev/null +++ b/Task/Roots-of-a-function/D/roots-of-a-function.d @@ -0,0 +1,71 @@ +import std.stdio, std.math, std.algorithm; + +bool nearZero(T)(in T a, in T b = T.epsilon * 4) pure nothrow { + return abs(a) <= b; +} + +T[] findRoot(T)(immutable T function(in T) pure nothrow f, + in T start, in T end, in T step=cast(T)0.001L, + T tolerance = cast(T)1e-4L) { + if (nearZero(step)) + writefln("WARNING: step size may be too small."); + immutable fi = f; + + /// Search root by simple bisection. + T searchRoot(T a, T b) pure nothrow { + T root; + int limit = 49; + T gap = b - a; + + while (!nearZero(gap) && limit--) { + if (nearZero(fi(a))) return a; + if (nearZero(fi(b))) return b; + root = (b + a) / 2.0L; + if (nearZero(fi(root))) return root; + if (fi(a) * fi(root) < 0) + b = root; + else + a = root; + gap = b - a; + } + + return root; + } + + immutable dir = cast(T)(end > start ? 1.0 : -1.0); + immutable step2 = (end > start) ? abs(step) : -abs(step); + T[T] result; + for (T x = start; (x * dir) <= (end * dir); x += step2) + if (f(x) * f(x + step2) <= 0) { + immutable T r = searchRoot(x, x + step2); + result[r] = f(r); + } + + return result.keys.sort().release(); +} + +void report(T)(in T[] r, immutable T function(in T) pure f, + in T tolerance = cast(T)1e-4L) { + if (r.length) { + writefln("Root found (tolerance = %1.4g):", tolerance); + foreach (x; r) { + immutable T y = f(x); + if (nearZero(y)) + writefln("... EXACTLY at %+1.20f, f(x) = %+1.4g",x,y); + else if (nearZero(y, tolerance)) + writefln(".... MAY-BE at %+1.20f, f(x) = %+1.4g",x,y); + else + writefln("Verify needed, f(%1.4g) = " ~ + "%1.4g > tolerance in magnitude", x, y); + } + } else + writefln("No root found."); +} + +real f(in real x) pure nothrow { + return x ^^ 3 - (3 * x ^^ 2) + 2 * x; +} + +void main() { + findRoot(&f, -1.0L, 3.0L, 0.001L).report(&f); +} diff --git a/Task/Roots-of-a-function/DWScript/roots-of-a-function.dwscript b/Task/Roots-of-a-function/DWScript/roots-of-a-function.dwscript new file mode 100644 index 0000000000..dd23426dc1 --- /dev/null +++ b/Task/Roots-of-a-function/DWScript/roots-of-a-function.dwscript @@ -0,0 +1,51 @@ +type TFunc = function (x : Float) : Float; + +function f(x : Float) : Float; +begin + Result := x*x*x-3.0*x*x +2.0*x; +end; + +const e = 1.0e-12; + +function Secant(xA, xB : Float; f : TFunc) : Float; +const + limit = 50; +var + fA, fB : Float; + d : Float; + i : Integer; +begin + fA := f(xA); + for i := 0 to limit do begin + fB := f(xB); + d := (xB-xA)/(fB-fA)*fB; + if Abs(d) < e then + Exit(xB); + xA := xB; + fA := fB; + xB -= d; + end; + PrintLn(Format('Function is not converging near (%7.4f,%7.4f).', [xA, xB])); + Result := -99.0; +end; + +const fstep = 1.0e-2; + +var x := -1.032; // just so we use secant method +var xx, value : Float; +var s := f(x)>0.0; + +while (x < 3.0) do begin + value := f(x); + if Abs(value)0.0); + end else if (value>0.0) <> s then begin + xx := Secant(x-fstep, x, f); + if xx <> -99.0 then // -99 meaning secand method failed + PrintLn(Format('Root found at x = %12.9f', [xx])) + else PrintLn(Format('Root found near x= %7.4f', [xx])); + s := (f(x+0.0001)>0.0); + end; + x += fstep; +end; diff --git a/Task/Roots-of-a-function/Fortran/roots-of-a-function-1.f b/Task/Roots-of-a-function/Fortran/roots-of-a-function-1.f new file mode 100644 index 0000000000..5df4e9efff --- /dev/null +++ b/Task/Roots-of-a-function/Fortran/roots-of-a-function-1.f @@ -0,0 +1,26 @@ +PROGRAM ROOTS_OF_A_FUNCTION + + IMPLICIT NONE + + INTEGER, PARAMETER :: dp = SELECTED_REAL_KIND(15) + REAL(dp) :: f, e, x, step, value + LOGICAL :: s + + f(x) = x*x*x - 3.0_dp*x*x + 2.0_dp*x + + x = -1.0_dp ; step = 1.0e-6_dp ; e = 1.0e-9_dp + + s = (f(x) > 0) + DO WHILE (x < 3.0) + value = f(x) + IF(ABS(value) < e) THEN + WRITE(*,"(A,F12.9)") "Root found at x =", x + s = .NOT. s + ELSE IF ((value > 0) .NEQV. s) THEN + WRITE(*,"(A,F12.9)") "Root found near x = ", x + s = .NOT. s + END IF + x = x + step + END DO + +END PROGRAM ROOTS_OF_A_FUNCTION diff --git a/Task/Roots-of-a-function/Fortran/roots-of-a-function-2.f b/Task/Roots-of-a-function/Fortran/roots-of-a-function-2.f new file mode 100644 index 0000000000..31131675c5 --- /dev/null +++ b/Task/Roots-of-a-function/Fortran/roots-of-a-function-2.f @@ -0,0 +1,22 @@ +INTEGER, PARAMETER :: dp = SELECTED_REAL_KIND(15) +INTEGER :: i=1, limit=100 +REAL(dp) :: d, e, f, x, x1, x2 + +f(x) = x*x*x - 3.0_dp*x*x + 2.0_dp*x + +x1 = -1.0_dp ; x2 = 3.0_dp ; e = 1.0e-15_dp + +DO + IF (i > limit) THEN + WRITE(*,*) "Function not converging" + EXIT + END IF + d = (x2 - x1) / (f(x2) - f(x1)) * f(x2) + IF (ABS(d) < e) THEN + WRITE(*,"(A,F18.15)") "Root found at x = ", x2 + EXIT + END IF + x1 = x2 + x2 = x2 - d + i = i + 1 +END DO diff --git a/Task/Roots-of-a-function/Go/roots-of-a-function.go b/Task/Roots-of-a-function/Go/roots-of-a-function.go new file mode 100644 index 0000000000..eff79c0c88 --- /dev/null +++ b/Task/Roots-of-a-function/Go/roots-of-a-function.go @@ -0,0 +1,44 @@ +package main + +import ( + "fmt" + "math" +) + +func f(x float64) float64 { + return x*x*x - 3*x*x + 2*x +} + +var ( + lower float64 = -.5 + upper float64 = 2.6 + step float64 = 1 +) + +func main() { + for x0, x1 := lower, lower+step; x0 < upper; x0, x1 = x1, x1+step { + if x1 > upper { + x1 = upper + } + r, status := secant(x0, x1) + if status != "" && r >= x0 && r < x1 { + fmt.Printf(" %6.3f %s\n", r, status) + } + } +} + +func secant(x0, x1 float64) (float64, string) { + var f0 float64 + f1 := f(x0) + for i := 0; i < 100; i++ { + f0, f1 = f1, f(x1) + switch { + case f1 == 0: + return x1, "exact" + case math.Abs(x1-x0) < 1e-6: + return x1, "approximate" + } + x0, x1 = x1, x1-f1*(x1-x0)/(f1-f0) + } + return 0, "" +} diff --git a/Task/Roots-of-a-function/Haskell/roots-of-a-function-1.hs b/Task/Roots-of-a-function/Haskell/roots-of-a-function-1.hs new file mode 100644 index 0000000000..fab5d72527 --- /dev/null +++ b/Task/Roots-of-a-function/Haskell/roots-of-a-function-1.hs @@ -0,0 +1,4 @@ +f x = x^3-3*x^2+2*x + +findRoots start stop step eps = + [x | x <- [start, start+step .. stop], abs (f x) < eps] diff --git a/Task/Roots-of-a-function/Haskell/roots-of-a-function-2.hs b/Task/Roots-of-a-function/Haskell/roots-of-a-function-2.hs new file mode 100644 index 0000000000..016549988f --- /dev/null +++ b/Task/Roots-of-a-function/Haskell/roots-of-a-function-2.hs @@ -0,0 +1,2 @@ +*Main> findRoots (-1.0) 3.0 0.0001 0.000000001 +[-9.381755897326649e-14,0.9999999999998124,1.9999999999997022] diff --git a/Task/Roots-of-a-function/Haskell/roots-of-a-function-3.hs b/Task/Roots-of-a-function/Haskell/roots-of-a-function-3.hs new file mode 100644 index 0000000000..4bff921094 --- /dev/null +++ b/Task/Roots-of-a-function/Haskell/roots-of-a-function-3.hs @@ -0,0 +1,7 @@ +import Numeric.GSL.Polynomials +import Data.Complex + +*Main> mapM_ print $ polySolve [0,2,-3,1] +(-5.421010862427522e-20) :+ 0.0 +2.000000000000001 :+ 0.0 +0.9999999999999996 :+ 0.0 diff --git a/Task/Roots-of-a-function/Haskell/roots-of-a-function-4.hs b/Task/Roots-of-a-function/Haskell/roots-of-a-function-4.hs new file mode 100644 index 0000000000..bb14261173 --- /dev/null +++ b/Task/Roots-of-a-function/Haskell/roots-of-a-function-4.hs @@ -0,0 +1,4 @@ +*Main> mapM_ (print.realPart) $ polySolve [0,2,-3,1] +-5.421010862427522e-20 +2.000000000000001 +0.9999999999999996 diff --git a/Task/Roots-of-a-function/HicEst/roots-of-a-function-1.hicest b/Task/Roots-of-a-function/HicEst/roots-of-a-function-1.hicest new file mode 100644 index 0000000000..93e970e0c3 --- /dev/null +++ b/Task/Roots-of-a-function/HicEst/roots-of-a-function-1.hicest @@ -0,0 +1,10 @@ +OPEN(FIle='test.txt') + +1 DLG(NameEdit=x0, DNum=3) + +x = x0 +chi2 = SOLVE(NUL=x^3 - 3*x^2 + 2*x, Unknown=x, I=iterations, NumDiff=1E-15) +EDIT(Text='approximate exact ', Word=(chi2 == 0), Parse=solution) + +WRITE(FIle='test.txt', LENgth=6, Name) x0, x, solution, chi2, iterations +GOTO 1 diff --git a/Task/Roots-of-a-function/HicEst/roots-of-a-function-2.hicest b/Task/Roots-of-a-function/HicEst/roots-of-a-function-2.hicest new file mode 100644 index 0000000000..4bb1dd93f6 --- /dev/null +++ b/Task/Roots-of-a-function/HicEst/roots-of-a-function-2.hicest @@ -0,0 +1,9 @@ +x0=0.5; x=1; solution=exact; chi2=79E-32 iterations=65; +x0=0.4; x=2E-162 solution=exact; chi2=0; iterations=1E4; +x0=0.45; x=1; solution=exact; chi2=79E-32 iterations=67; +x0=0.42; x=2E-162 solution=exact; chi2=0; iterations=1E4; +x0=1.5; x=1.5; solution=approximate; chi2=0.1406; iterations=14: +x0=1.54; x=1; solution=exact; chi2=44E-32 iterations=63; +x0=1.55; x=2; solution=exact; chi2=79E-32 iterations=55; +x0=1E10; x=2; solution=exact; chi2=18E-31 iterations=511; +x0=-1E10; x=0; solution=exact; chi2=0; iterations=1E4; diff --git a/Task/Roots-of-a-function/J/roots-of-a-function-1.j b/Task/Roots-of-a-function/J/roots-of-a-function-1.j new file mode 100644 index 0000000000..a8f865be37 --- /dev/null +++ b/Task/Roots-of-a-function/J/roots-of-a-function-1.j @@ -0,0 +1,2 @@ + 1{::p. 0 2 _3 1 +2 1 0 diff --git a/Task/Roots-of-a-function/J/roots-of-a-function-2.j b/Task/Roots-of-a-function/J/roots-of-a-function-2.j new file mode 100644 index 0000000000..29de15cd88 --- /dev/null +++ b/Task/Roots-of-a-function/J/roots-of-a-function-2.j @@ -0,0 +1,2 @@ + (0=]p.1{::p.) 0 2 _3 1 +1 1 1 diff --git a/Task/Roots-of-a-function/J/roots-of-a-function-3.j b/Task/Roots-of-a-function/J/roots-of-a-function-3.j new file mode 100644 index 0000000000..01e42479f5 --- /dev/null +++ b/Task/Roots-of-a-function/J/roots-of-a-function-3.j @@ -0,0 +1,5 @@ + blackbox=: 0 2 _3 1&p. + (#~ (=<./)@:|@blackbox) i.&.(1e6&*)&.(1&+) 3 +0 1 2 + 0=blackbox 0 1 2 +1 1 1 diff --git a/Task/Roots-of-a-function/Java/roots-of-a-function.java b/Task/Roots-of-a-function/Java/roots-of-a-function.java new file mode 100644 index 0000000000..2b570dfc9b --- /dev/null +++ b/Task/Roots-of-a-function/Java/roots-of-a-function.java @@ -0,0 +1,38 @@ +public class Roots { + public interface Function { + public double f(double x); + } + + private static int sign(double x) { + return (x < 0.0) ? -1 : (x > 0.0) ? 1 : 0; + } + + public static void printRoots(Function f, double lowerBound, + double upperBound, double step) { + double x = lowerBound, ox = x; + double y = f.f(x), oy = y; + int s = sign(y), os = s; + + for (; x <= upperBound ; x += step) { + s = sign(y = f.f(x)); + if (s == 0) { + System.out.println(x); + } else if (s != os) { + double dx = x - ox; + double dy = y - oy; + double cx = x - dx * (y / dy); + System.out.println("~" + cx); + } + ox = x; oy = y; os = s; + } + } + + public static void main(String[] args) { + Function poly = new Function () { + public double f(double x) { + return x*x*x - 3*x*x + 2*x; + } + }; + printRoots(poly, -1.0, 4, 0.002); + } +} diff --git a/Task/Roots-of-a-function/Liberty-BASIC/roots-of-a-function.liberty b/Task/Roots-of-a-function/Liberty-BASIC/roots-of-a-function.liberty new file mode 100644 index 0000000000..208ebde99e --- /dev/null +++ b/Task/Roots-of-a-function/Liberty-BASIC/roots-of-a-function.liberty @@ -0,0 +1,46 @@ +' Finds and output the roots of a given function f(x), +' within a range of x values. + +' [RC]Roots of an function + + mainwin 80 12 + + xMin =-1 + xMax = 3 + y =f( xMin) ' Since Liberty BASIC has an 'eval(' function the fn + ' and limits would be better entered via 'input'. + LastY =y + + eps =1E-12 ' closeness acceptable + + bigH=0.01 + + print + print " Checking for roots of x^3 -3 *x^2 +2 *x =0 over range -1 to +3" + print + + x=xMin: dx = bigH + do + x=x+dx + y = f(x) + 'print x, dx, y + if y*LastY <0 then 'there is a root, should drill deeper + if dx < eps then 'we are close enough + print " Just crossed axis, solution f( x) ="; y; " at x ="; using( "#.#####", x) + LastY = y + dx = bigH 'after closing on root, continue with big step + else + x=x-dx 'step back + dx = dx/10 'repeat with smaller step + end if + end if + loop while x 0.0) && (v < 0.0)) || ((u < 0.0) && (v > 0.0));; + +let xtol a b = (a = b);; (* or use |a-b| < epsilon *) + +let rec regula_falsi a b fa fb f = + if xtol a b then (a, fa) else + let c = (fb*.a -. fa*.b) /. (fb -. fa) in + let fc = f c in + if fc = 0.0 then (c, fc) else + if bracket fa fc then + regula_falsi a c fa fc f + else + regula_falsi c b fc fb f;; + +let search lo hi step f = + let rec next x fx = + if x > hi then [] else + let y = x +. step in + let fy = f y in + if fx = 0.0 then + (x,fx) :: next y fy + else if bracket fx fy then + (regula_falsi x y fx fy f) :: next y fy + else + next y fy in + next lo (f lo);; + +let showroot (x,fx) = + Printf.printf "f(%.17f) = %.17f [%s]\n" + x fx (if fx = 0.0 then "exact" else "approx") in +let f x = ((x -. 3.0)*.x +. 2.0)*.x in +List.iter showroot (search (-5.0) 5.0 0.1 f);; diff --git a/Task/Roots-of-a-function/Objeck/roots-of-a-function.objeck b/Task/Roots-of-a-function/Objeck/roots-of-a-function.objeck new file mode 100644 index 0000000000..fa0b2217ac --- /dev/null +++ b/Task/Roots-of-a-function/Objeck/roots-of-a-function.objeck @@ -0,0 +1,34 @@ +bundle Default { + class Roots { + function : f(x : Float) ~ Float + { + return (x*x*x - 3.0*x*x + 2.0*x); + } + + function : Main(args : String[]) ~ Nil + { + step := 0.001; + start := -1.0; + stop := 3.0; + value := f(start); + sign := (value > 0); + + if(0.0 = value) { + start->PrintLine(); + }; + + for(x := start + step; x <= stop; x += step;) { + value := f(x); + + if((value > 0) <> sign) { + IO.Console->Instance()->Print("~")->PrintLine(x); + } + else if(0 = value) { + IO.Console->Instance()->Print("~")->PrintLine(x); + }; + + sign := (value > 0); + }; + } + } +} diff --git a/Task/Roots-of-a-function/Octave/roots-of-a-function-1.octave b/Task/Roots-of-a-function/Octave/roots-of-a-function-1.octave new file mode 100644 index 0000000000..6dfbbf4c0f --- /dev/null +++ b/Task/Roots-of-a-function/Octave/roots-of-a-function-1.octave @@ -0,0 +1,11 @@ +a = [ 1, -3, 2, 0 ]; +r = roots(a); +% let's print it +for i = 1:3 + n = polyval(a, r(i)); + printf("x%d = %f (%f", i, r(i), n); + if (n != 0.0) + printf(" not"); + endif + printf(" exact)\n"); +endfor diff --git a/Task/Roots-of-a-function/Octave/roots-of-a-function-2.octave b/Task/Roots-of-a-function/Octave/roots-of-a-function-2.octave new file mode 100644 index 0000000000..ba3409f630 --- /dev/null +++ b/Task/Roots-of-a-function/Octave/roots-of-a-function-2.octave @@ -0,0 +1,21 @@ +function y = f(x) + y = x.^3 -3.*x.^2 + 2.*x; +endfunction + +step = 0.001; +tol = 10 .* eps; +start = -1; +stop = 3; +se = sign(f(start)); + +x = start; +while (x <= stop) + v = f(x); + if ( (v < tol) && (v > -tol) ) + printf("root at %f\n", x); + elseif ( sign(v) != se ) + printf("root near %f\n", x); + endif + se = sign(v); + x = x + step; +endwhile diff --git a/Task/Roots-of-a-function/PARI-GP/roots-of-a-function-1.pari b/Task/Roots-of-a-function/PARI-GP/roots-of-a-function-1.pari new file mode 100644 index 0000000000..b20951307b --- /dev/null +++ b/Task/Roots-of-a-function/PARI-GP/roots-of-a-function-1.pari @@ -0,0 +1 @@ +polroots(x^3-3*x^2+2*x) diff --git a/Task/Roots-of-a-function/PARI-GP/roots-of-a-function-2.pari b/Task/Roots-of-a-function/PARI-GP/roots-of-a-function-2.pari new file mode 100644 index 0000000000..72414f7e8d --- /dev/null +++ b/Task/Roots-of-a-function/PARI-GP/roots-of-a-function-2.pari @@ -0,0 +1 @@ +polroots(x^3-3*x^2+2*x,1) diff --git a/Task/Roots-of-a-function/PARI-GP/roots-of-a-function-3.pari b/Task/Roots-of-a-function/PARI-GP/roots-of-a-function-3.pari new file mode 100644 index 0000000000..9dd1a295db --- /dev/null +++ b/Task/Roots-of-a-function/PARI-GP/roots-of-a-function-3.pari @@ -0,0 +1,3 @@ +solve(x=-.5,.5,x^3-3*x^2+2*x) +solve(x=.5,1.5,x^3-3*x^2+2*x) +solve(x=1.5,2.5,x^3-3*x^2+2*x) diff --git a/Task/Roots-of-a-function/PARI-GP/roots-of-a-function-4.pari b/Task/Roots-of-a-function/PARI-GP/roots-of-a-function-4.pari new file mode 100644 index 0000000000..0d36b7eb7d --- /dev/null +++ b/Task/Roots-of-a-function/PARI-GP/roots-of-a-function-4.pari @@ -0,0 +1,19 @@ +findRoots(P)={ + my(f=factor(P),t); + for(i=1,#f[,1], + if(poldegree(f[i,1]) == 1, + for(j=1,f[i,2], + print(-polcoeff(f[i,1], 0), " (exact)") + ) + ); + if(poldegree(f[i,1]) > 1, + t=polroots(f[i,1]); + for(j=1,#t, + for(k=1,f[i,2], + print(if(imag(t[j]) == 0.,real(t[j]),t[j]), " (approximate)") + ) + ) + ) + ) +}; +findRoots(x^3-3*x^2+2*x) diff --git a/Task/Roots-of-a-function/PARI-GP/roots-of-a-function-5.pari b/Task/Roots-of-a-function/PARI-GP/roots-of-a-function-5.pari new file mode 100644 index 0000000000..20d73a3d7d --- /dev/null +++ b/Task/Roots-of-a-function/PARI-GP/roots-of-a-function-5.pari @@ -0,0 +1,46 @@ +findRoots(P)={ + my(f=factor(P),t); + for(i=1,#f[,1], + if(poldegree(f[i,1]) == 1, + for(j=1,f[i,2], + print(-polcoeff(f[i,1], 0), " (exact)") + ) + ); + if(poldegree(f[i,1]) == 2, + t=solveQuadratic(polcoeff(f[i,1],2),polcoeff(f[i,1],1),polcoeff(f[i,1],0)); + for(j=1,f[i,2], + print(t[1]" (exact)\n"t[2]" (exact)") + ) + ); + if(poldegree(f[i,1]) > 2, + t=polroots(f[i,1]); + for(j=1,#t, + for(k=1,f[i,2], + print(if(imag(t[j]) == 0.,real(t[j]),t[j]), " (approximate)") + ) + ) + ) + ) +}; +solveQuadratic(a,b,c)={ + my(t=-b/2/a,s=b^2/4/a^2-c/a,inner=core(numerator(s))/core(denominator(s)),outer=sqrtint(s/inner)); + if(inner < 0, + outer *= I; + inner *= -1 + ); + s=if(inner == 1, + outer + , + if(outer == 1, + Str("sqrt(", inner, ")") + , + Str(outer, " * sqrt(", inner, ")") + ) + ); + if (t, + [Str(t, " + ", s), Str(t, " - ", s)] + , + [s, Str("-", s)] + ) +}; +findRoots(x^3-3*x^2+2*x) diff --git a/Task/Roots-of-a-function/PL-I/roots-of-a-function.pli b/Task/Roots-of-a-function/PL-I/roots-of-a-function.pli new file mode 100644 index 0000000000..5587ff7b93 --- /dev/null +++ b/Task/Roots-of-a-function/PL-I/roots-of-a-function.pli @@ -0,0 +1,41 @@ +f: procedure (x) returns (float (18)); + declare x float (18); + return (x**3 - 3*x**2 + 2*x ); +end f; + +declare eps float, (x, y) float (18); +declare dx fixed decimal (15,13); + +eps = 1e-12; + +do dx = -5.03 to 5 by 0.1; + x = dx; + if sign(f(x)) ^= sign(f(dx+0.1)) then + call locate_root; +end; + +locate_root: procedure; + declare (left, mid, right) float (18); + + put skip list ('Looking for root in [' || x, x+0.1 || ']' ); + left = x; right = dx+0.1; + PUT SKIP LIST (F(LEFT), F(RIGHT) ); + if abs(f(left) ) < eps then + do; put skip list ('Found a root at x=', left); return; end; + else if abs(f(right) ) < eps then + do; put skip list ('Found a root at x=', right); return; end; + do forever; + mid = (left+right)/2; + if sign(f(mid)) = 0 then + do; put skip list ('Root found at x=', mid); return; end; + else if sign(f(left)) ^= sign(f(mid)) then + right = mid; + else + left = mid; + /* put skip list (left || right); */ + if abs(right-left) < eps then + do; put skip list ('There is a root near ' || + (left+right)/2); return; + end; + end; +end locate_root; diff --git a/Task/Roots-of-a-function/Pascal/roots-of-a-function.pascal b/Task/Roots-of-a-function/Pascal/roots-of-a-function.pascal new file mode 100644 index 0000000000..5856527c30 --- /dev/null +++ b/Task/Roots-of-a-function/Pascal/roots-of-a-function.pascal @@ -0,0 +1,64 @@ +Program RootsFunction; + +var + e, x, step, value: double; + s: boolean; + i, limit: integer; + x1, x2, d: double; + +function f(const x: double): double; + begin + f := x*x*x - 3*x*x + 2*x; + end; + +begin + x := -1; + step := 1.0e-6; + e := 1.0e-9; + s := (f(x) > 0); + + writeln('Version 1: simply stepping x:'); + while x < 3.0 do + begin + value := f(x); + if abs(value) < e then + begin + writeln ('root found at x = ', x); + s := not s; + end + else if ((value > 0) <> s) then + begin + writeln ('root found at x = ', x); + s := not s; + end; + x := x + step; + end; + + writeln('Version 2: secant method:'); + x1 := -1.0; + x2 := 3.0; + e := 1.0e-15; + i := 1; + limit := 300; + while true do + begin + if i > limit then + begin + writeln('Error: function not converging'); + exit; + end; + d := (x2 - x1) / (f(x2) - f(x1)) * f(x2); + if abs(d) < e then + begin + if d = 0 then + write('Exact ') + else + write('Approximate '); + writeln('root found at x = ', x2); + exit; + end; + x1 := x2; + x2 := x2 - d; + i := i + 1; + end; +end. diff --git a/Task/Roots-of-a-function/Perl-6/roots-of-a-function.pl6 b/Task/Roots-of-a-function/Perl-6/roots-of-a-function.pl6 new file mode 100644 index 0000000000..2564b55759 --- /dev/null +++ b/Task/Roots-of-a-function/Perl-6/roots-of-a-function.pl6 @@ -0,0 +1,19 @@ +sub f($x) { $x*$x*$x - 3*$x*$x + 2*$x } + +my $start = -1; +my $stop = 3; +my $step = 0.001; + +for $start, * + $step ... $stop -> $x { + state $sign = 0; + given f($x) { + my $next = .sign; + when 0.0 { + say "Root found at $x"; + } + when $sign and $next != $sign { + say "Root found near $x"; + } + NEXT $sign = $next; + } +} diff --git a/Task/Roots-of-a-function/Perl/roots-of-a-function.pl b/Task/Roots-of-a-function/Perl/roots-of-a-function.pl new file mode 100644 index 0000000000..c9a85a3f3a --- /dev/null +++ b/Task/Roots-of-a-function/Perl/roots-of-a-function.pl @@ -0,0 +1,37 @@ +sub f +{ + my $x = shift; + + return ($x * $x * $x - 3*$x*$x + 2*$x); +} + +my $step = 0.001; # Smaller step values produce more accurate and precise results +my $start = -1; +my $stop = 3; +my $value = &f($start); +my $sign = $value > 0; + +# Check for root at start + +print "Root found at $start\n" if ( 0 == $value ); + +for( my $x = $start + $step; + $x <= $stop; + $x += $step ) +{ + $value = &f($x); + + if ( 0 == $value ) + { + # We hit a root + print "Root found at $x\n"; + } + elsif ( ( $value > 0 ) != $sign ) + { + # We passed a root + print "Root found near $x\n"; + } + + # Update our sign + $sign = ( $value > 0 ); +} diff --git a/Task/Roots-of-a-function/PicoLisp/roots-of-a-function.l b/Task/Roots-of-a-function/PicoLisp/roots-of-a-function.l new file mode 100644 index 0000000000..ae5fcc7271 --- /dev/null +++ b/Task/Roots-of-a-function/PicoLisp/roots-of-a-function.l @@ -0,0 +1,11 @@ +(de findRoots (F Start Stop Step Eps) + (filter + '((N) (> Eps (abs (F N)))) + (range Start Stop Step) ) ) + +(scl 12) + +(mapcar round + (findRoots + '((X) (+ (*/ X X X `(* 1.0 1.0)) (*/ -3 X X 1.0) (* 2 X))) + -1.0 3.0 0.0001 0.00000001 ) ) diff --git a/Task/Roots-of-a-function/PureBasic/roots-of-a-function.purebasic b/Task/Roots-of-a-function/PureBasic/roots-of-a-function.purebasic new file mode 100644 index 0000000000..0932759948 --- /dev/null +++ b/Task/Roots-of-a-function/PureBasic/roots-of-a-function.purebasic @@ -0,0 +1,28 @@ +Procedure.d f(x.d) + ProcedureReturn x*x*x-3*x*x+2*x +EndProcedure + +Procedure main() + OpenConsole() + Define.d StepSize= 0.001 + Define.d Start=-1, stop=3 + Define.d value=f(start), x=start + Define.i oldsign=Sign(value) + + If value=0 + PrintN("Root found at "+StrF(start)) + EndIf + + While x<=stop + value=f(x) + If Sign(value) <> oldsign + PrintN("Root found near "+StrF(x)) + ElseIf value = 0 + PrintN("Root found at "+StrF(x)) + EndIf + oldsign=Sign(value) + x+StepSize + Wend +EndProcedure + +main() diff --git a/Task/Roots-of-a-function/Python/roots-of-a-function.py b/Task/Roots-of-a-function/Python/roots-of-a-function.py new file mode 100644 index 0000000000..b6799c55b7 --- /dev/null +++ b/Task/Roots-of-a-function/Python/roots-of-a-function.py @@ -0,0 +1,23 @@ +f = lambda x: x * x * x - 3 * x * x + 2 * x + +step = 0.001 # Smaller step values produce more accurate and precise results +start = -1 +stop = 3 + +sign = f(start) > 0 + +x = start +while x <= stop: + value = f(x) + + if value == 0: + # We hit a root + print "Root found at", x + elif (value > 0) != sign: + # We passed a root + print "Root found near", x + + # Update our sign + sign = value > 0 + + x += step diff --git a/Task/Roots-of-a-function/R/roots-of-a-function.r b/Task/Roots-of-a-function/R/roots-of-a-function.r new file mode 100644 index 0000000000..a66fcaf084 --- /dev/null +++ b/Task/Roots-of-a-function/R/roots-of-a-function.r @@ -0,0 +1,18 @@ +f <- function(x) x^3 -3*x^2 + 2*x + +findroots <- function(f, begin, end, tol = 1e-20, step = 0.001) { + se <- ifelse(sign(f(begin))==0, 1, sign(f(begin))) + x <- begin + while ( x <= end ) { + v <- f(x) + if ( abs(v) < tol ) { + print(sprintf("root at %f", x)) + } else if ( ifelse(sign(v)==0, 1, sign(v)) != se ) { + print(sprintf("root near %f", x)) + } + se <- ifelse( sign(v) == 0 , 1, sign(v)) + x <- x + step + } +} + +findroots(f, -1, 3) diff --git a/Task/Roots-of-a-function/REXX/roots-of-a-function-1.rexx b/Task/Roots-of-a-function/REXX/roots-of-a-function-1.rexx new file mode 100644 index 0000000000..1672c68dc6 --- /dev/null +++ b/Task/Roots-of-a-function/REXX/roots-of-a-function-1.rexx @@ -0,0 +1,16 @@ +/*REXX program to find the roots of a specific function. */ +parse arg bot top inc . /*allow user to specify options. */ +if bot=='' | bot==',' then bot=-3 /*Not specified? Then use default*/ +if top=='' | top==',' then top=+3 /* " " " " " */ +if inc=='' | inc==',' then inc=.0001 /* " " " " " */ +z=f(bot); !=sign(z) + + do j=bot to top by inc /*traipse through all the values.*/ + z=f(j); $=sign(z) /*compute new value and the sign.*/ + if z=0 then say 'found a root at' j/1 + else if !\==$ then if !\==0 then say 'passed a root at' j/1 + !=$ /*use the new sign. */ + end /*j*/ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────F function──────────────────────────*/ +f: procedure; parse arg x; return x**3 - 3 * x**2 + 2 * x diff --git a/Task/Roots-of-a-function/REXX/roots-of-a-function-2.rexx b/Task/Roots-of-a-function/REXX/roots-of-a-function-2.rexx new file mode 100644 index 0000000000..bfca864f74 --- /dev/null +++ b/Task/Roots-of-a-function/REXX/roots-of-a-function-2.rexx @@ -0,0 +1,2 @@ +/*──────────────────────────────────F function──────────────────────────*/ +f: procedure; parse arg x; x2=x*x; return x*x2 - 3*x2 + x+x diff --git a/Task/Roots-of-a-function/RLaB/roots-of-a-function.rlab b/Task/Roots-of-a-function/RLaB/roots-of-a-function.rlab new file mode 100644 index 0000000000..73e02303b9 --- /dev/null +++ b/Task/Roots-of-a-function/RLaB/roots-of-a-function.rlab @@ -0,0 +1,8 @@ +f = function(x) +{ + rval = x .^ 3 - 3 * x .^ 2 + 2 * x; + return rval; +}; + +>> findroot(f, , [-5,5]) + 0 diff --git a/Task/Roots-of-a-function/Ruby/roots-of-a-function-1.rb b/Task/Roots-of-a-function/Ruby/roots-of-a-function-1.rb new file mode 100644 index 0000000000..cbab6121a0 --- /dev/null +++ b/Task/Roots-of-a-function/Ruby/roots-of-a-function-1.rb @@ -0,0 +1,22 @@ +def sign(x) + x <=> 0 +end + +def find_roots(f, range, step) + sign = sign(f[range.begin]) + + range.step(step) do |x| + value = f[x] + + if value == 0 + puts "Root found at #{x}" + elsif sign(value) == -sign + puts "Root found between #{x-step} and #{x}" + end + + sign = sign(value) + end +end + +f = lambda { |x| x**3 - 3*x**2 + 2*x } +find_roots(f, -1..3, 0.001) diff --git a/Task/Roots-of-a-function/Ruby/roots-of-a-function-2.rb b/Task/Roots-of-a-function/Ruby/roots-of-a-function-2.rb new file mode 100644 index 0000000000..10937032eb --- /dev/null +++ b/Task/Roots-of-a-function/Ruby/roots-of-a-function-2.rb @@ -0,0 +1,19 @@ +class Numeric + def sign + zero? ? 0 : self / abs + end +end + +def find_roots(range, step = 1e-3) + range.step( step ).inject( yield(range.begin).sign ) { |sign, x| + value = yield(x) + if value == 0 + puts "Root found at #{x}" + elsif value.sign == -sign + puts "Root found between #{x-step} and #{x}" + end + value.sign + } +end + +find_roots(-1..3) { |x| x**3 - 3*x**2 + 2*x } diff --git a/Task/Roots-of-a-function/Tcl/roots-of-a-function-1.tcl b/Task/Roots-of-a-function/Tcl/roots-of-a-function-1.tcl new file mode 100644 index 0000000000..d020fb6b95 --- /dev/null +++ b/Task/Roots-of-a-function/Tcl/roots-of-a-function-1.tcl @@ -0,0 +1,15 @@ +proc froots {lambda {start -3} {end 3} {step 0.0001}} { + set res {} + set lastsign [sgn [apply $lambda $start]] + for {set x $start} {$x <= $end} {set x [expr {$x + $step}]} { + set sign [sgn [apply $lambda $x]] + if {$sign != $lastsign} { + lappend res [format ~%.11f $x] + } + set lastsign $sign + } + return $res +} +proc sgn x {expr {($x>0) - ($x<0)}} + +puts [froots {x {expr {$x**3 - 3*$x**2 + 2*$x}}}] diff --git a/Task/Roots-of-a-function/Tcl/roots-of-a-function-2.tcl b/Task/Roots-of-a-function/Tcl/roots-of-a-function-2.tcl new file mode 100644 index 0000000000..0b02805275 --- /dev/null +++ b/Task/Roots-of-a-function/Tcl/roots-of-a-function-2.tcl @@ -0,0 +1,29 @@ +proc frootsNR {f df {start -3} {end 3} {step 0.001}} { + set res {} + set lastsign [sgn [apply $f $start]] + for {set x $start} {$x <= $end} {set x [expr {$x + $step}]} { + set sign [sgn [apply $f $x]] + if {$sign != $lastsign} { + lappend res [format ~%.15f [nr $x $f $df]] + } + set lastsign $sign + } + return $res +} +proc sgn x {expr {($x>0) - ($x<0)}} +proc nr {x1 f df} { + # Newton's method converges very rapidly indeed + for {set iters 0} {$iters < 10} {incr iters} { + set x1 [expr { + [set x0 $x1] - [apply $f $x0]/[apply $df $x0] + }] + if {$x0 == $x1} { + break + } + } + return $x1 +} + +puts [frootsNR \ + {x {expr {$x**3 - 3*$x**2 + 2*$x}}} \ + {x {expr {3*$x**2 - 6*$x + 2}}}] diff --git a/Task/Roots-of-a-quadratic-function/0DESCRIPTION b/Task/Roots-of-a-quadratic-function/0DESCRIPTION new file mode 100644 index 0000000000..505b94254e --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/0DESCRIPTION @@ -0,0 +1,29 @@ +{{Clarified-review}}Write a program to find the roots of a quadratic equation, i.e., solve the equation ax^2 + bx + c = 0. Your program must correctly handle non-real roots, but it need not check that a \neq 0. + +The problem of solving a quadratic equation is a good example of how dangerous it can be to ignore the peculiarities of floating-point arithmetic. The obvious way to implement the quadratic formula suffers catastrophic loss of accuracy when one of the roots to be found is much closer to 0 than the other. In their classic textbook on numeric methods ''[http://www.pdas.com/fmm.htm Computer Methods for Mathematical Computations]'', George Forsythe, Michael Malcolm, and Cleve Moler suggest trying the naive algorithm with a = 1, b = -10^5, and c = 1. (For double-precision floats, set b = -10^9.) Consider the following implementation in [[Ada]]: +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions; + +procedure Quadratic_Equation is + type Roots is array (1..2) of Float; + function Solve (A, B, C : Float) return Roots is + SD : constant Float := sqrt (B**2 - 4.0 * A * C); + AA : constant Float := 2.0 * A; + begin + return ((- B + SD) / AA, (- B - SD) / AA); + end Solve; + + R : constant Roots := Solve (1.0, -10.0E5, 1.0); +begin + Put_Line ("X1 =" & Float'Image (R (1)) & " X2 =" & Float'Image (R (2))); +end Quadratic_Equation; +Sample output: +
    X1 = 1.00000E+06 X2 = 0.00000E+00
    +As we can see, the second root has lost all significant figures. The right answer is that X2 is about 10^{-6}. The naive method is numerically unstable. + +Suggested by Middlebrook (D-OA), a better numerical method: to define two parameters q = \sqrt{a c} / b and f = 1/2 + \sqrt{1 - 4 q^2} /2 + +and the two roots of the quardratic are: \frac{-b}{a} f and \frac{-c}{b f} + + +'''Task''': do it better. This means that given a = 1, b = -10^9, and c = 1, both of the roots your program returns should be greater than 10^{-11}. Or, if your language can't do floating-point arithmetic any more precisely than single precision, your program should be able to handle b = -10^6. Either way, show what your program gives as the roots of the quadratic in question. See page 9 of [http://dlc.sun.com/pdf/800-7895/800-7895.pdf "What Every Scientist Should Know About Floating-Point Arithmetic"] for a possible algorithm. diff --git a/Task/Roots-of-a-quadratic-function/1META.yaml b/Task/Roots-of-a-quadratic-function/1META.yaml new file mode 100644 index 0000000000..8644b2ad9b --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Arithmetic operations diff --git a/Task/Roots-of-a-quadratic-function/ALGOL-68/roots-of-a-quadratic-function.alg b/Task/Roots-of-a-quadratic-function/ALGOL-68/roots-of-a-quadratic-function.alg new file mode 100644 index 0000000000..8493d90926 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/ALGOL-68/roots-of-a-quadratic-function.alg @@ -0,0 +1,55 @@ +quadratic equation: +BEGIN + + MODE ROOTS = UNION([]REAL, []COMPL); + MODE QUADRATIC = STRUCT(REAL a,b,c); + + PROC solve = (QUADRATIC q)ROOTS: + BEGIN + REAL a = a OF q, b = b OF q, c = c OF q; + REAL sa = b**2 - 4*a*c; + IF sa >=0 THEN # handle the +ve case as REAL # + REAL sqrt sa = ( b<0 | sqrt(sa) | -sqrt(sa)); + REAL r1 = (-b + sqrt sa)/(2*a), + r2 = (-b - sqrt sa)/(2*a); + []REAL((r1,r2)) + ELSE # handle the -ve case as COMPL conjugate pairs # + COMPL compl sqrt sa = ( b<0 | complex sqrt(sa) | -complex sqrt(sa)); + COMPL r1 = (-b + compl sqrt sa)/(2*a), + r2 = (-b - compl sqrt sa)/(2*a); + []COMPL (r1, r2) + FI + END # solve #; + + PROC real evaluate = (QUADRATIC q, REAL x )REAL: (a OF q*x + b OF q)*x + c OF q; + PROC compl evaluate = (QUADRATIC q, COMPL x)COMPL: (a OF q*x + b OF q)*x + c OF q; + + # only a very tiny difference between the 2 examples # + []QUADRATIC test = ((1, -10e5, 1), (1, 0, 1), (1,-3,2), (1,3,2), (4,0,4), (3,4,5)); + + FORMAT real fmt = $g(-0,8)$; + FORMAT compl fmt = $f(real fmt)"+"f(real fmt)"i"$; + FORMAT quadratic fmt = $f(real fmt)" x**2 + "f(real fmt)" x + "f(real fmt)" = 0"$; + + FOR index TO UPB test DO + QUADRATIC quadratic = test[index]; + ROOTS r = solve(quadratic); + +# Output the two different scenerios # + printf(($"Quadratic: "$, quadratic fmt, quadratic, $l$)); + CASE r IN + ([]REAL r): + printf(($"REAL x1 = "$, real fmt, r[1], + $", x2 = "$, real fmt, r[2], $"; "$, + $"REAL y1 = "$, real fmt, real evaluate(quadratic,r[1]), + $", y2 = "$, real fmt, real evaluate(quadratic,r[2]), $";"ll$ + )), + ([]COMPL c): + printf(($"COMPL x1,x2 = "$, real fmt, re OF c[1], $"+/-"$, + real fmt, ABS im OF c[1], $"; "$, + $"COMPL y1 = "$, compl fmt, compl evaluate(quadratic,c[1]), + $", y2 = "$, compl fmt, compl evaluate(quadratic,c[2]), $";"ll$ + )) + ESAC + OD +END # quadratic_equation # diff --git a/Task/Roots-of-a-quadratic-function/Ada/roots-of-a-quadratic-function.ada b/Task/Roots-of-a-quadratic-function/Ada/roots-of-a-quadratic-function.ada new file mode 100644 index 0000000000..0ccae08b66 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Ada/roots-of-a-quadratic-function.ada @@ -0,0 +1,22 @@ +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions; + +procedure Quadratic_Equation is + type Roots is array (1..2) of Float; + function Solve (A, B, C : Float) return Roots is + SD : constant Float := sqrt (B**2 - 4.0 * A * C); + X : Float; + begin + if B < 0.0 then + X := (- B + SD) / 2.0 * A; + return (X, C / (A * X)); + else + X := (- B - SD) / 2.0 * A; + return (C / (A * X), X); + end if; + end Solve; + + R : constant Roots := Solve (1.0, -10.0E5, 1.0); +begin + Put_Line ("X1 =" & Float'Image (R (1)) & " X2 =" & Float'Image (R (2))); +end Quadratic_Equation; diff --git a/Task/Roots-of-a-quadratic-function/AutoHotkey/roots-of-a-quadratic-function.ahk b/Task/Roots-of-a-quadratic-function/AutoHotkey/roots-of-a-quadratic-function.ahk new file mode 100644 index 0000000000..a9fc3b0f24 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/AutoHotkey/roots-of-a-quadratic-function.ahk @@ -0,0 +1,23 @@ +MsgBox % quadratic(u,v, 1,-3,2) ", " u ", " v +MsgBox % quadratic(u,v, 1,3,2) ", " u ", " v +MsgBox % quadratic(u,v, -2,4,-2) ", " u ", " v +MsgBox % quadratic(u,v, 1,0,1) ", " u ", " v +SetFormat FloatFast, 0.15e +MsgBox % quadratic(u,v, 1,-1.0e8,1) ", " u ", " v + +quadratic(ByRef x1, ByRef x2, a,b,c) { ; -> #real roots {x1,x2} of ax²+bx+c + If (a = 0) + Return -1 ; ERROR: not quadratic + d := b*b - 4*a*c + If (d < 0) { + x1 := x2 := "" + Return 0 + } + If (d = 0) { + x1 := x2 := -b/2/a + Return 1 + } + x1 := (-b - (b<0 ? -sqrt(d) : sqrt(d)))/2/a + x2 := c/a/x1 + Return 2 +} diff --git a/Task/Roots-of-a-quadratic-function/BBC-BASIC/roots-of-a-quadratic-function.bbc b/Task/Roots-of-a-quadratic-function/BBC-BASIC/roots-of-a-quadratic-function.bbc new file mode 100644 index 0000000000..3f340a0eec --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/BBC-BASIC/roots-of-a-quadratic-function.bbc @@ -0,0 +1,28 @@ + FOR test% = 1 TO 7 + READ a$, b$, c$ + PRINT "For a = " ; a$ ", b = " ; b$ ", c = " ; c$ TAB(32) ; + PROCsolvequadratic(EVAL(a$), EVAL(b$), EVAL(c$)) + NEXT + END + + DATA 1, -1E9, 1 + DATA 1, 0, 1 + DATA 2, -1, -6 + DATA 1, 2, -2 + DATA 0.5, SQR(2), 1 + DATA 1, 3, 2 + DATA 3, 4, 5 + + DEF PROCsolvequadratic(a, b, c) + LOCAL d, f + d = b^2 - 4*a*c + CASE SGN(d) OF + WHEN 0: + PRINT "the single root is " ; -b/2/a + WHEN +1: + f = (1 + SQR(1-4*a*c/b^2))/2 + PRINT "the real roots are " ; -f*b/a " and " ; -c/b/f + WHEN -1: + PRINT "the complex roots are " ; -b/2/a " +/- " ; SQR(-d)/2/a "*i" + ENDCASE + ENDPROC diff --git a/Task/Roots-of-a-quadratic-function/C++/roots-of-a-quadratic-function.cpp b/Task/Roots-of-a-quadratic-function/C++/roots-of-a-quadratic-function.cpp new file mode 100644 index 0000000000..99c7926ad0 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/C++/roots-of-a-quadratic-function.cpp @@ -0,0 +1,28 @@ +#include +#include +#include + +typedef std::complex complex; + +std::pair + solve_quadratic_equation(double a, double b, double c) +{ + b /= a; + c /= a; + double discriminant = b*b-4*c; + if (discriminant < 0) + return std::make_pair(complex(-b/2, std::sqrt(-discriminant)/2), + complex(-b/2, -std::sqrt(-discriminant)/2)); + + double root = std::sqrt(discriminant); + double solution1 = (b > 0)? (-b - root)/2 + : (-b + root)/2; + + return std::make_pair(solution1, c/solution1); +} + +int main() +{ + std::pair result = solve_quadratic_equation(1, -1e20, 1); + std::cout << result.first << ", " << result.second << std::endl; +} diff --git a/Task/Roots-of-a-quadratic-function/C/roots-of-a-quadratic-function-1.c b/Task/Roots-of-a-quadratic-function/C/roots-of-a-quadratic-function-1.c new file mode 100644 index 0000000000..b813fa14ff --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/C/roots-of-a-quadratic-function-1.c @@ -0,0 +1,61 @@ +#include +#include +#include +#include + +typedef double complex cplx; + +void quad_root +(double a, double b, double c, cplx * ra, cplx *rb) +{ + double d, e; + if (!a) { + *ra = b ? -c / b : 0; + *rb = 0; + return; + } + if (!c) { + *ra = 0; + *rb = -b / a; + return; + } + + b /= 2; + if (fabs(b) > fabs(c)) { + e = 1 - (a / b) * (c / b); + d = sqrt(fabs(e)) * fabs(b); + } else { + e = (c > 0) ? a : -a; + e = b * (b / fabs(c)) - e; + d = sqrt(fabs(e)) * sqrt(fabs(c)); + } + + if (e < 0) { + e = fabs(d / a); + d = -b / a; + *ra = d + I * e; + *rb = d - I * e; + return; + } + + d = (b >= 0) ? d : -d; + e = (d - b) / a; + d = e ? (c / e) / a : 0; + *ra = d; + *rb = e; + return; +} + +int main() +{ + cplx ra, rb; + quad_root(1, 1e12 + 1, 1e12, &ra, &rb); + printf("(%g + %g i), (%g + %g i)\n", + creal(ra), cimag(ra), creal(rb), cimag(rb)); + + quad_root(1e300, -1e307 + 1, 1e300, &ra, &rb); + printf("(%g + %g i), (%g + %g i)\n", + creal(ra), cimag(ra), creal(rb), cimag(rb)); + + return 0; +} diff --git a/Task/Roots-of-a-quadratic-function/C/roots-of-a-quadratic-function-2.c b/Task/Roots-of-a-quadratic-function/C/roots-of-a-quadratic-function-2.c new file mode 100644 index 0000000000..17ec4f1ef7 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/C/roots-of-a-quadratic-function-2.c @@ -0,0 +1,2 @@ +(-1e+12 + 0 i), (-1 + 0 i) +(1.00208e+07 + 0 i), (9.9792e-08 + 0 i) diff --git a/Task/Roots-of-a-quadratic-function/C/roots-of-a-quadratic-function-3.c b/Task/Roots-of-a-quadratic-function/C/roots-of-a-quadratic-function-3.c new file mode 100644 index 0000000000..42f26ba658 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/C/roots-of-a-quadratic-function-3.c @@ -0,0 +1,12 @@ +#include +#include +#include + +void roots_quadratic_eq(double a, double b, double c, complex double *x) +{ + double delta; + + delta = b*b - 4.0*a*c; + x[0] = (-b + csqrt(delta)) / (2.0*a); + x[1] = (-b - csqrt(delta)) / (2.0*a); +} diff --git a/Task/Roots-of-a-quadratic-function/C/roots-of-a-quadratic-function-4.c b/Task/Roots-of-a-quadratic-function/C/roots-of-a-quadratic-function-4.c new file mode 100644 index 0000000000..3a55550957 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/C/roots-of-a-quadratic-function-4.c @@ -0,0 +1,15 @@ +void roots_quadratic_eq2(double a, double b, double c, complex double *x) +{ + b /= a; + c /= a; + double delta = b*b - 4*c; + if ( delta < 0 ) { + x[0] = -b/2 + I*sqrt(-delta)/2.0; + x[1] = -b/2 - I*sqrt(-delta)/2.0; + } else { + double root = sqrt(delta); + double sol = (b>0) ? (-b - root)/2.0 : (-b + root)/2.0; + x[0] = sol; + x[1] = c/sol; + } +} diff --git a/Task/Roots-of-a-quadratic-function/C/roots-of-a-quadratic-function-5.c b/Task/Roots-of-a-quadratic-function/C/roots-of-a-quadratic-function-5.c new file mode 100644 index 0000000000..904393f0cc --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/C/roots-of-a-quadratic-function-5.c @@ -0,0 +1,15 @@ +int main() +{ + complex double x[2]; + + roots_quadratic_eq(1, -1e20, 1, x); + printf("x1 = (%.20le, %.20le)\nx2 = (%.20le, %.20le)\n\n", + creal(x[0]), cimag(x[0]), + creal(x[1]), cimag(x[1])); + roots_quadratic_eq2(1, -1e20, 1, x); + printf("x1 = (%.20le, %.20le)\nx2 = (%.20le, %.20le)\n\n", + creal(x[0]), cimag(x[0]), + creal(x[1]), cimag(x[1])); + + return 0; +} diff --git a/Task/Roots-of-a-quadratic-function/Common-Lisp/roots-of-a-quadratic-function.lisp b/Task/Roots-of-a-quadratic-function/Common-Lisp/roots-of-a-quadratic-function.lisp new file mode 100644 index 0000000000..46307bfa8a --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Common-Lisp/roots-of-a-quadratic-function.lisp @@ -0,0 +1,7 @@ +(defun quadratic (a b c) + "Compute the roots of a quadratic in the form ax^2 + bx + c = 1. Evaluates to a list of the two roots." + (let ((discriminant (- (expt b 2) (* 4 a c))) + (denominator (* 2 a)) + (neg-b (* b -1))) + (list (/ (+ neg-b (sqrt discriminant)) denominator) + (/ (- neg-b (sqrt discriminant)) denominator)))) diff --git a/Task/Roots-of-a-quadratic-function/D/roots-of-a-quadratic-function.d b/Task/Roots-of-a-quadratic-function/D/roots-of-a-quadratic-function.d new file mode 100644 index 0000000000..bb0f0b24fa --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/D/roots-of-a-quadratic-function.d @@ -0,0 +1,47 @@ +import std.math, std.traits; + +CommonType!(T1, T2, T3)[] naiveQR(T1, T2, T3) + (in T1 a, in T2 b, in T3 c) +pure nothrow if (isFloatingPoint!T1) { + alias typeof(typeof(return)[0]) ReturnT; + if (a == 0) + return [cast(ReturnT)c / b]; // it's a linear function + immutable ReturnT det = b ^^ 2 - 4 * a * c; + if (det < 0) + return []; // no real number root + immutable SD = sqrt(det); + return [(-b + SD) / 2 * a, (-b - SD) / 2 * a]; +} + +CommonType!(T1, T2, T3)[] cautiQR(T1, T2, T3) + (in T1 a, in T2 b, in T3 c) +pure nothrow if (isFloatingPoint!T1) { + alias typeof(typeof(return)[0]) ReturnT; + if (a == 0) + return [cast(ReturnT)c / b]; // it's a linear function + immutable ReturnT det = b ^^ 2 - 4 * a * c; + if (det < 0) + return []; // no real number root + immutable SD = sqrt(det); + + if (b * a < 0) { + immutable x = (-b + SD) / 2 * a; + return [x, c / (a * x)]; + } else { + immutable x = (-b - SD) / 2 * a; + return [c / (a * x), x]; + } +} + +void main() { + import std.stdio; + writeln("With 32 bit float type:"); + writefln(" Naive: [%(%g, %)]", naiveQR(1.0f, -10e5f, 1.0f)); + writefln("Cautious: [%(%g, %)]", cautiQR(1.0f, -10e5f, 1.0f)); + writeln("\nWith 64 bit double type:"); + writefln(" Naive: [%(%g, %)]", naiveQR(1.0, -10e5, 1.0)); + writefln("Cautious: [%(%g, %)]", cautiQR(1.0, -10e5, 1.0)); + writeln("\nWith 80 bit real type:"); + writefln(" Naive: [%(%g, %)]", naiveQR(1.0L, -10e5L, 1.0L)); + writefln("Cautious: [%(%g, %)]", cautiQR(1.0L, -10e5L, 1.0L)); +} diff --git a/Task/Roots-of-a-quadratic-function/Factor/roots-of-a-quadratic-function-1.factor b/Task/Roots-of-a-quadratic-function/Factor/roots-of-a-quadratic-function-1.factor new file mode 100644 index 0000000000..66f962da14 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Factor/roots-of-a-quadratic-function-1.factor @@ -0,0 +1,6 @@ +:: quadratic-equation ( a b c -- x1 x2 ) + b sq a c * 4 * - sqrt :> sd + b 0 < + [ b neg sd + a 2 * / ] + [ b neg sd - a 2 * / ] if :> x + x c a x * / ; diff --git a/Task/Roots-of-a-quadratic-function/Factor/roots-of-a-quadratic-function-2.factor b/Task/Roots-of-a-quadratic-function/Factor/roots-of-a-quadratic-function-2.factor new file mode 100644 index 0000000000..80abb055a5 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Factor/roots-of-a-quadratic-function-2.factor @@ -0,0 +1,4 @@ +( scratchpad ) 1 -1.e20 1 quadratic-equation +--- Data stack: +1.0e+20 +9.999999999999999e-21 diff --git a/Task/Roots-of-a-quadratic-function/Factor/roots-of-a-quadratic-function-3.factor b/Task/Roots-of-a-quadratic-function/Factor/roots-of-a-quadratic-function-3.factor new file mode 100644 index 0000000000..9cde30d7c8 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Factor/roots-of-a-quadratic-function-3.factor @@ -0,0 +1,4 @@ +:: quadratic-equation2 ( a b c -- x1 x2 ) + a c * sqrt b / :> q + 1 4 q sq * - sqrt 0.5 * 0.5 + :> f + b neg a / f * c neg b / f / ; diff --git a/Task/Roots-of-a-quadratic-function/Factor/roots-of-a-quadratic-function-4.factor b/Task/Roots-of-a-quadratic-function/Factor/roots-of-a-quadratic-function-4.factor new file mode 100644 index 0000000000..1aa999ce24 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Factor/roots-of-a-quadratic-function-4.factor @@ -0,0 +1,4 @@ +( scratchpad ) 1 -1.e20 1 quadratic-equation +--- Data stack: +1.0e+20 +1.0e-20 diff --git a/Task/Roots-of-a-quadratic-function/Forth/roots-of-a-quadratic-function-1.fth b/Task/Roots-of-a-quadratic-function/Forth/roots-of-a-quadratic-function-1.fth new file mode 100644 index 0000000000..2994bd4f1b --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Forth/roots-of-a-quadratic-function-1.fth @@ -0,0 +1,13 @@ +: quadratic ( fa fb fc -- r1 r2 ) + frot frot + ( c a b ) + fover 3 fpick f* -4e f* fover fdup f* f+ + ( c a b det ) + fdup f0< if abort" imaginary roots" then + fsqrt + fover f0< if fnegate then + f+ fnegate + ( c a b-det ) + 2e f/ fover f/ + ( c a r1 ) + frot frot f/ fover f/ ; diff --git a/Task/Roots-of-a-quadratic-function/Forth/roots-of-a-quadratic-function-2.fth b/Task/Roots-of-a-quadratic-function/Forth/roots-of-a-quadratic-function-2.fth new file mode 100644 index 0000000000..85afb8dbae --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Forth/roots-of-a-quadratic-function-2.fth @@ -0,0 +1,10 @@ +: quadratic { F: a F: b F: c -- r1 r2 } + b b f* 4e a f* c f* f- + fdup f0< if abort" imaginary roots" then + fsqrt + b f0< if fnegate then b f+ fnegate 2e f/ a f/ + c a f/ fover f/ ; + +\ test +1 set-precision +1e -1e6 1e quadratic fs. fs. \ 1e-6 1e6 diff --git a/Task/Roots-of-a-quadratic-function/Fortran/roots-of-a-quadratic-function.f b/Task/Roots-of-a-quadratic-function/Fortran/roots-of-a-quadratic-function.f new file mode 100644 index 0000000000..1bd0c817e0 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Fortran/roots-of-a-quadratic-function.f @@ -0,0 +1,34 @@ +PROGRAM QUADRATIC + + IMPLICIT NONE + INTEGER, PARAMETER :: dp = SELECTED_REAL_KIND(15) + REAL(dp) :: a, b, c, e, discriminant, rroot1, rroot2 + COMPLEX(dp) :: croot1, croot2 + + WRITE(*,*) "Enter the coefficients of the equation ax^2 + bx + c" + WRITE(*, "(A)", ADVANCE="NO") "a = " + READ *, a + WRITE(*,"(A)", ADVANCE="NO") "b = " + READ *, b + WRITE(*,"(A)", ADVANCE="NO") "c = " + READ *, c + + WRITE(*,"(3(A,E23.15))") "Coefficients are: a = ", a, " b = ", b, " c = ", c + e = 1.0e-9_dp + discriminant = b*b - 4.0_dp*a*c + + IF (ABS(discriminant) < e) THEN + rroot1 = -b / (2.0_dp * a) + WRITE(*,*) "The roots are real and equal:" + WRITE(*,"(A,E23.15)") "Root = ", rroot1 + ELSE IF (discriminant > 0) THEN + rroot1 = -(b + SIGN(SQRT(discriminant), b)) / (2.0_dp * a) + rroot2 = c / (a * rroot1) + WRITE(*,*) "The roots are real:" + WRITE(*,"(2(A,E23.15))") "Root1 = ", rroot1, " Root2 = ", rroot2 + ELSE + croot1 = (-b + SQRT(CMPLX(discriminant))) / (2.0_dp*a) + croot2 = CONJG(croot1) + WRITE(*,*) "The roots are complex:" + WRITE(*,"(2(A,2E23.15,A))") "Root1 = ", croot1, "j ", " Root2 = ", croot2, "j" + END IF diff --git a/Task/Roots-of-a-quadratic-function/GAP/roots-of-a-quadratic-function.gap b/Task/Roots-of-a-quadratic-function/GAP/roots-of-a-quadratic-function.gap new file mode 100644 index 0000000000..213cc8954c --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/GAP/roots-of-a-quadratic-function.gap @@ -0,0 +1,10 @@ +QuadraticRoots := function(a, b, c) + local d; + d := Sqrt(b*b - 4*a*c); + return [ (-b+d)/(2*a), (-b-d)/(2*a) ]; +end; + +# Hint : E(12) is a 12th primitive root of 1 +QuadraticRoots(2, 2, -1); +# [ 1/2*E(12)^4-1/2*E(12)^7+1/2*E(12)^8+1/2*E(12)^11, +# 1/2*E(12)^4+1/2*E(12)^7+1/2*E(12)^8-1/2*E(12)^11 ] diff --git a/Task/Roots-of-a-quadratic-function/Go/roots-of-a-quadratic-function.go b/Task/Roots-of-a-quadratic-function/Go/roots-of-a-quadratic-function.go new file mode 100644 index 0000000000..219835dcfb --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Go/roots-of-a-quadratic-function.go @@ -0,0 +1,57 @@ +package main + +import ( + "fmt" + "math" +) + +func qr(a, b, c float64) ([]float64, []complex128) { + d := b*b-4*a*c + switch { + case d == 0: + // single root + return []float64{-b/(2*a)}, nil + case d > 0: + // two real roots + if b < 0 { + d = math.Sqrt(d)-b + } else { + d = -math.Sqrt(d)-b + } + return []float64{d/(2*a), (2*c)/d}, nil + case d < 0: + // two complex roots + + den := 1/(2*a) + t1 := complex(-b*den, 0) + t2 := complex(0, math.Sqrt(-d)*den) + return nil, []complex128{t1+t2, t1-t2} + } + // otherwise d overflowed or a coefficient was NAN + return []float64{d}, nil +} + +func test(a, b, c float64) { + fmt.Print("coefficients: ", a, b, c, " -> ") + r, i := qr(a, b, c) + switch len(r) { + case 1: + fmt.Println("one real root:", r[0]) + case 2: + fmt.Println("two real roots:", r[0], r[1]) + default: + fmt.Println("two complex roots:", i[0], i[1]) + } +} + +func main() { + for _, c := range [][3]float64{ + {1, -2, 1}, + {1, 0, 1}, + {1, -10, 1}, + {1, -1000, 1}, + {1, -1e9, 1}, + } { + test(c[0], c[1], c[2]) + } +} diff --git a/Task/Roots-of-a-quadratic-function/Haskell/roots-of-a-quadratic-function.hs b/Task/Roots-of-a-quadratic-function/Haskell/roots-of-a-quadratic-function.hs new file mode 100644 index 0000000000..e588ea32b2 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Haskell/roots-of-a-quadratic-function.hs @@ -0,0 +1,10 @@ +import Data.Complex + +type CD = Complex Double + +quadraticRoots :: (CD, CD, CD) -> (CD, CD) +quadraticRoots (a, b, c) = + if realPart b > 0 + then ((2*c) / (-b - d), (-b - d) / (2*a)) + else ((-b + d) / (2*a), (2*c) / (-b + d)) + where d = sqrt $ b^2 - 4*a*c diff --git a/Task/Roots-of-a-quadratic-function/IDL/roots-of-a-quadratic-function.idl b/Task/Roots-of-a-quadratic-function/IDL/roots-of-a-quadratic-function.idl new file mode 100644 index 0000000000..cb9e560d1a --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/IDL/roots-of-a-quadratic-function.idl @@ -0,0 +1,17 @@ +compile_OPT IDL2 + +print, "input a, press enter, input b, press enter, input c, press enter" +read,a,b,c +Promt='Enter values of a,b,c and hit enter' + +a0=0.0 +b0=0.0 +c0=0.0 ;make them floating point variables + +x=-b+sqrt((b^2)-4*a*c) +y=-b-sqrt((b^2)-4*a*c) +z=2*a +d= x/z +e= y/z + +print, d,e diff --git a/Task/Roots-of-a-quadratic-function/J/roots-of-a-quadratic-function-1.j b/Task/Roots-of-a-quadratic-function/J/roots-of-a-quadratic-function-1.j new file mode 100644 index 0000000000..e670b4e0a0 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/J/roots-of-a-quadratic-function-1.j @@ -0,0 +1,6 @@ + coeff =. _3 |.\ 3 4 4r3 3 2 _1 3 2 1 1 _1e6 1 + > {:"1 p. coeff + _0.666667 _0.666667 + _1 0.333333 +_0.333333j0.471405 _0.333333j_0.471405 + 1e6 1e_6 diff --git a/Task/Roots-of-a-quadratic-function/J/roots-of-a-quadratic-function-2.j b/Task/Roots-of-a-quadratic-function/J/roots-of-a-quadratic-function-2.j new file mode 100644 index 0000000000..3d81a46522 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/J/roots-of-a-quadratic-function-2.j @@ -0,0 +1,6 @@ + p. 0 16 _12 2 NB. return multiplier ; roots ++-+-----+ +|2|4 2 0| ++-+-----+ + p. 2 ; 4 2 0 NB. return coefficients +0 16 _12 2 diff --git a/Task/Roots-of-a-quadratic-function/J/roots-of-a-quadratic-function-3.j b/Task/Roots-of-a-quadratic-function/J/roots-of-a-quadratic-function-3.j new file mode 100644 index 0000000000..bcdb2f8ed5 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/J/roots-of-a-quadratic-function-3.j @@ -0,0 +1,10 @@ + 1{::p. 1 _1e5 1 NB. display roots +100000 1e_5 + 1 _1e5 1 p. 1{::p. 1 _1e5 1 NB. test roots +_3.38436e_7 0 + 1 _1e5 1 p. 1e5 1e_5 NB. test displayed roots +1 9.99999e_11 + 1e5 1e_5 - 1{::p. 1 _1e5 1 NB. find difference +1e_5 _1e_15 + 1 _1e5 1 p. 1e5 1e_5-1e_5 _1e_15 NB. test displayed roots with adjustment +_3.38436e_7 0 diff --git a/Task/Roots-of-a-quadratic-function/J/roots-of-a-quadratic-function-4.j b/Task/Roots-of-a-quadratic-function/J/roots-of-a-quadratic-function-4.j new file mode 100644 index 0000000000..4b9a60008b --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/J/roots-of-a-quadratic-function-4.j @@ -0,0 +1,2 @@ + 1 {:: p.1 _1e9 1 +1e9 1e_9 diff --git a/Task/Roots-of-a-quadratic-function/J/roots-of-a-quadratic-function-5.j b/Task/Roots-of-a-quadratic-function/J/roots-of-a-quadratic-function-5.j new file mode 100644 index 0000000000..d345aacb22 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/J/roots-of-a-quadratic-function-5.j @@ -0,0 +1,9 @@ +q_r =: 3 : 0 +'a b c' =. y +q=. b %~ %: a * c +f=. 0.5 + 0.5*%:(1-4*q*q) +(-b*f%a),(-c%b*f) +) + +q_r 1 _1e6 1 +1e6 1e_6 diff --git a/Task/Roots-of-a-quadratic-function/Java/roots-of-a-quadratic-function.java b/Task/Roots-of-a-quadratic-function/Java/roots-of-a-quadratic-function.java new file mode 100644 index 0000000000..c13f2c6acf --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Java/roots-of-a-quadratic-function.java @@ -0,0 +1,74 @@ +public class QuadraticRoots { + private static class Complex { + double re, im; + + public Complex(double re, double im) { + this.re = re; + this.im = im; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) {return true;} + if (!(obj instanceof Complex)) {return false;} + Complex other = (Complex) obj; + return (re == other.re) && (im == other.im); + } + + @Override + public String toString() { + if (im == 0.0) {return String.format("%g", re);} + if (re == 0.0) {return String.format("%gi", im);} + return String.format("%g %c %gi", re, + (im < 0.0 ? '-' : '+'), Math.abs(im)); + } + } + + private static Complex[] quadraticRoots(double a, double b, double c) { + Complex[] roots = new Complex[2]; + double d = b * b - 4.0 * a * c; // discriminant + double aa = a + a; + + if (d < 0.0) { + double re = -b / aa; + double im = Math.sqrt(-d) / aa; + roots[0] = new Complex(re, im); + roots[1] = new Complex(re, -im); + } else if (b < 0.0) { + // Avoid calculating -b - Math.sqrt(d), to avoid any + // subtractive cancellation when it is near zero. + double re = (-b + Math.sqrt(d)) / aa; + roots[0] = new Complex(re, 0.0); + roots[1] = new Complex(c / (a * re), 0.0); + } else { + // Avoid calculating -b + Math.sqrt(d). + double re = (-b - Math.sqrt(d)) / aa; + roots[1] = new Complex(re, 0.0); + roots[0] = new Complex(c / (a * re), 0.0); + } + return roots; + } + + public static void main(String[] args) { + double[][] equations = { + {1.0, 22.0, -1323.0}, // two distinct real roots + {6.0, -23.0, 20.0}, // with a != 1.0 + {1.0, -1.0e9, 1.0}, // with one root near zero + {1.0, 2.0, 1.0}, // one real root (double root) + {1.0, 0.0, 1.0}, // two imaginary roots + {1.0, 1.0, 1.0} // two complex roots + }; + for (int i = 0; i < equations.length; i++) { + Complex[] roots = quadraticRoots( + equations[i][0], equations[i][1], equations[i][2]); + System.out.format("%na = %g b = %g c = %g%n", + equations[i][0], equations[i][1], equations[i][2]); + if (roots[0].equals(roots[1])) { + System.out.format("X1,2 = %s%n", roots[0]); + } else { + System.out.format("X1 = %s%n", roots[0]); + System.out.format("X2 = %s%n", roots[1]); + } + } + } +} diff --git a/Task/Roots-of-a-quadratic-function/Liberty-BASIC/roots-of-a-quadratic-function.liberty b/Task/Roots-of-a-quadratic-function/Liberty-BASIC/roots-of-a-quadratic-function.liberty new file mode 100644 index 0000000000..af97080df4 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Liberty-BASIC/roots-of-a-quadratic-function.liberty @@ -0,0 +1,14 @@ +a=1:b=2:c=3 + 'assume a<>0 + print quad$(a,b,c) + end + +function quad$(a,b,c) + D=b^2-4*a*c + x=-1*b + if D<0 then + quad$=str$(x/(2*a));" +i";str$(sqr(abs(D))/(2*a));" , ";str$(x/(2*a));" -i";str$(sqr(abs(D))/abs(2*a)) + else + quad$=str$(x/(2*a)+sqr(D)/(2*a));" , ";str$(x/(2*a)-sqr(D)/(2*a)) + end if +end function diff --git a/Task/Roots-of-a-quadratic-function/Logo/roots-of-a-quadratic-function.logo b/Task/Roots-of-a-quadratic-function/Logo/roots-of-a-quadratic-function.logo new file mode 100644 index 0000000000..b8d8903506 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Logo/roots-of-a-quadratic-function.logo @@ -0,0 +1,5 @@ +to quadratic :a :b :c + localmake "d sqrt (:b*:b - 4*:a*:c) + if :b < 0 [make "d minus :d] + output list (:d-:b)/(2*:a) (2*:c)/(:d-:b) +end diff --git a/Task/Roots-of-a-quadratic-function/Lua/roots-of-a-quadratic-function.lua b/Task/Roots-of-a-quadratic-function/Lua/roots-of-a-quadratic-function.lua new file mode 100644 index 0000000000..1e5ff5f69a --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Lua/roots-of-a-quadratic-function.lua @@ -0,0 +1,9 @@ +function qsolve(a, b, c) + if b < 0 then return qsolve(-a, -b, -c) end + val = b + (b^2 - 4*a*c)^(1/2) --this never exhibits instability if b > 0 + return -val / (2 * a), -2 * c / val --2c / val is the same as the "unstable" second root +end + +for i = 1, 12 do + print(qsolve(1, 0-10^i, 1)) +end diff --git a/Task/Roots-of-a-quadratic-function/MATLAB/roots-of-a-quadratic-function.m b/Task/Roots-of-a-quadratic-function/MATLAB/roots-of-a-quadratic-function.m new file mode 100644 index 0000000000..5186d1286b --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/MATLAB/roots-of-a-quadratic-function.m @@ -0,0 +1 @@ +roots([1 -3 2]) % coefficients in decreasing order of power e.g. [x^n ... x^2 x^1 x^0] diff --git a/Task/Roots-of-a-quadratic-function/Mathematica/roots-of-a-quadratic-function.math b/Task/Roots-of-a-quadratic-function/Mathematica/roots-of-a-quadratic-function.math new file mode 100644 index 0000000000..5bbb9bdc86 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Mathematica/roots-of-a-quadratic-function.math @@ -0,0 +1,9 @@ +Solve[a x^2 + b x + c == 0, x] +Solve[x^2 - 10^5 x + 1 == 0, x] +Root[#1^2 - 10^5 #1 + 1 &, 1] +Root[#1^2 - 10^5 #1 + 1 &, 2] +Reduce[a x^2 + b x + c == 0, x] +Reduce[x^2 - 10^5 x + 1 == 0, x] +FindInstance[x^2 - 10^5 x + 1 == 0, x, Reals, 2] +FindRoot[x^2 - 10^5 x + 1 == 0, {x, 0}] +FindRoot[x^2 - 10^5 x + 1 == 0, {x, 10^6}] diff --git a/Task/Roots-of-a-quadratic-function/Maxima/roots-of-a-quadratic-function.maxima b/Task/Roots-of-a-quadratic-function/Maxima/roots-of-a-quadratic-function.maxima new file mode 100644 index 0000000000..cf4b3f6027 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Maxima/roots-of-a-quadratic-function.maxima @@ -0,0 +1,16 @@ +solve(a*x^2 + b*x + c = 0, x); + +/* 2 2 + sqrt(b - 4 a c) + b sqrt(b - 4 a c) - b + [x = - --------------------, x = --------------------] + 2 a 2 a */ + +fpprec: 40$ + +solve(x^2 - 10^9*x + 1 = 0, x); +/* [x = 500000000 - sqrt(249999999999999999), + x = sqrt(249999999999999999) + 500000000] */ + +bfloat(%); +/* [x = 1.0000000000000000009999920675269450501b-9, + x = 9.99999999999999998999999999999999999b8] */ diff --git a/Task/Roots-of-a-quadratic-function/Modula-3/roots-of-a-quadratic-function.mod3 b/Task/Roots-of-a-quadratic-function/Modula-3/roots-of-a-quadratic-function.mod3 new file mode 100644 index 0000000000..a6c929eefe --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Modula-3/roots-of-a-quadratic-function.mod3 @@ -0,0 +1,25 @@ +MODULE Quad EXPORTS Main; + +IMPORT IO, Fmt, Math; + +TYPE Roots = ARRAY [1..2] OF LONGREAL; + +VAR r: Roots; + +PROCEDURE Solve(a, b, c: LONGREAL): Roots = + VAR sd: LONGREAL := Math.sqrt(b * b - 4.0D0 * a * c); + x: LONGREAL; + BEGIN + IF b < 0.0D0 THEN + x := (-b + sd) / 2.0D0 * a; + RETURN Roots{x, c / (a * x)}; + ELSE + x := (-b - sd) / 2.0D0 * a; + RETURN Roots{c / (a * x), x}; + END; + END Solve; + +BEGIN + r := Solve(1.0D0, -10.0D5, 1.0D0); + IO.Put("X1 = " & Fmt.LongReal(r[1]) & " X2 = " & Fmt.LongReal(r[2]) & "\n"); +END Quad. diff --git a/Task/Roots-of-a-quadratic-function/OCaml/roots-of-a-quadratic-function-1.ocaml b/Task/Roots-of-a-quadratic-function/OCaml/roots-of-a-quadratic-function-1.ocaml new file mode 100644 index 0000000000..a97ea42640 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/OCaml/roots-of-a-quadratic-function-1.ocaml @@ -0,0 +1,20 @@ +type quadroots = + | RealRoots of float * float + | ComplexRoots of Complex.t * Complex.t ;; + +let quadsolve a b c = + let d = (b *. b) -. (4.0 *. a *. c) in + if d < 0.0 + then + let r = -. b /. (2.0 *. a) + and i = sqrt(-. d) /. (2.0 *. a) in + ComplexRoots ({ Complex.re = r; Complex.im = i }, + { Complex.re = r; Complex.im = (-.i) }) + else + let r = + if b < 0.0 + then ((sqrt d) -. b) /. (2.0 *. a) + else ((sqrt d) +. b) /. (-2.0 *. a) + in + RealRoots (r, c /. (r *. a)) +;; diff --git a/Task/Roots-of-a-quadratic-function/OCaml/roots-of-a-quadratic-function-2.ocaml b/Task/Roots-of-a-quadratic-function/OCaml/roots-of-a-quadratic-function-2.ocaml new file mode 100644 index 0000000000..84f8eed917 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/OCaml/roots-of-a-quadratic-function-2.ocaml @@ -0,0 +1,10 @@ +# quadsolve 1.0 0.0 (-2.0) ;; +- : quadroots = RealRoots (-1.4142135623730951, 1.4142135623730949) + +# quadsolve 1.0 0.0 2.0 ;; +- : quadroots = +ComplexRoots ({Complex.re = 0.; Complex.im = 1.4142135623730951}, + {Complex.re = 0.; Complex.im = -1.4142135623730951}) + +# quadsolve 1.0 (-1.0e5) 1.0 ;; +- : quadroots = RealRoots (99999.99999, 1.0000000001000001e-005) diff --git a/Task/Roots-of-a-quadratic-function/PARI-GP/roots-of-a-quadratic-function.pari b/Task/Roots-of-a-quadratic-function/PARI-GP/roots-of-a-quadratic-function.pari new file mode 100644 index 0000000000..28990852f5 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/PARI-GP/roots-of-a-quadratic-function.pari @@ -0,0 +1,11 @@ +roots(a,b,c)={ + b /= a; + c /= a; + my (delta = b^2 - 4*c, root=sqrt(delta)); + if (delta < 0, + [root-b,-root-b]/2 + , + my(sol=if(b>0, -b - root,-b + root)/2); + [sol,c/sol] + ) +}; diff --git a/Task/Roots-of-a-quadratic-function/PL-I/roots-of-a-quadratic-function.pli b/Task/Roots-of-a-quadratic-function/PL-I/roots-of-a-quadratic-function.pli new file mode 100644 index 0000000000..80f549bf66 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/PL-I/roots-of-a-quadratic-function.pli @@ -0,0 +1,16 @@ + declare (c1, c2) float complex, + (a, b, c, x1, x2) float; + + get list (a, b, c); + if b**2 < 4*a*c then + do; + c1 = (-b + sqrt(b**2 - 4+0i*a*c)) / (2*a); + c2 = (-b - sqrt(b**2 - 4+0i*a*c)) / (2*a); + put data (c1, c2); + end; + else + do; + x1 = (-b + sqrt(b**2 - 4*a*c)) / (2*a); + x2 = (-b - sqrt(b**2 - 4*a*c)) / (2*a); + put data (x1, x2); + end; diff --git a/Task/Roots-of-a-quadratic-function/Pascal/roots-of-a-quadratic-function.pascal b/Task/Roots-of-a-quadratic-function/Pascal/roots-of-a-quadratic-function.pascal new file mode 100644 index 0000000000..720e1a3c55 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Pascal/roots-of-a-quadratic-function.pascal @@ -0,0 +1,28 @@ +Program QuadraticRoots; + +var + a, b, c, q, f: double; + +begin + a := 1; + b := -10e9; + c := 1; + q := sqrt(a * c) / b; + f := (1 + sqrt(1 - 4 * q * q)) / 2; + + writeln ('Version 1:'); + writeln ('x1: ', (-b * f / a):16, ', x2: ', (-c / (b * f)):16); + + writeln ('Version 2:'); + q := sqrt(b * b - 4 * a * c); + if b < 0 then + begin + f := (-b + q) / 2 * a; + writeln ('x1: ', f:16, ', x2: ', (c / (a * f)):16); + end + else + begin + f := (-b - q) / 2 * a; + writeln ('x1: ', (c / (a * f)):16, ', x2: ', f:16); + end; +end. diff --git a/Task/Roots-of-a-quadratic-function/Perl-6/roots-of-a-quadratic-function.pl6 b/Task/Roots-of-a-quadratic-function/Perl-6/roots-of-a-quadratic-function.pl6 new file mode 100644 index 0000000000..9b94845554 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Perl-6/roots-of-a-quadratic-function.pl6 @@ -0,0 +1,23 @@ +my @sets = [1, 2, 1], + [1, 2, 3], + [1, -2, 1], + [1, 0, -4], + [1, -10**6, 1]; + +for @sets -> @coefficients { + say "Roots for @coefficients.join(', ').fmt("%-16s")", + "=> (&quadroots( @coefficients ).join(', '))"; +} + +multi sub quadroots ($a, $b, $c) { + my $root = (my $t = $b ** 2 - 4 * $a * $c ) < 0 + ?? $t.Complex.sqrt + !! $t.sqrt; + return ( -$b + $root ) / (2 * $a), + ( -$b - $root ) / (2 * $a); +} + +multi sub quadroots (@a) { + @a == 3 or die "Expected three elements, got {+@a}"; + quadroots |@a; +} diff --git a/Task/Roots-of-a-quadratic-function/Perl/roots-of-a-quadratic-function.pl b/Task/Roots-of-a-quadratic-function/Perl/roots-of-a-quadratic-function.pl new file mode 100644 index 0000000000..68242d1ebe --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Perl/roots-of-a-quadratic-function.pl @@ -0,0 +1,12 @@ +use Math::Complex; + +($x1,$x2) = solveQuad(1,2,3); + +print "x1 = $x1, x2 = $x2\n"; + +sub solveQuad +{ + my ($a,$b,$c) = @_; + my $root = sqrt($b**2 - 4*$a*$c); + return ( -$b + $root )/(2*$a), ( -$b - $root )/(2*$a); +} diff --git a/Task/Roots-of-a-quadratic-function/PicoLisp/roots-of-a-quadratic-function.l b/Task/Roots-of-a-quadratic-function/PicoLisp/roots-of-a-quadratic-function.l new file mode 100644 index 0000000000..a12c4ce98d --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/PicoLisp/roots-of-a-quadratic-function.l @@ -0,0 +1,15 @@ +(scl 40) + +(de solveQuad (A B C) + (let SD (sqrt (- (* B B) (* 4 A C))) + (if (lt0 B) + (list + (*/ (- SD B) A 2.0) + (*/ C 2.0 (*/ A A (- SD B) `(* 1.0 1.0))) ) + (list + (*/ C 2.0 (*/ A A (- 0 B SD) `(* 1.0 1.0))) + (*/ (- 0 B SD) A 2.0) ) ) ) ) + +(mapcar round + (solveQuad 1.0 -1000000.0 1.0) + (6 .) ) diff --git a/Task/Roots-of-a-quadratic-function/Python/roots-of-a-quadratic-function.py b/Task/Roots-of-a-quadratic-function/Python/roots-of-a-quadratic-function.py new file mode 100644 index 0000000000..bdb3319605 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Python/roots-of-a-quadratic-function.py @@ -0,0 +1,25 @@ +>>> def quad_discriminating_roots(a,b,c, entier = 1e-5): + discriminant = b*b - 4*a*c + a,b,c,d =complex(a), complex(b), complex(c), complex(discriminant) + root1 = (-b + d**0.5)/2./a + root2 = (-b - d**0.5)/2./a + if abs(discriminant) < entier: + return "real and equal", abs(root1), abs(root1) + if discriminant > 0: + return "real", root1.real, root2.real + return "complex", root1, root2 + +>>> for coeffs in ((3, 4, 4/3.), (3, 2, -1), (3, 2, 1), (1.0, -10.0E5, 1.0)): + print "Roots of: %gX^2 %+gX %+g are" % coeffs + print " %s: %s, %s" % quad_discriminating_roots(*coeffs) + + +Roots of: 3X^2 +4X +1.33333 are + real and equal: 0.666666666667, 0.666666666667 +Roots of: 3X^2 +2X -1 are + real: 0.333333333333, -1.0 +Roots of: 3X^2 +2X +1 are + complex: (-0.333333333333+0.471404520791j), (-0.333333333333-0.471404520791j) +Roots of: 1X^2 -1e+06X +1 are + real: 999999.999999, 1.00000761449e-06 +>>> diff --git a/Task/Roots-of-a-quadratic-function/R/roots-of-a-quadratic-function.r b/Task/Roots-of-a-quadratic-function/R/roots-of-a-quadratic-function.r new file mode 100644 index 0000000000..84cf6d604a --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/R/roots-of-a-quadratic-function.r @@ -0,0 +1,18 @@ +quaddiscrroots <- function(a,b,c, tol=1e-5) { + d <- b*b - 4*a*c + 0i + root1 <- (-b + sqrt(d))/(2*a) + root2 <- (-b - sqrt(d))/(2*a) + if ( abs(Re(d)) < tol ) { + list("real and equal", abs(root1), abs(root1)) + } else if ( Re(d) > 0 ) { + list("real", Re(root1), Re(root2)) + } else { + list("complex", root1, root2) + } +} + +for(coeffs in list(c(3,4,4/3), c(3,2,-1), c(3,2,1), c(1, -1e6, 1)) ) { + cat(sprintf("roots of %gx^2 %+gx^1 %+g are\n", coeffs[1], coeffs[2], coeffs[3])) + r <- quaddiscrroots(coeffs[1], coeffs[2], coeffs[3]) + cat(sprintf(" %s: %s, %s\n", r[[1]], r[[2]], r[[3]])) +} diff --git a/Task/Roots-of-a-quadratic-function/REXX/roots-of-a-quadratic-function.rexx b/Task/Roots-of-a-quadratic-function/REXX/roots-of-a-quadratic-function.rexx new file mode 100644 index 0000000000..8d1efbced1 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/REXX/roots-of-a-quadratic-function.rexx @@ -0,0 +1,36 @@ +/*REXX program finds the roots (may be complex) of a quadratic function.*/ +numeric digits 120 /*use enough digits for extremes.*/ +parse arg a b c . /*get specified arguments: A B C*/ +a=a/1; b=b/1; c=c/1 /*normalize the three numbers. */ +say 'a=' a /*show value of A. */ +say 'b=' b /* " " " B. */ +say 'c=' c /* " " " C. */ +call quadratic a b c /*solve the quadratic function. */ +numeric digits sqrt(digits())%1 /*reduce digits for human beans. */ +r1=r1/1 /*normalize to the new digits. */ +r2=r2/1 /* " " " " " */ +if r1j\=0 then r1=r1 || left('+',r1j>0)(r1j/1)"i" /*handle complex num.*/ +if r2j\=0 then r2=r2 || left('+',r2j>0)(r2j/1)"i" /* " " " */ +say +say 'root1=' r1 /*show 1st root (may be complex).*/ +say 'root2=' r2 /* " 2nd " " " " */ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────QUADRATIC subroutine────────────────*/ +quadratic: parse arg aa bb cc . +?=sqrt(bb**2-4*aa*cc) /*compute sqrt (might be complex)*/ +aa2=1 / (aa+aa) /*compute reciprocal of 2*aa */ +if right(?,1)=='i' then do /*are the roots complex? */ + ?i=left(?,length(?)-1) + r1=-bb*aa2; r2=r1; r1j=?i*aa2; r2j=-?i*aa2 + end + else do + r1=(-bb+?)*aa2; r2=(-bb-?)*aa2; r1j=0; r2j=0 + end +return +/*──────────────────────────────────SQRT subroutine─────────────────────*/ +sqrt: procedure; parse arg x,f; if x=0 then return 0; d=digits() +numeric digits 11; g=.sqrtG(); 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)i +.sqrtG: i=left('i',x<0); numeric form; m.=11; p=d+d%4+2 + parse value format(x,2,1,,0) 'E0' with g 'E' _ .; return g*.5'E'_%2 diff --git a/Task/Roots-of-a-quadratic-function/Ruby/roots-of-a-quadratic-function.rb b/Task/Roots-of-a-quadratic-function/Ruby/roots-of-a-quadratic-function.rb new file mode 100644 index 0000000000..b6389fe996 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Ruby/roots-of-a-quadratic-function.rb @@ -0,0 +1,15 @@ +require 'complex' + +def quadratic(a, b, c) + sqrt_discriminant = Math.sqrt(b**2 - 4*a*c) + [(-b + sqrt_discriminant) / (2.0*a), (-b - sqrt_discriminant) / (2.0*a)] +end + +p quadratic(3, 4, 4/3.0) # {-2/3} +p quadratic(3, 2, -1) # {1/3, -1} +p quadratic(3, 2, 1) # {(-1/3 + sqrt(2/9)i), (-1/3 - sqrt(2/9)i)} +p quadratic(1, 0, 1) # {(0+i), (0-i)} +p quadratic(1, -1e6, 1) # {1e6, 1e-6} +p quadratic(-2, 7, 15) # {5, -3/2} +p quadratic(1, -2, 1) # {1} +p quadratic(1, 3, 3) # {(-3 - sqrt(3)i)/2), (-3 + sqrt(3)i)/2)} diff --git a/Task/Roots-of-a-quadratic-function/Run-BASIC/roots-of-a-quadratic-function.run b/Task/Roots-of-a-quadratic-function/Run-BASIC/roots-of-a-quadratic-function.run new file mode 100644 index 0000000000..45ab725c01 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Run-BASIC/roots-of-a-quadratic-function.run @@ -0,0 +1,12 @@ +print "FOR 1,2,3 => ";quad$(1,2,3) +print "FOR 4,5,6 => ";quad$(4,5,6) + +FUNCTION quad$(a,b,c) + d = b^2-4 * a*c + x = -1*b + if d<0 then + quad$ = str$(x/(2*a));" +i";str$(sqr(abs(d))/(2*a))+" , "+str$(x/(2*a));" -i";str$(sqr(abs(d))/abs(2*a)) + else + quad$ = str$(x/(2*a)+sqr(d)/(2*a))+" , "+str$(x/(2*a)-sqr(d)/(2*a)) + end if +END FUNCTION diff --git a/Task/Roots-of-a-quadratic-function/Scala/roots-of-a-quadratic-function-1.scala b/Task/Roots-of-a-quadratic-function/Scala/roots-of-a-quadratic-function-1.scala new file mode 100644 index 0000000000..ba5a98cf04 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Scala/roots-of-a-quadratic-function-1.scala @@ -0,0 +1,17 @@ +import ArithmeticComplex._ +object QuadraticRoots { + def solve(a:Double, b:Double, c:Double)={ + val d = b*b-4.0*a*c + val aa = a+a + + if (d < 0.0) { // complex roots + val re= -b/aa; + val im = math.sqrt(-d)/aa; + (Complex(re, im), Complex(re, -im)) + } + else { // real roots + val re=if (b < 0.0) (-b+math.sqrt(d))/aa else (-b -math.sqrt(d))/aa + (re, (c/(a*re))) + } + } +} diff --git a/Task/Roots-of-a-quadratic-function/Scala/roots-of-a-quadratic-function-2.scala b/Task/Roots-of-a-quadratic-function/Scala/roots-of-a-quadratic-function-2.scala new file mode 100644 index 0000000000..eacca88ec2 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Scala/roots-of-a-quadratic-function-2.scala @@ -0,0 +1,17 @@ +val equations=Array( + (1.0, 22.0, -1323.0), // two distinct real roots + (6.0, -23.0, 20.0), // with a != 1.0 + (1.0, -1.0e9, 1.0), // with one root near zero + (1.0, 2.0, 1.0), // one real root (double root) + (1.0, 0.0, 1.0), // two imaginary roots + (1.0, 1.0, 1.0) // two complex roots +); + +equations.foreach{v => + val (a,b,c)=v + println("a=%g b=%g c=%g".format(a,b,c)) + val roots=solve(a, b, c) + println("x1="+roots._1) + if(roots._1 != roots._2) println("x2="+roots._2) + println +} diff --git a/Task/Roots-of-a-quadratic-function/Scheme/roots-of-a-quadratic-function.ss b/Task/Roots-of-a-quadratic-function/Scheme/roots-of-a-quadratic-function.ss new file mode 100644 index 0000000000..92aea9f79f --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Scheme/roots-of-a-quadratic-function.ss @@ -0,0 +1,40 @@ +(define (quadratic a b c) + (if (= a 0) + (if (= b 0) 'fail (- (/ c b))) + (let ((delta (- (* b b) (* 4 a c)))) + (if (and (real? delta) (> delta 0)) + (let ((u (+ b (* (if (>= b 0) 1 -1) (sqrt delta))))) + (list (/ u -2 a) (/ (* -2 c) u))) + (list + (/ (- (sqrt delta) b) 2 a) + (/ (+ (sqrt delta) b) -2 a)))))) + + +; examples + +(quadratic 1 -1 -1) +; (1.618033988749895 -0.6180339887498948) + +(quadratic 1 0 -2) +; (-1.4142135623730951 1.414213562373095) + +(quadratic 1 0 2) +; (0+1.4142135623730951i 0-1.4142135623730951i) + +(quadratic 1+1i 2 5) +; (-1.0922677260818898-1.1884256155834088i 0.09226772608188982+2.1884256155834088i) + +(quadratic 0 4 3) +; -3/4 + +(quadratic 0 0 1) +; fail + +(quadratic 1 2 0) +; (-2 0) + +(quadratic 1 2 1) +; (-1 -1) + +(quadratic 1 -1e5 1) +; (99999.99999 1.0000000001000001e-05) diff --git a/Task/Roots-of-a-quadratic-function/Seed7/roots-of-a-quadratic-function.seed7 b/Task/Roots-of-a-quadratic-function/Seed7/roots-of-a-quadratic-function.seed7 new file mode 100644 index 0000000000..a8d94f0478 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Seed7/roots-of-a-quadratic-function.seed7 @@ -0,0 +1,35 @@ +$ include "seed7_05.s7i"; + include "float.s7i"; + include "math.s7i"; + +const type: roots is new struct + var float: x1 is 0.0; + var float: x2 is 0.0; + end struct; + +const func roots: solve (in float: a, in float: b, in float: c) is func + result + var roots: solution is roots.value; + local + var float: sd is 0.0; + var float: x is 0.0; + begin + sd := sqrt(b**2 - 4.0 * a * c); + if b < 0.0 then + x := (-b + sd) / 2.0 * a; + solution.x1 := x; + solution.x2 := c / (a * x); + else + x := (-b - sd) / 2.0 * a; + solution.x1 := c / (a * x); + solution.x2 := x; + end if; + end func; + +const proc: main is func + local + var roots: r is roots.value; + begin + r := solve(1.0, -10.0E5, 1.0); + writeln("X1 = " <& r.x1 digits 6 <& " X2 = " <& r.x2 digits 6); + end func; diff --git a/Task/Roots-of-a-quadratic-function/Tcl/roots-of-a-quadratic-function.tcl b/Task/Roots-of-a-quadratic-function/Tcl/roots-of-a-quadratic-function.tcl new file mode 100644 index 0000000000..f14eb21b46 --- /dev/null +++ b/Task/Roots-of-a-quadratic-function/Tcl/roots-of-a-quadratic-function.tcl @@ -0,0 +1,37 @@ +package require math::complexnumbers +namespace import math::complexnumbers::complex math::complexnumbers::tostring + +proc quadratic {a b c} { + set discrim [expr {$b**2 - 4*$a*$c}] + set roots [list] + if {$discrim < 0} { + set term1 [expr {(-1.0*$b)/(2*$a)}] + set term2 [expr {sqrt(abs($discrim))/(2*$a)}] + lappend roots [tostring [complex $term1 $term2]] \ + [tostring [complex $term1 [expr {-1 * $term2}]]] + } elseif {$discrim == 0} { + lappend roots [expr {-1.0*$b / (2*$a)}] + } else { + lappend roots [expr {(-1*$b + sqrt($discrim)) / (2 * $a)}] \ + [expr {(-1*$b - sqrt($discrim)) / (2 * $a)}] + } + return $roots +} + +proc report_quad {a b c} { + puts [format "%sx**2 + %sx + %s = 0" $a $b $c] + foreach root [quadratic $a $b $c] { + puts " x = $root" + } +} + +# examples on this page +report_quad 3 4 [expr {4/3.0}] ;# {-2/3} +report_quad 3 2 -1 ;# {1/3, -1} +report_quad 3 2 1 ;# {(-1/3 + sqrt(2/9)i), (-1/3 - sqrt(2/9)i)} +report_quad 1 0 1 ;# {(0+i), (0-i)} +report_quad 1 -1e6 1 ;# {1e6, 1e-6} +# examples from http://en.wikipedia.org/wiki/Quadratic_equation +report_quad -2 7 15 ;# {5, -3/2} +report_quad 1 -2 1 ;# {1} +report_quad 1 3 3 ;# {(-3 - sqrt(3)i)/2), (-3 + sqrt(3)i)/2)} diff --git a/Task/Roots-of-unity/0DESCRIPTION b/Task/Roots-of-unity/0DESCRIPTION new file mode 100644 index 0000000000..3a1caea77f --- /dev/null +++ b/Task/Roots-of-unity/0DESCRIPTION @@ -0,0 +1 @@ +The purpose of this task is to explore working with complex numbers. Given n, find the n-th [[wp:Roots of unity|roots of unity]]. diff --git a/Task/Roots-of-unity/1META.yaml b/Task/Roots-of-unity/1META.yaml new file mode 100644 index 0000000000..8644b2ad9b --- /dev/null +++ b/Task/Roots-of-unity/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Arithmetic operations diff --git a/Task/Roots-of-unity/ALGOL-68/roots-of-unity.alg b/Task/Roots-of-unity/ALGOL-68/roots-of-unity.alg new file mode 100644 index 0000000000..b144c67672 --- /dev/null +++ b/Task/Roots-of-unity/ALGOL-68/roots-of-unity.alg @@ -0,0 +1,8 @@ +FORMAT complex fmt=$g(-6,4)"⊥"g(-6,4)$; +FOR root FROM 2 TO 10 DO + printf(($g(4)$,root)); + FOR n FROM 0 TO root-1 DO + printf(($xf(complex fmt)$,complex exp( 0 I 2*pi*n/root))) + OD; + printf($l$) +OD diff --git a/Task/Roots-of-unity/Ada/roots-of-unity.ada b/Task/Roots-of-unity/Ada/roots-of-unity.ada new file mode 100644 index 0000000000..5b84abf9b5 --- /dev/null +++ b/Task/Roots-of-unity/Ada/roots-of-unity.ada @@ -0,0 +1,34 @@ +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Float_Text_IO; use Ada.Float_Text_IO; +with Ada.Numerics.Complex_Types; use Ada.Numerics.Complex_Types; + +procedure Roots_Of_Unity is + Root : Complex; +begin + for N in 2..10 loop + Put_Line ("N =" & Integer'Image (N)); + for K in 0..N - 1 loop + Root := + Compose_From_Polar + ( Modulus => 1.0, + Argument => Float (K), + Cycle => Float (N) + ); + -- Output + Put (" k =" & Integer'Image (K) & ", "); + if Re (Root) < 0.0 then + Put ("-"); + else + Put ("+"); + end if; + Put (abs Re (Root), Fore => 1, Exp => 0); + if Im (Root) < 0.0 then + Put ("-"); + else + Put ("+"); + end if; + Put (abs Im (Root), Fore => 1, Exp => 0); + Put_Line ("i"); + end loop; + end loop; +end Roots_Of_Unity; diff --git a/Task/Roots-of-unity/AutoHotkey/roots-of-unity.ahk b/Task/Roots-of-unity/AutoHotkey/roots-of-unity.ahk new file mode 100644 index 0000000000..95b7911eb0 --- /dev/null +++ b/Task/Roots-of-unity/AutoHotkey/roots-of-unity.ahk @@ -0,0 +1,4 @@ +n := 8, a := 8*atan(1)/n +Loop %n% + i := A_Index-1, t .= cos(a*i) ((s:=sin(a*i))<0 ? " - i*" . -s : " + i*" . s) "`n" +Msgbox % t diff --git a/Task/Roots-of-unity/BASIC/roots-of-unity.basic b/Task/Roots-of-unity/BASIC/roots-of-unity.basic new file mode 100644 index 0000000000..40f67d4de3 --- /dev/null +++ b/Task/Roots-of-unity/BASIC/roots-of-unity.basic @@ -0,0 +1,13 @@ + CLS + PI = 3.1415926# + n = 5 'this can be changed for any desired n + angle = 0 'start at angle 0 + DO + real = COS(angle) 'real axis is the x axis + IF (ABS(real) < 10 ^ -5) THEN real = 0 'get rid of annoying sci notation + imag = SIN(angle) 'imaginary axis is the y axis + IF (ABS(imag) < 10 ^ -5) THEN imag = 0 'get rid of annoying sci notation + PRINT real; "+"; imag; "i" 'answer on every line + angle = angle + (2 * PI) / n + 'all the way around the circle at even intervals + LOOP WHILE angle < 2 * PI diff --git a/Task/Roots-of-unity/BBC-BASIC/roots-of-unity.bbc b/Task/Roots-of-unity/BBC-BASIC/roots-of-unity.bbc new file mode 100644 index 0000000000..fe4bb0c8c0 --- /dev/null +++ b/Task/Roots-of-unity/BBC-BASIC/roots-of-unity.bbc @@ -0,0 +1,11 @@ + @% = &20408 + FOR n% = 2 TO 5 + PRINT STR$(n%) ": " ; + FOR root% = 0 TO n%-1 + real = COS(2*PI * root% / n%) + imag = SIN(2*PI * root% / n%) + PRINT real imag "i" ; + IF root% <> n%-1 PRINT "," ; + NEXT + PRINT + NEXT n% diff --git a/Task/Roots-of-unity/C++/roots-of-unity.cpp b/Task/Roots-of-unity/C++/roots-of-unity.cpp new file mode 100644 index 0000000000..a9d6534503 --- /dev/null +++ b/Task/Roots-of-unity/C++/roots-of-unity.cpp @@ -0,0 +1,16 @@ +#include +#include +#include + +double const pi = 4 * std::atan(1); + +int main() +{ + for (int n = 2; n <= 10; ++n) + { + std::cout << n << ": "; + for (int k = 0; k < n; ++k) + std::cout << std::polar(1, 2*pi*k/n) << " "; + std::cout << std::endl; + } +} diff --git a/Task/Roots-of-unity/C/roots-of-unity.c b/Task/Roots-of-unity/C/roots-of-unity.c new file mode 100644 index 0000000000..922892048c --- /dev/null +++ b/Task/Roots-of-unity/C/roots-of-unity.c @@ -0,0 +1,24 @@ +#include +#include + +int main() +{ + double a, c, s, PI2 = atan2(1, 1) * 8; + int n, i; + + for (n = 1; n < 10; n++) for (i = 0; i < n; i++) { + c = s = 0; + if (!i ) c = 1; + else if(n == 4 * i) s = 1; + else if(n == 2 * i) c = -1; + else if(3 * n == 4 * i) s = -1; + else + a = i * PI2 / n, c = cos(a), s = sin(a); + + if (c) printf("%.2g", c); + printf(s == 1 ? "i" : s == -1 ? "-i" : s ? "%+.2gi" : "", s); + printf(i == n - 1 ?"\n":", "); + } + + return 0; +} diff --git a/Task/Roots-of-unity/CoffeeScript/roots-of-unity.coffeescript b/Task/Roots-of-unity/CoffeeScript/roots-of-unity.coffeescript new file mode 100644 index 0000000000..bcbe5ec7b5 --- /dev/null +++ b/Task/Roots-of-unity/CoffeeScript/roots-of-unity.coffeescript @@ -0,0 +1,28 @@ +# Find the n nth-roots of 1 +nth_roots_of_unity = (n) -> + (complex_unit_vector(2*Math.PI*i/n) for i in [1..n]) + +complex_unit_vector = (rad) -> + new Complex(Math.cos(rad), Math.sin(rad)) + +class Complex + constructor: (@real, @imag) -> + toString: -> + round_z = (n) -> + if Math.abs(n) < 0.00005 then 0 else n + fmt = (n) -> n.toFixed(3) + real = round_z @real + imag = round_z @imag + s = '' + if real and imag + "#{fmt real}+#{fmt imag}i" + else if real or !imag + "#{fmt real}" + else + "#{fmt imag}i" + +do -> + for n in [2..5] + console.log "---1 to the 1/#{n}" + for root in nth_roots_of_unity n + console.log root.toString() diff --git a/Task/Roots-of-unity/Common-Lisp/roots-of-unity.lisp b/Task/Roots-of-unity/Common-Lisp/roots-of-unity.lisp new file mode 100644 index 0000000000..0cc771e8c0 --- /dev/null +++ b/Task/Roots-of-unity/Common-Lisp/roots-of-unity.lisp @@ -0,0 +1,3 @@ +(defun roots-of-unity (n) + (loop for i below n + collect (cis (* pi (/ (* 2 i) n))))) diff --git a/Task/Roots-of-unity/D/roots-of-unity.d b/Task/Roots-of-unity/D/roots-of-unity.d new file mode 100644 index 0000000000..14fd9543e7 --- /dev/null +++ b/Task/Roots-of-unity/D/roots-of-unity.d @@ -0,0 +1,10 @@ +import std.stdio, std.math, std.range, std.algorithm; + +auto nthRoots(in int n) /*pure nothrow*/ { + return iota(n).map!(k => expi(PI * 2 * (k + 1) / n))(); +} + +void main() { + foreach (i; 1 .. 6) + writefln("#%d: [%(%5.2f, %)]", i, nthRoots(i)); +} diff --git a/Task/Roots-of-unity/Forth/roots-of-unity.fth b/Task/Roots-of-unity/Forth/roots-of-unity.fth new file mode 100644 index 0000000000..1f8e2233a8 --- /dev/null +++ b/Task/Roots-of-unity/Forth/roots-of-unity.fth @@ -0,0 +1,10 @@ +: f0. ( f -- ) + fdup 0e 0.001e f~ if fdrop 0e then f. ; +: .roots ( n -- ) + dup 1 do + pi i 2* 0 d>f f* dup 0 d>f f/ ( F: radians ) + fsincos cr ." real " f0. ." imag " f0. + loop drop ; + +3 set-precision +5 .roots diff --git a/Task/Roots-of-unity/Fortran/roots-of-unity-1.f b/Task/Roots-of-unity/Fortran/roots-of-unity-1.f new file mode 100644 index 0000000000..5aaf349662 --- /dev/null +++ b/Task/Roots-of-unity/Fortran/roots-of-unity-1.f @@ -0,0 +1,19 @@ +PROGRAM Roots + + COMPLEX :: root + INTEGER :: i, n + REAL :: angle, pi + + pi = 4.0 * ATAN(1.0) + DO n = 2, 7 + angle = 0.0 + WRITE(*,"(I1,A)", ADVANCE="NO") n,": " + DO i = 1, n + root = CMPLX(COS(angle), SIN(angle)) + WRITE(*,"(SP,2F7.4,A)", ADVANCE="NO") root, "j " + angle = angle + (2.0*pi / REAL(n)) + END DO + WRITE(*,*) + END DO + +END PROGRAM Roots diff --git a/Task/Roots-of-unity/Fortran/roots-of-unity-2.f b/Task/Roots-of-unity/Fortran/roots-of-unity-2.f new file mode 100644 index 0000000000..5c71d524fd --- /dev/null +++ b/Task/Roots-of-unity/Fortran/roots-of-unity-2.f @@ -0,0 +1,15 @@ +program unity + real, parameter :: pi = 3.141592653589793 + complex, parameter :: i = (0, 1) + complex, dimension(0:7-1) :: unit_circle + integer :: n, j + + do n = 2, 7 + !!!! KEY STEP, does all the calculations in one statement !!!! + unit_circle(0:n-1) = exp(2*i*pi/n * (/ (j, j=0, n-1) /) ) + + write(*,"(i1,a)", advance="no") n, ": " + write(*,"(sp,2f7.4,a)", advance="no") (unit_circle(j), "j ", j = 0, n-1) + write(*,*) + end do + end program unity diff --git a/Task/Roots-of-unity/GAP/roots-of-unity.gap b/Task/Roots-of-unity/GAP/roots-of-unity.gap new file mode 100644 index 0000000000..cd874964d1 --- /dev/null +++ b/Task/Roots-of-unity/GAP/roots-of-unity.gap @@ -0,0 +1,7 @@ +roots := n -> List([0 .. n-1], k -> E(n)^k); + +r:=roots(7); +# [ 1, E(7), E(7)^2, E(7)^3, E(7)^4, E(7)^5, E(7)^6 ] + +List(r, x -> x^7); +# [ 1, 1, 1, 1, 1, 1, 1 ] diff --git a/Task/Roots-of-unity/Go/roots-of-unity.go b/Task/Roots-of-unity/Go/roots-of-unity.go new file mode 100644 index 0000000000..fce80b01f4 --- /dev/null +++ b/Task/Roots-of-unity/Go/roots-of-unity.go @@ -0,0 +1,24 @@ +package main + +import ( + "fmt" + "math" + "math/cmplx" +) + +func main() { + for n := 2; n <= 5; n++ { + fmt.Printf("%d roots of 1:\n", n) + for _, r := range roots(n) { + fmt.Printf(" %18.15f\n", r) + } + } +} + +func roots(n int) []complex128 { + r := make([]complex128, n) + for i := 0; i < n; i++ { + r[i] = cmplx.Rect(1, 2*math.Pi*float64(i)/float64(n)) + } + return r +} diff --git a/Task/Roots-of-unity/Groovy/roots-of-unity-1.groovy b/Task/Roots-of-unity/Groovy/roots-of-unity-1.groovy new file mode 100644 index 0000000000..fd8c3fd426 --- /dev/null +++ b/Task/Roots-of-unity/Groovy/roots-of-unity-1.groovy @@ -0,0 +1,7 @@ +/** The following closure creates a list of n evenly-spaced points around the unit circle, + * useful in FFT calculations, among other things */ +def rootsOfUnity = { n -> + (0.. + println "rootsOfUnity(${n}):" + def rou = rootsOfUnity(n) + rou.each { println it } + assert rou[0] == 1 + def actual = n > 1 ? rou[Math.floor(n/2) as int] : rou[0] + def expected = n > 1 ? (n%2 == 0) ? -1 : ~rou[Math.ceil(n/2) as int] : rou[0] + def message = n > 1 ? (n%2 == 0) ? 'middle-most root should be -1' : 'two middle-most roots should be conjugates' : '' + assert (actual - expected).abs() < tol : message + assert rou.every { (it.rho - 1) < tol } : 'all roots should have magnitude 1' + println() +} diff --git a/Task/Roots-of-unity/Haskell/roots-of-unity-1.hs b/Task/Roots-of-unity/Haskell/roots-of-unity-1.hs new file mode 100644 index 0000000000..2cf1710151 --- /dev/null +++ b/Task/Roots-of-unity/Haskell/roots-of-unity-1.hs @@ -0,0 +1,3 @@ +import Data.Complex + +rootsOfUnity n = [cis (2*pi*k/n) | k <- [0..n-1]] diff --git a/Task/Roots-of-unity/Haskell/roots-of-unity-2.hs b/Task/Roots-of-unity/Haskell/roots-of-unity-2.hs new file mode 100644 index 0000000000..5fbd9291e6 --- /dev/null +++ b/Task/Roots-of-unity/Haskell/roots-of-unity-2.hs @@ -0,0 +1,4 @@ +*Main> rootsOfUnity 3 +[1.0 :+ 0.0, + (-0.4999999999999998) :+ 0.8660254037844387, + (-0.5000000000000004) :+ (-0.8660254037844384)] diff --git a/Task/Roots-of-unity/IDL/roots-of-unity-1.idl b/Task/Roots-of-unity/IDL/roots-of-unity-1.idl new file mode 100644 index 0000000000..5707b37a42 --- /dev/null +++ b/Task/Roots-of-unity/IDL/roots-of-unity-1.idl @@ -0,0 +1,2 @@ +n = 5 +print, exp( dcomplex( 0, 2*!dpi/n) ) ^ ( 1 + indgen(n) ) diff --git a/Task/Roots-of-unity/IDL/roots-of-unity-2.idl b/Task/Roots-of-unity/IDL/roots-of-unity-2.idl new file mode 100644 index 0000000000..d2ec11c734 --- /dev/null +++ b/Task/Roots-of-unity/IDL/roots-of-unity-2.idl @@ -0,0 +1 @@ +( 0.30901699, 0.95105652)( -0.80901699, 0.58778525)( -0.80901699, -0.58778525)( 0.30901699, -0.95105652)( 1.0000000, -1.1102230e-16) diff --git a/Task/Roots-of-unity/Icon/roots-of-unity.icon b/Task/Roots-of-unity/Icon/roots-of-unity.icon new file mode 100644 index 0000000000..13b78a244c --- /dev/null +++ b/Task/Roots-of-unity/Icon/roots-of-unity.icon @@ -0,0 +1,12 @@ +procedure main() + roots(10) +end + +procedure roots(n) + every n := 2 to 10 do + every writes(n | (str_rep((0 to (n-1)) * 2 * &pi / n)) | "\n") +end + +procedure str_rep(k) + return " " || cos(k) || "+" || sin(k) || "i" +end diff --git a/Task/Roots-of-unity/J/roots-of-unity-1.j b/Task/Roots-of-unity/J/roots-of-unity-1.j new file mode 100644 index 0000000000..d5c650457c --- /dev/null +++ b/Task/Roots-of-unity/J/roots-of-unity-1.j @@ -0,0 +1,7 @@ + rou=: [: ^ 0j2p1 * i. % ] + + rou 4 +1 0j1 _1 0j_1 + + rou 5 +1 0.309017j0.951057 _0.809017j0.587785 _0.809017j_0.587785 0.309017j_0.951057 diff --git a/Task/Roots-of-unity/J/roots-of-unity-2.j b/Task/Roots-of-unity/J/roots-of-unity-2.j new file mode 100644 index 0000000000..9bf6662df1 --- /dev/null +++ b/Task/Roots-of-unity/J/roots-of-unity-2.j @@ -0,0 +1,8 @@ +rou1=: 3 : 0 + z=. 0 $ r=. ^ o. 0j2 % y [ e=. 1 + for. i.y do. + z=. z,e + e=. e*r + end. + z +) diff --git a/Task/Roots-of-unity/Java/roots-of-unity.java b/Task/Roots-of-unity/Java/roots-of-unity.java new file mode 100644 index 0000000000..6fe2245de0 --- /dev/null +++ b/Task/Roots-of-unity/Java/roots-of-unity.java @@ -0,0 +1,10 @@ +public static void unity(int n){ + //all the way around the circle at even intervals + for(double angle = 0;angle < 2 * Math.PI;angle += (2 * Math.PI) / n){ + double real = Math.cos(angle); //real axis is the x axis + if(Math.abs(real) < 1.0E-3) real = 0.0; //get rid of annoying sci notation + double imag = Math.sin(angle); //imaginary axis is the y axis + if(Math.abs(imag) < 1.0E-3) imag = 0.0; //get rid of annoying sci notation + System.out.print(real + " + " + imag + "i\t"); //tab-separated answers + } +} diff --git a/Task/Roots-of-unity/Liberty-BASIC/roots-of-unity.liberty b/Task/Roots-of-unity/Liberty-BASIC/roots-of-unity.liberty new file mode 100644 index 0000000000..f5d5a252fc --- /dev/null +++ b/Task/Roots-of-unity/Liberty-BASIC/roots-of-unity.liberty @@ -0,0 +1,54 @@ +WindowWidth =400 +WindowHeight =400 + +'nomainwin + +open "N'th Roots of One" for graphics_nsb_nf as #w + +#w "trapclose [quit]" + +for n =1 To 10 + angle =0 + #w "font arial 16 bold" + print n; "th roots." + #w "cls" + #w "size 1 ; goto 200 200 ; down ; color lightgray ; circle 150 ; size 10 ; set 200 200 ; size 2" + #w "up ; goto 200 0 ; down ; goto 200 400 ; up ; goto 0 200 ; down ; goto 400 200" + #w "up ; goto 40 20 ; down ; color black" + #w "font arial 6" + #w "\"; n; " roots of 1." + + for i = 1 To n + x = cos( Radian( angle)) + y = sin( Radian( angle)) + + print using( "##", i); ": ( " + using( "##.######", x);_ + " +i *" +using( "##.######", y); ") or e^( i *"; i -1; " *2 *Pi/ "; n; ")" + + #w "color "; 255 *i /n; " 0 "; 256 -255 *i /n + #w "up ; goto 200 200" + #w "down ; goto "; 200 +150 *x; " "; 200 -150 *y + #w "up ; goto "; 200 +165 *x; " "; 200 -165 *y + #w "\"; str$( i) + #w "up" + + angle =angle +360 /n + + next i + + timer 500, [on] + wait + [on] + timer 0 +next n + +wait + +[quit] + close #w + + end + +function Radian( theta) + Radian =theta *3.1415926535 /180 +end function diff --git a/Task/Roots-of-unity/Lua/roots-of-unity.lua b/Task/Roots-of-unity/Lua/roots-of-unity.lua new file mode 100644 index 0000000000..ed0202f9da --- /dev/null +++ b/Task/Roots-of-unity/Lua/roots-of-unity.lua @@ -0,0 +1,29 @@ +--defines addition, subtraction, negation, multiplication, division, conjugation, norms, and a conversion to strgs. +complex = setmetatable({ +__add = function(u, v) return complex(u.real + v.real, u.imag + v.imag) end, +__sub = function(u, v) return complex(u.real - v.real, u.imag - v.imag) end, +__mul = function(u, v) return complex(u.real * v.real - u.imag * v.imag, u.real * v.imag + u.imag * v.real) end, +__div = function(u, v) return u * complex(v.real / v.norm, -v.imag / v.norm) end, +__unm = function(u) return complex(-u.real, -u.imag) end, +__concat = function(u, v) + if type(u) == "table" then return u.real .. " + " .. u.imag .. "i" .. v + elseif type(u) == "string" or type(u) == "number" then return u .. v.real .. " + " .. v.imag .. "i" + end end, +__index = function(u, index) + local operations = { + norm = function(u) return u.real ^ 2 + u.imag ^ 2 end, + conj = function(u) return complex(u.real, -u.imag) end, + } + return operations[index] and operations[index](u) +end, +__newindex = function() error() end +}, { +__call = function(z, realpart, imagpart) return setmetatable({real = realpart, imag = imagpart}, complex) end +} ) +n = io.read() + 0 +val = complex(math.cos(2*math.pi / n), math.sin(2*math.pi / n)) +root = complex(1, 0) +for i = 1, n do + root = root * val + print(root .. "") +end diff --git a/Task/Roots-of-unity/MATLAB/roots-of-unity-1.m b/Task/Roots-of-unity/MATLAB/roots-of-unity-1.m new file mode 100644 index 0000000000..2dbee7548a --- /dev/null +++ b/Task/Roots-of-unity/MATLAB/roots-of-unity-1.m @@ -0,0 +1,6 @@ +function z = rootsOfUnity(n) + + assert(n >= 1,'n >= 1'); + z = roots([1 zeros(1,n-1) -1]); + +end diff --git a/Task/Roots-of-unity/MATLAB/roots-of-unity-2.m b/Task/Roots-of-unity/MATLAB/roots-of-unity-2.m new file mode 100644 index 0000000000..b202b80dac --- /dev/null +++ b/Task/Roots-of-unity/MATLAB/roots-of-unity-2.m @@ -0,0 +1,7 @@ +>> rootsOfUnity(3) + +ans = + + -0.500000000000000 + 0.866025403784439i + -0.500000000000000 - 0.866025403784439i + 1.000000000000000 diff --git a/Task/Roots-of-unity/Mathematica/roots-of-unity.math b/Task/Roots-of-unity/Mathematica/roots-of-unity.math new file mode 100644 index 0000000000..180178f85c --- /dev/null +++ b/Task/Roots-of-unity/Mathematica/roots-of-unity.math @@ -0,0 +1 @@ +RootsUnity[nthroot_Integer?Positive] := Table[Exp[2 Pi I i/nthroot], {i, 0, nthroot - 1}] diff --git a/Task/Roots-of-unity/Maxima/roots-of-unity-1.maxima b/Task/Roots-of-unity/Maxima/roots-of-unity-1.maxima new file mode 100644 index 0000000000..9f9395e0b1 --- /dev/null +++ b/Task/Roots-of-unity/Maxima/roots-of-unity-1.maxima @@ -0,0 +1 @@ +solve(1 = x^n, x) diff --git a/Task/Roots-of-unity/Maxima/roots-of-unity-2.maxima b/Task/Roots-of-unity/Maxima/roots-of-unity-2.maxima new file mode 100644 index 0000000000..0f02817f1e --- /dev/null +++ b/Task/Roots-of-unity/Maxima/roots-of-unity-2.maxima @@ -0,0 +1 @@ +for n:1 thru 5 do display(solve(1 = x^n, x)); diff --git a/Task/Roots-of-unity/Maxima/roots-of-unity-3.maxima b/Task/Roots-of-unity/Maxima/roots-of-unity-3.maxima new file mode 100644 index 0000000000..c3943b37d5 --- /dev/null +++ b/Task/Roots-of-unity/Maxima/roots-of-unity-3.maxima @@ -0,0 +1,5 @@ +solve(1 = x, x) = [x = 1] +solve(1 = x^2, x) = [x = -1, x = 1] +solve(1 = x^3, x) = [x = (sqrt(3)*%i-1)/2, x = -(sqrt(3)*%i+1)/2, x = 1] +solve(1 = x^4, x) = [x = %i, x = -1, x = -%i, x = 1] +solve(1 = x^5, x) = [x = %e^((2*%i*%pi)/5), x = %e^((4*%i*%pi)/5), x = %e^(-(4*%i*%pi)/5), x = %e^(-(2*%i*%pi)/5), x = 1] diff --git a/Task/Roots-of-unity/OCaml/roots-of-unity.ocaml b/Task/Roots-of-unity/OCaml/roots-of-unity.ocaml new file mode 100644 index 0000000000..2a02887ff9 --- /dev/null +++ b/Task/Roots-of-unity/OCaml/roots-of-unity.ocaml @@ -0,0 +1,13 @@ +open Complex + +let pi = 4. *. atan 1. + +let () = + for n = 1 to 10 do + Printf.printf "%2d " n; + for k = 1 to n do + let ret = polar 1. (2. *. pi *. float_of_int k /. float_of_int n) in + Printf.printf "(%f + %f i)" ret.re ret.im + done; + print_newline () + done diff --git a/Task/Roots-of-unity/Octave/roots-of-unity.octave b/Task/Roots-of-unity/Octave/roots-of-unity.octave new file mode 100644 index 0000000000..6cc9a51dc4 --- /dev/null +++ b/Task/Roots-of-unity/Octave/roots-of-unity.octave @@ -0,0 +1,7 @@ +for j = 2 : 10 + printf("*** %d\n", j); + for n = 1 : j + disp(exp(2i*pi*n/j)); + endfor + disp(""); +endfor diff --git a/Task/Roots-of-unity/PARI-GP/roots-of-unity.pari b/Task/Roots-of-unity/PARI-GP/roots-of-unity.pari new file mode 100644 index 0000000000..efb2414626 --- /dev/null +++ b/Task/Roots-of-unity/PARI-GP/roots-of-unity.pari @@ -0,0 +1 @@ +vector(n,k,exp(2*Pi*I*k/n)) diff --git a/Task/Roots-of-unity/PL-I/roots-of-unity.pli b/Task/Roots-of-unity/PL-I/roots-of-unity.pli new file mode 100644 index 0000000000..9762357562 --- /dev/null +++ b/Task/Roots-of-unity/PL-I/roots-of-unity.pli @@ -0,0 +1,22 @@ +complex_roots: + procedure (N); + declare N fixed binary nonassignable; + declare x float, c fixed decimal (10,8) complex; + declare twopi float initial ((4*asin(1.0))); + + do x = 0 to twopi by twopi/N; + c = complex(cos(x), sin(x)); + put skip list (c); + end; +end complex_roots; + + 1.00000000+0.00000000I + 0.80901700+0.58778524I + 0.30901697+0.95105654I + -0.30901703+0.95105648I + -0.80901706+0.58778518I + -1.00000000-0.00000008I + -0.80901694-0.58778536I + -0.30901709-0.95105648I + 0.30901712-0.95105648I + 0.80901724-0.58778494I diff --git a/Task/Roots-of-unity/Pascal/roots-of-unity.pascal b/Task/Roots-of-unity/Pascal/roots-of-unity.pascal new file mode 100644 index 0000000000..23edf706f2 --- /dev/null +++ b/Task/Roots-of-unity/Pascal/roots-of-unity.pascal @@ -0,0 +1,25 @@ +Program Roots; + +var + root: record // poor man's complex type. + r: real; + i: real; + end; + i, n: integer; + angle: real; + +begin + for n := 2 to 7 do + begin + angle := 0.0; + write(n, ': '); + for i := 1 to n do + begin + root.r := cos(angle); + root.i := sin(angle); + write(root.r:8:5, root.i:8:5, 'i '); + angle := angle + (2.0 * pi / n); + end; + writeln; + end; +end. diff --git a/Task/Roots-of-unity/Perl-6/roots-of-unity.pl6 b/Task/Roots-of-unity/Perl-6/roots-of-unity.pl6 new file mode 100644 index 0000000000..2da09f1eba --- /dev/null +++ b/Task/Roots-of-unity/Perl-6/roots-of-unity.pl6 @@ -0,0 +1,5 @@ +sub roots_of_unity (Int $n where { $n > 0 }) { + map { exp 2i * pi/$n * $_ }, ^$n +} + +printf "% .5f + % .5fi\n", .re, .im for roots_of_unity 10; diff --git a/Task/Roots-of-unity/Perl/roots-of-unity.pl b/Task/Roots-of-unity/Perl/roots-of-unity.pl new file mode 100644 index 0000000000..e04f0a6561 --- /dev/null +++ b/Task/Roots-of-unity/Perl/roots-of-unity.pl @@ -0,0 +1,11 @@ +use Math::Complex; + +foreach $n (2 .. 10) { + printf "%2d", $n; + foreach $k (0 .. $n-1) { + $ret = cplxe(1, 2 * pi * $k / $n); + $ret->display_format(style => 'cartesian', format => '%.3f'); + print " $ret"; + } + print "\n"; +} diff --git a/Task/Roots-of-unity/PicoLisp/roots-of-unity.l b/Task/Roots-of-unity/PicoLisp/roots-of-unity.l new file mode 100644 index 0000000000..5a29b132f9 --- /dev/null +++ b/Task/Roots-of-unity/PicoLisp/roots-of-unity.l @@ -0,0 +1,15 @@ +(load "@lib/math.l") + +(for N (range 2 10) + (let Angle 0.0 + (prin N ": ") + (for I N + (let Ipart (sin Angle) + (prin + (round (cos Angle) 4) + (if (lt0 Ipart) "-" "+") + "j" + (round (abs Ipart) 4) + " " ) ) + (inc 'Angle (*/ 2 pi N)) ) + (prinl) ) ) diff --git a/Task/Roots-of-unity/PureBasic/roots-of-unity.purebasic b/Task/Roots-of-unity/PureBasic/roots-of-unity.purebasic new file mode 100644 index 0000000000..715841008c --- /dev/null +++ b/Task/Roots-of-unity/PureBasic/roots-of-unity.purebasic @@ -0,0 +1,12 @@ +OpenConsole() +For n = 2 To 10 + angle = 0 + PrintN(Str(n)) + For i = 1 To n + x.f = Cos(Radian(angle)) + y.f = Sin(Radian(angle)) + PrintN( Str(i) + ": " + StrF(x, 6) + " / " + StrF(y, 6)) + angle = angle + (360 / n) + Next +Next +Input() diff --git a/Task/Roots-of-unity/Python/roots-of-unity.py b/Task/Roots-of-unity/Python/roots-of-unity.py new file mode 100644 index 0000000000..9368844f16 --- /dev/null +++ b/Task/Roots-of-unity/Python/roots-of-unity.py @@ -0,0 +1,20 @@ +import cmath +class Complex(complex): + def __repr__(self): + rp = '%7.5f'%self.real if not self.pureImag() else '' + ip = '%7.5fj'%self.imag if not self.pureReal() else '' + conj = '' if (self.pureImag() or self.pureReal() or self.imag<0.0) else '+' + return '0.0' if (self.pureImag() and self.pureReal()) else rp+conj+ip + def pureImag(self): + return abs( self.real) < 0.000005 + def pureReal(self): + return abs( self.imag) < 0.000005 + +def croots(n): + if n<=0: + return None + return (Complex(cmath.rect(1, 2*k*cmath.pi/n)) for k in range(n)) + # in pre-Python 2.6, return (Complex(cmath.exp(2j*k*cmath.pi/n)) for k in range(n)) + +for nr in range(2,11): + print nr, list(croots(nr)) diff --git a/Task/Roots-of-unity/R/roots-of-unity.r b/Task/Roots-of-unity/R/roots-of-unity.r new file mode 100644 index 0000000000..15f11131bb --- /dev/null +++ b/Task/Roots-of-unity/R/roots-of-unity.r @@ -0,0 +1,7 @@ +for(j in 2:10) { + r <- sprintf("%d: ", j) + for(n in 1:j) { + r <- paste(r, format(exp(2i*pi*n/j), digits=4), ifelse(n +360 deg.*/ +/*──────────────────────────────────COS subroutine──────────────────────*/ +cos: procedure; arg x; x=r2r(x); a=abs(x); numeric fuzz min(9,digits()-9); +if a=pi() then return -1; if a=pi()/2 | a=2*pi() then return 0 +if a=pi()/3 then return .5; if a=2*pi()/3 then return -.5; return .sincos(1,1,-1) +/*──────────────────────────────────SIN subroutine──────────────────────*/ +sin: procedure; arg x; x=r2r(x); numeric fuzz min(5,digits()-3) +if abs(x)=pi() then return 0; return .sincos(x,x,1) +/*──────────────────────────────────.SINCOS subroutine──────────────────*/ +.sincos: parse arg z,_,i; x=x*x; p=z + do k=2 by 2; _=-_*x/(k*(k+i)); z=z+_; if z=p then leave; p=z; end; +return z diff --git a/Task/Roots-of-unity/RLaB/roots-of-unity.rlab b/Task/Roots-of-unity/RLaB/roots-of-unity.rlab new file mode 100644 index 0000000000..3fe31903cf --- /dev/null +++ b/Task/Roots-of-unity/RLaB/roots-of-unity.rlab @@ -0,0 +1,16 @@ +// specify polynomial +>> n = 10; +>> a = zeros(1,n+1); a[1] = 1; a[n+1] = -1; +>> polyroots(a) + radius roots success +>> polyroots(a).roots + -0.309016994 + 0.951056516i + -0.809016994 + 0.587785252i + -1 + 5.95570041e-23i + -0.809016994 - 0.587785252i + -0.309016994 - 0.951056516i + 0.309016994 - 0.951056516i + 0.809016994 - 0.587785252i + 1 + 0i + 0.809016994 + 0.587785252i + 0.309016994 + 0.951056516i diff --git a/Task/Roots-of-unity/Racket/roots-of-unity.rkt b/Task/Roots-of-unity/Racket/roots-of-unity.rkt new file mode 100644 index 0000000000..f845fb6d3c --- /dev/null +++ b/Task/Roots-of-unity/Racket/roots-of-unity.rkt @@ -0,0 +1,5 @@ +#lang racket + +(define (roots-of-unity n) + (for/list ([k n]) + (make-polar 1 (* k (/ (* 2 pi) n))))) diff --git a/Task/Roots-of-unity/Ruby/roots-of-unity.rb b/Task/Roots-of-unity/Ruby/roots-of-unity.rb new file mode 100644 index 0000000000..7b89d60a0b --- /dev/null +++ b/Task/Roots-of-unity/Ruby/roots-of-unity.rb @@ -0,0 +1,6 @@ +require 'complex' + +for n in 2..10 + printf "%2d ", n + puts (0..n-1).map { |k| Complex.polar(1, 2 * Math::PI * k / n) }.join(" ") +end diff --git a/Task/Roots-of-unity/Scala/roots-of-unity.scala b/Task/Roots-of-unity/Scala/roots-of-unity.scala new file mode 100644 index 0000000000..42e9522e29 --- /dev/null +++ b/Task/Roots-of-unity/Scala/roots-of-unity.scala @@ -0,0 +1 @@ +def rootsOfUnity(n:Int)=for(k <- 0 until n) yield Complex.fromPolar(1.0, 2*math.Pi*k/n) diff --git a/Task/Roots-of-unity/Scheme/roots-of-unity.ss b/Task/Roots-of-unity/Scheme/roots-of-unity.ss new file mode 100644 index 0000000000..64f52f65d4 --- /dev/null +++ b/Task/Roots-of-unity/Scheme/roots-of-unity.ss @@ -0,0 +1,10 @@ +(define pi (* 4 (atan 1))) + +(do ((n 2 (+ n 1))) + ((> n 10)) + (display n) + (do ((k 0 (+ k 1))) + ((>= k n)) + (display " ") + (display (make-polar 1 (* 2 pi (/ k n))))) + (newline)) diff --git a/Task/Roots-of-unity/Seed7/roots-of-unity-1.seed7 b/Task/Roots-of-unity/Seed7/roots-of-unity-1.seed7 new file mode 100644 index 0000000000..a68c38da97 --- /dev/null +++ b/Task/Roots-of-unity/Seed7/roots-of-unity-1.seed7 @@ -0,0 +1,17 @@ +$ include "seed7_05.s7i"; + include "float.s7i"; + include "complex.s7i"; + +const proc: main is func + local + var integer: n is 0; + var integer: k is 0; + begin + for n range 2 to 10 do + write(n lpad 2 <& ": "); + for k range 0 to pred(n) do + write(polar(1.0, 2.0 * PI * flt(k) / flt(n)) digits 4 lpad 15 <& " "); + end for; + writeln; + end for; + end func; diff --git a/Task/Roots-of-unity/Seed7/roots-of-unity-2.seed7 b/Task/Roots-of-unity/Seed7/roots-of-unity-2.seed7 new file mode 100644 index 0000000000..35eeb50b92 --- /dev/null +++ b/Task/Roots-of-unity/Seed7/roots-of-unity-2.seed7 @@ -0,0 +1,9 @@ +2: 1.0000+0.0000i -1.0000+0.0000i + 3: 1.0000+0.0000i -0.5000+0.8660i -0.5000-0.8660i + 4: 1.0000+0.0000i 0.0000+1.0000i -1.0000+0.0000i 0.0000-1.0000i + 5: 1.0000+0.0000i 0.3090+0.9511i -0.8090+0.5878i -0.8090-0.5878i 0.3090-0.9511i + 6: 1.0000+0.0000i 0.5000+0.8660i -0.5000+0.8660i -1.0000+0.0000i -0.5000-0.8660i 0.5000-0.8660i + 7: 1.0000+0.0000i 0.6235+0.7818i -0.2225+0.9749i -0.9010+0.4339i -0.9010-0.4339i -0.2225-0.9749i 0.6235-0.7818i + 8: 1.0000+0.0000i 0.7071+0.7071i 0.0000+1.0000i -0.7071+0.7071i -1.0000+0.0000i -0.7071-0.7071i 0.0000-1.0000i 0.7071-0.7071i + 9: 1.0000+0.0000i 0.7660+0.6428i 0.1736+0.9848i -0.5000+0.8660i -0.9397+0.3420i -0.9397-0.3420i -0.5000-0.8660i 0.1736-0.9848i 0.7660-0.6428i +10: 1.0000+0.0000i 0.8090+0.5878i 0.3090+0.9511i -0.3090+0.9511i -0.8090+0.5878i -1.0000+0.0000i -0.8090-0.5878i -0.3090-0.9511i 0.3090-0.9511i 0.8090-0.5878i diff --git a/Task/Roots-of-unity/TI-89-BASIC/roots-of-unity-1.ti-89 b/Task/Roots-of-unity/TI-89-BASIC/roots-of-unity-1.ti-89 new file mode 100644 index 0000000000..82bdf7094d --- /dev/null +++ b/Task/Roots-of-unity/TI-89-BASIC/roots-of-unity-1.ti-89 @@ -0,0 +1 @@ +cZeros(x^n - 1, x) diff --git a/Task/Roots-of-unity/TI-89-BASIC/roots-of-unity-2.ti-89 b/Task/Roots-of-unity/TI-89-BASIC/roots-of-unity-2.ti-89 new file mode 100644 index 0000000000..7cef6e5521 --- /dev/null +++ b/Task/Roots-of-unity/TI-89-BASIC/roots-of-unity-2.ti-89 @@ -0,0 +1 @@ +{-1/2+√(3)/2*i, -1/2-√(3)/2*i, 1} diff --git a/Task/Roots-of-unity/Tcl/roots-of-unity.tcl b/Task/Roots-of-unity/Tcl/roots-of-unity.tcl new file mode 100644 index 0000000000..9dbf82dc52 --- /dev/null +++ b/Task/Roots-of-unity/Tcl/roots-of-unity.tcl @@ -0,0 +1,13 @@ +package require Tcl 8.5 +namespace import tcl::mathfunc::* + +set pi 3.14159265 +for {set n 2} {$n <= 10} {incr n} { + set angle 0.0 + set row $n: + for {set i 1} {$i <= $n} {incr i} { + lappend row [format %5.4f%+5.4fi [cos $angle] [sin $angle]] + set angle [expr {$angle + 2*$pi/$n}] + } + puts $row +} diff --git a/Task/Roots-of-unity/Ursala/roots-of-unity.ursala b/Task/Roots-of-unity/Ursala/roots-of-unity.ursala new file mode 100644 index 0000000000..741ff48120 --- /dev/null +++ b/Task/Roots-of-unity/Ursala/roots-of-unity.ursala @@ -0,0 +1,9 @@ +#import std +#import nat +#import flo + +roots = ~&htxPC+ c..mul:-0^*DlSiiDlStK9\iota c..mul@iiX+ c..cpow/-1.+ div/1.+ float + +#cast %jLL + +tests = roots* <1,2,3,4,5,6> diff --git a/Task/Rosetta-Code-Count-examples/0DESCRIPTION b/Task/Rosetta-Code-Count-examples/0DESCRIPTION new file mode 100644 index 0000000000..12fae61891 --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/0DESCRIPTION @@ -0,0 +1,11 @@ +Find the total number of programming examples for each [[:Category:Programming Tasks|task]] and the total for all tasks. + +Essentially, count the number of occurrences of =={{header| on each task page. + +Output: + +
    100 doors: 20 examples.
    +99 Bottles of Beer: 29 examples.
    +Abstract type: 10 examples.
    +
    +Total: X examples.
    diff --git a/Task/Rosetta-Code-Count-examples/1META.yaml b/Task/Rosetta-Code-Count-examples/1META.yaml new file mode 100644 index 0000000000..b392469fa2 --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Rosetta Code related diff --git a/Task/Rosetta-Code-Count-examples/Ada/rosetta-code-count-examples.ada b/Task/Rosetta-Code-Count-examples/Ada/rosetta-code-count-examples.ada new file mode 100644 index 0000000000..29d0419cb0 --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/Ada/rosetta-code-count-examples.ada @@ -0,0 +1,101 @@ +with Aws.Client, Aws.Messages, Aws.Response, Aws.Resources, Aws.Url; +with Dom.Readers, Dom.Core, Dom.Core.Documents, Dom.Core.Nodes, Dom.Core.Attrs; +with Input_Sources.Strings, Unicode, Unicode.Ces.Utf8; +with Ada.Strings.Unbounded, Ada.Strings.Fixed, Ada.Text_IO, Ada.Command_Line; +with Ada.Containers.Vectors; + +use Aws.Client, Aws.Messages, Aws.Response, Aws.Resources, Aws.Url; +use Dom.Readers, Dom.Core, Dom.Core.Documents, Dom.Core.Nodes, Dom.Core.Attrs; +use Aws, Ada.Strings.Unbounded, Ada.Strings.Fixed, Input_Sources.Strings; +use Ada.Text_IO, Ada.Command_Line; + +procedure Count_Examples is + + package Members_Vectors is new Ada.Containers.Vectors ( + Index_Type => Positive, + Element_Type => Unbounded_String); + use Members_Vectors; + + Exemples : Vector; + Nbr_Lg, Total : Natural := 0; + + procedure Get_Vector (Category : in String; Mbr_Vector : in out Vector) is + Reader : Tree_Reader; + Doc : Document; + List : Node_List; + N : Node; + A : Attr; + Page : Aws.Response.Data; + Uri_Xml : constant String := + "http://rosettacode.org/mw/api.php?action=query&list=categorymembers" + & + "&format=xml&cmlimit=500&cmtitle=Category:"; + begin + Page := Client.Get (Uri_Xml & Category); + if Response.Status_Code (Page) not in Messages.Success then + raise Client.Connection_Error; + end if; + declare + Xml : constant String := Message_Body (Page); + Source : String_Input; + begin + Open + (Xml'Unrestricted_Access, + Unicode.Ces.Utf8.Utf8_Encoding, + Source); + Parse (Reader, Source); + Close (Source); + end; + Doc := Get_Tree (Reader); + List := Get_Elements_By_Tag_Name (Doc, "cm"); + for Index in 1 .. Length (List) loop + N := Item (List, Index - 1); + A := Get_Named_Item (Attributes (N), "title"); + Append (Mbr_Vector, To_Unbounded_String (Value (A))); + end loop; + Free (List); + Free (Reader); + end Get_Vector; + + function Scan_Page (Title : String) return Natural is + Page : Aws.Response.Data; + File : Aws.Resources.File_Type; + Buffer : String (1 .. 1024); + Languages, Position, Last : Natural := 0; + begin + Page := + Client.Get + ("http://rosettacode.org/mw/index.php?title=" & + Aws.Url.Encode (Title) & + "&action=raw"); + Response.Message_Body (Page, File); + while not End_Of_File (File) loop + Resources.Get_Line (File, Buffer, Last); + Position := + Index + (Source => Buffer (Buffer'First .. Last), + Pattern => "=={{header|"); + if Position > 0 then + Languages := Languages + 1; + end if; + end loop; + Close (File); + return Languages; + end Scan_Page; + +begin + Get_Vector ("Programming_Tasks", Exemples); + + for I in First_Index (Exemples) .. Last_Index (Exemples) loop + declare + Title : constant String := + To_String (Members_Vectors.Element (Exemples, I)); + begin + Nbr_Lg := Scan_Page (Title); + Total := Total + Nbr_Lg; + Put_Line (Title & " :" & Integer'Image (Nbr_Lg) & " exemples."); + end; + end loop; + + Put_Line ("Total :" & Integer'Image (Total) & " exemples."); +end Count_Examples; diff --git a/Task/Rosetta-Code-Count-examples/AutoHotkey/rosetta-code-count-examples.ahk b/Task/Rosetta-Code-Count-examples/AutoHotkey/rosetta-code-count-examples.ahk new file mode 100644 index 0000000000..2abaeb18cc --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/AutoHotkey/rosetta-code-count-examples.ahk @@ -0,0 +1,20 @@ +UrlDownloadToFile + , http://www.rosettacode.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=500&format=xml + , tasks.xml +FileRead, tasks, tasks.xml +pos = 0 +quote = " ; " +regtitle := "", i%) + title$ = MID$(a$, i%+7, j%-i%-10) + REM Replace HTML codes: + REPEAT + k% = INSTR(title$, "&") + IF k% THEN + l% = INSTR(title$, ";", k%) + title$ = LEFT$(title$,k%-1) + \ + \ FNhtml(MID$(title$,k%,l%-k%+1)) + MID$(title$,l%+1) + ENDIF + UNTIL k% = 0 + t$ = title$ + REM Substitute characters not allowed in a URL: + FOR s% = 1 TO LEN(special$) + REPEAT + s$ = MID$(special$, s%, 1) + k% = INSTR(t$, s$) + IF k% t$ = LEFT$(t$,k%-1) + "%" + STR$~ASCs$ + MID$(t$,k%+1) + UNTIL k% = 0 + NEXT + url$ = "http://www.rosettacode.org/w/index.php?title=" + t$ + \ + \ "&action=raw" + file$ = @tmp$ + "title.htm" + SYS UDTF, 0, url$, file$, 0, 0 TO fail% + IF fail% ERROR 100, "File download failed " + t$ + examples% = 0 + task% = OPENIN(file$) + WHILE NOT EOF#task% + IF INSTR(GET$#task%, "=={{header|") examples% += 1 + ENDWHILE + CLOSE #task% + Total% += examples% + PRINT title$ ": " ; examples% " examples." + ENDIF + UNTIL i% = 0 + i% = INSTR(a$, "cmcontinue=") + IF i% THEN + CLOSE #file% + j% = INSTR(a$, """", i%+1) + k% = INSTR(a$, """", j%+1) + url$ = "http://www.rosettacode.org/w/api.php?action=query" + \ + \ "&list=categorymembers&cmtitle=Category:Programming_Tasks" + \ + \ "&cmlimit=500&format=xml&cmcontinue=" + MID$(a$,j%+1,k%-j%) + REPEAT + i% = INSTR(url$, "|") + IF i% url$ = LEFT$(url$,i%-1) + "%7C" + MID$(url$,i%+1) + UNTIL i% = 0 + file$ = @tmp$ + "tasks.xml" + SYS UDTF, 0, url$, file$, 0, 0 TO fail% + IF fail% ERROR 100, "File download failed (continue)" + file% = OPENIN(file$) + ENDIF + ENDWHILE + CLOSE #file% + PRINT ' "Total: " ; Total% " examples." + END + + DEF FNhtml(h$) + IF LEFT$(h$,2) = "&#" THEN = CHR$(VALMID$(h$,3)) + CASE h$ OF + WHEN """: = """" + ENDCASE + = h$ diff --git a/Task/Rosetta-Code-Count-examples/Clojure/rosetta-code-count-examples-1.clj b/Task/Rosetta-Code-Count-examples/Clojure/rosetta-code-count-examples-1.clj new file mode 100644 index 0000000000..2a02a00924 --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/Clojure/rosetta-code-count-examples-1.clj @@ -0,0 +1,39 @@ +(ns count-examples + (:import [java.net URLEncoder]) + (:use [clojure.contrib.http.agent :only (http-agent string)] + [clojure.contrib.json :only (read-json)] + [clojure.contrib.string :only (join)])) + +(defn url-encode [v] (URLEncoder/encode (str v) "utf-8")) + +(defn rosettacode-get [path params] + (let [param-string (join "&" (for [[n v] params] (str (name n) "=" (url-encode v))))] + (string (http-agent (format "http://www.rosettacode.org/w/%s?%s" path param-string))))) + +(defn rosettacode-query [params] + (read-json (rosettacode-get "api.php" (merge {:action "query" :format "json"} params)))) + +(defn list-cm + ([params] (list-cm params nil)) + ([params continue] + (let [cm-params (merge {:list "categorymembers"} params (or continue {})) + result (rosettacode-query cm-params)] + (concat (-> result (:query) (:categorymembers)) + (if-let [cmcontinue (-> result (:query-continue) (:categorymembers))] + (list-cm params cmcontinue)))))) + +(defn programming-tasks [] + (let [result (list-cm {:cmtitle "Category:Programming_Tasks" :cmlimit 50})] + (map #(:title %) result))) + +(defn task-count [task] + [task (count + (re-seq #"==\{\{header" + (rosettacode-get "index.php" {:action "raw" :title task})))]) + +(defn print-result [] + (let [task-counts (map task-count (programming-tasks))] + (doseq [[task count] task-counts] + (println (str task ":") count) + (flush)) + (println "Total: " (reduce #(+ %1 (second %2)) 0 task-counts)))) diff --git a/Task/Rosetta-Code-Count-examples/Clojure/rosetta-code-count-examples-2.clj b/Task/Rosetta-Code-Count-examples/Clojure/rosetta-code-count-examples-2.clj new file mode 100644 index 0000000000..f2a356dbb4 --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/Clojure/rosetta-code-count-examples-2.clj @@ -0,0 +1,16 @@ +count-examples> (print-result) +100 doors: 73 +24 game: 18 +24 game/Solve: 14 +99 Bottles of Beer: 89 +Abstract type: 27 +Accumulator factory: 23 +Ackermann function: 73 +Active Directory/Connect: 4 +Active Directory/Search for a user: 3 +Active object: 14 +Add a variable to a class instance at runtime: 21 +Address of a variable: 20 +... +Total: 11216 +nil diff --git a/Task/Rosetta-Code-Count-examples/D/rosetta-code-count-examples.d b/Task/Rosetta-Code-Count-examples/D/rosetta-code-count-examples.d new file mode 100644 index 0000000000..a74727fb97 --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/D/rosetta-code-count-examples.d @@ -0,0 +1,48 @@ +import tango.io.Stdout; +import tango.net.http.HttpClient; +import tango.net.http.HttpHeaders; +import tango.text.xml.Document; +import tango.text.Util; + +alias HttpHeader.ContentLength CL; + +auto url = "http://www.rosettacode.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=500&format=xml"; +void main() +{ + auto client = new HttpClient (HttpClient.Get, url); + client.open(); + char[] mainData, tmp; + int total, i; + + void cat(void[] content) { tmp ~= cast(char[]) content; } + + if (client.isResponseOK) { + client.read(&cat, client.getResponseHeaders.getInt(CL)); + mainData = tmp; + tmp = null; + + auto doc = new Document!(char); + doc.parse(mainData); + foreach (n; doc.query.descendant("cm").attribute("title")) { + auto subClient = new HttpClient(HttpClient.Get, + "http://www.rosettacode.org/w/index.php?title=" ~ + replace(n.value.dup, ' ', '_') ~ "&action=raw"); + subClient.open(); + if (! subClient.isResponseOK) { + Stderr (client.getResponse); + break; + } + subClient.read(&cat, subClient.getResponseHeaders.getInt(CL)); + foreach (segment; patterns(cast(char[])tmp, "=={{header|")) i++; + --i; + if (i) --i; + Stdout.formatln ("{0,-40} - {}", n.value, i); + total += i; + tmp = null; + i = 0; + } + Stdout("total examples: ", total).newline; + } else { + Stderr (client.getResponse); + } +} diff --git a/Task/Rosetta-Code-Count-examples/EGL/rosetta-code-count-examples-1.egl b/Task/Rosetta-Code-Count-examples/EGL/rosetta-code-count-examples-1.egl new file mode 100644 index 0000000000..b9e86896d8 --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/EGL/rosetta-code-count-examples-1.egl @@ -0,0 +1,76 @@ +package com.eglexamples.client; + +import org.eclipse.edt.rui.widgets.*; + +handler RosettaCodeHandler type RUIhandler{initialUI =[ui], title = "Rosetta Code Tasks and Counts"} + + ui GridLayout{columns = 3, rows = 4, cellPadding = 4, children = [ b1, dg1, l1, l2, l3, l4 ]}; + + b1 Button{ layoutData = new GridLayoutData{ row = 1, column = 1 }, text = "Go!", onClick ::= b1_onClick }; + l1 TextLabel{ layoutData = new GridLayoutData{ row = 1, column = 2 }, text = "Total Tasks:" }; + l2 TextLabel{ layoutData = new GridLayoutData{ row = 1, column = 3 }, text = "0" }; + + l3 TextLabel{ layoutData = new GridLayoutData{ row = 2, column = 2 }, text = "Total Implementations:" }; + l4 TextLabel{ layoutData = new GridLayoutData{ row = 2, column = 3 }, text = "0" }; + + dg1 DataGrid{ layoutData = new GridLayoutData{ row = 3, column = 1, horizontalSpan = 3 }, + pageSize = 10, showScrollbar = true, + columns = [ new DataGridColumn{name = "title", displayName = "Task", width=220}, + new DataGridColumn{name = "count", displayName = "Count", width=100} ] }; + + cmcontinue string?; + title string?; + allTasks Task[]; + + restBindingTasks IHttp? = new HttpRest{ + restType = eglx.rest.ServiceType.TrueRest, + request.uri = "http://rosettacode.org/mw/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=1&format=json"}; + + restBindingPageDetail IHttp? = new HttpRest{ + restType = eglx.rest.ServiceType.TrueRest, + request.uri = "http://rosettacode.org/mw/index.php"}; + + function b1_onClick(event Event in) + call ProxyFunctions.listTasks("") using restBindingTasks + returning to listTasksCallBack onException exceptionHandler; + end + + function listTasksCallBack(retResult RosettaCodeJSON in) + title = retResult.query.categorymembers[1].title; + cmcontinue = retResult.queryContinue.categorymembers.cmcontinue; + + call ProxyFunctions.fetchPageDetail(title) using restBindingPageDetail + returning to pageDetailCallBack onException exceptionHandler; + end + + function pageDetailCallBack(pageResults string in) + count int = countSubstring("=={{header", pageResults); + allTasks.appendElement(new Task { title = title, count = count }); + l2.text = l2.text as int + 1; + l4.text = l4.text as int + count; + + if(cmcontinue != null) + call ProxyFunctions.listTasks(cmcontinue) using restBindingTasks + returning to listTasksCallBack onException exceptionHandler; + else + dg1.data = allTasks as any[]; + end + 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 exceptionHandler(exp AnyException in) + end + +end + +record Task + title string; + count int; +end diff --git a/Task/Rosetta-Code-Count-examples/EGL/rosetta-code-count-examples-2.egl b/Task/Rosetta-Code-Count-examples/EGL/rosetta-code-count-examples-2.egl new file mode 100644 index 0000000000..c672f8ca00 --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/EGL/rosetta-code-count-examples-2.egl @@ -0,0 +1,37 @@ +package com.eglexamples.client; + +library ProxyFunctions + + function listTasks(continueLocation String in) returns (RosettaCodeJSON) { + @Rest{method = _GET, uriTemplate = "&cmcontinue={continueLocation}", + requestFormat = None, responseFormat = JSON} + } + end + + function fetchPageDetail(title String in) returns (String) { + @Rest{method = _GET, uriTemplate = "?title={title}&action=raw", + requestFormat = None, responseFormat = None} + } + end + +end + +record RosettaCodeJSON + query Query; + queryContinue QueryContinue{JSONName = "query-continue"}; +end + +record Query + categorymembers Categorymembers[]; +end + +record Categorymembers + cmcontinue string?; + pageid int?; + ns int?; + title string?; +end + +record QueryContinue + categorymembers Categorymembers; +end diff --git a/Task/Rosetta-Code-Count-examples/Erlang/rosetta-code-count-examples.erl b/Task/Rosetta-Code-Count-examples/Erlang/rosetta-code-count-examples.erl new file mode 100644 index 0000000000..3708959104 --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/Erlang/rosetta-code-count-examples.erl @@ -0,0 +1,62 @@ +-module(rosseta_examples). +-include_lib("xmerl/include/xmerl.hrl"). + +-export([main/0]). + +main() -> + application:start(inets), + Titles = read_titles(empty), + Result = lists:foldl(fun(Title,Acc) -> Acc + calculate_one(Title) end, 0, Titles), + io:format("Total: ~p examples.\n",[Result]), + application:stop(inets). + +read_titles(CurrentContinue) -> + URL0 = "http://rosettacode.org/mw/api.php?" ++ + "action=query&list=categorymembers&cmtitle=Category:Programming_Tasks" ++ + "&cmlimit=500&format=xml", + URL = + case CurrentContinue of + empty -> URL0; + _ -> URL0 ++ "&cmcontinue=" ++ CurrentContinue + end, + {ok,Answer} = httpc:request(URL), + {Document,_} = xmerl_scan:string(lists:last(tuple_to_list(Answer))), + Continue = + [Value || #xmlAttribute{value = Value} <- xmerl_xpath:string("//@cmcontinue", Document)], + Titles = + [Value || #xmlAttribute{value = Value} <- xmerl_xpath:string("//@title", Document)], + case Continue of + []-> + Titles; + [ContValue | _] -> + Titles ++ read_titles(ContValue) + end. + +calculate_one(Title0) -> + Title = replace_chars(Title0), + URL = "http://www.rosettacode.org/w/index.php?title=" ++ + Title ++ "&action=raw", + case httpc:request(URL) of + {ok,Result} -> + {match,Found} = + re:run(lists:last(tuple_to_list(Result)), "\n=={{header(|)", [global]), + io:format("~ts: ~p examples.\n",[Title0,length(Found)]), + length(Found); + {error,socket_closed_remotely} -> + io:format("Socket closed remotely. Retry.\n"), + calculate_one(Title0) + end. + +replace_chars(String) -> + replace_chars(String,[]). + +replace_chars([$ | T],Acc) -> + replace_chars(T, [$_| Acc]); +replace_chars([$+| T],Acc) -> + replace_chars(T, lists:reverse("%2B") ++ Acc); +replace_chars([8211| T],Acc) -> + replace_chars(T, lists:reverse("%E2%80%93") ++ Acc); +replace_chars([Other| T],Acc) -> + replace_chars(T, [Other| Acc]); +replace_chars([],Acc) -> + lists:reverse(Acc). diff --git a/Task/Rosetta-Code-Count-examples/Go/rosetta-code-count-examples.go b/Task/Rosetta-Code-Count-examples/Go/rosetta-code-count-examples.go new file mode 100644 index 0000000000..a7cceb6e2c --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/Go/rosetta-code-count-examples.go @@ -0,0 +1,75 @@ +package main + +import ( + "bytes" + "encoding/xml" + "fmt" + "io" + "io/ioutil" + "net/http" + "net/url" + "strings" +) + +func req(u string, foundCm func(string)) string { + resp, err := http.Get(u) + if err != nil { + fmt.Println(err) // connection or request fail + return "" + } + defer resp.Body.Close() + for p := xml.NewDecoder(resp.Body); ; { + t, err := p.RawToken() + switch s, ok := t.(xml.StartElement); { + case err == io.EOF: + return "" + case err != nil: + fmt.Println(err) + return "" + case !ok: + continue + case s.Name.Local == "cm": + for _, a := range s.Attr { + if a.Name.Local == "title" { + foundCm(a.Value) + } + } + case s.Name.Local == "categorymembers" && len(s.Attr) > 0 && + s.Attr[0].Name.Local == "cmcontinue": + return url.QueryEscape(s.Attr[0].Value) + } + } + return "" +} + +func main() { + taskQuery := "http://rosettacode.org/mw/api.php?action=query" + + "&format=xml&list=categorymembers&cmlimit=500" + + "&cmtitle=Category:Programming_Tasks" + continueAt := req(taskQuery, count) + for continueAt > "" { + continueAt = req(taskQuery+"&cmcontinue="+continueAt, count) + } + fmt.Printf("Total: %d examples.\n", total) +} + +var marker = []byte("=={{header|") +var total int + +func count(cm string) { + taskFmt := "http://rosettacode.org/mw/index.php?title=%s&action=raw" + taskEsc := url.QueryEscape(strings.Replace(cm, " ", "_", -1)) + resp, err := http.Get(fmt.Sprintf(taskFmt, taskEsc)) + var page []byte + if err == nil { + page, err = ioutil.ReadAll(resp.Body) + resp.Body.Close() + } + if err != nil { + fmt.Println(err) + return + } + examples := bytes.Count(page, marker) + fmt.Printf("%s: %d\n", cm, examples) + total += examples +} diff --git a/Task/Rosetta-Code-Count-examples/Haskell/rosetta-code-count-examples-1.hs b/Task/Rosetta-Code-Count-examples/Haskell/rosetta-code-count-examples-1.hs new file mode 100644 index 0000000000..d7d1672254 --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/Haskell/rosetta-code-count-examples-1.hs @@ -0,0 +1,37 @@ +import Network.Browser +import Network.HTTP +import Network.URI +import Data.List +import Data.Maybe +import Text.XML.Light +import Control.Arrow + +justifyR w = foldl ((.return).(++).tail) (replicate w ' ') +showFormatted t n = t ++ ": " ++ justifyR 4 (show n) + +getRespons url = do + rsp <- Network.Browser.browse $ do + setAllowRedirects True + setOutHandler $ const (return ()) -- quiet + request $ getRequest url + return $ rspBody $ snd rsp + +getNumbOfExampels p = do + let pg = intercalate "_" $ words p + rsp <- getRespons $ "http://www.rosettacode.org/w/index.php?title=" ++ pg ++ "&action=raw" + let taskPage = rsp + countEx = length $ filter (=="=={{header|") $ takeWhile(not.null) $ unfoldr (Just. (take 11 &&& drop 1)) taskPage + return countEx + +progTaskExamples = do + rsp <- getRespons "http://www.rosettacode.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=500&format=xml" + + let xmls = onlyElems $ parseXML $ rsp + tasks = concatMap (map (fromJust.findAttr (unqual "title")). filterElementsName (== unqual "cm")) xmls + + taskxx <- mapM getNumbOfExampels tasks + let ns = taskxx + tot = sum ns + + mapM_ putStrLn $ zipWith showFormatted tasks ns + putStrLn $ ("Total: " ++) $ show tot diff --git a/Task/Rosetta-Code-Count-examples/Haskell/rosetta-code-count-examples-2.hs b/Task/Rosetta-Code-Count-examples/Haskell/rosetta-code-count-examples-2.hs new file mode 100644 index 0000000000..626e2b9d95 --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/Haskell/rosetta-code-count-examples-2.hs @@ -0,0 +1,10 @@ +*Main> progTaskExamples +100 doors: 56 +24 game: 11 +24 game Player: 9 +99 Bottles of Beer: 73 +Abstract type: 23 +Ackermann Function: 61 +Active object: 9 +... +Total: 9156 diff --git a/Task/Rosetta-Code-Count-examples/Haskell/rosetta-code-count-examples-3.hs b/Task/Rosetta-Code-Count-examples/Haskell/rosetta-code-count-examples-3.hs new file mode 100644 index 0000000000..0b99ee7c31 --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/Haskell/rosetta-code-count-examples-3.hs @@ -0,0 +1,65 @@ +$define RCINDEX "http://rosettacode.org/mw/api.php?format=xml&action=query&list=categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=500" +$define RCTASK "http://rosettacode.org/mw/index.php?action=raw&title=" +$define RCUA "User-Agent: Unicon Rosetta 0.1" +$define RCXUA "X-Unicon: http://unicon.org/" +$define TASKTOT "* Total Tasks *" +$define TOTTOT "* Total Headers*" + +link strings +link hexcvt + +procedure main(A) # simple single threaded read all at once implementation + +index := ReadURL(RCINDEX) # 1. read the index + +pages := [] +index ? while tab(find("'\""),3,"0")||";",c) + } + +dxml[1] := u # insert URI as 1st arg +u := replacem!dxml # de-xml it +every (c := "") ||:= tr[!u] # reencode everything +return c +end + +procedure ReadURL(url) #: read URL into string +write(&errout,"Opening ",image(url)) +page := open(url,"m",RCUA,RCXUA) | stop("Unable to open ",url) +text := "" +if page["Status-Code"] < 300 then + while text ||:= reads(page,-1) +else + stop(page["Status-Code"]," ",page["Reason-Phrase"]) +close(page) +return text +end diff --git a/Task/Rosetta-Code-Count-examples/J/rosetta-code-count-examples-1.j b/Task/Rosetta-Code-Count-examples/J/rosetta-code-count-examples-1.j new file mode 100644 index 0000000000..a47f432cba --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/J/rosetta-code-count-examples-1.j @@ -0,0 +1,20 @@ +require 'web/gethttp' + +getAllTaskSolnCounts=: monad define + tasks=. getCategoryMembers 'Programming_Tasks' + counts=. getTaskSolnCounts &> tasks + tasks;counts +) + +getTaskSolnCounts=: monad define + makeuri=. 'http://www.rosettacode.org/w/index.php?title=' , ,&'&action=raw' + wikidata=. gethttp makeuri urlencode y + ([: +/ '{{header|'&E.) wikidata +) + +formatSolnCounts=: monad define + 'tasks counts'=. y + tasks=. tasks , &.>':' + res=. ;:^:_1 tasks ,. (8!:0 counts) ,. <'examples.' + res , 'Total examples: ' , ": +/counts +) diff --git a/Task/Rosetta-Code-Count-examples/J/rosetta-code-count-examples-2.j b/Task/Rosetta-Code-Count-examples/J/rosetta-code-count-examples-2.j new file mode 100644 index 0000000000..c5da0cab6d --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/J/rosetta-code-count-examples-2.j @@ -0,0 +1,6 @@ + formatSolnCounts getAllTaskSolnCounts '' +100 doors: 61 examples. +24 game: 15 examples. +24 game Player: 11 examples. +99 Bottles of Beer: 76 examples. +... diff --git a/Task/Rosetta-Code-Count-examples/Java/rosetta-code-count-examples.java b/Task/Rosetta-Code-Count-examples/Java/rosetta-code-count-examples.java new file mode 100644 index 0000000000..642c7699e5 --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/Java/rosetta-code-count-examples.java @@ -0,0 +1,69 @@ +import java.util.ArrayList; +import ScreenScrape; + +public class CountProgramExamples { + private static final String baseURL = "http://rosettacode.org/wiki/"; + private static final String rootURL = "http://www.rosettacode.org/w/" + + "api.php?action=query&list=categorymembers" + + "&cmtitle=Category:Programming_Tasks&cmlimit=500&format=xml"; + private static final String taskBegin = "title=\""; + private static final String taskEnd = "\""; + private static final String exmplBegin = ""; + private static final String exmplEnd = ""; + private static final String editBegin = ""; + + /** + * @param args + */ + public static void main(String[] args) { + int exTotal = 0; + try { + // Get root query results + ArrayList tasks = new ArrayList(); + ScreenScrape ss = new ScreenScrape(); + String rootPage = ss.read(rootURL); + while (rootPage.contains(taskBegin)) { + rootPage = rootPage.substring(rootPage.indexOf(taskBegin) + + taskBegin.length()); + String title = rootPage.substring(0, rootPage.indexOf(taskEnd)); + if (!title.contains("Category:")) { + tasks.add(title); + } + rootPage = rootPage.substring(rootPage.indexOf(taskEnd)); + } + // Loop through each task and print count + for (String task : tasks) { + String title = task.replaceAll("'", "'"); + String taskPage = ss.read(baseURL + title.replaceAll(" ", "_")); + int exSubTot; + if (taskPage.contains(exmplBegin)) { + int startPos = taskPage.lastIndexOf(exmplBegin) + + exmplBegin.length(); + String countStr = taskPage.substring(startPos, + taskPage.indexOf(exmplEnd, startPos)); + exSubTot = Integer + .parseInt(countStr.contains(".") ? countStr + .substring(0, countStr.indexOf(".")) + : countStr); + } else { + exSubTot = 0; + while (taskPage.contains(editBegin)) { + taskPage = taskPage.substring(taskPage + .indexOf(editBegin) + editBegin.length()); + exSubTot++; + } + } + exTotal += exSubTot; + System.out.println(title + ": " + exSubTot + " examples."); + } + // Print total + System.out.println("\nTotal: " + exTotal + " examples."); + } catch (Exception e) { + System.out.println(title); + System.out.println(startPos + ":" + + taskPage.indexOf(exmplEnd, startPos)); + System.out.println(taskPage); + e.printStackTrace(System.out); + } + } +} diff --git a/Task/Rosetta-Code-Count-examples/MATLAB/rosetta-code-count-examples.m b/Task/Rosetta-Code-Count-examples/MATLAB/rosetta-code-count-examples.m new file mode 100644 index 0000000000..3a93fa9afb --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/MATLAB/rosetta-code-count-examples.m @@ -0,0 +1,18 @@ + function c = count_examples(url) + c = 0; + [s, success] = urlread (url); + if ~success, return; end; + c = length(strfind(s,'

    " "], "\" has ", + Length@Select[Import["http://rosettacode.org/wiki/" <> #, "Data"][[1,2]], + StringFreeQ[#, __ ~~ "Programming Task" | __ ~~ "Omit"]& ], " example(s)"]& + ~Map~ StringReplace[TaskList, " " -> "_"] diff --git a/Task/Rosetta-Code-Count-examples/OCaml/rosetta-code-count-examples.ocaml b/Task/Rosetta-Code-Count-examples/OCaml/rosetta-code-count-examples.ocaml new file mode 100644 index 0000000000..e8b9288c6c --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/OCaml/rosetta-code-count-examples.ocaml @@ -0,0 +1,62 @@ +open Http_client.Convenience + + +let repl_quote s = + let reg = Str.regexp_string "'" in + (Str.global_replace reg "%27" s) + +let repl_space s = + let s = String.copy s in + for i = 0 to pred(String.length s) do + if s.[i] = ' ' then s.[i] <- '_' + done; + (s) +(* or in OCaml 4.00+: + let repl_space = String.map (fun c -> if c = ' ' then '_' else c) +*) + +let count_ex s = + let pat = Str.regexp_string "=={{header|" in + let rec aux n p = + try + let p = Str.search_forward pat s p in + aux (n+1) (p+1) + with Not_found -> (n) + in + aux 0 0 + +let get_child child xml = + let child = + List.find + (function Xml.Element (tag,_,_) when tag = child -> true | _ -> false) xml + in + Xml.children child + +let () = + let url = "http://www.rosettacode.org/w/api.php?action=query&list=categorymembers&\ + cmtitle=Category:Programming_Tasks&cmlimit=500&format=xml" in + + let xml = Xml.parse_string (http_get url) in + + let total = ref 0 in + at_exit (fun () -> Printf.printf "\n Total: %d\n" !total); + + let f = function + | Xml.Element ("cm", attrs, _) -> + (try + let _title = List.assoc "title" attrs in + let title = repl_quote (repl_space _title) in + let url = "http://www.rosettacode.org/w/index.php?title="^ title ^"&action=raw" in + let n = count_ex (http_get url) in + Printf.printf "%s: %d\n%!" _title n; + total := n + !total; + with Http_client.Http_error (404, _) -> ()) + | _ -> () + in + + match xml with + | Xml.Element ("api", _, ch) -> + let query = get_child "query" ch in + let catmb = get_child "categorymembers" query in + List.iter f catmb + | _ -> () diff --git a/Task/Rosetta-Code-Count-examples/Oz/rosetta-code-count-examples.oz b/Task/Rosetta-Code-Count-examples/Oz/rosetta-code-count-examples.oz new file mode 100644 index 0000000000..789d287782 --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/Oz/rosetta-code-count-examples.oz @@ -0,0 +1,85 @@ +declare + [HTTPClient] = {Module.link ['x-ozlib://mesaros/net/HTTPClient.ozf']} + [XMLParser] = {Module.link ['x-oz://system/xml/Parser.ozf']} + [StringX] = {Module.link ['x-oz://system/String.ozf']} + [Regex] = {Module.link ['x-oz://contrib/regex']} + + AllTasksUrl = "http://rosettacode.org/mw/api.php?action=query&list="# + "categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=500&format=xml" + + proc {Main} + AllTasks = {Parse {GetPage AllTasksUrl}} + TaskTitles = {GetTitles AllTasks} + Total = {NewCell 0} + in + for Task in TaskTitles do + TaskPage = {GetPage {TaskUrl Task}} + RE = {Regex.compile "{{header\\|" [extended newline icase]} + NumMatches = {Length {Regex.allMatches RE TaskPage}} + in + {System.showInfo Task#": "#NumMatches#" examples."} + Total := @Total + NumMatches + end + {System.showInfo "Total: "#@Total#" examples."} + end + + fun {TaskUrl Task} + "http://rosettacode.org/mw/index.php?"# + "title="#{PercentEncode {StringX.replace Task " " "_"}}# + "&action=raw" + end + + %% GetPage + local + Client = {New HTTPClient.urlGET init(inPrms(toFile:false toStrm:true) _)} + in + fun {GetPage RawUrl} + Url = {VirtualString.toString RawUrl} + OutParams + HttpResponseParams + in + {Client getService(Url ?OutParams ?HttpResponseParams)} + OutParams.sOut + end + end + + %% Parse + local + Parser = {New XMLParser.parser init} + in + fun {Parse Xs} {Parser parseVS(Xs $)} end + end + + fun {GetTitles Doc} + CMs = Doc.2.1.children.1.children.1.children + fun {Attributes element(attributes:As ...)} As end + fun {IsTitle attribute(name:N ...)} N == title end + in + {Map {Filter {Flatten {Map CMs Attributes}} IsTitle} + fun {$ A} {Atom.toString A.value} end} + end + + fun {PercentEncode Xs} + case Xs of nil then nil + [] X|Xr then + if {Char.isDigit X} orelse {Member X [&- &_ &. &~]} + orelse X >= &a andthen X =< &z + orelse X >= &z andthen X =< &Z then + X|{PercentEncode Xr} + else + {Append &%|{ToHex2 X} {PercentEncode Xr}} + end + end + end + + fun {ToHex2 X} + [{ToHex1 X div 16} {ToHex1 X mod 16}] + end + + fun {ToHex1 X} + if X >= 0 andthen X =< 9 then &0 + X + elseif X >= 10 andthen X =< 15 then &A + X - 10 + end + end +in + {Main} diff --git a/Task/Rosetta-Code-Count-examples/Perl/rosetta-code-count-examples-1.pl b/Task/Rosetta-Code-Count-examples/Perl/rosetta-code-count-examples-1.pl new file mode 100644 index 0000000000..e204f2a787 --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/Perl/rosetta-code-count-examples-1.pl @@ -0,0 +1,10 @@ +use LWP::Simple; + +my $site = "http://rosettacode.org"; +my $list_url = "/mw/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=500&format=xml"; + +for (get("$site$list_url") =~ /cm.*?title="(.*?)"/g) { + (my $slug = $_) =~ tr/ /_/; + my $count = () = get("$site/wiki/$slug") =~ /toclevel-1/g; + print "$_: $count examples\n"; +} diff --git a/Task/Rosetta-Code-Count-examples/Perl/rosetta-code-count-examples-2.pl b/Task/Rosetta-Code-Count-examples/Perl/rosetta-code-count-examples-2.pl new file mode 100644 index 0000000000..e0b89bbbf7 --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/Perl/rosetta-code-count-examples-2.pl @@ -0,0 +1,12 @@ +use v5.10; +use Mojo::UserAgent; + +my $site = "http://rosettacode.org"; +my $list_url = "/mw/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=500&format=xml"; + +my $ua = Mojo::UserAgent->new; +$ua->get("$site$list_url")->res->dom->find('cm')->each(sub { + (my $slug = $_->{title}) =~ tr/ /_/; + my $count = $ua->get("$site/wiki/$slug")->res->dom->find("#toc .toclevel-1")->size; + say "$_->{title}: $count examples"; +}); diff --git a/Task/Rosetta-Code-Count-examples/PicoLisp/rosetta-code-count-examples.l b/Task/Rosetta-Code-Count-examples/PicoLisp/rosetta-code-count-examples.l new file mode 100644 index 0000000000..db55565d40 --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/PicoLisp/rosetta-code-count-examples.l @@ -0,0 +1,12 @@ +(load "@lib/http.l") + +(client "rosettacode.org" 80 + "mw/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=500&format=xml" + (while (from " title=\"") + (let Task (till "\"") + (client "rosettacode.org" 80 (pack "wiki/" (replace Task " " "_")) + (let Cnt 0 + (while (from "") + (unless (sub? "." (till "<" T)) + (inc 'Cnt) ) ) + (out NIL (prinl (ht:Pack Task) ": " Cnt)) ) ) ) ) ) diff --git a/Task/Rosetta-Code-Count-examples/PureBasic/rosetta-code-count-examples.purebasic b/Task/Rosetta-Code-Count-examples/PureBasic/rosetta-code-count-examples.purebasic new file mode 100644 index 0000000000..fbb34093c2 --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/PureBasic/rosetta-code-count-examples.purebasic @@ -0,0 +1,25 @@ +OpenConsole() +URLDownloadToFile_( #Null, "http://www.rosettacode.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=500&format=xml", "tasks.xml", 0, #Null) +ReadFile(0, "tasks.xml") + x1$ = ReadString(0) + Repeat + x2 = FindString(x1$, "title=", x2 + 1) + If x2 + title$ = Mid(x1$, x2 + 7, 99) + title$ = Left(title$, FindString(title$, ">", 1) - 4) + URLDownloadToFile_( #Null, "http://www.rosettacode.org/w/index.php?title=" + title$ + "&action=raw", "task.xml", 0, #Null) + ReadFile(1, "task.xml") + While Not Eof(1) + y1$ = ReadString(1) + If FindString(y1$, "=={{header|", 1) + j + 1 + EndIf + Wend + PrintN( title$ +": " + Str(j) + " examples") + k + j + j = 0 + CloseFile(1) + EndIf + Until x2 = 0 + PrintN("Total: " + Str(k) + " examples") + Input() diff --git a/Task/Rosetta-Code-Count-examples/Python/rosetta-code-count-examples.py b/Task/Rosetta-Code-Count-examples/Python/rosetta-code-count-examples.py new file mode 100644 index 0000000000..1c3bf5b90d --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/Python/rosetta-code-count-examples.py @@ -0,0 +1,12 @@ +import urllib, xml.dom.minidom + +x = urllib.urlopen("http://www.rosettacode.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=500&format=xml") + +tasks = [] +for i in xml.dom.minidom.parseString(x.read()).getElementsByTagName("cm"): + t = i.getAttribute('title').replace(" ", "_") + y = urllib.urlopen("http://www.rosettacode.org/w/index.php?title=%s&action=raw" % t.encode('utf-8')) + tasks.append( y.read().lower().count("{{header|") ) + print t.replace("_", " ") + ": %d examples." % tasks[-1] + +print "\nTotal: %d examples." % sum(tasks) diff --git a/Task/Rosetta-Code-Count-examples/R/rosetta-code-count-examples.r b/Task/Rosetta-Code-Count-examples/R/rosetta-code-count-examples.r new file mode 100644 index 0000000000..889be021d7 --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/R/rosetta-code-count-examples.r @@ -0,0 +1,14 @@ +library(XML) +library(RCurl) +doc <- xmlInternalTreeParse("http://www.rosettacode.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=500&format=xml") +nodes <- getNodeSet(doc,"//cm") +titles = as.character( sapply(nodes, xmlGetAttr, "title") ) +headers <- list() +counts <- list() +for (i in 1:length(titles)){ + headers[[i]] <- getURL( paste("http://rosettacode.org/mw/index.php?title=", gsub(" ", "_", titles[i]), "&action=raw", sep="") ) + counts[[i]] <- strsplit(headers[[i]],split=" ")[[1]] + counts[[i]] <- grep("\\{\\{header", counts[[i]]) + cat(titles[i], ":", length(counts[[i]]), "examples\n") +} +cat("Total: ", length(unlist(counts)), "examples\n") diff --git a/Task/Rosetta-Code-Count-examples/Ruby/rosetta-code-count-examples-1.rb b/Task/Rosetta-Code-Count-examples/Ruby/rosetta-code-count-examples-1.rb new file mode 100644 index 0000000000..0415f43225 --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/Ruby/rosetta-code-count-examples-1.rb @@ -0,0 +1,51 @@ +require 'open-uri' +require 'rexml/document' + +module RosettaCode + + URL_ROOT = "http://rosettacode.org/mw" + + def self.get_url(page, query) + begin + # Ruby 1.9.2 + pstr = URI.encode_www_form_component(page) + qstr = URI.encode_www_form(query) + rescue NoMethodError + require 'cgi' + pstr = CGI.escape(page) + qstr = query.map {|k,v| + "%s=%s" % [CGI.escape(k.to_s), CGI.escape(v.to_s)]}.join("&") + end + url = "#{URL_ROOT}/#{pstr}?#{qstr}" + p url if $DEBUG + url + end + + def self.get_api_url(query) + get_url "api.php", query + end + + def self.category_members(category) + query = { + "action" => "query", + "list" => "categorymembers", + "cmtitle" => "Category:#{category}", + "format" => "xml", + "cmlimit" => 500, + } + while true + url = get_api_url query + doc = REXML::Document.new open(url) + + REXML::XPath.each(doc, "//cm") do |task| + yield task.attribute("title").value + end + + continue = REXML::XPath.first(doc, "//query-continue") + break if continue.nil? + cm = REXML::XPath.first(continue, "categorymembers") + query["cmcontinue"] = cm.attribute("cmcontinue").value + end + end + +end diff --git a/Task/Rosetta-Code-Count-examples/Ruby/rosetta-code-count-examples-2.rb b/Task/Rosetta-Code-Count-examples/Ruby/rosetta-code-count-examples-2.rb new file mode 100644 index 0000000000..3a19cd34f8 --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/Ruby/rosetta-code-count-examples-2.rb @@ -0,0 +1,13 @@ +require 'rosettacode' + +total_examples = 0 + +RosettaCode.category_members("Programming_Tasks") do |task| + url = RosettaCode.get_url("index.php", {"action" => "raw", "title" => task}) + examples = open(url).read.scan("=={{header").length + puts "#{task}: #{examples}" + total_examples += examples +end + +puts +puts "Total: #{total_examples}" diff --git a/Task/Rosetta-Code-Count-examples/Run-BASIC/rosetta-code-count-examples.run b/Task/Rosetta-Code-Count-examples/Run-BASIC/rosetta-code-count-examples.run new file mode 100644 index 0000000000..98e7e076d8 --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/Run-BASIC/rosetta-code-count-examples.run @@ -0,0 +1,32 @@ +html "" + +a$ = httpGet$("http://rosettacode.org/wiki/Category:Programming_Tasks") +a$ = word$(a$,1,"
    NumTaskExamples
    ") +i = instr(a$,"
    0 + count = count + 1 + i = instr(a$,"",i+5) + a1$ = mid$(a$,i+15,j-i) + taskId$ = word$(a1$,1,"""") + task$ = word$(a1$,3,"""") + url$ = "http://rosettacode.org/wiki/";taskId$ + a2$ = httpGet$(url$) + ii = instr(a2$,"") + jj = 0 + while ii > 0 + jj = ii + ii = instr(a2$,"",ii+10) + wend + if jj = 0 then + examp = 0 + else + kk = instr(a2$,"<",jj+24) + examp = int(val(mid$(a2$,jj+24,kk-jj-24))) + end if + html "";count;"";task$;"";examp;"" + totExamp = totExamp + examp +wend +html "**** Total **";totExamp;"" +end diff --git a/Task/Rosetta-Code-Count-examples/Scala/rosetta-code-count-examples.scala b/Task/Rosetta-Code-Count-examples/Scala/rosetta-code-count-examples.scala new file mode 100644 index 0000000000..54e5ee53f6 --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/Scala/rosetta-code-count-examples.scala @@ -0,0 +1,14 @@ +import java.net.{URL, URLEncoder} +import scala.io.Source.fromURL + +val allTasksURL = "http://www.rosettacode.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=500&format=xml" +val allTasks = xml.parsing.XhtmlParser(fromURL(new URL(allTasksURL))) + +val regexExpr = "(?i)==\\{\\{header\\|".r +def oneTaskURL(title: String) = "http://www.rosettacode.org/w/index.php?title=%s&action=raw" format URLEncoder.encode(title.replace(' ', '_'), "UTF-8") +def count(title: String) = regexExpr findAllIn fromURL(new URL(oneTaskURL(title)))(io.Codec.UTF8).mkString length + +val counts = for (task <- allTasks \\ "cm" \\ "@title" map (_.text)) yield scala.actors.Futures.future((task, count(task))) + +counts map (_.apply) map Function.tupled("%s: %d examples." format (_, _)) foreach println +println("\nTotal: %d examples." format (counts map (_.apply._2) sum)) diff --git a/Task/Rosetta-Code-Count-examples/TUSCRIPT/rosetta-code-count-examples.tuscript b/Task/Rosetta-Code-Count-examples/TUSCRIPT/rosetta-code-count-examples.tuscript new file mode 100644 index 0000000000..be933b9baf --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/TUSCRIPT/rosetta-code-count-examples.tuscript @@ -0,0 +1,39 @@ +$$ MODE TUSCRIPT +url="http://www.rosettacode.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=500&format=xml" +data=REQUEST (url) + +BUILD S_TABLE beg=* +DATA :title=": +BUILD S_TABLE end=* +DATA :": + +titles=EXTRACT (data,beg|,end,1,0,"~~") +titles=SPLIT (titles,":~~:") +sz_titles=SIZE (titles) + +BUILD R_TABLE header=":==\{\{header|:" +all=* + +ERROR/STOP CREATE ("tasks",seq-e,-std-) + +COMPILE +LOOP title=titles +ask=* +ask =SET_VALUE(ask,"title",title) +ask =SET_VALUE(ask,"action","raw") +ask =ENCODE (ask,cgi) +http ="http://www.rosettacode.org/mw/index.php" +url =CONCAT (http,"?",ask) +data =REQUEST (url) +header =FILTER_INDEX (data,header,-) +sz_header=SIZE(header) +line =CONCAT (title,"=",sz_header," members") +FILE "tasks" = line +all =APPEND(all,sz_header) +ENDLOOP + +ENDCOMPILE +all =JOIN(all),sum=SUM(all),time=time() +line=CONCAT (time,": ", sz_titles, " Programing Tasks: ", sum, " solutions") + +FILE "tasks" = line diff --git a/Task/Rosetta-Code-Count-examples/Tcl/rosetta-code-count-examples.tcl b/Task/Rosetta-Code-Count-examples/Tcl/rosetta-code-count-examples.tcl new file mode 100644 index 0000000000..ab23c47ebf --- /dev/null +++ b/Task/Rosetta-Code-Count-examples/Tcl/rosetta-code-count-examples.tcl @@ -0,0 +1,65 @@ +package require Tcl 8.5 +package require http +package require json + +fconfigure stdout -buffering none + +proc get_tasks {category} { + set start [clock milliseconds] + puts -nonewline "getting $category members..." + set base_url http://www.rosettacode.org/w/api.php + set query {action query list categorymembers cmtitle Category:%s format json cmlimit 500} + set this_query [dict create {*}[split [format $query $category]]] + set tasks [list] + + while {1} { + set url [join [list $base_url [http::formatQuery {*}$this_query]] ?] + set response [http::geturl $url] + if {[set s [http::status $response]] ne "ok" || [http::ncode $response] != 200} { + error "Oops: url=$url\nstatus=$s\nhttp code=[http::code $response]" + } + set data [json::json2dict [http::data $response]] + http::cleanup $response + + # add tasks to list + foreach task [dict get $data query categorymembers] { + lappend tasks [dict get [dict create {*}$task] title] + } + + if {[catch {dict get $data query-continue categorymembers cmcontinue} continue_task] != 0} { + # no more continuations, we're done + break + } + dict set this_query cmcontinue $continue_task + } + puts " found [llength $tasks] tasks in [expr {[clock milliseconds] - $start}] milliseconds" + return $tasks +} + +# This proc can be replaced by a single regexp command: +# set count [regexp -all "***=$needle" $haystack] +# However this proc is more efficient -- we're dealing with plain strings only. +proc count_substrings {needle haystack} { + set count 0 + set idx 0 + while {[set idx [string first $needle $haystack $idx]] != -1} { + incr count + incr idx + } + return $count +} + +set total 0 +foreach task [get_tasks Programming_Tasks] { + set url [format "http://www.rosettacode.org/w/index.php?title=%s&action=raw" [string map {{ } _} $task]] + set response [http::geturl $url] + if {[set s [http::status $response]] ne "ok" || [http::ncode $response] != 200} { + error "Oops: url=$url\nstatus=$s\nhttp code=[http::code $response]" + } + set count [count_substrings "\{\{header|" [http::data $response]] + puts [format "%3d examples in %s" $count $task] + http::cleanup $response + incr total $count +} + +puts "\nTotal: $total examples" diff --git a/Task/Rosetta-Code-Find-unimplemented-tasks/0DESCRIPTION b/Task/Rosetta-Code-Find-unimplemented-tasks/0DESCRIPTION new file mode 100644 index 0000000000..76b95f1351 --- /dev/null +++ b/Task/Rosetta-Code-Find-unimplemented-tasks/0DESCRIPTION @@ -0,0 +1,5 @@ +Given the name of a language on Rosetta Code, find all tasks which are not implemented in that language. + +Note: Implementations should allow for fetching more data than can be returned in one request to Rosetta Code. + +You'll need to use the Media Wiki API, which you can find out about locally, [http://rosettacode.org/mw/api.php here], or in Media Wiki's API documentation at, [http://www.mediawiki.org/wiki/API_Query API:Query] diff --git a/Task/Rosetta-Code-Find-unimplemented-tasks/1META.yaml b/Task/Rosetta-Code-Find-unimplemented-tasks/1META.yaml new file mode 100644 index 0000000000..b392469fa2 --- /dev/null +++ b/Task/Rosetta-Code-Find-unimplemented-tasks/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Rosetta Code related diff --git a/Task/Rosetta-Code-Find-unimplemented-tasks/Ada/rosetta-code-find-unimplemented-tasks.ada b/Task/Rosetta-Code-Find-unimplemented-tasks/Ada/rosetta-code-find-unimplemented-tasks.ada new file mode 100644 index 0000000000..402884b167 --- /dev/null +++ b/Task/Rosetta-Code-Find-unimplemented-tasks/Ada/rosetta-code-find-unimplemented-tasks.ada @@ -0,0 +1,123 @@ +with Aws.Client, Aws.Messages, Aws.Response, Aws.Resources, Aws.Url; +with Dom.Readers, Dom.Core, Dom.Core.Documents, Dom.Core.Nodes, Dom.Core.Attrs; +with Input_Sources.Strings, Unicode, Unicode.Ces.Utf8; +with Ada.Strings.Unbounded, Ada.Text_IO, Ada.Command_Line; +with Ada.Containers.Vectors; + +use Aws.Client, Aws.Messages, Aws.Response, Aws.Resources, Aws.Url; +use Dom.Readers, Dom.Core, Dom.Core.Documents, Dom.Core.Nodes, Dom.Core.Attrs; +use Aws, Ada.Strings.Unbounded, Input_Sources.Strings; +use Ada.Text_IO, Ada.Command_Line; + +procedure Not_Coded is + + package Members_Vectors is new Ada.Containers.Vectors ( + Index_Type => Positive, + Element_Type => Unbounded_String); + use Members_Vectors; + + All_Tasks, Language_Members : Vector; + + procedure Get_Vector (Category : in String; Mbr_Vector : in out Vector) is + Reader : Tree_Reader; + Doc : Document; + List : Node_List; + N : Node; + A : Attr; + Page : Aws.Response.Data; + S : Messages.Status_Code; + + -- Query has cmlimit value of 100, so we need 5 calls to + -- retrieve the complete list of Programming_category + Uri_Xml : constant String := + "http://rosettacode.org/mw/api.php?action=query&list=categorymembers" + & + "&format=xml&cmlimit=100&cmtitle=Category:"; + Cmcontinue : Unbounded_String := Null_Unbounded_String; + begin + loop + Page := + Aws.Client.Get (Uri_Xml & Category & (To_String (Cmcontinue))); + S := Response.Status_Code (Page); + if S not in Messages.Success then + Put_Line + ("Unable to retrieve data => Status Code :" & + Image (S) & + " Reason :" & + Reason_Phrase (S)); + raise Connection_Error; + end if; + declare + Xml : constant String := Message_Body (Page); + Source : String_Input; + begin + Open + (Xml'Unrestricted_Access, + Unicode.Ces.Utf8.Utf8_Encoding, + Source); + Parse (Reader, Source); + Close (Source); + end; + Doc := Get_Tree (Reader); + List := Get_Elements_By_Tag_Name (Doc, "cm"); + for Index in 1 .. Length (List) loop + N := Item (List, Index - 1); + A := Get_Named_Item (Attributes (N), "title"); + Members_Vectors.Append + (Mbr_Vector, + To_Unbounded_String (Value (A))); + end loop; + Free (List); + List := Get_Elements_By_Tag_Name (Doc, "query-continue"); + if Length (List) = 0 then + -- we are done + Free (List); + Free (Reader); + exit; + end if; + N := First_Child (Item (List, 0)); + A := Get_Named_Item (Attributes (N), "cmcontinue"); + Cmcontinue := + To_Unbounded_String + ("&cmcontinue=" & Aws.Url.Encode (Value (A))); + Free (List); + Free (Reader); + end loop; + end Get_Vector; + + procedure Quick_Diff (From : in out Vector; Substract : in Vector) is + Beginning, Position : Extended_Index; + begin + -- take adavantage that both lists are already sorted + Beginning := First_Index (From); + for I in First_Index (Substract) .. Last_Index (Substract) loop + Position := + Find_Index + (Container => From, + Item => Members_Vectors.Element (Substract, I), + Index => Beginning); + if not (Position = No_Index) then + Delete (From, Position); + Beginning := Position; + end if; + end loop; + end Quick_Diff; + +begin + if Argument_Count = 0 then + Put_Line ("Can't process : No language given!"); + return; + else + Get_Vector (Argument (1), Language_Members); + end if; + + Get_Vector ("Programming_Tasks", All_Tasks); + Quick_Diff (All_Tasks, Language_Members); + + for I in First_Index (All_Tasks) .. Last_Index (All_Tasks) loop + Put_Line (To_String (Members_Vectors.Element (All_Tasks, I))); + end loop; + Put_Line + ("Numbers of tasks not implemented :=" & + Integer'Image (Last_Index ((All_Tasks)))); +end Not_Coded; diff --git a/Task/Rosetta-Code-Find-unimplemented-tasks/AutoHotkey/rosetta-code-find-unimplemented-tasks.ahk b/Task/Rosetta-Code-Find-unimplemented-tasks/AutoHotkey/rosetta-code-find-unimplemented-tasks.ahk new file mode 100644 index 0000000000..97bd6c3de4 --- /dev/null +++ b/Task/Rosetta-Code-Find-unimplemented-tasks/AutoHotkey/rosetta-code-find-unimplemented-tasks.ahk @@ -0,0 +1,184 @@ +#NoEnv ; do not resolve environment variables (speed) +#SingleInstance force ; allow only one instance +SetBatchLines, -1 ; set to highest script speed +SetControlDelay, 0 ; set delay between control commands to lowest + +; additional label, for clarity only +AutoExec: + Gui, Add, DDL, x10 y10 w270 r20 vlngStr ; add drop-down list + Gui, Add, Button, x290 y10 gShowLng, Show Unimplemented ; add button + Gui, Add, ListView, x10 y36 w400 h300 vcatLst gOnLV, Unimplemented ; add listview + Gui, Add, StatusBar, vsbStr, ; add statusbar + Gui, Show, , RosettaCode unimplemented list ; show the gui + allLng := getList("lng") ; get a list of all available languages + selectStr = Select language... ; set selection string for ddl + GuiControl, , LngStr, |%selectStr%||%allLng% ; set the ddl to new contents + SB_SetIcon("user32.dll", 5) ; change statusbar icon + SB_SetText("Done loading languages. Select from menu.") ; change statusbar text +Return ; end of the autoexec section. Script waits for input. + +; subroutine for language list in ddl update +ShowLng: + Gui, Submit, NoHide ; refresh all gui variables + If (lngStr != selectStr) ; if the current selected language is not the selection string + { + SB_SetIcon("user32.dll", 2) ; set statusbar icon to exclamation + SB_SetText("Loading unimplemented tasks... Please wait.") ; set statusbar text + allTsk := getList("tsk") ; get a list of all tasks + allThis := getList(lngStr) ; get a list of all done tasks for this language + Loop, Parse, allTsk, | ; parse the list of all tasks + { + If !InStr(allThis,A_LoopField) ; if the current task is not found in the list of all tasks + notImpl .= A_LoopField . "|" ; add the current field to the notImpl variable + allTskCnt := A_Index ; save the index for final count + } + StringTrimRight, notImpl, notImpl, 1 ; remove last delimiter + LV_Delete() ; emty the listview + GuiControl, -Redraw, catLst ; set the listview to not redraw while adding (speed) + Loop, Parse, notImpl, | ; parse the list of not implemented tasks + { + LV_Add("", A_LoopField) ; add them to the listview, field by field + notImplCnt := A_Index ; save the index for final count + } + GuiControl, +Redraw, catLst ; set the listview back to normal + SB_SetIcon("user32.dll", 5) ; change statusbar icon to information + SB_SetText("There are " . notImplCnt . " of " . allTskCnt + . " tasks unimplemented. Double-click task to open in browser.") ; set the statusbar text + notImpl = ; empty the notImpl variable + notImplCnt = 0 ; set the count back to 0 + } +Return + +; subroutine for action on listview +OnLV: + If (A_GuiEvent = "DoubleClick") ; if the listview was double-clicked + { + LV_GetText(rowTxt, A_EventInfo) ; get the text of the clicked row + rowTxt := Enc_Uri(rowTxt) ; uri-encode the text + StringReplace, rowTxt, rowTxt, `%20, _, All ; replace all space-encodings with underscores + Run % "http://rosettacode.org/wiki/" . rowTxt ; run the resulting link in the default browser + } +Return + +; generic function to gather list +getList(category) +{ + fileName = temp.xml ; set temp-file name + If (category = "lng") ; if the category received is lng + { + category = Programming_Languages ; set the category + fileName = lng.xml ; set temp-file name + IfExist, %fileName% ; if the file already exists + { + FileGetTime, modTime, %fileName% ; get the last modified time + EnvSub, modTime, %A_Now%, days ; get the difference between now and last modified time in days + If (modTime < 3) ; if the result is less than 3 + Goto, GetFileNoDL ; go to function-internal subroutine to parse + } + SB_SetIcon("user32.dll", 2) ; set statusbar icon + SB_SetText("Loading languages... Please wait.") ; set statusbar text + } + If (category = "tsk") ; if the category received is tsk + category = Programming_Tasks ; set the category + + getFile: ; function-internal subroutine for getting a file and parsing it + ; construct the url + url := "http://www.rosettacode.org/w/api.php?action=query&list=" + . "categorymembers&cmtitle=Category:" . category + . "&cmlimit=500&format=xml" . doContinue + UrlDownloadToFile, %url%, %fileName% ; download the url + + getFileNoDL: ; function-internal subroutine for parsing a file + FileRead, data, %fileName% ; read file into variable + pos = 1 ; set while-loop counter + rxp = title="(.*?)" ; set regular expression + While (pos := RegExMatch(data, rxp, title, pos)) ; get the contents of the title fields one-by-one + { + If InStr(title1, "Category:") ; if the contents contain Category: + StringTrimLeft, title1, title1, 9 ; remove that from the contents + StringReplace, title1, title1, |, `|, All ; escape all containing delimiters + title1 := Dec_XML(UTF82Ansi(title1)) ; convert to ansi first and then decode html entities + allTitles .= title1 . "|" ; add this title to list + pos++ ; increment counter + } + rxp = cmcontinue="(.*?)" ; set regular expression + If RegExMatch(data, rxp, next) ; when found + { + doContinue = &cmcontinue=%next1% ; set continuation string to add to url + Goto getFile ; go to function-internal subroutine to redownload and parse + } + StringTrimRight, allTitles, allTitles, 1 ; remove last delimiter from result + Return allTitles ; return result +} + +; function to convert html entities to ansi equivalents +Dec_XML(str) +{ + Loop + If RegexMatch(str, "S)(&#(\d+);)", dec) + StringReplace, str, str, %dec1%, % Chr(dec2), All + Else If RegexMatch(str, "Si)(&#x([\da-f]+);)", hex) + StringReplace, str, str, %hex1%, % Chr("0x" . hex2), All + Else + Break + StringReplace, str, str,  , %A_Space%, All + StringReplace, str, str, ", ", All + StringReplace, str, str, ', ', All + StringReplace, str, str, <, <, All + StringReplace, str, str, >, >, All + StringReplace, str, str, &, &, All + return, str +} + +; function to uri-encode input string +Enc_Uri(str) +{ + f = %A_FormatInteger% + SetFormat, Integer, Hex + If RegExMatch(str, "^\w+:/{0,2}", pr) + StringTrimLeft, str, str, StrLen(pr) + StringReplace, str, str, `%, `%25, All + Loop + If RegExMatch(str, "i)[^\w\.~%/:]", char) + StringReplace, str, str, %char%, % "%" . SubStr(Asc(char),3), All + Else Break + SetFormat, Integer, %f% + Return, pr . str +} + +; function to convert unicode to ansi text +UTF82Ansi(zString) +{ + Ansi2Unicode(zString, wString, 65001) + Unicode2Ansi(wString, sString, 0) + Return sString +} + +; helper function for unicode to ansi function +Ansi2Unicode(ByRef sString, ByRef wString, CP = 0) +{ + nSize := DllCall("MultiByteToWideChar", "Uint", CP + , "Uint", 0, "Uint", &sString, "int", -1 + , "Uint", 0, "int", 0) + VarSetCapacity(wString, nSize * 2) + DllCall("MultiByteToWideChar" + , "Uint", CP, "Uint", 0, "Uint", &sString, "int", -1 + , "Uint", &wString, "int", nSize) +} + +; helper function for unicode to ansi function +Unicode2Ansi(ByRef wString, ByRef sString, CP = 0) +{ + nSize := DllCall("WideCharToMultiByte" + , "Uint", CP, "Uint", 0, "Uint", &wString, "int", -1 + , "Uint", 0, "int", 0, "Uint", 0, "Uint", 0) + VarSetCapacity(sString, nSize) + DllCall("WideCharToMultiByte" + , "Uint", CP, "Uint", 0, "Uint", &wString, "int", -1 + , "str", sString, "int", nSize, "Uint", 0, "Uint", 0) +} + +; subroutine called when user closes the gui +GuiClose: + ExitApp ; exit the script +Return diff --git a/Task/Rosetta-Code-Find-unimplemented-tasks/Go/rosetta-code-find-unimplemented-tasks.go b/Task/Rosetta-Code-Find-unimplemented-tasks/Go/rosetta-code-find-unimplemented-tasks.go new file mode 100644 index 0000000000..9740a04683 --- /dev/null +++ b/Task/Rosetta-Code-Find-unimplemented-tasks/Go/rosetta-code-find-unimplemented-tasks.go @@ -0,0 +1,74 @@ +package main + +import ( + "encoding/xml" + "fmt" + "io" + "net/http" + "net/url" +) + +const language = "Go" + +var baseQuery = "http://rosettacode.org/mw/api.php?action=query" + + "&format=xml&list=categorymembers&cmlimit=100" + +func req(u string, foundCm func(string)) string { + resp, err := http.Get(u) + if err != nil { + fmt.Println(err) // connection or request fail + return "" + } + defer resp.Body.Close() + for p := xml.NewDecoder(resp.Body); ; { + t, err := p.RawToken() + switch s, ok := t.(xml.StartElement); { + case err == io.EOF: + return "" + case err != nil: + fmt.Println(err) + return "" + case !ok: + continue + case s.Name.Local == "cm": + for _, a := range s.Attr { + if a.Name.Local == "title" { + foundCm(a.Value) + } + } + case s.Name.Local == "categorymembers" && len(s.Attr) > 0 && + s.Attr[0].Name.Local == "cmcontinue": + return url.QueryEscape(s.Attr[0].Value) + } + } + return "" +} + +func main() { + // get language members, store in a map + langMap := make(map[string]bool) + storeLang := func(cm string) { langMap[cm] = true } + languageQuery := baseQuery + "&cmtitle=Category:" + language + continueAt := req(languageQuery, storeLang) + for continueAt > "" { + continueAt = req(languageQuery+"&cmcontinue="+continueAt, storeLang) + } + + // a quick check to avoid long output + if len(langMap) == 0 { + fmt.Println("no tasks implemented for", language) + return + } + + // get tasks, print as we go along + printUnImp := func(cm string) { + if !langMap[cm] { + fmt.Println(cm) + } + } + taskQuery := baseQuery + "&cmtitle=Category:Programming_Tasks" + continueAt = req(taskQuery, printUnImp) + for continueAt > "" { + continueAt = req(taskQuery+"&cmcontinue="+continueAt, printUnImp) + } +} diff --git a/Task/Rosetta-Code-Find-unimplemented-tasks/Haskell/rosetta-code-find-unimplemented-tasks.hs b/Task/Rosetta-Code-Find-unimplemented-tasks/Haskell/rosetta-code-find-unimplemented-tasks.hs new file mode 100644 index 0000000000..83c6b67b20 --- /dev/null +++ b/Task/Rosetta-Code-Find-unimplemented-tasks/Haskell/rosetta-code-find-unimplemented-tasks.hs @@ -0,0 +1,27 @@ +import Network.Browser +import Network.HTTP +import Network.URI +import Data.List +import Data.Maybe +import Text.XML.Light +import Control.Arrow +import Data.Char + +getRespons url = do + rsp <- Network.Browser.browse $ do + setAllowRedirects True + setOutHandler $ const (return ()) -- quiet + request $ getRequest url + return $ rspBody $ snd rsp + +replaceWithSpace c = (\x -> if c==x then ' ' else x) + +encl = chr 34 + +unimpTasks lang = do + allTasks <- getRespons "http://www.rosettacode.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=500&format=xml" + impl <- getRespons ( "http://rosettacode.org/json/isb/" ++ lang ++ ".json") + let langxx = map (map(replaceWithSpace '_')) $ filter (/=",") $ words $ map (replaceWithSpace encl ) $ init $ drop 1 impl + xml = onlyElems $ parseXML allTasks + allxx = concatMap (map (fromJust.findAttr (unqual "title")). filterElementsName (== unqual "cm")) xml + mapM_ putStrLn $ sort $ allxx \\ langxx diff --git a/Task/Rosetta-Code-Find-unimplemented-tasks/J/rosetta-code-find-unimplemented-tasks-1.j b/Task/Rosetta-Code-Find-unimplemented-tasks/J/rosetta-code-find-unimplemented-tasks-1.j new file mode 100644 index 0000000000..ed568389c8 --- /dev/null +++ b/Task/Rosetta-Code-Find-unimplemented-tasks/J/rosetta-code-find-unimplemented-tasks-1.j @@ -0,0 +1,25 @@ +require 'strings web/gethttp' + +findUnimpTasks=: ('Programming_Tasks' -.&getCategoryMembers ,&'/Omit') ([ #~ -.@e.) getCategoryMembers + +getTagContents=: dyad define + 'starttag endtag'=. x + ('\' -.~ endtag&taketo)&.>@(starttag&E. <@((#starttag)&}.);.1 ]) y +) + +NB. RosettaCode Utilities +parseTitles=: ('"title":"';'"')&getTagContents +parseCMcontinue=:('"cmcontinue":"';'"')&getTagContents +getCMcontquery=: ('&cmcontinue=' , urlencode)^:(0 < #)@>@parseCMcontinue + +getCategoryMembers=: monad define + buildqry=. 'action=query&list=categorymembers&cmtitle=Category:' , ,&'&cmlimit=500&format=json' + url=.'http://www.rosettacode.org/w/api.php' + uri=. url ,'?', buildqry urlencode y + catmbrs=. qrycont=. '' + whilst. #qrycont=. getCMcontquery jsondat do. + jsondat=. gethttp uri , qrycont + catmbrs=. catmbrs, parseTitles jsondat + end. + catmbrs +) diff --git a/Task/Rosetta-Code-Find-unimplemented-tasks/J/rosetta-code-find-unimplemented-tasks-2.j b/Task/Rosetta-Code-Find-unimplemented-tasks/J/rosetta-code-find-unimplemented-tasks-2.j new file mode 100644 index 0000000000..212cf5c5c7 --- /dev/null +++ b/Task/Rosetta-Code-Find-unimplemented-tasks/J/rosetta-code-find-unimplemented-tasks-2.j @@ -0,0 +1,4 @@ + 4{. findUnimpTasks 'J' NB. get first 4 unimplemented tasks for J ++-------------+--------------+----------------+------------------------------+ +|Active object|Atomic updates|Basic input loop|Call foreign language function| ++-------------+--------------+----------------+------------------------------+ diff --git a/Task/Rosetta-Code-Find-unimplemented-tasks/Oz/rosetta-code-find-unimplemented-tasks.oz b/Task/Rosetta-Code-Find-unimplemented-tasks/Oz/rosetta-code-find-unimplemented-tasks.oz new file mode 100644 index 0000000000..976efd5cbe --- /dev/null +++ b/Task/Rosetta-Code-Find-unimplemented-tasks/Oz/rosetta-code-find-unimplemented-tasks.oz @@ -0,0 +1,127 @@ +declare + [HTTPClient] = {Link ['x-ozlib://mesaros/net/HTTPClient.ozf']} + [XMLParser] = {Link ['x-oz://system/xml/Parser.ozf']} + + fun {FindUnimplementedTasks Language} + AllTasks = {FindCategory "Programming Tasks"} + LangTasks = {FindCategory Language} + in + {ListDiff AllTasks LangTasks} + end + + fun {FindCategory Cat} + CatUrl = "http://www.rosettacode.org/mw/api.php?action=query" + #"&list=categorymembers" + #"&cmtitle=Category:"#{PercentEncode Cat} + #"&cmlimit=500&format=xml" + + fun {Loop CMContinue} + [_ Doc] = {Parse {GetPage CatUrl#CMContinue}} + Titles = {XPath Doc + [api query categorymembers cm {Attribute title}]} + in + case {XPath Doc + [api 'query-continue' categorymembers {Attribute cmcontinue}]} + of nil then Titles + [] [NewCMContinueAtom] then + NewCMContinue = {PercentEncode {Atom.toString NewCMContinueAtom}} + in + {Append Titles + {Loop "&cmcontinue="#NewCMContinue}} + end + end + in + {Loop nil} + end + + + %% XPath emulation + fun {XPath Doc Path} + P|Pr = Path + in + Doc.name = P %% assert + {FoldL Pr XPathStep [Doc]} + end + + Nothing = {NewName} + fun {NotNothing X} X \= Nothing end + + fun {XPathStep Elements P} + if {Atom.is P} then + {FilteredChildren Elements P} + elseif {Procedure.is P} then + {Filter {Map Elements P} NotNothing} + end + end + + %% A flat list of all Type-children of all Elements. + fun {FilteredChildren Elements Type} + {Flatten + {Map Elements + fun {$ E} + {Filter E.children + fun {$ X} + case X of element(name:!Type ...) then true + else false + end + end} + end}} + end + + fun {Attribute Attr} + fun {$ Element} + case {Filter Element.attributes fun {$ A} A.name == Attr end} + of [A] then A.value + else Nothing + end + end + end + + + %% GetPage + Client = {New HTTPClient.urlGET init(inPrms(toFile:false toStrm:true) _)} + fun {GetPage RawUrl} + Url = {VirtualString.toString RawUrl} + OutParams + in + {Client getService(Url ?OutParams ?_)} + OutParams.sOut + end + + fun {PercentEncode Xs} + case Xs of nil then nil + [] X|Xr then + if {Char.isDigit X} orelse {Member X [&- &_ &. &~]} + orelse X >= &a andthen X =< &z + orelse X >= &z andthen X =< &Z then + X|{PercentEncode Xr} + else + {Append &%|{ToHex2 X} {PercentEncode Xr}} + end + end + end + + fun {ToHex2 X} + [{ToHex1 X div 16} {ToHex1 X mod 16}] + end + + fun {ToHex1 X} + if X >= 0 andthen X =< 9 then &0 + X + elseif X >= 10 andthen X =< 15 then &A + X - 10 + end + end + + + %% Parse + local + Parser = {New XMLParser.parser init} + in + fun {Parse Xs} {Parser parseVS(Xs $)} end + end + + fun {ListDiff Xs Ys} + {FoldL Ys List.subtract Xs} + end +in + %% show tasks not implemented in Oz + {ForAll {FindUnimplementedTasks "Oz"} System.showInfo} diff --git a/Task/Rosetta-Code-Find-unimplemented-tasks/Perl/rosetta-code-find-unimplemented-tasks.pl b/Task/Rosetta-Code-Find-unimplemented-tasks/Perl/rosetta-code-find-unimplemented-tasks.pl new file mode 100644 index 0000000000..8ae140bd22 --- /dev/null +++ b/Task/Rosetta-Code-Find-unimplemented-tasks/Perl/rosetta-code-find-unimplemented-tasks.pl @@ -0,0 +1,24 @@ +use LWP::Simple 'get'; + +my $fmt = 'http://www.rosettacode.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:%s&cmlimit=500&format=json'; +my $lang = shift + or die "No language given.\n"; + +sub urlencode + {join '', map {sprintf '%%%02x', ord} split //, shift} +sub tasks + {my $category = urlencode shift; + my @tasks; + my $json = get sprintf $fmt, $category; + for (;;) + {push @tasks, $json =~ /"title":"(.+?)"}/g; + $json =~ /"cmcontinue":"(.+?)"}/ or last; + $json = get sprintf $fmt . '&cmcontinue=%s', + $category, urlencode $1;} + return @tasks;} + +my @all = tasks 'Programming_Tasks'; +my %lang = map {$_, 1} tasks $lang + or die "No such category.\n"; +$lang{$_} or print "$_\n" + foreach @all; diff --git a/Task/Rosetta-Code-Find-unimplemented-tasks/PicoLisp/rosetta-code-find-unimplemented-tasks-1.l b/Task/Rosetta-Code-Find-unimplemented-tasks/PicoLisp/rosetta-code-find-unimplemented-tasks-1.l new file mode 100644 index 0000000000..979737798a --- /dev/null +++ b/Task/Rosetta-Code-Find-unimplemented-tasks/PicoLisp/rosetta-code-find-unimplemented-tasks-1.l @@ -0,0 +1,24 @@ +(load "@lib/http.l" "@lib/xm.l") + +(de rosettaCategory (Cat) + (let (Cont NIL Xml) + (make + (loop + (client "rosettacode.org" 80 + (pack + "mw/api.php?action=query&list=categorymembers&cmtitle=Category:" + Cat + "&cmlimit=200&format=xml" + Cont ) + (while (line)) + (setq Xml (and (xml?) (xml))) ) + (NIL Xml) + (for M (body Xml 'query 'categorymembers) + (link (attr M 'title)) ) + (NIL (attr Xml 'query-continue' categorymembers 'cmcontinue)) + (setq Cont (pack "&cmcontinue=" @)) ) ) ) ) + +(de unimplemented (Task) + (diff + (rosettaCategory "Programming_Tasks") + (rosettaCategory Task) ) ) diff --git a/Task/Rosetta-Code-Find-unimplemented-tasks/PicoLisp/rosetta-code-find-unimplemented-tasks-2.l b/Task/Rosetta-Code-Find-unimplemented-tasks/PicoLisp/rosetta-code-find-unimplemented-tasks-2.l new file mode 100644 index 0000000000..54710cf6fa --- /dev/null +++ b/Task/Rosetta-Code-Find-unimplemented-tasks/PicoLisp/rosetta-code-find-unimplemented-tasks-2.l @@ -0,0 +1,26 @@ +import xml.dom.minidom +import urllib, sys + +def findrc(category): + name = "http://www.rosettacode.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:%s&cmlimit=500&format=xml" % urllib.quote(category) + cmcontinue, titles = '', [] + while True: + u = urllib.urlopen(name + cmcontinue) + xmldata = u.read() + u.close() + x = xml.dom.minidom.parseString(xmldata) + titles += [i.getAttribute("title") for i in x.getElementsByTagName("cm")] + cmcontinue = filter( None, + (urllib.quote(i.getAttribute("cmcontinue")) + for i in x.getElementsByTagName("categorymembers")) ) + if cmcontinue: + cmcontinue = '&cmcontinue=' + cmcontinue[0] + else: + break + return titles + +alltasks = findrc("Programming_Tasks") +lang = findrc(sys.argv[1]) + +for i in [i for i in alltasks if i not in lang]: + print i diff --git a/Task/Rosetta-Code-Find-unimplemented-tasks/R/rosetta-code-find-unimplemented-tasks.r b/Task/Rosetta-Code-Find-unimplemented-tasks/R/rosetta-code-find-unimplemented-tasks.r new file mode 100644 index 0000000000..4ae8289f15 --- /dev/null +++ b/Task/Rosetta-Code-Find-unimplemented-tasks/R/rosetta-code-find-unimplemented-tasks.r @@ -0,0 +1,16 @@ +library(XML) +find.unimplemented.tasks <- function(lang="R"){ + PT <- xmlInternalTreeParse( paste("http://www.rosettacode.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks&cmlimit=500&format=xml",sep="") ) + PT.nodes <- getNodeSet(PT,"//cm") + PT.titles = as.character( sapply(PT.nodes, xmlGetAttr, "title") ) + language <- xmlInternalTreeParse( paste("http://www.rosettacode.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:", + lang, "&cmlimit=500&format=xml",sep="") ) + lang.nodes <- getNodeSet(language,"//cm") + lang.titles = as.character( sapply(lang.nodes, xmlGetAttr, "title") ) + unimplemented <- setdiff(PT.titles, lang.titles) + unimplemented +} +# Usage +find.unimplemented.tasks(lang="Python") +langs <- c("R","python","perl") +sapply(langs, find.unimplemented.tasks) # fetching data for multiple languages diff --git a/Task/Rosetta-Code-Find-unimplemented-tasks/Ruby/rosetta-code-find-unimplemented-tasks.rb b/Task/Rosetta-Code-Find-unimplemented-tasks/Ruby/rosetta-code-find-unimplemented-tasks.rb new file mode 100644 index 0000000000..373909a2f0 --- /dev/null +++ b/Task/Rosetta-Code-Find-unimplemented-tasks/Ruby/rosetta-code-find-unimplemented-tasks.rb @@ -0,0 +1,46 @@ +require 'rosettacode' +require 'time' + +module RosettaCode + def self.get_unimplemented(lang) + programming_tasks = [] + category_members("Programming_Tasks") {|task| programming_tasks << task} + + lang_tasks = [] + category_members(lang) {|task| lang_tasks << task} + + lang_tasks_omit = [] + category_members("#{lang}/Omit") {|task| lang_tasks_omit << task} + + [programming_tasks - lang_tasks, lang_tasks_omit] + end + + def self.created_time(title) + url = get_api_url({ + "action" => "query", + "titles" => title, + "format" => "xml", + "rvlimit" => 500, + "prop" => "revisions", + "rvprop" => "timestamp" + }) + doc = REXML::Document.new open(url) + REXML::XPath.each(doc, "//rev").collect do |node| + Time.parse( node.attribute("timestamp").value ) + end.min + end + +end + +puts Time.now +lang = ARGV[0] || "Ruby" +unimplemented, omitted = RosettaCode.get_unimplemented(lang) +unimplemented.collect {|title| [title, RosettaCode.created_time(title)]} . + sort_by {|e| e[1]} . + each do |title, date| + puts "%s %6s %s" % [ + date.strftime("%Y-%m-%d"), + omitted.include?(title) ? "[omit]" : "" , + title + ] + end diff --git a/Task/Rosetta-Code-Find-unimplemented-tasks/Run-BASIC/rosetta-code-find-unimplemented-tasks.run b/Task/Rosetta-Code-Find-unimplemented-tasks/Run-BASIC/rosetta-code-find-unimplemented-tasks.run new file mode 100644 index 0000000000..0e5311174c --- /dev/null +++ b/Task/Rosetta-Code-Find-unimplemented-tasks/Run-BASIC/rosetta-code-find-unimplemented-tasks.run @@ -0,0 +1,43 @@ +WordWrap$ = "style='white-space: pre-wrap;white-space: -moz-pre-wrap;white-space: -pre-wrap;white-space: -o-pre-wrap;word-wrap: break-word'" +a$ = httpGet$("http://rosettacode.org/wiki/Category:Programming_Languages") +a$ = word$(a$,2,"mw-subcategories") +a$ = word$(a$,1,"") +i = instr(a$,"/wiki/Category:") +html " Select language from list
    " +html "" +html "

    Number of Languages:";count;"
    " +button #go,"GO", [go] +html " " +button #ex, "Exit", [exit] +wait + +[go] +cls +lang$ = #request get$("lang") +h$ = "http://rosettacode.org/wiki/Reports:Tasks_not_implemented_in_";lang$ +a$ = httpGet$(h$) +a$ = word$(a$,3,"mw-content-ltr") +html "" +i = instr(a$," 0 + i = instr(a$,"title=""",i) + j = instr(a$,""">",i+7) + if c mod 4 = 0 then html "" + c = c + 1 + html "" + i = instr(a$,"
    ";mid$(a$,i+7,j-(i+7));"
    " +print "Total unImplemented Tasks:";c +[exit] +end diff --git a/Task/Rosetta-Code-Find-unimplemented-tasks/Tcl/rosetta-code-find-unimplemented-tasks.tcl b/Task/Rosetta-Code-Find-unimplemented-tasks/Tcl/rosetta-code-find-unimplemented-tasks.tcl new file mode 100644 index 0000000000..1a0c6cfe3c --- /dev/null +++ b/Task/Rosetta-Code-Find-unimplemented-tasks/Tcl/rosetta-code-find-unimplemented-tasks.tcl @@ -0,0 +1,97 @@ +package require Tcl 8.5 +package require http +package require json +package require struct::set + +fconfigure stdout -buffering none + +# Initialize a cache of lookups +array set cache {} +proc log msg { + #puts -nonewline $msg +} + +proc get_tasks {category} { + global cache + if {[info exists cache($category)]} { + return $cache($category) + } + set base_url http://www.rosettacode.org/w/api.php + set query { + action query + list categorymembers + cmtitle Category:%s + format json + cmlimit 500 + } + set query [list {*}$query]; # remove excess whitespace + set this_query [dict create {*}[split [format $query $category]]] + set tasks [list] + + while {1} { + set url [join [list $base_url [http::formatQuery {*}$this_query]] ?] + while 1 { + set response [http::geturl $url] + # Process redirects + if {[http::ncode $response] == 301} { + set newurl [dict get [http::meta $response] Location] + if {[string match http://* $newurl]} { + set url $newurl + } else { + set url [regexp -inline {http://[^/]+} $url] + append url $newurl + } + continue + } + # Check for oopsies! + if { + [set s [http::status $response]] ne "ok" + || [http::ncode $response] != 200 + } then { + error "Oops: url=$url\nstatus=$s\nhttp code=[http::code $response]" + } + break + } + + # Get the data out of the message + set data [json::json2dict [http::data $response]] + http::cleanup $response + + # add tasks to list + foreach task [dict get $data query categorymembers] { + lappend tasks [dict get [dict create {*}$task] title] + } + + if {[catch { + dict get $data query-continue categorymembers cmcontinue + } continue_task]} then { + # no more continuations, we're done + break + } + dict set this_query cmcontinue $continue_task + } + return [set cache($category) $tasks] +} + +proc get_unimplemented {lang} { + set tasks [get_tasks Programming_Tasks] + set collected [get_tasks Collection_Members] + set doneTasks [get_tasks $lang] + set omittedTasks [get_tasks $lang/Omit] + + # Map generic collection task categories to specific ones + set tasks [regsub -all {Category:(\S+)} $tasks "\\1/$lang"] + + set collectOfLang [struct::set intersect $collected $doneTasks] + set ignorable [struct::set union $doneTasks $omittedTasks $collectOfLang] + set unimplemented [struct::set difference $tasks $ignorable] + + puts "\n$lang has [llength $unimplemented] unimplemented programming tasks:" + if {[llength $unimplemented]} { + puts " [join [lsort $unimplemented] "\n "]" + } +} + +foreach lang {Perl Python Ruby Tcl} { + get_unimplemented $lang +} diff --git a/Task/Rosetta-Code-Fix-code-tags/0DESCRIPTION b/Task/Rosetta-Code-Fix-code-tags/0DESCRIPTION new file mode 100644 index 0000000000..7fe1727e83 --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/0DESCRIPTION @@ -0,0 +1,10 @@ +Fix Rosetta Code deprecated code tags, with these rules: + +

    Change <%s> to 
    +Change  to 
    +Change  to 
    +Change  to 
    + +Usage: + +
    ./convert.py < wikisource.txt > converted.txt
    diff --git a/Task/Rosetta-Code-Fix-code-tags/1META.yaml b/Task/Rosetta-Code-Fix-code-tags/1META.yaml new file mode 100644 index 0000000000..79419892a3 --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Rosetta Code related +note: Text processing diff --git a/Task/Rosetta-Code-Fix-code-tags/AutoHotkey/rosetta-code-fix-code-tags.ahk b/Task/Rosetta-Code-Fix-code-tags/AutoHotkey/rosetta-code-fix-code-tags.ahk new file mode 100644 index 0000000000..d4c533fa74 --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/AutoHotkey/rosetta-code-fix-code-tags.ahk @@ -0,0 +1,15 @@ +; usage: > fixtags.ahk input.txt ouput.txt +FileRead, text, %1% +langs = ada,awk,autohotkey,etc +slang = /lang +slang := "<" . slang . "/>" +Loop, Parse, langs, `, +{ + tag1 = <%A_LoopField%> + tag2 = + text := RegExReplace(text, tag1, "") + text := RegExReplace(text, tag2, slang) + text := RegExReplace(text, "(.*?)" + , "$2" . slang) +} +FileAppend, % text, %2% diff --git a/Task/Rosetta-Code-Fix-code-tags/Go/rosetta-code-fix-code-tags.go b/Task/Rosetta-Code-Fix-code-tags/Go/rosetta-code-fix-code-tags.go new file mode 100644 index 0000000000..be3a7983ae --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/Go/rosetta-code-fix-code-tags.go @@ -0,0 +1,88 @@ +package main + +import "fmt" +import "io/ioutil" +import "log" +import "os" +import "regexp" +import "strings" + +func main() { + err := fix() + if err != nil { + log.Fatalln(err) + } +} + +func fix() (err error) { + buf, err := ioutil.ReadAll(os.Stdin) + if err != nil { + return err + } + out, err := Lang(string(buf)) + if err != nil { + return err + } + fmt.Println(out) + return nil +} + +func Lang(in string) (out string, err error) { + reg := regexp.MustCompile("<[^>]+>") + out = reg.ReplaceAllStringFunc(in, repl) + return out, nil +} + +func repl(in string) (out string) { + if in == "" { + // Change to + return "" + } + + // mid is the content in between '<' and '>'. + mid := in[1 : len(in)-1] + + // thanks, random lua guy + var langs = []string{ + "abap", "actionscript", "actionscript3", "ada", "apache", "applescript", + "apt_sources", "asm", "asp", "autoit", "avisynth", "bash", "basic4gl", + "bf", "blitzbasic", "bnf", "boo", "c", "caddcl", "cadlisp", "cfdg", "cfm", + "cil", "c_mac", "cobol", "cpp", "cpp-qt", "csharp", "css", "d", "delphi", + "diff", "_div", "dos", "dot", "eiffel", "email", "fortran", "freebasic", + "genero", "gettext", "glsl", "gml", "gnuplot", "go", "groovy", "haskell", + "hq9plus", "html4strict", "idl", "ini", "inno", "intercal", "io", "java", + "java5", "javascript", "kixtart", "klonec", "klonecpp", "latex", "lisp", + "lolcode", "lotusformulas", "lotusscript", "lscript", "lua", "m68k", + "make", "matlab", "mirc", "modula3", "mpasm", "mxml", "mysql", "nsis", + "objc", "ocaml", "ocaml-brief", "oobas", "oracle11", "oracle8", "pascal", + "per", "perl", "php", "php-brief", "pic16", "pixelbender", "plsql", + "povray", "powershell", "progress", "prolog", "providex", "python", + "qbasic", "rails", "reg", "robots", "ruby", "sas", "scala", "scheme", + "scilab", "sdlbasic", "smalltalk", "smarty", "sql", "tcl", "teraterm", + "text", "thinbasic", "tsql", "typoscript", "vb", "vbnet", "verilog", + "vhdl", "vim", "visualfoxpro", "visualprolog", "whitespace", "winbatch", + "xml", "xorg_conf", "xpp", "z80", + } + for _, lang := range langs { + if mid == lang { + // Change <%s> to + return fmt.Sprintf("", lang) + } + + if strings.HasPrefix(mid, "/") { + if mid[len("/"):] == lang { + // Change to + return "" + } + } + + if strings.HasPrefix(mid, "code ") { + if mid[len("code "):] == lang { + // Change to + return fmt.Sprintf("", lang) + } + } + } + + return in +} diff --git a/Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-1.j b/Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-1.j new file mode 100644 index 0000000000..855cb790a2 --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-1.j @@ -0,0 +1,6 @@ +require 'printf strings files' + +langs=. <;._1 LF -.~ noun define NB. replace with real lang strings + foo bar + baz +) diff --git a/Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-2.j b/Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-2.j new file mode 100644 index 0000000000..e083cf4e0f --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-2.j @@ -0,0 +1,2 @@ +| +| diff --git a/Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-3.j b/Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-3.j new file mode 100644 index 0000000000..1c7f21afcd --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-3.j @@ -0,0 +1,2 @@ +| +| diff --git a/Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-4.j b/Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-4.j new file mode 100644 index 0000000000..ce73763049 --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-4.j @@ -0,0 +1 @@ +fixCodeTags=: rplc&(, <;._2;._2 &> patterns vbsprintf _5]\ 5#langs) diff --git a/Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-5.j b/Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-5.j new file mode 100644 index 0000000000..452afb5cb5 --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-5.j @@ -0,0 +1 @@ +saepe audire diff --git a/Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-6.j b/Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-6.j new file mode 100644 index 0000000000..9a4565775d --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-6.j @@ -0,0 +1 @@ +In sit inermis deleniti percipit diff --git a/Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-7.j b/Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-7.j new file mode 100644 index 0000000000..08a05fe66e --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-7.j @@ -0,0 +1 @@ +soluta appetere ut mel diff --git a/Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-8.j b/Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-8.j new file mode 100644 index 0000000000..0fee031400 --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-8.j @@ -0,0 +1 @@ +posse nullam lobortis ex usu diff --git a/Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-9.j b/Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-9.j new file mode 100644 index 0000000000..9d96ffbddc --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/J/rosetta-code-fix-code-tags-9.j @@ -0,0 +1 @@ + 'converted.txt' fwrite~ fixCodeTags fread 'wikisource.txt' diff --git a/Task/Rosetta-Code-Fix-code-tags/JavaScript/rosetta-code-fix-code-tags.js b/Task/Rosetta-Code-Fix-code-tags/JavaScript/rosetta-code-fix-code-tags.js new file mode 100644 index 0000000000..b76292285f --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/JavaScript/rosetta-code-fix-code-tags.js @@ -0,0 +1,11 @@ +var langs = ['foo', 'bar', 'baz']; // real list of langs goes here +var end_tag = ''; + +var line; +while (line = readline()) { + line = line.replace(new RegExp('', 'gi'), end_tag); + for (var i = 0; i < langs.length; i++) + line = line.replace(new RegExp('<(?:code )?(' + langs[i] + ')>', 'gi'), '') + .replace(new RegExp('', 'gi'), end_tag); + print(line); +} diff --git a/Task/Rosetta-Code-Fix-code-tags/Lua/rosetta-code-fix-code-tags.lua b/Task/Rosetta-Code-Fix-code-tags/Lua/rosetta-code-fix-code-tags.lua new file mode 100644 index 0000000000..f33f6e5fe6 --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/Lua/rosetta-code-fix-code-tags.lua @@ -0,0 +1,29 @@ +--thanks, random python guy +langs = {'ada', 'cpp-qt', 'pascal', 'lscript', 'z80', 'visualprolog', +'html4strict', 'cil', 'objc', 'asm', 'progress', 'teraterm', 'hq9plus', +'genero', 'tsql', 'email', 'pic16', 'tcl', 'apt_sources', 'io', 'apache', +'vhdl', 'avisynth', 'winbatch', 'vbnet', 'ini', 'scilab', 'ocaml-brief', +'sas', 'actionscript3', 'qbasic', 'perl', 'bnf', 'cobol', 'powershell', +'php', 'kixtart', 'visualfoxpro', 'mirc', 'make', 'javascript', 'cpp', +'sdlbasic', 'cadlisp', 'php-brief', 'rails', 'verilog', 'xml', 'csharp', +'actionscript', 'nsis', 'bash', 'typoscript', 'freebasic', 'dot', +'applescript', 'haskell', 'dos', 'oracle8', 'cfdg', 'glsl', 'lotusscript', +'mpasm', 'latex', 'sql', 'klonec', 'ruby', 'ocaml', 'smarty', 'python', +'oracle11', 'caddcl', 'robots', 'groovy', 'smalltalk', 'diff', 'fortran', +'cfm', 'lua', 'modula3', 'vb', 'autoit', 'java', 'text', 'scala', +'lotusformulas', 'pixelbender', 'reg', '_div', 'whitespace', 'providex', +'asp', 'css', 'lolcode', 'lisp', 'inno', 'mysql', 'plsql', 'matlab', +'oobas', 'vim', 'delphi', 'xorg_conf', 'gml', 'prolog', 'bf', 'per', +'scheme', 'mxml', 'd', 'basic4gl', 'm68k', 'gnuplot', 'idl', 'abap', +'intercal', 'c_mac', 'thinbasic', 'java5', 'xpp', 'boo', 'klonecpp', +'blitzbasic', 'eiffel', 'povray', 'c', 'gettext'} + +for line in io.lines() do + for i, v in ipairs(langs) do + line = line:gsub("<" .. v .. ">", "") + line = line:gsub("", "") + line = line:gsub("", "") --the weird concatenation is to prevent the markup from breaking + line = line:gsub("", "") + end + print(line) +end diff --git a/Task/Rosetta-Code-Fix-code-tags/Mathematica/rosetta-code-fix-code-tags-1.math b/Task/Rosetta-Code-Fix-code-tags/Mathematica/rosetta-code-fix-code-tags-1.math new file mode 100644 index 0000000000..80df0d77a8 --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/Mathematica/rosetta-code-fix-code-tags-1.math @@ -0,0 +1,5 @@ +"} +]>>"converted.txt" + +->conversion of sample text +Lorem ipsumsaepe audire diff --git a/Task/Rosetta-Code-Fix-code-tags/Mathematica/rosetta-code-fix-code-tags-2.math b/Task/Rosetta-Code-Fix-code-tags/Mathematica/rosetta-code-fix-code-tags-2.math new file mode 100644 index 0000000000..9a4565775d --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/Mathematica/rosetta-code-fix-code-tags-2.math @@ -0,0 +1 @@ +In sit inermis deleniti percipit diff --git a/Task/Rosetta-Code-Fix-code-tags/Mathematica/rosetta-code-fix-code-tags-3.math b/Task/Rosetta-Code-Fix-code-tags/Mathematica/rosetta-code-fix-code-tags-3.math new file mode 100644 index 0000000000..781121b8e3 --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/Mathematica/rosetta-code-fix-code-tags-3.math @@ -0,0 +1 @@ +Vix ut doctus cetero invenire diff --git a/Task/Rosetta-Code-Fix-code-tags/Mathematica/rosetta-code-fix-code-tags-4.math b/Task/Rosetta-Code-Fix-code-tags/Mathematica/rosetta-code-fix-code-tags-4.math new file mode 100644 index 0000000000..08a05fe66e --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/Mathematica/rosetta-code-fix-code-tags-4.math @@ -0,0 +1 @@ +soluta appetere ut mel diff --git a/Task/Rosetta-Code-Fix-code-tags/Mathematica/rosetta-code-fix-code-tags-5.math b/Task/Rosetta-Code-Fix-code-tags/Mathematica/rosetta-code-fix-code-tags-5.math new file mode 100644 index 0000000000..0fee031400 --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/Mathematica/rosetta-code-fix-code-tags-5.math @@ -0,0 +1 @@ +posse nullam lobortis ex usu diff --git a/Task/Rosetta-Code-Fix-code-tags/OCaml/rosetta-code-fix-code-tags-1.ocaml b/Task/Rosetta-Code-Fix-code-tags/OCaml/rosetta-code-fix-code-tags-1.ocaml new file mode 100644 index 0000000000..6de4d29bc7 --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/OCaml/rosetta-code-fix-code-tags-1.ocaml @@ -0,0 +1,59 @@ +#load "str.cma" + +let langs = + Str.split (Str.regexp " ") + "actionscript ada algol68 amigae applescript autohotkey awk bash basic \ + befunge bf c cfm cobol cpp csharp d delphi e eiffel factor false forth \ + fortran fsharp haskell haxe j java javascript lisaac lisp logo lua m4 \ + mathematica maxscript modula3 moo objc ocaml octave oz pascal perl \ + perl6 php pike pop11 powershell prolog python qbasic r rebol ruby \ + scala scheme slate smalltalk tcl ti89b vbnet vedit" + +let read_in ic = + let buf = Buffer.create 16384 + and tmp = String.create 4096 in + let rec aux() = + let bytes = input ic tmp 0 4096 in + if bytes > 0 then begin + Buffer.add_substring buf tmp 0 bytes; + aux() + end + in + (try aux() with End_of_file -> ()); + (Buffer.contents buf) + +let repl pat tpl str = + let reg = Str.regexp_string_case_fold pat in + let str = Str.global_replace reg tpl str in + (str) + +(* change <%s> to *) +let repl1 lang str = + let pat = "<" ^ lang ^ ">" + and tpl = "" in + (repl pat tpl str) + +(* change to *) +let repl2 lang str = + let pat = "" + and tpl = "" in + (repl pat tpl str) + +(* change to *) +let repl3 lang str = + let pat = "" + and tpl = "" in + (repl pat tpl str) + +(* change to *) +let repl4 lang str = + let pat = "" + and tpl = "" in + (repl pat tpl str) + + +let () = + print_string ( + List.fold_left (fun str lang -> + (repl4 lang (repl3 lang (repl2 lang (repl1 lang str)))) + ) (read_in stdin) langs) diff --git a/Task/Rosetta-Code-Fix-code-tags/OCaml/rosetta-code-fix-code-tags-2.ocaml b/Task/Rosetta-Code-Fix-code-tags/OCaml/rosetta-code-fix-code-tags-2.ocaml new file mode 100644 index 0000000000..8bf4da2a1f --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/OCaml/rosetta-code-fix-code-tags-2.ocaml @@ -0,0 +1 @@ + (repl4 lang (repl3 lang (repl2 lang (repl1 lang str)))) diff --git a/Task/Rosetta-Code-Fix-code-tags/OCaml/rosetta-code-fix-code-tags-3.ocaml b/Task/Rosetta-Code-Fix-code-tags/OCaml/rosetta-code-fix-code-tags-3.ocaml new file mode 100644 index 0000000000..516376f72a --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/OCaml/rosetta-code-fix-code-tags-3.ocaml @@ -0,0 +1 @@ + List.fold_right (fun repl -> repl lang) [repl1; repl2; repl3; repl4] str diff --git a/Task/Rosetta-Code-Fix-code-tags/Perl/rosetta-code-fix-code-tags.pl b/Task/Rosetta-Code-Fix-code-tags/Perl/rosetta-code-fix-code-tags.pl new file mode 100644 index 0000000000..ff13ad9e0a --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/Perl/rosetta-code-fix-code-tags.pl @@ -0,0 +1,26 @@ +my @langs = qw(ada cpp-qt pascal lscript z80 visualprolog +html4strict cil objc asm progress teraterm hq9plus genero tsql +email pic16 tcl apt_sources io apache vhdl avisynth winbatch +vbnet ini scilab ocaml-brief sas actionscript3 qbasic perl bnf +cobol powershell php kixtart visualfoxpro mirc make javascript +cpp sdlbasic cadlisp php-brief rails verilog xml csharp +actionscript nsis bash typoscript freebasic dot applescript +haskell dos oracle8 cfdg glsl lotusscript mpasm latex sql klonec +ruby ocaml smarty python oracle11 caddcl robots groovy smalltalk +diff fortran cfm lua modula3 vb autoit java text scala +lotusformulas pixelbender reg _div whitespace providex asp css +lolcode lisp inno mysql plsql matlab oobas vim delphi xorg_conf +gml prolog bf per scheme mxml d basic4gl m68k gnuplot idl abap +intercal c_mac thinbasic java5 xpp boo klonecpp blitzbasic eiffel +povray c gettext); + +my $text = join "", ; +my $slang="/lang"; +for (@langs) { + $text =~ s|<$_>||g; + $text =~ s||<$slang>|g; +} + +$text =~ s|(.*?)|$2<$slang>|sg; + +print $text; diff --git a/Task/Rosetta-Code-Fix-code-tags/PicoLisp/rosetta-code-fix-code-tags.l b/Task/Rosetta-Code-Fix-code-tags/PicoLisp/rosetta-code-fix-code-tags.l new file mode 100644 index 0000000000..7c3f69050c --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/PicoLisp/rosetta-code-fix-code-tags.l @@ -0,0 +1,14 @@ +#!/usr/bin/picolisp /usr/lib/picolisp/lib.l + +(let Lang '("ada" "awk" "c" "forth" "prolog" "python" "z80") + (in NIL + (while (echo "<") + (let S (till ">" T) + (cond + ((pre? "code " S) (prin " 2 + PrintN("Usage: "+GetFilePart(ProgramFilename())+" InFile OutFile") + End +EndIf + +Define Infile$ =ProgramParameter(), Outfile$=ProgramParameter() +If ReadFile(0,Infile$) + NewList Out$() + Define line$, part$, new$, pos1, pos2 + While Not Eof(0) + line$=ReadString(0): pos2=0 + Repeat + pos1=FindString(line$,"<",pos2) + pos2=FindString(line$,">",pos1) + If pos1 And pos2 + part$=Mid(line$,pos1+1,pos2-pos1-1) + If Mid(part$,1,1)="/" + new$="<"+"/lang>" ; Line split to avoid problem forum coding + ElseIf Mid(part$,1,5)="code " + new$="" + Else + new$="" + EndIf + line$=ReplaceString(line$,"<"+part$+">",new$) + Else + Break + EndIf + ForEver + AddElement(Out$()): Out$()=line$ + Wend + CloseFile(0) + If CreateFile(1, Outfile$) + ForEach Out$() + WriteStringN(1,Out$()) + Next + CloseFile(1) + EndIf +EndIf diff --git a/Task/Rosetta-Code-Fix-code-tags/Python/rosetta-code-fix-code-tags.py b/Task/Rosetta-Code-Fix-code-tags/Python/rosetta-code-fix-code-tags.py new file mode 100644 index 0000000000..04aa07177a --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/Python/rosetta-code-fix-code-tags.py @@ -0,0 +1,36 @@ +# coding: utf-8 + +import sys +import re + +langs = ['ada', 'cpp-qt', 'pascal', 'lscript', 'z80', 'visualprolog', +'html4strict', 'cil', 'objc', 'asm', 'progress', 'teraterm', 'hq9plus', +'genero', 'tsql', 'email', 'pic16', 'tcl', 'apt_sources', 'io', 'apache', +'vhdl', 'avisynth', 'winbatch', 'vbnet', 'ini', 'scilab', 'ocaml-brief', +'sas', 'actionscript3', 'qbasic', 'perl', 'bnf', 'cobol', 'powershell', +'php', 'kixtart', 'visualfoxpro', 'mirc', 'make', 'javascript', 'cpp', +'sdlbasic', 'cadlisp', 'php-brief', 'rails', 'verilog', 'xml', 'csharp', +'actionscript', 'nsis', 'bash', 'typoscript', 'freebasic', 'dot', +'applescript', 'haskell', 'dos', 'oracle8', 'cfdg', 'glsl', 'lotusscript', +'mpasm', 'latex', 'sql', 'klonec', 'ruby', 'ocaml', 'smarty', 'python', +'oracle11', 'caddcl', 'robots', 'groovy', 'smalltalk', 'diff', 'fortran', +'cfm', 'lua', 'modula3', 'vb', 'autoit', 'java', 'text', 'scala', +'lotusformulas', 'pixelbender', 'reg', '_div', 'whitespace', 'providex', +'asp', 'css', 'lolcode', 'lisp', 'inno', 'mysql', 'plsql', 'matlab', +'oobas', 'vim', 'delphi', 'xorg_conf', 'gml', 'prolog', 'bf', 'per', +'scheme', 'mxml', 'd', 'basic4gl', 'm68k', 'gnuplot', 'idl', 'abap', +'intercal', 'c_mac', 'thinbasic', 'java5', 'xpp', 'boo', 'klonecpp', +'blitzbasic', 'eiffel', 'povray', 'c', 'gettext'] + +slang = '/lang' +code='code' + +text = sys.stdin.read() + +for i in langs: + text = text.replace("<%s>" % i,"" % i) + text = text.replace("" % i, "<%s>" % slang) + +text = re.sub("(?s)<%s (.+?)>(.*?)"%(code,code), r"\2<%s>" % slang, text) + +sys.stdout.write(text) diff --git a/Task/Rosetta-Code-Fix-code-tags/R/rosetta-code-fix-code-tags.r b/Task/Rosetta-Code-Fix-code-tags/R/rosetta-code-fix-code-tags.r new file mode 100644 index 0000000000..cbdbb9c332 --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/R/rosetta-code-fix-code-tags.r @@ -0,0 +1,14 @@ +fixtags <- function(page) +{ + langs <- c("c", "c-sharp", "r") # a complete list is required, obviously + langs <- paste(langs, collapse="|") + page <- gsub(paste("<(", langs, ")>", sep=""), "", page) + page <- gsub(paste("", sep=""), "", page) + page <- gsub(paste("", sep=""), "", page) + page <- gsub(paste("", sep=""), "", page) + page +} + +page <- "lorem ipsum some c codedolor sit amet,some c-sharp code +consectetur adipisicing elit,some r codesed do eiusmod tempor incididunt" +fixtags(page) diff --git a/Task/Rosetta-Code-Fix-code-tags/REXX/rosetta-code-fix-code-tags-1.rexx b/Task/Rosetta-Code-Fix-code-tags/REXX/rosetta-code-fix-code-tags-1.rexx new file mode 100644 index 0000000000..499c7783a7 --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/REXX/rosetta-code-fix-code-tags-1.rexx @@ -0,0 +1,21 @@ +/*REXX program fixes (changes) depreciated code tags with newer tags.*/ +@ = '<' /*ensure RC doesn't get confused.*/ +old. = /*define a default value for OLD.*/ +old.1 = @'%s>' ; new.1 = @'lang %s>' +old.2 = @'/%s>' ; new.2 = @'/lang>' +old.3 = @'code %s>' ; new.3 = @'lang %s>' +old.4 = @'/code>' ; new.4 = @'/lang>' + +ifid = 'Wikisource.txt' /* Input File IDentifier. */ +ofid = 'converted.txt' /*Output " " */ + + do while lines(ifid) \== 0 /*keep trunkin' until it's done. */ + _=linein(ifid) /*read a record from input file. */ + + do j=1 while old.j \== '' /*change old ──► new until done. */ + _=changestr(new.j,_,old.j) /*let REXX do the heavy lifting. */ + end /*j*/ + + call lineout ofid,_ /*write the re-formatted record. */ + end /*while lines(ifid...*/ + /*stick a fork in it, we're done.*/ diff --git a/Task/Rosetta-Code-Fix-code-tags/REXX/rosetta-code-fix-code-tags-2.rexx b/Task/Rosetta-Code-Fix-code-tags/REXX/rosetta-code-fix-code-tags-2.rexx new file mode 100644 index 0000000000..f1e6eb5a74 --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/REXX/rosetta-code-fix-code-tags-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 j")) {""} + text.gsub!(Regexp.new(""), "<#{slash_lang}>") +end +text.gsub!(//, '') +text.gsub!(/<\/code>/, "<#{slash_lang}>") +print text + +__END__ +Lorem ipsum saepe audire elaboraret ne quo, id equidem +atomorum inciderint usu. In sit inermis deleniti percipit, +ius ex tale civibus omittam. Vix ut doctus cetero invenire, his eu +altera electram. Tota adhuc altera te sea, soluta appetere ut mel. +Quo quis graecis vivendo te, posse nullam lobortis ex usu. Eam volumus perpetua +constituto id, mea an omittam fierent vituperatoribus. diff --git a/Task/Rosetta-Code-Fix-code-tags/Ruby/rosetta-code-fix-code-tags-2.rb b/Task/Rosetta-Code-Fix-code-tags/Ruby/rosetta-code-fix-code-tags-2.rb new file mode 100644 index 0000000000..452afb5cb5 --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/Ruby/rosetta-code-fix-code-tags-2.rb @@ -0,0 +1 @@ +saepe audire diff --git a/Task/Rosetta-Code-Fix-code-tags/Ruby/rosetta-code-fix-code-tags-3.rb b/Task/Rosetta-Code-Fix-code-tags/Ruby/rosetta-code-fix-code-tags-3.rb new file mode 100644 index 0000000000..9a4565775d --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/Ruby/rosetta-code-fix-code-tags-3.rb @@ -0,0 +1 @@ +In sit inermis deleniti percipit diff --git a/Task/Rosetta-Code-Fix-code-tags/Ruby/rosetta-code-fix-code-tags-4.rb b/Task/Rosetta-Code-Fix-code-tags/Ruby/rosetta-code-fix-code-tags-4.rb new file mode 100644 index 0000000000..08a05fe66e --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/Ruby/rosetta-code-fix-code-tags-4.rb @@ -0,0 +1 @@ +soluta appetere ut mel diff --git a/Task/Rosetta-Code-Fix-code-tags/Ruby/rosetta-code-fix-code-tags-5.rb b/Task/Rosetta-Code-Fix-code-tags/Ruby/rosetta-code-fix-code-tags-5.rb new file mode 100644 index 0000000000..0fee031400 --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/Ruby/rosetta-code-fix-code-tags-5.rb @@ -0,0 +1 @@ +posse nullam lobortis ex usu diff --git a/Task/Rosetta-Code-Fix-code-tags/Tcl/rosetta-code-fix-code-tags-1.tcl b/Task/Rosetta-Code-Fix-code-tags/Tcl/rosetta-code-fix-code-tags-1.tcl new file mode 100644 index 0000000000..bb6e3b6c56 --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/Tcl/rosetta-code-fix-code-tags-1.tcl @@ -0,0 +1,20 @@ +set langs { + ada cpp-qt pascal lscript z80 visualprolog html4strict cil objc asm progress teraterm + hq9plus genero tsql email pic16 tcl apt_sources io apache vhdl avisynth winbatch vbnet + ini scilab ocaml-brief sas actionscript3 qbasic perl bnf cobol powershell php kixtart + visualfoxpro mirc make javascript cpp sdlbasic cadlisp php-brief rails verilog xml + csharp actionscript nsis bash typoscript freebasic dot applescript haskell dos oracle8 + cfdg glsl lotusscript mpasm latex sql klonec ruby ocaml smarty python oracle11 caddcl + robots groovy smalltalk diff fortran cfm lua modula3 vb autoit java text scala lotusformulas + pixelbender reg _div whitespace providex asp css lolcode lisp inno mysql plsql matlab + oobas vim delphi xorg_conf gml prolog bf per scheme mxml d basic4gl m68k gnuplot idl + abap intercal c_mac thinbasic java5 xpp boo klonecpp blitzbasic eiffel povray c gettext +} + +set text [read stdin] +set slang /lang +foreach lang $langs { + set text [regsub -all "<$lang>" $text ""] + set text [regsub -all "" $text "<$slang>"] +} +set text [regsub -all "(.+?)" $text "\\2<$slang>"] diff --git a/Task/Rosetta-Code-Fix-code-tags/Tcl/rosetta-code-fix-code-tags-2.tcl b/Task/Rosetta-Code-Fix-code-tags/Tcl/rosetta-code-fix-code-tags-2.tcl new file mode 100644 index 0000000000..ccc77d56dd --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/Tcl/rosetta-code-fix-code-tags-2.tcl @@ -0,0 +1,2 @@ +set text [regexp -all "<([join $langs |])>" $text {}] +set text [regexp -all "" $text "<$slang>"] diff --git a/Task/Rosetta-Code-Fix-code-tags/Tcl/rosetta-code-fix-code-tags-3.tcl b/Task/Rosetta-Code-Fix-code-tags/Tcl/rosetta-code-fix-code-tags-3.tcl new file mode 100644 index 0000000000..043b94cd1f --- /dev/null +++ b/Task/Rosetta-Code-Fix-code-tags/Tcl/rosetta-code-fix-code-tags-3.tcl @@ -0,0 +1,7 @@ +set replacements [list <$slang>] +foreach lang $langs { + lappend replacements "<$lang>" "" + lappend replacements "" "<$slang>" + lappend replacements "" "" +} +set text [string map $replacements $text] diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/0DESCRIPTION b/Task/Rosetta-Code-Rank-languages-by-popularity/0DESCRIPTION new file mode 100644 index 0000000000..2068c99cb1 --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/0DESCRIPTION @@ -0,0 +1,50 @@ +Sort most popular programming languages based in number of members in Rosetta Code categories +
    (from http://www.rosettacode.org/mw/index.php?title=Special:Categories&limit=5000) + +Sample output on March 27 2013: + +
      1. 717 - Tcl
    +  2. 663 - Python
    +  3. 643 - C
    +  4. 626 - PicoLisp
    +  5. 622 - J
    +  6. 587 - Go
    +  7. 587 - Ruby
    +  8. 585 - D
    +  9. 568 - Perl 6
    + 10. 564 - Ada
    + 11. 554 - Mathematica
    + 12. 535 - Perl
    + 13. 532 - Haskell
    + 14. 514 - BBC BASIC
    + 15. 505 - REXX
    + 16. 491 - Java
    + 17. 478 - OCaml
    + 18. 469 - PureBasic
    + 19. 462 - Unicon
    + 20. 430 - AutoHotkey
    + 21. 429 - Icon
    + 22. 425 - Common Lisp
    + 23. 420 - C sharp
    + 24. 401 - C++
    + 25. 366 - JavaScript
    + 26. 343 - Clojure
    + 27. 342 - Scala
    + 28. 341 - PARI/GP
    + 29. 326 - R
    + 30. 324 - Lua
    + 31. 316 - PHP
    + 32. 314 - ALGOL 68
    + 33. 312 - Forth
    + 34. 305 - Pascal
    + 35. 296 - Groovy
    + 36. 294 - XPL0
    + 37. 292 - Liberty BASIC
    + 38. 288 - Fortran
    + 39. 277 - Oz
    + 40. 275 - PL/I
    +...
    + +A complete ranked listing of all '''481''' languages (from the REXX example) is included here ──► [[RC_POP.OUT]]. + +Filtering wrong results is optional. You can check against [[Special:MostLinkedCategories]] diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/1META.yaml b/Task/Rosetta-Code-Rank-languages-by-popularity/1META.yaml new file mode 100644 index 0000000000..37dd50820a --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/1META.yaml @@ -0,0 +1,6 @@ +--- +category: +- Networking and Web Interaction +- Sorting +- Rosetta Code related +note: Text processing diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/ALGOL-68/rosetta-code-rank-languages-by-popularity.alg b/Task/Rosetta-Code-Rank-languages-by-popularity/ALGOL-68/rosetta-code-rank-languages-by-popularity.alg new file mode 100644 index 0000000000..86d724d2a0 --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/ALGOL-68/rosetta-code-rank-languages-by-popularity.alg @@ -0,0 +1,124 @@ +PROC good page = (REF STRING page) BOOL: + IF grep in string("^HTTP/[0-9.]* 200", page, NIL, NIL) = 0 + THEN TRUE + ELSE IF INT start, end; + grep in string("^HTTP/[0-9.]* [0-9]+ [a-zA-Z ]*", page, + start, end) = 0 + THEN print (page[start : end]) + ELSE print ("unknown error retrieving page") + FI; + FALSE + FI; + +MODE LISTOFSTRING = STRUCT(REF LINK first, last, INT upb); +MODE LINK = STRUCT(STRING value, REF LINK next); + +PRIO LISTINIT = 1; +OP LISTINIT = (REF LISTOFSTRING new, REF LINK first)REF LISTOFSTRING: ( + new := (first, first, (first IS REF LINK(NIL) | 0 | 1 )); + new +); + +OP +:= = (REF LISTOFSTRING list, []CHAR item)VOID: ( + HEAP LINK new := (STRING(item), REF LINK(NIL)); + IF first OF list IS REF LINK(NIL) THEN + first OF list := new + ELSE + next OF last OF list := new + FI; + last OF list := new; + upb OF list +:= 1 +); + +OP UPB = (LISTOFSTRING list)INT: upb OF list; + +OP ARRAYOFSTRING = (LISTOFSTRING list)[]STRING:( + [UPB list]STRING out; + REF LINK this := first OF list; + FOR i TO UPB list DO out[i] := value OF this; this := next OF this OD; + out +); + +INT match=0, no match=1, out of memory error=2, other error=3; + +PROC re split = (STRING re split, REF STRING beetles)[]STRING:( + LISTOFSTRING out := (NIL, NIL, 0); # LISTINIT REF LINK NIL; # + INT start := 1, pos, end; + WHILE grep in string(re split, beetles[start:], pos, end) = match DO + out +:= beetles[start:start+pos-2]; + out +:= beetles[start+pos-1:start+end-1]; + start +:= end + OD; + IF start > UPB beetles THEN + out +:= beetles[start:] + FI; + ARRAYOFSTRING(out) + ); + + +IF STRING reply; + INT rc = + http content (reply, "www.rosettacode.org", "http://www.rosettacode.org/w/index.php?title=Special:Categories&limit=500", 0); + rc /= 0 OR NOT good page (reply) +THEN print (("Error:",strerror (rc))) +ELSE + STRING # hack: HTML should be parsed by an official HTML parsing library # + re html tag = "<[^>]*>", + re a href category = "^
    max | max | UPB stats) DO + printf(($g(-0)". "g(-0)" - "gl$,i,stats[i])) + OD +FI diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/AWK/rosetta-code-rank-languages-by-popularity.awk b/Task/Rosetta-Code-Rank-languages-by-popularity/AWK/rosetta-code-rank-languages-by-popularity.awk new file mode 100644 index 0000000000..77ef666e36 --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/AWK/rosetta-code-rank-languages-by-popularity.awk @@ -0,0 +1,93 @@ +BEGIN { + for (i = 0; i <= 255; i++) + ord[sprintf("%c", i)] = i +} + +# Encode string with application/x-www-form-urlencoded escapes. +function escape(str, c, len, res) { + len = length(str) + res = "" + for (i = 1; i <= len; i++) { + c = substr(str, i, 1); + if (c ~ /[-._*0-9A-Za-z]/) + res = res c + else if (c == " ") + res = res "+" + else + res = res "%" sprintf("%02X", ord[c]) + } + return res +} + +function nc_open(gcmcontinue, host, path) { + host = "rosettacode.org" + path = "/mw/api.php" \ + "?action=query" \ + "&generator=categorymembers" \ + "&gcmtitle=Category:Programming%20Languages" \ + "&gcmlimit=500" \ + (gcmcontinue "" ? "&gcmcontinue=" escape(gcmcontinue) : "") \ + "&prop=categoryinfo" \ + "&format=txt" + + nc = "printf 'GET %s HTTP/1.1\r\nHost: %s\r\n\r\n' '" \ + path "' '" host "' | nc '" host "' 80" +} + +function nc_next(out) { + # Read each line of the HTTP response. + while (nc | getline > 0) { + # Ignore all lines except + # [gcmcontinue], [title] and [pages]. + if (index($0, "[gcmcontinue]")) { + # " [gcmcontinue] => BEFUNGE|" + sub(/^.*=> */, "") + out["gcmcontinue"] = $0 + } else if (index($0, "[title]")) { + # " [title] => Category:AWK" + sub(/^.*Category:/, "") + out["title"] = $0 + } else if(index($0, "[pages]")) { + # " [pages] => 129" + sub(/^.*=> */, "") + # Ignore " [pages] => Array". + if ($0 !~ /^[0-9]+/) + continue + + # Force conversion to number, so AWK will do + # numeric comparisons, not string comparisons. + out["pages"] = $0 + 0 + + # Return now; [pages] came after [title]. + return 1 + } + } + + if ("gcmcontinue" in out) { + close(nc) + nc_open(out["gcmcontinue"]) + delete out["gcmcontinue"] + return nc_next(out) + } else + return 0 +} + +BEGIN { + nc_open() + while (nc_next(language)) { + title = language["title"] # "AWK" + pages = language["pages"] # 129 + + # Insert "129 - AWK" into rank[]. + i = 1 + while (i <= count && (rank[i] + 0) >= pages) + i++ + for (j = count; j >= i; j--) + rank[j + 1] = rank[j] + rank[i] = pages " - " title + count++ + } + + for (i = 1; i <= count; i++) + print i ". " rank[i] +} diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/Ada/rosetta-code-rank-languages-by-popularity.ada b/Task/Rosetta-Code-Rank-languages-by-popularity/Ada/rosetta-code-rank-languages-by-popularity.ada new file mode 100644 index 0000000000..470a835d1b --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/Ada/rosetta-code-rank-languages-by-popularity.ada @@ -0,0 +1,89 @@ +with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; +with Ada.Strings.Fixed; use Ada.Strings.Fixed; +with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; +with Ada.Text_IO; use Ada.Text_IO; + +with Ada.Containers.Ordered_Sets; +with Ada.Strings.Less_Case_Insensitive; + +with AWS.Client; +with AWS.Response; + +procedure Test is + + use Ada.Strings; + + function "+" (S : String) return Unbounded_String renames To_Unbounded_String; + + type A_Language_Count is + record + Count : Integer := 0; + Language : Unbounded_String; + end record; + + function "=" (L, R : A_Language_Count) return Boolean is + begin + return L.Language = R.Language; + end "="; + + function "<" (L, R : A_Language_Count) return Boolean is + begin + -- Sort by 'Count' and then by Language name + return L.Count < R.Count + or else (L.Count = R.Count + and then Less_Case_Insensitive (Left => To_String (L.Language), + Right => To_String (R.Language))); + end "<"; + + package Sets is new Ada.Containers.Ordered_Sets (A_Language_Count); + use Sets; + + Counts : Set; + + procedure Find_Counts (S : String) is + Title_Str : constant String := "title=""Category:"; + End_A_Str : constant String := " ("; + + Title_At : constant Natural := Index (S, Title_Str); + begin + if Title_At /= 0 then + declare + Bracket_At : constant Natural := Index (S (Title_At + Title_Str'Length .. S'Last), ">"); + End_A_At : constant Natural := Index (S (Bracket_At + 1 .. S'Last), End_A_Str); + Space_At : constant Natural := Index (S (End_A_At + End_A_Str'Length .. S'Last), " "); + Count : constant Natural := Natural'Value (S (End_A_At + End_A_Str'Length .. Space_At - 1)); + Language : constant String := S (Title_At + Title_Str'Length .. Bracket_At - 2); + begin + if Bracket_At /= 0 and then End_A_At /= 0 and then Space_At /= 0 then + begin + Counts.Insert (New_Item => (Count, +Language)); + exception + when Constraint_Error => + Put_Line (Standard_Error, "Warning: repeated language: " & Language); + -- Ignore repeated results. + null; + end; + end if; + -- Recursively parse the string for languages and counts + Find_Counts (S (Space_At + 1 .. S'Last)); + end; + end if; + + end Find_Counts; + + Place : Natural := 1; + + procedure Display (C : Cursor) is + begin + Put (Place, Width => 1); Put (". "); + Put (Element (C).Count, Width => 1); Put (" - "); + Put_Line (To_String (Element (C).Language)); + Place := Place + 1; + end Display; + + Http_Source : constant AWS.Response.Data := + AWS.Client.Get ("http://rosettacode.org/mw/index.php?title=Special:Categories&limit=5000"); +begin + Find_Counts (AWS.Response.Message_Body (Http_Source)); + Counts.Reverse_Iterate (Display'Access); +end Test; diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/AutoHotkey/rosetta-code-rank-languages-by-popularity.ahk b/Task/Rosetta-Code-Rank-languages-by-popularity/AutoHotkey/rosetta-code-rank-languages-by-popularity.ahk new file mode 100644 index 0000000000..c4edb28367 --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/AutoHotkey/rosetta-code-rank-languages-by-popularity.ahk @@ -0,0 +1,71 @@ +StringCaseSense, On +Progress, b2 w120 zh0 fs9, Please wait ... +Sleep, 10 + +Link = http://www.rosettacode.org/w/index.php?title=Special:Categories&limit=5000 +FileDelete, Cats.html +URLDownloadToFile, %Link%, Cats.html +FileRead, Cats, Cats.html + +Link1 = http://rosettacode.org/wiki/Category:Programming_Languages +FileDelete, lang1.htm +URLDownloadToFile, %Link1%, Lang1.htm +FileRead, Lang1, Lang1.htm + +LookFor = (\(previous 200\) \(next 200 +RegExMatch(Lang1, LookFor, Link) ; Link2 +StringReplace, Link2, Link2, &, & + +FileDelete, lang2.htm +URLDownloadToFile, http://www.rosettacode.org%Link2%, Lang2.htm +FileRead, Lang2, Lang2.htm +Languages := Lang1 Lang2 + +; create list of categories with member count +Loop, Parse, Cats, `n, `r +{ + If InStr(A_LoopField, "
  • ") { + LookFor = title=\"Category:(.+?)" + RegExMatch(A_LoopField, LookFor, Name) + RegExMatch(A_LoopField, "(\d*)\smembers", Count) + CatsList .= Count1 "|" Name1 "`r`n" + } +} + +; create list of languages +RegExMatch(Languages, "(

    Subcategories

    )(.*)previous 200", Match) +LookFor =
    (.*?)(.*) +While RegExMatch(Match2, LookFor, Match) + LangList .= Match1 "`r`n" + +; create the final list +Loop, Parse, CatsList, `n, `r +{ + StringSplit, out, A_LoopField, | + If RegExMatch(LangList, "m)^" out2 "$") + FinalList .= A_LoopField "`r`n" +} + +Sort, FinalList, RN +Gui, -MinimizeBox +Gui, Margin, 6 +Gui, Add, ListView, y10 w363 r20 Grid, Rank|Members|Category +Loop, Parse, FinalList, `n, `r +{ + If A_LoopField { + StringSplit, Item, A_LoopField, | + LV_Add("", A_Index, Item1, Item2) + } +} + +LV_ModifyCol(1, "Integer") +LV_ModifyCol(2, "Integer") +LV_ModifyCol(3, 250) +FormatTime, Timestamp,, dd MMM yyyy +Progress, Off +Gui, Show,, Rosetta Categories - %Timestamp% +Return + +GuiClose: + ExitApp +Return diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/BBC-BASIC/rosetta-code-rank-languages-by-popularity.bbc b/Task/Rosetta-Code-Rank-languages-by-popularity/BBC-BASIC/rosetta-code-rank-languages-by-popularity.bbc new file mode 100644 index 0000000000..ee91103384 --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/BBC-BASIC/rosetta-code-rank-languages-by-popularity.bbc @@ -0,0 +1,90 @@ + INSTALL @lib$+"SORTLIB" + SortUp% = FN_sortinit(0,0) : REM Ascending + SortDown% = FN_sortinit(1,0) : REM Descending + + VDU 23,22,640;512;8,16,16,128+8 : REM Enable UTF-8 support + DIM lang$(1000), tasks%(1000) + NORM_IGNORECASE = 1 + + SYS "LoadLibrary", "URLMON.DLL" TO urlmon% + SYS "GetProcAddress", urlmon%, "URLDownloadToFileA" TO UDTF + + PRINT "Downloading languages list..." + url$ = "http://rosettacode.org/wiki/Category:Programming_Languages" + file$ = @tmp$ + "languages.htm" + SYS UDTF, 0, url$, file$, 0, 0 TO fail% + IF fail% ERROR 100, "File download failed (languages)" + + file% = OPENIN(file$) + index% = 0 + WHILE NOT EOF#file% + REPEAT + a$ = GET$#file% + IF INSTR(a$, "") + IF i% = 0 EXIT REPEAT + j% = i% + REPEAT i% -= 1 : UNTIL MID$(a$,i%,1) = ">" OR i% = 0 + IF i% = 0 EXIT REPEAT + lang$(index%) = MID$(a$, i%+1, j%-i%-1) + IF lang$(index%) <> "Languages" index% += 1 + UNTIL TRUE + ENDWHILE + CLOSE #file% + + C% = index% + CALL SortUp%, lang$(0) + + PRINT "Downloading categories list..." + url$ = "http://www.rosettacode.org/w/index.php" + url$ += "?title=Special:Categories&limit=5000" + file$ = @tmp$ + "categories.htm" + SYS UDTF, 0, url$, file$, 0, 0 TO fail% + IF fail% ERROR 100, "File download failed (categories)" + + file% = OPENIN(file$) + WHILE NOT EOF#file% + REPEAT + a$ = GET$#file% + i% = INSTR(a$, "member") + IF i% = 0 EXIT REPEAT + REPEAT i% -= 1 : UNTIL MID$(a$,i%,1) = "(" OR i% = 0 + IF i% = 0 EXIT REPEAT + tasks% = VAL(MID$(a$, i%+1)) + IF tasks% = 0 EXIT REPEAT + REPEAT i% -= 1 : UNTIL MID$(a$,i%,1) = "<" OR i% = 0 + IF i% = 0 EXIT REPEAT + j% = i% + REPEAT i% -= 1 : UNTIL MID$(a$,i%,1) = ">" OR i% = 0 + IF i% = 0 EXIT REPEAT + k% = FNwhere(lang$(), MID$(a$, i%+1, j%-i%-1), index%-1) + IF k% <> -1 tasks%(k%) += tasks% + UNTIL TRUE + ENDWHILE + CLOSE #file% + + CALL SortDown%, tasks%(0), lang$(0) + + VDU 14 + @% = 3 : REM Column width + PRINT "List of languages as of " TIME$ + FOR i% = 0 TO index%-1 + IF tasks%(i%) = 0 EXIT FOR + PRINT i%+1 ". " tasks%(i%) " - " lang$(i%) + NEXT + END + + DEF FNwhere(a$(), S$, T%) + LOCAL B%, C%, H% + H% = 2 + WHILE H%= 2 B% += H% + ENDIF + H% /= 2 + UNTIL H%=0 + SYS "CompareString", 0, NORM_IGNORECASE, S$, -1, a$(B%), -1 TO C% + IF C% = 2 THEN = B% ELSE = -1 diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/C++/rosetta-code-rank-languages-by-popularity.cpp b/Task/Rosetta-Code-Rank-languages-by-popularity/C++/rosetta-code-rank-languages-by-popularity.cpp new file mode 100644 index 0000000000..3bb14c22b4 --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/C++/rosetta-code-rank-languages-by-popularity.cpp @@ -0,0 +1,78 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct Sort { //sorting programming languages according to frequency + bool operator( ) ( const std::pair & a , const std::pair & b ) + const { + return a.second > b.second ; + } +} ; + +int main( ) { + try { + //setting up an io service , with templated subelements for resolver and query + boost::asio::io_service io_service ; + boost::asio::ip::tcp::resolver resolver ( io_service ) ; + boost::asio::ip::tcp::resolver::query query ( "rosettacode.org" , "http" ) ; + boost::asio::ip::tcp::resolver::iterator endpoint_iterator = resolver.resolve( query ) ; + boost::asio::ip::tcp::resolver::iterator end ; + boost::asio::ip::tcp::socket socket( io_service ) ; + boost::system::error_code error = boost::asio::error::host_not_found ; + //looking for an endpoint the socket will be able to connect to + while ( error && endpoint_iterator != end ) { + socket.close( ) ; + socket.connect( *endpoint_iterator++ , error ) ; + } + if ( error ) + throw boost::system::system_error ( error ) ; + //we send a request + boost::asio::streambuf request ; + std::ostream request_stream( &request ) ; + request_stream << "GET " << "/mw/index.php?title=Special:Categories&limit=5000" << " HTTP/1.0\r\n" ; + request_stream << "Host: " << "rosettacode.org" << "\r\n" ; + request_stream << "Accept: */*\r\n" ; + request_stream << "Connection: close\r\n\r\n" ; + //send the request + boost::asio::write( socket , request ) ; + //we receive the response analyzing every line and storing the programming language + boost::asio::streambuf response ; + std::istream response_stream ( &response ) ; + boost::asio::read_until( socket , response , "\r\n\r\n" ) ; + boost::regex e( "
  • ]+?\">([a-zA-Z\\+#1-9]+?)\\s?\\((\\d+) members\\)
  • " ) ; + //using the wrong regex produces incorrect sorting!! + std::ostringstream line ; + std::vector > languages ; //holds language and number of examples + boost::smatch matches ; + while ( boost::asio::read( socket , response , boost::asio::transfer_at_least( 1 ) , error ) ) { + line << &response ; + if ( boost::regex_search( line.str( ) , matches , e ) ) { + std::string lang( matches[2].first , matches[2].second ) ; + int zahl = atoi ( lang.c_str( ) ) ; + languages.push_back( std::make_pair( matches[ 1 ] , zahl ) ) ; + } + line.str( "") ;//we have to erase the string buffer for the next read + } + if ( error != boost::asio::error::eof ) + throw boost::system::system_error( error ) ; + //we sort the vector entries , see the struct above + std::sort( languages.begin( ) , languages.end( ) , Sort( ) ) ; + int n = 1 ; + for ( std::vector >::const_iterator spi = languages.begin( ) ; + spi != languages.end( ) ; ++spi ) { + std::cout << std::setw( 3 ) << std::right << n << '.' << std::setw( 4 ) << std::right << + spi->second << " - " << spi->first << '\n' ; + n++ ; + } + } catch ( std::exception &ex ) { + std::cout << "Exception: " << ex.what( ) << '\n' ; + } + return 0 ; +} diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/C/rosetta-code-rank-languages-by-popularity.c b/Task/Rosetta-Code-Rank-languages-by-popularity/C/rosetta-code-rank-languages-by-popularity.c new file mode 100644 index 0000000000..c7ebad89b7 --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/C/rosetta-code-rank-languages-by-popularity.c @@ -0,0 +1,77 @@ +#include +#include +#include + +const char * lang_url = "http://www.rosettacode.org/w/api.php?action=query&" + "list=categorymembers&cmtitle=Category:Programming_Languages&" + "cmlimit=500&format=json"; +const char * cat_url = "http://www.rosettacode.org/w/index.php?title=Special:Categories&limit=5000"; + +#define BLOCK 1024 +char *get_page(const char *url) +{ + char cmd[1024]; + char *ptr, *buf; + int bytes_read = 1, len = 0; + sprintf(cmd, "wget -q \"%s\" -O -", url); + FILE *fp = popen(cmd, "r"); + if (!fp) return 0; + for (ptr = buf = 0; bytes_read > 0; ) { + buf = realloc(buf, 1 + (len += BLOCK)); + if (!ptr) ptr = buf; + bytes_read = fread(ptr, 1, BLOCK, fp); + if (bytes_read <= 0) break; + ptr += bytes_read; + } + *++ptr = '\0'; + return buf; +} + +char ** get_langs(char *buf, int *l) +{ + char **arr = 0; + for (*l = 0; (buf = strstr(buf, "Category:")) && (buf += 9); ++*l) + for ( (*l)[arr = realloc(arr, sizeof(char*)*(1 + *l))] = buf; + *buf != '"' || (*buf++ = 0); + buf++); + + return arr; +} + +typedef struct { const char *name; int count; } cnt_t; +cnt_t * get_cats(char *buf, char ** langs, int len, int *ret_len) +{ + char str[1024], *found; + cnt_t *list = 0; + int i, llen = 0; + for (i = 0; i < len; i++) { + sprintf(str, "/wiki/Category:%s", langs[i]); + if (!(found = strstr(buf, str))) continue; + buf = found + strlen(str); + + if (!(found = strstr(buf, " ("))) continue; + list = realloc(list, sizeof(cnt_t) * ++llen); + list[llen - 1].name = langs[i]; + list[llen - 1].count = strtol(found + 6, 0, 10); + } + *ret_len = llen; + return list; +} + +int _scmp(const void *a, const void *b) +{ + int x = ((const cnt_t*)a)->count, y = ((const cnt_t*)b)->count; + return x < y ? -1 : x > y; +} + +int main() +{ + int len, clen; + char ** langs = get_langs(get_page(lang_url), &len); + cnt_t *cats = get_cats(get_page(cat_url), langs, len, &clen); + qsort(cats, clen, sizeof(cnt_t), _scmp); + while (--clen >= 0) + printf("%4d %s\n", cats[clen].count, cats[clen].name); + + return 0; +} diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/Cache-ObjectScript/rosetta-code-rank-languages-by-popularity.cos b/Task/Rosetta-Code-Rank-languages-by-popularity/Cache-ObjectScript/rosetta-code-rank-languages-by-popularity.cos new file mode 100644 index 0000000000..5065b666e9 --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/Cache-ObjectScript/rosetta-code-rank-languages-by-popularity.cos @@ -0,0 +1,108 @@ +Include %occSAX + +Class Utils.Net.RosettaCode Extends %ArrayOfDataTypes +{ + +ClassMethod GetTopLanguages(pHost As %String = "", pPath As %String = "", pTop As %Integer = 10) As %Status +{ + // check input parameters + 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.") + } + + // create http request and get page + Set req=##class(%Net.HttpRequest).%New() + Set req.Server=pHost + Do req.Get(pPath) + + // create xml stream with doc type + Set xml=##class(%Stream.GlobalCharacter).%New() + Set sc=xml.WriteLine("") + Set sc=xml.WriteLine($Char(9)_"") + Set sc=xml.WriteLine("]>") + + // copy xhtml stream to xml stream + Set xhtml=req.HttpResponse.Data + Set xhtml.LineTerminator=$Char(10) + While 'xhtml.AtEnd { + Set line=xhtml.ReadLine() + If line["!DOCTYPE" Continue + Set sc=xml.WriteLine(line) + } + + // now parse xml stream + Set sc=##class(%XML.TextReader).ParseStream(xml, .hdlr,, $$$SAXDEFAULTS-$$$SAXNAMESPACES) + If $$$ISERR(sc) Quit sc + + // get languages + Set array=..%New() + Set sc=array.GetLanguages(hdlr) + If array.Count()=0 Quit $$$ERROR($$$GeneralError, "No languages found.") + + // show top entries + Write "Top "_pTop_" Languages (as at "_$ZDate($HoroLog, 2)_"):", ! + For count=1:1:pTop { + Set members=array.GetPrevious(.key) + If key="" Quit + Write $Justify(count, 3), ". ", key, " - ", $ListToString(members, ", "), ! + } + + // finished + Quit $$$OK +} + +Method GetLanguages(pHandler As %XML.SAX.ContentHandler, pDepth As %Integer) As %Status [ Internal, Private ] +{ + // iterate through xml document, node by node + While pHandler.Read() { + + If '$Data(pDepth) { + + // find 'bodyContent' div element + If pHandler.AttributeCount, pHandler.MoveToAttributeName("id") { + If pHandler.Value="bodyContent" { + Set sc=..GetLanguages(pHandler, pHandler.Depth) + Quit + } + } + + } Else { + + // all done + If pDepth>pHandler.Depth Quit + + // get language name + If $Locate(pHandler.Path, "(/div/ul/li/a)$") { + If pHandler.AttributeCount, pHandler.MoveToAttributeName("href") { + If $Locate(pHandler.Value, "/Category:") { + Set sc=pHandler.MoveToContent() + Set lang=pHandler.Value + If $Locate(lang, "User|Tasks|Omit|attention|operations|Solutions by") Set lang="" + } + } + } + + // get members + If $Locate(pHandler.Path, "(/div/ul/li)$") { + If pHandler.HasValue, $Get(lang)'="" { + Set pos=$Locate(pHandler.Value, "(\d+) member") + If pos { + Set members=+$Extract(pHandler.Value, pos, *) + Set list=..GetAt(members) + Set $List(list, $ListLength(list)+1)=lang + Set sc=..SetAt(list, members) + Set lang="" + } + } + } + + } + + } + + // finished + Quit $$$OK +} + +} diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/D/rosetta-code-rank-languages-by-popularity.d b/Task/Rosetta-Code-Rank-languages-by-popularity/D/rosetta-code-rank-languages-by-popularity.d new file mode 100644 index 0000000000..68a84f343d --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/D/rosetta-code-rank-languages-by-popularity.d @@ -0,0 +1,24 @@ +import std.stdio, std.algorithm, std.conv, std.array, std.regex, + std.typecons, std.net.curl; + +void main() { + // Get a list of just the programming languages. + immutable r1 = `"title":"Category:([^"]+)"`; + const languages = get("www.rosettacode.org/w/api.php?action=query"~ + "&list=categorymembers&cmtitle=Category:Pro"~ + "gramming_Languages&cmlimit=500&format=json") + .match(r1.regex("g")).map!q{a[1].dup}.array; + + // Get a pagecount for all categories. + immutable r2 = `title="Category:([^"]+)">[^<]+` ~ + `[^(]+\((\d+) members\)`; + const pairs = get("www.rosettacode.org/w/index.php?" ~ + "title=Special:Categories&limit=5000") + .match(r2.regex("g")) + .filter!(m => languages.canFind(m[1])) + .map!(m => tuple(m[2].to!uint, m[1].dup)) + .array.sort!q{a > b}.release; + + foreach (i, res; pairs) + writefln("%3d. %3d - %s", i + 1, res[]); +} diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/Go/rosetta-code-rank-languages-by-popularity.go b/Task/Rosetta-Code-Rank-languages-by-popularity/Go/rosetta-code-rank-languages-by-popularity.go new file mode 100644 index 0000000000..a4d7241492 --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/Go/rosetta-code-rank-languages-by-popularity.go @@ -0,0 +1,114 @@ +package main + +import ( + "encoding/xml" + "fmt" + "io" + "io/ioutil" + "net/http" + "net/url" + "regexp" + "sort" + "strconv" + "strings" +) + +var baseQuery = "http://rosettacode.org/mw/api.php?action=query" + + "&format=xml&list=categorymembers&cmlimit=500" + +func req(u string, foundCm func(string)) string { + resp, err := http.Get(u) + if err != nil { + fmt.Println(err) // connection or request fail + return "" + } + defer resp.Body.Close() + for p := xml.NewDecoder(resp.Body); ; { + t, err := p.RawToken() + switch s, ok := t.(xml.StartElement); { + case err == io.EOF: + return "" + case err != nil: + fmt.Println(err) + return "" + case !ok: + continue + case s.Name.Local == "cm": + for _, a := range s.Attr { + if a.Name.Local == "title" { + foundCm(a.Value) + } + } + case s.Name.Local == "categorymembers" && len(s.Attr) > 0 && + s.Attr[0].Name.Local == "cmcontinue": + return url.QueryEscape(s.Attr[0].Value) + } + } + return "" +} + +// satisfy sort interface (reverse sorting) +type pop struct { + string + int +} +type popList []pop + +func (pl popList) Len() int { return len(pl) } +func (pl popList) Swap(i, j int) { pl[i], pl[j] = pl[j], pl[i] } +func (pl popList) Less(i, j int) bool { + switch d := pl[i].int - pl[j].int; { + case d > 0: + return true + case d < 0: + return false + } + return pl[i].string < pl[j].string +} + +func main() { + // get languages, store in a map + langMap := make(map[string]bool) + storeLang := func(cm string) { + if strings.HasPrefix(cm, "Category:") { + cm = cm[9:] + } + langMap[cm] = true + } + languageQuery := baseQuery + "&cmtitle=Category:Programming_Languages" + continueAt := req(languageQuery, storeLang) + for continueAt > "" { + continueAt = req(languageQuery+"&cmcontinue="+continueAt, storeLang) + } + // allocate slice for sorting + s := make(popList, 0, len(langMap)) + + // get big list of categories + resp, err := http.Get("http://rosettacode.org/mw/index.php" + + "?title=Special:Categories&limit=5000") + var page []byte + if err == nil { + page, err = ioutil.ReadAll(resp.Body) + resp.Body.Close() + } + if err != nil { + fmt.Println(err) + return + } + // split out fields of interest and populate sortable slice + rx := regexp.MustCompile("
  • (.*).*[(]([0-9]+) member") + for _, sm := range rx.FindAllSubmatch(page, -1) { + ls := string(sm[1]) + if langMap[ls] { + if n, err := strconv.Atoi(string(sm[2])); err == nil { + s = append(s, pop{ls, n}) + } + } + } + + // output + sort.Sort(s) + for i, lang := range s { + fmt.Printf("%3d. %3d - %s\n", i+1, lang.int, lang.string) + } +} diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/Haskell/rosetta-code-rank-languages-by-popularity.hs b/Task/Rosetta-Code-Rank-languages-by-popularity/Haskell/rosetta-code-rank-languages-by-popularity.hs new file mode 100644 index 0000000000..d6b79802c4 --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/Haskell/rosetta-code-rank-languages-by-popularity.hs @@ -0,0 +1,35 @@ +import Network.Browser +import Network.HTTP +import Network.URI +import Data.List +import Data.Maybe +import Text.XML.Light +import Control.Arrow +import Data.Ord + +getRespons url = do + rsp <- Network.Browser.browse $ do + setAllowRedirects True + setOutHandler $ const (return ()) -- quiet + request $ getRequest url + return $ rspBody $ snd rsp + + +mostPopLang = do + rsp <-getRespons $ "http://www.rosettacode.org/w/api.php?action=query&list=" ++ + "categorymembers&cmtitle=Category:Programming_Languages&cmlimit=500&format=xml" + mbrs <- getRespons "http://www.rosettacode.org/w/index.php?title=Special:Categories&limit=5000" + let xmls = onlyElems $ parseXML rsp + langs = concatMap (map ((\\"Category:"). fromJust.findAttr (unqual "title")). filterElementsName (== unqual "cm")) xmls + + let catMbr = second (read.takeWhile(/=' '). drop 6). break (=='<'). drop 1. dropWhile(/='>') . drop 5 + catNmbs :: [(String, Int)] + catNmbs = map catMbr $ filter (isPrefixOf "
  • ") $ lines mbrs + printFmt (n,(l,m)) = putStrLn $ take 6 (show n ++ ". ") ++ (show m) ++ " " ++ l + toMaybe (a,b) = + case b of + Just x -> Just (a,x) + _ -> Nothing + + mapM_ printFmt $ zip [1..] $ sortBy (flip (comparing snd)) + $ mapMaybe (toMaybe. (id &&& flip lookup catNmbs)) langs diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/HicEst/rosetta-code-rank-languages-by-popularity-1.hicest b/Task/Rosetta-Code-Rank-languages-by-popularity/HicEst/rosetta-code-rank-languages-by-popularity-1.hicest new file mode 100644 index 0000000000..d2435ac0e0 --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/HicEst/rosetta-code-rank-languages-by-popularity-1.hicest @@ -0,0 +1,33 @@ +CHARACTER cats*50000, catlist*50000, sortedCat*50000, sample*100 +DIMENSION RankNr(1) + + READ(ClipBoard) cats + catlist = ' ' + pos = 1 ! find language entries like * 100 doors (2 members) + nr = 0 + ! after next '*' find next "name" = '100 doors' and next "(...)" = '(2 members)' : +1 EDIT(Text=cats, SetPos=pos, Right='*', R, Mark1, R='(', Left, M2, Parse=name, R=2, P=members, GetPos=pos) + IF(pos > 0) THEN + READ(Text=members) count + IF(count > 0) THEN + nr = nr + 1 + WRITE(Text=catlist, Format='i4, 1x, 2a', APPend) count, name, ';' + ENDIF + GOTO 1 ! no WHILE in HicEst + ENDIF ! catlist is now = " 1 ... User ; 2 100 doors ; 3 3D ; 8 4D ; ..." + + ALLOCATE(RankNr, nr) + EDIT(Text=catlist, SePaRators=';', Option=1+4, SorTtoIndex=RankNr) ! case (1) and back (4) + + sortedCat = ' ' ! get the sorted list in the sequence of RankNr: + ok = 0 + DO i = 1, nr + EDIT(Text=catlist, SePaRators=';', ITeM=RankNr(i), CoPyto=sample) + discard = EDIT(Text=sample, LeXicon='user,attention,solutions,tasks,program,language,implementation,') + IF(discard == 0) THEN ! removes many of the non-language entries + ok = ok + 1 + WRITE(Text=sortedCat, APPend, Format='F5.0, 2A') ok, TRIM(sample), $CRLF + ENDIF + ENDDO + DLG(Text=sortedCat, Format=$CRLF) +END diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/HicEst/rosetta-code-rank-languages-by-popularity-2.hicest b/Task/Rosetta-Code-Rank-languages-by-popularity/HicEst/rosetta-code-rank-languages-by-popularity-2.hicest new file mode 100644 index 0000000000..aa7f0f9d91 --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/HicEst/rosetta-code-rank-languages-by-popularity-2.hicest @@ -0,0 +1,12 @@ +2010-04-24 18:31 +Top 10 entries (not all are languages) + 1. 394 Tcl + 2. 363 Python + 3. 346 Ruby + 4. 328 J + 5. 319 C + 6. 317 OCaml + 7. 315 Haskell + 8. 298 Perl + 9. 288 WikiStubs + 10. 281 Common Lisp diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/HicEst/rosetta-code-rank-languages-by-popularity-3.hicest b/Task/Rosetta-Code-Rank-languages-by-popularity/HicEst/rosetta-code-rank-languages-by-popularity-3.hicest new file mode 100644 index 0000000000..5b9eb91212 --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/HicEst/rosetta-code-rank-languages-by-popularity-3.hicest @@ -0,0 +1,18 @@ +require 'web/gethttp xml/sax/x2j regex' + +x2jclass 'rcPopLang' + +rx =: (<0 1) {:: (2#a:) ,~ rxmatches rxfrom ] + +'Popular Languages' x2jDefn + / := langs : langs =: 0 2 $ a: + html/body/div/div/div/ul/li := langs =: langs ,^:(a:~:{.@[)~ lang ; ' \((\d+) members?\)' rx y + html/body/div/div/div/ul/li/a := lang =: '^\s*((?:.(?!User|Tasks|Omit|attention|operations|by))+)\s*$' rx y +) + +cocurrent'base' + +sortTab =. \: __ ". [: ;:^:_1: {:"1 +formatTab =: [: ;:^:_1: [: (20 A. (<'-') , |. , [: ('.' <"1@:,.~ ":) 1 + 1 i.@,~ 1{$)&.|: sortTab f. + +rcPopLangs =: formatTab@:process_rcPopLang_@:gethttp diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/HicEst/rosetta-code-rank-languages-by-popularity-4.hicest b/Task/Rosetta-Code-Rank-languages-by-popularity/HicEst/rosetta-code-rank-languages-by-popularity-4.hicest new file mode 100644 index 0000000000..1e31405be4 --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/HicEst/rosetta-code-rank-languages-by-popularity-4.hicest @@ -0,0 +1,11 @@ + 10 {. rcPopLangs 'http://www.rosettacode.org/w/index.php?title=Special:Categories&limit=2000' + 1. 687 - Tcl + 2. 646 - Python + 3. 637 - C + 4. 626 - PicoLisp + 5. 612 - J + 6. 587 - Go + 7. 556 - Ada + 8. 550 - D + 9. 549 - Mathematica + 10. 526 - Perl diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/Mathematica/rosetta-code-rank-languages-by-popularity.math b/Task/Rosetta-Code-Rank-languages-by-popularity/Mathematica/rosetta-code-rank-languages-by-popularity.math new file mode 100644 index 0000000000..a8a89b94c5 --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/Mathematica/rosetta-code-rank-languages-by-popularity.math @@ -0,0 +1,5 @@ +Languages = Flatten[Import["http://rosettacode.org/wiki/Category:Programming_Languages","Data"][[1,1]]]; +Languages = Most@StringReplace[Languages, {" " -> "_", "+" -> "%2B"}]; +b = {#, If[# === {}, 0, #[[1]]]&@( StringCases[Import["http://rosettacode.org/wiki/Category:"<>#,"Plaintext"], + "category, out of " ~~ x:NumberString ~~ " total" ->x])} &/@ Languages; +For[i = 1, i < Length@b , i++ , Print[i, ". ", #[[2]], " - ", #[[1]] ]&@ Part[Reverse@SortBy[b, Last], i]] diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/Oz/rosetta-code-rank-languages-by-popularity.oz b/Task/Rosetta-Code-Rank-languages-by-popularity/Oz/rosetta-code-rank-languages-by-popularity.oz new file mode 100644 index 0000000000..21cedc9ead --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/Oz/rosetta-code-rank-languages-by-popularity.oz @@ -0,0 +1,40 @@ +declare + [HTTPClient] = {Module.link ['x-ozlib://mesaros/net/HTTPClient.ozf']} + [Regex] = {Module.link ['x-oz://contrib/regex']} + + fun {GetPage RawUrl} + Client = {New HTTPClient.urlGET init(inPrms(toFile:false toStrm:true) _)} + Url = {VirtualString.toString RawUrl} + OutParams + HttpResponseParams + in + {Client getService(Url ?OutParams ?HttpResponseParams)} + {Client closeAll(true)} + OutParams.sOut + end + + fun {GetCategories Doc} + {Map {Regex.allMatches "
  • ]+>([^<]+) \\(([0-9]+) member" Doc} + fun {$ Match} + Category = {Regex.group 1 Match Doc} + Count = {String.toInt {ByteString.toString {Regex.group 2 Match Doc}}} + in + Category#Count + end + } + end + + Url = "http://www.rosettacode.org/mw/index.php?title=Special:Categories&limit=5000" + + {System.showInfo "Retrieving..."} + Doc = {GetPage Url} + + {System.showInfo "Parsing..."} + Cs = {GetCategories Doc} +in + for + Cat#Count in {Sort Cs fun {$ _#C1 _#C2} C1 > C2 end} + I in 1..20 + do + {System.showInfo I#". "#Count#" - "#Cat} + end diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/Perl-6/rosetta-code-rank-languages-by-popularity.pl6 b/Task/Rosetta-Code-Rank-languages-by-popularity/Perl-6/rosetta-code-rank-languages-by-popularity.pl6 new file mode 100644 index 0000000000..b3535ce0b9 --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/Perl-6/rosetta-code-rank-languages-by-popularity.pl6 @@ -0,0 +1,25 @@ +shell "wget -O languages.html 'http://rosettacode.org/wiki/Category:Programming_Languages'"; +shell "wget -O categories.html 'http://www.rosettacode.org/mw/index.php?title=Special:Categories&limit=5000'"; + +my @lines = slurp('languages.html').lines; +shift @lines until @lines[0] ~~ / '

    Subcategories

    ' /; +my @languages = gather for @lines { + last if / '/bodycontent' /; + take ~$0 if + / '
  • ' (.*?) '
  • ' /; +} + +my %valid = @languages X=> 1; + +@lines = slurp('categories.html').lines; + +my @results = sort -*.[0], gather for @lines { + take [+$1, ~$0] if + / '
  • ' + (.*?) + '' .*? '(' (\d+) ' members)' /; +} + +for @results.kv -> $i, @l { + printf "%d:\t%3d - %s\n", $i+1, |@l; +} diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/Perl/rosetta-code-rank-languages-by-popularity.pl b/Task/Rosetta-Code-Rank-languages-by-popularity/Perl/rosetta-code-rank-languages-by-popularity.pl new file mode 100644 index 0000000000..c75cf07308 --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/Perl/rosetta-code-rank-languages-by-popularity.pl @@ -0,0 +1,17 @@ +use MediaWiki::API; +my $api = new MediaWiki::API({api_url => 'http://rosettacode.org/mw/api.php'}); + +my @pairs = + sort {$b->[1] <=> $a->[1] or $a->[0] cmp $b->[0]} + map {$_->{title} =~ s/\ACategory://; + [$_->{title}, $_->{categoryinfo}{size} || 0];} + values %{$api->api + ({action => 'query', + generator => 'categorymembers', + gcmtitle => 'Category:Programming Languages', + gcmlimit => 'max', + prop => 'categoryinfo'})->{query}{pages}}; + +for (my $n = 1 ; @pairs ; ++$n) + {my ($lang, $tasks) = @{shift @pairs}; + printf "%3d. %3d - %s\n", $n, $tasks, $lang;} diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/PicoLisp/rosetta-code-rank-languages-by-popularity.l b/Task/Rosetta-Code-Rank-languages-by-popularity/PicoLisp/rosetta-code-rank-languages-by-popularity.l new file mode 100644 index 0000000000..faa76c92eb --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/PicoLisp/rosetta-code-rank-languages-by-popularity.l @@ -0,0 +1,14 @@ +(load "@lib/http.l") + +(for (I . X) + (flip + (sort + (make + (client "rosettacode.org" 80 + "mw/index.php?title=Special:Categories&limit=5000" + (while (from "
  • ", 1) + 2, 30) + Row(i)\Name = Left(x3$, FindString(x3$, "<", 1) - 1) + If FindString(ignore$, Row(i)\Name, 1) Or Row(i)\Name = "" + Row(i)\count = 0 + EndIf +Wend +offset=OffsetOf(Language\count) +SortStructuredArray(Row(), #PB_Sort_Descending, offset, #PB_Sort_Integer) +OpenConsole() +For i = 0 To 20 + PrintN( Str(i + 1) + ". " + Str(Row(i)\count) + " - " + Row(i)\Name) +Next +Input() diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/Python/rosetta-code-rank-languages-by-popularity.py b/Task/Rosetta-Code-Rank-languages-by-popularity/Python/rosetta-code-rank-languages-by-popularity.py new file mode 100644 index 0000000000..7cbbc61509 --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/Python/rosetta-code-rank-languages-by-popularity.py @@ -0,0 +1,14 @@ +import urllib, re + +key1 = lambda x: int(x[1]) + +get1 = urllib.urlopen("http://www.rosettacode.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Languages&cmlimit=500&format=json").read() +get2 = urllib.urlopen("http://www.rosettacode.org/w/index.php?title=Special:Categories&limit=5000").read() + +langs = re.findall("\"title\":\"Category:(.+?)\"",get1) +qtdmbr = re.findall("title=\"Category:(.+?)\">.+? \((\d+) members\)",get2) + +result = [(x,int(y)) for x,y in qtdmbr if x in langs] + +for n, i in enumerate(sorted(result,key=key1,reverse=True)): + print "%3d. %3d - %s" % (n+1, i[1], i[0]) diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/R/rosetta-code-rank-languages-by-popularity.r b/Task/Rosetta-Code-Rank-languages-by-popularity/R/rosetta-code-rank-languages-by-popularity.r new file mode 100644 index 0000000000..7f981247df --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/R/rosetta-code-rank-languages-by-popularity.r @@ -0,0 +1,15 @@ +library(RJSONIO) +langUrl <- "http://rosettacode.org/mw/api.php?action=query&format=json&cmtitle=Category:Solutions_by_Programming_Language&list=categorymembers&cmlimit=500" + +languages <- fromJSON(langUrl)$query$categorymembers +languages <- sapply(languages, function(x) sub("Category:", "", x$title)) + +# fails if there are more than 500 users per language +user <- function (lang) { + userBaseUrl <- "http://rosettacode.org/mw/api.php?action=query&format=json&list=categorymembers&cmlimit=500&cmtitle=Category:" + userUrl <- paste(userBaseUrl, URLencode(paste(lang, " User", sep="")),sep="") + length(fromJSON(userUrl)$query$categorymembers) +} + +users <- sapply(languages, user) +head(sort(users, decreasing=TRUE),15) diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/REXX/rosetta-code-rank-languages-by-popularity.rexx b/Task/Rosetta-Code-Rank-languages-by-popularity/REXX/rosetta-code-rank-languages-by-popularity.rexx new file mode 100644 index 0000000000..4f49619b43 --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/REXX/rosetta-code-rank-languages-by-popularity.rexx @@ -0,0 +1,101 @@ +/*REXX program read two files and produces a ranked list of RC languages*/ +sep='█'; L.=0; #.=0; u.=0; catHeap= /*assign variable defaults.*/ +parse arg cutoff CinFID LinFID outFID . /*obtain specified options.*/ +if cutoff==',' | cutoff=='' then cutoff=0 /*assume no cutoff default.*/ + +if CinFID=='' then CinFID='RC_POP.CAT' /*not specified? Use default. */ +if LinFID=='' then LinFID='RC_POP.LAN' /*not specified? Use default. */ +if outFID=='' then outFID='RC_POP.OUT' /*not specified? Use default. */ + +call tell center('timestamp: ' date() time('Civil'),79,'═'), 1, 1 +#langs=reader('lang') /*assign to L.ααα */ +#cats =reader('cat') /*append to the catHeap*/ +#=0 /*number of categories.*/ + do j=1 until catHeap=='' /*process heap of cats.*/ + parse var catHeap cat.j (sep) catHeap /*pick off a category. */ + parse var cat.j cat.j '<' '(' mems . /*untangle the string. */ + cat.j=space(cat.j); _=cat.j; upper _ /*remove excess blanks.*/ + if _=='' | \L._ then iterate /*blank or ¬ a language*/ + if \datatype(mems,'W') then iterate /*"members" ¬ numeric.*/ + /*handle duplicates. */ + if u._\==0 then do /*(next) Possible echo the duplicate to screen.*/ + /*─── say duplicate found: ' cat.j ───*/ + do f=1 for # until _==@u.f; end /*f*/ +say cat.j 'is a dup, old=' #.f 'add mems='mems + #.f=#.f+mems; iterate j + end + u._=u._+1 + #=#+1; #.#=mems; @.#=cat.j; @u.#=_; #.#=mems /*bump counter, assign.*/ + end /*j*/ + +call tell # '(total) number of languages detected, ', + # 'language's(#) "found with number of entries ≥" cutoff, 1, 1 +call esort # /*sort the languages along with #*/ +rank=0; tied= /* [↓] show by ascending rank. */ + + do j=# by -1 for # while #.j>=cutoff; rank=rank+1 + if tied=='' then pRank=rank + tRank=rank; jp=j+1; jm=j-1; tied= + if #.j==#.jp | #.j==#.jm then tied='(tied)' + if #.j==#.jp then tRank=pRank + else pRank= Rank + + call tell right('rank:'right(tRank,4),20) left(tied,6), + right('('#.j left("entr"s(#.j,'ies',"y")')',9),20) @.j + end /*j*/ + call tell ' ☼ end-of-list. ☼', 1, 2 +if cutoff>0 then call tell ' Listing stopped due to a cutoff of' cutoff"." +exit /*stick a fork in it, we're done.*/ +/*───────────────────────────────ESORT subroutine───────────────────────*/ +esort: procedure expose #. @.; arg N; h=N + do while h>1; h=h%2 + do i=1 for N-h; j=i; k=h+i + do while #.k<#.j /*use hard swaps: @. have blanks.*/ + @=@.j; #=#.j; @.j=@.k; #.j=#.k; @.k=@; #.k=# + if h>=j then leave; j=j-h; k=k-h + end /*while #.k<#.j*/ + end /*i*/ + end /*while h>1*/ +return +/*───────────────────────────────READER subroutine──────────────────────*/ +reader: arg which 2; n=0; ig_ast=1 /*ARG uppers WHICH, gets 1st char*/ +if which=='L' then inFID=Linfid /*use this fileID for languages. */ +if which=='C' then inFID=Cinfid /* " " " " categories.*/ +oldMc='╬£C++'; newMc= "µC++" /*Unicode ╬£C++ ──> ASCII-8: µC++*/ +oldUc='UC++' /*old UC++ ──> ASCII-8: µC++*/ +oldMK='╨£╨Ü-'; newMK= "MK-" /*Unicode ╨£╨Ü- ──> ASCII-8: MK- */ +oldDV='D├⌐j├á'; newDV= 'Déjá' /*Unicode ├⌐j├á ──> ASCII-8: Déjá*/ +oldCA='Cach├⌐'; newCA= 'Caché' /*Unicode ach├⌐ ──> ASCII-8: aché*/ + + do while lines(inFID)\==0 /*read a file, 1 line at a time.*/ + $=translate(linein(inFID),,'9'x) /*handle any stray tab characters*/ + $$=space($); if $$=='' then iterate /*ignore all blank lines. */ + if pos(oldMc,$$)\==0 then $$=changestr(oldMc,$$,newMc) /*convert micro*/ + if pos(oldUc,$$)\==0 then $$=changestr(oldUc,$$,newMc) /*convert µC++ */ + if pos(oldMK,$$)\==0 then $$=changestr(oldMK,$$,newMK) /*convert MK- */ + if pos(oldDV,$$)\==0 then $$=changestr(oldDV,$$,newDV) /*convert Déjá */ + if pos(oldCA,$$)\==0 then $$=changestr(oldCA,$$,newCA) /*convert Caché*/ + $u=$; upper $u /*get an uppercase version. */ + if ig_ast then do; ig_ast=pos(' * ',$u)==0; if ig_ast then iterate; end + if pos('RETRIEVED FROM',$u)\==0 then leave /*a pseudo End-Of-Data.*/ + n=n+1 /*bump counter: legimate records.*/ + if which=='L' then do + if left($$,1)\=='*' then iterate /*legimate?*/ + parse upper var $$ '*' $$ '<'; $$=space($$) + L.$$=1 /*languages are stored uppercase.*/ + iterate /*iterates the DO WHILE LINES(...*/ + end /*(above) pick off language name.*/ + + if left($$,1)=='*' then $$=sep || space(substr($$,2)) + catHeap=catHeap $$ /*append to the (CATegory) heap. */ + end /*while lines...*/ + +call tell right(n,9) 'records read from file: ' inFID +return n +/*───────────────────────────────S subroutine───────────────────────────*/ +s: if arg(1)==1 then return arg(3); return word(arg(2) 's',1) /*plural*/ +/*───────────────────────────────TELL subroutine────────────────────────*/ +tell: do '0'arg(2); call lineout outFID,' ' ; say ; end + call lineout outFID,arg(1) ; say arg(1) + do '0'arg(3); call lineout outFID,' ' ; say ; end +return /*show before blanks lines (if any), MSG, show after blank lines*/ diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/Racket/rosetta-code-rank-languages-by-popularity.rkt b/Task/Rosetta-Code-Rank-languages-by-popularity/Racket/rosetta-code-rank-languages-by-popularity.rkt new file mode 100644 index 0000000000..4fd7e777b4 --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/Racket/rosetta-code-rank-languages-by-popularity.rkt @@ -0,0 +1,29 @@ +#lang racket + +(require net/url) +(require json) + +(define proglangs_url "http://rosettacode.org/mw/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Languages&cmlimit=500&format=json") +(define categories_url "http://rosettacode.org/mw/index.php?title=Special:Categories&limit=5000") + +(define (fetch-json urlstring) + (read-json (get-pure-port (string->url urlstring)))) + +(define programming-languages + (for/set ([h (in-list + (hash-ref (hash-ref (fetch-json proglangs_url) 'query) + 'categorymembers))]) + (substring (hash-ref h 'title) 9))) + +(define result '()) +(for ([l (in-port read-line (get-pure-port (string->url categories_url)))]) + (let ([res (regexp-match #px"title=\"Category:(.+?)\".+\\((\\d+) member" l)]) + (when (and res (set-member? programming-languages (cadr res))) + (set! result (cons (cons (cadr res) + (string->number (caddr res))) + result))))) + +(printf "Place\tCount\tName~n") +(for ([lang (in-list (sort result > #:key cdr))] + [place (in-naturals 1)]) + (printf "~a\t~a\t~a~n" place (cdr lang) (car lang))) diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/Ruby/rosetta-code-rank-languages-by-popularity.rb b/Task/Rosetta-Code-Rank-languages-by-popularity/Ruby/rosetta-code-rank-languages-by-popularity.rb new file mode 100644 index 0000000000..c2d356e1fa --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/Ruby/rosetta-code-rank-languages-by-popularity.rb @@ -0,0 +1,30 @@ +require 'rosettacode' + +langs = [] +RosettaCode.category_members("Programming Languages") {|lang| langs << lang} + +# API has trouble with long titles= values. +# To prevent skipping languages, use short slices of 20 titles. +langcount = {} +langs.each_slice(20) do |sublist| + url = RosettaCode.get_api_url({ + "action" => "query", + "prop" => "categoryinfo", + "format" => "xml", + "titles" => sublist.join("|"), + }) + + doc = REXML::Document.new open(url) + REXML::XPath.each(doc, "//page") do |page| + lang = page.attribute("title").value + info = REXML::XPath.first(page, "categoryinfo") + langcount[lang] = info.nil? ? 0 : info.attribute("pages").value.to_i + end +end + +puts Time.now +puts "There are #{langcount.length} languages" +puts "the top 25:" +langcount.sort_by {|key,val| val}.reverse[0,25].each_with_index do |(lang, count), i| + puts "#{i+1}. #{count} - #{lang.sub(/Category:/, '')}" +end diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/Run-BASIC/rosetta-code-rank-languages-by-popularity.run b/Task/Rosetta-Code-Rank-languages-by-popularity/Run-BASIC/rosetta-code-rank-languages-by-popularity.run new file mode 100644 index 0000000000..7f40df37c1 --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/Run-BASIC/rosetta-code-rank-languages-by-popularity.run @@ -0,0 +1,28 @@ +sqliteconnect #mem, ":memory:" ' make memory DB +#mem execute("CREATE TABLE stats(lang,cnt)") +a$ = httpGet$("http://rosettacode.org/wiki/Category:Programming_Languages") +aa$ = httpGet$("http://www.rosettacode.org/mw/index.php?title=Special:Categories&limit=5000") +i = instr(a$,"/wiki/Category:") +while i > 0 and lang$ <> "Languages" + j = instr(a$,"""",i) + lang$ = mid$(a$,i+15,j - i-15) + ii = instr(aa$,"Category:";lang$;"""") + jj = instr(aa$,"(",ii) + kk = instr(aa$," ",jj+1) + if ii = 0 then cnt = 0 else cnt = val(mid$(aa$,jj+1,kk-jj)) + k = instr(lang$,"%") ' convert hex values to characters + while k > 0 + lang$ = left$(lang$,k-1) + chr$(hexdec(mid$(lang$,k+1,2))) + mid$(lang$,k+3) + k = instr(lang$,"%") + wend + #mem execute("insert into stats values ('";lang$;"',";cnt;")") + i = instr(a$,"/wiki/Category:",i+10) +wend +html "" +#mem execute("SELECT * FROM stats ORDER BY cnt desc") ' order list by count descending +WHILE #mem hasanswer() + #row = #mem #nextrow() + rank = rank + 1 + html "" +WEND +html "
    ";rank;"";#row lang$();"";#row cnt();"
    " diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/Scala/rosetta-code-rank-languages-by-popularity.scala b/Task/Rosetta-Code-Rank-languages-by-popularity/Scala/rosetta-code-rank-languages-by-popularity.scala new file mode 100644 index 0000000000..074da05f0c --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/Scala/rosetta-code-rank-languages-by-popularity.scala @@ -0,0 +1,46 @@ +def scrapeRosettaCodeLanguageRanks() : Seq[(String,Int)] = { + + // + // The Programming Languages + // + val langs = { + val langsXML = scala.xml.XML.load("http://rosettacode.org/mw/api.php?action=query&list=categorymembers&cmtitle=Category:Programming_Languages&cmlimit=500&format=xml") + + (langsXML \\ "categorymembers" \ "cm") map (c => (c \ "@title").text) + } + + // + // The Categories + // + val cats = { + + // The categories include a page for the language and a count of the pages linked + // therein, this count is the data we need to scrape. + val catsXML = scala.xml.XML.load("http://rosettacode.org/mw/index.php?title=Special:Categories&limit=5000") + + (catsXML \\ "ul" \ "li") map {c => + + // Create a tuple pair, eg. ("Category:Erlang", 195) + ( + (c \ "a" \ "@title").toString, + ("[0-9]+".r.findFirstIn((c.child.drop(1)).text).getOrElse("0").toInt) // Takes the sibling of "a" and extracts the number + ) + } + } + + val ranks = ((langs map { s => cats.find( c => (c._1 == s) ) }).flatten) map {e => + + // Clean up the tuple pairs, eg ("Category:Erlang", 195) becomes ("Erlang", 192) + ( + (if( e._1.contains("Category:") ) e._1.split("Category:")(1) else e._1), + ((e._2 - 3) max 0) // 3 members (or links) are not of a task + ) + } sortBy ( - _._2 ) + + ranks +} + +val ranks = scrapeRosettaCodeLanguageRanks() + +println("Top 50 Rosetta Code Languages by Popularity, %tF:".format(new java.util.Date) + "\n" ) +ranks.take(50).zipWithIndex foreach {case ((lang,rank),i) => println( s"${i+1}. $rank - $lang" )} diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/TUSCRIPT/rosetta-code-rank-languages-by-popularity.tuscript b/Task/Rosetta-Code-Rank-languages-by-popularity/TUSCRIPT/rosetta-code-rank-languages-by-popularity.tuscript new file mode 100644 index 0000000000..1eacb2afa3 --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/TUSCRIPT/rosetta-code-rank-languages-by-popularity.tuscript @@ -0,0 +1,49 @@ +$$ MODE TUSCRIPT +remotedata = REQUEST ("http://www.rosettacode.org/mw/index.php?title=Special:Categories&limit=5000") +allmembers=allnames="" +COMPILE +LOOP d=remotedata +IF (d.sw."
  • ") THEN + name=EXTRACT (d,":<<%>>:"|,":<>:") + IF (name.eq."Language users") CYCLE + IF (name.sw."Unimplemented tasks") CYCLE + IF (name.sw."Programming") CYCLE + IF (name.sw."Solutions") CYCLE + IF (name.sw."Garbage") CYCLE + IF (name.sw."Typing") CYCLE + IF (name.sw."BASIC LANG") CYCLE + IF (name.ew."USER") CYCLE + IF (name.ew."tasks") CYCLE + IF (name.ew."attention") CYCLE + IF (name.ew."related") CYCLE + IF (name.ct."*omit*") CYCLE + IF (name.ct.":*Categor*:") CYCLE + IF (name.ct.":WikiSTUBS:") CYCLE + IF (name.ct.":Impl needed:") CYCLE + IF (name.ct.":Implementations:") CYCLE + IF (name.ct.":':") name = EXCHANGE (name,":'::") + members = STRINGS (d,":><1<>>/><<> member:") + IF (members!="") THEN + allmembers=APPEND (allmembers,members) + allnames =APPEND (allnames,name) + ENDIF +ENDIF +ENDLOOP +index = DIGIT_INDEX (allmembers) +index = REVERSE (index) +allmembers = INDEX_SORT (allmembers,index) +allnames = INDEX_SORT (allnames, index) +ERROR/STOP CREATE ("list",SEQ-E,-std-) +time=time(),balt=nalt="" +FILE "list" = time +LOOP n, a=allnames,b=allmembers + IF (b==balt) THEN + nr=nalt + ELSE + nalt=nr=n + ENDIF + content=concat (nr,". ",a," --- ",b) + FILE "list" = CONTENT + balt=b +ENDLOOP +ENDCOMPILE diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/Tcl/rosetta-code-rank-languages-by-popularity-1.tcl b/Task/Rosetta-Code-Rank-languages-by-popularity/Tcl/rosetta-code-rank-languages-by-popularity-1.tcl new file mode 100644 index 0000000000..2820a80883 --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/Tcl/rosetta-code-rank-languages-by-popularity-1.tcl @@ -0,0 +1,36 @@ +package require Tcl 8.5 +package require http + +set response [http::geturl http://rosettacode.org/mw/index.php?title=Special:Categories&limit=1000] + +array set ignore { + "Basic language learning" 1 + "Encyclopedia" 1 + "Implementations" 1 + "Language Implementations" 1 + "Language users" 1 + "Maintenance/OmitCategoriesCreated" 1 + "Programming Languages" 1 + "Programming Tasks" 1 + "RCTemplates" 1 + "Solutions by Library" 1 + "Solutions by Programming Language" 1 + "Solutions by Programming Task" 1 + "Unimplemented tasks by language" 1 + "WikiStubs" 1 + "Examples needing attention" 1 + "Impl needed" 1 +} + +foreach line [split [http::data $response] \n] { + if {[regexp {>([^<]+) \((\d+) member} $line -> lang num]} { + if {![info exists ignore($lang)]} { + lappend langs [list $num $lang] + } + } +} + +foreach entry [lsort -integer -index 0 -decreasing $langs] { + lassign $entry num lang + puts [format "%d. %d - %s" [incr i] $num $lang] +} diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/Tcl/rosetta-code-rank-languages-by-popularity-2.tcl b/Task/Rosetta-Code-Rank-languages-by-popularity/Tcl/rosetta-code-rank-languages-by-popularity-2.tcl new file mode 100644 index 0000000000..32357cc758 --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/Tcl/rosetta-code-rank-languages-by-popularity-2.tcl @@ -0,0 +1,86 @@ +package require Tcl 8.5 +package require http +package require tdom + +namespace eval rc { + ### Utility function that handles the low-level querying ### + proc rcq {q xp vn b} { + upvar 1 $vn v + dict set q action "query" + # Loop to pick up all results out of a category query + while 1 { + set url "http://rosettacode.org/mw/api.php?[http::formatQuery {*}$q]" + puts -nonewline stderr . ;# Indicate query progress... + set token [http::geturl $url] + set doc [dom parse [http::data $token]] + http::cleanup $token + + # Spoon out the DOM nodes that the caller wanted + foreach v [$doc selectNodes $xp] { + uplevel 1 $b + } + + # See if we want to go round the loop again + set next [$doc selectNodes "//query-continue/categorymembers"] + if {![llength $next]} break + dict set q cmcontinue [[lindex $next 0] getAttribute "cmcontinue"] + } + } + + ### API function: Iterate over the members of a category ### + proc members {page varName script} { + upvar 1 $varName var + set query [dict create cmtitle "Category:$page" {*}{ + list "categorymembers" + format "xml" + cmlimit "500" + }] + rcq $query "//cm" item { + # Tell the caller's script about the item + set var [$item getAttribute "title"] + uplevel 1 $script + } + } + + ### API function: Count the members of a list of categories ### + proc count {cats catVar countVar script} { + upvar 1 $catVar cat $countVar count + set query [dict create prop "categoryinfo" format "xml"] + for {set n 0} {$n<[llength $cats]} {incr n 40} { + dict set query titles [join [lrange $cats $n $n+39] |] + rcq $query "//page" item { + # Get title and count + set cat [$item getAttribute "title"] + set info [$item getElementsByTagName "categoryinfo"] + if {[llength $info]} { + set count [[lindex $info 0] getAttribute "pages"] + } else { + set count 0 + } + # Let the caller's script figure out what to do with them + uplevel 1 $script + } + } + } + + ### Assemble the bits into a whole API ### + namespace export members count + namespace ensemble create +} + +# Get the list of programming languages +rc members "Solutions by Programming Language" lang { + lappend langs $lang +} +# Get the count of solutions for each, stripping "Category:" prefix +rc count $langs l c { + lappend count [list [regsub {^Category:} $l {}] $c] +} +puts stderr "" ;# Because of the progress dots... +# Print the output +puts "There are [llength $count] languages" +puts "Here are the top fifteen:" +set count [lsort -index 1 -integer -decreasing $count] +foreach item [lrange $count 0 14] { + puts [format "%1\$3d. %3\$3d - %2\$s" [incr n] {*}$item] +} diff --git a/Task/Rosetta-Code-Rank-languages-by-popularity/UnixPipes/rosetta-code-rank-languages-by-popularity.unixpipes b/Task/Rosetta-Code-Rank-languages-by-popularity/UnixPipes/rosetta-code-rank-languages-by-popularity.unixpipes new file mode 100644 index 0000000000..a594dda861 --- /dev/null +++ b/Task/Rosetta-Code-Rank-languages-by-popularity/UnixPipes/rosetta-code-rank-languages-by-popularity.unixpipes @@ -0,0 +1,3 @@ +curl 'http://rosettacode.org/mw/index.php?title=Special:Categories&limit=5000' | +sed -n -e 's|^
  • = c low) + (char<= c high))) + +(defun rot-13-cs (cs) + (cond ((endp cs) nil) + ((or (char-btn (first cs) #\a #\m) + (char-btn (first cs) #\A #\M)) + (cons (code-char (+ (char-code (first cs)) 13)) + (rot-13-cs (rest cs)))) + ((or (char-btn (first cs) #\n #\z) + (char-btn (first cs) #\N #\Z)) + (cons (code-char (- (char-code (first cs)) 13)) + (rot-13-cs (rest cs)))) + (t (cons (first cs) (rot-13-cs (rest cs)))))) + +(defun rot-13 (s) + (coerce (rot-13-cs (coerce s 'list)) 'string)) diff --git a/Task/Rot-13/ALGOL-68/rot-13.alg b/Task/Rot-13/ALGOL-68/rot-13.alg new file mode 100644 index 0000000000..3abaf53534 --- /dev/null +++ b/Task/Rot-13/ALGOL-68/rot-13.alg @@ -0,0 +1,14 @@ +BEGIN + CHAR c; + on logical file end(stand in, (REF FILE f)BOOL: (stop; SKIP)); + on line end(stand in, (REF FILE f)BOOL: (print(new line); FALSE)); + DO + read(c); + IF c >= "A" AND c <= "M" OR c >= "a" AND c <= "m" THEN + c := REPR(ABS c + 13) + ELIF c >= "N" AND c <= "Z" OR c >= "n" AND c <= "z" THEN + c := REPR(ABS c - 13) + FI; + print(c) + OD +END # rot13 # diff --git a/Task/Rot-13/AWK/rot-13.awk b/Task/Rot-13/AWK/rot-13.awk new file mode 100644 index 0000000000..1e8cbbd3d3 --- /dev/null +++ b/Task/Rot-13/AWK/rot-13.awk @@ -0,0 +1,22 @@ +BEGIN { + for(i=0; i < 256; i++) { + amap[sprintf("%c", i)] = i + } + for(l=amap["a"]; l <= amap["z"]; l++) { + rot13[l] = sprintf("%c", (((l-amap["a"])+13) % 26 ) + amap["a"]) + } + FS = "" +} +{ + o = "" + for(i=1; i <= NF; i++) { + if ( amap[tolower($i)] in rot13 ) { + c = rot13[amap[tolower($i)]] + if ( tolower($i) != $i ) c = toupper(c) + o = o c + } else { + o = o $i + } + } + print o +} diff --git a/Task/Rot-13/Ada/rot-13.ada b/Task/Rot-13/Ada/rot-13.ada new file mode 100644 index 0000000000..5b07663e74 --- /dev/null +++ b/Task/Rot-13/Ada/rot-13.ada @@ -0,0 +1,40 @@ +with Ada.Text_IO.Text_Streams; use Ada.Text_IO.Text_Streams; +with Ada.Strings.Maps; use Ada.Strings.Maps; +with Ada.Command_Line; use Ada.Command_Line; + +procedure Rot_13 is + + From_Sequence : Character_Sequence := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; + Result_Sequence : Character_Sequence := "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM"; + Rot_13_Mapping : Character_Mapping := To_Mapping(From_Sequence, Result_Sequence); + + In_Char : Character; + Stdio : Stream_Access := Stream(Ada.Text_IO.Standard_Input); + Stdout : Stream_Access := Stream(Ada.Text_Io.Standard_Output); + Input : Ada.Text_Io.File_Type; + +begin + if Argument_Count > 0 then + for I in 1..Argument_Count loop + begin + Ada.Text_Io.Open(File => Input, Mode => Ada.Text_Io.In_File, Name => Argument(I)); + Stdio := Stream(Input); + while not Ada.Text_Io.End_Of_File(Input) loop + In_Char :=Character'Input(Stdio); + Character'Output(Stdout, Value(Rot_13_Mapping, In_Char)); + end loop; + Ada.Text_IO.Close(Input); + exception + when Ada.Text_IO.Name_Error => + Ada.Text_Io.Put_Line(File => Ada.Text_Io.Standard_Error, Item => "File " & Argument(I) & " is not a file."); + when Ada.Text_Io.Status_Error => + Ada.Text_Io.Put_Line(File => Ada.Text_Io.Standard_Error, Item => "File " & Argument(I) & " is already opened."); + end; + end loop; + else + while not Ada.Text_Io.End_Of_File loop + In_Char :=Character'Input(Stdio); + Character'Output(Stdout, Value(Rot_13_Mapping, In_Char)); + end loop; + end if; +end Rot_13; diff --git a/Task/Rot-13/AppleScript/rot-13-1.applescript b/Task/Rot-13/AppleScript/rot-13-1.applescript new file mode 100644 index 0000000000..22daefa3a3 --- /dev/null +++ b/Task/Rot-13/AppleScript/rot-13-1.applescript @@ -0,0 +1,3 @@ +to rot13(textString) +do shell script "tr a-zA-Z n-za-mN-ZA-M <<<" & quoted form of textString +end rot13 diff --git a/Task/Rot-13/AppleScript/rot-13-2.applescript b/Task/Rot-13/AppleScript/rot-13-2.applescript new file mode 100644 index 0000000000..db25234af2 --- /dev/null +++ b/Task/Rot-13/AppleScript/rot-13-2.applescript @@ -0,0 +1,13 @@ +to rot13(textString) + local outChars + set outChars to {} + repeat with ch in (characters of textString) + if (ch >= "a" and ch <= "m") or (ch >= "A" and ch <= "M") then + set ch to character id (id of ch + 13) + else if (ch >= "n" and ch <= "z") or (ch >= "N" and ch <= "Z") then + set ch to character id (id of ch - 13) + end + set end of outChars to ch + end + return outChars as text +end rot13 diff --git a/Task/Rot-13/AppleScript/rot-13-3.applescript b/Task/Rot-13/AppleScript/rot-13-3.applescript new file mode 100644 index 0000000000..42c3c0cdc2 --- /dev/null +++ b/Task/Rot-13/AppleScript/rot-13-3.applescript @@ -0,0 +1 @@ +rot13("nowhere ABJURER") diff --git a/Task/Rot-13/AutoHotkey/rot-13.ahk b/Task/Rot-13/AutoHotkey/rot-13.ahk new file mode 100644 index 0000000000..bc06461dc6 --- /dev/null +++ b/Task/Rot-13/AutoHotkey/rot-13.ahk @@ -0,0 +1,28 @@ +Str0=Hello, This is a sample text with 1 2 3 or other digits!@#$^&*()-_= +Str1 := Rot13(Str0) +Str2 := Rot13(Str1) +MsgBox % Str0 "`n" Str1 "`n" Str2 + +Rot13(string) +{ + Loop Parse, string + { + char := Asc(A_LoopField) + ; o is 'A' code if it is an uppercase letter, and 'a' code if it is a lowercase letter + o := Asc("A") * (Asc("A") <= char && char <= Asc("Z")) + Asc("a") * (Asc("a") <= char && char <= Asc("z")) + If (o > 0) + { + ; Set between 0 and 25, add rotation factor, modulus alphabet size + char := Mod(char - o + 13, 26) + ; Transform back to char, upper or lower + char := Chr(char + o) + } + Else + { + ; Non alphabetic, unchanged + char := A_LoopField + } + rStr .= char + } + Return rStr +} diff --git a/Task/Rot-13/BASIC/rot-13.basic b/Task/Rot-13/BASIC/rot-13.basic new file mode 100644 index 0000000000..5bf272fe38 --- /dev/null +++ b/Task/Rot-13/BASIC/rot-13.basic @@ -0,0 +1,17 @@ +CLS +INPUT "Enter a string: ", s$ +ans$ = "" +FOR a = 1 TO LEN(s$) + letter$ = MID$(s$, a, 1) + IF letter$ >= "A" AND letter$ <= "Z" THEN + char$ = CHR$(ASC(letter$) + 13) + IF char$ > "Z" THEN char$ = CHR$(ASC(char$) - 26) + ELSEIF letter$ >= "a" AND letter$ <= "z" THEN + char$ = CHR$(ASC(letter$) + 13) + IF char$ > "z" THEN char$ = CHR$(ASC(char$) - 26) + ELSE + char$ = letter$ + END IF + ans$ = ans$ + char$ +NEXT a +PRINT ans$ diff --git a/Task/Rot-13/BBC-BASIC/rot-13.bbc b/Task/Rot-13/BBC-BASIC/rot-13.bbc new file mode 100644 index 0000000000..ef0801c29c --- /dev/null +++ b/Task/Rot-13/BBC-BASIC/rot-13.bbc @@ -0,0 +1,22 @@ + REPEAT + INPUT A$ + PRINT FNrot13(A$) + UNTIL FALSE + END + + DEF FNrot13(A$) + LOCAL A%,B$,C$ + IF A$="" THEN ="" + FOR A%=1 TO LEN A$ + C$=MID$(A$,A%,1) + IF C$<"A" OR (C$>"Z" AND C$<"a") OR C$>"z" THEN + B$=B$+C$ + ELSE + IF (ASC(C$) AND &DF) + :"Z"`#v_:"M"`#v_:"@"`|> + : 0 `#v_@v-6-7< > +, < <+6+7 < +#include +#include +#include +#include +#include + +// the rot13 function +std::string rot13(std::string s) +{ + static std::string const + lcalph = "abcdefghijklmnopqrstuvwxyz", + ucalph = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + std::string result; + std::string::size_type pos; + + result.reserve(s.length()); + + for (std::string::iterator it = s.begin(); it != s.end(); ++it) + { + if ( (pos = lcalph.find(*it)) != std::string::npos ) + result.push_back(lcalph[(pos+13) % 26]); + else if ( (pos = ucalph.find(*it)) != std::string::npos ) + result.push_back(ucalph[(pos+13) % 26]); + else + result.push_back(*it); + } + + return result; +} + +// function to output the rot13 of a file on std::cout +// returns false if an error occurred processing the file, true otherwise +// on entry, the argument is must be open for reading +int rot13_stream(std::istream& is) +{ + std::string line; + while (std::getline(is, line)) + { + if (!(std::cout << rot13(line) << "\n")) + return false; + } + return is.eof(); +} + +// the main program +int main(int argc, char* argv[]) +{ + if (argc == 1) // no arguments given + return rot13_stream(std::cin)? EXIT_SUCCESS : EXIT_FAILURE; + + std::ifstream file; + for (int i = 1; i < argc; ++i) + { + file.open(argv[i], std::ios::in); + if (!file) + { + std::cerr << argv[0] << ": could not open for reading: " << argv[i] << "\n"; + return EXIT_FAILURE; + } + if (!rot13_stream(file)) + { + if (file.eof()) + // no error occurred for file, so the error must have been in output + std::cerr << argv[0] << ": error writing to stdout\n"; + else + std::cerr << argv[0] << ": error reading from " << argv[i] << "\n"; + return EXIT_FAILURE; + } + file.clear(); + file.close(); + if (!file) + std::cerr << argv[0] << ": warning: closing failed for " << argv[i] << "\n"; + } + return EXIT_SUCCESS; +} diff --git a/Task/Rot-13/C++/rot-13-2.cpp b/Task/Rot-13/C++/rot-13-2.cpp new file mode 100644 index 0000000000..ed1b68752d --- /dev/null +++ b/Task/Rot-13/C++/rot-13-2.cpp @@ -0,0 +1,41 @@ +#include +#include +#include // output_filter +#include // put +#include +#include +namespace io = boost::iostreams; + +class rot_output_filter : public io::output_filter +{ +public: + explicit rot_output_filter(int r=13):rotby(r),negrot(alphlen-r){}; + + template + bool put(Sink& dest, int c){ + char uc = toupper(c); + + if(('A' <= uc) && (uc <= ('Z'-rotby))) + c = c + rotby; + else if ((('Z'-rotby) <= uc) && (uc <= 'Z')) + c = c - negrot; + return boost::iostreams::put(dest, c); + }; +private: + static const int alphlen = 26; + const int rotby; + const int negrot; +}; + +int main(int argc, char *argv[]) +{ + io::filtering_ostream out; + out.push(rot_output_filter(13)); + out.push(std::cout); + + if (argc == 1) out << std::cin.rdbuf(); + else for(int i = 1; i < argc; ++i){ + std::ifstream in(argv[i]); + out << in.rdbuf(); + } +} diff --git a/Task/Rot-13/C/rot-13.c b/Task/Rot-13/C/rot-13.c new file mode 100644 index 0000000000..a4ffc76630 --- /dev/null +++ b/Task/Rot-13/C/rot-13.c @@ -0,0 +1,44 @@ +#include +#include +#include + +#define MAXLINE 1024 + +char *rot13(char *s) +{ + char *p=s; + int upper; + + while(*p) { + upper=toupper(*p); + if(upper>='A' && upper<='M') *p+=13; + else if(upper>='N' && upper<='Z') *p-=13; + ++p; + } + return s; +} + +void rot13file(FILE *fp) +{ + static char line[MAXLINE]; + while(fgets(line, MAXLINE, fp)>0) fputs(rot13(line), stdout); +} + +int main(int argc, char *argv[]) +{ + int n; + FILE *fp; + + if(argc>1) { + for(n=1; n= i (int \a)) (<= i (int \m))) + (and (>= i (int \A)) (<= i (int \M)))) + (char (+ i 13)) + (or (and (>= i (int \n)) (<= i (int \z))) + (and (>= i (int \N)) (<= i (int \Z)))) + (char (- i 13)) + :else c))) + +(apply str (map rot-13 "abcxyzABCXYZ")) ;; output "nopklmNOPKLM" diff --git a/Task/Rot-13/Clojure/rot-13-2.clj b/Task/Rot-13/Clojure/rot-13-2.clj new file mode 100644 index 0000000000..67faccf345 --- /dev/null +++ b/Task/Rot-13/Clojure/rot-13-2.clj @@ -0,0 +1,7 @@ +(let [A (into #{} "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") + A-map (zipmap A (take 52 (drop 26 (cycle A))))] + + (defn rot13[in-str] + (reduce str (map #(if (A %1) (A-map %1) %1) in-str)))) + +(rot13 "The Quick Brown Fox Jumped Over The Lazy Dog!") ;; produces "Gur Dhvpx Oebja Sbk Whzcrq Bire Gur Ynml Qbt!" diff --git a/Task/Rot-13/Common-Lisp/rot-13-1.lisp b/Task/Rot-13/Common-Lisp/rot-13-1.lisp new file mode 100644 index 0000000000..3c16c0c92c --- /dev/null +++ b/Task/Rot-13/Common-Lisp/rot-13-1.lisp @@ -0,0 +1,13 @@ +(defconstant +alphabet+ +'(#\A #\B #\C #\D #\E #\F #\G #\H #\I #\J #\K #\L #\M #\N #\O #\P + #\Q #\R #\S #\T #\U #\V #\W #\X #\Y #\Z)) + +(defun rot13 (s) + (map 'string + (lambda (c &aux (n (position (char-upcase c) +alphabet+))) + (if n + (funcall + (if (lower-case-p c) #'char-downcase #'identity) + (nth (mod (+ 13 n) 26) +alphabet+)) + c)) + s)) diff --git a/Task/Rot-13/Common-Lisp/rot-13-2.lisp b/Task/Rot-13/Common-Lisp/rot-13-2.lisp new file mode 100644 index 0000000000..5a5a6293e4 --- /dev/null +++ b/Task/Rot-13/Common-Lisp/rot-13-2.lisp @@ -0,0 +1,12 @@ +(defun rot13 (string) + (map 'string + (lambda (char &aux (code (char-code char))) + (if (alpha-char-p char) + (if (> (- code (char-code (if (upper-case-p char) + #\A #\a))) 12) + (code-char (- code 13)) + (code-char (+ code 13))) + char)) + string)) + +(rot13 "Moron") ; -> "Zbeba" diff --git a/Task/Rot-13/D/rot-13-1.d b/Task/Rot-13/D/rot-13-1.d new file mode 100644 index 0000000000..b0b6648885 --- /dev/null +++ b/Task/Rot-13/D/rot-13-1.d @@ -0,0 +1,12 @@ +import std.stdio; +import std.ascii: letters, U = uppercase, L = lowercase; +import std.string: makeTrans, translate; + +immutable r13 = makeTrans(letters, + //U[13 .. $] ~ U[0 .. 13] ~ + U[13 .. U.length] ~ U[0 .. 13] ~ + L[13 .. L.length] ~ L[0 .. 13]); + +void main() { + writeln("This is the 1st test!".translate(r13, null)); +} diff --git a/Task/Rot-13/D/rot-13-2.d b/Task/Rot-13/D/rot-13-2.d new file mode 100644 index 0000000000..3c7c20373a --- /dev/null +++ b/Task/Rot-13/D/rot-13-2.d @@ -0,0 +1,21 @@ +import std.stdio, std.string, std.traits; + +pure S rot13(S)(in S s) if (isSomeString!S) { + return rot(s, 13); +} + +pure S rot(S)(in S s, in int key) if (isSomeString!S) { + auto r = s.dup; + + foreach (i, ref c; r) { + 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) r; +} + +void main() { + "Gur Dhvpx Oebja Sbk Whzcf Bire Gur Ynml Qbt!".rot13().writeln(); +} diff --git a/Task/Rot-13/E/rot-13.e b/Task/Rot-13/E/rot-13.e new file mode 100644 index 0000000000..0bd0d17c51 --- /dev/null +++ b/Task/Rot-13/E/rot-13.e @@ -0,0 +1,12 @@ +pragma.enable("accumulator") + +var rot13Map := [].asMap() +for a in ['a', 'A'] { + for i in 0..!26 { + rot13Map with= (a + i, E.toString(a + (i + 13) % 26)) + } +} + +def rot13(s :String) { + return accum "" for c in s { _ + rot13Map.fetch(c, fn{ c }) } +} diff --git a/Task/Rot-13/Erlang/rot-13.erl b/Task/Rot-13/Erlang/rot-13.erl new file mode 100644 index 0000000000..5924e058b2 --- /dev/null +++ b/Task/Rot-13/Erlang/rot-13.erl @@ -0,0 +1,6 @@ +rot13(Str) -> + F = fun(C) when (C >= $A andalso C =< $M); (C >= $a andalso C =< $m) -> C + 13; + (C) when (C >= $N andalso C =< $Z); (C >= $n andalso C =< $z) -> C - 13; + (C) -> C + end, + lists:map(F, Str). diff --git a/Task/Rot-13/Euphoria/rot-13.euphoria b/Task/Rot-13/Euphoria/rot-13.euphoria new file mode 100644 index 0000000000..60450ac0f4 --- /dev/null +++ b/Task/Rot-13/Euphoria/rot-13.euphoria @@ -0,0 +1,39 @@ +include std/types.e +include std/text.e + +atom FALSE = 0 +atom TRUE = not FALSE + +function Rot13( object oStuff ) + integer iOffset + integer bIsUpper + object oResult + sequence sAlphabet = "abcdefghijklmnopqrstuvwxyz" + if sequence(oStuff) then + oResult = repeat( 0, length( oStuff ) ) + for i = 1 to length( oStuff ) do + oResult[ i ] = Rot13( oStuff[ i ] ) + end for + else + bIsUpper = FALSE + if t_upper( oStuff ) then + bIsUpper = TRUE + oStuff = lower( oStuff ) + end if + iOffset = find( oStuff, sAlphabet ) + if iOffset != 0 then + iOffset += 13 + iOffset = remainder( iOffset, 26 ) + if iOffset = 0 then iOffset = 1 end if + oResult = sAlphabet[iOffset] + if bIsUpper then + oResult = upper(oResult) + end if + else + oResult = oStuff --sprintf( "%s", oStuff ) + end if + end if + return oResult +end function + +puts( 1, Rot13( "abjurer NOWHERE." ) & "\n" ) diff --git a/Task/Rot-13/FALSE/rot-13.false b/Task/Rot-13/FALSE/rot-13.false new file mode 100644 index 0000000000..1ac39160bc --- /dev/null +++ b/Task/Rot-13/FALSE/rot-13.false @@ -0,0 +1 @@ +[^$1+][$32|$$'z>'a@>|$[\%]?~[13\'m>[_]?+]?,]#% diff --git a/Task/Rot-13/Factor/rot-13.factor b/Task/Rot-13/Factor/rot-13.factor new file mode 100644 index 0000000000..8adaf6c0ff --- /dev/null +++ b/Task/Rot-13/Factor/rot-13.factor @@ -0,0 +1,24 @@ +#! /usr/bin/env factor + +USING: kernel io ascii math combinators sequences ; +IN: rot13 + +: rot-base ( ch ch -- ch ) [ - 13 + 26 mod ] keep + ; + +: rot13-ch ( ch -- ch ) + { + { [ dup letter? ] [ CHAR: a rot-base ] } + { [ dup LETTER? ] [ CHAR: A rot-base ] } + [ ] + } + cond ; + +: rot13 ( str -- str ) [ rot13-ch ] map ; + +: main ( -- ) + [ readln dup ] + [ rot13 print flush ] + while + drop ; + +MAIN: main diff --git a/Task/Rot-13/Fantom/rot-13.fantom b/Task/Rot-13/Fantom/rot-13.fantom new file mode 100644 index 0000000000..2575262101 --- /dev/null +++ b/Task/Rot-13/Fantom/rot-13.fantom @@ -0,0 +1,35 @@ +class Rot13 +{ + static Str rot13 (Str input) + { + Str result := "" + input.each |Int c| + { + if ((c.lower >= 'a') && (c.lower <= 'm')) + result += (c+13).toChar + else if ((c.lower >= 'n') && (c.lower <= 'z')) + result += (c-13).toChar + else + result += c.toChar + } + return result + } + + public static Void main (Str[] args) + { + if (args.size == 1) + { // process each line of given file + Str filename := args[0] + File(filename.toUri).eachLine |Str line| + { + echo (rot13(line)) + } + } + else + { + echo ("Test:") + Str text := "abcstuABCSTU123!+-" + echo ("Text $text becomes ${rot13(text)}") + } + } +} diff --git a/Task/Rot-13/Forth/rot-13-1.fth b/Task/Rot-13/Forth/rot-13-1.fth new file mode 100644 index 0000000000..aae7bf9eb3 --- /dev/null +++ b/Task/Rot-13/Forth/rot-13-1.fth @@ -0,0 +1,5 @@ +: r13 ( c -- o ) + dup 32 or \ tolower + dup [char] a [char] z 1+ within if + [char] m > if -13 else 13 then + + else drop then ; diff --git a/Task/Rot-13/Forth/rot-13-2.fth b/Task/Rot-13/Forth/rot-13-2.fth new file mode 100644 index 0000000000..0f013b5458 --- /dev/null +++ b/Task/Rot-13/Forth/rot-13-2.fth @@ -0,0 +1,21 @@ +: ,chars ( end start -- ) + do i c, loop ; + +: xlate create does> ( c -- c' ) + c@ ; + +xlate rot13 + char A 0 ,chars + char Z 1+ char N ,chars + char N char A ,chars + char a char Z 1+ ,chars + char z 1+ char n ,chars + char n char a ,chars + 256 char z 1+ ,chars + +: rot13-string ( addr len -- ) + over + swap do i c@ rot13 i c! loop ; + +: .rot13" ( string -- ) + [char] " parse 2dup rot13-string type ; + +.rot13" abjurer NOWHERE" \ nowhere ABJURER diff --git a/Task/Rot-13/Fortran/rot-13-1.f b/Task/Rot-13/Fortran/rot-13-1.f new file mode 100644 index 0000000000..97a64d6c04 --- /dev/null +++ b/Task/Rot-13/Fortran/rot-13-1.f @@ -0,0 +1,58 @@ +program test_rot_13 + + implicit none + integer, parameter :: len_max = 256 + integer, parameter :: unit = 10 + character (len_max) :: file + character (len_max) :: fmt + character (len_max) :: line + integer :: arg + integer :: arg_max + integer :: iostat + + write (fmt, '(a, i0, a)') '(a', len_max, ')' + arg_max = iargc () + if (arg_max > 0) then +! Encode all files listed on the command line. + do arg = 1, arg_max + call getarg (arg, file) + open (unit, file = file, iostat = iostat) + if (iostat /= 0) cycle + do + read (unit, fmt = fmt, iostat = iostat) line + if (iostat /= 0) exit + write (*, '(a)') trim (rot_13 (line)) + end do + close (unit) + end do + else +! Encode standard input. + do + read (*, fmt = fmt, iostat = iostat) line + if (iostat /= 0) exit + write (*, '(a)') trim (rot_13 (line)) + end do + end if + +contains + + function rot_13 (input) result (output) + + implicit none + character (len_max), intent (in) :: input + character (len_max) :: output + integer :: i + + output = input + do i = 1, len_trim (output) + select case (output (i : i)) + case ('A' : 'M', 'a' : 'm') + output (i : i) = char (ichar (output (i : i)) + 13) + case ('N' : 'Z', 'n' : 'z') + output (i : i) = char (ichar (output (i : i)) - 13) + end select + end do + + end function rot_13 + +end program test_rot_13 diff --git a/Task/Rot-13/Fortran/rot-13-2.f b/Task/Rot-13/Fortran/rot-13-2.f new file mode 100644 index 0000000000..59aab2418e --- /dev/null +++ b/Task/Rot-13/Fortran/rot-13-2.f @@ -0,0 +1,12 @@ +> cat foo.txt +foo +> cat bar.txt +bar +> ./rot_13 foo.txt bar.txt +sbb +one +> ./rot_13 < foo.txt +sbb +> cat foo.txt bar.txt | ./rot_13 +sbb +one diff --git a/Task/Rot-13/GAP/rot-13.gap b/Task/Rot-13/GAP/rot-13.gap new file mode 100644 index 0000000000..5cea6b8eb5 --- /dev/null +++ b/Task/Rot-13/GAP/rot-13.gap @@ -0,0 +1,27 @@ +rot13 := function(s) + local upper, lower, c, n, t; + upper := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + lower := "abcdefghijklmnopqrstuvwxyz"; + t := [ ]; + for c in s do + n := Position(upper, c); + if n <> fail then + Add(t, upper[((n+12) mod 26) + 1]); + else + n := Position(lower, c); + if n <> fail then + Add(t, lower[((n+12) mod 26) + 1]); + else + Add(t, c); + fi; + fi; + od; + return t; +end; + +a := "England expects that every man will do his duty"; +# "England expects that every man will do his duty" +b := rot13(a); +# "Ratynaq rkcrpgf gung rirel zna jvyy qb uvf qhgl" +c := rot13(b); +# "England expects that every man will do his duty" diff --git a/Task/Rot-13/GML/rot-13-1.gml b/Task/Rot-13/GML/rot-13-1.gml new file mode 100644 index 0000000000..20bc46b323 --- /dev/null +++ b/Task/Rot-13/GML/rot-13-1.gml @@ -0,0 +1,16 @@ +#define rot13 +{ + out = ''; + for (x = 1; x <= string_length(argument0); x += 1) { + working = ord(string_char_at(argument0, x)); + if ((working > 64) && (working < 91)) { + working += 13; + if (working > 90) working -= 26; + } else if ((working > 96) && (working < 123)) { + working += 13; + if (working > 122) working -= 26; + } + out = out + chr(working); + } + return out; +} diff --git a/Task/Rot-13/GML/rot-13-2.gml b/Task/Rot-13/GML/rot-13-2.gml new file mode 100644 index 0000000000..2382c02a82 --- /dev/null +++ b/Task/Rot-13/GML/rot-13-2.gml @@ -0,0 +1 @@ +show_message(rot13("My dog has fleas!")); diff --git a/Task/Rot-13/GW-BASIC/rot-13.gw-basic b/Task/Rot-13/GW-BASIC/rot-13.gw-basic new file mode 100644 index 0000000000..555de0c097 --- /dev/null +++ b/Task/Rot-13/GW-BASIC/rot-13.gw-basic @@ -0,0 +1,14 @@ +10 INPUT "Enter a string: ",A$ +20 GOSUB 50 +30 PRINT B$ +40 END +50 FOR I=1 TO LEN(A$) +60 N=ASC(MID$(A$,I,1)) +70 E=255 +80 IF N>64 AND N<91 THEN E=90 ' uppercase +90 IF N>96 AND N<123 THEN E=122 ' lowercase +100 IF E<255 THEN N=N+13 +110 IF N>E THEN N=N-26 +120 B$=B$+CHR$(N) +130 NEXT +140 RETURN diff --git a/Task/Rot-13/Gema/rot-13.gema b/Task/Rot-13/Gema/rot-13.gema new file mode 100644 index 0000000000..d948acd4cd --- /dev/null +++ b/Task/Rot-13/Gema/rot-13.gema @@ -0,0 +1,2 @@ +/[a-mA-M]/=@int-char{@add{@char-int{$1};13}} +/[n-zN-Z]/=@int-char{@sub{@char-int{$1};13}} diff --git a/Task/Rot-13/Go/rot-13.go b/Task/Rot-13/Go/rot-13.go new file mode 100644 index 0000000000..3e64859c97 --- /dev/null +++ b/Task/Rot-13/Go/rot-13.go @@ -0,0 +1,23 @@ +package main + +import ( + "fmt" + "strings" +) + +func rot13char(c rune) rune { + if c >= 'a' && c <= 'm' || c >= 'A' && c <= 'M' { + return c + 13 + } else if c >= 'n' && c <= 'z' || c >= 'N' && c <= 'Z' { + return c - 13 + } + return c +} + +func rot13(s string) string { + return strings.Map(rot13char, s) +} + +func main() { + fmt.Println(rot13("nowhere ABJURER")) +} diff --git a/Task/Rot-13/Groovy/rot-13-1.groovy b/Task/Rot-13/Groovy/rot-13-1.groovy new file mode 100644 index 0000000000..5f2d77bbcb --- /dev/null +++ b/Task/Rot-13/Groovy/rot-13-1.groovy @@ -0,0 +1,12 @@ +def rot13 = { String s -> + (s as List).collect { ch -> + switch (ch) { + case ('a'..'m') + ('A'..'M'): + return (((ch as char) + 13) as char) + case ('n'..'z') + ('N'..'Z'): + return (((ch as char) - 13) as char) + default: + return ch + } + }.inject ("") { string, ch -> string += ch} +} diff --git a/Task/Rot-13/Groovy/rot-13-2.groovy b/Task/Rot-13/Groovy/rot-13-2.groovy new file mode 100644 index 0000000000..48be1f2a93 --- /dev/null +++ b/Task/Rot-13/Groovy/rot-13-2.groovy @@ -0,0 +1 @@ +println rot13("Noyr jnf V, 'rer V fnj Ryon.") diff --git a/Task/Rot-13/Haskell/rot-13-1.hs b/Task/Rot-13/Haskell/rot-13-1.hs new file mode 100644 index 0000000000..47217d21bb --- /dev/null +++ b/Task/Rot-13/Haskell/rot-13-1.hs @@ -0,0 +1,7 @@ +import Data.Char + +rot13 :: Char -> Char +rot13 c + | toLower c >= 'a' && toLower c <= 'm' = chr (ord c + 13) + | toLower c >= 'n' && toLower c <= 'z' = chr (ord c - 13) + | otherwise = c diff --git a/Task/Rot-13/Haskell/rot-13-2.hs b/Task/Rot-13/Haskell/rot-13-2.hs new file mode 100644 index 0000000000..248e7f2dd8 --- /dev/null +++ b/Task/Rot-13/Haskell/rot-13-2.hs @@ -0,0 +1,23 @@ +import System.Environment +import System.IO +import System.Directory +import Control.Monad + +hInteract :: (String -> String) -> Handle -> Handle -> IO () +hInteract f hIn hOut = + hGetContents hIn >>= hPutStr hOut . f + +processByTemp :: (Handle -> Handle -> IO ()) -> String -> IO () +processByTemp f name = do + hIn <- openFile name ReadMode + let tmp = name ++ "$" + hOut <- openFile tmp WriteMode + f hIn hOut + hClose hIn + hClose hOut + removeFile name + renameFile tmp name + +process :: (Handle -> Handle -> IO ()) -> [String] -> IO () +process f [] = f stdin stdout +process f ns = mapM_ (processByTemp f) ns diff --git a/Task/Rot-13/Haskell/rot-13-3.hs b/Task/Rot-13/Haskell/rot-13-3.hs new file mode 100644 index 0000000000..873a673471 --- /dev/null +++ b/Task/Rot-13/Haskell/rot-13-3.hs @@ -0,0 +1,3 @@ +main = do + names <- getArgs + process (hInteract (map rot13)) names diff --git a/Task/Rot-13/HicEst/rot-13.hicest b/Task/Rot-13/HicEst/rot-13.hicest new file mode 100644 index 0000000000..1802304165 --- /dev/null +++ b/Task/Rot-13/HicEst/rot-13.hicest @@ -0,0 +1,16 @@ +CHARACTER c, txt='abc? XYZ!', cod*100 + + DO i = 1, LEN_TRIM(txt) + c = txt(i) + n = ICHAR(txt(i)) + IF( (c >= 'a') * (c <= 'm') + (c >= 'A') * (c <= 'M') ) THEN + c = CHAR( ICHAR(c) + 13 ) + ELSEIF( (c >= 'n') * (c <= 'z') + (c >= 'N') * (c <= 'Z') ) THEN + c = CHAR( ICHAR(c) - 13 ) + ENDIF + + cod(i) = c + ENDDO + + WRITE(ClipBoard, Name) txt, cod ! txt=abc? XYZ!; cod=nop? KLM!; +END diff --git a/Task/Rot-13/Icon/rot-13.icon b/Task/Rot-13/Icon/rot-13.icon new file mode 100644 index 0000000000..2995b90961 --- /dev/null +++ b/Task/Rot-13/Icon/rot-13.icon @@ -0,0 +1,14 @@ +procedure main(arglist) + file := open(arglist[1],"r") | &input + every write(rot13(|read(file))) +end + +procedure rot13(s) #: returns rot13(string) +static a,n +initial { + a := &lcase || &ucase + (&lcase || &lcase) ? n := ( move(13), move(*&lcase) ) + (&ucase || &ucase) ? n ||:= ( move(13), move(*&ucase) ) + } +return map(s,a,n) +end diff --git a/Task/Rot-13/J/rot-13.j b/Task/Rot-13/J/rot-13.j new file mode 100644 index 0000000000..365823ca3c --- /dev/null +++ b/Task/Rot-13/J/rot-13.j @@ -0,0 +1 @@ +rot13=: {&((65 97+/~i.2 13) |.@[} i.256)&.(a.&i.) diff --git a/Task/Rot-13/Java/rot-13.java b/Task/Rot-13/Java/rot-13.java new file mode 100644 index 0000000000..221964086e --- /dev/null +++ b/Task/Rot-13/Java/rot-13.java @@ -0,0 +1,49 @@ +import java.io.*; + +public class Rot13 { + public static void main(String[] args) { + BufferedReader in; + if (args.length >= 1) { + for (String file : args) { + try { + in = new BufferedReader(new FileReader(file)); + String line; + while ((line = in.readLine()) != null) { + System.out.println(convert(line)); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } else { + try { + in = new BufferedReader(new InputStreamReader(System.in)); + String line; + while ((line = in.readLine()) != null) { + System.out.println(convert(line)); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + public static String convert(String msg) { + StringBuilder retVal = new StringBuilder(); + for (char a : msg.toCharArray()) { + if (a >= 'A' && a <= 'Z') { + a += 13; + if (a > 'Z') { + a -= 26; + } + } else if (a >= 'a' && a <= 'z') { + a += 13; + if (a > 'z') { + a -= 26; + } + } + retVal.append(a); + } + return retVal.toString(); + } +} diff --git a/Task/Rot-13/JavaScript/rot-13.js b/Task/Rot-13/JavaScript/rot-13.js new file mode 100644 index 0000000000..3932bb85dc --- /dev/null +++ b/Task/Rot-13/JavaScript/rot-13.js @@ -0,0 +1,6 @@ +function rot13(c) { + return c.replace(/([a-m])|([n-z])/ig, function($0,$1,$2) { + return String.fromCharCode($1 ? $1.charCodeAt(0) + 13 : $2 ? $2.charCodeAt(0) - 13 : 0) || $0; + }); +} +rot13("ABJURER nowhere") // NOWHERE abjurer diff --git a/Task/Rot-13/K/rot-13.k b/Task/Rot-13/K/rot-13.k new file mode 100644 index 0000000000..fd3870b11f --- /dev/null +++ b/Task/Rot-13/K/rot-13.k @@ -0,0 +1,4 @@ + rot13: {a:+65 97+\:2 13#!26;_ci@[!256;a;:;|a]_ic x} + + rot13 "Testing! 1 2 3" +"Grfgvat! 1 2 3" diff --git a/Task/Rot-13/Liberty-BASIC/rot-13-1.liberty b/Task/Rot-13/Liberty-BASIC/rot-13-1.liberty new file mode 100644 index 0000000000..06d6ab5caa --- /dev/null +++ b/Task/Rot-13/Liberty-BASIC/rot-13-1.liberty @@ -0,0 +1,29 @@ +input "Type some text to be encoded, then ENTER. ";tx$ + +tex$ = Rot13$(tx$) +print tex$ +'check +print Rot13$(tex$) + +wait + +Function Rot13$(t$) + if t$="" then + Rot13$="" + exit function + end if + for i = 1 to len(t$) + c$=mid$(t$,i,1) + ch$=c$ + if (asc(c$)>=asc("A")) and (asc(c$)<=asc("Z")) then + ch$=chr$(asc(c$)+13) + if (asc(ch$)>asc("Z")) then ch$=chr$(asc(ch$)-26) + end if + if (asc(c$)>=asc("a")) and (asc(c$)<=asc("z")) then + ch$=chr$(asc(c$)+13) + if (asc(ch$)>asc("z")) then ch$=chr$(asc(ch$)-26) + end if + rot$=rot$+ch$ + next + Rot13$=rot$ + end function diff --git a/Task/Rot-13/Liberty-BASIC/rot-13-2.liberty b/Task/Rot-13/Liberty-BASIC/rot-13-2.liberty new file mode 100644 index 0000000000..b2ffb5ecd1 --- /dev/null +++ b/Task/Rot-13/Liberty-BASIC/rot-13-2.liberty @@ -0,0 +1,12 @@ +Function Rot13$(t$) + for i = 1 to len(t$) + ch$=mid$(t$,i,1) + if (asc(ch$)>=asc("A")) and (asc(ch$)<=asc("Z")) then + ch$=chr$(asc("A")+ (asc(ch$)-asc("A")+13) mod 26) + end if + if (asc(ch$)>=asc("a")) and (asc(ch$)<=asc("z")) then + ch$=chr$(asc("a")+ (asc(ch$)-asc("a")+13) mod 26) + end if + Rot13$=Rot13$+ch$ + next + end function diff --git a/Task/Rot-13/Locomotive-Basic/rot-13.locomotive b/Task/Rot-13/Locomotive-Basic/rot-13.locomotive new file mode 100644 index 0000000000..0d880989d8 --- /dev/null +++ b/Task/Rot-13/Locomotive-Basic/rot-13.locomotive @@ -0,0 +1,14 @@ +10 INPUT "Enter a string: ",a$ +20 GOSUB 50 +30 PRINT b$ +40 END +50 FOR i=1 TO LEN(a$) +60 n=ASC(MID$(a$,i,1)) +70 e=255 +80 IF n>64 AND n<91 THEN e=90 ' uppercase +90 IF n>96 AND n<123 THEN e=122 ' lowercase +100 IF e<255 THEN n=n+13 +110 IF n>e THEN n=n-26 +120 b$=b$+CHR$(n) +130 NEXT +140 RETURN diff --git a/Task/Rot-13/Logo/rot-13.logo b/Task/Rot-13/Logo/rot-13.logo new file mode 100644 index 0000000000..dfd6984358 --- /dev/null +++ b/Task/Rot-13/Logo/rot-13.logo @@ -0,0 +1,9 @@ +to rot13 :c + make "a difference ascii lowercase :c ascii "a + if or :a < 0 :a > 25 [output :c] + make "delta ifelse :a < 13 [13] [-13] + output char sum :delta ascii :c +end + +print map "rot13 "|abjurer NOWHERE| +nowhere ABJURER diff --git a/Task/Rot-13/Lua/rot-13.lua b/Task/Rot-13/Lua/rot-13.lua new file mode 100644 index 0000000000..fe4c0a490b --- /dev/null +++ b/Task/Rot-13/Lua/rot-13.lua @@ -0,0 +1,5 @@ +function rot(l, o) return (l < 26 and l > -1) and string.char((l+13)%26 + o) end +a, A = string.byte'a', string.byte'A' +val = io.read() +val = val:gsub("(.)", function(l) return rot(l:byte()-a,a) or rot(l:byte()-A,A) or l end) +print(val) diff --git a/Task/Rot-13/MATLAB/rot-13-1.m b/Task/Rot-13/MATLAB/rot-13-1.m new file mode 100644 index 0000000000..429c2d2278 --- /dev/null +++ b/Task/Rot-13/MATLAB/rot-13-1.m @@ -0,0 +1,19 @@ +function r=rot13(s) + if ischar(s) + r=s; % preallocation and copy of non-letters + for i=1:size(s,1) + for j=1:size(s,2) + if isletter(s(i,j)) + if s(i,j)>=97 % lower case + base = 97; + else % upper case + base = 65; + end + r(i,j)=char(mod(s(i,j)-base+13,26)+base); + end + end + end + else + error('Argument must be a CHAR') + end +end diff --git a/Task/Rot-13/MATLAB/rot-13-2.m b/Task/Rot-13/MATLAB/rot-13-2.m new file mode 100644 index 0000000000..5147a16b1b --- /dev/null +++ b/Task/Rot-13/MATLAB/rot-13-2.m @@ -0,0 +1,5 @@ +>> rot13('Hello World!') + +ans = + +Uryyb Jbeyq! diff --git a/Task/Rot-13/MATLAB/rot-13-3.m b/Task/Rot-13/MATLAB/rot-13-3.m new file mode 100644 index 0000000000..0977f3a6e9 --- /dev/null +++ b/Task/Rot-13/MATLAB/rot-13-3.m @@ -0,0 +1,13 @@ +function text = rot13(text) + if ischar(text) + + selectedLetters = ( (text >= 'A') & (text <= 'Z') ); %Select upper case letters + text(selectedLetters) = char( mod( text(selectedLetters)-'A'+13,26 )+'A' ); + + selectedLetters = ( (text >= 'a') & (text <= 'z') ); %Select lower case letters + text(selectedLetters) = char( mod( text(selectedLetters)-'a'+13,26 )+'a' ); + + else + error('Argument must be a string.') + end +end diff --git a/Task/Rot-13/MATLAB/rot-13-4.m b/Task/Rot-13/MATLAB/rot-13-4.m new file mode 100644 index 0000000000..06c00ea57f --- /dev/null +++ b/Task/Rot-13/MATLAB/rot-13-4.m @@ -0,0 +1,11 @@ +>> plainText = char((64:123)) + +plainText = + +@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{ + +>> rot13(plainText) + +ans = + +@NOPQRSTUVWXYZABCDEFGHIJKLM[\]^_`nopqrstuvwxyzabcdefghijklm{ diff --git a/Task/Rot-13/MMIX/rot-13.mmix b/Task/Rot-13/MMIX/rot-13.mmix new file mode 100644 index 0000000000..afaf0e035e --- /dev/null +++ b/Task/Rot-13/MMIX/rot-13.mmix @@ -0,0 +1,35 @@ +// main registers +p IS $255 % text pointer +c GREG % char +cc GREG % uppercase copy of c +u GREG % all purpose + + LOC Data_Segment + GREG @ +Test BYTE "dit is een bericht voor de keizer",#a,0 + + LOC #100 +Main LDA p,Test + TRAP 0,Fputs,StdOut % show text to encrypt + LDA p,Test % points to text to encrypt + JMP 4F +// do in place text encryption + % REPEAT +2H ADD cc,c,0 % copy char + SUB cc,cc,' ' % make uppercase + CMP u,cc,'A' + BN u,3F % IF c < 'A' OR c > 'Z' THEN next char + CMP u,cc,'Z' + BP u,3F + CMP u,cc,'N' % ELSE + BN u,1F % IF c < 'N' THEN encrypt 'up' + SUB c,c,26 % ELSE char ready for encrypt 'down' +1H INCL c,13 % encrypt char + STBU c,p % replace char with encrypted char +3H INCL p,1 % move to next char +4H LDBU c,p % get next char + PBNZ c,2B % UNTIL EOT +// print result + LDA p,Test + TRAP 0,Fputs,StdOut % show encrypted text + TRAP 0,Halt,0 diff --git a/Task/Rot-13/MUMPS/rot-13.mumps b/Task/Rot-13/MUMPS/rot-13.mumps new file mode 100644 index 0000000000..25f7827ffb --- /dev/null +++ b/Task/Rot-13/MUMPS/rot-13.mumps @@ -0,0 +1,9 @@ +Rot13(in) New low,rot,up + Set up="ABCDEFGHIJKLMNOPQRSTUVWXYZ" + Set low="abcdefghijklmnopqrstuvwxyz" + Set rot=$Extract(up,14,26)_$Extract(up,1,13) + Set rot=rot_$Extract(low,14,26)_$Extract(low,1,13) + Quit $Translate(in,up_low,rot) + +Write $$Rot13("Hello World!") ; Uryyb Jbeyq! +Write $$Rot13("ABCDEFGHIJKLMNOPQRSTUVWXYZ") ; NOPQRSTUVWXYZABCDEFGHIJKLM diff --git a/Task/Rot-13/Maple/rot-13.maple b/Task/Rot-13/Maple/rot-13.maple new file mode 100644 index 0000000000..816624e0de --- /dev/null +++ b/Task/Rot-13/Maple/rot-13.maple @@ -0,0 +1,2 @@ +> StringTools:-Encode( "The Quick Brown Fox Jumped Over The Lazy Dog!", encoding = rot13 ); + "Gur Dhvpx Oebja Sbk Whzcrq Bire Gur Ynml Qbt!" diff --git a/Task/Rot-13/Mathematica/rot-13.math b/Task/Rot-13/Mathematica/rot-13.math new file mode 100644 index 0000000000..764712660d --- /dev/null +++ b/Task/Rot-13/Mathematica/rot-13.math @@ -0,0 +1,6 @@ +ruleslower=Thread[#-> RotateLeft[#, 13]]&[CharacterRange["a", "z"]]; +rulesupper=Thread[#-> RotateLeft[#, 13]]&[CharacterRange["A", "Z"]]; +rules=Join[ruleslower,rulesupper]; +text="Hello World! Are you there!?" +text=StringReplace[text,rules] +text=StringReplace[text,rules] diff --git a/Task/Rot-13/Maxima/rot-13.maxima b/Task/Rot-13/Maxima/rot-13.maxima new file mode 100644 index 0000000000..3b84dce2e5 --- /dev/null +++ b/Task/Rot-13/Maxima/rot-13.maxima @@ -0,0 +1,19 @@ +rot13(a) := simplode(map(ascii, map(lambda([n], + if (n >= 65 and n <= 77) or (n >= 97 and n <= 109) then n + 13 + elseif (n >= 78 and n <= 90) or (n >= 110 and n <= 122) then n - 13 + else n), map(cint, sexplode(a)))))$ + +lowercase: "abcdefghijklmnopqrstuvwxyz"$ +uppercase: "ABCDEFGHIJKLMNOPQRSTUVWXYZ"$ + +rot13(lowercase); +"nopqrstuvwxyzabcdefghijklm" + +rot13(uppercase); +"NOPQRSTUVWXYZABCDEFGHIJKLM" + +rot13("The quick brown fox jumps over the lazy dog"); +"Gur dhvpx oebja sbk whzcf bire gur ynml qbt" + +rot13(%); +"The quick brown fox jumps over the lazy dog" diff --git a/Task/Rot-13/Mirah/rot-13.mirah b/Task/Rot-13/Mirah/rot-13.mirah new file mode 100644 index 0000000000..bf62e80098 --- /dev/null +++ b/Task/Rot-13/Mirah/rot-13.mirah @@ -0,0 +1,18 @@ +def rot13 (value:string) + result = "" + d = ' '.toCharArray[0] + value.toCharArray.each do |c| + testChar = Character.toLowerCase(c) + if testChar <= 'm'.toCharArray[0] && testChar >= 'a'.toCharArray[0] then + d = char(c + 13) + end + if testChar <= 'z'.toCharArray[0] && testChar >= 'n'.toCharArray[0] then + d = char(c - 13) + end + result += d + end + result +end + + +puts rot13("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") diff --git a/Task/Rot-13/Modula-3/rot-13.mod3 b/Task/Rot-13/Modula-3/rot-13.mod3 new file mode 100644 index 0000000000..de9573d8c9 --- /dev/null +++ b/Task/Rot-13/Modula-3/rot-13.mod3 @@ -0,0 +1,19 @@ +MODULE Rot13 EXPORTS Main; + +IMPORT Stdio, Rd, Wr; + +VAR c: CHAR; + +<*FATAL ANY*> + +BEGIN + WHILE NOT Rd.EOF(Stdio.stdin) DO + c := Rd.GetChar(Stdio.stdin); + IF c >= 'A' AND c <= 'M' OR c >= 'a' AND c <= 'm' THEN + c := VAL(ORD((ORD(c) + 13)), CHAR); + ELSIF c >= 'N' AND c <= 'Z' OR c >= 'n' AND c <= 'z' THEN + c := VAL(ORD((ORD(c) - 13)), CHAR); + END; + Wr.PutChar(Stdio.stdout, c); + END; +END Rot13. diff --git a/Task/Rot-13/NetRexx/rot-13.netrexx b/Task/Rot-13/NetRexx/rot-13.netrexx new file mode 100644 index 0000000000..038f834e0d --- /dev/null +++ b/Task/Rot-13/NetRexx/rot-13.netrexx @@ -0,0 +1,94 @@ +/* NetRexx */ +options replace format comments java crossref savelog symbols nobinary + +parse arg fileNames + +rdr = BufferedReader + +do + if fileNames.length > 0 then do + loop n_ = 1 for fileNames.words + fileName = fileNames.word(n_) + rdr = BufferedReader(FileReader(File(fileName))) + encipher(rdr) + end n_ + end + else do + rdr = BufferedReader(InputStreamReader(System.in)) + encipher(rdr) + end +catch ex = IOException + ex.printStackTrace +end + +return + +method encipher(rdr = BufferedReader) public static signals IOException + + loop label l_ forever + line = rdr.readLine + if line = null then leave l_ + say rot13(line) + end l_ + return + +method rot13(input) public static signals IllegalArgumentException + + return caesar(input, 13, isFalse) + +method caesar(input = Rexx, idx = int, caps = boolean) public static signals IllegalArgumentException + + if idx < 1 | idx > 25 then signal IllegalArgumentException() + + -- 12345678901234567890123456 + itab = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + shift = itab.length - idx + parse itab tl +(shift) tr + otab = tr || tl + + if caps then input = input.upper + + cipher = input.translate(itab || itab.lower, otab || otab.lower) + + return cipher + +method caesar_encipher(input = Rexx, idx = int, caps = boolean) public static signals IllegalArgumentException + + return caesar(input, idx, caps) + +method caesar_decipher(input = Rexx, idx = int, caps = boolean) public static signals IllegalArgumentException + + return caesar(input, int(26) - idx, isFalse) + +method caesar_encipher(input = Rexx, idx = int) public static signals IllegalArgumentException + + return caesar(input, idx, isFalse) + +method caesar_decipher(input = Rexx, idx = int) public static signals IllegalArgumentException + + return caesar(input, int(26) - idx, isFalse) + +method caesar_encipher(input = Rexx, idx = int, opt = Rexx) public static signals IllegalArgumentException + + return caesar(input, idx, opt) + +method caesar_decipher(input = Rexx, idx = int, opt = Rexx) public static signals IllegalArgumentException + + return caesar(input, int(26) - idx, opt) + +method caesar(input = Rexx, idx = int, opt = Rexx) public static signals IllegalArgumentException + + if opt.upper.abbrev('U') >= 1 then caps = isTrue + else caps = isFalse + + return caesar(input, idx, caps) + +method caesar(input = Rexx, idx = int) public static signals IllegalArgumentException + + return caesar(input, idx, isFalse) + +method isTrue public static returns boolean + return (1 == 1) + +method isFalse public static returns boolean + return \isTrue diff --git a/Task/Rot-13/OCaml/rot-13-1.ocaml b/Task/Rot-13/OCaml/rot-13-1.ocaml new file mode 100644 index 0000000000..5440b0d801 --- /dev/null +++ b/Task/Rot-13/OCaml/rot-13-1.ocaml @@ -0,0 +1,4 @@ +let rot13 c = match c with + | 'A'..'M' | 'a'..'m' -> char_of_int (int_of_char c + 13) + | 'N'..'Z' | 'n'..'z' -> char_of_int (int_of_char c - 13) + | _ -> c diff --git a/Task/Rot-13/OCaml/rot-13-2.ocaml b/Task/Rot-13/OCaml/rot-13-2.ocaml new file mode 100644 index 0000000000..db9a8067b9 --- /dev/null +++ b/Task/Rot-13/OCaml/rot-13-2.ocaml @@ -0,0 +1,11 @@ +let rot13_str s = + let len = String.length s in + let result = String.create len in + for i = 0 to len - 1 do + result.[i] <- rot13 s.[i] + done; + result + +(* or in OCaml 4.00+: + let rot13_str = String.map rot13 +*) diff --git a/Task/Rot-13/OCaml/rot-13-3.ocaml b/Task/Rot-13/OCaml/rot-13-3.ocaml new file mode 100644 index 0000000000..e9dce2e619 --- /dev/null +++ b/Task/Rot-13/OCaml/rot-13-3.ocaml @@ -0,0 +1,5 @@ +let () = + try while true do + String.iter (fun c -> print_char (rot13 c)) (read_line()); + print_newline() + done with End_of_file -> () diff --git a/Task/Rot-13/Objeck/rot-13.objeck b/Task/Rot-13/Objeck/rot-13.objeck new file mode 100644 index 0000000000..7068c5f5e1 --- /dev/null +++ b/Task/Rot-13/Objeck/rot-13.objeck @@ -0,0 +1,25 @@ +bundle Default { + class Rot13 { + function : Main(args : String[]) ~ Nil { + Rot13("nowhere ABJURER")->PrintLine(); + } + + function : native : Rot13(text : String) ~ String { + rot := ""; + each(i : text) { + c := text->Get(i); + if(c >= 'a' & c <= 'm' | c >= 'A' & c <= 'M') { + rot->Append(c + 13); + } + else if(c >= 'n' & c <= 'z' | c >= 'N' & c <= 'Z') { + rot->Append(c - 13); + } + else { + rot->Append(c); + }; + }; + + return rot; + } + } +} diff --git a/Task/Rot-13/Oz/rot-13.oz b/Task/Rot-13/Oz/rot-13.oz new file mode 100644 index 0000000000..a758d3c8e3 --- /dev/null +++ b/Task/Rot-13/Oz/rot-13.oz @@ -0,0 +1,14 @@ +declare + fun {RotChar C} + if C >= &A andthen C =< &Z then &A + (C - &A + 13) mod 26 + elseif C >= &a andthen C =< &z then &a + (C - &a + 13) mod 26 + else C + end + end + + fun {Rot13 S} + {Map S RotChar} + end +in + {System.showInfo {Rot13 "NOWHERE Abjurer 42"}} + {System.showInfo {Rot13 {Rot13 "NOWHERE Abjurer 42"}}} diff --git a/Task/Rot-13/PARI-GP/rot-13.pari b/Task/Rot-13/PARI-GP/rot-13.pari new file mode 100644 index 0000000000..6d8bcfbaf2 --- /dev/null +++ b/Task/Rot-13/PARI-GP/rot-13.pari @@ -0,0 +1,7 @@ +rot13(s)={ + s=Vecsmall(s); + for(i=1,#s, + if(s[i]>109&s[i]<123,s[i]-=13,if(s[i]<110&s[i]>96,s[i]+=13,if(s[i]>77&s[i]<91,s[i]-=13,if(s[i]<78&s[i]>64,s[i]+=13)))) + ); + Strchr(s) +}; diff --git a/Task/Rot-13/PHP/rot-13-1.php b/Task/Rot-13/PHP/rot-13-1.php new file mode 100644 index 0000000000..10d1c7c340 --- /dev/null +++ b/Task/Rot-13/PHP/rot-13-1.php @@ -0,0 +1 @@ +echo str_rot13('foo'), "\n"; diff --git a/Task/Rot-13/PHP/rot-13-2.php b/Task/Rot-13/PHP/rot-13-2.php new file mode 100644 index 0000000000..415a8f6bdd --- /dev/null +++ b/Task/Rot-13/PHP/rot-13-2.php @@ -0,0 +1,8 @@ + diff --git a/Task/Rot-13/PL-I/rot-13.pli b/Task/Rot-13/PL-I/rot-13.pli new file mode 100644 index 0000000000..6f9d899d5f --- /dev/null +++ b/Task/Rot-13/PL-I/rot-13.pli @@ -0,0 +1,17 @@ +rotate: procedure (in) options (main); /* 2 March 2011 */ + declare in character (100) varying; + declare line character (500) varying; + declare input file; + + open file (input) title ('/' || in || ',type(text),recsize(500)' ); + + on endfile (input) stop; + + do forever; + get file (input) edit (line) (L); + line = translate ( + line, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', + 'NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm'); + put edit (line) (a); put skip; + end; +end; diff --git a/Task/Rot-13/Pascal/rot-13.pascal b/Task/Rot-13/Pascal/rot-13.pascal new file mode 100644 index 0000000000..6917c90051 --- /dev/null +++ b/Task/Rot-13/Pascal/rot-13.pascal @@ -0,0 +1,29 @@ +program rot13(input, output); + +function rot13(someText: string): string; +var + i: integer; + ch: char; + resultText: string = ''; + +begin + for i := 1 to Length(someText) do begin + ch := someText[i]; + case ch of + 'A' .. 'M', 'a' .. 'm': ch := chr(ord(ch)+13); + 'N' .. 'Z', 'n' .. 'z': ch := chr(ord(ch)-13) + end; + resultText := resultText + ch + end; + rot13 := resultText +end; + +var + line: string; + +begin + while not eof(input) do begin + readln(line); + writeln(rot13(line)) + end +end. diff --git a/Task/Rot-13/Perl-6/rot-13.pl6 b/Task/Rot-13/Perl-6/rot-13.pl6 new file mode 100644 index 0000000000..36bcaa5d3b --- /dev/null +++ b/Task/Rot-13/Perl-6/rot-13.pl6 @@ -0,0 +1,4 @@ +sub rot13 { $^s.trans: 'A..Za..z' => 'N..ZA..Mn..za..m' } + +multi MAIN () { print rot13 slurp } +multi MAIN (*@files) { print rot13 [~] map &slurp, @files } diff --git a/Task/Rot-13/Perl/rot-13-1.pl b/Task/Rot-13/Perl/rot-13-1.pl new file mode 100644 index 0000000000..ee3074a0a0 --- /dev/null +++ b/Task/Rot-13/Perl/rot-13-1.pl @@ -0,0 +1,7 @@ +sub rot13 { + my $string = shift; + $string =~ tr/A-Za-z/N-ZA-Mn-za-m/; + return $string; +} + +print rot13($_) while (<>); diff --git a/Task/Rot-13/Perl/rot-13-2.pl b/Task/Rot-13/Perl/rot-13-2.pl new file mode 100644 index 0000000000..c0dac877ab --- /dev/null +++ b/Task/Rot-13/Perl/rot-13-2.pl @@ -0,0 +1 @@ +perl -pe 'tr/A-Za-z/N-ZA-Mn-za-m/' diff --git a/Task/Rot-13/PicoLisp/rot-13-1.l b/Task/Rot-13/PicoLisp/rot-13-1.l new file mode 100644 index 0000000000..10d9d24721 --- /dev/null +++ b/Task/Rot-13/PicoLisp/rot-13-1.l @@ -0,0 +1,7 @@ +(de rot13-Ch (C) + (if + (or + (member C '`(apply circ (chop "ABCDEFGHIJKLMNOPQRSTUVWXYZ"))) + (member C '`(apply circ (chop "abcdefghijklmnopqrstuvwxyz"))) ) + (get @ 14) + C ) ) diff --git a/Task/Rot-13/PicoLisp/rot-13-2.l b/Task/Rot-13/PicoLisp/rot-13-2.l new file mode 100644 index 0000000000..8fcdd8cc01 --- /dev/null +++ b/Task/Rot-13/PicoLisp/rot-13-2.l @@ -0,0 +1,7 @@ +(de rot13-Ch (C) + (cond + ((>= "M" (uppc C) "A") + (char (+ (char C) 13)) ) + ((>= "Z" (uppc C) "N") + (char (- (char C) 13)) ) + (T C) ) ) diff --git a/Task/Rot-13/PicoLisp/rot-13-3.l b/Task/Rot-13/PicoLisp/rot-13-3.l new file mode 100644 index 0000000000..ab9a042d49 --- /dev/null +++ b/Task/Rot-13/PicoLisp/rot-13-3.l @@ -0,0 +1,3 @@ +(de rot13-stdIn () + (while (line) + (prinl (mapcar rot13-Ch @)) ) ) diff --git a/Task/Rot-13/Pike/rot-13.pike b/Task/Rot-13/Pike/rot-13.pike new file mode 100644 index 0000000000..b4ff3b2697 --- /dev/null +++ b/Task/Rot-13/Pike/rot-13.pike @@ -0,0 +1,6 @@ +import Crypto; + +int main(){ + string r = rot13("Hello, World"); + write(r + "\n"); +} diff --git a/Task/Rot-13/Pop11/rot-13.pop11 b/Task/Rot-13/Pop11/rot-13.pop11 new file mode 100644 index 0000000000..d36861f6c0 --- /dev/null +++ b/Task/Rot-13/Pop11/rot-13.pop11 @@ -0,0 +1,14 @@ +define rot13(s); + lvars j, c; + for j from 1 to length(s) do + s(j) -> c; + if `A` <= c and c <= `M` or `a` <= c and c <= `m` then + c + 13 -> s(j); + elseif `N` <= c and c <= `Z` or `n` <= c and c <= `z` then + c - 13 -> s(j); + endif; + endfor; + s; +enddefine; + +rot13('NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm') => diff --git a/Task/Rot-13/PostScript/rot-13.ps b/Task/Rot-13/PostScript/rot-13.ps new file mode 100644 index 0000000000..25b564058c --- /dev/null +++ b/Task/Rot-13/PostScript/rot-13.ps @@ -0,0 +1,10 @@ +/r13 { +4 dict begin + /rotc { + { + {{{64 gt} {91 lt}} all?} {65 - 13 + 26 mod 65 +} is? + {{{95 gt} {123 lt}} all?} {97 - 13 + 26 mod 97 +} is? + } cond + }. + {rotc} map cvstr +end}. diff --git a/Task/Rot-13/PowerShell/rot-13.psh b/Task/Rot-13/PowerShell/rot-13.psh new file mode 100644 index 0000000000..1bcb78558c --- /dev/null +++ b/Task/Rot-13/PowerShell/rot-13.psh @@ -0,0 +1,10 @@ +Function ROT13($String) +{ +$Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz " +$Cipher = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm " + Foreach($Char in $String.ToCharArray()) + { + $NewString += $Cipher.Chars($Alphabet.IndexOf($Char)) + } + Return $NewString +} diff --git a/Task/Rot-13/Prolog/rot-13-1.pro b/Task/Rot-13/Prolog/rot-13-1.pro new file mode 100644 index 0000000000..8f938c009a --- /dev/null +++ b/Task/Rot-13/Prolog/rot-13-1.pro @@ -0,0 +1,7 @@ +rot13(Str, SR) :- + maplist(rot, Str, Str1), + string_to_list(SR, Str1). + +rot(C, C1) :- + ( member(C, "abcdefghijklmABCDEFGHIJKLM") -> C1 is C+13; + ( member(C, "nopqrstuvwxyzNOPQRSTUVWXYZ") -> C1 is C-13; C1 = C)). diff --git a/Task/Rot-13/Prolog/rot-13-2.pro b/Task/Rot-13/Prolog/rot-13-2.pro new file mode 100644 index 0000000000..faf719fb98 --- /dev/null +++ b/Task/Rot-13/Prolog/rot-13-2.pro @@ -0,0 +1,2 @@ + ?- rot13("The Quick Brown Fox Jumped Over The Lazy Dog!", SR). +SR = "Gur Dhvpx Oebja Sbk Whzcrq Bire Gur Ynml Qbt!". diff --git a/Task/Rot-13/PureBasic/rot-13.purebasic b/Task/Rot-13/PureBasic/rot-13.purebasic new file mode 100644 index 0000000000..3d1edb6ad3 --- /dev/null +++ b/Task/Rot-13/PureBasic/rot-13.purebasic @@ -0,0 +1,29 @@ +Declare.s Rot13(text_to_code.s) + +If OpenConsole() + Define txt$ + + Print("Enter a string to encode: "): txt$=Input() + + PrintN("Coded : "+Rot13(txt$)) + PrintN("Decoded: "+Rot13(Rot13(txt$))) + + Print("Press ENTER to quit."): Input() + CloseConsole() +EndIf + +Procedure.s Rot13(s.s) + Protected.i i + Protected.s t, u + For i=1 To Len(s) + t=Mid(s,i,1) + Select Asc(t) + Case Asc("a") To Asc("m"), Asc("A") To Asc("M") + t=chr(Asc(t)+13) + Case Asc("n") To Asc("z"), Asc("N") To Asc("Z") + t=chr(Asc(t)-13) + EndSelect + u+t + Next + ProcedureReturn u +EndProcedure diff --git a/Task/Rot-13/Python/rot-13-1.py b/Task/Rot-13/Python/rot-13-1.py new file mode 100644 index 0000000000..8feb958ea7 --- /dev/null +++ b/Task/Rot-13/Python/rot-13-1.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +import string +def rot13(s): + """Implement the rot-13 encoding function: "rotate" each letter by the + letter that's 13 steps from it (wrapping from z to a) + """ + return s.translate( + string.maketrans( + string.ascii_uppercase + string.ascii_lowercase, + string.ascii_uppercase[13:] + string.ascii_uppercase[:13] + + string.ascii_lowercase[13:] + string.ascii_lowercase[:13] + ) + ) +if __name__ == "__main__": + """Peform line-by-line rot-13 encoding on any files listed on our + command line or act as a standard UNIX filter (if no arguments + specified). + """ + import fileinput + for line in fileinput.input(): + print rot13(line), # (Note the trailing comma; avoid double-spacing our output)! diff --git a/Task/Rot-13/Python/rot-13-2.py b/Task/Rot-13/Python/rot-13-2.py new file mode 100644 index 0000000000..2b433c8cac --- /dev/null +++ b/Task/Rot-13/Python/rot-13-2.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +import string +def rot13(s): + """Implement the rot-13 encoding function: "rotate" each letter by the + letter that's 13 steps from it (wrapping from z to a) + """ + return s.translate( + str.maketrans( + string.ascii_uppercase + string.ascii_lowercase, + string.ascii_uppercase[13:] + string.ascii_uppercase[:13] + + string.ascii_lowercase[13:] + string.ascii_lowercase[:13] + ) + ) +if __name__ == "__main__": + """Peform line-by-line rot-13 encoding on any files listed on our + command line or act as a standard UNIX filter (if no arguments + specified). + """ + import fileinput + for line in fileinput.input(): + print(rot13(line), end="") diff --git a/Task/Rot-13/R/rot-13.r b/Task/Rot-13/R/rot-13.r new file mode 100644 index 0000000000..96c498d74b --- /dev/null +++ b/Task/Rot-13/R/rot-13.r @@ -0,0 +1,10 @@ +rot13 <- function(x) +{ + old <- paste(letters, LETTERS, collapse="", sep="") + new <- paste(substr(old, 27, 52), substr(old, 1, 26), sep="") + chartr(old, new, x) +} +x <- "The Quick Brown Fox Jumps Over The Lazy Dog!.,:;'#~[]{}" +rot13(x) # "Gur Dhvpx Oebja Sbk Whzcf Bire Gur Ynml Qbt!.,:;'#~[]{}" +x2 <- paste(letters, LETTERS, collapse="", sep="") +rot13(x2) # "nNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmM" diff --git a/Task/Rot-13/REBOL/rot-13.rebol b/Task/Rot-13/REBOL/rot-13.rebol new file mode 100644 index 0000000000..e4499383ef --- /dev/null +++ b/Task/Rot-13/REBOL/rot-13.rebol @@ -0,0 +1,84 @@ +REBOL [ + Title: "Rot-13" + Date: 2009-12-14 + Author: oofoe + URL: http://rosettacode.org/wiki/Rot-13 +] + +; Test data has upper and lower case characters as well as characters +; that should not be transformed, like numbers, spaces and symbols. + +text: "This is a 28-character test!" + +print "Using cipher table:" + +; I build a set of correspondence lists here. 'x' is the letters from +; A-Z, in both upper and lowercase form. Note that REBOL can iterate +; directly over the alphabetic character sequence in the for loop. 'y' +; is the cipher form, 'x' rotated by 26 characters (remember, I have +; the lower and uppercase forms together). 'r' holds the final result, +; built as I iterate across the 'text' string. I search for the +; current character in the plaintext list ('x'), if I find it, I get +; the corresponding character from the ciphertext list +; ('y'). Otherwise, I pass the character through untransformed, then +; return the final string. + +rot-13: func [ + "Encrypt or decrypt rot-13 with tables." + text [string!] "Text to en/decrypt." + /local x y r i c +] [ + x: copy "" for i #"a" #"z" 1 [append x rejoin [i uppercase i]] + y: rejoin [copy skip x 26 copy/part x 26] + r: copy "" + + repeat i text [append r either c: find/case x i [y/(index? c)][i]] + r +] + +; Note that I am setting the 'text' variable to the result of rot-13 +; so I can reuse it again on the next call. The rot-13 algorithm is +; reversible, so I can just run it again without modification to decrypt. + +print [" Encrypted:" text: rot-13 text] +print [" Decrypted:" text: rot-13 text] + + +print "Using parse:" + +clamp: func [ + "Contain a value within two enclosing values. Wraps if necessary." + x v y +][ + x: to-integer x v: to-integer v y: to-integer y + case [v < x [y - v] v > y [v - y + x - 1] true v] +] + +; I'm using REBOL's 'parse' word here. I set up character sets for +; upper and lower-case letters, then let parse walk across the +; text. It looks for matches to upper-case letters, then lower-case, +; then skips to the next one if it can't find either. If a matching +; character is found, it's mathematically incremented by 13 and +; clamped to the appropriate character range. parse changes the +; character in place in the string, hence this is a destructive +; operation. + +rot-13: func [ + "Encrypt or decrypt rot-13 with parse." + text [string!] "Text to en/decrypt. Note: Destructive!" +] [ + u: charset [#"A" - #"Z"] + l: charset [#"a" - #"z"] + + parse text [some [ + i: ; Current position. + u (i/1: to-char clamp #"A" i/1 + 13 #"Z") | ; Upper case. + l (i/1: to-char clamp #"a" i/1 + 13 #"z") | ; Lower case. + skip]] ; Ignore others. + text +] + +; As you see, I don't need to re-assign 'text' anymore. + +print [" Encrypted:" rot-13 text] +print [" Decrypted:" rot-13 text] diff --git a/Task/Rot-13/REXX/rot-13.rexx b/Task/Rot-13/REXX/rot-13.rexx new file mode 100644 index 0000000000..7add3dfbca --- /dev/null +++ b/Task/Rot-13/REXX/rot-13.rexx @@ -0,0 +1,30 @@ +/*REXX program to encode several text strings with ROT 13 algorithm. */ +aa = 'foo' +say 'simple text = 'aa +say ' rot13 text = 'rot13(aa) +say + +bb = 'bar' +say 'simple text = 'bb +say ' rot13 text = 'rot13(bb) +say + +cc = "Noyr jnf V, 'rer V fnj Ryon." +say 'simple text = 'cc +say ' rot13 text = 'rot13(cc) +say + +dd = 'abc? ABC!' +say 'simple text = 'dd +say ' rot13 text = 'rot13(dd) +say + +ee = 'abjurer NOWHERE' +say 'simple text = 'ee +say ' rot13 text = 'rot13(ee) +exit /*stick a fork in it, we're done.*/ + +/*──────────────────────────────────ROT13 subroutine────────────────────*/ +rot13: return translate(arg(1),, + 'abcdefghijklmABCDEFGHIJKLMnopqrstuvwxyzNOPQRSTUVWXYZ',, + 'nopqrstuvwxyzNOPQRSTUVWXYZabcdefghijklmABCDEFGHIJKLM') diff --git a/Task/Rot-13/Racket/rot-13.rkt b/Task/Rot-13/Racket/rot-13.rkt new file mode 100644 index 0000000000..24d815d621 --- /dev/null +++ b/Task/Rot-13/Racket/rot-13.rkt @@ -0,0 +1,17 @@ +#!/bin/env racket +#lang racket/base + +(define (run i o) + (for ([ch (in-producer regexp-match #f #rx#"[a-zA-Z]" i 0 #f o)]) + (define b (bytes-ref (car ch) 0)) + (define a (if (< b 96) 65 97)) + (write-byte (+ (modulo (+ 13 (- b a)) 26) a)))) + +(require racket/cmdline) +(command-line + #:help-labels "(\"-\" specifies standard input)" + #:args files + (for ([f (if (null? files) '("-") files)]) + (if (equal? f "-") + (run (current-input-port) (current-output-port)) + (call-with-input-file f ( (i) (run i (current-output-port))))))) diff --git a/Task/Rot-13/Retro/rot-13.retro b/Task/Rot-13/Retro/rot-13.retro new file mode 100644 index 0000000000..9003155883 --- /dev/null +++ b/Task/Rot-13/Retro/rot-13.retro @@ -0,0 +1,11 @@ +{{ + : rotate ( cb-c ) tuck - 13 + 26 mod + ; + : rotate? ( c-c ) + dup 'a 'z within [ 'a rotate ] ifTrue + dup 'A 'Z within [ 'A rotate ] ifTrue ; +---reveal--- + : rot13 ( s-s ) dup [ [ @ rotate? ] sip ! ] ^types'STRING each@ ; +}} + +"abcdef123GHIJKL" rot13 dup puts cr rot13 puts +"abjurer NOWHERE" rot13 puts diff --git a/Task/Rot-13/Ruby/rot-13.rb b/Task/Rot-13/Ruby/rot-13.rb new file mode 100644 index 0000000000..b96ce180dd --- /dev/null +++ b/Task/Rot-13/Ruby/rot-13.rb @@ -0,0 +1,9 @@ +# Returns a copy of _s_ with rot13 encoding. +def rot13(s) + s.tr('A-Za-z', 'N-ZA-Mn-za-m') +end + +# Perform rot13 on files from command line, or standard input. +while line = ARGF.gets + print rot13(line) +end diff --git a/Task/Rot-13/Run-BASIC/rot-13.run b/Task/Rot-13/Run-BASIC/rot-13.run new file mode 100644 index 0000000000..5c348a43be --- /dev/null +++ b/Task/Rot-13/Run-BASIC/rot-13.run @@ -0,0 +1,14 @@ +INPUT "Enter a string: "; s$ +ans$ = "" +FOR a = 1 TO LEN(s$) + letter$ = MID$(s$, a, 1) + IF letter$ >= "A" AND letter$ <= "Z" THEN + char$ = CHR$(ASC(letter$) + 13) + IF char$ > "Z" THEN char$ = CHR$(ASC(char$) - 26) + else + if letter$ >= "a" AND letter$ <= "z" THEN char$ = CHR$(ASC(letter$) + 13) + IF char$ > "z" THEN char$ = CHR$(ASC(char$) - 26) ELSE char$ = letter$ + END IF + ans$ = ans$ + char$ +NEXT a +PRINT ans$ diff --git a/Task/Rot-13/SNOBOL4/rot-13.sno b/Task/Rot-13/SNOBOL4/rot-13.sno new file mode 100644 index 0000000000..0f4b047226 --- /dev/null +++ b/Task/Rot-13/SNOBOL4/rot-13.sno @@ -0,0 +1,21 @@ +* # Function using replace( ) + define('rot13(s)u1,u2,l1,l2') :(rot13_end) +rot13 &ucase len(13) . u1 rem . u2 + &lcase len(13) . l1 rem . l2 + rot13 = replace(s,&ucase &lcase,u2 u1 l2 l1) :(return) +rot13_end + +* # Function using pattern + define('rot13s(s)c') + alfa = &ucase &ucase &lcase &lcase :(rot13s_end) +rot13s s len(1) . c = :f(return) + alfa break(c) len(13) len(1) . c + rot13s = rot13s c :(rot13s) +rot13s_end + +* # Test and display both + str = rot13("I abjure the $19.99 trinket!") + output = str; output = rot13(str) + str = rot13s("He's a real Nowhere Man.") + output = str; output = rot13s(str) +end diff --git a/Task/Rot-13/Scala/rot-13.scala b/Task/Rot-13/Scala/rot-13.scala new file mode 100644 index 0000000000..e3cfc285cd --- /dev/null +++ b/Task/Rot-13/Scala/rot-13.scala @@ -0,0 +1,12 @@ +scala> def rot13(s: String) = s map { + | case c if 'a' <= c.toLower && c.toLower <= 'm' => c + 13 toChar + | case c if 'n' <= c.toLower && c.toLower <= 'z' => c - 13 toChar + | case c => c + | } +rot13: (s: String)String + +scala> rot13("7 Cities of Gold.") +res61: String = 7 Pvgvrf bs Tbyq. + +scala> rot13(res61) +res62: String = 7 Cities of Gold. diff --git a/Task/Rot-13/Scheme/rot-13.ss b/Task/Rot-13/Scheme/rot-13.ss new file mode 100644 index 0000000000..e3bf6e20ef --- /dev/null +++ b/Task/Rot-13/Scheme/rot-13.ss @@ -0,0 +1,14 @@ +(define (rot13 str) + (define (rot13-char c) + (integer->char (+ (char->integer c) + (cond ((and (char>=? c #\a) (char=? c #\A) (char=? c #\n) (char<=? c #\z)) + -13) + ((and (char>=? c #\N) (char<=? c #\Z)) + -13) + (else + 0))))) + (list->string (map rot13-char (string->list str)))) diff --git a/Task/Rot-13/Seed7/rot-13.seed7 b/Task/Rot-13/Seed7/rot-13.seed7 new file mode 100644 index 0000000000..71a6f49abd --- /dev/null +++ b/Task/Rot-13/Seed7/rot-13.seed7 @@ -0,0 +1,17 @@ +$ include "seed7_05.s7i"; + +const proc: main is func + local + var char: ch is ' '; + begin + ch := getc(IN); + while not eof(IN) do + if (ch >= 'a' and ch <= 'm') or (ch >= 'A' and ch <= 'M') then + ch := chr(ord(ch) + 13); + elsif (ch >= 'n' and ch <= 'z') or (ch >= 'N' and ch <= 'Z') then + ch := chr(ord(ch) - 13); + end if; + write(ch); + ch := getc(IN); + end while; + end func; diff --git a/Task/Rot-13/Slate/rot-13-1.slate b/Task/Rot-13/Slate/rot-13-1.slate new file mode 100644 index 0000000000..c42e8fb094 --- /dev/null +++ b/Task/Rot-13/Slate/rot-13-1.slate @@ -0,0 +1,23 @@ +#!/usr/local/bin/slate + +ch@(String Character traits) rot13 +[| value | + upper ::= ch isUppercase. + value := ch toLowercase as: Integer. + (value >= 97) /\ [value < 110] + ifTrue: [value += 13] + ifFalse: [(value > 109) /\ [value <= 122] + ifTrue: [value -= 13]]. + upper + ifTrue: [(value as: String Character) toUppercase] + ifFalse: [value as: String Character] +]. + +lobby define: #Rot13Encoder &parents: {Encoder}. + +c@(Rot13Encoder traits) convert +[ + [c in isAtEnd] whileFalse: [c out nextPut: c in next rot13]. +]. + +(Rot13Encoder newFrom: Console reader to: Console writer) convert. diff --git a/Task/Rot-13/Slate/rot-13-2.slate b/Task/Rot-13/Slate/rot-13-2.slate new file mode 100644 index 0000000000..85124b71ee --- /dev/null +++ b/Task/Rot-13/Slate/rot-13-2.slate @@ -0,0 +1,22 @@ +ch@(String Character traits) rot13 +[| value | + upper ::= ch isUppercase. + value := ch toLowercase as: Integer. + (value >= 97) /\ [value < 110] + ifTrue: [value += 13] + ifFalse: [(value > 109) /\ [value <= 122] + ifTrue: [value -= 13]]. + upper + ifTrue: [(value as: String Character) toUppercase] + ifFalse: [value as: String Character] +]. + +s@(String traits) rot13 +[ + result ::= s newSameSize. + s doWithIndex: [| :each :index | result at: index put: each rot13]. + result +]. + +slate[37]> 'abc123' rot13. +'nop123' diff --git a/Task/Rot-13/Smalltalk/rot-13.st b/Task/Rot-13/Smalltalk/rot-13.st new file mode 100644 index 0000000000..19fbc577c6 --- /dev/null +++ b/Task/Rot-13/Smalltalk/rot-13.st @@ -0,0 +1,74 @@ +"1. simple approach" +rot13 := [ :string | + string collect: [ :each | | index | + index := 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' + indexOf: each ifAbsent: [ 0 ]. "Smalltalk uses 1-based indexing" + index isZero + ifTrue: [ each ] + ifFalse: [ 'nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM' at: + index ] ] ]. + +(rot13 value: 'Test123') printNl "gives 'Grfg123'" + +"2. extending built-in classes" +Character extend [ + + inc [ + (inc isKindOf: Character) + ifTrue: [ + ^ ( Character value: ((self asInteger) + (inc asInteger)) ) + ] ifFalse: [ + ^ ( Character value: ((self asInteger) + inc) ) + ] + ] + - inc [ + ^ ( self + (inc asInteger negated) ) + ] + trFrom: map1 to: map2 [ + (map1 includes: self) ifTrue: [ + ^ map2 at: (map1 indexOf: self) + ] ifFalse: [ ^self ] + ] +]. + +String extend [ + rot: num [ |s| + s := String new. + self do: [ :c | + ((c asLowercase) between: $a and: $z) + ifTrue: [ |c1| + c1 := ( $a + ((((c asLowercase) - $a + num) asInteger) rem:26)). + (c isLowercase) ifFalse: [ c1 := c1 asUppercase ]. + s := s, (c1 asString) + ] + ifFalse: [ + s := s, (c asString) + ] + ]. + ^s + ] +]. + +('abcdefghijklmnopqrstuvwxyz123!' rot: 13) displayNl. +(('abcdefghijklmnopqrstuvwxyz123!' rot: 13) rot: 13) displayNl. + + + +"2. using a 'translation'. Not very idiomatic Smalltalk code" +rotThirteen := [ :s | |m1 m2 r| + r := String new. + m1 := OrderedCollection new. + 0 to: 25 do: [ :i | m1 add: ($a + i) ]. + m2 := OrderedCollection new. + 0 to: 25 do: [ :i | m2 add: ($a + ((i+13) rem: 26)) ]. + s do: [ :c | + (c between: $a and: $z) | (c between: $A and: $Z) + ifTrue: [ | a | + a := (c asLowercase) trFrom: m1 to: m2. + (c isUppercase) ifTrue: [ a := a asUppercase ]. + r := r, (a asString)] + ifFalse: [ r := r, (c asString) ] + ]. + r +]. + +(rotThirteen value: 'abcdefghijklmnopqrstuvwxyz123!') displayNl. diff --git a/Task/Rot-13/Standard-ML/rot-13.ml b/Task/Rot-13/Standard-ML/rot-13.ml new file mode 100644 index 0000000000..c941fccbcc --- /dev/null +++ b/Task/Rot-13/Standard-ML/rot-13.ml @@ -0,0 +1,9 @@ +fun rot13char c = + if c >= #"a" andalso c <= #"m" orelse c >= #"A" andalso c <= #"M" then + chr (ord c + 13) + else if c >= #"n" andalso c <= #"z" orelse c >= #"N" andalso c <= #"Z" then + chr (ord c - 13) + else + c + +val rot13 = String.map rot13char diff --git a/Task/Rot-13/TI-83-BASIC/rot-13.ti-83 b/Task/Rot-13/TI-83-BASIC/rot-13.ti-83 new file mode 100644 index 0000000000..baa0a252a1 --- /dev/null +++ b/Task/Rot-13/TI-83-BASIC/rot-13.ti-83 @@ -0,0 +1,13 @@ +:"ABCDEFGHIJKLMNOPQRSTUVWXYZ→Str0 +:".→Str2 +:For(N,1,length(Str1 +:If inString(Str0,sub(Str1,N,1 +:Then +:inString(Str0,sub(Str1,N,1 +:Ans+13-26(Ans>13 +:Str2+sub(Str0,Ans,1→Str2 +:Else +:Str2+sub(Str1,N,1→Str2 +:End +:End +:sub(Str2,2,length(Str2)-1→Str1 diff --git a/Task/Rot-13/TXR/rot-13.txr b/Task/Rot-13/TXR/rot-13.txr new file mode 100644 index 0000000000..07d08b6923 --- /dev/null +++ b/Task/Rot-13/TXR/rot-13.txr @@ -0,0 +1,15 @@ +@(deffilter rot13 + ("a" "n") ("b" "o") ("c" "p") ("d" "q") ("e" "r") ("f" "s") ("g" "t") + ("h" "u") ("i" "v") ("j" "w") ("k" "x") ("l" "y") ("m" "z") ("n" "a") + ("o" "b") ("p" "c") ("q" "d") ("r" "e") ("s" "f") ("t" "g") ("u" "h") + ("v" "i") ("w" "j") ("x" "k") ("y" "l") ("z" "m") + ("A" "N") ("B" "O") ("C" "P") ("D" "Q") ("E" "R") ("F" "S") ("G" "T") + ("H" "U") ("I" "V") ("J" "W") ("K" "X") ("L" "Y") ("M" "Z") ("N" "A") + ("O" "B") ("P" "C") ("Q" "D") ("R" "E") ("S" "F") ("T" "G") ("U" "H") + ("V" "I") ("W" "J") ("X" "K") ("Y" "L") ("Z" "M")) +@(collect :vars ()) +@line +@ (output :filter rot13) +@line +@ (end) +@(end) diff --git a/Task/Rot-13/Tcl/rot-13-1.tcl b/Task/Rot-13/Tcl/rot-13-1.tcl new file mode 100644 index 0000000000..2e6801495b --- /dev/null +++ b/Task/Rot-13/Tcl/rot-13-1.tcl @@ -0,0 +1,8 @@ +proc rot13 line { + string map { + a n b o c p d q e r f s g t h u i v j w k x l y m z + n a o b p c q d r e s f t g u h v i w j x k y l z m + A N B O C P D Q E R F S G T H U I V J W K X L Y M Z + N A O B P C Q D R E S F T G U H V I W J X K Y L Z M + } $line +} diff --git a/Task/Rot-13/Tcl/rot-13-2.tcl b/Task/Rot-13/Tcl/rot-13-2.tcl new file mode 100644 index 0000000000..4371e1cbec --- /dev/null +++ b/Task/Rot-13/Tcl/rot-13-2.tcl @@ -0,0 +1,4 @@ +package require Tclx +proc rot13 str { + translit "A-Za-z" "N-ZA-Mn-za-m" $str +} diff --git a/Task/Rot-13/TorqueScript/rot-13.torquescript b/Task/Rot-13/TorqueScript/rot-13.torquescript new file mode 100644 index 0000000000..c6e47fbe06 --- /dev/null +++ b/Task/Rot-13/TorqueScript/rot-13.torquescript @@ -0,0 +1,22 @@ +function rot13(%string) +{ + %alph = "abcdefghijklmnopqrstuvwxyz"; + %len = strLen(%string); + + for(%a = 0; %a < %len; %a++) + { + %char = getSubStr(%string,%a,1); + %pos = striPos(%alph, %char); + + if(%pos < 0) + %out = %out @ %char; + else + { + if(strPos(%alph, %char) < 0) + %out = %out @ strUpr(getSubStr(%alph, (%pos + 13) % 26)); + else + %out = %out @ getSubStr(%alph, (%pos + 13) % 26); + } + } + return %out; +} diff --git a/Task/Rot-13/UNIX-Shell/rot-13.sh b/Task/Rot-13/UNIX-Shell/rot-13.sh new file mode 100644 index 0000000000..8cead31535 --- /dev/null +++ b/Task/Rot-13/UNIX-Shell/rot-13.sh @@ -0,0 +1,6 @@ +#!/bin/sh +function rot13 () { + tr '[a-m][n-z][A-M][N-Z]' '[n-z][a-m][N-Z][A-M]' + } + +cat ${1+"$@"} | rot13 diff --git a/Task/Rot-13/Unlambda/rot-13.unlambda b/Task/Rot-13/Unlambda/rot-13.unlambda new file mode 100644 index 0000000000..836bf239f0 --- /dev/null +++ b/Task/Rot-13/Unlambda/rot-13.unlambda @@ -0,0 +1,10 @@ +``ci`d``@i`c``s`d```?aic.n``s`d```?bic.o``s`d```?cic.p``s`d```?dic.q``s`d```?eic +.r``s`d```?fic.s``s`d```?gic.t``s`d```?hic.u``s`d```?iic.v``s`d```?jic.w``s`d``` +?kic.x``s`d```?lic.y``s`d```?mic.z``s`d```?nic.a``s`d```?oic.b``s`d```?pic.c``s` +d```?qic.d``s`d```?ric.e``s`d```?sic.f``s`d```?tic.g``s`d```?uic.h``s`d```?vic.i +``s`d```?wic.j``s`d```?xic.k``s`d```?yic.l``s`d```?zic.m``s`d```?Nic.A``s`d```?O +ic.B``s`d```?Pic.C``s`d```?Qic.D``s`d```?Ric.E``s`d```?Sic.F``s`d```?Tic.G``s`d` +``?Uic.H``s`d```?Vic.I``s`d```?Wic.J``s`d```?Xic.K``s`d```?Yic.L``s`d```?Zic.M`` +s`d```?Aic.N``s`d```?Bic.O``s`d```?Cic.P``s`d```?Dic.Q``s`d```?Eic.R``s`d```?Fic +.S``s`d```?Gic.T``s`d```?Hic.U``s`d```?Iic.V``s`d```?Jic.W``s`d```?Kic.X``s`d``` +?Lic.Y``s`d```?Mic.Z`d`|c diff --git a/Task/Rot-13/Ursala/rot-13.ursala b/Task/Rot-13/Ursala/rot-13.ursala new file mode 100644 index 0000000000..afe0ef6fd2 --- /dev/null +++ b/Task/Rot-13/Ursala/rot-13.ursala @@ -0,0 +1,5 @@ +#import std + +#executable (<'parameterized','default-to-stdin'>,<>) + +rot = ~command.files; * contents:= ~contents; * * -:~& -- ^p(~&,rep13~&zyC)~~ ~=`A-~ letters diff --git a/Task/Rot-13/Vedit-macro-language/rot-13.vedit b/Task/Rot-13/Vedit-macro-language/rot-13.vedit new file mode 100644 index 0000000000..e8c2006c89 --- /dev/null +++ b/Task/Rot-13/Vedit-macro-language/rot-13.vedit @@ -0,0 +1,2 @@ +Translate_Load("ROT13.TBL") +Translate_Block(0, File_Size) diff --git a/Task/Rot-13/Visual-Basic-.NET/rot-13.visual b/Task/Rot-13/Visual-Basic-.NET/rot-13.visual new file mode 100644 index 0000000000..c3f36a8ac3 --- /dev/null +++ b/Task/Rot-13/Visual-Basic-.NET/rot-13.visual @@ -0,0 +1,23 @@ +Module Module1 + + Private Function rot13(ByVal str As String) As String + Dim newChars As Char(), i, j As Integer, original, replacement As String + + original = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" + replacement = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm" + + newChars = str.ToCharArray() + + For i = 0 To newChars.Length - 1 + For j = 0 To 51 + If newChars(i) = original(j) Then + newChars(i) = replacement(j) + Exit For + End If + Next + Next + + Return New String(newChars) + End Function + +End Module diff --git a/Task/Rot-13/X86-Assembly/rot-13.x86 b/Task/Rot-13/X86-Assembly/rot-13.x86 new file mode 100644 index 0000000000..8ea5959123 --- /dev/null +++ b/Task/Rot-13/X86-Assembly/rot-13.x86 @@ -0,0 +1,54 @@ +format ELF executable 3 +entry start + +segment readable writeable +buf rb 1 + +segment readable executable +start: mov eax, 3 ; syscall "read" + mov ebx, 0 ; stdin + mov ecx, buf ; buffer for read byte + mov edx, 1 ; len (read one byte) + int 80h + + cmp eax, 0 ; EOF? + jz exit + + xor eax, eax ; load read char to eax + mov al, [buf] + cmp eax, "A" ; see if it is in ascii a-z or A-Z + jl print + cmp eax, "z" + jg print + cmp eax, "Z" + jle rotup + cmp eax, "a" + jge rotlow + jmp print + +rotup: sub eax, "A"-13 ; do rot 13 for A-Z + cdq + mov ebx, 26 + div ebx + add edx, "A" + jmp rotend + +rotlow: sub eax, "a"-13 ; do rot 13 for a-z + cdq + mov ebx, 26 + div ebx + add edx, "a" + +rotend: mov [buf], dl + +print: mov eax, 4 ; syscall write + mov ebx, 1 ; stdout + mov ecx, buf ; *char + mov edx, 1 ; string length + int 80h + + jmp start + +exit: mov eax,1 ; syscall exit + xor ebx,ebx ; exit code + int 80h diff --git a/Task/Rot-13/XPL0/rot-13.xpl0 b/Task/Rot-13/XPL0/rot-13.xpl0 new file mode 100644 index 0000000000..80cb9a4490 --- /dev/null +++ b/Task/Rot-13/XPL0/rot-13.xpl0 @@ -0,0 +1,7 @@ +code ChIn=7, ChOut=8; +int C, CC; +repeat C:= ChIn(1); CC:= C&~$20; \CC handles lowercase too + ChOut(0, C + (if CC>=^A & CC<=^M then +13 + else if CC>=^N & CC<=^Z then -13 + else 0)); +until C = $1A; \EOF diff --git a/Task/Rot-13/XSLT/rot-13.xslt b/Task/Rot-13/XSLT/rot-13.xslt new file mode 100644 index 0000000000..aaf65faf8e --- /dev/null +++ b/Task/Rot-13/XSLT/rot-13.xslt @@ -0,0 +1,11 @@ + + + ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz + NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm + + + + + + + diff --git a/Task/Rot-13/ZX-Spectrum-Basic/rot-13.zx b/Task/Rot-13/ZX-Spectrum-Basic/rot-13.zx new file mode 100644 index 0000000000..f53a3e62ce --- /dev/null +++ b/Task/Rot-13/ZX-Spectrum-Basic/rot-13.zx @@ -0,0 +1,18 @@ +5 REM Translation of the QBasic provided solution +10 CLS +20 INPUT "Enter a string: ", s$ +30 LET a$ = "": REM a$ is the encoded string +40 FOR l = 1 TO LEN(s$) +50 LET i$ = s$(l): REM i$ is the letter being worked on +60 IF i$ < "A" OR i$ > "Z" THEN GO TO 100 +70 LET c$ = CHR$(CODE(i$) + 13): REM c$ is the encoded letter +80 IF c$ > "Z" THEN LET c$ = CHR$(CODE(c$) - 26) +90 GO TO 300 +100 IF i$ < "a" OR i$ > "z" THEN GO TO 200 +110 LET c$ = CHR$(CODE(i$) + 13) +120 IF c$ > "z" THEN LET c$ = CHR$(CODE(c$) - 26) +130 GO TO 300 +200 LET c$ = i$ +300 LET a$ = a$ + c$ +310 NEXT l +320 PRINT a$ diff --git a/Task/Run-length-encoding/0DESCRIPTION b/Task/Run-length-encoding/0DESCRIPTION new file mode 100644 index 0000000000..09c4c1d98f --- /dev/null +++ b/Task/Run-length-encoding/0DESCRIPTION @@ -0,0 +1,8 @@ +Given a string containing uppercase characters (A-Z), compress repeated 'runs' of the same character by storing the length of that run, and provide a function to reverse the compression. The output can be anything, as long as you can recreate the input with it. + +Example: + +: Input: WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW +: Output: 12W1B12W3B24W1B14W + +Note: the encoding step in the above example is the same as a step of the [[Look-and-say sequence]]. diff --git a/Task/Run-length-encoding/1META.yaml b/Task/Run-length-encoding/1META.yaml new file mode 100644 index 0000000000..093819d0be --- /dev/null +++ b/Task/Run-length-encoding/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Compression diff --git a/Task/Run-length-encoding/ALGOL-68/run-length-encoding.alg b/Task/Run-length-encoding/ALGOL-68/run-length-encoding.alg new file mode 100644 index 0000000000..c73c5ecd32 --- /dev/null +++ b/Task/Run-length-encoding/ALGOL-68/run-length-encoding.alg @@ -0,0 +1,72 @@ +STRING input := "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW"; +STRING output := "12W1B12W3B24W1B14W"; + +MODE YIELDCHAR = PROC(CHAR)VOID; +MODE GENCHAR = PROC(YIELDCHAR)VOID; + +PROC gen char string = (REF STRING s, YIELDCHAR yield)VOID: + FOR i FROM LWB s TO UPB s DO yield(s[i]) OD; + +CO +# Note: The following 2 lines use currying. This not supported by ELLA ALGOL 68RS # +GENCHAR input seq = gen char string(input,), + output seq = gen char string(output,); +END CO + +GENCHAR + input seq = (YIELDCHAR yield)VOID: gen char string(input, yield), + output seq = (YIELDCHAR yield)VOID: gen char string(output, yield); + +PROC gen encode = (GENCHAR gen char, YIELDCHAR yield)VOID: ( + INT count := 0; + CHAR prev; +# FOR CHAR c IN # gen char( # ) DO ( # +## (CHAR c)VOID: ( + IF count = 0 THEN + count := 1; + prev := c + ELIF c NE prev THEN + STRING str count := whole(count,0); + gen char string(str count, yield); count := 1; + yield(prev); prev := c + ELSE + count +:=1 + FI +# OD # )); + IF count NE 0 THEN + STRING str count := whole(count,0); + gen char string(str count,yield); + yield(prev) + FI +); + +STRING zero2nine = "0123456789"; + +PROC gen decode = (GENCHAR gen char, YIELDCHAR yield)VOID: ( + INT repeat := 0; +# FOR CHAR c IN # gen char( # ) DO ( # +## (CHAR c)VOID: ( + IF char in string(c, LOC INT, zero2nine) THEN + repeat := repeat*10 + ABS c - ABS "0" + ELSE + FOR i TO repeat DO yield(c) OD; + repeat := 0 + FI +# OD # )) +); + +# iterate through input string # +print("Encode input: "); +# FOR CHAR c IN # gen encode(input seq, # ) DO ( # +## (CHAR c)VOID: + print(c) +# OD # ); +print(new line); + +# iterate through output string # +print("Decode output: "); +# FOR CHAR c IN # gen decode(output seq, # ) DO ( # +## (CHAR c)VOID: + print(c) +# OD # ); +print(new line) diff --git a/Task/Run-length-encoding/APL/run-length-encoding.apl b/Task/Run-length-encoding/APL/run-length-encoding.apl new file mode 100644 index 0000000000..61c9e6bd2e --- /dev/null +++ b/Task/Run-length-encoding/APL/run-length-encoding.apl @@ -0,0 +1,4 @@ + ∇ ret←RLL rll;count +[1] count←∣2-/((1,(2≠/rll),1)×⍳1+⍴rll)~0 +[2] ret←(⍕count,¨(1,2≠/rll)/rll)~' ' + ∇ diff --git a/Task/Run-length-encoding/AWK/run-length-encoding-1.awk b/Task/Run-length-encoding/AWK/run-length-encoding-1.awk new file mode 100644 index 0000000000..db5a07edf9 --- /dev/null +++ b/Task/Run-length-encoding/AWK/run-length-encoding-1.awk @@ -0,0 +1,16 @@ +BEGIN { + FS="" +} +/^[^0-9]+$/ { + cp = $1; j = 0 + for(i=1; i <= NF; i++) { + if ( $i == cp ) { + j++; + } else { + printf("%d%c", j, cp) + j = 1 + } + cp = $i + } + printf("%d%c", j, cp) +} diff --git a/Task/Run-length-encoding/AWK/run-length-encoding-2.awk b/Task/Run-length-encoding/AWK/run-length-encoding-2.awk new file mode 100644 index 0000000000..44c072cd1b --- /dev/null +++ b/Task/Run-length-encoding/AWK/run-length-encoding-2.awk @@ -0,0 +1,13 @@ +BEGIN { + RS="[0-9]+[^0-9]" + final = ""; +} +{ + match(RT, /([0-9]+)([^0-9])/, r) + for(i=0; i < int(r[1]); i++) { + final = final r[2] + } +} +END { + print final +} diff --git a/Task/Run-length-encoding/Ada/run-length-encoding.ada b/Task/Run-length-encoding/Ada/run-length-encoding.ada new file mode 100644 index 0000000000..20a52bf398 --- /dev/null +++ b/Task/Run-length-encoding/Ada/run-length-encoding.ada @@ -0,0 +1,48 @@ +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Strings.Fixed; use Ada.Strings.Fixed; +procedure Test_Run_Length_Encoding is + function Encode (Data : String) return String is + begin + if Data'Length = 0 then + return ""; + else + declare + Code : constant Character := Data (Data'First); + Index : Integer := Data'First + 1; + begin + while Index <= Data'Last and then Code = Data (Index) loop + Index := Index + 1; + end loop; + declare + Prefix : constant String := Integer'Image (Index - Data'First); + begin + return Prefix (2..Prefix'Last) & Code & Encode (Data (Index..Data'Last)); + end; + end; + end if; + end Encode; + function Decode (Data : String) return String is + begin + if Data'Length = 0 then + return ""; + else + declare + Index : Integer := Data'First; + Count : Natural := 0; + begin + while Index < Data'Last and then Data (Index) in '0'..'9' loop + Count := Count * 10 + Character'Pos (Data (Index)) - Character'Pos ('0'); + Index := Index + 1; + end loop; + if Index > Data'First then + return Count * Data (Index) & Decode (Data (Index + 1..Data'Last)); + else + return Data; + end if; + end; + end if; + end Decode; +begin + Put_Line (Encode ("WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW")); + Put_Line (Decode ("12W1B12W3B24W1B14W")); +end Test_Run_Length_Encoding; diff --git a/Task/Run-length-encoding/AutoHotkey/run-length-encoding.ahk b/Task/Run-length-encoding/AutoHotkey/run-length-encoding.ahk new file mode 100644 index 0000000000..60c1c19617 --- /dev/null +++ b/Task/Run-length-encoding/AutoHotkey/run-length-encoding.ahk @@ -0,0 +1,35 @@ +MsgBox % key := rle_encode("WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW") +MsgBox % rle_decode(key) + +rle_encode(message) +{ + StringLeft, previous, message, 1 + StringRight, last, message, 1 + message .= Asc(Chr(last)+1) + count = 0 + Loop, Parse, message + { + If (previous == A_LoopField) + count +=1 + Else + { + output .= previous . count + previous := A_LoopField + count = 1 + } + } + Return output +} + +rle_decode(message) +{ + pos = 1 + While, item := RegExMatch(message, "\D", char, pos) + { + digpos := RegExMatch(message, "\d+", dig, item) + Loop, % dig + output .= char + pos := digpos + } + Return output +} diff --git a/Task/Run-length-encoding/BASIC/run-length-encoding.basic b/Task/Run-length-encoding/BASIC/run-length-encoding.basic new file mode 100644 index 0000000000..ba77ed55e3 --- /dev/null +++ b/Task/Run-length-encoding/BASIC/run-length-encoding.basic @@ -0,0 +1,55 @@ +DECLARE FUNCTION RLDecode$ (i AS STRING) +DECLARE FUNCTION RLEncode$ (i AS STRING) + +DIM initial AS STRING, encoded AS STRING, decoded AS STRING + +INPUT "Type something: ", initial +encoded = RLEncode(initial) +decoded = RLDecode(encoded) +PRINT initial +PRINT encoded +PRINT decoded + +FUNCTION RLDecode$ (i AS STRING) + DIM Loop0 AS LONG, rCount AS STRING, outP AS STRING, m AS STRING + + FOR Loop0 = 1 TO LEN(i) + m = MID$(i, Loop0, 1) + SELECT CASE m + CASE "0" TO "9" + rCount = rCount + m + CASE ELSE + IF LEN(rCount) THEN + outP = outP + STRING$(VAL(rCount), m) + rCount = "" + ELSE + outP = outP + m + END IF + END SELECT + NEXT + RLDecode$ = outP +END FUNCTION + +FUNCTION RLEncode$ (i AS STRING) + DIM tmp1 AS STRING, tmp2 AS STRING, outP AS STRING + DIM Loop0 AS LONG, rCount AS LONG + + tmp1 = MID$(i, 1, 1) + tmp2 = tmp1 + rCount = 1 + + FOR Loop0 = 2 TO LEN(i) + tmp1 = MID$(i, Loop0, 1) + IF tmp1 <> tmp2 THEN + outP = outP + LTRIM$(RTRIM$(STR$(rCount))) + tmp2 + tmp2 = tmp1 + rCount = 1 + ELSE + rCount = rCount + 1 + END IF + NEXT + + outP = outP + LTRIM$(RTRIM$(STR$(rCount))) + outP = outP + tmp2 + RLEncode$ = outP +END FUNCTION diff --git a/Task/Run-length-encoding/BBC-BASIC/run-length-encoding.bbc b/Task/Run-length-encoding/BBC-BASIC/run-length-encoding.bbc new file mode 100644 index 0000000000..baeec09ceb --- /dev/null +++ b/Task/Run-length-encoding/BBC-BASIC/run-length-encoding.bbc @@ -0,0 +1,36 @@ + input$ = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" + PRINT "Input: " input$ + rle$ = FNencodeRLE(input$) + output$ = FNdecodeRLE(rle$) + PRINT "Output: " output$ + END + + DEF FNencodeRLE(text$) + LOCAL n%, r%, c$, o$ + n% = 1 + WHILE n% <= LEN(text$) + c$ = MID$(text$, n%, 1) + n% += 1 + r% = 1 + WHILE c$ = MID$(text$, n%, 1) AND r% < 127 + r% += 1 + n% += 1 + ENDWHILE + IF r% < 3 o$ += STRING$(r%, c$) ELSE o$ += CHR$(128+r%) + c$ + ENDWHILE + = o$ + + DEF FNdecodeRLE(rle$) + LOCAL n%, c$, o$ + n% = 1 + WHILE n% <= LEN(rle$) + c$ = MID$(rle$, n%, 1) + n% += 1 + IF ASC(c$) > 128 THEN + o$ += STRING$(ASC(c$)-128, MID$(rle$, n%, 1)) + n% += 1 + ELSE + o$ += c$ + ENDIF + ENDWHILE + = o$ diff --git a/Task/Run-length-encoding/Bracmat/run-length-encoding.bracmat b/Task/Run-length-encoding/Bracmat/run-length-encoding.bracmat new file mode 100644 index 0000000000..2807c0ca76 --- /dev/null +++ b/Task/Run-length-encoding/Bracmat/run-length-encoding.bracmat @@ -0,0 +1,21 @@ + ( run-length + = character otherCharacter acc begin end + . :?acc + & 0:?begin + & @( !arg + : ? + [!begin + %@?character + ? + [?end + ( (%@:~!character:?otherCharacter) ? + & !acc !end+-1*!begin !character:?acc + & !otherCharacter:?character + & !end:?begin + & ~` + | &!acc !end+-1*!begin !character:?acc + ) + ) + & str$!acc + ) +& run-length$WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW diff --git a/Task/Run-length-encoding/Burlesque/run-length-encoding.blq b/Task/Run-length-encoding/Burlesque/run-length-encoding.blq new file mode 100644 index 0000000000..0f05e20d59 --- /dev/null +++ b/Task/Run-length-encoding/Burlesque/run-length-encoding.blq @@ -0,0 +1,2 @@ +"WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" +=[{^^[~\/L[Sh}\m diff --git a/Task/Run-length-encoding/C++/run-length-encoding.cpp b/Task/Run-length-encoding/C++/run-length-encoding.cpp new file mode 100644 index 0000000000..f993f04aff --- /dev/null +++ b/Task/Run-length-encoding/C++/run-length-encoding.cpp @@ -0,0 +1,53 @@ +#include +#include +#include +#include +#include + +std::string encode ( const std::string & ) ; +std::string decode ( const std::string & ) ; + +int main( ) { + std::string to_encode ( "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" ) ; + std::cout << to_encode << " encoded:" << std::endl ; + std::string encoded ( encode ( to_encode ) ) ; + std::cout << encoded << std::endl ; + std::string decoded ( decode( encoded ) ) ; + std::cout << "Decoded again:\n" ; + std::cout << decoded << std::endl ; + if ( to_encode == decoded ) + std::cout << "It must have worked!\n" ; + return 0 ; +} + +std::string encode( const std::string & to_encode ) { + std::string::size_type found = 0 , nextfound = 0 ; + std::ostringstream oss ; + nextfound = to_encode.find_first_not_of( to_encode[ found ] , found ) ; + while ( nextfound != std::string::npos ) { + oss << nextfound - found ; + oss << to_encode[ found ] ; + found = nextfound ; + nextfound = to_encode.find_first_not_of( to_encode[ found ] , found ) ; + } + //since we must not discard the last characters we add them at the end of the string + std::string rest ( to_encode.substr( found ) ) ;//last run of characters starts at position found + oss << rest.length( ) << to_encode[ found ] ; + return oss.str( ) ; +} + +std::string decode ( const std::string & to_decode ) { + boost::regex e ( "(\\d+)(\\w)" ) ; + boost::match_results matches ; + std::ostringstream oss ; + std::string::const_iterator start = to_decode.begin( ) , end = to_decode.end( ) ; + while ( boost::regex_search ( start , end , matches , e ) ) { + std::string numberstring ( matches[ 1 ].first , matches[ 1 ].second ) ; + int number = atoi( numberstring.c_str( ) ) ; + std::string character ( matches[ 2 ].first , matches[ 2 ].second ) ; + for ( int i = 0 ; i < number ; i++ ) + oss << character ; + start = matches[ 2 ].second ; + } + return oss.str( ) ; +} diff --git a/Task/Run-length-encoding/C/run-length-encoding.c b/Task/Run-length-encoding/C/run-length-encoding.c new file mode 100644 index 0000000000..2dcc38e024 --- /dev/null +++ b/Task/Run-length-encoding/C/run-length-encoding.c @@ -0,0 +1,147 @@ +#include +#include + +typedef struct stream_t stream_t, *stream; +struct stream_t { + /* get funciton is supposed to return a byte value (0-255), + or -1 to signify end of input */ + int (*get)(stream); + /* put function does output, one byte at a time */ + int (*put)(stream, int); +}; + +/* next two structs inherit from stream_t */ +typedef struct { + int (*get)(stream); + int (*put)(stream, int); + char *string; + int pos; +} string_stream; + +typedef struct { + int (*get)(stream); + int (*put)(stream, int); + FILE *fp; +} file_stream; + +/* methods for above streams */ +int sget(stream in) +{ + int c; + string_stream* s = (string_stream*) in; + c = (unsigned char)(s->string[s->pos]); + if (c == '\0') return -1; + s->pos++; + return c; +} + +int sput(stream out, int c) +{ + string_stream* s = (string_stream*) out; + s->string[s->pos++] = (c == -1) ? '\0' : c; + if (c == -1) s->pos = 0; + return 0; +} + +int file_put(stream out, int c) +{ + file_stream *f = (file_stream*) out; + return fputc(c, f->fp); +} + +/* helper function */ +void output(stream out, unsigned char* buf, int len) +{ + int i; + out->put(out, 128 + len); + for (i = 0; i < len; i++) + out->put(out, buf[i]); +} + +/* Specification: encoded stream are unsigned bytes consisting of sequences. + * First byte of each sequence is the length, followed by a number of bytes. + * If length <=128, the next byte is to be repeated length times; + * If length > 128, the next (length - 128) bytes are not repeated. + * this is to improve efficiency for long non-repeating sequences. + * This scheme can encode arbitrary byte values efficiently. + * c.f. Adobe PDF spec RLE stream encoding (not exactly the same) + */ +void encode(stream in, stream out) +{ + unsigned char buf[256]; + int len = 0, repeat = 0, end = 0, c; + int (*get)(stream) = in->get; + int (*put)(stream, int) = out->put; + + while (!end) { + end = ((c = get(in)) == -1); + if (!end) { + buf[len++] = c; + if (len <= 1) continue; + } + + if (repeat) { + if (buf[len - 1] != buf[len - 2]) + repeat = 0; + if (!repeat || len == 129 || end) { + /* write out repeating bytes */ + put(out, end ? len : len - 1); + put(out, buf[0]); + buf[0] = buf[len - 1]; + len = 1; + } + } else { + if (buf[len - 1] == buf[len - 2]) { + repeat = 1; + if (len > 2) { + output(out, buf, len - 2); + buf[0] = buf[1] = buf[len - 1]; + len = 2; + } + continue; + } + if (len == 128 || end) { + output(out, buf, len); + len = 0; + repeat = 0; + } + } + } + put(out, -1); +} + +void decode(stream in, stream out) +{ + int c, i, cnt; + while (1) { + c = in->get(in); + if (c == -1) return; + if (c > 128) { + cnt = c - 128; + for (i = 0; i < cnt; i++) + out->put(out, in->get(in)); + } else { + cnt = c; + c = in->get(in); + for (i = 0; i < cnt; i++) + out->put(out, c); + } + } +} + +int main() +{ + char buf[256]; + string_stream str_in = { sget, 0, + "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW", 0}; + string_stream str_out = { sget, sput, buf, 0 }; + file_stream file = { 0, file_put, stdout }; + + /* encode from str_in to str_out */ + encode((stream)&str_in, (stream)&str_out); + + /* decode from str_out to file (stdout) */ + decode((stream)&str_out, (stream)&file); + + return 0; +} diff --git a/Task/Run-length-encoding/Clojure/run-length-encoding.clj b/Task/Run-length-encoding/Clojure/run-length-encoding.clj new file mode 100644 index 0000000000..09e3da6046 --- /dev/null +++ b/Task/Run-length-encoding/Clojure/run-length-encoding.clj @@ -0,0 +1,7 @@ +(defn compress [s] + (->> (partition-by identity s) (mapcat (juxt count first)) (apply str))) + +(defn extract [s] + (->> (re-seq #"(\d+)([A-Z])" s) + (mapcat (fn [[_ n ch]] (repeat (Integer/parseInt n) ch))) + (apply str))) diff --git a/Task/Run-length-encoding/CoffeeScript/run-length-encoding-1.coffeescript b/Task/Run-length-encoding/CoffeeScript/run-length-encoding-1.coffeescript new file mode 100644 index 0000000000..1c3e9facf3 --- /dev/null +++ b/Task/Run-length-encoding/CoffeeScript/run-length-encoding-1.coffeescript @@ -0,0 +1,11 @@ +encode = (str) -> + str.replace /(.)\1*/g, (w) -> + w[0] + w.length + +decode = (str) -> + str.replace /(.)(\d+)/g, (m,w,n) -> + new Array(+n+1).join(w) + +console.log s = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" +console.log encode s +console.log decode encode s diff --git a/Task/Run-length-encoding/CoffeeScript/run-length-encoding-2.coffeescript b/Task/Run-length-encoding/CoffeeScript/run-length-encoding-2.coffeescript new file mode 100644 index 0000000000..7c743a9b53 --- /dev/null +++ b/Task/Run-length-encoding/CoffeeScript/run-length-encoding-2.coffeescript @@ -0,0 +1,8 @@ +encode = (str, offset = 75) -> + str.replace /(.)\1*/g, (w) -> + w[0] + String.fromCharCode(offset+w.length) + +decode = (str, offset = 75) -> + str.split('').map((w,i) -> + if not (i%2) then w else new Array(+w.charCodeAt(0)-offset).join(str[i-1]) + ).join('') diff --git a/Task/Run-length-encoding/Common-Lisp/run-length-encoding.lisp b/Task/Run-length-encoding/Common-Lisp/run-length-encoding.lisp new file mode 100644 index 0000000000..459357e7e8 --- /dev/null +++ b/Task/Run-length-encoding/Common-Lisp/run-length-encoding.lisp @@ -0,0 +1,23 @@ +(defun group-similar (sequence &key (test 'eql)) + (loop for x in (rest sequence) + with temp = (subseq sequence 0 1) + if (funcall test (first temp) x) + do (push x temp) + else + collect temp + and do (setf temp (list x)))) + +(defun run-length-encode (sequence) + (mapcar (lambda (group) (list (first group) (length group))) + (group-similar (coerce sequence 'list)))) + +(defun run-length-decode (sequence) + (reduce (lambda (s1 s2) (concatenate 'simple-string s1 s2)) + (mapcar (lambda (elem) + (make-string (second elem) + :initial-element + (first elem))) + sequence))) + +(run-length-encode "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW") +(run-length-decode '((#\W 12) (#\B 1) (#\W 12) (#\B 3) (#\W 24) (#\B 1))) diff --git a/Task/Run-length-encoding/D/run-length-encoding-1.d b/Task/Run-length-encoding/D/run-length-encoding-1.d new file mode 100644 index 0000000000..2cf89d60c3 --- /dev/null +++ b/Task/Run-length-encoding/D/run-length-encoding-1.d @@ -0,0 +1,13 @@ +import std.algorithm, std.array; + +alias encode = group; + +auto decode(Group!("a == b", string) enc) { + return enc.map!(t => [t[0]].replicate(t[1])).join; +} + +void main() { + immutable s = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWW" ~ + "WWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW"; + assert(s.encode.decode.equal(s)); +} diff --git a/Task/Run-length-encoding/D/run-length-encoding-2.d b/Task/Run-length-encoding/D/run-length-encoding-2.d new file mode 100644 index 0000000000..925a5b14b9 --- /dev/null +++ b/Task/Run-length-encoding/D/run-length-encoding-2.d @@ -0,0 +1,53 @@ +import std.stdio, std.array, std.conv; + +// Similar to the 'look and say' function. +string encode(in string input) { + if (input.empty) return input; + char last = input[$ - 1]; + string output; + int count; + + foreach_reverse (c; input) { + if (c == last) { + count++; + } else { + output = text(count) ~ last ~ output; + count = 1; + last = c; + } + } + + return text(count) ~ last ~ output; +} + +string decode(in string input) { + string i, result; + + foreach (c; input) + switch (c) { + case '0': .. case '9': + i ~= c; + break; + case 'A': .. case 'Z': + if (i.empty) + throw new Exception("Can not repeat a letter " ~ + "without a number of repetitions"); + result ~= replicate([c], to!int(i)); + i.length = 0; + break; + default: + throw new Exception("'" ~ c ~ + "' is not alphanumeric"); + } + + return result; +} + +void main() { + immutable txt = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWW" ~ + "WWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW"; + writeln("Input: ", txt); + immutable encoded = encode(txt); + writeln("Encoded: ", encoded); + assert(txt == decode(encoded)); +} diff --git a/Task/Run-length-encoding/D/run-length-encoding-3.d b/Task/Run-length-encoding/D/run-length-encoding-3.d new file mode 100644 index 0000000000..1c324c3c73 --- /dev/null +++ b/Task/Run-length-encoding/D/run-length-encoding-3.d @@ -0,0 +1,79 @@ +import std.stdio, std.conv, std.utf, std.array; +import vlq; + +struct RLE { // for utf string + ubyte[] encoded; + + RLE encode(const string s) { + validate(s); // check if s is well-formed utf, throw if not + encoded.length = 0; // reset + if (s.length == 0) return this; // empty string + string last; + VLQ count; + for (int i = 0; i < s.length; ) { + auto k = s.stride(i); + auto ucode = cast(string)s[i .. i + k]; + if (i == 0) last = ucode; + if (ucode == last) + count++; + else { + encoded ~= count.toVLQ ~ cast(ubyte[])last; + last = ucode; + count = 1; + } + i += k; + } + encoded ~= VLQ(count).toVLQ ~ cast(ubyte[])last; + return this; + } + + int opApply(int delegate(ref ulong c, ref string u) dg) { + VLQ count; + string ucode; + + for (int i = 0; i < encoded.length; ) { + auto k = count.extract(encoded[i .. $]); + i += k; + if (i >= encoded.length) + throw new Exception("not valid encoded string"); + k = stride(cast(string) encoded[i .. $], 0); + if (k == 0xff) // not valid utf code point + throw new Exception("not valid encoded string"); + ucode = cast(string)encoded[i .. i + k].dup; + dg(count.value, ucode); + i += k; + } + + return 0; + } + + string toString() { + string res; + foreach (ref i, s ; this) + if (indexOf("0123456789#", s) == -1) + res ~= text(i) ~ s; + else + res ~= text(i) ~ '#' ~ s; + return res; + } + + string decode() { + string res; + foreach (ref i, s; this) + res ~= replicate(s, cast(uint)i); + return res; + } +} + +void main() { + RLE r; + auto s = "尋尋覓覓冷冷清清淒淒慘慘戚戚\nWWWWWWWWWWWWBWWWWWWWWWWW" ~ + "WBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW\n" ~ + "11#222##333"; + auto f = File("display.txt", "w"); + f.writeln(s); + r.encode(s); + f.writefln("-----\n%s\n-----\n%s", r, r.decode()); + auto sEncoded = RLE.init.encode(s).encoded ; + assert(s == RLE(sEncoded).decode(), "Not work"); +} diff --git a/Task/Run-length-encoding/D/run-length-encoding-4.d b/Task/Run-length-encoding/D/run-length-encoding-4.d new file mode 100644 index 0000000000..d634564710 --- /dev/null +++ b/Task/Run-length-encoding/D/run-length-encoding-4.d @@ -0,0 +1,32 @@ +import std.stdio, std.conv, std.array, std.regex, std.utf, + std.algorithm; + +string reEncode(string s) { + validate(s); // Throw if it's not a well-formed UTF string + static string rep(Captures!string m) { + auto c = canFind("0123456789#", m[1]) ? "#" ~ m[1] : m[1]; + return text(m.hit.length / m[1].length) ~ c; + } + return std.regex.replace!rep(s, regex(`(.|[\n\r\f])\1*`, "g")); +} + + +string reDecode(string s) { + validate(s); // Throw if it's not a well-formed UTF string + static string rep(Captures!string m) { + string c = m[2]; + if (c.length > 1 && c[0] == '#') + c = c[1 .. $]; + return replicate(c, to!int(m[1])); + } + auto r=regex(`(\d+)(#[0123456789#]|[\n\r\f]|[^0123456789#\n\r\f]+)` + , "g"); + return std.regex.replace!rep(s, r); +} + +void main() { + auto s = "尋尋覓覓冷冷清清淒淒慘慘戚戚\nWWWWWWWWWWWWBWWWWWWWWWWW" ~ + "WBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW\n" ~ + "11#222##333"; + assert(s == reDecode(reEncode(s))); +} diff --git a/Task/Run-length-encoding/E/run-length-encoding-1.e b/Task/Run-length-encoding/E/run-length-encoding-1.e new file mode 100644 index 0000000000..97fc619c39 --- /dev/null +++ b/Task/Run-length-encoding/E/run-length-encoding-1.e @@ -0,0 +1,28 @@ +def rle(string) { + var seen := null + var count := 0 + var result := [] + def put() { + if (seen != null) { + result with= [count, seen] + } + } + for ch in string { + if (ch != seen) { + put() + seen := ch + count := 0 + } + count += 1 + } + put() + return result +} + +def unrle(coded) { + var result := "" + for [count, ch] in coded { + result += E.toString(ch) * count + } + return result +} diff --git a/Task/Run-length-encoding/E/run-length-encoding-2.e b/Task/Run-length-encoding/E/run-length-encoding-2.e new file mode 100644 index 0000000000..5b18364be2 --- /dev/null +++ b/Task/Run-length-encoding/E/run-length-encoding-2.e @@ -0,0 +1,5 @@ +? rle("WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW") +# value: [[12, 'W'], [1, 'B'], [12, 'W'], [3, 'B'], [24, 'W'], [1, 'B'], [14, 'W']] + +? unrle(rle("WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW")) +# value: "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" diff --git a/Task/Run-length-encoding/Erlang/run-length-encoding.erl b/Task/Run-length-encoding/Erlang/run-length-encoding.erl new file mode 100644 index 0000000000..e272adeac9 --- /dev/null +++ b/Task/Run-length-encoding/Erlang/run-length-encoding.erl @@ -0,0 +1,46 @@ +-module(rle). + +-export([encode/1,decode/1]). + +-include_lib("eunit/include/eunit.hrl"). + +encode(S) -> + doEncode(string:substr(S, 2), string:substr(S, 1, 1), 1, []). + +doEncode([], CurrChar, Count, R) -> + R ++ integer_to_list(Count) ++ CurrChar; +doEncode(S, CurrChar, Count, R) -> + NextChar = string:substr(S, 1, 1), + if + NextChar == CurrChar -> + doEncode(string:substr(S, 2), CurrChar, Count + 1, R); + true -> + doEncode(string:substr(S, 2), NextChar, 1, + R ++ integer_to_list(Count) ++ CurrChar) + end. + +decode(S) -> + doDecode(string:substr(S, 2), string:substr(S, 1, 1), []). + +doDecode([], _, R) -> + R; +doDecode(S, CurrString, R) -> + NextChar = string:substr(S, 1, 1), + IsInt = erlang:is_integer(catch(erlang:list_to_integer(NextChar))), + if + IsInt -> + doDecode(string:substr(S, 2), CurrString ++ NextChar, R); + true -> + doDecode(string:substr(S, 2), [], + R ++ string:copies(NextChar, list_to_integer(CurrString))) + end. + +rle_test_() -> + PreEncoded = + "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW", + Expected = "12W1B12W3B24W1B14W", + [ + ?_assert(encode(PreEncoded) =:= Expected), + ?_assert(decode(Expected) =:= PreEncoded), + ?_assert(decode(encode(PreEncoded)) =:= PreEncoded) + ]. diff --git a/Task/Run-length-encoding/Euphoria/run-length-encoding.euphoria b/Task/Run-length-encoding/Euphoria/run-length-encoding.euphoria new file mode 100644 index 0000000000..4c7723d9b2 --- /dev/null +++ b/Task/Run-length-encoding/Euphoria/run-length-encoding.euphoria @@ -0,0 +1,38 @@ +include misc.e + +function encode(sequence s) + sequence out + integer prev_char,count + if length(s) = 0 then + return {} + end if + out = {} + prev_char = s[1] + count = 1 + for i = 2 to length(s) do + if s[i] != prev_char then + out &= {count,prev_char} + prev_char = s[i] + count = 1 + else + count += 1 + end if + end for + out &= {count,prev_char} + return out +end function + +function decode(sequence s) + sequence out + out = {} + for i = 1 to length(s) by 2 do + out &= repeat(s[i+1],s[i]) + end for + return out +end function + +sequence s +s = encode("WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW") +pretty_print(1,s,{3}) +puts(1,'\n') +puts(1,decode(s)) diff --git a/Task/Run-length-encoding/FALSE/run-length-encoding-1.false b/Task/Run-length-encoding/FALSE/run-length-encoding-1.false new file mode 100644 index 0000000000..6951b5adac --- /dev/null +++ b/Task/Run-length-encoding/FALSE/run-length-encoding-1.false @@ -0,0 +1 @@ +1^[^$~][$@$@=$[%%\1+\$0~]?~[@.,1\$]?%]#%\., {encode} diff --git a/Task/Run-length-encoding/FALSE/run-length-encoding-2.false b/Task/Run-length-encoding/FALSE/run-length-encoding-2.false new file mode 100644 index 0000000000..c66131f249 --- /dev/null +++ b/Task/Run-length-encoding/FALSE/run-length-encoding-2.false @@ -0,0 +1,2 @@ +[0[^$$'9>'0@>|~]['0-\10*+]#]n: +[n;!$~][[\$][1-\$,]#%%]#%% {decode} diff --git a/Task/Run-length-encoding/Fan/run-length-encoding.fan b/Task/Run-length-encoding/Fan/run-length-encoding.fan new file mode 100644 index 0000000000..d04ef76684 --- /dev/null +++ b/Task/Run-length-encoding/Fan/run-length-encoding.fan @@ -0,0 +1,47 @@ +** +** Generates a run-length encoding for a string +** +class RLE +{ + Run[] encode(Str s) + { + runs := Run[,] + + s.size.times |i| + { + ch := s[i] + if (runs.size==0 || runs.last.char != ch) + runs.add(Run(ch)) + runs.last.inc + } + return runs + } + + Str decode(Run[] runs) + { + buf := StrBuf() + runs.each |run| + { + run.count.times { buf.add(run.char.toChar) } + } + return buf.toStr + } + + Void main() + { + echo(decode(encode( +"WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" + ))) + } + +} + +internal class Run +{ + Int char + Int count := 0 + new make(Int ch) { char = ch } + Void inc() { ++count } + + override Str toStr() { return "${count}${char.toChar}" } +} diff --git a/Task/Run-length-encoding/Forth/run-length-encoding-1.fth b/Task/Run-length-encoding/Forth/run-length-encoding-1.fth new file mode 100644 index 0000000000..340e11cece --- /dev/null +++ b/Task/Run-length-encoding/Forth/run-length-encoding-1.fth @@ -0,0 +1,15 @@ +variable a +: n>a (.) tuck a @ swap move a +! ; +: >a a @ c! 1 a +! ; +: encode ( c-addr +n a -- a n' ) + dup a ! -rot over c@ 1 2swap 1 /string bounds ?do + over i c@ = if 1+ + else n>a >a i c@ 1 then + loop n>a >a a @ over - ; + +: digit? [char] 0 [ char 9 1+ literal ] within ; +: decode ( c-addr +n a -- a n' ) + dup a ! 0 2swap bounds ?do + i c@ digit? if 10 * i c@ [char] 0 - + else + a @ over i c@ fill a +! 0 then + loop drop a @ over - ; diff --git a/Task/Run-length-encoding/Forth/run-length-encoding-2.fth b/Task/Run-length-encoding/Forth/run-length-encoding-2.fth new file mode 100644 index 0000000000..bbff30c980 --- /dev/null +++ b/Task/Run-length-encoding/Forth/run-length-encoding-2.fth @@ -0,0 +1,3 @@ +s" WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" +here 1000 + encode here 2000 + decode cr 3 spaces type + WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW diff --git a/Task/Run-length-encoding/Fortran/run-length-encoding.f b/Task/Run-length-encoding/Fortran/run-length-encoding.f new file mode 100644 index 0000000000..0962bb985f --- /dev/null +++ b/Task/Run-length-encoding/Fortran/run-length-encoding.f @@ -0,0 +1,73 @@ +program RLE + implicit none + + integer, parameter :: bufsize = 100 ! Sets maximum size of coded and decoded strings, adjust as necessary + character(bufsize) :: teststr = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" + character(bufsize) :: codedstr = "" Encode (Data (Index..Data'Last)); + end; + end; + end if; + end Encode; + function Decode (Data : String) return String is + begin + if Data'Length = 0 then + return ""; + else + declare + Index : Integer := Data'First; + Count : Natural := 0; + begin + while Index , decodedstr = "" + + call Encode(teststr, codedstr) + write(*,"(a)") trim(codedstr) + call Decode(codedstr, decodedstr) + write(*,"(a)") trim(decodedstr) + +contains + +subroutine Encode(instr, outstr) + character(*), intent(in) :: instr + character(*), intent(out) :: outstr + character(8) :: tempstr = "" + character(26) :: validchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + integer :: a, b, c, i + + if(verify(trim(instr), validchars) /= 0) then + outstr = "Invalid input" + return + end if + outstr = "" + c = 1 + a = iachar(instr(1:1)) + do i = 2, len(trim(instr)) + b = iachar(instr(i:i)) + if(a == b) then + c = c + 1 + else + write(tempstr, "(i0)") c + outstr = trim(outstr) // trim(tempstr) // achar(a) + a = b + c = 1 + end if + end do + write(tempstr, "(i0)") c + outstr = trim(outstr) // trim(tempstr) // achar(b) +end subroutine + +subroutine Decode(instr, outstr) + character(*), intent(in) :: instr + character(*), intent(out) :: outstr + character(26) :: validchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + integer :: startn, endn, n + + outstr = "" + startn = 1 + do while(startn < len(trim(instr))) + endn = scan(instr(startn:), validchars) + startn - 1 + read(instr(startn:endn-1), "(i8)") n + outstr = trim(outstr) // repeat(instr(endn:endn), n) + startn = endn + 1 + end do +end subroutine +end program diff --git a/Task/Run-length-encoding/Go/run-length-encoding.go b/Task/Run-length-encoding/Go/run-length-encoding.go new file mode 100644 index 0000000000..b1779ed946 --- /dev/null +++ b/Task/Run-length-encoding/Go/run-length-encoding.go @@ -0,0 +1,71 @@ +package main + +import "fmt" + +// encoding scheme: +// encode to byte array +// byte value < 26 means single character: byte value + 'A' +// byte value 26..255 means (byte value - 24) copies of next byte +func rllEncode(s string) (r []byte) { + if s == "" { + return + } + c := s[0] + if c < 'A' || c > 'Z' { + panic("invalid") + } + nc := byte(1) + for i := 1; i < len(s); i++ { + d := s[i] + switch { + case d != c: + case nc < (255 - 24): + nc++ + continue + } + if nc > 1 { + r = append(r, nc+24) + } + r = append(r, c-'A') + if d < 'A' || d > 'Z' { + panic("invalid") + } + c = d + nc = 1 + } + if nc > 1 { + r = append(r, nc+24) + } + r = append(r, c-'A') + return +} + +func main() { + s := "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" + fmt.Println("source: ", len(s), "bytes:", s) + e := rllEncode(s) + fmt.Println("encoded:", len(e), "bytes:", e) + d := rllDecode(e) + fmt.Println("decoded:", len(d), "bytes:", d) + fmt.Println("decoded = source:", d == s) +} + +func rllDecode(e []byte) string { + var c byte + var d []byte + for i := 0; i < len(e); i++ { + b := e[i] + if b < 26 { + c = 1 + } else { + c = b - 24 + i++ + b = e[i] + } + for c > 0 { + d = append(d, b+'A') + c-- + } + } + return string(d) +} diff --git a/Task/Run-length-encoding/Groovy/run-length-encoding-1.groovy b/Task/Run-length-encoding/Groovy/run-length-encoding-1.groovy new file mode 100644 index 0000000000..89e3ce587f --- /dev/null +++ b/Task/Run-length-encoding/Groovy/run-length-encoding-1.groovy @@ -0,0 +1,15 @@ +def rleEncode(text) { + def encoded = new StringBuilder() + (text =~ /(([A-Z])\2*)/).each { matcher -> + encoded.append(matcher[1].size()).append(matcher[2]) + } + encoded.toString() +} + +def rleDecode(text) { + def decoded = new StringBuilder() + (text =~ /([0-9]+)([A-Z])/).each { matcher -> + decoded.append(matcher[2] * Integer.parseInt(matcher[1])) + } + decoded.toString() +} diff --git a/Task/Run-length-encoding/Groovy/run-length-encoding-2.groovy b/Task/Run-length-encoding/Groovy/run-length-encoding-2.groovy new file mode 100644 index 0000000000..3cb7cf29b3 --- /dev/null +++ b/Task/Run-length-encoding/Groovy/run-length-encoding-2.groovy @@ -0,0 +1,7 @@ +def text = 'WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW' +def rleEncoded = rleEncode(text) +assert rleEncoded == '12W1B12W3B24W1B14W' +assert text == rleDecode(rleEncoded) + +println "Original Text: $text" +println "Encoded Text: $rleEncoded" diff --git a/Task/Run-length-encoding/Haskell/run-length-encoding.hs b/Task/Run-length-encoding/Haskell/run-length-encoding.hs new file mode 100644 index 0000000000..0e3a410317 --- /dev/null +++ b/Task/Run-length-encoding/Haskell/run-length-encoding.hs @@ -0,0 +1,24 @@ +import Data.List (group) + +-- Datatypes +type Encoded = [(Int, Char)] -- An encoded String with form [(times, char), ...] +type Decoded = String + +-- Takes a decoded string and returns an encoded list of tuples +rlencode :: Decoded -> Encoded +rlencode = map (\g -> (length g, head g)) . group + +-- Takes an encoded list of tuples and returns the associated decoded String +rldecode :: Encoded -> Decoded +rldecode = concatMap decodeTuple + where decodeTuple (n,c) = replicate n c + +main :: IO () +main = do + -- Get input + putStr "String to encode: " + input <- getLine + -- Output encoded and decoded versions of input + let encoded = rlencode input + decoded = rldecode encoded + putStrLn $ "Encoded: " ++ show encoded ++ "\nDecoded: " ++ show decoded diff --git a/Task/Run-length-encoding/Icon/run-length-encoding.icon b/Task/Run-length-encoding/Icon/run-length-encoding.icon new file mode 100644 index 0000000000..9d74eb7d1c --- /dev/null +++ b/Task/Run-length-encoding/Icon/run-length-encoding.icon @@ -0,0 +1,27 @@ +procedure main(arglist) + + s := "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" + + write(" s=",image(s)) + write("s1=",image(s1 := rle_encode(s))) + write("s2=",image(s2 := rle_decode(s1))) + + if s ~== s2 then write("Encode/Decode problem.") + else write("Encode/Decode worked.") +end + +procedure rle_encode(s) + es := "" + s ? while c := move(1) do es ||:= *(move(-1),tab(many(c))) || c + return es +end + +procedure rle_decode(es) + s := "" + es ? while s ||:= Repl(tab(many(&digits)),move(1)) + return s +end + +procedure Repl(n, c) + return repl(c,n) +end diff --git a/Task/Run-length-encoding/J/run-length-encoding-1.j b/Task/Run-length-encoding/J/run-length-encoding-1.j new file mode 100644 index 0000000000..8a7b83196b --- /dev/null +++ b/Task/Run-length-encoding/J/run-length-encoding-1.j @@ -0,0 +1,2 @@ +rle=: ;@(<@(":@#,{.);.1~ 1, 2 ~:/\ ]) +rld=: '0123456789'&(-.~ #~ i. ".@:{ ' ' ,~ [) diff --git a/Task/Run-length-encoding/J/run-length-encoding-2.j b/Task/Run-length-encoding/J/run-length-encoding-2.j new file mode 100644 index 0000000000..3ce60cf70b --- /dev/null +++ b/Task/Run-length-encoding/J/run-length-encoding-2.j @@ -0,0 +1,5 @@ + rle 'WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW' +12W1B12W3B24W1B14W + + rld '12W1B12W3B24W1B14W' +WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW diff --git a/Task/Run-length-encoding/Java/run-length-encoding-1.java b/Task/Run-length-encoding/Java/run-length-encoding-1.java new file mode 100644 index 0000000000..1b278d0cfb --- /dev/null +++ b/Task/Run-length-encoding/Java/run-length-encoding-1.java @@ -0,0 +1,38 @@ +import java.util.regex.Matcher; +import java.util.regex.Pattern; +public class RunLengthEncoding { + + public static String encode(String source) { + StringBuffer dest = new StringBuffer(); + for (int i = 0; i < source.length(); i++) { + int runLength = 1; + while (i+1 < source.length() && source.charAt(i) == source.charAt(i+1)) { + runLength++; + i++; + } + dest.append(runLength); + dest.append(source.charAt(i)); + } + return dest.toString(); + } + + public static String decode(String source) { + StringBuffer dest = new StringBuffer(); + Pattern pattern = Pattern.compile("[0-9]+|[a-zA-Z]"); + Matcher matcher = pattern.matcher(source); + while (matcher.find()) { + int number = Integer.parseInt(matcher.group()); + matcher.find(); + while (number-- != 0) { + dest.append(matcher.group()); + } + } + return dest.toString(); + } + + public static void main(String[] args) { + String example = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW"; + System.out.println(encode(example)); + System.out.println(decode("1W1B1W1B1W1B1W1B1W1B1W1B1W1B")); + } +} diff --git a/Task/Run-length-encoding/Java/run-length-encoding-2.java b/Task/Run-length-encoding/Java/run-length-encoding-2.java new file mode 100644 index 0000000000..e5dcd59198 --- /dev/null +++ b/Task/Run-length-encoding/Java/run-length-encoding-2.java @@ -0,0 +1,32 @@ +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class RunLengthEncodingTest { + private RLE = new RunLengthEncoding(); + + @Test + public void encodingTest() { + assertEquals("1W", RLE.encode("W")); + assertEquals("4W", RLE.encode("WWWW")); + assertEquals("5w4i7k3i6p5e4d2i1a", + RLE.encode("wwwwwiiiikkkkkkkiiippppppeeeeeddddiia")); + assertEquals("12B1N12B3N24B1N14B", + RLE.encode("BBBBBBBBBBBBNBBBBBBBBBBBBNNNBBBBBBBBBBBBBBBBBBBBBBBBNBBBBBBBBBBBBBB")); + assertEquals("12W1B12W3B24W1B14W", + RLE.encode("WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW")); + assertEquals("1W1B1W1B1W1B1W1B1W1B1W1B1W1B", RLE.encode("WBWBWBWBWBWBWB")); + + } + + @Test + public void decodingTest() { + assertEquals("W", RLE.decode("1W")); + assertEquals("WWWW", RLE.decode("4W")); + assertEquals("WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW", + RLE.decode("12W1B12W3B24W1B14W")); + assertEquals("WBWBWBWBWBWBWB", RLE.decode("1W1B1W1B1W1B1W1B1W1B1W1B1W1B")); + assertEquals("WBWBWBWBWBWBWB", RLE.decode("1W1B1W1B1W1B1W1B1W1B1W1B1W1B")); + + } +} diff --git a/Task/Run-length-encoding/JavaScript/run-length-encoding-1.js b/Task/Run-length-encoding/JavaScript/run-length-encoding-1.js new file mode 100644 index 0000000000..0363d820a6 --- /dev/null +++ b/Task/Run-length-encoding/JavaScript/run-length-encoding-1.js @@ -0,0 +1,15 @@ +function encode(input) { + var encoding = []; + var prev, count, i; + for (count = 1, prev = input[0], i = 1; i < input.length; i++) { + if (input[i] != prev) { + encoding.push([count, prev]); + count = 1; + prev = input[i]; + } + else + count ++; + } + encoding.push([count, prev]); + return encoding; +} diff --git a/Task/Run-length-encoding/JavaScript/run-length-encoding-2.js b/Task/Run-length-encoding/JavaScript/run-length-encoding-2.js new file mode 100644 index 0000000000..811d6dce8a --- /dev/null +++ b/Task/Run-length-encoding/JavaScript/run-length-encoding-2.js @@ -0,0 +1,5 @@ +function encode_re(input) { + var encoding = []; + input.match(/(.)\1*/g).forEach(function(substr){ encoding.push([substr.length, substr[0]]) }); + return encoding; +} diff --git a/Task/Run-length-encoding/JavaScript/run-length-encoding-3.js b/Task/Run-length-encoding/JavaScript/run-length-encoding-3.js new file mode 100644 index 0000000000..4b00067f93 --- /dev/null +++ b/Task/Run-length-encoding/JavaScript/run-length-encoding-3.js @@ -0,0 +1,5 @@ +function decode(encoded) { + var output = ""; + encoded.forEach(function(pair){ output += new Array(1+pair[0]).join(pair[1]) }) + return output; +} diff --git a/Task/Run-length-encoding/K/run-length-encoding-1.k b/Task/Run-length-encoding/K/run-length-encoding-1.k new file mode 100644 index 0000000000..6f0bc6a6f2 --- /dev/null +++ b/Task/Run-length-encoding/K/run-length-encoding-1.k @@ -0,0 +1 @@ +rle: {,/($-':i,#x),'x@i:&1,~=':x} diff --git a/Task/Run-length-encoding/K/run-length-encoding-2.k b/Task/Run-length-encoding/K/run-length-encoding-2.k new file mode 100644 index 0000000000..ecc1c41702 --- /dev/null +++ b/Task/Run-length-encoding/K/run-length-encoding-2.k @@ -0,0 +1 @@ +rld: {d:"0123456789"; ,/(.(d," ")@d?/:x)#'x _dvl d} diff --git a/Task/Run-length-encoding/K/run-length-encoding-3.k b/Task/Run-length-encoding/K/run-length-encoding-3.k new file mode 100644 index 0000000000..9e10dc321e --- /dev/null +++ b/Task/Run-length-encoding/K/run-length-encoding-3.k @@ -0,0 +1,4 @@ + rle "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" +"12W1B12W3B24W1B14W" + rld "12W1B12W3B24W1B14W" +"WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" diff --git a/Task/Run-length-encoding/Liberty-BASIC/run-length-encoding.liberty b/Task/Run-length-encoding/Liberty-BASIC/run-length-encoding.liberty new file mode 100644 index 0000000000..9f7b62efac --- /dev/null +++ b/Task/Run-length-encoding/Liberty-BASIC/run-length-encoding.liberty @@ -0,0 +1,48 @@ +mainwin 100 20 + + 'In$ ="aaaaaaaaaaaaaaaaaccbbbbbbbbbbbbbbba" ' testing... + In$ ="WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" + ' Out$= "12W1B12W3B24W1B14W" + + Out$ =Encoded$( In$) + Inv$ =Decoded$( Out$) + + print " Supplied string ="; In$ + Print " RLE version ="; Out$ + print " Decoded back to ="; Inv$ + + end + + function Encoded$( k$) + r$ ="" + r =1 + for i =2 to len( k$) + prev$ =mid$( k$, i -1, 1) + c$ =mid$( k$, i, 1) + if c$ =prev$ then ' entering a run of this character + r =r +1 + else ' it occurred only once + r$ =r$ +str$( r) +prev$ + r =1 + end if + next i + r$ =r$ +str$( r) +c$ + Encoded$ =r$ + end function + + function Decoded$( k$) + r$ ="" + v =0 + for i =1 to len( k$) + i$ =mid$( k$, i, 1) + if instr( "0123456789", i$) then + v =v *10 +val( i$) + else + for m =1 to v + r$ =r$ +i$ + next m + v =0 + end if + next i + Decoded$ =r$ + end function diff --git a/Task/Run-length-encoding/Logo/run-length-encoding.logo b/Task/Run-length-encoding/Logo/run-length-encoding.logo new file mode 100644 index 0000000000..5efff6f995 --- /dev/null +++ b/Task/Run-length-encoding/Logo/run-length-encoding.logo @@ -0,0 +1,18 @@ +to encode :str [:out "||] [:count 0] [:last first :str] + if empty? :str [output (word :out :count :last)] + if equal? first :str :last [output (encode bf :str :out :count+1 :last)] + output (encode bf :str (word :out :count :last) 1 first :str) +end + +to reps :n :w + output ifelse :n = 0 ["||] [word :w reps :n-1 :w] +end +to decode :str [:out "||] [:count 0] + if empty? :str [output :out] + if number? first :str [output (decode bf :str :out 10*:count + first :str)] + output (decode bf :str word :out reps :count first :str) +end + +make "foo "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW +make "rle encode :foo +show equal? :foo decode :rle diff --git a/Task/Run-length-encoding/Lua/run-length-encoding.lua b/Task/Run-length-encoding/Lua/run-length-encoding.lua new file mode 100644 index 0000000000..b056f2543a --- /dev/null +++ b/Task/Run-length-encoding/Lua/run-length-encoding.lua @@ -0,0 +1,31 @@ +local C, Ct, R, Cf, Cc = lpeg.C, lpeg.Ct, lpeg.R, lpeg.Cf, lpeg.Cc +astable = Ct(C(1)^0) + +function compress(t) + local ret = {} + for i, v in ipairs(t) do + if t[i-1] and v == t[i-1] then + ret[#ret - 1] = ret[#ret - 1] + 1 + else + ret[#ret + 1] = 1 + ret[#ret + 1] = v + end + end + t = ret + return table.concat(ret) +end +q = io.read() +print(compress(astable:match(q))) + +undo = Ct((Cf(Cc"0" * C(R"09")^1, function(a, b) return 10 * a + b end) * C(R"AZ"))^0) + +function decompress(s) + t = undo:match(s) + local ret = "" + for i = 1, #t - 1, 2 do + for _ = 1, t[i] do + ret = ret .. t[i+1] + end + end + return ret +end diff --git a/Task/Run-length-encoding/MMIX/run-length-encoding.mmix b/Task/Run-length-encoding/MMIX/run-length-encoding.mmix new file mode 100644 index 0000000000..0357b7f8e7 --- /dev/null +++ b/Task/Run-length-encoding/MMIX/run-length-encoding.mmix @@ -0,0 +1,110 @@ + LOC Data_Segment + GREG @ +Buf OCTA 0,0,0,0 integer print buffer +Char BYTE 0,0 single char print buffer +task BYTE "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWW" + BYTE "WWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW",0 +len GREG @-1-task + +// task should become this +tEnc BYTE "12W1B12W3B24W1B14W",0 + + GREG @ +// tuple array for encoding purposes +// each tuple is a tetra (4 bytes long or 2 wydes long) +// (c,l) in which c is a char and l = number of chars c +// high wyde of the tetra contains the char +// low wyde .. .. .. contains the length +RLE TETRA 0 + + LOC #100 locate program + GREG @ +// print number to stdout +// destroys input arg $3 ! +Prt64 LDA $255,Buf+23 points to LSD +// do +2H DIV $3,$3,10 (N,R) = divmod (N,10) + GET $13,rR get remainder + INCL $13,'0' convert to ascii + STBU $13,$255 store ascii digit + BZ $3,3F + SUB $255,$255,1 move pointer down + JMP 2B While N !=0 +3H TRAP 0,Fputs,StdOut print number to standard out + GO $127,$127,0 return + + GREG @ +// print char to stdout +PChar LDA $255,Char + STBU $4,$255 + TRAP 0,Fputs,StdOut + GO $127,$127,0 + + GREG @ +// encode routine +// $0 string pointer +// $1 index var +// $2 pointer to tuple array +// $11 temp var tuple +Encode SET $1,0 initialize index = 0 + SET $11,0 postion in string = 0 + LDBU $3,$0,$1 get first char + ADDU $6,$3,0 remember it + do +1H INCL $1,1 repeat incr index + LDBU $3,$0,$1 get a char + BZ $3,2F if EOS then finish + CMP $7,$3,$6 + PBZ $7,1B while new == old + XOR $4,$4,$4 new tuple + ADDU $4,$6,0 + SLU $4,$4,16 old char to tuple -> (c,_) + SUB $7,$1,$11 length = index - previous position + ADDU $11,$1,0 incr position + OR $4,$4,$7 length l to tuple -> (c,l) + STT $4,$2 put tuple in array + ADDU $6,$3,0 remember new char + INCL $2,4 incr 'tetra' pointer + JMP 1B loop +2H XOR $4,$4,$4 put last tuple in array + ADDU $4,$6,0 + SLU $4,$4,16 + SUB $7,$1,$11 + ADDU $11,$1,0 + OR $4,$4,$7 + STT $4,$2 + GO $127,$127,0 return + + GREG @ +Main LDA $0,task pointer uncompressed string + LDA $2,RLE pointer tuple array + GO $127,Encode encode string + LDA $2,RLE points to start tuples + SET $5,#ffff mask for extracting length +1H LDTU $3,$2 while not End of Array + BZ $3,2F + SRU $4,$3,16 char = (c,_) + AND $3,$3,$5 length = (_,l) + GO $127,Prt64 print length + GO $127,PChar print char + INCL $2,4 incr tuple pointer + JMP 1B wend +2H SET $4,#a print NL + GO $127,PChar + +// decode using the RLE tuples + LDA $2,RLE pointer tuple array + SET $5,#ffff mask +1H LDTU $3,$2 while not End of Array + BZ $3,2F + SRU $4,$3,16 char = (c,_) + AND $3,$3,$5 length = (_,l) +// for (i=0;i#&/@Range[0,9]))//.{x___,i_Integer,j_Integer,y___}:>{x,10i+j,y},2] diff --git a/Task/Run-length-encoding/Mathematica/run-length-encoding-2.math b/Task/Run-length-encoding/Mathematica/run-length-encoding-2.math new file mode 100644 index 0000000000..246f6bcb2c --- /dev/null +++ b/Task/Run-length-encoding/Mathematica/run-length-encoding-2.math @@ -0,0 +1,4 @@ +mystring="WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW"; +RunLengthEncode[mystring] +RunLengthDecode[%] +%==mystring diff --git a/Task/Run-length-encoding/Mathematica/run-length-encoding-3.math b/Task/Run-length-encoding/Mathematica/run-length-encoding-3.math new file mode 100644 index 0000000000..9c665c31da --- /dev/null +++ b/Task/Run-length-encoding/Mathematica/run-length-encoding-3.math @@ -0,0 +1,3 @@ +12W1B12W3B24W1B14W +WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW +True diff --git a/Task/Run-length-encoding/Mathematica/run-length-encoding-4.math b/Task/Run-length-encoding/Mathematica/run-length-encoding-4.math new file mode 100644 index 0000000000..73d4f72657 --- /dev/null +++ b/Task/Run-length-encoding/Mathematica/run-length-encoding-4.math @@ -0,0 +1,8 @@ +RunLengthEncode[s_String] := StringJoin[ + {ToString[Length[#]] <> First[#]} & /@ Split[StringSplit[s, ""]] + ] + +RunLengthDecode[s_String] := StringJoin[ + Table[#[[2]], {ToExpression[#[[1]]]}] & /@ + Partition[StringSplit[s, x : _?LetterQ :> x], 2] + ] diff --git a/Task/Run-length-encoding/Maxima/run-length-encoding.maxima b/Task/Run-length-encoding/Maxima/run-length-encoding.maxima new file mode 100644 index 0000000000..4cfb9bc7ec --- /dev/null +++ b/Task/Run-length-encoding/Maxima/run-length-encoding.maxima @@ -0,0 +1,9 @@ +rle(a) := block( + [n: slength(a), b: "", c: charat(a, 1), k: 1], + for i from 2 thru n do + if cequal(c, charat(a, i)) then k: k + 1 else (b: sconcat(b, k, c), c: charat(a, i), k: 1), + sconcat(b, k, c) +)$ + +rle("WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW"); +"12W1B12W3B24W1B14W" diff --git a/Task/Run-length-encoding/OCaml/run-length-encoding-1.ocaml b/Task/Run-length-encoding/OCaml/run-length-encoding-1.ocaml new file mode 100644 index 0000000000..3d2bf3c94b --- /dev/null +++ b/Task/Run-length-encoding/OCaml/run-length-encoding-1.ocaml @@ -0,0 +1,23 @@ +let encode str = + let len = String.length str in + let rec aux i acc = + if i >= len then List.rev acc + else + let c1 = str.[i] in + let rec aux2 j = + if j >= len then (c1, j-i) + else + let c2 = str.[j] in + if c1 = c2 + then aux2 (j+1) + else (c1, j-i) + in + let (c,n) as t = aux2 (i+1) in + aux (i+n) (t::acc) + in + aux 0 [] +;; + +let decode lst = + let l = List.map (fun (c,n) -> String.make n c) lst in + (String.concat "" l) diff --git a/Task/Run-length-encoding/OCaml/run-length-encoding-2.ocaml b/Task/Run-length-encoding/OCaml/run-length-encoding-2.ocaml new file mode 100644 index 0000000000..bf149cfc3d --- /dev/null +++ b/Task/Run-length-encoding/OCaml/run-length-encoding-2.ocaml @@ -0,0 +1,7 @@ +let () = + let e = encode "aaaaahhhhhhmmmmmmmuiiiiiiiaaaaaa" in + List.iter (fun (c,n) -> + Printf.printf " (%c, %d);\n" c n; + ) e; + print_endline (decode [('a', 5); ('h', 6); ('m', 7); ('u', 1); ('i', 7); ('a', 6)]); +;; diff --git a/Task/Run-length-encoding/OCaml/run-length-encoding-3.ocaml b/Task/Run-length-encoding/OCaml/run-length-encoding-3.ocaml new file mode 100644 index 0000000000..2f9e49e745 --- /dev/null +++ b/Task/Run-length-encoding/OCaml/run-length-encoding-3.ocaml @@ -0,0 +1,17 @@ +#load "str.cma";; + +open Str + +let encode = + global_substitute (Str.regexp "\\(.\\)\\1*") + (fun s -> string_of_int (String.length (matched_string s)) ^ + matched_group 1 s) + +let decode = + global_substitute (Str.regexp "\\([0-9]+\\)\\([^0-9]\\)") + (fun s -> String.make (int_of_string (matched_group 1 s)) + (matched_group 2 s).[0]) + +let () = + print_endline (encode "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW"); + print_endline (decode "12W1B12W3B24W1B14W"); diff --git a/Task/Run-length-encoding/Oz/run-length-encoding.oz b/Task/Run-length-encoding/Oz/run-length-encoding.oz new file mode 100644 index 0000000000..fdbfa2c81d --- /dev/null +++ b/Task/Run-length-encoding/Oz/run-length-encoding.oz @@ -0,0 +1,37 @@ +declare + fun {RLEncode Xs} + for G in {Group Xs} collect:C do + {C {Length G}#G.1} + end + end + + fun {RLDecode Xs} + for C#Y in Xs append:Ap do + {Ap {Replicate Y C}} + end + end + + %% Helpers + %% e.g. "1122" -> ["11" "22"] + fun {Group Xs} + case Xs of nil then nil + [] X|Xr then + Ys Zs + {List.takeDropWhile Xr fun {$ W} W==X end ?Ys ?Zs} + in + (X|Ys) | {Group Zs} + end + end + %% e.g. 3,4 -> [3 3 3 3] + fun {Replicate X N} + case N of 0 then nil + else X|{Replicate X N-1} + end + end + + Data = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" + Enc = {RLEncode Data} +in + {System.showInfo Data} + {Show Enc} + {System.showInfo {RLDecode Enc}} diff --git a/Task/Run-length-encoding/PARI-GP/run-length-encoding.pari b/Task/Run-length-encoding/PARI-GP/run-length-encoding.pari new file mode 100644 index 0000000000..a5335d92b4 --- /dev/null +++ b/Task/Run-length-encoding/PARI-GP/run-length-encoding.pari @@ -0,0 +1,31 @@ +rle(s)={ + if(s=="", return(s)); + my(v=Vec(s),cur=v[1],ct=1,out=""); + v=concat(v,99); \\ sentinel + for(i=2,#v, + if(v[i]==cur, + ct++ + , + out=Str(out,ct,cur); + cur=v[i]; + ct=1 + ) + ); + out +}; +elr(s)={ + if(s=="", return(s)); + my(v=Vec(s),ct=eval(v[1]),out=""); + v=concat(v,99); \\ sentinel + for(i=2,#v, + if(v[i]>="0" && v[i]<="9", + ct=10*ct+eval(v[i]) + , + for(j=1,ct,out=Str(out,v[i])); + ct=0 + ) + ); + out +}; +rle("WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW") +elr(%) diff --git a/Task/Run-length-encoding/PHP/run-length-encoding.php b/Task/Run-length-encoding/PHP/run-length-encoding.php new file mode 100644 index 0000000000..a4f880ae2e --- /dev/null +++ b/Task/Run-length-encoding/PHP/run-length-encoding.php @@ -0,0 +1,12 @@ + diff --git a/Task/Run-length-encoding/PL-I/run-length-encoding.pli b/Task/Run-length-encoding/PL-I/run-length-encoding.pli new file mode 100644 index 0000000000..7f2bb18675 --- /dev/null +++ b/Task/Run-length-encoding/PL-I/run-length-encoding.pli @@ -0,0 +1,38 @@ +declare (c1, c2) character (1); +declare run_length fixed binary; +declare input file; + +open file (input) title ('/RLE.DAT,type(text),recsize(20000)'); +on endfile (input) go to epilog; + +get file (input) edit (c1) (a(1)); +run_length = 1; +do forever; + get file (input) edit (c2) (a(1)); + if c1 = c2 then + run_length = run_length + 1; + else + do; put edit (trim(run_length), c1) (a); run_length=1; end; + c1 = c2; +end; +epilog: + put edit (trim(run_length), c1) (a); + put skip; + + +/* The reverse of the above operation: */ +declare c character (1); +declare i fixed binary; +declare new file; + +open file (new) title ('/NEW.DAT,type(text),recsize(20000)'); +on endfile (new) stop; +do forever; + run_length = 0; + do forever; + get file (new) edit (c) (a(1)); + if index('0123456789', c) = 0 then leave; + run_length = run_length*10 + c; + end; + put edit ((c do i = 1 to run_length)) (a); +end; diff --git a/Task/Run-length-encoding/Pascal/run-length-encoding.pascal b/Task/Run-length-encoding/Pascal/run-length-encoding.pascal new file mode 100644 index 0000000000..ed482c81d1 --- /dev/null +++ b/Task/Run-length-encoding/Pascal/run-length-encoding.pascal @@ -0,0 +1,51 @@ +Program RunLengthEncoding(output); + +procedure encode(s: string; var counts: array of integer; var letters: string); + var + i, j: integer; + begin + j := 0; + letters := ''; + if length(s) > 0 then + begin + j := 1; + letters := letters + s[1]; + counts[1] := 1; + for i := 2 to length(s) do + if s[i] = letters[j] then + inc(counts[j]) + else + begin + inc(j); + letters := letters + s[i]; + counts[j] := 1; + end; + end; + end; + +procedure decode(var s: string; counts: array of integer; letters: string); + var + i, j: integer; + begin + s := ''; + for i := 1 to length(letters) do + for j := 1 to counts[i] do + s := s + letters[i]; + end; + +var + s: string; + counts: array of integer; + letters: string; + i: integer; +begin + s := 'WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWW'; + writeln(s); + setlength(counts, length(s)); + encode(s, counts, letters); + for i := 1 to length(letters) - 1 do + write(counts[i], ' * ', letters[i], ', '); + writeln(counts[length(letters)], ' * ', letters[length(letters)]); + decode(s, counts, letters); + writeln(s); +end. diff --git a/Task/Run-length-encoding/Perl-6/run-length-encoding.pl6 b/Task/Run-length-encoding/Perl-6/run-length-encoding.pl6 new file mode 100644 index 0000000000..ae3d9bce30 --- /dev/null +++ b/Task/Run-length-encoding/Perl-6/run-length-encoding.pl6 @@ -0,0 +1,7 @@ +sub encode($str) { $str.subst(/(.) $0*/, -> $/ { $/.chars ~ $0 ~ ' ' }, :g); } + +sub decode($str) { $str.subst(/(\d+) (.) ' '/, -> $/ {$1 x $0}, :g); } + +my $e = encode('WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW'); +say $e; +say decode($e); diff --git a/Task/Run-length-encoding/Perl/run-length-encoding-1.pl b/Task/Run-length-encoding/Perl/run-length-encoding-1.pl new file mode 100644 index 0000000000..d2023794ae --- /dev/null +++ b/Task/Run-length-encoding/Perl/run-length-encoding-1.pl @@ -0,0 +1,13 @@ +# functional approach (return the encoded or decoded string) +sub encode { + (my $str = shift) =~ s {(.)(\1*)} {length($&).$1}gse; + return $str; } +sub decode { + (my $str = shift) =~ s {(\d+)(.)} {$2 x $1}gse; + return $str;} + +# procedural approach (modify the argument in place) +sub encode { + $_[0] =~ s {(.)(\1*)} {length($&).$1}gse; } +sub decode { + $_[0] =~ s {(\d+)(.)} {$2 x $1}gse; } diff --git a/Task/Run-length-encoding/Perl/run-length-encoding-2.pl b/Task/Run-length-encoding/Perl/run-length-encoding-2.pl new file mode 100644 index 0000000000..09a65df427 --- /dev/null +++ b/Task/Run-length-encoding/Perl/run-length-encoding-2.pl @@ -0,0 +1,14 @@ +sub encode + {my $str = shift; + $str =~ s {(.)(\1{0,254})} {pack("C",(length($2) + 1)) . $1 }gse; + return $str;} + +sub decode +{ + my @str = split //, shift; + my $r = ""; + foreach my $i (0 .. scalar(@str)/2-1) { + $r .= $str[2*$i + 1] x unpack("C", $str[2*$i]); + } + return $r; +} diff --git a/Task/Run-length-encoding/PicoLisp/run-length-encoding.l b/Task/Run-length-encoding/PicoLisp/run-length-encoding.l new file mode 100644 index 0000000000..075939f030 --- /dev/null +++ b/Task/Run-length-encoding/PicoLisp/run-length-encoding.l @@ -0,0 +1,23 @@ +(de encode (Str) + (pack + (make + (for (Lst (chop Str) Lst) + (let (N 1 C) + (while (= (setq C (pop 'Lst)) (car Lst)) + (inc 'N) ) + (link N C) ) ) ) ) ) + +(de decode (Str) + (pack + (make + (let N 0 + (for C (chop Str) + (if (>= "9" C "0") + (setq N (+ (format C) (* 10 N))) + (do N (link C)) + (zero N) ) ) ) ) ) ) + +(and + (prinl "Data: " "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW") + (prinl "Encoded: " (encode @)) + (prinl "Decoded: " (decode @)) ) diff --git a/Task/Run-length-encoding/PowerBASIC/run-length-encoding.powerbasic b/Task/Run-length-encoding/PowerBASIC/run-length-encoding.powerbasic new file mode 100644 index 0000000000..36bc048e9a --- /dev/null +++ b/Task/Run-length-encoding/PowerBASIC/run-length-encoding.powerbasic @@ -0,0 +1,52 @@ +FUNCTION RLDecode (i AS STRING) AS STRING + DIM Loop0 AS LONG, rCount AS STRING, outP AS STRING, m AS STRING + + FOR Loop0 = 1 TO LEN(i) + m = MID$(i, Loop0, 1) + SELECT CASE m + CASE "0" TO "9" + rCount = rCount & m + CASE ELSE + IF LEN(rCount) THEN + outP = outP & STRING$(VAL(rCount), m) + rCount="" + ELSE + outP = outP & m + END IF + END SELECT + NEXT + FUNCTION = outP +END FUNCTION + +FUNCTION RLEncode (i AS STRING) AS STRING + DIM tmp1 AS STRING, tmp2 AS STRING, outP AS STRING + DIM Loop0 AS LONG, rCount AS LONG + + tmp1 = MID$(i, 1, 1) + tmp2 = tmp1 + rCount = 1 + + FOR Loop0 = 2 TO LEN(i) + tmp1 = MID$(i, Loop0, 1) + IF tmp1 <> tmp2 THEN + outP = outP & TRIM$(STR$(rCount)) & tmp2 + tmp2 = tmp1 + rCount = 1 + ELSE + INCR rCount + END IF + NEXT + + outP = outP & TRIM$(STR$(rCount)) + outP = outP & tmp2 + FUNCTION = outP +END FUNCTION + +FUNCTION PBMAIN () AS LONG + DIM initial AS STRING, encoded AS STRING, decoded AS STRING + initial = INPUTBOX$("Type something.") + encoded = RLEncode(initial) + decoded = RLDecode(encoded) + 'in PB/Win, "?" = MSGBOX; in PB/DOS & PB/CC. "?" = PRINT + ? initial & $CRLF & encoded & $CRLF & decoded +END FUNCTION diff --git a/Task/Run-length-encoding/PowerShell/run-length-encoding.psh b/Task/Run-length-encoding/PowerShell/run-length-encoding.psh new file mode 100644 index 0000000000..fa35b163bb --- /dev/null +++ b/Task/Run-length-encoding/PowerShell/run-length-encoding.psh @@ -0,0 +1,18 @@ +function Compress-RLE ($s) { + $re = [regex] '(.)\1*' + $ret = "" + foreach ($m in $re.Matches($s)) { + $ret += $m.Length + $ret += $m.Value[0] + } + return $ret +} + +function Expand-RLE ($s) { + $re = [regex] '(\d+)(.)' + $ret = "" + foreach ($m in $re.Matches($s)) { + $ret += [string] $m.Groups[2] * [int] [string] $m.Groups[1] + } + return $ret +} diff --git a/Task/Run-length-encoding/Prolog/run-length-encoding.pro b/Task/Run-length-encoding/Prolog/run-length-encoding.pro new file mode 100644 index 0000000000..a2a567d664 --- /dev/null +++ b/Task/Run-length-encoding/Prolog/run-length-encoding.pro @@ -0,0 +1,108 @@ +% the test +run_length :- + L = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW", + writef('encode %s\n', [L]), + encode(L, R), + writeln(R), nl, + writef('decode %w\n', [R]), + decode(R, L1), + writeln(L1). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% encode +% +% translation +% from +% "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" +% to +% "12W1B12W3B24W1B14W" +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +encode(In, Out) :- + % Because of the special management of the "strings" by Prolog + ( is_list(In) -> I = In; string_to_list(In, I)), + packList(I, R1), + dcg_packList2List(R1,R2, []), + string_to_list(Out,R2). + + + +dcg_packList2List([[N, V]|T]) --> + { number_codes(N, LN)}, + LN, + [V], + dcg_packList2List(T). + +dcg_packList2List([]) --> []. + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% decode +% +% translation +% from +% "12W1B12W3B24W1B14W" +% to +% "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +decode(In, Out) :- + % Because of the special management of the "strings" by Prolog + ( is_list(In) -> I = In; string_to_list(In, I)), + dcg_List2packList(I, R1, []), + packList(L1, R1), + string_to_list(Out, L1). + + +dcg_List2packList([H|T]) --> + {code_type(H, digit)}, + parse_number([H|T], 0). + +dcg_List2packList([]) --> []. + + +parse_number([H|T], N) --> + {code_type(H, digit), !, + N1 is N*10 + H - 48 }, + parse_number(T, N1). + +parse_number([H|T], N) --> + [[N, H]], + dcg_List2packList(T). + + +% use of library clpfd allows packList(?In, ?Out) to works +% in both ways In --> Out and In <-- Out. + +:- use_module(library(clpfd)). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% ?- packList([a,a,a,b,c,c,c,d,d,e], L). +% L = [[3,a],[1,b],[3,c],[2,d],[1,e]] . +% ?- packList(R, [[3,a],[1,b],[3,c],[2,d],[1,e]]). +% R = [a,a,a,b,c,c,c,d,d,e] . +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +packList([],[]). + +packList([X],[[1,X]]) :- !. + + +packList([X|Rest],[XRun|Packed]):- + run(X,Rest, XRun,RRest), + packList(RRest,Packed). + + +run(Var,[],[1,Var],[]). + +run(Var,[Var|LRest],[N1, Var],RRest):- + N #> 0, + N1 #= N + 1, + run(Var,LRest,[N, Var],RRest). + + +run(Var,[Other|RRest], [1,Var],[Other|RRest]):- + dif(Var,Other). diff --git a/Task/Run-length-encoding/Pure/run-length-encoding.pure b/Task/Run-length-encoding/Pure/run-length-encoding.pure new file mode 100644 index 0000000000..e225fa77fa --- /dev/null +++ b/Task/Run-length-encoding/Pure/run-length-encoding.pure @@ -0,0 +1,15 @@ +using system; + +encode s = strcat $ map (sprintf "%d%s") $ encode $ chars s with + encode [] = []; + encode xs@(x:_) = (#takewhile (==x) xs,x) : encode (dropwhile (==x) xs); +end; + +decode s = strcat [c | n,c = parse s; i = 1..n] with + parse s::string = regexg item "([0-9]+)(.)" REG_EXTENDED s 0; + item info = val (reg 1 info!1), reg 2 info!1; +end; + +let s = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW"; +let r = encode s; // "12W1B12W3B24W1B14W" +decode r; diff --git a/Task/Run-length-encoding/PureBasic/run-length-encoding.purebasic b/Task/Run-length-encoding/PureBasic/run-length-encoding.purebasic new file mode 100644 index 0000000000..b6f2a3e106 --- /dev/null +++ b/Task/Run-length-encoding/PureBasic/run-length-encoding.purebasic @@ -0,0 +1,66 @@ +Procedure.s RLDecode(toDecode.s) + Protected.s repCount, output, currChar, tmp + Protected *c.Character = @toDecode + + While *c\c <> #Null + currChar = Chr(*c\c) + Select *c\c + Case '0' To '9' + repCount + currChar + Default + If repCount + tmp = Space(Val(repCount)) + ReplaceString(tmp, " ", currChar, #PB_String_InPlace) + output + tmp + repCount = "" + Else + output + currChar + EndIf + EndSelect + *c + SizeOf(Character) + Wend + + ProcedureReturn output +EndProcedure + +Procedure.s RLEncode(toEncode.s) + Protected.s currChar, prevChar, output + Protected repCount + Protected *c.Character = @toEncode + + prevChar = Chr(*c\c) + repCount = 1 + + *c + SizeOf(Character) + While *c\c <> #Null + currChar = Chr(*c\c) + If currChar <> prevChar + output + Str(repCount) + prevChar + prevChar = currChar + repCount = 1 + Else + repCount + 1 + EndIf + *c + SizeOf(Character) + Wend + + output + Str(repCount) + output + prevChar + ProcedureReturn output +EndProcedure + +If OpenConsole() + Define initial.s, encoded.s, decoded.s + + Print("Type something: ") + initial = Input() + encoded = RLEncode(initial) + decoded = RLDecode(encoded) + PrintN(initial) + PrintN(RLEncode(initial)) + PrintN(RLDecode(encoded)) + + Print(#CRLF$ + #CRLF$ + "Press ENTER to exit") + Input() + CloseConsole() +EndIf diff --git a/Task/Run-length-encoding/Python/run-length-encoding-1.py b/Task/Run-length-encoding/Python/run-length-encoding-1.py new file mode 100644 index 0000000000..941b463083 --- /dev/null +++ b/Task/Run-length-encoding/Python/run-length-encoding-1.py @@ -0,0 +1,29 @@ +def encode(input_string): + count = 1 + prev = '' + lst = [] + for character in input_string: + if character != prev: + if prev: + entry = (prev,count) + lst.append(entry) + #print lst + count = 1 + prev = character + else: + count += 1 + else: + entry = (character,count) + lst.append(entry) + return lst + + +def decode(lst): + q = "" + for character, count in lst: + q += character * count + return q + +#Method call +encode("aaaaahhhhhhmmmmmmmuiiiiiiiaaaaaa") +decode([('a', 5), ('h', 6), ('m', 7), ('u', 1), ('i', 7), ('a', 6)]) diff --git a/Task/Run-length-encoding/Python/run-length-encoding-2.py b/Task/Run-length-encoding/Python/run-length-encoding-2.py new file mode 100644 index 0000000000..240f793ed0 --- /dev/null +++ b/Task/Run-length-encoding/Python/run-length-encoding-2.py @@ -0,0 +1,9 @@ +from itertools import groupby +def encode(input_string): + return [(len(list(g)), k) for k,g in groupby(input_string)] + +def decode(lst): + return ''.join(c * n for n,c in lst) + +encode("aaaaahhhhhhmmmmmmmuiiiiiiiaaaaaa") +decode([(5, 'a'), (6, 'h'), (7, 'm'), (1, 'u'), (7, 'i'), (6, 'a')]) diff --git a/Task/Run-length-encoding/Python/run-length-encoding-3.py b/Task/Run-length-encoding/Python/run-length-encoding-3.py new file mode 100644 index 0000000000..3708627be1 --- /dev/null +++ b/Task/Run-length-encoding/Python/run-length-encoding-3.py @@ -0,0 +1,22 @@ +from re import sub + +def encode(text): + ''' + Doctest: + >>> encode('WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW') + '12W1B12W3B24W1B14W' + ''' + return sub(r'(.)\1*', lambda m: str(len(m.group(0))) + m.group(1), + text) + +def decode(text): + ''' + Doctest: + >>> decode('12W1B12W3B24W1B14W') + 'WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW' + ''' + return sub(r'(\d+)(\D)', lambda m: m.group(2) * int(m.group(1)), + text) + +textin = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" +assert decode(encode(textin)) == textin diff --git a/Task/Run-length-encoding/R/run-length-encoding-1.r b/Task/Run-length-encoding/R/run-length-encoding-1.r new file mode 100644 index 0000000000..abef9fbd88 --- /dev/null +++ b/Task/Run-length-encoding/R/run-length-encoding-1.r @@ -0,0 +1,9 @@ +runlengthencoding <- function(x) +{ + splitx <- unlist(strsplit(input, "")) + rlex <- rle(splitx) + paste(with(rlex, as.vector(rbind(lengths, values))), collapse="") +} + +input <- "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" +runlengthencoding(input) diff --git a/Task/Run-length-encoding/R/run-length-encoding-2.r b/Task/Run-length-encoding/R/run-length-encoding-2.r new file mode 100644 index 0000000000..d0931616c0 --- /dev/null +++ b/Task/Run-length-encoding/R/run-length-encoding-2.r @@ -0,0 +1,11 @@ +inverserunlengthencoding <- function(x) +{ + lengths <- as.numeric(unlist(strsplit(output, "[[:alpha:]]"))) + values <- unlist(strsplit(output, "[[:digit:]]")) + values <- values[values != ""] + uncompressed <- inverse.rle(list(lengths=lengths, values=values)) + paste(uncompressed, collapse="") +} + +output <- "12W1B12W3B24W1B14W" +inverserunlengthencoding(output) diff --git a/Task/Run-length-encoding/REXX/run-length-encoding-1.rexx b/Task/Run-length-encoding/REXX/run-length-encoding-1.rexx new file mode 100644 index 0000000000..7b68abb01c --- /dev/null +++ b/Task/Run-length-encoding/REXX/run-length-encoding-1.rexx @@ -0,0 +1,23 @@ +/*REXX program encodes string by using a run-length scheme (min len=2).*/ +parse arg x /*normally, input would be a file*/ +def='WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW' +if x=='' then x=def /*No input? Then use the default*/ +Lx=length(x) /*get the length of the X string.*/ +y= /*Y is the output string (so far)*/ + do j=1 to Lx /*warning! J is modified below.*/ + c=substr(x,j,1) /*pick a character, check for err*/ + if \datatype(c,'m') then do;say "error!: data isn't alphabetic";exit 13; end + r=0 /*R is NOT the number of chars. */ + + do k=j+1 to Lx while substr(x,k,1)==c + r=r+1 /*R is a replication count. */ + end /*k*/ + + if r==0 then Y = Y || c /*C wan't repeated, just OUT it.*/ + else Y = Y || r || c /*add it to the encoded string. */ + j=j+r /*A bad thing to do, but simple. */ + end /*j*/ + +say ' input=' x +say 'encoded=' y + /*stick a fork in it, we're done.*/ diff --git a/Task/Run-length-encoding/REXX/run-length-encoding-2.rexx b/Task/Run-length-encoding/REXX/run-length-encoding-2.rexx new file mode 100644 index 0000000000..ba2e4e6ffe --- /dev/null +++ b/Task/Run-length-encoding/REXX/run-length-encoding-2.rexx @@ -0,0 +1,24 @@ +/*REXX program decodes string by using a run-length scheme (min len=2).*/ +parse arg x /*normally, input would be a file*/ +if x=='' then x='11WB11W2B23WB13W' /*No input? Then use the default*/ +Lx=length(x) /*get the length of the X string.*/ +y= /*Y is the output string (so far)*/ + do j=1 to Lx /*warning! J is modified below.*/ + c=substr(x,j,1) + if \datatype(c,'W') then do /*a loner char, simply add to OUT*/ + y=y || c + iterate + end + d=1 + do k=j+1 to Lx while datatype(substr(x,k,1),'w') /*look for #end*/ + d=d+1 /*d is the number of digs so far.*/ + end /*k*/ + + n=substr(x,j,d)+1 /*D is length of encoded number.*/ + y=y || copies(substr(x,k,1),n) /*N is now the number of chars. */ + j=j+d /*A bad thing to do, but simple. */ + end /*j*/ + +say ' input=' x +say 'decoded=' y + /*stick a fork in it, we're done.*/ diff --git a/Task/Run-length-encoding/Ruby/run-length-encoding-1.rb b/Task/Run-length-encoding/Ruby/run-length-encoding-1.rb new file mode 100644 index 0000000000..a594cd7116 --- /dev/null +++ b/Task/Run-length-encoding/Ruby/run-length-encoding-1.rb @@ -0,0 +1,14 @@ +def encode(string) + string.scan(/(.)(\1*)/).collect do |char, repeat| + [char, 1 + repeat.length] + end +end + +def decode(encoding) + encoding.collect { |char, length| char * length }.join +end + +orig = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" +enc = encode(orig) # => [["W", 12], ["B", 1], ["W", 12], ["B", 3], ["W", 24], ["B", 1], ["W", 14]] +dec = decode(enc) +puts "success!" if dec == orig diff --git a/Task/Run-length-encoding/Ruby/run-length-encoding-2.rb b/Task/Run-length-encoding/Ruby/run-length-encoding-2.rb new file mode 100644 index 0000000000..8ebfe0e871 --- /dev/null +++ b/Task/Run-length-encoding/Ruby/run-length-encoding-2.rb @@ -0,0 +1,15 @@ +def encode(string) + encoding = [] + for char, repeat in string.scan(/(.)(\1*)/) + encoding << [char, 1 + repeat.length] + end + encoding +end + +def decode(encoding) + decoding = "" + for char, length in encoding + decoding << char * length + end + decoding +end diff --git a/Task/Run-length-encoding/Ruby/run-length-encoding-3.rb b/Task/Run-length-encoding/Ruby/run-length-encoding-3.rb new file mode 100644 index 0000000000..b8befa41cc --- /dev/null +++ b/Task/Run-length-encoding/Ruby/run-length-encoding-3.rb @@ -0,0 +1,10 @@ +def encode(str) + str.gsub(/(.)\1*/) {$&.length.to_s + $1} +end + +def decode(str) + str.gsub(/(\d+)(\D)/) {$2 * $1.to_i} +end + +encode('WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW') #=> "12W1B12W3B24W1B14W" +decode('12W1B12W3B24W1B14W') #=> "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" diff --git a/Task/Run-length-encoding/Run-BASIC/run-length-encoding.run b/Task/Run-length-encoding/Run-BASIC/run-length-encoding.run new file mode 100644 index 0000000000..21b35903b2 --- /dev/null +++ b/Task/Run-length-encoding/Run-BASIC/run-length-encoding.run @@ -0,0 +1,26 @@ +string$ = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" +beg = 1 +i = 1 +[loop] +s$ = mid$(string$,beg,1) +while mid$(string$,i,1) = s$ + i = i + 1 +wend +press$ = press$ ; i-beg;s$ +beg = i +if i < len(string$) then goto [loop] +print "Compressed:";press$ + +beg = 1 +i = 1 +[expand] +while mid$(press$,i,1) <= "9" + i = i + 1 +wend +for j = 1 to val(mid$(press$,beg, i - beg)) + expand$ = expand$ + mid$(press$,i,1) +next j +i = i + 1 +beg = i +if i < len(press$) then goto [expand] +print " Expanded:";expand$ diff --git a/Task/Run-length-encoding/SNOBOL4/run-length-encoding.sno b/Task/Run-length-encoding/SNOBOL4/run-length-encoding.sno new file mode 100644 index 0000000000..b17438ec90 --- /dev/null +++ b/Task/Run-length-encoding/SNOBOL4/run-length-encoding.sno @@ -0,0 +1,19 @@ +* # Encode RLE + define('rle(str)c,n') :(rle_end) +rle str len(1) . c :f(return) + str span(c) @n = + rle = rle n c :(rle) +rle_end + +* # Decode RLE + define('elr(str)c,n') :(elr_end) +elr str span('0123456789') . n len(1) . c = :f(return) + elr = elr dupl(c,n) :(elr) +elr_end + +* # Test and display + str = 'WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW' + output = str; + str = rle(str); output = str + str = elr(str); output = str +end diff --git a/Task/Run-length-encoding/Scala/run-length-encoding-1.scala b/Task/Run-length-encoding/Scala/run-length-encoding-1.scala new file mode 100644 index 0000000000..7eeafa1c88 --- /dev/null +++ b/Task/Run-length-encoding/Scala/run-length-encoding-1.scala @@ -0,0 +1,13 @@ +def encode(s: String) = (1 until s.size).foldLeft((1, s(0), new StringBuilder)) { + case ((len, c, sb), index) if c != s(index) => sb.append(len); sb.append(c); (1, s(index), sb) + case ((len, c, sb), _) => (len + 1, c, sb) +} match { + case (len, c, sb) => sb.append(len); sb.append(c); sb.toString +} + +def decode(s: String) = { + val sb = new StringBuilder + val Code = """(\d+)([A-Z])""".r + for (Code(len, c) <- Code findAllIn s) sb.append(c * len.toInt) + sb.toString +} diff --git a/Task/Run-length-encoding/Scala/run-length-encoding-2.scala b/Task/Run-length-encoding/Scala/run-length-encoding-2.scala new file mode 100644 index 0000000000..5b182c9a4d --- /dev/null +++ b/Task/Run-length-encoding/Scala/run-length-encoding-2.scala @@ -0,0 +1,4 @@ +def encode(s:String) = { + s.foldLeft((0,s(0),""))( (t,c) => t match {case (i,p,s) => if (p==c) (i+1,p,s) else (1,c,s+i+p)}) + match {case (i,p,s) => s+i+p} +} diff --git a/Task/Run-length-encoding/Scheme/run-length-encoding.ss b/Task/Run-length-encoding/Scheme/run-length-encoding.ss new file mode 100644 index 0000000000..b96440a7f7 --- /dev/null +++ b/Task/Run-length-encoding/Scheme/run-length-encoding.ss @@ -0,0 +1,15 @@ +(define (run-length-decode v) + (apply string-append (map (lambda (p) (make-string (car p) (cdr p))) v))) + +(define (run-length-encode s) +(let ((n (string-length s))) +(let loop ((i (- n 2)) (c (string-ref s (- n 1))) (k 1) (v '())) +(if (negative? i) (cons (cons k c) v) + (let ((x (string-ref s i))) + (if (char=? c x) (loop (- i 1) c (+ k 1) v) + (loop (- i 1) x 1 (cons (cons k c) v)))))))) + +(run-length-encode "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW") +; ((12 . #\W) (1 . #\B) (12 . #\W) (3 . #\B) (24 . #\W) (1 . #\B) (14 . #\W)) +(run-length-decode '((12 . #\W) (1 . #\B) (12 . #\W) (3 . #\B) (24 . #\W) (1 . #\B) (14 . #\W))) +; "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" diff --git a/Task/Run-length-encoding/Seed7/run-length-encoding.seed7 b/Task/Run-length-encoding/Seed7/run-length-encoding.seed7 new file mode 100644 index 0000000000..fd949fcf2a --- /dev/null +++ b/Task/Run-length-encoding/Seed7/run-length-encoding.seed7 @@ -0,0 +1,36 @@ +$ include "seed7_05.s7i"; + include "scanstri.s7i"; + +const func string: letterRleEncode (in string: data) is func + result + var string: result is ""; + local + var char: code is ' '; + var integer: index is 1; + begin + if length(data) <> 0 then + code := data[1]; + repeat + incr(index); + until index > length(data) or code <> data[index]; + result := str(pred(index)) & str(code) & letterRleEncode(data[index ..]); + end if; + end func; + +const func string: letterRleDecode (in var string: data) is func + result + var string: result is ""; + local + var integer: count is 0; + begin + if length(data) <> 0 then + count := integer parse getDigits(data); + result := data[1 len 1] mult count & letterRleDecode(data[2 ..]); + end if; + end func; + +const proc: main is func + begin + writeln(letterRleEncode("WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW")); + writeln(letterRleDecode("12W1B12W3B24W1B14W")); + end func; diff --git a/Task/Run-length-encoding/Standard-ML/run-length-encoding.ml b/Task/Run-length-encoding/Standard-ML/run-length-encoding.ml new file mode 100644 index 0000000000..e0333f6f0c --- /dev/null +++ b/Task/Run-length-encoding/Standard-ML/run-length-encoding.ml @@ -0,0 +1,17 @@ +fun encode str = + let + fun aux (sub, acc) = + case Substring.getc sub + of NONE => rev acc + | SOME (x, sub') => + let + val (y, z) = Substring.splitl (fn c => c = x) sub' + in + aux (z, (x, Substring.size y + 1) :: acc) + end + in + aux (Substring.full str, []) + end + +fun decode lst = + concat (map (fn (c,n) => implode (List.tabulate (n, fn _ => c))) lst) diff --git a/Task/Run-length-encoding/TUSCRIPT/run-length-encoding.tuscript b/Task/Run-length-encoding/TUSCRIPT/run-length-encoding.tuscript new file mode 100644 index 0000000000..74d9f026ea --- /dev/null +++ b/Task/Run-length-encoding/TUSCRIPT/run-length-encoding.tuscript @@ -0,0 +1,9 @@ +$$ MODE TUSCRIPT,{} +input="WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW",output="" +string=strings(input," ? ") +letter=ACCUMULATE(string,freq) +freq=SPLIT(freq),letter=SPLIT(letter) +output=JOIN(freq,"",letter) +output=JOIN(output,"") +PRINT input +PRINT output diff --git a/Task/Run-length-encoding/Tcl/run-length-encoding-1.tcl b/Task/Run-length-encoding/Tcl/run-length-encoding-1.tcl new file mode 100644 index 0000000000..11ebb85497 --- /dev/null +++ b/Task/Run-length-encoding/Tcl/run-length-encoding-1.tcl @@ -0,0 +1,15 @@ +proc encode {string} { + set encoding {} + # use a regular expression to match runs of one character + foreach {run -} [regexp -all -inline {(.)\1+|.} $string] { + lappend encoding [string length $run] [string index $run 0] + } + return $encoding +} + +proc decode {encoding} { + foreach {count char} $encoding { + append decoded [string repeat $char $count] + } + return $decoded +} diff --git a/Task/Run-length-encoding/Tcl/run-length-encoding-2.tcl b/Task/Run-length-encoding/Tcl/run-length-encoding-2.tcl new file mode 100644 index 0000000000..26b56392a2 --- /dev/null +++ b/Task/Run-length-encoding/Tcl/run-length-encoding-2.tcl @@ -0,0 +1,6 @@ +set str "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" +set enc [encode $str] ;# ==> {12 W 1 B 12 W 3 B 24 W 1 B 14 W} +set dec [decode $enc] +if {$str eq $dec} { + puts "success" +} diff --git a/Task/Run-length-encoding/Ursala/run-length-encoding.ursala b/Task/Run-length-encoding/Ursala/run-length-encoding.ursala new file mode 100644 index 0000000000..c3bf526be1 --- /dev/null +++ b/Task/Run-length-encoding/Ursala/run-length-encoding.ursala @@ -0,0 +1,16 @@ +#import std +#import nat + +encode = (rlc ==); *= ^lhPrNCT\~&h %nP+ length + +decode = (rlc ~&l-=digits); *=zyNCXS ^|DlS/~& iota+ %np + +test_data = 'WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW' + +#show+ + +example = + +< + encode test_data, + decode encode test_data> diff --git a/Task/Run-length-encoding/Vedit-macro-language/run-length-encoding.vedit b/Task/Run-length-encoding/Vedit-macro-language/run-length-encoding.vedit new file mode 100644 index 0000000000..1b89433674 --- /dev/null +++ b/Task/Run-length-encoding/Vedit-macro-language/run-length-encoding.vedit @@ -0,0 +1,31 @@ +:RL_ENCODE: +BOF +While (!At_EOF) { + if (At_EOL) { Line(1) Continue } // skip newlines + #1 = Cur_Char // #1 = character + Match("(.)\1*", REGEXP) // count run length + #2 = Chars_Matched // #2 = run length + if (#2 > 127) { #2 = 127 } // can be max 127 + if (#2 > 1 || #1 > 127) { + Del_Char(#2) + Ins_Char(#2 | 128) // run length (high bit set) + Ins_Char(#1) // character + } else { // single ASCII char + Char // skip + } +} +Return + +:RL_DECODE: +BOF +While (!At_EOF) { + #2 = Cur_Char + if (#2 > 127) { // is this run length? + #1 = Cur_Char(1) // #1 = character value + Del_Char(2) + Ins_Char(#1, COUNT, #2 & 127) + } else { // single ASCII char + Char + } +} +Return diff --git a/Task/Run-length-encoding/XPL0/run-length-encoding.xpl0 b/Task/Run-length-encoding/XPL0/run-length-encoding.xpl0 new file mode 100644 index 0000000000..6d2908bc56 --- /dev/null +++ b/Task/Run-length-encoding/XPL0/run-length-encoding.xpl0 @@ -0,0 +1,41 @@ +include c:\cxpl\codes; \intrinsic 'code' declarations +string 0; \use zero-terminated strings, instead of MSb terminated + +proc Compress(S); \Compress string using run-length encoding, & display it +char S; +int I, C0, C, N; +[I:= 0; +C0:= S(I); I:= I+1; +repeat ChOut(0, C0); + N:= 0; + repeat C:= S(I); I:= I+1; + N:= N+1; + until C#C0; + if N>1 then IntOut(0, N-1); + C0:= C; +until C=0; +]; \Compress + +proc Expand(S); \Expand compressed string, and display it +char S; +int I, C0, C, N; +[I:= 0; +C0:= S(I); I:= I+1; +repeat ChOut(0, C0); + C:= S(I); I:= I+1; + if C>=^1 & C<=^9 then + [N:= 0; + while C>=^0 & C<=^9 do + [N:= N*10 + C-^0; + C:= S(I); I:= I+1; + ]; + while N do [ChOut(0, C0); N:= N-1]; + ]; + C0:= C; +until C=0; +]; \Expand + +[Compress("WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW"); +CrLf(0); +Expand("W11BW11B2W23BW13"); CrLf(0); +] diff --git a/Task/Runtime-evaluation-In-an-environment/0DESCRIPTION b/Task/Runtime-evaluation-In-an-environment/0DESCRIPTION new file mode 100644 index 0000000000..d161a8b0cd --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/0DESCRIPTION @@ -0,0 +1,11 @@ + Given a program in the language (as a string or AST) with a free variable named x (or another name if that is not valid syntax), evaluate it with x bound to a provided value, then evaluate it again with x bound to another provided value, then subtract the result of the first from the second and return or print it. + +Do so in a way which: +* does not involve string manipulation of the input source code +* is plausibly extensible to a runtime-chosen set of bindings rather than just x +* does not make x a ''global'' variable +or note that these are impossible. + +===See also=== +* For more general examples and language-specific details, see [[Eval]]. +* [[Dynamic variable names]] is a similar task. diff --git a/Task/Runtime-evaluation-In-an-environment/ALGOL-68/runtime-evaluation-in-an-environment.alg b/Task/Runtime-evaluation-In-an-environment/ALGOL-68/runtime-evaluation-in-an-environment.alg new file mode 100644 index 0000000000..b3557c1d09 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/ALGOL-68/runtime-evaluation-in-an-environment.alg @@ -0,0 +1,3 @@ +PROC eval_with_x = (STRING code, INT a, b)STRING: + (INT x=a; evaluate(code) ) + (INT x=b; evaluate(code)); +print((eval_with_x("2 ** x", 3, 5), new line)) diff --git a/Task/Runtime-evaluation-In-an-environment/AutoHotkey/runtime-evaluation-in-an-environment.ahk b/Task/Runtime-evaluation-In-an-environment/AutoHotkey/runtime-evaluation-in-an-environment.ahk new file mode 100644 index 0000000000..4cb5a9e25d --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/AutoHotkey/runtime-evaluation-in-an-environment.ahk @@ -0,0 +1,32 @@ +msgbox % first := evalWithX("x + 4", 5) +msgbox % second := evalWithX("x + 4", 6) +msgbox % second - first +return + +evalWithX(expression, xvalue) +{ +global script +script = +( + expression(){ + x = %xvalue% ; := would need quotes + return %expression% + } +) +renameFunction("expression", "") ; remove any previous expressions +gosub load ; cannot use addScript inside a function yet +exp := "expression" +return %exp%() +} + +load: +DllCall(A_AhkPath "\addScript","Str",script,"Uchar",0,"Cdecl UInt") +return + +renameFunction(funcName, newname){ +static +x%newname% := newname ; store newname in a static variable so its memory is not freed +strput(newname, &x%newname%, strlen(newname) + 1) +if fnp := FindFunc(funcName) + numput(&x%newname%, fnp+0, 0, "uint") +} diff --git a/Task/Runtime-evaluation-In-an-environment/BBC-BASIC/runtime-evaluation-in-an-environment.bbc b/Task/Runtime-evaluation-In-an-environment/BBC-BASIC/runtime-evaluation-in-an-environment.bbc new file mode 100644 index 0000000000..c113ccb6b9 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/BBC-BASIC/runtime-evaluation-in-an-environment.bbc @@ -0,0 +1,8 @@ + expression$ = "x^2 - 7" + one = FN_eval_with_x(expression$, 1.2) + two = FN_eval_with_x(expression$, 3.4) + PRINT two - one + END + + DEF FN_eval_with_x(expr$, x) + = EVAL(expr$) diff --git a/Task/Runtime-evaluation-In-an-environment/Common-Lisp/runtime-evaluation-in-an-environment-1.lisp b/Task/Runtime-evaluation-In-an-environment/Common-Lisp/runtime-evaluation-in-an-environment-1.lisp new file mode 100644 index 0000000000..c6e08c1c07 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/Common-Lisp/runtime-evaluation-in-an-environment-1.lisp @@ -0,0 +1,4 @@ +(defun eval-with-x (program a b) + (let ((at-a (eval `(let ((x ',a)) ,program))) + (at-b (eval `(let ((x ',b)) ,program)))) + (- at-b at-a))) diff --git a/Task/Runtime-evaluation-In-an-environment/Common-Lisp/runtime-evaluation-in-an-environment-2.lisp b/Task/Runtime-evaluation-In-an-environment/Common-Lisp/runtime-evaluation-in-an-environment-2.lisp new file mode 100644 index 0000000000..cb1129295f --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/Common-Lisp/runtime-evaluation-in-an-environment-2.lisp @@ -0,0 +1,2 @@ +(eval-with-x '(exp x) 0 1) +=> 1.7182817 diff --git a/Task/Runtime-evaluation-In-an-environment/Common-Lisp/runtime-evaluation-in-an-environment-3.lisp b/Task/Runtime-evaluation-In-an-environment/Common-Lisp/runtime-evaluation-in-an-environment-3.lisp new file mode 100644 index 0000000000..3a78836cd2 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/Common-Lisp/runtime-evaluation-in-an-environment-3.lisp @@ -0,0 +1,5 @@ +(defun eval-with-x (program a b) + (let* ((f (compile nil `(lambda (x) ,program))) + (at-a (funcall f a)) + (at-b (funcall f b))) + (- at-b at-a))) diff --git a/Task/Runtime-evaluation-In-an-environment/E/runtime-evaluation-in-an-environment-1.e b/Task/Runtime-evaluation-In-an-environment/E/runtime-evaluation-in-an-environment-1.e new file mode 100644 index 0000000000..018bbdeb40 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/E/runtime-evaluation-in-an-environment-1.e @@ -0,0 +1,15 @@ +# Constructing an environment has to be done by way of evaluation +#for historical reasons which will hopefully be entirely eliminated soon. +def bindX(value) { + def [resolver, env] := e` # bind x and capture its resolver and the + def x # resulting environment + `.evalToPair(safeScope) + resolver.resolve(value) # set the value + return env +} + +def evalWithX(program, a, b) { + def atA := program.eval(bindX(a)) + def atB := program.eval(bindX(b)) + return atB - atA +} diff --git a/Task/Runtime-evaluation-In-an-environment/E/runtime-evaluation-in-an-environment-2.e b/Task/Runtime-evaluation-In-an-environment/E/runtime-evaluation-in-an-environment-2.e new file mode 100644 index 0000000000..6ca7e94dcb --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/E/runtime-evaluation-in-an-environment-2.e @@ -0,0 +1,2 @@ +? evalWithX(e`(x :float64).exp()`, 0, 1) +# value: 1.7182818284590455 diff --git a/Task/Runtime-evaluation-In-an-environment/Forth/runtime-evaluation-in-an-environment-1.fth b/Task/Runtime-evaluation-In-an-environment/Forth/runtime-evaluation-in-an-environment-1.fth new file mode 100644 index 0000000000..ed479c3879 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/Forth/runtime-evaluation-in-an-environment-1.fth @@ -0,0 +1,7 @@ +: f-" ( a b snippet" -- ) + [char] " parse ( code len ) + 2dup 2>r evaluate + swap 2r> evaluate + - . ; + +2 3 f-" dup *" \ 5 (3*3 - 2*2) diff --git a/Task/Runtime-evaluation-In-an-environment/Forth/runtime-evaluation-in-an-environment-2.fth b/Task/Runtime-evaluation-In-an-environment/Forth/runtime-evaluation-in-an-environment-2.fth new file mode 100644 index 0000000000..e3f889ffc0 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/Forth/runtime-evaluation-in-an-environment-2.fth @@ -0,0 +1,15 @@ +: :macro ( "name ccc" -- ) + : [CHAR] ; PARSE POSTPONE SLITERAL POSTPONE EVALUATE + POSTPONE ; IMMEDIATE +; + +:macro times 0 do ; + +: test 8 times ." spam " loop ; + +see test +: test + 8 0 + DO .\" spam " + LOOP + ; ok diff --git a/Task/Runtime-evaluation-In-an-environment/Genyris/runtime-evaluation-in-an-environment-1.genyris b/Task/Runtime-evaluation-In-an-environment/Genyris/runtime-evaluation-in-an-environment-1.genyris new file mode 100644 index 0000000000..0f8bb281f2 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/Genyris/runtime-evaluation-in-an-environment-1.genyris @@ -0,0 +1,7 @@ +defmacro add100() (+ x 100) + +var x 23 +var firstresult (add100) +x = 1000 +print + + firstresult (add100) diff --git a/Task/Runtime-evaluation-In-an-environment/Genyris/runtime-evaluation-in-an-environment-2.genyris b/Task/Runtime-evaluation-In-an-environment/Genyris/runtime-evaluation-in-an-environment-2.genyris new file mode 100644 index 0000000000..8d93a933c3 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/Genyris/runtime-evaluation-in-an-environment-2.genyris @@ -0,0 +1,8 @@ +def add100() (+ .x 100) + +(dict) # create an environment capable of holding dynamic bindings + var .x 23 # create a binding in the dictionary + var firstresult (add100) + .x = 1000 + print + + firstresult (add100) diff --git a/Task/Runtime-evaluation-In-an-environment/Genyris/runtime-evaluation-in-an-environment-3.genyris b/Task/Runtime-evaluation-In-an-environment/Genyris/runtime-evaluation-in-an-environment-3.genyris new file mode 100644 index 0000000000..cb692456d7 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/Genyris/runtime-evaluation-in-an-environment-3.genyris @@ -0,0 +1,4 @@ +(dict) + var .x 23 + (dict) + print .x # fails diff --git a/Task/Runtime-evaluation-In-an-environment/Go/runtime-evaluation-in-an-environment.go b/Task/Runtime-evaluation-In-an-environment/Go/runtime-evaluation-in-an-environment.go new file mode 100644 index 0000000000..f27441a8a8 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/Go/runtime-evaluation-in-an-environment.go @@ -0,0 +1,67 @@ +package main + +import ( + "bitbucket.org/binet/go-eval/pkg/eval" + "fmt" + "go/parser" + "go/token" +) + +func main() { + // an expression on x + squareExpr := "x*x" + + // parse to abstract syntax tree + fset := token.NewFileSet() + squareAst, err := parser.ParseExpr(squareExpr) + if err != nil { + fmt.Println(err) + return + } + // create an environment or "world" + w := eval.NewWorld() + + // allocate a variable + wVar := new(intV) + + // bind the variable to the name x + err = w.DefineVar("x", eval.IntType, wVar) + if err != nil { + fmt.Println(err) + return + } + // bind the expression AST to the world + squareCode, err := w.CompileExpr(fset, squareAst) + if err != nil { + fmt.Println(err) + return + } + // directly manipulate value of variable within world + *wVar = 5 + // evaluate + r0, err := squareCode.Run() + if err != nil { + fmt.Println(err) + return + } + // change value + *wVar-- + // revaluate + r1, err := squareCode.Run() + if err != nil { + fmt.Println(err) + return + } + // print difference + fmt.Println(r0.(eval.IntValue).Get(nil) - r1.(eval.IntValue).Get(nil)) +} + +// int value implementation. +type intV int64 + +func (v *intV) String() string { return fmt.Sprint(*v) } +func (v *intV) Get(*eval.Thread) int64 { return int64(*v) } +func (v *intV) Set(_ *eval.Thread, x int64) { *v = intV(x) } +func (v *intV) Assign(t *eval.Thread, o eval.Value) { + *v = intV(o.(eval.IntValue).Get(t)) +} diff --git a/Task/Runtime-evaluation-In-an-environment/Groovy/runtime-evaluation-in-an-environment-1.groovy b/Task/Runtime-evaluation-In-an-environment/Groovy/runtime-evaluation-in-an-environment-1.groovy new file mode 100644 index 0000000000..de2e68a3df --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/Groovy/runtime-evaluation-in-an-environment-1.groovy @@ -0,0 +1,3 @@ +def cruncher = { x1, x2, program -> + Eval.x(x1, program) - Eval.x(x2, program) +} diff --git a/Task/Runtime-evaluation-In-an-environment/Groovy/runtime-evaluation-in-an-environment-2.groovy b/Task/Runtime-evaluation-In-an-environment/Groovy/runtime-evaluation-in-an-environment-2.groovy new file mode 100644 index 0000000000..dddabfa480 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/Groovy/runtime-evaluation-in-an-environment-2.groovy @@ -0,0 +1,5 @@ +def fibonacciProgram = ''' +x < 1 ? 0 : x == 1 ? 1 : (2..x).inject([0,1]){i, j -> [i[1], i[0]+i[1]]}[1] +''' + +println "F(${10}) - F(${5}) = ${Eval.x(10, fibonacciProgram)} - ${Eval.x(5, fibonacciProgram)} = " + cruncher(10, 5, fibonacciProgram) diff --git a/Task/Runtime-evaluation-In-an-environment/J/runtime-evaluation-in-an-environment-1.j b/Task/Runtime-evaluation-In-an-environment/J/runtime-evaluation-in-an-environment-1.j new file mode 100644 index 0000000000..a2adf169f9 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/J/runtime-evaluation-in-an-environment-1.j @@ -0,0 +1,7 @@ + EvalWithX=. monad : 0 + 'CODE V0 V1'=. y + (". CODE [ x=. V1) - (". CODE [ x=. V0) + ) + + EvalWithX '^x';0;1 +1.71828183 diff --git a/Task/Runtime-evaluation-In-an-environment/J/runtime-evaluation-in-an-environment-2.j b/Task/Runtime-evaluation-In-an-environment/J/runtime-evaluation-in-an-environment-2.j new file mode 100644 index 0000000000..b98afec275 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/J/runtime-evaluation-in-an-environment-2.j @@ -0,0 +1,2 @@ + (0&({::) -~&>/@:(128!:2&.>) 1 2&{) '^';0;1 +1.71828183 diff --git a/Task/Runtime-evaluation-In-an-environment/J/runtime-evaluation-in-an-environment-3.j b/Task/Runtime-evaluation-In-an-environment/J/runtime-evaluation-in-an-environment-3.j new file mode 100644 index 0000000000..30faf99392 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/J/runtime-evaluation-in-an-environment-3.j @@ -0,0 +1,3 @@ +EvalDiffWithY=: dyad define + -~/verb def x"_1 y +) diff --git a/Task/Runtime-evaluation-In-an-environment/J/runtime-evaluation-in-an-environment-4.j b/Task/Runtime-evaluation-In-an-environment/J/runtime-evaluation-in-an-environment-4.j new file mode 100644 index 0000000000..83e767afe3 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/J/runtime-evaluation-in-an-environment-4.j @@ -0,0 +1,2 @@ + '^y' EvalDiffWithY 0 1 +1.71828 diff --git a/Task/Runtime-evaluation-In-an-environment/J/runtime-evaluation-in-an-environment-5.j b/Task/Runtime-evaluation-In-an-environment/J/runtime-evaluation-in-an-environment-5.j new file mode 100644 index 0000000000..74e5e39123 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/J/runtime-evaluation-in-an-environment-5.j @@ -0,0 +1,4 @@ +EvalDiffWithName=: adverb define +: + -~/m adverb def ('(m)=.y';x)"_1 y +) diff --git a/Task/Runtime-evaluation-In-an-environment/J/runtime-evaluation-in-an-environment-6.j b/Task/Runtime-evaluation-In-an-environment/J/runtime-evaluation-in-an-environment-6.j new file mode 100644 index 0000000000..29480f922e --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/J/runtime-evaluation-in-an-environment-6.j @@ -0,0 +1,4 @@ + '^George' 'George' EvalDiffWithName 0 1 +1.71828 + 'Z + 2^Z' 'Z' EvalDiffWithName 2 3 +5 diff --git a/Task/Runtime-evaluation-In-an-environment/Java/runtime-evaluation-in-an-environment.java b/Task/Runtime-evaluation-In-an-environment/Java/runtime-evaluation-in-an-environment.java new file mode 100644 index 0000000000..2ca7716183 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/Java/runtime-evaluation-in-an-environment.java @@ -0,0 +1,2 @@ +ScriptEngine js = new ScriptEngineManager().getEngineByName("js"); +System.out.println(js.eval("function D(x){return x*2;} var x=3; x=D(x);")); diff --git a/Task/Runtime-evaluation-In-an-environment/JavaScript/runtime-evaluation-in-an-environment-1.js b/Task/Runtime-evaluation-In-an-environment/JavaScript/runtime-evaluation-in-an-environment-1.js new file mode 100644 index 0000000000..818025ac03 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/JavaScript/runtime-evaluation-in-an-environment-1.js @@ -0,0 +1,7 @@ +function evalWithX(expr, a, b) { + var x = a; + var atA = eval(expr); + x = b; + var atB = eval(expr); + return atB - atA; +} diff --git a/Task/Runtime-evaluation-In-an-environment/JavaScript/runtime-evaluation-in-an-environment-2.js b/Task/Runtime-evaluation-In-an-environment/JavaScript/runtime-evaluation-in-an-environment-2.js new file mode 100644 index 0000000000..c0bfa67b48 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/JavaScript/runtime-evaluation-in-an-environment-2.js @@ -0,0 +1 @@ +evalWithX('Math.exp(x)', 0, 1) // returns 1.718281828459045 diff --git a/Task/Runtime-evaluation-In-an-environment/Liberty-BASIC/runtime-evaluation-in-an-environment.liberty b/Task/Runtime-evaluation-In-an-environment/Liberty-BASIC/runtime-evaluation-in-an-environment.liberty new file mode 100644 index 0000000000..8ec451697a --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/Liberty-BASIC/runtime-evaluation-in-an-environment.liberty @@ -0,0 +1,7 @@ + expression$ = "x^2 - 7" +Print (EvaluateWithX(expression$, 5) - EvaluateWithX(expression$, 3)) +End + +Function EvaluateWithX(expression$, x) + EvaluateWithX = Eval(expression$) +End Function diff --git a/Task/Runtime-evaluation-In-an-environment/Lua/runtime-evaluation-in-an-environment.lua b/Task/Runtime-evaluation-In-an-environment/Lua/runtime-evaluation-in-an-environment.lua new file mode 100644 index 0000000000..ce97d2dd49 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/Lua/runtime-evaluation-in-an-environment.lua @@ -0,0 +1,4 @@ +code = loadstring"return x^2" --this doesn't really need to be input, does it? +val1 = setfenv(code, {x = io.read() + 0})() +val2 = setfenv(code, {x = io.read() + 0})() +print(val2 - val1) diff --git a/Task/Runtime-evaluation-In-an-environment/Mathematica/runtime-evaluation-in-an-environment.math b/Task/Runtime-evaluation-In-an-environment/Mathematica/runtime-evaluation-in-an-environment.math new file mode 100644 index 0000000000..89ab6e74f6 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/Mathematica/runtime-evaluation-in-an-environment.math @@ -0,0 +1,3 @@ +Input source code is "10 x" , X is locally bound to 3 & 2 and the resulting expressions evaluated. +(10 x /. x -> 3 ) - (10 x /. x -> 2 ) +-> 10 diff --git a/Task/Runtime-evaluation-In-an-environment/Metafont/runtime-evaluation-in-an-environment.metafont b/Task/Runtime-evaluation-In-an-environment/Metafont/runtime-evaluation-in-an-environment.metafont new file mode 100644 index 0000000000..aeb8635243 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/Metafont/runtime-evaluation-in-an-environment.metafont @@ -0,0 +1,7 @@ +vardef evalit(expr s, va, vb) = +save x,a,b; x := va; a := scantokens s; +x := vb; b := scantokens s; a-b +enddef; + +show(evalit("2x+1", 5, 3)); +end diff --git a/Task/Runtime-evaluation-In-an-environment/Octave/runtime-evaluation-in-an-environment.octave b/Task/Runtime-evaluation-In-an-environment/Octave/runtime-evaluation-in-an-environment.octave new file mode 100644 index 0000000000..61a735529e --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/Octave/runtime-evaluation-in-an-environment.octave @@ -0,0 +1,10 @@ +function r = calcit(f, val1, val2) + x = val1; + a = eval(f); + x = val2; + b = eval(f); + r = b-a; +endfunction + +p = "x .* 2"; +disp(calcit(p, [1:3], [4:6])); diff --git a/Task/Runtime-evaluation-In-an-environment/Oz/runtime-evaluation-in-an-environment.oz b/Task/Runtime-evaluation-In-an-environment/Oz/runtime-evaluation-in-an-environment.oz new file mode 100644 index 0000000000..a42e467cc8 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/Oz/runtime-evaluation-in-an-environment.oz @@ -0,0 +1,8 @@ +declare + fun {EvalWithX Program A B} + {Compiler.evalExpression Program env('X':B) _} + - + {Compiler.evalExpression Program env('X':A) _} + end +in + {Show {EvalWithX "{Exp X}" 0.0 1.0}} diff --git a/Task/Runtime-evaluation-In-an-environment/PARI-GP/runtime-evaluation-in-an-environment.pari b/Task/Runtime-evaluation-In-an-environment/PARI-GP/runtime-evaluation-in-an-environment.pari new file mode 100644 index 0000000000..e0984e1e9d --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/PARI-GP/runtime-evaluation-in-an-environment.pari @@ -0,0 +1,2 @@ +test(f,a,b)=f=eval(f);f(a)-f(b); +test("x->print(x);x^2-sin(x)",1,3) diff --git a/Task/Runtime-evaluation-In-an-environment/PHP/runtime-evaluation-in-an-environment.php b/Task/Runtime-evaluation-In-an-environment/PHP/runtime-evaluation-in-an-environment.php new file mode 100644 index 0000000000..18211922c1 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/PHP/runtime-evaluation-in-an-environment.php @@ -0,0 +1,11 @@ + diff --git a/Task/Runtime-evaluation-In-an-environment/Perl-6/runtime-evaluation-in-an-environment.pl6 b/Task/Runtime-evaluation-In-an-environment/Perl-6/runtime-evaluation-in-an-environment.pl6 new file mode 100644 index 0000000000..9f44e67c9b --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/Perl-6/runtime-evaluation-in-an-environment.pl6 @@ -0,0 +1,9 @@ +sub eval_with_x { + my $code = @_.shift; + my $x = @_.shift; + my $first = eval $code; + $x = @_.shift; + return eval($code) - $first; +} + +print eval_with_x('3 * $x', 5, 10), "\n"; # Prints "15". diff --git a/Task/Runtime-evaluation-In-an-environment/Perl/runtime-evaluation-in-an-environment.pl b/Task/Runtime-evaluation-In-an-environment/Perl/runtime-evaluation-in-an-environment.pl new file mode 100644 index 0000000000..399f01505c --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/Perl/runtime-evaluation-in-an-environment.pl @@ -0,0 +1,8 @@ +sub eval_with_x + {my $code = shift; + my $x = shift; + my $first = eval $code; + $x = shift; + return eval($code) - $first;} + +print eval_with_x('3 * $x', 5, 10), "\n"; # Prints "15". diff --git a/Task/Runtime-evaluation-In-an-environment/PicoLisp/runtime-evaluation-in-an-environment.l b/Task/Runtime-evaluation-In-an-environment/PicoLisp/runtime-evaluation-in-an-environment.l new file mode 100644 index 0000000000..7aac99dc40 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/PicoLisp/runtime-evaluation-in-an-environment.l @@ -0,0 +1,12 @@ +(let Expression '(+ X (* X X)) # Local expression + (println + (+ + (let X 3 + (eval Expression) ) + (let X 4 + (eval Expression) ) ) ) + (let Function (list '(X) Expression) # Build a local function + (println + (+ + (Function 3) + (Function 4) ) ) ) ) diff --git a/Task/Runtime-evaluation-In-an-environment/Pike/runtime-evaluation-in-an-environment-1.pike b/Task/Runtime-evaluation-In-an-environment/Pike/runtime-evaluation-in-an-environment-1.pike new file mode 100644 index 0000000000..b753f284c5 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/Pike/runtime-evaluation-in-an-environment-1.pike @@ -0,0 +1,11 @@ +> int x=10; +Result: 10 +> x * 5; +Result: 50 +> dump wrapper +Last compiled wrapper: +001: mapping(string:mixed) ___hilfe = ___Hilfe->variables; +002: # 1 +003: mixed ___HilfeWrapper() { return (([mapping(string:int)](mixed)___hilfe)->x) * 5; ; } +004: +> diff --git a/Task/Runtime-evaluation-In-an-environment/Pike/runtime-evaluation-in-an-environment-2.pike b/Task/Runtime-evaluation-In-an-environment/Pike/runtime-evaluation-in-an-environment-2.pike new file mode 100644 index 0000000000..b941335497 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/Pike/runtime-evaluation-in-an-environment-2.pike @@ -0,0 +1,8 @@ +string payload = "x * 5"; + +program demo = compile_string("string eval(mixed x){ " + payload + "; }"); + +demo()->eval(10); +Result: 50 +demo()->eval(20); +Result: 100 diff --git a/Task/Runtime-evaluation-In-an-environment/Python/runtime-evaluation-in-an-environment-1.py b/Task/Runtime-evaluation-In-an-environment/Python/runtime-evaluation-in-an-environment-1.py new file mode 100644 index 0000000000..6f90bf9e7d --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/Python/runtime-evaluation-in-an-environment-1.py @@ -0,0 +1,5 @@ +>>> def eval_with_x(code, a, b): + return eval(code, {'x':b}) - eval(code, {'x':a}) + +>>> eval_with_x('2 ** x', 3, 5) +24 diff --git a/Task/Runtime-evaluation-In-an-environment/Python/runtime-evaluation-in-an-environment-2.py b/Task/Runtime-evaluation-In-an-environment/Python/runtime-evaluation-in-an-environment-2.py new file mode 100644 index 0000000000..281d7407a5 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/Python/runtime-evaluation-in-an-environment-2.py @@ -0,0 +1,9 @@ +>>> def eval_with_args(code, **kwordargs): + return eval(code, kwordargs) + +>>> code = '2 ** x' +>>> eval_with_args(code, x=5) - eval_with_args(code, x=3) +24 +>>> code = '3 * x + y' +>>> eval_with_args(code, x=5, y=2) - eval_with_args(code, x=3, y=1) +7 diff --git a/Task/Runtime-evaluation-In-an-environment/R/runtime-evaluation-in-an-environment.r b/Task/Runtime-evaluation-In-an-environment/R/runtime-evaluation-in-an-environment.r new file mode 100644 index 0000000000..47a3514ae4 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/R/runtime-evaluation-in-an-environment.r @@ -0,0 +1,15 @@ +evalWithAB <- function(expr, var, a, b) { + env <- new.env() # provide a separate env, so that the choosen + assign(var, a, envir=env) # var name do not collide with symbols inside + # this function (e.g. it could be even "env") + atA <- eval(parse(text=expr), env) + # and then evaluate the expression inside this + # ad hoc env-ironment + assign(var, b, envir=env) + atB <- eval(parse(text=expr), env) + return(atB - atA) +} + +print(evalWithAB("2*x+1", "x", 5, 3)) +print(evalWithAB("2*y+1", "y", 5, 3)) +print(evalWithAB("2*y+1", "x", 5, 3)) # error: object "y" not found diff --git a/Task/Runtime-evaluation-In-an-environment/REBOL/runtime-evaluation-in-an-environment.rebol b/Task/Runtime-evaluation-In-an-environment/REBOL/runtime-evaluation-in-an-environment.rebol new file mode 100644 index 0000000000..4003f453d5 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/REBOL/runtime-evaluation-in-an-environment.rebol @@ -0,0 +1,5 @@ +prog: [x * 2] +fn: func [x] [do bind prog 'x] +a: fn 2 +b: fn 4 +subtract b a diff --git a/Task/Runtime-evaluation-In-an-environment/REXX/runtime-evaluation-in-an-environment.rexx b/Task/Runtime-evaluation-In-an-environment/REXX/runtime-evaluation-in-an-environment.rexx new file mode 100644 index 0000000000..cfe3a20c0d --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/REXX/runtime-evaluation-in-an-environment.rexx @@ -0,0 +1,9 @@ +/*REXX program to demonstrate some run-time evaulations. */ + +a=fact(3) +b=fact(4) +say b-a +exit /*stick a fork in it, we're done.*/ + +/*───────────────────────────────────FACT subroutine────────────────────*/ +fact: procedure; parse arg n; !=1; do j=2 to n; !=!*j; end; return ! diff --git a/Task/Runtime-evaluation-In-an-environment/Ruby/runtime-evaluation-in-an-environment.rb b/Task/Runtime-evaluation-In-an-environment/Ruby/runtime-evaluation-in-an-environment.rb new file mode 100644 index 0000000000..5c1e130b38 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/Ruby/runtime-evaluation-in-an-environment.rb @@ -0,0 +1,9 @@ +def bind_x_to_value(x) + binding +end + +def eval_with_x(code, a, b) + eval(code, bind_x_to_value(b)) - eval(code, bind_x_to_value(a)) +end + +puts eval_with_x('2 ** x', 3, 5) # Prints "24" diff --git a/Task/Runtime-evaluation-In-an-environment/SNOBOL4/runtime-evaluation-in-an-environment-1.sno b/Task/Runtime-evaluation-In-an-environment/SNOBOL4/runtime-evaluation-in-an-environment-1.sno new file mode 100644 index 0000000000..80be1fdf44 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/SNOBOL4/runtime-evaluation-in-an-environment-1.sno @@ -0,0 +1,6 @@ + compiled = code(' define("triple(x)") :(a);triple triple = 3 * x :(return)') : +a x = 1 + first = triple(x) + x = 3 + output = triple(x) - first +end diff --git a/Task/Runtime-evaluation-In-an-environment/SNOBOL4/runtime-evaluation-in-an-environment-2.sno b/Task/Runtime-evaluation-In-an-environment/SNOBOL4/runtime-evaluation-in-an-environment-2.sno new file mode 100644 index 0000000000..2f214db7d8 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/SNOBOL4/runtime-evaluation-in-an-environment-2.sno @@ -0,0 +1,6 @@ + compiled = code(' define("triple()") :(a);triple triple = 3 * x :(return)') : +a x = 1 + first = triple(x) + x = 3 + output = triple(x) - first +end diff --git a/Task/Runtime-evaluation-In-an-environment/Scheme/runtime-evaluation-in-an-environment.ss b/Task/Runtime-evaluation-In-an-environment/Scheme/runtime-evaluation-in-an-environment.ss new file mode 100644 index 0000000000..f001cda183 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/Scheme/runtime-evaluation-in-an-environment.ss @@ -0,0 +1,4 @@ +(define (eval-with-x prog a b) + (let ((at-a (eval `(let ((x ',a)) ,prog))) + (at-b (eval `(let ((x ',b)) ,prog)))) + (- at-b at-a))) diff --git a/Task/Runtime-evaluation-In-an-environment/TI-89-BASIC/runtime-evaluation-in-an-environment.ti-89 b/Task/Runtime-evaluation-In-an-environment/TI-89-BASIC/runtime-evaluation-in-an-environment.ti-89 new file mode 100644 index 0000000000..5804f2a64a --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/TI-89-BASIC/runtime-evaluation-in-an-environment.ti-89 @@ -0,0 +1,12 @@ +evalx(prog, a, b) +Func + Local x,eresult1,eresult2 + a→x + expr(prog)→eresult1 + b→x + expr(prog)→eresult2 + Return eresult2-eresult1 +EndFunc + +■ evalx("ℯ^x", 0., 1) + 1.71828 diff --git a/Task/Runtime-evaluation-In-an-environment/Tcl/runtime-evaluation-in-an-environment-1.tcl b/Task/Runtime-evaluation-In-an-environment/Tcl/runtime-evaluation-in-an-environment-1.tcl new file mode 100644 index 0000000000..9ef0e74e2b --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/Tcl/runtime-evaluation-in-an-environment-1.tcl @@ -0,0 +1,9 @@ +proc eval_twice {func a b} { + set x $a + set 1st [expr $func] + set x $b + set 2nd [expr $func] + expr {$2nd - $1st} +} + +puts [eval_twice {2 ** $x} 3 5] ;# ==> 24 diff --git a/Task/Runtime-evaluation-In-an-environment/Tcl/runtime-evaluation-in-an-environment-2.tcl b/Task/Runtime-evaluation-In-an-environment/Tcl/runtime-evaluation-in-an-environment-2.tcl new file mode 100644 index 0000000000..6fc0e3eacf --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/Tcl/runtime-evaluation-in-an-environment-2.tcl @@ -0,0 +1,4 @@ +proc eval_with_x {code val1 val2} { + expr {[set x $val2; eval $code] - [set x $val1; eval $code]} +} +eval_with_x {expr {2**$x}} 3 5 ;# ==> 24 diff --git a/Task/Runtime-evaluation-In-an-environment/UNIX-Shell/runtime-evaluation-in-an-environment.sh b/Task/Runtime-evaluation-In-an-environment/UNIX-Shell/runtime-evaluation-in-an-environment.sh new file mode 100644 index 0000000000..425683e000 --- /dev/null +++ b/Task/Runtime-evaluation-In-an-environment/UNIX-Shell/runtime-evaluation-in-an-environment.sh @@ -0,0 +1,15 @@ +eval_with_x() { + set -- "`x=$2; eval "$1"`" "`x=$3; eval "$1"`" + expr "$2" - "$1" +} + +eval_with_x ' + # compute 2 ** $x + p=1 + while test $x -gt 0; do + p=`expr $p \* 2` + x=`expr $x - 1` + done + echo $p +' 3 5 +# Prints '24' diff --git a/Task/Runtime-evaluation/0DESCRIPTION b/Task/Runtime-evaluation/0DESCRIPTION new file mode 100644 index 0000000000..7f7df6dbe7 --- /dev/null +++ b/Task/Runtime-evaluation/0DESCRIPTION @@ -0,0 +1,5 @@ + Demonstrate your language's ability for programs to execute code written in the language provided at runtime. Show us what kind of program fragments are permitted (e.g. expressions vs. statements), how you get values in and out (e.g. environments, arguments, return values), if applicable what lexical/static environment the program is evaluated in, and what facilities for restricting (e.g. sandboxes, resource limits) or customizing (e.g. debugging facilities) the execution. + +You may not invoke a separate evaluator program, or invoke a compiler and then its output, unless the interface of that program, and the syntax and means of executing it, are considered part of your language/library/platform. + +For a more constrained task giving a specific program fragment to evaluate, see [[Eval in environment]]. diff --git a/Task/Runtime-evaluation/ALGOL-68/runtime-evaluation.alg b/Task/Runtime-evaluation/ALGOL-68/runtime-evaluation.alg new file mode 100644 index 0000000000..0e766870c6 --- /dev/null +++ b/Task/Runtime-evaluation/ALGOL-68/runtime-evaluation.alg @@ -0,0 +1 @@ +print(evaluate("4.0*arctan(1.0)")) diff --git a/Task/Runtime-evaluation/AutoHotkey/runtime-evaluation.ahk b/Task/Runtime-evaluation/AutoHotkey/runtime-evaluation.ahk new file mode 100644 index 0000000000..72f78b4437 --- /dev/null +++ b/Task/Runtime-evaluation/AutoHotkey/runtime-evaluation.ahk @@ -0,0 +1,32 @@ +; requires AutoHotkey_H or AutoHotkey.dll +msgbox % eval("3 + 4") +msgbox % eval("4 + 4") +return + + +eval(expression) +{ +global script +script = +( + expression(){ + return %expression% + } +) +renameFunction("expression", "") ; remove any previous expressions +gosub load ; cannot use addScript inside a function yet +exp := "expression" +return %exp%() +} + +load: +DllCall(A_AhkPath "\addScript","Str",script,"Uchar",0,"Cdecl UInt") +return + +renameFunction(funcName, newname){ +static +x%newname% := newname ; store newname in a static variable so its memory is not freed +strput(newname, &x%newname%, strlen(newname) + 1) +if fnp := FindFunc(funcName) + numput(&x%newname%, fnp+0, 0, "uint") +} diff --git a/Task/Runtime-evaluation/BASIC/runtime-evaluation.basic b/Task/Runtime-evaluation/BASIC/runtime-evaluation.basic new file mode 100644 index 0000000000..cea993732a --- /dev/null +++ b/Task/Runtime-evaluation/BASIC/runtime-evaluation.basic @@ -0,0 +1,2 @@ +10 REM load the next program +20 LOAD "PROG2" diff --git a/Task/Runtime-evaluation/BBC-BASIC/runtime-evaluation-1.bbc b/Task/Runtime-evaluation/BBC-BASIC/runtime-evaluation-1.bbc new file mode 100644 index 0000000000..3755ada3d5 --- /dev/null +++ b/Task/Runtime-evaluation/BBC-BASIC/runtime-evaluation-1.bbc @@ -0,0 +1,2 @@ + expr$ = "PI^2 + 1" + PRINT EVAL(expr$) diff --git a/Task/Runtime-evaluation/BBC-BASIC/runtime-evaluation-2.bbc b/Task/Runtime-evaluation/BBC-BASIC/runtime-evaluation-2.bbc new file mode 100644 index 0000000000..8ca03a7f62 --- /dev/null +++ b/Task/Runtime-evaluation/BBC-BASIC/runtime-evaluation-2.bbc @@ -0,0 +1,16 @@ + exec$ = "PRINT ""Hello world!""" + bbc$ = FNtokenise(exec$) + + tmpfile$ = @tmp$+"temp.bbc" + tmpfile% = OPENOUT(tmpfile$) + BPUT#tmpfile%, bbc$+CHR$0 + CLOSE #tmpfile% + + CALL tmpfile$ + END + + DEF FNtokenise(A$) + LOCAL A% + A% = EVAL("0:"+A$) + A$ = $(!332+2) + = CHR$(LENA$+4) + CHR$0 + CHR$0 + A$ + CHR$13 diff --git a/Task/Runtime-evaluation/Burlesque/runtime-evaluation-1.blq b/Task/Runtime-evaluation/Burlesque/runtime-evaluation-1.blq new file mode 100644 index 0000000000..43d56a155a --- /dev/null +++ b/Task/Runtime-evaluation/Burlesque/runtime-evaluation-1.blq @@ -0,0 +1,2 @@ +blsq ) {5 5 .+}e! +10 diff --git a/Task/Runtime-evaluation/Burlesque/runtime-evaluation-2.blq b/Task/Runtime-evaluation/Burlesque/runtime-evaluation-2.blq new file mode 100644 index 0000000000..f2af55c0bf --- /dev/null +++ b/Task/Runtime-evaluation/Burlesque/runtime-evaluation-2.blq @@ -0,0 +1,4 @@ +blsq ) 1 10r@{5.+}m[ +{6 7 8 9 10 11 12 13 14 15} +blsq ) 1 10r@{5.+}6 0sam[ +{7 8 9 10 11 12 13 14 15 16} diff --git a/Task/Runtime-evaluation/Burlesque/runtime-evaluation-3.blq b/Task/Runtime-evaluation/Burlesque/runtime-evaluation-3.blq new file mode 100644 index 0000000000..f146126a79 --- /dev/null +++ b/Task/Runtime-evaluation/Burlesque/runtime-evaluation-3.blq @@ -0,0 +1,2 @@ +blsq ) 1 10r@"5.+"psm[ +{6 7 8 9 10 11 12 13 14 15} diff --git a/Task/Runtime-evaluation/Burlesque/runtime-evaluation-4.blq b/Task/Runtime-evaluation/Burlesque/runtime-evaluation-4.blq new file mode 100644 index 0000000000..3bb8533f7f --- /dev/null +++ b/Task/Runtime-evaluation/Burlesque/runtime-evaluation-4.blq @@ -0,0 +1,2 @@ +blsq ) "[m}+.5{@r01 1"<-pe +{6 7 8 9 10 11 12 13 14 15} diff --git a/Task/Runtime-evaluation/Burlesque/runtime-evaluation-5.blq b/Task/Runtime-evaluation/Burlesque/runtime-evaluation-5.blq new file mode 100644 index 0000000000..0183c09a9c --- /dev/null +++ b/Task/Runtime-evaluation/Burlesque/runtime-evaluation-5.blq @@ -0,0 +1,2 @@ +blsq ) {3 2}(?*)[+e! +6 diff --git a/Task/Runtime-evaluation/Burlesque/runtime-evaluation-6.blq b/Task/Runtime-evaluation/Burlesque/runtime-evaluation-6.blq new file mode 100644 index 0000000000..6c280a20fb --- /dev/null +++ b/Task/Runtime-evaluation/Burlesque/runtime-evaluation-6.blq @@ -0,0 +1,8 @@ +blsq ) ?+ +ERROR: Burlesque: (.+) Invalid arguments! +blsq ) ?+to +"Error" +blsq ) (?+) +?+ +blsq ) (?+)to +"Ident" diff --git a/Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-1.lisp b/Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-1.lisp new file mode 100644 index 0000000000..2c8c52492d --- /dev/null +++ b/Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-1.lisp @@ -0,0 +1 @@ +(eval '(+ 4 5)) ; returns 9 diff --git a/Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-2.lisp b/Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-2.lisp new file mode 100644 index 0000000000..e2f79be152 --- /dev/null +++ b/Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-2.lisp @@ -0,0 +1,2 @@ +(defun add-four-complicated (a-number) + (eval `(+ 4 ',a-number))) diff --git a/Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-3.lisp b/Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-3.lisp new file mode 100644 index 0000000000..b8568aecd9 --- /dev/null +++ b/Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-3.lisp @@ -0,0 +1,2 @@ +(defun add-four-by-function (a-number) + (funcall (eval '(lambda (n) (+ 4 n)))) a-number) diff --git a/Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-4.lisp b/Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-4.lisp new file mode 100644 index 0000000000..02007733a5 --- /dev/null +++ b/Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-4.lisp @@ -0,0 +1 @@ +(eval (read-from-string "(+ 4 5)")) diff --git a/Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-5.lisp b/Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-5.lisp new file mode 100644 index 0000000000..7c01e42da0 --- /dev/null +++ b/Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-5.lisp @@ -0,0 +1,3 @@ +(let ((x 11) (y 22)) + ;; This is an error! Inside the eval, x and y are unbound! + (format t "~%x + y = ~a" (eval '(+ x y)))) diff --git a/Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-6.lisp b/Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-6.lisp new file mode 100644 index 0000000000..a602ab50b9 --- /dev/null +++ b/Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-6.lisp @@ -0,0 +1,2 @@ +(let ((x 11) (y 22)) + (format t "~%x + y = ~a" (eval `(+ ,x ,y)))) diff --git a/Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-7.lisp b/Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-7.lisp new file mode 100644 index 0000000000..682e707d98 --- /dev/null +++ b/Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-7.lisp @@ -0,0 +1 @@ +(system:run-shell-command ...) diff --git a/Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-8.lisp b/Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-8.lisp new file mode 100644 index 0000000000..a06ac521a6 --- /dev/null +++ b/Task/Runtime-evaluation/Common-Lisp/runtime-evaluation-8.lisp @@ -0,0 +1 @@ +(find-symbol "FOO" "BAR") diff --git a/Task/Runtime-evaluation/E/runtime-evaluation-1.e b/Task/Runtime-evaluation/E/runtime-evaluation-1.e new file mode 100644 index 0000000000..e8316b1aef --- /dev/null +++ b/Task/Runtime-evaluation/E/runtime-evaluation-1.e @@ -0,0 +1,2 @@ +? e`1 + 1`.eval(safeScope) +# value: 2 diff --git a/Task/Runtime-evaluation/E/runtime-evaluation-2.e b/Task/Runtime-evaluation/E/runtime-evaluation-2.e new file mode 100644 index 0000000000..ccacb79033 --- /dev/null +++ b/Task/Runtime-evaluation/E/runtime-evaluation-2.e @@ -0,0 +1,5 @@ +? def [value, env] := e`def x := 1 + 1`.evalToPair(safeScope) +# value: [2, ...] + +? e`x`.eval(env) +# value: 2 diff --git a/Task/Runtime-evaluation/E/runtime-evaluation-3.e b/Task/Runtime-evaluation/E/runtime-evaluation-3.e new file mode 100644 index 0000000000..1ec1d5183a --- /dev/null +++ b/Task/Runtime-evaluation/E/runtime-evaluation-3.e @@ -0,0 +1,5 @@ +? def prog := .run("1 + 1") +# value: e`1.add(1)` + +? prog.eval(safeScope) +# value: 2 diff --git a/Task/Runtime-evaluation/Erlang/runtime-evaluation.erl b/Task/Runtime-evaluation/Erlang/runtime-evaluation.erl new file mode 100644 index 0000000000..abb178cabd --- /dev/null +++ b/Task/Runtime-evaluation/Erlang/runtime-evaluation.erl @@ -0,0 +1,8 @@ +1> {ok, Tokens, _} = erl_scan:string("X + 4 * lists:sum([1,2,3,4])."). +... +2> {ok, [Form]} = erl_parse:parse_exprs(Tokens). +... +3> Bindings = erl_eval:add_binding('X', 17, erl_eval:new_bindings()). +[{'X',17}] +4> {value, Value, _} = erl_eval:expr(Form, Bindings). +{value,57,[{'X',17}]} diff --git a/Task/Runtime-evaluation/Forth/runtime-evaluation-1.fth b/Task/Runtime-evaluation/Forth/runtime-evaluation-1.fth new file mode 100644 index 0000000000..c71cb5a567 --- /dev/null +++ b/Task/Runtime-evaluation/Forth/runtime-evaluation-1.fth @@ -0,0 +1,4 @@ +s" variable foo 1e fatan 4e f*" evaluate + +f. \ 3.14159... +1 foo ! diff --git a/Task/Runtime-evaluation/Forth/runtime-evaluation-2.fth b/Task/Runtime-evaluation/Forth/runtime-evaluation-2.fth new file mode 100644 index 0000000000..574db69065 --- /dev/null +++ b/Task/Runtime-evaluation/Forth/runtime-evaluation-2.fth @@ -0,0 +1,10 @@ +unused . \ show how much dictionary space is available +marker restore + +create foo 30 allot +: my-def 30 0 do cr i . ." test" loop ; + +unused . \ lower than before + +restore +unused . \ same as first unused; restore, foo, and my-def no longer defined diff --git a/Task/Runtime-evaluation/GW-BASIC/runtime-evaluation.gw-basic b/Task/Runtime-evaluation/GW-BASIC/runtime-evaluation.gw-basic new file mode 100644 index 0000000000..7933275295 --- /dev/null +++ b/Task/Runtime-evaluation/GW-BASIC/runtime-evaluation.gw-basic @@ -0,0 +1,10 @@ +10 LINE INPUT "Type an expression: ",A$ +20 OPEN "CHAIN.TMP" FOR OUTPUT AS #1 +30 PRINT #1, "70 LET Y=("+A$+")" +40 CLOSE #1 +50 CHAIN MERGE "CHAIN.TMP",60,ALL +60 FOR X=0 TO 5 +70 REM +80 PRINT X,Y +90 NEXT X +100 GOTO 10 diff --git a/Task/Runtime-evaluation/Go/runtime-evaluation.go b/Task/Runtime-evaluation/Go/runtime-evaluation.go new file mode 100644 index 0000000000..07b471c4d5 --- /dev/null +++ b/Task/Runtime-evaluation/Go/runtime-evaluation.go @@ -0,0 +1,25 @@ +package main +import ( + "fmt" + "bitbucket.org/binet/go-eval/pkg/eval" + "go/token" +) + +func main() { + w := eval.NewWorld(); + fset := token.NewFileSet(); + + code, err := w.Compile(fset, "1 + 2") + if err != nil { + fmt.Println("Compile error"); + return + } + + val, err := code.Run(); + if err != nil { + fmt.Println("Run time error"); + return; + } + fmt.Println("Return value:", val) //prints, well, 3 + +} diff --git a/Task/Runtime-evaluation/Groovy/runtime-evaluation-1.groovy b/Task/Runtime-evaluation/Groovy/runtime-evaluation-1.groovy new file mode 100644 index 0000000000..bd2cf5b706 --- /dev/null +++ b/Task/Runtime-evaluation/Groovy/runtime-evaluation-1.groovy @@ -0,0 +1,7 @@ +def years1 = new GroovyShell().evaluate(''' +(2008..2121).findAll { + Date.parse("yyyy-MM-dd", "${it}-12-25").format("EEE") == "Sun" +} +''') + +println years1 diff --git a/Task/Runtime-evaluation/Groovy/runtime-evaluation-2.groovy b/Task/Runtime-evaluation/Groovy/runtime-evaluation-2.groovy new file mode 100644 index 0000000000..ef5a595e93 --- /dev/null +++ b/Task/Runtime-evaluation/Groovy/runtime-evaluation-2.groovy @@ -0,0 +1,9 @@ +def startYear = 2008 +def endYear = 2121 +def years2 = new GroovyShell().evaluate(""" +(${startYear}..${endYear}).findAll { + Date.parse("yyyy-MM-dd", "\${it}-12-25").format("EEE") == "Sun" +} +""") + +println years2 diff --git a/Task/Runtime-evaluation/Groovy/runtime-evaluation-3.groovy b/Task/Runtime-evaluation/Groovy/runtime-evaluation-3.groovy new file mode 100644 index 0000000000..59f015de56 --- /dev/null +++ b/Task/Runtime-evaluation/Groovy/runtime-evaluation-3.groovy @@ -0,0 +1,8 @@ +def context = new B inding() +context.startYear = 2008 +context.endYear = 2121 +def years3 = new GroovyShell(context).evaluate(''' +(startYear..endYear).findAll { + Date.parse("yyyy-MM-dd", "${it}-12-25").format("EEE") == "Sun" +} +''') diff --git a/Task/Runtime-evaluation/Groovy/runtime-evaluation-4.groovy b/Task/Runtime-evaluation/Groovy/runtime-evaluation-4.groovy new file mode 100644 index 0000000000..13a7e08b80 --- /dev/null +++ b/Task/Runtime-evaluation/Groovy/runtime-evaluation-4.groovy @@ -0,0 +1,7 @@ +def years4 = new GroovyShell( new B inding(startYear: 2008, endYear: 2121) ).evaluate(''' +(startYear..endYear).findAll { + Date.parse("yyyy-MM-dd", "${it}-12-25").format("EEE") == "Sun" +} +''') + +println years4 diff --git a/Task/Runtime-evaluation/Groovy/runtime-evaluation-5.groovy b/Task/Runtime-evaluation/Groovy/runtime-evaluation-5.groovy new file mode 100644 index 0000000000..592422caf7 --- /dev/null +++ b/Task/Runtime-evaluation/Groovy/runtime-evaluation-5.groovy @@ -0,0 +1,8 @@ +def binding = new B inding(startYear: 2008, endYear: 2121) +new GroovyShell( binding ).evaluate(''' +yearList = (startYear..endYear).findAll { + Date.parse("yyyy-MM-dd", "${it}-12-25").format("EEE") == "Sun" +} +''') + +println binding.yearList diff --git a/Task/Runtime-evaluation/Groovy/runtime-evaluation-6.groovy b/Task/Runtime-evaluation/Groovy/runtime-evaluation-6.groovy new file mode 100644 index 0000000000..29aff36f5b --- /dev/null +++ b/Task/Runtime-evaluation/Groovy/runtime-evaluation-6.groovy @@ -0,0 +1,7 @@ +def years5 = Eval.xy(2008, 2121, ''' +(x..y).findAll { + Date.parse("yyyy-MM-dd", "${it}-12-25").format("EEE") == "Sun" +} +''') + +println years5 diff --git a/Task/Runtime-evaluation/HicEst/runtime-evaluation.hicest b/Task/Runtime-evaluation/HicEst/runtime-evaluation.hicest new file mode 100644 index 0000000000..2bd5485dec --- /dev/null +++ b/Task/Runtime-evaluation/HicEst/runtime-evaluation.hicest @@ -0,0 +1,8 @@ +value = XEQ( " temp = 1 + 2 + 3 ") ! value is assigned 6 +! temp is undefined outside XEQ, if it was not defined before. + +XEQ(" WRITE(Messagebox) 'Hello World !' ") + +OPEN(FIle="my_file.txt") +READ(FIle="my_file.txt", Row=6) string +XEQ( string ) ! executes row 6 of my_file.txt diff --git a/Task/Runtime-evaluation/J/runtime-evaluation-1.j b/Task/Runtime-evaluation/J/runtime-evaluation-1.j new file mode 100644 index 0000000000..df58d4fd76 --- /dev/null +++ b/Task/Runtime-evaluation/J/runtime-evaluation-1.j @@ -0,0 +1 @@ +". 'a =: +/ 1 2 3' NB. execute a string to sum 1, 2 and 3 and assign to noun a diff --git a/Task/Runtime-evaluation/J/runtime-evaluation-2.j b/Task/Runtime-evaluation/J/runtime-evaluation-2.j new file mode 100644 index 0000000000..14384d1426 --- /dev/null +++ b/Task/Runtime-evaluation/J/runtime-evaluation-2.j @@ -0,0 +1 @@ +monad :'+/y' 1 2 3 diff --git a/Task/Runtime-evaluation/JavaScript/runtime-evaluation.js b/Task/Runtime-evaluation/JavaScript/runtime-evaluation.js new file mode 100644 index 0000000000..bcebc918f4 --- /dev/null +++ b/Task/Runtime-evaluation/JavaScript/runtime-evaluation.js @@ -0,0 +1,5 @@ +var foo = eval('{value: 42}'); +eval('var bar = "Hello, world!";'); + +typeof foo; // 'object' +typeof bar; // 'string' diff --git a/Task/Runtime-evaluation/Liberty-BASIC/runtime-evaluation-1.liberty b/Task/Runtime-evaluation/Liberty-BASIC/runtime-evaluation-1.liberty new file mode 100644 index 0000000000..9082af382d --- /dev/null +++ b/Task/Runtime-evaluation/Liberty-BASIC/runtime-evaluation-1.liberty @@ -0,0 +1,20 @@ +'Dimension a numerical and string array +Dim myArray(5) +Dim myStringArray$(5) + +'Fill both arrays with the appropriate data +For i = 0 To 5 + myArray(i) = i + myStringArray$(i) = "String - " + str$(i) +Next i + +'Set two variables with the names of each array +numArrayName$ = "myArray" +strArrayName$ = "myStringArray" + +'Retrieve the array data by evaluating a string +'that correlates to the array +For i = 0 To 5 + Print Eval$(numArrayName$ + "(" + str$(i) + ")") + Print Eval$(strArrayName$ + "$(" + str$(i) + ")") +Next i diff --git a/Task/Runtime-evaluation/Liberty-BASIC/runtime-evaluation-2.liberty b/Task/Runtime-evaluation/Liberty-BASIC/runtime-evaluation-2.liberty new file mode 100644 index 0000000000..4d42fc7c51 --- /dev/null +++ b/Task/Runtime-evaluation/Liberty-BASIC/runtime-evaluation-2.liberty @@ -0,0 +1,14 @@ +Struct myStruct, value As long, _ + string As ptr +myStruct.value.struct = 10 +myStruct.string.struct = "Hello World!" + +structName$ = "myStruct" +numElement$ = "value" +strElement$ = "string" + +Print Eval$(structName$ + "." + numElement$ + "." + "struct") + +'Pay close attention that this is EVAL() because we are +'retrieving the PTR to the string which is essentially a ulong +Print Winstring(Eval(structName$ + "." + strElement$ + "." + "struct")) diff --git a/Task/Runtime-evaluation/Lua/runtime-evaluation.lua b/Task/Runtime-evaluation/Lua/runtime-evaluation.lua new file mode 100644 index 0000000000..b2ba76d8b5 --- /dev/null +++ b/Task/Runtime-evaluation/Lua/runtime-evaluation.lua @@ -0,0 +1,5 @@ +f = loadstring(s) -- load a string as a function. Returns a function. + +one = loadstring"return 1" -- one() returns 1 + +two = loadstring"return ..." -- two() returns the arguments passed to it diff --git a/Task/Runtime-evaluation/Maxima/runtime-evaluation.maxima b/Task/Runtime-evaluation/Maxima/runtime-evaluation.maxima new file mode 100644 index 0000000000..54edf24386 --- /dev/null +++ b/Task/Runtime-evaluation/Maxima/runtime-evaluation.maxima @@ -0,0 +1,17 @@ +/* Here is how to create a function and return a value at runtime. In the first example, +the function is made global, i.e. it still exists after the statement is run. In the second example, the function +is declared local. The evaluated string may read or write any variable defined before eval_string is run. */ + +kill(f)$ + +eval_string("block(f(x) := x^2 + 1, f(2))"); +5 + +fundef(f); +/* f(x) := x^2 + 1 */ + +eval_string("block([f], local(f), f(x) := x^3 + 1, f(2))"); +9 + +fundef(f); +/* f(x) := x^2 + 1 */ diff --git a/Task/Runtime-evaluation/OxygenBasic/runtime-evaluation.oxy b/Task/Runtime-evaluation/OxygenBasic/runtime-evaluation.oxy new file mode 100644 index 0000000000..be1058e48c --- /dev/null +++ b/Task/Runtime-evaluation/OxygenBasic/runtime-evaluation.oxy @@ -0,0 +1,50 @@ + function ExecSeries(string s,double b,e,i) as string + '=================================================== + ' + sys a,p + string v,u,tab,cr,er + ' + 'PREPARE OUTPUT BUFFER + ' + p=1 + cr=chr(13) chr(10) + tab=chr(9) + v=nuls 4096 + mid v,p,s+cr+cr + p+=4+len s + ' + double x,y,z 'shared variables + ' + 'COMPILE + ' + a=compile s + er=error + if er then + print "runtime error: " er : exit function + end if + ' + 'EXECUTE + ' + for x=b to e step i + if p+128>=len v then + v+=nuls len(v) 'extend buffer + end if + call a + u=str(x) tab str(y) cr + mid v,p,u : p+=len u + next + ' + freememory a 'release compiled code + ' + return left v,p-1 'results + ' + end function + + '===== + 'TESTS + '===== + + 'Expression, StartVal, EndVal stepVal, Increment + + print ExecSeries "y=x*x*x", 1, 10, 1 + print ExecSeries "y=sqrt x",1, 9 , 1 diff --git a/Task/Runtime-evaluation/Oz/runtime-evaluation.oz b/Task/Runtime-evaluation/Oz/runtime-evaluation.oz new file mode 100644 index 0000000000..8c023a1e52 --- /dev/null +++ b/Task/Runtime-evaluation/Oz/runtime-evaluation.oz @@ -0,0 +1,17 @@ +declare + %% simplest case: just evaluate expressions without bindings + R1 = {Compiler.virtualStringToValue "{Abs ~42}"} + {Show R1} + + %% eval expressions with additional bindings and + %% the possibility to kill the evaluation by calling KillProc + KillProc + R2 = {Compiler.evalExpression "{Abs A}" unit('A':~42) ?KillProc} + {Show R2} + + %% full control: add and remove bindings, eval expressions or + %% statements, set compiler switches etc. + Engine = {New Compiler.engine init} + {Engine enqueue(setSwitch(expression false))} %% statements instead of expr. + {Engine enqueue(mergeEnv(env('A':42 'System':System)))} + {Engine enqueue(feedVirtualString("{System.show A}"))} diff --git a/Task/Runtime-evaluation/PHP/runtime-evaluation.php b/Task/Runtime-evaluation/PHP/runtime-evaluation.php new file mode 100644 index 0000000000..fabb64a287 --- /dev/null +++ b/Task/Runtime-evaluation/PHP/runtime-evaluation.php @@ -0,0 +1,5 @@ + 35 diff --git a/Task/Runtime-evaluation/Perl/runtime-evaluation.pl b/Task/Runtime-evaluation/Perl/runtime-evaluation.pl new file mode 100644 index 0000000000..c8780ec12e --- /dev/null +++ b/Task/Runtime-evaluation/Perl/runtime-evaluation.pl @@ -0,0 +1,2 @@ +my ($a, $b) = (-5, 7); +$ans = eval 'abs($a * $b)'; # => 35 diff --git a/Task/Runtime-evaluation/Pike/runtime-evaluation.pike b/Task/Runtime-evaluation/Pike/runtime-evaluation.pike new file mode 100644 index 0000000000..576b473391 --- /dev/null +++ b/Task/Runtime-evaluation/Pike/runtime-evaluation.pike @@ -0,0 +1,9 @@ +program demo = compile_string(#" + string name=\"demo\"; + string hello() + { + return(\"hello, i am \"+name); + }"); + +demo()->hello(); +Result: "hello, i am demo" diff --git a/Task/Runtime-evaluation/Python/runtime-evaluation-1.py b/Task/Runtime-evaluation/Python/runtime-evaluation-1.py new file mode 100644 index 0000000000..00ea2c7d39 --- /dev/null +++ b/Task/Runtime-evaluation/Python/runtime-evaluation-1.py @@ -0,0 +1,5 @@ +>>> exec ''' +x = sum([1,2,3,4]) +print x +''' +10 diff --git a/Task/Runtime-evaluation/Python/runtime-evaluation-2.py b/Task/Runtime-evaluation/Python/runtime-evaluation-2.py new file mode 100644 index 0000000000..becda42d70 --- /dev/null +++ b/Task/Runtime-evaluation/Python/runtime-evaluation-2.py @@ -0,0 +1,5 @@ +>>> exec(''' +x = sum([1,2,3,4]) +print(x) +''') +10 diff --git a/Task/Runtime-evaluation/R/runtime-evaluation-1.r b/Task/Runtime-evaluation/R/runtime-evaluation-1.r new file mode 100644 index 0000000000..7043a8ca60 --- /dev/null +++ b/Task/Runtime-evaluation/R/runtime-evaluation-1.r @@ -0,0 +1,3 @@ +expr1 <- quote(a+b*c) +expr2 <- parse(text="a+b*c")[[1]] +expr3 <- call("+", quote(`a`), call("*", quote(`b`), quote(`c`))) diff --git a/Task/Runtime-evaluation/R/runtime-evaluation-2.r b/Task/Runtime-evaluation/R/runtime-evaluation-2.r new file mode 100644 index 0000000000..ac5692281a --- /dev/null +++ b/Task/Runtime-evaluation/R/runtime-evaluation-2.r @@ -0,0 +1,3 @@ +> a <- 1; b <- 2; c <- 3 +> eval(expr1) +[1] 7 diff --git a/Task/Runtime-evaluation/R/runtime-evaluation-3.r b/Task/Runtime-evaluation/R/runtime-evaluation-3.r new file mode 100644 index 0000000000..56f290a3a5 --- /dev/null +++ b/Task/Runtime-evaluation/R/runtime-evaluation-3.r @@ -0,0 +1,11 @@ +> env <- as.environment(list(a=1, b=3, c=2)) +> evalq(a, env) +[1] 1 +> eval(expr1, env) #this fails; env has only emptyenv() as a parent so can't find "+" +Error in eval(expr, envir, enclos) : could not find function "+" +> parent.env(env) <- sys.frame() +> eval(expr1, env) # eval in env, enclosed in the current context +[1] 7 +> assign("b", 5, env) # assign() can assign into environments +> eval(expr1, env) +[1] 11 diff --git a/Task/Runtime-evaluation/REXX/runtime-evaluation.rexx b/Task/Runtime-evaluation/REXX/runtime-evaluation.rexx new file mode 100644 index 0000000000..0cd7cca4b7 --- /dev/null +++ b/Task/Runtime-evaluation/REXX/runtime-evaluation.rexx @@ -0,0 +1,22 @@ +/*REXX program to illustrate ability to execute code written at runtime.*/ +numeric digits 10000000 +bee=51 +stuff='bee=min(-2,44); say 13*2 "[from inside the box."; abc=abs(bee)' +interpret stuff +say 'bee=' bee +say 'abc=' abc +say + +say 'enter an expression:' +pull expression +say +say 'expression entered is:' expression + +interpret '?='expression + +say +say 'length of result='length(?) +say ' left 50 bytes of result='left(?,50)'...' +say 'right 50 bytes of result=...'right(?,50) + + /*stick a fork in it, we're done.*/ diff --git a/Task/Runtime-evaluation/Ruby/runtime-evaluation-1.rb b/Task/Runtime-evaluation/Ruby/runtime-evaluation-1.rb new file mode 100644 index 0000000000..cebd7d10a4 --- /dev/null +++ b/Task/Runtime-evaluation/Ruby/runtime-evaluation-1.rb @@ -0,0 +1,2 @@ +a, b = 5, -7 +ans = eval "(a * b).abs" # => 35 diff --git a/Task/Runtime-evaluation/Ruby/runtime-evaluation-2.rb b/Task/Runtime-evaluation/Ruby/runtime-evaluation-2.rb new file mode 100644 index 0000000000..1991e2567c --- /dev/null +++ b/Task/Runtime-evaluation/Ruby/runtime-evaluation-2.rb @@ -0,0 +1,18 @@ +def first(main_var, main_binding) + foo = 42 + second [[main_var, main_binding], ["foo", binding]] +end + +def second(args) + sqr = lambda {|x| x**2} + deref(args << ["sqr", binding]) +end + +def deref(stuff) + stuff.each do |varname, context| + puts "value of #{varname} is #{eval varname, context}" + end +end + +hello = "world" +first "hello", binding diff --git a/Task/Runtime-evaluation/SNOBOL4/runtime-evaluation-1.sno b/Task/Runtime-evaluation/SNOBOL4/runtime-evaluation-1.sno new file mode 100644 index 0000000000..c81fac643f --- /dev/null +++ b/Task/Runtime-evaluation/SNOBOL4/runtime-evaluation-1.sno @@ -0,0 +1,4 @@ + expression = "' page ' (i + 1)" + i = 7 + output = eval(expression) +end diff --git a/Task/Runtime-evaluation/SNOBOL4/runtime-evaluation-2.sno b/Task/Runtime-evaluation/SNOBOL4/runtime-evaluation-2.sno new file mode 100644 index 0000000000..92c9a0f8f7 --- /dev/null +++ b/Task/Runtime-evaluation/SNOBOL4/runtime-evaluation-2.sno @@ -0,0 +1,2 @@ + compiled = code(' output = "Hello, world."') :s +end diff --git a/Task/Runtime-evaluation/Scheme/runtime-evaluation.ss b/Task/Runtime-evaluation/Scheme/runtime-evaluation.ss new file mode 100644 index 0000000000..5688327892 --- /dev/null +++ b/Task/Runtime-evaluation/Scheme/runtime-evaluation.ss @@ -0,0 +1,12 @@ +> (define x 37) +> (eval '(+ x 5)) +42 +> (eval '(+ x 5) (interaction-environment)) +42 +> (eval '(+ x 5) (scheme-report-environment 5)) ;; provides R5RS definitions + +Error: identifier not visible x. +Type (debug) to enter the debugger. +> (display (eval (read))) +(+ 4 5) ;; this is input from the user. +9 diff --git a/Task/Runtime-evaluation/Slate/runtime-evaluation-1.slate b/Task/Runtime-evaluation/Slate/runtime-evaluation-1.slate new file mode 100644 index 0000000000..ff63f63e3f --- /dev/null +++ b/Task/Runtime-evaluation/Slate/runtime-evaluation-1.slate @@ -0,0 +1,2 @@ +`(4 + 5) evaluate. +`(4 + 5) evaluateIn: prototypes. diff --git a/Task/Runtime-evaluation/Slate/runtime-evaluation-2.slate b/Task/Runtime-evaluation/Slate/runtime-evaluation-2.slate new file mode 100644 index 0000000000..d0b37ed7b7 --- /dev/null +++ b/Task/Runtime-evaluation/Slate/runtime-evaluation-2.slate @@ -0,0 +1 @@ +(Syntax Parser newOn: '4 + 5') upToEnd do: [| :each | print: each evaluate] diff --git a/Task/Runtime-evaluation/Slate/runtime-evaluation-3.slate b/Task/Runtime-evaluation/Slate/runtime-evaluation-3.slate new file mode 100644 index 0000000000..6df336e6da --- /dev/null +++ b/Task/Runtime-evaluation/Slate/runtime-evaluation-3.slate @@ -0,0 +1,2 @@ +define: #x -> 4. +`(x `unquote + 5) evaluate. diff --git a/Task/Runtime-evaluation/Slate/runtime-evaluation-4.slate b/Task/Runtime-evaluation/Slate/runtime-evaluation-4.slate new file mode 100644 index 0000000000..c3ab3e0cc2 --- /dev/null +++ b/Task/Runtime-evaluation/Slate/runtime-evaluation-4.slate @@ -0,0 +1,2 @@ +define: #x -> 4. +(Syntax Parser newOn: x printString ; ' + 5') diff --git a/Task/Runtime-evaluation/Slate/runtime-evaluation-5.slate b/Task/Runtime-evaluation/Slate/runtime-evaluation-5.slate new file mode 100644 index 0000000000..931fa87093 --- /dev/null +++ b/Task/Runtime-evaluation/Slate/runtime-evaluation-5.slate @@ -0,0 +1,2 @@ +define: #x -> 4. +[| x | x: 5. `(x `unquote + 5) evaluate] do. diff --git a/Task/Runtime-evaluation/Smalltalk/runtime-evaluation-1.st b/Task/Runtime-evaluation/Smalltalk/runtime-evaluation-1.st new file mode 100644 index 0000000000..b25476f873 --- /dev/null +++ b/Task/Runtime-evaluation/Smalltalk/runtime-evaluation-1.st @@ -0,0 +1 @@ +[ 4 + 5 ] value. diff --git a/Task/Runtime-evaluation/Smalltalk/runtime-evaluation-2.st b/Task/Runtime-evaluation/Smalltalk/runtime-evaluation-2.st new file mode 100644 index 0000000000..247f7fc650 --- /dev/null +++ b/Task/Runtime-evaluation/Smalltalk/runtime-evaluation-2.st @@ -0,0 +1,2 @@ +e := ' 123 degreesToRadians sin '. +Transcript show: (Compiler evaluate: e) . diff --git a/Task/Runtime-evaluation/Smalltalk/runtime-evaluation-3.st b/Task/Runtime-evaluation/Smalltalk/runtime-evaluation-3.st new file mode 100644 index 0000000000..a173b50add --- /dev/null +++ b/Task/Runtime-evaluation/Smalltalk/runtime-evaluation-3.st @@ -0,0 +1,2 @@ +e := '[ :x :y | (x*x + (y*y)) sqrt ]'. +Transcript show: ((Compiler evaluate: e) value: 3 value: 4). diff --git a/Task/Runtime-evaluation/Tcl/runtime-evaluation-1.tcl b/Task/Runtime-evaluation/Tcl/runtime-evaluation-1.tcl new file mode 100644 index 0000000000..25c501a965 --- /dev/null +++ b/Task/Runtime-evaluation/Tcl/runtime-evaluation-1.tcl @@ -0,0 +1,4 @@ +set four 4 +set result1 [eval "expr {$four + 5}"] ;# string input + +set result2 [eval [list expr [list $four + 5]]] ;# list input diff --git a/Task/Runtime-evaluation/Tcl/runtime-evaluation-2.tcl b/Task/Runtime-evaluation/Tcl/runtime-evaluation-2.tcl new file mode 100644 index 0000000000..c0b4d6b65c --- /dev/null +++ b/Task/Runtime-evaluation/Tcl/runtime-evaluation-2.tcl @@ -0,0 +1,21 @@ +# Create an interpreter with a default set of restrictions +interp create -safe restrictedContext + +# Our secret variable +set v "secret" + +# Allow some guarded access to the secret from the restricted context. +interp alias restrictedContext doubleSecret {} example +proc example {} { + global v + lappend v $v + return [llength $v] +} + +# Evaluate a script in the restricted context +puts [restrictedContext eval { + append v " has been leaked" + catch {file delete yourCriticalFile.txt} ;# Will be denied! + return "there are [doubleSecret] words in the secret: the magic number is [expr {4 + 5}]" +}]; # --> there are 2 words in the secret: the magic number is 9 +puts $v; # --> secret secret diff --git a/Task/Runtime-evaluation/Tcl/runtime-evaluation-3.tcl b/Task/Runtime-evaluation/Tcl/runtime-evaluation-3.tcl new file mode 100644 index 0000000000..d3b7a163ba --- /dev/null +++ b/Task/Runtime-evaluation/Tcl/runtime-evaluation-3.tcl @@ -0,0 +1,8 @@ +set i [interp create] +interp limit $i commands -value [expr [$i eval info cmdcount]+20] -granularity 1 +interp eval $i { + set x 0 + while {1} { # Infinite loop! Bwahahahaha! + puts "Counting up... [incr x]" + } +} diff --git a/Task/S-Expressions/0DESCRIPTION b/Task/S-Expressions/0DESCRIPTION new file mode 100644 index 0000000000..2d9f2d65b0 --- /dev/null +++ b/Task/S-Expressions/0DESCRIPTION @@ -0,0 +1,21 @@ +[[wp:S-Expression|S-Expressions]] are one convenient way to parse and store data. + +Write a simple reader and writer for S-Expressions that handles quoted and unquoted strings, integers and floats. + +The reader should read a single but nested S-Expression from a string and store it in a suitable datastructure (list, array, etc). Newlines and other whitespace may be ignored unless contained within a quoted string. “()” inside quoted strings are not interpreted, but treated as part of the string. Handling escaped quotes inside a string is optional; thus “(foo"bar)” maybe treated as a string “foo"bar”, or as an error. + +For this, the reader need not recognise “\” for escaping, but should, in addition, recognize numbers if the language has appropriate datatypes. + +Languages that support it may treat unquoted strings as symbols. + +Note that with the exception of “()"” (“\” if escaping is supported) and whitespace there are no special characters. Anything else is allowed without quotes. + +The reader should be able to read the following input +((data "quoted data" 123 4.5) + (data (!@# (4.5) "(more" "data)"))) +and turn it into a native datastructure. (see the [[#Pike|Pike]], [[#Python|Python]] and [[#Ruby|Ruby]] implementations for examples of native data structures.) + +The writer should be able to take the produced list and turn it into a new S-Expression. +Strings that don't contain whitespace or parentheses () don't need to be quoted in the resulting S-Expression, but as a simplification, any string may be quoted. + +'''Extra Credit:''' Let the writer produce pretty printed output with indenting and line-breaks diff --git a/Task/S-Expressions/1META.yaml b/Task/S-Expressions/1META.yaml new file mode 100644 index 0000000000..32d20151af --- /dev/null +++ b/Task/S-Expressions/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Data Structures diff --git a/Task/S-Expressions/Ada/s-expressions-1.ada b/Task/S-Expressions/Ada/s-expressions-1.ada new file mode 100644 index 0000000000..612c04f220 --- /dev/null +++ b/Task/S-Expressions/Ada/s-expressions-1.ada @@ -0,0 +1,55 @@ +with Ada.Strings.Unbounded; +private with Ada.Containers.Indefinite_Vectors; + +generic + with procedure Print_Line(Indention: Natural; Line: String); +package S_Expr is + + function "-"(S: String) return Ada.Strings.Unbounded.Unbounded_String + renames Ada.Strings.Unbounded.To_Unbounded_String; + + function "+"(U: Ada.Strings.Unbounded.Unbounded_String) return String + renames Ada.Strings.Unbounded.To_String; + + type Empty_Data is tagged null record; + subtype Data is Empty_Data'Class; + procedure Print(This: Empty_Data; Indention: Natural); + -- any object form class Data knows how to print itself + -- objects of class data are either List of Data or Atomic + -- atomic objects hold either an integer or a float or a string + + type List_Of_Data is new Empty_Data with private; + overriding procedure Print(This: List_Of_Data; Indention: Natural); + function First(This: List_Of_Data) return Data; + function Rest(This: List_Of_Data) return List_Of_Data; + function Empty(This: List_Of_Data) return Boolean; + + type Atomic is new Empty_Data with null record; + + type Str_Data is new Atomic with record + Value: Ada.Strings.Unbounded.Unbounded_String; + Quoted: Boolean := False; + end record; + overriding procedure Print(This: Str_Data; Indention: Natural); + + type Int_Data is new Atomic with record + Value: Integer; + end record; + overriding procedure Print(This: Int_Data; Indention: Natural); + + type Flt_Data is new Atomic with record + Value: Float; + end record; + overriding procedure Print(This: Flt_Data; Indention: Natural); + +private + + package Vectors is new Ada.Containers.Indefinite_Vectors + (Index_Type => Positive, + Element_Type => Data); + + type List_Of_Data is new Empty_Data with record + Values: Vectors.Vector; + end record; + +end S_Expr; diff --git a/Task/S-Expressions/Ada/s-expressions-2.ada b/Task/S-Expressions/Ada/s-expressions-2.ada new file mode 100644 index 0000000000..e3ecfaef94 --- /dev/null +++ b/Task/S-Expressions/Ada/s-expressions-2.ada @@ -0,0 +1,55 @@ +with Ada.Integer_Text_IO, Ada.Float_Text_IO; + +package body S_Expr is + + function First(This: List_Of_Data) return Data is + begin + return This.Values.First_Element; + end First; + + function Rest(This: List_Of_Data) return List_Of_Data is + List: List_Of_Data := This; + begin + List.Values.Delete_First; + return List; + end Rest; + + function Empty(This: List_Of_Data) return Boolean is + begin + return This.Values.Is_Empty; + end Empty; + + procedure Print(This: Empty_Data; Indention: Natural) is + begin + Print_Line(Indention, ""); + end Print; + + procedure Print(This: Int_Data; Indention: Natural) is + begin + Print_Line(Indention, Integer'Image(This.Value)); + end Print; + + procedure Print(This: Flt_Data; Indention: Natural) is + begin + Print_Line(Indention, Float'Image(This.Value)); + end Print; + + procedure Print(This: Str_Data; Indention: Natural) is + begin + if This.Quoted then + Print_Line(Indention, """" & (+This.Value) & """"); + else + Print_Line(Indention, +This.Value); + end if; + end Print; + + procedure Print(This: List_Of_Data; Indention: Natural) is + begin + Print_Line(Indention, " ( "); + for I in This.Values.First_Index .. This.Values.Last_Index loop + This.Values.Element(I).Print(Indention + 1); + end loop; + Print_Line(Indention, " ) "); + end Print; + +end S_Expr; diff --git a/Task/S-Expressions/Ada/s-expressions-3.ada b/Task/S-Expressions/Ada/s-expressions-3.ada new file mode 100644 index 0000000000..8bbf93702a --- /dev/null +++ b/Task/S-Expressions/Ada/s-expressions-3.ada @@ -0,0 +1,7 @@ +generic -- child of a generic package must be a generic unit +package S_Expr.Parser is + + function Parse(Input: String) return List_Of_Data; + -- the result of a parse process is always a list of expressions + +end S_Expr.Parser; diff --git a/Task/S-Expressions/Ada/s-expressions-4.ada b/Task/S-Expressions/Ada/s-expressions-4.ada new file mode 100644 index 0000000000..40c6442395 --- /dev/null +++ b/Task/S-Expressions/Ada/s-expressions-4.ada @@ -0,0 +1,110 @@ +with Ada.Integer_Text_IO, Ada.Float_Text_IO; + +package body S_Expr.Parser is + + function Parse(Input: String) return List_Of_Data is + + procedure First_Token(S: String; + Start_Of_Token, End_Of_Token: out Positive) is + begin + Start_Of_Token := S'First; + while Start_Of_Token <= S'Last and then S(Start_Of_Token) = ' ' loop + Start_Of_Token := Start_Of_Token + 1; -- skip spaces + end loop; + if Start_Of_Token > S'Last then + End_Of_Token := Start_Of_Token - 1; + -- S(Start_Of_Token .. End_Of_Token) is the empty string + elsif (S(Start_Of_Token) = '(') or (S(Start_Of_Token) = ')') then + End_OF_Token := Start_Of_Token; -- the bracket is the token + elsif S(Start_Of_Token) = '"' then -- " -- begin quoted string + End_Of_Token := Start_Of_Token + 1; + while S(End_Of_Token) /= '"' loop -- " -- search for closing bracket + End_Of_Token := End_Of_Token + 1; + end loop; -- raises Constraint_Error if closing bracket not found + else -- Token is some kind of string + End_Of_Token := Start_Of_Token; + while End_Of_Token < S'Last and then + ((S(End_Of_Token+1) /= ' ') and (S(End_Of_Token+1) /= '(') and + (S(End_Of_Token+1) /= ')') and (S(End_Of_Token+1) /= '"')) loop -- " + End_Of_Token := End_Of_Token + 1; + end loop; + end if; + end First_Token; + + procedure To_Int(Token: String; I: out Integer; Found: out Boolean) is + Last: Positive; + begin + Ada.Integer_Text_IO.Get(Token, I, Last); + Found := Last = Token'Last; + exception + when others => Found := False; + end To_Int; + + procedure To_Flt(Token: String; F: out Float; Found: out Boolean) is + Last: Positive; + begin + Ada.Float_Text_IO.Get(Token, F, Last); + Found := Last = Token'Last; + exception + when others => Found := False; + end To_Flt; + + function Quoted_String(Token: String) return Boolean is + begin + return + Token'Length >= 2 and then Token(Token'First)='"' -- " + and then Token(Token'Last) ='"'; -- " + end Quoted_String; + + Start, Stop: Positive; + + procedure Recursive_Parse(This: in out List_Of_Data) is + + Found: Boolean; + + Flt: Flt_Data; + Int: Int_Data; + Str: Str_Data; + Lst: List_Of_Data; + + begin + while Input(Start .. Stop) /= "" loop + if Input(Start .. Stop) = ")" then + return; + elsif Input(Start .. Stop) = "(" then + First_Token(Input(Stop+1 .. Input'Last), Start, Stop); + Recursive_Parse(Lst); + This.Values.Append(Lst); + else + To_Int(Input(Start .. Stop), Int.Value, Found); + if Found then + This.Values.Append(Int); + else + To_Flt(Input(Start .. Stop), Flt.Value, Found); + if Found then + This.Values.Append(Flt); + else + if Quoted_String(Input(Start .. Stop)) then + Str.Value := -Input(Start+1 .. Stop-1); + Str.Quoted := True; + else + Str.Value := -Input(Start .. Stop); + Str.Quoted := False; + end if; + This.Values.Append(Str); + end if; + end if; + end if; + First_Token(Input(Stop+1 .. Input'Last), Start, Stop); + end loop; + end Recursive_Parse; + + L: List_Of_Data; + + begin + First_Token(Input, Start, Stop); + Recursive_Parse(L); + return L; + end Parse; + +end S_Expr.Parser; diff --git a/Task/S-Expressions/Ada/s-expressions-5.ada b/Task/S-Expressions/Ada/s-expressions-5.ada new file mode 100644 index 0000000000..63047352bd --- /dev/null +++ b/Task/S-Expressions/Ada/s-expressions-5.ada @@ -0,0 +1,23 @@ +with S_Expr.Parser, Ada.Text_IO; + +procedure Test_S_Expr is + + procedure Put_Line(Indention: Natural; Line: String) is + begin + for I in 1 .. 3*Indention loop + Ada.Text_IO.Put(" "); + end loop; + Ada.Text_IO.Put_Line(Line); + end Put_Line; + + package S_Exp is new S_Expr(Put_Line); + package S_Par is new S_Exp.Parser; + + Input: String := "((data ""quoted data"" 123 4.5)" & + "(data (!@# (4.5) ""(more"" ""data)"")))"; + Expression_List: S_Exp.List_Of_Data := S_Par.Parse(Input); + +begin + Expression_List.First.Print(Indention => 0); + -- Parse will output a list of S-Expressions. We need the first Expression. +end Test_S_Expr; diff --git a/Task/S-Expressions/C/s-expressions-1.c b/Task/S-Expressions/C/s-expressions-1.c new file mode 100644 index 0000000000..08d16d23cb --- /dev/null +++ b/Task/S-Expressions/C/s-expressions-1.c @@ -0,0 +1,226 @@ +#include +#include +#include +#include + +enum { S_NONE, S_LIST, S_STRING, S_SYMBOL }; + +typedef struct { + int type; + size_t len; + void *buf; +} s_expr, *expr; + +void whine(const char *s) +{ + fprintf(stderr, "parse error before ==>%.10s\n", s); +} + +expr parse_string(const char *s, char **e) +{ + expr ex = calloc(sizeof(s_expr), 1); + char buf[256] = {0}; + int i = 0; + + while (*s) { + if (i >= 256) { + fprintf(stderr, "string too long:\n"); + whine(s); + goto fail; + } + switch (*s) { + case '\\': + switch (*++s) { + case '\\': + case '"': buf[i++] = *s++; + continue; + + default: whine(s); + goto fail; + } + case '"': goto success; + default: buf[i++] = *s++; + } + } +fail: + free(ex); + return 0; + +success: + *(const char **)e = s + 1; + ex->type = S_STRING; + ex->buf = strdup(buf); + ex->len = strlen(buf); + return ex; +} + +expr parse_symbol(const char *s, char **e) +{ + expr ex = calloc(sizeof(s_expr), 1); + char buf[256] = {0}; + int i = 0; + + while (*s) { + if (i >= 256) { + fprintf(stderr, "symbol too long:\n"); + whine(s); + goto fail; + } + if (isspace(*s)) goto success; + if (*s == ')' || *s == '(') { + s--; + goto success; + } + + switch (*s) { + case '\\': + switch (*++s) { + case '\\': case '"': case '(': case ')': + buf[i++] = *s++; + continue; + default: whine(s); + goto fail; + } + case '"': whine(s); + goto success; + default: buf[i++] = *s++; + } + } +fail: + free(ex); + return 0; + +success: + *(const char **)e = s + 1; + ex->type = S_SYMBOL; + ex->buf = strdup(buf); + ex->len = strlen(buf); + return ex; +} + +void append(expr list, expr ele) +{ + list->buf = realloc(list->buf, sizeof(expr) * ++list->len); + ((expr*)(list->buf))[list->len - 1] = ele; +} + +expr parse_list(const char *s, char **e) +{ + expr ex = calloc(sizeof(s_expr), 1), chld; + char *next; + + ex->len = 0; + + while (*s) { + if (isspace(*s)) { + s++; + continue; + } + + switch (*s) { + case '"': + chld = parse_string(s+1, &next); + if (!chld) goto fail; + append(ex, chld); + s = next; + continue; + case '(': + chld = parse_list(s+1, &next); + if (!chld) goto fail; + append(ex, chld); + s = next; + continue; + case ')': + goto success; + + default: + chld = parse_symbol(s, &next); + if (!chld) goto fail; + append(ex, chld); + s = next; + continue; + } + } + +fail: + whine(s); + free(ex); + return 0; + +success: + *(const char **)e = s+1; + ex->type = S_LIST; + return ex; +} + +expr parse_term(const char *s, char **e) +{ + while (*s) { + if (isspace(*s)) { + s++; + continue; + } + switch(*s) { + case '(': + return parse_list(s+1, e); + case '"': + return parse_string(s+1, e); + default: + return parse_symbol(s+1, e); + } + } + return 0; +} + +void print_expr(expr e, int depth) +{ +#define sep() for(i = 0; i < depth; i++) printf(" ") + int i; + if (!e) return; + + + switch(e->type) { + case S_LIST: + sep(); + puts("("); + for (i = 0; i < e->len; i++) + print_expr(((expr*)e->buf)[i], depth + 1); + sep(); + puts(")"); + return; + case S_SYMBOL: + case S_STRING: + sep(); + if (e->type == S_STRING) putchar('"'); + for (i = 0; i < e->len; i++) { + switch(((char*)e->buf)[i]) { + case '"': + case '\\': + putchar('\\'); + break; + case ')': case '(': + if (e->type == S_SYMBOL) + putchar('\\'); + } + + putchar(((char*)e->buf)[i]); + } + if (e->type == S_STRING) putchar('"'); + putchar('\n'); + return; + } +} + +int main() +{ + char *next; + const char *in = "((data da\\(\\)ta \"quot\\\\ed data\" 123 4.5)\n" + " (\"data\" (!@# (4.5) \"(mo\\\"re\" \"data)\")))"; + + expr x = parse_term(in, &next); + + printf("input is:\n%s\n", in); + printf("parsed as:\n"); + print_expr(x, 0); + return 0; +} diff --git a/Task/S-Expressions/C/s-expressions-2.c b/Task/S-Expressions/C/s-expressions-2.c new file mode 100644 index 0000000000..d2c97a867f --- /dev/null +++ b/Task/S-Expressions/C/s-expressions-2.c @@ -0,0 +1,24 @@ +input is: +((data da\(\)ta "quot\\ed data" 123 4.5) + ("data" (!@# (4.5) "(mo\"re" "data)"))) +parsed as: +( + ( + data + da\(\)ta + "quot\\ed data" + 123 + 4.5 + ) + ( + "data" + ( + !@# + ( + 4.5 + ) + "(mo\"re" + "data)" + ) + ) +) diff --git a/Task/S-Expressions/CoffeeScript/s-expressions-1.coffeescript b/Task/S-Expressions/CoffeeScript/s-expressions-1.coffeescript new file mode 100644 index 0000000000..985795fc0e --- /dev/null +++ b/Task/S-Expressions/CoffeeScript/s-expressions-1.coffeescript @@ -0,0 +1,130 @@ +# This code works with Lisp-like s-expressions. +# +# We lex tokens then do recursive descent on the tokens +# to build our data structures. + +sexp = (data) -> + # Convert a JS data structure to a string s-expression. A sexier version + # would remove quotes around strings that don't need them. + s = '' + if Array.isArray data + children = (sexp elem for elem in data).join ' ' + '(' + children + ')' + else + return JSON.stringify data + +parse_sexp = (sexp) -> + tokens = lex_sexp sexp + i = 0 + + _parse_list = -> + i += 1 + arr = [] + while i < tokens.length and tokens[i].type != ')' + arr.push _parse() + if i < tokens.length + i += 1 + else + throw Error "missing end paren" + arr + + _guess_type = (word) -> + # This is crude, doesn't handle all forms of floats. + if word.match /^\d+\.\d+$/ + parseFloat(word) + else if word.match /^\d+/ + parseInt(word) + else + word + + _parse_word = -> + token = tokens[i] + i += 1 + if token.type == 'string' + token.word + else + _guess_type token.word + + _parse = -> + return undefined unless i < tokens.length + token = tokens[i] + if token.type == '(' + _parse_list() + else + _parse_word() + + exp = _parse() + throw Error "premature termination" if i < tokens.length + exp + +lex_sexp = (sexp) -> + is_whitespace = (c) -> c in [' ', '\t', '\n'] + i = 0 + tokens = [] + + test = (f) -> + return false unless i < sexp.length + f(sexp[i]) + + eat_char = (c) -> + tokens.push + type: c + i += 1 + + eat_whitespace = -> + i += 1 + while test is_whitespace + i += 1 + + eat_word = -> + token = c + i += 1 + word_char = (c) -> + c != ')' and !is_whitespace c + while test word_char + token += sexp[i] + i += 1 + tokens.push + type: "word" + word: token + + eat_quoted_word = -> + start = i + i += 1 + token = '' + while test ((c) -> c != '"') + if sexp[i] == '\\' + i += 1 + throw Error("escaping error") unless i < sexp.length + token += sexp[i] + i += 1 + if test ((c) -> c == '"') + tokens.push + type: "string" + word: token + i += 1 + else + throw Error("end quote missing #{sexp.substring(start, i)}") + + while i < sexp.length + c = sexp[i] + if c == '(' or c == ')' + eat_char c + else if is_whitespace c + eat_whitespace() + else if c == '"' + eat_quoted_word() + else + eat_word() + tokens + +do -> + input = """ + ((data "quoted data with escaped \\"" 123 4.5 "14") + (data (!@# (4.5) "(more" "data)"))) + """ + console.log "input:\n#{input}\n" + output = parse_sexp(input) + pp = (data) -> JSON.stringify data, null, ' ' + console.log "output:\n#{pp output}\n" + console.log "round trip:\n#{sexp output}\n" diff --git a/Task/S-Expressions/CoffeeScript/s-expressions-2.coffeescript b/Task/S-Expressions/CoffeeScript/s-expressions-2.coffeescript new file mode 100644 index 0000000000..06687067d6 --- /dev/null +++ b/Task/S-Expressions/CoffeeScript/s-expressions-2.coffeescript @@ -0,0 +1,29 @@ +> coffee sexp.coffee +input: +((data "quoted data with escaped \"" 123 4.5 "14") + (data (!@# (4.5) "(more" "data)"))) + +output: +[ + [ + "data", + "quoted data with escaped \"", + 123, + 4.5, + "14" + ], + [ + "data", + [ + "!@#", + [ + 4.5 + ], + "(more", + "data)" + ] + ] +] + +round trip: +(("data" "quoted data with escaped \"" 123 4.5 "14") ("data" ("!@#" (4.5) "(more" "data)"))) diff --git a/Task/S-Expressions/Common-Lisp/s-expressions-1.lisp b/Task/S-Expressions/Common-Lisp/s-expressions-1.lisp new file mode 100644 index 0000000000..f51bf98817 --- /dev/null +++ b/Task/S-Expressions/Common-Lisp/s-expressions-1.lisp @@ -0,0 +1,5 @@ +(defun lsquare-reader (stream char) + (declare (ignore char)) + (read-delimited-list #\] stream t)) +(set-macro-character #\[ #'lsquare-reader) ;;Call the lsquare-reader function when a '[' token is parsed +(set-macro-character #\] (get-macro-character #\) nil)) ;;Do the same thing as ')' when a ']' token is parsed diff --git a/Task/S-Expressions/Common-Lisp/s-expressions-2.lisp b/Task/S-Expressions/Common-Lisp/s-expressions-2.lisp new file mode 100644 index 0000000000..9140bced10 --- /dev/null +++ b/Task/S-Expressions/Common-Lisp/s-expressions-2.lisp @@ -0,0 +1,16 @@ +;;A list of unit tests. Each test is a cons in which the car (left side) contains the +;;test string and the cdr (right side) the expected result of reading the S-Exp. +(setf unit-tests + (list + (cons "[]" NIL) + (cons "[a b c]" '(a b c)) + (cons "[\"abc\" \"def\"]" '("abc" "def")) + (cons "[1 2 [3 4 [5]]]" '(1 2 (3 4 (5)))) + (cons "[\"(\" 1 2 \")\"]" '("(" 1 2 ")")) + (cons "[4/8 3/6 2/4]" '(1/2 1/2 1/2)) + (cons "[reduce #'+ '[1 2 3]]" '(reduce #'+ '(1 2 3))))) + +(defun run-tests () + (dolist (test unit-tests) + (format t "String: ~23s Expected: ~23s Actual: ~s~%" + (car test) (cdr test) (read-from-string (car test))))) diff --git a/Task/S-Expressions/Common-Lisp/s-expressions-3.lisp b/Task/S-Expressions/Common-Lisp/s-expressions-3.lisp new file mode 100644 index 0000000000..fbfe5baa5a --- /dev/null +++ b/Task/S-Expressions/Common-Lisp/s-expressions-3.lisp @@ -0,0 +1,24 @@ +(defun write-sexp (sexp) + "Writes a Lisp s-expression in square bracket notation." + (labels ((parse (sexp) + (cond ((null sexp) "") + ((atom sexp) (format nil "~s " sexp)) + ((listp sexp) + (concatenate + 'string + (if (listp (car sexp)) + (concatenate 'string "[" + (fix-spacing (parse (car sexp))) + "] ") + (parse (car sexp))) + (parse (cdr sexp)))))) + (fix-spacing (str) + (let ((empty-string "")) + (unless (null str) + (if (equal str empty-string) + empty-string + (let ((last-char (1- (length str)))) + (if (eq #\Space (char str last-char)) + (subseq str 0 last-char) + str))))))) + (concatenate 'string "[" (fix-spacing (parse sexp)) "]"))) diff --git a/Task/S-Expressions/Common-Lisp/s-expressions-4.lisp b/Task/S-Expressions/Common-Lisp/s-expressions-4.lisp new file mode 100644 index 0000000000..196fdc9d14 --- /dev/null +++ b/Task/S-Expressions/Common-Lisp/s-expressions-4.lisp @@ -0,0 +1,7 @@ +(setf unit-tests '(((1 2) (3 4)) (1 2 3 4) ("ab(cd" "mn)op") + (1 (2 (3 (4)))) ((1) (2) (3)) ())) + +(defun run-tests () + (dolist (test unit-tests) + (format t "Before: ~18s After: ~s~%" + test (write-sexp test)))) diff --git a/Task/S-Expressions/D/s-expressions.d b/Task/S-Expressions/D/s-expressions.d new file mode 100644 index 0000000000..693b97b903 --- /dev/null +++ b/Task/S-Expressions/D/s-expressions.d @@ -0,0 +1,90 @@ +import std.stdio: write, writeln; +import std.conv: text, parse; +import std.algorithm: canFind; +import std.variant: Variant; +import std.uni: isAlpha, isNumber, isWhite; + +alias Sexp = Variant; + +struct Symbol { + private string name; + string toString() { return name; } +} + +Sexp parseSexp(in string raw) { + static bool isIdentChar(in char c) @safe pure /*nothrow*/ { + return c.isAlpha || "0123456789!@#-".canFind(c); + } + + size_t pos = 0; + while (isWhite(raw[pos])) pos++; + Sexp _parse() { + size_t i = pos + 1; + scope (exit) + pos = i; + if (raw[pos] == '"') { + while (raw[i] != '"' && i < raw.length) + i++; + i++; + return Sexp(raw[pos+1..i-1]); + } else if (isNumber(raw[pos])) { + while (isNumber(raw[i]) && i < raw.length) + i++; + if (raw[i] == '.') { + i++; + while (isNumber(raw[i]) && i < raw.length) + i++; + return Sexp(parse!double(raw[pos .. i])); + } + return Sexp(parse!ulong(raw[pos .. i])); + } else if (isIdentChar(raw[pos])) { + while (isIdentChar(raw[i]) && i < raw.length) + i++; + return Sexp(Symbol(raw[pos .. i])); + } else if (raw[pos] == '(') { + Sexp[] lst; + while (raw[i] != ')') { + while (isWhite(raw[i])) + i++; + pos = i; + lst ~= _parse(); + i = pos; + while (isWhite(raw[i])) + i++; + } + i = pos + 1; + return Sexp(lst); + } + return Sexp(null); + } + return _parse(); +} + +void writeSexp(Sexp expr) { + if (expr.type == typeid(string)) { + write("\""); + write(expr); + write("\""); + } else if (expr.type == typeid(Sexp[])) { + write("("); + auto arr = expr.get!(Sexp[]); + foreach (immutable i, e; arr) { + writeSexp(e); + if (i + 1 < arr.length) + write(" "); + } + write(")"); + } else { + write(expr); + } +} + +void main() { + auto test = `((data "quoted data" 123 4.5) + (data (!@# (4.5) "(more" "data)")))`; + auto pTest = parseSexp(test); + writeln("Parsed: ", pTest); + write("Printed: "); + writeSexp(pTest); + writeln(); +} diff --git a/Task/S-Expressions/Go/s-expressions.go b/Task/S-Expressions/Go/s-expressions.go new file mode 100644 index 0000000000..1e76f2e3fa --- /dev/null +++ b/Task/S-Expressions/Go/s-expressions.go @@ -0,0 +1,174 @@ +package main + +import ( + "errors" + "fmt" + "reflect" + "strconv" + "strings" + "unicode" +) + +var input = `((data "quoted data" 123 4.5) + (data (!@# (4.5) "(more" "data)")))` + +func main() { + fmt.Println("input:") + fmt.Println(input) + + s, err := parseSexp(input) + if err != nil { + fmt.Println("error:", err) + return + } + + fmt.Println("\nparsed:") + fmt.Println(s) + + fmt.Println("\nrepresentation:") + s.dump(0) +} + +// dynamic types for i are string, qString, int, float64, list, and error. +type sexp struct { + i interface{} +} +type qString string +type list []sexp + +func (s sexp) String() string { + return fmt.Sprintf("%v", s.i) +} + +func (q qString) String() string { + return strconv.Quote(string(q)) +} + +func (l list) String() string { + if len(l) == 0 { + return "()" + } + b := fmt.Sprintf("(%v", l[0]) + for _, s := range l[1:] { + b = fmt.Sprintf("%s %v", b, s) + } + return b + ")" +} + +// parseSexp parses a string into a Go representation of an s-expression. +// +// Quoted strings go from one " to the next. There is no escape character, +// all characters except " are valid. +// +// Otherwise atoms are any string of characters between any of '(', ')', +// '"', or white space characters. If the atom parses as a Go int type +// using strconv.Atoi, it is taken as int; if it parses as a Go float64 +// type using strconv.ParseFloat, it is taken as float64; otherwise it is +// taken as an unquoted string. +// +// Unmatched (, ), or " are errors. +// An empty or all whitespace input string is an error. +// Left over text after the sexp is an error. +// +// An empty list is a valid sexp, but there is no nil, no cons, no dot. +func parseSexp(s string) (sexp, error) { + s1, rem := ps2(s, -1) + if err, isErr := s1.i.(error); isErr { + return sexp{}, err + } + if rem > "" { + return s1, errors.New("Left over text: " + rem) + } + return s1, nil +} + +// recursive. n = -1 means not parsing a list. n >= 0 means the number +// of list elements parsed so far. string result is unparsed remainder +// of the input string s0. +func ps2(s0 string, n int) (x sexp, rem string) { + tok, s1 := gettok(s0) + switch t := tok.(type) { + case error: + return sexp{tok}, s1 + case nil: // this is also an error + if n < 0 { + return sexp{errors.New("blank input string")}, s0 + } else { + return sexp{errors.New("unmatched (")}, "" + } + case byte: + switch { + case t == '(': + x, s1 = ps2(s1, 0) // x is a list + if _, isErr := x.i.(error); isErr { + return x, s0 + } + case n < 0: + return sexp{errors.New("unmatched )")}, "" + default: + // found end of list. allocate space for it. + return sexp{make(list, n)}, s1 + } + default: + x = sexp{tok} // x is an atom + } + if n < 0 { + // not in a list, just return the s-expression x + return x, s1 + } + // in a list. hold on to x while we parse the rest of the list. + l, s1 := ps2(s1, n+1) + // result l is either an error or the allocated list, not completely + // filled in yet. + if _, isErr := l.i.(error); !isErr { + // as long as no errors, drop x into its place in the list + l.i.(list)[n] = x + } + return l, s1 +} + +// gettok gets one token from string s. +// return values are the token and the remainder of the string. +// dynamic type of tok indicates result: +// nil: no token. string was empty or all white space. +// byte: one of '(' or ')' +// otherwise string, qString, int, float64, or error. +func gettok(s string) (tok interface{}, rem string) { + s = strings.TrimSpace(s) + if s == "" { + return nil, "" + } + switch s[0] { + case '(', ')': + return s[0], s[1:] + case '"': + if i := strings.Index(s[1:], `"`); i >= 0 { + return qString(s[1 : i+1]), s[i+2:] + } + return errors.New(`unmatched "`), s + } + i := 1 + for i < len(s) && s[i] != '(' && s[i] != ')' && s[i] != '"' && + !unicode.IsSpace(rune(s[i])) { + i++ + } + if j, err := strconv.Atoi(s[:i]); err == nil { + return j, s[i:] + } + if f, err := strconv.ParseFloat(s[:i], 64); err == nil { + return f, s[i:] + } + return s[:i], s[i:] +} + +func (s sexp) dump(i int) { + fmt.Printf("%*s%v: ", i*3, "", reflect.TypeOf(s.i)) + if l, isList := s.i.(list); isList { + fmt.Println(len(l), "elements") + for _, e := range l { + e.dump(i + 1) + } + } else { + fmt.Println(s.i) + } +} diff --git a/Task/S-Expressions/Haskell/s-expressions.hs b/Task/S-Expressions/Haskell/s-expressions.hs new file mode 100644 index 0000000000..5917db847f --- /dev/null +++ b/Task/S-Expressions/Haskell/s-expressions.hs @@ -0,0 +1,49 @@ +import Text.ParserCombinators.Parsec ((<|>), (), many, many1, char, try, parse, sepBy, choice) +import Text.ParserCombinators.Parsec.Char (noneOf) +import Text.ParserCombinators.Parsec.Token (integer, float, whiteSpace, stringLiteral, makeTokenParser) +import Text.ParserCombinators.Parsec.Language (haskellDef) + + +data Val = Int Integer + | Float Double + | String String + | Symbol String + | List [Val] deriving (Eq, Show) + +lexer = makeTokenParser haskellDef + +tInteger = (integer lexer) >>= (return . Int) "integer" + +tFloat = (float lexer) >>= (return . Float) "floating point number" + +tString = (stringLiteral lexer) >>= (return . String) "string" + +tSymbol = (many1 $ noneOf "()\" \t\n\r") >>= (return . Symbol) "symbol" + +tAtom = choice [try tFloat, try tInteger, tSymbol, tString] "atomic expression" + +tExpr = do + whiteSpace lexer + expr <- tList <|> tAtom + whiteSpace lexer + return expr + "expression" + +tList = do + char '(' + list <- many tExpr + char ')' + return $ List list + "list" + +tProg = many tExpr "program" + +p ex = case parse tProg "" ex of + Right x -> putStrLn $ unwords $ map show x + Left err -> print err + +main = do + let expr = "((data \"quoted data\" 123 4.5)\n (data (!@# (4.5) \"(more\" \"data)\")))" + putStrLn $ "The input:\n" ++ expr ++ "\n" + putStr "Parsed as:\n" + p expr diff --git a/Task/S-Expressions/Icon/s-expressions.icon b/Task/S-Expressions/Icon/s-expressions.icon new file mode 100644 index 0000000000..50561c87b8 --- /dev/null +++ b/Task/S-Expressions/Icon/s-expressions.icon @@ -0,0 +1,60 @@ +link ximage + +procedure main() + in := "((data 'quoted data' 123 4.5) (data (!@# (4.5) '(more' 'data)')))" + # in := map(in,"'","\"") # uncomment to put back double quotes if desired + write("Input: ",image(in)) + write("Structure: \n",ximage(S := string2sexp(in))) + write("Output: ",image(sexp2string(S))) +end + +procedure sexp2string(S) #: return a string representing the s-expr + s := "" + every t := !S do { + if type(t) == "list" then + s ||:= "(" || trim(sexp2string(t)) || ")" + else + if upto('() \t\r\n',t) then + s ||:= "'" || t || "'" + else + s ||:= t + s ||:= " " + } + return trim(s) +end + +procedure string2sexp(s) #: return a s-expression nested list + if s ? ( sexptokenize(T := []), pos(0) ) then + return sexpnest(T) + else + write("Malformed: ",s) +end + +procedure sexpnest(T,L) #: transform s-expr token list to nested list + /L := [] + while t := get(T) do + case t of { + "(" : { + put(L,[]) + sexpnest(T,L[*L]) + } + ")" : return L + default : put(L, numeric(t) | t) + } + return L +end + +procedure sexptokenize(T) #: return list of tokens parsed from an s-expr string +static sym +initial sym := &letters++&digits++'~`!@#$%^&*_-+|;:.,<>[]{}' + until pos(0) do + case &subject[&pos] of { + " " : tab(many(' \t\r\n')) # consume whitespace + "'"|"\"" : + (q := move(1)) & put(T,tab(find(q))) & move(1) # quotes + "(" : put(T,move(1)) & sexptokenize(T) # open + ")" : put(T,move(1)) &return T # close + default : put(T, tab(many(sym))) # other symbols + } + return T +end diff --git a/Task/S-Expressions/J/s-expressions-1.j b/Task/S-Expressions/J/s-expressions-1.j new file mode 100644 index 0000000000..a502424dac --- /dev/null +++ b/Task/S-Expressions/J/s-expressions-1.j @@ -0,0 +1,52 @@ +NB. character classes: 0: paren, 1: quote, 2: whitespace, 3: wordforming (default) +chrMap=: '()';'"';' ',LF,TAB,CR + +NB. state columns correspond to the above character classes +NB. first digit chooses next state. +NB. second digit is action 0: do nothing, 1: start word, 2: end word +states=: 10 10#: ".;._2]0 :0 + 11 21 00 31 NB. state 0: initial state + 12 22 02 32 NB. state 1: after () or after closing " + 40 10 40 40 NB. state 2: after opening " + 12 22 02 30 NB. state 3: after word forming character + 40 10 40 40 NB. state 4: between opening " and closing " +) + +tokenize=: (0;states;{.r +) + +wrSexpr=: ('(' , ;:^:_1 , ')'"_)^:L.L:1^:L. :.rdSexpr + +fmt=: 3 :0 :.unfmt + if. '"' e. {.y do. }.,}: y NB. quoted string + elseif. 0=#$n=.".y do. n NB. number or character + elseif. do. s:s:inv y + end. +) + +readSexpr=: fmt L:0 @rdSexpr :.writeSexpr +writeSexpr=: wrSexpr @(unfmt L:0) :.readSexpr diff --git a/Task/S-Expressions/J/s-expressions-2.j b/Task/S-Expressions/J/s-expressions-2.j new file mode 100644 index 0000000000..25b64a764f --- /dev/null +++ b/Task/S-Expressions/J/s-expressions-2.j @@ -0,0 +1,12 @@ + readSexpr '((data "quoted data" 123 4.5) (data (!@# (4.5) "(more" "data)")))' +┌───────────────────────────┬────────────────────────────────┐ +│┌─────┬───────────┬───┬───┐│┌─────┬────────────────────────┐│ +││`data│quoted data│123│4.5│││`data│┌────┬─────┬─────┬─────┐││ +│└─────┴───────────┴───┴───┘││ ││`!@#│┌───┐│(more│data)│││ +│ ││ ││ ││4.5││ │ │││ +│ ││ ││ │└───┘│ │ │││ +│ ││ │└────┴─────┴─────┴─────┘││ +│ │└─────┴────────────────────────┘│ +└───────────────────────────┴────────────────────────────────┘ + writeSexpr readSexpr '((data "quoted data" 123 4.5) (data (!@# (4.5) "(more" "data)")))' +((data "quoted data" 123 4.5) (data (!@# (4.5) "(more" "data)"))) diff --git a/Task/S-Expressions/Java/s-expressions-1.java b/Task/S-Expressions/Java/s-expressions-1.java new file mode 100644 index 0000000000..1502b10df2 --- /dev/null +++ b/Task/S-Expressions/Java/s-expressions-1.java @@ -0,0 +1,111 @@ +package jfkbits; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.Reader; +import java.io.StreamTokenizer; +import java.io.StringReader; +import java.util.Iterator; + +public class LispTokenizer implements Iterator +{ + // Instance variables have default access to allow unit tests access. + StreamTokenizer m_tokenizer; + IOException m_ioexn; + + /** Constructs a tokenizer that scans input from the given string. + * @param src A string containing S-expressions. + */ + public LispTokenizer(String src) + { + this(new StringReader(src)); + } + + /** Constructs a tokenizer that scans input from the given Reader. + * @param r Reader for the character input source + */ + public LispTokenizer(Reader r) + { + if(r == null) + r = new StringReader(""); + BufferedReader buffrdr = new BufferedReader(r); + m_tokenizer = new StreamTokenizer(buffrdr); + m_tokenizer.resetSyntax(); // We don't like the default settings + + m_tokenizer.whitespaceChars(0, ' '); + m_tokenizer.wordChars(' '+1,255); + m_tokenizer.ordinaryChar('('); + m_tokenizer.ordinaryChar(')'); + m_tokenizer.ordinaryChar('\''); + m_tokenizer.commentChar(';'); + m_tokenizer.quoteChar('"'); + } + + public Token peekToken() + { + if(m_ioexn != null) + return null; + try + { + m_tokenizer.nextToken(); + } + catch(IOException e) + { + m_ioexn = e; + return null; + } + if(m_tokenizer.ttype == StreamTokenizer.TT_EOF) + return null; + Token token = new Token(m_tokenizer); + m_tokenizer.pushBack(); + return token; + } + + public boolean hasNext() + { + if(m_ioexn != null) + return false; + try + { + m_tokenizer.nextToken(); + } + catch(IOException e) + { + m_ioexn = e; + return false; + } + if(m_tokenizer.ttype == StreamTokenizer.TT_EOF) + return false; + m_tokenizer.pushBack(); + return true; + } + + /** Return the most recently caught IOException, if any, + * + * @return + */ + public IOException getIOException() + { + return m_ioexn; + } + + public Token next() + { + try + { + m_tokenizer.nextToken(); + } + catch(IOException e) + { + m_ioexn = e; + return null; + } + + Token token = new Token(m_tokenizer); + return token; + } + + public void remove() + { + } +} diff --git a/Task/S-Expressions/Java/s-expressions-2.java b/Task/S-Expressions/Java/s-expressions-2.java new file mode 100644 index 0000000000..13e173c18f --- /dev/null +++ b/Task/S-Expressions/Java/s-expressions-2.java @@ -0,0 +1,29 @@ +package jfkbits; +import java.io.StreamTokenizer; + +public class Token +{ + public static final int SYMBOL = StreamTokenizer.TT_WORD; + public int type; + public String text; + public int line; + + public Token(StreamTokenizer tzr) + { + this.type = tzr.ttype; + this.text = tzr.sval; + this.line = tzr.lineno(); + } + + public String toString() + { + switch(this.type) + { + case SYMBOL: + case '"': + return this.text; + default: + return String.valueOf((char)this.type); + } + } +} diff --git a/Task/S-Expressions/Java/s-expressions-3.java b/Task/S-Expressions/Java/s-expressions-3.java new file mode 100644 index 0000000000..d6b99511dd --- /dev/null +++ b/Task/S-Expressions/Java/s-expressions-3.java @@ -0,0 +1,17 @@ +package jfkbits; + +import jfkbits.LispParser.Expr; + +public class Atom implements Expr +{ + String name; + public String toString() + { + return name; + } + public Atom(String text) + { + name = text; + } + +} diff --git a/Task/S-Expressions/Java/s-expressions-4.java b/Task/S-Expressions/Java/s-expressions-4.java new file mode 100644 index 0000000000..bcf15f17dc --- /dev/null +++ b/Task/S-Expressions/Java/s-expressions-4.java @@ -0,0 +1,20 @@ +package jfkbits; + +public class StringAtom extends Atom +{ + public String toString() + { + // StreamTokenizer hardcodes escaping with \, and doesn't allow \n inside words + String escaped = name.replace("\\", "\\\\").replace("\n", "\\n").replace("\r", "\\r").replace("\"", "\\\""); + return "\""+escaped+"\""; + } + + public StringAtom(String text) + { + super(text); + } + public String getValue() + { + return name; + } +} diff --git a/Task/S-Expressions/Java/s-expressions-5.java b/Task/S-Expressions/Java/s-expressions-5.java new file mode 100644 index 0000000000..d1e7e8518e --- /dev/null +++ b/Task/S-Expressions/Java/s-expressions-5.java @@ -0,0 +1,71 @@ +package jfkbits; + +import java.util.AbstractCollection; +import java.util.Arrays; +import java.util.Iterator; +import java.util.ArrayList; + +import jfkbits.LispParser.Expr; + +public class ExprList extends ArrayList implements Expr +{ + ExprList parent = null; + int indent =1; + + public int getIndent() + { + if (parent != null) + { + return parent.getIndent()+indent; + } + else return 0; + } + + public void setIndent(int indent) + { + this.indent = indent; + } + + + + public void setParent(ExprList parent) + { + this.parent = parent; + } + + public String toString() + { + String indent = ""; + if (parent != null && parent.get(0) != this) + { + indent = "\n"; + char[] chars = new char[getIndent()]; + Arrays.fill(chars, ' '); + indent += new String(chars); + } + + String output = indent+"("; + for(Iterator it=this.iterator(); it.hasNext(); ) + { + Expr expr = it.next(); + output += expr.toString(); + if (it.hasNext()) + output += " "; + } + output += ")"; + return output; + } + + @Override + public synchronized boolean add(Expr e) + { + if (e instanceof ExprList) + { + ((ExprList) e).setParent(this); + if (size() != 0 && get(0) instanceof Atom) + ((ExprList) e).setIndent(2); + } + return super.add(e); + } + +} diff --git a/Task/S-Expressions/Java/s-expressions-6.java b/Task/S-Expressions/Java/s-expressions-6.java new file mode 100644 index 0000000000..dbe55857b4 --- /dev/null +++ b/Task/S-Expressions/Java/s-expressions-6.java @@ -0,0 +1,47 @@ +package jfkbits; + + +public class LispParser +{ + LispTokenizer tokenizer; + + public LispParser(LispTokenizer input) + { + tokenizer=input; + } + + public class ParseException extends Exception + { + + } + + public interface Expr + { + // abstract parent for Atom and ExprList + } + + public Expr parseExpr() throws ParseException + { + Token token = tokenizer.next(); + switch(token.type) + { + case '(': return parseExprList(token); + case '"': return new StringAtom(token.text); + default: return new Atom(token.text); + } + } + + + protected ExprList parseExprList(Token openParen) throws ParseException + { + ExprList acc = new ExprList(); + while(tokenizer.peekToken().type != ')') + { + Expr element = parseExpr(); + acc.add(element); + } + Token closeParen = tokenizer.next(); + return acc; + } + +} diff --git a/Task/S-Expressions/Java/s-expressions-7.java b/Task/S-Expressions/Java/s-expressions-7.java new file mode 100644 index 0000000000..21dc4dca0e --- /dev/null +++ b/Task/S-Expressions/Java/s-expressions-7.java @@ -0,0 +1,26 @@ +import jfkbits.ExprList; +import jfkbits.LispParser; +import jfkbits.LispParser.ParseException; +import jfkbits.LispTokenizer; + +public class LispParserDemo +{ + public static void main(String args[]) + { + + LispTokenizer tzr = new LispTokenizer( + "((data \"quoted data\" 123 4.5)\n (data (!@# (4.5) \"(more\" \"data)\")))"); + LispParser parser = new LispParser(tzr); + + try + { + Expr result = parser.parseExpr(); + System.out.println(result); + } + catch (ParseException e1) + { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } +} diff --git a/Task/S-Expressions/OCaml/s-expressions-1.ocaml b/Task/S-Expressions/OCaml/s-expressions-1.ocaml new file mode 100644 index 0000000000..6bad52aec5 --- /dev/null +++ b/Task/S-Expressions/OCaml/s-expressions-1.ocaml @@ -0,0 +1,29 @@ +(** This module is a very simple parsing library for S-expressions. *) +(* Copyright (C) 2009 Florent Monnier, released under MIT license. *) + +type sexpr = Atom of string | Expr of sexpr list +(** the type of S-expressions *) + +val parse_string : string -> sexpr list +(** parse from a string *) + +val parse_ic : in_channel -> sexpr list +(** parse from an input channel *) + +val parse_file : string -> sexpr list +(** parse from a file *) + +val parse : (unit -> char option) -> sexpr list +(** parse from a custom function, [None] indicates the end of the flux *) + +val print_sexpr : sexpr list -> unit +(** a dump function for the type [sexpr] *) + +val print_sexpr_indent : sexpr list -> unit +(** same than [print_sexpr] but with indentation *) + +val string_of_sexpr : sexpr list -> string +(** convert an expression of type [sexpr] into a string *) + +val string_of_sexpr_indent : sexpr list -> string +(** same than [string_of_sexpr] but with indentation *) diff --git a/Task/S-Expressions/OCaml/s-expressions-2.ocaml b/Task/S-Expressions/OCaml/s-expressions-2.ocaml new file mode 100644 index 0000000000..cb17135706 --- /dev/null +++ b/Task/S-Expressions/OCaml/s-expressions-2.ocaml @@ -0,0 +1,178 @@ +(** This module is a very simple parsing library for S-expressions. *) +(* Copyright (C) 2009 Florent Monnier, released under MIT license. *) +(* modified to match the task description *) + +type sexpr = Atom of string | Expr of sexpr list + +type state = + | Parse_root of sexpr list + | Parse_content of sexpr list + | Parse_word of Buffer.t * sexpr list + | Parse_string of bool * Buffer.t * sexpr list + +let parse pop_char = + let rec aux st = + match pop_char() with + | None -> + begin match st with + | Parse_root sl -> (List.rev sl) + | Parse_content _ + | Parse_word _ + | Parse_string _ -> + failwith "Parsing error: content not closed by parenthesis" + end + | Some c -> + match c with + | '(' -> + begin match st with + | Parse_root sl -> + let this = aux(Parse_content []) in + aux(Parse_root((Expr this)::sl)) + | Parse_content sl -> + let this = aux(Parse_content []) in + aux(Parse_content((Expr this)::sl)) + | Parse_word(w, sl) -> + let this = aux(Parse_content []) in + aux(Parse_content((Expr this)::Atom(Buffer.contents w)::sl)) + | Parse_string(_, s, sl) -> + Buffer.add_char s c; + aux(Parse_string(false, s, sl)) + end + | ')' -> + begin match st with + | Parse_root sl -> + failwith "Parsing error: closing parenthesis without openning" + | Parse_content sl -> (List.rev sl) + | Parse_word(w, sl) -> List.rev(Atom(Buffer.contents w)::sl) + | Parse_string(_, s, sl) -> + Buffer.add_char s c; + aux(Parse_string(false, s, sl)) + end + | ' ' | '\n' | '\r' | '\t' -> + begin match st with + | Parse_root sl -> aux(Parse_root sl) + | Parse_content sl -> aux(Parse_content sl) + | Parse_word(w, sl) -> aux(Parse_content(Atom(Buffer.contents w)::sl)) + | Parse_string(_, s, sl) -> + Buffer.add_char s c; + aux(Parse_string(false, s, sl)) + end + | '"' -> + (* '"' *) + begin match st with + | Parse_root _ -> failwith "Parse error: double quote at root level" + | Parse_content sl -> + let s = Buffer.create 74 in + aux(Parse_string(false, s, sl)) + | Parse_word(w, sl) -> + let s = Buffer.create 74 in + aux(Parse_string(false, s, Atom(Buffer.contents w)::sl)) + | Parse_string(true, s, sl) -> + Buffer.add_char s c; + aux(Parse_string(false, s, sl)) + | Parse_string(false, s, sl) -> + aux(Parse_content(Atom(Buffer.contents s)::sl)) + end + | '\\' -> + begin match st with + | Parse_string(true, s, sl) -> + Buffer.add_char s c; + aux(Parse_string(false, s, sl)) + | Parse_string(false, s, sl) -> + aux(Parse_string(true, s, sl)) + | _ -> + failwith "Parsing error: escape character in wrong place" + end + | _ -> + begin match st with + | Parse_root _ -> + failwith(Printf.sprintf "Parsing error: char '%c' at root level" c) + | Parse_content sl -> + let w = Buffer.create 16 in + Buffer.add_char w c; + aux(Parse_word(w, sl)) + | Parse_word(w, sl) -> + Buffer.add_char w c; + aux(Parse_word(w, sl)) + | Parse_string(_, s, sl) -> + Buffer.add_char s c; + aux(Parse_string(false, s, sl)) + end + in + aux (Parse_root []) + + +let string_pop_char str = + let len = String.length str in + let i = ref(-1) in + (function () -> incr i; if !i >= len then None else Some(str.[!i])) + + +let parse_string str = + parse (string_pop_char str) + + +let ic_pop_char ic = + (function () -> + try Some(input_char ic) + with End_of_file -> (None)) + + +let parse_ic ic = + parse (ic_pop_char ic) + + +let parse_file filename = + let ic = open_in filename in + let res = parse_ic ic in + close_in ic; + (res) + + +let quote s = + "\"" ^ s ^ "\"" + +let needs_quote s = + List.exists (String.contains s) [' '; '\n'; '\r'; '\t'; '('; ')'] + +let protect s = + let s = String.escaped s in + if needs_quote s then quote s else s + + +let string_of_sexpr s = + let rec aux acc = function + | (Atom tag)::tl -> aux ((protect tag)::acc) tl + | (Expr e)::tl -> + let s = + "(" ^ + (String.concat " " (aux [] e)) + ^ ")" + in + aux (s::acc) tl + | [] -> (List.rev acc) + in + String.concat " " (aux [] s) + + +let print_sexpr s = + print_endline (string_of_sexpr s) + + +let string_of_sexpr_indent s = + let rec aux i acc = function + | (Atom tag)::tl -> aux i ((protect tag)::acc) tl + | (Expr e)::tl -> + let s = + "\n" ^ (String.make i ' ') ^ "(" ^ + (String.concat " " (aux (succ i) [] e)) + ^ ")" + in + aux i (s::acc) tl + | [] -> (List.rev acc) + in + String.concat "\n" (aux 0 [] s) + + +let print_sexpr_indent s = + print_endline (string_of_sexpr_indent s) diff --git a/Task/S-Expressions/Perl-6/s-expressions.pl6 b/Task/S-Expressions/Perl-6/s-expressions.pl6 new file mode 100644 index 0000000000..5fbec5f7ff --- /dev/null +++ b/Task/S-Expressions/Perl-6/s-expressions.pl6 @@ -0,0 +1,43 @@ +grammar S-Exp { + rule TOP {^ $}; + + token s-list { '(' ~ ')' [ ** [\s+] | '' ] } + token in_list { | } + + proto token s-token {*} + token s-token:sym {\d*\.?\d+} + token s-token:sym {'"' ['\"' |<-[\\"]>]*? '"'} #' + token s-token:sym {<-[()\s]>+} + +} + +# The Actions class, for each syntactic rule there is a method +# that stores some data in the abstract syntax tree with make +class S-Exp::ACTIONS { + method TOP ($/) {make $.ast} + method s-list ($/) {make [$».ast]} + method in_list ($/) {make $/.values[0].ast} + + method s-token:sym ($/){make +$/} + method s-token:sym ($/){make ~$/.substr(1,*-1)} + method s-token:sym ($/){make ~$/} +} + +multi s-exp_writer (Positional $ary) {'(' ~ $ary.map(&s-exp_writer).join(' ') ~ ')'} +multi s-exp_writer (Numeric $num) {~$num} +multi s-exp_writer (Str $str) { + return $str unless $str ~~ /<[(")]>|\s/; + return '()' if $str eq '()'; + '"' ~ $str.subst('"', '\"' ) ~ '"'; +} + + +my $s-exp = '((data "quoted data" 123 4.5) + (data (!@# (4.5) "(more" "data)")))'; + +my $actions = S-Exp::ACTIONS.new(); +my $perl_array = (S-Exp.parse($s-exp, :$actions)).ast; + +say "the expression:\n$s-exp\n"; +say "the perl6-expression:\n{$perl_array.perl}\n"; +say "and back:\n{s-exp_writer($perl_array)}"; diff --git a/Task/S-Expressions/Perl/s-expressions-1.pl b/Task/S-Expressions/Perl/s-expressions-1.pl new file mode 100644 index 0000000000..1a015a427e --- /dev/null +++ b/Task/S-Expressions/Perl/s-expressions-1.pl @@ -0,0 +1,34 @@ +use Text::Balanced qw(extract_delimited extract_bracketed); + +sub sexpr +{ + my $txt = $_[0]; + $txt =~ s/^\s+//s; + $txt =~ s/\s+$//s; + $txt =~ /^\((.*)\)$/s or die "Not an s-expression: <<<$txt>>>"; + $txt = $1; + + my $ret = []; + my $w; + while ($txt ne '') { + my $c = substr $txt,0,1; + if ($c eq '(') { + ($w, $txt) = extract_bracketed($txt, '()'); + $w = sexpr($w); + } elsif ($c eq '"') { + ($w, $txt) = extract_delimited($txt, '"'); + $w =~ s/^"(.*)"/$1/; + } else { + $txt =~ s/^(\S+)// and $w = $1; + } + push @$ret, $w; + $txt =~ s/^\s+//s; + } + return $ret; +} + +sub quote +{ (local $_ = $_[0]) =~ /[\s\"\(\)]/s ? do{s/\"/\\\"/gs; qq{"$_"}} : $_; } + +sub sexpr2txt +{ qq{(@{[ map { ref($_) eq '' ? quote($_) : sexpr2txt($_) } @{$_[0]} ]})} } diff --git a/Task/S-Expressions/Perl/s-expressions-2.pl b/Task/S-Expressions/Perl/s-expressions-2.pl new file mode 100644 index 0000000000..ddcf3cb87a --- /dev/null +++ b/Task/S-Expressions/Perl/s-expressions-2.pl @@ -0,0 +1,13 @@ +my $s = sexpr(q{ + +((data "quoted data" 123 4.5) + (data (!@# (4.5) "(more" "data)"))) + +}); + +# Dump structure +use Data::Dumper; +print Dumper $s; + +# Convert back +print sexpr2txt($s)."\n"; diff --git a/Task/S-Expressions/PicoLisp/s-expressions-1.l b/Task/S-Expressions/PicoLisp/s-expressions-1.l new file mode 100644 index 0000000000..c20b55f97e --- /dev/null +++ b/Task/S-Expressions/PicoLisp/s-expressions-1.l @@ -0,0 +1,21 @@ +: (any "((data \"quoted data\" 123 4.5) (data (!@# (4.5) \"(more\" \"data)\")))") +-> ((data "quoted data" 123 5) (data (!@# (5) "(more" "data)"))) + +: (view @) ++---+-- data +| | +| +-- "quoted data" +| | +| +-- 123 +| | +| +-- 5 +| ++---+-- data + | + +---+-- !@# + | + +---+-- 5 + | + +-- "(more" + | + +-- "data)" diff --git a/Task/S-Expressions/PicoLisp/s-expressions-2.l b/Task/S-Expressions/PicoLisp/s-expressions-2.l new file mode 100644 index 0000000000..8ff9fe9028 --- /dev/null +++ b/Task/S-Expressions/PicoLisp/s-expressions-2.l @@ -0,0 +1,26 @@ +(de readSexpr () + (case (skip) + ("(" (char) (readList)) + ("\"" (char) (readString)) + (T (readAtom)) ) ) ) + +(de readList () + (make + (loop + (NIL (skip)) + (T (= @ ")") (char)) + (link (readSexpr)) ) ) ) + +(de readString () + (pack + (make + (until (= "\"" (or (peek) (quit "Unterminated string"))) + (link (char)) ) + (char) ) ) ) + +(de readAtom () + (let X + (make + (until (or (sp? (peek)) (member (peek) '("(" ")"))) + (link (char)) ) ) + (or (format X) (intern (pack X))) ) ) diff --git a/Task/S-Expressions/PicoLisp/s-expressions-3.l b/Task/S-Expressions/PicoLisp/s-expressions-3.l new file mode 100644 index 0000000000..4e35a5be8c --- /dev/null +++ b/Task/S-Expressions/PicoLisp/s-expressions-3.l @@ -0,0 +1,2 @@ +: (pipe (prin "((data \"quoted data\" 123 4.5) (data (!@# (4.5) \"(more\" \"data)\")))") (readSexpr)) +-> ((data "quoted data" 123 5) (data (!@# (5) "(more" "data)"))) diff --git a/Task/S-Expressions/PicoLisp/s-expressions-4.l b/Task/S-Expressions/PicoLisp/s-expressions-4.l new file mode 100644 index 0000000000..f210881879 --- /dev/null +++ b/Task/S-Expressions/PicoLisp/s-expressions-4.l @@ -0,0 +1,2 @@ +: (sym @@) +-> "((data \"quoted data\" 123 5) (data (!@# (5) \"(more\" \"data)\")))" diff --git a/Task/S-Expressions/PicoLisp/s-expressions-5.l b/Task/S-Expressions/PicoLisp/s-expressions-5.l new file mode 100644 index 0000000000..7ffb082ada --- /dev/null +++ b/Task/S-Expressions/PicoLisp/s-expressions-5.l @@ -0,0 +1,14 @@ +(de printSexpr (Expr Fun) + (cond + ((pair Expr) + (Fun "(") + (printSexpr (car Expr) Fun) + (for X (cdr Expr) + (Fun " ") + (printSexpr X Fun) ) + (Fun ")") ) + ((str? Expr) + (Fun "\"") + (mapc Fun (chop Expr)) + (Fun "\"") ) + (T (mapc Fun (chop Expr))) ) ) diff --git a/Task/S-Expressions/PicoLisp/s-expressions-6.l b/Task/S-Expressions/PicoLisp/s-expressions-6.l new file mode 100644 index 0000000000..a574e8f95d --- /dev/null +++ b/Task/S-Expressions/PicoLisp/s-expressions-6.l @@ -0,0 +1,4 @@ +: (printSexpr + '((data "quoted data" 123 4.5) (data (!@# (4.5) "(more" "data)"))) + prin ) +((data "quoted data" 123 5) (data (!@# (5) "(more" "data)"))) diff --git a/Task/S-Expressions/PicoLisp/s-expressions-7.l b/Task/S-Expressions/PicoLisp/s-expressions-7.l new file mode 100644 index 0000000000..fcc0fdecc7 --- /dev/null +++ b/Task/S-Expressions/PicoLisp/s-expressions-7.l @@ -0,0 +1,6 @@ +: (pack + (make + (printSexpr + '((data "quoted data" 123 4.5) (data (!@# (4.5) "(more" "data)"))) + link ) ) ) +-> "((data \"quoted data\" 123 5) (data (!@# (5) \"(more\" \"data)\")))" diff --git a/Task/S-Expressions/Pike/s-expressions.pike b/Task/S-Expressions/Pike/s-expressions.pike new file mode 100644 index 0000000000..ed40d20d91 --- /dev/null +++ b/Task/S-Expressions/Pike/s-expressions.pike @@ -0,0 +1,106 @@ +class Symbol(string name) +{ + string _sprintf(int type) + { + switch(type) + { + case 's': return name; + case 'O': return sprintf("(Symbol: %s)", name||""); + case 'q': return name; + case 't': return "Symbol"; + default: return sprintf("%"+int2char(type), name); + } + } + + mixed cast(string type) + { + switch(type) + { + case "string": return name; + default: throw(sprintf("can not cast 'Symbol' to '%s'", type)); + } + } +} + +mixed value(string token) +{ + if ((string)(int)token==token) + return (int)token; + array result = array_sscanf(token, "%f%s"); + if (sizeof(result) && floatp(result[0]) && ! sizeof(result[1])) + return result[0]; + else + return Symbol(token); +} + +array tokenizer(string input) +{ + array output = ({}); + for(int i=0; ipush(ret); ret=({}); break; + case ")": + if (!sizeof(ret) || !stack->ptr) + { + // Mismatch + werror ("unmatched close parenthesis\n"); + return ret; + } + ret=stack->pop()+({ ret }); + break; + default: ret+=({token}); break; + } + } + return ret; +} + +string sexp(array input) +{ + array output = ({}); + foreach(input;; mixed item) + { + if (arrayp(item)) + output += ({ sexp(item) }); + else if (intp(item)) + output += ({ sprintf("%d", item) }); + else if (floatp(item)) + output += ({ sprintf("%f", item) }); + else + output += ({ sprintf("%q", item) }); + } + return "("+output*" "+")"; +} + +string input = "((data \"quoted data\" 123 4.5)\n (data (!@# (4.5) \"(more\" \"data)\")))"; +array data = group(tokenizer(input))[0]; +string output = sexp(data); diff --git a/Task/S-Expressions/Python/s-expressions-1.py b/Task/S-Expressions/Python/s-expressions-1.py new file mode 100644 index 0000000000..f9a211b384 --- /dev/null +++ b/Task/S-Expressions/Python/s-expressions-1.py @@ -0,0 +1,60 @@ +import re + +dbg = False + +term_regex = r'''(?mx) + \s*(?: + (?P\()| + (?P\))| + (?P\d+\.\d+|\d+)\b| + (?P"[^"]*")| + (?P\S+)\b + )''' + +def parse_sexp(sexp): + stack = [] + out = [] + if dbg: print("%-6s %-14s %-44s %-s" % tuple("term value out stack".split())) + for termtypes in re.finditer(term_regex, sexp): + term, value = [(t,v) for t,v in termtypes.groupdict().items() if v][0] + if dbg: print("%-7s %-14s %-44r %-r" % (term, value, out, stack)) + if term == 'brackl': + stack.append(out) + out = [] + elif term == 'brackr': + assert stack, "Trouble with nesting of brackets" + tmpout, out = out, stack.pop(-1) + out.append(tmpout) + elif term == 'num': + v = float(value) + if v.is_integer(): v = int(v) + out.append(v) + elif term == 'sq': + out.append(value[1:-1]) + elif term == 's': + out.append(value) + else: + raise NotImplementedError("Error: %r" % (term, value)) + assert not stack, "Trouble with nesting of brackets" + return out[0] + +def print_sexp(exp): + out = '' + if type(exp) == type([]): + out += '(' + ' '.join(print_sexp(x) for x in exp) + ')' + elif type(exp) == type('') and re.search(r'[\s()]', exp): + out += '"%s"' % repr(exp)[1:-1].replace('"', '\"') + else: + out += '%s' % exp + return out + + +if __name__ == '__main__': + sexp = ''' ( ( data "quoted data" 123 4.5) + (data (123 (4.5) "(more" "data)")))''' + + print('Input S-expression: %r' % (sexp, )) + parsed = parse_sexp(sexp) + print("\nParsed to Python:", parsed) + + print("\nThen back to: '%s'" % print_sexp(parsed)) diff --git a/Task/S-Expressions/Python/s-expressions-2.py b/Task/S-Expressions/Python/s-expressions-2.py new file mode 100644 index 0000000000..f897c132e8 --- /dev/null +++ b/Task/S-Expressions/Python/s-expressions-2.py @@ -0,0 +1,23 @@ +>>> from pprint import pprint as pp +>>> x = [[(t,v) for t,v in termtypes.groupdict().items() if v][0] for termtypes in re.finditer(term_regex, sexp)] +>>> pp(x) +[('brackl', '('), + ('brackl', '('), + ('s', 'data'), + ('sq', '"quoted data"'), + ('num', '123'), + ('num', '4.5'), + ('brackr', ')'), + ('brackl', '('), + ('s', 'data'), + ('brackl', '('), + ('num', '123'), + ('brackl', '('), + ('num', '4.5'), + ('brackr', ')'), + ('sq', '"(more"'), + ('sq', '"data)"'), + ('brackr', ')'), + ('brackr', ')'), + ('brackr', ')')] +>>> diff --git a/Task/S-Expressions/REXX/s-expressions.rexx b/Task/S-Expressions/REXX/s-expressions.rexx new file mode 100644 index 0000000000..2d79e2f785 --- /dev/null +++ b/Task/S-Expressions/REXX/s-expressions.rexx @@ -0,0 +1,75 @@ +/*REXX program parses an S-expression and displays the results. */ +input= '((data "quoted data" 123 4.5) (data (!@# (4.5) "(more" "data)")))' +say 'input:' /*indicate what is being shown. */ +say input /*echo the input to the screen. */ +say copies('═',length(input)) /*display a header fence. */ +$.= /*stem array to hold the tokens. */ +groupO.1 = '{' ; groupC.1 = '}' /*grouping symbols (Open & Close)*/ +groupO.2 = '[' ; groupC.2 = ']' /* " " " " " */ +groupO.3 = '(' ; groupC.3 = ')' /* " " " " " */ +groupSym = 3 /*the number of grouping symbols.*/ +# = 0 /*the number of tokens. */ +tabs = 10 /*used for indenting the levels. */ +q.1 = "'" /*literal string delimiter, 1st. */ +q.2 = '"' /* " " " 2nd. */ +numLits = 2 /*number of kinds of literals. */ +seps = ',;' /*characters used for separation.*/ +atoms = ' 'seps /*characters used to sep atoms. */ +level = 0 /*current level being processed. */ +quoted = 0 /*quotation level (when nested). */ +groupu = /*used to go ↑ an expresion level*/ +groupd = /* " " " ↓ " " " */ + do n=1 for groupSym /*handle for # grouping symbols. */ + atoms = atoms || groupO.n || groupC.n + groupu = groupu || groupO.n + groupd = groupd || groupC.n + end /*n*/ +literals= + do k=1 for numLits + literals = literals || q.k + end /*k*/ +!= +/*═════════════════════════════════════start of the text parsing.═══════*/ + do j=1 to length(input); _ = substr(input,j,1) + if quoted then do + !=! || _ + if _==literalStart then quoted=0 + iterate + end + + if pos(_,literals)\==0 then do + literalStart = _ + ! = ! || _ + quoted = 1 + iterate + end + + if pos(_,atoms)==0 then do; !=! || _ ; iterate; end + else do; call add!; ! = _ ; end + + if pos(_,literals)==0 then do + if pos(_,groupu)\==0 then level=level+1 + call add! + if pos(_,groupd)\==0 then level=level-1 + if level<0 then say 'oops, mismatched' _ + iterate + end + end /*j*/ + +call add! /*handle any residual tokens. */ +if level\==0 then say 'oops, mismatched grouping symbol' +if quoted then say 'oops, no end of quoted literal' literalStart +/*═════════════════════════════════════end of text parsing.═════════════*/ + + do j=1 for # + say $.j + end /*j*/ +exit /*stick a fork in it, we're done.*/ + +/*──────────────────────────────────ADD! subroutine─────────────────────*/ +add!: if !\='' then do + #=#+1 + $.#=left('',max(0,tabs*(level-1)))! + end + != + return diff --git a/Task/S-Expressions/Racket/s-expressions.rkt b/Task/S-Expressions/Racket/s-expressions.rkt new file mode 100644 index 0000000000..dc07f9d853 --- /dev/null +++ b/Task/S-Expressions/Racket/s-expressions.rkt @@ -0,0 +1,9 @@ +#lang racket +(define input +#<<--- +((data "quoted data" 123 4.5) + (data (!@# (4.5) "(more" "data)"))) +--- + ) + +(read (open-input-string input)) diff --git a/Task/S-Expressions/Ruby/s-expressions.rb b/Task/S-Expressions/Ruby/s-expressions.rb new file mode 100644 index 0000000000..e7796a378d --- /dev/null +++ b/Task/S-Expressions/Ruby/s-expressions.rb @@ -0,0 +1,124 @@ +class SExpr + def initialize(str) + @original = str + @data = parse_sexpr(str) + end + attr_reader :data, :original + + def to_sexpr + @data.to_sexpr + end + + private + + def parse_sexpr(str) + state = :token_start + tokens = [] + word = "" + str.each_char do |char| + case state + + when :token_start + case char + when "(" + tokens << :lbr + when ")" + tokens << :rbr + when /\s/ + # do nothing, just consume the whitespace + when '"' + state = :read_quoted_string + word = "" + else + state = :read_string_or_number + word = char + end + + when :read_quoted_string + case char + when '"' + tokens << word + state = :token_start + else + word << char + end + + when :read_string_or_number + case char + when /\s/ + tokens << symbol_or_number(word) + state = :token_start + when ')' + tokens << symbol_or_number(word) + tokens << :rbr + state = :token_start + else + word << char + end + end + end + + sexpr_tokens_to_array(tokens) + end + + def symbol_or_number(word) + begin + Integer(word) + rescue ArgumentError + begin + Float(word) + rescue ArgumentError + word.to_sym + end + end + end + + def sexpr_tokens_to_array(tokens, idx = 0) + result = [] + while idx < tokens.length + case tokens[idx] + when :lbr + tmp, idx = sexpr_tokens_to_array(tokens, idx + 1) + result << tmp + when :rbr + return [result, idx] + else + result << tokens[idx] + end + idx += 1 + end + result[0] + end +end + +class Object + def to_sexpr + self + end +end + +class String + def to_sexpr + self.match(/[\s()]/) ? self.inspect : self + end +end + +class Symbol + alias :to_sexpr :to_s +end + +class Array + def to_sexpr + "(%s)" % inject([]) {|a, elem| a << elem.to_sexpr}.join(" ") + end +end + + +sexpr = SExpr.new <710889 +B0YBKJ +406566 +B0YBLH +228276 +B0YBKL +557910 +B0YBKR +585284 +B0YBKT +B00030 Produce this output: +
    7108899
    +B0YBKJ7
    +4065663
    +B0YBLH2
    +2282765
    +B0YBKL9
    +5579107
    +B0YBKR5
    +5852842
    +B0YBKT7
    +B000300
    + +For extra credit, check each input is correctly formed, especially with respect to valid characters allowed in a SEDOL string. + +C.f. [[Luhn test]] diff --git a/Task/SEDOLs/1META.yaml b/Task/SEDOLs/1META.yaml new file mode 100644 index 0000000000..0b9ae97960 --- /dev/null +++ b/Task/SEDOLs/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Checksums diff --git a/Task/SEDOLs/ALGOL-68/sedols.alg b/Task/SEDOLs/ALGOL-68/sedols.alg new file mode 100644 index 0000000000..8b2ef61756 --- /dev/null +++ b/Task/SEDOLs/ALGOL-68/sedols.alg @@ -0,0 +1,58 @@ +[]INT sedol weights = (1, 3, 1, 7, 3, 9); +STRING reject = "AEIOUaeiou"; + +PROC strcspn = (STRING s,reject)INT: ( + INT out:=0; + FOR i TO UPB s DO + IF char in string(s[i], LOC INT, reject) THEN + return out + FI; + out:=i + OD; + return out: out +); + +PROC sedol checksum = (REF STRING sedol6)INT: +( + INT out; + + INT len := UPB sedol6; + INT sum := 0; + + IF sedol6[len-1] = REPR 10 THEN len-:=1; sedol6[len]:=null char FI; + IF len = 7 THEN + putf(stand error, ($"SEDOL code already checksummed? ("g")"l$, sedol6)); + out := ABS ( BIN ABS sedol6[6] AND 16r7f); return out + FI; + IF len > 7 OR len < 6 OR strcspn(sedol6, reject) /= 6 THEN + putf(stand error, ($"not a SEDOL code? ("g")"l$, sedol6)); + out := -1; return out + FI; + FOR i TO UPB sedol6 DO + sum+:=sedol weights[i]* + IF is digit(sedol6[i]) THEN + ABS sedol6[i]- ABS "0" + ELIF is alpha(sedol6[i]) THEN + (ABS to upper(sedol6[i])-ABS "A") + 10 + ELSE + putf(stand error, $"SEDOL with not alphanumeric digit"l$); + out:=-1; return out + FI + OD; + out := (10 - (sum MOD 10)) MOD 10 + ABS "0"; + return out: out +); + +main: +( + STRING line; + + on logical file end(stand in, (REF FILE f)BOOL: done); + DO getf(stand in, ($gl$,line)); + INT sr := sedol checksum(line); + IF sr > 0 THEN + printf(($ggl$, line, REPR sedol checksum(line))) + FI + OD; + done: SKIP +) diff --git a/Task/SEDOLs/AWK/sedols.awk b/Task/SEDOLs/AWK/sedols.awk new file mode 100644 index 0000000000..706820e4ea --- /dev/null +++ b/Task/SEDOLs/AWK/sedols.awk @@ -0,0 +1,49 @@ +function ord(a) +{ + return amap[a] +} + +function sedol_checksum(sed) +{ + sw[1] = 1; sw[2] = 3; sw[3] = 1 + sw[4] = 7; sw[5] = 3; sw[6] = 9 + sum = 0 + for(i=1; i <= 6; i++) { + c = substr(toupper(sed), i, 1) + if ( c ~ /[[:digit:]]/ ) { + sum += c*sw[i] + } else { + sum += (ord(c)-ord("A")+10)*sw[i] + } + } + return (10 - (sum % 10)) % 10 +} + +BEGIN { # prepare amap for ord + for(_i=0;_i<256;_i++) { + astr = sprintf("%c", _i) + amap[astr] = _i + } +} + +/[AEIOUaeiou]/ { + print "'" $0 "' not a valid SEDOL code" + next +} +{ + if ( (length($0) > 7) || (length($0) < 6) ) { + print "'" $0 "' is too long or too short to be valid SEDOL" + next + } + sedol = substr($0, 1, 6) + sedolcheck = sedol_checksum(sedol) + if ( length($0) == 7 ) { + if ( (sedol sedolcheck) != $0 ) { + print sedol sedolcheck " (original " $0 " has wrong check digit" + } else { + print sedol sedolcheck + } + } else { + print sedol sedolcheck + } +} diff --git a/Task/SEDOLs/ActionScript/sedols.as b/Task/SEDOLs/ActionScript/sedols.as new file mode 100644 index 0000000000..154778649c --- /dev/null +++ b/Task/SEDOLs/ActionScript/sedols.as @@ -0,0 +1,50 @@ +//Return the code corresponding to a given character. +//ActionScript does not have a character type, so 1-digit strings +//are used instead +function toSEDOLCode(char:String):uint { + //Make sure only a single character was sent. + if(char.length != 1) + throw new Error("toSEDOL expected string length of 1, got " + char.length); + //Character is uppercase + if (char >= "A" && char <= "Z") { + return SEDOL.charCodeAt() + 10 - "A".charCodeAt(); + } + //Character is numeric + else if (char >= "0" && char <= "9"){ + return uint(char); + } + //Error: character is neither numeric nor uppercase + else{ + throw new Error("toSEDOLCode expected numeric or uppercase character, recieved " + char); + } +} +//Calculate the weighted sum for the SEDOL. +function toSum(str:String):uint { + if(str.length != 6) + throw new Error("toSum expected length 6, recieved " + str.length); + var sum:uint=0; + for (var i:uint = 0; i < str.length; i++) + sum+=toSEDOLCode(str.charAt(i))*[1,3,1,7,3,9][i]; + return sum; +} +//Calculate the check digit from the weighted sum. +function toCheck(num:int):uint +{ + return (10 -(num % 10)) % 10; +} +//Print the SEDOL with the check digit added. +function printWithCheck(SEDOL:String):void +{ + trace(SEDOL + toCheck(toSum(SEDOL))); +} +printWithCheck("710889"); +printWithCheck("B0YBKJ"); +printWithCheck("406566"); +printWithCheck("B0YBLH"); +printWithCheck("228276"); +printWithCheck("B0YBKL"); +printWithCheck("557910"); +printWithCheck("B0YBKR"); +printWithCheck("585284"); +printWithCheck("B0YBKT"); +printWithCheck("B00030"); diff --git a/Task/SEDOLs/Ada/sedols.ada b/Task/SEDOLs/Ada/sedols.ada new file mode 100644 index 0000000000..d6a6d03f2e --- /dev/null +++ b/Task/SEDOLs/Ada/sedols.ada @@ -0,0 +1,40 @@ +with Ada.Text_IO; use Ada.Text_IO; + +procedure Test_SEDOL is + + subtype SEDOL_String is String (1..6); + type SEDOL_Sum is range 0..9; + + function Check (SEDOL : SEDOL_String) return SEDOL_Sum is + Weight : constant array (SEDOL_String'Range) of Integer := (1,3,1,7,3,9); + Sum : Integer := 0; + Item : Integer; + begin + for Index in SEDOL'Range loop + Item := Character'Pos (SEDOL (Index)); + case Item is + when Character'Pos ('0')..Character'Pos ('9') => + Item := Item - Character'Pos ('0'); + when Character'Pos ('B')..Character'Pos ('D') | + Character'Pos ('F')..Character'Pos ('H') | + Character'Pos ('J')..Character'Pos ('N') | + Character'Pos ('P')..Character'Pos ('T') | + Character'Pos ('V')..Character'Pos ('Z') => + Item := Item - Character'Pos ('A') + 10; + when others => + raise Constraint_Error; + end case; + Sum := Sum + Item * Weight (Index); + end loop; + return SEDOL_Sum ((-Sum) mod 10); + end Check; + + Test : constant array (1..10) of SEDOL_String := + ( "710889", "B0YBKJ", "406566", "B0YBLH", "228276", + "B0YBKL", "557910", "B0YBKR", "585284", "B0YBKT" + ); +begin + for Index in Test'Range loop + Put_Line (Test (Index) & Character'Val (Character'Pos ('0') + Check (Test (Index)))); + end loop; +end Test_SEDOL; diff --git a/Task/SEDOLs/AutoHotkey/sedols.ahk b/Task/SEDOLs/AutoHotkey/sedols.ahk new file mode 100644 index 0000000000..deedca1445 --- /dev/null +++ b/Task/SEDOLs/AutoHotkey/sedols.ahk @@ -0,0 +1,17 @@ +MsgBox % SEDOL("710889") ;7108899 +MsgBox % SEDOL("B0YBKJ") ;B0YBKJ7 +MsgBox % SEDOL("406566") ;4065663 +MsgBox % SEDOL("B0YBLH") ;B0YBLH2 +MsgBox % SEDOL("228276") ;2282765 +MsgBox % SEDOL("B0YBKL") ;B0YBKL9 +MsgBox % SEDOL("557910") ;5579107 +MsgBox % SEDOL("B0YBKR") ;B0YBKR5 +MsgBox % SEDOL("585284") ;5852842 +MsgBox % SEDOL("B0YBKT") ;B0YBKT7 + +SEDOL(w) { + Static w1:=1,w2:=3,w3:=1,w4:=7,w5:=3,w6:=9 + Loop Parse, w + s += ((c:=Asc(A_LoopField))>=Asc("A") ? c-Asc("A")+10 : c-Asc("0")) * w%A_Index% + Return w mod(10-mod(s,10),10) +} diff --git a/Task/SEDOLs/BASIC/sedols.basic b/Task/SEDOLs/BASIC/sedols.basic new file mode 100644 index 0000000000..80562d478a --- /dev/null +++ b/Task/SEDOLs/BASIC/sedols.basic @@ -0,0 +1,31 @@ +DECLARE FUNCTION getSedolCheckDigit! (str AS STRING) +DO + INPUT a$ + PRINT a$ + STR$(getSedolCheckDigit(a$)) +LOOP WHILE a$ <> "" + +FUNCTION getSedolCheckDigit (str AS STRING) + IF LEN(str) <> 6 THEN + PRINT "Six chars only please" + EXIT FUNCTION + END IF + str = UCASE$(str) + DIM mult(6) AS INTEGER + mult(1) = 1: mult(2) = 3: mult(3) = 1 + mult(4) = 7: mult(5) = 3: mult(6) = 9 + total = 0 + FOR i = 1 TO 6 + s$ = MID$(str, i, 1) + IF s$ = "A" OR s$ = "E" OR s$ = "I" OR s$ = "O" OR s$ = "U" THEN + PRINT "No vowels" + EXIT FUNCTION + END IF + IF ASC(s$) >= 48 AND ASC(s$) <= 57 THEN + total = total + VAL(s$) * mult(i) + ELSE + total = total + (ASC(s$) - 55) * mult(i) + END IF + + NEXT i + getSedolCheckDigit = (10 - (total MOD 10)) MOD 10 +END FUNCTION diff --git a/Task/SEDOLs/BBC-BASIC/sedols.bbc b/Task/SEDOLs/BBC-BASIC/sedols.bbc new file mode 100644 index 0000000000..961928f411 --- /dev/null +++ b/Task/SEDOLs/BBC-BASIC/sedols.bbc @@ -0,0 +1,21 @@ + PRINT FNsedol("710889") + PRINT FNsedol("B0YBKJ") + PRINT FNsedol("406566") + PRINT FNsedol("B0YBLH") + PRINT FNsedol("228276") + PRINT FNsedol("B0YBKL") + PRINT FNsedol("557910") + PRINT FNsedol("B0YBKR") + PRINT FNsedol("585284") + PRINT FNsedol("B0YBKT") + PRINT FNsedol("B00030") + END + + DEF FNsedol(d$) + LOCAL a%, i%, s%, weights%() + DIM weights%(6) : weights%() = 0, 1, 3, 1, 7, 3, 9 + FOR i% = 1 TO 6 + a% = ASCMID$(d$,i%) - &30 + s% += (a% + 7 * (a% > 9)) * weights%(i%) + NEXT + = d$ + CHR$(&30 + (10 - s% MOD 10) MOD 10) diff --git a/Task/SEDOLs/C++/sedols.cpp b/Task/SEDOLs/C++/sedols.cpp new file mode 100644 index 0000000000..3c2cf949a9 --- /dev/null +++ b/Task/SEDOLs/C++/sedols.cpp @@ -0,0 +1,52 @@ +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +const int weights[] = {1,3,1,7,3,9}; +const string valid_chars = "BCDFGHJKLMNPQRSTVWXYZ0123456789"; + +int char_value(char c){ return isalpha(c) ? c -'A' + 10 : c - '0'; } + +int sedol_checksum(string const& sedol) +{ + //Check contents + if(sedol.size() != 6) + throw length_error("length of sedol string != 6"); + if(sedol.find_first_not_of(valid_chars) != std::string::npos) + throw invalid_argument("sedol string contains disallowed characters"); + + vector char_values; + transform(sedol.begin(), sedol.end(), back_inserter(char_values), char_value); + const int weighted_sum = inner_product(char_values.begin(), char_values.end(), weights, 0); + return (10 - (weighted_sum % 10)) % 10; +} + +int main() +{ + string inputs[] = { + "710889", + "B0YBKJ", + "406566", + "B0YBLH", + "228276", + "B0YBKL", + "557910", + "B0YBKR", + "585284", + "B0YBKT", + "B00030" + }; + const size_t n_inputs = sizeof(inputs) / sizeof(*inputs); + + for(size_t i = 0; i != n_inputs; ++i) + { + cout << inputs[i] << sedol_checksum(inputs[i]) << "\n"; + } + return 0; +} diff --git a/Task/SEDOLs/C/sedols.c b/Task/SEDOLs/C/sedols.c new file mode 100644 index 0000000000..82a33d2d52 --- /dev/null +++ b/Task/SEDOLs/C/sedols.c @@ -0,0 +1,48 @@ +#include +#include +#include + +int sedol_weights[] = {1, 3, 1, 7, 3, 9}; +const char *reject = "AEIOUaeiou"; + +int sedol_checksum(const char *sedol6) +{ + int len = strlen(sedol6); + int sum = 0, i; + + if ( len == 7 ) { + fprintf(stderr, "SEDOL code already checksummed? (%s)\n", sedol6); + return sedol6[6] & 0x7f; + } + if ( (len > 7) || (len < 6) || ( strcspn(sedol6, reject) != 6 )) { + fprintf(stderr, "not a SEDOL code? (%s)\n", sedol6); + return -1; + } + for(i=0; i < 6; i++) { + if ( isdigit(sedol6[i]) ) { + sum += (sedol6[i]-'0')*sedol_weights[i]; + } else if ( isalpha(sedol6[i]) ) { + sum += ((toupper(sedol6[i])-'A') + 10)*sedol_weights[i]; + } else { + fprintf(stderr, "SEDOL with not alphanumeric digit\n"); + return -1; + } + } + return (10 - (sum%10))%10 + '0'; +} + + +#define MAXLINELEN 10 +int main() +{ + char line[MAXLINELEN]; + int sr, len; + while( fgets(line, MAXLINELEN, stdin) != NULL ) { + len = strlen(line); + if ( line[len-1] == '\n' ) line[len-1]='\0'; + sr = sedol_checksum(line); + if ( sr > 0 ) + printf("%s%c\n", line, sr); + } + return 0; +} diff --git a/Task/SEDOLs/Common-Lisp/sedols.lisp b/Task/SEDOLs/Common-Lisp/sedols.lisp new file mode 100644 index 0000000000..8070b0e673 --- /dev/null +++ b/Task/SEDOLs/Common-Lisp/sedols.lisp @@ -0,0 +1,12 @@ +(defun append-sedol-check-digit (sedol &key (start 0) (end (+ start 6))) + (assert (<= 0 start end (length sedol))) + (assert (= (- end start) 6)) + (loop + :with checksum = 0 + :for weight :in '(1 3 1 7 3 9) + :for index :upfrom start + :do (incf checksum (* weight (digit-char-p (char sedol index) 36))) + :finally (let* ((posn (- 10 (mod checksum 10))) + (head (subseq sedol start end)) + (tail (digit-char posn))) + (return (concatenate 'string head (list tail)))))) diff --git a/Task/SEDOLs/D/sedols-1.d b/Task/SEDOLs/D/sedols-1.d new file mode 100644 index 0000000000..e9ca975227 --- /dev/null +++ b/Task/SEDOLs/D/sedols-1.d @@ -0,0 +1,20 @@ +import std.stdio, std.algorithm, std.string, std.numeric, std.ascii; + +char checksum(in char[] sedol) +in { + assert(sedol.length == 6); + foreach (c; sedol) + assert(isDigit(c) || (isUpper(c) && !canFind("AEIOU", c))); +} out (result) { + assert(isDigit(result)); +} body { + static int c2v(in dchar c){ return isDigit(c) ? c-'0' : c-'A'+10; } + immutable int d = sedol.map!c2v().dotProduct([1,3,1,7,3,9]); + return '0' + 10 - (d % 10); +} + +void main() { + foreach (sedol; "710889 B0YBKJ 406566 B0YBLH 228276 + B0YBKL 557910 B0YBKR 585284 B0YBKT".split()) + writeln(sedol, checksum(sedol)); +} diff --git a/Task/SEDOLs/D/sedols-2.d b/Task/SEDOLs/D/sedols-2.d new file mode 100644 index 0000000000..16dafdd074 --- /dev/null +++ b/Task/SEDOLs/D/sedols-2.d @@ -0,0 +1,35 @@ +import std.stdio, std.algorithm, std.string, std.numeric, std.ascii; + +char sedolChecksum(in char[] sedol) /*pure*/ nothrow +in { + assert(sedol.length == 6, "SEDOL must be 6 chars long."); + enum uint mask = 0b11_1110_1111_1011_1110_1110_1110; + + foreach (c; sedol) + assert(isDigit(c) || + (c > 'A' && c <= 'Z' && ((1U << (c - 'A')) & mask)), + "SEDOL with wrong char."); +} out(result) { + assert(isDigit(result)); + static int c2v(in dchar c){ return isDigit(c) ? c-'0' : c-'A'+10; } + immutable int d = sedol.map!c2v().dotProduct([1,3,1,7,3,9]); + assert((d + result - '0') % 10 == 0); +} body { + enum int[] weights = [1, 3, 1, 7, 3, 9]; + + int sum = 0; + foreach (i, c; sedol) { + if (isDigit(c)) + sum += (c - '0') * weights[i]; + else + sum += (c - 'A' + 10) * weights[i]; + } + + return '0' + 10 - (sum % 10); +} + +void main() { + foreach (s; ["710889", "B0YBKJ", "406566", "B0YBLH", "228276", + "B0YBKL", "557910", "B0YBKR", "585284", "B0YBKT"]) + writeln(s, s.sedolChecksum()); +} diff --git a/Task/SEDOLs/D/sedols-3.d b/Task/SEDOLs/D/sedols-3.d new file mode 100644 index 0000000000..504a6e8b35 --- /dev/null +++ b/Task/SEDOLs/D/sedols-3.d @@ -0,0 +1,12 @@ +import std.stdio, std.algorithm, std.string, std.numeric; + +auto checksum(string s) { + auto m = s.map!q{ a>='0' && a<='9' ? a-'0' : a-'A'+10 }(); + return '0' + 10 - m.dotProduct([1,3,1,7,3,9]) % 10; +} + +void main() { + foreach (sedol; "710889 B0YBKJ 406566 B0YBLH 228276 + B0YBKL 557910 B0YBKR 585284 B0YBKT".split()) + writeln(sedol, sedol.checksum()); +} diff --git a/Task/SEDOLs/E/sedols.e b/Task/SEDOLs/E/sedols.e new file mode 100644 index 0000000000..18403cfb8b --- /dev/null +++ b/Task/SEDOLs/E/sedols.e @@ -0,0 +1,37 @@ +def weights := [1,3,1,7,3,9] +def Digit := ('0'..'9') +def Letter := ('B'..'D'|'F'..'H'|'J'..'N'|'P'..'T'|'V'..'Z') +def sedolCharValue(c) { + switch (c) { + match digit :Digit { return digit - '0' } + match letter :Letter { + return letter - 'A' + } + } +} + +def checksum(sedol :String) { + require(sedol.size() == 6) + var sum := 0 + for i => c in sedol { + sum += weights[i] * sedolCharValue(c) + } + return E.toString((10 - sum %% 10) %% 10) +} + +def addChecksum(sedol :String) { + return sedol + checksum(sedol) +} + +for sedol in "710889 + B0YBKJ + 406566 + B0YBLH + 228276 + B0YBKL + 557910 + B0YBKR + 585284 + B0YBKT".trim().split("\n") { + println(addChecksum(sedol.trim())) +} diff --git a/Task/SEDOLs/Forth/sedols.fth b/Task/SEDOLs/Forth/sedols.fth new file mode 100644 index 0000000000..fd1bd7aafe --- /dev/null +++ b/Task/SEDOLs/Forth/sedols.fth @@ -0,0 +1,28 @@ +create weight 1 , 3 , 1 , 7 , 3 , 9 , + +: char>num ( '0-9A-Z' -- 0..35 ) + dup [char] 9 > 7 and - [char] 0 - ; + +: check+ ( sedol -- sedol' ) + 6 <> abort" wrong SEDOL length" + 0 ( sum ) + 6 0 do + over I + c@ char>num + weight I cells + @ * + + + loop + 10 mod 10 swap - 10 mod [char] 0 + + over 6 + c! 7 ; + +: sedol" [char] " parse check+ type ; + +sedol" 710889" 7108899 ok +sedol" B0YBKJ" B0YBKJ7 ok +sedol" 406566" 4065663 ok +sedol" B0YBLH" B0YBLH2 ok +sedol" 228276" 2282765 ok +sedol" B0YBKL" B0YBKL9 ok +sedol" 557910" 5579107 ok +sedol" B0YBKR" B0YBKR5 ok +sedol" 585284" 5852842 ok +sedol" B0YBKT" B0YBKT7 ok diff --git a/Task/SEDOLs/Fortran/sedols.f b/Task/SEDOLs/Fortran/sedols.f new file mode 100644 index 0000000000..c0b4f1bf1e --- /dev/null +++ b/Task/SEDOLs/Fortran/sedols.f @@ -0,0 +1,43 @@ +MODULE SEDOL_CHECK + IMPLICIT NONE + CONTAINS + + FUNCTION Checkdigit(c) + CHARACTER :: Checkdigit + CHARACTER(6), INTENT(IN) :: c + CHARACTER(36) :: alpha = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + INTEGER, DIMENSION(6) :: weights = (/ 1, 3, 1, 7, 3, 9 /), temp + INTEGER :: i, n + + DO i = 1, 6 + temp(i) = INDEX(alpha, c(i:i)) - 1 + END DO + temp = temp * weights + n = MOD(10 - (MOD(SUM(temp), 10)), 10) + Checkdigit = ACHAR(n + 48) + END FUNCTION Checkdigit + +END MODULE SEDOL_CHECK + +PROGRAM SEDOLTEST + USE SEDOL_CHECK + IMPLICIT NONE + + CHARACTER(31) :: valid = "0123456789BCDFGHJKLMNPQRSTVWXYZ" + CHARACTER(6) :: codes(10) = (/ "710889", "B0YBKJ", "406566", "B0YBLH", "228276" , & + "B0YBKL", "557910", "B0YBKR", "585284", "B0YBKT" /) + CHARACTER(7) :: sedol + INTEGER :: i, invalid + + DO i = 1, 10 + invalid = VERIFY(codes(i), valid) + IF (invalid == 0) THEN + sedol = codes(i) + sedol(7:7) = Checkdigit(codes(i)) + ELSE + sedol = "INVALID" + END IF + WRITE(*, "(2A9)") codes(i), sedol + END DO + +END PROGRAM SEDOLTEST diff --git a/Task/SEDOLs/Go/sedols.go b/Task/SEDOLs/Go/sedols.go new file mode 100644 index 0000000000..af28fda225 --- /dev/null +++ b/Task/SEDOLs/Go/sedols.go @@ -0,0 +1,62 @@ +package main + +import ( + "fmt" + "strings" + "strconv" +) + +const input = `710889 +B0YBKJ +406566 +B0YBLH +228276 +B0YBKL +557910 +B0YBKR +585284 +B0YBKT +B00030 + +B +B0003 +B000300 +A00030 +E00030 +I00030 +O00030 +U00030 +β00030 +β0003` + +var weight = [...]int{1,3,1,7,3,9} + +func csd(code string) string { + switch len(code) { + case 6: + case 0: + return "No data" + default: + return "Invalid length" + } + sum := 0 + for i, c := range code { + n, err := strconv.ParseInt(string(c), 36, 0) + if err != nil || c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U' { + return "Invalid character" + } + sum += int(n)*weight[i] + } + return strconv.Itoa(9-(sum-1)%10) +} + +func main() { + for _, s := range strings.Split(input, "\n") { + d := csd(s) + if len(d) > 1 { + fmt.Printf(":%s: %s\n", s, d) + } else { + fmt.Println(s + d) + } + } +} diff --git a/Task/SEDOLs/Groovy/sedols-1.groovy b/Task/SEDOLs/Groovy/sedols-1.groovy new file mode 100644 index 0000000000..32ca96c56f --- /dev/null +++ b/Task/SEDOLs/Groovy/sedols-1.groovy @@ -0,0 +1,10 @@ +def checksum(text) { + assert text.size() == 6 && !text.toUpperCase().find(/[AEIOU]+/) : "Invalid SEDOL text: $text" + + def sum = 0 + (0..5).each { index -> + sum += Character.digit(text.charAt(index), 36) * [1, 3, 1, 7, 3, 9][index] + } + text + (10 - (sum % 10)) % 10 +} +String.metaClass.sedol = { this.&checksum(delegate) } diff --git a/Task/SEDOLs/Groovy/sedols-2.groovy b/Task/SEDOLs/Groovy/sedols-2.groovy new file mode 100644 index 0000000000..354ce69af7 --- /dev/null +++ b/Task/SEDOLs/Groovy/sedols-2.groovy @@ -0,0 +1,6 @@ +[ '710889': '7108899', 'B0YBKJ': 'B0YBKJ7', '406566': '4065663', 'B0YBLH': 'B0YBLH2', + '228276': '2282765', 'B0YBKL': 'B0YBKL9', '557910': '5579107', 'B0YBKR': 'B0YBKR5', + '585284': '5852842', 'B0YBKT': 'B0YBKT7', 'B00030': 'B000300'].each { text, expected -> + println "Checking $text -> $expected" + assert expected == text.sedol() +} diff --git a/Task/SEDOLs/Haskell/sedols.hs b/Task/SEDOLs/Haskell/sedols.hs new file mode 100644 index 0000000000..7403aea6af --- /dev/null +++ b/Task/SEDOLs/Haskell/sedols.hs @@ -0,0 +1,22 @@ +import Data.Char + +char2value c | c `elem` "AEIOU" = error "No vowels." + | c >= '0' && c <= '9' = ord c - ord '0' + | c >= 'A' && c <= 'Z' = ord c - ord 'A' + 10 + +sedolweight = [1,3,1,7,3,9] + +checksum sedol = show ((10 - (tmp `mod` 10)) `mod` 10) + where tmp = sum $ zipWith (*) sedolweight $ map char2value sedol + +main = mapM_ (\sedol -> putStrLn $ sedol ++ checksum sedol) + [ "710889", + "B0YBKJ", + "406566", + "B0YBLH", + "228276", + "B0YBKL", + "557910", + "B0YBKR", + "585284", + "B0YBKT" ] diff --git a/Task/SEDOLs/Icon/sedols.icon b/Task/SEDOLs/Icon/sedols.icon new file mode 100644 index 0000000000..995877e868 --- /dev/null +++ b/Task/SEDOLs/Icon/sedols.icon @@ -0,0 +1,19 @@ +procedure main() +every write(sedol("710889"|"B0YBKJ"|"406566"|"B0YBLH"|"228276"| + "B0YBKL"|"557910"|"B0YBKR"|"585284"|"B0YBKT"|"B00030")) +end + +procedure sedol(x) #: return the completed sedol with check digit +static w,c +initial { + every (i := -1, c := table())[!(&digits||&ucase)] := i +:= 1 # map chars + every c[!"AEIOU"] := &null # delete vowels + w := [1,3,1,7,3,9] # weights + } + +if *(x := map(x,&lcase,&ucase)) = *w then { # match lengths + every (t :=0, i := 1 to *x) do + t +:= \c[x[i]]*w[i] | fail # accumulate weighted chars + return x || (10 - (t%10)) % 10 # complete + } +end diff --git a/Task/SEDOLs/J/sedols-1.j b/Task/SEDOLs/J/sedols-1.j new file mode 100644 index 0000000000..11a4a00aa7 --- /dev/null +++ b/Task/SEDOLs/J/sedols-1.j @@ -0,0 +1,2 @@ +sn =. '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' +ac0 =: (, 10 | 1 3 1 7 3 9 +/@:* -)&.(sn i. |:) diff --git a/Task/SEDOLs/J/sedols-2.j b/Task/SEDOLs/J/sedols-2.j new file mode 100644 index 0000000000..4eec8dc20f --- /dev/null +++ b/Task/SEDOLs/J/sedols-2.j @@ -0,0 +1 @@ +ac1 =: (, 10 | (10 - 1 3 1 7 3 9) +/@:* ])&.(sn i. |:) diff --git a/Task/SEDOLs/J/sedols-3.j b/Task/SEDOLs/J/sedols-3.j new file mode 100644 index 0000000000..11018851bb --- /dev/null +++ b/Task/SEDOLs/J/sedols-3.j @@ -0,0 +1 @@ +ac1 =: (, 10 | 9 7 9 3 7 1 +/@:* ])&.(sn i. |:) diff --git a/Task/SEDOLs/J/sedols-4.j b/Task/SEDOLs/J/sedols-4.j new file mode 100644 index 0000000000..dd40068d16 --- /dev/null +++ b/Task/SEDOLs/J/sedols-4.j @@ -0,0 +1 @@ +ac2 =. (,"1 0 (841 $ '0987654321') {~ 1 3 1 7 3 9 +/ .*~ sn i. ]) diff --git a/Task/SEDOLs/Java/sedols.java b/Task/SEDOLs/Java/sedols.java new file mode 100644 index 0000000000..bae38216f4 --- /dev/null +++ b/Task/SEDOLs/Java/sedols.java @@ -0,0 +1,31 @@ +import java.util.Scanner; + +public class SEDOL{ + public static void main(String[] args){ + Scanner sc = new Scanner(System.in); + while(sc.hasNext()){ + String sedol = sc.next(); + System.out.println(sedol + getSedolCheckDigit(sedol)); + } + } + + private static final int[] mult = {1, 3, 1, 7, 3, 9}; + + public static int getSedolCheckDigit(String str){ + if(!validateSedol(str)){ + System.err.println("SEDOL strings must contain six characters with no vowels."); + return -1; + } + str = str.toUpperCase(); + int total = 0; + for(int i = 0;i < 6; i++){ + char s = str.charAt(i); + total += Character.digit(s, 36) * mult[i]; + } + return (10 - (total % 10)) % 10; + } + + public static boolean validateSedol(String str){ + return (str.length() == 6) && !str.toUpperCase().matches(".*?[AEIOU].*?"); + } +} diff --git a/Task/SEDOLs/JavaScript/sedols.js b/Task/SEDOLs/JavaScript/sedols.js new file mode 100644 index 0000000000..d4b6a86067 --- /dev/null +++ b/Task/SEDOLs/JavaScript/sedols.js @@ -0,0 +1,41 @@ +function sedol(input) { + return input + sedol_check_digit(input); +} + +var weight = [1, 3, 1, 7, 3, 9, 1]; +function sedol_check_digit(char6) { + if (char6.search(/^[0-9BCDFGHJKLMNPQRSTVWXYZ]{6}$/) == -1) + throw "Invalid SEDOL number '" + char6 + "'"; + var sum = 0; + for (var i = 0; i < char6.length; i++) + sum += weight[i] * parseInt(char6.charAt(i), 36); + var check = (10 - sum%10) % 10; + return check.toString(); +} + +var input = [ + '710889', 'B0YBKJ', '406566', 'B0YBLH', '228276', + 'B0YBKL', '557910', 'B0YBKR', '585284', 'B0YBKT', + "BOATER" , "12345", "123456", "1234567" +]; + +var expected = [ + '7108899', 'B0YBKJ7', '4065663', 'B0YBLH2', '2282765', + 'B0YBKL9', '5579107', 'B0YBKR5', '5852842', 'B0YBKT7', + null, null, '1234563', null +]; + +for (var i in input) { + try { + var sedolized = sedol(input[i]); + if (sedolized == expected[i]) + print(sedolized); + else + print("error: calculated sedol for input " + input[i] + + " is " + sedolized + ", but it should be " + expected[i] + ); + } + catch (e) { + print("error: " + e); + } +} diff --git a/Task/SEDOLs/Liberty-BASIC/sedols.liberty b/Task/SEDOLs/Liberty-BASIC/sedols.liberty new file mode 100644 index 0000000000..4257089b80 --- /dev/null +++ b/Task/SEDOLs/Liberty-BASIC/sedols.liberty @@ -0,0 +1,31 @@ +'adapted from BASIC solution + mult(1) = 1: mult(2) = 3: mult(3) = 1 + mult(4) = 7: mult(5) = 3: mult(6) = 9 + +DO + INPUT a$ + PRINT a$ + STR$(getSedolCheckDigit(a$)) +LOOP WHILE a$ <> "" + +FUNCTION getSedolCheckDigit (str$) + IF LEN(str$) <> 6 THEN + PRINT "Six chars only please" + EXIT FUNCTION + END IF + str$ = upper$(str$) + total = 0 + FOR i = 1 TO 6 + s$ = MID$(str$, i, 1) + IF (s$ = "A") OR (s$ = "E") OR (s$ = "I") OR (s$ = "O") OR (s$ = "U") THEN + PRINT "No vowels" + EXIT FUNCTION + END IF + IF (ASC(s$) >= 48) AND (ASC(s$) <= 57) THEN + total = total + VAL(s$) * mult(i) + ELSE + total = total + (ASC(s$) - 55) * mult(i) + END IF + + NEXT i + getSedolCheckDigit = (10 - (total MOD 10)) MOD 10 +END FUNCTION diff --git a/Task/SEDOLs/M4/sedols.m4 b/Task/SEDOLs/M4/sedols.m4 new file mode 100644 index 0000000000..7e873b32a0 --- /dev/null +++ b/Task/SEDOLs/M4/sedols.m4 @@ -0,0 +1,17 @@ +divert(-1) +changequote(`[',`]') +define([_bar],include(sedol.inp)) +define([eachlineA], + [ifelse(eval($2>0),1, + [$3(substr([$1],0,$2))[]eachline(substr([$1],incr($2)),[$3])])]) +define([eachline],[eachlineA([$1],index($1,[ +]),[$2])]) +define([_idx], + [index([0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ],substr($1,$2,1))]) +define([_wsum], + [eval(_idx($1,0)+_idx($1,1)*3+_idx($1,2)+_idx($1,3)*7+_idx($1,4)*3+_idx($1,5)*9)]) +define([checksum], + [$1[]eval((10-_wsum($1)%10)%10) +]) +divert +eachline(_bar,[checksum]) diff --git a/Task/SEDOLs/MUMPS/sedols.mumps b/Task/SEDOLs/MUMPS/sedols.mumps new file mode 100644 index 0000000000..3d5a70e556 --- /dev/null +++ b/Task/SEDOLs/MUMPS/sedols.mumps @@ -0,0 +1,21 @@ +SEDOL + NEW A,B +SEDOL1 + READ !,"Enter the first 6 digits of a SEDOL: ",A + SET B=$$SEDOLCHK(A) + WRITE !,$SELECT($LENGTH(B)=1:"Full SEDOL is "_A_B,1:B) + GOTO SEDOL1 + QUIT +SEDOLCHK(STOCK) + NEW WT,VAL,I,CHK,C,FLAG + SET WT="1317391",VAL=0,FLAG=0 + FOR I=1:1:6 SET C=$$TOUPPER($EXTRACT(STOCK,I)),VAL=VAL+($$SEDVAL(C)*$EXTRACT(WT,I)) SET:"AEIOUaeiou"[C FLAG=1 + SET:$LENGTH(STOCK)'=6 FLAG=1 + KILL WT,I,CHK,C + QUIT $SELECT(FLAG:"INVALID",'FLAG:(10-(VAL#10))#10) +SEDVAL(X) + QUIT $SELECT($ISVALIDNUM(X):X,1:$ASCII(X)-$ASCII("@")+9) +TOUPPER(X) + NEW UP,LO + SET UP="ABCDEFGHIJKLMNOPQRSTUVWXYZ",LO="abcdefghijklmnopqrstuvwxyz" + QUIT $TRANSLATE(X,LO,UP) diff --git a/Task/SEDOLs/Mathematica/sedols.math b/Task/SEDOLs/Mathematica/sedols.math new file mode 100644 index 0000000000..d23135cda9 --- /dev/null +++ b/Task/SEDOLs/Mathematica/sedols.math @@ -0,0 +1,19 @@ +SEDOL[Code_?(Function[v,StringFreeQ[v,{"A","E","I","O","U"}]])]:= +Code<>ToString[10-Mod[ToExpression[Quiet[Flatten[Characters[Code] +/.x_?LetterQ->(ToCharacterCode[x]-55)]]].{1,3,1,7,3,9},10]] + +Scan[Print[SEDOL[#]] &, {"710889","B0YBKJ","406566","B0YBLH","228276","B0YBKL","557910","B0YBKR","585284","B0YBKT","B00030","DUMMY"}] + +->Output: +7108899 +B0YBKJ7 +4065663 +B0YBLH2 +2282765 +B0YBKL9 +5579107 +B0YBKR5 +5852842 +B0YBKT7 +B0003010 +SEDOL[DUMMY] -> rejected diff --git a/Task/SEDOLs/Mercury/sedols.mercury b/Task/SEDOLs/Mercury/sedols.mercury new file mode 100644 index 0000000000..bdf4efc56b --- /dev/null +++ b/Task/SEDOLs/Mercury/sedols.mercury @@ -0,0 +1,53 @@ +:- module sedol. +:- interface. + +:- import_module io. +:- pred main(io::di, io::uo) is det. + +:- implementation. +:- import_module char, int, list, require, string. + +main(!IO) :- + Input = [ + "710889", + "B0YBKJ", + "406566", + "B0YBLH", + "228276", + "B0YBKL", + "557910", + "B0YBKR", + "585284", + "B0YBKT", + "B00030" + ], + list.foldl(print_with_checksum, Input, !IO). + +:- pred print_with_checksum(string::in, io::di, io::uo) is det. + +print_with_checksum(S, !IO) :- + io.format("%s%d\n", [s(S), i(sedol_checksum(S))], !IO). + +:- func sedol_checksum(string) = int. + +sedol_checksum(Sedol) = CheckSum :- + Digits = string.foldr((func(C, A) = [to_sedol_code(C) | A]), Sedol, []), + WeightedDigits = list.map_corresponding(int.times, Digits, [1, 3, 1, 7, 3, 9]), + WeightedSum = list.foldl(int.plus, WeightedDigits, 0), + CheckSum = (10 - (WeightedSum mod 10)) mod 10. + +:- func to_sedol_code(char) = int. + +to_sedol_code(Char) = + ( if char.digit_to_int(Char, Code), not is_vowel(to_upper(Char)) + then Code + else func_error("invalid SEDOL") + ). + +:- pred is_vowel(char::in) is semidet. + +is_vowel('A'). +is_vowel('E'). +is_vowel('I'). +is_vowel('O'). +is_vowel('O'). diff --git a/Task/SEDOLs/Modula-3/sedols.mod3 b/Task/SEDOLs/Modula-3/sedols.mod3 new file mode 100644 index 0000000000..ededc9c39d --- /dev/null +++ b/Task/SEDOLs/Modula-3/sedols.mod3 @@ -0,0 +1,44 @@ +MODULE SEDOL EXPORTS Main; + +IMPORT IO, Fmt, Text, Stdio; + +EXCEPTION BadSedol(TEXT); + +VAR test := ARRAY [1..10] OF TEXT {"710889", "B0YBKJ", "406566", "B0YBLH", + "228276", "B0YBKL", "557910", "B0YBKR", + "585284", "B0YBKT" }; + +PROCEDURE Check(sed: TEXT): INTEGER RAISES {BadSedol}= + VAR + weights := ARRAY [0..5] OF INTEGER {1, 3, 1, 7, 3, 9}; + result, d: INTEGER; + char: CHAR; + BEGIN + IF Text.Length(sed) # 6 THEN + RAISE BadSedol("ERROR: Must be 6 digits."); + END; + result := 0; + FOR i := 0 TO 5 DO + char := Text.GetChar(sed, i); + CASE char OF + | '0'..'9' => d := ORD(char) - ORD('0'); + | 'B'..'D', 'F'..'H', 'J'..'N', 'P'..'T', 'V'..'Z' + => d := ORD(char) - ORD('A') + 10; + ELSE + RAISE BadSedol("ERROR: Must be numbers or (non-vowel) letters."); + END; + INC(result, d * weights[i]); + END; + result := (10 - (result MOD 10)) MOD 10; + RETURN result; + END Check; + +BEGIN + TRY + FOR i := FIRST(test) TO LAST(test) DO + IO.Put(test[i] & Fmt.Char(VAL(ORD('0') + Check(test[i]), CHAR)) & "\n"); + END; + EXCEPT + | BadSedol(text) => IO.Put(text & "\n", Stdio.stderr); + END; +END SEDOL. diff --git a/Task/SEDOLs/OCaml/sedols.ocaml b/Task/SEDOLs/OCaml/sedols.ocaml new file mode 100644 index 0000000000..e2fad564c9 --- /dev/null +++ b/Task/SEDOLs/OCaml/sedols.ocaml @@ -0,0 +1,29 @@ +let char2value c = + assert (not (String.contains "AEIOU" c)); + match c with + '0'..'9' -> int_of_char c - int_of_char '0' + | 'A'..'Z' -> int_of_char c - int_of_char 'A' + 10 + +let sedolweight = [1;3;1;7;3;9] + +let explode s = + let result = ref [] in + String.iter (fun c -> result := c :: !result) s; + List.rev !result + +let checksum sedol = + let tmp = List.fold_left2 (fun sum ch weight -> sum + char2value ch * weight) + 0 (explode sedol) sedolweight in + string_of_int ((10 - (tmp mod 10)) mod 10) + +List.iter (fun sedol -> print_endline (sedol ^ checksum sedol)) + [ "710889"; + "B0YBKJ"; + "406566"; + "B0YBLH"; + "228276"; + "B0YBKL"; + "557910"; + "B0YBKR"; + "585284"; + "B0YBKT" ] diff --git a/Task/SEDOLs/PHP/sedols.php b/Task/SEDOLs/PHP/sedols.php new file mode 100644 index 0000000000..301bb30b94 --- /dev/null +++ b/Task/SEDOLs/PHP/sedols.php @@ -0,0 +1,26 @@ +function char2value($c) { + assert(stripos('AEIOU', $c) === FALSE); + return intval($c, 36); +} + +$sedolweight = array(1,3,1,7,3,9); + +function checksum($sedol) { + global $sedolweight; + $tmp = array_sum(array_map(create_function('$ch, $weight', 'return char2value($ch) * $weight;'), + str_split($sedol), $sedolweight) + ); + return strval((10 - ($tmp % 10)) % 10); +} + +foreach (array('710889', + 'B0YBKJ', + '406566', + 'B0YBLH', + '228276', + 'B0YBKL', + '557910', + 'B0YBKR', + '585284', + 'B0YBKT') as $sedol) + echo $sedol, checksum($sedol), "\n"; diff --git a/Task/SEDOLs/PL-I/sedols.pli b/Task/SEDOLs/PL-I/sedols.pli new file mode 100644 index 0000000000..e45f435748 --- /dev/null +++ b/Task/SEDOLs/PL-I/sedols.pli @@ -0,0 +1,23 @@ +/* Compute SEDOLs; includes check for invalid characters. */ +sedol: procedure options (main); /* 3 March 2012 */ + declare alphabet character (36) static initial + ('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'); + declare weight (6) fixed static initial (1, 3, 1, 7, 3, 9); + declare s character (6); + declare (i, v, k) fixed; + + do while ('1'b); + get edit (s) (a(6)); + put skip edit (s) (a); + /* Check for invalid characters: */ + if verify(s, '0123456789BCDFGHJKLMNPQRSTVWXYZ') > 0 then stop; + v = 0; + do i = 1 to 6; + k = index(alphabet, substr(s, i, 1)) - 1; + v = v + weight(i) * k; + end; + k = mod(v, 10); + v = mod(10 - k, 10); + put edit (s, v) (x(2), a, f(1)); put edit (' ') (a); + end; +end sedol; diff --git a/Task/SEDOLs/Pascal/sedols.pascal b/Task/SEDOLs/Pascal/sedols.pascal new file mode 100644 index 0000000000..10bb7a01c6 --- /dev/null +++ b/Task/SEDOLs/Pascal/sedols.pascal @@ -0,0 +1,45 @@ +program Sedols(output); + +function index(c: char): integer; + const + alpha = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + var + i: integer; + begin + index := 0; + for i := low(alpha) to high(alpha) do + if c = alpha[i] then + index := i; + end; + +function checkdigit(c: string): char; + const + weight: array [1..6] of integer = (1, 3, 1, 7, 3, 9); + var + i, sum: integer; + begin + sum := 0; + for i := 1 to 6 do + sum := sum + (index(c[i]) - 1) * weight[i]; + checkdigit := char((10 - (sum mod 10)) mod 10 + 48); + end; + +const + codes: array [1..11] of string = + ('710889', 'B0YBKJ', '406566', 'B0YBLH', + '228276', 'B0YBKL', '557910', 'B0YBKR', + '585284', 'B0YBKT', 'B00030'); + +var + seforl: string; + i: integer; + +begin + for i := low(codes) to high(codes) do + begin + seforl := codes[i]; + setlength(seforl, 7); + seforl[7] := checkdigit(codes[i]); + writeln(codes[i], ' -> ', seforl); + end; +end. diff --git a/Task/SEDOLs/Perl-6/sedols.pl6 b/Task/SEDOLs/Perl-6/sedols.pl6 new file mode 100644 index 0000000000..e561063fc4 --- /dev/null +++ b/Task/SEDOLs/Perl-6/sedols.pl6 @@ -0,0 +1,26 @@ +sub sedol( Str $s ) { + die 'No vowels allowed' if $s ~~ /<[AEIOU]>/; + die 'Invalid format' if $s !~~ /^ <[0..9B..DF..HJ..NP..TV..Z]>**6 $ /; + + my %base36 = ( 0..9, 'A'..'Z' ) Z ( ^36 ); + my @weights = 1, 3, 1, 7, 3, 9; + + my @vs = %base36{ $s.comb }; + my $checksum = [+] @vs Z* @weights; + my $check_digit = (10 - $checksum % 10) % 10; + return $s ~ $check_digit; +} + +say sedol($_) for < + 710889 + B0YBKJ + 406566 + B0YBLH + 228276 + B0YBKL + 557910 + B0YBKR + 585284 + B0YBKT + B00030 +>; diff --git a/Task/SEDOLs/Perl/sedols.pl b/Task/SEDOLs/Perl/sedols.pl new file mode 100644 index 0000000000..dd1155f984 --- /dev/null +++ b/Task/SEDOLs/Perl/sedols.pl @@ -0,0 +1,26 @@ +use List::Util qw(sum); +use POSIX qw(strtol); + +sub zip(&\@\@) { + my $f = shift; + my @a = @{shift()}; + my @b = @{shift()}; + my @result; + push(@result, $f->(shift @a, shift @b)) while @a && @b; + return @result; +} + +my @weights = (1, 3, 1, 7, 3, 9); +sub sedol($) { + my $s = shift; + $s =~ /[AEIOU]/ and die "No vowels"; + my @vs = map {(strtol $_, 36)[0]} split //, $s; + my $checksum = sum (zip {$_[0] * $_[1]} @vs, @weights); + my $check_digit = (10 - $checksum % 10) % 10; + return $s . $check_digit; +} + +while (<>) { + chomp; + print sedol($_), "\n"; +} diff --git a/Task/SEDOLs/PicoLisp/sedols.l b/Task/SEDOLs/PicoLisp/sedols.l new file mode 100644 index 0000000000..b8ff96f1d8 --- /dev/null +++ b/Task/SEDOLs/PicoLisp/sedols.l @@ -0,0 +1,21 @@ +(de sedol (Str) + (pack Str + (char + (+ `(char "0") + (% + (- 10 + (% + (sum + '((W C) + (cond + ((>= "9" C "0") + (* W (format C)) ) + ((>= "Z" (setq C (uppc C)) "A") + (* W (+ 10 (- (char C) `(char "A")))) ) ) ) + (1 3 1 7 3 9) + (chop Str) ) + 10 ) ) + 10 ) ) ) ) ) + +(for S '("710889" "B0YBKJ" "406566" "B0YBLH" "228276" "B0YBKL" "557910" "B0YBKR" "585284" "B0YBKT" "B00030") + (prinl (sedol S)) ) diff --git a/Task/SEDOLs/PureBasic/sedols.purebasic b/Task/SEDOLs/PureBasic/sedols.purebasic new file mode 100644 index 0000000000..fb3a190eb2 --- /dev/null +++ b/Task/SEDOLs/PureBasic/sedols.purebasic @@ -0,0 +1,40 @@ +Procedure.s SEDOLs(rawstring$) + Protected i, j, sum, c, m + For i=1 To Len(rawstring$) + c=Asc(Mid(rawstring$,i,1)) + Select c + Case Asc("0") To Asc("9") + j=Val(Mid(rawstring$,i,1)) + Default + j=c-Asc("A") + EndSelect + Select i + Case 1, 3, 7: m=1 + Case 2, 5: m=3 + Case 4: m=7 + Default: m=9 + EndSelect + sum+j*m + Next + sum=(10-(sum%10))%10 + ProcedureReturn rawstring$+Str(sum) +EndProcedure + +Define result$, i +Restore Tests +For i=0 To 10 + Read.s SEDOL$ + result$+SEDOLs(SEDOL$) + If i%2 + result$+#CRLF$ + ElseIf i<10 + result$+", " + EndIf +Next +MessageRequester("SEDOLs","Result"+#CRLF$+result$) + +DataSection + Tests: + Data.s "710889","B0YBKJ","406566","B0YBLH","228276" + Data.s "B0YBKL","557910","B0YBKR","585284","B0YBKT","B00030" +EndDataSection diff --git a/Task/SEDOLs/Python/sedols.py b/Task/SEDOLs/Python/sedols.py new file mode 100644 index 0000000000..3e18ece7c3 --- /dev/null +++ b/Task/SEDOLs/Python/sedols.py @@ -0,0 +1,25 @@ +def char2value(c): + assert c not in 'AEIOU', "No vowels" + return int(c, 36) + +sedolweight = [1,3,1,7,3,9] + +def checksum(sedol): + tmp = sum(map(lambda ch, weight: char2value(ch) * weight, + sedol, sedolweight) + ) + return str((10 - (tmp % 10)) % 10) + +for sedol in ''' + 710889 + B0YBKJ + 406566 + B0YBLH + 228276 + B0YBKL + 557910 + B0YBKR + 585284 + B0YBKT + '''.split(): + print sedol + checksum(sedol) diff --git a/Task/SEDOLs/R/sedols.r b/Task/SEDOLs/R/sedols.r new file mode 100644 index 0000000000..0f51c294d0 --- /dev/null +++ b/Task/SEDOLs/R/sedols.r @@ -0,0 +1,37 @@ +# Read in data from text connection +datalines <- readLines(tc <- textConnection("710889 +B0YBKJ +406566 +B0YBLH +228276 +B0YBKL +557910 +B0YBKR +585284 +B0YBKT")); close(tc) + +# Check data valid +checkSedol <- function(datalines) +{ + ok <- grep("^[[:digit:][:upper:]]{6}$", datalines) + if(length(ok) < length(datalines)) + { + stop("there are invalid lines") + } +} +checkSedol(datalines) + +# Append check digit +appendCheckDigit <- function(x) +{ + if(length(x) > 1) return(sapply(x, appendCheckDigit)) + ascii <- as.integer(charToRaw(x)) + scores <- ifelse(ascii < 65, ascii - 48, ascii - 55) + weights <- c(1, 3, 1, 7, 3, 9) + chkdig <- (10 - sum(scores * weights) %% 10) %% 10 + paste(x, as.character(chkdig), sep="") +} +withchkdig <- appendCheckDigit(datalines) + +#Print in format requested +writeLines(withchkdig) diff --git a/Task/SEDOLs/REXX/sedols.rexx b/Task/SEDOLs/REXX/sedols.rexx new file mode 100644 index 0000000000..8fb8f10cb0 --- /dev/null +++ b/Task/SEDOLs/REXX/sedols.rexx @@ -0,0 +1,53 @@ +/*REXX program computes the check (last) digit for 6 or 7 char SEDOLs.*/ + /*if the SEDOL is 6 characters, */ + /*a check digit is added. */ + + /*if the SEDOL is 7 characters, a */ + /*check digit is created and it is*/ + /*verified that it's equal to the */ + /*check digit already on the SEDOL*/ +@.= +arg @.1 . /*allow a user-specified SEDOL. */ +if @.1=='' then do /*if none, then assume 11 defaults*/ + @.1 = 710889 + @.2 ='B0YBKJ' + @.3 = 406566 + @.4 ='B0YBLH' + @.5 = 228276 + @.6 ='B0YBKL' + @.7 = 557910 + @.8 ='B0YBKR' + @.9 = 585284 + @.10='B0YBKT' + @.11='B00030' + end + +@abcU='ABCDEFGHIJKLMNOPQRSTUVWXYZ' /*the uppercase Latin alphabet. */ +alphaDigs='0123456789'@abcU /*legal chars, and then some. */ +allowable=space(translate(alphaDigs,,'AEIOU'),0) /*remove the vowels.*/ +weights=1317391 /*various weights for SEDOL chars*/ + /*an alternative would be to use:*/ + /* weights='1 3 1 7 3 9 1' if */ + /*any weights were greater than 9*/ + do j=1 while @.j\==''; sedol=@.j /*process each specified SEDOL. */ + L=length(sedol) + if L<6 | L>7 then call ser "SEDOL isn't a valid length" + if left(sedol,1)==9 then call swa 'SEDOL is reserved for end user allocation' + _=verify(sedol,allowable) + if _\==0 then call ser 'illegal character in SEDOL:' substr(sedol,_,1) + sum=0 /*checkDigit sum (so far). */ + do k=1 for 6 /*process each character in SEDOL*/ + sum=sum+(pos(substr(sedol,k,1),alphaDigs)-1)*substr(weights,k,1) + end /*k*/ + + chkDig= (10-sum//10) // 10 + r=right(sedol,1) + if L==7 & chkDig\==r then call ser sedol,'invalid check digit:' r + say 'SEDOL:' left(sedol,9) 'SEDOL + check digit:' left(sedol,6)chkDig + end /*j*/ + +exit /*stick a fork in it, we're done.*/ +/*─────────────────────────────────────subroutines──────────────────────*/ +sed: say; say 'SEDOL:' sedol; say; return +ser: say; say '*** error! ***'; say; say arg(1); call sed; exit 13 +swa: say; say '*** warning! ***' arg(1); say; return diff --git a/Task/SEDOLs/Racket/sedols.rkt b/Task/SEDOLs/Racket/sedols.rkt new file mode 100644 index 0000000000..0df209e1a0 --- /dev/null +++ b/Task/SEDOLs/Racket/sedols.rkt @@ -0,0 +1,63 @@ +#lang racket +;;; Since the Task gives us unchecksummed and checksummed SEDOLs, and +;;; we'll just take a list of the output SEDOLs and remove their last +;;; characters for the input +(define output-SEDOLS + (list "7108899" "B0YBKJ7" "4065663" + "B0YBLH2" "2282765" "B0YBKL9" + "5579107" "B0YBKR5" "5852842" + "B0YBKT7" "B000300")) +(define (output->input-SEDOL S) (substring S 0 6)) +(define input-SEDOLS (map output->input-SEDOL output-SEDOLS)) + +;;; checksum calculation +(define (SEDOL-character-value c) + (if (char-numeric? c) + (- (char->integer c) (char->integer #\0)) + (+ 10 (- (char->integer c) (char->integer #\A))))) +(define (SEDOL-character-sum S) + (for/sum ((c S) ; if we run out of c's before the final 1 in weight, we'll have the unchecksummed weighted sum + (weight (in-list '(1 3 1 7 3 9 1)))) + (* weight (SEDOL-character-value c)))) +(define (SEDOL-checksum S) (number->string (modulo (- 10 (SEDOL-character-sum S)) 10))) + +;;; build output from input +(define (SEDOL-append-checksum S) (string-append S (SEDOL-checksum S))) + +;;; Extra credit -- according to wikipedia: +;;; "SEDOLs are seven characters in length" +;;; "vowels are never used" +;;; there seems to be no statement as to case, but we'll assert that too! +;;; +;;; valid-SEDOL? is a predicate... it doesn't report a reason +(define (invalid-SEDOL? S) + (define (invalid-SEDOL-character? c) + (if + (and (not (char-upper-case? c)) (not (char-numeric? c))) + (format "contains non upper case/non numeric ~a" c) + (case c [(#\A #\E #\I #\O #\U) (format "contains vowel ~a" c)] [else #f]))) + (cond + [(< (string-length S) 7) "too few characters"] + [(> (string-length S) 7) "too many characters"] + [(not (zero? (modulo (SEDOL-character-sum S) 10))) "invalid checksum"] + [(for/first ((c S) #:when (invalid-SEDOL-character? c)) c) => identity] + [else #f])) ; a.k.a. valid! + +(module+ main + (for* ((S input-SEDOLS)) + (displayln (SEDOL-append-checksum S))) + (newline) + (displayln "Extra Credit!") + (displayln (invalid-SEDOL? "B0YBKT7")) ; expect #f output + (displayln (invalid-SEDOL? "B000301")) ; expect "invalid checksum" output + ) + +(module+ test + (require rackunit) + (check-= (SEDOL-character-value #\3) 3 0) + (check-= (SEDOL-character-value #\B) 11 0) + (check-equal? (invalid-SEDOL? "B000301") "invalid checksum") + (for ((S output-SEDOLS)) + (check-false (invalid-SEDOL? S)) + (check-equal? (SEDOL-append-checksum (substring S 0 6)) + S (format "test SEDOL for ~a" S)))) diff --git a/Task/SEDOLs/Ruby/sedols.rb b/Task/SEDOLs/Ruby/sedols.rb new file mode 100644 index 0000000000..ba96d21fb1 --- /dev/null +++ b/Task/SEDOLs/Ruby/sedols.rb @@ -0,0 +1,28 @@ +def char2value(c) + raise "No vowels" if 'AEIOU'.include?(c) + c.to_i(36) +end + +Sedolweight = [1,3,1,7,3,9] + +def checksum(sedol) + tmp = sedol.split('').zip(Sedolweight).map { |ch, weight| + char2value(ch) * weight }.inject(0) { |sum, x| + sum + x } + ((10 - (tmp % 10)) % 10).to_s +end + +for sedol in %w{ + 710889 + B0YBKJ + 406566 + B0YBLH + 228276 + B0YBKL + 557910 + B0YBKR + 585284 + B0YBKT + } + puts sedol + checksum(sedol) +end diff --git a/Task/SEDOLs/Scala/sedols.scala b/Task/SEDOLs/Scala/sedols.scala new file mode 100644 index 0000000000..1883eb8a98 --- /dev/null +++ b/Task/SEDOLs/Scala/sedols.scala @@ -0,0 +1,7 @@ +class SEDOL(s: String) { + require(s.size == 6 || s.size == 7, "SEDOL length must be 6 or 7 characters") + require(s.size == 6 || s(6).asDigit == chksum, "Incorrect SEDOL checksum") + require(s forall (c => !("aeiou" contains c.toLower)), "Vowels not allowed in SEDOL") + def chksum = 10 - ((s zip List(1, 3, 1, 7, 3, 9) map { case (c, w) => c.asDigit * w } sum) % 10) + override def toString = s.take(6) + chksum +} diff --git a/Task/SEDOLs/Seed7/sedols.seed7 b/Task/SEDOLs/Seed7/sedols.seed7 new file mode 100644 index 0000000000..52494f5c95 --- /dev/null +++ b/Task/SEDOLs/Seed7/sedols.seed7 @@ -0,0 +1,35 @@ +$ include "seed7_05.s7i"; + +const func char: sedolCheckDigit (in string: sedol) is func + result + var char: checkDigit is ' '; + local + const array integer: weight is [] (1, 3, 1, 7, 3, 9); + var char: ch is ' '; + var integer: index is 0; + var integer: item is 0; + var integer: sum is 0; + begin + for ch key index range sedol do + case ch of + when {'0' .. '9'}: + item := ord(ch) - ord('0'); + when {'A' .. 'Z'} - {'A', 'E', 'I', 'O', 'U'}: + item := ord(ch) - ord('A') + 10; + otherwise: + raise RANGE_ERROR; + end case; + sum +:= item * weight[index]; + end for; + checkDigit := chr(-sum mod 10 + ord('0')); + end func; + +const proc: main is func + local + var string: sedol is ""; + begin + for sedol range [] ("710889", "B0YBKJ", "406566", "B0YBLH", "228276", "B0YBKL", + "557910", "B0YBKR", "585284", "B0YBKT", "B00030") do + writeln(sedol <& sedolCheckDigit(sedol)); + end for; + end func; diff --git a/Task/SEDOLs/Smalltalk/sedols-1.st b/Task/SEDOLs/Smalltalk/sedols-1.st new file mode 100644 index 0000000000..adcc4ab2a0 --- /dev/null +++ b/Task/SEDOLs/Smalltalk/sedols-1.st @@ -0,0 +1,6 @@ +String extend [ + includesAnyOf: aSet [ + aSet do: [ :e | (self includes: e) ifTrue: [ ^true ] ]. + ^false + ] +]. diff --git a/Task/SEDOLs/Smalltalk/sedols-2.st b/Task/SEDOLs/Smalltalk/sedols-2.st new file mode 100644 index 0000000000..2a9eda397b --- /dev/null +++ b/Task/SEDOLs/Smalltalk/sedols-2.st @@ -0,0 +1,43 @@ +Object subclass: SEDOL [ + |weight charList| + + initialize [ + weight := Array from: { 1. 3. 1. 7. 3. 9 }. + charList := + ('ABCDEFGHIJKLMNOPQRSTUVWXYZ' asOrderedCollection) + collect: [ :c | ('AEIOU' includes: c) ifTrue: [ nil ] ifFalse: [ c ] ]. + ] + + SEDOL class >> new [ + ^ (self basicNew) initialize + ] + + "to be considered private" + blindCheckDigit: aSEDOL [ |sum| + sum := 0. + aSEDOL keysAndValuesDo: [ :i :c | + ('0123456789' includes: c) + ifTrue: [ sum := sum + + ((weight at: i) * + (Number readFrom: (c asString readStream))). + ] + ifFalse: [ sum := sum + (((charList indexOf: c) + 9) * + (weight at: i)) + ] + ]. + ^ ((10 - (sum rem: 10)) rem: 10) displayString + ] + + checked: aSEDOL [ + (aSEDOL size < 6) | + (aSEDOL size > 7) | + (aSEDOL asUppercase includesAnyOf: 'AEIOU' asSet ) + ifTrue: [ SystemExceptions.InvalidArgument + signalOn: aSEDOL + reason: 'Not a valid SEDOL' + ] + ifFalse: [ |t| t := aSEDOL copyFrom: 1 to: 6. + ^ t , (self blindCheckDigit: t) + ] + ] +]. diff --git a/Task/SEDOLs/Smalltalk/sedols-3.st b/Task/SEDOLs/Smalltalk/sedols-3.st new file mode 100644 index 0000000000..49965d5b72 --- /dev/null +++ b/Task/SEDOLs/Smalltalk/sedols-3.st @@ -0,0 +1,12 @@ +|sedol| +sedol := SEDOL new. +{ '710889'. + 'B0YBKJ'. + '406566'. + 'B0YBLH'. + '228276'. + 'B0YBKL'. + '557910'. + 'B0YBKR'. + '585284'. + 'B0YBKT' } do: [ :c | (sedol checked: c) displayNl ] diff --git a/Task/SEDOLs/Standard-ML/sedols.ml b/Task/SEDOLs/Standard-ML/sedols.ml new file mode 100644 index 0000000000..5a3a0e38f1 --- /dev/null +++ b/Task/SEDOLs/Standard-ML/sedols.ml @@ -0,0 +1,26 @@ +fun char2value c = + if List.exists (fn x => x = c) (explode "AEIOU") then raise Fail "no vowels" + else if Char.isDigit c then ord c - ord #"0" + else if Char.isUpper c then ord c - ord #"A" + 10 + else raise Match + +val sedolweight = [1,3,1,7,3,9] + +fun checksum sedol = let + val tmp = ListPair.foldlEq (fn (ch, weight, sum) => sum + char2value ch * weight) + 0 (explode sedol, sedolweight) +in + Int.toString ((10 - (tmp mod 10)) mod 10) +end + +app (fn sedol => print (sedol ^ checksum sedol ^ "\n")) + [ "710889", + "B0YBKJ", + "406566", + "B0YBLH", + "228276", + "B0YBKL", + "557910", + "B0YBKR", + "585284", + "B0YBKT" ]; diff --git a/Task/SEDOLs/TUSCRIPT/sedols.tuscript b/Task/SEDOLs/TUSCRIPT/sedols.tuscript new file mode 100644 index 0000000000..6c8e27eda8 --- /dev/null +++ b/Task/SEDOLs/TUSCRIPT/sedols.tuscript @@ -0,0 +1,20 @@ +$$ MODE TUSCRIPT +check="1'3'1'7'3'9" +values="123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" +value=STRINGS (values,":<%:") +BUILD r_TABLE/or illegal=":A:E:I:O:U:" +LOOP input="710889'B0YBKJ'406566'B0YBLH'228276'B0YBKL'557910'B0YBKR'585284'B0YBKT'BOYAKT'B00030",sum="" + IF (input.ma.illegal) THEN + PRINT/ERROR input, " illegal" + CYCLE + ENDIF + strings=STRINGS (input,":<%:") + LOOP d,nr=strings + c=SELECT (check,#d) + IF (nr!='digits') nr=FILTER_INDEX (value,":{nr}:",-) + x=nr*c, sum=APPEND(sum,x) + ENDLOOP + endsum=SUM(sum), checksum=10-(endsum%10) + IF (checksum==10) checksum=0 + PRINT input, " checkdigit: ", checksum +ENDLOOP diff --git a/Task/SEDOLs/Tcl/sedols.tcl b/Task/SEDOLs/Tcl/sedols.tcl new file mode 100644 index 0000000000..484165ddba --- /dev/null +++ b/Task/SEDOLs/Tcl/sedols.tcl @@ -0,0 +1,38 @@ +namespace eval sedol { + variable chars {0 1 2 3 4 5 6 7 8 9 "" B C D "" F G H "" J K L M N "" P Q R S T "" V W X Y Z} + variable weight {1 3 1 7 3 9 1} + + proc checksum {alnum6} { + variable chars + variable weight + set sum 0 + set col 0 + foreach char [split [string toupper [string range $alnum6 0 5]] ""] { + if {[set idx [lsearch -exact $chars $char]] == -1} { + error "invalid character: $char" + } + incr sum [expr {$idx * [lindex $weight $col]}] + incr col + } + return [expr {(10 - ($sum % 10)) % 10}] + } + + proc valid {alnum7} { + expr {[checksum [string range $alnum7 0 5]] == [string index $alnum7 6]} + } +} + +proc assert {condition {message "Assertion failed!"}} { + if { ! [uplevel 1 [list expr $condition]]} { + return -code error $message + } +} + +set codes {710889 B0YBKJ 406566 B0YBLH 228276 B0YBKL 557910 B0YBKR 585284 B0YBKT} +set answers {7108899 B0YBKJ7 4065663 B0YBLH2 2282765 B0YBKL9 5579107 B0YBKR5 5852842 B0YBKT7} + +foreach code $codes answer $answers { + set sedol "${code}[sedol::checksum $code]" + assert {$sedol eq $answer} "assertion failed: $sedol ne $answer" + puts $sedol +} diff --git a/Task/SEDOLs/Ursala/sedols-1.ursala b/Task/SEDOLs/Ursala/sedols-1.ursala new file mode 100644 index 0000000000..9e1185a904 --- /dev/null +++ b/Task/SEDOLs/Ursala/sedols-1.ursala @@ -0,0 +1,8 @@ +#import std +#import nat + +alphabet = digits-- ~=`A-~r letters +weights = <1,3,1,7,3,9> +charval = -:@rlXS num alphabet +iprod = sum:-0+ product*p/weights+ charval* +checksum = difference/10+ remainder\10+ iprod diff --git a/Task/SEDOLs/Ursala/sedols-2.ursala b/Task/SEDOLs/Ursala/sedols-2.ursala new file mode 100644 index 0000000000..8401c32cec --- /dev/null +++ b/Task/SEDOLs/Ursala/sedols-2.ursala @@ -0,0 +1,2 @@ +weights = difference/*10 <1,3,1,7,3,9> +checksum = remainder\10+ iprod diff --git a/Task/SEDOLs/Ursala/sedols-3.ursala b/Task/SEDOLs/Ursala/sedols-3.ursala new file mode 100644 index 0000000000..7b71b009fa --- /dev/null +++ b/Task/SEDOLs/Ursala/sedols-3.ursala @@ -0,0 +1,2 @@ +lookup = -: (^/~& product^|/~& charval)*lsPrK0/weights alphabet +iprod = sum:-0+ lookup*p/weights diff --git a/Task/SEDOLs/Ursala/sedols-4.ursala b/Task/SEDOLs/Ursala/sedols-4.ursala new file mode 100644 index 0000000000..b8c0cbbc9c --- /dev/null +++ b/Task/SEDOLs/Ursala/sedols-4.ursala @@ -0,0 +1,2 @@ +lookups = (-:+ * ^/~&l product^|/charval ~&)* *-* -*weights alphabet +iprod = sum:-0+ gang +^|(~&,~)*lNrXXK9 ^(~&,&h!)* lookups diff --git a/Task/SEDOLs/Ursala/sedols-5.ursala b/Task/SEDOLs/Ursala/sedols-5.ursala new file mode 100644 index 0000000000..c9fabb5972 --- /dev/null +++ b/Task/SEDOLs/Ursala/sedols-5.ursala @@ -0,0 +1,15 @@ +#show+ + +examples = ^T(~&,~&h+ %nP+ checksum)*t + +-[ +710889 +B0YBKJ +406566 +B0YBLH +228276 +B0YBKL +557910 +B0YBKR +585284 +B0YBKT]- diff --git a/Task/Safe-addition/0DESCRIPTION b/Task/Safe-addition/0DESCRIPTION new file mode 100644 index 0000000000..e8e0d9c2c3 --- /dev/null +++ b/Task/Safe-addition/0DESCRIPTION @@ -0,0 +1,8 @@ +Implementation of [[wp:Interval_arithmetic|interval arithmetic]] and more generally fuzzy number arithmetic require operations that yield safe upper and lower bounds of the exact result. For example, for an addition, it is the operations *↑ and *↓ defined as: ''a'' +↓ ''b'' ≤ ''a'' + ''b'' ≤ ''a'' +↑ ''b''. Additionally it is desired that the width of the interval (''a'' +↑ ''b'') - (''a'' +↓ ''b'') would be about the machine epsilon after removing the exponent part. + +Differently to the standard floating-point arithmetic, safe interval arithmetic is '''accurate''' (but still imprecise). I.e. the result of each defined operation contains (though does not identify) the exact mathematical outcome. + +Usually a [[wp:Floating_Point_Unit|FPU's]] have machine +,-,*,/ operations accurate within the machine precision. To illustrate it, let us consider a machine with decimal floating-point arithmetic that has the precision is 3 decimal points. If the result of the machine addition is 1.23, then the exact mathematical result is within the interval ]1.22, 1.24[. When the machine rounds towards zero, then the exact result is within [1.23,1.24[. This is the basis for an implementation of safe addition. + +===Task=== +Show how +↓ and +↑ can be implemented in your language using the standard floating-point type. Define an interval type based on the standard floating-point one, and implement an interval-valued addition of two floating-point numbers considering them exact, in short an operation that yields the interval [''a'' +↓ ''b'', ''a'' +↑ ''b'']. diff --git a/Task/Safe-addition/1META.yaml b/Task/Safe-addition/1META.yaml new file mode 100644 index 0000000000..8644b2ad9b --- /dev/null +++ b/Task/Safe-addition/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Arithmetic operations diff --git a/Task/Safe-addition/Ada/safe-addition-1.ada b/Task/Safe-addition/Ada/safe-addition-1.ada new file mode 100644 index 0000000000..f702aac934 --- /dev/null +++ b/Task/Safe-addition/Ada/safe-addition-1.ada @@ -0,0 +1,4 @@ +type Interval is record + Lower : Float; + Upper : Float; +end record; diff --git a/Task/Safe-addition/Ada/safe-addition-2.ada b/Task/Safe-addition/Ada/safe-addition-2.ada new file mode 100644 index 0000000000..15a14a46e4 --- /dev/null +++ b/Task/Safe-addition/Ada/safe-addition-2.ada @@ -0,0 +1,19 @@ +function "+" (A, B : Float) return Interval is + Result : constant Float := A + B; +begin + if Result < 0.0 then + if Float'Machine_Rounds then + return (Float'Adjacent (Result, Float'First), Float'Adjacent (Result, 0.0)); + else + return (Float'Adjacent (Result, Float'First), Result); + end if; + elsif Result > 0.0 then + if Float'Machine_Rounds then + return (Float'Adjacent (Result, 0.0), Float'Adjacent (Result, Float'Last)); + else + return (Result, Float'Adjacent (Result, Float'Last)); + end if; + else -- Underflow + return (Float'Adjacent (0.0, Float'First), Float'Adjacent (0.0, Float'Last)); + end if; +end "+"; diff --git a/Task/Safe-addition/Ada/safe-addition-3.ada b/Task/Safe-addition/Ada/safe-addition-3.ada new file mode 100644 index 0000000000..c2dff556ef --- /dev/null +++ b/Task/Safe-addition/Ada/safe-addition-3.ada @@ -0,0 +1,10 @@ +with Ada.Text_IO; use Ada.Text_IO; +procedure Test_Interval_Addition is + -- Definitions from above + procedure Put (I : Interval) is + begin + Put (Long_Float'Image (Long_Float (I.Lower)) & "," & Long_Float'Image (Long_Float (I.Upper))); + end Put; +begin + Put (1.14 + 2000.0); +end Test_Interval_Addition; diff --git a/Task/Safe-addition/C/safe-addition-1.c b/Task/Safe-addition/C/safe-addition-1.c new file mode 100644 index 0000000000..202d72c344 --- /dev/null +++ b/Task/Safe-addition/C/safe-addition-1.c @@ -0,0 +1,50 @@ +#include /* fegetround(), fesetround() */ +#include /* printf() */ + +/* + * Calculates an interval for a + b. + * interval[0] <= a + b + * a + b <= interval[1] + */ +void +safe_add(volatile double interval[2], volatile double a, volatile double b) +{ +#pragma STDC FENV_ACCESS ON + unsigned int orig; + + orig = fegetround(); + fesetround(FE_DOWNWARD); /* round to -infinity */ + interval[0] = a + b; + fesetround(FE_UPWARD); /* round to +infinity */ + interval[1] = a + b; + fesetround(orig); +} + +int +main() +{ + const double nums[][2] = { + {1, 2}, + {0.1, 0.2}, + {1e100, 1e-100}, + {1e308, 1e308}, + }; + double ival[2]; + int i; + + for (i = 0; i < sizeof(nums) / sizeof(nums[0]); i++) { + /* + * Calculate nums[i][0] + nums[i][1]. + */ + safe_add(ival, nums[i][0], nums[i][1]); + + /* + * Print the result. %.17g gives the best output. + * %.16g or plain %g gives not enough digits. + */ + printf("%.17g + %.17g =\n", nums[i][0], nums[i][1]); + printf(" [%.17g, %.17g]\n", ival[0], ival[1]); + printf(" size %.17g\n\n", ival[1] - ival[0]); + } + return 0; +} diff --git a/Task/Safe-addition/C/safe-addition-2.c b/Task/Safe-addition/C/safe-addition-2.c new file mode 100644 index 0000000000..35bad10e27 --- /dev/null +++ b/Task/Safe-addition/C/safe-addition-2.c @@ -0,0 +1,49 @@ +#include /* _controlfp() */ +#include /* printf() */ + +/* + * Calculates an interval for a + b. + * interval[0] <= a + b + * a + b <= interval[1] + */ +void +safe_add(volatile double interval[2], volatile double a, volatile double b) +{ + unsigned int orig; + + orig = _controlfp(0, 0); + _controlfp(_RC_DOWN, _MCW_RC); /* round to -infinity */ + interval[0] = a + b; + _controlfp(_RC_UP, _MCW_RC); /* round to +infinity */ + interval[1] = a + b; + _controlfp(orig, _MCW_RC); +} + +int +main() +{ + const double nums[][2] = { + {1, 2}, + {0.1, 0.2}, + {1e100, 1e-100}, + {1e308, 1e308}, + }; + double ival[2]; + int i; + + for (i = 0; i < sizeof(nums) / sizeof(nums[0]); i++) { + /* + * Calculate nums[i][0] + nums[i][1]. + */ + safe_add(ival, nums[i][0], nums[i][1]); + + /* + * Print the result. %.17g gives the best output. + * %.16g or plain %g gives not enough digits. + */ + printf("%.17g + %.17g =\n", nums[i][0], nums[i][1]); + printf(" [%.17g, %.17g]\n", ival[0], ival[1]); + printf(" size %.17g\n\n", ival[1] - ival[0]); + } + return 0; +} diff --git a/Task/Safe-addition/C/safe-addition-3.c b/Task/Safe-addition/C/safe-addition-3.c new file mode 100644 index 0000000000..fc2d05414e --- /dev/null +++ b/Task/Safe-addition/C/safe-addition-3.c @@ -0,0 +1,49 @@ +#include /* fpsetround() */ +#include /* printf() */ + +/* + * Calculates an interval for a + b. + * interval[0] <= a + b + * a + b <= interval[1] + */ +void +safe_add(volatile double interval[2], volatile double a, volatile double b) +{ + fp_rnd orig; + + orig = fpsetround(FP_RM); /* round to -infinity */ + interval[0] = a + b; + fpsetround(FP_RP); /* round to +infinity */ + interval[1] = a + b; + fpsetround(orig); +} + +int +main() +{ + const double nums[][2] = { + {1, 2}, + {0.1, 0.2}, + {1e100, 1e-100}, + {1e308, 1e308}, + }; + double ival[2]; + int i; + + for (i = 0; i < sizeof(nums) / sizeof(nums[0]); i++) { + /* + * Calculate nums[i][0] + nums[i][1]. + */ + safe_add(ival, nums[i][0], nums[i][1]); + + /* + * Print the result. With OpenBSD libc, %.17g gives + * the best output; %.16g or plain %g gives not enough + * digits. + */ + printf("%.17g + %.17g =\n", nums[i][0], nums[i][1]); + printf(" [%.17g, %.17g]\n", ival[0], ival[1]); + printf(" size %.17g\n\n", ival[1] - ival[0]); + } + return 0; +} diff --git a/Task/Safe-addition/E/safe-addition-1.e b/Task/Safe-addition/E/safe-addition-1.e new file mode 100644 index 0000000000..a2ded51da5 --- /dev/null +++ b/Task/Safe-addition/E/safe-addition-1.e @@ -0,0 +1,17 @@ +def makeInterval(a :float64, b :float64) { + require(a <= b) + def interval { + to least() { return a } + to greatest() { return b } + to __printOn(out) { + out.print("[", a, ", ", b, "]") + } + to add(other) { + require(a <=> b) + require(other.least() <=> other.greatest()) + def result := a + other.least() + return makeInterval(result.previous(), result.next()) + } + } + return interval +} diff --git a/Task/Safe-addition/E/safe-addition-2.e b/Task/Safe-addition/E/safe-addition-2.e new file mode 100644 index 0000000000..2ad4dc8a76 --- /dev/null +++ b/Task/Safe-addition/E/safe-addition-2.e @@ -0,0 +1,2 @@ +? makeInterval(1.14, 1.14) + makeInterval(2000.0, 2000.0) +# value: [2001.1399999999999, 2001.1400000000003] diff --git a/Task/Safe-addition/Go/safe-addition.go b/Task/Safe-addition/Go/safe-addition.go new file mode 100644 index 0000000000..029d952482 --- /dev/null +++ b/Task/Safe-addition/Go/safe-addition.go @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" + "math" +) + +// type requested by task +type interval struct { + lower, upper float64 +} + +// a constructor +func stepAway(x float64) interval { + return interval { + math.Nextafter(x, math.Inf(-1)), + math.Nextafter(x, math.Inf(1))} +} + +// function requested by task +func safeAdd(a, b float64) interval { + return stepAway(a + b) + +} + +// example +func main() { + a, b := 1.2, .03 + fmt.Println(a, b, safeAdd(a, b)) +} diff --git a/Task/Safe-addition/J/safe-addition.j b/Task/Safe-addition/J/safe-addition.j new file mode 100644 index 0000000000..c608c9b308 --- /dev/null +++ b/Task/Safe-addition/J/safe-addition.j @@ -0,0 +1,4 @@ + err =. 2^ 53-~ 2 <.@^. | NB. get the size of one-half unit in the last place + safeadd =. + (-,+) +&err + 0j15": 1.14 safeadd 2000.0 NB. print with 15 digits after the decimal +2001.139999999999873 2001.140000000000327 diff --git a/Task/Safe-addition/Python/safe-addition.py b/Task/Safe-addition/Python/safe-addition.py new file mode 100644 index 0000000000..272749b111 --- /dev/null +++ b/Task/Safe-addition/Python/safe-addition.py @@ -0,0 +1,5 @@ +>>> sum([.1, .1, .1, .1, .1, .1, .1, .1, .1, .1]) +0.9999999999999999 +>>> from math import fsum +>>> fsum([.1, .1, .1, .1, .1, .1, .1, .1, .1, .1]) +1.0 diff --git a/Task/Safe-addition/REXX/safe-addition.rexx b/Task/Safe-addition/REXX/safe-addition.rexx new file mode 100644 index 0000000000..869b593684 --- /dev/null +++ b/Task/Safe-addition/REXX/safe-addition.rexx @@ -0,0 +1,5 @@ +numeric digits 1000 /*defines precision to be 1000 digits. */ + +y=digits() /*sets Y to existing number of digits.*/ + +numeric digits digits()+digits()%10 /*increase digits by 10%.*/ diff --git a/Task/Safe-addition/Ruby/safe-addition.rb b/Task/Safe-addition/Ruby/safe-addition.rb new file mode 100644 index 0000000000..8c20771ef7 --- /dev/null +++ b/Task/Safe-addition/Ruby/safe-addition.rb @@ -0,0 +1,23 @@ +require 'bigdecimal' +require 'bigdecimal/util' # String#to_d + +def safe_add(a, b, prec) + a, b = a.to_d, b.to_d + rm = BigDecimal::ROUND_MODE + orig = BigDecimal.mode(rm) + + BigDecimal.mode(rm, BigDecimal::ROUND_FLOOR) + low = a.add(b, prec) + + BigDecimal.mode(rm, BigDecimal::ROUND_CEILING) + high = a.add(b, prec) + + BigDecimal.mode(rm, orig) + low..high +end + +[["1", "2"], + ["0.1", "0.2"], + ["0.1", "0.00002"], + ["0.1", "-0.00002"], +].each { |a, b| puts "#{a} + #{b} = #{safe_add(a, b, 3)}" } diff --git a/Task/Safe-addition/Tcl/safe-addition-1.tcl b/Task/Safe-addition/Tcl/safe-addition-1.tcl new file mode 100644 index 0000000000..f4363d93db --- /dev/null +++ b/Task/Safe-addition/Tcl/safe-addition-1.tcl @@ -0,0 +1,12 @@ +package require critcl +package provide stepaway 1.0 +critcl::ccode { + #include + #include +} +critcl::cproc stepup {double value} double { + return nextafter(value, DBL_MAX); +} +critcl::cproc stepdown {double value} double { + return nextafter(value, -DBL_MAX); +} diff --git a/Task/Safe-addition/Tcl/safe-addition-2.tcl b/Task/Safe-addition/Tcl/safe-addition-2.tcl new file mode 100644 index 0000000000..02e1ffc20a --- /dev/null +++ b/Task/Safe-addition/Tcl/safe-addition-2.tcl @@ -0,0 +1,5 @@ +package require stepaway +proc safe+ {a b} { + set val [expr {double($a) + $b}] + return [list [stepdown $val] [stepup $val]] +} diff --git a/Task/Same-Fringe/0DESCRIPTION b/Task/Same-Fringe/0DESCRIPTION new file mode 100644 index 0000000000..c71cdc988b --- /dev/null +++ b/Task/Same-Fringe/0DESCRIPTION @@ -0,0 +1,5 @@ +Write a routine that will compare the leaves ("fringe") of two binary trees to determine whether they are the same list of leaves when visited left-to-right. The structure or balance of the trees does not matter; only the number, order, and value of the leaves is important. + +Any solution is allowed here, but many computer scientists will consider it inelegant to collect either fringe in its entirety before starting to collect the other one. In fact, this problem is usually proposed in various forums as a way to show off various forms of concurrency (tree-rotation algorithms have also been used to get around the need to collect one tree first). Thinking of it a slightly different way, an elegant solution is one that can perform the minimum amount of work to falsify the equivalence of the fringes when they differ somewhere in the middle, short-circuiting the unnecessary additional traversals and comparisons. + +Any representation of a binary tree is allowed, as long as the nodes are orderable, and only downward links are used (for example, you may not use parent or sibling pointers to avoid recursion). diff --git a/Task/Same-Fringe/Ada/same-fringe-1.ada b/Task/Same-Fringe/Ada/same-fringe-1.ada new file mode 100644 index 0000000000..ee7c6470b4 --- /dev/null +++ b/Task/Same-Fringe/Ada/same-fringe-1.ada @@ -0,0 +1,26 @@ +generic + type Data is private; +package Bin_Trees is + + type Tree_Type is private; + + function Empty(Tree: Tree_Type) return Boolean; + function Left (Tree: Tree_Type) return Tree_Type; + function Right(Tree: Tree_Type) return Tree_Type; + function Item (Tree: Tree_Type) return Data; + function Empty return Tree_Type; + + procedure Destroy_Tree(N: in out Tree_Type); + function Tree(Value: Data) return Tree_Type; + function Tree(Value: Data; Left, Right : Tree_Type) return Tree_Type; + +private + + type Node; + type Tree_Type is access Node; + type Node is record + Left, Right: Tree_Type := null; + Item: Data; + end record; + +end Bin_Trees; diff --git a/Task/Same-Fringe/Ada/same-fringe-2.ada b/Task/Same-Fringe/Ada/same-fringe-2.ada new file mode 100644 index 0000000000..4ecb4a808c --- /dev/null +++ b/Task/Same-Fringe/Ada/same-fringe-2.ada @@ -0,0 +1,52 @@ +with Ada.Unchecked_Deallocation; + +package body Bin_Trees is + + function Empty(Tree: Tree_Type) return Boolean is + begin + return Tree = null; + end Empty; + + function Empty return Tree_Type is + begin + return null; + end Empty; + + function Left (Tree: Tree_Type) return Tree_Type is + begin + return Tree.Left; + end Left; + + function Right(Tree: Tree_Type) return Tree_Type is + begin + return Tree.Right; + end Right; + + function Item (Tree: Tree_Type) return Data is + begin + return Tree.Item; + end Item; + + procedure Destroy_Tree(N: in out Tree_Type) is + procedure free is new Ada.Unchecked_Deallocation(Node, Tree_Type); + begin + if not Empty(N) then + Destroy_Tree(N.Left); + Destroy_Tree(N.Right); + Free(N); + end if; + end Destroy_Tree; + + function Tree(Value: Data; Left, Right : Tree_Type) return Tree_Type is + Temp : Tree_Type := new Node; + begin + Temp.all := (Left, Right, Value); + return Temp; + end Tree; + + function Tree(Value: Data) return Tree_Type is + begin + return Tree(Value, null, null); + end Tree; + +end Bin_Trees; diff --git a/Task/Same-Fringe/Ada/same-fringe-3.ada b/Task/Same-Fringe/Ada/same-fringe-3.ada new file mode 100644 index 0000000000..1d280f8d41 --- /dev/null +++ b/Task/Same-Fringe/Ada/same-fringe-3.ada @@ -0,0 +1,11 @@ + generic + with procedure Process_Data(Item: Data); + with function Stop return Boolean; + with procedure Finish; + package Bin_Trees.Traverse is + task Inorder_Task is + entry Run(Tree: Tree_Type); + -- this will call each Item in Tree and, at the very end, it will call Finish + -- except when Stop becomes true; in this case, the task terminates + end Inorder_Task; + end Bin_Trees.Traverse; diff --git a/Task/Same-Fringe/Ada/same-fringe-4.ada b/Task/Same-Fringe/Ada/same-fringe-4.ada new file mode 100644 index 0000000000..fd2d86bb89 --- /dev/null +++ b/Task/Same-Fringe/Ada/same-fringe-4.ada @@ -0,0 +1,23 @@ + package body Bin_Trees.Traverse is + task body Inorder_Task is + procedure Inorder(Tree: Tree_Type) is + begin + if not Empty(Tree) and not Stop then + Inorder(Tree.Left); + if not Stop then + Process_Data(Item => Tree.Item); + end if; + if (not Stop) then + Inorder(Tree.Right); + end if; + end if; + end Inorder; + T: Tree_Type; + begin + accept Run(Tree: Tree_Type) do + T := Tree; + end Run; + Inorder(T); + Finish; + end Inorder_Task; + end Bin_Trees.Traverse; diff --git a/Task/Same-Fringe/Ada/same-fringe-5.ada b/Task/Same-Fringe/Ada/same-fringe-5.ada new file mode 100644 index 0000000000..a5d5f3b644 --- /dev/null +++ b/Task/Same-Fringe/Ada/same-fringe-5.ada @@ -0,0 +1,162 @@ +with Ada.Text_IO, Bin_Trees.Traverse; + +procedure Main is + + package B_Trees is new Bin_Trees(Character); use B_Trees; + + function Same_Fringe(T1, T2: Tree_Type) return Boolean is + + protected type Buffer_Type is + entry Write(Item: Character); + entry Write_Done; + entry Read_And_Compare(Item: Character); + entry Read_Done; + entry Wait_For_The_End; + function Early_Abort return Boolean; + function The_Same return Boolean; + private + Current: Character; + Readable: Boolean := False; + Done: Boolean := False; + Same: Boolean := True; + Finished: Boolean := False; + end Buffer_Type; + + protected body Buffer_Type is + + entry Write(Item: Character) when not Readable is + begin + Readable := True; + Current := Item; + end Write; + + entry Write_Done when not Readable is + begin + Readable := True; + Done := True; + end Write_Done; + + entry Read_And_Compare(Item: Character) when Readable is + begin + if Done then -- Producer is already out of items + Same := False; + Finished := True; + -- Readable remains True, else Consumer might lock itself out + elsif + Item /= Current then + Same := False; + Finished := True; + Readable := False; + else + Readable := False; + end if; + end Read_And_Compare; + + entry Read_Done when Readable is + begin + Readable := False; + Same := Same and Done; + Finished := True; + end Read_Done; + + entry Wait_For_The_End when (Finished) or (not Same) is + begin + null; -- "when ..." is all we need + end Wait_For_The_End; + + function The_Same return Boolean is + begin + return Same; + end The_Same; + + function Early_Abort return Boolean is + begin + return not The_Same or Finished; + end Early_Abort; + + end Buffer_Type; + + Buffer: Buffer_Type; + + -- some wrapper subprogram needed to instantiate the generics below + + procedure Prod_Write(Item: Character) is + begin + Buffer.Write(Item); + end Prod_Write; + + function Stop return Boolean is + begin + return Buffer.Early_Abort; + end Stop; + + procedure Prod_Stop is + begin + Buffer.Write_Done; + end Prod_Stop; + + procedure Cons_Write(Item: Character) is + begin + Buffer.Read_And_Compare(Item); + end Cons_Write; + + procedure Cons_Stop is + begin + Buffer.Read_Done; + end Cons_Stop; + + package Producer is new B_Trees.Traverse(Prod_Write, Stop, Prod_Stop); + package Consumer is new B_Trees.Traverse(Cons_Write, Stop, Cons_Stop); + + begin + Producer.Inorder_Task.Run(T1); + Consumer.Inorder_Task.Run(T2); + Buffer.Wait_For_The_End; + return Buffer.The_Same; + end Same_Fringe; + + procedure Show_Preorder(Tree: Tree_Type; Prefix: String := "") is + use Ada.Text_IO; + begin + if Prefix /= "" then + Ada.Text_IO.Put(Prefix); + end if; + if not Empty(Tree) then + Put("(" & Item(Tree)); Put(", "); + Show_Preorder(Left(Tree)); Put(", "); + Show_Preorder(Right(Tree)); Put(")"); + end if; + if Prefix /= "" then + New_Line; + end if; + end Show_Preorder; + + T_0: Tree_Type := Tree('a', Empty, Tree('b')); + T: array(1 .. 5) of Tree_Type; + +begin + T(1) := Tree('d', Tree('c'), T_0); + T(2) := Tree('c', Empty, Tree('a', Tree('d'), Tree('b'))); + T(3) := Tree('e', T(1), T(2)); + T(4) := Tree('e', T(2), T(1)); + T(5) := Tree('e', T_0, Tree('c', Tree('d'), T(1))); + + -- First display the trees you have (in preorder) + for I in T'Range loop + Show_Preorder(T(I), "Tree(" & Integer'Image(I) & " ) is "); + end loop; + Ada.Text_IO.New_Line; + + -- Now compare them, which have the same fringe? + for I in T'Range loop + for J in T'Range loop + if Same_Fringe(T(J), T(I)) then + Ada.Text_IO.Put("same("); + else + Ada.Text_IO.Put("DIFF("); + end if; + Ada.Text_IO.Put(Integer'Image(I) & "," & Integer'Image(J) & " ); "); + end loop; + Ada.Text_IO.New_Line; + end loop; +end Main; diff --git a/Task/Same-Fringe/C/same-fringe.c b/Task/Same-Fringe/C/same-fringe.c new file mode 100644 index 0000000000..fa2ffe8242 --- /dev/null +++ b/Task/Same-Fringe/C/same-fringe.c @@ -0,0 +1,121 @@ +#include +#include +#include + +typedef struct { + ucontext_t caller, callee; + char stack[8192]; + void *in, *out; +} co_t; + +co_t * co_new(void(*f)(), void *data) +{ + co_t * c = malloc(sizeof(*c)); + getcontext(&c->callee); + c->in = data; + + c->callee.uc_stack.ss_sp = c->stack; + c->callee.uc_stack.ss_size = sizeof(c->stack); + c->callee.uc_link = &c->caller; + makecontext(&c->callee, f, 1, (int)c); + + return c; +} + +void co_del(co_t *c) +{ + free(c); +} + +inline void +co_yield(co_t *c, void *data) +{ + c->out = data; + swapcontext(&c->callee, &c->caller); +} + +inline void * +co_collect(co_t *c) +{ + c->out = 0; + swapcontext(&c->caller, &c->callee); + return c->out; +} + +// end of coroutine stuff + +typedef struct node node; +struct node { + int v; + node *left, *right; +}; + +node *newnode(int v) +{ + node *n = malloc(sizeof(node)); + n->left = n->right = 0; + n->v = v; + return n; +} + +void tree_insert(node **root, node *n) +{ + while (*root) root = ((*root)->v > n->v) + ? &(*root)->left + : &(*root)->right; + *root = n; +} + +void tree_trav(int x) +{ + co_t *c = (co_t *) x; + + void trav(node *root) { + if (!root) return; + trav(root->left); + co_yield(c, root); + trav(root->right); + } + + trav(c->in); +} + +int tree_eq(node *t1, node *t2) +{ + co_t *c1 = co_new(tree_trav, t1); + co_t *c2 = co_new(tree_trav, t2); + + node *p = 0, *q = 0; + do { + p = co_collect(c1); + q = co_collect(c2); + } while (p && q && (p->v == q->v)); + + co_del(c1); + co_del(c2); + return !p && !q; +} + +int main() +{ + int x[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1 }; + int y[] = { 2, 5, 7, 1, 9, 0, 6, 4, 8, 3, -1 }; + int z[] = { 0, 1, 2, 3, 4, 5, 6, 8, 9, -1 }; + + node *t1 = 0, *t2 = 0, *t3 = 0; + + void mktree(int *buf, node **root) { + int i; + for (i = 0; buf[i] >= 0; i++) + tree_insert(root, newnode(buf[i])); + } + + mktree(x, &t1); // ordered binary tree, result of traversing + mktree(y, &t2); // should be independent of insertion, so t1 == t2 + mktree(z, &t3); + + printf("t1 == t2: %s\n", tree_eq(t1, t2) ? "yes" : "no"); + printf("t1 == t3: %s\n", tree_eq(t1, t3) ? "yes" : "no"); + + return 0; +} diff --git a/Task/Same-Fringe/D/same-fringe-1.d b/Task/Same-Fringe/D/same-fringe-1.d new file mode 100644 index 0000000000..2c496dabec --- /dev/null +++ b/Task/Same-Fringe/D/same-fringe-1.d @@ -0,0 +1,22 @@ +struct Node(T) { + T data; + Node* L, R; +} + +bool sameFringe(T)(Node!T* t1, Node!T* t2) { + T[] scan(Node!T* t) { + if (!t) return []; + return (!t.L && !t.R) ? [t.data] : scan(t.L) ~ scan(t.R); + } + return scan(t1) == scan(t2); +} + +void main() { + import std.stdio; + alias N = Node!int; + auto t1 = new N(10, new N(20, new N(30, new N(40), new N(50)))); + auto t2 = new N(1, new N(2, new N(3, new N(40), new N(50)))); + writeln(sameFringe(t1, t2)); + auto t3 = new N(1, new N(2, new N(3, new N(40), new N(51)))); + writeln(sameFringe(t1, t3)); +} diff --git a/Task/Same-Fringe/D/same-fringe-2.d b/Task/Same-Fringe/D/same-fringe-2.d new file mode 100644 index 0000000000..269f3c456d --- /dev/null +++ b/Task/Same-Fringe/D/same-fringe-2.d @@ -0,0 +1,194 @@ +import std.array: empty; +import std.algorithm: equal; + + +// Replace with an efficient stack when available in Phobos. +struct Stack(T) { + private T[] data; + + public @property bool empty() const pure nothrow { + return data.empty; + } + + // Can't be const if T isn't a value or const. + public @property T head() const pure nothrow + in { + assert(!data.empty); + } body { + return data[$ - 1]; + } + + public void push(T x) pure nothrow { + data ~= x; + } + + public void pop() pure nothrow + in { + assert(!data.empty); + } body { + data.length--; + } +} + + +struct BinaryTreeNode(T) { + T data; + BinaryTreeNode* left, right; +} + + +struct Fringe(T) { + alias const(BinaryTreeNode!T)* BT; + private Stack!BT stack; + + pure nothrow invariant() { + assert(stack.empty || isLeaf(stack.head)); + } + + public this(BT t) pure nothrow { + if (t != null) { + stack.push(t); + if (!isLeaf(t)) { + // Here invariant() doesn't hold. + // invariant() isn't called for private methods. + nextLeaf(); + } + } + } + + public @property bool empty() const pure nothrow { + return stack.empty; + } + + public @property T front() const pure nothrow + in { + assert(!stack.empty && stack.head != null); + } body { + return stack.head.data; + } + + public void popFront() pure nothrow + in { + assert(!stack.empty); + } body { + stack.pop(); + if (!empty()) + nextLeaf(); + } + + private static bool isLeaf(in BT t) pure nothrow { + return t != null && t.left == null && t.right == null; + } + + private void nextLeaf() pure nothrow + in { + assert(!stack.empty); + } body { + auto t = stack.head; + + while (!stack.empty && !isLeaf(t)) { + stack.pop(); + if (t.right != null) + stack.push(t.right); + if (t.left != null) + stack.push(t.left); + t = stack.head; + } + } +} + + +bool sameFringe(T)(in BinaryTreeNode!T* t1, in BinaryTreeNode!T* t2) +pure nothrow { + return Fringe!T(t1).equal(Fringe!T(t2)); +} + + +unittest { + alias BinaryTreeNode!int N; + + static N* n(in int x, N* l=null, N* r=null) pure nothrow { + return new N(x, l, r); + } + + { + N* t; + assert(sameFringe(t, t)); + } + + { + const t1 = n(10); + const t2 = n(10); + assert(sameFringe(t1, t2)); + } + + { + const t1 = n(10); + const t2 = n(20); + assert(!sameFringe(t1, t2)); + } + + { + const t1 = n(10, n(20)); + const t2 = n(30, n(20)); + assert(sameFringe(t1, t2)); + } + + { + const t1 = n(10, n(20)); + const t2 = n(10, n(30)); + assert(!sameFringe(t1, t2)); + } + + { + const t1 = n(10, n(20), n(30)); + const t2 = n(5, n(20), n(30)); + assert(sameFringe(t1, t2)); + } + + { + const t1 = n(10, n(20), n(30)); + const t2 = n(5, n(20), n(35)); + assert(!sameFringe(t1, t2)); + } + + { + const t1 = n(10, n(20, n(30))); + const t2 = n(1, n(2, n(30))); + assert(sameFringe(t1, t2)); + } + + { + const t1 = n(10, n(20, n(30, n(40), n(50)))); + const t2 = n(1, n(2, n(3, n(40), n(50)))); + assert(sameFringe(t1, t2)); + } + + { + const t1 = n(10, n(20, n(30, n(40), n(50)))); + const t2 = n(1, n(2, n(3, n(40), n(51)))); + assert(!sameFringe(t1, t2)); + } +} + + +void main() { + import std.stdio; + alias N = BinaryTreeNode!int; + + static N* n(in int x, N* l=null, N* r=null) pure nothrow { + return new N(x, l, r); + } + + const t1 = n(10, n(20, n(30, n(40), n(50)))); + writeln("fringe(t1): ", Fringe!int(t1)); + + const t2 = n(1, n(2, n(3, n(40), n(50)))); + writeln("fringe(t2): ", Fringe!int(t2)); + + const t3 = n(1, n(2, n(3, n(40), n(51)))); + writeln("fringe(t3): ", Fringe!int(t3)); + + writeln("sameFringe(t1, t2): ", sameFringe(t1, t2)); + writeln("sameFringe(t1, t3): ", sameFringe(t1, t3)); +} diff --git a/Task/Same-Fringe/Go/same-fringe.go b/Task/Same-Fringe/Go/same-fringe.go new file mode 100644 index 0000000000..77bcbb4a3e --- /dev/null +++ b/Task/Same-Fringe/Go/same-fringe.go @@ -0,0 +1,71 @@ +package main + +import "fmt" + +type node struct { + int + left, right *node +} + +// function returns a channel that yields the leaves of the tree. +// the channel is closed after all leaves are received. +func leaves(t *node) chan int { + ch := make(chan int) + // recursive function to walk tree. + var f func(*node) + f = func(n *node) { + if n == nil { + return + } + // leaves are identified by having no children. + if n.left == nil && n.right == nil { + ch <- n.int + } else { + f(n.left) + f(n.right) + } + } + // goroutine runs concurrently with others. + // it walks the tree then closes the channel. + go func() { + f(t) + close(ch) + }() + return ch +} + +func sameFringe(t1, t2 *node) bool { + f1 := leaves(t1) + f2 := leaves(t2) + for l1 := range f1 { + // both trees must yield a leaf, and the leaves must be equal. + if l2, ok := <-f2; !ok || l1 != l2 { + return false + } + } + // there must be nothing left in f2 after consuming all of f1. + _, ok := <-f2 + return !ok +} + +func main() { + // the different shapes of the trees is shown with indention. + // the leaves are easy to spot by the int: key. + t1 := &node{3, + &node{1, + &node{int: 1}, + &node{int: 2}}, + &node{8, + &node{int: 5}, + &node{int: 13}}} + // t2 with negative values for internal nodes that can't possibly match + // positive values in t1, just to show that only leaves are being compared. + t2 := &node{-8, + &node{-3, + &node{-1, + &node{int: 1}, + &node{int: 2}}, + &node{int: 5}}, + &node{int: 13}} + fmt.Println(sameFringe(t1, t2)) // prints true. +} diff --git a/Task/Same-Fringe/Haskell/same-fringe.hs b/Task/Same-Fringe/Haskell/same-fringe.hs new file mode 100644 index 0000000000..531ae4dcdc --- /dev/null +++ b/Task/Same-Fringe/Haskell/same-fringe.hs @@ -0,0 +1,24 @@ +data Tree a = Leaf a | Node (Tree a) (Tree a) + deriving (Show, Eq) + +fringe :: Tree a -> [a] +fringe (Leaf x) = [x] +fringe (Node n1 n2) = fringe n1 ++ fringe n2 + +sameFringe :: (Eq a) => Tree a -> Tree a -> Bool +sameFringe t1 t2 = fringe t1 == fringe t2 + +main = do + let a = Node (Leaf 1) (Node (Leaf 2) (Node (Leaf 3) (Node (Leaf 4) (Leaf 5)))) + b = Node (Leaf 1) (Node (Node (Leaf 2) (Leaf 3)) (Node (Leaf 4) (Leaf 5))) + c = Node (Node (Node (Node (Leaf 1) (Leaf 2)) (Leaf 3)) (Leaf 4)) (Leaf 5) + print $ sameFringe a a + print $ sameFringe a b + print $ sameFringe a c + + let x = Node (Leaf 1) (Node (Leaf 2) (Node (Leaf 3) (Node (Leaf 4) (Node (Leaf 5) (Leaf 6))))) + y = Node (Leaf 0) (Node (Node (Leaf 2) (Leaf 3)) (Node (Leaf 4) (Leaf 5))) + z = Node (Leaf 1) (Node (Leaf 2) (Node (Node (Leaf 4) (Leaf 3)) (Leaf 5))) + print $ sameFringe a x + print $ sameFringe a y + print $ sameFringe a z diff --git a/Task/Same-Fringe/J/same-fringe-1.j b/Task/Same-Fringe/J/same-fringe-1.j new file mode 100644 index 0000000000..ddaaccba15 --- /dev/null +++ b/Task/Same-Fringe/J/same-fringe-1.j @@ -0,0 +1 @@ +sameFringe=: -:&([: ; > + { + Node getLeft(); + Node getRight(); + boolean isLeaf(); + T getData(); + } + + public static class SimpleNode> implements Node + { + private final T data; + public SimpleNode left; + public SimpleNode right; + + public SimpleNode(T data) + { this(data, null, null); } + + public SimpleNode(T data, SimpleNode left, SimpleNode right) + { + this.data = data; + this.left = left; + this.right = right; + } + + public Node getLeft() + { return left; } + + public Node getRight() + { return right; } + + public boolean isLeaf() + { return ((left == null) && (right == null)); } + + public T getData() + { return data; } + + public SimpleNode addToTree(T data) + { + int cmp = data.compareTo(this.data); + if (cmp == 0) + throw new IllegalArgumentException("Same data!"); + if (cmp < 0) + { + if (left == null) + return (left = new SimpleNode(data)); + return left.addToTree(data); + } + if (right == null) + return (right = new SimpleNode(data)); + return right.addToTree(data); + } + } + + public static > boolean areLeavesSame(Node node1, Node node2) + { + Stack> stack1 = new Stack>(); + Stack> stack2 = new Stack>(); + stack1.push(node1); + stack2.push(node2); + // NOT using short-circuit operator + while (((node1 = advanceToLeaf(stack1)) != null) & ((node2 = advanceToLeaf(stack2)) != null)) + if (!node1.getData().equals(node2.getData())) + return false; + // Return true if finished at same time + return (node1 == null) && (node2 == null); + } + + private static > Node advanceToLeaf(Stack> stack) + { + while (!stack.isEmpty()) + { + Node node = stack.pop(); + if (node.isLeaf()) + return node; + Node rightNode = node.getRight(); + if (rightNode != null) + stack.push(rightNode); + Node leftNode = node.getLeft(); + if (leftNode != null) + stack.push(leftNode); + } + return null; + } + + public static void main(String[] args) + { + SimpleNode headNode1 = new SimpleNode(35, new SimpleNode(25, new SimpleNode(15, new SimpleNode(10), new SimpleNode(20)), new SimpleNode(30)), new SimpleNode(45, new SimpleNode(40), new SimpleNode(50))); + SimpleNode headNode2 = new SimpleNode(24, new SimpleNode(14, new SimpleNode(10), new SimpleNode(16, null, new SimpleNode(20))), new SimpleNode(34, new SimpleNode(30), new SimpleNode(42, new SimpleNode(40), new SimpleNode(56, new SimpleNode(50), null)))); + SimpleNode headNode3 = new SimpleNode(24, new SimpleNode(14, new SimpleNode(10), new SimpleNode(16, null, new SimpleNode(20))), new SimpleNode(34, new SimpleNode(30), new SimpleNode(42, new SimpleNode(40), new SimpleNode(50, null, new SimpleNode(56))))); + System.out.print("Leaves for set 1: "); + simpleWalk(headNode1); + System.out.println(); + System.out.print("Leaves for set 2: "); + simpleWalk(headNode2); + System.out.println(); + System.out.print("Leaves for set 3: "); + simpleWalk(headNode3); + System.out.println(); + System.out.println("areLeavesSame(1, 2)? " + areLeavesSame(headNode1, headNode2)); + System.out.println("areLeavesSame(2, 3)? " + areLeavesSame(headNode2, headNode3)); + } + + public static void simpleWalk(Node node) + { + if (node.isLeaf()) + System.out.print(node.getData() + " "); + else + { + Node left = node.getLeft(); + if (left != null) + simpleWalk(left); + Node right = node.getRight(); + if (right != null) + simpleWalk(right); + } + } +} diff --git a/Task/Same-Fringe/OCaml/same-fringe.ocaml b/Task/Same-Fringe/OCaml/same-fringe.ocaml new file mode 100644 index 0000000000..d3df9cea28 --- /dev/null +++ b/Task/Same-Fringe/OCaml/same-fringe.ocaml @@ -0,0 +1,23 @@ +type 'a btree = Leaf of 'a | BTree of ('a btree * 'a btree) + +let rec next = function + | [] -> None + | h :: t -> match h with + | Leaf x -> Some (x,t) + | BTree(a,b) -> next (a::b::t) + +let samefringe t1 t2 = + let rec aux s1 s2 = match (next s1, next s2) with + | None, None -> true + | None, _ | _, None -> false + | Some(a,b), Some(c,d) -> (a=c) && aux b d in + aux [t1] [t2] + +(* Test: *) +let () = + let u = BTree(Leaf 1, BTree(Leaf 2, Leaf 3)) in + let v = BTree(BTree(Leaf 1, Leaf 2), Leaf 3) in + let w = BTree(BTree(Leaf 3, Leaf 2), Leaf 1) in + let check a b = + print_endline (if samefringe a b then "same" else "different") in + check u v; check v u; check v w; diff --git a/Task/Same-Fringe/Perl-6/same-fringe-1.pl6 b/Task/Same-Fringe/Perl-6/same-fringe-1.pl6 new file mode 100644 index 0000000000..68667ee7ce --- /dev/null +++ b/Task/Same-Fringe/Perl-6/same-fringe-1.pl6 @@ -0,0 +1,8 @@ +sub fringe ($tree) { + multi sub fringey (Pair $node) { fringey $_ for $node.kv; } + multi sub fringey ( Any $leaf) { take $leaf; } + + (gather fringey $tree), Cool; +} + +sub samefringe ($a, $b) { all fringe($a) Z=== fringe($b) } diff --git a/Task/Same-Fringe/Perl-6/same-fringe-2.pl6 b/Task/Same-Fringe/Perl-6/same-fringe-2.pl6 new file mode 100644 index 0000000000..0a23ae022c --- /dev/null +++ b/Task/Same-Fringe/Perl-6/same-fringe-2.pl6 @@ -0,0 +1,15 @@ +my $a = 1 => 2 => 3 => 4 => 5 => 6 => 7 => 8; +my $b = 1 => (( 2 => 3 ) => (4 => (5 => ((6 => 7) => 8)))); +my $c = (((1 => 2) => 3) => 4) => 5 => 6 => 7 => 8; + +my $x = 1 => 2 => 3 => 4 => 5 => 6 => 7 => 8 => 9; +my $y = 0 => 2 => 3 => 4 => 5 => 6 => 7 => 8; +my $z = 1 => 2 => (4 => 3) => 5 => 6 => 7 => 8; + +say so samefringe $a, $a; +say so samefringe $a, $b; +say so samefringe $a, $c; + +say not samefringe $a, $x; +say not samefringe $a, $y; +say not samefringe $a, $z; diff --git a/Task/Same-Fringe/PicoLisp/same-fringe-1.l b/Task/Same-Fringe/PicoLisp/same-fringe-1.l new file mode 100644 index 0000000000..9c90a4f61e --- /dev/null +++ b/Task/Same-Fringe/PicoLisp/same-fringe-1.l @@ -0,0 +1,19 @@ +(de nextLeaf (Rt Tree) + (co Rt + (recur (Tree) + (when Tree + (recurse (cadr Tree)) + (yield (car Tree)) + (recurse (cddr Tree)) ) ) ) ) + +(de cmpTrees (Tree1 Tree2) + (prog1 + (use (Node1 Node2) + (loop + (setq + Node1 (nextLeaf "rt1" Tree1) + Node2 (nextLeaf "rt2" Tree2) ) + (T (nor Node1 Node2) T) + (NIL (= Node1 Node2)) ) ) + (co "rt1") + (co "rt2") ) ) diff --git a/Task/Same-Fringe/PicoLisp/same-fringe-2.l b/Task/Same-Fringe/PicoLisp/same-fringe-2.l new file mode 100644 index 0000000000..a1fb5c10d2 --- /dev/null +++ b/Task/Same-Fringe/PicoLisp/same-fringe-2.l @@ -0,0 +1,27 @@ +: (balance '*Tree1 (range 1 7)) +-> NIL +: (for N (5 4 6 3 7 1 2) (idx '*Tree2 N T)) +-> NIL + +: (view *Tree1 T) + 7 + 6 + 5 +4 + 3 + 2 + 1 +-> NIL + +: (view *Tree2 T) + 7 + 6 +5 + 4 + 3 + 2 + 1 +-> NIL + +: (cmpTrees *Tree1 *Tree2) +-> T diff --git a/Task/Same-Fringe/Python/same-fringe.py b/Task/Same-Fringe/Python/same-fringe.py new file mode 100644 index 0000000000..8991d6668e --- /dev/null +++ b/Task/Same-Fringe/Python/same-fringe.py @@ -0,0 +1,35 @@ +try: + from itertools import zip_longest as izip_longest # Python 3.x +except: + from itertools import izip_longest # Python 2.6+ + +def fringe(tree): + """Yield tree members L-to-R depth first, + as if stored in a binary tree""" + for node1 in tree: + if isinstance(node1, tuple): + for node2 in fringe(node1): + yield node2 + else: + yield node1 + +def same_fringe(tree1, tree2): + return all(node1 == node2 for node1, node2 in + izip_longest(fringe(tree1), fringe(tree2))) + +if __name__ == '__main__': + a = 1, 2, 3, 4, 5, 6, 7, 8 + b = 1, (( 2, 3 ), (4, (5, ((6, 7), 8)))) + c = (((1, 2), 3), 4), 5, 6, 7, 8 + + x = 1, 2, 3, 4, 5, 6, 7, 8, 9 + y = 0, 2, 3, 4, 5, 6, 7, 8 + z = 1, 2, (4, 3), 5, 6, 7, 8 + + assert same_fringe(a, a) + assert same_fringe(a, b) + assert same_fringe(a, c) + + assert not same_fringe(a, x) + assert not same_fringe(a, y) + assert not same_fringe(a, z) diff --git a/Task/Same-Fringe/REXX/same-fringe-1.rexx b/Task/Same-Fringe/REXX/same-fringe-1.rexx new file mode 100644 index 0000000000..91656ddc38 --- /dev/null +++ b/Task/Same-Fringe/REXX/same-fringe-1.rexx @@ -0,0 +1,176 @@ +/* REXX *************************************************************** +* Same Fringe +* 1 A A +* / \ / \ / \ +* / \ / \ / \ +* / \ / \ / \ +* 2 3 B C B C +* / \ / / \ / / \ / +* 4 5 6 D E F D E F +* / / \ / / \ / / \ +* 7 8 9 G H I G * I +* +* 23.08.2012 Walter Pachl derived from +* http://rosettacode.org/wiki/Tree_traversal +* Tree A: A B D G E C F H I +* Tree B: A B D G E C F * I +**********************************************************************/ +debug=0 +node.=0 +lvl=0 + +Call mktree 'A' +Call mktree 'B' + +done.=0 +za=root.a; leafa=node.a.za.0name +zb=root.a; leafb=node.b.zb.0name +done.a.za=1 +done.b.zb=1 +Do i=1 To 12 + if leafa=leafb Then Do + If leafa=0 Then Do + Say 'Fringes are equal' + Leave + End + Say leafa '=' leafb + Do j=1 To 12 Until done.a.za=0 + za=go_next(za,'A'); leafa=node.a.za.0name + End + done.a.za=1 + Do j=1 To 12 Until done.b.zb=0 + zb=go_next(zb,'B'); leafb=node.b.zb.0name + End + done.b.zb=1 + End + Else Do + Select + When leafa=0 Then + Say leafb 'exceeds leaves in tree A' + When leafb=0 Then + Say leafa 'exceeds leaves in tree B' + Otherwise + Say 'First difference' leafa '<>' leafb + End + Leave + End + End +Exit + + +note: +/********************************************************************** +* add the node to the preorder list unless it's already there +* add the node to the level list +**********************************************************************/ + Parse Arg z,t + If z<>0 &, /* it's a node */ + done.z=0 Then Do /* not yet done */ + wl.t=wl.t z /* add it to the preorder list*/ + ll.lvl=ll.lvl z /* add it to the level list */ + done.z=1 /* remember it's done */ + leafl=leafl node.t.z.0name + End + Return + +go_next: Procedure Expose node. lvl +/********************************************************************** +* find the next node to visit in the treewalk +**********************************************************************/ + next=0 + Parse arg z,t + If node.t.z.0left<>0 Then Do /* there is a left son */ + If node.t.z.0left.done=0 Then Do /* we have not visited it */ + next=node.t.z.0left /* so we go there */ + node.t.z.0left.done=1 /* note we were here */ + lvl=lvl+1 /* increase the level */ + End + End + If next=0 Then Do /* not moved yet */ + If node.t.z.0rite<>0 Then Do /* there is a right son */ + If node.t.z.0rite.done=0 Then Do /* we have not visited it */ + next=node.t.z.0rite /* so we go there */ + node.t.z.0rite.done=1 /* note we were here */ + lvl=lvl+1 /* increase the level */ + End + End + End + If next=0 Then Do /* not moved yet */ + next=node.t.z.0father /* go to the father */ + lvl=lvl-1 /* decrease the level */ + End + Return next /* that's the next node */ + /* or zero if we are done */ + +mknode: Procedure Expose node. +/********************************************************************** +* create a new node +**********************************************************************/ + Parse Arg name,t + z=node.t.0+1 + node.t.z.0name=name + node.t.z.0father=0 + node.t.z.0left =0 + node.t.z.0rite =0 + node.t.0=z + Return z /* number of the node just created */ + +attleft: Procedure Expose node. +/********************************************************************** +* make son the left son of father +**********************************************************************/ + Parse Arg son,father,t + node.t.son.0father=father + z=node.t.father.0left + If z<>0 Then Do + node.t.z.0father=son + node.t.son.0left=z + End + node.t.father.0left=son + Return + +attrite: Procedure Expose node. +/********************************************************************** +* make son the right son of father +**********************************************************************/ + Parse Arg son,father,t + node.t.son.0father=father + z=node.t.father.0rite + If z<>0 Then Do + node.t.z.0father=son + node.t.son.0rite=z + End + node.t.father.0rite=son + le=node.t.father.0left + If le>0 Then + node.t.le.0brother=node.t.father.0rite + Return + +mktree: Procedure Expose node. root. +/********************************************************************** +* build the tree according to the task +**********************************************************************/ + Parse Arg t + If t='A' Then Do + a=mknode('A',t); root.t=a + b=mknode('B',t); Call attleft b,a,t + c=mknode('C',t); Call attrite c,a,t + d=mknode('D',t); Call attleft d,b,t + e=mknode('E',t); Call attrite e,b,t + f=mknode('F',t); Call attleft f,c,t + g=mknode('G',t); Call attleft g,d,t + h=mknode('H',t); Call attleft h,f,t + i=mknode('I',t); Call attrite i,f,t + End + Else Do + a=mknode('A',t); root.t=a + b=mknode('B',t); Call attleft b,a,t + c=mknode('C',t); Call attrite c,a,t + d=mknode('D',t); Call attleft d,b,t + e=mknode('E',t); Call attrite e,b,t + f=mknode('F',t); Call attleft f,c,t + g=mknode('G',t); Call attleft g,d,t + h=mknode('*',t); Call attleft h,f,t + i=mknode('I',t); Call attrite i,f,t + End + Return diff --git a/Task/Same-Fringe/REXX/same-fringe-2.rexx b/Task/Same-Fringe/REXX/same-fringe-2.rexx new file mode 100644 index 0000000000..5ef788e5e7 --- /dev/null +++ b/Task/Same-Fringe/REXX/same-fringe-2.rexx @@ -0,0 +1,139 @@ +/* REXX *************************************************************** +* Same Fringe += 1 A A += / \ / \ / \ += / \ / \ / \ += / \ / \ / \ += 2 3 B C B C += / \ / / \ / / \ / += 4 5 6 D E F D E F += / / \ / / \ / / \ += 7 8 9 G H I G * I += +* 23.08.2012 Walter Pachl derived from +* http://rosettacode.org/wiki/Tree_traversal +* Tree A: A B D G E C F H I +* Tree B: A B D G E C F * I +**********************************************************************/ +node.=0 + +Call mktree 'A' +Call mktree 'B' + +sideboard.=0 + +za=root.a; leafa=node.a.za.0name +zb=root.b; leafb=node.b.zb.0name +Do i=1 To 20 Until za=0 & zb=0 + If leafa=leafb Then Do + Say leafa '=' leafb + Parse Value get_next(za,'A') with za leafa + Parse Value get_next(zb,'B') with zb leafb + End + Else Do + Select + When za=0 Then Say leafb 'exceeds tree A' + When zb=0 Then Say leafa 'exceeds tree B' + Otherwise Say 'First difference' leafa '<>' leafb + End + Leave + Exit + End + End +exit + +get_next: Procedure Expose node. sideboard. + Parse Arg za,t + Select + When node.t.za.0left<>0 Then Do + If node.t.za.0rite<>0 Then Do + z=sideboard.t.0+1 + sideboard.t.z=node.t.za.0rite + sideboard.t.0=z + End + za=node.t.za.0left + End + When node.t.za.0rite<>0 Then Do + za=node.t.za.0rite + End + Otherwise Do + z=sideboard.t.0 + za=sideboard.t.z + z=z-1 + sideboard.t.0=z + End + End + Return za node.t.za.0name + +mknode: Procedure Expose node. +/********************************************************************** +* create a new node +**********************************************************************/ + Parse Arg name,t + z=node.t.0+1 + node.t.z.0name=name + node.t.z.0father=0 + node.t.z.0left =0 + node.t.z.0rite =0 + node.t.0=z + Return z /* number of the node just created */ + +attleft: Procedure Expose node. +/********************************************************************** +* make son the left son of father +**********************************************************************/ + Parse Arg son,father,t + node.t.son.0father=father + z=node.t.father.0left + If z<>0 Then Do + node.t.z.0father=son + node.t.son.0left=z + End + node.t.father.0left=son + Return + +attrite: Procedure Expose node. +/********************************************************************** +* make son the right son of father +**********************************************************************/ + Parse Arg son,father,t + node.t.son.0father=father + z=node.t.father.0rite + If z<>0 Then Do + node.t.z.0father=son + node.t.son.0rite=z + End + node.t.father.0rite=son + le=node.t.father.0left + If le>0 Then + node.t.le.0brother=node.t.father.0rite + Return + +mktree: Procedure Expose node. root. +/********************************************************************** +* build the tree according to the task +**********************************************************************/ + Parse Arg t + If t='A' Then Do + a=mknode('A',t); root.t=a + b=mknode('B',t); Call attleft b,a,t + c=mknode('C',t); Call attrite c,a,t + d=mknode('D',t); Call attleft d,b,t + e=mknode('E',t); Call attrite e,b,t + f=mknode('F',t); Call attleft f,c,t + g=mknode('G',t); Call attleft g,d,t + h=mknode('H',t); Call attleft h,f,t + i=mknode('I',t); Call attrite i,f,t + End + Else Do + a=mknode('A',t); root.t=a + b=mknode('B',t); Call attleft b,a,t + c=mknode('C',t); Call attrite c,a,t + d=mknode('D',t); Call attleft d,b,t + e=mknode('E',t); Call attrite e,b,t + f=mknode('F',t); Call attleft f,c,t + g=mknode('G',t); Call attleft g,d,t + h=mknode('*',t); Call attleft h,f,t + i=mknode('I',t); Call attrite i,f,t + End + Return diff --git a/Task/Same-Fringe/REXX/same-fringe-3.rexx b/Task/Same-Fringe/REXX/same-fringe-3.rexx new file mode 100644 index 0000000000..c4949a57fc --- /dev/null +++ b/Task/Same-Fringe/REXX/same-fringe-3.rexx @@ -0,0 +1,87 @@ +/*REXX pgm examines leaves of two binary trees. Tree used is as above.*/ +_=left('',28); say _ ' A A ' + say _ ' / \ ◄────1st tree / \ ' + say _ ' / \ / \ ' + say _ ' / \ / \ ' + say _ ' B C B C ' + say _ ' / \ / 2nd tree────► / \ / ' + say _ ' D E F D E F ' + say _ ' / / \ / / \ ' + say _ 'G H I G δ I ' +say; #=0 /*#: # of leaves. */ +parse var # done. 1 node. /*set all these variables to zero*/ +call make_tree '1st' +call make_tree '2nd' +z1=root.1st; L1=node.1st.z1; done.1st.z1=1 /*L1 is a leaf on 1st tree*/ +z2=z1; L2=node.2nd.z2; done.2nd.z2=1 /*L2 " " " " 2nd " */ + + do #%2 /*loop for the number of leaves. */ + if L1==L2 then do + if L1==0 then call sayX 'The trees are equal.' + say ' The ' L1 " leaf is identical in both trees." + do until \done.1st.z1 + z1=go_next(z1,'1st'); L1=node.1st.z1 + end + done.1st.z1=1 + do until \done.2nd.z2 + z2=go_next(z2,'2nd'); L2=node.2nd.z2 + end + done.2nd.z2=1 + end + else select + when L1==0 then call sayX L2 'exceeds leaves in 1st tree' + when L2==0 then call sayX L1 'exceeds leaves in 2nd tree' + otherwise call sayX 'A difference is: ' L1 '¬=' L2 + end /*select*/ + end /*#%2*/ +exit +/*──────────────────────────────────GO_NEXT subroutine──────────────────*/ +go_next: procedure expose node.; arg q,t /*find next node.*/ +next=0 +if node.t.q._Lson\==0 then /*is there a left branch in tree?*/ + if node.t.q._Lson.done==0 then do /*has this node been visited yet?*/ + next=node.t.q._Lson /*──► next node. */ + node.t.q._Lson.done=1 /*mark Lson done.*/ + end +if next==0 then + if node.t.q._Rson\==0 then /*is there a right tree branch ? */ + if node.t.q._Rson.done==0 then do /*has this node been visited yet?*/ + next=node.t.q._Rson /*──► next node*/ + node.t.q._Rson.done=1 /*mark Rson don*/ + end +if next==0 then next=node.t.q._dad /*process the father node. */ +return next /*the next node (or 0, if done).*/ +/*──────────────────────────────────MAKE_NODE subroutine────────────────*/ +make_node: parse arg name,t; # = #+1 /*make a new node/branch on tree.*/ +q = node.t.0 + 1; node.t.q = name; node.t.q._dad = 0 +node.t.q._Lson = 0; node.t.q._Rson = 0; node.t.0 = q +return q /*number of the node just created*/ +/*──────────────────────────────────MAKE_TREE subroutine────────────────*/ +make_tree: procedure expose node. root. #; arg tree /*build a tree.*/ + hhh='δ' /*the odd duck in the whole tree.*/ +if tree=='1ST' then hhh='H' + a=make_node('A',tree); root.tree=a + b=make_node('B',tree); call sonL b,a,tree + c=make_node('C',tree); call sonR c,a,tree + d=make_node('D',tree); call sonL d,b,tree + e=make_node('E',tree); call sonR e,b,tree + f=make_node('F',tree); call sonL f,c,tree + g=make_node('G',tree); call sonL g,d,tree + /*quack?*/ h=make_node(hhh,tree); call sonL h,f,tree + i=make_node('I',tree); call sonR i,f,tree +return +/*──────────────────────────────────SAYX subroutine─────────────────────*/ +sayX: say; say arg(1); say; exit /*tell msg & exit.*/ +/*──────────────────────────────────SONL subroutine─────────────────────*/ +sonL: procedure expose node.; parse arg son,dad,t /*build left son. */ + node.t.son._dad=dad; q=node.t.dad._Lson +if q\==0 then do; node.t.q._dad=son; node.t.son._Lson=q; end +node.t.dad._Lson=son +return +/*──────────────────────────────────SONR subroutine─────────────────────*/ +sonR: procedure expose node.; parse arg son,dad,t /*build right son.*/ + node.t.son._dad=dad; q=node.t.dad._Rson +if q\==0 then do; node.t.q._dad=son; node.t.son._Rson=q; end +node.t.dad._Rson=son +if node.t.dad._Lson>0 then node.t.le._brother=node.t.dad._Rson +return diff --git a/Task/Same-Fringe/Racket/same-fringe.rkt b/Task/Same-Fringe/Racket/same-fringe.rkt new file mode 100644 index 0000000000..4a6dd9c785 --- /dev/null +++ b/Task/Same-Fringe/Racket/same-fringe.rkt @@ -0,0 +1,30 @@ +#lang racket +(require racket/control) + +(define (make-fringe-getter tree) + (λ () + (let loop ([tree tree]) + (match tree + [(cons a d) (loop a) + (loop d)] + ['() (void)] + [else (fcontrol tree)])) + (fcontrol 'done))) + +(define (same-fringe? tree1 tree2) + (let loop ([get-fringe1 (make-fringe-getter tree1)] + [get-fringe2 (make-fringe-getter tree2)]) + (% (get-fringe1) + (λ (fringe1 get-fringe1) + (% (get-fringe2) + (λ (fringe2 get-fringe2) + (and (equal? fringe1 fringe2) + (or (eq? fringe1 'done) + (loop get-fringe1 get-fringe2))))))))) + +;; unit tests +(require rackunit) +(check-true (same-fringe? '((1 2 3) ((4 5 6) (7 8))) + '(((1 2 3) (4 5 6)) (7 8)))) +(check-false (same-fringe? '((1 2 3) ((4 5 6) (7 8))) + '(((1 2 3) (4 6)) (8)))) diff --git a/Task/Same-Fringe/Tcl/same-fringe-1.tcl b/Task/Same-Fringe/Tcl/same-fringe-1.tcl new file mode 100644 index 0000000000..cb3e152549 --- /dev/null +++ b/Task/Same-Fringe/Tcl/same-fringe-1.tcl @@ -0,0 +1,33 @@ +package require Tcl 8.6 +package require struct::tree + +# A wrapper round a coroutine for iterating over the leaves of a tree in order +proc leafiterator {tree} { + coroutine coro[incr ::coroutines] apply {tree { + yield [info coroutine] + $tree walk [$tree rootname] node { + if {[$tree isleaf $node]} { + yield $node + } + } + yieldto break + }} $tree +} + +# Compare two trees for equality of their leaf node names +proc samefringe {tree1 tree2} { + set c1 [leafiterator $tree1] + set c2 [leafiterator $tree2] + try { + while 1 { + if {[set l1 [$c1]] ne [set l2 [$c2]]} { + puts "$l1 != $l2"; # Just so we can see where we failed + return 0 + } + } + return 1 + } finally { + rename $c1 {} + rename $c2 {} + } +} diff --git a/Task/Same-Fringe/Tcl/same-fringe-2.tcl b/Task/Same-Fringe/Tcl/same-fringe-2.tcl new file mode 100644 index 0000000000..4e139ef076 --- /dev/null +++ b/Task/Same-Fringe/Tcl/same-fringe-2.tcl @@ -0,0 +1,20 @@ +# Make some trees to compare... +struct::tree t1 deserialize { + root {} {} + a 0 {} + d 3 {} + e 3 {} + b 0 {} + c 0 {} +} +struct::tree t2 deserialize { + root {} {} + a 0 {} + d 3 {} + e 3 {} + b 0 {} + cc 0 {} +} + +# Print the boolean result of doing the comparison +puts [samefringe t1 t2] diff --git a/Task/Scope-Function-names-and-labels/0DESCRIPTION b/Task/Scope-Function-names-and-labels/0DESCRIPTION new file mode 100644 index 0000000000..dbae0e9d5a --- /dev/null +++ b/Task/Scope-Function-names-and-labels/0DESCRIPTION @@ -0,0 +1,5 @@ +The task is to explain or demonstrate the levels of visibility of function names and labels within the language. + +;See also +* [[Variables]] for levels of scope relating to visibility of program variables +* [[Scope modifiers]] for general scope modification facilities diff --git a/Task/Scope-Function-names-and-labels/1META.yaml b/Task/Scope-Function-names-and-labels/1META.yaml new file mode 100644 index 0000000000..13f8d408a6 --- /dev/null +++ b/Task/Scope-Function-names-and-labels/1META.yaml @@ -0,0 +1,4 @@ +--- +category: +- Scope +note: Basic language learning diff --git a/Task/Scope-Function-names-and-labels/AWK/scope-function-names-and-labels.awk b/Task/Scope-Function-names-and-labels/AWK/scope-function-names-and-labels.awk new file mode 100644 index 0000000000..d33a3b352c --- /dev/null +++ b/Task/Scope-Function-names-and-labels/AWK/scope-function-names-and-labels.awk @@ -0,0 +1,9 @@ +# This program outputs a greeting +BEGIN { + sayhello() # Call the function defined below + exit +} + +function sayhello { + print "Hello World!" # Outputs a message to the terminal +} diff --git a/Task/Scope-Function-names-and-labels/BASIC/scope-function-names-and-labels-1.basic b/Task/Scope-Function-names-and-labels/BASIC/scope-function-names-and-labels-1.basic new file mode 100644 index 0000000000..6bbb4d11aa --- /dev/null +++ b/Task/Scope-Function-names-and-labels/BASIC/scope-function-names-and-labels-1.basic @@ -0,0 +1 @@ +GOTO 50: REM THIS WILL WORK IMMEDIATELY diff --git a/Task/Scope-Function-names-and-labels/BASIC/scope-function-names-and-labels-2.basic b/Task/Scope-Function-names-and-labels/BASIC/scope-function-names-and-labels-2.basic new file mode 100644 index 0000000000..c30a29d22e --- /dev/null +++ b/Task/Scope-Function-names-and-labels/BASIC/scope-function-names-and-labels-2.basic @@ -0,0 +1,8 @@ +10 DEF FN S(A)=A*A +20 PRINT FN S(2): REM THIS WILL WORK +30 PRINT FN C(2): REM CALLING A FUNCTION PRIOR TO DEFINITION MAY NOT WORK +40 GOSUB 9000 +50 PRINT FN C(2): REM THIS WILL WORK +60 END +9000 DEF FN C(A)=A*A*A +9999 RETURN diff --git a/Task/Scope-Function-names-and-labels/Perl-6/scope-function-names-and-labels.pl6 b/Task/Scope-Function-names-and-labels/Perl-6/scope-function-names-and-labels.pl6 new file mode 100644 index 0000000000..31c8306e0e --- /dev/null +++ b/Task/Scope-Function-names-and-labels/Perl-6/scope-function-names-and-labels.pl6 @@ -0,0 +1,53 @@ +# call a routine before it has been defined +say log(); # prints: outer + +# define a subroutine that overrides a CORE function +sub log { 'outer' }; +{ + # redefine the subroutine in this block + sub log { 'inner' }; + { + # redefine the subroutine yet again + sub log { 'way down inside' }; + + # call it within this block + say log(); # prints: way down inside + + # call it from the block one level out + say &OUTER::log(); # prints: inner + + # call it from the block two levels out + say &OUTER::OUTER::log(); # prints: outer + + # call it from the outermost block + say &UNIT::log(); # prints: outer + + # call a subroutine that is post declared in outermost scope + outersub() + } + + { + # subroutine in an inner block that doesn't redefine it + # uses definition from nearest enclosing block + say log(); # prints: inner + } + # call it within this block + say log(); # prints: inner + + # call it from the block one level out + say &OUTER::log(); # prints: outer +} + +sub outersub{ + # call subroutine within this block - gets outer sub + say log(); # prints: outer + + # call subroutine from the scope of the callers block + say &CALLER::log(); # prints: way down inside + + # call subroutine from the outer scope of the callers block + say &CALLER::OUTER::log(); # prints: inner + + # call the original overridden CORE routine + say &CORE::log(e); # prints: 1 ( natural log of e ) +} diff --git a/Task/Scope-Function-names-and-labels/REXX/scope-function-names-and-labels.rexx b/Task/Scope-Function-names-and-labels/REXX/scope-function-names-and-labels.rexx new file mode 100644 index 0000000000..ba680af863 --- /dev/null +++ b/Task/Scope-Function-names-and-labels/REXX/scope-function-names-and-labels.rexx @@ -0,0 +1,13 @@ +/*REXX program demonstrates use of labels and a CALL. */ +zz=4 +signal do_add +ttt=sinD(30) /*this REXX statement is never executed.*/ + +do_add: /*coming here from the SIGNAL statement.*/ + +say 'calling the sub add.2.args' +call add.2.args 1,7 +say 'sum=' result +exit /*stick a fork in it, 'cause we're done.*/ + +add.2.args: procedure; parse arg x,y; return x+y diff --git a/Task/Scope-Function-names-and-labels/Tcl/scope-function-names-and-labels.tcl b/Task/Scope-Function-names-and-labels/Tcl/scope-function-names-and-labels.tcl new file mode 100644 index 0000000000..86c01b5119 --- /dev/null +++ b/Task/Scope-Function-names-and-labels/Tcl/scope-function-names-and-labels.tcl @@ -0,0 +1,6 @@ +doFoo 1 2 3; # Will produce an error + +proc doFoo {a b c} { + puts [expr {$a + $b*$c}] +} +doFoo 1 2 3; # Will now print 7 (and will continue to do so until doFoo is renamed or deleted diff --git a/Task/Scope-Function-names-and-labels/UNIX-Shell/scope-function-names-and-labels.sh b/Task/Scope-Function-names-and-labels/UNIX-Shell/scope-function-names-and-labels.sh new file mode 100644 index 0000000000..d6393d58a0 --- /dev/null +++ b/Task/Scope-Function-names-and-labels/UNIX-Shell/scope-function-names-and-labels.sh @@ -0,0 +1,10 @@ +#!/bin/sh +multiply 3 4 # This will not work +echo $? # A bogus value was returned because multiply definition has not yet been run. + +multiply() { + return `expr $1 \* $2` # The backslash is required to suppress interpolation +} + +multiply 3 4 # Ok. It works now. +echo $? # This gives 12 diff --git a/Task/Scope-Function-names-and-labels/ZX-Spectrum-Basic/scope-function-names-and-labels.zx b/Task/Scope-Function-names-and-labels/ZX-Spectrum-Basic/scope-function-names-and-labels.zx new file mode 100644 index 0000000000..222e0d9438 --- /dev/null +++ b/Task/Scope-Function-names-and-labels/ZX-Spectrum-Basic/scope-function-names-and-labels.zx @@ -0,0 +1,5 @@ +9000 REM The function is immediately visible and usable +9010 DEF FN s(x)=x*x + +PRINT FN s(5): REM This will work immediately +GO TO 50: REM This will work immediately diff --git a/Task/Scope-modifiers/0DESCRIPTION b/Task/Scope-modifiers/0DESCRIPTION new file mode 100644 index 0000000000..c4533ae259 --- /dev/null +++ b/Task/Scope-modifiers/0DESCRIPTION @@ -0,0 +1,3 @@ +Most programming languages offer support for [[Creating a function|subroutines]]. When execution changes between subroutines, different sets of variables and functions ("scopes") are available to the program. Frequently these sets are defined by the placement of the variable and function declarations ("static scoping" or "lexical scoping"). These sets may also be defined by special modifiers to the variable and function declarations. + +Show the different scope modifiers available in your language and briefly explain how they change the scope of their variable or function. If your language has no scope modifiers, note it. diff --git a/Task/Scope-modifiers/1META.yaml b/Task/Scope-modifiers/1META.yaml new file mode 100644 index 0000000000..659c8686af --- /dev/null +++ b/Task/Scope-modifiers/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Basic language learning diff --git a/Task/Scope-modifiers/Ada/scope-modifiers-1.ada b/Task/Scope-modifiers/Ada/scope-modifiers-1.ada new file mode 100644 index 0000000000..74515837e2 --- /dev/null +++ b/Task/Scope-modifiers/Ada/scope-modifiers-1.ada @@ -0,0 +1,5 @@ +package P is + ... -- Declarations placed here are publicly visible +private + ... -- These declarations are visible only to the children of P +end P; diff --git a/Task/Scope-modifiers/Ada/scope-modifiers-2.ada b/Task/Scope-modifiers/Ada/scope-modifiers-2.ada new file mode 100644 index 0000000000..a63f191001 --- /dev/null +++ b/Task/Scope-modifiers/Ada/scope-modifiers-2.ada @@ -0,0 +1,11 @@ +package P is + type T is private; -- No components visible + procedure F (X : in out T); -- The only visible operation + N : constant T; -- A constant, which value is hidden +private + type T is record -- The implementation, visible to children only + Component : Integer; + end record; + procedure V (X : in out T); -- Operation used only by children + N : constant T := (Component => 0); -- Constant implementation +end P; diff --git a/Task/Scope-modifiers/Ada/scope-modifiers-3.ada b/Task/Scope-modifiers/Ada/scope-modifiers-3.ada new file mode 100644 index 0000000000..236da0e7e3 --- /dev/null +++ b/Task/Scope-modifiers/Ada/scope-modifiers-3.ada @@ -0,0 +1,4 @@ +package body P is + -- The implementation of P, invisible to anybody + procedure W (X : in out T); -- Operation used only internally +end P; diff --git a/Task/Scope-modifiers/Ada/scope-modifiers-4.ada b/Task/Scope-modifiers/Ada/scope-modifiers-4.ada new file mode 100644 index 0000000000..e0024c887f --- /dev/null +++ b/Task/Scope-modifiers/Ada/scope-modifiers-4.ada @@ -0,0 +1,5 @@ +private package P.Q is + ... -- Visible to the siblings only +private + ... -- Visible to the children only +end P.Q; diff --git a/Task/Scope-modifiers/AutoHotkey/scope-modifiers.ahk b/Task/Scope-modifiers/AutoHotkey/scope-modifiers.ahk new file mode 100644 index 0000000000..2839e9ced6 --- /dev/null +++ b/Task/Scope-modifiers/AutoHotkey/scope-modifiers.ahk @@ -0,0 +1,25 @@ +singleton = "global variable" + +assume_global() +{ + Global ; assume all variables declared in this function are global in scope + Static callcount := 0 ; except this one declared static, initialized once only + MsgBox % singleton ; usefull to initialize a bunch of singletons + callcount++ +} + +assume_global2() +{ + Local var1 ; assume global except for var1 (similar to global scope declaration) + MsgBox % singleton +} + +object(member, value = 0, null = 0) +{ + Static ; assume all variables in this function to be static + If value ; can be used to simulate objects + _%member% := value + Else If null + _%member% := "" + Return (_%member%) +} diff --git a/Task/Scope-modifiers/BBC-BASIC/scope-modifiers.bbc b/Task/Scope-modifiers/BBC-BASIC/scope-modifiers.bbc new file mode 100644 index 0000000000..364fb9a4df --- /dev/null +++ b/Task/Scope-modifiers/BBC-BASIC/scope-modifiers.bbc @@ -0,0 +1,33 @@ + var1$ = "Global1" + var2$ = "Global2" + + PRINT "Before function call:" + PRINT "var1$ = """ var1$ """" + PRINT "var2$ = """ var2$ """" + + PROCtestscope(var1$) + PROCtestscope(var1$) + + PRINT "After function call:" + PRINT "var1$ = """ var1$ """" + PRINT "var2$ = """ var2$ """" + END + + DEF PROCtestscope(var2$) + PRINT "On entry to function:" + PRINT "var1$ = """ var1$ """" + PRINT "var2$ = """ var2$ """" + + LOCAL var1$ + PRIVATE var2$ + PRINT "After LOCAL/PRIVATE:" + PRINT "var1$ = """ var1$ """" + PRINT "var2$ = """ var2$ """" + + var1$ = "Local" + var2$ = "Private" + PRINT "After assignments:" + PRINT "var1$ = """ var1$ """" + PRINT "var2$ = """ var2$ """" + + ENDPROC diff --git a/Task/Scope-modifiers/C/scope-modifiers-1.c b/Task/Scope-modifiers/C/scope-modifiers-1.c new file mode 100644 index 0000000000..87f08d20c4 --- /dev/null +++ b/Task/Scope-modifiers/C/scope-modifiers-1.c @@ -0,0 +1,24 @@ +int a; // a is global +static int p; // p is "locale" and can be seen only from file1.c + +extern float v; // a global declared somewhere else + +// a "global" function +int code(int arg) +{ + int myp; // 1) this can be seen only from inside code + // 2) In recursive code this variable will be in a + // different stack frame (like a closure) + static int myc; // 3) still a variable that can be seen only from + // inside code, but its value will be kept + // among different code calls + // 4) In recursive code this variable will be the + // same in every stack frame - a significant scoping difference +} + +// a "local" function; can be seen only inside file1.c +static void code2(void) +{ + v = v * 1.02; // update global v + // ... +} diff --git a/Task/Scope-modifiers/C/scope-modifiers-2.c b/Task/Scope-modifiers/C/scope-modifiers-2.c new file mode 100644 index 0000000000..a2248c42d7 --- /dev/null +++ b/Task/Scope-modifiers/C/scope-modifiers-2.c @@ -0,0 +1,8 @@ +float v; // a global to be used from file1.c too +static int p; // a file-scoped p; nothing to share with static p + // in file1.c + +int code(int); // this is enough to be able to use global code defined in file1.c + // normally these things go into a header.h + +// ... diff --git a/Task/Scope-modifiers/Common-Lisp/scope-modifiers.lisp b/Task/Scope-modifiers/Common-Lisp/scope-modifiers.lisp new file mode 100644 index 0000000000..440a79f967 --- /dev/null +++ b/Task/Scope-modifiers/Common-Lisp/scope-modifiers.lisp @@ -0,0 +1,12 @@ +;; *bug* shall have a dynamic binding. +(declaim (special *bug*)) + +(let ((shape "triangle") (*bug* "ant")) + (flet ((speak () + (format t "~% There is some ~A in my ~A!" *bug* shape))) + (format t "~%Put ~A in your ~A..." *bug* shape) + (speak) + + (let ((shape "circle") (*bug* "cockroach")) + (format t "~%Put ~A in your ~A..." *bug* shape) + (speak)))) diff --git a/Task/Scope-modifiers/Delphi/scope-modifiers-1.delphi b/Task/Scope-modifiers/Delphi/scope-modifiers-1.delphi new file mode 100644 index 0000000000..3e18ebf09e --- /dev/null +++ b/Task/Scope-modifiers/Delphi/scope-modifiers-1.delphi @@ -0,0 +1 @@ +private diff --git a/Task/Scope-modifiers/Delphi/scope-modifiers-2.delphi b/Task/Scope-modifiers/Delphi/scope-modifiers-2.delphi new file mode 100644 index 0000000000..418c98625a --- /dev/null +++ b/Task/Scope-modifiers/Delphi/scope-modifiers-2.delphi @@ -0,0 +1 @@ +protected diff --git a/Task/Scope-modifiers/Delphi/scope-modifiers-3.delphi b/Task/Scope-modifiers/Delphi/scope-modifiers-3.delphi new file mode 100644 index 0000000000..a48cf0de7a --- /dev/null +++ b/Task/Scope-modifiers/Delphi/scope-modifiers-3.delphi @@ -0,0 +1 @@ +public diff --git a/Task/Scope-modifiers/Delphi/scope-modifiers-4.delphi b/Task/Scope-modifiers/Delphi/scope-modifiers-4.delphi new file mode 100644 index 0000000000..418c98625a --- /dev/null +++ b/Task/Scope-modifiers/Delphi/scope-modifiers-4.delphi @@ -0,0 +1 @@ +protected diff --git a/Task/Scope-modifiers/Delphi/scope-modifiers-5.delphi b/Task/Scope-modifiers/Delphi/scope-modifiers-5.delphi new file mode 100644 index 0000000000..94513e133e --- /dev/null +++ b/Task/Scope-modifiers/Delphi/scope-modifiers-5.delphi @@ -0,0 +1 @@ +automated diff --git a/Task/Scope-modifiers/Delphi/scope-modifiers-6.delphi b/Task/Scope-modifiers/Delphi/scope-modifiers-6.delphi new file mode 100644 index 0000000000..23c348349e --- /dev/null +++ b/Task/Scope-modifiers/Delphi/scope-modifiers-6.delphi @@ -0,0 +1,2 @@ +strict private +strict protected diff --git a/Task/Scope-modifiers/Ela/scope-modifiers.ela b/Task/Scope-modifiers/Ela/scope-modifiers.ela new file mode 100644 index 0000000000..29e00400f6 --- /dev/null +++ b/Task/Scope-modifiers/Ela/scope-modifiers.ela @@ -0,0 +1,5 @@ +pi # private +pi = 3.14159 + +sum # private +sum x y = x + y diff --git a/Task/Scope-modifiers/Icon/scope-modifiers.icon b/Task/Scope-modifiers/Icon/scope-modifiers.icon new file mode 100644 index 0000000000..5960963bc4 --- /dev/null +++ b/Task/Scope-modifiers/Icon/scope-modifiers.icon @@ -0,0 +1,6 @@ +global var1 # used outside of procedures + +procedure one() # a global procedure (the only kind) +local var2 # used inside of procedures +static var3 # also used inside of procedures +end diff --git a/Task/Scope-modifiers/J/scope-modifiers.j b/Task/Scope-modifiers/J/scope-modifiers.j new file mode 100644 index 0000000000..12688094f0 --- /dev/null +++ b/Task/Scope-modifiers/J/scope-modifiers.j @@ -0,0 +1,17 @@ + A=: 1 + B=: 2 + C=: 3 + F=: verb define + A=:4 + B=.5 + D=.6 + A+B+C+D + ) + F '' +18 + A +4 + B +2 + D +|value error diff --git a/Task/Scope-modifiers/Java/scope-modifiers.java b/Task/Scope-modifiers/Java/scope-modifiers.java new file mode 100644 index 0000000000..1ad6c0c8c5 --- /dev/null +++ b/Task/Scope-modifiers/Java/scope-modifiers.java @@ -0,0 +1,35 @@ +public //any class may access this member directly + +protected //only this class, subclasses of this class, +//and classes in the same package may access this member directly + +private //only this class may access this member directly + +static //for use with other modifiers +//limits this member to one reference for the entire JVM + +//adding no modifier (sometimes called "friendly") allows access to the member by classes in the same package + +// Modifier | Class | Package | Subclass | World +// ------------|-------|---------|----------|------- +// public | Y | Y | Y | Y +// protected | Y | Y | Y | N +// no modifier | Y | Y | N | N +// private | Y | N | N | N + +//method parameters are available inside the entire method + +//Other declarations follow lexical scoping, +//being in the scope of the innermost set of braces ({}) to them. +//You may also create local scopes by surrounding blocks of code with braces. + +public void function(int x){ + //can use x here + int y; + //can use x and y here + { + int z; + //can use x, y, and z here + } + //can use x and y here, but NOT z +} diff --git a/Task/Scope-modifiers/Logo/scope-modifiers.logo b/Task/Scope-modifiers/Logo/scope-modifiers.logo new file mode 100644 index 0000000000..2410188dd1 --- /dev/null +++ b/Task/Scope-modifiers/Logo/scope-modifiers.logo @@ -0,0 +1,15 @@ +make "g 5 ; global + +to proc :p + make "h 4 ; also global + local "l ; local, no initial value + localmake "m 3 + + sub 7 +end + +to sub :s + ; can see :g, :h, and :s + ; if called from proc, can also see :l and :m + localmake "h 5 ; hides global :h within this procedure and those it calls +end diff --git a/Task/Scope-modifiers/MUMPS/scope-modifiers.mumps b/Task/Scope-modifiers/MUMPS/scope-modifiers.mumps new file mode 100644 index 0000000000..391a8afe2a --- /dev/null +++ b/Task/Scope-modifiers/MUMPS/scope-modifiers.mumps @@ -0,0 +1,15 @@ +OUTER + SET OUT=1,IN=0 + WRITE "OUT = ",OUT,! + WRITE "IN = ",IN,! + DO INNER + WRITE:$DATA(OUT)=0 "OUT was destroyed",! + QUIT +INNER + WRITE "OUT (inner scope) = ",OUT,! + WRITE "IN (outer scope) = ",IN,! + NEW IN + SET IN=3.14 + WRITE "IN (inner scope) = ",IN,! + KILL OUT + QUIT diff --git a/Task/Scope-modifiers/Mathematica/scope-modifiers.math b/Task/Scope-modifiers/Mathematica/scope-modifiers.math new file mode 100644 index 0000000000..3f125f11dd --- /dev/null +++ b/Task/Scope-modifiers/Mathematica/scope-modifiers.math @@ -0,0 +1,19 @@ +Module -> localize names of variables (lexical scoping) +Block -> localize values of variables (dynamic scoping) + +Module creates new symbols: + +Module[{x}, Print[x]; + Module[{x}, Print[x]] +] + +->x$119 +->x$120 + +Block localizes values only; it does not create new symbols: + +x = 7; +Block[{x=0}, Print[x]] +Print[x] +->0 +->7 diff --git a/Task/Scope-modifiers/Perl-6/scope-modifiers-1.pl6 b/Task/Scope-modifiers/Perl-6/scope-modifiers-1.pl6 new file mode 100644 index 0000000000..3478395ff1 --- /dev/null +++ b/Task/Scope-modifiers/Perl-6/scope-modifiers-1.pl6 @@ -0,0 +1,4 @@ +my $lexical-variable; +our $package-variable; +state $persistent-lexical; +has $.public-attribute; diff --git a/Task/Scope-modifiers/Perl-6/scope-modifiers-2.pl6 b/Task/Scope-modifiers/Perl-6/scope-modifiers-2.pl6 new file mode 100644 index 0000000000..189b8d0f5c --- /dev/null +++ b/Task/Scope-modifiers/Perl-6/scope-modifiers-2.pl6 @@ -0,0 +1,13 @@ +sub a { + my $*dyn = 'a'; + c(); +} +sub b { + my $*dyn = 'b'; + c(); +} +sub c { + say $*dyn; +} +a(); # says a +b(); # says b diff --git a/Task/Scope-modifiers/Perl/scope-modifiers-1.pl b/Task/Scope-modifiers/Perl/scope-modifiers-1.pl new file mode 100644 index 0000000000..3b5778181a --- /dev/null +++ b/Task/Scope-modifiers/Perl/scope-modifiers-1.pl @@ -0,0 +1,9 @@ +use strict; +$x = 1; # Compilation error. +our $y = 2; +print "$y\n"; # Legal; refers to $main::y. + +package Foo; +our $z = 3; +package Bar; +print "$z\n"; # Refers to $Foo::z. diff --git a/Task/Scope-modifiers/Perl/scope-modifiers-2.pl b/Task/Scope-modifiers/Perl/scope-modifiers-2.pl new file mode 100644 index 0000000000..80293e2939 --- /dev/null +++ b/Task/Scope-modifiers/Perl/scope-modifiers-2.pl @@ -0,0 +1,13 @@ +package Foo; +my $fruit = 'apple'; +package Bar; +print "$fruit\n"; # Prints "apple". +{ + my $fruit = 'banana'; + print "$fruit\n"; # Prints "banana". +} +print "$fruit\n"; # Prints "apple". + # The second $fruit has been destroyed. +our $fruit = 'orange'; +print "$fruit\n"; # Prints "orange"; refers to $Bar::fruit. + # The first $fruit is inaccessible. diff --git a/Task/Scope-modifiers/Perl/scope-modifiers-3.pl b/Task/Scope-modifiers/Perl/scope-modifiers-3.pl new file mode 100644 index 0000000000..af52a7528e --- /dev/null +++ b/Task/Scope-modifiers/Perl/scope-modifiers-3.pl @@ -0,0 +1,10 @@ +use 5.10.0; + +sub count_up +{ + state $foo = 13; + say $foo++; +} + +count_up; # Prints "13". +count_up; # Prints "14". diff --git a/Task/Scope-modifiers/Perl/scope-modifiers-4.pl b/Task/Scope-modifiers/Perl/scope-modifiers-4.pl new file mode 100644 index 0000000000..3e4809a738 --- /dev/null +++ b/Task/Scope-modifiers/Perl/scope-modifiers-4.pl @@ -0,0 +1,17 @@ +our $camelid = 'llama'; + +sub phooey +{ + print "$camelid\n"; +} + +phooey; # Prints "llama". + +sub do_phooey +{ + local $camelid = 'alpaca'; + phooey; +} + +do_phooey; # Prints "alpaca". +phooey; # Prints "llama". diff --git a/Task/Scope-modifiers/PowerShell/scope-modifiers.psh b/Task/Scope-modifiers/PowerShell/scope-modifiers.psh new file mode 100644 index 0000000000..151f2ac929 --- /dev/null +++ b/Task/Scope-modifiers/PowerShell/scope-modifiers.psh @@ -0,0 +1,6 @@ +$a = "foo" # global scope +function test { + $a = "bar" # local scope + Write-Host Local: $a # "bar" - local variable + Write-Host Global: $global:a # "foo" - global variable +} diff --git a/Task/Scope-modifiers/PureBasic/scope-modifiers.purebasic b/Task/Scope-modifiers/PureBasic/scope-modifiers.purebasic new file mode 100644 index 0000000000..4729b16c5f --- /dev/null +++ b/Task/Scope-modifiers/PureBasic/scope-modifiers.purebasic @@ -0,0 +1,32 @@ +;define a local integer variable by simply using it +baseAge.i = 10 +;explicitly define local strings +Define person.s = "Amy", friend.s = "Susan" +;define variables that are both accessible inside and outside procedures +Global ageDiff = 3 +Global extraYears = 5 + + +Procedure test() + ;define a local integer variable by simply using it + baseAge.i = 30 + ;explicitly define a local string + Define person.s = "Bob" + ;allow access to a local variable in the main body of code + Shared friend + ;create a local variable distinct from a variable with global scope having the same name + Protected extraYears = 2 + + PrintN(person + " and " + friend + " are " + Str(baseAge) + " and " + Str(baseAge + ageDiff + extraYears) + " years old.") +EndProcedure + + +If OpenConsole() + test() + + PrintN(person + " and " + friend + " are " + Str(baseAge) + " and " + Str(baseAge + ageDiff + extraYears) + " years old.") + + Print(#CRLF$ + #CRLF$ + "Press ENTER to exit") + Input() + CloseConsole() +EndIf diff --git a/Task/Scope-modifiers/Python/scope-modifiers.py b/Task/Scope-modifiers/Python/scope-modifiers.py new file mode 100644 index 0000000000..30f0ed5457 --- /dev/null +++ b/Task/Scope-modifiers/Python/scope-modifiers.py @@ -0,0 +1,30 @@ +>>> x="From global scope" +>>> def outerfunc(): + x = "From scope at outerfunc" + + def scoped_local(): + x = "scope local" + return "scoped_local scope gives x = " + x + print(scoped_local()) + + def scoped_nonlocal(): + nonlocal x + return "scoped_nonlocal scope gives x = " + x + print(scoped_nonlocal()) + + def scoped_global(): + global x + return "scoped_global scope gives x = " + x + print(scoped_global()) + + def scoped_notdefinedlocally(): + return "scoped_notdefinedlocally scope gives x = " + x + print(scoped_notdefinedlocally()) + + +>>> outerfunc() +scoped_local scope gives x = scope local +scoped_nonlocal scope gives x = From scope at outerfunc +scoped_global scope gives x = From global scope +scoped_notdefinedlocally scope gives x = From global scope +>>> diff --git a/Task/Scope-modifiers/R/scope-modifiers-1.r b/Task/Scope-modifiers/R/scope-modifiers-1.r new file mode 100644 index 0000000000..ec622a1415 --- /dev/null +++ b/Task/Scope-modifiers/R/scope-modifiers-1.r @@ -0,0 +1,7 @@ +X <- "global x" +f <- function() { + x <- "local x" + print(x) #"local x" +} +f() #prints "local x" +print(x) #prints "global x" diff --git a/Task/Scope-modifiers/R/scope-modifiers-2.r b/Task/Scope-modifiers/R/scope-modifiers-2.r new file mode 100644 index 0000000000..ef6aac87a4 --- /dev/null +++ b/Task/Scope-modifiers/R/scope-modifiers-2.r @@ -0,0 +1,5 @@ +d <- data.frame(a=c(2,4,6), b = c(5,7,9)) +attach(d) +b - a #success +detach(d) +b - a #produces error diff --git a/Task/Scope-modifiers/R/scope-modifiers-3.r b/Task/Scope-modifiers/R/scope-modifiers-3.r new file mode 100644 index 0000000000..5710560424 --- /dev/null +++ b/Task/Scope-modifiers/R/scope-modifiers-3.r @@ -0,0 +1,37 @@ +x <- "global x" +print(x) #"global x" + +local({ ## local({...}) is a shortcut for evalq({...}, envir=new.env()) + ## and is also equivalent to (function() {...})() + + x <- "outer local x" + print(x) #"outer local x" + x <<- "modified global x" + print(x) #"outer local x" still + y <<- "created global y" + print(y) #"created global y" + local({ + + ## Note, <<- is _not_ a global assignment operator. If an + ## enclosing scope defines the variable, that enclosing scope gets + ## the assignment. This happens in the order of evalution; a local + ## variable may be defined later on in the same scope. + + x <- "inner local x" + print(x) #"inner local x" + x <<- "modified outer local x" + print(x) #"inner local x" + y <<- "modified global y" + print(y) #"modified global y" + y <- "local y" + print(y) #"local y" + + ##this is the only way to reliably do a global assignment: + assign("x", "twice modified global x", globalenv()) + print(evalq(x, globalenv())) #"twice modified global x" + }) + + print(x) #"modified outer local x" +}) +print(x) #"twice modified global x" +print(y) #"modified global y" diff --git a/Task/Scope-modifiers/R/scope-modifiers-4.r b/Task/Scope-modifiers/R/scope-modifiers-4.r new file mode 100644 index 0000000000..cfa543994b --- /dev/null +++ b/Task/Scope-modifiers/R/scope-modifiers-4.r @@ -0,0 +1,11 @@ +x <- "global x" +f <- function() { + cat("Lexically enclosed x: ", x,"\n") + cat("Lexically enclosed x: ", evalq(x, parent.env(sys.frame())),"\n") + cat("Dynamically enclosed x: ", evalq(x, parent.frame()),"\n") +} + +local({ + x <- "local x" + f() +}) diff --git a/Task/Scope-modifiers/R/scope-modifiers-5.r b/Task/Scope-modifiers/R/scope-modifiers-5.r new file mode 100644 index 0000000000..93081024e8 --- /dev/null +++ b/Task/Scope-modifiers/R/scope-modifiers-5.r @@ -0,0 +1,12 @@ +d <- data.frame(a=c(2,4,6), b = c(5,7,9)) +also <- c(1, 0, 2) +with(d, mean(b - a + also)) #returns 4 + +## with() is built in, but you might have implemented it like this: + +with.impl <- function(env, expr) { + env <- as.environment(env) + parent.env(env) <- parent.frame() + eval(substitute(expr), envir=env) +} +with.impl(d, mean(b - a + also)) diff --git a/Task/Scope-modifiers/REXX/scope-modifiers.rexx b/Task/Scope-modifiers/REXX/scope-modifiers.rexx new file mode 100644 index 0000000000..c735d3c2b4 --- /dev/null +++ b/Task/Scope-modifiers/REXX/scope-modifiers.rexx @@ -0,0 +1,23 @@ +/*REXX program to display scope modifiers (for subroutines/functions). */ +a=1/4 +b=20 +c=3 +d=5 +call SSN_571 d**4 + + /* at this point, A is defined and equal to .25 */ + /* at this point, B is defined and equal to 40 */ + /* at this point, C is defined and equal to 27 */ + /* at this point, D is defined and equal to 5 */ + /* at this point, FF isn't defined. */ + /* at this point, EWE is defined and equal to 'female sheep' */ + /* at this point, G is defined and equal to 625 */ +exit /*stick a fork in it, we're done.*/ +/*─────────────────────────────────────SSN_571 submarine, er, subroutine*/ +SSN_571: procedure expose b c ewe g; parse arg g +b = b*2 +c = c**3 +ff = b+c +ewe = 'female sheep' +d = 55555555 +return /*compliments to Jules Verne's Captain Nemo? */ diff --git a/Task/Scope-modifiers/TI-89-BASIC/scope-modifiers.ti-89 b/Task/Scope-modifiers/TI-89-BASIC/scope-modifiers.ti-89 new file mode 100644 index 0000000000..b4ecfcc0b1 --- /dev/null +++ b/Task/Scope-modifiers/TI-89-BASIC/scope-modifiers.ti-89 @@ -0,0 +1,3 @@ +Local x +2 → x +Return x^x diff --git a/Task/Scope-modifiers/TXR/scope-modifiers-1.txr b/Task/Scope-modifiers/TXR/scope-modifiers-1.txr new file mode 100644 index 0000000000..5e508dc05d --- /dev/null +++ b/Task/Scope-modifiers/TXR/scope-modifiers-1.txr @@ -0,0 +1,6 @@ +@(maybe)@# perhaps this subclause suceeds or not +@ (block foo) +@ (bind a "a") +@ (accept foo) +@(end) +@(bind b "b") diff --git a/Task/Scope-modifiers/TXR/scope-modifiers-2.txr b/Task/Scope-modifiers/TXR/scope-modifiers-2.txr new file mode 100644 index 0000000000..17da1f57ca --- /dev/null +++ b/Task/Scope-modifiers/TXR/scope-modifiers-2.txr @@ -0,0 +1,6 @@ +@(maybe)@# perhaps this subclause suceeds or not +@ (block foo) +@ (bind a "a") +@ (fail foo) +@(end) +@(bind b "b") diff --git a/Task/Scope-modifiers/Tcl/scope-modifiers-1.tcl b/Task/Scope-modifiers/Tcl/scope-modifiers-1.tcl new file mode 100644 index 0000000000..56e6a9a135 --- /dev/null +++ b/Task/Scope-modifiers/Tcl/scope-modifiers-1.tcl @@ -0,0 +1,18 @@ +set globalVar "This is a global variable" +namespace eval nsA { + variable varInA "This is a variable in nsA" +} +namespace eval nsB { + variable varInB "This is a variable in nsB" + proc showOff {varname} { + set localVar "This is a local variable" + global globalVar + variable varInB + namespace upvar ::nsA varInA varInA + puts "variable $varname holds \"[set $varname]\"" + } +} +nsB::showOff globalVar +nsB::showOff varInA +nsB::showOff varInB +nsB::showOff localVar diff --git a/Task/Scope-modifiers/Tcl/scope-modifiers-2.tcl b/Task/Scope-modifiers/Tcl/scope-modifiers-2.tcl new file mode 100644 index 0000000000..b259e6bd10 --- /dev/null +++ b/Task/Scope-modifiers/Tcl/scope-modifiers-2.tcl @@ -0,0 +1,11 @@ +oo::class create example { + # Note that this is otherwise syntactically the same as a local variable + variable objVar + constructor {} { + set objVar "This is an object variable" + } + method showOff {} { + puts "variable objVar holds \"$objVar\"" + } +} +[example new] showOff diff --git a/Task/Scope-modifiers/Tcl/scope-modifiers-3.tcl b/Task/Scope-modifiers/Tcl/scope-modifiers-3.tcl new file mode 100644 index 0000000000..c1e3e60afd --- /dev/null +++ b/Task/Scope-modifiers/Tcl/scope-modifiers-3.tcl @@ -0,0 +1,4 @@ +proc decr {varName {decrement 1}} { + upvar 1 $varName var + incr var [expr {-$decrement}] +} diff --git a/Task/Scope-modifiers/Tcl/scope-modifiers-4.tcl b/Task/Scope-modifiers/Tcl/scope-modifiers-4.tcl new file mode 100644 index 0000000000..2500783579 --- /dev/null +++ b/Task/Scope-modifiers/Tcl/scope-modifiers-4.tcl @@ -0,0 +1,3 @@ +proc semival args { + uplevel 1 [join $args ";"] +} diff --git a/Task/Scope-modifiers/Tcl/scope-modifiers-5.tcl b/Task/Scope-modifiers/Tcl/scope-modifiers-5.tcl new file mode 100644 index 0000000000..2120307915 --- /dev/null +++ b/Task/Scope-modifiers/Tcl/scope-modifiers-5.tcl @@ -0,0 +1,15 @@ +proc loop {varName from to body} { + upvar 1 $varName var + for {set var $from} {$var <= $to} {incr var} { + uplevel 1 $body + } +} + +loop x 1 10 { + puts "x is now $x" + if {$x == 5} { + puts "breaking out..." + break + } +} +puts "done" diff --git a/Task/Scope-modifiers/Ursala/scope-modifiers-1.ursala b/Task/Scope-modifiers/Ursala/scope-modifiers-1.ursala new file mode 100644 index 0000000000..0a985986db --- /dev/null +++ b/Task/Scope-modifiers/Ursala/scope-modifiers-1.ursala @@ -0,0 +1,11 @@ +local_shop = 0 +hidden_variable = 3 + +#library+ + +this_public_constant = local_shop +a_visible_function = + + +#library- + +for_local_people = 7 diff --git a/Task/Scope-modifiers/Ursala/scope-modifiers-2.ursala b/Task/Scope-modifiers/Ursala/scope-modifiers-2.ursala new file mode 100644 index 0000000000..4a293f0fa5 --- /dev/null +++ b/Task/Scope-modifiers/Ursala/scope-modifiers-2.ursala @@ -0,0 +1,10 @@ +foo = 1 + +#hide+ + +foo = 2 +bar = 3 + +#hide- + +x = foo diff --git a/Task/Scope-modifiers/Ursala/scope-modifiers-3.ursala b/Task/Scope-modifiers/Ursala/scope-modifiers-3.ursala new file mode 100644 index 0000000000..07ed7c0a49 --- /dev/null +++ b/Task/Scope-modifiers/Ursala/scope-modifiers-3.ursala @@ -0,0 +1,13 @@ +foo = 1 + +#hide+ + +#export+ +foo = 2 +#export- + +bar = 3 + +#hide- + +x = foo diff --git a/Task/Scope-modifiers/Ursala/scope-modifiers-4.ursala b/Task/Scope-modifiers/Ursala/scope-modifiers-4.ursala new file mode 100644 index 0000000000..b8699e7308 --- /dev/null +++ b/Task/Scope-modifiers/Ursala/scope-modifiers-4.ursala @@ -0,0 +1,4 @@ +#import std + +cat = 3 +a_string = std-cat('foo','bar') diff --git a/Task/Secure-temporary-file/0DESCRIPTION b/Task/Secure-temporary-file/0DESCRIPTION new file mode 100644 index 0000000000..8bb90b7a3b --- /dev/null +++ b/Task/Secure-temporary-file/0DESCRIPTION @@ -0,0 +1 @@ +Create a temporary file, '''securely and exclusively''' (opening it such that there are no possible [[race condition|race conditions]]). It's fine assuming local filesystem semantics (NFS or other networking filesystems can have signficantly more complicated semantics for satisfying the "no race conditions" criteria). The function should automatically resolve name collisions and should only fail in cases where permission is denied, the filesystem is read-only or full, or similar conditions exist (returning an error or raising an exception as appropriate to the language/environment). diff --git a/Task/Secure-temporary-file/1META.yaml b/Task/Secure-temporary-file/1META.yaml new file mode 100644 index 0000000000..f6d82c59ad --- /dev/null +++ b/Task/Secure-temporary-file/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Programming environment operations diff --git a/Task/Secure-temporary-file/Ada/secure-temporary-file.ada b/Task/Secure-temporary-file/Ada/secure-temporary-file.ada new file mode 100644 index 0000000000..94e7b361cd --- /dev/null +++ b/Task/Secure-temporary-file/Ada/secure-temporary-file.ada @@ -0,0 +1,14 @@ +with Ada.Text_Io; use Ada.Text_Io; + +procedure Temp_File is + Temp : File_Type; + Contents : String(1..80); + Length : Natural; +begin + -- Create a temporary file + Create(File => Temp); + Put_Line(File => Temp, Item => "Hello World"); + Reset(File => Temp, Mode => In_File); + Get_Line(File => Temp, Item => Contents, Last => Length); + Put_Line(Contents(1..Length)); +end Temp_File; diff --git a/Task/Secure-temporary-file/BBC-BASIC/secure-temporary-file.bbc b/Task/Secure-temporary-file/BBC-BASIC/secure-temporary-file.bbc new file mode 100644 index 0000000000..deb7a772bb --- /dev/null +++ b/Task/Secure-temporary-file/BBC-BASIC/secure-temporary-file.bbc @@ -0,0 +1,27 @@ + file% = FNopentempfile + IF file% = 0 ERROR 100, "Failed to open temp file" + PRINT #file%, "Hello world!" + PTR#file% = 0 + INPUT #file%, message$ + CLOSE #file% + PRINT message$ + END + + DEF FNopentempfile + LOCAL pname%, hfile%, chan% + OPEN_EXISTING = 3 + FILE_FLAG_DELETE_ON_CLOSE = &4000000 + GENERIC_READ = &80000000 + GENERIC_WRITE = &40000000 + INVALID_HANDLE_VALUE = -1 + DIM pname% LOCAL 260 + FOR chan% = 5 TO 12 + IF @hfile%(chan%) = 0 EXIT FOR + NEXT + IF chan% > 12 THEN = 0 + SYS "GetTempFileName", @tmp$, "BBC", 0, pname% + SYS "CreateFile", $$pname%, GENERIC_READ OR GENERIC_WRITE, 0, 0, \ + \ OPEN_EXISTING, FILE_FLAG_DELETE_ON_CLOSE, 0 TO hfile% + IF hfile% = INVALID_HANDLE_VALUE THEN = 0 + @hfile%(chan%) = hfile% + = chan% diff --git a/Task/Secure-temporary-file/C/secure-temporary-file-1.c b/Task/Secure-temporary-file/C/secure-temporary-file-1.c new file mode 100644 index 0000000000..d3bdfc1668 --- /dev/null +++ b/Task/Secure-temporary-file/C/secure-temporary-file-1.c @@ -0,0 +1,14 @@ +#include +#include + +int main(void) +{ + FILE *fh = tmpfile(); /* file is automatically deleted when program exits */ + /* do stuff with stream "fh" */ + fclose(fh); + /* The C standard library also has a tmpnam() function to create a file + for you to open later. But you should not use it because someone else might + be able to open the file from the time it is created by this function to the + time you open it. */ + return 0; +} diff --git a/Task/Secure-temporary-file/C/secure-temporary-file-2.c b/Task/Secure-temporary-file/C/secure-temporary-file-2.c new file mode 100644 index 0000000000..d59d6c4a25 --- /dev/null +++ b/Task/Secure-temporary-file/C/secure-temporary-file-2.c @@ -0,0 +1,12 @@ +#include +#include + +int main(void) +{ + char filename[] = "/tmp/prefixXXXXXX"; + int fd = mkstemp(filename); + puts(filename); + /* do stuff with file descriptor "fd" */ + close(fd); + return 0; +} diff --git a/Task/Secure-temporary-file/Clojure/secure-temporary-file.clj b/Task/Secure-temporary-file/Clojure/secure-temporary-file.clj new file mode 100644 index 0000000000..2300e7c00d --- /dev/null +++ b/Task/Secure-temporary-file/Clojure/secure-temporary-file.clj @@ -0,0 +1,2 @@ +user=> (doto (java.io.File/createTempFile "pre" ".suff") .deleteOnExit) +# diff --git a/Task/Secure-temporary-file/D/secure-temporary-file.d b/Task/Secure-temporary-file/D/secure-temporary-file.d new file mode 100644 index 0000000000..34fb737799 --- /dev/null +++ b/Task/Secure-temporary-file/D/secure-temporary-file.d @@ -0,0 +1,15 @@ +module tempfile ; +import tango.io.TempFile, tango.io.Stdout ; + +void main(char[][] args) { + + // create a temporary file that will be deleted automatically when out of scope + auto tempTransient = new TempFile(TempFile.Transient) ; + Stdout(tempTransient.path()).newline ; + + // create a temporary file, still persist after the TempFile object has been destroyed + auto tempPermanent = new TempFile(TempFile.Permanent) ; + Stdout(tempPermanent.path()).newline ; + + // both can only be accessed by the current user (the program?). +} diff --git a/Task/Secure-temporary-file/Go/secure-temporary-file.go b/Task/Secure-temporary-file/Go/secure-temporary-file.go new file mode 100644 index 0000000000..e48c66a889 --- /dev/null +++ b/Task/Secure-temporary-file/Go/secure-temporary-file.go @@ -0,0 +1,3 @@ +import "io/ioutil" + +file_obj, err := ioutil.TempFile("", "foo") diff --git a/Task/Secure-temporary-file/Groovy/secure-temporary-file.groovy b/Task/Secure-temporary-file/Groovy/secure-temporary-file.groovy new file mode 100644 index 0000000000..69ceccb281 --- /dev/null +++ b/Task/Secure-temporary-file/Groovy/secure-temporary-file.groovy @@ -0,0 +1,3 @@ +def file = File.createTempFile( "xxx", ".txt" ) +file.deleteOnExit() +println file diff --git a/Task/Secure-temporary-file/Haskell/secure-temporary-file.hs b/Task/Secure-temporary-file/Haskell/secure-temporary-file.hs new file mode 100644 index 0000000000..99a8ce3121 --- /dev/null +++ b/Task/Secure-temporary-file/Haskell/secure-temporary-file.hs @@ -0,0 +1,5 @@ +import System.IO + +main = do (pathOfTempFile, h) <- openTempFile "." "prefix.suffix" -- first argument is path to directory where you want to put it + -- do stuff with it here; "h" is the Handle to the opened file + return () diff --git a/Task/Secure-temporary-file/HicEst/secure-temporary-file.hicest b/Task/Secure-temporary-file/HicEst/secure-temporary-file.hicest new file mode 100644 index 0000000000..d696ce7cb1 --- /dev/null +++ b/Task/Secure-temporary-file/HicEst/secure-temporary-file.hicest @@ -0,0 +1,12 @@ +! The "scratch" option opens a file exclusively for the current process. +! A scratch file is automatically deleted upon process termination. + +OPEN( FIle='TemporaryAndExclusive', SCRatch, IOStat=ErrNr) +WRITE(FIle='TemporaryAndExclusive') "something" +WRITE(FIle='TemporaryAndExclusive', CLoSe=1) ! explicit "close" deletes file + +! Without "scratch" access can be controlled by "denyread", "denywrite", "denyreadwrite" options. + +OPEN( FIle='DenyForOthers', DenyREAdWRIte, IOStat=ErrNr) +WRITE(FIle='DenyForOthers') "something" +WRITE(FIle='DenyForOthers', DELETE=1) diff --git a/Task/Secure-temporary-file/Java/secure-temporary-file.java b/Task/Secure-temporary-file/Java/secure-temporary-file.java new file mode 100644 index 0000000000..accbc7b3ea --- /dev/null +++ b/Task/Secure-temporary-file/Java/secure-temporary-file.java @@ -0,0 +1,13 @@ +import java.io.File; + +try { + // Create temp file + File filename = File.createTempFile("prefix", ".suffix"); + + // Delete temp file when program exits + filename.deleteOnExit(); + + System.out.println(filename); + +} catch (IOException e) { +} diff --git a/Task/Secure-temporary-file/Lua/secure-temporary-file.lua b/Task/Secure-temporary-file/Lua/secure-temporary-file.lua new file mode 100644 index 0000000000..a178bace59 --- /dev/null +++ b/Task/Secure-temporary-file/Lua/secure-temporary-file.lua @@ -0,0 +1,5 @@ +fp = io.tmpfile() + +-- do some file operations + +fp:close() diff --git a/Task/Secure-temporary-file/Mathematica/secure-temporary-file.math b/Task/Secure-temporary-file/Mathematica/secure-temporary-file.math new file mode 100644 index 0000000000..9a3d3a0036 --- /dev/null +++ b/Task/Secure-temporary-file/Mathematica/secure-temporary-file.math @@ -0,0 +1,2 @@ +tmp = OpenWrite[] +Close[tmp] diff --git a/Task/Secure-temporary-file/OCaml/secure-temporary-file.ocaml b/Task/Secure-temporary-file/OCaml/secure-temporary-file.ocaml new file mode 100644 index 0000000000..fb3694b244 --- /dev/null +++ b/Task/Secure-temporary-file/OCaml/secure-temporary-file.ocaml @@ -0,0 +1,2 @@ +# Filename.temp_file "prefix." ".suffix" ;; +- : string = "/home/blue_prawn/tmp/prefix.301f82.suffix" diff --git a/Task/Secure-temporary-file/Octave/secure-temporary-file.octave b/Task/Secure-temporary-file/Octave/secure-temporary-file.octave new file mode 100644 index 0000000000..1d4e60802a --- /dev/null +++ b/Task/Secure-temporary-file/Octave/secure-temporary-file.octave @@ -0,0 +1,3 @@ + [FID, MSG] = tmpfile(); % Return the file ID corresponding to a new temporary + filename = tmpnam (...); % generates temporary file name, but does not open file + [FID, NAME, MSG] = mkstemp (TEMPLATE, DELETE); % Return the file ID corresponding to a new temporary file with a unique name created from TEMPLATE. diff --git a/Task/Secure-temporary-file/PHP/secure-temporary-file.php b/Task/Secure-temporary-file/PHP/secure-temporary-file.php new file mode 100644 index 0000000000..7c7e4a49f9 --- /dev/null +++ b/Task/Secure-temporary-file/PHP/secure-temporary-file.php @@ -0,0 +1,9 @@ +$fh = tmpfile(); +// do stuff with $fh +fclose($fh); +// file removed when closed + +// or: +$filename = tempnam('/tmp', 'prefix'); +echo "$filename\n"; +// open $filename and do stuff with it diff --git a/Task/Secure-temporary-file/Pascal/secure-temporary-file.pascal b/Task/Secure-temporary-file/Pascal/secure-temporary-file.pascal new file mode 100644 index 0000000000..ef98291609 --- /dev/null +++ b/Task/Secure-temporary-file/Pascal/secure-temporary-file.pascal @@ -0,0 +1,14 @@ +Program TempFileDemo; + +uses + SysUtils; + +var + tempFile: text; + +begin + assign (Tempfile, GetTempFileName); + rewrite (tempFile); + writeln (tempFile, 5); + close (tempFile); +end. diff --git a/Task/Secure-temporary-file/Perl/secure-temporary-file-1.pl b/Task/Secure-temporary-file/Perl/secure-temporary-file-1.pl new file mode 100644 index 0000000000..a139b31bd1 --- /dev/null +++ b/Task/Secure-temporary-file/Perl/secure-temporary-file-1.pl @@ -0,0 +1,6 @@ +use File::Temp qw(tempfile); +$fh = tempfile(); +($fh2, $filename) = tempfile(); # this file stays around by default +print "$filename\n"; +close $fh; +close $fh2; diff --git a/Task/Secure-temporary-file/Perl/secure-temporary-file-2.pl b/Task/Secure-temporary-file/Perl/secure-temporary-file-2.pl new file mode 100644 index 0000000000..12b0063e5f --- /dev/null +++ b/Task/Secure-temporary-file/Perl/secure-temporary-file-2.pl @@ -0,0 +1,4 @@ +use File::Temp; +$fh = new File::Temp; +print $fh->filename, "\n"; +close $fh; diff --git a/Task/Secure-temporary-file/PicoLisp/secure-temporary-file.l b/Task/Secure-temporary-file/PicoLisp/secure-temporary-file.l new file mode 100644 index 0000000000..4cbf857b4b --- /dev/null +++ b/Task/Secure-temporary-file/PicoLisp/secure-temporary-file.l @@ -0,0 +1,11 @@ +: (out (tmp "foo") (println 123)) # Write tempfile +-> 123 + +: (in (tmp "foo") (read)) # Read tempfile +-> 123 + +: (let F (tmp "foo") + (ctl F # Get exclusive lock + (let N (in F (read)) # Atomic increment + (out F (println (inc N))) ) ) ) +-> 124 diff --git a/Task/Secure-temporary-file/PureBasic/secure-temporary-file.purebasic b/Task/Secure-temporary-file/PureBasic/secure-temporary-file.purebasic new file mode 100644 index 0000000000..1759cafb34 --- /dev/null +++ b/Task/Secure-temporary-file/PureBasic/secure-temporary-file.purebasic @@ -0,0 +1,25 @@ +Procedure.s TempFile() + Protected a, Result$ + + For a = 0 To 9999 + Result$ = GetTemporaryDirectory() + StringField(GetFilePart(ProgramFilename()),1,".") + Result$ + "_" + Str(ElapsedMilliseconds()) + "_(" + RSet(Str(a),4,"0") + ").tmp" + If FileSize(Result$) = -1 ; -1 = File not found + ProcedureReturn Result$ + EndIf + Next + + ProcedureReturn "" +EndProcedure + + +Define File, File$ + +File$ = TempFile() +If File$ <> "" + File = CreateFile(#PB_Any, File$) + If File <> 0 + WriteString(File, "Some temporary data here...") + CloseFile(File) + EndIf +EndIf diff --git a/Task/Secure-temporary-file/Python/secure-temporary-file-1.py b/Task/Secure-temporary-file/Python/secure-temporary-file-1.py new file mode 100644 index 0000000000..2509b1753a --- /dev/null +++ b/Task/Secure-temporary-file/Python/secure-temporary-file-1.py @@ -0,0 +1,9 @@ +>>> import tempfile +>>> invisible = tempfile.TemporaryFile() +>>> invisible.name +'' +>>> visible = tempfile.NamedTemporaryFile() +>>> visible.name +'/tmp/tmpZNfc_s' +>>> visible.close() +>>> invisible.close() diff --git a/Task/Secure-temporary-file/Python/secure-temporary-file-2.py b/Task/Secure-temporary-file/Python/secure-temporary-file-2.py new file mode 100644 index 0000000000..e8046e81e0 --- /dev/null +++ b/Task/Secure-temporary-file/Python/secure-temporary-file-2.py @@ -0,0 +1,5 @@ +fd, path = tempfile.mkstemp() +try: + # use the path or the file descriptor +finally: + os.close(fd) diff --git a/Task/Secure-temporary-file/Racket/secure-temporary-file.rkt b/Task/Secure-temporary-file/Racket/secure-temporary-file.rkt new file mode 100644 index 0000000000..245cc24d09 --- /dev/null +++ b/Task/Secure-temporary-file/Racket/secure-temporary-file.rkt @@ -0,0 +1,2 @@ +#lang racket +(make-temporary-file) diff --git a/Task/Secure-temporary-file/Ruby/secure-temporary-file.rb b/Task/Secure-temporary-file/Ruby/secure-temporary-file.rb new file mode 100644 index 0000000000..e7130b3dc4 --- /dev/null +++ b/Task/Secure-temporary-file/Ruby/secure-temporary-file.rb @@ -0,0 +1,8 @@ +irb(main):001:0> require 'tempfile' +=> true +irb(main):002:0> f = Tempfile.new('foo') +=> # +irb(main):003:0> f.path +=> "/tmp/foo20081226-307-10p746n-0" +irb(main):004:0> f.close +=> nil diff --git a/Task/Secure-temporary-file/Scala/secure-temporary-file.scala b/Task/Secure-temporary-file/Scala/secure-temporary-file.scala new file mode 100644 index 0000000000..78a2159a63 --- /dev/null +++ b/Task/Secure-temporary-file/Scala/secure-temporary-file.scala @@ -0,0 +1,14 @@ +import java.io.File + +try { + // Create temp file + val filename = File.createTempFile("prefix", ".suffix") + + // Delete temp file when program exits + filename.deleteOnExit + + System.out.println(filename) + +} catch { + case _: java.io.IOException => +} diff --git a/Task/Secure-temporary-file/Standard-ML/secure-temporary-file.ml b/Task/Secure-temporary-file/Standard-ML/secure-temporary-file.ml new file mode 100644 index 0000000000..85f58b1ce6 --- /dev/null +++ b/Task/Secure-temporary-file/Standard-ML/secure-temporary-file.ml @@ -0,0 +1 @@ +val filename = OS.FileSys.tmpName (); diff --git a/Task/Secure-temporary-file/TUSCRIPT/secure-temporary-file.tuscript b/Task/Secure-temporary-file/TUSCRIPT/secure-temporary-file.tuscript new file mode 100644 index 0000000000..c82ebc1316 --- /dev/null +++ b/Task/Secure-temporary-file/TUSCRIPT/secure-temporary-file.tuscript @@ -0,0 +1,6 @@ +$$ MODE TUSCRIPT +tmpfile="test.txt" +ERROR/STOP CREATE (tmpfile,seq-E,-std-) +text="hello world" +FILE $tmpfile = text +- tmpfile "test.txt" can only be accessed by one user an will be deleted upon programm termination diff --git a/Task/Secure-temporary-file/Tcl/secure-temporary-file.tcl b/Task/Secure-temporary-file/Tcl/secure-temporary-file.tcl new file mode 100644 index 0000000000..df2c1b66a4 --- /dev/null +++ b/Task/Secure-temporary-file/Tcl/secure-temporary-file.tcl @@ -0,0 +1 @@ +set chan [file tempfile filenameVar] diff --git a/Task/Secure-temporary-file/UNIX-Shell/secure-temporary-file.sh b/Task/Secure-temporary-file/UNIX-Shell/secure-temporary-file.sh new file mode 100644 index 0000000000..baff39ab0d --- /dev/null +++ b/Task/Secure-temporary-file/UNIX-Shell/secure-temporary-file.sh @@ -0,0 +1,13 @@ +RESTOREUMASK=$(umask) +TRY=0 +while :; do + TRY=$(( TRY + 1 )) + umask 0077 + MYTMP=${TMPDIR:-/tmp}/$(basename $0).$$.$(date +%s).$TRY + trap "rm -fr $MYTMP" EXIT + mkdir "$MYTMP" 2>/dev/null && break +done +umask "$RESTOREUMASK" +cd "$MYTMP" || { + echo "Temporary directory failure on $MYTMP" >&2 + exit 1; } diff --git a/Task/Self-describing-numbers/0DESCRIPTION b/Task/Self-describing-numbers/0DESCRIPTION new file mode 100644 index 0000000000..87d87ac572 --- /dev/null +++ b/Task/Self-describing-numbers/0DESCRIPTION @@ -0,0 +1,14 @@ +There are several integers numbers called "self-describing" or "[[wp:Self-descriptive number|self-descriptive]]" + +Integers with the property that, when digit positions are labeled 0 to N-1, the digit in each position is equal to the number of times that that digit appears in the number. + +For example 2020 is a four digit self describing number. + +Position "0" has value 2 and there is two 0 in the number. Position "1" has value 0 because there are not 1's in the number. +Position "2" has value 2 and there is two 2. And the position "3" has value 0 and there are zero 3's. + +Self-describing numbers < 100.000.000: 1210 - 2020 - 21200 - 3211000 - 42101000 + +;Task Description +# Write a function/routine/method/... that will check whether a given positive integer is self-describing. +# As an optional stretch goal - generate and display the set of self-describing numbers. diff --git a/Task/Self-describing-numbers/AWK/self-describing-numbers.awk b/Task/Self-describing-numbers/AWK/self-describing-numbers.awk new file mode 100644 index 0000000000..6a0528d7ec --- /dev/null +++ b/Task/Self-describing-numbers/AWK/self-describing-numbers.awk @@ -0,0 +1,17 @@ +# syntax: GAWK -f SELF-DESCRIBING_NUMBERS.AWK +BEGIN { + for (n=1; n<=100000000; n++) { + if (is_self_describing(n)) { + print(n) + } + } + exit(0) +} +function is_self_describing(n, i) { + for (i=1; i<=length(n); i++) { + if (substr(n,i,1) != gsub(i-1,"&",n)) { + return(0) + } + } + return(1) +} diff --git a/Task/Self-describing-numbers/Ada/self-describing-numbers.ada b/Task/Self-describing-numbers/Ada/self-describing-numbers.ada new file mode 100644 index 0000000000..4a9772a0a5 --- /dev/null +++ b/Task/Self-describing-numbers/Ada/self-describing-numbers.ada @@ -0,0 +1,25 @@ +with Ada.Text_IO; use Ada.Text_IO; +procedure SelfDesc is + subtype Desc_Int is Long_Integer range 0 .. 10**10-1; + + function isDesc (innum : Desc_Int) return Boolean is + subtype S_Int is Natural range 0 .. 10; + type S_Int_Arr is array (0 .. 9) of S_Int; + ref, cnt : S_Int_Arr := (others => 0); + n, digit : S_Int := 0; num : Desc_Int := innum; + begin + loop + digit := S_Int (num mod 10); + ref (9 - n) := digit; cnt (digit) := cnt (digit) + 1; + num := num / 10; exit when num = 0; n := n + 1; + end loop; + return ref (9 - n .. 9) = cnt (0 .. n); + end isDesc; + +begin + for i in Desc_Int range 1 .. 100_000_000 loop + if isDesc (i) then + Put_Line (Desc_Int'Image (i)); + end if; + end loop; +end SelfDesc; diff --git a/Task/Self-describing-numbers/AutoHotkey/self-describing-numbers.ahk b/Task/Self-describing-numbers/AutoHotkey/self-describing-numbers.ahk new file mode 100644 index 0000000000..6644e586be --- /dev/null +++ b/Task/Self-describing-numbers/AutoHotkey/self-describing-numbers.ahk @@ -0,0 +1,23 @@ +; The following directives and commands speed up execution: +#NoEnv +SetBatchlines -1 +ListLines Off +Process, Priority,, high + +MsgBox % 2020 ": " IsSelfDescribing(2020) "`n" 1337 ": " IsSelfDescribing(1337) "`n" 1210 ": " IsSelfDescribing(1210) +Loop 100000000 + If IsSelfDescribing(A_Index) + list .= A_Index "`n" +MsgBox % "Self-describing numbers < 100000000 :`n" . list + +CountSubstring(fullstring, substring){ + StringReplace, junk, fullstring, %substring%, , UseErrorLevel + return errorlevel +} + +IsSelfDescribing(number){ + Loop Parse, number + If Not CountSubString(number, A_Index-1) = A_LoopField + return false + return true +} diff --git a/Task/Self-describing-numbers/BASIC/self-describing-numbers.basic b/Task/Self-describing-numbers/BASIC/self-describing-numbers.basic new file mode 100644 index 0000000000..b16a3d1a78 --- /dev/null +++ b/Task/Self-describing-numbers/BASIC/self-describing-numbers.basic @@ -0,0 +1,24 @@ +Dim x, r, b, c, n, m As Integer +Dim a, d As String +Dim v(10), w(10) As Integer +Cls +For x = 1 To 5000000 + a$ = ltrim$(Str$(x)) + b = Len(a$) + For c = 1 To b + d$ = Mid$(a$, c, 1) + v(Val(d$)) = v(Val(d$)) + 1 + w(c - 1) = Val(d$) + Next c + r = 0 + For n = 0 To 10 + If v(n) = w(n) Then r = r + 1 + v(n) = 0 + w(n) = 0 + Next n + If r = 11 Then Print x; " Yes,is autodescriptive number" +Next x +Print +Print "End" +sleep +end diff --git a/Task/Self-describing-numbers/BBC-BASIC/self-describing-numbers.bbc b/Task/Self-describing-numbers/BBC-BASIC/self-describing-numbers.bbc new file mode 100644 index 0000000000..5cbe027496 --- /dev/null +++ b/Task/Self-describing-numbers/BBC-BASIC/self-describing-numbers.bbc @@ -0,0 +1,16 @@ + FOR N = 1 TO 5E7 + IF FNselfdescribing(N) PRINT N + NEXT + END + + DEF FNselfdescribing(N%) + LOCAL D%(), I%, L%, O% + DIM D%(9) + O% = N% + L% = LOG(N%) + WHILE N% + I% = N% MOD 10 + D%(I%) += 10^(L%-I%) + N% DIV=10 + ENDWHILE + = O% = SUM(D%()) diff --git a/Task/Self-describing-numbers/C/self-describing-numbers-1.c b/Task/Self-describing-numbers/C/self-describing-numbers-1.c new file mode 100644 index 0000000000..ad7c2be178 --- /dev/null +++ b/Task/Self-describing-numbers/C/self-describing-numbers-1.c @@ -0,0 +1,45 @@ +#include + +int self_desc(const char *s) +{ + unsigned char cnt[10] = {0}; + int i; + for (i = 0; s[i] != '\0'; i++) cnt[s[i] - '0']++; + for (i = 0; s[i] != '\0'; i++) if (cnt[i] + '0' != s[i]) return 0; + return 1; +} + +void gen(int n) +{ + char d[11]; + int one, i; + /* one = 0 may be confusing. 'one' is the number of digit 1s */ + for (one = 0; one <= 2 && one < n - 2; one++) { + for (i = 0; i <= n; d[i++] = 0); + + if ((d[0] = n - 2 - one) != 2) { + d[2] = d[d[0] - 0] = 1; + d[1] = 2; + } else { + d[1] = one ? 1 : 0; + d[2] = 2; + } + + for (i = 0; i < n; d[i++] += '0'); + if (self_desc(d)) printf("%s\n", d); + } +} + +int main() +{ + int i; + const char *nums[] = { "1210", "1337", "2020", "21200", "3211000", "42101000", 0}; + + for (i = 0; nums[i]; i++) + printf("%s is %sself describing\n", nums[i], + self_desc(nums[i]) ? "" : "not "); + + printf("\nAll autobiograph numbers:\n"); + for (i = 0; i < 11; i++) gen(i); + return 0; +} diff --git a/Task/Self-describing-numbers/C/self-describing-numbers-2.c b/Task/Self-describing-numbers/C/self-describing-numbers-2.c new file mode 100644 index 0000000000..4201b39332 --- /dev/null +++ b/Task/Self-describing-numbers/C/self-describing-numbers-2.c @@ -0,0 +1,15 @@ +1210 is self describing +1337 is not self describing +2020 is self describing +21200 is self describing +3211000 is self describing +42101000 is self describing + +All autobiograph numbers: +2020 +1210 +21200 +3211000 +42101000 +521001000 +6210001000 diff --git a/Task/Self-describing-numbers/C/self-describing-numbers-3.c b/Task/Self-describing-numbers/C/self-describing-numbers-3.c new file mode 100644 index 0000000000..047679cae1 --- /dev/null +++ b/Task/Self-describing-numbers/C/self-describing-numbers-3.c @@ -0,0 +1,26 @@ +#include + +inline int self_desc(unsigned long long xx) +{ + register unsigned int d, x; + unsigned char cnt[10] = {0}, dig[10] = {0}; + + for (d = 0; xx > ~0U; xx /= 10) + cnt[ dig[d++] = xx % 10 ]++; + + for (x = xx; x; x /= 10) + cnt[ dig[d++] = x % 10 ]++; + + while(d-- && dig[x++] == cnt[d]); + + return d == -1; +} + +int main() +{ + int i; + for (i = 1; i < 100000000; i++) /* don't handle 0 */ + if (self_desc(i)) printf("%d\n", i); + + return 0; +} diff --git a/Task/Self-describing-numbers/C/self-describing-numbers-4.c b/Task/Self-describing-numbers/C/self-describing-numbers-4.c new file mode 100644 index 0000000000..fe98e74c50 --- /dev/null +++ b/Task/Self-describing-numbers/C/self-describing-numbers-4.c @@ -0,0 +1,5 @@ +1210 +2020 +21200 +3211000 +42101000 diff --git a/Task/Self-describing-numbers/D/self-describing-numbers-1.d b/Task/Self-describing-numbers/D/self-describing-numbers-1.d new file mode 100644 index 0000000000..3dfabd2a32 --- /dev/null +++ b/Task/Self-describing-numbers/D/self-describing-numbers-1.d @@ -0,0 +1,10 @@ +import std.stdio, std.algorithm, std.range, std.conv; + +bool isSelfDescribing(in long n) { + auto nu = n.text().map!q{a - '0'}(); + return nu.equal( nu.length.iota().map!(a => count(nu, a))() ); +} + +void main() { + writeln(iota(4_000_000).filter!isSelfDescribing()); +} diff --git a/Task/Self-describing-numbers/D/self-describing-numbers-2.d b/Task/Self-describing-numbers/D/self-describing-numbers-2.d new file mode 100644 index 0000000000..227f5d4bbe --- /dev/null +++ b/Task/Self-describing-numbers/D/self-describing-numbers-2.d @@ -0,0 +1,42 @@ +import std.stdio; + +bool isSelfDescribing2(long n) { + if (n <= 0) + return false; + + __gshared static uint[10] digits, d; + digits[] = 0; + d[] = 0; + int i; + if (n < uint.max) { + uint nu = cast(uint)n; + for (i = 0; nu > 0 && i < digits.length; nu /= 10, i++) { + d[i] = cast(ubyte)(nu % 10); + digits[d[i]]++; + } + if (nu > 0) + return false; + } else { + for (i = 0; n > 0 && i < digits.length; n /= 10, i++) { + d[i] = cast(ubyte)(n % 10); + digits[d[i]]++; + } + if (n > 0) + return false; + } + + foreach (k; 0 .. i) + if (d[k] != digits[i - k - 1]) + return false; + return true; +} + +void main() { + foreach (x; [1210, 2020, 21200, 3211000, + 42101000, 521001000, 6210001000]) + assert(isSelfDescribing2(x)); + + foreach (i; 0 .. 4_000_000) + if (isSelfDescribing2(i)) + writeln(i); +} diff --git a/Task/Self-describing-numbers/Erlang/self-describing-numbers.erl b/Task/Self-describing-numbers/Erlang/self-describing-numbers.erl new file mode 100644 index 0000000000..9a90829279 --- /dev/null +++ b/Task/Self-describing-numbers/Erlang/self-describing-numbers.erl @@ -0,0 +1,2 @@ +sdn(N) -> lists:map(fun(S)->length(lists:filter(fun(C)->C-$0==S end,N))+$0 end,lists:seq(0,length(N)-1))==N. +gen(M) -> lists:filter(fun(N)->sdn(integer_to_list(N)) end,lists:seq(0,M)). diff --git a/Task/Self-describing-numbers/Forth/self-describing-numbers.fth b/Task/Self-describing-numbers/Forth/self-describing-numbers.fth new file mode 100644 index 0000000000..9a72965fdd --- /dev/null +++ b/Task/Self-describing-numbers/Forth/self-describing-numbers.fth @@ -0,0 +1,16 @@ +\ where unavailable. +: third ( A b c -- A b c A ) >r over r> swap ; +: (.) ( u -- c-addr u ) 0 <# #s #> ; + +\ COUNT is a standard word with a very different meaning, so this +\ would typically be beheaded, or given another name, or otherwise +\ given a short lifespan, so to speak. +: count ( c-addr1 u1 c -- c-addr1 u1 c+1 u ) + 0 2over bounds do + over i c@ = if 1+ then + loop swap 1+ swap ; + +: self-descriptive? ( u -- f ) + (.) [char] 0 third third bounds ?do + count i c@ [char] 0 - <> if drop 2drop false unloop exit then + loop drop 2drop true ; diff --git a/Task/Self-describing-numbers/Go/self-describing-numbers.go b/Task/Self-describing-numbers/Go/self-describing-numbers.go new file mode 100644 index 0000000000..cc46726b23 --- /dev/null +++ b/Task/Self-describing-numbers/Go/self-describing-numbers.go @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" + "strconv" + "strings" +) + +// task 1 requirement +func sdn(n int64) bool { + if n >= 1e10 { + return false + } + s := strconv.FormatInt(n, 10) + for d, p := range s { + if int(p)-'0' != strings.Count(s, strconv.Itoa(d)) { + return false + } + } + return true +} + +// task 2 code (takes a while to run) +func main() { + for n := int64(0); n < 1e10; n++ { + if sdn(n) { + fmt.Println(n) + } + } +} diff --git a/Task/Self-describing-numbers/Haskell/self-describing-numbers-1.hs b/Task/Self-describing-numbers/Haskell/self-describing-numbers-1.hs new file mode 100644 index 0000000000..73d620be7b --- /dev/null +++ b/Task/Self-describing-numbers/Haskell/self-describing-numbers-1.hs @@ -0,0 +1,16 @@ +import Data.Char + +count :: Int -> [Int] -> Int +count x = length . filter (x ==) + +isSelfDescribing :: Integer -> Bool +isSelfDescribing n = + nu == f where + nu = map digitToInt (show n) + f = map (\a -> count a nu) [0 .. ((length nu)-1)] + +main = do + let tests = [1210, 2020, 21200, 3211000, + 42101000, 521001000, 6210001000] + print $ map isSelfDescribing tests + print $ filter isSelfDescribing [0 .. 4000000] diff --git a/Task/Self-describing-numbers/Haskell/self-describing-numbers-2.hs b/Task/Self-describing-numbers/Haskell/self-describing-numbers-2.hs new file mode 100644 index 0000000000..a63a7d1a74 --- /dev/null +++ b/Task/Self-describing-numbers/Haskell/self-describing-numbers-2.hs @@ -0,0 +1,21 @@ +import Data.Char (intToDigit) +import Control.Monad (replicateM, forM_) + +count :: Int -> [Int] -> Int +count x = length . filter (x ==) + +-- all the combinations of n digits of base n +-- a base-n number are represented as a list of ints, one per digit +allBaseNNumsOfLength :: Int -> [[Int]] +allBaseNNumsOfLength n = replicateM n [0..n-1] + +isSelfDescribing :: [Int] -> Bool +isSelfDescribing num = + all (\(i,x) -> x == count i num) $ zip [0..] num + +-- translate it back into an integer in base-10 +decimalize :: [Int] -> Int +decimalize = read . map intToDigit + +main = forM_ [1..7] $ + print . map decimalize . filter isSelfDescribing . allBaseNNumsOfLength diff --git a/Task/Self-describing-numbers/Icon/self-describing-numbers-1.icon b/Task/Self-describing-numbers/Icon/self-describing-numbers-1.icon new file mode 100644 index 0000000000..2735fd3b01 --- /dev/null +++ b/Task/Self-describing-numbers/Icon/self-describing-numbers-1.icon @@ -0,0 +1,28 @@ +procedure count (test_item, str) + result := 0 + every item := !str do + if test_item == item then result +:= 1 + return result +end + +procedure is_self_describing (n) + ns := string (n) # convert to a string + every i := 1 to *ns do { + if count (string(i-1), ns) ~= ns[i] then fail + } + return 1 # success +end + +# generator for creating self_describing_numbers +procedure self_describing_numbers () + n := 1 + repeat { + if is_self_describing(n) then suspend n + n +:= 1 + } +end + +procedure main () + # write the first 4 self-describing numbers + every write (self_describing_numbers ()\4) +end diff --git a/Task/Self-describing-numbers/Icon/self-describing-numbers-2.icon b/Task/Self-describing-numbers/Icon/self-describing-numbers-2.icon new file mode 100644 index 0000000000..38bb2a2695 --- /dev/null +++ b/Task/Self-describing-numbers/Icon/self-describing-numbers-2.icon @@ -0,0 +1,11 @@ +procedure is_self_describing (n) + ns := string (n) # convert to a string + every i := 1 to *ns do { + if count (string(i-1), ns) ~= ns[i] then fail + } + return n # on success, return the self-described number +end + +procedure self_describing_numbers () + suspend is_self_describing(seq()) +end diff --git a/Task/Self-describing-numbers/J/self-describing-numbers-1.j b/Task/Self-describing-numbers/J/self-describing-numbers-1.j new file mode 100644 index 0000000000..0cbc5ba028 --- /dev/null +++ b/Task/Self-describing-numbers/J/self-describing-numbers-1.j @@ -0,0 +1,3 @@ + digits =: 10&#.^:_1 + counts =: _1 + [: #/.~ i.@:# , ] + selfdesc =: = counts&.digits"0 NB. Note use of "under" diff --git a/Task/Self-describing-numbers/J/self-describing-numbers-2.j b/Task/Self-describing-numbers/J/self-describing-numbers-2.j new file mode 100644 index 0000000000..f9e9ede21e --- /dev/null +++ b/Task/Self-describing-numbers/J/self-describing-numbers-2.j @@ -0,0 +1,2 @@ + selfdesc 2020 1210 21200 3211000 43101000 42101000 +1 1 1 1 0 1 diff --git a/Task/Self-describing-numbers/J/self-describing-numbers-3.j b/Task/Self-describing-numbers/J/self-describing-numbers-3.j new file mode 100644 index 0000000000..b97164807f --- /dev/null +++ b/Task/Self-describing-numbers/J/self-describing-numbers-3.j @@ -0,0 +1,2 @@ + I.@:selfdesc i. 1e6 +1210 2020 21200 diff --git a/Task/Self-describing-numbers/Java/self-describing-numbers.java b/Task/Self-describing-numbers/Java/self-describing-numbers.java new file mode 100644 index 0000000000..9b331c1a4d --- /dev/null +++ b/Task/Self-describing-numbers/Java/self-describing-numbers.java @@ -0,0 +1,27 @@ +public class SelfDescribingNumbers{ + public static boolean isSelfDescribing(int a){ + String s = Integer.toString(a); + for(int i = 0; i < s.length(); i++){ + String s0 = s.charAt(i) + ""; + int b = Integer.parseInt(s0); // number of times i-th digit must occur for it to be a self describing number + int count = 0; + for(int j = 0; j < s.length(); j++){ + int temp = Integer.parseInt(s.charAt(j) + ""); + if(temp == i){ + count++; + } + if (count > b) return false; + } + if(count != b) return false; + } + return true; + } + + public static void main(String[] args){ + for(int i = 0; i < 100000000; i++){ + if(isSelfDescribing(i)){ + System.out.println(i); + } + } + } +} diff --git a/Task/Self-describing-numbers/JavaScript/self-describing-numbers.js b/Task/Self-describing-numbers/JavaScript/self-describing-numbers.js new file mode 100644 index 0000000000..1363d87a5f --- /dev/null +++ b/Task/Self-describing-numbers/JavaScript/self-describing-numbers.js @@ -0,0 +1,28 @@ +function is_self_describing(n) { + var digits = Number(n).toString().split("").map(function(elem) {return Number(elem)}); + var len = digits.length; + var count = digits.map(function(x){return 0}); + + digits.forEach(function(digit, idx, ary) { + if (digit >= count.length) + return false + count[digit] ++; + }); + + return digits.equals(count); +} + +Array.prototype.equals = function(other) { + if (this === other) + return true; // same object + if (this.length != other.length) + return false; + for (idx in this) + if (this[idx] !== other[idx]) + return false; + return true; +} + +for (var i=1; i<=3300000; i++) + if (is_self_describing(i)) + print(i); diff --git a/Task/Self-describing-numbers/Julia/self-describing-numbers.julia b/Task/Self-describing-numbers/Julia/self-describing-numbers.julia new file mode 100644 index 0000000000..d14cc1af83 --- /dev/null +++ b/Task/Self-describing-numbers/Julia/self-describing-numbers.julia @@ -0,0 +1,11 @@ +julia> function selfie(x) + y = string(x) + return all([string(i[2]) == string(mapreduce(x->string(x)==string(i[1]-1),+,y)) for i in enumerate(y)]) +end +# method added to generic function selfie + +julia> selfie(2020) +true + +julia> selfie(2021) +false diff --git a/Task/Self-describing-numbers/K/self-describing-numbers.k b/Task/Self-describing-numbers/K/self-describing-numbers.k new file mode 100644 index 0000000000..2d11a6f887 --- /dev/null +++ b/Task/Self-describing-numbers/K/self-describing-numbers.k @@ -0,0 +1,6 @@ + sdn: {n~+/'n=/:!#n:0$'$x}' + sdn 1210 2020 2121 21200 3211000 42101000 +1 1 0 1 1 1 + + &sdn@!:1e6 +1210 2020 21200 diff --git a/Task/Self-describing-numbers/Liberty-BASIC/self-describing-numbers.liberty b/Task/Self-describing-numbers/Liberty-BASIC/self-describing-numbers.liberty new file mode 100644 index 0000000000..b096357927 --- /dev/null +++ b/Task/Self-describing-numbers/Liberty-BASIC/self-describing-numbers.liberty @@ -0,0 +1,19 @@ +'adapted from BASIC solution +FOR x = 1 TO 5000000 + a$ = TRIM$(STR$(x)) + b = LEN(a$) + FOR c = 1 TO b + d$ = MID$(a$, c, 1) + v(VAL(d$)) = v(VAL(d$)) + 1 + w(c - 1) = VAL(d$) + NEXT c + r = 0 + FOR n = 0 TO 10 + IF v(n) = w(n) THEN r = r + 1 + v(n) = 0 + w(n) = 0 + NEXT n + IF r = 11 THEN PRINT x; " is a self-describing number" +NEXT x +PRINT +PRINT "End" diff --git a/Task/Self-describing-numbers/Logo/self-describing-numbers.logo b/Task/Self-describing-numbers/Logo/self-describing-numbers.logo new file mode 100644 index 0000000000..761f651d09 --- /dev/null +++ b/Task/Self-describing-numbers/Logo/self-describing-numbers.logo @@ -0,0 +1,26 @@ +TO XX +BT +MAKE "AA (ARRAY 10 0) +MAKE "BB (ARRAY 10 0) +FOR [Z 0 9][SETITEM :Z :AA "0 SETITEM :Z :BB "0 ] + FOR [A 1 50000][ + MAKE "B COUNT :A + MAKE "Y 0 + MAKE "X 0 + MAKE "R 0 + MAKE "J 0 + MAKE "K 0 + + FOR [C 1 :B][MAKE "D ITEM :C :A + SETITEM :C - 1 :AA :D + MAKE "X ITEM :D :BB + MAKE "Y :X + 1 + SETITEM :D :BB :Y + MAKE "R 0] + FOR [Z 0 9][MAKE "J ITEM :Z :AA + MAKE "K ITEM :Z :BB + IF :J = :K [MAKE "R :R + 1]] +IF :R = 10 [PR :A] +FOR [Z 0 9][SETITEM :Z :AA "0 SETITEM :Z :BB "0 ]] +PR [END] +END diff --git a/Task/Self-describing-numbers/Lua/self-describing-numbers.lua b/Task/Self-describing-numbers/Lua/self-describing-numbers.lua new file mode 100644 index 0000000000..5ea5e3616e --- /dev/null +++ b/Task/Self-describing-numbers/Lua/self-describing-numbers.lua @@ -0,0 +1,21 @@ +function Is_self_describing( n ) + local s = tostring( n ) + + local t = {} + for i = 0, 9 do t[i] = 0 end + + for i = 1, s:len() do + local idx = tonumber( s:sub(i,i) ) + t[idx] = t[idx] + 1 + end + + for i = 1, s:len() do + if t[i-1] ~= tonumber( s:sub(i,i) ) then return false end + end + + return true +end + +for i = 1, 999999999 do + print( Is_self_describing( i ) ) +end diff --git a/Task/Self-describing-numbers/MATLAB/self-describing-numbers-1.m b/Task/Self-describing-numbers/MATLAB/self-describing-numbers-1.m new file mode 100644 index 0000000000..16a7a74656 --- /dev/null +++ b/Task/Self-describing-numbers/MATLAB/self-describing-numbers-1.m @@ -0,0 +1,5 @@ +function z = isSelfDescribing(n) + s = int2str(n)-'0'; % convert to vector of digits + y = hist(s,0:9); + z = all(y(1:length(s))==s); +end; diff --git a/Task/Self-describing-numbers/MATLAB/self-describing-numbers-2.m b/Task/Self-describing-numbers/MATLAB/self-describing-numbers-2.m new file mode 100644 index 0000000000..8080f42220 --- /dev/null +++ b/Task/Self-describing-numbers/MATLAB/self-describing-numbers-2.m @@ -0,0 +1,5 @@ +for k = 1:1e10, + if isSelfDescribing(k), + printf('%i\n',k); + end +end; diff --git a/Task/Self-describing-numbers/Mathematica/self-describing-numbers.math b/Task/Self-describing-numbers/Mathematica/self-describing-numbers.math new file mode 100644 index 0000000000..6aefaa1864 --- /dev/null +++ b/Task/Self-describing-numbers/Mathematica/self-describing-numbers.math @@ -0,0 +1 @@ +isSelfDescribing[n_Integer] := (RotateRight[DigitCount[n]] == PadRight[IntegerDigits[n], 10]) diff --git a/Task/Self-describing-numbers/PARI-GP/self-describing-numbers.pari b/Task/Self-describing-numbers/PARI-GP/self-describing-numbers.pari new file mode 100644 index 0000000000..a58b468abd --- /dev/null +++ b/Task/Self-describing-numbers/PARI-GP/self-describing-numbers.pari @@ -0,0 +1,2 @@ +S=[1210, 2020, 21200, 3211000, 42101000, 521001000, 6210001000]; +isself(n)=vecsearch(S,n) diff --git a/Task/Self-describing-numbers/Pascal/self-describing-numbers.pascal b/Task/Self-describing-numbers/Pascal/self-describing-numbers.pascal new file mode 100644 index 0000000000..ccf672a776 --- /dev/null +++ b/Task/Self-describing-numbers/Pascal/self-describing-numbers.pascal @@ -0,0 +1,43 @@ +Program SelfDescribingNumber; + +uses + SysUtils; + +function check(number: longint): boolean; + var + i, d: integer; + a: string; + count, w : array [0..9] of integer; + + begin + a := intToStr(number); + for i := 0 to 9 do + begin + count[i] := 0; + w[i] := 0; + end; + for i := 1 to length(a) do + begin + d := ord(a[i]) - ord('0'); + inc(count[d]); + w[i - 1] := d; + end; + check := true; + i := 0; + while check and (i <= 9) do + begin + check := count[i] = w[i]; + inc(i); + end; + end; + +var + x: longint; + +begin + writeln ('Autodescriptive numbers from 1 to 100000000:'); + for x := 1 to 100000000 do + if check(x) then + writeln (' ', x); + writeln('Job done.'); +end. diff --git a/Task/Self-describing-numbers/Perl-6/self-describing-numbers.pl6 b/Task/Self-describing-numbers/Perl-6/self-describing-numbers.pl6 new file mode 100644 index 0000000000..90e9224ea2 --- /dev/null +++ b/Task/Self-describing-numbers/Perl-6/self-describing-numbers.pl6 @@ -0,0 +1,18 @@ +my @values = <1210 2020 21200 3211000 +42101000 521001000 6210001000 27 115508>; + +for @values -> $test { + say "$test is {$test.&sdn ?? '' !! 'NOT ' }a self describing number."; +} + +sub sdn ($num) { + my @digits; + my $chars = $num.chars; + @digits[$_]++ for $num.comb; + return 0 if @digits.elems > $chars; + @digits[$_] //= '0' for ^$chars; + my $string = join '', @digits; + return 1 if $num eq $string; +} + +say $_ if $_.&sdn for ^9999999; diff --git a/Task/Self-describing-numbers/Perl/self-describing-numbers.pl b/Task/Self-describing-numbers/Perl/self-describing-numbers.pl new file mode 100644 index 0000000000..182001e703 --- /dev/null +++ b/Task/Self-describing-numbers/Perl/self-describing-numbers.pl @@ -0,0 +1,12 @@ +sub is_selfdesc +{ + local $_ = shift; + my @b = (0) x length; + $b[$_]++ for my @a = split //; + return "@a" eq "@b"; +} + +# check all numbers from 0 to 100k plus two 'big' ones +for (0 .. 100000, 3211000, 42101000) { + print "$_\n" if is_selfdesc($_); +} diff --git a/Task/Self-describing-numbers/PicoLisp/self-describing-numbers.l b/Task/Self-describing-numbers/PicoLisp/self-describing-numbers.l new file mode 100644 index 0000000000..2a0f067234 --- /dev/null +++ b/Task/Self-describing-numbers/PicoLisp/self-describing-numbers.l @@ -0,0 +1,5 @@ +(de selfDescribing (N) + (not + (find '((D I) (<> D (cnt = N (circ I)))) + (setq N (mapcar format (chop N))) + (range 0 (length N)) ) ) ) diff --git a/Task/Self-describing-numbers/Prolog/self-describing-numbers.pro b/Task/Self-describing-numbers/Prolog/self-describing-numbers.pro new file mode 100644 index 0000000000..eb83d2ea1f --- /dev/null +++ b/Task/Self-describing-numbers/Prolog/self-describing-numbers.pro @@ -0,0 +1,107 @@ +:- use_module(library(clpfd)). + +self_describling :- + forall(between(1, 10, I), + (findall(N, self_describling(I,N), L), + format('Len ~w, Numbers ~w~n', [I, L]))). + +% search of the self_describling numbers of a given len +self_describling(Len, N) :- + length(L, Len), + Len1 is Len - 1, + L = [H|T], + + % the first figure is greater than 0 + H in 1..Len1, + + % there is a least to figures so the number of these figures + % is at most Len - 2 + Len2 is Len - 2, + T ins 0..Len2, + + % the sum of the figures is equal to the len of the number + sum(L, #=, Len), + + % There is at least one figure corresponding to the number of zeros + H1 #= H+1, + element(H1, L, V), + V #> 0, + + % create the list + label(L), + + % test the list + msort(L, LNS), + packList(LNS,LNP), + numlist(0, Len1, NumList), + verif(LNP,NumList, L), + + % list is OK, create the number + maplist(atom_number, LA, L), + number_chars(N, LA). + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% testing a number (not use in this program) +self_describling(N) :- + number_chars(N, L), + maplist(atom_number, L, LN), + msort(LN, LNS), + packList(LNS,LNP), !, + length(L, Len), + Len1 is Len - 1, + numlist(0, Len1, NumList), + verif(LNP,NumList, LN). + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% verif(PackList, Order_of_Numeral, Numeral_of_the_nuber_to_test) +% Packlist is of the form [[Number_of_Numeral, Order_of_Numeral]|_] +% Test succeed when + +% All lists are empty +verif([], [], []). + +% Packlist is empty and all lasting numerals are 0 +verif([], [_N|S], [0|T]) :- + verif([], S, T). + +% Number of numerals N is V +verif([[V, N]|R], [N|S], [V|T]) :- + verif(R, S, T). + +% Number of numerals N is 0 +verif([[V, N1]|R], [N|S], [0|T]) :- + N #< N1, + verif([[V,N1]|R], S, T). + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% ?- packList([a,a,a,b,c,c,c,d,d,e], L). +% L = [[3,a],[1,b],[3,c],[2,d],[1,e]] . +% ?- packList(R, [[3,a],[1,b],[3,c],[2,d],[1,e]]). +% R = [a,a,a,b,c,c,c,d,d,e] . +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +packList([],[]). + +packList([X],[[1,X]]) :- !. + + +packList([X|Rest],[XRun|Packed]):- + run(X,Rest, XRun,RRest), + packList(RRest,Packed). + + +run(Var,[],[1, Var],[]). + +run(Var,[Var|LRest],[N1, Var],RRest):- + N #> 0, + N1 #= N + 1, + run(Var,LRest,[N, Var],RRest). + + +run(Var,[Other|RRest], [1, Var],[Other|RRest]):- + dif(Var,Other). diff --git a/Task/Self-describing-numbers/PureBasic/self-describing-numbers.purebasic b/Task/Self-describing-numbers/PureBasic/self-describing-numbers.purebasic new file mode 100644 index 0000000000..5ca3cfb431 --- /dev/null +++ b/Task/Self-describing-numbers/PureBasic/self-describing-numbers.purebasic @@ -0,0 +1,73 @@ +Procedure isSelfDescribing(x.q) + ;returns 1 if number is self-describing, otherwise it returns 0 + Protected digitCount, digit, i, digitSum + Dim digitTally(10) + Dim digitprediction(10) + + If x <= 0 + ProcedureReturn 0 ;number must be positive and non-zero + EndIf + + While x > 0 And i < 10 + digit = x % 10 + digitSum + digit + If digitSum > 10 + ProcedureReturn 0 ;sum of digits' values exceeds maximum possible + EndIf + digitprediction(i) = digit + digitTally(digit) + 1 + x / 10 + i + 1 + Wend + digitCount = i - 1 + + If digitSum < digitCount Or x > 0 + ProcedureReturn 0 ;sum of digits' values is too small or number has more than 10 digits + EndIf + + For i = 0 To digitCount + If digitTally(i) <> digitprediction(digitCount - i) + ProcedureReturn 0 ;number is not self-describing + EndIf + Next + ProcedureReturn 1 ;number is self-describing +EndProcedure + +Procedure displayAll() + Protected i, j, t + PrintN("Starting search for all self-describing numbers..." + #CRLF$) + For j = 0 To 9 + PrintN(#CRLF$ + "Searching possibilites " + Str(j * 1000000000) + " -> " + Str((j + 1) * 1000000000 - 1)+ "...") + t = ElapsedMilliseconds() + For i = 0 To 999999999 + If isSelfDescribing(j * 1000000000 + i) + PrintN(Str(j * 1000000000 + i)) + EndIf + Next + PrintN("Time to search this range of possibilities: " + Str((ElapsedMilliseconds() - t) / 1000) + "s.") + Next + PrintN(#CRLF$ + "Search complete.") +EndProcedure + +If OpenConsole() + + DataSection + Data.q 1210, 2020, 21200, 3211000, 42101000, 521001000, 6210001000, 3214314 + EndDataSection + + Define i, x.q + For i = 1 To 8 + Read.q x + Print(Str(x) + " is ") + If Not isSelfDescribing(x) + Print("not ") + EndIf + PrintN("selfdescribing.") + Next + PrintN(#CRLF$) + + displayAll() + + Print(#CRLF$ + #CRLF$ + "Press ENTER to exit"): Input() + CloseConsole() +EndIf diff --git a/Task/Self-describing-numbers/Python/self-describing-numbers-1.py b/Task/Self-describing-numbers/Python/self-describing-numbers-1.py new file mode 100644 index 0000000000..76f893faf5 --- /dev/null +++ b/Task/Self-describing-numbers/Python/self-describing-numbers-1.py @@ -0,0 +1,8 @@ +>>> def isSelfDescribing(n): + s = str(n) + return all(s.count(str(i)) == int(ch) for i, ch in enumerate(s)) + +>>> [x for x in range(4000000) if isSelfDescribing(x)] +[1210, 2020, 21200, 3211000] +>>> [(x, isSelfDescribing(x)) for x in (1210, 2020, 21200, 3211000, 42101000, 521001000, 6210001000)] +[(1210, True), (2020, True), (21200, True), (3211000, True), (42101000, True), (521001000, True), (6210001000, True)] diff --git a/Task/Self-describing-numbers/Python/self-describing-numbers-2.py b/Task/Self-describing-numbers/Python/self-describing-numbers-2.py new file mode 100644 index 0000000000..48372b2614 --- /dev/null +++ b/Task/Self-describing-numbers/Python/self-describing-numbers-2.py @@ -0,0 +1,11 @@ +def impl(d, c, m): + if m < 0: return + if d == c[:len(d)]: print d + for i in range(c[len(d)],m+1): + dd = d+[i] + if iy then iterate /*if ¬ self-describing, try again*/ + say right(_,w) 'is a self-describing number.' /*display it.*/ + end /*n*/ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────TEST_SDN subroutine─────────────────*/ +test_sdn: procedure expose $; parse arg ? +if right(?,1)\==0 then return 1; return wordpos(?,$)==0 diff --git a/Task/Self-describing-numbers/Ruby/self-describing-numbers.rb b/Task/Self-describing-numbers/Ruby/self-describing-numbers.rb new file mode 100644 index 0000000000..353f524954 --- /dev/null +++ b/Task/Self-describing-numbers/Ruby/self-describing-numbers.rb @@ -0,0 +1,14 @@ +def is_self_describing?(n) + digits = n.to_s.chars.collect {|digit| digit.to_i} + len = digits.length + count = Array.new(len, 0) + + digits.each do |digit| + return false if digit >= len + count[digit] = count[digit] + 1 + end + + digits.eql?(count) +end + +3_300_000.times {|n| puts n if is_self_describing?(n)} diff --git a/Task/Self-describing-numbers/Run-BASIC/self-describing-numbers.run b/Task/Self-describing-numbers/Run-BASIC/self-describing-numbers.run new file mode 100644 index 0000000000..72db34ee79 --- /dev/null +++ b/Task/Self-describing-numbers/Run-BASIC/self-describing-numbers.run @@ -0,0 +1,17 @@ +for i = 0 to 50000000 step 10 + a$ = str$(i) + for c = 1 TO len(a$) + d = val(mid$(a$, c, 1)) + j(d) = j(d) + 1 + k(c-1) = d + next c + r = 0 + for n = 0 to 10 + r = r + (j(n) = k(n)) + j(n) = 0 + k(n) = 0 + next n + if r = 11 then print i +next i +print "== End ==" +end diff --git a/Task/Self-describing-numbers/Seed7/self-describing-numbers.seed7 b/Task/Self-describing-numbers/Seed7/self-describing-numbers.seed7 new file mode 100644 index 0000000000..d5df4f7ca6 --- /dev/null +++ b/Task/Self-describing-numbers/Seed7/self-describing-numbers.seed7 @@ -0,0 +1,66 @@ +$ include "seed7_05.s7i"; + +const func boolean: selfDescr (in string: stri) is func + result + var boolean: check is TRUE; + local + var integer: idx is 0; + var array integer: count is [0 .. 9] times 0; + begin + for idx range 1 to length(stri) do + incr(count[ord(stri[idx]) - ord('0')]); + end for; + idx := 1; + while check and idx <= length(stri) do + check := count[pred(idx)] = ord(stri[idx]) - ord('0'); + incr(idx); + end while; + end func; + +const proc: gen (in integer: n) is func + local + var array integer : digits is 0 times 0; + var string: stri is ""; + var integer: numberOfOneDigits is 0; + var integer: idx is 0; + begin + while numberOfOneDigits <= 2 and numberOfOneDigits < n - 2 do + digits := n times 0; + digits[1] := n - 2 - numberOfOneDigits; + if digits[1] <> 2 then + digits[digits[1] + 1] := 1; + digits[2] := 2; + digits[3] := 1; + else + digits[2] := ord(numberOfOneDigits <> 0); + digits[3] := 2; + end if; + stri := ""; + for idx range 1 to n do + stri &:= chr(ord(digits[idx]) + ord('0')); + end for; + if selfDescr(stri) then + writeln(stri); + end if; + incr(numberOfOneDigits); + end while; + end func; + +const proc: main is func + local + const array integer: nums is [] (1210, 1337, 2020, 21200, 3211000, 42101000); + var integer: number is 0; + begin + for number range nums do + write(number <& " is "); + if not selfDescr(str(number)) then + write("not "); + end if; + writeln("self describing"); + end for; + writeln; + writeln("All autobiograph numbers:"); + for number range 1 to 10 do + gen(number); + end for; + end func; diff --git a/Task/Self-describing-numbers/Tcl/self-describing-numbers.tcl b/Task/Self-describing-numbers/Tcl/self-describing-numbers.tcl new file mode 100644 index 0000000000..84e2d85a86 --- /dev/null +++ b/Task/Self-describing-numbers/Tcl/self-describing-numbers.tcl @@ -0,0 +1,16 @@ +package require Tcl 8.5 +proc isSelfDescribing num { + set digits [split $num ""] + set len [llength $digits] + set count [lrepeat $len 0] + foreach d $digits { + if {$d >= $len} {return false} + lset count $d [expr {[lindex $count $d] + 1}] + } + foreach d $digits c $count {if {$c != $d} {return false}} + return true +} + +for {set i 0} {$i < 100000000} {incr i} { + if {[isSelfDescribing $i]} {puts $i} +} diff --git a/Task/Self-describing-numbers/XPL0/self-describing-numbers.xpl0 b/Task/Self-describing-numbers/XPL0/self-describing-numbers.xpl0 new file mode 100644 index 0000000000..7e1b25f408 --- /dev/null +++ b/Task/Self-describing-numbers/XPL0/self-describing-numbers.xpl0 @@ -0,0 +1,35 @@ +code ChOut=8, IntOut=11; + +func SelfDesc(N); \Returns 'true' if N is self-describing +int N; +int Len, \length = number of digits in N + I, D; +char Digit(10), Count(10); + + proc Num2Str(N); \Convert integer N to string in Digit + int N; + int R; + [N:= N/10; + R:= rem(0); + if N then Num2Str(N); + Digit(Len):= R; + Len:= Len+1; + ]; + +[Len:= 0; +Num2Str(N); +for I:= 0 to Len-1 do Count(I):= 0; +for I:= 0 to Len-1 do + [D:= Digit(I); + if D >= Len then return false; + Count(D):= Count(D)+1; + ]; +for I:= 0 to Len-1 do + if Count(I) # Digit(I) then return false; +return true; +]; \SelfDesc + + +int N; +for N:= 0 to 100_000_000-1 do + if SelfDesc(N) then [IntOut(0, N); ChOut(0, ^ )] diff --git a/Task/Self-referential-sequence/0DESCRIPTION b/Task/Self-referential-sequence/0DESCRIPTION new file mode 100644 index 0000000000..206c2c61d8 --- /dev/null +++ b/Task/Self-referential-sequence/0DESCRIPTION @@ -0,0 +1,48 @@ +There are several ways to generate a self-referential sequence. One very common one (the [[Look-and-say sequence]]) is to start with a positive integer, then generate the next term by concatenating enumerated groups of adjacent alike digits: + +0, 10, 1110, 3110, 132110, 1113122110, 311311222110 ... + +The terms generated grow in length geometrically and never converge. + +Another way to generate a self-referential sequence is to summarize the previous term. + +Count how many of each alike digit there is, then concatenate the sum and digit for each of the sorted enumerated digits. Note that the first five terms are the same as for the previous sequence. + +0, 10, 1110, 3110, 132110, 13123110, 23124110 ... see [[oeis:A036058|The On-Line Encyclopedia of Integer Sequences]] + +Sort the digits largest to smallest. Do not include counts of digits that do not appear in the previous term. + +Depending on the seed value, series generated this way always either converge to a stable value or to a short cyclical pattern. (For our purposes, I'll use converge to mean an element matches a previously seen element.) The sequence shown, with a seed value of 0, converges to a stable value of 1433223110 after 11 iterations. The seed value that converges most quickly is 22. It goes stable after the first element. (The next element is 22, which has been seen before.) + +Task: + +Find all the positive integer seed values under 1000000, for the above convergent self-referential sequence, that takes the largest number of iterations before converging. Then print out the number of iterations and the sequence they return. Note that different permutations of the digits of the seed will yield the same sequence. For this task, assume leading zeros are not permitted. + +
    Seed Value(s): 9009 9090 9900
    +
    +Iterations: 21
    +
    +Sequence: (same for all three seeds except for first element)
    +9009
    +2920
    +192210
    +19222110
    +19323110
    +1923123110
    +1923224110
    +191413323110
    +191433125110
    +19151423125110
    +19251413226110
    +1916151413325110
    +1916251423127110
    +191716151413326110
    +191726151423128110
    +19181716151413327110
    +19182716151423129110
    +29181716151413328110
    +19281716151423228110
    +19281716151413427110
    +19182716152413228110
    +
    +See also: [[Self-describing numbers]] and [[Look-and-say sequence]] diff --git a/Task/Self-referential-sequence/Ada/self-referential-sequence.ada b/Task/Self-referential-sequence/Ada/self-referential-sequence.ada new file mode 100644 index 0000000000..991847d9e8 --- /dev/null +++ b/Task/Self-referential-sequence/Ada/self-referential-sequence.ada @@ -0,0 +1,62 @@ +with Ada.Text_IO; use Ada.Text_IO; +with Ada.Containers.Vectors; +procedure SelfRef is + subtype Seed is Natural range 0 .. 1_000_000; + subtype Num is Natural range 0 .. 10; + type NumList is array (0 .. 10) of Num; + package IO is new Ada.Text_IO.Integer_IO (Natural); + package DVect is new Ada.Containers.Vectors (Positive, NumList); + + function Init (innum : Seed) return NumList is + list : NumList := (others => 0); + number : Seed := innum; d : Num; + begin + loop + d := Num (number mod 10); + list (d) := list (d) + 1; + number := number / 10; exit when number = 0; + end loop; return list; + end Init; + + procedure Next (inoutlist : in out NumList) is + list : NumList := (others => 0); + begin + for i in list'Range loop + if inoutlist (i) /= 0 then + list (i) := list (i) + 1; + list (inoutlist (i)) := list (inoutlist (i)) + 1; + end if; + end loop; inoutlist := list; + end Next; + + procedure Show (list : NumList) is begin + for i in reverse list'Range loop + if list (i) > 0 then + IO.Put (list (i), Width => 1); IO.Put (i, Width => 1); + end if; + end loop; New_Line; + end Show; + + function Iterate (theseed : Seed; p : Boolean) return Natural is + list : NumList := Init (theseed); + vect : DVect.Vector; + begin + vect.Append (list); + loop + if p then Show (list); end if; + Next (list); exit when vect.Contains (list); vect.Append (list); + end loop; + return Integer (DVect.Length (vect)) + 1; + end Iterate; + + mseed : Seed; + len, maxlen : Natural := 0; +begin + for i in Seed'Range loop + len := Iterate (i, False); + if len > maxlen then mseed := i; maxlen := len; end if; + end loop; + IO.Put (maxlen, Width => 1); Put_Line (" Iterations:"); + IO.Put (mseed, Width => 1); New_Line; + len := Iterate (mseed, True); +end SelfRef; diff --git a/Task/Self-referential-sequence/AutoHotkey/self-referential-sequence.ahk b/Task/Self-referential-sequence/AutoHotkey/self-referential-sequence.ahk new file mode 100644 index 0000000000..d4ca19bcf9 --- /dev/null +++ b/Task/Self-referential-sequence/AutoHotkey/self-referential-sequence.ahk @@ -0,0 +1,33 @@ +; The following directives and commands speed up execution: +#NoEnv +SetBatchlines -1 +ListLines Off +Process, Priority,, high + +iterations := 0, seed := "Seeds: " + +Loop 1000000 + If (newIterations := CountSubString(list := ListSequence(A_Index), "`n")) > iterations + iterations := newiterations + ,final := "`nIterations: " iterations+1 "`nSequence:`n`n" A_Index "`n" list + ,seed := A_Index " " + else if (newIterations = iterations) + seed .= A_Index " " +MsgBox % "Seeds: " . seed . final +ListSequence(seed){ + While !InStr("`n" . out, "`n" (d:=Describe(seed)) "`n") + out .= d "`n", seed := d + return out +} + +Describe(n){ + Loop 10 + If (t:=CountSubString(n, 10-A_Index)) + out .= t . (10-A_Index) + return out +} + +CountSubstring(fullstring, substring){ + StringReplace, junk, fullstring, %substring%, , UseErrorLevel + return errorlevel +} diff --git a/Task/Self-referential-sequence/BBC-BASIC/self-referential-sequence.bbc b/Task/Self-referential-sequence/BBC-BASIC/self-referential-sequence.bbc new file mode 100644 index 0000000000..51b3e2d667 --- /dev/null +++ b/Task/Self-referential-sequence/BBC-BASIC/self-referential-sequence.bbc @@ -0,0 +1,41 @@ + *FLOAT64 + DIM list$(30) + maxiter% = 0 + maxseed% = 0 + FOR seed% = 0 TO 999999 + list$(0) = STR$(seed%) + iter% = 0 + REPEAT + list$(iter%+1) = FNseq(list$(iter%)) + IF VALlist$(iter%+1) <= VALlist$(iter%) THEN + FOR try% = iter% TO 0 STEP -1 + IF list$(iter%+1) = list$(try%) EXIT REPEAT + NEXT + ENDIF + iter% += 1 + UNTIL FALSE + IF iter% >= maxiter% THEN + IF iter% > maxiter% CLS + maxiter% = iter% + maxseed% = seed% + PRINT "Seed " ;seed% " has "; iter% " iterations" + ENDIF + NEXT + PRINT '"Sequence:" + number$ = STR$(maxseed%) + FOR i% = 1 TO maxiter% + PRINT number$ + number$ = FNseq(number$) + NEXT + END + + DEF FNseq(n$) + LOCAL I%, o$, d%() + DIM d%(9) + FOR I% = 1 TO LEN(n$) + d%(ASCMID$(n$,I%)-&30) += 1 + NEXT + FOR I% = 9 TO 0 STEP -1 + IF d%(I%) o$ += STR$d%(I%) + STR$I% + NEXT + = o$ diff --git a/Task/Self-referential-sequence/Bracmat/self-referential-sequence.bracmat b/Task/Self-referential-sequence/Bracmat/self-referential-sequence.bracmat new file mode 100644 index 0000000000..b78e29ffd4 --- /dev/null +++ b/Task/Self-referential-sequence/Bracmat/self-referential-sequence.bracmat @@ -0,0 +1,72 @@ +( ( self-referential + = seq N next + . ( next + = R S d f + . 0:?S + & whl + ' (@(!arg:%@?d ?arg)&(.!d)+!S:?S) + & :?R + & whl + ' ( !S:#?f*(.?d)+?S + & !f !d !R:?R + ) + & str$!R + ) + & 1:?N + & !arg:?seq + & whl + ' ( next$!arg:?arg + & ~(!seq:? !arg ?) + & !arg !seq:?seq + & 1+!N:?N + ) + & (!seq.!N) + ) +& ( Perm + = permutations S p + . :?permutations + & ( perm + = prefix List original A Z p + . !arg:(?prefix.) + & str$!prefix:?p + & (!S:?+(.!p)+?|(.!p)+!S:?S) + | !arg:(0 ?.?)& + | !arg:(?prefix.?List:?original) + & whl + ' ( @(!List:%?A ?Z) + & perm$(!prefix !A.!Z) + & str$(!Z !A):~!original:?List + ) + ) + & 0:?S + & perm$(.!arg) + & :?permutations + & whl + ' ( !S:?*(.?p)+?S + & !p !permutations:?permutations + ) + & !permutations + ) +& -1:?i:?max +& :?seqs +& whl + ' ( 1+!i:<1000000:?i + & ( @(!i:? %@?a >%@!a ?) + | self-referential$!i + : ( ?seq + . ( >!max:?max&:?seqs + | !max + ) + & ( "Seed Value(s):" Perm$!i + . "Sequence: (same for all three seeds except for first element) +" + !seq + ) + !seqs + : ?seqs + ) + | + ) + ) +& out$("Iterations:" !max !seqs) +); diff --git a/Task/Self-referential-sequence/C/self-referential-sequence.c b/Task/Self-referential-sequence/C/self-referential-sequence.c new file mode 100644 index 0000000000..2745d364c2 --- /dev/null +++ b/Task/Self-referential-sequence/C/self-referential-sequence.c @@ -0,0 +1,123 @@ +#include +#include +#include + +typedef struct rec_t rec_t; +struct rec_t { + int depth; + rec_t * p[10]; +}; + +rec_t root = {0, {0}}; + +#define USE_POOL_ALLOC +#ifdef USE_POOL_ALLOC /* not all that big a deal */ +rec_t *tail = 0, *head = 0; +#define POOL_SIZE (1 << 20) +inline rec_t *new_rec() +{ + if (head == tail) { + head = calloc(sizeof(rec_t), POOL_SIZE); + tail = head + POOL_SIZE; + } + return head++; +} +#else +#define new_rec() calloc(sizeof(rec_t), 1) +#endif + +rec_t *find_rec(char *s) +{ + int i; + rec_t *r = &root; + while (*s) { + i = *s++ - '0'; + if (!r->p[i]) r->p[i] = new_rec(); + r = r->p[i]; + } + return r; +} + +/* speed up number to string conversion */ +char number[100][4]; +void init() +{ + int i; + for (i = 0; i < 100; i++) + sprintf(number[i], "%d", i); +} + +void count(char *buf) +{ + int i, c[10] = {0}; + char *s; + + for (s = buf; *s; c[*s++ - '0']++); + + for (i = 9; i >= 0; i--) { + if (!c[i]) continue; + s = number[c[i]]; + + *buf++ = s[0]; + if ((*buf = s[1])) buf++; + + *buf++ = i + '0'; + } + + *buf = '\0'; +} + +int depth(char *in, int d) +{ + rec_t *r = find_rec(in); + + if (r->depth > 0) + return r->depth; + + d++; + if (!r->depth) r->depth = -d; + else r->depth += d; + + count(in); + d = depth(in, d); + + if (r->depth <= 0) r->depth = d + 1; + return r->depth; +} + +int main(void) +{ + char a[100]; + int i, d, best_len = 0, n_best = 0; + int best_ints[32]; + rec_t *r; + + init(); + + for (i = 0; i < 1000000; i++) { + sprintf(a, "%d", i); + d = depth(a, 0); + + if (d < best_len) continue; + if (d > best_len) { + n_best = 0; + best_len = d; + } + if (d == best_len) + best_ints[n_best++] = i; + } + + printf("longest length: %d\n", best_len); + for (i = 0; i < n_best; i++) { + printf("%d\n", best_ints[i]); + sprintf(a, "%d", best_ints[i]); + for (d = 0; d <= best_len; d++) { + r = find_rec(a); + printf("%3d: %s\n", r->depth, a); + count(a); + } + putchar('\n'); + } + + return 0; +} diff --git a/Task/Self-referential-sequence/CoffeeScript/self-referential-sequence.coffeescript b/Task/Self-referential-sequence/CoffeeScript/self-referential-sequence.coffeescript new file mode 100644 index 0000000000..9aba116894 --- /dev/null +++ b/Task/Self-referential-sequence/CoffeeScript/self-referential-sequence.coffeescript @@ -0,0 +1,42 @@ +sequence = (n) -> + cnts = {} + for c in n.toString() + d = parseInt(c) + incr cnts, d + + seq = [] + while true + s = '' + for i in [9..0] + s += "#{cnts[i]}#{i}" if cnts[i] + if s in seq + break + seq.push s + + new_cnts = {} + for digit, cnt of cnts + incr new_cnts, cnt + incr new_cnts, digit + cnts = new_cnts + seq + +incr = (h, k) -> + h[k] ?= 0 + h[k] += 1 + +descending = (n) -> + return true if n < 10 + tens = n / 10 + return false if n % 10 > tens % 10 + descending(tens) + +max_len = 0 +for i in [1..1000000] + if descending(i) + seq = sequence(i) + if seq.length > max_len + max_len = seq.length + max_seq = seq + max_i = i + +console.log max_i, max_seq diff --git a/Task/Self-referential-sequence/Common-Lisp/self-referential-sequence-1.lisp b/Task/Self-referential-sequence/Common-Lisp/self-referential-sequence-1.lisp new file mode 100644 index 0000000000..84e4779018 --- /dev/null +++ b/Task/Self-referential-sequence/Common-Lisp/self-referential-sequence-1.lisp @@ -0,0 +1,29 @@ +(defun count-and-say (str) + (let* ((s (sort (map 'list #'identity str) #'char>)) + (out (list (first s) 0))) + (loop for x in s do + (if (char= x (first out)) + (incf (second out)) + (setf out (nconc (list x 1) out)))) + (format nil "~{~a~^~}" (nreverse out)))) + +(defun ref-seq-len (n &optional doprint) + (let ((s (format nil "~d" n)) hist) + (loop (push s hist) + (if doprint (format t "~a~%" s)) + (setf s (count-and-say s)) + (loop for item in hist + for i from 0 to 2 do + (if (string= s item) (return-from ref-seq-len (length hist))))))) + +(defun find-longest (top) + (let (nums (len 0)) + (dotimes (x top) + (let ((l (ref-seq-len x))) + (if (> l len) (setf len l nums nil)) + (if (= l len) (push x nums)))) + (list nums len))) + +(let ((r (find-longest 1000000))) + (format t "Longest: ~a~%" r) + (ref-seq-len (first (first r)) t)) diff --git a/Task/Self-referential-sequence/Common-Lisp/self-referential-sequence-2.lisp b/Task/Self-referential-sequence/Common-Lisp/self-referential-sequence-2.lisp new file mode 100644 index 0000000000..7e9419343c --- /dev/null +++ b/Task/Self-referential-sequence/Common-Lisp/self-referential-sequence-2.lisp @@ -0,0 +1,22 @@ +Longest: ((9900 9090 9009) 21) +9900 +2920 +192210 +19222110 +19323110 +1923123110 +1923224110 +191413323110 +191433125110 +19151423125110 +19251413226110 +1916151413325110 +1916251423127110 +191716151413326110 +191726151423128110 +19181716151413327110 +19182716151423129110 +29181716151413328110 +19281716151423228110 +19281716151413427110 +19182716152413228110 diff --git a/Task/Self-referential-sequence/D/self-referential-sequence-1.d b/Task/Self-referential-sequence/D/self-referential-sequence-1.d new file mode 100644 index 0000000000..35ba0bfc29 --- /dev/null +++ b/Task/Self-referential-sequence/D/self-referential-sequence-1.d @@ -0,0 +1,37 @@ +import std.stdio, std.algorithm, std.conv; + +string[] selfReferentialSeq(string n, string[] seen=[]) { + static string[][string] cache; + if (n in cache) return cache[n]; + if (canFind(seen, n)) return []; + + int[10] digit_count; + foreach (d; n) + digit_count[d - '0']++; + string term; + foreach_reverse (d; 0 .. 10) + if (digit_count[d] > 0) + term ~= text(digit_count[d], d); + return cache[n] = [n] ~ selfReferentialSeq(term, [n] ~ seen); +} + +void main() { + enum int limit = 1_000_000; + int max_len; + int[] max_vals; + + foreach (n; 1 .. limit) { + const seq = n.text().selfReferentialSeq(); + if (seq.length > max_len) { + max_len = seq.length; + max_vals = [n]; + } else if (seq.length == max_len) + max_vals ~= n; + } + + writeln("values: ", max_vals); + writeln("iterations: ", max_len); + writeln("sequence:"); + foreach (idx, val; max_vals[0].text().selfReferentialSeq()) + writefln("%2d %s", idx + 1, val); +} diff --git a/Task/Self-referential-sequence/D/self-referential-sequence-2.d b/Task/Self-referential-sequence/D/self-referential-sequence-2.d new file mode 100644 index 0000000000..69feed9246 --- /dev/null +++ b/Task/Self-referential-sequence/D/self-referential-sequence-2.d @@ -0,0 +1,176 @@ +import std.range, std.algorithm; + +struct Permutations(bool doCopy=true, T) { + T[] items; + int r; + bool stopped; + int[] indices, cycles; + static if (!doCopy) + T[] result; + + this(T)(T[] items, int r=-1) /*pure nothrow*/ { + this.items = items; + immutable int n = items.length; + if (r < 0) + r = n; + this.r = r; + immutable n_minus_r = n - r; + if (n_minus_r < 0) { + this.stopped = true; + } else { + this.stopped = false; + this.indices = iota(n).array(); // not pure nothrow + this.cycles = iota(n, n_minus_r, -1).array(); + } + + static if (!doCopy) + result = new T[r]; + } + + @property bool empty() const pure nothrow { + return this.stopped; + } + + static if (doCopy) { + @property T[] front() const pure nothrow { + assert(!this.stopped); + auto result = new T[r]; + foreach (i, ref re; result) + re = items[indices[i]]; + return result; + } + } else { + @property T[] front() pure nothrow { + assert(!this.stopped); + foreach (i, ref re; this.result) + re = items[indices[i]]; + return this.result; + } + } + + void popFront() pure nothrow { + assert(!this.stopped); + int i = r - 1; + while (i >= 0) { + immutable int j = cycles[i] - 1; + if (j > 0) { + cycles[i] = j; + swap(indices[i], indices[$ - j]); + return; + } + cycles[i] = indices.length - i; + immutable int n1 = indices.length - 1; + assert(n1 >= 0); + immutable int num = indices[i]; + foreach (k; i .. n1) + indices[k] = indices[k + 1]; + indices[n1] = num; + i--; + } + + this.stopped = true; + } +} + +Permutations!(doCopy, T) permutations(bool doCopy=true, T) + (T[] items, int r=-1) +/*pure nothrow*/ { + return Permutations!(doCopy, T)(items, r); +} + +// --------------------------------- + +import std.stdio, std.typecons, std.conv, std.algorithm, std.array; + +enum maxIters = 1_000_000; + +string A036058(string ns) { + return group(ns).map!(t => text(t[1]) ~ cast(char)t[0])().join(); +} + +int A036058_length(bool doPrint=false)(string numberString="0") { + int iterations = 1; + int queue_index; + string[3] last_three; + + while (true) { + static if (doPrint) + writefln(" %2d %s", iterations, numberString); + + //numberString = cast(string)(cast(ubyte[])numberString.dup).sort().release(); + // this is a workaround -------- + int[10] digitsCounts; + foreach (char digit; numberString) + digitsCounts[digit - '0']++; + auto numb = new char[numberString.length]; + int count = 0; + foreach (i, d; digitsCounts) + foreach (n; 0 .. d) { + numb[count] = cast(char)(i + '0'); + count++; + } + numberString = cast(string)numb; + // end work-around -------- + + if (last_three[].canFind(numberString)) + break; + assert(iterations < maxIters); + last_three[queue_index] = numberString; + numberString = A036058(numberString); + iterations++; + queue_index++; + queue_index %= 3; + } + + return iterations; +} + +Tuple!(int,int[]) max_A036058_length(R)(R start_range=iota(11)) { + bool[string] already_done; + auto max_len = tuple(-1, (int[]).init); + + foreach (n; start_range) { + string sns = cast(string)(cast(ubyte[])to!(char[])(n)).sort().release(); + if (sns !in already_done) { + already_done[sns] = true; + int size = A036058_length(sns); + if (size > max_len[0]) + max_len = tuple(size, [n]); + else if (size == max_len[0]) + max_len[1] ~= n; + } + } + return max_len; +} + +void main() { + auto lenMax_starts = max_A036058_length(iota(maxIters)); + int lenMax = lenMax_starts[0]; + int[] starts = lenMax_starts[1]; + + // Expand + int[] allStarts; + foreach (n; starts) { + bool[string] set; + foreach (k; permutations!false(to!(char[])(n), 4)) + if (k[0] != '0') + set[k.idup] = true; + allStarts ~= set.byKey().map!(to!int)().array(); + } + + allStarts = allStarts.sort().release().filter!(x => x < maxIters)().array(); + + writefln("The longest length, followed by the number(s) with the +longest sequence length for starting sequence numbers below maxIters +are: +Iterations = %d and sequence-starts = %s.", lenMax, allStarts); + + writeln("Note that only the first of any sequences with the same +digits is printed below. (The others will differ only in their first +term)."); + + foreach (n; starts) { + writeln(); + A036058_length!true(to!string(n)); + } +} diff --git a/Task/Self-referential-sequence/D/self-referential-sequence-3.d b/Task/Self-referential-sequence/D/self-referential-sequence-3.d new file mode 100644 index 0000000000..3bbbaf4bfa --- /dev/null +++ b/Task/Self-referential-sequence/D/self-referential-sequence-3.d @@ -0,0 +1,139 @@ +import core.stdc.stdio, core.stdc.stdlib; + +struct MemoryPool(T, int MAX_BLOCK_BYTES=1 << 17) { + static assert(!is(T == class), + "MemoryPool is designed for native data."); + static assert(MAX_BLOCK_BYTES >= 1, + "MemoryPool: MAX_BLOCK_BYTES must be >= 1 bytes."); + + static struct Block { + static assert(MAX_BLOCK_BYTES >= T.sizeof, + "MemoryPool: MAX_BLOCK_BYTES must be" ~ + " bigger than a T."); + static if ((T.sizeof * 5) > MAX_BLOCK_BYTES) + pragma(msg, "MemoryPool: Block is very small."); + + T[(MAX_BLOCK_BYTES / T.sizeof)] items; + } + + __gshared static Block*[] blocks; + + __gshared static T* nextFree, lastFree; + + static T* newItem() nothrow { + if (nextFree >= lastFree) { + blocks ~= cast(Block*)calloc(1, Block.sizeof); + if (blocks[$ - 1] == null) + exit(1); + nextFree = blocks[$ - 1].items.ptr; + lastFree = nextFree + Block.items.length; + } + + return nextFree++; + } + + static void freeAll() nothrow { + foreach (block_ptr; blocks) + free(block_ptr); + blocks.length = 0; + nextFree = null; + lastFree = null; + } +} + +struct Rec { // Tree node + int length; + Rec*[10] p; +} + +__gshared int nNodes; +__gshared Rec* rec_root; +__gshared MemoryPool!Rec recPool; + +Rec* findRec(char* s, Rec* root) nothrow { + int c; + Rec* next; + + while (true) { + c = *s; + s++; + if (!c) + break; + c -= '0'; + next = root.p[c]; + if (!next) { + nNodes++; + next = recPool.newItem(); + root.p[c] = next; + } + root = next; + } + return root; +} + +void nextNum(char* s) nothrow { + int[10] cnt; + for (int i = 0; s[i]; i++) + cnt[s[i] - '0']++; + + foreach_reverse (i; 0 .. 10) { + if (!cnt[i]) + continue; + s += sprintf(s, "%d%c", cnt[i], i + '0'); + } +} + +int getLen(char* s, int depth) nothrow { + auto r = findRec(s, rec_root); + if (r.length > 0) + return r.length; + + depth++; + if (!r.length) + r.length = -depth; + else + r.length += depth; + + nextNum(s); + depth = 1 + getLen(s, depth); + + if (r.length <= 0) + r.length = depth; + return r.length; +} + +void main() nothrow { + enum MAXN = 1_000_000; + + int[100] longest; + int nLongest, ml; + char[32] buf; + rec_root = recPool.newItem(); + + foreach (i; 0 .. MAXN) { + sprintf(buf.ptr, "%d", i); + int l = getLen(buf.ptr, 0); + if (l < ml) + continue; + if (l > ml) { + nLongest = 0; + ml = l; + } + longest[nLongest] = i; + nLongest++; + } + + printf("seq leng: %d\n\n", ml); + foreach (i; 0 .. nLongest) { + sprintf(buf.ptr, "%d", longest[i]); + // print len+1 so we know repeating starts from when + foreach (l; 0 .. ml + 1) { + printf("%2d: %s\n", getLen(buf.ptr, 0), buf.ptr); + nextNum(buf.ptr); + } + printf("\n"); + } + + printf("Allocated %d Rec tree nodes.\n", nNodes); + //recPool.freeAll(); +} diff --git a/Task/Self-referential-sequence/Go/self-referential-sequence.go b/Task/Self-referential-sequence/Go/self-referential-sequence.go new file mode 100644 index 0000000000..070ebceac2 --- /dev/null +++ b/Task/Self-referential-sequence/Go/self-referential-sequence.go @@ -0,0 +1,75 @@ +package main + +import ( + "fmt" + "strconv" +) + +func main() { + var maxLen int + var seqMaxLen [][]string + for n := 1; n < 1e6; n++ { + switch s := seq(n); { + case len(s) == maxLen: + seqMaxLen = append(seqMaxLen, s) + case len(s) > maxLen: + maxLen = len(s) + seqMaxLen = [][]string{s} + } + } + fmt.Println("Max sequence length:", maxLen) + fmt.Println("Sequences:", len(seqMaxLen)) + for _, seq := range seqMaxLen { + fmt.Println("Sequence:") + for _, t := range seq { + fmt.Println(t) + } + } +} + +func seq(n int) []string { + s := strconv.Itoa(n) + ss := []string{s} + + for { + dSeq := sortD(s) + d := dSeq[0] + nd := 1 + s = "" + for i := 1; ; i++ { + if i == len(dSeq) { + s = fmt.Sprintf("%s%d%c", s, nd, d) + break + } + if dSeq[i] == d { + nd++ + } else { + s = fmt.Sprintf("%s%d%c", s, nd, d) + d = dSeq[i] + nd = 1 + } + } + for _, s0 := range ss { + if s == s0 { + return ss + } + } + ss = append(ss, s) + } + panic("unreachable") +} + +func sortD(s string) []rune { + r := make([]rune, len(s)) + for i, d := range s { + j := 0 + for ; j < i; j++ { + if d > r[j] { + copy(r[j+1:], r[j:i]) + break + } + } + r[j] = d + } + return r +} diff --git a/Task/Self-referential-sequence/Haskell/self-referential-sequence.hs b/Task/Self-referential-sequence/Haskell/self-referential-sequence.hs new file mode 100644 index 0000000000..c2a18d59f8 --- /dev/null +++ b/Task/Self-referential-sequence/Haskell/self-referential-sequence.hs @@ -0,0 +1,25 @@ +import Data.Set (Set, member, insert, empty) +import Data.List (group, sort) + +step :: String -> String +step = concatMap (\list -> show (length list) ++ [head list]) . group . sort + +findCycle :: (Ord a) => [a] -> [a] +findCycle = aux empty where + aux set (x : xs) + | x `member` set = [] + | otherwise = x : aux (insert x set) xs + +select :: [[a]] -> [[a]] +select = snd . foldl (\(len, acc) xs -> case len `compare` length xs of + LT -> (length xs, [xs]) + EQ -> (len, xs : acc) + GT -> (len, acc)) (0, []) + +main :: IO () +main = mapM_ (mapM_ print) $ -- Print out all the numbers + select $ -- find the longest ones + map findCycle $ -- run the sequences until there is a repeat + map (iterate step) $ -- produce the sequence + map show -- turn the numbers into digits + [1..1000000] -- The input seeds diff --git a/Task/Self-referential-sequence/Icon/self-referential-sequence-1.icon b/Task/Self-referential-sequence/Icon/self-referential-sequence-1.icon new file mode 100644 index 0000000000..fd3956741b --- /dev/null +++ b/Task/Self-referential-sequence/Icon/self-referential-sequence-1.icon @@ -0,0 +1,38 @@ +link printf + +procedure main() +every L := !longestselfrefseq(1000000) do + every printf(" %i : %i\n",i := 1 to *L,L[i]) +end + + +procedure longestselfrefseq(N) #: find longest sequences from 1 to N + +mlen := 0 +every L := selfrefseq(n := 1 to N) do { + if mlen <:= *L then + ML := [L] + else if mlen = *L then + put(ML,L) + } + +return ML +end + +procedure selfrefseq(n) #: return list of sequence oeis:A036058 for seed n +S := set() +L := [] +every p := seq(1) do + if member(S,n) then return L # ends at a repeat + else { + insert(S,n) + put(L,n) + n := nextselfrefseq(n) + } +end + +procedure nextselfrefseq(n) #: return next element of sequence oeis:A036058 +every (Counts := table(0))[integer(!n)] +:= 1 # count digits +every (n := "") ||:= (0 < Counts[i := 9 to 0 by -1]) || i # assemble counts +return integer(n) +end diff --git a/Task/Self-referential-sequence/Icon/self-referential-sequence-2.icon b/Task/Self-referential-sequence/Icon/self-referential-sequence-2.icon new file mode 100644 index 0000000000..5f51769c6e --- /dev/null +++ b/Task/Self-referential-sequence/Icon/self-referential-sequence-2.icon @@ -0,0 +1,29 @@ + link strings # to get csort() + +procedure main(A) + limit := A[1] | 1000000 # Allow alternate limit + mSq := 0 + # May have multiple 'unique' sequence sets (unrelated seeds) so use table + every s := [n := 1 to limit, sequence(n)] do { + if mSq <:= *s[2] then mT := table() # new max, start over + if mSq == *s[2] then insert((/mT[n := csort(n)] := set()) | mT[n],s) + } + dumpSequences(mT) +end + +procedure sequence(n) # produce sequence of SDS with seed n + every (repeats := [], iter := seq(), put(repeats, n)) do + if (n := nElem(n)) == !repeats then return repeats # Converged +end + +procedure nElem(n) # given n, produce its self-description + every (n1 := "", c := !cset(n)) do + (every (d := 0) +:= (upto(c, n),1)) | (n1 := d||c||n1) + return n1 +end + +procedure dumpSequences(seqTab) # Show each 'unique' sequence in table + every writes("Seeds:" | (!!seqTab)[1], " ") + write("\n\nIterations: ",*(!!seqTab)[2]) + every s := !seqTab do (write() & every write(!(!s\1)[2])) +end diff --git a/Task/Self-referential-sequence/J/self-referential-sequence-1.j b/Task/Self-referential-sequence/J/self-referential-sequence-1.j new file mode 100644 index 0000000000..246b02a868 --- /dev/null +++ b/Task/Self-referential-sequence/J/self-referential-sequence-1.j @@ -0,0 +1,6 @@ +require'stats' +digits=: 10&#.inv"0 :. ([: ".@; (<'x'),~":&.>) +summar=: (#/.~ ,@,. ~.)@\:~&.digits +sequen=: ~.@(, summar@{:)^:_ +values=: ~. \:~&.digits i.1e6 +allvar=: [:(#~(=&<.&(10&^.) >./))@~.({~ perm@#)&.(digits"1) diff --git a/Task/Self-referential-sequence/J/self-referential-sequence-2.j b/Task/Self-referential-sequence/J/self-referential-sequence-2.j new file mode 100644 index 0000000000..3b90e47bb0 --- /dev/null +++ b/Task/Self-referential-sequence/J/self-referential-sequence-2.j @@ -0,0 +1,26 @@ + ;allvar&.> values #~ (= >./) #@sequen"0 values +9900 9090 9009 + # sequen 9900 +21 + ,.sequen 9900 + 9900 + 2920 + 192210 + 19222110 + 19323110 + 1923123110 + 1923224110 + 191413323110 + 191433125110 + 19151423125110 + 19251413226110 + 1916151413325110 + 1916251423127110 + 191716151413326110 + 191726151423128110 +19181716151413327110 +19182716151423129110 +29181716151413328110 +19281716151423228110 +19281716151413427110 +19182716152413228110 diff --git a/Task/Self-referential-sequence/J/self-referential-sequence-3.j b/Task/Self-referential-sequence/J/self-referential-sequence-3.j new file mode 100644 index 0000000000..9e8dfed02d --- /dev/null +++ b/Task/Self-referential-sequence/J/self-referential-sequence-3.j @@ -0,0 +1,4 @@ + digits 321 +3 2 1 + digits inv 34 5 +345 diff --git a/Task/Self-referential-sequence/J/self-referential-sequence-4.j b/Task/Self-referential-sequence/J/self-referential-sequence-4.j new file mode 100644 index 0000000000..3613cf0f8c --- /dev/null +++ b/Task/Self-referential-sequence/J/self-referential-sequence-4.j @@ -0,0 +1,2 @@ + summar 0 1 2 +10 11 12 diff --git a/Task/Self-referential-sequence/Mathematica/self-referential-sequence.math b/Task/Self-referential-sequence/Mathematica/self-referential-sequence.math new file mode 100644 index 0000000000..4a8a0304cb --- /dev/null +++ b/Task/Self-referential-sequence/Mathematica/self-referential-sequence.math @@ -0,0 +1,6 @@ +selfRefSequence[ x_ ] := FromDigits@Flatten@Reverse@Cases[Transpose@{RotateRight[DigitCount@x,1], Range[0,9]},Except[{0,_}]] +DisplaySequence[ x_ ] := NestWhileList[selfRefSequence,x,UnsameQ[##]&,4] +data= {#, Length@DisplaySequence[#]}&/@Range[1000000]; +Print["Values: ", Select[data ,#[[2]] == Max@data[[;;,2]]&][[1,;;]]] +Print["Iterations: ", Length@DisplaySequence[#]&/@Select[data ,#[[2]] == Max@data[[;;,2]]&][[1,;;]]] +DisplaySequence@Select[data, #[[2]] == Max@data[[;;,2]]&][[1]]//Column diff --git a/Task/Self-referential-sequence/Perl-6/self-referential-sequence.pl6 b/Task/Self-referential-sequence/Perl-6/self-referential-sequence.pl6 new file mode 100644 index 0000000000..7f2971b781 --- /dev/null +++ b/Task/Self-referential-sequence/Perl-6/self-referential-sequence.pl6 @@ -0,0 +1,47 @@ +my @list; +my $longest = 0; +my %seen; + +for 1 .. 1000000 -> $m { + next unless $m ~~ /0/; # seed must have a zero + my $j = join '', $m.comb.sort; + next if %seen.exists($j); # already tested a permutation + %seen{$j} = ''; + my @seq := converging($m); + my %elems; + my $count; + for @seq[] -> $value { last if ++%elems{$value} == 2; $count++; }; + if $longest == $count { + @list.push($m); + say "\b" x 20, "$count, $m"; # monitor progress + } + elsif $longest < $count { + $longest = $count; + @list = $m; + say "\b" x 20, "$count, $m"; # monitor progress + } +}; + +for @list -> $m { + say "Seed Value(s): ", ~permutations($m).uniq.grep( { .substr(0,1) != 0 } ); + my @seq := converging($m); + my %elems; + my $count; + for @seq[] -> $value { last if ++%elems{$value} == 2; $count++; }; + say "\nIterations: ", $count; + say "\nSequence: (Only one shown per permutation group.)"; + .say for @seq[^$count], "\n"; +} + +sub converging ($seed) { return $seed, -> $l { join '', map { $_.value.elems~$_.key }, $l.comb.classify({$^b}).sort: {-$^c.key} } ... * } + +sub permutations ($string, $sofar? = '' ) { + return $sofar unless $string.chars; + my @perms; + for ^$string.chars -> $idx { + my $this = $string.substr(0,$idx)~$string.substr($idx+1); + my $char = substr($string, $idx,1); + @perms.push( permutations( $this, join '', $sofar, $char ) ) ; + } + return @perms; +} diff --git a/Task/Self-referential-sequence/Perl/self-referential-sequence.pl b/Task/Self-referential-sequence/Perl/self-referential-sequence.pl new file mode 100644 index 0000000000..3d61b60b89 --- /dev/null +++ b/Task/Self-referential-sequence/Perl/self-referential-sequence.pl @@ -0,0 +1,39 @@ +sub next_num { + my @a; + $a[$_]++ for split '', shift; + join('', map(exists $a[$_] ? $a[$_].$_ : "", reverse 0 .. 9)); +} + +my %cache; +sub seq { + my $a = shift; + my (%seen, @s); + until ($seen{$a}) { + $seen{$a} = 1; + push(@s, $a); + last if !wantarray && $cache{$a}; + $a = next_num($a); + } + return (@s) if wantarray; + + my $l = $cache{$a}; + if ($l) { $cache{$s[$_]} = $#s - $_ + $l for (0 .. $#s); } + else { + $l++ while ($s[-$l] != $a); + $cache{pop @s} = $l for (1 .. $l); + $cache{pop @s} = ++$l while @s; + } + $cache{$s[0]} +} + +my (@mlist, $mlen); +for (1 .. 100_000) { # 1_000_000 takes very, very long + my $l = seq($_); + next if $l < $mlen; + + if ($l > $mlen) { $mlen = $l; @mlist = (); } + push @mlist, $_; +} + +print "longest ($mlen): @mlist\n"; +print join("\n", seq($_)), "\n\n" for @mlist; diff --git a/Task/Self-referential-sequence/PicoLisp/self-referential-sequence.l b/Task/Self-referential-sequence/PicoLisp/self-referential-sequence.l new file mode 100644 index 0000000000..dabc4241f7 --- /dev/null +++ b/Task/Self-referential-sequence/PicoLisp/self-referential-sequence.l @@ -0,0 +1,16 @@ +(de selfRefSequence (Seed) + (let L (mapcar format (chop Seed)) + (make + (for (Cache NIL (not (idx 'Cache L T))) + (setq L + (las (flip (sort (copy (link L))))) ) ) ) ) ) + +(let Res NIL + (for Seed 1000000 + (let N (length (selfRefSequence Seed)) + (cond + ((> N (car Res)) (setq Res (list N Seed))) + ((= N (car Res)) (queue 'Res Seed)) ) ) ) + (println 'Values: (cdr Res)) + (println 'Iterations: (car Res)) + (mapc prinl (selfRefSequence (cadr Res))) ) diff --git a/Task/Self-referential-sequence/Python/self-referential-sequence.py b/Task/Self-referential-sequence/Python/self-referential-sequence.py new file mode 100644 index 0000000000..1e05f3a2b5 --- /dev/null +++ b/Task/Self-referential-sequence/Python/self-referential-sequence.py @@ -0,0 +1,65 @@ +from itertools import groupby, permutations + +def A036058(number): + return ''.join( str(len(list(g))) + k + for k,g in groupby(sorted(str(number), reverse=True)) ) + +def A036058_length(numberstring='0', printit=False): + iterations, last_three, queue_index = 1, ([None] * 3), 0 + + def A036058(number): + # rely on external reverse-sort of digits of number + return ''.join( str(len(list(g))) + k + for k,g in groupby(number) ) + + while True: + if printit: + print(" %2i %s" % (iterations, numberstring)) + numberstring = ''.join(sorted(numberstring, reverse=True)) + if numberstring in last_three: + break + assert iterations < 1000000 + last_three[queue_index], numberstring = numberstring, A036058(numberstring) + iterations += 1 + queue_index +=1 + queue_index %=3 + return iterations + +def max_A036058_length( start_range=range(11) ): + already_done = set() + max_len = (-1, []) + for n in start_range: + sn = str(n) + sns = tuple(sorted(sn, reverse=True)) + if sns not in already_done: + already_done.add(sns) + size = A036058_length(sns) + if size > max_len[0]: + max_len = (size, [n]) + elif size == max_len[0]: + max_len[1].append(n) + return max_len + +lenmax, starts = max_A036058_length( range(1000000) ) + +# Expand +allstarts = [] +for n in starts: + allstarts += [int(''.join(x)) + for x in set(k + for k in permutations(str(n), 4) + if k[0] != '0')] +allstarts = [x for x in sorted(allstarts) if x < 1000000] + +print ( '''\ +The longest length, followed by the number(s) with the longest sequence length +for starting sequence numbers below 1000000 are: + Iterations = %i and sequence-starts = %s.''' % (lenmax, allstarts) ) + +print ( ''' +Note that only the first of any sequences with the same digits is printed below. +(The others will differ only in their first term)''' ) + +for n in starts: + print() + A036058_length(str(n), printit=True) diff --git a/Task/Self-referential-sequence/REXX/self-referential-sequence.rexx b/Task/Self-referential-sequence/REXX/self-referential-sequence.rexx new file mode 100644 index 0000000000..8d1d9da58c --- /dev/null +++ b/Task/Self-referential-sequence/REXX/self-referential-sequence.rexx @@ -0,0 +1,35 @@ +/*REXX program to generate a self-referential sequence and list the maxs*/ +parse arg low high .; maxL=0; seeds=; max$$= +if low=='' then low=1 /*no low? Then use the default*/ +if high=='' then high=1000000 /*no high? " " " " */ +/*══════════════════════════════════════════════════traipse through #'s.*/ + do seed=low to high; n=seed; $.=0; $$=n; $.n=1 + + do j=1 until x==n /*generate interation sequence. */ + x=n; n= + do k=9 to 0 by -1 /*gen new sequence*/ + _=countstr(k,x); if _\==0 then n=n || _ || k + end /*k*/ + if $.n then leave /*sequence been generated before?*/ + $$=$$'-'n; $.n=1 /*add number to sequence & roster*/ + end /*j*/ + + if j==maxL then do /*sequence equal to max so far ? */ + seeds=seeds seed; maxnums=maxnums n; max$$=max$$ $$ + end + else if j>maxL then do /*have found a new best sequence.*/ + seeds=seed; maxL=j; maxnums=n; max$$=$$ + end + end /*seed*/ +/*═══════════════════════════════════════════════════display the output.*/ +say 'seeds that had the most iterations =' seeds +hdr=copies('─',30); say 'maximum sequence length =' maxL + + do j=1 for words(max$$); say + say hdr "iteration sequence for: " word(seeds,j) ' ('maxL "iterations)" + q=translate(word(max$$,j),,'-') + do k=1 for words(q) + say word(q,k) + end /*k*/ + end /*j*/ + /*stick a fork in it, we're done.*/ diff --git a/Task/Self-referential-sequence/Ruby/self-referential-sequence.rb b/Task/Self-referential-sequence/Ruby/self-referential-sequence.rb new file mode 100644 index 0000000000..769cb14589 --- /dev/null +++ b/Task/Self-referential-sequence/Ruby/self-referential-sequence.rb @@ -0,0 +1,37 @@ +$cache = {} +def selfReferentialSequence_cached(n, seen = []) + return $cache[n] if $cache.include? n + return [] if seen.include? n + + digit_count = Array.new(10, 0) + n.to_s.chars.collect {|char| digit_count[char.to_i] += 1} + term = '' + 9.downto(0).each do |d| + if digit_count[d] > 0 + term += digit_count[d].to_s + d.to_s + end + end + term = term.to_i + $cache[n] = [n] + selfReferentialSequence_cached(term, [n] + seen) +end + +limit = 1_000_000 +max_len = 0 +max_vals = [] + +1.upto(limit - 1) do |n| + seq = selfReferentialSequence_cached(n) + if seq.length > max_len + max_len = seq.length + max_vals = [n] + elsif seq.length == max_len + max_vals << n + end +end + +puts "values: #{max_vals.inspect}" +puts "iterations: #{max_len}" +puts "sequence:" +selfReferentialSequence_cached(max_vals[0]).each_with_index do |val, idx| + puts "%2d %d" % [idx + 1, val] +end diff --git a/Task/Self-referential-sequence/Tcl/self-referential-sequence.tcl b/Task/Self-referential-sequence/Tcl/self-referential-sequence.tcl new file mode 100644 index 0000000000..febd12d9f4 --- /dev/null +++ b/Task/Self-referential-sequence/Tcl/self-referential-sequence.tcl @@ -0,0 +1,49 @@ +proc nextterm n { + foreach c [split $n ""] {incr t($c)} + foreach c {9 8 7 6 5 4 3 2 1 0} { + if {[info exist t($c)]} {append r $t($c) $c} + } + return $r +} +# Local context of lambda term is just for speed +apply {limit { + # Build a digit cache; this adds quite a bit of speed + set done [lrepeat [set l2 [expr {$limit * 100}]] 0] + # Iterate over search space + set maxlen 0 + set maxes {} + for {set i 0} {$i < $limit} {incr i} { + if {[lindex $done $i]} continue + # Compute the sequence length for this value (with help from cache) + set seq {} + for {set seed $i} {$seed ni $seq} {set seed [nextterm $seed]} { + if {$seed < $l2 && [lindex $done $seed]} { + set len [expr {[llength $seq] + [lindex $done $seed]}] + break + } + set len [llength [lappend seq $seed]] + } + # What are we going to do about it? + if {$len > $maxlen} { + set maxlen $len + set maxes [list $i] + } elseif {$len == $maxlen} { + lappend maxes $i + } + # Update the cache with what we have learned + foreach n $seq { + if {$n < $l2} {lset done $n $len} + incr len -1 + } + } + # Output code + puts "max length: $maxlen" + foreach c $maxes {puts $c} + puts "Sample max-len sequence:" + set seq {} + # Rerun the sequence generator for printing; faster for large limits + for {set seed [lindex $c 0]} {$seed ni $seq} {set seed [nextterm $seed]} { + lappend seq $seed + puts "\t$seed" + } +}} 1000000 diff --git a/Task/Semordnilap/0DESCRIPTION b/Task/Semordnilap/0DESCRIPTION new file mode 100644 index 0000000000..822ad72410 --- /dev/null +++ b/Task/Semordnilap/0DESCRIPTION @@ -0,0 +1,8 @@ +A [http://en.wikipedia.org/wiki/Semordnilap#Semordnilaps semordnilap], is a word (or phrase) that spells a different word (or phrase) backward. "Semordnilap" is a word that itself is a semordnilap. + +Example: ''lager'' and ''regal'' + +Using only words from the [http://www.puzzlers.org/pub/wordlists/unixdict.txt unixdict], report the total number of unique semordnilap pairs, and print 5 examples. (Note that lager/regal and regal/lager should be counted as one unique pair.) + +;Cf. +* [[Palindrome_detection|Palindrome detection]] diff --git a/Task/Semordnilap/1META.yaml b/Task/Semordnilap/1META.yaml new file mode 100644 index 0000000000..50be2d308f --- /dev/null +++ b/Task/Semordnilap/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Semordnilap diff --git a/Task/Semordnilap/AWK/semordnilap.awk b/Task/Semordnilap/AWK/semordnilap.awk new file mode 100644 index 0000000000..8f2bdb4aab --- /dev/null +++ b/Task/Semordnilap/AWK/semordnilap.awk @@ -0,0 +1,20 @@ +# syntax: GAWK -f SEMORDNILAP.AWK unixdict.txt +{ arr[$0]++ } +END { + PROCINFO["sorted_in"] = "@ind_str_asc" + for (word in arr) { + rword = "" + for (j=length(word); j>0; j--) { + rword = rword substr(word,j,1) + } + if (word == rword) { continue } # palindrome + if (rword in arr) { + if (word in shown || rword in shown) { continue } + shown[word]++ + shown[rword]++ + if (n++ < 5) { printf("%s %s\n",word,rword) } + } + } + printf("%d words\n",n) + exit(0) +} diff --git a/Task/Semordnilap/Ada/semordnilap-1.ada b/Task/Semordnilap/Ada/semordnilap-1.ada new file mode 100644 index 0000000000..682626c8d0 --- /dev/null +++ b/Task/Semordnilap/Ada/semordnilap-1.ada @@ -0,0 +1,19 @@ +with Ada.Containers.Indefinite_Vectors, Ada.Text_IO; + +package String_Vectors is + + package String_Vec is new Ada.Containers.Indefinite_Vectors + (Index_Type => Positive, Element_Type => String); + + type Vec is new String_Vec.Vector with null record; + + function Read(Filename: String) return Vec; + -- uses Ada.Text_IO to read words from the given file into a Vec + -- requirement: each word is written in a single line + + function Is_In(List: Vec; + Word: String; + Start: Positive; Stop: Natural) return Boolean; + -- checks if Word is in List(Start .. Stop); + -- requirement: the words in List are sorted alphabetically +end String_Vectors; diff --git a/Task/Semordnilap/Ada/semordnilap-2.ada b/Task/Semordnilap/Ada/semordnilap-2.ada new file mode 100644 index 0000000000..6f03d4cae1 --- /dev/null +++ b/Task/Semordnilap/Ada/semordnilap-2.ada @@ -0,0 +1,35 @@ +package body String_Vectors is + + function Is_In(List: Vec; + Word: String; + Start: Positive; Stop: Natural) return Boolean is + Middle: Positive; + begin + if Start > Stop then + return False; + else + Middle := (Start+Stop) / 2; + if List.Element(Middle) = Word then + return True; + elsif List.Element(Middle) < Word then + return List.Is_In(Word, Middle+1, Stop); + else + return List.Is_In(Word, Start, Middle-1); + end if; + end if; + end Is_In; + + function Read(Filename: String) return Vec is + package IO renames Ada.Text_IO; + Persistent_List: IO.File_Type; + List: Vec; + begin + IO.Open(File => Persistent_List, Name => Filename, Mode => IO.In_File); + while not IO.End_Of_File(Persistent_List) loop + List.Append(New_Item => IO.Get_Line(Persistent_List)); + end loop; + IO.Close(Persistent_List); + return List; + end Read; + +end String_Vectors; diff --git a/Task/Semordnilap/Ada/semordnilap-3.ada b/Task/Semordnilap/Ada/semordnilap-3.ada new file mode 100644 index 0000000000..fb86fd8153 --- /dev/null +++ b/Task/Semordnilap/Ada/semordnilap-3.ada @@ -0,0 +1,30 @@ +with String_Vectors, Ada.Text_IO, Ada.Command_Line; + +procedure Semordnilap is + + function Backward(S: String) return String is + begin + if S'Length < 2 then + return S; + else + return (S(S'Last) & Backward(S(S'First+1 .. S'Last-1)) & S(S'First)); + end if; + end Backward; + + W: String_Vectors.Vec := String_Vectors.Read(Ada.Command_Line.Argument(1)); + + Semi_Counter: Natural := 0; + +begin + for I in W.First_Index .. W.Last_Index loop + if W.Element(I) /= Backward(W.Element(I)) and then + W.Is_In(Backward(W.Element(I)), W.First_Index, I) then + Semi_Counter := Semi_Counter + 1; + if Semi_Counter <= 5 then + Ada.Text_IO.Put_Line(W.Element(I) & " - " & Backward(W.Element(I))); + end if; + end if; + end loop; + Ada.Text_IO.New_Line; + Ada.Text_IO.Put("pairs found:" & Integer'Image(Semi_Counter)); +end Semordnilap; diff --git a/Task/Semordnilap/BBC-BASIC/semordnilap.bbc b/Task/Semordnilap/BBC-BASIC/semordnilap.bbc new file mode 100644 index 0000000000..613dec95e1 --- /dev/null +++ b/Task/Semordnilap/BBC-BASIC/semordnilap.bbc @@ -0,0 +1,50 @@ + INSTALL @lib$+"SORTLIB" + Sort% = FN_sortinit(0,0) + + DIM dict$(26000*2) + + REM Load the dictionary, eliminating palindromes: + dict% = OPENIN("C:\unixdict.txt") + IF dict%=0 ERROR 100, "No dictionary file" + index% = 0 + REPEAT + A$ = GET$#dict% + B$ = FNreverse(A$) + IF A$<>B$ THEN + dict$(index%) = A$ + dict$(index%+1) = B$ + index% += 2 + ENDIF + UNTIL EOF#dict% + CLOSE #dict% + Total% = index% + + REM Sort the dictionary: + C% = Total% + CALL Sort%, dict$(0) + + REM Find semordnilaps: + pairs% = 0 + examples% = 0 + FOR index% = 0 TO Total%-2 + IF dict$(index%)=dict$(index%+1) THEN + IF examples%<5 IF LEN(dict$(index%))>4 THEN + PRINT dict$(index%) " " FNreverse(dict$(index%)) + examples% += 1 + ENDIF + pairs% += 1 + ENDIF + NEXT + + PRINT "Total number of unique pairs = "; pairs%/2 + END + + DEF FNreverse(A$) + LOCAL I%, L%, P% + IF A$="" THEN ="" + L% = LENA$ - 1 + P% = !^A$ + FOR I% = 0 TO L% DIV 2 + SWAP P%?I%, L%?(P%-I%) + NEXT + = A$ diff --git a/Task/Semordnilap/C++/semordnilap.cpp b/Task/Semordnilap/C++/semordnilap.cpp new file mode 100644 index 0000000000..37aa8408b2 --- /dev/null +++ b/Task/Semordnilap/C++/semordnilap.cpp @@ -0,0 +1,29 @@ +#include +#include +#include +#include + +int main() +{ + std::ifstream input("unixdict.txt"); + if (!input) { + return 1; // couldn't open input file + } + + std::set words; // previous words + std::string word; // current word + size_t count = 0; // pair count + + while (input >> word) { + std::string drow(word.rbegin(), word.rend()); // reverse + if (words.find(drow) == words.end()) { // pair not found + words.insert(word); + } else { // pair found + if (count < 5) { + std::cout << word << ' ' << drow << '\n'; + } + ++count; + } + } + std::cout << "\nSemordnilap pairs: " << count << '\n'; +} diff --git a/Task/Semordnilap/C/semordnilap.c b/Task/Semordnilap/C/semordnilap.c new file mode 100644 index 0000000000..7d44b3d6d5 --- /dev/null +++ b/Task/Semordnilap/C/semordnilap.c @@ -0,0 +1,66 @@ +#include +#include +#include /* stdlib.h might not have obliged. */ +#include + +static void reverse(char *s, int len) +{ + int i, j; + char tmp; + + for (i = 0, j = len - 1; i < len / 2; ++i, --j) + tmp = s[i], s[i] = s[j], s[j] = tmp; +} + +/* Wrap strcmp() for qsort(). */ +static int strsort(const void *s1, const void *s2) +{ + return strcmp(*(char **) s1, *(char **) s2); +} + +int main(void) +{ + int i, c, ct = 0, len, sem = 0; + char **words, **drows, tmp[24]; + FILE *dict = fopen("unixdict.txt", "r"); + + /* Determine word count. */ + while ((c = fgetc(dict)) != EOF) + ct += c == '\n'; + rewind(dict); + + /* Using alloca() is generally discouraged, but we're not doing + * anything too fancy and the memory gains are significant. */ + words = alloca(ct * sizeof words); + drows = alloca(ct * sizeof drows); + + for (i = 0; fscanf(dict, "%s%n", tmp, &len) != EOF; ++i) { + /* Use just enough memory to store the next word. */ + strcpy(words[i] = alloca(len), tmp); + + /* Store it again, then reverse it. */ + strcpy(drows[i] = alloca(len), tmp); + reverse(drows[i], len - 1); + } + + fclose(dict); + qsort(drows, ct, sizeof drows, strsort); + + /* Walk both sorted lists, checking only the words which could + * possibly be a semordnilap pair for the current reversed word. */ + for (c = i = 0; i < ct; ++i) { + while (strcmp(drows[i], words[c]) > 0 && c < ct - 1) + c++; + /* We found a semordnilap. */ + if (!strcmp(drows[i], words[c])) { + strcpy(tmp, drows[i]); + reverse(tmp, strlen(tmp)); + /* Unless it was a palindrome. */ + if (strcmp(drows[i], tmp) > 0 && sem++ < 5) + printf("%s\t%s\n", drows[i], tmp); + } + } + + printf("Semordnilap pairs: %d\n", sem); + return 0; +} diff --git a/Task/Semordnilap/D/semordnilap.d b/Task/Semordnilap/D/semordnilap.d new file mode 100644 index 0000000000..d2c5fc5de4 --- /dev/null +++ b/Task/Semordnilap/D/semordnilap.d @@ -0,0 +1,17 @@ +import std.stdio, std.file, std.string, std.algorithm; + +void main() { + bool[string] seenWords; + size_t pairCount = 0; + + foreach (word; readText("unixdict.txt").toLower().splitter()) { + auto drow = word.dup.reverse; + if (drow in seenWords) { + if (pairCount++ < 5) + writeln(word, " ", drow); + } else + seenWords[word] = true; + } + + writeln("\nSemordnilap pairs: ", pairCount); +} diff --git a/Task/Semordnilap/Go/semordnilap.go b/Task/Semordnilap/Go/semordnilap.go new file mode 100644 index 0000000000..9c4104b4df --- /dev/null +++ b/Task/Semordnilap/Go/semordnilap.go @@ -0,0 +1,58 @@ +package main + +import ( + "fmt" + "io/ioutil" + "log" + "strings" +) + +func main() { + // read file into memory as one big block + data, err := ioutil.ReadFile("unixdict.txt") + if err != nil { + log.Fatal(err) + } + // copy the block, split it up into words + words := strings.Split(string(data), "\n") + // optional, free the first block for garbage collection + data = nil + // put words in a map, also determine length of longest word + m := make(map[string]bool) + longest := 0 + for _, w := range words { + m[string(w)] = true + if len(w) > longest { + longest = len(w) + } + } + // allocate a buffer for reversing words + r := make([]byte, longest) + // iterate over word list + sem := 0 + var five []string + for _, w := range words { + // first, delete from map. this prevents a palindrome from matching + // itself, and also prevents it's reversal from matching later. + delete(m, w) + // use buffer to reverse word + last := len(w) - 1 + for i := 0; i < len(w); i++ { + r[i] = w[last-i] + } + rs := string(r[:len(w)]) + // see if reversed word is in map, accumulate results + if m[rs] { + sem++ + if len(five) < 5 { + five = append(five, w+"/"+rs) + } + } + } + // print results + fmt.Println(sem, "pairs") + fmt.Println("examples:") + for _, e := range five { + fmt.Println(" ", e) + } +} diff --git a/Task/Semordnilap/Groovy/semordnilap-1.groovy b/Task/Semordnilap/Groovy/semordnilap-1.groovy new file mode 100644 index 0000000000..d9a4d6247a --- /dev/null +++ b/Task/Semordnilap/Groovy/semordnilap-1.groovy @@ -0,0 +1,9 @@ +def semordnilapWords(source) { + def words = [] as Set + def semordnilaps = [] + source.eachLine { word -> + if (words.contains(word.reverse())) semordnilaps << word + words << word + } + semordnilaps +} diff --git a/Task/Semordnilap/Groovy/semordnilap-2.groovy b/Task/Semordnilap/Groovy/semordnilap-2.groovy new file mode 100644 index 0000000000..08394e9e9b --- /dev/null +++ b/Task/Semordnilap/Groovy/semordnilap-2.groovy @@ -0,0 +1,3 @@ +def semordnilaps = semordnilapWords(new URL('http://www.puzzlers.org/pub/wordlists/unixdict.txt')) +println "Found ${semordnilaps.size()} semordnilap words" +semordnilaps[0..<5].each { println "$it -> ${it.reverse()}" } diff --git a/Task/Semordnilap/Haskell/semordnilap.hs b/Task/Semordnilap/Haskell/semordnilap.hs new file mode 100644 index 0000000000..9baeea60bd --- /dev/null +++ b/Task/Semordnilap/Haskell/semordnilap.hs @@ -0,0 +1,10 @@ +import qualified Data.Set as S + +semordnilaps = snd . foldl f (S.empty,[]) where + f (s,w) x | S.member (reverse x) s = (s, x:w) + | otherwise = (S.insert x s, w) + +main=do s <- readFile "unixdict.txt" + let l = semordnilaps (lines s) + print $ length l + mapM_ print $ map (\x->(x, reverse x)) $ take 5 l diff --git a/Task/Semordnilap/J/semordnilap-1.j b/Task/Semordnilap/J/semordnilap-1.j new file mode 100644 index 0000000000..3446221a48 --- /dev/null +++ b/Task/Semordnilap/J/semordnilap-1.j @@ -0,0 +1,4 @@ + isSemordnilap=: |.&.> (~: *. e.) ] + unixdict=: <;._2 freads 'unixdict.txt' + #semordnilaps=: ~. /:~"1 (,. |.&.>) (#~ isSemordnilap) unixdict +158 diff --git a/Task/Semordnilap/J/semordnilap-2.j b/Task/Semordnilap/J/semordnilap-2.j new file mode 100644 index 0000000000..b5e7848725 --- /dev/null +++ b/Task/Semordnilap/J/semordnilap-2.j @@ -0,0 +1,12 @@ + (5?.158) { semordnilaps +┌────┬────┐ +│kay │yak │ +├────┼────┤ +│nat │tan │ +├────┼────┤ +│avis│siva│ +├────┼────┤ +│flow│wolf│ +├────┼────┤ +│caw │wac │ +└────┴────┘ diff --git a/Task/Semordnilap/Java/semordnilap.java b/Task/Semordnilap/Java/semordnilap.java new file mode 100644 index 0000000000..e973f04a9a --- /dev/null +++ b/Task/Semordnilap/Java/semordnilap.java @@ -0,0 +1,30 @@ +import java.io.*; +import java.util.*; + +public class Semordnilaps { + + public static void main(String[] args) throws IOException { + List lst = readLines("unixdict.txt"); + Set seen = new HashSet<>(); + int count = 0; + for (String w : lst) { + String r = new StringBuilder(w).reverse().toString(); + if (seen.contains(r)) { + if (count++ < 5) + System.out.printf("%-10s %-10s\n", w, r); + } else seen.add(w); + } + System.out.println("\nSemordnilap pairs found: " + count); + } + + private static List readLines(String fn) throws IOException { + List lines; + try (BufferedReader br = new BufferedReader(new FileReader(fn))) { + lines = new ArrayList<>(); + String line; + while ((line = br.readLine()) != null) + lines.add(line.trim().toLowerCase()); + } + return lines; + } +} diff --git a/Task/Semordnilap/Julia/semordnilap.julia b/Task/Semordnilap/Julia/semordnilap.julia new file mode 100644 index 0000000000..c4b414f4b6 --- /dev/null +++ b/Task/Semordnilap/Julia/semordnilap.julia @@ -0,0 +1,4 @@ +raw = readdlm("unixdict.txt",String)[:] +inter = intersect(raw,map(reverse,raw)) #find the matching strings/revstrings +res = String[b == 1 && a != reverse(a) && a < reverse(a) ? a : reverse(a) for a in inter, b in 1:2] #create pairs +res = res[res[:,1] .!= res[:,2],:] #get rid of duplicates, palindromes diff --git a/Task/Semordnilap/Liberty-BASIC/semordnilap.liberty b/Task/Semordnilap/Liberty-BASIC/semordnilap.liberty new file mode 100644 index 0000000000..5a6b76e6c6 --- /dev/null +++ b/Task/Semordnilap/Liberty-BASIC/semordnilap.liberty @@ -0,0 +1,44 @@ +print "Loading dictionary." +open "unixdict.txt" for input as #1 +while not(eof(#1)) + line input #1, a$ + dict$=dict$+" "+a$ +wend +close #1 + +print "Dictionary loaded." +print "Seaching for semordnilaps." + +semo$=" " 'string to hold words with semordnilaps + +do + i=i+1 + w$=word$(dict$,i) + p$=reverseString$(w$) + if w$<>p$ then + p$=" "+p$+" " + if instr(semo$,p$) = 0 then + if instr(dict$,p$) then + pairs=pairs+1 + print w$+" /"+p$ + semo$=semo$+w$+p$ + end if + end if + end if + scan +loop until w$="" + +print "Total number of unique semordnilap pairs is ";pairs +wait + +Function isPalindrome(string$) + string$ = Lower$(string$) + reverseString$ = reverseString$(string$) + If string$ = reverseString$ Then isPalindrome = 1 +End Function + +Function reverseString$(string$) + For i = Len(string$) To 1 Step -1 + reverseString$ = reverseString$ + Mid$(string$, i, 1) + Next i +End Function diff --git a/Task/Semordnilap/Mathematica/semordnilap.math b/Task/Semordnilap/Mathematica/semordnilap.math new file mode 100644 index 0000000000..d4121e1e33 --- /dev/null +++ b/Task/Semordnilap/Mathematica/semordnilap.math @@ -0,0 +1,3 @@ +data = Import["http://www.puzzlers.org/pub/wordlists/unixdict.txt", "List"]; +result = DeleteDuplicates[ Select[data, MemberQ[data, StringReverse[#]] && # =!= StringReverse[#] &], (# ===StringReverse[#2]) &]; +Print[Length[result], Take[result, 5]] diff --git a/Task/Semordnilap/NetRexx/semordnilap.netrexx b/Task/Semordnilap/NetRexx/semordnilap.netrexx new file mode 100644 index 0000000000..a6b41de4bc --- /dev/null +++ b/Task/Semordnilap/NetRexx/semordnilap.netrexx @@ -0,0 +1,29 @@ +/* NetRexx */ +options replace format comments java crossref symbols nobinary + +/* REXX *************************************************************** +* 07.09.2012 Walter Pachl +**********************************************************************/ +fid = 'unixdict.txt' /* the test dictionary */ +ifi = File(fid) +ifr = BufferedReader(FileReader(ifi)) +have = '' /* words encountered */ +pi = 0 /* number of palindromes */ +loop label j_ forever /* as long there is input */ + line = ifr.readLine /* read a line (String) */ + if line = null then leave j_ /* NULL indicates EOF */ + w = Rexx(line) /* each line contains 1 word */ + If w > '' Then Do /* not a blank line */ + r = w.reverse /* reverse it */ + If have[r] > '' Then Do /* was already encountered */ + pi = pi + 1 /* increment number of pal's */ + If pi <= 5 Then /* the first 5 are listed */ + Say have[r] w + End + have[w] = w /* remember the word */ + End + end j_ +ifr.close + +Say pi 'words in' fid 'have a palindrome' /* total number found */ +return diff --git a/Task/Semordnilap/OCaml/semordnilap.ocaml b/Task/Semordnilap/OCaml/semordnilap.ocaml new file mode 100644 index 0000000000..0576a3ce7b --- /dev/null +++ b/Task/Semordnilap/OCaml/semordnilap.ocaml @@ -0,0 +1,34 @@ +module StrSet = Set.Make(String) + +let str_rev s = + let len = String.length s in + let r = String.create len in + for i = 0 to len - 1 do + r.[i] <- s.[len - 1 - i] + done; + (r) + +let input_line_opt ic = + try Some (input_line ic) + with End_of_file -> close_in ic; None + +let () = + let ic = open_in "unixdict.txt" in + let rec aux set acc = + match input_line_opt ic with + | Some word -> + let rev = str_rev word in + if StrSet.mem rev set + then aux set ((word, rev) :: acc) + else aux (StrSet.add word set) acc + | None -> + (acc) + in + let pairs = aux StrSet.empty [] in + let len = List.length pairs in + Printf.printf "Semordnilap pairs: %d\n" len; + Random.self_init (); + for i = 1 to 5 do + let (word, rev) = List.nth pairs (Random.int len) in + Printf.printf " %s %s\n" word rev + done diff --git a/Task/Semordnilap/PHP/semordnilap.php b/Task/Semordnilap/PHP/semordnilap.php new file mode 100644 index 0000000000..0f3a996bc3 --- /dev/null +++ b/Task/Semordnilap/PHP/semordnilap.php @@ -0,0 +1,15 @@ + $reversed_word) + $words[$word] = $reversed_word; +} +echo count($words), "\n"; +// array_rand() returns keys, not values +foreach (array_rand($words, 5) as $word) + echo "$word $words[$word]\n"; diff --git a/Task/Semordnilap/PL-I/semordnilap.pli b/Task/Semordnilap/PL-I/semordnilap.pli new file mode 100644 index 0000000000..d8dd5b89ca --- /dev/null +++ b/Task/Semordnilap/PL-I/semordnilap.pli @@ -0,0 +1,41 @@ +find: procedure options (main); /* 20/1/2013 */ + declare word character (20) varying controlled; + declare dict(*) character (20) varying controlled; + declare 1 pair controlled, + 2 a character (20) varying, 2 b character (20) varying; + declare (i, j) fixed binary; + declare in file; + + open file(in) title ('/UNIXDICT.TXT,type(LF),recsize(100)'); + on endfile (in) go to completed_read; + do forever; + allocate word; + get file (in) edit (word) (L); + end; + +completed_read: + free word; /* because at the final allocation, no word was stored. */ + allocate dict(allocation(word)); + do i = 1 to hbound(dict,1); + dict(i) = word; free word; + end; + + /* Search dictionary for pairs: */ + do i = 1 to hbound(dict,1)-1; + do j = i+1 to hbound(dict,1); + if length(dict(i)) = length(dict(j)) then + do; + if dict(i) = reverse(dict(j)) then + do; + allocate pair; pair.a = dict(i); pair.b = dict(j); + end; + end; + end; + end; + + put skip list ('There are ' || trim(allocation(pair)) || ' pairs.'); + + do while (allocation(pair) > 0); + put skip edit (pair) (a, col(20), a); free pair; + end; +end find; diff --git a/Task/Semordnilap/Perl-6/semordnilap.pl6 b/Task/Semordnilap/Perl-6/semordnilap.pl6 new file mode 100644 index 0000000000..cd1b3c3122 --- /dev/null +++ b/Task/Semordnilap/Perl-6/semordnilap.pl6 @@ -0,0 +1,8 @@ +my \words = set slurp("unixdict.txt").lines; + +my \sems = gather for words.list -> \word { + my \drow = word.flip; + take [word,drow] if drow ∈ words and drow lt word; +} + +.say for +sems, sems.pick(5); diff --git a/Task/Semordnilap/Perl/semordnilap.pl b/Task/Semordnilap/Perl/semordnilap.pl new file mode 100644 index 0000000000..1236f1bbb9 --- /dev/null +++ b/Task/Semordnilap/Perl/semordnilap.pl @@ -0,0 +1,7 @@ +while (<>) { + chomp; + my $r = reverse; + $seen{$r}++ and $c++ < 5 and print "$_ $r\n" or $seen{$_}++; +} + +print "$c\n" diff --git a/Task/Semordnilap/Python/semordnilap-1.py b/Task/Semordnilap/Python/semordnilap-1.py new file mode 100644 index 0000000000..ae0e2beb57 --- /dev/null +++ b/Task/Semordnilap/Python/semordnilap-1.py @@ -0,0 +1,11 @@ +>>> with open('unixdict.txt') as f: + wordset = set(f.read().strip().split()) + +>>> revlist = (''.join(word[::-1]) for word in wordset) +>>> pairs = set((wrd, rev) for wrd, rev in zip(wordset, revlist) + if wrd < rev and rev in wordset) +>>> len(pairs) +158 +>>> sorted(pairs, key=lambda p: (len(p[0]), p))[-5:] +[('damon', 'nomad'), ('lager', 'regal'), ('leper', 'repel'), ('lever', 'revel'), ('kramer', 'remark')] +>>> diff --git a/Task/Semordnilap/Python/semordnilap-2.py b/Task/Semordnilap/Python/semordnilap-2.py new file mode 100644 index 0000000000..3842dbf442 --- /dev/null +++ b/Task/Semordnilap/Python/semordnilap-2.py @@ -0,0 +1,16 @@ +import os +import random +# Load file and put it to dictionary as set +dictionary = {word.rstrip(os.linesep) for word in open('unixdict.txt')} + +# List of results +results = [] +for word in dictionary: + # [::-1] reverses string + reversed_word = word[::-1] + if reversed_word in dictionary and word > reversed_word: + results.append((word, reversed_word)) + +print(len(results)) +for words in random.sample(results, 5): + print(' '.join(words)) diff --git a/Task/Semordnilap/REXX/semordnilap-1.rexx b/Task/Semordnilap/REXX/semordnilap-1.rexx new file mode 100644 index 0000000000..d5e120230d --- /dev/null +++ b/Task/Semordnilap/REXX/semordnilap-1.rexx @@ -0,0 +1,19 @@ +/* REXX *************************************************************** +* 07.09.2012 Walter Pachl +**********************************************************************/ +fid='unixdict.txt' /* the test dictionary */ +have.='' /* words encountered */ +pi=0 /* number of palindromes */ +Do li=1 By 1 While lines(fid)>0 /* as long there is input */ + w=linein(fid) /* read a word */ + If w>'' Then Do /* not a blank line */ + r=reverse(w) /* reverse it */ + If have.r>'' Then Do /* was already encountered */ + pi=pi+1 /* increment number of pal's */ + If pi<=5 Then /* the first 5 ale listed */ + Say have.r w + End + have.w=w /* remember the word */ + End + End +Say pi 'words in' fid 'have a palindrome' /* total number found */ diff --git a/Task/Semordnilap/REXX/semordnilap-2.rexx b/Task/Semordnilap/REXX/semordnilap-2.rexx new file mode 100644 index 0000000000..e014ab994e --- /dev/null +++ b/Task/Semordnilap/REXX/semordnilap-2.rexx @@ -0,0 +1,15 @@ +/*REXX program finds palindrome pairs using a dictionary (UNIXDICT.TXT)*/ +#=0 /*number of palindromes (so far).*/ +parse arg iFID .; if iFID=='' then iFID='UNIXDICT.TXT' /*use default?*/ +@.= /*caseless non-duplicated words. */ + do while lines(ifid)\==0; _=linein(iFID); u=translate(space(_,0)) + if length(u)<2 | @.u\=='' then iterate /*can't be a unique pal.*/ + r=reverse(u) + if @.r\=='' then do; #=#+1 /*found palindrome pair.*/ + if #<6 then say @.r',' _ /*only list first 5 pals*/ + end + @.u=_ + end /*while*/ +say /*a unique palindrome pair = a semordnilap*/ +say "There're" # 'unique palindrome pairs in the dictionary file:' iFID + /*stick a fork in it, we're done.*/ diff --git a/Task/Semordnilap/Ruby/semordnilap.rb b/Task/Semordnilap/Ruby/semordnilap.rb new file mode 100644 index 0000000000..761dddaca5 --- /dev/null +++ b/Task/Semordnilap/Ruby/semordnilap.rb @@ -0,0 +1,9 @@ +DICT=File.readlines("unixdict.txt").collect{|line| line.tr("\n", "")} +res=[] +i = 0 +DICT.collect {|z| z.reverse}.sort.each {|z| + i+=1 while z > DICT[i] and i < DICT.length-1 + res.push z if z.eql?(DICT[i]) and z < z.reverse +} +puts "There are #{res.length} semordnilaps, of which the following are 5:" +res.sample(5).each {|z| puts "#{z} #{z.reverse}"} diff --git a/Task/Semordnilap/TUSCRIPT/semordnilap.tuscript b/Task/Semordnilap/TUSCRIPT/semordnilap.tuscript new file mode 100644 index 0000000000..647feee04b --- /dev/null +++ b/Task/Semordnilap/TUSCRIPT/semordnilap.tuscript @@ -0,0 +1,23 @@ +$$ MODE TUSCRIPT,{} +requestdata = REQUEST ("http://www.puzzlers.org/pub/wordlists/unixdict.txt") +DICT semordnilap CREATE 99999 +COMPILE +LOOP r=requestdata +rstrings=STRINGS(r," ? ") +rreverse=REVERSE(rstrings) +revstring=EXCHANGE (rreverse,":'':':'::") +group=APPEND (r,revstring) +sort=ALPHA_SORT (group) +DICT semordnilap APPEND/QUIET/COUNT sort,num,cnt,"","" +ENDLOOP +DICT semordnilap UNLOAD wordgroups,num,howmany +get_palins=FILTER_INDEX (howmany,-," 1 ") +size=SIZE(get_palins) +PRINT "unixdict.txt contains ", size, " palindromes" +PRINT " " +palindromes=SELECT (wordgroups,#get_palins) +LOOP n=1,5 +take5=SELECT (palindromes,#n) +PRINT n,". ",take5 +ENDLOOP +ENDCOMPILE diff --git a/Task/Semordnilap/Tcl/semordnilap.tcl b/Task/Semordnilap/Tcl/semordnilap.tcl new file mode 100644 index 0000000000..9fea9f4850 --- /dev/null +++ b/Task/Semordnilap/Tcl/semordnilap.tcl @@ -0,0 +1,30 @@ +package require Tcl 8.5 +package require http + +# Fetch the words +set t [http::geturl http://www.puzzlers.org/pub/wordlists/unixdict.txt] +set wordlist [split [http::data $t] \n] +http::cleanup $t + +# Build hash table for speed +foreach word $wordlist { + set reversed([string reverse $word]) "dummy" +} + +# Find where a reversal exists +foreach word $wordlist { + if {[info exists reversed($word)] && $word ne [string reverse $word]} { + # Remove to prevent pairs from being printed twice + unset reversed([string reverse $word]) + # Add to collection of pairs + set pairs($word/[string reverse $word]) "dummy" + } +} +set pairlist [array names pairs] ;# NB: pairs are in *arbitrary* order + +# Report what we've found +puts "Found [llength $pairlist] reversed pairs" +foreach pair $pairlist { + puts "Example: $pair" + if {[incr i]>=5} break +} diff --git a/Task/Semordnilap/XPL0/semordnilap.xpl0 b/Task/Semordnilap/XPL0/semordnilap.xpl0 new file mode 100644 index 0000000000..7ead4ada16 --- /dev/null +++ b/Task/Semordnilap/XPL0/semordnilap.xpl0 @@ -0,0 +1,60 @@ +include c:\cxpl\codes; \intrinsic 'code' declarations +string 0; \use zero-terminated strings +def LF=$0A, CR=$0D, EOF=$1A; + +proc RevStr(S); \Reverse order of characters in a string +char S; +int I, J, T; +[J:= 0; +while S(J) do J:= J+1; +J:= J-1; +I:= 0; +while I 42 +} diff --git a/Task/Send-an-unknown-method-call/Go/send-an-unknown-method-call-2.go b/Task/Send-an-unknown-method-call/Go/send-an-unknown-method-call-2.go new file mode 100644 index 0000000000..623167b44a --- /dev/null +++ b/Task/Send-an-unknown-method-call/Go/send-an-unknown-method-call-2.go @@ -0,0 +1,12 @@ +procedure main() + x := foo() # create object + x.m1() # static call of m1 method + # two examples where the method string can be dynamically constructed ... + "foo_m1"(x) # ... need to know class name and method name to construct name + x.__m["m1"] # ... general method (better) +end + +class foo(a,b,c) # define object +method m1(x) +end +end diff --git a/Task/Send-an-unknown-method-call/Java/send-an-unknown-method-call.java b/Task/Send-an-unknown-method-call/Java/send-an-unknown-method-call.java new file mode 100644 index 0000000000..455be733cb --- /dev/null +++ b/Task/Send-an-unknown-method-call/Java/send-an-unknown-method-call.java @@ -0,0 +1,18 @@ +import java.lang.reflect.Method; + +class Example { + public int foo(int x) { + return 42 + x; + } +} + +public class Main { + public static void main(String[] args) throws Exception { + Object example = new Example(); + String name = "foo"; + Class clazz = example.getClass(); + Method meth = clazz.getMethod(name, int.class); + Object result = meth.invoke(example, 5); // result is int wrapped in an object (Integer) + System.out.println(result); // prints "47" + } +} diff --git a/Task/Send-an-unknown-method-call/JavaScript/send-an-unknown-method-call.js b/Task/Send-an-unknown-method-call/JavaScript/send-an-unknown-method-call.js new file mode 100644 index 0000000000..ecc56a3890 --- /dev/null +++ b/Task/Send-an-unknown-method-call/JavaScript/send-an-unknown-method-call.js @@ -0,0 +1,7 @@ +example = new Object; +example.foo = function(x) { + return 42 + x; +}; + +name = "foo"; +example[name](5) # => 47 diff --git a/Task/Send-an-unknown-method-call/MATLAB/send-an-unknown-method-call.m b/Task/Send-an-unknown-method-call/MATLAB/send-an-unknown-method-call.m new file mode 100644 index 0000000000..625aec66de --- /dev/null +++ b/Task/Send-an-unknown-method-call/MATLAB/send-an-unknown-method-call.m @@ -0,0 +1,5 @@ + funName = 'foo'; % generate function name + feval (funNAME, ...) % evaluation function with optional parameters + + funName = 'a=atan(pi)'; % generate function name + eval (funName, 'printf(''Error\n'')') diff --git a/Task/Send-an-unknown-method-call/Objective-C/send-an-unknown-method-call.m b/Task/Send-an-unknown-method-call/Objective-C/send-an-unknown-method-call.m new file mode 100644 index 0000000000..60b585f8ec --- /dev/null +++ b/Task/Send-an-unknown-method-call/Objective-C/send-an-unknown-method-call.m @@ -0,0 +1,23 @@ +#import + +@interface Example : NSObject { } +- (NSNumber *)foo; +@end + +@implementation Example +- (NSNumber *)foo { + return [NSNumber numberWithInt:42]; +} +@end + +int main (int argc, const char *argv[]) { + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + + id example = [[Example alloc] init]; + SEL selector = @selector(foo); // or = NSSelectorFromString(@"foo"); + NSLog(@"%@", [example performSelector:selector]); + [example release]; + + [pool release]; + return 0; +} diff --git a/Task/Send-an-unknown-method-call/PARI-GP/send-an-unknown-method-call.pari b/Task/Send-an-unknown-method-call/PARI-GP/send-an-unknown-method-call.pari new file mode 100644 index 0000000000..51b5607dee --- /dev/null +++ b/Task/Send-an-unknown-method-call/PARI-GP/send-an-unknown-method-call.pari @@ -0,0 +1,2 @@ +foo()=5; +eval(Str("foo","()")) diff --git a/Task/Send-an-unknown-method-call/PHP/send-an-unknown-method-call.php b/Task/Send-an-unknown-method-call/PHP/send-an-unknown-method-call.php new file mode 100644 index 0000000000..105d62f50f --- /dev/null +++ b/Task/Send-an-unknown-method-call/PHP/send-an-unknown-method-call.php @@ -0,0 +1,15 @@ +$name(5), "\n"; // prints "47" + +// alternately: +echo call_user_func(array($example, $name), 5), "\n"; +?> diff --git a/Task/Send-an-unknown-method-call/Perl-6/send-an-unknown-method-call.pl6 b/Task/Send-an-unknown-method-call/Perl-6/send-an-unknown-method-call.pl6 new file mode 100644 index 0000000000..9931fb8720 --- /dev/null +++ b/Task/Send-an-unknown-method-call/Perl-6/send-an-unknown-method-call.pl6 @@ -0,0 +1,3 @@ +my $object = 42 but role { method add-me($x) { self + $x } } +my $name = 'add-me'; +say $object."$name"(5); # 47 diff --git a/Task/Send-an-unknown-method-call/Perl/send-an-unknown-method-call.pl b/Task/Send-an-unknown-method-call/Perl/send-an-unknown-method-call.pl new file mode 100644 index 0000000000..6e7df7980e --- /dev/null +++ b/Task/Send-an-unknown-method-call/Perl/send-an-unknown-method-call.pl @@ -0,0 +1,12 @@ +package Example; +sub new { + bless {} +} +sub foo { + my ($self, $x) = @_; + return 42 + $x; +} + +package main; +my $name = "foo"; +print Example->new->$name(5), "\n"; # prints "47" diff --git a/Task/Send-an-unknown-method-call/PicoLisp/send-an-unknown-method-call.l b/Task/Send-an-unknown-method-call/PicoLisp/send-an-unknown-method-call.l new file mode 100644 index 0000000000..905ec6565e --- /dev/null +++ b/Task/Send-an-unknown-method-call/PicoLisp/send-an-unknown-method-call.l @@ -0,0 +1 @@ +(send (expression) Obj arg1 arg2) diff --git a/Task/Send-an-unknown-method-call/Pike/send-an-unknown-method-call.pike b/Task/Send-an-unknown-method-call/Pike/send-an-unknown-method-call.pike new file mode 100644 index 0000000000..232b19838e --- /dev/null +++ b/Task/Send-an-unknown-method-call/Pike/send-an-unknown-method-call.pike @@ -0,0 +1,3 @@ +string unknown = "format_nice"; +object now = Calendar.now(); +now[unknown](); diff --git a/Task/Send-an-unknown-method-call/Python/send-an-unknown-method-call.py b/Task/Send-an-unknown-method-call/Python/send-an-unknown-method-call.py new file mode 100644 index 0000000000..1877434c3b --- /dev/null +++ b/Task/Send-an-unknown-method-call/Python/send-an-unknown-method-call.py @@ -0,0 +1,6 @@ +class Example(object): + def foo(self, x): + return 42 + x + +name = "foo" +getattr(Example(), name)(5) # => 47 diff --git a/Task/Send-an-unknown-method-call/Qi/send-an-unknown-method-call.qi b/Task/Send-an-unknown-method-call/Qi/send-an-unknown-method-call.qi new file mode 100644 index 0000000000..390fef347f --- /dev/null +++ b/Task/Send-an-unknown-method-call/Qi/send-an-unknown-method-call.qi @@ -0,0 +1,6 @@ +(define foo -> 5) + +(define execute-function + Name -> (eval [(INTERN Name)])) + +(execute-function "foo") diff --git a/Task/Send-an-unknown-method-call/Ruby/send-an-unknown-method-call-1.rb b/Task/Send-an-unknown-method-call/Ruby/send-an-unknown-method-call-1.rb new file mode 100644 index 0000000000..6e3c29759d --- /dev/null +++ b/Task/Send-an-unknown-method-call/Ruby/send-an-unknown-method-call-1.rb @@ -0,0 +1,14 @@ +class Example + def foo + 42 + end + def bar(arg1, arg2, &block) + block.call arg1, arg2 + end +end + +symbol = :foo +Example.new.send symbol # => 42 +Example.new.send( :bar, 1, 2 ) { |x,y| x+y } # => 3 +args = [1, 2] +Example.new.send( "bar", *args ) { |x,y| x+y } # => 3 diff --git a/Task/Send-an-unknown-method-call/Ruby/send-an-unknown-method-call-2.rb b/Task/Send-an-unknown-method-call/Ruby/send-an-unknown-method-call-2.rb new file mode 100644 index 0000000000..4d82a9e8bc --- /dev/null +++ b/Task/Send-an-unknown-method-call/Ruby/send-an-unknown-method-call-2.rb @@ -0,0 +1,11 @@ +class Example + private + def privacy; "secret"; end + public + def publicity; "hi"; end +end + +e = Example.new +e.public_send :publicity # => "hi" +e.public_send :privacy # raises NoMethodError +e.send :privacy # => "secret" diff --git a/Task/Send-an-unknown-method-call/Smalltalk/send-an-unknown-method-call.st b/Task/Send-an-unknown-method-call/Smalltalk/send-an-unknown-method-call.st new file mode 100644 index 0000000000..1069d64db7 --- /dev/null +++ b/Task/Send-an-unknown-method-call/Smalltalk/send-an-unknown-method-call.st @@ -0,0 +1,9 @@ +Object subclass: #Example. + +Example extend [ + foo: x [ + ^ 42 + x ] ]. + +symbol := 'foo:' asSymbol. " same as symbol := #foo: " + +Example new perform: symbol with: 5. " returns 47 " diff --git a/Task/Send-an-unknown-method-call/Tcl/send-an-unknown-method-call.tcl b/Task/Send-an-unknown-method-call/Tcl/send-an-unknown-method-call.tcl new file mode 100644 index 0000000000..a4bbf840cf --- /dev/null +++ b/Task/Send-an-unknown-method-call/Tcl/send-an-unknown-method-call.tcl @@ -0,0 +1,14 @@ +package require Tcl 8.6 +oo::class create Example { + method foo {} {return 42} + method 1 {s} {puts "fee$s"} + method 2 {s} {puts "fie$s"} + method 3 {s} {puts "foe$s"} + method 4 {s} {puts "fum$s"} +} +set eg [Example new] +set mthd [format "%c%c%c" 102 111 111]; # A "foo" by any other means would smell as sweet +puts [$eg $mthd] +for {set i 1} {$i <= 4} {incr i} { + $eg $i ... +} diff --git a/Task/Send-email/0DESCRIPTION b/Task/Send-email/0DESCRIPTION new file mode 100644 index 0000000000..f53408c05f --- /dev/null +++ b/Task/Send-email/0DESCRIPTION @@ -0,0 +1,6 @@ +Write a function to send an email. The function should have parameters for setting From, To and Cc addresses; the Subject, and the message text, and optionally fields for the server name and login details. +* If appropriate, explain what notifications of problems/success are given. +* Solutions using libraries or functions from the language are preferred, but failing that, external programs can be used with an explanation. +* Note how portable the solution given is between operating systems when multi-OS languages are used. + +(Remember to obfuscate any sensitive data used in examples) diff --git a/Task/Send-email/1META.yaml b/Task/Send-email/1META.yaml new file mode 100644 index 0000000000..688669690e --- /dev/null +++ b/Task/Send-email/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Networking and Web Interaction diff --git a/Task/Send-email/Ada/send-email.ada b/Task/Send-email/Ada/send-email.ada new file mode 100644 index 0000000000..63de933e67 --- /dev/null +++ b/Task/Send-email/Ada/send-email.ada @@ -0,0 +1,27 @@ +with AWS.SMTP, AWS.SMTP.Client, AWS.SMTP.Authentication.Plain; +with Ada.Text_IO; +use Ada, AWS; + +procedure Sendmail is + Status : SMTP.Status; + Auth : aliased constant SMTP.Authentication.Plain.Credential := + SMTP.Authentication.Plain.Initialize ("id", "password"); + Isp : SMTP.Receiver; +begin + Isp := + SMTP.Client.Initialize + ("smtp.mail.com", + Port => 5025, + Credential => Auth'Unchecked_Access); + SMTP.Client.Send + (Isp, + From => SMTP.E_Mail ("Me", "me@some.org"), + To => SMTP.E_Mail ("You", "you@any.org"), + Subject => "subject", + Message => "Here is the text", + Status => Status); + if not SMTP.Is_Ok (Status) then + Text_IO.Put_Line + ("Can't send message :" & SMTP.Status_Message (Status)); + end if; +end Sendmail; diff --git a/Task/Send-email/AutoHotkey/send-email.ahk b/Task/Send-email/AutoHotkey/send-email.ahk new file mode 100644 index 0000000000..6670e26818 --- /dev/null +++ b/Task/Send-email/AutoHotkey/send-email.ahk @@ -0,0 +1,37 @@ +sSubject:= "greeting" +sText := "hello" +sFrom := "ahk@rosettacode" +sTo := "whomitmayconcern" + +sServer := "smtp.gmail.com" ; specify your SMTP server +nPort := 465 ; 25 +bTLS := True ; False +inputbox, sUsername, Username +inputbox, sPassword, password + +COM_Init() +pmsg := COM_CreateObject("CDO.Message") +pcfg := COM_Invoke(pmsg, "Configuration") +pfld := COM_Invoke(pcfg, "Fields") + +COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/sendusing", 2) +COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout", 60) +COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpserver", sServer) +COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpserverport", nPort) +COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpusessl", bTLS) +COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1) +COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/sendusername", sUsername) +COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/sendpassword", sPassword) +COM_Invoke(pfld, "Update") + +COM_Invoke(pmsg, "Subject", sSubject) +COM_Invoke(pmsg, "From", sFrom) +COM_Invoke(pmsg, "To", sTo) +COM_Invoke(pmsg, "TextBody", sText) +COM_Invoke(pmsg, "Send") + +COM_Release(pfld) +COM_Release(pcfg) +COM_Release(pmsg) +COM_Term() +#Include COM.ahk diff --git a/Task/Send-email/BBC-BASIC/send-email.bbc b/Task/Send-email/BBC-BASIC/send-email.bbc new file mode 100644 index 0000000000..3265b81007 --- /dev/null +++ b/Task/Send-email/BBC-BASIC/send-email.bbc @@ -0,0 +1,84 @@ + INSTALL @lib$+"SOCKLIB" + + Server$ = "smtp.gmail.com" + From$ = "sender@somewhere" + To$ = "recipient@elsewhere" + CC$ = "another@nowhere" + Subject$ = "Rosetta Code" + Message$ = "This is a test of sending email." + + PROCsendmail(Server$, From$, To$, CC$, "", Subject$, "", Message$) + END + + DEF PROCsendmail(smtp$,from$,to$,cc$,bcc$,subject$,replyto$,body$) + LOCAL D%, S%, skt%, reply$ + DIM D% LOCAL 31, S% LOCAL 15 + + SYS "GetLocalTime", S% + SYS "GetDateFormat", 0, 0, S%, "ddd, dd MMM yyyy ", D%, 18 + SYS "GetTimeFormat", 0, 0, S%, "HH:mm:ss +0000", D%+17, 15 + D%?31 = 13 + + PROC_initsockets + skt% = FN_tcpconnect(smtp$,"mail") + IF skt% <= 0 skt% = FN_tcpconnect(smtp$,"25") + IF skt% <= 0 ERROR 100, "Failed to connect to SMTP server" + IF FN_readlinesocket(skt%, 1000, reply$) + WHILE FN_readlinesocket(skt%, 10, reply$) > 0 : ENDWHILE + + PROCsend(skt%,"HELO "+FN_gethostname) + PROCmail(skt%,"MAIL FROM: ",from$) + IF to$<>"" PROClist(skt%,to$) + IF cc$<>"" PROClist(skt%,cc$) + IF bcc$<>"" PROClist(skt%,bcc$) + PROCsend(skt%, "DATA") + + IF FN_writelinesocket(skt%, "Date: "+$D%) + IF FN_writelinesocket(skt%, "From: "+from$) + IF FN_writelinesocket(skt%, "To: "+to$) + IF cc$<>"" IF FN_writelinesocket(skt%, "Cc: "+cc$) + IF subject$<>"" IF FN_writelinesocket(skt%, "Subject: "+subject$) + IF replyto$<>"" IF FN_writelinesocket(skt%, "Reply-To: "+replyto$) + IF FN_writelinesocket(skt%, "MIME-Version: 1.0") + IF FN_writelinesocket(skt%, "Content-type: text/plain; charset=US-ASCII") + + IF FN_writelinesocket(skt%, "") + IF FN_writelinesocket(skt%, body$) + IF FN_writelinesocket(skt%, ".") + + PROCsend(skt%,"QUIT") + + PROC_exitsockets + ENDPROC + + DEF PROClist(skt%,list$) + LOCAL comma% + REPEAT + WHILE ASClist$=32 list$=MID$(list$,2):ENDWHILE + comma% = INSTR(list$,",") + IF comma% THEN + PROCmail(skt%,"RCPT TO: ",LEFT$(list$,comma%-1)) + list$ = MID$(list$,comma%+1) + ELSE + PROCmail(skt%,"RCPT TO: ",list$) + ENDIF + UNTIL comma% = 0 + ENDPROC + + DEF PROCmail(skt%,cmd$,mail$) + LOCAL I%,J% + I% = INSTR(mail$,"<") + J% = INSTR(mail$,">",I%) + IF I% IF J% THEN + PROCsend(skt%, cmd$+MID$(mail$,I%,J%-I%+1)) + ELSE + PROCsend(skt%, cmd$+"<"+mail$+">") + ENDIF + ENDPROC + + DEF PROCsend(skt%,cmd$) + LOCAL reply$ + IF FN_writelinesocket(skt%,cmd$) < 0 THEN ERROR 100, "Send failed" + IF FN_readlinesocket(skt%, 200, reply$) + WHILE FN_readlinesocket(skt%, 10, reply$) > 0 : ENDWHILE + ENDPROC diff --git a/Task/Send-email/C++/send-email.cpp b/Task/Send-email/C++/send-email.cpp new file mode 100644 index 0000000000..7148839209 --- /dev/null +++ b/Task/Send-email/C++/send-email.cpp @@ -0,0 +1,46 @@ +// on Ubuntu: sudo apt-get install libpoco-dev +// or see http://pocoproject.org/ +// compile with: g++ -Wall -O3 send-mail-cxx.C -lPocoNet -lPocoFoundation + +#include +#include +#include +#include + +using namespace Poco::Net; + +int main (int argc, char **argv) +{ + try + { + MailMessage msg; + + msg.addRecipient (MailRecipient (MailRecipient::PRIMARY_RECIPIENT, + "alice@example.com", + "Alice Moralis")); + msg.addRecipient (MailRecipient (MailRecipient::CC_RECIPIENT, + "pat@example.com", + "Patrick Kilpatrick")); + msg.addRecipient (MailRecipient (MailRecipient::BCC_RECIPIENT, + "mike@example.com", + "Michael Carmichael")); + + msg.setSender ("Roy Kilroy "); + + msg.setSubject ("Rosetta Code"); + msg.setContent ("Sending mail from C++ using POCO C++ Libraries"); + + SMTPClientSession smtp ("mail.example.com"); // SMTP server name + smtp.login (); + smtp.sendMessage (msg); + smtp.close (); + std::cerr << "Sent mail successfully!" << std::endl; + } + catch (std::exception &e) + { + std::cerr << "failed to send mail: " << e.what() << std::endl; + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} diff --git a/Task/Send-email/D/send-email.d b/Task/Send-email/D/send-email.d new file mode 100644 index 0000000000..0deef206e0 --- /dev/null +++ b/Task/Send-email/D/send-email.d @@ -0,0 +1,10 @@ +import std.net.curl; + +void main() { + auto smtp = SMTP("smtps://smtp.gmail.com"); + smtp.setAuthentication("someuser@gmail.com", "somepassword"); + smtp.mailTo = [""]; + smtp.mailFrom = ""; + smtp.message = "Subject:test\n\nExample Message"; + smtp.perform(); +} diff --git a/Task/Send-email/Delphi/send-email.delphi b/Task/Send-email/Delphi/send-email.delphi new file mode 100644 index 0000000000..57eb1438db --- /dev/null +++ b/Task/Send-email/Delphi/send-email.delphi @@ -0,0 +1,33 @@ +procedure SendEmail; +var + msg: TIdMessage; + smtp: TIdSMTP; +begin + smtp := TIdSMTP.Create; + try + smtp.Host := 'smtp.server.com'; + smtp.Port := 587; + smtp.Username := 'login'; + smtp.Password := 'password'; + smtp.AuthType := satNone; + smtp.Connect; + msg := TIdMessage.Create(nil); + try + with msg.Recipients.Add do begin + Address := 'doug@gmail.com'; + Name := 'Doug'; + end; + with msg.Sender do begin + Address := 'fred@server.com'; + Name := 'Fred'; + end; + msg.Subject := 'subj'; + msg.Body.Text := 'here goes email message'; + smtp.Send(msg); + finally + msg.Free; + end; + finally + smtp.Free; + end; +end; diff --git a/Task/Send-email/Factor/send-email.factor b/Task/Send-email/Factor/send-email.factor new file mode 100644 index 0000000000..afda093ae8 --- /dev/null +++ b/Task/Send-email/Factor/send-email.factor @@ -0,0 +1,14 @@ +USING: kernel accessors smtp io.sockets namespaces ; +IN: learn + +: send-mail ( from to cc subject body -- ) + "smtp.gmail.com" 587 smtp-server set + smtp-tls? on + "noneofyourbuisness@gmail.com" "password" smtp-auth set + + swap >>from + swap >>to + swap >>cc + swap >>subject + swap >>body + send-email ; diff --git a/Task/Send-email/Fantom/send-email.fantom b/Task/Send-email/Fantom/send-email.fantom new file mode 100644 index 0000000000..a706c67501 --- /dev/null +++ b/Task/Send-email/Fantom/send-email.fantom @@ -0,0 +1,32 @@ +using email + +class Mail +{ + // create a client for sending email - add your own host/username/password + static SmtpClient makeClient () + { + client := SmtpClient + { + host = "yourhost" + username = "yourusername" + password = "yourpassword" + } + return client + } + + public static Void main() + { + // create email + email := Email + { + to = ["to@addr"] + from = "from@addr" + cc = ["cc@addr"] + subject = test" + body = TextPart { text = "test email" } + } + + // create client and send email + makeClient.send (email) + } +} diff --git a/Task/Send-email/Go/send-email.go b/Task/Send-email/Go/send-email.go new file mode 100644 index 0000000000..217233450d --- /dev/null +++ b/Task/Send-email/Go/send-email.go @@ -0,0 +1,161 @@ +package main + +import ( + "bufio" + "bytes" + "errors" + "flag" + "fmt" + "io/ioutil" + "net/smtp" + "os" + "strings" +) + +type Message struct { + From string + To []string + Cc []string + Subject string + Content string +} + +func (m Message) Bytes() (r []byte) { + to := strings.Join(m.To, ",") + cc := strings.Join(m.Cc, ",") + + r = append(r, []byte("From: "+m.From+"\n")...) + r = append(r, []byte("To: "+to+"\n")...) + r = append(r, []byte("Cc: "+cc+"\n")...) + r = append(r, []byte("Subject: "+m.Subject+"\n\n")...) + r = append(r, []byte(m.Content)...) + + return +} + +func (m Message) Send(host string, port int, user, pass string) (err error) { + err = check(host, user, pass) + if err != nil { + return + } + + err = smtp.SendMail(fmt.Sprintf("%v:%v", host, port), + smtp.PlainAuth("", user, pass, host), + m.From, + m.To, + m.Bytes(), + ) + + return +} + +func check(host, user, pass string) error { + if host == "" { + return errors.New("Bad host") + } + if user == "" { + return errors.New("Bad username") + } + if pass == "" { + return errors.New("Bad password") + } + + return nil +} + +func main() { + var flags struct { + host string + port int + user string + pass string + } + flag.StringVar(&flags.host, "host", "", "SMTP server to connect to") + flag.IntVar(&flags.port, "port", 587, "Port to connect to SMTP server on") + flag.StringVar(&flags.user, "user", "", "Username to authenticate with") + flag.StringVar(&flags.pass, "pass", "", "Password to authenticate with") + flag.Parse() + + err := check(flags.host, flags.user, flags.pass) + if err != nil { + flag.Usage() + os.Exit(1) + } + + bufin := bufio.NewReader(os.Stdin) + + fmt.Printf("From: ") + from, err := bufin.ReadString('\n') + if err != nil { + fmt.Printf("Error: %v\n", err) + os.Exit(1) + } + from = strings.Trim(from, " \t\n\r") + + var to []string + for { + fmt.Printf("To (Blank to finish): ") + tmp, err := bufin.ReadString('\n') + if err != nil { + fmt.Printf("Error: %v\n", err) + os.Exit(1) + } + tmp = strings.Trim(tmp, " \t\n\r") + + if tmp == "" { + break + } + + to = append(to, tmp) + } + + var cc []string + for { + fmt.Printf("Cc (Blank to finish): ") + tmp, err := bufin.ReadString('\n') + if err != nil { + fmt.Printf("Error: %v\n", err) + os.Exit(1) + } + tmp = strings.Trim(tmp, " \t\n\r") + + if tmp == "" { + break + } + + cc = append(cc, tmp) + } + + fmt.Printf("Subject: ") + subject, err := bufin.ReadString('\n') + if err != nil { + fmt.Printf("Error: %v\n", err) + os.Exit(1) + } + subject = strings.Trim(subject, " \t\n\r") + + fmt.Printf("Content (Until EOF):\n") + content, err := ioutil.ReadAll(os.Stdin) + if err != nil { + fmt.Printf("Error: %v\n", err) + os.Exit(1) + } + content = bytes.Trim(content, " \t\n\r") + + m := Message{ + From: from, + To: to, + Cc: cc, + Subject: subject, + Content: string(content), + } + + fmt.Printf("\nSending message...\n") + err = m.Send(flags.host, flags.port, flags.user, flags.pass) + if err != nil { + fmt.Printf("Error: %v\n", err) + os.Exit(1) + } + + fmt.Printf("Message sent.\n") +} diff --git a/Task/Send-email/Java/send-email.java b/Task/Send-email/Java/send-email.java new file mode 100644 index 0000000000..f534153f87 --- /dev/null +++ b/Task/Send-email/Java/send-email.java @@ -0,0 +1,56 @@ +import java.util.Properties; + +import javax.mail.MessagingException; +import javax.mail.Session; +import javax.mail.Transport; +import javax.mail.Message.RecipientType; +import javax.mail.internet.InternetAddress; +import javax.mail.internet.MimeMessage; + +/** + * Mail + */ +public class Mail +{ + /** + * Session + */ + protected Session session; + + /** + * Mail constructor. + * + * @param host Host + */ + public Mail(String host) + { + Properties properties = new Properties(); + properties.put("mail.smtp.host", host); + session = Session.getDefaultInstance(properties); + } + + /** + * Send email message. + * + * @param from From + * @param tos Recipients + * @param ccs CC Recipients + * @param subject Subject + * @param text Text + * @throws MessagingException + */ + public void send(String from, String tos[], String ccs[], String subject, + String text) + throws MessagingException + { + MimeMessage message = new MimeMessage(session); + message.setFrom(new InternetAddress(from)); + for (String to : tos) + message.addRecipient(RecipientType.TO, new InternetAddress(to)); + for (String cc : ccs) + message.addRecipient(RecipientType.TO, new InternetAddress(cc)); + message.setSubject(subject); + message.setText(text); + Transport.send(message); + } +} diff --git a/Task/Send-email/Liberty-BASIC/send-email.liberty b/Task/Send-email/Liberty-BASIC/send-email.liberty new file mode 100644 index 0000000000..c2b53b985b --- /dev/null +++ b/Task/Send-email/Liberty-BASIC/send-email.liberty @@ -0,0 +1,25 @@ +text$ = "This is a simple text message." + +from$ = "user@diga.me.es" +username$ = "me@diga.me.es" +'password$ = "***********" +recipient$ = "somebody@gmail.com" +server$ = "auth.smtp.1and1.co.uk:25" +subject$ = chr$( 34) +text$ +chr$( 34) ' Use quotes to allow spaces in text. +message$ = chr$( 34) +"Hello world." +chr$( 34) +attach$ = "a.txt" +logfile$ = "sendemail.log" + +cmd$ = " -f "; from$;_ 'from + " -t "; recipient$;_ 'to + " -u "; subject$;_ 'subject + " -s "; server$;_ 'server + " -m "; message$;_ 'message + " -a "; attach$;_ 'file to attach + " -l "; logfile$;_ 'file to log result in + " -xu "; username$ 'smtp user name + '" -xp "; password$ 'smtp password not given so will ask in a CMD window + +run "sendEmail.exe "; cmd$, HIDE + +end diff --git a/Task/Send-email/LotusScript/send-email.lotusscript b/Task/Send-email/LotusScript/send-email.lotusscript new file mode 100644 index 0000000000..abd13d4a0a --- /dev/null +++ b/Task/Send-email/LotusScript/send-email.lotusscript @@ -0,0 +1,9 @@ +Dim session As New NotesSession +Dim db As NotesDatabase +Dim doc As NotesDocument +Set db = session.CurrentDatabase +Set doc = New NotesDocument( db ) +doc.Form = "Memo" +doc.SendTo = "John Doe" +doc.Subject = "Subject of this mail" +Call doc.Send( False ) diff --git a/Task/Send-email/Lua/send-email.lua b/Task/Send-email/Lua/send-email.lua new file mode 100644 index 0000000000..3245cbdd7b --- /dev/null +++ b/Task/Send-email/Lua/send-email.lua @@ -0,0 +1,31 @@ +-- load the smtp support +local smtp = require("socket.smtp") + +-- Connects to server "localhost" and sends a message to users +-- "fulano@example.com", "beltrano@example.com", +-- and "sicrano@example.com". +-- Note that "fulano" is the primary recipient, "beltrano" receives a +-- carbon copy and neither of them knows that "sicrano" received a blind +-- carbon copy of the message. +from = "" + +rcpt = { + "", + "", + "" +} + +mesgt = { + headers = { + to = "Fulano da Silva ", + cc = '"Beltrano F. Nunes" ', + subject = "My first message" + }, + body = "I hope this works. If it does, I can send you another 1000 copies." +} + +r, e = smtp.send{ + from = from, + rcpt = rcpt, + source = smtp.message(mesgt) +} diff --git a/Task/Send-email/Mathematica/send-email-1.math b/Task/Send-email/Mathematica/send-email-1.math new file mode 100644 index 0000000000..f335975a92 --- /dev/null +++ b/Task/Send-email/Mathematica/send-email-1.math @@ -0,0 +1,3 @@ +SendMail["From" -> "from@email.com", "To" -> "to@email.com", + "Subject" -> "Sending Email from Mathematica", "Body" -> "Hello world!", + "Server" -> "smtp.email.com"] diff --git a/Task/Send-email/Mathematica/send-email-2.math b/Task/Send-email/Mathematica/send-email-2.math new file mode 100644 index 0000000000..e282d5f8a2 --- /dev/null +++ b/Task/Send-email/Mathematica/send-email-2.math @@ -0,0 +1,15 @@ +"To" +"Cc" +"Bcc" +"Subject" +"Body" +"Attachments" +"From" +"Server" +"EncryptionProtocol" +"Fullname" +"Password" +"PortNumber" +"ReplyTo" +"ServerAuthentication" +"UserName" diff --git a/Task/Send-email/NewLISP/send-email.newlisp b/Task/Send-email/NewLISP/send-email.newlisp new file mode 100644 index 0000000000..2e59729540 --- /dev/null +++ b/Task/Send-email/NewLISP/send-email.newlisp @@ -0,0 +1,2 @@ +(module "smtp.lsp") +(SMTP:send-mail "user@asite.com" "somebody@isp.com" "Greetings" "How are you today? - john doe -" "smtp.asite.com" "user" "password") diff --git a/Task/Send-email/OCaml/send-email.ocaml b/Task/Send-email/OCaml/send-email.ocaml new file mode 100644 index 0000000000..c7b45ab93f --- /dev/null +++ b/Task/Send-email/OCaml/send-email.ocaml @@ -0,0 +1,11 @@ +let h = Smtp.connect "smtp.gmail.fr";; +Smtp.helo h "hostname";; +Smtp.mail h "";; +Smtp.rcpt h "";; +let email_header = "\ +From: John Smith +To: John Doe +Subject: surprise";; +let email_msg = "Happy Birthday";; +Smtp.data h (email_header ^ "\r\n\r\n" ^ email_msg);; +Smtp.quit h;; diff --git a/Task/Send-email/PHP/send-email.php b/Task/Send-email/PHP/send-email.php new file mode 100644 index 0000000000..9c400e28b5 --- /dev/null +++ b/Task/Send-email/PHP/send-email.php @@ -0,0 +1 @@ +mail('hello@world.net', 'My Subject', "A Message!", "From: my@address.com"); diff --git a/Task/Send-email/Perl/send-email-1.pl b/Task/Send-email/Perl/send-email-1.pl new file mode 100644 index 0000000000..e7f9abfdd1 --- /dev/null +++ b/Task/Send-email/Perl/send-email-1.pl @@ -0,0 +1,33 @@ +use Net::SMTP; +use Authen::SASL; + # Net::SMTP's 'auth' method needs Authen::SASL to work, but + # this is undocumented, and if you don't have the latter, the + # method will just silently fail. Hence we explicitly use + # Authen::SASL here. + +sub send_email + {my %o = + (from => '', to => [], cc => [], + subject => '', body => '', + host => '', user => '', password => '', + @_); + ref $o{$_} or $o{$_} = [$o{$_}] foreach 'to', 'cc'; + + my $smtp = new Net::SMTP($o{host} ? $o{host} : ()) + or die "Couldn't connect to SMTP server"; + + $o{password} and + $smtp->auth($o{user}, $o{password}) || + die 'SMTP authentication failed'; + + $smtp->mail($o{user}); + $smtp->recipient($_) foreach @{$o{to}}, @{$o{cc}}; + $smtp->data; + $o{from} and $smtp->datasend("From: $o{from}\n"); + $smtp->datasend('To: ' . join(', ', @{$o{to}}) . "\n"); + @{$o{cc}} and $smtp->datasend('Cc: ' . join(', ', @{$o{cc}}) . "\n"); + $o{subject} and $smtp->datasend("Subject: $o{subject}\n"); + $smtp->datasend("\n$o{body}"); + $smtp->dataend; + + return 1;} diff --git a/Task/Send-email/Perl/send-email-2.pl b/Task/Send-email/Perl/send-email-2.pl new file mode 100644 index 0000000000..610ca5eb1a --- /dev/null +++ b/Task/Send-email/Perl/send-email-2.pl @@ -0,0 +1,9 @@ +send_email + from => 'A. T. Tappman', + to => ['suchandsuch@example.com', 'soandso@example.org'], + cc => 'somebodyelse@example.net', + subject => 'Important message', + body => 'I yearn for you tragically.', + host => 'smtp.example.com:587', + user => 'tappman@example.com', + password => 'yossarian'; diff --git a/Task/Send-email/Perl/send-email-3.pl b/Task/Send-email/Perl/send-email-3.pl new file mode 100644 index 0000000000..d3ef72c81d --- /dev/null +++ b/Task/Send-email/Perl/send-email-3.pl @@ -0,0 +1,3 @@ +send_email + to => 'suchandsuch@example.com', + user => 'tappman@example.com'; diff --git a/Task/Send-email/PicoLisp/send-email.l b/Task/Send-email/PicoLisp/send-email.l new file mode 100644 index 0000000000..6cbcc7924c --- /dev/null +++ b/Task/Send-email/PicoLisp/send-email.l @@ -0,0 +1 @@ +(mail "localhost" 25 "me@from.org" "you@to.org" "Subject" NIL "Hello") diff --git a/Task/Send-email/Pike/send-email.pike b/Task/Send-email/Pike/send-email.pike new file mode 100644 index 0000000000..7f25b37456 --- /dev/null +++ b/Task/Send-email/Pike/send-email.pike @@ -0,0 +1,8 @@ +int main(){ + string to = "some@email.add"; + string subject = "Hello There."; + string from = "me@myaddr.ess"; + string msg = "Hello there! :)"; + + Protocols.SMTP.Client()->simple_mail(to,subject,from,msg); +} diff --git a/Task/Send-email/PureBasic/send-email.purebasic b/Task/Send-email/PureBasic/send-email.purebasic new file mode 100644 index 0000000000..c9688acebf --- /dev/null +++ b/Task/Send-email/PureBasic/send-email.purebasic @@ -0,0 +1,15 @@ +InitNetwork() + +CreateMail(0, "from@mydomain.com", "This is the Subject") + +SetMailBody(0, "Hello " + Chr(10) + "This is a mail !") + +AddMailRecipient(0, "test@yourdomain.com", #PB_Mail_To) + +AddMailRecipient(0, "test2@yourdomain.com", #PB_Mail_Cc) + +If SendMail(0, "smtp.mail.com") + MessageRequester("Information", "Mail correctly sent !") +Else + MessageRequester("Error", "Can't sent the mail !") +EndIf diff --git a/Task/Send-email/Python/send-email-1.py b/Task/Send-email/Python/send-email-1.py new file mode 100644 index 0000000000..b17d27bd61 --- /dev/null +++ b/Task/Send-email/Python/send-email-1.py @@ -0,0 +1,18 @@ +import smtplib + +def sendemail(from_addr, to_addr_list, cc_addr_list, + subject, message, + login, password, + smtpserver='smtp.gmail.com:587'): + header = 'From: %s\n' % from_addr + header += 'To: %s\n' % ','.join(to_addr_list) + header += 'Cc: %s\n' % ','.join(cc_addr_list) + header += 'Subject: %s\n\n' % subject + message = header + message + + server = smtplib.SMTP(smtpserver) + server.starttls() + server.login(login,password) + problems = server.sendmail(from_addr, to_addr_list, message) + server.quit() + return problems diff --git a/Task/Send-email/Python/send-email-2.py b/Task/Send-email/Python/send-email-2.py new file mode 100644 index 0000000000..09eeecc257 --- /dev/null +++ b/Task/Send-email/Python/send-email-2.py @@ -0,0 +1,7 @@ +sendemail(from_addr = 'python@RC.net', + to_addr_list = ['RC@gmail.com'], + cc_addr_list = ['RC@xx.co.uk'], + subject = 'Howdy', + message = 'Howdy from a python function', + login = 'pythonuser', + password = 'XXXXX') diff --git a/Task/Send-email/REBOL/send-email.rebol b/Task/Send-email/REBOL/send-email.rebol new file mode 100644 index 0000000000..804ce14445 --- /dev/null +++ b/Task/Send-email/REBOL/send-email.rebol @@ -0,0 +1 @@ +send user@host.dom "My message" diff --git a/Task/Send-email/Racket/send-email.rkt b/Task/Send-email/Racket/send-email.rkt new file mode 100644 index 0000000000..d534555d5a --- /dev/null +++ b/Task/Send-email/Racket/send-email.rkt @@ -0,0 +1,14 @@ +#lang racket +(require net/head net/smtp) + +(smtp-send-message + "192.168.0.1" + "Sender " + '("Recipient ") + (standard-message-header + "Sender " + '("Recipient ") + '() ; CC + '() ; BCC + "Subject") + '("Hello World!")) diff --git a/Task/Send-email/Ruby/send-email.rb b/Task/Send-email/Ruby/send-email.rb new file mode 100644 index 0000000000..6abdbcdd93 --- /dev/null +++ b/Task/Send-email/Ruby/send-email.rb @@ -0,0 +1,77 @@ +require 'base64' +require 'net/smtp' +require 'tmail' +require 'mime/types' + +class Email + def initialize(from, to, subject, body, options={}) + @opts = {:attachments => [], :server => 'localhost'}.update(options) + @msg = TMail::Mail.new + @msg.from = from + @msg.to = to + @msg.subject = subject + @msg.cc = @opts[:cc] if @opts[:cc] + @msg.bcc = @opts[:bcc] if @opts[:bcc] + + if @opts[:attachments].empty? + # just specify the body + @msg.body = body + else + # attach attachments, including the body + @msg.body = "This is a multi-part message in MIME format.\n" + + msg_body = TMail::Mail.new + msg_body.body = body + msg_body.set_content_type("text","plain", {:charset => "ISO-8859-1"}) + @msg.parts << msg_body + + octet_stream = MIME::Types['application/octet-stream'].first + + @opts[:attachments].select {|file| File.readable?(file)}.each do |file| + mime_type = MIME::Types.type_for(file).first || octet_stream + @msg.parts << create_attachment(file, mime_type) + end + end + end + attr_reader :msg + + def create_attachment(file, mime_type) + attach = TMail::Mail.new + if mime_type.binary? + attach.body = Base64.encode64(File.read(file)) + attach.transfer_encoding = 'base64' + else + attach.body = File.read(file) + end + attach.set_disposition("attachment", {:filename => file}) + attach.set_content_type(mime_type.media_type, mime_type.sub_type, {:name=>file}) + attach + end + + # instance method to send an Email object + def send + args = @opts.values_at(:server, :port, :helo, :username, :password, :authtype) + Net::SMTP.start(*args) do |smtp| + smtp.send_message(@msg.to_s, @msg.from[0], @msg.to) + end + end + + # class method to construct an Email object and send it + def self.send(*args) + self.new(*args).send + end +end + +Email.send( + 'sender@sender.invalid', + %w{ recip1@recipient.invalid recip2@example.com }, + 'the subject', + "the body\nhas lines", + { + :attachments => %w{ file1 file2 file3 }, + :server => 'mail.example.com', + :helo => 'sender.invalid', + :username => 'user', + :password => 'secret' + } +) diff --git a/Task/Send-email/SAS/send-email.sas b/Task/Send-email/SAS/send-email.sas new file mode 100644 index 0000000000..74952d68a7 --- /dev/null +++ b/Task/Send-email/SAS/send-email.sas @@ -0,0 +1,10 @@ +filename msg email + to="afriend@someserver.com" + cc="anotherfriend@somecompany.com" + subject="Important message" +; + +data _null_; + file msg; + put "Hello, Connected World!"; +run; diff --git a/Task/Send-email/TUSCRIPT/send-email.tuscript b/Task/Send-email/TUSCRIPT/send-email.tuscript new file mode 100644 index 0000000000..67e34052c8 --- /dev/null +++ b/Task/Send-email/TUSCRIPT/send-email.tuscript @@ -0,0 +1,14 @@ +$$ MODE TUSCRIPT + +system=SYSTEM () + +IF (system=="WIN") THEN +SET to="name@domain.org" +SET cc="name@domain.net" +subject="test" +text=* +DATA how are you? + +status = SEND_MAIL (to,cc,subject,text,-) + +ENDIF diff --git a/Task/Send-email/TXR/send-email.txr b/Task/Send-email/TXR/send-email.txr new file mode 100644 index 0000000000..f7364a3d3e --- /dev/null +++ b/Task/Send-email/TXR/send-email.txr @@ -0,0 +1,23 @@ +#!/usr/bin/txr +@(next :args) +@(cases) +@TO +@SUBJ +@ (maybe) +@CC +@ (or) +@ (bind CC "") +@ (end) +@(or) +@ (throw error "must specify at least To and Subject") +@(end) +@(next "-") +@(collect) +@BODY +@(end) +@(output `!mail -s "@SUBJ" -c "@CC" "@TO"`) +@(repeat) +@BODY +@(end) +. +@(end) diff --git a/Task/Send-email/Tcl/send-email.tcl b/Task/Send-email/Tcl/send-email.tcl new file mode 100644 index 0000000000..62d6b7fd9a --- /dev/null +++ b/Task/Send-email/Tcl/send-email.tcl @@ -0,0 +1,23 @@ +package require smtp +package require mime +package require tls + +set gmailUser ******* +set gmailPass hunter2; # Hello, bash.org! + +proc send_simple_message {recipient subject body} { + global gmailUser gmailPass + + # Build the message + set token [mime::initialize -canonical text/plain -string $body] + mime::setheader $token Subject $subject + + # Send it! + smtp::sendmessage $token -userame $gamilUser -password $gmailPass \ + -recipients $recipient -servers smtp.gmail.com -ports 587 + + # Clean up + mime::finalize $token +} + +send_simple_message recipient@example.com "Testing" "This is a test message." diff --git a/Task/Sequence-of-non-squares/0DESCRIPTION b/Task/Sequence-of-non-squares/0DESCRIPTION new file mode 100644 index 0000000000..00a4ca5a0c --- /dev/null +++ b/Task/Sequence-of-non-squares/0DESCRIPTION @@ -0,0 +1,5 @@ +Show that the following remarkable formula gives the [http://www.research.att.com/~njas/sequences/A000037 sequence] of non-square [[wp:Natural_number|natural numbers]]: + n + floor(1/2 + sqrt(n)) +* Print out the values for n in the range 1 to 22 +* Show that no squares occur for n less than one million +* This sequence is also known as [http://oeis.org/A000037 A000037]. diff --git a/Task/Sequence-of-non-squares/1META.yaml b/Task/Sequence-of-non-squares/1META.yaml new file mode 100644 index 0000000000..8644b2ad9b --- /dev/null +++ b/Task/Sequence-of-non-squares/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Arithmetic operations diff --git a/Task/Sequence-of-non-squares/ALGOL-68/sequence-of-non-squares.alg b/Task/Sequence-of-non-squares/ALGOL-68/sequence-of-non-squares.alg new file mode 100644 index 0000000000..26d2daabdf --- /dev/null +++ b/Task/Sequence-of-non-squares/ALGOL-68/sequence-of-non-squares.alg @@ -0,0 +1,19 @@ +PROC non square = (INT n)INT: n + ENTIER(0.5 + sqrt(n)); + +main: ( + + # first 22 values (as a list) has no squares: # + FOR i TO 22 DO + print((whole(non square(i),-3),space)) + OD; + print(new line); + + # The following check shows no squares up to one million: # + FOR i TO 1 000 000 DO + REAL j = sqrt(non square(i)); + IF j = ENTIER j THEN + put(stand out, ("Error: number is a square:", j, new line)); + stop + FI + OD +) diff --git a/Task/Sequence-of-non-squares/AWK/sequence-of-non-squares.awk b/Task/Sequence-of-non-squares/AWK/sequence-of-non-squares.awk new file mode 100644 index 0000000000..668b63b941 --- /dev/null +++ b/Task/Sequence-of-non-squares/AWK/sequence-of-non-squares.awk @@ -0,0 +1,26 @@ +$ awk 'func f(n){return(n+int(.5+sqrt(n)))}BEGIN{for(i=1;i<=22;i++)print i,f(i)}' +1 2 +2 3 +3 5 +4 6 +5 7 +6 8 +7 10 +8 11 +9 12 +10 13 +11 14 +12 15 +13 17 +14 18 +15 19 +16 20 +17 21 +18 22 +19 23 +20 24 +21 26 +22 27 + +$ awk 'func f(n){return(n+int(.5+sqrt(n)))}BEGIN{for(i=1;i<100000;i++){n=f(i);r=int(sqrt(n));if(r*r==n)print n"is square"}}' +$ diff --git a/Task/Sequence-of-non-squares/Ada/sequence-of-non-squares.ada b/Task/Sequence-of-non-squares/Ada/sequence-of-non-squares.ada new file mode 100644 index 0000000000..b7e5726641 --- /dev/null +++ b/Task/Sequence-of-non-squares/Ada/sequence-of-non-squares.ada @@ -0,0 +1,24 @@ +with Ada.Numerics.Long_Elementary_Functions; +with Ada.Text_IO; use Ada.Text_IO; + +procedure Sequence_Of_Non_Squares_Test is + use Ada.Numerics.Long_Elementary_Functions; + + function Non_Square (N : Positive) return Positive is + begin + return N + Positive (Long_Float'Rounding (Sqrt (Long_Float (N)))); + end Non_Square; + + I : Positive; +begin + for N in 1..22 loop -- First 22 non-squares + Put (Natural'Image (Non_Square (N))); + end loop; + New_Line; + for N in 1..1_000_000 loop -- Check first million of + I := Non_Square (N); + if I = Positive (Sqrt (Long_Float (I)))**2 then + Put_Line ("Found a square:" & Positive'Image (N)); + end if; + end loop; +end Sequence_Of_Non_Squares_Test; diff --git a/Task/Sequence-of-non-squares/AutoHotkey/sequence-of-non-squares.ahk b/Task/Sequence-of-non-squares/AutoHotkey/sequence-of-non-squares.ahk new file mode 100644 index 0000000000..20ca74f418 --- /dev/null +++ b/Task/Sequence-of-non-squares/AutoHotkey/sequence-of-non-squares.ahk @@ -0,0 +1,8 @@ +Loop 22 + t .= (A_Index + floor(0.5 + sqrt(A_Index))) " " +MsgBox %t% + +s := 0 +Loop 1000000 + x := A_Index + floor(0.5 + sqrt(A_Index)), s += x = round(sqrt(x))**2 +Msgbox Number of bad squares = %s% ; 0 diff --git a/Task/Sequence-of-non-squares/BASIC/sequence-of-non-squares.basic b/Task/Sequence-of-non-squares/BASIC/sequence-of-non-squares.basic new file mode 100644 index 0000000000..c6197bb930 --- /dev/null +++ b/Task/Sequence-of-non-squares/BASIC/sequence-of-non-squares.basic @@ -0,0 +1,25 @@ +DIM i AS Integer +DIM j AS Double +DIM found AS Integer + +FUNCTION nonsqr (n AS Integer) AS Integer + nonsqr = n + INT(0.5 + SQR(n)) +END FUNCTION + +' Display first 22 values +FOR i = 1 TO 22 + PRINT nonsqr(i); " "; +NEXT i +PRINT + +' Check for squares up to one million +found = 0 +FOR i = 1 TO 1000000 + j = SQR(nonsqr(i)) + IF j = INT(j) THEN + found = 1 + PRINT "Found square: "; i + EXIT FOR + END IF +NEXT i +IF found=0 THEN PRINT "No squares found" diff --git a/Task/Sequence-of-non-squares/BBC-BASIC/sequence-of-non-squares.bbc b/Task/Sequence-of-non-squares/BBC-BASIC/sequence-of-non-squares.bbc new file mode 100644 index 0000000000..88d9b49ccc --- /dev/null +++ b/Task/Sequence-of-non-squares/BBC-BASIC/sequence-of-non-squares.bbc @@ -0,0 +1,12 @@ + FOR N% = 1 TO 22 + S% = N% + SQR(N%) + 0.5 + PRINT S% + NEXT + + PRINT '"Checking...." + FOR N% = 1 TO 999999 + S% = N% + SQR(N%) + 0.5 + R% = SQR(S%) + IF S%/R% = R% STOP + NEXT + PRINT "No squares occur for n < 1000000" diff --git a/Task/Sequence-of-non-squares/Bc/sequence-of-non-squares.bc b/Task/Sequence-of-non-squares/Bc/sequence-of-non-squares.bc new file mode 100644 index 0000000000..9981f29ab5 --- /dev/null +++ b/Task/Sequence-of-non-squares/Bc/sequence-of-non-squares.bc @@ -0,0 +1,46 @@ +#! /usr/bin/bc + +scale = 20 + +define ceil(x) { + auto intx + intx=int(x) + if (intx +#include +#include +#include +#include +#include + +double nextNumber( double number ) { + return number + floor( 0.5 + sqrt( number ) ) ; +} + +int main( ) { + std::vector non_squares ; + typedef std::vector::iterator SVI ; + non_squares.reserve( 1000000 ) ; + //create a vector with a million sequence numbers + for ( double i = 1.0 ; i < 100001.0 ; i += 1 ) + non_squares.push_back( nextNumber( i ) ) ; + //copy the first numbers to standard out + std::copy( non_squares.begin( ) , non_squares.begin( ) + 22 , + std::ostream_iterator(std::cout, " " ) ) ; + std::cout << '\n' ; + //find if floor of square root equals square root( i. e. it's a square number ) + SVI found = std::find_if ( non_squares.begin( ) , non_squares.end( ) , + boost::bind( &floor, boost::bind( &sqrt, _1 ) ) == boost::bind( &sqrt, _1 ) ) ; + if ( found != non_squares.end( ) ) { + std::cout << "Found a square number in the sequence!\n" ; + std::cout << "It is " << *found << " !\n" ; + } + else { + std::cout << "Up to 1000000, found no square number in the sequence!\n" ; + } + return 0 ; +} diff --git a/Task/Sequence-of-non-squares/C/sequence-of-non-squares.c b/Task/Sequence-of-non-squares/C/sequence-of-non-squares.c new file mode 100644 index 0000000000..d182227b6b --- /dev/null +++ b/Task/Sequence-of-non-squares/C/sequence-of-non-squares.c @@ -0,0 +1,24 @@ +#include +#include +#include + +int nonsqr(int n) { + return n + (int)(0.5 + sqrt(n)); + /* return n + (int)round(sqrt(n)); in C99 */ +} + +int main() { + int i; + + /* first 22 values (as a list) has no squares: */ + for (i = 1; i < 23; i++) + printf("%d ", nonsqr(i)); + printf("\n"); + + /* The following check shows no squares up to one million: */ + for (i = 1; i < 1000000; i++) { + double j = sqrt(nonsqr(i)); + assert(j != floor(j)); + } + return 0; +} diff --git a/Task/Sequence-of-non-squares/Clojure/sequence-of-non-squares.clj b/Task/Sequence-of-non-squares/Clojure/sequence-of-non-squares.clj new file mode 100644 index 0000000000..428fc323be --- /dev/null +++ b/Task/Sequence-of-non-squares/Clojure/sequence-of-non-squares.clj @@ -0,0 +1,13 @@ +;; provides floor and sqrt, but we use Java's sqrt as it's faster +;; (Clojure's is more exact) +(use 'clojure.contrib.math) + + +(defn nonsqr [#^Integer n] (+ n (floor (+ 0.5 (Math/sqrt n))))) +(defn square? [#^Double n] + (let [r (floor (Math/sqrt n))] + (= (* r r) n))) + +(doseq [n (range 1 23)] (printf "%s -> %s\n" n (nonsqr n))) + +(defn verify [] (not-any? square? (map nonsqr (range 1 1000000))) ) diff --git a/Task/Sequence-of-non-squares/CoffeeScript/sequence-of-non-squares-1.coffeescript b/Task/Sequence-of-non-squares/CoffeeScript/sequence-of-non-squares-1.coffeescript new file mode 100644 index 0000000000..9290f11d4c --- /dev/null +++ b/Task/Sequence-of-non-squares/CoffeeScript/sequence-of-non-squares-1.coffeescript @@ -0,0 +1,19 @@ +non_square = (n) -> n + Math.floor(1/2 + Math.sqrt(n)) + +is_square = (n) -> + r = Math.floor(Math.sqrt(n)) + r * r is n + +do -> + first_22_non_squares = (non_square i for i in [1..22]) + console.log first_22_non_squares + + # test is_square has no false negatives: + for i in [1..10000] + throw Error("is_square broken") unless is_square i*i + + # test non_square is valid for first million values of n + for i in [1..1000000] + throw Error("non_square broken") if is_square non_square(i) + + console.log "success" diff --git a/Task/Sequence-of-non-squares/CoffeeScript/sequence-of-non-squares-2.coffeescript b/Task/Sequence-of-non-squares/CoffeeScript/sequence-of-non-squares-2.coffeescript new file mode 100644 index 0000000000..3862a52e27 --- /dev/null +++ b/Task/Sequence-of-non-squares/CoffeeScript/sequence-of-non-squares-2.coffeescript @@ -0,0 +1,3 @@ +> coffee foo.coffee +[ 2, 3, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27 ] +success diff --git a/Task/Sequence-of-non-squares/Common-Lisp/sequence-of-non-squares.lisp b/Task/Sequence-of-non-squares/Common-Lisp/sequence-of-non-squares.lisp new file mode 100644 index 0000000000..00db1b2b58 --- /dev/null +++ b/Task/Sequence-of-non-squares/Common-Lisp/sequence-of-non-squares.lisp @@ -0,0 +1,16 @@ +(defun non-square-sequence () + (flet ((non-square (n) + "Compute the N-th number of the non-square sequence" + (+ n (floor (+ 1/2 (sqrt n))))) + (squarep (n) + "Tests, whether N is a square" + (let ((r (floor (sqrt n)))) + (= (* r r) n)))) + (loop + :for n :upfrom 1 :to 22 + :do (format t "~2D -> ~D~%" n (non-square n))) + (loop + :for n :upfrom 1 :to 1000000 + :when (squarep (non-square n)) + :do (format t "Found a square: ~D -> ~D~%" + n (non-square n))))) diff --git a/Task/Sequence-of-non-squares/D/sequence-of-non-squares.d b/Task/Sequence-of-non-squares/D/sequence-of-non-squares.d new file mode 100644 index 0000000000..7d180200bd --- /dev/null +++ b/Task/Sequence-of-non-squares/D/sequence-of-non-squares.d @@ -0,0 +1,14 @@ +import std.stdio, std.math, std.algorithm, std.range; + +int nonSquare(in int n) pure nothrow { + return n + cast(int)(0.5 + sqrt(cast(real)n)); +} + +void main() { + iota(1, 23).map!nonSquare().writeln(); + + foreach (i; 1 .. 1_000_000) { + int ns = nonSquare(i); + assert(ns != (cast(int)sqrt(cast(real)ns)) ^^ 2); + } +} diff --git a/Task/Sequence-of-non-squares/Euphoria/sequence-of-non-squares.euphoria b/Task/Sequence-of-non-squares/Euphoria/sequence-of-non-squares.euphoria new file mode 100644 index 0000000000..39a08e6b83 --- /dev/null +++ b/Task/Sequence-of-non-squares/Euphoria/sequence-of-non-squares.euphoria @@ -0,0 +1,24 @@ +function nonsqr( atom n) + return n + floor( 0.5 + sqrt( n ) ) +end function + +puts( 1, " n r(n)\n" ) +puts( 1, "--- ---\n" ) +for i = 1 to 22 do + printf( 1, "%3d %3d\n", { i, nonsqr(i) } ) +end for + +atom j +atom found +found = 0 +for i = 1 to 1000000 do + j = sqrt(nonsqr(i)) + if integer(j) then + found = 1 + printf( 1, "Found square: %d\n", i ) + exit + end if +end for +if found = 0 then + puts( 1, "No squares found\n" ) +end if diff --git a/Task/Sequence-of-non-squares/Fantom/sequence-of-non-squares.fantom b/Task/Sequence-of-non-squares/Fantom/sequence-of-non-squares.fantom new file mode 100644 index 0000000000..4139b181ae --- /dev/null +++ b/Task/Sequence-of-non-squares/Fantom/sequence-of-non-squares.fantom @@ -0,0 +1,21 @@ +class Main +{ + static Float fn (Int n) + { + n + (0.5f + (n * 1.0f).sqrt).floor + } + + static Bool isSquare (Float n) + { + n.sqrt.floor == n.sqrt + } + + public static Void main () + { + (1..22).each |n| + { + echo ("$n is ${fn(n)}") + } + echo ((1..1000000).toList.any |n| { isSquare (fn(n)) } ) + } +} diff --git a/Task/Sequence-of-non-squares/Forth/sequence-of-non-squares.fth b/Task/Sequence-of-non-squares/Forth/sequence-of-non-squares.fth new file mode 100644 index 0000000000..527617f597 --- /dev/null +++ b/Task/Sequence-of-non-squares/Forth/sequence-of-non-squares.fth @@ -0,0 +1,10 @@ +: u>f 0 d>f ; +: f>u f>d drop ; + +: fn ( n -- n ) dup u>f fsqrt fround f>u + ; +: test ( n -- ) 1 do i fn . loop ; +23 test \ 2 3 5 6 7 8 10 11 12 13 14 15 17 18 19 20 21 22 23 24 26 27 ok + +: square? ( n -- ? ) u>f fsqrt fdup fround f- f0= ; +: test ( n -- ) 1 do i fn square? if cr i . ." fn was square" then loop ; +1000000 test \ ok diff --git a/Task/Sequence-of-non-squares/Fortran/sequence-of-non-squares.f b/Task/Sequence-of-non-squares/Fortran/sequence-of-non-squares.f new file mode 100644 index 0000000000..6d06ffced1 --- /dev/null +++ b/Task/Sequence-of-non-squares/Fortran/sequence-of-non-squares.f @@ -0,0 +1,20 @@ +PROGRAM NONSQUARES + + IMPLICIT NONE + + INTEGER :: m, n, nonsqr + + DO n = 1, 22 + nonsqr = n + FLOOR(0.5 + SQRT(REAL(n))) ! or could use NINT(SQRT(REAL(n))) + WRITE(*,*) nonsqr + END DO + + DO n = 1, 1000000 + nonsqr = n + FLOOR(0.5 + SQRT(REAL(n))) + m = INT(SQRT(REAL(nonsqr))) + IF (m*m == nonsqr) THEN + WRITE(*,*) "Square found, n=", n + END IF + END DO + +END PROGRAM NONSQUARES diff --git a/Task/Sequence-of-non-squares/GAP/sequence-of-non-squares.gap b/Task/Sequence-of-non-squares/GAP/sequence-of-non-squares.gap new file mode 100644 index 0000000000..40cb98e42b --- /dev/null +++ b/Task/Sequence-of-non-squares/GAP/sequence-of-non-squares.gap @@ -0,0 +1,45 @@ +# Here we use generators : the given formula doesn't need one, but the alternate +# non-squares function is better done with a generator. + +# The formula is implemented with exact floor(sqrt(n)), so we use +# a trick: multiply by 100 to get the first decimal digit of the +# square root of n, then add 5 (that's 1/2 multiplied by 10). +# Then just divide by 10 to get floor(1/2 + sqrt(n)) exactly. +# It looks weird, but unlike floating point, it will do the job +# for any n. +NonSquaresGen := function() + local ns, n; + n := 0; + ns := function() + n := n + 1; + return n + QuoInt(5 + RootInt(100*n), 10); + end; + return ns; +end; + +NonSquaresAlt := function() + local ns, n, q, k; + n := 1; + q := 4; + k := 3; + ns := function() + n := n + 1; + if n = q then + n := n + 1; + k := k + 2; + q := q + k; + fi; + return n; + end; + return ns; +end; + +gen := NonSquaresGen(); +List([1 .. 22] i -> gen()); +# [ 2, 3, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27 ] + +a := NonSquaresGen(); +b := NonSquaresAlt(); + +ForAll([1 .. 1000000], i -> a() = b()); +# true diff --git a/Task/Sequence-of-non-squares/Go/sequence-of-non-squares.go b/Task/Sequence-of-non-squares/Go/sequence-of-non-squares.go new file mode 100644 index 0000000000..c4d56cf706 --- /dev/null +++ b/Task/Sequence-of-non-squares/Go/sequence-of-non-squares.go @@ -0,0 +1,37 @@ +package main + +import ( + "fmt" + "math" +) + +func remarkable(n int) int { + return n + int(.5+math.Sqrt(float64(n))) +} + +func main() { + // task 1 + fmt.Println(" n r(n)") + fmt.Println("--- ---") + for n := 1; n <= 22; n++ { + fmt.Printf("%3d %3d\n", n, remarkable(n)) + } + + // task 2 + const limit = 1e6 + fmt.Println("\nChecking for squares for n <", limit) + next := 2 + nextSq := 4 + for n := 1; n < limit; n++ { + r := remarkable(n) + switch { + case r == nextSq: + panic(n) + case r > nextSq: + fmt.Println(nextSq, "didn't occur") + next++ + nextSq = next * next + } + } + fmt.Println("No squares occur for n <", limit) +} diff --git a/Task/Sequence-of-non-squares/Groovy/sequence-of-non-squares-1.groovy b/Task/Sequence-of-non-squares/Groovy/sequence-of-non-squares-1.groovy new file mode 100644 index 0000000000..99129e14bb --- /dev/null +++ b/Task/Sequence-of-non-squares/Groovy/sequence-of-non-squares-1.groovy @@ -0,0 +1 @@ + def nonSquare = { long n -> n + ((1/2 + n**0.5) as long) } diff --git a/Task/Sequence-of-non-squares/Groovy/sequence-of-non-squares-2.groovy b/Task/Sequence-of-non-squares/Groovy/sequence-of-non-squares-2.groovy new file mode 100644 index 0000000000..ca58f0d8fe --- /dev/null +++ b/Task/Sequence-of-non-squares/Groovy/sequence-of-non-squares-2.groovy @@ -0,0 +1,2 @@ +(1..22).each { println nonSquare(it) } +(1..1000000).each { assert ((nonSquare(it)**0.5 as long)**2) != nonSquare(it) } diff --git a/Task/Sequence-of-non-squares/Haskell/sequence-of-non-squares.hs b/Task/Sequence-of-non-squares/Haskell/sequence-of-non-squares.hs new file mode 100644 index 0000000000..8f7426a109 --- /dev/null +++ b/Task/Sequence-of-non-squares/Haskell/sequence-of-non-squares.hs @@ -0,0 +1,2 @@ +nonsqr :: Integral a => a -> a +nonsqr n = n + round (sqrt (fromIntegral n)) diff --git a/Task/Sequence-of-non-squares/HicEst/sequence-of-non-squares.hicest b/Task/Sequence-of-non-squares/HicEst/sequence-of-non-squares.hicest new file mode 100644 index 0000000000..fa09d96827 --- /dev/null +++ b/Task/Sequence-of-non-squares/HicEst/sequence-of-non-squares.hicest @@ -0,0 +1,13 @@ +REAL :: n=22, nonSqr(n) + +nonSqr = $ + FLOOR(0.5 + $^0.5) +WRITE() nonSqr + +squares_found = 0 +DO i = 1, 1E6 + non2 = i + FLOOR(0.5 + i^0.5) + root = FLOOR( non2^0.5 ) + squares_found = squares_found + (non2 == root*root) +ENDDO +WRITE(Name) squares_found +END diff --git a/Task/Sequence-of-non-squares/IDL/sequence-of-non-squares.idl b/Task/Sequence-of-non-squares/IDL/sequence-of-non-squares.idl new file mode 100644 index 0000000000..1bd7eac420 --- /dev/null +++ b/Task/Sequence-of-non-squares/IDL/sequence-of-non-squares.idl @@ -0,0 +1,4 @@ +n = lindgen(1000000)+1 ; Take a million numbers +f = n+floor(.5+sqrt(n)) ; Apply formula +print,f[0:21] ; Output first 22 +print,where(sqrt(f) eq fix(sqrt(f))) ; Test for squares diff --git a/Task/Sequence-of-non-squares/Icon/sequence-of-non-squares.icon b/Task/Sequence-of-non-squares/Icon/sequence-of-non-squares.icon new file mode 100644 index 0000000000..76ee15ebe9 --- /dev/null +++ b/Task/Sequence-of-non-squares/Icon/sequence-of-non-squares.icon @@ -0,0 +1,15 @@ +link numbers + +procedure main() + +every n := 1 to 22 do + write("nsq(",n,") := ",nsq(n)) + +every x := sqrt(nsq(n := 1 to 1000000)) do + if x = floor(x)^2 then write("nsq(",n,") = ",x," is a square.") +write("finished.") +end + +procedure nsq(n) # return non-squares +return n + floor(0.5 + sqrt(n)) +end diff --git a/Task/Sequence-of-non-squares/J/sequence-of-non-squares.j b/Task/Sequence-of-non-squares/J/sequence-of-non-squares.j new file mode 100644 index 0000000000..6aca38b57e --- /dev/null +++ b/Task/Sequence-of-non-squares/J/sequence-of-non-squares.j @@ -0,0 +1,7 @@ + rf=:+ 0.5 <.@+ %: NB. Remarkable formula + + rf 1+i.22 NB. Results from 1 to 22 +2 3 5 6 7 8 10 11 12 13 14 15 17 18 19 20 21 22 23 24 26 27 + + +/ (rf e. *:) 1+i.1e6 NB. Number of square RFs <= 1e6 +0 diff --git a/Task/Sequence-of-non-squares/Java/sequence-of-non-squares.java b/Task/Sequence-of-non-squares/Java/sequence-of-non-squares.java new file mode 100644 index 0000000000..92645b46a9 --- /dev/null +++ b/Task/Sequence-of-non-squares/Java/sequence-of-non-squares.java @@ -0,0 +1,18 @@ +public class SeqNonSquares { + public static int nonsqr(int n) { + return n + (int)Math.round(Math.sqrt(n)); + } + + public static void main(String[] args) { + // first 22 values (as a list) has no squares: + for (int i = 1; i < 23; i++) + System.out.print(nonsqr(i) + " "); + System.out.println(); + + // The following check shows no squares up to one million: + for (int i = 1; i < 1000000; i++) { + double j = Math.sqrt(nonsqr(i)); + assert j != Math.floor(j); + } + } +} diff --git a/Task/Sequence-of-non-squares/Liberty-BASIC/sequence-of-non-squares.liberty b/Task/Sequence-of-non-squares/Liberty-BASIC/sequence-of-non-squares.liberty new file mode 100644 index 0000000000..d55be90eb4 --- /dev/null +++ b/Task/Sequence-of-non-squares/Liberty-BASIC/sequence-of-non-squares.liberty @@ -0,0 +1,21 @@ +for i = 1 to 22 + print nonsqr( i); " "; +next i +print + +found = 0 +for i = 1 to 1000000 + j = ( nonsqr( i))^0.5 + if j = int( j) then + found = 1 + print "Found square: "; i + exit for + end if +next i +if found =0 then print "No squares found" + +end + +function nonsqr( n) + nonsqr = n +int( 0.5 +n^0.5) +end function diff --git a/Task/Sequence-of-non-squares/Logo/sequence-of-non-squares.logo b/Task/Sequence-of-non-squares/Logo/sequence-of-non-squares.logo new file mode 100644 index 0000000000..3baf6af59f --- /dev/null +++ b/Task/Sequence-of-non-squares/Logo/sequence-of-non-squares.logo @@ -0,0 +1 @@ +repeat 22 [print sum # round sqrt #] diff --git a/Task/Sequence-of-non-squares/Lua/sequence-of-non-squares.lua b/Task/Sequence-of-non-squares/Lua/sequence-of-non-squares.lua new file mode 100644 index 0000000000..71bb49b84a --- /dev/null +++ b/Task/Sequence-of-non-squares/Lua/sequence-of-non-squares.lua @@ -0,0 +1 @@ +for i = 1, 22 do print(i + math.round(i^.5)) end diff --git a/Task/Sequence-of-non-squares/MATLAB/sequence-of-non-squares-1.m b/Task/Sequence-of-non-squares/MATLAB/sequence-of-non-squares-1.m new file mode 100644 index 0000000000..4f080671bc --- /dev/null +++ b/Task/Sequence-of-non-squares/MATLAB/sequence-of-non-squares-1.m @@ -0,0 +1,19 @@ +function nonSquares(i) + + for n = (1:i) + + generatedNumber = n + floor(1/2 + sqrt(n)); + + if mod(sqrt(generatedNumber),1)==0 %Check to see if the sqrt of the generated number is an integer + fprintf('\n%d generates a square number: %d\n', [n,generatedNumber]); + return + else %If it isn't then the generated number is a square number + if n<=22 + fprintf('%d ',generatedNumber); + end + end + end + + fprintf('\nNo square numbers were generated for n <= %d\n',i); + +end diff --git a/Task/Sequence-of-non-squares/MATLAB/sequence-of-non-squares-2.m b/Task/Sequence-of-non-squares/MATLAB/sequence-of-non-squares-2.m new file mode 100644 index 0000000000..c650b60497 --- /dev/null +++ b/Task/Sequence-of-non-squares/MATLAB/sequence-of-non-squares-2.m @@ -0,0 +1,3 @@ +>> nonSquares(1000000) +2 3 5 6 7 8 10 11 12 13 14 15 17 18 19 20 21 22 23 24 26 27 +No square numbers were generated for n <= 1000000 diff --git a/Task/Sequence-of-non-squares/MMIX/sequence-of-non-squares.mmix b/Task/Sequence-of-non-squares/MMIX/sequence-of-non-squares.mmix new file mode 100644 index 0000000000..f2c68f2fe9 --- /dev/null +++ b/Task/Sequence-of-non-squares/MMIX/sequence-of-non-squares.mmix @@ -0,0 +1,87 @@ + LOC Data_Segment + GREG @ +buf OCTA 0,0 + + GREG @ +NL BYTE #a,0 +errh BYTE "Sorry, number ",0 +errt BYTE "is a quare.",0 +prtOk BYTE "No squares found below 1000000.",0 + +i IS $1 % loop var. +x IS $2 % computations +y IS $3 % .. +z IS $4 % .. +t IS $5 % temp +Ja IS $127 % return address + + LOC #100 % locate program + GREG @ + +// print integer of max. 7 digits to StdOut +// primarily used to show the first 22 non squares +// in advance the end of the buffer is filled with ' 0 ' +// reg x contains int to be printed +bp IS $71 +0H GREG #0000000000203020 +prtInt STO 0B,buf % initialize buffer + LDA bp,buf+7 % points after LSD + % REPEAT +1H SUB bp,bp,1 % move buffer pointer + DIV x,x,10 % divmod (x,10) + GET t,rR % get remainder + INCL t,'0' % make char digit + STB t,bp % store digit + PBNZ x,1B % UNTIL no more digits + LDA $255,bp + TRAP 0,Fputs,StdOut % print integer + GO Ja,Ja,0 % 'return' + +// function calculates non square +// x = RF ( i ) +RF FLOT x,i % convert i to float + FSQRT x,0,x % x = floor ( 0.5 + sqrt i ) + FIX x,x % convert float to int + ADD x,x,i % x = i + floor ( 0.5 + sqrt i ) + GO Ja,Ja,0 % 'return' + + % main (argc, argv) { +// generate the first 22 non squares +Main SET i,1 % for ( i=1; i<=22; i++){ +1H GO Ja,RF % x = RF (i) + GO Ja,prtInt % print non square + INCL i,1 % i++ + CMP t,i,22 % i<=22 ? + PBNP t,1B % } + LDA $255,NL + TRAP 0,Fputs,StdOut + +// check if RF (i) is a square for 0 < i < 1000000 + SET i,1000 + MUL i,i,i + SUB i,i,1 % for ( i = 999999; i>0; i--) +3H GO Ja,RF % x = RF ( i ) +// square test + FLOT y,x % convert int x to float + FSQRT z,3,y % z = floor ( sqrt ( int (x) ) ) + FIX z,z % z = cint z + MUL z,z,z % z = z^2 + CMP t,x,z % x != (int sqrt x)^2 ? + PBNZ t,2F % if yes then continue +// it should not happen, but if a square is found + LDA $255,errh % else print err-message + TRAP 0,Fputs,StdOut + GO Ja,prtInt % show trespasser + LDA $255,errt + TRAP 0,Fputs,StdOut + LDA $255,NL + TRAP 0,Fputs,StdOut + TRAP 0,Halt,0 + +2H SUB i,i,1 % i-- + PBNZ i,3B % i>0? } + LDA $255,prtOk % + TRAP 0,Fputs,StdOut + LDA $255,NL + TRAP 0,Fputs,StdOut + TRAP 0,Halt,0 % } diff --git a/Task/Sequence-of-non-squares/Mathematica/sequence-of-non-squares.math b/Task/Sequence-of-non-squares/Mathematica/sequence-of-non-squares.math new file mode 100644 index 0000000000..bc1d21fec9 --- /dev/null +++ b/Task/Sequence-of-non-squares/Mathematica/sequence-of-non-squares.math @@ -0,0 +1,5 @@ +nonsq = (# + Floor[0.5 + Sqrt[#]]) &; +nonsq@Range[22] +If[! Or @@ (IntegerQ /@ Sqrt /@ nonsq@Range[10^6]), + Print["No squares for n <= ", 10^6] + ] diff --git a/Task/Sequence-of-non-squares/Maxima/sequence-of-non-squares.maxima b/Task/Sequence-of-non-squares/Maxima/sequence-of-non-squares.maxima new file mode 100644 index 0000000000..eb98a9e832 --- /dev/null +++ b/Task/Sequence-of-non-squares/Maxima/sequence-of-non-squares.maxima @@ -0,0 +1,10 @@ +nonsquare(n) := n + quotient(isqrt(100 * n) + 5, 10); +makelist(nonsquare(n), n, 1, 20); +[2,3,5,6,7,8,10,11,12,13,14,15,17,18,19,20,21,22,23,24] + +not_square(n) := isqrt(n)^2 # n$ + +m: 10^6$ +u: makelist(i, i, 1, m)$ +is(sublist(u, not_square) = sublist(map(nonsquare, u), lambda([x], x <= m))); +true diff --git a/Task/Sequence-of-non-squares/Modula-3/sequence-of-non-squares.mod3 b/Task/Sequence-of-non-squares/Modula-3/sequence-of-non-squares.mod3 new file mode 100644 index 0000000000..0909dae595 --- /dev/null +++ b/Task/Sequence-of-non-squares/Modula-3/sequence-of-non-squares.mod3 @@ -0,0 +1,23 @@ +MODULE NonSquare EXPORTS Main; + +IMPORT IO, Fmt, Math; + +VAR i: INTEGER; + +PROCEDURE NonSquare(n: INTEGER): INTEGER = + BEGIN + RETURN n + FLOOR(0.5D0 + Math.sqrt(FLOAT(n, LONGREAL))); + END NonSquare; + +BEGIN + FOR n := 1 TO 22 DO + IO.Put(Fmt.Int(NonSquare(n)) & " "); + END; + IO.Put("\n"); + FOR n := 1 TO 1000000 DO + i := NonSquare(n); + IF i = FLOOR(Math.sqrt(FLOAT(i, LONGREAL))) THEN + IO.Put("Found square: " & Fmt.Int(n) & "\n"); + END; + END; +END NonSquare. diff --git a/Task/Sequence-of-non-squares/OCaml/sequence-of-non-squares.ocaml b/Task/Sequence-of-non-squares/OCaml/sequence-of-non-squares.ocaml new file mode 100644 index 0000000000..65b37a019a --- /dev/null +++ b/Task/Sequence-of-non-squares/OCaml/sequence-of-non-squares.ocaml @@ -0,0 +1,15 @@ +# let nonsqr n = n + truncate (0.5 +. sqrt (float n));; +val nonsqr : int -> int = +# (* first 22 values (as a list) has no squares: *) + for i = 1 to 22 do + Printf.printf "%d " (nonsqr i) + done; + print_newline ();; +2 3 5 6 7 8 10 11 12 13 14 15 17 18 19 20 21 22 23 24 26 27 +- : unit = () +# (* The following check shows no squares up to one million: *) + for i = 1 to 1_000_000 do + let j = sqrt (float (nonsqr i)) in + assert (j <> floor j) + done;; +- : unit = () diff --git a/Task/Sequence-of-non-squares/Oz/sequence-of-non-squares.oz b/Task/Sequence-of-non-squares/Oz/sequence-of-non-squares.oz new file mode 100644 index 0000000000..b4fe11a0ff --- /dev/null +++ b/Task/Sequence-of-non-squares/Oz/sequence-of-non-squares.oz @@ -0,0 +1,17 @@ +declare + fun {NonSqr N} + N + {Float.toInt {Floor 0.5 + {Sqrt {Int.toFloat N}}}} + end + + fun {SqrtInt N} + {Float.toInt {Sqrt {Int.toFloat N}}} + end + + fun {IsSquare N} + {Pow {SqrtInt N} 2} == N + end + + Ns = {Map {List.number 1 999999 1} NonSqr} +in + {Show {List.take Ns 22}} + {Show {Some Ns IsSquare}} diff --git a/Task/Sequence-of-non-squares/PARI-GP/sequence-of-non-squares.pari b/Task/Sequence-of-non-squares/PARI-GP/sequence-of-non-squares.pari new file mode 100644 index 0000000000..cfb15c00a5 --- /dev/null +++ b/Task/Sequence-of-non-squares/PARI-GP/sequence-of-non-squares.pari @@ -0,0 +1 @@ +[vector(22,n,n + floor(1/2 + sqrt(n))), sum(n=1,1e6,issquare(n + floor(1/2 + sqrt(n))))] diff --git a/Task/Sequence-of-non-squares/PL-I/sequence-of-non-squares-1.pli b/Task/Sequence-of-non-squares/PL-I/sequence-of-non-squares-1.pli new file mode 100644 index 0000000000..4a8251ed6f --- /dev/null +++ b/Task/Sequence-of-non-squares/PL-I/sequence-of-non-squares-1.pli @@ -0,0 +1,2 @@ + put skip edit ((n, n + floor(sqrt(n) + 0.5) do n = 1 to n)) + (skip, 2 f(5)); diff --git a/Task/Sequence-of-non-squares/PL-I/sequence-of-non-squares-2.pli b/Task/Sequence-of-non-squares/PL-I/sequence-of-non-squares-2.pli new file mode 100644 index 0000000000..bfa67e4495 --- /dev/null +++ b/Task/Sequence-of-non-squares/PL-I/sequence-of-non-squares-2.pli @@ -0,0 +1,21 @@ + 1 2 + 2 3 + 3 5 + 4 6 + 5 7 + 6 8 + 7 10 + 8 11 + 9 12 + 10 13 + 11 14 + 12 15 + 13 17 + 14 18 + 15 19 + 16 20 + 17 21 + 18 22 + 19 23 + 20 24 + 21 26 diff --git a/Task/Sequence-of-non-squares/PL-I/sequence-of-non-squares-3.pli b/Task/Sequence-of-non-squares/PL-I/sequence-of-non-squares-3.pli new file mode 100644 index 0000000000..d0fa7ab72b --- /dev/null +++ b/Task/Sequence-of-non-squares/PL-I/sequence-of-non-squares-3.pli @@ -0,0 +1,17 @@ +test: proc options (main); + declare n fixed (15); + + do n = 1 to 1000000; + if perfect_square (n + fixed(sqrt(n) + 0.5, 15)) then + do; put skip list ('formula fails for n = ', n); stop; end; + end; + +perfect_square: procedure (N) returns (bit (1) aligned); + declare N fixed (15); + declare K fixed (15); + + k = sqrt(N)+0.1; + return ( k*k = N ); +end perfect_square; + +end test; diff --git a/Task/Sequence-of-non-squares/Pascal/sequence-of-non-squares.pascal b/Task/Sequence-of-non-squares/Pascal/sequence-of-non-squares.pascal new file mode 100644 index 0000000000..950e6486c3 --- /dev/null +++ b/Task/Sequence-of-non-squares/Pascal/sequence-of-non-squares.pascal @@ -0,0 +1,24 @@ +Program SequenceOfNonSquares(output); + +uses + Math; + +var + m, n, test: longint; + +begin + for n := 1 to 22 do + begin + test := n + floor(0.5 + sqrt(n)); + write(test, ' '); + end; + writeln; + + for n := 1 to 1000000 do + begin + test := n + floor(0.5 + sqrt(n)); + m := round(sqrt(test)); + if (m*m = test) then + writeln('square found for n = ', n); + end; +end. diff --git a/Task/Sequence-of-non-squares/Perl-6/sequence-of-non-squares.pl6 b/Task/Sequence-of-non-squares/Perl-6/sequence-of-non-squares.pl6 new file mode 100644 index 0000000000..c8e7878f38 --- /dev/null +++ b/Task/Sequence-of-non-squares/Perl-6/sequence-of-non-squares.pl6 @@ -0,0 +1,7 @@ +sub nth_term (Int $n) { $n + round sqrt $n } + +say nth_term $_ for 1 .. 22; + +loop (my $i = 1; $i <= 1_000_000; $i++) { + $i.&nth_term.sqrt %% 1 and say "nth_term($i) is square."; +} diff --git a/Task/Sequence-of-non-squares/Perl/sequence-of-non-squares.pl b/Task/Sequence-of-non-squares/Perl/sequence-of-non-squares.pl new file mode 100644 index 0000000000..833c0733f4 --- /dev/null +++ b/Task/Sequence-of-non-squares/Perl/sequence-of-non-squares.pl @@ -0,0 +1,6 @@ +sub nonsqr { my $n = shift; $n + int(0.5 + sqrt($n)) } +print join(' ', map nonsqr($_), 1..22), "\n"; +foreach my $i (1..1_000_000) { + my $j = sqrt(nonsqr($i)); + $j != int($j) or die "Found a square in the sequence: $i"; +} diff --git a/Task/Sequence-of-non-squares/PicoLisp/sequence-of-non-squares.l b/Task/Sequence-of-non-squares/PicoLisp/sequence-of-non-squares.l new file mode 100644 index 0000000000..3490be4533 --- /dev/null +++ b/Task/Sequence-of-non-squares/PicoLisp/sequence-of-non-squares.l @@ -0,0 +1,10 @@ +(de sqfun (N) + (+ N (sqrt N T)) ) # 'sqrt' rounds when called with 'T' + +(for I 22 + (println I (sqfun I)) ) + +(for I 1000000 + (let (N (sqfun I) R (sqrt N)) + (when (= N (* R R)) + (prinl N " is square") ) ) ) diff --git a/Task/Sequence-of-non-squares/PostScript/sequence-of-non-squares.ps b/Task/Sequence-of-non-squares/PostScript/sequence-of-non-squares.ps new file mode 100644 index 0000000000..9992949ec2 --- /dev/null +++ b/Task/Sequence-of-non-squares/PostScript/sequence-of-non-squares.ps @@ -0,0 +1,10 @@ +/nonsquare { dup sqrt .5 add floor add } def +/issquare { dup sqrt floor dup mul eq } def + +1 1 22 { nonsquare = } for + +1 1 1000 { + dup nonsquare issquare { + (produced a square!) = = exit + } if pop +} for diff --git a/Task/Sequence-of-non-squares/PowerShell/sequence-of-non-squares-1.psh b/Task/Sequence-of-non-squares/PowerShell/sequence-of-non-squares-1.psh new file mode 100644 index 0000000000..cb24315ae6 --- /dev/null +++ b/Task/Sequence-of-non-squares/PowerShell/sequence-of-non-squares-1.psh @@ -0,0 +1,3 @@ +filter Get-NonSquare { + return $_ + [Math]::Floor(1/2 + [Math]::Sqrt($_)) +} diff --git a/Task/Sequence-of-non-squares/PowerShell/sequence-of-non-squares-2.psh b/Task/Sequence-of-non-squares/PowerShell/sequence-of-non-squares-2.psh new file mode 100644 index 0000000000..5119abbeda --- /dev/null +++ b/Task/Sequence-of-non-squares/PowerShell/sequence-of-non-squares-2.psh @@ -0,0 +1 @@ +1..22 | Get-NonSquare diff --git a/Task/Sequence-of-non-squares/PowerShell/sequence-of-non-squares-3.psh b/Task/Sequence-of-non-squares/PowerShell/sequence-of-non-squares-3.psh new file mode 100644 index 0000000000..fe79df7153 --- /dev/null +++ b/Task/Sequence-of-non-squares/PowerShell/sequence-of-non-squares-3.psh @@ -0,0 +1,6 @@ +1..1000000 ` + | Get-NonSquare ` + | Where-Object { + $r = [Math]::Sqrt($_) + [Math]::Truncate($r) -eq $r + } diff --git a/Task/Sequence-of-non-squares/PureBasic/sequence-of-non-squares.purebasic b/Task/Sequence-of-non-squares/PureBasic/sequence-of-non-squares.purebasic new file mode 100644 index 0000000000..5884fa91c2 --- /dev/null +++ b/Task/Sequence-of-non-squares/PureBasic/sequence-of-non-squares.purebasic @@ -0,0 +1,27 @@ +OpenConsole() +For a = 1 To 22 + ; Integer, so no floor needed + tmp = 1 / 2 + Sqr(a) + Print(Str(a + tmp) + ", ") +Next +PrintN("") +PrintN("Starting check till one million") +For a = 1 To 1000000 + value.d = a + Round((1 / 2 + Sqr(a)), #PB_Round_Down) + root = Sqr(value) + If value - root*root = 0 + found + 1 + If found < 20 + PrintN("Found a square! " + Str(value)) + ElseIf found = 20 + PrintN("And more") + EndIf + EndIf +Next +If found + PrintN(Str(found) + " Squares found, see above") +Else + PrintN("No squares, all ok") +EndIf +; Wait for enter +Input() diff --git a/Task/Sequence-of-non-squares/Python/sequence-of-non-squares.py b/Task/Sequence-of-non-squares/Python/sequence-of-non-squares.py new file mode 100644 index 0000000000..d4c98b8f51 --- /dev/null +++ b/Task/Sequence-of-non-squares/Python/sequence-of-non-squares.py @@ -0,0 +1,14 @@ +>>> from math import sqrt +>>> # (Using the fact that round(X) is equivalent to floor(0.5+X) for our range of X) +>>> def nonsqr(n): return n + int(round(sqrt(n))) + +>>> # first 22 values (as a list) has no squares: +>>> [nonsqr(i) for i in xrange(1,23)] +[2, 3, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27] +>>> # The following check shows no squares up to one million: +>>> for i in xrange(1,1000000): + j = sqrt(nonsqr(i)) + assert j != int(j), "Found a square in the sequence: %i" % i + + +>>> diff --git a/Task/Sequence-of-non-squares/R/sequence-of-non-squares-1.r b/Task/Sequence-of-non-squares/R/sequence-of-non-squares-1.r new file mode 100644 index 0000000000..628a68a1e7 --- /dev/null +++ b/Task/Sequence-of-non-squares/R/sequence-of-non-squares-1.r @@ -0,0 +1,2 @@ +nonsqr <- function(n) n + floor(1/2 + sqrt(n)) +nonsqr(1:22) diff --git a/Task/Sequence-of-non-squares/R/sequence-of-non-squares-2.r b/Task/Sequence-of-non-squares/R/sequence-of-non-squares-2.r new file mode 100644 index 0000000000..768b81e408 --- /dev/null +++ b/Task/Sequence-of-non-squares/R/sequence-of-non-squares-2.r @@ -0,0 +1,7 @@ +is.square <- function(x) +{ + sqrx <- sqrt(x) + err <- abs(sqrx - round(sqrx)) + err < 100*.Machine$double.eps +} +any(is.square(nonsqr(1:1e6))) diff --git a/Task/Sequence-of-non-squares/REXX/sequence-of-non-squares.rexx b/Task/Sequence-of-non-squares/REXX/sequence-of-non-squares.rexx new file mode 100644 index 0000000000..7812d2a68e --- /dev/null +++ b/Task/Sequence-of-non-squares/REXX/sequence-of-non-squares.rexx @@ -0,0 +1,35 @@ +/*REXX program to show some non-square numbers.*/ + + do j=1 for 22 + say right(j,6) right(j+floor(1/2 + sqrt(j)),7) + end + +oops=0 + + do k=1 for 1000000-1 + n=k+floor(.5+sqrt(k)) + iroot=isqrt(n) + if iroot*iroot==n then oops=oops+1 + end + +say +say oops 'squares found up to' k-1 +exit + +/*-------------------------------FLOOR subroutine----------------------*/ +floor:procedure; parse arg x;return trunc(x-(x<0)) + +/*-------------------------------SQRT subroutine-----------------------*/ +sqrt: procedure; parse arg x,f; if x=0 then return 0; d=digits() +numeric digits 11; g=x/4; m.=11; p=d+d%4+2 + 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 /*return the normalized square root of X.*/ + +/*-------------------------------ISQRT subroutine----------------------*/ +isqrt:procedure;parse arg x; x=trunc(x); r=0; q=1 + do while q<=x; q=q*4; end + do while q>1; q=q%4; _=x-r-q; r=r%2; if _>=0 then do; x=_; r=r+q; end + end +return r /*return the integer square root of X.*/ diff --git a/Task/Sequence-of-non-squares/Racket/sequence-of-non-squares.rkt b/Task/Sequence-of-non-squares/Racket/sequence-of-non-squares.rkt new file mode 100644 index 0000000000..dd692b8905 --- /dev/null +++ b/Task/Sequence-of-non-squares/Racket/sequence-of-non-squares.rkt @@ -0,0 +1,11 @@ +#lang racket + +(define (non-square n) + (+ n (exact-floor (+ 1/2 (sqrt n))))) + +(map non-square (range 1 23)) + +(define (square? n) (integer? (sqrt n))) + +(for/or ([n (in-range 1 1000001)]) + (square? (non-square n))) diff --git a/Task/Sequence-of-non-squares/Ruby/sequence-of-non-squares.rb b/Task/Sequence-of-non-squares/Ruby/sequence-of-non-squares.rb new file mode 100644 index 0000000000..94f95d15cd --- /dev/null +++ b/Task/Sequence-of-non-squares/Ruby/sequence-of-non-squares.rb @@ -0,0 +1,9 @@ +def f(n); n + (0.5 + Math.sqrt(n)).floor; end + +(1..22).each { |n| p "#{n} #{f(n)}" } + +non_squares = (1..1_000_000).map { |n| f(n) } +squares = (1..1001).map { |n| n**2 } # Note: 1001*1001 = 1_002_001 > 1_001_000 = f(1_000_000) +(squares & non_squares).each do |n| + fail "Oops, found a square f(#{non_squares.index(n)}) = #{n}" +end diff --git a/Task/Sequence-of-non-squares/Scala/sequence-of-non-squares.scala b/Task/Sequence-of-non-squares/Scala/sequence-of-non-squares.scala new file mode 100644 index 0000000000..ef3dbd6cf9 --- /dev/null +++ b/Task/Sequence-of-non-squares/Scala/sequence-of-non-squares.scala @@ -0,0 +1,9 @@ +def nonsqr(n:Int)=n+math.round(math.sqrt(n)).toInt + +for(n<-1 to 22) println(n + " "+ nonsqr(n)) + +val test=(1 to 1000000).exists{n => + val j=math.sqrt(nonsqr(n)) + j==math.floor(j) +} +println("squares up to one million="+test) diff --git a/Task/Sequence-of-non-squares/Scheme/sequence-of-non-squares.ss b/Task/Sequence-of-non-squares/Scheme/sequence-of-non-squares.ss new file mode 100644 index 0000000000..fb374cb45e --- /dev/null +++ b/Task/Sequence-of-non-squares/Scheme/sequence-of-non-squares.ss @@ -0,0 +1,31 @@ +(define non-squares + (lambda (index) + (+ index (inexact->exact (floor (+ (/ 1 2) (sqrt index))))))) + +(define sequence + (lambda (function) + (lambda (start) + (lambda (stop) + (if (> start stop) + (list) + (cons (function start) + (((sequence function) (+ start 1)) stop))))))) + +(define square? + (lambda (number) + ((lambda (root) + (= (* root root) number)) + (floor (sqrt number))))) + +(define any? + (lambda (predicate?) + (lambda (list) + (and (not (null? list)) + (or (predicate? (car list)) + ((any? predicate?) (cdr list))))))) + +(display (((sequence non-squares) 1) 22)) +(newline) + +(display ((any? square?) (((sequence non-squares) 1) 999999))) +(newline) diff --git a/Task/Sequence-of-non-squares/Seed7/sequence-of-non-squares.seed7 b/Task/Sequence-of-non-squares/Seed7/sequence-of-non-squares.seed7 new file mode 100644 index 0000000000..685ce891f0 --- /dev/null +++ b/Task/Sequence-of-non-squares/Seed7/sequence-of-non-squares.seed7 @@ -0,0 +1,26 @@ +$ include "seed7_05.s7i"; + include "float.s7i"; + include "math.s7i"; + +const func integer: nonsqr (in integer: n) is + return n + trunc(0.5 + sqrt(flt(n))); + +const proc: main is func + local + var integer: i is 0; + var float: j is 0.0; + begin + # First 22 values (as a list) has no squares: + for i range 1 to 22 do + write(nonsqr(i) <& " "); + end for; + writeln; + + # The following check shows no squares up to one million: + for i range 1 to 1000000 do + j := sqrt(flt(nonsqr(i))); + if j = floor(j) then + writeln("Found square for nonsqr(" <& i <& ")"); + end if; + end for; + end func; diff --git a/Task/Sequence-of-non-squares/Standard-ML/sequence-of-non-squares.ml b/Task/Sequence-of-non-squares/Standard-ML/sequence-of-non-squares.ml new file mode 100644 index 0000000000..f200755969 --- /dev/null +++ b/Task/Sequence-of-non-squares/Standard-ML/sequence-of-non-squares.ml @@ -0,0 +1,12 @@ +- fun nonsqr n = n + round (Math.sqrt (real n)); +val nonsqr = fn : int -> int +- List.tabulate (23, nonsqr); +val it = [0,2,3,5,6,7,8,10,11,12,13,14,...] : int list +- let fun loop i = if i = 1000000 then true + else let val j = Math.sqrt (real (nonsqr i)) in + Real.!= (j, Real.realFloor j) andalso + loop (i+1) + end in + loop 1 + end; +val it = true : bool diff --git a/Task/Sequence-of-non-squares/TI-89-BASIC/sequence-of-non-squares-1.ti-89 b/Task/Sequence-of-non-squares/TI-89-BASIC/sequence-of-non-squares-1.ti-89 new file mode 100644 index 0000000000..c7e343b5d3 --- /dev/null +++ b/Task/Sequence-of-non-squares/TI-89-BASIC/sequence-of-non-squares-1.ti-89 @@ -0,0 +1,4 @@ +■ n+floor(1/2+√(n)) → f(n) + Done +■ seq(f(n),n,1,22) + {2,3,5,6,7,8,10,11,12,13,14,15,17,18,19,20,21,22,23,24,26,27} diff --git a/Task/Sequence-of-non-squares/TI-89-BASIC/sequence-of-non-squares-2.ti-89 b/Task/Sequence-of-non-squares/TI-89-BASIC/sequence-of-non-squares-2.ti-89 new file mode 100644 index 0000000000..0edcf5e7e2 --- /dev/null +++ b/Task/Sequence-of-non-squares/TI-89-BASIC/sequence-of-non-squares-2.ti-89 @@ -0,0 +1,11 @@ +test() +Prgm + Local i, ns + For i, 1, 10^6 + f(i) → ns + If (floor(√(ns)))^2 = ns Then + Disp "Oops: " & string(ns) + EndIf + EndFor + Disp "Done" +EndPrgm diff --git a/Task/Sequence-of-non-squares/Tcl/sequence-of-non-squares.tcl b/Task/Sequence-of-non-squares/Tcl/sequence-of-non-squares.tcl new file mode 100644 index 0000000000..26ba355ba5 --- /dev/null +++ b/Task/Sequence-of-non-squares/Tcl/sequence-of-non-squares.tcl @@ -0,0 +1,17 @@ +package require Tcl 8.5 + +set f {n {expr {$n + floor(0.5 + sqrt($n))}}} + +for {set x 1} {$x <= 22} {incr x} { + puts [format "%d\t%s" $x [apply $f $x]] +} + +puts "looking for a square..." +for {set x 1} {$x <= 1000000} {incr x} { + set y [apply $f $x] + set s [expr {sqrt($y)}] + if {$s == int($s)} { + error "found a square in the sequence: $x -> $y" + } +} +puts "done" diff --git a/Task/Sequence-of-non-squares/Ursala/sequence-of-non-squares.ursala b/Task/Sequence-of-non-squares/Ursala/sequence-of-non-squares.ursala new file mode 100644 index 0000000000..1ad3f43575 --- /dev/null +++ b/Task/Sequence-of-non-squares/Ursala/sequence-of-non-squares.ursala @@ -0,0 +1,10 @@ +#import nat +#import flo + +nth_non_square = float; plus^/~& math..trunc+ plus/0.5+ sqrt +is_square = sqrt; ^E/~& math..trunc + +#show+ + +examples = %neALP ^(~&,nth_non_square)*t iota23 +check = (is_square*~+nth_non_square*t; ~&i&& %eLP)||-[no squares found]-! iota 1000000 diff --git a/Task/Sequence-of-non-squares/XPL0/sequence-of-non-squares.xpl0 b/Task/Sequence-of-non-squares/XPL0/sequence-of-non-squares.xpl0 new file mode 100644 index 0000000000..8e324d31f7 --- /dev/null +++ b/Task/Sequence-of-non-squares/XPL0/sequence-of-non-squares.xpl0 @@ -0,0 +1,23 @@ +include c:\cxpl\codes; \intrinsic 'code' declarations + +func real Floor(X); \Truncate X toward - infinity +real X; +return float(fix(X-0.5)); + +func PerfectSq(N); \Return 'true' if N is a perfect square +int N; +return sqrt(N)*sqrt(N) = N; + +int N, M, M0; +[for N:= 1 to 22 do + [IntOut(0, fix(float(N) + Floor(0.5 + sqrt(float(N))))); ChOut(0,^ )]; +CrLf(0); +M0:= 1; +for N:= 1 to 999_999 do + [M:= fix(float(N) + Floor(0.5 + sqrt(float(N)))); + if PerfectSq(M) then [IntOut(0, M); Crlf(0)]; \error: have square + if M#M0+1 and not PerfectSq(M0+1) then \error: not sequential + [IntOut(0, M); Crlf(0)]; + M0:= M; + ]; +] diff --git a/Task/Set-consolidation/0DESCRIPTION b/Task/Set-consolidation/0DESCRIPTION new file mode 100644 index 0000000000..eeecffd03d --- /dev/null +++ b/Task/Set-consolidation/0DESCRIPTION @@ -0,0 +1,20 @@ +Given two sets of items then if any item is common to any set then the result of applying ''consolidation'' to those sets is a set of sets whose contents is: +* The two input sets if no common item exists between the two input sets of items. +* The single set that is the union of the two input sets if they share a common item. + +Given N sets of items where N>2 then the result is the same as repeatedly replacing all combinations of two sets by their consolidation until no further consolidation between set pairs is possible. +If N<2 then consolidation has no strict meaning and the input can be returned. + +;'''Example 1:''' +:Given the two sets {A,B} and {C,D} then there is no common element between the sets and the result is the same as the input. +;'''Example 2:''' +:Given the two sets {A,B} and {B,D} then there is a common element B between the sets and the result is the single set {B,D,A}. (Note that order of items in a set is immaterial: {A,B,D} is the same as {B,D,A} and {D,A,B}, etc). +;'''Example 3:''' +:Given the three sets {A,B} and {C,D} and {D,B} then there is no common element between the sets {A,B} and {C,D} but the sets {A,B} and {D,B} do share a common element that consolidates to produce the result {B,D,A}. On examining this result with the remaining set, {C,D}, they share a common element and so consolidate to the final output of the single set {A,B,C,D} +;'''Example 4:''' +:The consolidation of the five sets: +::{H,I,K}, {A,B}, {C,D}, {D,B}, and {F,G,H} +:Is the two sets: +::{A, C, B, D}, and {G, F, I, H, K} + +'''See also:''' diff --git a/Task/Set-consolidation/Ada/set-consolidation-1.ada b/Task/Set-consolidation/Ada/set-consolidation-1.ada new file mode 100644 index 0000000000..a795b55c96 --- /dev/null +++ b/Task/Set-consolidation/Ada/set-consolidation-1.ada @@ -0,0 +1,27 @@ +generic + type Element is (<>); + with function Image(E: Element) return String; +package Set_Cons is + + type Set is private; + + -- constructor and manipulation functions for type Set + function "+"(E: Element) return Set; + function "+"(Left, Right: Element) return Set; + function "+"(Left: Set; Right: Element) return Set; + function "-"(Left: Set; Right: Element) return Set; + + -- compare, unite or output a Set + function Nonempty_Intersection(Left, Right: Set) return Boolean; + function Union(Left, Right: Set) return Set; + function Image(S: Set) return String; + + type Set_Vec is array(Positive range <>) of Set; + + -- output a Set_Vec + function Image(V: Set_Vec) return String; + +private + type Set is array(Element) of Boolean; + +end Set_Cons; diff --git a/Task/Set-consolidation/Ada/set-consolidation-2.ada b/Task/Set-consolidation/Ada/set-consolidation-2.ada new file mode 100644 index 0000000000..eee0528e16 --- /dev/null +++ b/Task/Set-consolidation/Ada/set-consolidation-2.ada @@ -0,0 +1,77 @@ +package body Set_Cons is + + function "+"(E: Element) return Set is + S: Set := (others => False); + begin + S(E) := True; + return S; + end "+"; + + function "+"(Left, Right: Element) return Set is + begin + return (+Left) + Right; + end "+"; + + function "+"(Left: Set; Right: Element) return Set is + S: Set := Left; + begin + S(Right) := True; + return S; + end "+"; + + function "-"(Left: Set; Right: Element) return Set is + S: Set := Left; + begin + S(Right) := False; + return S; + end "-"; + + function Nonempty_Intersection(Left, Right: Set) return Boolean is + begin + for E in Element'Range loop + if Left(E) and then Right(E) then return True; + end if; + end loop; + return False; + end Nonempty_Intersection; + + function Union(Left, Right: Set) return Set is + S: Set := Left; + begin + for E in Right'Range loop + if Right(E) then S(E) := True; + end if; + end loop; + return S; + end Union; + + function Image(S: Set) return String is + + function Image(S: Set; Found: Natural) return String is + begin + for E in S'Range loop + if S(E) then + if Found = 0 then + return Image(E) & Image((S-E), Found+1); + else + return "," & Image(E) & Image((S-E), Found+1); + end if; + end if; + end loop; + return ""; + end Image; + + begin + return "{" & Image(S, 0) & "}"; + end Image; + + function Image(V: Set_Vec) return String is + begin + if V'Length = 0 then + return ""; + else + return Image(V(V'First)) & Image(V(V'First+1 .. V'Last)); + end if; + end Image; + +end Set_Cons; diff --git a/Task/Set-consolidation/Ada/set-consolidation-3.ada b/Task/Set-consolidation/Ada/set-consolidation-3.ada new file mode 100644 index 0000000000..b1923dfc6b --- /dev/null +++ b/Task/Set-consolidation/Ada/set-consolidation-3.ada @@ -0,0 +1,40 @@ +with Ada.Text_IO, Set_Cons; + +procedure Set_Consolidation is + + type El_Type is (A, B, C, D, E, F, G, H, I, K); + + function Image(El: El_Type) return String is + begin + return El_Type'Image(El); + end Image; + + package Helper is new Set_Cons(Element => El_Type, Image => Image); + use Helper; + + function Consolidate(List: Set_Vec) return Set_Vec is + begin + for I in List'First .. List'Last - 1 loop + for J in I+1 .. List'Last loop + -- if List(I) and List(J) share an element + -- then recursively consolidate + -- (List(I) union List(J)) followed by List(K), K not in {I, J} + if Nonempty_Intersection(List(I), List(J)) then + return Consolidate + (Union(List(I), List(J)) + & List(List'First .. I-1) + & List(I+1 .. J-1) + & List(J+1 .. List'Last)); + end if; + end loop; + end loop; + return List; + end Consolidate; + +begin + Ada.Text_IO.Put_Line(Image(Consolidate((A+B) & (C+D)))); + Ada.Text_IO.Put_Line(Image(Consolidate((A+B) & (B+D)))); + Ada.Text_IO.Put_Line(Image(Consolidate((A+B) & (C+D) & (D+B)))); + Ada.Text_IO.Put_Line + (Image(Consolidate((H+I+K) & (A+B) & (C+D) & (D+B) & (F+G+H)))); +end Set_Consolidation; diff --git a/Task/Set-consolidation/Bracmat/set-consolidation.bracmat b/Task/Set-consolidation/Bracmat/set-consolidation.bracmat new file mode 100644 index 0000000000..ced20b4d43 --- /dev/null +++ b/Task/Set-consolidation/Bracmat/set-consolidation.bracmat @@ -0,0 +1,28 @@ +( ( consolidate + = a m z mm za zm zz + . ( removeNumFactors + = a m z + . !arg:?a+#%*?m+?z + & !a+!m+removeNumFactors$!z + | !arg + ) + & !arg + : ?a + %?`m + ( %?z + & !m + : ? + + ( %@?mm + & !z:?za (?+!mm+?:?zm) ?zz + ) + + ? + ) + & consolidate$(!a removeNumFactors$(!m+!zm) !za !zz) + | !arg + ) +& (test=.out$(!arg "==>" consolidate$!arg)) +& test$(A+B C+D) +& test$(A+B B+D) +& test$(A+B C+D D+B) +& test$(H+I+K A+B C+D D+B F+G+H) +); diff --git a/Task/Set-consolidation/C/set-consolidation-1.c b/Task/Set-consolidation/C/set-consolidation-1.c new file mode 100644 index 0000000000..299de1565c --- /dev/null +++ b/Task/Set-consolidation/C/set-consolidation-1.c @@ -0,0 +1,37 @@ +#include + +#define s(x) (1U << ((x) - 'A')) + +typedef unsigned int bitset; + +int consolidate(bitset *x, int len) +{ + int i, j; + for (i = len - 2; i >= 0; i--) + for (j = len - 1; j > i; j--) + if (x[i] & x[j]) + x[i] |= x[j], x[j] = x[--len]; + return len; +} + +void show_sets(bitset *x, int len) +{ + bitset b; + while(len--) { + for (b = 'A'; b <= 'Z'; b++) + if (x[len] & s(b)) printf("%c ", b); + putchar('\n'); + } +} + +int main(void) +{ + bitset x[] = { s('A') | s('B'), s('C') | s('D'), s('B') | s('D'), + s('F') | s('G') | s('H'), s('H') | s('I') | s('K') }; + + int len = sizeof(x) / sizeof(x[0]); + + puts("Before:"); show_sets(x, len); + puts("\nAfter:"); show_sets(x, consolidate(x, len)); + return 0; +} diff --git a/Task/Set-consolidation/C/set-consolidation-2.c b/Task/Set-consolidation/C/set-consolidation-2.c new file mode 100644 index 0000000000..87194cd4b9 --- /dev/null +++ b/Task/Set-consolidation/C/set-consolidation-2.c @@ -0,0 +1,102 @@ +#include +#include +#include + +struct edge { int to; struct edge *next; }; +struct node { int group; struct edge *e; }; + +int **consolidate(int **x) +{ +# define alloc(v, size) v = calloc(size, sizeof(v[0])); + int group, n_groups, n_nodes; + int n_edges = 0; + struct edge *edges, *ep; + struct node *nodes; + int pos, *stack, **ret; + + void add_edge(int a, int b) { + ep->to = b; + ep->next = nodes[a].e; + nodes[a].e = ep; + ep++; + } + + void traverse(int a) { + if (nodes[a].group) return; + + nodes[a].group = group; + stack[pos++] = a; + + for (struct edge *e = nodes[a].e; e; e = e->next) + traverse(e->to); + } + + n_groups = n_nodes = 0; + for (int i = 0; x[i]; i++, n_groups++) + for (int j = 0; x[i][j]; j++) { + n_edges ++; + if (x[i][j] >= n_nodes) + n_nodes = x[i][j] + 1; + } + + alloc(ret, n_nodes); + alloc(nodes, n_nodes); + alloc(stack, n_nodes); + ep = alloc(edges, n_edges); + + for (int i = 0; x[i]; i++) + for (int *s = x[i], j = 0; s[j]; j++) + add_edge(s[j], s[j + 1] ? s[j + 1] : s[0]); + + group = 0; + for (int i = 1; i < n_nodes; i++) { + if (nodes[i].group) continue; + + group++, pos = 0; + traverse(i); + + stack[pos++] = 0; + ret[group - 1] = malloc(sizeof(int) * pos); + memcpy(ret[group - 1], stack, sizeof(int) * pos); + } + + free(edges); + free(stack); + free(nodes); + + // caller is responsible for freeing ret + return realloc(ret, sizeof(ret[0]) * (1 + group)); +# undef alloc +} + +void show_sets(int **x) +{ + for (int i = 0; x[i]; i++) { + printf("%d: ", i); + for (int j = 0; x[i][j]; j++) + printf(" %d", x[i][j]); + putchar('\n'); + } +} + +int main(void) +{ + int *x[] = { + (int[]) {1, 2, 0}, // 0: end of set + (int[]) {3, 4, 0}, + (int[]) {3, 1, 0}, + (int[]) {0}, // empty set + (int[]) {5, 6, 0}, + (int[]) {7, 6, 0}, + (int[]) {3, 9, 10, 0}, + 0 // 0: end of sets + }; + + puts("input:"); + show_sets(x); + + puts("components:"); + show_sets(consolidate(x)); + + return 0; +} diff --git a/Task/Set-consolidation/D/set-consolidation-1.d b/Task/Set-consolidation/D/set-consolidation-1.d new file mode 100644 index 0000000000..039df92bd1 --- /dev/null +++ b/Task/Set-consolidation/D/set-consolidation-1.d @@ -0,0 +1,29 @@ +import std.stdio, std.algorithm, std.array; + +dchar[][] consolidate(dchar[][] sets) { + foreach (set; sets) + set.sort; + + foreach (i, ref si; sets[0 .. $ - 1]) { + if (si.empty) + continue; + foreach (ref sj; sets[i + 1 .. $]) + if (!sj.empty && !si.setIntersection(sj).empty) { + sj = si.setUnion(sj).uniq.array; + si = null; + } + } + + return sets.filter!"!a.empty".array; +} + +void main() { + [['A', 'B'], ['C','D']].consolidate.writeln; + + [['A','B'], ['B','D']].consolidate.writeln; + + [['A','B'], ['C','D'], ['D','B']].consolidate.writeln; + + [['H','I','K'], ['A','B'], ['C','D'], + ['D','B'], ['F','G','H']].consolidate.writeln; +} diff --git a/Task/Set-consolidation/D/set-consolidation-2.d b/Task/Set-consolidation/D/set-consolidation-2.d new file mode 100644 index 0000000000..90784204ed --- /dev/null +++ b/Task/Set-consolidation/D/set-consolidation-2.d @@ -0,0 +1,32 @@ +import std.stdio, std.algorithm, std.array; + +dchar[][] consolidate(dchar[][] sets) { + foreach (set; sets) + set.sort; + + dchar[][] consolidateR(dchar[][] s) { + if (s.length < 2) + return s; + auto r = [s[0]]; + foreach (x; consolidateR(s[1 .. $])) { + if (!r[0].setIntersection(x).empty) { + r[0] = r[0].setUnion(x).uniq.array; + } else + r ~= x; + } + return r; + } + + return consolidateR(sets); +} + +void main() { + [['A', 'B'], ['C','D']].consolidate.writeln; + + [['A','B'], ['B','D']].consolidate.writeln; + + [['A','B'], ['C','D'], ['D','B']].consolidate.writeln; + + [['H','I','K'], ['A','B'], ['C','D'], + ['D','B'], ['F','G','H']].consolidate.writeln; +} diff --git a/Task/Set-consolidation/Ela/set-consolidation-1.ela b/Task/Set-consolidation/Ela/set-consolidation-1.ela new file mode 100644 index 0000000000..f756567128 --- /dev/null +++ b/Task/Set-consolidation/Ela/set-consolidation-1.ela @@ -0,0 +1,11 @@ +open list + +merge [] ys = ys +merge (x::xs) ys | x `elem` ys = merge xs ys + | else = merge xs (x::ys) + +consolidate (_::[])@xs = xs +consolidate (x::xs) = conso [x] (consolidate xs) + where conso xs [] = xs + conso (x::xs)@r (y::ys) | intersect x y <> [] = conso ((merge x y)::xs) ys + | else = conso (r ++ [y]) ys diff --git a/Task/Set-consolidation/Ela/set-consolidation-2.ela b/Task/Set-consolidation/Ela/set-consolidation-2.ela new file mode 100644 index 0000000000..ce9b3f5fa7 --- /dev/null +++ b/Task/Set-consolidation/Ela/set-consolidation-2.ela @@ -0,0 +1,4 @@ +open console + +consolidate [['H','I','K'], ['A','B'], ['C','D'], ['D','B'], ['F','G','H']] |> writen $ + consolidate [['A','B'], ['B','D']] |> writen diff --git a/Task/Set-consolidation/Go/set-consolidation.go b/Task/Set-consolidation/Go/set-consolidation.go new file mode 100644 index 0000000000..b0fc6e5a79 --- /dev/null +++ b/Task/Set-consolidation/Go/set-consolidation.go @@ -0,0 +1,56 @@ +package main + +import "fmt" + +type set map[string]bool + +var testCase = []set{ + set{"H": true, "I": true, "K": true}, + set{"A": true, "B": true}, + set{"C": true, "D": true}, + set{"D": true, "B": true}, + set{"F": true, "G": true, "H": true}, +} + +func main() { + fmt.Println(consolidate(testCase)) +} + +func consolidate(sets []set) []set { + setlist := []set{} + for _, s := range sets { + if s != nil && len(s) > 0 { + setlist = append(setlist, s) + } + } + for i, s1 := range setlist { + if len(s1) > 0 { + for _, s2 := range setlist[i+1:] { + if s1.disjoint(s2) { + continue + } + for e := range s1 { + s2[e] = true + delete(s1, e) + } + s1 = s2 + } + } + } + r := []set{} + for _, s := range setlist { + if len(s) > 0 { + r = append(r, s) + } + } + return r +} + +func (s1 set) disjoint(s2 set) bool { + for e := range s2 { + if s1[e] { + return false + } + } + return true +} diff --git a/Task/Set-consolidation/Haskell/set-consolidation.hs b/Task/Set-consolidation/Haskell/set-consolidation.hs new file mode 100644 index 0000000000..94267efca7 --- /dev/null +++ b/Task/Set-consolidation/Haskell/set-consolidation.hs @@ -0,0 +1,8 @@ +import qualified Data.Set as S + +consolidate :: Ord a => [S.Set a] -> [S.Set a] +consolidate = foldl comb [] + where comb [] s' = [s'] + comb (s:ss) s' + | S.null (s `S.intersection` s') = s : comb ss s' + | otherwise = comb ss (s `S.union` s') diff --git a/Task/Set-consolidation/J/set-consolidation-1.j b/Task/Set-consolidation/J/set-consolidation-1.j new file mode 100644 index 0000000000..4500a42588 --- /dev/null +++ b/Task/Set-consolidation/J/set-consolidation-1.j @@ -0,0 +1,4 @@ +consolidate=:4 :0/ + b=. y 1&e.@e.&> x + (1,-.b)#(~.;x,b#y);y +) diff --git a/Task/Set-consolidation/J/set-consolidation-2.j b/Task/Set-consolidation/J/set-consolidation-2.j new file mode 100644 index 0000000000..7e0a81e876 --- /dev/null +++ b/Task/Set-consolidation/J/set-consolidation-2.j @@ -0,0 +1,16 @@ + consolidate 'ab';'cd' +┌──┬──┐ +│ab│cd│ +└──┴──┘ + consolidate 'ab';'bd' +┌───┐ +│abd│ +└───┘ + consolidate 'ab';'cd';'db' +┌────┐ +│abcd│ +└────┘ + consolidate 'hij';'ab';'cd';'db';'fgh' +┌─────┬────┐ +│hijfg│abcd│ +└─────┴────┘ diff --git a/Task/Set-consolidation/Java/set-consolidation.java b/Task/Set-consolidation/Java/set-consolidation.java new file mode 100644 index 0000000000..91c7b83722 --- /dev/null +++ b/Task/Set-consolidation/Java/set-consolidation.java @@ -0,0 +1,63 @@ +import java.util.*; + +public class SetConsolidation { + + public static void main(String[] args) { + List> h1 = hashSetList("AB", "CD"); + System.out.println(consolidate(h1)); + + List> h2 = hashSetList("AB", "BD"); + System.out.println(consolidateR(h2)); + + List> h3 = hashSetList("AB", "CD", "DB"); + System.out.println(consolidate(h3)); + + List> h4 = hashSetList("HIK", "AB", "CD", "DB", "FGH"); + System.out.println(consolidateR(h4)); + } + + // iterative + private static List> + consolidate(Collection> sets) { + List> r = new ArrayList<>(); + for (Set s : sets) { + List> new_r = new ArrayList<>(); + new_r.add(s); + for (Set x : r) { + if (!Collections.disjoint(s, x)) { + s.addAll(x); + } else { + new_r.add(x); + } + } + r = new_r; + } + return r; + } + + // recursive + private static List> consolidateR(List> sets) { + if (sets.size() < 2) + return sets; + List> r = new ArrayList<>(); + r.add(sets.get(0)); + for (Set x : consolidateR(sets.subList(1, sets.size()))) { + if (!Collections.disjoint(r.get(0), x)) { + r.get(0).addAll(x); + } else { + r.add(x); + } + } + return r; + } + + private static List> hashSetList(String... set) { + List> r = new ArrayList<>(); + for (int i = 0; i < set.length; i++) { + r.add(new HashSet()); + for (int j = 0; j < set[i].length(); j++) + r.get(i).add(set[i].charAt(j)); + } + return r; + } +} diff --git a/Task/Set-consolidation/Mathematica/set-consolidation.math b/Task/Set-consolidation/Mathematica/set-consolidation.math new file mode 100644 index 0000000000..30436e04b1 --- /dev/null +++ b/Task/Set-consolidation/Mathematica/set-consolidation.math @@ -0,0 +1,10 @@ +reduce[x_] := + Block[{pairs, unique}, + pairs = + DeleteCases[ + Subsets[Range@ + Length@x, {2}], _?(Intersection @@ x[[#]] == {} &)]; + unique = Complement[Range@Length@x, Flatten@pairs]; + Join[Union[Flatten[x[[#]]]] & /@ pairs, x[[unique]]]] + +consolidate[x__] := FixedPoint[reduce, {x}] diff --git a/Task/Set-consolidation/OCaml/set-consolidation.ocaml b/Task/Set-consolidation/OCaml/set-consolidation.ocaml new file mode 100644 index 0000000000..443fc4273a --- /dev/null +++ b/Task/Set-consolidation/OCaml/set-consolidation.ocaml @@ -0,0 +1,40 @@ +let join a b = + List.fold_left (fun acc v -> + if List.mem v acc then acc else v::acc + ) b a + +let share a b = List.exists (fun x -> List.mem x b) a + +let extract p lst = + let rec aux acc = function + | x::xs -> if p x then Some (x, List.rev_append acc xs) else aux (x::acc) xs + | [] -> None + in + aux [] lst + +let consolidate sets = + let rec aux acc = function + | [] -> List.rev acc + | x::xs -> + match extract (share x) xs with + | Some (y, ys) -> aux acc ((join x y) :: ys) + | None -> aux (x::acc) xs + in + aux [] sets + +let print_sets sets = + print_string "{ "; + List.iter (fun set -> + print_string "{"; + print_string (String.concat " " set); + print_string "} " + ) sets; + print_endline "}" + +let () = + print_sets (consolidate [["A";"B"]; ["C";"D"]]); + print_sets (consolidate [["A";"B"]; ["B";"C"]]); + print_sets (consolidate [["A";"B"]; ["C";"D"]; ["D";"B"]]); + print_sets (consolidate [["H";"I";"K"]; ["A";"B"]; ["C";"D"]; ["D";"B"]; + ["F";"G";"H"]]); +;; diff --git a/Task/Set-consolidation/PARI-GP/set-consolidation.pari b/Task/Set-consolidation/PARI-GP/set-consolidation.pari new file mode 100644 index 0000000000..39290f1dd4 --- /dev/null +++ b/Task/Set-consolidation/PARI-GP/set-consolidation.pari @@ -0,0 +1,12 @@ +cons(V)={ + my(v,u,s); + for(i=1,#V, + v=V[i]; + for(j=i+1,#V, + u=V[j]; + if(#setintersect(u,v),V[i]=v=vecsort(setunion(u,v));V[j]=[];s++) + ) + ); + V=select(v->#v,V); + if(s,cons(V),V) +}; diff --git a/Task/Set-consolidation/Perl-6/set-consolidation.pl6 b/Task/Set-consolidation/Perl-6/set-consolidation.pl6 new file mode 100644 index 0000000000..4d0d8a5518 --- /dev/null +++ b/Task/Set-consolidation/Perl-6/set-consolidation.pl6 @@ -0,0 +1,17 @@ +multi consolidate() { () } +multi consolidate(Set \this is copy, *@those) { + gather { + for consolidate |@those -> \that { + if this ∩ that { this ∪= that } + else { take that } + } + take this; + } +} + +enum Elems ('A'..'Z'); +say $_, "\n ==> ", consolidate |$_ + for [set(A,B), set(C,D)], + [set(A,B), set(B,D)], + [set(A,B), set(C,D), set(D,B)], + [set(H,I,K), set(A,B), set(C,D), set(D,B), set(F,G,H)]; diff --git a/Task/Set-consolidation/PicoLisp/set-consolidation-1.l b/Task/Set-consolidation/PicoLisp/set-consolidation-1.l new file mode 100644 index 0000000000..3b82239237 --- /dev/null +++ b/Task/Set-consolidation/PicoLisp/set-consolidation-1.l @@ -0,0 +1,8 @@ +(de consolidate (S) + (when S + (let R (cons (car S)) + (for X (consolidate (cdr S)) + (if (mmeq X (car R)) + (set R (uniq (conc X (car R)))) + (conc R (cons X)) ) ) + R ) ) ) diff --git a/Task/Set-consolidation/PicoLisp/set-consolidation-2.l b/Task/Set-consolidation/PicoLisp/set-consolidation-2.l new file mode 100644 index 0000000000..2a18744b91 --- /dev/null +++ b/Task/Set-consolidation/PicoLisp/set-consolidation-2.l @@ -0,0 +1,8 @@ +: (consolidate '((A B) (C D))) +-> ((A B) (C D)) +: (consolidate '((A B) (B D))) +-> ((B D A)) +: (consolidate '((A B) (C D) (D B))) +-> ((D B C A)) +: (consolidate '((H I K) (A B) (C D) (D B) (F G H))) +-> ((F G H I K) (D B C A)) diff --git a/Task/Set-consolidation/Python/set-consolidation-1.py b/Task/Set-consolidation/Python/set-consolidation-1.py new file mode 100644 index 0000000000..5b9f6dfc35 --- /dev/null +++ b/Task/Set-consolidation/Python/set-consolidation-1.py @@ -0,0 +1,42 @@ +def consolidate(sets): + ''' + >>> # Define some variables + >>> A,B,C,D,E,F,G,H,I,J,K = 'A,B,C,D,E,F,G,H,I,J,K'.split(',') + >>> # Consolidate some lists of sets + >>> consolidate([{A,B}, {C,D}]) + [{'A', 'B'}, {'C', 'D'}] + >>> consolidate([{A,B}, {B,D}]) + [{'A', 'B', 'D'}] + >>> consolidate([{A,B}, {C,D}, {D,B}]) + [{'A', 'C', 'B', 'D'}] + >>> consolidate([{H,I,K}, {A,B}, {C,D}, {D,B}, {F,G,H}]) + [{'A', 'C', 'B', 'D'}, {'G', 'F', 'I', 'H', 'K'}] + >>> consolidate([{A,H}, {H,I,K}, {A,B}, {C,D}, {D,B}, {F,G,H}]) + [{'A', 'C', 'B', 'D', 'G', 'F', 'I', 'H', 'K'}] + >>> consolidate([{H,I,K}, {A,B}, {C,D}, {D,B}, {F,G,H}, {A,H}]) + [{'A', 'C', 'B', 'D', 'G', 'F', 'I', 'H', 'K'}] + >>> # Confirm order-independence + >>> from copy import deepcopy + >>> import itertools + >>> sets = [{H,I,K}, {A,B}, {C,D}, {D,B}, {F,G,H}, {A,H}] + >>> answer = consolidate(deepcopy(sets)) + >>> for perm in itertools.permutations(sets): + assert consolidate(deepcopy(perm)) == answer + + + >>> answer + [{'A', 'C', 'B', 'D', 'G', 'F', 'I', 'H', 'K'}] + >>> len(list(itertools.permutations(sets))) + 720 + >>> + ''' + setlist = [s for s in sets if s] + for i, s1 in enumerate(setlist): + if s1: + for s2 in setlist[i+1:]: + intersection = s1.intersection(s2) + if intersection: + s2.update(s1) + s1.clear() + s1 = s2 + return [s for s in setlist if s] diff --git a/Task/Set-consolidation/Python/set-consolidation-2.py b/Task/Set-consolidation/Python/set-consolidation-2.py new file mode 100644 index 0000000000..678ab8fba6 --- /dev/null +++ b/Task/Set-consolidation/Python/set-consolidation-2.py @@ -0,0 +1,8 @@ +def conso(s): + if len(s) < 2: return s + + r, b = [s[0]], conso(s[1:]) + for x in b: + if r[0].intersection(x): r[0].update(x) + else: r.append(x) + return r diff --git a/Task/Set-consolidation/REXX/set-consolidation.rexx b/Task/Set-consolidation/REXX/set-consolidation.rexx new file mode 100644 index 0000000000..e2863263ef --- /dev/null +++ b/Task/Set-consolidation/REXX/set-consolidation.rexx @@ -0,0 +1,53 @@ +/*REXX program shows how to consolidate a sample bunch of sets. */ +sets.= /*assign all SETS. to null. */ +sets.1 = '{A,B} {C,D}' +sets.2 = "{A,B} {B,D}" +sets.3 = '{A,B} {C,D} {D,B}' +sets.4 = '{H,I,K} {A,B} {C,D} {D,B} {F,G,H}' +sets.5 = '{snow,ice,slush,frost,fog} {iceburgs,icecubes} {rain,fog,sleet}' + + do j=1 while sets.j\=='' /*traipse through the sample sets*/ + call SETcombo sets.j /*have the other guy do the work.*/ + end /*j*/ +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────SETcombo subroutine─────────────────*/ +SETcombo: procedure; parse arg bunch; n=words(bunch); newBunch= +say ' the old sets=' space(bunch) + + do k=1 for n /*change all commas to a blank. */ + @.k=translate(word(bunch,k),,'},{') /*create a list of words (=a set)*/ + end /*k*/ /*... and also remove the braces.*/ + + do until \changed; changed=0 /*consolidate some sets (maybe).*/ + do set=1 for n-1 + do item=1 for words(@.set); x=word(@.set,item) + do other=set+1 to n + if isIn(x,@.other) then do; changed=1 + @.set=@.set @.other; @.other= + iterate set + end + end /*other*/ + end /*item*/ + end /*set*/ + end /*until ¬changed*/ + + do set=1 for n; new= /*remove duplicates in a set. */ + do items=1 for words(@.set) + x=word(@.set,items); if x==',' then iterate; if x=='' then leave + new=new x /*start building the new set. */ + do forever; if \isIn(x,@.set) then leave + _=wordpos(x,@.set) + @.set=subword(@.set,1,_-1) ',' subword(@.set,_+1) /*purify set.*/ + end /*forever*/ + end /*items*/ + @.set=translate(strip(new),','," ") + end /*set*/ + + do new=1 for n; if @.new=='' then iterate + newBunch=space(newbunch '{'@.new"}") + end /*new*/ + +say ' the new sets=' newBunch; say +return +/*──────────────────────────────────isIn subroutine─────────────────────*/ +isIn: return wordpos(arg(1),arg(2))\==0 /*is (word) arg1 in set arg2? */ diff --git a/Task/Set-consolidation/Tcl/set-consolidation-1.tcl b/Task/Set-consolidation/Tcl/set-consolidation-1.tcl new file mode 100644 index 0000000000..3b007b0b76 --- /dev/null +++ b/Task/Set-consolidation/Tcl/set-consolidation-1.tcl @@ -0,0 +1,18 @@ +package require struct::set + +proc consolidate {sets} { + if {[llength $sets] < 2} { + return $sets + } + + set r [list {}] + set r0 [lindex $sets 0] + foreach x [consolidate [lrange $sets 1 end]] { + if {[struct::set size [struct::set intersect $x $r0]]} { + struct::set add r0 $x + } else { + lappend r $x + } + } + return [lset r 0 $r0] +} diff --git a/Task/Set-consolidation/Tcl/set-consolidation-2.tcl b/Task/Set-consolidation/Tcl/set-consolidation-2.tcl new file mode 100644 index 0000000000..2cbbbf13cb --- /dev/null +++ b/Task/Set-consolidation/Tcl/set-consolidation-2.tcl @@ -0,0 +1,4 @@ +puts 1:[consolidate {{A B} {C D}}] +puts 2:[consolidate {{A B} {B D}}] +puts 3:[consolidate {{A B} {C D} {D B}}] +puts 4:[consolidate {{H I K} {A B} {C D} {D B} {F G H}}] diff --git a/Task/Set-of-real-numbers/0DESCRIPTION b/Task/Set-of-real-numbers/0DESCRIPTION new file mode 100644 index 0000000000..ddfac94216 --- /dev/null +++ b/Task/Set-of-real-numbers/0DESCRIPTION @@ -0,0 +1,33 @@ +All real numbers form the uncountable set ℝ. Among its subsets, relatively simple are the convex sets, each expressed as a range between two real numbers ''a'' and ''b'' where ''a'' ≤ ''b''. There are actually four cases for the meaning of "between", depending on open or closed boundary: +* [''a'', ''b'']: {''x'' | ''a'' ≤ ''x'' and ''x'' ≤ ''b'' } +* (''a'', ''b''): {''x'' | ''a'' < ''x'' and ''x'' < ''b'' } +* [''a'', ''b''): {''x'' | ''a'' ≤ ''x'' and ''x'' < ''b'' } +* (''a'', ''b'']: {''x'' | ''a'' < ''x'' and ''x'' ≤ ''b'' } +Note that if ''a'' = ''b'', of the four only [''a'', ''a''] would be non-empty. + +'''Task''' +* Devise a way to represent any set of real numbers, for the definition of 'any' in the implementation notes below. +* Provide methods for these common set operations (''x'' is a real number; ''A'' and ''B'' are sets): +:* ''x'' ∈ ''A'': determine if ''x'' is an element of ''A'' +:: example: 1 is in [1, 2), while 2, 3, ... are not. +:* ''A'' ∪ ''B'': union of ''A'' and ''B'', i.e. {''x'' | ''x'' ∈ ''A'' or ''x'' ∈ ''B''} +:: example: [0, 2) ∪ (1, 3) = [0, 3); [0, 1) ∪ (2, 3] = well, [0, 1) ∪ (2, 3] +:* ''A'' ∩ ''B'': intersection of ''A'' and ''B'', i.e. {''x'' | ''x'' ∈ ''A'' and ''x'' ∈ ''B''} +:: example: [0, 2) ∩ (1, 3) = (1, 2); [0, 1) ∩ (2, 3] = empty set +:* ''A'' - ''B'': difference between ''A'' and ''B'', also written as ''A'' \ ''B'', i.e. {''x'' | ''x'' ∈ ''A'' and ''x'' ∉ ''B''} +:: example: [0, 2) − (1, 3) = [0, 1] +* Test your implementation by checking if numbers 0, 1, and 2 are in any of the following sets: +:* (0, 1] ∪ [0, 2) +:* [0, 2) ∩ (1, 2] +:* [0, 3) − (0, 1) +:* [0, 3) − [0, 1] + +'''Implementation notes''' +* 'Any' real set means 'sets that can be expressed as the union of a finite number of convex real sets'. Cantor's set needs not apply. +* Infinities should be handled gracefully; indeterminate numbers (NaN) can be ignored. +* You can use your machine's native real number representation, which is probably IEEE floating point, and assume it's good enough (it usually is). + +'''Optional work''' +* Have a method to determin if a given set is empty (contains no element). +* Define ''[http://www.wolframalpha.com/input/?i=%7Csin%28pi+x2%29%7C%3E1%2F2%2C+0+%3C+x+%3C+10 A]'' = {''x'' | 0 < ''x'' < 10 and |sin(π ''x''²)| > 1/2 }, ''[http://www.wolframalpha.com/input/?i=%7Csin%28pi+x%29%7C%3E1%2F2%2C+0+%3C+x+%3C+10 B]'' = {''x'' | 0 < ''x'' < 10 and |sin(π ''x'')| > 1/2}, calculate the length of the real axis covered by the set ''A'' − ''B''. Note that +|sin(π ''x'')| > 1/2 is the same as ''n'' + 1/6 < ''x'' < ''n'' + 5/6 for all integers ''n''; your program does not need to derive this by itself. diff --git a/Task/Set-of-real-numbers/C-sharp/set-of-real-numbers-1.cs b/Task/Set-of-real-numbers/C-sharp/set-of-real-numbers-1.cs new file mode 100644 index 0000000000..5e1af44979 --- /dev/null +++ b/Task/Set-of-real-numbers/C-sharp/set-of-real-numbers-1.cs @@ -0,0 +1,33 @@ +using System; + +namespace RosettaCode.SetOfRealNumbers +{ + public class Set + { + public Set(Predicate contains) + { + Contains = contains; + } + + public Predicate Contains + { + get; + private set; + } + + public Set Union(Set set) + { + return new Set(value => Contains(value) || set.Contains(value)); + } + + public Set Intersection(Set set) + { + return new Set(value => Contains(value) && set.Contains(value)); + } + + public Set Difference(Set set) + { + return new Set(value => Contains(value) && !set.Contains(value)); + } + } +} diff --git a/Task/Set-of-real-numbers/C-sharp/set-of-real-numbers-2.cs b/Task/Set-of-real-numbers/C-sharp/set-of-real-numbers-2.cs new file mode 100644 index 0000000000..3aa95f7f35 --- /dev/null +++ b/Task/Set-of-real-numbers/C-sharp/set-of-real-numbers-2.cs @@ -0,0 +1,49 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using RosettaCode.SetOfRealNumbers; + +namespace RosettaCode.SetOfRealNumbersTest +{ + [TestClass] + public class SetTest + { + [TestMethod] + public void TestUnion() + { + var set = + new Set(value => 0d < value && value <= 1d).Union( + new Set(value => 0d <= value && value < 2d)); + Assert.IsTrue(set.Contains(0d)); + Assert.IsTrue(set.Contains(1d)); + Assert.IsFalse(set.Contains(2d)); + } + + [TestMethod] + public void TestIntersection() + { + var set = + new Set(value => 0d <= value && value < 2d).Intersection( + new Set(value => 1d < value && value <= 2d)); + Assert.IsFalse(set.Contains(0d)); + Assert.IsFalse(set.Contains(1d)); + Assert.IsFalse(set.Contains(2d)); + } + + [TestMethod] + public void TestDifference() + { + var set = + new Set(value => 0d <= value && value < 3d).Difference( + new Set(value => 0d < value && value < 1d)); + Assert.IsTrue(set.Contains(0d)); + Assert.IsTrue(set.Contains(1d)); + Assert.IsTrue(set.Contains(2d)); + + set = + new Set(value => 0d <= value && value < 3d).Difference( + new Set(value => 0d <= value && value <= 1d)); + Assert.IsFalse(set.Contains(0d)); + Assert.IsFalse(set.Contains(1d)); + Assert.IsTrue(set.Contains(2d)); + } + } +} diff --git a/Task/Set-of-real-numbers/D/set-of-real-numbers.d b/Task/Set-of-real-numbers/D/set-of-real-numbers.d new file mode 100644 index 0000000000..bcdda17e71 --- /dev/null +++ b/Task/Set-of-real-numbers/D/set-of-real-numbers.d @@ -0,0 +1,61 @@ +struct Set(T) { + const pure nothrow bool delegate(in T) contains; + + bool opIn_r(in T x) const pure nothrow { + return contains(x); + } + + Set opBinary(string op)(in Set set) + const pure nothrow if (op == "+" || op == "-") { + static if (op == "+") + return Set(x => contains(x) || set.contains(x)); + else + return Set(x => contains(x) && !set.contains(x)); + } + + Set intersection(in Set set) const pure nothrow { + return Set(x => contains(x) && set.contains(x)); + } +} + +unittest { // Test union. + alias DSet = Set!double; + const s = DSet(x => 0.0 < x && x <= 1.0) + + DSet(x => 0.0 <= x && x < 2.0); + assert(0.0 in s); + assert(1.0 in s); + assert(2.0 !in s); +} + +unittest { // Test difference. + alias DSet = Set!double; + const s1 = DSet(x => 0.0 <= x && x < 3.0) - + DSet(x => 0.0 < x && x < 1.0); + assert(0.0 in s1); + assert(0.5 !in s1); + assert(1.0 in s1); + assert(2.0 in s1); + + const s2 = DSet(x => 0.0 <= x && x < 3.0) - + DSet(x => 0.0 <= x && x <= 1.0); + assert(0.0 !in s2); + assert(1.0 !in s2); + assert(2.0 in s2); + + const s3 = DSet(x => 0 <= x && x <= double.infinity) - + DSet(x => 1.0 <= x && x <= 2.0); + assert(0.0 in s3); + assert(1.5 !in s3); + assert(3.0 in s3); +} + +unittest { // Test intersection. + alias DSet = Set!double; + const s = DSet(x => 0.0 <= x && x < 2.0).intersection( + DSet(x => 1.0 < x && x <= 2.0)); + assert(0.0 !in s); + assert(1.0 !in s); + assert(2.0 !in s); +} + +void main() {} diff --git a/Task/Set-of-real-numbers/J/set-of-real-numbers-1.j b/Task/Set-of-real-numbers/J/set-of-real-numbers-1.j new file mode 100644 index 0000000000..606f659e2f --- /dev/null +++ b/Task/Set-of-real-numbers/J/set-of-real-numbers-1.j @@ -0,0 +1,18 @@ +has=: 1 :'(interval m)`:6' +ing=: `'' + +interval=: 3 :0 + if.0`>:@.cH))ing +) + +in=: 4 :'y has x' +union=: 4 :'(x has +. y has)ing' +intersect=: 4 :'(x has *. y has)ing' +without=: 4 :'(x has *. [: -. y has)ing' diff --git a/Task/Set-of-real-numbers/J/set-of-real-numbers-10.j b/Task/Set-of-real-numbers/J/set-of-real-numbers-10.j new file mode 100644 index 0000000000..783aa055a0 --- /dev/null +++ b/Task/Set-of-real-numbers/J/set-of-real-numbers-10.j @@ -0,0 +1,2 @@ + (+/_2 -~/\zA) - +/,0>.zA (<.&{: - >.&{.)"1/&(_2 ]\ ]) zB +2.07586 diff --git a/Task/Set-of-real-numbers/J/set-of-real-numbers-11.j b/Task/Set-of-real-numbers/J/set-of-real-numbers-11.j new file mode 100644 index 0000000000..074e778223 --- /dev/null +++ b/Task/Set-of-real-numbers/J/set-of-real-numbers-11.j @@ -0,0 +1,4 @@ +intervalSet=: interval@('[',[,',',],')'"_)&": +A=: union/_2 intervalSet/\ zA +B=: union/_2 intervalSet/\ zB +diff=: A without B diff --git a/Task/Set-of-real-numbers/J/set-of-real-numbers-12.j b/Task/Set-of-real-numbers/J/set-of-real-numbers-12.j new file mode 100644 index 0000000000..27ad4e9ae4 --- /dev/null +++ b/Task/Set-of-real-numbers/J/set-of-real-numbers-12.j @@ -0,0 +1,2 @@ + +/ ((2 (+/%#)\ edge diff) in diff) * 2 -~/\ edge diff +2.07588 diff --git a/Task/Set-of-real-numbers/J/set-of-real-numbers-2.j b/Task/Set-of-real-numbers/J/set-of-real-numbers-2.j new file mode 100644 index 0000000000..c9d09447b5 --- /dev/null +++ b/Task/Set-of-real-numbers/J/set-of-real-numbers-2.j @@ -0,0 +1,10 @@ + ('(0,1]' union '[0,2)')has 0 1 2 +1 1 0 + ('[0,2)' intersect '(1,2]')has 0 1 2 +0 0 0 + ('[0,3)' without '(0,1]')has 0 1 2 +1 0 1 + ('[0,3)' without '(0,1)')has 0 1 2 +1 1 1 + ('[0,3)' without '[0,1]')has 0 1 2 +0 0 1 diff --git a/Task/Set-of-real-numbers/J/set-of-real-numbers-3.j b/Task/Set-of-real-numbers/J/set-of-real-numbers-3.j new file mode 100644 index 0000000000..c5a77f423c --- /dev/null +++ b/Task/Set-of-real-numbers/J/set-of-real-numbers-3.j @@ -0,0 +1,2 @@ + ('(0,1]' union '[0,2)')has +(0&< *. 1&>:) +. 0&<: *. 2&> diff --git a/Task/Set-of-real-numbers/J/set-of-real-numbers-4.j b/Task/Set-of-real-numbers/J/set-of-real-numbers-4.j new file mode 100644 index 0000000000..afbf3b4725 --- /dev/null +++ b/Task/Set-of-real-numbers/J/set-of-real-numbers-4.j @@ -0,0 +1,23 @@ +has=: 1 :'(0 {:: interval m)`:6' +ing=: `'' + +edge=: 1&{::&interval +edges=: /:~@~.@,&edge +contour=: (, 2 (+/%#)\ ])@edge + +interval=: 3 :0 + if.0`>:@.cH))ing ; lo,hi +) + +in=: 4 :'y has x' +union=: 4 :'(x has +. y has)ing; x edges y' +intersect=: 4 :'(x has *. y has)ing; x edges y' +without=: 4 :'(x has *. [: -. y has)ing; x edges y' +isEmpty=: 1 -.@e. contour in ] diff --git a/Task/Set-of-real-numbers/J/set-of-real-numbers-5.j b/Task/Set-of-real-numbers/J/set-of-real-numbers-5.j new file mode 100644 index 0000000000..bfa568f5d2 --- /dev/null +++ b/Task/Set-of-real-numbers/J/set-of-real-numbers-5.j @@ -0,0 +1,10 @@ + isEmpty '(0,1]' union '[0,2)' +0 + isEmpty '[0,2)' intersect '(1,2]' +0 + isEmpty '[0,2)' intersect '(2,3]' +1 + isEmpty '[0,2)' intersect '[2,3]' +1 + isEmpty '[0,2]' intersect '[2,3]' +0 diff --git a/Task/Set-of-real-numbers/J/set-of-real-numbers-6.j b/Task/Set-of-real-numbers/J/set-of-real-numbers-6.j new file mode 100644 index 0000000000..dac6f6be5f --- /dev/null +++ b/Task/Set-of-real-numbers/J/set-of-real-numbers-6.j @@ -0,0 +1,2 @@ + 1p_1 * _1 o. 0.5 +0.166667 diff --git a/Task/Set-of-real-numbers/J/set-of-real-numbers-7.j b/Task/Set-of-real-numbers/J/set-of-real-numbers-7.j new file mode 100644 index 0000000000..8af5cc79a7 --- /dev/null +++ b/Task/Set-of-real-numbers/J/set-of-real-numbers-7.j @@ -0,0 +1,4 @@ + (#~ 0.5 = 1 |@o. 1r6p1&*) i. 30 +1 5 7 11 13 17 19 23 25 29 + 2 -~/\ (#~ 0.5 = 1 |@o. 1r6p1&*) i. 30 +4 2 4 2 4 2 4 2 4 diff --git a/Task/Set-of-real-numbers/J/set-of-real-numbers-8.j b/Task/Set-of-real-numbers/J/set-of-real-numbers-8.j new file mode 100644 index 0000000000..aa68843073 --- /dev/null +++ b/Task/Set-of-real-numbers/J/set-of-real-numbers-8.j @@ -0,0 +1 @@ +zeros0toN=: ((>: # ])[:+/\1,$&4 2@<.)&.(6&*) diff --git a/Task/Set-of-real-numbers/J/set-of-real-numbers-9.j b/Task/Set-of-real-numbers/J/set-of-real-numbers-9.j new file mode 100644 index 0000000000..cb71c0c1ce --- /dev/null +++ b/Task/Set-of-real-numbers/J/set-of-real-numbers-9.j @@ -0,0 +1,11 @@ +zB=: zeros0toN 10 +zA=: zeros0toN&.*: 10 + + zA +0.408248 0.912871 1.08012 1.35401 1.47196 1.68325 1.77951 1.95789 2.04124 2.1984... + zB +0.166667 0.833333 1.16667 1.83333 2.16667 2.83333 3.16667 3.83333 4.16667 4.8333... + #zA +200 + #zB +20 diff --git a/Task/Set-of-real-numbers/Perl-6/set-of-real-numbers.pl6 b/Task/Set-of-real-numbers/Perl-6/set-of-real-numbers.pl6 new file mode 100644 index 0000000000..10792079d5 --- /dev/null +++ b/Task/Set-of-real-numbers/Perl-6/set-of-real-numbers.pl6 @@ -0,0 +1,149 @@ +class Iv { + has $.range handles ; + method empty { + $.min after $.max or $.min === $.max && ($.excludes_min || $.excludes_max) + } + multi method Bool() { not self.empty }; + method length() { $.max - $.min } + method gist() { + ($.excludes_min ?? '(' !! '[') ~ + $.min ~ ',' ~ $.max ~ + ($.excludes_max ?? ')' !! ']'); + } +} + +class IvSet { + has Iv @.intervals; + + sub canon (@i) { + my @new = consolidate(|@i).grep(*.so); + @new.sort(*.range.min); + } + + method new(@ranges) { + my @iv = canon @ranges.map: { Iv.new(:range($_)) } + self.bless(*, :intervals(@iv)); + } + + method complement { + my @new; + my @old = @!intervals; + if not @old { + return iv -Inf..Inf; + } + my $pre; + push @old, $(Inf^..Inf) unless @old[*-1].max === Inf; + if @old[0].min === -Inf { + $pre = @old.shift; + } + else { + $pre = -Inf..^-Inf; + } + while @old { + my $old = @old.shift; + my $excludes_min = !$pre.excludes_max; + my $excludes_max = !$old.excludes_min; + push @new, $(Range.new($pre.max,$old.min,:$excludes_min,:$excludes_max)); + $pre = $old; + } + IvSet.new(@new); + } + + method ACCEPTS(IvSet:D $me: $candidate) { + so $.intervals.any.ACCEPTS($candidate); + } + method empty { so $.intervals.all.empty } + multi method Bool() { not self.empty }; + + method length() { [+] $.intervals».length } + method gist() { join ' ', $.intervals».gist } +} + +sub iv(**@ranges) { IvSet.new(@ranges) } + +multi infix:<∩> (Iv $a, Iv $b) { + if $a.min ~~ $b or $a.max ~~ $b or $b.min ~~ $a or $b.max ~~ $a { + my $min = $a.range.min max $b.range.min; + my $max = $a.range.max min $b.range.max; + my $excludes_min = not $min ~~ $a & $b; + my $excludes_max = not $max ~~ $a & $b; + Iv.new(:range(Range.new($min,$max,:$excludes_min, :$excludes_max))); + } +} +multi infix:<∪> (Iv $a, Iv $b) { + my $min = $a.range.min min $b.range.min; + my $max = $a.range.max max $b.range.max; + my $excludes_min = not $min ~~ $a | $b; + my $excludes_max = not $max ~~ $a | $b; + Iv.new(:range(Range.new($min,$max,:$excludes_min, :$excludes_max))); +} + +multi infix:<∩> (IvSet $ars, IvSet $brs) { + my @overlap; + for $ars.intervals -> $a { + for $brs.intervals -> $b { + if $a.min ~~ $b or $a.max ~~ $b or $b.min ~~ $a or $b.max ~~ $a { + my $min = $a.range.min max $b.range.min; + my $max = $a.range.max min $b.range.max; + my $excludes_min = not $min ~~ $a & $b; + my $excludes_max = not $max ~~ $a & $b; + push @overlap, $(Range.new($min,$max,:$excludes_min, :$excludes_max)); + } + } + } + IvSet.new(@overlap) +} + +multi infix:<∪> (IvSet $a, IvSet $b) { + iv |$a.intervals».range, |$b.intervals».range; +} + +multi consolidate() { () } +multi consolidate($this is copy, *@those) { + gather { + for consolidate |@those -> $that { + if $this ∩ $that { $this ∪= $that } + else { take $that } + } + take $this; + } +} + +multi infix:<−> (IvSet $a, IvSet $b) { $a ∩ $b.complement } + +multi prefix:<−> (IvSet $a) { $a.complement; } + +constant ℝ = iv -Inf..Inf; + +my $s1 = iv(0^..1) ∪ iv(0..^2); +my $s2 = iv(0..^2) ∩ iv(1^..2); +my $s3 = iv(0..^3) − iv(0^..^1); +my $s4 = iv(0..^3) − iv(0..1) ; + +say "\t\t\t\t0\t1\t2"; +say "(0, 1] ∪ [0, 2) -> $s1.gist()\t", 0 ~~ $s1,"\t", 1 ~~ $s1,"\t", 2 ~~ $s1; +say "[0, 2) ∩ (1, 2] -> $s2.gist()\t", 0 ~~ $s2,"\t", 1 ~~ $s2,"\t", 2 ~~ $s2; +say "[0, 3) − (0, 1) -> $s3.gist()\t", 0 ~~ $s3,"\t", 1 ~~ $s3,"\t", 2 ~~ $s3; +say "[0, 3) − [0, 1] -> $s4.gist()\t", 0 ~~ $s4,"\t", 1 ~~ $s4,"\t", 2 ~~ $s4; + +say ''; + +say "ℝ is not empty: ", !ℝ.empty; +say "[0,3] − ℝ is empty: ", not iv(0..3) − ℝ; + +my $A = iv(0..10) + ∩ + [∪] (0..10).map: { iv $_ - 1/6 .. $_ + 1/6 } + +my $B = iv 0..sqrt(1/6), + |(1..99).map({ $(sqrt($_-1/6) .. sqrt($_ + 1/6)) }), + sqrt(100-1/6)..10; + +say 'A − A is empty: ', not $A − $A; + +say ''; + +my $C = $A − $B; +say "A − B ="; +say " ",.gist for $C.intervals; +say "Length A − B = ", $C.length; diff --git a/Task/Set-of-real-numbers/Perl/set-of-real-numbers-1.pl b/Task/Set-of-real-numbers/Perl/set-of-real-numbers-1.pl new file mode 100644 index 0000000000..503d7b74c4 --- /dev/null +++ b/Task/Set-of-real-numbers/Perl/set-of-real-numbers-1.pl @@ -0,0 +1,179 @@ +use utf8; + +# numbers used as boundaries to real sets. Each has 3 components: +# the real value x; +# a +/-1 indicating if it's x + ϵ or x - ϵ +# a 0/1 indicating if it's the left border or right border +# e.g. "[1.5, ..." is written "1.5, -1, 0", while "..., 2)" is "2, -1, 1" +package BNum; + +use overload ( + '""' => \&_str, + '<=>' => \&_cmp, +); + +sub new { + my $self = shift; + bless [@_], ref $self || $self +} + +sub flip { + my @a = @{+shift}; + $a[2] = !$a[2]; + bless \@a +} + +my $brackets = qw/ [ ( ) ] /; +sub _str { + my $v = sprintf "%.2f", $_[0][0]; + $_[0][2] + ? $v . ($_[0][1] == 1 ? "]" : ")") + : ($_[0][1] == 1 ? "(" : "[" ) . $v; +} + +sub _cmp { + my ($a, $b, $swap) = @_; + + # if one of the argument is a normal number + if ($swap) { return -_ncmp($a, $b) } + if (!ref $b || !$b->isa(__PACKAGE__)) { return _ncmp($a, $b) } + + $a->[0] <=> $b->[0] || $a->[1] <=> $b->[1] +} + +sub _ncmp { + # $a is a BNum, $b is something comparable to a real + my ($a, $b) = @_; + $a->[0] <=> $b || $a->[1] <=> 0 +} + +package RealSet; +use Carp; +use overload ( + '""' => \&_str, + '|' => \&_or, + '&' => \&_and, + '~' => \&_neg, + '-' => \&_diff, + 'bool' => \¬_empty, # set is true if not empty +); + +my %pm = qw/ [ -1 ( 1 ) -1 ] 1 /; +sub range { + my ($cls, $a, $b, $spec) = @_; + $spec =~ /^( \[ | \( )( \) | \] )$/x or croak "bad spec $spec"; + + $a = BNum->new($a, $pm{$1}, 0); + $b = BNum->new($b, $pm{$2}, 1); + normalize($a < $b ? [$a, $b] : []) +} + +sub normalize { + my @a = @{+shift}; + # remove invalid or duplicate borders, such as "[2, 1]" or "3) [3" + # note that "(a" == "a]" and "a)" == "[a", but "a)" < "(a" and + # "[a" < "a]" + for (my $i = $#a; $i > 0; $i --) { + splice @a, $i - 1, 2 + if $a[$i] <= $a[$i - 1] + } + bless \@a +} + +sub not_empty { scalar @{ normalize shift } } + +sub _str { + my (@a, @s) = @{+shift} or return '()'; + join " ∪ ", map { shift(@a).", ".shift(@a) } 0 .. $#a/2 +} + +sub _or { + # we may have nested ranges now; let only outmost ones survive + my $d = 0; + normalize [ + map { $_->[2] ? --$d ? () : ($_) + : $d++ ? () : ($_) } + sort{ $a <=> $b } @{+shift}, @{+shift} + ]; +} + +sub _neg { + normalize [ + BNum->new('-inf', 1, 0), + map($_->flip, @{+shift}), + BNum->new('inf', -1, 1), + ] +} + +sub _and { + my $d = 0; + normalize [ + map { $_->[2] ? --$d ? ($_) : () + : $d++ ? ($_) : () } + sort{ $a <=> $b } @{+shift}, @{+shift} + ]; +} + +sub _diff { shift() & ~shift() } + +sub has { + my ($a, $b) = @_; + for (my $i = 0; $i < $#$a; $i += 2) { + return 1 if $a->[$i] <= $b && $b <= $a->[$i + 1] + } + return 0 +} + +sub len { + my ($a, $l) = shift; + for (my $i = 0; $i < $#$a; $i += 2) { + $l += $a->[$i+1][0] - $a->[$i][0] + } + return $l +} + +package main; +use List::Util 'reduce'; + +sub rng { RealSet->range(@_) } +my @sets = ( + rng(0, 1, '(]') | rng(0, 2, '[)'), + rng(0, 2, '[)') & rng(0, 2, '(]'), + rng(0, 3, '[)') - rng(0, 1, '()'), + rng(0, 3, '[)') - rng(0, 1, '[]'), +); + +for my $i (0 .. $#sets) { + print "Set $i = ", $sets[$i], ": "; + for (0 .. 2) { + print "has $_; " if $sets[$i]->has($_); + } + print "\n"; +} + +# optional task +print "\n####\n"; +sub brev { # show only head and tail if string too long + my $x = shift; + return $x if length $x < 60; + substr($x, 0, 30)." ... ".substr($x, -30, 30) +} + +# "|sin(x)| > 1/2" means (n + 1/6) pi < x < (n + 5/6) pi +my $x = reduce { $a | $b } + map(rng(sqrt($_ + 1./6), sqrt($_ + 5./6), '()'), 0 .. 101); +$x &= rng(0, 10, '()'); + +print "A\t", '= {x | 0 < x < 10 and |sin(π x²)| > 1/2 }', + "\n\t= ", brev($x), "\n"; + +my $y = reduce { $a | $b } + map { rng($_ + 1./6, $_ + 5./6, '()') } 0 .. 11; +$y &= rng(0, 10, '()'); + +print "B\t", '= {x | 0 < x < 10 and |sin(π x)| > 1/2 }', + "\n\t= ", brev($y), "\n"; + +my $z = $x - $y; +print "A - B\t= ", brev($z), "\n\tlength = ", $z->len, "\n"; +print $z ? "not empty\n" : "empty\n"; diff --git a/Task/Set-of-real-numbers/Perl/set-of-real-numbers-2.pl b/Task/Set-of-real-numbers/Perl/set-of-real-numbers-2.pl new file mode 100644 index 0000000000..f7faa2f665 --- /dev/null +++ b/Task/Set-of-real-numbers/Perl/set-of-real-numbers-2.pl @@ -0,0 +1,13 @@ +Set 0 = [0.00, 2.00): has 0; has 1; +Set 1 = (0.00, 2.00): has 1; +Set 2 = [0.00, 0.00] ∪ [1.00, 3.00): has 0; has 1; has 2; +Set 3 = (1.00, 3.00): has 2; + +#### +A = {x | 0 < x < 10 and |sin(π x²)| > 1/2 } + = (0.41, 0.91) ∪ (1.08, 1.35) ∪ ... ∪ (9.91, 9.94) ∪ (9.96, 9.99) +B = {x | 0 < x < 10 and |sin(π x)| > 1/2 } + = (0.17, 0.83) ∪ (1.17, 1.83) ∪ ... ∪ (8.17, 8.83) ∪ (9.17, 9.83) +A - B = [0.83, 0.91) ∪ (1.08, 1.17] ∪ ... ∪ (9.91, 9.94) ∪ (9.96, 9.99) + length = 2.07586484118467 + not empty diff --git a/Task/Set-of-real-numbers/Python/set-of-real-numbers.py b/Task/Set-of-real-numbers/Python/set-of-real-numbers.py new file mode 100644 index 0000000000..6516e079c6 --- /dev/null +++ b/Task/Set-of-real-numbers/Python/set-of-real-numbers.py @@ -0,0 +1,47 @@ +class Setr(): + def __init__(self, lo, hi, includelo=True, includehi=False): + self.eqn = "(%i<%sX<%s%i)" % (lo, + '=' if includelo else '', + '=' if includehi else '', + hi) + + def includes(self, X): + return eval(self.eqn, locals()) + + def union(self, b): + ans = Setr(0,0) + ans.eqn = "(%sor%s)" % (self.eqn, b.eqn) + return ans + + def intersection(self, b): + ans = Setr(0,0) + ans.eqn = "(%sand%s)" % (self.eqn, b.eqn) + return ans + + def difference(self, b): + ans = Setr(0,0) + ans.eqn = "(%sand not%s)" % (self.eqn, b.eqn) + return ans + + def union(self, b): + ans = Setr(0,0) + ans.eqn = "(%sor%s)" % (self.eqn, b.eqn) + return ans + + def __repr__(self): + return "Setr%s" % self.eqn + + +sets = [Setr(0,1, 0,1).union(Setr(0,2, 1,0)), + Setr(0,2, 1,0).intersection(Setr(1,2, 0,1)), + Setr(0,3, 1,0).difference(Setr(0,1, 0,0)), + Setr(0,3, 1,0).difference(Setr(0,1, 1,1)), + ] +settexts = '(0, 1] ∪ [0, 2);[0, 2) ∩ (1, 2];[0, 3) − (0, 1);[0, 3) − [0, 1]'.split(';') + +for s,t in zip(sets, settexts): + print("Set %s %s. %s" % (t, + ', '.join("%scludes %i" + % ('in' if s.includes(v) else 'ex', v) + for v in range(3)), + s.eqn)) diff --git a/Task/Set-of-real-numbers/REXX/set-of-real-numbers-1.rexx b/Task/Set-of-real-numbers/REXX/set-of-real-numbers-1.rexx new file mode 100644 index 0000000000..d5cc95dbc9 --- /dev/null +++ b/Task/Set-of-real-numbers/REXX/set-of-real-numbers-1.rexx @@ -0,0 +1,40 @@ +/*REXX pgm demonstrates a way to represent any set of real #s and usage.*/ +call set_query , , '(0,1] union [0,2)' +call set_query , , '[0,2) ∩ (1,3)' +call set_query , , '[0,3] - (0,1)' +call set_query , , '[0,3] - [0,1]' +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────SET_empty subroutine────────────────*/ +set_empty: parse arg _; nam=set_val(_,00); return @.3>@.4 +/*──────────────────────────────────SET_ISIN subroutine─────────────────*/ +set_isin: parse arg #,x; call set_val x +if \datatype(#,'N') then call set_bad "number isn't not numeric:" # + if (@.1=='(' & #<=@.2) |, + (@.1=='[' & #< @.2) |, + (@.4==')' & #>=@.3) |, + (@.4==']' & #> @.3) then return 0 +return 1 +/*──────────────────────────────────SET_query subroutine────────────────*/ +set_query: parse arg lv,hv,s1 oop s2 .; op=oop; upper op; cop= +if lv=='' then lv=0; if hv=='' then hv=2; if op=='' then cop=0 +if wordpos(op,'| or UNION') \==0 then cop='|' +if wordpos(op,'& ∩ AND INTER INTERSECTION') \==0 then cop='&' +if wordpos(op,'\ - DIF DIFF DIFFERENCE') \==0 then cop='\' +say + do i=lv to hv; b =set_isin(i,s1) + if cop\==0 then do + b2=set_isin(i,s2) + if cop=='&' then b=b & b2 + if cop=='|' then b=b | b2 + if cop=='\' then b=b & \b2 + end + express = s1 center(oop,max(5,length(oop))) s2 + say right(i,5) ' is in set' express": " word('no yes',b+1) + end /*i*/ +return +/*──────────────────────────────────SET_VAL subroutine──────────────────*/ +set_val: parse arg q; q=space(q,0); L=length(q); @.0=',' +@.4=right(q,1) +parse var q @.1 2 @.2 ',' @.3 (@.4) +if @.2>@.3 then parse var L . @.0 @.2 @.3 +return space(@.1 @.2 @.0 @.3 @.4,0) diff --git a/Task/Set-of-real-numbers/REXX/set-of-real-numbers-2.rexx b/Task/Set-of-real-numbers/REXX/set-of-real-numbers-2.rexx new file mode 100644 index 0000000000..ff59af2010 --- /dev/null +++ b/Task/Set-of-real-numbers/REXX/set-of-real-numbers-2.rexx @@ -0,0 +1,53 @@ +/*REXX pgm demonstrates a way to represent any set of real #s and usage.*/ +call set_query , , '(0,1] union [0,2)' +call set_query , , '[0,2) ∩ (1,3)' +call set_query , , '[0,3] - (0,1)' +call set_query , , '[0,3] - [0,1]' +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────SET_BAD subroutine─────────-────────*/ +set_bad: say; say '***error!*** bad format of SET_def: ('arg(1)")"; exit +/*──────────────────────────────────SET_empty subroutine────────────────*/ +set_empty: parse arg _; nam=set_val(_,00); return @.3>@.4 +/*──────────────────────────────────SET_ISIN subroutine─────────────────*/ +set_isin: parse arg #,x; call set_val x +if \datatype(#,'N') then call set_bad "number isn't not numeric:" # + if (@.1=='(' & #<=@.2) |, + (@.1=='[' & #< @.2) |, + (@.4==')' & #>=@.3) |, + (@.4==']' & #> @.3) then return 0 +return 1 +/*──────────────────────────────────SET_query subroutine────────────────*/ +set_query: parse arg lv,hv,s1 oop s2 .; op=oop; upper op; cop= +if lv=='' then lv=0; if hv=='' then hv=2; if op=='' then cop=0 +if wordpos(op,'| or UNION') \==0 then cop='|' +if wordpos(op,'& ∩ AND INTER INTERSECTION') \==0 then cop='&' +if wordpos(op,'\ - DIF DIFF DIFFERENCE') \==0 then cop='\' +if cop=='' then call set_bad 'invalid operation:' oop +say + do i=lv to hv; b =set_isin(i,s1) + if cop\==0 then do + b2=set_isin(i,s2) + if cop=='&' then b=b & b2 + if cop=='|' then b=b | b2 + if cop=='\' then b=b & \b2 + end + express = s1 center(oop,max(5,length(oop))) s2 + say right(i,5) ' is in set' express": " word('no yes',b+1) + end /*i*/ +return +/*──────────────────────────────────SET_VAL subroutine──────────────────*/ +set_val: parse arg q; q=space(q,0); L=length(q); @.0=',' +infinity = copies(9,digits()-1)'e'copies(9,digits()-1)'0' +if L<2 then call set_bad 'invalid expression' +@.4=right(q,1) +parse var q @.1 2 @.2 ',' @.3 (@.4) +if @.1\=='(' & @.1\=='[' then call set_bad 'left boundry' +if @.4\==')' & @.4\==']' then call set_bad 'right boundry' + + do j=2 to 3; u=@.j; upper u + if right(@.j,1)=='∞' | u="INFINITY" then @.j='-'infinity + if \datatype(@.j,'N') then call set_bad 'value not numeric:' @.j + end /*j*/ + +if @.2>@.3 then parse var L . @.0 @.2 @.3 +return space(@.1 @.2 @.0 @.3 @.4,0) diff --git a/Task/Set-of-real-numbers/Tcl/set-of-real-numbers-1.tcl b/Task/Set-of-real-numbers/Tcl/set-of-real-numbers-1.tcl new file mode 100644 index 0000000000..4794935b01 --- /dev/null +++ b/Task/Set-of-real-numbers/Tcl/set-of-real-numbers-1.tcl @@ -0,0 +1,146 @@ +package require Tcl 8.5 + +proc inRange {x range} { + lassign $range a aClosed b bClosed + expr {($aClosed ? $a<=$x : $a<$x) && ($bClosed ? $x<=$b : $x<$b)} +} +proc normalize {A} { + set A [lsort -index 0 -real [lsort -index 1 -integer -decreasing $A]] + for {set i 0} {$i < [llength $A]} {incr i} { + lassign [lindex $A $i] a aClosed b bClosed + if {$b < $a || ($a == $b && !($aClosed && $bClosed))} { + set A [lreplace $A $i $i] + incr i -1 + } + } + for {set i 0} {$i < [llength $A]} {incr i} { + for {set j [expr {$i+1}]} {$j < [llength $A]} {incr j} { + set R [lindex $A $i] + lassign [lindex $A $j] a aClosed b bClosed + if {[inRange $a $R]} { + if {![inRange $b $R]} { + lset A $i 2 $b + lset A $i 3 $bClosed + } + set A [lreplace $A $j $j] + incr j -1 + } + } + } + return $A +} + +proc realset {args} { + set RE {^\s*([\[(])\s*([-\d.e]+|-inf)\s*,\s*([-\d.e]+|inf)\s*([\])])\s*$} + set result {} + foreach s $args { + if { + [regexp $RE $s --> left a b right] && + [string is double $a] && [string is double $b] + } then { + lappend result [list \ + $a [expr {$left eq "\["}] $b [expr {$right eq "\]"}]] + } else { + error "bad range descriptor" + } + } + return $result +} +proc elementOf {x A} { + foreach range $A { + if {[inRange $x $range]} {return 1} + } + return 0 +} +proc union {A B} { + return [normalize [concat $A $B]] +} +proc intersection {A B} { + set B [normalize $B] + set C {} + foreach RA [normalize $A] { + lassign $RA Aa AaClosed Ab AbClosed + foreach RB $B { + lassign $RB Ba BaClosed Bb BbClosed + if {$Aa > $Bb || $Ba > $Ab} continue + set RC {} + lappend RC [expr {max($Aa,$Ba)}] + if {$Aa==$Ba} { + lappend RC [expr {min($AaClosed,$BaClosed)}] + } else { + lappend RC [expr {$Aa>$Ba ? $AaClosed : $BaClosed}] + } + lappend RC [expr {min($Ab,$Bb)}] + if {$Ab==$Bb} { + lappend RC [expr {min($AbClosed,$BbClosed)}] + } else { + lappend RC [expr {$Ab<$Bb ? $AbClosed : $BbClosed}] + } + lappend C $RC + } + } + return [normalize $C] +} +proc difference {A B} { + set C {} + set B [normalize $B] + foreach arange [normalize $A] { + if {[isEmpty [intersection [list $arange] $B]]} { + lappend C $arange + continue + } + lassign $arange Aa AaClosed Ab AbClosed + foreach brange $B { + lassign $brange Ba BaClosed Bb BbClosed + if {$Bb < $Aa || ($Bb==$Aa && !($AaClosed && $BbClosed))} { + continue + } + if {$Ab < $Ba || ($Ab==$Ba && !($BaClosed && $AbClosed))} { + lappend C [list $Aa $AaClosed $Ab $AbClosed] + unset arange + break + } + if {$Aa==$Bb} { + set AaClosed 0 + continue + } elseif {$Ab==$Ba} { + set AbClosed 0 + lappend C [list $Aa $AaClosed $Ab $AbClosed] + unset arange + continue + } + if {$Aa<$Ba} { + lappend C [list $Aa $AaClosed $Ba [expr {!$BaClosed}]] + if {$Ab>$Bb} { + set Aa $Bb + set AaClosed [expr {!$BbClosed}] + } else { + unset arange + break + } + } elseif {$Aa==$Ba} { + lappend C [list $Aa $AaClosed $Ba [expr {!$BaClosed}]] + set Aa $Bb + set AaClosed [expr {!$BbClosed}] + } else { + set Aa $Bb + set AaClosed [expr {!$BbClosed}] + } + } + if {[info exist arange]} { + lappend C [list $Aa $AaClosed $Ab $AbClosed] + } + } + return [normalize $C] +} +proc isEmpty A { + expr {![llength [normalize $A]]} +} +proc length A { + set len 0.0 + foreach range [normalize $A] { + lassign $range a _ b _ + set len [expr {$len + ($b-$a)}] + } + return $len +} diff --git a/Task/Set-of-real-numbers/Tcl/set-of-real-numbers-2.tcl b/Task/Set-of-real-numbers/Tcl/set-of-real-numbers-2.tcl new file mode 100644 index 0000000000..5e6a8c61f4 --- /dev/null +++ b/Task/Set-of-real-numbers/Tcl/set-of-real-numbers-2.tcl @@ -0,0 +1,19 @@ +foreach {str Set} { + {(0, 1] ∪ [0, 2)} { + union [realset {(0,1]}] [realset {[0,2)}] + } + {[0, 2) ∩ (1, 2]} { + intersection [realset {[0,2)}] [realset {(1,2]}] + } + {[0, 3) − (0, 1)} { + difference [realset {[0,3)}] [realset {(0,1)}] + } + {[0, 3) − [0, 1]} { + difference [realset {[0,3)}] [realset {[0,1]}] + } +} { + set Set [eval $Set] + foreach x {0 1 2} { + puts "$x : $str :\t[elementOf $x $Set]" + } +} diff --git a/Task/Set-of-real-numbers/Tcl/set-of-real-numbers-3.tcl b/Task/Set-of-real-numbers/Tcl/set-of-real-numbers-3.tcl new file mode 100644 index 0000000000..dfeb754093 --- /dev/null +++ b/Task/Set-of-real-numbers/Tcl/set-of-real-numbers-3.tcl @@ -0,0 +1,19 @@ +proc spi2 {from to} { + for {set i $from} {$i<=$to} {incr i} { + lappend result [list [expr {$i+1./6}] 0 [expr {$i+5./6}] 0] + } + return [intersection [list [list $from 0 $to 0]] $result] +} +proc applyfunc {var func} { + upvar 1 $var A + for {set i 0} {$i < [llength $A]} {incr i} { + lassign [lindex $A $i] a - b - + lset A $i 0 [$func $a] + lset A $i 2 [$func $b] + } +} +set A [spi2 0 100] +applyfunc A ::tcl::mathfunc::sqrt +set B [spi2 0 10] +set AB [difference $A $B] +puts "[llength $AB] contiguous subsets, total length [length $AB]" diff --git a/Task/Set/0DESCRIPTION b/Task/Set/0DESCRIPTION new file mode 100644 index 0000000000..12abd2cff7 --- /dev/null +++ b/Task/Set/0DESCRIPTION @@ -0,0 +1,16 @@ +{{data structure}} +A set is a collection of elements, without duplicates and without order. + +Show each of these set operations: + +* Set creation +* Test m ∈ S -- "m is an element in set S" +* A ∪ B -- ''union''; a set of all elements either in set A or in set B. +* A ∩ B -- ''intersection''; a set of all elements in ''both'' set A and set B. +* A ∖ B -- ''difference''; a set of all elements in set A, except those in set B. +* A ⊆ B -- ''subset''; true if every element in set A is also in set B. +* A = B -- ''equality''; true if every element of set A is in set B and vice-versa. + +As an option, show some other set operations. (If A ⊆ B, but A ≠ B, then A is called a true or proper subset of B, written A ⊂ B or A ⊊ B.) As another option, show how to modify a mutable set. + +One might implement a set using an [[associative array]] (with set elements as array keys and some dummy value as the values). One might also implement a set with a binary search tree, or with a hash table, or with an ordered array of binary bits (operated on with bitwise binary operators). The basic test, m ∈ S, is [[O]](n) with a sequential list of elements, O(''log'' n) with a balanced binary search tree, or (O(1) average-case, O(n) worst case) with a hash table. diff --git a/Task/Set/1META.yaml b/Task/Set/1META.yaml new file mode 100644 index 0000000000..9e130e8a7b --- /dev/null +++ b/Task/Set/1META.yaml @@ -0,0 +1,2 @@ +--- +note: Discrete math diff --git a/Task/Set/Ada/set.ada b/Task/Set/Ada/set.ada new file mode 100644 index 0000000000..a3ce3246a6 --- /dev/null +++ b/Task/Set/Ada/set.ada @@ -0,0 +1,54 @@ +with Ada.Text_IO, Ada.Containers.Ordered_Sets; + +procedure Set_Demo is + + package CS is new Ada.Containers.Ordered_Sets(Character); use CS; + package IO renames Ada.Text_IO; + + -- helper functions for string to something conversion, and vice versa + function To_Set(S: String) return Set is + Result: Set; + begin + for I in S'Range loop + begin + Result.Insert(S(I)); + -- raises Constraint_Error if S(I) is already in Result + exception + when Constraint_Error => null; + end; + end loop; + return Result; + end To_Set; + + function Image(S: Set) return String is + C: Character; + T: Set := S; + begin + if T.Is_Empty then + return ""; + else + C:= T.First_Element; + T.Delete_First; + return C & Image(T); + end if; + end Image; + + function Image(C: Ada.Containers.Count_Type) return String renames + Ada.Containers.Count_Type'Image; + + S1, S2: Set; +begin -- main program + loop + S1 := To_Set(Ada.Text_IO.Get_Line); + exit when S1 = To_Set("quit!"); + S2 := To_Set(Ada.Text_IO.Get_Line); + IO.Put_Line("Sets [" & Image(S1) & "], [" & Image(S2) & "] of size" + & Image(S1.Length) & " and" & Image(S2.Length) & "."); + IO.Put_Line("Intersection: [" & Image(Intersection(S1, S2)) & "],"); + IO.Put_Line("Union: [" & Image(Union(S1, S2)) & "],"); + IO.Put_Line("Difference: [" & Image(Difference(S1, S2)) & "],"); + IO.Put_Line("Symmetric Diff: [" & Image(S1 xor S2) & "],"); + IO.Put_Line("Subset: " & Boolean'Image(S1.Is_Subset(S2)) + & ", Equal: " & Boolean'Image(S1 = S2) & "."); + end loop; +end Set_Demo; diff --git a/Task/Set/BBC-BASIC/set.bbc b/Task/Set/BBC-BASIC/set.bbc new file mode 100644 index 0000000000..3d35844e9d --- /dev/null +++ b/Task/Set/BBC-BASIC/set.bbc @@ -0,0 +1,43 @@ + DIM list$(6) + list$() = "apple", "banana", "cherry", "date", "elderberry", "fig", "grape" + + setA% = %1010101 + PRINT "Set A: " FNlistset(list$(), setA%) + setB% = %0111110 + PRINT "Set B: " FNlistset(list$(), setB%) + elementM% = %0000010 + PRINT "Element M: " FNlistset(list$(), elementM%) ' + + IF elementM% AND setA% THEN + PRINT "M is an element of set A" + ELSE + PRINT "M is not an element of set A" + ENDIF + IF elementM% AND setB% THEN + PRINT "M is an element of set B" + ELSE + PRINT "M is not an element of set B" + ENDIF + + PRINT '"The union of A and B is " FNlistset(list$(), setA% OR setB%) + PRINT "The intersection of A and B is " FNlistset(list$(), setA% AND setB%) + PRINT "The difference of A and B is " FNlistset(list$(), setA% AND NOT setB%) + + IF (setA% AND setB%) = setA% THEN + PRINT '"Set A is a subset of set B" + ELSE + PRINT '"Set A is not a subset of set B" + ENDIF + IF setA% = setB% THEN + PRINT "Set A is equal to set B" + ELSE + PRINT "Set A is not equal to set B" + ENDIF + END + + DEF FNlistset(list$(), set%) + LOCAL i%, o$ + FOR i% = 0 TO 31 + IF set% AND 1 << i% o$ += list$(i%) + ", " + NEXT + = LEFT$(LEFT$(o$)) diff --git a/Task/Set/C++/set.cpp b/Task/Set/C++/set.cpp new file mode 100644 index 0000000000..b2a9f980b9 --- /dev/null +++ b/Task/Set/C++/set.cpp @@ -0,0 +1,79 @@ +#include +#include +#include +#include + +namespace set_display { +template +std::ostream& operator<<(std::ostream& os, const std::set& set) +{ + os << '['; + if (!set.empty()) { + std::copy(set.begin(), --set.end(), std::ostream_iterator(os, ", ")); + os << *--set.end(); + } + return os << ']'; +} +} + +template +bool contains(const std::set& set, const T& key) +{ + return set.count(key) != 0; +} + +template +std::set set_union(const std::set& a, const std::set& b) +{ + std::set result; + std::set_union(a.begin(), a.end(), b.begin(), b.end(), std::inserter(result, result.end())); + return result; +} + +template +std::set set_intersection(const std::set& a, const std::set& b) +{ + std::set result; + std::set_intersection(a.begin(), a.end(), b.begin(), b.end(), std::inserter(result, result.end())); + return result; +} + +template +std::set set_difference(const std::set& a, const std::set& b) +{ + std::set result; + std::set_difference(a.begin(), a.end(), b.begin(), b.end(), std::inserter(result, result.end())); + return result; +} + +template +bool is_subset(const std::set& set, const std::set& subset) +{ + return std::includes(set.begin(), set.end(), subset.begin(), subset.end()); +} + +int main() +{ + using namespace set_display; + std::set a{2, 5, 7, 5, 9, 2}; //C++11 initialization syntax + std::set b{1, 5, 9, 7, 4 }; + std::cout << "a = " << a << '\n'; + std::cout << "b = " << b << '\n'; + + int value1 = 8, value2 = 5; + std::cout << "Set a " << (contains(a, value1) ? "contains " : "does not contain ") << value1 << '\n'; + std::cout << "Set a " << (contains(a, value2) ? "contains " : "does not contain ") << value2 << '\n'; + + std::cout << "Union of a and b: " << set_union(a, b) << '\n'; + std::cout << "Intersection of a and b: " << set_intersection(a, b) << '\n'; + std::cout << "Difference of a and b: " << set_difference(a, b) << '\n'; + + std::set sub{5, 9}; + std::cout << "Set b " << (is_subset(a, b) ? "is" : "is not") << " a subset of a\n"; + std::cout << "Set " << sub << ' ' << (is_subset(a, sub) ? "is" : "is not") << " a subset of a\n"; + + std::set copy = a; + std::cout << "a " << (a == copy ? "equals " : "does not equal ") << copy << '\n'; + + return 0; +} diff --git a/Task/Set/C/set.c b/Task/Set/C/set.c new file mode 100644 index 0000000000..b5bf0d01b1 --- /dev/null +++ b/Task/Set/C/set.c @@ -0,0 +1,45 @@ +#include + +typedef unsigned int set_t; /* probably 32 bits; change according to need */ + +void show_set(set_t x, const char *name) +{ + int i; + printf("%s is:", name); + for (i = 0; (1U << i) <= x; i++) + if (x & (1U << i)) + printf(" %d", i); + putchar('\n'); +} + +int main(void) +{ + int i; + set_t a, b, c; + + a = 0; /* empty set */ + for (i = 0; i < 10; i += 3) /* add 0 3 6 9 to set a */ + a |= (1U << i); + show_set(a, "a"); + + for (i = 0; i < 5; i++) + printf("\t%d%s in set a\n", i, (a & (1U << i)) ? "":" not"); + + b = a; + b |= (1U << 5); b |= (1U << 10); /* b is a plus 5, 10 */ + b &= ~(1U << 0); /* sans 0 */ + show_set(b, "b"); + + show_set(a | b, "union(a, b)"); + show_set(c = a & b, "c = common(a, b)"); + show_set(a & ~b, "a - b"); /* diff, not arithmetic minus */ + show_set(b & ~a, "b - a"); + printf("b is%s a subset of a\n", !(b & ~a) ? "" : " not"); + printf("c is%s a subset of a\n", !(c & ~a) ? "" : " not"); + + printf("union(a, b) - common(a, b) %s union(a - b, b - a)\n", + ((a | b) & ~(a & b)) == ((a & ~b) | (b & ~a)) + ? "equals" : "does not equal"); + + return 0; +} diff --git a/Task/Set/Clojure/set.clj b/Task/Set/Clojure/set.clj new file mode 100644 index 0000000000..48a143fc72 --- /dev/null +++ b/Task/Set/Clojure/set.clj @@ -0,0 +1,15 @@ +(require 'clojure.set) + +; sets can be created using the set method or set literal syntax +(def a (set [1 2 3 4])) +(def b #{4 5 6 7}) + +(a 10) ; returns the element if it's contained in the set, otherwise nil + +(clojure.set/union a b) + +(clojure.set/intersection a b) + +(clojure.set/difference a b) + +(clojure.set/subset? a b) diff --git a/Task/Set/CoffeeScript/set.coffeescript b/Task/Set/CoffeeScript/set.coffeescript new file mode 100644 index 0000000000..d14663b823 --- /dev/null +++ b/Task/Set/CoffeeScript/set.coffeescript @@ -0,0 +1,85 @@ +# For ad-hoc set features, it sometimes makes sense to use hashes directly, +# rather than abstract to this level, but I'm showing a somewhat heavy +# solution to show off CoffeeScript class syntax. +class Set + constructor: (elems...) -> + @hash = {} + for elem in elems + @hash[elem] = true + + add: (elem) -> + @hash[elem] = true + + remove: (elem) -> + delete @hash[elem] + + has: (elem) -> + @hash[elem]? + + union: (set2) -> + set = new Set() + for elem of @hash + set.add elem + for elem in set2.to_array() + set.add elem + set + + intersection: (set2) -> + set = new Set() + for elem of @hash + set.add elem if set2.has elem + set + + minus: (set2) -> + set = new Set() + for elem of @hash + set.add elem if !set2.has elem + set + + is_subset_of: (set2) -> + for elem of @hash + return false if !set2.has elem + true + + equals: (set2) -> + this.is_subset_of(set2) and set2.is_subset_of this + + to_array: -> + (elem for elem of @hash) + + each: (f) -> + for elem of @hash + f(elem) + + to_string: -> + @to_array() + +run_tests = -> + set1 = new Set("apple", "banana") # creation + console.log set1.has "apple" # true (membership) + console.log set1.has "worms" # false (membership) + + set2 = new Set("banana", "carrots") + console.log set1.union(set2).to_string() # [ 'apple', 'banana', 'carrots' ] (union) + console.log set1.intersection(set2).to_string() # [ 'banana' ] (intersection) + console.log set1.minus(set2).to_string() # [ 'apple' ] (difference) + + set3 = new Set("apple") + console.log set3.is_subset_of set1 # true + console.log set3.is_subset_of set2 # false + + set4 = new Set("apple", "banana") + console.log set4.equals set1 # true + console.log set4.equals set2 # false + + set5 = new Set("foo") + set5.add "bar" # add + console.log set5.to_string() # [ 'foo', 'bar' ] + set5.remove "bar" # remove + console.log set5.to_string() # [ 'foo' ] + + # iteration, prints apple then banana (order not guaranteed) + set1.each (elem) -> + console.log elem + +run_tests() diff --git a/Task/Set/Common-Lisp/set.lisp b/Task/Set/Common-Lisp/set.lisp new file mode 100644 index 0000000000..23d8ca0b82 --- /dev/null +++ b/Task/Set/Common-Lisp/set.lisp @@ -0,0 +1,22 @@ +(setf a '(1 2 3 4)) +(setf b '(2 3 4 5)) + +(format t "sets: ~a ~a~%" a b) + +;;; element +(loop for x from 1 to 6 do + (format t (if (member x a) + "~d ∈ A~%" + "~d ∉ A~%") x)) + +(format t "A ∪ B: ~a~%" (union a b)) +(format t "A ∩ B: ~a~%" (intersection a b)) +(format t "A \\ B: ~a~%" (set-difference a b)) +(format t (if (subsetp a b) + "~a ⊆ ~a~%" + "~a ⊈ ~a~%") a b) + +(format t (if (and (subsetp a b) + (subsetp b a)) + "~a = ~a~%" + "~a ≠ ~a~%") a b) diff --git a/Task/Set/D/set.d b/Task/Set/D/set.d new file mode 100644 index 0000000000..0c963530a7 --- /dev/null +++ b/Task/Set/D/set.d @@ -0,0 +1,18 @@ +import std.stdio, std.algorithm; + +void main() { + auto set1 = [1, 2, 3, 4, 5, 6]; + auto set2 = [2, 5, 6, 3, 4, 8].sort; // [2, 3, 4, 5, 6, 8] + auto set3 = [1, 2, 5]; + + assert(equal(setUnion(set1, set2), [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 8])); + assert(equal(setIntersection(set1, set2), [2, 3, 4, 5, 6])); + assert(equal(setDifference(set1, set2), [1])); + assert(equal(setSymmetricDifference(set1, set2), [1, 8])); + assert(equal(setDifference(set3, set1), new int[](0))); // subset + assert(set1 != set2); + + auto set4 = [ [ 1, 4, 7, 8 ], [ 1, 7 ], [ 1, 7, 8], [ 4 ], [ 7 ], ]; + auto set5 = [ 1, 1, 1, 4, 4, 7, 7, 7, 7, 8, 8 ]; + assert(equal(nWayUnion(set4), set5)); +} diff --git a/Task/Set/Factor/set.factor b/Task/Set/Factor/set.factor new file mode 100644 index 0000000000..9543494d62 --- /dev/null +++ b/Task/Set/Factor/set.factor @@ -0,0 +1,15 @@ +( scratchpad ) USE: sets +( scratchpad ) HS{ 2 5 4 3 } HS{ 5 6 7 } union . +HS{ 2 3 4 5 6 7 } +( scratchpad ) HS{ 2 5 4 3 } HS{ 5 6 7 } intersect . +HS{ 5 } +( scratchpad ) HS{ 2 5 4 3 } HS{ 5 6 7 } diff . +HS{ 2 3 4 } +( scratchpad ) HS{ 2 5 4 3 } HS{ 5 6 7 } subset? . +f +( scratchpad ) HS{ 5 6 } HS{ 5 6 7 } subset? . +t +( scratchpad ) HS{ 5 6 } HS{ 5 6 7 } set= . +f +( scratchpad ) HS{ 6 5 7 } HS{ 5 6 7 } set= . +t diff --git a/Task/Set/Go/set.go b/Task/Set/Go/set.go new file mode 100644 index 0000000000..5afb85b476 --- /dev/null +++ b/Task/Set/Go/set.go @@ -0,0 +1,124 @@ +package main + +import "fmt" + +type set map[int]bool + +func main() { + // task: set creation + s0 := make(set) // create empty set + s1 := set{3: true} // create set with one element + s2 := set{3: true, 1: true} // create set with two elements + + // option: another way to create a set + s3 := newSet([]int{3, 1, 4, 1, 5, 9}) + + // option: output! + fmt.Println("s0:", s0) + fmt.Println("s1:", s1) + fmt.Println("s2:", s2) + fmt.Println("s3:", s3) + + // task: element predicate + fmt.Printf("%v ∈ s0: %t\n", 3, s0.hasElement(3)) + fmt.Printf("%v ∈ s3: %t\n", 3, s3.hasElement(3)) + fmt.Printf("%v ∈ s3: %t\n", 2, s3.hasElement(2)) + + // task: union + b := set{4: true, 2: true} + fmt.Printf("s3 ∪ %v: %v\n", b, union(s3, b)) + + // task: intersection + fmt.Printf("s3 ∩ %v: %v\n", b, intersection(s3, b)) + + // task: difference + fmt.Printf("s3 \\ %v: %v\n", b, difference(s3, b)) + + // task: subset predicate + fmt.Printf("%v ⊆ s3: %t\n", b, subset(b, s3)) + fmt.Printf("%v ⊆ s3: %t\n", s2, subset(s2, s3)) + fmt.Printf("%v ⊆ s3: %t\n", s0, subset(s0, s3)) + + // task: equality + s2Same := set{1: true, 3: true} + fmt.Printf("%v = s2: %t\n", s2Same, equal(s2Same, s2)) + + // option: proper subset + fmt.Printf("%v ⊂ s2: %t\n", s2Same, properSubset(s2Same, s2)) + fmt.Printf("%v ⊂ s3: %t\n", s2Same, properSubset(s2Same, s3)) + + // option: delete. it's built in. + delete(s3, 3) + fmt.Println("s3, 3 deleted:", s3) +} + +func newSet(ms []int) set { + s := make(set) + for _, m := range ms { + s[m] = true + } + return s +} + +func (s set) String() string { + if len(s) == 0 { + return "∅" + } + r := "{" + for e := range s { + r = fmt.Sprintf("%s%v, ", r, e) + } + return r[:len(r)-2] + "}" +} + +func (s set) hasElement(m int) bool { + return s[m] +} + +func union(a, b set) set { + s := make(set) + for e := range a { + s[e] = true + } + for e := range b { + s[e] = true + } + return s +} + +func intersection(a, b set) set { + s := make(set) + for e := range a { + if b[e] { + s[e] = true + } + } + return s +} + +func difference(a, b set) set { + s := make(set) + for e := range a { + if !b[e] { + s[e] = true + } + } + return s +} + +func subset(a, b set) bool { + for e := range a { + if !b[e] { + return false + } + } + return true +} + +func equal(a, b set) bool { + return len(a) == len(b) && subset(a, b) +} + +func properSubset(a, b set) bool { + return len(a) < len(b) && subset(a, b) +} diff --git a/Task/Set/Groovy/set.groovy b/Task/Set/Groovy/set.groovy new file mode 100644 index 0000000000..b8bb8b63c8 --- /dev/null +++ b/Task/Set/Groovy/set.groovy @@ -0,0 +1,19 @@ +def s1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] as Set +def m1 = 6 +def m2 = 7 +def s2 = [0, 2, 4, 6, 8] as Set +assert m1 in s1 : 'member' +assert ! (m2 in s2) : 'not a member' +def su = s1 + s2 +assert su == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] as Set : 'union' +def si = s1.intersect(s2) +assert si == [8, 6, 4, 2] as Set : 'intersection' +def sd = s1 - s2 +assert sd == [1, 3, 5, 7, 9, 10] as Set : 'difference' +assert s1.containsAll(si) : 'subset' +assert ! s1.containsAll(s2) : 'not a subset' +assert (si + sd) == s1 : 'equality' +assert (s2 + sd) != s1 : 'inequality' +assert s1 != su && su.containsAll(s1) : 'proper subset' +s1 << 0 +assert s1 == su : 'added element 0 to s1' diff --git a/Task/Set/Haskell/set-1.hs b/Task/Set/Haskell/set-1.hs new file mode 100644 index 0000000000..b9063499f6 --- /dev/null +++ b/Task/Set/Haskell/set-1.hs @@ -0,0 +1,35 @@ +Prelude> import Data.Set +Prelude Data.Set> empty :: Set Integer -- Empty set +fromList [] +Prelude Data.Set> let s1 = fromList [1,2,3,4,3] -- Convert list into set +Prelude Data.Set> s1 +fromList [1,2,3,4] +Prelude Data.Set> let s2 = fromList [3,4,5,6] +Prelude Data.Set> union s1 s2 -- Union +fromList [1,2,3,4,5,6] +Prelude Data.Set> intersection s1 s2 -- Intersection +fromList [3,4] +Prelude Data.Set> s1 \\ s2 -- Difference +fromList [1,2] +Prelude Data.Set> s1 `isSubsetOf` s1 -- Subset +True +Prelude Data.Set> fromList [3,1] `isSubsetOf` s1 +True +Prelude Data.Set> s1 `isProperSubsetOf` s1 -- Proper subset +False +Prelude Data.Set> fromList [3,1] `isProperSubsetOf` s1 +True +Prelude Data.Set> fromList [3,2,4,1] == s1 -- Equality +True +Prelude Data.Set> s1 == s2 +False +Prelude Data.Set> 2 `member` s1 -- Membership +True +Prelude Data.Set> 10 `notMember` s1 +True +Prelude Data.Set> size s1 -- Cardinality +4 +Prelude Data.Set> insert 99 s1 -- Create a new set by inserting +fromList [1,2,3,4,99] +Prelude Data.Set> delete 3 s1 -- Create a new set by deleting +fromList [1,2,4] diff --git a/Task/Set/Haskell/set-2.hs b/Task/Set/Haskell/set-2.hs new file mode 100644 index 0000000000..cc79257cf6 --- /dev/null +++ b/Task/Set/Haskell/set-2.hs @@ -0,0 +1,15 @@ +Prelude> import Data.List +Prelude Data.List> let s3 = nub [1,2,3,4,3] -- Remove duplicates from list +Prelude Data.List> s3 +[1,2,3,4] +Prelude Data.List> let s4 = [3,4,5,6] +Prelude Data.List> union s3 s4 -- Union +[1,2,3,4,5,6] +Prelude Data.List> intersect s3 s4 -- Intersection +[3,4] +Prelude Data.List> s3 \\ s4 -- Difference +[1,2] +Prelude Data.List> 42 : s3 -- Return new list with element inserted at the beginning +[42,1,2,3,4] +Prelude Data.List> delete 3 s3 -- Return new list with first occurrence of element removed +[1,2,4] diff --git a/Task/Set/Icon/set-1.icon b/Task/Set/Icon/set-1.icon new file mode 100644 index 0000000000..0a372aadb9 --- /dev/null +++ b/Task/Set/Icon/set-1.icon @@ -0,0 +1,61 @@ +procedure display_set (s) + writes ("[") + every writes (!s || " ") + write ("]") +end + +# fail unless s1 and s2 contain the same elements +procedure set_equals (s1, s2) + return subset(s1, s2) & subset(s2, s1) +end + +# fail if every element in s2 is not contained in s1 +procedure subset (s1, s2) + every (a := !s2) do { + if not(member(s1,a)) then fail + } + return s2 +end + +procedure main () + a := set(1, 1, 2, 3, 4) + b := set(2, 3, 5) + writes ("a: ") + display_set (a) + writes ("b: ") + display_set (b) + # basic set operations + writes ("Intersection: ") + display_set (a ** b) + writes ("Union: ") + display_set (a ++ b) + writes ("Difference: ") + display_set (a -- b) + # membership + if member(a, 2) then + write ("2 is a member of a") + else + write ("2 is not a member of a") + if member(a, 5) then + write ("5 is a member of a") + else + write ("5 is not a member of a") + # equality + if set_equals(a, set(1,2,3,4,4)) then + write ("a equals set(1,2,3,4,4)") + else + write ("a does not equal set(1,2,3,4,4)") + if set_equals(a, b) then + write ("a equals b") + else + write ("a does not equal b") + # subset + if subset(a, set(1,2)) then + write ("(1,2) is included in a") + else + write ("(1,2) is not included in a") + if subset(a, set(1,2,5)) then + write ("(1,2,5) is included in a") + else + write ("(1,2,5) is not included in a") +end diff --git a/Task/Set/Icon/set-2.icon b/Task/Set/Icon/set-2.icon new file mode 100644 index 0000000000..d0386808f8 --- /dev/null +++ b/Task/Set/Icon/set-2.icon @@ -0,0 +1,39 @@ +link sets + +procedure main () + a := set(1, 1, 2, 3, 4) + b := set(2, 3, 5) + write ("a: ", simage(a)) + write ("b: ", simage(b)) + # basic set operations + write ("Intersection: ", simage (a**b)) + write ("Union: ", simage (a++b)) + write ("Difference: ", simage (a--b)) + # membership + if member(a, 2) then + write ("2 is a member of a") + else + write ("2 is not a member of a") + if member(a, 5) then + write ("5 is a member of a") + else + write ("5 is not a member of a") + # equality + if seteq(a, set(1,2,3,4,4)) then + write ("a equals set(1,2,3,4,4)") + else + write ("a does not equal set(1,2,3,4,4)") + if seteq(a, b) then + write ("a equals b") + else + write ("a does not equal b") + # check subset + if setlt(set(1,2), a) then + write ("(1,2) is included in a") + else + write ("(1,2) is not included in a") + if setlt(a, set(1,2,5), a) then + write ("(1,2,5) is included in a") + else + write ("(1,2,5) is not included in a") +end diff --git a/Task/Set/J/set-1.j b/Task/Set/J/set-1.j new file mode 100644 index 0000000000..2dbfb3e4e3 --- /dev/null +++ b/Task/Set/J/set-1.j @@ -0,0 +1,5 @@ +union=: ~.@, +intersection=: [ -. -. +difference=: -. +subset=: *./@e. +equality=: -:&(/:~) diff --git a/Task/Set/J/set-2.j b/Task/Set/J/set-2.j new file mode 100644 index 0000000000..94837b65b5 --- /dev/null +++ b/Task/Set/J/set-2.j @@ -0,0 +1,12 @@ + 2 4 6 8 ~.@, 2 3 5 7 +2 4 6 8 3 5 7 + 2 4 6 8 ([ -. -.) 2 3 5 7 +2 + 2 4 6 8 -. 2 3 5 7 +4 6 8 + 2 4 6 8 *./@e. 2 3 5 7 +0 + '' *./@e. 2 3 5 7 +1 + 2 4 6 8 3 5 7 -:&(/:~) 8 7 6 5 4 3 2 +1 diff --git a/Task/Set/J/set-3.j b/Task/Set/J/set-3.j new file mode 100644 index 0000000000..4342b81eb4 --- /dev/null +++ b/Task/Set/J/set-3.j @@ -0,0 +1,12 @@ + 2 4 6 8 union 2 3 5 7 +2 4 6 8 3 5 7 + 2 4 6 8 intersection 2 3 5 7 +2 + 2 4 6 8 difference 2 3 5 7 +4 6 8 + 2 4 6 8 subset 2 3 5 7 +0 + '' subset 2 3 5 7 +1 + 2 4 6 8 3 5 7 equality 8 7 6 5 4 3 2 +1 diff --git a/Task/Set/J/set-4.j b/Task/Set/J/set-4.j new file mode 100644 index 0000000000..003746e134 --- /dev/null +++ b/Task/Set/J/set-4.j @@ -0,0 +1 @@ +properSubset=: subset *. 1 - equality diff --git a/Task/Set/Java/set.java b/Task/Set/Java/set.java new file mode 100644 index 0000000000..f7f869da5a --- /dev/null +++ b/Task/Set/Java/set.java @@ -0,0 +1,62 @@ +import java.util.Arrays; +import java.util.Collections; +import java.util.Set; +import java.util.TreeSet; + +public class Sets { + public static void main(String[] args){ + Set a = new TreeSet<>(); + //TreeSet sorts on natural ordering (or an optional comparator) + //other options: HashSet (hashcode) + // LinkedHashSet (insertion order) + // EnumSet (optimized for enum values) + //others at: http://download.oracle.com/javase/7/docs/api/java/util/Set.html + Set b = new TreeSet<>(); + Set c = new TreeSet<>(); + Set d = new TreeSet<>(); + + a.addAll(Arrays.asList(1, 2, 3, 4, 5)); + b.addAll(Arrays.asList(2, 3, 4, 5, 6, 8)); + c.addAll(Arrays.asList(2, 3, 4)); + d.addAll(Arrays.asList(2, 3, 4)); + System.out.println("a: " + a); + System.out.println("b: " + b); + System.out.println("c: " + c); + System.out.println("d: " + d); + + System.out.println("2 in a: " + a.contains(2)); + System.out.println("6 in a: " + a.contains(6)); + + Set ab = new TreeSet<>(); + ab.addAll(a); + ab.addAll(b); + System.out.println("a union b: " + ab); + + Set a_b = new TreeSet<>(); + a_b.addAll(a); + a_b.removeAll(b); + System.out.println("a - b: " + a_b); + + System.out.println("c subset of a: " + a.containsAll(c)); + //use a.conatins() for single elements + + System.out.println("c = d: " + c.equals(d)); + System.out.println("d = c: " + d.equals(c)); + + Set aib = new TreeSet<>(); + aib.addAll(a); + aib.retainAll(b); + System.out.println("a intersect b: " + aib); + + System.out.println("add 7 to a: " + a.add(7)); + System.out.println("add 2 to a again: " + a.add(2)); + + //other noteworthy things related to sets: + Set empty = Collections.EMPTY_SET; //immutable empty set + //empty.add(2); would fail + empty.isEmpty(); //test if a set is empty + empty.size(); + Collections.disjoint(a, b); //returns true if the sets have no common elems (based on their .equals() methods) + Collections.unmodifiableSet(a); //returns an immutable copy of a + } +} diff --git a/Task/Set/Liberty-BASIC/set.liberty b/Task/Set/Liberty-BASIC/set.liberty new file mode 100644 index 0000000000..33762b53ea --- /dev/null +++ b/Task/Set/Liberty-BASIC/set.liberty @@ -0,0 +1,148 @@ +A$ ="red hot chili peppers rule OK" +B$ ="lady in red" + +print " New set, in space-separated form. Extra spaces and duplicates will be removed. " +input newSet$ + newSet$ =trim$( newSet$) + newSet$ =stripBigSpaces$( newSet$) + newSet$ =removeDupes$( newSet$) +print " Set stored as the string '"; newSet$; "'" + +print +print " 'red' is an element of '"; A$; "' is "; isAnElementOf$( "red", A$) +print " 'blue' is an element of '"; A$; "' is "; isAnElementOf$( "blue", A$) +print " 'red' is an element of '"; B$; "' is "; isAnElementOf$( "red", B$) +print +print " Union of '"; A$; "' & '"; B$; "' is '"; unionOf$( A$, B$); "'." +print +print " Intersection of '"; A$; "' & '"; B$; "' is '"; intersectionOf$( A$, B$); "'." +print +print " Difference of '"; A$; "' & '"; B$; "' is '"; differenceOf$( A$, B$); "'." +print +print " '"; A$; "' equals '"; A$; "' is "; equalSets$( A$, A$) +print " '"; A$; "' equals '"; B$; "' is "; equalSets$( A$, B$) +print +print " '"; A$; "' is a subset of '"; B$; "' is "; isSubsetOf$( A$, B$) +print " 'red peppers' is a subset of 'red hot chili peppers rule OK' is "; isSubsetOf$( "red peppers", "red hot chili peppers rule OK") + +end + +function removeDupes$( a$) + numElements =countElements( a$) + redim elArray$( numElements) ' ie 4 elements are array entries 1 to 4 and 0 is spare ="" + for m =0 to numElements + el$ =word$( a$, m, " ") + elArray$( m) =el$ + next m + sort elArray$(), 0, numElements + b$ ="" + penultimate$ ="999" + for jk =0 to numElements ' do not use "" ( nuls) or elementsalready seen + if elArray$( jk) ="" then [on] + if elArray$( jk) <>penultimate$ then b$ =b$ +elArray$( jk) +" ": penultimate$ =elArray$( jk) + [on] + next jk + b$ =trim$( b$) + removeDupes$ =b$ +end function + +function stripBigSpaces$( a$) ' copy byte by byte, but id=f a space had a preceding space, ignore it. + lenA =len( a$) + penul$ ="" + for i =1 to len( a$) + c$ =mid$( a$, i, 1) + if c$ <>" " then + if penul$ <>" " then + b$ =b$ +c$ + else + b$ =b$ +" " +c$ + end if + end if + penul$ =c$ + next i + stripBigSpaces$ =b$ +end function + +function countElements( a$) ' count elements repr'd by space-separated words in string rep'n. + if isNul$( a$) ="True" then countElements =0: exit function + i =0 + do + el$ =word$( a$, i +1, " ") + i =i +1 + loop until el$ ="" + countElements =i -1 +end function + +function isNul$( a$) ' a nul set implies its string rep'n is length zero. + if a$ ="" then isNul$ ="True" else isNul$ ="False" +end function + +function isAnElementOf$( a$, b$) ' check element a$ exists in set b$. + isAnElementOf$ ="False" + i =0 + do + el$ =word$( b$, i +1, " ") + if a$ =el$ then isAnElementOf$ ="True" + i =i +1 + loop until el$ ="" +end function + +function unionOf$( a$, b$) + i =1 + o$ =a$ + do + w$ =word$( b$, i, " ") + if w$ ="" then exit do + if isAnElementOf$( w$, a$) ="False" then o$ =o$ +" " +w$ + i =i +1 + loop until w$ ="" + unionOf$ =o$ +end function + +function intersectionOf$( a$, b$) + i =1 + o$ ="" + do + el$ =word$( a$, i, " ") + if el$ ="" then exit do + if ( isAnElementOf$( el$, b$) ="True") and ( o$ ="") then o$ =el$ + if ( isAnElementOf$( el$, b$) ="True") and ( o$ <>el$) then o$ =o$ +" " +el$ + i =i +1 + loop until el$ ="" + intersectionOf$ =o$ +end function + +function equalSets$( a$, b$) + if len( a$) <>len( b$) then equalSets$ ="False": exit function + i =1 + do + el$ =word$( a$, i, " ") + if isAnElementOf$( el$, b$) ="False" then equalSets$ ="False": exit function + i =i +1 + loop until w$ ="" + equalSets$ ="True" +end function + +function differenceOf$( a$, b$) + i =1 + o$ ="" + do + el$ =word$( a$, i, " ") + if el$ ="" then exit do + if ( isAnElementOf$( el$, b$) ="False") and ( o$ ="") then o$ =el$ + if ( isAnElementOf$( el$, b$) ="False") and ( o$ <>el$) then o$ =o$ +" " +el$ + i =i +1 + loop until el$ ="" + differenceOf$ =o$ +end function + +function isSubsetOf$( a$, b$) + isSubsetOf$ ="True" + i =1 + do + el$ =word$( a$, i, " ") + if el$ ="" then exit do + if ( isAnElementOf$( el$, b$) ="False") then isSubsetOf$ ="False": exit function + i =i +1 + loop until el$ ="" +end function diff --git a/Task/Set/MATLAB/set.m b/Task/Set/MATLAB/set.m new file mode 100644 index 0000000000..c48f89c136 --- /dev/null +++ b/Task/Set/MATLAB/set.m @@ -0,0 +1,16 @@ + % Set creation + s = [1, 2, 4]; % numeric values + t = {'a','bb','ccc'}; % cell array of strings + u = unique([1,2,3,3,2,3,2,4,1]); % set consists only of unique elements + % Test m ∈ S -- "m is an element in set S" + ismember(m, S) + % A ∪ B -- union; a set of all elements either in set A or in set B. + union(A, B) + % A ∩ B -- intersection; a set of all elements in both set A and set B. + intersect(A, B) + % A ∖ B -- difference; a set of all elements in set A, except those in set B. + setdiff(A, B) + % A ⊆ B -- subset; true if every element in set A is also in set B. + all(ismember(A, B)) + % A = B -- equality; true if every element of set A is in set B and vice-versa. + isempty(setxor(A, B)) diff --git a/Task/Set/Maple/set.maple b/Task/Set/Maple/set.maple new file mode 100644 index 0000000000..f6c538fec1 --- /dev/null +++ b/Task/Set/Maple/set.maple @@ -0,0 +1,41 @@ +> S := { 2, 3, 5, 7, 11, Pi, "foo", { 2/3, 3/4, 4/5 } }; + S := {2, 3, 5, 7, 11, "foo", Pi, {2/3, 3/4, 4/5}} + +> type( S, set ); + true + +> Pi in S; + Pi in {2, 3, 5, 7, 11, "foo", Pi, {2/3, 3/4, 4/5}} + +> if Pi in S then print( yes ) else print( no ) end: + yes + +> member( Pi, S ); + true + +> if 4 in S then print( yes ) else print( no ) end: + no + +> evalb( { 2/3, 3/4, 4/5 } in S ); + true + +> { a, b, c } union { 1, 2, 3 }; + {1, 2, 3, a, b, c} + +> { a, b, c } intersect { b, c, d }; + {b, c} + +> { a, b, c } minus { b, c, d }; + {a} + +> { a, b } subset { a, b, c }; + true + +> { a, d } subset { a, b, c }; + false + +> evalb( { 1, 2, 3 } = { 1, 2, 3 } ); + true + +> evalb( { 1, 2, 3 } = { 1, 2, 4 } ); + false diff --git a/Task/Set/Mathematica/set.math b/Task/Set/Mathematica/set.math new file mode 100644 index 0000000000..1fcf6e4212 --- /dev/null +++ b/Task/Set/Mathematica/set.math @@ -0,0 +1,8 @@ +set1 = {"a", "b", "c", "d", "e"}; set2 = {"a", "b", "c", "d", "e", "f", "g"}; +MemberQ[set1, "a"] +Union[set1 , set2] +Intersection[set1 , set2] +Complement[set2, set1](*Set Difference*) +MemberQ[Subsets[set2], set1](*Subset*) +set1 == set2(*Equality*) +set1 == set1(*Equality*) diff --git a/Task/Set/Maxima/set.maxima b/Task/Set/Maxima/set.maxima new file mode 100644 index 0000000000..d91357e5bb --- /dev/null +++ b/Task/Set/Maxima/set.maxima @@ -0,0 +1,78 @@ +/* illustrating some functions on sets; names are self-explanatory */ + +a: {1, 2, 3, 4}; +{1, 2, 3, 4} + +b: {2, 4, 6, 8}; +{2, 4, 6, 8} + +intersection(a, b); +{2, 4} + +union(a, b); +{1, 2, 3, 4, 6, 8} + +powerset(a); +{{}, {1}, {1, 2}, {1, 2, 3}, {1, 2, 3, 4}, {1, 2, 4}, {1, 3}, {1, 3, 4}, {1, 4}, {2}, {2, 3}, {2, 3, 4}, {2, 4}, {3}, {3, 4}, {4}} + +set_partitions(a); +{{{1}, {2}, {3}, {4}}, {{1}, {2}, {3, 4}}, {{1}, {2, 3}, {4}}, {{1}, {2, 3, 4}}, {{1}, {2, 4}, {3}}, {{1, 2}, {3}, {4}}, +{{1, 2}, {3, 4}}, {{1, 2, 3}, {4}}, {{1, 2, 3, 4}}, {{1, 2, 4}, {3}}, {{1, 3}, {2}, {4}}, {{1, 3}, {2, 4}}, {{1, 3, 4}, {2}}, +{{1, 4}, {2}, {3}}, {{1, 4}, {2, 3}}} + +setdifference(a, b); +{1, 3} + +emptyp(a); +false + +elementp(2, a); +true + +cardinality(a); +4 + +cartesian_product(a, b); +{[1, 2], [1, 4], [1, 6], [1, 8], [2, 2], [2, 4], [2, 6], [2, 8], [3, 2], [3, 4], [3, 6], [3, 8], [4, 2], [4, 4], [4, 6], [4, 8]} + +subsetp(a, b); +false + +symmdifference(a, b); +{1, 3, 6, 8} + +partition_set(union(a, b), evenp); +[{1, 3}, {2, 4, 6, 8}] + +c: setify(makelist(fib(n), n, 1, 20)); +{1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765} + +equiv_classes(c, lambda([m, n], mod(m - n, 3) = 0)); +{{1, 13, 34, 55, 610, 1597, 2584}, {2, 5, 8, 89, 233, 377, 4181}, {3, 21, 144, 987, 6765}} + +disjointp(a, b); +false + +adjoin(7, a); +{1, 2, 3, 4, 7} + +a; +{1, 2, 3, 4} + +disjoin(1, a); +{2, 3, 4} + +a; +{1, 2, 3, 4} + +subset(c, primep); +{2, 3, 5, 13, 89, 233, 1597} + +permutations(a); +{[1, 2, 3, 4], [1, 2, 4, 3], [1, 3, 2, 4], [1, 3, 4, 2], [1, 4, 2, 3], [1, 4, 3, 2], + [2, 1, 3, 4], [2, 1, 4, 3], [2, 3, 1, 4], [2, 3, 4, 1], [2, 4, 1, 3], [2, 4, 3, 1], + [3, 1, 2, 4], [3, 1, 4, 2], [3, 2, 1, 4], [3, 2, 4, 1], [3, 4, 1, 2], [3, 4, 2, 1], + [4, 1, 2, 3], [4, 1, 3, 2], [4, 2, 1, 3], [4, 2, 3, 1], [4, 3, 1, 2], [4, 3, 2, 1]} + +setequalp(a, b); +false diff --git a/Task/Set/OCaml/set.ocaml b/Task/Set/OCaml/set.ocaml new file mode 100644 index 0000000000..73811eb1c5 --- /dev/null +++ b/Task/Set/OCaml/set.ocaml @@ -0,0 +1,68 @@ +# module IntSet = Set.Make(struct type t = int let compare = compare end);; (* Create a module for our type of set *) +module IntSet : + sig + type elt = int + type t + val empty : t + val is_empty : t -> bool + val mem : elt -> t -> bool + val add : elt -> t -> t + val singleton : elt -> t + val remove : elt -> t -> t + val union : t -> t -> t + val inter : t -> t -> t + val diff : t -> t -> t + val compare : t -> t -> int + val equal : t -> t -> bool + val subset : t -> t -> bool + val iter : (elt -> unit) -> t -> unit + val fold : (elt -> 'a -> 'a) -> t -> 'a -> 'a + val for_all : (elt -> bool) -> t -> bool + val exists : (elt -> bool) -> t -> bool + val filter : (elt -> bool) -> t -> t + val partition : (elt -> bool) -> t -> t * t + val cardinal : t -> int + val elements : t -> elt list + val min_elt : t -> elt + val max_elt : t -> elt + val choose : t -> elt + val split : elt -> t -> t * bool * t + end +# IntSet.empty;; (* Empty set. A set is an abstract type that will not display in the interpreter *) +- : IntSet.t = +# IntSet.elements (IntSet.empty);; (* Get the previous set into a list *) +- : IntSet.elt list = [] +# let from_list lst = List.fold_right IntSet.add lst IntSet.empty;; (* Convenience function for constructing a set from a list *) +val from_list : IntSet.elt list -> IntSet.t = +# let s1 = from_list [1;2;3;4;3];; +val s1 : IntSet.t = +# IntSet.elements s1;; +- : IntSet.elt list = [1; 2; 3; 4] +# let s2 = from_list [3;4;5;6];; +val s2 : IntSet.t = +# IntSet.elements s2;; +- : IntSet.elt list = [3; 4; 5; 6] +# IntSet.elements (IntSet.union s1 s2);; (* Union *) +- : IntSet.elt list = [1; 2; 3; 4; 5; 6] +# IntSet.elements (IntSet.inter s1 s2);; (* Intersection *) +- : IntSet.elt list = [3; 4] +# IntSet.elements (IntSet.diff s1 s2);; (* Difference *) +- : IntSet.elt list = [1; 2] +# IntSet.subset s1 s1;; (* Subset *) +- : bool = true +# IntSet.subset (from_list [3;1]) s1;; +- : bool = true +# IntSet.equal (from_list [3;2;4;1]) s1;; (* Equality *) +- : bool = true +# IntSet.equal s1 s2;; +- : bool = false +# IntSet.mem 2 s1;; (* Membership *) +- : bool = true +# IntSet.mem 10 s1;; +- : bool = false +# IntSet.cardinal s1;; (* Cardinality *) +- : int = 4 +# IntSet.elements (IntSet.add 99 s1);; (* Create a new set by inserting *) +- : IntSet.elt list = [1; 2; 3; 4; 99] +# IntSet.elements (IntSet.remove 3 s1);; (* Create a new set by deleting *) +- : IntSet.elt list = [1; 2; 4] diff --git a/Task/Set/Objective-C/set.m b/Task/Set/Objective-C/set.m new file mode 100644 index 0000000000..23782b0168 --- /dev/null +++ b/Task/Set/Objective-C/set.m @@ -0,0 +1,57 @@ +#import + +int main (int argc, const char *argv[]) { + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + + NSSet *s1 = [NSSet setWithObjects:@"a", @"b", @"c", @"d", @"e", nil]; + NSSet *s2 = [NSSet setWithObjects:@"b", @"c", @"d", @"e", @"f", @"h", nil]; + NSSet *s3 = [NSSet setWithObjects:@"b", @"c", @"d", nil]; + NSSet *s4 = [NSSet setWithObjects:@"b", @"c", @"d", nil]; + NSLog(@"s1: %@", s1); + NSLog(@"s2: %@", s2); + NSLog(@"s3: %@", s3); + NSLog(@"s4: %@", s4); + + // Membership + NSLog(@"b in s1: %d", [s1 containsObject:@"b"]); + NSLog(@"f in s1: %d", [s1 containsObject:@"f"]); + + // Union + NSMutableSet *s12 = [NSMutableSet setWithSet:s1]; + [s12 unionSet:s2]; + NSLog(@"s1 union s2: %@", s12); + + // Intersection + NSMutableSet *s1i2 = [NSMutableSet setWithSet:s1]; + [s1i2 intersectSet:s2]; + NSLog(@"s1 intersect s2: %@", s1i2); + + // Difference + NSMutableSet *s1_2 = [NSMutableSet setWithSet:s1]; + [s1_2 minusSet:s2]; + NSLog(@"s1 - s2: %@", s1_2); + + // Subset of + NSLog(@"s3 subset of s1: %d", [s3 isSubsetOfSet:s1]); + + // Equality + NSLog(@"s3 = s4: %d", [s3 isEqualToSet:s4]); + + // Cardinality + NSLog(@"size of s1: %lu", [s1 count]); + + // Has intersection (not disjoint) + NSLog(@"does s1 intersect s2? %d", [s1 intersectsSet:s2]); + + // Adding and removing elements from a mutable set + NSMutableSet *mut_s1 = [NSMutableSet setWithSet:s1]; + [mut_s1 addObject:@"g"]; + NSLog(@"mut_s1 after adding g: %@", mut_s1); + [mut_s1 addObject:@"b"]; + NSLog(@"mut_s1 after adding b again: %@", mut_s1); + [mut_s1 removeObject:@"c"]; + NSLog(@"mut_s1 after removing c: %@", mut_s1); + + [pool release]; + return 0; +} diff --git a/Task/Set/PARI-GP/set.pari b/Task/Set/PARI-GP/set.pari new file mode 100644 index 0000000000..6517ff7621 --- /dev/null +++ b/Task/Set/PARI-GP/set.pari @@ -0,0 +1,14 @@ +setsubset(s,t)={ + for(i=1,#s, + if(!setsearch(t,s[i]), return(0)) + ); + 1 +}; +s=Set([1,2,2]) +t=Set([4,2,4]) +setsearch(s,1) +setunion(s,t) +setintersect(s,t) +setminus(s,t) +setsubset(s,t) +s==t diff --git a/Task/Set/Pascal/set.pascal b/Task/Set/Pascal/set.pascal new file mode 100644 index 0000000000..f844045c84 --- /dev/null +++ b/Task/Set/Pascal/set.pascal @@ -0,0 +1,94 @@ +program Rosetta_Set; + +{$mode objfpc}{$H+} + +uses {$IFDEF UNIX} {$IFDEF UseCThreads} + cthreads, {$ENDIF} {$ENDIF} + Classes; + +{$R *.res} +type + CharSet = set of char; + +var + A, B, C, S: CharSet; + M: char; + + function SetToString(const ASet: CharSet): string; + var + J: char; + begin + Result := ''; + // Test all chars + for J in char do + // If the char is in set, add to result + if J in ASet then + Result := Result + J + ', '; + // Clear the result + if Result > '' then + Delete(Result, Length(Result) - 1, 2); + end; + + procedure PrintSet(const ASet: CharSet; const ASetName: string; + const ATitle: string = ''); + begin + if ATitle > '' then + WriteLn(ATitle); + WriteLn(ASetName, ' = [', SetToString(ASet), ']', #10); + end; + + procedure ShowEqual(const ASetA, ASetB: CharSet; const ASetNameA, ASetNameB: string); + begin + WriteLn(ASetNameA, ' = [', SetToString(ASetA), ']'); + WriteLn(ASetNameB, ' = [', SetToString(ASetB), ']'); + if ASetA = ASetB then + WriteLn(ASetNameA, ' = ', ASetNameB) + else + WriteLn(ASetNameA, ' <> ', ASetNameB); + end; + + +begin + // Set Creation + A := ['A', 'B', 'C', 'D', 'E', 'F']; + B := ['E', 'F', 'G', 'H', 'I', 'J']; + PrintSet(A, 'A', 'Set Creation'); + PrintSet(B, 'B'); + + // Test m ∈ S -- "m is an element in set S" + M := 'A'; + if M in A then + WriteLn('"A" is in set A'); + + // A ∪ B -- union; a set of all elements either in set A or in set B. + S := A + B; + PrintSet(S, 'S', 'S = A U B -- union; a set of all elements either in set A or in set B.'); + + // A ∩ B -- intersection; a set of all elements in both set A and set B. + S := A * B; + PrintSet(S, 'S', + 'S = A ∩ B -- intersection; a set of all elements in both set A and set B.'); + + // A \ B -- difference; a set of all elements in set A, except those in set B. + S := A - B; + PrintSet(S, 'S', + 'S = A \ B -- difference; a set of all elements in set A, except those in set B.'); + + // A ⊆ B -- subset; true if every element in set A is also in set B. + Writeln('A ⊆ B -- subset; true if every element in set A is also in set B.'); + if A <= B then + WriteLn('A in B') + else + Writeln('A is not in B'); + Writeln; + //A = B -- equality; true if every element of set A is in set B and vice-versa. + Writeln('A = B -- equality; true if every element of set A is in set B and vice-versa.'); + + ShowEqual(A, B, 'A', 'B'); + S := A * B; + C := ['E', 'F']; + ShowEqual(S, C, 'S', 'C'); + + readln; + +end. diff --git a/Task/Set/Perl-6/set.pl6 b/Task/Set/Perl-6/set.pl6 new file mode 100644 index 0000000000..5eb19a80e7 --- /dev/null +++ b/Task/Set/Perl-6/set.pl6 @@ -0,0 +1,19 @@ +use Test; + +my $a = set
    ; +my $b = set ; +my $c = set ; + +ok 'c' ∈ $a, "c is an element in set A"; +nok 'd' ∈ $a, "d is not an element in set A"; + +is $a ∪ $b, set(), "union; a set of all elements either in set A or in set B"; +is $a ∩ $b, set(), "intersection; a set of all elements in both set A and set B"; +is $a (-) $b, set(), "difference; a set of all elements in set A, except those in set B"; + +ok $a ⊆ $c, "subset; true if every element in set A is also in set B"; +nok $c ⊆ $a, "subset; false if every element in set A is not also in set B"; +ok $a ⊂ $c, "strict subset; true if every element in set A is also in set B"; +nok $a ⊂ $a, "strict subset; false for equal sets"; +ok $a === set(), "equality; true if every element of set A is in set B and vice-versa"; +nok $a === $b, "equality; false for differing sets"; diff --git a/Task/Set/Perl/set.pl b/Task/Set/Perl/set.pl new file mode 100644 index 0000000000..c573a3ff3c --- /dev/null +++ b/Task/Set/Perl/set.pl @@ -0,0 +1,113 @@ +use strict; + +package Set; # likely will conflict with stuff on CPAN +use overload + '""' => \&str, + 'bool' => \&count, + '+=' => \&add, + '-=' => \&del, + '-' => \&diff, + '==' => \&eq, + '&' => \&intersection, + '|' => \&union, + '^' => \&xdiff; + +sub str { + my $set = shift; + # This has drawbacks: stringification is used as set key + # if the set is added to another set as an element, which + # may cause inconsistencies if the element set is modified + # later. In general, a hash key loses its object identity + # anyway, so it's not unique to us. + "Set{ ". join(", " => sort map("$_", values %$set)) . " }" +} + +sub new { + my $pkg = shift; + my $h = bless {}; + $h->add($_) for @_; + $h +} + +sub add { + my ($set, $elem) = @_; + $set->{$elem} = $elem; + $set +} + +sub del { + my ($set, $elem) = @_; + delete $set->{$elem}; + $set +} + +sub has { # set has element + my ($set, $elem) = @_; + exists $set->{$elem} +} + +sub union { + my ($this, $that) = @_; + bless { %$this, %$that } +} + +sub intersection { + my ($this, $that) = @_; + my $s = new Set; + for (keys %$this) { + $s->{$_} = $this->{$_} if exists $that->{$_} + } + $s +} + +sub diff { + my ($this, $that) = @_; + my $s = Set->new; + for (keys %$this) { + $s += $this->{$_} unless exists $that->{$_} + } + $s +} + +sub xdiff { # xor, symmetric diff + my ($this, $that) = @_; + my $s = new Set; + bless { %{ ($this - $that) | ($that - $this) } } +} + +sub count { scalar(keys %{+shift}) } + +sub eq { + my ($this, $that) = @_; + !($this - $that) && !($that - $this); +} + +sub contains { # this is a superset of that + my ($this, $that) = @_; + for (keys %$that) { + return 0 unless $this->has($_) + } + return 1 +} + +package main; +my ($x, $y, $z, $w); + +$x = Set->new(1, 2, 3); +$x += $_ for (5 .. 7); +$y = Set->new(1, 2, 4, $x); # not the brightest idea + +print "set x is: $x\nset y is: $y\n"; +for (1 .. 4, $x) { + print "$_ is", $y->has($_) ? "" : " not", " in y\n"; +} + +print "union: ", $x | $y, "\n"; +print "intersect: ", $x & $y, "\n"; +print "z = x - y = ", $z = $x - $y, "\n"; +print "y is ", $x->contains($y) ? "" : "not ", "a subset of x\n"; +print "z is ", $x->contains($z) ? "" : "not ", "a subset of x\n"; +print "z = (x | y) - (x & y) = ", $z = ($x | $y) - ($x & $y), "\n"; +print "w = x ^ y = ", $w = ($x ^ $y), "\n"; +print "w is ", ($w == $z) ? "" : "not ", "equal to z\n"; +print "w is ", ($w == $x) ? "" : "not ", "equal to x\n"; diff --git a/Task/Set/PicoLisp/set-1.l b/Task/Set/PicoLisp/set-1.l new file mode 100644 index 0000000000..c99224ce77 --- /dev/null +++ b/Task/Set/PicoLisp/set-1.l @@ -0,0 +1,46 @@ +(setq + Set1 (1 2 3 7 abc "def" (u v w)) + Set2 (2 3 5 hello (x y z)) + Set3 (3 hello (x y z)) ) + + +# Element tests (any non-NIL value means "yes") +: (member "def" Set1) +-> ("def" (u v w)) + +: (member "def" Set2) +-> NIL + +: (member '(x y z) Set2) +-> ((x y z)) + + +# Union +: (uniq (append Set1 Set2)) +-> (1 2 3 7 abc "def" (u v w) 5 hello (x y z)) + + +# Intersection +: (sect Set1 Set2) +-> (2 3) + + +# Difference +: (diff Set1 Set2) +-> (1 7 abc "def" (u v w)) + + +# Test for subset +: (not (diff Set1 Set2)) +-> NIL # Set1 is not a subset of Set2 + +: (not (diff Set3 Set2)) +-> T # Set3 is a subset of Set2 + + +# Test for equality +: (= (sort (copy Set1)) (sort (copy Set2))) +-> NIL + +: (= (sort (copy Set2)) (sort (copy Set2))) +-> T diff --git a/Task/Set/PicoLisp/set-2.l b/Task/Set/PicoLisp/set-2.l new file mode 100644 index 0000000000..12c91b42db --- /dev/null +++ b/Task/Set/PicoLisp/set-2.l @@ -0,0 +1,57 @@ +# Create three test-sets +(balance 'Set1 (1 2 3 7 abc "def" (u v w))) +(balance 'Set2 (2 3 5 hello (x y z))) +(balance 'Set3 (3 hello (x y z))) + + +# Get contents +: (idx 'Set1) +-> (1 2 3 7 abc "def" (u v w)) + +: (idx 'Set2) +-> (2 3 5 hello (x y z)) + + +# Element tests (any non-NIL value means "yes") +: (idx 'Set1 "def") +-> ("def" (abc) (u v w)) + +: (idx 'Set2 "def") +-> NIL + +: (idx 'Set2 '(x y z)) +-> ((x y z)) + + +# Union +: (use S + (balance 'S (idx 'Set1)) + (balance 'S (idx 'Set2) T) + (idx 'S) ) +-> (1 2 3 5 7 abc "def" hello (u v w) (x y z)) + + +# Intersection +: (sect (idx 'Set1) (idx 'Set2)) +-> (2 3) + + +# Difference +: (diff (idx 'Set1) (idx 'Set2)) +-> (1 7 abc "def" (u v w)) + + +# Test for subset +: (not (diff (idx 'Set1) (idx 'Set2))) +-> NIL # Set1 is not a subset of Set2 + +: (not (diff (idx 'Set3) (idx 'Set2))) +-> T # Set3 is a subset of Set2 + + +# Test for equality +: (= (idx 'Set1) (idx 'Set2)) +-> NIL + +: (= (idx 'Set2) (idx 'Set2)) +-> T diff --git a/Task/Set/Prolog/set.pro b/Task/Set/Prolog/set.pro new file mode 100644 index 0000000000..56bb628cb7 --- /dev/null +++ b/Task/Set/Prolog/set.pro @@ -0,0 +1,49 @@ +:- use_module(library(lists)). + +set :- + A = [2, 4, 1, 3], + B = [5, 2, 3, 2], + ( is_set(A) -> format('~w is a set~n', [A]) + ; format('~w is not a set~n', [A])), + ( is_set(B) -> format('~w is a set~n', [B]) + ; format('~w is not a set~n', [B])), + + % create a set from a list + + list_to_set(B, BS), + ( is_set(BS) -> format('~nCreate a set from a list~n~w is a set~n', [BS]) + ; format('~w is not a set~n', [BS])), + + intersection(A, BS, I), + format('~n~w intersection ~w => ~w~n', [A, BS, I]), + union(A, BS, U), + format('~w union ~w => ~w~n', [A, BS, U]), + difference(A, BS, D), + format('~w difference ~w => ~w~n', [A, BS, D]), + + X = [1,2], + ( subset(X, A) -> format('~n~w is a subset of ~w~n', [X, A]) + ; format('~w is not a subset of ~w~n', [X, A])), + Y = [1,5], + ( subset(Y, A) -> format('~w is a subset of ~w~n', [Y, A]) + ; format('~w is not a subset of ~w~n', [Y, A])), + Z = [1, 2, 3, 4], + ( equal(Z, A) -> format('~n~w is equal to ~w~n', [Z, A]) + ; format('~w is not equal to ~w~n', [Z, A])), + T = [1, 2, 3], + ( equal(T, A) -> format('~w is equal to ~w~n', [T, A]) + ; format('~w is not equal to ~w~n', [T, A])). + + + +% compute difference of sets +difference(A, B, D) :- + exclude(member_(B), A, D). + +member_(L, X) :- + member(X, L). + +equal([], []). +equal([H1 | T1], B) :- + select(H1, B, B1), + equal(T1, B1). diff --git a/Task/Set/PureBasic/set.purebasic b/Task/Set/PureBasic/set.purebasic new file mode 100644 index 0000000000..47e7e42b32 --- /dev/null +++ b/Task/Set/PureBasic/set.purebasic @@ -0,0 +1,170 @@ +Procedure.s booleanText(b) ;returns 'True' or 'False' for a boolean input + If b: ProcedureReturn "True": EndIf + ProcedureReturn "False" +EndProcedure + +Procedure.s listSetElements(Map a(), delimeter.s = " ") ;format elements for display + Protected output$ + + ForEach a() + output$ + MapKey(a()) + delimeter + Next + + ProcedureReturn "(" + RTrim(output$, delimeter) + ")" +EndProcedure + +Procedure.s listSortedSetElements(Map a(), delimeter.s = " ") ;format elements for display as sorted for easy comparison + Protected output$ + NewList b.s() + + ForEach a() + AddElement(b()): b() = MapKey(a()) + Next + SortList(b(), #PB_Sort_Ascending | #PB_Sort_NoCase) + ForEach b() + output$ + b() + delimeter + Next + + ProcedureReturn "(" + RTrim(output$, delimeter) + ")" +EndProcedure + +Procedure cardinalityOf(Map a()) + ProcedureReturn MapSize(a()) +EndProcedure + +Procedure createSet(elements.s, Map o(), delimeter.s = " ", clearSet = 1) + Protected i, elementCount + + If clearSet: ClearMap(o()): EndIf + elementCount = CountString(elements, delimeter) + 1 ;add one for the last element which won't have a delimeter + For i = 1 To elementCount + AddMapElement(o(), StringField(elements, i, delimeter)) + Next + + ProcedureReturn MapSize(o()) +EndProcedure + +Procedure adjoinTo(elements.s, Map o(), delimeter.s = " ") + ProcedureReturn createSet(elements, o(), delimeter, 0) +EndProcedure + +Procedure disjoinFrom(elements.s, Map o(), delimeter.s = " ") + Protected i, elementCount + + elementCount = CountString(elements, delimeter) + 1 ;add one for the last element which won't have a delimeter + For i = 1 To elementCount + DeleteMapElement(o(), StringField(elements, i, delimeter)) + Next + + ProcedureReturn MapSize(o()) +EndProcedure + +Procedure isElementOf(element.s, Map a()) + ProcedureReturn FindMapElement(a(), element) +EndProcedure + + + +Procedure unionOf(Map a(), Map b(), Map o()) + CopyMap(a(), o()) + ForEach b() + AddMapElement(o(), MapKey(b())) + Next + + ProcedureReturn MapSize(o()) +EndProcedure + +Procedure intersectionOf(Map a(), Map b(), Map o()) + ClearMap(o()) + ForEach a() + If FindMapElement(b(), MapKey(a())) + AddMapElement(o(), MapKey(a())) + EndIf + Next + + ProcedureReturn MapSize(o()) +EndProcedure + +Procedure differenceOf(Map a(), Map b(), Map o()) + CopyMap(a(), o()) + ForEach b() + If FindMapElement(o(), MapKey(b())) + DeleteMapElement(o()) + Else + AddMapElement(o(), MapKey(b())) + EndIf + Next + + ProcedureReturn MapSize(o()) +EndProcedure + +Procedure isSubsetOf(Map a(), Map b()) ;boolean + ForEach a() + If Not FindMapElement(b(), MapKey(a())) + ProcedureReturn 0 + EndIf + Next + ProcedureReturn 1 +EndProcedure + +Procedure isProperSubsetOf(Map a(), Map b()) ;boolean + If MapSize(a()) = MapSize(b()) + ProcedureReturn 0 + EndIf + ProcedureReturn isSubsetOf(a(), b()) +EndProcedure + +Procedure isEqualTo(Map a(), Map b()) + If MapSize(a()) = MapSize(b()) + ProcedureReturn isSubsetOf(a(), b()) + EndIf + ProcedureReturn 0 +EndProcedure + +Procedure isEmpty(Map a()) ;boolean + If MapSize(a()) + ProcedureReturn 0 + EndIf + ProcedureReturn 1 +EndProcedure + +If OpenConsole() + NewMap a() + NewMap b() + NewMap o() ;for output sets + NewMap c() + + createSet("red blue green orange yellow", a()) + PrintN("Set A = " + listSortedSetElements(a()) + " of cardinality " + Str(cardinalityOf(a())) + ".") + createSet("lady green red", b()) + PrintN("Set B = " + listSortedSetElements(b()) + " of cardinality " + Str(cardinalityOf(b())) + ".") + PrintN("'red' is an element of A is " + booleanText(isElementOf("red", a())) + ".") + PrintN("'red' is an element of B is " + booleanText(isElementOf("red", b())) + ".") + PrintN("'blue' is an element of B is " + booleanText(isElementOf("blue", b())) + ".") + + unionOf(a(), b(), o()) + PrintN(#crlf$ + "Union of A & B is " + listSortedSetElements(o()) + ".") + intersectionOf(a(), b(), o()) + PrintN("Intersection of A & B is " + listSortedSetElements(o()) + ".") + differenceOf(a(), b(), o()) + PrintN("Difference of A & B is " + listSortedSetElements(o()) + ".") + + PrintN(listSortedSetElements(a()) + " equals " + listSortedSetElements(a()) + " is " + booleanText(isEqualTo(a(), a())) + ".") + PrintN(listSortedSetElements(a()) + " equals " + listSortedSetElements(b()) + " is " + booleanText(isEqualTo(a(), b())) + ".") + + createSet("red green", c()) + PrintN(#crlf$ + listSortedSetElements(c()) + " is a subset of " + listSortedSetElements(a()) + " is "+ booleanText(isSubsetOf(c(), a())) + ".") + PrintN(listSortedSetElements(c()) + " is a proper subset of " + listSortedSetElements(b()) + " is "+ booleanText(isProperSubsetOf(c(), b())) + ".") + PrintN(listSortedSetElements(c()) + " is a proper subset of " + listSortedSetElements(a()) + " is "+ booleanText(isProperSubsetOf(c(), a())) + ".") + PrintN(listSortedSetElements(b()) + " is a proper subset of " + listSortedSetElements(b()) + " is "+ booleanText(isProperSubsetOf(b(), b())) + ".") + + PrintN(#crlf$ + "Set C = " + listSortedSetElements(c()) + " of cardinality " + Str(cardinalityOf(c())) + ".") + adjoinTo("dog cat mouse", c()) + PrintN("Add 'dog cat mouse' to C to get " + listSortedSetElements(c()) + " of cardinality " + Str(cardinalityOf(c())) + ".") + disjoinFrom("red green dog", c()) + PrintN("Take away 'red green dog' from C to get " + listSortedSetElements(c()) + " of cardinality " + Str(cardinalityOf(c())) + ".") + + + Print(#crlf$ + #crlf$ + "Press ENTER to exit"): Input() + CloseConsole() +EndIf diff --git a/Task/Set/Python/set.py b/Task/Set/Python/set.py new file mode 100644 index 0000000000..e9a892bff3 --- /dev/null +++ b/Task/Set/Python/set.py @@ -0,0 +1,49 @@ +>>> s1, s2 = {1, 2, 3, 4}, {3, 4, 5, 6} +>>> s1 | s2; # Union +{1, 2, 3, 4, 5, 6} +>>> s1 & s2; # Intersection +{3, 4} +>>> s1 - s2; # Difference +{1, 2} +>>> s1 < s1; # True subset +False +>>> {3, 1} < s1; # True subset +True +>>> s1 <= s1; # Subset +True +>>> {3, 1} <= s1; # Subset +True +>>> {3, 2, 4, 1} == s1; # Equality +True +>>> s1 == s2; # Equality +False +>>> 2 in s1; # Membership +True +>>> 10 not in s1; # Non-membership +True +>>> {1, 2, 3, 4, 5} > s1; # True superset +True +>>> {1, 2, 3, 4} > s1; # True superset +False +>>> {1, 2, 3, 4} >= s1; # Superset +True +>>> s1 ^ s2; # Symmetric difference +{1, 2, 5, 6} +>>> len(s1); # Cardinality +4 +>>> s1.add(99); # Mutability +>>> s1 +{99, 1, 2, 3, 4} +>>> s1.discard(99); # Mutability +>>> s1 +{1, 2, 3, 4} +>>> s1 |= s2; # Mutability +>>> s1 +{1, 2, 3, 4, 5, 6} +>>> s1 -= s2; # Mutability +>>> s1 +{1, 2} +>>> s1 ^= s2; # Mutability +>>> s1 +{1, 2, 3, 4, 5, 6} +>>> diff --git a/Task/Set/REXX/set.rexx b/Task/Set/REXX/set.rexx new file mode 100644 index 0000000000..8f18027a83 --- /dev/null +++ b/Task/Set/REXX/set.rexx @@ -0,0 +1,56 @@ +/*REXX program demonstrates some common SET functions. */ +truth.0='false'; truth.1='true' /*common names for truth table. */ +set.= /*order of sets isn't important. */ + +call setAdd 'prime',2 3 2 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 +call setSay 'prime' /*a small set of primes (numbers).*/ + +call setAdd 'emirp',97 97 89 83 79 73 71 67 61 59 53 47 43 41 37 31 29 23 19 17 13 11 7 5 3 2 +call setSay 'emirp' /*a small set of baclward primes. */ + +call setAdd 'happy',1 7 10 13 19 23 28 31 32 44 49 68 70 79 82 86 91 100 94 97 97 97 97 97 +call setSay 'happy' /*a small set of happy numbers. */ + + do j=11 to 100 by 10 /*see if PRIME contains some nums*/ + call setHas 'prime',j + say ' prime contains' j":" truth.result + end /*j*/ + +call setUnion 'prime','happy','eweion'; call setSay 'eweion' +call setCommon 'prime','happy','common'; call setSay 'common' +call setDiff 'prime','happy','diff' ; call setSay 'diff' +call setSubset 'prime','happy' ; say ' prime is a subset of happy:' truth.result +call setEqual 'prime','emirp' ; say ' prime is equal to emirp:' truth.result +exit /*stick a fork in it, we're done.*/ +/*──────────────────────────────────subroutines─────────────────────────*/ +setHas: procedure expose set.; arg _ .,! .;return wordpos(!,set._)\==0 +setAdd: return set$('add' ,arg(1),arg(2)) +setDiff: return set$('diff' ,arg(1),arg(2),arg(3)) +setSay: return set$('say' ,arg(1),arg(2)) +setUnion: return set$('union' ,arg(1),arg(2),arg(3)) +setCommon: return set$('common',arg(1),arg(2),arg(3)) +setEqual: return set$('equal' ,arg(1),arg(2)) +setSubset: return set$('subSet',arg(1),arg(2)) +/*──────────────────────────────────set$ subroutine─────────────────────*/ +set$: procedure expose set.; arg $,_1,_2,_3; set_=set._1; t=_3; s=t; !=1 +if $=='SAY' then do; say '[set.'_1"]="set._1; return set._1; end +if $=='UNION' then do + call set$ 'add',_3,set._1 + call set$ 'add',_3,set._2 + return set._3 + end +add=$=='ADD';common=$=='COMMON';diff=$=='DIFF';eq=$=='EQUAL';subset=$=='SUBSET' +if common | diff | eq | subset then s=_2 +if add then do; set_=_2; t=_1; s=_1; end + + do j=1 for words(set_); _=word(set_,j); has=wordpos(_,set.s)\==0 + if (add & \has) |, + (common & has) |, + (diff & \has) then set.t=space(set.t _) + if (eq | subset) & \has then return 0 + end /*j*/ + +if subset then return 1 +if eq then if arg()>3 then return 1 + else return set$('equal',_2,_1,1) +return set.t diff --git a/Task/Set/Racket/set.rkt b/Task/Set/Racket/set.rkt new file mode 100644 index 0000000000..26afe0a45d --- /dev/null +++ b/Task/Set/Racket/set.rkt @@ -0,0 +1,12 @@ +#lang racket + +(define A (set 1 2 3 4)) +(define B (set 3 4 5 6)) +(define C (set 4 5)) + +(set-union A B) ; gives (set 1 2 3 4 5 6) +(set-intersect A B) ; gives (set 3 4) +(set-subtract A B) ; gives (set 1 2) +(set=? A B) ; gives #f +(subset? C A) ; gives #f +(subset? C B) ; gives #t diff --git a/Task/Set/Ruby/set.rb b/Task/Set/Ruby/set.rb new file mode 100644 index 0000000000..ff9bba935f --- /dev/null +++ b/Task/Set/Ruby/set.rb @@ -0,0 +1,43 @@ +>> require 'set' +=> true +>> s1, s2 = Set[1, 2, 3, 4], [3, 4, 5, 6].to_set # different ways of creating a set +=> [#, #] +>> s1 | s2 # Union +=> # +>> s1 & s2 # Intersection +=> # +>> s1 - s2 # Difference +=> # +>> s1.proper_subset?(s1) # Proper subset +=> false +>> Set[3, 1].proper_subset?(s1) # Proper subset +=> true +>> s1.subset?(s1) # Subset +=> true +>> Set[3, 1].subset?(s1) # Subset +=> true +>> Set[3, 2, 4, 1] == s1 # Equality +=> true +>> s1 == s2 # Equality +=> false +>> s1.include?(2) # Membership +=> true +>> Set[1, 2, 3, 4, 5].proper_superset?(s1) # Proper superset +=> true +>> Set[1, 2, 3, 4].proper_superset?(s1) # Proper superset +=> false +>> Set[1, 2, 3, 4].superset?(s1) # Superset +=> true +>> s1 ^ s2 # Symmetric difference +=> # +>> s1.size # Cardinality +=> 4 +>> s1 << 99 # Mutability (or s1.add(99) ) +=> # +>> s1.delete(99) # Mutability +=> # +>> s1.merge(s2) # Mutability +=> # +>> s1.subtract(s2) # Mutability +=> # +>> diff --git a/Task/Set/Scala/set.scala b/Task/Set/Scala/set.scala new file mode 100644 index 0000000000..a0e54b3334 --- /dev/null +++ b/Task/Set/Scala/set.scala @@ -0,0 +1,10 @@ +object sets { + val set1 = Set(1,2,3,4,5) + val set2 = Set(3,5,7,9) + println(set1 contains 3) + println(set1 | set2) + println(set1 & set2) + println(set1 diff set2) + println(set1 subsetOf set2) + println(set1 == set2) +} diff --git a/Task/Set/Scheme/set.ss b/Task/Set/Scheme/set.ss new file mode 100644 index 0000000000..6735f13c9c --- /dev/null +++ b/Task/Set/Scheme/set.ss @@ -0,0 +1,43 @@ +(define (element? a lst) + (and (not (null? lst)) + (or (eq? a (car lst)) + (element? a (cdr lst))))) + +; util, not strictly needed +(define (uniq lst) + (if (null? lst) lst + (let ((a (car lst)) (b (cdr lst))) + (if (element? a b) + (uniq b) + (cons a (uniq b)))))) + +(define (intersection a b) + (cond ((null? a) '()) + ((null? b) '()) + (else + (append (intersection (cdr a) b) + (if (element? (car a) b) + (list (car a)) + '()))))) + +(define (union a b) + (if (null? a) b + (union (cdr a) + (if (element? (car a) b) + b + (cons (car a) b))))) + +(define (diff a b) ; a - b + (if (null? a) '() + (if (element? (car a) b) + (diff (cdr a) b) + (cons (car a) (diff (cdr a) b))))) + +(define (subset? a b) ; A ⊆ B + (if (null? a) #t + (and (element? (car a) b) + (subset? (cdr a) b)))) + +(define (set-eq? a b) + (and (subset? a b) + (subset? b a))) diff --git a/Task/Set/Seed7/set.seed7 b/Task/Set/Seed7/set.seed7 new file mode 100644 index 0000000000..c0460070b9 --- /dev/null +++ b/Task/Set/Seed7/set.seed7 @@ -0,0 +1,26 @@ +$ include "seed7_05.s7i"; + +const type: charSet is set of char; +enable_output(charSet); + +const proc: main is func + local + const charSet: A is {'A', 'B', 'C', 'D', 'E', 'F'}; + var charSet: B is charSet.value; + var char: m is 'A'; + begin + B := {'E', 'F', 'G', 'H', 'I', 'K'}; + incl(B, 'J'); # Add 'J' to set B + excl(B, 'K'); # Remove 'K' from set B + writeln("A: " <& A); + writeln("B: " <& B); + writeln("m: " <& m); + writeln("m in A -- m is an element in A: " <& m in A); + writeln("A | B -- union: " <& A | B); + writeln("A & B -- intersection: " <& A & B); + writeln("A - B -- difference: " <& A - B); + writeln("A >< B -- symmetric difference: " <& A >< B); + writeln("A <= A -- subset: " <& A <= A); + writeln("A < A -- proper subset: " <& A < A); + writeln("A = B -- equality: " <& A = B); + end func; diff --git a/Task/Set/Smalltalk/set.st b/Task/Set/Smalltalk/set.st new file mode 100644 index 0000000000..fbef628162 --- /dev/null +++ b/Task/Set/Smalltalk/set.st @@ -0,0 +1,20 @@ +#(1 2 3) asSet union: #(2 3 4) asSet. +"a Set(1 2 3 4)" + +#(1 2 3) asSet intersection: #(2 3 4) asSet. +"a Set(2 3)" + +#(1 2 3) asSet difference: #(2 3 4) asSet. +"a Set(1)" + +#(1 2 3) asSet includesAllOf: #(1 3) asSet. +"true" + +#(1 2 3) asSet includesAllOf: #(1 3 4) asSet. +"false" + +#(1 2 3) asSet = #(2 1 3) asSet. +"true" + +#(1 2 3) asSet = #(1 2 4) asSet. +"false" diff --git a/Task/Set/Tcl/set.tcl b/Task/Set/Tcl/set.tcl new file mode 100644 index 0000000000..e4c4eea3e0 --- /dev/null +++ b/Task/Set/Tcl/set.tcl @@ -0,0 +1,21 @@ +package require struct::set + +# Many ways to build sets +set s1 [list 1 2 3 4] +set s2 {3 4 5 6} +struct::set add s3 {2 3 4 3 2}; # $s3 will be proper set... +set item 5 + +puts "union: [struct::set union $s1 $s2]" +puts "intersection: [struct::set intersect $s1 $s2]" +puts "difference: [struct::set difference $s1 $s2]" +puts "membership predicate: [struct::set contains $s1 $item]" +puts "subset predicate: [struct::set subsetof $s1 $s2]"; # NB: not strict subset test! +puts "equality predicate: [struct::set equal $s1 $s2]" + +# Adding an element to a set (note that we pass in the name of the variable holding the set): +struct::set include s3 $item +# Removing an element from a set: +struct::set exclude s3 $item +# Getting the cardinality: +puts "cardinality: [struct::set size $s3]